@smthrs/gateway 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smthrs/gateway",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Stable Smithers Gateway RPC contracts, auth scopes, and deployment metadata",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -31,7 +31,7 @@
31
31
  "openapi.yaml"
32
32
  ],
33
33
  "dependencies": {
34
- "@smthrs/protocol": "0.34.0"
34
+ "@smthrs/protocol": "0.35.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/bun": "latest",
@@ -22,6 +22,33 @@ function validStartedBy(value) {
22
22
  };
23
23
  }
24
24
 
25
+ const CANCELLATION_SOURCE_KINDS = new Set(["signal", "rpc", "cli", "engine"]);
26
+
27
+ /** @param {Record<string, unknown>} row */
28
+ function cancellationSourceFromRow(row) {
29
+ if (typeof row.cancelRequestSource !== "string") return undefined;
30
+ const rawKind = row.cancelRequestSource;
31
+ const legacyTransport = rawKind === "http" || rawKind === "websocket" || rawKind === "gateway";
32
+ const kind = legacyTransport ? "rpc" : rawKind;
33
+ if (!CANCELLATION_SOURCE_KINDS.has(kind)) return undefined;
34
+ const detail =
35
+ typeof row.cancelRequestDetail === "string"
36
+ ? row.cancelRequestDetail
37
+ : legacyTransport
38
+ ? `${rawKind} cancellation request`
39
+ : undefined;
40
+ return {
41
+ kind,
42
+ ...(detail !== undefined ? { detail } : {}),
43
+ ...(typeof row.cancelRequestSignal === "string" ? { signal: row.cancelRequestSignal } : {}),
44
+ ...(Number.isSafeInteger(row.cancelRequestClientPid) && Number(row.cancelRequestClientPid) > 0
45
+ ? { clientPid: Number(row.cancelRequestClientPid) }
46
+ : {}),
47
+ ...(typeof row.cancelRequestId === "string" ? { requestId: row.cancelRequestId } : {}),
48
+ ...(typeof row.cancelRequestClientIdentity === "string" ? { clientIdentity: row.cancelRequestClientIdentity } : {}),
49
+ };
50
+ }
51
+
25
52
  /**
26
53
  * @template {Record<string, unknown>} Row
27
54
  * @param {Row} row
@@ -29,6 +56,11 @@ function validStartedBy(value) {
29
56
  */
