@sema-agent/core 7.69.0 → 7.69.1

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 (309) hide show
  1. package/CHANGELOG.md +583 -0
  2. package/dist/agents/repair-loop.js +6 -14
  3. package/dist/agents/subagent.js +2 -1
  4. package/dist/agents/verify.d.ts +1 -1
  5. package/dist/agents/verify.js +7 -1
  6. package/dist/brain/reasoning-request.d.ts +7 -0
  7. package/dist/brain/reasoning-request.js +6 -0
  8. package/dist/core/agent-config-dir.d.ts +39 -3
  9. package/dist/core/agent-config-dir.js +67 -11
  10. package/dist/core/allow-entry.d.ts +5 -5
  11. package/dist/core/allow-entry.js +12 -6
  12. package/dist/core/ask-headline.d.ts +2 -2
  13. package/dist/core/ask-origin.d.ts +31 -31
  14. package/dist/core/ask-origin.js +20 -13
  15. package/dist/core/attachment-source.d.ts +1 -1
  16. package/dist/core/attachment-source.js +1 -0
  17. package/dist/core/auto-compaction.d.ts +44 -62
  18. package/dist/core/auto-compaction.js +44 -103
  19. package/dist/core/cache-break-detector.d.ts +23 -11
  20. package/dist/core/cache-break-detector.js +11 -5
  21. package/dist/core/checkpoint-features.d.ts +1 -1
  22. package/dist/core/checkpoint-features.js +1 -1
  23. package/dist/core/checkpoint-requirements.d.ts +19 -1
  24. package/dist/core/checkpoint-requirements.js +6 -0
  25. package/dist/core/checkpoint-row-verdict.js +3 -0
  26. package/dist/core/checkpoint-store.d.ts +13 -2
  27. package/dist/core/child-clamp-seats.d.ts +30 -3
  28. package/dist/core/child-clamp-seats.js +24 -0
  29. package/dist/core/compaction-retired-members.d.ts +12 -0
  30. package/dist/core/compaction-retired-members.js +22 -0
  31. package/dist/core/config-refusal-codes.d.ts +1 -1
  32. package/dist/core/config-refusal-codes.js +2 -0
  33. package/dist/core/context-edit.d.ts +32 -17
  34. package/dist/core/context-edit.js +28 -0
  35. package/dist/core/cron.d.ts +68 -0
  36. package/dist/core/cron.js +259 -0
  37. package/dist/core/engine-attestation.d.ts +16 -0
  38. package/dist/core/engine-attestation.js +2 -0
  39. package/dist/core/engine-capabilities.d.ts +14 -1
  40. package/dist/core/engine-capabilities.js +1 -1
  41. package/dist/core/engine-notice.d.ts +18 -7
  42. package/dist/core/engine-version.js +1 -1
  43. package/dist/core/gate-outcome.d.ts +29 -2
  44. package/dist/core/gate-outcome.js +6 -0
  45. package/dist/core/git-read-only.d.ts +10 -0
  46. package/dist/core/git-read-only.js +1 -0
  47. package/dist/core/git-worktree-env.js +9 -8
  48. package/dist/core/governance-codes.d.ts +9 -2
  49. package/dist/core/governance-codes.js +9 -0
  50. package/dist/core/locked-config.js +7 -3
  51. package/dist/core/lsp.d.ts +3 -0
  52. package/dist/core/lsp.js +3 -2
  53. package/dist/core/memory-engine/engine.d.ts +48 -12
  54. package/dist/core/memory-engine/engine.js +108 -46
  55. package/dist/core/memory-engine/file-backend.d.ts +2 -1
  56. package/dist/core/memory-engine/index-copies.d.ts +47 -0
  57. package/dist/core/memory-engine/index-copies.js +88 -0
  58. package/dist/core/memory-engine/layout.d.ts +20 -3
  59. package/dist/core/memory-engine/layout.js +39 -3
  60. package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
  61. package/dist/core/memory-engine/origin-clearance.js +2 -4
  62. package/dist/core/memory-engine/types.d.ts +16 -3
  63. package/dist/core/mode-policy.d.ts +7 -1
  64. package/dist/core/mode-policy.js +9 -0
  65. package/dist/core/mods/session-compact.js +3 -3
  66. package/dist/core/mods/stations.d.ts +2 -0
  67. package/dist/core/mods/stations.js +2 -1
  68. package/dist/core/path-guard-rows.d.ts +8 -3
  69. package/dist/core/path-guard-rows.js +18 -5
  70. package/dist/core/peer-seat.d.ts +3 -0
  71. package/dist/core/peer-seat.js +3 -0
  72. package/dist/core/permission-rule-model.js +3 -2
  73. package/dist/core/process-identity.d.ts +11 -3
  74. package/dist/core/process-identity.js +26 -16
  75. package/dist/core/runner/assemble-result.d.ts +5 -0
  76. package/dist/core/runner/assemble-result.js +1 -1
  77. package/dist/core/runner/cleared-results-record.d.ts +33 -0
  78. package/dist/core/runner/cleared-results-record.js +56 -0
  79. package/dist/core/runner/compact-session.js +14 -9
  80. package/dist/core/runner/compaction-knobs.d.ts +1 -1
  81. package/dist/core/runner/continuation-gate.js +2 -1
  82. package/dist/core/runner/continues-from.d.ts +1 -1
  83. package/dist/core/runner/continues-from.js +1 -1
  84. package/dist/core/runner/contracts.d.ts +83 -31
  85. package/dist/core/runner/conversation-segment.d.ts +19 -12
  86. package/dist/core/runner/conversation-segment.js +27 -7
  87. package/dist/core/runner/derived-route-fallback.d.ts +2 -12
  88. package/dist/core/runner/derived-route-fallback.js +0 -6
  89. package/dist/core/runner/gate-exit.d.ts +2 -1
  90. package/dist/core/runner/gate-exit.js +4 -2
  91. package/dist/core/runner/git-status-frame.d.ts +2 -2
  92. package/dist/core/runner/git-status-frame.js +2 -1
  93. package/dist/core/runner/initial-run-state.js +1 -1
  94. package/dist/core/runner/leg-caller-places.d.ts +39 -0
  95. package/dist/core/runner/leg-caller-places.js +23 -0
  96. package/dist/core/runner/leg-frame.d.ts +8 -2
  97. package/dist/core/runner/leg-receipt.d.ts +29 -2
  98. package/dist/core/runner/leg-receipt.js +37 -6
  99. package/dist/core/runner/media-removed-seat.d.ts +10 -6
  100. package/dist/core/runner/media-removed-seat.js +6 -3
  101. package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
  102. package/dist/core/runner/messages-omitted-seat.js +15 -5
  103. package/dist/core/runner/person-path-rows.d.ts +25 -7
  104. package/dist/core/runner/person-path-rows.js +16 -2
  105. package/dist/core/runner/prefix-ledger.d.ts +120 -0
  106. package/dist/core/runner/prefix-ledger.js +176 -0
  107. package/dist/core/runner/prepare-advisor.d.ts +2 -0
  108. package/dist/core/runner/prepare-advisor.js +2 -1
  109. package/dist/core/runner/prepare-artifact.d.ts +3 -0
  110. package/dist/core/runner/prepare-artifact.js +2 -2
  111. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  112. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  113. package/dist/core/runner/prepare-config-doors.d.ts +9 -8
  114. package/dist/core/runner/prepare-config-doors.js +15 -12
  115. package/dist/core/runner/prepare-context-lane.d.ts +25 -6
  116. package/dist/core/runner/prepare-context-lane.js +82 -27
  117. package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
  118. package/dist/core/runner/prepare-gate-stations.js +2 -4
  119. package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
  120. package/dist/core/runner/prepare-hands-readface.js +41 -22
  121. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
  122. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  123. package/dist/core/runner/prepare-memory.d.ts +10 -2
  124. package/dist/core/runner/prepare-memory.js +51 -5
  125. package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
  126. package/dist/core/runner/prepare-policy-chain.js +13 -2
  127. package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
  128. package/dist/core/runner/prepare-prompt-assembly.js +10 -4
  129. package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
  130. package/dist/core/runner/prepare-prompt-inputs.js +6 -7
  131. package/dist/core/runner/prepare-safety-scan.js +7 -0
  132. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
  133. package/dist/core/runner/prepare-suspend-saga.js +3 -2
  134. package/dist/core/runner/prepare-task.js +59 -53
  135. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
  136. package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
  137. package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
  138. package/dist/core/runner/prepare-turn-wiring.js +8 -18
  139. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
  140. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  141. package/dist/core/runner/prompt-suggestions.d.ts +3 -1
  142. package/dist/core/runner/prompt-suggestions.js +1 -1
  143. package/dist/core/runner/read-block-judge.d.ts +47 -0
  144. package/dist/core/runner/read-block-judge.js +33 -0
  145. package/dist/core/runner/role-resolution-table.d.ts +15 -10
  146. package/dist/core/runner/role-resolution-table.js +4 -5
  147. package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
  148. package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
  149. package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
  150. package/dist/core/runner/run-compaction-machinery.js +3 -39
  151. package/dist/core/runner/run-harness-handlers.js +4 -17
  152. package/dist/core/runner/run-identity-wiring.js +4 -1
  153. package/dist/core/runner/run-leg.js +11 -1
  154. package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
  155. package/dist/core/runner/run-recovery-lanes.js +34 -18
  156. package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
  157. package/dist/core/runner/run-settle-and-teardown.js +14 -22
  158. package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
  159. package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
  160. package/dist/core/runner/run-terminal-adoption.js +5 -88
  161. package/dist/core/runner/run-tool-mount-facts.js +1 -5
  162. package/dist/core/runner/run-turn-boundary.js +56 -26
  163. package/dist/core/runner/runtask.js +7 -7
  164. package/dist/core/runner/session-hash-salt.d.ts +18 -0
  165. package/dist/core/runner/session-hash-salt.js +36 -0
  166. package/dist/core/runner/shell-env-withheld.d.ts +8 -5
  167. package/dist/core/runner/shell-env-withheld.js +3 -3
  168. package/dist/core/runner/side-call-account.d.ts +9 -1
  169. package/dist/core/runner/side-call-account.js +15 -4
  170. package/dist/core/runner/skill-mention.d.ts +12 -0
  171. package/dist/core/runner/skill-mention.js +50 -0
  172. package/dist/core/runner/stream-settle-backstop.js +1 -0
  173. package/dist/core/runner/synthetic-tools.js +2 -2
  174. package/dist/core/runner/tool-table-view.d.ts +5 -9
  175. package/dist/core/runner/tool-table-view.js +23 -21
  176. package/dist/core/runner/write-protection-station.d.ts +5 -2
  177. package/dist/core/runner/write-protection-station.js +1 -1
  178. package/dist/core/runner-deps.d.ts +25 -27
  179. package/dist/core/scheduler.d.ts +13 -3
  180. package/dist/core/scheduler.js +0 -12
  181. package/dist/core/secret-env.d.ts +47 -11
  182. package/dist/core/secret-env.js +65 -4
  183. package/dist/core/sensitive-path-policy.js +4 -0
  184. package/dist/core/session-checkout.js +10 -9
  185. package/dist/core/shell-read-silence.d.ts +2 -1
  186. package/dist/core/shell-run-candidates.d.ts +1 -1
  187. package/dist/core/shell-run-candidates.js +11 -3
  188. package/dist/core/task-event.d.ts +32 -10
  189. package/dist/core/task-intake.d.ts +5 -3
  190. package/dist/core/task-intake.js +6 -2
  191. package/dist/core/task-result.d.ts +39 -0
  192. package/dist/core/task-spec-members.d.ts +3 -0
  193. package/dist/core/task-spec-members.js +2 -2
  194. package/dist/core/task-spec.d.ts +37 -20
  195. package/dist/core/tool-policy.d.ts +30 -18
  196. package/dist/core/tool-policy.js +44 -32
  197. package/dist/core/tool-roster.d.ts +21 -7
  198. package/dist/core/tool-roster.js +34 -6
  199. package/dist/core/tool-spec-members.js +1 -1
  200. package/dist/core/tool-spec.d.ts +27 -0
  201. package/dist/core/tools.js +1 -0
  202. package/dist/core/trace.d.ts +42 -19
  203. package/dist/core/unc-spelling.d.ts +31 -0
  204. package/dist/core/unc-spelling.js +51 -0
  205. package/dist/core/wiring-manifest.d.ts +30 -3
  206. package/dist/core/wiring-manifest.js +10 -0
  207. package/dist/core/workflow-run-store-contract.js +22 -0
  208. package/dist/core/workflow-run-store.d.ts +17 -13
  209. package/dist/core/workflow-run-store.js +1 -1
  210. package/dist/core/write-protect.d.ts +4 -0
  211. package/dist/core/write-protect.js +17 -15
  212. package/dist/engine/compaction/compaction.d.ts +48 -98
  213. package/dist/engine/compaction/compaction.js +136 -216
  214. package/dist/engine/compaction/utils.d.ts +2 -11
  215. package/dist/engine/compaction/utils.js +4 -13
  216. package/dist/engine/execution-env/node-execution-env.js +17 -6
  217. package/dist/engine/harness/agent-harness.d.ts +19 -5
  218. package/dist/engine/harness/agent-harness.js +18 -7
  219. package/dist/engine/harness/types.d.ts +5 -7
  220. package/dist/engine/loop/agent-loop.d.ts +14 -1
  221. package/dist/engine/loop/agent-loop.js +31 -11
  222. package/dist/engine/loop/types.d.ts +8 -2
  223. package/dist/index.d.ts +9 -6
  224. package/dist/index.js +8 -6
  225. package/dist/internal/harness-types.d.ts +1 -1
  226. package/dist/internal/harness.d.ts +1 -1
  227. package/dist/internal/harness.js +1 -1
  228. package/dist/orchestration/run-spec.js +7 -2
  229. package/dist/orchestration/run-workflow-tool.js +5 -3
  230. package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
  231. package/dist/orchestration/workflow-park-adoption.js +195 -45
  232. package/dist/orchestration/workflow-types.d.ts +20 -0
  233. package/dist/orchestration/workflow-types.js +1 -0
  234. package/dist/orchestration/workflow.d.ts +3 -2
  235. package/dist/orchestration/workflow.js +10 -4
  236. package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
  237. package/dist/prompt-assembly/catalog/events.d.ts +8 -0
  238. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
  239. package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
  240. package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
  241. package/dist/prompt-assembly/catalog/mechanism.js +1 -0
  242. package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
  243. package/dist/prompt-assembly/catalog/schema.js +1 -0
  244. package/dist/prompt-assembly/catalog/sections.js +8 -0
  245. package/dist/prompt-assembly/event-registry.js +1 -0
  246. package/dist/prompt-assembly/select.js +1 -0
  247. package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
  248. package/dist/prompt-assembly/turn-snapshot.js +6 -18
  249. package/dist/prompt-assembly/types.d.ts +3 -0
  250. package/dist/prompts/default.d.ts +9 -0
  251. package/dist/prompts/default.js +4 -0
  252. package/dist/shell/lex.d.ts +75 -11
  253. package/dist/shell/lex.js +340 -76
  254. package/dist/tools/fs/bash-program-position.js +2 -6
  255. package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
  256. package/dist/tools/fs/bash-readonly-classifier.js +19 -9
  257. package/dist/tools/fs/containment-face.d.ts +12 -3
  258. package/dist/tools/fs/containment-face.js +16 -7
  259. package/dist/tools/fs/file-read-check.d.ts +26 -1
  260. package/dist/tools/fs/file-read-check.js +20 -2
  261. package/dist/tools/fs/fs-bash.js +4 -4
  262. package/dist/tools/fs/fs-read.d.ts +3 -0
  263. package/dist/tools/fs/fs-read.js +2 -2
  264. package/dist/tools/fs/fs-search-tools.d.ts +2 -2
  265. package/dist/tools/fs/fs-search-tools.js +4 -4
  266. package/dist/tools/fs/index.js +5 -3
  267. package/dist/tools/fs/pdf.js +12 -4
  268. package/dist/tools/fs/read-deny-home.d.ts +13 -2
  269. package/dist/tools/fs/read-deny-home.js +26 -22
  270. package/dist/tools/fs/read-deny.js +15 -6
  271. package/dist/tools/fs/removal-targets.d.ts +33 -17
  272. package/dist/tools/fs/removal-targets.js +160 -61
  273. package/dist/tools/fs/repo-map.d.ts +1 -1
  274. package/dist/tools/fs/repo-map.js +2 -2
  275. package/dist/tools/fs/safety.d.ts +28 -5
  276. package/dist/tools/fs/safety.js +72 -8
  277. package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
  278. package/dist/tools/fs/shell-read-bindings.js +25 -6
  279. package/dist/tools/fs/shell-read-check.d.ts +3 -0
  280. package/dist/tools/fs/shell-read-check.js +22 -4
  281. package/dist/tools/fs/shell-read-establish.js +73 -43
  282. package/dist/tools/fs/shell-read-judge.d.ts +32 -14
  283. package/dist/tools/fs/shell-read-judge.js +13 -5
  284. package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
  285. package/dist/tools/fs/shell-read-object-path.js +17 -4
  286. package/dist/tools/fs/shell-read-plan.d.ts +8 -2
  287. package/dist/tools/fs/shell-read-plan.js +36 -22
  288. package/dist/tools/fs/shell-read-sourced.js +12 -4
  289. package/dist/tools/fs/shell-read-start.d.ts +4 -2
  290. package/dist/tools/fs/shell-read-start.js +3 -3
  291. package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
  292. package/dist/tools/fs/shell-read-workdir.js +35 -17
  293. package/dist/tools/scheduler-tools.d.ts +7 -17
  294. package/dist/tools/scheduler-tools.js +9 -85
  295. package/dist/tools/worktree.js +5 -4
  296. package/package.json +3 -2
  297. package/test/export-surface.snapshot.json +47 -1
  298. package/wire-changes/core-stores-sql@7.68.6.json +39 -0
  299. package/wire-changes/core-stores-sql@7.69.1.json +39 -0
  300. package/wire-changes/core@7.68.6.json +125 -0
  301. package/wire-changes/core@7.69.1.json +2561 -0
  302. package/wire-changes/mods-kernel@7.68.6.json +39 -0
  303. package/wire-changes/mods-kernel@7.69.1.json +39 -0
  304. package/wire-changes/primitives@7.68.6.json +39 -0
  305. package/wire-changes/primitives@7.69.1.json +39 -0
  306. package/wire-changes/wiki-gate@7.68.6.json +39 -0
  307. package/wire-changes/wiki-gate@7.69.1.json +39 -0
  308. package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
  309. package/dist/core/runner/prompt-hash-salt.js +0 -2
