mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 08:11:09 +00:00
* ACPX: keep plugin-local runtime installs out of dist * Gateway: harden ACP startup and service PATH * ACP: reinitialize error-state configured bindings * ACP: classify pre-turn runtime failures as session init failures * Plugins: move configured ACP routing behind channel seams * Telegram tests: align startup probe assertions after rebase * Discord: harden ACP configured binding recovery * ACP: recover Discord bindings after stale runtime exits * ACPX: replace dead sessions during ensure * Discord: harden ACP binding recovery * Discord: fix review follow-ups * ACP bindings: load channel snapshots across workspaces * ACP bindings: cache snapshot channel plugin resolution * Experiments: add ACP pluginification holy grail plan * Experiments: rename ACP pluginification plan doc * Experiments: drop old ACP pluginification doc path * ACP: move configured bindings behind plugin services * Experiments: update bindings capability architecture plan * Bindings: isolate configured binding routing and targets * Discord tests: fix runtime env helper path * Tests: fix channel binding CI regressions * Tests: normalize ACP workspace assertion on Windows * Bindings: isolate configured binding registry * Bindings: finish configured binding cleanup * Bindings: finish generic cleanup * Bindings: align runtime approval callbacks * ACP: delete residual bindings barrel * Bindings: restore legacy compatibility * Revert "Bindings: restore legacy compatibility" This reverts commit ac2ed68fa2426ecc874d68278c71c71ad363fcfe. * Tests: drop ACP route legacy helper names * Discord/ACP: fix binding regressions --------- Co-authored-by: Onur <2453968+osolmaz@users.noreply.github.com>
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import type { OpenClawConfig } from "../../config/config.js";
|
|
import type { ConversationRef } from "../../infra/outbound/session-binding-service.js";
|
|
import type { ResolvedAgentRoute } from "../../routing/resolve-route.js";
|
|
import { deriveLastRoutePolicy } from "../../routing/resolve-route.js";
|
|
import { resolveAgentIdFromSessionKey } from "../../routing/session-key.js";
|
|
import { resolveConfiguredBinding } from "./binding-registry.js";
|
|
import { ensureConfiguredBindingTargetReady } from "./binding-targets.js";
|
|
import type { ConfiguredBindingResolution } from "./binding-types.js";
|
|
|
|
export type ConfiguredBindingRouteResult = {
|
|
bindingResolution: ConfiguredBindingResolution | null;
|
|
route: ResolvedAgentRoute;
|
|
boundSessionKey?: string;
|
|
boundAgentId?: string;
|
|
};
|
|
|
|
type ConfiguredBindingRouteConversationInput =
|
|
| {
|
|
conversation: ConversationRef;
|
|
}
|
|
| {
|
|
channel: string;
|
|
accountId: string;
|
|
conversationId: string;
|
|
parentConversationId?: string;
|
|
};
|
|
|
|
function resolveConfiguredBindingConversationRef(
|
|
params: ConfiguredBindingRouteConversationInput,
|
|
): ConversationRef {
|
|
if ("conversation" in params) {
|
|
return params.conversation;
|
|
}
|
|
return {
|
|
channel: params.channel,
|
|
accountId: params.accountId,
|
|
conversationId: params.conversationId,
|
|
parentConversationId: params.parentConversationId,
|
|
};
|
|
}
|
|
|
|
export function resolveConfiguredBindingRoute(
|
|
params: {
|
|
cfg: OpenClawConfig;
|
|
route: ResolvedAgentRoute;
|
|
} & ConfiguredBindingRouteConversationInput,
|
|
): ConfiguredBindingRouteResult {
|
|
const bindingResolution =
|
|
resolveConfiguredBinding({
|
|
cfg: params.cfg,
|
|
conversation: resolveConfiguredBindingConversationRef(params),
|
|
}) ?? null;
|
|
if (!bindingResolution) {
|
|
return {
|
|
bindingResolution: null,
|
|
route: params.route,
|
|
};
|
|
}
|
|
|
|
const boundSessionKey = bindingResolution.statefulTarget.sessionKey.trim();
|
|
if (!boundSessionKey) {
|
|
return {
|
|
bindingResolution,
|
|
route: params.route,
|
|
};
|
|
}
|
|
const boundAgentId =
|
|
resolveAgentIdFromSessionKey(boundSessionKey) || bindingResolution.statefulTarget.agentId;
|
|
return {
|
|
bindingResolution,
|
|
boundSessionKey,
|
|
boundAgentId,
|
|
route: {
|
|
...params.route,
|
|
sessionKey: boundSessionKey,
|
|
agentId: boundAgentId,
|
|
lastRoutePolicy: deriveLastRoutePolicy({
|
|
sessionKey: boundSessionKey,
|
|
mainSessionKey: params.route.mainSessionKey,
|
|
}),
|
|
matchedBy: "binding.channel",
|
|
},
|
|
};
|
|
}
|
|
|
|
export async function ensureConfiguredBindingRouteReady(params: {
|
|
cfg: OpenClawConfig;
|
|
bindingResolution: ConfiguredBindingResolution | null;
|
|
}): Promise<{ ok: true } | { ok: false; error: string }> {
|
|
return await ensureConfiguredBindingTargetReady(params);
|
|
}
|