@herdctl/core 0.0.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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +219 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-final.json +51 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +251 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/config/index.html +191 -0
- package/coverage/src/config/index.ts.html +442 -0
- package/coverage/src/config/interpolate.ts.html +652 -0
- package/coverage/src/config/loader.ts.html +1501 -0
- package/coverage/src/config/merge.ts.html +823 -0
- package/coverage/src/config/parser.ts.html +1213 -0
- package/coverage/src/config/schema.ts.html +1123 -0
- package/coverage/src/fleet-manager/errors.ts.html +2326 -0
- package/coverage/src/fleet-manager/event-types.ts.html +1219 -0
- package/coverage/src/fleet-manager/fleet-manager.ts.html +7030 -0
- package/coverage/src/fleet-manager/index.html +206 -0
- package/coverage/src/fleet-manager/index.ts.html +469 -0
- package/coverage/src/fleet-manager/job-manager.ts.html +2074 -0
- package/coverage/src/fleet-manager/job-queue.ts.html +2479 -0
- package/coverage/src/fleet-manager/types.ts.html +2602 -0
- package/coverage/src/index.html +116 -0
- package/coverage/src/index.ts.html +181 -0
- package/coverage/src/runner/errors.ts.html +1006 -0
- package/coverage/src/runner/index.html +191 -0
- package/coverage/src/runner/index.ts.html +256 -0
- package/coverage/src/runner/job-executor.ts.html +1429 -0
- package/coverage/src/runner/message-processor.ts.html +1150 -0
- package/coverage/src/runner/sdk-adapter.ts.html +658 -0
- package/coverage/src/runner/types.ts.html +559 -0
- package/coverage/src/scheduler/errors.ts.html +388 -0
- package/coverage/src/scheduler/index.html +206 -0
- package/coverage/src/scheduler/index.ts.html +244 -0
- package/coverage/src/scheduler/interval.ts.html +652 -0
- package/coverage/src/scheduler/schedule-runner.ts.html +1411 -0
- package/coverage/src/scheduler/schedule-state.ts.html +718 -0
- package/coverage/src/scheduler/scheduler.ts.html +1795 -0
- package/coverage/src/scheduler/types.ts.html +733 -0
- package/coverage/src/state/directory.ts.html +736 -0
- package/coverage/src/state/errors.ts.html +376 -0
- package/coverage/src/state/fleet-state.ts.html +937 -0
- package/coverage/src/state/index.html +221 -0
- package/coverage/src/state/index.ts.html +322 -0
- package/coverage/src/state/job-metadata.ts.html +1420 -0
- package/coverage/src/state/job-output.ts.html +1033 -0
- package/coverage/src/state/schemas/fleet-state.ts.html +445 -0
- package/coverage/src/state/schemas/index.html +176 -0
- package/coverage/src/state/schemas/index.ts.html +286 -0
- package/coverage/src/state/schemas/job-metadata.ts.html +628 -0
- package/coverage/src/state/schemas/job-output.ts.html +616 -0
- package/coverage/src/state/schemas/session-info.ts.html +361 -0
- package/coverage/src/state/session.ts.html +844 -0
- package/coverage/src/state/types.ts.html +262 -0
- package/coverage/src/state/utils/atomic.ts.html +748 -0
- package/coverage/src/state/utils/index.html +146 -0
- package/coverage/src/state/utils/index.ts.html +103 -0
- package/coverage/src/state/utils/reads.ts.html +1621 -0
- package/coverage/src/work-sources/adapters/github.ts.html +3583 -0
- package/coverage/src/work-sources/adapters/index.html +131 -0
- package/coverage/src/work-sources/adapters/index.ts.html +277 -0
- package/coverage/src/work-sources/errors.ts.html +298 -0
- package/coverage/src/work-sources/index.html +176 -0
- package/coverage/src/work-sources/index.ts.html +529 -0
- package/coverage/src/work-sources/manager.ts.html +1324 -0
- package/coverage/src/work-sources/registry.ts.html +619 -0
- package/coverage/src/work-sources/types.ts.html +568 -0
- package/dist/config/__tests__/agent.test.d.ts +2 -0
- package/dist/config/__tests__/agent.test.d.ts.map +1 -0
- package/dist/config/__tests__/agent.test.js +752 -0
- package/dist/config/__tests__/agent.test.js.map +1 -0
- package/dist/config/__tests__/interpolate.test.d.ts +2 -0
- package/dist/config/__tests__/interpolate.test.d.ts.map +1 -0
- package/dist/config/__tests__/interpolate.test.js +509 -0
- package/dist/config/__tests__/interpolate.test.js.map +1 -0
- package/dist/config/__tests__/loader.test.d.ts +2 -0
- package/dist/config/__tests__/loader.test.d.ts.map +1 -0
- package/dist/config/__tests__/loader.test.js +631 -0
- package/dist/config/__tests__/loader.test.js.map +1 -0
- package/dist/config/__tests__/merge.test.d.ts +2 -0
- package/dist/config/__tests__/merge.test.d.ts.map +1 -0
- package/dist/config/__tests__/merge.test.js +672 -0
- package/dist/config/__tests__/merge.test.js.map +1 -0
- package/dist/config/__tests__/parser.test.d.ts +2 -0
- package/dist/config/__tests__/parser.test.d.ts.map +1 -0
- package/dist/config/__tests__/parser.test.js +476 -0
- package/dist/config/__tests__/parser.test.js.map +1 -0
- package/dist/config/__tests__/schema.test.d.ts +2 -0
- package/dist/config/__tests__/schema.test.d.ts.map +1 -0
- package/dist/config/__tests__/schema.test.js +776 -0
- package/dist/config/__tests__/schema.test.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +26 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/interpolate.d.ts +76 -0
- package/dist/config/interpolate.d.ts.map +1 -0
- package/dist/config/interpolate.js +143 -0
- package/dist/config/interpolate.js.map +1 -0
- package/dist/config/loader.d.ts +147 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +336 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/merge.d.ts +84 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +138 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/parser.d.ts +143 -0
- package/dist/config/parser.d.ts.map +1 -0
- package/dist/config/parser.js +316 -0
- package/dist/config/parser.js.map +1 -0
- package/dist/config/schema.d.ts +1906 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +268 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/fleet-manager/__tests__/coverage.test.d.ts +13 -0
- package/dist/fleet-manager/__tests__/coverage.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/coverage.test.js +2282 -0
- package/dist/fleet-manager/__tests__/coverage.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/errors.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/errors.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/errors.test.js +557 -0
- package/dist/fleet-manager/__tests__/errors.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/event-helpers.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/event-helpers.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/event-helpers.test.js +368 -0
- package/dist/fleet-manager/__tests__/event-helpers.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/integration.test.d.ts +11 -0
- package/dist/fleet-manager/__tests__/integration.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/integration.test.js +949 -0
- package/dist/fleet-manager/__tests__/integration.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/job-control.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/job-control.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/job-control.test.js +215 -0
- package/dist/fleet-manager/__tests__/job-control.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/job-manager.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/job-manager.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/job-manager.test.js +659 -0
- package/dist/fleet-manager/__tests__/job-manager.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/job-queue.test.d.ts +5 -0
- package/dist/fleet-manager/__tests__/job-queue.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/job-queue.test.js +315 -0
- package/dist/fleet-manager/__tests__/job-queue.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/reload.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/reload.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/reload.test.js +609 -0
- package/dist/fleet-manager/__tests__/reload.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/status-queries.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/status-queries.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/status-queries.test.js +488 -0
- package/dist/fleet-manager/__tests__/status-queries.test.js.map +1 -0
- package/dist/fleet-manager/__tests__/trigger.test.d.ts +7 -0
- package/dist/fleet-manager/__tests__/trigger.test.d.ts.map +1 -0
- package/dist/fleet-manager/__tests__/trigger.test.js +471 -0
- package/dist/fleet-manager/__tests__/trigger.test.js.map +1 -0
- package/dist/fleet-manager/errors.d.ts +407 -0
- package/dist/fleet-manager/errors.d.ts.map +1 -0
- package/dist/fleet-manager/errors.js +569 -0
- package/dist/fleet-manager/errors.js.map +1 -0
- package/dist/fleet-manager/event-types.d.ts +302 -0
- package/dist/fleet-manager/event-types.d.ts.map +1 -0
- package/dist/fleet-manager/event-types.js +9 -0
- package/dist/fleet-manager/event-types.js.map +1 -0
- package/dist/fleet-manager/fleet-manager.d.ts +699 -0
- package/dist/fleet-manager/fleet-manager.d.ts.map +1 -0
- package/dist/fleet-manager/fleet-manager.js +1906 -0
- package/dist/fleet-manager/fleet-manager.js.map +1 -0
- package/dist/fleet-manager/index.d.ts +17 -0
- package/dist/fleet-manager/index.d.ts.map +1 -0
- package/dist/fleet-manager/index.js +29 -0
- package/dist/fleet-manager/index.js.map +1 -0
- package/dist/fleet-manager/job-manager.d.ts +271 -0
- package/dist/fleet-manager/job-manager.d.ts.map +1 -0
- package/dist/fleet-manager/job-manager.js +443 -0
- package/dist/fleet-manager/job-manager.js.map +1 -0
- package/dist/fleet-manager/job-queue.d.ts +422 -0
- package/dist/fleet-manager/job-queue.d.ts.map +1 -0
- package/dist/fleet-manager/job-queue.js +448 -0
- package/dist/fleet-manager/job-queue.js.map +1 -0
- package/dist/fleet-manager/types.d.ts +680 -0
- package/dist/fleet-manager/types.d.ts.map +1 -0
- package/dist/fleet-manager/types.js +8 -0
- package/dist/fleet-manager/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/runner/__tests__/errors.test.d.ts +2 -0
- package/dist/runner/__tests__/errors.test.d.ts.map +1 -0
- package/dist/runner/__tests__/errors.test.js +264 -0
- package/dist/runner/__tests__/errors.test.js.map +1 -0
- package/dist/runner/__tests__/job-executor.test.d.ts +2 -0
- package/dist/runner/__tests__/job-executor.test.d.ts.map +1 -0
- package/dist/runner/__tests__/job-executor.test.js +1345 -0
- package/dist/runner/__tests__/job-executor.test.js.map +1 -0
- package/dist/runner/__tests__/message-processor.test.d.ts +2 -0
- package/dist/runner/__tests__/message-processor.test.d.ts.map +1 -0
- package/dist/runner/__tests__/message-processor.test.js +768 -0
- package/dist/runner/__tests__/message-processor.test.js.map +1 -0
- package/dist/runner/__tests__/sdk-adapter.test.d.ts +2 -0
- package/dist/runner/__tests__/sdk-adapter.test.d.ts.map +1 -0
- package/dist/runner/__tests__/sdk-adapter.test.js +554 -0
- package/dist/runner/__tests__/sdk-adapter.test.js.map +1 -0
- package/dist/runner/errors.d.ts +121 -0
- package/dist/runner/errors.d.ts.map +1 -0
- package/dist/runner/errors.js +212 -0
- package/dist/runner/errors.js.map +1 -0
- package/dist/runner/index.d.ts +12 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +15 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/job-executor.d.ts +98 -0
- package/dist/runner/job-executor.d.ts.map +1 -0
- package/dist/runner/job-executor.js +333 -0
- package/dist/runner/job-executor.js.map +1 -0
- package/dist/runner/message-processor.d.ts +45 -0
- package/dist/runner/message-processor.d.ts.map +1 -0
- package/dist/runner/message-processor.js +294 -0
- package/dist/runner/message-processor.js.map +1 -0
- package/dist/runner/sdk-adapter.d.ts +60 -0
- package/dist/runner/sdk-adapter.d.ts.map +1 -0
- package/dist/runner/sdk-adapter.js +138 -0
- package/dist/runner/sdk-adapter.js.map +1 -0
- package/dist/runner/types.d.ts +135 -0
- package/dist/runner/types.d.ts.map +1 -0
- package/dist/runner/types.js +7 -0
- package/dist/runner/types.js.map +1 -0
- package/dist/scheduler/__tests__/errors.test.d.ts +2 -0
- package/dist/scheduler/__tests__/errors.test.d.ts.map +1 -0
- package/dist/scheduler/__tests__/errors.test.js +101 -0
- package/dist/scheduler/__tests__/errors.test.js.map +1 -0
- package/dist/scheduler/__tests__/interval.test.d.ts +2 -0
- package/dist/scheduler/__tests__/interval.test.d.ts.map +1 -0
- package/dist/scheduler/__tests__/interval.test.js +419 -0
- package/dist/scheduler/__tests__/interval.test.js.map +1 -0
- package/dist/scheduler/__tests__/schedule-runner.test.d.ts +2 -0
- package/dist/scheduler/__tests__/schedule-runner.test.d.ts.map +1 -0
- package/dist/scheduler/__tests__/schedule-runner.test.js +634 -0
- package/dist/scheduler/__tests__/schedule-runner.test.js.map +1 -0
- package/dist/scheduler/__tests__/schedule-state.test.d.ts +2 -0
- package/dist/scheduler/__tests__/schedule-state.test.d.ts.map +1 -0
- package/dist/scheduler/__tests__/schedule-state.test.js +572 -0
- package/dist/scheduler/__tests__/schedule-state.test.js.map +1 -0
- package/dist/scheduler/__tests__/scheduler.test.d.ts +2 -0
- package/dist/scheduler/__tests__/scheduler.test.d.ts.map +1 -0
- package/dist/scheduler/__tests__/scheduler.test.js +987 -0
- package/dist/scheduler/__tests__/scheduler.test.js.map +1 -0
- package/dist/scheduler/errors.d.ts +61 -0
- package/dist/scheduler/errors.d.ts.map +1 -0
- package/dist/scheduler/errors.js +81 -0
- package/dist/scheduler/errors.js.map +1 -0
- package/dist/scheduler/index.d.ts +13 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +17 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/interval.d.ts +64 -0
- package/dist/scheduler/interval.d.ts.map +1 -0
- package/dist/scheduler/interval.js +139 -0
- package/dist/scheduler/interval.js.map +1 -0
- package/dist/scheduler/schedule-runner.d.ts +149 -0
- package/dist/scheduler/schedule-runner.d.ts.map +1 -0
- package/dist/scheduler/schedule-runner.js +277 -0
- package/dist/scheduler/schedule-runner.js.map +1 -0
- package/dist/scheduler/schedule-state.d.ts +105 -0
- package/dist/scheduler/schedule-state.d.ts.map +1 -0
- package/dist/scheduler/schedule-state.js +151 -0
- package/dist/scheduler/schedule-state.js.map +1 -0
- package/dist/scheduler/scheduler.d.ts +138 -0
- package/dist/scheduler/scheduler.d.ts.map +1 -0
- package/dist/scheduler/scheduler.js +423 -0
- package/dist/scheduler/scheduler.js.map +1 -0
- package/dist/scheduler/types.d.ts +160 -0
- package/dist/scheduler/types.d.ts.map +1 -0
- package/dist/scheduler/types.js +8 -0
- package/dist/scheduler/types.js.map +1 -0
- package/dist/state/__tests__/directory.test.d.ts +2 -0
- package/dist/state/__tests__/directory.test.d.ts.map +1 -0
- package/dist/state/__tests__/directory.test.js +414 -0
- package/dist/state/__tests__/directory.test.js.map +1 -0
- package/dist/state/__tests__/fleet-state.test.d.ts +2 -0
- package/dist/state/__tests__/fleet-state.test.d.ts.map +1 -0
- package/dist/state/__tests__/fleet-state.test.js +696 -0
- package/dist/state/__tests__/fleet-state.test.js.map +1 -0
- package/dist/state/__tests__/job-metadata-schema.test.d.ts +2 -0
- package/dist/state/__tests__/job-metadata-schema.test.d.ts.map +1 -0
- package/dist/state/__tests__/job-metadata-schema.test.js +329 -0
- package/dist/state/__tests__/job-metadata-schema.test.js.map +1 -0
- package/dist/state/__tests__/job-metadata.test.d.ts +2 -0
- package/dist/state/__tests__/job-metadata.test.d.ts.map +1 -0
- package/dist/state/__tests__/job-metadata.test.js +667 -0
- package/dist/state/__tests__/job-metadata.test.js.map +1 -0
- package/dist/state/__tests__/job-output.test.d.ts +2 -0
- package/dist/state/__tests__/job-output.test.d.ts.map +1 -0
- package/dist/state/__tests__/job-output.test.js +672 -0
- package/dist/state/__tests__/job-output.test.js.map +1 -0
- package/dist/state/__tests__/session-schema.test.d.ts +2 -0
- package/dist/state/__tests__/session-schema.test.d.ts.map +1 -0
- package/dist/state/__tests__/session-schema.test.js +323 -0
- package/dist/state/__tests__/session-schema.test.js.map +1 -0
- package/dist/state/__tests__/session.test.d.ts +2 -0
- package/dist/state/__tests__/session.test.d.ts.map +1 -0
- package/dist/state/__tests__/session.test.js +468 -0
- package/dist/state/__tests__/session.test.js.map +1 -0
- package/dist/state/directory.d.ts +42 -0
- package/dist/state/directory.d.ts.map +1 -0
- package/dist/state/directory.js +170 -0
- package/dist/state/directory.js.map +1 -0
- package/dist/state/errors.d.ts +44 -0
- package/dist/state/errors.d.ts.map +1 -0
- package/dist/state/errors.js +82 -0
- package/dist/state/errors.js.map +1 -0
- package/dist/state/fleet-state.d.ts +126 -0
- package/dist/state/fleet-state.d.ts.map +1 -0
- package/dist/state/fleet-state.js +196 -0
- package/dist/state/fleet-state.js.map +1 -0
- package/dist/state/index.d.ts +21 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +30 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/job-metadata.d.ts +151 -0
- package/dist/state/job-metadata.d.ts.map +1 -0
- package/dist/state/job-metadata.js +287 -0
- package/dist/state/job-metadata.js.map +1 -0
- package/dist/state/job-output.d.ts +116 -0
- package/dist/state/job-output.d.ts.map +1 -0
- package/dist/state/job-output.js +218 -0
- package/dist/state/job-output.js.map +1 -0
- package/dist/state/schemas/__tests__/job-output.test.d.ts +2 -0
- package/dist/state/schemas/__tests__/job-output.test.d.ts.map +1 -0
- package/dist/state/schemas/__tests__/job-output.test.js +279 -0
- package/dist/state/schemas/__tests__/job-output.test.js.map +1 -0
- package/dist/state/schemas/fleet-state.d.ts +249 -0
- package/dist/state/schemas/fleet-state.d.ts.map +1 -0
- package/dist/state/schemas/fleet-state.js +97 -0
- package/dist/state/schemas/fleet-state.js.map +1 -0
- package/dist/state/schemas/index.d.ts +10 -0
- package/dist/state/schemas/index.d.ts.map +1 -0
- package/dist/state/schemas/index.js +10 -0
- package/dist/state/schemas/index.js.map +1 -0
- package/dist/state/schemas/job-metadata.d.ts +118 -0
- package/dist/state/schemas/job-metadata.d.ts.map +1 -0
- package/dist/state/schemas/job-metadata.js +123 -0
- package/dist/state/schemas/job-metadata.js.map +1 -0
- package/dist/state/schemas/job-output.d.ts +291 -0
- package/dist/state/schemas/job-output.d.ts.map +1 -0
- package/dist/state/schemas/job-output.js +132 -0
- package/dist/state/schemas/job-output.js.map +1 -0
- package/dist/state/schemas/session-info.d.ts +65 -0
- package/dist/state/schemas/session-info.d.ts.map +1 -0
- package/dist/state/schemas/session-info.js +58 -0
- package/dist/state/schemas/session-info.js.map +1 -0
- package/dist/state/session.d.ts +92 -0
- package/dist/state/session.d.ts.map +1 -0
- package/dist/state/session.js +173 -0
- package/dist/state/session.js.map +1 -0
- package/dist/state/types.d.ts +54 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +18 -0
- package/dist/state/types.js.map +1 -0
- package/dist/state/utils/__tests__/atomic.test.d.ts +2 -0
- package/dist/state/utils/__tests__/atomic.test.d.ts.map +1 -0
- package/dist/state/utils/__tests__/atomic.test.js +537 -0
- package/dist/state/utils/__tests__/atomic.test.js.map +1 -0
- package/dist/state/utils/__tests__/reads.test.d.ts +2 -0
- package/dist/state/utils/__tests__/reads.test.d.ts.map +1 -0
- package/dist/state/utils/__tests__/reads.test.js +792 -0
- package/dist/state/utils/__tests__/reads.test.js.map +1 -0
- package/dist/state/utils/atomic.d.ts +89 -0
- package/dist/state/utils/atomic.d.ts.map +1 -0
- package/dist/state/utils/atomic.js +157 -0
- package/dist/state/utils/atomic.js.map +1 -0
- package/dist/state/utils/index.d.ts +6 -0
- package/dist/state/utils/index.d.ts.map +1 -0
- package/dist/state/utils/index.js +6 -0
- package/dist/state/utils/index.js.map +1 -0
- package/dist/state/utils/reads.d.ts +196 -0
- package/dist/state/utils/reads.d.ts.map +1 -0
- package/dist/state/utils/reads.js +346 -0
- package/dist/state/utils/reads.js.map +1 -0
- package/dist/work-sources/__tests__/github.test.d.ts +2 -0
- package/dist/work-sources/__tests__/github.test.d.ts.map +1 -0
- package/dist/work-sources/__tests__/github.test.js +1334 -0
- package/dist/work-sources/__tests__/github.test.js.map +1 -0
- package/dist/work-sources/__tests__/manager.test.d.ts +2 -0
- package/dist/work-sources/__tests__/manager.test.d.ts.map +1 -0
- package/dist/work-sources/__tests__/manager.test.js +424 -0
- package/dist/work-sources/__tests__/manager.test.js.map +1 -0
- package/dist/work-sources/__tests__/registry.test.d.ts +2 -0
- package/dist/work-sources/__tests__/registry.test.d.ts.map +1 -0
- package/dist/work-sources/__tests__/registry.test.js +381 -0
- package/dist/work-sources/__tests__/registry.test.js.map +1 -0
- package/dist/work-sources/__tests__/types.test.d.ts +2 -0
- package/dist/work-sources/__tests__/types.test.d.ts.map +1 -0
- package/dist/work-sources/__tests__/types.test.js +406 -0
- package/dist/work-sources/__tests__/types.test.js.map +1 -0
- package/dist/work-sources/adapters/github.d.ts +290 -0
- package/dist/work-sources/adapters/github.d.ts.map +1 -0
- package/dist/work-sources/adapters/github.js +803 -0
- package/dist/work-sources/adapters/github.js.map +1 -0
- package/dist/work-sources/adapters/index.d.ts +10 -0
- package/dist/work-sources/adapters/index.d.ts.map +1 -0
- package/dist/work-sources/adapters/index.js +31 -0
- package/dist/work-sources/adapters/index.js.map +1 -0
- package/dist/work-sources/errors.d.ts +40 -0
- package/dist/work-sources/errors.d.ts.map +1 -0
- package/dist/work-sources/errors.js +54 -0
- package/dist/work-sources/errors.js.map +1 -0
- package/dist/work-sources/index.d.ts +105 -0
- package/dist/work-sources/index.d.ts.map +1 -0
- package/dist/work-sources/index.js +24 -0
- package/dist/work-sources/index.js.map +1 -0
- package/dist/work-sources/manager.d.ts +370 -0
- package/dist/work-sources/manager.d.ts.map +1 -0
- package/dist/work-sources/manager.js +61 -0
- package/dist/work-sources/manager.js.map +1 -0
- package/dist/work-sources/registry.d.ts +128 -0
- package/dist/work-sources/registry.d.ts.map +1 -0
- package/dist/work-sources/registry.js +132 -0
- package/dist/work-sources/registry.js.map +1 -0
- package/dist/work-sources/types.d.ts +127 -0
- package/dist/work-sources/types.d.ts.map +1 -0
- package/dist/work-sources/types.js +8 -0
- package/dist/work-sources/types.js.map +1 -0
- package/package.json +23 -0
- package/src/config/__tests__/agent.test.ts +864 -0
- package/src/config/__tests__/interpolate.test.ts +644 -0
- package/src/config/__tests__/loader.test.ts +784 -0
- package/src/config/__tests__/merge.test.ts +751 -0
- package/src/config/__tests__/parser.test.ts +533 -0
- package/src/config/__tests__/schema.test.ts +873 -0
- package/src/config/index.ts +119 -0
- package/src/config/interpolate.ts +189 -0
- package/src/config/loader.ts +472 -0
- package/src/config/merge.ts +246 -0
- package/src/config/parser.ts +376 -0
- package/src/config/schema.ts +346 -0
- package/src/fleet-manager/__tests__/coverage.test.ts +2869 -0
- package/src/fleet-manager/__tests__/errors.test.ts +660 -0
- package/src/fleet-manager/__tests__/event-helpers.test.ts +448 -0
- package/src/fleet-manager/__tests__/integration.test.ts +1209 -0
- package/src/fleet-manager/__tests__/job-control.test.ts +283 -0
- package/src/fleet-manager/__tests__/job-manager.test.ts +869 -0
- package/src/fleet-manager/__tests__/job-queue.test.ts +401 -0
- package/src/fleet-manager/__tests__/reload.test.ts +751 -0
- package/src/fleet-manager/__tests__/status-queries.test.ts +595 -0
- package/src/fleet-manager/__tests__/trigger.test.ts +601 -0
- package/src/fleet-manager/errors.ts +747 -0
- package/src/fleet-manager/event-types.ts +378 -0
- package/src/fleet-manager/fleet-manager.ts +2315 -0
- package/src/fleet-manager/index.ts +128 -0
- package/src/fleet-manager/job-manager.ts +663 -0
- package/src/fleet-manager/job-queue.ts +798 -0
- package/src/fleet-manager/types.ts +839 -0
- package/src/index.ts +32 -0
- package/src/runner/__tests__/errors.test.ts +382 -0
- package/src/runner/__tests__/job-executor.test.ts +1708 -0
- package/src/runner/__tests__/message-processor.test.ts +960 -0
- package/src/runner/__tests__/sdk-adapter.test.ts +626 -0
- package/src/runner/errors.ts +307 -0
- package/src/runner/index.ts +57 -0
- package/src/runner/job-executor.ts +448 -0
- package/src/runner/message-processor.ts +355 -0
- package/src/runner/sdk-adapter.ts +191 -0
- package/src/runner/types.ts +158 -0
- package/src/scheduler/__tests__/errors.test.ts +159 -0
- package/src/scheduler/__tests__/interval.test.ts +515 -0
- package/src/scheduler/__tests__/schedule-runner.test.ts +798 -0
- package/src/scheduler/__tests__/schedule-state.test.ts +671 -0
- package/src/scheduler/__tests__/scheduler.test.ts +1280 -0
- package/src/scheduler/errors.ts +101 -0
- package/src/scheduler/index.ts +53 -0
- package/src/scheduler/interval.ts +189 -0
- package/src/scheduler/schedule-runner.ts +442 -0
- package/src/scheduler/schedule-state.ts +211 -0
- package/src/scheduler/scheduler.ts +570 -0
- package/src/scheduler/types.ts +216 -0
- package/src/state/__tests__/directory.test.ts +595 -0
- package/src/state/__tests__/fleet-state.test.ts +868 -0
- package/src/state/__tests__/job-metadata-schema.test.ts +414 -0
- package/src/state/__tests__/job-metadata.test.ts +831 -0
- package/src/state/__tests__/job-output.test.ts +856 -0
- package/src/state/__tests__/session-schema.test.ts +378 -0
- package/src/state/__tests__/session.test.ts +604 -0
- package/src/state/directory.ts +217 -0
- package/src/state/errors.ts +97 -0
- package/src/state/fleet-state.ts +284 -0
- package/src/state/index.ts +79 -0
- package/src/state/job-metadata.ts +445 -0
- package/src/state/job-output.ts +316 -0
- package/src/state/schemas/__tests__/job-output.test.ts +338 -0
- package/src/state/schemas/fleet-state.ts +120 -0
- package/src/state/schemas/index.ts +67 -0
- package/src/state/schemas/job-metadata.ts +181 -0
- package/src/state/schemas/job-output.ts +177 -0
- package/src/state/schemas/session-info.ts +92 -0
- package/src/state/session.ts +253 -0
- package/src/state/types.ts +59 -0
- package/src/state/utils/__tests__/atomic.test.ts +723 -0
- package/src/state/utils/__tests__/reads.test.ts +1071 -0
- package/src/state/utils/atomic.ts +221 -0
- package/src/state/utils/index.ts +6 -0
- package/src/state/utils/reads.ts +512 -0
- package/src/work-sources/__tests__/github.test.ts +1800 -0
- package/src/work-sources/__tests__/manager.test.ts +529 -0
- package/src/work-sources/__tests__/registry.test.ts +477 -0
- package/src/work-sources/__tests__/types.test.ts +479 -0
- package/src/work-sources/adapters/github.ts +1166 -0
- package/src/work-sources/adapters/index.ts +64 -0
- package/src/work-sources/errors.ts +71 -0
- package/src/work-sources/index.ts +148 -0
- package/src/work-sources/manager.ts +413 -0
- package/src/work-sources/registry.ts +178 -0
- package/src/work-sources/types.ts +161 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +19 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Work Source Adapters
|
|
3
|
+
*
|
|
4
|
+
* This module exports built-in adapters and registers them with the
|
|
5
|
+
* work source registry at module load time.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { registerWorkSource, isWorkSourceRegistered } from "../registry.js";
|
|
9
|
+
import {
|
|
10
|
+
createGitHubAdapter,
|
|
11
|
+
GitHubWorkSourceAdapter,
|
|
12
|
+
GitHubAPIError,
|
|
13
|
+
GitHubAuthError,
|
|
14
|
+
extractRateLimitInfo,
|
|
15
|
+
isRateLimitResponse,
|
|
16
|
+
calculateBackoffDelay,
|
|
17
|
+
type GitHubWorkSourceConfig,
|
|
18
|
+
type GitHubIssue,
|
|
19
|
+
type RateLimitInfo,
|
|
20
|
+
type RateLimitWarningOptions,
|
|
21
|
+
type RetryOptions,
|
|
22
|
+
} from "./github.js";
|
|
23
|
+
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// Re-export Adapters
|
|
26
|
+
// =============================================================================
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
GitHubWorkSourceAdapter,
|
|
30
|
+
createGitHubAdapter,
|
|
31
|
+
GitHubAPIError,
|
|
32
|
+
GitHubAuthError,
|
|
33
|
+
extractRateLimitInfo,
|
|
34
|
+
isRateLimitResponse,
|
|
35
|
+
calculateBackoffDelay,
|
|
36
|
+
};
|
|
37
|
+
export type {
|
|
38
|
+
GitHubWorkSourceConfig,
|
|
39
|
+
GitHubIssue,
|
|
40
|
+
RateLimitInfo,
|
|
41
|
+
RateLimitWarningOptions,
|
|
42
|
+
RetryOptions,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// Auto-registration of Built-in Adapters
|
|
47
|
+
// =============================================================================
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Register built-in adapters
|
|
51
|
+
*
|
|
52
|
+
* This function is called automatically when the module is imported.
|
|
53
|
+
* It only registers adapters that haven't already been registered,
|
|
54
|
+
* allowing tests to pre-register mocks before importing this module.
|
|
55
|
+
*/
|
|
56
|
+
function registerBuiltInAdapters(): void {
|
|
57
|
+
// Register GitHub adapter if not already registered
|
|
58
|
+
if (!isWorkSourceRegistered("github")) {
|
|
59
|
+
registerWorkSource("github", createGitHubAdapter);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Auto-register on module load
|
|
64
|
+
registerBuiltInAdapters();
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classes for work-sources module
|
|
3
|
+
*
|
|
4
|
+
* Provides typed errors with descriptive messages for work source operations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Base Error Class
|
|
9
|
+
// =============================================================================
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base error class for all work source errors
|
|
13
|
+
*/
|
|
14
|
+
export class WorkSourceError extends Error {
|
|
15
|
+
constructor(message: string, options?: { cause?: Error }) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "WorkSourceError";
|
|
18
|
+
this.cause = options?.cause;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// Registry Errors
|
|
24
|
+
// =============================================================================
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when attempting to get a work source adapter for an unregistered type
|
|
28
|
+
*
|
|
29
|
+
* This error indicates that no factory has been registered for the requested
|
|
30
|
+
* work source type. Use `registerWorkSource()` to register a factory before
|
|
31
|
+
* attempting to get an adapter.
|
|
32
|
+
*/
|
|
33
|
+
export class UnknownWorkSourceError extends WorkSourceError {
|
|
34
|
+
/** The work source type that was requested */
|
|
35
|
+
public readonly sourceType: string;
|
|
36
|
+
/** List of currently registered work source types */
|
|
37
|
+
public readonly availableTypes: string[];
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
sourceType: string,
|
|
41
|
+
availableTypes: string[],
|
|
42
|
+
options?: { cause?: Error }
|
|
43
|
+
) {
|
|
44
|
+
const availableList =
|
|
45
|
+
availableTypes.length > 0 ? availableTypes.join(", ") : "none";
|
|
46
|
+
super(
|
|
47
|
+
`Unknown work source type: "${sourceType}". Available types: ${availableList}`,
|
|
48
|
+
options
|
|
49
|
+
);
|
|
50
|
+
this.name = "UnknownWorkSourceError";
|
|
51
|
+
this.sourceType = sourceType;
|
|
52
|
+
this.availableTypes = availableTypes;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Error thrown when attempting to register a work source type that is already registered
|
|
58
|
+
*/
|
|
59
|
+
export class DuplicateWorkSourceError extends WorkSourceError {
|
|
60
|
+
/** The work source type that was already registered */
|
|
61
|
+
public readonly sourceType: string;
|
|
62
|
+
|
|
63
|
+
constructor(sourceType: string, options?: { cause?: Error }) {
|
|
64
|
+
super(
|
|
65
|
+
`Work source type "${sourceType}" is already registered. Use a different type name or unregister the existing one first.`,
|
|
66
|
+
options
|
|
67
|
+
);
|
|
68
|
+
this.name = "DuplicateWorkSourceError";
|
|
69
|
+
this.sourceType = sourceType;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work Sources Module
|
|
3
|
+
*
|
|
4
|
+
* Provides a common interface for fetching and managing work items
|
|
5
|
+
* from various sources (GitHub Issues, Linear, etc.).
|
|
6
|
+
*
|
|
7
|
+
* All work source adapters implement the WorkSource interface to ensure
|
|
8
|
+
* consistent behavior across different backends.
|
|
9
|
+
*
|
|
10
|
+
* The registry allows dynamic registration of adapter factories,
|
|
11
|
+
* enabling extensibility without modifying core code.
|
|
12
|
+
*
|
|
13
|
+
* The WorkSourceManager interface defines the contract between work sources
|
|
14
|
+
* and the scheduler/runner, allowing clean integration without coupling.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Re-export all types
|
|
18
|
+
export * from "./types.js";
|
|
19
|
+
|
|
20
|
+
// Re-export errors
|
|
21
|
+
export * from "./errors.js";
|
|
22
|
+
|
|
23
|
+
// Re-export manager interface and types
|
|
24
|
+
export type {
|
|
25
|
+
WorkSourceManager,
|
|
26
|
+
WorkSourceManagerFactory,
|
|
27
|
+
GetNextWorkItemOptions,
|
|
28
|
+
GetNextWorkItemResult,
|
|
29
|
+
ReleaseWorkItemOptions,
|
|
30
|
+
ReportOutcomeOptions,
|
|
31
|
+
} from "./manager.js";
|
|
32
|
+
|
|
33
|
+
// Re-export registry functions and types
|
|
34
|
+
export {
|
|
35
|
+
registerWorkSource,
|
|
36
|
+
getWorkSource,
|
|
37
|
+
getRegisteredTypes,
|
|
38
|
+
isWorkSourceRegistered,
|
|
39
|
+
unregisterWorkSource,
|
|
40
|
+
clearWorkSourceRegistry,
|
|
41
|
+
} from "./registry.js";
|
|
42
|
+
export type { WorkSourceConfig, WorkSourceFactory } from "./registry.js";
|
|
43
|
+
|
|
44
|
+
// Re-export built-in adapters (also triggers auto-registration)
|
|
45
|
+
export * from "./adapters/index.js";
|
|
46
|
+
|
|
47
|
+
// Import types for interface definition
|
|
48
|
+
import type {
|
|
49
|
+
WorkItem,
|
|
50
|
+
FetchOptions,
|
|
51
|
+
FetchResult,
|
|
52
|
+
ClaimResult,
|
|
53
|
+
WorkResult,
|
|
54
|
+
ReleaseOptions,
|
|
55
|
+
ReleaseResult,
|
|
56
|
+
} from "./types.js";
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// WorkSourceAdapter Interface
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Common interface for all work source adapters
|
|
64
|
+
*
|
|
65
|
+
* Work sources provide work items from external systems (GitHub, Linear, etc.)
|
|
66
|
+
* and handle the lifecycle of claiming, completing, and releasing work.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const github = new GitHubWorkSourceAdapter({ owner: 'org', repo: 'repo' });
|
|
71
|
+
*
|
|
72
|
+
* // Fetch available work
|
|
73
|
+
* const { items } = await github.fetchAvailableWork({ labels: ['agent-ready'] });
|
|
74
|
+
*
|
|
75
|
+
* // Claim a work item
|
|
76
|
+
* const claim = await github.claimWork(items[0].id);
|
|
77
|
+
* if (claim.success) {
|
|
78
|
+
* // Do work...
|
|
79
|
+
* await github.completeWork(items[0].id, { outcome: 'success', summary: 'Fixed the bug' });
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export interface WorkSourceAdapter {
|
|
84
|
+
/**
|
|
85
|
+
* The type identifier for this work source (e.g., 'github', 'linear')
|
|
86
|
+
*
|
|
87
|
+
* Used to prefix work item IDs and identify the source in logs/state.
|
|
88
|
+
*/
|
|
89
|
+
readonly type: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Fetch available work items from the source
|
|
93
|
+
*
|
|
94
|
+
* Returns work items that match the specified filters and are available
|
|
95
|
+
* to be claimed (not already in progress by another agent).
|
|
96
|
+
*
|
|
97
|
+
* @param options - Filtering and pagination options
|
|
98
|
+
* @returns Promise resolving to fetched items with pagination info
|
|
99
|
+
*/
|
|
100
|
+
fetchAvailableWork(options?: FetchOptions): Promise<FetchResult>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Claim a work item for processing
|
|
104
|
+
*
|
|
105
|
+
* Marks the work item as in-progress in the external system to prevent
|
|
106
|
+
* other agents from picking it up. The exact mechanism depends on the
|
|
107
|
+
* source (e.g., adding a label, assigning to a bot user).
|
|
108
|
+
*
|
|
109
|
+
* @param workItemId - The ID of the work item to claim
|
|
110
|
+
* @returns Promise resolving to the claim result
|
|
111
|
+
*/
|
|
112
|
+
claimWork(workItemId: string): Promise<ClaimResult>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Complete a work item with the given result
|
|
116
|
+
*
|
|
117
|
+
* Updates the external system to reflect completion (e.g., closing an issue,
|
|
118
|
+
* adding a comment with the summary). The work item is released from claim.
|
|
119
|
+
*
|
|
120
|
+
* @param workItemId - The ID of the work item to complete
|
|
121
|
+
* @param result - The outcome and details of the work
|
|
122
|
+
* @returns Promise resolving when the completion is recorded
|
|
123
|
+
*/
|
|
124
|
+
completeWork(workItemId: string, result: WorkResult): Promise<void>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Release a claimed work item without completing it
|
|
128
|
+
*
|
|
129
|
+
* Returns the work item to available status so other agents can claim it.
|
|
130
|
+
* Use this when an agent cannot complete the work (e.g., timeout, error).
|
|
131
|
+
*
|
|
132
|
+
* @param workItemId - The ID of the work item to release
|
|
133
|
+
* @param options - Options for the release (reason, add comment, etc.)
|
|
134
|
+
* @returns Promise resolving to the release result
|
|
135
|
+
*/
|
|
136
|
+
releaseWork(workItemId: string, options?: ReleaseOptions): Promise<ReleaseResult>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Get a specific work item by ID
|
|
140
|
+
*
|
|
141
|
+
* Fetches the current state of a work item from the source.
|
|
142
|
+
* Returns undefined if the work item doesn't exist.
|
|
143
|
+
*
|
|
144
|
+
* @param workItemId - The ID of the work item to fetch
|
|
145
|
+
* @returns Promise resolving to the work item or undefined
|
|
146
|
+
*/
|
|
147
|
+
getWork(workItemId: string): Promise<WorkItem | undefined>;
|
|
148
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work Source Manager Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract between work sources and the scheduler/runner.
|
|
5
|
+
* The scheduler uses this interface to fetch work, report outcomes,
|
|
6
|
+
* and manage work source instances per agent.
|
|
7
|
+
*
|
|
8
|
+
* This module defines ONLY the interface - no scheduler logic is implemented here.
|
|
9
|
+
* The scheduler implementation will import and use this interface.
|
|
10
|
+
*
|
|
11
|
+
* @example Scheduler Usage Pattern
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // The scheduler will use the manager like this:
|
|
14
|
+
* const manager: WorkSourceManager = getWorkSourceManager();
|
|
15
|
+
*
|
|
16
|
+
* // 1. Get next available work for an agent
|
|
17
|
+
* const workItem = await manager.getNextWorkItem(agent);
|
|
18
|
+
* if (!workItem) {
|
|
19
|
+
* // No work available, scheduler may check other agents or wait
|
|
20
|
+
* return;
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // 2. Work item is already claimed by getNextWorkItem()
|
|
24
|
+
* // Build prompt from work item and execute job
|
|
25
|
+
* const prompt = buildPromptFromWorkItem(workItem);
|
|
26
|
+
* const result = await executeJob({ agent, prompt, ... });
|
|
27
|
+
*
|
|
28
|
+
* // 3. Report outcome to update external system
|
|
29
|
+
* await manager.reportOutcome(workItem.id, {
|
|
30
|
+
* outcome: result.success ? 'success' : 'failure',
|
|
31
|
+
* summary: result.summary ?? 'Job completed',
|
|
32
|
+
* error: result.error?.message,
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Error Handling Pattern
|
|
37
|
+
* ```typescript
|
|
38
|
+
* try {
|
|
39
|
+
* const workItem = await manager.getNextWorkItem(agent);
|
|
40
|
+
* // ... execute work ...
|
|
41
|
+
* await manager.reportOutcome(workItem.id, { outcome: 'success', summary: '...' });
|
|
42
|
+
* } catch (error) {
|
|
43
|
+
* // On unexpected error, release the work item back to available pool
|
|
44
|
+
* if (workItem) {
|
|
45
|
+
* await manager.releaseWorkItem(workItem.id, `Unexpected error: ${error.message}`);
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Multiple Agents Pattern
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Manager caches adapters per agent to avoid repeated instantiation
|
|
53
|
+
* for (const agent of agents) {
|
|
54
|
+
* // Each call uses cached adapter for the agent's work source
|
|
55
|
+
* const workItem = await manager.getNextWorkItem(agent);
|
|
56
|
+
* // ...
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
import type { ResolvedAgent } from "../config/loader.js";
|
|
62
|
+
import type {
|
|
63
|
+
WorkItem,
|
|
64
|
+
WorkResult,
|
|
65
|
+
ClaimResult,
|
|
66
|
+
ReleaseResult,
|
|
67
|
+
ReleaseOptions,
|
|
68
|
+
FetchOptions,
|
|
69
|
+
} from "./types.js";
|
|
70
|
+
import type { WorkSourceAdapter } from "./index.js";
|
|
71
|
+
|
|
72
|
+
// =============================================================================
|
|
73
|
+
// Manager Types
|
|
74
|
+
// =============================================================================
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Options for fetching the next work item
|
|
78
|
+
*
|
|
79
|
+
* Allows the scheduler to customize work item selection beyond
|
|
80
|
+
* what's configured in the agent's work source.
|
|
81
|
+
*/
|
|
82
|
+
export interface GetNextWorkItemOptions {
|
|
83
|
+
/**
|
|
84
|
+
* Additional labels to filter by (combined with agent's configured labels)
|
|
85
|
+
*/
|
|
86
|
+
labels?: string[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Whether to automatically claim the work item
|
|
90
|
+
* Defaults to true - the scheduler typically wants to claim immediately
|
|
91
|
+
*/
|
|
92
|
+
autoClaim?: boolean;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Custom fetch options to pass to the adapter
|
|
96
|
+
* These override the default options for this specific fetch
|
|
97
|
+
*/
|
|
98
|
+
fetchOptions?: Partial<FetchOptions>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Result of getting the next work item
|
|
103
|
+
*
|
|
104
|
+
* Includes both the work item (if found) and claim status (if autoClaim was true).
|
|
105
|
+
* This allows the scheduler to handle various scenarios:
|
|
106
|
+
* - No work available (item is null)
|
|
107
|
+
* - Work found and claimed successfully
|
|
108
|
+
* - Work found but claim failed (race condition with another agent)
|
|
109
|
+
*/
|
|
110
|
+
export interface GetNextWorkItemResult {
|
|
111
|
+
/**
|
|
112
|
+
* The work item, or null if no work is available
|
|
113
|
+
*/
|
|
114
|
+
item: WorkItem | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Whether the work item was claimed
|
|
118
|
+
* Only relevant when autoClaim is true and item is not null
|
|
119
|
+
*/
|
|
120
|
+
claimed: boolean;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Claim result details if claiming was attempted
|
|
124
|
+
* Contains failure reason if claimed is false
|
|
125
|
+
*/
|
|
126
|
+
claimResult?: ClaimResult;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Options for releasing a work item
|
|
131
|
+
*/
|
|
132
|
+
export interface ReleaseWorkItemOptions extends ReleaseOptions {
|
|
133
|
+
/**
|
|
134
|
+
* The agent that claimed the work item
|
|
135
|
+
* Used to resolve the correct adapter for the release operation
|
|
136
|
+
*/
|
|
137
|
+
agent: ResolvedAgent;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Options for reporting work outcome
|
|
142
|
+
*/
|
|
143
|
+
export interface ReportOutcomeOptions {
|
|
144
|
+
/**
|
|
145
|
+
* The agent that processed the work item
|
|
146
|
+
* Used to resolve the correct adapter for the completion operation
|
|
147
|
+
*/
|
|
148
|
+
agent: ResolvedAgent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// =============================================================================
|
|
152
|
+
// WorkSourceManager Interface
|
|
153
|
+
// =============================================================================
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Interface for managing work sources and coordinating with the scheduler
|
|
157
|
+
*
|
|
158
|
+
* The WorkSourceManager provides a high-level interface for the scheduler to:
|
|
159
|
+
* 1. Fetch available work items for agents
|
|
160
|
+
* 2. Claim work items to prevent race conditions
|
|
161
|
+
* 3. Report outcomes after job completion
|
|
162
|
+
* 4. Release work items on error/timeout
|
|
163
|
+
*
|
|
164
|
+
* The manager handles:
|
|
165
|
+
* - Work source adapter instantiation and caching per agent
|
|
166
|
+
* - Resolving work source configuration from agent configs
|
|
167
|
+
* - Coordinating claim/release lifecycle
|
|
168
|
+
*
|
|
169
|
+
* Implementation Notes for Scheduler Authors:
|
|
170
|
+
* - Call getNextWorkItem() with autoClaim=true (default) for atomic fetch+claim
|
|
171
|
+
* - Always call reportOutcome() or releaseWorkItem() after processing
|
|
172
|
+
* - The manager caches adapters, so repeated calls are efficient
|
|
173
|
+
* - If an agent has no work_source configured, getNextWorkItem returns { item: null }
|
|
174
|
+
*
|
|
175
|
+
* @example Basic Scheduler Loop
|
|
176
|
+
* ```typescript
|
|
177
|
+
* async function processAgent(manager: WorkSourceManager, agent: ResolvedAgent) {
|
|
178
|
+
* // Check if we can run more instances
|
|
179
|
+
* if (activeJobs[agent.name] >= (agent.instances?.max_concurrent ?? 1)) {
|
|
180
|
+
* return; // Already at capacity
|
|
181
|
+
* }
|
|
182
|
+
*
|
|
183
|
+
* // Try to get work
|
|
184
|
+
* const { item, claimed, claimResult } = await manager.getNextWorkItem(agent);
|
|
185
|
+
*
|
|
186
|
+
* if (!item) {
|
|
187
|
+
* return; // No work available
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* if (!claimed) {
|
|
191
|
+
* // Someone else claimed it first (race condition)
|
|
192
|
+
* console.log(`Work ${item.id} claimed by another agent: ${claimResult?.reason}`);
|
|
193
|
+
* return;
|
|
194
|
+
* }
|
|
195
|
+
*
|
|
196
|
+
* // Execute the job
|
|
197
|
+
* try {
|
|
198
|
+
* const result = await executeJob(agent, item);
|
|
199
|
+
* await manager.reportOutcome(item.id, result, { agent });
|
|
200
|
+
* } catch (error) {
|
|
201
|
+
* await manager.releaseWorkItem(item.id, {
|
|
202
|
+
* agent,
|
|
203
|
+
* reason: error.message,
|
|
204
|
+
* addComment: true,
|
|
205
|
+
* });
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export interface WorkSourceManager {
|
|
211
|
+
/**
|
|
212
|
+
* Get the next available work item for an agent
|
|
213
|
+
*
|
|
214
|
+
* Fetches the highest priority available work item from the agent's
|
|
215
|
+
* configured work source. By default, also claims the item atomically
|
|
216
|
+
* to prevent race conditions with other agents.
|
|
217
|
+
*
|
|
218
|
+
* @param agent - The resolved agent configuration
|
|
219
|
+
* @param options - Options for fetching and claiming
|
|
220
|
+
* @returns Result containing the work item (if any) and claim status
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* - Returns { item: null, claimed: false } if agent has no work_source
|
|
224
|
+
* - Returns { item: null, claimed: false } if no work is available
|
|
225
|
+
* - With autoClaim=true, claimed=false means another agent claimed it first
|
|
226
|
+
* - The scheduler should handle claim failures by retrying or moving on
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const result = await manager.getNextWorkItem(agent);
|
|
231
|
+
*
|
|
232
|
+
* if (!result.item) {
|
|
233
|
+
* console.log('No work available for agent:', agent.name);
|
|
234
|
+
* return;
|
|
235
|
+
* }
|
|
236
|
+
*
|
|
237
|
+
* if (!result.claimed) {
|
|
238
|
+
* console.log('Work was claimed by another agent');
|
|
239
|
+
* return;
|
|
240
|
+
* }
|
|
241
|
+
*
|
|
242
|
+
* // Safe to process the work item
|
|
243
|
+
* console.log('Processing:', result.item.title);
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
getNextWorkItem(
|
|
247
|
+
agent: ResolvedAgent,
|
|
248
|
+
options?: GetNextWorkItemOptions
|
|
249
|
+
): Promise<GetNextWorkItemResult>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Report the outcome of processing a work item
|
|
253
|
+
*
|
|
254
|
+
* Updates the external system (GitHub, Linear, etc.) with the job result.
|
|
255
|
+
* This typically involves:
|
|
256
|
+
* - Adding a comment with the summary
|
|
257
|
+
* - Closing the issue/task if successful
|
|
258
|
+
* - Removing in-progress labels
|
|
259
|
+
* - Adding completion labels
|
|
260
|
+
*
|
|
261
|
+
* @param taskId - The work item ID (from WorkItem.id)
|
|
262
|
+
* @param result - The outcome of the work
|
|
263
|
+
* @param options - Options including the agent that processed the item
|
|
264
|
+
*
|
|
265
|
+
* @remarks
|
|
266
|
+
* - Must be called after job completion (success or failure)
|
|
267
|
+
* - For failures, use result.outcome='failure' and include result.error
|
|
268
|
+
* - The external system behavior depends on the adapter implementation
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* // Success case
|
|
273
|
+
* await manager.reportOutcome(
|
|
274
|
+
* workItem.id,
|
|
275
|
+
* {
|
|
276
|
+
* outcome: 'success',
|
|
277
|
+
* summary: 'Fixed the authentication bug',
|
|
278
|
+
* details: 'Updated the JWT validation logic...',
|
|
279
|
+
* artifacts: ['https://github.com/org/repo/pull/123'],
|
|
280
|
+
* },
|
|
281
|
+
* { agent }
|
|
282
|
+
* );
|
|
283
|
+
*
|
|
284
|
+
* // Failure case
|
|
285
|
+
* await manager.reportOutcome(
|
|
286
|
+
* workItem.id,
|
|
287
|
+
* {
|
|
288
|
+
* outcome: 'failure',
|
|
289
|
+
* summary: 'Unable to reproduce the issue',
|
|
290
|
+
* error: 'Tests pass on all environments',
|
|
291
|
+
* },
|
|
292
|
+
* { agent }
|
|
293
|
+
* );
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
reportOutcome(
|
|
297
|
+
taskId: string,
|
|
298
|
+
result: WorkResult,
|
|
299
|
+
options: ReportOutcomeOptions
|
|
300
|
+
): Promise<void>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Release a claimed work item without completing it
|
|
304
|
+
*
|
|
305
|
+
* Returns the work item to the available pool so other agents can claim it.
|
|
306
|
+
* Use this when:
|
|
307
|
+
* - Job times out
|
|
308
|
+
* - Unexpected error prevents completion
|
|
309
|
+
* - Agent is shutting down mid-task
|
|
310
|
+
* - Manual intervention is needed
|
|
311
|
+
*
|
|
312
|
+
* @param taskId - The work item ID (from WorkItem.id)
|
|
313
|
+
* @param options - Release options including reason and agent
|
|
314
|
+
* @returns Result indicating if the release was successful
|
|
315
|
+
*
|
|
316
|
+
* @remarks
|
|
317
|
+
* - Always call this or reportOutcome after claiming work
|
|
318
|
+
* - If addComment is true, posts a comment explaining the release
|
|
319
|
+
* - The work item becomes available for other agents to claim
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* // On timeout
|
|
324
|
+
* await manager.releaseWorkItem(workItem.id, {
|
|
325
|
+
* agent,
|
|
326
|
+
* reason: 'Job timed out after 30 minutes',
|
|
327
|
+
* addComment: true,
|
|
328
|
+
* });
|
|
329
|
+
*
|
|
330
|
+
* // On error
|
|
331
|
+
* await manager.releaseWorkItem(workItem.id, {
|
|
332
|
+
* agent,
|
|
333
|
+
* reason: `Unexpected error: ${error.message}`,
|
|
334
|
+
* addComment: true,
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
releaseWorkItem(
|
|
339
|
+
taskId: string,
|
|
340
|
+
options: ReleaseWorkItemOptions
|
|
341
|
+
): Promise<ReleaseResult>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Get the work source adapter for an agent
|
|
345
|
+
*
|
|
346
|
+
* Returns the cached adapter instance for the agent's work source,
|
|
347
|
+
* or null if the agent has no work source configured.
|
|
348
|
+
*
|
|
349
|
+
* This is useful for:
|
|
350
|
+
* - Direct adapter operations not covered by the manager
|
|
351
|
+
* - Inspecting adapter state or configuration
|
|
352
|
+
* - Testing and debugging
|
|
353
|
+
*
|
|
354
|
+
* @param agent - The resolved agent configuration
|
|
355
|
+
* @returns The adapter instance or null
|
|
356
|
+
*
|
|
357
|
+
* @remarks
|
|
358
|
+
* - Adapters are cached per agent (by agent name + work source type)
|
|
359
|
+
* - Creating new adapters is cheap but caching improves consistency
|
|
360
|
+
* - The adapter is created lazily on first access
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* const adapter = await manager.getAdapter(agent);
|
|
365
|
+
*
|
|
366
|
+
* if (!adapter) {
|
|
367
|
+
* console.log('Agent has no work source configured');
|
|
368
|
+
* return;
|
|
369
|
+
* }
|
|
370
|
+
*
|
|
371
|
+
* // Direct adapter operations
|
|
372
|
+
* const workItem = await adapter.getWork('github:12345');
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
getAdapter(agent: ResolvedAgent): Promise<WorkSourceAdapter | null>;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Clear the adapter cache
|
|
379
|
+
*
|
|
380
|
+
* Removes all cached adapter instances. Use this when:
|
|
381
|
+
* - Configuration has changed and adapters need to be recreated
|
|
382
|
+
* - Testing requires fresh adapter instances
|
|
383
|
+
* - Memory cleanup is needed
|
|
384
|
+
*
|
|
385
|
+
* @remarks
|
|
386
|
+
* - Subsequent getAdapter/getNextWorkItem calls will create new adapters
|
|
387
|
+
* - In-flight operations on old adapters are not affected
|
|
388
|
+
* - Does not affect external system state
|
|
389
|
+
*/
|
|
390
|
+
clearCache(): void;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// =============================================================================
|
|
394
|
+
// Factory Function Type
|
|
395
|
+
// =============================================================================
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Factory function for creating WorkSourceManager instances
|
|
399
|
+
*
|
|
400
|
+
* The scheduler will use this to get a manager instance. The default
|
|
401
|
+
* implementation is provided by the work-sources module, but this can
|
|
402
|
+
* be customized for testing or advanced use cases.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* // Default usage
|
|
407
|
+
* const manager = createWorkSourceManager();
|
|
408
|
+
*
|
|
409
|
+
* // With custom options (future extension point)
|
|
410
|
+
* const manager = createWorkSourceManager({ cache: customCache });
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export type WorkSourceManagerFactory = () => WorkSourceManager;
|