@capybara-hq/kernel 0.1.0-rc.3 → 0.1.0-rc.5
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 +47 -16
- package/dist/admin/admin.controller.js +44 -19
- package/dist/admin/extensions.controller.d.ts +24 -3
- package/dist/admin/extensions.controller.js +48 -8
- 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 +19 -0
- package/dist/agents/agent-lookup.js +21 -0
- package/dist/agents/agent-profile.service.d.ts +29 -0
- package/dist/agents/agent-profile.service.js +117 -0
- package/dist/agents/agents.controller.d.ts +168 -3
- package/dist/agents/agents.controller.js +201 -12
- package/dist/agents/agents.module.d.ts +4 -1
- package/dist/agents/agents.module.js +36 -6
- package/dist/agents/agents.service.d.ts +64 -27
- package/dist/agents/agents.service.js +199 -74
- package/dist/agents/definition.d.ts +53 -0
- package/dist/agents/definition.js +55 -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/instruction-files.d.ts +60 -0
- package/dist/agents/instruction-files.js +111 -0
- package/dist/agents/models.controller.d.ts +9 -3
- package/dist/agents/models.controller.js +19 -4
- 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/profile.d.ts +96 -0
- package/dist/agents/profile.js +51 -0
- package/dist/agents/readiness.controller.d.ts +26 -0
- package/dist/agents/readiness.controller.js +56 -0
- 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 +476 -53
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +87 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/finish.d.ts +44 -0
- package/dist/background/finish.js +94 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +36 -0
- package/dist/background/launch.js +70 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +190 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +48 -0
- package/dist/background/session.js +79 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +68 -0
- package/dist/background/stop.js +243 -0
- package/dist/background/store.d.ts +162 -0
- package/dist/background/store.js +357 -0
- package/dist/background/store.module.d.ts +6 -0
- package/dist/background/store.module.js +22 -0
- package/dist/background/tasks.service.d.ts +77 -0
- package/dist/background/tasks.service.js +211 -0
- package/dist/background/wake-rules.d.ts +66 -0
- package/dist/background/wake-rules.js +113 -0
- package/dist/background/wake.d.ts +30 -0
- package/dist/background/wake.js +63 -0
- 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/claude/agents.js +2 -0
- 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 +623 -83
- 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 +1148 -1137
- 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 +21 -3
- package/dist/channels/channels.module.js +2 -0
- package/dist/channels/connections.service.d.ts +16 -1
- package/dist/channels/connections.service.js +38 -4
- 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/channels/threads.d.ts +5 -0
- package/dist/channels/threads.js +8 -0
- package/dist/config/docs.js +3 -1
- package/dist/config/schema.d.ts +24 -2
- package/dist/config/schema.js +145 -19
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +29 -5
- package/dist/conversations/agent-tree.d.ts +46 -0
- package/dist/conversations/agent-tree.js +92 -0
- package/dist/conversations/attachments.service.d.ts +30 -0
- package/dist/conversations/attachments.service.js +130 -5
- package/dist/conversations/conversations.controller.d.ts +79 -23
- package/dist/conversations/conversations.controller.js +141 -50
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.service.d.ts +108 -9
- package/dist/conversations/conversations.service.js +237 -30
- package/dist/conversations/environment-status.d.ts +24 -0
- package/dist/conversations/environment-status.js +71 -0
- package/dist/conversations/event-log.d.ts +21 -6
- package/dist/conversations/event-log.js +70 -1
- package/dist/conversations/events.d.ts +140 -0
- package/dist/conversations/events.js +142 -13
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.js +13 -2
- package/dist/conversations/queue.service.d.ts +1 -1
- package/dist/conversations/queue.service.js +8 -1
- package/dist/conversations/titles.d.ts +12 -3
- package/dist/conversations/titles.js +36 -8
- package/dist/conversations/tree.d.ts +17 -0
- package/dist/conversations/tree.js +42 -0
- package/dist/ctx/create-ctx.d.ts +5 -0
- package/dist/ctx/create-ctx.js +15 -5
- package/dist/db/kernel-schema.d.ts +420 -20
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- 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 +90 -2
- package/dist/errors.js +90 -2
- package/dist/evals/reconstruct.d.ts +18 -9
- package/dist/evals/reconstruct.js +26 -7
- package/dist/evals/run-replay.d.ts +7 -2
- package/dist/evals/run-replay.js +42 -7
- package/dist/evals/step-replay.d.ts +2 -5
- package/dist/evals/step-replay.js +13 -7
- package/dist/evals/trajectory.js +1 -1
- package/dist/evals/trajectory.service.d.ts +8 -3
- package/dist/evals/trajectory.service.js +26 -14
- package/dist/evals/worker.d.ts +5 -5
- package/dist/evals/worker.js +9 -3
- package/dist/extensions/admin-ops.d.ts +36 -10
- package/dist/extensions/admin-ops.js +67 -42
- package/dist/extensions/admin-view.d.ts +39 -10
- package/dist/extensions/admin-view.js +111 -20
- package/dist/extensions/blobs.js +1 -0
- 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-issues.d.ts +13 -1
- package/dist/extensions/config-issues.js +22 -5
- package/dist/extensions/config-json-schema.d.ts +43 -7
- package/dist/extensions/config-json-schema.js +124 -58
- package/dist/extensions/deployment-config-store.d.ts +6 -0
- package/dist/extensions/deployment-config.d.ts +78 -8
- package/dist/extensions/deployment-config.js +172 -34
- package/dist/extensions/display-name.d.ts +22 -0
- package/dist/extensions/display-name.js +77 -0
- package/dist/extensions/effective-config.d.ts +127 -0
- package/dist/extensions/effective-config.js +368 -0
- package/dist/extensions/extensions.module.js +14 -2
- package/dist/extensions/hooks.d.ts +37 -4
- package/dist/extensions/hooks.js +82 -16
- package/dist/extensions/host.d.ts +45 -2
- package/dist/extensions/host.js +112 -16
- package/dist/extensions/installs.d.ts +20 -8
- package/dist/extensions/installs.js +37 -15
- package/dist/extensions/org-config.d.ts +81 -6
- package/dist/extensions/org-config.js +195 -44
- package/dist/extensions/org-levels.d.ts +37 -0
- package/dist/extensions/org-levels.js +71 -0
- package/dist/extensions/org-overrides.d.ts +151 -0
- package/dist/extensions/org-overrides.js +524 -0
- package/dist/extensions/package.d.ts +14 -1
- package/dist/extensions/package.js +51 -2
- package/dist/extensions/permission-view.d.ts +19 -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.controller.d.ts +34 -0
- package/dist/extensions/point-defaults.controller.js +71 -0
- package/dist/extensions/point-defaults.d.ts +71 -0
- package/dist/extensions/point-defaults.js +234 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +5 -1
- package/dist/extensions/resolve.js +15 -2
- package/dist/files/previewers.d.ts +8 -1
- package/dist/files/previewers.js +35 -6
- package/dist/http/api.module.js +31 -3
- package/dist/http/app.d.ts +11 -2
- package/dist/http/app.js +31 -5
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- 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.controller.js +9 -5
- package/dist/identity/auth.guard.d.ts +13 -5
- package/dist/identity/auth.guard.js +26 -9
- package/dist/identity/cookies.d.ts +20 -5
- package/dist/identity/cookies.js +44 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -4
- package/dist/identity/me.controller.d.ts +5 -1
- package/dist/identity/me.controller.js +12 -3
- package/dist/identity/principal.d.ts +3 -3
- package/dist/identity/principal.js +3 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- 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 +2 -2
- package/dist/index.js +1 -1
- package/dist/infra/cli/kernel-cli.module.js +9 -1
- package/dist/infra/config/kernel-config.service.js +27 -1
- package/dist/infra/database/database.module.js +1 -0
- 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/lifecycle/process-guards.js +4 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/queue/add-job-once.d.ts +14 -0
- package/dist/infra/queue/add-job-once.js +16 -0
- package/dist/infra/queue/redis-connection.d.ts +6 -0
- package/dist/infra/queue/redis-connection.js +7 -0
- package/dist/infra/redis/redis.module.js +6 -2
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- 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/log.d.ts +13 -1
- package/dist/log.js +93 -17
- 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 +43 -9
- package/dist/models/purposes.js +48 -18
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +41 -17
- package/dist/orgs/offboarding.d.ts +12 -8
- package/dist/orgs/offboarding.js +54 -33
- 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 +20 -3
- package/dist/orgs/settings.service.js +19 -4
- 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 +1387 -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 +15 -1
- package/dist/runtime/context/build.d.ts +11 -7
- package/dist/runtime/context/build.js +46 -19
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +8 -6
- package/dist/runtime/context/compaction.js +13 -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.js +2 -0
- package/dist/runtime/langgraph-loop.d.ts +3 -1
- package/dist/runtime/langgraph-loop.js +36 -17
- package/dist/runtime/loop.d.ts +34 -5
- package/dist/runtime/maintenance.d.ts +9 -4
- package/dist/runtime/maintenance.js +35 -8
- package/dist/runtime/model-call.d.ts +46 -8
- package/dist/runtime/model-call.js +72 -21
- package/dist/runtime/providers.d.ts +6 -0
- package/dist/runtime/providers.js +8 -0
- 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 +59 -2
- package/dist/runtime/run-queue.js +311 -38
- package/dist/runtime/run-worker.d.ts +11 -5
- package/dist/runtime/run-worker.js +69 -33
- package/dist/runtime/runtime.module.js +11 -3
- package/dist/runtime/step-log.d.ts +15 -4
- package/dist/runtime/step-log.js +24 -7
- 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 +44 -28
- 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.d.ts +2 -1
- package/dist/runtime/usage-report.js +19 -13
- package/dist/runtime/waits.d.ts +145 -36
- package/dist/runtime/waits.js +423 -109
- 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 +10 -4
- package/dist/sandbox/sandbox.service.d.ts +282 -129
- package/dist/sandbox/sandbox.service.js +736 -381
- 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 +25 -4
- package/dist/tools/builtin-names.d.ts +41 -7
- package/dist/tools/builtin-names.js +59 -7
- 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 +19 -1
- package/dist/tools/builtins/builtin-tools.js +59 -2
- 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.d.ts +1 -1
- package/dist/tools/builtins/sandbox/bash.js +241 -4
- package/dist/tools/builtins/sandbox/common.d.ts +69 -27
- package/dist/tools/builtins/sandbox/common.js +87 -48
- package/dist/tools/builtins/sandbox/deliver.js +1 -1
- 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 +3 -1
- package/dist/tools/builtins/sandbox/index.js +7 -1
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +74 -0
- package/dist/tools/builtins/sandbox/task-output.js +329 -0
- package/dist/tools/builtins/sandbox/task-stop.d.ts +10 -0
- package/dist/tools/builtins/sandbox/task-stop.js +113 -0
- 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/errors.d.ts +8 -0
- package/dist/tools/builtins/web/errors.js +53 -0
- package/dist/tools/builtins/web/extract.d.ts +62 -0
- package/dist/tools/builtins/web/extract.js +271 -0
- package/dist/tools/builtins/web/fetch.d.ts +55 -0
- package/dist/tools/builtins/web/fetch.js +175 -0
- package/dist/tools/builtins/web/index.d.ts +13 -0
- package/dist/tools/builtins/web/index.js +12 -0
- package/dist/tools/builtins/web/page-cache.d.ts +25 -0
- package/dist/tools/builtins/web/page-cache.js +77 -0
- package/dist/tools/builtins/web/search.d.ts +25 -0
- package/dist/tools/builtins/web/search.js +210 -0
- package/dist/tools/builtins/web/url.d.ts +17 -0
- package/dist/tools/builtins/web/url.js +43 -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/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -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 +202 -364
- package/dist/tools/policy.d.ts +1 -1
- package/dist/tools/policy.js +36 -16
- package/dist/tools/registry.d.ts +120 -8
- package/dist/tools/registry.js +112 -19
- package/dist/tools/tools.module.js +24 -2
- package/dist/tools/validate.js +1 -1
- package/dist/ui/views.d.ts +2 -1
- package/dist/ui/views.js +17 -3
- package/package.json +3 -3
- package/src/migrations/0064_account_last_org.sql +7 -0
- package/src/migrations/0065_conversation_archive.sql +8 -0
- package/src/migrations/0066_extension_display_name.sql +4 -0
- package/src/migrations/0067_agent_profiles.sql +20 -0
- package/src/migrations/0068_agent_avatar_uploads.sql +7 -0
- package/src/migrations/0069_attachments_agent_idx.sql +3 -0
- package/src/migrations/0070_background_tasks.sql +37 -0
- package/src/migrations/0071_background_tasks_reserve.sql +6 -0
- package/src/migrations/0072_background_tasks_stopping.sql +5 -0
- package/src/migrations/0073_org_extension_point_defaults.sql +11 -0
- 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/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 -24
- package/dist/extensions/org-config.controller.js +0 -62
|
@@ -18,45 +18,43 @@ import { OrgLock } from "../orgs/org-lock.js";
|
|
|
18
18
|
import { can, roleAtLeast } from "../orgs/roles.js";
|
|
19
19
|
import { packagePath } from "../packages/tgz.js";
|
|
20
20
|
import { StorageService } from "../storage/storage.service.js";
|
|
21
|
-
import { catalogHasIcon, findConnectorIn,
|
|
22
|
-
import { itemView } from "./catalog-items.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
21
|
+
import { catalogHasIcon, findConnectorIn, orgTemplateView, readCatalogIcon, readCatalogTemplates, templatePluginProblem, } from "./catalog-content.js";
|
|
22
|
+
import { itemView, ownerOnlyFacts, versionUsable } from "./catalog-items.js";
|
|
23
|
+
import { connectorTemplatesOn, templateIdOfPath } from "./component-state.js";
|
|
24
|
+
import { itemPendingError, ownerOf, ownersOf } from "./ownership.js";
|
|
25
|
+
import { PluginInstaller, uninstallPreviewHash, upsertOrgSwitch, } from "./plugin-install.js";
|
|
26
|
+
import { requestable, switchable, visibleTo, wantedOn } from "./scope.js";
|
|
27
27
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
28
28
|
const itemNotFound = () => new ApiError("catalog.item_not_found", "Catalog item not found");
|
|
29
|
-
const
|
|
29
|
+
const notOffered = () => new ApiError("catalog.approval_required", "This plugin is not offered to this organization; an org admin can request access");
|
|
30
|
+
const pluginDisabled = () => new ApiError("plugin.disabled", "This plugin is disabled by the super admin and cannot be switched on");
|
|
30
31
|
/**
|
|
31
|
-
* Organizations
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* Organizations see the platform catalog with the plugin scope rules applied (plugin and component
|
|
33
|
+
* management spec §5): a plugin is `all` (on in every org unless an org admin switched it off,
|
|
34
|
+
* layering spec §4), `optional` (an org admin switches it on), or `named` (offered to the listed
|
|
35
|
+
* orgs). Members get the list read-only; org admins switch a plugin on (an install by
|
|
36
|
+
* {@link PluginInstaller}, with its dependencies; the union of the component actions of the plugins
|
|
37
|
+
* it brings in is re-checked inside the org row lock) or off (an uninstall, after a preview they
|
|
38
|
+
* confirm with its hash). Disabled item -> `plugin.disabled`; a
|
|
39
|
+
* dependency unresolved / disabled / in a cycle -> `catalog.dependency_*`; an extension or a
|
|
40
|
+
* template's connector not on the deployment -> `catalog.not_deployed`. No in-process state.
|
|
39
41
|
*/
|
|
40
42
|
let OrgCatalogService = class OrgCatalogService {
|
|
41
43
|
kdb;
|
|
42
44
|
orgLock;
|
|
43
45
|
storage;
|
|
44
46
|
registry;
|
|
45
|
-
requests;
|
|
46
47
|
pluginInstaller;
|
|
47
|
-
pluginUpgrader;
|
|
48
48
|
log;
|
|
49
49
|
txHost;
|
|
50
50
|
constructor(kdb,
|
|
51
51
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
52
|
-
orgLock, storage, registry,
|
|
52
|
+
orgLock, storage, registry, pluginInstaller, log, txHost) {
|
|
53
53
|
this.kdb = kdb;
|
|
54
54
|
this.orgLock = orgLock;
|
|
55
55
|
this.storage = storage;
|
|
56
56
|
this.registry = registry;
|
|
57
|
-
this.requests = requests;
|
|
58
57
|
this.pluginInstaller = pluginInstaller;
|
|
59
|
-
this.pluginUpgrader = pluginUpgrader;
|
|
60
58
|
this.log = log;
|
|
61
59
|
this.txHost = txHost;
|
|
62
60
|
}
|
|
@@ -64,7 +62,11 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
64
62
|
get db() {
|
|
65
63
|
return this.kdb.db;
|
|
66
64
|
}
|
|
67
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The org's view of the items: a `named` item without the org on its list is `not_offered` when
|
|
67
|
+
* shown to other orgs and absent otherwise; disabled ones are shown to admins as `unavailable`
|
|
68
|
+
* and absent for members. Each item carries the org's pending request for it.
|
|
69
|
+
*/
|
|
68
70
|
async list(orgId, accountId, itemId) {
|
|
69
71
|
const m = await this.db
|
|
70
72
|
.selectFrom("memberships")
|
|
@@ -82,67 +84,141 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
82
84
|
if (itemId !== undefined)
|
|
83
85
|
q = q.where("id", "=", itemId);
|
|
84
86
|
if (!isAdmin)
|
|
85
|
-
q = q.where("
|
|
86
|
-
const
|
|
87
|
+
q = q.where("disabled", "=", false);
|
|
88
|
+
const all = await q.execute();
|
|
89
|
+
const [listed, switches] = await Promise.all([
|
|
90
|
+
this.db
|
|
91
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
92
|
+
.select("item_id")
|
|
93
|
+
.where("org_id", "=", orgId)
|
|
94
|
+
.execute(),
|
|
95
|
+
this.db
|
|
96
|
+
.selectFrom("catalog_item_org_switches")
|
|
97
|
+
.select(["item_id", "enabled"])
|
|
98
|
+
.where("org_id", "=", orgId)
|
|
99
|
+
.execute(),
|
|
100
|
+
]);
|
|
101
|
+
const inList = new Set(listed.map((r) => r.item_id));
|
|
102
|
+
// Hidden `named` items (not listed, not shown to other orgs) are absent; shown ones are
|
|
103
|
+
// `not_offered`
|
|
104
|
+
// An org upload waiting for the super admin is its owner's only (ruling P3-9)
|
|
105
|
+
const items = all.filter((i) => (!i.awaiting_confirmation || i.owner_org_id === orgId) &&
|
|
106
|
+
(visibleTo({ scope: i.builtin ? "all" : i.scope }, inList.has(i.id)) ||
|
|
107
|
+
requestable(i, inList.has(i.id))));
|
|
87
108
|
if (items.length === 0)
|
|
88
109
|
return [];
|
|
110
|
+
const sw = new Map(switches.map((r) => [r.item_id, r.enabled]));
|
|
89
111
|
const ids = items.map((i) => i.id);
|
|
90
|
-
const [versions,
|
|
112
|
+
const [versions, pluginInstalls, configs, requests] = await Promise.all([
|
|
91
113
|
this.db
|
|
92
114
|
.selectFrom("catalog_item_versions")
|
|
93
|
-
.select([
|
|
115
|
+
.select([
|
|
116
|
+
"item_id",
|
|
117
|
+
"version",
|
|
118
|
+
"source",
|
|
119
|
+
"source_format",
|
|
120
|
+
"manifest",
|
|
121
|
+
"object_prefix",
|
|
122
|
+
"files",
|
|
123
|
+
"applied_at",
|
|
124
|
+
"rejected_at",
|
|
125
|
+
])
|
|
94
126
|
.where("item_id", "in", ids)
|
|
95
127
|
.execute(),
|
|
96
|
-
this.db
|
|
97
|
-
.selectFrom("catalog_org_grants")
|
|
98
|
-
.select("item_id")
|
|
99
|
-
.where("org_id", "=", orgId)
|
|
100
|
-
.execute(),
|
|
101
|
-
this.requests.latestByItem(orgId),
|
|
102
128
|
this.db
|
|
103
129
|
.selectFrom("plugin_installs")
|
|
104
130
|
.select(["id", "item_id", "version"])
|
|
105
131
|
.where("org_id", "=", orgId)
|
|
106
132
|
.where("status", "in", ["installing", "installed", "upgrading"])
|
|
107
133
|
.execute(),
|
|
134
|
+
this.db
|
|
135
|
+
.selectFrom("extension_org_configs")
|
|
136
|
+
.select("plugin")
|
|
137
|
+
.where("org_id", "=", orgId)
|
|
138
|
+
.where("config", "is not", null)
|
|
139
|
+
.execute(),
|
|
140
|
+
this.db
|
|
141
|
+
.selectFrom("catalog_requests")
|
|
142
|
+
.select(["id", "item_id", "kind", "created_at"])
|
|
143
|
+
.where("org_id", "=", orgId)
|
|
144
|
+
.where("item_id", "in", ids)
|
|
145
|
+
.where("kind", "in", ["access", "enable"])
|
|
146
|
+
.where("status", "=", "pending")
|
|
147
|
+
.orderBy("created_at")
|
|
148
|
+
.execute(),
|
|
108
149
|
]);
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const granted = new Set(grants.map((g) => g.item_id));
|
|
150
|
+
const pending = new Map(requests.map((r) => [
|
|
151
|
+
r.item_id,
|
|
152
|
+
{ id: r.id, kind: r.kind, createdAt: r.created_at.toISOString() },
|
|
153
|
+
]));
|
|
114
154
|
const undeployed = await this.undeployed(items.flatMap((i) => {
|
|
115
155
|
const v = versions.find((x) => x.item_id === i.id && x.version === i.latest_version);
|
|
116
156
|
return v ? [v] : [];
|
|
117
157
|
}));
|
|
158
|
+
const configured = new Set(configs.map((c) => c.plugin));
|
|
159
|
+
const owners = await ownersOf(this.db, items.flatMap((i) => (i.owner_org_id === null ? [] : [i.owner_org_id])));
|
|
160
|
+
const loaded = new Map(this.registry.manifests().map((x) => [x.name, x]));
|
|
118
161
|
const out = [];
|
|
119
162
|
for (const i of items) {
|
|
120
|
-
|
|
121
|
-
|
|
163
|
+
// Another org sees only an org-owned plugin's applied version, never one its owner
|
|
164
|
+
// uploaded that is pending or was rejected (ruling P3-34), nor such a version of a plugin
|
|
165
|
+
// transferred to the platform since (ruling P3-52)
|
|
166
|
+
const vs = versions.filter((v) => v.item_id === i.id &&
|
|
167
|
+
(i.owner_org_id === orgId ||
|
|
168
|
+
(versionUsable(v) && (i.owner_org_id === null || v.version === i.latest_version))));
|
|
169
|
+
const { installs: _installs, marketplaceId: _source, latestMarketplaceVersion: _latest, newerInMarketplace: _newer, scopeOrgs: _scopeOrgs, enabledOrgs: _enabledOrgs, offCount: _offCount, pending: _pending, shownToOthers: _shown, awaitingConfirmation, pendingVersion, ...view } = itemView(i, vs, 0, undefined, ownerOnlyFacts(ownerOf(i.owner_org_id, owners)));
|
|
122
170
|
const latest = vs.find((v) => v.version === i.latest_version);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
171
|
+
const a = pluginInstalls.find((x) => x.item_id === i.id);
|
|
172
|
+
const scope = i.builtin ? "all" : i.scope;
|
|
173
|
+
const wanted = wantedOn(i, inList.has(i.id), sw.get(i.id) ?? null);
|
|
174
|
+
let state;
|
|
175
|
+
if (i.awaiting_confirmation)
|
|
176
|
+
state = "awaiting_confirmation";
|
|
177
|
+
else if (i.disabled)
|
|
178
|
+
state = "unavailable";
|
|
179
|
+
else if (requestable(i, inList.has(i.id)))
|
|
180
|
+
state = "not_offered";
|
|
181
|
+
else if (a) {
|
|
182
|
+
// An on connector template without a connector here (ruling P2-10)
|
|
183
|
+
const missing = await this.pluginInstaller.missingConnectors(orgId, i.id);
|
|
184
|
+
state = (missing?.templates.length ?? 0) > 0 ? "needs_config" : "on";
|
|
128
185
|
}
|
|
129
|
-
else if (i.
|
|
130
|
-
|
|
186
|
+
else if (i.builtin)
|
|
187
|
+
state = "on";
|
|
188
|
+
else if (!wanted)
|
|
189
|
+
state = "off";
|
|
190
|
+
else {
|
|
191
|
+
const m = latest?.manifest;
|
|
192
|
+
const ext = m?.extension ? loaded.get(m.name) : undefined;
|
|
193
|
+
// only the connector templates on in the org need input (ruling P2-6)
|
|
194
|
+
const templateIds = (m?.connectorTemplates ?? []).map((t) => templateIdOfPath(t.path));
|
|
195
|
+
const needsInputs = (await connectorTemplatesOn(this.db, orgId, i.id, templateIds)).size > 0 ||
|
|
196
|
+
(m?.extension !== undefined &&
|
|
197
|
+
ext?.config?.org !== undefined &&
|
|
198
|
+
!ext.config.org.safeParse({}).success &&
|
|
199
|
+
!configured.has(m.name));
|
|
200
|
+
// Wanted but not installed and needing nothing: the sync has not installed it (yet, or its
|
|
201
|
+
// install failed); `off`, so an org admin can switch it on (the worker start retries it)
|
|
202
|
+
state = needsInputs ? "needs_config" : "off";
|
|
131
203
|
}
|
|
132
|
-
else
|
|
133
|
-
installable = "yes";
|
|
134
|
-
const a = pluginInstalls.find((x) => x.item_id === i.id);
|
|
135
204
|
out.push({
|
|
136
205
|
...view,
|
|
137
|
-
|
|
206
|
+
// A pending upload is the owner's business only (other orgs never learn of it)
|
|
207
|
+
...(i.owner_org_id === orgId && { awaitingConfirmation, pendingVersion }),
|
|
208
|
+
scope,
|
|
209
|
+
builtin: i.builtin,
|
|
210
|
+
state,
|
|
211
|
+
switchable: state !== "not_offered" && state !== "awaiting_confirmation" && switchable(i),
|
|
212
|
+
notDeployed: latest !== undefined && undeployed.has(i.id),
|
|
138
213
|
installed: a
|
|
139
214
|
? {
|
|
140
215
|
pluginInstallId: a.id,
|
|
141
216
|
version: a.version,
|
|
142
|
-
|
|
217
|
+
// no per-org upgrade: the platform update moves every org (ruling F2)
|
|
218
|
+
upgradeAvailable: null,
|
|
143
219
|
}
|
|
144
220
|
: null,
|
|
145
|
-
request:
|
|
221
|
+
request: pending.get(i.id) ?? null,
|
|
146
222
|
});
|
|
147
223
|
}
|
|
148
224
|
return out;
|
|
@@ -168,21 +244,59 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
168
244
|
if (!v)
|
|
169
245
|
throw itemNotFound();
|
|
170
246
|
const m = v.manifest;
|
|
247
|
+
const templates = await readCatalogTemplates(this.storage, v);
|
|
248
|
+
// Providers the install would switch on first (a refusal is the install's to report)
|
|
249
|
+
const implied = await this.pluginInstaller
|
|
250
|
+
.impliedProviders(orgId, m, templates, m.dependencies ?? [])
|
|
251
|
+
.catch((e) => {
|
|
252
|
+
if (e instanceof ApiError)
|
|
253
|
+
return [];
|
|
254
|
+
throw e;
|
|
255
|
+
});
|
|
171
256
|
return {
|
|
172
257
|
item,
|
|
173
258
|
hasIcon: m.icon !== undefined,
|
|
174
259
|
extension: m.extension ? m.name : null,
|
|
175
|
-
templates:
|
|
176
|
-
dependencies:
|
|
260
|
+
templates: templates.map((t) => orgTemplateView(t.id, t.file)),
|
|
261
|
+
dependencies: [
|
|
262
|
+
...(m.dependencies ?? []).map((d) => ({ name: d.name, range: d.version })),
|
|
263
|
+
...implied.map((d) => ({ name: d.name, range: d.range, implied: true })),
|
|
264
|
+
],
|
|
177
265
|
skills: (m.skills ?? []).map((s) => packagePath(s.path)),
|
|
178
266
|
agents: (m.agents ?? []).map((a) => packagePath(a.path)),
|
|
267
|
+
missingTemplates: item.installed !== null && item.state === "needs_config"
|
|
268
|
+
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? []).map((t) => orgTemplateView(t.id, t.file))
|
|
269
|
+
: [],
|
|
179
270
|
};
|
|
180
271
|
}
|
|
181
272
|
/**
|
|
182
|
-
* The item's icon; members don't see disabled items
|
|
183
|
-
* reading storage).
|
|
273
|
+
* The item's icon; members don't see disabled items, nobody outside its list sees a hidden
|
|
274
|
+
* `named` item (-> `catalog.item_not_found`, decided before reading storage). Without `orgId`
|
|
275
|
+
* (the super admin) every item.
|
|
184
276
|
*/
|
|
185
|
-
icon(itemId, isAdmin) {
|
|
277
|
+
async icon(itemId, isAdmin, orgId) {
|
|
278
|
+
if (orgId === undefined)
|
|
279
|
+
return readCatalogIcon(this.db, this.storage, itemId, isAdmin);
|
|
280
|
+
if (!UUID_RE.test(itemId))
|
|
281
|
+
throw itemNotFound();
|
|
282
|
+
// A hidden `named` item stays absent here too
|
|
283
|
+
const item = await this.db
|
|
284
|
+
.selectFrom("catalog_items")
|
|
285
|
+
.select(["scope", "builtin", "shown_to_others", "owner_org_id", "shareable"])
|
|
286
|
+
.where("id", "=", itemId)
|
|
287
|
+
.where("deleted_at", "is", null)
|
|
288
|
+
.executeTakeFirst();
|
|
289
|
+
// Not requestable from outside its list (hidden, or held back by the share gate): only listed orgs
|
|
290
|
+
if (item && !item.builtin && item.scope === "named" && !requestable(item, false)) {
|
|
291
|
+
const listed = await this.db
|
|
292
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
293
|
+
.select("item_id")
|
|
294
|
+
.where("item_id", "=", itemId)
|
|
295
|
+
.where("org_id", "=", orgId)
|
|
296
|
+
.executeTakeFirst();
|
|
297
|
+
if (listed === undefined)
|
|
298
|
+
throw itemNotFound();
|
|
299
|
+
}
|
|
186
300
|
return readCatalogIcon(this.db, this.storage, itemId, isAdmin);
|
|
187
301
|
}
|
|
188
302
|
/** For the admin item detail: whether the latest version has an icon. */
|
|
@@ -226,22 +340,18 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
226
340
|
}));
|
|
227
341
|
return out;
|
|
228
342
|
}
|
|
229
|
-
/**
|
|
230
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Installs a plugin in the org (the old install route, an alias of switching it on): the role
|
|
345
|
+
* first, then item errors (a member cannot probe a disabled item through error codes), then the
|
|
346
|
+
* installer. Records the org's switch as on.
|
|
347
|
+
*/
|
|
348
|
+
async install(orgId, actor, itemId, body, actorTokenId, auditDetail) {
|
|
231
349
|
if (!UUID_RE.test(itemId))
|
|
232
350
|
throw itemNotFound();
|
|
233
|
-
// The role first (forbidden when it can install nothing), then item errors: a member cannot
|
|
234
|
-
// probe the existence or versions of a disabled item through error codes
|
|
235
351
|
await this.assertCanInstall(orgId, actor);
|
|
236
|
-
const item = await this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
.where("id", "=", itemId)
|
|
240
|
-
.where("deleted_at", "is", null)
|
|
241
|
-
.executeTakeFirst();
|
|
242
|
-
if (!item)
|
|
243
|
-
throw itemNotFound();
|
|
244
|
-
const version = body.version ?? item.latest_version;
|
|
352
|
+
const item = await this.visibleItem(orgId, itemId);
|
|
353
|
+
// The platform's version (one per deployment, ruling P2-17)
|
|
354
|
+
const version = item.platform_synced_version ?? item.latest_version;
|
|
245
355
|
const v = await this.db
|
|
246
356
|
.selectFrom("catalog_item_versions")
|
|
247
357
|
.select("version")
|
|
@@ -250,107 +360,169 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
250
360
|
.executeTakeFirst();
|
|
251
361
|
if (!v)
|
|
252
362
|
throw new ApiError("catalog.item_not_found", `Version ${version} of this item not found`);
|
|
253
|
-
const opts =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return { status: 202, request: await this.requests.view(pending) };
|
|
264
|
-
}
|
|
265
|
-
// 2. Install (each step re-checks the item policy in its own transaction)
|
|
266
|
-
const { version: _version, ...input } = body;
|
|
267
|
-
const view = await this.pluginInstaller.install(orgId, actor, itemId, version, input, opts);
|
|
363
|
+
const opts = {
|
|
364
|
+
switchOn: true,
|
|
365
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
366
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
367
|
+
};
|
|
368
|
+
if (item.disabled)
|
|
369
|
+
throw pluginDisabled();
|
|
370
|
+
// Dependencies resolved, extensions deployed, template connectors available
|
|
371
|
+
await this.pluginInstaller.preflight(orgId, actor, itemId, version);
|
|
372
|
+
const view = await this.pluginInstaller.install(orgId, actor, itemId, version, body, opts);
|
|
268
373
|
return {
|
|
269
374
|
status: 201,
|
|
270
375
|
installed: { itemId, version, pluginInstallId: view.id },
|
|
271
376
|
install: view,
|
|
272
377
|
};
|
|
273
378
|
}
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
*/
|
|
278
|
-
async requestIfNeeded(orgId, actor, item, version, actions, opts) {
|
|
279
|
-
const itemId = item.id;
|
|
280
|
-
const t = this.db;
|
|
281
|
-
await lockOrgForActions(this.orgLock, orgId, actor, actions);
|
|
282
|
-
const locked = await t
|
|
379
|
+
/** The item when the org may see it (scope), else `catalog.item_not_found`. */
|
|
380
|
+
async visibleItem(orgId, itemId) {
|
|
381
|
+
const item = await this.db
|
|
283
382
|
.selectFrom("catalog_items")
|
|
284
|
-
.
|
|
383
|
+
.selectAll()
|
|
285
384
|
.where("id", "=", itemId)
|
|
286
|
-
.
|
|
385
|
+
.where("deleted_at", "is", null)
|
|
287
386
|
.executeTakeFirst();
|
|
288
|
-
if (!
|
|
387
|
+
if (!item)
|
|
388
|
+
throw itemNotFound();
|
|
389
|
+
// An org upload waiting for the super admin: absent for other orgs, not switchable by its
|
|
390
|
+
// owner (ruling P3-9)
|
|
391
|
+
if (item.awaiting_confirmation) {
|
|
392
|
+
if (item.owner_org_id !== orgId)
|
|
393
|
+
throw itemNotFound();
|
|
394
|
+
throw itemPendingError(item.name);
|
|
395
|
+
}
|
|
396
|
+
const listed = await this.db
|
|
397
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
398
|
+
.select("item_id")
|
|
399
|
+
.where("item_id", "=", itemId)
|
|
400
|
+
.where("org_id", "=", orgId)
|
|
401
|
+
.executeTakeFirst();
|
|
402
|
+
if (!visibleTo({ scope: item.builtin ? "all" : item.scope }, listed !== undefined)) {
|
|
403
|
+
// Shown to other orgs: the org sees it and may request access, but cannot switch it on
|
|
404
|
+
if (requestable(item, false))
|
|
405
|
+
throw notOffered();
|
|
289
406
|
throw itemNotFound();
|
|
290
|
-
if (locked.policy === "disabled")
|
|
291
|
-
throw itemDisabled();
|
|
292
|
-
if (locked.policy === "needs_approval") {
|
|
293
|
-
const grant = await t
|
|
294
|
-
.selectFrom("catalog_org_grants")
|
|
295
|
-
.select("item_id")
|
|
296
|
-
.where("item_id", "=", itemId)
|
|
297
|
-
.where("org_id", "=", orgId)
|
|
298
|
-
.executeTakeFirst();
|
|
299
|
-
if (!grant) {
|
|
300
|
-
return this.requests.requestDeployment(orgId, actor, item, version, opts);
|
|
301
|
-
}
|
|
302
407
|
}
|
|
303
|
-
return
|
|
408
|
+
return item;
|
|
304
409
|
}
|
|
305
|
-
/** The
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
410
|
+
/** The org's live plugin install of the item, if any. */
|
|
411
|
+
liveInstall(orgId, itemId) {
|
|
412
|
+
return this.db
|
|
413
|
+
.selectFrom("plugin_installs")
|
|
414
|
+
.select("id")
|
|
415
|
+
.where("org_id", "=", orgId)
|
|
416
|
+
.where("item_id", "=", itemId)
|
|
417
|
+
.where("status", "in", ["installing", "installed", "upgrading"])
|
|
418
|
+
.executeTakeFirst();
|
|
309
419
|
}
|
|
310
420
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
421
|
+
* The org admin's switch of a plugin (`PUT catalog/:itemId/switch`). On: installs it (or just
|
|
422
|
+
* records the switch when it is installed already). Off: refused for builtin items
|
|
423
|
+
* (`plugin.scope_locked`; an `all` one may go off, layering spec §4); without `confirm` returns
|
|
424
|
+
* the uninstall preview and its hash, with the hash of the current preview uninstalls (a changed
|
|
425
|
+
* preview -> `plugin.switch_stale`). The switch row is written after the install / uninstall.
|
|
315
426
|
*/
|
|
316
|
-
async
|
|
427
|
+
async setSwitch(orgId, actor, itemId, body, actorTokenId, auditDetail) {
|
|
428
|
+
if (!UUID_RE.test(itemId))
|
|
429
|
+
throw itemNotFound();
|
|
317
430
|
await this.assertCanInstall(orgId, actor);
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return { status: 202, request: await this.requests.view(pending) };
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
status: 200,
|
|
326
|
-
install: await this.pluginUpgrader.upgrade(orgId, actor, installId, body, opts, diff),
|
|
431
|
+
const item = await this.visibleItem(orgId, itemId);
|
|
432
|
+
const opts = {
|
|
433
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
434
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
327
435
|
};
|
|
436
|
+
if (body.enabled) {
|
|
437
|
+
if (item.disabled)
|
|
438
|
+
throw pluginDisabled();
|
|
439
|
+
if ((await this.liveInstall(orgId, itemId)) !== undefined) {
|
|
440
|
+
await this.recordSwitch(orgId, actor, itemId, true);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
await this.install(orgId, actor, itemId, body.inputs ?? {}, actorTokenId, auditDetail);
|
|
444
|
+
}
|
|
445
|
+
return { kind: "done", item: await this.itemOf(orgId, actor, itemId) };
|
|
446
|
+
}
|
|
447
|
+
if (!switchable(item)) {
|
|
448
|
+
throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be switched off here");
|
|
449
|
+
}
|
|
450
|
+
const live = await this.liveInstall(orgId, itemId);
|
|
451
|
+
if (live === undefined) {
|
|
452
|
+
await this.recordSwitch(orgId, actor, itemId, false);
|
|
453
|
+
return { kind: "done", item: await this.itemOf(orgId, actor, itemId) };
|
|
454
|
+
}
|
|
455
|
+
const preview = await this.pluginInstaller.previewUninstall(orgId, live.id);
|
|
456
|
+
const confirm = uninstallPreviewHash(preview);
|
|
457
|
+
if (body.confirm === undefined)
|
|
458
|
+
return { kind: "preview", preview, confirm };
|
|
459
|
+
// The hash is re-checked and the switch row written inside the uninstall's transaction
|
|
460
|
+
await this.pluginInstaller.uninstall(orgId, actor, live.id, opts, { expectHash: body.confirm });
|
|
461
|
+
return { kind: "done", item: await this.itemOf(orgId, actor, itemId) };
|
|
328
462
|
}
|
|
329
|
-
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
463
|
+
/**
|
|
464
|
+
* `DELETE plugin-installs/:installId` of a catalog plugin follows the switch-off semantics: builtin
|
|
465
|
+
* items are refused (`plugin.scope_locked`) unless the install is not live (failed, or
|
|
466
|
+
* `installing`: the installer cleans up a stale one and refuses a fresh one). Removing a live
|
|
467
|
+
* install writes the switch row false in the uninstall's transaction (an `all` item then stays
|
|
468
|
+
* off in the org); removing a failed or stale one writes none.
|
|
469
|
+
*/
|
|
470
|
+
async uninstall(orgId, actor, installId, actorTokenId) {
|
|
471
|
+
if (!UUID_RE.test(installId))
|
|
472
|
+
throw new ApiError("plugin.install_not_found", "Plugin install not found");
|
|
473
|
+
const row = await this.db
|
|
474
|
+
.selectFrom("plugin_installs as a")
|
|
475
|
+
.innerJoin("catalog_items as i", "i.id", "a.item_id")
|
|
476
|
+
.select(["i.scope", "i.builtin", "a.status"])
|
|
477
|
+
.where("a.id", "=", installId)
|
|
478
|
+
.where("a.org_id", "=", orgId)
|
|
479
|
+
.executeTakeFirst();
|
|
480
|
+
// A failed or stuck install is cleaned up whatever the scope (it is not on anyway)
|
|
481
|
+
const live = row?.status === "installed" || row?.status === "upgrading";
|
|
482
|
+
if (row !== undefined && live && !switchable(row)) {
|
|
483
|
+
throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be uninstalled here");
|
|
484
|
+
}
|
|
485
|
+
return this.pluginInstaller.uninstall(orgId, actor, installId, actorTokenId !== undefined ? { actorTokenId } : {},
|
|
486
|
+
// only a live install was on: removing a failed or stale one writes no switch row, so an
|
|
487
|
+
// item its scope wants stays wanted and the sync installs it again
|
|
488
|
+
row !== undefined && live ? {} : undefined);
|
|
489
|
+
}
|
|
490
|
+
async itemOf(orgId, accountId, itemId) {
|
|
491
|
+
const [item] = await this.list(orgId, accountId, itemId);
|
|
492
|
+
if (!item)
|
|
493
|
+
throw itemNotFound();
|
|
494
|
+
return item;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Writes the org's switch row of the item under the org row lock. The item row is locked FOR
|
|
498
|
+
* SHARE first (exclusive with a scope change, an unshare, ruling P3-25, and an owner's delete or
|
|
499
|
+
* transfer); switching on re-checks that the org may still see it; the install path re-checks the same in `assertItemInstallable`.
|
|
500
|
+
*/
|
|
501
|
+
async recordSwitch(orgId, actor, itemId, enabled) {
|
|
502
|
+
await this.orgLock.lock(orgId);
|
|
503
|
+
// Both directions lock the item row FOR SHARE: an owner's delete or transfer (FOR UPDATE)
|
|
504
|
+
// decides on who uses it, so a switch-off racing it must not change that answer meanwhile
|
|
505
|
+
const item = await this.db
|
|
334
506
|
.selectFrom("catalog_items")
|
|
335
|
-
.select(["
|
|
507
|
+
.select(["scope", "builtin"])
|
|
336
508
|
.where("id", "=", itemId)
|
|
509
|
+
.where("deleted_at", "is", null)
|
|
337
510
|
.forShare()
|
|
338
511
|
.executeTakeFirst();
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return this.requests.requestDeployment(orgId, actor, locked, body.version, opts);
|
|
512
|
+
if (enabled) {
|
|
513
|
+
if (!item)
|
|
514
|
+
throw itemNotFound();
|
|
515
|
+
const listed = await this.db
|
|
516
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
517
|
+
.select("item_id")
|
|
518
|
+
.where("item_id", "=", itemId)
|
|
519
|
+
.where("org_id", "=", orgId)
|
|
520
|
+
.executeTakeFirst();
|
|
521
|
+
if (!visibleTo({ scope: item.builtin ? "all" : item.scope }, listed !== undefined)) {
|
|
522
|
+
throw itemNotFound();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
await upsertOrgSwitch(this.db, orgId, itemId, enabled, actor);
|
|
354
526
|
}
|
|
355
527
|
/** The actor can install something in the org (forbidden otherwise), checked before item errors. */
|
|
356
528
|
async assertCanInstall(orgId, actor) {
|
|
@@ -362,10 +534,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
362
534
|
};
|
|
363
535
|
__decorate([
|
|
364
536
|
Transactional()
|
|
365
|
-
], OrgCatalogService.prototype, "
|
|
366
|
-
__decorate([
|
|
367
|
-
Transactional()
|
|
368
|
-
], OrgCatalogService.prototype, "upgradeRequestIfNeeded", null);
|
|
537
|
+
], OrgCatalogService.prototype, "recordSwitch", null);
|
|
369
538
|
__decorate([
|
|
370
539
|
Transactional()
|
|
371
540
|
], OrgCatalogService.prototype, "assertCanInstall", null);
|
|
@@ -375,10 +544,8 @@ OrgCatalogService = __decorate([
|
|
|
375
544
|
__param(1, Inject(OrgLock)),
|
|
376
545
|
__param(2, Inject(StorageService)),
|
|
377
546
|
__param(3, Inject(ExtensionRegistry)),
|
|
378
|
-
__param(4, Inject(
|
|
379
|
-
__param(5, Inject(
|
|
380
|
-
__param(6, Inject(
|
|
381
|
-
__param(7, Inject(KERNEL_LOGGER)),
|
|
382
|
-
__param(8, Inject(TransactionHost))
|
|
547
|
+
__param(4, Inject(PluginInstaller)),
|
|
548
|
+
__param(5, Inject(KERNEL_LOGGER)),
|
|
549
|
+
__param(6, Inject(TransactionHost))
|
|
383
550
|
], OrgCatalogService);
|
|
384
551
|
export { OrgCatalogService };
|