@sema-agent/core 7.72.0 → 7.73.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.
Files changed (256) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/parked-resume-drive.d.ts +10 -0
  5. package/dist/agents/parked-resume-drive.js +9 -0
  6. package/dist/agents/retain-ledger.d.ts +3 -0
  7. package/dist/agents/send-message-tool.js +1 -0
  8. package/dist/agents/send-user-message-tool.d.ts +12 -0
  9. package/dist/agents/send-user-message-tool.js +67 -0
  10. package/dist/agents/subagent-steps.d.ts +9 -0
  11. package/dist/agents/subagent-steps.js +38 -0
  12. package/dist/agents/subagent.d.ts +2 -0
  13. package/dist/agents/subagent.js +43 -12
  14. package/dist/agents/verify.js +23 -8
  15. package/dist/agents/yield-adoption.js +3 -1
  16. package/dist/brain/anthropic.js +14 -9
  17. package/dist/brain/open-responses.js +4 -5
  18. package/dist/brain/openai.js +30 -23
  19. package/dist/brain/stream-engine.js +159 -151
  20. package/dist/core/actions-digest.d.ts +43 -0
  21. package/dist/core/actions-digest.js +22 -0
  22. package/dist/core/allow-entry.js +3 -3
  23. package/dist/core/auto-mode.d.ts +7 -9
  24. package/dist/core/auto-mode.js +114 -8
  25. package/dist/core/checkpoint-features.d.ts +3 -2
  26. package/dist/core/checkpoint-features.js +1 -1
  27. package/dist/core/checkpoint-rekey.d.ts +1 -1
  28. package/dist/core/checkpoint-rekey.js +6 -1
  29. package/dist/core/checkpoint-requirements.d.ts +23 -3
  30. package/dist/core/checkpoint-requirements.js +5 -1
  31. package/dist/core/checkpoint-row-verdict.js +7 -1
  32. package/dist/core/checkpoint-store.d.ts +24 -2
  33. package/dist/core/checkpoint-store.js +1 -0
  34. package/dist/core/child-clamp-seats.d.ts +15 -0
  35. package/dist/core/child-clamp-seats.js +15 -0
  36. package/dist/core/delegation-frames.d.ts +1 -0
  37. package/dist/core/delegation-frames.js +1 -1
  38. package/dist/core/engine-capabilities.d.ts +5 -1
  39. package/dist/core/engine-capabilities.js +1 -1
  40. package/dist/core/engine-notice.d.ts +30 -22
  41. package/dist/core/engine-version.js +1 -1
  42. package/dist/core/entries-not-applied.d.ts +19 -7
  43. package/dist/core/entries-not-applied.js +33 -1
  44. package/dist/core/governance-codes.d.ts +7 -1
  45. package/dist/core/governance-codes.js +13 -5
  46. package/dist/core/hooks.d.ts +3 -0
  47. package/dist/core/hooks.js +1 -0
  48. package/dist/core/host-instance.d.ts +23 -0
  49. package/dist/core/host-instance.js +69 -0
  50. package/dist/core/instruction-preview.d.ts +63 -0
  51. package/dist/core/instruction-preview.js +406 -0
  52. package/dist/core/leg-budget.d.ts +26 -0
  53. package/dist/core/leg-budget.js +9 -0
  54. package/dist/core/leg-identity.d.ts +51 -1
  55. package/dist/core/leg-identity.js +45 -2
  56. package/dist/core/manager-launch-check.d.ts +48 -0
  57. package/dist/core/manager-launch-check.js +64 -0
  58. package/dist/core/mcp-call-meta.d.ts +2 -2
  59. package/dist/core/mcp-injection-drop.d.ts +20 -10
  60. package/dist/core/mcp-injection-drop.js +9 -3
  61. package/dist/core/mcp-server-spec.d.ts +2 -1
  62. package/dist/core/member-outcome.d.ts +3 -2
  63. package/dist/core/member-outcome.js +1 -1
  64. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  65. package/dist/core/memory-engine/deletion-record.js +96 -0
  66. package/dist/core/memory-engine/engine.js +24 -16
  67. package/dist/core/memory-engine/file-backend.js +7 -5
  68. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  69. package/dist/core/memory-engine/projection-ledger.js +1 -1
  70. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  71. package/dist/core/memory-engine/scope-contract.js +18 -18
  72. package/dist/core/memory-engine/sync-client.js +26 -6
  73. package/dist/core/memory-engine/sync.d.ts +20 -2
  74. package/dist/core/memory-engine/sync.js +18 -17
  75. package/dist/core/mode-policy.d.ts +21 -6
  76. package/dist/core/mode-policy.js +15 -6
  77. package/dist/core/own-property-receipt.js +11 -4
  78. package/dist/core/parent-spec-seat.d.ts +13 -11
  79. package/dist/core/parent-spec-seat.js +13 -9
  80. package/dist/core/peer-seat.js +3 -3
  81. package/dist/core/peer-task-store.d.ts +365 -0
  82. package/dist/core/peer-task-store.js +682 -0
  83. package/dist/core/permission-rule-consent.js +6 -11
  84. package/dist/core/permission-rule-model.d.ts +27 -0
  85. package/dist/core/permission-rule-model.js +33 -5
  86. package/dist/core/permission-rule-provider.d.ts +35 -33
  87. package/dist/core/permission-rule-provider.js +38 -295
  88. package/dist/core/permission-rule-store.d.ts +181 -8
  89. package/dist/core/permission-rule-store.js +420 -17
  90. package/dist/core/permission-rule-sync.js +15 -1
  91. package/dist/core/project-seat.d.ts +55 -0
  92. package/dist/core/project-seat.js +96 -0
  93. package/dist/core/protocol-http-auth.d.ts +3 -2
  94. package/dist/core/protocol-http-auth.js +26 -18
  95. package/dist/core/remote-env.d.ts +4 -4
  96. package/dist/core/retired-keys.js +1 -0
  97. package/dist/core/rule-offer-read.d.ts +1 -1
  98. package/dist/core/rule-offer-read.js +32 -4
  99. package/dist/core/run-ledger-seat.d.ts +66 -0
  100. package/dist/core/run-ledger-seat.js +70 -0
  101. package/dist/core/run-ledger.d.ts +332 -0
  102. package/dist/core/run-ledger.js +550 -0
  103. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  104. package/dist/core/runner/checkpoint-scope.js +12 -4
  105. package/dist/core/runner/construction-doors.js +6 -0
  106. package/dist/core/runner/contracts.d.ts +21 -5
  107. package/dist/core/runner/delegation-owner.d.ts +30 -0
  108. package/dist/core/runner/delegation-owner.js +20 -4
  109. package/dist/core/runner/finish-reason-seat.js +4 -2
  110. package/dist/core/runner/leg-frame.js +3 -0
  111. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  112. package/dist/core/runner/nested-memory-lane.js +91 -30
  113. package/dist/core/runner/person-path-rows.d.ts +21 -16
  114. package/dist/core/runner/person-path-rows.js +80 -15
  115. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  116. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  117. package/dist/core/runner/prepare-config-doors.js +5 -3
  118. package/dist/core/runner/prepare-context-lane.js +1 -0
  119. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  120. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  121. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  122. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  123. package/dist/core/runner/prepare-hands-readface.js +12 -1
  124. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  125. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  126. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  127. package/dist/core/runner/prepare-run-refs.js +3 -2
  128. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  129. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  130. package/dist/core/runner/prepare-task.js +36 -27
  131. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  132. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  133. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  134. package/dist/core/runner/prepare-wiring-manifest.js +5 -2
  135. package/dist/core/runner/resume-apply.js +11 -5
  136. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  137. package/dist/core/runner/resume-review-outcome.js +24 -1
  138. package/dist/core/runner/run-harness-handlers.js +3 -0
  139. package/dist/core/runner/run-identity-wiring.js +3 -2
  140. package/dist/core/runner/run-leg.js +3 -0
  141. package/dist/core/runner/run-notification-lane.js +20 -1
  142. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  143. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  144. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  145. package/dist/core/runner/runtask.d.ts +6 -2
  146. package/dist/core/runner/runtask.js +21 -9
  147. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  148. package/dist/core/runner/shell-env-withheld.js +1 -2
  149. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  150. package/dist/core/runner/stop-tail-notice.js +9 -2
  151. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  152. package/dist/core/runner/stream-settle-backstop.js +1 -0
  153. package/dist/core/runner/task-start-doors.js +6 -3
  154. package/dist/core/runner/terminal-account.d.ts +6 -1
  155. package/dist/core/runner/terminal-account.js +16 -1
  156. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  157. package/dist/core/runner-deps.d.ts +13 -10
  158. package/dist/core/secret-env.d.ts +53 -37
  159. package/dist/core/secret-env.js +44 -47
  160. package/dist/core/session-checkout.d.ts +3 -0
  161. package/dist/core/session-checkout.js +1 -0
  162. package/dist/core/session-store.d.ts +12 -6
  163. package/dist/core/session-store.js +26 -6
  164. package/dist/core/session.d.ts +31 -8
  165. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  166. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  167. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  168. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  169. package/dist/core/store-contracts/session-store-contract.js +87 -3
  170. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  171. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  172. package/dist/core/task-event.d.ts +10 -3
  173. package/dist/core/task-notification.d.ts +96 -10
  174. package/dist/core/task-notification.js +129 -5
  175. package/dist/core/task-registry-shared.d.ts +12 -1
  176. package/dist/core/task-registry-shared.js +3 -1
  177. package/dist/core/task-registry-workflow.d.ts +1 -1
  178. package/dist/core/task-registry-workflow.js +9 -1
  179. package/dist/core/task-registry.d.ts +39 -2
  180. package/dist/core/task-registry.js +76 -12
  181. package/dist/core/task-result.d.ts +13 -0
  182. package/dist/core/task-spec-members.d.ts +3 -1
  183. package/dist/core/task-spec-members.js +11 -3
  184. package/dist/core/task-spec.d.ts +48 -22
  185. package/dist/core/tool-catalog-entries.js +2 -0
  186. package/dist/core/tool-mount-facts.d.ts +1 -1
  187. package/dist/core/tool-mount-facts.js +1 -0
  188. package/dist/core/tool-mount-plan.d.ts +3 -1
  189. package/dist/core/tool-mount-plan.js +6 -0
  190. package/dist/core/tool-mount-static.d.ts +1 -1
  191. package/dist/core/tool-mount-static.js +4 -2
  192. package/dist/core/tool-result-store.d.ts +19 -2
  193. package/dist/core/tool-result-store.js +51 -2
  194. package/dist/core/tool-spec.d.ts +9 -2
  195. package/dist/core/user-attachment.d.ts +5 -1
  196. package/dist/core/user-attachment.js +14 -7
  197. package/dist/core/wiring-manifest.d.ts +26 -20
  198. package/dist/core/wiring-manifest.js +7 -3
  199. package/dist/core/workflow-journal-store.d.ts +53 -10
  200. package/dist/core/workflow-journal-store.js +27 -4
  201. package/dist/core/workflow-run-store-contract.js +16 -0
  202. package/dist/core/workflow-run-store.d.ts +9 -7
  203. package/dist/core/workflow-run-store.js +4 -1
  204. package/dist/engine/execution-env/node-execution-env.js +3 -1
  205. package/dist/engine/harness/types.d.ts +24 -1
  206. package/dist/engine/harness/types.js +10 -0
  207. package/dist/engine/llm/types.d.ts +5 -7
  208. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  209. package/dist/engine/session/import-validate.js +6 -1
  210. package/dist/engine/session/session.d.ts +15 -2
  211. package/dist/engine/session/session.js +34 -4
  212. package/dist/index.d.ts +18 -7
  213. package/dist/index.js +13 -4
  214. package/dist/orchestration/run-workflow-tool.js +40 -32
  215. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  216. package/dist/orchestration/workflow-park-adoption.js +47 -12
  217. package/dist/orchestration/workflow-stop.d.ts +128 -0
  218. package/dist/orchestration/workflow-stop.js +156 -0
  219. package/dist/orchestration/workflow.d.ts +30 -6
  220. package/dist/orchestration/workflow.js +117 -55
  221. package/dist/prompts/manager-recipe.d.ts +18 -0
  222. package/dist/prompts/manager-recipe.js +24 -0
  223. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  224. package/dist/stores/file/permission-rule-store.js +0 -1
  225. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  226. package/dist/stores/file/workflow-journal-store.js +93 -5
  227. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  228. package/dist/tools/fs/file-write-check.js +9 -3
  229. package/dist/tools/fs/index.d.ts +8 -7
  230. package/dist/tools/fs/index.js +4 -4
  231. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  232. package/dist/tools/fs/read-deny-home.js +5 -5
  233. package/dist/tools/fs/read-deny.d.ts +33 -8
  234. package/dist/tools/fs/read-deny.js +114 -25
  235. package/dist/tools/fs/safety.d.ts +4 -1
  236. package/dist/tools/fs/safety.js +4 -2
  237. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  238. package/dist/tools/fs/shell-read-check.js +96 -14
  239. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  240. package/dist/tools/fs/shell-read-establish.js +21 -11
  241. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  242. package/dist/tools/fs/shell-read-judge.js +26 -7
  243. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  244. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  245. package/package.json +2 -2
  246. package/test/export-surface.snapshot.json +131 -1
  247. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  248. package/wire-changes/answers/core@7.73.0.json +216 -0
  249. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  250. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  251. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  252. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  253. package/wire-changes/core@7.73.0.json +6480 -0
  254. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  255. package/wire-changes/primitives@7.73.0.json +227 -0
  256. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -1,6 +1,6 @@
