@sema-agent/sdk 29.0.0 → 30.0.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
@@ -1881,6 +1881,11 @@ paths:
1881
1881
  the row can write it, never wider; an operator / service token gets no extra reach; a stranger and "no such session" answer byte-identical
1882
1882
  `404 not_found.session`, no existence oracle) -> body (400) -> the store's one write door -> read back and answer with the list row.
1883
1883
  Only rows on the LIST face are writable: a placed (delegation-transcript) session is not in the list, so a PATCH on it answers 404.
1884
+ server >= 7.139.0 (contract section 20, "conditional write"): the body may carry `expectedRowTag` (the `rowTag` of the list row you read) — "write only if the row is still that one", judged and written under one row lock.
1885
+ Still that row ⇒ `200`, the row carrying the tag AFTER the write (the tag is a function of the writable bits' VALUES and of the session itself, NOT a write counter: it changes when a value actually changed; writing the value the row already holds — `pinned: false` on an unpinned row — returns the SAME tag); no longer ⇒ `409 conflict.session_row_changed`, NOT ONE BYTE written, body `currentRow` = the row as it stands now (the same projection as the 200 row, with the new `rowTag`) —
1886
+ decide again, then send ITS `rowTag`; never resend verbatim. EVERY miss is a 409 (no "the row already holds the value you want" exemption: `currentRow` already equal to what you wanted ⇒ treat it as synced). A session that is a
1887
+ read-only MIRROR here (execution placement `mirror`) ⇒ `409 conflict.session_mirror` with `forkPath` — with or without `expectedRowTag` (an unconditional PATCH on a mirror used to write). A session whose owner changed after the
1888
+ ownership gate read ⇒ `404 not_found.session`, nothing written. A client that auto-replays pending writes MUST send `expectedRowTag`.
1884
1889
  requestBody:
1885
1890
  required: true
1886
1891
  content:
@@ -1896,13 +1901,23 @@ paths:
1896
1901
  description: >-
1897
1902
  Malformed body, told apart by `errorCode` (branch on the code, never the sentence). `request.body_shape` — not a JSON object / empty body /
1898
1903
  a key outside the closed set `{ title, pinned }` / `title: ""` (the only spelling of "clear" is `null`). `request.field_invalid` — `title`
1899
- neither a string nor `null`, longer than 120 characters, or with leading / trailing whitespace; `pinned` not a boolean. Invalid JSON answers
1904
+ neither a string nor `null`, longer than 120 characters, or with leading / trailing whitespace; `pinned` not a boolean; (server >= 7.139.0) `expectedRowTag` not a 43-character `[A-Za-z0-9_-]` string.
1905
+ Server >= 7.139.0: `expectedRowTag` ALONE (no `title` / `pinned`) is `request.body_shape` too; a server <= 7.138.x answers `request.body_shape` for the key itself — fail-closed, do not drop it and resend. Invalid JSON answers
1900
1906
  like every other JSON-body route (`request.invalid_json`). The row is untouched on any 400.
1901
1907
  content:
1902
1908
  application/json:
1903
1909
  schema: { $ref: '#/components/schemas/ErrorResponse' }
1904
1910
  '401': { $ref: '#/components/responses/Unauthorized' }
1905
1911
  '404': { $ref: '#/components/responses/NotFound' }
1912
+ '409':
1913
+ description: >-
1914
+ server >= 7.139.0, told apart by `errorCode` (both `ConflictError`, `activeTaskId` absent): `conflict.session_row_changed` — the body carried `expectedRowTag` and the row is no longer that one; NOTHING was written;
1915
+ top-level `currentRow` = the list row as it stands now (same projection as the 200 row, with the new `rowTag`) — treat it as synced if its writable bits already equal what you wanted, else decide again and send ITS `rowTag`
1916
+ (never resend verbatim). `conflict.session_mirror` — this session is a read-only MIRROR of a session whose writer is elsewhere (execution placement `mirror`), it cannot be renamed or pinned here, with or without
1917
+ `expectedRowTag`; top-level `forkPath` (`/v1/sessions/{id}/fork`): fork it to continue here; nothing was written.
1918
+ content:
1919
+ application/json:
1920
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
1906
1921
  '501': { $ref: '#/components/responses/NotImplemented' }
1907
1922
  delete:
1908
1923
  tags: [sessions]
@@ -1977,21 +1992,38 @@ paths:
1977
1992
  regenerate-from-here). Owner-scoped (non-owner → 404; the fork is owned by the caller). 400 `request.id_invalid` on an id that is not
1978
1993
  a canonical uuid — ANY uuid version passes since server >= 7.125.0 (the ONE shape gate shared with sync / policy / delete; <= 7.124.x accepted only
1979
1994
  uuidv7 here, so a shell-preset v4 id was creatable and syncable but not forkable). 501 without a durable session store.
1995
+ server >= 7.139.0 (contract section 23.4): the OPTIONAL body `{ forkId, forkNonce }` makes the fork keyed and RETRYABLE (together or not at all) — first `200 { sessionId }` (= `forkId`), a same-key retry
1996
+ `200 { sessionId, replayed: true }`; `forkId` already another session of yours ⇒ `409 conflict.fork_id_taken` (final: pick new keys); someone else's session ⇒ `404 not_found.session`; two collisions with another writer
1997
+ on the same target ⇒ `503 state.fork_target_unsettled` (`permanence: "transient"`, retry the same keys). Reconcile with `GET /v1/sessions/{forkId}/execution-placement` (`absent` / `writer` ⇒ forked; `forking` ⇒ a
1998
+ `DB_BACKEND=local` copy did not finish, retry the same keys; 404 ⇒ not forked). A fork's new session is `absent` and first executes on the CURRENT lane. The route now PARSES the body (it ignored it up to 7.138.x).
1999
+ requestBody:
2000
+ required: false
2001
+ content:
2002
+ application/json:
2003
+ schema: { $ref: '#/components/schemas/SessionForkBody' }
1980
2004
  responses:
1981
2005
  '200':
1982
- description: The new branched session id.
2006
+ description: 'The new branched session id (`replayed: true` on a same-key retry of a keyed fork, server >= 7.139.0).'
1983
2007
  content:
1984
2008
  application/json:
