Skip to content

Commit 42d7300

Browse files
committed
fix(gateway): document task ledger SDK surface
1 parent 4ef1022 commit 42d7300

5 files changed

Lines changed: 45 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
1313
- Telegram/Feishu: honor configured per-agent and global `reasoningDefault` values when deciding whether channel reasoning previews should stream or stay hidden, addressing the preview-default part of #73182. Thanks @anagnorisis2peripeteia.
1414
- Docker: run the runtime image under `tini` so long-lived containers reap orphaned child processes and forward signals correctly. (#77885) Thanks @VintageAyu.
1515
- Logging/redaction: redact quoted HTTP client secret fields and auth/cookie headers in shared log and formatted error output. Related #71211 and #65623. (#75033) Thanks @liaoandi.
16+
- Gateway/SDK: document and stabilize the task ledger RPC surface for `tasks.list`, `tasks.get`, and `tasks.cancel`, including generated Swift model typing for optional task summaries. Thanks @BunsDev.
1617
- Google/Gemini: normalize retired `google/gemini-3-pro-preview` and `google-gemini-cli/gemini-3-pro-preview` selections to `google/gemini-3.1-pro-preview` before they are written to model config.
1718
- Google/Gemini: emit canonical `google/gemini-3.1-pro-preview` ids from configured provider catalog rows so model list and selection paths can test Gemini 3.1 instead of retired Gemini 3 Pro.
1819
- Google/Gemini: normalize nested proxy-provider catalog ids like `google/gemini-3-pro-preview` to `google/gemini-3.1-pro-preview`, so Kilo-style configured catalogs test Gemini 3.1 instead of the retired Gemini 3 Pro id.

apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ public struct ResponseFrame: Codable, Sendable {
165165
public let id: String
166166
public let ok: Bool
167167
public let payload: AnyCodable?
168-
public let error: [String: AnyCodable]?
168+
public let error: ErrorShape?
169169

170170
public init(
171171
type: String,
172172
id: String,
173173
ok: Bool,
174174
payload: AnyCodable?,
175-
error: [String: AnyCodable]?)
175+
error: ErrorShape?)
176176
{
177177
self.type = type
178178
self.id = id
@@ -195,14 +195,14 @@ public struct EventFrame: Codable, Sendable {
195195
public let event: String
196196
public let payload: AnyCodable?
197197
public let seq: Int?
198-
public let stateversion: [String: AnyCodable]?
198+
public let stateversion: StateVersion?
199199

200200
public init(
201201
type: String,
202202
event: String,
203203
payload: AnyCodable?,
204204
seq: Int?,
205-
stateversion: [String: AnyCodable]?)
205+
stateversion: StateVersion?)
206206
{
207207
self.type = type
208208
self.event = event
@@ -2778,13 +2778,13 @@ public struct WizardStep: Codable, Sendable {
27782778

27792779
public struct WizardNextResult: Codable, Sendable {
27802780
public let done: Bool
2781-
public let step: [String: AnyCodable]?
2781+
public let step: WizardStep?
27822782
public let status: AnyCodable?
27832783
public let error: String?
27842784

27852785
public init(
27862786
done: Bool,
2787-
step: [String: AnyCodable]?,
2787+
step: WizardStep?,
27882788
status: AnyCodable?,
27892789
error: String?)
27902790
{
@@ -2805,14 +2805,14 @@ public struct WizardNextResult: Codable, Sendable {
28052805
public struct WizardStartResult: Codable, Sendable {
28062806
public let sessionid: String
28072807
public let done: Bool
2808-
public let step: [String: AnyCodable]?
2808+
public let step: WizardStep?
28092809
public let status: AnyCodable?
28102810
public let error: String?
28112811

28122812
public init(
28132813
sessionid: String,
28142814
done: Bool,
2815-
step: [String: AnyCodable]?,
2815+
step: WizardStep?,
28162816
status: AnyCodable?,
28172817
error: String?)
28182818
{
@@ -4755,7 +4755,7 @@ public struct ToolsInvokeResult: Codable, Sendable {
47554755
public let requiresapproval: Bool?
47564756
public let approvalid: String?
47574757
public let source: AnyCodable?
4758-
public let error: [String: AnyCodable]?
4758+
public let error: ToolsInvokeError?
47594759

47604760
public init(
47614761
ok: Bool,
@@ -4764,7 +4764,7 @@ public struct ToolsInvokeResult: Codable, Sendable {
47644764
requiresapproval: Bool?,
47654765
approvalid: String?,
47664766
source: AnyCodable?,
4767-
error: [String: AnyCodable]?)
4767+
error: ToolsInvokeError?)
47684768
{
47694769
self.ok = ok
47704770
self.toolname = toolname

docs/gateway/protocol.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ enumeration of `src/gateway/server-methods/*.ts`.
411411
- `agents.list` returns configured agent entries, including effective model and runtime metadata.
412412
- `agents.create`, `agents.update`, and `agents.delete` manage agent records and workspace wiring.
413413
- `agents.files.list`, `agents.files.get`, and `agents.files.set` manage the bootstrap workspace files exposed for an agent.
414+
- `tasks.list`, `tasks.get`, and `tasks.cancel` expose the Gateway task ledger to SDK and operator clients.
414415
- `artifacts.list`, `artifacts.get`, and `artifacts.download` expose transcript-derived artifact summaries and downloads for an explicit `sessionKey`, `runId`, or `taskId` scope. Run and task queries resolve the owning session server-side and only return transcript media with matching provenance; unsafe or local URL sources return unsupported downloads instead of fetching server-side.
415416
- `environments.list` and `environments.status` expose read-only Gateway-local and node environment discovery for SDK clients.
416417
- `agent.identity.get` returns the effective assistant identity for an agent or session.
@@ -499,6 +500,34 @@ enumeration of `src/gateway/server-methods/*.ts`.
499500
- Nodes may call `skills.bins` to fetch the current list of skill executables
500501
for auto-allow checks.
501502

503+
### Task ledger RPCs
504+
505+
Operator clients may inspect and cancel Gateway background task records through
506+
the task ledger RPCs. These methods return sanitized task summaries, not raw
507+
runtime state.
508+
509+
- `tasks.list` requires `operator.read`.
510+
- Params: optional `status` (`"queued"`, `"running"`, `"completed"`,
511+
`"failed"`, `"cancelled"`, or `"timed_out"`) or an array of those statuses,
512+
optional `agentId`, optional `sessionKey`, optional `limit` from `1` to
513+
`500`, and optional string `cursor`.
514+
- Result: `{ "tasks": TaskSummary[], "nextCursor"?: string }`.
515+
- `tasks.get` requires `operator.read`.
516+
- Params: `{ "taskId": string }`.
517+
- Result: `{ "task": TaskSummary }`.
518+
- Missing task ids return the Gateway not-found error shape.
519+
- `tasks.cancel` requires `operator.write`.
520+
- Params: `{ "taskId": string, "reason"?: string }`.
521+
- Result:
522+
`{ "found": boolean, "cancelled": boolean, "reason"?: string, "task"?: TaskSummary }`.
523+
- `found` reports whether the ledger had a matching task. `cancelled`
524+
reports whether the runtime accepted or recorded cancellation.
525+
526+
`TaskSummary` includes `id`, `status`, and optional metadata such as `kind`,
527+
`runtime`, `title`, `agentId`, `sessionKey`, `childSessionKey`, `ownerKey`,
528+
`runId`, `taskId`, `flowId`, `parentTaskId`, `sourceId`, timestamps, progress,
529+
terminal summary, and sanitized error text.
530+
502531
### Operator helper methods
503532

504533
- Operators may call `commands.list` (`operator.read`) to fetch the runtime

docs/reference/openclaw-sdk-api-design.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ oc.runs.events(runId, { after });
4949
oc.runs.wait(runId);
5050
oc.runs.cancel(runId);
5151

52-
oc.tasks.list(); // future API: current SDK throws unsupported
53-
oc.tasks.get(taskId); // future API: current SDK throws unsupported
54-
oc.tasks.cancel(taskId); // future API: current SDK throws unsupported
52+
oc.tasks.list({ status: "running" });
53+
oc.tasks.get(taskId);
54+
oc.tasks.cancel(taskId, { reason });
5555
oc.tasks.events(taskId, { after }); // future API
5656

5757
oc.models.list();

scripts/protocol-gen-swift.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function emitStruct(name: string, schema: JsonSchema): string {
175175
const codingKeys: string[] = [];
176176
for (const [key, propSchema] of Object.entries(props)) {
177177
const propName = safeName(key);
178-
const propType = swiftType(propSchema, required.has(key));
178+
const propType = swiftType(propSchema, required.has(key), true);
179179
lines.push(` public let ${propName}: ${propType}`);
180180
if (propName !== key) {
181181
codingKeys.push(` case ${propName} = "${key}"`);
@@ -189,7 +189,7 @@ function emitStruct(name: string, schema: JsonSchema): string {
189189
.map(([key, prop]) => {
190190
const propName = safeName(key);
191191
const req = required.has(key);
192-
return ` ${propName}: ${swiftType(prop, true)}${req ? "" : "?"}`;
192+
return ` ${propName}: ${swiftType(prop, true, true)}${req ? "" : "?"}`;
193193
})
194194
.join(",\n") +
195195
")\n" +

0 commit comments

Comments
 (0)