@@ -1010,9 +1010,15 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1010
1010
  return;
1011
1011
  const records = [chain.root, ...chain.successors.filter((r) => r.id !== runId)];
1012
1012
  const entryOf = (key) => chain.root.parks?.find((p) => p.token === key.token && p.parkedBy === from);
1013
+ const stand = (key) => {
1014
+ key.parkedBy = runId;
1015
+ const settled = entryOf(key)?.settledDecisions;
1016
+ if (settled !== undefined)
1017
+ key.settledDecisions = settled;
1018
+ };
1013
1019
  for (const key of open)
1014
1020
  if (entryOf(key)?.passedTo === runId)
1015
- key.parkedBy = runId;
1021
+ stand(key);
1016
1022
  open = open.filter((key) => {
1017
1023
  const entry = entryOf(key);
1018
1024
  if (entry === undefined || entry.passedTo !== undefined)
@@ -1029,7 +1035,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1029
1035
  const won = await storeWithin(Promise.resolve().then(() => store.update(from, scope, next, { rev: chain.root.rev ?? 0 }, { cause: "park_pass" })));
1030
1036
  if (won.ok && won.value) {
1031
1037
  for (const key of open)
1032
- key.parkedBy = runId;
1038
+ stand(key);
1033
1039
  return;
1034
1040
  }
1035
1041
  }
@@ -1501,7 +1507,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1501
1507
  const parks = run.parks ?? (run.parks = []);
1502
1508
  const at = parks.findIndex((e) => e.callKey === rec.callKey);
1503
1509
  const held = at === -1 ? undefined : parks[at];
1504
- const holder = { parkedBy: runId, generation: held?.generation ?? 0 };
1510
+ const holder = { parkedBy: runId, generation: held?.generation ?? 0, ...(held?.token === paused.terminal.token && held.settledDecisions !== undefined ? { settledDecisions: held.settledDecisions } : {}) };
1505
1511
  const key = held !== undefined && held.token === paused.terminal.token && held.originUnconfirmed !== true
1506
1512
  ? { callKey: rec.callKey, sessionId: paused.sessionId, token: paused.terminal.token, originRunId: held.originRunId, ...holder }
1507
1513
  : { callKey: rec.callKey, sessionId: paused.sessionId, token: paused.terminal.token, originRunId: runId, originUnconfirmed: true, ...holder };
@@ -2990,7 +2996,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
2990
2996
  if (e === null || typeof e !== "object" || holder === undefined || typeof e.callKey !== "string" || typeof e.sessionId !== "string" || typeof e.token !== "string" || typeof e.originRunId !== "string" || !/^\d+:/.test(e.callKey)) {
2991
2997
  throw parkBindingBroken(-1, "a recorded park entry is malformed or its call key has no ordinal");
2992
2998
  }
2993
- offerCandidate(callKeyOrdinal(e.callKey), { callKey: e.callKey, sessionId: e.sessionId, token: e.token, originRunId: e.originRunId, ...(e.originUnconfirmed === true ? { originUnconfirmed: true } : {}), ...holder });
2999
+ offerCandidate(callKeyOrdinal(e.callKey), { callKey: e.callKey, sessionId: e.sessionId, token: e.token, originRunId: e.originRunId, ...(e.originUnconfirmed === true ? { originUnconfirmed: true } : {}), ...holder, ...(Array.isArray(e.settledDecisions) ? { settledDecisions: e.settledDecisions } : {}) });
2994
3000
  }
