@sema-agent/core 7.48.0 → 7.49.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 (421) hide show
  1. package/CHANGELOG.md +457 -0
  2. package/README.md +2 -2
  3. package/dist/agents/cascade.d.ts +2 -5
  4. package/dist/agents/child-failure.d.ts +20 -0
  5. package/dist/agents/child-failure.js +28 -0
  6. package/dist/agents/cross-session-ref.d.ts +11 -3
  7. package/dist/agents/cross-session-ref.js +6 -0
  8. package/dist/agents/cumulative-stats.d.ts +12 -15
  9. package/dist/agents/cumulative-stats.js +1 -1
  10. package/dist/agents/extra-tool-names.js +1 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +17 -13
  12. package/dist/agents/inherited-tool-pool.js +4 -3
  13. package/dist/agents/peer-session-drain.d.ts +3 -2
  14. package/dist/agents/peer-session-drain.js +5 -4
  15. package/dist/agents/send-message-tool.js +2 -9
  16. package/dist/agents/subagent.d.ts +10 -29
  17. package/dist/agents/subagent.js +65 -53
  18. package/dist/agents/suspend-guard.d.ts +1 -1
  19. package/dist/agents/tool-filter.d.ts +76 -65
  20. package/dist/agents/tool-filter.js +122 -92
  21. package/dist/agents/verify.d.ts +4 -7
  22. package/dist/agents/verify.js +6 -7
  23. package/dist/bench/metrics.d.ts +1 -2
  24. package/dist/brain/anthropic.js +133 -79
  25. package/dist/brain/errors.d.ts +53 -6
  26. package/dist/brain/errors.js +22 -2
  27. package/dist/brain/input-too-long.d.ts +40 -19
  28. package/dist/brain/input-too-long.js +3 -16
  29. package/dist/brain/open-responses.js +19 -10
  30. package/dist/brain/openai.js +123 -32
  31. package/dist/brain/provider-dialect.d.ts +214 -0
  32. package/dist/brain/provider-dialect.js +186 -0
  33. package/dist/brain/request-params.d.ts +27 -8
  34. package/dist/brain/request-params.js +7 -12
  35. package/dist/brain/request-route.d.ts +84 -0
  36. package/dist/brain/request-route.js +41 -0
  37. package/dist/brain/retry.d.ts +8 -0
  38. package/dist/brain/retry.js +10 -4
  39. package/dist/brain/route-adjudicator.d.ts +7 -0
  40. package/dist/brain/route-adjudicator.js +5 -1
  41. package/dist/brain/status-sink.d.ts +20 -0
  42. package/dist/brain/status-sink.js +11 -0
  43. package/dist/brain/stream-engine.d.ts +52 -1
  44. package/dist/brain/stream-engine.js +81 -24
  45. package/dist/brain/stream-shared.d.ts +57 -11
  46. package/dist/brain/stream-shared.js +28 -2
  47. package/dist/core/a2a.d.ts +1 -0
  48. package/dist/core/agent-config-dir.js +3 -2
  49. package/dist/core/allow-entry.d.ts +21 -12
  50. package/dist/core/allow-entry.js +38 -31
  51. package/dist/core/arg-summary.d.ts +21 -28
  52. package/dist/core/arg-summary.js +235 -88
  53. package/dist/core/ask-origin.d.ts +42 -24
  54. package/dist/core/ask-origin.js +18 -13
  55. package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
  56. package/dist/core/auto-mode-prompt-assets.js +1 -1
  57. package/dist/core/auto-mode-prompt.d.ts +11 -1
  58. package/dist/core/auto-mode-prompt.js +13 -10
  59. package/dist/core/auto-mode-rebuild.d.ts +7 -0
  60. package/dist/core/auto-mode-rebuild.js +4 -1
  61. package/dist/core/canonical-json.d.ts +3 -0
  62. package/dist/core/canonical-json.js +2 -1
  63. package/dist/core/checkpoint-requirements.d.ts +892 -0
  64. package/dist/core/checkpoint-requirements.js +333 -0
  65. package/dist/core/checkpoint-store.d.ts +94 -65
  66. package/dist/core/checkpoint-store.js +14 -26
  67. package/dist/core/child-clamp-seats.d.ts +228 -69
  68. package/dist/core/child-clamp-seats.js +211 -17
  69. package/dist/core/classifier-unavailable-arm.d.ts +5 -1
  70. package/dist/core/classifier-unavailable-arm.js +3 -3
  71. package/dist/core/compliance.d.ts +3 -0
  72. package/dist/core/compliance.js +9 -4
  73. package/dist/core/credential-vocabulary.d.ts +140 -0
  74. package/dist/core/credential-vocabulary.js +131 -0
  75. package/dist/core/decision-receipt.js +1 -1
  76. package/dist/core/effective-path-target.d.ts +73 -16
  77. package/dist/core/effective-path-target.js +63 -33
  78. package/dist/core/engine-notice.d.ts +43 -11
  79. package/dist/core/file-history-store.js +2 -2
  80. package/dist/core/fs-write-gate-policy.d.ts +4 -0
  81. package/dist/core/fs-write-gate-policy.js +22 -5
  82. package/dist/core/gate-bounded-await.d.ts +28 -13
  83. package/dist/core/gate-bounded-await.js +41 -4
  84. package/dist/core/gate-fold.d.ts +1 -1
  85. package/dist/core/gate-fold.js +24 -25
  86. package/dist/core/gate-lanes.js +16 -15
  87. package/dist/core/gate-outcome.d.ts +20 -5
  88. package/dist/core/gate-outcome.js +5 -0
  89. package/dist/core/governance-codes.d.ts +11 -4
  90. package/dist/core/governance-codes.js +14 -3
  91. package/dist/core/hooks.d.ts +21 -0
  92. package/dist/core/locked-config.d.ts +8 -0
  93. package/dist/core/locked-config.js +14 -2
  94. package/dist/core/lsp.js +3 -5
  95. package/dist/core/mailbox-store.d.ts +3 -4
  96. package/dist/core/mcp-connection-pool.d.ts +75 -0
  97. package/dist/core/mcp-connection-pool.js +128 -0
  98. package/dist/core/mcp-failure.d.ts +2 -1
  99. package/dist/core/mcp-failure.js +13 -2
  100. package/dist/core/mcp.d.ts +4 -0
  101. package/dist/core/mcp.js +70 -43
  102. package/dist/core/memory-engine/content-origin.js +2 -14
  103. package/dist/core/memory-engine/engine.d.ts +32 -22
  104. package/dist/core/memory-engine/engine.js +103 -55
  105. package/dist/core/memory-engine/file-backend.d.ts +13 -30
  106. package/dist/core/memory-engine/file-backend.js +37 -252
  107. package/dist/core/memory-engine/index.d.ts +1 -1
  108. package/dist/core/memory-engine/index.js +1 -1
  109. package/dist/core/memory-engine/layout.d.ts +139 -9
  110. package/dist/core/memory-engine/layout.js +350 -7
  111. package/dist/core/memory-engine/scope-contract.d.ts +10 -0
  112. package/dist/core/memory-engine/scope-contract.js +8 -0
  113. package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
  114. package/dist/core/memory-engine/session-incarnation.js +5 -2
  115. package/dist/core/memory-engine/types.d.ts +10 -1
  116. package/dist/core/memory.js +5 -17
  117. package/dist/core/model-seat.d.ts +4 -4
  118. package/dist/core/model-seat.js +1 -1
  119. package/dist/core/mounted-mcp.d.ts +57 -0
  120. package/dist/core/mounted-mcp.js +19 -0
  121. package/dist/core/namespaced-rule-name.d.ts +29 -0
  122. package/dist/core/namespaced-rule-name.js +52 -0
  123. package/dist/core/park-selfcheck.d.ts +1 -1
  124. package/dist/core/park-selfcheck.js +16 -6
  125. package/dist/core/path-guard-rows.d.ts +99 -0
  126. package/dist/core/path-guard-rows.js +45 -0
  127. package/dist/core/path-identity.d.ts +22 -16
  128. package/dist/core/path-identity.js +10 -10
  129. package/dist/core/path-rule-binding.d.ts +2 -1
  130. package/dist/core/path-rule-binding.js +3 -1
  131. package/dist/core/pause-registry.d.ts +16 -2
  132. package/dist/core/pause-registry.js +6 -0
  133. package/dist/core/permission-rule-consent.js +0 -7
  134. package/dist/core/permission-rule-model.d.ts +68 -24
  135. package/dist/core/permission-rule-model.js +105 -24
  136. package/dist/core/permission-rule-store.js +2 -2
  137. package/dist/core/permission-rules.d.ts +3 -30
  138. package/dist/core/permission-rules.js +4 -54
  139. package/dist/core/read-root-candidate.d.ts +1 -3
  140. package/dist/core/read-root-candidate.js +4 -15
  141. package/dist/core/real-approval.d.ts +4 -3
  142. package/dist/core/retired-keys.d.ts +13 -0
  143. package/dist/core/retired-keys.js +14 -0
  144. package/dist/core/roles.d.ts +2 -3
  145. package/dist/core/roles.js +15 -6
  146. package/dist/core/runner/assemble-result.d.ts +0 -7
  147. package/dist/core/runner/assemble-result.js +19 -31
  148. package/dist/core/runner/caller-roster.d.ts +78 -0
  149. package/dist/core/runner/caller-roster.js +219 -0
  150. package/dist/core/runner/checkpoint-scope.d.ts +16 -16
  151. package/dist/core/runner/checkpoint-scope.js +2 -2
  152. package/dist/core/runner/child-tree.js +2 -2
  153. package/dist/core/runner/contracts.d.ts +68 -35
  154. package/dist/core/runner/decide-continuation.d.ts +51 -3
  155. package/dist/core/runner/decide-continuation.js +76 -21
  156. package/dist/core/runner/denial-limit-arms.d.ts +17 -5
  157. package/dist/core/runner/denial-limit-arms.js +11 -9
  158. package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
  159. package/dist/core/runner/extra-body-dropped-seat.js +22 -0
  160. package/dist/core/runner/finish-reason-seat.d.ts +9 -0
  161. package/dist/core/runner/finish-reason-seat.js +40 -0
  162. package/dist/core/runner/gate-exit.d.ts +44 -32
  163. package/dist/core/runner/gate-exit.js +112 -25
  164. package/dist/core/runner/inherited-ask-grants.js +6 -4
  165. package/dist/core/runner/mcp-redial.d.ts +3 -3
  166. package/dist/core/runner/mcp-redial.js +3 -4
  167. package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
  168. package/dist/core/runner/permission-rule-lanes.js +5 -4
  169. package/dist/core/runner/prepare-artifact.d.ts +4 -0
  170. package/dist/core/runner/prepare-artifact.js +2 -1
  171. package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
  172. package/dist/core/runner/prepare-ask-lane.js +12 -6
  173. package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
  174. package/dist/core/runner/prepare-boundary-parks.js +4 -7
  175. package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
  176. package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
  177. package/dist/core/runner/prepare-config-doors.d.ts +9 -9
  178. package/dist/core/runner/prepare-config-doors.js +10 -5
  179. package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
  180. package/dist/core/runner/prepare-defer-classify.js +5 -3
  181. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  182. package/dist/core/runner/prepare-delegation-surface.js +3 -3
  183. package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
  184. package/dist/core/runner/prepare-gate-stations.js +9 -7
  185. package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
  186. package/dist/core/runner/prepare-hands-readface.js +7 -7
  187. package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
  188. package/dist/core/runner/prepare-inherited-gate.js +14 -15
  189. package/dist/core/runner/prepare-listings.d.ts +7 -24
  190. package/dist/core/runner/prepare-listings.js +4 -5
  191. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
  192. package/dist/core/runner/prepare-memory-engine-session.js +4 -3
  193. package/dist/core/runner/prepare-memory.d.ts +6 -0
  194. package/dist/core/runner/prepare-memory.js +13 -13
  195. package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
  196. package/dist/core/runner/prepare-offload-wrappers.js +3 -3
  197. package/dist/core/runner/prepare-park-ask.d.ts +7 -8
  198. package/dist/core/runner/prepare-park-ask.js +17 -10
  199. package/dist/core/runner/prepare-policy-chain.js +24 -44
  200. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  201. package/dist/core/runner/prepare-project-context.js +3 -4
  202. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
  203. package/dist/core/runner/prepare-protocol-tools.js +3 -4
  204. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  205. package/dist/core/runner/prepare-run-refs.js +2 -1
  206. package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
  207. package/dist/core/runner/prepare-safety-scan.js +1 -2
  208. package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
  209. package/dist/core/runner/prepare-suspend-saga.js +28 -12
  210. package/dist/core/runner/prepare-task.d.ts +1 -1
  211. package/dist/core/runner/prepare-task.js +67 -56
  212. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
  213. package/dist/core/runner/prepare-wiring-manifest.js +5 -8
  214. package/dist/core/runner/resume-apply.js +7 -14
  215. package/dist/core/runner/resume-checkpoint-screen.js +11 -4
  216. package/dist/core/runner/resume-internals-and-config.js +2 -2
  217. package/dist/core/runner/resume-policy-outcome.js +5 -32
  218. package/dist/core/runner/resume-review-outcome.js +4 -1
  219. package/dist/core/runner/retired-runner-deps.d.ts +6 -0
  220. package/dist/core/runner/retired-runner-deps.js +10 -1
  221. package/dist/core/runner/run-brain-sinks.d.ts +4 -0
  222. package/dist/core/runner/run-brain-sinks.js +5 -2
  223. package/dist/core/runner/run-harness-handlers.js +29 -36
  224. package/dist/core/runner/run-leg.d.ts +0 -2
  225. package/dist/core/runner/run-leg.js +32 -33
  226. package/dist/core/runner/run-terminal-adoption.js +4 -3
  227. package/dist/core/runner/runtask.js +8 -8
  228. package/dist/core/runner/session-rule-policy.js +5 -5
  229. package/dist/core/runner/stream-settle-backstop.js +7 -4
  230. package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
  231. package/dist/core/runner/sub-agent-deny-lists.js +111 -80
  232. package/dist/core/runner/terminal-account.d.ts +48 -0
  233. package/dist/core/runner/terminal-account.js +186 -0
  234. package/dist/core/runner/tool-end-body.d.ts +54 -17
  235. package/dist/core/runner/tool-end-body.js +27 -2
  236. package/dist/core/runner/tool-face-overlay.d.ts +3 -1
  237. package/dist/core/runner/tool-face-overlay.js +6 -4
  238. package/dist/core/runner/tool-occurrence.d.ts +106 -0
  239. package/dist/core/runner/tool-occurrence.js +123 -0
  240. package/dist/core/runner/tool-progress-lane.d.ts +16 -8
  241. package/dist/core/runner/tool-progress-lane.js +25 -34
  242. package/dist/core/runner/tool-turn-repair-seat.d.ts +28 -4
  243. package/dist/core/runner/tool-turn-repair-seat.js +36 -13
  244. package/dist/core/runner/turn-attachments.d.ts +1 -1
  245. package/dist/core/runner/write-protection-station.d.ts +21 -9
  246. package/dist/core/runner/write-protection-station.js +20 -17
  247. package/dist/core/runner-deps.d.ts +12 -22
  248. package/dist/core/secret-env.d.ts +16 -5
  249. package/dist/core/secret-env.js +23 -63
  250. package/dist/core/sensitive-path-policy.d.ts +19 -18
  251. package/dist/core/sensitive-path-policy.js +73 -49
  252. package/dist/core/session-reconcile.d.ts +3 -0
  253. package/dist/core/session-reconcile.js +5 -4
  254. package/dist/core/session-store.d.ts +5 -0
  255. package/dist/core/session-store.js +12 -0
  256. package/dist/core/session.d.ts +13 -0
  257. package/dist/core/shared-memory/normalize.d.ts +17 -4
  258. package/dist/core/shared-memory/normalize.js +7 -7
  259. package/dist/core/shell-lexer.js +5 -4
  260. package/dist/core/shell-wrapper-projection.js +1 -1
  261. package/dist/core/skill-grant.js +1 -1
  262. package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
  263. package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
  264. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
  265. package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
  266. package/dist/core/stub-env.d.ts +2 -0
  267. package/dist/core/stub-env.js +1 -0
  268. package/dist/core/synthetic-read-verdict.js +2 -2
  269. package/dist/core/task-event.d.ts +59 -5
  270. package/dist/core/task-result.d.ts +1 -1
  271. package/dist/core/task-spec.d.ts +42 -9
  272. package/dist/core/terminal-cause.d.ts +94 -11
  273. package/dist/core/tighten-task-spec.d.ts +5 -4
  274. package/dist/core/tighten-task-spec.js +20 -25
  275. package/dist/core/tool-catalog-entries.d.ts +5 -7
  276. package/dist/core/tool-catalog-entries.js +14 -15
  277. package/dist/core/tool-face.d.ts +47 -0
  278. package/dist/core/tool-face.js +5 -0
  279. package/dist/core/tool-model-gate.d.ts +5 -5
  280. package/dist/core/tool-name-aliases.d.ts +26 -2
  281. package/dist/core/tool-name-aliases.js +13 -0
  282. package/dist/core/tool-name-list.d.ts +30 -0
  283. package/dist/core/tool-name-list.js +55 -0
  284. package/dist/core/tool-name-readings.d.ts +1 -9
  285. package/dist/core/tool-name-readings.js +1 -3
  286. package/dist/core/tool-policy.d.ts +195 -85
  287. package/dist/core/tool-policy.js +165 -380
  288. package/dist/core/tool-registry.d.ts +44 -1
  289. package/dist/core/tool-registry.js +26 -0
  290. package/dist/core/tool-roster.d.ts +19 -1
  291. package/dist/core/tool-roster.js +21 -2
  292. package/dist/core/tool-spec-members.d.ts +45 -0
  293. package/dist/core/tool-spec-members.js +169 -0
  294. package/dist/core/tool-spec.d.ts +46 -8
  295. package/dist/core/tools.d.ts +6 -2
  296. package/dist/core/tools.js +8 -4
  297. package/dist/core/untrusted-egress.js +29 -26
  298. package/dist/core/untrusted-text.d.ts +13 -10
  299. package/dist/core/untrusted-text.js +6 -44
  300. package/dist/core/workflow-journal-store.d.ts +4 -1
  301. package/dist/core/write-protect.d.ts +65 -29
  302. package/dist/core/write-protect.js +235 -177
  303. package/dist/engine/compaction/compaction.d.ts +2 -2
  304. package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
  305. package/dist/engine/execution-env/node-execution-env.js +16 -38
  306. package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
  307. package/dist/engine/execution-env/symlink-chain.js +32 -0
  308. package/dist/engine/harness/types.d.ts +7 -0
  309. package/dist/engine/llm/tool-turns.d.ts +3 -0
  310. package/dist/engine/llm/tool-turns.js +1 -0
  311. package/dist/engine/llm/types.d.ts +59 -23
  312. package/dist/engine/loop/agent-loop.js +16 -2
  313. package/dist/engine/session/memory-repo.js +11 -3
  314. package/dist/engine/session/repo-utils.d.ts +8 -0
  315. package/dist/engine/session/repo-utils.js +13 -0
  316. package/dist/index.d.ts +20 -23
  317. package/dist/index.js +17 -20
  318. package/dist/internal/harness.d.ts +1 -1
  319. package/dist/internal/harness.js +1 -1
  320. package/dist/internal/llm.d.ts +2 -2
  321. package/dist/internal/llm.js +1 -1
  322. package/dist/orchestration/governance-baseline-validity.js +1 -1
  323. package/dist/orchestration/run-spec.js +3 -3
  324. package/dist/orchestration/run-workflow-tool.d.ts +16 -35
  325. package/dist/orchestration/run-workflow-tool.js +38 -78
  326. package/dist/orchestration/workflow-governance.d.ts +21 -25
  327. package/dist/orchestration/workflow-governance.js +38 -78
  328. package/dist/orchestration/workflow-primitives.d.ts +7 -22
  329. package/dist/orchestration/workflow-primitives.js +5 -12
  330. package/dist/orchestration/workflow-types.d.ts +1 -1
  331. package/dist/orchestration/workflow.d.ts +61 -11
  332. package/dist/orchestration/workflow.js +189 -117
  333. package/dist/scenarios/full-body.d.ts +1 -1
  334. package/dist/shell/lex.d.ts +0 -21
  335. package/dist/shell/lex.js +250 -68
  336. package/dist/shell/shell-words.d.ts +35 -0
  337. package/dist/shell/shell-words.js +65 -0
  338. package/dist/stores/file/checkpoint-store.d.ts +5 -5
  339. package/dist/stores/file/checkpoint-store.js +5 -2
  340. package/dist/stores/file/index.d.ts +0 -8
  341. package/dist/stores/file/index.js +0 -12
  342. package/dist/stores/file/session-store.d.ts +3 -0
  343. package/dist/stores/file/session-store.js +44 -19
  344. package/dist/tools/artifact/artifact-tool.js +2 -0
  345. package/dist/tools/fs/bash-program-position.d.ts +12 -4
  346. package/dist/tools/fs/bash-program-position.js +32 -9
  347. package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
  348. package/dist/tools/fs/bash-readonly-classifier.js +8 -7
  349. package/dist/tools/fs/containment-face.d.ts +4 -0
  350. package/dist/tools/fs/containment-face.js +3 -0
  351. package/dist/tools/fs/fs-shared.d.ts +10 -0
  352. package/dist/tools/fs/fs-shared.js +18 -0
  353. package/dist/tools/fs/fs-write.js +4 -2
  354. package/dist/tools/fs/index.d.ts +1 -1
  355. package/dist/tools/fs/program-read-model.d.ts +46 -20
  356. package/dist/tools/fs/program-read-model.js +50 -20
  357. package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
  358. package/dist/tools/fs/program-read-model.rows.js +16 -15
  359. package/dist/tools/fs/read-deny-home.d.ts +33 -47
  360. package/dist/tools/fs/read-deny-home.js +35 -49
  361. package/dist/tools/fs/read-deny.d.ts +23 -22
  362. package/dist/tools/fs/read-deny.js +114 -89
  363. package/dist/tools/fs/removal-targets.d.ts +56 -23
  364. package/dist/tools/fs/removal-targets.js +65 -87
  365. package/dist/tools/fs/safety.d.ts +29 -22
  366. package/dist/tools/fs/safety.js +17 -11
  367. package/dist/tools/fs/search.js +10 -8
  368. package/dist/tools/fs/shell-read-argv.js +1 -1
  369. package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
  370. package/dist/tools/fs/shell-read-bindings.js +324 -86
  371. package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
  372. package/dist/tools/fs/shell-read-builtins.js +43 -0
  373. package/dist/tools/fs/shell-read-check.d.ts +15 -1
  374. package/dist/tools/fs/shell-read-check.js +67 -43
  375. package/dist/tools/fs/shell-read-establish.js +6 -6
  376. package/dist/tools/fs/shell-read-functions.d.ts +22 -0
  377. package/dist/tools/fs/shell-read-functions.js +29 -0
  378. package/dist/tools/fs/shell-read-judge.d.ts +51 -18
  379. package/dist/tools/fs/shell-read-judge.js +40 -4
  380. package/dist/tools/fs/shell-read-plan.d.ts +12 -6
  381. package/dist/tools/fs/shell-read-plan.js +118 -113
  382. package/dist/tools/fs/shell-read-start.d.ts +29 -6
  383. package/dist/tools/fs/shell-read-start.js +16 -9
  384. package/dist/tools/fs/shell-read-word.js +4 -0
  385. package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
  386. package/dist/tools/fs/shell-read-workdir.js +281 -0
  387. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
  388. package/dist/tools/fs/shell-read-write-targets.js +14 -5
  389. package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
  390. package/dist/tools/fs/shell-reentry-text.js +3 -11
  391. package/dist/tools/task-list.d.ts +1 -2
  392. package/dist/tools/web.js +1 -1
  393. package/package.json +4 -1
  394. package/test/export-surface.snapshot.json +107 -143
  395. package/wire-changes/core@7.49.0.json +4765 -0
  396. package/dist/agents/teacher.d.ts +0 -159
  397. package/dist/agents/teacher.js +0 -577
  398. package/dist/agents/team.d.ts +0 -226
  399. package/dist/agents/team.js +0 -257
  400. package/dist/core/strategy-store.d.ts +0 -238
  401. package/dist/core/strategy-store.js +0 -253
  402. package/dist/orchestration/builtin-workflows.d.ts +0 -133
  403. package/dist/orchestration/builtin-workflows.js +0 -159
  404. package/dist/scenarios/env.d.ts +0 -40
  405. package/dist/scenarios/env.js +0 -39
  406. package/dist/scenarios/scenario-registry.d.ts +0 -110
  407. package/dist/scenarios/scenario-registry.js +0 -140
  408. package/dist/scenarios/teacher-quickstart.d.ts +0 -40
  409. package/dist/scenarios/teacher-quickstart.js +0 -12
  410. package/dist/stores/cc/lockfile.d.ts +0 -10
  411. package/dist/stores/cc/lockfile.js +0 -98
  412. package/dist/stores/cc/mailbox-store.d.ts +0 -20
  413. package/dist/stores/cc/mailbox-store.js +0 -255
  414. package/dist/stores/cc/roster-adapter.d.ts +0 -12
  415. package/dist/stores/cc/roster-adapter.js +0 -117
  416. package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
  417. package/dist/stores/cc/sidecar-transcript.js +0 -264
  418. package/dist/stores/cc/task-list-store.d.ts +0 -2
  419. package/dist/stores/cc/task-list-store.js +0 -125
  420. package/dist/stores/file/strategy-store.d.ts +0 -97
  421. package/dist/stores/file/strategy-store.js +0 -341
