@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
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Async run state index.
|
|
3
|
-
* Owns:
|
|
3
|
+
* Owns: directory discovery, locked catalog registration/rebuild, same-session location navigation, and legacy inventory.
|
|
4
|
+
* Excludes: launch wiring, model delivery, work/native authority, and retained-generation storage.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
import { existsSync, mkdirSync, readdirSync } from "node:fs";
|
|
7
|
+
import { closeSync, constants, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readdirSync, lstatSync } from "node:fs";
|
|
7
8
|
import { join, resolve } from "node:path";
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { acquireFileMutationLock, writeTextAtomic } from "./file-state.ts";
|
|
11
|
+
import { observeRunContextExportLocation, readRunContextIdentity, runContextExportPath, RUN_CONTEXT_SOURCE_METADATA_MAX_BYTES, type RunContextIndexIdentity } from "./runs-context-index.ts";
|
|
12
|
+
import { RUN_DELIVERY_MODEL_MAX_BYTES } from "./limits.ts";
|
|
13
|
+
import { readJsonFileResilient } from "./state-readers.ts";
|
|
10
14
|
|
|
11
15
|
export interface RunStateIndexEntry {
|
|
12
16
|
ownerId?: string;
|
|
13
17
|
recipe?: string;
|
|
14
18
|
run: string;
|
|
19
|
+
run_instance_id?: string;
|
|
15
20
|
state_dir: string;
|
|
16
21
|
status: string;
|
|
17
22
|
tool?: string;
|
|
@@ -116,25 +121,346 @@ function indexEntryFromStatus(
|
|
|
116
121
|
};
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
interface DirectoryRegistration {
|
|
125
|
+
entry: RunStateIndexEntry;
|
|
126
|
+
unchanged: () => boolean;
|
|
127
|
+
}
|
|
128
|
+
interface RunStateCatalog {
|
|
129
|
+
entries: RunStateIndexEntry[];
|
|
130
|
+
[key: string]: unknown;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function prepareDirectoryRegistration(stateDir: string, status: Record<string, unknown>): DirectoryRegistration {
|
|
134
|
+
if (!status || typeof status !== "object" || typeof status.run !== "string" || !status.run ||
|
|
135
|
+
typeof status.run_instance_id !== "string" || !status.run_instance_id ||
|
|
136
|
+
typeof status.state_dir !== "string" || typeof status.status !== "string" || !status.status ||
|
|
137
|
+
(Object.hasOwn(status, "ownerId") && (typeof status.ownerId !== "string" || !status.ownerId))) {
|
|
138
|
+
throw new Error("Run state directory registration identity is invalid.");
|
|
139
|
+
}
|
|
140
|
+
const reading = readRunContextIdentity(resolve(stateDir), { run: status.run, run_instance_id: status.run_instance_id,
|
|
141
|
+
...(Object.hasOwn(status, "ownerId") ? { ownerId: status.ownerId } : {}) });
|
|
142
|
+
if (reading.state !== "available" || status.state_dir !== reading.local_path) {
|
|
143
|
+
throw new Error("Run state directory registration identity is unavailable.");
|
|
144
|
+
}
|
|
145
|
+
const progress = status.progress && typeof status.progress === "object" ? status.progress as Record<string, unknown> : undefined;
|
|
146
|
+
const entry: RunStateIndexEntry = { run: reading.identity.run, run_instance_id: reading.identity.run_instance_id,
|
|
147
|
+
state_dir: reading.local_path, status: status.status,
|
|
148
|
+
...(reading.identity.ownerId === undefined ? {} : { ownerId: reading.identity.ownerId }),
|
|
149
|
+
...(typeof status.recipe === "string" ? { recipe: status.recipe } : {}),
|
|
150
|
+
...(typeof status.tool === "string" ? { tool: status.tool } : {}),
|
|
151
|
+
...(typeof progress?.updatedAt === "string" ? { updated_at: progress.updatedAt }
|
|
152
|
+
: typeof status.createdAt === "string" ? { updated_at: status.createdAt } : {}) };
|
|
153
|
+
return { entry, unchanged: reading.unchanged };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function readCatalog(path: string): RunStateCatalog | undefined {
|
|
157
|
+
let fd: number;
|
|
158
|
+
try { fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)); }
|
|
159
|
+
catch (error) {
|
|
160
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
let bytes: Buffer;
|
|
164
|
+
let failed = false;
|
|
165
|
+
let failure: unknown;
|
|
166
|
+
try {
|
|
167
|
+
if (!fstatSync(fd).isFile()) throw new Error("Run state catalog requires a regular file.");
|
|
168
|
+
bytes = readFileSync(fd);
|
|
169
|
+
} catch (error) { failed = true; failure = error; throw error; }
|
|
170
|
+
finally {
|
|
171
|
+
try { closeSync(fd); }
|
|
172
|
+
catch (error) { throw failed ? new AggregateError([failure, error], "Run state catalog read and close failed.") : error; }
|
|
173
|
+
}
|
|
174
|
+
const value: unknown = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes));
|
|
175
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || !Array.isArray((value as RunStateCatalog).entries)) {
|
|
176
|
+
throw new Error("Run state catalog is invalid.");
|
|
177
|
+
}
|
|
178
|
+
const catalog = value as RunStateCatalog;
|
|
179
|
+
for (const row of catalog.entries) {
|
|
180
|
+
if (!row || typeof row !== "object" || Array.isArray(row) || typeof row.run !== "string" ||
|
|
181
|
+
typeof row.state_dir !== "string" || typeof row.status !== "string" ||
|
|
182
|
+
(Object.hasOwn(row, "ownerId") && typeof row.ownerId !== "string") ||
|
|
183
|
+
(Object.hasOwn(row, "run_instance_id") && typeof row.run_instance_id !== "string")) {
|
|
184
|
+
throw new Error("Run state catalog entry is invalid.");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return catalog;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function publishDirectoryRegistrations(stateRoot: string, registrations: DirectoryRegistration[], explicit: boolean): RunStateIndexEntry[] {
|
|
191
|
+
mkdirSync(stateRoot, { recursive: true });
|
|
192
|
+
const path = runIndexPath(stateRoot);
|
|
193
|
+
const release = acquireFileMutationLock(path);
|
|
194
|
+
let failed = false;
|
|
195
|
+
let failure: unknown;
|
|
196
|
+
try {
|
|
197
|
+
const catalog = readCatalog(path) ?? { entries: [] };
|
|
198
|
+
let entries = [...catalog.entries];
|
|
199
|
+
const assertCurrent = (): void => {
|
|
200
|
+
if (registrations.some(registration => !registration.unchanged())) {
|
|
201
|
+
throw new Error("Run state directory registration observation changed.");
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
assertCurrent();
|
|
205
|
+
for (const { entry } of registrations) {
|
|
206
|
+
const position = entries.findIndex(row => row.state_dir === entry.state_dir);
|
|
207
|
+
const previous = entries[position];
|
|
208
|
+
const sameGeneration = previous && previous.run === entry.run && previous.ownerId === entry.ownerId &&
|
|
209
|
+
previous.run_instance_id === entry.run_instance_id;
|
|
210
|
+
const merged = sameGeneration ? { ...previous, ...entry } : { ...entry };
|
|
211
|
+
for (const optional of ["ownerId", "recipe", "tool", "updated_at"] as const) {
|
|
212
|
+
if (!Object.hasOwn(entry, optional)) delete merged[optional];
|
|
213
|
+
}
|
|
214
|
+
const remaining = entries.filter(row => row.state_dir !== entry.state_dir);
|
|
215
|
+
if (!explicit && sameGeneration) remaining.splice(position, 0, merged);
|
|
216
|
+
else remaining.unshift(merged);
|
|
217
|
+
entries = remaining;
|
|
218
|
+
}
|
|
219
|
+
writeTextAtomic(path, `${JSON.stringify({ ...catalog, entries, rebuilt_at: new Date().toISOString() }, null, 2)}\n`,
|
|
220
|
+
{ onBeforeReplace: assertCurrent });
|
|
221
|
+
return entries;
|
|
222
|
+
} catch (error) { failed = true; failure = error; throw error; }
|
|
223
|
+
finally {
|
|
224
|
+
try { release(); }
|
|
225
|
+
catch (error) { throw failed ? new AggregateError([failure, error], "Run state catalog publication and release failed.") : error; }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Kernel metadata registration only; never a producer, work or visibility capability. */
|
|
230
|
+
export function registerRunStateDirectory(stateRoot: string, stateDir: string, status: Record<string, unknown>): void {
|
|
231
|
+
publishDirectoryRegistrations(stateRoot, [prepareDirectoryRegistration(stateDir, status)], true);
|
|
232
|
+
}
|
|
233
|
+
|
|
119
234
|
export function rebuildRunStateIndex(
|
|
120
235
|
stateRoot: string,
|
|
121
236
|
getRunStatus: RunStatusReader,
|
|
122
237
|
): RunStateIndexEntry[] {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
238
|
+
const registrations = listRunStateDirs(stateRoot).flatMap(stateDir => {
|
|
239
|
+
try { return [prepareDirectoryRegistration(stateDir, getRunStatus(stateDir))]; }
|
|
240
|
+
catch { return []; }
|
|
241
|
+
});
|
|
242
|
+
return publishDirectoryRegistrations(stateRoot, registrations, false);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function observeRunInventory(stateDirs: string[], getRunStatus: RunStatusReader): RunStateIndexEntry[] {
|
|
246
|
+
return stateDirs.flatMap(stateDir => {
|
|
247
|
+
try { return [indexEntryFromStatus(getRunStatus(stateDir))]; }
|
|
248
|
+
catch { return []; }
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface RunNavigationFile {
|
|
253
|
+
readonly role: string;
|
|
254
|
+
readonly format_hint: "json" | "jsonl" | "text";
|
|
255
|
+
readonly state: "present" | "missing" | "unavailable";
|
|
256
|
+
readonly path: string | null;
|
|
257
|
+
readonly bytes_total?: number;
|
|
258
|
+
readonly mutable: true;
|
|
259
|
+
}
|
|
260
|
+
export interface RunNavigationItem {
|
|
261
|
+
readonly run: string;
|
|
262
|
+
readonly run_instance_id: string | null;
|
|
263
|
+
readonly state: "available" | "unavailable";
|
|
264
|
+
readonly directory: string | null;
|
|
265
|
+
readonly depth: number;
|
|
266
|
+
readonly files: readonly Readonly<RunNavigationFile>[];
|
|
267
|
+
readonly reason?: string;
|
|
268
|
+
}
|
|
269
|
+
export interface RunNavigationPriority {
|
|
270
|
+
readonly root_order: "latest_registration" | "failed_subtrees_first";
|
|
271
|
+
/** Observed data for ordering only; exact map identity admission remains independent. */
|
|
272
|
+
readonly failed: readonly Readonly<RunContextIndexIdentity & { state_dir: string }>[];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export type RunSessionNavigation =
|
|
276
|
+
| { readonly state: "unavailable"; readonly reason: "session_unavailable" | "catalog_unavailable" | "response_too_large" }
|
|
277
|
+
| { readonly state: "available"; readonly session_id: string; readonly content_scope: "file_locations_only";
|
|
278
|
+
readonly lineage_scope: "direct_session_owned_rows"; readonly file_inventory_scope: "canonical_starting_locations";
|
|
279
|
+
readonly priority?: Readonly<{ root_order: RunNavigationPriority["root_order"]; basis: "observed_failed_rows" }>;
|
|
280
|
+
readonly items: readonly Readonly<RunNavigationItem>[];
|
|
281
|
+
readonly shown: number; readonly omitted: number; readonly total: number };
|
|
282
|
+
|
|
283
|
+
export type RunDirectoryNavigation =
|
|
284
|
+
| { readonly state: "unavailable"; readonly reason: "session_unavailable" | "session_mismatch" | "session_changed" |
|
|
285
|
+
"identity_unavailable" | "identity_mismatch" | "observation_changed" | "navigation_unavailable" | "response_too_large" }
|
|
286
|
+
| { readonly state: "available"; readonly content_scope: "file_locations_only";
|
|
287
|
+
readonly file_inventory_scope: "canonical_starting_locations"; readonly run: string; readonly run_instance_id: string;
|
|
288
|
+
readonly directory: string; readonly files: readonly Readonly<RunNavigationFile>[] };
|
|
289
|
+
|
|
290
|
+
const NAVIGATION_FILES = [
|
|
291
|
+
["context_index", "context-index.json", "json"], ["result", "result.json", "json"], ["metadata", "run.json", "json"],
|
|
292
|
+
["execution", "execution.json", "json"], ["trace", "trace.jsonl", "jsonl"], ["control", "controls.jsonl", "jsonl"],
|
|
293
|
+
["stdout", "stdout.log", "text"], ["stderr", "stderr.log", "text"],
|
|
294
|
+
] as const;
|
|
295
|
+
|
|
296
|
+
function navigationFiles(directory: string, expected: RunContextIndexIdentity): {
|
|
297
|
+
files: readonly Readonly<RunNavigationFile>[]; unchanged: () => boolean;
|
|
298
|
+
} {
|
|
299
|
+
const files: Readonly<RunNavigationFile>[] = NAVIGATION_FILES.map(([role, leaf, format_hint]) => {
|
|
300
|
+
const path = join(directory, leaf);
|
|
301
|
+
try {
|
|
302
|
+
const observed = lstatSync(path);
|
|
303
|
+
if (!observed.isFile() || !Number.isSafeInteger(observed.size) || observed.size < 0) {
|
|
304
|
+
return Object.freeze({ role, format_hint, state: "unavailable" as const, path: null, mutable: true as const });
|
|
130
305
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
306
|
+
return Object.freeze({ role, format_hint, state: "present" as const, path, bytes_total: observed.size, mutable: true as const });
|
|
307
|
+
} catch (error) {
|
|
308
|
+
return Object.freeze({ role, format_hint, state: (error as NodeJS.ErrnoException).code === "ENOENT" ? "missing" as const : "unavailable" as const,
|
|
309
|
+
path: null, mutable: true as const });
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const sessions = observeRunContextExportLocation(directory, expected, "sessions");
|
|
313
|
+
files.splice(4, 0, Object.freeze({ role: "published_sessions", format_hint: "json", mutable: true,
|
|
314
|
+
state: sessions.state === "available" ? "present" : sessions.reason === "export_missing" ? "missing" : "unavailable",
|
|
315
|
+
path: sessions.state === "available" ? sessions.local_path : null,
|
|
316
|
+
...(sessions.state === "available" ? { bytes_total: sessions.bytes_total } : {}) }));
|
|
317
|
+
return { files: Object.freeze(files), unchanged: sessions.state === "available" ? sessions.unchanged : () => true };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Pure data decoder for frozen location packets; schema validity never grants read/publication/work authority. */
|
|
321
|
+
export function decodeRunDirectoryNavigation(value: unknown): Readonly<RunDirectoryNavigation> {
|
|
322
|
+
const invalid = (): never => { throw new Error("Run file navigation data is invalid"); };
|
|
323
|
+
const record = (value: unknown, fields: readonly string[]): Record<string, unknown> => {
|
|
324
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return invalid();
|
|
325
|
+
const descriptors = Object.getOwnPropertyDescriptors(value), result: Record<string, unknown> = {};
|
|
326
|
+
for (const key of Object.keys(descriptors)) {
|
|
327
|
+
if (!fields.includes(key) || !Object.hasOwn(descriptors[key], "value")) return invalid();
|
|
328
|
+
result[key] = descriptors[key].value;
|
|
329
|
+
}
|
|
330
|
+
return result;
|
|
331
|
+
};
|
|
332
|
+
const string = (value: unknown): value is string => typeof value === "string" && value.length > 0 && value.length <= 4096 && Buffer.from(value).toString("utf8") === value;
|
|
333
|
+
const base = record(value, ["state", "reason", "run", "run_instance_id", "directory", "content_scope", "file_inventory_scope", "files"]);
|
|
334
|
+
if (base.state === "unavailable") {
|
|
335
|
+
const reasons = ["session_unavailable", "session_mismatch", "session_changed", "identity_unavailable", "identity_mismatch", "observation_changed", "navigation_unavailable", "response_too_large"];
|
|
336
|
+
if (Object.keys(base).length !== 2 || !reasons.includes(base.reason as string)) return invalid();
|
|
337
|
+
return Object.freeze({ state: "unavailable", reason: base.reason as Extract<RunDirectoryNavigation, { state: "unavailable" }>["reason"] });
|
|
338
|
+
}
|
|
339
|
+
if (base.state !== "available" || Object.keys(base).length !== 7 || !string(base.run) || !string(base.run_instance_id) || !string(base.directory) ||
|
|
340
|
+
base.directory !== resolve(base.directory) || base.content_scope !== "file_locations_only" ||
|
|
341
|
+
base.file_inventory_scope !== "canonical_starting_locations" || !Array.isArray(base.files)) return invalid();
|
|
342
|
+
const slots: readonly (readonly [string, string, string])[] = [...NAVIGATION_FILES.slice(0, 4),
|
|
343
|
+
["published_sessions", runContextExportPath("sessions"), "json"], ...NAVIGATION_FILES.slice(4)];
|
|
344
|
+
if (base.files.length !== slots.length || Object.keys(base.files).length !== slots.length) return invalid();
|
|
345
|
+
const directory = base.directory, sourceFiles = base.files;
|
|
346
|
+
const files = slots.map(([role, leaf, format], index): Readonly<RunNavigationFile> => {
|
|
347
|
+
const descriptor = Object.getOwnPropertyDescriptor(sourceFiles, String(index));
|
|
348
|
+
if (!descriptor || !Object.hasOwn(descriptor, "value")) return invalid();
|
|
349
|
+
const file = record(descriptor.value, ["role", "format_hint", "state", "path", "bytes_total", "mutable"]);
|
|
350
|
+
if (file.role !== role || file.format_hint !== format || file.mutable !== true) return invalid();
|
|
351
|
+
if (file.state === "present") {
|
|
352
|
+
if (file.path !== join(directory, leaf) || typeof file.bytes_total !== "number" || !Number.isSafeInteger(file.bytes_total) || file.bytes_total < 0) return invalid();
|
|
353
|
+
return Object.freeze({ role, format_hint: format as RunNavigationFile["format_hint"], state: "present", path: file.path as string, bytes_total: file.bytes_total, mutable: true });
|
|
354
|
+
}
|
|
355
|
+
if ((file.state !== "missing" && file.state !== "unavailable") || file.path !== null || file.bytes_total !== undefined) return invalid();
|
|
356
|
+
return Object.freeze({ role, format_hint: format as RunNavigationFile["format_hint"], state: file.state, path: null, mutable: true });
|
|
357
|
+
});
|
|
358
|
+
const answer = Object.freeze({ state: "available" as const, content_scope: "file_locations_only" as const,
|
|
359
|
+
file_inventory_scope: "canonical_starting_locations" as const, run: base.run, run_instance_id: base.run_instance_id,
|
|
360
|
+
directory, files: Object.freeze(files) });
|
|
361
|
+
return Buffer.byteLength(JSON.stringify(answer), "utf8") <= RUN_DELIVERY_MODEL_MAX_BYTES ? answer : invalid();
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** One exact current-session Run's physical starting locations; no catalog/body reads or authority recovery. */
|
|
365
|
+
export function readRunDirectoryNavigation(stateDir: string, expected: unknown, sessionId: string | undefined): Readonly<RunDirectoryNavigation> {
|
|
366
|
+
const unavailable = (reason: Extract<RunDirectoryNavigation, { state: "unavailable" }>["reason"]): Readonly<RunDirectoryNavigation> =>
|
|
367
|
+
Object.freeze({ state: "unavailable", reason });
|
|
368
|
+
if (typeof sessionId !== "string" || !sessionId) return unavailable("session_unavailable");
|
|
369
|
+
const owner = expected && typeof expected === "object" ? Object.getOwnPropertyDescriptor(expected, "ownerId") : undefined;
|
|
370
|
+
if (!owner || !Object.hasOwn(owner, "value") || owner.value !== sessionId) return unavailable("session_mismatch");
|
|
371
|
+
const identity = readRunContextIdentity(stateDir, expected);
|
|
372
|
+
if (identity.state !== "available") return unavailable(identity.reason);
|
|
373
|
+
const observed = navigationFiles(identity.local_path, identity.identity);
|
|
374
|
+
const value = Object.freeze({ state: "available" as const, content_scope: "file_locations_only" as const,
|
|
375
|
+
file_inventory_scope: "canonical_starting_locations" as const, run: identity.identity.run,
|
|
376
|
+
run_instance_id: identity.identity.run_instance_id, directory: identity.local_path, files: observed.files });
|
|
377
|
+
if (!identity.unchanged() || !observed.unchanged()) return unavailable("observation_changed");
|
|
378
|
+
return Buffer.byteLength(JSON.stringify(value), "utf8") <= RUN_DELIVERY_MODEL_MAX_BYTES ? value : unavailable("response_too_large");
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Current Kernel session selection only; no body reads, scans, producer key or old manager retention. */
|
|
382
|
+
export function readRunSessionNavigation(stateRoot: string, sessionId: string, priority?: RunNavigationPriority): Readonly<RunSessionNavigation> {
|
|
383
|
+
const unavailable = (reason: Extract<RunSessionNavigation, { state: "unavailable" }>["reason"]): Readonly<RunSessionNavigation> => Object.freeze({ state: "unavailable", reason });
|
|
384
|
+
if (typeof sessionId !== "string" || !sessionId) return unavailable("session_unavailable");
|
|
385
|
+
let catalog: RunStateCatalog | undefined;
|
|
386
|
+
try { catalog = readCatalog(runIndexPath(stateRoot)); }
|
|
387
|
+
catch { return unavailable("catalog_unavailable"); }
|
|
388
|
+
if (!catalog) return unavailable("catalog_unavailable");
|
|
389
|
+
const selected = catalog.entries.filter(row => row.ownerId === sessionId);
|
|
390
|
+
if (new Set(selected.map(row => row.state_dir)).size !== selected.length) return unavailable("catalog_unavailable");
|
|
391
|
+
const key = (row: { run: string; run_instance_id?: unknown; state_dir: string }) => JSON.stringify([row.run, row.run_instance_id, row.state_dir]);
|
|
392
|
+
const nodes = selected.map(row => {
|
|
393
|
+
const invalid = (reason: string): Readonly<RunNavigationItem> => Object.freeze({ run: row.run,
|
|
394
|
+
run_instance_id: typeof row.run_instance_id === "string" ? row.run_instance_id : null,
|
|
395
|
+
state: "unavailable", directory: null, depth: 0, files: Object.freeze([]), reason });
|
|
396
|
+
if (typeof row.run_instance_id !== "string" || !row.run_instance_id) return { key: key(row), item: invalid("generation_unavailable"), parent: undefined, unchanged: () => true };
|
|
397
|
+
const identity = readRunContextIdentity(row.state_dir, { run: row.run, run_instance_id: row.run_instance_id, ownerId: sessionId });
|
|
398
|
+
if (identity.state !== "available") return { key: key(row), item: invalid(identity.reason), parent: undefined, unchanged: () => true };
|
|
399
|
+
const read = readJsonFileResilient<Record<string, unknown> | undefined>(join(identity.local_path, "run.json"), undefined,
|
|
400
|
+
{ maxBytes: RUN_CONTEXT_SOURCE_METADATA_MAX_BYTES, strictUtf8: true });
|
|
401
|
+
if (read.diagnostics.length || !read.value || !identity.unchanged()) {
|
|
402
|
+
return { key: key(row), item: invalid("observation_changed"), parent: undefined, unchanged: () => true };
|
|
403
|
+
}
|
|
404
|
+
const parent = read.value.delivery_parent;
|
|
405
|
+
const p = parent && typeof parent === "object" && !Array.isArray(parent) ? parent as Record<string, unknown> : undefined;
|
|
406
|
+
const parentKey = p && typeof p.run === "string" && typeof p.run_instance_id === "string" && typeof p.state_dir === "string"
|
|
407
|
+
? key({ run: p.run, run_instance_id: p.run_instance_id, state_dir: p.state_dir }) : undefined;
|
|
408
|
+
const files = navigationFiles(identity.local_path, identity.identity);
|
|
409
|
+
const item: Readonly<RunNavigationItem> = Object.freeze({ run: row.run, run_instance_id: row.run_instance_id,
|
|
410
|
+
state: "available", directory: identity.local_path, depth: 0, files: files.files });
|
|
411
|
+
return { key: key(row), item, parent: parentKey, unchanged: () => identity.unchanged() && files.unchanged() };
|
|
136
412
|
});
|
|
137
|
-
|
|
413
|
+
const byKey = new Map(nodes.map(node => [node.key, node]));
|
|
414
|
+
const children = new Map<string, typeof nodes>();
|
|
415
|
+
const roots: typeof nodes = [];
|
|
416
|
+
for (const node of nodes) {
|
|
417
|
+
if (node.parent && byKey.has(node.parent)) {
|
|
418
|
+
const siblings = children.get(node.parent) ?? []; siblings.push(node); children.set(node.parent, siblings);
|
|
419
|
+
} else roots.push(node);
|
|
420
|
+
}
|
|
421
|
+
const failedSubtrees = new Set<string>();
|
|
422
|
+
for (const failure of priority?.failed ?? []) {
|
|
423
|
+
if (failure.ownerId !== sessionId) continue;
|
|
424
|
+
const observedKey = key(failure), node = byKey.get(observedKey);
|
|
425
|
+
if (node?.item.state === "available") failedSubtrees.add(observedKey);
|
|
426
|
+
}
|
|
427
|
+
const pending = [...failedSubtrees];
|
|
428
|
+
while (pending.length) {
|
|
429
|
+
const parent = byKey.get(pending.pop()!)?.parent;
|
|
430
|
+
if (parent && byKey.get(parent)?.item.state === "available" && !failedSubtrees.has(parent)) {
|
|
431
|
+
failedSubtrees.add(parent); pending.push(parent);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
// Stable partition preserves catalog recency among peers; a failed descendant never precedes its own ancestors.
|
|
435
|
+
const preferFailed = (peers: typeof nodes): typeof nodes => [
|
|
436
|
+
...peers.filter(node => failedSubtrees.has(node.key)), ...peers.filter(node => !failedSubtrees.has(node.key)),
|
|
437
|
+
];
|
|
438
|
+
const ordered: Readonly<RunNavigationItem>[] = [];
|
|
439
|
+
const seen = new Set<string>();
|
|
440
|
+
const orderedRoots = priority?.root_order === "failed_subtrees_first" ? preferFailed(roots) : roots;
|
|
441
|
+
const stack = orderedRoots.slice().reverse().map(node => ({ node, depth: 0 }));
|
|
442
|
+
while (stack.length) {
|
|
443
|
+
const { node, depth } = stack.pop()!;
|
|
444
|
+
if (seen.has(node.key)) continue;
|
|
445
|
+
seen.add(node.key);
|
|
446
|
+
ordered.push(Object.freeze({ ...node.item, depth }));
|
|
447
|
+
for (const child of preferFailed(children.get(node.key) ?? []).reverse()) stack.push({ node: child, depth: depth + 1 });
|
|
448
|
+
}
|
|
449
|
+
for (const node of nodes) if (!seen.has(node.key)) ordered.push(Object.freeze({ ...node.item,
|
|
450
|
+
state: "unavailable", reason: "lineage_cycle", directory: null, files: Object.freeze([]) }));
|
|
451
|
+
const items: Readonly<RunNavigationItem>[] = [];
|
|
452
|
+
const result = () => Object.freeze({ state: "available" as const, session_id: sessionId,
|
|
453
|
+
content_scope: "file_locations_only" as const, lineage_scope: "direct_session_owned_rows" as const,
|
|
454
|
+
file_inventory_scope: "canonical_starting_locations" as const,
|
|
455
|
+
...(priority ? { priority: Object.freeze({ root_order: priority.root_order, basis: "observed_failed_rows" as const }) } : {}),
|
|
456
|
+
items: Object.freeze(items.slice()), shown: items.length, omitted: ordered.length - items.length, total: ordered.length });
|
|
457
|
+
if (Buffer.byteLength(JSON.stringify(result())) > RUN_DELIVERY_MODEL_MAX_BYTES) return unavailable("response_too_large");
|
|
458
|
+
for (const item of ordered) {
|
|
459
|
+
items.push(item);
|
|
460
|
+
if (Buffer.byteLength(JSON.stringify(result())) > RUN_DELIVERY_MODEL_MAX_BYTES) { items.pop(); break; }
|
|
461
|
+
}
|
|
462
|
+
const answer = result();
|
|
463
|
+
return nodes.some(node => !node.unchanged()) ? unavailable("catalog_unavailable") : answer;
|
|
138
464
|
}
|
|
139
465
|
|
|
140
466
|
export function readRunStateIndex(
|
|
@@ -185,7 +511,9 @@ export function listRuns(
|
|
|
185
511
|
): Array<Record<string, unknown>> {
|
|
186
512
|
if (!existsSync(stateRoot)) return [];
|
|
187
513
|
const indexed = readRunStateIndex(stateRoot, readJson);
|
|
188
|
-
|
|
514
|
+
// The catalog locates directories; registration-time status cannot decide current inventory or filters.
|
|
515
|
+
const entries = observeRunInventory(indexed ? indexed.map(entry => entry.state_dir) : listRunStateDirs(stateRoot), getRunStatus);
|
|
516
|
+
if (!indexed) entries.sort((a, b) => (b.updated_at ?? "").localeCompare(a.updated_at ?? ""));
|
|
189
517
|
return entries
|
|
190
518
|
.filter((entry) => matchesStatusFilter(entry.status, statusFilter))
|
|
191
519
|
.map(compactIndexEntry);
|