@nocobase/app-plugin-agents 0.1.0-beta.1 → 0.1.0-beta.11
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 +398 -0
- package/README.md +129 -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 +101 -219
- package/dist/client/locales/en-US.d.ts.map +1 -1
- package/dist/client/locales/en-US.js +106 -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 +54 -0
- package/dist/client/locales/runtimes.en-US.d.ts.map +1 -1
- package/dist/client/locales/runtimes.en-US.js +57 -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 +57 -3
- package/dist/client/locales/runtimes.zh-CN.js.map +1 -1
- package/dist/client/locales/skills.en-US.d.ts +1 -0
- package/dist/client/locales/skills.en-US.d.ts.map +1 -1
- package/dist/client/locales/skills.en-US.js +2 -1
- package/dist/client/locales/skills.en-US.js.map +1 -1
- package/dist/client/locales/skills.zh-CN.d.ts.map +1 -1
- package/dist/client/locales/skills.zh-CN.js +2 -1
- package/dist/client/locales/skills.zh-CN.js.map +1 -1
- package/dist/client/locales/zh-CN.d.ts.map +1 -1
- package/dist/client/locales/zh-CN.js +108 -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 +68 -0
- package/dist/client/pages/runtimes/workspace-diagnostics.js.map +1 -0
- package/dist/client/pages/skills/detail/index.d.ts.map +1 -1
- package/dist/client/pages/skills/detail/index.js +7 -10
- package/dist/client/pages/skills/detail/index.js.map +1 -1
- package/dist/client/pages/skills/index.d.ts.map +1 -1
- package/dist/client/pages/skills/index.js +2 -2
- package/dist/client/pages/skills/index.js.map +1 -1
- 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 +62 -2
- package/dist/database/migrations/202610020003_ag_create_runs.d.ts.map +1 -1
- package/dist/database/migrations/202610020003_ag_create_runs.js +0 -1
- package/dist/database/migrations/202610020003_ag_create_runs.js.map +1 -1
- 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/database/migrations/202610250001_ag_comment_runner_consent.d.ts +4 -0
- package/dist/database/migrations/202610250001_ag_comment_runner_consent.d.ts.map +1 -0
- package/dist/database/migrations/202610250001_ag_comment_runner_consent.js +41 -0
- package/dist/database/migrations/202610250001_ag_comment_runner_consent.js.map +1 -0
- package/dist/database/migrations/202610260001_ag_drop_directory_index.d.ts +4 -0
- package/dist/database/migrations/202610260001_ag_drop_directory_index.d.ts.map +1 -0
- package/dist/database/migrations/202610260001_ag_drop_directory_index.js +24 -0
- package/dist/database/migrations/202610260001_ag_drop_directory_index.js.map +1 -0
- package/dist/database/migrations/202610260001_ag_run_revision.d.ts +4 -0
- package/dist/database/migrations/202610260001_ag_run_revision.d.ts.map +1 -0
- package/dist/database/migrations/202610260001_ag_run_revision.js +19 -0
- package/dist/database/migrations/202610260001_ag_run_revision.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 +41 -37
- package/dist/server/composition.d.ts.map +1 -1
- package/dist/server/composition.js +66 -66
- 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 +64 -66
- 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 +47 -67
- package/dist/server/core/runs/claim.d.ts.map +1 -1
- package/dist/server/core/runs/claim.js +805 -313
- package/dist/server/core/runs/claim.js.map +1 -1
- package/dist/server/core/runs/comment-consent.d.ts +24 -0
- package/dist/server/core/runs/comment-consent.d.ts.map +1 -0
- package/dist/server/core/runs/comment-consent.js +116 -0
- package/dist/server/core/runs/comment-consent.js.map +1 -0
- 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 +9 -0
- package/dist/server/core/runs/identity.d.ts.map +1 -0
- package/dist/server/core/runs/identity.js +75 -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 +58 -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 +98 -50
- 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 +91 -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-data-purge.d.ts +15 -0
- package/dist/server/core/runs/run-data-purge.d.ts.map +1 -0
- package/dist/server/core/runs/run-data-purge.js +82 -0
- package/dist/server/core/runs/run-data-purge.js.map +1 -0
- package/dist/server/core/runs/run-requests.d.ts +245 -0
- package/dist/server/core/runs/run-requests.d.ts.map +1 -0
- package/dist/server/core/runs/run-requests.js +543 -0
- package/dist/server/core/runs/run-requests.js.map +1 -0
- package/dist/server/core/runs/run.service.d.ts +96 -11
- package/dist/server/core/runs/run.service.d.ts.map +1 -1
- package/dist/server/core/runs/run.service.js +921 -96
- package/dist/server/core/runs/run.service.js.map +1 -1
- package/dist/server/core/runs/run.store.d.ts +25 -3
- package/dist/server/core/runs/run.store.d.ts.map +1 -1
- package/dist/server/core/runs/run.store.js +52 -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 +1 -0
- package/dist/server/core/runs/sweeper.d.ts.map +1 -1
- package/dist/server/core/runs/sweeper.js +55 -10
- package/dist/server/core/runs/sweeper.js.map +1 -1
- package/dist/server/core/runs/transitions.d.ts +2 -2
- package/dist/server/core/runs/transitions.d.ts.map +1 -1
- package/dist/server/core/runs/transitions.js +80 -8
- 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/skills/skill.service.d.ts +6 -2
- package/dist/server/core/skills/skill.service.d.ts.map +1 -1
- package/dist/server/core/skills/skill.service.js +43 -58
- package/dist/server/core/skills/skill.service.js.map +1 -1
- package/dist/server/core/skills/skill.store.d.ts +14 -0
- package/dist/server/core/skills/skill.store.d.ts.map +1 -1
- package/dist/server/core/skills/skill.store.js +30 -0
- package/dist/server/core/skills/skill.store.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/kernel/scopes.d.ts.map +1 -1
- package/dist/server/kernel/scopes.js +3 -1
- package/dist/server/kernel/scopes.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 +8 -25
- package/dist/server/providers/agents.d.ts.map +1 -1
- package/dist/server/providers/agents.js +11 -75
- package/dist/server/providers/agents.js.map +1 -1
- package/dist/server/providers/runners.d.ts.map +1 -1
- package/dist/server/providers/runners.js +23 -0
- package/dist/server/providers/runners.js.map +1 -1
- package/dist/server/routes/admin.d.ts.map +1 -1
- package/dist/server/routes/admin.js +158 -209
- 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 +27 -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 +381 -84
- 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 +32 -8
- package/dist/server/runners/runner.service.d.ts.map +1 -1
- package/dist/server/runners/runner.service.js +130 -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 +13 -9
- package/dist/server/tokens.d.ts.map +1 -1
- package/dist/server/tokens.js +7 -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 -167
- 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 +213 -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/skills.d.ts +8 -4
- package/dist/shared/skills.d.ts.map +1 -1
- package/dist/shared/skills.js +7 -2
- package/dist/shared/skills.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 +10 -2
- 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 +6 -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
|
@@ -1,115 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agents:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* every change (`agent.history.ts`).
|
|
2
|
+
* Agents: one for each coding tool and model the runners report (`syncRunner`), and the application's own
|
|
3
|
+
* (`ensureSystem`). Nobody creates or deletes an agent. Someone who manages agents writes what an agent discovered from
|
|
4
|
+
* runners is good at, chooses its default reasoning effort and enables or disables it (`update`); everything else about
|
|
5
|
+
* it is the application's, the same for each (`setDefaults`: its instructions and business actions). Who may change an
|
|
6
|
+
* agent is the route's concern; the service checks the values and the revision an edit was made against, and keeps
|
|
7
|
+
* the history of every change (`agent.history.ts`).
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Disabling an agent withdraws its queued runs and announces `agent.removed`, so the application lets go of the work
|
|
10
|
+
* it gave the agent.
|
|
12
11
|
*/
|
|
13
|
-
import {
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
14
13
|
import { z } from 'zod';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { effortsFor, MAX_MODEL_ENTRIES, } from '../../../shared/agents.js';
|
|
15
|
+
import { agentNameOf, discoveryKey } from '../../../shared/model-catalog.js';
|
|
16
|
+
import { lockDiscovery, preferences, } from './discovery.js';
|
|
17
|
+
import { reportedModels } from '../../../shared/runners.js';
|
|
18
|
+
import { invalid, notFound, ProtocolError } from '../../kernel/errors.js';
|
|
18
19
|
import { cleanList } from '../../kernel/values.js';
|
|
19
|
-
import { attachmentsRepo, replaceAttachments, skillsRepo, } from '../skills/skill.store.js';
|
|
20
20
|
import { diffAgents, listChanges, recordChange, } from './agent.history.js';
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/** An entry's reasoning effort; empty for the default. Which values its tool or service takes is `checkType`'s. */
|
|
33
|
-
const EffortSchema = z
|
|
34
|
-
.string()
|
|
35
|
-
.trim()
|
|
36
|
-
.max(32)
|
|
37
|
-
.nullable()
|
|
38
|
-
.optional()
|
|
39
|
-
.transform((effort) => (effort ? effort : null));
|
|
40
|
-
const RunnerEntrySchema = z.strictObject({
|
|
41
|
-
tool: AgentToolSchema,
|
|
42
|
-
model: z
|
|
43
|
-
.string()
|
|
44
|
-
.trim()
|
|
45
|
-
.max(200)
|
|
46
|
-
.nullable()
|
|
21
|
+
import { agentDirectory, agentNamesOf, agentsRepo, findAgent, insertAgent, isRemoved, listAgents, reviseAgent, updateAgent, } from './agent.store.js';
|
|
22
|
+
/** What changing an agent accepts. */
|
|
23
|
+
export const AgentPatchSchema = z.strictObject({
|
|
24
|
+
description: z.string().max(10_000).nullable().optional().meta({
|
|
25
|
+
description: 'What it is good at: the project manager hands it work by this. Required to enable it.',
|
|
26
|
+
}),
|
|
27
|
+
effort: z.string().trim().max(32).nullable().optional().meta({
|
|
28
|
+
description: "Its default reasoning effort, one of its tool's; null for the tool's default.",
|
|
29
|
+
}),
|
|
30
|
+
enabled: z
|
|
31
|
+
.boolean()
|
|
47
32
|
.optional()
|
|
48
|
-
.
|
|
49
|
-
effort: EffortSchema,
|
|
50
|
-
});
|
|
51
|
-
const OnlineEntrySchema = z.strictObject({
|
|
52
|
-
modelService: z.string().trim().min(1).max(100),
|
|
53
|
-
model: z.string().trim().min(1).max(200),
|
|
54
|
-
effort: EffortSchema,
|
|
55
|
-
});
|
|
56
|
-
/**
|
|
57
|
-
* An agent's list of tools and models: runner entries (`{ tool, model?, effort? }`) or online ones
|
|
58
|
-
* (`{ modelService, model, effort? }`).
|
|
59
|
-
*/
|
|
60
|
-
export const ModelEntriesSchema = z
|
|
61
|
-
.array(z.union([RunnerEntrySchema, OnlineEntrySchema]))
|
|
62
|
-
.max(MAX_MODEL_ENTRIES)
|
|
63
|
-
.meta({
|
|
64
|
-
description: 'The tools and models, in order, the first its default, each with an optional reasoning effort its tool or service takes: `[{"tool":"codex","model":"gpt-5","effort":"high"},{"tool":"claude"}]` for a runner agent, `[{"modelService":"openai","model":"gpt-5","effort":"low"}]` for an online one. A runner agent needs at least one; an online agent may have none until a model is configured.',
|
|
65
|
-
});
|
|
66
|
-
const fields = {
|
|
67
|
-
name: z.string().trim().min(1).max(200),
|
|
68
|
-
description: z.string().max(10_000).nullable(),
|
|
69
|
-
avatar: z.string().trim().max(500).nullable(),
|
|
70
|
-
modelEntries: ModelEntriesSchema,
|
|
71
|
-
instructions: z.string().max(100_000).nullable(),
|
|
72
|
-
runnerIds: z.array(z.string().min(1).max(64)).max(100),
|
|
73
|
-
skillIds: z.array(z.string().min(1).max(64)).max(100),
|
|
74
|
-
actions: z.array(z.string().min(1).max(100)).max(100),
|
|
75
|
-
confirmChanges: z.enum(CONFIRM_CHANGES),
|
|
76
|
-
access: z.enum(AGENT_ACCESS),
|
|
77
|
-
userIds: z.array(z.string().min(1).max(64)).max(500),
|
|
78
|
-
ownerUserId: z.string().min(1).max(64),
|
|
79
|
-
maxConcurrentRuns: z.number().int().min(1).max(100),
|
|
80
|
-
maxAttempts: z.number().int().min(1).max(10),
|
|
81
|
-
toolPolicy: ToolPolicyPatchSchema.nullable(),
|
|
82
|
-
};
|
|
83
|
-
/** What creating an agent accepts. */
|
|
84
|
-
export const AgentInputSchema = z.strictObject({
|
|
85
|
-
...fields,
|
|
86
|
-
type: z.enum(AGENT_TYPES).optional(),
|
|
87
|
-
modelEntries: fields.modelEntries.optional(),
|
|
88
|
-
description: fields.description.optional(),
|
|
89
|
-
avatar: fields.avatar.optional(),
|
|
90
|
-
instructions: fields.instructions.optional(),
|
|
91
|
-
runnerIds: fields.runnerIds.optional(),
|
|
92
|
-
skillIds: fields.skillIds.optional(),
|
|
93
|
-
actions: fields.actions.optional(),
|
|
94
|
-
confirmChanges: fields.confirmChanges.optional(),
|
|
95
|
-
access: fields.access.optional(),
|
|
96
|
-
userIds: fields.userIds.optional(),
|
|
97
|
-
ownerUserId: fields.ownerUserId.optional(),
|
|
98
|
-
maxConcurrentRuns: fields.maxConcurrentRuns.optional(),
|
|
99
|
-
maxAttempts: fields.maxAttempts.optional(),
|
|
100
|
-
toolPolicy: fields.toolPolicy.optional(),
|
|
101
|
-
});
|
|
102
|
-
/**
|
|
103
|
-
* What updating an agent accepts: any field of the input but its type, and the revision the edit was made against. A
|
|
104
|
-
* patch naming a type is refused (`AGENT_TYPE_IMMUTABLE`) rather than having it ignored.
|
|
105
|
-
*/
|
|
106
|
-
export const AgentPatchSchema = z
|
|
107
|
-
.strictObject(fields)
|
|
108
|
-
.partial()
|
|
109
|
-
.extend({
|
|
33
|
+
.meta({ description: 'Offer it work, or stop offering it.' }),
|
|
110
34
|
expectedRevision: z.number().int().min(1),
|
|
111
|
-
type: z.never({ error: 'An agent keeps its type.' }).optional(),
|
|
112
35
|
});
|
|
36
|
+
const NO_DEFAULTS = { instructions: null, actions: [] };
|
|
37
|
+
/** How often a runner's report refreshes when its tools and models were last seen. */
|
|
38
|
+
const REPORT_REFRESH_MS = 10 * 60_000;
|
|
39
|
+
/** How many runs of one discovered agent may run at once: as many as the runners' slots allow. */
|
|
40
|
+
const RUNNER_AGENT_CONCURRENCY = 100;
|
|
41
|
+
/** How many attempts a run of any agent gets. */
|
|
42
|
+
const AGENT_ATTEMPTS = 3;
|
|
43
|
+
/** The effort a discovered agent starts with: `medium` when its tool takes it, else the tool's default. */
|
|
44
|
+
function initialEffort(tool) {
|
|
45
|
+
return effortsFor({ tool }).includes('medium') ? 'medium' : null;
|
|
46
|
+
}
|
|
47
|
+
/** The fixed id of the agent of a tool and model, so two runners reporting it at once create one. */
|
|
48
|
+
export function runnerAgentId(tool, model) {
|
|
49
|
+
const hash = createHash('sha256')
|
|
50
|
+
.update(`${tool}\u0000${model}`)
|
|
51
|
+
.digest('hex')
|
|
52
|
+
.slice(0, 20);
|
|
53
|
+
return `runner-${tool}-${hash}`;
|
|
54
|
+
}
|
|
113
55
|
/** Thrown inside an update's transaction when the patch changes nothing, to roll the raised revision back. */
|
|
114
56
|
class Unchanged extends Error {
|
|
115
57
|
agent;
|
|
@@ -121,197 +63,178 @@ class Unchanged extends Error {
|
|
|
121
63
|
function revisionConflict(current) {
|
|
122
64
|
return new ProtocolError('REVISION_CONFLICT', 'The agent was changed by someone else since you opened it. Reload it to see what changed, then make your change again.', { revision: current });
|
|
123
65
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'name',
|
|
128
|
-
'description',
|
|
129
|
-
'avatar',
|
|
130
|
-
'modelEntries',
|
|
131
|
-
'instructions',
|
|
132
|
-
'confirmChanges',
|
|
133
|
-
'access',
|
|
134
|
-
'ownerUserId',
|
|
135
|
-
'maxConcurrentRuns',
|
|
136
|
-
'maxAttempts',
|
|
137
|
-
'toolPolicy',
|
|
138
|
-
])
|
|
139
|
-
if (input[key] !== undefined)
|
|
140
|
-
values[key] = input[key];
|
|
141
|
-
if (input.runnerIds !== undefined)
|
|
142
|
-
values.runnerIds = cleanList(input.runnerIds);
|
|
143
|
-
if (input.actions !== undefined)
|
|
144
|
-
values.actions = cleanList(input.actions);
|
|
145
|
-
return values;
|
|
66
|
+
/** Whether work may be given to the agent: enabled, with at least one tool and model. */
|
|
67
|
+
export function isWorkable(agent) {
|
|
68
|
+
return agent.status === 'enabled' && agent.modelEntries.length > 0;
|
|
146
69
|
}
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
const found = await skillsRepo(conn).findMany({
|
|
152
|
-
filter: (f) => f.or(unique.map((id) => f.string('id').eq(id))),
|
|
153
|
-
});
|
|
154
|
-
if (found.length !== unique.length)
|
|
155
|
-
throw invalid('Some of the skills do not exist.');
|
|
156
|
-
}
|
|
157
|
-
await replaceAttachments(conn, 'agent', agentId, unique, () => ids.next(), now);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* 400 unless the fields fit the type: a runner agent's entries name coding tools, at least one; an online agent's name
|
|
161
|
-
* model services and their models (none while it is not configured), and it has none of what only a runner uses
|
|
162
|
-
* (runners, a tool policy), nor a business action meant for runner agents only. No entry is listed twice, and each
|
|
163
|
-
* entry's effort is one its tool or service takes.
|
|
164
|
-
*/
|
|
165
|
-
async function checkType(deps, agent,
|
|
166
|
-
/** The entries saved before; an online entry among them stays even when its service no longer offers it. */
|
|
167
|
-
previous) {
|
|
168
|
-
const wrongType = (key) => (deps.actionTypes?.(key) ?? AGENT_TYPES).includes(agent.type) === false;
|
|
169
|
-
const refused = agent.actions.filter(wrongType);
|
|
170
|
-
if (refused.length > 0)
|
|
171
|
-
throw invalid(`A ${agent.type} agent cannot be given ${refused.join(', ')}.`, { reason: 'ACTION_NOT_FOR_TYPE', actions: refused });
|
|
172
|
-
const entries = agent.modelEntries;
|
|
173
|
-
if (entries.length === 0 && agent.type === 'runner')
|
|
174
|
-
throw invalid('A runner agent needs at least one coding tool (modelEntries).');
|
|
175
|
-
if (entries.some((entry, index) => entries.slice(0, index).some((other) => sameEntry(entry, other))))
|
|
176
|
-
throw invalid('The same tool and model are listed twice.');
|
|
177
|
-
for (const entry of entries)
|
|
178
|
-
if (entry.effort && !effortsFor(entry).includes(entry.effort))
|
|
179
|
-
throw invalid(`${isRunnerEntry(entry) ? entry.tool : entry.modelService} takes no reasoning effort ${entry.effort}: use one of ${effortsFor(entry).join(', ')}.`, { reason: 'EFFORT_UNSUPPORTED' });
|
|
180
|
-
if (agent.type === 'runner') {
|
|
181
|
-
if (!entries.every(isRunnerEntry))
|
|
182
|
-
throw invalid('A runner agent works with coding tools: each entry names a tool, not a model service.');
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (!entries.every(isOnlineEntry))
|
|
186
|
-
throw invalid('An online agent has no coding tool: each entry names a model service and a model.');
|
|
187
|
-
if (agent.runnerIds.length > 0 || agent.toolPolicy !== null)
|
|
188
|
-
throw invalid('An online agent runs on the server: it takes no runners or tool policy.');
|
|
189
|
-
// An entry saved before its service changed stays until someone changes it; a new one must be offered now.
|
|
190
|
-
const added = entries.filter((entry) => !previous.some((saved) => sameEntry(saved, entry)));
|
|
191
|
-
if (added.length === 0)
|
|
192
|
-
return;
|
|
193
|
-
const catalog = await deps.models();
|
|
194
|
-
for (const entry of added)
|
|
195
|
-
if (!offers(catalog, entry.modelService, entry.model))
|
|
196
|
-
throw invalid(`The model service ${entry.modelService} does not offer the model ${entry.model}.`, { reason: 'MODEL_UNAVAILABLE' });
|
|
70
|
+
/** The tools and models a runner reports signed in, normalized, each once. */
|
|
71
|
+
export function reportedCombos(runner) {
|
|
72
|
+
const tools = [...new Set(runner.tools.map((tool) => tool.kind))];
|
|
73
|
+
return tools.flatMap((tool) => reportedModels(runner, tool).map((model) => ({ tool, model })));
|
|
197
74
|
}
|
|
198
75
|
export function createAgentService(deps) {
|
|
199
76
|
const { tx, ids, clock, people } = deps;
|
|
77
|
+
let defaults = () => NO_DEFAULTS;
|
|
200
78
|
const require = async (conn, id) => {
|
|
201
79
|
const agent = await findAgent(conn, id);
|
|
202
|
-
if (!agent)
|
|
80
|
+
if (!agent || (await isRemoved(conn, id)))
|
|
203
81
|
throw notFound('Agent');
|
|
204
82
|
return agent;
|
|
205
83
|
};
|
|
206
|
-
|
|
207
|
-
const revise = async (conn, agent, values) => {
|
|
208
|
-
if (!(await reviseAgent(conn, agent.id, agent.revision, values)))
|
|
209
|
-
throw revisionConflict((await require(conn, agent.id)).revision);
|
|
210
|
-
};
|
|
211
|
-
const removed = (unit, agent, reason, byUserId) => unit.emit({
|
|
84
|
+
const removed = (unit, agent, byUserId) => unit.emit({
|
|
212
85
|
type: 'agent.removed',
|
|
213
86
|
agentId: agent.id,
|
|
214
87
|
name: agent.name,
|
|
215
|
-
reason,
|
|
88
|
+
reason: 'disabled',
|
|
216
89
|
byUserId,
|
|
217
90
|
});
|
|
91
|
+
/** The defaults as stored: the instructions, and the actions each once. */
|
|
92
|
+
const currentDefaults = () => {
|
|
93
|
+
const value = defaults();
|
|
94
|
+
return {
|
|
95
|
+
instructions: value.instructions,
|
|
96
|
+
actions: cleanList(value.actions),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
async function createRunnerAgent(unit, tool, model, now) {
|
|
100
|
+
const id = runnerAgentId(tool, model);
|
|
101
|
+
const { instructions, actions } = currentDefaults();
|
|
102
|
+
try {
|
|
103
|
+
// A savepoint: another runner's report creating the same agent at once leaves this transaction usable.
|
|
104
|
+
await unit.conn.transaction((conn) => insertAgent(conn, {
|
|
105
|
+
id,
|
|
106
|
+
name: agentNameOf(tool, model),
|
|
107
|
+
description: null,
|
|
108
|
+
nameText: null,
|
|
109
|
+
descriptionText: null,
|
|
110
|
+
avatar: null,
|
|
111
|
+
type: 'runner',
|
|
112
|
+
source: 'runner',
|
|
113
|
+
status: 'pending',
|
|
114
|
+
tool,
|
|
115
|
+
model,
|
|
116
|
+
modelEntries: [{ tool, model, effort: initialEffort(tool) }],
|
|
117
|
+
instructions,
|
|
118
|
+
runnerIds: [],
|
|
119
|
+
actions: [...actions],
|
|
120
|
+
confirmChanges: 'larger',
|
|
121
|
+
access: 'everyone',
|
|
122
|
+
ownerUserId: 'system',
|
|
123
|
+
maxConcurrentRuns: RUNNER_AGENT_CONCURRENCY,
|
|
124
|
+
maxAttempts: AGENT_ATTEMPTS,
|
|
125
|
+
toolPolicy: null,
|
|
126
|
+
lastReportedAt: now,
|
|
127
|
+
createdAt: now,
|
|
128
|
+
updatedAt: now,
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (await agentsRepo(unit.conn).findOne({ filter: { id } }))
|
|
133
|
+
return false;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
await recordChange(unit.conn, {
|
|
137
|
+
id: ids.next(),
|
|
138
|
+
agentId: id,
|
|
139
|
+
revision: 1,
|
|
140
|
+
action: 'created',
|
|
141
|
+
actorUserId: null,
|
|
142
|
+
changes: [],
|
|
143
|
+
createdAt: now,
|
|
144
|
+
});
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
218
147
|
return {
|
|
219
|
-
|
|
148
|
+
setIgnored: (groups, ignored) => tx.run(async ({ conn, emit }) => {
|
|
149
|
+
const result = [];
|
|
150
|
+
const lockedGroups = [];
|
|
151
|
+
// Stable ordering avoids deadlocks between overlapping batches.
|
|
152
|
+
for (const group of [...groups].sort((a, b) => a.key.localeCompare(b.key))) {
|
|
153
|
+
lockedGroups.push(await lockDiscovery(conn, group.key, group.expectedRevision));
|
|
154
|
+
}
|
|
155
|
+
const agents = await listAgents(conn);
|
|
156
|
+
for (const group of lockedGroups) {
|
|
157
|
+
const members = agents.filter((agent) => agent.source === 'runner' &&
|
|
158
|
+
agent.tool &&
|
|
159
|
+
agent.model &&
|
|
160
|
+
discoveryKey(agent.tool, agent.model) === group.key);
|
|
161
|
+
if (!members.some((agent) => agent.status === 'pending') ||
|
|
162
|
+
members.some((agent) => agent.status === 'enabled'))
|
|
163
|
+
throw invalid('Only pending discovery groups can be ignored or restored. Reload the list.', { reason: 'DISCOVERY_NOT_PENDING' });
|
|
164
|
+
await preferences(conn).updateMany({
|
|
165
|
+
filter: { key: group.key },
|
|
166
|
+
values: { ignored },
|
|
167
|
+
});
|
|
168
|
+
for (const member of members)
|
|
169
|
+
emit({ type: 'agent.changed', agentId: member.id });
|
|
170
|
+
result.push({ ...group, ignored });
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}),
|
|
174
|
+
list: () => listAgents(tx.read()),
|
|
220
175
|
get: (id) => require(tx.read(), id),
|
|
221
176
|
find: findAgent,
|
|
177
|
+
names: agentNamesOf,
|
|
178
|
+
directory: agentDirectory,
|
|
222
179
|
async findWorkable(conn, id) {
|
|
223
180
|
const agent = await findAgent(conn, id);
|
|
224
|
-
if (!agent || agent
|
|
181
|
+
if (!agent || !isWorkable(agent) || (await isRemoved(conn, id)))
|
|
225
182
|
return null;
|
|
226
183
|
return agent;
|
|
227
184
|
},
|
|
228
|
-
listActive
|
|
229
|
-
|
|
230
|
-
const type = input.type ?? 'runner';
|
|
231
|
-
await checkType(deps, {
|
|
232
|
-
type,
|
|
233
|
-
modelEntries: input.modelEntries ?? [],
|
|
234
|
-
runnerIds: input.runnerIds ?? [],
|
|
235
|
-
toolPolicy: input.toolPolicy ?? null,
|
|
236
|
-
skillIds: input.skillIds ?? [],
|
|
237
|
-
actions: input.actions ?? [],
|
|
238
|
-
}, []);
|
|
239
|
-
return tx.run(async ({ conn, emit }) => {
|
|
240
|
-
const now = clock.now().toISOString();
|
|
241
|
-
const id = ids.next();
|
|
242
|
-
await insertAgent(conn, {
|
|
243
|
-
id,
|
|
244
|
-
name: input.name,
|
|
245
|
-
description: input.description ?? null,
|
|
246
|
-
nameText: null,
|
|
247
|
-
descriptionText: input.descriptionText
|
|
248
|
-
? { ...input.descriptionText }
|
|
249
|
-
: null,
|
|
250
|
-
avatar: input.avatar ?? null,
|
|
251
|
-
type,
|
|
252
|
-
modelEntries: [...(input.modelEntries ?? [])],
|
|
253
|
-
instructions: input.instructions ?? null,
|
|
254
|
-
runnerIds: cleanList(input.runnerIds ?? []),
|
|
255
|
-
actions: cleanList(input.actions ?? []),
|
|
256
|
-
confirmChanges: input.confirmChanges ?? 'larger',
|
|
257
|
-
access: input.access ?? 'ownerOnly',
|
|
258
|
-
ownerUserId: input.ownerUserId ?? createdById,
|
|
259
|
-
maxConcurrentRuns: input.maxConcurrentRuns ?? 2,
|
|
260
|
-
maxAttempts: input.maxAttempts ?? 3,
|
|
261
|
-
toolPolicy: input.toolPolicy ?? null,
|
|
262
|
-
createdAt: now,
|
|
263
|
-
updatedAt: now,
|
|
264
|
-
});
|
|
265
|
-
await replaceUsers(conn, id, cleanList(input.userIds ?? []), () => ids.next(), now);
|
|
266
|
-
if (input.skillIds !== undefined)
|
|
267
|
-
await attachSkills(conn, id, input.skillIds, ids, now);
|
|
268
|
-
await recordChange(conn, {
|
|
269
|
-
id: ids.next(),
|
|
270
|
-
agentId: id,
|
|
271
|
-
revision: 1,
|
|
272
|
-
action: 'created',
|
|
273
|
-
actorUserId: createdById,
|
|
274
|
-
changes: [],
|
|
275
|
-
createdAt: now,
|
|
276
|
-
});
|
|
277
|
-
emit({ type: 'agent.changed', agentId: id });
|
|
278
|
-
return require(conn, id);
|
|
279
|
-
});
|
|
185
|
+
async listActive(conn) {
|
|
186
|
+
return (await listAgents(conn)).filter(isWorkable);
|
|
280
187
|
},
|
|
281
188
|
async update(id, byUserId, patch) {
|
|
282
189
|
const current = await require(tx.read(), id);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
190
|
+
if (current.source !== 'runner')
|
|
191
|
+
throw invalid('This agent is kept by the application: change it in the application’s settings.', { reason: 'AGENT_MANAGED' });
|
|
192
|
+
const effort = patch.effort === undefined ? undefined : patch.effort;
|
|
193
|
+
const entry = current.modelEntries[0];
|
|
194
|
+
if (effort && entry && !effortsFor(entry).includes(effort))
|
|
195
|
+
throw invalid(`${entry.tool} takes no reasoning effort ${effort}: use one of ${effortsFor(entry).join(', ')}.`, { reason: 'EFFORT_UNSUPPORTED' });
|
|
196
|
+
const description = patch.description === undefined
|
|
197
|
+
? current.description
|
|
198
|
+
: patch.description?.trim()
|
|
199
|
+
? patch.description.trim()
|
|
200
|
+
: null;
|
|
201
|
+
const status = patch.enabled === undefined
|
|
202
|
+
? current.status
|
|
203
|
+
: patch.enabled
|
|
204
|
+
? 'enabled'
|
|
205
|
+
: current.status === 'pending'
|
|
206
|
+
? 'pending'
|
|
207
|
+
: 'disabled';
|
|
208
|
+
if (status === 'enabled' && !description)
|
|
209
|
+
throw invalid('Write what the agent is good at before enabling it: the project manager hands it work by this.', { reason: 'GOOD_AT_REQUIRED' });
|
|
293
210
|
try {
|
|
294
|
-
return await tx.run(async (
|
|
211
|
+
return await tx.run(async (unit) => {
|
|
212
|
+
const { conn, emit } = unit;
|
|
295
213
|
const before = await require(conn, id);
|
|
214
|
+
if (before.tool && before.model) {
|
|
215
|
+
const group = await lockDiscovery(conn, discoveryKey(before.tool, before.model));
|
|
216
|
+
if (patch.enabled && group.ignored)
|
|
217
|
+
throw invalid('Restore this discovery group before enabling it.', { reason: 'DISCOVERY_IGNORED' });
|
|
218
|
+
}
|
|
296
219
|
if (patch.expectedRevision !== before.revision)
|
|
297
220
|
throw revisionConflict(before.revision);
|
|
298
221
|
const now = clock.now().toISOString();
|
|
299
|
-
|
|
300
|
-
...
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
222
|
+
const modelEntries = effort === undefined
|
|
223
|
+
? [...before.modelEntries]
|
|
224
|
+
: before.modelEntries.map((item, index) => index === 0 ? { ...item, effort } : item);
|
|
225
|
+
if (!(await reviseAgent(conn, id, before.revision, {
|
|
226
|
+
description,
|
|
227
|
+
descriptionText: description === before.description && before.descriptionText
|
|
228
|
+
? {
|
|
229
|
+
key: before.descriptionText.key,
|
|
230
|
+
ns: before.descriptionText.ns,
|
|
231
|
+
}
|
|
232
|
+
: null,
|
|
233
|
+
status,
|
|
234
|
+
modelEntries: modelEntries.slice(0, MAX_MODEL_ENTRIES),
|
|
309
235
|
updatedAt: now,
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
await replaceUsers(conn, id, cleanList(patch.userIds), () => ids.next(), now);
|
|
313
|
-
if (patch.skillIds !== undefined)
|
|
314
|
-
await attachSkills(conn, id, patch.skillIds, ids, now);
|
|
236
|
+
})))
|
|
237
|
+
throw revisionConflict((await require(conn, id)).revision);
|
|
315
238
|
const after = await require(conn, id);
|
|
316
239
|
const changes = diffAgents(before, after);
|
|
317
240
|
if (changes.length === 0)
|
|
@@ -320,11 +243,19 @@ export function createAgentService(deps) {
|
|
|
320
243
|
id: ids.next(),
|
|
321
244
|
agentId: id,
|
|
322
245
|
revision: after.revision,
|
|
323
|
-
action:
|
|
246
|
+
action: before.status !== after.status
|
|
247
|
+
? after.status === 'enabled'
|
|
248
|
+
? 'enabled'
|
|
249
|
+
: 'disabled'
|
|
250
|
+
: 'updated',
|
|
324
251
|
actorUserId: byUserId,
|
|
325
252
|
changes,
|
|
326
253
|
createdAt: now,
|
|
327
254
|
});
|
|
255
|
+
if (before.status === 'enabled' && after.status !== 'enabled') {
|
|
256
|
+
await deps.owned?.withdrawQueued(unit, id, byUserId);
|
|
257
|
+
removed(unit, after, byUserId);
|
|
258
|
+
}
|
|
328
259
|
emit({ type: 'agent.changed', agentId: id });
|
|
329
260
|
return after;
|
|
330
261
|
});
|
|
@@ -335,59 +266,161 @@ export function createAgentService(deps) {
|
|
|
335
266
|
throw error;
|
|
336
267
|
}
|
|
337
268
|
},
|
|
338
|
-
|
|
339
|
-
const agent = await require(unit.conn, id);
|
|
340
|
-
if (agent.archivedAt)
|
|
341
|
-
return agent;
|
|
269
|
+
ensureSystem: (input, byUserId = null) => tx.run(async ({ conn, emit }) => {
|
|
342
270
|
const now = clock.now().toISOString();
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
271
|
+
const values = {
|
|
272
|
+
name: input.name,
|
|
273
|
+
nameText: input.nameText ? { ...input.nameText } : null,
|
|
274
|
+
description: input.description,
|
|
275
|
+
instructions: input.instructions,
|
|
276
|
+
actions: cleanList(input.actions),
|
|
277
|
+
modelEntries: input.modelEntries
|
|
278
|
+
.slice(0, MAX_MODEL_ENTRIES)
|
|
279
|
+
.map((entry) => ({ ...entry })),
|
|
280
|
+
};
|
|
281
|
+
const before = await findAgent(conn, input.id);
|
|
282
|
+
if (!before) {
|
|
283
|
+
await insertAgent(conn, {
|
|
284
|
+
id: input.id,
|
|
285
|
+
...values,
|
|
286
|
+
descriptionText: null,
|
|
287
|
+
avatar: null,
|
|
288
|
+
type: 'runner',
|
|
289
|
+
source: 'system',
|
|
290
|
+
status: 'enabled',
|
|
291
|
+
tool: null,
|
|
292
|
+
model: null,
|
|
293
|
+
runnerIds: [],
|
|
294
|
+
confirmChanges: 'larger',
|
|
295
|
+
access: 'everyone',
|
|
296
|
+
ownerUserId: 'system',
|
|
297
|
+
maxConcurrentRuns: RUNNER_AGENT_CONCURRENCY,
|
|
298
|
+
maxAttempts: AGENT_ATTEMPTS,
|
|
299
|
+
toolPolicy: null,
|
|
300
|
+
lastReportedAt: null,
|
|
301
|
+
createdAt: now,
|
|
302
|
+
updatedAt: now,
|
|
303
|
+
});
|
|
304
|
+
await recordChange(conn, {
|
|
305
|
+
id: ids.next(),
|
|
306
|
+
agentId: input.id,
|
|
307
|
+
revision: 1,
|
|
308
|
+
action: 'created',
|
|
309
|
+
actorUserId: byUserId,
|
|
310
|
+
changes: [],
|
|
311
|
+
createdAt: now,
|
|
312
|
+
});
|
|
313
|
+
emit({ type: 'agent.changed', agentId: input.id });
|
|
314
|
+
return (await findAgent(conn, input.id));
|
|
315
|
+
}
|
|
316
|
+
const unchanged = !(await isRemoved(conn, input.id)) &&
|
|
317
|
+
before.source === 'system' &&
|
|
318
|
+
before.status === 'enabled' &&
|
|
319
|
+
before.name === values.name &&
|
|
320
|
+
JSON.stringify(before.nameText) === JSON.stringify(values.nameText) &&
|
|
321
|
+
before.description === values.description &&
|
|
322
|
+
before.instructions === values.instructions &&
|
|
323
|
+
JSON.stringify(before.actions) === JSON.stringify(values.actions) &&
|
|
324
|
+
JSON.stringify(before.modelEntries) ===
|
|
325
|
+
JSON.stringify(values.modelEntries.map((entry) => ({
|
|
326
|
+
tool: entry.tool,
|
|
327
|
+
model: entry.model ?? null,
|
|
328
|
+
effort: entry.effort ?? null,
|
|
329
|
+
})));
|
|
330
|
+
if (unchanged)
|
|
331
|
+
return before;
|
|
332
|
+
await reviseAgent(conn, input.id, before.revision, {
|
|
333
|
+
...values,
|
|
334
|
+
source: 'system',
|
|
335
|
+
status: 'enabled',
|
|
336
|
+
archivedAt: null,
|
|
337
|
+
deletedAt: null,
|
|
338
|
+
updatedAt: now,
|
|
352
339
|
});
|
|
353
|
-
await
|
|
354
|
-
unit.emit({ type: 'agent.changed', agentId: id });
|
|
355
|
-
removed(unit, agent, 'archived', byUserId);
|
|
356
|
-
return require(unit.conn, id);
|
|
357
|
-
}),
|
|
358
|
-
restore: (id, byUserId) => tx.run(async ({ conn, emit }) => {
|
|
359
|
-
const agent = await require(conn, id);
|
|
360
|
-
if (!agent.archivedAt)
|
|
361
|
-
return agent;
|
|
362
|
-
const now = clock.now().toISOString();
|
|
363
|
-
await revise(conn, agent, { archivedAt: null, updatedAt: now });
|
|
340
|
+
const after = (await findAgent(conn, input.id));
|
|
364
341
|
await recordChange(conn, {
|
|
365
342
|
id: ids.next(),
|
|
366
|
-
agentId: id,
|
|
367
|
-
revision:
|
|
368
|
-
action: '
|
|
343
|
+
agentId: input.id,
|
|
344
|
+
revision: after.revision,
|
|
345
|
+
action: 'updated',
|
|
369
346
|
actorUserId: byUserId,
|
|
370
|
-
changes:
|
|
347
|
+
changes: diffAgents(before, after),
|
|
371
348
|
createdAt: now,
|
|
372
349
|
});
|
|
373
|
-
emit({ type: 'agent.changed', agentId: id });
|
|
374
|
-
return
|
|
350
|
+
emit({ type: 'agent.changed', agentId: input.id });
|
|
351
|
+
return after;
|
|
375
352
|
}),
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
353
|
+
async syncRunner(unit, runner) {
|
|
354
|
+
const combos = reportedCombos(runner);
|
|
355
|
+
if (combos.length === 0)
|
|
356
|
+
return;
|
|
357
|
+
const now = clock.now();
|
|
358
|
+
const nowText = now.toISOString();
|
|
359
|
+
const known = new Map((await agentsRepo(unit.conn).findMany({
|
|
360
|
+
filter: (f) => f.or(combos.map((combo) => f.string('id').eq(runnerAgentId(combo.tool, combo.model)))),
|
|
361
|
+
})).map((record) => [record.id, record]));
|
|
362
|
+
const created = [];
|
|
363
|
+
const stale = [];
|
|
364
|
+
for (const combo of combos) {
|
|
365
|
+
const id = runnerAgentId(combo.tool, combo.model);
|
|
366
|
+
const record = known.get(id);
|
|
367
|
+
if (!record) {
|
|
368
|
+
if (await createRunnerAgent(unit, combo.tool, combo.model, nowText))
|
|
369
|
+
created.push(id);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
const generated = agentNameOf(combo.tool, combo.model);
|
|
373
|
+
if (record.status === 'pending' &&
|
|
374
|
+
record.name ===
|
|
375
|
+
`${{ claude: 'Claude', codex: 'Codex', pi: 'Pi', opencode: 'OpenCode' }[combo.tool]} · ${combo.model.split('/').at(-1)}` &&
|
|
376
|
+
record.name !== generated)
|
|
377
|
+
await updateAgent(unit.conn, id, { name: generated });
|
|
378
|
+
if (!record.lastReportedAt ||
|
|
379
|
+
now.getTime() - Date.parse(record.lastReportedAt) >= REPORT_REFRESH_MS)
|
|
380
|
+
stale.push(id);
|
|
381
|
+
}
|
|
382
|
+
if (stale.length > 0)
|
|
383
|
+
await agentsRepo(unit.conn).updateMany({
|
|
384
|
+
filter: (f) => f.or(stale.map((id) => f.string('id').eq(id))),
|
|
385
|
+
values: { lastReportedAt: nowText },
|
|
386
|
+
});
|
|
387
|
+
for (const id of created)
|
|
388
|
+
unit.emit({ type: 'agent.changed', agentId: id });
|
|
389
|
+
},
|
|
390
|
+
setDefaults(provider) {
|
|
391
|
+
defaults = provider;
|
|
392
|
+
return () => {
|
|
393
|
+
if (defaults === provider)
|
|
394
|
+
defaults = () => NO_DEFAULTS;
|
|
395
|
+
};
|
|
396
|
+
},
|
|
397
|
+
async applyDefaults(options = {}) {
|
|
398
|
+
const { instructions, actions } = currentDefaults();
|
|
399
|
+
return tx.run(async ({ conn, emit }) => {
|
|
400
|
+
const records = await agentsRepo(conn).findMany({
|
|
401
|
+
filter: (f) => f.and([
|
|
402
|
+
f.string('source').eq('runner'),
|
|
403
|
+
f.date('deletedAt').empty(),
|
|
404
|
+
]),
|
|
405
|
+
});
|
|
406
|
+
let changed = 0;
|
|
407
|
+
for (const record of records) {
|
|
408
|
+
const agent = (await findAgent(conn, record.id));
|
|
409
|
+
if ((options.preserveInstructions ||
|
|
410
|
+
agent.instructions === instructions) &&
|
|
411
|
+
JSON.stringify(agent.actions) === JSON.stringify(actions))
|
|
412
|
+
continue;
|
|
413
|
+
await updateAgent(conn, record.id, {
|
|
414
|
+
...(options.preserveInstructions ? {} : { instructions }),
|
|
415
|
+
actions: [...actions],
|
|
416
|
+
updatedAt: clock.now().toISOString(),
|
|
417
|
+
});
|
|
418
|
+
emit({ type: 'agent.changed', agentId: record.id });
|
|
419
|
+
changed += 1;
|
|
420
|
+
}
|
|
421
|
+
return changed;
|
|
385
422
|
});
|
|
386
|
-
|
|
387
|
-
await deleteAgent(conn, id);
|
|
388
|
-
unit.emit({ type: 'agent.changed', agentId: id });
|
|
389
|
-
removed(unit, agent, 'deleted', byUserId);
|
|
390
|
-
}),
|
|
423
|
+
},
|
|
391
424
|
async history(id, options = {}) {
|
|
392
425
|
const conn = tx.read();
|
|
393
426
|
await require(conn, id);
|
|
@@ -413,15 +446,7 @@ export function createAgentService(deps) {
|
|
|
413
446
|
createdAt: clock.now().toISOString(),
|
|
414
447
|
});
|
|
415
448
|
},
|
|
416
|
-
mayInvoke(agent
|
|
417
|
-
if (agent.archivedAt)
|
|
418
|
-
return false;
|
|
419
|
-
if (agent.ownerUserId === userId)
|
|
420
|
-
return true;
|
|
421
|
-
if (agent.access === 'everyone')
|
|
422
|
-
return true;
|
|
423
|
-
return agent.access === 'users' && agent.userIds.includes(userId);
|
|
424
|
-
},
|
|
449
|
+
mayInvoke: (agent) => isWorkable(agent),
|
|
425
450
|
};
|
|
426
451
|
}
|
|
427
452
|
//# sourceMappingURL=agent.service.js.map
|