openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
129 lines (128 loc) • 5.19 kB
JavaScript
import { l as resolveSessionStorePathCore } from "./paths-DvQ5AJvD.mjs";
import { t as warnPluginSdkDeprecation } from "./sdk-deprecation-D5N9acnu.mjs";
import { o as readSessionUpdatedAtInWorker } from "./session-entry-read-runtime-1Fp1sybj.mjs";
import "./session-accessor-CizTbDQj.mjs";
import { o as readSessionUpdatedAtCore } from "./session-accessor.sqlite-entry-Da3xxVPX.mjs";
import { o as resolveAgentRoute } from "./resolve-route-DBnTWpM6.mjs";
import { a as resolveEnvelopeFormatOptions, t as formatAgentEnvelope } from "./envelope-C1e0Wmhj.mjs";
//#region src/channels/inbound-event/envelope.ts
/** @deprecated Await createChannelInboundEnvelopeBuilderAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function createChannelInboundEnvelopeBuilder(e) {
warnPluginSdkDeprecation({
family: "channel-inbound-envelope",
method: "createChannelInboundEnvelopeBuilder",
replacement: "await createChannelInboundEnvelopeBuilderAsync"
});
const t = resolveSessionStorePathCore(e.cfg.session?.store, { agentId: e.route.agentId });
return createEnvelopeFormatter(e.cfg, () => readSessionUpdatedAtCore({
storePath: t,
sessionKey: e.route.sessionKey
}));
}
/** Prepare once per inbound message; history formatting remains synchronous and SQL-free. */
async function createChannelInboundEnvelopeBuilderAsync(e) {
const t = resolveSessionStorePathCore(e.cfg.session?.store, { agentId: e.route.agentId });
const n = await readSessionUpdatedAtInWorker({
storePath: t,
sessionKey: e.route.sessionKey
});
return createEnvelopeFormatter(e.cfg, () => n);
}
function createEnvelopeFormatter(e, t) {
const n = resolveEnvelopeFormatOptions(e);
return (e) => {
const r = e.previousTimestamp === null ? void 0 : e.previousTimestamp ?? t();
return formatAgentEnvelope({
...e,
previousTimestamp: r,
envelope: e.envelope ?? n
});
};
}
/** @deprecated Use resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function resolveChannelInboundRouteEnvelope(e) {
warnPluginSdkDeprecation({
family: "channel-inbound-envelope",
method: "resolveChannelInboundRouteEnvelope",
replacement: "resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync"
});
const t = resolveAgentRoute(e);
return {
route: t,
buildEnvelope: createChannelInboundEnvelopeBuilder({
cfg: e.cfg,
route: t
})
};
}
/** @deprecated Await createChannelInboundEnvelopeBuilderAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function createInboundEnvelopeBuilder(e) {
warnPluginSdkDeprecation({
family: "channel-inbound-envelope",
method: "createInboundEnvelopeBuilder",
replacement: "await createChannelInboundEnvelopeBuilderAsync"
});
const t = e.resolveStorePath(e.sessionStore, { agentId: e.route.agentId });
const n = e.resolveEnvelopeFormatOptions(e.cfg);
return (r) => {
const i = e.readSessionUpdatedAt({
storePath: t,
sessionKey: e.route.sessionKey
});
const a = e.formatAgentEnvelope({
channel: r.channel,
from: r.from,
timestamp: r.timestamp,
previousTimestamp: i,
envelope: n,
body: r.body
});
return {
storePath: t,
body: a
};
};
}
/** @deprecated Use resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function resolveInboundRouteEnvelopeBuilder(e) {
warnPluginSdkDeprecation({
family: "channel-inbound-envelope",
method: "resolveInboundRouteEnvelopeBuilder",
replacement: "resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync"
});
const t = e.resolveAgentRoute({
cfg: e.cfg,
channel: e.channel,
accountId: e.accountId,
peer: e.peer
});
return {
route: t,
buildEnvelope: createInboundEnvelopeBuilder({
...e,
route: t
})
};
}
/** @deprecated Use resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function resolveInboundRouteEnvelopeBuilderWithRuntime(e) {
warnPluginSdkDeprecation({
family: "channel-inbound-envelope",
method: "resolveInboundRouteEnvelopeBuilderWithRuntime",
replacement: "resolveAgentRoute and await createChannelInboundEnvelopeBuilderAsync"
});
return resolveInboundRouteEnvelopeBuilder({
cfg: e.cfg,
channel: e.channel,
accountId: e.accountId,
peer: e.peer,
resolveAgentRoute: (t) => e.runtime.routing.resolveAgentRoute(t),
sessionStore: e.sessionStore,
resolveStorePath: e.runtime.session.resolveStorePath,
readSessionUpdatedAt: e.runtime.session.readSessionUpdatedAt,
resolveEnvelopeFormatOptions: e.runtime.reply.resolveEnvelopeFormatOptions,
formatAgentEnvelope: e.runtime.reply.formatAgentEnvelope
});
}
//#endregion
export { resolveInboundRouteEnvelopeBuilder as a, resolveChannelInboundRouteEnvelope as i, createChannelInboundEnvelopeBuilderAsync as n, resolveInboundRouteEnvelopeBuilderWithRuntime as o, createInboundEnvelopeBuilder as r, createChannelInboundEnvelopeBuilder as t };