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,682 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 9C: Workflow coordinator.
|
|
3
|
+
*
|
|
4
|
+
* ── Purpose ───────────────────────────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* Sequences CursorProductSession and ClaudeProductSession instances,
|
|
7
|
+
* one at a time, through a human-authored list of task specs.
|
|
8
|
+
*
|
|
9
|
+
* ── What this is NOT (W1) ─────────────────────────────────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* NOT authority — calls session functions; makes no decisions.
|
|
12
|
+
* NOT a planner — task specs are fixed at definition time; none are derived.
|
|
13
|
+
* NOT a retry engine — retry creates a new session; H re-approves every time.
|
|
14
|
+
* NOT a batch approver — each session requires explicit H approval (W2).
|
|
15
|
+
* NOT stateful — all functions return new WorkflowRun objects.
|
|
16
|
+
*
|
|
17
|
+
* ── Function contract ─────────────────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* createWorkflowRun(spec) → "reviewing"
|
|
20
|
+
* startWorkflow(run, ...) → "task_ready" | "task_conflict" | "completed"
|
|
21
|
+
* cancelWorkflow(run) → "stopped" (no session created)
|
|
22
|
+
* advanceWorkflow(run, ...) → "task_ready" | "task_conflict" | "completed"
|
|
23
|
+
* acceptWorkflowConflict(run) → "task_ready"
|
|
24
|
+
* confirmWorkflowTask(run, yes) → "task_approved" | "task_failed"
|
|
25
|
+
* deliverWorkflowTask(run, ...) → "running" | "task_scope" | "task_failed"
|
|
26
|
+
* answerWorkflowScope(run, idx, ...) → "task_approved" (→ call deliverWorkflowTask)
|
|
27
|
+
* applyFailureAction(run, action, ...) → "running" | "stopped"
|
|
28
|
+
*
|
|
29
|
+
* ── Shell loop ─────────────────────────────────────────────────────────────────
|
|
30
|
+
*
|
|
31
|
+
* run = createWorkflowRun(spec) // → "reviewing"
|
|
32
|
+
* // (H confirms pre-flight list)
|
|
33
|
+
* run = startWorkflow(run, ...) // → "task_ready" | "task_conflict"
|
|
34
|
+
* while (!isWorkflowTerminal(run)):
|
|
35
|
+
* if "task_conflict": run = acceptWorkflowConflict(run) // or reject
|
|
36
|
+
* if "task_ready": run = confirmWorkflowTask(run, yes)
|
|
37
|
+
* if "task_approved": run = await deliverWorkflowTask(run, ...)
|
|
38
|
+
* if "task_scope": run = await answerWorkflowScope(run, idx, ...)
|
|
39
|
+
* run = await deliverWorkflowTask(run, ...)
|
|
40
|
+
* if "task_failed": run = applyFailureAction(run, action)
|
|
41
|
+
* if "running": run = advanceWorkflow(run, ...)
|
|
42
|
+
*
|
|
43
|
+
* ── Authority invariants (W1–W8) ──────────────────────────────────────────────
|
|
44
|
+
*
|
|
45
|
+
* W2: confirmWorkflowTask(yes) → calls approve() only. deliverWorkflowTask
|
|
46
|
+
* is a separate explicit call. The coordinator never auto-delivers.
|
|
47
|
+
* W3: applyFailureAction("retry") creates a new session; never resumes.
|
|
48
|
+
* W6: applyOCDOverride() adds to prohibited globs; never removes.
|
|
49
|
+
* W7: task spec inputs are read-only; never modified after createWorkflowRun.
|
|
50
|
+
* W8: runtime is taken from task spec; never derived or converted.
|
|
51
|
+
*
|
|
52
|
+
* See: docs/phase-9b-workflow-design.md
|
|
53
|
+
*/
|
|
54
|
+
import { createHash } from "node:crypto";
|
|
55
|
+
// ─── Product session imports ──────────────────────────────────────────────────
|
|
56
|
+
import { createSession, submit, approve, reject, acceptConflict, answerScope, deliver, } from "../product/cursor-product-session.js";
|
|
57
|
+
import { createClaudeSession, submitClaude, approveClaude, rejectClaude, acceptClaudeConflict, answerClaudeScope, deliverClaude, } from "../product/claude-product-session.js";
|
|
58
|
+
import { parseChange } from "../understand/interpretation/parser.js";
|
|
59
|
+
import { isFsChange } from "../understand/interpretation/types.js";
|
|
60
|
+
import { createWorkflowRunEnvelope } from "../ucp/envelope.js";
|
|
61
|
+
import { persistEnvelope } from "../ucp/persistence/index.js";
|
|
62
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
63
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
64
|
+
function taskLabel(t) {
|
|
65
|
+
return t.spec.label ?? t.spec.input.slice(0, 60);
|
|
66
|
+
}
|
|
67
|
+
function runtimeFor(run, index) {
|
|
68
|
+
// W8: runtime comes from spec only. Never derived from content.
|
|
69
|
+
return run.spec.tasks[index]?.runtime ?? run.spec.defaultRuntime ?? "cursor";
|
|
70
|
+
}
|
|
71
|
+
function maxRetries(run) {
|
|
72
|
+
return run.spec.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
73
|
+
}
|
|
74
|
+
function applyOCDOverride(base, override) {
|
|
75
|
+
// W6: can only add prohibited globs, never remove.
|
|
76
|
+
if (!override || override.additionalProhibitedGlobs.length === 0)
|
|
77
|
+
return base;
|
|
78
|
+
return {
|
|
79
|
+
...base,
|
|
80
|
+
alwaysProhibitedGlobs: [
|
|
81
|
+
...base.alwaysProhibitedGlobs,
|
|
82
|
+
...override.additionalProhibitedGlobs,
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// ─── FS operation helpers ──────────────────────────────────────────────────────
|
|
87
|
+
/**
|
|
88
|
+
* Build an FsChange from a structured WorkflowTaskSpec (when operationType is set).
|
|
89
|
+
* Returns undefined if the spec fields are incomplete for the given operation.
|
|
90
|
+
*/
|
|
91
|
+
function buildFsChangeFromSpec(spec) {
|
|
92
|
+
switch (spec.operationType) {
|
|
93
|
+
case "create_dir": {
|
|
94
|
+
const p = spec.targetFiles?.[0];
|
|
95
|
+
return p ? { operationType: "create_dir", dirPath: p } : undefined;
|
|
96
|
+
}
|
|
97
|
+
case "write_file": {
|
|
98
|
+
const p = spec.targetFiles?.[0];
|
|
99
|
+
return p !== undefined && spec.content !== undefined
|
|
100
|
+
? { operationType: "write_file", filePath: p, content: spec.content }
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
case "rename": {
|
|
104
|
+
const p = spec.targetFiles?.[0];
|
|
105
|
+
return p !== undefined && spec.newPath !== undefined
|
|
106
|
+
? { operationType: "rename", filePath: p, newPath: spec.newPath }
|
|
107
|
+
: undefined;
|
|
108
|
+
}
|
|
109
|
+
case "delete_file": {
|
|
110
|
+
const p = spec.targetFiles?.[0];
|
|
111
|
+
return p ? { operationType: "delete_file", filePath: p } : undefined;
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function fsOpHeadline(op, taskNum) {
|
|
118
|
+
switch (op.operationType) {
|
|
119
|
+
case "create_dir": return `Task ${taskNum}: Create directory ${op.dirPath}`;
|
|
120
|
+
case "write_file": return `Task ${taskNum}: Create file ${op.filePath}`;
|
|
121
|
+
case "rename": return `Task ${taskNum}: Rename ${op.filePath} → ${op.newPath}`;
|
|
122
|
+
case "delete_file": return `Task ${taskNum}: Delete ${op.filePath}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function applyClaudeOCDOverride(base, override) {
|
|
126
|
+
// W6: can only add prohibited globs, never remove.
|
|
127
|
+
if (!override || override.additionalProhibitedGlobs.length === 0)
|
|
128
|
+
return base;
|
|
129
|
+
return {
|
|
130
|
+
...base,
|
|
131
|
+
alwaysProhibitedGlobs: [
|
|
132
|
+
...base.alwaysProhibitedGlobs,
|
|
133
|
+
...override.additionalProhibitedGlobs,
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function deriveWorkflowRunId(spec) {
|
|
138
|
+
const content = JSON.stringify({ name: spec.name, tasks: spec.tasks });
|
|
139
|
+
return createHash("sha256").update(content).digest("hex").slice(0, 16);
|
|
140
|
+
}
|
|
141
|
+
// ─── Display builders ─────────────────────────────────────────────────────────
|
|
142
|
+
function buildDisplay(run, headline, extras = {}) {
|
|
143
|
+
const total = run.spec.tasks.length;
|
|
144
|
+
const current = run.currentIndex + 1;
|
|
145
|
+
const progress = `Task ${Math.min(current, total)} of ${total}`;
|
|
146
|
+
const currentTask = run.spec.tasks[run.currentIndex];
|
|
147
|
+
const currentLabel = currentTask
|
|
148
|
+
? (currentTask.label ?? currentTask.input.slice(0, 60))
|
|
149
|
+
: undefined;
|
|
150
|
+
const taskSummary = run.tasks
|
|
151
|
+
.filter(t => t.outcome !== "pending")
|
|
152
|
+
.map(t => ({ index: t.index, label: taskLabel(t), outcome: t.outcome }));
|
|
153
|
+
return {
|
|
154
|
+
headline,
|
|
155
|
+
progress,
|
|
156
|
+
...(currentLabel !== undefined ? { currentLabel } : {}),
|
|
157
|
+
...(taskSummary.length > 0 ? { taskSummary } : {}),
|
|
158
|
+
...(extras.failureNote ? { failureNote: extras.failureNote } : {}),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// ─── Task array helpers ───────────────────────────────────────────────────────
|
|
162
|
+
function updateTask(tasks, index, updater) {
|
|
163
|
+
return tasks.map((t, i) => (i === index ? updater(t) : t));
|
|
164
|
+
}
|
|
165
|
+
function mk(phase, base, overrides) {
|
|
166
|
+
const merged = { ...base, phase, ...overrides };
|
|
167
|
+
// Filter undefined values when explicitly clearing currentSession or currentFsOp.
|
|
168
|
+
if ("currentSession" in overrides || "currentFsOp" in overrides) {
|
|
169
|
+
return Object.fromEntries(Object.entries(merged).filter(([, v]) => v !== undefined));
|
|
170
|
+
}
|
|
171
|
+
return merged;
|
|
172
|
+
}
|
|
173
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
174
|
+
/**
|
|
175
|
+
* Create a new WorkflowRun from a spec.
|
|
176
|
+
*
|
|
177
|
+
* The run begins in "reviewing" phase (Phase 11D / WF-R1).
|
|
178
|
+
* No session is created until H explicitly starts the workflow via startWorkflow().
|
|
179
|
+
*
|
|
180
|
+
* WF-R2: currentSession is absent in "reviewing".
|
|
181
|
+
*
|
|
182
|
+
* @param opts.mode "break_glass" to skip per-step human confirm (BG-1).
|
|
183
|
+
* @param opts.breakGlassReason Required when mode is "break_glass" (BG-4).
|
|
184
|
+
* Recorded in audit permanently (BG-3).
|
|
185
|
+
*/
|
|
186
|
+
export function createWorkflowRun(spec, opts) {
|
|
187
|
+
const tasks = spec.tasks.map((s, i) => ({
|
|
188
|
+
index: i,
|
|
189
|
+
spec: s,
|
|
190
|
+
outcome: "pending",
|
|
191
|
+
retryCount: 0,
|
|
192
|
+
}));
|
|
193
|
+
const display = buildDisplay({ spec, tasks, currentIndex: 0 }, `Workflow "${spec.name}" ready. ${spec.tasks.length} task(s).`);
|
|
194
|
+
const mode = opts?.mode ?? "normal";
|
|
195
|
+
const breakGlassReason = opts?.breakGlassReason;
|
|
196
|
+
return {
|
|
197
|
+
phase: "reviewing",
|
|
198
|
+
workflowRunId: deriveWorkflowRunId(spec),
|
|
199
|
+
spec,
|
|
200
|
+
tasks,
|
|
201
|
+
currentIndex: 0,
|
|
202
|
+
display,
|
|
203
|
+
...(mode !== "normal" ? { mode } : {}),
|
|
204
|
+
...(breakGlassReason ? { breakGlassReason } : {}),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
// ─── startWorkflow ────────────────────────────────────────────────────────────
|
|
208
|
+
/**
|
|
209
|
+
* Confirm the pre-flight review and start executing the first task.
|
|
210
|
+
*
|
|
211
|
+
* WF-R3: the only path out of "reviewing" into execution.
|
|
212
|
+
*
|
|
213
|
+
* Transitions "reviewing" → "idle" → immediately calls advanceWorkflow to
|
|
214
|
+
* prepare the first task. Returns the same result advanceWorkflow would:
|
|
215
|
+
* "task_ready" | "task_conflict" | "completed" (if all tasks auto-skip).
|
|
216
|
+
*
|
|
217
|
+
* Valid from "reviewing" only; no-op from any other phase.
|
|
218
|
+
*/
|
|
219
|
+
export function startWorkflow(run, cursorPolicy, claudeOCDPolicy, claudeToolPolicy) {
|
|
220
|
+
if (run.phase !== "reviewing")
|
|
221
|
+
return run;
|
|
222
|
+
// Transition to "idle" (internal phase) without touching tasks or sessions.
|
|
223
|
+
const idleRun = { ...run, phase: "idle" };
|
|
224
|
+
return advanceWorkflow(idleRun, cursorPolicy, claudeOCDPolicy, claudeToolPolicy);
|
|
225
|
+
}
|
|
226
|
+
// ─── cancelWorkflow ───────────────────────────────────────────────────────────
|
|
227
|
+
/**
|
|
228
|
+
* Cancel the workflow at the pre-flight stage.
|
|
229
|
+
*
|
|
230
|
+
* H declined to start. No session was ever created (WF-R1).
|
|
231
|
+
* Transitions "reviewing" → "stopped" cleanly.
|
|
232
|
+
*
|
|
233
|
+
* Valid from "reviewing" only; no-op from any other phase.
|
|
234
|
+
*/
|
|
235
|
+
export function cancelWorkflow(run) {
|
|
236
|
+
if (run.phase !== "reviewing")
|
|
237
|
+
return run;
|
|
238
|
+
const display = buildDisplay(run, `Workflow "${run.spec.name}" cancelled before start.`);
|
|
239
|
+
return mk("stopped", run, { currentSession: undefined, display });
|
|
240
|
+
}
|
|
241
|
+
// ─── Terminal guard ───────────────────────────────────────────────────────────
|
|
242
|
+
export function isWorkflowTerminal(run) {
|
|
243
|
+
return run.phase === "completed" || run.phase === "stopped";
|
|
244
|
+
}
|
|
245
|
+
// ─── advanceWorkflow ──────────────────────────────────────────────────────────
|
|
246
|
+
/**
|
|
247
|
+
* Advance the workflow to the next task.
|
|
248
|
+
*
|
|
249
|
+
* Called when phase is "idle" or "running".
|
|
250
|
+
*
|
|
251
|
+
* Creates a new session for the current task spec, submits the task input,
|
|
252
|
+
* and transitions to "task_ready", "task_conflict", or "completed".
|
|
253
|
+
*
|
|
254
|
+
* Auto-skips tasks where intake returns a non-execute mode ("skipped_by_intake").
|
|
255
|
+
* This is the V1 default policy for non-execute inputs (see Phase 9B design).
|
|
256
|
+
*
|
|
257
|
+
* @param cursorPolicy Workspace Cursor OCD policy (workflow override is applied internally).
|
|
258
|
+
* @param claudeOCDPolicy Workspace Claude OCD policy (workflow override is applied internally).
|
|
259
|
+
* @param claudeToolPolicy Claude tool policy.
|
|
260
|
+
*/
|
|
261
|
+
export function advanceWorkflow(run, cursorPolicy, claudeOCDPolicy, claudeToolPolicy) {
|
|
262
|
+
if (isWorkflowTerminal(run))
|
|
263
|
+
return run;
|
|
264
|
+
// "reviewing" is guarded here (WF-R3): only startWorkflow() may exit reviewing.
|
|
265
|
+
if (run.phase !== "idle" && run.phase !== "running")
|
|
266
|
+
return run;
|
|
267
|
+
// All tasks exhausted.
|
|
268
|
+
if (run.currentIndex >= run.spec.tasks.length) {
|
|
269
|
+
const display = buildDisplay(run, `Workflow "${run.spec.name}" completed.`);
|
|
270
|
+
return mk("completed", run, { display });
|
|
271
|
+
}
|
|
272
|
+
const idx = run.currentIndex;
|
|
273
|
+
const runtime = runtimeFor(run, idx);
|
|
274
|
+
const taskSpec = run.spec.tasks[idx];
|
|
275
|
+
// ── FS operation fast path (bypasses intake entirely) ────────────────────
|
|
276
|
+
//
|
|
277
|
+
// If the task spec declares an explicit operationType, or if NL parsing
|
|
278
|
+
// returns an FsChange, route to the FS op path. No session is created.
|
|
279
|
+
// These operations are always-executable deterministic primitives.
|
|
280
|
+
let detectedFsOp;
|
|
281
|
+
if (taskSpec.operationType && taskSpec.operationType !== "replace") {
|
|
282
|
+
detectedFsOp = buildFsChangeFromSpec(taskSpec);
|
|
283
|
+
}
|
|
284
|
+
if (!detectedFsOp) {
|
|
285
|
+
const parsed = parseChange(taskSpec.input);
|
|
286
|
+
if (parsed !== null && isFsChange(parsed)) {
|
|
287
|
+
detectedFsOp = parsed;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (detectedFsOp !== undefined) {
|
|
291
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t }));
|
|
292
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: idx }, fsOpHeadline(detectedFsOp, idx + 1));
|
|
293
|
+
return mk("task_ready", run, { currentFsOp: detectedFsOp, tasks: updatedTasks, display });
|
|
294
|
+
}
|
|
295
|
+
// ── Submit the task to its session ───────────────────────────────────────
|
|
296
|
+
let currentSession;
|
|
297
|
+
if (runtime === "cursor") {
|
|
298
|
+
// W8: runtime comes from spec. W6: override can only tighten.
|
|
299
|
+
const policy = applyOCDOverride(cursorPolicy, run.spec.ocdOverride);
|
|
300
|
+
const session = submit(createSession(), taskSpec.input, policy);
|
|
301
|
+
currentSession = { runtime: "cursor", state: session };
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const ocdPolicy = applyClaudeOCDOverride(claudeOCDPolicy, run.spec.ocdOverride);
|
|
305
|
+
const session = submitClaude(createClaudeSession(), taskSpec.input, ocdPolicy, claudeToolPolicy);
|
|
306
|
+
currentSession = { runtime: "claude", state: session };
|
|
307
|
+
}
|
|
308
|
+
const sessionPhase = currentSession.state.phase;
|
|
309
|
+
// ── Surface non-execute modes explicitly (no silent skips) ───────────────
|
|
310
|
+
// V1 default: intake_failed and not_execute are auto-skipped.
|
|
311
|
+
// The display message and task record preserve the reason for the UI.
|
|
312
|
+
if (sessionPhase === "not_execute" || sessionPhase === "intake_failed") {
|
|
313
|
+
const display_msg = sessionPhase === "intake_failed"
|
|
314
|
+
? `Task ${idx + 1}: Input could not be processed.`
|
|
315
|
+
: `Task ${idx + 1}: Input is not a supported operation.`;
|
|
316
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({
|
|
317
|
+
...t,
|
|
318
|
+
outcome: "skipped_by_intake",
|
|
319
|
+
...(currentSession.state.intentId !== undefined ? { intentId: currentSession.state.intentId } : {}),
|
|
320
|
+
...(currentSession.state.responseId !== undefined ? { responseId: currentSession.state.responseId } : {}),
|
|
321
|
+
}));
|
|
322
|
+
const nextIndex = idx + 1;
|
|
323
|
+
const next = {
|
|
324
|
+
...run,
|
|
325
|
+
tasks: updatedTasks,
|
|
326
|
+
currentIndex: nextIndex,
|
|
327
|
+
phase: "running",
|
|
328
|
+
display: buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: nextIndex }, display_msg),
|
|
329
|
+
};
|
|
330
|
+
// Recurse to advance to the next task.
|
|
331
|
+
return advanceWorkflow(next, cursorPolicy, claudeOCDPolicy, claudeToolPolicy);
|
|
332
|
+
}
|
|
333
|
+
// ── Surface prepared / conflict ───────────────────────────────────────────
|
|
334
|
+
const nextPhase = sessionPhase === "conflict" ? "task_conflict" : "task_ready";
|
|
335
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({
|
|
336
|
+
...t,
|
|
337
|
+
...(currentSession.state.intentId !== undefined ? { intentId: currentSession.state.intentId } : {}),
|
|
338
|
+
...(currentSession.state.responseId !== undefined ? { responseId: currentSession.state.responseId } : {}),
|
|
339
|
+
}));
|
|
340
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: idx }, sessionPhase === "conflict"
|
|
341
|
+
? `Task ${idx + 1}: OCD conflict detected.`
|
|
342
|
+
: (taskSpec.label ?? taskSpec.input.slice(0, 60)));
|
|
343
|
+
return mk(nextPhase, run, { tasks: updatedTasks, currentSession, display });
|
|
344
|
+
}
|
|
345
|
+
// ─── acceptWorkflowConflict ───────────────────────────────────────────────────
|
|
346
|
+
/**
|
|
347
|
+
* Accept the OCD conflict on the current task.
|
|
348
|
+
*
|
|
349
|
+
* Valid from "task_conflict" only.
|
|
350
|
+
* Transitions to "task_ready".
|
|
351
|
+
*/
|
|
352
|
+
export function acceptWorkflowConflict(run) {
|
|
353
|
+
if (isWorkflowTerminal(run))
|
|
354
|
+
return run;
|
|
355
|
+
if (run.phase !== "task_conflict" || !run.currentSession)
|
|
356
|
+
return run;
|
|
357
|
+
let nextSession;
|
|
358
|
+
if (run.currentSession.runtime === "cursor") {
|
|
359
|
+
nextSession = { runtime: "cursor", state: acceptConflict(run.currentSession.state) };
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
nextSession = { runtime: "claude", state: acceptClaudeConflict(run.currentSession.state) };
|
|
363
|
+
}
|
|
364
|
+
const idx = run.currentIndex;
|
|
365
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Conflict accepted. Ready for approval.`);
|
|
366
|
+
return mk("task_ready", run, { currentSession: nextSession, display });
|
|
367
|
+
}
|
|
368
|
+
// ─── confirmWorkflowTask ──────────────────────────────────────────────────────
|
|
369
|
+
/**
|
|
370
|
+
* Confirm (approve) or reject the current prepared task.
|
|
371
|
+
*
|
|
372
|
+
* Valid from "task_ready" and "task_conflict" (rejection path).
|
|
373
|
+
*
|
|
374
|
+
* yes=true → calls approve() / approveClaude() → "task_approved"
|
|
375
|
+
* yes=false → calls reject() / rejectClaude() → "task_failed" (outcome: "rejected")
|
|
376
|
+
*
|
|
377
|
+
* ── Proof W2 (never approves on behalf of H) ────────────────────────────────
|
|
378
|
+
*
|
|
379
|
+
* This function calls approve() exactly once when yes=true.
|
|
380
|
+
* It does NOT call deliver() or deliverClaude().
|
|
381
|
+
* The session transitions to "approved", not "accepted".
|
|
382
|
+
* deliverWorkflowTask() is the separate, explicit delivery step.
|
|
383
|
+
*/
|
|
384
|
+
export function confirmWorkflowTask(run, yes) {
|
|
385
|
+
if (isWorkflowTerminal(run))
|
|
386
|
+
return run;
|
|
387
|
+
if (run.phase !== "task_ready" && run.phase !== "task_conflict")
|
|
388
|
+
return run;
|
|
389
|
+
const idx = run.currentIndex;
|
|
390
|
+
// ── FS operation path (no session needed) ────────────────────────────────
|
|
391
|
+
if (run.currentFsOp) {
|
|
392
|
+
if (!yes) {
|
|
393
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t, outcome: "rejected" }));
|
|
394
|
+
const display = buildDisplay({ ...run, tasks: updatedTasks }, `Task ${idx + 1}: Rejected by H.`, { failureNote: "Task was rejected." });
|
|
395
|
+
return mk("task_failed", run, { currentFsOp: undefined, tasks: updatedTasks, display });
|
|
396
|
+
}
|
|
397
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Approved. Executing operation.`);
|
|
398
|
+
return mk("task_approved", run, { display });
|
|
399
|
+
}
|
|
400
|
+
// ── Session path ──────────────────────────────────────────────────────────
|
|
401
|
+
if (!run.currentSession)
|
|
402
|
+
return run;
|
|
403
|
+
if (!yes) {
|
|
404
|
+
// H rejected. Transition to task_failed with rejected outcome.
|
|
405
|
+
let nextSession;
|
|
406
|
+
if (run.currentSession.runtime === "cursor") {
|
|
407
|
+
nextSession = { runtime: "cursor", state: reject(run.currentSession.state) };
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
nextSession = { runtime: "claude", state: rejectClaude(run.currentSession.state) };
|
|
411
|
+
}
|
|
412
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t, outcome: "rejected" }));
|
|
413
|
+
const display = buildDisplay({ ...run, tasks: updatedTasks }, `Task ${idx + 1}: Rejected by H.`, { failureNote: "Task was rejected." });
|
|
414
|
+
return mk("task_failed", run, { currentSession: nextSession, tasks: updatedTasks, display });
|
|
415
|
+
}
|
|
416
|
+
// H approved. Call approve() only — NO delivery. (W2 proof point)
|
|
417
|
+
let nextSession;
|
|
418
|
+
if (run.currentSession.runtime === "cursor") {
|
|
419
|
+
nextSession = { runtime: "cursor", state: approve(run.currentSession.state) };
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
nextSession = { runtime: "claude", state: approveClaude(run.currentSession.state) };
|
|
423
|
+
}
|
|
424
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Approved. Ready to deliver.`);
|
|
425
|
+
return mk("task_approved", run, { currentSession: nextSession, display });
|
|
426
|
+
}
|
|
427
|
+
// ─── deliverWorkflowTask ──────────────────────────────────────────────────────
|
|
428
|
+
/**
|
|
429
|
+
* Deliver the current approved task to its runtime.
|
|
430
|
+
*
|
|
431
|
+
* Valid from "task_approved" only.
|
|
432
|
+
*
|
|
433
|
+
* Outcome:
|
|
434
|
+
* accepted → record outcome, increment currentIndex → "running"
|
|
435
|
+
* scope_question → "task_scope"
|
|
436
|
+
* exec_error / blocked → "task_failed"
|
|
437
|
+
*
|
|
438
|
+
* @param plugins WorkflowPlugins — coordinator picks the right one by runtime (W8 / Proof 3).
|
|
439
|
+
* @param storeDir UCP store directory.
|
|
440
|
+
* @param deps Optional gate dependencies (for test injection, Claude only).
|
|
441
|
+
*/
|
|
442
|
+
export async function deliverWorkflowTask(run, plugins, storeDir, deps) {
|
|
443
|
+
if (isWorkflowTerminal(run))
|
|
444
|
+
return run;
|
|
445
|
+
if (run.phase !== "task_approved")
|
|
446
|
+
return run;
|
|
447
|
+
const idx = run.currentIndex;
|
|
448
|
+
// ── FS operation delivery path ────────────────────────────────────────────
|
|
449
|
+
if (run.currentFsOp) {
|
|
450
|
+
if (!plugins.fs) {
|
|
451
|
+
return transitionToFailed(run, idx, "No filesystem plugin configured for this server.");
|
|
452
|
+
}
|
|
453
|
+
const result = await plugins.fs.executeFsOp(run.currentFsOp);
|
|
454
|
+
if (result.kind === "accepted") {
|
|
455
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({
|
|
456
|
+
...t, outcome: "accepted",
|
|
457
|
+
}));
|
|
458
|
+
const nextIndex = idx + 1;
|
|
459
|
+
const isDone = nextIndex >= run.spec.tasks.length;
|
|
460
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: nextIndex }, isDone
|
|
461
|
+
? `Workflow "${run.spec.name}" completed.`
|
|
462
|
+
: `Task ${idx + 1}: Done. Advancing to task ${nextIndex + 1}.`);
|
|
463
|
+
return mk(isDone ? "completed" : "running", run, { tasks: updatedTasks, currentIndex: nextIndex, currentFsOp: undefined, currentSession: undefined, display });
|
|
464
|
+
}
|
|
465
|
+
return transitionToFailed(run, idx, result.detail ?? "Filesystem operation failed.");
|
|
466
|
+
}
|
|
467
|
+
// ── Session delivery path (existing) ─────────────────────────────────────
|
|
468
|
+
if (!run.currentSession)
|
|
469
|
+
return run;
|
|
470
|
+
// ── Deliver via the correct plugin (W8 / Proof 3) ────────────────────────
|
|
471
|
+
let nextSession;
|
|
472
|
+
if (run.currentSession.runtime === "cursor") {
|
|
473
|
+
const plugin = plugins.cursor;
|
|
474
|
+
if (!plugin) {
|
|
475
|
+
// No cursor plugin provided — block.
|
|
476
|
+
return transitionToFailed(run, idx, "No cursor plugin provided for this task.");
|
|
477
|
+
}
|
|
478
|
+
const delivered = await deliver(run.currentSession.state, plugin, storeDir);
|
|
479
|
+
nextSession = { runtime: "cursor", state: delivered };
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
const plugin = plugins.claude;
|
|
483
|
+
if (!plugin) {
|
|
484
|
+
return transitionToFailed(run, idx, "No claude plugin provided for this task.");
|
|
485
|
+
}
|
|
486
|
+
const delivered = await deliverClaude(run.currentSession.state, plugin, storeDir, deps);
|
|
487
|
+
nextSession = { runtime: "claude", state: delivered };
|
|
488
|
+
}
|
|
489
|
+
const deliveredPhase = nextSession.state.phase;
|
|
490
|
+
// ── Map delivery outcome ──────────────────────────────────────────────────
|
|
491
|
+
if (deliveredPhase === "accepted") {
|
|
492
|
+
// Record outcome and advance to next task.
|
|
493
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t, outcome: "accepted" }));
|
|
494
|
+
const nextIndex = idx + 1;
|
|
495
|
+
const isDone = nextIndex >= run.spec.tasks.length;
|
|
496
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: nextIndex }, isDone
|
|
497
|
+
? `Workflow "${run.spec.name}" completed.`
|
|
498
|
+
: `Task ${idx + 1}: Accepted. Advancing to task ${nextIndex + 1}.`);
|
|
499
|
+
return mk(isDone ? "completed" : "running", run, { tasks: updatedTasks, currentIndex: nextIndex, currentSession: undefined, display });
|
|
500
|
+
}
|
|
501
|
+
if (deliveredPhase === "scope_question") {
|
|
502
|
+
// F9 / WF-S3: if taskSpec carries explicit targetFiles, auto-resolve scope.
|
|
503
|
+
const taskSpec = run.spec.tasks[idx];
|
|
504
|
+
if (taskSpec.targetFiles && taskSpec.targetFiles.length > 0) {
|
|
505
|
+
const candidates = nextSession.runtime === "cursor"
|
|
506
|
+
? (nextSession.state.scopeQuestion?.candidates ?? [])
|
|
507
|
+
: (nextSession.state.scopeQuestion?.candidates ?? []);
|
|
508
|
+
const match = taskSpec.targetFiles.find(tf => candidates.includes(tf));
|
|
509
|
+
if (!match) {
|
|
510
|
+
// WF-S1: explicit scope provided but no candidate matches — contradiction.
|
|
511
|
+
return transitionToFailed(run, idx, `Scope contradiction: targetFiles [${taskSpec.targetFiles.join(", ")}] ` +
|
|
512
|
+
`did not match any delivery candidates [${candidates.join(", ")}]. ` +
|
|
513
|
+
`Verify that task input and targetFiles refer to the same file.`);
|
|
514
|
+
}
|
|
515
|
+
// Auto-answer scope without prompting H (WF-S3).
|
|
516
|
+
let answeredSession;
|
|
517
|
+
if (nextSession.runtime === "cursor") {
|
|
518
|
+
answeredSession = { runtime: "cursor", state: answerScope(nextSession.state, match) };
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
answeredSession = { runtime: "claude", state: answerClaudeScope(nextSession.state, match) };
|
|
522
|
+
}
|
|
523
|
+
const autoDisplay = buildDisplay(run, `Task ${idx + 1}: Scope auto-resolved to ${match}.`);
|
|
524
|
+
const autoApprovedRun = mk("task_approved", run, {
|
|
525
|
+
currentSession: answeredSession,
|
|
526
|
+
display: autoDisplay,
|
|
527
|
+
});
|
|
528
|
+
// Re-deliver with the auto-approved, scope-narrowed session.
|
|
529
|
+
return deliverWorkflowTask(autoApprovedRun, plugins, storeDir, deps);
|
|
530
|
+
}
|
|
531
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Scope clarification needed.`);
|
|
532
|
+
return mk("task_scope", run, { currentSession: nextSession, display });
|
|
533
|
+
}
|
|
534
|
+
// exec_error, blocked — surface as task_failed.
|
|
535
|
+
const note = nextSession.state.display.resultNote ?? "Execution failed.";
|
|
536
|
+
return transitionToFailed(run, idx, note, nextSession);
|
|
537
|
+
}
|
|
538
|
+
// ─── answerWorkflowScope ──────────────────────────────────────────────────────
|
|
539
|
+
/**
|
|
540
|
+
* Answer a scope clarification question for the current task.
|
|
541
|
+
*
|
|
542
|
+
* Valid from "task_scope" only.
|
|
543
|
+
* Transitions to "task_approved" so the caller can call deliverWorkflowTask again.
|
|
544
|
+
*
|
|
545
|
+
* @param choiceIdx 1-based index into the scope candidates.
|
|
546
|
+
* Out-of-range → returns state unchanged.
|
|
547
|
+
*/
|
|
548
|
+
export function answerWorkflowScope(run, choiceIdx) {
|
|
549
|
+
if (isWorkflowTerminal(run))
|
|
550
|
+
return run;
|
|
551
|
+
if (run.phase !== "task_scope" || !run.currentSession)
|
|
552
|
+
return run;
|
|
553
|
+
const candidates = run.currentSession.runtime === "cursor"
|
|
554
|
+
? (run.currentSession.state.scopeQuestion?.candidates ?? [])
|
|
555
|
+
: (run.currentSession.state.scopeQuestion?.candidates ?? []);
|
|
556
|
+
const file = candidates[choiceIdx - 1];
|
|
557
|
+
if (!file)
|
|
558
|
+
return run; // Out of range — re-prompt.
|
|
559
|
+
let nextSession;
|
|
560
|
+
if (run.currentSession.runtime === "cursor") {
|
|
561
|
+
nextSession = { runtime: "cursor", state: answerScope(run.currentSession.state, file) };
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
nextSession = { runtime: "claude", state: answerClaudeScope(run.currentSession.state, file) };
|
|
565
|
+
}
|
|
566
|
+
const idx = run.currentIndex;
|
|
567
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Scope answered. Re-approving.`);
|
|
568
|
+
return mk("task_approved", run, { currentSession: nextSession, display });
|
|
569
|
+
}
|
|
570
|
+
// ─── applyFailureAction ───────────────────────────────────────────────────────
|
|
571
|
+
/**
|
|
572
|
+
* Apply a failure action to the current failed task.
|
|
573
|
+
*
|
|
574
|
+
* Valid from "task_failed" only.
|
|
575
|
+
*
|
|
576
|
+
* Actions:
|
|
577
|
+
* stop → "stopped" (terminal)
|
|
578
|
+
* skip → record as "skipped", advance currentIndex → "running"
|
|
579
|
+
* retry → if retryCount < maxRetries: increment retryCount, reset session → "running"
|
|
580
|
+
* if retryCount >= maxRetries: returns state unchanged (stop/skip only)
|
|
581
|
+
*
|
|
582
|
+
* W3: retry creates a new session via advanceWorkflow; no session is re-opened.
|
|
583
|
+
*
|
|
584
|
+
* @returns Next WorkflowRun. Caller must call advanceWorkflow() after "running".
|
|
585
|
+
*/
|
|
586
|
+
export function applyFailureAction(run, action) {
|
|
587
|
+
if (isWorkflowTerminal(run))
|
|
588
|
+
return run;
|
|
589
|
+
if (run.phase !== "task_failed")
|
|
590
|
+
return run;
|
|
591
|
+
const idx = run.currentIndex;
|
|
592
|
+
if (action === "stop") {
|
|
593
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t, outcome: "stopped" }));
|
|
594
|
+
const display = buildDisplay({ ...run, tasks: updatedTasks }, `Workflow "${run.spec.name}" stopped at task ${idx + 1}.`);
|
|
595
|
+
return mk("stopped", run, { tasks: updatedTasks, currentSession: undefined, display });
|
|
596
|
+
}
|
|
597
|
+
if (action === "skip") {
|
|
598
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({ ...t, outcome: "skipped" }));
|
|
599
|
+
const nextIndex = idx + 1;
|
|
600
|
+
const isDone = nextIndex >= run.spec.tasks.length;
|
|
601
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: nextIndex }, isDone
|
|
602
|
+
? `Workflow "${run.spec.name}" completed (task ${idx + 1} skipped).`
|
|
603
|
+
: `Task ${idx + 1} skipped. Advancing to task ${nextIndex + 1}.`);
|
|
604
|
+
return mk(isDone ? "completed" : "running", run, { tasks: updatedTasks, currentIndex: nextIndex, currentSession: undefined, display });
|
|
605
|
+
}
|
|
606
|
+
// retry
|
|
607
|
+
const currentTask = run.tasks[idx];
|
|
608
|
+
if (!currentTask)
|
|
609
|
+
return run;
|
|
610
|
+
if (currentTask.retryCount >= maxRetries(run)) {
|
|
611
|
+
// Max retries exceeded — only stop/skip are valid. Return unchanged.
|
|
612
|
+
return run;
|
|
613
|
+
}
|
|
614
|
+
const updatedTasks = updateTask(run.tasks, idx, t => ({
|
|
615
|
+
...t,
|
|
616
|
+
retryCount: t.retryCount + 1,
|
|
617
|
+
outcome: "pending",
|
|
618
|
+
// Clear provenance IDs — new session will set new ones.
|
|
619
|
+
}));
|
|
620
|
+
const display = buildDisplay({ spec: run.spec, tasks: updatedTasks, currentIndex: idx }, `Task ${idx + 1}: Retrying (attempt ${currentTask.retryCount + 2}).`);
|
|
621
|
+
// W3: session is cleared. advanceWorkflow will create a new one.
|
|
622
|
+
return mk("running", run, { tasks: updatedTasks, currentSession: undefined, display });
|
|
623
|
+
}
|
|
624
|
+
// ─── UCP workflow run provenance ──────────────────────────────────────────────
|
|
625
|
+
/**
|
|
626
|
+
* buildWorkflowRunPayload — produce the UCP payload for ucp.workflow_run.v1.
|
|
627
|
+
*
|
|
628
|
+
* Called when the workflow reaches "completed" or "stopped" (W5).
|
|
629
|
+
* Not called for in-progress runs.
|
|
630
|
+
*
|
|
631
|
+
* @throws {Error} If run is not in a terminal phase.
|
|
632
|
+
*/
|
|
633
|
+
export function buildWorkflowRunPayload(run) {
|
|
634
|
+
if (run.phase !== "completed" && run.phase !== "stopped") {
|
|
635
|
+
throw new Error(`buildWorkflowRunPayload: run must be terminal, got "${run.phase}"`);
|
|
636
|
+
}
|
|
637
|
+
const finalOutcome = run.phase === "completed" ? "completed" : "stopped";
|
|
638
|
+
const acceptedCount = run.tasks.filter(t => t.outcome === "accepted").length;
|
|
639
|
+
const skippedCount = run.tasks.filter(t => t.outcome === "skipped" || t.outcome === "skipped_by_intake").length;
|
|
640
|
+
const sessionRefs = run.tasks
|
|
641
|
+
.filter(t => t.outcome !== "pending")
|
|
642
|
+
.map(t => ({
|
|
643
|
+
taskIndex: t.index,
|
|
644
|
+
outcome: t.outcome,
|
|
645
|
+
retryCount: t.retryCount,
|
|
646
|
+
...(t.intentId ? { intentId: t.intentId } : {}),
|
|
647
|
+
...(t.responseId ? { responseId: t.responseId } : {}),
|
|
648
|
+
}));
|
|
649
|
+
return {
|
|
650
|
+
workflowRunId: run.workflowRunId,
|
|
651
|
+
workflowName: run.spec.name,
|
|
652
|
+
finalOutcome,
|
|
653
|
+
taskCount: run.spec.tasks.length,
|
|
654
|
+
acceptedCount,
|
|
655
|
+
skippedCount,
|
|
656
|
+
taskInputs: run.spec.tasks.map(t => t.input),
|
|
657
|
+
sessionRefs,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* persistWorkflowRun — build a ucp.workflow_run.v1 envelope and persist it.
|
|
662
|
+
*
|
|
663
|
+
* This is fire-and-forget (uses persistEnvelope, not persistEnvelopeOrThrow).
|
|
664
|
+
* A persistence failure must NOT block the shell from rendering a terminal
|
|
665
|
+
* state to the user. The UCP record is an audit artifact, not a gate.
|
|
666
|
+
*
|
|
667
|
+
* @throws {Error} If run is not terminal. Call only after isWorkflowTerminal(run).
|
|
668
|
+
*/
|
|
669
|
+
export function persistWorkflowRun(run, storeDir) {
|
|
670
|
+
const payload = buildWorkflowRunPayload(run);
|
|
671
|
+
const envelope = createWorkflowRunEnvelope(payload);
|
|
672
|
+
persistEnvelope(storeDir, envelope);
|
|
673
|
+
}
|
|
674
|
+
// ─── Internal helpers ─────────────────────────────────────────────────────────
|
|
675
|
+
function transitionToFailed(run, idx, failureNote, nextSession) {
|
|
676
|
+
const display = buildDisplay(run, `Task ${idx + 1}: Failed.`, { failureNote });
|
|
677
|
+
return mk("task_failed", run, {
|
|
678
|
+
...(nextSession !== undefined ? { currentSession: nextSession } : {}),
|
|
679
|
+
display,
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
//# sourceMappingURL=coordinator.js.map
|