@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,6 +1,6 @@
1
1
  import { delimitUntrusted } from "../../core/untrusted-text.js";
2
2
  import { MAX_EXEC_OUTPUT_BYTES } from "../../core/exec-output-tail.js";
3
- import { hasBinaryExtension, isAbsoluteForFamily, isWinFormPath, joinForFamily, pathFamilyOf } from "./safety.js";
3
+ import { anchorSpelling, hasBinaryExtension, isWinFormPath, pathFamilyOf } from "./safety.js";
4
4
  import { homeViewsOf } from "./read-deny-home.js";
5
5
  import { createEntryDenyJudge } from "./dir-entries.js";
6
6
  import { thrownText } from "../../core/thrown-value.js";
@@ -781,7 +781,7 @@ export async function jsGrepDetailed(env, root, p, signal, guards, deny, denyOut
781
781
  const ignore = await buildIgnore(env, root, signal);
782
782
  const rootPrefix = root.replace(/[\\/]+$/, "") + (root.includes("\\") ? "\\" : "/");
783
783
  const family = pathFamilyOf({ root });
784
- const start = p.path ? (isAbsoluteForFamily(family, p.path) ? p.path : joinForFamily(family, root, p.path)) : root;
784
+ const start = p.path ? anchorSpelling(family, root, p.path) : root;
785
785
  let walked;
786
786
  if (p.path) {
787
787
  const info = await env.fileInfo(start, signal);
@@ -1062,7 +1062,7 @@ async function sortRgFilesByMtime(env, root, records, signal) {
1062
1062
  const family = pathFamilyOf({ root });
1063
1063
  const toAbs = (p) => {
1064
1064
  const stripped = p.startsWith("./") ? p.slice(2) : p;
1065
- return isAbsoluteForFamily(family, stripped) ? stripped : joinForFamily(family, root, stripped);
1065
+ return anchorSpelling(family, root, stripped);
1066
1066
  };
1067
1067
  const paths = records.map((r) => r.path ?? r.text);
1068
1068
  const infos = await Promise.all(paths.map((p) => env.fileInfo(toAbs(p), signal)));
@@ -1148,8 +1148,10 @@ export function rgOutputDenyTripwire(stdout, mode, judge, opts = {}) {
1148
1148
  return { trip: false };
1149
1149
  }
1150
1150
  function rgRecordAbsolute(base) {
1151
- const family = base !== undefined ? pathFamilyOf({ root: base }) : undefined;
1152
- return (p) => (base === undefined || family === undefined || isAbsoluteForFamily(family, p) ? p : joinForFamily(family, base, p.replace(/^\.[\\/]/, "")));
1151
+ if (base === undefined)
1152
+ return (p) => p;
1153
+ const family = pathFamilyOf({ root: base });
1154
+ return (p) => anchorSpelling(family, base, p.replace(/^\.[\\/]/, ""));
1153
1155
  }
1154
1156
  async function rgOutputDenyTripwireAt(env, stdout, mode, deny, opts, signal) {
1155
1157
  const views = homeViewsOf(env, deny, signal);
@@ -1258,7 +1260,7 @@ export async function rgGrepDetailed(env, root, p, signal, deny) {
1258
1260
  if (deny === undefined || deny.rgExclusionGlobs.length === 0)
1259
1261
  return { note: "" };
1260
1262
  if (p.path) {
1261
- const startPath = isAbsoluteForFamily(pathFamilyOf({ root }), p.path) ? p.path : joinForFamily(pathFamilyOf({ root }), root, p.path);
1263
+ const startPath = anchorSpelling(pathFamilyOf({ root }), root, p.path);
1262
1264
  const info = await env.fileInfo(startPath, signal);
1263
1265
  if (info.ok && info.value.kind === "file")
1264
1266
  return { note: "" };
@@ -1333,7 +1335,7 @@ async function rgDenyExistenceProbe(env, root, deny, target, signal) {
1333
1335
  }
1334
1336
  }
1335
1337
  export async function runGrepDetailed(env, root, p, signal, deny) {
1336
- const scope = p.path ? (isAbsoluteForFamily(pathFamilyOf({ root }), p.path) ? p.path : joinForFamily(pathFamilyOf({ root }), root, p.path)) : root;
1338
+ const scope = p.path ? anchorSpelling(pathFamilyOf({ root }), root, p.path) : root;
1337
1339
  const unexcludableUnder = async () => {
1338
1340
  if (deny?.unexcludableUnder === undefined)
1339
1341
  return false;
@@ -1359,7 +1361,7 @@ export async function runGlobDetailed(env, root, pattern, opts = {}, signal) {
1359
1361
  const baseIgnore = await buildIgnore(env, root, signal);
1360
1362
  const rootPrefix = root.replace(/[\\/]+$/, "") + (root.includes("\\") ? "\\" : "/");
1361
1363
  const family = pathFamilyOf({ root });
1362
- const start = opts.path ? (isAbsoluteForFamily(family, opts.path) ? opts.path : joinForFamily(family, root, opts.path)) : root;
1364
+ const start = opts.path ? anchorSpelling(family, root, opts.path) : root;
1363
1365
  if (opts.path !== undefined) {
1364
1366
  const probe = await env.fileInfo(start, signal);
1365
1367
  if (!probe.ok && probe.error.code === "not_found") {
@@ -92,7 +92,7 @@ export function unlistedWords(reads, toks, from, launcherIndices, provenance, ct
92
92
  const noPathOperands = slotVerb !== undefined && opensNoOperand(slotVerb);
93
93
  const expanding = new Set();
94
94
  for (let j = from; j < toks.length; j++) {
95
- if (launcherIndices.has(j))
95
+ if (launcherIndices.has(j) || message.has(j))
96
96
  continue;
97
97
  if (noPathOperands && j > argvStart && !evaluatesOperands(slotVerb))
98
98
  break;
@@ -12,11 +12,13 @@
12
12
  * here-document `${`), and resets every name to the state it starts the text in (a function body: it runs at its
13
13
  * call, against that table);
14
14
  * · {@link BindingThread} — the effects threaded through the segments the way the plan threads the working directory
15
- * (`shell-read-plan.ts`): a value bound in a segment that may not have run before a reader (an `&&` / `||` run, a
16
- * branch, a loop body, a subshell, a pipeline member, a background job) joins the values the name held before
17
- * instead of replacing them. A function body runs at its call, which the plan does not follow (a function may be
18
- * called anywhere after its definition): a name the body binds is unreadable to every reader past the body, whatever
19
- * is assigned to it later, and to every reader in another body — unless the body declared it with a plain `local`.
15
+ * (`shell-read-plan.ts`), in their ORDERED state: a binding is one for a reader only where it may run before the
16
+ * reader in the same shell — not one written after it, inside a subshell the reader is not in (a closed `( … )`, a
17
+ * pipeline member that is not the last, a background job) or in a function body (it runs at a call: a call the plan
18
+ * sees makes every name a body binds unknown from there). A value bound in a segment that may not have run before
19
+ * a reader (an `&&` / `||` run, a branch, a loop body, the last pipeline member) joins the values the name held
20
+ * before instead of replacing them. A reader in a function body loses every name another body binds — unless the
21
+ * body declared it with a plain `local`. `PWD` / `OLDPWD` start from what the working-directory thread says.
20
22
  * An attribute and a name reference hold for every segment they may RUN before: a later one, one in a function body
21
23
  * (it runs at its call), one in the same loop body (a later beat).
22
24
  *
@@ -26,6 +28,7 @@
26
28
  */
27
29
  import { type LexedRedirect, type LexedSegment, type LexedToken, type LexedWord } from "../../shell/lex.js";
28
30
  import { type DeclaredAttribute } from "./program-read-model.js";
31
+ import { type BuiltinState } from "./shell-read-builtins.js";
29
32
  /** A value a name may hold — the text the program receives ({@link spelled}: what a shell re-parsing it reads), literal
30
33
  * throughout, or a PATTERN whose matches are the values (a `for` list word the shell globs before the loop binds it;
31
34
  * `spelled` is then the pattern as the program receives it where it matches nothing): `glob`, with its `parts` — the
@@ -66,8 +69,12 @@ export interface FloorValue {
66
69
  export declare function judgedSpellingOf(v: BoundValue): string | undefined;
67
70
  /** A value as a deny-floor spelling, its judged spelling with it. */
68
71
  export declare function floorOf(v: BoundValue): FloorValue;
69
- /** What a name holds at one point of a text: its possible values, or `"unknown"`. */
70
- type NameState = readonly BoundValue[] | "unknown";
72
+ /** The values a name may hold where the text settles it. */
73
+ export type NameValues = readonly BoundValue[];
74
+ /** What a name holds at one point of a text: its possible values, or `"unknown"`. (The values are a NAMED arm: the
75
+ * release manifest reads a union that spells a word as a vocabulary, and a `readonly …[]` arm beside the word is a shape
76
+ * it cannot enumerate — it would then publish the set unreadable.) */
77
+ export type NameState = NameValues | "unknown";
71
78
  /**
72
79
  * The variables bash keeps itself — it sets them (`PWD`, `REPLY`, `OPTARG`, `BASH_REMATCH`, …), holds them read-only
73
80
  * (`SHELLOPTS`, `BASHOPTS`, `BASH_VERSINFO`: an assignment to one is refused), or evaluates every value assigned to them
@@ -76,11 +83,32 @@ type NameState = readonly BoundValue[] | "unknown";
76
83
  * question, never a read). Their value is never the text that bound it.
77
84
  */
78
85
  export declare const SHELL_INTEGER_VARIABLES: ReadonlySet<string>;
79
- /** Is this a variable bash keeps itself ({@link SHELL_INTEGER_VARIABLES}, or one it sets)? */
86
+ /** Is this a variable bash keeps itself ({@link SHELL_INTEGER_VARIABLES}, or one it sets)? The working-directory names
87
+ * ({@link WORKING_DIRECTORY_NAMES}) are not: their value is the working-directory thread's ({@link WorkingDirectoryState}). */
80
88
  export declare function shellKeepsName(name: string): boolean;
81
- /** One binding a segment makes: a name and what it now holds (`unknown` = made unknown). `prefix`: a prefix assignment
82
- * to a special builtin, which may or may not outlive the command. `loopVar`: a `for` loop's variable, held through
83
- * its body. */
89
+ /** The names bash sets when the working directory moves: `PWD` (where the shell stands, as the move spelled it) and
90
+ * `OLDPWD` (the `PWD` it stood in before the last move — `cd -` goes there). A text may assign them too. */
91
+ export declare const WORKING_DIRECTORY_NAMES: readonly ["PWD", "OLDPWD"];
92
+ export type WorkingDirectoryName = (typeof WORKING_DIRECTORY_NAMES)[number];
93
+ /** What the working-directory thread (`shell-read-plan.ts`) says the two names hold at one segment, before anything the
94
+ * text assigns them: the bases it may stand in (`PWD`) and the ones it stood in before its last move (`OLDPWD`) —
95
+ * `unknown` where it lost track, the move's spelling is not the base (a physical move), or the shell inherited it. */
96
+ export type WorkingDirectoryState = {
97
+ readonly [K in WorkingDirectoryName]: NameState;
98
+ } & {
99
+ /** The last segment before the reader whose move the thread applied or lost track at (-1: none in this text). */
100
+ readonly movedAt: number;
101
+ };
102
+ /** The POSIX special builtins: a prefix assignment to one stays after it, and one runs before a function of its name
103
+ * (in POSIX mode, which an inherited environment can turn on unseen). */
104
+ export declare const SPECIAL_BUILTINS: ReadonlySet<string>;
105
+ export declare const functionKey: (name: string) => string;
106
+ /** What a function name is at a reader: `defined` — it certainly is one; `absent` — it certainly is not; `maybe` — a branch,
107
+ * a loop, a body that may not have run, a removal that may not have found it. */
108
+ export type FunctionState = "defined" | "maybe" | "absent";
109
+ /** One binding a segment makes: a name and what it now holds (`unknown` = made unknown). `prefix`: a binding that may or
110
+ * may not take effect (a prefix assignment to a special builtin, which may or may not outlive its command; an `unset` of a
111
+ * function, which a read-only function refuses). `loopVar`: a `for` loop's variable, held through its body. */
84
112
  export interface Binding {
85
113
  readonly name: string;
86
114
  readonly state: NameState;
@@ -116,9 +144,9 @@ export interface BindingEffect {
116
144
  /** How one value word reads against the table, the earlier assignments of the same segment applied (bash assigns left
117
145
  * to right): its possible values, or `unknown`. */
118
146
  export type ValueReader = (word: Pick<LexedWord, "pieces">, quoted: boolean, overlay: ReadonlyMap<string, NameState>) => NameState;
119
- /** The segment's shape the effect needs beside its words: a function definition head was dropped from it. */
147
+ /** The segment's shape the effect needs beside its words: the functions whose definition heads were dropped from it. */
120
148
  export interface SegmentShape {
121
- readonly definesFunction: boolean;
149
+ readonly defines: readonly string[];
122
150
  }
123
151
  /** The argv projection of a lexed segment: structure that names nothing that runs here is dropped — a subshell
124
152
  * parenthesis, a bare `{` / `}`, a function definition's head (`NAME ()`, and `function NAME [()]` with a name of
@@ -134,9 +162,9 @@ export declare function projectSegment(segment: LexedSegment): ProjectedSegment;
134
162
  * `NAME ( )` ({@link isDefinitionName}), and `function NAME [( )]` — a bare `function` at command position, a name of any
135
163
  * spelling. The lexer puts the body's compound command back at command position after the head, so a definition
136
164
  * nested in a body is dropped the same way; after a drop the token that moved up is looked at again. Answers where the
137
- * heads stood: entry `k` counts the heads dropped right before the token now at `k` (the last entry, past the last
138
- * token, a head whose body opens in a later segment). */
139
- export declare function dropDefinitionHeads(tokens: LexedToken[]): readonly number[];
165
+ * heads stood: entry `k` names the functions whose heads were dropped right before the token now at `k` (the last entry,
166
+ * past the last token, a head whose body opens in a later segment). */
167
+ export declare function dropDefinitionHeads(tokens: LexedToken[]): readonly (readonly string[])[];
140
168
  /**
141
169
  * What a word holds through the names it refers to — `$NAME`, `${NAME}`, a leading `~` (the value of `HOME`): `undefined`
142
170
  * where it refers to no name (it reads as written), else {@link valueOf}. `table.stateOf` is read after `overlay` (the
@@ -175,8 +203,12 @@ export declare function loopListHeadAt(argv: readonly LexedWord[]): number | und
175
203
  /**
176
204
  * What ONE segment does to the names (see the module header). `argv` = the segment's argv projection (structure
177
205
  * dropped); `readValue` folds a value word against the table (a reader that answers `unknown` gives the names alone).
206
+ * `shadow`: the word the shell looks up first is a function of the text where the segment stands (`named`: it is one, the
207
+ * builtin of its name does not run — the call's effect is the body's; `maybe`: it may be one, so what the builtin binds is one
208
+ * more value its names may hold). `availability`: whether the builtin of a name runs by it where the segment stands
209
+ * ({@link BuiltinState}) — `disabled`: the word finds no command and binds nothing, `maybe`: as a function that may stand.
178
210
  */
179
- export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader): BindingEffect;
211
+ export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader, shadow?: "named" | "maybe", availability?: (builtin: string) => BuiltinState): BindingEffect;
180
212
  /**
181
213
  * The names an ARITHMETIC text may assign: every identifier in a text that carries an assignment operator (`=` that is no
182
214
  * comparison, `+=` and its kin, `++`, `--`) — read whole, not parsed: a name only compared there is made unknown too.
@@ -203,7 +235,19 @@ export interface InheritedNames {
203
235
  /** The deny floors a name starts the text with ({@link BindingTable.floorOf}): what the words handing it this text as
204
236
  * written may name there — or, for a substitution body, the floors its segment reads. */
205
237
  readonly floors?: ReadonlyMap<string, readonly FloorValue[]>;
238
+ /** The names something before the nested text may have changed — a change that can reach where it starts, and the
239
+ * names its own segment's command environment sets (`TMPDIR=… bash -c …`): there such a name no longer holds what the
240
+ * shell provides ({@link BindingTable.providedByShell}). `all`: any name. Absent: none. */
241
+ readonly rebound?: ReadonlySet<string> | "all";
242
+ }
243
+ /** The function and builtin keys of the shell a text runs in — a literal `eval` text, a substitution body (a fork): what each key
244
+ * holds where the text starts (the outer table's answer for it), and the names a call to one of the outer functions may change. */
245
+ export interface InheritedFunctions {
246
+ readonly start: (key: string) => NameState;
247
+ readonly bound: ReadonlySet<string> | "all";
206
248
  }
249
+ /** Two rebound sets as one. */
250
+ export declare function joinRebound(a: ReadonlySet<string> | "all" | undefined, b: Iterable<string> | "all" | undefined): ReadonlySet<string> | "all";
207
251
  /** What the thread answers for one reader: what a name may hold, and whether a name carries the integer attribute. */
208
252
  export interface BindingTable {
209
253
  stateOf(name: string): NameState;
@@ -217,6 +261,16 @@ export interface BindingTable {
217
261
  floorOf(name: string): readonly FloorValue[];
218
262
  /** What a substitution body here starts with. */
219
263
  readonly inherited: InheritedNames;
264
+ /** The names a change that can reach this point touched — a binding, or a name made unknown, that may run before it in
265
+ * this shell (the thread's order: {@link BindingThread}) — and the names its start says were rebound; `all`: any. */
266
+ readonly rebound: ReadonlySet<string> | "all";
267
+ /** Does this name still hold what the shell provides here: no change that can reach this point touched it? */
268
+ providedByShell(name: string): boolean;
269
+ /** What a function of this name is here: the one ordered rule that answers a variable's value answers it
270
+ * ({@link FunctionState}). A name the text never defines is `absent` to the caller's own filter, not to this thread. */
271
+ functionState(name: string): FunctionState;
272
+ /** Whether the builtin of this name runs by it here: the same ordered rule ({@link BuiltinState}). */
273
+ builtinState(name: string): BuiltinState;
220
274
  }
221
275
  /**
222
276
  * The effects of a text's segments, threaded the way the plan threads its working directory: a reader at segment `j`
@@ -226,11 +280,16 @@ export interface BindingTable {
226
280
  * assignment, and — reached through `&&` / `||` — it lies in `j`'s own `&&` run (`andRunStart`: the same index the
227
281
  * working-directory thread reads).
228
282
  *
229
- * A function body runs at its call, and the plan does not follow calls (a function may be called anywhere after its
230
- * definition — through a wrapper word, `eval`, `trap`, `source`, another function): a name bound in a body is
231
- * {@link Unreadable} to every reader past the body, a later assignment included, and to every reader in another body;
232
- * the body's own readers follow its own order. A name the body declares with a plain `local` (before the binding,
233
- * where the declaration certainly ran) never leaves it.
283
+ * A binding exists for a reader only where it may run before the reader IN THE SAME SHELL — the ordered state: one
284
+ * written after the reader, one inside a subshell the reader is not in (a `( … )` group that closed before it, a
285
+ * pipeline member that is not the last, a background job — a substitution body is a text of its own) and one in a
286
+ * function body is NOT a binding for it. A function body runs at its call: a call the plan can see (a program word
287
+ * naming one of the text's functions, a code body a builtin runs later, which may name one) makes every name a body
288
+ * binds unknown from that segment on ({@link functionBound}); a text the plan does not read (`eval`, `source`, a
289
+ * computed program word) already makes every name unknown. The last member of a pipeline may or may not run in this
290
+ * shell: its bindings join the values before them. A body's own readers follow its own order; a reader in another body
291
+ * loses a name any other body binds ({@link Unreadable}). A name the body declares with a plain `local` (before the
292
+ * binding, where the declaration certainly ran) never leaves it.
234
293
  *
235
294
  * An attribute ({@link NameAttribute}) and a name reference hold for every segment they may RUN before — a later one,
236
295
  * one in a function body, one in the same loop body: an assignment there binds something other than its text.
@@ -248,7 +307,11 @@ export declare class BindingThread {
248
307
  /** `HOME` may already hold something other than the declared home where the text starts (a substitution body
249
308
  * inside a text that bound it). */
250
309
  private readonly homeStartsTouched;
310
+ /** The functions the shell that runs this text (a literal `eval` text) already holds. */
311
+ private readonly inheritedFunctions?;
251
312
  private readonly entries;
313
+ /** The `local` declarations the walk applied as certain ({@link apply}), each where it stands. */
314
+ private readonly localDeclarations;
252
315
  /** The attributes the text gives ({@link BindingEffect.attributes}), and where — read off its names alone, before any
253
316
  * reader: one given later in the text may run first. */
254
317
  private readonly attributesAt;
@@ -256,10 +319,15 @@ export declare class BindingThread {
256
319
  private readonly unreadable;
257
320
  /** The block nesting each segment moves ({@link blockStructure}). */
258
321
  private readonly blocks;
259
- /** Segments that are a pipeline member or run in the background. */
260
- private readonly detached;
322
+ /** Segments that END in a pipe or a `&`: the command that closes them is a pipeline member that is not the last, or a
323
+ * background job — a subshell of its own ({@link ownSubshellAt}: which of the segment's bindings that is). */
324
+ private readonly ownSubshell;
261
325
  /** The floors the names start the text with ({@link InheritedNames.floors}). */
262
326
  private readonly startFloors;
327
+ /** The names rebound where the text starts ({@link InheritedNames.rebound}). */
328
+ private readonly startRebound;
329
+ /** Where a function body runs ({@link runsBodies}): the last segment that can call one, and the command environment of each call. */
330
+ private bodyRuns;
263
331
  constructor(segments: readonly LexedSegment[],
264
332
  /** What each segment binds, its names alone (a value is the reader's to read). */
265
333
  named: readonly BindingEffect[],
@@ -273,31 +341,96 @@ export declare class BindingThread {
273
341
  * inside a text that bound it). */
274
342
  homeStartsTouched?: boolean,
275
343
  /** What holds where the text starts: given before its first segment. */
276
- inherited?: InheritedNames);
344
+ inherited?: InheritedNames,
345
+ /** The functions the shell that runs this text (a literal `eval` text) already holds. */
346
+ inheritedFunctions?: InheritedFunctions | undefined);
277
347
  /** What a text nested at segment `j` starts with ({@link InheritedNames}) — `j` absent: a text run later, which every
278
- * segment may run before. */
348
+ * segment may run before (in whatever shell: a later text may run inside a subshell or a body, so every change
349
+ * counts). */
279
350
  inheritedAt(j?: number): InheritedNames;
280
- /** What segment `at` makes unreadable: in a function body, the names it binds (unless the body declared them `local`
281
- * where the declaration certainly ran) — every name where it may bind any; a name reference, every name. */
351
+ /** What a name holds where the text starts: a function name unbound, a builtin enabled (what the shell around an `eval` text, a
352
+ * substitution body or a text run later holds, if it says); a variable as the plan says. */
353
+ private startOf;
354
+ /** Does any segment of this text bind the name (or every name)? */
355
+ private bindsInText;
356
+ /** What a text this one runs at some later point (a `trap` action) finds each function and builtin key: the point is not ordered
357
+ * against the segments (it may fire after any of them, inside any body or subshell), so a key holds what the text starts it with
358
+ * and every value any segment binds it ({@link InheritedFunctions}). */
359
+ heldAnywhere(): InheritedFunctions;
360
+ /** Tell the thread where function bodies run: `runs[si]` — segment `si` may run one (a call, a text the plan does not
361
+ * read); `atEnd` — a code body may run at the text's end or at any point (`trap`); `environment[si]` — what a call's own
362
+ * command environment sets. A call inside a loop may run again after a later segment of the loop. The last run point
363
+ * bounds what can precede a body: a binding after it never does. A name a body that makes a call binds — `local` too:
364
+ * the shell's scope is dynamic, the callee runs inside it — is unreadable to a reader in any other body. */
365
+ runsBodies(runs: readonly boolean[], atEnd: boolean, environment: readonly (ReadonlySet<string> | "all" | undefined)[]): void;
366
+ /** The names a reader that runs LATER than it stands may find rebound by segments after it: a reader in a function body
367
+ * runs at each call, so every segment up to the last run point (and a call's own command environment) may run before it;
368
+ * a text handed to run later (`j` absent) at any point. A reader that runs where it stands has none: the effects the walk
369
+ * has applied so far are the ones that precede it. A `local` counts like any binding: it shortens a name's life, not the
370
+ * view of a reader that runs inside its extent (a body called from there, a `trap` text it sets). */
371
+ private boundLater;
372
+ /** Does a binding segment `at` makes, standing at `standing`, run in a subshell of its own — a pipeline member that is
373
+ * not the last, a background job? A segment's closing pipe or `&` ends ITS LAST command, at the depth that command
374
+ * stands: a binding that stands shallower (a function definition's head, in front of the block its body opens in the
375
+ * same segment: `f(){ ls | head; … }`) is not that member — the pipe closes a command inside the body, and the
376
+ * definition is the shell's own. */
377
+ private ownSubshellAt;
378
+ /** Is a binding segment `at` makes one no later reader may count on as certain: made in a pipeline member (it follows a
379
+ * `|`, or it is {@link ownSubshellAt}) or a background job? */
380
+ private detachedAt;
381
+ /** Can a binding segment `at` makes exist for a reader at segment `j` (`j` absent: a reader at the text's end, outside
382
+ * every body and subshell)? Not where `at` stands in a function body the reader is not in (the body runs at its call),
383
+ * runs in a subshell of its own (a pipeline member that is not the last, a background job), or stands in a `( … )`
384
+ * group the reader is not in. */
385
+ private visible;
386
+ /** Where the binding `name` of segment `at` is made: the segment's own place, or — a function definition — where its head
387
+ * stands. */
388
+ private standingOf;
389
+ /** The names any of the text's function bodies binds — what a call to one of them may change — or `all` where a body
390
+ * may bind any name. A name the body keeps `local` ({@link leavesBody}) stays in it. */
391
+ functionBound(): ReadonlySet<string> | "all";
392
+ /** The function body a binding segment `at` makes belongs to, where the name can outlive it: the body it stands in — a
393
+ * plain `local NAME` is the body's own and never leaves it (an optioned declaration, `declare -g` / `local -p`, reads no
394
+ * scope, so it can). What a reader in ANOTHER body loses ({@link unreadableBy}); a call to the body changes it unless a
395
+ * declaration the body certainly ran covers the name ({@link functionBound}). */
396
+ private bodyBinding;
397
+ /** Does segment `at` stand in a function body (it runs at a call, not here)? */
398
+ inFunctionBody(at: number): boolean;
399
+ /** Does segment `at` run in a subshell (a `( … )` group, a pipeline member that is not the last, a background job) or a
400
+ * function body — whatever it changes, the shell that runs the next segment may not see? */
401
+ runsApart(at: number): boolean;
402
+ /** Segment `at` hands this shell a body it runs at ANY later point (a `trap` action, an alias value): every name the
403
+ * body may bind (`all`: any) is unreadable to every reader after `at`, whatever is assigned to it in between. */
404
+ runsLater(at: number, names: ReadonlySet<string> | "all"): void;
405
+ /** What segment `at` makes unreadable: in a function body, the names it binds (a plain `local` stays in it) — every name
406
+ * where it may bind any; a name reference, every name. Read before any segment is applied, so it does not ask which
407
+ * declarations certainly ran: a name a body assigns after its own `local` is lost to a reader in another body all the same
408
+ * (more questions, never fewer). */
282
409
  private unreadableBy;
283
410
  /** May segment `x` run before segment `e` runs (`x` being `e`: before a later run of it): `x` comes first in the text,
284
411
  * `e` stands in a function body (the body runs at its call, after any segment, and may run again), or both stand in
285
412
  * one loop's body (a later beat runs `x` again first). */
286
413
  private mayRunBefore;
287
- /** Did the body certainly declare this name `local` before segment `at`: an earlier segment of the body, run on its
288
- * own (no `&&` / `||`, no pipeline member or background job), in a block still open at `at`. */
414
+ /** Did the body certainly declare this name `local` before segment `at`: an earlier segment of the body, run on its own
415
+ * (no `&&` / `||`, no pipeline member or background job), in a block still open at `at`, whose declaration the walk
416
+ * APPLIED as certain — the shell ran its word as the builtin: no function of that name standing, no launcher, path or
417
+ * redirection in the way, and the builtin enabled where the body runs (what {@link bindingEffectOf} concluded, the ordered
418
+ * state of {@link BindingTable.functionState} and {@link BindingTable.builtinState}; recorded by {@link apply}). */
289
419
  private declaredLocal;
290
- /** Does the block that holds segment `at`'s words stay open (no closing word, no switch of branch) through `j`? */
420
+ /** Does the block that holds a binding's words stay open (no closing word, no switch of branch) through `j`? */
291
421
  private heldThrough;
292
422
  /** Apply segment `at`'s effect. `andRun`: the segment was reached through `&&` / `||`. `loopEnd`: for a loop variable,
293
423
  * the index of the loop's end. */
294
424
  apply(at: number, effect: BindingEffect, andRun: boolean, loopEnd?: number): void;
295
- /** Has the function body a binding at segment `at` was made in closed by segment `j`? */
296
- private leftBody;
297
- /** Make these names unknown from segment `at` on (a loop body that binds them may have run before any of its beats). */
425
+ /** Does a reader at segment `j` lose the name `u` makes unreadable: past a name reference it may run after, or in a
426
+ * function body other than the one that binds it? */
427
+ private lostAt;
428
+ /** Make these names unknown from segment `at` on (a loop body that binds them may have run before any of its beats; a
429
+ * call runs a body that binds them). */
298
430
  kill(at: number, names: Iterable<string> | "all"): void;
299
- /** The table a reader at segment `j` sees; `andRunStart` = the first segment of `j`'s `&&` run. */
300
- tableAt(j: number, andRunStart: number): BindingTable;
431
+ /** The table a reader at segment `j` sees; `andRunStart` = the first segment of `j`'s `&&` run; `where` = what the
432
+ * working-directory thread says `PWD` / `OLDPWD` hold there (absent: it does not say — both unknown). */
433
+ tableAt(j: number, andRunStart: number, where?: WorkingDirectoryState): BindingTable;
301
434
  }
302
435
  /** A segment that opens with `((`: an arithmetic command (or a subshell in a subshell — the tokens are the same). */
303
436
  export declare function isArithmeticCommand(segment: LexedSegment): boolean;
@@ -322,4 +455,3 @@ export declare function arithmeticSubstitutions(text: string, table: BindingTabl
322
455
  }): string[];
323
456
  /** The text of every `[…]` subscript in an arithmetic text (nested brackets balanced; an unclosed one runs to the end). */
324
457
  export declare function subscriptsOf(text: string): string[];
325
- export {};