@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,371 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { AgentHarness, NodeExecutionEnv, formatSkillsForSystemPrompt, loadSkills } from "@earendil-works/pi-agent-core/node";
|
|
4
|
+
import { toStoredAgentMessage } from "./agent-message-storage.js";
|
|
5
|
+
import { resolveAgentModel } from "./agent-model-resolver.js";
|
|
6
|
+
import {} from "./agent-types.js";
|
|
7
|
+
import { appendVisibleCustomMessage } from "./agent-runtime-messages.js";
|
|
8
|
+
import { runToolBeforeExecute } from "./agent-tool-approval.js";
|
|
9
|
+
import { createCallSubagentTool, extractAssistantText, formatSubagentResult, getNextCompletedSubagent, hasRunningSubagent } from "./agent-subagents.js";
|
|
10
|
+
import { createSessionRepo, getEnvApiKey, getSkillDirs, interruptHarness, toAgentSessionMetadata } from "./agent-runtime-support.js";
|
|
11
|
+
import { createInMemorySubagentRepository } from "./subagent-repository.js";
|
|
12
|
+
import { pluginRegistry } from '../../plugin.js';
|
|
13
|
+
const AGENT_CONTINUATION_CUSTOM_TYPE = "agent_continuation";
|
|
14
|
+
const AGENT_CONTINUE_PROMPT = "";
|
|
15
|
+
const CALL_SUBAGENT_CUSTOM_TYPE = "callsubagent";
|
|
16
|
+
const SUBAGENT_RESULT_CUSTOM_TYPE = "subagent_result";
|
|
17
|
+
export function createAgentRuntime(options) {
|
|
18
|
+
const runningAgents = new Map();
|
|
19
|
+
const sessionRepo = options.sessionRepo ?? createSessionRepo();
|
|
20
|
+
const subagentRepository = options.subagentRepository ?? createInMemorySubagentRepository();
|
|
21
|
+
const subagents = new Map();
|
|
22
|
+
return {
|
|
23
|
+
interrupt: async (agentId) => {
|
|
24
|
+
const runningAgent = runningAgents.get(agentId);
|
|
25
|
+
if (!runningAgent) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
runningAgents.delete(agentId);
|
|
29
|
+
await interruptHarness(runningAgent.harness);
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
listMessages: async ({ session: metadata, workspacePath }) => {
|
|
33
|
+
const session = await sessionRepo.open({ ...metadata, cwd: workspacePath });
|
|
34
|
+
const context = await session.buildContext();
|
|
35
|
+
return context.messages.map((message) => toStoredAgentMessage(`message_${randomUUID()}`, message));
|
|
36
|
+
},
|
|
37
|
+
start: async (input) => {
|
|
38
|
+
const env = new NodeExecutionEnv({ cwd: input.workspacePath });
|
|
39
|
+
const model = await resolveAgentModel(input.provider, input.modelId, options.getCustomModel);
|
|
40
|
+
if (!model) {
|
|
41
|
+
throw new Error("Unknown model");
|
|
42
|
+
}
|
|
43
|
+
const createHarness = async (harnessOptions) => {
|
|
44
|
+
let activeMessageId;
|
|
45
|
+
const pendingVisibleMessages = new Map();
|
|
46
|
+
const pluginContext = {
|
|
47
|
+
agentName: harnessOptions.agentName ?? "main",
|
|
48
|
+
env,
|
|
49
|
+
isContinue: harnessOptions.isContinue,
|
|
50
|
+
session: harnessOptions.session,
|
|
51
|
+
prompt: harnessOptions.pluginPrompt,
|
|
52
|
+
thinkingLevel: 'medium',
|
|
53
|
+
model
|
|
54
|
+
};
|
|
55
|
+
const contribution = await pluginRegistry.resolveContributions(pluginContext);
|
|
56
|
+
const skillDirs = getSkillDirs(input.workspacePath, [...(options.skillDirs || []), ...(contribution.skillDirs || [])]);
|
|
57
|
+
const { skills: loadedSkills } = await loadSkills(env, skillDirs);
|
|
58
|
+
const skills = [...loadedSkills, ...(contribution.skills || [])];
|
|
59
|
+
const tools = [
|
|
60
|
+
...(contribution.tools || []),
|
|
61
|
+
createCallSubagentTool({
|
|
62
|
+
startSubagent: async ({ agentName, prompt, toolCallId }) => {
|
|
63
|
+
const agentId = `agent_${randomUUID()}`;
|
|
64
|
+
const createdAt = new Date().toISOString();
|
|
65
|
+
const childSession = await sessionRepo.create({
|
|
66
|
+
cwd: input.workspacePath
|
|
67
|
+
});
|
|
68
|
+
const childSessionMetadata = toAgentSessionMetadata(await childSession.getMetadata());
|
|
69
|
+
subagentRepository.create({
|
|
70
|
+
agentId,
|
|
71
|
+
createdAt,
|
|
72
|
+
parentAgentId: harnessOptions.agentId,
|
|
73
|
+
sessionCreatedAt: childSessionMetadata.createdAt,
|
|
74
|
+
sessionId: childSessionMetadata.id,
|
|
75
|
+
sessionPath: childSessionMetadata.path,
|
|
76
|
+
status: "running",
|
|
77
|
+
taskId: input.taskId,
|
|
78
|
+
updatedAt: createdAt
|
|
79
|
+
});
|
|
80
|
+
let started;
|
|
81
|
+
try {
|
|
82
|
+
started = await startHarness(prompt, {
|
|
83
|
+
agentId,
|
|
84
|
+
agentName,
|
|
85
|
+
isContinue: false,
|
|
86
|
+
parentAgentId: harnessOptions.agentId,
|
|
87
|
+
pluginPrompt: prompt,
|
|
88
|
+
session: childSession
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
subagentRepository.delete(agentId);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
const details = {
|
|
96
|
+
agentId: started.agentId,
|
|
97
|
+
agentName,
|
|
98
|
+
parentAgentId: harnessOptions.agentId,
|
|
99
|
+
session: started.session,
|
|
100
|
+
taskId: input.taskId
|
|
101
|
+
};
|
|
102
|
+
subagents.set(started.agentId, {
|
|
103
|
+
agentId: started.agentId,
|
|
104
|
+
agentName,
|
|
105
|
+
agentSession: started.harnessSession,
|
|
106
|
+
consumed: false,
|
|
107
|
+
lastAssistantText: "",
|
|
108
|
+
parentAgentId: harnessOptions.agentId,
|
|
109
|
+
...(harnessOptions.agentName === undefined
|
|
110
|
+
? {}
|
|
111
|
+
: { parentAgentName: harnessOptions.agentName }),
|
|
112
|
+
parentSession: harnessOptions.session,
|
|
113
|
+
session: started.session,
|
|
114
|
+
status: "running"
|
|
115
|
+
});
|
|
116
|
+
pendingVisibleMessages.set(toolCallId, {
|
|
117
|
+
content: `Subagent "${agentName}" is running.`,
|
|
118
|
+
customType: CALL_SUBAGENT_CUSTOM_TYPE,
|
|
119
|
+
details
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
text: `Subagent "${agentName}" is running. agentId=${started.agentId}`,
|
|
125
|
+
type: "text"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
details
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
];
|
|
133
|
+
const harness = new AgentHarness({
|
|
134
|
+
activeToolNames: tools.map(tool => tool.name),
|
|
135
|
+
env,
|
|
136
|
+
getApiKeyAndHeaders: async () => {
|
|
137
|
+
const apiKey = (await options.getApiKey?.(input.provider, input.modelId)) ??
|
|
138
|
+
getEnvApiKey(input.provider);
|
|
139
|
+
return apiKey ? { apiKey } : undefined;
|
|
140
|
+
},
|
|
141
|
+
model: contribution.model || model,
|
|
142
|
+
resources: { skills },
|
|
143
|
+
session: harnessOptions.session,
|
|
144
|
+
systemPrompt: ({ resources }) => [
|
|
145
|
+
...(contribution.systemPrompts || []),
|
|
146
|
+
`Workspace: ${input.workspacePath}`,
|
|
147
|
+
`Current time: ${new Date().toISOString()}`,
|
|
148
|
+
"Use shell_exec for workspace commands and skill scripts.",
|
|
149
|
+
"Resolve skill-relative references from each skill file directory.",
|
|
150
|
+
formatSkillsForSystemPrompt(resources.skills ?? [])
|
|
151
|
+
]
|
|
152
|
+
.filter(Boolean)
|
|
153
|
+
.join("\n\n"),
|
|
154
|
+
tools
|
|
155
|
+
});
|
|
156
|
+
harness.subscribe(async (event) => {
|
|
157
|
+
try {
|
|
158
|
+
contribution.subscribe?.(event);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// Keep plugin subscriber failures from breaking agent event delivery.
|
|
162
|
+
}
|
|
163
|
+
if (event.type === "message_start") {
|
|
164
|
+
activeMessageId = `message_${randomUUID()}`;
|
|
165
|
+
options.eventBus.emit({
|
|
166
|
+
agentId: harnessOptions.agentId,
|
|
167
|
+
payload: { message: toStoredAgentMessage(activeMessageId, event.message) },
|
|
168
|
+
type: "message_start"
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (event.type === "message_update" && activeMessageId) {
|
|
173
|
+
options.eventBus.emit({
|
|
174
|
+
agentId: harnessOptions.agentId,
|
|
175
|
+
payload: {
|
|
176
|
+
delta: event.assistantMessageEvent,
|
|
177
|
+
messageId: activeMessageId
|
|
178
|
+
},
|
|
179
|
+
type: "message_delta"
|
|
180
|
+
});
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (event.type === "message_end") {
|
|
184
|
+
const messageId = activeMessageId ?? `message_${randomUUID()}`;
|
|
185
|
+
const message = toStoredAgentMessage(messageId, event.message);
|
|
186
|
+
const subagent = subagents.get(harnessOptions.agentId);
|
|
187
|
+
if (subagent) {
|
|
188
|
+
subagent.lastAssistantText = extractAssistantText(event.message);
|
|
189
|
+
}
|
|
190
|
+
options.eventBus.emit({
|
|
191
|
+
agentId: harnessOptions.agentId,
|
|
192
|
+
payload: { message },
|
|
193
|
+
type: "message_end"
|
|
194
|
+
});
|
|
195
|
+
activeMessageId = undefined;
|
|
196
|
+
if (event.message.role === "toolResult") {
|
|
197
|
+
const pendingMessage = pendingVisibleMessages.get(event.message.toolCallId);
|
|
198
|
+
if (pendingMessage) {
|
|
199
|
+
await appendVisibleCustomMessage({
|
|
200
|
+
agentId: harnessOptions.agentId,
|
|
201
|
+
...pendingMessage,
|
|
202
|
+
eventBus: options.eventBus,
|
|
203
|
+
session: harnessOptions.session
|
|
204
|
+
});
|
|
205
|
+
pendingVisibleMessages.delete(event.message.toolCallId);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (event.type === "agent_end") {
|
|
211
|
+
options.eventBus.emit({ agentId: harnessOptions.agentId, type: "agent_end" });
|
|
212
|
+
if (harnessOptions.parentAgentId) {
|
|
213
|
+
await finishSubagent(harnessOptions.agentId, contribution);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const continued = await continueOrEndTask(harnessOptions.agentId, harnessOptions.agentName, harnessOptions.session, contribution);
|
|
217
|
+
if (!continued) {
|
|
218
|
+
options.eventBus.emit({
|
|
219
|
+
agentId: harnessOptions.agentId,
|
|
220
|
+
type: "task_end"
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
harness.on("tool_call", async (event) => {
|
|
226
|
+
const tool = tools.find(tool => tool.name === event.toolName);
|
|
227
|
+
if (!tool)
|
|
228
|
+
return undefined;
|
|
229
|
+
return runToolBeforeExecute({
|
|
230
|
+
agentId: harnessOptions.agentId,
|
|
231
|
+
approvalStore: options.approvalStore,
|
|
232
|
+
event,
|
|
233
|
+
eventBus: options.eventBus,
|
|
234
|
+
tool,
|
|
235
|
+
workspacePath: input.workspacePath
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
return harness;
|
|
239
|
+
};
|
|
240
|
+
const finishSubagent = async (agentId, contribution) => {
|
|
241
|
+
const subagent = subagents.get(agentId);
|
|
242
|
+
if (!subagent)
|
|
243
|
+
return;
|
|
244
|
+
const continued = await continueOrEndTask(subagent.agentId, subagent.agentName, subagent.agentSession, contribution);
|
|
245
|
+
if (continued)
|
|
246
|
+
return;
|
|
247
|
+
subagent.status = "completed";
|
|
248
|
+
subagentRepository.updateStatus(subagent.agentId, "completed", new Date().toISOString());
|
|
249
|
+
await continueOrEndTask(subagent.parentAgentId, subagent.parentAgentName, subagent.parentSession, undefined);
|
|
250
|
+
subagents.delete(subagent.agentId);
|
|
251
|
+
};
|
|
252
|
+
const continueOrEndTask = async (harnessAgentId, harnessAgentName, harnessSession, contribution) => {
|
|
253
|
+
const currentSubagent = subagents.get(harnessAgentId);
|
|
254
|
+
const completedSubagent = getNextCompletedSubagent(subagents, harnessAgentId);
|
|
255
|
+
if (completedSubagent) {
|
|
256
|
+
completedSubagent.consumed = true;
|
|
257
|
+
const prompt = formatSubagentResult(completedSubagent);
|
|
258
|
+
// 这里有问题,因为子agent结束时父agent可能还在运行,所以不能直接加入消息并再次启动父agent,应该先检查父agent的状态,
|
|
259
|
+
// 若父agent未在运行则执行以下逻辑,
|
|
260
|
+
// 若父agent正在运行则应该等一个父agent可插入消息的位置(例如下一轮工具执行完成后),插入消息即可,无需重启一个harness
|
|
261
|
+
await appendVisibleCustomMessage({
|
|
262
|
+
agentId: harnessAgentId,
|
|
263
|
+
content: prompt,
|
|
264
|
+
customType: SUBAGENT_RESULT_CUSTOM_TYPE,
|
|
265
|
+
details: {
|
|
266
|
+
agentId: completedSubagent.agentId,
|
|
267
|
+
agentName: completedSubagent.agentName,
|
|
268
|
+
session: completedSubagent.session
|
|
269
|
+
},
|
|
270
|
+
eventBus: options.eventBus,
|
|
271
|
+
session: harnessSession
|
|
272
|
+
});
|
|
273
|
+
await startHarness(AGENT_CONTINUE_PROMPT, {
|
|
274
|
+
agentId: harnessAgentId,
|
|
275
|
+
isContinue: true,
|
|
276
|
+
pluginPrompt: prompt,
|
|
277
|
+
session: harnessSession,
|
|
278
|
+
...(currentSubagent === undefined
|
|
279
|
+
? {}
|
|
280
|
+
: { parentAgentId: currentSubagent.parentAgentId }),
|
|
281
|
+
...(harnessAgentName === undefined
|
|
282
|
+
? {}
|
|
283
|
+
: { agentName: harnessAgentName })
|
|
284
|
+
});
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
if (hasRunningSubagent(subagents, harnessAgentId)) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
const currentSessionMetadata = toAgentSessionMetadata(await harnessSession.getMetadata());
|
|
291
|
+
const context = await harnessSession.buildContext();
|
|
292
|
+
const continuation = await contribution?.onAgentEnd?.({
|
|
293
|
+
messages: context.messages,
|
|
294
|
+
runInput: { ...input, session: currentSessionMetadata },
|
|
295
|
+
session: currentSessionMetadata
|
|
296
|
+
});
|
|
297
|
+
if (!continuation?.prompt) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
await appendVisibleCustomMessage({
|
|
301
|
+
agentId: harnessAgentId,
|
|
302
|
+
content: continuation.prompt,
|
|
303
|
+
customType: AGENT_CONTINUATION_CUSTOM_TYPE,
|
|
304
|
+
details: continuation.details,
|
|
305
|
+
eventBus: options.eventBus,
|
|
306
|
+
session: harnessSession
|
|
307
|
+
});
|
|
308
|
+
await startHarness(AGENT_CONTINUE_PROMPT, {
|
|
309
|
+
agentId: harnessAgentId,
|
|
310
|
+
isContinue: true,
|
|
311
|
+
pluginPrompt: continuation.prompt,
|
|
312
|
+
session: harnessSession,
|
|
313
|
+
...(currentSubagent === undefined
|
|
314
|
+
? {}
|
|
315
|
+
: { parentAgentId: currentSubagent.parentAgentId }),
|
|
316
|
+
...(harnessAgentName === undefined
|
|
317
|
+
? {}
|
|
318
|
+
: { agentName: harnessAgentName })
|
|
319
|
+
});
|
|
320
|
+
return true;
|
|
321
|
+
};
|
|
322
|
+
const startHarness = async (promptText, harnessOptions) => {
|
|
323
|
+
const harnessAgentId = harnessOptions.agentId ?? `agent_${randomUUID()}`;
|
|
324
|
+
const harnessSession = harnessOptions.session ?? (await sessionRepo.create({ cwd: input.workspacePath }));
|
|
325
|
+
const harnessSessionMetadata = toAgentSessionMetadata(await harnessSession.getMetadata());
|
|
326
|
+
const harness = await createHarness({
|
|
327
|
+
...harnessOptions,
|
|
328
|
+
agentId: harnessAgentId,
|
|
329
|
+
session: harnessSession
|
|
330
|
+
});
|
|
331
|
+
runningAgents.set(harnessAgentId, {
|
|
332
|
+
harness,
|
|
333
|
+
sessionId: harnessSessionMetadata.id
|
|
334
|
+
});
|
|
335
|
+
void harness.prompt(promptText)
|
|
336
|
+
.catch((error) => {
|
|
337
|
+
options.eventBus.emit({
|
|
338
|
+
agentId: harnessAgentId,
|
|
339
|
+
payload: {
|
|
340
|
+
message: error instanceof Error ? error.message : "Agent run failed"
|
|
341
|
+
},
|
|
342
|
+
type: "agent_error"
|
|
343
|
+
});
|
|
344
|
+
})
|
|
345
|
+
.finally(() => {
|
|
346
|
+
if (runningAgents.get(harnessAgentId)?.harness === harness) {
|
|
347
|
+
runningAgents.delete(harnessAgentId);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
agentId: harnessAgentId,
|
|
352
|
+
harnessSession,
|
|
353
|
+
session: harnessSessionMetadata
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
const inputSession = input.session
|
|
357
|
+
? await sessionRepo.open({ ...input.session, cwd: input.workspacePath })
|
|
358
|
+
: undefined;
|
|
359
|
+
const startedHarness = await startHarness(input.prompt, {
|
|
360
|
+
isContinue: false,
|
|
361
|
+
pluginPrompt: input.prompt,
|
|
362
|
+
...(inputSession ? { session: inputSession } : {})
|
|
363
|
+
});
|
|
364
|
+
return {
|
|
365
|
+
agentId: startedHarness.agentId,
|
|
366
|
+
session: startedHarness.session,
|
|
367
|
+
status: "running"
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ServerPlugin } from "@hold-rein/plugin-server";
|
|
2
|
+
import type { AgentSessionMetadata } from "./agent-types";
|
|
3
|
+
export interface SubagentRun<ParentSession> {
|
|
4
|
+
agentId: string;
|
|
5
|
+
agentName: string;
|
|
6
|
+
agentSession: ParentSession;
|
|
7
|
+
consumed: boolean;
|
|
8
|
+
lastAssistantText: string;
|
|
9
|
+
parentAgentId: string;
|
|
10
|
+
parentAgentName?: string;
|
|
11
|
+
parentSession: ParentSession;
|
|
12
|
+
session: AgentSessionMetadata;
|
|
13
|
+
status: "running" | "completed";
|
|
14
|
+
}
|
|
15
|
+
export declare function createCallSubagentTool(input: {
|
|
16
|
+
startSubagent: (input: {
|
|
17
|
+
agentName: string;
|
|
18
|
+
prompt: string;
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
content: {
|
|
22
|
+
text: string;
|
|
23
|
+
type: "text";
|
|
24
|
+
}[];
|
|
25
|
+
details: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
}): ServerPlugin.PluginTool;
|
|
28
|
+
export declare function getNextCompletedSubagent<ParentSession>(subagents: Map<string, SubagentRun<ParentSession>>, parentAgentId: string): SubagentRun<ParentSession> | undefined;
|
|
29
|
+
export declare function hasRunningSubagent<ParentSession>(subagents: Map<string, SubagentRun<ParentSession>>, parentAgentId: string): boolean;
|
|
30
|
+
export declare function formatSubagentResult<ParentSession>(subagent: SubagentRun<ParentSession>): string;
|
|
31
|
+
export declare function extractAssistantText(message: unknown): string;
|
|
32
|
+
//# sourceMappingURL=agent-subagents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-subagents.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/agent-subagents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,WAAW,WAAW,CAAC,aAAa;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,aAAa,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,aAAa,EAAE,CAAC,KAAK,EAAE;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC;QACZ,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1C,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC,CAAC;CACJ,GAAG,YAAY,CAAC,UAAU,CAmC1B;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EACpD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,EAClD,aAAa,EAAE,MAAM,GACpB,WAAW,CAAC,aAAa,CAAC,GAAG,SAAS,CAOxC;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAC9C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC,EAClD,aAAa,EAAE,MAAM,GACpB,OAAO,CAKT;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAChD,QAAQ,EAAE,WAAW,CAAC,aAAa,CAAC,GACnC,MAAM,CAOR;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAmB7D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Type } from "@earendil-works/pi-ai";
|
|
2
|
+
export function createCallSubagentTool(input) {
|
|
3
|
+
return {
|
|
4
|
+
description: "Start a child agent to work on a delegated task.",
|
|
5
|
+
executionMode: "parallel",
|
|
6
|
+
label: "Call Subagent",
|
|
7
|
+
name: "call_subagent",
|
|
8
|
+
parameters: Type.Object({
|
|
9
|
+
agentName: Type.String({
|
|
10
|
+
description: "Short display name for the child agent."
|
|
11
|
+
}),
|
|
12
|
+
prompt: Type.String({
|
|
13
|
+
description: "Task prompt for the child agent."
|
|
14
|
+
})
|
|
15
|
+
}),
|
|
16
|
+
async execute(toolCallId, rawParams) {
|
|
17
|
+
const params = rawParams;
|
|
18
|
+
const agentName = typeof params.agentName === "string" && params.agentName.trim()
|
|
19
|
+
? params.agentName.trim()
|
|
20
|
+
: "subagent";
|
|
21
|
+
const prompt = typeof params.prompt === "string" && params.prompt.trim()
|
|
22
|
+
? params.prompt.trim()
|
|
23
|
+
: "";
|
|
24
|
+
if (!prompt) {
|
|
25
|
+
throw new Error("call_subagent requires a prompt");
|
|
26
|
+
}
|
|
27
|
+
return input.startSubagent({ agentName, prompt, toolCallId });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function getNextCompletedSubagent(subagents, parentAgentId) {
|
|
32
|
+
return Array.from(subagents.values()).find((subagent) => subagent.parentAgentId === parentAgentId &&
|
|
33
|
+
subagent.status === "completed" &&
|
|
34
|
+
!subagent.consumed);
|
|
35
|
+
}
|
|
36
|
+
export function hasRunningSubagent(subagents, parentAgentId) {
|
|
37
|
+
return Array.from(subagents.values()).some((subagent) => subagent.parentAgentId === parentAgentId && subagent.status === "running");
|
|
38
|
+
}
|
|
39
|
+
export function formatSubagentResult(subagent) {
|
|
40
|
+
return [
|
|
41
|
+
`Subagent "${subagent.agentName}" completed.`,
|
|
42
|
+
`agentId: ${subagent.agentId}`,
|
|
43
|
+
"",
|
|
44
|
+
subagent.lastAssistantText || "No assistant response was captured."
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
export function extractAssistantText(message) {
|
|
48
|
+
if (!message || typeof message !== "object")
|
|
49
|
+
return "";
|
|
50
|
+
const record = message;
|
|
51
|
+
if (record.role !== "assistant" || !Array.isArray(record.content)) {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return record.content
|
|
55
|
+
.map((block) => {
|
|
56
|
+
if (!block || typeof block !== "object")
|
|
57
|
+
return "";
|
|
58
|
+
const content = block;
|
|
59
|
+
return content.type === "text" && typeof content.text === "string"
|
|
60
|
+
? content.text
|
|
61
|
+
: "";
|
|
62
|
+
})
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join("\n");
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TaskTitleResult } from "./agent-types";
|
|
2
|
+
import type { WorkspaceRepository } from "../workspaces/workspace-repository";
|
|
3
|
+
export interface DeleteTaskResult {
|
|
4
|
+
status: "deleted" | "not_found" | "running";
|
|
5
|
+
taskId: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function deleteTask(repository: WorkspaceRepository, taskId: string): Promise<DeleteTaskResult>;
|
|
8
|
+
export declare function renameTask(repository: WorkspaceRepository, taskId: string, title: string, updatedAt: string): TaskTitleResult | null;
|
|
9
|
+
//# sourceMappingURL=agent-task-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-task-actions.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/agent-task-actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,CAiB3B;AAED,wBAAgB,UAAU,CACxB,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,eAAe,GAAG,IAAI,CAIxB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { unlink } from "node:fs/promises";
|
|
2
|
+
export async function deleteTask(repository, taskId) {
|
|
3
|
+
const task = repository.findTaskById(taskId);
|
|
4
|
+
if (!task) {
|
|
5
|
+
return { status: "not_found", taskId };
|
|
6
|
+
}
|
|
7
|
+
if (task.status === "running") {
|
|
8
|
+
return { status: "running", taskId };
|
|
9
|
+
}
|
|
10
|
+
if (task.sessionPath) {
|
|
11
|
+
await deleteSessionFile(task.sessionPath);
|
|
12
|
+
}
|
|
13
|
+
repository.deleteTaskById(taskId);
|
|
14
|
+
return { status: "deleted", taskId };
|
|
15
|
+
}
|
|
16
|
+
export function renameTask(repository, taskId, title, updatedAt) {
|
|
17
|
+
const task = repository.updateTaskTitle(taskId, title, updatedAt);
|
|
18
|
+
return task ? { id: task.id, title: task.title } : null;
|
|
19
|
+
}
|
|
20
|
+
async function deleteSessionFile(sessionPath) {
|
|
21
|
+
try {
|
|
22
|
+
await unlink(sessionPath);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (isMissingFileError(error)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function isMissingFileError(error) {
|
|
32
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AgentModelLookup } from "./agent-model-resolver";
|
|
2
|
+
export interface GenerateTaskTitleInput {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
modelId: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
provider: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TaskTitleGenerator {
|
|
9
|
+
generateTitle: (input: GenerateTaskTitleInput) => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateTaskTitleGeneratorOptions {
|
|
12
|
+
getCustomModel?: AgentModelLookup;
|
|
13
|
+
}
|
|
14
|
+
export declare function createDefaultTaskTitleGenerator(options?: CreateTaskTitleGeneratorOptions): TaskTitleGenerator;
|
|
15
|
+
//# sourceMappingURL=agent-task-title-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-task-title-generator.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/agent-task-title-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,+BAA+B;IAC9C,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,+BAAoC,GAC5C,kBAAkB,CAqDpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { complete } from "@earendil-works/pi-ai";
|
|
2
|
+
import { resolveAgentModel } from "./agent-model-resolver.js";
|
|
3
|
+
export function createDefaultTaskTitleGenerator(options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
generateTitle: async (input) => {
|
|
6
|
+
const model = await resolveAgentModel(input.provider, input.modelId, options.getCustomModel);
|
|
7
|
+
if (!model) {
|
|
8
|
+
return createFallbackTitle(input.prompt);
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const message = await complete(model, {
|
|
12
|
+
messages: [
|
|
13
|
+
{
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
text: [
|
|
17
|
+
"Create a concise task title for this user request.",
|
|
18
|
+
"Return only the title, without quotes or punctuation wrappers.",
|
|
19
|
+
`Request: ${input.prompt}`
|
|
20
|
+
].join("\n"),
|
|
21
|
+
type: "text"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
role: "user",
|
|
25
|
+
timestamp: Date.now()
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
systemPrompt: "You create short software task titles."
|
|
29
|
+
}, {
|
|
30
|
+
...(input.apiKey ? { apiKey: input.apiKey } : {}),
|
|
31
|
+
maxTokens: 64,
|
|
32
|
+
temperature: 0.2
|
|
33
|
+
});
|
|
34
|
+
const title = message.content
|
|
35
|
+
.filter((content) => content.type === "text")
|
|
36
|
+
.map((content) => content.text)
|
|
37
|
+
.join("")
|
|
38
|
+
.trim();
|
|
39
|
+
return normalizeGeneratedTitle(title, input.prompt);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return createFallbackTitle(input.prompt);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function normalizeGeneratedTitle(title, prompt) {
|
|
48
|
+
const normalizedTitle = title
|
|
49
|
+
.replace(/^["'`]+|["'`]+$/g, "")
|
|
50
|
+
.replace(/\s+/g, " ")
|
|
51
|
+
.trim();
|
|
52
|
+
return normalizedTitle.length > 0
|
|
53
|
+
? normalizedTitle.slice(0, 80)
|
|
54
|
+
: createFallbackTitle(prompt);
|
|
55
|
+
}
|
|
56
|
+
function createFallbackTitle(prompt) {
|
|
57
|
+
const normalizedPrompt = prompt.replace(/\s+/g, " ").trim();
|
|
58
|
+
return normalizedPrompt.length > 0
|
|
59
|
+
? normalizedPrompt.slice(0, 80)
|
|
60
|
+
: "New task";
|
|
61
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ServerPlugin } from "@hold-rein/plugin-server";
|
|
2
|
+
import type { AgentApprovalStore } from "./agent-approval-store";
|
|
3
|
+
import type { AgentEventBus } from "./agent-event-bus";
|
|
4
|
+
export declare function runToolBeforeExecute(input: {
|
|
5
|
+
agentId: string;
|
|
6
|
+
approvalStore: AgentApprovalStore;
|
|
7
|
+
event: ServerPlugin.ToolBeforeExecuteOptions["event"];
|
|
8
|
+
eventBus: AgentEventBus;
|
|
9
|
+
tool: ServerPlugin.PluginTool;
|
|
10
|
+
workspacePath: string;
|
|
11
|
+
}): Promise<ServerPlugin.ToolBeforeExecuteResult>;
|
|
12
|
+
//# sourceMappingURL=agent-tool-approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-approval.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/agent-tool-approval.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,kBAAkB,CAAC;IAClC,KAAK,EAAE,YAAY,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACtD,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB,iDAwCA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
export async function runToolBeforeExecute(input) {
|
|
3
|
+
if (!input.tool.beforeExecute)
|
|
4
|
+
return undefined;
|
|
5
|
+
return input.tool.beforeExecute({
|
|
6
|
+
workspacePath: input.workspacePath,
|
|
7
|
+
event: input.event,
|
|
8
|
+
requestApproval: async (title) => {
|
|
9
|
+
const approvalId = `approval_${randomUUID()}`;
|
|
10
|
+
const approvalRequest = {
|
|
11
|
+
agentId: input.agentId,
|
|
12
|
+
approvalId,
|
|
13
|
+
...(title === undefined ? {} : { title }),
|
|
14
|
+
tool: {
|
|
15
|
+
name: input.tool.name,
|
|
16
|
+
input: input.event.input,
|
|
17
|
+
...(input.tool.description === undefined
|
|
18
|
+
? {}
|
|
19
|
+
: { description: input.tool.description }),
|
|
20
|
+
...(input.tool.label === undefined ? {} : { label: input.tool.label }),
|
|
21
|
+
toolCallId: input.event.toolCallId
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const approval = input.approvalStore.request(approvalRequest);
|
|
25
|
+
input.eventBus.emit({
|
|
26
|
+
agentId: input.agentId,
|
|
27
|
+
payload: approvalRequest,
|
|
28
|
+
type: "approval_requested"
|
|
29
|
+
});
|
|
30
|
+
const decision = await approval;
|
|
31
|
+
return decision.approved
|
|
32
|
+
? undefined
|
|
33
|
+
: {
|
|
34
|
+
block: true,
|
|
35
|
+
reason: decision.reason?.trim() ||
|
|
36
|
+
`User denied execute tool: ${input.tool.name}`
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|