fix: align SDK wait and protocol contracts · openclaw/openclaw@29de89a
steipete
·
2026-04-30
·
via Recent Commits to openclaw:main
File tree
macos/Sources/OpenClawProtocol
shared/OpenClawKit/Sources/OpenClawProtocol
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1851,11 +1851,11 @@ public struct SessionsMessagesUnsubscribeParams: Codable, Sendable {
|
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | public struct SessionsAbortParams: Codable, Sendable { |
1854 | | -public let key: String |
| 1854 | +public let key: String? |
1855 | 1855 | public let runid: String? |
1856 | 1856 | |
1857 | 1857 | public init( |
1858 | | - key: String, |
| 1858 | + key: String?, |
1859 | 1859 | runid: String?) |
1860 | 1860 | { |
1861 | 1861 | self.key = key |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1851,11 +1851,11 @@ public struct SessionsMessagesUnsubscribeParams: Codable, Sendable {
|
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | public struct SessionsAbortParams: Codable, Sendable { |
1854 | | -public let key: String |
| 1854 | +public let key: String? |
1855 | 1855 | public let runid: String? |
1856 | 1856 | |
1857 | 1857 | public init( |
1858 | | - key: String, |
| 1858 | + key: String?, |
1859 | 1859 | runid: String?) |
1860 | 1860 | { |
1861 | 1861 | self.key = key |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -146,7 +146,7 @@ have to parse `raw` for normal UI.
|
146 | 146 | ```typescript |
147 | 147 | type RunResult = { |
148 | 148 | runId: string; |
149 | | - status: "completed" | "failed" | "cancelled" | "timed_out"; |
| 149 | + status: "accepted" | "completed" | "failed" | "cancelled" | "timed_out"; |
150 | 150 | sessionId?: string; |
151 | 151 | sessionKey?: string; |
152 | 152 | taskId?: string; |
@@ -172,6 +172,11 @@ shape, so current lifecycle-backed runs usually report epoch millisecond
|
172 | 172 | numbers while adapters may still surface ISO strings. Rich UI, tool traces, and |
173 | 173 | runtime-native details belong in events and artifacts. |
174 | 174 | |
| 175 | +`accepted` is a non-terminal wait result: it means the Gateway wait deadline |
| 176 | +expired before the run produced a lifecycle end/error. It must not be treated as |
| 177 | +`timed_out`; `timed_out` is reserved for a run that exceeded its own runtime |
| 178 | +timeout. |
| 179 | + |
175 | 180 | ## Approvals and questions |
176 | 181 | |
177 | 182 | Approvals must be first-class because coding agents constantly cross safety |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,13 @@ function runStatusFromWaitPayload(payload: unknown): RunResult["status"] {
|
64 | 64 | if (status === "ok" || status === "completed" || status === "succeeded") { |
65 | 65 | return "completed"; |
66 | 66 | } |
67 | | -if (status === "timeout" || status === "timed_out") { |
| 67 | +if (status === "timeout") { |
| 68 | +if (stopReason === "timeout" || stopReason === "timed_out" || record.aborted === true) { |
| 69 | +return "timed_out"; |
| 70 | +} |
| 71 | +return "accepted"; |
| 72 | +} |
| 73 | +if (status === "timed_out") { |
68 | 74 | return "timed_out"; |
69 | 75 | } |
70 | 76 | if (status === "accepted") { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -136,6 +136,41 @@ describe("OpenClaw SDK", () => {
|
136 | 136 | }); |
137 | 137 | }); |
138 | 138 | |
| 139 | +it("keeps wait-only deadlines non-terminal", async () => { |
| 140 | +const transport = new FakeTransport({ |
| 141 | +"agent.wait": { status: "timeout", runId: "run_still_active" }, |
| 142 | +}); |
| 143 | +const oc = new OpenClaw({ transport }); |
| 144 | + |
| 145 | +const result = await oc.runs.wait("run_still_active"); |
| 146 | + |
| 147 | +expect(result).toMatchObject({ |
| 148 | +runId: "run_still_active", |
| 149 | +status: "accepted", |
| 150 | +}); |
| 151 | +expect(result.error).toBeUndefined(); |
| 152 | +}); |
| 153 | + |
| 154 | +it("maps terminal runtime timeout snapshots to timed_out", async () => { |
| 155 | +const transport = new FakeTransport({ |
| 156 | +"agent.wait": { |
| 157 | +status: "timeout", |
| 158 | +runId: "run_timed_out", |
| 159 | +stopReason: "timeout", |
| 160 | +error: "agent runtime timeout", |
| 161 | +}, |
| 162 | +}); |
| 163 | +const oc = new OpenClaw({ transport }); |
| 164 | + |
| 165 | +const result = await oc.runs.wait("run_timed_out"); |
| 166 | + |
| 167 | +expect(result).toMatchObject({ |
| 168 | +runId: "run_timed_out", |
| 169 | +status: "timed_out", |
| 170 | +error: { message: "agent runtime timeout" }, |
| 171 | +}); |
| 172 | +}); |
| 173 | + |
139 | 174 | it("splits provider-qualified model refs and rejects unsupported run options", async () => { |
140 | 175 | const transport = new FakeTransport({ |
141 | 176 | agent: { status: "accepted", runId: "run_openrouter" }, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。