1985
- schema:
1986
- type: object
1987
- # 封闭:铸造点 `routes/sessions.ts` 是单键字面量 `{ sessionId: newId }`。
1988
- additionalProperties: false
1989
- required: [sessionId]
1990
- properties:
1991
- sessionId: { type: string }
2009
+ schema: { $ref: '#/components/schemas/SessionForkResult' }
1992
2010
  '400': { $ref: '#/components/responses/BadRequest' }
1993
2011
  '401': { $ref: '#/components/responses/Unauthorized' }
1994
2012
  '404': { $ref: '#/components/responses/NotFound' }
2013
+ '409':
2014
+ description: >-
2015
+ `conflict.fork_id_taken` (server >= 7.139.0, keyed fork): `forkId` already names ANOTHER session of yours (a different fork, or a session this fork request did not create); nothing was forked; top-level `forkId`.
2016
+ FINAL — pick a new `forkId` and `forkNonce`. (Someone else's session answers `404 not_found.session`, byte-identical to an unknown source.)
2017
+ content:
2018
+ application/json:
2019
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
2020
+ '503':
2021
+ description: >-
2022
+ `state.fork_target_unsettled` (server >= 7.139.0, keyed fork): two attempts both collided with another writer on the same target id and neither could read the target back — the server does not guess; body
2023
+ `permanence: "transient"`. Retry the SAME `forkId` / `forkNonce` verbatim. (`ServiceStateError`; the SDK does not retry a fork for you.)
2024
+ content:
2025
+ application/json:
2026
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
1995
2027
  '500':
1996
2028
  description: >-
1997
2029
  server >= 7.137.0: `invalid_session` — this route has no error mapping of its own; a session error it raises reaches the server's top-level catch, which maps it through the shared table: an `invalid_session` error
@@ -2002,6 +2034,84 @@ paths:
2002
2034
  schema: { $ref: '#/components/schemas/ErrorResponse' }
2003
2035
  '501': { $ref: '#/components/responses/NotImplemented' }
2004
2036
 
2037
+ /v1/sessions/{sessionId}/execution-placement:
2038
+ parameters:
2039
+ - $ref: '#/components/parameters/PrincipalHeader'
2040
+ - in: path
2041
+ name: sessionId
2042
+ required: true
2043
+ schema: { type: string }
2044
+ get:
2045
+ tags: [sessions]
2046
+ operationId: sessionsExecutionPlacement
2047
+ x-status: live # server >= 7.139.0 (contract section 23.1); no capability bit (an older server answers route-level 404 `not_found.route`).
2048
+ summary: Read one root session's execution placement on this deployment (absent / writer / mirror / forking).
2049
+ description: >
2050
+ server >= 7.139.0 (contract section 23.1) — the execution placement of one ROOT session's current occupant on THIS deployment (see `ExecutionPlacement`). Its documented uses: the SOURCE of the rebind verb's `expectedRev`
2051
+ (`device.rev` on the `writer` arm — it replaces the retired `GET /v1/devices/sessions/{rootSessionId}`), "is this deployment the writer?" before a session-sync push (`writer` ⇒ do not push, pull or fork instead), and reconciling a keyed fork.
2052
+ Visibility = the session's owner OR an explicit operator (an operator reads any session); a stranger and an unknown session answer the SAME `404 not_found.session` (anti-enumeration); a delegated child's partition row is not a root
2053
+ session (404). A malformed percent-encoded id segment ⇒ `400 request.path_malformed`. A session store without the execution seat (the engine's in-memory default) ⇒ `501 capability.session_store_required` — such a deployment does
2054
+ not record placement, and answering `absent` would say "not placed yet" for "not recorded". Inside the no-credential write gate (this GET too): no service credential and `ALLOW_UNAUTHED_WRITES` off ⇒ `503 auth.service_token_required`.
2055
+ A read, not a lock: the placement can change right after (a concurrent first execution / import).
2056
+ responses:
2057
+ '200':
2058
+ description: The placement.
2059
+ content:
2060
+ application/json:
2061
+ schema: { $ref: '#/components/schemas/ExecutionPlacement' }
2062
+ '400': { $ref: '#/components/responses/BadRequest' }
2063
+ '401': { $ref: '#/components/responses/Unauthorized' }
2064
+ '404': { $ref: '#/components/responses/NotFound' }
2065
+ '501': { $ref: '#/components/responses/NotImplemented' }
2066
+ '503':
2067
+ description: '`auth.service_token_required` — the no-credential write gate (no service credential configured and `ALLOW_UNAUTHED_WRITES` off).'
2068
+ content:
2069
+ application/json:
2070
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
2071
+
2072
+ /v1/sessions/{sessionId}/children/retire:
2073
+ parameters:
2074
+ - $ref: '#/components/parameters/PrincipalHeader'
2075
+ - in: path
2076
+ name: sessionId
2077
+ required: true
2078
+ schema: { type: string }
2079
+ post:
2080
+ tags: [sessions]
2081
+ operationId: sessionsChildrenRetire
2082
+ x-status: live # server >= 7.139.0 (contract section 23.5); no capability bit (an older server answers route-level 404 `not_found.route`).
2083
+ summary: Retire every background child rooted at this session (no body).
2084
+ description: >
2085
+ server >= 7.139.0 (contract section 23.5) — the SAME coordinator as the retirement `DELETE /v1/sessions/{sessionId}` runs first: running children are stopped, parked ones have their card voided and are driven to a terminal
2086
+ state, then the roster is re-enumerated until none is live. Use it BEFORE a rebind or a session-sync push: `409 device.rebind_active_run` / `409 session_active` bodies of the shape `{ children, retirePath }` name this
2087
+ path as `retirePath`. `POST /v1/sessions/{sessionId}/background/stop` keeps its meaning (stops running background agents / workflows and reaps shells; parked children and their pending cards stay) — "stop everything" = the stop verb
2088
+ plus this one. Auth, rate limit and the no-credential write gate are the stop verb's (session owner OR explicit operator; a stranger and an unknown session answer the same `404 not_found.session`; no session-ownership face ⇒
2089
+ `501 capability.session_ownership_required`). It does NOT judge the root run: a live root run may spawn children again after the retirement — that shape is caught by the claim read inside the rebind / push write transaction.
2090
+ Children dispatched after the observation, and children registered under another principal than the session owner, are invisible to the observation and absent from the receipt.
2091
+ responses:
2092
+ '200':
2093
+ description: The children that were observed and are now retired (an empty array when there were none).
2094
+ content:
2095
+ application/json:
2096
+ schema: { $ref: '#/components/schemas/SessionChildrenRetireResult' }
2097
+ '401': { $ref: '#/components/responses/Unauthorized' }
2098
+ '404': { $ref: '#/components/responses/NotFound' }
2099
+ '409':
2100
+ description: >-
2101
+ `conflict.session_children_alive`: some children cannot be ended from THIS replica (running on another replica, or parked on approval with no durable approval store here); NOTHING was moved; top-level `remaining` = their
2102
+ ids (the same strings as `GET /v1/agents/roster`) — same code, same projection as the delete gate. Wait for them or stop them where they run, then retry verbatim. A retirement that cannot finish stopping answers the
2103
+ delete gate's failure shape (500; an idempotent retry converges).
2104
+ content:
2105
+ application/json:
2106
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
2107
+ '429': { $ref: '#/components/responses/RateLimited' }
2108
+ '501': { $ref: '#/components/responses/NotImplemented' }
2109
+ '503':
2110
+ description: '`auth.service_token_required` — the no-credential write gate (no service credential configured and `ALLOW_UNAUTHED_WRITES` off).'
2111
+ content:
2112
+ application/json:
2113
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
2114
+
2005
2115
  /v1/sessions/{sessionId}/head:
2006
2116
  parameters:
2007
2117
  - $ref: '#/components/parameters/PrincipalHeader'
@@ -6763,23 +6873,20 @@ paths:
6763
6873
  get:
6764
6874
  tags: [devices]
6765
6875
  operationId: devicesSessionBinding
6766
- x-status: gated # server routes/devices.ts;同族 501 谓词。SDK devices.sessionBinding() 消费。
6767
- summary: Read one root session's device binding (all the material a shell's rebind UX needs).
6768
- description: >
6769
- `boundDevice.rev` is exactly the prior state the rebind verb's `expectedRev` must echo — READ THIS FIRST,
6770
- then rebind. Unbound / not yours ⇒ 404 `not_found.device`, SAME code SAME string (anti-enumeration: "no
6771
- visible binding" is one answer; it does not tell you whether the session exists).
6876
+ x-status: retired # server 7.139.0 (MIGRATION 7.139.0 item 15) deleted the route (global 404 `not_found.route`); sdk 30.0.0 deleted the verb `devices.sessionBinding()` (zero alias).
6877
+ summary: RETIRED (server 7.139.0) — read one root session's device binding; read GET /v1/sessions/{sessionId}/execution-placement instead.
6878
+ description: >
6879
+ RETIRED since server 7.139.0: this route no longer exists — the old path answers the global `404 not_found.route`. A device binding is now the device inside the `writer` placement of the root session row; read
6880
+ `GET /v1/sessions/{sessionId}/execution-placement`. Key mapping: the old body's `boundDevice.deviceId` / `boundDevice.rev` ⇒ the new `device.deviceId` / `device.rev` (`rev` is still what the rebind verb's `expectedRev` must echo);
6881
+ `boundAt` is gone; the old body's `rootSessionId` is the path id. "No binding" used to be `404 not_found.device` and is now a 200 (the role is not `writer`, or there is no `device` key); a stranger's and an unknown session answer the same
6882
+ `404 not_found.session` (it used to be `not_found.device`). The visibility gate changed too: the old read judged by device domain (a tenant claim and the same owner as the binding, else 403 / 404; operators exempt), the new one by session
6883
+ (the session-face owner predicate OR an explicit operator). Servers 7.88.0–7.138.x still serve this route; this spec keeps the entry as a tombstone (the SDK support floor is below 7.139.0) and the SDK carries no verb for it any more: against server >= 7.139.0 read `GET /v1/sessions/{sessionId}/execution-placement`; a deployment that still reads the binding on a server below 7.139.0 stays on sdk 29.x.
6772
6884
  responses:
