@sema-agent/sdk 18.0.0 → 18.1.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/openapi.yaml CHANGED
@@ -3234,7 +3234,9 @@ paths:
3234
3234
  Frames: `meta` ({type,version,mode:"approvals-delta",pollMs}), then `synced` ({type,count}) once the
3235
3235
  first full snapshot has been emitted, then `pending`/`resolved` deltas; plus `heartbeat` ({type}) on the
3236
3236
  keep-alive tick and a terminal `error` ({type,errorCode:"STREAM_MAX_DURATION",…}) when the 15-min cap
3237
- fires. (Corrected 2026-07-31: this list used to name only meta/pending/resolved — a consumer written to
3237
+ fires — or, server >= 7.122.0, `error` with `errorCode:"draining"` at the moment the instance enters drain (same code and
3238
+ sentence as the billable-submit 503 `draining`; the server closes the stream right after the frame, reconnect to the
3239
+ replacement instance). (Corrected 2026-07-31: this list used to name only meta/pending/resolved — a consumer written to
3238
3240
  it silently drops three frame kinds it really receives.) Each data payload mirrors its SSE event name in
3239
3241
  `data.type` — proxy-safe dispatch. Cross-replica by
3240
3242
  construction (polls the SHARED checkpoint table). 15-min cap + heartbeats; a DB blip retries, never
@@ -3735,8 +3737,12 @@ paths:
3735
3737
  `ErrorResponse`-shaped. Codes: "request.body_shape" (bad/missing `decision`, OR an unrecognised
3736
3738
  top-level key — server >= 7.86.0 / S-438 key closure, the body carries `unknownKeys` /
3737
3739
  `unsupportedKeys`) · "request.field_conflict" (`edit` without a non-empty `editedPlan`;
3738
- `editedPlan` present on approve/reject; `permissionModeAfter` sent with `edit`/`reject`;
3739
- `permissionModeAfter` on a task that was not submitted with `permissionMode:"plan"`) ·
3740
+ `editedPlan` present on approve/reject; `permissionModeAfter` sent with `reject`;
3741
+ `permissionModeAfter` on a task whose stored permission mode is not `plan`) — match these two by CODE;
3742
+ server >= 7.122.0: `approve` and `edit` both carry the plan out of plan mode and both take the key, and a
3743
+ run's mode word has ONE source, the stored submit body (an operator `AUTONOMY=plan` task is stored as `plan`
3744
+ and takes the key); <= 7.121.x only `approve` took it and the second conflict read "not submitted with
3745
+ `permissionMode:"plan"`" ·
3740
3746
  "request.field_invalid" (non-string `reason`; `permissionModeAfter` outside the two-word closed
3741
3747
  set — zero widening arm) · "request.path_malformed" (a bad percent-encoded path segment —
3742
3748
  server >= 7.86.0 / S-430 turned that family from 500 `internal.error` into a 400 across 16 doors).
@@ -4668,7 +4674,8 @@ paths:
4668
4674
  (`LEADER_ENABLED` off) the answer depends on the server: server >= 7.116.0 mounts the route unconditionally and answers
