@nocobase/app-plugin-agents 0.1.0-beta.9 → 1.0.0-beta.16
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 +315 -0
- package/README.md +94 -51
- package/dist/client/api/client.d.ts +25 -19
- package/dist/client/api/client.d.ts.map +1 -1
- package/dist/client/api/client.js +23 -24
- package/dist/client/api/client.js.map +1 -1
- package/dist/client/api/keys.d.ts +4 -1
- package/dist/client/api/keys.d.ts.map +1 -1
- package/dist/client/api/keys.js +4 -1
- package/dist/client/api/keys.js.map +1 -1
- package/dist/client/api/runners.d.ts +8 -4
- package/dist/client/api/runners.d.ts.map +1 -1
- package/dist/client/api/runners.js +9 -0
- package/dist/client/api/runners.js.map +1 -1
- package/dist/client/chat/ai-form.d.ts +13 -0
- package/dist/client/chat/ai-form.d.ts.map +1 -0
- package/dist/client/chat/ai-form.js +57 -0
- package/dist/client/chat/ai-form.js.map +1 -0
- package/dist/client/chat/api.d.ts +16 -14
- package/dist/client/chat/api.d.ts.map +1 -1
- package/dist/client/chat/api.js +85 -18
- package/dist/client/chat/api.js.map +1 -1
- package/dist/client/chat/client-id.d.ts +3 -0
- package/dist/client/chat/client-id.d.ts.map +1 -0
- package/dist/client/chat/client-id.js +17 -0
- package/dist/client/chat/client-id.js.map +1 -0
- 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/context-model.d.ts +21 -3
- package/dist/client/chat/context-model.d.ts.map +1 -1
- package/dist/client/chat/context-model.js +33 -4
- package/dist/client/chat/context-model.js.map +1 -1
- package/dist/client/chat/controller.d.ts +83 -0
- package/dist/client/chat/controller.d.ts.map +1 -0
- package/dist/client/chat/controller.js +767 -0
- package/dist/client/chat/controller.js.map +1 -0
- package/dist/client/chat/extensions.d.ts +8 -3
- package/dist/client/chat/extensions.d.ts.map +1 -1
- package/dist/client/chat/extensions.js.map +1 -1
- package/dist/client/chat/feedback.d.ts +18 -0
- package/dist/client/chat/feedback.d.ts.map +1 -0
- package/dist/client/chat/feedback.js +38 -0
- package/dist/client/chat/feedback.js.map +1 -0
- package/dist/client/chat/form-registry.d.ts +95 -0
- package/dist/client/chat/form-registry.d.ts.map +1 -0
- package/dist/client/chat/form-registry.js +384 -0
- package/dist/client/chat/form-registry.js.map +1 -0
- package/dist/client/chat/keys.d.ts +1 -0
- package/dist/client/chat/keys.d.ts.map +1 -1
- package/dist/client/chat/keys.js +3 -1
- package/dist/client/chat/keys.js.map +1 -1
- package/dist/client/chat/message-model.d.ts +38 -44
- package/dist/client/chat/message-model.d.ts.map +1 -1
- package/dist/client/chat/message-model.js +138 -56
- package/dist/client/chat/message-model.js.map +1 -1
- package/dist/client/chat/provider.d.ts +12 -2
- package/dist/client/chat/provider.d.ts.map +1 -1
- package/dist/client/chat/provider.js +130 -4
- package/dist/client/chat/provider.js.map +1 -1
- package/dist/client/chat/submissions.d.ts +67 -0
- package/dist/client/chat/submissions.d.ts.map +1 -0
- package/dist/client/chat/submissions.js +241 -0
- package/dist/client/chat/submissions.js.map +1 -0
- package/dist/client/chat/tool-renderer.d.ts +39 -0
- package/dist/client/chat/tool-renderer.d.ts.map +1 -0
- package/dist/client/chat/tool-renderer.js +27 -0
- package/dist/client/chat/tool-renderer.js.map +1 -0
- package/dist/client/chat/use-chat-scroll.d.ts +4 -0
- package/dist/client/chat/use-chat-scroll.d.ts.map +1 -0
- package/dist/client/chat/use-chat-scroll.js +73 -0
- package/dist/client/chat/use-chat-scroll.js.map +1 -0
- package/dist/client/chat/use-chat.d.ts +13 -24
- package/dist/client/chat/use-chat.d.ts.map +1 -1
- package/dist/client/chat/use-chat.js +250 -235
- package/dist/client/chat/use-chat.js.map +1 -1
- package/dist/client/chat.d.ts +20 -8
- package/dist/client/chat.d.ts.map +1 -1
- package/dist/client/chat.js +16 -4
- 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 +20 -39
- package/dist/client/components/agent-picker.js.map +1 -1
- package/dist/client/components/quota-status.d.ts +16 -0
- package/dist/client/components/quota-status.d.ts.map +1 -0
- package/dist/client/components/quota-status.js +39 -0
- package/dist/client/components/quota-status.js.map +1 -0
- package/dist/client/components/runners-refresh.d.ts.map +1 -1
- package/dist/client/components/runners-refresh.js +1 -0
- package/dist/client/components/runners-refresh.js.map +1 -1
- package/dist/client/components/variables/variable-dialogs.d.ts.map +1 -1
- package/dist/client/components/variables/variable-dialogs.js +7 -7
- package/dist/client/components/variables/variable-dialogs.js.map +1 -1
- package/dist/client/config.d.ts +2 -0
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js +2 -0
- package/dist/client/config.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 +4 -12
- package/dist/client/hooks/use-agent-picker-labels.js.map +1 -1
- package/dist/client/hooks/use-quota-expiry.d.ts +7 -0
- package/dist/client/hooks/use-quota-expiry.d.ts.map +1 -0
- package/dist/client/hooks/use-quota-expiry.js +92 -0
- package/dist/client/hooks/use-quota-expiry.js.map +1 -0
- package/dist/client/hooks/use-realtime-topic.d.ts +1 -4
- package/dist/client/hooks/use-realtime-topic.d.ts.map +1 -1
- package/dist/client/hooks/use-realtime-topic.js +7 -11
- package/dist/client/hooks/use-realtime-topic.js.map +1 -1
- package/dist/client/kit.d.ts +14 -12
- package/dist/client/kit.d.ts.map +1 -1
- package/dist/client/kit.js +37 -14
- package/dist/client/kit.js.map +1 -1
- package/dist/client/lib/agents.d.ts +5 -18
- package/dist/client/lib/agents.d.ts.map +1 -1
- package/dist/client/lib/agents.js +18 -55
- package/dist/client/lib/agents.js.map +1 -1
- package/dist/client/lib/format.d.ts +3 -1
- package/dist/client/lib/format.d.ts.map +1 -1
- package/dist/client/lib/format.js +25 -0
- package/dist/client/lib/format.js.map +1 -1
- package/dist/client/lib/skill-settings-context.d.ts +9 -0
- package/dist/client/lib/skill-settings-context.d.ts.map +1 -0
- package/dist/client/lib/skill-settings-context.js +4 -0
- package/dist/client/lib/skill-settings-context.js.map +1 -0
- package/dist/client/lib/skill-settings.d.ts +12 -0
- package/dist/client/lib/skill-settings.d.ts.map +1 -0
- package/dist/client/lib/skill-settings.js +37 -0
- package/dist/client/lib/skill-settings.js.map +1 -0
- package/dist/client/locales/chat.en-US.d.ts +8 -27
- package/dist/client/locales/chat.en-US.d.ts.map +1 -1
- package/dist/client/locales/chat.en-US.js +12 -30
- 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 +9 -27
- package/dist/client/locales/chat.zh-CN.js.map +1 -1
- package/dist/client/locales/de-DE.d.ts +5 -0
- package/dist/client/locales/de-DE.d.ts.map +1 -0
- package/dist/client/locales/de-DE.js +1219 -0
- package/dist/client/locales/de-DE.js.map +1 -0
- package/dist/client/locales/en-US.d.ts +95 -217
- package/dist/client/locales/en-US.d.ts.map +1 -1
- package/dist/client/locales/en-US.js +100 -218
- package/dist/client/locales/en-US.js.map +1 -1
- package/dist/client/locales/es-ES.d.ts +5 -0
- package/dist/client/locales/es-ES.d.ts.map +1 -0
- package/dist/client/locales/es-ES.js +1228 -0
- package/dist/client/locales/es-ES.js.map +1 -0
- package/dist/client/locales/fr-FR.d.ts +5 -0
- package/dist/client/locales/fr-FR.d.ts.map +1 -0
- package/dist/client/locales/fr-FR.js +1229 -0
- package/dist/client/locales/fr-FR.js.map +1 -0
- package/dist/client/locales/id-ID.d.ts +5 -0
- package/dist/client/locales/id-ID.d.ts.map +1 -0
- package/dist/client/locales/id-ID.js +1219 -0
- package/dist/client/locales/id-ID.js.map +1 -0
- package/dist/client/locales/index.d.ts.map +1 -1
- package/dist/client/locales/index.js +8 -0
- package/dist/client/locales/index.js.map +1 -1
- package/dist/client/locales/ja-JP.d.ts +5 -0
- package/dist/client/locales/ja-JP.d.ts.map +1 -0
- package/dist/client/locales/ja-JP.js +1219 -0
- package/dist/client/locales/ja-JP.js.map +1 -0
- package/dist/client/locales/pt-BR.d.ts +5 -0
- package/dist/client/locales/pt-BR.d.ts.map +1 -0
- package/dist/client/locales/pt-BR.js +1229 -0
- package/dist/client/locales/pt-BR.js.map +1 -0
- package/dist/client/locales/runWait.en-US.d.ts +7 -0
- package/dist/client/locales/runWait.en-US.d.ts.map +1 -1
- package/dist/client/locales/runWait.en-US.js +10 -3
- package/dist/client/locales/runWait.en-US.js.map +1 -1
- package/dist/client/locales/runWait.zh-CN.d.ts +1 -1
- package/dist/client/locales/runWait.zh-CN.d.ts.map +1 -1
- package/dist/client/locales/runWait.zh-CN.js +11 -4
- package/dist/client/locales/runWait.zh-CN.js.map +1 -1
- package/dist/client/locales/runtimes.en-US.d.ts +83 -0
- package/dist/client/locales/runtimes.en-US.d.ts.map +1 -1
- package/dist/client/locales/runtimes.en-US.js +84 -1
- 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 +83 -0
- package/dist/client/locales/runtimes.zh-CN.js.map +1 -1
- package/dist/client/locales/skills.en-US.d.ts +7 -0
- package/dist/client/locales/skills.en-US.d.ts.map +1 -1
- package/dist/client/locales/skills.en-US.js +8 -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 +8 -1
- package/dist/client/locales/skills.zh-CN.js.map +1 -1
- package/dist/client/locales/vi-VN.d.ts +5 -0
- package/dist/client/locales/vi-VN.d.ts.map +1 -0
- package/dist/client/locales/vi-VN.js +1219 -0
- package/dist/client/locales/vi-VN.js.map +1 -0
- package/dist/client/locales/zh-CN.d.ts.map +1 -1
- package/dist/client/locales/zh-CN.js +102 -220
- package/dist/client/locales/zh-CN.js.map +1 -1
- package/dist/client/locales/zh-TW.d.ts +5 -0
- package/dist/client/locales/zh-TW.d.ts.map +1 -0
- package/dist/client/locales/zh-TW.js +1219 -0
- package/dist/client/locales/zh-TW.js.map +1 -0
- package/dist/client/model-suggestion.d.ts +6 -0
- package/dist/client/model-suggestion.d.ts.map +1 -0
- package/dist/client/model-suggestion.js +25 -0
- package/dist/client/model-suggestion.js.map +1 -0
- 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 +99 -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 +7 -101
- 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 +185 -0
- package/dist/client/pages/agents/runner-agents.js.map +1 -0
- 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 +1 -1
- package/dist/client/pages/runtimes/index.js.map +1 -1
- package/dist/client/pages/runtimes/quota-targets.d.ts +4 -0
- package/dist/client/pages/runtimes/quota-targets.d.ts.map +1 -0
- package/dist/client/pages/runtimes/quota-targets.js +18 -0
- package/dist/client/pages/runtimes/quota-targets.js.map +1 -0
- package/dist/client/pages/runtimes/quota.d.ts +17 -0
- package/dist/client/pages/runtimes/quota.d.ts.map +1 -0
- package/dist/client/pages/runtimes/quota.js +50 -0
- package/dist/client/pages/runtimes/quota.js.map +1 -0
- package/dist/client/pages/runtimes/runner-cells.d.ts +11 -4
- package/dist/client/pages/runtimes/runner-cells.d.ts.map +1 -1
- package/dist/client/pages/runtimes/runner-cells.js +6 -3
- package/dist/client/pages/runtimes/runner-cells.js.map +1 -1
- package/dist/client/pages/runtimes/runner-overview.d.ts +9 -0
- package/dist/client/pages/runtimes/runner-overview.d.ts.map +1 -0
- package/dist/client/pages/runtimes/runner-overview.js +109 -0
- package/dist/client/pages/runtimes/runner-overview.js.map +1 -0
- package/dist/client/pages/runtimes/runner-runs.d.ts +5 -0
- package/dist/client/pages/runtimes/runner-runs.d.ts.map +1 -0
- package/dist/client/pages/runtimes/runner-runs.js +35 -0
- package/dist/client/pages/runtimes/runner-runs.js.map +1 -0
- package/dist/client/pages/runtimes/runner-sheet.d.ts +2 -3
- package/dist/client/pages/runtimes/runner-sheet.d.ts.map +1 -1
- package/dist/client/pages/runtimes/runner-sheet.js +43 -171
- package/dist/client/pages/runtimes/runner-sheet.js.map +1 -1
- package/dist/client/pages/runtimes/runner-tools.d.ts +17 -0
- package/dist/client/pages/runtimes/runner-tools.d.ts.map +1 -0
- package/dist/client/pages/runtimes/runner-tools.js +75 -0
- package/dist/client/pages/runtimes/runner-tools.js.map +1 -0
- package/dist/client/pages/runtimes/runner-workspaces.d.ts +6 -0
- package/dist/client/pages/runtimes/runner-workspaces.d.ts.map +1 -0
- package/dist/client/pages/runtimes/runner-workspaces.js +37 -0
- package/dist/client/pages/runtimes/runner-workspaces.js.map +1 -0
- package/dist/client/pages/runtimes/tool-slots-fields.js +1 -1
- package/dist/client/pages/runtimes/tool-slots-fields.js.map +1 -1
- package/dist/client/pages/runtimes/workspace-diagnostics.d.ts +6 -4
- package/dist/client/pages/runtimes/workspace-diagnostics.d.ts.map +1 -1
- package/dist/client/pages/runtimes/workspace-diagnostics.js +67 -33
- package/dist/client/pages/runtimes/workspace-diagnostics.js.map +1 -1
- package/dist/client/pages/skills/detail/index.d.ts.map +1 -1
- package/dist/client/pages/skills/detail/index.js +11 -15
- 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/date-range-picker.d.ts.map +1 -1
- package/dist/client/pages/usage/date-range-picker.js +14 -2
- package/dist/client/pages/usage/date-range-picker.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.map +1 -1
- package/dist/client/runs/format-wait.js +15 -1
- package/dist/client/runs/format-wait.js.map +1 -1
- 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 +24 -9
- package/dist/client/runs/subject-runs.js.map +1 -1
- package/dist/client/runs/use-run-events.d.ts +1 -1
- package/dist/client/runs/use-run-events.d.ts.map +1 -1
- package/dist/client/runs/use-run-events.js +5 -2
- package/dist/client/runs/use-run-events.js.map +1 -1
- package/dist/client/runs.d.ts +1 -1
- package/dist/client/runs.d.ts.map +1 -1
- package/dist/client/runs.js +1 -1
- package/dist/client/runs.js.map +1 -1
- package/dist/database/migrations/.manifest.json +38 -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/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/202610170001_ag_runner_quota.d.ts +4 -0
- package/dist/database/migrations/202610170001_ag_runner_quota.d.ts.map +1 -0
- package/dist/database/migrations/202610170001_ag_runner_quota.js +19 -0
- package/dist/database/migrations/202610170001_ag_runner_quota.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/database/migrations/202610270001_ag_online_agent.d.ts +4 -0
- package/dist/database/migrations/202610270001_ag_online_agent.d.ts.map +1 -0
- package/dist/database/migrations/202610270001_ag_online_agent.js +43 -0
- package/dist/database/migrations/202610270001_ag_online_agent.js.map +1 -0
- package/dist/database/migrations/202610270002_ag_chat_list_visibility.d.ts +4 -0
- package/dist/database/migrations/202610270002_ag_chat_list_visibility.d.ts.map +1 -0
- package/dist/database/migrations/202610270002_ag_chat_list_visibility.js +17 -0
- package/dist/database/migrations/202610270002_ag_chat_list_visibility.js.map +1 -0
- package/dist/package.json +34 -12
- package/dist/server/cli/run-credential.js +1 -1
- package/dist/server/cli/surface.d.ts.map +1 -1
- package/dist/server/cli/surface.js +4 -1
- package/dist/server/cli/surface.js.map +1 -1
- package/dist/server/composition.d.ts +36 -35
- package/dist/server/composition.d.ts.map +1 -1
- package/dist/server/composition.js +99 -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 +347 -321
- package/dist/server/core/agents/agent.service.js.map +1 -1
- package/dist/server/core/agents/agent.store.d.ts +26 -12
- package/dist/server/core/agents/agent.store.d.ts.map +1 -1
- package/dist/server/core/agents/agent.store.js +74 -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 +88 -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 +3 -2
- package/dist/server/core/agents/index.d.ts.map +1 -1
- package/dist/server/core/agents/index.js +3 -2
- package/dist/server/core/agents/index.js.map +1 -1
- package/dist/server/core/brief/brief.js +3 -3
- package/dist/server/core/brief/brief.js.map +1 -1
- package/dist/server/core/callers/index.d.ts +10 -1
- package/dist/server/core/callers/index.d.ts.map +1 -1
- package/dist/server/core/callers/index.js +15 -0
- package/dist/server/core/callers/index.js.map +1 -1
- package/dist/server/core/conversations/attachments.d.ts.map +1 -1
- package/dist/server/core/conversations/attachments.js +6 -1
- package/dist/server/core/conversations/attachments.js.map +1 -1
- package/dist/server/core/conversations/availability.d.ts +6 -11
- package/dist/server/core/conversations/availability.d.ts.map +1 -1
- package/dist/server/core/conversations/availability.js +11 -15
- package/dist/server/core/conversations/availability.js.map +1 -1
- package/dist/server/core/conversations/chat-settings.d.ts +2 -2
- package/dist/server/core/conversations/chat-settings.d.ts.map +1 -1
- package/dist/server/core/conversations/chat-settings.js +17 -22
- package/dist/server/core/conversations/chat-settings.js.map +1 -1
- package/dist/server/core/conversations/conversation.service.d.ts +13 -8
- package/dist/server/core/conversations/conversation.service.d.ts.map +1 -1
- package/dist/server/core/conversations/conversation.service.js +397 -383
- package/dist/server/core/conversations/conversation.service.js.map +1 -1
- package/dist/server/core/conversations/conversation.store.d.ts +3 -0
- package/dist/server/core/conversations/conversation.store.d.ts.map +1 -1
- package/dist/server/core/conversations/conversation.store.js +2 -1
- package/dist/server/core/conversations/conversation.store.js.map +1 -1
- package/dist/server/core/conversations/page-context.d.ts +8 -2
- package/dist/server/core/conversations/page-context.d.ts.map +1 -1
- package/dist/server/core/conversations/page-context.js +61 -2
- package/dist/server/core/conversations/page-context.js.map +1 -1
- package/dist/server/core/conversations/ports.d.ts +18 -20
- package/dist/server/core/conversations/ports.d.ts.map +1 -1
- package/dist/server/core/reports/model-usage.d.ts.map +1 -1
- package/dist/server/core/reports/model-usage.js +42 -44
- package/dist/server/core/reports/model-usage.js.map +1 -1
- package/dist/server/core/reports/prices.d.ts.map +1 -1
- package/dist/server/core/reports/prices.js +29 -5
- package/dist/server/core/reports/prices.js.map +1 -1
- package/dist/server/core/reports/report.service.d.ts +4 -2
- package/dist/server/core/reports/report.service.d.ts.map +1 -1
- package/dist/server/core/reports/report.service.js +148 -66
- package/dist/server/core/reports/report.service.js.map +1 -1
- package/dist/server/core/runs/access.d.ts +5 -0
- package/dist/server/core/runs/access.d.ts.map +1 -0
- package/dist/server/core/runs/access.js +10 -0
- package/dist/server/core/runs/access.js.map +1 -0
- package/dist/server/core/runs/availability.d.ts +18 -6
- package/dist/server/core/runs/availability.d.ts.map +1 -1
- package/dist/server/core/runs/availability.js +40 -34
- package/dist/server/core/runs/availability.js.map +1 -1
- package/dist/server/core/runs/claim.d.ts +30 -106
- package/dist/server/core/runs/claim.d.ts.map +1 -1
- package/dist/server/core/runs/claim.js +630 -323
- 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 +13 -1
- package/dist/server/core/runs/eligibility.d.ts.map +1 -1
- package/dist/server/core/runs/eligibility.js +41 -10
- package/dist/server/core/runs/eligibility.js.map +1 -1
- package/dist/server/core/runs/execution-view.d.ts +8 -0
- package/dist/server/core/runs/execution-view.d.ts.map +1 -1
- package/dist/server/core/runs/execution-view.js +9 -0
- package/dist/server/core/runs/execution-view.js.map +1 -1
- package/dist/server/core/runs/execution.d.ts +1 -1
- package/dist/server/core/runs/execution.d.ts.map +1 -1
- package/dist/server/core/runs/execution.js +8 -2
- package/dist/server/core/runs/execution.js.map +1 -1
- 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 +6 -6
- package/dist/server/core/runs/index.d.ts.map +1 -1
- package/dist/server/core/runs/index.js +6 -6
- package/dist/server/core/runs/index.js.map +1 -1
- package/dist/server/core/runs/input-gate.d.ts +1 -1
- package/dist/server/core/runs/input-gate.d.ts.map +1 -1
- package/dist/server/core/runs/input-gate.js +4 -2
- package/dist/server/core/runs/input-gate.js.map +1 -1
- package/dist/server/core/runs/lifecycle.d.ts +16 -18
- package/dist/server/core/runs/lifecycle.d.ts.map +1 -1
- package/dist/server/core/runs/lifecycle.js +150 -62
- package/dist/server/core/runs/lifecycle.js.map +1 -1
- package/dist/server/core/runs/policy.d.ts +9 -2
- package/dist/server/core/runs/policy.d.ts.map +1 -1
- package/dist/server/core/runs/policy.js +17 -8
- package/dist/server/core/runs/policy.js.map +1 -1
- package/dist/server/core/runs/ports.d.ts +41 -31
- 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 +1 -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 +25 -0
- package/dist/server/core/runs/run-requests.d.ts.map +1 -1
- package/dist/server/core/runs/run-requests.js +131 -64
- package/dist/server/core/runs/run-requests.js.map +1 -1
- package/dist/server/core/runs/run.service.d.ts +31 -2
- package/dist/server/core/runs/run.service.d.ts.map +1 -1
- package/dist/server/core/runs/run.service.js +638 -74
- package/dist/server/core/runs/run.service.js.map +1 -1
- package/dist/server/core/runs/run.store.d.ts +11 -0
- package/dist/server/core/runs/run.store.d.ts.map +1 -1
- package/dist/server/core/runs/run.store.js +39 -11
- package/dist/server/core/runs/run.store.js.map +1 -1
- package/dist/server/core/runs/runner-view.d.ts +12 -2
- package/dist/server/core/runs/runner-view.d.ts.map +1 -1
- package/dist/server/core/runs/runner-view.js +55 -13
- 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 +66 -17
- package/dist/server/core/runs/sweeper.js.map +1 -1
- package/dist/server/core/runs/transitions.d.ts +6 -2
- package/dist/server/core/runs/transitions.d.ts.map +1 -1
- package/dist/server/core/runs/transitions.js +73 -19
- package/dist/server/core/runs/transitions.js.map +1 -1
- package/dist/server/core/runs/workload.d.ts +17 -5
- package/dist/server/core/runs/workload.d.ts.map +1 -1
- package/dist/server/core/runs/workload.js +203 -68
- 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 +87 -66
- 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/transaction-read.d.ts +4 -0
- package/dist/server/core/transaction-read.d.ts.map +1 -0
- package/dist/server/core/transaction-read.js +30 -0
- package/dist/server/core/transaction-read.js.map +1 -0
- 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.map +1 -1
- package/dist/server/core/variables/variable.service.d.ts +18 -0
- package/dist/server/core/variables/variable.service.d.ts.map +1 -1
- package/dist/server/core/variables/variable.service.js +95 -20
- package/dist/server/core/variables/variable.service.js.map +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/jobs/job.service.d.ts +1 -1
- package/dist/server/jobs/job.service.d.ts.map +1 -1
- package/dist/server/jobs/job.service.js +8 -2
- package/dist/server/jobs/job.service.js.map +1 -1
- package/dist/server/kernel/events.d.ts +7 -3
- package/dist/server/kernel/events.d.ts.map +1 -1
- package/dist/server/kernel/events.js.map +1 -1
- package/dist/server/kernel/scopes.d.ts +6 -0
- 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/locales/de-DE.d.ts +5 -0
- package/dist/server/locales/de-DE.d.ts.map +1 -0
- package/dist/server/locales/de-DE.js +54 -0
- package/dist/server/locales/de-DE.js.map +1 -0
- package/dist/server/locales/es-ES.d.ts +5 -0
- package/dist/server/locales/es-ES.d.ts.map +1 -0
- package/dist/server/locales/es-ES.js +54 -0
- package/dist/server/locales/es-ES.js.map +1 -0
- package/dist/server/locales/fr-FR.d.ts +5 -0
- package/dist/server/locales/fr-FR.d.ts.map +1 -0
- package/dist/server/locales/fr-FR.js +54 -0
- package/dist/server/locales/fr-FR.js.map +1 -0
- package/dist/server/locales/id-ID.d.ts +5 -0
- package/dist/server/locales/id-ID.d.ts.map +1 -0
- package/dist/server/locales/id-ID.js +54 -0
- package/dist/server/locales/id-ID.js.map +1 -0
- package/dist/server/locales/index.d.ts.map +1 -1
- package/dist/server/locales/index.js +8 -0
- package/dist/server/locales/index.js.map +1 -1
- package/dist/server/locales/ja-JP.d.ts +5 -0
- package/dist/server/locales/ja-JP.d.ts.map +1 -0
- package/dist/server/locales/ja-JP.js +54 -0
- package/dist/server/locales/ja-JP.js.map +1 -0
- package/dist/server/locales/pt-BR.d.ts +5 -0
- package/dist/server/locales/pt-BR.d.ts.map +1 -0
- package/dist/server/locales/pt-BR.js +54 -0
- package/dist/server/locales/pt-BR.js.map +1 -0
- package/dist/server/locales/vi-VN.d.ts +5 -0
- package/dist/server/locales/vi-VN.d.ts.map +1 -0
- package/dist/server/locales/vi-VN.js +54 -0
- package/dist/server/locales/vi-VN.js.map +1 -0
- package/dist/server/locales/zh-TW.d.ts +5 -0
- package/dist/server/locales/zh-TW.d.ts.map +1 -0
- package/dist/server/locales/zh-TW.js +54 -0
- package/dist/server/locales/zh-TW.js.map +1 -0
- package/dist/server/online/agent/configuration.d.ts +26 -0
- package/dist/server/online/agent/configuration.d.ts.map +1 -0
- package/dist/server/online/agent/configuration.js +261 -0
- package/dist/server/online/agent/configuration.js.map +1 -0
- package/dist/server/online/agent/contracts.d.ts +87 -0
- package/dist/server/online/agent/contracts.d.ts.map +1 -0
- package/dist/server/online/agent/contracts.js +2 -0
- package/dist/server/online/agent/contracts.js.map +1 -0
- package/dist/server/online/agent/errors.d.ts +11 -0
- package/dist/server/online/agent/errors.d.ts.map +1 -0
- package/dist/server/online/agent/errors.js +21 -0
- package/dist/server/online/agent/errors.js.map +1 -0
- package/dist/server/online/agent/index.d.ts +11 -0
- package/dist/server/online/agent/index.d.ts.map +1 -0
- package/dist/server/online/agent/index.js +9 -0
- package/dist/server/online/agent/index.js.map +1 -0
- package/dist/server/online/agent/messages/json.d.ts +5 -0
- package/dist/server/online/agent/messages/json.d.ts.map +1 -0
- package/dist/server/online/agent/messages/json.js +88 -0
- package/dist/server/online/agent/messages/json.js.map +1 -0
- package/dist/server/online/agent/messages/projection.d.ts +20 -0
- package/dist/server/online/agent/messages/projection.d.ts.map +1 -0
- package/dist/server/online/agent/messages/projection.js +495 -0
- package/dist/server/online/agent/messages/projection.js.map +1 -0
- package/dist/server/online/agent/messages/validation.d.ts +7 -0
- package/dist/server/online/agent/messages/validation.d.ts.map +1 -0
- package/dist/server/online/agent/messages/validation.js +159 -0
- package/dist/server/online/agent/messages/validation.js.map +1 -0
- package/dist/server/online/agent/native/backend.d.ts +60 -0
- package/dist/server/online/agent/native/backend.d.ts.map +1 -0
- package/dist/server/online/agent/native/backend.js +411 -0
- package/dist/server/online/agent/native/backend.js.map +1 -0
- package/dist/server/online/agent/native/execution.d.ts +41 -0
- package/dist/server/online/agent/native/execution.d.ts.map +1 -0
- package/dist/server/online/agent/native/execution.js +430 -0
- package/dist/server/online/agent/native/execution.js.map +1 -0
- package/dist/server/online/agent/native/session.d.ts +40 -0
- package/dist/server/online/agent/native/session.d.ts.map +1 -0
- package/dist/server/online/agent/native/session.js +104 -0
- package/dist/server/online/agent/native/session.js.map +1 -0
- package/dist/server/online/agent/native/types.d.ts +32 -0
- package/dist/server/online/agent/native/types.d.ts.map +1 -0
- package/dist/server/online/agent/native/types.js +2 -0
- package/dist/server/online/agent/native/types.js.map +1 -0
- package/dist/server/online/agent/persistence/manager.d.ts +16 -0
- package/dist/server/online/agent/persistence/manager.d.ts.map +1 -0
- package/dist/server/online/agent/persistence/manager.js +209 -0
- package/dist/server/online/agent/persistence/manager.js.map +1 -0
- package/dist/server/online/agent/persistence/state.d.ts +11 -0
- package/dist/server/online/agent/persistence/state.d.ts.map +1 -0
- package/dist/server/online/agent/persistence/state.js +45 -0
- package/dist/server/online/agent/persistence/state.js.map +1 -0
- package/dist/server/online/agent/persistence/store.d.ts +58 -0
- package/dist/server/online/agent/persistence/store.d.ts.map +1 -0
- package/dist/server/online/agent/persistence/store.js +634 -0
- package/dist/server/online/agent/persistence/store.js.map +1 -0
- package/dist/server/online/agent/persistence/types.d.ts +44 -0
- package/dist/server/online/agent/persistence/types.d.ts.map +1 -0
- package/dist/server/online/agent/persistence/types.js +2 -0
- package/dist/server/online/agent/persistence/types.js.map +1 -0
- package/dist/server/online/agent/runner/backend.d.ts +57 -0
- package/dist/server/online/agent/runner/backend.d.ts.map +1 -0
- package/dist/server/online/agent/runner/backend.js +501 -0
- package/dist/server/online/agent/runner/backend.js.map +1 -0
- package/dist/server/online/agent/runner/projection.d.ts +10 -0
- package/dist/server/online/agent/runner/projection.d.ts.map +1 -0
- package/dist/server/online/agent/runner/projection.js +171 -0
- package/dist/server/online/agent/runner/projection.js.map +1 -0
- package/dist/server/online/agent/runner/types.d.ts +44 -0
- package/dist/server/online/agent/runner/types.d.ts.map +1 -0
- package/dist/server/online/agent/runner/types.js +2 -0
- package/dist/server/online/agent/runner/types.js.map +1 -0
- package/dist/server/online/agent/service.d.ts +47 -0
- package/dist/server/online/agent/service.d.ts.map +1 -0
- package/dist/server/online/agent/service.js +111 -0
- package/dist/server/online/agent/service.js.map +1 -0
- package/dist/server/online/agent/transport/streams.d.ts +54 -0
- package/dist/server/online/agent/transport/streams.d.ts.map +1 -0
- package/dist/server/online/agent/transport/streams.js +440 -0
- package/dist/server/online/agent/transport/streams.js.map +1 -0
- package/dist/server/online/agent/types.d.ts +155 -0
- package/dist/server/online/agent/types.d.ts.map +1 -0
- package/dist/server/online/agent/types.js +2 -0
- package/dist/server/online/agent/types.js.map +1 -0
- 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/providers.d.ts.map +1 -1
- package/dist/server/online/providers.js +26 -2
- package/dist/server/online/providers.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/online/services.d.ts.map +1 -1
- package/dist/server/online/services.js +101 -24
- package/dist/server/online/services.js.map +1 -1
- package/dist/server/providers/agents.d.ts +18 -25
- package/dist/server/providers/agents.d.ts.map +1 -1
- package/dist/server/providers/agents.js +72 -101
- package/dist/server/providers/agents.js.map +1 -1
- package/dist/server/providers/authorization.d.ts +1 -1
- package/dist/server/providers/authorization.d.ts.map +1 -1
- package/dist/server/providers/authorization.js +3 -2
- package/dist/server/providers/authorization.js.map +1 -1
- package/dist/server/providers/runners.d.ts +3 -1
- package/dist/server/providers/runners.d.ts.map +1 -1
- package/dist/server/providers/runners.js +38 -9
- package/dist/server/providers/runners.js.map +1 -1
- package/dist/server/routes/admin.d.ts +4 -0
- package/dist/server/routes/admin.d.ts.map +1 -1
- package/dist/server/routes/admin.js +131 -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 +313 -164
- 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 +8 -0
- 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 -22
- package/dist/server/routes/roster.js.map +1 -1
- package/dist/server/routes/run-requests.js +3 -3
- package/dist/server/routes/run-requests.js.map +1 -1
- package/dist/server/routes/runners/admin.d.ts.map +1 -1
- package/dist/server/routes/runners/admin.js +219 -25
- package/dist/server/routes/runners/admin.js.map +1 -1
- package/dist/server/routes/runners/install.d.ts.map +1 -1
- package/dist/server/routes/runners/install.js +7 -2
- 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 +2 -0
- package/dist/server/routes/runners/runner.js.map +1 -1
- package/dist/server/routes/schemas.d.ts +18 -10
- package/dist/server/routes/schemas.d.ts.map +1 -1
- package/dist/server/routes/schemas.js +497 -153
- package/dist/server/routes/schemas.js.map +1 -1
- package/dist/server/runners/runner.service.d.ts +47 -4
- package/dist/server/runners/runner.service.d.ts.map +1 -1
- package/dist/server/runners/runner.service.js +423 -79
- package/dist/server/runners/runner.service.js.map +1 -1
- package/dist/server/runners/runner.store.d.ts +8 -3
- package/dist/server/runners/runner.store.d.ts.map +1 -1
- package/dist/server/runners/runner.store.js +63 -6
- package/dist/server/runners/runner.store.js.map +1 -1
- package/dist/server/runners/slots.d.ts +5 -2
- package/dist/server/runners/slots.d.ts.map +1 -1
- package/dist/server/runners/slots.js +3 -4
- package/dist/server/runners/slots.js.map +1 -1
- package/dist/server/runners/workspaces.d.ts.map +1 -1
- package/dist/server/runners/workspaces.js +18 -2
- package/dist/server/runners/workspaces.js.map +1 -1
- 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 +8 -7
- package/dist/server/tokens.d.ts.map +1 -1
- package/dist/server/tokens.js +4 -2
- package/dist/server/tokens.js.map +1 -1
- package/dist/shared/access.d.ts +3 -7
- package/dist/shared/access.d.ts.map +1 -1
- package/dist/shared/access.js +3 -7
- package/dist/shared/access.js.map +1 -1
- package/dist/shared/agents.d.ts +131 -169
- package/dist/shared/agents.d.ts.map +1 -1
- package/dist/shared/agents.js +36 -102
- package/dist/shared/agents.js.map +1 -1
- package/dist/shared/conversations.d.ts +93 -170
- package/dist/shared/conversations.d.ts.map +1 -1
- package/dist/shared/conversations.js +8 -30
- package/dist/shared/conversations.js.map +1 -1
- package/dist/shared/locales/access.en-US.js +3 -3
- package/dist/shared/locales/access.zh-CN.js +4 -4
- package/dist/shared/model-catalog.d.ts +53 -0
- package/dist/shared/model-catalog.d.ts.map +1 -0
- package/dist/shared/model-catalog.js +182 -0
- package/dist/shared/model-catalog.js.map +1 -0
- package/dist/shared/online-agent.d.ts +3 -0
- package/dist/shared/online-agent.d.ts.map +1 -0
- package/dist/shared/online-agent.js +3 -0
- package/dist/shared/online-agent.js.map +1 -0
- package/dist/shared/page-ui-context.d.ts +26 -0
- package/dist/shared/page-ui-context.d.ts.map +1 -0
- package/dist/shared/page-ui-context.js +129 -0
- package/dist/shared/page-ui-context.js.map +1 -0
- package/dist/shared/quota.d.ts +15 -0
- package/dist/shared/quota.d.ts.map +1 -0
- package/dist/shared/quota.js +2 -0
- package/dist/shared/quota.js.map +1 -0
- package/dist/shared/runners.d.ts +132 -14
- package/dist/shared/runners.d.ts.map +1 -1
- package/dist/shared/runners.js +171 -11
- package/dist/shared/runners.js.map +1 -1
- package/dist/shared/runs.d.ts +57 -1
- package/dist/shared/runs.d.ts.map +1 -1
- package/dist/shared/runs.js +28 -0
- package/dist/shared/runs.js.map +1 -1
- package/dist/shared/skills.d.ts +11 -5
- 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/ui-message.d.ts +80 -0
- package/dist/shared/ui-message.d.ts.map +1 -0
- package/dist/shared/ui-message.js +153 -0
- package/dist/shared/ui-message.js.map +1 -0
- package/dist/shared/variables.js +1 -1
- package/dist/shared/variables.js.map +1 -1
- package/docs/ai-forms.md +346 -0
- package/docs/execution-history.md +19 -0
- package/docs/mysql-installation-upgrade.md +7 -0
- package/docs/runner-agents.md +27 -0
- package/docs/ui-message-clients.md +80 -0
- package/docs/ui-messages.md +209 -0
- package/docs/workspace-cleanup.md +13 -0
- package/package.json +40 -26
- package/skills/nocobase-app-plugin-agents/SKILL.md +16 -13
- package/skills/nocobase-app-plugin-agents/references/agents.md +30 -0
- package/skills/nocobase-app-plugin-agents/references/extension-points.md +21 -21
- package/skills/nocobase-app-plugin-agents/references/model-services.md +17 -0
- package/skills/nocobase-app-plugin-agents/references/online-agent.md +216 -0
- package/skills/nocobase-app-plugin-agents/references/runners.md +12 -0
- package/skills/nocobase-app-plugin-agents/references/setup-and-config.md +6 -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 +29 -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 -86
- 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 -44
- package/dist/client/components/model-entries.d.ts.map +0 -1
- package/dist/client/components/model-entries.js +0 -104
- 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/model-suggestions.d.ts +0 -28
- package/dist/client/lib/model-suggestions.d.ts.map +0 -1
- package/dist/client/lib/model-suggestions.js +0 -44
- package/dist/client/lib/model-suggestions.js.map +0 -1
- package/dist/client/lib/tool-policy.d.ts +0 -3
- package/dist/client/lib/tool-policy.d.ts.map +0 -1
- package/dist/client/lib/tool-policy.js +0 -5
- 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 -69
- package/dist/client/pages/agents/agent-model.d.ts.map +0 -1
- package/dist/client/pages/agents/agent-model.js +0 -153
- 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 -21
- package/dist/client/pages/agents/detail/sections.d.ts.map +0 -1
- package/dist/client/pages/agents/detail/sections.js +0 -280
- 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 -198
- 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
|
@@ -30,41 +30,43 @@
|
|
|
30
30
|
* Portable by design: the database layer offers no `FOR UPDATE SKIP LOCKED` or advisory locks, and the guarded update
|
|
31
31
|
* plus the agent-row write give the same guarantees on every dialect (SQLite serializes writers anyway).
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* the
|
|
37
|
-
*
|
|
33
|
+
* Polls are the hot path: every runner walks the same candidates, so a write per candidate is a write per candidate per
|
|
34
|
+
* runner per poll. Everything that rules a candidate out is read outside any transaction — identity, `fits()`, slots,
|
|
35
|
+
* concurrency and comment consent — and a transaction opens only for the run about to be claimed. The agent row is
|
|
36
|
+
* the only row a claim locks with a self-update, and only in that final transaction after `fits()` (or when a stale
|
|
37
|
+
* identity has to be repaired first, which current work never needs). PostgreSQL runs at READ COMMITTED, where each
|
|
38
|
+
* statement sees the latest committed rows, so no transaction needs no-op writes to refresh a snapshot; comment
|
|
39
|
+
* consent needs no chain lock, because confirmation is final and rejection or Run as me end the chain's queued runs,
|
|
40
|
+
* which the guarded update sees. A new write or lock here needs a measured reason (`tests/claim-concurrency.test.ts`
|
|
41
|
+
* counts them, and the lock waits on PostgreSQL).
|
|
42
|
+
|
|
38
43
|
*/
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
44
|
+
import { GLOBAL_SKILL_TARGET } from '../../../shared/skills.js';
|
|
45
|
+
import { ANNOUNCED_FAILURES, isProtocolSupported, policyAllowsAgent, policyAllowsRepo, policyAllowsSubject, TIMINGS, } from '@nocobase/agent-protocol';
|
|
46
|
+
import { runnerLowOnDisk, runsEntry, toolLimit, supportsWorkspaceKey, } from '../../../shared/runners.js';
|
|
47
|
+
import { queueStart } from './selection.js';
|
|
41
48
|
import { createHash } from 'node:crypto';
|
|
42
|
-
import { onlineEntriesOrDefault, runnerEntries, sameEntry, } from '../../../shared/agents.js';
|
|
43
49
|
import { later } from '../../kernel/clock.js';
|
|
44
50
|
import { notFound } from '../../kernel/errors.js';
|
|
45
51
|
import { runSecretsKey } from '../../kernel/redaction.js';
|
|
46
|
-
import { cleanList, covers } from '../../kernel/values.js';
|
|
47
|
-
import { findAgent, lockAgentForClaim } from '../agents/index.js';
|
|
48
|
-
import {
|
|
49
|
-
import { joinBrief, onlineSkillsSection, renderBrief, } from '../brief/index.js';
|
|
52
|
+
import { cleanList, covers, jsonObject } from '../../kernel/values.js';
|
|
53
|
+
import { findAgent, findAgents, lockAgentForClaim } from '../agents/index.js';
|
|
54
|
+
import { joinBrief, renderBrief } from '../brief/index.js';
|
|
50
55
|
import { cliPackageFor } from './cli-package.js';
|
|
51
56
|
import { executionHistory } from './execution.js';
|
|
52
57
|
import { describeVariables, variableRefs, } from '../variables/index.js';
|
|
53
58
|
import { mountsFor, prepareExtensions, repoAccessFor, sessionKeyOf, withSections, } from './extensions.js';
|
|
54
|
-
import { dialectOf, } from './ports.js';
|
|
55
59
|
import { MAX_CLAIM_FAILURES, toolPolicyFor } from './policy.js';
|
|
56
60
|
import { mintRunToken } from './run-tokens.js';
|
|
57
|
-
import {
|
|
58
|
-
import { ACTIVE, countActive, eventsRepo, findRunRecord, markDelivered, pendingInputs, runsOfKey, runsRepo, sessionsRepo, toInput, toRun, } from './run.store.js';
|
|
61
|
+
import { ACTIVE, countActive, eventsRepo, findRunRecord, markDelivered, pendingInputs, runsOfKey, runsRepo, inputsRepo, sessionsRepo, toInput, toExecutions, toRun, } from './run.store.js';
|
|
59
62
|
import { dropInputs } from './input-gate.js';
|
|
60
63
|
import { finishRun } from './transitions.js';
|
|
64
|
+
import { queuedIdentityCurrent, refreshQueuedIdentity } from './identity.js';
|
|
65
|
+
import { currentCommentOwner, commentConsent, commentFromOwner, withdrawCommentRequests, } from './comment-consent.js';
|
|
66
|
+
import { insertRunRequest, runRequestsRepo } from './run-requests.js';
|
|
61
67
|
import { consumeReset, saveBrief } from './workspace.store.js';
|
|
62
68
|
/** Queued runs looked at per claim, oldest first by priority. */
|
|
63
69
|
const CANDIDATES = 50;
|
|
64
|
-
/** Whether a run holder id is an application instance's (an online run's), not a runner's. */
|
|
65
|
-
export function isServerHolder(runnerId) {
|
|
66
|
-
return runnerId !== null && runnerId.startsWith('server:');
|
|
67
|
-
}
|
|
68
70
|
class AssemblyError extends Error {
|
|
69
71
|
cause;
|
|
70
72
|
constructor(message, cause) {
|
|
@@ -101,57 +103,50 @@ function toolRoom(tools) {
|
|
|
101
103
|
};
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
104
|
-
* The entry `runner` takes a run of `agent` with: the first whose tool it has enabled, installed and signed in
|
|
105
|
-
*
|
|
106
|
+
* The entry `runner` takes a run of `agent` with: the first whose tool it has enabled, installed and signed in, with
|
|
107
|
+
* the entry's model among those it reports (`runsEntry`). Null when it has none of them.
|
|
106
108
|
*/
|
|
107
|
-
export function pickEntry(runner, agent) {
|
|
108
|
-
return (
|
|
109
|
+
export function pickEntry(runner, agent, now) {
|
|
110
|
+
return (agent.modelEntries.find((entry) => runsEntry(runner, entry, now)) ?? null);
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
113
|
* The entry `runner` takes a run of `agent` with when some of its tools are full: the first whose tool it runs and
|
|
112
114
|
* `open` says has room. Null when none has.
|
|
113
115
|
*/
|
|
114
|
-
export function pickOpenEntry(runner, agent, open) {
|
|
115
|
-
return (
|
|
116
|
-
}
|
|
117
|
-
/** Whether `runner` has one of `agent`'s tools enabled, installed and signed in; never for an online agent. */
|
|
118
|
-
export function hasTool(runner, agent) {
|
|
119
|
-
return pickEntry(runner, agent) !== null;
|
|
116
|
+
export function pickOpenEntry(runner, agent, open, now) {
|
|
117
|
+
return (agent.modelEntries.find((entry) => runsEntry(runner, entry, now) && open(entry.tool)) ?? null);
|
|
120
118
|
}
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
*/
|
|
125
|
-
export function onlineEntryOf(agent, wanted, fallback = null) {
|
|
126
|
-
const entries = onlineEntriesOrDefault(agent, fallback);
|
|
127
|
-
return ((wanted && entries.find((entry) => sameEntry(entry, wanted))) ??
|
|
128
|
-
entries[0] ??
|
|
129
|
-
null);
|
|
119
|
+
/** Whether `runner` has one of `agent`'s tools and models enabled, installed, signed in and reported. */
|
|
120
|
+
export function hasTool(runner, agent, now) {
|
|
121
|
+
return pickEntry(runner, agent, now) !== null;
|
|
130
122
|
}
|
|
131
123
|
/**
|
|
132
124
|
* Whether `runner` may run work of `agent` as `actorUserId` that needs `requires`, before any lock is taken and before
|
|
133
|
-
* a payload is known: the agent
|
|
125
|
+
* a payload is known: the agent enabled, its tool and model reported there, its owner's policy, and trust.
|
|
134
126
|
*/
|
|
135
|
-
export function fitsActor(runner, agent, actorUserId, requires) {
|
|
136
|
-
if (agent.
|
|
127
|
+
export function fitsActor(runner, agent, actorUserId, requires, now) {
|
|
128
|
+
if (agent.status !== 'enabled' || runnerLowOnDisk(runner))
|
|
129
|
+
return false;
|
|
130
|
+
if (!isProtocolSupported(runner.protocolVersion) ||
|
|
131
|
+
runner.status === 'upgrade_required' ||
|
|
132
|
+
runner.status === 'revoked')
|
|
137
133
|
return false;
|
|
138
134
|
if (!covers(runner.features, requires))
|
|
139
135
|
return false;
|
|
140
|
-
if (!hasTool(runner, agent))
|
|
136
|
+
if (!hasTool(runner, agent, now))
|
|
141
137
|
return false;
|
|
142
138
|
if (!policyAllowsAgent(runner.policy, agent))
|
|
143
139
|
return false;
|
|
144
|
-
if (agent.runnerIds.length > 0 && !agent.runnerIds.includes(runner.id))
|
|
145
|
-
return false;
|
|
146
140
|
return runner.trust === 'team' || runner.ownerUserId === actorUserId;
|
|
147
141
|
}
|
|
148
142
|
/** Whether `runner` may run `run` of `agent`, before any lock is taken and before its payload is known. */
|
|
149
|
-
export function fits(runner, agent, run) {
|
|
150
|
-
return fitsActor(runner, agent, run.actorUserId, toRun(run).requires);
|
|
143
|
+
export function fits(runner, agent, run, now) {
|
|
144
|
+
return fitsActor(runner, agent, run.actorUserId, toRun(run).requires, now);
|
|
151
145
|
}
|
|
152
146
|
/** The runner features a payload needs. */
|
|
153
|
-
export function payloadRequires(dirs, skills, variables) {
|
|
147
|
+
export function payloadRequires(dirs, skills, variables, workspaceKey = false) {
|
|
154
148
|
return [
|
|
149
|
+
...(workspaceKey ? ['workspaceKey'] : []),
|
|
155
150
|
...(dirs.some((dir) => dir.kind === 'repo') ? ['checkout'] : []),
|
|
156
151
|
...(dirs.some((dir) => dir.kind === 'directory')
|
|
157
152
|
? ['directories']
|
|
@@ -175,11 +170,11 @@ export function variableTargets(agent, assembly) {
|
|
|
175
170
|
{ scope: 'agent', scopeId: agent.id },
|
|
176
171
|
];
|
|
177
172
|
}
|
|
178
|
-
/**
|
|
179
|
-
export function skillTargets(
|
|
173
|
+
/** Team defaults, application scopes and directories, from lowest to highest priority. */
|
|
174
|
+
export function skillTargets(_agent, assembly) {
|
|
180
175
|
return [
|
|
181
|
-
|
|
182
|
-
...assembly.scopes,
|
|
176
|
+
GLOBAL_SKILL_TARGET,
|
|
177
|
+
...assembly.scopes.filter((target) => target.scope !== 'agent' && target.scope !== 'global'),
|
|
183
178
|
...assembly.dirs.flatMap((dir) => dir.scopeId ? [{ scope: 'workdir', scopeId: dir.scopeId }] : []),
|
|
184
179
|
];
|
|
185
180
|
}
|
|
@@ -198,7 +193,6 @@ function fingerprint(agent, entry, layers, skills) {
|
|
|
198
193
|
/** The brief for `assembly`, with the skills a run would get. */
|
|
199
194
|
export function briefOf(agent, assembly, skills, cli, appName) {
|
|
200
195
|
const rendered = renderBrief({
|
|
201
|
-
dialect: dialectOf(agent),
|
|
202
196
|
agentName: agent.name,
|
|
203
197
|
subject: { noun: assembly.subject.noun, key: assembly.subject.key },
|
|
204
198
|
task: assembly.task,
|
|
@@ -252,7 +246,226 @@ async function settleClaimInputs(conn, pending, effective, now) {
|
|
|
252
246
|
}
|
|
253
247
|
export function createClaimService(deps) {
|
|
254
248
|
const { tx, clock } = deps;
|
|
255
|
-
|
|
249
|
+
/** Reuse only identical ordered targets, within this attempt and connection. */
|
|
250
|
+
function claimResources(conn, runId) {
|
|
251
|
+
const cache = new Map();
|
|
252
|
+
return (agent, assembly) => {
|
|
253
|
+
const skills = skillTargets(agent, assembly);
|
|
254
|
+
const variables = variableTargets(agent, assembly);
|
|
255
|
+
const key = JSON.stringify([skills, variables]);
|
|
256
|
+
let result = cache.get(key);
|
|
257
|
+
if (!result) {
|
|
258
|
+
result = (async () => ({
|
|
259
|
+
skills: await deps.skills.forRun(conn, skills, runId),
|
|
260
|
+
variables: await deps.variables.prepareRun(conn, variables),
|
|
261
|
+
}))();
|
|
262
|
+
cache.set(key, result);
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/** Database reads only; used by the actual claim and ordered-model diagnostics. */
|
|
268
|
+
async function assemblyCompatibility(conn, run, agent, runner, assembly, resources = claimResources(conn, run.id)) {
|
|
269
|
+
if (!isProtocolSupported(runner.protocolVersion) ||
|
|
270
|
+
(assembly.workspaceKey && !supportsWorkspaceKey(runner)))
|
|
271
|
+
return 'incompatible';
|
|
272
|
+
const { skills, variables } = await resources(agent, assembly);
|
|
273
|
+
const names = variables.names;
|
|
274
|
+
if (!covers(runner.features, [
|
|
275
|
+
...run.requires,
|
|
276
|
+
...payloadRequires(payloadDirs(assembly.dirs), skills.length, names.length, Boolean(assembly.workspaceKey)),
|
|
277
|
+
]))
|
|
278
|
+
return 'incompatible';
|
|
279
|
+
if (!fitsActor(runner, agent, run.actorUserId, run.requires, clock.now().getTime()) ||
|
|
280
|
+
!policyAllowsSubject(runner.policy, assembly.subject.key) ||
|
|
281
|
+
assembly.dirs.some((dir) => (dir.kind === 'repo' && !policyAllowsRepo(runner.policy, dir.url)) ||
|
|
282
|
+
(dir.kind === 'directory' && dir.runnerId !== runner.id)))
|
|
283
|
+
return 'restricted';
|
|
284
|
+
if (runner.trust !== 'team' && variables.teamOnly.length > 0)
|
|
285
|
+
return 'restricted';
|
|
286
|
+
return 'ready';
|
|
287
|
+
}
|
|
288
|
+
async function selectionFacts(conn, run, agent, requirePolicy = true, trust, resources = claimResources(conn, run.id)) {
|
|
289
|
+
const policy = await deps.selectionPolicies?.forRun(conn, run);
|
|
290
|
+
if ((requirePolicy && !policy) || !deps.runners)
|
|
291
|
+
return null;
|
|
292
|
+
const now = clock.now();
|
|
293
|
+
const start = queueStart(run);
|
|
294
|
+
const registered = (await deps.runners.all(conn)).filter((runner) => !trust ||
|
|
295
|
+
(trust === 'team' ? runner.trust === 'team' : runner.trust !== 'team'));
|
|
296
|
+
const binding = deps.subjects.get(run.subject.kind);
|
|
297
|
+
if (!binding)
|
|
298
|
+
throw new Error(`No context provider for ${run.subject.kind}.`);
|
|
299
|
+
const inputs = (await pendingInputs(conn, run.id)).map(toInput);
|
|
300
|
+
const active = await countActive(conn, 'agentId', agent.id);
|
|
301
|
+
const sameWork = (await runsOfKey(conn, {
|
|
302
|
+
agentId: agent.id,
|
|
303
|
+
subjectKind: run.subject.kind,
|
|
304
|
+
subjectId: run.subject.id,
|
|
305
|
+
threadScope: run.threadScope,
|
|
306
|
+
}, ACTIVE)).length > 0;
|
|
307
|
+
const entries = [];
|
|
308
|
+
for (const entry of agent.modelEntries) {
|
|
309
|
+
const single = { ...agent, modelEntries: [entry] };
|
|
310
|
+
const candidates = registered.filter((runner) => runner.status !== 'revoked');
|
|
311
|
+
const connected = candidates.filter((runner) => (runner.status === 'online' ||
|
|
312
|
+
runner.status === 'upgrade_required') &&
|
|
313
|
+
runner.lastSeenAt !== null &&
|
|
314
|
+
new Date(runner.lastSeenAt).getTime() + TIMINGS.offlineAfterMs >
|
|
315
|
+
now.getTime());
|
|
316
|
+
const installed = connected.filter((runner) => runner.tools.some((tool) => tool.kind === entry.tool));
|
|
317
|
+
const usable = installed.filter((runner) => runsEntry(runner, entry, clock.now().getTime()));
|
|
318
|
+
const online = usable.filter((runner) => runner.trust === 'team' || runner.ownerUserId === run.actorUserId);
|
|
319
|
+
const compatible = [];
|
|
320
|
+
const loads = [];
|
|
321
|
+
let unknown = false;
|
|
322
|
+
let incompatible = false;
|
|
323
|
+
let ready = false;
|
|
324
|
+
let directoryBlocked = false;
|
|
325
|
+
for (const runner of online) {
|
|
326
|
+
if (!isProtocolSupported(runner.protocolVersion) ||
|
|
327
|
+
runner.status === 'upgrade_required') {
|
|
328
|
+
incompatible = true;
|
|
329
|
+
loads.push({
|
|
330
|
+
name: runner.name,
|
|
331
|
+
ownerUserId: runner.ownerUserId,
|
|
332
|
+
reason: 'incompatible',
|
|
333
|
+
lastSeenAt: runner.lastSeenAt,
|
|
334
|
+
});
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const assembly = await binding.context
|
|
338
|
+
.assemble(conn, {
|
|
339
|
+
run: run,
|
|
340
|
+
agent,
|
|
341
|
+
runner,
|
|
342
|
+
inputs,
|
|
343
|
+
cli: deps.cli.name,
|
|
344
|
+
appName: deps.app.name,
|
|
345
|
+
})
|
|
346
|
+
.catch(() => null);
|
|
347
|
+
if (!assembly) {
|
|
348
|
+
unknown = true;
|
|
349
|
+
loads.push({
|
|
350
|
+
name: runner.name,
|
|
351
|
+
ownerUserId: runner.ownerUserId,
|
|
352
|
+
reason: 'unknown',
|
|
353
|
+
lastSeenAt: runner.lastSeenAt,
|
|
354
|
+
});
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const reason = await assemblyCompatibility(conn, run, single, runner, assembly, resources);
|
|
358
|
+
if (reason !== 'ready') {
|
|
359
|
+
incompatible ||= reason === 'incompatible';
|
|
360
|
+
loads.push({
|
|
361
|
+
name: runner.name,
|
|
362
|
+
ownerUserId: runner.ownerUserId,
|
|
363
|
+
reason,
|
|
364
|
+
lastSeenAt: runner.lastSeenAt,
|
|
365
|
+
});
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const requiredVariables = (await resources(single, assembly)).variables
|
|
369
|
+
.passthrough;
|
|
370
|
+
if (requiredVariables.length > 0 && runner.variables == null) {
|
|
371
|
+
unknown = true;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (requiredVariables.some((name) => !runner.variables?.includes(name)))
|
|
375
|
+
continue;
|
|
376
|
+
compatible.push(runner);
|
|
377
|
+
const held = await deps.slotsHeld(conn, runner.id);
|
|
378
|
+
const byTool = held.byTool ?? {};
|
|
379
|
+
const used = held.jobs + held.runs;
|
|
380
|
+
const directory = directoryKeyOf(runner.id, payloadDirs(assembly.dirs));
|
|
381
|
+
const blockedDirectory = directory !== null &&
|
|
382
|
+
(await directoryBusy(conn, runner.id, run.id, directory));
|
|
383
|
+
directoryBlocked ||= blockedDirectory;
|
|
384
|
+
const hasRoom = !runner.draining &&
|
|
385
|
+
(runner.globalFree ?? 1) > 0 &&
|
|
386
|
+
used < runner.slots &&
|
|
387
|
+
(byTool[entry.tool] ?? 0) < toolLimit(runner, entry.tool) &&
|
|
388
|
+
(runner.toolLoad?.[entry.tool]?.free ?? 1) > 0 &&
|
|
389
|
+
!blockedDirectory;
|
|
390
|
+
ready ||= hasRoom && runner.globalFree !== undefined;
|
|
391
|
+
if (hasRoom && runner.globalFree === undefined)
|
|
392
|
+
unknown = true;
|
|
393
|
+
loads.push({
|
|
394
|
+
name: runner.name,
|
|
395
|
+
ownerUserId: runner.ownerUserId,
|
|
396
|
+
reason: hasRoom
|
|
397
|
+
? runner.globalFree === undefined
|
|
398
|
+
? 'unknown'
|
|
399
|
+
: 'ready'
|
|
400
|
+
: runner.draining
|
|
401
|
+
? runner.draining
|
|
402
|
+
: blockedDirectory
|
|
403
|
+
? 'restricted'
|
|
404
|
+
: 'busy',
|
|
405
|
+
lastSeenAt: runner.lastSeenAt,
|
|
406
|
+
used,
|
|
407
|
+
limit: runner.slots,
|
|
408
|
+
toolUsed: byTool[entry.tool] ?? 0,
|
|
409
|
+
toolLimit: toolLimit(runner, entry.tool),
|
|
410
|
+
reportedFree: runner.toolLoad?.[entry.tool]?.free,
|
|
411
|
+
reportedTotalFree: runner.globalFree,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
let reason = compatible.length
|
|
415
|
+
? ready
|
|
416
|
+
? 'ready'
|
|
417
|
+
: 'busy'
|
|
418
|
+
: online.length
|
|
419
|
+
? incompatible
|
|
420
|
+
? 'incompatible'
|
|
421
|
+
: 'restricted'
|
|
422
|
+
: usable.length
|
|
423
|
+
? 'noSharedRunner'
|
|
424
|
+
: installed.length
|
|
425
|
+
? 'toolUnavailable'
|
|
426
|
+
: connected.length
|
|
427
|
+
? 'toolNotInstalled'
|
|
428
|
+
: 'offline';
|
|
429
|
+
if (directoryBlocked && !ready)
|
|
430
|
+
reason = 'restricted';
|
|
431
|
+
if (!ready &&
|
|
432
|
+
compatible.length > 0 &&
|
|
433
|
+
loads.every((runner) => runner.reason === 'updatePending' || runner.reason === 'pruning'))
|
|
434
|
+
reason = loads.some((runner) => runner.reason === 'updatePending')
|
|
435
|
+
? 'updatePending'
|
|
436
|
+
: 'pruning';
|
|
437
|
+
if (unknown &&
|
|
438
|
+
!ready &&
|
|
439
|
+
!loads.some((runner) => runner.reason === 'busy'))
|
|
440
|
+
reason = 'unknown';
|
|
441
|
+
if (compatible.length && sameWork)
|
|
442
|
+
reason = 'sameWorkActive';
|
|
443
|
+
else if (compatible.length && active >= agent.maxConcurrentRuns)
|
|
444
|
+
reason = 'concurrencyFull';
|
|
445
|
+
else if (start > now.getTime())
|
|
446
|
+
reason = 'delayed';
|
|
447
|
+
entries.push({
|
|
448
|
+
tool: entry.tool,
|
|
449
|
+
model: entry.model,
|
|
450
|
+
reason,
|
|
451
|
+
compatibleCount: compatible.length,
|
|
452
|
+
blockers: [
|
|
453
|
+
...(unknown ? ['unknown'] : []),
|
|
454
|
+
...new Set(loads
|
|
455
|
+
.map((runner) => runner.reason)
|
|
456
|
+
.filter((reason) => reason !== undefined && reason !== 'ready')),
|
|
457
|
+
],
|
|
458
|
+
runners: loads,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return {
|
|
462
|
+
queueEnteredAt: new Date(start).toISOString(),
|
|
463
|
+
fallbackAfterSeconds: policy?.fallbackAfterSeconds ?? 0,
|
|
464
|
+
sampledAt: now.toISOString(),
|
|
465
|
+
entries,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
async function assemble({ conn }, run, agent, runner, inputs, leaseExpiresAt, prepared, entry, resources = claimResources(conn, run.id)) {
|
|
256
469
|
const binding = deps.subjects.get(run.subjectKind);
|
|
257
470
|
if (!binding)
|
|
258
471
|
throw new Error(`No context provider is registered for subjects of kind "${run.subjectKind}".`);
|
|
@@ -264,9 +477,11 @@ export function createClaimService(deps) {
|
|
|
264
477
|
inputs,
|
|
265
478
|
cli: deps.cli.name,
|
|
266
479
|
appName: deps.app.name,
|
|
267
|
-
dialect: 'cli',
|
|
268
480
|
};
|
|
269
|
-
const assembly = await binding.context.assemble(conn, claim);
|
|
481
|
+
const assembly = await binding.context.assemble(conn, claim, prepared.get('subject'));
|
|
482
|
+
// workspace.key is required for coordinating runs; old runners must not silently ignore it.
|
|
483
|
+
if ((await assemblyCompatibility(conn, toRun(run), agent, runner, assembly, resources)) === 'incompatible')
|
|
484
|
+
throw new NotForThisRunner();
|
|
270
485
|
inputs = assembly.inputs ?? inputs;
|
|
271
486
|
const effectiveClaim = { ...claim, inputs };
|
|
272
487
|
// Its owner's local policy keeps this runner off the subject, or off one of the repositories: another runner takes
|
|
@@ -282,30 +497,29 @@ export function createClaimService(deps) {
|
|
|
282
497
|
if (directoryKey !== null &&
|
|
283
498
|
(await directoryBusy(conn, runner.id, run.id, directoryKey)))
|
|
284
499
|
throw new NotForThisRunner();
|
|
285
|
-
const skills = await
|
|
286
|
-
const
|
|
287
|
-
const names = await deps.variables.namesOf(conn, variables);
|
|
500
|
+
const { skills, variables } = await resources(agent, assembly);
|
|
501
|
+
const names = variables.names;
|
|
288
502
|
const requires = cleanList([
|
|
289
503
|
...view.requires,
|
|
290
|
-
...payloadRequires(dirs, skills.length, names.length),
|
|
504
|
+
...payloadRequires(dirs, skills.length, names.length, Boolean(assembly.workspaceKey)),
|
|
291
505
|
]);
|
|
292
506
|
if (!covers(runner.features, requires))
|
|
293
507
|
throw new NotForThisRunner();
|
|
294
508
|
// A variable for team runners only keeps a personal runner off the run.
|
|
295
509
|
if (names.length > 0 && runner.trust !== 'team') {
|
|
296
|
-
const teamOnly =
|
|
510
|
+
const teamOnly = variables.teamOnly;
|
|
297
511
|
if (teamOnly.length > 0)
|
|
298
512
|
throw new TeamRunnersOnly(teamOnly);
|
|
299
513
|
}
|
|
300
514
|
const env = names.length > 0
|
|
301
|
-
? await
|
|
515
|
+
? await variables.deliver({
|
|
302
516
|
runId: run.id,
|
|
303
517
|
runnerId: runner.id,
|
|
304
518
|
})
|
|
305
519
|
: [];
|
|
306
520
|
// Variables taken from the runner: names only. A runner that does not provide one fails the run while preparing
|
|
307
521
|
// it, saying how to provide it; runners are not chosen by them.
|
|
308
|
-
const passthrough =
|
|
522
|
+
const passthrough = variables.passthrough;
|
|
309
523
|
const nowText = clock.now().toISOString();
|
|
310
524
|
const clean = await consumeReset(conn, { kind: run.subjectKind, id: run.subjectId }, run.id, nowText);
|
|
311
525
|
const session = await sessionsRepo(conn).findOne({
|
|
@@ -352,6 +566,11 @@ export function createClaimService(deps) {
|
|
|
352
566
|
const sessionNote = resume ? assembly.turn.resumed : assembly.turn.fresh;
|
|
353
567
|
const turn = [
|
|
354
568
|
brief.turn,
|
|
569
|
+
...(toExecutions(run.executionHistory).find((execution) => execution.attempt === Number(run.attempt) - 1)?.failureReason === 'runnerUpgrade'
|
|
570
|
+
? [
|
|
571
|
+
'The previous attempt was interrupted by a runner upgrade. Continue from the current state.',
|
|
572
|
+
]
|
|
573
|
+
: []),
|
|
355
574
|
...resumeNotes,
|
|
356
575
|
...(sessionNote ? [sessionNote] : []),
|
|
357
576
|
].join('\n\n');
|
|
@@ -395,10 +614,13 @@ export function createClaimService(deps) {
|
|
|
395
614
|
},
|
|
396
615
|
inputs,
|
|
397
616
|
workspace: {
|
|
617
|
+
sessionScope: run.threadScope,
|
|
398
618
|
dirs,
|
|
399
619
|
env,
|
|
400
620
|
...(passthrough.length > 0 ? { passthrough } : {}),
|
|
401
621
|
...(clean ? { clean: true } : {}),
|
|
622
|
+
...(assembly.workspaceKey ? { key: assembly.workspaceKey } : {}),
|
|
623
|
+
...(assembly.readOnly ? { readOnly: true } : {}),
|
|
402
624
|
...(git ? { git } : {}),
|
|
403
625
|
},
|
|
404
626
|
skills,
|
|
@@ -465,18 +687,175 @@ export function createClaimService(deps) {
|
|
|
465
687
|
});
|
|
466
688
|
});
|
|
467
689
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
690
|
+
/** What reconciling a comment run would change, read without writing: most runs need nothing. */
|
|
691
|
+
async function planCommentConsent(conn, runId) {
|
|
692
|
+
const none = { kind: 'none' };
|
|
693
|
+
const run = await findRunRecord(conn, runId);
|
|
694
|
+
if (!run?.commentRootRunId)
|
|
695
|
+
return none;
|
|
696
|
+
const root = await findRunRecord(conn, run.commentRootRunId);
|
|
697
|
+
if (!root)
|
|
698
|
+
return none;
|
|
699
|
+
if (run.status !== 'queued') {
|
|
700
|
+
const pending = await runRequestsRepo(conn).findMany({
|
|
701
|
+
filter: {
|
|
702
|
+
commentRootRunId: root.id,
|
|
703
|
+
commentRunId: run.id,
|
|
704
|
+
purpose: 'personalRunner',
|
|
705
|
+
status: 'pending',
|
|
706
|
+
},
|
|
707
|
+
limit: 1,
|
|
708
|
+
});
|
|
709
|
+
return pending.length > 0 ? { kind: 'withdraw', rootId: root.id } : none;
|
|
710
|
+
}
|
|
711
|
+
if (!(await queuedIdentityCurrent(conn, deps, run)))
|
|
712
|
+
return { kind: 'refresh', run };
|
|
713
|
+
if (!(await currentCommentOwner(conn, deps.subjects, root)))
|
|
714
|
+
return {
|
|
715
|
+
kind: 'cancel',
|
|
716
|
+
run,
|
|
717
|
+
detail: 'The comment belongs to an earlier owner assignment.',
|
|
718
|
+
};
|
|
719
|
+
if (root.commentExecution === 'requester' ||
|
|
720
|
+
run.actorUserId !== root.ownerUserId)
|
|
721
|
+
return none;
|
|
722
|
+
const { decision } = await commentConsent(conn, root);
|
|
723
|
+
if (decision === 'confirmed' || decision === 'pending')
|
|
724
|
+
return none;
|
|
725
|
+
if (await commentFromOwner(conn, root))
|
|
726
|
+
return none;
|
|
727
|
+
if (decision === 'rejected')
|
|
728
|
+
return {
|
|
729
|
+
kind: 'cancel',
|
|
730
|
+
run,
|
|
731
|
+
detail: 'The comment personal runner authorization is no longer valid.',
|
|
732
|
+
};
|
|
733
|
+
const agent = await findAgent(conn, run.agentId);
|
|
734
|
+
if (!agent)
|
|
735
|
+
return none;
|
|
736
|
+
const team = await selectionFacts(conn, toRun(run), agent, false, 'team');
|
|
737
|
+
if (!team ||
|
|
738
|
+
team.entries.some((e) => e.compatibleCount > 0 ||
|
|
739
|
+
e.reason === 'unknown' ||
|
|
740
|
+
e.blockers?.includes('unknown')))
|
|
741
|
+
return none;
|
|
742
|
+
const personal = await selectionFacts(conn, toRun(run), agent, false, 'personal');
|
|
743
|
+
if (!personal?.entries.some((e) => e.compatibleCount > 0))
|
|
744
|
+
return none;
|
|
745
|
+
const sourceInputs = await inputsRepo(conn).findMany({
|
|
746
|
+
filter: { runId: root.id },
|
|
747
|
+
sort: (sort) => [sort.field('createdAt').asc(), sort.field('id').asc()],
|
|
748
|
+
});
|
|
749
|
+
const input = sourceInputs.find((input) => input.type === 'comment' &&
|
|
750
|
+
jsonObject(input.payload).commentSourceSnapshot === true) ?? sourceInputs.find((input) => input.type === 'comment');
|
|
751
|
+
return input ? { kind: 'request', run, root, input } : none;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Brings a comment run's consent up to date. It takes no lock of its own: callers that may create a request hold
|
|
755
|
+
* the run's agent row (enqueue, retry and the sweeper do), which serializes the duplicate check in insertRunRequest
|
|
756
|
+
* with every other enqueue and claim of that agent. Everything else is a guarded update.
|
|
757
|
+
*/
|
|
758
|
+
async function reconcileCommentConsent(unit, runId) {
|
|
759
|
+
let plan = await planCommentConsent(unit.conn, runId);
|
|
760
|
+
if (plan.kind === 'refresh') {
|
|
761
|
+
if (!(await refreshQueuedIdentity(unit, deps, plan.run)))
|
|
762
|
+
return;
|
|
763
|
+
plan = await planCommentConsent(unit.conn, runId);
|
|
764
|
+
}
|
|
765
|
+
switch (plan.kind) {
|
|
766
|
+
case 'withdraw':
|
|
767
|
+
await withdrawCommentRequests(unit, plan.rootId, clock.now().toISOString(), runId);
|
|
768
|
+
return;
|
|
769
|
+
case 'cancel':
|
|
770
|
+
await finishRun(unit, deps, plan.run, {
|
|
771
|
+
status: 'cancelled',
|
|
772
|
+
reason: null,
|
|
773
|
+
detail: plan.detail,
|
|
774
|
+
});
|
|
775
|
+
return;
|
|
776
|
+
case 'request': {
|
|
777
|
+
const { run, root, input } = plan;
|
|
778
|
+
await insertRunRequest(unit, deps, {
|
|
779
|
+
purpose: 'personalRunner',
|
|
780
|
+
commentRootRunId: root.id,
|
|
781
|
+
commentRunId: run.id,
|
|
782
|
+
commentOwnerKey: root.commentOwnerKey ?? null,
|
|
783
|
+
agentId: run.agentId,
|
|
784
|
+
subject: toRun(run).subject,
|
|
785
|
+
threadScope: run.threadScope,
|
|
786
|
+
// The plan only asks for runs acting as the chain's owner.
|
|
787
|
+
responsibleUserId: run.actorUserId,
|
|
788
|
+
requestedByUserId: root.requestedByUserId ?? root.actorUserId,
|
|
789
|
+
ownerUserId: run.actorUserId,
|
|
790
|
+
priority: Number(run.priority),
|
|
791
|
+
requires: toRun(run).requires,
|
|
792
|
+
fireAt: run.availableAt,
|
|
793
|
+
maxAttempts: Number(run.maxAttempts),
|
|
794
|
+
input: toInput(input),
|
|
795
|
+
});
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
default:
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Whether this runner may take this candidate under comment consent, read outside any transaction. Immutable facts
|
|
804
|
+
* settle most candidates without a query: no comment chain, work run as the commenter, or work not run as the
|
|
805
|
+
* chain's owner. The rest read the chain's requests once. A decision never needs a lock: confirmation is final,
|
|
806
|
+
* and rejection or Run as me end the chain's queued runs, which the claim's guarded `status = 'queued'` update sees.
|
|
807
|
+
*/
|
|
808
|
+
async function commentConsentFor(conn, runner, run) {
|
|
809
|
+
const allowed = { allowed: true, confirmedByUserId: null };
|
|
810
|
+
const refused = { allowed: false, confirmedByUserId: null };
|
|
811
|
+
if (!run.commentRootRunId || run.commentExecution === 'requester')
|
|
812
|
+
return allowed;
|
|
813
|
+
const root = await findRunRecord(conn, run.commentRootRunId);
|
|
814
|
+
if (!root || root.commentRootRunId !== root.id)
|
|
815
|
+
return refused;
|
|
816
|
+
if (root.commentExecution === 'requester' ||
|
|
817
|
+
run.actorUserId !== root.ownerUserId)
|
|
818
|
+
return allowed;
|
|
819
|
+
const { decision, confirmation } = await commentConsent(conn, root);
|
|
820
|
+
if (decision === 'rejected')
|
|
821
|
+
return refused;
|
|
822
|
+
if (decision === 'confirmed')
|
|
823
|
+
return {
|
|
824
|
+
allowed: true,
|
|
825
|
+
confirmedByUserId: confirmation?.settledById ?? null,
|
|
826
|
+
};
|
|
827
|
+
if (runner.trust === 'team')
|
|
828
|
+
return allowed;
|
|
829
|
+
return (await commentFromOwner(conn, root)) ? allowed : refused;
|
|
830
|
+
}
|
|
831
|
+
/** Withdraws the request a team claim made obsolete, writing only when one is pending. */
|
|
832
|
+
async function withdrawIfPending(rootId, runId) {
|
|
833
|
+
try {
|
|
834
|
+
const pending = await runRequestsRepo(tx.read()).findMany({
|
|
835
|
+
filter: {
|
|
836
|
+
commentRootRunId: rootId,
|
|
837
|
+
commentRunId: runId,
|
|
838
|
+
purpose: 'personalRunner',
|
|
839
|
+
status: 'pending',
|
|
840
|
+
},
|
|
841
|
+
limit: 1,
|
|
842
|
+
});
|
|
843
|
+
if (pending.length > 0)
|
|
844
|
+
await tx.run((unit) => withdrawCommentRequests(unit, rootId, clock.now().toISOString(), runId));
|
|
845
|
+
}
|
|
846
|
+
catch (error) {
|
|
847
|
+
deps.onClaimFailure?.(runId, error);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
async function admit(unit, run, agent, runner, inputs, prepared) {
|
|
851
|
+
const rejection = await deps.subjects.get(run.subjectKind)?.context.admit?.(unit.conn, {
|
|
472
852
|
run: toRun(run),
|
|
473
853
|
agent,
|
|
474
854
|
runner,
|
|
475
855
|
inputs,
|
|
476
856
|
cli: deps.cli.name,
|
|
477
857
|
appName: deps.app.name,
|
|
478
|
-
|
|
479
|
-
});
|
|
858
|
+
}, prepared);
|
|
480
859
|
if (!rejection)
|
|
481
860
|
return true;
|
|
482
861
|
await finishRun(unit, deps, run, {
|
|
@@ -487,62 +866,144 @@ export function createClaimService(deps) {
|
|
|
487
866
|
return false;
|
|
488
867
|
}
|
|
489
868
|
async function attempt(runner, agent, candidate, reported) {
|
|
490
|
-
// Avoid assembling or asking authorization when a cheap claim rule already rules this work out.
|
|
491
869
|
const conn = tx.read();
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
870
|
+
// Rules that do not depend on who the run acts as come first, and settle the rest of the pass: an agent at its
|
|
871
|
+
// limit is checked once per poll, not once per queued run.
|
|
872
|
+
if ((await countActive(conn, 'agentId', agent.id)) >= agent.maxConcurrentRuns)
|
|
873
|
+
return { kind: 'full', scope: 'agent' };
|
|
874
|
+
// Repair pre-upgrade queued work before even checking personal runner ownership. Reading first keeps a poll over
|
|
875
|
+
// current work free of transactions and row locks; only work whose identity changed is written.
|
|
876
|
+
if (deps.subjects.get(candidate.subjectKind)?.actsAs &&
|
|
877
|
+
!(await queuedIdentityCurrent(conn, deps, candidate))) {
|
|
878
|
+
const current = await tx.run(async (unit) => {
|
|
879
|
+
await lockAgentForClaim(unit.conn, agent.id, clock.now().toISOString());
|
|
880
|
+
const run = await findRunRecord(unit.conn, candidate.id);
|
|
881
|
+
return run?.status === 'queued'
|
|
882
|
+
? refreshQueuedIdentity(unit, deps, run)
|
|
883
|
+
: null;
|
|
884
|
+
});
|
|
885
|
+
if (!current)
|
|
886
|
+
return { kind: 'skipped' };
|
|
887
|
+
candidate = current;
|
|
888
|
+
}
|
|
889
|
+
// Avoid assembling or asking authorization when a cheap claim rule already rules this work out.
|
|
890
|
+
if (!fits(runner, agent, candidate, clock.now().getTime()) ||
|
|
496
891
|
(await runsOfKey(conn, candidate, ACTIVE)).length > 0)
|
|
497
892
|
return { kind: 'skipped' };
|
|
893
|
+
const consent = await commentConsentFor(conn, runner, candidate);
|
|
894
|
+
if (!consent.allowed)
|
|
895
|
+
return { kind: 'skipped' };
|
|
498
896
|
// Before the transaction: on SQLite it holds the only connection, so the providers read what else they need now.
|
|
499
|
-
const prepared = await prepareExtensions(toRun(candidate), deps.sections, deps.mounts, (error) => deps.onClaimFailure?.(candidate.id, error), deps.repoAccess, { onDemand: asksCredentialsOnDemand(runner) });
|
|
897
|
+
const prepared = new Map(await prepareExtensions(toRun(candidate), deps.sections, deps.mounts, (error) => deps.onClaimFailure?.(candidate.id, error), deps.repoAccess, { onDemand: asksCredentialsOnDemand(runner) }));
|
|
898
|
+
const subjectContext = deps.subjects.get(candidate.subjectKind)?.context;
|
|
899
|
+
if (subjectContext?.prepare) {
|
|
900
|
+
try {
|
|
901
|
+
prepared.set('subject', await subjectContext.prepare(toRun(candidate)));
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
deps.onClaimFailure?.(candidate.id, error);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
500
907
|
let taken;
|
|
908
|
+
let runnerFull = false;
|
|
501
909
|
try {
|
|
502
910
|
taken = await tx.run(async (unit) => {
|
|
503
911
|
const { conn } = unit;
|
|
504
912
|
const now = clock.now();
|
|
505
913
|
const nowText = now.toISOString();
|
|
506
914
|
await lockAgentForClaim(conn, agent.id, nowText);
|
|
915
|
+
const queuedRun = await findRunRecord(conn, candidate.id);
|
|
916
|
+
if (!queuedRun || queuedRun.status !== 'queued')
|
|
917
|
+
return null;
|
|
918
|
+
const identity = await refreshQueuedIdentity(unit, deps, queuedRun);
|
|
919
|
+
// Providers were prepared for the candidate's identity outside this transaction.
|
|
920
|
+
if (!identity || identity.actorUserId !== candidate.actorUserId)
|
|
921
|
+
return null;
|
|
507
922
|
if ((await countActive(conn, 'agentId', agent.id)) >=
|
|
508
923
|
agent.maxConcurrentRuns)
|
|
509
924
|
return null;
|
|
510
925
|
// Slots are shared with the jobs the runner holds.
|
|
511
|
-
|
|
926
|
+
const held = await deps.slotsHeld(conn, runner.id);
|
|
927
|
+
if (held.runs + held.jobs >= runner.slots) {
|
|
928
|
+
runnerFull = true;
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
// Total and per-tool room come from the same locked snapshot.
|
|
932
|
+
const byTool = held.byTool ?? {};
|
|
933
|
+
const current = identity;
|
|
934
|
+
if (!current ||
|
|
935
|
+
current.status !== 'queued' ||
|
|
936
|
+
(current.availableAt &&
|
|
937
|
+
new Date(current.availableAt).getTime() > now.getTime()))
|
|
512
938
|
return null;
|
|
513
|
-
|
|
514
|
-
const byTool = await runsHeldByTool(conn, runner.id);
|
|
515
|
-
const entry = pickOpenEntry(runner, agent, (tool) => (byTool[tool] ?? 0) < toolLimit(runner, tool) && reported.has(tool));
|
|
939
|
+
const entry = pickOpenEntry(runner, agent, (tool) => (byTool[tool] ?? 0) < toolLimit(runner, tool) && reported.has(tool), now.getTime());
|
|
516
940
|
if (!entry)
|
|
517
941
|
return null;
|
|
518
942
|
const busy = await runsOfKey(conn, candidate, ACTIVE);
|
|
519
943
|
if (busy.length > 0)
|
|
520
944
|
return null;
|
|
521
|
-
const leaseExpiresAt = later(now, TIMINGS.
|
|
945
|
+
const leaseExpiresAt = later(now, TIMINGS.startTimeoutMs);
|
|
946
|
+
const dispatchValues = {
|
|
947
|
+
status: 'dispatched',
|
|
948
|
+
failureReason: null,
|
|
949
|
+
failureDetail: null,
|
|
950
|
+
runnerId: runner.id,
|
|
951
|
+
// Brief providers observe this reservation inside the claim transaction.
|
|
952
|
+
// Replace a previous attempt's tool before computing the roster.
|
|
953
|
+
tool: entry.tool,
|
|
954
|
+
leaseExpiresAt,
|
|
955
|
+
dispatchedAt: nowText,
|
|
956
|
+
lastActivityAt: nowText,
|
|
957
|
+
availableAt: null,
|
|
958
|
+
updatedAt: nowText,
|
|
959
|
+
...(consent.confirmedByUserId
|
|
960
|
+
? { confirmedByUserId: consent.confirmedByUserId }
|
|
961
|
+
: {}),
|
|
962
|
+
};
|
|
522
963
|
const claimed = await runsRepo(conn).updateMany({
|
|
523
964
|
filter: (f) => f.and([
|
|
524
965
|
f.string('id').eq(candidate.id),
|
|
525
966
|
f.string('status').eq('queued'),
|
|
967
|
+
f.string('actorUserId').eq(candidate.actorUserId),
|
|
526
968
|
]),
|
|
527
|
-
values:
|
|
528
|
-
status: 'dispatched',
|
|
529
|
-
runnerId: runner.id,
|
|
530
|
-
leaseExpiresAt,
|
|
531
|
-
dispatchedAt: nowText,
|
|
532
|
-
lastActivityAt: nowText,
|
|
533
|
-
availableAt: null,
|
|
534
|
-
updatedAt: nowText,
|
|
535
|
-
},
|
|
969
|
+
values: dispatchValues,
|
|
536
970
|
});
|
|
537
971
|
if (claimed.updatedCount !== 1)
|
|
538
972
|
return null;
|
|
539
|
-
const run =
|
|
540
|
-
const pending = await pendingInputs(conn, run.id)
|
|
973
|
+
const run = { ...current, ...dispatchValues };
|
|
974
|
+
const pending = (await pendingInputs(conn, run.id)).filter((input) => !run.commentRootRunId ||
|
|
975
|
+
input.type !== 'comment' ||
|
|
976
|
+
jsonObject(input.payload).commentRootRunId === run.commentRootRunId);
|
|
541
977
|
let assembled;
|
|
978
|
+
let selectionSnapshot;
|
|
542
979
|
try {
|
|
543
|
-
if (!(await admit(unit, run, agent, runner, pending.map(toInput))))
|
|
980
|
+
if (!(await admit(unit, run, agent, runner, pending.map(toInput), prepared.get('subject'))))
|
|
544
981
|
return null;
|
|
545
|
-
|
|
982
|
+
// Admission must precede preflight assembly: a missing or obsolete
|
|
983
|
+
// subject is cancelled normally, rather than counted as setup failure.
|
|
984
|
+
const resources = claimResources(conn, run.id);
|
|
985
|
+
const selection = await selectionFacts(conn, toRun(current), agent, true, undefined, resources);
|
|
986
|
+
const elapsed = Math.max(0, (now.getTime() - queueStart(toRun(current))) / 1000);
|
|
987
|
+
const preferredAvailable = (selection?.entries[0]?.compatibleCount ?? 0) > 0 ||
|
|
988
|
+
selection?.entries[0]?.reason === 'unknown' ||
|
|
989
|
+
selection?.entries[0]?.blockers?.includes('unknown') === true;
|
|
990
|
+
const chosenIndex = agent.modelEntries.indexOf(entry);
|
|
991
|
+
if (selection && chosenIndex > 0) {
|
|
992
|
+
// Throw to roll back the provisional dispatch; the original run keeps
|
|
993
|
+
// waiting for its first choice without consuming an attempt or token.
|
|
994
|
+
if (preferredAvailable && elapsed < selection.fallbackAfterSeconds)
|
|
995
|
+
throw new NotForThisRunner();
|
|
996
|
+
selectionSnapshot = {
|
|
997
|
+
reason: preferredAvailable
|
|
998
|
+
? 'preferredQueued'
|
|
999
|
+
: 'preferredUnavailable',
|
|
1000
|
+
preferredTool: agent.modelEntries[0].tool,
|
|
1001
|
+
preferredModel: agent.modelEntries[0].model,
|
|
1002
|
+
queueEnteredAt: selection.queueEnteredAt,
|
|
1003
|
+
waitedSeconds: elapsed,
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
assembled = await assemble(unit, run, agent, runner, pending.map(toInput), leaseExpiresAt, prepared, entry, resources);
|
|
546
1007
|
}
|
|
547
1008
|
catch (error) {
|
|
548
1009
|
if (error instanceof NotForThisRunner)
|
|
@@ -558,6 +1019,7 @@ export function createClaimService(deps) {
|
|
|
558
1019
|
directoryKey: assembled.directoryKey,
|
|
559
1020
|
tool: assembled.entry.tool,
|
|
560
1021
|
executionHistory: executionHistory(run, {
|
|
1022
|
+
...(selectionSnapshot ? { selection: selectionSnapshot } : {}),
|
|
561
1023
|
attempt: Number(run.attempt),
|
|
562
1024
|
runnerId: runner.id,
|
|
563
1025
|
runnerName: runner.name,
|
|
@@ -608,8 +1070,15 @@ export function createClaimService(deps) {
|
|
|
608
1070
|
}
|
|
609
1071
|
if (!taken) {
|
|
610
1072
|
await discardRepoAccess(candidate, prepared);
|
|
611
|
-
return
|
|
1073
|
+
return runnerFull
|
|
1074
|
+
? { kind: 'full', scope: 'runner' }
|
|
1075
|
+
: { kind: 'skipped' };
|
|
612
1076
|
}
|
|
1077
|
+
// After the claim commits, never inside it: decisions settle the request before touching runs, so a claim that
|
|
1078
|
+
// held its run while waiting for the request could deadlock with them. A request left pending by a crash here is
|
|
1079
|
+
// withdrawn by the next reconciliation, and confirming it finds the run no longer waiting.
|
|
1080
|
+
if (candidate.commentRootRunId && runner.trust === 'team')
|
|
1081
|
+
await withdrawIfPending(candidate.commentRootRunId, candidate.id);
|
|
613
1082
|
return { kind: 'claimed', payload: taken };
|
|
614
1083
|
}
|
|
615
1084
|
async function discardRepoAccess(run, prepared) {
|
|
@@ -642,20 +1111,18 @@ export function createClaimService(deps) {
|
|
|
642
1111
|
filter: { id: runId },
|
|
643
1112
|
values: {
|
|
644
1113
|
claimFailures: failures,
|
|
1114
|
+
failureReason: 'setupFailed',
|
|
645
1115
|
failureDetail: error.message.slice(0, 10_000),
|
|
646
1116
|
},
|
|
647
1117
|
});
|
|
648
1118
|
});
|
|
649
1119
|
}
|
|
650
|
-
/** Queued runs
|
|
651
|
-
async function
|
|
1120
|
+
/** Queued runs that may be claimed now, in claim order. */
|
|
1121
|
+
async function candidates() {
|
|
652
1122
|
const now = clock.now();
|
|
653
1123
|
return runsRepo(tx.read()).findMany({
|
|
654
1124
|
filter: (f) => f.and([
|
|
655
1125
|
f.string('status').eq('queued'),
|
|
656
|
-
f.string('agentType').eq(type),
|
|
657
|
-
// A consultation is taken by the holder of the run that asked it, never from the queue.
|
|
658
|
-
f.string('parentRunId').empty(),
|
|
659
1126
|
f.or([
|
|
660
1127
|
f.date('availableAt').empty(),
|
|
661
1128
|
f.date('availableAt').notAfter(now),
|
|
@@ -669,180 +1136,38 @@ export function createClaimService(deps) {
|
|
|
669
1136
|
limit: CANDIDATES,
|
|
670
1137
|
});
|
|
671
1138
|
}
|
|
672
|
-
/** Takes an online run for `holder` in one transaction, or skips it when another holder or run got there first. */
|
|
673
|
-
async function attemptServer(holder, agent, candidate) {
|
|
674
|
-
const prepared = await prepareExtensions(toRun(candidate), deps.sections, undefined, (error) => deps.onClaimFailure?.(candidate.id, error));
|
|
675
|
-
return tx.run(async (unit) => {
|
|
676
|
-
const { conn } = unit;
|
|
677
|
-
const now = clock.now();
|
|
678
|
-
const nowText = now.toISOString();
|
|
679
|
-
// Serializes claims and enqueues of this agent, so one key never has two runs held.
|
|
680
|
-
await lockAgentForClaim(conn, agent.id, nowText);
|
|
681
|
-
if ((await runsOfKey(conn, candidate, ACTIVE)).length > 0)
|
|
682
|
-
return null;
|
|
683
|
-
const leaseExpiresAt = later(now, TIMINGS.leaseMs);
|
|
684
|
-
const taken = await runsRepo(conn).updateMany({
|
|
685
|
-
filter: (f) => f.and([
|
|
686
|
-
f.string('id').eq(candidate.id),
|
|
687
|
-
f.string('status').eq('queued'),
|
|
688
|
-
]),
|
|
689
|
-
values: {
|
|
690
|
-
status: 'dispatched',
|
|
691
|
-
runnerId: holder.id,
|
|
692
|
-
leaseExpiresAt,
|
|
693
|
-
dispatchedAt: nowText,
|
|
694
|
-
lastActivityAt: nowText,
|
|
695
|
-
availableAt: null,
|
|
696
|
-
updatedAt: nowText,
|
|
697
|
-
},
|
|
698
|
-
});
|
|
699
|
-
if (taken.updatedCount !== 1)
|
|
700
|
-
return null;
|
|
701
|
-
const run = (await findRunRecord(conn, candidate.id));
|
|
702
|
-
const pending = await pendingInputs(conn, run.id);
|
|
703
|
-
const inputs = pending.map(toInput);
|
|
704
|
-
let claimed;
|
|
705
|
-
try {
|
|
706
|
-
if (!(await admit(unit, run, agent, null, inputs)))
|
|
707
|
-
return null;
|
|
708
|
-
claimed = await assembleServer(unit, run, agent, holder, inputs, leaseExpiresAt, prepared);
|
|
709
|
-
}
|
|
710
|
-
catch (error) {
|
|
711
|
-
throw new AssemblyError(error instanceof Error ? error.message : String(error), error);
|
|
712
|
-
}
|
|
713
|
-
await settleClaimInputs(conn, pending, claimed.inputs, nowText);
|
|
714
|
-
await runsRepo(conn).updateMany({
|
|
715
|
-
filter: { id: run.id },
|
|
716
|
-
values: {
|
|
717
|
-
tool: null,
|
|
718
|
-
executionHistory: executionHistory(run, {
|
|
719
|
-
attempt: Number(run.attempt),
|
|
720
|
-
runnerId: holder.id,
|
|
721
|
-
runnerName: null,
|
|
722
|
-
runnerOwnerUserId: null,
|
|
723
|
-
runnerOwnerName: null,
|
|
724
|
-
runnerTrust: null,
|
|
725
|
-
tool: null,
|
|
726
|
-
toolVersion: null,
|
|
727
|
-
modelService: claimed.model?.modelService ?? null,
|
|
728
|
-
model: claimed.model?.model ?? null,
|
|
729
|
-
actualModels: [],
|
|
730
|
-
effort: claimed.model?.effort ?? null,
|
|
731
|
-
dispatchedAt: nowText,
|
|
732
|
-
finishedAt: null,
|
|
733
|
-
failureReason: null,
|
|
734
|
-
}),
|
|
735
|
-
modelService: claimed.model?.modelService ?? null,
|
|
736
|
-
model: claimed.model?.model ?? null,
|
|
737
|
-
effort: claimed.model?.effort ?? null,
|
|
738
|
-
},
|
|
739
|
-
});
|
|
740
|
-
unit.emit({ type: 'run.changed', runId: run.id, status: 'dispatched' });
|
|
741
|
-
return {
|
|
742
|
-
...claimed,
|
|
743
|
-
run: {
|
|
744
|
-
...claimed.run,
|
|
745
|
-
tool: null,
|
|
746
|
-
modelService: claimed.model?.modelService ?? null,
|
|
747
|
-
model: claimed.model?.model ?? null,
|
|
748
|
-
effort: claimed.model?.effort ?? null,
|
|
749
|
-
},
|
|
750
|
-
};
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
async function assembleServer({ conn }, run, agent, holder, inputs, leaseExpiresAt, prepared) {
|
|
754
|
-
const binding = deps.subjects.get(run.subjectKind);
|
|
755
|
-
if (!binding)
|
|
756
|
-
throw new Error(`No context provider is registered for subjects of kind "${run.subjectKind}".`);
|
|
757
|
-
const view = toRun(run);
|
|
758
|
-
const claim = {
|
|
759
|
-
run: view,
|
|
760
|
-
agent,
|
|
761
|
-
runner: null,
|
|
762
|
-
inputs,
|
|
763
|
-
cli: deps.cli.name,
|
|
764
|
-
appName: deps.app.name,
|
|
765
|
-
dialect: 'tools',
|
|
766
|
-
};
|
|
767
|
-
const assembly = await binding.context.assemble(conn, claim);
|
|
768
|
-
inputs = assembly.inputs ?? inputs;
|
|
769
|
-
const effectiveClaim = { ...claim, inputs };
|
|
770
|
-
if (assembly.dirs.length > 0)
|
|
771
|
-
throw new Error('An online agent has no working directory, and this work needs one.');
|
|
772
|
-
const skills = await deps.skills.forRun(conn, skillTargets(agent, assembly), run.id);
|
|
773
|
-
const own = new Set(skills.map((skill) => skill.slug));
|
|
774
|
-
const rendered = briefOf(agent, await withSections(conn, deps.sections, effectiveClaim, assembly, prepared), [], deps.cli.name, deps.app.name);
|
|
775
|
-
// The skills an online run reads through its tools, and the agents it may consult, whatever system layer its
|
|
776
|
-
// subject gives it.
|
|
777
|
-
const consultable = (await deps.consultations?.targets(conn, run, agent)) ?? [];
|
|
778
|
-
const depth = run.parentRunId
|
|
779
|
-
? ((await deps.consultations?.chain(conn, run))?.length ?? 1) - 1
|
|
780
|
-
: 0;
|
|
781
|
-
const section = [
|
|
782
|
-
...onlineSkillsSection([
|
|
783
|
-
...skills,
|
|
784
|
-
...(deps.onlineSkills?.() ?? []).filter((skill) => !own.has(skill.slug)),
|
|
785
|
-
]),
|
|
786
|
-
...(consultable.length > 0 ? ['', ...consultSection(consultable)] : []),
|
|
787
|
-
];
|
|
788
|
-
const layers = section.length > 0
|
|
789
|
-
? {
|
|
790
|
-
...rendered.layers,
|
|
791
|
-
system: [rendered.layers.system, '', ...section].join('\n'),
|
|
792
|
-
}
|
|
793
|
-
: rendered.layers;
|
|
794
|
-
const brief = { ...rendered, layers, prompt: joinBrief(layers) };
|
|
795
|
-
const token = await mintRunToken(conn, deps, run, holder.id);
|
|
796
|
-
deps.secrets?.remember(runSecretsKey(run.id), [token.value]);
|
|
797
|
-
const last = await eventsRepo(conn).findOne({
|
|
798
|
-
filter: { runId: run.id },
|
|
799
|
-
sort: (sort) => sort.field('seq').desc(),
|
|
800
|
-
});
|
|
801
|
-
await saveBrief(conn, () => deps.ids.next(), {
|
|
802
|
-
runId: run.id,
|
|
803
|
-
attempt: Number(run.attempt),
|
|
804
|
-
layers: brief.layers,
|
|
805
|
-
turn: brief.turn,
|
|
806
|
-
prompt: brief.prompt,
|
|
807
|
-
createdAt: clock.now().toISOString(),
|
|
808
|
-
});
|
|
809
|
-
return {
|
|
810
|
-
runId: run.id,
|
|
811
|
-
attempt: Number(run.attempt),
|
|
812
|
-
agent,
|
|
813
|
-
run: view,
|
|
814
|
-
model: onlineEntryOf(agent, assembly.model, (await deps.defaultModel?.(conn)) ?? null),
|
|
815
|
-
system: brief.prompt,
|
|
816
|
-
turn: brief.turn,
|
|
817
|
-
inputs,
|
|
818
|
-
token: token.value,
|
|
819
|
-
skills,
|
|
820
|
-
leaseExpiresAt,
|
|
821
|
-
firstSeq: (last ? Number(last.seq) : 0) + 1,
|
|
822
|
-
consultable,
|
|
823
|
-
depth,
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
1139
|
async function claimOne(runner, seen, reported) {
|
|
1140
|
+
if (runner.draining)
|
|
1141
|
+
return null;
|
|
827
1142
|
const conn = tx.read();
|
|
828
|
-
const
|
|
829
|
-
const agents =
|
|
830
|
-
|
|
831
|
-
|
|
1143
|
+
const queued = await candidates();
|
|
1144
|
+
const agents = await findAgents(conn, queued
|
|
1145
|
+
.filter((candidate) => !seen.has(candidate.id))
|
|
1146
|
+
.map((candidate) => candidate.agentId));
|
|
1147
|
+
const full = new Set();
|
|
1148
|
+
for (const candidate of queued) {
|
|
1149
|
+
if (seen.has(candidate.id) || full.has(candidate.agentId))
|
|
832
1150
|
continue;
|
|
833
1151
|
seen.add(candidate.id);
|
|
834
|
-
if (!agents.has(candidate.agentId))
|
|
835
|
-
agents.set(candidate.agentId, await findAgent(conn, candidate.agentId));
|
|
836
1152
|
const agent = agents.get(candidate.agentId);
|
|
837
|
-
if (!agent ||
|
|
1153
|
+
if (!agent ||
|
|
1154
|
+
(!deps.subjects.get(candidate.subjectKind)?.actsAs &&
|
|
1155
|
+
!fits(runner, agent, candidate, clock.now().getTime())))
|
|
838
1156
|
continue;
|
|
839
1157
|
// None of its tools has room on the runner's side: the runs behind it may still fit.
|
|
840
|
-
if (!pickOpenEntry(runner, agent, (tool) => reported.has(tool)))
|
|
1158
|
+
if (!pickOpenEntry(runner, agent, (tool) => reported.has(tool), clock.now().getTime()))
|
|
841
1159
|
continue;
|
|
842
1160
|
try {
|
|
843
1161
|
const result = await attempt(runner, agent, candidate, reported);
|
|
844
1162
|
if (result.kind === 'claimed')
|
|
845
1163
|
return result.payload;
|
|
1164
|
+
if (result.kind === 'full') {
|
|
1165
|
+
if (result.scope === 'runner')
|
|
1166
|
+
return null;
|
|
1167
|
+
// Seen candidates are passed over for good in this claim; unvisited ones stay eligible for the next pass.
|
|
1168
|
+
seen.delete(candidate.id);
|
|
1169
|
+
full.add(candidate.agentId);
|
|
1170
|
+
}
|
|
846
1171
|
}
|
|
847
1172
|
catch (error) {
|
|
848
1173
|
// Rolled back: the run stays queued for a runner it fits.
|
|
@@ -856,16 +1181,57 @@ export function createClaimService(deps) {
|
|
|
856
1181
|
return null;
|
|
857
1182
|
}
|
|
858
1183
|
return {
|
|
1184
|
+
reconcileCommentConsent,
|
|
1185
|
+
async reconcileCommentQueue() {
|
|
1186
|
+
const conn = tx.read();
|
|
1187
|
+
const queued = await runsRepo(conn).findMany({
|
|
1188
|
+
filter: (f) => f.and([
|
|
1189
|
+
f.string('status').eq('queued'),
|
|
1190
|
+
f.string('commentRootRunId').notEmpty(),
|
|
1191
|
+
]),
|
|
1192
|
+
sort: (s) => [s.field('createdAt').asc()],
|
|
1193
|
+
limit: 100,
|
|
1194
|
+
});
|
|
1195
|
+
const pending = await runRequestsRepo(conn).findMany({
|
|
1196
|
+
filter: { purpose: 'personalRunner', status: 'pending' },
|
|
1197
|
+
limit: 100,
|
|
1198
|
+
});
|
|
1199
|
+
for (const id of new Set([
|
|
1200
|
+
...queued.map((run) => run.id),
|
|
1201
|
+
...pending
|
|
1202
|
+
.map((request) => request.commentRunId)
|
|
1203
|
+
.filter((id) => Boolean(id)),
|
|
1204
|
+
])) {
|
|
1205
|
+
// Read first: a sweep over settled chains opens no transaction at all.
|
|
1206
|
+
const plan = await planCommentConsent(conn, id);
|
|
1207
|
+
if (plan.kind === 'none')
|
|
1208
|
+
continue;
|
|
1209
|
+
await tx.run(async (unit) => {
|
|
1210
|
+
if (plan.kind === 'request' || plan.kind === 'refresh')
|
|
1211
|
+
await lockAgentForClaim(unit.conn, plan.run.agentId, clock.now().toISOString());
|
|
1212
|
+
await reconcileCommentConsent(unit, id);
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
diagnose: (conn, run, agent) => selectionFacts(conn, run, agent, false),
|
|
1217
|
+
async selectionWait(runId) {
|
|
1218
|
+
const conn = tx.read();
|
|
1219
|
+
const run = await findRunRecord(conn, runId);
|
|
1220
|
+
if (!run || run.status !== 'queued')
|
|
1221
|
+
return null;
|
|
1222
|
+
const agent = await findAgent(conn, run.agentId);
|
|
1223
|
+
return agent ? selectionFacts(conn, toRun(run), agent, false) : null;
|
|
1224
|
+
},
|
|
859
1225
|
async claim(runner, free, tools) {
|
|
860
|
-
if (runner.status !== 'online')
|
|
861
|
-
return [];
|
|
862
|
-
if ((await deps.slotsUsed(tx.read(), runner.id)) >= runner.slots)
|
|
1226
|
+
if (runner.status !== 'online' || runnerLowOnDisk(runner))
|
|
863
1227
|
return [];
|
|
864
1228
|
const payloads = [];
|
|
865
1229
|
const seen = new Set();
|
|
866
1230
|
const limit = Math.min(free, runner.slots);
|
|
867
1231
|
const reported = toolRoom(tools);
|
|
868
1232
|
while (payloads.length < limit) {
|
|
1233
|
+
if ((await deps.slotsUsed(tx.read(), runner.id)) >= runner.slots)
|
|
1234
|
+
break;
|
|
869
1235
|
const payload = await claimOne(runner, seen, reported);
|
|
870
1236
|
if (!payload)
|
|
871
1237
|
break;
|
|
@@ -874,64 +1240,6 @@ export function createClaimService(deps) {
|
|
|
874
1240
|
}
|
|
875
1241
|
return payloads;
|
|
876
1242
|
},
|
|
877
|
-
async claimServer(holder, limit) {
|
|
878
|
-
const claimed = [];
|
|
879
|
-
const conn = tx.read();
|
|
880
|
-
const agents = new Map();
|
|
881
|
-
for (const candidate of await candidatesOf('online')) {
|
|
882
|
-
if (claimed.length >= limit)
|
|
883
|
-
break;
|
|
884
|
-
if (!agents.has(candidate.agentId))
|
|
885
|
-
agents.set(candidate.agentId, await findAgent(conn, candidate.agentId));
|
|
886
|
-
const agent = agents.get(candidate.agentId);
|
|
887
|
-
if (!agent || agent.archivedAt || agent.type !== 'online')
|
|
888
|
-
continue;
|
|
889
|
-
try {
|
|
890
|
-
const taken = await attemptServer(holder, agent, candidate);
|
|
891
|
-
if (taken)
|
|
892
|
-
claimed.push(taken);
|
|
893
|
-
}
|
|
894
|
-
catch (error) {
|
|
895
|
-
if (!(error instanceof AssemblyError))
|
|
896
|
-
throw error;
|
|
897
|
-
await recordFailure(candidate.id, error);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
return claimed;
|
|
901
|
-
},
|
|
902
|
-
async claimChild(holder, runId) {
|
|
903
|
-
const conn = tx.read();
|
|
904
|
-
const candidate = await findRunRecord(conn, runId);
|
|
905
|
-
if (!candidate?.parentRunId || candidate.status !== 'queued')
|
|
906
|
-
throw notFound('Run');
|
|
907
|
-
const parent = await findRunRecord(conn, candidate.parentRunId);
|
|
908
|
-
if (parent?.runnerId !== holder.id)
|
|
909
|
-
throw notFound('Run');
|
|
910
|
-
const agent = await findAgent(conn, candidate.agentId);
|
|
911
|
-
if (!agent || agent.archivedAt || agent.type !== 'online')
|
|
912
|
-
throw notFound('Agent');
|
|
913
|
-
try {
|
|
914
|
-
const taken = await attemptServer(holder, agent, candidate);
|
|
915
|
-
if (!taken)
|
|
916
|
-
throw notFound('Run');
|
|
917
|
-
return taken;
|
|
918
|
-
}
|
|
919
|
-
catch (error) {
|
|
920
|
-
if (!(error instanceof AssemblyError))
|
|
921
|
-
throw error;
|
|
922
|
-
// One attempt: a consultation that cannot be assembled fails at once.
|
|
923
|
-
await tx.run(async (unit) => {
|
|
924
|
-
const run = await findRunRecord(unit.conn, runId);
|
|
925
|
-
if (run)
|
|
926
|
-
await finishRun(unit, deps, run, {
|
|
927
|
-
status: 'failed',
|
|
928
|
-
reason: 'setupFailed',
|
|
929
|
-
detail: error.message,
|
|
930
|
-
});
|
|
931
|
-
});
|
|
932
|
-
throw error;
|
|
933
|
-
}
|
|
934
|
-
},
|
|
935
1243
|
async runSkills(runner, runId) {
|
|
936
1244
|
const conn = tx.read();
|
|
937
1245
|
const run = await findRunRecord(conn, runId);
|
|
@@ -948,8 +1256,7 @@ export function createClaimService(deps) {
|
|
|
948
1256
|
inputs: [],
|
|
949
1257
|
cli: deps.cli.name,
|
|
950
1258
|
appName: deps.app.name,
|
|
951
|
-
|
|
952
|
-
});
|
|
1259
|
+
}, await binding.context.prepare?.(toRun(run)));
|
|
953
1260
|
return deps.skills.forRun(conn, skillTargets(agent, assembly), run.id);
|
|
954
1261
|
},
|
|
955
1262
|
};
|