@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38
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 +5 -5
- package/dist/admin/admin.module.d.ts +3 -2
- package/dist/admin/admin.module.js +9 -5
- package/dist/admin/audit-log.service.d.ts +51 -0
- package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
- package/dist/admin/audit.controller.d.ts +18 -6
- package/dist/admin/audit.controller.js +36 -6
- package/dist/admin/audit.schemas.d.ts +9 -1
- package/dist/admin/audit.schemas.js +22 -2
- package/dist/admin/org-network.controller.d.ts +30 -0
- package/dist/admin/org-network.controller.js +77 -0
- package/dist/admin/org-network.schemas.d.ts +16 -0
- package/dist/admin/org-network.schemas.js +27 -0
- package/dist/admin/org-network.service.d.ts +41 -0
- package/dist/admin/org-network.service.js +101 -0
- package/dist/admin/outbox-dead.controller.d.ts +4 -6
- package/dist/admin/outbox-dead.controller.js +9 -6
- package/dist/admin/outbox-dead.schemas.d.ts +16 -0
- package/dist/admin/outbox-dead.schemas.js +25 -1
- package/dist/admin/outbox-dead.service.d.ts +16 -7
- package/dist/admin/outbox-dead.service.js +34 -10
- package/dist/admin/overview.service.d.ts +3 -3
- package/dist/admin/overview.service.js +0 -1
- package/dist/agents/agent-lookup.js +2 -10
- package/dist/agents/agents.service.js +9 -20
- package/dist/agents/definition.d.ts +3 -51
- package/dist/agents/definition.js +4 -254
- package/dist/agents/org-templates.js +2 -6
- package/dist/agents/readiness.controller.d.ts +4 -12
- package/dist/agents/readiness.controller.js +4 -12
- package/dist/agents/readiness.service.d.ts +23 -11
- package/dist/agents/readiness.service.js +31 -14
- package/dist/agents/templates.d.ts +0 -6
- package/dist/agents/templates.js +8 -34
- package/dist/background/store.d.ts +2 -0
- package/dist/background/store.js +3 -1
- package/dist/background/wake-rules.js +2 -1
- package/dist/catalog/admin-catalog.controller.d.ts +1 -2
- package/dist/catalog/admin-catalog.controller.js +1 -2
- package/dist/catalog/appearance.service.js +1 -3
- package/dist/catalog/catalog-content.d.ts +1 -1
- package/dist/catalog/catalog-content.js +1 -4
- package/dist/catalog/catalog-items.js +3 -3
- package/dist/catalog/catalog-scope.service.d.ts +10 -28
- package/dist/catalog/catalog-scope.service.js +22 -73
- package/dist/catalog/cli.d.ts +0 -11
- package/dist/catalog/cli.js +0 -20
- package/dist/catalog/component-scope.service.js +0 -2
- package/dist/catalog/component-state.js +2 -2
- package/dist/catalog/install-status.d.ts +6 -0
- package/dist/catalog/install-status.js +6 -0
- package/dist/catalog/job-ids.d.ts +0 -4
- package/dist/catalog/job-ids.js +0 -4
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +2 -0
- package/dist/catalog/org-catalog.service.js +8 -3
- package/dist/catalog/org-extension-switch.d.ts +7 -2
- package/dist/catalog/org-extension-switch.js +56 -9
- package/dist/catalog/org-plugin-uploads.d.ts +6 -15
- package/dist/catalog/org-plugin-uploads.js +9 -27
- package/dist/catalog/owned-items.js +1 -3
- package/dist/catalog/platform-import-update.js +1 -1
- package/dist/catalog/plugin-import.d.ts +15 -13
- package/dist/catalog/plugin-import.js +21 -30
- package/dist/catalog/plugin-install.d.ts +3 -43
- package/dist/catalog/plugin-install.js +8 -150
- package/dist/catalog/plugin-package.d.ts +5 -10
- package/dist/catalog/plugin-package.js +12 -33
- package/dist/catalog/plugin-upgrade.js +5 -4
- package/dist/catalog/scope-jobs.d.ts +34 -34
- package/dist/catalog/scope-jobs.js +50 -37
- package/dist/catalog/scope-orgs.d.ts +1 -1
- package/dist/catalog/scope-orgs.js +1 -2
- package/dist/catalog/scope-sync-workers.d.ts +4 -3
- package/dist/catalog/scope-sync-workers.js +18 -6
- package/dist/catalog/scope-sync.d.ts +56 -59
- package/dist/catalog/scope-sync.js +96 -166
- package/dist/catalog/unshare.d.ts +3 -4
- package/dist/catalog/unshare.js +5 -8
- package/dist/channels/job-ids.d.ts +2 -6
- package/dist/channels/job-ids.js +2 -6
- package/dist/channels/outbound.d.ts +1 -1
- package/dist/channels/outbound.js +1 -1
- package/dist/channels/supervisor.d.ts +2 -3
- package/dist/channels/supervisor.js +2 -3
- package/dist/client/client-access.service.js +1 -1
- package/dist/config/env.js +19 -1
- package/dist/config/load.d.ts +0 -6
- package/dist/config/load.js +8 -27
- package/dist/config/schema.d.ts +54 -47
- package/dist/config/schema.js +198 -42
- package/dist/conversations/attachments.service.d.ts +10 -3
- package/dist/conversations/attachments.service.js +49 -16
- package/dist/conversations/conversations.controller.d.ts +0 -39
- package/dist/conversations/conversations.controller.js +0 -39
- package/dist/conversations/event-log.js +4 -1
- package/dist/conversations/events.d.ts +71 -46
- package/dist/conversations/events.js +124 -112
- package/dist/conversations/media-types.d.ts +25 -0
- package/dist/conversations/media-types.js +38 -0
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.service.js +9 -2
- package/dist/conversations/titles.js +6 -0
- package/dist/ctx/create-ctx.d.ts +8 -1
- package/dist/ctx/create-ctx.js +13 -3
- package/dist/ctx/net.d.ts +50 -0
- package/dist/ctx/net.js +67 -0
- package/dist/ctx/secrets.d.ts +24 -7
- package/dist/ctx/secrets.js +97 -30
- package/dist/db/kernel-schema.d.ts +27 -6
- package/dist/devices/devices.service.js +2 -1
- package/dist/errors.d.ts +10 -2
- package/dist/errors.js +10 -2
- package/dist/evals/reconstruct.d.ts +4 -17
- package/dist/evals/reconstruct.js +13 -53
- package/dist/evals/recorded-tools.d.ts +0 -27
- package/dist/evals/recorded-tools.js +2 -92
- package/dist/evals/run-replay.d.ts +1 -6
- package/dist/evals/run-replay.js +10 -17
- package/dist/evals/sets.service.d.ts +17 -5
- package/dist/evals/sets.service.js +33 -12
- package/dist/evals/snapshot.d.ts +1 -2
- package/dist/evals/snapshot.js +4 -17
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +17 -4
- package/dist/extensions/admin-view.d.ts +7 -4
- package/dist/extensions/admin-view.js +27 -21
- package/dist/extensions/bootstrap.js +0 -1
- package/dist/extensions/cli.js +0 -1
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +9 -4
- package/dist/extensions/host.js +14 -8
- package/dist/extensions/installs.d.ts +1 -3
- package/dist/extensions/instance.d.ts +0 -2
- package/dist/extensions/instance.js +0 -3
- package/dist/extensions/org-config.d.ts +4 -4
- package/dist/extensions/org-config.js +13 -22
- package/dist/extensions/package.d.ts +6 -6
- package/dist/extensions/package.js +3 -7
- package/dist/extensions/permission-view.d.ts +2 -4
- package/dist/extensions/plugin-items.d.ts +21 -1
- package/dist/extensions/plugin-items.js +28 -0
- package/dist/extensions/sync.js +5 -10
- package/dist/extensions/unavailable.js +0 -1
- package/dist/http/api.module.js +4 -1
- package/dist/identity/audit.d.ts +0 -12
- package/dist/identity/audit.js +0 -27
- package/dist/identity/auth.controller.js +5 -9
- package/dist/identity/cookies.d.ts +4 -9
- package/dist/identity/cookies.js +8 -32
- package/dist/identity/initial-passwords.d.ts +1 -1
- package/dist/identity/initial-passwords.js +1 -2
- package/dist/identity/sessions.d.ts +0 -6
- package/dist/identity/sessions.js +0 -18
- package/dist/inbox/platform-inbox.service.d.ts +33 -1
- package/dist/inbox/platform-inbox.service.js +56 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
- package/dist/infra/cli/master-key-rewrap.js +24 -0
- package/dist/infra/config/kernel-config.service.js +0 -17
- package/dist/infra/database/transaction-host.d.ts +32 -1
- package/dist/infra/database/transaction-host.js +30 -4
- package/dist/infra/database/xact-lock.d.ts +16 -0
- package/dist/infra/database/xact-lock.js +28 -1
- package/dist/infra/health/health.controller.js +8 -0
- package/dist/infra/health/process-fault.d.ts +16 -0
- package/dist/infra/health/process-fault.js +49 -0
- package/dist/infra/lifecycle/process-guards.d.ts +8 -2
- package/dist/infra/lifecycle/process-guards.js +12 -3
- package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
- package/dist/infra/lifecycle/shutdown-signals.js +28 -13
- package/dist/infra/outbox/outbox.service.d.ts +12 -9
- package/dist/infra/outbox/outbox.service.js +22 -26
- package/dist/infra/outbox/registry.d.ts +15 -7
- package/dist/infra/outbox/registry.js +39 -23
- package/dist/lifecycle/kernel-lifecycle.js +1 -7
- package/dist/models/enablement.d.ts +5 -6
- package/dist/models/enablement.js +7 -14
- package/dist/net/public-address.d.ts +21 -1
- package/dist/net/public-address.js +56 -10
- package/dist/net/safe-fetch.d.ts +4 -1
- package/dist/net/safe-fetch.js +15 -4
- package/dist/orgs/directory-sync.js +2 -0
- package/dist/orgs/members.service.js +5 -0
- package/dist/orgs/network-allowances.service.d.ts +79 -0
- package/dist/orgs/network-allowances.service.js +371 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +9 -2
- package/dist/orgs/org-lock.d.ts +28 -2
- package/dist/orgs/org-lock.js +59 -4
- package/dist/orgs/orgs.controller.d.ts +11 -2
- package/dist/orgs/orgs.controller.js +19 -3
- package/dist/orgs/orgs.module.d.ts +3 -2
- package/dist/orgs/orgs.module.js +6 -2
- package/dist/orgs/orgs.schemas.d.ts +12 -0
- package/dist/orgs/orgs.schemas.js +5 -0
- package/dist/orgs/orgs.service.js +6 -1
- package/dist/orgs/settings.controller.d.ts +3 -2
- package/dist/orgs/settings.service.d.ts +59 -14
- package/dist/orgs/settings.service.js +102 -20
- package/dist/overrides.d.ts +7 -7
- package/dist/overrides.js +4 -4
- package/dist/packages/tgz.d.ts +0 -2
- package/dist/packages/tgz.js +0 -2
- package/dist/platform/exclusions.js +0 -5
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.d.ts +2 -2
- package/dist/platform/ops/admin.ops.js +9 -6
- package/dist/platform/ops/agents.ops.js +1 -1
- package/dist/platform/ops/connectors.ops.js +46 -1
- package/dist/platform/ops/evals.ops.js +1 -64
- package/dist/platform/ops/extensions-admin.ops.js +1 -1
- package/dist/platform/ops/inbox.ops.js +16 -3
- package/dist/platform/ops/org-plugins.ops.js +1 -1
- package/dist/platform/ops/orgs.ops.d.ts +11 -3
- package/dist/platform/ops/orgs.ops.js +139 -5
- package/dist/platform/ops/outbox.ops.js +5 -5
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker-role.d.ts +2 -3
- package/dist/roles/worker-role.js +3 -13
- package/dist/runtime/checkpointer.d.ts +3 -0
- package/dist/runtime/checkpointer.js +7 -4
- package/dist/runtime/context/build.d.ts +56 -18
- package/dist/runtime/context/build.js +143 -50
- package/dist/runtime/context/compaction.d.ts +1 -3
- package/dist/runtime/context/compaction.js +42 -8
- package/dist/runtime/context/run-context.js +1 -2
- package/dist/runtime/context/skills.d.ts +27 -56
- package/dist/runtime/context/skills.js +42 -114
- package/dist/runtime/context/tool-changes.d.ts +3 -3
- package/dist/runtime/context/tool-changes.js +6 -16
- package/dist/runtime/hook-calls.d.ts +6 -6
- package/dist/runtime/hook-calls.js +7 -7
- package/dist/runtime/langgraph-loop.js +9 -3
- package/dist/runtime/maintenance.d.ts +3 -11
- package/dist/runtime/maintenance.js +5 -20
- package/dist/runtime/model-call.d.ts +5 -0
- package/dist/runtime/model-call.js +48 -36
- package/dist/runtime/providers.d.ts +33 -35
- package/dist/runtime/providers.js +64 -109
- package/dist/runtime/run-context.service.js +7 -22
- package/dist/runtime/run-deletion.d.ts +6 -0
- package/dist/runtime/run-deletion.js +39 -16
- package/dist/runtime/run-execution.d.ts +56 -3
- package/dist/runtime/run-execution.js +81 -11
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-liveness.d.ts +11 -0
- package/dist/runtime/run-liveness.js +19 -0
- package/dist/runtime/run-orphan-check.job.js +2 -1
- package/dist/runtime/run-queue.js +8 -16
- package/dist/runtime/run-worker.d.ts +2 -2
- package/dist/runtime/run-worker.js +8 -6
- package/dist/runtime/step-log.d.ts +5 -0
- package/dist/runtime/step-log.js +9 -4
- package/dist/runtime/subagents/definition.d.ts +16 -20
- package/dist/runtime/subagents/definition.js +27 -27
- package/dist/runtime/subagents/dispatch.d.ts +6 -2
- package/dist/runtime/subagents/dispatch.js +17 -3
- package/dist/runtime/subagents/org-agents.js +1 -2
- package/dist/runtime/subagents/preamble.d.ts +3 -2
- package/dist/runtime/subagents/preamble.js +3 -2
- package/dist/runtime/subagents/render.d.ts +1 -2
- package/dist/runtime/subagents/render.js +1 -2
- package/dist/runtime/subagents/skill-fork.d.ts +2 -4
- package/dist/runtime/subagents/template-skills.d.ts +47 -0
- package/dist/runtime/subagents/template-skills.js +76 -0
- package/dist/runtime/waits.js +3 -1
- package/dist/schedules/effective-settings.d.ts +9 -3
- package/dist/schedules/effective-settings.js +5 -4
- package/dist/schedules/fire.js +11 -0
- package/dist/schedules/scheduled-tasks.service.js +5 -0
- package/dist/schedules/unattended.d.ts +2 -0
- package/dist/schedules/unattended.js +6 -1
- package/dist/skills/agent-skills.service.js +1 -2
- package/dist/skills/catalog.d.ts +1 -3
- package/dist/skills/catalog.js +1 -3
- package/dist/skills/conversation-catalog.d.ts +1 -2
- package/dist/skills/conversation-catalog.js +1 -2
- package/dist/skills/usable.js +2 -3
- package/dist/storage/storage.service.js +9 -1
- package/dist/tools/approvals.service.js +2 -4
- package/dist/tools/builtin-names.d.ts +2 -9
- package/dist/tools/builtin-names.js +4 -13
- package/dist/tools/builtins/sandbox/bash.js +3 -3
- package/dist/tools/builtins/sandbox/common.d.ts +7 -13
- package/dist/tools/builtins/sandbox/common.js +8 -115
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
- package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
- package/dist/tools/builtins/sandbox/glob.js +1 -3
- package/dist/tools/builtins/sandbox/grep.js +3 -5
- package/dist/tools/builtins/sandbox/index.d.ts +8 -5
- package/dist/tools/builtins/sandbox/index.js +10 -5
- package/dist/tools/builtins/sandbox/read.js +3 -2
- package/dist/tools/builtins/tool-search.d.ts +4 -7
- package/dist/tools/builtins/tool-search.js +6 -10
- package/dist/tools/connector-account-policies.d.ts +30 -3
- package/dist/tools/connector-account-policies.js +54 -7
- package/dist/tools/connector-content.js +1 -0
- package/dist/tools/connectors.controller.d.ts +24 -11
- package/dist/tools/connectors.controller.js +35 -6
- package/dist/tools/connectors.schemas.d.ts +14 -1
- package/dist/tools/connectors.schemas.js +14 -2
- package/dist/tools/connectors.service.d.ts +22 -0
- package/dist/tools/connectors.service.js +65 -6
- package/dist/tools/drift.d.ts +6 -2
- package/dist/tools/drift.js +10 -5
- package/dist/tools/git-push-policy.d.ts +4 -1
- package/dist/tools/git-push-policy.js +3 -1
- package/dist/tools/info.d.ts +1 -7
- package/dist/tools/info.js +5 -18
- package/dist/tools/job-ids.d.ts +0 -4
- package/dist/tools/job-ids.js +1 -6
- package/dist/tools/pipeline.d.ts +4 -10
- package/dist/tools/pipeline.js +17 -62
- package/dist/tools/policy.d.ts +6 -2
- package/dist/tools/policy.js +14 -12
- package/dist/tools/registry.js +1 -5
- package/dist/ui/views.d.ts +5 -5
- package/dist/ui/views.js +10 -16
- package/package.json +3 -3
- package/src/migrations/0137_audit_org_idx.sql +5 -0
- package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
- package/src/migrations/0139_retire_legacy_forms.sql +183 -0
- package/src/migrations/0140_retire_history_forms.sql +148 -0
- package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
- package/src/migrations/0142_backfill_event_fields.sql +74 -0
- package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
- package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
- package/src/migrations/0145_org_network_allowances.sql +12 -0
- package/dist/admin/platform-audit.service.d.ts +0 -41
- package/dist/conversations/job-ids.d.ts +0 -6
- package/dist/conversations/job-ids.js +0 -6
- package/dist/extensions/job-ids.d.ts +0 -6
- package/dist/extensions/job-ids.js +0 -6
- package/dist/infra/queue/retired-schedulers.d.ts +0 -7
- package/dist/infra/queue/retired-schedulers.js +0 -9
- package/dist/orgs/job-ids.d.ts +0 -8
- package/dist/orgs/job-ids.js +0 -8
- package/dist/runtime/context/legacy-text.d.ts +0 -22
- package/dist/runtime/context/legacy-text.js +0 -37
- package/dist/runtime/job-ids.d.ts +0 -10
- package/dist/runtime/job-ids.js +0 -10
- package/dist/runtime/retired-schedulers.d.ts +0 -7
- package/dist/runtime/retired-schedulers.js +0 -31
- package/dist/storage/job-ids.d.ts +0 -6
- package/dist/storage/job-ids.js +0 -6
- package/dist/tools/legacy-data.d.ts +0 -34
- package/dist/tools/legacy-data.js +0 -76
- package/dist/tools/legacy-keys.d.ts +0 -51
- package/dist/tools/legacy-keys.js +0 -114
|
@@ -23,6 +23,7 @@ import { StorageService } from "../storage/storage.service.js";
|
|
|
23
23
|
import { catalogHasIcon, findConnectorIn, orgTemplateView, readCatalogIcon, readCatalogTemplates, templatePluginProblem, } from "./catalog-content.js";
|
|
24
24
|
import { itemView, ownerOnlyFacts, versionUsable } from "./catalog-items.js";
|
|
25
25
|
import { connectorTemplatesOn, templateIdOfPath } from "./component-state.js";
|
|
26
|
+
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
26
27
|
import { itemPendingError, ownerOf, ownersOf } from "./ownership.js";
|
|
27
28
|
import { PluginInstaller, uninstallPreviewHash, upsertOrgSwitch, } from "./plugin-install.js";
|
|
28
29
|
import { requestable, switchable, visibleTo, wantedOn } from "./scope.js";
|
|
@@ -135,7 +136,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
135
136
|
.selectFrom("plugin_installs")
|
|
136
137
|
.select(["id", "item_id", "version"])
|
|
137
138
|
.where("org_id", "=", orgId)
|
|
138
|
-
.where("status", "in", [
|
|
139
|
+
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
139
140
|
.execute(),
|
|
140
141
|
this.db
|
|
141
142
|
.selectFrom("extension_org_configs")
|
|
@@ -450,6 +451,10 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
450
451
|
}
|
|
451
452
|
return item;
|
|
452
453
|
}
|
|
454
|
+
/** Whether the org has a live install of the item (switching it on then installs nothing). */
|
|
455
|
+
async hasLiveInstall(orgId, itemId) {
|
|
456
|
+
return (await this.liveInstall(orgId, itemId)) !== undefined;
|
|
457
|
+
}
|
|
453
458
|
/** The org's live plugin install of the item, if any. */
|
|
454
459
|
liveInstall(orgId, itemId) {
|
|
455
460
|
return this.db
|
|
@@ -457,7 +462,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
457
462
|
.select("id")
|
|
458
463
|
.where("org_id", "=", orgId)
|
|
459
464
|
.where("item_id", "=", itemId)
|
|
460
|
-
.where("status", "in", [
|
|
465
|
+
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
461
466
|
.executeTakeFirst();
|
|
462
467
|
}
|
|
463
468
|
/**
|
|
@@ -526,7 +531,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
526
531
|
.where("a.org_id", "=", orgId)
|
|
527
532
|
.executeTakeFirst();
|
|
528
533
|
// A failed or stuck install is cleaned up whatever the scope (it is not on anyway)
|
|
529
|
-
const live = row?.status === "installed"
|
|
534
|
+
const live = row?.status === "installed";
|
|
530
535
|
if (row !== undefined && live && !switchable(row)) {
|
|
531
536
|
throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be uninstalled here");
|
|
532
537
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OrgExtensionConfigs, type OrgExtensionInput, type OrgExtensionView } from "../extensions/org-config.js";
|
|
2
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
2
3
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
3
4
|
import type { UninstallPreview } from "./plugin-install.js";
|
|
4
5
|
/** The result of {@link OrgExtensionSwitch.put}: the extension, or the plugin uninstall preview. */
|
|
@@ -21,12 +22,14 @@ export type OrgExtensionPutResult = {
|
|
|
21
22
|
* the effective config (the stored one with its secrets, or the given `config` merged with them),
|
|
22
23
|
* and the install receives the given `config` as its `extensionConfig`, so the extension is enabled
|
|
23
24
|
* with it. A config write that fails for another reason after the switch succeeded returns that
|
|
24
|
-
* error
|
|
25
|
+
* error in the same transaction as the switch, so the switch stays as it was (a fresh install is the
|
|
26
|
+
* exception: it commits on its own and carries the config itself).
|
|
25
27
|
*/
|
|
26
28
|
export declare class OrgExtensionSwitch {
|
|
29
|
+
readonly txHost: TransactionHost;
|
|
27
30
|
private readonly configs;
|
|
28
31
|
private readonly catalog;
|
|
29
|
-
constructor(configs: OrgExtensionConfigs, catalog: OrgCatalogService);
|
|
32
|
+
constructor(txHost: TransactionHost, configs: OrgExtensionConfigs, catalog: OrgCatalogService);
|
|
30
33
|
/**
|
|
31
34
|
* - `enabled` on an extension of one catalog plugin: that plugin's switch; off without `confirm`
|
|
32
35
|
* returns the preview and its hash, with the hash uninstalls; a builtin plugin (any of several
|
|
@@ -38,4 +41,6 @@ export declare class OrgExtensionSwitch {
|
|
|
38
41
|
put(orgId: string, actor: string, extension: string, body: OrgExtensionInput & {
|
|
39
42
|
confirm?: string | undefined;
|
|
40
43
|
}, actorTokenId?: string): Promise<OrgExtensionPutResult>;
|
|
44
|
+
private applyAtomic;
|
|
45
|
+
private apply;
|
|
41
46
|
}
|
|
@@ -10,6 +10,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
12
|
import { OrgExtensionConfigs, } from "../extensions/org-config.js";
|
|
13
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
14
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
13
15
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
14
16
|
/**
|
|
15
17
|
* `PUT orgs/:orgId/extensions/:extension`: for an extension that ships in a catalog plugin, `enabled`
|
|
@@ -22,12 +24,15 @@ import { OrgCatalogService } from "./org-catalog.service.js";
|
|
|
22
24
|
* the effective config (the stored one with its secrets, or the given `config` merged with them),
|
|
23
25
|
* and the install receives the given `config` as its `extensionConfig`, so the extension is enabled
|
|
24
26
|
* with it. A config write that fails for another reason after the switch succeeded returns that
|
|
25
|
-
* error
|
|
27
|
+
* error in the same transaction as the switch, so the switch stays as it was (a fresh install is the
|
|
28
|
+
* exception: it commits on its own and carries the config itself).
|
|
26
29
|
*/
|
|
27
30
|
let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
31
|
+
txHost;
|
|
28
32
|
configs;
|
|
29
33
|
catalog;
|
|
30
|
-
constructor(configs, catalog) {
|
|
34
|
+
constructor(txHost, configs, catalog) {
|
|
35
|
+
this.txHost = txHost;
|
|
31
36
|
this.configs = configs;
|
|
32
37
|
this.catalog = catalog;
|
|
33
38
|
}
|
|
@@ -60,8 +65,48 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
60
65
|
if (enabled || input.config !== undefined) {
|
|
61
66
|
await this.configs.put(orgId, extension, { ...config, ...(enabled && { enabled: true }) }, actor, actorTokenId, { validateOnly: true });
|
|
62
67
|
}
|
|
68
|
+
// A fresh install is a multi-step saga that commits on its own and already enables the
|
|
69
|
+
// extension with the given config (`extensionConfig`): no transaction spans it, and no second
|
|
70
|
+
// config write follows. Everything else (the switch row, an uninstall, the config write) is one
|
|
71
|
+
// transaction: a failing config write leaves the switch as it was.
|
|
72
|
+
const installing = enabled === true && !(await this.catalog.hasLiveInstall(orgId, plan.itemId));
|
|
73
|
+
const args = {
|
|
74
|
+
orgId,
|
|
75
|
+
actor,
|
|
76
|
+
extension,
|
|
77
|
+
itemId: plan.itemId,
|
|
78
|
+
enabled,
|
|
79
|
+
input,
|
|
80
|
+
confirm,
|
|
81
|
+
actorTokenId,
|
|
82
|
+
};
|
|
83
|
+
const r = await (installing ? this.apply(args, true) : this.applyAtomic(args));
|
|
84
|
+
if (r !== "readBack")
|
|
85
|
+
return r;
|
|
86
|
+
// Read after the commit: the list reads its own snapshot, which sees only committed rows
|
|
87
|
+
const view = (await this.configs.list(orgId)).find((v) => v.plugin === extension);
|
|
88
|
+
if (view)
|
|
89
|
+
return { kind: "done", view };
|
|
90
|
+
return {
|
|
91
|
+
kind: "done",
|
|
92
|
+
view: await this.configs.put(orgId, extension, { enabled: true }, actor, actorTokenId, {
|
|
93
|
+
ifDisabled: { skipped: false },
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
applyAtomic(a) {
|
|
98
|
+
return this.apply(a, false);
|
|
99
|
+
}
|
|
100
|
+
async apply(a, installing) {
|
|
101
|
+
const { orgId, actor, extension, itemId, enabled, input, confirm, actorTokenId } = a;
|
|
102
|
+
// Switching on inside the transaction relies on the live install seen before it: one removed
|
|
103
|
+
// meanwhile would run the install saga here, which commits on its own. Refuse instead; the
|
|
104
|
+
// retry takes the install path.
|
|
105
|
+
if (!installing && enabled === true && !(await this.catalog.hasLiveInstall(orgId, itemId))) {
|
|
106
|
+
throw new ApiError("conflict", "The plugin's install in this organization changed while it was being switched on; try again");
|
|
107
|
+
}
|
|
63
108
|
const r = await this.catalog
|
|
64
|
-
.setSwitch(orgId, actor,
|
|
109
|
+
.setSwitch(orgId, actor, itemId, enabled
|
|
65
110
|
? {
|
|
66
111
|
enabled: true,
|
|
67
112
|
...(input.config !== undefined && { inputs: { extensionConfig: input.config } }),
|
|
@@ -74,9 +119,7 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
74
119
|
return r;
|
|
75
120
|
if (input.config === undefined) {
|
|
76
121
|
if (!enabled) {
|
|
77
|
-
|
|
78
|
-
if (view)
|
|
79
|
-
return { kind: "done", view };
|
|
122
|
+
return "readBack";
|
|
80
123
|
}
|
|
81
124
|
// Switching on: the install enabled it already (no second write)
|
|
82
125
|
return {
|
|
@@ -88,14 +131,18 @@ let OrgExtensionSwitch = class OrgExtensionSwitch {
|
|
|
88
131
|
}
|
|
89
132
|
return {
|
|
90
133
|
kind: "done",
|
|
91
|
-
view: await this.configs.put(orgId, extension, { config: input.config, ...(enabled && { enabled: true }) }, actor, actorTokenId),
|
|
134
|
+
view: await this.configs.put(orgId, extension, { config: input.config, ...(enabled && { enabled: true }) }, actor, actorTokenId, installing ? { ifDisabled: { skipped: false } } : undefined),
|
|
92
135
|
};
|
|
93
136
|
}
|
|
94
137
|
};
|
|
138
|
+
__decorate([
|
|
139
|
+
Transactional()
|
|
140
|
+
], OrgExtensionSwitch.prototype, "applyAtomic", null);
|
|
95
141
|
OrgExtensionSwitch = __decorate([
|
|
96
142
|
Injectable(),
|
|
97
|
-
__param(0, Inject(
|
|
98
|
-
__param(1, Inject(
|
|
143
|
+
__param(0, Inject(TransactionHost)),
|
|
144
|
+
__param(1, Inject(OrgExtensionConfigs)),
|
|
145
|
+
__param(2, Inject(OrgCatalogService))
|
|
99
146
|
], OrgExtensionSwitch);
|
|
100
147
|
export { OrgExtensionSwitch };
|
|
101
148
|
/**
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { SingleProviderNote } from "../extensions/single-provider.js";
|
|
2
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
3
2
|
import type { ActorOpts, CatalogItemView } from "./catalog.service.js";
|
|
4
|
-
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
5
3
|
import { PluginImport, type PluginReview } from "./plugin-import.js";
|
|
6
4
|
import { PlatformPluginUpdater, type PlatformUpdatePreview } from "./plugin-upgrade.js";
|
|
7
5
|
/** A staged org upload: the review, and the update preview of a new version (null: none). */
|
|
@@ -40,10 +38,8 @@ export declare function ownerUpdateHash(reviewHash: string, diffHash: string): s
|
|
|
40
38
|
/**
|
|
41
39
|
* An org admin's plugin upload (spec §14.1 item 1, rulings P3-7, P3-8, P3-12, P3-13 to P3-15'): a
|
|
42
40
|
* `.tgz` prepared and confirmed through {@link PluginImport} in owner mode (the org's own staging,
|
|
43
|
-
* its admin re-checked under the org row lock), owned by the org with scope `named: [owner]`.
|
|
44
|
-
*
|
|
45
|
-
* `PluginImport` cannot reach the scope service, which depends on it), and installs it in the
|
|
46
|
-
* owner org.
|
|
41
|
+
* its admin re-checked under the org row lock), owned by the org with scope `named: [owner]`. The
|
|
42
|
+
* confirm's commit owes the item's scope sync, which installs it in the owner org.
|
|
47
43
|
*
|
|
48
44
|
* A new version of the org's own plugin without an extension (P3-12, P3-12') is reviewed with the
|
|
49
45
|
* platform update it applies (`PlatformPluginUpdater.previewForOwner` on the staged target,
|
|
@@ -54,24 +50,19 @@ export declare function ownerUpdateHash(reviewHash: string, diffHash: string): s
|
|
|
54
50
|
*/
|
|
55
51
|
export declare class OrgPluginUploads {
|
|
56
52
|
private readonly pluginImport;
|
|
57
|
-
private readonly scope;
|
|
58
53
|
private readonly updater;
|
|
59
|
-
|
|
60
|
-
constructor(pluginImport: PluginImport, scope: CatalogScopeService, updater: PlatformPluginUpdater, txHost: TransactionHost);
|
|
54
|
+
constructor(pluginImport: PluginImport, updater: PlatformPluginUpdater);
|
|
61
55
|
/** Reads, checks and stages the uploaded tgz for the org (see `PluginImport.prepare`). */
|
|
62
56
|
prepare(actor: string, orgId: string, bytes: Uint8Array, opts?: ActorOpts): Promise<OrgUploadReview>;
|
|
63
57
|
/** The org's own staged upload; another org's or the platform's -> 404 `plugin.staging_not_found`. */
|
|
64
58
|
staged(orgId: string, stagingId: string): Promise<OrgUploadReview>;
|
|
65
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Confirms the org's staged upload (applying a new version); its commit owes the scope sync.
|
|
61
|
+
*/
|
|
66
62
|
confirm(actor: string, orgId: string, stagingId: string, input: {
|
|
67
63
|
reviewHash: string;
|
|
68
64
|
shareable?: boolean;
|
|
69
65
|
}, opts?: ActorOpts): Promise<OrgUploadResult>;
|
|
70
|
-
/**
|
|
71
|
-
* Owes the confirmed item's scope sync in a transaction of its own: the confirm's writes span
|
|
72
|
-
* more than one transaction (`PluginImport.confirm`), and the sync follows the last of them.
|
|
73
|
-
*/
|
|
74
|
-
private oweSync;
|
|
75
66
|
/** The review with the update preview of a new version and the combined hash (P3-12). */
|
|
76
67
|
private withUpdate;
|
|
77
68
|
}
|
|
@@ -10,10 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { ApiError } from "../errors.js";
|
|
13
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
14
|
-
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
15
13
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
16
|
-
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
17
14
|
import { PluginImport } from "./plugin-import.js";
|
|
18
15
|
import { PlatformPluginUpdater } from "./plugin-upgrade.js";
|
|
19
16
|
/** The hash an org confirms a new version with: the review's and the update's (P3-12). */
|
|
@@ -27,10 +24,8 @@ const reviewStale = (name, version) => new ApiError("plugin.review_stale", `The
|
|
|
27
24
|
/**
|
|
28
25
|
* An org admin's plugin upload (spec §14.1 item 1, rulings P3-7, P3-8, P3-12, P3-13 to P3-15'): a
|
|
29
26
|
* `.tgz` prepared and confirmed through {@link PluginImport} in owner mode (the org's own staging,
|
|
30
|
-
* its admin re-checked under the org row lock), owned by the org with scope `named: [owner]`.
|
|
31
|
-
*
|
|
32
|
-
* `PluginImport` cannot reach the scope service, which depends on it), and installs it in the
|
|
33
|
-
* owner org.
|
|
27
|
+
* its admin re-checked under the org row lock), owned by the org with scope `named: [owner]`. The
|
|
28
|
+
* confirm's commit owes the item's scope sync, which installs it in the owner org.
|
|
34
29
|
*
|
|
35
30
|
* A new version of the org's own plugin without an extension (P3-12, P3-12') is reviewed with the
|
|
36
31
|
* platform update it applies (`PlatformPluginUpdater.previewForOwner` on the staged target,
|
|
@@ -41,14 +36,10 @@ const reviewStale = (name, version) => new ApiError("plugin.review_stale", `The
|
|
|
41
36
|
*/
|
|
42
37
|
let OrgPluginUploads = class OrgPluginUploads {
|
|
43
38
|
pluginImport;
|
|
44
|
-
scope;
|
|
45
39
|
updater;
|
|
46
|
-
|
|
47
|
-
constructor(pluginImport, scope, updater, txHost) {
|
|
40
|
+
constructor(pluginImport, updater) {
|
|
48
41
|
this.pluginImport = pluginImport;
|
|
49
|
-
this.scope = scope;
|
|
50
42
|
this.updater = updater;
|
|
51
|
-
this.txHost = txHost;
|
|
52
43
|
}
|
|
53
44
|
/** Reads, checks and stages the uploaded tgz for the org (see `PluginImport.prepare`). */
|
|
54
45
|
async prepare(actor, orgId, bytes, opts = {}) {
|
|
@@ -60,7 +51,9 @@ let OrgPluginUploads = class OrgPluginUploads {
|
|
|
60
51
|
const r = await this.pluginImport.staged(stagingId, { orgId });
|
|
61
52
|
return this.withUpdate(orgId, r.stagingId, r.review);
|
|
62
53
|
}
|
|
63
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Confirms the org's staged upload (applying a new version); its commit owes the scope sync.
|
|
56
|
+
*/
|
|
64
57
|
async confirm(actor, orgId, stagingId, input, opts = {}) {
|
|
65
58
|
const st = await this.pluginImport.stagedTarget(stagingId, { orgId });
|
|
66
59
|
if (!appliesAtOnce(st)) {
|
|
@@ -71,7 +64,6 @@ let OrgPluginUploads = class OrgPluginUploads {
|
|
|
71
64
|
// A version waiting for the super admin is synced by their confirmation (P3-10)
|
|
72
65
|
if (r.pending)
|
|
73
66
|
return { item: r.item, outcome: "pending" };
|
|
74
|
-
await this.oweSync(r.item.id);
|
|
75
67
|
return { item: r.item, outcome: r.firstVersion ? "installed" : "updated" };
|
|
76
68
|
}
|
|
77
69
|
// The one hash covers the review and the update (P3-12): both recomputed now
|
|
@@ -82,6 +74,8 @@ let OrgPluginUploads = class OrgPluginUploads {
|
|
|
82
74
|
const r = await this.pluginImport.confirm(actor, stagingId, {
|
|
83
75
|
reviewHash: st.reviewHash,
|
|
84
76
|
...(input.shareable !== undefined && { shareable: input.shareable }),
|
|
77
|
+
// the update below owes the scope sync with its commit
|
|
78
|
+
updateFollows: true,
|
|
85
79
|
}, { ...opts, owner: { orgId } });
|
|
86
80
|
// The version is committed; a failed update leaves it imported (uploading it again retries)
|
|
87
81
|
const u = await this.updater.updateAsOwner(orgId, actor, r.item.id, st.version, preview.diffHash, opts);
|
|
@@ -93,13 +87,6 @@ let OrgPluginUploads = class OrgPluginUploads {
|
|
|
93
87
|
}),
|
|
94
88
|
};
|
|
95
89
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Owes the confirmed item's scope sync in a transaction of its own: the confirm's writes span
|
|
98
|
-
* more than one transaction (`PluginImport.confirm`), and the sync follows the last of them.
|
|
99
|
-
*/
|
|
100
|
-
async oweSync(itemId) {
|
|
101
|
-
await this.scope.enqueueSync(itemId);
|
|
102
|
-
}
|
|
103
90
|
/** The review with the update preview of a new version and the combined hash (P3-12). */
|
|
104
91
|
async withUpdate(orgId, stagingId, review) {
|
|
105
92
|
const st = await this.pluginImport.stagedTarget(stagingId, { orgId });
|
|
@@ -113,15 +100,10 @@ let OrgPluginUploads = class OrgPluginUploads {
|
|
|
113
100
|
};
|
|
114
101
|
}
|
|
115
102
|
};
|
|
116
|
-
__decorate([
|
|
117
|
-
Transactional()
|
|
118
|
-
], OrgPluginUploads.prototype, "oweSync", null);
|
|
119
103
|
OrgPluginUploads = __decorate([
|
|
120
104
|
Injectable(),
|
|
121
105
|
__param(0, Inject(PluginImport)),
|
|
122
|
-
__param(1, Inject(
|
|
123
|
-
__param(2, Inject(PlatformPluginUpdater)),
|
|
124
|
-
__param(3, Inject(TransactionHost))
|
|
106
|
+
__param(1, Inject(PlatformPluginUpdater))
|
|
125
107
|
], OrgPluginUploads);
|
|
126
108
|
export { OrgPluginUploads };
|
|
127
109
|
/**
|
|
@@ -423,7 +423,6 @@ let OwnedItems = class OwnedItems {
|
|
|
423
423
|
pending_at: null,
|
|
424
424
|
...(!item.shareable && { shown_to_others: false }),
|
|
425
425
|
...(item.scope === "all" && { scope: "named" }),
|
|
426
|
-
scope_version: sql `scope_version + 1`,
|
|
427
426
|
updated_at: now,
|
|
428
427
|
})
|
|
429
428
|
.where("id", "=", item.id)
|
|
@@ -470,7 +469,7 @@ let OwnedItems = class OwnedItems {
|
|
|
470
469
|
for (const { c, orgs } of narrow) {
|
|
471
470
|
await t
|
|
472
471
|
.updateTable(TABLE_OF[c.kind])
|
|
473
|
-
.set({ scope: "named",
|
|
472
|
+
.set({ scope: "named", updated_at: now })
|
|
474
473
|
.where("id", "=", c.id)
|
|
475
474
|
.execute();
|
|
476
475
|
await t
|
|
@@ -622,7 +621,6 @@ let OwnedItems = class OwnedItems {
|
|
|
622
621
|
...(!c.shareable && { shown_to_others: false }),
|
|
623
622
|
...(narrowTo !== null && {
|
|
624
623
|
scope: "named",
|
|
625
|
-
scope_version: sql `scope_version + 1`,
|
|
626
624
|
}),
|
|
627
625
|
updated_at: now,
|
|
628
626
|
})
|
|
@@ -62,7 +62,7 @@ let PlatformImportUpdate = class PlatformImportUpdate {
|
|
|
62
62
|
}
|
|
63
63
|
// The review hash is checked by the import's confirm (409 plugin.review_stale, nothing
|
|
64
64
|
// written)
|
|
65
|
-
const imported = await this.pluginImport.confirm(actor, stagingId, { reviewHash: input.reviewHash, deploy: false }, opts);
|
|
65
|
+
const imported = await this.pluginImport.confirm(actor, stagingId, { reviewHash: input.reviewHash, deploy: false, updateFollows: true }, opts);
|
|
66
66
|
try {
|
|
67
67
|
const update = await this.updater.updateHeld(actor, st.itemId, { version: st.version, diffHash: input.diffHash }, opts);
|
|
68
68
|
return { item: await this.pluginImport.view(st.itemId), update };
|
|
@@ -33,8 +33,7 @@ import type { PluginScope } from "./scope.js";
|
|
|
33
33
|
*
|
|
34
34
|
* prepare: the tgz is always hostile input, and **nothing is written until every check passes**
|
|
35
35
|
* (F-AD): `readPluginPackage` (plugin.json, package.json, listed / scanned skills and templates,
|
|
36
|
-
* icons
|
|
37
|
-
* (`readExtensionPackage`), the extension's deployment state (config-declared names are
|
|
36
|
+
* icons), the extension's module graph and migrations (`readExtensionPackage`), the extension's deployment state (config-declared names are
|
|
38
37
|
* refused; name ownership; a downgrade to a version with unrun migrations is refused), each skill by
|
|
39
38
|
* the skill package rules, each connector template against the connector loaded on this replica (or
|
|
40
39
|
* statically when the connector is provided by the plugin's own extension or by a dependency), the
|
|
@@ -387,9 +386,8 @@ export interface StagedTarget {
|
|
|
387
386
|
};
|
|
388
387
|
}
|
|
389
388
|
/**
|
|
390
|
-
* The API error of a plugin package that cannot be read in a catalog path:
|
|
391
|
-
* `
|
|
392
|
-
* spec §5) -> `theme.invalid` (details `[{ theme, errors }]`) or `theme.unreadable` (details
|
|
389
|
+
* The API error of a plugin package that cannot be read in a catalog path: undeclared client code
|
|
390
|
+
* -> `client.undeclared`; a failing theme (themes spec §5) -> `theme.invalid` (details `[{ theme, errors }]`) or `theme.unreadable` (details
|
|
393
391
|
* `[{ theme, issues }]`, the failing pairs); anything else -> `catalog.invalid_manifest` (issues as
|
|
394
392
|
* details).
|
|
395
393
|
*/
|
|
@@ -417,10 +415,8 @@ export declare class PluginImport {
|
|
|
417
415
|
private readonly platform;
|
|
418
416
|
/** The client build of a dropped org upload's package is deleted with it. */
|
|
419
417
|
private readonly clientBuilds;
|
|
420
|
-
/** The scope sync
|
|
418
|
+
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
421
419
|
private readonly outbox;
|
|
422
|
-
/** The backstop's delay (a test seam; default `SCOPE_BACKSTOP_DELAY_MS`). */
|
|
423
|
-
private readonly backstopDelayMs;
|
|
424
420
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
425
421
|
private files;
|
|
426
422
|
/**
|
|
@@ -442,10 +438,8 @@ export declare class PluginImport {
|
|
|
442
438
|
platform: PlatformComponents,
|
|
443
439
|
/** The client build of a dropped org upload's package is deleted with it. */
|
|
444
440
|
clientBuilds: ClientBuilds,
|
|
445
|
-
/** The scope sync
|
|
446
|
-
outbox: Pick<OutboxService, "add"
|
|
447
|
-
/** The backstop's delay (a test seam; default `SCOPE_BACKSTOP_DELAY_MS`). */
|
|
448
|
-
backstopDelayMs?: number);
|
|
441
|
+
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
442
|
+
outbox: Pick<OutboxService, "add">);
|
|
449
443
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
450
444
|
private get db();
|
|
451
445
|
/**
|
|
@@ -557,7 +551,7 @@ export declare class PluginImport {
|
|
|
557
551
|
* extension's deploy result (a failed deploy is returned, not thrown). `scope` (default
|
|
558
552
|
* `optional`) and `orgs` (only with `named`; each an existing org, else `validation_failed`) are
|
|
559
553
|
* written when this confirm creates the item; a new version of an existing item keeps its scope.
|
|
560
|
-
* The
|
|
554
|
+
* The commit owes the item's scope sync, or the extension's deploy does (see {@link commit}).
|
|
561
555
|
*
|
|
562
556
|
* An org upload (`opts.owner`, spec §14): only that org's staging; the actor re-checked as its
|
|
563
557
|
* admin; `scope` / `orgs` are not taken: a new item is owned by the org, scope `named: [owner]`,
|
|
@@ -587,6 +581,14 @@ export declare class PluginImport {
|
|
|
587
581
|
* `approval`.
|
|
588
582
|
*/
|
|
589
583
|
deploy?: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* A platform update of the item to this version follows the confirm (`PlatformImportUpdate`,
|
|
586
|
+
* an org's own version applied at once by `OrgPluginUploads`): the update owes the item's
|
|
587
|
+
* scope sync with its own commit, so this commit owes none. A sync owed here would run while
|
|
588
|
+
* the update moves the extension, converge the orgs to the old version, and turn the
|
|
589
|
+
* update's reviewed diff stale before its commit.
|
|
590
|
+
*/
|
|
591
|
+
updateFollows?: boolean;
|
|
590
592
|
}, opts?: ActorOpts & {
|
|
591
593
|
owner?: ImportOwner;
|
|
592
594
|
}): Promise<PluginConfirmResult>;
|
|
@@ -9,7 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
11
11
|
import { appearanceIssues, PLUGIN_MANIFEST_FILE, parseSkillMd, pluginDescription, SDK_VERSION, SKILL_ENTRY_FILE, } from "@capybara-hq/plugin-sdk";
|
|
12
|
-
import { Inject, Injectable
|
|
12
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import semver from "semver";
|
|
15
15
|
import { ClientBuilds } from "../client/client-builds.service.js";
|
|
@@ -55,7 +55,7 @@ import { PlanStale, PlatformComponents } from "./platform-components.js";
|
|
|
55
55
|
import { PluginPackageError, readPluginFiles, readPluginPackage, themeApiError, } from "./plugin-package.js";
|
|
56
56
|
import { hasImportRequests, importRequestOf, resolveImportRequests } from "./request-rules.js";
|
|
57
57
|
import { assertNameNotReserved } from "./reserved-names.js";
|
|
58
|
-
import { oweScopeItem
|
|
58
|
+
import { oweScopeItem } from "./scope-jobs.js";
|
|
59
59
|
import { addScopeOrg } from "./scope-orgs.js";
|
|
60
60
|
import { maxSatisfying, satisfiesRange } from "./versions.js";
|
|
61
61
|
/**
|
|
@@ -64,8 +64,7 @@ import { maxSatisfying, satisfiesRange } from "./versions.js";
|
|
|
64
64
|
*
|
|
65
65
|
* prepare: the tgz is always hostile input, and **nothing is written until every check passes**
|
|
66
66
|
* (F-AD): `readPluginPackage` (plugin.json, package.json, listed / scanned skills and templates,
|
|
67
|
-
* icons
|
|
68
|
-
* (`readExtensionPackage`), the extension's deployment state (config-declared names are
|
|
67
|
+
* icons), the extension's module graph and migrations (`readExtensionPackage`), the extension's deployment state (config-declared names are
|
|
69
68
|
* refused; name ownership; a downgrade to a version with unrun migrations is refused), each skill by
|
|
70
69
|
* the skill package rules, each connector template against the connector loaded on this replica (or
|
|
71
70
|
* statically when the connector is provided by the plugin's own extension or by a dependency), the
|
|
@@ -112,16 +111,12 @@ const invalid = (problems) => new ApiError("catalog.invalid_manifest", `Invalid
|
|
|
112
111
|
const reviewStale = (review) => new ApiError("plugin.review_stale", `The review of plugin ${review.name} ${review.version} is out of date (it changed, or its extension on this deployment changed since it was prepared); review it again`);
|
|
113
112
|
const mismatch = (what) => new ApiError("marketplace.package_mismatch", `The downloaded package does not match the marketplace entry: ${what}`);
|
|
114
113
|
/**
|
|
115
|
-
* The API error of a plugin package that cannot be read in a catalog path:
|
|
116
|
-
* `
|
|
117
|
-
* spec §5) -> `theme.invalid` (details `[{ theme, errors }]`) or `theme.unreadable` (details
|
|
114
|
+
* The API error of a plugin package that cannot be read in a catalog path: undeclared client code
|
|
115
|
+
* -> `client.undeclared`; a failing theme (themes spec §5) -> `theme.invalid` (details `[{ theme, errors }]`) or `theme.unreadable` (details
|
|
118
116
|
* `[{ theme, issues }]`, the failing pairs); anything else -> `catalog.invalid_manifest` (issues as
|
|
119
117
|
* details).
|
|
120
118
|
*/
|
|
121
119
|
export function catalogPackageError(e) {
|
|
122
|
-
const legacy = e.code === "catalog.legacy_format" || e.code === "extension.legacy_format";
|
|
123
|
-
if (legacy)
|
|
124
|
-
return new ApiError("catalog.legacy_format", e.message, e.issues);
|
|
125
120
|
if (e.code === "client.undeclared")
|
|
126
121
|
return new ApiError("client.undeclared", e.message);
|
|
127
122
|
if (e.code === "theme.invalid" || e.code === "theme.unreadable") {
|
|
@@ -165,7 +160,6 @@ let PluginImport = class PluginImport {
|
|
|
165
160
|
platform;
|
|
166
161
|
clientBuilds;
|
|
167
162
|
outbox;
|
|
168
|
-
backstopDelayMs;
|
|
169
163
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
170
164
|
files;
|
|
171
165
|
/**
|
|
@@ -187,10 +181,8 @@ let PluginImport = class PluginImport {
|
|
|
187
181
|
platform,
|
|
188
182
|
/** The client build of a dropped org upload's package is deleted with it. */
|
|
189
183
|
clientBuilds,
|
|
190
|
-
/** The scope sync
|
|
191
|
-
outbox
|
|
192
|
-
/** The backstop's delay (a test seam; default `SCOPE_BACKSTOP_DELAY_MS`). */
|
|
193
|
-
backstopDelayMs = SCOPE_BACKSTOP_DELAY_MS) {
|
|
184
|
+
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
185
|
+
outbox) {
|
|
194
186
|
this.kdb = kdb;
|
|
195
187
|
this.adminLock = adminLock;
|
|
196
188
|
this.orgLock = orgLock;
|
|
@@ -208,7 +200,6 @@ let PluginImport = class PluginImport {
|
|
|
208
200
|
this.platform = platform;
|
|
209
201
|
this.clientBuilds = clientBuilds;
|
|
210
202
|
this.outbox = outbox;
|
|
211
|
-
this.backstopDelayMs = backstopDelayMs;
|
|
212
203
|
this.files = storage;
|
|
213
204
|
}
|
|
214
205
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
@@ -679,7 +670,7 @@ let PluginImport = class PluginImport {
|
|
|
679
670
|
* extension's deploy result (a failed deploy is returned, not thrown). `scope` (default
|
|
680
671
|
* `optional`) and `orgs` (only with `named`; each an existing org, else `validation_failed`) are
|
|
681
672
|
* written when this confirm creates the item; a new version of an existing item keeps its scope.
|
|
682
|
-
* The
|
|
673
|
+
* The commit owes the item's scope sync, or the extension's deploy does (see {@link commit}).
|
|
683
674
|
*
|
|
684
675
|
* An org upload (`opts.owner`, spec §14): only that org's staging; the actor re-checked as its
|
|
685
676
|
* admin; `scope` / `orgs` are not taken: a new item is owned by the org, scope `named: [owner]`,
|
|
@@ -746,7 +737,7 @@ let PluginImport = class PluginImport {
|
|
|
746
737
|
scope,
|
|
747
738
|
orgs: [...new Set(orgs ?? [])].sort(),
|
|
748
739
|
...(owner !== undefined && { owner, shareable: input.shareable ?? false }),
|
|
749
|
-
}, stored, opts, prepared);
|
|
740
|
+
}, stored, opts, prepared, input.updateFollows === true);
|
|
750
741
|
const { now } = committed;
|
|
751
742
|
if (committed.pending) {
|
|
752
743
|
// Waits for the super admin (P3-10): no platform components, nothing deployed
|
|
@@ -830,7 +821,9 @@ let PluginImport = class PluginImport {
|
|
|
830
821
|
* for another item or version, or a component changed since it -> `plugin.review_stale`. A new
|
|
831
822
|
* version of an existing item leaves them to the platform update.
|
|
832
823
|
*/
|
|
833
|
-
async commit(actor, c, scope, stored, opts, prepared
|
|
824
|
+
async commit(actor, c, scope, stored, opts, prepared,
|
|
825
|
+
/** A platform update follows and owes the scope sync (see `confirm`'s `updateFollows`). */
|
|
826
|
+
updateFollows) {
|
|
834
827
|
const { stagingId, review, staged, src, manifest } = c;
|
|
835
828
|
const reviewed = review.extension;
|
|
836
829
|
const stale = () => reviewStale(review);
|
|
@@ -1077,19 +1070,19 @@ let PluginImport = class PluginImport {
|
|
|
1077
1070
|
throw e;
|
|
1078
1071
|
}
|
|
1079
1072
|
}
|
|
1080
|
-
// The commit owes the
|
|
1081
|
-
//
|
|
1082
|
-
|
|
1073
|
+
// The commit owes the item's scope sync when its scope turns it on by itself (`all` or
|
|
1074
|
+
// `named`; an org's own item always), unless an extension is to be installed or upgraded: then
|
|
1075
|
+
// its deploy owes it (`oweDeployedExtensionSync`), so no sync runs before it is enabled; or a
|
|
1076
|
+
// platform update to this version follows: its commit owes it
|
|
1077
|
+
const deploys = now !== undefined && now.action !== "keep";
|
|
1078
|
+
if (!pending && !deploys && !updateFollows) {
|
|
1083
1079
|
const item = await t
|
|
1084
1080
|
.selectFrom("catalog_items")
|
|
1085
1081
|
.select("scope")
|
|
1086
1082
|
.where("id", "=", itemId)
|
|
1087
1083
|
.executeTakeFirstOrThrow();
|
|
1088
|
-
if (item.scope !== "optional") {
|
|
1089
|
-
await oweScopeItem(this.outbox, t, itemId
|
|
1090
|
-
backstop: true,
|
|
1091
|
-
backstopDelayMs: this.backstopDelayMs,
|
|
1092
|
-
});
|
|
1084
|
+
if (item.scope !== "optional" || owner !== undefined) {
|
|
1085
|
+
await oweScopeItem(this.outbox, t, itemId);
|
|
1093
1086
|
}
|
|
1094
1087
|
}
|
|
1095
1088
|
return {
|
|
@@ -1740,9 +1733,7 @@ PluginImport = __decorate([
|
|
|
1740
1733
|
__param(14, Inject(TransactionHost)),
|
|
1741
1734
|
__param(15, Inject(PlatformComponents)),
|
|
1742
1735
|
__param(16, Inject(ClientBuilds)),
|
|
1743
|
-
__param(17, Inject(OutboxService))
|
|
1744
|
-
__param(18, Optional()),
|
|
1745
|
-
__param(18, Inject(SCOPE_BACKSTOP_DELAY))
|
|
1736
|
+
__param(17, Inject(OutboxService))
|
|
1746
1737
|
], PluginImport);
|
|
1747
1738
|
export { PluginImport };
|
|
1748
1739
|
/**
|