6773
- '200':
6774
- description: The binding.
6885
+ '404':
6886
+ description: 'Server >= 7.139.0: the global `not_found.route` — the route is gone.'
6775
6887
  content:
6776
6888
  application/json:
6777
- schema: { $ref: '#/components/schemas/DeviceSessionBinding' }
6778
- '400': { $ref: '#/components/responses/BadRequest' } # request.path_malformed / request.id_invalid
6779
- '401': { $ref: '#/components/responses/Unauthorized' }
6780
- '403': { $ref: '#/components/responses/Forbidden' } # auth.forbidden
6781
- '404': { $ref: '#/components/responses/NotFound' } # not_found.device — unbound OR not yours, byte-identical
6782
- '501': { $ref: '#/components/responses/NotImplemented' } # capability.device_lane_required
6889
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
6783
6890
 
6784
6891
  /v1/devices/sessions/{rootSessionId}/rebind:
6785
6892
  parameters:
@@ -6791,15 +6898,16 @@ paths:
6791
6898
  x-status: gated # server routes/devices.ts;同族 501 谓词 + 无活跃 run 门需 run store(501 capability.run_store_required)。SDK devices.rebind() 消费。
6792
6899
  summary: Explicitly rebind a root session to another device (v1 has no implicit rebind).
6793
6900
  description: >
6794
- `expectedRev` IS REQUIRED and must be the rev read from `GET /v1/devices/sessions/{rootSessionId}`: an
6795
- explicit prior state, so two concurrent operators cannot silently stomp each other. Door order (frozen,
6901
+ `expectedRev` IS REQUIRED and must be the rev read from `GET /v1/sessions/{rootSessionId}/execution-placement` (`device.rev` on the `writer` arm; server >= 7.139.0 — before it, `boundDevice.rev` of the retired
6902
+ `GET /v1/devices/sessions/{rootSessionId}`): an explicit prior state, so two concurrent operators cannot silently stomp each other. Door order (frozen,
6796
6903
  five steps server-side):
6797
6904
  (1) owner door — a non-owner gets 404, SAME bytes;
6798
6905
  (2) target-device door — `toDeviceId` must exist, belong to THE BINDING'S domain (an operator may not
6799
6906
  rebind across tenants) and not be revoked; otherwise 404, SAME bytes;
