@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ExtensionHost } from "../extensions/host.js";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import type { KernelLogger } from "../log.js";
|
|
4
|
+
import { ModelPurposesService } from "../models/purposes.js";
|
|
5
|
+
import { ProviderRegistry } from "../runtime/providers.js";
|
|
6
|
+
import { AgentsService, type AgentView, type AgentVisibility } from "./agents.service.js";
|
|
7
|
+
import type { ModelRef } from "./definition.js";
|
|
8
|
+
import { type ModelSource, type PlanItem } from "./from-template.js";
|
|
9
|
+
import { PendingConnectorRequests } from "./pending-connector-requests.js";
|
|
10
|
+
import type { ProfileInput } from "./profile.js";
|
|
11
|
+
/** The preview of creating an agent from a template (`POST …/agents/from-template/preview`). */
|
|
12
|
+
export interface TemplatePreview {
|
|
13
|
+
items: PlanItem[];
|
|
14
|
+
/** The automatic choice the dialog preselects (P4-4); null when the org has no usable model. */
|
|
15
|
+
model: (ModelRef & {
|
|
16
|
+
source: ModelSource;
|
|
17
|
+
}) | null;
|
|
18
|
+
dropped: string[];
|
|
19
|
+
previewHash: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateFromTemplateRequest {
|
|
22
|
+
templateId: string;
|
|
23
|
+
name: string;
|
|
24
|
+
visibility?: AgentVisibility;
|
|
25
|
+
members?: string[];
|
|
26
|
+
model?: ModelRef;
|
|
27
|
+
avatar?: ProfileInput["avatar"];
|
|
28
|
+
previewHash: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creating agents from templates (rulings P4-3…P4-8): the preview and the create both resolve the
|
|
32
|
+
* template with {@link planFromTemplate}; the create refuses a plan whose hash differs from the
|
|
33
|
+
* preview's (409 `agent.template_preview_stale`: the base part, and the automatic model's part when
|
|
34
|
+
* no model is chosen), writes the agent through
|
|
35
|
+
* {@link AgentsService.createFromTemplate}, and after the commit opens the pending connector request
|
|
36
|
+
* when the creator cannot configure connectors.
|
|
37
|
+
*/
|
|
38
|
+
export declare class AgentsFromTemplate {
|
|
39
|
+
private readonly db;
|
|
40
|
+
private readonly agents;
|
|
41
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
42
|
+
private readonly host;
|
|
43
|
+
private readonly providers;
|
|
44
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
45
|
+
private readonly purposes;
|
|
46
|
+
private readonly requests;
|
|
47
|
+
private readonly log;
|
|
48
|
+
constructor(db: KernelDb, agents: AgentsService,
|
|
49
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
50
|
+
host: Pick<ExtensionHost, "tools" | "enabledPlugins">, providers: Pick<ProviderRegistry, "resolve" | "list">,
|
|
51
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
52
|
+
purposes: Pick<ModelPurposesService, "resolve">, requests: PendingConnectorRequests, log: Pick<KernelLogger, "warn">);
|
|
53
|
+
/** The template, when usable in the org (P4-3); otherwise 404 `component.not_found`. */
|
|
54
|
+
private template;
|
|
55
|
+
private plan;
|
|
56
|
+
preview(orgId: string, templateId: string): Promise<TemplatePreview>;
|
|
57
|
+
create(orgId: string, actorAccountId: string, req: CreateFromTemplateRequest, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
58
|
+
agent: AgentView;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { ApiError } from "../errors.js";
|
|
12
|
+
import { ExtensionHost } from "../extensions/host.js";
|
|
13
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
15
|
+
import { ModelPurposesService } from "../models/purposes.js";
|
|
16
|
+
import { can } from "../orgs/roles.js";
|
|
17
|
+
import { ProviderRegistry } from "../runtime/providers.js";
|
|
18
|
+
import { AgentsService } from "./agents.service.js";
|
|
19
|
+
import { planFromTemplate, } from "./from-template.js";
|
|
20
|
+
import { PendingConnectorRequests } from "./pending-connector-requests.js";
|
|
21
|
+
import { loadTemplates } from "./templates.js";
|
|
22
|
+
/**
|
|
23
|
+
* Creating agents from templates (rulings P4-3…P4-8): the preview and the create both resolve the
|
|
24
|
+
* template with {@link planFromTemplate}; the create refuses a plan whose hash differs from the
|
|
25
|
+
* preview's (409 `agent.template_preview_stale`: the base part, and the automatic model's part when
|
|
26
|
+
* no model is chosen), writes the agent through
|
|
27
|
+
* {@link AgentsService.createFromTemplate}, and after the commit opens the pending connector request
|
|
28
|
+
* when the creator cannot configure connectors.
|
|
29
|
+
*/
|
|
30
|
+
let AgentsFromTemplate = class AgentsFromTemplate {
|
|
31
|
+
db;
|
|
32
|
+
agents;
|
|
33
|
+
host;
|
|
34
|
+
providers;
|
|
35
|
+
purposes;
|
|
36
|
+
requests;
|
|
37
|
+
log;
|
|
38
|
+
constructor(db, agents,
|
|
39
|
+
/** Extension tools loaded here and the org's enabled extensions. */
|
|
40
|
+
host, providers,
|
|
41
|
+
/** The tier's purpose mapping (`subagent_<tier>`, P4-4). */
|
|
42
|
+
purposes, requests, log) {
|
|
43
|
+
this.db = db;
|
|
44
|
+
this.agents = agents;
|
|
45
|
+
this.host = host;
|
|
46
|
+
this.providers = providers;
|
|
47
|
+
this.purposes = purposes;
|
|
48
|
+
this.requests = requests;
|
|
49
|
+
this.log = log;
|
|
50
|
+
}
|
|
51
|
+
/** The template, when usable in the org (P4-3); otherwise 404 `component.not_found`. */
|
|
52
|
+
async template(orgId, templateId) {
|
|
53
|
+
const row = (await loadTemplates(this.db.db, orgId, [templateId])).get(templateId);
|
|
54
|
+
if (!row) {
|
|
55
|
+
throw new ApiError("component.not_found", "The agent template does not exist or is not available in this organization");
|
|
56
|
+
}
|
|
57
|
+
return row;
|
|
58
|
+
}
|
|
59
|
+
async plan(orgId, row, model) {
|
|
60
|
+
const opts = {
|
|
61
|
+
pluginTools: this.host.tools().map((t) => ({ plugin: t.plugin, name: t.spec.name })),
|
|
62
|
+
enabledPlugins: await this.host.enabledPlugins(orgId),
|
|
63
|
+
resolveModel: async (ref) => {
|
|
64
|
+
try {
|
|
65
|
+
return (await this.providers.resolve(orgId, ref)).info.parameters;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
purpose: async (purpose) => {
|
|
72
|
+
try {
|
|
73
|
+
return await this.purposes.resolve(orgId, purpose);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
if (e instanceof ApiError)
|
|
77
|
+
return null;
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
defaultModel: async () => {
|
|
82
|
+
for (const p of await this.providers.list(orgId)) {
|
|
83
|
+
const m = p.models.find((x) => x.kind === "chat");
|
|
84
|
+
if (m)
|
|
85
|
+
return { provider: p.provider, model: m.id };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
...(model !== undefined && { model }),
|
|
90
|
+
};
|
|
91
|
+
return planFromTemplate(this.db.db, orgId, row, opts);
|
|
92
|
+
}
|
|
93
|
+
async preview(orgId, templateId) {
|
|
94
|
+
const plan = await this.plan(orgId, await this.template(orgId, templateId));
|
|
95
|
+
return {
|
|
96
|
+
items: plan.items,
|
|
97
|
+
model: plan.auto === null ? null : { ...plan.auto.ref, source: plan.auto.source },
|
|
98
|
+
dropped: plan.dropped,
|
|
99
|
+
previewHash: plan.hash,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async create(orgId, actorAccountId, req, actorTokenId, auditDetail) {
|
|
103
|
+
const row = await this.template(orgId, req.templateId);
|
|
104
|
+
const plan = await this.plan(orgId, row, req.model);
|
|
105
|
+
// the base part always; the automatic model's part only when the person chose none, so a
|
|
106
|
+
// silently changed choice is stale while an explicit one never is
|
|
107
|
+
const [base, auto] = req.previewHash.split(".");
|
|
108
|
+
if (base !== plan.baseHash || (req.model === undefined && auto !== plan.modelHash)) {
|
|
109
|
+
throw new ApiError("agent.template_preview_stale", "The template or the organization changed since the preview; preview it again");
|
|
110
|
+
}
|
|
111
|
+
if (plan.model === null) {
|
|
112
|
+
throw new ApiError("agent.model_unavailable", "No model is available for the new agent");
|
|
113
|
+
}
|
|
114
|
+
const { agent, role } = await this.agents.createFromTemplate(orgId, actorAccountId, {
|
|
115
|
+
definition: {
|
|
116
|
+
...plan.definition,
|
|
117
|
+
name: req.name,
|
|
118
|
+
model: plan.model.ref,
|
|
119
|
+
modelParams: plan.model.params,
|
|
120
|
+
},
|
|
121
|
+
visibility: req.visibility ?? "private",
|
|
122
|
+
...(req.members !== undefined && { memberIds: req.members }),
|
|
123
|
+
profile: {
|
|
124
|
+
description: plan.profile.description,
|
|
125
|
+
quickActions: plan.profile.quickActions,
|
|
126
|
+
...(req.avatar != null && { avatar: req.avatar }),
|
|
127
|
+
},
|
|
128
|
+
}, { id: req.templateId, version: row.version, name: row.name }, actorTokenId, auditDetail);
|
|
129
|
+
const keys = (agent.definition.pendingConnectors ?? []).map((c) => c.key);
|
|
130
|
+
if (keys.length > 0 && !can(role, "connectors.manage")) {
|
|
131
|
+
try {
|
|
132
|
+
await this.requests.openFor({
|
|
133
|
+
orgId,
|
|
134
|
+
agentId: agent.id,
|
|
135
|
+
ownerAccountId: agent.ownerAccountId,
|
|
136
|
+
keys,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
// the agent stands; its 待配置 notice offers the request again (ruling P4-7)
|
|
141
|
+
this.log.warn("cannot open the pending connector request of a new agent", {
|
|
142
|
+
orgId,
|
|
143
|
+
agentId: agent.id,
|
|
144
|
+
err,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { agent };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
AgentsFromTemplate = __decorate([
|
|
152
|
+
Injectable(),
|
|
153
|
+
__param(0, Inject(KernelDb)),
|
|
154
|
+
__param(1, Inject(AgentsService)),
|
|
155
|
+
__param(2, Inject(ExtensionHost)),
|
|
156
|
+
__param(3, Inject(ProviderRegistry)),
|
|
157
|
+
__param(4, Inject(ModelPurposesService)),
|
|
158
|
+
__param(5, Inject(PendingConnectorRequests)),
|
|
159
|
+
__param(6, Inject(KERNEL_LOGGER))
|
|
160
|
+
], AgentsFromTemplate);
|
|
161
|
+
export { AgentsFromTemplate };
|
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
import type { LocalizedName
|
|
1
|
+
import type { LocalizedName } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
3
|
-
import {
|
|
4
|
+
import { type Principal } from "../identity/principal.js";
|
|
5
|
+
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
|
+
import { type KernelModelInfo, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
|
|
7
|
+
declare const ModelsQuery: z.ZodObject<{
|
|
8
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
chat: "chat";
|
|
10
|
+
embedding: "embedding";
|
|
11
|
+
image_generation: "image_generation";
|
|
12
|
+
other: "other";
|
|
13
|
+
rerank: "rerank";
|
|
14
|
+
speech_to_text: "speech_to_text";
|
|
15
|
+
text_to_speech: "text_to_speech";
|
|
16
|
+
video_generation: "video_generation";
|
|
17
|
+
}>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
4
19
|
/**
|
|
5
20
|
* 可选模型(`/api/v1/orgs/:orgId/models`):已安装的模型供应商及其模型,列表缓存在 Redis。Each provider
|
|
6
|
-
* carries its extension's display name (null when it has none).
|
|
21
|
+
* carries its extension's display name (null when it has none). Listed for the org (its effective
|
|
22
|
+
* provider config: a provider needing configuration there is absent); only enabled models (neither
|
|
23
|
+
* the platform nor the org disabled them, spec B §5.3), optionally of one `?kind=`; every model
|
|
24
|
+
* carries its normalised `kind` (`other` for a kind this kernel does not know).
|
|
7
25
|
*/
|
|
8
26
|
export declare class ModelsController {
|
|
9
27
|
private readonly registry;
|
|
10
28
|
private readonly displayNames;
|
|
11
29
|
constructor(registry: ProviderRegistry, displayNames: ExtensionDisplayNames);
|
|
12
|
-
list(): Promise<{
|
|
30
|
+
list(org: OrgContext, q: z.infer<typeof ModelsQuery>): Promise<{
|
|
13
31
|
providers: {
|
|
14
32
|
provider: string;
|
|
15
33
|
displayName: LocalizedName | null;
|
|
16
|
-
models:
|
|
34
|
+
models: KernelModelInfo[];
|
|
17
35
|
}[];
|
|
18
36
|
}>;
|
|
37
|
+
/**
|
|
38
|
+
* The org's model catalog (the settings page; `org.models.manage`, people only): every provider
|
|
39
|
+
* with its status for the org and every model the platform left on, each with `disabled` for the
|
|
40
|
+
* org's own list.
|
|
41
|
+
*/
|
|
42
|
+
catalog(principal: Principal, org: OrgContext): Promise<{
|
|
43
|
+
providers: (ProviderStatus & {
|
|
44
|
+
displayName: LocalizedName | null;
|
|
45
|
+
})[];
|
|
46
|
+
}>;
|
|
19
47
|
}
|
|
48
|
+
export {};
|
|
@@ -8,12 +8,35 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Get, Inject } from "@nestjs/common";
|
|
11
|
+
import { z } from "zod";
|
|
11
12
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
14
|
+
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
|
+
import { ZQuery } from "../infra/validation/zod-params.js";
|
|
16
|
+
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
17
|
+
import { ProviderRegistry, } from "../runtime/providers.js";
|
|
18
|
+
const ModelsQuery = z.object({
|
|
19
|
+
kind: z
|
|
20
|
+
.enum([
|
|
21
|
+
"chat",
|
|
22
|
+
"embedding",
|
|
23
|
+
"rerank",
|
|
24
|
+
"image_generation",
|
|
25
|
+
"video_generation",
|
|
26
|
+
"speech_to_text",
|
|
27
|
+
"text_to_speech",
|
|
28
|
+
"other",
|
|
29
|
+
])
|
|
30
|
+
.optional(),
|
|
31
|
+
});
|
|
32
|
+
class ModelsQueryDto extends createZodDto(ModelsQuery, "ModelsQuery") {
|
|
33
|
+
}
|
|
14
34
|
/**
|
|
15
35
|
* 可选模型(`/api/v1/orgs/:orgId/models`):已安装的模型供应商及其模型,列表缓存在 Redis。Each provider
|
|
16
|
-
* carries its extension's display name (null when it has none).
|
|
36
|
+
* carries its extension's display name (null when it has none). Listed for the org (its effective
|
|
37
|
+
* provider config: a provider needing configuration there is absent); only enabled models (neither
|
|
38
|
+
* the platform nor the org disabled them, spec B §5.3), optionally of one `?kind=`; every model
|
|
39
|
+
* carries its normalised `kind` (`other` for a kind this kernel does not know).
|
|
17
40
|
*/
|
|
18
41
|
let ModelsController = class ModelsController {
|
|
19
42
|
registry;
|
|
@@ -22,8 +45,8 @@ let ModelsController = class ModelsController {
|
|
|
22
45
|
this.registry = registry;
|
|
23
46
|
this.displayNames = displayNames;
|
|
24
47
|
}
|
|
25
|
-
async list() {
|
|
26
|
-
const providers = await this.registry.list();
|
|
48
|
+
async list(org, q) {
|
|
49
|
+
const providers = await this.registry.list(org.orgId, q.kind === undefined ? {} : { kind: q.kind });
|
|
27
50
|
const names = await this.displayNames.many(providers.map((p) => p.provider));
|
|
28
51
|
return {
|
|
29
52
|
providers: providers.map((p) => ({
|
|
@@ -33,11 +56,32 @@ let ModelsController = class ModelsController {
|
|
|
33
56
|
})),
|
|
34
57
|
};
|
|
35
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The org's model catalog (the settings page; `org.models.manage`, people only): every provider
|
|
61
|
+
* with its status for the org and every model the platform left on, each with `disabled` for the
|
|
62
|
+
* org's own list.
|
|
63
|
+
*/
|
|
64
|
+
async catalog(principal, org) {
|
|
65
|
+
requireUser(principal);
|
|
66
|
+
const providers = await this.registry.catalog(org.orgId);
|
|
67
|
+
const names = await this.displayNames.many(providers.map((p) => p.plugin));
|
|
68
|
+
return {
|
|
69
|
+
providers: providers.map((p) => ({ ...p, displayName: names.get(p.plugin) ?? null })),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
36
72
|
};
|
|
37
73
|
__decorate([
|
|
38
74
|
Get(),
|
|
39
|
-
OrgAction("agents.use")
|
|
75
|
+
OrgAction("agents.use"),
|
|
76
|
+
__param(0, CurrentOrg()),
|
|
77
|
+
__param(1, ZQuery(ModelsQueryDto))
|
|
40
78
|
], ModelsController.prototype, "list", null);
|
|
79
|
+
__decorate([
|
|
80
|
+
Get("catalog"),
|
|
81
|
+
OrgAction("org.models.manage"),
|
|
82
|
+
__param(0, CurrentPrincipal()),
|
|
83
|
+
__param(1, CurrentOrg())
|
|
84
|
+
], ModelsController.prototype, "catalog", null);
|
|
41
85
|
ModelsController = __decorate([
|
|
42
86
|
Controller("api/v1/orgs/:orgId/models"),
|
|
43
87
|
__param(0, Inject(ProviderRegistry)),
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { type AgentTemplate } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type Owner } from "../catalog/ownership.js";
|
|
3
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
4
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { OrgLock } from "../orgs/org-lock.js";
|
|
7
|
+
import { AgentLookup, type AgentView } from "./agent-lookup.js";
|
|
8
|
+
import { type AgentTemplateView } from "./templates.js";
|
|
9
|
+
/** A template with its definition, as `GET orgs/:orgId/agent-templates/:id` answers. */
|
|
10
|
+
export interface AgentTemplateDetail extends AgentTemplateView {
|
|
11
|
+
/** The current definition (the served version). */
|
|
12
|
+
definition: AgentTemplate;
|
|
13
|
+
/** Who owns it: the platform, or the org that created it (P3-14's shape). */
|
|
14
|
+
owner: Owner;
|
|
15
|
+
/**
|
|
16
|
+
* The org's own template (an org template, promoted or not; rulings P3-6, P4-12): its admins
|
|
17
|
+
* edit, delete and set 可共享 on it. Always false for a plugin's template.
|
|
18
|
+
*/
|
|
19
|
+
owned: boolean;
|
|
20
|
+
/** 可共享 (only meaningful when `owned`). */
|
|
21
|
+
shareable: boolean;
|
|
22
|
+
/** Shared already: the platform row it was promoted to on share (ruling P3-3). */
|
|
23
|
+
promoted: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* In the org's usable set (agents can be created from it here). False only when the owner reads
|
|
26
|
+
* its own template while it is not usable in its org (a promoted one switched off there).
|
|
27
|
+
*/
|
|
28
|
+
usable: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What 另存为模板 left out (ruling P4-10), listed to the person: `kind` names the part of the
|
|
32
|
+
* agent, `name` the item (roster name, skill or connector name), `id` its id when it has one, and
|
|
33
|
+
* `reason`:
|
|
34
|
+
* - `org_agent`: an allowlisted org agent in the roster (an agent, not a template);
|
|
35
|
+
* - `unavailable`: a skill, sub-agent template or connector the org can no longer use;
|
|
36
|
+
* - `agent_skill`: one of the agent's own skills (not in the org library, so no other agent could
|
|
37
|
+
* resolve it);
|
|
38
|
+
* - `no_endpoint`: a hand-configured connector without a URL to record (an inline OpenAPI document);
|
|
39
|
+
* - `unsupported_protocol`: a hand-configured connector of a kind other than MCP or OpenAPI;
|
|
40
|
+
* - `limit`: past a template limit (connectors 16, sub-agent types and inline 16, tools 200, a
|
|
41
|
+
* connector entry's tools and policy keys 200 together: kind `tool_policy`, `name` the tool,
|
|
42
|
+
* `id` the connector);
|
|
43
|
+
* - `connector_tool`: a policy on a tool of a connector the template does not carry (kind
|
|
44
|
+
* `tool_policy`, `name` its key; carried connectors take their policies in `policies`), or a
|
|
45
|
+
* connector tool key in an inline sub-agent's allowlist (kind `subagent_inline`,
|
|
46
|
+
* `field: "tools"`, `name` the sub-agent): connector keys embed this org's connector slug;
|
|
47
|
+
* - `unsupported_field`: a field of an inline sub-agent a template's inline entry cannot hold
|
|
48
|
+
* (kind `subagent_inline`, `field`: `disallowedTools`, `toolPolicies`, `effort` or `maxSteps`);
|
|
49
|
+
* - `model_param`: a model parameter other than a valid `effort` (kind `model_param`, `name` its
|
|
50
|
+
* key): a template records only the effort (P4-10);
|
|
51
|
+
* - `fallback`: the fallback model and its parameters (kind `fallback_model`, `name`
|
|
52
|
+
* `provider/model`): a template has no fallback;
|
|
53
|
+
* - `empty_text`: whitespace-only text a template requires (kind `subagent_inline` with `field`
|
|
54
|
+
* `description` or `instructions`: the sub-agent is left out; kind `quick_action`, `name` its
|
|
55
|
+
* title: the quick action is left out).
|
|
56
|
+
* An inline sub-agent's skills that are the agent's own (`agent_skill`), gone (`unavailable`) or
|
|
57
|
+
* past the 3 a template holds (`limit`) are listed as kind `skill`.
|
|
58
|
+
*/
|
|
59
|
+
export interface SaveAsOmission {
|
|
60
|
+
kind: "subagent_agent" | "subagent_template" | "subagent_inline" | "skill" | "connector" | "tool" | "tool_policy" | "model_param" | "fallback_model" | "quick_action";
|
|
61
|
+
name: string;
|
|
62
|
+
id?: string;
|
|
63
|
+
/** The field of an inline sub-agent left out (`connector_tool`, `unsupported_field`). */
|
|
64
|
+
field?: string;
|
|
65
|
+
reason: "org_agent" | "unavailable" | "agent_skill" | "no_endpoint" | "unsupported_protocol" | "limit" | "connector_tool" | "unsupported_field" | "model_param" | "fallback" | "empty_text";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Roster names no template may take (ruling T4-R15): `general-purpose`, always the roster's first
|
|
69
|
+
* entry. Claude Code's other built-in types (`Explore`, `Plan`) are capitalized, which the
|
|
70
|
+
* template name rule already refuses.
|
|
71
|
+
*/
|
|
72
|
+
export declare const RESERVED_TEMPLATE_NAMES: ReadonlySet<string>;
|
|
73
|
+
/**
|
|
74
|
+
* A connector's URL as a template may record it (ruling P4-11): userinfo, query and fragment
|
|
75
|
+
* removed (they may carry credentials). Null when it is no absolute http(s) URL.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sanitizeEndpoint(raw: string): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* Validates a template definition the way an `agents/<name>.md` file is (the SDK parser, so the
|
|
80
|
+
* two never drift): the definition minus `instructions` as the frontmatter (JSON is YAML), then
|
|
81
|
+
* the instructions as the body. Problems -> 400 `validation_failed` naming each.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseTemplateDefinition(definition: Record<string, unknown>): AgentTemplate;
|
|
84
|
+
/**
|
|
85
|
+
* Ruling P4-11 on an edit: a `connectors[].needs.endpoint` that carries userinfo, a query or a
|
|
86
|
+
* fragment, or is no http(s) URL of at most 2048 characters, is refused with 400
|
|
87
|
+
* `validation_failed` naming the field and what it carries (an edit is never stripped silently).
|
|
88
|
+
* One that differs only by normalization (a trailing slash, the host's case) is accepted:
|
|
89
|
+
* returns the template with each such endpoint in its canonical {@link sanitizeEndpoint} form.
|
|
90
|
+
*/
|
|
91
|
+
export declare function canonicalEndpoints(template: AgentTemplate): AgentTemplate;
|
|
92
|
+
/**
|
|
93
|
+
* The template an agent is saved as (rulings P4-10, P4-11), with what was left out. Pure reads of
|
|
94
|
+
* the org's state through `db`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function templateFromAgent(db: KernelSchemaDb, orgId: string, agent: AgentView, meta: {
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
template: AgentTemplate;
|
|
101
|
+
omitted: SaveAsOmission[];
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* The org's agent templates beyond the plugin ones (rulings P4-9 to P4-12): 另存为模板, the detail
|
|
105
|
+
* of a usable template and the owner's new versions. Writes run under the org row lock, with
|
|
106
|
+
* `agents.manage` re-checked there.
|
|
107
|
+
*/
|
|
108
|
+
export declare class OrgAgentTemplates {
|
|
109
|
+
private readonly kdb;
|
|
110
|
+
private readonly orgLock;
|
|
111
|
+
private readonly agents;
|
|
112
|
+
readonly txHost: TransactionHost;
|
|
113
|
+
constructor(kdb: KernelDb, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "view">, txHost: TransactionHost);
|
|
114
|
+
private get db();
|
|
115
|
+
/**
|
|
116
|
+
* 另存为模板 (ruling P4-9): the org's live agent `agentId` (any one: an org admin may edit every
|
|
117
|
+
* agent of the org) saved as the org template `name` (version 1, `plugin_name` null), mapped
|
|
118
|
+
* by {@link templateFromAgent}. The bare name must be free in the org (rule 10): a usable
|
|
119
|
+
* template of that type, one of the org's own rows of that name, or a live platform template
|
|
120
|
+
* the org created under that name -> 409 `agent_template.name_taken` naming its owner (details
|
|
121
|
+
* `[{ owner, templateId }]`). Audits `agent_template.created`.
|
|
122
|
+
*/
|
|
123
|
+
saveAs(orgId: string, actor: string, agentId: string, meta: {
|
|
124
|
+
name: string;
|
|
125
|
+
description: string;
|
|
126
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
127
|
+
template: AgentTemplateDetail;
|
|
128
|
+
omitted: SaveAsOmission[];
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Rule 10 for a new org template named `name` (a bare type): refused for a reserved roster name
|
|
132
|
+
* (details `[{ reserved: true }]`), and while the org's usable set has that type, the org has a
|
|
133
|
+
* live row of that name without a plugin (an unusable copy too: the live-name index), a
|
|
134
|
+
* plugin-less platform template of that name is offered to the org (ruling P2-3's alignment),
|
|
135
|
+
* or the platform has a live template the org created under that name (promotion would clash).
|
|
136
|
+
*/
|
|
137
|
+
private assertNameFree;
|
|
138
|
+
/**
|
|
139
|
+
* A template usable in the org by id ({@link loadTemplates}: an org row, a linked copy, a
|
|
140
|
+
* platform template on in the org), or the org's own template whatever its switch, with its
|
|
141
|
+
* definition, owner and the org's flags. Otherwise -> 404 `component.not_found`.
|
|
142
|
+
*/
|
|
143
|
+
detail(orgId: string, id: string): Promise<AgentTemplateDetail>;
|
|
144
|
+
/**
|
|
145
|
+
* A new version of the org's own template `id` (ruling P4-12; `agents.manage` re-checked under
|
|
146
|
+
* the org row lock): `definition` is validated like a template file and keeps its name;
|
|
147
|
+
* `expectedVersion` must be the version the editor read (else 409
|
|
148
|
+
* `agent_template.version_conflict`). An unshared template gets a new version of its org row; a
|
|
149
|
+
* promoted one a new version of its platform row (ruling P3-4), which the org row then serves
|
|
150
|
+
* (ruling P3-43), and the orgs using it are told (`shared_item_updated`). An unchanged
|
|
151
|
+
* definition writes nothing. Not the org's own -> 409 `catalog.not_owned`; missing -> 404.
|
|
152
|
+
* Agents created earlier are never touched. Audits `agent_template.updated`.
|
|
153
|
+
*/
|
|
154
|
+
update(orgId: string, actor: string, id: string, body: {
|
|
155
|
+
definition: Record<string, unknown>;
|
|
156
|
+
expectedVersion: number;
|
|
157
|
+
}, actorTokenId?: string): Promise<AgentTemplateDetail>;
|
|
158
|
+
/**
|
|
159
|
+
* The org's own template `id` ({@link readOwnTemplate}, the predicate `OwnedItems` shares), or
|
|
160
|
+
* undefined: another org's, a plugin's, or a copy of a platform template it does not own.
|
|
161
|
+
*/
|
|
162
|
+
private ownRow;
|
|
163
|
+
/**
|
|
164
|
+
* What the org's own template serves, read directly (its usable-set entry is missing while the
|
|
165
|
+
* org switched its promoted template off): the platform row's current version when it is newer
|
|
166
|
+
* than the org row's (ruling P3-43), else the org row's.
|
|
167
|
+
*/
|
|
168
|
+
private ownServed;
|
|
169
|
+
/** 409 `catalog.not_owned` for a template the org has but does not own, else 404. */
|
|
170
|
+
private notOwnedOrMissing;
|
|
171
|
+
/**
|
|
172
|
+
* The owner of a usable template the org does not own itself: a platform template's (or a
|
|
173
|
+
* linked copy's) `owner_org_id`, a plugin template's catalog item owner, else the platform.
|
|
174
|
+
*/
|
|
175
|
+
private ownerOfRow;
|
|
176
|
+
}
|