@hold-rein/cli 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/api/app.d.ts +7 -0
- package/dist/runtime/api/app.d.ts.map +1 -0
- package/dist/runtime/api/app.js +41 -0
- package/dist/runtime/api/config/const.d.ts +8 -0
- package/dist/runtime/api/config/const.d.ts.map +1 -0
- package/dist/runtime/api/config/const.js +9 -0
- package/dist/runtime/api/config/env.d.ts +10 -0
- package/dist/runtime/api/config/env.d.ts.map +1 -0
- package/dist/runtime/api/config/env.js +32 -0
- package/dist/runtime/api/db/connection.d.ts +11 -0
- package/dist/runtime/api/db/connection.d.ts.map +1 -0
- package/dist/runtime/api/db/connection.js +21 -0
- package/dist/runtime/api/db/index.d.ts +4 -0
- package/dist/runtime/api/db/index.d.ts.map +1 -0
- package/dist/runtime/api/db/index.js +3 -0
- package/dist/runtime/api/db/migrate.d.ts +4 -0
- package/dist/runtime/api/db/migrate.d.ts.map +1 -0
- package/dist/runtime/api/db/migrate.js +308 -0
- package/dist/runtime/api/db/schema.d.ts +1610 -0
- package/dist/runtime/api/db/schema.d.ts.map +1 -0
- package/dist/runtime/api/db/schema.js +148 -0
- package/dist/runtime/api/middleware/error-middleware.d.ts +3 -0
- package/dist/runtime/api/middleware/error-middleware.d.ts.map +1 -0
- package/dist/runtime/api/middleware/error-middleware.js +5 -0
- package/dist/runtime/api/middleware/not-found-middleware.d.ts +3 -0
- package/dist/runtime/api/middleware/not-found-middleware.d.ts.map +1 -0
- package/dist/runtime/api/middleware/not-found-middleware.js +4 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts +10 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/active-task-run-registry.js +20 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.d.ts +7 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-approval-store.js +23 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.d.ts +8 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-event-bus.js +40 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.d.ts +22 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-message-repository.js +60 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.d.ts +4 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-message-storage.js +11 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts +4 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-model-resolver.js +17 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime-messages.js +19 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime-support.js +38 -0
- package/dist/runtime/api/modules/agents/agent-runtime.d.ts +25 -0
- package/dist/runtime/api/modules/agents/agent-runtime.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-runtime.js +371 -0
- package/dist/runtime/api/modules/agents/agent-subagents.d.ts +32 -0
- package/dist/runtime/api/modules/agents/agent-subagents.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-subagents.js +65 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.d.ts +9 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-task-actions.js +33 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts +15 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-task-title-generator.js +61 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts +12 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-tool-approval.js +40 -0
- package/dist/runtime/api/modules/agents/agent-types.d.ts +198 -0
- package/dist/runtime/api/modules/agents/agent-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agent-types.js +1 -0
- package/dist/runtime/api/modules/agents/agents-router.d.ts +7 -0
- package/dist/runtime/api/modules/agents/agents-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agents-router.js +210 -0
- package/dist/runtime/api/modules/agents/agents-service.d.ts +52 -0
- package/dist/runtime/api/modules/agents/agents-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/agents-service.js +282 -0
- package/dist/runtime/api/modules/agents/approval/store.d.ts +7 -0
- package/dist/runtime/api/modules/agents/approval/store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/approval/store.js +23 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts +14 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/approval/tool-approval.js +43 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.d.ts +16 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/custom-agent-model.js +21 -0
- package/dist/runtime/api/modules/agents/default-agents-service.d.ts +3 -0
- package/dist/runtime/api/modules/agents/default-agents-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/default-agents-service.js +52 -0
- package/dist/runtime/api/modules/agents/event/event-bus.d.ts +8 -0
- package/dist/runtime/api/modules/agents/event/event-bus.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/event/event-bus.js +40 -0
- package/dist/runtime/api/modules/agents/index.d.ts +11 -0
- package/dist/runtime/api/modules/agents/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/index.js +9 -0
- package/dist/runtime/api/modules/agents/message/storage.d.ts +4 -0
- package/dist/runtime/api/modules/agents/message/storage.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/message/storage.js +11 -0
- package/dist/runtime/api/modules/agents/model/custom-model.d.ts +16 -0
- package/dist/runtime/api/modules/agents/model/custom-model.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/model/custom-model.js +21 -0
- package/dist/runtime/api/modules/agents/model/resolver.d.ts +4 -0
- package/dist/runtime/api/modules/agents/model/resolver.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/model/resolver.js +17 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts +8 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/browser-tool-result.js +35 -0
- package/dist/runtime/api/modules/agents/router/index.d.ts +10 -0
- package/dist/runtime/api/modules/agents/router/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/index.js +210 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.d.ts +24 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/router/request-parsing.js +78 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts +5 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.js +115 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts +13 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.js +31 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts +21 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.js +69 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts +26 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/continuation-subagent.js +67 -0
- package/dist/runtime/api/modules/agents/runtime/index.d.ts +3 -0
- package/dist/runtime/api/modules/agents/runtime/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/index.js +432 -0
- package/dist/runtime/api/modules/agents/runtime/messages.d.ts +12 -0
- package/dist/runtime/api/modules/agents/runtime/messages.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/messages.js +19 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts +22 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-results.js +39 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts +49 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/subagent-tools.js +195 -0
- package/dist/runtime/api/modules/agents/runtime/support.d.ts +19 -0
- package/dist/runtime/api/modules/agents/runtime/support.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/support.js +106 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts +28 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/token-collection.js +131 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts +15 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/token-usage-sync.js +46 -0
- package/dist/runtime/api/modules/agents/runtime/type.d.ts +62 -0
- package/dist/runtime/api/modules/agents/runtime/type.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/type.js +1 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts +3 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.js +31 -0
- package/dist/runtime/api/modules/agents/service/default.d.ts +3 -0
- package/dist/runtime/api/modules/agents/service/default.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/default.js +65 -0
- package/dist/runtime/api/modules/agents/service/index.d.ts +56 -0
- package/dist/runtime/api/modules/agents/service/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/index.js +296 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts +14 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/interrupt-task.js +34 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts +14 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/service/startup-recovery.js +15 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.d.ts +3 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/shell-command-risk.js +24 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts +4 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/shell-exec-tool.js +71 -0
- package/dist/runtime/api/modules/agents/subagent/index.d.ts +45 -0
- package/dist/runtime/api/modules/agents/subagent/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/index.js +143 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts +13 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/lifecycle.js +36 -0
- package/dist/runtime/api/modules/agents/subagent/repository.d.ts +12 -0
- package/dist/runtime/api/modules/agents/subagent/repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent/repository.js +93 -0
- package/dist/runtime/api/modules/agents/subagent-repository.d.ts +11 -0
- package/dist/runtime/api/modules/agents/subagent-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/subagent-repository.js +65 -0
- package/dist/runtime/api/modules/agents/task/actions.d.ts +10 -0
- package/dist/runtime/api/modules/agents/task/actions.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/actions.js +37 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts +10 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/active-run-registry.js +20 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.d.ts +14 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/run-monitor.js +42 -0
- package/dist/runtime/api/modules/agents/task/title-generator.d.ts +15 -0
- package/dist/runtime/api/modules/agents/task/title-generator.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task/title-generator.js +61 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.d.ts +14 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.d.ts.map +1 -0
- package/dist/runtime/api/modules/agents/task-run-monitor.js +42 -0
- package/dist/runtime/api/modules/file-system/file-system-router.d.ts +6 -0
- package/dist/runtime/api/modules/file-system/file-system-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/file-system-router.js +119 -0
- package/dist/runtime/api/modules/file-system/file-system-service.d.ts +30 -0
- package/dist/runtime/api/modules/file-system/file-system-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/file-system-service.js +209 -0
- package/dist/runtime/api/modules/file-system/index.d.ts +4 -0
- package/dist/runtime/api/modules/file-system/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/file-system/index.js +1 -0
- package/dist/runtime/api/modules/health/health-router.d.ts +3 -0
- package/dist/runtime/api/modules/health/health-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/health/health-router.js +10 -0
- package/dist/runtime/api/modules/health/index.d.ts +2 -0
- package/dist/runtime/api/modules/health/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/health/index.js +1 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts +3 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/default-model-provider-service.js +21 -0
- package/dist/runtime/api/modules/model-providers/index.d.ts +5 -0
- package/dist/runtime/api/modules/model-providers/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/index.js +4 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts +8 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.js +35 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts +51 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-provider-repository.js +314 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts +9 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-providers-router.js +188 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts +52 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-providers/model-providers-service.js +239 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts +3 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.js +22 -0
- package/dist/runtime/api/modules/model-proxies/index.d.ts +5 -0
- package/dist/runtime/api/modules/model-proxies/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/index.js +4 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts +7 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-router.js +55 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts +26 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxies-service.js +107 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts +39 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-repository.js +146 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts +20 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts.map +1 -0
- package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.js +45 -0
- package/dist/runtime/api/modules/plugins/plugins-router.d.ts +7 -0
- package/dist/runtime/api/modules/plugins/plugins-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/plugins/plugins-router.js +11 -0
- package/dist/runtime/api/modules/skills/default-skills-service.d.ts +3 -0
- package/dist/runtime/api/modules/skills/default-skills-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/default-skills-service.js +9 -0
- package/dist/runtime/api/modules/skills/index.d.ts +5 -0
- package/dist/runtime/api/modules/skills/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/index.js +3 -0
- package/dist/runtime/api/modules/skills/skills-router.d.ts +7 -0
- package/dist/runtime/api/modules/skills/skills-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-router.js +56 -0
- package/dist/runtime/api/modules/skills/skills-service.d.ts +7 -0
- package/dist/runtime/api/modules/skills/skills-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-service.js +264 -0
- package/dist/runtime/api/modules/skills/skills-types.d.ts +22 -0
- package/dist/runtime/api/modules/skills/skills-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/skills/skills-types.js +1 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts +3 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.js +17 -0
- package/dist/runtime/api/modules/usage-stats/index.d.ts +4 -0
- package/dist/runtime/api/modules/usage-stats/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/index.js +2 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts +7 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-router.js +42 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts +40 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-service.js +144 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts +39 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/usage-stats/usage-stats-types.js +1 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts +3 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/default-workspaces-service.js +20 -0
- package/dist/runtime/api/modules/workspaces/index.d.ts +6 -0
- package/dist/runtime/api/modules/workspaces/index.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/index.js +5 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts +41 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspace-repository.js +326 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.d.ts +33 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspace-types.js +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts +7 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-router.js +71 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts +24 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts.map +1 -0
- package/dist/runtime/api/modules/workspaces/workspaces-service.js +109 -0
- package/dist/runtime/api/plugin.d.ts +5 -0
- package/dist/runtime/api/plugin.d.ts.map +1 -0
- package/dist/runtime/api/plugin.js +48 -0
- package/dist/runtime/api/response/api-response.d.ts +11 -0
- package/dist/runtime/api/response/api-response.d.ts.map +1 -0
- package/dist/runtime/api/response/api-response.js +18 -0
- package/dist/runtime/api/response/index.d.ts +3 -0
- package/dist/runtime/api/response/index.d.ts.map +1 -0
- package/dist/runtime/api/response/index.js +2 -0
- package/dist/runtime/api/response/response-codes.d.ts +52 -0
- package/dist/runtime/api/response/response-codes.d.ts.map +1 -0
- package/dist/runtime/api/response/response-codes.js +44 -0
- package/dist/runtime/api/router/v1/index.d.ts +12 -0
- package/dist/runtime/api/router/v1/index.d.ts.map +1 -0
- package/dist/runtime/api/router/v1/index.js +26 -0
- package/dist/runtime/api/runtime.d.ts +15 -0
- package/dist/runtime/api/runtime.d.ts.map +1 -0
- package/dist/runtime/api/runtime.js +30 -0
- package/dist/runtime/api/server.d.ts +2 -0
- package/dist/runtime/api/server.d.ts.map +1 -0
- package/dist/runtime/api/server.js +14 -0
- package/dist/runtime/api/service/health-service.d.ts +7 -0
- package/dist/runtime/api/service/health-service.d.ts.map +1 -0
- package/dist/runtime/api/service/health-service.js +7 -0
- package/dist/runtime/web/assets/abap-DLDM7-KI.js +1 -0
- package/dist/runtime/web/assets/apex-DNDY2TF8.js +1 -0
- package/dist/runtime/web/assets/azcli-Y6nb8tq_.js +1 -0
- package/dist/runtime/web/assets/bat-BwHxbl9M.js +1 -0
- package/dist/runtime/web/assets/bicep-CFznDFnq.js +2 -0
- package/dist/runtime/web/assets/cameligo-Bf6VGUru.js +1 -0
- package/dist/runtime/web/assets/clojure-Dnu-v4kV.js +1 -0
- package/dist/runtime/web/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/runtime/web/assets/coffee-Bd8akH9Z.js +1 -0
- package/dist/runtime/web/assets/cpp-BbWJElDN.js +1 -0
- package/dist/runtime/web/assets/csharp-Co3qMtFm.js +1 -0
- package/dist/runtime/web/assets/csp-D-4FJmMZ.js +1 -0
- package/dist/runtime/web/assets/css-DdJfP1eB.js +3 -0
- package/dist/runtime/web/assets/css.worker-B4z49cGk.js +93 -0
- package/dist/runtime/web/assets/cssMode-w2xbbUEW.js +1 -0
- package/dist/runtime/web/assets/cypher-cTPe9QuQ.js +1 -0
- package/dist/runtime/web/assets/dart-BOtBlQCF.js +1 -0
- package/dist/runtime/web/assets/dockerfile-BG73LgW2.js +1 -0
- package/dist/runtime/web/assets/ecl-BEgZUVRK.js +1 -0
- package/dist/runtime/web/assets/elixir-BkW5O-1t.js +1 -0
- package/dist/runtime/web/assets/flow9-BeJ5waoc.js +1 -0
- package/dist/runtime/web/assets/freemarker2-mywz2bob.js +3 -0
- package/dist/runtime/web/assets/fsharp-PahG7c26.js +1 -0
- package/dist/runtime/web/assets/go-acbASCJo.js +1 -0
- package/dist/runtime/web/assets/graphql-BxJiqAUM.js +1 -0
- package/dist/runtime/web/assets/handlebars-Cy-2QN_R.js +1 -0
- package/dist/runtime/web/assets/hcl-DtV1sZF8.js +1 -0
- package/dist/runtime/web/assets/html-2WQMGvns.js +1 -0
- package/dist/runtime/web/assets/html.worker-DtiGdgqp.js +470 -0
- package/dist/runtime/web/assets/htmlMode-BznIdxOy.js +1 -0
- package/dist/runtime/web/assets/index-CQ_mZUpS.css +1 -0
- package/dist/runtime/web/assets/index-CtZcItCu.js +1512 -0
- package/dist/runtime/web/assets/ini-Kd9XrMLS.js +1 -0
- package/dist/runtime/web/assets/java-CXBNlu9o.js +1 -0
- package/dist/runtime/web/assets/javascript-BK6G_5BV.js +1 -0
- package/dist/runtime/web/assets/json.worker-leyajbqV.js +58 -0
- package/dist/runtime/web/assets/jsonMode-DI8_Cj0K.js +7 -0
- package/dist/runtime/web/assets/julia-cl7-CwDS.js +1 -0
- package/dist/runtime/web/assets/kotlin-s7OhZKlX.js +1 -0
- package/dist/runtime/web/assets/less-9HpZscsL.js +2 -0
- package/dist/runtime/web/assets/lexon-OrD6JF1K.js +1 -0
- package/dist/runtime/web/assets/liquid-CE7Qnc0w.js +1 -0
- package/dist/runtime/web/assets/lspLanguageFeatures-DKvGiYOU.js +4 -0
- package/dist/runtime/web/assets/lua-Cyyb5UIc.js +1 -0
- package/dist/runtime/web/assets/m3-B8OfTtLu.js +1 -0
- package/dist/runtime/web/assets/markdown-BFxVWTOG.js +1 -0
- package/dist/runtime/web/assets/mdx-Fk0ZjYeT.js +1 -0
- package/dist/runtime/web/assets/mips-CiqrrVzr.js +1 -0
- package/dist/runtime/web/assets/msdax-DmeGPVcC.js +1 -0
- package/dist/runtime/web/assets/mysql-C_tMU-Nz.js +1 -0
- package/dist/runtime/web/assets/objective-c-BDtDVThU.js +1 -0
- package/dist/runtime/web/assets/pascal-vHIfCaH5.js +1 -0
- package/dist/runtime/web/assets/pascaligo-DtZ0uQbO.js +1 -0
- package/dist/runtime/web/assets/perl-Ub6l9XKa.js +1 -0
- package/dist/runtime/web/assets/pgsql-BlNEE0v7.js +1 -0
- package/dist/runtime/web/assets/php-BBUBE1dy.js +1 -0
- package/dist/runtime/web/assets/pla-DSh2-awV.js +1 -0
- package/dist/runtime/web/assets/postiats-CocnycG-.js +1 -0
- package/dist/runtime/web/assets/powerquery-tScXyioY.js +1 -0
- package/dist/runtime/web/assets/powershell-COWaemsV.js +1 -0
- package/dist/runtime/web/assets/protobuf-Brw8urJB.js +2 -0
- package/dist/runtime/web/assets/pug-8SOpv6rk.js +1 -0
- package/dist/runtime/web/assets/python-xn7eKnQc.js +1 -0
- package/dist/runtime/web/assets/qsharp-Bw9ernYp.js +1 -0
- package/dist/runtime/web/assets/r-j7ic8hl3.js +1 -0
- package/dist/runtime/web/assets/razor-BjC5fot0.js +1 -0
- package/dist/runtime/web/assets/redis-Bu5POkcn.js +1 -0
- package/dist/runtime/web/assets/redshift-Bs9aos_-.js +1 -0
- package/dist/runtime/web/assets/restructuredtext-CqXO7rUv.js +1 -0
- package/dist/runtime/web/assets/ruby-zBfavPgS.js +1 -0
- package/dist/runtime/web/assets/rust-BzKRNQWT.js +1 -0
- package/dist/runtime/web/assets/sb-BBc9UKZt.js +1 -0
- package/dist/runtime/web/assets/scala-D9hQfWCl.js +1 -0
- package/dist/runtime/web/assets/scheme-BPhDTwHR.js +1 -0
- package/dist/runtime/web/assets/scss-CBJaRo0y.js +3 -0
- package/dist/runtime/web/assets/shell-DiJ1NA_G.js +1 -0
- package/dist/runtime/web/assets/solidity-Db0IVjzk.js +1 -0
- package/dist/runtime/web/assets/sophia-CnS9iZB_.js +1 -0
- package/dist/runtime/web/assets/sparql-CJmd_6j2.js +1 -0
- package/dist/runtime/web/assets/sql-ClhHkBeG.js +1 -0
- package/dist/runtime/web/assets/st-CHwy0fLd.js +1 -0
- package/dist/runtime/web/assets/swift-Bqt4WxQ4.js +3 -0
- package/dist/runtime/web/assets/systemverilog-Bs9z6M-B.js +1 -0
- package/dist/runtime/web/assets/tcl-Dm6ycUr_.js +1 -0
- package/dist/runtime/web/assets/ts.worker-59MjiAqk.js +67731 -0
- package/dist/runtime/web/assets/tsMode-8t6AIduV.js +11 -0
- package/dist/runtime/web/assets/twig-Csy3S7wG.js +1 -0
- package/dist/runtime/web/assets/typescript-DvPPogGC.js +1 -0
- package/dist/runtime/web/assets/typespec-Btyra-wh.js +1 -0
- package/dist/runtime/web/assets/vb-Db0cS2oM.js +1 -0
- package/dist/runtime/web/assets/wgsl-BTesnYfV.js +298 -0
- package/dist/runtime/web/assets/xml-CB8xdh8u.js +1 -0
- package/dist/runtime/web/assets/yaml-B4sXC4FA.js +1 -0
- package/dist/runtime/web/index.html +13 -0
- package/package.json +42 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AgentHarness, JsonlSessionRepoApi } from "@earendil-works/pi-agent-core/node";
|
|
2
|
+
import type { AppDatabase } from "../../../db";
|
|
3
|
+
import type { AgentRunResult, AgentSessionMetadata, BrowserToolResultInput, StoredAgentMessage, RunAgentInput } from "../agent-types";
|
|
4
|
+
import type { AgentApprovalStore } from "../approval/store";
|
|
5
|
+
import type { AgentEventBus } from "../event/event-bus";
|
|
6
|
+
import type { AgentModelLookup } from '../model/resolver';
|
|
7
|
+
import type { ModelProxiesService } from "../../model-proxies/model-proxies-service";
|
|
8
|
+
import type { SkillsService } from "../../skills";
|
|
9
|
+
import type { SubagentRepository } from "../subagent/repository";
|
|
10
|
+
import type { TokenUsageStorageTarget } from "./token-collection";
|
|
11
|
+
export interface AgentRuntime {
|
|
12
|
+
interrupt: (agentId: string) => Promise<boolean>;
|
|
13
|
+
listMessages: (input: {
|
|
14
|
+
session: AgentSessionMetadata;
|
|
15
|
+
workspacePath: string;
|
|
16
|
+
}) => Promise<StoredAgentMessage[]>;
|
|
17
|
+
start: (input: RunAgentInput) => Promise<AgentRunResult>;
|
|
18
|
+
submitBrowserToolResult?: (input: BrowserToolResultInput) => Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateAgentRuntimeOptions {
|
|
21
|
+
approvalStore: AgentApprovalStore;
|
|
22
|
+
browserToolTimeoutMs?: number;
|
|
23
|
+
eventBus: AgentEventBus;
|
|
24
|
+
getApiKey?: (provider: string, modelId: string) => Promise<string | undefined>;
|
|
25
|
+
getCustomModel?: AgentModelLookup;
|
|
26
|
+
modelProxiesService?: ModelProxiesService;
|
|
27
|
+
sessionRepo?: JsonlSessionRepoApi;
|
|
28
|
+
skillDirs?: string[];
|
|
29
|
+
skillsService?: SkillsService;
|
|
30
|
+
subagentDatabase?: AppDatabase;
|
|
31
|
+
subagentRepository: SubagentRepository;
|
|
32
|
+
tokenFlushIntervalMs?: number;
|
|
33
|
+
tokenUsageStorageTarget?: TokenUsageStorageTarget;
|
|
34
|
+
}
|
|
35
|
+
export interface RunningAgent {
|
|
36
|
+
harness: AgentHarness;
|
|
37
|
+
sessionId: string;
|
|
38
|
+
}
|
|
39
|
+
export type HarnessSession = Awaited<ReturnType<JsonlSessionRepoApi["create"]>>;
|
|
40
|
+
export interface StartHarnessOptions {
|
|
41
|
+
agentId?: string;
|
|
42
|
+
agentName?: string;
|
|
43
|
+
isContinue: boolean;
|
|
44
|
+
parentAgentId?: string;
|
|
45
|
+
pluginPrompt: string;
|
|
46
|
+
session?: HarnessSession;
|
|
47
|
+
}
|
|
48
|
+
export type CreateHarnessOptions = StartHarnessOptions & {
|
|
49
|
+
agentId: string;
|
|
50
|
+
session: HarnessSession;
|
|
51
|
+
};
|
|
52
|
+
export interface PendingVisibleCustomMessage {
|
|
53
|
+
content: string;
|
|
54
|
+
customType: string;
|
|
55
|
+
details?: unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface StartHarnessResult {
|
|
58
|
+
agentId: string;
|
|
59
|
+
harnessSession: HarnessSession;
|
|
60
|
+
session: AgentSessionMetadata;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/runtime/type.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function readWorkspaceAgentInstructions(workspacePath: string): Promise<string | undefined>;
|
|
2
|
+
export declare function formatWorkspaceAgentInstructionsForSystemPrompt(instructions: string | undefined): string | undefined;
|
|
3
|
+
//# sourceMappingURL=workspace-agent-instructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-agent-instructions.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/runtime/workspace-agent-instructions.ts"],"names":[],"mappings":"AAKA,wBAAsB,8BAA8B,CAClD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB7B;AAED,wBAAgB,+CAA+C,CAC7D,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CASpB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
const WORKSPACE_AGENT_INSTRUCTIONS_FILE = "AGENTS.md";
|
|
4
|
+
export async function readWorkspaceAgentInstructions(workspacePath) {
|
|
5
|
+
try {
|
|
6
|
+
const content = await readFile(join(workspacePath, WORKSPACE_AGENT_INSTRUCTIONS_FILE), "utf8");
|
|
7
|
+
const trimmedContent = content.trim();
|
|
8
|
+
return trimmedContent === "" ? undefined : trimmedContent;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (isMissingFileError(error)) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function formatWorkspaceAgentInstructionsForSystemPrompt(instructions) {
|
|
18
|
+
if (instructions === undefined) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
"Workspace AGENTS.md mandatory constraints:",
|
|
23
|
+
instructions
|
|
24
|
+
].join("\n\n");
|
|
25
|
+
}
|
|
26
|
+
function isMissingFileError(error) {
|
|
27
|
+
return (typeof error === "object" &&
|
|
28
|
+
error !== null &&
|
|
29
|
+
"code" in error &&
|
|
30
|
+
error.code === "ENOENT");
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/service/default.ts"],"names":[],"mappings":"AAUA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,GAAG,CAAC;AAU5D,wBAAgB,uBAAuB,IAAI,aAAa,CAgDvD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { loadApiEnv } from "../../../config/env.js";
|
|
2
|
+
import { DB_FILE } from "../../../config/const.js";
|
|
3
|
+
import { createDatabase, migrateDatabase } from "../../../db/index.js";
|
|
4
|
+
import { createSqliteWorkspaceRepository } from "../../workspaces/index.js";
|
|
5
|
+
import { createAgentApprovalStore } from "../approval/store.js";
|
|
6
|
+
import { getDefaultActiveTaskRunRegistry } from "../task/active-run-registry.js";
|
|
7
|
+
import { createAgentEventBus } from "../event/event-bus.js";
|
|
8
|
+
import { createAgentRuntime } from "../runtime/index.js";
|
|
9
|
+
import { createDefaultTaskTitleGenerator } from "../task/title-generator.js";
|
|
10
|
+
import { createAgentsService } from ".";
|
|
11
|
+
import { toCustomAgentModel } from "../model/custom-model.js";
|
|
12
|
+
import { createSqliteSubagentRepository } from "../subagent/repository.js";
|
|
13
|
+
import { getDefaultModelProvidersService } from "../../model-providers/index.js";
|
|
14
|
+
import { getDefaultModelProxiesService } from "../../model-proxies/index.js";
|
|
15
|
+
import { getDefaultSkillsService } from "../../skills/index.js";
|
|
16
|
+
import { recoverInterruptedAgentRuns } from "./startup-recovery.js";
|
|
17
|
+
let service;
|
|
18
|
+
export function getDefaultAgentsService() {
|
|
19
|
+
if (!service) {
|
|
20
|
+
loadApiEnv();
|
|
21
|
+
const database = createDatabase(process.env.SQLITE_DB_PATH ?? DB_FILE);
|
|
22
|
+
const approvalStore = createAgentApprovalStore();
|
|
23
|
+
const eventBus = createAgentEventBus();
|
|
24
|
+
const modelProvidersService = getDefaultModelProvidersService();
|
|
25
|
+
const modelProxiesService = getDefaultModelProxiesService();
|
|
26
|
+
const getCustomModel = createCustomModelLookup(modelProvidersService);
|
|
27
|
+
migrateDatabase(database.sqlite);
|
|
28
|
+
const repository = createSqliteWorkspaceRepository(database);
|
|
29
|
+
const subagentRepository = createSqliteSubagentRepository(database);
|
|
30
|
+
recoverInterruptedAgentRuns({
|
|
31
|
+
now: new Date().toISOString(),
|
|
32
|
+
repository,
|
|
33
|
+
subagentRepository
|
|
34
|
+
});
|
|
35
|
+
const runtime = createAgentRuntime({
|
|
36
|
+
approvalStore,
|
|
37
|
+
eventBus,
|
|
38
|
+
getApiKey: async (provider, modelId) => modelProvidersService.getConfiguredModelForProvider(provider, modelId)
|
|
39
|
+
?.apiKey,
|
|
40
|
+
getCustomModel,
|
|
41
|
+
modelProxiesService,
|
|
42
|
+
skillsService: getDefaultSkillsService(),
|
|
43
|
+
subagentDatabase: database,
|
|
44
|
+
subagentRepository,
|
|
45
|
+
tokenUsageStorageTarget: repository
|
|
46
|
+
});
|
|
47
|
+
service = createAgentsService({
|
|
48
|
+
activeTaskRuns: getDefaultActiveTaskRunRegistry(),
|
|
49
|
+
approvalStore,
|
|
50
|
+
eventBus,
|
|
51
|
+
modelProvidersService,
|
|
52
|
+
repository,
|
|
53
|
+
runtime,
|
|
54
|
+
subagentRepository,
|
|
55
|
+
titleGenerator: createDefaultTaskTitleGenerator({ getCustomModel })
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return service;
|
|
59
|
+
}
|
|
60
|
+
function createCustomModelLookup(modelProvidersService) {
|
|
61
|
+
return (provider, modelId) => {
|
|
62
|
+
const configuredModel = modelProvidersService.getConfiguredModelForProvider(provider, modelId);
|
|
63
|
+
return configuredModel ? toCustomAgentModel(configuredModel) : null;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ModelProvidersService } from "../../model-providers/model-providers-service";
|
|
2
|
+
import type { WorkspaceRepository } from "../../workspaces/workspace-repository";
|
|
3
|
+
import type { AgentApprovalStore } from "../approval/store";
|
|
4
|
+
import type { ActiveTaskRunRegistry } from "../task/active-run-registry";
|
|
5
|
+
import type { AgentEventBus, AgentEventListener } from "../event/event-bus";
|
|
6
|
+
import type { AgentRuntime } from "../runtime/type";
|
|
7
|
+
import type { TaskTitleGenerator } from "../task/title-generator";
|
|
8
|
+
import { type DeleteTaskResult } from "../task/actions";
|
|
9
|
+
import type { AgentEventSubscription, ApprovalPolicy, ApprovalDecisionInput, ApprovalDecisionResult, BrowserRuntimeContributions, BrowserToolResultInput, InterruptTaskResult, StartAgentInput, StartAgentResult, SubscribeAgentEventsInput, TaskMessageHistory, ThinkingLevel, TaskTitleResult } from "../agent-types";
|
|
10
|
+
import { type SubagentRepository } from "../subagent/repository";
|
|
11
|
+
export interface AgentsService {
|
|
12
|
+
approveAgentAction: (input: ApprovalDecisionInput) => Promise<ApprovalDecisionResult>;
|
|
13
|
+
deleteTask: (input: GetTaskTitleInput) => Promise<DeleteTaskResult>;
|
|
14
|
+
getTaskTitle: (input: GetTaskTitleInput) => Promise<TaskTitleResult | null>;
|
|
15
|
+
interruptTask: (input: GetTaskTitleInput) => Promise<InterruptTaskResult>;
|
|
16
|
+
continueTask: (input: ContinueTaskInput) => Promise<StartAgentResult | null>;
|
|
17
|
+
listTaskMessages: (input: GetTaskTitleInput) => Promise<TaskMessageHistory>;
|
|
18
|
+
renameTask: (input: RenameTaskInput) => Promise<TaskTitleResult | null>;
|
|
19
|
+
startAgent: (input: StartAgentInput) => Promise<StartAgentResult>;
|
|
20
|
+
submitBrowserToolResult: (input: BrowserToolResultInput) => Promise<BrowserToolResultInput | null>;
|
|
21
|
+
subscribeToAgentEvents: (input: SubscribeAgentEventsInput, listener: AgentEventListener) => AgentEventSubscription;
|
|
22
|
+
}
|
|
23
|
+
export interface GetTaskTitleInput {
|
|
24
|
+
taskId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface RenameTaskInput extends GetTaskTitleInput {
|
|
27
|
+
title: string;
|
|
28
|
+
}
|
|
29
|
+
interface ContinueTaskBaseInput {
|
|
30
|
+
approvalPolicy?: ApprovalPolicy;
|
|
31
|
+
prompt: string;
|
|
32
|
+
runtimeContributions?: BrowserRuntimeContributions;
|
|
33
|
+
thinkingLevel?: ThinkingLevel;
|
|
34
|
+
taskId: string;
|
|
35
|
+
}
|
|
36
|
+
export type ContinueTaskInput = ContinueTaskBaseInput & ({
|
|
37
|
+
modelId: string;
|
|
38
|
+
provider: string;
|
|
39
|
+
} | {
|
|
40
|
+
modelId?: never;
|
|
41
|
+
provider?: never;
|
|
42
|
+
});
|
|
43
|
+
export interface CreateAgentsServiceOptions {
|
|
44
|
+
activeTaskRuns?: ActiveTaskRunRegistry;
|
|
45
|
+
approvalStore: AgentApprovalStore;
|
|
46
|
+
eventBus: AgentEventBus;
|
|
47
|
+
modelProvidersService?: ModelProvidersService;
|
|
48
|
+
now?: () => Date;
|
|
49
|
+
repository: WorkspaceRepository;
|
|
50
|
+
runtime: AgentRuntime;
|
|
51
|
+
subagentRepository?: SubagentRepository;
|
|
52
|
+
titleGenerator: TaskTitleGenerator;
|
|
53
|
+
}
|
|
54
|
+
export declare function createAgentsService(options: CreateAgentsServiceOptions): AgentsService;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/service/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import { deleteTask, renameTask } from "../task/actions.js";
|
|
5
|
+
import { startTaskRun } from "../task/run-monitor.js";
|
|
6
|
+
import { interruptTaskRun } from "./interrupt-task.js";
|
|
7
|
+
import { createInMemorySubagentRepository } from "../subagent/repository.js";
|
|
8
|
+
export function createAgentsService(options) {
|
|
9
|
+
const titleJobs = new Map();
|
|
10
|
+
const now = options.now ?? (() => new Date());
|
|
11
|
+
const subagentRepository = options.subagentRepository ?? createInMemorySubagentRepository();
|
|
12
|
+
return {
|
|
13
|
+
approveAgentAction: async (input) => {
|
|
14
|
+
if (!options.approvalStore.decide(input)) {
|
|
15
|
+
throw new Error("Unknown approval request");
|
|
16
|
+
}
|
|
17
|
+
return input;
|
|
18
|
+
},
|
|
19
|
+
deleteTask: ({ taskId }) => deleteTask(options.repository, taskId, subagentRepository),
|
|
20
|
+
getTaskTitle: async ({ taskId }) => {
|
|
21
|
+
const task = options.repository.findTaskById(taskId);
|
|
22
|
+
if (!task) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (task.title.trim().length > 0) {
|
|
26
|
+
return { id: task.id, title: task.title };
|
|
27
|
+
}
|
|
28
|
+
const titleJob = titleJobs.get(task.id);
|
|
29
|
+
if (titleJob) {
|
|
30
|
+
return titleJob;
|
|
31
|
+
}
|
|
32
|
+
startTitleJob({
|
|
33
|
+
input: {
|
|
34
|
+
approvalPolicy: task.approvalPolicy,
|
|
35
|
+
modelId: task.lastModelId ?? task.lastModelName,
|
|
36
|
+
prompt: task.initialUserMessage,
|
|
37
|
+
provider: task.lastModelProvider,
|
|
38
|
+
thinkingLevel: task.thinkingLevel,
|
|
39
|
+
workspacePath: ""
|
|
40
|
+
},
|
|
41
|
+
now,
|
|
42
|
+
repository: options.repository,
|
|
43
|
+
task,
|
|
44
|
+
titleGenerator: options.titleGenerator,
|
|
45
|
+
titleJobs
|
|
46
|
+
});
|
|
47
|
+
return titleJobs.get(task.id) ?? { id: task.id, title: task.title };
|
|
48
|
+
},
|
|
49
|
+
interruptTask: async ({ taskId }) => {
|
|
50
|
+
return interruptTaskRun({
|
|
51
|
+
...(options.activeTaskRuns
|
|
52
|
+
? { activeTaskRuns: options.activeTaskRuns }
|
|
53
|
+
: {}),
|
|
54
|
+
now,
|
|
55
|
+
repository: options.repository,
|
|
56
|
+
runtime: options.runtime,
|
|
57
|
+
subagentRepository,
|
|
58
|
+
taskId
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
continueTask: async (input) => {
|
|
62
|
+
const { prompt, taskId } = input;
|
|
63
|
+
const task = options.repository.findTaskById(taskId);
|
|
64
|
+
if (!task)
|
|
65
|
+
return null;
|
|
66
|
+
const workspace = options.repository.findWorkspaceById(task.workspaceId);
|
|
67
|
+
if (!workspace)
|
|
68
|
+
return null;
|
|
69
|
+
const session = getTaskSession(task);
|
|
70
|
+
const selectedModel = input.modelId !== undefined && input.provider !== undefined
|
|
71
|
+
? getTaskModelMetadata(input.provider, input.modelId, options.modelProvidersService)
|
|
72
|
+
: null;
|
|
73
|
+
const optionUpdate = {
|
|
74
|
+
approvalPolicy: input.approvalPolicy ?? task.approvalPolicy,
|
|
75
|
+
thinkingLevel: input.thinkingLevel ?? task.thinkingLevel
|
|
76
|
+
};
|
|
77
|
+
options.repository.updateTaskOptions(taskId, optionUpdate, now().toISOString());
|
|
78
|
+
options.repository.updateTaskStatus(taskId, "running", now().toISOString());
|
|
79
|
+
const run = await startTaskRun({
|
|
80
|
+
...(options.activeTaskRuns
|
|
81
|
+
? { activeTaskRuns: options.activeTaskRuns }
|
|
82
|
+
: {}),
|
|
83
|
+
eventBus: options.eventBus,
|
|
84
|
+
now,
|
|
85
|
+
repository: options.repository,
|
|
86
|
+
runtime: options.runtime,
|
|
87
|
+
runtimeInput: {
|
|
88
|
+
modelId: selectedModel?.lastModelId ?? task.lastModelId ?? task.lastModelName,
|
|
89
|
+
prompt,
|
|
90
|
+
provider: selectedModel?.lastModelProvider ?? task.lastModelProvider,
|
|
91
|
+
...optionUpdate,
|
|
92
|
+
...(input.runtimeContributions === undefined
|
|
93
|
+
? {}
|
|
94
|
+
: { runtimeContributions: input.runtimeContributions }),
|
|
95
|
+
...(session ? { session } : {}),
|
|
96
|
+
taskId,
|
|
97
|
+
workspacePath: workspace.path
|
|
98
|
+
},
|
|
99
|
+
taskId
|
|
100
|
+
});
|
|
101
|
+
options.repository.updateTaskSession(taskId, run.session);
|
|
102
|
+
const continuedAt = now().toISOString();
|
|
103
|
+
if (selectedModel) {
|
|
104
|
+
options.repository.updateTaskModel(taskId, selectedModel, continuedAt);
|
|
105
|
+
}
|
|
106
|
+
const updatedTask = options.repository.updateTaskContinuedAt(taskId, continuedAt) ?? task;
|
|
107
|
+
return toStartAgentResult(run, updatedTask, workspace);
|
|
108
|
+
},
|
|
109
|
+
listTaskMessages: async ({ taskId }) => {
|
|
110
|
+
const task = options.repository.findTaskById(taskId);
|
|
111
|
+
if (!task)
|
|
112
|
+
return emptyTaskMessageHistory();
|
|
113
|
+
const workspace = options.repository.findWorkspaceById(task.workspaceId);
|
|
114
|
+
const session = getTaskSession(task);
|
|
115
|
+
if (!workspace || !session)
|
|
116
|
+
return emptyTaskMessageHistory();
|
|
117
|
+
const messages = await options.runtime.listMessages({
|
|
118
|
+
session,
|
|
119
|
+
workspacePath: workspace.path
|
|
120
|
+
});
|
|
121
|
+
const subagents = await Promise.all(subagentRepository.findByTaskId(taskId).map(async (subagent) => ({
|
|
122
|
+
agentId: subagent.agentId,
|
|
123
|
+
agentName: subagent.agentName,
|
|
124
|
+
messages: await loadSubagentMessages({
|
|
125
|
+
runtime: options.runtime,
|
|
126
|
+
subagent,
|
|
127
|
+
workspacePath: workspace.path
|
|
128
|
+
}),
|
|
129
|
+
parentAgentId: subagent.parentAgentId,
|
|
130
|
+
status: subagent.status
|
|
131
|
+
})));
|
|
132
|
+
return { messages, subagents };
|
|
133
|
+
},
|
|
134
|
+
renameTask: async ({ taskId, title }) => renameTask(options.repository, taskId, title, now().toISOString()),
|
|
135
|
+
startAgent: async (input) => {
|
|
136
|
+
const taskOptions = getTaskRunOptions(input);
|
|
137
|
+
const createdAt = now().toISOString();
|
|
138
|
+
const workspace = ensureWorkspace({
|
|
139
|
+
createdAt,
|
|
140
|
+
repository: options.repository,
|
|
141
|
+
workspacePath: input.workspacePath
|
|
142
|
+
});
|
|
143
|
+
const configuredModel = options.modelProvidersService?.getConfiguredModelForProvider(input.provider, input.modelId) ?? null;
|
|
144
|
+
const taskModel = getTaskModelMetadata(input.provider, input.modelId, options.modelProvidersService);
|
|
145
|
+
const task = options.repository.createTask({
|
|
146
|
+
createdAt,
|
|
147
|
+
id: `task_${randomUUID()}`,
|
|
148
|
+
initialUserMessage: input.prompt,
|
|
149
|
+
lastContinuedAt: createdAt,
|
|
150
|
+
...taskModel,
|
|
151
|
+
approvalPolicy: taskOptions.approvalPolicy,
|
|
152
|
+
sessionCreatedAt: null,
|
|
153
|
+
sessionId: null,
|
|
154
|
+
sessionPath: null,
|
|
155
|
+
status: "running",
|
|
156
|
+
thinkingLevel: taskOptions.thinkingLevel,
|
|
157
|
+
title: "",
|
|
158
|
+
updatedAt: createdAt,
|
|
159
|
+
workspaceId: workspace.id
|
|
160
|
+
});
|
|
161
|
+
startTitleJob({
|
|
162
|
+
...(configuredModel?.apiKey ? { apiKey: configuredModel.apiKey } : {}),
|
|
163
|
+
input,
|
|
164
|
+
now,
|
|
165
|
+
repository: options.repository,
|
|
166
|
+
task,
|
|
167
|
+
titleGenerator: options.titleGenerator,
|
|
168
|
+
titleJobs
|
|
169
|
+
});
|
|
170
|
+
const run = await startTaskRun({
|
|
171
|
+
...(options.activeTaskRuns
|
|
172
|
+
? { activeTaskRuns: options.activeTaskRuns }
|
|
173
|
+
: {}),
|
|
174
|
+
eventBus: options.eventBus,
|
|
175
|
+
now,
|
|
176
|
+
repository: options.repository,
|
|
177
|
+
runtime: options.runtime,
|
|
178
|
+
runtimeInput: { ...input, ...taskOptions, taskId: task.id },
|
|
179
|
+
taskId: task.id
|
|
180
|
+
});
|
|
181
|
+
const updatedTask = options.repository.updateTaskSession(task.id, run.session) ?? task;
|
|
182
|
+
return toStartAgentResult(run, updatedTask, workspace);
|
|
183
|
+
},
|
|
184
|
+
submitBrowserToolResult: async (input) => {
|
|
185
|
+
const accepted = (await options.runtime.submitBrowserToolResult?.(input)) ?? false;
|
|
186
|
+
return accepted ? input : null;
|
|
187
|
+
},
|
|
188
|
+
subscribeToAgentEvents: (input, listener) => options.eventBus.subscribe(input, listener)
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function getTaskRunOptions(input) {
|
|
192
|
+
return {
|
|
193
|
+
approvalPolicy: input.approvalPolicy ?? "approval",
|
|
194
|
+
thinkingLevel: input.thinkingLevel ?? "medium"
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function emptyTaskMessageHistory() {
|
|
198
|
+
return { messages: [], subagents: [] };
|
|
199
|
+
}
|
|
200
|
+
async function loadSubagentMessages(input) {
|
|
201
|
+
const session = getSubagentSession(input.subagent);
|
|
202
|
+
if (!session)
|
|
203
|
+
return [];
|
|
204
|
+
try {
|
|
205
|
+
return await input.runtime.listMessages({
|
|
206
|
+
session,
|
|
207
|
+
workspacePath: input.workspacePath
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function getSubagentSession(subagent) {
|
|
215
|
+
if (!subagent.sessionCreatedAt ||
|
|
216
|
+
!subagent.sessionId ||
|
|
217
|
+
!subagent.sessionPath) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
createdAt: subagent.sessionCreatedAt,
|
|
222
|
+
id: subagent.sessionId,
|
|
223
|
+
path: subagent.sessionPath
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function getTaskSession(task) {
|
|
227
|
+
if (!task.sessionId || !task.sessionPath || !task.sessionCreatedAt) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
createdAt: task.sessionCreatedAt,
|
|
232
|
+
id: task.sessionId,
|
|
233
|
+
path: task.sessionPath
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function toStartAgentResult(run, task, workspace) {
|
|
237
|
+
return {
|
|
238
|
+
agentId: run.agentId,
|
|
239
|
+
sessionId: run.session.id,
|
|
240
|
+
status: run.status,
|
|
241
|
+
task,
|
|
242
|
+
workspace
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function ensureWorkspace(input) {
|
|
246
|
+
const existingWorkspace = input.repository.findWorkspaceByPath(input.workspacePath);
|
|
247
|
+
if (existingWorkspace) {
|
|
248
|
+
return existingWorkspace;
|
|
249
|
+
}
|
|
250
|
+
const name = basename(input.workspacePath) || input.workspacePath;
|
|
251
|
+
return input.repository.createWorkspace({
|
|
252
|
+
createdAt: input.createdAt,
|
|
253
|
+
id: `workspace_${randomUUID()}`,
|
|
254
|
+
name,
|
|
255
|
+
path: input.workspacePath,
|
|
256
|
+
updatedAt: input.createdAt
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function getProviderSource(provider, modelProvidersService) {
|
|
260
|
+
const summary = modelProvidersService
|
|
261
|
+
.listModelProviders()
|
|
262
|
+
.find((item) => item.id === provider);
|
|
263
|
+
return summary?.source === "custom" ? "custom" : "built_in";
|
|
264
|
+
}
|
|
265
|
+
function getTaskModelMetadata(provider, modelId, modelProvidersService) {
|
|
266
|
+
const configuredModel = modelProvidersService?.getConfiguredModelForProvider(provider, modelId) ?? null;
|
|
267
|
+
return {
|
|
268
|
+
lastModelId: modelId,
|
|
269
|
+
lastModelName: configuredModel?.model.name ?? modelId,
|
|
270
|
+
lastModelProvider: provider,
|
|
271
|
+
lastModelProviderSource: modelProvidersService?.hasProvider(provider)
|
|
272
|
+
? getProviderSource(provider, modelProvidersService)
|
|
273
|
+
: "built_in"
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function startTitleJob(input) {
|
|
277
|
+
const titleJob = input.titleGenerator
|
|
278
|
+
.generateTitle({
|
|
279
|
+
...(input.apiKey ? { apiKey: input.apiKey } : {}),
|
|
280
|
+
modelId: input.input.modelId,
|
|
281
|
+
prompt: input.input.prompt,
|
|
282
|
+
provider: input.input.provider
|
|
283
|
+
})
|
|
284
|
+
.then((title) => {
|
|
285
|
+
const currentTask = input.repository.findTaskById(input.task.id);
|
|
286
|
+
if (!currentTask || currentTask.title.trim().length > 0) {
|
|
287
|
+
return { id: input.task.id, title: currentTask?.title ?? title };
|
|
288
|
+
}
|
|
289
|
+
const updatedTask = input.repository.updateTaskTitle(input.task.id, title, input.now().toISOString());
|
|
290
|
+
return { id: input.task.id, title: updatedTask?.title ?? title };
|
|
291
|
+
})
|
|
292
|
+
.finally(() => {
|
|
293
|
+
input.titleJobs.delete(input.task.id);
|
|
294
|
+
});
|
|
295
|
+
input.titleJobs.set(input.task.id, titleJob);
|
|
296
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WorkspaceRepository } from "../../workspaces/workspace-repository";
|
|
2
|
+
import type { InterruptTaskResult } from "../agent-types";
|
|
3
|
+
import type { AgentRuntime } from "../runtime/type";
|
|
4
|
+
import type { SubagentRepository } from "../subagent/repository";
|
|
5
|
+
import type { ActiveTaskRunRegistry } from "../task/active-run-registry";
|
|
6
|
+
export declare function interruptTaskRun(input: {
|
|
7
|
+
activeTaskRuns?: ActiveTaskRunRegistry;
|
|
8
|
+
now: () => Date;
|
|
9
|
+
repository: WorkspaceRepository;
|
|
10
|
+
runtime: AgentRuntime;
|
|
11
|
+
subagentRepository: SubagentRepository;
|
|
12
|
+
taskId: string;
|
|
13
|
+
}): Promise<InterruptTaskResult>;
|
|
14
|
+
//# sourceMappingURL=interrupt-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interrupt-task.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/service/interrupt-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,UAAU,EAAE,mBAAmB,CAAC;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiC/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { interruptRunningSubagents } from "../subagent/lifecycle.js";
|
|
2
|
+
export async function interruptTaskRun(input) {
|
|
3
|
+
const task = input.repository.findTaskById(input.taskId);
|
|
4
|
+
if (!task) {
|
|
5
|
+
return { status: "not_found", taskId: input.taskId };
|
|
6
|
+
}
|
|
7
|
+
const agentId = input.activeTaskRuns?.getAgentId(input.taskId);
|
|
8
|
+
const interruptedAt = input.now().toISOString();
|
|
9
|
+
const interruptSubagents = () => interruptRunningSubagents({
|
|
10
|
+
now: interruptedAt,
|
|
11
|
+
runtime: input.runtime,
|
|
12
|
+
subagentRepository: input.subagentRepository,
|
|
13
|
+
taskId: input.taskId
|
|
14
|
+
});
|
|
15
|
+
if (task.status !== "running" || !agentId) {
|
|
16
|
+
return toChildInterruptResult(await interruptSubagents(), input.taskId);
|
|
17
|
+
}
|
|
18
|
+
const interrupted = await input.runtime.interrupt(agentId);
|
|
19
|
+
if (!interrupted) {
|
|
20
|
+
input.activeTaskRuns?.remove(input.taskId);
|
|
21
|
+
return toChildInterruptResult(await interruptSubagents(), input.taskId);
|
|
22
|
+
}
|
|
23
|
+
input.repository.updateTaskStatus(input.taskId, "error", interruptedAt);
|
|
24
|
+
await interruptSubagents();
|
|
25
|
+
input.activeTaskRuns?.remove(input.taskId);
|
|
26
|
+
return { agentId, status: "interrupted", taskId: input.taskId };
|
|
27
|
+
}
|
|
28
|
+
function toChildInterruptResult(agentIds, taskId) {
|
|
29
|
+
const [agentId] = agentIds;
|
|
30
|
+
if (!agentId) {
|
|
31
|
+
return { status: "not_running", taskId };
|
|
32
|
+
}
|
|
33
|
+
return { agentId, status: "interrupted", taskId };
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WorkspaceRepository } from "../../workspaces/workspace-repository";
|
|
2
|
+
import type { SubagentRepository } from "../subagent/repository";
|
|
3
|
+
import type { ActiveTaskRunRegistry } from "../task/active-run-registry";
|
|
4
|
+
export interface StartupRecoveryResult {
|
|
5
|
+
interruptedSubagentIds: string[];
|
|
6
|
+
interruptedTaskIds: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function recoverInterruptedAgentRuns(input: {
|
|
9
|
+
activeTaskRuns?: ActiveTaskRunRegistry;
|
|
10
|
+
now: string;
|
|
11
|
+
repository: WorkspaceRepository;
|
|
12
|
+
subagentRepository: SubagentRepository;
|
|
13
|
+
}): StartupRecoveryResult;
|
|
14
|
+
//# sourceMappingURL=startup-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-recovery.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/service/startup-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,MAAM,WAAW,qBAAqB;IACpC,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,mBAAmB,CAAC;IAChC,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,GAAG,qBAAqB,CAmBxB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function recoverInterruptedAgentRuns(input) {
|
|
2
|
+
const interruptedTaskIds = input.repository
|
|
3
|
+
.listWorkspaces()
|
|
4
|
+
.flatMap((workspace) => input.repository.listAllTasksByWorkspaceId(workspace.id))
|
|
5
|
+
.filter((task) => task.status === "running" &&
|
|
6
|
+
input.activeTaskRuns?.getAgentId(task.id) === undefined)
|
|
7
|
+
.map((task) => {
|
|
8
|
+
input.repository.updateTaskStatus(task.id, "error", input.now);
|
|
9
|
+
return task.id;
|
|
10
|
+
});
|
|
11
|
+
const interruptedSubagentIds = input.subagentRepository
|
|
12
|
+
.interruptRunning(input.now)
|
|
13
|
+
.map((subagent) => subagent.agentId);
|
|
14
|
+
return { interruptedSubagentIds, interruptedTaskIds };
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-command-risk.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/shell-command-risk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAmBtD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAU1E"}
|