4669
4675
  **501 `capability.leader_endpoint_required`** (new code; under multi-tenant the identity gate's 401 still comes first);
4670
4676
  <= 7.115.x did not register the route at all → the generic **404** `not_found.route`. Detect "leader unavailable" by
4671
- `errorCode` (or the `capabilities.leader` bit, which reads the same fact as the gate), not by the status alone.
4677
+ `errorCode` (or the `capabilities.leader` bit — server >= 7.122.0 also reads false on a deployment whose operator runs `AUTONOMY=plan`, where a submit answers
4678
+ 422 `request.autonomy_lane_refused` instead; see `Capabilities.leader`), not by the status alone.
4672
4679
 
4673
4680
 
4674
4681
  🔴 IDEMPOTENCY (server >= 7.24.0): this POST now consumes the `Idempotency-Key` header — the header is
@@ -4717,6 +4724,20 @@ paths:
4717
4724
  content:
4718
4725
  application/json:
4719
4726
  schema: { $ref: '#/components/schemas/ErrorResponse' }
4727
+ '422':
4728
+ description: >-
4729
+ errorCode "request.autonomy_lane_refused" (server >= 7.122.0) — the deployment runs the operator `AUTONOMY=plan`: every task starts
4730
+ in plan mode and leaves it only when a person approves its plan through plan review, and a leader task's workers have no plan
4731
+ review channel, so they could neither write nor hand their plan to anyone who can approve it. REFUSED at the door, NO run created;
4732
+ a replay with the same `Idempotency-Key` gets the same 422 (the idempotency key is not consumed). The `capabilities.leader` bit
4733
+ reads false on such a deployment (the same judgement as this refusal) — read it, or `GET /v1/policy` `autonomy`, beforehand. Exits: submit the work as a run (`POST /v1/runs`, plan reviewed through
4734
+ `POST /v1/assistant/tasks/{taskId}/plan_review`), or ask the operator to set `AUTONOMY=read-only` or `ask` (leader tasks run
4735
+ there). Not the hosted-posture refusal (`request.host_posture_refused`): that one is the tenant axis, this one is the AUTONOMY
4736
+ axis. A change to `plan` after acceptance is caught where the run is born: the 202'd run ends with the same sentence in
4737
+ `GET /v1/leader/{leaderRunId}` `error` and no worker is started.
4738
+ content:
4739
+ application/json:
4740
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
4720
4741
  '409':
4721
4742
  description: >-
4722
4743
  errorCode "conflict.leader_run_exists" (server >= 7.24.0) — your `Idempotency-Key` hit a leader run
@@ -7206,7 +7227,12 @@ components:
7206
7227
  `config.permission_mode_unavailable`. `bypassPermissions` RELEASES the ten releasable ask classes (server >= 7.115.0: the tenth is `unstated`, a server-tool call nobody stated)
7207
7228
  and DISCLOSES each (`tool_end.gate.disposition.released` + one `engine_notice` `permission.ask_released_by_mode` per (mode, class) per run);
7208
7229
  immune classes (deployment-authored, ask / org rules, hooks, ancestors, questions …) still ask; a write whose protection
7209
- cannot be judged is refused (`deniedBy: mode`). Request vocabulary: SIX words (server >= 7.119.0) — `dontAsk`, the engine's
7230
+ cannot be judged is refused (`deniedBy: mode`) on the file tools — and, from server >= 7.122.0 / core 7.47.0, RELEASED on the SHELL face
7231
+ (an eleventh class, `write_protection_unresolved`, for a caller-supplied tool whose wire name is exactly `Bash` or `Monitor` and which
7232
+ declares a write-path target; see `ModeRelease.reason`). `plan` (server >= 7.122.0): the engine's plan mode and nothing the service adds —
7233
+ the tool table equals `default`'s, the engine mounts the plan-presenting tool, and a write or any non-read-only call is asked AT CALL TIME by the
7234
+ engine's plan gate (a card where somebody can answer, a refusal where nobody can; a delegated sub-agent inherits plan as its ceiling); up to
7235
+ 7.121.x the service also mapped `plan` to read-only hands, withheld the delegation tool and refused `Workflow`. Request vocabulary: SIX words (server >= 7.119.0) — `dontAsk`, the engine's
7210
7236
  "auto-refuse" mode, is accepted and passes through verbatim: the ENGINE refuses the calls that would ask (no card, no parked row,
7211
7237
  `tool_end.gate.disposition = { kind: denied, deniedBy: mode, mode: dontAsk, … }`), the run ends normally, and it is never looser
7212
7238
  than `default`. One exception: a PreToolUse hook's OWN ask, when no other class in that ask's set backs it, is still handed to a person
@@ -7216,7 +7242,7 @@ components:
7216
7242
  hold for <= 7.105.0 only.
7217
7243
  CC-parity permission-mode INTENT — the values THIS wire's closed submit-gate accepts (the first five on server <= 7.118.x,
7218
7244
  plus `dontAsk` from 7.119.0 = the engine's whole mode vocabulary, `capabilities.permissionModes`). The frontend (TUI shell / web portal) carries the RAW mode; the SERVICE interprets it TIGHTEN-ONLY vs the deployment baseline:
7219
- `plan` ⇒ mount present_plan (core enablePlanMode) + read-only hands (CC EnterPlanMode research);
7245
+ `plan` ⇒ mount present_plan (core enablePlanMode) + read-only hands (CC EnterPlanMode research) — that is the <= 7.121.x reading; server >= 7.122.0: see the `plan` sentence in the first block;
7220
7246
  `default` adds the manual ask gate on non-exempt writes (scratchpad dirs / remembered session
7221
7247
  exemptions still auto-allow — not literally every Write/Edit); the server emits the SAME gate-policy
7222
7248
  for `auto` as for `default` — sending `auto` is NOT itself what arms core's auto-mode classifier; that
@@ -9077,7 +9103,16 @@ components:
9077
9103
  asyncRuns: { type: boolean }
9078
9104
  artifacts: { type: boolean }
9079
9105
  approvals: { type: boolean }
9080
- leader: { type: boolean }
9106
+ leader:
9107
+ type: boolean
9108
+ description: >-
9109
+ The `POST /v1/leader` lane. server >= 7.122.0 reads the conjunction of two facts: the leader face is mounted (`LEADER_ENABLED` etc.) AND the
9110
+ operator entry floor takes leader submissions — the same judgement as the 422 `request.autonomy_lane_refused` at the door (a leader task's
9111
+ workers have no plan review channel). So on a deployment whose operator runs `AUTONOMY=plan` the bit reads false and a direct submit still
9112
+ answers 422 `request.autonomy_lane_refused`; with `AUTONOMY=read-only` / `ask` / unset the bit follows the face. A false bit from an absent face
9113
+ answers 501 `capability.leader_endpoint_required` on submit (404 `not_found.route` on <= 7.115.x) — tell the two falses apart by the submit's
9114
+ `errorCode`, or read `GET /v1/policy` `autonomy` beforehand. <= 7.121.x (historical reading): the bit read the face only — true on a `plan`
9115
+ deployment, no prediction of the refusal.
9081
9116
  version: { type: string }
9082
9117
  scenarios:
9083
9118
  type: array
@@ -9928,13 +9963,16 @@ components:
9928
9963
  taskWriteFaceOpen:
9929
9964
  type: boolean
9930
9965
  description: >
9931
- server >= 7.95.0 (S-591; value meaning refined at 7.96.0 / S-613; mint `routes/capabilities.ts:653` =
9932
- `taskWriteFaceRefusal(deps.config) === undefined && autonomyOverrides(deps.config.autonomy).writeFace !== "roots"`)
9966
+ server >= 7.95.0 (S-591; value meaning refined at 7.96.0 / S-613; mint `routes/capabilities.ts` =
9967
+ `taskWriteFaceRefusal(deps.config) === undefined && autonomyKeepsOpenWriteFace(deps.config.autonomy)` from server >= 7.122.0;
9968
+ up to 7.121.x the right half was `autonomyOverrides(deps.config.autonomy).writeFace !== "roots"`)
9933
9969
  — DISCLOSURE BIT OF THE WRITE-CONTAINMENT FACE: does this deployment honour the task-level "open the write
9934
9970
  fence" declaration (`permissionMode:"bypassPermissions"` ⇒ `TaskSpec.writeFace:"open"`, writes outside the
9935
9971
  workspace roots)? `false` has two forms: (1) the hosted-posture gate refuses ⇒ sending that mode gets
