@openclaw/gateway-protocol 2026.8.1-beta.1 → 2026.8.1-beta.3

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.
@@ -0,0 +1,90 @@
1
+ //#region src/gateway-error-details.d.ts
2
+ /** Gateway JSON-RPC style error codes shared by clients and server handlers. */
3
+ declare const ErrorCodes: {
4
+ /** @deprecated Retained for source compatibility; no current server emitter. */readonly NOT_LINKED: "NOT_LINKED"; /** Device exists but still needs an explicit pairing approval. */
5
+ readonly NOT_PAIRED: "NOT_PAIRED"; /** @deprecated Retained for source compatibility; no current server emitter. */
6
+ readonly AGENT_TIMEOUT: "AGENT_TIMEOUT"; /** Request payload failed protocol validation or method preconditions. */
7
+ readonly INVALID_REQUEST: "INVALID_REQUEST"; /** Authenticated caller lacks permission for the requested operation. */
8
+ readonly FORBIDDEN: "FORBIDDEN"; /** Approval resolution referenced a missing or expired approval request. */
9
+ readonly APPROVAL_NOT_FOUND: "APPROVAL_NOT_FOUND"; /** Gateway service or required backend is temporarily unavailable. */
10
+ readonly UNAVAILABLE: "UNAVAILABLE";
11
+ };
12
+ /** Closed set of canonical gateway error code strings. */
13
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
14
+ /** Stable discriminants for structured method-level failures. */
15
+ declare const GatewayErrorDetailCodes: {
16
+ readonly CRON_JOB_NOT_FOUND: "CRON_JOB_NOT_FOUND";
17
+ readonly MISSING_SCOPE: "MISSING_SCOPE";
18
+ readonly MCP_APP_VIEW_EXPIRED: "MCP_APP_VIEW_EXPIRED";
19
+ readonly OUTBOUND_DELIVERY_QUEUED: "OUTBOUND_DELIVERY_QUEUED";
20
+ readonly USER_PREFS_LIMIT_EXCEEDED: "USER_PREFS_LIMIT_EXCEEDED";
21
+ readonly SESSION_COMPANION_BUSY: "SESSION_COMPANION_BUSY";
22
+ readonly SKILL_PROPOSAL_REVISION_CHANGED: "SKILL_PROPOSAL_REVISION_CHANGED";
23
+ readonly PROJECT_CLONE_FAILED: "PROJECT_CLONE_FAILED";
24
+ readonly UNKNOWN_AGENT_ID: "UNKNOWN_AGENT_ID";
25
+ readonly WIZARD_NOT_FOUND: "WIZARD_NOT_FOUND";
26
+ };
27
+ /** Missing cron automation identified by its exact store key. */
28
+ type CronJobNotFoundErrorDetails = {
29
+ code: typeof GatewayErrorDetailCodes.CRON_JOB_NOT_FOUND;
30
+ jobId: string;
31
+ };
32
+ /** Missing operator-scope details shared by WebSocket and HTTP responses. */
33
+ type MissingScopeErrorDetails = {
34
+ code: typeof GatewayErrorDetailCodes.MISSING_SCOPE;
35
+ missingScope: string;
36
+ requiredScopes: string[];
37
+ };
38
+ type McpAppViewExpiredErrorDetails = {
39
+ code: typeof GatewayErrorDetailCodes.MCP_APP_VIEW_EXPIRED;
40
+ };
41
+ type OutboundDeliveryQueuedErrorDetails = {
42
+ code: typeof GatewayErrorDetailCodes.OUTBOUND_DELIVERY_QUEUED;
43
+ };
44
+ /** Per-profile preference quota details returned by users.prefs.set. */
45
+ type UserPrefsLimitExceededErrorDetails = {
46
+ code: typeof GatewayErrorDetailCodes.USER_PREFS_LIMIT_EXCEEDED;
47
+ limit: number;
48
+ currentCount: number;
49
+ };
50
+ /** Unknown agent details carried by agent-scoped method validation failures. */
51
+ type UnknownAgentIdErrorDetails = {
52
+ code: typeof GatewayErrorDetailCodes.UNKNOWN_AGENT_ID;
53
+ agentId: string;
54
+ };
55
+ /** Missing or expired process-local setup wizard session. */
56
+ type WizardNotFoundErrorDetails = {
57
+ code: typeof GatewayErrorDetailCodes.WIZARD_NOT_FOUND;
58
+ };
59
+ type ProjectCloneFailureCause = "invalid_url" | "auth_required" | "not_found" | "network" | "target_exists" | "clone_failed";
60
+ type ProjectCloneErrorDetails = {
61
+ code: typeof GatewayErrorDetailCodes.PROJECT_CLONE_FAILED;
62
+ cause: ProjectCloneFailureCause;
63
+ };
64
+ /** Optimistic-concurrency mismatch for an operator-reviewed Skill Workshop draft. */
65
+ type SkillProposalRevisionChangedErrorDetails = {
66
+ code: typeof GatewayErrorDetailCodes.SKILL_PROPOSAL_REVISION_CHANGED;
67
+ expectedRevisionHash: string;
68
+ currentRevisionHash: string;
69
+ };
70
+ /** Structured details emitted by method-level failures. */
71
+ type GatewayErrorDetails = CronJobNotFoundErrorDetails | MissingScopeErrorDetails | McpAppViewExpiredErrorDetails | OutboundDeliveryQueuedErrorDetails | UserPrefsLimitExceededErrorDetails | SkillProposalRevisionChangedErrorDetails | ProjectCloneErrorDetails | UnknownAgentIdErrorDetails | WizardNotFoundErrorDetails;
72
+ /** Reads a typed cron lookup miss without parsing operator-facing prose. */
73
+ declare function readCronJobNotFoundError(error: unknown): CronJobNotFoundErrorDetails | null;
74
+ /** Builds the canonical stale-draft details shared by Skill Workshop RPCs. */
75
+ declare function buildSkillProposalRevisionChangedErrorDetails(params: {
76
+ expectedRevisionHash: string;
77
+ currentRevisionHash: string;
78
+ }): SkillProposalRevisionChangedErrorDetails;
79
+ /** Reads a stale Skill Workshop decision without parsing operator-facing prose. */
80
+ declare function readSkillProposalRevisionChangedError(error: unknown): SkillProposalRevisionChangedErrorDetails | null;
81
+ /** Reads validated missing-scope details from an untrusted protocol payload. */
82
+ declare function readMissingScopeErrorDetails(details: unknown): MissingScopeErrorDetails | null;
83
+ declare function isMcpAppViewExpiredError(error: unknown): boolean;
84
+ /**
85
+ * Reads a method-level missing-scope failure, preferring structured details.
86
+ * The message fallback keeps clients compatible with gateways predating structured details.
87
+ */
88
+ declare function readMissingScopeError(error: unknown): MissingScopeErrorDetails | null;
89
+ //#endregion
90
+ export { readCronJobNotFoundError as _, GatewayErrorDetails as a, readSkillProposalRevisionChangedError as b, OutboundDeliveryQueuedErrorDetails as c, SkillProposalRevisionChangedErrorDetails as d, UnknownAgentIdErrorDetails as f, isMcpAppViewExpiredError as g, buildSkillProposalRevisionChangedErrorDetails as h, GatewayErrorDetailCodes as i, ProjectCloneErrorDetails as l, WizardNotFoundErrorDetails as m, ErrorCode as n, McpAppViewExpiredErrorDetails as o, UserPrefsLimitExceededErrorDetails as p, ErrorCodes as r, MissingScopeErrorDetails as s, CronJobNotFoundErrorDetails as t, ProjectCloneFailureCause as u, readMissingScopeError as v, readMissingScopeErrorDetails as y };
@@ -1,2 +1,2 @@
1
- import { a as McpAppViewExpiredErrorDetails, c as WizardNotFoundErrorDetails, d as readMissingScopeErrorDetails, i as GatewayErrorDetails, l as isMcpAppViewExpiredError, n as ErrorCodes, o as MissingScopeErrorDetails, r as GatewayErrorDetailCodes, s as UnknownAgentIdErrorDetails, t as ErrorCode, u as readMissingScopeError } from "./gateway-error-details-Btc09cgL.mjs";
2
- export { ErrorCode, ErrorCodes, GatewayErrorDetailCodes, GatewayErrorDetails, McpAppViewExpiredErrorDetails, MissingScopeErrorDetails, UnknownAgentIdErrorDetails, WizardNotFoundErrorDetails, isMcpAppViewExpiredError, readMissingScopeError, readMissingScopeErrorDetails };
1
+ import { _ as readCronJobNotFoundError, a as GatewayErrorDetails, b as readSkillProposalRevisionChangedError, c as OutboundDeliveryQueuedErrorDetails, d as SkillProposalRevisionChangedErrorDetails, f as UnknownAgentIdErrorDetails, g as isMcpAppViewExpiredError, h as buildSkillProposalRevisionChangedErrorDetails, i as GatewayErrorDetailCodes, l as ProjectCloneErrorDetails, m as WizardNotFoundErrorDetails, n as ErrorCode, o as McpAppViewExpiredErrorDetails, p as UserPrefsLimitExceededErrorDetails, r as ErrorCodes, s as MissingScopeErrorDetails, t as CronJobNotFoundErrorDetails, u as ProjectCloneFailureCause, v as readMissingScopeError, y as readMissingScopeErrorDetails } from "./gateway-error-details-DR-CyzeW.mjs";
2
+ export { CronJobNotFoundErrorDetails, ErrorCode, ErrorCodes, GatewayErrorDetailCodes, GatewayErrorDetails, McpAppViewExpiredErrorDetails, MissingScopeErrorDetails, OutboundDeliveryQueuedErrorDetails, ProjectCloneErrorDetails, ProjectCloneFailureCause, SkillProposalRevisionChangedErrorDetails, UnknownAgentIdErrorDetails, UserPrefsLimitExceededErrorDetails, WizardNotFoundErrorDetails, buildSkillProposalRevisionChangedErrorDetails, isMcpAppViewExpiredError, readCronJobNotFoundError, readMissingScopeError, readMissingScopeErrorDetails, readSkillProposalRevisionChangedError };
@@ -1,11 +1,12 @@
1
+ import { t as asNullableRecord } from "./record-coerce-BKHrZ46I.mjs";
1
2
  //#region src/gateway-error-details.ts