2995
3001
  for (const [ord, e] of replayByOrdinal.entries()) {
2996
3002
  if (e?.parked === undefined)
@@ -64,6 +64,7 @@ Don't overindex on soft feedback - give it the appropriate weight based on the c
64
64
  Same for your notes - if they contain some caution or limitation, question whether the reason still holds and drop it if not. This isn't a reason to take risky, irreversible, destructive actions without confirmation though, and an old or general go-ahead doesn't count as confirmation, so if the caution is about these kinds of actions then keep it until a human gives confirmation (even if you wrote it yourself).
65
65
 
66
66
  Don't create planning, decision, or analysis documents unless the user asks for them — work from the context, not intermediate files.`;
67
+ const SKILL_INVOCATION = "When the user types `/<skill-name>`, invoke it via Skill. Only use skills listed in the skills listing — don't guess.";
67
68
  const FABLE_CLASSIC_FINAL_MESSAGE = "Your final message of a turn is the only text the caller is guaranteed to read. Put every conclusion, answer, and deliverable in it — lead with the outcome, then supporting detail. Never leave a result only in an intermediate message or in your reasoning.";
68
69
  const FABLE_CLASSIC_AUTONOMY = "When operating autonomously: before ending your turn, check that the task is actually complete (not just planned); before any state-changing action, re-verify that the evidence supports that specific action rather than pattern-matching a familiar case.";
69
70
  const FABLE_CLASSIC_TOOL_JSON = "When calling tools, provide exactly ONE complete JSON value per parameter — never concatenate multiple values, never truncate, never wrap a value in commentary.";
@@ -116,6 +117,11 @@ export const CORE_BEHAVIOR_MESSAGES = [
116
117
  attribution: { form: "verbatim", cc: ["cli321.js B[21169568,21171288) `MNr`", "cli321.js B[21200100,21200182) `hasMemoryGuidance`"] },
117
118
  securityBearing: true,
118
119
  },
120
+ {
121
+ id: "core/simple.skill-invocation",
122
+ variants: [{ id: "default", when: { host: STANDARD }, text: SKILL_INVOCATION }],
123
+ attribution: { form: "adapted", cc: ['cli321.js:287153 "invoke it via"'] },
124
+ },
119
125
  { id: "core/sema.verify-fresh", variants: [{ id: "lean", when: LEAN, text: VERIFY_FRESH }], attribution: { form: "sema-owned" } },
120
126
  { id: "core/sema.evidence-audit", variants: [{ id: "lean", when: LEAN, text: EVIDENCE_AUDIT }], attribution: { form: "sema-owned" }, securityBearing: true },
121
127
  { id: "core/behavior.fable-classic.final-message", variants: [{ id: "classic-fable", when: CLASSIC_FABLE, text: FABLE_CLASSIC_FINAL_MESSAGE }], attribution: { form: "adapted" } },
@@ -792,6 +792,14 @@ export declare const EVENT_MESSAGES: readonly [{
792
792
  readonly text: string;
793
793
  }];
794
794
  attribution: Attribution;
795
+ }, {
796
+ id: "core/event.skill-mention";
797
+ variants: readonly [{
798
+ readonly id: "default";
799
+ readonly when: {};
800
+ readonly text: string;
801
+ }];
802
+ attribution: Attribution;
795
803
  }, {
796
804
  id: "core/event.workflow-continuation.started";
797
805
  variants: readonly [{
@@ -121,6 +121,12 @@ ${COMMUNICATING_TAIL}`,
121
121
  在运行会改变系统状态的命令(比如重启、删除或修改配置)之前,先核实证据确实支持这个具体操作。一个看起来像已知故障的信号,可能另有原因。`,
122
122
  },
123
123
  },
124
+ "core/simple.skill-invocation": {
125
+ default: {
126
+ sourceDigest: "sha256:59d9d979d6f742fb9c79d0101a9d5811debc5da55e432b622f566bf534adb94f",
127
+ text: "当用户输入 `/<skill-name>` 时,用 Skill 工具调用它。只使用技能清单里列出的技能——不要猜。",
128
+ },
129
+ },
124
130
  "core/sema.verify-fresh": {
125
131
  lean: {
126
132
  sourceDigest: "sha256:793fc618e224f81693321aa40ab81fe69fae43752d8184d7626af2d9aee80ca8",
@@ -46,6 +46,7 @@ export const ZH_HANS_MECHANISM = {
46
46
  "core/event.orphaned-background-tasks.no-description": row("sha256:d632e251e13956f762ef83e9b96e22b2704e3efdee30fb1990574c8b412803af", "(无描述)"),
47
47
  "core/event.language": row("sha256:b211365f0291aba8ef44879815558bf96c37e5be0707f35ee22dbbe624c5233b", '# 语言\n始终用 {{language}} 回复。所有解释、注释以及与用户的交流都使用 {{language}}。技术术语和代码标识符保持原样。\n使用 {{language}} 时保持完全正确的书写,包括所有必需的变音符号、重音符号和特殊字符。绝不要用 ASCII 字符替代带重音的字符(例如,绝不要把 "não" 写成 "nao",把 "für" 写成 "fur",或把 "löschen" 写成 "loeschen")。'),
48
48
  "core/event.language.cleared": row("sha256:2bfbac2bf91bc7e6ad72812a24996e8e3a6e096195450d009023b4601022620e", "语言偏好已被清除。与用户使用相同的语言。"),
49
+ "core/event.skill-mention": row("sha256:7b9cb2fe0e39ff62771fb6754289e6d994d667dbed6945eb20a401ed5459d125", '用户的消息里有 /{{name}},这是一个技能的名称。如果用户是要你运行它,就调用 {{tool}} 工具,传入 skill: "{{name}}",并把用户给的参数放进 args。如果用户只是提到它,不要运行。'),
49
50
  "core/event.workflow-continuation.started": row("sha256:70a34fd39678d419a79a120410580f266a7b986c06584f7c89e561b3d8d3f3e1", '工作流运行 "{{run}}" 停在一张审批卡上;引擎已拿到部署交来的决定,从停下的那一步接着跑,新运行是 "{{as}}"。是否接着跑了,看运行 "{{as}}" 的完成通知。不要为它调用 {{tool}}。'),
50
51
  "core/event.workflow-continuation.started-denied": row("sha256:863ed43d39966fa5059681f54ed2dc5ff2a76a553405857c7f956bb74c682724", '工作流运行 "{{run}}" 停在一张审批卡上;引擎已拿到部署交来的决定,从停下的那一步接着跑,新运行是 "{{as}}"。是否接着跑了,看运行 "{{as}}" 的完成通知。这条决定拒绝了那一步:只拒这一步,工作流其余步骤照常往下走;要停掉整个运行,就取消它。不要为它调用 {{tool}}。'),
51
52
  "core/event.workflow-continuation.ask": row("sha256:e12545a207fa762f119761960a66d8460b2b3670fc3c1548d9b98a38cbd1cd33", '工作流运行 "{{run}}" 的审批决定这次没有用上:{{sentence}}。要申请这项审批,用同一份脚本加 resumeFromRunId: "{{run}}" 调用 {{tool}}——这次调用一获批准,就会带着这条决定把运行接着跑下去。'),
@@ -368,6 +368,14 @@ export declare const MECHANISM_EVENT_MESSAGES: readonly [{
368
368
  readonly text: string;
369
369
  }];
370
370
  attribution: Attribution;
371
+ }, {
372
+ id: "core/event.skill-mention";
373
+ variants: readonly [{
374
+ readonly id: "default";
375
+ readonly when: {};
376
+ readonly text: string;
377
+ }];
378
+ attribution: Attribution;
371
379
  }, {
372
380
  id: "core/event.workflow-continuation.started";
373
381
  variants: readonly [{
@@ -52,6 +52,7 @@ export const MECHANISM_EVENT_MESSAGES = Object.freeze([
52
52
  mechanism("core/event.orphaned-background-tasks.no-description", "(no description)", cc("verbatim", `cli316.js B[17270700,17271700) "(no description)"`)),
53
53
  mechanism("core/event.language", '# Language\nAlways respond in {{language}}. Use {{language}} for all explanations, comments, and communications with the user. Technical terms and code identifiers should remain in their original form.\nMaintain full orthographic correctness for {{language}}, including all required diacritical marks, accents, and special characters. Never substitute accented characters with their ASCII equivalents (e.g., never write "nao" for "não", "fur" for "für", or "loeschen" for "löschen").', cc("verbatim", `cli321.js:284845-284847 "# Language"`)),
54
54
  mechanism("core/event.language.cleared", "The language preference was cleared. Match the user's language.", cc("verbatim", `cli321.js:284845 "The language preference was cleared"`)),
55
+ mechanism("core/event.skill-mention", 'The user\'s message contains /{{name}}, which is the name of a skill. If they are asking you to run it, call the {{tool}} tool with skill: "{{name}}", passing any arguments they gave as args. If they only mention it, do not run it.', cc("verbatim", `cli321.js:288917 "which is the name of a skill"`)),
55
56
  mechanism("core/event.workflow-continuation.started", 'Workflow run "{{run}}" was stopped on an approval; the decision the deployment handed over was given to the engine, which continues it as run "{{as}}" from the parked step — whether it continued is told by run "{{as}}"\'s completion notification. Do not call {{tool}} for it.', SEMA),
56
57
  mechanism("core/event.workflow-continuation.started-denied", 'Workflow run "{{run}}" was stopped on an approval; the decision the deployment handed over was given to the engine, which continues it as run "{{as}}" from the parked step — whether it continued is told by run "{{as}}"\'s completion notification. The decision refuses that step: only that step is refused, and the rest of the workflow goes on past it — to stop the whole run, cancel it. Do not call {{tool}} for it.', SEMA),
57
58
  mechanism("core/event.workflow-continuation.ask", 'The approval decision for workflow run "{{run}}" was not applied this time: {{sentence}}. To ask for that approval, call {{tool}} with the same script and resumeFromRunId: "{{run}}" — once that call is approved, it continues the run with the decision.', SEMA),
@@ -98,7 +98,7 @@ export declare function bundleMembersOf(name: PromptTraitName): readonly PromptT
98
98
  * `executionEnvironmentDeclared` from two of them, `workToolsAbsent` (the face leaves nothing for the work: no tool to act
99
99
  * through and none to hand the result out through) and `actingToolsAbsent` (no tool to act through) from the tool-face class.
100
100
  * An optional fact that is absent reads as `false`. */
101
- export declare const PROMPT_FACT_NAMES: readonly ["policyEnabled", "hooksEnabled", "isolationEnabled", "readFaceOpen", "writeFaceOpen", "withinTaskCompactionEnabled", "supervisorEnabled", "orchestrationEnabled", "orchestrationDeferred", "awarenessEnabled", "goalEnabled", "worktreeIsolated", "teammateEnabled", "isSubagent", "memoryStoreAbsent", "executionEnvironmentDeclared", "workToolsAbsent", "actingToolsAbsent"];
101
+ export declare const PROMPT_FACT_NAMES: readonly ["policyEnabled", "hooksEnabled", "isolationEnabled", "readFaceOpen", "writeFaceOpen", "withinTaskCompactionEnabled", "supervisorEnabled", "orchestrationEnabled", "orchestrationDeferred", "awarenessEnabled", "goalEnabled", "worktreeIsolated", "teammateEnabled", "isSubagent", "memoryStoreAbsent", "skillToolMounted", "executionEnvironmentDeclared", "workToolsAbsent", "actingToolsAbsent"];
102
102
  export type PromptFactName = (typeof PROMPT_FACT_NAMES)[number];
103
103
  /** A conjunction of fact equalities — the whole predicate language. No disjunction, no expressions. */
104
104
  export type FactConjunction = Readonly<Partial<Record<PromptFactName, boolean>>>;
@@ -63,6 +63,7 @@ export const PROMPT_FACT_NAMES = Object.freeze([
63
63
  "teammateEnabled",
64
64
  "isSubagent",
65
65
  "memoryStoreAbsent",
66
+ "skillToolMounted",
66
67
  "executionEnvironmentDeclared",
67
68
  "workToolsAbsent",
68
69
  "actingToolsAbsent",
@@ -46,6 +46,14 @@ export const SECTIONS = [
46
46
  { id: "core/model.fable-identity", band: "constitution", rank: 255, block: HARNESS, body: { message: "core/model.fable-identity" } },
47
47
  { id: "core/model.llm-rnd-capabilities", band: "constitution", rank: 256, block: HARNESS, body: { message: "core/model.llm-rnd-capabilities" } },
48
48
  { id: "core/simple.tool-param-json", band: "core-behavior", rank: 258, block: HARNESS, admit: CALLING, body: { message: "core/simple.tool-param-json" } },
49
+ {
50
+ id: "core/simple.skill-invocation",
51
+ band: "core-behavior",
52
+ rank: 260,
53
+ block: HARNESS,
54
+ admit: { skillToolMounted: true, isSubagent: false },
55
+ body: { message: "core/simple.skill-invocation" },
56
+ },
49
57
  {
50
58
  id: "core/simple.context-management",
51
59
  band: "constitution",
@@ -114,6 +114,7 @@ const ROWS = [
114
114
  { kind: "final_verification", defaultPolicy: "always", messages: ["core/event.final-verification", "core/event.final-verification.reentry"] },
115
115
  { kind: "advisor_tool", defaultPolicy: "always", messages: ["core/event.advisor-tool", "core/event.advisor-tool.abbreviated", "core/event.advisor-tool.removed"] },
116
116
  { kind: "language", defaultPolicy: "always", messages: ["core/event.language", "core/event.language.cleared"] },
117
+ { kind: "skill_mention", defaultPolicy: "always", dedupe: "replace-by-key", maxBytes: 2048, messages: ["core/event.skill-mention"] },
117
118
  { kind: "orphaned_background_tasks", defaultPolicy: "always", messages: ["core/event.orphaned-background-tasks", "core/event.orphaned-background-tasks.line", "core/event.orphaned-background-tasks.no-description"] },
118
119
  {
119
120
  kind: "workflow_continuation",
@@ -54,6 +54,7 @@ export function catalogFactsOf(facts) {
54
54
  teammateEnabled: facts.teammateEnabled,
55
55
  isSubagent: facts.isSubagent === true,
56
56
  memoryStoreAbsent: facts.memoryStoreAbsent === true,
57
+ skillToolMounted: facts.skillToolMounted === true,
57
58
  executionEnvironmentDeclared: facts.policyEnabled || facts.isolationEnabled,
58
59
  workToolsAbsent: facts.toolFace === "none",
59
60
  actingToolsAbsent: facts.toolFace === "none" || facts.toolFace === "finishing",
@@ -1,4 +1,4 @@
1
- import type { PrefixChangeCause, PrefixChangeDeclaration, ToolFingerprintInput } from "../core/cache-break-detector.js";
1
+ import type { PrefixChangeDeclaration, ToolFingerprintInput } from "../core/cache-break-detector.js";
2
2
  /** Every prefix-shaping input a request carries — the CLASSIFICATION DOMAIN. Adding a field here
3
3
  * without classifying it in {@link PREFIX_INPUT_CLASSIFICATION} is a compile error. */
4
4
  export interface RawPrefixInputs {
@@ -14,12 +14,12 @@ export interface RawPrefixInputs {
14
14
  groupId: string;
15
15
  cacheControlBoundary: boolean;
16
16
  }>;
17
- /** The composed stable system text (digested — text never enters the snapshot object).
18
- * UNSALTED by design, same rule as the tool wireSchemaDigest ("schemas are code"): a full-text
19
- * sha of a LONG composed prompt is an equality oracle only for someone who already possesses the
20
- * exact bytes — unlike the SHORT guessable manifest blocks (env facts, one-line memory) whose
21
- * dictionary-preimage risk is why block hashes are salted. Cross-run comparability is the whole
22
- * point of this identity; salting would destroy it. */
17
+ /** The composed stable system text (digested — text never enters the snapshot object) by the
18
+ * `promptHasher` {@link buildTurnPromptSnapshot} is handed: the run loop hands one keyed with the
19
+ * session's hash salt (a fixed public prefix + a short guessable suffix — an env fact, a memory
20
+ * line — would make an unsalted full-text sha enumerable), so the digest compares across the
21
+ * session's runs and processes while the salt is stored (a leg-only salt, the store could not keep
22
+ * it, compares within the leg), never across unrelated sessions; with no hasher, the content sha. */
23
23
  stableSystemText: string;
24
24
  /** Wire-face tool projections (name/description/schema — the mounted set, post-defer). */
25
25
  toolWire: ReadonlyArray<ToolFingerprintInput>;
@@ -79,16 +79,6 @@ export interface CacheIdentityElements {
79
79
  }
80
80
  /** Which writer moved the tool table: a deferred activation, a roster refresh, or the per-request view. */
81
81
  export type ToolTableSource = "activation" | "roster" | "view";
82
- /** One identity move as the trace reports it: the declared word and, where known, where it sits. */
83
- export interface PrefixChangeNote {
84
- cause: PrefixChangeCause;
85
- /** `tool_table` only. */
86
- source?: ToolTableSource;
87
- /** `leg_start_inputs` only: the head segments that differ from the session's anchor (block ids, `tools`). */
88
- segments?: string[];
89
- /** `tool_table` only: the first tool position whose wire face differs. */
90
- firstChangedIndex?: number;
91
- }
92
82
  /** The leg's prefix identity AND its declaration seat: each in-leg change to the head is declared once, by the seat that
93
83
  * makes it, through the refresher of the element it moves (the word fixed by the refresher) or {@link TurnPromptSnapshot.declare}. */
94
84
  export interface TurnPromptSnapshot {
@@ -96,14 +86,9 @@ export interface TurnPromptSnapshot {
96
86
  /** sha256(canonical(elements)) — the ONE eight-element identity value. */
97
87
  cacheIdentity: string;
98
88
  lowering: LoweringRecord;
99
- /** invoked after every refresh that MOVED the identity, with the declared word, so the run loop can emit the
100
- * changed identity (`prompt.snapshot_changed` trace); traces must never keep claiming a superseded prefix. */
101
- onChange?: (snapshot: TurnPromptSnapshot, change: PrefixChangeNote) => void;
102
- /** invoked with every declaration (an identity move, or {@link TurnPromptSnapshot.declare}); the leg's detector reads it. */
89
+ /** invoked with every declaration (an identity move — after the refresh applied, so the snapshot never reads a mixed
90
+ * state — or {@link TurnPromptSnapshot.declare}); the session's prefix ledger reads it. */
103
91
  onDeclared?: (declaration: PrefixChangeDeclaration) => void;
104
- /** The leg-start opening prepare found against the session's anchor (absent when the head is the anchored one,
105
- * or the session holds no anchor for this segment); the run loop reports it once, beside `prompt.assembled`. */
106
- legStart?: PrefixChangeNote;
107
92
  /** The tool table's wire digest as MOUNTED (moved by `activation` / `roster`, not the per-request `view`): the anchor
108
93
  * compares legs in it, since prepare sees the table before any request's view re-applies the same hiding. */
109
94
  readonly mountedToolWireDigest: string;
@@ -132,9 +117,11 @@ export interface TurnPromptSnapshot {
132
117
  * reach the digest — enforced structurally (this function reads exactly the identity fields).
133
118
  *
134
119
  * `promptHasher`: the digest applied to COMPOSED PROMPT TEXT — callers inject a
135
- * KEYED/salted hasher (the run loop uses the per-process manifest salt): a fixed public prefix +
120
+ * KEYED/salted hasher (the run loop uses the session's hash salt): a fixed public prefix +
136
121
  * short unknown suffix (an env fact, a memory note, a tenant string) makes an unsalted full-text
137
122
  * sha ENUMERABLE, recreating exactly the disclosure the salted block hashes prevent. Consequence,
138
- * documented: `stableSystemDigest` (and thus `cacheIdentity`) compares within one process only;
139
- * cross-process reconciliation rides the CODE-class digests (artifact/toolWire — unsalted). */
123
+ * documented: `stableSystemDigest` (and thus `cacheIdentity`) compares within one session (across its
124
+ * runs and engine processes) and between a fork and its source when the fork's active branch holds the source's salt
125
+ * entry, never across unrelated sessions; with no `promptHasher` it is the unsalted content sha (comparable anywhere);
126
+ * the CODE-class digests (artifact/toolWire) are unsalted. */
140
127
  export declare function buildTurnPromptSnapshot(raw: Omit<RawPrefixInputs, "turn" | "cacheRead">, api: string, promptHasher?: (text: string) => string): TurnPromptSnapshot;
@@ -53,7 +53,6 @@ export function buildTurnPromptSnapshot(raw, api, promptHasher) {
53
53
  ...(raw.cacheRetention !== undefined ? { cacheRetention: raw.cacheRetention } : {}),
54
54
  };
55
55
  const toolFace = (t) => ({ name: t.name, description: t.description, parameters: t.parameters });
56
- let toolFaces = raw.toolWire.map((t) => canonical(toolFace(t)));
57
56
  const elements = {
58
57
  provider: raw.provider,
59
58
  modelId: raw.modelId,
@@ -64,13 +63,12 @@ export function buildTurnPromptSnapshot(raw, api, promptHasher) {
64
63
  requestPolicyDigest: textContentHashOf(canonical(requestPolicy)),
65
64
  loweringVersion: `${lowering.version}/${lowering.form}/${api}`,
66
65
  };
67
- const bump = (change) => {
66
+ const bump = (cause) => {
68
67
  const next = identityOf(elements);
69
68
  if (next === snapshot.cacheIdentity)
70
69
  return;
71
70
  snapshot.cacheIdentity = next;
72
- snapshot.onDeclared?.({ cause: change.cause });
73
- snapshot.onChange?.(snapshot, change);
71
+ snapshot.onDeclared?.({ cause });
74
72
  };
75
73
  let mounted = elements.toolWireDigest;
76
74
  const snapshot = {
@@ -81,26 +79,16 @@ export function buildTurnPromptSnapshot(raw, api, promptHasher) {
81
79
  return mounted;
82
80
  },
83
81
  refreshTools(toolWire, source) {
84
- const faces = toolWire.map((t) => canonical(toolFace(t)));
85
- const n = Math.min(faces.length, toolFaces.length);
86
- let first = faces.length === toolFaces.length ? -1 : n;
87
- for (let i = 0; i < n; i++) {
88
- if (faces[i] !== toolFaces[i]) {
89
- first = i;
90
- break;
91
- }
92
- }
93
- toolFaces = faces;
94
82
  elements.toolWireDigest = textContentHashOf(canonical(toolWire.map(toolFace)));
95
83
  if (source !== "view")
96
84
  mounted = elements.toolWireDigest;
97
- bump({ cause: "tool_table", source, ...(first >= 0 ? { firstChangedIndex: first } : {}) });
85
+ bump("tool_table");
98
86
  },
99
87
  refreshStableSystem(stableSystemText, artifactDigest) {
100
88
  elements.stableSystemDigest = promptSha(stableSystemText);
101
89
  if (artifactDigest !== undefined)
102
90
  elements.artifactDigest = artifactDigest;
103
- bump({ cause: "compaction" });
91
+ bump("compaction");
104
92
  },
105
93
  refreshRequestPolicy(p) {
106
94
  const retention = p.cacheRetention === undefined ? requestPolicy.cacheRetention : (p.cacheRetention ?? undefined);
@@ -112,12 +100,12 @@ export function buildTurnPromptSnapshot(raw, api, promptHasher) {
112
100
  ...((p.fastSpeed !== undefined ? p.fastSpeed : requestPolicy.fastSpeed === true) ? { fastSpeed: true } : {}),
113
101
  };
114
102
  elements.requestPolicyDigest = textContentHashOf(canonical(requestPolicy));
115
- bump({ cause: "request_policy" });
103
+ bump("request_policy");
116
104
  },
117
105
  refreshModel(m) {
118
106
  elements.provider = m.provider;
119
107
  elements.modelId = m.modelId;
120
- bump({ cause: "model_namespace" });
108
+ bump("model_namespace");
121
109
  },
122
110
  declare(declaration) {
123
111
  snapshot.onDeclared?.(declaration);
@@ -39,6 +39,9 @@ export interface PromptRuntimeFacts {
39
39
  /** The run has no memory store and no channel to persist through, and holds the user's conversation: the memory
40
40
  * renderer leads with the no-persistent-store sentence. OPTIONAL — absence reads as false. */
41
41
  memoryStoreAbsent?: boolean;
42
+ /** The `Skill` tool is on this leg's mounted roster (it mounts only with a non-empty skill set the valve leaves it for, so the
43
+ * skills listing is announced too): admits the skill-invocation sentence. OPTIONAL — absence reads as false. */
44
+ skillToolMounted?: boolean;
42
45
  /** What the tool valve left the model on this leg (`toolFaceClassOf`): the catalog reads it as `workToolsAbsent` /
43
46
  * `actingToolsAbsent`. OPTIONAL — absence reads as `acting` (the text every leg with a tool to act through receives). */
44
47
  toolFace?: import("../core/tool-face.js").ToolFaceClass;
@@ -186,6 +186,15 @@ export declare function formatLocalDate(now: Date, timeZone?: string): string;
186
186
  * validity so `buildEnvironmentContext` annotates `(UTC)` rather than the bogus zone.
187
187
  */
188
188
  export declare function isValidTimeZone(tz: string): boolean;
189
+ /**
190
+ * The user's time zone as the engine judges it for one run: the client-supplied `clientContext.timeZone` when
191
+ * {@link isValidTimeZone} accepts it, else `undefined`. The one reading both consumers take: the environment block dates
192
+ * "today" in it (and annotates `(UTC)` when it is absent), and the scheduler context carries it as the zone a cron
193
+ * intent is read in — so the date the model is shown and the clock its schedules fire on cannot be two zones.
194
+ */
195
+ export declare function judgedUserTimeZone(clientContext: {
196
+ readonly timeZone?: string;
197
+ } | undefined): string | undefined;
189
198
  /**
190
199
  * The `# Environment` block (design/64 §20 — CC `computeSimpleEnvInfo`): situational facts (date, model
191
200
  * identity, cwd, git, platform, OS) so the agent reasons about time, shell syntax, paths, and git correctly.
@@ -63,6 +63,10 @@ export function isValidTimeZone(tz) {
63
63
  return false;
64
64
  }
65
65
  }
66
+ export function judgedUserTimeZone(clientContext) {
67
+ const tz = clientContext?.timeZone;
68
+ return tz !== undefined && isValidTimeZone(tz) ? tz : undefined;
69
+ }
66
70
  export function buildEnvironmentContext(given, text = engineTextFor()) {
67
71
  const { ...facts } = given;
68
72
  const lines = [];
@@ -45,14 +45,22 @@ export declare const PARSE_FAILURE_SENTENCE: {
45
45
  readonly heredoc_without_delimiter: "a here-document operator names no delimiter";
46
46
  readonly heredoc_delimiter_expands: "a here-document delimiter is not a plain word";
47
47
  };
48
+ /**
49
+ * The segments a shell MAY run around a stop, in order: those read in full before it ({@link LexParseFailure.readBefore}), the
50
+ * statement it stopped in as far as the stop where the shell still runs that statement ({@link STATEMENT_RUNS_PAST}: the words
51
+ * read in full before the stop are the command's first words, judged as written; the word the stop falls in, a here-document
52
+ * whose body was not reached and all past the stop stay unread), and the statements past the stop ({@link segmentsPastStop}).
53
+ * That head is {@link LexedSegment.spliced}: its program may receive more words, so what it binds or where it moves is a candidate;
54
+ * its substitutions are those its words carry (a substitution in the word the stop falls in is that word's, unread too).
55
+ */
56
+ export declare function segmentsAroundStop(source: string, failure: LexParseFailure): readonly LexedSegment[];
48
57
  /** The constructs of this dialect a POSIX `sh` reads as something else. */
49
58
  export declare const BASH_ONLY_CONSTRUCTS: readonly ["ansi_c_quoting", "locale_string", "append_assignment", "subscript_assignment", "compound_assignment", "here_string", "process_substitution", "redirect_both", "pipe_both", "brace_expansion"];
50
59
  export type BashOnlyConstruct = (typeof BASH_ONLY_CONSTRUCTS)[number];
51
60
  /**
52
- * The ANSI-C escapes this lexer folds: the thirteen single-letter ones, whose byte is the same in every bash and
53
- * in the reference implementation's table. Numeric, control and unicode escapes are NOT here — their bytes differ
54
- * between bash 3.2 and 5.x (`\c?`, `\u`, `\U`) or truncate the region (NUL) — and a body carrying one is
55
- * `unresolved` rather than decoded. Admission to this table is a differential test against the real shells.
61
+ * The single-letter ANSI-C escapes this lexer folds: the thirteen whose byte is the same in every bash. The numeric and
62
+ * control escapes are folded beside them where they yield such a byte ({@link numericEscapeAt}); every other escape is
63
+ * `unresolved` rather than decoded. Admission is a differential test against the real shells.
56
64
  */
57
65
  export declare const ANSI_C_ESCAPES: {
58
66
  readonly a: "\u0007";
@@ -223,14 +231,20 @@ export interface LexedSegment {
223
231
  /** The bodies among {@link substitutions} of a function or value substitution (`${ list; }`, `${| list; }`): their list
224
232
  * runs in the CURRENT shell, so what it assigns or where it moves outlives the word. Absent when there is none. */
225
233
  readonly currentShell?: readonly string[];
226
- /** The segment stands where a `source` of a file this text wrote stood (#3400): it is the written literal's text, not
227
- * the text as the shell will read it — whether it runs is not proven (the write may have failed or gone to a device,
228
- * the printer may be shadowed), so what it binds or where it moves is one more candidate, never a certainty (#3557). */
234
+ /** Whether the segment runs where it stands is not proven, so what it binds or where it moves is one more candidate, never
235
+ * a certainty (#3557): it stands where a `source` of a file this text wrote stood (#3400) — the written literal's text, not
236
+ * the text as the shell will read it (the write may have failed or gone to a device, the printer may be shadowed) — or it
237
+ * is a statement read past the place the lexer stopped ({@link segmentsPastStop}: a reading that may have started inside
238
+ * a construct, or past text no shell gets beyond). */
229
239
  readonly spliced?: true;
230
240
  /** The `source` segment itself, kept after the segments its written literal was spliced into (#3557): never spliced
231
241
  * again. The inserted segments are only {@link spliced} — a `source` among them of a file the inserted text itself
232
242
  * wrote splices on the next pass (a guard on `spliced` would hide `. ./inner.sh` inside the spliced text). */
233
243
  readonly sourced?: true;
244
+ /** The words a statement holds before the place the lexer stopped in it ({@link segmentsAroundStop}): judged as that
245
+ * command, and no statement the splice of a written `source` reads — the statements around it are adjacent to it as they
246
+ * were before the head was read. */
247
+ readonly stopHead?: true;
234
248
  }
235
249
  export interface LexedCommand {
236
250
  readonly segments: readonly LexedSegment[];
@@ -244,7 +258,12 @@ export interface LexParseFailure {
244
258
  };
245
259
  /** The segments the walk read before it stopped, the last one holding the tokens it had read when it stopped. Bash runs
246
260
  * each complete line before it parses the next one (`rm -r x` on line 1 runs although line 2 never closes its quote),
247
- * so a reader asking what the text MAY run reads these as runs; a reader asking what the text DOES reads the failure. */
261
+ * so a reader asking what the text MAY run reads these as runs; a reader asking what the text DOES reads the failure.
262
+ * Every segment before the last is such a run — the read station's planner and the deny lanes read the same ones. A
263
+ * here-document the text never terminates is read as the shells read it, to the end of the text: the segment owning it
264
+ * holds that body, and the last segment is an empty one at the text's end. Which of these runs a shell reaches is not
265
+ * decided here (a quote left open on the SAME line stops bash before any of that line runs; zsh parses the whole text
266
+ * first): the reading is of what MAY run. */
248
267
  readonly readBefore: readonly LexedSegment[];
249
268
  }
250
269
  /** A command: its segments, or the one reason it has none. */
@@ -319,6 +338,21 @@ export declare function parameterArithmeticTexts(body: string): {
319
338
  readonly subscript?: string;
320
339
  readonly offset?: string;
321
340
  };
341
+ /**
342
+ * The command lines a parameter expansion's OPERAND runs (`${X:-$(cmd)}` when X is unset or empty, `${X:+$(cmd)}` when it is
343
+ * set, `${X#$(cmd)}` always; measured on bash 3.2 and 5.2, dash, zsh): the command and process substitutions written in it,
344
+ * and those of the arithmetic and parameter expansions written in it — read as the shell expands the operand, left to right.
345
+ * In double quotes (`quoted`) a single quote is an ordinary character there (`"${X:-'$(cmd)'}"` runs cmd); outside them a
346
+ * single-quoted run — `$'…'` read to its unescaped close — is text, and a double-quoted run inside the operand reads as in
347
+ * double quotes (`${X:-'$(cmd)'}` runs nothing, `${X:-"'$(cmd)'"}` runs cmd). `<(…)` / `>(…)` are process substitutions
348
+ * outside both, and in double quotes in a pattern operand too ({@link PATTERN_OPERAND}: `"${X#<(cmd)}"`, `"${X//<(cmd)/}"`,
349
+ * `"${X^^<(cmd)}"` run cmd; `"${X:-<(cmd)}"` does not — measured on 3.2 and 5.3). A substitution's
350
+ * own text is never rewritten (`${X:-$(cat '.env')}` reads `cat '.env'`). A subscript and a substring offset are not operand
351
+ * text ({@link parameterArithmeticTexts}: the evaluator's). The walk stops at an expansion it cannot delimit and keeps what it
352
+ * read before it: the word itself stays unread either way (its braces carry `$`, {@link UNREADABLE_EXPANSION_TEXT}). The
353
+ * one reading of what an operand runs: the deny lanes' lines ({@link expansionRunsOf}) and the read station's nested plans.
354
+ */
355
+ export declare function parameterOperandLines(body: string, quoted: boolean): readonly string[];
322
356
  /** What evaluating an expansion (a word's, a here-document body's) runs, as far as its text shows it. `lines`: the command
323
357
  * lines its substitutions run, each a command line of its own — a command or process substitution's body, the list of
324
358
  * `${ …; }`, and the substitutions an arithmetic text holds (bash expands that text as double-quoted text first:
@@ -326,13 +360,18 @@ export declare function parameterArithmeticTexts(body: string): {
326
360
  * ALSO run a program no line shows — the arithmetic evaluator evaluates a NAME recursively (`a='x[$(…)]'; $((a))`), so
327
361
  * arithmetic text that names a variable or carries a `$` may, and so may a parameter expansion's subscript or substring
328
362
  * offset (its own or one nested in its text, `${x:-${a[i]}}`), a value it re-reads (`${!R}`, `${P@P}`), and a parameter,
329
- * brace or glob text that carries a substitution opener (a parameter's operand is word grammar this lexer does not read).
330
- * The one reading of what an expansion runs: {@link expansionHidesRun} is its boolean face. */
363
+ * brace or glob text that carries a substitution opener. A parameter's operand is word grammar this lexer does not read as
364
+ * words, but the substitutions written in it run (`${X:-$(cmd)}` runs cmd when X is unset, `${X#$(cmd)}` always; measured on
365
+ * bash 3.2 and 5.2, dash, zsh): they are its lines ({@link parameterOperandLines}, the reading the read station's planner
366
+ * takes of the same operand), and the expansion stays hidden — whether the operand is expanded, and what it yields, the
367
+ * text does not say. The one reading of what an expansion runs: {@link expansionHidesRun} is its boolean face. */
331
368
  export interface ExpansionRuns {
332
369
  readonly lines: readonly string[];
333
370
  readonly hidden: boolean;
334
371
  }
335
- export declare function expansionRunsOf(e: WordExpansion): ExpansionRuns;
372
+ /** `quoted`: the expansion stands in double quotes (a here-document body and an arithmetic text expand as such) — how its
373
+ * operand's quotes read ({@link parameterOperandLines}). */
374
+ export declare function expansionRunsOf(e: WordExpansion, quoted?: boolean): ExpansionRuns;
336
375
  /** An arithmetic text's runs: none when it is plain ({@link arithmeticTextIsPlain}); else hidden (the evaluator may run
337
376
  * what a value names), with the lines of the substitutions it holds, read as double-quoted text
338
377
  * ({@link expansionsInHeredocBody}: quotes are ordinary characters there). */
@@ -393,6 +432,31 @@ export declare function heredocBodyPieces(body: string): readonly WordPiece[] |
393
432
  /** Lex a command: its segments, or the one reason bash (or this lexer) cannot delimit them — with the segments read
394
433
  * before it ({@link LexParseFailure.readBefore}). */
395
434
  export declare function lexShell(source: string): ShellLex;
435
+ /** How many characters, in all, the readings past one stop are charged before no new one starts ({@link segmentsPastStop}): a
436
+ * reading that ends where an earlier one opened a statement is charged what it read, any other one the rest of the text (the
437
+ * last one started may run past the budget). Past it no boundary is read from: what stands after it is read by no reading,
438
+ * and stays inside the text the lexer did not read — the unreadable
439
+ * segment it stopped in reaches to the text's end ({@link LexParseFailure.readBefore}), so every reader still takes the whole
440
+ * text as one it cannot read. A script of a few thousand lines with a stop every few hundred is charged well under it. */
441
+ export declare const READ_PAST_STOP_BUDGET: number;
442
+ /**
443
+ * The statements written past the place the lexer stopped ({@link LexParseFailure}), as segments a shell MAY run. Where the
444
+ * lexer stops, a shell need not: bash 5 reads past a `case` in a substitution and a here-document delimiter spelled with a
445
+ * `$`, and runs every statement after them. The lexer cannot say where such a construct ends, so it does not guess: it
446
+ * starts reading again at EVERY statement boundary past the stop (a line break, `;`, `&`, `|`) and keeps every complete
447
+ * segment any such reading reads, each once (by where it starts), in the order they stand. The lexer carries nothing from
448
+ * one statement to the next but a here-document body owed and an arithmetic command left open: a reading does not start
449
+ * where an earlier reading opened a statement with neither, and ends where it opens one so itself at such a place — from
450
+ * there on the two read alike. A reading that starts inside the construct, or inside text another reading took as quoted
451
+ * or as a here-document's body, may read a piece of it as a statement: such a piece is judged as one (a question or a
452
+ * refusal about text that would not run), and what it may bind is a binding for the statements after it. Each segment is
453
+ * {@link LexedSegment.spliced} — whether it runs is not proven, so what it binds is a candidate — and a reading's first
454
+ * one stands after a line break; offsets are the whole text's. The construct itself — the segment the lexer stopped in —
455
+ * is in none of them: what it runs stays unread. The readings start past both the stop and the start of that segment: an
456
+ * unterminated here-document's body, read to the text's end, is no text past it. They are bounded by
457
+ * {@link READ_PAST_STOP_BUDGET}.
458
+ */
459
+ export declare function segmentsPastStop(source: string, failure: LexParseFailure): readonly LexedSegment[];
396
460
  /**
397
461
  * The refused-reading view of {@link lexShell}: a parse failure, and any word whose value cannot be read off the
398
462
  * text, become the one `{ reject }` sentence a consumer's unreadable arm already takes. A reader that keeps the