9936
- `422 request.host_posture_refused`; (2) the deployment runs `AUTONOMY=read-only|plan` ⇒ the request is
9937
- accepted but the write face is clamped back to roots — the declaration silently does nothing. Three states
9972
+ `422 request.host_posture_refused`; (2) the deployment runs `AUTONOMY=read-only` ⇒ the request is
9973
+ accepted but the write face is clamped back to roots — the declaration silently does nothing; server >= 7.122.0: `AUTONOMY=plan`
9974
+ reads `false` too, but because the entry mode word is clamped to `plan` at admission (the engine's plan mode runs instead of
9975
+ `bypassPermissions`; up to 7.121.x it was the same read-only-hands + roots clamp as `AUTONOMY=read-only`, and a hosted deployment answered 422 `request.host_posture_refused` where it now accepts the request into plan). Three states
9938
9976
  are folded into one bit on purpose: the caller has exactly one decision (send that key or not); tier and
9939
9977
  evidence live in the refusal body and the operator's `GET /v1/diagnostics/wiring`. It speaks ONLY for the
9940
9978
  write-containment cell — the other two columns of `bypassPermissions` are unaffected.
@@ -12848,8 +12886,9 @@ components:
12848
12886
  REQUIRED iff `decision==="edit"` (FORBIDDEN otherwise → 400).
