@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
package/dist/config/schema.js
CHANGED
|
@@ -332,7 +332,7 @@ export const KernelConfigSchema = z.object({
|
|
|
332
332
|
description: "Mirror URLs of the official marketplace's marketplace.json (https), tried in order when the main URL fails; only for a marketplace.json URL (a git marketplace has no mirrors: point url at a mirror repository instead)",
|
|
333
333
|
})),
|
|
334
334
|
})
|
|
335
|
-
// Same rule as
|
|
335
|
+
// Same rule as a custom marketplace: a git marketplace has no mirrors.
|
|
336
336
|
.refine((o) => o.mirrors.length === 0 || !isGitMarketplaceUrl(o.url), {
|
|
337
337
|
message: "a git marketplace has no mirrors (point marketplaces.official.url at a mirror repository instead)",
|
|
338
338
|
path: ["mirrors"],
|
|
@@ -580,7 +580,7 @@ export const KernelConfigSchema = z.object({
|
|
|
580
580
|
.boolean()
|
|
581
581
|
.default(true)
|
|
582
582
|
.meta(meta({
|
|
583
|
-
description: "Whether the finish of a background Bash task starts a run on an idle conversation (the person who started the task's run is the trigger); an organization can override it in its settings. When false the event is only logged and shown, and the next message picks it up",
|
|
583
|
+
description: "Whether the finish of a background Bash task or a sub-agent's delivery starts a run on an idle conversation or sub-agent (the person who started the task's or the sub-agent's run is the trigger); an organization can override it in its settings. When false the event is only logged and shown, and the next message picks it up",
|
|
584
584
|
})),
|
|
585
585
|
maxRunSeconds: z
|
|
586
586
|
.number()
|
|
@@ -930,7 +930,17 @@ export const KernelConfigSchema = z.object({
|
|
|
930
930
|
.prefault({}),
|
|
931
931
|
subagents: z
|
|
932
932
|
.object({
|
|
933
|
-
|
|
933
|
+
maxDepth: z
|
|
934
|
+
.number()
|
|
935
|
+
.int()
|
|
936
|
+
.min(1)
|
|
937
|
+
.max(5)
|
|
938
|
+
.default(3)
|
|
939
|
+
.meta(meta({
|
|
940
|
+
hot: true,
|
|
941
|
+
description: "Levels of sub-agents below the conversation's own agent; 1 means sub-agents cannot dispatch sub-agents of their own. Organizations can be given their own value in the deployment setting subagentLimitOverrides",
|
|
942
|
+
})),
|
|
943
|
+
maxConcurrentPerConversation: z
|
|
934
944
|
.number()
|
|
935
945
|
.int()
|
|
936
946
|
.min(1)
|
|
@@ -938,26 +948,27 @@ export const KernelConfigSchema = z.object({
|
|
|
938
948
|
.default(4)
|
|
939
949
|
.meta(meta({
|
|
940
950
|
hot: true,
|
|
941
|
-
description: "Sub-agents one
|
|
951
|
+
description: "Sub-agents one conversation may have running at the same time, whichever of its runs dispatched them; agent calls beyond it are refused. Organizations can be given their own value in subagentLimitOverrides",
|
|
942
952
|
})),
|
|
943
953
|
maxDispatchesPerRun: z
|
|
944
954
|
.number()
|
|
945
955
|
.int()
|
|
946
|
-
.min(
|
|
956
|
+
.min(0)
|
|
947
957
|
.max(500)
|
|
948
958
|
.default(50)
|
|
949
959
|
.meta(meta({
|
|
950
960
|
hot: true,
|
|
951
|
-
description: "Sub-agents
|
|
961
|
+
description: "Sub-agents the whole tree under a person's message may dispatch in total, counted across every level (nested dispatches and SendMessage messages that restart an idle sub-agent included); later agent calls and such messages are refused. 0 means no limit. Organizations can be given their own value in subagentLimitOverrides",
|
|
952
962
|
})),
|
|
953
963
|
maxTokensPerRun: z
|
|
954
964
|
.number()
|
|
955
965
|
.int()
|
|
956
|
-
.min(
|
|
966
|
+
.min(0)
|
|
967
|
+
.refine((n) => n === 0 || n >= 10_000, "0 (no limit) or at least 10,000")
|
|
957
968
|
.default(5_000_000)
|
|
958
969
|
.meta(meta({
|
|
959
970
|
hot: true,
|
|
960
|
-
description: "Tokens (input, output and cache)
|
|
971
|
+
description: "Tokens (input, output and cache) all sub-agents of the tree under a person's message may use together; at the cap running sub-agents stop and new dispatches are refused. 0 means no limit; otherwise at least 10,000. Organizations can be given their own value in subagentLimitOverrides",
|
|
961
972
|
})),
|
|
962
973
|
})
|
|
963
974
|
.prefault({}),
|
|
@@ -1024,16 +1035,16 @@ export const KernelConfigSchema = z.object({
|
|
|
1024
1035
|
image: z
|
|
1025
1036
|
.string()
|
|
1026
1037
|
.min(1)
|
|
1027
|
-
.
|
|
1038
|
+
.optional()
|
|
1028
1039
|
.meta(meta({
|
|
1029
|
-
description: "Image for
|
|
1040
|
+
description: "Image for environment instances, passed to the sandbox extension; unset (the default), each extension uses the image published with its own version (ghcr.io/capybara-hq/capybara-sandbox). Set it to a locally built or mirrored image for offline deployments; an extension that builds instances from its own template may ignore it",
|
|
1030
1041
|
})),
|
|
1031
1042
|
lockWaitSeconds: z
|
|
1032
1043
|
.number()
|
|
1033
1044
|
.positive()
|
|
1034
1045
|
.default(75)
|
|
1035
1046
|
.meta(meta({
|
|
1036
|
-
description: "Seconds a sandbox call waits while
|
|
1047
|
+
description: "Seconds a sandbox call waits for the environment's instance (while it is being created, resumed or suspended, or all its concurrent command slots are taken) before failing with sandbox.busy; keep it above the 60-second sandbox lock TTL so a call after a replica crash waits for the dead replica's lock to expire",
|
|
1037
1048
|
})),
|
|
1038
1049
|
maxConcurrentCommands: z
|
|
1039
1050
|
.number()
|
|
@@ -1043,7 +1054,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1043
1054
|
.default(6)
|
|
1044
1055
|
.meta(meta({
|
|
1045
1056
|
hot: true,
|
|
1046
|
-
description: "Sandbox commands and file operations that may run at the same time in one
|
|
1057
|
+
description: "Sandbox commands and file operations that may run at the same time in one environment, shared by all its conversations and their sub-agents; 1 runs them one at a time",
|
|
1047
1058
|
})),
|
|
1048
1059
|
deliverMaxBytes: z
|
|
1049
1060
|
.number()
|
|
@@ -1062,7 +1073,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1062
1073
|
.max(100)
|
|
1063
1074
|
.default(4)
|
|
1064
1075
|
.meta(meta({
|
|
1065
|
-
description: "Most background Bash tasks (run_in_background) that may run at once in one conversation
|
|
1076
|
+
description: "Most background Bash tasks (run_in_background) that may run at once in one conversation, its sub-agents included (counted per root conversation, not per environment); a launch beyond it is refused",
|
|
1066
1077
|
})),
|
|
1067
1078
|
maxSeconds: z
|
|
1068
1079
|
.number()
|
|
@@ -1078,7 +1089,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1078
1089
|
.min(1)
|
|
1079
1090
|
.default(10)
|
|
1080
1091
|
.meta(meta({
|
|
1081
|
-
description: "How often the worker checks the running background Bash tasks of every
|
|
1092
|
+
description: "How often the worker checks the running background Bash tasks of every environment for a finish, in seconds; read when the worker starts",
|
|
1082
1093
|
})),
|
|
1083
1094
|
})
|
|
1084
1095
|
.prefault({}),
|
|
@@ -1089,7 +1100,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1089
1100
|
.positive()
|
|
1090
1101
|
.default(1)
|
|
1091
1102
|
.meta(meta({
|
|
1092
|
-
description: "CPU cores for each
|
|
1103
|
+
description: "CPU cores for each environment instance; applies to instances created after the change (an extension that sizes instances by its own template, such as E2B, may not apply it)",
|
|
1093
1104
|
})),
|
|
1094
1105
|
memoryMb: z
|
|
1095
1106
|
.number()
|
|
@@ -1097,7 +1108,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1097
1108
|
.positive()
|
|
1098
1109
|
.default(2048)
|
|
1099
1110
|
.meta(meta({
|
|
1100
|
-
description: "Memory limit of each
|
|
1111
|
+
description: "Memory limit of each environment instance in MiB; applies to instances created after the change (an extension that sizes instances by its own template, such as E2B, may not apply it)",
|
|
1101
1112
|
})),
|
|
1102
1113
|
diskMb: z
|
|
1103
1114
|
.number()
|
|
@@ -1105,7 +1116,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1105
1116
|
.positive()
|
|
1106
1117
|
.default(5120)
|
|
1107
1118
|
.meta(meta({
|
|
1108
|
-
description: "Disk limit of each
|
|
1119
|
+
description: "Disk limit of each environment's file system in MiB; applies to file systems created after the change (Docker: only with a volume driver that supports size; an extension whose storage cannot be sized may not apply it)",
|
|
1109
1120
|
})),
|
|
1110
1121
|
maxCommandSeconds: z
|
|
1111
1122
|
.number()
|
|
@@ -1121,7 +1132,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1121
1132
|
.positive()
|
|
1122
1133
|
.default(10)
|
|
1123
1134
|
.meta(meta({
|
|
1124
|
-
description: "Minutes without
|
|
1135
|
+
description: "Minutes without a command from any conversation of the environment before its running instance is suspended (files are kept, processes end)",
|
|
1125
1136
|
})),
|
|
1126
1137
|
destroyAfterInactiveDays: z
|
|
1127
1138
|
.number()
|
|
@@ -1129,7 +1140,7 @@ export const KernelConfigSchema = z.object({
|
|
|
1129
1140
|
.positive()
|
|
1130
1141
|
.default(7)
|
|
1131
1142
|
.meta(meta({
|
|
1132
|
-
description: "Days without use before
|
|
1143
|
+
description: "Days without use before an environment's instance is destroyed; its files are kept until the environment is deleted, and the next use starts a new instance on them",
|
|
1133
1144
|
})),
|
|
1134
1145
|
maxRunningMinutes: z
|
|
1135
1146
|
.number()
|
|
@@ -1137,13 +1148,13 @@ export const KernelConfigSchema = z.object({
|
|
|
1137
1148
|
.positive()
|
|
1138
1149
|
.default(120)
|
|
1139
1150
|
.meta(meta({
|
|
1140
|
-
description: "Minutes
|
|
1151
|
+
description: "Minutes an environment's instance may run continuously before it is suspended even while in use (skipped while a command is running)",
|
|
1141
1152
|
})),
|
|
1142
1153
|
egress: z
|
|
1143
1154
|
.enum(["none", "allowlist", "open"])
|
|
1144
1155
|
.default("allowlist")
|
|
1145
1156
|
.meta(meta({
|
|
1146
|
-
description: "Outbound network from
|
|
1157
|
+
description: "Outbound network from environment instances: none, allowlist (only allowHosts) or open; applies to instances created after the change, existing ones keep theirs until destroyed",
|
|
1147
1158
|
})),
|
|
1148
1159
|
allowHosts: z
|
|
1149
1160
|
.array(z.string())
|
|
@@ -1156,12 +1167,25 @@ export const KernelConfigSchema = z.object({
|
|
|
1156
1167
|
});
|
|
1157
1168
|
})
|
|
1158
1169
|
.meta(meta({
|
|
1159
|
-
description: "Hosts
|
|
1170
|
+
description: "Hosts environment instances may reach when egress is allowlist: lowercase hostnames, optional leading '*.', no IPs, ports or internal-only names; applies to instances created after the change",
|
|
1160
1171
|
})),
|
|
1161
1172
|
})
|
|
1162
1173
|
.prefault({}),
|
|
1163
1174
|
})
|
|
1164
1175
|
.prefault({}),
|
|
1176
|
+
environments: z
|
|
1177
|
+
.object({
|
|
1178
|
+
maxPersonal: z
|
|
1179
|
+
.number()
|
|
1180
|
+
.int()
|
|
1181
|
+
.min(1)
|
|
1182
|
+
.default(10)
|
|
1183
|
+
.meta(meta({
|
|
1184
|
+
hot: true,
|
|
1185
|
+
description: "Most personal environments a member may have in one org, the default one included; creating one more fails with environment.limit_reached",
|
|
1186
|
+
})),
|
|
1187
|
+
})
|
|
1188
|
+
.prefault({}),
|
|
1165
1189
|
evals: z
|
|
1166
1190
|
.object({
|
|
1167
1191
|
orgConcurrency: z
|
|
@@ -1228,6 +1252,30 @@ export const KernelConfigSchema = z.object({
|
|
|
1228
1252
|
path: ["defaultTokenCap"],
|
|
1229
1253
|
})
|
|
1230
1254
|
.prefault({}),
|
|
1255
|
+
models: z
|
|
1256
|
+
.object({
|
|
1257
|
+
listTimeoutMs: z
|
|
1258
|
+
.number()
|
|
1259
|
+
.int()
|
|
1260
|
+
.positive()
|
|
1261
|
+
.max(300_000)
|
|
1262
|
+
.default(10_000)
|
|
1263
|
+
.meta(meta({
|
|
1264
|
+
hot: true,
|
|
1265
|
+
description: "Time limit in milliseconds for one model provider's model list (listModels, which may page through a large platform catalog); a provider that exceeds it is treated as failing to list",
|
|
1266
|
+
})),
|
|
1267
|
+
embedTimeoutMs: z
|
|
1268
|
+
.number()
|
|
1269
|
+
.int()
|
|
1270
|
+
.positive()
|
|
1271
|
+
.max(600_000)
|
|
1272
|
+
.default(60_000)
|
|
1273
|
+
.meta(meta({
|
|
1274
|
+
hot: true,
|
|
1275
|
+
description: "Time limit in milliseconds for one embed call to a model provider (one batch of an extension's ctx.models.embed); the call is aborted and fails with a timeout model error",
|
|
1276
|
+
})),
|
|
1277
|
+
})
|
|
1278
|
+
.prefault({}),
|
|
1231
1279
|
hooks: z
|
|
1232
1280
|
.object({
|
|
1233
1281
|
timeoutMs: z
|
|
@@ -2,10 +2,12 @@ import { type ExpressionBuilder } from "kysely";
|
|
|
2
2
|
import type { KernelDatabase } from "../db/kernel-schema.js";
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
/**
|
|
5
|
-
* A sub-agent's conversation is reached through its
|
|
6
|
-
* same rule as its trajectory
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A sub-agent's conversation is reached through the root of its tree (sub-agents spec §6.1,
|
|
6
|
+
* review m6, the same rule as its trajectory; agent map spec §4.1: nested sub-agents at any
|
|
7
|
+
* depth): the root is a chat conversation of the same org and owner whose agent is not deleted
|
|
8
|
+
* and still visible to the viewer, and every conversation between is a sub-agent conversation of
|
|
9
|
+
* that org. Any other kind passes. The child's own `agent_id` (the dispatched agent for an org
|
|
10
|
+
* agent, §5.5) is checked on top by the callers.
|
|
9
11
|
*/
|
|
10
12
|
export declare const parentReachable: (viewerAccountId: string) => (eb: ExpressionBuilder<KernelDatabase, "conversations">) => import("kysely").ExpressionWrapper<KernelDatabase, "conversations", import("kysely").SqlBool>;
|
|
11
13
|
/**
|
|
@@ -12,10 +12,32 @@ import { sql } from "kysely";
|
|
|
12
12
|
import { visibleTo } from "../agents/agent-lookup.js";
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* The root of a sub-agent conversation's tree, as a correlated scalar subquery: walks
|
|
16
|
+
* `parent_conversation_id` up from the conversation's parent through sub-agent conversations of
|
|
17
|
+
* the same org (at most 16 levels, far above `subagents.maxDepth`'s bound of 5) to the first
|
|
18
|
+
* conversation without a parent. Null when the chain leaves the org, passes a conversation of
|
|
19
|
+
* another kind or does not end.
|
|
20
|
+
*/
|
|
21
|
+
const rootOfParent = () => sql `(
|
|
22
|
+
WITH RECURSIVE up(id, parent, kind, n) AS (
|
|
23
|
+
SELECT c.id, c.parent_conversation_id, c.kind, 0 FROM capybara.conversations c
|
|
24
|
+
WHERE c.id = ${sql.ref("conversations.parent_conversation_id")}
|
|
25
|
+
AND c.org_id = ${sql.ref("conversations.org_id")}
|
|
26
|
+
UNION ALL
|
|
27
|
+
SELECT c.id, c.parent_conversation_id, c.kind, up.n + 1
|
|
28
|
+
FROM capybara.conversations c JOIN up ON c.id = up.parent
|
|
29
|
+
WHERE up.kind = 'subagent' AND up.n < 16
|
|
30
|
+
AND c.org_id = ${sql.ref("conversations.org_id")}
|
|
31
|
+
)
|
|
32
|
+
SELECT id FROM up WHERE parent IS NULL LIMIT 1
|
|
33
|
+
)`;
|
|
34
|
+
/**
|
|
35
|
+
* A sub-agent's conversation is reached through the root of its tree (sub-agents spec §6.1,
|
|
36
|
+
* review m6, the same rule as its trajectory; agent map spec §4.1: nested sub-agents at any
|
|
37
|
+
* depth): the root is a chat conversation of the same org and owner whose agent is not deleted
|
|
38
|
+
* and still visible to the viewer, and every conversation between is a sub-agent conversation of
|
|
39
|
+
* that org. Any other kind passes. The child's own `agent_id` (the dispatched agent for an org
|
|
40
|
+
* agent, §5.5) is checked on top by the callers.
|
|
19
41
|
*/
|
|
20
42
|
export const parentReachable = (viewerAccountId) => (eb) => eb.or([
|
|
21
43
|
eb("conversations.kind", "<>", "subagent"),
|
|
@@ -23,7 +45,7 @@ export const parentReachable = (viewerAccountId) => (eb) => eb.or([
|
|
|
23
45
|
.selectFrom("conversations as p")
|
|
24
46
|
.innerJoin("agents", "agents.id", "p.agent_id")
|
|
25
47
|
.select(sql `1`.as("one"))
|
|
26
|
-
.
|
|
48
|
+
.where("p.id", "=", rootOfParent())
|
|
27
49
|
.whereRef("p.org_id", "=", "conversations.org_id")
|
|
28
50
|
.where("p.account_id", "=", viewerAccountId)
|
|
29
51
|
.where("p.kind", "=", "chat")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* One agent of a conversation tree as the agent map shows it (agent map spec §8, §9.2): the root
|
|
4
|
+
* conversation or a sub-agent at any depth.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentTreeNode {
|
|
7
|
+
/** The conversation's id (a sub-agent's is its child conversation's). */
|
|
8
|
+
id: string;
|
|
9
|
+
/** A sub-agent's dispatched description; the root's title ("" before it has one). */
|
|
10
|
+
description: string;
|
|
11
|
+
/**
|
|
12
|
+
* The sub-agent type (`conversations.subagent_type`, set at the first dispatch); null for the
|
|
13
|
+
* root, and for a sub-agent row that has none (the column is nullable; no sentinel is invented).
|
|
14
|
+
*/
|
|
15
|
+
agentType: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The latest run's status; `idle` when no run is active and the latest run completed (or the
|
|
18
|
+
* conversation has no run yet).
|
|
19
|
+
*/
|
|
20
|
+
status: "queued" | "running" | "waiting" | "completed" | "failed" | "aborted" | "idle";
|
|
21
|
+
/** The model of the latest run (a queued sub-agent's: the dispatched one); null when unknown. */
|
|
22
|
+
model: {
|
|
23
|
+
provider: string;
|
|
24
|
+
model: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/** The first run's start; null until a run started. */
|
|
27
|
+
startedAt: string | null;
|
|
28
|
+
/** The latest run's end; null while a run is active or before any run ended. */
|
|
29
|
+
finishedAt: string | null;
|
|
30
|
+
/** The wall time of the conversation's own runs, summed (a running run up to now). */
|
|
31
|
+
durationMs: number;
|
|
32
|
+
/** The tokens of the conversation's own runs (`usage` events with a run; never descendants'). */
|
|
33
|
+
tokens: number;
|
|
34
|
+
/** The tool calls of the conversation's own runs (its `tool_result` events). */
|
|
35
|
+
toolCalls: number;
|
|
36
|
+
/** The sub-agents it dispatched, oldest first. */
|
|
37
|
+
children: AgentTreeNode[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The agent tree of the root conversation `rootId` of org `orgId`: null when it is not a root
|
|
41
|
+
* chat conversation of that org. The tree's ids come from {@link conversationTree} (one recursive
|
|
42
|
+
* query); one more query reads every node's numbers. A deleted conversation, and a sub-agent
|
|
43
|
+
* conversation without a dispatch row, is left out with its subtree. Call only after an access
|
|
44
|
+
* check of the root.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readAgentTree(db: KernelSchemaDb, orgId: string, rootId: string): Promise<AgentTreeNode | null>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { conversationTree } from "./tree.js";
|
|
3
|
+
const ACTIVE = new Set(["queued", "running", "waiting"]);
|
|
4
|
+
/**
|
|
5
|
+
* The agent tree of the root conversation `rootId` of org `orgId`: null when it is not a root
|
|
6
|
+
* chat conversation of that org. The tree's ids come from {@link conversationTree} (one recursive
|
|
7
|
+
* query); one more query reads every node's numbers. A deleted conversation, and a sub-agent
|
|
8
|
+
* conversation without a dispatch row, is left out with its subtree. Call only after an access
|
|
9
|
+
* check of the root.
|
|
10
|
+
*/
|
|
11
|
+
export async function readAgentTree(db, orgId, rootId) {
|
|
12
|
+
const ids = (await conversationTree(db, rootId)).map((t) => t.id);
|
|
13
|
+
if (ids.length === 0)
|
|
14
|
+
return null;
|
|
15
|
+
const { rows } = await sql `
|
|
16
|
+
SELECT c.id, c.parent_conversation_id, c.subagent_type, c.title,
|
|
17
|
+
(SELECT e.payload->>'description' FROM capybara.conversation_events e
|
|
18
|
+
WHERE e.conversation_id = c.parent_conversation_id AND e.type = 'subagent_dispatched'
|
|
19
|
+
AND e.payload->>'subagentId' = c.id
|
|
20
|
+
ORDER BY e.seq DESC LIMIT 1) AS description,
|
|
21
|
+
(SELECT e.payload->'model' FROM capybara.conversation_events e
|
|
22
|
+
WHERE e.conversation_id = c.parent_conversation_id AND e.type = 'subagent_dispatched'
|
|
23
|
+
AND e.payload->>'subagentId' = c.id
|
|
24
|
+
ORDER BY e.seq DESC LIMIT 1) AS dispatched_model,
|
|
25
|
+
(SELECT e.payload->'model' FROM capybara.conversation_events e
|
|
26
|
+
WHERE e.conversation_id = c.id AND e.type = 'run_started'
|
|
27
|
+
ORDER BY e.seq DESC LIMIT 1) AS run_model,
|
|
28
|
+
latest.status AS last_status, latest.finished_at AS last_finished_at,
|
|
29
|
+
runs.started_at, runs.duration_ms,
|
|
30
|
+
(SELECT count(*) FROM capybara.conversation_events e
|
|
31
|
+
WHERE e.conversation_id = c.id AND e.type = 'tool_result') AS tool_calls,
|
|
32
|
+
(SELECT coalesce(sum(
|
|
33
|
+
coalesce((e.payload->>'inputTokens')::bigint, 0)
|
|
34
|
+
+ coalesce((e.payload->>'outputTokens')::bigint, 0)
|
|
35
|
+
+ coalesce((e.payload->>'cacheReadTokens')::bigint, 0)
|
|
36
|
+
+ coalesce((e.payload->>'cacheWriteTokens')::bigint, 0)
|
|
37
|
+
), 0)
|
|
38
|
+
FROM capybara.conversation_events e
|
|
39
|
+
WHERE e.conversation_id = c.id AND e.type = 'usage' AND e.run_id IS NOT NULL) AS tokens
|
|
40
|
+
FROM capybara.conversations c
|
|
41
|
+
LEFT JOIN LATERAL (
|
|
42
|
+
SELECT r.status, r.finished_at FROM capybara.runs r
|
|
43
|
+
WHERE r.conversation_id = c.id
|
|
44
|
+
ORDER BY r.created_at DESC, r.id DESC
|
|
45
|
+
LIMIT 1
|
|
46
|
+
) latest ON true
|
|
47
|
+
CROSS JOIN LATERAL (
|
|
48
|
+
SELECT min(r.started_at) AS started_at,
|
|
49
|
+
coalesce(sum(floor(extract(epoch FROM coalesce(r.finished_at, now()) - r.started_at) * 1000))
|
|
50
|
+
FILTER (WHERE r.started_at IS NOT NULL), 0)::bigint AS duration_ms
|
|
51
|
+
FROM capybara.runs r WHERE r.conversation_id = c.id
|
|
52
|
+
) runs
|
|
53
|
+
WHERE c.id IN (${sql.join(ids)}) AND c.org_id = ${orgId} AND c.deleted_at IS NULL
|
|
54
|
+
AND (
|
|
55
|
+
(c.id = ${rootId} AND c.kind = 'chat' AND c.parent_conversation_id IS NULL)
|
|
56
|
+
OR (c.id <> ${rootId} AND c.kind = 'subagent' AND EXISTS (
|
|
57
|
+
SELECT 1 FROM capybara.subagent_dispatches sd WHERE sd.child_conversation_id = c.id
|
|
58
|
+
))
|
|
59
|
+
)
|
|
60
|
+
ORDER BY c.created_at, c.id
|
|
61
|
+
`.execute(db);
|
|
62
|
+
const nodes = new Map();
|
|
63
|
+
for (const r of rows)
|
|
64
|
+
nodes.set(r.id, toNode(r, r.id === rootId));
|
|
65
|
+
for (const r of rows) {
|
|
66
|
+
if (r.id === rootId || r.parent_conversation_id === null)
|
|
67
|
+
continue;
|
|
68
|
+
const node = nodes.get(r.id);
|
|
69
|
+
const parent = nodes.get(r.parent_conversation_id);
|
|
70
|
+
if (node && parent)
|
|
71
|
+
parent.children.push(node);
|
|
72
|
+
}
|
|
73
|
+
return nodes.get(rootId) ?? null;
|
|
74
|
+
}
|
|
75
|
+
function toNode(r, isRoot) {
|
|
76
|
+
const active = r.last_status !== null && ACTIVE.has(r.last_status);
|
|
77
|
+
const status = r.last_status === null || r.last_status === "completed" ? "idle" : r.last_status;
|
|
78
|
+
return {
|
|
79
|
+
id: r.id,
|
|
80
|
+
description: (isRoot ? r.title : (r.description ?? r.title)) ?? "",
|
|
81
|
+
agentType: isRoot ? null : r.subagent_type,
|
|
82
|
+
status,
|
|
83
|
+
model: modelOf(r.run_model ?? r.dispatched_model),
|
|
84
|
+
startedAt: r.started_at?.toISOString() ?? null,
|
|
85
|
+
finishedAt: active ? null : (r.last_finished_at?.toISOString() ?? null),
|
|
86
|
+
durationMs: Number(r.duration_ms),
|
|
87
|
+
tokens: Number(r.tokens),
|
|
88
|
+
toolCalls: Number(r.tool_calls),
|
|
89
|
+
children: [],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const modelOf = (m) => m ? { provider: m.provider, model: m.model } : null;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import type { EnvironmentView } from "../environments/environments.service.js";
|
|
3
4
|
import { type Principal } from "../identity/principal.js";
|
|
4
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
6
|
import { ConversationToolInfo, type ToolInfo } from "../tools/info.js";
|
|
7
|
+
import type { AgentTreeNode } from "./agent-tree.js";
|
|
6
8
|
import { type ArtifactPreview, ConversationArtifacts } from "./artifacts.js";
|
|
7
9
|
import { type ConversationGroup, ConversationsService, type ConversationView, type SubagentView, type UsageTotals } from "./conversations.service.js";
|
|
10
|
+
import { ConversationEnvironmentStatus } from "./environment-status.js";
|
|
8
11
|
import type { ConversationEvent } from "./events.js";
|
|
9
12
|
import { ConversationFiles, type FileOutput } from "./files.js";
|
|
10
13
|
import { ConversationOutputs, type OutputPage } from "./outputs-read.js";
|
|
11
14
|
import type { QueueItem, QueuePauseReason } from "./queue.js";
|
|
12
15
|
import { ConversationQueue } from "./queue.service.js";
|
|
13
|
-
import { ConversationSandboxStatus, type SandboxStatusView } from "./sandbox-status.js";
|
|
14
16
|
declare const ListQuery: z.ZodObject<{
|
|
15
17
|
q: z.ZodOptional<z.ZodString>;
|
|
16
18
|
state: z.ZodOptional<z.ZodEnum<{
|
|
@@ -42,7 +44,8 @@ declare const SubagentsQuery: z.ZodObject<{
|
|
|
42
44
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
43
45
|
}, z.core.$strip>;
|
|
44
46
|
declare const EventsQuery: z.ZodObject<{
|
|
45
|
-
after: z.
|
|
47
|
+
after: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
48
|
+
before: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"end">, z.ZodCoercedNumber<unknown>]>>;
|
|
46
49
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
47
50
|
}, z.core.$strip>;
|
|
48
51
|
/** `?keys=a,b`: 1–100 comma-separated tool keys of 1–200 characters each. */
|
|
@@ -95,9 +98,12 @@ declare const MessageBody: z.ZodObject<{
|
|
|
95
98
|
* `POST /conversations`: `message` creates the conversation with its first message (create on
|
|
96
99
|
* first send; `clientMessageId` is required and makes a retry return the same conversation).
|
|
97
100
|
* Without it the conversation is created empty (API clients; the web never does).
|
|
101
|
+
* `environmentId` binds it to one of the caller's environments; without it the caller's default
|
|
102
|
+
* environment (environments spec §4.1 item 1).
|
|
98
103
|
*/
|
|
99
104
|
declare const CreateBody: z.ZodObject<{
|
|
100
105
|
agentId: z.ZodString;
|
|
106
|
+
environmentId: z.ZodOptional<z.ZodString>;
|
|
101
107
|
message: z.ZodOptional<z.ZodObject<{
|
|
102
108
|
text: z.ZodString;
|
|
103
109
|
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -123,9 +129,7 @@ declare const CreateBody: z.ZodObject<{
|
|
|
123
129
|
}, z.core.$strict>>;
|
|
124
130
|
}, z.core.$strict>;
|
|
125
131
|
/**
|
|
126
|
-
* `POST …/queue
|
|
127
|
-
* now and applied when the message is sent (final review I1). A skill invocation is rendered now
|
|
128
|
-
* and checked again when sent (phase D Task 9).
|
|
132
|
+
* `POST …/queue` (deprecated, behaves as `POST …/messages`): the message fields (no retry).
|
|
129
133
|
*/
|
|
130
134
|
declare const QueueBody: z.ZodObject<{
|
|
131
135
|
text: z.ZodString;
|
|
@@ -173,11 +177,11 @@ export declare class ConversationsController {
|
|
|
173
177
|
private readonly conversations;
|
|
174
178
|
private readonly outputs;
|
|
175
179
|
private readonly artifacts;
|
|
176
|
-
private readonly
|
|
180
|
+
private readonly environmentStatus;
|
|
177
181
|
private readonly toolInfo;
|
|
178
182
|
private readonly queue;
|
|
179
183
|
private readonly files;
|
|
180
|
-
constructor(conversations: ConversationsService, outputs: ConversationOutputs, artifacts: ConversationArtifacts,
|
|
184
|
+
constructor(conversations: ConversationsService, outputs: ConversationOutputs, artifacts: ConversationArtifacts, environmentStatus: ConversationEnvironmentStatus, toolInfo: ConversationToolInfo, queue: ConversationQueue, files: ConversationFiles);
|
|
181
185
|
/**
|
|
182
186
|
* 201 when created; 200 when `message.clientMessageId` repeats an earlier first send. With a
|
|
183
187
|
* message the answer has `event` (the `user_message`) and `events`: every event the first send
|
|
@@ -215,9 +219,14 @@ export declare class ConversationsController {
|
|
|
215
219
|
get(principal: Principal, org: OrgContext, id: string): Promise<{
|
|
216
220
|
conversation: ConversationView;
|
|
217
221
|
}>;
|
|
218
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Events in ascending seq. `after`: those after it (at most `limit`; the client passes the last
|
|
224
|
+
* seq back as the next `after`). `before` (a seq, or `end` for the log's last page): the
|
|
225
|
+
* turn-aligned page before it, `{ events, turnsBefore }` (history paging spec §2).
|
|
226
|
+
*/
|
|
219
227
|
events(principal: Principal, org: OrgContext, id: string, q: z.infer<typeof EventsQuery>): Promise<{
|
|
220
228
|
events: ConversationEvent[];
|
|
229
|
+
turnsBefore?: number;
|
|
221
230
|
}>;
|
|
222
231
|
/**
|
|
223
232
|
* The conversation's sub-agents, newest first (sub-agents spec §14.3): `{ subagents, next }`,
|
|
@@ -228,6 +237,14 @@ export declare class ConversationsController {
|
|
|
228
237
|
subagents: SubagentView[];
|
|
229
238
|
next: string | null;
|
|
230
239
|
}>;
|
|
240
|
+
/**
|
|
241
|
+
* The agent tree of a root conversation (agent map spec §8, §9.2): `{ root }`, each node with its
|
|
242
|
+
* status, model, time, tokens, tool calls and children. Owner only; a sub-agent's id is
|
|
243
|
+
* `conversation.not_found`.
|
|
244
|
+
*/
|
|
245
|
+
agentTree(principal: Principal, org: OrgContext, { id }: z.infer<typeof IdParams>): Promise<{
|
|
246
|
+
root: AgentTreeNode;
|
|
247
|
+
}>;
|
|
231
248
|
/**
|
|
232
249
|
* The conversation's token usage, its sub-agents' included (sub-agents spec §8.3):
|
|
233
250
|
* `{ usage: { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens } }`. Owner only.
|
|
@@ -270,11 +287,13 @@ export declare class ConversationsController {
|
|
|
270
287
|
*/
|
|
271
288
|
fileContent(principal: Principal, org: OrgContext, id: string, fileId: string, q: z.infer<typeof FileContentQuery>, reply: FastifyReply): Promise<void>;
|
|
272
289
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
290
|
+
* The environment the conversation works in (a sub-agent: its root's), as its owner sees it,
|
|
291
|
+
* with its instance state; `null` while unbound, or when the environment was deleted. Same
|
|
292
|
+
* visibility as the event stream.
|
|
276
293
|
*/
|
|
277
|
-
|
|
294
|
+
environment(principal: Principal, org: OrgContext, id: string): Promise<{
|
|
295
|
+
environment: EnvironmentView | null;
|
|
296
|
+
}>;
|
|
278
297
|
/**
|
|
279
298
|
* Display metadata (title, kind, key arguments, source) of the tools a conversation's calls name,
|
|
280
299
|
* for the tool rows (UI refresh B). Same visibility as the event stream; never model-visible.
|
|
@@ -295,12 +314,12 @@ export declare class ConversationsController {
|
|
|
295
314
|
pauseReason?: QueuePauseReason;
|
|
296
315
|
}>;
|
|
297
316
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
317
|
+
* Deprecated: behaves as `POST …/messages` (202 `{ event }`): an interjection while a run is
|
|
318
|
+
* active, a new run otherwise; nothing is queued any more. Kept for older clients for one release;
|
|
319
|
+
* the leftover-item routes below keep working until the queue table is dropped (contract step).
|
|
300
320
|
*/
|
|
301
|
-
enqueue(principal: Principal, org: OrgContext, id: string, body: z.infer<typeof QueueBody
|
|
302
|
-
|
|
303
|
-
event?: ConversationEvent;
|
|
321
|
+
enqueue(principal: Principal, org: OrgContext, id: string, body: z.infer<typeof QueueBody>): Promise<{
|
|
322
|
+
event: ConversationEvent;
|
|
304
323
|
}>;
|
|
305
324
|
/** "Continue sending" after a pause (202). Declared before `:itemId` routes. */
|
|
306
325
|
resumeQueue(principal: Principal, org: OrgContext, id: string): Promise<Record<string, never>>;
|
|
@@ -312,7 +331,13 @@ export declare class ConversationsController {
|
|
|
312
331
|
sendQueued(principal: Principal, org: OrgContext, id: string, itemId: string): Promise<{
|
|
313
332
|
event: ConversationEvent;
|
|
314
333
|
}>;
|
|
315
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Stops the current run (the conversation's owner): 202 `{ runId }`; nothing active → 409
|
|
336
|
+
* `run.not_active`. On a root conversation `runId` is the stopped run, and its background
|
|
337
|
+
* sub-agents keep working. On a sub-agent's conversation (the root's owner, at any depth) the
|
|
338
|
+
* sub-agent stops with every sub-agent below it, and `runId` is the sub-agent's latest run,
|
|
339
|
+
* which may already be finished when only its descendants were working (agent map spec §6).
|
|
340
|
+
*/
|
|
316
341
|
abort(principal: Principal, org: OrgContext, id: string): Promise<{
|
|
317
342
|
runId: string;
|
|
318
343
|
}>;
|