@capybara-hq/kernel 0.1.0-rc.4 → 0.1.0-rc.6
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 +61 -5
- package/dist/admin/admin.controller.d.ts +51 -14
- package/dist/admin/admin.controller.js +60 -19
- package/dist/admin/extensions.controller.d.ts +16 -2
- package/dist/admin/extensions.controller.js +26 -6
- 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/agents/agent-lookup.d.ts +16 -0
- package/dist/agents/agent-lookup.js +11 -0
- package/dist/agents/agents.controller.d.ts +76 -1
- package/dist/agents/agents.controller.js +90 -11
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +32 -6
- package/dist/agents/agents.service.d.ts +54 -23
- package/dist/agents/agents.service.js +180 -76
- package/dist/agents/definition.d.ts +49 -0
- package/dist/agents/definition.js +45 -0
- package/dist/agents/from-template.d.ts +106 -0
- package/dist/agents/from-template.js +649 -0
- package/dist/agents/from-template.service.d.ts +60 -0
- package/dist/agents/from-template.service.js +161 -0
- package/dist/agents/models.controller.d.ts +34 -5
- package/dist/agents/models.controller.js +50 -6
- package/dist/agents/org-templates.d.ts +176 -0
- package/dist/agents/org-templates.js +827 -0
- package/dist/agents/pending-connector-requests.d.ts +77 -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/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- package/dist/agents/templates.controller.d.ts +86 -5
- package/dist/agents/templates.controller.js +171 -7
- package/dist/agents/templates.d.ts +127 -23
- package/dist/agents/templates.js +475 -52
- package/dist/background/background.module.js +8 -1
- package/dist/background/finish.d.ts +3 -2
- package/dist/background/launch-lock.d.ts +4 -3
- package/dist/background/launch-lock.js +4 -3
- package/dist/background/poll.job.d.ts +9 -6
- package/dist/background/poll.job.js +30 -22
- package/dist/background/session.d.ts +13 -2
- package/dist/background/session.js +13 -0
- package/dist/background/stop.d.ts +12 -6
- package/dist/background/stop.js +57 -39
- package/dist/background/store.d.ts +18 -6
- package/dist/background/store.js +12 -6
- package/dist/background/tasks.service.d.ts +15 -5
- package/dist/background/tasks.service.js +42 -17
- package/dist/background/wake-rules.d.ts +27 -18
- package/dist/background/wake-rules.js +52 -22
- package/dist/background/wake.d.ts +13 -11
- package/dist/background/wake.js +20 -14
- package/dist/catalog/admin-catalog.controller.d.ts +129 -30
- package/dist/catalog/admin-catalog.controller.js +213 -42
- package/dist/catalog/catalog-content.d.ts +58 -32
- package/dist/catalog/catalog-content.js +34 -8
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +60 -0
- package/dist/catalog/catalog-items.d.ts +111 -7
- package/dist/catalog/catalog-items.js +279 -13
- package/dist/catalog/catalog-scope.service.d.ts +260 -0
- package/dist/catalog/catalog-scope.service.js +1116 -0
- package/dist/catalog/catalog.module.d.ts +7 -9
- package/dist/catalog/catalog.module.js +41 -31
- package/dist/catalog/catalog.service.d.ts +101 -29
- package/dist/catalog/catalog.service.js +104 -106
- package/dist/catalog/cli.d.ts +11 -1
- package/dist/catalog/cli.js +26 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +395 -0
- package/dist/catalog/component-scope.controller.d.ts +152 -0
- package/dist/catalog/component-scope.controller.js +287 -0
- package/dist/catalog/component-scope.service.d.ts +303 -0
- package/dist/catalog/component-scope.service.js +936 -0
- package/dist/catalog/component-state.d.ts +174 -0
- package/dist/catalog/component-state.js +437 -0
- package/dist/catalog/job-ids.d.ts +30 -0
- package/dist/catalog/job-ids.js +25 -0
- package/dist/catalog/marketplace-fetch.d.ts +1 -1
- package/dist/catalog/marketplaces.controller.d.ts +22 -5
- package/dist/catalog/marketplaces.controller.js +56 -7
- package/dist/catalog/marketplaces.service.d.ts +54 -14
- package/dist/catalog/marketplaces.service.js +71 -22
- package/dist/catalog/org-catalog.controller.d.ts +125 -34
- package/dist/catalog/org-catalog.controller.js +181 -65
- package/dist/catalog/org-catalog.service.d.ts +65 -33
- package/dist/catalog/org-catalog.service.js +324 -157
- package/dist/catalog/org-extension-switch.d.ts +41 -0
- package/dist/catalog/org-extension-switch.js +115 -0
- package/dist/catalog/org-extension.controller.d.ts +119 -0
- package/dist/catalog/org-extension.controller.js +266 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
- package/dist/catalog/org-plugin-uploads.controller.js +213 -0
- package/dist/catalog/org-plugin-uploads.d.ts +63 -0
- package/dist/catalog/org-plugin-uploads.js +116 -0
- package/dist/catalog/owned-items.d.ts +184 -0
- package/dist/catalog/owned-items.js +789 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
- package/dist/catalog/owned-plugin-cleanup.js +194 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +221 -0
- package/dist/catalog/platform-components.js +761 -0
- package/dist/catalog/platform-migration.d.ts +115 -0
- package/dist/catalog/platform-migration.js +582 -0
- package/dist/catalog/plugin-import.d.ts +178 -34
- package/dist/catalog/plugin-import.js +622 -82
- package/dist/catalog/plugin-install.d.ts +185 -41
- package/dist/catalog/plugin-install.js +758 -126
- package/dist/catalog/plugin-upgrade.d.ts +260 -225
- package/dist/catalog/plugin-upgrade.js +1147 -1136
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +193 -118
- package/dist/catalog/requests.service.js +526 -343
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-orgs.d.ts +21 -0
- package/dist/catalog/scope-orgs.js +67 -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 +7 -0
- package/dist/catalog/scope-sync-workers.js +29 -0
- package/dist/catalog/scope-sync.d.ts +176 -0
- package/dist/catalog/scope-sync.js +576 -0
- package/dist/catalog/scope.d.ts +42 -0
- package/dist/catalog/scope.js +42 -0
- package/dist/catalog/unshare.d.ts +22 -0
- package/dist/catalog/unshare.js +118 -0
- package/dist/channels/actions.js +1 -0
- package/dist/channels/cards.js +20 -2
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/inbound.d.ts +9 -1
- package/dist/channels/inbound.js +67 -5
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +29 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +10 -2
- package/dist/config/schema.js +70 -22
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +27 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/conversations.controller.d.ts +43 -18
- package/dist/conversations/conversations.controller.js +79 -38
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.service.d.ts +73 -15
- package/dist/conversations/conversations.service.js +115 -35
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +20 -5
- package/dist/conversations/event-log.js +60 -0
- package/dist/conversations/events.d.ts +84 -2
- package/dist/conversations/events.js +91 -17
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +5 -0
- package/dist/conversations/titles.d.ts +5 -3
- package/dist/conversations/titles.js +21 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +38 -7
- package/dist/db/kernel-schema.d.ts +386 -18
- package/dist/environments/access.d.ts +41 -0
- package/dist/environments/access.js +77 -0
- package/dist/environments/conversation-environments.d.ts +61 -0
- package/dist/environments/conversation-environments.js +170 -0
- package/dist/environments/dto.d.ts +25 -0
- package/dist/environments/dto.js +12 -0
- package/dist/environments/environments.controller.d.ts +33 -0
- package/dist/environments/environments.controller.js +110 -0
- package/dist/environments/environments.module.d.ts +8 -0
- package/dist/environments/environments.module.js +27 -0
- package/dist/environments/environments.service.d.ts +153 -0
- package/dist/environments/environments.service.js +541 -0
- package/dist/environments/legacy-cleanup.job.d.ts +34 -0
- package/dist/environments/legacy-cleanup.job.js +141 -0
- package/dist/errors.d.ts +85 -2
- package/dist/errors.js +85 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +4 -2
- package/dist/evals/run-replay.js +20 -6
- package/dist/evals/runs.service.d.ts +2 -1
- package/dist/evals/runs.service.js +13 -12
- package/dist/evals/step-replay.d.ts +4 -6
- package/dist/evals/step-replay.js +4 -3
- 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 +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +65 -42
- package/dist/extensions/admin-view.d.ts +37 -10
- package/dist/extensions/admin-view.js +103 -20
- package/dist/extensions/bootstrap.d.ts +17 -4
- package/dist/extensions/bootstrap.js +70 -9
- package/dist/extensions/cli.d.ts +12 -0
- package/dist/extensions/cli.js +11 -2
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +28 -5
- package/dist/extensions/deployment-config.js +48 -7
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +11 -11
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +24 -10
- package/dist/extensions/host.js +49 -54
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +75 -6
- package/dist/extensions/org-config.js +184 -32
- 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/permission-view.d.ts +16 -4
- package/dist/extensions/permission-view.js +4 -4
- package/dist/extensions/plugin-items.d.ts +21 -0
- package/dist/extensions/plugin-items.js +42 -0
- package/dist/extensions/point-defaults.d.ts +12 -5
- package/dist/extensions/point-defaults.js +37 -9
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +25 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +29 -29
- package/dist/identity/accounts.js +47 -47
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.js +1 -1
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/settings.d.ts +22 -11
- package/dist/identity/settings.js +53 -18
- 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/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +7 -3
- package/dist/inbox/inbox.service.d.ts +62 -3
- package/dist/inbox/inbox.service.js +74 -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 +151 -0
- package/dist/inbox/platform-inbox.service.js +263 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +24 -1
- package/dist/infra/database/xact-lock.d.ts +1 -1
- package/dist/infra/database/xact-lock.js +1 -1
- package/dist/infra/events/kernel-events.d.ts +19 -2
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/kernel.module.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
- package/dist/lifecycle/kernel-lifecycle.js +4 -4
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +99 -0
- package/dist/models/enablement.js +263 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/prices.d.ts +5 -5
- package/dist/models/prices.js +4 -4
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +37 -12
- package/dist/models/purposes.js +63 -17
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +9 -7
- package/dist/orgs/offboarding.js +28 -17
- package/dist/orgs/org-lock.d.ts +5 -0
- package/dist/orgs/org-lock.js +13 -0
- package/dist/orgs/org.guard.d.ts +10 -0
- package/dist/orgs/org.guard.js +43 -32
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.service.d.ts +20 -7
- package/dist/orgs/orgs.service.js +32 -12
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +5 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +15 -3
- package/dist/orgs/settings.service.js +6 -2
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- 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 +11 -0
- package/dist/platform/errors.js +26 -0
- package/dist/platform/exclusions.d.ts +12 -0
- package/dist/platform/exclusions.js +1405 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +92 -0
- package/dist/platform/operation.js +35 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
- package/dist/platform/ops/agent-templates.ops.js +92 -0
- package/dist/platform/ops/agents.ops.d.ts +19 -0
- package/dist/platform/ops/agents.ops.js +294 -0
- package/dist/platform/ops/connectors.ops.d.ts +15 -0
- package/dist/platform/ops/connectors.ops.js +126 -0
- package/dist/platform/ops/errors.d.ts +11 -0
- package/dist/platform/ops/errors.js +22 -0
- package/dist/platform/ops/extensions.ops.d.ts +19 -0
- package/dist/platform/ops/extensions.ops.js +116 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
- package/dist/platform/ops/marketplaces.ops.js +157 -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 +23 -0
- package/dist/platform/ops/platform.ops.js +158 -0
- package/dist/platform/ops/plugins.ops.d.ts +33 -0
- package/dist/platform/ops/plugins.ops.js +377 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +153 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/skills.ops.d.ts +13 -0
- package/dist/platform/ops/skills.ops.js +98 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/platform-ops.module.d.ts +7 -0
- package/dist/platform/platform-ops.module.js +55 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/redact-orgs.d.ts +7 -0
- package/dist/platform/redact-orgs.js +52 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/roles/worker-role.d.ts +6 -4
- package/dist/roles/worker-role.js +14 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +9 -1
- package/dist/runtime/context/build.d.ts +6 -4
- package/dist/runtime/context/build.js +26 -7
- package/dist/runtime/context/claude-tools.d.ts +2 -1
- package/dist/runtime/context/claude-tools.js +5 -4
- package/dist/runtime/context/compaction.js +9 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/skills.js +9 -2
- package/dist/runtime/context/tool-changes.d.ts +27 -0
- package/dist/runtime/context/tool-changes.js +60 -0
- package/dist/runtime/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -7
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +35 -17
- package/dist/runtime/loop.d.ts +32 -4
- package/dist/runtime/maintenance.d.ts +7 -4
- package/dist/runtime/maintenance.js +23 -8
- package/dist/runtime/model-call.d.ts +38 -11
- package/dist/runtime/model-call.js +97 -24
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +321 -67
- package/dist/runtime/run-control.d.ts +11 -1
- package/dist/runtime/run-control.js +12 -0
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-jobs.d.ts +3 -5
- package/dist/runtime/run-jobs.js +3 -7
- package/dist/runtime/run-queue.d.ts +37 -3
- package/dist/runtime/run-queue.js +188 -11
- package/dist/runtime/run-worker.d.ts +12 -6
- package/dist/runtime/run-worker.js +58 -35
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/step-log.d.ts +9 -4
- package/dist/runtime/step-log.js +8 -5
- package/dist/runtime/stream.controller.d.ts +23 -1
- package/dist/runtime/stream.controller.js +60 -3
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +27 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +105 -7
- package/dist/runtime/subagents/definition.d.ts +12 -3
- package/dist/runtime/subagents/definition.js +46 -32
- package/dist/runtime/subagents/deliveries.d.ts +71 -0
- package/dist/runtime/subagents/deliveries.js +228 -0
- package/dist/runtime/subagents/dispatch.d.ts +115 -26
- package/dist/runtime/subagents/dispatch.js +212 -141
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +95 -0
- package/dist/runtime/subagents/messages.js +328 -0
- package/dist/runtime/subagents/preamble.d.ts +4 -4
- package/dist/runtime/subagents/preamble.js +9 -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 +30 -0
- package/dist/runtime/subagents/render.js +53 -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 +3 -2
- package/dist/runtime/subagents/skill-fork.js +8 -4
- 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 +11 -6
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +169 -96
- package/dist/runtime/waits.d.ts +140 -37
- package/dist/runtime/waits.js +394 -106
- package/dist/sandbox/jobs.d.ts +40 -13
- package/dist/sandbox/jobs.js +57 -20
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/providers.d.ts +2 -2
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +4 -3
- package/dist/sandbox/sandbox.service.d.ts +229 -134
- package/dist/sandbox/sandbox.service.js +630 -409
- package/dist/skills/catalog.d.ts +3 -2
- package/dist/skills/catalog.js +21 -43
- package/dist/skills/changes.controller.d.ts +7 -0
- package/dist/skills/changes.controller.js +19 -1
- package/dist/skills/invoke.js +8 -3
- package/dist/skills/package.d.ts +20 -1
- package/dist/skills/package.js +28 -1
- package/dist/skills/skills.controller.d.ts +39 -4
- package/dist/skills/skills.controller.js +88 -10
- package/dist/skills/skills.module.js +10 -1
- package/dist/skills/skills.service.d.ts +106 -26
- package/dist/skills/skills.service.js +421 -75
- package/dist/skills/usable.d.ts +81 -0
- package/dist/skills/usable.js +379 -0
- package/dist/tools/approvals.service.d.ts +20 -2
- package/dist/tools/approvals.service.js +23 -4
- package/dist/tools/builtin-names.d.ts +21 -5
- package/dist/tools/builtin-names.js +30 -5
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/builtin-tools.d.ts +6 -2
- package/dist/tools/builtins/builtin-tools.js +37 -12
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +34 -0
- package/dist/tools/builtins/platform.js +362 -0
- package/dist/tools/builtins/sandbox/bash.js +13 -3
- package/dist/tools/builtins/sandbox/common.d.ts +43 -24
- package/dist/tools/builtins/sandbox/common.js +80 -45
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -4
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +14 -3
- package/dist/tools/builtins/sandbox/task-output.js +30 -5
- package/dist/tools/builtins/sandbox/task-stop.js +2 -1
- package/dist/tools/builtins/sandbox/write.js +2 -2
- 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 +22 -14
- package/dist/tools/builtins/skill-load.js +86 -57
- package/dist/tools/builtins/skill-write.js +1 -1
- package/dist/tools/builtins/web/extract.js +5 -1
- package/dist/tools/builtins/web/fetch.js +1 -0
- package/dist/tools/builtins/web/search.js +1 -0
- package/dist/tools/connectors.controller.d.ts +10 -0
- package/dist/tools/connectors.controller.js +12 -0
- package/dist/tools/connectors.service.d.ts +46 -5
- package/dist/tools/connectors.service.js +94 -15
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/info.d.ts +42 -1
- package/dist/tools/info.js +64 -1
- package/dist/tools/org-tool-switches.d.ts +74 -0
- package/dist/tools/org-tool-switches.js +184 -0
- package/dist/tools/pipeline.d.ts +46 -40
- package/dist/tools/pipeline.js +193 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +98 -5
- package/dist/tools/registry.js +87 -9
- package/dist/tools/tools.module.js +12 -2
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -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/dist/catalog/upgrade-targets.d.ts +0 -56
- package/dist/catalog/upgrade-targets.js +0 -90
- package/dist/conversations/sandbox-status.d.ts +0 -24
- package/dist/conversations/sandbox-status.js +0 -52
- package/dist/extensions/org-config.controller.d.ts +0 -32
- package/dist/extensions/org-config.controller.js +0 -70
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { Annotation, END, START, StateGraph } from "@langchain/langgraph";
|
|
2
2
|
import { MediaCache } from "./media-cache.js";
|
|
3
3
|
import { runFinalWrapUp, runModelStep, } from "./model-call.js";
|
|
4
|
-
import { subagentBudgetUsedUp } from "./subagents/limits.js";
|
|
4
|
+
import { budgetRunOf, subagentBudgetUsedUp } from "./subagents/limits.js";
|
|
5
5
|
import { isForkInvocation } from "./subagents/skill-fork.js";
|
|
6
6
|
/**
|
|
7
7
|
* 图状态:只记录进度,消息每步从事件日志重建(runModelStep 自己读日志),checkpoint 很小。
|
|
8
8
|
* - `step`:当前(最近一次进入的)步骤编号,prepare 节点 +1;
|
|
9
|
-
* - `consumedUpToSeq`:已吸收的最大可吸收事件 seq(user_message / background_task_finished
|
|
10
|
-
* finish TaskOutput or TaskStop already reported is absorbed like any
|
|
9
|
+
* - `consumedUpToSeq`:已吸收的最大可吸收事件 seq(user_message / background_task_finished /
|
|
10
|
+
* subagent_delivery; a finish TaskOutput or TaskStop already reported is absorbed like any
|
|
11
|
+
* other, rendered short);
|
|
11
12
|
* - `lastStopReason`:最近一步模型调用的停止原因;
|
|
12
13
|
* - `outcome`:图的结束方式(在决定结束的节点里写入,续跑已结束的图时直接读出,不依赖当前时间)。
|
|
14
|
+
* - `budgetWrapUp`: set when a sub-agent's tree used its token budget after the run made a step: the
|
|
15
|
+
* run goes to the `wrapUp` node for one tool-less call that hands back what it found, then ends
|
|
16
|
+
* with `budget` (sub-agents spec §8.3). Null otherwise (the step limit routes there by `step`; a channel cannot share the
|
|
17
|
+
* node's name).
|
|
13
18
|
*
|
|
14
19
|
* 所有 channel 都是默认的 LastValue(不用实验性的 DeltaChannel,也没有子图):
|
|
15
20
|
* 每个 checkpoint 自带完整状态,`pruneToLatest` 之后仍能独立还原(R19)。
|
|
@@ -19,8 +24,15 @@ const LoopState = Annotation.Root({
|
|
|
19
24
|
consumedUpToSeq: Annotation(),
|
|
20
25
|
lastStopReason: Annotation(),
|
|
21
26
|
outcome: Annotation(),
|
|
27
|
+
budgetWrapUp: Annotation(),
|
|
22
28
|
});
|
|
23
|
-
const INITIAL = {
|
|
29
|
+
const INITIAL = {
|
|
30
|
+
step: 0,
|
|
31
|
+
consumedUpToSeq: 0,
|
|
32
|
+
lastStopReason: null,
|
|
33
|
+
outcome: null,
|
|
34
|
+
budgetWrapUp: null,
|
|
35
|
+
};
|
|
24
36
|
/**
|
|
25
37
|
* prepare 节点在停机信号下抛出:本次 invoke 以它结束,checkpoint 停在 prepare 之前
|
|
26
38
|
* (LangGraph 把出错的任务记为该 checkpoint 上的 pending error,`invoke(null)` 续跑时重新执行它)。
|
|
@@ -56,7 +68,9 @@ class LoopSuspended extends Error {
|
|
|
56
68
|
* worker 崩溃后由其他副本从最近的 checkpoint 续跑(spec 4.4、Review Focus 1)。
|
|
57
69
|
*
|
|
58
70
|
* 图:`prepare → model →(tool_use)tools → prepare …`;prepare 发现步数超过上限 → `wrapUp` → 结束;
|
|
59
|
-
* prepare finding the deadline passed
|
|
71
|
+
* prepare finding the deadline passed → end; a sub-agent's run finding its tree's token budget used
|
|
72
|
+
* up → `wrapUp` (one tool-less call that hands back its findings) → end, or end at once when the
|
|
73
|
+
* run has made no step yet (nothing new to report);
|
|
60
74
|
* 模型中止或正常结束 → 结束。`durability: "sync"`:每个节点的 checkpoint 在下一个节点开始前落库。
|
|
61
75
|
*
|
|
62
76
|
* 幂等:`runModelStep` / `runFinalWrapUp` 按 (runId, step) 幂等,续跑重新执行 model 节点时若回复已在日志里,
|
|
@@ -130,6 +144,7 @@ export class LangGraphLoop {
|
|
|
130
144
|
accountId: ctx.triggerAccountId,
|
|
131
145
|
...(ctx.conversationKind !== undefined && { conversationKind: ctx.conversationKind }),
|
|
132
146
|
...(ctx.parent !== undefined && { parentRunId: ctx.parent.runId, parent: ctx.parent }),
|
|
147
|
+
...(ctx.subagent === true && { subagent: true }),
|
|
133
148
|
});
|
|
134
149
|
const deps = this.stepDeps;
|
|
135
150
|
const hooks = this.hooks;
|
|
@@ -140,11 +155,14 @@ export class LangGraphLoop {
|
|
|
140
155
|
// 否则 consumed_seq 越过它们、也不会再起新一轮。
|
|
141
156
|
if (timedOut())
|
|
142
157
|
return { outcome: "max_duration" };
|
|
143
|
-
// a sub-agent stops before its next request once its
|
|
144
|
-
//
|
|
158
|
+
// a sub-agent stops before its next request once its tree used its token budget (spec §8.3,
|
|
159
|
+
// agent map §6: on the budget run; fresh read, in-flight requests of others may overshoot by
|
|
160
|
+
// one each). A run that made a step hands back what it found in one final tool-less call
|
|
161
|
+
// (one more over); a run stopped before its first step (a wake of a stopped tree) has
|
|
162
|
+
// nothing new to report and ends at once.
|
|
145
163
|
if (ctx.parent !== undefined &&
|
|
146
|
-
(await subagentBudgetUsedUp(deps.db, deps.config, ctx.orgId, ctx.parent.runId))) {
|
|
147
|
-
return { outcome: "budget" };
|
|
164
|
+
(await subagentBudgetUsedUp(deps.db, deps.config, ctx.orgId, ctx.parent.budgetRunId ?? (await budgetRunOf(deps.db, ctx.parent.runId))))) {
|
|
165
|
+
return s.step > 0 ? { step: s.step + 1, budgetWrapUp: true } : { outcome: "budget" };
|
|
148
166
|
}
|
|
149
167
|
let consumed = s.consumedUpToSeq;
|
|
150
168
|
// the run's first prepare (also when it runs again after a suspend on its fork's sub-agent)
|
|
@@ -173,8 +191,10 @@ export class LangGraphLoop {
|
|
|
173
191
|
const model = async (s) => {
|
|
174
192
|
const r = await runModelStep(deps, input(s.step, s.consumedUpToSeq));
|
|
175
193
|
await hooks.afterModelStep?.(ctx.runId, s.step, r);
|
|
194
|
+
// budget used up by a compaction call before the step's request: hand back in the wrap-up,
|
|
195
|
+
// at this step (it logged no request)
|
|
176
196
|
if (r.budget)
|
|
177
|
-
return {
|
|
197
|
+
return { budgetWrapUp: true };
|
|
178
198
|
if (r.aborted) {
|
|
179
199
|
return { lastStopReason: "aborted", outcome: timedOut() ? "max_duration" : "aborted" };
|
|
180
200
|
}
|
|
@@ -218,11 +238,12 @@ export class LangGraphLoop {
|
|
|
218
238
|
return {};
|
|
219
239
|
};
|
|
220
240
|
const wrapUp = async (s) => {
|
|
221
|
-
const
|
|
241
|
+
const budget = s.budgetWrapUp === true;
|
|
242
|
+
const r = await runFinalWrapUp(deps, input(s.step, s.consumedUpToSeq), budget ? "budget" : "max_steps");
|
|
222
243
|
await hooks.afterModelStep?.(ctx.runId, s.step, r);
|
|
223
244
|
return {
|
|
224
245
|
lastStopReason: r.aborted ? "aborted" : r.stopReason,
|
|
225
|
-
outcome: r.
|
|
246
|
+
outcome: r.aborted && !timedOut() ? "aborted" : budget || r.budget ? "budget" : "max_steps",
|
|
226
247
|
};
|
|
227
248
|
};
|
|
228
249
|
return new StateGraph(LoopState)
|
|
@@ -235,12 +256,9 @@ export class LangGraphLoop {
|
|
|
235
256
|
// (aborted / completed: a fork invocation's run ended in its first prepare, phase D)
|
|
236
257
|
if (s.outcome !== null)
|
|
237
258
|
return END;
|
|
238
|
-
return s.step > ctx.limits.maxSteps ? "wrapUp" : "model";
|
|
259
|
+
return s.budgetWrapUp === true || s.step > ctx.limits.maxSteps ? "wrapUp" : "model";
|
|
239
260
|
}, ["model", "wrapUp", END])
|
|
240
|
-
.addConditionalEdges("model", (s) => (s.outcome === null ? "tools" : END), [
|
|
241
|
-
"tools",
|
|
242
|
-
END,
|
|
243
|
-
])
|
|
261
|
+
.addConditionalEdges("model", (s) => (s.budgetWrapUp === true ? "wrapUp" : s.outcome === null ? "tools" : END), ["tools", "wrapUp", END])
|
|
244
262
|
.addEdge("tools", "prepare")
|
|
245
263
|
.addEdge("wrapUp", END)
|
|
246
264
|
.compile({ checkpointer: this.saver });
|
package/dist/runtime/loop.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export interface LoopContext {
|
|
|
22
22
|
shutdown: AbortSignal;
|
|
23
23
|
sink: StreamSink;
|
|
24
24
|
/**
|
|
25
|
-
* 下一个步骤间隙要吸收的事件:返回 seq > afterSeq 的可吸收事件(`user_message
|
|
26
|
-
* `background_task_finished`, `isAbsorbable`;且只含本轮开始时尚未被消费的,
|
|
25
|
+
* 下一个步骤间隙要吸收的事件:返回 seq > afterSeq 的可吸收事件(`user_message`、
|
|
26
|
+
* `background_task_finished` 与 `subagent_delivery`, `isAbsorbable`;且只含本轮开始时尚未被消费的,
|
|
27
27
|
* 即 seq 也大于会话的 `consumed_seq`),按 seq 升序。loop 记录吸收到的最大 seq 作为 `consumedUpToSeq`。
|
|
28
28
|
*/
|
|
29
29
|
pendingAbsorbable(afterSeq: number): Promise<AbsorbableEvent[]>;
|
|
@@ -37,21 +37,49 @@ export interface LoopContext {
|
|
|
37
37
|
*/
|
|
38
38
|
conversationKind?: "chat" | "eval" | "subagent";
|
|
39
39
|
/**
|
|
40
|
-
* Set for a sub-agent's run (phase C): the dispatch this run serves. Its tools use the
|
|
41
|
-
* conversation's sandbox (spec §10.1), and it
|
|
40
|
+
* Set for a sub-agent's run (phase C): the dispatch this run serves. Its tools use the root
|
|
41
|
+
* conversation's sandbox (spec §10.1), and it dispatches sub-agents only while its depth is
|
|
42
|
+
* below `subagents.maxDepth` (agent map spec §4.1).
|
|
42
43
|
*/
|
|
43
44
|
parent?: SubagentParent;
|
|
45
|
+
/**
|
|
46
|
+
* The run is a sub-agent's without a live `parent`: a child case's eval replay. Its requests
|
|
47
|
+
* offer the message tools a sub-agent has (`SendMessage`, `SubagentHandback`), as the recorded
|
|
48
|
+
* run's did; not for a fork invocation's child (`SubagentParent.forSkill`). Implied by `parent`.
|
|
49
|
+
*/
|
|
50
|
+
subagent?: boolean;
|
|
44
51
|
}
|
|
45
52
|
/** Where a sub-agent's run was dispatched from (its `subagent_dispatches` row). */
|
|
46
53
|
export interface SubagentParent {
|
|
47
54
|
conversationId: string;
|
|
48
55
|
runId: string;
|
|
49
56
|
callId: string;
|
|
57
|
+
/**
|
|
58
|
+
* The parent conversation's depth below the root (0: the parent is the root); this run's own
|
|
59
|
+
* depth is one more (agent map spec §6, `conversations.subagent_depth`).
|
|
60
|
+
*/
|
|
61
|
+
depth: number;
|
|
62
|
+
/** The root conversation of the tree: its sandbox is the one every sub-agent works in. */
|
|
63
|
+
rootConversationId: string;
|
|
50
64
|
/**
|
|
51
65
|
* The child runs another org agent than its parent conversation's (§5.5, `template.source`
|
|
52
66
|
* `agent`): only then the parent agent's current policies are read on top of its own.
|
|
53
67
|
*/
|
|
54
68
|
otherAgent?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The tree's budget run of this child run (agent map spec §6): the run's own `budget_run_id`
|
|
71
|
+
* (a dispatched run's, or a wake run's current window of the root), else its dispatch row's, read
|
|
72
|
+
* once when the run starts. The loop's budget check and the token counter (`appendCounted`) use
|
|
73
|
+
* it; absent only when unknown, then read with `budgetRunOf(runId)` (the parent run's window,
|
|
74
|
+
* stale for a wake run, whose `runId` is the first dispatch's).
|
|
75
|
+
*/
|
|
76
|
+
budgetRunId?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The run is a person's fork invocation's child (phase D, its dispatch's `for_skill`): its parent
|
|
79
|
+
* run waits for its final reply as the skill's report, so it gets neither `SubagentHandback` nor
|
|
80
|
+
* `SendMessage` to its parent (agent map spec §5.4: the fork's behaviour does not change).
|
|
81
|
+
*/
|
|
82
|
+
forSkill?: boolean;
|
|
55
83
|
}
|
|
56
84
|
/**
|
|
57
85
|
* 运行在等什么人处理:审批(`approvals` 行)或输入请求(`questions` 行,统一承载 `AskUserQuestion`、
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WorkerHost } from "@nestjs/bullmq";
|
|
2
2
|
import type { Job, Queue, Worker } from "bullmq";
|
|
3
|
+
import { OwnedPluginCleanup } from "../catalog/owned-plugin-cleanup.js";
|
|
3
4
|
import { ScheduledRuns } from "../infra/schedule/scheduled-runs.js";
|
|
4
5
|
import type { KernelLogger } from "../log.js";
|
|
5
6
|
import { DirectorySync } from "../orgs/directory-sync.js";
|
|
@@ -12,9 +13,10 @@ export { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
|
|
|
12
13
|
export declare const MAINTENANCE_CONCURRENCY = 5;
|
|
13
14
|
/**
|
|
14
15
|
* The one consumer of `cap-kernel-maintenance` (decision R11 of the Nest kernel spec): dispatches
|
|
15
|
-
* each one-off job by name to its domain (`wait-timeout` → {@link Waits}, `sandbox-destroy-for`
|
|
16
|
-
* {@link SandboxService}, `drift-connector` → {@link ToolDrift}, `directory-sync` →
|
|
17
|
-
* {@link DirectorySync}, `bg-wake` → {@link RunQueue.ensureRun}
|
|
16
|
+
* each one-off job by name to its domain (`wait-timeout` → {@link Waits}, `sandbox-destroy-for` and
|
|
17
|
+
* `sandbox-reset-files` → {@link SandboxService}, `drift-connector` → {@link ToolDrift}, `directory-sync` →
|
|
18
|
+
* {@link DirectorySync}, `bg-wake` → {@link RunQueue.ensureRun}, `owned-plugin-cleanup` →
|
|
19
|
+
* {@link OwnedPluginCleanup}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
18
20
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
19
21
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
20
22
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -26,10 +28,11 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
|
26
28
|
private readonly drift;
|
|
27
29
|
private readonly directory;
|
|
28
30
|
private readonly runs;
|
|
31
|
+
private readonly ownedCleanup;
|
|
29
32
|
private readonly scheduled;
|
|
30
33
|
private readonly log;
|
|
31
34
|
private readonly queue;
|
|
32
|
-
constructor(waits: Pick<Waits, "processTimeout">, sandbox: Pick<SandboxService, "
|
|
35
|
+
constructor(waits: Pick<Waits, "processTimeout">, sandbox: Pick<SandboxService, "destroyEnvironment" | "resetFileSystem">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, runs: Pick<RunQueue, "ensureRun">, ownedCleanup: Pick<OwnedPluginCleanup, "run">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, queue: Pick<Queue, "removeJobScheduler">);
|
|
33
36
|
/**
|
|
34
37
|
* Removes the retired job schedulers (`RETIRED_SCHEDULER_IDS`, runtime/retired-schedulers.ts): every fixed-period
|
|
35
38
|
* maintenance job is a `@LockedCron` / `@LockedInterval` now. Idempotent; called once when a
|
|
@@ -10,6 +10,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { getQueueToken, OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
|
|
11
11
|
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
12
12
|
import { BG_WAKE_JOB } from "../background/wake-rules.js";
|
|
13
|
+
import { OWNED_PLUGIN_CLEANUP_JOB } from "../catalog/job-ids.js";
|
|
14
|
+
import { OwnedPluginCleanup, OwnedPluginCleanupModule } from "../catalog/owned-plugin-cleanup.js";
|
|
13
15
|
import { configuredProcessor } from "../infra/queue/configured-processor.js";
|
|
14
16
|
import { QueueModule } from "../infra/queue/queue.module.js";
|
|
15
17
|
import { removeRetiredSchedulers } from "../infra/queue/retired-schedulers.js";
|
|
@@ -19,7 +21,7 @@ import { ScheduledRuns } from "../infra/schedule/scheduled-runs.js";
|
|
|
19
21
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
20
22
|
import { DIRECTORY_SYNC_JOB, DirectorySync } from "../orgs/directory-sync.js";
|
|
21
23
|
import { OrgsModule } from "../orgs/orgs.module.js";
|
|
22
|
-
import { runSandboxDestroyFor, SANDBOX_DESTROY_FOR_JOB } from "../sandbox/jobs.js";
|
|
24
|
+
import { runSandboxDestroyFor, runSandboxResetFiles, SANDBOX_DESTROY_FOR_JOB, SANDBOX_RESET_FILES_JOB, } from "../sandbox/jobs.js";
|
|
23
25
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
24
26
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
25
27
|
import { ToolDrift } from "../tools/drift.js";
|
|
@@ -35,9 +37,10 @@ export { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
|
|
|
35
37
|
export const MAINTENANCE_CONCURRENCY = 5;
|
|
36
38
|
/**
|
|
37
39
|
* The one consumer of `cap-kernel-maintenance` (decision R11 of the Nest kernel spec): dispatches
|
|
38
|
-
* each one-off job by name to its domain (`wait-timeout` → {@link Waits}, `sandbox-destroy-for`
|
|
39
|
-
* {@link SandboxService}, `drift-connector` → {@link ToolDrift}, `directory-sync` →
|
|
40
|
-
* {@link DirectorySync}, `bg-wake` → {@link RunQueue.ensureRun}
|
|
40
|
+
* each one-off job by name to its domain (`wait-timeout` → {@link Waits}, `sandbox-destroy-for` and
|
|
41
|
+
* `sandbox-reset-files` → {@link SandboxService}, `drift-connector` → {@link ToolDrift}, `directory-sync` →
|
|
42
|
+
* {@link DirectorySync}, `bg-wake` → {@link RunQueue.ensureRun}, `owned-plugin-cleanup` →
|
|
43
|
+
* {@link OwnedPluginCleanup}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
41
44
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
42
45
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
43
46
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -49,16 +52,18 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
49
52
|
drift;
|
|
50
53
|
directory;
|
|
51
54
|
runs;
|
|
55
|
+
ownedCleanup;
|
|
52
56
|
scheduled;
|
|
53
57
|
log;
|
|
54
58
|
queue;
|
|
55
|
-
constructor(waits, sandbox, drift, directory, runs, scheduled, log, queue) {
|
|
59
|
+
constructor(waits, sandbox, drift, directory, runs, ownedCleanup, scheduled, log, queue) {
|
|
56
60
|
super();
|
|
57
61
|
this.waits = waits;
|
|
58
62
|
this.sandbox = sandbox;
|
|
59
63
|
this.drift = drift;
|
|
60
64
|
this.directory = directory;
|
|
61
65
|
this.runs = runs;
|
|
66
|
+
this.ownedCleanup = ownedCleanup;
|
|
62
67
|
this.scheduled = scheduled;
|
|
63
68
|
this.log = log;
|
|
64
69
|
this.queue = queue;
|
|
@@ -86,6 +91,9 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
86
91
|
case SANDBOX_DESTROY_FOR_JOB:
|
|
87
92
|
await runSandboxDestroyFor(this.sandbox, this.log, job);
|
|
88
93
|
return;
|
|
94
|
+
case SANDBOX_RESET_FILES_JOB:
|
|
95
|
+
await runSandboxResetFiles(this.sandbox, job);
|
|
96
|
+
return;
|
|
89
97
|
case DRIFT_CONNECTOR_JOB: {
|
|
90
98
|
const { orgId, connectorId, trigger } = job.data;
|
|
91
99
|
await this.drift.check(orgId, connectorId, trigger);
|
|
@@ -101,6 +109,10 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
101
109
|
await this.runs.ensureRun(conversationId, { wakeRetry: (retry ?? 0) + 1 });
|
|
102
110
|
return;
|
|
103
111
|
}
|
|
112
|
+
// a removed org-owned plugin's extension (plugin scope phase 3, P3-20)
|
|
113
|
+
case OWNED_PLUGIN_CLEANUP_JOB:
|
|
114
|
+
await this.ownedCleanup.run(job.data.itemId);
|
|
115
|
+
return;
|
|
104
116
|
default:
|
|
105
117
|
if (await this.scheduled.runNow(job.name))
|
|
106
118
|
return;
|
|
@@ -127,9 +139,10 @@ MaintenanceProcessor = __decorate([
|
|
|
127
139
|
__param(2, Inject(ToolDrift)),
|
|
128
140
|
__param(3, Inject(DirectorySync)),
|
|
129
141
|
__param(4, Inject(RunQueue)),
|
|
130
|
-
__param(5, Inject(
|
|
131
|
-
__param(6, Inject(
|
|
132
|
-
__param(7, Inject(
|
|
142
|
+
__param(5, Inject(OwnedPluginCleanup)),
|
|
143
|
+
__param(6, Inject(ScheduledRuns)),
|
|
144
|
+
__param(7, Inject(KERNEL_LOGGER)),
|
|
145
|
+
__param(8, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME)))
|
|
133
146
|
], MaintenanceProcessor);
|
|
134
147
|
export { MaintenanceProcessor };
|
|
135
148
|
/**
|
|
@@ -149,6 +162,8 @@ MaintenanceModule = __decorate([
|
|
|
149
162
|
SandboxModule,
|
|
150
163
|
ToolsModule,
|
|
151
164
|
OrgsModule,
|
|
165
|
+
// the removed org plugins' cleanup and its daily sweep (worker-only through this module)
|
|
166
|
+
OwnedPluginCleanupModule,
|
|
152
167
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
153
168
|
],
|
|
154
169
|
providers: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContentBlock, type Logger, type
|
|
1
|
+
import { type ContentBlock, type Logger, type ModelRequest, type ModelStreamEvent, type ModelUsage, type StopReason } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { AgentDefinition } from "../agents/definition.js";
|
|
3
3
|
import type { AppendEvent, EventLog } from "../conversations/event-log.js";
|
|
4
4
|
import { type ConversationEvent } from "../conversations/events.js";
|
|
@@ -9,22 +9,38 @@ import { type BuildModelRequestInput, type MediaBytes, type MediaInfo, type Mode
|
|
|
9
9
|
import { type ConversationKindForHooks, type HookRunner } from "./hook-calls.js";
|
|
10
10
|
import type { SubagentParent } from "./loop.js";
|
|
11
11
|
import { MediaCache } from "./media-cache.js";
|
|
12
|
-
import { type ProviderRegistry } from "./providers.js";
|
|
12
|
+
import { type BoundProvider, type ProviderRegistry } from "./providers.js";
|
|
13
13
|
import type { StepLog } from "./step-log.js";
|
|
14
14
|
import type { UsageReporter } from "./usage-report.js";
|
|
15
15
|
/** 单轮收尾的尾部提醒(模型可见,英文;spec 6 轮次额度收尾)。 */
|
|
16
16
|
export declare const WRAP_UP_REMINDER = "Step limit reached. Do not call tools. Summarize what you found and what remains for the user.";
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The tail reminder of a sub-agent's final call once its tree used its token budget (model-visible,
|
|
19
|
+
* English; sub-agents spec §8.3): the child hands back what it found instead of ending with nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare const BUDGET_WRAP_UP_REMINDER: string;
|
|
22
|
+
/** Why a run makes its final, tool-less call: its step limit, or its tree's token budget. */
|
|
23
|
+
export type WrapUpReason = "max_steps" | "budget";
|
|
24
|
+
export { TOOLS_UNSUPPORTED_REMINDER } from "./context/reminders.js";
|
|
19
25
|
/** 不可用工具提醒的前缀(模型可见,英文)。 */
|
|
20
26
|
export declare const TOOLS_UNAVAILABLE_PREFIX = "The following tools are unavailable in this run: ";
|
|
21
27
|
/** 本 run 中此前有工具不可用、现在全部恢复时的提醒(模型可见,英文)。 */
|
|
22
28
|
export declare const TOOLS_AVAILABLE_AGAIN = "All previously unavailable tools are available again.";
|
|
23
29
|
/** 不可用工具提醒:`The following tools are unavailable in this run: <ref> (<reason>), ...`。 */
|
|
24
30
|
export declare function toolsUnavailableReminder(unavailable: readonly UnavailableTool[]): string;
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* `run_failed` message of a model request denied by a policy hook (user-facing, never model-visible);
|
|
33
|
+
* also the message of the `model.hook_denied` error a denied `ctx.models.embed` call rejects with.
|
|
34
|
+
*/
|
|
35
|
+
export declare const modelDeniedText: (plugin: string, reason: string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* 流式增量的出口(推给前端等订阅方);`step_reset` 表示丢弃本步已推出的增量、重新开始。
|
|
38
|
+
* `stream_end` (the step's model stream completed) and `step_end` (the step's `assistant_message`
|
|
39
|
+
* is logged) carry no delta: the run worker's sink writes and then clears the step's live draft on
|
|
40
|
+
* them (spec 2026-11-07 §3.2) and publishes neither.
|
|
41
|
+
*/
|
|
26
42
|
export type StreamSink = (delta: {
|
|
27
|
-
kind: "text" | "thinking" | "step_reset";
|
|
43
|
+
kind: "text" | "thinking" | "step_reset" | "stream_end" | "step_end";
|
|
28
44
|
runId: string;
|
|
29
45
|
step: number;
|
|
30
46
|
text?: string;
|
|
@@ -95,9 +111,12 @@ export interface ModelStepInput {
|
|
|
95
111
|
conversationKind?: ConversationKindForHooks;
|
|
96
112
|
/** A sub-agent's run: where it was dispatched from (hook payloads carry it as `parent`). */
|
|
97
113
|
parent?: SubagentParent;
|
|
114
|
+
/** A sub-agent's run without a live parent (a child case's eval replay, `LoopContext`). */
|
|
115
|
+
subagent?: boolean;
|
|
98
116
|
/**
|
|
99
|
-
* A sub-agent's run (phase C): the parent run whose `subagent_tokens_used` counts
|
|
100
|
-
* event this step writes (step, wrap-up and compaction calls; spec §8.3
|
|
117
|
+
* A sub-agent's run (phase C): the parent run whose budget run's `subagent_tokens_used` counts
|
|
118
|
+
* every usage event this step writes (step, wrap-up and compaction calls; spec §8.3, agent map
|
|
119
|
+
* spec §6).
|
|
101
120
|
*/
|
|
102
121
|
parentRunId?: string;
|
|
103
122
|
/**
|
|
@@ -150,13 +169,16 @@ export declare function runModelStep(deps: ModelStepDeps, input: ModelStepInput)
|
|
|
150
169
|
* 单轮收尾:到达步数上限时调用一次。写入收尾 `reminder`(位于请求末尾);照常带工具(历史里有工具调用时
|
|
151
170
|
* 部分供应商要求请求声明工具,也保持缓存前缀稳定),但 `toolChoice: "none"`——模型只能回复文本。
|
|
152
171
|
* 其余与 `runModelStep` 相同(幂等、降级、中止)。
|
|
172
|
+
*
|
|
173
|
+
* `reason: "budget"`: a sub-agent whose tree used its token budget makes this one call to hand back
|
|
174
|
+
* what it found (sub-agents spec §8.3); it is not stopped by the budget again (one call over).
|
|
153
175
|
*/
|
|
154
|
-
export declare function runFinalWrapUp(deps: ModelStepDeps, input: ModelStepInput): Promise<ModelStepResult>;
|
|
176
|
+
export declare function runFinalWrapUp(deps: ModelStepDeps, input: ModelStepInput, reason?: WrapUpReason): Promise<ModelStepResult>;
|
|
155
177
|
/**
|
|
156
178
|
* Appends a model call's events (its reply or compaction outcome with its `usage`; also the usage
|
|
157
179
|
* of a `WebFetch` extraction call, `tools/builtins/web/extract.ts`). For a
|
|
158
180
|
* sub-agent's run (`input.parentRunId`) in one transaction that also adds the tokens of the usage
|
|
159
|
-
* events it newly wrote to the
|
|
181
|
+
* events it newly wrote to the budget run's `subagent_tokens_used` (sub-agents spec §8.3): a usage
|
|
160
182
|
* event already in the log (an idempotent hit after a crash) adds nothing, so each call counts
|
|
161
183
|
* exactly once.
|
|
162
184
|
*/
|
|
@@ -166,6 +188,11 @@ export declare function appendCounted(deps: {
|
|
|
166
188
|
}, input: {
|
|
167
189
|
conversationId: string;
|
|
168
190
|
parentRunId?: string | undefined;
|
|
191
|
+
/** The run's budget window (agent map spec §6), when known; else the parent run's. */
|
|
192
|
+
budgetRunId?: string | undefined;
|
|
193
|
+
parent?: {
|
|
194
|
+
budgetRunId?: string | undefined;
|
|
195
|
+
} | undefined;
|
|
169
196
|
}, events: AppendEvent[]): Promise<ConversationEvent[]>;
|
|
170
197
|
/** {@link assembleModelRequest} 的输入。 */
|
|
171
198
|
export interface AssembleModelRequestInput extends Omit<BuildModelRequestInput, "tools"> {
|
|
@@ -190,6 +217,6 @@ export declare function assembleModelRequest(input: AssembleModelRequestInput):
|
|
|
190
217
|
* 外部 `signal` 触发 → `StepAborted`。每次 `next()` 都与停止信号竞速,供应商不响应 signal 也不会卡住。
|
|
191
218
|
* 运行时与评测单步回放(`evals/step-replay.ts`)、评委共用。
|
|
192
219
|
*/
|
|
193
|
-
export declare function consumeModelStream(provider:
|
|
220
|
+
export declare function consumeModelStream(provider: BoundProvider, request: ModelRequest, idleMs: number, signal: AbortSignal, onDelta: (ev: Exclude<ModelStreamEvent, {
|
|
194
221
|
type: "message_complete";
|
|
195
222
|
}>) => void): Promise<StreamOutcome>;
|