@@ -1,3 +1,24 @@
1
+ /**
2
+ * The PROGRAM READ MODEL — one table that answers "what does this program do with its k-th word", and the readers
3
+ * every shell face reads it through.
4
+ *
5
+ * A row is one program (the basename bash runs; a versioned spelling of an interpreter is its row), carrying every
6
+ * argument fact the shell faces need: its option grammar (one per implementation where implementations disagree),
7
+ * the ROLE each option value and each operand plays, whether a form walks a tree, how an interpreter receives the
8
+ * program it runs, what a launcher steps over before the program it runs, which words a builtin keeps as shell text
9
+ * to run later. The rows live in `program-read-model.rows.ts`; this module is the schema and the readers.
10
+ *
11
+ * Every reader below is a PROJECTION of the same row: the option-slot reading the candidate extraction walks
12
+ * (`readArgs`), the traversal reading, the program-delivery reading, the launcher step, the program-text reading of a
13
+ * language the station parses, the message slots, the code bodies. A reader never carries a table of its own; a fact
14
+ * one reader needs and the row does not state is added to the row, where every other reader sees it too.
15
+ *
16
+ * Rows are checked against the real binaries by `test/program-read-model.binary-gate.test.ts`: each declared option
17
+ * of each row is run, per implementation, on fixtures whose every word is a FIFO, and the words the binary OPENED are
18
+ * compared with the words the row predicts it opens. A row whose opener cannot be witnessed locally (a daemon, an
19
+ * object store, a shell builtin) says so in its `witness`, with the reason.
20
+ */
21
+ import { type WordPiece } from "../../shell/lex.js";
1
22
  /** What a datum names: never a file. */
