
























@@ -156,6 +156,23 @@ describe("OpenClaw SDK", () => {
156156expect(result.error?.message).toBe("aborted by operator");
157157});
158158159+it("maps restart wait snapshots to cancelled", async () => {
160+const transport = new FakeTransport({
161+"agent.wait": {
162+status: "timeout",
163+runId: "run_restart",
164+stopReason: "restart",
165+providerStarted: true,
166+},
167+});
168+const oc = new OpenClaw({ transport });
169+170+const result = await oc.runs.wait("run_restart");
171+172+expect(result.runId).toBe("run_restart");
173+expect(result.status).toBe("cancelled");
174+});
175+159176it("maps provider-started rpc timeout wait snapshots to timed_out", async () => {
160177const transport = new FakeTransport({
161178"agent.wait": {
@@ -1209,9 +1226,57 @@ describe("OpenClaw SDK", () => {
12091226expect(cancelled.runId).toBe("run_1");
12101227expect(cancelled.data).toEqual({ phase: "end", aborted: true, stopReason: "rpc" });
121112281212-const hardTimeout = normalizeGatewayEvent({
1229+const restartCancelled = normalizeGatewayEvent({
12131230event: "agent",
12141231seq: 6,
1232+payload: {
1233+runId: "run_1",
1234+stream: "lifecycle",
1235+ ts,
1236+data: {
1237+phase: "end",
1238+aborted: true,
1239+stopReason: "restart",
1240+providerStarted: true,
1241+},
1242+},
1243+});
1244+expect(restartCancelled.type).toBe("run.cancelled");
1245+expect(restartCancelled.runId).toBe("run_1");
1246+expect(restartCancelled.data).toEqual({
1247+phase: "end",
1248+aborted: true,
1249+stopReason: "restart",
1250+providerStarted: true,
1251+});
1252+1253+const restartErrorCancelled = normalizeGatewayEvent({
1254+event: "agent",
1255+seq: 7,
1256+payload: {
1257+runId: "run_1",
1258+stream: "lifecycle",
1259+ ts,
1260+data: {
1261+phase: "error",
1262+aborted: true,
1263+stopReason: "restart",
1264+error: "agent run aborted for restart",
1265+},
1266+},
1267+});
1268+expect(restartErrorCancelled.type).toBe("run.cancelled");
1269+expect(restartErrorCancelled.runId).toBe("run_1");
1270+expect(restartErrorCancelled.data).toEqual({
1271+phase: "error",
1272+aborted: true,
1273+stopReason: "restart",
1274+error: "agent run aborted for restart",
1275+});
1276+1277+const hardTimeout = normalizeGatewayEvent({
1278+event: "agent",
1279+seq: 8,
12151280payload: {
12161281runId: "run_1",
12171282stream: "lifecycle",
@@ -1237,7 +1302,7 @@ describe("OpenClaw SDK", () => {
1237130212381303const hardTimeoutError = normalizeGatewayEvent({
12391304event: "agent",
1240-seq: 7,
1305+seq: 9,
12411306payload: {
12421307runId: "run_1",
12431308stream: "lifecycle",
@@ -1261,7 +1326,7 @@ describe("OpenClaw SDK", () => {
1261132612621327const providerStartedError = normalizeGatewayEvent({
12631328event: "agent",
1264-seq: 8,
1329+seq: 10,
12651330payload: {
12661331runId: "run_1",
12671332stream: "lifecycle",
@@ -1283,7 +1348,7 @@ describe("OpenClaw SDK", () => {
1283134812841349const hardTimeoutEnd = normalizeGatewayEvent({
12851350event: "agent",
1286-seq: 9,
1351+seq: 11,
12871352payload: {
12881353runId: "run_1",
12891354stream: "lifecycle",
@@ -1305,7 +1370,7 @@ describe("OpenClaw SDK", () => {
1305137013061371const providerStartedEnd = normalizeGatewayEvent({
13071372event: "agent",
1308-seq: 10,
1373+seq: 12,
13091374payload: {
13101375runId: "run_1",
13111376stream: "lifecycle",
@@ -1325,7 +1390,7 @@ describe("OpenClaw SDK", () => {
1325139013261391const authRevoked = normalizeGatewayEvent({
13271392event: "agent",
1328-seq: 10,
1393+seq: 13,
13291394payload: {
13301395runId: "run_1",
13311396stream: "lifecycle",
@@ -1343,7 +1408,7 @@ describe("OpenClaw SDK", () => {
1343140813441409const timedOut = normalizeGatewayEvent({
13451410event: "agent",
1346-seq: 11,
1411+seq: 14,
13471412payload: {
13481413runId: "run_1",
13491414stream: "lifecycle",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。