2
3
  /** Gateway JSON-RPC style error codes shared by clients and server handlers. */
3
4
  const ErrorCodes = {
4
- /** Client has not completed account/device linking for this gateway. */
5
+ /** @deprecated Retained for source compatibility; no current server emitter. */
5
6
  NOT_LINKED: "NOT_LINKED",
6
7
  /** Device exists but still needs an explicit pairing approval. */
7
8
  NOT_PAIRED: "NOT_PAIRED",
8
- /** Agent turn exceeded the gateway wait window. */
9
+ /** @deprecated Retained for source compatibility; no current server emitter. */
9
10
  AGENT_TIMEOUT: "AGENT_TIMEOUT",
10
11
  /** Request payload failed protocol validation or method preconditions. */
11
12
  INVALID_REQUEST: "INVALID_REQUEST",
@@ -18,19 +19,52 @@ const ErrorCodes = {
18
19
  };
19
20
  /** Stable discriminants for structured method-level failures. */
20
21
  const GatewayErrorDetailCodes = {
22
+ CRON_JOB_NOT_FOUND: "CRON_JOB_NOT_FOUND",
21
23
  MISSING_SCOPE: "MISSING_SCOPE",
22
24
  MCP_APP_VIEW_EXPIRED: "MCP_APP_VIEW_EXPIRED",
25
+ OUTBOUND_DELIVERY_QUEUED: "OUTBOUND_DELIVERY_QUEUED",
26
+ USER_PREFS_LIMIT_EXCEEDED: "USER_PREFS_LIMIT_EXCEEDED",
23
27
  SESSION_COMPANION_BUSY: "SESSION_COMPANION_BUSY",
28
+ SKILL_PROPOSAL_REVISION_CHANGED: "SKILL_PROPOSAL_REVISION_CHANGED",
29
+ PROJECT_CLONE_FAILED: "PROJECT_CLONE_FAILED",
24
30
  UNKNOWN_AGENT_ID: "UNKNOWN_AGENT_ID",
25
31
  WIZARD_NOT_FOUND: "WIZARD_NOT_FOUND"
26
32
  };
27
33
  const LEGACY_MISSING_SCOPE_PATTERN = /\bmissing scope:\s*([a-z0-9._-]+)/i;
28
- function asRecord(value) {
29
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
34
+ const SHA256_PATTERN = /^[a-fA-F0-9]{64}$/;
35
+ /** Reads a typed cron lookup miss without parsing operator-facing prose. */
36
+ function readCronJobNotFoundError(error) {
37
+ const details = asNullableRecord(asNullableRecord(error)?.details);
38
+ if (details?.code !== GatewayErrorDetailCodes.CRON_JOB_NOT_FOUND) return null;
39
+ const jobId = typeof details.jobId === "string" ? details.jobId.trim() : "";
40
+ return jobId ? {
41
+ code: GatewayErrorDetailCodes.CRON_JOB_NOT_FOUND,
42
+ jobId
43
+ } : null;
44
+ }
45
+ /** Builds the canonical stale-draft details shared by Skill Workshop RPCs. */
46
+ function buildSkillProposalRevisionChangedErrorDetails(params) {
47
+ return {
48
+ code: GatewayErrorDetailCodes.SKILL_PROPOSAL_REVISION_CHANGED,
49
+ expectedRevisionHash: params.expectedRevisionHash,
50
+ currentRevisionHash: params.currentRevisionHash
51
+ };
52
+ }
53
+ /** Reads a stale Skill Workshop decision without parsing operator-facing prose. */
54
+ function readSkillProposalRevisionChangedError(error) {
55
+ const details = asNullableRecord(asNullableRecord(error)?.details);
56
+ if (details?.code !== GatewayErrorDetailCodes.SKILL_PROPOSAL_REVISION_CHANGED) return null;
57
+ const expectedRevisionHash = typeof details.expectedRevisionHash === "string" ? details.expectedRevisionHash : "";
58
+ const currentRevisionHash = typeof details.currentRevisionHash === "string" ? details.currentRevisionHash : "";
59
+ if (!SHA256_PATTERN.test(expectedRevisionHash) || !SHA256_PATTERN.test(currentRevisionHash)) return null;
60
+ return buildSkillProposalRevisionChangedErrorDetails({
61
+ expectedRevisionHash,
62
+ currentRevisionHash
63
+ });
30
64
  }
31
65
  /** Reads validated missing-scope details from an untrusted protocol payload. */
32
66
  function readMissingScopeErrorDetails(details) {
33
- const record = asRecord(details);
67
+ const record = asNullableRecord(details);
34
68
  if (record?.code !== GatewayErrorDetailCodes.MISSING_SCOPE) return null;
35
69
  const missingScope = typeof record.missingScope === "string" ? record.missingScope.trim() : "";
36
70
  const requiredScopes = Array.isArray(record.requiredScopes) ? record.requiredScopes.map((scope) => typeof scope === "string" ? scope.trim() : "") : [];
@@ -42,14 +76,14 @@ function readMissingScopeErrorDetails(details) {
42
76
  };
43
77
  }
44
78
  function isMcpAppViewExpiredError(error) {
45
- return asRecord(asRecord(error)?.details)?.code === GatewayErrorDetailCodes.MCP_APP_VIEW_EXPIRED;
79
+ return asNullableRecord(asNullableRecord(error)?.details)?.code === GatewayErrorDetailCodes.MCP_APP_VIEW_EXPIRED;
46
80
  }
47
81
  /**
48
82
  * Reads a method-level missing-scope failure, preferring structured details.
49
83
  * The message fallback keeps clients compatible with gateways predating structured details.
50
84
  */
51
85
  function readMissingScopeError(error) {
52
- const record = asRecord(error);
86
+ const record = asNullableRecord(error);
53
87
  if (!record) return null;
54
88
  const structured = readMissingScopeErrorDetails(record.details);
55
89
  if (structured) return structured;
@@ -64,4 +98,4 @@ function readMissingScopeError(error) {
64
98
  } : null;
65
99
  }
66
100
  //#endregion
67
- export { ErrorCodes, GatewayErrorDetailCodes, isMcpAppViewExpiredError, readMissingScopeError, readMissingScopeErrorDetails };
101
+ export { ErrorCodes, GatewayErrorDetailCodes, buildSkillProposalRevisionChangedErrorDetails, isMcpAppViewExpiredError, readCronJobNotFoundError, readMissingScopeError, readMissingScopeErrorDetails, readSkillProposalRevisionChangedError };