2
23
  export declare const DATUM_FORMS: readonly ["count", "pattern", "name-pattern", "label", "message", "delimiter"];
3
24
  export type DatumForm = (typeof DATUM_FORMS)[number];
@@ -8,7 +29,7 @@ export declare const PATH_VALUE_FORMS: readonly ["indirect", "form", "header", "
8
29
  export type PathValueForm = (typeof PATH_VALUE_FORMS)[number];
9
30
  /** What selecting an option does to how the program runs ({@link OptionSpec.mode}) — a CLOSED set (`docs/CLOSED-SETS.md`,
10
31
  * `OptionMode`). */
11
- export declare const OPTION_MODES: readonly ["banner", "interactive", "names-program", "follows", "repeats", "quiet", "forced"];
32
+ export declare const OPTION_MODES: readonly ["banner", "interactive", "names-program", "follows", "repeats", "quiet", "forced", "queries"];
12
33
  export type OptionMode = (typeof OPTION_MODES)[number];
13
34
  /**
14
35
  * What one word is in this program's hands — a CLOSED set (`docs/CLOSED-SETS.md`, `ArgRoleKind`), the eleven members the
@@ -167,7 +188,8 @@ export interface OptionSpec {
167
188
  * the program to run without a value (`node --test`; a launcher's, from the caller's environment: `su -m`); `follows`:
168
189
  * follows its files as they grow, until killed (`tail -f`); `repeats`: repeats on an interval until killed (`free -s`);
169
190
  * `quiet`: prints only what the program's own text tells it to (`sed -n`); `forced`: removes without asking, and passes
170
- * over an operand that is not there (`rm -f`). */
191
+ * over an operand that is not there (`rm -f`); `queries`: a LOOKUP — the operands are names it looks up and describes, and
192
+ * it runs none of them (`command -v`). */
171
193
  readonly mode?: OptionMode;
172
194
  /** This switch turns the program's own value glob off (`curl -g`): every {@link ArgRole} `programGlob` value of the
173
195
  * invocation is read literally. */
@@ -339,11 +361,9 @@ export interface ProgramRow {
339
361
  /** What a declaration builtin does to every name it binds with no switch selected ({@link OptionSpec.assigns}):
340
362
  * `readonly` makes them read-only, as `declare -r` does. */
341
363
  readonly assigns?: DeclaredAttribute;
342
- /** It moves the working directory in a way the station does not follow (`pushd`). */
343
- readonly movesBase?: "unfollowed";
344
- /** What it writes to its standard output, read off its operands ({@link printedText}): `words` = its operands joined
345
- * by a space (`echo`), `format` = its one operand as a format (`printf`). */
346
- readonly prints?: "words" | "format";
364
+ /** It moves the working directory through the directory stack (`pushd` / `popd`): the working-directory thread reads
365
+ * how (`shell-read-workdir.ts`). */
366
+ readonly movesBase?: "stack";
347
367
  /** A shell block word at the program position: it names no command of its own. */
348
368
  readonly syntax?: "block";
349
369
  /** Git-style subcommands: the word after the program's own options names one, and the words after it are read by
@@ -383,7 +403,7 @@ export declare function isDeclarationBuiltin(name: string): boolean;
383
403
  export declare function declaredAttributes(row: ProgramRow | undefined, args: readonly string[]): ReadonlySet<DeclaredAttribute>;
384
404
  /** Opens no file, starts no program and evaluates nothing (a declaration builtin: only bare — its caller checks). */
385
405
  export declare function isInertBuiltin(name: string): boolean;
386
- export declare function movesBaseUnfollowed(name: string): boolean;
406
+ export declare function movesBaseByStack(name: string): boolean;
387
407
  /** The LONG-OPTION name carried by a token (`--file=p` → `file`, `--reg` → `reg`); `undefined` for anything that is
388
408
  * not a long option with a non-empty name (`--`, `--=x`, a short option). */
389
409
  export declare function longOptionNameOf(tok: string): string | undefined;
@@ -668,14 +688,6 @@ export declare function programDelivery(row: ProgramRow | undefined, args: reado
668
688
  /** The language of the program an interpreter row runs: the language of its program operand, or of the first option that
669
689
  * delivers program text or a program file. `undefined` for a row that runs no program text. */
670
690
  export declare function programLanguageOf(row: ProgramRow | undefined): string | undefined;
671
- /**
672
- * The text a printer row ({@link ProgramRow.prints}) writes to its standard output, read off its argv (the program word
673
- * excluded; `undefined` = a word whose value the command does not spell). `undefined` wherever the words do not spell the
674
- * text: such a word, an option the row does not explain, an escape the program may interpret (a backslash: `echo -e`, an
675
- * `echo` that reads escapes by default, every `printf` format), a format with a directive (`%`) or values to fill it, or a
676
- * row that prints nothing it is handed.
677
- */
678
- export declare function printedText(row: ProgramRow | undefined, args: readonly (string | undefined)[]): string | undefined;
679
691
  /**
680
692
  * The argv indices some implementation of the row reads as a path it OPENS (an ordinary operand, a value or operand of a
681
693
  * reading path role, a program file) while another reads them as something else (program text, a backup suffix, a
@@ -701,6 +713,15 @@ export declare function launcherOptionArity(row: ProgramRow, tok: string): 0 | 1
701
713
  export declare function launcherOptionPathRole(row: ProgramRow, tok: string): Extract<ArgRole, {
702
714
  kind: "path";
703
715
  }> | undefined;
716
+ /** Does this launcher option word move the base its program runs in — the directory, the root, or where its word is looked
717
+ * up (an option whose value's role is a path with a `base`) — read off the option itself, whether or not its value is
718
+ * written (`nsenter -w` bare takes the target process's directory)? In a cluster, a letter up to the first that takes a
719
+ * value. `false` for any word the walk does not step. */
720
+ export declare function launcherOptionMovesBase(row: ProgramRow, tok: string): boolean;
721
+ /** Does this launcher option word select a LOOKUP ({@link OptionSpec.mode} `queries`: `command -v`, `-V`, a cluster
722
+ * carrying one — `-pv`), so that the words after the options are names and no program is run? In a cluster, a letter up
723
+ * to the first that takes a value. `false` for any word the walk does not step. */
724
+ export declare function launcherOptionQueries(row: ProgramRow, tok: string): boolean;
704
725
  /** How many words one launcher option occupies ({@link readLauncherOption}), or `undefined` where the row does not
705
726
  * explain it. */
706
727
  export declare function launcherOptionStep(row: ProgramRow, tok: string): 1 | 2 | undefined;
@@ -754,13 +775,18 @@ export declare function subcommandOf(row: ProgramRow | undefined, words: readonl
754
775
  readonly relocated: boolean;
755
776
  } | undefined;
756
777
  /**
757
- * The indices of the SETTLED words a row's subcommand reads as message text: the value of its message option attached
758
- * or as the next word, by its own grammar. The global options are read exactly ({@link subcommandOf}); in the subcommand
759
- * an unknown long option takes no value, an unknown short letter or an unsettled word takes the next word (which is
760
- * then never a message).
778
+ * The indices of the words a row's subcommand reads as message text: the value of its message option attached or as the
779
+ * next word, by its own grammar. The global options are read exactly ({@link subcommandOf}); in the subcommand an unknown
780
+ * long option takes no value, an unknown short letter or an unsettled word takes the next word (which is then never a
781
+ * message). The option word itself is settled; its separate value is a message whether the text settles it or the shell
782
+ * computes it as ONE argument — every expansion in it a command substitution in double quotes, whose output is one field
783
+ * (a parameter is not taken so: `"$@"` and `"${a[@]}"` are several).
761
784
  */
762
785
  export declare function messageWords(program: string, words: readonly {
763
786
  readonly folded: string;
764
787
  readonly expands: unknown;
788
+ readonly word?: {
789
+ readonly expansions: readonly WordPiece[];
790
+ };
765
791
  }[], programIndex: number): Set<number>;
766
792
  export {};
@@ -2,7 +2,7 @@ import { literalTildeSpelling } from "../../shell/lex.js";
2
2
  import { PROGRAM_ROWS } from "./program-read-model.rows.js";
3
3
  export const DATUM_FORMS = Object.freeze(["count", "pattern", "name-pattern", "label", "message", "delimiter"]);
4
4
  export const PATH_VALUE_FORMS = Object.freeze(["indirect", "form", "header", "url"]);
5
- export const OPTION_MODES = Object.freeze(["banner", "interactive", "names-program", "follows", "repeats", "quiet", "forced"]);
5
+ export const OPTION_MODES = Object.freeze(["banner", "interactive", "names-program", "follows", "repeats", "quiet", "forced", "queries"]);
6
6
  export const ARG_ROLE_KINDS = Object.freeze(["path", "mount-source", "object-path", "program-text", "program-file", "shell-text", "command", "assignment", "binds-name", "entry-probe", "datum"]);
7
7
  export const PATH_EFFECTS = Object.freeze(["read", "names", "write", "create", "edit-in-place"]);
8
8
  export const WRITING_EFFECTS = new Set(["write", "create", "edit-in-place"]);
@@ -66,8 +66,8 @@ export function isInertBuiltin(name) {
66
66
  const b = programRow(name)?.builtin;
67
67
  return b === "inert" || b === "declaration";
68
68
  }
69
- export function movesBaseUnfollowed(name) {
70
- return programRow(name)?.movesBase === "unfollowed";
69
+ export function movesBaseByStack(name) {
70
+ return programRow(name)?.movesBase === "stack";
71
71
  }
72
72
  export function longOptionNameOf(tok) {
73
73
  if (!tok.startsWith("--") || tok.length === 2)
@@ -979,21 +979,6 @@ export function programLanguageOf(row) {
979
979
  return r.language;
980
980
  return undefined;
981
981
  }
982
- export function printedText(row, args) {
983
- const words = args.filter((a) => a !== undefined);
984
- if (row?.prints === undefined || words.length !== args.length)
985
- return undefined;
986
- const events = readArgRoles(row, words);
987
- const from = events.find((e) => e.kind === "operand" || e.kind === "dash-word-operand")?.at ?? words.length;
988
- if (events.some((e) => e.at < from && e.kind === "option" && e.reading === "speculative"))
989
- return undefined;
990
- const printed = words.slice(from);
991
- if (printed.some((w) => w.includes("\\")))
992
- return undefined;
993
- if (row.prints === "words")
994
- return printed.join(" ");
995
- return printed.length === 1 && !printed[0].includes("%") ? printed[0] : undefined;
996
- }
997
982
  export function wordsReadBySomeImplementations(row, args) {
998
983
  if (row === undefined || row.grammars.length < 2)
999
984
  return new Set();
@@ -1034,7 +1019,7 @@ export function moduleTailOf(row, args) {
1034
1019
  }
1035
1020
  function steppableLauncherOption(row, tok) {
1036
1021
  const m = tok.startsWith("--") ? (tok.includes("=") ? undefined : mergedTable(row, "long").get(tok.slice(2))) : tok.length === 2 && tok.startsWith("-") ? mergedTable(row, "short").get(tok[1]) : undefined;
1037
- if (m === undefined || m.spec.value?.kind === "shell-text" || (m.spec.value?.kind === "path" && m.spec.value.base !== undefined))
1022
+ if (m === undefined || m.spec.value?.kind === "shell-text")
1038
1023
  return undefined;
1039
1024
  return m.arity !== "disputed" || takesNoWordBare(row, tok) ? m : undefined;
1040
1025
  }
@@ -1085,6 +1070,47 @@ export function launcherOptionPathRole(row, tok) {
1085
1070
  const role = readLauncherOption(row, tok)?.valued?.spec.value;
1086
1071
  return role?.kind === "path" ? role : undefined;
1087
1072
  }
1073
+ export function launcherOptionMovesBase(row, tok) {
1074
+ const moves = (m) => m?.spec.value?.kind === "path" && m.spec.value.base !== undefined;
1075
+ if (tok === "-" || tok === "--")
1076
+ return false;
1077
+ if (tok.startsWith("--")) {
1078
+ const eq = tok.indexOf("=");
1079
+ return moves(steppableLauncherOption(row, eq > 2 ? tok.slice(0, eq) : tok));
1080
+ }
1081
+ if (!/^-[^-]/.test(tok))
1082
+ return false;
1083
+ for (let i = 1; i < tok.length; i++) {
1084
+ const m = steppableLauncherOption(row, `-${tok[i]}`);
1085
+ if (m === undefined)
1086
+ return false;
1087
+ if (moves(m))
1088
+ return true;
1089
+ if (m.arity !== 0)
1090
+ return false;
1091
+ }
1092
+ return false;
1093
+ }
1094
+ export function launcherOptionQueries(row, tok) {
1095
+ if (tok === "-" || tok === "--")
1096
+ return false;
1097
+ if (tok.startsWith("--")) {
1098
+ const eq = tok.indexOf("=");
1099
+ return steppableLauncherOption(row, eq > 2 ? tok.slice(0, eq) : tok)?.spec.mode === "queries";
1100
+ }
1101
+ if (!/^-[^-]/.test(tok))
1102
+ return false;
1103
+ for (let i = 1; i < tok.length; i++) {
1104
+ const m = steppableLauncherOption(row, `-${tok[i]}`);
1105
+ if (m === undefined)
1106
+ return false;
1107
+ if (m.spec.mode === "queries")
1108
+ return true;
1109
+ if (m.arity !== 0)
1110
+ return false;
1111
+ }
1112
+ return false;
1113
+ }
1088
1114
  export function launcherOptionStep(row, tok) {
1089
1115
  return readLauncherOption(row, tok)?.step;
1090
1116
  }
@@ -1267,12 +1293,16 @@ export function messageWords(program, words, programIndex) {
1267
1293
  const j = programIndex + 1 + found.at;
1268
1294
  const sub = found.row.grammars[0];
1269
1295
  const settled = (k) => words[k] !== undefined && words[k].expands === false;
1296
+ const oneArgument = (k) => {
1297
+ const pieces = words[k]?.word?.expansions ?? [];
1298
+ return pieces.length > 0 && pieces.every((p) => p.expansion?.kind === "command" && p.expansion.yields === "one");
1299
+ };
1270
1300
  const longValues = Object.entries(sub.long).filter(([, s]) => s.arity === 1);
1271
1301
  let pending;
1272
1302
  for (let k = j + 1; k < words.length; k++) {
1273
1303
  const w = words[k].folded;
1274
1304
  if (pending !== undefined) {
1275
- if (pending === "message" && settled(k))
1305
+ if (pending === "message" && (settled(k) || oneArgument(k)))
1276
1306
  out.add(k);
1277
1307
  pending = undefined;
1278
1308
  continue;
@@ -1,17 +1,3 @@
1
- /**
2
- * The rows of the program read model (`program-read-model.ts` is the schema and the readers). One row per program
3
- * bash can run at a segment's program position, grouped by family. Every row is DATA: adding a program, an option or
4
- * an implementation is a row edit, never a reader branch.
5
- *
6
- * How a row is written:
7
- * · an option is declared with its arity and, where it is known, the ROLE of its value; a value whose role is not
8
- * known is declared by arity alone, and every reader then reads that option the speculative way;
9
- * · where two implementations of one program disagree, the row carries one grammar per implementation, and the
10
- * readers combine them (a short letter whose arity they dispute is read as nothing; a disputed long name as
11
- * optional-valued; a spelling one implementation does not declare is one it rejects, opening nothing);
12
- * · a row is checked against the real binaries by the gate (`test/program-read-model.binary-gate.test.ts`);
13
- * a row the gate cannot run says why in `witness`.
14
- */
15
1
  import type { ProgramRow } from "./program-read-model.js";
16
2
  /** The time a launcher waits (`timeout 5s …`): a number with an optional unit. */
17
3
  export declare const DURATION_SPELLING: RegExp;
@@ -1,3 +1,4 @@
1
+ import { shellWordsOf } from "../../shell/shell-words.js";
1
2
  const READ = { kind: "path", effect: "read" };
2
3
  const WRITE = { kind: "path", effect: "write" };
3
4
  const CREATED = { kind: "path", effect: "create" };
@@ -30,6 +31,7 @@ const OBJECT_PATH = { kind: "object-path" };
30
31
  const text = (language) => ({ kind: "program-text", language });
31
32
  const file = (language) => ({ kind: "program-file", language });
32
33
  const SWITCH = { arity: 0 };
34
+ const QUERY = { arity: 0, mode: "queries" };
33
35
  const val = (value, extra = {}) => ({ arity: 1, ...(value !== undefined ? { value } : {}), ...extra });
34
36
  const optional = (value) => ({ arity: "attached", ...(value !== undefined ? { value } : {}) });
35
37
  const switches = (letters, extra = {}) => Object.fromEntries([...letters].map((l) => [l, { arity: 0, ...extra }]));
@@ -379,10 +381,10 @@ const launchers = [
379
381
  values: { "-u": LABEL, "--unset": LABEL, "-C": WORKDIR, "--chdir": WORKDIR, "-a": LABEL, "--argv0": LABEL, "-P": PROGRAM_SEARCH },
380
382
  optional: { "--default-signal": LABEL, "--ignore-signal": LABEL },
381
383
  shellText: ["-S", "--split-string"],
382
- }), { lacks: ["-P"] }, { lacks: ["-a", "--ignore-environment", "--debug", "--list-signal-handling", "--help", "--version", "--unset", "--chdir", "--argv0", "--default-signal", "--ignore-signal", "--split-string"] }), launcher: { assignmentOperands: true, bareDash: true }, witness: BINARY },
383
- launcher("command", {}, grammar({ p: SWITCH })),
384
- launcher("builtin"),
385
- launcher("exec", {}, launcherGrammar({ switches: ["-c", "-l"], values: { "-a": LABEL } })),
384
+ }, { stepsDashDash: true }), { lacks: ["-P"] }, { lacks: ["-a", "--ignore-environment", "--debug", "--list-signal-handling", "--help", "--version", "--unset", "--chdir", "--argv0", "--default-signal", "--ignore-signal", "--split-string"] }), launcher: { assignmentOperands: true, bareDash: true }, witness: BINARY },
385
+ launcher("command", {}, grammar({ p: SWITCH, v: QUERY, V: QUERY }, {}, { stepsDashDash: true })),
386
+ launcher("builtin", {}, grammar({}, {}, { stepsDashDash: true })),
387
+ launcher("exec", {}, launcherGrammar({ switches: ["-c", "-l"], values: { "-a": LABEL } }, { stepsDashDash: true })),
386
388
  launcher("noglob", {}, undefined, { witness: { declared: "a zsh precommand modifier" } }),
387
389
  launcher("nocorrect", {}, undefined, { witness: { declared: "a zsh precommand modifier" } }),
388
390
  { key: "xargs", grammars: implementations(launcherGrammar({
@@ -405,8 +407,8 @@ const launchers = [
405
407
  { key: "runuser", grammars: [launcherGrammar({ ...SU_OPTIONS, values: { ...SU_OPTIONS.values, "-u": LABEL, "--user": LABEL } }, { afterFirstOperand: "options", stepsDashDash: true })], launcher: { shellText: "user", programWith: ["-u", "--user"], asUser: { home: "target", loginWith: ["-l", "--login"] } }, witness: PRIVILEGED },
406
408
  launcher("chroot", { requiredOperands: 1, whenNoProgram: "shell" }, undefined, { witness: PRIVILEGED }),
407
409
  launcher("setpriv", {}, undefined, { witness: PRIVILEGED }),
408
- launcher("nohup", {}, grammar({}, BANNERS)),
409
- { key: "nice", grammars: implementations(grammar({ n: val(COUNT) }, { adjustment: val(COUNT), ...BANNERS }), {}, { lacks: ["--adjustment", "--help", "--version"] }), launcher: { negativeIntegerIsOwnArgument: true }, witness: BINARY },
410
+ launcher("nohup", {}, grammar({}, BANNERS, { stepsDashDash: true })),
411
+ { key: "nice", grammars: implementations(grammar({ n: val(COUNT) }, { adjustment: val(COUNT), ...BANNERS }, { stepsDashDash: true }), {}, { lacks: ["--adjustment", "--help", "--version"] }), launcher: { negativeIntegerIsOwnArgument: true }, witness: BINARY },
410
412
  launcher("ionice", {}, launcherGrammar({
411
413
  switches: ["-t", "--ignore", "-h", "--help", "-V", "--version"],
412
414
  banners: ["-h", "-V"],
@@ -417,8 +419,8 @@ const launchers = [
417
419
  values: { "-p": COUNT, "--pid": COUNT, "-T": COUNT, "-P": COUNT, "-D": COUNT, "--sched-runtime": COUNT, "--sched-period": COUNT, "--sched-deadline": COUNT },
418
420
  }), { witness: LINUX_NAMESPACE }),
419
421
  launcher("taskset", { requiredOperands: 1, requiredOperandSpelling: /^(?:0x)?[\da-f]+$|^[\d,:-]+$/i }, launcherGrammar({ switches: ["-a", "-p", "-c", "--all-tasks", "--pid", "--cpu-list", "--help", "--version"] }), { witness: LINUX_NAMESPACE }),
420
- { key: "stdbuf", grammars: implementations(grammar({ i: val(LABEL), o: val(LABEL), e: val(LABEL) }, { input: val(LABEL), output: val(LABEL), error: val(LABEL), ...BANNERS }), {}, { lacks: ["--input", "--output", "--error", "--help", "--version"] }), launcher: {}, witness: BINARY },
421
- launcher("timeout", { requiredOperands: 1, requiredOperandSpelling: DURATION_SPELLING }, grammar({ v: SWITCH, k: val(COUNT), s: val(LABEL) }, { foreground: SWITCH, "preserve-status": SWITCH, verbose: SWITCH, "kill-after": val(COUNT), signal: val(LABEL), ...BANNERS })),
422
+ { key: "stdbuf", grammars: implementations(grammar({ i: val(LABEL), o: val(LABEL), e: val(LABEL) }, { input: val(LABEL), output: val(LABEL), error: val(LABEL), ...BANNERS }, { stepsDashDash: true }), {}, { lacks: ["--input", "--output", "--error", "--help", "--version"] }), launcher: {}, witness: BINARY },
423
+ launcher("timeout", { requiredOperands: 1, requiredOperandSpelling: DURATION_SPELLING }, grammar({ v: SWITCH, k: val(COUNT), s: val(LABEL) }, { foreground: SWITCH, "preserve-status": SWITCH, verbose: SWITCH, "kill-after": val(COUNT), signal: val(LABEL), ...BANNERS }, { stepsDashDash: true })),
422
424
  { key: "time", grammars: implementations(grammar({ p: SWITCH, a: SWITCH, v: SWITCH, q: SWITCH, f: val(LABEL), o: val(WRITE) }, { portability: SWITCH, append: SWITCH, verbose: SWITCH, quiet: SWITCH, help: SWITCH, version: SWITCH, format: val(LABEL), output: val(WRITE) }, { stepsDashDash: true }), {}, { lacks: ["-v", "-q", "-f", "--portability", "--append", "--verbose", "--quiet", "--help", "--version", "--format", "--output"] }), launcher: {}, witness: BINARY },
423
425
  { key: "watch", grammars: [
424
426
  launcherGrammar({
@@ -429,12 +431,12 @@ const launchers = [
429
431
  }, { afterFirstOperand: "operands", stepsDashDash: true }),
430
432
  launcherGrammar({ switches: ["-d", "-t"], values: { "-n": COUNT } }, { afterFirstOperand: "operands", stepsDashDash: true }),
431
433
  ], launcher: { shellText: "joined", programWith: ["-x", "--exec"] }, witness: SHELL_TEXT_LAUNCHER },
432
- launcher("setsid", {}, launcherGrammar({ switches: ["-c", "-f", "-w", "--ctty", "--fork", "--wait", "--help", "--version"] })),
434
+ launcher("setsid", {}, launcherGrammar({ switches: ["-c", "-f", "-w", "--ctty", "--fork", "--wait", "--help", "--version"] }, { stepsDashDash: true })),
433
435
  launcher("flock", { requiredOperands: 1 }, launcherGrammar({
434
436
  switches: ["-s", "-x", "-u", "-n", "-o", "-F", "--shared", "--exclusive", "--unlock", "--nonblock", "--nb", "--close", "--no-fork", "--verbose", "--help", "--version"],
435
437
  values: { "-w": COUNT, "-E": COUNT, "--timeout": COUNT, "--wait": COUNT, "--conflict-exit-code": COUNT },
436
438
  shellText: ["-c", "--command"],
437
- }), { operands: { rest: CREATED } }),
439
+ }, { stepsDashDash: true }), { operands: { rest: CREATED } }),
438
440
  launcher("unshare", { whenNoProgram: "shell" }, launcherGrammar({
439
441
  switches: ["-m", "-u", "-i", "-n", "-p", "-U", "-C", "-T", "-f", "-r", "-c", "--mount", "--uts", "--ipc", "--net", "--pid", "--user", "--cgroup", "--time", "--fork", "--map-root-user", "--map-current-user", "--kill-child", "--mount-proc", "--keep-caps", "--help", "--version"],
440
442
  values: { "-R": ROOTDIR, "-w": WORKDIR, "-S": LABEL, "-G": LABEL, "--setuid": LABEL, "--setgid": LABEL, "--root": ROOTDIR, "--wd": WORKDIR, "--propagation": LABEL, "--setgroups": LABEL, "--monotonic": COUNT, "--boottime": COUNT, "--map-user": LABEL, "--map-group": LABEL },
@@ -504,7 +506,7 @@ const git = {
504
506
  const noPath = (key, rest, extra = {}) => ({ key, grammars: [], operands: { rest }, witness: BINARY, ...extra });
505
507
  const BUILTIN_ONLY = { declared: "a shell builtin with no binary of its own on every host: its words are read by the shell" };
506
508
  const noPathRows = [
507
- noPath("pwd", LABEL, { builtin: "inert" }), noPath("echo", LABEL, { builtin: "inert", grammars: [grammar(switches("neE"), {}, { afterFirstOperand: "operands" })], prints: "words" }), noPath("printf", LABEL, { grammars: [grammar({ v: val(BINDS_NAME) })], prints: "format" }), noPath("whoami", LABEL), noPath("uname", LABEL),
509
+ noPath("pwd", LABEL, { builtin: "inert" }), noPath("echo", LABEL, { builtin: "inert", grammars: [grammar(switches("neE"), {}, { afterFirstOperand: "operands" })] }), noPath("printf", LABEL, { grammars: [grammar({ v: val(BINDS_NAME) })] }), noPath("whoami", LABEL), noPath("uname", LABEL),
508
510
  noPath("which", LABEL), noPath("basename", LABEL), noPath("dirname", LABEL),
509
511
  { key: "tr", grammars: [], operands: { rest: LABEL, stdinBelow: "always" }, witness: BINARY },
510
512
  noPath("cal", COUNT), noPath("uptime", LABEL), noPath("id", LABEL), noPath("groups", LABEL), noPath("nproc", LABEL), noPath("locale", LABEL),
@@ -583,6 +585,7 @@ const stdinReaders = [
583
585
  ];
584
586
  const SYNTAX = { declared: "shell syntax, not a program: read by the lexer" };
585
587
  const block = (key, g = []) => ({ key, grammars: g, syntax: "block", witness: SYNTAX });
588
+ const BLOCK_GRAMMARS = { "[[": [grammar({ v: val(BINDS_NAME) })] };
586
589
  export const PROGRAM_ROWS = [
587
590
  head, tail, cut, grepRow("grep"), grepRow("egrep"), grepRow("fgrep"), diff, cmp, sed, date, tar, find, curl,
588
591
  ls, walker("du", "names", true), walker("rg", "contents", false), walker("tree", "names", true), walker("ag", "contents", false), walker("ack", "contents", false),
@@ -622,11 +625,9 @@ export const PROGRAM_ROWS = [
622
625
  ...nameBinders,
623
626
  ...["make", "gmake", "bmake", "cmake", "ninja", "meson"].map(assignmentNotPaths),
624
627
  containerRuntime("docker"), containerRuntime("podman"),
625
- { key: "pushd", grammars: [], movesBase: "unfollowed", witness: BUILTIN_ONLY },
626
- { key: "popd", grammars: [], movesBase: "unfollowed", witness: BUILTIN_ONLY },
628
+ ...[...shellWordsOf("stack_mover")].map((key) => ({ key, grammars: [], movesBase: "stack", witness: BUILTIN_ONLY })),
627
629
  ...SHELLS.map((s) => shellRow(s, "c-option", BINARY, [SHELL_GRAMMARS[s]], "script")),
628
630
  shellRow("eval", "words", BUILTIN_ONLY), shellRow("source", "file-operand", BUILTIN_ONLY), shellRow(".", "file-operand", BUILTIN_ONLY), shellRow("parallel", "non-option-words", BINARY, [], "script"),
629
631
  ...codeBodyRows,
630
- ...["for", "select", "case", "esac", "fi", "done", "function", "coproc", "]]", "in"].map((k) => block(k)),
631
- block("[[", [grammar({ v: val(BINDS_NAME) })]),
632
+ ...[...shellWordsOf("block")].map((k) => block(k, BLOCK_GRAMMARS[k])),
632
633
  ];
@@ -15,68 +15,54 @@ export declare function declaredReadDenyHomes(env: Pick<ExecutionEnv, "homeDir">
15
15
  * gave no answer, or where the declared home's own probe did not answer (ask again later). */
16
16
  export declare function readDenyHomesOf(env: Pick<ExecutionEnv, "homeDir" | "canonicalPath">, signal?: AbortSignal): Promise<string[]>;
17
17
  /**
18
- * Where the home-anchored rows of a table LEAD beyond the home's own spellings, keyed by the row's pattern — the
19
- * `linked` argument of `compileReadDeny`. For each row, its LITERAL HEAD (`readDenyRunHead`: the run's segments before
20
- * the first one carrying `*`) is spelled under each home and resolved the way the read faces mint their keys
21
- * (`canonicalizeTarget`: the longest existing prefix resolved, the rest rejoined); a location that differs from every
22
- * home's own spelling of the head is where one of the head's segments is a link, and the row is placed there too.
23
- * · a head that resolves to its own spelling under a home adds nothing (the row is already placed there);
18
+ * Where a table's deny rows LEAD past the places their own runs anchor them, keyed by the row's pattern — the `linked`
19
+ * argument of `compileReadDeny`. ONE constructor for every anchor ({@link ReadDenyRowAnchor}): the rows the anchor
20
+ * places, each row's LITERAL HEAD ({@link literalHeadOf}) spelled under each of the anchor's places and resolved the way the
21
+ * read faces mint their keys (`canonicalizeTarget`: the longest existing prefix resolved, the rest rejoined); a location
22
+ * that differs from the spellings the row is already anchored at is where one of the head's segments is a link (`~/.sema`
23
+ * into a dotfiles directory, `/app` a link to `/data/app`), and the row is placed there too.
24
+ * · a head that resolves to its own spelling at an anchored place adds nothing (the row is already placed there);
24
25
  * · a head under a spelling that is no directory (a segment of it is a file, a symlink to a file, a device node or a
25
26
  * socket — the environment answers `not_directory` for the head) has nothing below it: an answer that adds nothing;
26
27
  * · any other head that cannot be resolved (an unanswered or refused probe — a directory the probe may not enter — a
27
- * probe that throws) adds nothing, and the answer is not WHOLE (`whole: false`): the row stays placed at the home's
28
- * spellings until the mount places again;
29
- * · a row whose head is empty (`~/.sema.*`) has no location to resolve and adds nothing;
28
+ * probe that throws) adds nothing, and the answer is not WHOLE (`whole: false`): the row stays at the places its run
29
+ * anchors until the mount places again;
30
30
  * · the heads are resolved together, so one placement waits at most one probe bound — or, with `deadline` (an absolute
31
31
  * time), each head until then: a head still unresolved at the deadline is a head that did not answer;
32
32
  * · read per placement — a link created afterwards is followed from the next placement on.
33
33
  */
34
- export declare function readDenyHomeLinksOf(env: ExecutionEnv, entries: readonly {
34
+ export declare function readDenyLinksOf(env: ExecutionEnv, entries: readonly {
35
35
  readonly pattern: string;
36
36
  readonly caseSensitive?: boolean;
37
- }[], homes: readonly string[], signal?: AbortSignal, deadline?: number): Promise<{
37
+ }[], anchor: ReadDenyRowAnchor, signal?: AbortSignal, deadline?: number): Promise<{
38
38
  readonly linked: Map<string, string[]>;
39
39
  readonly whole: boolean;
40
40
  }>;
41
41
  /**
42
- * Where the ROOTED rows of a table (`/app/config-lkg.json`, read-deny.ts) lead — the same `linked` answer
43
- * {@link readDenyHomeLinksOf} gives for home-anchored rows, by the same machine ({@link linkedLocationsOf}): the row's
44
- * LITERAL HEAD is spelled under the root and resolved the way the read faces mint their keys, and a location that differs
45
- * from the spelling is where one of the head's segments is a link (`/app` a link to `/data/app`) — the row is placed
46
- * there too, so a read of the link's target meets it. The laws are `readDenyHomeLinksOf`'s: a head that resolves to its own
47
- * spelling adds nothing, a head with nothing below it adds nothing, a head the environment does not answer adds
48
- * nothing and the answer is not WHOLE, a row whose head is empty (`/*.json`) has no location to resolve. A root is no
49
- * home, so the answer does not depend on the homes: it is read whether or not a home answered.
42
+ * Which rows one placement reads, and where their heads are spelled:
43
+ * · `home` — the home-anchored rows (`~/…`), under each home; the row's run anchors it there;
44
+ * · `root` — the ROOTED rows (`/app/config-lkg.json`, {@link isRootedReadDenyPattern}), under the filesystem root; the run
45
+ * anchors it there. A root is no home: read whether or not a home answered;
46
+ * · `unanchored` — the rows that open with the configuration directory's name (`~/.sema/…`, {@link agentConfigDirTail})
47
+ * under each spelling of the root the host declares for that directory (`RunnerDeps.agentConfigDir`): the head BELOW
48
+ * the directory name, a head that ends at it (`~/.sema/*.json`, `~/.sema`) the root itself. The row's run does not
49
+ * anchor it there (it is anchored at the homes), so every location — the spelling itself and where it leads — is one
50
+ * the row is placed at in addition; the row's name in every refusal is unchanged.
51
+ * A home or rooted row whose head is empty (`~/.sema.*`, `/*.json`) has no location to resolve and adds nothing.
50
52
  */
51
- export declare function readDenyRootLinksOf(env: ExecutionEnv, entries: readonly {
52
- readonly pattern: string;
53
- readonly caseSensitive?: boolean;
54
- }[], signal?: AbortSignal, deadline?: number): Promise<{
55
- readonly linked: Map<string, string[]>;
56
- readonly whole: boolean;
57
- }>;
58
- /**
59
- * Where the rows that open with the configuration directory's name (`~/.sema/…`, {@link agentConfigDirTail}) lead when
60
- * the host declares the directory's root (`RunnerDeps.agentConfigDir`) — the same `linked` answer
61
- * {@link readDenyHomeLinksOf} gives, for the same rows: the row's literal head below the directory name is spelled under
62
- * each spelling of the root and resolved the way the read faces mint their keys. A row is not anchored at the root by
63
- * its own run (it is anchored at the homes), so every location here — the spelling itself and where it leads — is one the
64
- * row is placed at in addition; the home spelling stays placed. The row's name in every refusal is unchanged.
65
- * · a row whose run does not open with the directory's name (`~/.sema.*`, the external tools' files) adds nothing;
66
- * · a row whose head ends at the directory name (`~/.sema/*.json`, `~/.sema`) is placed at the root itself, the rest of
67
- * its run matched below it.
68
- */
69
- export declare function readDenyConfigRootLinksOf(env: ExecutionEnv, entries: readonly {
70
- readonly pattern: string;
71
- readonly caseSensitive?: boolean;
72
- }[], roots: readonly string[], signal?: AbortSignal, deadline?: number): Promise<{
73
- readonly linked: Map<string, string[]>;
74
- readonly whole: boolean;
75
- }>;
53
+ export type ReadDenyRowAnchor = {
54
+ readonly at: "home";
55
+ readonly homes: readonly string[];
56
+ } | {
57
+ readonly at: "root";
58
+ } | {
59
+ readonly at: "unanchored";
60
+ readonly roots: readonly string[];
61
+ };
76
62
  /** Where an absolute location LEADS in one environment — resolved the way the read and write faces mint their keys
77
63
  * (`canonicalizeTarget`: the longest existing prefix resolved, the rest rejoined). `undefined` when the environment
78
64
  * does not answer (a refused or failed probe, one that throws). The one resolution a deny row's placement reads: a
79
- * home-anchored row's head ({@link readDenyHomeLinksOf}) and a rule row's head ({@link whereItsAnsweredPrefixLeads}). */
65
+ * deny row's head ({@link readDenyLinksOf}) and a rule row's head ({@link whereItsAnsweredPrefixLeads}). */
80
66
  export declare function whereItLeads(env: ExecutionEnv, at: string, family?: PathFamily, signal?: AbortSignal): Promise<string | undefined>;
81
67
  /** {@link whereItLeads} with a floor: where the environment does not answer for `at` (a probe that fails), the longest
82
68
  * prefix it does answer for is resolved and the rest rejoined — a rule row's head below a base that resolves is never
@@ -150,13 +136,13 @@ export declare function carryHomeViews<T extends object>(judge: T, source: HomeV
150
136
  * · the HOME SET — `homes` when the mount carries a list (the account is not asked and no home is added), else the
151
137
  * declared home and the account lookup's answer ({@link declaredReadDenyHomes}); every home of the set is anchored at
152
138
  * its spelling and, where the environment answered one, its canonical spelling — one rule for both forms;
153
- * · the DECLARED home's canonical spelling under the tree's gate bound, and its rows' heads ({@link readDenyHomeLinksOf}):
139
+ * · the DECLARED home's canonical spelling under the tree's gate bound, and its rows' heads ({@link readDenyLinksOf}):
154
140
  * a declared home, or a head under it, that did not answer leaves the placement not WHOLE — and an account lookup
155
141
  * with no answer, or a declared home that did not answer, places nothing: the rows are held anywhere (`compile([])`)
156
142
  * rather than at a spelling that may miss the home's canonical one;
157
143
  * · each AUXILIARY home (see the module head) read once under {@link AUXILIARY_HOME_PROBE_MS} — its spellings, its
158
144
  * chain, its rows' heads — at the same time; whatever of it did not answer costs that home alone and never `whole`;
159
- * · the ROOTED rows' heads ({@link readDenyRootLinksOf}), read whether or not a home answered: a head that did not answer
145
+ * · the ROOTED rows' heads ({@link readDenyLinksOf}), read whether or not a home answered: a head that did not answer
160
146
  * leaves the placement not WHOLE, and a placement that held the rows anywhere still places them.
161
147
  * `compile` is the mount's own compile; the rows' patterns are read off its compile at no home. */
162
148
  export declare function placeReadDenyAtHome(env: ExecutionEnv, compile: (homes: readonly string[], linked?: ReadonlyMap<string, readonly string[]>) => ReadDenyMatcher, homes?: readonly string[], signal?: AbortSignal, configRoot?: string): Promise<{