@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
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Run clock binding and explicit runtime-local supervision ownership.
|
|
3
|
+
* Owns: bounded readonly clock/frame admission, origin/reference retention, first-natural timing freezes, composed snapshots and cooperative same-origin controller claims.
|
|
4
|
+
* Excludes: origin creation/backfill, global/cross-runtime leases, independent supervision/recovery, work/native authority and actuation.
|
|
5
|
+
*/
|
|
6
|
+
import { lstatSync, type BigIntStats } from "node:fs";
|
|
7
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
8
|
+
import { readRunSupervisionClock, createRunSupervisionController, createRunSupervisionTimebase,
|
|
9
|
+
type RunSupervisionClock, type RunSupervisionController, type RunSupervisionControllerPorts, type RunSupervisionControllerSnapshot,
|
|
10
|
+
type RunSupervisionTimebaseReading, type RunSupervisionTimeObservation } from "./run-supervision.ts";
|
|
11
|
+
import { readRunContextIdentity, RUN_CONTEXT_SOURCE_METADATA_MAX_BYTES, RUN_CONTEXT_INDEX_METADATA_MAX_BYTES, type RunContextIndexIdentity } from "./runs-context-index.ts";
|
|
12
|
+
import { readOwnedRunStateDirectory, RUN_STATE_OWNERSHIP_FILE } from "./runs-ownership.ts";
|
|
13
|
+
import { readJsonFileResilient } from "./state-readers.ts";
|
|
14
|
+
import { admitRunSnapshotReferenceReader, type RunSnapshotReferenceReader, type RunSnapshotReferencesReading } from "./runs-context-exports.ts";
|
|
15
|
+
import { readRunSnapshotFacts, type RunSnapshotFactsReading } from "./runs-status.ts";
|
|
16
|
+
import { projectRunSnapshot, type RunSnapshot, type RunSnapshotProjection } from "./runs-snapshot.ts";
|
|
17
|
+
import { withRunNaturalResultTimingAdmission, readRunNaturalResultTimingAcceptance,
|
|
18
|
+
type RunNaturalResultTimingAdmission, type RunNaturalResultTimingAcceptance, type RunResultProducer } from "./runs-results.ts";
|
|
19
|
+
|
|
20
|
+
export type RunSupervisionBindingReading =
|
|
21
|
+
| { readonly state: "available"; readonly identity: Readonly<RunContextIndexIdentity>; readonly clock: Readonly<RunSupervisionClock>; readonly unchanged: () => boolean }
|
|
22
|
+
| { readonly state: "unavailable"; readonly reason: "identity_unavailable" | "identity_mismatch" | "observation_changed" |
|
|
23
|
+
"clock_metadata_unavailable" | "clock_unconfigured" | "clock_invalid" };
|
|
24
|
+
type Unavailable = Extract<RunSupervisionBindingReading, { state: "unavailable" }>;
|
|
25
|
+
type ObservedBinding = Extract<RunSupervisionBindingReading, { state: "available" }> & { readonly frameUnchanged: () => boolean };
|
|
26
|
+
export type BoundRunSupervisionControllerReading =
|
|
27
|
+
| { readonly state: "available"; readonly controller: Readonly<RunSupervisionController> }
|
|
28
|
+
| Unavailable | Extract<RunSupervisionTimebaseReading, { state: "unavailable" }>;
|
|
29
|
+
function unavailable(reason: Unavailable["reason"]): Readonly<Unavailable> { return Object.freeze({ state: "unavailable", reason }); }
|
|
30
|
+
function sameObject(a: BigIntStats, b: BigIntStats): boolean { return a.dev === b.dev && a.ino === b.ino; }
|
|
31
|
+
function sameFile(a: BigIntStats, b: BigIntStats): boolean {
|
|
32
|
+
return b.isFile() && sameObject(a, b) && a.size === b.size && a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs;
|
|
33
|
+
}
|
|
34
|
+
function observeBinding(stateDir: string, expected: unknown): Readonly<ObservedBinding | Unavailable> {
|
|
35
|
+
const owner = readRunContextIdentity(stateDir, expected);
|
|
36
|
+
if (owner.state === "unavailable") return owner;
|
|
37
|
+
try {
|
|
38
|
+
const root = owner.local_path; const path = join(root, "run.json"); const markerPath = join(root, RUN_STATE_OWNERSHIP_FILE);
|
|
39
|
+
const directory = lstatSync(root, { bigint: true }); const marker = lstatSync(markerPath, { bigint: true }); const before = lstatSync(path, { bigint: true });
|
|
40
|
+
if (!directory.isDirectory() || !marker.isFile() || !before.isFile() || before.size > BigInt(RUN_CONTEXT_SOURCE_METADATA_MAX_BYTES)) return unavailable("clock_metadata_unavailable");
|
|
41
|
+
const read = readJsonFileResilient<unknown>(path, undefined, { maxBytes: RUN_CONTEXT_SOURCE_METADATA_MAX_BYTES, strictUtf8: true });
|
|
42
|
+
const unchanged = (): boolean => {
|
|
43
|
+
try { return owner.unchanged() && sameFile(before, lstatSync(path, { bigint: true })); } catch { return false; }
|
|
44
|
+
};
|
|
45
|
+
if (!unchanged()) return unavailable("observation_changed");
|
|
46
|
+
if (read.diagnostics.length || !read.value || typeof read.value !== "object" || Array.isArray(read.value)) return unavailable("clock_metadata_unavailable");
|
|
47
|
+
const meta = read.value as Record<string, unknown>;
|
|
48
|
+
if (meta.run !== owner.identity.run || meta.run_instance_id !== owner.identity.run_instance_id || meta.ownerId !== owner.identity.ownerId || meta.state_dir !== root) return unavailable("identity_mismatch");
|
|
49
|
+
let decoded: RunSupervisionClock | undefined;
|
|
50
|
+
try { decoded = readRunSupervisionClock(meta); } catch { return unavailable("clock_invalid"); }
|
|
51
|
+
if (!decoded) return unavailable("clock_unconfigured");
|
|
52
|
+
const clock = Object.freeze({ started_at: decoded.started_at, supervision: Object.freeze({ ...decoded.supervision }) });
|
|
53
|
+
const frameUnchanged = (): boolean => {
|
|
54
|
+
try { const current = lstatSync(root, { bigint: true }); return current.isDirectory() && sameObject(directory, current) && sameFile(marker, lstatSync(markerPath, { bigint: true })); }
|
|
55
|
+
catch { return false; }
|
|
56
|
+
};
|
|
57
|
+
if (!unchanged() || !frameUnchanged()) return unavailable("observation_changed");
|
|
58
|
+
return Object.freeze({ state: "available", identity: owner.identity, clock, unchanged, frameUnchanged });
|
|
59
|
+
} catch { return unavailable("clock_metadata_unavailable"); }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Curated metadata only; no current-time read, clock repair, lifecycle/native observation or role body. */
|
|
63
|
+
export function readRunSupervisionBinding(stateDir: string, expected: unknown): Readonly<RunSupervisionBindingReading> {
|
|
64
|
+
const observed = observeBinding(stateDir, expected);
|
|
65
|
+
return observed.state === "unavailable" ? observed : Object.freeze({ state: "available", identity: observed.identity, clock: observed.clock, unchanged: observed.unchanged });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Does not start automatically; origin must be the genuine reference retained from generation admission. */
|
|
69
|
+
export function createRunSupervisionControllerFromState(stateDir: string, expected: unknown, origin: unknown,
|
|
70
|
+
ports: Omit<RunSupervisionControllerPorts, "readCurrent">): Readonly<BoundRunSupervisionControllerReading> {
|
|
71
|
+
const initial = observeBinding(stateDir, expected);
|
|
72
|
+
if (initial.state === "unavailable") return initial;
|
|
73
|
+
const timebase = createRunSupervisionTimebase(initial.clock, origin);
|
|
74
|
+
if (timebase.state === "unavailable") return timebase;
|
|
75
|
+
if (!initial.unchanged()) return unavailable("observation_changed");
|
|
76
|
+
const controller = createRunSupervisionController(initial.identity, timebase.timebase, {
|
|
77
|
+
...ports,
|
|
78
|
+
readCurrent: () => {
|
|
79
|
+
if (!initial.frameUnchanged()) return null;
|
|
80
|
+
const current = observeBinding(stateDir, initial.identity);
|
|
81
|
+
if (current.state === "unavailable" || !current.unchanged() || !initial.frameUnchanged()) return null;
|
|
82
|
+
return Object.freeze({ identity: current.identity, clock: current.clock });
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
return Object.freeze({ state: "available", controller });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// --- Explicit runtime-local retention ---
|
|
90
|
+
|
|
91
|
+
export type RunSupervisionOwnerReading =
|
|
92
|
+
| { readonly state: "retained" | "stopped" | "released"; readonly identity: Readonly<RunContextIndexIdentity>; readonly controller?: Readonly<RunSupervisionControllerSnapshot> }
|
|
93
|
+
| { readonly state: "controlled"; readonly identity: Readonly<RunContextIndexIdentity>; readonly controller: Readonly<RunSupervisionControllerSnapshot> }
|
|
94
|
+
| { readonly state: "unavailable"; readonly reason: Extract<BoundRunSupervisionControllerReading, { state: "unavailable" }>["reason"] |
|
|
95
|
+
"identity_invalid" | "origin_not_retained" | "owner_closed" | "controller_claimed" };
|
|
96
|
+
type OwnerUnavailable = Extract<RunSupervisionOwnerReading, { state: "unavailable" }>;
|
|
97
|
+
export type RunSupervisionOwnerTimeReading =
|
|
98
|
+
| { readonly state: "available"; readonly basis: "since_admission"; readonly identity: Readonly<RunContextIndexIdentity>;
|
|
99
|
+
readonly timing: Readonly<RunSupervisionTimeObservation>; readonly unchanged: () => boolean }
|
|
100
|
+
| { readonly state: "unavailable"; readonly reason: OwnerUnavailable["reason"] | "owner_stopped" };
|
|
101
|
+
export type RunSupervisionOwnerReferencesReading = RunSnapshotReferencesReading | OwnerUnavailable |
|
|
102
|
+
{ readonly state: "unavailable"; readonly reason: "owner_stopped" | "references_not_retained" };
|
|
103
|
+
export type RunSupervisionOwnerSnapshotReading =
|
|
104
|
+
| { readonly state: "available"; readonly snapshot: Readonly<RunSnapshot>; readonly unchanged: () => boolean }
|
|
105
|
+
| Extract<RunSnapshotProjection | RunSnapshotFactsReading | RunSupervisionOwnerReferencesReading, { state: "unavailable" }>;
|
|
106
|
+
export type RunSupervisionOwnerNaturalTimeReading =
|
|
107
|
+
| { readonly state: "available"; readonly basis: "first_natural_acceptance"; readonly identity: Readonly<RunContextIndexIdentity>;
|
|
108
|
+
readonly elapsed_ms: number; readonly natural_acceptance: Readonly<{ code: number; recorded_status: "done" | "failed"; completed_at: string }>;
|
|
109
|
+
readonly unchanged: () => boolean }
|
|
110
|
+
| Extract<RunSupervisionOwnerTimeReading, { state: "unavailable" }>
|
|
111
|
+
| { readonly state: "unavailable"; readonly reason: "natural_time_not_captured" | "natural_time_capturing" | "natural_time_unproven" | "natural_acceptance_mismatch" };
|
|
112
|
+
export interface RunSupervisionOwnerClose {
|
|
113
|
+
readonly state: "closed";
|
|
114
|
+
readonly timer_cleanup?: "unproven";
|
|
115
|
+
}
|
|
116
|
+
export interface RunSupervisionOwner {
|
|
117
|
+
readonly onSupervisionClockCaptured: (capture: unknown) => void;
|
|
118
|
+
readonly start: (expected: unknown) => Readonly<RunSupervisionOwnerReading>;
|
|
119
|
+
readonly stop: (expected: unknown) => Readonly<RunSupervisionOwnerReading>;
|
|
120
|
+
readonly release: (expected: unknown) => Readonly<RunSupervisionOwnerReading>;
|
|
121
|
+
readonly snapshot: (expected: unknown) => Readonly<RunSupervisionOwnerReading>;
|
|
122
|
+
readonly observeTime: (expected: unknown, stateDir?: string) => Readonly<RunSupervisionOwnerTimeReading>;
|
|
123
|
+
readonly observeReferences: (expected: unknown, stateDir?: string) => Readonly<RunSupervisionOwnerReferencesReading>;
|
|
124
|
+
/** Active postcommit admission only; the first authorized attempt is final across original-origin owners. */
|
|
125
|
+
readonly captureNaturalTime: (expected: unknown, producer: RunResultProducer, admission: RunNaturalResultTimingAdmission, stateDir?: string) => Readonly<RunSupervisionOwnerNaturalTimeReading>;
|
|
126
|
+
/** Historical elapsed plus current owner/clock/frame, not current result/lifecycle or a new sample. */
|
|
127
|
+
readonly observeFrozenNaturalTime: (expected: unknown, stateDir?: string) => Readonly<RunSupervisionOwnerNaturalTimeReading>;
|
|
128
|
+
readonly observeSnapshot: (expected: unknown, capturedAt: unknown, stateDir?: string) => Readonly<RunSupervisionOwnerSnapshotReading>;
|
|
129
|
+
readonly close: () => Readonly<RunSupervisionOwnerClose>;
|
|
130
|
+
}
|
|
131
|
+
interface SharedOriginClaim {
|
|
132
|
+
readonly binding: string;
|
|
133
|
+
readonly frameUnchanged: () => boolean;
|
|
134
|
+
holder?: object;
|
|
135
|
+
natural?: FrozenNaturalTime;
|
|
136
|
+
}
|
|
137
|
+
type FrozenNaturalTime =
|
|
138
|
+
| { readonly state: "capturing" | "unproven"; readonly producer: RunResultProducer; readonly admission: RunNaturalResultTimingAdmission }
|
|
139
|
+
| { readonly state: "frozen"; readonly producer: RunResultProducer; readonly admission: RunNaturalResultTimingAdmission;
|
|
140
|
+
readonly acceptance: Readonly<RunNaturalResultTimingAcceptance>; readonly elapsed_ms: number };
|
|
141
|
+
// Cooperative claims share only genuine origins in this module/runtime, never persisted or native scope authority.
|
|
142
|
+
const sharedOriginClaims = new WeakMap<object, SharedOriginClaim>();
|
|
143
|
+
interface RetainedSupervision {
|
|
144
|
+
readonly claim: SharedOriginClaim;
|
|
145
|
+
readonly token: object;
|
|
146
|
+
readonly identity: Readonly<RunContextIndexIdentity>;
|
|
147
|
+
readonly stateDir: string;
|
|
148
|
+
readonly origin: object;
|
|
149
|
+
readonly clockKey: string;
|
|
150
|
+
readonly references?: Readonly<RunSnapshotReferenceReader>;
|
|
151
|
+
readonly frameUnchanged: () => boolean;
|
|
152
|
+
stopped: boolean;
|
|
153
|
+
controller?: Readonly<RunSupervisionController>;
|
|
154
|
+
}
|
|
155
|
+
function own(value: unknown, key: string): unknown {
|
|
156
|
+
return value && typeof value === "object" && !Array.isArray(value) ? Object.getOwnPropertyDescriptor(value, key)?.value : undefined;
|
|
157
|
+
}
|
|
158
|
+
function ownerIdentity(value: unknown): Readonly<RunContextIndexIdentity> | undefined {
|
|
159
|
+
const run = own(value, "run"); const generation = own(value, "run_instance_id");
|
|
160
|
+
const descriptor = value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, "ownerId") : undefined; const owner = descriptor?.value;
|
|
161
|
+
if (typeof run !== "string" || !run || /[^A-Za-z0-9_.-]/u.test(run) || typeof generation !== "string" || !generation ||
|
|
162
|
+
(descriptor && !Object.hasOwn(descriptor, "value")) || (owner !== undefined && (typeof owner !== "string" || !owner))) return undefined;
|
|
163
|
+
return Object.freeze({ run, run_instance_id: generation, ...(owner === undefined ? {} : { ownerId: owner }) });
|
|
164
|
+
}
|
|
165
|
+
function ownerKey(identity: RunContextIndexIdentity): string { return JSON.stringify([identity.run, identity.run_instance_id, identity.ownerId ?? null]); }
|
|
166
|
+
function retainAdmissionFrame(stateDir: string, run: string): (() => boolean) | undefined {
|
|
167
|
+
try {
|
|
168
|
+
const directory = lstatSync(stateDir, { bigint: true }); const markerPath = join(stateDir, RUN_STATE_OWNERSHIP_FILE); const marker = lstatSync(markerPath, { bigint: true });
|
|
169
|
+
if (!directory.isDirectory() || !marker.isFile()) return undefined;
|
|
170
|
+
const unchanged = (): boolean => {
|
|
171
|
+
try { const current = lstatSync(stateDir, { bigint: true }); return current.isDirectory() && sameObject(directory, current) && sameFile(marker, lstatSync(markerPath, { bigint: true })); }
|
|
172
|
+
catch { return false; }
|
|
173
|
+
};
|
|
174
|
+
const owned = readOwnedRunStateDirectory(stateDir, { maxBytes: RUN_CONTEXT_INDEX_METADATA_MAX_BYTES });
|
|
175
|
+
return owned.run === run && owned.stateDir === stateDir && unchanged() ? unchanged : undefined;
|
|
176
|
+
} catch { return undefined; }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Explicit retention with cooperative same-origin claims; no default watcher, cross-process lease or independent supervisor. */
|
|
180
|
+
export function createRunSupervisionOwner(ports: Omit<RunSupervisionControllerPorts, "readCurrent">): Readonly<RunSupervisionOwner> {
|
|
181
|
+
const schedule = ports.schedule; const notify = ports.onDeadlineDue;
|
|
182
|
+
if (typeof notify !== "function" || (schedule !== undefined && typeof schedule !== "function")) throw new Error("Run supervision owner requires synchronous controller ports.");
|
|
183
|
+
const retainedPorts = Object.freeze({ onDeadlineDue: notify.bind(ports), ...(schedule === undefined ? {} : { schedule: schedule.bind(ports) }) });
|
|
184
|
+
const records = new Map<string, RetainedSupervision>(); const origins = new WeakMap<object, string>();
|
|
185
|
+
let closed = false; let cleanupUnproven = false;
|
|
186
|
+
const absent = (reason: OwnerUnavailable["reason"]): Readonly<OwnerUnavailable> => Object.freeze({ state: "unavailable", reason });
|
|
187
|
+
const find = (expected: unknown): RetainedSupervision | Readonly<OwnerUnavailable> => {
|
|
188
|
+
if (closed) return absent("owner_closed");
|
|
189
|
+
const identity = ownerIdentity(expected); if (!identity) return absent("identity_invalid");
|
|
190
|
+
return records.get(ownerKey(identity)) ?? absent("origin_not_retained");
|
|
191
|
+
};
|
|
192
|
+
const view = (record: RetainedSupervision): Readonly<RunSupervisionOwnerReading> => {
|
|
193
|
+
const controller = record.controller?.snapshot();
|
|
194
|
+
return record.stopped ? Object.freeze({ state: "stopped", identity: record.identity, ...(controller ? { controller } : {}) })
|
|
195
|
+
: controller ? Object.freeze({ state: "controlled", identity: record.identity, controller })
|
|
196
|
+
: Object.freeze({ state: "retained", identity: record.identity });
|
|
197
|
+
};
|
|
198
|
+
const snapshot = (expected: unknown): Readonly<RunSupervisionOwnerReading> => { const record = find(expected); return "state" in record ? record : view(record); };
|
|
199
|
+
const rememberCleanup = (record: RetainedSupervision): void => { if (record.controller?.snapshot().timer_cleanup === "unproven") cleanupUnproven = true; };
|
|
200
|
+
const releaseClaim = (record: RetainedSupervision): void => { if (record.claim.holder === record.token) record.claim.holder = undefined; };
|
|
201
|
+
const stopRecord = (record: RetainedSupervision): void => {
|
|
202
|
+
if (record.stopped) return;
|
|
203
|
+
record.stopped = true; record.controller?.stop(); rememberCleanup(record);
|
|
204
|
+
};
|
|
205
|
+
const revokedRecord = (record: RetainedSupervision): Extract<RunSupervisionOwnerTimeReading, { state: "unavailable" }> | undefined => {
|
|
206
|
+
if (closed) return absent("owner_closed");
|
|
207
|
+
if (records.get(ownerKey(record.identity)) !== record) return absent("origin_not_retained");
|
|
208
|
+
if (record.stopped) return Object.freeze({ state: "unavailable", reason: "owner_stopped" });
|
|
209
|
+
if (!record.frameUnchanged()) return absent("observation_changed");
|
|
210
|
+
// Frame ports are synchronous, but can reenter this owner; never let their last read hide revocation.
|
|
211
|
+
if (closed) return absent("owner_closed");
|
|
212
|
+
if (records.get(ownerKey(record.identity)) !== record) return absent("origin_not_retained");
|
|
213
|
+
return record.stopped ? Object.freeze({ state: "unavailable", reason: "owner_stopped" }) : undefined;
|
|
214
|
+
};
|
|
215
|
+
const owner: Readonly<RunSupervisionOwner> = Object.freeze({
|
|
216
|
+
onSupervisionClockCaptured: (capture: unknown): void => {
|
|
217
|
+
if (closed) throw new Error("Run supervision owner is closed.");
|
|
218
|
+
const identity = ownerIdentity(own(capture, "identity")); const stateDir = own(capture, "state_dir"); const origin = own(capture, "origin"); const metadata = own(capture, "clock");
|
|
219
|
+
if (own(capture, "kind") !== "run_clock_origin_captured" || own(capture, "visibility") !== "kernel_only" ||
|
|
220
|
+
own(capture, "publication") !== "unpublished" || own(capture, "work_started") !== false ||
|
|
221
|
+
!identity || typeof stateDir !== "string" || !isAbsolute(stateDir) || resolve(stateDir) !== stateDir || !origin || typeof origin !== "object") {
|
|
222
|
+
throw new Error("Run supervision clock capture is invalid.");
|
|
223
|
+
}
|
|
224
|
+
const referenceDescriptor = Object.getOwnPropertyDescriptor(capture as object, "snapshot_references");
|
|
225
|
+
const references = referenceDescriptor && Object.hasOwn(referenceDescriptor, "value")
|
|
226
|
+
? admitRunSnapshotReferenceReader(stateDir, identity, referenceDescriptor.value) : undefined;
|
|
227
|
+
if (referenceDescriptor && !references) throw new Error("Run supervision snapshot-reference capture is invalid.");
|
|
228
|
+
const key = ownerKey(identity); const existing = records.get(key); let decoded: RunSupervisionClock | undefined;
|
|
229
|
+
const policy = own(metadata, "supervision");
|
|
230
|
+
try { decoded = readRunSupervisionClock({ started_at: own(metadata, "started_at"), supervision: {
|
|
231
|
+
report_every_ms: own(policy, "report_every_ms"), max_runtime_ms: own(policy, "max_runtime_ms"), deadline_at: own(policy, "deadline_at"),
|
|
232
|
+
}, ...(metadata && typeof metadata === "object" && Object.hasOwn(metadata, "createdAt") ? { createdAt: own(metadata, "createdAt") } : {}) }); }
|
|
233
|
+
catch { throw new Error("Run supervision clock capture is invalid."); }
|
|
234
|
+
if (!decoded) throw new Error("Run supervision clock capture is invalid.");
|
|
235
|
+
const clockKey = JSON.stringify(decoded);
|
|
236
|
+
if (existing) {
|
|
237
|
+
if (existing.origin !== origin || existing.stateDir !== stateDir || existing.clockKey !== clockKey || existing.references !== references || !existing.frameUnchanged()) {
|
|
238
|
+
throw new Error("Run supervision clock capture conflicts with retained identity, state or origin.");
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (origins.has(origin)) throw new Error("Run supervision origin is already retained or released by this owner.");
|
|
243
|
+
const timebase = createRunSupervisionTimebase(decoded, origin);
|
|
244
|
+
if (timebase.state === "unavailable") throw new Error("Run supervision clock capture origin is unavailable or incompatible.");
|
|
245
|
+
const frameUnchanged = retainAdmissionFrame(stateDir, identity.run);
|
|
246
|
+
if (!frameUnchanged) throw new Error("Run supervision admission state frame is unavailable or changed.");
|
|
247
|
+
const binding = JSON.stringify([stateDir, key]); let claim = sharedOriginClaims.get(origin);
|
|
248
|
+
if (claim && claim.binding !== binding) throw new Error("Run supervision origin binding already belongs to another identity or state.");
|
|
249
|
+
if (claim && !claim.frameUnchanged()) throw new Error("Run supervision origin admission frame changed.");
|
|
250
|
+
if (closed) throw new Error("Run supervision owner is closed.");
|
|
251
|
+
if (records.has(key) || origins.has(origin)) throw new Error("Run supervision origin is already retained or released by this owner.");
|
|
252
|
+
if (!claim) { claim = { binding, frameUnchanged }; sharedOriginClaims.set(origin, claim); }
|
|
253
|
+
records.set(key, { identity, stateDir, origin, clockKey, references, frameUnchanged: claim.frameUnchanged, claim, token: {}, stopped: false }); origins.set(origin, key);
|
|
254
|
+
},
|
|
255
|
+
start: (expected: unknown): Readonly<RunSupervisionOwnerReading> => {
|
|
256
|
+
const record = find(expected); if ("state" in record) return record;
|
|
257
|
+
if (record.stopped) return view(record);
|
|
258
|
+
if (!record.controller) {
|
|
259
|
+
if (!record.frameUnchanged()) return absent("observation_changed");
|
|
260
|
+
if (record.claim.holder && record.claim.holder !== record.token) return absent("controller_claimed");
|
|
261
|
+
record.claim.holder = record.token;
|
|
262
|
+
try {
|
|
263
|
+
const scheduleWake = retainedPorts.schedule;
|
|
264
|
+
const controllerPorts = scheduleWake ? { ...retainedPorts, schedule: (wake: () => void, milliseconds: number) =>
|
|
265
|
+
scheduleWake(() => { try { wake(); } finally { rememberCleanup(record); } }, milliseconds) } : retainedPorts;
|
|
266
|
+
const reading = createRunSupervisionControllerFromState(record.stateDir, record.identity, record.origin, controllerPorts);
|
|
267
|
+
if (reading.state === "unavailable") return reading;
|
|
268
|
+
if (!record.frameUnchanged()) { reading.controller.stop(); return absent("observation_changed"); }
|
|
269
|
+
if (closed || records.get(ownerKey(record.identity)) !== record || record.stopped) { reading.controller.stop(); return snapshot(expected); }
|
|
270
|
+
record.controller = reading.controller;
|
|
271
|
+
} finally { if (!record.controller) releaseClaim(record); }
|
|
272
|
+
}
|
|
273
|
+
record.controller.start(); rememberCleanup(record); return snapshot(expected);
|
|
274
|
+
},
|
|
275
|
+
stop: (expected: unknown): Readonly<RunSupervisionOwnerReading> => { const record = find(expected); if ("state" in record) return record; stopRecord(record); return view(record); },
|
|
276
|
+
release: (expected: unknown): Readonly<RunSupervisionOwnerReading> => {
|
|
277
|
+
const record = find(expected); if ("state" in record) return record;
|
|
278
|
+
stopRecord(record); releaseClaim(record); records.delete(ownerKey(record.identity)); const controller = record.controller?.snapshot();
|
|
279
|
+
return Object.freeze({ state: "released", identity: record.identity, ...(controller ? { controller } : {}) });
|
|
280
|
+
},
|
|
281
|
+
snapshot,
|
|
282
|
+
observeReferences: (expected: unknown, stateDir?: string): Readonly<RunSupervisionOwnerReferencesReading> => {
|
|
283
|
+
const record = find(expected); if ("state" in record) return record;
|
|
284
|
+
if (stateDir !== undefined && stateDir !== record.stateDir) return absent("identity_mismatch");
|
|
285
|
+
const revoked = () => revokedRecord(record);
|
|
286
|
+
const initial = revoked(); if (initial) return initial;
|
|
287
|
+
if (!record.references) return Object.freeze({ state: "unavailable", reason: "references_not_retained" });
|
|
288
|
+
const reading = record.references.read(); const afterRead = revoked(); if (afterRead) return afterRead;
|
|
289
|
+
if (reading.state === "unavailable") return reading;
|
|
290
|
+
const unchanged = (): boolean => !revoked() && reading.unchanged() && !revoked() &&
|
|
291
|
+
!closed && records.get(ownerKey(record.identity)) === record && !record.stopped;
|
|
292
|
+
if (!unchanged()) return revoked() ?? absent("observation_changed");
|
|
293
|
+
return Object.freeze({ ...reading, unchanged });
|
|
294
|
+
},
|
|
295
|
+
captureNaturalTime: (expected: unknown, producer: RunResultProducer, admission: RunNaturalResultTimingAdmission, stateDir?: string): Readonly<RunSupervisionOwnerNaturalTimeReading> => {
|
|
296
|
+
const record = find(expected); if ("state" in record) return record;
|
|
297
|
+
if (stateDir !== undefined && stateDir !== record.stateDir) return absent("identity_mismatch");
|
|
298
|
+
const initial = revokedRecord(record); if (initial) return initial;
|
|
299
|
+
let attempt: FrozenNaturalTime | undefined; let staged: FrozenNaturalTime | undefined; let stable: (() => boolean) | undefined;
|
|
300
|
+
try {
|
|
301
|
+
const refused = withRunNaturalResultTimingAdmission(record.stateDir, producer, admission, acceptance => {
|
|
302
|
+
if (ownerKey(acceptance.identity) !== ownerKey(record.identity)) return absent("identity_mismatch");
|
|
303
|
+
const existing = record.claim.natural;
|
|
304
|
+
if (existing) return existing.admission !== admission || existing.producer !== producer
|
|
305
|
+
? Object.freeze({ state: "unavailable" as const, reason: "natural_acceptance_mismatch" as const }) : undefined;
|
|
306
|
+
attempt = Object.freeze({ state: "capturing", producer, admission }); record.claim.natural = attempt;
|
|
307
|
+
const observed = owner.observeTime(record.identity, record.stateDir);
|
|
308
|
+
if (observed.state === "available" && observed.timing.state === "available") {
|
|
309
|
+
stable = observed.unchanged;
|
|
310
|
+
staged = Object.freeze({ state: "frozen", producer, admission, acceptance, elapsed_ms: observed.timing.elapsed_ms });
|
|
311
|
+
}
|
|
312
|
+
return undefined;
|
|
313
|
+
});
|
|
314
|
+
if (refused) return refused;
|
|
315
|
+
if (attempt && record.claim.natural === attempt) {
|
|
316
|
+
const revoked = revokedRecord(record);
|
|
317
|
+
if (!staged || !stable || !stable() || revoked || revokedRecord(record)) {
|
|
318
|
+
record.claim.natural = Object.freeze({ state: "unproven", producer, admission });
|
|
319
|
+
return revoked ?? revokedRecord(record) ?? Object.freeze({ state: "unavailable", reason: "natural_time_unproven" });
|
|
320
|
+
}
|
|
321
|
+
record.claim.natural = staged;
|
|
322
|
+
}
|
|
323
|
+
} catch (error) {
|
|
324
|
+
if (attempt && record.claim.natural === attempt) record.claim.natural = Object.freeze({ state: "unproven", producer, admission });
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
return owner.observeFrozenNaturalTime(record.identity, record.stateDir);
|
|
328
|
+
},
|
|
329
|
+
observeFrozenNaturalTime: (expected: unknown, stateDir?: string): Readonly<RunSupervisionOwnerNaturalTimeReading> => {
|
|
330
|
+
const record = find(expected); if ("state" in record) return record;
|
|
331
|
+
if (stateDir !== undefined && stateDir !== record.stateDir) return absent("identity_mismatch");
|
|
332
|
+
const initial = revokedRecord(record); if (initial) return initial;
|
|
333
|
+
const frozen = record.claim.natural;
|
|
334
|
+
if (!frozen) return Object.freeze({ state: "unavailable", reason: "natural_time_not_captured" });
|
|
335
|
+
if (frozen.state !== "frozen") return Object.freeze({ state: "unavailable", reason: frozen.state === "capturing" ? "natural_time_capturing" : "natural_time_unproven" });
|
|
336
|
+
const acceptance = readRunNaturalResultTimingAcceptance(record.stateDir, frozen.producer, frozen.admission);
|
|
337
|
+
if (acceptance !== frozen.acceptance) return Object.freeze({ state: "unavailable", reason: "natural_acceptance_mismatch" });
|
|
338
|
+
const binding = observeBinding(record.stateDir, record.identity);
|
|
339
|
+
const afterRead = revokedRecord(record); if (afterRead) return afterRead;
|
|
340
|
+
if (binding.state === "unavailable") return binding;
|
|
341
|
+
if (JSON.stringify(binding.clock) !== record.clockKey) return absent("clock_changed");
|
|
342
|
+
const unchanged = (): boolean => !revokedRecord(record) && record.claim.natural === frozen && binding.unchanged() && binding.frameUnchanged() &&
|
|
343
|
+
!revokedRecord(record) && !closed && records.get(ownerKey(record.identity)) === record && !record.stopped;
|
|
344
|
+
if (!unchanged()) return revokedRecord(record) ?? absent("observation_changed");
|
|
345
|
+
return Object.freeze({ state: "available", basis: "first_natural_acceptance", identity: record.identity, elapsed_ms: frozen.elapsed_ms,
|
|
346
|
+
natural_acceptance: Object.freeze({ code: acceptance.code, recorded_status: acceptance.recorded_status, completed_at: acceptance.completed_at }), unchanged });
|
|
347
|
+
},
|
|
348
|
+
observeSnapshot: (expected: unknown, capturedAt: unknown, stateDir?: string): Readonly<RunSupervisionOwnerSnapshotReading> => {
|
|
349
|
+
const record = find(expected); if ("state" in record) return record;
|
|
350
|
+
if (stateDir !== undefined && stateDir !== record.stateDir) return absent("identity_mismatch");
|
|
351
|
+
const initial = revokedRecord(record); if (initial) return initial;
|
|
352
|
+
const references = owner.observeReferences(record.identity, record.stateDir);
|
|
353
|
+
const afterReferences = revokedRecord(record); if (afterReferences) return afterReferences;
|
|
354
|
+
if (references.state === "unavailable") return references;
|
|
355
|
+
if (references.references.cwd === null) return Object.freeze({ state: "unavailable", reason: "references_unavailable" });
|
|
356
|
+
const facts = readRunSnapshotFacts(record.stateDir, record.identity, capturedAt, owner.observeTime, owner.observeFrozenNaturalTime);
|
|
357
|
+
const afterFacts = revokedRecord(record); if (afterFacts) return afterFacts;
|
|
358
|
+
if (facts.state === "unavailable") return facts;
|
|
359
|
+
const unchanged = (): boolean => !revokedRecord(record) && references.unchanged() && facts.unchanged() &&
|
|
360
|
+
!closed && records.get(ownerKey(record.identity)) === record && !record.stopped;
|
|
361
|
+
if (!unchanged()) return revokedRecord(record) ?? absent("observation_changed");
|
|
362
|
+
// Canonical lifecycle/time are facts, not permission to expose their mutable cwd/index fields.
|
|
363
|
+
const projected = projectRunSnapshot(record.identity, { identity: facts.facts.identity, captured_at: facts.facts.captured_at,
|
|
364
|
+
lifecycle: facts.facts.lifecycle, timing: facts.facts.timing, cwd: references.references.cwd,
|
|
365
|
+
...(references.references.context_index ? { context_index: references.references.context_index } : {}) });
|
|
366
|
+
if (!unchanged()) return revokedRecord(record) ?? absent("observation_changed");
|
|
367
|
+
return projected.state === "unavailable" ? projected : Object.freeze({ ...projected, unchanged });
|
|
368
|
+
},
|
|
369
|
+
observeTime: (expected: unknown, stateDir?: string): Readonly<RunSupervisionOwnerTimeReading> => {
|
|
370
|
+
const record = find(expected); if ("state" in record) return record;
|
|
371
|
+
if (stateDir !== undefined && stateDir !== record.stateDir) return absent("identity_mismatch");
|
|
372
|
+
const revoked = () => revokedRecord(record);
|
|
373
|
+
const initial = revoked(); if (initial) return initial;
|
|
374
|
+
const binding = observeBinding(record.stateDir, record.identity);
|
|
375
|
+
const afterRead = revoked(); if (afterRead) return afterRead;
|
|
376
|
+
if (binding.state === "unavailable") return binding;
|
|
377
|
+
if (JSON.stringify(binding.clock) !== record.clockKey) return absent("clock_changed");
|
|
378
|
+
const timebase = createRunSupervisionTimebase(binding.clock, record.origin);
|
|
379
|
+
if (timebase.state === "unavailable") return timebase;
|
|
380
|
+
const unchanged = (): boolean => !revoked() && binding.unchanged() && binding.frameUnchanged() &&
|
|
381
|
+
!closed && records.get(ownerKey(record.identity)) === record && !record.stopped;
|
|
382
|
+
if (!unchanged()) return revoked() ?? absent("observation_changed");
|
|
383
|
+
const timing = timebase.timebase.observe();
|
|
384
|
+
const afterSample = revoked(); if (afterSample) return afterSample;
|
|
385
|
+
if (!unchanged()) return revoked() ?? absent("observation_changed");
|
|
386
|
+
return Object.freeze({ state: "available", basis: "since_admission", identity: record.identity, timing, unchanged });
|
|
387
|
+
},
|
|
388
|
+
close: (): Readonly<RunSupervisionOwnerClose> => {
|
|
389
|
+
if (!closed) { closed = true; for (const record of records.values()) { stopRecord(record); releaseClaim(record); } records.clear(); }
|
|
390
|
+
return Object.freeze({ state: "closed", ...(cleanupUnproven ? { timer_cleanup: "unproven" as const } : {}) });
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
return owner;
|
|
394
|
+
}
|
|
@@ -67,6 +67,7 @@ export interface RunTraceReadEvent {
|
|
|
67
67
|
export interface RunTraceJournalRead {
|
|
68
68
|
diagnostics: StateReadDiagnostic[];
|
|
69
69
|
events: RunTraceReadEvent[];
|
|
70
|
+
omittedEvents: number;
|
|
70
71
|
fileBytes: number;
|
|
71
72
|
omittedPrefixBytes: number;
|
|
72
73
|
readBytes: number;
|
|
@@ -134,6 +135,13 @@ function hasExactFields(record: Record<string, unknown>, fields: Set<string>): b
|
|
|
134
135
|
return keys.length === fields.size && keys.every((key) => fields.has(key));
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
function clipTraceSummary(summary: string): string {
|
|
139
|
+
const last = summary.charCodeAt(999), next = summary.charCodeAt(1_000);
|
|
140
|
+
// Keep the UTF-16 allowance without bisecting an original surrogate pair.
|
|
141
|
+
const end = last >= 0xd800 && last <= 0xdbff && next >= 0xdc00 && next <= 0xdfff ? 999 : 1_000;
|
|
142
|
+
return summary.slice(0, end);
|
|
143
|
+
}
|
|
144
|
+
|
|
137
145
|
function normalizeTraceEventInput(input: unknown): AppendTraceEventInput {
|
|
138
146
|
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
139
147
|
throw new Error("Trace event must be an object");
|
|
@@ -175,7 +183,7 @@ function normalizeTraceEventInput(input: unknown): AppendTraceEventInput {
|
|
|
175
183
|
return {
|
|
176
184
|
kind: record.kind,
|
|
177
185
|
...(record.summary !== undefined
|
|
178
|
-
? { summary: record.summary
|
|
186
|
+
? { summary: clipTraceSummary(record.summary) }
|
|
179
187
|
: {}),
|
|
180
188
|
...(record.data !== undefined ? { data: record.data } : {}),
|
|
181
189
|
...(record.level !== undefined
|
|
@@ -542,6 +550,7 @@ export function readRunTraceJournal(stateDir: string): RunTraceJournalRead {
|
|
|
542
550
|
path,
|
|
543
551
|
}],
|
|
544
552
|
events: [],
|
|
553
|
+
omittedEvents: 0,
|
|
545
554
|
fileBytes: 0,
|
|
546
555
|
omittedPrefixBytes: 0,
|
|
547
556
|
readBytes: 0,
|
|
@@ -550,6 +559,7 @@ export function readRunTraceJournal(stateDir: string): RunTraceJournalRead {
|
|
|
550
559
|
const diagnostics: StateReadDiagnostic[] = [];
|
|
551
560
|
let events: RunTraceReadEvent[] = [];
|
|
552
561
|
let eventHead = 0;
|
|
562
|
+
let omittedEvents = 0;
|
|
553
563
|
let ordinal = window.leadingPartialLines;
|
|
554
564
|
const diagnose = (message: string, line?: number): void => {
|
|
555
565
|
diagnostics.push({ message, path, ...(line === undefined ? {} : { line }) });
|
|
@@ -557,7 +567,7 @@ export function readRunTraceJournal(stateDir: string): RunTraceJournalRead {
|
|
|
557
567
|
};
|
|
558
568
|
const retain = (event: TraceEvent): void => {
|
|
559
569
|
events.push({ event, ordinal });
|
|
560
|
-
if (events.length - eventHead > Limits.TRACE_JOURNAL_MAX_EVENTS) eventHead += 1;
|
|
570
|
+
if (events.length - eventHead > Limits.TRACE_JOURNAL_MAX_EVENTS) { eventHead += 1; omittedEvents += 1; }
|
|
561
571
|
if (eventHead > Limits.TRACE_JOURNAL_MAX_EVENTS) {
|
|
562
572
|
events = events.slice(eventHead);
|
|
563
573
|
eventHead = 0;
|
|
@@ -584,6 +594,7 @@ export function readRunTraceJournal(stateDir: string): RunTraceJournalRead {
|
|
|
584
594
|
return {
|
|
585
595
|
diagnostics,
|
|
586
596
|
events: events.slice(eventHead),
|
|
597
|
+
omittedEvents,
|
|
587
598
|
fileBytes: window.fileBytes,
|
|
588
599
|
omittedPrefixBytes: window.omittedPrefixBytes,
|
|
589
600
|
readBytes: window.readBytes,
|
|
@@ -592,7 +603,7 @@ export function readRunTraceJournal(stateDir: string): RunTraceJournalRead {
|
|
|
592
603
|
|
|
593
604
|
export function summarizeRunTraceJournal(read: RunTraceJournalRead): RunTraceSummary {
|
|
594
605
|
const marker = [...read.events].reverse().map(({ event }) => markerData(event)).find(Boolean);
|
|
595
|
-
const incomplete = Boolean(marker) || read.omittedPrefixBytes > 0;
|
|
606
|
+
const incomplete = Boolean(marker) || read.omittedPrefixBytes > 0 || read.omittedEvents > 0 || read.diagnostics.length > 0;
|
|
596
607
|
return {
|
|
597
608
|
history_complete: !incomplete, compacted: Boolean(marker),
|
|
598
609
|
compactions_total: marker?.compactions_total ?? 0,
|
|
@@ -15,6 +15,7 @@ import * as RecipesDiscovery from "./recipes-discovery.ts";
|
|
|
15
15
|
import * as RecipesReferences from "./recipes-references.ts";
|
|
16
16
|
import * as RecipesUsage from "./recipes-usage.ts";
|
|
17
17
|
import * as ToolsLocal from "./tools-local.ts";
|
|
18
|
+
import * as ToolsResponse from "./tools-response.ts";
|
|
18
19
|
|
|
19
20
|
export interface RuntimeContext {
|
|
20
21
|
hasUI: boolean;
|
|
@@ -195,20 +196,38 @@ export function createAutoToolsRuntime(
|
|
|
195
196
|
(warning) => !shadowed.includes(warning) && !skipped.includes(warning),
|
|
196
197
|
);
|
|
197
198
|
const lines = ["pi-actors recipe registry warning"];
|
|
199
|
+
const groups: Array<[string, number, number]> = [];
|
|
198
200
|
if (shadowed.length > 0) {
|
|
199
201
|
lines.push("User recipes shadow lower-priority user sources:");
|
|
202
|
+
const start = lines.length;
|
|
200
203
|
lines.push(...shadowed.map((warning) => `• ${warning}`));
|
|
204
|
+
groups[groups.length] = ["shadowed_sources", start, lines.length];
|
|
201
205
|
}
|
|
202
206
|
if (skipped.length > 0) {
|
|
203
207
|
lines.push("Recipes skipped from tool exposure:");
|
|
208
|
+
const start = lines.length;
|
|
204
209
|
lines.push(...skipped.map((warning) => `• ${warning}`));
|
|
210
|
+
groups[groups.length] = ["skipped_tool_exposure", start, lines.length];
|
|
205
211
|
}
|
|
206
212
|
if (other.length > 0) {
|
|
207
213
|
lines.push("Other registry diagnostics:");
|
|
214
|
+
const start = lines.length;
|
|
208
215
|
lines.push(...other.map((warning) => `• ${warning}`));
|
|
216
|
+
groups[groups.length] = ["other_diagnostics", start, lines.length];
|
|
209
217
|
}
|
|
210
218
|
lines.push("Next: inspect target=recipes view=doctor");
|
|
211
|
-
|
|
219
|
+
// Preserve the original layout join/coercion and its faults before projecting owned warning slots.
|
|
220
|
+
void `${lines.join("\n")}\n`;
|
|
221
|
+
let text = ToolsResponse.formatMarkdownField("report", "pi-actors recipe registry warning");
|
|
222
|
+
for (const [key, start, end] of groups) {
|
|
223
|
+
text += `\n- ${key}:`;
|
|
224
|
+
for (let index = start; index < end; index++) {
|
|
225
|
+
const value = lines[index].slice(2);
|
|
226
|
+
text += "\n" + (value.isWellFormed() ? ToolsResponse.formatMarkdownField("warning", value, 1)
|
|
227
|
+
: " - warning:\n - result: unavailable\n - reason: malformed_selected_text");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return text + "\n" + ToolsResponse.formatMarkdownField("instruction", "Next: inspect target=recipes view=doctor") + "\n";
|
|
212
231
|
}
|
|
213
232
|
function loadTools(
|
|
214
233
|
ctx: RuntimeContext,
|
|
@@ -353,7 +372,7 @@ export function createRecipeToolReloadWatcher(
|
|
|
353
372
|
setWatchStatus("failed");
|
|
354
373
|
try {
|
|
355
374
|
ctx.ui.notify(
|
|
356
|
-
"Recipe live reload watcher failed
|
|
375
|
+
"- report: Recipe live reload watcher failed\n- instruction: restart the session or use register_tool again to refresh recipe tools.",
|
|
357
376
|
"warning",
|
|
358
377
|
);
|
|
359
378
|
} catch (error) {
|
|
@@ -372,7 +391,7 @@ export function createRecipeToolReloadWatcher(
|
|
|
372
391
|
try {
|
|
373
392
|
runtime.loadTools(ctx, deps.getResolutionContext?.());
|
|
374
393
|
if (notifyAfterReload) {
|
|
375
|
-
ctx.ui.notify("Recipe tools refreshed from ~/.pi/agent/recipes", "info");
|
|
394
|
+
ctx.ui.notify("- report: Recipe tools refreshed from ~/.pi/agent/recipes", "info");
|
|
376
395
|
}
|
|
377
396
|
notifyAfterReload = false;
|
|
378
397
|
} catch (error) {
|