@capybara-hq/kernel 0.1.0-rc.3 → 0.1.0-rc.31
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 +94 -5
- package/dist/admin/admin-agents.controller.d.ts +28 -0
- package/dist/admin/admin-agents.controller.js +79 -0
- package/dist/admin/admin-connectors.controller.d.ts +29 -0
- package/dist/admin/admin-connectors.controller.js +79 -0
- package/dist/admin/admin-items.schemas.d.ts +42 -0
- package/dist/admin/admin-items.schemas.js +48 -0
- package/dist/admin/admin.controller.d.ts +54 -82
- package/dist/admin/admin.controller.js +118 -83
- package/dist/admin/admin.module.d.ts +5 -1
- package/dist/admin/admin.module.js +56 -4
- package/dist/admin/admin.schemas.d.ts +87 -0
- package/dist/admin/admin.schemas.js +53 -0
- package/dist/admin/audit.controller.d.ts +14 -0
- package/dist/admin/audit.controller.js +42 -0
- package/dist/admin/audit.schemas.d.ts +8 -0
- package/dist/admin/audit.schemas.js +17 -0
- package/dist/admin/extensions.controller.d.ts +34 -3
- package/dist/admin/extensions.controller.js +66 -8
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/health.service.d.ts +104 -0
- package/dist/admin/health.service.js +250 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/admin/outbox-dead.controller.d.ts +23 -0
- package/dist/admin/outbox-dead.controller.js +62 -0
- package/dist/admin/outbox-dead.schemas.d.ts +8 -0
- package/dist/admin/outbox-dead.schemas.js +18 -0
- package/dist/admin/outbox-dead.service.d.ts +70 -0
- package/dist/admin/outbox-dead.service.js +190 -0
- package/dist/admin/overview.controller.d.ts +31 -0
- package/dist/admin/overview.controller.js +78 -0
- package/dist/admin/overview.schemas.d.ts +8 -0
- package/dist/admin/overview.schemas.js +13 -0
- package/dist/admin/overview.service.d.ts +147 -0
- package/dist/admin/overview.service.js +257 -0
- package/dist/admin/platform-audit.service.d.ts +41 -0
- package/dist/admin/platform-audit.service.js +70 -0
- 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/admin/usage.service.d.ts +149 -0
- package/dist/admin/usage.service.js +321 -0
- package/dist/agents/admin-agents.d.ts +105 -0
- package/dist/agents/admin-agents.js +228 -0
- package/dist/agents/agent-lookup.d.ts +24 -0
- package/dist/agents/agent-lookup.js +36 -0
- package/dist/agents/agent-profile.service.d.ts +31 -0
- package/dist/agents/agent-profile.service.js +122 -0
- package/dist/agents/agents.controller.d.ts +53 -168
- package/dist/agents/agents.controller.js +163 -34
- package/dist/agents/agents.module.d.ts +6 -2
- package/dist/agents/agents.module.js +44 -7
- package/dist/agents/agents.schemas.d.ts +440 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +130 -39
- package/dist/agents/agents.service.js +435 -136
- package/dist/agents/definition.d.ts +169 -23
- package/dist/agents/definition.js +310 -55
- package/dist/agents/from-template.d.ts +109 -0
- package/dist/agents/from-template.js +693 -0
- package/dist/agents/from-template.service.d.ts +72 -0
- package/dist/agents/from-template.service.js +178 -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 +44 -6
- package/dist/agents/models.controller.js +84 -8
- package/dist/agents/org-templates.d.ts +186 -0
- package/dist/agents/org-templates.js +932 -0
- package/dist/agents/pending-connector-requests.d.ts +79 -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 +114 -0
- package/dist/agents/profile.js +55 -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 +77 -5
- package/dist/agents/templates.controller.js +153 -7
- package/dist/agents/templates.d.ts +133 -23
- package/dist/agents/templates.js +490 -53
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/app.js +2 -0
- package/dist/attribution/platform-attribution.d.ts +104 -0
- package/dist/attribution/platform-attribution.js +149 -0
- package/dist/background/background.controller.d.ts +38 -0
- package/dist/background/background.controller.js +88 -0
- package/dist/background/background.module.d.ts +10 -0
- package/dist/background/background.module.js +39 -0
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/finish.d.ts +47 -0
- package/dist/background/finish.js +106 -0
- package/dist/background/launch-lock.d.ts +15 -0
- package/dist/background/launch-lock.js +40 -0
- package/dist/background/launch.d.ts +81 -0
- package/dist/background/launch.js +160 -0
- package/dist/background/poll.job.d.ts +56 -0
- package/dist/background/poll.job.js +195 -0
- package/dist/background/render.d.ts +23 -0
- package/dist/background/render.js +48 -0
- package/dist/background/session.d.ts +60 -0
- package/dist/background/session.js +102 -0
- package/dist/background/status.d.ts +35 -0
- package/dist/background/status.js +57 -0
- package/dist/background/stop.d.ts +66 -0
- package/dist/background/stop.js +224 -0
- package/dist/background/store.d.ts +175 -0
- package/dist/background/store.js +385 -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 +109 -0
- package/dist/background/tasks.service.js +271 -0
- package/dist/background/wake-rules.d.ts +71 -0
- package/dist/background/wake-rules.js +124 -0
- package/dist/background/wake.d.ts +30 -0
- package/dist/background/wake.js +63 -0
- package/dist/catalog/admin-catalog.controller.d.ts +156 -55
- package/dist/catalog/admin-catalog.controller.js +313 -68
- package/dist/catalog/admin-catalog.schemas.d.ts +87 -0
- package/dist/catalog/admin-catalog.schemas.js +107 -0
- package/dist/catalog/appearance.schemas.d.ts +10 -0
- package/dist/catalog/appearance.schemas.js +20 -0
- package/dist/catalog/appearance.service.d.ts +105 -0
- package/dist/catalog/appearance.service.js +306 -0
- package/dist/catalog/catalog-content.d.ts +144 -35
- package/dist/catalog/catalog-content.js +122 -13
- package/dist/catalog/catalog-files.d.ts +42 -0
- package/dist/catalog/catalog-files.js +89 -0
- package/dist/catalog/catalog-import.module.d.ts +7 -0
- package/dist/catalog/catalog-import.module.js +59 -0
- package/dist/catalog/catalog-items.d.ts +122 -7
- package/dist/catalog/catalog-items.js +301 -13
- package/dist/catalog/catalog-scope.service.d.ts +330 -0
- package/dist/catalog/catalog-scope.service.js +1312 -0
- package/dist/catalog/catalog.module.d.ts +8 -9
- package/dist/catalog/catalog.module.js +55 -31
- package/dist/catalog/catalog.service.d.ts +129 -31
- package/dist/catalog/catalog.service.js +193 -105
- package/dist/catalog/claude/agents.js +2 -0
- package/dist/catalog/claude/report.d.ts +9 -2
- package/dist/catalog/claude/report.js +1 -0
- package/dist/catalog/claude/translate.js +4 -1
- package/dist/catalog/cli.d.ts +12 -1
- package/dist/catalog/cli.js +24 -1
- package/dist/catalog/component-promotion.d.ts +96 -0
- package/dist/catalog/component-promotion.js +394 -0
- package/dist/catalog/component-scope.controller.d.ts +102 -0
- package/dist/catalog/component-scope.controller.js +257 -0
- package/dist/catalog/component-scope.schemas.d.ts +118 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +394 -0
- package/dist/catalog/component-scope.service.js +1133 -0
- package/dist/catalog/component-state.d.ts +219 -0
- package/dist/catalog/component-state.js +493 -0
- package/dist/catalog/git-source.d.ts +9 -1
- package/dist/catalog/git-source.js +29 -2
- package/dist/catalog/job-ids.d.ts +19 -1
- package/dist/catalog/job-ids.js +21 -1
- package/dist/catalog/marketplace-fetch.d.ts +6 -3
- package/dist/catalog/marketplace-fetch.js +4 -1
- package/dist/catalog/marketplace-icons.d.ts +64 -0
- package/dist/catalog/marketplace-icons.js +131 -0
- package/dist/catalog/marketplaces.controller.d.ts +50 -41
- package/dist/catalog/marketplaces.controller.js +130 -46
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +110 -17
- package/dist/catalog/marketplaces.service.js +339 -30
- package/dist/catalog/org-catalog.controller.d.ts +124 -62
- package/dist/catalog/org-catalog.controller.js +208 -93
- package/dist/catalog/org-catalog.schemas.d.ts +117 -0
- package/dist/catalog/org-catalog.schemas.js +141 -0
- package/dist/catalog/org-catalog.service.d.ts +72 -33
- package/dist/catalog/org-catalog.service.js +377 -158
- 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 +133 -0
- package/dist/catalog/org-extension.controller.js +313 -0
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +77 -0
- package/dist/catalog/org-plugin-uploads.controller.js +199 -0
- package/dist/catalog/org-plugin-uploads.d.ts +77 -0
- package/dist/catalog/org-plugin-uploads.js +134 -0
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +19 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +30 -0
- package/dist/catalog/owned-items.d.ts +181 -0
- package/dist/catalog/owned-items.js +790 -0
- package/dist/catalog/owned-plugin-cleanup.d.ts +47 -0
- package/dist/catalog/owned-plugin-cleanup.js +140 -0
- package/dist/catalog/ownership.d.ts +172 -0
- package/dist/catalog/ownership.js +326 -0
- package/dist/catalog/platform-components.d.ts +264 -0
- package/dist/catalog/platform-components.js +857 -0
- package/dist/catalog/platform-import-update.d.ts +50 -0
- package/dist/catalog/platform-import-update.js +116 -0
- package/dist/catalog/plugin-import.d.ts +289 -52
- package/dist/catalog/plugin-import.js +846 -143
- package/dist/catalog/plugin-install.d.ts +235 -51
- package/dist/catalog/plugin-install.js +915 -139
- package/dist/catalog/plugin-package.d.ts +50 -4
- package/dist/catalog/plugin-package.js +221 -8
- package/dist/catalog/plugin-upgrade.d.ts +325 -225
- package/dist/catalog/plugin-upgrade.js +1317 -1133
- package/dist/catalog/request-rules.d.ts +65 -0
- package/dist/catalog/request-rules.js +217 -0
- package/dist/catalog/requests.service.d.ts +251 -117
- package/dist/catalog/requests.service.js +701 -323
- package/dist/catalog/reserved-names.d.ts +8 -0
- package/dist/catalog/reserved-names.js +42 -0
- package/dist/catalog/scope-jobs.d.ts +59 -0
- package/dist/catalog/scope-jobs.js +65 -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 +29 -0
- package/dist/catalog/scope-sync-workers.js +85 -0
- package/dist/catalog/scope-sync.d.ts +151 -0
- package/dist/catalog/scope-sync.js +568 -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 +119 -0
- package/dist/channels/actions.d.ts +5 -0
- package/dist/channels/actions.js +33 -7
- package/dist/channels/cards.d.ts +59 -9
- package/dist/channels/cards.js +173 -20
- package/dist/channels/channels.module.d.ts +13 -9
- package/dist/channels/channels.module.js +33 -11
- package/dist/channels/channels.schemas.d.ts +41 -0
- package/dist/channels/channels.schemas.js +40 -0
- package/dist/channels/connections.controller.d.ts +46 -37
- package/dist/channels/connections.controller.js +76 -34
- package/dist/channels/connections.service.d.ts +105 -13
- package/dist/channels/connections.service.js +277 -30
- package/dist/channels/deliver-job.d.ts +32 -0
- package/dist/channels/deliver-job.js +29 -0
- package/dist/channels/inbound.d.ts +12 -2
- package/dist/channels/inbound.js +89 -22
- package/dist/channels/jobs.d.ts +37 -20
- package/dist/channels/jobs.js +79 -27
- package/dist/channels/outbound.d.ts +40 -3
- package/dist/channels/outbound.js +187 -22
- package/dist/channels/phrases.d.ts +93 -2
- package/dist/channels/phrases.js +71 -1
- package/dist/channels/supervisor.d.ts +2 -0
- package/dist/channels/supervisor.js +4 -0
- package/dist/channels/threads.d.ts +21 -3
- package/dist/channels/threads.js +46 -3
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/client/client-access.service.d.ts +102 -0
- package/dist/client/client-access.service.js +303 -0
- package/dist/client/client-builds.service.d.ts +109 -0
- package/dist/client/client-builds.service.js +229 -0
- package/dist/client/client-delivery.controller.d.ts +25 -0
- package/dist/client/client-delivery.controller.js +66 -0
- package/dist/client/client-files.d.ts +48 -0
- package/dist/client/client-files.js +136 -0
- package/dist/client/client-reports.cron.d.ts +13 -0
- package/dist/client/client-reports.cron.js +42 -0
- package/dist/client/client-reports.service.d.ts +30 -0
- package/dist/client/client-reports.service.js +102 -0
- package/dist/client/client-sign-in.service.d.ts +21 -0
- package/dist/client/client-sign-in.service.js +49 -0
- package/dist/client/client.controller.d.ts +49 -0
- package/dist/client/client.controller.js +129 -0
- package/dist/client/client.module.d.ts +8 -0
- package/dist/client/client.module.js +28 -0
- package/dist/client/client.schemas.d.ts +61 -0
- package/dist/client/client.schemas.js +27 -0
- package/dist/config/docs.js +5 -1
- package/dist/config/load.d.ts +6 -0
- package/dist/config/load.js +26 -0
- package/dist/config/schema.d.ts +71 -11
- package/dist/config/schema.js +432 -61
- package/dist/conversations/access.d.ts +6 -4
- package/dist/conversations/access.js +29 -5
- package/dist/conversations/agent-tree.d.ts +62 -0
- package/dist/conversations/agent-tree.js +128 -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 +91 -44
- package/dist/conversations/conversations.controller.js +161 -82
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +10 -7
- package/dist/conversations/conversations.schemas.d.ts +60 -0
- package/dist/conversations/conversations.schemas.js +93 -0
- package/dist/conversations/conversations.service.d.ts +291 -23
- package/dist/conversations/conversations.service.js +479 -82
- package/dist/conversations/device-status.d.ts +24 -0
- package/dist/conversations/device-status.js +71 -0
- package/dist/conversations/event-log.d.ts +61 -18
- package/dist/conversations/event-log.js +135 -21
- package/dist/conversations/events.d.ts +528 -17
- package/dist/conversations/events.js +537 -33
- package/dist/conversations/message-context.d.ts +82 -0
- package/dist/conversations/message-context.js +149 -0
- package/dist/conversations/queue.d.ts +20 -4
- package/dist/conversations/queue.js +44 -5
- package/dist/conversations/queue.service.d.ts +20 -9
- package/dist/conversations/queue.service.js +88 -23
- package/dist/conversations/source.d.ts +10 -0
- package/dist/conversations/source.js +17 -0
- package/dist/conversations/titles.d.ts +33 -11
- package/dist/conversations/titles.js +76 -25
- package/dist/conversations/tree.d.ts +27 -0
- package/dist/conversations/tree.js +77 -0
- package/dist/ctx/create-ctx.d.ts +48 -5
- package/dist/ctx/create-ctx.js +174 -34
- package/dist/db/kernel-schema.d.ts +819 -33
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +3 -0
- package/dist/devices/access.d.ts +66 -0
- package/dist/devices/access.js +113 -0
- package/dist/devices/conversation-devices.d.ts +107 -0
- package/dist/devices/conversation-devices.js +315 -0
- package/dist/devices/devices.controller.d.ts +52 -0
- package/dist/devices/devices.controller.js +162 -0
- package/dist/devices/devices.module.d.ts +8 -0
- package/dist/devices/devices.module.js +34 -0
- package/dist/devices/devices.schemas.d.ts +11 -0
- package/dist/devices/devices.schemas.js +22 -0
- package/dist/devices/devices.service.d.ts +421 -0
- package/dist/devices/devices.service.js +1080 -0
- package/dist/devices/dto.d.ts +55 -0
- package/dist/devices/dto.js +59 -0
- package/dist/devices/label.d.ts +11 -0
- package/dist/devices/label.js +25 -0
- package/dist/devices/legacy-cleanup.job.d.ts +34 -0
- package/dist/devices/legacy-cleanup.job.js +141 -0
- package/dist/devices/public-suffix.d.ts +6 -0
- package/dist/devices/public-suffix.js +79 -0
- package/dist/errors.d.ts +286 -8
- package/dist/errors.js +286 -8
- package/dist/evals/evals.module.js +16 -3
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/jobs.d.ts +14 -6
- package/dist/evals/jobs.js +21 -19
- package/dist/evals/plan.d.ts +20 -15
- package/dist/evals/plan.js +29 -6
- package/dist/evals/reconstruct.d.ts +52 -23
- package/dist/evals/reconstruct.js +147 -43
- package/dist/evals/recorded-tools.d.ts +11 -1
- package/dist/evals/recorded-tools.js +39 -3
- package/dist/evals/run-replay.d.ts +28 -5
- package/dist/evals/run-replay.js +101 -18
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +13 -13
- package/dist/evals/runs.service.js +55 -62
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +10 -9
- package/dist/evals/sets.service.js +39 -19
- package/dist/evals/snapshot.d.ts +10 -3
- package/dist/evals/snapshot.js +19 -5
- package/dist/evals/step-replay.d.ts +10 -6
- package/dist/evals/step-replay.js +21 -9
- package/dist/evals/trajectory.d.ts +19 -3
- package/dist/evals/trajectory.js +14 -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 +11 -4
- package/dist/extensions/admin-ops.d.ts +81 -14
- package/dist/extensions/admin-ops.js +181 -47
- package/dist/extensions/admin-view.d.ts +57 -10
- package/dist/extensions/admin-view.js +249 -27
- package/dist/extensions/approvals.d.ts +12 -2
- package/dist/extensions/blobs.d.ts +14 -1
- package/dist/extensions/blobs.js +49 -5
- package/dist/extensions/bootstrap.d.ts +86 -11
- package/dist/extensions/bootstrap.js +222 -37
- 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/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 +94 -9
- package/dist/extensions/deployment-config.js +255 -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 +133 -0
- package/dist/extensions/effective-config.js +379 -0
- package/dist/extensions/extensions.module.js +34 -12
- package/dist/extensions/guide-places.d.ts +68 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/hooks.d.ts +59 -7
- package/dist/extensions/hooks.js +97 -17
- package/dist/extensions/host.d.ts +105 -12
- package/dist/extensions/host.js +372 -87
- package/dist/extensions/installs.d.ts +30 -9
- package/dist/extensions/installs.js +61 -17
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-hooks.d.ts +99 -0
- package/dist/extensions/lifecycle-hooks.js +273 -0
- package/dist/extensions/lifecycle.d.ts +6 -1
- package/dist/extensions/lifecycle.js +9 -2
- package/dist/extensions/locks.d.ts +12 -0
- package/dist/extensions/locks.js +26 -0
- package/dist/extensions/org-config.d.ts +110 -8
- package/dist/extensions/org-config.js +234 -47
- 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 +18 -4
- package/dist/extensions/package.js +57 -4
- package/dist/extensions/permission-set.d.ts +35 -5
- package/dist/extensions/permission-set.js +36 -5
- package/dist/extensions/permission-view.d.ts +112 -15
- package/dist/extensions/permission-view.js +40 -17
- package/dist/extensions/plugin-guides.d.ts +282 -0
- package/dist/extensions/plugin-guides.js +554 -0
- package/dist/extensions/plugin-icons.d.ts +54 -0
- package/dist/extensions/plugin-icons.js +125 -0
- 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 +28 -0
- package/dist/extensions/point-defaults.controller.js +69 -0
- package/dist/extensions/point-defaults.d.ts +100 -0
- package/dist/extensions/point-defaults.js +267 -0
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/registry.d.ts +1 -1
- package/dist/extensions/registry.js +2 -0
- package/dist/extensions/resolve.d.ts +51 -1
- package/dist/extensions/resolve.js +85 -3
- package/dist/extensions/single-provider.d.ts +92 -0
- package/dist/extensions/single-provider.js +180 -0
- package/dist/extensions/sources.d.ts +13 -2
- package/dist/extensions/sources.js +2 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +46 -0
- package/dist/extensions/unavailable.d.ts +50 -0
- package/dist/extensions/unavailable.js +115 -0
- package/dist/extensions/usage-subscribers.d.ts +43 -0
- package/dist/extensions/usage-subscribers.js +108 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +10 -3
- package/dist/files/previewers.js +40 -11
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/git/gateway.d.ts +93 -0
- package/dist/git/gateway.js +750 -0
- package/dist/git/gateway.route.d.ts +16 -0
- package/dist/git/gateway.route.js +41 -0
- package/dist/git/git.module.d.ts +10 -0
- package/dist/git/git.module.js +31 -0
- package/dist/git/identity.d.ts +80 -0
- package/dist/git/identity.js +209 -0
- package/dist/git/pkt-line.d.ts +53 -0
- package/dist/git/pkt-line.js +146 -0
- package/dist/git/run-end.d.ts +29 -0
- package/dist/git/run-end.js +121 -0
- package/dist/git/sources.d.ts +42 -0
- package/dist/git/sources.js +134 -0
- package/dist/git/tickets.d.ts +69 -0
- package/dist/git/tickets.js +194 -0
- package/dist/http/api.module.js +86 -4
- package/dist/http/app.d.ts +17 -2
- package/dist/http/app.js +34 -5
- package/dist/http/gateway-routes.d.ts +7 -3
- package/dist/http/gateway-routes.js +6 -3
- package/dist/http/nest-logger.d.ts +6 -5
- package/dist/http/nest-logger.js +24 -10
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +77 -31
- package/dist/identity/accounts.js +133 -52
- 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 +35 -9
- package/dist/identity/cookies.d.ts +26 -5
- package/dist/identity/cookies.js +58 -6
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +7 -4
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +17 -1
- package/dist/identity/me.controller.js +45 -4
- package/dist/identity/me.schemas.d.ts +24 -0
- package/dist/identity/me.schemas.js +25 -0
- package/dist/identity/principal.d.ts +11 -3
- package/dist/identity/principal.js +11 -3
- package/dist/identity/sessions.d.ts +12 -0
- package/dist/identity/sessions.js +45 -0
- package/dist/identity/settings.d.ts +216 -12
- package/dist/identity/settings.js +420 -29
- 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/identity/write-actor.d.ts +11 -0
- package/dist/identity/write-actor.js +7 -0
- package/dist/inbox/inbox.module.d.ts +4 -1
- package/dist/inbox/inbox.module.js +9 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/inbox.service.d.ts +65 -4
- package/dist/inbox/inbox.service.js +82 -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 +128 -0
- package/dist/inbox/platform-inbox.service.js +232 -0
- package/dist/inbox/platform-notices.d.ts +19 -0
- package/dist/inbox/platform-notices.js +9 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +8 -1
- package/dist/infra/cli/kernel-cli.module.js +14 -1
- package/dist/infra/config/kernel-config.service.d.ts +7 -0
- package/dist/infra/config/kernel-config.service.js +70 -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 +28 -25
- package/dist/infra/lifecycle/process-guards.js +4 -0
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/logging/logging.module.d.ts +4 -2
- package/dist/infra/logging/logging.module.js +24 -6
- package/dist/infra/outbox/outbox-relay.module.d.ts +6 -0
- package/dist/infra/outbox/outbox-relay.module.js +18 -0
- package/dist/infra/outbox/outbox.dispatcher.d.ts +103 -0
- package/dist/infra/outbox/outbox.dispatcher.js +310 -0
- package/dist/infra/outbox/outbox.module.d.ts +24 -0
- package/dist/infra/outbox/outbox.module.js +50 -0
- package/dist/infra/outbox/outbox.relay.d.ts +31 -0
- package/dist/infra/outbox/outbox.relay.js +76 -0
- package/dist/infra/outbox/outbox.service.d.ts +57 -0
- package/dist/infra/outbox/outbox.service.js +165 -0
- package/dist/infra/outbox/registry.d.ts +296 -0
- package/dist/infra/outbox/registry.js +291 -0
- package/dist/infra/presence/presence.module.d.ts +6 -0
- package/dist/infra/presence/presence.module.js +22 -0
- package/dist/infra/presence/replica-presence.d.ts +87 -0
- package/dist/infra/presence/replica-presence.js +189 -0
- package/dist/infra/queue/queue-names.d.ts +8 -0
- package/dist/infra/queue/queue-names.js +17 -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/throttler/named-throttlers.d.ts +12 -0
- package/dist/infra/throttler/named-throttlers.js +67 -0
- package/dist/infra/throttler/throttler.guard.js +1 -1
- package/dist/infra/tokens.d.ts +6 -1
- package/dist/infra/tokens.js +6 -1
- package/dist/kernel.module.js +18 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +9 -3
- package/dist/lifecycle/kernel-lifecycle.js +46 -11
- package/dist/local-devices/device-auth.controller.d.ts +42 -0
- package/dist/local-devices/device-auth.controller.js +116 -0
- package/dist/local-devices/device-auth.d.ts +124 -0
- package/dist/local-devices/device-auth.js +410 -0
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/local-devices/device-auth.module.js +25 -0
- package/dist/local-devices/device-policy.service.d.ts +174 -0
- package/dist/local-devices/device-policy.service.js +470 -0
- package/dist/local-devices/device-routes.d.ts +36 -0
- package/dist/local-devices/device-routes.js +90 -0
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/local-devices/keys.d.ts +25 -0
- package/dist/local-devices/keys.js +25 -0
- package/dist/local-devices/local-device-gateway.d.ts +136 -0
- package/dist/local-devices/local-device-gateway.js +570 -0
- package/dist/local-devices/local-device-provider.d.ts +116 -0
- package/dist/local-devices/local-device-provider.js +203 -0
- package/dist/local-devices/local-devices.module.d.ts +17 -0
- package/dist/local-devices/local-devices.module.js +60 -0
- package/dist/local-devices/machines.d.ts +163 -0
- package/dist/local-devices/machines.js +540 -0
- package/dist/local-devices/network-grants.d.ts +88 -0
- package/dist/local-devices/network-grants.js +268 -0
- package/dist/local-devices/policy-op-jobs.d.ts +15 -0
- package/dist/local-devices/policy-op-jobs.js +12 -0
- package/dist/local-devices/policy-summary.d.ts +98 -0
- package/dist/local-devices/policy-summary.js +151 -0
- package/dist/local-devices/relay.d.ts +100 -0
- package/dist/local-devices/relay.js +373 -0
- package/dist/local-devices/targets.d.ts +28 -0
- package/dist/local-devices/targets.js +73 -0
- package/dist/log.d.ts +13 -1
- package/dist/log.js +93 -17
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +319 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +19 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +8 -6
- package/dist/models/prices.js +11 -9
- package/dist/models/purposes.controller.d.ts +6 -4
- package/dist/models/purposes.controller.js +13 -7
- package/dist/models/purposes.d.ts +79 -14
- package/dist/models/purposes.js +120 -34
- package/dist/net/public-address.d.ts +14 -4
- package/dist/net/public-address.js +22 -12
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +16 -4
- package/dist/orgs/directory-sync.d.ts +14 -5
- package/dist/orgs/directory-sync.js +42 -18
- package/dist/orgs/members.service.js +1 -1
- package/dist/orgs/offboarding.d.ts +54 -57
- package/dist/orgs/offboarding.js +161 -185
- 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.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.module.js +10 -10
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +29 -8
- package/dist/orgs/orgs.service.js +57 -16
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +11 -1
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.controller.js +4 -3
- package/dist/orgs/settings.service.d.ts +278 -31
- package/dist/orgs/settings.service.js +357 -47
- package/dist/overrides.d.ts +49 -4
- package/dist/overrides.js +28 -2
- package/dist/packages/npm.d.ts +28 -9
- package/dist/packages/npm.js +30 -19
- package/dist/packages/provenance.d.ts +3 -1
- package/dist/packages/provenance.js +7 -3
- 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 +28 -0
- package/dist/platform/errors.js +65 -0
- package/dist/platform/exclusions.d.ts +11 -0
- package/dist/platform/exclusions.js +792 -0
- package/dist/platform/method.d.ts +6 -0
- package/dist/platform/method.js +15 -0
- package/dist/platform/operation.d.ts +169 -0
- package/dist/platform/operation.js +106 -0
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin-items.ops.d.ts +37 -0
- package/dist/platform/ops/admin-items.ops.js +278 -0
- package/dist/platform/ops/admin.ops.d.ts +38 -0
- package/dist/platform/ops/admin.ops.js +546 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +50 -0
- package/dist/platform/ops/agent-skills.ops.js +509 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +17 -0
- package/dist/platform/ops/agent-templates.ops.js +272 -0
- package/dist/platform/ops/agents.ops.d.ts +37 -0
- package/dist/platform/ops/agents.ops.js +726 -0
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +94 -0
- package/dist/platform/ops/catalog-admin.ops.js +710 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +854 -0
- package/dist/platform/ops/connectors.ops.d.ts +17 -0
- package/dist/platform/ops/connectors.ops.js +190 -0
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +504 -0
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +313 -0
- package/dist/platform/ops/errors.d.ts +16 -0
- package/dist/platform/ops/errors.js +30 -0
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +794 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +372 -0
- package/dist/platform/ops/extensions.ops.d.ts +25 -0
- package/dist/platform/ops/extensions.ops.js +347 -0
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +384 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +22 -0
- package/dist/platform/ops/marketplaces.ops.js +466 -0
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +35 -0
- package/dist/platform/ops/org-plugins.ops.js +388 -0
- package/dist/platform/ops/org-settings.ops.d.ts +18 -0
- package/dist/platform/ops/org-settings.ops.js +134 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +301 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/outbox.ops.d.ts +21 -0
- package/dist/platform/ops/outbox.ops.js +125 -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 +41 -0
- package/dist/platform/ops/platform.ops.js +261 -0
- package/dist/platform/ops/plugins.ops.d.ts +35 -0
- package/dist/platform/ops/plugins.ops.js +476 -0
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.d.ts +14 -0
- package/dist/platform/ops/requests.ops.js +192 -0
- package/dist/platform/ops/role.d.ts +4 -0
- package/dist/platform/ops/role.js +10 -0
- package/dist/platform/ops/schedules.ops.d.ts +21 -0
- package/dist/platform/ops/schedules.ops.js +509 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/skills.ops.d.ts +17 -0
- package/dist/platform/ops/skills.ops.js +160 -0
- package/dist/platform/ops/summary.d.ts +10 -0
- package/dist/platform/ops/summary.js +18 -0
- package/dist/platform/ops/themes.ops.d.ts +14 -0
- package/dist/platform/ops/themes.ops.js +47 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +118 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +45 -0
- package/dist/platform/platform-ops.module.js +150 -0
- package/dist/platform/platform.module.d.ts +8 -0
- package/dist/platform/platform.module.js +25 -0
- package/dist/platform/registry.d.ts +30 -0
- package/dist/platform/registry.js +111 -0
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +91 -0
- package/dist/roles/gateway-role.d.ts +18 -3
- package/dist/roles/gateway-role.js +33 -5
- package/dist/roles/gateway.module.d.ts +2 -1
- package/dist/roles/gateway.module.js +6 -3
- package/dist/roles/worker-role.d.ts +11 -4
- package/dist/roles/worker-role.js +24 -7
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +33 -7
- package/dist/runtime/compaction-progress.d.ts +62 -0
- package/dist/runtime/compaction-progress.js +82 -0
- package/dist/runtime/compaction-settings.service.d.ts +16 -0
- package/dist/runtime/compaction-settings.service.js +42 -0
- package/dist/runtime/compaction.service.d.ts +50 -0
- package/dist/runtime/compaction.service.js +75 -0
- package/dist/runtime/context/build.d.ts +28 -8
- package/dist/runtime/context/build.js +156 -28
- package/dist/runtime/context/claude-tools.d.ts +3 -1
- package/dist/runtime/context/claude-tools.js +8 -6
- package/dist/runtime/context/compaction.d.ts +109 -12
- package/dist/runtime/context/compaction.js +387 -51
- package/dist/runtime/context/device-paths.d.ts +82 -0
- package/dist/runtime/context/device-paths.js +165 -0
- package/dist/runtime/context/fit.d.ts +111 -0
- package/dist/runtime/context/fit.js +278 -0
- package/dist/runtime/context/plugin-context.d.ts +20 -0
- package/dist/runtime/context/plugin-context.js +30 -0
- package/dist/runtime/context/reminders.d.ts +2 -0
- package/dist/runtime/context/reminders.js +2 -0
- package/dist/runtime/context/run-context.d.ts +88 -0
- package/dist/runtime/context/run-context.js +296 -0
- package/dist/runtime/context/skills.d.ts +14 -1
- package/dist/runtime/context/skills.js +45 -7
- 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 +52 -21
- package/dist/runtime/limits.d.ts +15 -0
- package/dist/runtime/limits.js +25 -0
- package/dist/runtime/loop.d.ts +50 -8
- package/dist/runtime/loop.js +2 -1
- package/dist/runtime/maintenance.d.ts +19 -5
- package/dist/runtime/maintenance.js +102 -10
- package/dist/runtime/model-call.d.ts +191 -24
- package/dist/runtime/model-call.js +966 -365
- package/dist/runtime/plugin-context.service.d.ts +75 -0
- package/dist/runtime/plugin-context.service.js +220 -0
- package/dist/runtime/providers.d.ts +149 -29
- package/dist/runtime/providers.js +332 -63
- package/dist/runtime/queue-lost-jobs.d.ts +24 -0
- package/dist/runtime/queue-lost-jobs.js +51 -0
- package/dist/runtime/run-context.service.d.ts +82 -0
- package/dist/runtime/run-context.service.js +270 -0
- package/dist/runtime/run-control.d.ts +62 -5
- package/dist/runtime/run-control.js +98 -12
- package/dist/runtime/run-drafts.d.ts +85 -0
- package/dist/runtime/run-drafts.js +230 -0
- package/dist/runtime/run-finish.d.ts +49 -12
- package/dist/runtime/run-finish.js +125 -14
- package/dist/runtime/run-jobs.d.ts +112 -15
- package/dist/runtime/run-jobs.js +224 -32
- package/dist/runtime/run-orphan-check.job.d.ts +145 -0
- package/dist/runtime/run-orphan-check.job.js +344 -0
- package/dist/runtime/run-processors.d.ts +16 -9
- package/dist/runtime/run-processors.js +1 -1
- package/dist/runtime/run-queue.d.ts +134 -49
- package/dist/runtime/run-queue.js +519 -228
- package/dist/runtime/run-status.d.ts +12 -0
- package/dist/runtime/run-status.js +21 -0
- package/dist/runtime/run-steps.d.ts +3 -2
- package/dist/runtime/run-steps.js +15 -11
- package/dist/runtime/run-worker.d.ts +63 -22
- package/dist/runtime/run-worker.js +406 -117
- package/dist/runtime/runtime.module.d.ts +2 -3
- package/dist/runtime/runtime.module.js +36 -9
- package/dist/runtime/step-log.d.ts +31 -7
- package/dist/runtime/step-log.js +49 -11
- package/dist/runtime/stream.controller.d.ts +24 -4
- package/dist/runtime/stream.controller.js +60 -9
- package/dist/runtime/stream.d.ts +4 -1
- package/dist/runtime/stream.js +42 -3
- package/dist/runtime/subagents/child.d.ts +55 -7
- package/dist/runtime/subagents/child.js +106 -8
- package/dist/runtime/subagents/definition.d.ts +54 -25
- package/dist/runtime/subagents/definition.js +164 -212
- package/dist/runtime/subagents/deliveries.d.ts +74 -0
- package/dist/runtime/subagents/deliveries.js +237 -0
- package/dist/runtime/subagents/dispatch.d.ts +121 -32
- package/dist/runtime/subagents/dispatch.js +221 -173
- package/dist/runtime/subagents/limits.d.ts +24 -5
- package/dist/runtime/subagents/limits.js +40 -6
- package/dist/runtime/subagents/messages.d.ts +99 -0
- package/dist/runtime/subagents/messages.js +336 -0
- package/dist/runtime/subagents/preamble.d.ts +5 -4
- package/dist/runtime/subagents/preamble.js +10 -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 +6 -5
- package/dist/runtime/subagents/skill-fork.js +16 -9
- 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 +12 -7
- package/dist/runtime/subagents/tree-jobs.d.ts +61 -0
- package/dist/runtime/subagents/tree-jobs.js +86 -0
- package/dist/runtime/usage-report-jobs.d.ts +63 -0
- package/dist/runtime/usage-report-jobs.js +106 -0
- package/dist/runtime/usage-report.d.ts +48 -98
- package/dist/runtime/usage-report.js +142 -243
- package/dist/runtime/waits.d.ts +134 -165
- package/dist/runtime/waits.js +352 -706
- package/dist/sandbox/jobs.d.ts +50 -13
- package/dist/sandbox/jobs.js +64 -21
- package/dist/sandbox/leases.d.ts +37 -54
- package/dist/sandbox/leases.js +71 -115
- package/dist/sandbox/modes.d.ts +108 -0
- package/dist/sandbox/modes.js +126 -0
- package/dist/sandbox/platform-auto-mode.d.ts +63 -0
- package/dist/sandbox/platform-auto-mode.js +63 -0
- package/dist/sandbox/providers.d.ts +34 -7
- package/dist/sandbox/providers.js +54 -9
- package/dist/sandbox/review/classifier.d.ts +135 -0
- package/dist/sandbox/review/classifier.js +419 -0
- package/dist/sandbox/review/index.d.ts +13 -0
- package/dist/sandbox/review/index.js +10 -0
- package/dist/sandbox/review/review.service.d.ts +133 -0
- package/dist/sandbox/review/review.service.js +370 -0
- package/dist/sandbox/review/rules.d.ts +85 -0
- package/dist/sandbox/review/rules.js +5196 -0
- package/dist/sandbox/review/types.d.ts +102 -0
- package/dist/sandbox/review/types.js +48 -0
- package/dist/sandbox/sandbox-file-reader.d.ts +35 -0
- package/dist/sandbox/sandbox-file-reader.js +98 -0
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +21 -5
- package/dist/sandbox/sandbox.service.d.ts +464 -133
- package/dist/sandbox/sandbox.service.js +1255 -407
- package/dist/sandbox/unreachable.d.ts +30 -0
- package/dist/sandbox/unreachable.js +108 -0
- package/dist/schedules/calendar.d.ts +134 -0
- package/dist/schedules/calendar.js +410 -0
- package/dist/schedules/effective-settings.d.ts +16 -0
- package/dist/schedules/effective-settings.js +17 -0
- package/dist/schedules/errors.d.ts +8 -0
- package/dist/schedules/errors.js +8 -0
- package/dist/schedules/fire.d.ts +137 -0
- package/dist/schedules/fire.js +697 -0
- package/dist/schedules/grant-rules.d.ts +118 -0
- package/dist/schedules/grant-rules.js +184 -0
- package/dist/schedules/job-ids.d.ts +81 -0
- package/dist/schedules/job-ids.js +95 -0
- package/dist/schedules/pause.d.ts +9 -0
- package/dist/schedules/pause.js +33 -0
- package/dist/schedules/run-tracker.d.ts +76 -0
- package/dist/schedules/run-tracker.js +321 -0
- package/dist/schedules/scan.job.d.ts +45 -0
- package/dist/schedules/scan.job.js +189 -0
- package/dist/schedules/schedule-math.d.ts +73 -0
- package/dist/schedules/schedule-math.js +275 -0
- package/dist/schedules/scheduled-tasks.service.d.ts +362 -0
- package/dist/schedules/scheduled-tasks.service.js +1246 -0
- package/dist/schedules/schedules.controller.d.ts +72 -0
- package/dist/schedules/schedules.controller.js +256 -0
- package/dist/schedules/schedules.module.d.ts +16 -0
- package/dist/schedules/schedules.module.js +61 -0
- package/dist/schedules/schedules.schemas.d.ts +351 -0
- package/dist/schedules/schedules.schemas.js +213 -0
- package/dist/schedules/store.d.ts +86 -0
- package/dist/schedules/store.js +410 -0
- package/dist/schedules/store.module.d.ts +6 -0
- package/dist/schedules/store.module.js +21 -0
- package/dist/schedules/types.d.ts +110 -0
- package/dist/schedules/types.js +1 -0
- package/dist/schedules/unattended.d.ts +87 -0
- package/dist/schedules/unattended.js +184 -0
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +296 -0
- package/dist/setup/oauth-token-probe.d.ts +40 -0
- package/dist/setup/oauth-token-probe.js +96 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/skills/agent-skills.controller.d.ts +48 -0
- package/dist/skills/agent-skills.controller.js +131 -0
- package/dist/skills/agent-skills.service.d.ts +258 -0
- package/dist/skills/agent-skills.service.js +961 -0
- package/dist/skills/catalog.d.ts +80 -70
- package/dist/skills/catalog.js +136 -241
- package/dist/skills/changes.controller.d.ts +12 -22
- package/dist/skills/changes.controller.js +27 -56
- package/dist/skills/changes.service.d.ts +69 -115
- package/dist/skills/changes.service.js +249 -599
- package/dist/skills/conversation-catalog.d.ts +53 -0
- package/dist/skills/conversation-catalog.js +142 -0
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invocation-keys.d.ts +1 -1
- package/dist/skills/invocation-keys.js +1 -1
- package/dist/skills/invoke.d.ts +4 -4
- package/dist/skills/invoke.js +16 -4
- package/dist/skills/package.d.ts +15 -1
- package/dist/skills/package.js +14 -1
- package/dist/skills/skills.controller.d.ts +35 -7
- package/dist/skills/skills.controller.js +64 -11
- package/dist/skills/skills.module.js +25 -3
- package/dist/skills/skills.schemas.d.ts +44 -0
- package/dist/skills/skills.schemas.js +68 -0
- package/dist/skills/skills.service.d.ts +158 -60
- package/dist/skills/skills.service.js +640 -162
- package/dist/skills/usable.d.ts +131 -0
- package/dist/skills/usable.js +522 -0
- package/dist/themes/render-css.d.ts +13 -0
- package/dist/themes/render-css.js +135 -0
- package/dist/themes/theme-delivery.service.d.ts +36 -0
- package/dist/themes/theme-delivery.service.js +116 -0
- package/dist/themes/theme-state.d.ts +116 -0
- package/dist/themes/theme-state.js +221 -0
- package/dist/themes/theme-usage.d.ts +61 -0
- package/dist/themes/theme-usage.js +98 -0
- package/dist/themes/themes-public.controller.d.ts +33 -0
- package/dist/themes/themes-public.controller.js +98 -0
- package/dist/themes/themes.controller.d.ts +13 -0
- package/dist/themes/themes.controller.js +38 -0
- package/dist/themes/themes.module.d.ts +3 -0
- package/dist/themes/themes.module.js +21 -0
- package/dist/themes/themes.schemas.d.ts +3 -0
- package/dist/themes/themes.schemas.js +2 -0
- package/dist/themes/themes.service.d.ts +50 -0
- package/dist/themes/themes.service.js +99 -0
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/admin-connectors.d.ts +69 -0
- package/dist/tools/admin-connectors.js +135 -0
- package/dist/tools/approvals.controller.d.ts +4 -2
- package/dist/tools/approvals.controller.js +19 -5
- package/dist/tools/approvals.schemas.d.ts +22 -0
- package/dist/tools/approvals.schemas.js +17 -0
- package/dist/tools/approvals.service.d.ts +479 -19
- package/dist/tools/approvals.service.js +1472 -34
- package/dist/tools/builtin-names.d.ts +78 -22
- package/dist/tools/builtin-names.js +130 -28
- package/dist/tools/builtins/agent.d.ts +23 -21
- package/dist/tools/builtins/agent.js +62 -55
- package/dist/tools/builtins/ask-user.js +3 -2
- package/dist/tools/builtins/builtin-tools.d.ts +29 -3
- package/dist/tools/builtins/builtin-tools.js +102 -11
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/handback.d.ts +28 -0
- package/dist/tools/builtins/handback.js +53 -0
- package/dist/tools/builtins/platform.d.ts +51 -0
- package/dist/tools/builtins/platform.js +451 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +3 -3
- package/dist/tools/builtins/sandbox/bash.js +290 -18
- package/dist/tools/builtins/sandbox/common.d.ts +162 -37
- package/dist/tools/builtins/sandbox/common.js +273 -63
- package/dist/tools/builtins/sandbox/deliver.js +9 -6
- package/dist/tools/builtins/sandbox/device-code.d.ts +40 -0
- package/dist/tools/builtins/sandbox/device-code.js +57 -0
- package/dist/tools/builtins/sandbox/edit.js +48 -39
- package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
- package/dist/tools/builtins/sandbox/file-state.js +33 -3
- package/dist/tools/builtins/sandbox/glob.js +16 -9
- package/dist/tools/builtins/sandbox/grep.js +12 -9
- package/dist/tools/builtins/sandbox/index.d.ts +9 -4
- package/dist/tools/builtins/sandbox/index.js +15 -4
- package/dist/tools/builtins/sandbox/read.js +12 -7
- package/dist/tools/builtins/sandbox/task-list.d.ts +12 -0
- package/dist/tools/builtins/sandbox/task-list.js +130 -0
- package/dist/tools/builtins/sandbox/task-output.d.ts +110 -0
- package/dist/tools/builtins/sandbox/task-output.js +401 -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 +41 -33
- package/dist/tools/builtins/schedules.d.ts +109 -0
- package/dist/tools/builtins/schedules.js +947 -0
- 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 +27 -16
- package/dist/tools/builtins/skill-load.js +97 -61
- package/dist/tools/builtins/tool-search.js +4 -3
- 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 +60 -0
- package/dist/tools/builtins/web/extract.js +268 -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/connector-account-policies.d.ts +59 -0
- package/dist/tools/connector-account-policies.js +173 -0
- package/dist/tools/connectors.controller.d.ts +76 -9
- package/dist/tools/connectors.controller.js +138 -17
- package/dist/tools/connectors.schemas.d.ts +27 -0
- package/dist/tools/connectors.schemas.js +34 -0
- package/dist/tools/connectors.service.d.ts +147 -11
- package/dist/tools/connectors.service.js +357 -30
- package/dist/tools/credentials.d.ts +41 -0
- package/dist/tools/credentials.js +150 -1
- package/dist/tools/credentials.module.d.ts +7 -0
- package/dist/tools/credentials.module.js +22 -0
- package/dist/tools/device-op-resolver.d.ts +40 -0
- package/dist/tools/device-op-resolver.js +121 -0
- package/dist/tools/elicitation.d.ts +2 -0
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/extension-tools.controller.d.ts +14 -0
- package/dist/tools/extension-tools.controller.js +37 -0
- package/dist/tools/fixed-ask.d.ts +7 -0
- package/dist/tools/fixed-ask.js +9 -0
- package/dist/tools/git-asks.d.ts +113 -0
- package/dist/tools/git-asks.js +174 -0
- package/dist/tools/git-push-policy.d.ts +89 -0
- package/dist/tools/git-push-policy.js +175 -0
- package/dist/tools/info.d.ts +45 -4
- package/dist/tools/info.js +67 -4
- package/dist/tools/legacy-keys.js +0 -1
- package/dist/tools/network-asks.d.ts +115 -0
- package/dist/tools/network-asks.js +223 -0
- package/dist/tools/oauth/discovery.d.ts +38 -16
- package/dist/tools/oauth/discovery.js +59 -33
- package/dist/tools/oauth/flow-paths.d.ts +1 -1
- package/dist/tools/oauth/flow-paths.js +1 -1
- package/dist/tools/oauth/flow.js +1 -1
- package/dist/tools/oauth/tokens.d.ts +54 -7
- package/dist/tools/oauth/tokens.js +87 -17
- package/dist/tools/org-tool-switches.d.ts +89 -0
- package/dist/tools/org-tool-switches.js +201 -0
- package/dist/tools/pipeline.d.ts +173 -51
- package/dist/tools/pipeline.js +797 -390
- package/dist/tools/policy.d.ts +46 -13
- package/dist/tools/policy.js +187 -49
- package/dist/tools/questions.service.d.ts +50 -9
- package/dist/tools/questions.service.js +128 -12
- package/dist/tools/registry.d.ts +207 -54
- package/dist/tools/registry.js +312 -212
- package/dist/tools/tools.module.js +51 -5
- package/dist/tools/validate.js +1 -1
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +65 -0
- package/dist/ui/arrangement.js +171 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +42 -17
- package/dist/ui/registry.js +46 -14
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +70 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +112 -18
- package/dist/ui/views.js +254 -47
- package/package.json +6 -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/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/src/migrations/0093_connected_environments.sql +37 -0
- package/src/migrations/0094_environment_paths_idx.sql +7 -0
- package/src/migrations/0095_environment_files_resets.sql +5 -0
- package/src/migrations/0096_environment_demoted_default.sql +18 -0
- package/src/migrations/0097_extension_installs_enabled_at.sql +16 -0
- package/src/migrations/0098_single_provider_running_first.sql +41 -0
- package/src/migrations/0099_channel_connection_guide_ack.sql +6 -0
- package/src/migrations/0100_catalog_files.sql +13 -0
- package/src/migrations/0101_marketplace_icons.sql +32 -0
- package/src/migrations/0102_themes.sql +64 -0
- package/src/migrations/0103_ui_theme_setting.sql +7 -0
- package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/src/migrations/0107_extension_client_builds.sql +50 -0
- package/src/migrations/0108_question_skipped.sql +6 -0
- package/src/migrations/0109_audit_platform_idx.sql +5 -0
- package/src/migrations/0110_usage_time_idx.sql +8 -0
- package/src/migrations/0111_agent_skill_sharing.sql +22 -0
- package/src/migrations/0112_skill_share_requests.sql +4 -0
- package/src/migrations/0113_scheduled_tasks.sql +108 -0
- package/src/migrations/0114_network_asks.sql +23 -0
- package/src/migrations/0115_network_requests.sql +28 -0
- package/src/migrations/0116_skills_default_on.sql +37 -0
- package/src/migrations/0117_sandbox_tiers.sql +11 -0
- package/src/migrations/0118_device_policy_ops.sql +6 -0
- package/src/migrations/0119_outbox.sql +22 -0
- package/src/migrations/0120_drop_usage_report_sweep.sql +7 -0
- package/src/migrations/0121_drop_platform_migration_runs.sql +12 -0
- package/src/migrations/0122_drop_scheduled_task_runs_rechecked_at.sql +5 -0
- package/src/migrations/0123_pgvector.sql +27 -0
- package/src/migrations/0124_conversation_source.sql +36 -0
- package/src/migrations/0125_conversation_tree_stopped_at.sql +5 -0
- package/src/migrations/0126_git_gateway.sql +10 -0
- package/src/migrations/0127_git_push_policy.sql +12 -0
- package/src/migrations/0128_scheduled_task_plugin_disabled.sql +10 -0
- package/src/migrations/0129_connector_plugin_disabled.sql +5 -0
- package/src/migrations/0130_auto_mode.sql +48 -0
- package/src/migrations/0131_device_mode.sql +9 -0
- package/src/migrations/0132_compact_runs.sql +6 -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
- package/dist/tools/builtins/skill-write.d.ts +0 -59
- package/dist/tools/builtins/skill-write.js +0 -244
|
@@ -8,14 +8,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
11
|
-
import { PLUGIN_MANIFEST_FILE, parseSkillMd, SDK_VERSION, SKILL_ENTRY_FILE, } from "@capybara-hq/plugin-sdk";
|
|
12
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { appearanceIssues, PLUGIN_MANIFEST_FILE, parseSkillMd, pluginDescription, SDK_VERSION, SKILL_ENTRY_FILE, } from "@capybara-hq/plugin-sdk";
|
|
12
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import semver from "semver";
|
|
15
|
+
import { ClientBuilds } from "../client/client-builds.service.js";
|
|
16
|
+
import { checkClientFiles } from "../client/client-files.js";
|
|
15
17
|
import { ApiError } from "../errors.js";
|
|
16
18
|
import { ExtensionAdminOps } from "../extensions/admin-ops.js";
|
|
19
|
+
import { ExtensionAdmin } from "../extensions/admin-view.js";
|
|
17
20
|
import { writeSnapshot } from "../extensions/approvals.js";
|
|
18
|
-
import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
21
|
+
import { blobKey, ExtensionBlobs } from "../extensions/blobs.js";
|
|
19
22
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
20
23
|
import { PluginApproveLock, PluginInstallLock } from "../extensions/locks.js";
|
|
21
24
|
import { unrunMigrations } from "../extensions/migrate-lock.js";
|
|
@@ -24,28 +27,39 @@ import { diffPermissions, permissionKeys, WARNINGS_KEY_PREFIX, } from "../extens
|
|
|
24
27
|
import { reviewHash as extensionReviewHash, migrationWarnings, permissionGroups, permissionKeyItems, } from "../extensions/permission-view.js";
|
|
25
28
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
26
29
|
import { audit } from "../identity/audit.js";
|
|
27
|
-
import {
|
|
30
|
+
import { assertCustomAllowed } from "../identity/settings.js";
|
|
31
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
28
32
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
33
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
29
34
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
30
35
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
31
36
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
37
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
32
38
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
39
|
+
import { OrgLock } from "../orgs/org-lock.js";
|
|
33
40
|
import { packPackageTgz } from "../packages/tgz.js";
|
|
34
41
|
import { checkSkillFiles, SkillArchiveError } from "../skills/package.js";
|
|
35
42
|
import { StorageService } from "../storage/storage.service.js";
|
|
43
|
+
import { canonicalJson } from "../tools/canonical-json.js";
|
|
36
44
|
import { endpointCredentialIssues } from "../tools/endpoint.js";
|
|
37
|
-
import { canonicalJson } from "../tools/registry.js";
|
|
38
45
|
import { findConnectorIn } from "./catalog-content.js";
|
|
39
|
-
import {
|
|
46
|
+
import { displayFilePaths, putDisplayFiles, sweepDisplayFiles } from "./catalog-files.js";
|
|
47
|
+
import { assertOrgsExist, assertPluginNameOwner, catalogObjectPrefix, itemConfirmations, itemScopeFacts, itemView, markVersionApplied, permissionsMismatch, precheckCatalogImport, putCatalogFiles, templateProblems, unappliedOwnVersion, writeCatalogVersion, } from "./catalog-items.js";
|
|
40
48
|
import { CLAUDE_PLUGIN_FILE, claudeContentDigest, } from "./claude/manifest.js";
|
|
41
49
|
import { CLAUDE_MCP_CONNECTOR } from "./claude/mcp.js";
|
|
42
50
|
import { item as reportItem, sortItems, } from "./claude/report.js";
|
|
43
51
|
import { isClaudePluginTree, translateClaudePlugin } from "./claude/translate.js";
|
|
44
52
|
import { CatalogItemLock } from "./locks.js";
|
|
45
|
-
import {
|
|
53
|
+
import { assertNameFree, assertPackageFree, assertShareable, packageOwner, releaseExtensionClaim, shareGate, usableBy, } from "./ownership.js";
|
|
54
|
+
import { PlanStale, PlatformComponents } from "./platform-components.js";
|
|
55
|
+
import { PluginPackageError, readPluginFiles, readPluginPackage, themeApiError, } from "./plugin-package.js";
|
|
56
|
+
import { hasImportRequests, importRequestOf, resolveImportRequests } from "./request-rules.js";
|
|
57
|
+
import { assertNameNotReserved } from "./reserved-names.js";
|
|
58
|
+
import { oweScopeItem, SCOPE_BACKSTOP_DELAY, SCOPE_BACKSTOP_DELAY_MS } from "./scope-jobs.js";
|
|
59
|
+
import { addScopeOrg } from "./scope-orgs.js";
|
|
46
60
|
import { maxSatisfying, satisfiesRange } from "./versions.js";
|
|
47
61
|
/**
|
|
48
|
-
*
|
|
62
|
+
* Platform import of a plugin (package ecosystem spec §4.3): one review for every plugin, whatever
|
|
49
63
|
* it contains (an extension, skills, connector templates, dependencies), confirmed once.
|
|
50
64
|
*
|
|
51
65
|
* prepare: the tgz is always hostile input, and **nothing is written until every check passes**
|
|
@@ -55,27 +69,32 @@ import { maxSatisfying, satisfiesRange } from "./versions.js";
|
|
|
55
69
|
* refused; name ownership; a downgrade to a version with unrun migrations is refused), each skill by
|
|
56
70
|
* the skill package rules, each connector template against the connector loaded on this replica (or
|
|
57
71
|
* statically when the connector is provided by the plugin's own extension or by a dependency), the
|
|
58
|
-
* catalog name / version conflicts and the actor still
|
|
72
|
+
* catalog name / version conflicts and the actor still a super admin. Dependencies are only
|
|
59
73
|
* resolved against the imported catalog versions for the review (an unresolved one does not block
|
|
60
74
|
* the import, spec §4.1); they are never fetched. Only then is the extension handed to
|
|
61
|
-
* `ExtensionInstalls.ingest` (source `catalog`), the skill / template
|
|
62
|
-
* storage,
|
|
75
|
+
* `ExtensionInstalls.ingest` (source `catalog`), the skill / template files written to object
|
|
76
|
+
* storage, the display files (icons, setup guide files; `catalog-files.ts`) written to PG with a
|
|
77
|
+
* staging row (24 hours), and `catalog.plugin_staged` audited. A display file inside a skill
|
|
78
|
+
* directory or at a template's path goes to both places: each reader finds it where it looks.
|
|
63
79
|
*
|
|
64
80
|
* confirm: `reviewHash` must match the staging; in one transaction it deletes the staging row
|
|
65
81
|
* (confirm works once), locks the extension name and recomputes its deployment state (installed /
|
|
66
82
|
* upgraded / swapped after the review -> `plugin.review_stale`), writes the extension's permission
|
|
67
|
-
* snapshot when it is installed by this import (
|
|
68
|
-
* `extension.permissions_approved` carrying the plugin), and creates the item
|
|
69
|
-
* (`manifest` = the normalized plugin.json,
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
83
|
+
* snapshot when it is installed or upgraded by this import (source web, audit
|
|
84
|
+
* `extension.permissions_approved` carrying the plugin), and creates the item (with the scope the
|
|
85
|
+
* admin chose, default `optional`) or adds the version (`manifest` = the normalized plugin.json,
|
|
86
|
+
* `extension_sha256`, the files under the staging prefix); an item's first usable version also
|
|
87
|
+
* gets its platform component rows there (their files copied before, keyed by content: a failure
|
|
88
|
+
* leaves nothing a retry copies again; no job heals an item later). After the commit the plugin's
|
|
89
|
+
* own extension is installed on the deployment and enabled (`ExtensionAdminOps.install` + `enable`;
|
|
90
|
+
* each replica reconciles, no restart); a failure is returned, not thrown, and an upgrade that was
|
|
91
|
+
* not installed gets its old snapshot back.
|
|
74
92
|
*
|
|
75
93
|
* Expired staging is cleaned by the maintenance job `app-staging-cleanup`
|
|
76
|
-
* ({@link PluginImport.cleanupExpired}): it deletes the staging row and its object prefix
|
|
77
|
-
*
|
|
78
|
-
*
|
|
94
|
+
* ({@link PluginImport.cleanupExpired}): it deletes the staging row and its object prefix, then the
|
|
95
|
+
* display files (`catalog_files`) nothing lists any more; a stored extension package stays in the
|
|
96
|
+
* content-addressed `extension_packages` (the same as importing the same tgz again; without an
|
|
97
|
+
* install record referencing it it is never loaded).
|
|
79
98
|
*/
|
|
80
99
|
/** How long a staged import is kept. */
|
|
81
100
|
export const PLUGIN_STAGING_TTL_MS = 24 * 3600_000;
|
|
@@ -94,12 +113,20 @@ const reviewStale = (review) => new ApiError("plugin.review_stale", `The review
|
|
|
94
113
|
const mismatch = (what) => new ApiError("marketplace.package_mismatch", `The downloaded package does not match the marketplace entry: ${what}`);
|
|
95
114
|
/**
|
|
96
115
|
* The API error of a plugin package that cannot be read in a catalog path: the pre-0.1.0 format ->
|
|
97
|
-
* `catalog.legacy_format
|
|
116
|
+
* `catalog.legacy_format`; undeclared client code -> `client.undeclared`; a failing theme (themes
|
|
117
|
+
* spec §5) -> `theme.invalid` (details `[{ theme, errors }]`) or `theme.unreadable` (details
|
|
118
|
+
* `[{ theme, issues }]`, the failing pairs); anything else -> `catalog.invalid_manifest` (issues as
|
|
119
|
+
* details).
|
|
98
120
|
*/
|
|
99
121
|
export function catalogPackageError(e) {
|
|
100
122
|
const legacy = e.code === "catalog.legacy_format" || e.code === "extension.legacy_format";
|
|
101
123
|
if (legacy)
|
|
102
124
|
return new ApiError("catalog.legacy_format", e.message, e.issues);
|
|
125
|
+
if (e.code === "client.undeclared")
|
|
126
|
+
return new ApiError("client.undeclared", e.message);
|
|
127
|
+
if (e.code === "theme.invalid" || e.code === "theme.unreadable") {
|
|
128
|
+
return themeApiError(e);
|
|
129
|
+
}
|
|
103
130
|
return invalid(e.issues);
|
|
104
131
|
}
|
|
105
132
|
/** Runs a package read, mapping its errors with {@link catalogPackageError}. */
|
|
@@ -123,16 +150,22 @@ const fileOf = (path, data) => ({
|
|
|
123
150
|
let PluginImport = class PluginImport {
|
|
124
151
|
kdb;
|
|
125
152
|
adminLock;
|
|
153
|
+
orgLock;
|
|
126
154
|
installLock;
|
|
127
155
|
approveLock;
|
|
128
156
|
itemLock;
|
|
129
157
|
config;
|
|
130
158
|
installs;
|
|
131
159
|
ops;
|
|
160
|
+
admin;
|
|
132
161
|
blobs;
|
|
133
162
|
registry;
|
|
134
163
|
log;
|
|
135
164
|
txHost;
|
|
165
|
+
platform;
|
|
166
|
+
clientBuilds;
|
|
167
|
+
outbox;
|
|
168
|
+
backstopDelayMs;
|
|
136
169
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
137
170
|
files;
|
|
138
171
|
/**
|
|
@@ -142,24 +175,40 @@ let PluginImport = class PluginImport {
|
|
|
142
175
|
*/
|
|
143
176
|
connectorsLoaded = true;
|
|
144
177
|
constructor(kdb,
|
|
145
|
-
/** The
|
|
146
|
-
adminLock,
|
|
178
|
+
/** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
|
|
179
|
+
adminLock,
|
|
180
|
+
/** The owner org's lock: an org upload re-checks its admin under it (ruling P3-7). */
|
|
181
|
+
orgLock, installLock, approveLock, itemLock, config, storage, installs, ops, admin,
|
|
147
182
|
/** Reads a package from the package store (confirm recomputes the permission set). */
|
|
148
183
|
blobs,
|
|
149
184
|
/** Config-declared names, loaded connectors and extension versions (the extension registry). */
|
|
150
|
-
registry, log, txHost
|
|
185
|
+
registry, log, txHost,
|
|
186
|
+
/** The platform rows of a new item's components, written in the confirm's transaction. */
|
|
187
|
+
platform,
|
|
188
|
+
/** The client build of a dropped org upload's package is deleted with it. */
|
|
189
|
+
clientBuilds,
|
|
190
|
+
/** The scope sync's backstop, owed by the confirm's commit (ruling R24). */
|
|
191
|
+
outbox,
|
|
192
|
+
/** The backstop's delay (a test seam; default `SCOPE_BACKSTOP_DELAY_MS`). */
|
|
193
|
+
backstopDelayMs = SCOPE_BACKSTOP_DELAY_MS) {
|
|
151
194
|
this.kdb = kdb;
|
|
152
195
|
this.adminLock = adminLock;
|
|
196
|
+
this.orgLock = orgLock;
|
|
153
197
|
this.installLock = installLock;
|
|
154
198
|
this.approveLock = approveLock;
|
|
155
199
|
this.itemLock = itemLock;
|
|
156
200
|
this.config = config;
|
|
157
201
|
this.installs = installs;
|
|
158
202
|
this.ops = ops;
|
|
203
|
+
this.admin = admin;
|
|
159
204
|
this.blobs = blobs;
|
|
160
205
|
this.registry = registry;
|
|
161
206
|
this.log = log;
|
|
162
207
|
this.txHost = txHost;
|
|
208
|
+
this.platform = platform;
|
|
209
|
+
this.clientBuilds = clientBuilds;
|
|
210
|
+
this.outbox = outbox;
|
|
211
|
+
this.backstopDelayMs = backstopDelayMs;
|
|
163
212
|
this.files = storage;
|
|
164
213
|
}
|
|
165
214
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
@@ -174,21 +223,29 @@ let PluginImport = class PluginImport {
|
|
|
174
223
|
useCliStorage(storage) {
|
|
175
224
|
this.files = storage;
|
|
176
225
|
this.connectorsLoaded = false;
|
|
226
|
+
this.platform.useCliStorage(storage);
|
|
177
227
|
}
|
|
178
228
|
/**
|
|
179
|
-
* The
|
|
229
|
+
* The super-admin re-check under the lock, in the caller's transaction. `actor` null is the
|
|
180
230
|
* CLI (the operator of the deployment: no account to re-check, audits carry no actor), like
|
|
181
|
-
* `ExtensionInstalls.ingest`.
|
|
231
|
+
* `ExtensionInstalls.ingest`. An org upload (`owner`) re-checks the actor as an admin of the
|
|
232
|
+
* owner org under the org row lock instead (`catalog.upload`; an org deleted meanwhile -> 404
|
|
233
|
+
* `org.not_found`).
|
|
182
234
|
*/
|
|
183
|
-
async authorizeActor(actor) {
|
|
184
|
-
if (
|
|
235
|
+
async authorizeActor(actor, owner) {
|
|
236
|
+
if (owner !== undefined) {
|
|
237
|
+
if (actor === null)
|
|
238
|
+
throw new Error("an org upload has an actor");
|
|
239
|
+
await this.orgLock.lockAndAuthorize(owner.orgId, actor, "catalog.upload");
|
|
240
|
+
}
|
|
241
|
+
else if (actor === null)
|
|
185
242
|
await this.adminLock.lock();
|
|
186
243
|
else
|
|
187
244
|
await this.adminLock.lockAndAuthorize(actor);
|
|
188
245
|
}
|
|
189
246
|
/** The re-check alone, in a transaction of its own (before anything is written). */
|
|
190
|
-
async authorize(actor) {
|
|
191
|
-
await this.authorizeActor(actor);
|
|
247
|
+
async authorize(actor, owner) {
|
|
248
|
+
await this.authorizeActor(actor, owner);
|
|
192
249
|
}
|
|
193
250
|
/**
|
|
194
251
|
* Reads, checks and stages a plugin (see the file header). Returns the staging id and review.
|
|
@@ -279,6 +336,10 @@ let PluginImport = class PluginImport {
|
|
|
279
336
|
*/
|
|
280
337
|
async prepareContents(actor, pkg, tgz, source, opts) {
|
|
281
338
|
const maxBytes = this.config.get().packages.maxBytes;
|
|
339
|
+
const owner = opts.owner;
|
|
340
|
+
if (owner !== undefined && source.kind !== "file") {
|
|
341
|
+
throw new Error("an org upload is a file (ruling P3-7)");
|
|
342
|
+
}
|
|
282
343
|
// 1. Every check (nothing written)
|
|
283
344
|
const m = pkg.manifest;
|
|
284
345
|
const packageName = packageNameOf(pkg);
|
|
@@ -292,14 +353,50 @@ let PluginImport = class PluginImport {
|
|
|
292
353
|
? await readingPackage(() => readExtensionPackage(bytes, { maxBytes, hostSdkVersion: SDK_VERSION }))
|
|
293
354
|
: undefined;
|
|
294
355
|
const content = this.checkContent(pkg, format);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
356
|
+
// suggestedAppearance.theme against the themes the scan found (the manifest may not list them)
|
|
357
|
+
const appearance = appearanceIssues(m, pkg.themes.map((t) => t.id));
|
|
358
|
+
if (appearance.length > 0)
|
|
359
|
+
throw invalid(appearance);
|
|
360
|
+
// Client code (client extensions spec §9.1): the section re-checked and every file against it
|
|
361
|
+
// (keys, listed = present, sizes, sha384 recomputed, the CSS layer wrap); delivered from object
|
|
362
|
+
// storage, so refused without one. The store checks the bytes it writes again. A bootstrap
|
|
363
|
+
// plugin never carries it: a bootstrap run may have no object store (it may be a bootstrap
|
|
364
|
+
// plugin itself), and a required entry failing on that would stop the start.
|
|
365
|
+
if (ext?.section.client !== undefined) {
|
|
366
|
+
if (source.kind === "bootstrap") {
|
|
367
|
+
throw new ApiError("client.invalid", `Bootstrap plugin ${m.name} ships client code (extension.client), which a bootstrap plugin may not carry: its files are kept in object storage, which a bootstrap run may not have (the object store may be a bootstrap plugin itself); take ${m.name} out of bootstrap.json and import it into the catalog instead`);
|
|
368
|
+
}
|
|
369
|
+
checkClientFiles(ext.section.client, pkg.files);
|
|
370
|
+
this.files.assertAvailable();
|
|
371
|
+
}
|
|
372
|
+
// A name live for another owner (an org's for the super admin; the platform's or another
|
|
373
|
+
// org's for an org) -> 409 plugin.name_taken naming it (P3-14); the same owner adds a version
|
|
374
|
+
await assertNameFree(this.db, m.name, owner?.orgId ?? null);
|
|
375
|
+
if (owner !== undefined) {
|
|
376
|
+
// a bootstrap or marketplace plugin's name stays free for the platform (ruling P3-28)
|
|
377
|
+
await assertNameNotReserved(this.db, m.name);
|
|
378
|
+
// its npm package is an identity of this org only (ruling P3-51)
|
|
379
|
+
await assertPackageFree(this.db, packageName, owner.orgId);
|
|
380
|
+
await assertCustomContent(this.db, content);
|
|
381
|
+
}
|
|
382
|
+
// An org's own version imported but not applied: its update is retried (pre-flight F4)
|
|
383
|
+
const retry = owner !== undefined && !m.extension
|
|
384
|
+
? await unappliedOwnVersion(this.db, m.name, owner.orgId, {
|
|
385
|
+
packageName,
|
|
386
|
+
version: m.version,
|
|
387
|
+
contentDigest: pkg.contentDigest,
|
|
388
|
+
})
|
|
389
|
+
: undefined;
|
|
390
|
+
const { existing, version } = retry !== undefined
|
|
391
|
+
? { existing: { id: retry.itemId }, version: retry.version }
|
|
392
|
+
: await precheckCatalogImport(this.db, m.name, {
|
|
393
|
+
packageName,
|
|
394
|
+
version: m.version,
|
|
395
|
+
contentDigest: pkg.contentDigest,
|
|
396
|
+
...(source.integrity !== undefined && { integrity: source.integrity }),
|
|
397
|
+
...(source.detail !== undefined && { detail: source.detail }),
|
|
398
|
+
...(source.marketplaceId !== undefined && { marketplaceId: source.marketplaceId }),
|
|
399
|
+
});
|
|
303
400
|
// The catalog name space is the extension name space: a declarative plugin cannot take a
|
|
304
401
|
// config-declared or another package's extension name either
|
|
305
402
|
this.assertNotDeclared(m.name);
|
|
@@ -309,8 +406,17 @@ let PluginImport = class PluginImport {
|
|
|
309
406
|
extension = await this.reviewExtension(ext, await this.extensionState(m.name, packageName));
|
|
310
407
|
await assertDowngradable(this.db, extension, ext.migrationSql);
|
|
311
408
|
}
|
|
312
|
-
|
|
409
|
+
// Display files go to PG with the staging row; skills and templates need object storage, which a
|
|
410
|
+
// bootstrap import never has (the object store may be a bootstrap plugin itself). A file that is
|
|
411
|
+
// both (an icon inside a skill directory) goes to both: the readers of each look only there
|
|
412
|
+
const displayFiles = content.files.filter((f) => content.displayPaths.has(f.path));
|
|
413
|
+
const objectFiles = content.files.filter((f) => content.objectPaths.has(f.path));
|
|
414
|
+
if (objectFiles.length > 0 && retry === undefined) {
|
|
415
|
+
if (source.kind === "bootstrap" && !this.files.available) {
|
|
416
|
+
throw new ApiError("storage.unavailable", `Bootstrap plugin ${m.name} ships skills, connector templates, agent templates or themes, which are kept in object storage, and object storage is not running yet (it may be a bootstrap plugin itself); a required bootstrap plugin may ship only an icon and setup guides, an optional one is retried once the extensions have loaded`);
|
|
417
|
+
}
|
|
313
418
|
this.files.assertAvailable();
|
|
419
|
+
}
|
|
314
420
|
const src = {
|
|
315
421
|
kind: source.kind,
|
|
316
422
|
ref: source.ref,
|
|
@@ -318,7 +424,7 @@ let PluginImport = class PluginImport {
|
|
|
318
424
|
...(source.marketplaceId !== undefined && { marketplaceId: source.marketplaceId }),
|
|
319
425
|
...(source.detail !== undefined && { detail: source.detail }),
|
|
320
426
|
};
|
|
321
|
-
const dependencies = await this.resolveDependencies(m);
|
|
427
|
+
const dependencies = await this.resolveDependencies(m, owner);
|
|
322
428
|
let translation;
|
|
323
429
|
if (opts.claude !== undefined) {
|
|
324
430
|
const added = [
|
|
@@ -348,7 +454,8 @@ let PluginImport = class PluginImport {
|
|
|
348
454
|
contentDigest: pkg.contentDigest,
|
|
349
455
|
packageName,
|
|
350
456
|
publisher: m.publisher,
|
|
351
|
-
description: m.description,
|
|
457
|
+
description: pluginDescription(m.description).en,
|
|
458
|
+
descriptionZh: pluginDescription(m.description).zh ?? null,
|
|
352
459
|
...(m.displayName !== undefined && { displayName: m.displayName }),
|
|
353
460
|
...(m.license !== undefined && { license: m.license }),
|
|
354
461
|
...(m.homepage !== undefined && { homepage: m.homepage }),
|
|
@@ -356,6 +463,7 @@ let PluginImport = class PluginImport {
|
|
|
356
463
|
skills: content.skills,
|
|
357
464
|
connectorTemplates: content.templates,
|
|
358
465
|
...(content.agentTemplates.length > 0 && { agentTemplates: content.agentTemplates }),
|
|
466
|
+
...(content.themes.length > 0 && { themes: content.themes }),
|
|
359
467
|
dependencies,
|
|
360
468
|
source: src,
|
|
361
469
|
provenance: (opts.provenance ?? NOT_NPM).provenance,
|
|
@@ -364,8 +472,9 @@ let PluginImport = class PluginImport {
|
|
|
364
472
|
reviewHash: "",
|
|
365
473
|
};
|
|
366
474
|
review.reviewHash = pluginReviewHash(review, content.files);
|
|
367
|
-
// Re-check under the lock that the actor is still an
|
|
368
|
-
|
|
475
|
+
// Re-check under the lock that the actor is still a super admin (an org upload: an admin of
|
|
476
|
+
// the owner org) before writing
|
|
477
|
+
await this.authorize(actor, owner);
|
|
369
478
|
// 2. Write: the extension into the package store, files into object storage, the staging row
|
|
370
479
|
const stagingId = randomUUID();
|
|
371
480
|
const itemId = existing?.id ?? randomUUID();
|
|
@@ -379,12 +488,14 @@ let PluginImport = class PluginImport {
|
|
|
379
488
|
}, {
|
|
380
489
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
381
490
|
...(bootstrap && { store: "pg" }),
|
|
491
|
+
// an org upload only stores the package (nothing runs until the super admin confirms)
|
|
492
|
+
...(owner !== undefined && { owner }),
|
|
382
493
|
});
|
|
383
494
|
}
|
|
384
495
|
let objectPrefix = null;
|
|
385
|
-
if (
|
|
496
|
+
if (objectFiles.length > 0 && retry === undefined) {
|
|
386
497
|
objectPrefix = catalogObjectPrefix(itemId, version, stagingId);
|
|
387
|
-
await putCatalogFiles(this.files, objectPrefix,
|
|
498
|
+
await putCatalogFiles(this.files, objectPrefix, objectFiles);
|
|
388
499
|
}
|
|
389
500
|
const keys = ext
|
|
390
501
|
? permissionKeys(permissionSetOfPackage(ext))
|
|
@@ -392,28 +503,34 @@ let PluginImport = class PluginImport {
|
|
|
392
503
|
.sort()
|
|
393
504
|
: [];
|
|
394
505
|
const mismatch = permissionsMismatch(opts.expect?.marketplace?.permissions, ext ? keys : undefined);
|
|
506
|
+
const manifest = normalizedManifest(pkg);
|
|
507
|
+
const replacements = manifest.suggestedAppearance?.replacements;
|
|
395
508
|
const staged = {
|
|
396
509
|
itemId,
|
|
397
510
|
packageName,
|
|
398
511
|
version,
|
|
399
512
|
contentDigest: pkg.contentDigest,
|
|
400
513
|
size: tgz.size,
|
|
401
|
-
manifest
|
|
514
|
+
manifest,
|
|
515
|
+
...(replacements !== undefined && { appearanceOrder: Object.keys(replacements) }),
|
|
402
516
|
files: content.files.map(({ path, size, sha256 }) => ({ path, size, sha256 })),
|
|
403
517
|
...(mismatch !== null && { permissionsMismatch: mismatch }),
|
|
404
518
|
sourceFormat: format,
|
|
405
519
|
...(translation !== undefined && { translation }),
|
|
406
520
|
...(license.text !== undefined && { licenseText: license.text }),
|
|
407
521
|
...(license.truncated && { licenseTruncated: true }),
|
|
522
|
+
...(retry !== undefined && { retry: true }),
|
|
408
523
|
};
|
|
409
|
-
await this.writeStaging(actor, stagingId, review, staged, objectPrefix, src, opts);
|
|
524
|
+
await this.writeStaging(actor, stagingId, review, staged, objectPrefix, src, opts, owner, displayFiles);
|
|
410
525
|
return { stagingId, review, permissionKeys: keys, permissionsMismatch: mismatch };
|
|
411
526
|
}
|
|
412
527
|
/** The staging row and the `catalog.plugin_staged` audit, the actor re-checked under the lock. */
|
|
413
|
-
async writeStaging(actor, stagingId, review, staged, objectPrefix, src, opts) {
|
|
528
|
+
async writeStaging(actor, stagingId, review, staged, objectPrefix, src, opts, owner, displayFiles) {
|
|
414
529
|
const { extension } = review;
|
|
415
530
|
const t = this.db;
|
|
416
|
-
await this.authorizeActor(actor);
|
|
531
|
+
await this.authorizeActor(actor, owner);
|
|
532
|
+
// committed with the staging row that lists them (the sweep keeps what a staging lists)
|
|
533
|
+
await putDisplayFiles(t, displayFiles);
|
|
417
534
|
await t
|
|
418
535
|
.insertInto("plugin_import_staging")
|
|
419
536
|
.values({
|
|
@@ -424,6 +541,8 @@ let PluginImport = class PluginImport {
|
|
|
424
541
|
source: JSON.stringify(src),
|
|
425
542
|
created_by: actor,
|
|
426
543
|
expires_at: new Date(Date.now() + PLUGIN_STAGING_TTL_MS),
|
|
544
|
+
// the org's own staging (P3-8); null = the super admin's
|
|
545
|
+
org_id: owner?.orgId ?? null,
|
|
427
546
|
})
|
|
428
547
|
.execute();
|
|
429
548
|
await audit(t, {
|
|
@@ -443,6 +562,8 @@ let PluginImport = class PluginImport {
|
|
|
443
562
|
...(extension && {
|
|
444
563
|
extension: { sha256: extension.sha256, action: extension.action },
|
|
445
564
|
}),
|
|
565
|
+
...(owner !== undefined && { orgId: owner.orgId }),
|
|
566
|
+
...opts.auditDetail,
|
|
446
567
|
},
|
|
447
568
|
});
|
|
448
569
|
}
|
|
@@ -465,9 +586,10 @@ let PluginImport = class PluginImport {
|
|
|
465
586
|
/**
|
|
466
587
|
* A staged import's review, as prepare returned it, with a marketplace import's permission
|
|
467
588
|
* mismatch when there is one (the import page loads `?staging=<id>` with it). Unknown, expired or
|
|
468
|
-
* already confirmed -> 404 `plugin.staging_not_found`.
|
|
589
|
+
* already confirmed -> 404 `plugin.staging_not_found`. Each sees only its own staging (P3-8):
|
|
590
|
+
* the super admin's routes the platform's (no `owner`), an org's routes that org's.
|
|
469
591
|
*/
|
|
470
|
-
async staged(stagingId) {
|
|
592
|
+
async staged(stagingId, owner) {
|
|
471
593
|
if (!UUID_RE.test(stagingId))
|
|
472
594
|
throw notFound();
|
|
473
595
|
const row = await this.db
|
|
@@ -475,6 +597,7 @@ let PluginImport = class PluginImport {
|
|
|
475
597
|
.select(["id", "review", "manifest"])
|
|
476
598
|
.where("id", "=", stagingId)
|
|
477
599
|
.where("expires_at", ">", sql `now()`)
|
|
600
|
+
.where(ownStaging(owner))
|
|
478
601
|
.executeTakeFirst();
|
|
479
602
|
if (!row)
|
|
480
603
|
throw notFound();
|
|
@@ -486,17 +609,119 @@ let PluginImport = class PluginImport {
|
|
|
486
609
|
};
|
|
487
610
|
}
|
|
488
611
|
/**
|
|
489
|
-
*
|
|
490
|
-
*
|
|
612
|
+
* What an org's staged upload targets (P3-12, pre-flight F3): its item, version and review hash,
|
|
613
|
+
* whether the item exists (a new version of the org's own plugin) or the version is imported
|
|
614
|
+
* already (F4), and the target as the platform updater reads it: the staged manifest and files,
|
|
615
|
+
* or the imported version's for a retry. Another org's staging -> 404 `plugin.staging_not_found`.
|
|
616
|
+
* Without `owner`: a platform staging, and `existing` means a live platform-owned item (the
|
|
617
|
+
* platform's import and update, `PlatformImportUpdate`).
|
|
618
|
+
*/
|
|
619
|
+
async stagedTarget(stagingId, owner) {
|
|
620
|
+
if (!UUID_RE.test(stagingId))
|
|
621
|
+
throw notFound();
|
|
622
|
+
const row = await this.db
|
|
623
|
+
.selectFrom("plugin_import_staging")
|
|
624
|
+
.select(["review", "manifest", "object_prefix"])
|
|
625
|
+
.where("id", "=", stagingId)
|
|
626
|
+
.where("expires_at", ">", sql `now()`)
|
|
627
|
+
.where(ownStaging(owner))
|
|
628
|
+
.executeTakeFirst();
|
|
629
|
+
if (!row)
|
|
630
|
+
throw notFound();
|
|
631
|
+
const review = row.review;
|
|
632
|
+
const staged = row.manifest;
|
|
633
|
+
const item = await this.db
|
|
634
|
+
.selectFrom("catalog_items")
|
|
635
|
+
.select(["id", "awaiting_confirmation"])
|
|
636
|
+
.where("id", "=", staged.itemId)
|
|
637
|
+
.where("deleted_at", "is", null)
|
|
638
|
+
.where((eb) => owner === undefined ? eb("owner_org_id", "is", null) : eb("owner_org_id", "=", owner.orgId))
|
|
639
|
+
.executeTakeFirst();
|
|
640
|
+
const imported = staged.retry === true
|
|
641
|
+
? await this.db
|
|
642
|
+
.selectFrom("catalog_item_versions")
|
|
643
|
+
.select(["version", "manifest", "object_prefix", "files", "extension_sha256"])
|
|
644
|
+
.where("item_id", "=", staged.itemId)
|
|
645
|
+
.where("version", "=", staged.version)
|
|
646
|
+
.executeTakeFirst()
|
|
647
|
+
: undefined;
|
|
648
|
+
return {
|
|
649
|
+
itemId: staged.itemId,
|
|
650
|
+
version: staged.version,
|
|
651
|
+
reviewHash: review.reviewHash,
|
|
652
|
+
extension: review.extension !== undefined,
|
|
653
|
+
existing: item !== undefined,
|
|
654
|
+
awaiting: item?.awaiting_confirmation === true,
|
|
655
|
+
retry: staged.retry === true,
|
|
656
|
+
target: imported !== undefined
|
|
657
|
+
? {
|
|
658
|
+
version: imported.version,
|
|
659
|
+
manifest: imported.manifest,
|
|
660
|
+
object_prefix: imported.object_prefix,
|
|
661
|
+
files: imported.files,
|
|
662
|
+
extension_sha256: imported.extension_sha256,
|
|
663
|
+
}
|
|
664
|
+
: {
|
|
665
|
+
version: staged.version,
|
|
666
|
+
manifest: staged.manifest,
|
|
667
|
+
object_prefix: row.object_prefix,
|
|
668
|
+
files: staged.files,
|
|
669
|
+
extension_sha256: review.extension?.sha256 ?? null,
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
/** The catalog item's view (as a confirm returns it). */
|
|
674
|
+
async view(itemId) {
|
|
675
|
+
return this.itemView(itemId);
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Confirms a staged import (see the file header). Returns the committed catalog item and the
|
|
679
|
+
* extension's deploy result (a failed deploy is returned, not thrown). `scope` (default
|
|
680
|
+
* `optional`) and `orgs` (only with `named`; each an existing org, else `validation_failed`) are
|
|
681
|
+
* written when this confirm creates the item; a new version of an existing item keeps its scope.
|
|
682
|
+
* The caller enqueues the scope sync of the item after this returns.
|
|
683
|
+
*
|
|
684
|
+
* An org upload (`opts.owner`, spec §14): only that org's staging; the actor re-checked as its
|
|
685
|
+
* admin; `scope` / `orgs` are not taken: a new item is owned by the org, scope `named: [owner]`,
|
|
686
|
+
* not shown to other orgs, `shareable` as given (default false). Custom deny, the name owner and
|
|
687
|
+
* the dependencies are checked again under the item name's lock. A package with an extension
|
|
688
|
+
* is stored and its extension name claimed, nothing approved or installed: the version waits
|
|
689
|
+
* for the super admin (`pending`, ruling P3-10; see {@link commit}).
|
|
491
690
|
*/
|
|
492
691
|
async confirm(actor, stagingId, input, opts = {}) {
|
|
493
692
|
if (!UUID_RE.test(stagingId))
|
|
494
693
|
throw notFound();
|
|
694
|
+
const owner = opts.owner;
|
|
695
|
+
if (owner !== undefined && (input.scope !== undefined || input.orgs !== undefined)) {
|
|
696
|
+
throw new Error("an org upload's scope is its owner's");
|
|
697
|
+
}
|
|
698
|
+
// A staging prepared by approving an org's `import` request defaults to that org (spec §5.1
|
|
699
|
+
// rule 3); the admin may still choose any scope
|
|
700
|
+
const linked = input.scope === undefined && owner === undefined
|
|
701
|
+
? await importRequestOf(this.db, stagingId)
|
|
702
|
+
: undefined;
|
|
703
|
+
const scope = owner !== undefined
|
|
704
|
+
? "named"
|
|
705
|
+
: (input.scope ?? (linked !== undefined ? "named" : "optional"));
|
|
706
|
+
const orgs = owner !== undefined
|
|
707
|
+
? [owner.orgId]
|
|
708
|
+
: (input.orgs ?? (linked !== undefined ? [linked.orgId] : undefined));
|
|
709
|
+
if (input.orgs !== undefined && scope !== "named") {
|
|
710
|
+
throw new ApiError("validation_failed", "orgs: only allowed with scope named", [
|
|
711
|
+
{ path: "orgs", message: "only allowed with scope named" },
|
|
712
|
+
]);
|
|
713
|
+
}
|
|
714
|
+
if (scope === "named" && (orgs ?? []).length === 0) {
|
|
715
|
+
throw new ApiError("validation_failed", "orgs: scope named needs at least one organization", [
|
|
716
|
+
{ path: "orgs", message: "scope named needs at least one organization" },
|
|
717
|
+
]);
|
|
718
|
+
}
|
|
495
719
|
const row = await this.db
|
|
496
720
|
.selectFrom("plugin_import_staging")
|
|
497
721
|
.selectAll()
|
|
498
722
|
.where("id", "=", stagingId)
|
|
499
723
|
.where("expires_at", ">", sql `now()`)
|
|
724
|
+
.where(ownStaging(owner))
|
|
500
725
|
.executeTakeFirst();
|
|
501
726
|
if (!row)
|
|
502
727
|
throw notFound();
|
|
@@ -505,36 +730,149 @@ let PluginImport = class PluginImport {
|
|
|
505
730
|
const src = row.source;
|
|
506
731
|
if (input.reviewHash !== review.reviewHash)
|
|
507
732
|
throw reviewStale(review);
|
|
508
|
-
const manifest =
|
|
733
|
+
const manifest = staged.manifest;
|
|
509
734
|
const reviewed = review.extension;
|
|
510
|
-
// Read the stored package outside the transaction (unless it was already installed as is
|
|
511
|
-
|
|
512
|
-
const
|
|
735
|
+
// Read the stored package outside the transaction (unless it was already installed as is, or
|
|
736
|
+
// an org upload, which approves nothing)
|
|
737
|
+
const stored = reviewed && reviewed.action !== "keep" && owner === undefined
|
|
738
|
+
? await this.readStored(reviewed.sha256)
|
|
739
|
+
: undefined;
|
|
740
|
+
// The platform components of the item's first usable version: planned and their files copied
|
|
741
|
+
// (keyed by content) before the transaction, their rows written in it
|
|
742
|
+
const prepared = staged.retry === true || (owner !== undefined && reviewed !== undefined)
|
|
743
|
+
? undefined
|
|
744
|
+
: await this.prepareFirstVersion(staged, row.object_prefix, owner);
|
|
745
|
+
const committed = await this.commit(actor, { stagingId, review, staged, src, manifest, objectPrefix: row.object_prefix }, {
|
|
746
|
+
scope,
|
|
747
|
+
orgs: [...new Set(orgs ?? [])].sort(),
|
|
748
|
+
...(owner !== undefined && { owner, shareable: input.shareable ?? false }),
|
|
749
|
+
}, stored, opts, prepared);
|
|
513
750
|
const { now } = committed;
|
|
514
|
-
|
|
751
|
+
if (committed.pending) {
|
|
752
|
+
// Waits for the super admin (P3-10): no platform components, nothing deployed
|
|
753
|
+
return {
|
|
754
|
+
item: await this.itemView(committed.itemId),
|
|
755
|
+
created: committed.created,
|
|
756
|
+
deploy: null,
|
|
757
|
+
pending: true,
|
|
758
|
+
firstVersion: false,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
if (input.deploy === false) {
|
|
762
|
+
return {
|
|
763
|
+
item: await this.itemView(committed.itemId),
|
|
764
|
+
created: committed.created,
|
|
765
|
+
deploy: null,
|
|
766
|
+
pending: false,
|
|
767
|
+
firstVersion: committed.firstVersion,
|
|
768
|
+
...(now &&
|
|
769
|
+
committed.previous !== undefined && {
|
|
770
|
+
approval: { review, extension: now, previous: committed.previous },
|
|
771
|
+
}),
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
const deploy = now && now.action !== "keep"
|
|
515
775
|
? await this.deploy(actor, review, committed.itemId, now, committed.previous, opts, input.enable ?? true)
|
|
516
776
|
: null;
|
|
517
|
-
return {
|
|
777
|
+
return {
|
|
778
|
+
item: await this.itemView(committed.itemId),
|
|
779
|
+
created: committed.created,
|
|
780
|
+
deploy,
|
|
781
|
+
pending: false,
|
|
782
|
+
firstVersion: committed.firstVersion,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* The platform components of the staged version when its confirm will most likely make it the
|
|
787
|
+
* item's first usable version ({@link commit} decides under its locks): no live item of the name
|
|
788
|
+
* yet, or an org upload replacing its own first upload still awaiting confirmation. Planned from
|
|
789
|
+
* the staged content and their files copied, outside any transaction; otherwise undefined.
|
|
790
|
+
*/
|
|
791
|
+
async prepareFirstVersion(staged, objectPrefix, owner) {
|
|
792
|
+
const live = await this.db
|
|
793
|
+
.selectFrom("catalog_items")
|
|
794
|
+
.select(["id", "awaiting_confirmation", "owner_org_id"])
|
|
795
|
+
.where("name", "=", staged.manifest.name)
|
|
796
|
+
.where("deleted_at", "is", null)
|
|
797
|
+
.executeTakeFirst();
|
|
798
|
+
const first = live === undefined ||
|
|
799
|
+
(owner !== undefined && live.awaiting_confirmation && live.owner_org_id === owner.orgId);
|
|
800
|
+
if (!first)
|
|
801
|
+
return undefined;
|
|
802
|
+
return this.platform.prepareImport({
|
|
803
|
+
itemId: live?.id ?? staged.itemId,
|
|
804
|
+
plugin: staged.manifest.name,
|
|
805
|
+
version: staged.version,
|
|
806
|
+
manifest: staged.manifest,
|
|
807
|
+
objectPrefix,
|
|
808
|
+
files: staged.files,
|
|
809
|
+
sourceFormat: staged.sourceFormat ?? "capybara",
|
|
810
|
+
});
|
|
518
811
|
}
|
|
519
812
|
/**
|
|
520
813
|
* The confirm's transaction: the staging row consumed, the extension's action recomputed under
|
|
521
814
|
* its install lock (stale -> `plugin.review_stale`), its snapshot approved, and the catalog
|
|
522
815
|
* version written under the item name's lock.
|
|
816
|
+
*
|
|
817
|
+
* An org upload with an extension (ruling P3-10) approves nothing: under the install lock it
|
|
818
|
+
* claims the extension name for its package (another package's -> 409
|
|
819
|
+
* `extension.name_conflict` naming its owner, before anything is written), and the version
|
|
820
|
+
* written becomes the item's pending one (`pending_version` / `_by` / `_at`; a first version
|
|
821
|
+
* also `awaiting_confirmation`). A later upload replaces the pending version (P3-11). An org
|
|
822
|
+
* upload without an extension for an item whose first version still waits (plan Task 6) replaces
|
|
823
|
+
* that upload and applies at once: the item stops waiting and the claim is released (nothing
|
|
824
|
+
* was installed under it).
|
|
825
|
+
*
|
|
826
|
+
* The item's first usable version (a new item not waiting, or an awaiting first upload replaced)
|
|
827
|
+
* writes the platform rows of its skills, agent templates, connector templates and themes
|
|
828
|
+
* (plugin scope phase 2) from `prepared` (their files copied before the transaction, keyed by
|
|
829
|
+
* content): a failure rolls the whole confirm back, and a retry copies nothing again. A plan made
|
|
830
|
+
* for another item or version, or a component changed since it -> `plugin.review_stale`. A new
|
|
831
|
+
* version of an existing item leaves them to the platform update.
|
|
523
832
|
*/
|
|
524
|
-
async commit(actor, c,
|
|
833
|
+
async commit(actor, c, scope, stored, opts, prepared) {
|
|
525
834
|
const { stagingId, review, staged, src, manifest } = c;
|
|
526
835
|
const reviewed = review.extension;
|
|
527
836
|
const stale = () => reviewStale(review);
|
|
528
|
-
|
|
837
|
+
const { owner } = scope;
|
|
838
|
+
await this.authorizeActor(actor, owner);
|
|
529
839
|
const t = this.db;
|
|
530
840
|
const used = await t
|
|
531
841
|
.deleteFrom("plugin_import_staging")
|
|
532
842
|
.where("id", "=", stagingId)
|
|
533
843
|
.where("expires_at", ">", sql `now()`)
|
|
844
|
+
.where(ownStaging(owner))
|
|
534
845
|
.returning("id")
|
|
535
846
|
.executeTakeFirst();
|
|
536
847
|
if (!used)
|
|
537
848
|
throw notFound();
|
|
849
|
+
if (owner !== undefined) {
|
|
850
|
+
await assertCustomContent(t, {
|
|
851
|
+
skills: review.skills,
|
|
852
|
+
agentTemplates: review.agentTemplates ?? [],
|
|
853
|
+
templates: review.connectorTemplates,
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
await assertOrgsExist(t, scope.orgs);
|
|
857
|
+
// Checked again before this upload claims anything (ruling P3-51)
|
|
858
|
+
if (owner !== undefined)
|
|
859
|
+
await assertPackageFree(t, staged.packageName, owner.orgId);
|
|
860
|
+
// The item's name lock and its live row before the extension's install lock: the global lock
|
|
861
|
+
// order is the item, then the install lock (ruling P3-50; ExtensionAdminOps.install locks the
|
|
862
|
+
// source item row before the install lock, an org deletion its items before it). Taken after
|
|
863
|
+
// the install lock instead, a confirmation of an org upload racing a replacement upload
|
|
864
|
+
// deadlocks (40P01).
|
|
865
|
+
const m = manifest;
|
|
866
|
+
await this.itemLock.lock(m.name);
|
|
867
|
+
// The scope the audit records: the review's for a new item, the item's own for a new version
|
|
868
|
+
// of a live item (which keeps its scope)
|
|
869
|
+
const existing = await t
|
|
870
|
+
.selectFrom("catalog_items")
|
|
871
|
+
.select(["id", "scope", "awaiting_confirmation", "package_name"])
|
|
872
|
+
.where("name", "=", m.name)
|
|
873
|
+
.where("deleted_at", "is", null)
|
|
874
|
+
.forUpdate()
|
|
875
|
+
.executeTakeFirst();
|
|
538
876
|
let now;
|
|
539
877
|
let previous;
|
|
540
878
|
if (reviewed) {
|
|
@@ -544,23 +882,73 @@ let PluginImport = class PluginImport {
|
|
|
544
882
|
await this.installLock.lock(reviewed.name);
|
|
545
883
|
now = {
|
|
546
884
|
...reviewed,
|
|
547
|
-
...actionOf(await this.extensionState(reviewed.name, staged.packageName), reviewed.sha256),
|
|
885
|
+
...actionOf(await this.extensionState(reviewed.name, staged.packageName), reviewed.sha256, reviewed.version),
|
|
548
886
|
};
|
|
549
887
|
if (pluginReviewHash({ ...review, extension: now }, staged.files) !== review.reviewHash) {
|
|
550
888
|
throw stale();
|
|
551
889
|
}
|
|
890
|
+
if (owner !== undefined) {
|
|
891
|
+
// An org upload only claims the name (P3-10): the super admin approves and installs it
|
|
892
|
+
await t
|
|
893
|
+
.insertInto("extension_name_owners")
|
|
894
|
+
.values({ name: reviewed.name, package_name: staged.packageName })
|
|
895
|
+
.onConflict((oc) => oc.column("name").doNothing())
|
|
896
|
+
.execute();
|
|
897
|
+
await assertPluginNameOwner(t, reviewed.name, staged.packageName);
|
|
898
|
+
}
|
|
552
899
|
// A foreseeable deploy failure (a downgrade to a version with unrun migrations) is refused
|
|
553
900
|
// before anything is written
|
|
554
|
-
if (
|
|
901
|
+
if (now.action === "upgrade" && stored) {
|
|
555
902
|
await assertDowngradable(t, now, stored.migrationSql);
|
|
556
903
|
}
|
|
557
|
-
if (now.action === "install" ||
|
|
904
|
+
if (owner === undefined && (now.action === "install" || now.action === "upgrade")) {
|
|
558
905
|
previous = await this.approve(actor, review, staged, now, stored, opts);
|
|
559
906
|
}
|
|
560
907
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
908
|
+
// Under the name's lock: the first confirm of a name wins, a later one of another owner is
|
|
909
|
+
// refused naming it, before anything of it is written (P3-14)
|
|
910
|
+
await assertNameFree(t, m.name, owner?.orgId ?? null);
|
|
911
|
+
if (owner !== undefined) {
|
|
912
|
+
await assertNameNotReserved(t, m.name);
|
|
913
|
+
await this.resolveDependencies(m, owner);
|
|
914
|
+
}
|
|
915
|
+
const actual = existing === undefined
|
|
916
|
+
? scope
|
|
917
|
+
: {
|
|
918
|
+
scope: existing.scope,
|
|
919
|
+
orgs: (await t
|
|
920
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
921
|
+
.select("org_id")
|
|
922
|
+
.where("item_id", "=", existing.id)
|
|
923
|
+
.orderBy("org_id")
|
|
924
|
+
.execute()).map((r) => r.org_id),
|
|
925
|
+
};
|
|
926
|
+
if (staged.retry === true) {
|
|
927
|
+
// An org's own version imported already (pre-flight F4): nothing to write, the caller
|
|
928
|
+
// retries its update; it must still be there as reviewed
|
|
929
|
+
const v = existing === undefined
|
|
930
|
+
? undefined
|
|
931
|
+
: await t
|
|
932
|
+
.selectFrom("catalog_item_versions")
|
|
933
|
+
.select("version")
|
|
934
|
+
.where("item_id", "=", existing.id)
|
|
935
|
+
.where("version", "=", staged.version)
|
|
936
|
+
.where("content_digest", "=", staged.contentDigest)
|
|
937
|
+
.executeTakeFirst();
|
|
938
|
+
if (existing === undefined || existing.id !== staged.itemId || v === undefined)
|
|
939
|
+
throw stale();
|
|
940
|
+
return {
|
|
941
|
+
itemId: existing.id,
|
|
942
|
+
created: false,
|
|
943
|
+
firstVersion: false,
|
|
944
|
+
pending: false,
|
|
945
|
+
now,
|
|
946
|
+
previous,
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
const { id: itemId, created } = await writeCatalogVersion(t, {
|
|
950
|
+
// an org's version becomes its latest only when applied or confirmed (P3-34)
|
|
951
|
+
...(owner !== undefined && { keepLatest: true }),
|
|
564
952
|
actor,
|
|
565
953
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
566
954
|
name: m.name,
|
|
@@ -568,9 +956,10 @@ let PluginImport = class PluginImport {
|
|
|
568
956
|
version: staged.version,
|
|
569
957
|
contentDigest: staged.contentDigest,
|
|
570
958
|
manifest: m,
|
|
959
|
+
appearanceOrder: staged.appearanceOrder ?? null,
|
|
571
960
|
listing: {
|
|
572
961
|
publisher: m.publisher,
|
|
573
|
-
description: m.description,
|
|
962
|
+
description: pluginDescription(m.description).en,
|
|
574
963
|
displayName: m.displayName ?? null,
|
|
575
964
|
},
|
|
576
965
|
newItemId: staged.itemId,
|
|
@@ -591,12 +980,126 @@ let PluginImport = class PluginImport {
|
|
|
591
980
|
licenseTruncated: staged.licenseTruncated === true,
|
|
592
981
|
auditDetail: {
|
|
593
982
|
stagingId,
|
|
594
|
-
|
|
595
|
-
|
|
983
|
+
scope: actual.scope,
|
|
984
|
+
...(actual.scope === "named" && { orgs: actual.orgs }),
|
|
596
985
|
...(now && { extension: { name: now.name, version: now.version, action: now.action } }),
|
|
597
986
|
},
|
|
598
987
|
});
|
|
599
|
-
|
|
988
|
+
// A new item gets the scope chosen in the review; a new version keeps the item's scope, its
|
|
989
|
+
// org list and its scope version (prepare reuses the live item's id, so the id cannot tell)
|
|
990
|
+
if (created) {
|
|
991
|
+
await t
|
|
992
|
+
.updateTable("catalog_items")
|
|
993
|
+
.set({
|
|
994
|
+
scope: scope.scope,
|
|
995
|
+
// an org upload: the org owns it, nobody else sees it until shared and shown (P3-16)
|
|
996
|
+
...(owner !== undefined && {
|
|
997
|
+
owner_org_id: owner.orgId,
|
|
998
|
+
shareable: scope.shareable === true,
|
|
999
|
+
shown_to_others: false,
|
|
1000
|
+
}),
|
|
1001
|
+
})
|
|
1002
|
+
.where("id", "=", itemId)
|
|
1003
|
+
.execute();
|
|
1004
|
+
if (scope.scope === "named" && scope.orgs.length > 0) {
|
|
1005
|
+
await t
|
|
1006
|
+
.insertInto("catalog_item_scope_orgs")
|
|
1007
|
+
.values(scope.orgs.map((org_id) => ({ item_id: itemId, org_id })))
|
|
1008
|
+
.onConflict((oc) => oc.doNothing())
|
|
1009
|
+
.execute();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
// The org requests this staging answers resolve with the confirm; on an item that existed
|
|
1013
|
+
// already (imported meanwhile) a `named` scope gains their orgs. An org-owned item held back by
|
|
1014
|
+
// the share gate fails closed before any request is marked (ruling P3-26; P3-14 refuses a
|
|
1015
|
+
// super admin import of an org-owned name, so this should not be reached)
|
|
1016
|
+
const item = created
|
|
1017
|
+
? undefined
|
|
1018
|
+
: await t
|
|
1019
|
+
.selectFrom("catalog_items")
|
|
1020
|
+
.select(["id", "name", "scope", "builtin", "owner_org_id", "shareable"])
|
|
1021
|
+
.where("id", "=", itemId)
|
|
1022
|
+
.forUpdate()
|
|
1023
|
+
.executeTakeFirstOrThrow();
|
|
1024
|
+
if (item !== undefined && !shareGate(item) && (await hasImportRequests(t, stagingId))) {
|
|
1025
|
+
assertShareable(item);
|
|
1026
|
+
}
|
|
1027
|
+
const requestOrgs = await resolveImportRequests(t, stagingId, itemId, actor, opts);
|
|
1028
|
+
if (item !== undefined) {
|
|
1029
|
+
for (const org of requestOrgs)
|
|
1030
|
+
await addScopeOrg(t, actor, item, org, opts);
|
|
1031
|
+
}
|
|
1032
|
+
const pending = owner !== undefined && reviewed !== undefined;
|
|
1033
|
+
// An org's first version without an extension is installed at once: applied (P3-52)
|
|
1034
|
+
if (owner !== undefined && created && !pending)
|
|
1035
|
+
await markVersionApplied(t, itemId, staged.version);
|
|
1036
|
+
if (pending) {
|
|
1037
|
+
// Waits for the super admin; a later upload replaces the pending version (P3-10, P3-11)
|
|
1038
|
+
await t
|
|
1039
|
+
.updateTable("catalog_items")
|
|
1040
|
+
.set({
|
|
1041
|
+
...(created && { awaiting_confirmation: true }),
|
|
1042
|
+
pending_version: staged.version,
|
|
1043
|
+
pending_by: actor,
|
|
1044
|
+
pending_at: sql `now()`,
|
|
1045
|
+
})
|
|
1046
|
+
.where("id", "=", itemId)
|
|
1047
|
+
.execute();
|
|
1048
|
+
}
|
|
1049
|
+
// A first version still waiting replaced by one without an extension: applied at once
|
|
1050
|
+
const replacedAwaiting = owner !== undefined && !pending && existing?.awaiting_confirmation === true;
|
|
1051
|
+
if (replacedAwaiting) {
|
|
1052
|
+
await t
|
|
1053
|
+
.updateTable("catalog_items")
|
|
1054
|
+
.set({
|
|
1055
|
+
awaiting_confirmation: false,
|
|
1056
|
+
pending_version: null,
|
|
1057
|
+
pending_by: null,
|
|
1058
|
+
pending_at: null,
|
|
1059
|
+
latest_version: staged.version,
|
|
1060
|
+
})
|
|
1061
|
+
.where("id", "=", itemId)
|
|
1062
|
+
.execute();
|
|
1063
|
+
await markVersionApplied(t, itemId, staged.version);
|
|
1064
|
+
await releaseExtensionClaim(t, m.name, existing.package_name);
|
|
1065
|
+
}
|
|
1066
|
+
const firstVersion = (created && !pending) || replacedAwaiting;
|
|
1067
|
+
if (firstVersion) {
|
|
1068
|
+
if (prepared?.plan.itemId !== itemId || prepared.plan.version !== staged.version) {
|
|
1069
|
+
throw stale();
|
|
1070
|
+
}
|
|
1071
|
+
try {
|
|
1072
|
+
await this.platform.applySyncIn(prepared);
|
|
1073
|
+
}
|
|
1074
|
+
catch (e) {
|
|
1075
|
+
if (e instanceof PlanStale)
|
|
1076
|
+
throw stale();
|
|
1077
|
+
throw e;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
// The commit owes the scope sync's backstop (ruling R24) when the item's scope turns it on by
|
|
1081
|
+
// itself: the caller owes the immediate sync after the deploy, which a crash may lose
|
|
1082
|
+
if (!pending) {
|
|
1083
|
+
const item = await t
|
|
1084
|
+
.selectFrom("catalog_items")
|
|
1085
|
+
.select("scope")
|
|
1086
|
+
.where("id", "=", itemId)
|
|
1087
|
+
.executeTakeFirstOrThrow();
|
|
1088
|
+
if (item.scope !== "optional") {
|
|
1089
|
+
await oweScopeItem(this.outbox, t, itemId, {
|
|
1090
|
+
backstop: true,
|
|
1091
|
+
backstopDelayMs: this.backstopDelayMs,
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return {
|
|
1096
|
+
itemId,
|
|
1097
|
+
created,
|
|
1098
|
+
firstVersion,
|
|
1099
|
+
pending,
|
|
1100
|
+
now,
|
|
1101
|
+
previous,
|
|
1102
|
+
};
|
|
600
1103
|
}
|
|
601
1104
|
/**
|
|
602
1105
|
* Writes the extension's permission snapshot for the version being imported (source web; cli
|
|
@@ -644,7 +1147,9 @@ let PluginImport = class PluginImport {
|
|
|
644
1147
|
}
|
|
645
1148
|
/**
|
|
646
1149
|
* Deploys the plugin's extension after the commit: `install` (a new install is disabled, a version
|
|
647
|
-
* change keeps the desired state) then `enable
|
|
1150
|
+
* change keeps the desired state) then `enable`, unless another enabled extension provides one of
|
|
1151
|
+
* its single-provider extension points: then it stays disabled (result `installed` with code
|
|
1152
|
+
* `extension.single_provider_enabled`). Nothing is thrown; the result says what happened.
|
|
648
1153
|
* When an upgrade was not installed, the snapshot overwritten at confirm is restored (the old
|
|
649
1154
|
* version keeps running, F-O; audit `extension.permissions_restored`). Retry through the extension
|
|
650
1155
|
* admin (the package is already in the package store) with the sha256 from the result.
|
|
@@ -659,8 +1164,9 @@ let PluginImport = class PluginImport {
|
|
|
659
1164
|
const failure = (e) => e instanceof ApiError
|
|
660
1165
|
? { code: e.code, message: e.message }
|
|
661
1166
|
: { code: "internal", message: "Internal error" };
|
|
1167
|
+
let installed;
|
|
662
1168
|
try {
|
|
663
|
-
await this.ops.install(p.name, p.sha256, actor, opts.actorTokenId, {
|
|
1169
|
+
installed = await this.ops.install(p.name, p.sha256, actor, opts.actorTokenId, {
|
|
664
1170
|
catalogItemId: itemId,
|
|
665
1171
|
});
|
|
666
1172
|
}
|
|
@@ -686,17 +1192,32 @@ let PluginImport = class PluginImport {
|
|
|
686
1192
|
}
|
|
687
1193
|
return result;
|
|
688
1194
|
}
|
|
1195
|
+
// An upgrade of an enabled extension that newly provides a held single-provider point: left
|
|
1196
|
+
// disabled by the install, and why
|
|
1197
|
+
if (installed.leftDisabled !== undefined) {
|
|
1198
|
+
return { ...base, result: "installed", ...installed.leftDisabled };
|
|
1199
|
+
}
|
|
689
1200
|
if (!enable)
|
|
690
1201
|
return { ...base, result: "installed" };
|
|
691
1202
|
try {
|
|
692
|
-
await this.ops.
|
|
693
|
-
|
|
1203
|
+
const r = await this.ops.enableUnlessOccupied(p.name, actor, opts.actorTokenId);
|
|
1204
|
+
if (r.enabled)
|
|
1205
|
+
return { ...base, result: "enabled" };
|
|
1206
|
+
// A single-provider point another enabled extension provides: installed disabled, and why
|
|
1207
|
+
return { ...base, result: "installed", ...r.note };
|
|
694
1208
|
}
|
|
695
1209
|
catch (e) {
|
|
696
1210
|
this.log.warn("enabling a plugin's extension failed", { plugin: p.name, err: e });
|
|
697
1211
|
return { ...base, result: "failed", ...failure(e) };
|
|
698
1212
|
}
|
|
699
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Puts back the approval a confirm with `deploy: false` wrote, after the step that was to deploy
|
|
1216
|
+
* the extension failed (see {@link restoreSnapshot}; false when someone changed it meanwhile).
|
|
1217
|
+
*/
|
|
1218
|
+
async restoreApproval(actor, held, opts = {}) {
|
|
1219
|
+
return this.restoreSnapshot(actor, held.review, held.extension, held.previous, opts);
|
|
1220
|
+
}
|
|
700
1221
|
/**
|
|
701
1222
|
* Restores the snapshot overwritten at confirm (deletes it when there was none before), audits
|
|
702
1223
|
* `extension.permissions_restored`. Compare-and-write (row locked): restores only while the
|
|
@@ -745,11 +1266,24 @@ let PluginImport = class PluginImport {
|
|
|
745
1266
|
return true;
|
|
746
1267
|
}
|
|
747
1268
|
/**
|
|
748
|
-
* Deletes expired staging rows and their object prefixes (maintenance job `app-staging-cleanup`)
|
|
749
|
-
* Row by row: objects first, then the
|
|
750
|
-
*
|
|
1269
|
+
* Deletes expired staging rows and their object prefixes (maintenance job `app-staging-cleanup`),
|
|
1270
|
+
* then the unused display files ({@link sweepDisplayFiles}). Row by row: objects first, then the
|
|
1271
|
+
* row (a failed object delete keeps the row for the next round); concurrent replicas skip each
|
|
1272
|
+
* other's rows (`SKIP LOCKED`). Returns the rows deleted.
|
|
751
1273
|
*/
|
|
752
1274
|
async cleanupExpired() {
|
|
1275
|
+
const total = await this.cleanupStagingRows();
|
|
1276
|
+
// display files no version or staging lists (an abandoned import's), older than a staging
|
|
1277
|
+
try {
|
|
1278
|
+
await sweepDisplayFiles(this.db, PLUGIN_STAGING_TTL_MS);
|
|
1279
|
+
}
|
|
1280
|
+
catch (err) {
|
|
1281
|
+
this.log.warn("cannot sweep unused catalog display files", { err });
|
|
1282
|
+
}
|
|
1283
|
+
return total;
|
|
1284
|
+
}
|
|
1285
|
+
/** The expired staging rows, batch by batch; returns the rows deleted. */
|
|
1286
|
+
async cleanupStagingRows() {
|
|
753
1287
|
let total = 0;
|
|
754
1288
|
for (;;) {
|
|
755
1289
|
const batch = await this.db
|
|
@@ -786,7 +1320,7 @@ let PluginImport = class PluginImport {
|
|
|
786
1320
|
const t = this.db;
|
|
787
1321
|
const locked = await t
|
|
788
1322
|
.selectFrom("plugin_import_staging")
|
|
789
|
-
.select("id")
|
|
1323
|
+
.select(["id", "org_id", "review", "manifest"])
|
|
790
1324
|
.where("id", "=", r.id)
|
|
791
1325
|
.where("expires_at", "<=", sql `now()`)
|
|
792
1326
|
.forUpdate()
|
|
@@ -797,8 +1331,86 @@ let PluginImport = class PluginImport {
|
|
|
797
1331
|
if (r.object_prefix)
|
|
798
1332
|
await this.files.deployment().deletePrefix(r.object_prefix);
|
|
799
1333
|
await t.deleteFrom("plugin_import_staging").where("id", "=", r.id).execute();
|
|
1334
|
+
await this.dropOrgPackage(locked);
|
|
800
1335
|
return true;
|
|
801
1336
|
}
|
|
1337
|
+
/**
|
|
1338
|
+
* An expired org staging's extension package (an org upload stores it at prepare, P3-10): removed
|
|
1339
|
+
* with the staging unless something else uses it — an install (running or migrated), a catalog
|
|
1340
|
+
* version, another staging — or it was stored by anyone else (the package row's source must be
|
|
1341
|
+
* this staging's own `catalog` ref). A platform staging keeps its package, as before. Its object
|
|
1342
|
+
* is deleted after the commit.
|
|
1343
|
+
*/
|
|
1344
|
+
async dropOrgPackage(row) {
|
|
1345
|
+
const sha = row.review.extension?.sha256;
|
|
1346
|
+
if (row.org_id === null || sha === undefined)
|
|
1347
|
+
return;
|
|
1348
|
+
const staged = row.manifest;
|
|
1349
|
+
const t = this.db;
|
|
1350
|
+
const pkg = await t
|
|
1351
|
+
.selectFrom("extension_packages")
|
|
1352
|
+
.select("blob_store")
|
|
1353
|
+
.where("sha256", "=", sha)
|
|
1354
|
+
.where("source", "=", "catalog")
|
|
1355
|
+
.where("source_ref", "=", `${staged.itemId}@${staged.version}`)
|
|
1356
|
+
.forUpdate()
|
|
1357
|
+
.executeTakeFirst();
|
|
1358
|
+
if (!pkg)
|
|
1359
|
+
return;
|
|
1360
|
+
const used = (await t
|
|
1361
|
+
.selectFrom("extension_installs")
|
|
1362
|
+
.select("name")
|
|
1363
|
+
.where((eb) => eb.or([eb("sha256", "=", sha), eb("migrated_sha", "=", sha)]))
|
|
1364
|
+
.executeTakeFirst()) ??
|
|
1365
|
+
(await t
|
|
1366
|
+
.selectFrom("catalog_item_versions")
|
|
1367
|
+
.select("version")
|
|
1368
|
+
.where("extension_sha256", "=", sha)
|
|
1369
|
+
.executeTakeFirst()) ??
|
|
1370
|
+
(await t
|
|
1371
|
+
.selectFrom("plugin_import_staging")
|
|
1372
|
+
.select("id")
|
|
1373
|
+
.where(sql `review->'extension'->>'sha256' = ${sha}`)
|
|
1374
|
+
.executeTakeFirst());
|
|
1375
|
+
if (used !== undefined)
|
|
1376
|
+
return;
|
|
1377
|
+
const build = await t
|
|
1378
|
+
.selectFrom("extension_client_builds")
|
|
1379
|
+
.select("object_prefix")
|
|
1380
|
+
.where("package_sha256", "=", sha)
|
|
1381
|
+
.executeTakeFirst();
|
|
1382
|
+
// extension_blobs (a PG-stored package) and extension_client_builds go with the row (ON
|
|
1383
|
+
// DELETE CASCADE)
|
|
1384
|
+
await t.deleteFrom("extension_packages").where("sha256", "=", sha).execute();
|
|
1385
|
+
if (build !== undefined) {
|
|
1386
|
+
afterCommit(async () => {
|
|
1387
|
+
try {
|
|
1388
|
+
await this.clientBuilds.deleteFiles(sha, build.object_prefix);
|
|
1389
|
+
}
|
|
1390
|
+
catch (err) {
|
|
1391
|
+
this.log.warn("cannot delete an expired org upload's client build objects", {
|
|
1392
|
+
sha256: sha,
|
|
1393
|
+
err,
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
// The object only once the row is gone for good: a failure leaves an unreferenced object
|
|
1399
|
+
// (harmless; a later upload of the same bytes rewrites it), never a row without its bytes
|
|
1400
|
+
if (pkg.blob_store === "object") {
|
|
1401
|
+
afterCommit(async () => {
|
|
1402
|
+
try {
|
|
1403
|
+
await this.files.deployment().delete(blobKey(sha));
|
|
1404
|
+
}
|
|
1405
|
+
catch (err) {
|
|
1406
|
+
this.log.warn("cannot delete an expired org upload's extension package object", {
|
|
1407
|
+
sha256: sha,
|
|
1408
|
+
err,
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
802
1414
|
// ---------------------------------------------------------------------------------------------
|
|
803
1415
|
/** npm / marketplace imports: the package must be the one that was asked for. */
|
|
804
1416
|
checkExpected(pkg, expect, format = "capybara") {
|
|
@@ -837,7 +1449,6 @@ let PluginImport = class PluginImport {
|
|
|
837
1449
|
const m = pkg.manifest;
|
|
838
1450
|
const notLoaded = [];
|
|
839
1451
|
const templatePaths = new Map();
|
|
840
|
-
const pinned = new Map((m.skills ?? []).map((s) => [packagePath(s.path), s.pinned === true]));
|
|
841
1452
|
const problems = [];
|
|
842
1453
|
const stored = new Map();
|
|
843
1454
|
const keep = (path) => {
|
|
@@ -845,8 +1456,16 @@ let PluginImport = class PluginImport {
|
|
|
845
1456
|
if (data !== undefined && !stored.has(path))
|
|
846
1457
|
stored.set(path, fileOf(path, data));
|
|
847
1458
|
};
|
|
848
|
-
|
|
849
|
-
|
|
1459
|
+
const objectPaths = new Set();
|
|
1460
|
+
const keepObject = (path) => {
|
|
1461
|
+
keep(path);
|
|
1462
|
+
if (stored.has(path))
|
|
1463
|
+
objectPaths.add(path);
|
|
1464
|
+
};
|
|
1465
|
+
// The plugin icon and the setup guide documents (rendered by PluginGuides): display files
|
|
1466
|
+
const displayPaths = displayFilePaths(m, pkg.connectorTemplates.flatMap((c) => (c.file.icon === undefined ? [] : [c.file.icon])));
|
|
1467
|
+
for (const path of displayPaths)
|
|
1468
|
+
keep(path);
|
|
850
1469
|
const skills = [];
|
|
851
1470
|
for (const s of pkg.skills) {
|
|
852
1471
|
const files = s.files.map((f) => fileOf(f, pkg.files.get(`${s.dir}/${f}`)));
|
|
@@ -862,10 +1481,9 @@ let PluginImport = class PluginImport {
|
|
|
862
1481
|
body: "errors" in md ? "" : md.body,
|
|
863
1482
|
path: `./${s.dir}`,
|
|
864
1483
|
files: files.length,
|
|
865
|
-
suggestPinned: pinned.get(s.dir) === true,
|
|
866
1484
|
});
|
|
867
1485
|
for (const f of s.files)
|
|
868
|
-
|
|
1486
|
+
keepObject(`${s.dir}/${f}`);
|
|
869
1487
|
}
|
|
870
1488
|
catch (e) {
|
|
871
1489
|
if (!(e instanceof SkillArchiveError))
|
|
@@ -909,10 +1527,8 @@ let PluginImport = class PluginImport {
|
|
|
909
1527
|
else {
|
|
910
1528
|
problems.push(`${at}.connector: extension ${t.plugin} providing connector "${t.connector}" is not loaded in this deployment and is neither this plugin's extension nor a dependency`);
|
|
911
1529
|
}
|
|
912
|
-
|
|
1530
|
+
keepObject(c.path);
|
|
913
1531
|
templatePaths.set(c.id, c.path);
|
|
914
|
-
if (c.file.icon !== undefined)
|
|
915
|
-
keep(packagePath(c.file.icon));
|
|
916
1532
|
return {
|
|
917
1533
|
id: c.id,
|
|
918
1534
|
displayName: c.file.displayName,
|
|
@@ -926,43 +1542,89 @@ let PluginImport = class PluginImport {
|
|
|
926
1542
|
};
|
|
927
1543
|
});
|
|
928
1544
|
const agentTemplates = pkg.agentTemplates.map((a) => {
|
|
929
|
-
|
|
1545
|
+
keepObject(a.path);
|
|
930
1546
|
const { name, description, instructions, model, ...rest } = a.template;
|
|
931
1547
|
return { name, path: a.path, description, instructions, model: model ?? "inherit", ...rest };
|
|
932
1548
|
});
|
|
1549
|
+
// Themes: the file as written, the assets as sanitized by the reader (never the uploaded
|
|
1550
|
+
// originals: a shared path, e.g. the plugin icon, is stored sanitized too)
|
|
1551
|
+
const themes = pkg.themes.map((t) => {
|
|
1552
|
+
keepObject(t.path);
|
|
1553
|
+
for (const [path, data] of t.assets) {
|
|
1554
|
+
stored.set(path, fileOf(path, data));
|
|
1555
|
+
objectPaths.add(path);
|
|
1556
|
+
}
|
|
1557
|
+
const logo = t.theme.logo;
|
|
1558
|
+
return {
|
|
1559
|
+
id: t.id,
|
|
1560
|
+
name: t.theme.name,
|
|
1561
|
+
schemes: ["dark", "light"].filter((k) => t.theme.schemes[k] !== undefined),
|
|
1562
|
+
fonts: t.theme.fonts?.length ?? 0,
|
|
1563
|
+
logo: logo !== undefined && Object.keys(logo).length > 0,
|
|
1564
|
+
};
|
|
1565
|
+
});
|
|
933
1566
|
if (problems.length > 0)
|
|
934
1567
|
throw invalid(problems);
|
|
935
1568
|
return {
|
|
936
1569
|
files: [...stored.values()],
|
|
1570
|
+
displayPaths,
|
|
1571
|
+
objectPaths,
|
|
937
1572
|
templates,
|
|
938
1573
|
skills,
|
|
939
1574
|
agentTemplates,
|
|
1575
|
+
themes,
|
|
940
1576
|
notLoaded,
|
|
941
1577
|
templatePaths,
|
|
942
1578
|
};
|
|
943
1579
|
}
|
|
944
1580
|
/**
|
|
945
1581
|
* The highest imported, non-deleted catalog version satisfying each dependency's range (null when
|
|
946
|
-
* none does).
|
|
1582
|
+
* none does). An org upload (`owner`, P3-13) resolves only against items the org can use
|
|
1583
|
+
* ({@link usableBy}: confirmed, not disabled, offered to it), and any dependency left unresolved
|
|
1584
|
+
* -> 409 `plugin.dependency_unavailable` (details `[{ dependencies }]`, their names): an org
|
|
1585
|
+
* upload never brings in anything the org could not install itself.
|
|
947
1586
|
*/
|
|
948
|
-
async resolveDependencies(m) {
|
|
1587
|
+
async resolveDependencies(m, owner) {
|
|
949
1588
|
const deps = m.dependencies ?? [];
|
|
950
1589
|
if (deps.length === 0)
|
|
951
1590
|
return [];
|
|
952
|
-
const
|
|
1591
|
+
const names = deps.map((d) => d.name);
|
|
1592
|
+
const versions = this.db
|
|
953
1593
|
.selectFrom("catalog_items as i")
|
|
954
1594
|
.innerJoin("catalog_item_versions as v", "v.item_id", "i.id")
|
|
955
|
-
.select(["i.name", "v.version", "v.imported_at"])
|
|
956
1595
|
.where("i.deleted_at", "is", null)
|
|
957
|
-
.where("i.name", "in",
|
|
958
|
-
|
|
959
|
-
|
|
1596
|
+
.where("i.name", "in", names);
|
|
1597
|
+
const rows = owner === undefined
|
|
1598
|
+
? await versions.select(["i.name", "v.version", "v.imported_at"]).execute()
|
|
1599
|
+
: (await versions
|
|
1600
|
+
// the org's own row of a `named` list (usableBy reads whether it is listed)
|
|
1601
|
+
.leftJoin("catalog_item_scope_orgs as so", (j) => j.onRef("so.item_id", "=", "i.id").on("so.org_id", "=", owner.orgId))
|
|
1602
|
+
.select([
|
|
1603
|
+
"i.name",
|
|
1604
|
+
"v.version",
|
|
1605
|
+
"v.imported_at",
|
|
1606
|
+
"i.scope",
|
|
1607
|
+
"i.builtin",
|
|
1608
|
+
"i.disabled",
|
|
1609
|
+
"i.deleted_at",
|
|
1610
|
+
"i.awaiting_confirmation",
|
|
1611
|
+
"i.owner_org_id",
|
|
1612
|
+
"i.shareable",
|
|
1613
|
+
"so.org_id as listed",
|
|
1614
|
+
])
|
|
1615
|
+
.execute()).filter((r) => usableBy(r, owner.orgId, r.listed !== null));
|
|
1616
|
+
const resolved = deps.map((d) => ({
|
|
960
1617
|
name: d.name,
|
|
961
1618
|
range: d.version,
|
|
962
1619
|
resolved: maxSatisfying(rows
|
|
963
1620
|
.filter((r) => r.name === d.name)
|
|
964
1621
|
.map((r) => ({ version: r.version, importedAt: r.imported_at })), d.version)?.version ?? null,
|
|
965
1622
|
}));
|
|
1623
|
+
const missing = resolved.filter((d) => d.resolved === null).map((d) => d.name);
|
|
1624
|
+
if (owner !== undefined && missing.length > 0) {
|
|
1625
|
+
throw new ApiError("plugin.dependency_unavailable", `Dependencies not available to this organization: ${missing.join(", ")}`, [{ dependencies: missing }]);
|
|
1626
|
+
}
|
|
1627
|
+
return resolved;
|
|
966
1628
|
}
|
|
967
1629
|
/**
|
|
968
1630
|
* The extension's state on the deployment; installed from another npm package ->
|
|
@@ -980,7 +1642,7 @@ let PluginImport = class PluginImport {
|
|
|
980
1642
|
.where("extension_installs.name", "=", name)
|
|
981
1643
|
.executeTakeFirst();
|
|
982
1644
|
if (r && r.package_name !== packageName) {
|
|
983
|
-
throw new ApiError("extension.name_conflict", `Extension ${name} is already installed from package ${r.package_name}; package ${packageName} cannot use it
|
|
1645
|
+
throw new ApiError("extension.name_conflict", `Extension ${name} is already installed from package ${r.package_name}; package ${packageName} cannot use it`, [{ owner: await packageOwner(this.db, r.package_name, name) }]);
|
|
984
1646
|
}
|
|
985
1647
|
return r
|
|
986
1648
|
? { kind: "installed", version: r.version, sha256: r.sha256, packageName: r.package_name }
|
|
@@ -1002,7 +1664,7 @@ let PluginImport = class PluginImport {
|
|
|
1002
1664
|
name,
|
|
1003
1665
|
version: pkg.section.version,
|
|
1004
1666
|
sha256: pkg.sha256,
|
|
1005
|
-
...actionOf(state, pkg.sha256),
|
|
1667
|
+
...actionOf(state, pkg.sha256, pkg.section.version),
|
|
1006
1668
|
permissions,
|
|
1007
1669
|
added,
|
|
1008
1670
|
addedItems: permissionKeyItems(added),
|
|
@@ -1010,6 +1672,7 @@ let PluginImport = class PluginImport {
|
|
|
1010
1672
|
warnings,
|
|
1011
1673
|
reviewHash: extensionReviewHash(set, warnings),
|
|
1012
1674
|
sensitive: permissions.some((g) => g.sensitive) || warnings.length > 0,
|
|
1675
|
+
...(pkg.section.client !== undefined && { client: reviewClient(pkg) }),
|
|
1013
1676
|
};
|
|
1014
1677
|
}
|
|
1015
1678
|
async readStored(sha256) {
|
|
@@ -1027,10 +1690,11 @@ let PluginImport = class PluginImport {
|
|
|
1027
1690
|
.executeTakeFirstOrThrow();
|
|
1028
1691
|
const versions = await this.db
|
|
1029
1692
|
.selectFrom("catalog_item_versions")
|
|
1030
|
-
.select(["version", "source", "imported_at"])
|
|
1693
|
+
.select(["version", "source", "imported_at", "extension_sha256", "manifest", "source_format"])
|
|
1031
1694
|
.where("item_id", "=", itemId)
|
|
1032
1695
|
.execute();
|
|
1033
|
-
|
|
1696
|
+
const facts = await itemScopeFacts(this.db, [item], await itemConfirmations(this.admin, [item], new Map([[item.id, versions]])));
|
|
1697
|
+
return itemView(item, versions, 0, undefined, facts.get(item.id));
|
|
1034
1698
|
}
|
|
1035
1699
|
};
|
|
1036
1700
|
__decorate([
|
|
@@ -1054,41 +1718,48 @@ __decorate([
|
|
|
1054
1718
|
__decorate([
|
|
1055
1719
|
Transactional()
|
|
1056
1720
|
], PluginImport.prototype, "cleanupOne", null);
|
|
1721
|
+
__decorate([
|
|
1722
|
+
Transactional({ propagation: "mandatory" })
|
|
1723
|
+
], PluginImport.prototype, "dropOrgPackage", null);
|
|
1057
1724
|
PluginImport = __decorate([
|
|
1058
1725
|
Injectable(),
|
|
1059
1726
|
__param(0, Inject(KernelDb)),
|
|
1060
|
-
__param(1, Inject(
|
|
1061
|
-
__param(2, Inject(
|
|
1062
|
-
__param(3, Inject(
|
|
1063
|
-
__param(4, Inject(
|
|
1064
|
-
__param(5, Inject(
|
|
1065
|
-
__param(6, Inject(
|
|
1066
|
-
__param(7, Inject(
|
|
1067
|
-
__param(8, Inject(
|
|
1068
|
-
__param(9, Inject(
|
|
1069
|
-
__param(10, Inject(
|
|
1070
|
-
__param(11, Inject(
|
|
1071
|
-
__param(12, Inject(
|
|
1727
|
+
__param(1, Inject(SuperAdminLock)),
|
|
1728
|
+
__param(2, Inject(OrgLock)),
|
|
1729
|
+
__param(3, Inject(PluginInstallLock)),
|
|
1730
|
+
__param(4, Inject(PluginApproveLock)),
|
|
1731
|
+
__param(5, Inject(CatalogItemLock)),
|
|
1732
|
+
__param(6, Inject(KernelConfigService)),
|
|
1733
|
+
__param(7, Inject(StorageService)),
|
|
1734
|
+
__param(8, Inject(ExtensionInstalls)),
|
|
1735
|
+
__param(9, Inject(ExtensionAdminOps)),
|
|
1736
|
+
__param(10, Inject(ExtensionAdmin)),
|
|
1737
|
+
__param(11, Inject(ExtensionBlobs)),
|
|
1738
|
+
__param(12, Inject(ExtensionRegistry)),
|
|
1739
|
+
__param(13, Inject(KERNEL_LOGGER)),
|
|
1740
|
+
__param(14, Inject(TransactionHost)),
|
|
1741
|
+
__param(15, Inject(PlatformComponents)),
|
|
1742
|
+
__param(16, Inject(ClientBuilds)),
|
|
1743
|
+
__param(17, Inject(OutboxService)),
|
|
1744
|
+
__param(18, Optional()),
|
|
1745
|
+
__param(18, Inject(SCOPE_BACKSTOP_DELAY))
|
|
1072
1746
|
], PluginImport);
|
|
1073
1747
|
export { PluginImport };
|
|
1074
1748
|
/**
|
|
1075
1749
|
* plugin.json as stored on the version: skills and connector templates listed explicitly (what was
|
|
1076
|
-
* scanned when the manifest omitted them)
|
|
1750
|
+
* scanned when the manifest omitted them).
|
|
1077
1751
|
*/
|
|
1078
1752
|
function normalizedManifest(pkg) {
|
|
1079
|
-
const
|
|
1080
|
-
const { agents: _, ...manifest } = pkg.manifest;
|
|
1753
|
+
const { agents: _, themes: __, ...manifest } = pkg.manifest;
|
|
1081
1754
|
return {
|
|
1082
1755
|
...manifest,
|
|
1083
|
-
skills: pkg.skills.map((s) => {
|
|
1084
|
-
const p = pinned.get(s.dir);
|
|
1085
|
-
return { path: `./${s.dir}`, ...(p !== undefined && { pinned: p }) };
|
|
1086
|
-
}),
|
|
1756
|
+
skills: pkg.skills.map((s) => ({ path: `./${s.dir}` })),
|
|
1087
1757
|
connectorTemplates: pkg.connectorTemplates.map((t) => ({ path: `./${t.path}` })),
|
|
1088
1758
|
// listed only when there are any, so the stored manifests of other plugins stay as they were
|
|
1089
1759
|
...(pkg.agentTemplates.length > 0 && {
|
|
1090
1760
|
agents: pkg.agentTemplates.map((a) => ({ path: `./${a.path}` })),
|
|
1091
1761
|
}),
|
|
1762
|
+
...(pkg.themes.length > 0 && { themes: pkg.themes.map((t) => ({ path: `./${t.path}` })) }),
|
|
1092
1763
|
};
|
|
1093
1764
|
}
|
|
1094
1765
|
/** package.json `name`, or null without one (a git plugin; never the string "undefined"). */
|
|
@@ -1097,13 +1768,20 @@ function packageNameOf(pkg) {
|
|
|
1097
1768
|
return typeof name === "string" ? name : null;
|
|
1098
1769
|
}
|
|
1099
1770
|
/** The extension's deployment state -> action and current version. */
|
|
1100
|
-
function actionOf(s, sha256) {
|
|
1771
|
+
function actionOf(s, sha256, version) {
|
|
1101
1772
|
if (s.kind === "installed") {
|
|
1773
|
+
// A version below the deployed one is recorded in the catalog only: an import never
|
|
1774
|
+
// downgrades the deployment (ruling H)
|
|
1775
|
+
const older = s.sha256 !== sha256 &&
|
|
1776
|
+
semver.valid(version) !== null &&
|
|
1777
|
+
semver.valid(s.version) !== null &&
|
|
1778
|
+
semver.lt(version, s.version);
|
|
1102
1779
|
return {
|
|
1103
|
-
action: s.sha256 === sha256 ? "keep" : "upgrade",
|
|
1780
|
+
action: s.sha256 === sha256 || older ? "keep" : "upgrade",
|
|
1104
1781
|
deployed: true,
|
|
1105
1782
|
currentVersion: s.version,
|
|
1106
1783
|
currentSha256: s.sha256,
|
|
1784
|
+
...(older && { olderThanDeployed: true }),
|
|
1107
1785
|
};
|
|
1108
1786
|
}
|
|
1109
1787
|
return { action: "install", deployed: false, currentVersion: null, currentSha256: null };
|
|
@@ -1113,13 +1791,17 @@ function actionOf(s, sha256) {
|
|
|
1113
1791
|
* current version / package, its own review digest), every template field, each skill's name / path
|
|
1114
1792
|
* / file count, the dependency resolution, the sha256 of every stored file, the format, the
|
|
1115
1793
|
* translation report's items, the sha256 of the license text and the two review flags
|
|
1116
|
-
* (`claudeManifestIgnored`, `licenseTruncated`),
|
|
1794
|
+
* (`claudeManifestIgnored`, `licenseTruncated`), the agent templates when there are any and the
|
|
1795
|
+
* themes when there are any.
|
|
1117
1796
|
* Exported for tests. `repository` is display only.
|
|
1118
1797
|
*/
|
|
1119
1798
|
export function pluginReviewHash(r, files) {
|
|
1120
1799
|
const e = r.extension;
|
|
1121
1800
|
const lic = r.licenseText;
|
|
1122
|
-
|
|
1801
|
+
// canonicalJson, not JSON.stringify: the review is stored as jsonb, which reorders object keys,
|
|
1802
|
+
// so a template's auth / endpoint object would hash differently at confirm (plugin.review_stale
|
|
1803
|
+
// on every import of a plugin whose connector template has a non-trivial auth block).
|
|
1804
|
+
const canonical = canonicalJson([
|
|
1123
1805
|
r.name,
|
|
1124
1806
|
r.version,
|
|
1125
1807
|
r.contentDigest,
|
|
@@ -1146,9 +1828,34 @@ export function pluginReviewHash(r, files) {
|
|
|
1146
1828
|
...((r.agentTemplates ?? []).length > 0
|
|
1147
1829
|
? [(r.agentTemplates ?? []).map((a) => [a.path, canonicalJson(a)])]
|
|
1148
1830
|
: []),
|
|
1831
|
+
// themes, only when there are any, tagged (never read as agent templates)
|
|
1832
|
+
...((r.themes ?? []).length > 0
|
|
1833
|
+
? [{ themes: (r.themes ?? []).map((t) => [t.id, canonicalJson(t)]) }]
|
|
1834
|
+
: []),
|
|
1149
1835
|
]);
|
|
1150
1836
|
return createHash("sha256").update(canonical).digest("hex").slice(0, 32);
|
|
1151
1837
|
}
|
|
1838
|
+
/** The client code of a read extension package for its review (sizes from the package's files). */
|
|
1839
|
+
function reviewClient(pkg) {
|
|
1840
|
+
const c = pkg.section.client;
|
|
1841
|
+
const sizes = new Map(pkg.files.map((f) => [f.path, f.size]));
|
|
1842
|
+
const files = [
|
|
1843
|
+
...(c.entry !== undefined ? [c.entry] : []),
|
|
1844
|
+
...(c.styles ?? []),
|
|
1845
|
+
...(c.assets ?? []),
|
|
1846
|
+
].map((path) => {
|
|
1847
|
+
// checkClientFiles ran first: every listed file is in the package
|
|
1848
|
+
const size = sizes.get(path.slice(2));
|
|
1849
|
+
if (size === undefined)
|
|
1850
|
+
throw new Error(`client file ${path} is not in the package`);
|
|
1851
|
+
return { path, size };
|
|
1852
|
+
});
|
|
1853
|
+
return {
|
|
1854
|
+
files,
|
|
1855
|
+
totalBytes: files.reduce((n, f) => n + f.size, 0),
|
|
1856
|
+
apiVersion: c.apiVersion,
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1152
1859
|
/**
|
|
1153
1860
|
* A version change that is a downgrade (the imported version below the installed one) whose
|
|
1154
1861
|
* version has migrations not run on this deployment -> `extension.downgrade_unsupported` (the same
|
|
@@ -1183,26 +1890,22 @@ function licenseOf(files) {
|
|
|
1183
1890
|
return { truncated: false };
|
|
1184
1891
|
}
|
|
1185
1892
|
/**
|
|
1186
|
-
* The
|
|
1187
|
-
*
|
|
1188
|
-
* undefined keeps the plugin's flags.
|
|
1893
|
+
* The staging rows a route may see (P3-8): the platform's (`org_id` null) without an owner, else
|
|
1894
|
+
* the owner org's.
|
|
1189
1895
|
*/
|
|
1190
|
-
function
|
|
1191
|
-
|
|
1192
|
-
return m;
|
|
1193
|
-
const byName = new Map(review.skills.map((s) => [s.name, s.path]));
|
|
1194
|
-
const unknown = names.filter((n) => !byName.has(n));
|
|
1195
|
-
if (unknown.length > 0) {
|
|
1196
|
-
throw new ApiError("validation_failed", `pinnedSuggestions: ${unknown.map((n) => JSON.stringify(n)).join(", ")} ${unknown.length === 1 ? "is not a skill" : "are not skills"} of this plugin`);
|
|
1197
|
-
}
|
|
1198
|
-
const paths = new Set(names.map((n) => byName.get(n)));
|
|
1199
|
-
return {
|
|
1200
|
-
...m,
|
|
1201
|
-
skills: (m.skills ?? []).map(({ pinned: _, ...s }) => paths.has(s.path) ? { ...s, pinned: true } : s),
|
|
1202
|
-
};
|
|
1896
|
+
function ownStaging(owner) {
|
|
1897
|
+
return (eb) => owner === undefined ? eb("org_id", "is", null) : eb("org_id", "=", owner.orgId);
|
|
1203
1898
|
}
|
|
1204
|
-
/**
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1899
|
+
/**
|
|
1900
|
+
* An org upload's custom deny, by content (ruling P3-15'): skills or agent templates ->
|
|
1901
|
+
* `customSkills`, connector templates -> `customConnectors`; each `deny` -> 403
|
|
1902
|
+
* `catalog.custom_disabled`. A package carrying neither passes; themes are covered by neither
|
|
1903
|
+
* switch (themes spec §6), so a themes-only upload passes.
|
|
1904
|
+
*/
|
|
1905
|
+
async function assertCustomContent(db, content) {
|
|
1906
|
+
if (content.skills.length > 0 || content.agentTemplates.length > 0) {
|
|
1907
|
+
await assertCustomAllowed(db, "customSkills");
|
|
1908
|
+
}
|
|
1909
|
+
if (content.templates.length > 0)
|
|
1910
|
+
await assertCustomAllowed(db, "customConnectors");
|
|
1208
1911
|
}
|