@capybara-hq/kernel 0.1.0-rc.4 → 0.1.0-rc.40
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/bootstrap.json +94 -5
- package/dist/admin/admin-agents.controller.d.ts +28 -0
- package/dist/admin/admin-agents.controller.js +79 -0
- package/dist/admin/admin-connectors.controller.d.ts +29 -0
- package/dist/admin/admin-connectors.controller.js +79 -0
- package/dist/admin/admin-items.schemas.d.ts +42 -0
- package/dist/admin/admin-items.schemas.js +48 -0
- package/dist/admin/admin.controller.d.ts +47 -80
- package/dist/admin/admin.controller.js +111 -85
- package/dist/admin/admin.module.d.ts +6 -1
- package/dist/admin/admin.module.js +60 -4
- package/dist/admin/admin.schemas.d.ts +87 -0
- package/dist/admin/admin.schemas.js +53 -0
- package/dist/admin/audit-log.service.d.ts +51 -0
- package/dist/admin/audit-log.service.js +78 -0
- package/dist/admin/audit.controller.d.ts +26 -0
- package/dist/admin/audit.controller.js +72 -0
- package/dist/admin/audit.schemas.d.ts +16 -0
- package/dist/admin/audit.schemas.js +37 -0
- package/dist/admin/extensions.controller.d.ts +26 -2
- package/dist/admin/extensions.controller.js +44 -6
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/health.service.d.ts +104 -0
- package/dist/admin/health.service.js +250 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/admin/org-network.controller.d.ts +30 -0
- package/dist/admin/org-network.controller.js +77 -0
- package/dist/admin/org-network.schemas.d.ts +16 -0
- package/dist/admin/org-network.schemas.js +27 -0
- package/dist/admin/org-network.service.d.ts +41 -0
- package/dist/admin/org-network.service.js +101 -0
- package/dist/admin/outbox-dead.controller.d.ts +21 -0
- package/dist/admin/outbox-dead.controller.js +65 -0
- package/dist/admin/outbox-dead.schemas.d.ts +24 -0
- package/dist/admin/outbox-dead.schemas.js +42 -0
- package/dist/admin/outbox-dead.service.d.ts +81 -0
- package/dist/admin/outbox-dead.service.js +248 -0
- package/dist/admin/overview.controller.d.ts +31 -0
- package/dist/admin/overview.controller.js +78 -0
- package/dist/admin/overview.schemas.d.ts +8 -0
- package/dist/admin/overview.schemas.js +13 -0
- package/dist/admin/overview.service.d.ts +147 -0
- package/dist/admin/overview.service.js +256 -0
- package/dist/admin/setup-lock.d.ts +1 -1
- package/dist/admin/setup-lock.js +1 -1
- package/dist/admin/setup.controller.d.ts +1 -1
- package/dist/admin/setup.controller.js +1 -1
- package/dist/admin/setup.service.d.ts +4 -4
- package/dist/admin/setup.service.js +8 -8
- package/dist/admin/usage.service.d.ts +149 -0
- package/dist/admin/usage.service.js +321 -0
- package/dist/agents/admin-agents.d.ts +105 -0
- package/dist/agents/admin-agents.js +228 -0
- package/dist/agents/agent-lookup.d.ts +21 -0
- package/dist/agents/agent-lookup.js +28 -10
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +26 -231
- package/dist/agents/agents.controller.js +70 -51
- package/dist/agents/agents.module.d.ts +6 -2
- package/dist/agents/agents.module.js +43 -7
- package/dist/agents/agents.schemas.d.ts +440 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +117 -34
- package/dist/agents/agents.service.js +411 -146
- package/dist/agents/definition.d.ts +143 -49
- package/dist/agents/definition.js +228 -233
- package/dist/agents/from-template.d.ts +109 -0
- package/dist/agents/from-template.js +693 -0
- package/dist/agents/from-template.service.d.ts +72 -0
- package/dist/agents/from-template.service.js +178 -0
- package/dist/agents/models.controller.d.ts +38 -6
- package/dist/agents/models.controller.js +70 -9
- package/dist/agents/org-templates.d.ts +186 -0
- package/dist/agents/org-templates.js +928 -0
- package/dist/agents/pending-connector-requests.d.ts +79 -0
- package/dist/agents/pending-connector-requests.js +215 -0
- package/dist/agents/pending-connectors.controller.d.ts +39 -0
- package/dist/agents/pending-connectors.controller.js +91 -0
- package/dist/agents/pending-connectors.service.d.ts +62 -0
- package/dist/agents/pending-connectors.service.js +282 -0
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/readiness.controller.d.ts +8 -19
- package/dist/agents/readiness.controller.js +11 -25
- package/dist/agents/readiness.service.d.ts +42 -0
- package/dist/agents/readiness.service.js +78 -0
- package/dist/agents/templates.controller.d.ts +77 -5
- package/dist/agents/templates.controller.js +153 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +465 -54
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/app.js +2 -0
- package/dist/attribution/platform-attribution.d.ts +104 -0
- package/dist/attribution/platform-attribution.js +149 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.module.js +8 -1
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/finish.d.ts +8 -4
- package/dist/background/finish.js +16 -4
- package/dist/background/launch-lock.d.ts +4 -3
- package/dist/background/launch-lock.js +4 -3
- package/dist/background/launch.d.ts +57 -12
- package/dist/background/launch.js +106 -16
- package/dist/background/poll.job.d.ts +10 -7
- package/dist/background/poll.job.js +37 -24
- package/dist/background/session.d.ts +28 -5
- package/dist/background/session.js +42 -6
- package/dist/background/status.d.ts +2 -2
- package/dist/background/status.js +4 -4
- package/dist/background/stop.d.ts +12 -8
- package/dist/background/stop.js +58 -59
- package/dist/background/store.d.ts +34 -7
- package/dist/background/store.js +44 -8
- package/dist/background/tasks.service.d.ts +50 -8
- package/dist/background/tasks.service.js +131 -46
- package/dist/background/wake-rules.d.ts +32 -18
- package/dist/background/wake-rules.js +65 -23
- package/dist/background/wake.d.ts +13 -11
- package/dist/background/wake.js +20 -14
- package/dist/catalog/admin-catalog.controller.d.ts +157 -57
- package/dist/catalog/admin-catalog.controller.js +314 -70
- package/dist/catalog/admin-catalog.schemas.d.ts +87 -0
- package/dist/catalog/admin-catalog.schemas.js +107 -0
- package/dist/catalog/appearance.schemas.d.ts +10 -0
- package/dist/catalog/appearance.schemas.js +20 -0
- package/dist/catalog/appearance.service.d.ts +105 -0
- package/dist/catalog/appearance.service.js +304 -0
- package/dist/catalog/catalog-content.d.ts +145 -36
- package/dist/catalog/catalog-content.js +123 -17
- package/dist/catalog/catalog-files.d.ts +42 -0
- package/dist/catalog/catalog-files.js +89 -0
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +59 -0
- package/dist/catalog/catalog-items.d.ts +122 -7
- package/dist/catalog/catalog-items.js +302 -14
- package/dist/catalog/catalog-scope.service.d.ts +312 -0
- package/dist/catalog/catalog-scope.service.js +1261 -0
- package/dist/catalog/catalog.module.d.ts +8 -9
- package/dist/catalog/catalog.module.js +55 -31
- package/dist/catalog/catalog.service.d.ts +129 -31
- package/dist/catalog/catalog.service.js +193 -105
- package/dist/catalog/claude/report.d.ts +9 -2
- package/dist/catalog/claude/report.js +1 -0
- package/dist/catalog/claude/translate.js +4 -1
- package/dist/catalog/cli.d.ts +1 -1
- package/dist/catalog/cli.js +4 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +394 -0
- package/dist/catalog/component-scope.controller.d.ts +102 -0
- package/dist/catalog/component-scope.controller.js +257 -0
- package/dist/catalog/component-scope.schemas.d.ts +118 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +394 -0
- package/dist/catalog/component-scope.service.js +1131 -0
- package/dist/catalog/component-state.d.ts +219 -0
- package/dist/catalog/component-state.js +493 -0
- package/dist/catalog/git-source.d.ts +9 -1
- package/dist/catalog/git-source.js +29 -2
- package/dist/catalog/install-status.d.ts +6 -0
- package/dist/catalog/install-status.js +6 -0
- package/dist/catalog/job-ids.d.ts +19 -5
- package/dist/catalog/job-ids.js +21 -5
- package/dist/catalog/marketplace-fetch.d.ts +6 -3
- package/dist/catalog/marketplace-fetch.js +4 -1
- package/dist/catalog/marketplace-icons.d.ts +64 -0
- package/dist/catalog/marketplace-icons.js +131 -0
- package/dist/catalog/marketplaces.controller.d.ts +50 -41
- package/dist/catalog/marketplaces.controller.js +130 -46
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +110 -17
- package/dist/catalog/marketplaces.service.js +339 -30
- package/dist/catalog/org-catalog.controller.d.ts +124 -62
- package/dist/catalog/org-catalog.controller.js +208 -93
- package/dist/catalog/org-catalog.schemas.d.ts +117 -0
- package/dist/catalog/org-catalog.schemas.js +141 -0
- package/dist/catalog/org-catalog.service.d.ts +74 -33
- package/dist/catalog/org-catalog.service.js +382 -158
- package/dist/catalog/org-extension-switch.d.ts +46 -0
- package/dist/catalog/org-extension-switch.js +162 -0
- package/dist/catalog/org-extension.controller.d.ts +133 -0
- package/dist/catalog/org-extension.controller.js +313 -0
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +77 -0
- package/dist/catalog/org-plugin-uploads.controller.js +199 -0
- package/dist/catalog/org-plugin-uploads.d.ts +68 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +19 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +30 -0
- package/dist/catalog/owned-items.d.ts +181 -0
- package/dist/catalog/owned-items.js +788 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +47 -0
- package/dist/catalog/owned-plugin-cleanup.js +140 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +264 -0
- package/dist/catalog/platform-components.js +857 -0
- package/dist/catalog/platform-import-update.d.ts +50 -0
- package/dist/catalog/platform-import-update.js +116 -0
- package/dist/catalog/plugin-import.d.ts +294 -55
- package/dist/catalog/plugin-import.js +841 -147
- package/dist/catalog/plugin-install.d.ts +232 -88
- package/dist/catalog/plugin-install.js +866 -232
- package/dist/catalog/plugin-package.d.ts +54 -13
- package/dist/catalog/plugin-package.js +225 -33
- package/dist/catalog/plugin-upgrade.d.ts +325 -225
- package/dist/catalog/plugin-upgrade.js +1317 -1132
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +253 -117
- package/dist/catalog/requests.service.js +724 -323
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-jobs.d.ts +59 -0
- package/dist/catalog/scope-jobs.js +78 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +66 -0
- package/dist/catalog/scope-state.d.ts +35 -0
- package/dist/catalog/scope-state.js +87 -0
- package/dist/catalog/scope-sync-workers.d.ts +30 -0
- package/dist/catalog/scope-sync-workers.js +97 -0
- package/dist/catalog/scope-sync.d.ts +148 -0
- package/dist/catalog/scope-sync.js +498 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +21 -0
- package/dist/catalog/unshare.js +116 -0
- package/dist/channels/actions.d.ts +5 -0
- package/dist/channels/actions.js +33 -7
- package/dist/channels/cards.d.ts +59 -9
- package/dist/channels/cards.js +172 -19
- package/dist/channels/channels.module.d.ts +13 -9
- package/dist/channels/channels.module.js +33 -11
- package/dist/channels/channels.schemas.d.ts +41 -0
- package/dist/channels/channels.schemas.js +40 -0
- package/dist/channels/connections.controller.d.ts +46 -37
- package/dist/channels/connections.controller.js +76 -34
- package/dist/channels/connections.service.d.ts +89 -12
- package/dist/channels/connections.service.js +239 -26
- package/dist/channels/deliver-job.d.ts +32 -0
- package/dist/channels/deliver-job.js +29 -0
- package/dist/channels/inbound.d.ts +12 -27
- package/dist/channels/inbound.js +115 -23
- package/dist/channels/job-ids.d.ts +2 -6
- package/dist/channels/job-ids.js +2 -6
- package/dist/channels/jobs.d.ts +37 -20
- package/dist/channels/jobs.js +79 -27
- package/dist/channels/outbound.d.ts +40 -3
- package/dist/channels/outbound.js +187 -22
- package/dist/channels/phrases.d.ts +121 -2
- package/dist/channels/phrases.js +99 -1
- package/dist/channels/supervisor.d.ts +4 -3
- package/dist/channels/supervisor.js +6 -3
- package/dist/channels/threads.d.ts +16 -3
- package/dist/channels/threads.js +38 -3
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/client/client-access.service.d.ts +102 -0
- package/dist/client/client-access.service.js +303 -0
- package/dist/client/client-builds.service.d.ts +109 -0
- package/dist/client/client-builds.service.js +229 -0
- package/dist/client/client-delivery.controller.d.ts +25 -0
- package/dist/client/client-delivery.controller.js +66 -0
- package/dist/client/client-files.d.ts +48 -0
- package/dist/client/client-files.js +136 -0
- package/dist/client/client-reports.cron.d.ts +13 -0
- package/dist/client/client-reports.cron.js +42 -0
- package/dist/client/client-reports.service.d.ts +30 -0
- package/dist/client/client-reports.service.js +102 -0
- package/dist/client/client-sign-in.service.d.ts +21 -0
- package/dist/client/client-sign-in.service.js +49 -0
- package/dist/client/client.controller.d.ts +49 -0
- package/dist/client/client.controller.js +129 -0
- package/dist/client/client.module.d.ts +8 -0
- package/dist/client/client.module.js +28 -0
- package/dist/client/client.schemas.d.ts +61 -0
- package/dist/client/client.schemas.js +27 -0
- package/dist/config/docs.js +5 -1
- package/dist/config/env.js +19 -1
- package/dist/config/load.js +8 -1
- package/dist/config/schema.d.ts +103 -50
- package/dist/config/schema.js +528 -97
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +27 -5
- package/dist/conversations/agent-tree.d.ts +62 -0
- package/dist/conversations/agent-tree.js +128 -0
- package/dist/conversations/attachments.service.d.ts +49 -3
- package/dist/conversations/attachments.service.js +108 -38
- package/dist/conversations/conversations.controller.d.ts +62 -82
- package/dist/conversations/conversations.controller.js +107 -105
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.d.ts +60 -0
- package/dist/conversations/conversations.schemas.js +93 -0
- package/dist/conversations/conversations.service.d.ts +300 -30
- package/dist/conversations/conversations.service.js +496 -117
- package/dist/conversations/device-status.d.ts +24 -0
- package/dist/conversations/device-status.js +71 -0
- package/dist/conversations/event-log.d.ts +60 -17
- package/dist/conversations/event-log.js +129 -21
- package/dist/conversations/events.d.ts +546 -44
- package/dist/conversations/events.js +628 -98
- package/dist/conversations/files.d.ts +39 -12
- package/dist/conversations/files.js +134 -55
- package/dist/conversations/media-types.d.ts +25 -0
- package/dist/conversations/media-types.js +38 -0
- package/dist/conversations/message-context.d.ts +82 -0
- package/dist/conversations/message-context.js +149 -0
- package/dist/conversations/queue.d.ts +20 -4
- package/dist/conversations/queue.js +31 -3
- package/dist/conversations/queue.service.d.ts +20 -9
- package/dist/conversations/queue.service.js +95 -25
- package/dist/conversations/source.d.ts +10 -0
- package/dist/conversations/source.js +17 -0
- package/dist/conversations/titles.d.ts +26 -11
- package/dist/conversations/titles.js +67 -25
- package/dist/conversations/tree.d.ts +27 -0
- package/dist/conversations/tree.js +77 -0
- package/dist/ctx/create-ctx.d.ts +81 -9
- package/dist/ctx/create-ctx.js +223 -53
- package/dist/ctx/net.d.ts +50 -0
- package/dist/ctx/net.js +67 -0
- package/dist/ctx/secrets.d.ts +24 -7
- package/dist/ctx/secrets.js +97 -30
- package/dist/db/kernel-schema.d.ts +815 -36
- package/dist/devices/access.d.ts +66 -0
- package/dist/devices/access.js +113 -0
- package/dist/devices/conversation-devices.d.ts +161 -0
- package/dist/devices/conversation-devices.js +367 -0
- package/dist/devices/device-projects.service.d.ts +162 -0
- package/dist/devices/device-projects.service.js +503 -0
- package/dist/devices/devices.controller.d.ts +65 -0
- package/dist/devices/devices.controller.js +219 -0
- package/dist/devices/devices.module.d.ts +8 -0
- package/dist/devices/devices.module.js +47 -0
- package/dist/devices/devices.schemas.d.ts +11 -0
- package/dist/devices/devices.schemas.js +30 -0
- package/dist/devices/devices.service.d.ts +421 -0
- package/dist/devices/devices.service.js +1085 -0
- package/dist/devices/dto.d.ts +86 -0
- package/dist/devices/dto.js +96 -0
- package/dist/devices/label.d.ts +11 -0
- package/dist/devices/label.js +25 -0
- package/dist/devices/legacy-cleanup.job.d.ts +34 -0
- package/dist/devices/legacy-cleanup.job.js +141 -0
- package/dist/devices/public-suffix.d.ts +6 -0
- package/dist/devices/public-suffix.js +79 -0
- package/dist/devices/working-root.d.ts +41 -0
- package/dist/devices/working-root.js +50 -0
- package/dist/errors.d.ts +327 -10
- package/dist/errors.js +327 -10
- package/dist/evals/evals.module.js +16 -3
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/jobs.d.ts +14 -6
- package/dist/evals/jobs.js +21 -19
- package/dist/evals/plan.d.ts +20 -15
- package/dist/evals/plan.js +29 -6
- package/dist/evals/reconstruct.d.ts +44 -28
- package/dist/evals/reconstruct.js +134 -70
- package/dist/evals/recorded-tools.d.ts +9 -26
- package/dist/evals/recorded-tools.js +30 -84
- package/dist/evals/run-replay.d.ts +34 -11
- package/dist/evals/run-replay.js +99 -32
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +13 -13
- package/dist/evals/runs.service.js +55 -62
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +24 -11
- package/dist/evals/sets.service.js +64 -23
- package/dist/evals/snapshot.d.ts +9 -3
- package/dist/evals/snapshot.js +5 -4
- package/dist/evals/step-replay.d.ts +10 -6
- package/dist/evals/step-replay.js +9 -3
- package/dist/evals/trajectory.d.ts +19 -3
- package/dist/evals/trajectory.js +14 -1
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +11 -4
- package/dist/extensions/admin-ops.d.ts +86 -14
- package/dist/extensions/admin-ops.js +194 -49
- package/dist/extensions/admin-view.d.ts +61 -13
- package/dist/extensions/admin-view.js +267 -47
- package/dist/extensions/approvals.d.ts +12 -2
- package/dist/extensions/blobs.d.ts +14 -1
- package/dist/extensions/blobs.js +48 -5
- package/dist/extensions/bootstrap.d.ts +86 -11
- package/dist/extensions/bootstrap.js +221 -37
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -3
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +44 -6
- package/dist/extensions/deployment-config.js +131 -7
- package/dist/extensions/effective-config.d.ts +133 -0
- package/dist/extensions/effective-config.js +379 -0
- package/dist/extensions/extensions.module.js +31 -12
- package/dist/extensions/guide-places.d.ts +68 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/hooks.d.ts +59 -7
- package/dist/extensions/hooks.js +97 -17
- package/dist/extensions/host.d.ts +87 -14
- package/dist/extensions/host.js +299 -81
- package/dist/extensions/installs.d.ts +31 -12
- package/dist/extensions/installs.js +61 -17
- package/dist/extensions/instance.d.ts +15 -2
- package/dist/extensions/instance.js +18 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-hooks.d.ts +99 -0
- package/dist/extensions/lifecycle-hooks.js +273 -0
- package/dist/extensions/lifecycle.d.ts +6 -1
- package/dist/extensions/lifecycle.js +9 -2
- package/dist/extensions/locks.d.ts +12 -0
- package/dist/extensions/locks.js +26 -0
- package/dist/extensions/org-config.d.ts +104 -8
- package/dist/extensions/org-config.js +214 -35
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/package.d.ts +6 -5
- package/dist/extensions/package.js +5 -5
- package/dist/extensions/permission-set.d.ts +40 -9
- package/dist/extensions/permission-set.js +43 -9
- package/dist/extensions/permission-view.d.ts +112 -20
- package/dist/extensions/permission-view.js +50 -22
- package/dist/extensions/plugin-guides.d.ts +282 -0
- package/dist/extensions/plugin-guides.js +554 -0
- package/dist/extensions/plugin-icons.d.ts +54 -0
- package/dist/extensions/plugin-icons.js +125 -0
- package/dist/extensions/plugin-items.d.ts +41 -0
- package/dist/extensions/plugin-items.js +70 -0
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +43 -7
- package/dist/extensions/point-defaults.js +80 -19
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/resolve.d.ts +51 -1
- package/dist/extensions/resolve.js +85 -3
- package/dist/extensions/single-provider.d.ts +92 -0
- package/dist/extensions/single-provider.js +180 -0
- package/dist/extensions/sources.d.ts +13 -2
- package/dist/extensions/sources.js +2 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +46 -0
- package/dist/extensions/sync.js +5 -10
- package/dist/extensions/unavailable.d.ts +50 -0
- package/dist/extensions/unavailable.js +114 -0
- package/dist/extensions/usage-subscribers.d.ts +43 -0
- package/dist/extensions/usage-subscribers.js +108 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +10 -3
- package/dist/files/previewers.js +46 -11
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/git/gateway.d.ts +93 -0
- package/dist/git/gateway.js +750 -0
- package/dist/git/gateway.route.d.ts +16 -0
- package/dist/git/gateway.route.js +41 -0
- package/dist/git/git.module.d.ts +10 -0
- package/dist/git/git.module.js +31 -0
- package/dist/git/identity.d.ts +80 -0
- package/dist/git/identity.js +209 -0
- package/dist/git/pkt-line.d.ts +53 -0
- package/dist/git/pkt-line.js +146 -0
- package/dist/git/run-end.d.ts +29 -0
- package/dist/git/run-end.js +121 -0
- package/dist/git/sources.d.ts +42 -0
- package/dist/git/sources.js +134 -0
- package/dist/git/tickets.d.ts +69 -0
- package/dist/git/tickets.js +194 -0
- package/dist/http/api.module.js +81 -4
- package/dist/http/app.d.ts +25 -4
- package/dist/http/app.js +46 -7
- package/dist/http/gateway-routes.d.ts +7 -3
- package/dist/http/gateway-routes.js +6 -3
- package/dist/http/plugin-dispatch.d.ts +58 -18
- package/dist/http/plugin-dispatch.js +137 -30
- package/dist/http/plugin-route-access.d.ts +56 -0
- package/dist/http/plugin-route-access.js +192 -0
- package/dist/identity/accounts.d.ts +77 -31
- package/dist/identity/accounts.js +133 -52
- package/dist/identity/audit.d.ts +2 -13
- package/dist/identity/audit.js +0 -27
- package/dist/identity/auth.controller.js +5 -9
- package/dist/identity/auth.guard.d.ts +38 -16
- package/dist/identity/auth.guard.js +96 -41
- package/dist/identity/cookies.d.ts +8 -7
- package/dist/identity/cookies.js +19 -29
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +7 -4
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +158 -0
- package/dist/identity/me.controller.d.ts +12 -0
- package/dist/identity/me.controller.js +34 -2
- package/dist/identity/me.schemas.d.ts +24 -0
- package/dist/identity/me.schemas.js +25 -0
- package/dist/identity/principal.d.ts +11 -3
- package/dist/identity/principal.js +11 -3
- package/dist/identity/sessions.d.ts +0 -6
- package/dist/identity/sessions.js +0 -18
- package/dist/identity/settings.d.ts +216 -12
- package/dist/identity/settings.js +420 -29
- package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
- package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
- package/dist/identity/write-actor.d.ts +11 -0
- package/dist/identity/write-actor.js +7 -0
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +9 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/inbox.service.d.ts +65 -4
- package/dist/inbox/inbox.service.js +82 -4
- package/dist/inbox/org-notices.d.ts +63 -0
- package/dist/inbox/org-notices.js +91 -0
- package/dist/inbox/platform-inbox.controller.d.ts +23 -0
- package/dist/inbox/platform-inbox.controller.js +58 -0
- package/dist/inbox/platform-inbox.service.d.ts +160 -0
- package/dist/inbox/platform-inbox.service.js +282 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +12 -3
- package/dist/infra/cli/kernel-cli.module.js +14 -1
- package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
- package/dist/infra/cli/master-key-rewrap.js +24 -0
- package/dist/infra/config/kernel-config.service.d.ts +7 -0
- package/dist/infra/config/kernel-config.service.js +47 -1
- package/dist/infra/database/transaction-host.d.ts +32 -0
- package/dist/infra/database/transaction-host.js +40 -3
- package/dist/infra/database/xact-lock.d.ts +17 -1
- package/dist/infra/database/xact-lock.js +29 -2
- package/dist/infra/events/kernel-events.d.ts +20 -25
- package/dist/infra/health/health.controller.js +8 -0
- package/dist/infra/health/process-fault.d.ts +16 -0
- package/dist/infra/health/process-fault.js +49 -0
- package/dist/infra/lifecycle/process-guards.d.ts +8 -2
- package/dist/infra/lifecycle/process-guards.js +12 -3
- package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
- package/dist/infra/lifecycle/shutdown-signals.js +28 -13
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/outbox/outbox-relay.module.d.ts +6 -0
- package/dist/infra/outbox/outbox-relay.module.js +18 -0
- package/dist/infra/outbox/outbox.dispatcher.d.ts +103 -0
- package/dist/infra/outbox/outbox.dispatcher.js +310 -0
- package/dist/infra/outbox/outbox.module.d.ts +24 -0
- package/dist/infra/outbox/outbox.module.js +50 -0
- package/dist/infra/outbox/outbox.relay.d.ts +31 -0
- package/dist/infra/outbox/outbox.relay.js +76 -0
- package/dist/infra/outbox/outbox.service.d.ts +60 -0
- package/dist/infra/outbox/outbox.service.js +161 -0
- package/dist/infra/outbox/registry.d.ts +321 -0
- package/dist/infra/outbox/registry.js +318 -0
- package/dist/infra/presence/presence.module.d.ts +6 -0
- package/dist/infra/presence/presence.module.js +22 -0
- package/dist/infra/presence/replica-presence.d.ts +87 -0
- package/dist/infra/presence/replica-presence.js +189 -0
- package/dist/infra/queue/queue-names.d.ts +8 -0
- package/dist/infra/queue/queue-names.js +17 -0
- package/dist/infra/throttler/named-throttlers.d.ts +15 -0
- package/dist/infra/throttler/named-throttlers.js +83 -0
- package/dist/infra/throttler/throttler.guard.d.ts +2 -1
- package/dist/infra/throttler/throttler.guard.js +3 -2
- package/dist/kernel.module.js +21 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +9 -3
- package/dist/lifecycle/kernel-lifecycle.js +47 -18
- package/dist/local-devices/device-auth.controller.d.ts +42 -0
- package/dist/local-devices/device-auth.controller.js +116 -0
- package/dist/local-devices/device-auth.d.ts +124 -0
- package/dist/local-devices/device-auth.js +410 -0
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/local-devices/device-auth.module.js +25 -0
- package/dist/local-devices/device-policy.service.d.ts +174 -0
- package/dist/local-devices/device-policy.service.js +470 -0
- package/dist/local-devices/device-routes.d.ts +36 -0
- package/dist/local-devices/device-routes.js +90 -0
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/local-devices/keys.d.ts +25 -0
- package/dist/local-devices/keys.js +25 -0
- package/dist/local-devices/local-device-gateway.d.ts +136 -0
- package/dist/local-devices/local-device-gateway.js +570 -0
- package/dist/local-devices/local-device-provider.d.ts +152 -0
- package/dist/local-devices/local-device-provider.js +238 -0
- package/dist/local-devices/local-devices.module.d.ts +17 -0
- package/dist/local-devices/local-devices.module.js +60 -0
- package/dist/local-devices/machines.d.ts +164 -0
- package/dist/local-devices/machines.js +543 -0
- package/dist/local-devices/network-grants.d.ts +88 -0
- package/dist/local-devices/network-grants.js +267 -0
- package/dist/local-devices/policy-op-jobs.d.ts +15 -0
- package/dist/local-devices/policy-op-jobs.js +12 -0
- package/dist/local-devices/policy-summary.d.ts +98 -0
- package/dist/local-devices/policy-summary.js +152 -0
- package/dist/local-devices/relay.d.ts +102 -0
- package/dist/local-devices/relay.js +375 -0
- package/dist/local-devices/targets.d.ts +33 -0
- package/dist/local-devices/targets.js +87 -0
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +319 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +100 -0
- package/dist/models/enablement.js +257 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +19 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +8 -6
- package/dist/models/prices.js +11 -9
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +56 -14
- package/dist/models/purposes.js +90 -25
- package/dist/net/public-address.d.ts +35 -5
- package/dist/net/public-address.js +78 -22
- package/dist/net/safe-fetch.d.ts +6 -2
- package/dist/net/safe-fetch.js +31 -8
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +44 -18
- package/dist/orgs/members.service.js +6 -1
- package/dist/orgs/network-allowances.service.d.ts +79 -0
- package/dist/orgs/network-allowances.service.js +371 -0
- package/dist/orgs/offboarding.d.ts +55 -56
- package/dist/orgs/offboarding.js +147 -170
- package/dist/orgs/org-lock.d.ts +33 -2
- package/dist/orgs/org-lock.js +72 -4
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.controller.d.ts +12 -6
- package/dist/orgs/orgs.controller.js +21 -8
- package/dist/orgs/orgs.module.d.ts +3 -2
- package/dist/orgs/orgs.module.js +16 -12
- package/dist/orgs/orgs.schemas.d.ts +20 -0
- package/dist/orgs/orgs.schemas.js +21 -0
- package/dist/orgs/orgs.service.d.ts +32 -9
- package/dist/orgs/orgs.service.js +81 -22
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +11 -1
- package/dist/orgs/settings.controller.d.ts +6 -3
- package/dist/orgs/settings.controller.js +9 -4
- package/dist/orgs/settings.service.d.ts +379 -45
- package/dist/orgs/settings.service.js +515 -77
- package/dist/overrides.d.ts +56 -4
- package/dist/overrides.js +32 -2
- package/dist/packages/npm.d.ts +28 -9
- package/dist/packages/npm.js +30 -19
- package/dist/packages/provenance.d.ts +3 -1
- package/dist/packages/provenance.js +7 -3
- package/dist/packages/tgz.d.ts +0 -2
- package/dist/packages/tgz.js +0 -2
- package/dist/platform/actor.d.ts +48 -0
- package/dist/platform/actor.js +100 -0
- package/dist/platform/agent-docs.d.ts +18 -0
- package/dist/platform/agent-docs.js +59 -0
- package/dist/platform/availability.d.ts +14 -0
- package/dist/platform/availability.js +43 -0
- package/dist/platform/errors.d.ts +28 -0
- package/dist/platform/errors.js +65 -0
- package/dist/platform/exclusions.d.ts +11 -0
- package/dist/platform/exclusions.js +787 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +169 -0
- package/dist/platform/operation.js +106 -0
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin-items.ops.d.ts +37 -0
- package/dist/platform/ops/admin-items.ops.js +278 -0
- package/dist/platform/ops/admin.ops.d.ts +38 -0
- package/dist/platform/ops/admin.ops.js +549 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +50 -0
- package/dist/platform/ops/agent-skills.ops.js +510 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +17 -0
- package/dist/platform/ops/agent-templates.ops.js +272 -0
- package/dist/platform/ops/agents.ops.d.ts +37 -0
- package/dist/platform/ops/agents.ops.js +723 -0
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +94 -0
- package/dist/platform/ops/catalog-admin.ops.js +710 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +854 -0
- package/dist/platform/ops/connectors.ops.d.ts +17 -0
- package/dist/platform/ops/connectors.ops.js +235 -0
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +505 -0
- package/dist/platform/ops/devices.ops.d.ts +28 -0
- package/dist/platform/ops/devices.ops.js +446 -0
- package/dist/platform/ops/errors.d.ts +16 -0
- package/dist/platform/ops/errors.js +30 -0
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +731 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +372 -0
- package/dist/platform/ops/extensions.ops.d.ts +25 -0
- package/dist/platform/ops/extensions.ops.js +347 -0
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +397 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +22 -0
- package/dist/platform/ops/marketplaces.ops.js +466 -0
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +35 -0
- package/dist/platform/ops/org-plugins.ops.js +388 -0
- package/dist/platform/ops/org-settings.ops.d.ts +18 -0
- package/dist/platform/ops/org-settings.ops.js +144 -0
- package/dist/platform/ops/orgs.ops.d.ts +36 -0
- package/dist/platform/ops/orgs.ops.js +435 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/outbox.ops.d.ts +21 -0
- package/dist/platform/ops/outbox.ops.js +125 -0
- package/dist/platform/ops/paging.d.ts +14 -0
- package/dist/platform/ops/paging.js +20 -0
- package/dist/platform/ops/platform.ops.d.ts +41 -0
- package/dist/platform/ops/platform.ops.js +261 -0
- package/dist/platform/ops/plugins.ops.d.ts +35 -0
- package/dist/platform/ops/plugins.ops.js +476 -0
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +192 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/schedules.ops.d.ts +21 -0
- package/dist/platform/ops/schedules.ops.js +509 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/skills.ops.d.ts +17 -0
- package/dist/platform/ops/skills.ops.js +160 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/ops/themes.ops.d.ts +14 -0
- package/dist/platform/ops/themes.ops.js +47 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +118 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +45 -0
- package/dist/platform/platform-ops.module.js +150 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +94 -0
- package/dist/roles/gateway-role.d.ts +18 -3
- package/dist/roles/gateway-role.js +33 -5
- package/dist/roles/gateway.module.d.ts +2 -1
- package/dist/roles/gateway.module.js +6 -3
- package/dist/roles/worker-role.d.ts +13 -7
- package/dist/roles/worker-role.js +27 -20
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +27 -7
- package/dist/runtime/checkpointer.d.ts +3 -0
- package/dist/runtime/checkpointer.js +9 -3
- package/dist/runtime/compaction-progress.d.ts +62 -0
- package/dist/runtime/compaction-progress.js +82 -0
- package/dist/runtime/compaction-settings.service.d.ts +16 -0
- package/dist/runtime/compaction-settings.service.js +42 -0
- package/dist/runtime/compaction.service.d.ts +50 -0
- package/dist/runtime/compaction.service.js +75 -0
- package/dist/runtime/context/build.d.ts +80 -21
- package/dist/runtime/context/build.js +291 -64
- package/dist/runtime/context/claude-tools.d.ts +2 -1
- package/dist/runtime/context/claude-tools.js +5 -4
- package/dist/runtime/context/compaction.d.ts +111 -16
- package/dist/runtime/context/compaction.js +423 -55
- package/dist/runtime/context/device-paths.d.ts +82 -0
- package/dist/runtime/context/device-paths.js +165 -0
- package/dist/runtime/context/fit.d.ts +111 -0
- package/dist/runtime/context/fit.js +278 -0
- package/dist/runtime/context/plugin-context.d.ts +20 -0
- package/dist/runtime/context/plugin-context.js +30 -0
- package/dist/runtime/context/project-root.d.ts +43 -0
- package/dist/runtime/context/project-root.js +85 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/run-context.d.ts +88 -0
- package/dist/runtime/context/run-context.js +295 -0
- package/dist/runtime/context/skills.d.ts +38 -54
- package/dist/runtime/context/skills.js +85 -119
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +50 -0
- package/dist/runtime/conversation-lock.d.ts +4 -11
- package/dist/runtime/conversation-lock.js +14 -18
- package/dist/runtime/hook-calls.d.ts +14 -7
- package/dist/runtime/hook-calls.js +47 -14
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +60 -24
- package/dist/runtime/limits.d.ts +15 -0
- package/dist/runtime/limits.js +25 -0
- package/dist/runtime/loop.d.ts +48 -7
- package/dist/runtime/loop.js +2 -1
- package/dist/runtime/maintenance.d.ts +21 -15
- package/dist/runtime/maintenance.js +99 -27
- package/dist/runtime/model-call.d.ts +186 -30
- package/dist/runtime/model-call.js +1014 -378
- package/dist/runtime/plugin-context.service.d.ts +75 -0
- package/dist/runtime/plugin-context.service.js +220 -0
- package/dist/runtime/project/knowledge.d.ts +129 -0
- package/dist/runtime/project/knowledge.js +248 -0
- package/dist/runtime/project/knowledge.service.d.ts +85 -0
- package/dist/runtime/project/knowledge.service.js +288 -0
- package/dist/runtime/providers.d.ts +156 -44
- package/dist/runtime/providers.js +346 -130
- package/dist/runtime/queue-lost-jobs.d.ts +24 -0
- package/dist/runtime/queue-lost-jobs.js +51 -0
- package/dist/runtime/run-context.service.d.ts +82 -0
- package/dist/runtime/run-context.service.js +255 -0
- package/dist/runtime/run-control.d.ts +62 -5
- package/dist/runtime/run-control.js +98 -12
- package/dist/runtime/run-deletion.d.ts +29 -0
- package/dist/runtime/run-deletion.js +153 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-execution.d.ts +76 -0
- package/dist/runtime/run-execution.js +175 -0
- package/dist/runtime/run-finish.d.ts +49 -12
- package/dist/runtime/run-finish.js +140 -15
- package/dist/runtime/run-jobs.d.ts +112 -15
- package/dist/runtime/run-jobs.js +235 -32
- package/dist/runtime/run-liveness.d.ts +11 -0
- package/dist/runtime/run-liveness.js +19 -0
- package/dist/runtime/run-orphan-check.job.d.ts +145 -0
- package/dist/runtime/run-orphan-check.job.js +413 -0
- package/dist/runtime/run-processors.d.ts +16 -9
- package/dist/runtime/run-processors.js +1 -1
- package/dist/runtime/run-queue.d.ts +123 -61
- package/dist/runtime/run-queue.js +454 -253
- package/dist/runtime/run-status.d.ts +12 -0
- package/dist/runtime/run-status.js +21 -0
- package/dist/runtime/run-steps.d.ts +3 -2
- package/dist/runtime/run-steps.js +15 -11
- package/dist/runtime/run-worker.d.ts +78 -28
- package/dist/runtime/run-worker.js +499 -154
- package/dist/runtime/runtime.module.d.ts +2 -3
- package/dist/runtime/runtime.module.js +41 -6
- package/dist/runtime/step-log.d.ts +30 -7
- package/dist/runtime/step-log.js +42 -13
- package/dist/runtime/stream.controller.d.ts +24 -4
- package/dist/runtime/stream.controller.js +60 -9
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +50 -5
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +106 -8
- package/dist/runtime/subagents/definition.d.ts +53 -28
- package/dist/runtime/subagents/definition.js +161 -211
- package/dist/runtime/subagents/deliveries.d.ts +74 -0
- package/dist/runtime/subagents/deliveries.js +237 -0
- package/dist/runtime/subagents/dispatch.d.ts +125 -32
- package/dist/runtime/subagents/dispatch.js +233 -171
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +99 -0
- package/dist/runtime/subagents/messages.js +336 -0
- package/dist/runtime/subagents/org-agents.js +1 -2
- package/dist/runtime/subagents/preamble.d.ts +6 -4
- package/dist/runtime/subagents/preamble.js +11 -7
- package/dist/runtime/subagents/progress.d.ts +8 -6
- package/dist/runtime/subagents/progress.js +11 -6
- package/dist/runtime/subagents/render.d.ts +29 -0
- package/dist/runtime/subagents/render.js +52 -0
- package/dist/runtime/subagents/roster.d.ts +24 -7
- package/dist/runtime/subagents/roster.js +47 -11
- package/dist/runtime/subagents/skill-fork.d.ts +8 -9
- package/dist/runtime/subagents/skill-fork.js +16 -9
- package/dist/runtime/subagents/status.d.ts +14 -0
- package/dist/runtime/subagents/status.js +23 -0
- package/dist/runtime/subagents/subagents.service.d.ts +7 -4
- package/dist/runtime/subagents/subagents.service.js +12 -7
- package/dist/runtime/subagents/template-skills.d.ts +47 -0
- package/dist/runtime/subagents/template-skills.js +76 -0
- package/dist/runtime/subagents/tree-jobs.d.ts +62 -0
- package/dist/runtime/subagents/tree-jobs.js +86 -0
- package/dist/runtime/usage-report-jobs.d.ts +63 -0
- package/dist/runtime/usage-report-jobs.js +106 -0
- package/dist/runtime/usage-report.d.ts +47 -98
- package/dist/runtime/usage-report.js +141 -243
- package/dist/runtime/waits.d.ts +130 -167
- package/dist/runtime/waits.js +328 -706
- package/dist/sandbox/jobs.d.ts +50 -13
- package/dist/sandbox/jobs.js +64 -21
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/modes.d.ts +120 -0
- package/dist/sandbox/modes.js +145 -0
- package/dist/sandbox/platform-auto-mode.d.ts +63 -0
- package/dist/sandbox/platform-auto-mode.js +63 -0
- package/dist/sandbox/providers.d.ts +34 -7
- package/dist/sandbox/providers.js +54 -9
- package/dist/sandbox/review/classifier.d.ts +135 -0
- package/dist/sandbox/review/classifier.js +419 -0
- package/dist/sandbox/review/index.d.ts +13 -0
- package/dist/sandbox/review/index.js +10 -0
- package/dist/sandbox/review/review.service.d.ts +145 -0
- package/dist/sandbox/review/review.service.js +372 -0
- package/dist/sandbox/review/rules.d.ts +87 -0
- package/dist/sandbox/review/rules.js +5319 -0
- package/dist/sandbox/review/types.d.ts +116 -0
- package/dist/sandbox/review/types.js +48 -0
- package/dist/sandbox/sandbox-file-reader.d.ts +35 -0
- package/dist/sandbox/sandbox-file-reader.js +98 -0
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +15 -4
- package/dist/sandbox/sandbox.service.d.ts +436 -145
- package/dist/sandbox/sandbox.service.js +1232 -435
- package/dist/sandbox/unreachable.d.ts +30 -0
- package/dist/sandbox/unreachable.js +108 -0
- package/dist/schedules/calendar.d.ts +134 -0
- package/dist/schedules/calendar.js +410 -0
- package/dist/schedules/effective-settings.d.ts +22 -0
- package/dist/schedules/effective-settings.js +18 -0
- package/dist/schedules/errors.d.ts +8 -0
- package/dist/schedules/errors.js +8 -0
- package/dist/schedules/fire.d.ts +137 -0
- package/dist/schedules/fire.js +708 -0
- package/dist/schedules/grant-rules.d.ts +120 -0
- package/dist/schedules/grant-rules.js +186 -0
- package/dist/schedules/job-ids.d.ts +81 -0
- package/dist/schedules/job-ids.js +95 -0
- package/dist/schedules/pause.d.ts +9 -0
- package/dist/schedules/pause.js +33 -0
- package/dist/schedules/run-tracker.d.ts +76 -0
- package/dist/schedules/run-tracker.js +321 -0
- package/dist/schedules/scan.job.d.ts +45 -0
- package/dist/schedules/scan.job.js +189 -0
- package/dist/schedules/schedule-math.d.ts +73 -0
- package/dist/schedules/schedule-math.js +294 -0
- package/dist/schedules/scheduled-tasks.service.d.ts +362 -0
- package/dist/schedules/scheduled-tasks.service.js +1253 -0
- package/dist/schedules/schedules.controller.d.ts +72 -0
- package/dist/schedules/schedules.controller.js +256 -0
- package/dist/schedules/schedules.module.d.ts +16 -0
- package/dist/schedules/schedules.module.js +61 -0
- package/dist/schedules/schedules.schemas.d.ts +351 -0
- package/dist/schedules/schedules.schemas.js +213 -0
- package/dist/schedules/store.d.ts +86 -0
- package/dist/schedules/store.js +410 -0
- package/dist/schedules/store.module.d.ts +6 -0
- package/dist/schedules/store.module.js +21 -0
- package/dist/schedules/types.d.ts +110 -0
- package/dist/schedules/types.js +1 -0
- package/dist/schedules/unattended.d.ts +89 -0
- package/dist/schedules/unattended.js +189 -0
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +296 -0
- package/dist/setup/oauth-token-probe.d.ts +40 -0
- package/dist/setup/oauth-token-probe.js +96 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/skills/agent-skills.controller.d.ts +48 -0
- package/dist/skills/agent-skills.controller.js +131 -0
- package/dist/skills/agent-skills.service.d.ts +258 -0
- package/dist/skills/agent-skills.service.js +960 -0
- package/dist/skills/catalog.d.ts +84 -71
- package/dist/skills/catalog.js +152 -245
- package/dist/skills/changes.controller.d.ts +12 -22
- package/dist/skills/changes.controller.js +27 -56
- package/dist/skills/changes.service.d.ts +69 -115
- package/dist/skills/changes.service.js +249 -599
- package/dist/skills/conversation-catalog.d.ts +52 -0
- package/dist/skills/conversation-catalog.js +141 -0
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invocation-keys.d.ts +1 -1
- package/dist/skills/invocation-keys.js +1 -1
- package/dist/skills/invoke.d.ts +68 -6
- package/dist/skills/invoke.js +229 -9
- package/dist/skills/package.d.ts +15 -1
- package/dist/skills/package.js +14 -1
- package/dist/skills/skills.controller.d.ts +35 -7
- package/dist/skills/skills.controller.js +64 -11
- package/dist/skills/skills.module.js +30 -3
- package/dist/skills/skills.schemas.d.ts +44 -0
- package/dist/skills/skills.schemas.js +68 -0
- package/dist/skills/skills.service.d.ts +158 -60
- package/dist/skills/skills.service.js +640 -162
- package/dist/skills/usable.d.ts +131 -0
- package/dist/skills/usable.js +521 -0
- package/dist/storage/storage.service.js +9 -1
- package/dist/themes/render-css.d.ts +13 -0
- package/dist/themes/render-css.js +135 -0
- package/dist/themes/theme-delivery.service.d.ts +36 -0
- package/dist/themes/theme-delivery.service.js +116 -0
- package/dist/themes/theme-state.d.ts +116 -0
- package/dist/themes/theme-state.js +221 -0
- package/dist/themes/theme-usage.d.ts +61 -0
- package/dist/themes/theme-usage.js +98 -0
- package/dist/themes/themes-public.controller.d.ts +33 -0
- package/dist/themes/themes-public.controller.js +98 -0
- package/dist/themes/themes.controller.d.ts +13 -0
- package/dist/themes/themes.controller.js +38 -0
- package/dist/themes/themes.module.d.ts +3 -0
- package/dist/themes/themes.module.js +21 -0
- package/dist/themes/themes.schemas.d.ts +3 -0
- package/dist/themes/themes.schemas.js +2 -0
- package/dist/themes/themes.service.d.ts +50 -0
- package/dist/themes/themes.service.js +99 -0
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/admin-connectors.d.ts +69 -0
- package/dist/tools/admin-connectors.js +135 -0
- package/dist/tools/approvals.controller.d.ts +4 -2
- package/dist/tools/approvals.controller.js +19 -5
- package/dist/tools/approvals.schemas.d.ts +22 -0
- package/dist/tools/approvals.schemas.js +17 -0
- package/dist/tools/approvals.service.d.ts +485 -19
- package/dist/tools/approvals.service.js +1468 -34
- package/dist/tools/builtin-names.d.ts +55 -24
- package/dist/tools/builtin-names.js +97 -31
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/ask-user.js +3 -2
- package/dist/tools/builtins/builtin-tools.d.ts +17 -5
- package/dist/tools/builtins/builtin-tools.js +79 -20
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +51 -0
- package/dist/tools/builtins/platform.js +451 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +2 -2
- package/dist/tools/builtins/sandbox/bash.js +94 -34
- package/dist/tools/builtins/sandbox/common.d.ts +168 -42
- package/dist/tools/builtins/sandbox/common.js +298 -138
- package/dist/tools/builtins/sandbox/deliver.js +9 -6
- package/dist/tools/builtins/sandbox/device-code.d.ts +40 -0
- package/dist/tools/builtins/sandbox/device-code.js +57 -0
- package/dist/tools/builtins/sandbox/edit.js +48 -39
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
- package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
- package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
- package/dist/tools/builtins/sandbox/file-state.js +33 -3
- package/dist/tools/builtins/sandbox/glob.js +15 -9
- package/dist/tools/builtins/sandbox/grep.js +13 -11
- package/dist/tools/builtins/sandbox/index.d.ts +11 -5
- package/dist/tools/builtins/sandbox/index.js +15 -5
- package/dist/tools/builtins/sandbox/read.js +13 -7
- package/dist/tools/builtins/sandbox/task-list.d.ts +12 -0
- package/dist/tools/builtins/sandbox/task-list.js +130 -0
- package/dist/tools/builtins/sandbox/task-output.d.ts +54 -7
- package/dist/tools/builtins/sandbox/task-output.js +122 -25
- package/dist/tools/builtins/sandbox/task-stop.js +6 -5
- package/dist/tools/builtins/sandbox/write.js +41 -33
- package/dist/tools/builtins/schedules.d.ts +109 -0
- package/dist/tools/builtins/schedules.js +947 -0
- package/dist/tools/builtins/send-message.d.ts +56 -0
- package/dist/tools/builtins/send-message.js +100 -0
- package/dist/tools/builtins/skill-load.d.ts +74 -18
- package/dist/tools/builtins/skill-load.js +255 -61
- package/dist/tools/builtins/tool-search.d.ts +4 -7
- package/dist/tools/builtins/tool-search.js +10 -13
- package/dist/tools/builtins/web/extract.d.ts +2 -4
- package/dist/tools/builtins/web/extract.js +6 -5
- package/dist/tools/builtins/web/fetch.js +1 -0
- package/dist/tools/builtins/web/search.js +1 -0
- package/dist/tools/connector-account-policies.d.ts +86 -0
- package/dist/tools/connector-account-policies.js +220 -0
- package/dist/tools/connector-content.js +1 -0
- package/dist/tools/connectors.controller.d.ts +89 -9
- package/dist/tools/connectors.controller.js +167 -17
- package/dist/tools/connectors.schemas.d.ts +40 -0
- package/dist/tools/connectors.schemas.js +46 -0
- package/dist/tools/connectors.service.d.ts +169 -11
- package/dist/tools/connectors.service.js +421 -35
- package/dist/tools/credentials.d.ts +41 -0
- package/dist/tools/credentials.js +150 -1
- package/dist/tools/credentials.module.d.ts +7 -0
- package/dist/tools/credentials.module.js +22 -0
- package/dist/tools/device-op-resolver.d.ts +40 -0
- package/dist/tools/device-op-resolver.js +121 -0
- package/dist/tools/drift.d.ts +6 -2
- package/dist/tools/drift.js +10 -5
- package/dist/tools/elicitation.d.ts +2 -0
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/fixed-ask.d.ts +7 -0
- package/dist/tools/fixed-ask.js +9 -0
- package/dist/tools/git-asks.d.ts +113 -0
- package/dist/tools/git-asks.js +174 -0
- package/dist/tools/git-push-policy.d.ts +92 -0
- package/dist/tools/git-push-policy.js +177 -0
- package/dist/tools/info.d.ts +46 -11
- package/dist/tools/info.js +72 -22
- package/dist/tools/job-ids.d.ts +0 -4
- package/dist/tools/job-ids.js +1 -6
- package/dist/tools/network-asks.d.ts +122 -0
- package/dist/tools/network-asks.js +233 -0
- package/dist/tools/oauth/discovery.d.ts +38 -16
- package/dist/tools/oauth/discovery.js +59 -33
- package/dist/tools/oauth/flow.js +1 -1
- package/dist/tools/oauth/tokens.d.ts +54 -7
- package/dist/tools/oauth/tokens.js +87 -17
- package/dist/tools/org-tool-switches.d.ts +89 -0
- package/dist/tools/org-tool-switches.js +201 -0
- package/dist/tools/pipeline.d.ts +175 -59
- package/dist/tools/pipeline.js +846 -442
- package/dist/tools/policy.d.ts +51 -14
- package/dist/tools/policy.js +200 -60
- package/dist/tools/questions.service.d.ts +50 -9
- package/dist/tools/questions.service.js +128 -12
- package/dist/tools/registry.d.ts +196 -56
- package/dist/tools/registry.js +300 -219
- package/dist/tools/tools.module.js +42 -8
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +65 -0
- package/dist/ui/arrangement.js +171 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +42 -17
- package/dist/ui/registry.js +46 -14
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +70 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +113 -19
- package/dist/ui/views.js +257 -56
- package/package.json +6 -3
- package/src/migrations/0074_subagent_tree.sql +50 -0
- package/src/migrations/0075_plugin_scope.sql +61 -0
- package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
- package/src/migrations/0077_scope_requests.sql +52 -0
- package/src/migrations/0078_scope_grant_switches.sql +18 -0
- package/src/migrations/0079_scope_live_install_switches.sql +19 -0
- package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
- package/src/migrations/0081_platform_components.sql +129 -0
- package/src/migrations/0082_platform_migration.sql +33 -0
- package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
- package/src/migrations/0084_org_owned_items.sql +85 -0
- package/src/migrations/0085_agent_templates_phase4.sql +45 -0
- package/src/migrations/0086_org_layering.sql +30 -0
- package/src/migrations/0087_approval_summary.sql +6 -0
- package/src/migrations/0088_environments.sql +80 -0
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/src/migrations/0093_connected_environments.sql +37 -0
- package/src/migrations/0094_environment_paths_idx.sql +7 -0
- package/src/migrations/0095_environment_files_resets.sql +5 -0
- package/src/migrations/0096_environment_demoted_default.sql +18 -0
- package/src/migrations/0097_extension_installs_enabled_at.sql +16 -0
- package/src/migrations/0098_single_provider_running_first.sql +41 -0
- package/src/migrations/0099_channel_connection_guide_ack.sql +6 -0
- package/src/migrations/0100_catalog_files.sql +13 -0
- package/src/migrations/0101_marketplace_icons.sql +32 -0
- package/src/migrations/0102_themes.sql +64 -0
- package/src/migrations/0103_ui_theme_setting.sql +7 -0
- package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/src/migrations/0107_extension_client_builds.sql +50 -0
- package/src/migrations/0108_question_skipped.sql +6 -0
- package/src/migrations/0109_audit_platform_idx.sql +5 -0
- package/src/migrations/0110_usage_time_idx.sql +8 -0
- package/src/migrations/0111_agent_skill_sharing.sql +22 -0
- package/src/migrations/0112_skill_share_requests.sql +4 -0
- package/src/migrations/0113_scheduled_tasks.sql +108 -0
- package/src/migrations/0114_network_asks.sql +23 -0
- package/src/migrations/0115_network_requests.sql +28 -0
- package/src/migrations/0116_skills_default_on.sql +37 -0
- package/src/migrations/0117_sandbox_tiers.sql +11 -0
- package/src/migrations/0118_device_policy_ops.sql +6 -0
- package/src/migrations/0119_outbox.sql +22 -0
- package/src/migrations/0120_drop_usage_report_sweep.sql +7 -0
- package/src/migrations/0121_drop_platform_migration_runs.sql +12 -0
- package/src/migrations/0122_drop_scheduled_task_runs_rechecked_at.sql +5 -0
- package/src/migrations/0123_pgvector.sql +27 -0
- package/src/migrations/0124_conversation_source.sql +36 -0
- package/src/migrations/0125_conversation_tree_stopped_at.sql +5 -0
- package/src/migrations/0126_git_gateway.sql +10 -0
- package/src/migrations/0127_git_push_policy.sql +12 -0
- package/src/migrations/0128_scheduled_task_plugin_disabled.sql +10 -0
- package/src/migrations/0129_connector_plugin_disabled.sql +5 -0
- package/src/migrations/0130_auto_mode.sql +48 -0
- package/src/migrations/0131_device_mode.sql +9 -0
- package/src/migrations/0132_compact_runs.sql +6 -0
- package/src/migrations/0133_project_root.sql +30 -0
- package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
- package/src/migrations/0135_run_execution_claim.sql +2 -0
- package/src/migrations/0136_run_recovery_cursor.sql +6 -0
- package/src/migrations/0137_audit_org_idx.sql +5 -0
- package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
- package/src/migrations/0139_retire_legacy_forms.sql +183 -0
- package/src/migrations/0140_retire_history_forms.sql +148 -0
- package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
- package/src/migrations/0142_backfill_event_fields.sql +74 -0
- package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
- package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
- package/src/migrations/0145_org_network_allowances.sql +12 -0
- package/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/job-ids.d.ts +0 -6
- package/dist/conversations/job-ids.js +0 -6
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/job-ids.d.ts +0 -6
- package/dist/extensions/job-ids.js +0 -6
- package/dist/extensions/org-config.controller.d.ts +0 -32
- package/dist/extensions/org-config.controller.js +0 -70
- package/dist/infra/queue/retired-schedulers.d.ts +0 -7
- package/dist/infra/queue/retired-schedulers.js +0 -9
- package/dist/orgs/job-ids.d.ts +0 -8
- package/dist/orgs/job-ids.js +0 -8
- package/dist/runtime/context/legacy-text.d.ts +0 -22
- package/dist/runtime/context/legacy-text.js +0 -37
- package/dist/runtime/job-ids.d.ts +0 -10
- package/dist/runtime/job-ids.js +0 -10
- package/dist/runtime/retired-schedulers.d.ts +0 -7
- package/dist/runtime/retired-schedulers.js +0 -31
- package/dist/storage/job-ids.d.ts +0 -6
- package/dist/storage/job-ids.js +0 -6
- package/dist/tools/builtins/skill-write.d.ts +0 -59
- package/dist/tools/builtins/skill-write.js +0 -244
- package/dist/tools/legacy-data.d.ts +0 -34
- package/dist/tools/legacy-data.js +0 -76
- package/dist/tools/legacy-keys.d.ts +0 -51
- package/dist/tools/legacy-keys.js +0 -115
package/dist/tools/pipeline.js
CHANGED
|
@@ -7,38 +7,53 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
|
-
import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
13
12
|
import { EventLog } from "../conversations/event-log.js";
|
|
14
|
-
import { ToolViewSchema } from "../conversations/events.js";
|
|
13
|
+
import { COMMAND_ASK_MAX_CHARS, COMMAND_ASK_TEXT_MAX_CHARS, ToolViewSchema, } from "../conversations/events.js";
|
|
14
|
+
import { ConversationDevices } from "../devices/conversation-devices.js";
|
|
15
|
+
import { pathAgainstWorkingRoot } from "../devices/working-root.js";
|
|
16
|
+
import { ApiError } from "../errors.js";
|
|
17
|
+
import { EffectiveConfigs, NEEDS_CONFIG_REASON } from "../extensions/effective-config.js";
|
|
15
18
|
import { clipText } from "../extensions/hooks.js";
|
|
16
19
|
import { ExtensionHost } from "../extensions/host.js";
|
|
17
20
|
import { ExtensionUnloadedError, PLUGIN_UNLOADED_TOOL_ERROR } from "../extensions/inflight.js";
|
|
18
21
|
import { audit } from "../identity/audit.js";
|
|
22
|
+
import { sha256Hex } from "../identity/hash.js";
|
|
19
23
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
20
24
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
21
25
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
22
26
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
23
27
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
28
|
+
import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
29
|
+
import { NetworkGrants } from "../local-devices/network-grants.js";
|
|
24
30
|
import { UNKNOWN_RESULT_TEXT } from "../runtime/context/pairing.js";
|
|
25
31
|
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../runtime/hook-calls.js";
|
|
26
|
-
import {
|
|
27
|
-
import { assistantIdemKey,
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
32
|
+
import { subagentWaitingIdemKey } from "../runtime/loop.js";
|
|
33
|
+
import { assistantIdemKey, MAX_STEP_MODEL_CALLS, modelCallIdemKey } from "../runtime/model-call.js";
|
|
34
|
+
import { rootSurfaceOf } from "../runtime/subagents/child.js";
|
|
35
|
+
import { SubagentMessages } from "../runtime/subagents/messages.js";
|
|
36
|
+
import { pairStoppedForks } from "../runtime/subagents/skill-fork.js";
|
|
31
37
|
import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
38
|
+
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
39
|
+
import { isSessionGrantableRule, } from "../sandbox/review/index.js";
|
|
40
|
+
import { CommandReviewService } from "../sandbox/review/review.service.js";
|
|
41
|
+
import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRunOf, } from "../schedules/unattended.js";
|
|
32
42
|
import { skillLoadOfferedIn } from "../skills/catalog.js";
|
|
33
|
-
import { ApprovalsService } from "./approvals.service.js";
|
|
43
|
+
import { ApprovalsService, } from "./approvals.service.js";
|
|
34
44
|
import { Breaker, breakerOpenMessage } from "./breaker.js";
|
|
35
|
-
import { TOOL_SEARCH } from "./builtin-names.js";
|
|
36
|
-
import {
|
|
45
|
+
import { SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
|
|
46
|
+
import { AGENT_TOOL, AgentToolInput } from "./builtins/agent.js";
|
|
47
|
+
import { HandbackInput } from "./builtins/handback.js";
|
|
48
|
+
import { DEVICE_CODE_PATTERN, deviceCodeIdemKey, GITHUB_DEVICE_LOGIN_URL, } from "./builtins/sandbox/device-code.js";
|
|
49
|
+
import { SendMessageInput } from "./builtins/send-message.js";
|
|
37
50
|
import { isAlwaysLoaded, notLoadedText } from "./builtins/tool-search.js";
|
|
51
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
38
52
|
import { CredentialMissing, Credentials } from "./credentials.js";
|
|
39
53
|
import { ToolDrift } from "./drift.js";
|
|
40
54
|
import { ElicitationSession } from "./elicitation.js";
|
|
41
|
-
import {
|
|
55
|
+
import { blockedEventHosts, clipKept, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, planNetworkAsk, settledNetworkNotes, withNetworkNotes, } from "./network-asks.js";
|
|
56
|
+
import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
|
|
42
57
|
import { renderResult, resolveOutputRefs, spillIfLarge, ToolOutputs } from "./outputs.js";
|
|
43
58
|
import { createDecidePolicy } from "./policy.js";
|
|
44
59
|
import { QuestionsService } from "./questions.service.js";
|
|
@@ -51,47 +66,84 @@ import { validateInput } from "./validate.js";
|
|
|
51
66
|
export const APPROVAL_DENIED_TEXT = "The user denied this tool call.";
|
|
52
67
|
/**
|
|
53
68
|
* The denied call's result when the approver gave a reason (model-visible, in the log). "An
|
|
54
|
-
* approver": under role escalation an admin, not the requester, decides.
|
|
55
|
-
* they recorded ("The user denied this tool call. Reason: …"); only new denials use this one.
|
|
69
|
+
* approver": under role escalation an admin, not the requester, decides.
|
|
56
70
|
*/
|
|
57
71
|
export const approvalDeniedText = (reason) => reason === null ? APPROVAL_DENIED_TEXT : `An approver denied this tool call. Reason: ${reason}`;
|
|
58
72
|
/** 审批超时(按拒绝)。 */
|
|
59
73
|
export const approvalExpiredText = (hours) => `Approval timed out after ${hours}h; treated as denied.`;
|
|
60
74
|
/** 等待审批期间 run 被中止。 */
|
|
61
75
|
export const APPROVAL_CANCELLED_TEXT = "The run was stopped while waiting for approval.";
|
|
76
|
+
/**
|
|
77
|
+
* The command review's deny text (auto mode spec §5.4, P-D12): the model-visible reason and what it
|
|
78
|
+
* can do instead. `kind` says whether a shell command or a file write was held.
|
|
79
|
+
*/
|
|
80
|
+
export const commandDeniedText = (reason, kind) => kind === "write"
|
|
81
|
+
? `This write is blocked by review: ${reason}. Write it another way or ask the user to allow it.`
|
|
82
|
+
: `Command blocked by review: ${reason}. Do the work another way or ask the user to run it.`;
|
|
83
|
+
/**
|
|
84
|
+
* A command (or write) the review held in an unattended run: no one can answer, so it is a deny at
|
|
85
|
+
* once — no approval, no grant (P-D3).
|
|
86
|
+
*/
|
|
87
|
+
export const commandUnattendedText = (reason, kind) => kind === "write"
|
|
88
|
+
? `This write needs approval (${reason}), and no one can approve it now; do it another way or leave it for the person.`
|
|
89
|
+
: `This command needs approval (${reason}), and no one can approve it now; do the work another way or leave it for the person.`;
|
|
90
|
+
/**
|
|
91
|
+
* A command longer than the ask ceiling (`COMMAND_ASK_MAX_CHARS`): it cannot be shown for approval,
|
|
92
|
+
* and an approval must bind the whole text, so the call is refused before any approval exists.
|
|
93
|
+
*/
|
|
94
|
+
export const commandTooLongReason = (chars) => `The command is ${chars} characters long; commands over ${COMMAND_ASK_MAX_CHARS} are too long to review and approve.`;
|
|
95
|
+
/** The model-visible result of a command over the ask ceiling (actionable, English). */
|
|
96
|
+
export const commandTooLongText = (chars) => `This command is too long to review (${chars} characters; the limit is ${COMMAND_ASK_MAX_CHARS}). Split it into shorter commands; long inline scripts are reviewed as code the review cannot read.`;
|
|
97
|
+
/** The person declined a held command or write (P-D12); `reason` is what they said, if anything. */
|
|
98
|
+
export const commandDeclinedText = (reason, kind) => {
|
|
99
|
+
const what = kind === "write" ? "this write" : "to run this command";
|
|
100
|
+
return reason === null
|
|
101
|
+
? `The user declined ${what}. Continue without it or ask the user.`
|
|
102
|
+
: `The user declined ${what}: ${reason}. Continue without it or ask the user.`;
|
|
103
|
+
};
|
|
62
104
|
/** 等待用户输入期间 run 被中止。 */
|
|
63
105
|
export const INPUT_CANCELLED_TEXT = "The run was stopped while waiting for user input.";
|
|
106
|
+
/**
|
|
107
|
+
* The result of an `AskUserQuestion` call whose question the user skipped by sending a message
|
|
108
|
+
* (reply-while-question spec §7.1): the message follows in the log as an ordinary user message.
|
|
109
|
+
*/
|
|
110
|
+
export const QUESTION_SKIPPED_TEXT = "The user did not answer this question and sent a message instead; read it below and continue.";
|
|
111
|
+
/** The result of any other tool's input request (extension `input_required`, MCP elicitation) skipped by a message. */
|
|
112
|
+
export const INPUT_SKIPPED_TEXT = "The user did not provide the requested input and sent a message instead; read it below and continue. Call the tool again only if it is still needed.";
|
|
64
113
|
/** 同一调用连续请求输入超过上限。 */
|
|
65
114
|
export const TOO_MANY_INPUT_REQUESTS_TEXT = "Tool requested user input too many times.";
|
|
66
115
|
/** run 已被中止 / 到达截止时间,调用尚未开始执行。 */
|
|
67
116
|
export const RUN_STOPPED_TEXT = "The run was stopped before this tool call was executed.";
|
|
68
117
|
/** 调用执行中 run 被中止 / 到达截止时间。 */
|
|
69
118
|
export const RUN_STOPPED_DURING_TEXT = "The run was stopped while this tool call was running; its outcome is unknown. Verify before retrying.";
|
|
119
|
+
/** The fixed result of a call whose input request was skipped by a message (spec §7.1). */
|
|
120
|
+
const skippedResult = (toolKey) => toolKey === "AskUserQuestion"
|
|
121
|
+
? {
|
|
122
|
+
content: QUESTION_SKIPPED_TEXT,
|
|
123
|
+
isError: false,
|
|
124
|
+
display: {
|
|
125
|
+
summary: {
|
|
126
|
+
zh: "用户没有回答,直接发了消息",
|
|
127
|
+
en: "User sent a message instead of answering",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
: {
|
|
132
|
+
content: INPUT_SKIPPED_TEXT,
|
|
133
|
+
isError: true,
|
|
134
|
+
display: {
|
|
135
|
+
summary: { zh: "用户没有提供输入,直接发了消息", en: "User sent a message instead" },
|
|
136
|
+
},
|
|
137
|
+
};
|
|
70
138
|
const timeoutText = (key, ms) => `Tool ${key} timed out after ${ms / 1000}s. The operation may or may not have completed; verify before retrying.`;
|
|
71
139
|
const failedText = (key, errName) => `Tool ${key} failed (${errName}). The operation may not have completed; check before retrying or try another approach.`;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* before the rename (spec §9; a builtin maps without a scope)?
|
|
75
|
-
*/
|
|
76
|
-
const isAgentCallKey = (key) => key === AGENT_TOOL || legacyToolKey(key) === AGENT_TOOL;
|
|
77
|
-
/** The connector slugs and extension names among the run's tools (to read old `<x>__<tool>` keys). */
|
|
78
|
-
const legacyScopeOf = (tools) => {
|
|
79
|
-
const connectorSlugs = new Set();
|
|
80
|
-
const extensionNames = new Set();
|
|
81
|
-
for (const t of tools) {
|
|
82
|
-
const p = parseToolKey(t.key);
|
|
83
|
-
if (p?.kind === "connector")
|
|
84
|
-
connectorSlugs.add(p.slug);
|
|
85
|
-
else if (p?.kind === "extension")
|
|
86
|
-
extensionNames.add(p.plugin);
|
|
87
|
-
}
|
|
88
|
-
return { connectorSlugs, extensionNames };
|
|
89
|
-
};
|
|
90
|
-
const unknownToolText = (name, keys, toolSearch, hint = null) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
|
|
91
|
-
(toolSearch ? " Use ToolSearch to load other tools." : "") +
|
|
92
|
-
(hint === null ? "" : ` ${hint}`);
|
|
140
|
+
const unknownToolText = (name, keys, toolSearch) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
|
|
141
|
+
(toolSearch ? " Use ToolSearch to load other tools." : "");
|
|
93
142
|
const unavailableText = (name, reason) => `Tool "${name}" is unavailable: ${reason}.`;
|
|
94
|
-
|
|
143
|
+
/** With a per-call policy key (`Platform:<operation>`), the text names it. */
|
|
144
|
+
const deniedText = (key, policyKey) => policyKey === undefined || policyKey === key
|
|
145
|
+
? `Tool ${key} is denied by policy.`
|
|
146
|
+
: `Tool ${key} is denied by policy for ${policyKey}.`;
|
|
95
147
|
/** Longest hook reason quoted in {@link hookDeniedText}. */
|
|
96
148
|
const HOOK_REASON_MAX = 500;
|
|
97
149
|
/**
|
|
@@ -105,8 +157,41 @@ const personalMissingText = (connectorName) => `The user has not connected ${con
|
|
|
105
157
|
const orgMissingText = (connectorName) => `${connectorName} has no organization credential configured; ask an organization admin to set it up.`;
|
|
106
158
|
/** Optional provider: the pipeline's {@link ToolPipelineHooks} (tests). */
|
|
107
159
|
export const TOOL_PIPELINE_HOOKS = Symbol("TOOL_PIPELINE_HOOKS");
|
|
108
|
-
/**
|
|
109
|
-
|
|
160
|
+
/**
|
|
161
|
+
* The tools the command review covers (auto mode spec §5.1): the shell and the file tools whose
|
|
162
|
+
* writes may leave the workspace. Any other tool call is not reviewed (the review service answers
|
|
163
|
+
* `allow` for it too; the pipeline skips the facts read).
|
|
164
|
+
*/
|
|
165
|
+
const REVIEWED_TOOL_KEYS = new Set(["Bash", "Write", "Edit"]);
|
|
166
|
+
/** Whether the review holds a shell command or a file write, for the texts and the ask's detail. */
|
|
167
|
+
const reviewKindOf = (toolKey) => toolKey === "Bash" ? "command" : "write";
|
|
168
|
+
/**
|
|
169
|
+
* The working root a reviewed call carries to its tool: a project root only. In free mode the
|
|
170
|
+
* reviewed root is the recorded workspace, which may be stale; the tool then maps it to the held
|
|
171
|
+
* instance's own workspace as it always has.
|
|
172
|
+
*/
|
|
173
|
+
const carriedRoot = (facts) => facts.workingRoot !== undefined && facts.workingRoot !== facts.workspace
|
|
174
|
+
? facts.workingRoot
|
|
175
|
+
: undefined;
|
|
176
|
+
/** The review record of an allowed call. */
|
|
177
|
+
const allowRecord = (v) => ({
|
|
178
|
+
decision: "allow",
|
|
179
|
+
by: v.by,
|
|
180
|
+
rule: v.rule,
|
|
181
|
+
reason: v.reason,
|
|
182
|
+
});
|
|
183
|
+
/** The review record of a denied call (the rule table's, the classifier's or a person's). */
|
|
184
|
+
const denyRecord = (by, rule, reason) => ({
|
|
185
|
+
decision: "deny",
|
|
186
|
+
by,
|
|
187
|
+
rule,
|
|
188
|
+
reason,
|
|
189
|
+
});
|
|
190
|
+
/** A string field of a validated tool input, or "" (never another type). */
|
|
191
|
+
const textField = (input, field) => {
|
|
192
|
+
const v = input?.[field];
|
|
193
|
+
return typeof v === "string" ? v : "";
|
|
194
|
+
};
|
|
110
195
|
const approvalAuthorization = (a) => ({
|
|
111
196
|
approvalId: a.id,
|
|
112
197
|
approvedByAccountId: a.decidedBy,
|
|
@@ -155,6 +240,59 @@ function withNotes(result, notes) {
|
|
|
155
240
|
content: [...content, ...notes.map((text) => ({ type: "text", text }))],
|
|
156
241
|
};
|
|
157
242
|
}
|
|
243
|
+
/** A network ask's kept display fields, written with its result when the ask settles. */
|
|
244
|
+
const keptExtras = (kept) => ({
|
|
245
|
+
...(kept?.outputId !== undefined && { outputId: kept.outputId }),
|
|
246
|
+
...(kept?.contentTypes !== undefined && { contentTypes: kept.contentTypes }),
|
|
247
|
+
...(kept?.display !== undefined && { display: kept.display }),
|
|
248
|
+
...(kept?.view !== undefined && { view: kept.view }),
|
|
249
|
+
});
|
|
250
|
+
/** A builtin result's kernel-internal network report (see `BuiltinResult.networkReport`). */
|
|
251
|
+
function networkReportOf(result) {
|
|
252
|
+
const r = result?.networkReport;
|
|
253
|
+
if (r === undefined || typeof r.deviceId !== "string" || !Array.isArray(r.blocked)) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
const blocked = r.blocked.filter((b) => typeof b === "object" &&
|
|
257
|
+
b !== null &&
|
|
258
|
+
typeof b.host === "string" &&
|
|
259
|
+
typeof b.port === "number" &&
|
|
260
|
+
["device", "org", "address", "unknown"].includes(b.layer));
|
|
261
|
+
return blocked.length === 0 ? undefined : { deviceId: r.deviceId, blocked };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* A kernel-internal device code (see `BuiltinResult.loginCode` and `KeptToolResult.loginCode`):
|
|
265
|
+
* the shape is checked again here so a malformed value never reaches the log (the event schema
|
|
266
|
+
* would throw).
|
|
267
|
+
*/
|
|
268
|
+
function validLoginCode(v) {
|
|
269
|
+
const r = v;
|
|
270
|
+
if (r == null ||
|
|
271
|
+
typeof r.url !== "string" ||
|
|
272
|
+
typeof r.code !== "string" ||
|
|
273
|
+
r.url !== GITHUB_DEVICE_LOGIN_URL ||
|
|
274
|
+
!DEVICE_CODE_PATTERN.test(r.code)) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
return { url: r.url, code: r.code };
|
|
278
|
+
}
|
|
279
|
+
/** A builtin result's kernel-internal device code (`{ loginCode: { url, code } }`). */
|
|
280
|
+
function loginCodeOf(result) {
|
|
281
|
+
return validLoginCode(result?.loginCode);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The display-only `device_code` event of the call whose output carried the code (auto mode spec
|
|
285
|
+
* §6, P-D13). The key is per (run, call), so a retry of that call appends it once; a different
|
|
286
|
+
* call with the same code is deduplicated by value (`EventLog.deviceCodeShown`).
|
|
287
|
+
*/
|
|
288
|
+
function deviceCodeEvent(runId, step, callId, code) {
|
|
289
|
+
return {
|
|
290
|
+
type: "device_code",
|
|
291
|
+
runId,
|
|
292
|
+
idemKey: deviceCodeIdemKey(runId, callId),
|
|
293
|
+
payload: { step, callId, ...code },
|
|
294
|
+
};
|
|
295
|
+
}
|
|
158
296
|
/** 审批的等待时长(小时,四舍五入,至少 1)。 */
|
|
159
297
|
const approvalHours = (a) => Math.max(1, Math.round((new Date(a.expiresAt).getTime() - new Date(a.createdAt).getTime()) / 3_600_000));
|
|
160
298
|
const approvalWait = (a) => ({
|
|
@@ -181,9 +319,15 @@ let ToolPipeline = class ToolPipeline {
|
|
|
181
319
|
deps;
|
|
182
320
|
constructor(kdb, eventLog,
|
|
183
321
|
/** The `Agent` tool's sub-agent dispatch; absent (tests): `Agent` calls are refused. */
|
|
184
|
-
subagents,
|
|
322
|
+
subagents,
|
|
323
|
+
/** The message tools between agents; absent (tests): their calls are refused. */
|
|
324
|
+
messages, registry, credentials, breaker, outputs, approvals, questions, config, log,
|
|
185
325
|
/** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
|
|
186
|
-
host, drift, txHost, hooks
|
|
326
|
+
host, drift, effective, switches, txHost, hooks, networkGrants, devicePolicy,
|
|
327
|
+
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
328
|
+
review,
|
|
329
|
+
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
|
330
|
+
devices) {
|
|
187
331
|
this.config = config;
|
|
188
332
|
this.txHost = txHost;
|
|
189
333
|
this.deps = {
|
|
@@ -202,19 +346,29 @@ let ToolPipeline = class ToolPipeline {
|
|
|
202
346
|
get pluginHooks() {
|
|
203
347
|
return host?.hooks;
|
|
204
348
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
349
|
+
effective,
|
|
350
|
+
switches,
|
|
351
|
+
inlineViews: (plugin) => new Set((host?.current(plugin)?.ui ?? [])
|
|
352
|
+
.filter((r) => r.slot.id === "conversation.tool-result.card")
|
|
353
|
+
.map((r) => r.contribution.id)),
|
|
208
354
|
onToolsChanged: (orgId, connectorId) => {
|
|
209
355
|
void drift?.onToolsChanged(orgId, connectorId);
|
|
210
356
|
},
|
|
211
357
|
get subagents() {
|
|
212
358
|
return subagents ? { dispatch: (a) => subagents.dispatch(a) } : undefined;
|
|
213
359
|
},
|
|
360
|
+
messages,
|
|
361
|
+
review,
|
|
362
|
+
devices,
|
|
363
|
+
network: networkGrants && devicePolicy
|
|
364
|
+
? { grants: networkGrants, devices: devicePolicy }
|
|
365
|
+
: undefined,
|
|
214
366
|
};
|
|
215
367
|
const decide = hooks?.decidePolicy;
|
|
216
368
|
// the default policy reads live, on the context's handle
|
|
217
|
-
this.decide =
|
|
369
|
+
this.decide =
|
|
370
|
+
decide ??
|
|
371
|
+
((tool, def, c) => createDecidePolicy(kdb.db, log.debug && { debug: log.debug.bind(log) })(tool, def, c));
|
|
218
372
|
}
|
|
219
373
|
/**
|
|
220
374
|
* tools 节点:按顺序处理本步 assistant 消息里的全部 `tool_call`,每个调用都以一条 `tool_result` 结束
|
|
@@ -223,12 +377,21 @@ let ToolPipeline = class ToolPipeline {
|
|
|
223
377
|
* 某个调用需要等人处理(审批 / 用户输入)→ 返回 `suspended`,之后的调用留到续跑时处理;
|
|
224
378
|
* 续跑时重新进入本函数,按 PG 里的审批 / 输入请求结果继续。
|
|
225
379
|
*/
|
|
226
|
-
async runStep(
|
|
380
|
+
async runStep(given) {
|
|
381
|
+
let ctx = given;
|
|
227
382
|
const { eventLog } = this.deps;
|
|
228
383
|
const msg = await eventLog.findByIdem(ctx.conversationId, assistantIdemKey(ctx.runId, ctx.step));
|
|
229
384
|
if (msg?.type !== "assistant_message")
|
|
230
385
|
return { kind: "done" };
|
|
231
386
|
const calls = msg.payload.content.flatMap((b) => b.type === "tool_call" ? [{ id: b.id, name: b.name, input: b.input }] : []);
|
|
387
|
+
// scheduled tasks spec §7: read live for each step (a person's message absorbed since makes the
|
|
388
|
+
// rest of the run attended)
|
|
389
|
+
if (calls.length > 0 && ctx.unattended === undefined) {
|
|
390
|
+
ctx = {
|
|
391
|
+
...ctx,
|
|
392
|
+
unattended: await unattendedRunOf(this.deps.db, this.config, ctx.orgId, ctx.runId),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
232
395
|
let resolved;
|
|
233
396
|
const resolve = async () => {
|
|
234
397
|
// 每步实时解析(连接器 / 插件状态可能在模型调用之后变化)
|
|
@@ -237,325 +400,41 @@ let ToolPipeline = class ToolPipeline {
|
|
|
237
400
|
// skill invocation in the log → Skill is offered (see skillLoadOffered)
|
|
238
401
|
const skillLoad = await skillLoadOfferedIn(this.deps.db, this.deps.eventLog, ctx.conversationId);
|
|
239
402
|
resolved = await this.deps.registry.forAgent(ctx.orgId, {
|
|
240
|
-
|
|
403
|
+
disabledTools: ctx.agent.disabledTools,
|
|
404
|
+
subagentTools: ctx.agent.subagentTools,
|
|
241
405
|
skillLoad,
|
|
242
406
|
subagents: ctx.agent.subagents,
|
|
407
|
+
child: ctx.parent !== undefined,
|
|
408
|
+
forkChild: ctx.parent?.forSkill === true,
|
|
409
|
+
sandboxConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
|
|
410
|
+
replay: ctx.conversationKind === "eval",
|
|
411
|
+
source: ctx.source,
|
|
243
412
|
});
|
|
244
413
|
}
|
|
245
414
|
return resolved;
|
|
246
415
|
};
|
|
247
|
-
// `Agent`
|
|
248
|
-
//
|
|
249
|
-
let open = 0;
|
|
416
|
+
// an `Agent` call's dispatch writes its result (the sub-agent runs in the background, agent
|
|
417
|
+
// map spec §4.1), so no call keeps the step waiting on a sub-agent
|
|
250
418
|
for (const call of calls) {
|
|
251
419
|
if (await eventLog.findByIdem(ctx.conversationId, idem.result(ctx.runId, call.id)))
|
|
252
420
|
continue;
|
|
253
|
-
if (isAgentCallKey(call.name)) {
|
|
254
|
-
const row = await dispatchOfCall(this.deps.db, ctx.runId, call.id);
|
|
255
|
-
if (row) {
|
|
256
|
-
if (!(await this.finishAgentCall(ctx, row, call, resolve)))
|
|
257
|
-
open++;
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
421
|
const waitingFor = await this.processCall(ctx, call, resolve);
|
|
262
|
-
if (waitingFor
|
|
263
|
-
open++;
|
|
264
|
-
else if (waitingFor)
|
|
422
|
+
if (waitingFor)
|
|
265
423
|
return { kind: "suspended", waitingFor };
|
|
266
424
|
}
|
|
267
|
-
if (open > 0) {
|
|
268
|
-
// the run is being stopped (a person, its deadline): it does not wait for its sub-agents;
|
|
269
|
-
// their calls get their results now, and the children are stopped after the run's terminal
|
|
270
|
-
// commit (spec §12)
|
|
271
|
-
if (ctx.signal.aborted) {
|
|
272
|
-
const stopped = await this.stopOpenAgentCallsNow(ctx.runId, ctx.agent);
|
|
273
|
-
if (stopped.toSeq !== null) {
|
|
274
|
-
await eventLog.notify(ctx.conversationId, stopped.toSeq);
|
|
275
|
-
}
|
|
276
|
-
stopped.fire();
|
|
277
|
-
return { kind: "done" };
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
kind: "suspended",
|
|
281
|
-
waitingFor: subagentsWait(ctx.runId, ctx.step, this.config.get()),
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
425
|
return { kind: "done" };
|
|
285
426
|
}
|
|
286
427
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* dispatch time is not recorded, so nothing is guessed) and fires `tool.postExecute` with the
|
|
294
|
-
* result, from the replica that writes it (spec §11).
|
|
428
|
+
* Writes, in the caller's transaction (`mandatory`), what a run that is being stopped (a person,
|
|
429
|
+
* its deadline, a failure, an orphan repair) still owes its log: the report of its fork invocation
|
|
430
|
+
* (phase D, `pairStoppedForks`; a still active fork child is stopped by the caller after its
|
|
431
|
+
* commit). An `Agent` call has its result from its dispatch (agent map spec §4.1), so there is
|
|
432
|
+
* nothing to write for it. Returns the fork's call id (the caller must not write a "not executed"
|
|
433
|
+
* result for it), the highest seq written, and `fire`, a no-op kept for the callers' hook phase.
|
|
295
434
|
*/
|
|
296
|
-
async
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
call.input.model !== undefined;
|
|
300
|
-
const r = await childResult(this.deps.eventLog, row, { modelGiven });
|
|
301
|
-
if (!r)
|
|
302
|
-
return false;
|
|
303
|
-
// No spec-hash check as in processCall: an `Agent` call writes no tool_call_started holding
|
|
304
|
-
// the executed definition's hash, and its description changes with the roster and limits
|
|
305
|
-
// while the child runs. The call's approval (forCall: its latest) is by construction the one
|
|
306
|
-
// that let this dispatch start, since a dispatch happens only after an approved decision.
|
|
307
|
-
const approval = await this.deps.approvals.forCall(ctx.runId, call.id);
|
|
308
|
-
// the result keeps the logged key (`agent` for a call dispatched before the rename, spec §9)
|
|
309
|
-
await this.writeResult(ctx, row.parentCallId, call.name, { content: r.content, isError: r.isError }, [finishedEvent(row, r.finished)], {
|
|
310
|
-
durationMs: r.finished.durationMs,
|
|
311
|
-
connectorId: null,
|
|
312
|
-
...(approval?.status === "approved" && {
|
|
313
|
-
authorization: approvalAuthorization(approval),
|
|
314
|
-
}),
|
|
315
|
-
});
|
|
316
|
-
const hooks = this.deps.pluginHooks;
|
|
317
|
-
const scope = hookScope(hooks, ctx);
|
|
318
|
-
if (hooks && scope && hooks.has("tool.postExecute")) {
|
|
319
|
-
const tool = (await resolve()).tools.find((t) => t.key === AGENT_TOOL);
|
|
320
|
-
if (tool) {
|
|
321
|
-
fireObserve(hooks, "tool.postExecute", {
|
|
322
|
-
...scope,
|
|
323
|
-
step: ctx.step,
|
|
324
|
-
callId: call.id,
|
|
325
|
-
toolKey: AGENT_TOOL,
|
|
326
|
-
specHash: tool.specHash,
|
|
327
|
-
input: call.input,
|
|
328
|
-
isError: r.isError,
|
|
329
|
-
content: r.content,
|
|
330
|
-
durationMs: r.finished.durationMs,
|
|
331
|
-
}, ctx.signal, this.deps.log);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
/** {@link stopOpenAgentCalls} in a transaction of its own (a stop seen by the tools node). */
|
|
337
|
-
async stopOpenAgentCallsNow(runId, agent) {
|
|
338
|
-
return this.stopOpenAgentCalls(runId, agent);
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Writes, in the caller's transaction (`mandatory`), the `tool_result` of every open `Agent` call
|
|
342
|
-
* of a run that is being stopped
|
|
343
|
-
* (sub-agents spec §12: a person stopped it while it waited on sub-agents, or its deadline or a
|
|
344
|
-
* stop hit its tools node after a dispatch). A call whose child already ended gets the child's
|
|
345
|
-
* result (and the missing `subagent_finished`); one whose child is still active gets
|
|
346
|
-
* {@link AGENT_STOPPED_WITH_RUN_TEXT}. The caller stops those children after its commit.
|
|
347
|
-
*
|
|
348
|
-
* Like every `Agent` result (see {@link finishAgentCall}), each is audited `tool.called` in it
|
|
349
|
-
* (duration: the child's, or the time since the dispatch) and fires `tool.postExecute`, through
|
|
350
|
-
* `fire()`, which the caller runs after its commit. Returns the steps and calls written (the
|
|
351
|
-
* caller must not write a "not executed" result for them) and the highest seq written.
|
|
352
|
-
*/
|
|
353
|
-
async stopOpenAgentCalls(runId, agent) {
|
|
354
|
-
const t = this.deps.db;
|
|
355
|
-
// phase D: the run's fork invocation without a report gets one (a fork has no tool call)
|
|
356
|
-
const forks = await pairStoppedForks(t, this.deps.eventLog, runId);
|
|
357
|
-
const none = {
|
|
358
|
-
steps: [],
|
|
359
|
-
callIds: new Set(forks.callIds),
|
|
360
|
-
toSeq: forks.toSeq,
|
|
361
|
-
fire: () => { },
|
|
362
|
-
};
|
|
363
|
-
const all = await t
|
|
364
|
-
.selectFrom("subagent_dispatches")
|
|
365
|
-
.select([
|
|
366
|
-
"parent_run_id",
|
|
367
|
-
"parent_call_id",
|
|
368
|
-
"parent_conversation_id",
|
|
369
|
-
"child_conversation_id",
|
|
370
|
-
"child_run_id",
|
|
371
|
-
"step",
|
|
372
|
-
"created_at",
|
|
373
|
-
])
|
|
374
|
-
.where("parent_run_id", "=", runId)
|
|
375
|
-
.orderBy("step")
|
|
376
|
-
.orderBy("created_at")
|
|
377
|
-
.execute();
|
|
378
|
-
const dispatches = all.filter((d) => forkSeqOfCall(d.parent_call_id, d.step) === null);
|
|
379
|
-
if (dispatches.length === 0)
|
|
380
|
-
return none;
|
|
381
|
-
const run = await t
|
|
382
|
-
.selectFrom("runs as r")
|
|
383
|
-
.innerJoin("conversations as c", "c.id", "r.conversation_id")
|
|
384
|
-
.select([
|
|
385
|
-
"r.conversation_id",
|
|
386
|
-
"r.trigger_account_id",
|
|
387
|
-
"r.agent_version",
|
|
388
|
-
"c.org_id",
|
|
389
|
-
"c.agent_id",
|
|
390
|
-
"c.kind",
|
|
391
|
-
])
|
|
392
|
-
.where("r.id", "=", runId)
|
|
393
|
-
.executeTakeFirst();
|
|
394
|
-
if (!run)
|
|
395
|
-
return none;
|
|
396
|
-
const conversationId = run.conversation_id;
|
|
397
|
-
const inputs = new Map();
|
|
398
|
-
// the logged key of each call (`agent` for a call dispatched before the rename, spec §9)
|
|
399
|
-
const names = new Map();
|
|
400
|
-
const events = [];
|
|
401
|
-
const calls = [];
|
|
402
|
-
for (const d of dispatches) {
|
|
403
|
-
const written = await t
|
|
404
|
-
.selectFrom("conversation_events")
|
|
405
|
-
.select("seq")
|
|
406
|
-
.where("conversation_id", "=", conversationId)
|
|
407
|
-
.where("idem_key", "=", idem.result(runId, d.parent_call_id))
|
|
408
|
-
.executeTakeFirst();
|
|
409
|
-
if (written)
|
|
410
|
-
continue;
|
|
411
|
-
if (!inputs.has(`step:${d.step}`)) {
|
|
412
|
-
inputs.set(`step:${d.step}`, true);
|
|
413
|
-
const msg = await t
|
|
414
|
-
.selectFrom("conversation_events")
|
|
415
|
-
.select("payload")
|
|
416
|
-
.where("conversation_id", "=", conversationId)
|
|
417
|
-
.where("idem_key", "=", assistantIdemKey(runId, d.step))
|
|
418
|
-
.executeTakeFirst();
|
|
419
|
-
const content = msg?.payload?.content ?? [];
|
|
420
|
-
for (const b of content) {
|
|
421
|
-
if (b.type === "tool_call" && b.id !== undefined) {
|
|
422
|
-
inputs.set(b.id, b.input);
|
|
423
|
-
if (b.name !== undefined)
|
|
424
|
-
names.set(b.id, b.name);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
const input = inputs.get(d.parent_call_id);
|
|
429
|
-
const row = {
|
|
430
|
-
parentRunId: d.parent_run_id,
|
|
431
|
-
parentCallId: d.parent_call_id,
|
|
432
|
-
parentConversationId: d.parent_conversation_id,
|
|
433
|
-
childConversationId: d.child_conversation_id,
|
|
434
|
-
childRunId: d.child_run_id,
|
|
435
|
-
};
|
|
436
|
-
const child = await t
|
|
437
|
-
.selectFrom("runs")
|
|
438
|
-
.select("status")
|
|
439
|
-
.where("id", "=", d.child_run_id)
|
|
440
|
-
.executeTakeFirst();
|
|
441
|
-
// a child that already ended keeps its own result (its log is committed)
|
|
442
|
-
const ended = child !== undefined && TERMINAL_STATUSES.has(child.status)
|
|
443
|
-
? await childResult(this.deps.eventLog, row, {
|
|
444
|
-
modelGiven: typeof input === "object" &&
|
|
445
|
-
input !== null &&
|
|
446
|
-
input.model !== undefined,
|
|
447
|
-
})
|
|
448
|
-
: null;
|
|
449
|
-
if (ended)
|
|
450
|
-
events.push(finishedEvent(row, ended.finished));
|
|
451
|
-
const r = ended
|
|
452
|
-
? { content: ended.content, isError: ended.isError, durationMs: ended.finished.durationMs }
|
|
453
|
-
: {
|
|
454
|
-
content: AGENT_STOPPED_WITH_RUN_TEXT,
|
|
455
|
-
isError: true,
|
|
456
|
-
durationMs: Math.max(0, Date.now() - new Date(d.created_at).getTime()),
|
|
457
|
-
};
|
|
458
|
-
events.push({
|
|
459
|
-
type: "tool_result",
|
|
460
|
-
runId,
|
|
461
|
-
idemKey: idem.result(runId, d.parent_call_id),
|
|
462
|
-
payload: {
|
|
463
|
-
step: d.step,
|
|
464
|
-
callId: d.parent_call_id,
|
|
465
|
-
toolKey: names.get(d.parent_call_id) ?? AGENT_TOOL,
|
|
466
|
-
content: r.content,
|
|
467
|
-
isError: r.isError,
|
|
468
|
-
},
|
|
469
|
-
});
|
|
470
|
-
calls.push({ step: d.step, callId: d.parent_call_id, input, r });
|
|
471
|
-
}
|
|
472
|
-
if (calls.length === 0)
|
|
473
|
-
return none;
|
|
474
|
-
const written = await this.deps.eventLog.appendIn(conversationId, events);
|
|
475
|
-
for (const c of calls) {
|
|
476
|
-
const approval = await t
|
|
477
|
-
.selectFrom("approvals")
|
|
478
|
-
.select(["id", "status", "decided_by", "scope"])
|
|
479
|
-
.where("run_id", "=", runId)
|
|
480
|
-
.where("call_id", "=", c.callId)
|
|
481
|
-
.orderBy("attempt", "desc")
|
|
482
|
-
.limit(1)
|
|
483
|
-
.executeTakeFirst();
|
|
484
|
-
await audit(t, {
|
|
485
|
-
actorAccountId: run.trigger_account_id,
|
|
486
|
-
orgId: run.org_id,
|
|
487
|
-
action: "tool.called",
|
|
488
|
-
target: conversationId,
|
|
489
|
-
detail: {
|
|
490
|
-
toolKey: AGENT_TOOL,
|
|
491
|
-
isError: c.r.isError,
|
|
492
|
-
durationMs: c.r.durationMs,
|
|
493
|
-
agentId: run.agent_id,
|
|
494
|
-
agentVersion: run.agent_version,
|
|
495
|
-
conversationId,
|
|
496
|
-
runId,
|
|
497
|
-
callId: c.callId,
|
|
498
|
-
...(approval?.status === "approved" && {
|
|
499
|
-
approvalId: approval.id,
|
|
500
|
-
approvedByAccountId: approval.decided_by,
|
|
501
|
-
scope: approval.scope,
|
|
502
|
-
}),
|
|
503
|
-
},
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
const fire = () => {
|
|
507
|
-
const hooks = this.deps.pluginHooks;
|
|
508
|
-
const scope = hookScope(hooks, {
|
|
509
|
-
conversationKind: run.kind,
|
|
510
|
-
orgId: run.org_id,
|
|
511
|
-
accountId: run.trigger_account_id,
|
|
512
|
-
agentId: run.agent_id,
|
|
513
|
-
agentVersion: run.agent_version,
|
|
514
|
-
conversationId,
|
|
515
|
-
runId,
|
|
516
|
-
});
|
|
517
|
-
if (!hooks || !scope || !hooks.has("tool.postExecute"))
|
|
518
|
-
return;
|
|
519
|
-
void (async () => {
|
|
520
|
-
const def = agent ??
|
|
521
|
-
normalizeStoredDefinition((await this.deps.db
|
|
522
|
-
.selectFrom("agent_versions")
|
|
523
|
-
.select("definition")
|
|
524
|
-
.where("agent_id", "=", run.agent_id)
|
|
525
|
-
.where("version", "=", run.agent_version)
|
|
526
|
-
.executeTakeFirstOrThrow()).definition);
|
|
527
|
-
const skillLoad = await skillLoadOfferedIn(this.deps.db, this.deps.eventLog, conversationId);
|
|
528
|
-
const resolved = await this.deps.registry.forAgent(run.org_id, {
|
|
529
|
-
tools: def.tools ?? [],
|
|
530
|
-
skillLoad,
|
|
531
|
-
subagents: def.subagents,
|
|
532
|
-
});
|
|
533
|
-
const tool = resolved.tools.find((x) => x.key === AGENT_TOOL);
|
|
534
|
-
if (!tool)
|
|
535
|
-
return;
|
|
536
|
-
// the run is over: nothing aborts these observe hooks but their own timeouts
|
|
537
|
-
const signal = new AbortController().signal;
|
|
538
|
-
for (const c of calls) {
|
|
539
|
-
fireObserve(hooks, "tool.postExecute", {
|
|
540
|
-
...scope,
|
|
541
|
-
step: c.step,
|
|
542
|
-
callId: c.callId,
|
|
543
|
-
toolKey: AGENT_TOOL,
|
|
544
|
-
specHash: tool.specHash,
|
|
545
|
-
input: c.input,
|
|
546
|
-
isError: c.r.isError,
|
|
547
|
-
content: c.r.content,
|
|
548
|
-
durationMs: c.r.durationMs,
|
|
549
|
-
}, signal, this.deps.log);
|
|
550
|
-
}
|
|
551
|
-
})().catch((err) => this.deps.log.warn("cannot fire tool.postExecute for stopped agent calls", { runId, err }));
|
|
552
|
-
};
|
|
553
|
-
return {
|
|
554
|
-
steps: [...new Set(calls.map((c) => c.step))],
|
|
555
|
-
callIds: new Set([...forks.callIds, ...calls.map((c) => c.callId)]),
|
|
556
|
-
toSeq: Math.max(forks.toSeq ?? 0, ...written.map((e) => e.seq)),
|
|
557
|
-
fire,
|
|
558
|
-
};
|
|
435
|
+
async stopOpenAgentCalls(runId) {
|
|
436
|
+
const forks = await pairStoppedForks(this.deps.db, this.deps.eventLog, runId);
|
|
437
|
+
return { steps: [], callIds: new Set(forks.callIds), toSeq: forks.toSeq, fire: () => { } };
|
|
559
438
|
}
|
|
560
439
|
/**
|
|
561
440
|
* 处理一个尚无结果的调用。先看输入请求的轮次:最近一轮仍 pending → 继续等;否则本次是第
|
|
@@ -567,24 +446,68 @@ let ToolPipeline = class ToolPipeline {
|
|
|
567
446
|
const last = rounds.at(-1);
|
|
568
447
|
if (last?.status === "pending")
|
|
569
448
|
return inputWait(last);
|
|
449
|
+
// skipped by the starter's message: the kernel writes the result, the tool is not called again
|
|
450
|
+
// (spec D6: an extension would only see `answer: null`, an MCP call would be re-sent)
|
|
451
|
+
if (last?.status === "skipped") {
|
|
452
|
+
await this.writeResult(ctx, call.id, last.toolKey, skippedResult(last.toolKey));
|
|
453
|
+
return undefined;
|
|
454
|
+
}
|
|
570
455
|
const attempt = rounds.length + 1;
|
|
571
456
|
const started = await this.deps.eventLog.findByIdem(ctx.conversationId, idem.started(ctx.runId, call.id, attempt));
|
|
572
457
|
if (started?.type === "tool_call_started") {
|
|
458
|
+
// a command that ran and was refused a network host waits for the device owner (network
|
|
459
|
+
// ask-to-allow spec §6.2, P-D2): pending → wait on; settled → its kept result and the
|
|
460
|
+
// outcome's note (the command is never run again; its tool.called was audited when it ran)
|
|
461
|
+
const ask = await this.deps.approvals.networkForCall(ctx.runId, call.id);
|
|
462
|
+
if (ask !== null) {
|
|
463
|
+
const notes = settledNetworkNotes(ask, approvalHours(ask));
|
|
464
|
+
if (notes === null)
|
|
465
|
+
return approvalWait(ask);
|
|
466
|
+
const kept = ask.detail?.result;
|
|
467
|
+
// the device code the command printed is carried in the kept result: write its
|
|
468
|
+
// display-only event here too (a crash before the ask's first write, or an older kept
|
|
469
|
+
// result; the event's ids and the per-conversation code check keep it to one)
|
|
470
|
+
const keptCode = validLoginCode(kept?.loginCode);
|
|
471
|
+
const pre = keptCode !== undefined &&
|
|
472
|
+
!(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, keptCode.code))
|
|
473
|
+
? [deviceCodeEvent(ctx.runId, ctx.step, call.id, keptCode)]
|
|
474
|
+
: [];
|
|
475
|
+
await this.writeResult(ctx, call.id, call.name, {
|
|
476
|
+
...keptExtras(kept),
|
|
477
|
+
content: withNetworkNotes(kept?.content ?? UNKNOWN_RESULT_TEXT, notes),
|
|
478
|
+
isError: kept?.isError ?? true,
|
|
479
|
+
...(kept?.review !== undefined && { review: kept.review }),
|
|
480
|
+
}, pre);
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
573
483
|
// 确实开始执行过:照样审计 tool.called(耗时未知);放行依据只认批准了所执行定义的审批记录
|
|
574
484
|
const key = started.payload.toolKey;
|
|
575
485
|
const approval = await this.deps.approvals.forCall(ctx.runId, call.id);
|
|
576
486
|
const approved = approval?.status === "approved" && approval.specHash === started.payload.specHash
|
|
577
487
|
? approval
|
|
578
488
|
: null;
|
|
489
|
+
// a command that ran under the person's `command` approval: its review record and
|
|
490
|
+
// authorization survive the lost result too (the ask is the whole truth on a resume)
|
|
491
|
+
const commandAsk = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
492
|
+
const command = commandAsk?.status === "approved" ? commandAsk : null;
|
|
493
|
+
const authorization = approved !== null
|
|
494
|
+
? approvalAuthorization(approved)
|
|
495
|
+
: command !== null
|
|
496
|
+
? approvalAuthorization(command)
|
|
497
|
+
: null;
|
|
579
498
|
const source = approved ? null : (await resolve()).tools.find((t) => t.key === key)?.source;
|
|
580
|
-
await this.writeResult(ctx, call.id, key, {
|
|
499
|
+
await this.writeResult(ctx, call.id, key, {
|
|
500
|
+
content: UNKNOWN_RESULT_TEXT,
|
|
501
|
+
isError: true,
|
|
502
|
+
...(command !== null && { review: this.personAllowRecord(command) }),
|
|
503
|
+
}, [], {
|
|
581
504
|
durationMs: null,
|
|
582
505
|
connectorId: approved
|
|
583
506
|
? approved.connectorId
|
|
584
507
|
: source?.kind === "connector"
|
|
585
508
|
? source.connectorId
|
|
586
509
|
: null,
|
|
587
|
-
...(
|
|
510
|
+
...(authorization !== null && { authorization }),
|
|
588
511
|
});
|
|
589
512
|
return undefined;
|
|
590
513
|
}
|
|
@@ -601,22 +524,18 @@ let ToolPipeline = class ToolPipeline {
|
|
|
601
524
|
return this.runCall(ctx, call, await resolve(), attempt, resume);
|
|
602
525
|
}
|
|
603
526
|
async runCall(ctx, call, resolved, attempt, resume) {
|
|
604
|
-
|
|
605
|
-
|
|
527
|
+
// the command review's record for this call's result (absent: not reviewed, or no device)
|
|
528
|
+
let review;
|
|
529
|
+
const fail = async (content, key = call.name, view) => {
|
|
530
|
+
await this.writeResult(ctx, call.id, key, {
|
|
531
|
+
content,
|
|
532
|
+
isError: true,
|
|
533
|
+
...(view !== undefined && { view }),
|
|
534
|
+
...(review !== undefined && { review }),
|
|
535
|
+
});
|
|
606
536
|
return undefined;
|
|
607
537
|
};
|
|
608
|
-
|
|
609
|
-
// A call logged before the tool keys were renamed (spec 8.1): the request that issued it offered
|
|
610
|
-
// the old key. It runs as the current tool with translated input; the result keeps the logged key.
|
|
611
|
-
let legacy = false;
|
|
612
|
-
if (!tool) {
|
|
613
|
-
const next = legacyToolKey(call.name, legacyScopeOf(resolved.tools));
|
|
614
|
-
const current = next === null ? undefined : resolved.tools.find((t) => t.key === next);
|
|
615
|
-
if (current && (await this.requestToolKeys(ctx))?.has(call.name) === true) {
|
|
616
|
-
tool = current;
|
|
617
|
-
legacy = true;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
538
|
+
const tool = resolved.tools.find((t) => t.key === call.name);
|
|
620
539
|
if (!tool) {
|
|
621
540
|
const why = resolved.unavailable.find((u) => u.ref === call.name) ??
|
|
622
541
|
resolved.hidden?.find((u) => u.ref === call.name);
|
|
@@ -630,19 +549,20 @@ let ToolPipeline = class ToolPipeline {
|
|
|
630
549
|
keys = keys.filter((k) => isAlwaysLoaded(k) || sent.has(k));
|
|
631
550
|
}
|
|
632
551
|
keys.sort();
|
|
633
|
-
return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH)
|
|
552
|
+
return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH)));
|
|
634
553
|
}
|
|
635
|
-
const outKey =
|
|
554
|
+
const outKey = tool.key;
|
|
636
555
|
// ToolSearch 模式下,模型只能调用请求里带了完整定义的工具:目录里有、但发出本次调用的请求没加载 →
|
|
637
556
|
// 明确错误,不自动加载(spec 5.5 / 6.3)。同一步里先 ToolSearch 再调用刚加载的工具同样报错。
|
|
638
|
-
|
|
557
|
+
// This is the protocol working, not a failure: the `not_loaded` view lets the row read neutral.
|
|
558
|
+
if (resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
|
|
639
559
|
const sent = await this.sentTools(ctx);
|
|
640
560
|
if (sent !== null && !sent.has(tool.key))
|
|
641
|
-
return fail(notLoadedText(tool.key), outKey);
|
|
561
|
+
return fail(notLoadedText(tool.key), outKey, { kind: "not_loaded" });
|
|
642
562
|
}
|
|
643
563
|
let input;
|
|
644
564
|
try {
|
|
645
|
-
input = await resolveOutputRefs(
|
|
565
|
+
input = await resolveOutputRefs(call.input, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
|
|
646
566
|
}
|
|
647
567
|
catch (e) {
|
|
648
568
|
if (e instanceof ToolError)
|
|
@@ -656,6 +576,22 @@ let ToolPipeline = class ToolPipeline {
|
|
|
656
576
|
});
|
|
657
577
|
if (invalid !== null)
|
|
658
578
|
return fail(invalid, outKey);
|
|
579
|
+
// the per-call policy key (Platform tool spec §6.2): key and summary come from the resolved
|
|
580
|
+
// input, while the approval binding below compares the raw call.input
|
|
581
|
+
const callPolicy = (await tool.callPolicy?.(input, {
|
|
582
|
+
orgId: ctx.orgId,
|
|
583
|
+
accountId: ctx.accountId,
|
|
584
|
+
agentId: ctx.agentId,
|
|
585
|
+
conversationId: ctx.conversationId,
|
|
586
|
+
runId: ctx.runId,
|
|
587
|
+
rawInput: call.input,
|
|
588
|
+
signal: ctx.signal,
|
|
589
|
+
})) ?? null;
|
|
590
|
+
// a deny with a reason (e.g. an unavailable operation): the reason is the tool error
|
|
591
|
+
if (callPolicy?.policy === "deny" && callPolicy.denyReason !== undefined) {
|
|
592
|
+
return fail(callPolicy.denyReason, outKey);
|
|
593
|
+
}
|
|
594
|
+
const policyKey = callPolicy?.key ?? tool.key;
|
|
659
595
|
const decision = await this.decide(tool, ctx.agent, {
|
|
660
596
|
orgId: ctx.orgId,
|
|
661
597
|
accountId: ctx.accountId,
|
|
@@ -664,11 +600,20 @@ let ToolPipeline = class ToolPipeline {
|
|
|
664
600
|
runId: ctx.runId,
|
|
665
601
|
...(ctx.parent !== undefined && {
|
|
666
602
|
parentConversationId: ctx.parent.conversationId,
|
|
603
|
+
rootConversationId: ctx.parent.rootConversationId,
|
|
667
604
|
...(ctx.parent.otherAgent !== undefined && { parentAgentDiffers: ctx.parent.otherAgent }),
|
|
668
605
|
}),
|
|
606
|
+
callPolicy,
|
|
607
|
+
...(ctx.unattended != null && { unattended: ctx.unattended }),
|
|
669
608
|
});
|
|
670
609
|
if (decision === "deny")
|
|
671
|
-
return fail(deniedText(tool.key), outKey);
|
|
610
|
+
return fail(deniedText(tool.key, callPolicy?.key), outKey);
|
|
611
|
+
if (typeof decision === "object" && "refused" in decision) {
|
|
612
|
+
if (decision.missingGrant !== undefined && ctx.unattended != null) {
|
|
613
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, decision.missingGrant);
|
|
614
|
+
}
|
|
615
|
+
return fail(decision.refused, outKey);
|
|
616
|
+
}
|
|
672
617
|
if (typeof decision === "object" && "unavailable" in decision) {
|
|
673
618
|
return fail(unavailableText(tool.key, decision.unavailable), outKey);
|
|
674
619
|
}
|
|
@@ -676,10 +621,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
676
621
|
// (不写 tool_call_started:此时尚未开始执行)。
|
|
677
622
|
let approval = await this.deps.approvals.forCall(ctx.runId, call.id);
|
|
678
623
|
// 批准的是旧定义(等待期间工具定义变了):原批准不适用于当前定义,策略仍需审批时按新定义重新审批。
|
|
679
|
-
// An
|
|
680
|
-
//
|
|
681
|
-
|
|
682
|
-
|
|
624
|
+
// An approval binds the exact input it showed (Platform tool spec §6.3): an approved record
|
|
625
|
+
// whose stored input differs from the call's is not used.
|
|
626
|
+
const approvedHere = approval?.status === "approved" &&
|
|
627
|
+
approval.specHash === tool.specHash &&
|
|
628
|
+
canonicalJson(approval.input) === canonicalJson(call.input ?? {});
|
|
683
629
|
const stale = approval?.status === "approved" && !approvedHere;
|
|
684
630
|
if ((!approval || stale) && typeof decision === "object" && "ask" in decision) {
|
|
685
631
|
approval = await this.deps.approvals.request({
|
|
@@ -689,13 +635,15 @@ let ToolPipeline = class ToolPipeline {
|
|
|
689
635
|
runId: ctx.runId,
|
|
690
636
|
step: ctx.step,
|
|
691
637
|
callId: call.id,
|
|
692
|
-
toolKey:
|
|
638
|
+
toolKey: policyKey,
|
|
693
639
|
specHash: decision.ask.specHash,
|
|
694
640
|
connectorId: decision.ask.connectorId,
|
|
695
641
|
input: call.input,
|
|
696
642
|
requestedFor: decision.ask.requestedFor,
|
|
697
643
|
approverRole: decision.ask.approverRole,
|
|
698
644
|
policy: decision.ask.policy,
|
|
645
|
+
...(callPolicy?.summary !== undefined && { summary: callPolicy.summary }),
|
|
646
|
+
...(callPolicy !== null && !callPolicy.remember && { scopes: ["once"] }),
|
|
699
647
|
});
|
|
700
648
|
}
|
|
701
649
|
if (approval && approval.status !== "approved") {
|
|
@@ -703,16 +651,31 @@ let ToolPipeline = class ToolPipeline {
|
|
|
703
651
|
return refused === null ? approvalWait(approval) : fail(refused, outKey);
|
|
704
652
|
}
|
|
705
653
|
// 走到这里即放行:在(与当前定义一致的)审批下执行,否则是授权或策略放行
|
|
706
|
-
|
|
654
|
+
let authorization = approval?.status === "approved" && approvedHere
|
|
707
655
|
? approvalAuthorization(approval)
|
|
708
656
|
: typeof decision === "object" && "grant" in decision
|
|
709
657
|
? { grant: decision.grant }
|
|
710
658
|
: { policy: "allow" };
|
|
659
|
+
// Auto mode spec §5.1: the command review, after argument validation and the tool policy (and
|
|
660
|
+
// its approval), before the plugin hooks and `tool_call_started`. A deny ends the call here; an
|
|
661
|
+
// ask parks the run on the command approval (attended) or is a deny at once (unattended). An
|
|
662
|
+
// already decided command approval resumes the call without re-reviewing.
|
|
663
|
+
const reviewed = await this.reviewCall(ctx, call, tool, input);
|
|
664
|
+
if (reviewed.kind === "wait")
|
|
665
|
+
return reviewed.wait;
|
|
666
|
+
if (reviewed.kind === "result") {
|
|
667
|
+
review = reviewed.review;
|
|
668
|
+
return fail(reviewed.content, outKey);
|
|
669
|
+
}
|
|
670
|
+
review = reviewed.review;
|
|
671
|
+
const reviewedWorkingRoot = reviewed.workingRoot;
|
|
672
|
+
if (reviewed.commandAsk !== undefined)
|
|
673
|
+
authorization = approvalAuthorization(reviewed.commandAsk);
|
|
711
674
|
// tool.preExecute after policy and approval, before tool_call_started (F10)
|
|
712
675
|
const hooks = this.deps.pluginHooks;
|
|
713
676
|
const scope = hookScope(hooks, ctx);
|
|
714
677
|
if (scope && hooks?.has("tool.preExecute")) {
|
|
715
|
-
// sticky: a denial already logged for this call (e.g.
|
|
678
|
+
// sticky: a denial already logged for this call (e.g. a crash right after it)
|
|
716
679
|
// is final: fail with the recorded reason, never re-run the hooks or execute the tool. Only
|
|
717
680
|
// looked up when a tool.preExecute hook could run (M-2: no query without hooks); a denial is
|
|
718
681
|
// written with the call's tool_result, so a call with a logged denial never runs again anyway.
|
|
@@ -758,20 +721,80 @@ let ToolPipeline = class ToolPipeline {
|
|
|
758
721
|
step: ctx.step,
|
|
759
722
|
callId: call.id,
|
|
760
723
|
});
|
|
761
|
-
await this.writeResult(ctx, call.id, outKey, {
|
|
724
|
+
await this.writeResult(ctx, call.id, outKey, {
|
|
725
|
+
content: hookDeniedText(verdict.plugin, verdict.reason),
|
|
726
|
+
isError: true,
|
|
727
|
+
...(review !== undefined && { review }),
|
|
728
|
+
}, [event], undefined, [hookDeniedAudit(site, event.payload, verdict)]);
|
|
762
729
|
return undefined;
|
|
763
730
|
}
|
|
764
731
|
}
|
|
765
|
-
// `Agent` (sub-agents spec §7.1): no tool_call_started;
|
|
766
|
-
//
|
|
732
|
+
// `Agent` (sub-agents spec §7.1, agent map spec §4.1): no tool_call_started; one transaction
|
|
733
|
+
// makes the dispatch durable (its marker is the subagent_dispatches row) and writes the call's
|
|
734
|
+
// immediate result, while the sub-agent runs in the background
|
|
767
735
|
const dispatcher = this.deps.subagents;
|
|
768
736
|
if (tool.source.kind === "builtin" && tool.key === AGENT_TOOL && dispatcher) {
|
|
769
737
|
const parsed = AgentToolInput.safeParse(input);
|
|
770
738
|
if (!parsed.success) {
|
|
771
|
-
return fail("Invalid agent call: pass description and prompt, and optionally subagent_type
|
|
739
|
+
return fail("Invalid agent call: pass description and prompt, and optionally subagent_type and model.", outKey);
|
|
772
740
|
}
|
|
773
|
-
const r = await dispatcher.dispatch({
|
|
774
|
-
|
|
741
|
+
const r = await dispatcher.dispatch({
|
|
742
|
+
ctx,
|
|
743
|
+
callId: call.id,
|
|
744
|
+
input: parsed.data,
|
|
745
|
+
call: { toolKey: outKey, authorization, startedAt: Date.now() },
|
|
746
|
+
});
|
|
747
|
+
if (r.kind === "refused")
|
|
748
|
+
return fail(r.content, outKey);
|
|
749
|
+
if (hooks && hookBase) {
|
|
750
|
+
fireObserve(hooks, "tool.postExecute", {
|
|
751
|
+
...hookBase,
|
|
752
|
+
isError: false,
|
|
753
|
+
content: r.content,
|
|
754
|
+
durationMs: 0,
|
|
755
|
+
}, ctx.signal, this.deps.log);
|
|
756
|
+
}
|
|
757
|
+
return undefined;
|
|
758
|
+
}
|
|
759
|
+
// `SendMessage` and `SubagentHandback` (agent map spec §4.2, §4.3): no tool_call_started; each
|
|
760
|
+
// write is idempotent by the call (the message in the sub-agent's log, the delivery in the
|
|
761
|
+
// parent's), so a call retried after a crash sends nothing twice. A send that starts an idle
|
|
762
|
+
// sub-agent writes its result with the dispatch, like `Agent`
|
|
763
|
+
const messenger = this.deps.messages;
|
|
764
|
+
if (tool.source.kind === "builtin" &&
|
|
765
|
+
(tool.key === SEND_MESSAGE || tool.key === SUBAGENT_HANDBACK) &&
|
|
766
|
+
messenger) {
|
|
767
|
+
const t0 = Date.now();
|
|
768
|
+
let r;
|
|
769
|
+
if (tool.key === SEND_MESSAGE) {
|
|
770
|
+
const parsed = SendMessageInput.safeParse(input);
|
|
771
|
+
if (!parsed.success) {
|
|
772
|
+
return fail("Invalid SendMessage call: pass to and message.", outKey);
|
|
773
|
+
}
|
|
774
|
+
r = await messenger.toChild(ctx, call.id, parsed.data.to, parsed.data.message, {
|
|
775
|
+
authorization,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
const parsed = HandbackInput.safeParse(input);
|
|
780
|
+
if (!parsed.success)
|
|
781
|
+
return fail("Invalid SubagentHandback call: pass message.", outKey);
|
|
782
|
+
r = await messenger.toParent(ctx, "report", parsed.data.message, call.id);
|
|
783
|
+
}
|
|
784
|
+
if (r.isError)
|
|
785
|
+
return fail(r.content, outKey);
|
|
786
|
+
const durationMs = Date.now() - t0;
|
|
787
|
+
if (r.logged !== true) {
|
|
788
|
+
await this.writeResult(ctx, call.id, outKey, { content: r.content, isError: false }, [], {
|
|
789
|
+
durationMs,
|
|
790
|
+
connectorId: null,
|
|
791
|
+
authorization,
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
if (hooks && hookBase) {
|
|
795
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: false, content: r.content, durationMs }, ctx.signal, this.deps.log);
|
|
796
|
+
}
|
|
797
|
+
return undefined;
|
|
775
798
|
}
|
|
776
799
|
await this.deps.eventLog.append(ctx.conversationId, [
|
|
777
800
|
{
|
|
@@ -782,9 +805,19 @@ let ToolPipeline = class ToolPipeline {
|
|
|
782
805
|
},
|
|
783
806
|
]);
|
|
784
807
|
const t0 = Date.now();
|
|
785
|
-
let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools);
|
|
808
|
+
let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools, reviewedWorkingRoot);
|
|
786
809
|
const durationMs = Date.now() - t0;
|
|
787
810
|
await this.deps.hooks?.afterExecute?.(ctx.runId, call.id);
|
|
811
|
+
// scheduled tasks spec §7, `fail` mode: no one answers an input request or connects an app
|
|
812
|
+
if (unattendedFails(ctx.unattended) && ctx.unattended != null) {
|
|
813
|
+
if (outcome.kind === "input_required") {
|
|
814
|
+
outcome = { kind: "error", message: UNATTENDED_QUESTION_ERROR };
|
|
815
|
+
}
|
|
816
|
+
else if (outcome.kind === "connection_required") {
|
|
817
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, connectionGrantKey(outcome.connectorSlug));
|
|
818
|
+
outcome = { kind: "error", message: UNATTENDED_CONNECTION_ERROR(outcome.connectorName) };
|
|
819
|
+
}
|
|
820
|
+
}
|
|
788
821
|
if (outcome.kind === "input_required") {
|
|
789
822
|
const asked = await this.askInput(ctx, call.id, tool.key, attempt, outcome);
|
|
790
823
|
if (typeof asked !== "string")
|
|
@@ -811,6 +844,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
811
844
|
const card = outcome.kind === "result" && tool.source.kind === "plugin"
|
|
812
845
|
? this.cardOf(outcome.result, tool.source.plugin, tool.key)
|
|
813
846
|
: undefined;
|
|
847
|
+
// a `gh auth login --web` device code (`Bash`; auto mode spec §6): display only, written under
|
|
848
|
+
// this call before its result, never part of the result or the request the model sees
|
|
849
|
+
const loginCode = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
850
|
+
? loginCodeOf(outcome.result)
|
|
851
|
+
: undefined;
|
|
814
852
|
const cfg = this.config.get().tools;
|
|
815
853
|
const spilled = await spillIfLarge(rendered.text, {
|
|
816
854
|
// 内置工具可给更低的转存阈值(沙箱 bash 30000 字符)
|
|
@@ -838,8 +876,50 @@ let ToolPipeline = class ToolPipeline {
|
|
|
838
876
|
},
|
|
839
877
|
]
|
|
840
878
|
: [];
|
|
879
|
+
if (loginCode !== undefined &&
|
|
880
|
+
!(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, loginCode.code))) {
|
|
881
|
+
// the per-call id makes a retry or a resumed run append it once; a second call (a task read
|
|
882
|
+
// again, another command printing the same code) does not show the same code twice (P-D13)
|
|
883
|
+
pre.push(deviceCodeEvent(ctx.runId, ctx.step, call.id, loginCode));
|
|
884
|
+
}
|
|
885
|
+
const callAudit = {
|
|
886
|
+
durationMs,
|
|
887
|
+
connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
|
|
888
|
+
authorization,
|
|
889
|
+
};
|
|
890
|
+
// a foreground command refused network hosts (network ask-to-allow spec §6.2): display-only
|
|
891
|
+
// `network_blocked` before the result, then an ask to the device owner (the run waits; the
|
|
892
|
+
// result is written when the ask settles) or notes after the output
|
|
893
|
+
const report = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
894
|
+
? networkReportOf(outcome.result)
|
|
895
|
+
: undefined;
|
|
896
|
+
let content = spilled.content;
|
|
897
|
+
if (report !== undefined) {
|
|
898
|
+
const handled = await this.networkBlocked(ctx, call.id, outKey, input, report, pre, callAudit, {
|
|
899
|
+
text: rendered.text,
|
|
900
|
+
content: spilled.content,
|
|
901
|
+
isError: rendered.isError,
|
|
902
|
+
...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
|
|
903
|
+
...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
|
|
904
|
+
...(display !== undefined && { display }),
|
|
905
|
+
...(view !== undefined && { view }),
|
|
906
|
+
...(review !== undefined && { review }),
|
|
907
|
+
// carried into the kept result so a resumed run writes the event too (it was written
|
|
908
|
+
// with `network_blocked` below when the ask was created)
|
|
909
|
+
...(loginCode !== undefined && { loginCode }),
|
|
910
|
+
});
|
|
911
|
+
if (handled.kind === "wait") {
|
|
912
|
+
if (hooks && hookBase) {
|
|
913
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
|
|
914
|
+
}
|
|
915
|
+
return handled.wait;
|
|
916
|
+
}
|
|
917
|
+
if (handled.event !== null)
|
|
918
|
+
pre.push(handled.event);
|
|
919
|
+
content = withNetworkNotes(content, handled.notes);
|
|
920
|
+
}
|
|
841
921
|
await this.writeResult(ctx, call.id, outKey, {
|
|
842
|
-
content
|
|
922
|
+
content,
|
|
843
923
|
isError: rendered.isError,
|
|
844
924
|
...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
|
|
845
925
|
...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
|
|
@@ -847,52 +927,324 @@ let ToolPipeline = class ToolPipeline {
|
|
|
847
927
|
...(display !== undefined && { display }),
|
|
848
928
|
...(view !== undefined && { view }),
|
|
849
929
|
...(card !== undefined && { card }),
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
// a sub-agent that needs a personal connection: mirrored in the parent for display (spec §9;
|
|
856
|
-
// not a wait, the child got the connect text as its result)
|
|
930
|
+
...(review !== undefined && { review }),
|
|
931
|
+
}, pre, callAudit);
|
|
932
|
+
// a sub-agent that needs a personal connection: mirrored in the root conversation of its tree
|
|
933
|
+
// for display (sub-agents spec §9, agent map spec §7; not a wait, the child got the connect
|
|
934
|
+
// text as its result)
|
|
857
935
|
if (outcome.kind === "connection_required" && ctx.parent !== undefined) {
|
|
858
|
-
await this.deps.
|
|
859
|
-
.append(ctx.parent.conversationId, [
|
|
860
|
-
{
|
|
861
|
-
type: "subagent_waiting",
|
|
862
|
-
runId: ctx.parent.runId,
|
|
863
|
-
idemKey: subagentWaitingIdemKey(ctx.runId, `connect-${call.id}`),
|
|
864
|
-
payload: {
|
|
865
|
-
subagentId: ctx.conversationId,
|
|
866
|
-
childRunId: ctx.runId,
|
|
867
|
-
kind: "connect",
|
|
868
|
-
toolKey: tool.key,
|
|
869
|
-
},
|
|
870
|
-
},
|
|
871
|
-
])
|
|
872
|
-
.catch((err) => this.deps.log.warn("cannot surface a sub-agent's connect card in its parent", {
|
|
936
|
+
await this.surfaceConnectInRoot(ctx, ctx.parent, call.id, tool.key).catch((err) => this.deps.log.warn("cannot surface a sub-agent's connect card in its root conversation", {
|
|
873
937
|
runId: ctx.runId,
|
|
874
938
|
err,
|
|
875
939
|
}));
|
|
876
940
|
}
|
|
877
941
|
if (hooks && hookBase) {
|
|
878
|
-
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content
|
|
942
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content, durationMs }, ctx.signal, this.deps.log);
|
|
879
943
|
}
|
|
880
944
|
return undefined;
|
|
881
945
|
}
|
|
882
946
|
/**
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
947
|
+
* The command review of one call (auto mode spec §5.1, §5.4), after argument validation and the
|
|
948
|
+
* tool policy (and its approval), before the plugin hooks and execution. The device facts come
|
|
949
|
+
* from the same `ConversationDevices.forTool` the tool enters; with no device (or a deployment
|
|
950
|
+
* without a review service) the call runs unreviewed and fails on its own if it cannot. A deny is
|
|
951
|
+
* final whatever the mode and approvals; an `ask` waits for the device owner's `command` approval
|
|
952
|
+
* when the run is attended, and is a deny at once when it is not. A command approval already
|
|
953
|
+
* asked is the whole truth on a resume: the call is never reviewed twice.
|
|
886
954
|
*/
|
|
887
|
-
async
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
return
|
|
955
|
+
async reviewCall(ctx, call, tool, input) {
|
|
956
|
+
const review = this.deps.review;
|
|
957
|
+
const devices = this.deps.devices;
|
|
958
|
+
if (review === undefined || devices === undefined)
|
|
959
|
+
return { kind: "continue" };
|
|
960
|
+
if (!REVIEWED_TOOL_KEYS.has(tool.key))
|
|
961
|
+
return { kind: "continue" };
|
|
962
|
+
const asked = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
963
|
+
const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
|
|
964
|
+
if (asked !== null) {
|
|
965
|
+
const settled = this.settledCommandAsk(asked, tool.key);
|
|
966
|
+
// an approved call runs in the root it was reviewed against only while the device still runs
|
|
967
|
+
// in the mode recorded with the ask; otherwise the tool decides its working root afresh. A
|
|
968
|
+
// judged root that is the recorded workspace (free mode) is not carried either
|
|
969
|
+
// ({@link carriedRoot}): the tool maps it to the held instance's workspace as always
|
|
970
|
+
if (settled.kind === "continue" && settled.workingRoot !== undefined) {
|
|
971
|
+
const now = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
|
|
972
|
+
if (now === null ||
|
|
973
|
+
now.mode !== asked.command?.mode ||
|
|
974
|
+
carriedRoot({ workspace: now.workspace, workingRoot: settled.workingRoot }) === undefined) {
|
|
975
|
+
return { ...settled, workingRoot: undefined };
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return settled;
|
|
894
979
|
}
|
|
895
|
-
|
|
980
|
+
const facts = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
|
|
981
|
+
if (facts === null)
|
|
982
|
+
return { kind: "continue" }; // no device: the tool fails on its own
|
|
983
|
+
const kind = reviewKindOf(tool.key);
|
|
984
|
+
const attended = ctx.unattended == null && ctx.accountId === facts.ownerAccountId;
|
|
985
|
+
// a command over the ceiling is refused before any review: no stage reads it in full, and no
|
|
986
|
+
// approval could bind a text the person cannot see (hardening spec R8)
|
|
987
|
+
if (kind === "command") {
|
|
988
|
+
const text = textField(input, "command");
|
|
989
|
+
if (text.length > COMMAND_ASK_MAX_CHARS) {
|
|
990
|
+
return {
|
|
991
|
+
kind: "result",
|
|
992
|
+
content: commandTooLongText(text.length),
|
|
993
|
+
review: denyRecord("rule", null, commandTooLongReason(text.length)),
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
const verdict = await review.review({
|
|
998
|
+
orgId: ctx.orgId,
|
|
999
|
+
conversationId: rootConversationId,
|
|
1000
|
+
runId: ctx.runId,
|
|
1001
|
+
accountId: ctx.accountId,
|
|
1002
|
+
toolKey: tool.key,
|
|
1003
|
+
input,
|
|
1004
|
+
mode: facts.mode,
|
|
1005
|
+
// the working root: a bound project's root, where commands start and writes need no ask
|
|
1006
|
+
workspace: facts.workingRoot,
|
|
1007
|
+
// the owner's home, never the project root: the home-level rules stay where they were
|
|
1008
|
+
home: facts.home,
|
|
1009
|
+
// and the device workspace's home, so a project outside every home still protects it
|
|
1010
|
+
deviceHome: facts.deviceHome,
|
|
1011
|
+
attended,
|
|
1012
|
+
step: ctx.step,
|
|
1013
|
+
callId: call.id,
|
|
1014
|
+
signal: ctx.signal,
|
|
1015
|
+
...(ctx.parent !== undefined && {
|
|
1016
|
+
parentRunId: ctx.parent.runId,
|
|
1017
|
+
...(ctx.parent.budgetRunId !== undefined && { budgetRunId: ctx.parent.budgetRunId }),
|
|
1018
|
+
parent: {
|
|
1019
|
+
conversationId: ctx.parent.conversationId,
|
|
1020
|
+
runId: ctx.parent.runId,
|
|
1021
|
+
callId: ctx.parent.callId,
|
|
1022
|
+
},
|
|
1023
|
+
}),
|
|
1024
|
+
agentId: ctx.agentId,
|
|
1025
|
+
agentVersion: ctx.agentVersion,
|
|
1026
|
+
...(ctx.conversationKind !== undefined && { conversationKind: ctx.conversationKind }),
|
|
1027
|
+
});
|
|
1028
|
+
if (verdict.decision === "allow") {
|
|
1029
|
+
return { kind: "continue", review: allowRecord(verdict), workingRoot: carriedRoot(facts) };
|
|
1030
|
+
}
|
|
1031
|
+
if (verdict.decision === "deny") {
|
|
1032
|
+
return {
|
|
1033
|
+
kind: "result",
|
|
1034
|
+
content: commandDeniedText(verdict.reason, kind),
|
|
1035
|
+
review: denyRecord(verdict.by, verdict.rule, verdict.reason),
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
// ask
|
|
1039
|
+
const command = kind === "command" ? textField(input, "command") : tool.key;
|
|
1040
|
+
if (!attended) {
|
|
1041
|
+
const reason = verdict.reason;
|
|
1042
|
+
return {
|
|
1043
|
+
kind: "result",
|
|
1044
|
+
content: commandUnattendedText(reason, kind),
|
|
1045
|
+
review: denyRecord(verdict.by, verdict.rule, reason),
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
const detail = {
|
|
1049
|
+
deviceId: facts.deviceId,
|
|
1050
|
+
deviceName: facts.deviceName,
|
|
1051
|
+
mode: facts.mode,
|
|
1052
|
+
kind,
|
|
1053
|
+
// the whole command the approval covers (the event keeps a clamped copy for display)
|
|
1054
|
+
command,
|
|
1055
|
+
// a relative path as it will be written: resolved against the working root
|
|
1056
|
+
...(kind === "write" && {
|
|
1057
|
+
path: clipText(facts.workingRoot === undefined
|
|
1058
|
+
? textField(input, "file_path")
|
|
1059
|
+
: pathAgainstWorkingRoot(textField(input, "file_path"), facts.workingRoot), 4096),
|
|
1060
|
+
}),
|
|
1061
|
+
rule: verdict.rule,
|
|
1062
|
+
reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
|
|
1063
|
+
// the root the review judged, always (the workspace in free mode): the approved call runs
|
|
1064
|
+
// against what the person approved, not a later snapshot
|
|
1065
|
+
...(facts.workingRoot !== undefined && { workingRoot: facts.workingRoot }),
|
|
1066
|
+
};
|
|
1067
|
+
let ask;
|
|
1068
|
+
try {
|
|
1069
|
+
ask = await this.deps.approvals.requestCommand({
|
|
1070
|
+
orgId: ctx.orgId,
|
|
1071
|
+
conversationId: ctx.conversationId,
|
|
1072
|
+
runId: ctx.runId,
|
|
1073
|
+
step: ctx.step,
|
|
1074
|
+
callId: call.id,
|
|
1075
|
+
requestedFor: facts.ownerAccountId,
|
|
1076
|
+
detail,
|
|
1077
|
+
// `once` always; `session` only for a concrete rule class, never an `unsure.*` catch-all (P-D2)
|
|
1078
|
+
scopes: isSessionGrantableRule(verdict.rule) ? ["once", "session"] : ["once"],
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
catch (err) {
|
|
1082
|
+
// fail closed: an ask that cannot be created is a deny, never a run of the held call
|
|
1083
|
+
this.deps.log.warn("command ask could not be created; denying the call", {
|
|
1084
|
+
conversationId: ctx.conversationId,
|
|
1085
|
+
callId: call.id,
|
|
1086
|
+
err,
|
|
1087
|
+
});
|
|
1088
|
+
const reason = "The approval could not be created";
|
|
1089
|
+
return {
|
|
1090
|
+
kind: "result",
|
|
1091
|
+
content: commandDeniedText(reason, kind),
|
|
1092
|
+
review: denyRecord(verdict.by, verdict.rule, reason),
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
1096
|
+
}
|
|
1097
|
+
/** The outcome of a call whose `command` approval was already asked (a resume). */
|
|
1098
|
+
settledCommandAsk(ask, toolKey) {
|
|
1099
|
+
const kind = reviewKindOf(toolKey);
|
|
1100
|
+
const rule = ask.command?.rule ?? null;
|
|
1101
|
+
if (ask.status === "pending")
|
|
1102
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
1103
|
+
if (ask.status === "approved") {
|
|
1104
|
+
return {
|
|
1105
|
+
kind: "continue",
|
|
1106
|
+
commandAsk: ask,
|
|
1107
|
+
review: this.personAllowRecord(ask),
|
|
1108
|
+
workingRoot: ask.command?.workingRoot,
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
if (ask.status === "denied") {
|
|
1112
|
+
const reason = ask.denyReason;
|
|
1113
|
+
return {
|
|
1114
|
+
kind: "result",
|
|
1115
|
+
content: commandDeclinedText(reason, kind),
|
|
1116
|
+
review: denyRecord("person", rule, reason ?? "The user declined."),
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
const text = ask.status === "expired" ? approvalExpiredText(approvalHours(ask)) : APPROVAL_CANCELLED_TEXT;
|
|
1120
|
+
return { kind: "result", content: text, review: denyRecord("person", rule, text) };
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* The review record of a command (or write) the person allowed: its scope, and for a shell
|
|
1124
|
+
* command the SHA-256 of the text the ask holds in full, so an audit can match record and text.
|
|
1125
|
+
*/
|
|
1126
|
+
personAllowRecord(ask) {
|
|
1127
|
+
return {
|
|
1128
|
+
decision: "allow",
|
|
1129
|
+
by: "person",
|
|
1130
|
+
rule: ask.command?.rule ?? null,
|
|
1131
|
+
reason: ask.command?.reason ?? "The user allowed this call.",
|
|
1132
|
+
...((ask.scope === "once" || ask.scope === "session") && { scope: ask.scope }),
|
|
1133
|
+
...(ask.command !== null &&
|
|
1134
|
+
ask.command.kind === "command" && {
|
|
1135
|
+
commandHash: sha256Hex(ask.command.command),
|
|
1136
|
+
}),
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* A foreground command's refused network hosts (network ask-to-allow spec §6.2, §6.8, §8.3):
|
|
1141
|
+
* the `network_blocked` event, the missing grants of an unattended run, and either notes for the
|
|
1142
|
+
* result written now, or (device-layer hosts worth asking) `network_blocked` and the call's
|
|
1143
|
+
* `tool.called` audit written now, the result kept in a network ask to the device's owner and
|
|
1144
|
+
* the run's wait. The kept result is the formatted one (≤ 16 KB: larger output is archived)
|
|
1145
|
+
* followed by the notes written now; it is written with the decision's note when the ask
|
|
1146
|
+
* settles (P-D2).
|
|
1147
|
+
*/
|
|
1148
|
+
async networkBlocked(ctx, callId, toolKey, input, report, pre, callAudit, result) {
|
|
1149
|
+
const hosts = blockedEventHosts(report.blocked);
|
|
1150
|
+
if (hosts.length === 0)
|
|
1151
|
+
return { kind: "write", event: null, notes: [] };
|
|
1152
|
+
const event = {
|
|
1153
|
+
type: "network_blocked",
|
|
1154
|
+
runId: ctx.runId,
|
|
1155
|
+
idemKey: networkBlockedIdemKey(ctx.runId, callId),
|
|
1156
|
+
payload: { step: ctx.step, callId, hosts },
|
|
1157
|
+
};
|
|
1158
|
+
const network = this.deps.network;
|
|
1159
|
+
if (network === undefined)
|
|
1160
|
+
return { kind: "write", event, notes: [] };
|
|
1161
|
+
const device = await network.devices.summary(report.deviceId);
|
|
1162
|
+
const run = hosts.some((h) => h.layer === "device")
|
|
1163
|
+
? await network.grants.runState(ctx.runId, report.deviceId)
|
|
1164
|
+
: null;
|
|
1165
|
+
const limits = this.config.get().sandbox.limits;
|
|
1166
|
+
const plan = planNetworkAsk(hosts, run, {
|
|
1167
|
+
device,
|
|
1168
|
+
unattended: ctx.unattended,
|
|
1169
|
+
outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
|
|
1170
|
+
});
|
|
1171
|
+
if (ctx.unattended != null) {
|
|
1172
|
+
for (const key of plan.missingGrants) {
|
|
1173
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, key);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
if (plan.ask.length === 0)
|
|
1177
|
+
return { kind: "write", event, notes: plan.notes };
|
|
1178
|
+
// the device's owner is the only person who may decide (spec §5.2)
|
|
1179
|
+
const owner = await this.deps.db
|
|
1180
|
+
.selectFrom("devices")
|
|
1181
|
+
.select("owner_account_id")
|
|
1182
|
+
.where("id", "=", report.deviceId)
|
|
1183
|
+
.where("org_id", "=", ctx.orgId)
|
|
1184
|
+
.where("deleted_at", "is", null)
|
|
1185
|
+
.executeTakeFirst();
|
|
1186
|
+
if (owner === undefined)
|
|
1187
|
+
return { kind: "write", event, notes: plan.notes };
|
|
1188
|
+
let { content, outputId } = result;
|
|
1189
|
+
if (Buffer.byteLength(content, "utf8") > NETWORK_ASK_KEPT_MAX_BYTES && outputId === undefined) {
|
|
1190
|
+
// output under the spill threshold but over what an ask keeps: archive it after all
|
|
1191
|
+
const spilled = await spillIfLarge(result.text, { spillChars: 0, previewChars: this.config.get().tools.outputPreviewChars }, (c) => this.deps.outputs.save({
|
|
1192
|
+
orgId: ctx.orgId,
|
|
1193
|
+
conversationId: ctx.conversationId,
|
|
1194
|
+
callId,
|
|
1195
|
+
content: c,
|
|
1196
|
+
}));
|
|
1197
|
+
content = spilled.content;
|
|
1198
|
+
outputId = spilled.outputId;
|
|
1199
|
+
}
|
|
1200
|
+
const { text: _text, ...rest } = result;
|
|
1201
|
+
const kept = {
|
|
1202
|
+
...rest,
|
|
1203
|
+
content: withNetworkNotes(clipKept(content), plan.notes),
|
|
1204
|
+
...(outputId !== undefined && { outputId }),
|
|
1205
|
+
};
|
|
1206
|
+
// the command ran: the call's display-only events (a `device_code`) and network_blocked with
|
|
1207
|
+
// its tool.called now, the result once the ask settles
|
|
1208
|
+
const written = await this.writeResultIn(ctx, callId, toolKey, { isError: result.isError }, [...pre, event], callAudit, []);
|
|
1209
|
+
await this.deps.eventLog.notify(ctx.conversationId, Math.max(...written.map((e) => e.seq)));
|
|
1210
|
+
const given = (input ?? {});
|
|
1211
|
+
const ask = await this.deps.approvals.requestNetwork({
|
|
1212
|
+
orgId: ctx.orgId,
|
|
1213
|
+
conversationId: ctx.conversationId,
|
|
1214
|
+
runId: ctx.runId,
|
|
1215
|
+
step: ctx.step,
|
|
1216
|
+
callId,
|
|
1217
|
+
requestedFor: owner.owner_account_id,
|
|
1218
|
+
detail: {
|
|
1219
|
+
deviceId: report.deviceId,
|
|
1220
|
+
hosts: plan.ask,
|
|
1221
|
+
command: typeof given.command === "string" ? clipText(given.command, 2000) : "",
|
|
1222
|
+
description: typeof given.description === "string" ? given.description : null,
|
|
1223
|
+
result: kept,
|
|
1224
|
+
},
|
|
1225
|
+
scopes: plan.scopes,
|
|
1226
|
+
});
|
|
1227
|
+
return { kind: "wait", wait: approvalWait(ask), content: kept.content };
|
|
1228
|
+
}
|
|
1229
|
+
/** Appends a sub-agent's connect card to its root conversation ({@link rootSurfaceOf}). */
|
|
1230
|
+
async surfaceConnectInRoot(ctx, parent, callId, toolKey) {
|
|
1231
|
+
const target = await rootSurfaceOf(this.deps.db, ctx.conversationId, ctx.runId, parent);
|
|
1232
|
+
if (!target)
|
|
1233
|
+
return;
|
|
1234
|
+
await this.deps.eventLog.append(target.conversationId, [
|
|
1235
|
+
{
|
|
1236
|
+
type: "subagent_waiting",
|
|
1237
|
+
runId: target.runId,
|
|
1238
|
+
idemKey: subagentWaitingIdemKey(ctx.runId, `connect-${callId}`),
|
|
1239
|
+
payload: {
|
|
1240
|
+
subagentId: ctx.conversationId,
|
|
1241
|
+
childRunId: ctx.runId,
|
|
1242
|
+
path: target.path,
|
|
1243
|
+
kind: "connect",
|
|
1244
|
+
toolKey,
|
|
1245
|
+
},
|
|
1246
|
+
},
|
|
1247
|
+
]);
|
|
896
1248
|
}
|
|
897
1249
|
/**
|
|
898
1250
|
* 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
|
|
@@ -900,7 +1252,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
900
1252
|
* 或找不到 model_call 时返回 null(不做加载检查)。已加载集合由此从日志得出,不放进程内存。
|
|
901
1253
|
*/
|
|
902
1254
|
async sentTools(ctx) {
|
|
903
|
-
|
|
1255
|
+
// attempts can reach MAX_STEP_MODEL_CALLS after reactive overflow fix-ups; the assistant_message
|
|
1256
|
+
// comes from the last attempt, so scan from the top
|
|
1257
|
+
for (let attempt = MAX_STEP_MODEL_CALLS; attempt >= 1; attempt--) {
|
|
904
1258
|
const e = await this.deps.eventLog.findByIdem(ctx.conversationId, modelCallIdemKey(ctx.runId, ctx.step, attempt));
|
|
905
1259
|
if (e?.type !== "model_call")
|
|
906
1260
|
continue;
|
|
@@ -963,7 +1317,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
963
1317
|
* 带 `tools.timeoutMs` 超时与 run 的中止信号(合并后传给处理函数 / 连接器,不响应信号的也按时结束)。
|
|
964
1318
|
* 熔断只作用于连接器工具(键为组织 × 连接器)。
|
|
965
1319
|
*/
|
|
966
|
-
async execute(tool, input, ctx, callId, resume, stepTools) {
|
|
1320
|
+
async execute(tool, input, ctx, callId, resume, stepTools, reviewedWorkingRoot) {
|
|
967
1321
|
if (tool.source.kind === "connector") {
|
|
968
1322
|
return this.executeConnector(tool, tool.source, input, ctx, resume);
|
|
969
1323
|
}
|
|
@@ -978,15 +1332,24 @@ let ToolPipeline = class ToolPipeline {
|
|
|
978
1332
|
conversationId: ctx.conversationId,
|
|
979
1333
|
callId,
|
|
980
1334
|
...(resume !== undefined && { resume }),
|
|
1335
|
+
// who and where (memory plugin spec §6.2): `accountId` stays the trigger account
|
|
1336
|
+
source: ctx.source,
|
|
1337
|
+
ownerAccountId: ctx.ownerAccountId,
|
|
1338
|
+
role: ctx.role,
|
|
981
1339
|
...(tool.source.kind === "builtin" && stepTools !== undefined && { tools: stepTools }),
|
|
982
1340
|
...(tool.source.kind === "builtin" && { runId: ctx.runId }),
|
|
983
1341
|
...(tool.source.kind === "builtin" &&
|
|
984
1342
|
ctx.deadline !== undefined && { runDeadline: ctx.deadline }),
|
|
985
|
-
// a
|
|
1343
|
+
// a reviewed call runs in the working root its review judged (project root spec §4.3)
|
|
1344
|
+
...(tool.source.kind === "builtin" &&
|
|
1345
|
+
reviewedWorkingRoot !== undefined && { reviewedWorkingRoot }),
|
|
1346
|
+
// a sub-agent works in its root conversation's sandbox (spec §10.1, at every depth)
|
|
986
1347
|
...(tool.source.kind === "builtin" &&
|
|
987
|
-
ctx.parent !== undefined && { sandboxConversationId: ctx.parent.
|
|
1348
|
+
ctx.parent !== undefined && { sandboxConversationId: ctx.parent.rootConversationId }),
|
|
988
1349
|
...(tool.source.kind === "builtin" &&
|
|
989
1350
|
ctx.parent !== undefined && { parentRunId: ctx.parent.runId }),
|
|
1351
|
+
...(tool.source.kind === "builtin" &&
|
|
1352
|
+
ctx.parent?.budgetRunId !== undefined && { budgetRunId: ctx.parent.budgetRunId }),
|
|
990
1353
|
// the hook scope of a builtin's own model call (the WebFetch extraction)
|
|
991
1354
|
...(tool.source.kind === "builtin" && {
|
|
992
1355
|
step: ctx.step,
|
|
@@ -1004,7 +1367,28 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1004
1367
|
// 内置工具可按输入给自己的时限(沙箱 bash 按命令超时加余量);缺省 tools.timeoutMs
|
|
1005
1368
|
const timeoutMs = tool.timeoutMs?.(input) ?? this.config.get().tools.timeoutMs;
|
|
1006
1369
|
try {
|
|
1007
|
-
|
|
1370
|
+
// a plugin tool runs with the extension's effective config for the org, never without it
|
|
1371
|
+
// (layering spec A §6): one read per call, cached by EffectiveConfigs
|
|
1372
|
+
let config = {};
|
|
1373
|
+
if (tool.source.kind === "plugin") {
|
|
1374
|
+
// turned off in the org since the step resolved its tools (spec A §7)
|
|
1375
|
+
if (await this.deps.switches.isToolOff(ctx.orgId, tool.source.plugin, tool.source.name)) {
|
|
1376
|
+
return { kind: "error", message: `${toolTurnedOffReason(tool.key)}.` };
|
|
1377
|
+
}
|
|
1378
|
+
const effective = await this.deps.effective.get(ctx.orgId, tool.source.plugin);
|
|
1379
|
+
if (!effective.ok) {
|
|
1380
|
+
// unloaded or disabled since the step resolved its tools: the documented unloaded error
|
|
1381
|
+
if (effective.notRunning)
|
|
1382
|
+
return { kind: "error", message: PLUGIN_UNLOADED_TOOL_ERROR };
|
|
1383
|
+
return { kind: "error", message: unavailableText(tool.key, NEEDS_CONFIG_REASON) };
|
|
1384
|
+
}
|
|
1385
|
+
config = { config: effective.config };
|
|
1386
|
+
}
|
|
1387
|
+
const r = await this.bounded(ctx.signal, async (signal) => {
|
|
1388
|
+
await this.txHost.run(async () => { });
|
|
1389
|
+
signal.throwIfAborted();
|
|
1390
|
+
return handler(input, { ...base, ...config, signal });
|
|
1391
|
+
}, undefined, timeoutMs);
|
|
1008
1392
|
if (r === "timeout") {
|
|
1009
1393
|
return { kind: "error", message: timeoutText(tool.key, timeoutMs) };
|
|
1010
1394
|
}
|
|
@@ -1025,7 +1409,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1025
1409
|
const connectorId = source.connectorId;
|
|
1026
1410
|
const app = await db
|
|
1027
1411
|
.selectFrom("connectors")
|
|
1028
|
-
.select(["name", "connector", "endpoint", "auth", "status"])
|
|
1412
|
+
.select(["name", "slug", "connector", "endpoint", "auth", "status"])
|
|
1029
1413
|
.where("id", "=", connectorId)
|
|
1030
1414
|
.where("org_id", "=", orgId)
|
|
1031
1415
|
.where("deleted_at", "is", null)
|
|
@@ -1061,10 +1445,13 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1061
1445
|
// 远端在调用途中向用户要输入(MCP elicitation,见 elicitation.ts):需要问用户时中止本次调用、按 input_required
|
|
1062
1446
|
// 处理;续跑时用 ctx.resume 的答案答复远端再次发起的同一请求。resources 工具不续跑,一律拒绝。
|
|
1063
1447
|
const suspend = new AbortController();
|
|
1448
|
+
// an unattended run in `fail` mode declines every elicitation: no one is there to answer
|
|
1449
|
+
const unattended = unattendedFails(ctx.unattended);
|
|
1064
1450
|
const elicit = new ElicitationSession({
|
|
1065
1451
|
resume,
|
|
1066
1452
|
onSuspend: () => suspend.abort(),
|
|
1067
|
-
declineAll: source.resources === true,
|
|
1453
|
+
declineAll: source.resources === true || unattended,
|
|
1454
|
+
...(unattended && { declineNote: UNATTENDED_ELICITATION_NOTE }),
|
|
1068
1455
|
});
|
|
1069
1456
|
// 远端可能把收到的凭据回显在结果 / 错误 / elicitation 表单里:写入事件之前按本次注入的值打码(见 redact.ts)
|
|
1070
1457
|
const clean = (o) => {
|
|
@@ -1100,6 +1487,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1100
1487
|
kind: "connection_required",
|
|
1101
1488
|
connectorId,
|
|
1102
1489
|
connectorName: app.name,
|
|
1490
|
+
connectorSlug: app.slug,
|
|
1103
1491
|
message: personalMissingText(app.name),
|
|
1104
1492
|
}
|
|
1105
1493
|
: { kind: "error", message: orgMissingText(app.name) };
|
|
@@ -1130,6 +1518,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1130
1518
|
await credentials.onUnauthorized(orgId, connectorId, auth, ctx.accountId, stale);
|
|
1131
1519
|
},
|
|
1132
1520
|
signal,
|
|
1521
|
+
orgId,
|
|
1133
1522
|
onElicit: elicit.handle,
|
|
1134
1523
|
onToolsChanged: () => {
|
|
1135
1524
|
try {
|
|
@@ -1145,6 +1534,8 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1145
1534
|
},
|
|
1146
1535
|
});
|
|
1147
1536
|
const session = await opened;
|
|
1537
|
+
await this.txHost.run(async () => { });
|
|
1538
|
+
signal.throwIfAborted();
|
|
1148
1539
|
return source.resources
|
|
1149
1540
|
? runResourceTool(session, source.name, input)
|
|
1150
1541
|
: // 交回已复核的定义(connector_tools.spec,含 connectorData):连接器按它路由,远端变化须先经漂移复核
|
|
@@ -1189,6 +1580,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1189
1580
|
thrown(key, e) {
|
|
1190
1581
|
if (e instanceof ToolError)
|
|
1191
1582
|
return { kind: "error", message: e.message };
|
|
1583
|
+
// an extension tool's ctx.models.embed denied by a policy hook (spec B §5.4): the model sees the
|
|
1584
|
+
// deny text (sanitized reason), as for a denied tool call, not a generic failure
|
|
1585
|
+
if (e instanceof ApiError && e.code === "model.hook_denied") {
|
|
1586
|
+
return { kind: "error", message: e.message };
|
|
1587
|
+
}
|
|
1192
1588
|
// 提供工具的插件实例在调用进行中被撤销(停用 / 升级),排空时限到后中止(C17)
|
|
1193
1589
|
if (e instanceof ExtensionUnloadedError) {
|
|
1194
1590
|
this.deps.log.warn("tool call aborted: plugin unloaded", { toolKey: key, plugin: e.plugin });
|
|
@@ -1359,9 +1755,6 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1359
1755
|
return out;
|
|
1360
1756
|
}
|
|
1361
1757
|
};
|
|
1362
|
-
__decorate([
|
|
1363
|
-
Transactional()
|
|
1364
|
-
], ToolPipeline.prototype, "stopOpenAgentCallsNow", null);
|
|
1365
1758
|
__decorate([
|
|
1366
1759
|
Transactional({ propagation: "mandatory" })
|
|
1367
1760
|
], ToolPipeline.prototype, "stopOpenAgentCalls", null);
|
|
@@ -1373,18 +1766,29 @@ ToolPipeline = __decorate([
|
|
|
1373
1766
|
__param(0, Inject(KernelDb)),
|
|
1374
1767
|
__param(1, Inject(EventLog)),
|
|
1375
1768
|
__param(2, Inject(SubagentsService)),
|
|
1376
|
-
__param(3, Inject(
|
|
1377
|
-
__param(4, Inject(
|
|
1378
|
-
__param(5, Inject(
|
|
1379
|
-
__param(6, Inject(
|
|
1380
|
-
__param(7, Inject(
|
|
1381
|
-
__param(8, Inject(
|
|
1382
|
-
__param(9, Inject(
|
|
1383
|
-
__param(10, Inject(
|
|
1384
|
-
__param(11, Inject(
|
|
1385
|
-
__param(12, Inject(
|
|
1386
|
-
__param(13, Inject(
|
|
1387
|
-
__param(14,
|
|
1388
|
-
__param(
|
|
1769
|
+
__param(3, Inject(SubagentMessages)),
|
|
1770
|
+
__param(4, Inject(ToolRegistry)),
|
|
1771
|
+
__param(5, Inject(Credentials)),
|
|
1772
|
+
__param(6, Inject(Breaker)),
|
|
1773
|
+
__param(7, Inject(ToolOutputs)),
|
|
1774
|
+
__param(8, Inject(ApprovalsService)),
|
|
1775
|
+
__param(9, Inject(QuestionsService)),
|
|
1776
|
+
__param(10, Inject(KernelConfigService)),
|
|
1777
|
+
__param(11, Inject(KERNEL_LOGGER)),
|
|
1778
|
+
__param(12, Inject(ExtensionHost)),
|
|
1779
|
+
__param(13, Inject(ToolDrift)),
|
|
1780
|
+
__param(14, Inject(EffectiveConfigs)),
|
|
1781
|
+
__param(15, Inject(OrgToolSwitches)),
|
|
1782
|
+
__param(16, Inject(TransactionHost)),
|
|
1783
|
+
__param(17, Optional()),
|
|
1784
|
+
__param(17, Inject(TOOL_PIPELINE_HOOKS)),
|
|
1785
|
+
__param(18, Optional()),
|
|
1786
|
+
__param(18, Inject(NetworkGrants)),
|
|
1787
|
+
__param(19, Optional()),
|
|
1788
|
+
__param(19, Inject(DevicePolicyService)),
|
|
1789
|
+
__param(20, Optional()),
|
|
1790
|
+
__param(20, Inject(CommandReviewService)),
|
|
1791
|
+
__param(21, Optional()),
|
|
1792
|
+
__param(21, Inject(ConversationDevices))
|
|
1389
1793
|
], ToolPipeline);
|
|
1390
1794
|
export { ToolPipeline };
|