1
1
  import { strict as assert } from "node:assert";
2
- import { statSync } from "node:fs";
3
- import { isAbsolute } from "node:path";
2
+ import { readdirSync, statSync } from "node:fs";
3
+ import { isAbsolute, join } from "node:path";
4
4
  import { SessionError, StoredSession, uuidv7 } from "../../internal/harness.js";
5
5
  import { promptIdentityOf, walkPromptEpochCarriers } from "../../prompt-assembly/epoch.js";
6
6
  import { textContentHashOf } from "../canonical-json.js";
@@ -149,7 +149,7 @@ function assertActivityOrder(rows, newerToOlder, what) {
149
149
  }
150
150
  const HOOK_WORDS = { subject: "SessionStoreContractHooks", unit: "hook", moment: "at sessionStoreContract" };
151
151
  const REQUIRED_HOOKS = ["deleteSession", "reopen"];
152
- const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "composed", "runAssertion", "onOptionalMember"];
152
+ const OPTIONAL_HOOKS = ["replica", "tokenlessRow", "openRefusedRow", "unreadableRow", "ageIdle", "idleClockOf", "composed", "runAssertion", "onOptionalMember"];
153
153
  const GRANT_FIXTURE_FUNCTIONS = ["current", "replaced", "ended", "unknownStatus"];
