fix: align gateway approval typings

This commit is contained in:
Ayaan Zaidi
2026-04-06 14:02:21 +05:30
parent 279f56e658
commit 0bfe6710a2
3 changed files with 14 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ export const APPROVAL_NOT_FOUND_DETAILS = {
type PendingApprovalLookupError =
| "missing"
| {
code: ErrorCodes.INVALID_REQUEST;
code: (typeof ErrorCodes)["INVALID_REQUEST"];
message: string;
};

View File

@@ -7,6 +7,7 @@ import {
DEFAULT_EXEC_APPROVAL_TIMEOUT_MS,
resolveExecApprovalAllowedDecisions,
resolveExecApprovalRequestAllowedDecisions,
type ExecApprovalDecision,
type ExecApprovalRequest,
type ExecApprovalResolved,
} from "../../infra/exec-approvals.js";
@@ -324,17 +325,18 @@ export function createExecApprovalHandlers(
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "invalid decision"));
return;
}
const decision: ExecApprovalDecision = p.decision;
await handleApprovalResolve({
manager,
inputId: p.id,
decision: p.decision,
decision,
respond,
context,
client,
exposeAmbiguousPrefixError: true,
validateDecision: (snapshot) => {
const allowedDecisions = resolveExecApprovalRequestAllowedDecisions(snapshot.request);
return allowedDecisions.includes(p.decision)
return allowedDecisions.includes(decision)
? null
: {
message:

View File

@@ -13,7 +13,15 @@ const mocks = vi.hoisted(() => ({
resolveOutboundSessionRoute: vi.fn(),
ensureOutboundSessionEntry: vi.fn(async () => undefined),
resolveMessageChannelSelection: vi.fn(),
sendPoll: vi.fn(async () => ({ messageId: "poll-1" })),
sendPoll: vi.fn<
() => Promise<{
messageId: string;
toJid?: string;
channelId?: string;
conversationId?: string;
pollId?: string;
}>
>(async () => ({ messageId: "poll-1" })),
getChannelPlugin: vi.fn(),
loadOpenClawPlugins: vi.fn(),
applyPluginAutoEnable: vi.fn(),