@caupulican/pi-adaptative 0.81.39 → 0.81.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +19 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +67 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +397 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +71 -136
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +477 -1318
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +20 -12
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +46 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +54 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +140 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +12 -11
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +9 -4
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +50 -15
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +6 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +70 -21
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +52 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +25 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +93 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +10 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +6 -6
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +20 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +17 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +1 -0
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +7 -10
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +8 -6
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +11 -41
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +2 -4
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +10 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -0
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +6 -9
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +4 -4
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +197 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +4 -4
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +2 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +225 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +26 -20
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +237 -178
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +61 -24
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +28 -1
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +6 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +10 -4
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/settings-manager.d.ts +9 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +80 -28
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +85 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-protocol-controller.d.ts +91 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +149 -29
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +108 -23
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/goal.d.ts +5 -5
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +10 -10
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +43 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +168 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +102 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +128 -44
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +76 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +63 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +50 -17
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +59 -26
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +7 -0
- package/docs/ui-reference/orchestration-before.txt +7 -0
- package/docs/ui-reference/orchestration-reference.txt +6 -0
- package/docs/usage.md +14 -2
- package/docs/work-directory.md +19 -8
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAEN,4BAA4B,EAG5B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,8BAA8B;IAC9C,KAAK,EAAE,yBAAyB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,EAAE,4BAA4B,CAAC;IACvC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,WAAW,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACvD;AAaD,qBAAa,yBAAyB;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IAEzC,YAAY,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,EAI9E;IAED,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAIlD;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAOpE;IAED,IAAI,IAAI,8BAA8B,CA0DrC;IAED,IAAI,CACH,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,yBAAyB,EAChC,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GACnC,MAAM,CAiBR;IAED,OAAO,CAAC,SAAS;CAgCjB","sourcesContent":["import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { resourceDir } from \"../agent-paths.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport type { OrchestrationProfile } from \"./contracts.ts\";\nimport {\n\tOrchestrationProfileError,\n\tOrchestrationProfileRegistry,\n\tparseOrchestrationProfile,\n\tvalidateOrchestrationProfile,\n} from \"./profile-registry.ts\";\n\nexport type OrchestrationProfileScope = \"global\" | \"project\";\n\nexport interface OrchestrationProfileDiagnostic {\n\tscope: OrchestrationProfileScope;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface OrchestrationProfileLoadResult {\n\tregistry: OrchestrationProfileRegistry;\n\tprofiles: readonly OrchestrationProfile[];\n\tdiagnostics: readonly OrchestrationProfileDiagnostic[];\n}\n\nconst PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n\nfunction authoredProfile(profile: OrchestrationProfile): Omit<OrchestrationProfile, \"sourcePath\"> {\n\tconst { sourcePath: _sourcePath, ...authored } = profile;\n\treturn authored;\n}\n\nfunction messageFrom(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nexport class OrchestrationProfileStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly cwd: string;\n\tprivate readonly projectTrusted: boolean;\n\n\tconstructor(options: { agentDir: string; cwd: string; projectTrusted: boolean }) {\n\t\tthis.agentDir = resolve(options.agentDir);\n\t\tthis.cwd = resolve(options.cwd);\n\t\tthis.projectTrusted = options.projectTrusted;\n\t}\n\n\tdirectory(scope: OrchestrationProfileScope): string {\n\t\treturn scope === \"global\"\n\t\t\t? join(resourceDir(\"profiles\", this.agentDir), \"orchestration\")\n\t\t\t: join(this.cwd, CONFIG_DIR_NAME, \"profiles\", \"orchestration\");\n\t}\n\n\tfilePath(profileId: string, scope: OrchestrationProfileScope): string {\n\t\tif (!PROFILE_ID_PATTERN.test(profileId)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.\",\n\t\t\t);\n\t\t}\n\t\treturn join(this.directory(scope), `${profileId}.json`);\n\t}\n\n\tload(): OrchestrationProfileLoadResult {\n\t\tconst diagnostics: OrchestrationProfileDiagnostic[] = [];\n\t\tconst globalProfiles = this.loadScope(\"global\", diagnostics);\n\t\tconst projectProfiles = this.projectTrusted ? this.loadScope(\"project\", diagnostics) : [];\n\t\tif (!this.projectTrusted && existsSync(this.directory(\"project\"))) {\n\t\t\tdiagnostics.push({\n\t\t\t\tscope: \"project\",\n\t\t\t\tpath: this.directory(\"project\"),\n\t\t\t\tmessage: \"Project orchestration profiles were not loaded because the project is untrusted.\",\n\t\t\t});\n\t\t}\n\t\tconst profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const profile of projectProfiles) profilesById.set(profile.profileId, profile);\n\t\tlet profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));\n\t\tlet removed = true;\n\t\twhile (removed) {\n\t\t\tremoved = false;\n\t\t\tconst available = new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t\t\tprofiles = profiles.filter((profile) => {\n\t\t\t\tconst invalidTarget = profile.dispatchProfileIds.find((profileId) => {\n\t\t\t\t\tconst target = available.get(profileId);\n\t\t\t\t\treturn !target || target.role === \"orchestrator\";\n\t\t\t\t});\n\t\t\t\tconst verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;\n\t\t\t\tconst invalidVerifier =\n\t\t\t\t\tprofile.verificationProfileId && verifier?.role !== \"verifier\"\n\t\t\t\t\t\t? profile.verificationProfileId\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst unauthorizedVerifier =\n\t\t\t\t\tprofile.role === \"orchestrator\"\n\t\t\t\t\t\t? profile.dispatchProfileIds\n\t\t\t\t\t\t\t\t.map((profileId) => available.get(profileId))\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(target) =>\n\t\t\t\t\t\t\t\t\t\ttarget?.verificationProfileId &&\n\t\t\t\t\t\t\t\t\t\t!profile.dispatchProfileIds.includes(target.verificationProfileId),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (!invalidTarget && !invalidVerifier && !unauthorizedVerifier) return true;\n\t\t\t\tremoved = true;\n\t\t\t\tconst message = invalidTarget\n\t\t\t\t\t? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`\n\t\t\t\t\t: invalidVerifier\n\t\t\t\t\t\t? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`\n\t\t\t\t\t\t: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tscope: profile.sourcePath?.startsWith(this.directory(\"project\")) ? \"project\" : \"global\",\n\t\t\t\t\tpath: profile.sourcePath ?? profile.profileId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tregistry: new OrchestrationProfileRegistry(profiles),\n\t\t\tprofiles,\n\t\t\tdiagnostics,\n\t\t};\n\t}\n\n\tsave(\n\t\tprofile: OrchestrationProfile,\n\t\tscope: OrchestrationProfileScope,\n\t\toptions: { overwrite?: boolean } = {},\n\t): string {\n\t\tif (scope === \"project\" && !this.projectTrusted) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Project is not trusted; refusing to write project orchestration profiles.\",\n\t\t\t);\n\t\t}\n\t\tvalidateOrchestrationProfile(profile);\n\t\tconst filePath = this.filePath(profile.profileId, scope);\n\t\twithFileLockSync(filePath, () => {\n\t\t\tif (!options.overwrite && existsSync(filePath)) {\n\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\twriteFileAtomicSync(filePath, `${JSON.stringify(authoredProfile(profile), null, 2)}\\n`);\n\t\t});\n\t\treturn filePath;\n\t}\n\n\tprivate loadScope(\n\t\tscope: OrchestrationProfileScope,\n\t\tdiagnostics: OrchestrationProfileDiagnostic[],\n\t): OrchestrationProfile[] {\n\t\tconst directory = this.directory(scope);\n\t\tif (!existsSync(directory)) return [];\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readdirSync(directory)\n\t\t\t\t.filter((entry) => entry.endsWith(\".json\"))\n\t\t\t\t.sort((left, right) => left.localeCompare(right));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({ scope, path: directory, message: messageFrom(error) });\n\t\t\treturn [];\n\t\t}\n\t\tconst profilesById = new Map<string, OrchestrationProfile>();\n\t\tfor (const entry of entries) {\n\t\t\tconst sourcePath = join(directory, entry);\n\t\t\ttry {\n\t\t\t\tconst profile = parseOrchestrationProfile(JSON.parse(readFileSync(sourcePath, \"utf-8\")), sourcePath);\n\t\t\t\tif (profilesById.has(profile.profileId)) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprofilesById.set(profile.profileId, profile);\n\t\t\t} catch (error) {\n\t\t\t\tdiagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });\n\t\t\t}\n\t\t}\n\t\treturn [...profilesById.values()];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { CONFIG_DIR_NAME } from "../../config.js";
|
|
4
|
+
import { resourceDir } from "../agent-paths.js";
|
|
5
|
+
import { withFileLockSync, writeFileAtomicSync } from "../util/atomic-file.js";
|
|
6
|
+
import { OrchestrationProfileError, OrchestrationProfileRegistry, parseOrchestrationProfile, validateOrchestrationProfile, } from "./profile-registry.js";
|
|
7
|
+
const PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
8
|
+
function authoredProfile(profile) {
|
|
9
|
+
const { sourcePath: _sourcePath, ...authored } = profile;
|
|
10
|
+
return authored;
|
|
11
|
+
}
|
|
12
|
+
function messageFrom(error) {
|
|
13
|
+
return error instanceof Error ? error.message : String(error);
|
|
14
|
+
}
|
|
15
|
+
export class OrchestrationProfileStore {
|
|
16
|
+
agentDir;
|
|
17
|
+
cwd;
|
|
18
|
+
projectTrusted;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.agentDir = resolve(options.agentDir);
|
|
21
|
+
this.cwd = resolve(options.cwd);
|
|
22
|
+
this.projectTrusted = options.projectTrusted;
|
|
23
|
+
}
|
|
24
|
+
directory(scope) {
|
|
25
|
+
return scope === "global"
|
|
26
|
+
? join(resourceDir("profiles", this.agentDir), "orchestration")
|
|
27
|
+
: join(this.cwd, CONFIG_DIR_NAME, "profiles", "orchestration");
|
|
28
|
+
}
|
|
29
|
+
filePath(profileId, scope) {
|
|
30
|
+
if (!PROFILE_ID_PATTERN.test(profileId)) {
|
|
31
|
+
throw new OrchestrationProfileError("Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.");
|
|
32
|
+
}
|
|
33
|
+
return join(this.directory(scope), `${profileId}.json`);
|
|
34
|
+
}
|
|
35
|
+
load() {
|
|
36
|
+
const diagnostics = [];
|
|
37
|
+
const globalProfiles = this.loadScope("global", diagnostics);
|
|
38
|
+
const projectProfiles = this.projectTrusted ? this.loadScope("project", diagnostics) : [];
|
|
39
|
+
if (!this.projectTrusted && existsSync(this.directory("project"))) {
|
|
40
|
+
diagnostics.push({
|
|
41
|
+
scope: "project",
|
|
42
|
+
path: this.directory("project"),
|
|
43
|
+
message: "Project orchestration profiles were not loaded because the project is untrusted.",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));
|
|
47
|
+
for (const profile of projectProfiles)
|
|
48
|
+
profilesById.set(profile.profileId, profile);
|
|
49
|
+
let profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));
|
|
50
|
+
let removed = true;
|
|
51
|
+
while (removed) {
|
|
52
|
+
removed = false;
|
|
53
|
+
const available = new Map(profiles.map((profile) => [profile.profileId, profile]));
|
|
54
|
+
profiles = profiles.filter((profile) => {
|
|
55
|
+
const invalidTarget = profile.dispatchProfileIds.find((profileId) => {
|
|
56
|
+
const target = available.get(profileId);
|
|
57
|
+
return !target || target.role === "orchestrator";
|
|
58
|
+
});
|
|
59
|
+
const verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;
|
|
60
|
+
const invalidVerifier = profile.verificationProfileId && verifier?.role !== "verifier"
|
|
61
|
+
? profile.verificationProfileId
|
|
62
|
+
: undefined;
|
|
63
|
+
const unauthorizedVerifier = profile.role === "orchestrator"
|
|
64
|
+
? profile.dispatchProfileIds
|
|
65
|
+
.map((profileId) => available.get(profileId))
|
|
66
|
+
.find((target) => target?.verificationProfileId &&
|
|
67
|
+
!profile.dispatchProfileIds.includes(target.verificationProfileId))
|
|
68
|
+
: undefined;
|
|
69
|
+
if (!invalidTarget && !invalidVerifier && !unauthorizedVerifier)
|
|
70
|
+
return true;
|
|
71
|
+
removed = true;
|
|
72
|
+
const message = invalidTarget
|
|
73
|
+
? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`
|
|
74
|
+
: invalidVerifier
|
|
75
|
+
? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`
|
|
76
|
+
: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;
|
|
77
|
+
diagnostics.push({
|
|
78
|
+
scope: profile.sourcePath?.startsWith(this.directory("project")) ? "project" : "global",
|
|
79
|
+
path: profile.sourcePath ?? profile.profileId,
|
|
80
|
+
message,
|
|
81
|
+
});
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
registry: new OrchestrationProfileRegistry(profiles),
|
|
87
|
+
profiles,
|
|
88
|
+
diagnostics,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
save(profile, scope, options = {}) {
|
|
92
|
+
if (scope === "project" && !this.projectTrusted) {
|
|
93
|
+
throw new OrchestrationProfileError("Project is not trusted; refusing to write project orchestration profiles.");
|
|
94
|
+
}
|
|
95
|
+
validateOrchestrationProfile(profile);
|
|
96
|
+
const filePath = this.filePath(profile.profileId, scope);
|
|
97
|
+
withFileLockSync(filePath, () => {
|
|
98
|
+
if (!options.overwrite && existsSync(filePath)) {
|
|
99
|
+
throw new OrchestrationProfileError(`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`);
|
|
100
|
+
}
|
|
101
|
+
writeFileAtomicSync(filePath, `${JSON.stringify(authoredProfile(profile), null, 2)}\n`);
|
|
102
|
+
});
|
|
103
|
+
return filePath;
|
|
104
|
+
}
|
|
105
|
+
loadScope(scope, diagnostics) {
|
|
106
|
+
const directory = this.directory(scope);
|
|
107
|
+
if (!existsSync(directory))
|
|
108
|
+
return [];
|
|
109
|
+
let entries;
|
|
110
|
+
try {
|
|
111
|
+
entries = readdirSync(directory)
|
|
112
|
+
.filter((entry) => entry.endsWith(".json"))
|
|
113
|
+
.sort((left, right) => left.localeCompare(right));
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
diagnostics.push({ scope, path: directory, message: messageFrom(error) });
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
const profilesById = new Map();
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
const sourcePath = join(directory, entry);
|
|
122
|
+
try {
|
|
123
|
+
const profile = parseOrchestrationProfile(JSON.parse(readFileSync(sourcePath, "utf-8")), sourcePath);
|
|
124
|
+
if (profilesById.has(profile.profileId)) {
|
|
125
|
+
throw new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`);
|
|
126
|
+
}
|
|
127
|
+
profilesById.set(profile.profileId, profile);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
diagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return [...profilesById.values()];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=profile-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-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E,CAAC,CAAC;YAC1E,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC7D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1C,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBACrG,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;oBACzC,MAAM,IAAI,yBAAyB,CAClC,oCAAoC,OAAO,CAAC,SAAS,QAAQ,KAAK,SAAS,CAC3E,CAAC;gBACH,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACF,CAAC;QACD,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAAA,CAClC;CACD","sourcesContent":["import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../../config.ts\";\nimport { resourceDir } from \"../agent-paths.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport type { OrchestrationProfile } from \"./contracts.ts\";\nimport {\n\tOrchestrationProfileError,\n\tOrchestrationProfileRegistry,\n\tparseOrchestrationProfile,\n\tvalidateOrchestrationProfile,\n} from \"./profile-registry.ts\";\n\nexport type OrchestrationProfileScope = \"global\" | \"project\";\n\nexport interface OrchestrationProfileDiagnostic {\n\tscope: OrchestrationProfileScope;\n\tpath: string;\n\tmessage: string;\n}\n\nexport interface OrchestrationProfileLoadResult {\n\tregistry: OrchestrationProfileRegistry;\n\tprofiles: readonly OrchestrationProfile[];\n\tdiagnostics: readonly OrchestrationProfileDiagnostic[];\n}\n\nconst PROFILE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;\n\nfunction authoredProfile(profile: OrchestrationProfile): Omit<OrchestrationProfile, \"sourcePath\"> {\n\tconst { sourcePath: _sourcePath, ...authored } = profile;\n\treturn authored;\n}\n\nfunction messageFrom(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nexport class OrchestrationProfileStore {\n\tprivate readonly agentDir: string;\n\tprivate readonly cwd: string;\n\tprivate readonly projectTrusted: boolean;\n\n\tconstructor(options: { agentDir: string; cwd: string; projectTrusted: boolean }) {\n\t\tthis.agentDir = resolve(options.agentDir);\n\t\tthis.cwd = resolve(options.cwd);\n\t\tthis.projectTrusted = options.projectTrusted;\n\t}\n\n\tdirectory(scope: OrchestrationProfileScope): string {\n\t\treturn scope === \"global\"\n\t\t\t? join(resourceDir(\"profiles\", this.agentDir), \"orchestration\")\n\t\t\t: join(this.cwd, CONFIG_DIR_NAME, \"profiles\", \"orchestration\");\n\t}\n\n\tfilePath(profileId: string, scope: OrchestrationProfileScope): string {\n\t\tif (!PROFILE_ID_PATTERN.test(profileId)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Orchestration profile IDs must be 1-128 characters using only letters, numbers, '.', '_', or '-'.\",\n\t\t\t);\n\t\t}\n\t\treturn join(this.directory(scope), `${profileId}.json`);\n\t}\n\n\tload(): OrchestrationProfileLoadResult {\n\t\tconst diagnostics: OrchestrationProfileDiagnostic[] = [];\n\t\tconst globalProfiles = this.loadScope(\"global\", diagnostics);\n\t\tconst projectProfiles = this.projectTrusted ? this.loadScope(\"project\", diagnostics) : [];\n\t\tif (!this.projectTrusted && existsSync(this.directory(\"project\"))) {\n\t\t\tdiagnostics.push({\n\t\t\t\tscope: \"project\",\n\t\t\t\tpath: this.directory(\"project\"),\n\t\t\t\tmessage: \"Project orchestration profiles were not loaded because the project is untrusted.\",\n\t\t\t});\n\t\t}\n\t\tconst profilesById = new Map(globalProfiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const profile of projectProfiles) profilesById.set(profile.profileId, profile);\n\t\tlet profiles = [...profilesById.values()].sort((left, right) => left.profileId.localeCompare(right.profileId));\n\t\tlet removed = true;\n\t\twhile (removed) {\n\t\t\tremoved = false;\n\t\t\tconst available = new Map(profiles.map((profile) => [profile.profileId, profile]));\n\t\t\tprofiles = profiles.filter((profile) => {\n\t\t\t\tconst invalidTarget = profile.dispatchProfileIds.find((profileId) => {\n\t\t\t\t\tconst target = available.get(profileId);\n\t\t\t\t\treturn !target || target.role === \"orchestrator\";\n\t\t\t\t});\n\t\t\t\tconst verifier = profile.verificationProfileId ? available.get(profile.verificationProfileId) : undefined;\n\t\t\t\tconst invalidVerifier =\n\t\t\t\t\tprofile.verificationProfileId && verifier?.role !== \"verifier\"\n\t\t\t\t\t\t? profile.verificationProfileId\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst unauthorizedVerifier =\n\t\t\t\t\tprofile.role === \"orchestrator\"\n\t\t\t\t\t\t? profile.dispatchProfileIds\n\t\t\t\t\t\t\t\t.map((profileId) => available.get(profileId))\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(target) =>\n\t\t\t\t\t\t\t\t\t\ttarget?.verificationProfileId &&\n\t\t\t\t\t\t\t\t\t\t!profile.dispatchProfileIds.includes(target.verificationProfileId),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (!invalidTarget && !invalidVerifier && !unauthorizedVerifier) return true;\n\t\t\t\tremoved = true;\n\t\t\t\tconst message = invalidTarget\n\t\t\t\t\t? `Dispatch target '${invalidTarget}' is missing or is another orchestrator.`\n\t\t\t\t\t: invalidVerifier\n\t\t\t\t\t\t? `Verifier target '${invalidVerifier}' is missing or is not a verifier.`\n\t\t\t\t\t\t: `Dispatched profile '${unauthorizedVerifier?.profileId}' requires verifier '${unauthorizedVerifier?.verificationProfileId}', which this orchestrator does not authorize.`;\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\tscope: profile.sourcePath?.startsWith(this.directory(\"project\")) ? \"project\" : \"global\",\n\t\t\t\t\tpath: profile.sourcePath ?? profile.profileId,\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t\treturn {\n\t\t\tregistry: new OrchestrationProfileRegistry(profiles),\n\t\t\tprofiles,\n\t\t\tdiagnostics,\n\t\t};\n\t}\n\n\tsave(\n\t\tprofile: OrchestrationProfile,\n\t\tscope: OrchestrationProfileScope,\n\t\toptions: { overwrite?: boolean } = {},\n\t): string {\n\t\tif (scope === \"project\" && !this.projectTrusted) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\"Project is not trusted; refusing to write project orchestration profiles.\",\n\t\t\t);\n\t\t}\n\t\tvalidateOrchestrationProfile(profile);\n\t\tconst filePath = this.filePath(profile.profileId, scope);\n\t\twithFileLockSync(filePath, () => {\n\t\t\tif (!options.overwrite && existsSync(filePath)) {\n\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t`Orchestration profile '${profile.profileId}' already exists in ${scope} scope.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\twriteFileAtomicSync(filePath, `${JSON.stringify(authoredProfile(profile), null, 2)}\\n`);\n\t\t});\n\t\treturn filePath;\n\t}\n\n\tprivate loadScope(\n\t\tscope: OrchestrationProfileScope,\n\t\tdiagnostics: OrchestrationProfileDiagnostic[],\n\t): OrchestrationProfile[] {\n\t\tconst directory = this.directory(scope);\n\t\tif (!existsSync(directory)) return [];\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readdirSync(directory)\n\t\t\t\t.filter((entry) => entry.endsWith(\".json\"))\n\t\t\t\t.sort((left, right) => left.localeCompare(right));\n\t\t} catch (error) {\n\t\t\tdiagnostics.push({ scope, path: directory, message: messageFrom(error) });\n\t\t\treturn [];\n\t\t}\n\t\tconst profilesById = new Map<string, OrchestrationProfile>();\n\t\tfor (const entry of entries) {\n\t\t\tconst sourcePath = join(directory, entry);\n\t\t\ttry {\n\t\t\t\tconst profile = parseOrchestrationProfile(JSON.parse(readFileSync(sourcePath, \"utf-8\")), sourcePath);\n\t\t\t\tif (profilesById.has(profile.profileId)) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Duplicate orchestration profile '${profile.profileId}' in ${scope} scope.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tprofilesById.set(profile.profileId, profile);\n\t\t\t} catch (error) {\n\t\t\t\tdiagnostics.push({ scope, path: sourcePath, message: messageFrom(error) });\n\t\t\t}\n\t\t}\n\t\treturn [...profilesById.values()];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RiskBudget } from "./contracts.ts";
|
|
2
|
+
export declare const RISK_BUDGET_LIMIT_FIELDS: readonly ["maxTokens", "maxWallClockMs", "maxCostUsd", "maxAttempts", "maxToolCalls"];
|
|
3
|
+
export type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];
|
|
4
|
+
export declare const RISK_BUDGET_FIELDS: readonly ["maxTokens", "maxWallClockMs", "maxCostUsd", "maxAttempts", "maxToolCalls", "requireApprovalAboveCostUsd"];
|
|
5
|
+
export declare function validateRiskBudget(budget: RiskBudget, label: string): void;
|
|
6
|
+
export declare function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[];
|
|
7
|
+
/** Intersects independent ceilings. Undefined fields do not constrain the result. */
|
|
8
|
+
export declare function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget;
|
|
9
|
+
//# sourceMappingURL=risk-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-budget.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,wBAAwB,uFAM3B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,eAAO,MAAM,kBAAkB,sHAAwE,CAAC;AASxG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS1E;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAM7G;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,GAAG,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAWlF","sourcesContent":["import type { RiskBudget } from \"./contracts.ts\";\n\nexport const RISK_BUDGET_LIMIT_FIELDS = [\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxCostUsd\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n] as const;\n\nexport type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];\n\nexport const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, \"requireApprovalAboveCostUsd\"] as const;\n\nconst DISCRETE_BUDGET_FIELDS: ReadonlySet<(typeof RISK_BUDGET_FIELDS)[number]> = new Set([\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n]);\n\nexport function validateRiskBudget(budget: RiskBudget, label: string): void {\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst value = budget[field];\n\t\tif (value === undefined) continue;\n\t\tif (!Number.isFinite(value) || value < 0) throw new TypeError(`${label}.${field} must be non-negative.`);\n\t\tif (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {\n\t\t\tthrow new TypeError(`${label}.${field} must be a non-negative safe integer.`);\n\t\t}\n\t}\n}\n\nexport function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[] {\n\treturn RISK_BUDGET_LIMIT_FIELDS.filter((field) => {\n\t\tconst request = requested[field];\n\t\tconst ceiling = authority[field];\n\t\treturn request !== undefined && ceiling !== undefined && request > ceiling;\n\t});\n}\n\n/** Intersects independent ceilings. Undefined fields do not constrain the result. */\nexport function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget {\n\tconst result: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst values = budgets.map((budget) => budget[field]).filter((value): value is number => value !== undefined);\n\t\tif (values.length > 0) result[field] = Math.min(...values);\n\t}\n\tconst approvalThreshold = result.requireApprovalAboveCostUsd;\n\tif (approvalThreshold !== undefined) {\n\t\tresult.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);\n\t}\n\treturn result;\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const RISK_BUDGET_LIMIT_FIELDS = [
|
|
2
|
+
"maxTokens",
|
|
3
|
+
"maxWallClockMs",
|
|
4
|
+
"maxCostUsd",
|
|
5
|
+
"maxAttempts",
|
|
6
|
+
"maxToolCalls",
|
|
7
|
+
];
|
|
8
|
+
export const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, "requireApprovalAboveCostUsd"];
|
|
9
|
+
const DISCRETE_BUDGET_FIELDS = new Set([
|
|
10
|
+
"maxTokens",
|
|
11
|
+
"maxWallClockMs",
|
|
12
|
+
"maxAttempts",
|
|
13
|
+
"maxToolCalls",
|
|
14
|
+
]);
|
|
15
|
+
export function validateRiskBudget(budget, label) {
|
|
16
|
+
for (const field of RISK_BUDGET_FIELDS) {
|
|
17
|
+
const value = budget[field];
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
continue;
|
|
20
|
+
if (!Number.isFinite(value) || value < 0)
|
|
21
|
+
throw new TypeError(`${label}.${field} must be non-negative.`);
|
|
22
|
+
if (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {
|
|
23
|
+
throw new TypeError(`${label}.${field} must be a non-negative safe integer.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function exceededRiskBudgetFields(requested, authority) {
|
|
28
|
+
return RISK_BUDGET_LIMIT_FIELDS.filter((field) => {
|
|
29
|
+
const request = requested[field];
|
|
30
|
+
const ceiling = authority[field];
|
|
31
|
+
return request !== undefined && ceiling !== undefined && request > ceiling;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** Intersects independent ceilings. Undefined fields do not constrain the result. */
|
|
35
|
+
export function intersectRiskBudgets(...budgets) {
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const field of RISK_BUDGET_FIELDS) {
|
|
38
|
+
const values = budgets.map((budget) => budget[field]).filter((value) => value !== undefined);
|
|
39
|
+
if (values.length > 0)
|
|
40
|
+
result[field] = Math.min(...values);
|
|
41
|
+
}
|
|
42
|
+
const approvalThreshold = result.requireApprovalAboveCostUsd;
|
|
43
|
+
if (approvalThreshold !== undefined) {
|
|
44
|
+
result.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=risk-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-budget.js","sourceRoot":"","sources":["../../../src/core/orchestration/risk-budget.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,WAAW;IACX,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;CACL,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AAE,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,kBAAkB,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC9G,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,iBAAiB,GAAG,MAAM,CAAC,2BAA2B,CAAC;IAC7D,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import type { RiskBudget } from \"./contracts.ts\";\n\nexport const RISK_BUDGET_LIMIT_FIELDS = [\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxCostUsd\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n] as const;\n\nexport type RiskBudgetLimitField = (typeof RISK_BUDGET_LIMIT_FIELDS)[number];\n\nexport const RISK_BUDGET_FIELDS = [...RISK_BUDGET_LIMIT_FIELDS, \"requireApprovalAboveCostUsd\"] as const;\n\nconst DISCRETE_BUDGET_FIELDS: ReadonlySet<(typeof RISK_BUDGET_FIELDS)[number]> = new Set([\n\t\"maxTokens\",\n\t\"maxWallClockMs\",\n\t\"maxAttempts\",\n\t\"maxToolCalls\",\n]);\n\nexport function validateRiskBudget(budget: RiskBudget, label: string): void {\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst value = budget[field];\n\t\tif (value === undefined) continue;\n\t\tif (!Number.isFinite(value) || value < 0) throw new TypeError(`${label}.${field} must be non-negative.`);\n\t\tif (DISCRETE_BUDGET_FIELDS.has(field) && !Number.isSafeInteger(value)) {\n\t\t\tthrow new TypeError(`${label}.${field} must be a non-negative safe integer.`);\n\t\t}\n\t}\n}\n\nexport function exceededRiskBudgetFields(requested: RiskBudget, authority: RiskBudget): RiskBudgetLimitField[] {\n\treturn RISK_BUDGET_LIMIT_FIELDS.filter((field) => {\n\t\tconst request = requested[field];\n\t\tconst ceiling = authority[field];\n\t\treturn request !== undefined && ceiling !== undefined && request > ceiling;\n\t});\n}\n\n/** Intersects independent ceilings. Undefined fields do not constrain the result. */\nexport function intersectRiskBudgets(...budgets: readonly RiskBudget[]): RiskBudget {\n\tconst result: RiskBudget = {};\n\tfor (const field of RISK_BUDGET_FIELDS) {\n\t\tconst values = budgets.map((budget) => budget[field]).filter((value): value is number => value !== undefined);\n\t\tif (values.length > 0) result[field] = Math.min(...values);\n\t}\n\tconst approvalThreshold = result.requireApprovalAboveCostUsd;\n\tif (approvalThreshold !== undefined) {\n\t\tresult.maxCostUsd = Math.min(result.maxCostUsd ?? approvalThreshold, approvalThreshold);\n\t}\n\treturn result;\n}\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { type AcceptanceCriterion, type AgentBindingContract, type AgentResumeContext, type ApprovalOutcome, type ApprovalRequestContract, type ApprovalResolutionContract, type AttemptCheckpoint, type AttemptLease, type AttemptStatus, type EvidenceContract, type ExecutionGrant, type ObjectiveContract, type OrchestrationDispatchRequest, type OrchestrationEvent, type RiskBudget, type TaskContract, type WorkerResultContract } from "./contracts.ts";
|
|
2
|
+
import { type OrchestrationEventStore } from "./event-store.ts";
|
|
3
|
+
export interface ObjectiveRuntimeState {
|
|
4
|
+
objective: ObjectiveContract;
|
|
5
|
+
taskIds: readonly string[];
|
|
6
|
+
evidence: readonly EvidenceContract[];
|
|
7
|
+
}
|
|
8
|
+
export interface TaskRuntimeState {
|
|
9
|
+
task: TaskContract;
|
|
10
|
+
attemptIds: readonly string[];
|
|
11
|
+
verification?: {
|
|
12
|
+
verifierTaskId: string;
|
|
13
|
+
verifierAttemptId: string;
|
|
14
|
+
verdict: "accepted" | "rejected" | "inconclusive";
|
|
15
|
+
reasonCode: string;
|
|
16
|
+
completedAt: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface AttemptRuntimeState {
|
|
20
|
+
attemptId: string;
|
|
21
|
+
taskId: string;
|
|
22
|
+
dispatch: OrchestrationDispatchRequest;
|
|
23
|
+
status: AttemptStatus;
|
|
24
|
+
reasonCode?: string;
|
|
25
|
+
grantId?: string;
|
|
26
|
+
/** Full compiled authority for new attempts; grantId alone is retained only when replaying legacy events. */
|
|
27
|
+
grant?: ExecutionGrant;
|
|
28
|
+
agentId?: string;
|
|
29
|
+
lease?: AttemptLease;
|
|
30
|
+
checkpointIds: readonly string[];
|
|
31
|
+
result?: WorkerResultContract;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface NotificationRuntimeState {
|
|
36
|
+
notificationId: string;
|
|
37
|
+
objectiveId: string;
|
|
38
|
+
attemptId?: string;
|
|
39
|
+
status: "pending" | "delivered";
|
|
40
|
+
message: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
deliveredAt?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ApprovalRuntimeState {
|
|
45
|
+
request: ApprovalRequestContract;
|
|
46
|
+
status: "pending" | ApprovalOutcome;
|
|
47
|
+
resolution?: ApprovalResolutionContract;
|
|
48
|
+
}
|
|
49
|
+
export interface TaskRuntimeProjection {
|
|
50
|
+
lastOrdinal: number;
|
|
51
|
+
agents: Readonly<Record<string, AgentBindingContract>>;
|
|
52
|
+
objectives: Readonly<Record<string, ObjectiveRuntimeState>>;
|
|
53
|
+
tasks: Readonly<Record<string, TaskRuntimeState>>;
|
|
54
|
+
attempts: Readonly<Record<string, AttemptRuntimeState>>;
|
|
55
|
+
checkpoints: Readonly<Record<string, AttemptCheckpoint>>;
|
|
56
|
+
approvals: Readonly<Record<string, ApprovalRuntimeState>>;
|
|
57
|
+
notifications: Readonly<Record<string, NotificationRuntimeState>>;
|
|
58
|
+
}
|
|
59
|
+
export interface CreateObjectiveInput {
|
|
60
|
+
objectiveId?: string;
|
|
61
|
+
title: string;
|
|
62
|
+
description: string;
|
|
63
|
+
constraints?: readonly string[];
|
|
64
|
+
acceptanceCriteria?: readonly AcceptanceCriterion[];
|
|
65
|
+
riskBudget?: RiskBudget;
|
|
66
|
+
}
|
|
67
|
+
export interface CreateTaskInput {
|
|
68
|
+
taskId?: string;
|
|
69
|
+
objectiveId: string;
|
|
70
|
+
title: string;
|
|
71
|
+
description: string;
|
|
72
|
+
role: TaskContract["role"];
|
|
73
|
+
dependsOn?: readonly string[];
|
|
74
|
+
requiredCapabilities?: TaskContract["requiredCapabilities"];
|
|
75
|
+
acceptanceCriterionIds?: readonly string[];
|
|
76
|
+
verificationOfTaskId?: string;
|
|
77
|
+
riskBudget?: RiskBudget;
|
|
78
|
+
}
|
|
79
|
+
export interface DurableTaskRuntimeOptions {
|
|
80
|
+
store: OrchestrationEventStore;
|
|
81
|
+
now?: () => number;
|
|
82
|
+
createId?: () => string;
|
|
83
|
+
}
|
|
84
|
+
export interface RegisterAgentInput {
|
|
85
|
+
agentId?: string;
|
|
86
|
+
role: AgentBindingContract["role"];
|
|
87
|
+
resumeContext: AgentResumeContext;
|
|
88
|
+
}
|
|
89
|
+
export declare class DurableTaskRuntimeError extends Error {
|
|
90
|
+
constructor(message: string);
|
|
91
|
+
}
|
|
92
|
+
export declare function reduceOrchestrationEvent(projection: TaskRuntimeProjection, event: OrchestrationEvent): TaskRuntimeProjection;
|
|
93
|
+
export declare function projectOrchestrationEvents(events: readonly OrchestrationEvent[]): TaskRuntimeProjection;
|
|
94
|
+
export declare class DurableTaskRuntime {
|
|
95
|
+
private readonly store;
|
|
96
|
+
private readonly now;
|
|
97
|
+
private readonly createId;
|
|
98
|
+
private state;
|
|
99
|
+
constructor(options: DurableTaskRuntimeOptions);
|
|
100
|
+
getSnapshot(): TaskRuntimeProjection;
|
|
101
|
+
registerAgent(input: RegisterAgentInput): AgentBindingContract;
|
|
102
|
+
createObjective(input: CreateObjectiveInput): ObjectiveContract;
|
|
103
|
+
/** Create or synchronize owner-authored objective metadata without disturbing lifecycle or task state. */
|
|
104
|
+
ensureObjective(input: CreateObjectiveInput & {
|
|
105
|
+
objectiveId: string;
|
|
106
|
+
}): ObjectiveContract;
|
|
107
|
+
recordObjectiveEvidence(objectiveId: string, evidence: EvidenceContract): EvidenceContract;
|
|
108
|
+
createTask(input: CreateTaskInput): TaskContract;
|
|
109
|
+
queueAttempt(taskId: string, dispatch: OrchestrationDispatchRequest, grantId?: string): AttemptRuntimeState;
|
|
110
|
+
bindAttemptGrant(attemptId: string, grant: ExecutionGrant): AttemptRuntimeState;
|
|
111
|
+
leaseAttempt(attemptId: string, ownerId: string, ttlMs: number, agentId?: string): AttemptLease;
|
|
112
|
+
startAttempt(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState;
|
|
113
|
+
checkpointAttempt(args: {
|
|
114
|
+
attemptId: string;
|
|
115
|
+
leaseId: string;
|
|
116
|
+
fencingToken: number;
|
|
117
|
+
summary: string;
|
|
118
|
+
artifactIds?: readonly string[];
|
|
119
|
+
evidenceIds?: readonly string[];
|
|
120
|
+
}): AttemptCheckpoint;
|
|
121
|
+
finishAttempt(result: WorkerResultContract): AttemptRuntimeState;
|
|
122
|
+
finishVerification(args: {
|
|
123
|
+
taskId: string;
|
|
124
|
+
verifierTaskId: string;
|
|
125
|
+
verifierAttemptId: string;
|
|
126
|
+
verdict: "accepted" | "rejected" | "inconclusive";
|
|
127
|
+
reasonCode: string;
|
|
128
|
+
}): TaskRuntimeState;
|
|
129
|
+
cancelAttempt(attemptId: string, reasonCode: string): AttemptRuntimeState;
|
|
130
|
+
failTask(taskId: string, reasonCode: string): TaskContract;
|
|
131
|
+
/**
|
|
132
|
+
* Recover unbound in-process work after a process restart. A completion has no resumable model
|
|
133
|
+
* transcript, so its old lease is fenced and the task becomes dispatchable for a fresh attempt.
|
|
134
|
+
* Agent-bound attempts are intentionally excluded: those must wake the same logical agent.
|
|
135
|
+
*/
|
|
136
|
+
recoverInterruptedUnboundAttempts(shouldRecover?: (attempt: AttemptRuntimeState) => boolean): string[];
|
|
137
|
+
expireLeases(at?: number): string[];
|
|
138
|
+
requestAgentResume(agentId: string): AgentBindingContract;
|
|
139
|
+
resumeAttempt(attemptId: string, agentId: string, ttlMs: number): AttemptLease;
|
|
140
|
+
pauseObjective(objectiveId: string): void;
|
|
141
|
+
resumeObjective(objectiveId: string): void;
|
|
142
|
+
cancelObjective(objectiveId: string): void;
|
|
143
|
+
completeObjective(objectiveId: string): void;
|
|
144
|
+
completeObjectiveFromOwner(objectiveId: string, acceptanceOverride: boolean): void;
|
|
145
|
+
requestApproval(approval: ApprovalRequestContract): ApprovalRuntimeState;
|
|
146
|
+
resolveApproval(approvalId: string, outcome: ApprovalOutcome, reasonCode: string): ApprovalRuntimeState;
|
|
147
|
+
enqueueNotification(args: {
|
|
148
|
+
notificationId?: string;
|
|
149
|
+
objectiveId: string;
|
|
150
|
+
attemptId?: string;
|
|
151
|
+
message: string;
|
|
152
|
+
}): NotificationRuntimeState;
|
|
153
|
+
markNotificationDelivered(notificationId: string): NotificationRuntimeState;
|
|
154
|
+
private transitionObjective;
|
|
155
|
+
private requireObjective;
|
|
156
|
+
private requireDispatchableTask;
|
|
157
|
+
private requireAttempt;
|
|
158
|
+
private approvalForAttempt;
|
|
159
|
+
private pendingApprovalForTask;
|
|
160
|
+
private requireActiveObjectiveForAttempt;
|
|
161
|
+
private validateApprovalRequest;
|
|
162
|
+
private requireLiveLease;
|
|
163
|
+
private refresh;
|
|
164
|
+
private commit;
|
|
165
|
+
private compactCurrentProjection;
|
|
166
|
+
private nowIso;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=task-runtime.d.ts.map
|