12849
12887
  🔴 THE BODY KEY SET IS CLOSED (server >= 7.86.0 / S-438): an unrecognised top-level key is refused with
12850
12888
  400 `request.body_shape` plus the `unknownKeys` / `unsupportedKeys` machine tables — refused rather
12851
- than dropped, because a misspelled `permissionModeAfter` would otherwise silently leave the task
12852
- read-only after its plan was approved.
12889
+ than dropped, because a misspelled `permissionModeAfter` would otherwise silently fold to `default`
12890
+ (the task keeps asking before each write after its plan was approved) while the caller believes the
12891
+ mode was settled.
12853
12892
  required: [decision]
12854
12893
  additionalProperties: false
12855
12894
  properties:
@@ -12860,18 +12899,35 @@ components:
12860
12899
  type: string
12861
12900
  enum: [default, acceptEdits]
12862
12901
  description: >
12863
- server >= 7.86.0 (S-433, P1; mints `routes/approvals-assistant.ts:1021/1024/1148`) — WHICH
12864
- PERMISSION MODE THIS TASK CONTINUES IN once the plan is approved. Before this key, approving a plan
12865
- was a BLANK CHEQUE: the plan was approved while the read-only clamp stayed on and every write kept
12866
- asking. `acceptEdits` = writes stop asking; `default` = keep asking (AND is the folded value when
12867
- the key is absent, so an older shell executes plans unchanged).
12868
- 🔴 THREE 400s, each with its own code: a value outside the two-word closed set ⇒
12902
+ server >= 7.86.0 (S-433, P1) — WHICH PERMISSION MODE THIS TASK CONTINUES IN once the plan is approved.
12903
+ `acceptEdits` = writes stop asking; `default` = keep asking (AND is the folded value when the key is
12904
+ absent, so an older shell executes plans unchanged). The decision writes the mode back into the task's
12905
+ stored submit body, so every later park -> resume continues in it and never falls back to plan.
12906
+ 🔴 server >= 7.122.0 — ONE JUDGE, ONE SOURCE: plan is only the engine's `permissionMode:"plan"`. Since 7.122.0
12907
+ the service adds no read-only clamp of its own, so there is none to lift: the tool table equals `default`'s,
12908
+ and a write or any non-read-only call is asked (somebody can answer) or refused (nobody can) AT CALL TIME by
12909
+ the engine's plan gate. A run's mode word has ONE source, the stored submit body; its two writers are the submit door
12910
+ and this write-back. A decision that carries the plan out of plan mode — `approve` (the original plan) or
12911
+ `edit` (the person's revised plan; the engine proceeds with it) — writes this key back (absent => `default`);
12912
+ only `reject` (the review goes back to redo the plan, plan mode stays) does not. Before 7.122.0 the service
12913
+ also mapped plan to read-only hands; this key was added in 7.86.0 because, before it, approving a plan was a
12914
+ BLANK CHEQUE (the plan was approved while the read-only clamp stayed on and every write kept asking); and on
12915
+ 7.86.0-7.121.x `edit` + this key was a 400 while `edit` itself wrote back `plan`, the continuation still held
12916
+ by the read-only hands. All of that is gone since 7.122.0.
12917
+ (A deployment's `AUTONOMY=read-only` static fence is a separate thing: since 7.122.0 it is all the service's governance
12918
+ layer re-folds on each resume, it has nothing to do with approving a plan, and approval does not lift it.)
12919
+ 🔴 THREE 400s, each with its own code (match by CODE, not by sentence — the two `request.field_conflict`
12920
+ sentences were reworded in 7.122.0, codes unchanged): a value outside the two-word closed set =>
12869
12921
  `request.field_invalid` (ZERO widening arm — this bit decides whether the model has hands after
12870
12922
  approval, so folding a misspelling into either mode is a silent downgrade on the security axis);
12871
- sending it with `edit`/`reject` ⇒ `request.field_conflict` (core: those two send the plan back to be
12872
- redone and the read-only clamp stays — dropping it there would let the caller believe the mode was
12873
- settled); sending it for a task that was NOT submitted with `permissionMode:"plan"` ⇒
12874
- `request.field_conflict` (approving the plan lifts no read-only restriction there).
12923
+ sending it with `reject` => `request.field_conflict`, server sentence `permissionModeAfter is only valid with a
12924
+ decision that carries the plan out ('approve' or 'edit'; got 'reject')` (a silent drop there would let the caller
12925
+ believe the mode was settled); sending it for a task whose STORED permission mode is not `plan` (the model
12926
+ entered plan mode itself, so approving returns it to the mode it was in before planning) =>
12927
+ `request.field_conflict`, server sentence `permissionModeAfter does not apply to this task: it was not
12928
+ started in plan mode (its stored permission mode is not "plan"), so approving the plan returns it to the mode
12929
+ it was in before planning`. A task STARTED in plan mode is one the request put there, or one an operator
12930
+ `AUTONOMY=plan` stamped at the submit door (its stored word is `plan`): the key is accepted for both.
12875
12931
  ⚠️ DIRECT-DOOR deployments: this key rides the HMAC envelope's TRAILING EXTENSION OBJECT (server
12876
12932
  7.87.0: `{answer?, permissionModeAfter?}`, present keys in lexicographic order; 7.86.0's bare
12877
12933
  trailing slot is DELETED with zero double-read) ⇒ a signer must sign the new shape, and mixed
