Tlon: move outbound session routing behind plugin boundary

This commit is contained in:
Gustavo Madeira Santana 2026-03-18 04:03:54 +00:00
parent de0285d8ea
commit c03b0877d0
No known key found for this signature in database
2 changed files with 42 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import type { ChannelAccountSnapshot, ChannelPlugin } from "openclaw/plugin-sdk/
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import { tlonChannelConfigSchema } from "./config-schema.js";
import { resolveTlonOutboundSessionRoute } from "./session-route.js";
import {
applyTlonSetupConfig,
createTlonSetupWizardBase,
@ -97,6 +98,7 @@ export const tlonPlugin: ChannelPlugin = {
looksLikeId: (target) => Boolean(parseTlonTarget(target)),
hint: formatTargetHint(),
},
resolveOutboundSessionRoute: (params) => resolveTlonOutboundSessionRoute(params),
},
outbound: {
deliveryMode: "direct",

View File

@ -0,0 +1,40 @@
import {
buildChannelOutboundSessionRoute,
type ChannelOutboundSessionRouteParams,
} from "openclaw/plugin-sdk/core";
import { parseTlonTarget } from "./targets.js";
export function resolveTlonOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
const parsed = parseTlonTarget(params.target);
if (!parsed) {
return null;
}
if (parsed.kind === "group") {
return buildChannelOutboundSessionRoute({
cfg: params.cfg,
agentId: params.agentId,
channel: "tlon",
accountId: params.accountId,
peer: {
kind: "group",
id: parsed.nest,
},
chatType: "group",
from: `tlon:group:${parsed.nest}`,
to: `tlon:${parsed.nest}`,
});
}
return buildChannelOutboundSessionRoute({
cfg: params.cfg,
agentId: params.agentId,
channel: "tlon",
accountId: params.accountId,
peer: {
kind: "direct",
id: parsed.ship,
},
chatType: "direct",
from: `tlon:${parsed.ship}`,
to: `tlon:${parsed.ship}`,
});
}