154
154
  function receiveHooks(make, hooks) {
155
155
  if (typeof make !== "function")
@@ -172,6 +172,8 @@ function receiveHooks(make, hooks) {
172
172
  throw receiptRefusal(`${HOOK_WORDS.subject}.noTokenlessRows must say why the store holds no row written before occupant tokens (a non-empty string) when present, got ${describeRejectedValue(none)}`);
173
173
  if (none !== undefined && readMember(got, "tokenlessRow") !== undefined)
174
174
  throw receiptRefusal(`${HOOK_WORDS.subject} gives tokenlessRow and declares noTokenlessRows — a store holds such rows (the hook writes one) or says why it holds none, not both`);
175
+ if ((readMember(got, "ageIdle") === undefined) !== (readMember(got, "idleClockOf") === undefined))
176
+ throw receiptRefusal(`${HOOK_WORDS.subject} gives one of ageIdle and idleClockOf — the idle clock seam is the two together (put a session past the idle window, read its clock), or neither`);
175
177
  const grants = readMember(got, "grants");
176
178
  if (grants !== undefined) {
177
179
  if (typeof grants !== "object" || grants === null)
@@ -230,6 +232,9 @@ async function runSessionStoreContract(make, hooks) {
230
232
  deleteUnreadable: (s) => hasHead(s) && typeof s.deleteUnreadable === "function",
231
233
  holder: (s) => s.fence !== undefined || hooks.composed !== undefined,
232
234
  recordOwner: (s) => hasOwnership(s) && typeof s.recordOwner === "function",
235
+ readRow: (s) => typeof s.readRow === "function",
236
+ idleClock: () => hooks.ageIdle !== undefined && hooks.idleClockOf !== undefined,
237
+ unreadableRow: () => hooks.unreadableRow !== undefined,
233
238
  };
234
239
  const FACE_OWED = {
235
240
  tokenlessRow: (s) => s.durability === "durable" && hooks.noTokenlessRows === undefined
@@ -1817,6 +1822,23 @@ async function runSessionStoreContract(make, hooks) {
1817
1822
  }
1818
1823
  assert.equal(await ownerOf(store, id, "after the refused deletes"), "kit-alice");
1819
1824
  });
1825
+ faceRun("[delete] the occupant form { row: { owner, incarnation } } deletes only the occupant a read answered: the row deleted and created again under the id by the same owner is not deleted by the first occupant's guard, and is by its own; row null, a log mark and a guard naming both forms are refused", ["delete", "ownership"], async (store) => {
1826
+ const id = freshId();
1827
+ await store.register(id, "kit-alice");
1828
+ const first = await tokenOf(store, id, "the first occupant");
1829
+ assert.equal(await store.delete(id, { owner: "kit-alice" }), true);
1830
+ await store.register(id, "kit-alice");
1831
+ const second = await tokenOf(store, id, "the id created again by the same owner");
1832
+ assert.notEqual(second, first, "a later create under the id is a new occupant");
1833
+ assert.equal(await store.delete(id, { row: { owner: "kit-alice", incarnation: first } }), false, "the first occupant's guard does not take the second");
1834
+ assert.equal(await store.delete(id, { row: { owner: "kit-bob", incarnation: second } }), false, "another owner's occupant guard deletes nothing");
1835
+ assert.equal(await ownerOf(store, id, "after two refused occupant deletes"), "kit-alice");
1836
+ for (const guard of [{ row: null }, { row: { owner: "kit-alice", incarnation: second }, log: { length: 0, lastEntryId: null } }, { owner: "kit-alice", row: { owner: "kit-alice", incarnation: second } }]) {
1837
+ await thrownBy(() => Reflect.apply(store.delete, store, [id, guard]), `delete with guard ${JSON.stringify(guard)}`);
1838
+ }
1839
+ assert.equal(await store.delete(id, { row: { owner: "kit-alice", incarnation: second } }), true, "its own occupant's guard deletes it");
1840
+ assert.equal(await headOf(store, id), undefined, "the row is gone");
1841
+ });
1820
1842
  faceRun("[delete] a row whose head reads and whose open is refused corrupt_session (the openRefusedRow hook) is judged on its head alone: another owner's guard answers false, its owner's answers true and the id answers nothing; the operator's delete, where present, answers false for it first (its head reads)", ["delete", "ownership", "openRefusedRow"], async (store) => {
1821
1843
  const id = freshId();
1822
1844
  await hooks.openRefusedRow(store, id, "kit-alice");
@@ -1851,6 +1873,68 @@ async function runSessionStoreContract(make, hooks) {
1851
1873
  assert.equal(await store.deleteUnreadable(none), false, "no row ⇒ false");
1852
1874
  assert.equal(await headOf(store, none), undefined, "and nothing is created under the id");
1853
1875
  });
1876
+ faceRun("[readRow] a read sweeps nothing: a session past the store's idle window is still held, and still reads, after another session's read", ["readRow", "idleClock"], async (store) => {
1877
+ const idle = freshId();
1878
+ const read = freshId();
1879
+ await append((await store.acquire(idle)).session, userEntry("i1", null));
1880
+ await append((await store.acquire(read)).session, userEntry("r1", null));
1881
+ await hooks.ageIdle(store, idle);
1882
+ const agedAt = await hooks.idleClockOf(store, idle);
1883
+ assert.ok(agedAt !== undefined, "the aged session is held before the read");
1884
+ assert.ok((await store.readRow(read)) !== undefined, "the read session's row is answered");
1885
+ assert.equal(await hooks.idleClockOf(store, idle), agedAt, "the idle session is still held, its clock where it was: the read evicted nothing");
1886
+ assert.deepEqual((await store.readRow(idle))?.entries.map((e) => e.id), ["i1"], "and its row still reads, its log whole: the read deleted nothing");
1887
+ });
1888
+ faceRun("[readRow] a read is no activity: the read session's idle clock does not move, nor its listed time", ["readRow", "idleClock"], async (store) => {
1889
+ const id = freshId();
1890
+ await append((await store.acquire(id)).session, userEntry("r1", null));
1891
+ await hooks.ageIdle(store, id);
1892
+ const before = await hooks.idleClockOf(store, id);
1893
+ const listedBefore = typeof store.list === "function" ? rowOf(await store.list(), id)?.lastActiveAt : undefined;
1894
+ assert.ok(before !== undefined, "the session is held before the read");
1895
+ assert.ok((await store.readRow(id)) !== undefined, "the row is answered");
1896
+ assert.equal(await hooks.idleClockOf(store, id), before, "the read moved the session's idle clock (or evicted it)");
1897
+ if (typeof store.list === "function")
1898
+ assert.equal(rowOf(await store.list(), id)?.lastActiveAt, listedBefore, "the read moved the session's listed time");
1899
+ });
1900
+ faceRun("[readRow] a read writes nothing: no row, entry, listed time or transcript file appears or changes — an id with no row included", ["readRow"], async (store) => {
1901
+ const id = freshId();
1902
+ const none = freshId();
1903
+ await append((await store.acquire(id)).session, userEntry("r1", null));
1904
+ const dir = store.transcriptDirectory;
1905
+ const files = () => (typeof dir === "string" ? readdirSync(dir, { recursive: true }).map(String).sort().map((f) => `${f}:${statSync(join(dir, f)).size}:${statSync(join(dir, f)).mtimeMs}`) : []);
1906
+ const listed = async () => (typeof store.list === "function" ? (await store.list()).map((r) => `${r.sessionId}:${r.lastActiveAt}`).sort() : []);
1907
+ const head = typeof store.headOf === "function" ? await store.headOf(id) : undefined;
1908
+ const [filesBefore, listedBefore] = [files(), await listed()];
1909
+ await store.readRow(id);
1910
+ assert.equal(await store.readRow(none), undefined, "an id with no row answers no row");
1911
+ assert.deepEqual(files(), filesBefore, "no transcript file appeared or changed");
1912
+ assert.deepEqual(await listed(), listedBefore, "no listed row appeared or moved");
1913
+ if (typeof store.headOf === "function") {
1914
+ assert.deepEqual(await store.headOf(id), head, "the read row's head is the one it had");
1915
+ assert.equal(await store.headOf(none), undefined, "nothing is created under an id with no row");
1916
+ }
1917
+ });
1918
+ faceRun("[readRow] an id with no row resolves undefined — a definite no — and a row resolves its metadata, head and whole log of one generation", ["readRow"], async (store) => {
1919
+ const none = freshId();
1920
+ assert.equal(await store.readRow(none), undefined, "no row ⇒ undefined, never a rejection");
1921
+ const id = freshId();
1922
+ const { session } = await store.acquire(id);
1923
+ await append(session, userEntry("r1", null));
1924
+ await append(session, assistantEntry("r2", "r1"));
1925
+ const row = await store.readRow(id);
1926
+ assert.ok(row !== undefined, "a row ⇒ answered");
1927
+ assert.equal(row.metadata.id, id, "the row's own metadata");
1928
+ assert.deepEqual(row.entries.map((e) => e.id), ["r1", "r2"], "its whole log, oldest first");
1929
+ assert.equal(row.head.leafId, "r2", "its head names the leaf of that log");
1930
+ assert.equal(row.head.incarnation, (await session.getMetadata()).incarnation, "and the occupant the store handed out");
1931
+ });
1932
+ faceRun("[readRow] a row that is there and cannot be read rejects coded (corrupt_session) — never the undefined of no row", ["readRow", "unreadableRow"], async (store) => {
1933
+ const id = freshId();
1934
+ await hooks.unreadableRow(store, id);
1935
+ const answer = await store.readRow(id).then((row) => ({ resolved: row }), (err) => ({ rejected: readMember(err, "code") }));
1936
+ assert.deepEqual(answer, { rejected: "corrupt_session" }, "a row whose header cannot be read is a failed read, told apart from no row");
1937
+ });
1854
1938
  await settle();
1855
1939
  }
1856
1940
  function firstTextBlock(entry) {
@@ -1,7 +1,25 @@
1
1
  import { type WorkflowJournalStore } from "../workflow-journal-store.js";
2
2
  import { type ContractAssertionRunner } from "./contract-harness.js";
3
+ /**
4
+ * Optional backend-specific hooks for the #5156 R1 `stopResumeClaim` arm-(b) contract cases (aging a held claim past its expiry,
5
+ * and — for backends that judge holder-process liveness — marking a held claim's process as gone). A backend that omits hooks
6
+ * still clears arms (a), (c), (d) and the non-writing arm whenever it implements `stopResumeClaim`.
7
+ */
8
+ export interface WorkflowJournalStoreContractHooks {
9
+ /** Age a held claim on `(sourceRunId, scope)` past its expiry so arm (b) ("expired") runs on the real backend.
10
+ * May return a cleanup callback (e.g. restoring a shifted clock), invoked in a `finally` after the stop call. */
11
+ readonly expireClaim?: (store: WorkflowJournalStore, key: {
12
+ readonly sourceRunId: string;
13
+ readonly scope: string;
14
+ }) => Promise<void | (() => void)> | void | (() => void);
15
+ /** Mark a held claim on `(sourceRunId, scope)` as published by a process proven gone on this host (file-store arm (b)). */
16
+ readonly markClaimHolderGone?: (store: WorkflowJournalStore, key: {
17
+ readonly sourceRunId: string;
18
+ readonly scope: string;
19
+ }) => Promise<void> | void;
20
+ }
3
21
  /**
4
22
  * The full cross-backend contract for {@link WorkflowJournalStore}. Every case builds its own store via
5
23
  * `make()`; with no runner the cases run sequentially and the first failure throws.
6
24
  */
7
- export declare function workflowJournalStoreContract(make: () => WorkflowJournalStore, runAssertion?: ContractAssertionRunner): Promise<void>;
25
+ export declare function workflowJournalStoreContract(make: () => WorkflowJournalStore, runAssertion?: ContractAssertionRunner, hooks?: WorkflowJournalStoreContractHooks): Promise<void>;
@@ -24,7 +24,7 @@ const parked = (ordinal, over = {}) => ({
24
24
  const OVER_CAP = "x".repeat(MAX_JOURNAL_RESULT_BYTES + 1024);
25
25
  const isOversizeRefusal = (e) => e instanceof Error && e.code === JOURNAL_OVERSIZE_ERROR_CODE;
26
26
  const isIncompatibleRefusal = (e) => e instanceof Error && e.code === JOURNAL_INCOMPATIBLE_ERROR_CODE;
27
- export async function workflowJournalStoreContract(make, runAssertion) {
27
+ export async function workflowJournalStoreContract(make, runAssertion, hooks) {
28
28
  const { run, settle } = beginContract(runAssertion);
29
29
  run("append → load returns entries ASCENDING by ordinal, both arms verbatim; a re-append per ordinal OVERWRITES", async () => {
30
30
  const store = make();
@@ -267,5 +267,93 @@ export async function workflowJournalStoreContract(make, runAssertion) {
267
267
  await store.releaseResumeClaim(one);
268
268
  await store.releaseResumeClaim(other);
269
269
  });
270
+ run("stopResumeClaim tombstone: absent (a), given holder (c), already tombstone (d), held by another (non-writing), stopped.by on resumeClaim, permanence and scope wall", async () => {
271
+ const store = make();
272
+ if (typeof store.stopResumeClaim !== "function")
273
+ return;
274
+ assert.equal(typeof store.resumeClaim, "function", "a store that implements stopResumeClaim also implements resumeClaim");
275
+ assert.equal(typeof store.releaseResumeClaim, "function", "a store that implements stopResumeClaim also implements releaseResumeClaim");
276
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "user" }), { stopped: true });
277
+ const refusedA = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-1", scope: "tenant-a" });
278
+ assert.equal(refusedA.granted, false, "arm (a): resumeClaim on a tombstone is refused");
279
+ assert.deepEqual(refusedA.stopped, { by: "user" }, "arm (a): resumeClaim reports explicit stopped.by");
280
+ assert.equal(refusedA.remainingMs, undefined, "arm (a): a tombstone has no remainingMs");
281
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-b", scope: "tenant-b" })).granted, true, "tombstone is isolated to its scope");
282
+ await store.releaseResumeClaim({ sourceRunId: "stop-a", newRunId: "run-b", scope: "tenant-b" });
283
+ for (const candidate of ["run-1", "user", "workflow:stopped", "", ...(refusedA.holder !== undefined ? [refusedA.holder] : [])]) {
284
+ await store.releaseResumeClaim({ sourceRunId: "stop-a", newRunId: candidate, scope: "tenant-a" });
285
+ const check = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: candidate, scope: "tenant-a" });
286
+ assert.equal(check.granted, false, `release by ${JSON.stringify(candidate)} must never delete a tombstone`);
287
+ assert.deepEqual(check.stopped, { by: "user" });
288
+ }
289
+ if (store.deleteRun !== undefined) {
290
+ await store.append("stop-a", "tenant-a", { callKey: key(0), result: completed(0) });
291
+ await store.deleteRun("stop-a", "tenant-a");
292
+ const afterDelete = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-after-del", scope: "tenant-a" });
293
+ assert.equal(afterDelete.granted, false, "deleteRun must not touch tombstones");
294
+ assert.deepEqual(afterDelete.stopped, { by: "user" });
295
+ }
296
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "second" }), { stopped: true }, "arm (d): re-stop without holder is idempotent");
297
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-a", scope: "tenant-a", stoppedBy: "third", holder: "foreign" }), { stopped: true }, "arm (d): re-stop with foreign holder is idempotent");
298
+ const afterIdem = await store.resumeClaim({ sourceRunId: "stop-a", newRunId: "run-2", scope: "tenant-a" });
299
+ assert.equal(afterIdem.granted, false);
300
+ assert.deepEqual(afterIdem.stopped, { by: "user" }, "arm (d): original stoppedBy is preserved");
301
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" })).granted, true);
302
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-c", scope: "tenant-a", stoppedBy: "operator", holder: "run-h1" }), { stopped: true }, "arm (c): matching holder rewrites claim into tombstone");
303
+ const formerHolderClaim = await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" });
304
+ assert.equal(formerHolderClaim.granted, false, "arm (c): former holder can no longer re-claim");
305
+ assert.deepEqual(formerHolderClaim.stopped, { by: "operator" });
306
+ await store.releaseResumeClaim({ sourceRunId: "stop-c", newRunId: "run-h1", scope: "tenant-a" });
307
+ const afterFormerRelease = await store.resumeClaim({ sourceRunId: "stop-c", newRunId: "run-h2", scope: "tenant-a" });
308
+ assert.equal(afterFormerRelease.granted, false, "arm (c): former holder's release never deletes the tombstone");
309
+ assert.deepEqual(afterFormerRelease.stopped, { by: "operator" });
310
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" })).granted, true);
311
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-held", scope: "tenant-a", stoppedBy: "user" }), { stopped: false, holder: "run-live" }, "non-writing arm (no holder) refuses naming holder");
312
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-held", scope: "tenant-a", stoppedBy: "user", holder: "run-wrong" }), { stopped: false, holder: "run-live" }, "non-writing arm (wrong holder) refuses naming holder");
313
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" })).granted, true, "non-writing arm leaves holder's claim intact");
314
+ const stillHeld = await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" });
315
+ assert.equal(stillHeld.granted, false);
316
+ assert.equal(stillHeld.stopped, undefined, "non-writing arm wrote no tombstone");
317
+ await store.releaseResumeClaim({ sourceRunId: "stop-held", newRunId: "run-live", scope: "tenant-a" });
318
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" })).granted, true, "once released, the untouched claim is free");
319
+ await store.releaseResumeClaim({ sourceRunId: "stop-held", newRunId: "run-other", scope: "tenant-a" });
320
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "team:stop-1", scope: "tenant-a", stoppedBy: "user" }), { stopped: true });
321
+ const oddRefused = await store.resumeClaim({ sourceRunId: "team:stop-1", newRunId: "run-odd", scope: "tenant-a" });
322
+ assert.equal(oddRefused.granted, false);
323
+ assert.deepEqual(oddRefused.stopped, { by: "user" });
324
+ });
325
+ if (hooks?.expireClaim !== undefined) {
326
+ const expireClaim = hooks.expireClaim;
327
+ run("stopResumeClaim tombstone arm (b): an expired claim no longer binds and is replaced with a tombstone", async () => {
328
+ const store = make();
329
+ if (typeof store.stopResumeClaim !== "function")
330
+ return;
331
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-expired", newRunId: "run-old", scope: "tenant-a" })).granted, true);
332
+ const restore = await expireClaim(store, { sourceRunId: "stop-expired", scope: "tenant-a" });
333
+ try {
334
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-expired", scope: "tenant-a", stoppedBy: "expiry-stop" }), { stopped: true }, "arm (b) expired: replaces non-binding claim with tombstone");
335
+ }
336
+ finally {
337
+ restore?.();
338
+ }
339
+ const refused = await store.resumeClaim({ sourceRunId: "stop-expired", newRunId: "run-new", scope: "tenant-a" });
340
+ assert.equal(refused.granted, false);
341
+ assert.deepEqual(refused.stopped, { by: "expiry-stop" });
342
+ });
343
+ }
344
+ if (hooks?.markClaimHolderGone !== undefined) {
345
+ const markClaimHolderGone = hooks.markClaimHolderGone;
346
+ run("stopResumeClaim tombstone arm (b): a claim whose holder process is proven gone no longer binds and is replaced with a tombstone", async () => {
347
+ const store = make();
348
+ if (typeof store.stopResumeClaim !== "function")
349
+ return;
350
+ assert.equal((await store.resumeClaim({ sourceRunId: "stop-gone", newRunId: "run-dead-proc", scope: "tenant-a" })).granted, true);
351
+ await markClaimHolderGone(store, { sourceRunId: "stop-gone", scope: "tenant-a" });
352
+ assert.deepEqual(await store.stopResumeClaim({ sourceRunId: "stop-gone", scope: "tenant-a", stoppedBy: "crash-stop" }), { stopped: true }, "arm (b) holder gone: replaces non-binding claim with tombstone");
353
+ const refused = await store.resumeClaim({ sourceRunId: "stop-gone", newRunId: "run-new", scope: "tenant-a" });
354
+ assert.equal(refused.granted, false);
355
+ assert.deepEqual(refused.stopped, { by: "crash-stop" });
356
+ });
357
+ }
270
358
  await settle();