@@ -13717,6 +13773,14 @@ components:
13717
13773
  `writeFace: open`; read `capabilities.taskWriteFaceOpen` first); (2) server >= 7.106.0 / S-895: `inheritEnv: "all"` on a
13718
13774
  hosted deployment (`REQUIRE_PRINCIPAL=true`; reach = the hosted posture only; read `capabilities.projectContext` first).
13719
13775
  Remove the key (or send `inheritEnv: "scrub"`) and resend. Resume legs fold it into 409 `resume_blocked_by_policy`.
13776
+ 🔴 `request.autonomy_lane_refused` (422, server >= 7.122.0): the deployment's operator `AUTONOMY` does not take tasks on this LANE.
13777
+ Today's only trigger is `AUTONOMY=plan` × `POST /v1/leader` — plan leaves plan mode only through a person approving the plan (plan
13778
+ review), a leader task's workers have no plan review channel, so the refusal is at the door and NO run is created (a replay with the
13779
+ same `Idempotency-Key` gets the same 422 and does not consume the key). Same family as `host_posture_refused` but a different axis:
13780
+ that one is the hosted / tenant posture axis (remove the key and resend); this one is the AUTONOMY axis (nothing to remove — submit
13781
+ as a run via `POST /v1/runs`, or ask the operator for `AUTONOMY=read-only` / `ask`, under which leader tasks run). Read the live
13782
+ config: a hot change takes effect on the next request; read `GET /v1/policy` `autonomy` beforehand (the `capabilities.leader` bit
13783
+ reads false on such a deployment).
13720
13784
  error: { type: string }
13721
13785
  errorMessage: { type: string }
13722
13786
  activeTaskId:
@@ -14455,7 +14519,9 @@ components:
14455
14519
  bypass-IMMUNE (not releasable).
14456
14520
  CLOSED on the gate record (screened with core `isAskClass`). `bypassPermissions` releases only the ten RELEASABLE classes
14457
14521
  (`transcript_write` / `rule_unreadable` / `probe` / `write_protection` / `tool_marks_mcp` / `tool_marks_a2a` /
14458
- `artifact_shared_read` / `mode` / `unstated` / `ordinary`); every other class (deployment-authored `operator_forced`, ask / org rules, hook,
14522
+ `artifact_shared_read` / `mode` / `unstated` / `ordinary`) — on every face — plus, from server >= 7.122.0 / core 7.47.0, an eleventh on the SHELL
14523
+ face only: `write_protection_unresolved` (core `releasableAskClassesFor(face)`: shell 11, other faces 10; on the file tools that class is
14524
+ refused, `deniedBy: mode`); every other class (deployment-authored `operator_forced`, ask / org rules, hook,
14459
14525
  ancestor, content question, …) asks under every mode.
