@llblab/pi-kit 0.38.4 → 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.
- package/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/node_modules/@llblab/pi-actors/AGENTS.md +108 -20
- package/node_modules/@llblab/pi-actors/BACKLOG.md +207 -4
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +13 -0
- package/node_modules/@llblab/pi-actors/README.md +31 -1
- package/node_modules/@llblab/pi-actors/dist/index.js +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +131 -62
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +3 -2
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +263 -129
- package/node_modules/@llblab/pi-actors/dist/lib/execution-files.d.ts +32 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-files.js +128 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +5 -4
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +19 -1
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +62 -26
- package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/execution.js +6 -1
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +9 -2
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +92 -14
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +21 -2
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +2 -2
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +25 -7
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +562 -262
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -10
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +80 -91
- package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.js +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +15 -1
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +216 -99
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +5 -4
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +64 -10
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.js +220 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +30 -6
- package/node_modules/@llblab/pi-actors/dist/lib/registry.js +270 -36
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.d.ts +213 -5
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.js +1909 -40
- package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.d.ts +107 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.js +412 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +9 -2
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +283 -60
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +26 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.d.ts +451 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.js +2315 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.d.ts +97 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.js +368 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +46 -7
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +78 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +334 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.d.ts +80 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.js +287 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.d.ts +110 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.js +282 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +66 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +349 -13
- package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.d.ts +73 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.js +227 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.d.ts +141 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.js +292 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +10 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +36 -4
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.d.ts +46 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.js +114 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +34 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +158 -26
- package/node_modules/@llblab/pi-actors/dist/lib/runs-results.d.ts +116 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-results.js +518 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +15 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +148 -9
- package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.d.ts +95 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.js +470 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.d.ts +58 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.js +92 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +44 -3
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +15 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +337 -13
- package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.d.ts +105 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.js +501 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +14 -3
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +22 -3
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +59 -3
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +14 -8
- package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +2 -4
- package/node_modules/@llblab/pi-actors/dist/lib/temp.js +4 -56
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +13 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +110 -43
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +18 -6
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +126 -31
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +31 -3
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +311 -47
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +29 -7
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +192 -43
- package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +272 -194
- package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +14 -2
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +46 -2
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +40 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +55 -1
- package/node_modules/@llblab/pi-actors/docs/README.md +9 -1
- package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +84 -15
- package/node_modules/@llblab/pi-actors/docs/agent-experience.md +216 -0
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +18 -2
- package/node_modules/@llblab/pi-actors/docs/composition-transport.md +103 -0
- package/node_modules/@llblab/pi-actors/docs/coordinator-delivery.md +204 -4
- package/node_modules/@llblab/pi-actors/docs/inspection.md +38 -2
- package/node_modules/@llblab/pi-actors/docs/output-projection-map.md +130 -0
- package/node_modules/@llblab/pi-actors/docs/releasing.md +19 -2
- package/node_modules/@llblab/pi-actors/docs/run-supervision.md +1622 -0
- package/node_modules/@llblab/pi-actors/docs/template-recipes.md +4 -0
- package/node_modules/@llblab/pi-actors/docs/windows-process-observation.md +248 -0
- package/node_modules/@llblab/pi-actors/index.ts +1 -1
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +164 -73
- package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +4 -2
- package/node_modules/@llblab/pi-actors/lib/command-templates.ts +287 -138
- package/node_modules/@llblab/pi-actors/lib/execution-files.ts +118 -0
- package/node_modules/@llblab/pi-actors/lib/execution-output.ts +4 -4
- package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +57 -27
- package/node_modules/@llblab/pi-actors/lib/execution.ts +8 -0
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +102 -12
- package/node_modules/@llblab/pi-actors/lib/file-state.ts +16 -2
- package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +2 -2
- package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +524 -261
- package/node_modules/@llblab/pi-actors/lib/inspector.ts +101 -130
- package/node_modules/@llblab/pi-actors/lib/limits.ts +1 -0
- package/node_modules/@llblab/pi-actors/lib/observability.ts +235 -116
- package/node_modules/@llblab/pi-actors/lib/pi.ts +59 -11
- package/node_modules/@llblab/pi-actors/lib/recipe-projection.ts +232 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +27 -6
- package/node_modules/@llblab/pi-actors/lib/registry.ts +266 -36
- package/node_modules/@llblab/pi-actors/lib/run-delivery.ts +1737 -49
- package/node_modules/@llblab/pi-actors/lib/run-supervision.ts +411 -0
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +237 -73
- package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +73 -1
- package/node_modules/@llblab/pi-actors/lib/runs-context-exports.ts +1871 -0
- package/node_modules/@llblab/pi-actors/lib/runs-context-index.ts +372 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +36 -18
- package/node_modules/@llblab/pi-actors/lib/runs-control.ts +297 -1
- package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +3 -1
- package/node_modules/@llblab/pi-actors/lib/runs-descendant-launches.ts +338 -0
- package/node_modules/@llblab/pi-actors/lib/runs-execution-evidence.ts +302 -0
- package/node_modules/@llblab/pi-actors/lib/runs-index.ts +345 -17
- package/node_modules/@llblab/pi-actors/lib/runs-native-launches.ts +270 -0
- package/node_modules/@llblab/pi-actors/lib/runs-outcomes.ts +377 -0
- package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +37 -4
- package/node_modules/@llblab/pi-actors/lib/runs-process-windows-mi.ts +113 -0
- package/node_modules/@llblab/pi-actors/lib/runs-process.ts +210 -34
- package/node_modules/@llblab/pi-actors/lib/runs-results.ts +601 -0
- package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +134 -10
- package/node_modules/@llblab/pi-actors/lib/runs-session-exports.ts +406 -0
- package/node_modules/@llblab/pi-actors/lib/runs-snapshot.ts +143 -0
- package/node_modules/@llblab/pi-actors/lib/runs-start.ts +44 -2
- package/node_modules/@llblab/pi-actors/lib/runs-status.ts +252 -10
- package/node_modules/@llblab/pi-actors/lib/runs-supervision.ts +394 -0
- package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +14 -3
- package/node_modules/@llblab/pi-actors/lib/runtime.ts +22 -3
- package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +76 -4
- package/node_modules/@llblab/pi-actors/lib/state-readers.ts +16 -7
- package/node_modules/@llblab/pi-actors/lib/temp.ts +3 -56
- package/node_modules/@llblab/pi-actors/lib/tools-access.ts +13 -0
- package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +110 -51
- package/node_modules/@llblab/pi-actors/lib/tools-local.ts +37 -24
- package/node_modules/@llblab/pi-actors/lib/tools-message.ts +120 -37
- package/node_modules/@llblab/pi-actors/lib/tools-response.ts +273 -50
- package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +31 -10
- package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +165 -42
- package/node_modules/@llblab/pi-actors/package.json +10 -6
- package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +272 -194
- package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +14 -2
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +46 -2
- package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +40 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +55 -1
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +224 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +118 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +980 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +2 -2
- package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +0 -16
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +0 -57
- package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +0 -79
|
@@ -7,8 +7,12 @@ import { closeSync, existsSync, fstatSync, openSync, readdirSync, readFileSync,
|
|
|
7
7
|
import { basename, dirname, isAbsolute, join, relative, } from "node:path";
|
|
8
8
|
import * as AsyncRuns from "./async-runs.js";
|
|
9
9
|
import * as Paths from "./paths.js";
|
|
10
|
+
import * as Limits from "./limits.js";
|
|
10
11
|
import * as RunsTrace from "./runs-trace.js";
|
|
12
|
+
import { readRunCompletionTextSource, readRunResultArtifactInventory, readRunResultDiagnosticOutcome } from "./runs-context-exports.js";
|
|
11
13
|
import { readJsonlFileResilient } from "./state-readers.js";
|
|
14
|
+
import { Document } from "yaml";
|
|
15
|
+
import { formatLiteralBlock, formatMarkdownField } from "./tools-response.js";
|
|
12
16
|
export function createRunUiObservationState() {
|
|
13
17
|
return {
|
|
14
18
|
attentionEventIds: new Map(),
|
|
@@ -21,10 +25,12 @@ export function primeRunAttentionState(state, ownerId, stateRoot) {
|
|
|
21
25
|
detectRunAttentionEvents(state.legacyEventLines, summarizeRuns(stateRoot, ownerId), state.attentionEventIds, true);
|
|
22
26
|
}
|
|
23
27
|
export function readRunUiSnapshot(state, ownerId, options = {}) {
|
|
24
|
-
|
|
28
|
+
return projectRunUiSnapshot(state, summarizeRuns(options.stateRoot, ownerId), options.includeAttention);
|
|
29
|
+
}
|
|
30
|
+
function projectRunUiSnapshot(state, summary, includeAttention) {
|
|
25
31
|
const status = renderRunStatus(summary, state.frame++);
|
|
26
32
|
return {
|
|
27
|
-
attentionEvents:
|
|
33
|
+
attentionEvents: includeAttention === false
|
|
28
34
|
? []
|
|
29
35
|
: detectRunAttentionEvents(state.legacyEventLines, summary, state.attentionEventIds),
|
|
30
36
|
status,
|
|
@@ -34,7 +40,9 @@ export function readRunUiSnapshot(state, ownerId, options = {}) {
|
|
|
34
40
|
}
|
|
35
41
|
/** Observe every Run generation routed to one root coordinator. */
|
|
36
42
|
export function readRunDeliverySnapshot(state, deliveryOwnerId, stateRoot) {
|
|
37
|
-
|
|
43
|
+
return projectRunDeliverySnapshot(state, summarizeRuns(stateRoot, undefined, deliveryOwnerId));
|
|
44
|
+
}
|
|
45
|
+
function projectRunDeliverySnapshot(state, summary) {
|
|
38
46
|
return {
|
|
39
47
|
attentionEvents: [],
|
|
40
48
|
status: undefined,
|
|
@@ -42,6 +50,14 @@ export function readRunDeliverySnapshot(state, deliveryOwnerId, stateRoot) {
|
|
|
42
50
|
transitions: detectRunTransitions(state.observed, summary),
|
|
43
51
|
};
|
|
44
52
|
}
|
|
53
|
+
/** Same-pass display/candidate projections only. No frame escapes or native fact is reused by flush/publication/control. */
|
|
54
|
+
export function readRunUiAndDeliverySnapshots(uiState, deliveryState, ownerId, stateRoot = Paths.getRunStateRoot()) {
|
|
55
|
+
const runs = readRunObservations(stateRoot);
|
|
56
|
+
return {
|
|
57
|
+
ui: projectRunUiSnapshot(uiState, summarizeRunObservations(runs, stateRoot, ownerId)),
|
|
58
|
+
delivery: projectRunDeliverySnapshot(deliveryState, summarizeRunObservations(runs, stateRoot, undefined, ownerId)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
45
61
|
export function pruneRunUiObservationState(state, snapshot) {
|
|
46
62
|
pruneRunObservationState(state.observed, state.legacyEventLines, snapshot.summary, snapshot.transitions.map((transition) => transition.stateDir ?? transition.run), state.attentionEventIds);
|
|
47
63
|
}
|
|
@@ -90,7 +106,10 @@ export function createRunStateWatcher(input) {
|
|
|
90
106
|
diagnostics.push({
|
|
91
107
|
code,
|
|
92
108
|
id: ++diagnosticId,
|
|
93
|
-
message:
|
|
109
|
+
message: [formatMarkdownField("watcher", code), formatMarkdownField("scope", scope),
|
|
110
|
+
formatMarkdownField("path", formatLiteralBlock(path)),
|
|
111
|
+
...(detail ? [formatMarkdownField("diagnostic", detail.slice(2))] : []),
|
|
112
|
+
formatMarkdownField("recovery", recovery.slice(2))].join("\n"),
|
|
94
113
|
path,
|
|
95
114
|
scope,
|
|
96
115
|
ts: new Date().toISOString(),
|
|
@@ -317,12 +336,14 @@ function terminalSemanticResult(status, stateDir, observedStatus) {
|
|
|
317
336
|
const type = reviewCompleted
|
|
318
337
|
? "review.completed"
|
|
319
338
|
: observedStatus === "done" ? "run.done" : "run.failed";
|
|
320
|
-
const
|
|
321
|
-
|
|
339
|
+
const hasPrimary = Object.hasOwn(result, "primary_text_protocol");
|
|
340
|
+
const hasDiagnostics = Object.hasOwn(result, "result_diagnostics_protocol");
|
|
341
|
+
const stdoutBody = !hasPrimary && !hasDiagnostics && observedStatus === "done" ? semanticBodyFromStdout(stateDir) : undefined;
|
|
322
342
|
return {
|
|
323
|
-
...(
|
|
324
|
-
|
|
325
|
-
|
|
343
|
+
...(hasPrimary ? { hasPrimaryText: true } : {}),
|
|
344
|
+
...(Object.hasOwn(result, "artifact_inventory_protocol") ? { hasArtifactInventory: true } : {}),
|
|
345
|
+
...(hasDiagnostics ? { hasResultDiagnostics: true } : {}),
|
|
346
|
+
...(!hasDiagnostics && (stdoutBody || typeof result.error === "string") ? { body: stdoutBody ?? result.error } : {}),
|
|
326
347
|
...(correlationId ? { correlationId } : {}),
|
|
327
348
|
metadata: {
|
|
328
349
|
...(status.transport_context &&
|
|
@@ -339,9 +360,9 @@ function terminalSemanticResult(status, stateDir, observedStatus) {
|
|
|
339
360
|
type,
|
|
340
361
|
};
|
|
341
362
|
}
|
|
342
|
-
function observeRun(stateDir) {
|
|
363
|
+
function observeRun(stateDir, observed) {
|
|
343
364
|
try {
|
|
344
|
-
const status = AsyncRuns.getRunStatus(stateDir);
|
|
365
|
+
const status = observed ?? AsyncRuns.getRunStatus(stateDir);
|
|
345
366
|
const progress = getProgress(status);
|
|
346
367
|
const run = typeof status.run === "string" ? status.run : undefined;
|
|
347
368
|
if (!run)
|
|
@@ -414,8 +435,19 @@ function observeRun(stateDir) {
|
|
|
414
435
|
return undefined;
|
|
415
436
|
}
|
|
416
437
|
}
|
|
438
|
+
function readRunObservations(stateRoot) {
|
|
439
|
+
if (!existsSync(stateRoot))
|
|
440
|
+
return undefined;
|
|
441
|
+
const directories = AsyncRuns.readRunStateIndex(stateRoot)?.map((entry) => entry.state_dir) ?? scanRunStateDirs(stateRoot);
|
|
442
|
+
return AsyncRuns.getRunInventoryStatuses(directories)
|
|
443
|
+
.map((status, index) => status ? observeRun(directories[index], status) : undefined)
|
|
444
|
+
.filter((run) => Boolean(run));
|
|
445
|
+
}
|
|
417
446
|
export function summarizeRuns(stateRoot = Paths.getRunStateRoot(), ownerId, deliveryOwnerId) {
|
|
418
|
-
|
|
447
|
+
return summarizeRunObservations(readRunObservations(stateRoot), stateRoot, ownerId, deliveryOwnerId);
|
|
448
|
+
}
|
|
449
|
+
function summarizeRunObservations(observations, stateRoot, ownerId, deliveryOwnerId) {
|
|
450
|
+
if (observations === undefined) {
|
|
419
451
|
return {
|
|
420
452
|
cancelled: 0,
|
|
421
453
|
done: 0,
|
|
@@ -428,10 +460,7 @@ export function summarizeRuns(stateRoot = Paths.getRunStateRoot(), ownerId, deli
|
|
|
428
460
|
total: 0,
|
|
429
461
|
};
|
|
430
462
|
}
|
|
431
|
-
const runs =
|
|
432
|
-
scanRunStateDirs(stateRoot))
|
|
433
|
-
.map((stateDir) => observeRun(stateDir))
|
|
434
|
-
.filter((run) => Boolean(run))
|
|
463
|
+
const runs = observations
|
|
435
464
|
.filter((run) => deliveryOwnerId !== undefined
|
|
436
465
|
? run.deliveryOwnerId === deliveryOwnerId ||
|
|
437
466
|
(run.deliveryOwnerId === undefined && run.ownerId === deliveryOwnerId)
|
|
@@ -532,8 +561,12 @@ function summarizeRunsWithoutSubagents(stateRoot, ownerId) {
|
|
|
532
561
|
};
|
|
533
562
|
}
|
|
534
563
|
export function countRunningSubagentsByRun(stateRoot = Paths.getRunStateRoot(), ownerId) {
|
|
564
|
+
// This backend cannot contribute without procfs; do not pay for native Run
|
|
565
|
+
// identity probes (notably synchronous Windows/macOS probes) just to discard them.
|
|
566
|
+
if (!existsSync("/proc"))
|
|
567
|
+
return new Map();
|
|
535
568
|
const runPidMap = getRunningRunPidMap(stateRoot, ownerId);
|
|
536
|
-
if (runPidMap.size === 0
|
|
569
|
+
if (runPidMap.size === 0)
|
|
537
570
|
return new Map();
|
|
538
571
|
const signature = [...runPidMap.keys()].sort().join(",");
|
|
539
572
|
const cacheKey = `${stateRoot}\0${ownerId ?? ""}`;
|
|
@@ -639,6 +672,17 @@ export function findRunRetirementCandidates(summary) {
|
|
|
639
672
|
terminalChildRuns: item.terminalChildRuns,
|
|
640
673
|
}));
|
|
641
674
|
}
|
|
675
|
+
function formatRunRetirementNotice(run, action, message = "") {
|
|
676
|
+
const fields = [formatMarkdownField("run", run.startsWith("run:") ? run.slice(4) : run), formatMarkdownField("retirement", action)];
|
|
677
|
+
if (action === "stop")
|
|
678
|
+
fields.push(formatMarkdownField("result", "request returned"), formatMarkdownField("reason", "child runs reached terminal state"));
|
|
679
|
+
else if (action === "cancel")
|
|
680
|
+
fields.push(formatMarkdownField("result", "cancellation reported"), formatMarkdownField("reason", "stop path failed"));
|
|
681
|
+
else
|
|
682
|
+
fields.push(formatMarkdownField("result", action === "skip" ? "skipped" : "failed"), formatMarkdownField("diagnostic", message));
|
|
683
|
+
fields.push(formatMarkdownField("closure", "unconfirmed"));
|
|
684
|
+
return fields.join("\n");
|
|
685
|
+
}
|
|
642
686
|
export async function executeRunRetirements(summary, options) {
|
|
643
687
|
const results = [];
|
|
644
688
|
for (const candidate of findRunRetirementCandidates(summary)) {
|
|
@@ -653,7 +697,7 @@ export async function executeRunRetirements(summary, options) {
|
|
|
653
697
|
options.attempted?.add(candidate.stateDir);
|
|
654
698
|
try {
|
|
655
699
|
await options.sendStop(candidate);
|
|
656
|
-
options.notify?.(
|
|
700
|
+
options.notify?.(formatRunRetirementNotice(candidate.run, "stop"), "info");
|
|
657
701
|
results.push({
|
|
658
702
|
action: "stop",
|
|
659
703
|
run: candidate.run,
|
|
@@ -666,8 +710,8 @@ export async function executeRunRetirements(summary, options) {
|
|
|
666
710
|
const cancelResult = options.cancelRun(candidate);
|
|
667
711
|
const cancelled = Boolean(cancelResult.cancelled);
|
|
668
712
|
options.notify?.(cancelled
|
|
669
|
-
?
|
|
670
|
-
:
|
|
713
|
+
? formatRunRetirementNotice(candidate.run, "cancel")
|
|
714
|
+
: formatRunRetirementNotice(candidate.run, "skip", `${error instanceof Error ? error.message : String(error)}`), cancelled ? "warning" : "error");
|
|
671
715
|
results.push({
|
|
672
716
|
action: cancelled ? "cancel" : "skip",
|
|
673
717
|
...(cancelled
|
|
@@ -683,7 +727,7 @@ export async function executeRunRetirements(summary, options) {
|
|
|
683
727
|
const message = cancelError instanceof Error
|
|
684
728
|
? cancelError.message
|
|
685
729
|
: String(cancelError);
|
|
686
|
-
options.notify?.(
|
|
730
|
+
options.notify?.(formatRunRetirementNotice(candidate.run, "failed", `${message}`), "error");
|
|
687
731
|
results.push({
|
|
688
732
|
action: "failed",
|
|
689
733
|
error: message,
|
|
@@ -709,6 +753,7 @@ export function detectRunTransitions(previous, summary) {
|
|
|
709
753
|
transitions.push({
|
|
710
754
|
from: old ?? "running",
|
|
711
755
|
run: run.run,
|
|
756
|
+
...(run.ownerId === undefined ? {} : { ownerId: run.ownerId }),
|
|
712
757
|
...(run.deliveryParent ? { deliveryParent: run.deliveryParent } : {}),
|
|
713
758
|
...(run.stateDir ? { stateDir: run.stateDir } : {}),
|
|
714
759
|
...(run.artifacts ? { artifacts: run.artifacts } : {}),
|
|
@@ -892,26 +937,6 @@ function relativeName(base, path) {
|
|
|
892
937
|
const name = relative(base, path);
|
|
893
938
|
return name && !name.startsWith("..") ? name : basename(path) || path;
|
|
894
939
|
}
|
|
895
|
-
function formatPathGroup(label, paths) {
|
|
896
|
-
const unique = [...new Set(paths.filter(Boolean))].slice(0, 8);
|
|
897
|
-
if (unique.length === 0)
|
|
898
|
-
return "";
|
|
899
|
-
const base = commonDirectory(unique);
|
|
900
|
-
const names = unique
|
|
901
|
-
.map((path) => `\`${relativeName(base, path)}\``)
|
|
902
|
-
.join(", ");
|
|
903
|
-
return `\n${label}:\n- Base: ${base ? `\`${base}\`` : "current run"}\n- Files: ${names}`;
|
|
904
|
-
}
|
|
905
|
-
function formatRunFileList(files) {
|
|
906
|
-
if (!Array.isArray(files))
|
|
907
|
-
return "";
|
|
908
|
-
return formatPathGroup("Run files", files.filter((file) => typeof file === "string"));
|
|
909
|
-
}
|
|
910
|
-
function formatNamedArtifacts(artifacts) {
|
|
911
|
-
if (!artifacts || typeof artifacts !== "object" || Array.isArray(artifacts))
|
|
912
|
-
return "";
|
|
913
|
-
return formatPathGroup("Artifacts", Object.values(artifacts).filter((path) => typeof path === "string"));
|
|
914
|
-
}
|
|
915
940
|
function getAttentionDataField(event, key) {
|
|
916
941
|
return event.data &&
|
|
917
942
|
typeof event.data === "object" &&
|
|
@@ -919,19 +944,96 @@ function getAttentionDataField(event, key) {
|
|
|
919
944
|
? event.data[key]
|
|
920
945
|
: undefined;
|
|
921
946
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const compact = rendered.replaceAll(/\s+/g, " ").trim();
|
|
927
|
-
if (!compact)
|
|
928
|
-
return "";
|
|
929
|
-
return `\nBody: ${compact.length > 500 ? `${compact.slice(0, 500)}…` : compact}`;
|
|
947
|
+
/** Only selected shallow compiler fields enter YAML; the selected body stays opaque and unindented. */
|
|
948
|
+
function renderAttention({ metadata, body }) {
|
|
949
|
+
const header = new Document(metadata).toString({ lineWidth: 0, defaultStringType: "QUOTE_DOUBLE", defaultKeyType: "PLAIN" }).slice(0, -1);
|
|
950
|
+
return body === undefined ? header : `---\n${header}\n---\n${body}`;
|
|
930
951
|
}
|
|
952
|
+
/** Ordinary selection has no urgent-steer or compact-output byte/depth allowance. */
|
|
931
953
|
export function formatRunAttentionMessage(event) {
|
|
954
|
+
const checkpoint = formatAXAttentionCheckpoint(event);
|
|
932
955
|
if (event.kind === "command.done")
|
|
933
|
-
return
|
|
934
|
-
|
|
956
|
+
return renderAttention(checkpoint);
|
|
957
|
+
for (const section of attentionPathSections(event)) {
|
|
958
|
+
checkpoint.metadata[section.key] = formatAXAttentionPaths(section.paths.slice(0, 8).filter(path => Buffer.from(path).toString("utf8") === path), section.paths.length);
|
|
959
|
+
}
|
|
960
|
+
return renderAttention(checkpoint);
|
|
961
|
+
}
|
|
962
|
+
function formatAXAttentionCheckpoint(event) {
|
|
963
|
+
const run = event.run.startsWith("run:") ? event.run.slice(4) : event.run;
|
|
964
|
+
const metadata = { run, checkpoint: event.summary };
|
|
965
|
+
const checkpoint = { metadata };
|
|
966
|
+
if (event.kind === "command.done" || event.body === undefined)
|
|
967
|
+
return checkpoint;
|
|
968
|
+
const rendered = typeof event.body === "string" ? event.body : JSON.stringify(event.body);
|
|
969
|
+
if (!rendered.trim())
|
|
970
|
+
return checkpoint;
|
|
971
|
+
let end = Math.min(rendered.length, 500);
|
|
972
|
+
const last = rendered.charCodeAt(end - 1), next = rendered.charCodeAt(end);
|
|
973
|
+
if (last >= 0xd800 && last <= 0xdbff && next >= 0xdc00 && next <= 0xdfff)
|
|
974
|
+
end--;
|
|
975
|
+
const preview = rendered.slice(0, end), clipped = end < rendered.length;
|
|
976
|
+
if (Buffer.from(preview).toString("utf8") !== preview) {
|
|
977
|
+
metadata.body = "unavailable";
|
|
978
|
+
metadata.body_reason = "malformed_legacy_preview";
|
|
979
|
+
metadata.body_omission = "[omitted: unknown]";
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
// Retain the old final body observation and structured-preview ellipsis placement, not its compiler fence.
|
|
983
|
+
checkpoint.body = typeof event.body === "string" ? preview + (clipped ? "…" : "") : preview + (clipped ? "\n…" : "");
|
|
984
|
+
if (clipped)
|
|
985
|
+
metadata.body_omission = "[omitted: unknown]";
|
|
986
|
+
}
|
|
987
|
+
metadata.body_basis = "Legacy record; original completeness/privacy unproven.";
|
|
988
|
+
metadata.body_upstream = "[omitted: unknown]";
|
|
989
|
+
return checkpoint;
|
|
990
|
+
}
|
|
991
|
+
function attentionPathSections(event) {
|
|
992
|
+
const artifacts = getAttentionDataField(event, "artifacts"), files = getAttentionDataField(event, "run_files");
|
|
993
|
+
if (event.kind === "command.done")
|
|
994
|
+
return [];
|
|
995
|
+
return [
|
|
996
|
+
{ key: "artifacts", values: artifacts && typeof artifacts === "object" && !Array.isArray(artifacts) ? Object.values(artifacts) : [] },
|
|
997
|
+
{ key: "run_files", values: Array.isArray(files) ? files : [] },
|
|
998
|
+
].map(({ key, values }) => ({ key,
|
|
999
|
+
paths: [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))],
|
|
1000
|
+
})).filter(section => section.paths.length > 0);
|
|
1001
|
+
}
|
|
1002
|
+
function formatAXAttentionPaths(paths, total) {
|
|
1003
|
+
return { shown: paths.length, omitted: total - paths.length, total, ...(paths.length ? { paths } : {}) };
|
|
1004
|
+
}
|
|
1005
|
+
/** Saved envelope.content is replayed before this formatter; only fresh complete candidates are fitted. */
|
|
1006
|
+
export function formatRunSteerMessage(event) {
|
|
1007
|
+
const limit = Limits.RUN_DELIVERY_STEER_MAX_BYTES;
|
|
1008
|
+
const checkpoint = formatAXAttentionCheckpoint(event);
|
|
1009
|
+
// YAML can escape malformed UTF-16: validate essential source values before serialization or reference reads.
|
|
1010
|
+
if ([checkpoint.metadata.run, checkpoint.metadata.checkpoint].some(value => Buffer.from(value).toString("utf8") !== value)
|
|
1011
|
+
|| Buffer.byteLength(renderAttention(checkpoint)) > limit) {
|
|
1012
|
+
throw new Error("Urgent steer checkpoint text exceeds its Unicode/byte delivery limits");
|
|
1013
|
+
}
|
|
1014
|
+
const sections = attentionPathSections(event);
|
|
1015
|
+
if (event.kind === "command.done")
|
|
1016
|
+
return renderAttention(checkpoint);
|
|
1017
|
+
const selected = { ...checkpoint.metadata };
|
|
1018
|
+
for (const [index, section] of sections.entries()) {
|
|
1019
|
+
const reserve = {};
|
|
1020
|
+
for (const next of sections.slice(index + 1))
|
|
1021
|
+
reserve[next.key] = formatAXAttentionPaths([], next.paths.length);
|
|
1022
|
+
const candidates = section.paths.slice(0, 8).filter(path => Buffer.from(path).toString("utf8") === path);
|
|
1023
|
+
let fitted = false;
|
|
1024
|
+
for (let shown = candidates.length; shown >= 0; shown -= 1) {
|
|
1025
|
+
const group = formatAXAttentionPaths(candidates.slice(0, shown), section.paths.length);
|
|
1026
|
+
const candidate = { ...selected, [section.key]: group, ...reserve };
|
|
1027
|
+
if (Buffer.byteLength(renderAttention({ ...checkpoint, metadata: candidate })) <= limit) {
|
|
1028
|
+
selected[section.key] = group;
|
|
1029
|
+
fitted = true;
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (!fitted)
|
|
1034
|
+
throw new Error("Urgent steer checkpoint and reference coverage exceed the delivery byte limit");
|
|
1035
|
+
}
|
|
1036
|
+
return renderAttention({ ...checkpoint, metadata: selected });
|
|
935
1037
|
}
|
|
936
1038
|
export function getRunTransitionNotificationType(transition) {
|
|
937
1039
|
if (transition.to === "done" || transition.to === "cancelled")
|
|
@@ -975,68 +1077,83 @@ function deliveryTreePosition(input, runsByIdentity) {
|
|
|
975
1077
|
}
|
|
976
1078
|
return { depth, rootIdentity };
|
|
977
1079
|
}
|
|
978
|
-
/**
|
|
979
|
-
|
|
980
|
-
const runsByIdentity = new Map(deliveryRuns.flatMap(
|
|
1080
|
+
/** Eligibility is metadata-only; ambient candidate checks must not read full primary bodies. */
|
|
1081
|
+
function readyRunCompletions(transitions, deliveryRuns) {
|
|
1082
|
+
const runsByIdentity = new Map(deliveryRuns.flatMap(run => {
|
|
981
1083
|
const identity = deliveryGenerationIdentity(run);
|
|
982
1084
|
return identity ? [[identity, run]] : [];
|
|
983
1085
|
}));
|
|
984
|
-
const incompleteRoots = new Set(deliveryRuns.flatMap(
|
|
1086
|
+
const incompleteRoots = new Set(deliveryRuns.flatMap(run => {
|
|
985
1087
|
if (TERMINAL.has(run.status))
|
|
986
1088
|
return [];
|
|
987
1089
|
const position = deliveryTreePosition(run, runsByIdentity);
|
|
988
1090
|
return position ? [position.rootIdentity] : [];
|
|
989
1091
|
}));
|
|
990
|
-
|
|
991
|
-
if (!shouldNotifyRunTransition(transition) ||
|
|
992
|
-
!transition.
|
|
993
|
-
!transition.runInstanceId ||
|
|
994
|
-
!transition.terminalAt ||
|
|
995
|
-
Number.isNaN(Date.parse(transition.terminalAt)))
|
|
1092
|
+
return transitions.flatMap(transition => {
|
|
1093
|
+
if (!shouldNotifyRunTransition(transition) || !transition.stateDir || !transition.runInstanceId ||
|
|
1094
|
+
!transition.terminalAt || Number.isNaN(Date.parse(transition.terminalAt)))
|
|
996
1095
|
return [];
|
|
997
1096
|
const position = deliveryTreePosition(transition, runsByIdentity);
|
|
998
1097
|
if (!position || incompleteRoots.has(position.rootIdentity))
|
|
999
1098
|
return [];
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1099
|
+
return [{ transition: { ...transition, stateDir: transition.stateDir, runInstanceId: transition.runInstanceId,
|
|
1100
|
+
terminalAt: transition.terminalAt }, depth: position.depth }];
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
export function hasRunCompletionBatchMembers(transitions, deliveryRuns = []) {
|
|
1104
|
+
return readyRunCompletions(transitions, deliveryRuns).length > 0;
|
|
1105
|
+
}
|
|
1106
|
+
/** Freeze primary/artifact source observations only for eligible members entering packet admission. */
|
|
1107
|
+
export function collectRunCompletionBatchMembers(transitions, deliveryRuns = []) {
|
|
1108
|
+
const admitted = readyRunCompletions(transitions, deliveryRuns).map(({ transition, depth }) => {
|
|
1109
|
+
const hasPrimary = transition.semanticResult?.hasPrimaryText === true;
|
|
1110
|
+
const hasDiagnostics = transition.semanticResult?.hasResultDiagnostics === true;
|
|
1111
|
+
const diagnosticReading = hasDiagnostics ? readRunResultDiagnosticOutcome(transition.stateDir, { run: transition.run,
|
|
1112
|
+
run_instance_id: transition.runInstanceId, ...(transition.ownerId === undefined ? {} : { ownerId: transition.ownerId }) }, transition.to) : undefined;
|
|
1113
|
+
const diagnostics = diagnosticReading?.state === "available" && diagnosticReading.terminal_status === transition.to && diagnosticReading.unchanged()
|
|
1114
|
+
? { ...diagnosticReading.binding, diagnostic_excerpt: diagnosticReading.excerpt } : diagnosticReading
|
|
1115
|
+
? { result_diagnostics: null, result_diagnostics_unavailable: diagnosticReading.state === "unavailable"
|
|
1116
|
+
? diagnosticReading.result_diagnostics_unavailable ?? diagnosticReading.reason : diagnosticReading.terminal_status !== transition.to ? "outcome_mismatch" : "observation_changed" } : undefined;
|
|
1117
|
+
const reading = hasPrimary ? readRunCompletionTextSource(transition.stateDir, { run: transition.run,
|
|
1118
|
+
run_instance_id: transition.runInstanceId, ...(transition.ownerId === undefined ? {} : { ownerId: transition.ownerId }) }) : undefined;
|
|
1119
|
+
const primary = !reading ? undefined
|
|
1120
|
+
: reading.state === "available" && reading.result_acceptance === "natural" && transition.to === "done" && reading.unchanged()
|
|
1121
|
+
? Object.freeze({ output: reading.original_output ?? reading.output })
|
|
1122
|
+
: Object.freeze({ output: null, output_unavailable: reading.state === "unavailable"
|
|
1123
|
+
? reading.output_unavailable ?? reading.reason : reading.result_acceptance !== "natural" ? "nonterminal_capture" : "observation_changed" });
|
|
1124
|
+
// Existing unsupported session/composition/failure displays stay diagnostics, never substitute for a lost source.
|
|
1125
|
+
const legacyDisplay = !hasPrimary || (reading?.state === "unavailable" && reading.reason === "output_unavailable" &&
|
|
1126
|
+
["not_selected", "selection_not_supported", "primary_not_selected_for_failure"].includes(reading.output_unavailable ?? ""));
|
|
1127
|
+
const body = !hasDiagnostics && legacyDisplay ? transition.semanticResult?.body ??
|
|
1128
|
+
(hasPrimary && transition.to === "done" ? semanticBodyFromStdout(transition.stateDir) : undefined) : undefined;
|
|
1129
|
+
const hasInventory = transition.semanticResult?.hasArtifactInventory === true;
|
|
1130
|
+
const inventoryReading = hasInventory ? readRunResultArtifactInventory(transition.stateDir, { run: transition.run,
|
|
1131
|
+
run_instance_id: transition.runInstanceId, ...(transition.ownerId === undefined ? {} : { ownerId: transition.ownerId }) }) : undefined;
|
|
1132
|
+
const inventory = inventoryReading?.state === "available" && inventoryReading.terminal_status === transition.to && inventoryReading.unchanged() ? inventoryReading.binding : inventoryReading
|
|
1133
|
+
? { artifact_inventory: null, artifact_inventory_unavailable: inventoryReading.state === "unavailable"
|
|
1134
|
+
? inventoryReading.artifact_inventory_unavailable ?? inventoryReading.reason : inventoryReading.terminal_status !== transition.to ? "outcome_mismatch" : "observation_changed" } : undefined;
|
|
1135
|
+
const artifactEntries = hasInventory ? [] : Object.entries(transition.artifacts ?? {})
|
|
1136
|
+
.filter((entry) => typeof entry[1] === "string" && Boolean(entry[1])).slice(0, 4);
|
|
1137
|
+
const rawSummary = transition.semanticResult?.summary.trim() || `Run ${transition.to}.`;
|
|
1138
|
+
return {
|
|
1139
|
+
...(artifactEntries.length > 0 ? { artifacts: Object.fromEntries(artifactEntries) } : {}),
|
|
1140
|
+
...(primary ? { primary_text: primary } : {}),
|
|
1141
|
+
...(primary?.output && reading?.state === "available" ? { completion_text: Object.freeze({ text: reading.output.preview,
|
|
1142
|
+
shown_bytes: reading.output.shown_bytes }) } : {}),
|
|
1143
|
+
...inventory,
|
|
1144
|
+
...diagnostics,
|
|
1145
|
+
...(body?.trim() ? { output: body.trim().length > 4_000 ? `${body.trim().slice(0, 3_999)}…` : body.trim() } : {}),
|
|
1146
|
+
...(transition.deliveryParent ? { parent_run: transition.deliveryParent.run,
|
|
1147
|
+
parent_run_instance_id: transition.deliveryParent.run_instance_id, parent_state_dir: transition.deliveryParent.state_dir } : {}),
|
|
1148
|
+
run: transition.run, run_instance_id: transition.runInstanceId, state_dir: transition.stateDir,
|
|
1149
|
+
status: transition.to,
|
|
1150
|
+
summary: rawSummary.length > 1_000 ? `${rawSummary.slice(0, 999)}…` : rawSummary,
|
|
1151
|
+
terminal_at: transition.terminalAt, tree_depth: depth,
|
|
1152
|
+
};
|
|
1034
1153
|
});
|
|
1035
1154
|
return admitted.sort((left, right) => left.tree_depth - right.tree_depth ||
|
|
1036
|
-
left.terminal_at.localeCompare(right.terminal_at) ||
|
|
1037
|
-
left.
|
|
1038
|
-
left.run_instance_id.localeCompare(right.run_instance_id) ||
|
|
1039
|
-
left.state_dir.localeCompare(right.state_dir)).map(({ tree_depth: _depth, ...member }) => member);
|
|
1155
|
+
left.terminal_at.localeCompare(right.terminal_at) || left.run.localeCompare(right.run) ||
|
|
1156
|
+
left.run_instance_id.localeCompare(right.run_instance_id) || left.state_dir.localeCompare(right.state_dir)).map(({ tree_depth: _depth, ...member }) => member);
|
|
1040
1157
|
}
|
|
1041
1158
|
const TERMINAL_FOLLOW_UP_ARTIFACT_LIMIT = 4;
|
|
1042
1159
|
const TERMINAL_FOLLOW_UP_IDENTIFIER_CHARS = 120;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Zones: pi agent sdk boundary, extension host adapters
|
|
4
4
|
* Owns direct pi SDK imports and exposes narrow pi-actors-facing helpers/types for the composition root.
|
|
5
5
|
*/
|
|
6
|
-
import type { ExtensionAPI, ExtensionContext, CustomMessageEntryDraft, TurnEndEvent, TurnEndEventResult } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext, SessionStartEvent, CustomMessageEntryDraft, TurnEndEvent, TurnEndEventResult } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import * as SessionEvidence from "./session-evidence.ts";
|
|
8
|
-
export type { ExtensionAPI, ExtensionContext, TurnEndEvent, TurnEndEventResult };
|
|
8
|
+
export type { ExtensionAPI, ExtensionContext, SessionStartEvent, TurnEndEvent, TurnEndEventResult };
|
|
9
|
+
export { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
9
10
|
export declare const RUN_COMPLETION_BATCH_CUSTOM_TYPE = "pi-actors-run-batch";
|
|
10
11
|
export declare const RUN_STEER_CUSTOM_TYPE = "pi-actors-run-steer";
|
|
11
12
|
export interface PiNotificationSink {
|
|
@@ -19,8 +20,8 @@ export interface PiNotificationSink {
|
|
|
19
20
|
}
|
|
20
21
|
export declare function getSessionId(ctx: ExtensionContext): string;
|
|
21
22
|
export declare function createNotificationSink(pi: ExtensionAPI, ctx: ExtensionContext): PiNotificationSink;
|
|
22
|
-
export declare function createRunCompletionBatchEntry(batchId: string, content: string): CustomMessageEntryDraft;
|
|
23
|
-
export declare function sendRunCompletionBatch(pi: ExtensionAPI, batchId: string, content: string): void;
|
|
23
|
+
export declare function createRunCompletionBatchEntry(batchId: string, content: string, presentation?: unknown): CustomMessageEntryDraft;
|
|
24
|
+
export declare function sendRunCompletionBatch(pi: ExtensionAPI, batchId: string, content: string, presentation?: unknown): void;
|
|
24
25
|
export declare function sendRunSteer(pi: ExtensionAPI, input: {
|
|
25
26
|
content: string;
|
|
26
27
|
eventId: string;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Owns direct pi SDK imports and exposes narrow pi-actors-facing helpers/types for the composition root.
|
|
5
5
|
*/
|
|
6
6
|
import * as SessionEvidence from "./session-evidence.js";
|
|
7
|
+
import * as RunDelivery from "./run-delivery.js";
|
|
8
|
+
export { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
7
9
|
export const RUN_COMPLETION_BATCH_CUSTOM_TYPE = "pi-actors-run-batch";
|
|
8
10
|
export const RUN_STEER_CUSTOM_TYPE = "pi-actors-run-steer";
|
|
9
11
|
export function getSessionId(ctx) {
|
|
@@ -18,7 +20,7 @@ export function createNotificationSink(pi, ctx) {
|
|
|
18
20
|
}),
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
|
-
export function createRunCompletionBatchEntry(batchId, content) {
|
|
23
|
+
export function createRunCompletionBatchEntry(batchId, content, presentation) {
|
|
22
24
|
return {
|
|
23
25
|
type: "custom_message",
|
|
24
26
|
customType: RUN_COMPLETION_BATCH_CUSTOM_TYPE,
|
|
@@ -29,11 +31,12 @@ export function createRunCompletionBatchEntry(batchId, content) {
|
|
|
29
31
|
batch_id: batchId,
|
|
30
32
|
kind: "completion_batch",
|
|
31
33
|
},
|
|
34
|
+
...(presentation === undefined ? {} : { pi_actors_presentation: presentation }),
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
|
-
export function sendRunCompletionBatch(pi, batchId, content) {
|
|
36
|
-
const { type: _type, ...message } = createRunCompletionBatchEntry(batchId, content);
|
|
38
|
+
export function sendRunCompletionBatch(pi, batchId, content, presentation) {
|
|
39
|
+
const { type: _type, ...message } = createRunCompletionBatchEntry(batchId, content, presentation);
|
|
37
40
|
pi.sendMessage(message, { deliverAs: "followUp", triggerTurn: true });
|
|
38
41
|
}
|
|
39
42
|
export function sendRunSteer(pi, input) {
|
|
@@ -53,6 +56,41 @@ export function sendRunSteer(pi, input) {
|
|
|
53
56
|
triggerTurn: true,
|
|
54
57
|
});
|
|
55
58
|
}
|
|
59
|
+
function hasCompletionFrontmatterPrefix(content) {
|
|
60
|
+
const opening = /^\uFEFF?---[ \t]*(?:\r\n|\r|\n)/u.exec(content);
|
|
61
|
+
if (!opening)
|
|
62
|
+
return false;
|
|
63
|
+
for (const line of content.slice(opening[0].length).split(/\r\n|\r|\n/u)) {
|
|
64
|
+
const field = line.trim();
|
|
65
|
+
if (field === "---")
|
|
66
|
+
return false;
|
|
67
|
+
if (!field)
|
|
68
|
+
continue;
|
|
69
|
+
if (/^(?:index|run|state|kind)[ \t]*:/iu.test(field) ||
|
|
70
|
+
["index", "run", "state", "kind"].some(key => key.startsWith(field.toLowerCase())))
|
|
71
|
+
return true;
|
|
72
|
+
// Continue through plausible metadata, not arbitrary thematic-break prose.
|
|
73
|
+
if (!/^[a-z_][a-z0-9_-]*[ \t]*:/iu.test(field))
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function unheaderedCompletionId(content) {
|
|
79
|
+
// Preserve the existing legacy RegExp coercion before inspecting compiler-owned record framing.
|
|
80
|
+
const legacyId = /^Batch: `([^`]{1,128})`$/mu.exec(content)?.[1];
|
|
81
|
+
if (typeof content === "string") {
|
|
82
|
+
const core = RunDelivery.readCompletionYamlCarrier(content);
|
|
83
|
+
if (core.state === "available")
|
|
84
|
+
return core.packet.batchId;
|
|
85
|
+
// Initial compiler headers only: never recover identity by scanning authored bodies.
|
|
86
|
+
if (/^(?:index: (?:\d+|"\?")\nrun: [^\n]*\nstate:|_completion:\n (?:codec|batch_id):)/u.test(content))
|
|
87
|
+
return { malformed: true };
|
|
88
|
+
}
|
|
89
|
+
if (typeof content === "string" && (hasCompletionFrontmatterPrefix(content) || /^(?:#|Run #|— Новый поток|- run:|- #0:\n|- result: omitted \(model byte limit\)\n|- omitted_results:)/u.test(content))) {
|
|
90
|
+
return RunDelivery.readRunCompletionRecordMarker(content)?.batchId ?? { malformed: true };
|
|
91
|
+
}
|
|
92
|
+
return legacyId;
|
|
93
|
+
}
|
|
56
94
|
function completionBatchMessage(message) {
|
|
57
95
|
if (!message || typeof message !== "object" || Array.isArray(message))
|
|
58
96
|
return undefined;
|
|
@@ -71,10 +109,15 @@ function completionBatchMessage(message) {
|
|
|
71
109
|
typeof envelope.batch_id === "string"
|
|
72
110
|
? envelope.batch_id
|
|
73
111
|
: undefined;
|
|
74
|
-
|
|
75
|
-
const
|
|
112
|
+
// Retained headers or the new closed footer identify delivery; authored labels never override either.
|
|
113
|
+
const contentId = record.content.startsWith("- completion:")
|
|
114
|
+
? /^- completion: ([^\r\n\u2028\u2029]{1,128})\n- presentation: ax_records\n/u.exec(record.content)?.[1]
|
|
115
|
+
: record.content.startsWith("- completions:")
|
|
116
|
+
? /^- completions: [1-9]\d{0,2}\n- batch: ([^\r\n\u2028\u2029]{1,128})\n/u.exec(record.content)?.[1]
|
|
117
|
+
: unheaderedCompletionId(record.content);
|
|
118
|
+
const batchId = detailedId ?? (typeof contentId === "string" ? contentId : undefined);
|
|
76
119
|
if (!batchId || batchId.length > 128)
|
|
77
|
-
return undefined;
|
|
120
|
+
return contentId && typeof contentId === "object" ? contentId : undefined;
|
|
78
121
|
return { batchId, content: record.content };
|
|
79
122
|
}
|
|
80
123
|
/** Collapse exact retry duplicates and remove conflicting delivery envelopes. */
|
|
@@ -83,7 +126,7 @@ export function dedupeRunCompletionBatchContext(messages) {
|
|
|
83
126
|
const conflicts = new Set();
|
|
84
127
|
for (const message of messages) {
|
|
85
128
|
const batch = completionBatchMessage(message);
|
|
86
|
-
if (!batch)
|
|
129
|
+
if (!batch || "malformed" in batch)
|
|
87
130
|
continue;
|
|
88
131
|
const existing = batches.get(batch.batchId);
|
|
89
132
|
if (existing !== undefined && existing !== batch.content) {
|
|
@@ -96,7 +139,7 @@ export function dedupeRunCompletionBatchContext(messages) {
|
|
|
96
139
|
const retained = new Set();
|
|
97
140
|
const filtered = messages.filter((message) => {
|
|
98
141
|
const batch = completionBatchMessage(message);
|
|
99
|
-
if (!batch)
|
|
142
|
+
if (!batch || "malformed" in batch)
|
|
100
143
|
return true;
|
|
101
144
|
if (conflicts.has(batch.batchId) || retained.has(batch.batchId))
|
|
102
145
|
return false;
|
|
@@ -108,7 +151,10 @@ export function dedupeRunCompletionBatchContext(messages) {
|
|
|
108
151
|
return { batches, conflicts, messages: filtered };
|
|
109
152
|
}
|
|
110
153
|
export function removeRunCompletionBatchFromContext(messages, batchId) {
|
|
111
|
-
return messages.filter((message) =>
|
|
154
|
+
return messages.filter((message) => {
|
|
155
|
+
const batch = completionBatchMessage(message);
|
|
156
|
+
return !batch || "malformed" in batch || batch.batchId !== batchId;
|
|
157
|
+
});
|
|
112
158
|
}
|
|
113
159
|
function steerMessage(message) {
|
|
114
160
|
if (!message || typeof message !== "object" || Array.isArray(message))
|
|
@@ -175,16 +221,24 @@ export function removeRunSteerFromContext(messages, steerId) {
|
|
|
175
221
|
return messages.filter((message) => steerMessage(message)?.steerId !== steerId);
|
|
176
222
|
}
|
|
177
223
|
export function inspectRunCompletionBatchSessionEvidence(ctx, input) {
|
|
178
|
-
|
|
224
|
+
let unidentifiedRecord = false;
|
|
225
|
+
const evidence = SessionEvidence.inspectBoundedActiveSessionEntries({
|
|
179
226
|
getEntry: (id) => ctx.sessionManager.getEntry(id),
|
|
180
227
|
leaf: ctx.sessionManager.getLeafEntry(),
|
|
181
228
|
match: (entry) => {
|
|
182
229
|
const batch = completionBatchMessage(entry);
|
|
230
|
+
if (batch && "malformed" in batch) {
|
|
231
|
+
unidentifiedRecord = true;
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
183
234
|
if (!batch || batch.batchId !== input.batchId)
|
|
184
235
|
return undefined;
|
|
185
236
|
return batch.content === input.content ? "present" : "conflict";
|
|
186
237
|
},
|
|
187
238
|
});
|
|
239
|
+
// An unidentified new record may be this pending epoch; it cannot prove absence or permit replay.
|
|
240
|
+
return evidence.status === "absent" && unidentifiedRecord
|
|
241
|
+
? { ...evidence, status: "unknown", reason: "completion record correlation is unavailable" } : evidence;
|
|
188
242
|
}
|
|
189
243
|
export function inspectRunSteerSessionEvidence(ctx, input) {
|
|
190
244
|
return SessionEvidence.inspectBoundedActiveSessionEntries({
|