openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.81 kB
JavaScript
//#region src/agents/harness/gateway-question-dispatch.ts
var QuestionDispatchRefusedError = class extends Error {
constructor(..._args) {
super(..._args);
this.name = "QuestionDispatchRefusedError";
}
};
/** A failed transport cannot release possibly committed input for another route. */
var QuestionAnswerUnconfirmedError = class extends Error {
constructor(cause) {
super("The question answer may have been accepted, but confirmation was lost. It was not sent again; check the conversation before retrying.", { cause });
this.name = "QuestionAnswerUnconfirmedError";
}
};
function resolveAgentQuestionGatewayCall(dispatcher) {
if (dispatcher && typeof dispatcher !== "function" && dispatcher.version !== 2) throw new Error("unsupported question dispatcher version");
return async (...args) => {
const [method, options, params, extra] = args;
if (typeof dispatcher === "function") {
if (extra?.dispatchAuthority?.kind === "source-bound") throw new QuestionDispatchRefusedError("source-bound question input requires the default or a version 2 dispatcher");
return args.length === 4 ? dispatcher(method, options, params, extra?.signal ? { signal: extra.signal } : void 0) : dispatcher(method, options, params);
}
if (dispatcher) return dispatcher.call({
method,
options,
params,
signal: extra?.signal,
authority: extra?.dispatchAuthority?.kind === "source-bound" ? {
kind: "source-bound",
assertCurrent: extra.dispatchAuthority.assertCurrent
} : { kind: "unscoped" }
});
const { callGatewayTool } = await import("./gateway-question-dispatch.runtime.js");
return callGatewayTool(method, options, params, extra);
};
}
//#endregion
export { QuestionDispatchRefusedError as n, resolveAgentQuestionGatewayCall as r, QuestionAnswerUnconfirmedError as t };