@llblab/pi-kit 0.38.3 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +2 -2
  3. package/node_modules/@llblab/pi-actors/AGENTS.md +108 -20
  4. package/node_modules/@llblab/pi-actors/BACKLOG.md +207 -4
  5. package/node_modules/@llblab/pi-actors/CHANGELOG.md +13 -0
  6. package/node_modules/@llblab/pi-actors/README.md +31 -1
  7. package/node_modules/@llblab/pi-actors/dist/index.js +1 -1
  8. package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +37 -0
  9. package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +131 -62
  10. package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +2 -0
  11. package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +3 -2
  12. package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +37 -0
  13. package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +263 -129
  14. package/node_modules/@llblab/pi-actors/dist/lib/execution-files.d.ts +32 -0
  15. package/node_modules/@llblab/pi-actors/dist/lib/execution-files.js +128 -0
  16. package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +5 -4
  17. package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +19 -1
  18. package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +62 -26
  19. package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +4 -1
  20. package/node_modules/@llblab/pi-actors/dist/lib/execution.js +6 -1
  21. package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +9 -2
  22. package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +92 -14
  23. package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +21 -2
  24. package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +2 -2
  25. package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +25 -7
  26. package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +562 -262
  27. package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -10
  28. package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +80 -91
  29. package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +1 -0
  30. package/node_modules/@llblab/pi-actors/dist/lib/limits.js +1 -0
  31. package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +15 -1
  32. package/node_modules/@llblab/pi-actors/dist/lib/observability.js +216 -99
  33. package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +5 -4
  34. package/node_modules/@llblab/pi-actors/dist/lib/pi.js +64 -10
  35. package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.d.ts +18 -0
  36. package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.js +220 -0
  37. package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +2 -0
  38. package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +30 -6
  39. package/node_modules/@llblab/pi-actors/dist/lib/registry.js +270 -36
  40. package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.d.ts +213 -5
  41. package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.js +1909 -40
  42. package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.d.ts +107 -0
  43. package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.js +412 -0
  44. package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +9 -2
  45. package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +283 -60
  46. package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +26 -1
  47. package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -2
  48. package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.d.ts +451 -0
  49. package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.js +2315 -0
  50. package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.d.ts +97 -0
  51. package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.js +368 -0
  52. package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +46 -7
  53. package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +78 -2
  54. package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +334 -2
  55. package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +4 -1
  56. package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.d.ts +80 -0
  57. package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.js +287 -0
  58. package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.d.ts +110 -0
  59. package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.js +282 -0
  60. package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +66 -1
  61. package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +349 -13
  62. package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.d.ts +73 -0
  63. package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.js +227 -0
  64. package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.d.ts +141 -0
  65. package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.js +292 -0
  66. package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +10 -1
  67. package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +36 -4
  68. package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.d.ts +46 -0
  69. package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.js +114 -0
  70. package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +34 -1
  71. package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +158 -26
  72. package/node_modules/@llblab/pi-actors/dist/lib/runs-results.d.ts +116 -0
  73. package/node_modules/@llblab/pi-actors/dist/lib/runs-results.js +518 -0
  74. package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +15 -2
  75. package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +148 -9
  76. package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.d.ts +95 -0
  77. package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.js +470 -0
  78. package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.d.ts +58 -0
  79. package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.js +92 -0
  80. package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +2 -0
  81. package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +44 -3
  82. package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +15 -1
  83. package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +337 -13
  84. package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.d.ts +105 -0
  85. package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.js +501 -0
  86. package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +1 -0
  87. package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +14 -3
  88. package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +22 -3
  89. package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +37 -0
  90. package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +59 -3
  91. package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +4 -1
  92. package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +14 -8
  93. package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +2 -4
  94. package/node_modules/@llblab/pi-actors/dist/lib/temp.js +4 -56
  95. package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +3 -0
  96. package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +13 -0
  97. package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +1 -0
  98. package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +110 -43
  99. package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +3 -0
  100. package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +18 -6
  101. package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +4 -1
  102. package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +126 -31
  103. package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +31 -3
  104. package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +311 -47
  105. package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +3 -0
  106. package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +29 -7
  107. package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +20 -0
  108. package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +192 -43
  109. package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +272 -194
  110. package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +14 -2
  111. package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +46 -2
  112. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +40 -0
  113. package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +55 -1
  114. package/node_modules/@llblab/pi-actors/docs/README.md +9 -1
  115. package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +84 -15
  116. package/node_modules/@llblab/pi-actors/docs/agent-experience.md +216 -0
  117. package/node_modules/@llblab/pi-actors/docs/async-runs.md +18 -2
  118. package/node_modules/@llblab/pi-actors/docs/composition-transport.md +103 -0
  119. package/node_modules/@llblab/pi-actors/docs/coordinator-delivery.md +204 -4
  120. package/node_modules/@llblab/pi-actors/docs/inspection.md +38 -2
  121. package/node_modules/@llblab/pi-actors/docs/output-projection-map.md +130 -0
  122. package/node_modules/@llblab/pi-actors/docs/releasing.md +19 -2
  123. package/node_modules/@llblab/pi-actors/docs/run-supervision.md +1622 -0
  124. package/node_modules/@llblab/pi-actors/docs/template-recipes.md +4 -0
  125. package/node_modules/@llblab/pi-actors/docs/windows-process-observation.md +248 -0
  126. package/node_modules/@llblab/pi-actors/index.ts +1 -1
  127. package/node_modules/@llblab/pi-actors/lib/async-runs.ts +164 -73
  128. package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +4 -2
  129. package/node_modules/@llblab/pi-actors/lib/command-templates.ts +287 -138
  130. package/node_modules/@llblab/pi-actors/lib/execution-files.ts +118 -0
  131. package/node_modules/@llblab/pi-actors/lib/execution-output.ts +4 -4
  132. package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +57 -27
  133. package/node_modules/@llblab/pi-actors/lib/execution.ts +8 -0
  134. package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +102 -12
  135. package/node_modules/@llblab/pi-actors/lib/file-state.ts +16 -2
  136. package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +2 -2
  137. package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +524 -261
  138. package/node_modules/@llblab/pi-actors/lib/inspector.ts +101 -130
  139. package/node_modules/@llblab/pi-actors/lib/limits.ts +1 -0
  140. package/node_modules/@llblab/pi-actors/lib/observability.ts +235 -116
  141. package/node_modules/@llblab/pi-actors/lib/pi.ts +59 -11
  142. package/node_modules/@llblab/pi-actors/lib/recipe-projection.ts +232 -0
  143. package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +27 -6
  144. package/node_modules/@llblab/pi-actors/lib/registry.ts +266 -36
  145. package/node_modules/@llblab/pi-actors/lib/run-delivery.ts +1737 -49
  146. package/node_modules/@llblab/pi-actors/lib/run-supervision.ts +411 -0
  147. package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +237 -73
  148. package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +73 -1
  149. package/node_modules/@llblab/pi-actors/lib/runs-context-exports.ts +1871 -0
  150. package/node_modules/@llblab/pi-actors/lib/runs-context-index.ts +372 -0
  151. package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +36 -18
  152. package/node_modules/@llblab/pi-actors/lib/runs-control.ts +297 -1
  153. package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +3 -1
  154. package/node_modules/@llblab/pi-actors/lib/runs-descendant-launches.ts +338 -0
  155. package/node_modules/@llblab/pi-actors/lib/runs-execution-evidence.ts +302 -0
  156. package/node_modules/@llblab/pi-actors/lib/runs-index.ts +345 -17
  157. package/node_modules/@llblab/pi-actors/lib/runs-native-launches.ts +270 -0
  158. package/node_modules/@llblab/pi-actors/lib/runs-outcomes.ts +377 -0
  159. package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +37 -4
  160. package/node_modules/@llblab/pi-actors/lib/runs-process-windows-mi.ts +113 -0
  161. package/node_modules/@llblab/pi-actors/lib/runs-process.ts +210 -34
  162. package/node_modules/@llblab/pi-actors/lib/runs-results.ts +601 -0
  163. package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +134 -10
  164. package/node_modules/@llblab/pi-actors/lib/runs-session-exports.ts +406 -0
  165. package/node_modules/@llblab/pi-actors/lib/runs-snapshot.ts +143 -0
  166. package/node_modules/@llblab/pi-actors/lib/runs-start.ts +44 -2
  167. package/node_modules/@llblab/pi-actors/lib/runs-status.ts +252 -10
  168. package/node_modules/@llblab/pi-actors/lib/runs-supervision.ts +394 -0
  169. package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +14 -3
  170. package/node_modules/@llblab/pi-actors/lib/runtime.ts +22 -3
  171. package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +76 -4
  172. package/node_modules/@llblab/pi-actors/lib/state-readers.ts +16 -7
  173. package/node_modules/@llblab/pi-actors/lib/temp.ts +3 -56
  174. package/node_modules/@llblab/pi-actors/lib/tools-access.ts +13 -0
  175. package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +110 -51
  176. package/node_modules/@llblab/pi-actors/lib/tools-local.ts +37 -24
  177. package/node_modules/@llblab/pi-actors/lib/tools-message.ts +120 -37
  178. package/node_modules/@llblab/pi-actors/lib/tools-response.ts +273 -50
  179. package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +31 -10
  180. package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +165 -42
  181. package/node_modules/@llblab/pi-actors/package.json +10 -6
  182. package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +272 -194
  183. package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +14 -2
  184. package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +46 -2
  185. package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +40 -0
  186. package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +55 -1
  187. package/node_modules/@llblab/pi-codex-usage/AGENTS.md +2 -2
  188. package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +6 -0
  189. package/node_modules/@llblab/pi-codex-usage/README.md +9 -5
  190. package/node_modules/@llblab/pi-codex-usage/lib/query.ts +229 -50
  191. package/node_modules/@llblab/pi-codex-usage/lib/usage.ts +9 -1
  192. package/node_modules/@llblab/pi-codex-usage/package.json +1 -1
  193. package/node_modules/yaml/LICENSE +13 -0
  194. package/node_modules/yaml/README.md +172 -0
  195. package/node_modules/yaml/bin.mjs +11 -0
  196. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  197. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  198. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  199. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  200. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  201. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  202. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  203. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  204. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  205. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  206. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
  207. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  208. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  209. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  210. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  211. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  212. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  213. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  214. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  215. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  216. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  217. package/node_modules/yaml/browser/dist/errors.js +57 -0
  218. package/node_modules/yaml/browser/dist/index.js +17 -0
  219. package/node_modules/yaml/browser/dist/log.js +11 -0
  220. package/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
  221. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  222. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  223. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  224. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  225. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  226. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  227. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  228. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  229. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  230. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  231. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  232. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  233. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  234. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  235. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  236. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  237. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  238. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  239. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  240. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  241. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  242. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  243. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  244. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  245. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  246. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  247. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  248. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  249. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  250. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  251. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  252. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  253. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  254. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  255. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  256. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  257. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  258. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  259. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  260. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  261. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  262. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  263. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  264. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  265. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  266. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  267. package/node_modules/yaml/browser/dist/util.js +11 -0
  268. package/node_modules/yaml/browser/dist/visit.js +233 -0
  269. package/node_modules/yaml/browser/index.js +5 -0
  270. package/node_modules/yaml/browser/package.json +3 -0
  271. package/node_modules/yaml/dist/cli.d.ts +8 -0
  272. package/node_modules/yaml/dist/cli.mjs +201 -0
  273. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  274. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  275. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  276. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  277. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  278. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  279. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  280. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  281. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  282. package/node_modules/yaml/dist/compose/composer.js +224 -0
  283. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  284. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  285. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  286. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  287. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  288. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  289. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  290. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  291. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  292. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  293. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  294. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  295. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  296. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  297. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  298. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  299. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  300. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  301. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  302. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  303. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  304. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  305. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  306. package/node_modules/yaml/dist/doc/Document.js +337 -0
  307. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  308. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  309. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  310. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  311. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  312. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  313. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  314. package/node_modules/yaml/dist/doc/directives.js +178 -0
  315. package/node_modules/yaml/dist/errors.d.ts +21 -0
  316. package/node_modules/yaml/dist/errors.js +62 -0
  317. package/node_modules/yaml/dist/index.d.ts +25 -0
  318. package/node_modules/yaml/dist/index.js +50 -0
  319. package/node_modules/yaml/dist/log.d.ts +3 -0
  320. package/node_modules/yaml/dist/log.js +19 -0
  321. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  322. package/node_modules/yaml/dist/nodes/Alias.js +118 -0
  323. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  324. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  325. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  326. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  327. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  328. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  329. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  330. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  331. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  332. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  333. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  334. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  335. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  336. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  337. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  338. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  339. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  340. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  341. package/node_modules/yaml/dist/options.d.ts +350 -0
  342. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  343. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  344. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  345. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  346. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  347. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  348. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  349. package/node_modules/yaml/dist/parse/cst.js +112 -0
  350. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  351. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  352. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  353. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  354. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  355. package/node_modules/yaml/dist/parse/parser.js +980 -0
  356. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  357. package/node_modules/yaml/dist/public-api.js +107 -0
  358. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  359. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  360. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  361. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  362. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  363. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  364. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  365. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  366. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  367. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  368. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  369. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  370. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  371. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  372. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  373. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  374. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  375. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  376. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  377. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  378. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  379. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  380. package/node_modules/yaml/dist/schema/tags.js +99 -0
  381. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  382. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  383. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  384. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  385. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  386. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  387. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  388. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  389. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  390. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  391. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  392. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  393. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  394. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  395. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  396. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  397. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  398. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  399. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  400. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  401. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  402. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  403. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  404. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  405. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  406. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  407. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  408. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  409. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  410. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  411. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  412. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  413. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  414. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  415. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  416. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  417. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  418. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  419. package/node_modules/yaml/dist/test-events.js +134 -0
  420. package/node_modules/yaml/dist/util.d.ts +16 -0
  421. package/node_modules/yaml/dist/util.js +28 -0
  422. package/node_modules/yaml/dist/visit.d.ts +102 -0
  423. package/node_modules/yaml/dist/visit.js +236 -0
  424. package/node_modules/yaml/package.json +97 -0
  425. package/node_modules/yaml/util.js +2 -0
  426. package/package.json +3 -3
  427. package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
  428. package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +0 -16
  429. package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +0 -57
  430. package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +0 -79
