@sema-agent/sdk 0.0.74 → 0.0.76

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.
Files changed (171) hide show
  1. package/dist/client.d.ts +48 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +55 -2
  4. package/dist/client.js.map +1 -1
  5. package/dist/control-client.d.ts +21 -0
  6. package/dist/control-client.d.ts.map +1 -1
  7. package/dist/control-client.js +42 -1
  8. package/dist/control-client.js.map +1 -1
  9. package/dist/control-types.d.ts +108 -0
  10. package/dist/control-types.d.ts.map +1 -1
  11. package/dist/control-types.js +15 -0
  12. package/dist/control-types.js.map +1 -1
  13. package/dist/errors.d.ts +88 -2
  14. package/dist/errors.d.ts.map +1 -1
  15. package/dist/errors.js +105 -8
  16. package/dist/errors.js.map +1 -1
  17. package/dist/events.d.ts +154 -16
  18. package/dist/events.d.ts.map +1 -1
  19. package/dist/events.js +1 -0
  20. package/dist/events.js.map +1 -1
  21. package/dist/health.d.ts +44 -0
  22. package/dist/health.d.ts.map +1 -1
  23. package/dist/health.js +32 -0
  24. package/dist/health.js.map +1 -1
  25. package/dist/idempotency.d.ts +8 -0
  26. package/dist/idempotency.d.ts.map +1 -1
  27. package/dist/idempotency.js +8 -0
  28. package/dist/idempotency.js.map +1 -1
  29. package/dist/index.d.ts +19 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +13 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/resources/approvals.d.ts +43 -0
  34. package/dist/resources/approvals.d.ts.map +1 -1
  35. package/dist/resources/approvals.js +23 -3
  36. package/dist/resources/approvals.js.map +1 -1
  37. package/dist/resources/assistant.d.ts +23 -0
  38. package/dist/resources/assistant.d.ts.map +1 -1
  39. package/dist/resources/assistant.js +22 -0
  40. package/dist/resources/assistant.js.map +1 -1
  41. package/dist/resources/control/auth-providers.d.ts +17 -0
  42. package/dist/resources/control/auth-providers.d.ts.map +1 -1
  43. package/dist/resources/control/auth-providers.js +6 -0
  44. package/dist/resources/control/auth-providers.js.map +1 -1
  45. package/dist/resources/control/config.d.ts +22 -0
  46. package/dist/resources/control/config.d.ts.map +1 -1
  47. package/dist/resources/control/config.js +12 -0
  48. package/dist/resources/control/config.js.map +1 -1
  49. package/dist/resources/control/fleet.d.ts +15 -0
  50. package/dist/resources/control/fleet.d.ts.map +1 -1
  51. package/dist/resources/control/fleet.js +8 -0
  52. package/dist/resources/control/fleet.js.map +1 -1
  53. package/dist/resources/control/images.d.ts +20 -0
  54. package/dist/resources/control/images.d.ts.map +1 -1
  55. package/dist/resources/control/images.js +10 -0
  56. package/dist/resources/control/images.js.map +1 -1
  57. package/dist/resources/control/lifecycle.d.ts +8 -0
  58. package/dist/resources/control/lifecycle.d.ts.map +1 -1
  59. package/dist/resources/control/lifecycle.js +3 -0
  60. package/dist/resources/control/lifecycle.js.map +1 -1
  61. package/dist/resources/control/publish.d.ts +12 -0
  62. package/dist/resources/control/publish.d.ts.map +1 -1
  63. package/dist/resources/control/publish.js +6 -0
  64. package/dist/resources/control/publish.js.map +1 -1
  65. package/dist/resources/control/secrets.d.ts +28 -0
  66. package/dist/resources/control/secrets.d.ts.map +1 -1
  67. package/dist/resources/control/secrets.js +16 -0
  68. package/dist/resources/control/secrets.js.map +1 -1
  69. package/dist/resources/control/users.d.ts +22 -0
  70. package/dist/resources/control/users.d.ts.map +1 -1
  71. package/dist/resources/control/users.js +12 -0
  72. package/dist/resources/control/users.js.map +1 -1
  73. package/dist/resources/control/versioning.d.ts +12 -0
  74. package/dist/resources/control/versioning.d.ts.map +1 -1
  75. package/dist/resources/control/versioning.js +6 -0
  76. package/dist/resources/control/versioning.js.map +1 -1
  77. package/dist/resources/control/workers.d.ts +14 -0
  78. package/dist/resources/control/workers.d.ts.map +1 -1
  79. package/dist/resources/control/workers.js +7 -0
  80. package/dist/resources/control/workers.js.map +1 -1
  81. package/dist/resources/elicitations.d.ts +43 -0
  82. package/dist/resources/elicitations.d.ts.map +1 -1
  83. package/dist/resources/elicitations.js +8 -0
  84. package/dist/resources/elicitations.js.map +1 -1
  85. package/dist/resources/fleet.d.ts +90 -0
  86. package/dist/resources/fleet.d.ts.map +1 -1
  87. package/dist/resources/fleet.js +27 -4
  88. package/dist/resources/fleet.js.map +1 -1
  89. package/dist/resources/images.d.ts +34 -0
  90. package/dist/resources/images.d.ts.map +1 -1
  91. package/dist/resources/images.js +29 -3
  92. package/dist/resources/images.js.map +1 -1
  93. package/dist/resources/leader.d.ts +10 -0
  94. package/dist/resources/leader.d.ts.map +1 -1
  95. package/dist/resources/leader.js +4 -0
  96. package/dist/resources/leader.js.map +1 -1
  97. package/dist/resources/memory.d.ts +37 -0
  98. package/dist/resources/memory.d.ts.map +1 -1
  99. package/dist/resources/memory.js +28 -0
  100. package/dist/resources/memory.js.map +1 -1
  101. package/dist/resources/models.d.ts +12 -0
  102. package/dist/resources/models.d.ts.map +1 -1
  103. package/dist/resources/models.js +4 -0
  104. package/dist/resources/models.js.map +1 -1
  105. package/dist/resources/ops.d.ts +16 -0
  106. package/dist/resources/ops.d.ts.map +1 -1
  107. package/dist/resources/ops.js +6 -0
  108. package/dist/resources/ops.js.map +1 -1
  109. package/dist/resources/policy.d.ts +8 -0
  110. package/dist/resources/policy.d.ts.map +1 -1
  111. package/dist/resources/policy.js +1 -0
  112. package/dist/resources/policy.js.map +1 -1
  113. package/dist/resources/questions.d.ts +57 -0
  114. package/dist/resources/questions.d.ts.map +1 -1
  115. package/dist/resources/questions.js +9 -0
  116. package/dist/resources/questions.js.map +1 -1
  117. package/dist/resources/runs.d.ts +143 -0
  118. package/dist/resources/runs.d.ts.map +1 -1
  119. package/dist/resources/runs.js +129 -2
  120. package/dist/resources/runs.js.map +1 -1
  121. package/dist/resources/session-sync.d.ts +61 -0
  122. package/dist/resources/session-sync.d.ts.map +1 -1
  123. package/dist/resources/session-sync.js +54 -1
  124. package/dist/resources/session-sync.js.map +1 -1
  125. package/dist/resources/sessions.d.ts +74 -0
  126. package/dist/resources/sessions.d.ts.map +1 -1
  127. package/dist/resources/sessions.js +64 -2
  128. package/dist/resources/sessions.js.map +1 -1
  129. package/dist/resources/side-query.d.ts +18 -0
  130. package/dist/resources/side-query.d.ts.map +1 -1
  131. package/dist/resources/side-query.js +1 -0
  132. package/dist/resources/side-query.js.map +1 -1
  133. package/dist/resources/tasks.d.ts +19 -0
  134. package/dist/resources/tasks.d.ts.map +1 -1
  135. package/dist/resources/tasks.js +21 -2
  136. package/dist/resources/tasks.js.map +1 -1
  137. package/dist/resources/tool-approvals.d.ts +53 -0
  138. package/dist/resources/tool-approvals.d.ts.map +1 -1
  139. package/dist/resources/tool-approvals.js +10 -0
  140. package/dist/resources/tool-approvals.js.map +1 -1
  141. package/dist/resources/trace.d.ts +23 -0
  142. package/dist/resources/trace.d.ts.map +1 -1
  143. package/dist/resources/trace.js +27 -2
  144. package/dist/resources/trace.js.map +1 -1
  145. package/dist/resources/usage.d.ts +21 -0
  146. package/dist/resources/usage.d.ts.map +1 -1
  147. package/dist/resources/usage.js +8 -0
  148. package/dist/resources/usage.js.map +1 -1
  149. package/dist/resources/workflows.d.ts +48 -0
  150. package/dist/resources/workflows.d.ts.map +1 -1
  151. package/dist/resources/workflows.js +40 -3
  152. package/dist/resources/workflows.js.map +1 -1
  153. package/dist/settings.d.ts +90 -0
  154. package/dist/settings.d.ts.map +1 -1
  155. package/dist/settings.js +24 -0
  156. package/dist/settings.js.map +1 -1
  157. package/dist/sse.d.ts +36 -0
  158. package/dist/sse.d.ts.map +1 -1
  159. package/dist/sse.js +53 -8
  160. package/dist/sse.js.map +1 -1
  161. package/dist/sync.d.ts +56 -0
  162. package/dist/sync.d.ts.map +1 -1
  163. package/dist/sync.js +48 -4
  164. package/dist/sync.js.map +1 -1
  165. package/dist/transport.d.ts +32 -0
  166. package/dist/transport.d.ts.map +1 -1
  167. package/dist/transport.js +40 -8
  168. package/dist/transport.js.map +1 -1
  169. package/dist/types.d.ts +691 -1
  170. package/dist/types.d.ts.map +1 -1
  171. package/package.json +1 -1