14460
14526
  ModeRelease:
14461
14527
  type: object
@@ -14477,8 +14543,19 @@ components:
14477
14543
  mandate: { $ref: '#/components/schemas/PersistedRuleMandate' }
14478
14544
  reason:
14479
14545
  type: string
14480
- enum: [rule_unreadable]
14481
- description: '`rule_unreadable` = the release went over a rule this call could not be read against (the rule store was unreadable — a security-axis fail-open direction the server discloses on its own).'
14546
+ enum: [rule_unreadable, write_protection_unresolved]
14547
+ description: >
14548
+ WHAT the release went over — one word: the FIRST member (in core `MODE_RELEASE_REASONS` array order) that the ask's class
14549
+ set holds; ABSENT when the set holds none. CLOSED set — the server screens it with core `isModeReleaseReason`, so a word
14550
+ outside it withholds the whole `gate` from the frame (and a consumer that dispatches on the word must learn each new one).
14551
+ `rule_unreadable` = the release went over a rule this call could not be read against (the rule store was unreadable — a
14552
+ security-axis fail-open direction the server discloses on its own).
14553
+ `write_protection_unresolved` (server >= 7.122.0 / core 7.47.0) = the release went over a write whose target the
14554
+ write-protection judge could not RESOLVE (whether it lands on the protected table is unknown). It is released on the SHELL
14555
+ face only: a caller-supplied tool whose wire name is exactly `Bash` or `Monitor` and which declares a write-path target,
14556
+ under `bypassPermissions`; on the file tools the same unresolved write is still refused (`deniedBy: mode`). The engine's
14557
+ own `Bash` / `Monitor` cannot mint this class and the server mounts no such tool — it comes from a caller-embedded tool of
14558
+ those names. Before server 7.122.0 / core 7.47.0 the set was `rule_unreadable` alone.
14482
14559
 
14483
14560
  GateClassifierAttribution:
14484
14561
  # sdk 9.5.0:具名 —— 同一份形挂在 `GateDisposition` 的两只臂上,内联会立刻是两份会各自漂的镜像。
@@ -17871,13 +17948,16 @@ components:
17871
17948
  🔴 Its arrival means the RUN IS STILL ALIVE — the 15-minute stream cap fired. The correct handling is to
17872
17949
  RECONNECT with `Last-Event-ID` and keep reading (the durable leg stamps `id:` on every frame); rendering
17873
17950
  it as a terminal would declare a live task dead. `done` / `failed` are the terminal arms; this one is not.
17874
- Known `errorCode`: `STREAM_MAX_DURATION` (open set — branch on the code, degrade unknown codes to the
17875
- generic "reconnectable stream-control signal").
17951
+ Known `errorCode`: `STREAM_MAX_DURATION` (the 15-minute cap) · `draining` (server >= 7.122.0: the instance entered drain / is being
17952
+ replaced — each of the eight read-only subscription streams gets this frame at the moment drain begins and is then closed by the server;
17953
+ same code and sentence as the billable-submit 503 `draining`, same reconnect protocol: reconnect with `Last-Event-ID`, the replacement
17954
+ instance serves it; NOT a run failure; the same reason family as the cap — the server closes a stream for flow control)
17955
+ (open set — branch on the code, degrade unknown codes to the generic "reconnectable stream-control signal").
17876
17956
  additionalProperties: false
17877
17957
  required: [type, errorCode]
17878
17958
  properties:
17879
17959
  type: { const: error }
17880
- errorCode: { type: string, description: 'STREAM_MAX_DURATION (open set).' }
17960
+ errorCode: { type: string, description: 'STREAM_MAX_DURATION | draining (server >= 7.122.0) (open set).' }
17881
17961
  message: { type: string }
17882
17962
  Event_question:
17883
17963
  type: object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/sdk",
3
- "version": "18.0.0",
3
+ "version": "18.1.0",
4
4
  "description": "Typed, zero-runtime-dependency SDK for the Sema agent fleet usage plane. The shared substrate for all doors (CC/Codex MCP façade + web). Server-side only — tokens never enter the browser.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",