6800
6907
  (3) NO-ACTIVE-RUN door, judged BEFORE the CAS, with the durable criterion = the run store's session claim
6801
6908
  (parked runs included) ⇒ 409 `device.rebind_active_run` carrying `activeTaskId`; no run store wired ⇒ 501
6802
- `capability.run_store_required` (a door with no criterion refuses);
6909
+ `capability.run_store_required` (a door with no criterion refuses). server >= 7.139.0: live BACKGROUND CHILDREN rooted at the session (running, or parked on approval) are refused at this door too, with the body
6910
+ `{ children, retirePath }` instead of `{ activeTaskId }` (branch on the key) — `POST <retirePath>` (`/v1/sessions/{id}/children/retire`) retires them, then retry;
6803
6911
  (4) prior-state CAS in one store transaction plus a `session_rebound` audit row ⇒ rev mismatch is 409
6804
6912
  `device.rebind_rev_conflict` carrying `currentRev`. 🔴 The SAME `toDeviceId` with a WRONG rev is still a
6805
6913
  409 — a wrong prior state is wrong;
@@ -7436,8 +7544,7 @@ components:
7436
7544
  type: string
7437
7545
  description: >
7438
7546
  CC Rewind parity (E18). Fork the conversation FROM this user-message SessionTreeEntry.id (non-destructive
7439
- branch via setLeafId). With `restoreFiles: true` ⇒ "both" (also restore the working tree — the retired spelling
7440
- `rewindFiles` still rides the wire but its restore sense is core's typed migration rejection naming `restoreFiles`). Alone ⇒
7547
+ branch via setLeafId). With `restoreFiles: true` ⇒ "both" (also restore the working tree). Alone ⇒
7441
7548
  "conversation". HONORED only where the deployment wired a resume-anchor store + the session head read `headOf` (<= 7.134.x: `getLeafId`) (capabilities.resumeAt);
7442
7549
  unknown anchor ⇒ 4xx, capability-off ⇒ 501. Cannot combine with a durable resume.
7443
7550
  resumeAtMode:
@@ -7453,15 +7560,6 @@ components:
7453
7560
  session), `rewind_snapshot.unresolvable` (with a file restore, `restoreFiles`: the target has no file-history boundary of its
7454
7561
  own — a "before" restore only trusts the target's OWN boundary and never crosses into an earlier turn).
7455
7562
  Only meaningful WITH `resumeAt` — sent alone it is a 400 (fail-loud, not a silent no-op).
7456
- rewindFiles:
7457
- type: boolean
7458
- description: >
7459
- RETIRED SPELLING (the whole-tree snapshot epoch; S-15 / design/381, server >= 7.52 — note corrected in sdk
7460
- 11.4.0, the same stale-note family as `rewindFilesTo`, board [8437] U3). Server `src/http/wire-types.ts`: still
7461
- accepted on the wire — its capture sense (true, no resumeAt) is a tolerated no-op with a deprecation disclosure;
7462
- its restore sense (true + resumeAt) is core's TYPED migration rejection naming `restoreFiles` (restore semantics
7463
- really changed: whole tree ⇒ tracked set; the server never remaps it silently). Send `restoreFiles` (probe
7464
- `capabilities.restoreFiles`); this key stays declared only for <= 7.51 servers.
7465
7563
  rewindFilesTo:
7466
7564
  type: string
7467
7565
  description: >
@@ -7487,9 +7585,10 @@ components:
7487
7585
  codex review R1-[medium]: `capabilities.restoreFiles` told clients to send this key while neither
7488
7586
  this schema nor the SDK type could express it). With `resumeAt`: restore the TRACKED SET (files
7489
7587
  this session edited) to that boundary on fork — S-15 narrowed restore whole-tree ⇒ tracked-set and
7490
- moved the request key off `rewindFiles` (the old `rewindFiles`+`resumeAt` spelling gets core's
7491
- typed migration rejection on ≥7.52). Probe `capabilities.restoreFiles` first: bit absent = older
7492
- server, send the old spelling; never send both spellings.
7588
+ moved the request key off the old spelling `rewindFiles`. 🔴 The old spelling `rewindFiles` is RETIRED outright
7589
+ (server 7.139.0, MIGRATION item 2; sdk 30.0.0 deleted the key, zero alias): a new submit that carries it is
7590
+ `400 request.body_shape` with `unknownKeys: ["rewindFiles"]` and creates no run (the durable-resume replay of an OLD stored body
7591
+ ignores it). Probe `capabilities.restoreFiles` first; send `restoreFiles` (+ `resumeAt`) or `rewindFilesTo`.
7493
7592
  acceptPartialRestore:
7494
7593
  type: boolean
7495
7594
  description: >-
@@ -7509,7 +7608,7 @@ components:
7509
7608
  word. ONE word, `disabled`: this run takes no first-touch backup of an edited file and mints no turn boundaries
7510
7609
  (delegates inherit it); absent = the deployment's setting (there is no `enabled` spelling). Any other value ⇒ 400
7511
7610
  `request.field_invalid` ("fileHistory must be the string 'disabled' when present …"), fresh and resume legs alike.
7512
- 🔴 Riding together with ANY restore key (`restoreFiles` / `rewindFilesTo` / the retired `rewindFiles`) ⇒ 400
7611
+ 🔴 Riding together with ANY restore key (`restoreFiles` / `rewindFilesTo`) ⇒ 400
7513
7612
  `request.field_conflict` AT ADMISSION ("fileHistory: 'disabled' cannot ride with a file restore …"), session and
7514
7613
  files untouched — drop it to restore. The leg's own verdict is `wiring_manifest.fileHistory`; whether to render a
7515
7614
  "don't capture this session" switch is `capabilities.fileHistoryCapture === "on-optional"` (the switch = send this
@@ -10000,7 +10099,7 @@ components:
10000
10099
  diagnostics, never as vocabulary). Empty array = honest "nothing usable here" (e.g. multi-tenant
10001
10100
  with no explicit allowlist); ABSENT = an older server (degrade to not teaching, not validating).
10002
10101
  resumeAt: { type: boolean, description: "E18 resume-at-message anchors are resolvable." }