271
359
  }
@@ -400,6 +400,13 @@ export type TaskEvent = ({
400
400
  } & TaskEventIdentity) | ({
401
401
  type: "reasoning_delta";
402
402
  delta: string;
403
+ } & TaskEventIdentity) | ({
404
+ /** A REASONING SEGMENT is complete — `text_end`'s twin for `reasoning_delta`: the brain closed the thinking block (OpenAI:
405
+ * when answer text starts/resumes or at attempt exit; Anthropic/Open-Responses: on provider block/item close or attempt exit;
406
+ * reasoning after text began is its own segment). `content` = full segment text, untrusted, non-empty only; absent if a custom brain
407
+ * emits none or the Runner's call guardrail / loop relay timer cuts first (terminal follows). Live `contentIndex` is arrival order, not saved index. */
408
+ type: "reasoning_end";
409
+ content: string;
403
410
  } & TaskEventIdentity) | ({
404
411
  type: "tool_start";
405
412
  toolCallId: string;
@@ -1554,9 +1561,9 @@ export type TaskEvent = ({
1554
1561
  tree?: string;
1555
1562
  }>;
1556
1563
  /** This leg's project identity, decided ONCE at leg start and fixed for the leg: `marker` = the checkout's
1557
- * `.sema/project` (a `TaskSpec.projectId`, when given, equals it); `declared` = the number this leg was given —
1558
- * by its host's `TaskSpec.projectId`, or, for a delegated child that declared nothing and whose own workspace
1559
- * has no marker, the verdict of the leg that spawned it. ABSENT = none of the three, or the marker could not be
1564
+ * `.sema/project` (a `TaskSpec.project.id`, when given, equals it); `declared` = the number this leg was given —
1565
+ * by its host's `TaskSpec.project.id`, or, for a delegated child that declared nothing and whose own workspace
1566
+ * has no marker, the project seat of the leg that spawned it (a woken agent: the leg that woke it). ABSENT = none of the three, or the marker could not be
1560
1567
  * read (the deployment's `onError` was told which file and why). */
1561
1568
  project?: {
1562
1569
  id: string;
@@ -2,7 +2,9 @@ import type { MailboxAppendMessage, MailboxStore } from "./mailbox-store.js";
2
2
  import { type EngineNotice } from "./engine-notice.js";
3
3
  import type { DelegationUnreviewed } from "./classifier-unavailable-arm.js";
4
4
  import type { TaskEvent } from "./task-event.js";
5
- import type { SemaTaskType } from "./task-registry-shared.js";
5
+ import { type SemaTaskType } from "./task-registry-shared.js";
6
+ import { type A2AWaitingFor } from "./a2a-task-state.js";
7
+ import type { AskDestination } from "./mcp-server-spec.js";
6
8
  import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
7
9
  export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
8
10
  /** The TERMINAL words of {@link TaskNotificationStatus}: the one table every "is this frame a completion?"
@@ -90,6 +92,8 @@ export interface TaskNotificationPayload {
90
92
  * born child's woken cycles (2, 3, … — its first cycle sends no notification).
91
93
  * - `external`: caller-supplied verbatim ({@link ExternalNotificationInput.seq}) — the injector's
92
94
  * own dedup discriminator across same-task_id+status events.
95
+ * - `peer_task`: per-row monotonically increasing counter (`lastSeq + 1` on every progress, reminder,
96
+ * reschedule, terminal, and overdue-tail frame, starting at 1, never reused).
93
97
  * Consumers (server inbox fold / shell render) key `taskId:status[:seq]` — a frame WITHOUT seq keeps
94
98
  * the old two-part key (single-cycle semantics), by contract. */
95
99
  seq?: number;
@@ -105,9 +109,8 @@ export interface TaskNotificationPayload {
105
109
  stoppedBy?: "user" | "parent" | "system" | (string & {});
106
110
  /** Present only as `true`, minted by the engine: this frame must not start a turn of an idle session on its own — a host that
107
111
  * wakes an idle session for a completion keeps this one for the session's next turn that something else starts (a person's
108
- * message, a still-open run). For the late result of an EXTERNAL agent-to-agent peer: an outside party must not be able to
109
- * trigger a model call while nobody is there. The host reads this bit and never infers it from the lane. No lane of this
110
- * engine version mints it yet (the peer-task lane will); ABSENT = handle the frame as before. */
112
+ * message, a still-open run). Minted by {@link peerTaskNotification} iff an overdue-tail late `event` arrives from an
113
+ * `outside` peer (wired when the peer-task lane launches); ABSENT = handle the frame as before. */
111
114
  noWake?: true;
112
115
  summary: string;
113
116
  /** RB-386① — the failure reason DIGEST on a `status:"failed"` terminal notification
@@ -220,6 +223,11 @@ export interface TaskNotificationPayload {
220
223
  recentSteps?: import("../agents/subagent-steps.js").SubagentStep[];
221
224
  /** Residual lane D (core half) — files the child mutated with edit counts. Background-agent lane only. */
222
225
  editedFiles?: import("../agents/subagent-steps.js").SubagentEditedFile[];
226
+ /** What the child did, counted over its whole event stream (`SubagentActions`: tool calls by tool, the shell commands with
227
+ * their exit codes, the files it changed — `none` included), rendered as the `<actions>` section beside the child's own
228
+ * words. Present only on a terminal frame of the background-agent lane whose parent run declares a member ledger
229
+ * (`TaskSpec.runLedger`); absent on every other frame, so a run without one reads its notifications unchanged. */
230
+ actions?: import("./actions-digest.js").SubagentActions;
223
231
  /** How the child ended — the background agent row's outcome (`MemberOutcome`), the one object the row, this frame and the
224
232
  * parent's report read: its ending word and its ONE refusal record (asks nobody could answer, calls a person or anything else
225
233
  * refused, a verdict that never landed, a person's halt). Present on a terminal frame of the background-agent lane whenever the
@@ -266,6 +274,10 @@ export interface TaskNotificationPayload {
266
274
  * re-judges the frame under the same sender at the drain. Engine-read; never rendered. */
267
275
  senderKey?: string;
268
276
  };
277
+ /** Facade carried on `task_type: "peer_task"` frames (named `peerTask` because {@link peer} is SendMessage's
278
+ * hop-chain carrier). Core fields are minted by the peer-task lane; `reminder` is reserved for the reminder
279
+ * producer, and `peerFinalBy` / `approvalBy` / `clock` are reserved for the deadline-extension producer. */
280
+ peerTask?: PeerTaskNotification;
269
281
  /**
270
282
  * design/385 §1.4 d1 — the delegated-child → parent UPLINK carrier (`SendMessage("main")`). Its
271
283
  * PRESENCE is the render discriminator: the frame reaches the parent's model as a top-level
@@ -717,16 +729,90 @@ export declare const SHORT_REPORT_UNSTORED = "a background task's report could n
717
729
  export declare function completionResultField(result: string | undefined, persist: (report: string) => Promise<import("./tool-result-store.js").TaskArtifact>, record: (ref: string) => void, notifier: Pick<import("./safe-notify.js").SafeNotifier, "notifyAsync">): Promise<{
718
730
  readonly text: string;
719
731
  } | undefined>;
720
- /** The codec version this engine writes into an `engine_frame` record and the highest it reads. */
721
- export declare const ENGINE_FRAME_CODEC_VERSION = 1;
732
+ /** Whether a peer accepts follow-up messages on a dispatched `peer_task`. */
733
+ export declare const PEER_TASK_FOLLOW_UPS: readonly ["accepted", "not_accepted"];
734
+ export type PeerTaskFollowUps = (typeof PEER_TASK_FOLLOW_UPS)[number];
735
+ /** Cancellation state of a `peer_task` row. */
736
+ export declare const PEER_TASK_CANCEL_STATES: readonly ["not_requested", "requested", "confirmed"];
737
+ export type PeerTaskCancelState = (typeof PEER_TASK_CANCEL_STATES)[number];
738
+ /** Peer-reported deadline clock state (`sema.deadline.clock`); not minted in this release. */
739
+ export declare const PEER_TASK_CLOCK_STATES: readonly ["running", "paused"];
740
+ export type PeerTaskClockState = (typeof PEER_TASK_CLOCK_STATES)[number];
741
+ /** Target of a `peer_task` reminder; not minted in this release. */
742
+ export declare const PEER_TASK_REMINDER_TARGETS: readonly ["peer", "peer_owner", "peer_approver"];
743
+ export type PeerTaskReminderTarget = (typeof PEER_TASK_REMINDER_TARGETS)[number];
744
+ /** Disposition of one `peer_task` reminder attempt; not minted in this release. */
745
+ export declare const PEER_TASK_REMINDER_DISPOSITIONS: readonly ["due", "skipped_not_sent", "sent", "received", "answered"];
746
+ export type PeerTaskReminderDisposition = (typeof PEER_TASK_REMINDER_DISPOSITIONS)[number];
747
+ /** Where the serving peer routed a received/answered reminder; not minted in this release. */
748
+ export declare const PEER_TASK_REMINDER_ROUTES: readonly ["pending_list", "run", "none"];
749
+ export type PeerTaskReminderRoute = (typeof PEER_TASK_REMINDER_ROUTES)[number];
750
+ /** Reminder disposition facet on a reminder `event` frame; not minted in this release. */
751
+ export interface PeerTaskReminderFacet {
752
+ readonly n: number;
753
+ readonly target: PeerTaskReminderTarget;
754
+ readonly disposition: PeerTaskReminderDisposition;
755
+ /** Present only when `disposition` is `"received"` or `"answered"`; not minted in this release. */
756
+ readonly routedTo?: PeerTaskReminderRoute;
757
+ }
758
+ /** Facade on `task_type: "peer_task"` notification frames. Every member is optional on the wire shape;
759
+ * `reminder` and `peerFinalBy` / `approvalBy` / `clock` are reserved and not minted in this release. */
760
+ export interface PeerTaskNotification {
761
+ readonly destination?: AskDestination;
762
+ readonly followUps?: PeerTaskFollowUps;
763
+ readonly cancel?: PeerTaskCancelState;
764
+ readonly waitingFor?: A2AWaitingFor;
765
+ readonly remoteMayContinue?: true;
766
+ readonly ackBy?: number;
767
+ readonly finalBy?: number;
768
+ /** Reserved for deadline-extension responses; not minted in this release. */
769
+ readonly peerFinalBy?: number;
770
+ /** Reserved for deadline-extension responses; not minted in this release. */
771
+ readonly approvalBy?: number;
772
+ /** Reserved for deadline-extension responses; not minted in this release. */
773
+ readonly clock?: PeerTaskClockState;
774
+ /** Reserved for reminder frames; not minted in this release. */
775
+ readonly reminder?: PeerTaskReminderFacet;
776
+ }
777
+ /** Input to {@link peerTaskNotification} (internal builder; reserved reminder and deadline-extension members are excluded). */
778
+ export interface PeerTaskNotificationInput {
779
+ readonly task_id: string;
780
+ readonly status: TaskNotificationStatus;
781
+ readonly seq: number;
782
+ readonly summary: string;
783
+ readonly result?: string;
784
+ readonly error?: string;
785
+ readonly errorCode?: string;
786
+ readonly stoppedBy?: TaskNotificationPayload["stoppedBy"];
787
+ readonly outcome?: import("./member-outcome.js").MemberOutcome;
788
+ readonly completionId?: string;
789
+ /** True iff this `status: "event"` frame carries a late result arriving inside the overdue tail. */
790
+ readonly overdueTail?: boolean;
791
+ readonly peerTask: {
792
+ readonly destination: AskDestination;
793
+ readonly followUps: PeerTaskFollowUps;
794
+ readonly cancel: PeerTaskCancelState;
795
+ readonly ackBy: number;
796
+ readonly finalBy: number;
797
+ readonly waitingFor?: A2AWaitingFor;
798
+ readonly remoteMayContinue?: true;
799
+ };
800
+ }
801
+ /** Pure builder for `peer_task` frames (internal to core; no live run emits outward frames in this release).
802
+ * Mints `noWake: true` iff `overdueTail === true && status === "event" && destination.boundary === "outside"`.
803
+ * Never mints reserved reminder or deadline-extension members (`peerFinalBy`, `approvalBy`, `clock`, `reminder`). */
804
+ export declare function peerTaskNotification(input: PeerTaskNotificationInput): TaskNotificationPayload;
805
+ /** Highest `engine_frame` codec version this engine reads (D1-b: writer picks the lowest readable version per frame). */
806
+ export declare const ENGINE_FRAME_CODEC_VERSION = 2;
722
807
  /** The engine's own lanes — the only frames the durable park may encode (an `external` event never is). */
723
- export declare const ENGINE_FRAME_TASK_TYPES: readonly ["background_agent", "monitor", "workflow"];
808
+ export declare const ENGINE_FRAME_TASK_TYPES: readonly ["background_agent", "monitor", "workflow", "peer_task"];
809
+ /** Lowest codec version whose reader understands `taskType` (D1-b: v2 for `peer_task`, v1 for the three original lanes). */
810
+ export declare function engineFrameCodecVersionFor(taskType: TaskNotificationPayload["task_type"]): number;
724
811
  /** May this frame take the durable engine-frame park? Its lane must be one of the engine's own and it
725
812
  * must wear no shell-less carrier. */
726
813
  export declare function isEngineFrameParkable(payload: TaskNotificationPayload): boolean;
727
- /** The record text of a durably parked engine frame: the codec version, the injection tier it was
728
- * submitted at, and the frame itself (its own `seq` is the lane's cycle count — a different domain
729
- * from the box seq, carried inside untouched). */
814
+ /** The record text of a durably parked engine frame: the lowest codec version that reads this lane
815
+ * ({@link engineFrameCodecVersionFor}), the injection tier, and the frame itself. */
730
816
  export declare function encodeEngineFrame(payload: TaskNotificationPayload, priority: SystemInjectionPriority): string;
731
817
  export type EngineFrameDecode = {
732
818
  ok: true;