usesteady 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +186 -0
- package/README.md +724 -0
- package/bin/use-steady.js +13 -0
- package/dist/server-store.d.ts +68 -0
- package/dist/server-store.d.ts.map +1 -0
- package/dist/server-store.js +133 -0
- package/dist/server-store.js.map +1 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +569 -0
- package/dist/server.js.map +1 -0
- package/dist/src/claude/adapters/api-adapter.d.ts +99 -0
- package/dist/src/claude/adapters/api-adapter.d.ts.map +1 -0
- package/dist/src/claude/adapters/api-adapter.js +415 -0
- package/dist/src/claude/adapters/api-adapter.js.map +1 -0
- package/dist/src/claude/adapters/stub-adapter.d.ts +73 -0
- package/dist/src/claude/adapters/stub-adapter.d.ts.map +1 -0
- package/dist/src/claude/adapters/stub-adapter.js +114 -0
- package/dist/src/claude/adapters/stub-adapter.js.map +1 -0
- package/dist/src/claude/artifact-mapper.d.ts +85 -0
- package/dist/src/claude/artifact-mapper.d.ts.map +1 -0
- package/dist/src/claude/artifact-mapper.js +187 -0
- package/dist/src/claude/artifact-mapper.js.map +1 -0
- package/dist/src/claude/delivery-gate.d.ts +136 -0
- package/dist/src/claude/delivery-gate.d.ts.map +1 -0
- package/dist/src/claude/delivery-gate.js +231 -0
- package/dist/src/claude/delivery-gate.js.map +1 -0
- package/dist/src/claude/index.d.ts +24 -0
- package/dist/src/claude/index.d.ts.map +1 -0
- package/dist/src/claude/index.js +23 -0
- package/dist/src/claude/index.js.map +1 -0
- package/dist/src/claude/types.d.ts +223 -0
- package/dist/src/claude/types.d.ts.map +1 -0
- package/dist/src/claude/types.js +64 -0
- package/dist/src/claude/types.js.map +1 -0
- package/dist/src/control/compiler.d.ts +125 -0
- package/dist/src/control/compiler.d.ts.map +1 -0
- package/dist/src/control/compiler.js +179 -0
- package/dist/src/control/compiler.js.map +1 -0
- package/dist/src/control/constraints.d.ts +42 -0
- package/dist/src/control/constraints.d.ts.map +1 -0
- package/dist/src/control/constraints.js +116 -0
- package/dist/src/control/constraints.js.map +1 -0
- package/dist/src/control/drift-detector.d.ts +49 -0
- package/dist/src/control/drift-detector.d.ts.map +1 -0
- package/dist/src/control/drift-detector.js +115 -0
- package/dist/src/control/drift-detector.js.map +1 -0
- package/dist/src/control/index.d.ts +44 -0
- package/dist/src/control/index.d.ts.map +1 -0
- package/dist/src/control/index.js +40 -0
- package/dist/src/control/index.js.map +1 -0
- package/dist/src/control/types.d.ts +144 -0
- package/dist/src/control/types.d.ts.map +1 -0
- package/dist/src/control/types.js +57 -0
- package/dist/src/control/types.js.map +1 -0
- package/dist/src/cursor/adapters/inprocess-adapter.d.ts +78 -0
- package/dist/src/cursor/adapters/inprocess-adapter.d.ts.map +1 -0
- package/dist/src/cursor/adapters/inprocess-adapter.js +308 -0
- package/dist/src/cursor/adapters/inprocess-adapter.js.map +1 -0
- package/dist/src/cursor/adapters/stub-adapter.d.ts +75 -0
- package/dist/src/cursor/adapters/stub-adapter.d.ts.map +1 -0
- package/dist/src/cursor/adapters/stub-adapter.js +120 -0
- package/dist/src/cursor/adapters/stub-adapter.js.map +1 -0
- package/dist/src/cursor/artifact-mapper.d.ts +81 -0
- package/dist/src/cursor/artifact-mapper.d.ts.map +1 -0
- package/dist/src/cursor/artifact-mapper.js +203 -0
- package/dist/src/cursor/artifact-mapper.js.map +1 -0
- package/dist/src/cursor/delivery-gate.d.ts +144 -0
- package/dist/src/cursor/delivery-gate.d.ts.map +1 -0
- package/dist/src/cursor/delivery-gate.js +208 -0
- package/dist/src/cursor/delivery-gate.js.map +1 -0
- package/dist/src/cursor/glob-matcher.d.ts +30 -0
- package/dist/src/cursor/glob-matcher.d.ts.map +1 -0
- package/dist/src/cursor/glob-matcher.js +68 -0
- package/dist/src/cursor/glob-matcher.js.map +1 -0
- package/dist/src/cursor/index.d.ts +43 -0
- package/dist/src/cursor/index.d.ts.map +1 -0
- package/dist/src/cursor/index.js +44 -0
- package/dist/src/cursor/index.js.map +1 -0
- package/dist/src/cursor/ocd-evaluator.d.ts +89 -0
- package/dist/src/cursor/ocd-evaluator.d.ts.map +1 -0
- package/dist/src/cursor/ocd-evaluator.js +142 -0
- package/dist/src/cursor/ocd-evaluator.js.map +1 -0
- package/dist/src/cursor/types.d.ts +309 -0
- package/dist/src/cursor/types.d.ts.map +1 -0
- package/dist/src/cursor/types.js +48 -0
- package/dist/src/cursor/types.js.map +1 -0
- package/dist/src/execution/claude/claude-execution-coordinator.d.ts +164 -0
- package/dist/src/execution/claude/claude-execution-coordinator.d.ts.map +1 -0
- package/dist/src/execution/claude/claude-execution-coordinator.js +198 -0
- package/dist/src/execution/claude/claude-execution-coordinator.js.map +1 -0
- package/dist/src/execution/claude/index.d.ts +13 -0
- package/dist/src/execution/claude/index.d.ts.map +1 -0
- package/dist/src/execution/claude/index.js +12 -0
- package/dist/src/execution/claude/index.js.map +1 -0
- package/dist/src/execution/cursor/cursor-execution-coordinator.d.ts +216 -0
- package/dist/src/execution/cursor/cursor-execution-coordinator.d.ts.map +1 -0
- package/dist/src/execution/cursor/cursor-execution-coordinator.js +233 -0
- package/dist/src/execution/cursor/cursor-execution-coordinator.js.map +1 -0
- package/dist/src/execution/cursor/index.d.ts +20 -0
- package/dist/src/execution/cursor/index.d.ts.map +1 -0
- package/dist/src/execution/cursor/index.js +18 -0
- package/dist/src/execution/cursor/index.js.map +1 -0
- package/dist/src/execution/reminders/index.d.ts +11 -0
- package/dist/src/execution/reminders/index.d.ts.map +1 -0
- package/dist/src/execution/reminders/index.js +9 -0
- package/dist/src/execution/reminders/index.js.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-coordinator.d.ts +125 -0
- package/dist/src/execution/reminders/reminder-execution-coordinator.d.ts.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-coordinator.js +129 -0
- package/dist/src/execution/reminders/reminder-execution-coordinator.js.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-types.d.ts +161 -0
- package/dist/src/execution/reminders/reminder-execution-types.d.ts.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-types.js +39 -0
- package/dist/src/execution/reminders/reminder-execution-types.js.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-validator.d.ts +45 -0
- package/dist/src/execution/reminders/reminder-execution-validator.d.ts.map +1 -0
- package/dist/src/execution/reminders/reminder-execution-validator.js +92 -0
- package/dist/src/execution/reminders/reminder-execution-validator.js.map +1 -0
- package/dist/src/execution/reminders/reminder-executor.d.ts +62 -0
- package/dist/src/execution/reminders/reminder-executor.d.ts.map +1 -0
- package/dist/src/execution/reminders/reminder-executor.js +113 -0
- package/dist/src/execution/reminders/reminder-executor.js.map +1 -0
- package/dist/src/execution/reminders/reminder-time-parser.d.ts +41 -0
- package/dist/src/execution/reminders/reminder-time-parser.d.ts.map +1 -0
- package/dist/src/execution/reminders/reminder-time-parser.js +113 -0
- package/dist/src/execution/reminders/reminder-time-parser.js.map +1 -0
- package/dist/src/friction/auto-capture.d.ts +38 -0
- package/dist/src/friction/auto-capture.d.ts.map +1 -0
- package/dist/src/friction/auto-capture.js +133 -0
- package/dist/src/friction/auto-capture.js.map +1 -0
- package/dist/src/friction/client.d.ts +39 -0
- package/dist/src/friction/client.d.ts.map +1 -0
- package/dist/src/friction/client.js +165 -0
- package/dist/src/friction/client.js.map +1 -0
- package/dist/src/friction/config.d.ts +16 -0
- package/dist/src/friction/config.d.ts.map +1 -0
- package/dist/src/friction/config.js +56 -0
- package/dist/src/friction/config.js.map +1 -0
- package/dist/src/friction/github-auth.d.ts +41 -0
- package/dist/src/friction/github-auth.d.ts.map +1 -0
- package/dist/src/friction/github-auth.js +155 -0
- package/dist/src/friction/github-auth.js.map +1 -0
- package/dist/src/friction/github-issues.d.ts +51 -0
- package/dist/src/friction/github-issues.d.ts.map +1 -0
- package/dist/src/friction/github-issues.js +118 -0
- package/dist/src/friction/github-issues.js.map +1 -0
- package/dist/src/friction/payout-ledger.d.ts +45 -0
- package/dist/src/friction/payout-ledger.d.ts.map +1 -0
- package/dist/src/friction/payout-ledger.js +111 -0
- package/dist/src/friction/payout-ledger.js.map +1 -0
- package/dist/src/friction/queue.d.ts +42 -0
- package/dist/src/friction/queue.d.ts.map +1 -0
- package/dist/src/friction/queue.js +179 -0
- package/dist/src/friction/queue.js.map +1 -0
- package/dist/src/friction/reviewer.d.ts +42 -0
- package/dist/src/friction/reviewer.d.ts.map +1 -0
- package/dist/src/friction/reviewer.js +269 -0
- package/dist/src/friction/reviewer.js.map +1 -0
- package/dist/src/friction/types.d.ts +63 -0
- package/dist/src/friction/types.d.ts.map +1 -0
- package/dist/src/friction/types.js +18 -0
- package/dist/src/friction/types.js.map +1 -0
- package/dist/src/history/index.d.ts +39 -0
- package/dist/src/history/index.d.ts.map +1 -0
- package/dist/src/history/index.js +41 -0
- package/dist/src/history/index.js.map +1 -0
- package/dist/src/history/session-chain.d.ts +36 -0
- package/dist/src/history/session-chain.d.ts.map +1 -0
- package/dist/src/history/session-chain.js +91 -0
- package/dist/src/history/session-chain.js.map +1 -0
- package/dist/src/history/types.d.ts +130 -0
- package/dist/src/history/types.d.ts.map +1 -0
- package/dist/src/history/types.js +32 -0
- package/dist/src/history/types.js.map +1 -0
- package/dist/src/history/workflow-history.d.ts +48 -0
- package/dist/src/history/workflow-history.d.ts.map +1 -0
- package/dist/src/history/workflow-history.js +116 -0
- package/dist/src/history/workflow-history.js.map +1 -0
- package/dist/src/index.d.ts +88 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +58 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/intake/classify-intent-state.d.ts +20 -0
- package/dist/src/intake/classify-intent-state.d.ts.map +1 -0
- package/dist/src/intake/classify-intent-state.js +29 -0
- package/dist/src/intake/classify-intent-state.js.map +1 -0
- package/dist/src/intake/intake-service.d.ts +105 -0
- package/dist/src/intake/intake-service.d.ts.map +1 -0
- package/dist/src/intake/intake-service.js +407 -0
- package/dist/src/intake/intake-service.js.map +1 -0
- package/dist/src/intake/response-planner.d.ts +25 -0
- package/dist/src/intake/response-planner.d.ts.map +1 -0
- package/dist/src/intake/response-planner.js +52 -0
- package/dist/src/intake/response-planner.js.map +1 -0
- package/dist/src/intake/signal-extractor.d.ts +25 -0
- package/dist/src/intake/signal-extractor.d.ts.map +1 -0
- package/dist/src/intake/signal-extractor.js +42 -0
- package/dist/src/intake/signal-extractor.js.map +1 -0
- package/dist/src/intake/trace.d.ts +157 -0
- package/dist/src/intake/trace.d.ts.map +1 -0
- package/dist/src/intake/trace.js +38 -0
- package/dist/src/intake/trace.js.map +1 -0
- package/dist/src/intake/types.d.ts +70 -0
- package/dist/src/intake/types.d.ts.map +1 -0
- package/dist/src/intake/types.js +30 -0
- package/dist/src/intake/types.js.map +1 -0
- package/dist/src/interaction/defaults.d.ts +12 -0
- package/dist/src/interaction/defaults.d.ts.map +1 -0
- package/dist/src/interaction/defaults.js +26 -0
- package/dist/src/interaction/defaults.js.map +1 -0
- package/dist/src/interaction/guidance-order.d.ts +53 -0
- package/dist/src/interaction/guidance-order.d.ts.map +1 -0
- package/dist/src/interaction/guidance-order.js +131 -0
- package/dist/src/interaction/guidance-order.js.map +1 -0
- package/dist/src/interaction/observe.d.ts +57 -0
- package/dist/src/interaction/observe.d.ts.map +1 -0
- package/dist/src/interaction/observe.js +77 -0
- package/dist/src/interaction/observe.js.map +1 -0
- package/dist/src/interaction/selectors.d.ts +16 -0
- package/dist/src/interaction/selectors.d.ts.map +1 -0
- package/dist/src/interaction/selectors.js +23 -0
- package/dist/src/interaction/selectors.js.map +1 -0
- package/dist/src/interaction/types.d.ts +105 -0
- package/dist/src/interaction/types.d.ts.map +1 -0
- package/dist/src/interaction/types.js +48 -0
- package/dist/src/interaction/types.js.map +1 -0
- package/dist/src/interaction/updater.d.ts +22 -0
- package/dist/src/interaction/updater.d.ts.map +1 -0
- package/dist/src/interaction/updater.js +87 -0
- package/dist/src/interaction/updater.js.map +1 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-detector.d.ts +48 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-detector.d.ts.map +1 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-detector.js +107 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-detector.js.map +1 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-types.d.ts +43 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-types.d.ts.map +1 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-types.js +20 -0
- package/dist/src/present/boundary-explanation/boundary-explanation-types.js.map +1 -0
- package/dist/src/present/boundary-explanation/index.d.ts +10 -0
- package/dist/src/present/boundary-explanation/index.d.ts.map +1 -0
- package/dist/src/present/boundary-explanation/index.js +2 -0
- package/dist/src/present/boundary-explanation/index.js.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-assertions.d.ts +70 -0
- package/dist/src/present/control-visibility/control-visibility-assertions.d.ts.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-assertions.js +138 -0
- package/dist/src/present/control-visibility/control-visibility-assertions.js.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-evaluator.d.ts +67 -0
- package/dist/src/present/control-visibility/control-visibility-evaluator.d.ts.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-evaluator.js +146 -0
- package/dist/src/present/control-visibility/control-visibility-evaluator.js.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-types.d.ts +113 -0
- package/dist/src/present/control-visibility/control-visibility-types.d.ts.map +1 -0
- package/dist/src/present/control-visibility/control-visibility-types.js +24 -0
- package/dist/src/present/control-visibility/control-visibility-types.js.map +1 -0
- package/dist/src/present/control-visibility/index.d.ts +16 -0
- package/dist/src/present/control-visibility/index.d.ts.map +1 -0
- package/dist/src/present/control-visibility/index.js +15 -0
- package/dist/src/present/control-visibility/index.js.map +1 -0
- package/dist/src/present/format.d.ts +57 -0
- package/dist/src/present/format.d.ts.map +1 -0
- package/dist/src/present/format.js +150 -0
- package/dist/src/present/format.js.map +1 -0
- package/dist/src/present/present-coordinator.d.ts +153 -0
- package/dist/src/present/present-coordinator.d.ts.map +1 -0
- package/dist/src/present/present-coordinator.js +213 -0
- package/dist/src/present/present-coordinator.js.map +1 -0
- package/dist/src/present/reminders/index.d.ts +22 -0
- package/dist/src/present/reminders/index.d.ts.map +1 -0
- package/dist/src/present/reminders/index.js +22 -0
- package/dist/src/present/reminders/index.js.map +1 -0
- package/dist/src/present/reminders/reminder-presenter.d.ts +76 -0
- package/dist/src/present/reminders/reminder-presenter.d.ts.map +1 -0
- package/dist/src/present/reminders/reminder-presenter.js +359 -0
- package/dist/src/present/reminders/reminder-presenter.js.map +1 -0
- package/dist/src/present/reminders/reminder-renderer.d.ts +82 -0
- package/dist/src/present/reminders/reminder-renderer.d.ts.map +1 -0
- package/dist/src/present/reminders/reminder-renderer.js +136 -0
- package/dist/src/present/reminders/reminder-renderer.js.map +1 -0
- package/dist/src/present/reminders/reminder-types.d.ts +131 -0
- package/dist/src/present/reminders/reminder-types.d.ts.map +1 -0
- package/dist/src/present/reminders/reminder-types.js +29 -0
- package/dist/src/present/reminders/reminder-types.js.map +1 -0
- package/dist/src/present/types.d.ts +114 -0
- package/dist/src/present/types.d.ts.map +1 -0
- package/dist/src/present/types.js +18 -0
- package/dist/src/present/types.js.map +1 -0
- package/dist/src/product/claude-product-session.d.ts +146 -0
- package/dist/src/product/claude-product-session.d.ts.map +1 -0
- package/dist/src/product/claude-product-session.js +362 -0
- package/dist/src/product/claude-product-session.js.map +1 -0
- package/dist/src/product/cursor-product-session.d.ts +211 -0
- package/dist/src/product/cursor-product-session.d.ts.map +1 -0
- package/dist/src/product/cursor-product-session.js +390 -0
- package/dist/src/product/cursor-product-session.js.map +1 -0
- package/dist/src/product/index.d.ts +28 -0
- package/dist/src/product/index.d.ts.map +1 -0
- package/dist/src/product/index.js +22 -0
- package/dist/src/product/index.js.map +1 -0
- package/dist/src/product/session-resilience/index.d.ts +17 -0
- package/dist/src/product/session-resilience/index.d.ts.map +1 -0
- package/dist/src/product/session-resilience/index.js +15 -0
- package/dist/src/product/session-resilience/index.js.map +1 -0
- package/dist/src/product/session-resilience/session-serializer.d.ts +43 -0
- package/dist/src/product/session-resilience/session-serializer.d.ts.map +1 -0
- package/dist/src/product/session-resilience/session-serializer.js +84 -0
- package/dist/src/product/session-resilience/session-serializer.js.map +1 -0
- package/dist/src/product/session-resilience/session-snapshot-types.d.ts +35 -0
- package/dist/src/product/session-resilience/session-snapshot-types.d.ts.map +1 -0
- package/dist/src/product/session-resilience/session-snapshot-types.js +21 -0
- package/dist/src/product/session-resilience/session-snapshot-types.js.map +1 -0
- package/dist/src/product/session-resilience/session-staleness.d.ts +54 -0
- package/dist/src/product/session-resilience/session-staleness.d.ts.map +1 -0
- package/dist/src/product/session-resilience/session-staleness.js +62 -0
- package/dist/src/product/session-resilience/session-staleness.js.map +1 -0
- package/dist/src/product/session-resilience/session-summary.d.ts +40 -0
- package/dist/src/product/session-resilience/session-summary.d.ts.map +1 -0
- package/dist/src/product/session-resilience/session-summary.js +72 -0
- package/dist/src/product/session-resilience/session-summary.js.map +1 -0
- package/dist/src/prv/patterns.d.ts +32 -0
- package/dist/src/prv/patterns.d.ts.map +1 -0
- package/dist/src/prv/patterns.js +40 -0
- package/dist/src/prv/patterns.js.map +1 -0
- package/dist/src/prv/prv.d.ts +13 -0
- package/dist/src/prv/prv.d.ts.map +1 -0
- package/dist/src/prv/prv.js +22 -0
- package/dist/src/prv/prv.js.map +1 -0
- package/dist/src/prv/types.d.ts +26 -0
- package/dist/src/prv/types.d.ts.map +1 -0
- package/dist/src/prv/types.js +15 -0
- package/dist/src/prv/types.js.map +1 -0
- package/dist/src/safety/detectors/arbitrary-exec.detector.d.ts +3 -0
- package/dist/src/safety/detectors/arbitrary-exec.detector.d.ts.map +1 -0
- package/dist/src/safety/detectors/arbitrary-exec.detector.js +31 -0
- package/dist/src/safety/detectors/arbitrary-exec.detector.js.map +1 -0
- package/dist/src/safety/detectors/bulk-data-exfil.detector.d.ts +21 -0
- package/dist/src/safety/detectors/bulk-data-exfil.detector.d.ts.map +1 -0
- package/dist/src/safety/detectors/bulk-data-exfil.detector.js +90 -0
- package/dist/src/safety/detectors/bulk-data-exfil.detector.js.map +1 -0
- package/dist/src/safety/detectors/destructive.detector.d.ts +3 -0
- package/dist/src/safety/detectors/destructive.detector.d.ts.map +1 -0
- package/dist/src/safety/detectors/destructive.detector.js +28 -0
- package/dist/src/safety/detectors/destructive.detector.js.map +1 -0
- package/dist/src/safety/detectors/evasion.detector.d.ts +3 -0
- package/dist/src/safety/detectors/evasion.detector.d.ts.map +1 -0
- package/dist/src/safety/detectors/evasion.detector.js +28 -0
- package/dist/src/safety/detectors/evasion.detector.js.map +1 -0
- package/dist/src/safety/detectors/secret-access.detector.d.ts +31 -0
- package/dist/src/safety/detectors/secret-access.detector.d.ts.map +1 -0
- package/dist/src/safety/detectors/secret-access.detector.js +78 -0
- package/dist/src/safety/detectors/secret-access.detector.js.map +1 -0
- package/dist/src/safety/registry.d.ts +9 -0
- package/dist/src/safety/registry.d.ts.map +1 -0
- package/dist/src/safety/registry.js +22 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/safety-gate.d.ts +16 -0
- package/dist/src/safety/safety-gate.d.ts.map +1 -0
- package/dist/src/safety/safety-gate.js +26 -0
- package/dist/src/safety/safety-gate.js.map +1 -0
- package/dist/src/safety/types.d.ts +35 -0
- package/dist/src/safety/types.d.ts.map +1 -0
- package/dist/src/safety/types.js +14 -0
- package/dist/src/safety/types.js.map +1 -0
- package/dist/src/shell/claude-shell.d.ts +63 -0
- package/dist/src/shell/claude-shell.d.ts.map +1 -0
- package/dist/src/shell/claude-shell.js +81 -0
- package/dist/src/shell/claude-shell.js.map +1 -0
- package/dist/src/shell/cli/friction-admin.d.ts +14 -0
- package/dist/src/shell/cli/friction-admin.d.ts.map +1 -0
- package/dist/src/shell/cli/friction-admin.js +276 -0
- package/dist/src/shell/cli/friction-admin.js.map +1 -0
- package/dist/src/shell/cli/friction-report.d.ts +16 -0
- package/dist/src/shell/cli/friction-report.d.ts.map +1 -0
- package/dist/src/shell/cli/friction-report.js +156 -0
- package/dist/src/shell/cli/friction-report.js.map +1 -0
- package/dist/src/shell/cli/main.d.ts +68 -0
- package/dist/src/shell/cli/main.d.ts.map +1 -0
- package/dist/src/shell/cli/main.js +488 -0
- package/dist/src/shell/cli/main.js.map +1 -0
- package/dist/src/shell/cli/use-steady.d.ts +26 -0
- package/dist/src/shell/cli/use-steady.d.ts.map +1 -0
- package/dist/src/shell/cli/use-steady.js +117 -0
- package/dist/src/shell/cli/use-steady.js.map +1 -0
- package/dist/src/shell/cursor-shell.d.ts +63 -0
- package/dist/src/shell/cursor-shell.d.ts.map +1 -0
- package/dist/src/shell/cursor-shell.js +88 -0
- package/dist/src/shell/cursor-shell.js.map +1 -0
- package/dist/src/shell/defaults.d.ts +51 -0
- package/dist/src/shell/defaults.d.ts.map +1 -0
- package/dist/src/shell/defaults.js +78 -0
- package/dist/src/shell/defaults.js.map +1 -0
- package/dist/src/shell/history-render.d.ts +56 -0
- package/dist/src/shell/history-render.d.ts.map +1 -0
- package/dist/src/shell/history-render.js +166 -0
- package/dist/src/shell/history-render.js.map +1 -0
- package/dist/src/shell/index.d.ts +43 -0
- package/dist/src/shell/index.d.ts.map +1 -0
- package/dist/src/shell/index.js +45 -0
- package/dist/src/shell/index.js.map +1 -0
- package/dist/src/shell/render.d.ts +42 -0
- package/dist/src/shell/render.d.ts.map +1 -0
- package/dist/src/shell/render.js +122 -0
- package/dist/src/shell/render.js.map +1 -0
- package/dist/src/shell/types.d.ts +46 -0
- package/dist/src/shell/types.d.ts.map +1 -0
- package/dist/src/shell/types.js +19 -0
- package/dist/src/shell/types.js.map +1 -0
- package/dist/src/shell/workflow-defaults.d.ts +23 -0
- package/dist/src/shell/workflow-defaults.d.ts.map +1 -0
- package/dist/src/shell/workflow-defaults.js +27 -0
- package/dist/src/shell/workflow-defaults.js.map +1 -0
- package/dist/src/shell/workflow-render.d.ts +54 -0
- package/dist/src/shell/workflow-render.d.ts.map +1 -0
- package/dist/src/shell/workflow-render.js +319 -0
- package/dist/src/shell/workflow-render.js.map +1 -0
- package/dist/src/shell/workflow-shell.d.ts +110 -0
- package/dist/src/shell/workflow-shell.d.ts.map +1 -0
- package/dist/src/shell/workflow-shell.js +180 -0
- package/dist/src/shell/workflow-shell.js.map +1 -0
- package/dist/src/skills/audit.d.ts +118 -0
- package/dist/src/skills/audit.d.ts.map +1 -0
- package/dist/src/skills/audit.js +147 -0
- package/dist/src/skills/audit.js.map +1 -0
- package/dist/src/skills/invocation.d.ts +131 -0
- package/dist/src/skills/invocation.d.ts.map +1 -0
- package/dist/src/skills/invocation.js +165 -0
- package/dist/src/skills/invocation.js.map +1 -0
- package/dist/src/skills/loader.d.ts +70 -0
- package/dist/src/skills/loader.d.ts.map +1 -0
- package/dist/src/skills/loader.js +220 -0
- package/dist/src/skills/loader.js.map +1 -0
- package/dist/src/skills/local-recovery-adapter.d.ts +49 -0
- package/dist/src/skills/local-recovery-adapter.d.ts.map +1 -0
- package/dist/src/skills/local-recovery-adapter.js +184 -0
- package/dist/src/skills/local-recovery-adapter.js.map +1 -0
- package/dist/src/skills/parser.d.ts +53 -0
- package/dist/src/skills/parser.d.ts.map +1 -0
- package/dist/src/skills/parser.js +336 -0
- package/dist/src/skills/parser.js.map +1 -0
- package/dist/src/skills/registry.d.ts +123 -0
- package/dist/src/skills/registry.d.ts.map +1 -0
- package/dist/src/skills/registry.js +144 -0
- package/dist/src/skills/registry.js.map +1 -0
- package/dist/src/skills/types.d.ts +242 -0
- package/dist/src/skills/types.d.ts.map +1 -0
- package/dist/src/skills/types.js +50 -0
- package/dist/src/skills/types.js.map +1 -0
- package/dist/src/skills/validator.d.ts +31 -0
- package/dist/src/skills/validator.d.ts.map +1 -0
- package/dist/src/skills/validator.js +366 -0
- package/dist/src/skills/validator.js.map +1 -0
- package/dist/src/ucp/envelope.d.ts +165 -0
- package/dist/src/ucp/envelope.d.ts.map +1 -0
- package/dist/src/ucp/envelope.js +241 -0
- package/dist/src/ucp/envelope.js.map +1 -0
- package/dist/src/ucp/hashes.d.ts +36 -0
- package/dist/src/ucp/hashes.d.ts.map +1 -0
- package/dist/src/ucp/hashes.js +59 -0
- package/dist/src/ucp/hashes.js.map +1 -0
- package/dist/src/ucp/mappers/map-artifact.d.ts +58 -0
- package/dist/src/ucp/mappers/map-artifact.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-artifact.js +51 -0
- package/dist/src/ucp/mappers/map-artifact.js.map +1 -0
- package/dist/src/ucp/mappers/map-change-interpretation.d.ts +12 -0
- package/dist/src/ucp/mappers/map-change-interpretation.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-change-interpretation.js +18 -0
- package/dist/src/ucp/mappers/map-change-interpretation.js.map +1 -0
- package/dist/src/ucp/mappers/map-completion.d.ts +10 -0
- package/dist/src/ucp/mappers/map-completion.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-completion.js +24 -0
- package/dist/src/ucp/mappers/map-completion.js.map +1 -0
- package/dist/src/ucp/mappers/map-context.d.ts +9 -0
- package/dist/src/ucp/mappers/map-context.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-context.js +13 -0
- package/dist/src/ucp/mappers/map-context.js.map +1 -0
- package/dist/src/ucp/mappers/map-debug-trace.d.ts +10 -0
- package/dist/src/ucp/mappers/map-debug-trace.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-debug-trace.js +18 -0
- package/dist/src/ucp/mappers/map-debug-trace.js.map +1 -0
- package/dist/src/ucp/mappers/map-disambiguation.d.ts +10 -0
- package/dist/src/ucp/mappers/map-disambiguation.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-disambiguation.js +21 -0
- package/dist/src/ucp/mappers/map-disambiguation.js.map +1 -0
- package/dist/src/ucp/mappers/map-execution-trace.d.ts +64 -0
- package/dist/src/ucp/mappers/map-execution-trace.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-execution-trace.js +57 -0
- package/dist/src/ucp/mappers/map-execution-trace.js.map +1 -0
- package/dist/src/ucp/mappers/map-intent-interpretation.d.ts +11 -0
- package/dist/src/ucp/mappers/map-intent-interpretation.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-intent-interpretation.js +17 -0
- package/dist/src/ucp/mappers/map-intent-interpretation.js.map +1 -0
- package/dist/src/ucp/mappers/map-intent.d.ts +9 -0
- package/dist/src/ucp/mappers/map-intent.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-intent.js +11 -0
- package/dist/src/ucp/mappers/map-intent.js.map +1 -0
- package/dist/src/ucp/mappers/map-prv.d.ts +10 -0
- package/dist/src/ucp/mappers/map-prv.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-prv.js +14 -0
- package/dist/src/ucp/mappers/map-prv.js.map +1 -0
- package/dist/src/ucp/mappers/map-reminder-execution.d.ts +57 -0
- package/dist/src/ucp/mappers/map-reminder-execution.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-reminder-execution.js +69 -0
- package/dist/src/ucp/mappers/map-reminder-execution.js.map +1 -0
- package/dist/src/ucp/mappers/map-replay-report.d.ts +81 -0
- package/dist/src/ucp/mappers/map-replay-report.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-replay-report.js +76 -0
- package/dist/src/ucp/mappers/map-replay-report.js.map +1 -0
- package/dist/src/ucp/mappers/map-response.d.ts +13 -0
- package/dist/src/ucp/mappers/map-response.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-response.js +25 -0
- package/dist/src/ucp/mappers/map-response.js.map +1 -0
- package/dist/src/ucp/mappers/map-safety.d.ts +14 -0
- package/dist/src/ucp/mappers/map-safety.d.ts.map +1 -0
- package/dist/src/ucp/mappers/map-safety.js +22 -0
- package/dist/src/ucp/mappers/map-safety.js.map +1 -0
- package/dist/src/ucp/persistence/index.d.ts +24 -0
- package/dist/src/ucp/persistence/index.d.ts.map +1 -0
- package/dist/src/ucp/persistence/index.js +22 -0
- package/dist/src/ucp/persistence/index.js.map +1 -0
- package/dist/src/ucp/persistence/query.d.ts +164 -0
- package/dist/src/ucp/persistence/query.d.ts.map +1 -0
- package/dist/src/ucp/persistence/query.js +240 -0
- package/dist/src/ucp/persistence/query.js.map +1 -0
- package/dist/src/ucp/persistence/reader.d.ts +43 -0
- package/dist/src/ucp/persistence/reader.d.ts.map +1 -0
- package/dist/src/ucp/persistence/reader.js +104 -0
- package/dist/src/ucp/persistence/reader.js.map +1 -0
- package/dist/src/ucp/persistence/store.d.ts +77 -0
- package/dist/src/ucp/persistence/store.d.ts.map +1 -0
- package/dist/src/ucp/persistence/store.js +177 -0
- package/dist/src/ucp/persistence/store.js.map +1 -0
- package/dist/src/ucp/persistence/write.d.ts +48 -0
- package/dist/src/ucp/persistence/write.d.ts.map +1 -0
- package/dist/src/ucp/persistence/write.js +59 -0
- package/dist/src/ucp/persistence/write.js.map +1 -0
- package/dist/src/ucp/projection.d.ts +146 -0
- package/dist/src/ucp/projection.d.ts.map +1 -0
- package/dist/src/ucp/projection.js +139 -0
- package/dist/src/ucp/projection.js.map +1 -0
- package/dist/src/ucp/types.d.ts +585 -0
- package/dist/src/ucp/types.d.ts.map +1 -0
- package/dist/src/ucp/types.js +57 -0
- package/dist/src/ucp/types.js.map +1 -0
- package/dist/src/understand/completion/completion.d.ts +26 -0
- package/dist/src/understand/completion/completion.d.ts.map +1 -0
- package/dist/src/understand/completion/completion.js +45 -0
- package/dist/src/understand/completion/completion.js.map +1 -0
- package/dist/src/understand/completion/rules.d.ts +61 -0
- package/dist/src/understand/completion/rules.d.ts.map +1 -0
- package/dist/src/understand/completion/rules.js +268 -0
- package/dist/src/understand/completion/rules.js.map +1 -0
- package/dist/src/understand/completion/types.d.ts +68 -0
- package/dist/src/understand/completion/types.d.ts.map +1 -0
- package/dist/src/understand/completion/types.js +34 -0
- package/dist/src/understand/completion/types.js.map +1 -0
- package/dist/src/understand/context/context-alignment.d.ts +18 -0
- package/dist/src/understand/context/context-alignment.d.ts.map +1 -0
- package/dist/src/understand/context/context-alignment.js +61 -0
- package/dist/src/understand/context/context-alignment.js.map +1 -0
- package/dist/src/understand/context/types.d.ts +20 -0
- package/dist/src/understand/context/types.d.ts.map +1 -0
- package/dist/src/understand/context/types.js +13 -0
- package/dist/src/understand/context/types.js.map +1 -0
- package/dist/src/understand/disambiguation/detectors/missing-context.detector.d.ts +12 -0
- package/dist/src/understand/disambiguation/detectors/missing-context.detector.d.ts.map +1 -0
- package/dist/src/understand/disambiguation/detectors/missing-context.detector.js +60 -0
- package/dist/src/understand/disambiguation/detectors/missing-context.detector.js.map +1 -0
- package/dist/src/understand/disambiguation/detectors/overloaded-term.detector.d.ts +13 -0
- package/dist/src/understand/disambiguation/detectors/overloaded-term.detector.d.ts.map +1 -0
- package/dist/src/understand/disambiguation/detectors/overloaded-term.detector.js +57 -0
- package/dist/src/understand/disambiguation/detectors/overloaded-term.detector.js.map +1 -0
- package/dist/src/understand/disambiguation/detectors/typo-adjacent.detector.d.ts +16 -0
- package/dist/src/understand/disambiguation/detectors/typo-adjacent.detector.d.ts.map +1 -0
- package/dist/src/understand/disambiguation/detectors/typo-adjacent.detector.js +56 -0
- package/dist/src/understand/disambiguation/detectors/typo-adjacent.detector.js.map +1 -0
- package/dist/src/understand/disambiguation/registry.d.ts +14 -0
- package/dist/src/understand/disambiguation/registry.d.ts.map +1 -0
- package/dist/src/understand/disambiguation/registry.js +27 -0
- package/dist/src/understand/disambiguation/registry.js.map +1 -0
- package/dist/src/understand/disambiguation/types.d.ts +34 -0
- package/dist/src/understand/disambiguation/types.d.ts.map +1 -0
- package/dist/src/understand/disambiguation/types.js +15 -0
- package/dist/src/understand/disambiguation/types.js.map +1 -0
- package/dist/src/understand/intent-interpretation/intent-interpretation.d.ts +86 -0
- package/dist/src/understand/intent-interpretation/intent-interpretation.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/intent-interpretation.js +141 -0
- package/dist/src/understand/intent-interpretation/intent-interpretation.js.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/color-intent.interpreter.d.ts +33 -0
- package/dist/src/understand/intent-interpretation/interpreters/color-intent.interpreter.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/color-intent.interpreter.js +66 -0
- package/dist/src/understand/intent-interpretation/interpreters/color-intent.interpreter.js.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/config-intent.interpreter.d.ts +20 -0
- package/dist/src/understand/intent-interpretation/interpreters/config-intent.interpreter.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/config-intent.interpreter.js +80 -0
- package/dist/src/understand/intent-interpretation/interpreters/config-intent.interpreter.js.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/text-intent.interpreter.d.ts +25 -0
- package/dist/src/understand/intent-interpretation/interpreters/text-intent.interpreter.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/text-intent.interpreter.js +47 -0
- package/dist/src/understand/intent-interpretation/interpreters/text-intent.interpreter.js.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/workflow-intent.interpreter.d.ts +35 -0
- package/dist/src/understand/intent-interpretation/interpreters/workflow-intent.interpreter.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/interpreters/workflow-intent.interpreter.js +89 -0
- package/dist/src/understand/intent-interpretation/interpreters/workflow-intent.interpreter.js.map +1 -0
- package/dist/src/understand/intent-interpretation/registry.d.ts +18 -0
- package/dist/src/understand/intent-interpretation/registry.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/registry.js +26 -0
- package/dist/src/understand/intent-interpretation/registry.js.map +1 -0
- package/dist/src/understand/intent-interpretation/types.d.ts +83 -0
- package/dist/src/understand/intent-interpretation/types.d.ts.map +1 -0
- package/dist/src/understand/intent-interpretation/types.js +40 -0
- package/dist/src/understand/intent-interpretation/types.js.map +1 -0
- package/dist/src/understand/interpretation/intent.d.ts +72 -0
- package/dist/src/understand/interpretation/intent.d.ts.map +1 -0
- package/dist/src/understand/interpretation/intent.js +414 -0
- package/dist/src/understand/interpretation/intent.js.map +1 -0
- package/dist/src/understand/interpretation/interpretation.d.ts +26 -0
- package/dist/src/understand/interpretation/interpretation.d.ts.map +1 -0
- package/dist/src/understand/interpretation/interpretation.js +43 -0
- package/dist/src/understand/interpretation/interpretation.js.map +1 -0
- package/dist/src/understand/interpretation/parser.d.ts +20 -0
- package/dist/src/understand/interpretation/parser.d.ts.map +1 -0
- package/dist/src/understand/interpretation/parser.js +88 -0
- package/dist/src/understand/interpretation/parser.js.map +1 -0
- package/dist/src/understand/interpretation/rules.d.ts +19 -0
- package/dist/src/understand/interpretation/rules.d.ts.map +1 -0
- package/dist/src/understand/interpretation/rules.js +222 -0
- package/dist/src/understand/interpretation/rules.js.map +1 -0
- package/dist/src/understand/interpretation/types.d.ts +90 -0
- package/dist/src/understand/interpretation/types.d.ts.map +1 -0
- package/dist/src/understand/interpretation/types.js +29 -0
- package/dist/src/understand/interpretation/types.js.map +1 -0
- package/dist/src/understand/shared/types.d.ts +13 -0
- package/dist/src/understand/shared/types.d.ts.map +1 -0
- package/dist/src/understand/shared/types.js +9 -0
- package/dist/src/understand/shared/types.js.map +1 -0
- package/dist/src/understand/silent-guidance/index.d.ts +4 -0
- package/dist/src/understand/silent-guidance/index.d.ts.map +1 -0
- package/dist/src/understand/silent-guidance/index.js +3 -0
- package/dist/src/understand/silent-guidance/index.js.map +1 -0
- package/dist/src/understand/silent-guidance/selector.d.ts +44 -0
- package/dist/src/understand/silent-guidance/selector.d.ts.map +1 -0
- package/dist/src/understand/silent-guidance/selector.js +158 -0
- package/dist/src/understand/silent-guidance/selector.js.map +1 -0
- package/dist/src/understand/silent-guidance/templates.d.ts +31 -0
- package/dist/src/understand/silent-guidance/templates.d.ts.map +1 -0
- package/dist/src/understand/silent-guidance/templates.js +109 -0
- package/dist/src/understand/silent-guidance/templates.js.map +1 -0
- package/dist/src/understand/silent-guidance/types.d.ts +36 -0
- package/dist/src/understand/silent-guidance/types.d.ts.map +1 -0
- package/dist/src/understand/silent-guidance/types.js +2 -0
- package/dist/src/understand/silent-guidance/types.js.map +1 -0
- package/dist/src/workflow/coordinator.d.ts +197 -0
- package/dist/src/workflow/coordinator.d.ts.map +1 -0
- package/dist/src/workflow/coordinator.js +682 -0
- package/dist/src/workflow/coordinator.js.map +1 -0
- package/dist/src/workflow/index.d.ts +30 -0
- package/dist/src/workflow/index.d.ts.map +1 -0
- package/dist/src/workflow/index.js +30 -0
- package/dist/src/workflow/index.js.map +1 -0
- package/dist/src/workflow/types.d.ts +213 -0
- package/dist/src/workflow/types.d.ts.map +1 -0
- package/dist/src/workflow/types.js +27 -0
- package/dist/src/workflow/types.js.map +1 -0
- package/package.json +54 -0
- package/ui/README.md +73 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-safety.d.ts","sourceRoot":"","sources":["../../../../src/ucp/mappers/map-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAiB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,cAAc,CASxF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapper: SafetyResult → SafetyEnvelope.
|
|
3
|
+
*
|
|
4
|
+
* Maps exactly from SafetyResult (src/safety/types.ts).
|
|
5
|
+
* Includes inspection fields (detectorId, matchedPattern) when present.
|
|
6
|
+
* "allow" results carry only the verdict — no reason or note.
|
|
7
|
+
*
|
|
8
|
+
* Optional fields use conditional spreading — never explicit undefined.
|
|
9
|
+
* See: src/ucp/types.ts — "PROTOCOL INVARIANT: Payloads must be undefined-free"
|
|
10
|
+
*/
|
|
11
|
+
import { createSafetyEnvelope } from "../envelope.js";
|
|
12
|
+
export function mapSafetyToEnvelope(result, refs) {
|
|
13
|
+
const payload = {
|
|
14
|
+
verdict: result.verdict,
|
|
15
|
+
...(result.reason !== undefined ? { reason: result.reason } : {}),
|
|
16
|
+
...(result.detectorId !== undefined ? { detectorId: result.detectorId } : {}),
|
|
17
|
+
...(result.matchedPattern !== undefined ? { matchedPattern: result.matchedPattern } : {}),
|
|
18
|
+
...(result.note !== undefined ? { note: result.note } : {}),
|
|
19
|
+
};
|
|
20
|
+
return createSafetyEnvelope(payload, refs);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=map-safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-safety.js","sourceRoot":"","sources":["../../../../src/ucp/mappers/map-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAItD,MAAM,UAAU,mBAAmB,CAAC,MAAoB,EAAE,IAAc;IACtE,MAAM,OAAO,GAAkB;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAY,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAU,MAAM,CAAC,MAAM,EAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,GAAG,CAAC,MAAM,CAAC,UAAU,KAAQ,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAM,MAAM,CAAC,UAAU,EAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,MAAM,CAAC,IAAI,KAAc,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAY,MAAM,CAAC,IAAI,EAAW,CAAC,CAAC,CAAC,EAAE,CAAC;KACxF,CAAC;IACF,OAAO,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence — public API.
|
|
3
|
+
*
|
|
4
|
+
* Phase 4A — store + write:
|
|
5
|
+
* persistEnvelope — fire-and-forget facade (callers use this)
|
|
6
|
+
* appendEnvelope — raw log append (returns byte offset)
|
|
7
|
+
* loadIndex / updateIndex / rebuildIndex — index management
|
|
8
|
+
*
|
|
9
|
+
* Phase 4B — reader + query:
|
|
10
|
+
* readEnvelopeAt — seek to byte offset, parse one envelope
|
|
11
|
+
* readAllEnvelopes — full log scan
|
|
12
|
+
* getEnvelopeById — O(1) id lookup via index
|
|
13
|
+
* getByType — type-filtered bulk lookup
|
|
14
|
+
* getChain — full intent provenance chain via byRoot
|
|
15
|
+
* getArtifactByRunId / getTraceByArtifactId / getReplayByArtifactId
|
|
16
|
+
* getTimeline — complete run reconstruction from intentId
|
|
17
|
+
*/
|
|
18
|
+
export type { UCPIndex } from "./store.js";
|
|
19
|
+
export { LOG_FILENAME, INDEX_FILENAME, emptyIndex, ensureStoreDir, appendEnvelope, loadIndex, updateIndex, rebuildIndex, } from "./store.js";
|
|
20
|
+
export { persistEnvelope } from "./write.js";
|
|
21
|
+
export { readEnvelopeAt, readAllEnvelopes } from "./reader.js";
|
|
22
|
+
export type { RunTimeline } from "./query.js";
|
|
23
|
+
export { getEnvelopeById, getByType, getChain, getArtifactByRunId, getTraceByArtifactId, getReplayByArtifactId, getReminderExecutionByResponseId, getTimeline, } from "./query.js";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ucp/persistence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence — public API.
|
|
3
|
+
*
|
|
4
|
+
* Phase 4A — store + write:
|
|
5
|
+
* persistEnvelope — fire-and-forget facade (callers use this)
|
|
6
|
+
* appendEnvelope — raw log append (returns byte offset)
|
|
7
|
+
* loadIndex / updateIndex / rebuildIndex — index management
|
|
8
|
+
*
|
|
9
|
+
* Phase 4B — reader + query:
|
|
10
|
+
* readEnvelopeAt — seek to byte offset, parse one envelope
|
|
11
|
+
* readAllEnvelopes — full log scan
|
|
12
|
+
* getEnvelopeById — O(1) id lookup via index
|
|
13
|
+
* getByType — type-filtered bulk lookup
|
|
14
|
+
* getChain — full intent provenance chain via byRoot
|
|
15
|
+
* getArtifactByRunId / getTraceByArtifactId / getReplayByArtifactId
|
|
16
|
+
* getTimeline — complete run reconstruction from intentId
|
|
17
|
+
*/
|
|
18
|
+
export { LOG_FILENAME, INDEX_FILENAME, emptyIndex, ensureStoreDir, appendEnvelope, loadIndex, updateIndex, rebuildIndex, } from "./store.js";
|
|
19
|
+
export { persistEnvelope } from "./write.js";
|
|
20
|
+
export { readEnvelopeAt, readAllEnvelopes } from "./reader.js";
|
|
21
|
+
export { getEnvelopeById, getByType, getChain, getArtifactByRunId, getTraceByArtifactId, getReplayByArtifactId, getReminderExecutionByResponseId, getTimeline, } from "./query.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ucp/persistence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EACL,eAAe,EACf,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gCAAgC,EAChC,WAAW,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence Query Layer — navigation over the UCP envelope history.
|
|
3
|
+
*
|
|
4
|
+
* Every query function in this module ONLY follows explicit refs (parentId, rootId)
|
|
5
|
+
* or field values stored in the payload. No relationship is inferred.
|
|
6
|
+
*
|
|
7
|
+
* ── Design constraints ────────────────────────────────────────────────────────
|
|
8
|
+
*
|
|
9
|
+
* 1. Refs-only navigation — getChain follows refs.rootId, child lookups follow
|
|
10
|
+
* refs.parentId. No structural inference beyond what refs declare.
|
|
11
|
+
*
|
|
12
|
+
* 2. No caching — each call reads from disk via reader.ts. Caching is deferred.
|
|
13
|
+
*
|
|
14
|
+
* 3. Type-narrowed returns — artifact/trace/replay queries return typed aliases.
|
|
15
|
+
* Narrowing is done by checking envelope.type before casting — never blindly.
|
|
16
|
+
*
|
|
17
|
+
* 4. Null-safe — all queries return null or empty array rather than throwing
|
|
18
|
+
* when data is missing or corrupt.
|
|
19
|
+
*
|
|
20
|
+
* 5. Zero mutation — returned envelopes are the exact parsed records; nothing
|
|
21
|
+
* is modified, sorted, or enriched by this layer.
|
|
22
|
+
*
|
|
23
|
+
* 6. No authority — queries are read-only observability tools. They must not
|
|
24
|
+
* affect any runtime, intake, or execution behavior.
|
|
25
|
+
*
|
|
26
|
+
* ── Query function summary ────────────────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* getEnvelopeById — load one envelope by id (uses byId index offset)
|
|
29
|
+
* getByType — load all envelopes for a type (uses byType index)
|
|
30
|
+
* getChain — load all envelopes for an intent (uses byRoot index)
|
|
31
|
+
* getArtifactByRunId — find artifact by payload.runId
|
|
32
|
+
* getTraceByArtifactId — find execution trace parented to an artifact env
|
|
33
|
+
* getReplayByArtifactId — find replay report parented to an artifact env
|
|
34
|
+
* getReminderExecutionByResponseId — find reminder execution parented to a response env
|
|
35
|
+
* getTimeline — full run reconstruction from an intentId
|
|
36
|
+
*
|
|
37
|
+
* ── Provenance chain (how envelopes link) ─────────────────────────────────────
|
|
38
|
+
*
|
|
39
|
+
* ucp.intent.v1 — no refs (it is the root)
|
|
40
|
+
* ucp.response.v1 — parentId = intentId, rootId = intentId
|
|
41
|
+
* ucp.artifact.v1 — rootId = intentId
|
|
42
|
+
* ucp.execution_trace.v1 — parentId = artifactEnvId, rootId = intentId
|
|
43
|
+
* ucp.replay_report.v1 — parentId = artifactEnvId, rootId = intentId
|
|
44
|
+
* ucp.reminder_execution.v1 — parentId = responseEnvId, rootId = intentId
|
|
45
|
+
*
|
|
46
|
+
* byRoot[intentId] covers: response + artifact + trace + replay + reminder_execution
|
|
47
|
+
* byParent[artifactEnvId] covers: trace + replay
|
|
48
|
+
* byParent[responseEnvId] covers: reminder_execution
|
|
49
|
+
*/
|
|
50
|
+
import type { UCPEnvelope, UCPType, ArtifactPayload, ArtifactEnvelope, ExecutionTracePayload, ExecutionTraceEnvelope, ReplayReportPayload, ReplayReportEnvelope, ReminderExecutionPayload, ReminderExecutionEnvelope } from "../types.js";
|
|
51
|
+
/**
|
|
52
|
+
* Load one envelope by its content-addressed id.
|
|
53
|
+
* Uses the byId byte-offset index for O(1) file seek.
|
|
54
|
+
*
|
|
55
|
+
* Returns null if the id is not in the index or the record is corrupt.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getEnvelopeById(storeDir: string, id: string): UCPEnvelope<unknown> | null;
|
|
58
|
+
/**
|
|
59
|
+
* Load all envelopes of a specific UCPType.
|
|
60
|
+
* Uses byType index to identify ids, then resolves each via byId offset.
|
|
61
|
+
*
|
|
62
|
+
* Returns envelopes in index order (which matches append/log order).
|
|
63
|
+
* Corrupt or missing records are skipped silently.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getByType(storeDir: string, type: UCPType): UCPEnvelope<unknown>[];
|
|
66
|
+
/**
|
|
67
|
+
* Load the full provenance chain for an intent.
|
|
68
|
+
*
|
|
69
|
+
* Returns the intent envelope itself plus every envelope that declares
|
|
70
|
+
* refs.rootId === intentId. This covers: response, artifact, trace, replay.
|
|
71
|
+
*
|
|
72
|
+
* Envelopes are returned in log order (chronological).
|
|
73
|
+
*
|
|
74
|
+
* Returns an empty array if intentId is not found in the index.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getChain(storeDir: string, intentId: string): UCPEnvelope<unknown>[];
|
|
77
|
+
/**
|
|
78
|
+
* Find the artifact envelope whose payload.runId matches.
|
|
79
|
+
*
|
|
80
|
+
* Uses byType["ucp.artifact.v1"] to limit the scan to artifact envelopes only.
|
|
81
|
+
* Does NOT scan the full log. Returns null if no match is found.
|
|
82
|
+
*
|
|
83
|
+
* IMPORTANT: follows stored field values only — does not infer runId from context.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getArtifactByRunId(storeDir: string, runId: string): ArtifactEnvelope | null;
|
|
86
|
+
/**
|
|
87
|
+
* Find the execution trace envelope that is a direct child of `artifactEnvId`.
|
|
88
|
+
*
|
|
89
|
+
* A trace envelope declares refs.parentId === artifactEnvId.
|
|
90
|
+
* Returns null if not found.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getTraceByArtifactId(storeDir: string, artifactEnvId: string): ExecutionTraceEnvelope | null;
|
|
93
|
+
/**
|
|
94
|
+
* Find the replay report envelope that is a direct child of `artifactEnvId`.
|
|
95
|
+
*
|
|
96
|
+
* A replay envelope declares refs.parentId === artifactEnvId.
|
|
97
|
+
* Returns null if not found.
|
|
98
|
+
*/
|
|
99
|
+
export declare function getReplayByArtifactId(storeDir: string, artifactEnvId: string): ReplayReportEnvelope | null;
|
|
100
|
+
/**
|
|
101
|
+
* Find the reminder execution envelope that is a direct child of `responseEnvId`.
|
|
102
|
+
*
|
|
103
|
+
* A reminder execution envelope declares refs.parentId === responseEnvId.
|
|
104
|
+
* Returns null if not found.
|
|
105
|
+
*
|
|
106
|
+
* Navigation: byParent[responseEnvId], filtered by type === "ucp.reminder_execution.v1".
|
|
107
|
+
*/
|
|
108
|
+
export declare function getReminderExecutionByResponseId(storeDir: string, responseEnvId: string): ReminderExecutionEnvelope | null;
|
|
109
|
+
/**
|
|
110
|
+
* A complete run timeline reconstructed from the UCP log.
|
|
111
|
+
*
|
|
112
|
+
* All fields may be null — a field is null when the corresponding envelope
|
|
113
|
+
* has not yet been persisted, or was not found in the index.
|
|
114
|
+
*
|
|
115
|
+
* null does NOT mean failure — it means that phase of the run is not (yet) recorded.
|
|
116
|
+
*
|
|
117
|
+
* ── Branch structure ──────────────────────────────────────────────────────────
|
|
118
|
+
*
|
|
119
|
+
* Standard execution branch:
|
|
120
|
+
* intent → response → artifact → trace + replay
|
|
121
|
+
*
|
|
122
|
+
* Reminder execution branch (Phase 6):
|
|
123
|
+
* intent → response → reminderExecution
|
|
124
|
+
*
|
|
125
|
+
* Both branches may be null — they are mutually exclusive in practice but
|
|
126
|
+
* the type system does not enforce exclusivity (both fields may be non-null
|
|
127
|
+
* if a run somehow produced both, though this should not occur).
|
|
128
|
+
*/
|
|
129
|
+
export type RunTimeline = {
|
|
130
|
+
/** The originating intent, if found. */
|
|
131
|
+
readonly intent: UCPEnvelope<unknown> | null;
|
|
132
|
+
/** The response envelope (mode + reason + guidance), if found. */
|
|
133
|
+
readonly response: UCPEnvelope<unknown> | null;
|
|
134
|
+
/** The artifact envelope (runId + goal + checksum), if found. */
|
|
135
|
+
readonly artifact: ArtifactEnvelope | null;
|
|
136
|
+
/** The execution trace envelope (traceHash + kinds), if found. */
|
|
137
|
+
readonly trace: ExecutionTraceEnvelope | null;
|
|
138
|
+
/** The replay report envelope (verdict + counts), if found. */
|
|
139
|
+
readonly replay: ReplayReportEnvelope | null;
|
|
140
|
+
/**
|
|
141
|
+
* The reminder execution envelope (verdict + time classification), if found.
|
|
142
|
+
*
|
|
143
|
+
* Present for runs that went through the reminder execution path (Phase 6).
|
|
144
|
+
* null for all standard (non-reminder) runs.
|
|
145
|
+
*
|
|
146
|
+
* Navigation: byRoot[intentId] scan → type === "ucp.reminder_execution.v1".
|
|
147
|
+
*/
|
|
148
|
+
readonly reminderExecution: ReminderExecutionEnvelope | null;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Reconstruct a full run timeline from an intent envelope id.
|
|
152
|
+
*
|
|
153
|
+
* Navigation is strictly refs-based:
|
|
154
|
+
* 1. intentId → intent envelope (byId lookup)
|
|
155
|
+
* 2. byRoot[intentId] → all descendants; typed by envelope.type
|
|
156
|
+
* 3. artifact env id → trace and replay (byParent lookup)
|
|
157
|
+
* 4. byRoot scan → reminderExecution (type === "ucp.reminder_execution.v1")
|
|
158
|
+
*
|
|
159
|
+
* No inference. No relationship reconstruction beyond what refs declare.
|
|
160
|
+
* Returns a RunTimeline where missing envelopes are null.
|
|
161
|
+
*/
|
|
162
|
+
export declare function getTimeline(storeDir: string, intentId: string): RunTimeline;
|
|
163
|
+
export type { ArtifactPayload, ExecutionTracePayload, ReplayReportPayload, ReminderExecutionPayload };
|
|
164
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/ucp/persistence/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAIrB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAQ,MAAM,GACf,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAK7B;AAID;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAM,OAAO,GAChB,WAAW,CAAC,OAAO,CAAC,EAAE,CAWxB;AAID;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAG,MAAM,EACjB,QAAQ,EAAG,MAAM,GAChB,WAAW,CAAC,OAAO,CAAC,EAAE,CAoBxB;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAK,MAAM,GACf,gBAAgB,GAAG,IAAI,CAezB;AAID;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAQ,MAAM,EACtB,aAAa,EAAG,MAAM,GACrB,sBAAsB,GAAG,IAAI,CAa/B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAQ,MAAM,EACtB,aAAa,EAAG,MAAM,GACrB,oBAAoB,GAAG,IAAI,CAa7B;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAO,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,yBAAyB,GAAG,IAAI,CAalC;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAa,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAW,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAW,gBAAgB,GAAG,IAAI,CAAC;IACpD,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAc,sBAAsB,GAAG,IAAI,CAAC;IAC1D,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAa,oBAAoB,GAAG,IAAI,CAAC;IACxD;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,WAAW,CAsBb;AAGD,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence Query Layer — navigation over the UCP envelope history.
|
|
3
|
+
*
|
|
4
|
+
* Every query function in this module ONLY follows explicit refs (parentId, rootId)
|
|
5
|
+
* or field values stored in the payload. No relationship is inferred.
|
|
6
|
+
*
|
|
7
|
+
* ── Design constraints ────────────────────────────────────────────────────────
|
|
8
|
+
*
|
|
9
|
+
* 1. Refs-only navigation — getChain follows refs.rootId, child lookups follow
|
|
10
|
+
* refs.parentId. No structural inference beyond what refs declare.
|
|
11
|
+
*
|
|
12
|
+
* 2. No caching — each call reads from disk via reader.ts. Caching is deferred.
|
|
13
|
+
*
|
|
14
|
+
* 3. Type-narrowed returns — artifact/trace/replay queries return typed aliases.
|
|
15
|
+
* Narrowing is done by checking envelope.type before casting — never blindly.
|
|
16
|
+
*
|
|
17
|
+
* 4. Null-safe — all queries return null or empty array rather than throwing
|
|
18
|
+
* when data is missing or corrupt.
|
|
19
|
+
*
|
|
20
|
+
* 5. Zero mutation — returned envelopes are the exact parsed records; nothing
|
|
21
|
+
* is modified, sorted, or enriched by this layer.
|
|
22
|
+
*
|
|
23
|
+
* 6. No authority — queries are read-only observability tools. They must not
|
|
24
|
+
* affect any runtime, intake, or execution behavior.
|
|
25
|
+
*
|
|
26
|
+
* ── Query function summary ────────────────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* getEnvelopeById — load one envelope by id (uses byId index offset)
|
|
29
|
+
* getByType — load all envelopes for a type (uses byType index)
|
|
30
|
+
* getChain — load all envelopes for an intent (uses byRoot index)
|
|
31
|
+
* getArtifactByRunId — find artifact by payload.runId
|
|
32
|
+
* getTraceByArtifactId — find execution trace parented to an artifact env
|
|
33
|
+
* getReplayByArtifactId — find replay report parented to an artifact env
|
|
34
|
+
* getReminderExecutionByResponseId — find reminder execution parented to a response env
|
|
35
|
+
* getTimeline — full run reconstruction from an intentId
|
|
36
|
+
*
|
|
37
|
+
* ── Provenance chain (how envelopes link) ─────────────────────────────────────
|
|
38
|
+
*
|
|
39
|
+
* ucp.intent.v1 — no refs (it is the root)
|
|
40
|
+
* ucp.response.v1 — parentId = intentId, rootId = intentId
|
|
41
|
+
* ucp.artifact.v1 — rootId = intentId
|
|
42
|
+
* ucp.execution_trace.v1 — parentId = artifactEnvId, rootId = intentId
|
|
43
|
+
* ucp.replay_report.v1 — parentId = artifactEnvId, rootId = intentId
|
|
44
|
+
* ucp.reminder_execution.v1 — parentId = responseEnvId, rootId = intentId
|
|
45
|
+
*
|
|
46
|
+
* byRoot[intentId] covers: response + artifact + trace + replay + reminder_execution
|
|
47
|
+
* byParent[artifactEnvId] covers: trace + replay
|
|
48
|
+
* byParent[responseEnvId] covers: reminder_execution
|
|
49
|
+
*/
|
|
50
|
+
import { loadIndex } from "./store.js";
|
|
51
|
+
import { readEnvelopeAt } from "./reader.js";
|
|
52
|
+
// ─── Single-envelope lookup ───────────────────────────────────────────────────
|
|
53
|
+
/**
|
|
54
|
+
* Load one envelope by its content-addressed id.
|
|
55
|
+
* Uses the byId byte-offset index for O(1) file seek.
|
|
56
|
+
*
|
|
57
|
+
* Returns null if the id is not in the index or the record is corrupt.
|
|
58
|
+
*/
|
|
59
|
+
export function getEnvelopeById(storeDir, id) {
|
|
60
|
+
const index = loadIndex(storeDir);
|
|
61
|
+
const offset = index.byId[id];
|
|
62
|
+
if (offset === undefined)
|
|
63
|
+
return null;
|
|
64
|
+
return readEnvelopeAt(storeDir, offset);
|
|
65
|
+
}
|
|
66
|
+
// ─── Type-based bulk lookup ───────────────────────────────────────────────────
|
|
67
|
+
/**
|
|
68
|
+
* Load all envelopes of a specific UCPType.
|
|
69
|
+
* Uses byType index to identify ids, then resolves each via byId offset.
|
|
70
|
+
*
|
|
71
|
+
* Returns envelopes in index order (which matches append/log order).
|
|
72
|
+
* Corrupt or missing records are skipped silently.
|
|
73
|
+
*/
|
|
74
|
+
export function getByType(storeDir, type) {
|
|
75
|
+
const index = loadIndex(storeDir);
|
|
76
|
+
const ids = index.byType[type] ?? [];
|
|
77
|
+
const results = [];
|
|
78
|
+
for (const id of ids) {
|
|
79
|
+
const env = getEnvelopeById(storeDir, id);
|
|
80
|
+
if (env !== null)
|
|
81
|
+
results.push(env);
|
|
82
|
+
}
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
// ─── Chain navigation (byRoot) ────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* Load the full provenance chain for an intent.
|
|
88
|
+
*
|
|
89
|
+
* Returns the intent envelope itself plus every envelope that declares
|
|
90
|
+
* refs.rootId === intentId. This covers: response, artifact, trace, replay.
|
|
91
|
+
*
|
|
92
|
+
* Envelopes are returned in log order (chronological).
|
|
93
|
+
*
|
|
94
|
+
* Returns an empty array if intentId is not found in the index.
|
|
95
|
+
*/
|
|
96
|
+
export function getChain(storeDir, intentId) {
|
|
97
|
+
const index = loadIndex(storeDir);
|
|
98
|
+
const results = [];
|
|
99
|
+
// The intent envelope itself has no refs — it is the root.
|
|
100
|
+
// It lives in byId but not in byRoot (nothing has rootId = intentId for the intent itself).
|
|
101
|
+
const intentOffset = index.byId[intentId];
|
|
102
|
+
if (intentOffset !== undefined) {
|
|
103
|
+
const intentEnv = readEnvelopeAt(storeDir, intentOffset);
|
|
104
|
+
if (intentEnv !== null)
|
|
105
|
+
results.push(intentEnv);
|
|
106
|
+
}
|
|
107
|
+
// All descendant envelopes: their refs.rootId === intentId
|
|
108
|
+
const childIds = index.byRoot[intentId] ?? [];
|
|
109
|
+
for (const id of childIds) {
|
|
110
|
+
const env = getEnvelopeById(storeDir, id);
|
|
111
|
+
if (env !== null)
|
|
112
|
+
results.push(env);
|
|
113
|
+
}
|
|
114
|
+
return results;
|
|
115
|
+
}
|
|
116
|
+
// ─── Artifact lookup ──────────────────────────────────────────────────────────
|
|
117
|
+
/**
|
|
118
|
+
* Find the artifact envelope whose payload.runId matches.
|
|
119
|
+
*
|
|
120
|
+
* Uses byType["ucp.artifact.v1"] to limit the scan to artifact envelopes only.
|
|
121
|
+
* Does NOT scan the full log. Returns null if no match is found.
|
|
122
|
+
*
|
|
123
|
+
* IMPORTANT: follows stored field values only — does not infer runId from context.
|
|
124
|
+
*/
|
|
125
|
+
export function getArtifactByRunId(storeDir, runId) {
|
|
126
|
+
const index = loadIndex(storeDir);
|
|
127
|
+
const ids = index.byType["ucp.artifact.v1"] ?? [];
|
|
128
|
+
for (const id of ids) {
|
|
129
|
+
const env = getEnvelopeById(storeDir, id);
|
|
130
|
+
if (env === null)
|
|
131
|
+
continue;
|
|
132
|
+
if (env.type !== "ucp.artifact.v1")
|
|
133
|
+
continue;
|
|
134
|
+
// Type-narrow: payload has runId because type === "ucp.artifact.v1"
|
|
135
|
+
const payload = env.payload;
|
|
136
|
+
if (payload.runId === runId)
|
|
137
|
+
return env;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
// ─── Children of an artifact (byParent) ──────────────────────────────────────
|
|
142
|
+
/**
|
|
143
|
+
* Find the execution trace envelope that is a direct child of `artifactEnvId`.
|
|
144
|
+
*
|
|
145
|
+
* A trace envelope declares refs.parentId === artifactEnvId.
|
|
146
|
+
* Returns null if not found.
|
|
147
|
+
*/
|
|
148
|
+
export function getTraceByArtifactId(storeDir, artifactEnvId) {
|
|
149
|
+
const index = loadIndex(storeDir);
|
|
150
|
+
const childIds = index.byParent[artifactEnvId] ?? [];
|
|
151
|
+
for (const id of childIds) {
|
|
152
|
+
const env = getEnvelopeById(storeDir, id);
|
|
153
|
+
if (env === null)
|
|
154
|
+
continue;
|
|
155
|
+
if (env.type === "ucp.execution_trace.v1") {
|
|
156
|
+
return env;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Find the replay report envelope that is a direct child of `artifactEnvId`.
|
|
163
|
+
*
|
|
164
|
+
* A replay envelope declares refs.parentId === artifactEnvId.
|
|
165
|
+
* Returns null if not found.
|
|
166
|
+
*/
|
|
167
|
+
export function getReplayByArtifactId(storeDir, artifactEnvId) {
|
|
168
|
+
const index = loadIndex(storeDir);
|
|
169
|
+
const childIds = index.byParent[artifactEnvId] ?? [];
|
|
170
|
+
for (const id of childIds) {
|
|
171
|
+
const env = getEnvelopeById(storeDir, id);
|
|
172
|
+
if (env === null)
|
|
173
|
+
continue;
|
|
174
|
+
if (env.type === "ucp.replay_report.v1") {
|
|
175
|
+
return env;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Find the reminder execution envelope that is a direct child of `responseEnvId`.
|
|
182
|
+
*
|
|
183
|
+
* A reminder execution envelope declares refs.parentId === responseEnvId.
|
|
184
|
+
* Returns null if not found.
|
|
185
|
+
*
|
|
186
|
+
* Navigation: byParent[responseEnvId], filtered by type === "ucp.reminder_execution.v1".
|
|
187
|
+
*/
|
|
188
|
+
export function getReminderExecutionByResponseId(storeDir, responseEnvId) {
|
|
189
|
+
const index = loadIndex(storeDir);
|
|
190
|
+
const childIds = index.byParent[responseEnvId] ?? [];
|
|
191
|
+
for (const id of childIds) {
|
|
192
|
+
const env = getEnvelopeById(storeDir, id);
|
|
193
|
+
if (env === null)
|
|
194
|
+
continue;
|
|
195
|
+
if (env.type === "ucp.reminder_execution.v1") {
|
|
196
|
+
return env;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Reconstruct a full run timeline from an intent envelope id.
|
|
203
|
+
*
|
|
204
|
+
* Navigation is strictly refs-based:
|
|
205
|
+
* 1. intentId → intent envelope (byId lookup)
|
|
206
|
+
* 2. byRoot[intentId] → all descendants; typed by envelope.type
|
|
207
|
+
* 3. artifact env id → trace and replay (byParent lookup)
|
|
208
|
+
* 4. byRoot scan → reminderExecution (type === "ucp.reminder_execution.v1")
|
|
209
|
+
*
|
|
210
|
+
* No inference. No relationship reconstruction beyond what refs declare.
|
|
211
|
+
* Returns a RunTimeline where missing envelopes are null.
|
|
212
|
+
*/
|
|
213
|
+
export function getTimeline(storeDir, intentId) {
|
|
214
|
+
const chain = getChain(storeDir, intentId);
|
|
215
|
+
let intent = null;
|
|
216
|
+
let response = null;
|
|
217
|
+
let artifact = null;
|
|
218
|
+
let reminderExecution = null;
|
|
219
|
+
for (const env of chain) {
|
|
220
|
+
switch (env.type) {
|
|
221
|
+
case "ucp.intent.v1":
|
|
222
|
+
intent = env;
|
|
223
|
+
break;
|
|
224
|
+
case "ucp.response.v1":
|
|
225
|
+
response = env;
|
|
226
|
+
break;
|
|
227
|
+
case "ucp.artifact.v1":
|
|
228
|
+
artifact = env;
|
|
229
|
+
break;
|
|
230
|
+
case "ucp.reminder_execution.v1":
|
|
231
|
+
reminderExecution = env;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// Trace and replay are children of the artifact envelope (standard execution branch)
|
|
236
|
+
const trace = artifact !== null ? getTraceByArtifactId(storeDir, artifact.id) : null;
|
|
237
|
+
const replay = artifact !== null ? getReplayByArtifactId(storeDir, artifact.id) : null;
|
|
238
|
+
return { intent, response, artifact, trace, replay, reminderExecution };
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/ucp/persistence/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAoB,MAAM,aAAa,CAAC;AAc/D,iFAAiF;AAEjF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,EAAgB;IAEhB,MAAM,KAAK,GAAI,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,iFAAiF;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,IAAiB;IAEjB,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,GAAG,GAAK,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACvC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iFAAiF;AAEjF;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,QAAiB,EACjB,QAAiB;IAEjB,MAAM,KAAK,GAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,2DAA2D;IAC3D,4FAA4F;IAC5F,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACzD,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC9C,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iFAAiF;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,KAAgB;IAEhB,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,GAAG,GAAK,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IAEpD,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,iBAAiB;YAAE,SAAS;QAE7C,oEAAoE;QACpE,MAAM,OAAO,GAAG,GAAG,CAAC,OAA0B,CAAC;QAC/C,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK;YAAE,OAAO,GAAuB,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAsB,EACtB,aAAsB;IAEtB,MAAM,KAAK,GAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAErD,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;YAC1C,OAAO,GAA6B,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAsB,EACtB,aAAsB;IAEtB,MAAM,KAAK,GAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAErD,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YACxC,OAAO,GAA2B,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gCAAgC,CAC9C,QAAqB,EACrB,aAAqB;IAErB,MAAM,KAAK,GAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAErD,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,eAAe,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,2BAA2B,EAAE,CAAC;YAC7C,OAAO,GAAgC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA8CD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,QAAgB;IAEhB,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE3C,IAAI,MAAM,GAA2C,IAAI,CAAC;IAC1D,IAAI,QAAQ,GAAyC,IAAI,CAAC;IAC1D,IAAI,QAAQ,GAAyC,IAAI,CAAC;IAC1D,IAAI,iBAAiB,GAAqC,IAAI,CAAC;IAE/D,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,eAAe;gBAAe,MAAM,GAAc,GAAG,CAAC;gBAAC,MAAM;YAClE,KAAK,iBAAiB;gBAAa,QAAQ,GAAY,GAAG,CAAC;gBAAC,MAAM;YAClE,KAAK,iBAAiB;gBAAa,QAAQ,GAAY,GAAuB,CAAC;gBAAC,MAAM;YACtF,KAAK,2BAA2B;gBAAG,iBAAiB,GAAG,GAAgC,CAAC;gBAAC,MAAM;QACjG,CAAC;IACH,CAAC;IAED,qFAAqF;IACrF,MAAM,KAAK,GAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAC,CAAC,IAAI,CAAC;IACvF,MAAM,MAAM,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence Reader — low-level log file reads.
|
|
3
|
+
*
|
|
4
|
+
* Provides two read primitives:
|
|
5
|
+
* readEnvelopeAt — seek to a byte offset, read one line, parse one envelope
|
|
6
|
+
* readAllEnvelopes — scan the full log, parse all valid lines
|
|
7
|
+
*
|
|
8
|
+
* ── Design constraints ────────────────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* 1. Read-only — these functions never write to disk.
|
|
11
|
+
* 2. Null-safe — missing file or corrupt line returns null / is skipped.
|
|
12
|
+
* 3. No caching — each call reads from disk. Caching is a Phase 4C concern.
|
|
13
|
+
* 4. No inference — returns raw parsed envelope exactly as stored.
|
|
14
|
+
*
|
|
15
|
+
* ── Performance note ──────────────────────────────────────────────────────────
|
|
16
|
+
*
|
|
17
|
+
* readEnvelopeAt uses openSync/readSync to seek without loading the full file.
|
|
18
|
+
* Chunk size of 64 KB covers virtually all real envelope sizes. For unusually
|
|
19
|
+
* large payloads, the chunk is extended automatically.
|
|
20
|
+
*
|
|
21
|
+
* readAllEnvelopes reads the full file once and splits by newline.
|
|
22
|
+
* This is correct for Phase 4B; rotation / streaming is a future concern.
|
|
23
|
+
*/
|
|
24
|
+
import type { UCPEnvelope } from "../types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Read and parse the envelope stored at `offset` bytes in envelopes.log.
|
|
27
|
+
*
|
|
28
|
+
* Returns null if:
|
|
29
|
+
* - The log file does not exist
|
|
30
|
+
* - The offset is beyond the end of file
|
|
31
|
+
* - The line at that offset is not valid JSON
|
|
32
|
+
*
|
|
33
|
+
* Does NOT verify the envelope hash. Integrity checks are a query-layer concern.
|
|
34
|
+
*/
|
|
35
|
+
export declare function readEnvelopeAt(storeDir: string, offset: number): UCPEnvelope<unknown> | null;
|
|
36
|
+
/**
|
|
37
|
+
* Read and parse all valid envelopes from envelopes.log.
|
|
38
|
+
*
|
|
39
|
+
* Corrupt or unparseable lines are skipped silently.
|
|
40
|
+
* Returns envelopes in log order (chronological, oldest first).
|
|
41
|
+
*/
|
|
42
|
+
export declare function readAllEnvelopes(storeDir: string): UCPEnvelope<unknown>[];
|
|
43
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../src/ucp/persistence/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAqC5F;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE,CAkBzE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UCP Persistence Reader — low-level log file reads.
|
|
3
|
+
*
|
|
4
|
+
* Provides two read primitives:
|
|
5
|
+
* readEnvelopeAt — seek to a byte offset, read one line, parse one envelope
|
|
6
|
+
* readAllEnvelopes — scan the full log, parse all valid lines
|
|
7
|
+
*
|
|
8
|
+
* ── Design constraints ────────────────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* 1. Read-only — these functions never write to disk.
|
|
11
|
+
* 2. Null-safe — missing file or corrupt line returns null / is skipped.
|
|
12
|
+
* 3. No caching — each call reads from disk. Caching is a Phase 4C concern.
|
|
13
|
+
* 4. No inference — returns raw parsed envelope exactly as stored.
|
|
14
|
+
*
|
|
15
|
+
* ── Performance note ──────────────────────────────────────────────────────────
|
|
16
|
+
*
|
|
17
|
+
* readEnvelopeAt uses openSync/readSync to seek without loading the full file.
|
|
18
|
+
* Chunk size of 64 KB covers virtually all real envelope sizes. For unusually
|
|
19
|
+
* large payloads, the chunk is extended automatically.
|
|
20
|
+
*
|
|
21
|
+
* readAllEnvelopes reads the full file once and splits by newline.
|
|
22
|
+
* This is correct for Phase 4B; rotation / streaming is a future concern.
|
|
23
|
+
*/
|
|
24
|
+
import { existsSync, openSync, readSync, closeSync, readFileSync, } from "fs";
|
|
25
|
+
import { join } from "path";
|
|
26
|
+
import { LOG_FILENAME } from "./store.js";
|
|
27
|
+
// ─── Single-envelope seek read ────────────────────────────────────────────────
|
|
28
|
+
const INITIAL_CHUNK_BYTES = 65_536; // 64 KB — enough for all realistic envelope sizes
|
|
29
|
+
/**
|
|
30
|
+
* Read and parse the envelope stored at `offset` bytes in envelopes.log.
|
|
31
|
+
*
|
|
32
|
+
* Returns null if:
|
|
33
|
+
* - The log file does not exist
|
|
34
|
+
* - The offset is beyond the end of file
|
|
35
|
+
* - The line at that offset is not valid JSON
|
|
36
|
+
*
|
|
37
|
+
* Does NOT verify the envelope hash. Integrity checks are a query-layer concern.
|
|
38
|
+
*/
|
|
39
|
+
export function readEnvelopeAt(storeDir, offset) {
|
|
40
|
+
const logPath = join(storeDir, LOG_FILENAME);
|
|
41
|
+
if (!existsSync(logPath))
|
|
42
|
+
return null;
|
|
43
|
+
const fd = openSync(logPath, "r");
|
|
44
|
+
try {
|
|
45
|
+
let chunkSize = INITIAL_CHUNK_BYTES;
|
|
46
|
+
let line = null;
|
|
47
|
+
while (line === null) {
|
|
48
|
+
const buffer = Buffer.alloc(chunkSize);
|
|
49
|
+
const bytesRead = readSync(fd, buffer, 0, chunkSize, offset);
|
|
50
|
+
if (bytesRead === 0)
|
|
51
|
+
return null; // offset beyond EOF
|
|
52
|
+
const text = buffer.slice(0, bytesRead).toString("utf8");
|
|
53
|
+
const newlineIdx = text.indexOf("\n");
|
|
54
|
+
if (newlineIdx !== -1) {
|
|
55
|
+
// Found end of line within the chunk
|
|
56
|
+
line = text.slice(0, newlineIdx);
|
|
57
|
+
}
|
|
58
|
+
else if (bytesRead < chunkSize) {
|
|
59
|
+
// EOF reached before newline — the file ends without trailing newline
|
|
60
|
+
line = text;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// Line exceeds chunk size — double and retry
|
|
64
|
+
chunkSize *= 2;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (line.trim() === "")
|
|
68
|
+
return null;
|
|
69
|
+
return JSON.parse(line);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
closeSync(fd);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ─── Full log scan ────────────────────────────────────────────────────────────
|
|
79
|
+
/**
|
|
80
|
+
* Read and parse all valid envelopes from envelopes.log.
|
|
81
|
+
*
|
|
82
|
+
* Corrupt or unparseable lines are skipped silently.
|
|
83
|
+
* Returns envelopes in log order (chronological, oldest first).
|
|
84
|
+
*/
|
|
85
|
+
export function readAllEnvelopes(storeDir) {
|
|
86
|
+
const logPath = join(storeDir, LOG_FILENAME);
|
|
87
|
+
if (!existsSync(logPath))
|
|
88
|
+
return [];
|
|
89
|
+
const raw = readFileSync(logPath, "utf8");
|
|
90
|
+
const lines = raw.split("\n");
|
|
91
|
+
const results = [];
|
|
92
|
+
for (const line of lines) {
|
|
93
|
+
if (line.trim() === "")
|
|
94
|
+
continue;
|
|
95
|
+
try {
|
|
96
|
+
results.push(JSON.parse(line));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Corrupt line — skip
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return results;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=reader.js.map
|