package/dist/errors.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Typed error hierarchy (openai-node style — DESIGN §2.3). The service's error codes become semantic types so
3
+ * callers branch on the error, not on a string. 🔴 messages are SECRET-SCRUBBED before surfacing (never echo a
4
+ * token / presigned URL into an error).
5
+ */
1
6
  export class APIError extends Error {
2
7
  status;
3
8
  code;
@@ -8,8 +13,10 @@ export class APIError extends Error {
8
13
  this.name = new.target.name;
9
14
  }
10
15
  }
16
+ /** 401 / 503 — fail-closed auth (missing/bad SERVICE_AUTH_TOKEN). */
11
17
  export class AuthError extends APIError {
12
18
  }
19
+ /** 429 — per-principal rate limit. `retryAfterMs` from `Retry-After` (the SDK honors it on retry). */
13
20
  export class RateLimitedError extends APIError {
14
21
  retryAfterMs;
15
22
  constructor(status, code, message, retryAfterMs) {
@@ -17,6 +24,10 @@ export class RateLimitedError extends APIError {
17
24
  this.retryAfterMs = retryAfterMs;
18
25
  }
19
26
  }
27
+ /** 429 `code:"quota_exhausted"` — the principal's usage quota (token windows / budget) is exhausted
28
+ * (E4 double-rail, service ≥1.150.0). Extends RateLimitedError so existing 429 handling still matches;
29
+ * carries the structured deny detail so the RENDER layer can produce a human message (人话归壳 — the wire
30
+ * stays structured, no display strings here). NOT usefully retryable inside the deny window. */
20
31
  export class QuotaExhaustedError extends RateLimitedError {
21
32
  detail;
22
33
  constructor(status, code, message, retryAfterMs, detail) {
@@ -24,15 +35,24 @@ export class QuotaExhaustedError extends RateLimitedError {
24
35
  this.detail = detail;
25
36
  }
26
37
  }
38
+ /** 400 `code:"scenario_not_allowed"` — the request's explicit `body.scenario` is outside the principal's
39
+ * assigned allowlist (scenario governance, service ≥1.152.0). Carries the service's
40
+ * `allowlist` VERBATIM (pure scenario names) so the RENDER layer can offer the valid choices (人话归壳 —
41
+ * the wire stays structured, no display strings here). NOT retryable verbatim: pick a scenario from
42
+ * `allowlist`, or omit `scenario` entirely to run on the assigned default. */
27
43
  export class ScenarioNotAllowedError extends APIError {
28
44
  allowlist;
29
- constructor(status, code, message, allowlist) {
45
+ constructor(status, code, message,
46
+ /** The principal's allowed scenario names (may be empty on an older service / defensive drop). */
47
+ allowlist) {
30
48
  super(status, code, message);
31
49
  this.allowlist = allowlist;
32
50
  }
33
51
  }
52
+ /** errorCode `budget.precall` / `budget.exceeded` — per-task or per-principal cost ceiling. NOT retryable. */
34
53
  export class BudgetExceededError extends APIError {
35
54
  }
55
+ /** 409 — session already has an active run, or an idempotency conflict / session CAS conflict. */
36
56
  export class ConflictError extends APIError {
37
57
  activeTaskId;
38
58
  constructor(status, code, message, activeTaskId) {
@@ -40,13 +60,25 @@ export class ConflictError extends APIError {
40
60
  this.activeTaskId = activeTaskId;
41
61
  }
42
62
  }
63
+ /** 2c session-sync (P1d) — a PUSH (`POST …/sync/import` or its Phase-B commit) or a `POST …/sync/plan` that WOULD
64
+ * lose destination history: the relation classified to `fork` or `stale` and the caller did NOT pass
65
+ * `{ resolution: "overwrite-dst" }`. 409, errorCode `conflict`, with the classified `relation` carrying the
66
+ * exclusive entry sets (mirrors the service SyncConflictError). DISTINCT from the session-CAS ConflictError
67
+ * (same status+code, but THIS one carries a `relation` — that's how the mapper tells them apart). Client action:
68
+ * surface the keep-local / keep-cloud divergence to the user; to override, re-push with `resolution:"overwrite-dst"`.
69
+ * NEVER auto-overwrite (a silent clobber is exactly the data loss the classifier exists to prevent). */
43
70
  export class SyncConflictError extends ConflictError {
44
71
  relation;
45
- constructor(status, code, message, relation) {
72
+ constructor(status, code, message,
73
+ /** The §7 `fork`/`stale` relation with the exclusive entry sets (untyped at the JSON boundary). */
74
+ relation) {
46
75
  super(status, code, message);
47
76
  this.relation = relation;
48
77
  }
49
78
  }
79
+ /** design/80 D-1 — the checkpoint you tried to decide is already TERMINAL (someone else resolved it, it was
80
+ * GC'd past its abandonment-TTL, or its SLA deadline fired a resolve-deny). DISTINCT from a binding mismatch
81
+ * and from session-CAS 409. Client action: this pending is gone → REFETCH the inbox; do not retry the decide. */
50
82
  export class ApprovalStaleError extends APIError {
51
83
  terminal;
52
84
  constructor(status, code, message, terminal) {
@@ -54,6 +86,9 @@ export class ApprovalStaleError extends APIError {
54
86
  this.terminal = terminal;
55
87
  }
56
88
  }
89
+ /** design/80 D-1 — your decide's binding (`boundCallId` / `boundInputHash`) does NOT match the current pending
90
+ * action: it was swapped under you (TOCTOU) or you replayed a stale yes. A SAFETY signal, not an expiry.
91
+ * Client action: REFETCH the PendingCheckpoint, RE-PRESENT it to the human, NEVER auto-retry. */
57
92
  export class ApprovalBindingMismatchError extends APIError {
58
93
  field;
59
94
  constructor(status, code, message, field) {
@@ -61,26 +96,56 @@ export class ApprovalBindingMismatchError extends APIError {
61
96
  this.field = field;
62
97
  }
63
98
  }
99
+ /** design/80 D-1 (core 1.101.0) — a concurrent resolve/reopen advanced the checkpoint's revision inside the
100
+ * engine's get→resolve window, so this resume failed-closed; the row is STILL pending. TRANSIENT (≠ terminal):
101
+ * do NOT treat as ApprovalStaleError. Client action: REFETCH the PendingCheckpoint + re-present, then decide
102
+ * again (retryable). */
64
103
  export class ApprovalConcurrentlyReopenedError extends APIError {
65
104
  }
105
+ /** design/80 D-A — you steered a run that is NOT running (it is durable-`suspended`, terminal, or unknown).
106
+ * Steer is at-most-once and NOT queued. Client action: surface "task isn't running"; if suspended, the path
107
+ * forward is the approval decide, not a steer. */
66
108
  export class SteeringNotRunningError extends APIError {
67
109
  }
110
+ /** design/80 D-A — the steer text carried a control-plane escape (e.g. `</system-reminder>`) and core rejected
111
+ * it (runtask.ts:489). Client action: it's an injection attempt or a malformed steer — surface it; don't retry
112
+ * verbatim. (The BFF also fences steer text defensively; this is core's authoritative reject.) */
68
113
  export class SteeringInvalidContentError extends APIError {
69
114
  }
115
+ /** design/80 D-G (direct-connect door, service [84]) — the signed principal JWT (`X-Approval-Principal-Token`)
116
+ * failed to verify against the worker's projected pubkey anchor (bad sig / exp / iss / aud / alg-not-pinned).
117
+ * 401. Client action: re-sign a fresh short-TTL JWT; persistent ⇒ BFF signing key/anchor misaligned. FORWARD-
118
+ * DRAFT: wire codes are service-locked; the BFF signer + live path land at M2. */
70
119
  export class PrincipalUnverifiedError extends APIError {
71
120
  }
121
+ /** design/80 D-G — the JWT verified but its `cnf.bnd` ≠ SHA256(checkpointToken): the identity assertion was
122
+ * minted for a DIFFERENT decision and lifted onto this one (token-lift). A SAFETY signal. 401. Client action:
123
+ * NEVER retry verbatim; re-mint the JWT bound to THIS checkpointToken. */
72
124
  export class PrincipalUnboundError extends APIError {
73
125
  }
126
+ /** ASSISTANT-WIRE-CONTRACT §4b(service main 6cd0164)— 你对一个 human/policy_ask 门调了 resume(CONTINUE)。
127
+ * 409 errorCode `gate_not_resumable`。一个 "continue" 绝不能绕过人审。SEMANTIC(错门), NOT session-CAS ConflictError。
128
+ * Client action: 这条路是 /decide(approve/deny), 不是 resume —— 改走人审 UI。 */
74
129
  export class GateNotResumableError extends APIError {
75
130
  }
131
+ /** ASSISTANT-WIRE-CONTRACT §4c(service main 6cd0164)— 你对一个非 plan_review 门调了 plan_review。
132
+ * 409 errorCode `gate_not_plan_review`。一个 plan 决策绝不能解 tool 审批 / resource_limit。SEMANTIC(错门), NOT ConflictError。
133
+ * Client action: 按 gateKind 选对的决策端点(/decide 或 /resume), 重取 inbox。 */
76
134
  export class GateNotPlanReviewError extends APIError {
77
135
  }
136
+ /** design/80 D-G — the direct-connect door requires the HMAC envelope (`X-Approval-Mac`) and it was absent. */
78
137
  export class ApprovalMacRequiredError extends APIError {
79
138
  }
139
+ /** design/80 D-G — the HMAC envelope failed verification (wrong key/kid, or a tampered [token,callId,hash,
140
+ * decision] tuple). 401. Client action: re-sign with the active HMAC kid; persistent ⇒ key rotation skew. */
80
141
  export class ApprovalMacInvalidError extends APIError {
81
142
  }
143
+ /** Map an HTTP status + parsed body to the right typed error. Used by transport.ts. */
82
144
  export function toApiError(status, body, retryAfterMs) {
83
145
  const b = (body ?? {});
146
+ // 🔴 `error` is not always a string: the scenario-detail 404 body is `{error:{code:"scenario_not_found"}}`
147
+ // (server 1.214 server.js:570). Coerce non-strings to a fallback (and surface a nested `error.code` as the
148
+ // typed code) instead of crashing scrub() inside the error path.
84
149
  const errField = body?.error;
85
150
  const nestedCode = typeof errField === "object" && errField !== null && typeof errField.code === "string"
86
151
  ? errField.code
@@ -88,35 +153,46 @@ export function toApiError(status, body, retryAfterMs) {
88
153
  const code = b.errorCode ?? nestedCode;
89
154
  const rawMsg = b.errorMessage ?? (typeof errField === "string" ? errField : undefined);
90
155
  const msg = scrub(rawMsg ?? nestedCode ?? `HTTP ${status}`);
156
+ // scenario governance — the service 400 keys the typed code on `code` (same posture as the E4 quota
157
+ // 429; the worker envelope's `errorCode` stays untouched for every other route). The allowlist passes
158
+ // through with a per-entry type guard (a malformed entry is dropped, never crashes the error path); a bare
159
+ // code with no/bad allowlist still maps to ScenarioNotAllowedError with an empty list (generic-fallback).
91
160
  if ((code ?? b.code) === "scenario_not_allowed") {
92
161
  const allowlist = Array.isArray(b.allowlist) ? b.allowlist.filter((x) => typeof x === "string" && x.length > 0) : [];
93
162
  return new ScenarioNotAllowedError(status, "scenario_not_allowed", msg, allowlist);
94
163
  }
95
164
  if (code === "budget.precall" || code === "budget.exceeded")
96
165
  return new BudgetExceededError(status, code, msg);
166
+ // design/80 D-1 — keyed on errorCode, NOT status (both are independent of the session-CAS 409 ConflictError).
97
167
  if (code === "approval_stale" || code === "checkpoint.already_resolved")
98
168
  return new ApprovalStaleError(status, code, msg, b.terminal);
99
169
  if (code === "checkpoint.reopened_concurrently")
100
- return new ApprovalConcurrentlyReopenedError(status, code, msg);
170
+ return new ApprovalConcurrentlyReopenedError(status, code, msg); // D-1 transient (core 1.101.0)
101
171
  if (code === "approval_binding_mismatch" || code === "checkpoint.invalid_outcome")
102
172
  return new ApprovalBindingMismatchError(status, code, msg, b.field);
173
+ // ASSISTANT-WIRE-CONTRACT §4b/§4c — 错门守卫, 键于 errorCode(都是 409 但语义 ≠ session-CAS ConflictError, 不能塌进通用 409)。
103
174
  if (code === "gate_not_resumable")
104
- return new GateNotResumableError(status, code, msg);
175
+ return new GateNotResumableError(status, code, msg); // §4b resume 撞 human/policy_ask
105
176
  if (code === "gate_not_plan_review")
106
- return new GateNotPlanReviewError(status, code, msg);
177
+ return new GateNotPlanReviewError(status, code, msg); // §4c plan_review 撞非 plan_review
107
178
  if (code === "steering.not_running")
108
- return new SteeringNotRunningError(status, code, msg);
179
+ return new SteeringNotRunningError(status, code, msg); // design/80 D-A
109
180
  if (code === "steering.invalid_content")
110
- return new SteeringInvalidContentError(status, code, msg);
181
+ return new SteeringInvalidContentError(status, code, msg); // design/80 D-A (422)
182
+ // design/80 D-G (direct-connect door, service [84]) — service-locked wire codes; forward-draft until M2 BFF signer.
111
183
  if (code === "principal_unverified")
112
184
  return new PrincipalUnverifiedError(status, code, msg);
113
185
  if (code === "principal_unbound")
114
- return new PrincipalUnboundError(status, code, msg);
186
+ return new PrincipalUnboundError(status, code, msg); // cnf.bnd ≠ SHA256(token) = token-lift
115
187
  if (code === "approval_mac_required")
116
188
  return new ApprovalMacRequiredError(status, code, msg);
117
189
  if (code === "approval_mac_invalid")
118
190
  return new ApprovalMacInvalidError(status, code, msg);
119
191
  if (status === 429) {
192
+ // E4 quota deny — the SERVICE 429 body keys the typed code on `code` (NOT `errorCode`; the
193
+ // worker envelope's errorCode stays untouched for every other route). Structured fields pass through
194
+ // VERBATIM with type guards (a malformed field is dropped, never crashes the error path); a bare code
195
+ // with no fields still maps to QuotaExhaustedError with an empty detail (generic-fallback contract).
120
196
  const qCode = code ?? b.code;
121
197
  if (qCode === "quota_exhausted") {
122
198
  const detail = {
@@ -133,6 +209,8 @@ export function toApiError(status, body, retryAfterMs) {
133
209
  }
134
210
  if (status === 401 || status === 503)
135
211
  return new AuthError(status, code, msg);
212
+ // 2c session-sync: a 409 `conflict` that CARRIES a fork/stale `relation` is the SyncConflictError (distinct from
213
+ // the session-CAS ConflictError, which has no `relation`). Keyed on the relation's presence + tag, not status alone.
136
214
  if (status === 409 && code === "conflict" && (b.relation?.relation === "fork" || b.relation?.relation === "stale")) {
137
215
  return new SyncConflictError(status, code, msg, b.relation);
138
216
  }
@@ -140,6 +218,13 @@ export function toApiError(status, body, retryAfterMs) {
140
218
  return new ConflictError(status, code, msg, b.activeTaskId);
141
219
  return new APIError(status, code, msg);
142
220
  }
221
+ // ── control plane (sema-registry /api/config/*) typed errors ────────────────────────────────────────────
222
+ // The control plane is a DIFFERENT backend from the worker /v1 plane and uses a DIFFERENT error envelope:
223
+ // `{ error: "<message>" }` (no `errorCode`), with `{ error, issues }` on validation and `{ error, currentVersion }`
224
+ // on a CAS conflict. So it gets its own typed hierarchy + mapper (toControlError) — never reuse toApiError,
225
+ // whose codes/shape are worker-specific.
226
+ /** Base for every control-plane (registry) error. Distinct from APIError so a caller can branch on which plane
227
+ * failed. `message` is secret-scrubbed (a registry/proxy may echo an Authorization header into an error body). */
143
228
  export class ControlError extends Error {
144
229
  status;
145
230
  constructor(status, message) {
@@ -148,12 +233,18 @@ export class ControlError extends Error {
148
233
  this.name = new.target.name;
149
234
  }
150
235
  }
236
+ /** 401 — missing/invalid registry Bearer (SEMA_REGISTRY_TOKEN). Fail-closed. */
151
237
  export class ControlAuthError extends ControlError {
152
238
  }
239
+ /** 403 — authenticated but the token's role is below what the write needs (editor / publisher per domain).
240
+ * Client action: surface "needs a higher role"; do NOT retry with the same token. */
153
241
  export class ControlForbiddenError extends ControlError {
154
242
  }
243
+ /** 404 — unknown domain / unknown change id / unknown worker. */
155
244
  export class ControlNotFoundError extends ControlError {
156
245
  }
246
+ /** 400 — zod validation failed. `issues` carries the flat `{ path, message }[]` (batch prefixes path with
247
+ * `[changeIndex, domain, …]`). Client action: fix the offending field; this is deterministic, do NOT retry. */
157
248
  export class ControlValidationError extends ControlError {
158
249
  issues;
159
250
  constructor(status, message, issues) {
@@ -161,6 +252,9 @@ export class ControlValidationError extends ControlError {
161
252
  this.issues = issues;
162
253
  }
163
254
  }
255
+ /** 409 — optimistic-lock (CAS) conflict: config changed since the version you read, or a publish-gate / draft
256
+ * conflict. `currentVersion` (when present) is where the store is now. Client action: re-read, re-base, retry.
257
+ * NOT auto-resolved (a silent clobber is exactly what the CAS prevents). */
164
258
  export class ControlConflictError extends ControlError {
165
259
  currentVersion;
166
260
  constructor(status, message, currentVersion) {
@@ -168,6 +262,8 @@ export class ControlConflictError extends ControlError {
168
262
  this.currentVersion = currentVersion;
169
263
  }
170
264
  }
265
+ /** Map a control-plane HTTP status + parsed body to the right typed error. Body envelope is `{ error, issues?,
266
+ * message?, currentVersion? }`. 🔴 message is scrubbed (Bearer / presigned) before surfacing. */
171
267
  export function toControlError(status, body) {
172
268
  const b = (body ?? {});
173
269
  const msg = scrub(b.error ?? b.message ?? `HTTP ${status}`);
@@ -187,6 +283,7 @@ export function toControlError(status, body) {
187
283
  }
188
284
  return new ControlError(status, msg);
189
285
  }
286
+ /** Best-effort secret scrub for error text (Bearer tokens, presigned-URL signatures). Defense in depth. */
190
287
  export function scrub(s) {
191
288
  return s
192
289
  .replace(/Bearer\s+[A-Za-z0-9._\-]+/gi, "Bearer <redacted>")
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEtB;IACA;IAFX,YACW,MAAc,EACd,IAAwB,EACjC,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAoB;QAIjC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAGD,MAAM,OAAO,SAAU,SAAQ,QAAQ;CAAG;AAG1C,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACoC;IAAhF,YAAY,MAAc,EAAE,IAAwB,EAAE,OAAe,EAAW,YAAqB;QACnG,K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+ /**
2
+ * Streaming event taxonomy — the UX命脉 (DIRECTION / SERVICE-CORE-CONTEXT §3.3). A chat UI renders these
3
+ * DISTINCTLY: reasoning (collapsible thinking) / text (the answer) / tool_start+tool_end (action cards) /
4
+ * turn_end (usage+cost) / suspended (NEEDS-YOU) / done / failed. Discriminated union — switch on `type`.
5
+ *
6
+ * Two stream sources, two vocabularies (service Drift 3):
7
+ * - live token stream `POST /v1/tasks/stream`: per-token `text_delta`/`reasoning_delta` (delta = the string
8
+ * fragment, core-native) + tool_start, tool_end, turn_end, compacted, status, workspace_changed, done.
9
+ * - durable resumable stream `GET /v1/runs/:id/events`: turn-AGGREGATED `text`/`reasoning` (no deltas) +
10
+ * tool_start, tool_end, turn_end, compacted, suspended, done, failed.
11
+ *
12
+ * design/99 §E1/§E2/§E3/§E10/§E13 (core 1.121.0+, service) — three additive enrichments now ride
13
+ * the wire and are bound here (all verified against core `TaskEvent` types.ts:1027-1108 + the service projections):
14
+ * - §E1: `tool_end` carries the model-facing `output` (+ `truncated`) — the action-card BODY.
15
+ * - §E2: every CONTENT event carries `eventId` (+ `parentToolCallId` for sub-agent attribution) — the
16
+ * dedup/resume anchor. NOT on the lifecycle arms (turn_end/compacted/suspended/done/failed), matching core.
17
+ * - §E3/§E10: a `status` arm (BrainStatus — rate-limit/retry/reconnect liveness, LIVE-only, never persisted).
18
+ * - §E13: a `workspace_changed` arm (a `cd` moved the tracked cwd — LIVE-only, for the shell's path display).
19
+ */
1
20
  import type { TaskResult, CheckpointGate } from "./types.js";
21
+ /**
22
+ * design/99 §E2 (core `TaskEventIdentity` types.ts:986-989; service `identityFields` project.ts:78-83) — the
23
+ * lightweight per-event identity carried by every CONTENT event (live + durable). ADDITIVE / tolerate-absent:
24
+ * a consumer that ignores both fields is unchanged; core/service emit them only when known.
25
+ *
26
+ * - `eventId` — a core-minted, time-sortable (uuidv7) stable handle stamped on each emitted content event (and,
27
+ * on the durable leg, the turn's first `text_delta` eventId is re-stamped on the aggregated `text` event as the
28
+ * E18 per-message resume handle, runs.ts:250). Gives a live UI a stable id to correlate/dedup streamed events
29
+ * and to anchor a resume/rewind position. (The live-wire SSE `id:` = the durable `task_event.seq`, a DIFFERENT
30
+ * axis, is surfaced separately on `StampedAgentEvent.id`, sse.ts.)
31
+ * - `parentToolCallId` — present ONLY when this run is a SUB-AGENT task spawned under a parent task's tool call;
32
+ * lets a consumer attribute streamed content to the delegation subtree it belongs to (core threads it without
33
+ * physically merging the child stream into the parent — observability threading ≠ model-context isolation).
34
+ */
2
35
  export interface EventIdentity {
3
36
  eventId?: string;
4
37
  parentToolCallId?: string;
5
38
  }
39
+ /**
40
+ * design/99 §E3/§E10 — a BRAIN-LAYER liveness phase surfaced on a live `status` event (core `BrainStatusPhase`
41
+ * types.ts:998). Provider-NEUTRAL: NEVER an HTTP status / provider taxonomy / stop_reason. CLOSED union, but
42
+ * treat as open on read (a deployment may surface its own phase on its own channel) — branch known, ignore rest.
43
+ */
6
44
  export type BrainStatusPhase = "rate_limited" | "retrying" | "reconnecting" | "circuit_open";
7
- export type AgentEvent = ({
45
+ export type AgentEvent =
46
+ /** durable: turn-aggregated thinking */
47
+ ({
8
48
  type: "reasoning";
9
49
  text: string;
10
- } & EventIdentity) | ({
50
+ } & EventIdentity)
51
+ /** durable: turn-aggregated answer text (carries the E18 resume-handle `eventId`, runs.ts:250) */
52
+ | ({
11
53
  type: "text";
12
54
  text: string;
13
- } & EventIdentity) | ({
55
+ } & EventIdentity)
56
+ /** live only: per-token thinking fragment */
57
+ | ({
14
58
  type: "reasoning_delta";
15
59
  delta: string;
16
- } & EventIdentity) | ({
60
+ } & EventIdentity)
61
+ /** live only: per-token answer fragment */
62
+ | ({
17
63
  type: "text_delta";
18
64
  delta: string;
19
- } & EventIdentity) | ({
65
+ } & EventIdentity)
66
+ /** 🔴 Q6(core 1.161.0):`toolName` = **CC 工具名词汇** `Read/Edit/Write/Bash/Grep/Glob/WebFetch/
67
+ * ToolSearch/Skill`(旧 `read_file/edit_file/write_file/bash/bash_readonly/glob/grep/web_fetch/tool_search/skill`
68
+ * 全废;`bash`+`bash_readonly` 并入单名 `Bash`,只读变体靠 `handsReadOnly` 选)。SDK 当**不透明字符串透传**、不
69
+ * switch/match —— 消费方若按工具名挑图标/分类/allowlist 用 CC 名。pre-1.161 durable replay 由 core
70
+ * `canonicalToolName` shim 自动归一,不 strand。 */
71
+ | ({
20
72
  type: "tool_start";
21
73
  toolCallId: string;
22
74
  toolName: string;
@@ -26,7 +78,20 @@ export type AgentEvent = ({
26
78
  toolCallId: string;
27
79
  toolName: string;
28
80
  isError: boolean;
81
+ /**
82
+ * design/99 §E1 — the tool's MODEL-FACING result content, the action-card BODY (Read lines, Bash stdout,
83
+ * Edit diff, Grep hits). NON-UNIFORM shape: passes through AS-IS within the core size cap (a `string`, or
84
+ * `(TextContent|ImageContent)[]` blocks); when the body exceeds the cap it DEGRADES to a single TRUNCATED
85
+ * string (see {@link truncated}). A consumer MUST handle both shapes. Absent ⇒ the tool produced no body.
86
+ * 🔴 UNTRUSTED RAW + OBSERVABILITY-ONLY: external tool output (file/shell/API bodies) — the service has
87
+ * already `redactDeep`'d it (server.ts:1022 live / project.ts:99 durable) and SIZE-bounds it, but a
88
+ * consumer MAY further bound before persist/display, and MUST NEVER re-feed it to a model (the model
89
+ * already holds the full untruncated result; a truncated replay misleads it — build prompts from the
90
+ * session). core types.ts:1037-1055.
91
+ */
29
92
  output?: unknown;
93
+ /** design/99 §E1 — `true` when {@link output} was SIZE-bounded (degraded to a truncated string). Absent/
94
+ * false = `output` is the complete body. Lets a consumer detect truncation without parsing the marker. */
30
95
  truncated?: boolean;
31
96
  } & EventIdentity) | {
32
97
  type: "turn_end";
@@ -37,32 +102,86 @@ export type AgentEvent = ({
37
102
  cacheWriteTokens?: number;
38
103
  costMicroUsd?: number;
39
104
  };
40
- } | {
105
+ }
106
+ /** Context-window compaction fired. `tokensBefore` = pre-compaction token count (meter reset cue).
107
+ * 🔴 K-1(core 答复):`trigger` 区分自动(逼近窗口上限)vs 手动(`/compact`)—— 今天引擎只发 `"auto"`,
108
+ * `"manual"` 形已留位待手动指令落地;缺则按 `"auto"` 渲染。`preserved_segment`(保留摘要原文)仍 DEFER,别等。 */
109
+ | {
41
110
  type: "compacted";
42
111
  tokensBefore?: number;
43
112
  trigger?: "auto" | "manual";
44
- } | {
113
+ }
114
+ /** E12 (shell-host;service runs.ts:392 + server.ts:3633, opt-in via `TaskRequest.suggestNextPrompts`) —
115
+ * post-completion "what to ask next" prompt suggestions. Appended to the DURABLE run-events tail AFTER a
116
+ * `done` with `status:"completed"` (core's fire-and-forget LLM pass; a suspended/failed/parked leg has none).
117
+ * 🔴 UNTRUSTED model text, service-REDACTED, UI-ONLY — render as clickable next-prompt chips; NEVER re-feed to
118
+ * a model. EPHEMERAL ordering: arrives on the durable leg only (the sync `POST /v1/tasks` returns a result with
119
+ * no events tail, so it never carries suggestions). Empty/absent ⇒ no suggestions (off / not completed).
120
+ * 🔴 TWO delivery paths (both LIVE-verified, tidb engine 2026-06-27): ① this `suggestions` EVENT on the
121
+ * `runs.events` tail (runs.ts:407 `append("suggestions",…)`); ② ALSO mirrored onto `RunRecord.suggestions` —
122
+ * `runs.get` reads the LAST suggestions event into the record (server.ts:1371), so a poller that doesn't stream
123
+ * events still gets them. Stream consumers read this arm; pollers read `RunRecord.suggestions`. */
124
+ | {
45
125
  type: "suggestions";
46
126
  suggestions: string[];
47
- } | ({
127
+ }
128
+ /** design/99 §E3/§E10 (LIVE-only) — a brain-layer liveness status the brain would otherwise absorb silently
129
+ * (a 429 rate-limit / a 5xx-or-network retry / a reconnect / an open circuit breaker). EPHEMERAL: a pure
130
+ * liveness signal, never persisted or replayed on resume; provider-neutral (no HTTP status/stop_reason). Lets
131
+ * a UI show "rate limited, retrying in Ns". core `BrainStatus` types.ts:1001-1007 + the `status` arm :1081-1093. */
132
+ | ({
48
133
  type: "status";
49
134
  phase: BrainStatusPhase | (string & {});
135
+ /** Optional neutral, human-readable hint (NO provider/HTTP detail). */
50
136
  detail?: string;
137
+ /** Seconds until the brain's next retry attempt (from the honored backoff / Retry-After), when known. */
51
138
  retryInSec?: number;
52
- } & EventIdentity) | ({
139
+ } & EventIdentity)
140
+ /** design/99 MF-10 (core 1.147+, `task_progress` arm types.ts:1104-1118) — a SUBAGENT PROGRESS TICK: a delegated
141
+ * sub-run's usage ACCRUING over time, emitted at each turn boundary WHILE it runs, so a parent UI animates the
142
+ * Task card's rollup (tokens / tool-uses climbing). Emitted ONLY for a subagent (a task carrying a
143
+ * `parentToolCallId`, via `& EventIdentity`); a top-level run's own usage is the consumer's own (turn_end).
144
+ * `status` is the literal `"running"` (the terminal usage is the `done` result, NOT this arm). LIVE/EPHEMERAL —
145
+ * NOT persisted, NOT replayed on resume (like `status`).
146
+ * 🔴 WIRE NOTE: core mints this arm, but as of service `1bf7a5c` NO service projection forwards it onto a
147
+ * CLIENT wire (`/v1/tasks/stream` or `/v1/runs/:id/events`) — the service consumes it INTERNALLY
148
+ * (`fleetRunPublisher.onEvent`, fleet-bus.ts:175) and re-expresses it as a fleet CHILD row (`parentId`+tokens)
149
+ * on `GET /v1/fleet/stream`. So today MF-10 is observable via `client.fleet.stream()` subagent child rows; this
150
+ * AgentEvent arm is the core-arm MIRROR and will surface on the task/run streams ONLY IF a future service
151
+ * projection transparently passes it through. Additive / tolerate-absent on read. */
152
+ | ({
53
153
  type: "task_progress";
154
+ /** The subagent's task id (the delegated sub-run). */
54
155
  taskId: string;
156
+ /** 🔴 BC-2 (core 1.151 / @sema-agent/server 1.6.1, runtask.js:752): the subagent's HUMAN display name for fleet
157
+ * child-row labels — derived from the subagent's declared label, NOT the raw objective (no leak). **Absent ⇒
158
+ * no name** (the child keeps its taskId; deliberately does NOT fall back to the objective). Additive/tolerate-absent. */
55
159
  name?: string;
160
+ /** Cumulative usage as of this turn boundary (closed 3-field set, byte-aligned to core). */
56
161
  usage: {
57
162
  totalTokens: number;
58
163
  toolUses: number;
59
164
  durationMs: number;
60
165
  };
166
+ /** Always the literal `"running"` mid-run (the terminal usage is the `done` result). */
61
167
  status: "running";
62
- } & EventIdentity) | ({
168
+ } & EventIdentity)
169
+ /** design/99 §E13 (LIVE-only) — the task's tracked working directory CHANGED mid-run (a `bash` `cd` moved it);
170
+ * carries the new logical cwd so a shell UI updates its prompt/path. Only fires when a real shell is mounted;
171
+ * the initial cwd is NOT announced (only subsequent changes). EPHEMERAL (not persisted; resets across a
172
+ * suspend/resume). core `workspace_changed` arm types.ts:1094-1107. */
173
+ | ({
63
174
  type: "workspace_changed";
64
175
  cwd: string;
65
- } & EventIdentity) | ({
176
+ } & EventIdentity)
177
+ /** [747] SendUserFile 渲染半场(board [966]②b)— the engine SENT THE USER A FILE via a presigned link
178
+ * (server ≥1.20x send-user-file tool; probe `capabilities().sendUserFile` before rendering affordances).
179
+ * Shape verified against server dist capabilities/send-user-file-tool.js `emitter.emit({type:"file_link",…})`:
180
+ * `url` = the presigned download URL (EXPIRES after `ttlSec` seconds — render a fetch-soon affordance, never
181
+ * persist the URL as durable); `status` = "normal" (a turn deliverable) | "proactive" (mid-run push);
182
+ * `display` hint = "render" (inline preview) | "attach" (attachment row), absent = consumer's default.
183
+ * Closed unions on the wire (server validates input), but treat as open on read — branch known, ignore rest. */
184
+ | ({
66
185
  type: "file_link";
67
186
  url: string;
68
187
  filename: string;
@@ -71,12 +190,26 @@ export type AgentEvent = ({
71
190
  status: "normal" | "proactive";
72
191
  caption?: string;
73
192
  display?: "render" | "attach";
74
- } & EventIdentity) | {
193
+ } & EventIdentity)
194
+ /** HITL: the run paused on an F4 policy gate or AskUserQuestion. The consumer must surface an approve/deny
195
+ * (or answer) decision via `client.approvals.decide(...)`, then resume. `gate` carries what's being asked.
196
+ * DURABLE-only (the live loop never writes `suspended`; the durable leg synthesizes it from the run row). */
197
+ | {
75
198
  type: "suspended";
76
199
  gate?: CheckpointGate | null;
77
- } | ({
200
+ }
201
+ /** durable (server ≥1.219, [998]②/[1005]①a): the prepare's prompt-assembly manifest — lands AHEAD of the
202
+ * first event of the turn it prepared (service runs.ts flushPromptManifest / trace/project.ts
203
+ * appendPromptManifest 实拆:`append("prompt_assembled", record)`). ids/digests/counts ONLY, never prompt
204
+ * bodies; hashes process-salted (not cross-restart comparable). ⚠️ MULTIPLE per task on cascade/verify runs
205
+ * (one per prepare, emission order); a resumed leg appends its own re-fired manifest. */
206
+ | ({
78
207
  type: "prompt_assembled";
79
- } & import("./types.js").PromptManifest) | {
208
+ } & import("./types.js").PromptManifest)
209
+ /** MF-W / per-model usage delta(@sema-agent/server 1.6.x;service runs.ts:265 / trace/project.ts:28 `append("model_usage",{usage:delta})`)
210
+ * —— **LIVE 实采(canary 1.6.1 在线验形 2026-06-27)**:`usage` 按模型名键控每模型的 token/cost 增量,与 `done.result.stats.modelUsage`
211
+ * 同源(多模型 run / role-routing 时区分各模型花费)。值字段同 `turn_end.usage`(均可缺,开集容演进)。 */
212
+ | {
80
213
  type: "model_usage";
81
214
  usage: Record<string, {
82
215
  inputTokens?: number;
@@ -86,13 +219,18 @@ export type AgentEvent = ({
86
219
  costMicroUsd?: number;
87
220
  [k: string]: unknown;
88
221
  }>;
89
- } | {
222
+ }
223
+ /** carries the full TaskResult (output string at .result, stats at .stats) — service Drift 4 */
224
+ | {
90
225
  type: "done";
91
226
  result: TaskResult;
92
- } | {
227
+ }
228
+ /** DURABLE-only (the live loop never writes `failed`; the durable leg synthesizes it from the run row). */
229
+ | {
93
230
  type: "failed";
94
231
  errorCode?: string;
95
232
  errorMessage?: string;
96
233
  };
234
+ /** Exhaustiveness helper for consumers' switch statements. */
97
235
  export declare function assertNever(x: never): never;
98
236
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAgB7D,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,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AA;CAAE,GAAG,OAAO,YAAY,EAAE,cAAc,CAAC;AACtE;;4EAE4E;GAC1E;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAA;CAAE;AACnM,gGAAgG;GAC9F;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE;AACtC,2GAA2G;GACzG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE3C"}
package/dist/events.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** Exhaustiveness helper for consumers' switch statements. */
1
2
  export function assertNever(x) {
2
3
  throw new Error(`unhandled AgentEvent: ${JSON.stringify(x)}`);
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AA2LA,MAAM,UAAU,WAAW,CAAC,CAAQ;IAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AA0LA,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,CAAQ;IAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC"}