10003
- rewindFiles: { type: boolean, description: "E19 working-tree snapshot/restore is wired." }
10102
+ rewindFiles: { type: boolean, description: "E19 file-history store present (the file-restore legs `restoreFiles` / `rewindFilesTo` can take effect). The bit's NAME is a historical spelling: the same-named REQUEST key `rewindFiles` is retired (server 7.139.0 ⇒ 400 `request.body_shape`), the bit itself is still minted." }
10004
10103
  rewindFilesTo:
10005
10104
  type: boolean
10006
10105
  description: >-
@@ -10018,10 +10117,9 @@ components:
10018
10117
  description: >-
10019
10118
  S-15 epoch discriminator (server ≥7.52, `Boolean(fileHistoryStore)`): this server understands the
10020
10119
  `restoreFiles` REQUEST KEY / tracked-set restore semantics (design/381 — restore narrowed
10021
- whole-tree ⇒ tracked set; the retired `rewindFiles`+`resumeAt` spelling gets core's typed
10022
- migration rejection there). New clients negotiate on THIS bit and send `restoreFiles` (+
10023
- `resumeAt`); absent ⇒ an older server, send the old spelling. `rewindFiles` keeps its name (same
10024
- affordance — "rewind can move files"); this bit is what tells the two epochs apart.
10120
+ whole-tree ⇒ tracked set). New clients negotiate on THIS bit and send `restoreFiles` (+
10121
+ `resumeAt`); absent ⇒ a server below the SDK's support floor. The capability bit `rewindFiles` keeps its
10122
+ name (same affordance — "rewind can move files"); the old REQUEST key of that name is retired (server 7.139.0).
10025
10123
  manualCompact: { type: boolean, description: "`POST /v1/runs/:id/compact` (needs a run store)." }
10026
10124
  configCatalog:
10027
10125
  type: boolean
@@ -14375,11 +14473,23 @@ components:
14375
14473
  >= 7.125.0 (a session's state, not a capability — NOT present-iff); a lister face with no session metadata (the in-memory run-store
14376
14474
  aggregate) always answers `false`. ABSENT = an older server (<= 7.124.x) — read as "not pinned". Not in `required` for that reason only.
14377
14475
  The list order is unchanged (recency by `lastActivityAt`); the client groups the pinned section. Renaming / pinning does not move `lastActivityAt`.
14476
+ rowTag:
14477
+ type: string
14478
+ pattern: '^[A-Za-z0-9_-]{43}$'
14479
+ description: >
14480
+ server >= 7.139.0 (contract section 20, "conditional write"): the ROW TAG — an opaque string (43 characters of `[A-Za-z0-9_-]`) to be echoed back verbatim as
14481
+ `PATCH /v1/sessions/{sessionId}` `expectedRowTag`: "write only if the row is still the one I read". It changes when one of the row's WRITABLE bits (today `title` / `pinned`)
14482
+ or the session ITSELF changes (deleted and re-created under the same id; a changed owner); a new run, the activity time and the preview do NOT change it; a value that was changed and
14483
+ changed back is unchanged (no value-judging round trip). The `PATCH` 200 row and the `currentRow` of a `409 conflict.session_row_changed` are the SAME projection and carry it too.
14484
+ PRESENT-IFF the row can be written conditionally (all three durable session backends); a lister face with no session metadata (the in-memory run-store aggregate) does not carry it.
14485
+ ABSENT = an older server (<= 7.138.x) or such a face — read as "no tag, unconditional write only". Never parse it, compare its order or use it across sessions. Not an ETag, no capability bit.
14378
14486
 
14379
14487
  SessionPatchBody:
14380
14488
  type: object
14381
14489
  description: >
14382
- `PATCH /v1/sessions/{sessionId}` body (server >= 7.125.0, contract section 20) — a CLOSED set of two keys, at least one: any other key, an empty body or a
14490
+ `PATCH /v1/sessions/{sessionId}` body (server >= 7.125.0, contract section 20) — a CLOSED set: the two writable bits `title` / `pinned` (at least one) plus, from server >= 7.139.0, the optional PRECONDITION
14491
+ `expectedRowTag` (the `rowTag` of the list row you read: "write only if the row is still that one"; stale ⇒ `409 conflict.session_row_changed`, nothing written; a key that is not a 43-character `[A-Za-z0-9_-]`
14492
+ string ⇒ `400 request.field_invalid`; `expectedRowTag` ALONE — no writable bit — ⇒ `400 request.body_shape`; a server <= 7.138.x answers `400 request.body_shape` for the unknown key: fail-closed, do NOT drop the key and resend). Any other key, an empty body or a
14383
14493
  non-object is `400 request.body_shape`. `title`: a string renames (1..120 CHARACTERS counted as Unicode characters = the storage column width, no leading /
14384
14494
  trailing whitespace, stored verbatim — not rewritten, not redacted); `null` CLEARS it back to the automatic title (the next submit lets the auto-titler fill
14385
14495
  it again). `""` is NOT a clear — it is `400 request.body_shape`. A string of the wrong form / a non-string-non-null `title` / a non-boolean `pinned` is