30
57
  export function serializeRunRow(row) {
31
58
  const normalized = normalizeApiRow(row);
59
+ const cancellationSource = cancellationSourceFromRow(normalized);
60
+ if (cancellationSource) normalized.cancellationSource = cancellationSource;
61
+ if (typeof normalized.owner === "string" && typeof normalized.app === "string") {
62
+ normalized.ownership = { owner: normalized.owner, app: normalized.app };
63
+ }
32
64
  let config;
33
65
  if (typeof normalized.configJson === "string") {
34
66
  try {
@@ -47,6 +47,7 @@ export type {
47
47
  ListRunDescendantsRequest,
48
48
  ListRunDescendantsResponse,
49
49
  GatewayRunDescendant,
50
+ GetRunResponse,
50
51
  RunTokenUsageEvent,
51
52
  GetRunDiffRequest,
52
53
  GetRunDiffResponse,
@@ -134,6 +135,8 @@ export type {
134
135
  BrowserActivityEvent,
135
136
  BrowserScreenshot,
136
137
  BrowserSelection,
138
+ RunCancellationSource,
139
+ RunOwnership,
137
140
  } from "@smthrs/protocol/gateway-rpc";
138
141
 
139
142
  export type GatewayRpcErrorDetails = ProtocolGatewayRpcErrorDetails;
@@ -1,4 +1,4 @@
1
- import { SmithersApiVersion as SmithersApiVersion$1, GatewayRpcMethod as GatewayRpcMethod$1, GatewayRpcErrorCode as GatewayRpcErrorCode$1, GatewayRpcErrorDetails as GatewayRpcErrorDetails$2, BrowserActRequest as BrowserActRequest$1, BrowserActResponse as BrowserActResponse$1, BrowserAction as BrowserAction$1, BrowserActivityEvent as BrowserActivityEvent$1, BrowserActor as BrowserActor$1, BrowserClickAction as BrowserClickAction$1, BrowserContextRequest as BrowserContextRequest$1, BrowserContextResponse as BrowserContextResponse$1, BrowserContextSlice as BrowserContextSlice$1, BrowserFrameEvent as BrowserFrameEvent$1, BrowserJournalEntry as BrowserJournalEntry$1, BrowserLocator as BrowserLocator$1, BrowserModifier as BrowserModifier$1, BrowserOutcome as BrowserOutcome$1, BrowserPickRequest as BrowserPickRequest$1, BrowserPickResponse as BrowserPickResponse$1, BrowserPoint as BrowserPoint$1, BrowserRectangle as BrowserRectangle$1, BrowserRedaction as BrowserRedaction$1, BrowserScreenshot as BrowserScreenshot$1, BrowserSelection as BrowserSelection$1, BrowserSnapshot as BrowserSnapshot$1, BrowserSource as BrowserSource$1, BrowserSummary as BrowserSummary$1, BrowserViewport as BrowserViewport$1, CancelRunRequest as CancelRunRequest$1, CancelRunResponse as CancelRunResponse$1, CloseBrowserSessionRequest as CloseBrowserSessionRequest$1, CloseBrowserSessionResponse as CloseBrowserSessionResponse$1, CreateBrowserSessionRequest as CreateBrowserSessionRequest$1, CreateBrowserSessionResponse as CreateBrowserSessionResponse$1, CreateTicketRequest as CreateTicketRequest$1, CronCreateRequest as CronCreateRequest$1, CronDeleteRequest as CronDeleteRequest$1, CronListRequest as CronListRequest$1, CronRunRequest as CronRunRequest$1, CrossedEffect as CrossedEffect$1, DeleteTicketRequest as DeleteTicketRequest$1, EffectBoundaryReport as EffectBoundaryReport$1, EffectRevertFailed as EffectRevertFailed$1, EffectRevertFinished as EffectRevertFinished$1, EffectRevertStarted as EffectRevertStarted$1, GatewayAccount as GatewayAccount$1, GatewayApprovalSummary as GatewayApprovalSummary$1, GatewayComparisonScoreRow as GatewayComparisonScoreRow$1, GatewayDiffBundle as GatewayDiffBundle$1, GatewayDiffPatch as GatewayDiffPatch$1, GatewayDocKind as GatewayDocKind$1, GatewayDocRow as GatewayDocRow$1, GatewayMemoryFact as GatewayMemoryFact$1, GatewayPrompt as GatewayPrompt$1, GatewayResponseFrame as GatewayResponseFrame$1, GatewayRunDescendant as GatewayRunDescendant$1, GatewayRunSummary as GatewayRunSummary$1, GatewayScoreDetail as GatewayScoreDetail$1, GatewayScoreRow as GatewayScoreRow$1, GatewayTicketRow as GatewayTicketRow$1, GatewayWorkflowSummary as GatewayWorkflowSummary$1, GetDevToolsSnapshotRequest as GetDevToolsSnapshotRequest$1, GetDevToolsSnapshotResponse as GetDevToolsSnapshotResponse$1, GetRunDiffOversizedResponse as GetRunDiffOversizedResponse$1, GetRunDiffRequest as GetRunDiffRequest$1, GetRunDiffResponse as GetRunDiffResponse$1, GetRunRequest as GetRunRequest$1, GetSchemaSignatureRequest as GetSchemaSignatureRequest$1, GetSchemaSignatureResponse as GetSchemaSignatureResponse$1, GetScoreDetailRequest as GetScoreDetailRequest$1, GetScoreDetailResponse as GetScoreDetailResponse$1, HijackRunRequest as HijackRunRequest$1, HijackRunResponse as HijackRunResponse$1, LaunchRunRequest as LaunchRunRequest$1, LaunchRunResponse as LaunchRunResponse$1, ListAccountsRequest as ListAccountsRequest$1, ListAccountsResponse as ListAccountsResponse$1, ListApprovalsRequest as ListApprovalsRequest$1, ListApprovalsResponse as ListApprovalsResponse$1, ListBrowserSessionsResponse as ListBrowserSessionsResponse$1, ListDocsRequest as ListDocsRequest$1, ListDocsResponse as ListDocsResponse$1, ListMemoryFactsRequest as ListMemoryFactsRequest$1, ListMemoryFactsResponse as ListMemoryFactsResponse$1, ListPromptsRequest as ListPromptsRequest$1, ListPromptsResponse as ListPromptsResponse$1, ListRunDescendantsRequest as ListRunDescendantsRequest$1, ListRunDescendantsResponse as ListRunDescendantsResponse$1, ListRunTokenUsageRequest as ListRunTokenUsageRequest$1, ListRunTokenUsageResponse as ListRunTokenUsageResponse$1, ListRunsRequest as ListRunsRequest$1, ListRunsResponse as ListRunsResponse$1, ListScoresForRunsRequest as ListScoresForRunsRequest$1, ListScoresForRunsResponse as ListScoresForRunsResponse$1, ListScoresRequest as ListScoresRequest$1, ListScoresResponse as ListScoresResponse$1, ListTicketsRequest as ListTicketsRequest$1, ListTicketsResponse as ListTicketsResponse$1, ListWorkflowsRequest as ListWorkflowsRequest$1, ListWorkflowsResponse as ListWorkflowsResponse$1, NodeRequest as NodeRequest$1, PauseRunRequest as PauseRunRequest$1, PauseRunResponse as PauseRunResponse$1, ResumeRunRequest as ResumeRunRequest$1, ResumeRunResponse as ResumeRunResponse$1, RewindRunRequest as RewindRunRequest$1, RewindRunResponse as RewindRunResponse$1, RunTokenUsageEvent as RunTokenUsageEvent$1, SideEffectBoundaryCrossed as SideEffectBoundaryCrossed$1, StreamDevToolsRequest as StreamDevToolsRequest$1, StreamRunEventsRequest as StreamRunEventsRequest$1, StreamRunEventsResponse as StreamRunEventsResponse$1, SubmitApprovalRequest as SubmitApprovalRequest$1, SubmitApprovalResponse as SubmitApprovalResponse$1, SubmitSignalRequest as SubmitSignalRequest$1, UpdateTicketRequest as UpdateTicketRequest$1, WhatHappenedRequest as WhatHappenedRequest$1, WhatHappenedResponse as WhatHappenedResponse$1 } from '@smthrs/protocol/gateway-rpc';
1
+ import { SmithersApiVersion as SmithersApiVersion$1, GatewayRpcMethod as GatewayRpcMethod$1, GatewayRpcErrorCode as GatewayRpcErrorCode$1, GatewayRpcErrorDetails as GatewayRpcErrorDetails$2, BrowserActRequest as BrowserActRequest$1, BrowserActResponse as BrowserActResponse$1, BrowserAction as BrowserAction$1, BrowserActivityEvent as BrowserActivityEvent$1, BrowserActor as BrowserActor$1, BrowserClickAction as BrowserClickAction$1, BrowserContextRequest as BrowserContextRequest$1, BrowserContextResponse as BrowserContextResponse$1, BrowserContextSlice as BrowserContextSlice$1, BrowserFrameEvent as BrowserFrameEvent$1, BrowserJournalEntry as BrowserJournalEntry$1, BrowserLocator as BrowserLocator$1, BrowserModifier as BrowserModifier$1, BrowserOutcome as BrowserOutcome$1, BrowserPickRequest as BrowserPickRequest$1, BrowserPickResponse as BrowserPickResponse$1, BrowserPoint as BrowserPoint$1, BrowserRectangle as BrowserRectangle$1, BrowserRedaction as BrowserRedaction$1, BrowserScreenshot as BrowserScreenshot$1, BrowserSelection as BrowserSelection$1, BrowserSnapshot as BrowserSnapshot$1, BrowserSource as BrowserSource$1, BrowserSummary as BrowserSummary$1, BrowserViewport as BrowserViewport$1, CancelRunRequest as CancelRunRequest$1, CancelRunResponse as CancelRunResponse$1, CloseBrowserSessionRequest as CloseBrowserSessionRequest$1, CloseBrowserSessionResponse as CloseBrowserSessionResponse$1, CreateBrowserSessionRequest as CreateBrowserSessionRequest$1, CreateBrowserSessionResponse as CreateBrowserSessionResponse$1, CreateTicketRequest as CreateTicketRequest$1, CronCreateRequest as CronCreateRequest$1, CronDeleteRequest as CronDeleteRequest$1, CronListRequest as CronListRequest$1, CronRunRequest as CronRunRequest$1, CrossedEffect as CrossedEffect$1, DeleteTicketRequest as DeleteTicketRequest$1, EffectBoundaryReport as EffectBoundaryReport$1, EffectRevertFailed as EffectRevertFailed$1, EffectRevertFinished as EffectRevertFinished$1, EffectRevertStarted as EffectRevertStarted$1, GatewayAccount as GatewayAccount$1, GatewayApprovalSummary as GatewayApprovalSummary$1, GatewayComparisonScoreRow as GatewayComparisonScoreRow$1, GatewayDiffBundle as GatewayDiffBundle$1, GatewayDiffPatch as GatewayDiffPatch$1, GatewayDocKind as GatewayDocKind$1, GatewayDocRow as GatewayDocRow$1, GatewayMemoryFact as GatewayMemoryFact$1, GatewayPrompt as GatewayPrompt$1, GatewayResponseFrame as GatewayResponseFrame$1, GatewayRunDescendant as GatewayRunDescendant$1, GatewayRunSummary as GatewayRunSummary$1, GatewayScoreDetail as GatewayScoreDetail$1, GatewayScoreRow as GatewayScoreRow$1, GatewayTicketRow as GatewayTicketRow$1, GatewayWorkflowSummary as GatewayWorkflowSummary$1, GetDevToolsSnapshotRequest as GetDevToolsSnapshotRequest$1, GetDevToolsSnapshotResponse as GetDevToolsSnapshotResponse$1, GetRunDiffOversizedResponse as GetRunDiffOversizedResponse$1, GetRunDiffRequest as GetRunDiffRequest$1, GetRunDiffResponse as GetRunDiffResponse$1, GetRunRequest as GetRunRequest$1, GetRunResponse as GetRunResponse$1, GetSchemaSignatureRequest as GetSchemaSignatureRequest$1, GetSchemaSignatureResponse as GetSchemaSignatureResponse$1, GetScoreDetailRequest as GetScoreDetailRequest$1, GetScoreDetailResponse as GetScoreDetailResponse$1, HijackRunRequest as HijackRunRequest$1, HijackRunResponse as HijackRunResponse$1, LaunchRunRequest as LaunchRunRequest$1, LaunchRunResponse as LaunchRunResponse$1, ListAccountsRequest as ListAccountsRequest$1, ListAccountsResponse as ListAccountsResponse$1, ListApprovalsRequest as ListApprovalsRequest$1, ListApprovalsResponse as ListApprovalsResponse$1, ListBrowserSessionsResponse as ListBrowserSessionsResponse$1, ListDocsRequest as ListDocsRequest$1, ListDocsResponse as ListDocsResponse$1, ListMemoryFactsRequest as ListMemoryFactsRequest$1, ListMemoryFactsResponse as ListMemoryFactsResponse$1, ListPromptsRequest as ListPromptsRequest$1, ListPromptsResponse as ListPromptsResponse$1, ListRunDescendantsRequest as ListRunDescendantsRequest$1, ListRunDescendantsResponse as ListRunDescendantsResponse$1, ListRunTokenUsageRequest as ListRunTokenUsageRequest$1, ListRunTokenUsageResponse as ListRunTokenUsageResponse$1, ListRunsRequest as ListRunsRequest$1, ListRunsResponse as ListRunsResponse$1, ListScoresForRunsRequest as ListScoresForRunsRequest$1, ListScoresForRunsResponse as ListScoresForRunsResponse$1, ListScoresRequest as ListScoresRequest$1, ListScoresResponse as ListScoresResponse$1, ListTicketsRequest as ListTicketsRequest$1, ListTicketsResponse as ListTicketsResponse$1, ListWorkflowsRequest as ListWorkflowsRequest$1, ListWorkflowsResponse as ListWorkflowsResponse$1, NodeRequest as NodeRequest$1, PauseRunRequest as PauseRunRequest$1, PauseRunResponse as PauseRunResponse$1, ResumeRunRequest as ResumeRunRequest$1, ResumeRunResponse as ResumeRunResponse$1, RewindRunRequest as RewindRunRequest$1, RewindRunResponse as RewindRunResponse$1, RunCancellationSource as RunCancellationSource$1, RunTokenUsageEvent as RunTokenUsageEvent$1, SideEffectBoundaryCrossed as SideEffectBoundaryCrossed$1, StreamDevToolsRequest as StreamDevToolsRequest$1, StreamRunEventsRequest as StreamRunEventsRequest$1, StreamRunEventsResponse as StreamRunEventsResponse$1, SubmitApprovalRequest as SubmitApprovalRequest$1, SubmitApprovalResponse as SubmitApprovalResponse$1, SubmitSignalRequest as SubmitSignalRequest$1, UpdateTicketRequest as UpdateTicketRequest$1, WhatHappenedRequest as WhatHappenedRequest$1, WhatHappenedResponse as WhatHappenedResponse$1 } from '@smthrs/protocol/gateway-rpc';
2
2
 
3
3
  /** @typedef {(typeof GATEWAY_SCOPE_VALUES)[number]} GatewayScope */
4
4
  declare const GATEWAY_SCOPE_VALUES: readonly ["run:read", "run:write", "run:admin", "approval:submit", "signal:submit", "cron:read", "cron:write", "account:read", "memory:read", "prompt:read", "score:read", "ticket:read", "ticket:write", "observability:read"];
@@ -102,6 +102,7 @@ type GatewayRpcErrorDefinition = GatewayRpcErrorDefinition$1;
102
102
  type GatewayRpcDefinition = GatewayRpcDefinition$1;
103
103
  type GatewayRpcMethod = GatewayRpcMethod$1;
104
104
  type GatewayResponseFrame = GatewayResponseFrame$1;
105
+ type RunCancellationSource = RunCancellationSource$1;
105
106
  type LaunchRunRequest = LaunchRunRequest$1;
106
107
  type LaunchRunResponse = LaunchRunResponse$1;
107
108
  type ResumeRunRequest = ResumeRunRequest$1;
@@ -124,6 +125,7 @@ type SubmitApprovalRequest = SubmitApprovalRequest$1;
124
125
  type SubmitApprovalResponse = SubmitApprovalResponse$1;
125
126
  type SubmitSignalRequest = SubmitSignalRequest$1;
126
127
  type GetRunRequest = GetRunRequest$1;
128
+ type GetRunResponse = GetRunResponse$1;
127
129
  type RunTokenUsageEvent = RunTokenUsageEvent$1;
128
130
  type ListRunTokenUsageRequest = ListRunTokenUsageRequest$1;
129
131
  type ListRunTokenUsageResponse = ListRunTokenUsageResponse$1;
@@ -218,4 +220,4 @@ type BrowserScreenshot = BrowserScreenshot$1;
218
220
  type BrowserSelection = BrowserSelection$1;
219
221
  type GatewayScope = GatewayScope$1;
220
222
 
221
- export { type BrowserActRequest, type BrowserActResponse, type BrowserAction, type BrowserActivityEvent, type BrowserActor, type BrowserClickAction, type BrowserContextRequest, type BrowserContextResponse, type BrowserContextSlice, type BrowserFrameEvent, type BrowserJournalEntry, type BrowserLocator, type BrowserModifier, type BrowserOutcome, type BrowserPickRequest, type BrowserPickResponse, type BrowserPoint, type BrowserRectangle, type BrowserRedaction, type BrowserScreenshot, type BrowserSelection, type BrowserSnapshot, type BrowserSource, type BrowserSummary, type BrowserViewport, type CancelRunRequest, type CancelRunResponse, type CloseBrowserSessionRequest, type CloseBrowserSessionResponse, type CreateBrowserSessionRequest, type CreateBrowserSessionResponse, type CreateTicketRequest, type CronCreateRequest, type CronDeleteRequest, type CronListRequest, type CronRunRequest, type CrossedEffect, type DeleteTicketRequest, type EffectBoundaryReport, type EffectRevertFailed, type EffectRevertFinished, type EffectRevertStarted, GATEWAY_EVENT_WINDOW_DEFAULT, GATEWAY_RPC_DEFINITIONS, GATEWAY_RPC_ERRORS, GATEWAY_RPC_LEGACY_METHOD_ALIASES, type GatewayAccount, type GatewayApprovalSummary, type GatewayComparisonScoreRow, type GatewayDiffBundle, type GatewayDiffPatch, type GatewayDocKind, type GatewayDocRow, type GatewayMemoryFact, type GatewayPrompt, type GatewayResponseFrame, type GatewayRpcDefinition, type GatewayRpcErrorCode, type GatewayRpcErrorDefinition, type GatewayRpcErrorDetails, type GatewayRpcMethod, type GatewayRunDescendant, type GatewayRunSummary, type GatewayScope, type GatewayScoreDetail, type GatewayScoreRow, type GatewayTicketRow, type GatewayWorkflowSummary, type GetDevToolsSnapshotRequest, type GetDevToolsSnapshotResponse, type GetRunDiffOversizedResponse, type GetRunDiffRequest, type GetRunDiffResponse, type GetRunRequest, type GetSchemaSignatureRequest, type GetSchemaSignatureResponse, type GetScoreDetailRequest, type GetScoreDetailResponse, type HijackRunRequest, type HijackRunResponse, type JsonSchema, type LaunchRunRequest, type LaunchRunResponse, type ListAccountsRequest, type ListAccountsResponse, type ListApprovalsRequest, type ListApprovalsResponse, type ListBrowserSessionsResponse, type ListDocsRequest, type ListDocsResponse, type ListMemoryFactsRequest, type ListMemoryFactsResponse, type ListPromptsRequest, type ListPromptsResponse, type ListRunDescendantsRequest, type ListRunDescendantsResponse, type ListRunTokenUsageRequest, type ListRunTokenUsageResponse, type ListRunsRequest, type ListRunsResponse, type ListScoresForRunsRequest, type ListScoresForRunsResponse, type ListScoresRequest, type ListScoresResponse, type ListTicketsRequest, type ListTicketsResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, type NodeRequest, type PauseRunRequest, type PauseRunResponse, type ResumeRunRequest, type ResumeRunResponse, type RewindRunRequest, type RewindRunResponse, type RunTokenUsageEvent, SMITHERS_API_VERSION, type SideEffectBoundaryCrossed, type SmithersApiVersion, type StreamDevToolsRequest, type StreamRunEventsRequest, type StreamRunEventsResponse, type SubmitApprovalRequest, type SubmitApprovalResponse, type SubmitSignalRequest, type UpdateTicketRequest, type WhatHappenedRequest, type WhatHappenedResponse, anyJsonSchema, canonicalGatewayRpcMethod, getGatewayRpcDefinition, getGatewayScopeValues, getRequiredScopeForGatewayMethod, isGatewayRpcMethod, listGatewayRpcMethods };
223
+ export { type BrowserActRequest, type BrowserActResponse, type BrowserAction, type BrowserActivityEvent, type BrowserActor, type BrowserClickAction, type BrowserContextRequest, type BrowserContextResponse, type BrowserContextSlice, type BrowserFrameEvent, type BrowserJournalEntry, type BrowserLocator, type BrowserModifier, type BrowserOutcome, type BrowserPickRequest, type BrowserPickResponse, type BrowserPoint, type BrowserRectangle, type BrowserRedaction, type BrowserScreenshot, type BrowserSelection, type BrowserSnapshot, type BrowserSource, type BrowserSummary, type BrowserViewport, type CancelRunRequest, type CancelRunResponse, type CloseBrowserSessionRequest, type CloseBrowserSessionResponse, type CreateBrowserSessionRequest, type CreateBrowserSessionResponse, type CreateTicketRequest, type CronCreateRequest, type CronDeleteRequest, type CronListRequest, type CronRunRequest, type CrossedEffect, type DeleteTicketRequest, type EffectBoundaryReport, type EffectRevertFailed, type EffectRevertFinished, type EffectRevertStarted, GATEWAY_EVENT_WINDOW_DEFAULT, GATEWAY_RPC_DEFINITIONS, GATEWAY_RPC_ERRORS, GATEWAY_RPC_LEGACY_METHOD_ALIASES, type GatewayAccount, type GatewayApprovalSummary, type GatewayComparisonScoreRow, type GatewayDiffBundle, type GatewayDiffPatch, type GatewayDocKind, type GatewayDocRow, type GatewayMemoryFact, type GatewayPrompt, type GatewayResponseFrame, type GatewayRpcDefinition, type GatewayRpcErrorCode, type GatewayRpcErrorDefinition, type GatewayRpcErrorDetails, type GatewayRpcMethod, type GatewayRunDescendant, type GatewayRunSummary, type GatewayScope, type GatewayScoreDetail, type GatewayScoreRow, type GatewayTicketRow, type GatewayWorkflowSummary, type GetDevToolsSnapshotRequest, type GetDevToolsSnapshotResponse, type GetRunDiffOversizedResponse, type GetRunDiffRequest, type GetRunDiffResponse, type GetRunRequest, type GetRunResponse, type GetSchemaSignatureRequest, type GetSchemaSignatureResponse, type GetScoreDetailRequest, type GetScoreDetailResponse, type HijackRunRequest, type HijackRunResponse, type JsonSchema, type LaunchRunRequest, type LaunchRunResponse, type ListAccountsRequest, type ListAccountsResponse, type ListApprovalsRequest, type ListApprovalsResponse, type ListBrowserSessionsResponse, type ListDocsRequest, type ListDocsResponse, type ListMemoryFactsRequest, type ListMemoryFactsResponse, type ListPromptsRequest, type ListPromptsResponse, type ListRunDescendantsRequest, type ListRunDescendantsResponse, type ListRunTokenUsageRequest, type ListRunTokenUsageResponse, type ListRunsRequest, type ListRunsResponse, type ListScoresForRunsRequest, type ListScoresForRunsResponse, type ListScoresRequest, type ListScoresResponse, type ListTicketsRequest, type ListTicketsResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, type NodeRequest, type PauseRunRequest, type PauseRunResponse, type ResumeRunRequest, type ResumeRunResponse, type RewindRunRequest, type RewindRunResponse, type RunCancellationSource, type RunTokenUsageEvent, SMITHERS_API_VERSION, type SideEffectBoundaryCrossed, type SmithersApiVersion, type StreamDevToolsRequest, type StreamRunEventsRequest, type StreamRunEventsResponse, type SubmitApprovalRequest, type SubmitApprovalResponse, type SubmitSignalRequest, type UpdateTicketRequest, type WhatHappenedRequest, type WhatHappenedResponse, anyJsonSchema, canonicalGatewayRpcMethod, getGatewayRpcDefinition, getGatewayScopeValues, getRequiredScopeForGatewayMethod, isGatewayRpcMethod, listGatewayRpcMethods };
package/src/rpc/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
  /** @typedef {import("./gatewayRpcTypes.ts").GatewayRpcDefinition} GatewayRpcDefinition */
8
8
  /** @typedef {import("./gatewayRpcTypes.ts").GatewayRpcMethod} GatewayRpcMethod */
9
9
  /** @typedef {import("./gatewayRpcTypes.ts").GatewayResponseFrame} GatewayResponseFrame */
10
+ /** @typedef {import("./gatewayRpcTypes.ts").RunCancellationSource} RunCancellationSource */
10
11
  /** @typedef {import("./gatewayRpcTypes.ts").LaunchRunRequest} LaunchRunRequest */
11
12
  /** @typedef {import("./gatewayRpcTypes.ts").LaunchRunResponse} LaunchRunResponse */
12
13
  /** @typedef {import("./gatewayRpcTypes.ts").ResumeRunRequest} ResumeRunRequest */
@@ -29,6 +30,7 @@
29
30
  /** @typedef {import("./gatewayRpcTypes.ts").SubmitApprovalResponse} SubmitApprovalResponse */
30
31
  /** @typedef {import("./gatewayRpcTypes.ts").SubmitSignalRequest} SubmitSignalRequest */
31
32
  /** @typedef {import("./gatewayRpcTypes.ts").GetRunRequest} GetRunRequest */
33
+ /** @typedef {import("./gatewayRpcTypes.ts").GetRunResponse} GetRunResponse */
32
34
  /** @typedef {import("./gatewayRpcTypes.ts").RunTokenUsageEvent} RunTokenUsageEvent */
33
35
  /** @typedef {import("./gatewayRpcTypes.ts").ListRunTokenUsageRequest} ListRunTokenUsageRequest */
34
36
  /** @typedef {import("./gatewayRpcTypes.ts").ListRunTokenUsageResponse} ListRunTokenUsageResponse */
@@ -141,9 +143,11 @@ const ACCOUNT_PROVIDERS = [
141
143
  "codex",
142
144
  "gemini",
143
145
  "kimi",
146
+ "grok",
144
147
  "anthropic-api",
145
148
  "openai-api",
146
149
  "gemini-api",
150
+ "xai-api",
147
151
  ];
148
152
 
149
153
  // The closed set of work-doc kinds in `_smithers_docs`. The GatewayDocKind
@@ -219,6 +223,26 @@ const nodeId = stringSchema("Workflow node id.");
219
223
  const iteration = integerSchema("Node iteration.", 0);
220
224
  const afterSeq = integerSchema("Replay events with sequence numbers greater than this value.", 0);
221
225
  const fromSeq = integerSchema("Legacy alias for afterSeq on DevTools streams.", 0);
226
+ const cancellationSource = objectSchema(
227
+ {
228
+ kind: { type: "string", enum: ["signal", "rpc", "cli", "engine"] },
229
+ detail: stringSchema("Human-readable cancellation detail."),
230
+ signal: stringSchema("POSIX signal that initiated cancellation."),
231
+ clientPid: integerSchema("Process id of the cancellation caller.", 1),
232
+ requestId: stringSchema("Request id of the first cancellation caller."),
233
+ clientIdentity: stringSchema("Authenticated identity of the first cancellation caller."),
234
+ },
235
+ ["kind"],
236
+ "Durable attribution for the first caller that cancelled the run.",
237
+ );
238
+ const runOwnership = objectSchema(
239
+ {
240
+ owner: stringSchema("Authenticated tenant owner key.", 1),
241
+ app: stringSchema("Authenticated application key.", 1),
242
+ },
243
+ ["owner", "app"],
244
+ "Exact persisted run ownership pair.",
245
+ );
222
246
  const runSummary = objectSchema(
223
247
  {
224
248
  runId,
@@ -227,11 +251,30 @@ const runSummary = objectSchema(
227
251
  createdAtMs: integerSchema("Unix epoch milliseconds.", 0),
228
252
  parentRunId: { type: ["string", "null"], description: "Immediate parent run id, if this is a child run." },
229
253
  system: booleanSchema("Whether this run belongs to an internal system workflow."),
254
+ cancellationSource,
255
+ ownership: runOwnership,
230
256
  },
231
257
  ["runId", "status", "system"],
232
258
  "Run summary view.",
233
259
  true,
234
260
  );
261
+ const cancelledRunOutcome = objectSchema(
262
+ {
263
+ runId,
264
+ depth: integerSchema("Distance from the requested root run.", 0),
265
+ action: { type: "string", enum: ["cancel-requested", "cancelled", "already-terminal", "missing"] },
266
+ },
267
+ ["runId", "depth", "action"],
268
+ "What recursive cancellation did to one run in the cancelled subtree.",
269
+ );
270
+ const cancelledProcess = objectSchema(
271
+ {
272
+ runId: { type: ["string", "null"], description: "Run the process belonged to." },
273
+ pid: integerSchema("Terminated process id.", 1),
274
+ },
275
+ ["runId", "pid"],
276
+ "A process tree cancellation terminated so work cannot outlive its run.",
277
+ );
235
278
  const runDescendant = objectSchema(
236
279
  {
237
280
  runId,
@@ -264,6 +307,8 @@ const runRecord = objectSchema(
264
307
  finishedAtMs: { type: ["integer", "null"], minimum: 0, description: "Unix epoch milliseconds." },
265
308
  summary: objectSchema({}, [], "Counts keyed by persisted node state.", true),
266
309
  runState: runStateView,
310
+ cancellationSource,
311
+ ownership: runOwnership,
267
312
  },
268
313
  ["runId", "system"],
269
314
  "Current run record, including node-state counts and optional derived runState.",
@@ -623,6 +668,12 @@ export const GATEWAY_RPC_ERRORS = {
623
668
  httpStatus: 409,
624
669
  description: "The run is not currently active and cannot be cancelled.",
625
670
  },
671
+ CONFLICT: {
672
+ version: SMITHERS_API_VERSION,
673
+ code: "CONFLICT",
674
+ httpStatus: 409,
675
+ description: "The requested run id is already taken by an existing run.",
676
+ },
626
677
  CronNotFound: {
627
678
  version: SMITHERS_API_VERSION,
628
679
  code: "CronNotFound",
@@ -840,10 +891,15 @@ export const GATEWAY_RPC_DEFINITIONS = [
840
891
  ["workflow"],
841
892
  ),
842
893
  responseSchema: objectSchema(
843
- { runId, workflow, system: booleanSchema("Whether the launched workflow is an internal system workflow.") },
894
+ {
895
+ runId,
896
+ workflow,
897
+ system: booleanSchema("Whether the launched workflow is an internal system workflow."),
898
+ ownership: runOwnership,
899
+ },
844
900
  ["runId", "workflow", "system"],
845
901
  ),
846
- errors: ["InvalidRequest", "InvalidInput", "Unauthorized", "Forbidden", "Internal"],
902
+ errors: ["InvalidRequest", "InvalidInput", "Unauthorized", "Forbidden", "CONFLICT", "Internal"],
847
903
  exampleRequest: {
848
904
  workflow: "deploy",
849
905
  input: { sha: "abc123" },
@@ -874,15 +930,47 @@ export const GATEWAY_RPC_DEFINITIONS = [
874
930
  version: SMITHERS_API_VERSION,
875
931
  method: "cancelRun",
876
932
  title: "Cancel Run",
877
- description: "Cancel an active run.",
933
+ description:
934
+ "Cancel a run AND every transitive child-workflow descendant as one recursive operation. Time-travel forks are spared; continue-as-new continuations are not.",
878
935
  maturity: "stable",
879
936
  transport: "http+websocket",
880
937
  requiredScope: "run:write",
881
938
  requestSchema: objectSchema({ runId }, ["runId"]),
882
- responseSchema: objectSchema({ runId, status: { type: "string", enum: ["cancelling"] } }, ["runId", "status"]),
883
- errors: ["InvalidRequest", "Unauthorized", "Forbidden", "RUN_NOT_ACTIVE", "Internal"],
939
+ responseSchema: objectSchema(
940
+ {
941
+ runId,
942
+ won: booleanSchema("Whether this request won the durable cancellation claim."),
943
+ status: { type: "string", enum: ["cancelled", "already-terminal", "not-found"] },
944
+ terminalStatus: stringSchema("Persisted terminal status after cancellation finalization."),
945
+ repaired: booleanSchema("Whether replay repaired incomplete cancellation cleanup."),
946
+ cancellationSource,
947
+ cancelledAttempts: integerSchema("Attempts closed across the whole cancelled subtree.", 0),
948
+ descendants: arraySchema(cancelledRunOutcome, "Every descendant the cascade reached, excluding the root run."),
949
+ terminatedOwners: arraySchema(cancelledProcess, "Detached owner processes terminated by the cascade."),
950
+ terminatedAgents: arraySchema(cancelledProcess, "Agent process trees terminated for the cancelled subtree."),
951
+ },
952
+ ["runId", "won", "status", "repaired"],
953
+ ),
954
+ errors: ["InvalidRequest", "Unauthorized", "Forbidden", "RunNotFound", "RUN_NOT_ACTIVE", "Internal"],
884
955
  exampleRequest: { runId: "run_01" },
885
- exampleResponse: { runId: "run_01", status: "cancelling" },
956
+ exampleResponse: {
957
+ runId: "run_01",
958
+ won: true,
959
+ status: "cancelled",
960
+ terminalStatus: "cancelled",
961
+ repaired: false,
962
+ cancellationSource: {
963
+ kind: "rpc",
964
+ detail: "websocket cancellation request",
965
+ clientPid: 4321,
966
+ requestId: "cancelRun-1",
967
+ clientIdentity: "user:operator",
968
+ },
969
+ cancelledAttempts: 2,
970
+ descendants: [{ runId: "run_01:child:review:0", depth: 1, action: "cancelled" }],
971
+ terminatedOwners: [{ runId: "run_01:child:review:0", pid: 4711 }],
972
+ terminatedAgents: [{ runId: "run_01:child:review:0", pid: 4712 }],
973
+ },
886
974
  },
887
975
  {
888
976
  version: SMITHERS_API_VERSION,
@@ -1098,10 +1186,12 @@ export const GATEWAY_RPC_DEFINITIONS = [
1098
1186
  model: stringSchema("Resolved provider model id."),
1099
1187
  agent: stringSchema("Agent id or adapter name."),
1100
1188
  inputTokens: integerSchema("Reported input tokens.", 0),
1189
+ freshInputTokens: integerSchema("Reported input tokens excluding cache reads.", 0),
1101
1190
  outputTokens: integerSchema("Reported output tokens.", 0),
1102
1191
  cacheReadTokens: integerSchema("Reported cache-read tokens.", 0),
1103
1192
  cacheWriteTokens: integerSchema("Reported cache-write tokens.", 0),
1104
1193
  reasoningTokens: integerSchema("Reported reasoning tokens.", 0),
1194
+ costUsd: { type: ["number", "null"], description: "Reported cost in USD, null when unknown." },
1105
1195
  timestampMs: integerSchema("Event timestamp in Unix epoch milliseconds.", 0),
1106
1196
  },
1107
1197
  [
@@ -1111,10 +1201,12 @@ export const GATEWAY_RPC_DEFINITIONS = [
1111
1201
  "model",
1112
1202
  "agent",
1113
1203
  "inputTokens",
1204
+ "freshInputTokens",
1114
1205
  "outputTokens",
1115
1206
  "cacheReadTokens",
1116
1207
  "cacheWriteTokens",
1117
1208
  "reasoningTokens",
1209
+ "costUsd",
1118
1210
  "timestampMs",
1119
1211
  ],
1120
1212
  ),
@@ -1135,10 +1227,12 @@ export const GATEWAY_RPC_DEFINITIONS = [
1135
1227
  model: "gpt-5.4-codex",
1136
1228
  agent: "codex-work",
1137
1229
  inputTokens: 120,
1230
+ freshInputTokens: 80,
1138
1231
  outputTokens: 30,
1139
1232
  cacheReadTokens: 40,
1140
1233
  cacheWriteTokens: 5,
1141
1234
  reasoningTokens: 12,
1235
+ costUsd: null,
1142
1236
  timestampMs: 1710000000000,
1143
1237
  },
1144
1238
  ],
@@ -1166,6 +1260,8 @@ export const GATEWAY_RPC_DEFINITIONS = [
1166
1260
  workflow: stringSchema("Optional workflow key filter."),
1167
1261
  parentRunId: stringSchema("Return only direct children of this run."),
1168
1262
  includeSystem: booleanSchema("Include internal system runs; they are excluded by default."),
1263
+ owner: stringSchema("Admin-only owner filter; must be paired with app.", 1),
1264
+ app: stringSchema("Admin-only application filter; must be paired with owner.", 1),
1169
1265
  }),
1170
1266
  }),
1171
1267
  responseSchema: arraySchema(runSummary, "Run summaries."),