@nocobase/app-plugin-agents 0.1.0-beta.1 → 0.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +355 -0
- package/README.md +107 -67
- package/dist/client/api/client.d.ts +25 -17
- package/dist/client/api/client.d.ts.map +1 -1
- package/dist/client/api/client.js +29 -27
- package/dist/client/api/client.js.map +1 -1
- package/dist/client/api/keys.d.ts +1 -1
- package/dist/client/api/keys.d.ts.map +1 -1
- package/dist/client/api/keys.js +1 -1
- package/dist/client/api/keys.js.map +1 -1
- package/dist/client/chat/api.d.ts +2 -7
- package/dist/client/chat/api.d.ts.map +1 -1
- package/dist/client/chat/api.js +0 -7
- package/dist/client/chat/api.js.map +1 -1
- package/dist/client/chat/consultation-identity.d.ts +7 -0
- package/dist/client/chat/consultation-identity.d.ts.map +1 -0
- package/dist/client/chat/consultation-identity.js +39 -0
- package/dist/client/chat/consultation-identity.js.map +1 -0
- package/dist/client/chat/message-model.d.ts +4 -2
- package/dist/client/chat/message-model.d.ts.map +1 -1
- package/dist/client/chat/message-model.js +28 -3
- package/dist/client/chat/message-model.js.map +1 -1
- package/dist/client/chat/use-chat.d.ts +2 -10
- package/dist/client/chat/use-chat.d.ts.map +1 -1
- package/dist/client/chat/use-chat.js +3 -10
- package/dist/client/chat/use-chat.js.map +1 -1
- package/dist/client/chat.d.ts +4 -1
- package/dist/client/chat.d.ts.map +1 -1
- package/dist/client/chat.js +3 -0
- package/dist/client/chat.js.map +1 -1
- package/dist/client/components/agent-picker.d.ts +6 -23
- package/dist/client/components/agent-picker.d.ts.map +1 -1
- package/dist/client/components/agent-picker.js +19 -39
- package/dist/client/components/agent-picker.js.map +1 -1
- package/dist/client/components/variables/variable-dialogs.d.ts +6 -1
- package/dist/client/components/variables/variable-dialogs.d.ts.map +1 -1
- package/dist/client/components/variables/variable-dialogs.js +27 -11
- package/dist/client/components/variables/variable-dialogs.js.map +1 -1
- package/dist/client/components/variables/variables-panel.d.ts.map +1 -1
- package/dist/client/components/variables/variables-panel.js +9 -2
- package/dist/client/components/variables/variables-panel.js.map +1 -1
- package/dist/client/hooks/use-agent-picker-labels.d.ts.map +1 -1
- package/dist/client/hooks/use-agent-picker-labels.js +3 -12
- package/dist/client/hooks/use-agent-picker-labels.js.map +1 -1
- package/dist/client/kit.d.ts +9 -12
- package/dist/client/kit.d.ts.map +1 -1
- package/dist/client/kit.js +12 -14
- package/dist/client/kit.js.map +1 -1
- package/dist/client/lib/agents.d.ts +5 -13
- package/dist/client/lib/agents.d.ts.map +1 -1
- package/dist/client/lib/agents.js +17 -32
- package/dist/client/lib/agents.js.map +1 -1
- package/dist/client/lib/install.js +1 -1
- package/dist/client/locales/chat.en-US.d.ts +9 -22
- package/dist/client/locales/chat.en-US.d.ts.map +1 -1
- package/dist/client/locales/chat.en-US.js +13 -25
- package/dist/client/locales/chat.en-US.js.map +1 -1
- package/dist/client/locales/chat.zh-CN.d.ts.map +1 -1
- package/dist/client/locales/chat.zh-CN.js +10 -22
- package/dist/client/locales/chat.zh-CN.js.map +1 -1
- package/dist/client/locales/en-US.d.ts +100 -219
- package/dist/client/locales/en-US.d.ts.map +1 -1
- package/dist/client/locales/en-US.js +105 -219
- package/dist/client/locales/en-US.js.map +1 -1
- package/dist/client/locales/runWait.en-US.d.ts +38 -0
- package/dist/client/locales/runWait.en-US.d.ts.map +1 -0
- package/dist/client/locales/runWait.en-US.js +37 -0
- package/dist/client/locales/runWait.en-US.js.map +1 -0
- package/dist/client/locales/runWait.zh-CN.d.ts +5 -0
- package/dist/client/locales/runWait.zh-CN.d.ts.map +1 -0
- package/dist/client/locales/runWait.zh-CN.js +32 -0
- package/dist/client/locales/runWait.zh-CN.js.map +1 -0
- package/dist/client/locales/runtimes.en-US.d.ts +55 -0
- package/dist/client/locales/runtimes.en-US.d.ts.map +1 -1
- package/dist/client/locales/runtimes.en-US.js +58 -3
- package/dist/client/locales/runtimes.en-US.js.map +1 -1
- package/dist/client/locales/runtimes.zh-CN.d.ts.map +1 -1
- package/dist/client/locales/runtimes.zh-CN.js +58 -3
- package/dist/client/locales/runtimes.zh-CN.js.map +1 -1
- package/dist/client/locales/zh-CN.d.ts.map +1 -1
- package/dist/client/locales/zh-CN.js +107 -221
- package/dist/client/locales/zh-CN.js.map +1 -1
- package/dist/client/online/services.d.ts.map +1 -1
- package/dist/client/online/services.js +5 -6
- package/dist/client/online/services.js.map +1 -1
- package/dist/client/pages/agents/agent-dialog.d.ts +9 -0
- package/dist/client/pages/agents/agent-dialog.d.ts.map +1 -0
- package/dist/client/pages/agents/agent-dialog.js +106 -0
- package/dist/client/pages/agents/agent-dialog.js.map +1 -0
- package/dist/client/pages/agents/agent-state.d.ts +11 -0
- package/dist/client/pages/agents/agent-state.d.ts.map +1 -0
- package/dist/client/pages/agents/agent-state.js +28 -0
- package/dist/client/pages/agents/agent-state.js.map +1 -0
- package/dist/client/pages/agents/index.d.ts +1 -1
- package/dist/client/pages/agents/index.d.ts.map +1 -1
- package/dist/client/pages/agents/index.js +6 -100
- package/dist/client/pages/agents/index.js.map +1 -1
- package/dist/client/pages/agents/runner-agents.d.ts +3 -0
- package/dist/client/pages/agents/runner-agents.d.ts.map +1 -0
- package/dist/client/pages/agents/runner-agents.js +172 -0
- package/dist/client/pages/agents/runner-agents.js.map +1 -0
- package/dist/client/pages/runtimes/connect.js +1 -1
- package/dist/client/pages/runtimes/connect.js.map +1 -1
- package/dist/client/pages/runtimes/index.d.ts.map +1 -1
- package/dist/client/pages/runtimes/index.js +3 -2
- package/dist/client/pages/runtimes/index.js.map +1 -1
- package/dist/client/pages/runtimes/runner-cells.d.ts +1 -1
- package/dist/client/pages/runtimes/runner-cells.d.ts.map +1 -1
- package/dist/client/pages/runtimes/runner-cells.js +4 -1
- package/dist/client/pages/runtimes/runner-cells.js.map +1 -1
- package/dist/client/pages/runtimes/runner-sheet.d.ts.map +1 -1
- package/dist/client/pages/runtimes/runner-sheet.js +12 -3
- package/dist/client/pages/runtimes/runner-sheet.js.map +1 -1
- package/dist/client/pages/runtimes/workspace-diagnostics.d.ts +9 -0
- package/dist/client/pages/runtimes/workspace-diagnostics.d.ts.map +1 -0
- package/dist/client/pages/runtimes/workspace-diagnostics.js +70 -0
- package/dist/client/pages/runtimes/workspace-diagnostics.js.map +1 -0
- package/dist/client/pages/usage/index.js +2 -2
- package/dist/client/pages/usage/index.js.map +1 -1
- package/dist/client/profile/default-agent.d.ts.map +1 -1
- package/dist/client/profile/default-agent.js +2 -4
- package/dist/client/profile/default-agent.js.map +1 -1
- package/dist/client/routes.d.ts +1 -1
- package/dist/client/routes.d.ts.map +1 -1
- package/dist/client/routes.js +1 -13
- package/dist/client/routes.js.map +1 -1
- package/dist/client/runs/format-wait.d.ts +21 -0
- package/dist/client/runs/format-wait.d.ts.map +1 -0
- package/dist/client/runs/format-wait.js +90 -0
- package/dist/client/runs/format-wait.js.map +1 -0
- package/dist/client/runs/subject-runs.d.ts +5 -0
- package/dist/client/runs/subject-runs.d.ts.map +1 -1
- package/dist/client/runs/subject-runs.js +13 -7
- package/dist/client/runs/subject-runs.js.map +1 -1
- package/dist/client/runs.d.ts +3 -1
- package/dist/client/runs.d.ts.map +1 -1
- package/dist/client/runs.js +3 -1
- package/dist/client/runs.js.map +1 -1
- package/dist/database/migrations/.manifest.json +48 -0
- package/dist/database/migrations/202610090001_ag_add_team_runner_variables.d.ts +9 -0
- package/dist/database/migrations/202610090001_ag_add_team_runner_variables.d.ts.map +1 -0
- package/dist/database/migrations/202610090001_ag_add_team_runner_variables.js +28 -0
- package/dist/database/migrations/202610090001_ag_add_team_runner_variables.js.map +1 -0
- package/dist/database/migrations/202610090002_ag_create_run_requests.d.ts +10 -0
- package/dist/database/migrations/202610090002_ag_create_run_requests.d.ts.map +1 -0
- package/dist/database/migrations/202610090002_ag_create_run_requests.js +105 -0
- package/dist/database/migrations/202610090002_ag_create_run_requests.js.map +1 -0
- package/dist/database/migrations/202610090003_ag_add_execution_history.d.ts +4 -0
- package/dist/database/migrations/202610090003_ag_add_execution_history.d.ts.map +1 -0
- package/dist/database/migrations/202610090003_ag_add_execution_history.js +17 -0
- package/dist/database/migrations/202610090003_ag_add_execution_history.js.map +1 -0
- package/dist/database/migrations/202610090004_ag_add_runner_workspace_usage.d.ts +9 -0
- package/dist/database/migrations/202610090004_ag_add_runner_workspace_usage.d.ts.map +1 -0
- package/dist/database/migrations/202610090004_ag_add_runner_workspace_usage.js +22 -0
- package/dist/database/migrations/202610090004_ag_add_runner_workspace_usage.js.map +1 -0
- package/dist/database/migrations/202610090005_ag_add_runner_variables.d.ts +10 -0
- package/dist/database/migrations/202610090005_ag_add_runner_variables.d.ts.map +1 -0
- package/dist/database/migrations/202610090005_ag_add_runner_variables.js +36 -0
- package/dist/database/migrations/202610090005_ag_add_runner_variables.js.map +1 -0
- package/dist/database/migrations/202610100001_ag_index_run_event_types.d.ts +4 -0
- package/dist/database/migrations/202610100001_ag_index_run_event_types.d.ts.map +1 -0
- package/dist/database/migrations/202610100001_ag_index_run_event_types.js +17 -0
- package/dist/database/migrations/202610100001_ag_index_run_event_types.js.map +1 -0
- package/dist/database/migrations/202610100002_ag_add_run_git_credentials.d.ts +9 -0
- package/dist/database/migrations/202610100002_ag_add_run_git_credentials.d.ts.map +1 -0
- package/dist/database/migrations/202610100002_ag_add_run_git_credentials.js +30 -0
- package/dist/database/migrations/202610100002_ag_add_run_git_credentials.js.map +1 -0
- package/dist/database/migrations/202610110001_ag_add_fresh_sessions.d.ts +4 -0
- package/dist/database/migrations/202610110001_ag_add_fresh_sessions.d.ts.map +1 -0
- package/dist/database/migrations/202610110001_ag_add_fresh_sessions.js +23 -0
- package/dist/database/migrations/202610110001_ag_add_fresh_sessions.js.map +1 -0
- package/dist/database/migrations/202610120001_ag_index_run_retries.d.ts +4 -0
- package/dist/database/migrations/202610120001_ag_index_run_retries.d.ts.map +1 -0
- package/dist/database/migrations/202610120001_ag_index_run_retries.js +17 -0
- package/dist/database/migrations/202610120001_ag_index_run_retries.js.map +1 -0
- package/dist/database/migrations/202610120002_ag_add_queue_entered_at.d.ts +4 -0
- package/dist/database/migrations/202610120002_ag_add_queue_entered_at.d.ts.map +1 -0
- package/dist/database/migrations/202610120002_ag_add_queue_entered_at.js +50 -0
- package/dist/database/migrations/202610120002_ag_add_queue_entered_at.js.map +1 -0
- package/dist/database/migrations/202610240020_ag_runner_agents.d.ts +4 -0
- package/dist/database/migrations/202610240020_ag_runner_agents.d.ts.map +1 -0
- package/dist/database/migrations/202610240020_ag_runner_agents.js +115 -0
- package/dist/database/migrations/202610240020_ag_runner_agents.js.map +1 -0
- package/dist/database/migrations/202610240040_ag_discovery_preferences.d.ts +4 -0
- package/dist/database/migrations/202610240040_ag_discovery_preferences.d.ts.map +1 -0
- package/dist/database/migrations/202610240040_ag_discovery_preferences.js +18 -0
- package/dist/database/migrations/202610240040_ag_discovery_preferences.js.map +1 -0
- package/dist/package.json +8 -10
- package/dist/server/cli/run-credential.js +1 -1
- package/dist/server/composition.d.ts +39 -37
- package/dist/server/composition.d.ts.map +1 -1
- package/dist/server/composition.js +53 -65
- package/dist/server/composition.js.map +1 -1
- package/dist/server/core/agents/agent.service.d.ts +51 -43
- package/dist/server/core/agents/agent.service.d.ts.map +1 -1
- package/dist/server/core/agents/agent.service.js +342 -317
- package/dist/server/core/agents/agent.service.js.map +1 -1
- package/dist/server/core/agents/agent.store.d.ts +24 -12
- package/dist/server/core/agents/agent.store.d.ts.map +1 -1
- package/dist/server/core/agents/agent.store.js +65 -64
- package/dist/server/core/agents/agent.store.js.map +1 -1
- package/dist/server/core/agents/agent.views.d.ts +29 -0
- package/dist/server/core/agents/agent.views.d.ts.map +1 -0
- package/dist/server/core/agents/agent.views.js +86 -0
- package/dist/server/core/agents/agent.views.js.map +1 -0
- package/dist/server/core/agents/discovery.d.ts +12 -0
- package/dist/server/core/agents/discovery.d.ts.map +1 -0
- package/dist/server/core/agents/discovery.js +39 -0
- package/dist/server/core/agents/discovery.js.map +1 -0
- package/dist/server/core/agents/index.d.ts +2 -1
- package/dist/server/core/agents/index.d.ts.map +1 -1
- package/dist/server/core/agents/index.js +2 -1
- package/dist/server/core/agents/index.js.map +1 -1
- package/dist/server/core/brief/brief.js +1 -1
- package/dist/server/core/brief/brief.js.map +1 -1
- package/dist/server/core/callers/index.d.ts +1 -1
- package/dist/server/core/conversations/availability.d.ts +11 -10
- package/dist/server/core/conversations/availability.d.ts.map +1 -1
- package/dist/server/core/conversations/availability.js +14 -32
- package/dist/server/core/conversations/availability.js.map +1 -1
- package/dist/server/core/conversations/chat-settings.d.ts.map +1 -1
- package/dist/server/core/conversations/chat-settings.js +5 -3
- package/dist/server/core/conversations/chat-settings.js.map +1 -1
- package/dist/server/core/conversations/conversation.service.d.ts +3 -5
- package/dist/server/core/conversations/conversation.service.d.ts.map +1 -1
- package/dist/server/core/conversations/conversation.service.js +161 -221
- package/dist/server/core/conversations/conversation.service.js.map +1 -1
- package/dist/server/core/conversations/ports.d.ts +3 -17
- package/dist/server/core/conversations/ports.d.ts.map +1 -1
- package/dist/server/core/reports/report.service.d.ts.map +1 -1
- package/dist/server/core/reports/report.service.js +5 -2
- package/dist/server/core/reports/report.service.js.map +1 -1
- package/dist/server/core/runs/availability.d.ts +18 -7
- package/dist/server/core/runs/availability.d.ts.map +1 -1
- package/dist/server/core/runs/availability.js +35 -24
- package/dist/server/core/runs/availability.js.map +1 -1
- package/dist/server/core/runs/claim.d.ts +33 -65
- package/dist/server/core/runs/claim.d.ts.map +1 -1
- package/dist/server/core/runs/claim.js +566 -307
- package/dist/server/core/runs/claim.js.map +1 -1
- package/dist/server/core/runs/eligibility.d.ts +51 -0
- package/dist/server/core/runs/eligibility.d.ts.map +1 -0
- package/dist/server/core/runs/eligibility.js +44 -0
- package/dist/server/core/runs/eligibility.js.map +1 -0
- package/dist/server/core/runs/execution-view.d.ts +10 -0
- package/dist/server/core/runs/execution-view.d.ts.map +1 -0
- package/dist/server/core/runs/execution-view.js +25 -0
- package/dist/server/core/runs/execution-view.js.map +1 -0
- package/dist/server/core/runs/execution.d.ts +13 -0
- package/dist/server/core/runs/execution.d.ts.map +1 -0
- package/dist/server/core/runs/execution.js +85 -0
- package/dist/server/core/runs/execution.js.map +1 -0
- package/dist/server/core/runs/extensions.d.ts +59 -4
- package/dist/server/core/runs/extensions.d.ts.map +1 -1
- package/dist/server/core/runs/extensions.js +45 -9
- package/dist/server/core/runs/extensions.js.map +1 -1
- package/dist/server/core/runs/git-credentials.d.ts +43 -0
- package/dist/server/core/runs/git-credentials.d.ts.map +1 -0
- package/dist/server/core/runs/git-credentials.js +129 -0
- package/dist/server/core/runs/git-credentials.js.map +1 -0
- package/dist/server/core/runs/identity.d.ts +6 -0
- package/dist/server/core/runs/identity.d.ts.map +1 -0
- package/dist/server/core/runs/identity.js +49 -0
- package/dist/server/core/runs/identity.js.map +1 -0
- package/dist/server/core/runs/index.d.ts +9 -5
- package/dist/server/core/runs/index.d.ts.map +1 -1
- package/dist/server/core/runs/index.js +9 -5
- package/dist/server/core/runs/index.js.map +1 -1
- package/dist/server/core/runs/input-gate.d.ts +34 -0
- package/dist/server/core/runs/input-gate.d.ts.map +1 -0
- package/dist/server/core/runs/input-gate.js +54 -0
- package/dist/server/core/runs/input-gate.js.map +1 -0
- package/dist/server/core/runs/lifecycle.d.ts +9 -19
- package/dist/server/core/runs/lifecycle.d.ts.map +1 -1
- package/dist/server/core/runs/lifecycle.js +76 -34
- package/dist/server/core/runs/lifecycle.js.map +1 -1
- package/dist/server/core/runs/policy.d.ts +8 -0
- package/dist/server/core/runs/policy.d.ts.map +1 -1
- package/dist/server/core/runs/policy.js +10 -0
- package/dist/server/core/runs/policy.js.map +1 -1
- package/dist/server/core/runs/ports.d.ts +84 -28
- package/dist/server/core/runs/ports.d.ts.map +1 -1
- package/dist/server/core/runs/ports.js +2 -13
- package/dist/server/core/runs/ports.js.map +1 -1
- package/dist/server/core/runs/preview.d.ts.map +1 -1
- package/dist/server/core/runs/preview.js +3 -3
- package/dist/server/core/runs/preview.js.map +1 -1
- package/dist/server/core/runs/run-requests.d.ts +220 -0
- package/dist/server/core/runs/run-requests.d.ts.map +1 -0
- package/dist/server/core/runs/run-requests.js +475 -0
- package/dist/server/core/runs/run-requests.js.map +1 -0
- package/dist/server/core/runs/run.service.d.ts +84 -11
- package/dist/server/core/runs/run.service.d.ts.map +1 -1
- package/dist/server/core/runs/run.service.js +433 -93
- package/dist/server/core/runs/run.service.js.map +1 -1
- package/dist/server/core/runs/run.store.d.ts +20 -3
- package/dist/server/core/runs/run.store.d.ts.map +1 -1
- package/dist/server/core/runs/run.store.js +49 -2
- package/dist/server/core/runs/run.store.js.map +1 -1
- package/dist/server/core/runs/runner-view.d.ts +6 -4
- package/dist/server/core/runs/runner-view.d.ts.map +1 -1
- package/dist/server/core/runs/runner-view.js +13 -11
- package/dist/server/core/runs/runner-view.js.map +1 -1
- package/dist/server/core/runs/selection.d.ts +13 -0
- package/dist/server/core/runs/selection.d.ts.map +1 -0
- package/dist/server/core/runs/selection.js +21 -0
- package/dist/server/core/runs/selection.js.map +1 -0
- package/dist/server/core/runs/sweeper.d.ts.map +1 -1
- package/dist/server/core/runs/sweeper.js +54 -10
- package/dist/server/core/runs/sweeper.js.map +1 -1
- package/dist/server/core/runs/transitions.d.ts +1 -1
- package/dist/server/core/runs/transitions.d.ts.map +1 -1
- package/dist/server/core/runs/transitions.js +69 -5
- package/dist/server/core/runs/transitions.js.map +1 -1
- package/dist/server/core/runs/workload.d.ts +3 -3
- package/dist/server/core/runs/workload.d.ts.map +1 -1
- package/dist/server/core/runs/workload.js +154 -45
- package/dist/server/core/runs/workload.js.map +1 -1
- package/dist/server/core/variables/index.d.ts +1 -1
- package/dist/server/core/variables/index.d.ts.map +1 -1
- package/dist/server/core/variables/index.js +1 -1
- package/dist/server/core/variables/index.js.map +1 -1
- package/dist/server/core/variables/variable.service.d.ts +38 -6
- package/dist/server/core/variables/variable.service.d.ts.map +1 -1
- package/dist/server/core/variables/variable.service.js +201 -30
- package/dist/server/core/variables/variable.service.js.map +1 -1
- package/dist/server/distribution/dist.service.d.ts +27 -5
- package/dist/server/distribution/dist.service.d.ts.map +1 -1
- package/dist/server/distribution/dist.service.js +41 -5
- package/dist/server/distribution/dist.service.js.map +1 -1
- package/dist/server/distribution/download-tokens.d.ts +1 -1
- package/dist/server/distribution/download-tokens.d.ts.map +1 -1
- package/dist/server/distribution/download-tokens.js +7 -4
- package/dist/server/distribution/download-tokens.js.map +1 -1
- package/dist/server/distribution/index.d.ts +11 -3
- package/dist/server/distribution/index.d.ts.map +1 -1
- package/dist/server/distribution/index.js +31 -8
- package/dist/server/distribution/index.js.map +1 -1
- package/dist/server/jobs/index.d.ts +1 -1
- package/dist/server/jobs/index.d.ts.map +1 -1
- package/dist/server/jobs/index.js +1 -1
- package/dist/server/jobs/index.js.map +1 -1
- package/dist/server/jobs/job.service.d.ts +3 -1
- package/dist/server/jobs/job.service.d.ts.map +1 -1
- package/dist/server/jobs/job.service.js +11 -3
- package/dist/server/jobs/job.service.js.map +1 -1
- package/dist/server/jobs/spec.d.ts +4 -0
- package/dist/server/jobs/spec.d.ts.map +1 -1
- package/dist/server/jobs/spec.js +6 -0
- package/dist/server/jobs/spec.js.map +1 -1
- package/dist/server/kernel/errors.d.ts +1 -1
- package/dist/server/kernel/errors.d.ts.map +1 -1
- package/dist/server/kernel/errors.js +1 -0
- package/dist/server/kernel/errors.js.map +1 -1
- package/dist/server/kernel/events.d.ts +34 -9
- package/dist/server/kernel/events.d.ts.map +1 -1
- package/dist/server/kernel/events.js.map +1 -1
- package/dist/server/kernel/redaction.d.ts +2 -0
- package/dist/server/kernel/redaction.d.ts.map +1 -1
- package/dist/server/kernel/redaction.js +17 -0
- package/dist/server/kernel/redaction.js.map +1 -1
- package/dist/server/online/index.d.ts +0 -5
- package/dist/server/online/index.d.ts.map +1 -1
- package/dist/server/online/index.js +0 -5
- package/dist/server/online/index.js.map +1 -1
- package/dist/server/online/routes.d.ts.map +1 -1
- package/dist/server/online/routes.js +6 -35
- package/dist/server/online/routes.js.map +1 -1
- package/dist/server/providers/agents.d.ts +4 -25
- package/dist/server/providers/agents.d.ts.map +1 -1
- package/dist/server/providers/agents.js +8 -75
- package/dist/server/providers/agents.js.map +1 -1
- package/dist/server/routes/admin.d.ts.map +1 -1
- package/dist/server/routes/admin.js +140 -201
- package/dist/server/routes/admin.js.map +1 -1
- package/dist/server/routes/chat.d.ts.map +1 -1
- package/dist/server/routes/chat.js +12 -70
- package/dist/server/routes/chat.js.map +1 -1
- package/dist/server/routes/index.d.ts.map +1 -1
- package/dist/server/routes/index.js +11 -1
- package/dist/server/routes/index.js.map +1 -1
- package/dist/server/routes/roster.d.ts.map +1 -1
- package/dist/server/routes/roster.js +6 -21
- package/dist/server/routes/roster.js.map +1 -1
- package/dist/server/routes/run-requests.d.ts +6 -0
- package/dist/server/routes/run-requests.d.ts.map +1 -0
- package/dist/server/routes/run-requests.js +216 -0
- package/dist/server/routes/run-requests.js.map +1 -0
- package/dist/server/routes/runners/admin.d.ts +9 -1
- package/dist/server/routes/runners/admin.d.ts.map +1 -1
- package/dist/server/routes/runners/admin.js +62 -24
- package/dist/server/routes/runners/admin.js.map +1 -1
- package/dist/server/routes/runners/dist.d.ts +5 -1
- package/dist/server/routes/runners/dist.d.ts.map +1 -1
- package/dist/server/routes/runners/dist.js +36 -9
- package/dist/server/routes/runners/dist.js.map +1 -1
- package/dist/server/routes/runners/install.d.ts.map +1 -1
- package/dist/server/routes/runners/install.js +98 -15
- package/dist/server/routes/runners/install.js.map +1 -1
- package/dist/server/routes/runners/runner.d.ts.map +1 -1
- package/dist/server/routes/runners/runner.js +25 -7
- package/dist/server/routes/runners/runner.js.map +1 -1
- package/dist/server/routes/runners/runs.d.ts +1 -1
- package/dist/server/routes/runners/runs.d.ts.map +1 -1
- package/dist/server/routes/runners/runs.js +23 -3
- package/dist/server/routes/runners/runs.js.map +1 -1
- package/dist/server/routes/schemas.d.ts +37 -8
- package/dist/server/routes/schemas.d.ts.map +1 -1
- package/dist/server/routes/schemas.js +367 -82
- package/dist/server/routes/schemas.js.map +1 -1
- package/dist/server/runners/index.d.ts +1 -0
- package/dist/server/runners/index.d.ts.map +1 -1
- package/dist/server/runners/index.js +1 -0
- package/dist/server/runners/index.js.map +1 -1
- package/dist/server/runners/runner.service.d.ts +22 -8
- package/dist/server/runners/runner.service.d.ts.map +1 -1
- package/dist/server/runners/runner.service.js +112 -14
- package/dist/server/runners/runner.service.js.map +1 -1
- package/dist/server/runners/runner.store.d.ts +10 -1
- package/dist/server/runners/runner.store.d.ts.map +1 -1
- package/dist/server/runners/runner.store.js +117 -4
- package/dist/server/runners/runner.store.js.map +1 -1
- package/dist/server/runners/sweeper.d.ts +5 -0
- package/dist/server/runners/sweeper.d.ts.map +1 -1
- package/dist/server/runners/sweeper.js +4 -2
- package/dist/server/runners/sweeper.js.map +1 -1
- package/dist/server/runners/workspaces.d.ts +33 -0
- package/dist/server/runners/workspaces.d.ts.map +1 -0
- package/dist/server/runners/workspaces.js +248 -0
- package/dist/server/runners/workspaces.js.map +1 -0
- package/dist/server/testing.d.ts +0 -2
- package/dist/server/testing.d.ts.map +1 -1
- package/dist/server/testing.js +1 -4
- package/dist/server/testing.js.map +1 -1
- package/dist/server/tokens.d.ts +12 -9
- package/dist/server/tokens.d.ts.map +1 -1
- package/dist/server/tokens.js +6 -2
- package/dist/server/tokens.js.map +1 -1
- package/dist/shared/access.d.ts +2 -6
- package/dist/shared/access.d.ts.map +1 -1
- package/dist/shared/access.js +2 -6
- package/dist/shared/access.js.map +1 -1
- package/dist/shared/agents.d.ts +128 -165
- package/dist/shared/agents.d.ts.map +1 -1
- package/dist/shared/agents.js +46 -97
- package/dist/shared/agents.js.map +1 -1
- package/dist/shared/conversations.d.ts +43 -89
- package/dist/shared/conversations.d.ts.map +1 -1
- package/dist/shared/conversations.js +5 -24
- package/dist/shared/conversations.js.map +1 -1
- package/dist/shared/model-catalog.d.ts +48 -0
- package/dist/shared/model-catalog.d.ts.map +1 -0
- package/dist/shared/model-catalog.js +148 -0
- package/dist/shared/model-catalog.js.map +1 -0
- package/dist/shared/models.js +1 -1
- package/dist/shared/models.js.map +1 -1
- package/dist/shared/runners.d.ts +107 -17
- package/dist/shared/runners.d.ts.map +1 -1
- package/dist/shared/runners.js +49 -7
- package/dist/shared/runners.js.map +1 -1
- package/dist/shared/runs.d.ts +203 -1
- package/dist/shared/runs.d.ts.map +1 -1
- package/dist/shared/runs.js +24 -0
- package/dist/shared/runs.js.map +1 -1
- package/dist/shared/variables.d.ts +22 -0
- package/dist/shared/variables.d.ts.map +1 -1
- package/dist/shared/variables.js +9 -1
- package/dist/shared/variables.js.map +1 -1
- package/package.json +24 -26
- package/skills/nocobase-app-plugin-agents/SKILL.md +8 -7
- package/skills/nocobase-app-plugin-agents/references/agents.md +30 -0
- package/skills/nocobase-app-plugin-agents/references/distribution.md +21 -4
- package/skills/nocobase-app-plugin-agents/references/extension-points.md +30 -20
- package/skills/nocobase-app-plugin-agents/references/model-services.md +17 -0
- package/skills/nocobase-app-plugin-agents/references/runners.md +15 -1
- package/skills/nocobase-app-plugin-agents/references/setup-and-config.md +4 -7
- package/skills/nocobase-app-plugin-agents/references/variables-skills-usage.md +4 -4
- package/skills/nocobase-app-plugin-agents/references/verification-and-troubleshooting.md +33 -32
- package/dist/client/chat/settings-section.d.ts +0 -5
- package/dist/client/chat/settings-section.d.ts.map +0 -1
- package/dist/client/chat/settings-section.js +0 -76
- package/dist/client/chat/settings-section.js.map +0 -1
- package/dist/client/components/agent-fields.d.ts +0 -45
- package/dist/client/components/agent-fields.d.ts.map +0 -1
- package/dist/client/components/agent-fields.js +0 -83
- package/dist/client/components/agent-fields.js.map +0 -1
- package/dist/client/components/agent-type.d.ts +0 -32
- package/dist/client/components/agent-type.d.ts.map +0 -1
- package/dist/client/components/agent-type.js +0 -80
- package/dist/client/components/agent-type.js.map +0 -1
- package/dist/client/components/model-entries.d.ts +0 -35
- package/dist/client/components/model-entries.d.ts.map +0 -1
- package/dist/client/components/model-entries.js +0 -82
- package/dist/client/components/model-entries.js.map +0 -1
- package/dist/client/hooks/use-agent-save.d.ts +0 -9
- package/dist/client/hooks/use-agent-save.d.ts.map +0 -1
- package/dist/client/hooks/use-agent-save.js +0 -40
- package/dist/client/hooks/use-agent-save.js.map +0 -1
- package/dist/client/hooks/use-model-catalog.d.ts +0 -9
- package/dist/client/hooks/use-model-catalog.d.ts.map +0 -1
- package/dist/client/hooks/use-model-catalog.js +0 -27
- package/dist/client/hooks/use-model-catalog.js.map +0 -1
- package/dist/client/lib/tool-policy.d.ts +0 -5
- package/dist/client/lib/tool-policy.d.ts.map +0 -1
- package/dist/client/lib/tool-policy.js +0 -10
- package/dist/client/lib/tool-policy.js.map +0 -1
- package/dist/client/online/default-model.d.ts +0 -5
- package/dist/client/online/default-model.d.ts.map +0 -1
- package/dist/client/online/default-model.js +0 -65
- package/dist/client/online/default-model.js.map +0 -1
- package/dist/client/pages/agents/agent-model.d.ts +0 -73
- package/dist/client/pages/agents/agent-model.d.ts.map +0 -1
- package/dist/client/pages/agents/agent-model.js +0 -172
- package/dist/client/pages/agents/agent-model.js.map +0 -1
- package/dist/client/pages/agents/detail/brief-preview.d.ts +0 -7
- package/dist/client/pages/agents/detail/brief-preview.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/brief-preview.js +0 -43
- package/dist/client/pages/agents/detail/brief-preview.js.map +0 -1
- package/dist/client/pages/agents/detail/history.d.ts +0 -11
- package/dist/client/pages/agents/detail/history.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/history.js +0 -149
- package/dist/client/pages/agents/detail/history.js.map +0 -1
- package/dist/client/pages/agents/detail/index.d.ts +0 -3
- package/dist/client/pages/agents/detail/index.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/index.js +0 -241
- package/dist/client/pages/agents/detail/index.js.map +0 -1
- package/dist/client/pages/agents/detail/sections.d.ts +0 -22
- package/dist/client/pages/agents/detail/sections.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/sections.js +0 -311
- package/dist/client/pages/agents/detail/sections.js.map +0 -1
- package/dist/client/pages/agents/detail/tab-draft.d.ts +0 -43
- package/dist/client/pages/agents/detail/tab-draft.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/tab-draft.js +0 -115
- package/dist/client/pages/agents/detail/tab-draft.js.map +0 -1
- package/dist/client/pages/agents/detail/unsaved-bar.d.ts +0 -13
- package/dist/client/pages/agents/detail/unsaved-bar.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/unsaved-bar.js +0 -21
- package/dist/client/pages/agents/detail/unsaved-bar.js.map +0 -1
- package/dist/client/pages/agents/new.d.ts +0 -3
- package/dist/client/pages/agents/new.d.ts.map +0 -1
- package/dist/client/pages/agents/new.js +0 -149
- package/dist/client/pages/agents/new.js.map +0 -1
- package/dist/client/pages/agents/preset-picker.d.ts +0 -8
- package/dist/client/pages/agents/preset-picker.d.ts.map +0 -1
- package/dist/client/pages/agents/preset-picker.js +0 -41
- package/dist/client/pages/agents/preset-picker.js.map +0 -1
- package/dist/server/core/consultations/consultation.service.d.ts +0 -59
- package/dist/server/core/consultations/consultation.service.d.ts.map +0 -1
- package/dist/server/core/consultations/consultation.service.js +0 -195
- package/dist/server/core/consultations/consultation.service.js.map +0 -1
- package/dist/server/core/consultations/index.d.ts +0 -3
- package/dist/server/core/consultations/index.d.ts.map +0 -1
- package/dist/server/core/consultations/index.js +0 -3
- package/dist/server/core/consultations/index.js.map +0 -1
- package/dist/server/core/consultations/prompt.d.ts +0 -41
- package/dist/server/core/consultations/prompt.d.ts.map +0 -1
- package/dist/server/core/consultations/prompt.js +0 -64
- package/dist/server/core/consultations/prompt.js.map +0 -1
- package/dist/server/core/presets/index.d.ts +0 -19
- package/dist/server/core/presets/index.d.ts.map +0 -1
- package/dist/server/core/presets/index.js +0 -28
- package/dist/server/core/presets/index.js.map +0 -1
- package/dist/server/online/cli-command.d.ts +0 -20
- package/dist/server/online/cli-command.d.ts.map +0 -1
- package/dist/server/online/cli-command.js +0 -345
- package/dist/server/online/cli-command.js.map +0 -1
- package/dist/server/online/consult-tool.d.ts +0 -54
- package/dist/server/online/consult-tool.d.ts.map +0 -1
- package/dist/server/online/consult-tool.js +0 -177
- package/dist/server/online/consult-tool.js.map +0 -1
- package/dist/server/online/executor.d.ts +0 -83
- package/dist/server/online/executor.d.ts.map +0 -1
- package/dist/server/online/executor.js +0 -714
- package/dist/server/online/executor.js.map +0 -1
- package/dist/server/online/sandbox.d.ts +0 -32
- package/dist/server/online/sandbox.d.ts.map +0 -1
- package/dist/server/online/sandbox.js +0 -246
- package/dist/server/online/sandbox.js.map +0 -1
- package/dist/server/online/scripted.d.ts +0 -12
- package/dist/server/online/scripted.d.ts.map +0 -1
- package/dist/server/online/scripted.js +0 -176
- package/dist/server/online/scripted.js.map +0 -1
- package/dist/server/online/tools.d.ts +0 -17
- package/dist/server/online/tools.d.ts.map +0 -1
- package/dist/server/online/tools.js +0 -31
- package/dist/server/online/tools.js.map +0 -1
- package/dist/server/vendor/THIRD_PARTY_LICENSES.txt +0 -782
- package/dist/server/vendor/just-bash.d.ts +0 -83
- package/dist/server/vendor/just-bash.js +0 -2102
- package/dist/shared/presets.d.ts +0 -30
- package/dist/shared/presets.d.ts.map +0 -1
- package/dist/shared/presets.js +0 -2
- package/dist/shared/presets.js.map +0 -1
- package/skills/nocobase-app-plugin-agents/references/online-agents.md +0 -31
|
@@ -3,20 +3,36 @@
|
|
|
3
3
|
* cancelling and retrying, and reading runs and their transcripts. Who may read or change a run is decided by the
|
|
4
4
|
* callers (the admin routes, the application); this service checks only that the person who wakes an agent may wake it.
|
|
5
5
|
*
|
|
6
|
-
* Work is keyed by (agent, subject, thread). New work for a key joins the run already working on it
|
|
7
|
-
* still be told (dispatched, or running with input), else
|
|
6
|
+
* Work is keyed by (agent, subject, thread). New work for a key joins the run already working on it as the same person
|
|
7
|
+
* while it can still be told (dispatched, or running with input), else that person's run waiting for it (queued), else
|
|
8
|
+
* starts a new run. Runs of one key working as different people are claimed one at a time (`claim.ts`).
|
|
8
9
|
*/
|
|
9
10
|
import { ProtocolError, TERMINAL_RUN_STATUSES, } from '@nocobase/agent-protocol';
|
|
10
11
|
import { conflict, forbidden, invalid, notFound, precondition, } from '../../kernel/errors.js';
|
|
11
12
|
import { asJson, cleanList, jsonObject } from '../../kernel/values.js';
|
|
12
13
|
import { findAgent, lockAgentForClaim } from '../agents/index.js';
|
|
14
|
+
import { agentNamesOf } from '../agents/agent.store.js';
|
|
15
|
+
import { createRunRequestService, insertRunRequest, } from './run-requests.js';
|
|
13
16
|
import { authenticateRunToken } from './run-tokens.js';
|
|
14
17
|
import { ACTIVE, eventsRepo, findRunRecord, inputsOnSince, inputsRepo, isActive, isTerminal, lastSummary, openRunsOn, pendingInputs, reposRepo, runsOfKey, runsRepo, toInput, toInputView, toRepo, toRun, usageRepo, } from './run.store.js';
|
|
15
|
-
import { dialectOf, takesType } from './ports.js';
|
|
16
18
|
import { readWorkload } from './workload.js';
|
|
17
19
|
import { finishRun } from './transitions.js';
|
|
20
|
+
import { gateInputs, gatePending } from './input-gate.js';
|
|
18
21
|
import { findBrief, requestReset } from './workspace.store.js';
|
|
19
22
|
export const DEFAULT_THREAD = 'main';
|
|
23
|
+
/**
|
|
24
|
+
* The run work went into, for a caller that names no responsible (a conversation, a consultation): such work is never
|
|
25
|
+
* pending, so a pending result is a programming error.
|
|
26
|
+
*/
|
|
27
|
+
export function queuedRun(result) {
|
|
28
|
+
if (result.outcome === 'pending')
|
|
29
|
+
throw new Error('Work that names no responsible was turned into a run request.');
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/** Who a chain of work a run belongs to started with: who confirmed it, else who it was requested by. */
|
|
33
|
+
function chainSourceOf(run) {
|
|
34
|
+
return run.confirmedByUserId ?? run.requestedByUserId ?? run.actorUserId;
|
|
35
|
+
}
|
|
20
36
|
/** A delay as the moment a run may be claimed, or null for now (and for any moment already past). */
|
|
21
37
|
function fireAtOf(value, now) {
|
|
22
38
|
if (value === undefined)
|
|
@@ -52,43 +68,50 @@ export function createRunService(deps) {
|
|
|
52
68
|
},
|
|
53
69
|
});
|
|
54
70
|
unit.emit({ type: 'run.input', runId, inputId: id });
|
|
71
|
+
await runsRepo(unit.conn).updateMany({
|
|
72
|
+
filter: { id: runId, status: 'queued' },
|
|
73
|
+
// New input may change the scopes its variables come from: the next claim tells again.
|
|
74
|
+
values: { teamOnlyVariables: null },
|
|
75
|
+
});
|
|
55
76
|
return id;
|
|
56
77
|
}
|
|
57
78
|
async function requireInvocable(unit, agentId, userId) {
|
|
58
79
|
const agent = await findAgent(unit.conn, agentId);
|
|
59
80
|
if (!agent)
|
|
60
81
|
throw notFound('Agent');
|
|
61
|
-
if (agent.
|
|
62
|
-
throw precondition('
|
|
82
|
+
if (agent.status !== 'enabled')
|
|
83
|
+
throw precondition('AGENT_NOT_ENABLED', 'The agent is not enabled.');
|
|
63
84
|
if (!deps.agents.mayInvoke(agent, userId))
|
|
64
85
|
throw forbidden('You may not wake this agent.');
|
|
65
86
|
return agent;
|
|
66
87
|
}
|
|
67
88
|
async function createRun(unit, agent, values) {
|
|
68
|
-
if (!takesType(deps.subjects.get(values.subject.kind), agent.type))
|
|
69
|
-
throw invalid(`A ${agent.type} agent cannot work on a ${values.subject.kind}.`, { reason: 'AGENT_TYPE_NOT_ALLOWED', agentType: agent.type });
|
|
70
89
|
const now = clock.now().toISOString();
|
|
71
90
|
const id = ids.next();
|
|
72
91
|
await runsRepo(unit.conn).createOne({
|
|
73
92
|
values: {
|
|
74
93
|
id,
|
|
75
94
|
agentId: agent.id,
|
|
76
|
-
agentType:
|
|
95
|
+
agentType: 'runner',
|
|
77
96
|
runnerId: null,
|
|
78
97
|
status: 'queued',
|
|
79
98
|
priority: values.priority,
|
|
80
99
|
attempt: 1,
|
|
81
100
|
maxAttempts: values.maxAttempts ?? agent.maxAttempts,
|
|
82
101
|
retryOfRunId: values.retryOfRunId,
|
|
102
|
+
freshSession: values.freshSession === true,
|
|
83
103
|
parentRunId: values.parentRunId ?? null,
|
|
84
104
|
subjectKind: values.subject.kind,
|
|
85
105
|
subjectId: values.subject.id,
|
|
86
106
|
threadScope: values.threadScope,
|
|
87
107
|
actorUserId: values.actorUserId,
|
|
108
|
+
requestedByUserId: values.requestedByUserId,
|
|
109
|
+
confirmedByUserId: values.confirmedByUserId,
|
|
88
110
|
ownerUserId: values.ownerUserId,
|
|
89
111
|
requires: cleanList([...values.requires]),
|
|
90
112
|
acceptsInput: false,
|
|
91
113
|
availableAt: values.availableAt ?? null,
|
|
114
|
+
queueEnteredAt: now,
|
|
92
115
|
leaseExpiresAt: null,
|
|
93
116
|
dispatchedAt: null,
|
|
94
117
|
startedAt: null,
|
|
@@ -103,6 +126,7 @@ export function createRunService(deps) {
|
|
|
103
126
|
workDir: null,
|
|
104
127
|
directoryKey: null,
|
|
105
128
|
claimFailures: 0,
|
|
129
|
+
teamOnlyVariables: null,
|
|
106
130
|
payloadFingerprint: null,
|
|
107
131
|
createdAt: now,
|
|
108
132
|
updatedAt: now,
|
|
@@ -152,49 +176,247 @@ export function createRunService(deps) {
|
|
|
152
176
|
}
|
|
153
177
|
return [...totals.values()];
|
|
154
178
|
}
|
|
179
|
+
/** Legacy runs have no snapshots; report their known primary-tool models without inventing attempt boundaries. */
|
|
180
|
+
async function readRuns(records) {
|
|
181
|
+
const runs = records.map(toRun);
|
|
182
|
+
const legacy = runs.filter((run) => run.executions?.length === 0 &&
|
|
183
|
+
(run.dispatchedAt !== null ||
|
|
184
|
+
run.tool !== null ||
|
|
185
|
+
run.modelService !== null));
|
|
186
|
+
if (legacy.length === 0)
|
|
187
|
+
return runs;
|
|
188
|
+
const usage = await usageRepo(tx.read()).findMany({
|
|
189
|
+
select: (select) => select.fields('runId', 'tool', 'model'),
|
|
190
|
+
distinct: ['runId', 'tool', 'model'],
|
|
191
|
+
filter: (f) => f.and([
|
|
192
|
+
f.string('model').ne(null),
|
|
193
|
+
f.or(legacy.map((run) => f.and([
|
|
194
|
+
f.string('runId').eq(run.id),
|
|
195
|
+
f.string('tool').eq(run.tool ?? 'online'),
|
|
196
|
+
]))),
|
|
197
|
+
]),
|
|
198
|
+
});
|
|
199
|
+
const models = new Map();
|
|
200
|
+
for (const row of usage)
|
|
201
|
+
if (row.model)
|
|
202
|
+
models.set(row.runId, [...(models.get(row.runId) ?? []), row.model]);
|
|
203
|
+
return runs.map((run) => run.executions?.length
|
|
204
|
+
? run
|
|
205
|
+
: {
|
|
206
|
+
...run,
|
|
207
|
+
actualModels: models.get(run.id) ?? [],
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Queues `work` for `agent`: it joins the run working on its key while that run can still be told, else the run
|
|
212
|
+
* waiting for it, else starts a new run.
|
|
213
|
+
*/
|
|
214
|
+
async function queue(unit, agent, work) {
|
|
215
|
+
// Serializes enqueues and claims for this agent, so a key never gets two waiting runs.
|
|
216
|
+
await lockAgentForClaim(unit.conn, agent.id, clock.now().toISOString());
|
|
217
|
+
const key = {
|
|
218
|
+
agentId: agent.id,
|
|
219
|
+
subjectKind: work.subject.kind,
|
|
220
|
+
subjectId: work.subject.id,
|
|
221
|
+
threadScope: work.threadScope,
|
|
222
|
+
};
|
|
223
|
+
// Only into work done as the same person: merged into another's run, it would borrow their identity, or wait
|
|
224
|
+
// for a runner that never takes it.
|
|
225
|
+
const open = await runsOfKey(unit.conn, key, ['queued', ...ACTIVE], work.actorUserId);
|
|
226
|
+
const candidate = open.find((run) => !work.freshSession &&
|
|
227
|
+
(run.status === 'dispatched' ||
|
|
228
|
+
(run.status === 'running' && Boolean(run.acceptsInput))));
|
|
229
|
+
// Joins the working run only when the subject would let the agent act on it now; otherwise it waits in a queued run,
|
|
230
|
+
// which the claim admits or cancels.
|
|
231
|
+
const working = candidate &&
|
|
232
|
+
(await gateInputs(unit.conn, deps, candidate, agent, [
|
|
233
|
+
{
|
|
234
|
+
id: '',
|
|
235
|
+
at: clock.now().toISOString(),
|
|
236
|
+
...work.input,
|
|
237
|
+
},
|
|
238
|
+
])).length > 0
|
|
239
|
+
? candidate
|
|
240
|
+
: undefined;
|
|
241
|
+
const waiting = open.find((run) => run.status === 'queued');
|
|
242
|
+
const target = working ?? waiting;
|
|
243
|
+
if (!working && waiting)
|
|
244
|
+
await hurry(unit, waiting, work.priority, work.fireAt);
|
|
245
|
+
if (target) {
|
|
246
|
+
if (!working && work.freshSession && !target.freshSession)
|
|
247
|
+
await runsRepo(unit.conn).updateMany({
|
|
248
|
+
filter: { id: target.id, status: 'queued' },
|
|
249
|
+
values: { freshSession: true, updatedAt: clock.now().toISOString() },
|
|
250
|
+
});
|
|
251
|
+
const inputId = await insertInput(unit, target.id, work.input);
|
|
252
|
+
return {
|
|
253
|
+
runId: target.id,
|
|
254
|
+
outcome: working ? 'appended' : 'merged',
|
|
255
|
+
status: target.status,
|
|
256
|
+
inputId,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const runId = await createRun(unit, agent, {
|
|
260
|
+
freshSession: work.freshSession,
|
|
261
|
+
subject: work.subject,
|
|
262
|
+
threadScope: work.threadScope,
|
|
263
|
+
actorUserId: work.actorUserId,
|
|
264
|
+
requestedByUserId: work.requestedByUserId,
|
|
265
|
+
confirmedByUserId: work.confirmedByUserId,
|
|
266
|
+
ownerUserId: work.ownerUserId,
|
|
267
|
+
priority: work.priority,
|
|
268
|
+
requires: work.requires,
|
|
269
|
+
retryOfRunId: null,
|
|
270
|
+
availableAt: work.fireAt,
|
|
271
|
+
...(work.parentRunId ? { parentRunId: work.parentRunId } : {}),
|
|
272
|
+
...(work.maxAttempts ? { maxAttempts: work.maxAttempts } : {}),
|
|
273
|
+
});
|
|
274
|
+
const inputId = await insertInput(unit, runId, work.input);
|
|
275
|
+
return { runId, outcome: 'created', status: 'queued', inputId };
|
|
276
|
+
}
|
|
277
|
+
/** The source of the chain of work a request belongs to (`EnqueueRequest.requestedByUserId`). */
|
|
278
|
+
async function sourceOf(unit, request) {
|
|
279
|
+
if (request.causedByRunId) {
|
|
280
|
+
const cause = await findRunRecord(unit.conn, request.causedByRunId);
|
|
281
|
+
if (!cause)
|
|
282
|
+
throw invalid('causedByRunId names no run.');
|
|
283
|
+
return chainSourceOf(cause);
|
|
284
|
+
}
|
|
285
|
+
const source = request.requestedByUserId ??
|
|
286
|
+
request.actorUserId ??
|
|
287
|
+
request.responsibleUserId;
|
|
288
|
+
if (!source)
|
|
289
|
+
throw invalid('Name who woke the agent: actorUserId, requestedByUserId or responsibleUserId.');
|
|
290
|
+
return source;
|
|
291
|
+
}
|
|
292
|
+
async function selectedIdentity(unit, request) {
|
|
293
|
+
const identity = await deps.subjects
|
|
294
|
+
.get(request.subject.kind)
|
|
295
|
+
?.actsAs?.(unit.conn, {
|
|
296
|
+
subjectId: request.subject.id,
|
|
297
|
+
agentId: request.agentId,
|
|
298
|
+
causedByRunId: request.causedByRunId,
|
|
299
|
+
inputs: [request.input],
|
|
300
|
+
});
|
|
301
|
+
if (identity && !identity.actorUserId)
|
|
302
|
+
throw new ProtocolError('FORBIDDEN', 'The subject has no valid execution identity.', { identityReason: identity.reason ?? 'noOwner' });
|
|
303
|
+
return identity;
|
|
304
|
+
}
|
|
305
|
+
/** Refuses work run as `userId` when no runner they may use can run the agent now: it would only wait. */
|
|
306
|
+
async function requireRunnerFor(unit, agent, userId, requires) {
|
|
307
|
+
// By the claim's own rules, the agent's variables included; the subject's are the claim's to check.
|
|
308
|
+
if (!(await deps.eligibility.canClaim(unit.conn, agent, {
|
|
309
|
+
actorUserId: userId,
|
|
310
|
+
requires: requires,
|
|
311
|
+
})))
|
|
312
|
+
throw precondition('NO_RUNNER_AVAILABLE', 'No runner you may use can run this agent now: connect one of your own, or ask the person who answers for this to confirm it.', { agentId: agent.id });
|
|
313
|
+
}
|
|
314
|
+
const requests = createRunRequestService({
|
|
315
|
+
tx,
|
|
316
|
+
ids,
|
|
317
|
+
clock,
|
|
318
|
+
people: deps.people,
|
|
319
|
+
currentResponsible: (unit, subject) => deps.subjects
|
|
320
|
+
.get(subject.kind)
|
|
321
|
+
?.responsibleUserId?.(unit.conn, subject.id),
|
|
322
|
+
mayInvoke: (agent, userId) => deps.agents.mayInvoke(agent, userId),
|
|
323
|
+
requireInvocable,
|
|
324
|
+
requireRunnerFor,
|
|
325
|
+
direct: async (unit, run) => {
|
|
326
|
+
const identity = await selectedIdentity(unit, {
|
|
327
|
+
agentId: run.agent.id,
|
|
328
|
+
subject: run.subject,
|
|
329
|
+
input: run.input,
|
|
330
|
+
});
|
|
331
|
+
const actorUserId = identity?.actorUserId ?? run.actorUserId;
|
|
332
|
+
const agent = await requireInvocable(unit, run.agent.id, actorUserId);
|
|
333
|
+
return queue(unit, agent, {
|
|
334
|
+
freshSession: run.freshSession,
|
|
335
|
+
subject: run.subject,
|
|
336
|
+
threadScope: run.threadScope,
|
|
337
|
+
actorUserId,
|
|
338
|
+
requestedByUserId: run.requestedByUserId,
|
|
339
|
+
confirmedByUserId: run.confirmedByUserId,
|
|
340
|
+
ownerUserId: identity ? actorUserId : run.ownerUserId,
|
|
341
|
+
priority: run.priority,
|
|
342
|
+
// As it was asked: a moment already past when it is confirmed means now.
|
|
343
|
+
fireAt: fireAtOf(run.fireAt ?? undefined, clock.now()),
|
|
344
|
+
requires: run.requires,
|
|
345
|
+
...(run.maxAttempts === null ? {} : { maxAttempts: run.maxAttempts }),
|
|
346
|
+
input: run.input,
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
});
|
|
155
350
|
return {
|
|
156
351
|
enqueue: (request, outer) => tx.run(async (unit) => {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
352
|
+
const source = await sourceOf(unit, request);
|
|
353
|
+
const identity = await selectedIdentity(unit, request);
|
|
354
|
+
const responsible = identity
|
|
355
|
+
? null
|
|
356
|
+
: (request.responsibleUserId ?? null);
|
|
357
|
+
const threadScope = request.threadScope ?? DEFAULT_THREAD;
|
|
358
|
+
const foreign = responsible !== null && source !== responsible;
|
|
359
|
+
if (foreign && (request.execution ?? 'auto') === 'auto') {
|
|
360
|
+
// A consultation's asker waits for its answer at once: it can never wait for someone's confirmation.
|
|
361
|
+
if (request.parentRunId)
|
|
362
|
+
throw invalid('A consultation cannot wait for confirmation: name no responsible for it.');
|
|
363
|
+
// Someone else's work waits for the responsible, who must be able to run it once they confirm it.
|
|
364
|
+
const agent = await requireInvocable(unit, request.agentId, source);
|
|
365
|
+
if (!deps.agents.mayInvoke(agent, responsible))
|
|
366
|
+
throw forbidden('The person who answers for this may not wake this agent.');
|
|
367
|
+
const created = await insertRunRequest(unit, { ids, clock }, {
|
|
368
|
+
agentId: agent.id,
|
|
369
|
+
freshSession: request.freshSession,
|
|
370
|
+
subject: request.subject,
|
|
371
|
+
threadScope,
|
|
372
|
+
responsibleUserId: responsible,
|
|
373
|
+
requestedByUserId: source,
|
|
374
|
+
ownerUserId: request.ownerUserId ?? null,
|
|
375
|
+
priority: request.priority ?? 0,
|
|
376
|
+
requires: request.requires ?? [],
|
|
377
|
+
fireAt: fireAtOf(request.fireAt, clock.now()),
|
|
378
|
+
maxAttempts: request.maxAttempts ?? null,
|
|
379
|
+
input: request.input,
|
|
380
|
+
});
|
|
176
381
|
return {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
status:
|
|
180
|
-
|
|
382
|
+
outcome: 'pending',
|
|
383
|
+
requestId: created.id,
|
|
384
|
+
status: 'pending',
|
|
385
|
+
runId: null,
|
|
386
|
+
inputId: null,
|
|
181
387
|
};
|
|
182
388
|
}
|
|
183
|
-
|
|
389
|
+
// As the responsible when they caused it; as the source when they run it as themselves (`mine`); as whoever
|
|
390
|
+
// woke the agent when nobody answers for the subject.
|
|
391
|
+
const actorUserId = identity?.actorUserId ??
|
|
392
|
+
(foreign ? source : (responsible ?? request.actorUserId ?? source));
|
|
393
|
+
const agent = await requireInvocable(unit, request.agentId, actorUserId);
|
|
394
|
+
if (foreign)
|
|
395
|
+
await requireRunnerFor(unit, agent, actorUserId, request.requires ?? []);
|
|
396
|
+
return queue(unit, agent, {
|
|
397
|
+
freshSession: request.freshSession,
|
|
184
398
|
subject: request.subject,
|
|
185
|
-
threadScope
|
|
186
|
-
actorUserId
|
|
187
|
-
|
|
399
|
+
threadScope,
|
|
400
|
+
actorUserId,
|
|
401
|
+
requestedByUserId: source,
|
|
402
|
+
confirmedByUserId: null,
|
|
403
|
+
ownerUserId: identity ? actorUserId : (request.ownerUserId ?? null),
|
|
188
404
|
priority: request.priority ?? 0,
|
|
405
|
+
fireAt: fireAtOf(request.fireAt, clock.now()),
|
|
189
406
|
requires: request.requires ?? [],
|
|
190
|
-
retryOfRunId: null,
|
|
191
|
-
availableAt: fireAt,
|
|
192
407
|
...(request.parentRunId ? { parentRunId: request.parentRunId } : {}),
|
|
193
408
|
...(request.maxAttempts ? { maxAttempts: request.maxAttempts } : {}),
|
|
409
|
+
input: request.input,
|
|
194
410
|
});
|
|
195
|
-
const inputId = await insertInput(unit, runId, request.input);
|
|
196
|
-
return { runId, outcome: 'created', status: 'queued', inputId };
|
|
197
411
|
}, outer),
|
|
412
|
+
requests,
|
|
413
|
+
identityInputs: async (conn, runId) => {
|
|
414
|
+
const run = await findRunRecord(conn, runId);
|
|
415
|
+
if (!run)
|
|
416
|
+
return null;
|
|
417
|
+
const inputs = await inputsRepo(conn).findMany({ filter: { runId } });
|
|
418
|
+
return { run: toRun(run), inputs: inputs.map(toInput) };
|
|
419
|
+
},
|
|
198
420
|
addInput: (runId, input, outer) => tx.run(async (unit) => {
|
|
199
421
|
const run = await require(unit.conn, runId);
|
|
200
422
|
if (isTerminal(run.status))
|
|
@@ -263,44 +485,119 @@ export function createRunService(deps) {
|
|
|
263
485
|
}
|
|
264
486
|
return ended;
|
|
265
487
|
}, outer),
|
|
266
|
-
retry: (runId, byUserId
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
488
|
+
retry: async (runId, byUserId, source = 'api') => {
|
|
489
|
+
const target = await require(tx.read(), runId);
|
|
490
|
+
// Resolve collection metadata outside the transaction too. The lock must
|
|
491
|
+
// precede consistent reads so repeatable-read databases see a concurrent
|
|
492
|
+
// retry that committed while this request waited for the lock.
|
|
493
|
+
await findAgent(tx.read(), target.agentId);
|
|
494
|
+
return tx.run(async (unit) => {
|
|
495
|
+
await lockAgentForClaim(unit.conn, target.agentId, clock.now().toISOString());
|
|
496
|
+
const run = await require(unit.conn, runId);
|
|
497
|
+
if (run.status !== 'failed' && run.status !== 'cancelled')
|
|
498
|
+
throw precondition('RUN_NOT_RETRYABLE', 'Only a failed or cancelled run can be retried.');
|
|
499
|
+
if (run.parentRunId)
|
|
500
|
+
throw precondition('RUN_NOT_RETRYABLE', 'A consultation is not retried: the agent that asked asks again.');
|
|
501
|
+
// The agent lock serializes retry and enqueue across server instances. Check
|
|
502
|
+
// the relationship even after the replacement has already ended.
|
|
503
|
+
const retried = await runsRepo(unit.conn).findOne({
|
|
504
|
+
filter: { retryOfRunId: run.id },
|
|
505
|
+
sort: (sort) => [
|
|
506
|
+
sort.field('createdAt').asc(),
|
|
507
|
+
sort.field('id').asc(),
|
|
508
|
+
],
|
|
278
509
|
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
510
|
+
if (retried)
|
|
511
|
+
throw precondition('RUN_ALREADY_RETRIED', 'This run has already been retried.', {
|
|
512
|
+
runId: retried.id,
|
|
513
|
+
});
|
|
514
|
+
const previousInputs = await inputsRepo(unit.conn).findMany({
|
|
515
|
+
filter: { runId: run.id },
|
|
516
|
+
});
|
|
517
|
+
const identity = await deps.subjects
|
|
518
|
+
.get(run.subjectKind)
|
|
519
|
+
?.actsAs?.(unit.conn, {
|
|
520
|
+
subjectId: run.subjectId,
|
|
521
|
+
agentId: run.agentId,
|
|
522
|
+
inputs: previousInputs.map(toInput),
|
|
523
|
+
causedByRunId: run.retryOfRunId ?? undefined,
|
|
524
|
+
});
|
|
525
|
+
if (identity && !identity.actorUserId)
|
|
526
|
+
throw forbidden(identity.reason ?? 'noOwner');
|
|
527
|
+
const actorUserId = identity?.actorUserId ?? byUserId;
|
|
528
|
+
const agent = await requireInvocable(unit, run.agentId, actorUserId);
|
|
529
|
+
const open = await runsOfKey(unit.conn, run, ['queued', ...ACTIVE], actorUserId);
|
|
530
|
+
if (open.length > 0)
|
|
531
|
+
throw precondition('AGENT_BUSY', 'The agent is already working on this.', {
|
|
532
|
+
runId: open[0].id,
|
|
533
|
+
});
|
|
534
|
+
const newId = await createRun(unit, agent, {
|
|
535
|
+
subject: { kind: run.subjectKind, id: run.subjectId },
|
|
536
|
+
threadScope: run.threadScope,
|
|
537
|
+
actorUserId,
|
|
538
|
+
requestedByUserId: byUserId,
|
|
539
|
+
confirmedByUserId: null,
|
|
540
|
+
ownerUserId: identity ? actorUserId : run.ownerUserId,
|
|
541
|
+
priority: Number(run.priority),
|
|
542
|
+
requires: toRun(run).requires,
|
|
543
|
+
retryOfRunId: run.id,
|
|
544
|
+
freshSession: run.freshSession,
|
|
545
|
+
});
|
|
546
|
+
for (const input of await pendingInputs(unit.conn, run.id))
|
|
547
|
+
await insertInput(unit, newId, {
|
|
548
|
+
type: input.type,
|
|
549
|
+
actor: toInput(input).actor,
|
|
550
|
+
text: input.text,
|
|
551
|
+
...(input.payload === null ? {} : { payload: input.payload }),
|
|
552
|
+
});
|
|
289
553
|
await insertInput(unit, newId, {
|
|
290
|
-
type:
|
|
291
|
-
actor:
|
|
292
|
-
|
|
293
|
-
|
|
554
|
+
type: 'retry',
|
|
555
|
+
actor: {
|
|
556
|
+
kind: 'user',
|
|
557
|
+
id: byUserId,
|
|
558
|
+
name: (await deps.people.names(unit.conn, [byUserId])).get(byUserId) ??
|
|
559
|
+
byUserId,
|
|
560
|
+
},
|
|
561
|
+
text: 'Retry the work of the previous run.',
|
|
562
|
+
payload: {
|
|
563
|
+
retryOfRunId: run.id,
|
|
564
|
+
failureReason: run.failureReason,
|
|
565
|
+
source,
|
|
566
|
+
},
|
|
294
567
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
568
|
+
unit.emit({
|
|
569
|
+
type: 'run.retried',
|
|
570
|
+
runId: newId,
|
|
571
|
+
retryOfRunId: run.id,
|
|
572
|
+
previousStatus: run.status,
|
|
573
|
+
});
|
|
574
|
+
return toRun(await require(unit.conn, newId));
|
|
300
575
|
});
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
576
|
+
},
|
|
577
|
+
get: async (runId) => (await readRuns([await require(tx.read(), runId)]))[0],
|
|
578
|
+
async retryInfo(runId) {
|
|
579
|
+
const conn = tx.read();
|
|
580
|
+
const next = await runsRepo(conn).findOne({
|
|
581
|
+
filter: { retryOfRunId: runId },
|
|
582
|
+
sort: (sort) => [sort.field('createdAt').asc(), sort.field('id').asc()],
|
|
583
|
+
});
|
|
584
|
+
if (!next)
|
|
585
|
+
return null;
|
|
586
|
+
const input = await inputsRepo(conn).findOne({
|
|
587
|
+
filter: { runId: next.id, type: 'retry' },
|
|
588
|
+
sort: (sort) => [
|
|
589
|
+
sort.field('createdAt').desc(),
|
|
590
|
+
sort.field('id').desc(),
|
|
591
|
+
],
|
|
592
|
+
});
|
|
593
|
+
const source = input?.payload?.source;
|
|
594
|
+
return {
|
|
595
|
+
runId: next.id,
|
|
596
|
+
actorUserId: next.actorUserId,
|
|
597
|
+
actorName: input ? toInputView(input).actor.name : next.actorUserId,
|
|
598
|
+
source: typeof source === 'string' ? source : 'unknown',
|
|
599
|
+
};
|
|
600
|
+
},
|
|
304
601
|
async detail(runId) {
|
|
305
602
|
const conn = tx.read();
|
|
306
603
|
const run = await require(conn, runId);
|
|
@@ -309,17 +606,36 @@ export function createRunService(deps) {
|
|
|
309
606
|
sort: (sort) => [sort.field('createdAt').asc(), sort.field('id').asc()],
|
|
310
607
|
});
|
|
311
608
|
const repos = await reposRepo(conn).findMany({ filter: { runId } });
|
|
609
|
+
const retried = await runsRepo(conn).findOne({
|
|
610
|
+
filter: { retryOfRunId: runId },
|
|
611
|
+
sort: (sort) => [sort.field('createdAt').asc(), sort.field('id').asc()],
|
|
612
|
+
});
|
|
312
613
|
const children = await runsRepo(conn).findMany({
|
|
313
614
|
filter: { parentRunId: runId },
|
|
314
615
|
sort: (sort) => [sort.field('createdAt').asc(), sort.field('id').asc()],
|
|
315
616
|
});
|
|
316
|
-
const names =
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
617
|
+
const names = await agentNamesOf(conn, [
|
|
618
|
+
...children.map((child) => child.agentId),
|
|
619
|
+
...inputs.flatMap((input) => input.actorKind === 'agent' && input.actorId ? [input.actorId] : []),
|
|
620
|
+
]);
|
|
320
621
|
return {
|
|
321
|
-
...
|
|
322
|
-
|
|
622
|
+
...(await readRuns([run]))[0],
|
|
623
|
+
actorName: (await deps.people.names(conn, [run.actorUserId])).get(run.actorUserId) ?? run.actorUserId,
|
|
624
|
+
requestedByName: (await deps.people.names(conn, [
|
|
625
|
+
run.requestedByUserId ?? run.actorUserId,
|
|
626
|
+
])).get(run.requestedByUserId ?? run.actorUserId) ??
|
|
627
|
+
run.requestedByUserId ??
|
|
628
|
+
run.actorUserId,
|
|
629
|
+
retriedRunId: retried?.id ?? null,
|
|
630
|
+
inputs: inputs.map((input) => {
|
|
631
|
+
const view = toInputView(input);
|
|
632
|
+
const name = view.actor.kind === 'agent' && view.actor.id
|
|
633
|
+
? names.get(view.actor.id)
|
|
634
|
+
: undefined;
|
|
635
|
+
return name === undefined
|
|
636
|
+
? view
|
|
637
|
+
: { ...view, actor: { ...view.actor, name } };
|
|
638
|
+
}),
|
|
323
639
|
repos: repos.map(toRepo),
|
|
324
640
|
usage: await usageOf(conn, runId),
|
|
325
641
|
children: children.map((child) => ({
|
|
@@ -361,7 +677,7 @@ export function createRunService(deps) {
|
|
|
361
677
|
limit: Math.min(Math.max(filter.limit ?? 50, 1), 200),
|
|
362
678
|
...(filter.cursor ? { cursor: filter.cursor } : {}),
|
|
363
679
|
});
|
|
364
|
-
return records
|
|
680
|
+
return readRuns(records);
|
|
365
681
|
},
|
|
366
682
|
async lastEnded(subjectKind, subjectIds) {
|
|
367
683
|
if (subjectIds.length === 0)
|
|
@@ -383,16 +699,44 @@ export function createRunService(deps) {
|
|
|
383
699
|
if (!newest.has(key))
|
|
384
700
|
newest.set(key, record);
|
|
385
701
|
}
|
|
386
|
-
return [...newest.values()]
|
|
702
|
+
return readRuns([...newest.values()]);
|
|
703
|
+
},
|
|
704
|
+
async workingOn(subjectKind, subjectIds) {
|
|
705
|
+
const ids = [...new Set(subjectIds)];
|
|
706
|
+
if (ids.length === 0)
|
|
707
|
+
return [];
|
|
708
|
+
const records = await runsRepo(tx.read()).findMany({
|
|
709
|
+
select: (select) => select.fields('subjectId', 'agentId'),
|
|
710
|
+
filter: (f) => f.and([
|
|
711
|
+
f.string('subjectKind').eq(subjectKind),
|
|
712
|
+
f.or(ids.map((id) => f.string('subjectId').eq(id))),
|
|
713
|
+
f.or(['dispatched', 'running'].map((status) => f.string('status').eq(status))),
|
|
714
|
+
]),
|
|
715
|
+
});
|
|
716
|
+
const pairs = new Map();
|
|
717
|
+
for (const record of records) {
|
|
718
|
+
pairs.set(JSON.stringify([record.subjectId, record.agentId]), {
|
|
719
|
+
subjectId: record.subjectId,
|
|
720
|
+
agentId: record.agentId,
|
|
721
|
+
working: true,
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
return [...pairs.values()];
|
|
387
725
|
},
|
|
388
726
|
workload(query) {
|
|
389
|
-
return readWorkload(tx.read(), clock, deps.runners, query);
|
|
727
|
+
return readWorkload(tx.read(), clock, deps.runners, query, deps.diagnose);
|
|
390
728
|
},
|
|
391
|
-
async events(runId, afterSeq, limit) {
|
|
729
|
+
async events(runId, afterSeq, limit, types) {
|
|
392
730
|
const conn = tx.read();
|
|
393
731
|
await require(conn, runId);
|
|
394
732
|
const rows = await eventsRepo(conn).findMany({
|
|
395
|
-
filter: (f) => f.and([
|
|
733
|
+
filter: (f) => f.and([
|
|
734
|
+
f.string('runId').eq(runId),
|
|
735
|
+
f.number('seq').gt(afterSeq),
|
|
736
|
+
...(types?.length
|
|
737
|
+
? [f.or(types.map((type) => f.string('type').eq(type)))]
|
|
738
|
+
: []),
|
|
739
|
+
]),
|
|
396
740
|
sort: (sort) => sort.field('seq').asc(),
|
|
397
741
|
limit: Math.min(Math.max(limit, 1), 1000),
|
|
398
742
|
});
|
|
@@ -428,7 +772,8 @@ export function createRunService(deps) {
|
|
|
428
772
|
subjectRef: { kind: run.subjectKind, id: run.subjectId },
|
|
429
773
|
actorUserId: run.actorUserId,
|
|
430
774
|
cancelRequested: run.cancelRequestedAt !== null,
|
|
431
|
-
|
|
775
|
+
// What the run may act on: a read never withholds anything, it only leaves out what delivery would.
|
|
776
|
+
inputs: (await gatePending(conn, deps, run)).kept.map(toInput),
|
|
432
777
|
};
|
|
433
778
|
},
|
|
434
779
|
async brief(runId) {
|
|
@@ -444,14 +789,10 @@ export function createRunService(deps) {
|
|
|
444
789
|
const conn = tx.read();
|
|
445
790
|
const binding = deps.subjects.get(run.subjectKind);
|
|
446
791
|
const agent = await findAgent(conn, run.agentId);
|
|
447
|
-
|
|
448
|
-
const runner = run.runnerId && agent?.type === 'runner'
|
|
792
|
+
const runner = run.runnerId
|
|
449
793
|
? await deps.runners.find(conn, run.runnerId)
|
|
450
794
|
: null;
|
|
451
|
-
if (!binding ||
|
|
452
|
-
!agent ||
|
|
453
|
-
(agent.type === 'runner' && !runner) ||
|
|
454
|
-
!isActive(run.status))
|
|
795
|
+
if (!binding || !agent || !runner || !isActive(run.status))
|
|
455
796
|
throw notFound('Run context');
|
|
456
797
|
const assembly = await binding.context.assemble(conn, {
|
|
457
798
|
run: toRun(run),
|
|
@@ -460,8 +801,7 @@ export function createRunService(deps) {
|
|
|
460
801
|
inputs: (await pendingInputs(conn, run.id)).map(toInput),
|
|
461
802
|
cli: deps.cliName,
|
|
462
803
|
appName: deps.appName,
|
|
463
|
-
|
|
464
|
-
});
|
|
804
|
+
}, await binding.context.prepare?.(toRun(run)));
|
|
465
805
|
return assembly.data;
|
|
466
806
|
},
|
|
467
807
|
openOn: openRunsOn,
|