@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/ui/views.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { ConversationsService } from "../conversations/conversations.service.js";
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
|
+
import { EffectiveConfigs, NEEDS_CONFIG_REASON } from "../extensions/effective-config.js";
|
|
15
16
|
import { ExtensionHost } from "../extensions/host.js";
|
|
16
17
|
import { PreviewerRegistry } from "../files/previewers.js";
|
|
17
18
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -100,9 +101,10 @@ function actionResultProblems(r) {
|
|
|
100
101
|
*/
|
|
101
102
|
let UiViews = class UiViews {
|
|
102
103
|
d;
|
|
103
|
-
constructor(host, conversations, previewers, db, log) {
|
|
104
|
+
constructor(host, conversations, previewers, db, log, effective) {
|
|
104
105
|
this.d = {
|
|
105
106
|
host,
|
|
107
|
+
effective,
|
|
106
108
|
// org config rows plus the required bootstrap plugins
|
|
107
109
|
enabledPlugins: (orgId) => host.enabledPlugins(orgId),
|
|
108
110
|
canAccessConversation: (orgId, id, accountId) => conversations.isAccessible(orgId, id, accountId),
|
|
@@ -223,7 +225,18 @@ let UiViews = class UiViews {
|
|
|
223
225
|
throw notFound();
|
|
224
226
|
if (!(await this.d.enabledPlugins(t.orgId)).has(t.plugin))
|
|
225
227
|
throw notFound();
|
|
226
|
-
|
|
228
|
+
// spec A §6: the extension is not called for an org whose effective config is not valid
|
|
229
|
+
const effective = await this.d.effective.get(t.orgId, t.plugin);
|
|
230
|
+
if (!effective.ok) {
|
|
231
|
+
throw new ApiError("extension.needs_config", `Extension ${t.plugin} ${NEEDS_CONFIG_REASON}`);
|
|
232
|
+
}
|
|
233
|
+
const base = {
|
|
234
|
+
orgId: t.orgId,
|
|
235
|
+
accountId: t.accountId,
|
|
236
|
+
role: t.role,
|
|
237
|
+
locale: t.locale,
|
|
238
|
+
config: effective.config,
|
|
239
|
+
};
|
|
227
240
|
if (!isConversationPlace(entry.contribution.place)) {
|
|
228
241
|
if (t.item !== undefined || t.card !== undefined) {
|
|
229
242
|
throw new ApiError("validation_failed", "item and callId are for conversation views");
|
|
@@ -299,6 +312,7 @@ UiViews = __decorate([
|
|
|
299
312
|
__param(1, Inject(ConversationsService)),
|
|
300
313
|
__param(2, Inject(PreviewerRegistry)),
|
|
301
314
|
__param(3, Inject(KernelDb)),
|
|
302
|
-
__param(4, Inject(KERNEL_LOGGER))
|
|
315
|
+
__param(4, Inject(KERNEL_LOGGER)),
|
|
316
|
+
__param(5, Inject(EffectiveConfigs))
|
|
303
317
|
], UiViews);
|
|
304
318
|
export { UiViews };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.6",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"yaml": "^2.9.1",
|
|
65
65
|
"yauzl": "3.4.0",
|
|
66
66
|
"zod": "^4.6.7",
|
|
67
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
67
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.4"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
71
71
|
"@types/pg": "^8.23.1",
|
|
72
72
|
"@types/semver": "^7.8.0",
|
|
73
73
|
"@types/yauzl": "3.4.0",
|
|
74
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
74
|
+
"@capybara-hq/testing": "0.1.0-rc.7"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "tsc -b"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
-- Agent map (spec docs/superpowers/specs/2026-11-06-agent-map-design.md §6): nested sub-agents
|
|
2
|
+
-- and a budget per tree.
|
|
3
|
+
-- - conversations.subagent_depth: levels below the root conversation (0 = a root, 1 = its child).
|
|
4
|
+
-- - runs.budget_run_id: the person-triggered root run whose window this run's dispatches and its
|
|
5
|
+
-- descendants' tokens count against; null = the run is its own budget run.
|
|
6
|
+
-- - subagent_dispatches.budget_run_id: the budget run the dispatch counted against (existing rows:
|
|
7
|
+
-- the dispatching run, which was its own budget run before nesting).
|
|
8
|
+
-- - subagent_dispatches.for_skill: the dispatch of a `context: fork` skill invocation (existing
|
|
9
|
+
-- fork dispatches are backfilled).
|
|
10
|
+
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS subagent_depth smallint NOT NULL DEFAULT 0;
|
|
11
|
+
|
|
12
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS budget_run_id text;
|
|
13
|
+
CREATE INDEX IF NOT EXISTS runs_budget_run_idx ON runs (budget_run_id)
|
|
14
|
+
WHERE budget_run_id IS NOT NULL;
|
|
15
|
+
|
|
16
|
+
ALTER TABLE subagent_dispatches ADD COLUMN IF NOT EXISTS budget_run_id text;
|
|
17
|
+
UPDATE subagent_dispatches SET budget_run_id = parent_run_id WHERE budget_run_id IS NULL;
|
|
18
|
+
ALTER TABLE subagent_dispatches ALTER COLUMN budget_run_id SET NOT NULL;
|
|
19
|
+
ALTER TABLE subagent_dispatches ADD COLUMN IF NOT EXISTS for_skill boolean NOT NULL DEFAULT false;
|
|
20
|
+
-- Existing fork dispatches (phase D: call id `skill-<seq>` at step 0, `skillCallId` / `FORK_STEP`
|
|
21
|
+
-- in runtime/subagents/skill-fork.ts) are marked, so a fork in flight across the upgrade keeps its
|
|
22
|
+
-- wait and its finish is never delivered as a background child's. A second run changes nothing.
|
|
23
|
+
UPDATE subagent_dispatches SET for_skill = true
|
|
24
|
+
WHERE for_skill = false AND step = 0 AND parent_call_id ~ '^skill-[0-9]+$';
|
|
25
|
+
CREATE INDEX IF NOT EXISTS subagent_dispatches_budget_run_idx
|
|
26
|
+
ON subagent_dispatches (budget_run_id);
|
|
27
|
+
|
|
28
|
+
-- Org overrides stored in deployment_settings.subagentLimitOverrides ({orgId: {...}}): the limit
|
|
29
|
+
-- maxConcurrentPerRun is now maxConcurrentPerConversation (per conversation, §6). Each org entry
|
|
30
|
+
-- holding the old key gets the new key with its value instead; an entry that already has the new
|
|
31
|
+
-- key keeps it. Rows without the old key are left as they are, so a second run changes nothing.
|
|
32
|
+
UPDATE deployment_settings AS ds
|
|
33
|
+
SET value = (
|
|
34
|
+
SELECT jsonb_object_agg(
|
|
35
|
+
e.org,
|
|
36
|
+
CASE
|
|
37
|
+
WHEN jsonb_typeof(e.entry) = 'object' AND e.entry ? 'maxConcurrentPerRun'
|
|
38
|
+
THEN jsonb_build_object('maxConcurrentPerConversation', e.entry -> 'maxConcurrentPerRun')
|
|
39
|
+
|| (e.entry - 'maxConcurrentPerRun')
|
|
40
|
+
ELSE e.entry
|
|
41
|
+
END
|
|
42
|
+
)
|
|
43
|
+
FROM jsonb_each(ds.value) AS e(org, entry)
|
|
44
|
+
)
|
|
45
|
+
WHERE ds.key = 'subagentLimitOverrides'
|
|
46
|
+
AND jsonb_typeof(ds.value) = 'object'
|
|
47
|
+
AND EXISTS (
|
|
48
|
+
SELECT 1 FROM jsonb_each(ds.value) AS e(org, entry)
|
|
49
|
+
WHERE jsonb_typeof(e.entry) = 'object' AND e.entry ? 'maxConcurrentPerRun'
|
|
50
|
+
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
-- Plugin scope (phase 1, spec 2026-11-05-plugin-component-management-design.md §5): every catalog item
|
|
2
|
+
-- gets a scope (all / optional / named), a builtin flag, a disabled flag, an org list (named) and
|
|
3
|
+
-- per-org switches. Replaces the catalog policy, grants and requests. Expand-only: `policy`,
|
|
4
|
+
-- `catalog_org_grants` and `catalog_requests` stay (nothing reads them after this release).
|
|
5
|
+
-- The backfill runs once per database (the migrator records the file); the UPDATEs below only read
|
|
6
|
+
-- the old columns, and the inserts are ON CONFLICT DO NOTHING.
|
|
7
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS scope text NOT NULL DEFAULT 'optional';
|
|
8
|
+
ALTER TABLE catalog_items DROP CONSTRAINT IF EXISTS catalog_items_scope_check;
|
|
9
|
+
ALTER TABLE catalog_items ADD CONSTRAINT catalog_items_scope_check
|
|
10
|
+
CHECK (scope IN ('all', 'optional', 'named'));
|
|
11
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS builtin boolean NOT NULL DEFAULT false;
|
|
12
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS disabled boolean NOT NULL DEFAULT false;
|
|
13
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS scope_version integer NOT NULL DEFAULT 0;
|
|
14
|
+
|
|
15
|
+
-- named scope: the orgs the item is offered to.
|
|
16
|
+
CREATE TABLE IF NOT EXISTS catalog_item_scope_orgs (
|
|
17
|
+
item_id uuid NOT NULL REFERENCES catalog_items(id) ON DELETE CASCADE,
|
|
18
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
19
|
+
PRIMARY KEY (item_id, org_id)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
-- Per-org on / off switch of an item's components.
|
|
23
|
+
CREATE TABLE IF NOT EXISTS catalog_item_org_switches (
|
|
24
|
+
item_id uuid NOT NULL REFERENCES catalog_items(id) ON DELETE CASCADE,
|
|
25
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
26
|
+
enabled boolean NOT NULL,
|
|
27
|
+
updated_by text REFERENCES accounts(id) ON DELETE SET NULL,
|
|
28
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
29
|
+
PRIMARY KEY (item_id, org_id)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
-- Backfill from policy / grants / installs.
|
|
33
|
+
UPDATE catalog_items SET disabled = true WHERE policy = 'disabled';
|
|
34
|
+
UPDATE catalog_items SET scope = 'named' WHERE policy = 'needs_approval';
|
|
35
|
+
|
|
36
|
+
-- Required bootstrap plugins are builtin and offered to every org.
|
|
37
|
+
UPDATE catalog_items SET scope = 'all', builtin = true
|
|
38
|
+
WHERE id IN (SELECT catalog_item_id FROM extension_installs
|
|
39
|
+
WHERE required AND catalog_item_id IS NOT NULL);
|
|
40
|
+
|
|
41
|
+
-- named: granted orgs and orgs that already installed it.
|
|
42
|
+
INSERT INTO catalog_item_scope_orgs (item_id, org_id)
|
|
43
|
+
SELECT g.item_id, g.org_id FROM catalog_org_grants g
|
|
44
|
+
JOIN catalog_items i ON i.id = g.item_id AND i.scope = 'named'
|
|
45
|
+
ON CONFLICT DO NOTHING;
|
|
46
|
+
INSERT INTO catalog_item_scope_orgs (item_id, org_id)
|
|
47
|
+
SELECT DISTINCT p.item_id, p.org_id FROM plugin_installs p
|
|
48
|
+
JOIN catalog_items i ON i.id = p.item_id AND i.scope = 'named'
|
|
49
|
+
WHERE p.status = 'installed'
|
|
50
|
+
ON CONFLICT DO NOTHING;
|
|
51
|
+
|
|
52
|
+
-- An org that installed the item keeps it on (builtin / all items need no switch).
|
|
53
|
+
INSERT INTO catalog_item_org_switches (item_id, org_id, enabled)
|
|
54
|
+
SELECT DISTINCT p.item_id, p.org_id, true FROM plugin_installs p
|
|
55
|
+
JOIN catalog_items i ON i.id = p.item_id AND i.scope <> 'all'
|
|
56
|
+
WHERE p.status = 'installed'
|
|
57
|
+
ON CONFLICT DO NOTHING;
|
|
58
|
+
|
|
59
|
+
-- Requests are gone: pending ones are withdrawn ('cancelled', the status the old withdraw used).
|
|
60
|
+
UPDATE catalog_requests SET status = 'cancelled', note = 'superseded by scope', decided_at = now()
|
|
61
|
+
WHERE status = 'pending';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- Plugin scope sync (spec 2026-11-05-plugin-component-management-design.md §5): the kernel installs
|
|
2
|
+
-- plugins in an org as no person (the worker job that converges orgs to a plugin's scope), so a
|
|
3
|
+
-- skill or skill version it creates has no creator. Relaxing NOT NULL is expand-only: rows written
|
|
4
|
+
-- before keep their creator, and dropping NOT NULL on a nullable column is a no-op.
|
|
5
|
+
ALTER TABLE skills ALTER COLUMN created_by DROP NOT NULL;
|
|
6
|
+
ALTER TABLE skill_versions ALTER COLUMN created_by DROP NOT NULL;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- Requests under plugin scope (phase 1, spec 2026-11-05-plugin-component-management-design.md
|
|
2
|
+
-- §5.1). A request has a kind: `access` (an org admin asks the enterprise admin to add the org to a
|
|
3
|
+
-- `named` item shown to other orgs), `import` (an org admin asks for a marketplace entry that is not
|
|
4
|
+
-- in the catalog yet: no item, the entry instead) or `enable` (a member asks the org admin to switch
|
|
5
|
+
-- an `optional` item on). Expand-only: `stage`, `version`, `org_decided_*` stay (the new code still
|
|
6
|
+
-- writes `stage` so the old NOT NULL and CHECK hold, and reads none of them).
|
|
7
|
+
|
|
8
|
+
-- Whether orgs outside a `named` item's list see it (as requestable). Never makes it usable.
|
|
9
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS shown_to_others boolean NOT NULL DEFAULT true;
|
|
10
|
+
|
|
11
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS kind text NOT NULL DEFAULT 'access';
|
|
12
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_kind_check;
|
|
13
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_kind_check
|
|
14
|
+
CHECK (kind IN ('access', 'import', 'enable'));
|
|
15
|
+
-- An `import` request names a marketplace entry; its item is written when the import's confirm
|
|
16
|
+
-- commits.
|
|
17
|
+
ALTER TABLE catalog_requests ALTER COLUMN item_id DROP NOT NULL;
|
|
18
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS marketplace_id text
|
|
19
|
+
REFERENCES marketplaces(id) ON DELETE SET NULL;
|
|
20
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS entry_name text;
|
|
21
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS entry_version text;
|
|
22
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_target_check;
|
|
23
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_target_check
|
|
24
|
+
CHECK (kind = 'import' AND entry_name IS NOT NULL OR kind <> 'import' AND item_id IS NOT NULL);
|
|
25
|
+
-- The optional reason of a rejection, shown to the requester.
|
|
26
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS reason text;
|
|
27
|
+
-- The prepared import of an approved `import` request (it resolves when that staging is confirmed;
|
|
28
|
+
-- a staging that expires leaves it pending).
|
|
29
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS staging_id uuid;
|
|
30
|
+
CREATE INDEX IF NOT EXISTS catalog_requests_staging_idx
|
|
31
|
+
ON catalog_requests (staging_id) WHERE staging_id IS NOT NULL;
|
|
32
|
+
-- The requester dismissed the decision notice from the inbox.
|
|
33
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS dismissed_at timestamptz;
|
|
34
|
+
|
|
35
|
+
-- One pending request per (org, kind, item or entry): replaces the old (org, item) index.
|
|
36
|
+
DROP INDEX IF EXISTS directory_requests_pending_uq;
|
|
37
|
+
CREATE UNIQUE INDEX IF NOT EXISTS catalog_requests_pending_item_uq
|
|
38
|
+
ON catalog_requests (org_id, kind, item_id)
|
|
39
|
+
WHERE status = 'pending' AND item_id IS NOT NULL;
|
|
40
|
+
CREATE UNIQUE INDEX IF NOT EXISTS catalog_requests_pending_entry_uq
|
|
41
|
+
ON catalog_requests (org_id, marketplace_id, entry_name)
|
|
42
|
+
WHERE status = 'pending' AND kind = 'import';
|
|
43
|
+
CREATE INDEX IF NOT EXISTS catalog_requests_kind_idx
|
|
44
|
+
ON catalog_requests (kind, status, created_at);
|
|
45
|
+
CREATE INDEX IF NOT EXISTS catalog_requests_requester_idx
|
|
46
|
+
ON catalog_requests (org_id, requested_by) WHERE status IN ('approved', 'rejected');
|
|
47
|
+
|
|
48
|
+
-- Rows written before kinds: a member's request (stage org) was an `enable` one; decided requests
|
|
49
|
+
-- from before are not shown to their requesters as new decisions.
|
|
50
|
+
UPDATE catalog_requests SET kind = 'enable' WHERE stage = 'org' AND kind = 'access';
|
|
51
|
+
UPDATE catalog_requests SET dismissed_at = now()
|
|
52
|
+
WHERE status <> 'pending' AND dismissed_at IS NULL;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Plugin scope follow-up to 0075 (spec 2026-11-05-plugin-component-management-design.md §6
|
|
2
|
+
-- "Migration of what exists"): 0075 put the orgs granted a `needs_approval` item on its `named`
|
|
3
|
+
-- list, where a listed org without a switch row wants the plugin on. A grant only allowed an
|
|
4
|
+
-- install; an org that never installed it did not have it on. Such orgs get an explicit switch
|
|
5
|
+
-- row `enabled = false`, so the plugin stays off there until an org admin switches it on.
|
|
6
|
+
-- Expand-only and idempotent: inserts only, ON CONFLICT DO NOTHING (a switch row an org admin or
|
|
7
|
+
-- 0075 wrote wins).
|
|
8
|
+
INSERT INTO catalog_item_org_switches (item_id, org_id, enabled)
|
|
9
|
+
SELECT s.item_id, s.org_id, false
|
|
10
|
+
FROM catalog_item_scope_orgs s
|
|
11
|
+
JOIN catalog_items i ON i.id = s.item_id AND i.policy = 'needs_approval'
|
|
12
|
+
JOIN catalog_org_grants g ON g.item_id = s.item_id AND g.org_id = s.org_id
|
|
13
|
+
WHERE NOT EXISTS (
|
|
14
|
+
SELECT 1 FROM plugin_installs p
|
|
15
|
+
WHERE p.item_id = s.item_id AND p.org_id = s.org_id
|
|
16
|
+
AND p.status IN ('installing', 'installed', 'upgrading')
|
|
17
|
+
)
|
|
18
|
+
ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Plugin scope follow-up to 0075 (spec 2026-11-05-plugin-component-management-design.md §6
|
|
2
|
+
-- "Migration of what exists"): 0075 listed and switched on only the org installs with status
|
|
3
|
+
-- `installed`. An install that was `installing` or `upgrading` when 0075 ran got no switch row,
|
|
4
|
+
-- which for an `optional` item means off, and no place on a `named` item's org list; the worker's
|
|
5
|
+
-- start-time scope resync would then uninstall it. Such installs get what 0075 gave installed ones:
|
|
6
|
+
-- the org on the named list and a switch row `enabled = true` (builtin / `all` items need none).
|
|
7
|
+
-- Expand-only and idempotent: inserts only, ON CONFLICT DO NOTHING (a row an org admin, 0075 or
|
|
8
|
+
-- 0078 wrote wins).
|
|
9
|
+
INSERT INTO catalog_item_scope_orgs (item_id, org_id)
|
|
10
|
+
SELECT DISTINCT p.item_id, p.org_id FROM plugin_installs p
|
|
11
|
+
JOIN catalog_items i ON i.id = p.item_id AND i.scope = 'named'
|
|
12
|
+
WHERE p.status IN ('installing', 'upgrading')
|
|
13
|
+
ON CONFLICT DO NOTHING;
|
|
14
|
+
|
|
15
|
+
INSERT INTO catalog_item_org_switches (item_id, org_id, enabled)
|
|
16
|
+
SELECT DISTINCT p.item_id, p.org_id, true FROM plugin_installs p
|
|
17
|
+
JOIN catalog_items i ON i.id = p.item_id AND i.scope <> 'all'
|
|
18
|
+
WHERE p.status IN ('installing', 'upgrading')
|
|
19
|
+
ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- The deployment-level role "enterprise admin" becomes "super admin" (plugin and component
|
|
2
|
+
-- management spec §13.4b): accounts.is_enterprise_admin becomes is_super_admin, and the stored
|
|
3
|
+
-- deployment setting orgCreation "enterprise_admin" becomes "super_admin". Historical audit rows
|
|
4
|
+
-- are not rewritten. No compatibility layer (release candidate).
|
|
5
|
+
|
|
6
|
+
-- capybara:allow-destructive column rename; code is renamed in the same release (release candidate, no compatibility layer)
|
|
7
|
+
DO $$
|
|
8
|
+
BEGIN
|
|
9
|
+
IF EXISTS (SELECT 1 FROM information_schema.columns
|
|
10
|
+
WHERE table_schema = 'capybara' AND table_name = 'accounts'
|
|
11
|
+
AND column_name = 'is_enterprise_admin') THEN
|
|
12
|
+
ALTER TABLE accounts RENAME COLUMN is_enterprise_admin TO is_super_admin;
|
|
13
|
+
END IF;
|
|
14
|
+
END
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
UPDATE deployment_settings SET value = '"super_admin"'::jsonb
|
|
18
|
+
WHERE key = 'orgCreation' AND value = '"enterprise_admin"'::jsonb;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
-- Platform components (phase 2, plan 2026-11-06-plugin-scope-phase-2.md rulings A2-C2, E2): skills,
|
|
2
|
+
-- agent templates and connector templates owned by the deployment instead of an org, with their own
|
|
3
|
+
-- scope (follow the plugin's, or their own), an org list (named) and per-org switches. Org copies
|
|
4
|
+
-- link to them. Expand-only: nothing existing is changed except `agent_templates.plugin_name`
|
|
5
|
+
-- losing NOT NULL (a template without a plugin is the bare `<name>`).
|
|
6
|
+
|
|
7
|
+
CREATE TABLE IF NOT EXISTS platform_skills (
|
|
8
|
+
id text PRIMARY KEY,
|
|
9
|
+
catalog_item_id uuid REFERENCES catalog_items(id) ON DELETE SET NULL,
|
|
10
|
+
plugin_name text,
|
|
11
|
+
name text NOT NULL,
|
|
12
|
+
description text NOT NULL,
|
|
13
|
+
description_zh text,
|
|
14
|
+
current_version integer NOT NULL CHECK (current_version >= 1),
|
|
15
|
+
scope_mode text NOT NULL DEFAULT 'follow' CHECK (scope_mode IN ('follow', 'own')),
|
|
16
|
+
scope text NOT NULL DEFAULT 'optional' CHECK (scope IN ('all', 'optional', 'named')),
|
|
17
|
+
disabled boolean NOT NULL DEFAULT false,
|
|
18
|
+
shown_to_others boolean NOT NULL DEFAULT true,
|
|
19
|
+
scope_version integer NOT NULL DEFAULT 0,
|
|
20
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
21
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
22
|
+
deleted_at timestamptz
|
|
23
|
+
);
|
|
24
|
+
CREATE UNIQUE INDEX IF NOT EXISTS platform_skills_live_name_uq
|
|
25
|
+
ON platform_skills ((coalesce(plugin_name, '')), name)
|
|
26
|
+
WHERE deleted_at IS NULL;
|
|
27
|
+
|
|
28
|
+
CREATE TABLE IF NOT EXISTS platform_skill_versions (
|
|
29
|
+
skill_id text NOT NULL REFERENCES platform_skills(id) ON DELETE CASCADE,
|
|
30
|
+
version integer NOT NULL CHECK (version >= 1),
|
|
31
|
+
manifest jsonb NOT NULL,
|
|
32
|
+
object_prefix text NOT NULL,
|
|
33
|
+
catalog_version text,
|
|
34
|
+
source_format text NOT NULL DEFAULT 'capybara' CHECK (source_format IN ('capybara', 'claude-code')),
|
|
35
|
+
suggest_pinned boolean NOT NULL DEFAULT false,
|
|
36
|
+
updated_on_own boolean NOT NULL DEFAULT false,
|
|
37
|
+
created_by text,
|
|
38
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
39
|
+
PRIMARY KEY (skill_id, version)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
CREATE TABLE IF NOT EXISTS platform_agent_templates (
|
|
43
|
+
id text PRIMARY KEY,
|
|
44
|
+
catalog_item_id uuid REFERENCES catalog_items(id) ON DELETE SET NULL,
|
|
45
|
+
plugin_name text,
|
|
46
|
+
name text NOT NULL,
|
|
47
|
+
description text,
|
|
48
|
+
description_zh text,
|
|
49
|
+
current_version integer NOT NULL CHECK (current_version >= 1),
|
|
50
|
+
scope_mode text NOT NULL DEFAULT 'follow' CHECK (scope_mode IN ('follow', 'own')),
|
|
51
|
+
scope text NOT NULL DEFAULT 'optional' CHECK (scope IN ('all', 'optional', 'named')),
|
|
52
|
+
disabled boolean NOT NULL DEFAULT false,
|
|
53
|
+
shown_to_others boolean NOT NULL DEFAULT true,
|
|
54
|
+
scope_version integer NOT NULL DEFAULT 0,
|
|
55
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
56
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
57
|
+
deleted_at timestamptz
|
|
58
|
+
);
|
|
59
|
+
CREATE UNIQUE INDEX IF NOT EXISTS platform_agent_templates_live_name_uq
|
|
60
|
+
ON platform_agent_templates ((coalesce(plugin_name, '')), name)
|
|
61
|
+
WHERE deleted_at IS NULL;
|
|
62
|
+
|
|
63
|
+
CREATE TABLE IF NOT EXISTS platform_agent_template_versions (
|
|
64
|
+
template_id text NOT NULL REFERENCES platform_agent_templates(id) ON DELETE CASCADE,
|
|
65
|
+
version integer NOT NULL CHECK (version >= 1),
|
|
66
|
+
definition jsonb NOT NULL,
|
|
67
|
+
object_prefix text,
|
|
68
|
+
catalog_version text,
|
|
69
|
+
source_format text NOT NULL DEFAULT 'capybara' CHECK (source_format IN ('capybara', 'claude-code')),
|
|
70
|
+
suggest_pinned boolean NOT NULL DEFAULT false,
|
|
71
|
+
updated_on_own boolean NOT NULL DEFAULT false,
|
|
72
|
+
created_by text,
|
|
73
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
74
|
+
PRIMARY KEY (template_id, version)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
CREATE TABLE IF NOT EXISTS platform_connector_templates (
|
|
78
|
+
id text PRIMARY KEY,
|
|
79
|
+
catalog_item_id uuid NOT NULL REFERENCES catalog_items(id) ON DELETE CASCADE,
|
|
80
|
+
template_id text NOT NULL,
|
|
81
|
+
current_version text NOT NULL,
|
|
82
|
+
file jsonb NOT NULL,
|
|
83
|
+
scope_mode text NOT NULL DEFAULT 'follow' CHECK (scope_mode IN ('follow', 'own')),
|
|
84
|
+
scope text NOT NULL DEFAULT 'optional' CHECK (scope IN ('all', 'optional', 'named')),
|
|
85
|
+
disabled boolean NOT NULL DEFAULT false,
|
|
86
|
+
shown_to_others boolean NOT NULL DEFAULT true,
|
|
87
|
+
scope_version integer NOT NULL DEFAULT 0,
|
|
88
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
89
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
90
|
+
deleted_at timestamptz
|
|
91
|
+
);
|
|
92
|
+
CREATE UNIQUE INDEX IF NOT EXISTS platform_connector_templates_live_uq
|
|
93
|
+
ON platform_connector_templates (catalog_item_id, template_id)
|
|
94
|
+
WHERE deleted_at IS NULL;
|
|
95
|
+
|
|
96
|
+
-- Scope of an own-scope component: the orgs it is offered to (named) and each org's switch.
|
|
97
|
+
CREATE TABLE IF NOT EXISTS component_scope_orgs (
|
|
98
|
+
kind text NOT NULL CHECK (kind IN ('skill', 'agent_template', 'connector_template')),
|
|
99
|
+
component_id text NOT NULL,
|
|
100
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
101
|
+
PRIMARY KEY (kind, component_id, org_id)
|
|
102
|
+
);
|
|
103
|
+
CREATE TABLE IF NOT EXISTS component_org_switches (
|
|
104
|
+
kind text NOT NULL CHECK (kind IN ('skill', 'agent_template', 'connector_template')),
|
|
105
|
+
component_id text NOT NULL,
|
|
106
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
107
|
+
enabled boolean NOT NULL,
|
|
108
|
+
updated_by text REFERENCES accounts(id) ON DELETE SET NULL,
|
|
109
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
110
|
+
PRIMARY KEY (kind, component_id, org_id)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
-- Links from the org copies (ruling B2): a pin keeps the copy on its own stored version.
|
|
114
|
+
ALTER TABLE skills ADD COLUMN IF NOT EXISTS platform_skill_id text
|
|
115
|
+
REFERENCES platform_skills(id) ON DELETE SET NULL;
|
|
116
|
+
ALTER TABLE skills ADD COLUMN IF NOT EXISTS pinned_version integer;
|
|
117
|
+
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS platform_template_id text
|
|
118
|
+
REFERENCES platform_agent_templates(id) ON DELETE SET NULL;
|
|
119
|
+
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS pinned_version integer;
|
|
120
|
+
ALTER TABLE connectors ADD COLUMN IF NOT EXISTS platform_template_id text
|
|
121
|
+
REFERENCES platform_connector_templates(id) ON DELETE SET NULL;
|
|
122
|
+
|
|
123
|
+
-- A template without a plugin is the bare `<name>`; the live-name index must still hold for NULLs.
|
|
124
|
+
ALTER TABLE agent_templates ALTER COLUMN plugin_name DROP NOT NULL;
|
|
125
|
+
-- capybara:allow-destructive the index is recreated in the same transaction over coalesce(plugin_name, '') so NULL plugin names stay unique; no data change
|
|
126
|
+
DROP INDEX IF EXISTS agent_templates_live_name_uq;
|
|
127
|
+
CREATE UNIQUE INDEX IF NOT EXISTS agent_templates_live_name_uq
|
|
128
|
+
ON agent_templates (org_id, (coalesce(plugin_name, '')), name)
|
|
129
|
+
WHERE deleted_at IS NULL;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
-- Plugin scope phase 2, Task 5: the migration of org copies to platform components
|
|
2
|
+
-- (`catalog/platform-migration.ts`, the worker job `platform-components-migrate`), and the org
|
|
3
|
+
-- notices it writes for the org admins' inbox.
|
|
4
|
+
|
|
5
|
+
-- The catalog version the item's platform components were last written from
|
|
6
|
+
-- (`PlatformComponents.syncFromVersion`); null = never: the migration job writes them once. Removed
|
|
7
|
+
-- components are not brought back, since an item with a version here is never synced by the job.
|
|
8
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS platform_synced_version text;
|
|
9
|
+
|
|
10
|
+
-- One row per run of the job (at every worker start and once a day): when it ran and what it
|
|
11
|
+
-- changed; rows older than 30 days are pruned, except the first finished run, whose start is the
|
|
12
|
+
-- cutoff of the one-shot rename step (only org skills whose current version predates it).
|
|
13
|
+
CREATE TABLE IF NOT EXISTS platform_migration_runs (
|
|
14
|
+
id uuid PRIMARY KEY,
|
|
15
|
+
started_at timestamptz NOT NULL DEFAULT now(),
|
|
16
|
+
finished_at timestamptz,
|
|
17
|
+
stats jsonb NOT NULL DEFAULT '{}'::jsonb
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- A notice for an org's admins (inbox item kind = `kind`), until one of them dismisses it.
|
|
21
|
+
-- `skill_renamed`: detail `{ skillId, from, to, platformSkillId, plugin }`.
|
|
22
|
+
CREATE TABLE IF NOT EXISTS org_notices (
|
|
23
|
+
id uuid PRIMARY KEY,
|
|
24
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
25
|
+
kind text NOT NULL CHECK (kind IN ('skill_renamed')),
|
|
26
|
+
detail jsonb NOT NULL,
|
|
27
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
28
|
+
dismissed_at timestamptz,
|
|
29
|
+
dismissed_by text REFERENCES accounts(id) ON DELETE SET NULL
|
|
30
|
+
);
|
|
31
|
+
CREATE INDEX IF NOT EXISTS org_notices_open_idx
|
|
32
|
+
ON org_notices (org_id, created_at DESC)
|
|
33
|
+
WHERE dismissed_at IS NULL;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Plugin scope phase 2, Task 11: the plugin scope sync's open failures, for the super admin's
|
|
2
|
+
-- inbox (`catalog/scope-sync.ts` writes them, `inbox/platform-inbox.service.ts` reads them). One
|
|
3
|
+
-- row per (item, org) whose last sync attempt failed; the next sync of that pair that does not
|
|
4
|
+
-- fail deletes it. The audit event `plugin.scope_sync_failed` stays the history. `op`: `install`
|
|
5
|
+
-- (turning it on), `uninstall` (turning it off), `dependencies` (installing the dependencies a
|
|
6
|
+
-- platform update added to a live install).
|
|
7
|
+
CREATE TABLE IF NOT EXISTS plugin_scope_sync_failures (
|
|
8
|
+
item_id uuid NOT NULL REFERENCES catalog_items(id) ON DELETE CASCADE,
|
|
9
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
10
|
+
op text NOT NULL CHECK (op IN ('install', 'uninstall', 'dependencies')),
|
|
11
|
+
code text NOT NULL,
|
|
12
|
+
message text NOT NULL,
|
|
13
|
+
failed_at timestamptz NOT NULL DEFAULT now(),
|
|
14
|
+
PRIMARY KEY (item_id, org_id)
|
|
15
|
+
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
-- Org-owned items, sharing, pending uploads and notices (phase 3, plan
|
|
2
|
+
-- 2026-11-06-plugin-scope-phase-3.md Task 1; rulings P3-3, P3-5, P3-6, P3-8, F27). Expand-only:
|
|
3
|
+
-- every column is nullable or defaulted, and existing rows stay platform-owned (owner_org_id NULL)
|
|
4
|
+
-- and not shareable. The only dropped objects are the old live-name indexes and the old notice
|
|
5
|
+
-- kind check, replaced in the same file.
|
|
6
|
+
|
|
7
|
+
-- Owners and pending uploads of catalog items. `owner_org_id` NULL = the platform; an org's
|
|
8
|
+
-- upload that carries an extension waits for the super admin (`awaiting_confirmation`), with the
|
|
9
|
+
-- uploaded version in `pending_*` until confirmed (P3-9 to P3-13).
|
|
10
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS owner_org_id text
|
|
11
|
+
REFERENCES orgs(id) ON DELETE SET NULL;
|
|
12
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
13
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS awaiting_confirmation boolean NOT NULL DEFAULT false;
|
|
14
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS pending_version text;
|
|
15
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS pending_by text
|
|
16
|
+
REFERENCES accounts(id) ON DELETE SET NULL;
|
|
17
|
+
ALTER TABLE catalog_items ADD COLUMN IF NOT EXISTS pending_at timestamptz;
|
|
18
|
+
CREATE INDEX IF NOT EXISTS catalog_items_owner_idx
|
|
19
|
+
ON catalog_items (owner_org_id)
|
|
20
|
+
WHERE owner_org_id IS NOT NULL AND deleted_at IS NULL;
|
|
21
|
+
|
|
22
|
+
-- Whether a version may be used (ruling P3-52): `applied_at` is set when it was applied or
|
|
23
|
+
-- confirmed (a platform import is applied as it is written: the default; an org's upload writes
|
|
24
|
+
-- NULL until its owner applies it or the super admin confirms it), `rejected_at` when the super
|
|
25
|
+
-- admin rejected it. Readers serving other orgs or the generic update use only applied, not
|
|
26
|
+
-- rejected versions, whoever owns the item (a transfer keeps the version rows). Existing rows
|
|
27
|
+
-- are platform imports: applied.
|
|
28
|
+
ALTER TABLE catalog_item_versions ADD COLUMN IF NOT EXISTS applied_at timestamptz DEFAULT now();
|
|
29
|
+
ALTER TABLE catalog_item_versions ADD COLUMN IF NOT EXISTS rejected_at timestamptz;
|
|
30
|
+
|
|
31
|
+
-- Platform components: the owning org (NULL = platform), the org they were created in
|
|
32
|
+
-- (`origin_org_id`, no FK, immutable; F27) and the share switch (P3-3, P3-5).
|
|
33
|
+
ALTER TABLE platform_skills ADD COLUMN IF NOT EXISTS owner_org_id text
|
|
34
|
+
REFERENCES orgs(id) ON DELETE SET NULL;
|
|
35
|
+
ALTER TABLE platform_skills ADD COLUMN IF NOT EXISTS origin_org_id text;
|
|
36
|
+
ALTER TABLE platform_skills ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
37
|
+
ALTER TABLE platform_agent_templates ADD COLUMN IF NOT EXISTS owner_org_id text
|
|
38
|
+
REFERENCES orgs(id) ON DELETE SET NULL;
|
|
39
|
+
ALTER TABLE platform_agent_templates ADD COLUMN IF NOT EXISTS origin_org_id text;
|
|
40
|
+
ALTER TABLE platform_agent_templates ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
41
|
+
ALTER TABLE platform_connector_templates ADD COLUMN IF NOT EXISTS owner_org_id text
|
|
42
|
+
REFERENCES orgs(id) ON DELETE SET NULL;
|
|
43
|
+
ALTER TABLE platform_connector_templates ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
44
|
+
|
|
45
|
+
-- Live names are unique per origin org (P3-5); the new indexes come first, then the old ones go
|
|
46
|
+
-- (F27: new names, so a re-run is a true no-op).
|
|
47
|
+
CREATE UNIQUE INDEX IF NOT EXISTS platform_skills_live_name_origin_uq
|
|
48
|
+
ON platform_skills ((coalesce(plugin_name, '')), name, (coalesce(origin_org_id, '')))
|
|
49
|
+
WHERE deleted_at IS NULL;
|
|
50
|
+
CREATE UNIQUE INDEX IF NOT EXISTS platform_agent_templates_live_name_origin_uq
|
|
51
|
+
ON platform_agent_templates ((coalesce(plugin_name, '')), name, (coalesce(origin_org_id, '')))
|
|
52
|
+
WHERE deleted_at IS NULL;
|
|
53
|
+
-- capybara:allow-destructive replaced by platform_skills_live_name_origin_uq created above in this file; no data change
|
|
54
|
+
DROP INDEX IF EXISTS platform_skills_live_name_uq;
|
|
55
|
+
-- capybara:allow-destructive replaced by platform_agent_templates_live_name_origin_uq created above in this file; no data change
|
|
56
|
+
DROP INDEX IF EXISTS platform_agent_templates_live_name_uq;
|
|
57
|
+
|
|
58
|
+
-- Org copies: whether the owner shares the copy with other orgs (P3-3, P3-6).
|
|
59
|
+
ALTER TABLE skills ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
60
|
+
ALTER TABLE agent_templates ADD COLUMN IF NOT EXISTS shareable boolean NOT NULL DEFAULT false;
|
|
61
|
+
|
|
62
|
+
-- An org's upload waits in staging under its org (P3-8); deleting the org drops the staging.
|
|
63
|
+
ALTER TABLE plugin_import_staging ADD COLUMN IF NOT EXISTS org_id text
|
|
64
|
+
REFERENCES orgs(id) ON DELETE CASCADE;
|
|
65
|
+
|
|
66
|
+
-- New org notice kinds. 0082 declared the CHECK inline, so it is named org_notices_kind_check.
|
|
67
|
+
-- capybara:allow-destructive the check is added back with the wider kind list in the next statement; existing rows (skill_renamed) satisfy it
|
|
68
|
+
ALTER TABLE org_notices DROP CONSTRAINT IF EXISTS org_notices_kind_check;
|
|
69
|
+
ALTER TABLE org_notices ADD CONSTRAINT org_notices_kind_check
|
|
70
|
+
CHECK (kind IN ('skill_renamed', 'item_shared', 'shared_item_updated',
|
|
71
|
+
'upload_confirmed', 'upload_rejected'));
|
|
72
|
+
|
|
73
|
+
-- A notice for the super admins (platform inbox), until one of them dismisses it.
|
|
74
|
+
-- `ownership_transferred`: a deleted org's shared item now belongs to the platform.
|
|
75
|
+
CREATE TABLE IF NOT EXISTS platform_notices (
|
|
76
|
+
id uuid PRIMARY KEY,
|
|
77
|
+
kind text NOT NULL CHECK (kind IN ('ownership_transferred')),
|
|
78
|
+
detail jsonb NOT NULL,
|
|
79
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
80
|
+
dismissed_at timestamptz,
|
|
81
|
+
dismissed_by text REFERENCES accounts(id) ON DELETE SET NULL
|
|
82
|
+
);
|
|
83
|
+
CREATE INDEX IF NOT EXISTS platform_notices_open_idx
|
|
84
|
+
ON platform_notices (created_at DESC)
|
|
85
|
+
WHERE dismissed_at IS NULL;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
-- Agent templates, phase 4 (spec 2026-11-05-plugin-component-management-design.md §15.2: P4-7
|
|
2
|
+
-- connector_setup requests, P4-8 provenance). Expand-only: every new column is nullable, existing
|
|
3
|
+
-- rows keep their shape, and the only dropped objects are two checks replaced in this file.
|
|
4
|
+
|
|
5
|
+
-- P4-8: where an agent came from. Display data only (no FK: the template may be deleted or
|
|
6
|
+
-- renamed later), written when an agent is created from a template.
|
|
7
|
+
ALTER TABLE agents ADD COLUMN IF NOT EXISTS created_from_template_id text;
|
|
8
|
+
ALTER TABLE agents ADD COLUMN IF NOT EXISTS created_from_template_version int;
|
|
9
|
+
ALTER TABLE agents ADD COLUMN IF NOT EXISTS created_from_template_name text;
|
|
10
|
+
|
|
11
|
+
-- P4-7: a `connector_setup` request asks an org admin to set up the connectors an agent made from a
|
|
12
|
+
-- template needs (`pending_keys`: the template's connector keys still without an instance). It
|
|
13
|
+
-- names its agent and no item or marketplace entry.
|
|
14
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS agent_id text
|
|
15
|
+
REFERENCES agents(id) ON DELETE CASCADE;
|
|
16
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS pending_keys jsonb;
|
|
17
|
+
|
|
18
|
+
-- capybara:allow-destructive the check is added back with `connector_setup` in the next statement; existing rows (access, import, enable) satisfy it
|
|
19
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_kind_check;
|
|
20
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_kind_check
|
|
21
|
+
CHECK (kind IN ('access', 'import', 'enable', 'connector_setup'));
|
|
22
|
+
|
|
23
|
+
-- item_id is already nullable (0077). The target check of 0077 required an item for every kind but
|
|
24
|
+
-- `import`; a connector_setup row needs an agent instead.
|
|
25
|
+
-- capybara:allow-destructive the check is added back with the connector_setup branch in the next statement; existing rows satisfy its first and third branches
|
|
26
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_target_check;
|
|
27
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_target_check
|
|
28
|
+
CHECK (
|
|
29
|
+
kind = 'import' AND entry_name IS NOT NULL
|
|
30
|
+
OR kind = 'connector_setup' AND agent_id IS NOT NULL
|
|
31
|
+
AND item_id IS NULL AND entry_name IS NULL
|
|
32
|
+
OR kind NOT IN ('import', 'connector_setup') AND item_id IS NOT NULL
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
-- `pending_keys` is a JSON array of keys when set.
|
|
36
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_pending_keys_check;
|
|
37
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_pending_keys_check
|
|
38
|
+
CHECK (pending_keys IS NULL OR jsonb_typeof(pending_keys) = 'array');
|
|
39
|
+
|
|
40
|
+
-- At most one pending setup request per agent (P4-7).
|
|
41
|
+
CREATE UNIQUE INDEX IF NOT EXISTS catalog_requests_pending_setup_uq
|
|
42
|
+
ON catalog_requests (agent_id) WHERE kind = 'connector_setup' AND status = 'pending';
|
|
43
|
+
|
|
44
|
+
CREATE INDEX IF NOT EXISTS catalog_requests_agent_idx
|
|
45
|
+
ON catalog_requests (agent_id) WHERE agent_id IS NOT NULL;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- Platform / org layering (spec 2026-11-07-platform-org-layering-design.md). Expand-only: two new
|
|
2
|
+
-- tables, nothing existing changes.
|
|
3
|
+
|
|
4
|
+
-- 0086, spec §5.4 / §5.8: an org's copy of an extension's overridable deployment config fields. A
|
|
5
|
+
-- row is a copy; no row means the org follows the platform ("no copy" and "a copy equal to the
|
|
6
|
+
-- platform" stay distinct). `config` holds the copy's non-secret values; its secrets live in
|
|
7
|
+
-- `secrets` under the org (namespace `kernel`, key `plugin-override:<plugin>:<path>`). Rows are kept
|
|
8
|
+
-- when the extension is disabled or uninstalled, like `extension_org_configs`.
|
|
9
|
+
CREATE TABLE IF NOT EXISTS extension_org_overrides (
|
|
10
|
+
plugin text NOT NULL,
|
|
11
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
12
|
+
config jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
13
|
+
created_by text REFERENCES accounts(id) ON DELETE SET NULL,
|
|
14
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
15
|
+
updated_by text REFERENCES accounts(id) ON DELETE SET NULL,
|
|
16
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
17
|
+
PRIMARY KEY (plugin, org_id)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- 0086, spec §7: an org admin's switch of one tool of an extension that is on in the org. No row
|
|
21
|
+
-- means the tool follows the extension (on).
|
|
22
|
+
CREATE TABLE IF NOT EXISTS org_tool_switches (
|
|
23
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
24
|
+
plugin text NOT NULL,
|
|
25
|
+
tool text NOT NULL,
|
|
26
|
+
enabled boolean NOT NULL,
|
|
27
|
+
updated_by text REFERENCES accounts(id) ON DELETE SET NULL,
|
|
28
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
29
|
+
PRIMARY KEY (org_id, plugin, tool)
|
|
30
|
+
);
|