@@ -1,9 +1,167 @@
1
1
  /**
2
- * Public tool response formatting
3
- * Zones: compact text summaries, verbose JSON switching, next-action rendering
4
- * Owns model-facing response helpers shared by public tool execution paths
2
+ * Shared response formatting.
3
+ * Zones: compact text summaries, snapshot/literal rendering, JSON switching, next-action rendering.
4
+ * Owns model-facing formatting shared by tool and coordinator delivery paths.
5
+ * Excludes: evidence reads/admission, source visibility, clock measurement and lifecycle/delivery authority.
5
6
  */
7
+ import { Document, isScalar, visit } from "yaml";
6
8
  import * as Limits from "./limits.js";
9
+ function yamlMetadataText(value) {
10
+ const document = new Document(value, { version: "1.2", schema: "core", aliasDuplicateObjects: false });
11
+ // yaml's plain-key preference otherwise treats a leading BOM as document whitespace.
12
+ visit(document, { Pair(_key, pair) {
13
+ if (isScalar(pair.key) && typeof pair.key.value === "string" && pair.key.value.includes("\uFEFF"))
14
+ pair.key.type = "QUOTE_DOUBLE";
15
+ } });
16
+ return document.toString({ collectionStyle: "block", indent: 2, lineWidth: 0, directives: false,
17
+ defaultKeyType: "PLAIN", defaultStringType: "QUOTE_DOUBLE", doubleQuotedAsJSON: true });
18
+ }
19
+ /** Pure selected-metadata formatting, not admission or authority. */
20
+ export function renderYamlMetadata(value, byteBudget) {
21
+ // Execution ceiling, not a caller allowance. The caller still owns its smaller policy budget.
22
+ if (!Number.isSafeInteger(byteBudget) || byteBudget <= 0 || byteBudget > 49152)
23
+ return { state: "unavailable", reason: "budget_invalid" };
24
+ let remaining = byteBudget;
25
+ let reason = "metadata_invalid";
26
+ const active = new Set();
27
+ const charge = (bytes) => {
28
+ remaining -= bytes;
29
+ if (remaining >= 0)
30
+ return true;
31
+ reason = "metadata_too_large";
32
+ return false;
33
+ };
34
+ const string = (text) => {
35
+ if (text.length > remaining) {
36
+ reason = "metadata_too_large";
37
+ return false;
38
+ }
39
+ return text.isWellFormed() && charge(Buffer.byteLength(text, "utf8"));
40
+ };
41
+ const copy = (input, depth) => {
42
+ if (!charge(1))
43
+ return undefined;
44
+ if (typeof input === "string")
45
+ return string(input) ? { value: input } : undefined;
46
+ if (input === null || typeof input === "boolean")
47
+ return { value: input };
48
+ // Refuse -0 explicitly: default YAML numeric serialization would erase its sign.
49
+ if (typeof input === "number")
50
+ return Number.isFinite(input) && !Object.is(input, -0) ? { value: input } : undefined;
51
+ if (!input || typeof input !== "object")
52
+ return undefined;
53
+ // Small explicit supported-input ceiling protects the library's recursive AST/stringifier.
54
+ if (depth > 64 || active.has(input))
55
+ return undefined;
56
+ const array = Array.isArray(input), prototype = Object.getPrototypeOf(input);
57
+ if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
58
+ return undefined;
59
+ active.add(input);
60
+ const result = array ? [] : Object.create(null);
61
+ const length = array ? Object.getOwnPropertyDescriptor(input, "length") : undefined;
62
+ if (array && (!length || !Object.hasOwn(length, "value") || !Number.isSafeInteger(length.value) || length.value < 0))
63
+ return undefined;
64
+ if (array && length.value > remaining) {
65
+ reason = "metadata_too_large";
66
+ return undefined;
67
+ }
68
+ let count = 0;
69
+ // ownKeys is necessarily atomic reflection; descriptor/value walks stop at the budget.
70
+ for (const key of Reflect.ownKeys(input)) {
71
+ if (array && key === "length")
72
+ continue;
73
+ if (typeof key !== "string" || (array && key !== String(count)))
74
+ return undefined;
75
+ const descriptor = Object.getOwnPropertyDescriptor(input, key);
76
+ if (!descriptor || !Object.hasOwn(descriptor, "value") || !descriptor.enumerable)
77
+ return undefined;
78
+ if (!array && !string(key))
79
+ return undefined;
80
+ const child = copy(descriptor.value, depth + 1);
81
+ if (!child)
82
+ return undefined;
83
+ Object.defineProperty(result, key, { value: child.value, enumerable: true, configurable: true, writable: true });
84
+ count++;
85
+ }
86
+ if (array && count !== length.value)
87
+ return undefined;
88
+ active.delete(input);
89
+ return { value: result };
90
+ };
91
+ try {
92
+ if (!value || typeof value !== "object")
93
+ return { state: "unavailable", reason: "metadata_invalid" };
94
+ const copied = copy(value, 0);
95
+ if (!copied)
96
+ return { state: "unavailable", reason };
97
+ const text = yamlMetadataText(copied.value);
98
+ return Buffer.byteLength(text, "utf8") <= byteBudget ? { state: "available", text } : { state: "unavailable", reason: "metadata_too_large" };
99
+ }
100
+ catch {
101
+ return { state: "unavailable", reason: "metadata_invalid" };
102
+ }
103
+ }
104
+ export function formatMarkdownField(key, value, depth = 0) {
105
+ const indent = " ".repeat(depth);
106
+ return /[\r\n]/u.test(value)
107
+ ? `${indent}- ${key}:\n${indent} ${value.replaceAll(/\r\n|\r|\n/gu, newline => `${newline}${indent} `)}`
108
+ : `${indent}- ${key}: ${value}`;
109
+ }
110
+ export function formatInspectNextAction(target, view, verbose) {
111
+ return ["- next:", formatMarkdownField("tool", "inspect", 1), formatMarkdownField("target", target, 1),
112
+ formatMarkdownField("view", view, 1), ...(verbose === undefined ? [] : [formatMarkdownField("verbose", String(verbose), 1)])].join("\n");
113
+ }
114
+ export function formatLiteralBlock(value) {
115
+ let length = 3;
116
+ for (const run of value.matchAll(/`+/gu))
117
+ length = Math.max(length, run[0].length + 1);
118
+ const fence = "`".repeat(length);
119
+ return `${fence}text\n${value}\n${fence}`;
120
+ }
121
+ /** Pure formatting of already-admitted snapshots. DTO/schema validity is NOT source, timing, visibility or lifecycle authority. */
122
+ export function renderRunSnapshot(value, format = "text") {
123
+ const unavailable = (reason) => Object.freeze({ state: "unavailable", reason });
124
+ if (format !== "text" && format !== "json")
125
+ return unavailable("format_invalid");
126
+ if (!value || typeof value !== "object" || Array.isArray(value))
127
+ return unavailable("snapshot_invalid");
128
+ const fields = Object.create(null);
129
+ for (const key of ["kind", "run", "run_instance_id", "captured_at", "elapsed_ms", "status", "phase", "cwd", "evidence", "evidence_error"]) {
130
+ const field = Object.getOwnPropertyDescriptor(value, key);
131
+ if (!field) {
132
+ if (key !== "phase" && key !== "evidence_error")
133
+ return unavailable("snapshot_invalid");
134
+ continue;
135
+ }
136
+ if (!Object.hasOwn(field, "value"))
137
+ return unavailable("snapshot_invalid");
138
+ if (typeof field.value === "string" && field.value.length > Limits.RUN_DELIVERY_MODEL_MAX_BYTES)
139
+ return unavailable("snapshot_too_large");
140
+ fields[key] = field.value;
141
+ }
142
+ const { kind, run, run_instance_id, captured_at, elapsed_ms, status, phase, cwd, evidence, evidence_error } = fields;
143
+ const scalar = (text) => typeof text === "string" && text.length > 0 && Buffer.from(text).toString("utf8") === text;
144
+ const reference = (text) => scalar(text) && !/[\u0000-\u001f\u007f]/u.test(text);
145
+ if (evidence !== null && !reference(evidence))
146
+ return unavailable("snapshot_invalid");
147
+ if (kind !== "run_snapshot" || !scalar(run) || /[^A-Za-z0-9_.-]/u.test(run) || !scalar(run_instance_id) || /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u.test(run_instance_id) ||
148
+ !scalar(captured_at) || !Number.isSafeInteger(Date.parse(captured_at)) || new Date(Date.parse(captured_at)).toISOString() !== captured_at ||
149
+ typeof elapsed_ms !== "number" || !Number.isSafeInteger(elapsed_ms) || elapsed_ms < 0 || (status !== "running" && status !== "done" && status !== "failed") ||
150
+ (phase !== undefined && (status !== "running" || phase !== "stopping")) || !reference(cwd) ||
151
+ (evidence === null ? evidence_error !== "index_unavailable" : evidence_error !== undefined))
152
+ return unavailable("snapshot_invalid");
153
+ const snapshot = Object.freeze({ kind, run, run_instance_id, captured_at, elapsed_ms, status,
154
+ ...(phase === "stopping" ? { phase } : {}), cwd, evidence,
155
+ ...(evidence === null ? { evidence_error: "index_unavailable" } : {}) });
156
+ // Compact JSON preserves the same bounded payload without a second pretty-print allowance or implicit fallback.
157
+ const json = JSON.stringify(snapshot);
158
+ if (Buffer.byteLength(json, "utf8") > Limits.RUN_DELIVERY_MODEL_MAX_BYTES)
159
+ return unavailable("snapshot_too_large");
160
+ const text = format === "json" ? json
161
+ : `run:${snapshot.run} · ${snapshot.status}${snapshot.phase ? ` (${snapshot.phase})` : ""} · elapsed=${snapshot.elapsed_ms}ms\ngeneration:\n${formatLiteralBlock(snapshot.run_instance_id)}` +
162
+ `\ncaptured_at: ${snapshot.captured_at}\ncwd:\n${formatLiteralBlock(snapshot.cwd)}\nevidence:${snapshot.evidence === null ? " unavailable (index_unavailable)" : `\n${formatLiteralBlock(snapshot.evidence)}`}`;
163
+ return Buffer.byteLength(text, "utf8") > Limits.RUN_DELIVERY_MODEL_MAX_BYTES ? unavailable("render_too_large") : Object.freeze({ state: "available", text });
164
+ }
7
165
  export function withLeadingLineBreak(text) {
8
166
  return `\n${text.replace(/^\n+/, "")}`;
9
167
  }
@@ -58,22 +216,30 @@ export function compactNextActions(actions) {
58
216
  function formatFailureCount(value) {
59
217
  return Array.isArray(value) ? value.length : undefined;
60
218
  }
61
- function compactPolicyAxis(label, value) {
62
- const axis = asRecord(value);
63
- const source = typeof axis.source === "string" ? axis.source : undefined;
64
- if (!source || source === "unused")
65
- return undefined;
66
- const renderedValue = typeof axis.value === "string" && axis.value.trim()
67
- ? `:${axis.value.trim()}`
68
- : "";
69
- return `${label}=${source}${renderedValue}`;
219
+ function launchModelPolicy(value) {
220
+ const policy = asRecord(value), fields = {};
221
+ for (const key of ["model", "thinking"]) {
222
+ const axis = asRecord(policy[key]);
223
+ if (typeof axis.source !== "string" || !axis.source || axis.source === "unused")
224
+ continue;
225
+ const source = axis.source;
226
+ // Retain legacy coercion/error behavior for unstable getter-produced values.
227
+ formatMarkdownField("source", source, 1);
228
+ const selected = { source };
229
+ if (typeof axis.value === "string" && axis.value.trim()) {
230
+ const text = axis.value.trim();
231
+ formatMarkdownField("value", text, 1);
232
+ selected.value = text;
233
+ }
234
+ fields[key] = Object.values(selected).every(field => typeof field === "string" && field.isWellFormed())
235
+ ? selected : { state: "unavailable", reason: "metadata_invalid" };
236
+ }
237
+ return fields;
70
238
  }
71
- function compactModelPolicy(value) {
72
- const policy = asRecord(value);
73
- return [
74
- compactPolicyAxis("model", policy.model),
75
- compactPolicyAxis("thinking", policy.thinking),
76
- ].filter((token) => Boolean(token));
239
+ const RUN_FILE_INVESTIGATION_COMMAND = "inspect target=runtime view=runs verbose=true";
240
+ /** Frozen older completion-format text: new launch layout must not change this shared packet helper. */
241
+ export function formatRunFileNavigationHandoff() {
242
+ return `Files (optional; current session):\n\`${RUN_FILE_INVESTIGATION_COMMAND}\``;
77
243
  }
78
244
  export function runNextActions(run) {
79
245
  const id = String(run ?? "").trim();
@@ -83,49 +249,132 @@ export function runNextActions(run) {
83
249
  `inspect target=run:${id} view=recipe`,
84
250
  `inspect target=run:${id} view=trace`,
85
251
  `inspect target=run:${id} view=control`,
252
+ RUN_FILE_INVESTIGATION_COMMAND,
86
253
  ];
87
254
  }
88
255
  export function compactAsyncRunStatus(value) {
89
- const status = asRecord(value);
90
- const progress = asRecord(status.progress);
91
- const result = asRecord(status.result);
92
- const run = String(status.run ?? "<unknown>");
93
- const tokens = [`run=${run}`, `status=${String(status.status ?? "unknown")}`];
256
+ const status = asRecord(value), progress = asRecord(status.progress), result = asRecord(status.result);
257
+ const run = String(status.run ?? "<unknown>"), displayRun = run.startsWith("run:") ? run.slice(4) : run;
258
+ const core = { run: displayRun, state: String(status.status ?? "unknown") };
94
259
  if (status.launch_kind)
95
- tokens.push(`launch_kind=${String(status.launch_kind)}`);
96
- tokens.push(...compactModelPolicy(status.model_policy ?? progress.model_policy));
97
- if (status.tool)
98
- tokens.push(`tool=${String(status.tool)}`);
99
- if (status.recipe)
100
- tokens.push(`recipe=${String(status.recipe)}`);
101
- if (status.retire_when)
102
- tokens.push(`retire_when=${String(status.retire_when)}`);
260
+ core.launch_kind = String(status.launch_kind);
261
+ if (status.reused === true)
262
+ core.launch = "existing Run reused";
263
+ const catalog = asRecord(status.catalog_registration);
264
+ if (catalog.state === "unavailable" && catalog.reason === "catalog_registration_failed")
265
+ core.catalog = "unavailable";
266
+ const fields = { ...core, ...launchModelPolicy(status.model_policy ?? progress.model_policy) };
267
+ for (const key of ["tool", "recipe", "retire_when"])
268
+ if (status[key])
269
+ fields[key] = String(status[key]);
103
270
  if (Number(status.pid) > 0)
104
- tokens.push(`pid=${Number(status.pid)}`);
271
+ fields.pid = Number(status.pid);
105
272
  if (progress.phase && progress.phase !== status.status)
106
- tokens.push(`phase=${String(progress.phase)}`);
273
+ fields.phase = String(progress.phase);
107
274
  if (Number(progress.activeSubagents) > 0)
108
- tokens.push(`active=${Number(progress.activeSubagents)}`);
275
+ fields.active_subagents = Number(progress.activeSubagents);
109
276
  if (Number(progress.completed) > 0)
110
- tokens.push(`completed=${Number(progress.completed)}`);
277
+ fields.completed = Number(progress.completed);
111
278
  const failures = formatFailureCount(progress.failures);
112
279
  if (failures !== undefined && failures > 0)
113
- tokens.push(`failures=${failures}`);
114
- if (result.code !== undefined)
115
- tokens.push(`code=${String(result.code)}`);
280
+ fields.failures = failures;
281
+ if (result.code !== undefined) {
282
+ const code = result.code, text = String(code);
283
+ fields.code = typeof code === "number" || typeof code === "boolean" ? code : text;
284
+ }
116
285
  if (result.killed === true)
117
- tokens.push("killed=true");
118
- const draftRecipe = status.draft_recipe;
119
- if (draftRecipe)
120
- tokens.push(`draft_recipe=${String(draftRecipe)}`);
121
- const nextActions = runNextActions(run);
122
- if (nextActions.length > 0)
123
- tokens.push(`next=${nextActions.map((action) => action.replaceAll(/\s+/g, "_")).join("|")}`);
124
- return `\n${tokens.join(" ")}`;
286
+ fields.killed = true;
287
+ if (status.draft_recipe)
288
+ fields.draft_recipe = String(status.draft_recipe);
289
+ const hint = { file_investigation: "optional; current session", next: { tool: "inspect", target: "runtime", view: "runs", verbose: true } };
290
+ const hasNavigation = Object.hasOwn(status, "file_navigation");
291
+ let navigation;
292
+ if (hasNavigation) {
293
+ // Preserve the original JSON selection (including hooks and thrown errors), once only.
294
+ const json = JSON.stringify(status.file_navigation ?? { state: "unavailable", reason: "navigation_unavailable" });
295
+ if (json === undefined)
296
+ formatLiteralBlock(json);
297
+ navigation = JSON.parse(json);
298
+ }
299
+ const direct = hasNavigation && asRecord(status.file_navigation).state === "available" && asRecord(navigation).state === "available";
300
+ const budget = Limits.RUN_DELIVERY_MODEL_MAX_BYTES - 1;
301
+ const render = (metadata) => {
302
+ const rendered = renderYamlMetadata(metadata, budget);
303
+ return rendered.state === "available" ? withLeadingLineBreak(rendered.text) : undefined;
304
+ };
305
+ // Invalid selected scalars are unavailable whole values, never repaired strings/paths.
306
+ for (const group of [core, fields]) {
307
+ for (const key of Object.keys(group)) {
308
+ const field = group[key];
309
+ if ((typeof field === "string" && !field.isWellFormed()) ||
310
+ (typeof field === "number" && (!Number.isFinite(field) || Object.is(field, -0)))) {
311
+ group[key] = { state: "unavailable", reason: "metadata_invalid" };
312
+ }
313
+ }
314
+ }
315
+ // Validate only runtime-selected JSON facts, never walk the original navigation again.
316
+ const navigationRendering = hasNavigation ? renderYamlMetadata({ run_files: navigation }, budget) : undefined;
317
+ const invalidNavigation = navigationRendering?.state === "unavailable" && navigationRendering.reason === "metadata_invalid";
318
+ const locations = !hasNavigation ? {} : { run_files: invalidNavigation
319
+ ? { state: "unavailable", reason: "metadata_invalid" } : navigation,
320
+ run_files_observation: "Observed locations; mutable." };
321
+ const full = render({ ...fields, ...locations, ...(direct && !invalidNavigation ? {} : hint) });
322
+ if (full !== undefined)
323
+ return full;
324
+ const omitted = !hasNavigation ? {} : { run_files: { state: "omitted", reason: "response_too_large", shown: 0, omitted: 1, total: 1 } };
325
+ const withoutRow = render({ ...fields, ...omitted, ...hint });
326
+ if (withoutRow !== undefined)
327
+ return withoutRow;
328
+ // Keep the original fallback observation order; no rereads on successful full receipts.
329
+ const fallback = { ...core };
330
+ if (typeof status.run_instance_id === "string") {
331
+ const generation = status.run_instance_id;
332
+ formatMarkdownField("run_instance_id", generation);
333
+ fallback.run_instance_id = typeof generation === "string" && generation.isWellFormed()
334
+ ? generation : { state: "unavailable", reason: "metadata_invalid" };
335
+ }
336
+ if (Number(status.pid) > 0) {
337
+ const pid = Number(status.pid);
338
+ fallback.pid = Number.isFinite(pid) && !Object.is(pid, -0) ? pid : { state: "unavailable", reason: "metadata_invalid" };
339
+ }
340
+ const omission = { launch_fields: "omitted", launch_omission: "response_too_large" };
341
+ return render({ ...omission, ...fallback, ...omitted, ...hint }) ??
342
+ render({ ...omission, ...omitted, ...hint });
125
343
  }
126
344
  export function maybeJsonText(value, verbose, compact) {
127
345
  return verbose ? jsonText(value) : compact;
128
346
  }
347
+ function unavailableSpawnProjection(reason) {
348
+ return `projection: unavailable\nreason: ${reason}\nwarning: "Full metadata is not shown. Launch or attachment processing preceded this projection; this is not a workload-failure or no-effects receipt. Do not repeat automatically."\n`;
349
+ }
350
+ /** Full spawn metadata retains legacy JSON selection; projection is not launch or source authority. */
351
+ export function spawnMetadataText(value, verbose, compact) {
352
+ if (!verbose)
353
+ return compact;
354
+ // Original selection faults remain exact, outside the recoverable projection boundary.
355
+ const selected = JSON.stringify(value, null, 2);
356
+ if (selected === undefined)
357
+ return `\n${unavailableSpawnProjection("yaml_projection_failed")}`;
358
+ try {
359
+ const clone = JSON.parse(selected), pending = [clone];
360
+ // Only the JSON clone is walked; full metadata borrows no bounded emitter allowance.
361
+ while (pending.length) {
362
+ const current = pending.pop();
363
+ if (typeof current === "string" && !current.isWellFormed())
364
+ return `\n${unavailableSpawnProjection("malformed_selected_text")}`;
365
+ if (current && typeof current === "object")
366
+ for (const [key, child] of Object.entries(current)) {
367
+ if (!key.isWellFormed())
368
+ return `\n${unavailableSpawnProjection("malformed_selected_text")}`;
369
+ pending.push(child);
370
+ }
371
+ }
372
+ return `\n${yamlMetadataText(clone)}`;
373
+ }
374
+ catch {
375
+ return `\n${unavailableSpawnProjection("yaml_projection_failed")}`;
376
+ }
377
+ }
129
378
  export function compactRecipeImports(summary) {
130
379
  const active = Array.isArray(summary.active)
131
380
  ? summary.active
@@ -215,6 +464,16 @@ export function recipeRegistryNextActions(summary, view) {
215
464
  }
216
465
  return [...new Set(actions)].slice(0, 4);
217
466
  }
467
+ /** Only these existing read-only inspection hints become action nodes; other advice stays content. */
468
+ export function formatInspectionHint(action) {
469
+ if (action === "inspect target=recipes view=doctor")
470
+ return formatInspectNextAction("recipes", "doctor");
471
+ if (action === "inspect target=recipes view=imports verbose=true")
472
+ return formatInspectNextAction("recipes", "imports", true);
473
+ if (action === "inspect target=recipes view=summary verbose=true")
474
+ return formatInspectNextAction("recipes", "summary", true);
475
+ return formatMarkdownField("instruction", action);
476
+ }
218
477
  export function compactRecipeRegistry(summary) {
219
478
  const active = Array.isArray(summary.active) ? summary.active.length : 0;
220
479
  const shadowed = Array.isArray(summary.shadowed)
@@ -238,6 +497,11 @@ export function compactRecipeRegistry(summary) {
238
497
  const nextActions = Array.isArray(summary.next_actions)
239
498
  ? summary.next_actions
240
499
  : [];
241
- return `\nrecipes active=${active} drafts=${drafts} shadowed=${shadowed} invalid=${invalid} disabled=${disabled} current_policy=${currentPolicy} skill_catalog_partial=${skillCatalogPartial} recommendations=${recommendations} diagnostics=${diagnostics}${compactNextActions(nextActions)}`;
500
+ const fields = [formatMarkdownField("recipes", "registry"), ...Object.entries({ active, drafts, shadowed, invalid, disabled,
501
+ current_policy: currentPolicy, skill_catalog_partial: skillCatalogPartial, recommendations, diagnostics })
502
+ .map(([key, value]) => formatMarkdownField(key, String(value)))];
503
+ if (nextActions.length)
504
+ fields.push(formatInspectionHint(nextActions[0]));
505
+ return "\n" + fields.join("\n");
242
506
  }
243
507
  export const DEFAULT_INSPECT_LINES = Limits.DEFAULT_INSPECT_LINES;
@@ -3,11 +3,14 @@
3
3
  * Zones: actor launch, draft recipe capture, launch diagnostics
4
4
  * Owns the public spawn execution path for run-backed actors
5
5
  */
6
+ import * as AsyncRuns from "./async-runs.ts";
6
7
  import * as ModelContext from "./model-context.ts";
7
8
  import type * as RecipeResolution from "./recipes-context.ts";
8
9
  export interface SpawnToolContext extends ModelContext.CurrentModelContext {
9
10
  recipeResolutionContext?: RecipeResolution.RecipeResolutionContext;
10
11
  cwd: string;
12
+ /** Kernel-injected only; never sourced from tool input/actor values. */
13
+ onSupervisionClockCaptured?: AsyncRuns.AsyncRunStartOptions["onSupervisionClockCaptured"];
11
14
  sessionManager?: {
12
15
  getSessionId?: () => string;
13
16
  };
@@ -7,13 +7,15 @@ import { mkdirSync, writeFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import * as AsyncRuns from "./async-runs.js";
9
9
  import { withFileMutationLock } from "./file-state.js";
10
+ import * as Limits from "./limits.js";
10
11
  import * as ModelContext from "./model-context.js";
11
12
  import * as Paths from "./paths.js";
12
13
  import * as RecipesUsage from "./recipes-usage.js";
13
14
  import * as Schema from "./schema.js";
14
15
  import * as ToolsResponse from "./tools-response.js";
16
+ import { readRunFileNavigationForContext } from "./tools-access.js";
15
17
  const asRecord = ToolsResponse.asRecord;
16
- const maybeJsonText = ToolsResponse.maybeJsonText;
18
+ const spawnMetadataText = ToolsResponse.spawnMetadataText;
17
19
  function getRunOwnerId(ctx) {
18
20
  return ctx.sessionManager?.getSessionId?.();
19
21
  }
@@ -48,15 +50,34 @@ function writeSpawnDraftRecipe(input, meta) {
48
50
  RecipesUsage.recordRecipeLaunch(path, new Date(), "spawn", Paths.getRecipeRoot());
49
51
  return path;
50
52
  }
53
+ /** Compiler-owned pre-launch diagnostics only; selected caller values are not admitted Run ids. */
54
+ function spawnGuardText(kind, value) {
55
+ const field = ToolsResponse.formatMarkdownField;
56
+ const facts = kind === "state_dir"
57
+ ? [field("result", "unsupported field"), field("reason", "Run state is runtime-owned; run:<id> remains addressable and retention-safe.")]
58
+ : [field("result", kind === "namespace" ? "unsupported Run target" : "invalid Run target"), field("accepted_format", "run:<id>"),
59
+ ...(kind === "id" ? [field("id_rule", "nonempty ASCII letters, digits, underscore, dot or hyphen")] : [])];
60
+ const render = (selected) => ToolsResponse.withLeadingLineBreak([field("field", kind === "state_dir" ? "state_dir" : "as"), ...(selected === undefined ? [] : [selected]), ...facts].join("\n"));
61
+ if (value === undefined)
62
+ return render();
63
+ const wellFormed = value.isWellFormed();
64
+ if (wellFormed) {
65
+ const complete = render(field("value", value));
66
+ if (Buffer.byteLength(complete) <= Limits.RUN_DELIVERY_MODEL_MAX_BYTES)
67
+ return complete;
68
+ }
69
+ const reason = wellFormed ? "response_too_large" : "malformed_selected_text";
70
+ return render(`- value: [${reason === "response_too_large" ? "omitted" : "unavailable"}]\n- value_omission:\n - reason: ${reason}\n - shown: 0\n - omitted: 1\n - total: 1`);
71
+ }
51
72
  function runIdFromTarget(target) {
52
73
  if (!target)
53
74
  return undefined;
54
75
  if (!target.startsWith("run:")) {
55
- throw new Error(`spawn.as accepts only run:<id>; received: ${target}`);
76
+ throw new Error(spawnGuardText("namespace", `${target}`));
56
77
  }
57
78
  const run = target.slice(4);
58
79
  if (!run || !/^[A-Za-z0-9_.-]+$/.test(run)) {
59
- throw new Error(`invalid spawn Run target: ${target}`);
80
+ throw new Error(spawnGuardText("id", `${target}`));
60
81
  }
61
82
  return run;
62
83
  }
@@ -77,12 +98,12 @@ export function createSpawnToolDefinition() {
77
98
  ]),
78
99
  values: Schema.looseObjectSchema("Runtime placeholder values passed to the actor."),
79
100
  transport_context: Schema.looseObjectSchema("Optional originating transport route preserved for detached terminal follow-up, e.g. Telegram chat_id and thread_id."),
80
- verbose: Schema.booleanSchema("Return full JSON instead of compact text."),
101
+ verbose: Schema.booleanSchema("Return full YAML instead of compact text."),
81
102
  }, []),
82
103
  async execute(toolCallId, params, _signal, _onUpdate, ctx) {
83
104
  const input = asRecord(params);
84
105
  if (input.state_dir !== undefined) {
85
- throw new Error("spawn.state_dir is not supported; run state is runtime-owned so run:<id> remains addressable and retention-safe.");
106
+ throw new Error(spawnGuardText("state_dir"));
86
107
  }
87
108
  const runId = runIdFromTarget(typeof input.as === "string" ? input.as : undefined);
88
109
  const recipe = typeof input.file === "string"
@@ -111,11 +132,12 @@ export function createSpawnToolDefinition() {
111
132
  artifacts: input.artifacts,
112
133
  }
113
134
  : {}),
114
- }, ctx.cwd, { skillContext: ctx.recipeResolutionContext?.activeSkills });
135
+ }, ctx.cwd, { skillContext: ctx.recipeResolutionContext?.activeSkills, onSupervisionClockCaptured: ctx.onSupervisionClockCaptured });
115
136
  const draftRecipe = writeSpawnDraftRecipe(input, meta);
116
137
  const nextActions = ToolsResponse.runNextActions(meta.run);
117
138
  const details = {
118
139
  ...meta,
140
+ file_navigation: readRunFileNavigationForContext(meta, ctx),
119
141
  ...(draftRecipe ? { draft_recipe: draftRecipe } : {}),
120
142
  next_actions: nextActions,
121
143
  };
@@ -123,7 +145,7 @@ export function createSpawnToolDefinition() {
123
145
  content: [
124
146
  {
125
147
  type: "text",
126
- text: maybeJsonText(details, input.verbose === true, ToolsResponse.compactAsyncRunStatus(details)),
148
+ text: spawnMetadataText(details, input.verbose === true, ToolsResponse.compactAsyncRunStatus(details)),
127
149
  },
128
150
  ],
129
151
  details,
@@ -4,19 +4,39 @@
4
4
  * Owns public Trace items; source journals and session parsing remain in their domains.
5
5
  */
6
6
  import { type RunArtifactDeclaration } from "./runs-artifacts.ts";
7
+ import * as RunsTrace from "./runs-trace.ts";
7
8
  export type TraceSource = "lifecycle" | "control" | "process" | "agent" | "artifact" | "runtime";
8
9
  export type TraceSourceFilter = TraceSource | "all";
9
10
  export declare const TRACE_ITEM_SEQUENCE: unique symbol;
11
+ export declare const TRACE_ITEM_CHRONOLOGY: unique symbol;
12
+ export type TraceChronologyReason = "history_incomplete" | "control_history_unproven" | "metadata_unavailable" | "metadata_private" | "metadata_too_large" | "metadata_ambiguous" | "timestamp_unavailable";
13
+ export type TraceChronology = Readonly<{
14
+ basis: "recorded_observations";
15
+ } & ({
16
+ state: "available";
17
+ ordinal: number;
18
+ total: number;
19
+ } | {
20
+ state: "unavailable";
21
+ reason: TraceChronologyReason;
22
+ })>;
10
23
  export interface TraceItem {
11
24
  id: string;
12
25
  ts: string;
13
26
  [TRACE_ITEM_SEQUENCE]?: number;
27
+ [TRACE_ITEM_CHRONOLOGY]?: TraceChronology;
14
28
  source: TraceSource;
15
29
  kind: string;
16
30
  summary: string;
17
31
  level?: "info" | "warning" | "error";
18
32
  detail: unknown;
19
33
  }
34
+ /** Data-only canonical-journal projection; captured Recipe context supplies privacy, never lifecycle/work authority. */
35
+ export declare function projectRunTraceJournal(read: RunsTrace.RunTraceJournalRead, options?: {
36
+ limit?: number;
37
+ recipe?: Record<string, unknown>;
38
+ redactEvidence?: (value: unknown) => unknown;
39
+ }): TraceItem[];
20
40
  export declare function projectRunTrace(stateDir: string, options?: {
21
41
  artifacts?: Record<string, RunArtifactDeclaration>;
22
42
  limit?: number;