diff --git a/src/commands/agents.binding-format.ts b/src/commands/agents.binding-format.ts new file mode 100644 index 00000000000..fdf55a23749 --- /dev/null +++ b/src/commands/agents.binding-format.ts @@ -0,0 +1,19 @@ +import type { AgentRouteBinding } from "../config/types.js"; + +export function describeBinding(binding: AgentRouteBinding): string { + const match = binding.match; + const parts = [match.channel]; + if (match.accountId) { + parts.push(`accountId=${match.accountId}`); + } + if (match.peer) { + parts.push(`peer=${match.peer.kind}:${match.peer.id}`); + } + if (match.guildId) { + parts.push(`guild=${match.guildId}`); + } + if (match.teamId) { + parts.push(`team=${match.teamId}`); + } + return parts.join(" "); +} diff --git a/src/commands/agents.bindings.ts b/src/commands/agents.bindings.ts index 5f86e54630f..20acd54f5f4 100644 --- a/src/commands/agents.bindings.ts +++ b/src/commands/agents.bindings.ts @@ -9,6 +9,8 @@ import { normalizeOptionalString } from "../shared/string-coerce.js"; import { normalizeStringEntries } from "../shared/string-normalization.js"; import type { ChannelChoice } from "./onboard-types.js"; +export { describeBinding } from "./agents.binding-format.js"; + function bindingMatchKey(match: AgentRouteBinding["match"]) { const accountId = normalizeOptionalString(match.accountId) || DEFAULT_ACCOUNT_ID; const identityKey = bindingMatchIdentityKey(match); @@ -49,24 +51,6 @@ function canUpgradeBindingAccountScope(params: { ); } -export function describeBinding(binding: AgentRouteBinding) { - const match = binding.match; - const parts = [match.channel]; - if (match.accountId) { - parts.push(`accountId=${match.accountId}`); - } - if (match.peer) { - parts.push(`peer=${match.peer.kind}:${match.peer.id}`); - } - if (match.guildId) { - parts.push(`guild=${match.guildId}`); - } - if (match.teamId) { - parts.push(`team=${match.teamId}`); - } - return parts.join(" "); -} - export function applyAgentBindings( cfg: OpenClawConfig, bindings: AgentRouteBinding[], diff --git a/src/commands/agents.commands.bind.ts b/src/commands/agents.commands.bind.ts index 7fa5af4215b..287bc616911 100644 --- a/src/commands/agents.commands.bind.ts +++ b/src/commands/agents.commands.bind.ts @@ -6,6 +6,7 @@ import type { AgentRouteBinding } from "../config/types.js"; import { normalizeAgentId } from "../routing/session-key.js"; import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; +import { describeBinding } from "./agents.binding-format.js"; import { requireValidConfig, requireValidConfigFileSnapshot } from "./agents.command-shared.js"; type AgentBindingsModule = typeof import("./agents.bindings.js"); @@ -35,24 +36,6 @@ function loadAgentBindingsModule(): Promise { return agentBindingsModulePromise; } -function describeBinding(binding: AgentRouteBinding): string { - const match = binding.match; - const parts = [match.channel]; - if (match.accountId) { - parts.push(`accountId=${match.accountId}`); - } - if (match.peer) { - parts.push(`peer=${match.peer.kind}:${match.peer.id}`); - } - if (match.guildId) { - parts.push(`guild=${match.guildId}`); - } - if (match.teamId) { - parts.push(`team=${match.teamId}`); - } - return parts.join(" "); -} - function resolveAgentId( cfg: Awaited>, agentInput: string | undefined,