@@ -14387,7 +14497,9 @@ components:
14387
14497
  usable-name normalization) is `400 request.field_invalid` too (`title must contain at least one visible character`; the session-sync 2c import's `title` reads the same rule). Such titles written before
14388
14498
  7.136.0 are not migrated.
14389
14499
  additionalProperties: false
14390
- minProperties: 1
14500
+ anyOf:
14501
+ - required: [title]
14502
+ - required: [pinned]
14391
14503
  properties:
14392
14504
  title:
14393
14505
  type: [string, 'null']
@@ -14396,6 +14508,84 @@ components:
14396
14508
  pattern: '^\S([\s\S]*\S)?$'
14397
14509
  description: 'A string = rename (1..120 characters, no leading / trailing whitespace); `null` = clear back to the automatic title; `""` is a 400 (the only spelling of "clear" is `null`).'
14398
14510
  pinned: { type: boolean, description: 'The pin (default `false` on a row that never set it).' }
14511
+ expectedRowTag:
14512
+ type: string
14513
+ pattern: '^[A-Za-z0-9_-]{43}$'
14514
+ description: 'server >= 7.139.0 — the PRECONDITION (not a writable bit): the `rowTag` of the list row you read. Still that row ⇒ the write happens (the 200 row carries the tag after the write — it changes only if a value actually changed; a write of the value already held returns the same tag); not any more ⇒ `409 conflict.session_row_changed` with `currentRow`, nothing written. Never resend verbatim after a 409.'
14515
+ SessionForkBody:
14516
+ type: object
14517
+ description: >
14518
+ `POST /v1/sessions/{sessionId}/fork` OPTIONAL body (server >= 7.139.0, contract section 23.4) — the keyed, retryable fork: `forkId` (the caller-minted canonical uuid that BECOMES the new session's id; not the source) and
14519
+ `forkNonce` (a non-empty string of at most 255 UTF-16 code units, i.e. JavaScript `String.length` — the server compares exactly that; a retry sends the SAME one). TOGETHER OR NEITHER: only one ⇒
14520
+ `400 request.field_conflict` (`detail.kind: "fork_target"`, `fields: ["forkId", "forkNonce"]`); neither (an empty object, or no body at all) = the previous form (the server mints the id). The server reads only these two keys
14521
+ and IGNORES any other key (the object is not key-closed). Note the route now PARSES the body (it ignored it up to 7.138.x): malformed JSON ⇒ `400 request.invalid_json`, over the 8 MiB cap ⇒ `413`, a JSON array or scalar ⇒ `400 request.field_invalid`.
14522
+ additionalProperties: true
14523
+ oneOf:
14524
+ - required: [forkId, forkNonce]
14525
+ - allOf:
14526
+ - not: { required: [forkId] }
14527
+ - not: { required: [forkNonce] }
14528
+ properties:
14529
+ forkId: { type: string, description: 'A canonical uuid (any version) naming the NEW session; not the source id (`400 request.field_invalid`), not a canonical uuid (`400 request.id_invalid`).' }
14530
+ forkNonce: { type: string, minLength: 1, maxLength: 255, description: 'The caller''s key for this fork request: non-empty, at most 255 UTF-16 code units (JavaScript `String.length`; JSON Schema `maxLength` counts code points, so it is only a necessary bound for text outside the BMP — the server refuses 256+ code units). A retry sends the same one. Not such a string ⇒ `400 request.field_invalid`.' }
14531
+ SessionForkResult:
14532
+ type: object
14533
+ description: >
14534
+ `POST /v1/sessions/{sessionId}/fork` 200 body: `sessionId` = the NEW branched session (= `forkId` on a keyed fork); `replayed: true` (server >= 7.139.0, keyed form only) = a retry by the same owner, same source and same
14535
+ nonce hit the earlier result. The key is ABSENT on a first fork and on every older server.
14536
+ additionalProperties: false
14537
+ required: [sessionId]
14538
+ properties:
14539
+ sessionId: { type: string }
14540
+ replayed: { type: boolean, enum: [true], description: 'Present only (and always `true`) on a same-key retry.' }
14541
+ SessionChildrenRetireResult:
14542
+ type: object
14543
+ description: >
14544
+ `POST /v1/sessions/{sessionId}/children/retire` 200 body (server >= 7.139.0, contract section 23.5): `children` = the background children the first observation found AND that are now all retired
14545
+ (an empty array when there were none); each item is the same string as the `GET /v1/agents/roster` row id.
14546
+ additionalProperties: false
14547
+ required: [children]
14548
+ properties:
14549
+ children: { type: array, items: { type: string } }
14550
+ ExecutionPlacementDevice:
14551
+ type: object
14552
+ description: >
14553
+ The device a `writer` placement on the device lane is bound to (`ExecutionPlacement`, server >= 7.139.0): `deviceId` + `rev` — `rev` is exactly what
14554
+ `POST /v1/devices/sessions/{rootSessionId}/rebind` `expectedRev` must echo. The device owner and the binding time do not ride the wire.
14555
+ additionalProperties: false
14556
+ required: [deviceId, rev]
14557
+ properties:
14558
+ deviceId: { type: string, minLength: 1 }
14559
+ rev: { type: integer, minimum: 0 }
14560
+ ExecutionPlacement:
14561
+ description: >
14562
+ `GET /v1/sessions/{sessionId}/execution-placement` 200 body (server >= 7.139.0, contract section 23.1) — the execution placement of one ROOT session's current occupant on THIS deployment, discriminated by `role`:
14563
+ `absent` (not yet executed here) · `writer` (this deployment is the writer; `lane` = the execution lane word, the `REMOTE_EXEC` value, `in-process` when unset; `device` only on the device lane once bound — `writer`
14564
+ without `device` there = a pre-upgrade session whose device is unknown) · `mirror` (a read-only copy imported from elsewhere; execution / rename / pin answer `409 conflict.session_mirror` with `forkPath`) ·
14565
+ `forking` (a keyed fork has not finished copying — `DB_BACKEND=local` crash middle state only). No `writer` ⇄ `mirror` and no `writer(L)` → `writer(L')` transition: to change, fork a new session. Closed set; the SDK reads it exhaustively.
14566
+ oneOf:
14567
+ - type: object
14568
+ additionalProperties: false
14569
+ required: [role]
14570
+ properties:
14571
+ role: { const: absent }
14572
+ - type: object
14573
+ additionalProperties: false
14574
+ required: [role, lane]
14575
+ properties:
14576
+ role: { const: writer }
14577
+ lane: { type: string, minLength: 1 }
14578
+ device: { $ref: '#/components/schemas/ExecutionPlacementDevice' }
14579
+ - type: object
14580
+ additionalProperties: false
14581
+ required: [role]
14582
+ properties:
14583
+ role: { const: mirror }
14584
+ - type: object
14585
+ additionalProperties: false
14586
+ required: [role]
14587
+ properties:
14588
+ role: { const: forking }
14399
14589
 
14400
14590
  SessionWindow:
14401
14591
  type: object
@@ -14852,6 +15042,11 @@ components:
14852
15042
  core's retain predicate (env declaration / task lane / row mark — any ⇒ kept) — present ONLY when true,
14853
15043
  never minted as false, and only ever on a shell row (`background_bash` / `monitor`; core `list()` row
14854
15044
  doc). Present = "keeps running" on the exit sheet; absent = an `includeRetained:false` stop WILL stop it.
15045
+ sessionId:
15046
+ type: string
15047
+ description: >-
15048
+ server >= 7.139.0 (MIGRATION 7.139.0 item 7): present-iff the background agent row is bound to a CHILD session — jump to that session with it (it still passes the session face's owner gate). ABSENT = none yet,
15049
+ or an older server. Only ever on a `background_agent` row.
14855
15050
  SessionBackgroundList:
14856
15051
  type: object
14857
15052
  description: '`GET /v1/sessions/{sessionId}/background` 200 body (contract §16). An idle session answers `{ rows: [] }`.'
@@ -15194,7 +15389,10 @@ components:
15194
15389
  budget): this code says nothing about the caller's quota. (`gone.` = 410, "the channel closed, switch
15195
15390
  channels"; `parking.` = 425, "intermediate state — you retry to learn the landing, not to re-submit".
15196
15391
  Both families, and both status codes, first reached the wire with server 7.3.0's in-stream approval
15197
- decision endpoint.) The SDK maps each family to a typed class, so a code this SDK has
15392
+ decision endpoint.) 🔴 server >= 7.139.0 also mints two 409 codes under a prefix that is NOT one of the fourteen:
15393
+ `execution_lane.not_served` / `execution_lane.tree_bound` (the session is placed on an execution lane this deployment no
15394
+ longer runs / another lane of this deployment; top-level `boundLane`) — they fall through to the STATUS tail (409 ⇒
15395
+ `ConflictError`), so branch on the code, never on a prefix family. The SDK maps each family to a typed class, so a code this SDK has
15198
15396
  never seen still degrades INFORMATIVELY (e.g. a future `capability.xyz_required` already lands on
15199
15397
  CapabilityUnavailableError). Family examples not named elsewhere in this document:
15200
15398
  `request.payload_too_large` (413 — a field or the whole body is over the server cap; shorten and
@@ -16619,8 +16817,8 @@ components:
16619
16817
  stays `readonly_out_of_root`).
16620
16818
  🔴 core >= 7.6.0 — the MCP family within this open set is now the CLOSED `McpFailureKind` word list
16621
16819
  (`connect_refused` / `connection_failed` / `connection_closed` / `unauthorized` / `http_status` / `not_mcp_response` /
16622
- `spawn_failed` / `timeout` / `protocol` / `invalid_config` / `credential_unavailable` / `unknown` — `credential_unavailable` from core 7.58.0 and
16623
- `unauthorized` from core 7.59.0, server >= 7.138.0); the retired
16820
+ `spawn_failed` / `timeout` / `protocol` / `invalid_config` / `credential_unavailable` / `host_refused` / `unknown` — `credential_unavailable` from core 7.58.0 and
16821
+ `unauthorized` from core 7.59.0, server >= 7.138.0; `host_refused` from core 7.60.0, server >= 7.139.0); the retired
16624
16822
  `MCP_FAILURE_CODES` spellings — including `network` and the `http_<status>` encoding — are gone,
16625
16823
  and an HTTP status now rides the structured `httpStatus` seat on `wiring_manifest.mcp[]` instead of
16626
16824
  being baked into the code. The set as a WHOLE stays open (a tool owns its own codes).
@@ -16769,6 +16967,7 @@ components:
16769
16967
  maxRetries: { type: number, description: "retry budget of the lane in force (refused-connect short lane = 2)" }
16770
16968
  retryInMs: { type: number, description: "same number as retryInSec at ms precision (countdown rendering)" }
16771
16969
  errClass: { type: string, description: "connect_refused | transport | stall | rate_limit | server | http | output_cap (core's seven words since core 7.14.0 — `stall` = this process's own stall watchdog cancelled the request) — retry-wait frames ONLY; never inferred from phase" }
16970
+ seat: { type: string, description: "server >= 7.139.0 (core 7.60.0 `BrainStatus.seat`, minted only when a non-empty string, passed through verbatim): WHOSE model call this frame is about, on EVERY phase — `classifier` = a call made for the auto-mode classifier lane (the classifier seat's model, or the main model standing in behind it): a side call beside the person's turn. ABSENT = the run's own turn (read as the main loop, never as unknown) and every older server. Open on read (a newer engine may name another seat)." }
16772
16971
  providerCondition: { type: string, description: "server >= 7.126.0 (core 7.49.0 #1454, passed through verbatim): what the provider said about the account / capacity — core's closed `PROVIDER_CONDITIONS`; a retry frame carries only the three retryable words `throttled | overloaded | unknown` (`quota_exhausted` / `stop_other` do not retry and ride the terminal `detail.providerCondition`). Presence law as `errorStatus`; read as an OPEN set (keep a default arm). ABSENT = not judged, read the same as `unknown` (back off, do not assert quota). Moves with `providerConditionSource`." }
16773
16972
  providerConditionSource: { type: string, description: "server >= 7.126.0 (core 7.49.0 #1454): the evidence the `providerCondition` verdict rests on — `unified_header | provider_code | status`; present exactly when `providerCondition` is; read as an OPEN set." }
16774
16973
  retryAtMs: { type: number, description: "server >= 7.52.0 (core 7.0.0): the WALL-CLOCK end of the wait = `Date.now() + retryInMs` at emit, on the emitting process's clock (not monotonic — never compare it with a local monotonic timer). `retryInMs` stays the authoritative RELATIVE amount; this is the producer's absolute note (a reader several hops away recomputing it would reset the countdown on every replay). Moves with `retryInMs`; absent ⇒ not minted." }
@@ -21475,7 +21674,8 @@ components:
21475
21674
  description: >
