fix(sdk): tighten approval response params · openclaw/openclaw@a635e97
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import type {
|
8 | 8 | AgentsDeleteParams, |
9 | 9 | AgentsUpdateParams, |
10 | 10 | AgentRunParams, |
| 11 | +ApprovalDecisionParams, |
11 | 12 | ArtifactQuery, |
12 | 13 | ArtifactsDownloadResult, |
13 | 14 | ArtifactsGetResult, |
@@ -909,8 +910,11 @@ export class ApprovalsNamespace {
|
909 | 910 | return await this.client.request("exec.approval.list", params === undefined ? {} : params); |
910 | 911 | } |
911 | 912 | |
912 | | -async respond(approvalId: string, decision: Record<string, unknown>): Promise<unknown> { |
913 | | -return await this.client.request("exec.approval.resolve", { ...decision, id: approvalId }); |
| 913 | +async respond(approvalId: string, params: ApprovalDecisionParams): Promise<unknown> { |
| 914 | +return await this.client.request("exec.approval.resolve", { |
| 915 | +id: approvalId, |
| 916 | +decision: params.decision, |
| 917 | +}); |
914 | 918 | } |
915 | 919 | } |
916 | 920 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -768,9 +768,10 @@ describe("OpenClaw SDK", () => {
|
768 | 768 | const oc = new OpenClaw({ transport }); |
769 | 769 | |
770 | 770 | await expect(oc.approvals.list()).resolves.toEqual({ approvals: [] }); |
771 | | -await expect( |
772 | | -oc.approvals.respond("approval-123", { id: "stale-approval", decision: "allow-once" }), |
773 | | -).resolves.toEqual({ ok: true }); |
| 771 | +const staleDecision = { id: "stale-approval", decision: "allow-once" as const }; |
| 772 | +await expect(oc.approvals.respond("approval-123", staleDecision)).resolves.toEqual({ |
| 773 | +ok: true, |
| 774 | +}); |
774 | 775 | |
775 | 776 | expect(transport.calls).toEqual([ |
776 | 777 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,7 @@ export type {
|
24 | 24 | AgentsDeleteParams, |
25 | 25 | AgentsUpdateParams, |
26 | 26 | AgentRunParams, |
| 27 | +ApprovalDecisionParams, |
27 | 28 | ApprovalMode, |
28 | 29 | ArtifactQuery, |
29 | 30 | ArtifactSummary, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -68,6 +68,10 @@ export type WorkspaceSelection = {
|
68 | 68 | |
69 | 69 | export type ApprovalMode = "ask" | "never" | "auto" | "trusted"; |
70 | 70 | |
| 71 | +export type ApprovalDecisionParams = { |
| 72 | +decision: "allow-once" | "allow-always" | "deny"; |
| 73 | +}; |
| 74 | + |
71 | 75 | /** Terminal and non-terminal status values returned by Run.wait. */ |
72 | 76 | export type RunStatus = "accepted" | "completed" | "failed" | "cancelled" | "timed_out"; |
73 | 77 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。