Tlon: move outbound session routing behind plugin boundary
This commit is contained in:
parent
de0285d8ea
commit
c03b0877d0
@ -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",
|
||||
|
||||
40
extensions/tlon/src/session-route.ts
Normal file
40
extensions/tlon/src/session-route.ts
Normal 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}`,
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user