21476
21675
  core >= 7.6.0 — the `McpFailureKind` word (`connect_refused` / `connection_failed` /
21477
21676
  `connection_closed` / `unauthorized` / `http_status` / `not_mcp_response` / `spawn_failed` / `timeout` /
21478
- `protocol` / `invalid_config` / `credential_unavailable` / `unknown`; server >= 7.138.0: `unauthorized` = the principal must authorize this server
21677
+ `protocol` / `invalid_config` / `credential_unavailable` / `host_refused` / `unknown`; server >= 7.139.0 (core 7.60.0): `host_refused` = the host seat of a host-supplied transport did not hand the request to the remote (nothing was
21678
+ sent; no deployment of this server mounts one today, the word is the engine's); server >= 7.138.0: `unauthorized` = the principal must authorize this server
21479
21679
  first — the endpoint answered 401 (after the deployment's peer seat was asked once more) or a 403 with an `insufficient_scope` challenge, or the peer
21480
21680
  seat answered that the principal is not authorized here; earlier servers sent the first two as `http_status`; `credential_unavailable` = the
21481
21681
  deployment's peer seat did not furnish the request (it threw, did not answer in time, or answered something the engine cannot carry), so the
@@ -22695,8 +22895,12 @@ components:
22695
22895
  in place"; now every candidate carries its own `behavior` and that seat is GONE — an entry that did not
22696
22896
  become a candidate is in `skipped` with its reason. A consumer rendering `uncovered.denyAskBuckets` reads
22697
22897
  `candidates[].behavior` instead.
22898
+
22899
+ 🔴 server >= 7.139.0 (core 7.60.0; MIGRATION 7.139.0 item 6) — THE KEY `translated` IS GONE (read-side BREAKING): core deleted the always-empty compatibility array and the server forwards the preview verbatim. This schema
22900
+ describes only that generation (CLOSED: a 7.139.0 body has no `translated`; a body from a server <= 7.138.x still carries `translated: []` and does not match this closed schema — the SDK's own readers ignore it). A reader that
22901
+ rendered a "rewritten spellings" column reads nothing for it (the array was always empty).
22698
22902
  additionalProperties: false
22699
- required: [candidates, skipped, translated, layers, uncovered]
22903
+ required: [candidates, skipped, layers, uncovered]
22700
22904
  properties:
22701
22905
  candidates:
22702
22906
  type: array
@@ -22706,25 +22910,6 @@ components:
22706
22910
  type: array
22707
22911
  items: { $ref: '#/components/schemas/CcImportSkippedRule' }
22708
22912
  description: 'Entries that did not become candidates. `reason` is PROSE, not a code — see the schema.'
22709
- translated:
22710
- type: array
22711
- description: >
22712
- ALWAYS EMPTY in this version — a compatibility seat core keeps on the wire shape (core
22713
- `ImportPreview.translated`, verbatim). It once carried entries whose MATCH FORM was rewritten on the
22714
- way in (the other product's space-star suggestion form translated to this lane's colon-star). That
22715
- translation is retired: space-star is now a first-class match form of this lane's own grammar, so an
22716
- entry's match form imports as the file states it and nothing is ever pushed here. A reader rendering a
22717
- "rewritten spellings" column from this seat renders an empty column, correctly.
22718
- ⚠️ Declared here from SDK 8.8.0 on: core has always emitted the key, so a closed schema without it
22719
- judged every real 200 body a violation (a staleness fix, not a behavior change).
22720
- items:
22721
- type: object
22722
- additionalProperties: false
22723
- required: [from, to, scope]
22724
- properties:
22725
- from: { type: string }
22726
- to: { type: string }
22727
- scope: { $ref: '#/components/schemas/RuleScope' }
22728
22913
  layers:
22729
22914
  type: array
22730
22915
  items: { $ref: '#/components/schemas/CcImportLayerReport' }
@@ -23395,25 +23580,6 @@ components:
23395
23580
  type: array
23396
23581
  items: { $ref: '#/components/schemas/DeviceSummary' }
23397
23582
 
23398
- DeviceBinding:
23399
- type: object
23400
- description: 'One session↔device binding (server `boundDeviceOf`; frozen key set).'
23401
- additionalProperties: false
23402
- required: [deviceId, rev, boundAt]
23403
- properties:
23404
- deviceId: { type: string, minLength: 1 }
23405
- rev: { type: integer, minimum: 0, description: 'The prior-state version — this is exactly what the rebind verb''s `expectedRev` must echo (an explicit prior state, so two concurrent operators cannot silently stomp each other).' }
23406
- boundAt: { type: string, format: date-time, description: 'ISO-8601.' }
23407
-
23408
- DeviceSessionBinding:
23409
- type: object
23410
- description: 'The `GET /v1/devices/sessions/{rootSessionId}` 200 body (all the material a shell''s rebind UX needs).'
23411
- additionalProperties: false
23412
- required: [rootSessionId, boundDevice]
23413
- properties:
23414
- rootSessionId: { type: string, minLength: 1 }
23415
- boundDevice: { $ref: '#/components/schemas/DeviceBinding' }
23416
-
23417
23583
  DeviceRebindRequest:
23418
23584
  type: object
23419
23585
  description: 'The `POST /v1/devices/sessions/{rootSessionId}/rebind` body. NOTE: server 7.88.2 does NOT key-close this one body (unknown keys are dropped silently, unlike enroll/revoke which answer 400 request.body_shape); a server-side ticket tracks closing it. This SDK never sends extra keys.'
@@ -23425,7 +23591,7 @@ components:
23425
23591
  type: integer
23426
23592
  minimum: 0
23427
23593
  description: >
23428
- REQUIRED — the rev read from `GET /v1/devices/sessions/{rootSessionId}`. 🔴 The same `toDeviceId` with a
23594
+ REQUIRED — the rev read from `GET /v1/sessions/{rootSessionId}/execution-placement` (`device.rev` on the `writer` arm; server >= 7.139.0). 🔴 The same `toDeviceId` with a
23429
23595
  WRONG rev is STILL a 409 `device.rebind_rev_conflict`: a wrong prior state is wrong. Not a non-negative
23430
23596
  integer ⇒ 400 request.field_invalid.
23431
23597
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/sdk",
3
- "version": "29.0.0",
3
+ "version": "30.0.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",
@@ -55,6 +55,6 @@
55
55
  "prepublishOnly": "rm -f tsconfig.tsbuildinfo && npm run build && npm run typecheck --workspaces=false --prefix ../.. && npm test --workspaces=false --prefix ../.. && npm run prepack"
56
56
  },
57
57
  "devDependencies": {
58
- "@sema-agent/settings-schema": "^14.7.0"
58
+ "@sema-agent/settings-schema": "^15.1.0"
59
59
  }
60
60
  }