@capybara-hq/kernel 0.1.0-rc.121 → 0.1.0-rc.123
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 +3 -3
- package/dist/background/finish.d.ts +5 -1
- package/dist/background/finish.js +29 -18
- package/dist/background/launch.d.ts +0 -5
- package/dist/background/launch.js +1 -6
- package/dist/background/managed.js +1 -4
- package/dist/background/poll.job.d.ts +3 -25
- package/dist/background/poll.job.js +20 -112
- package/dist/background/render.d.ts +2 -8
- package/dist/background/render.js +3 -17
- package/dist/background/stop.d.ts +15 -16
- package/dist/background/stop.js +39 -76
- package/dist/background/store.d.ts +17 -45
- package/dist/background/store.js +60 -94
- package/dist/background/tasks.service.d.ts +2 -5
- package/dist/background/tasks.service.js +9 -20
- package/dist/background/wake.js +3 -2
- package/dist/catalog/admin-catalog.controller.d.ts +2 -18
- package/dist/catalog/admin-catalog.controller.js +2 -28
- package/dist/catalog/catalog-content.d.ts +1 -5
- package/dist/catalog/catalog-items.d.ts +2 -6
- package/dist/catalog/catalog-items.js +5 -26
- package/dist/catalog/catalog-scope.service.d.ts +1 -121
- package/dist/catalog/catalog-scope.service.js +12 -552
- package/dist/catalog/catalog.service.d.ts +4 -15
- package/dist/catalog/catalog.service.js +7 -35
- package/dist/catalog/job-ids.d.ts +0 -18
- package/dist/catalog/job-ids.js +0 -20
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.js +6 -20
- package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
- package/dist/catalog/org-plugin-uploads.controller.js +6 -34
- package/dist/catalog/org-plugin-uploads.d.ts +3 -10
- package/dist/catalog/org-plugin-uploads.js +4 -18
- package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
- package/dist/catalog/owned-items.d.ts +6 -11
- package/dist/catalog/owned-items.js +10 -20
- package/dist/catalog/ownership.d.ts +3 -29
- package/dist/catalog/ownership.js +4 -54
- package/dist/catalog/platform-components.d.ts +5 -11
- package/dist/catalog/platform-components.js +8 -15
- package/dist/catalog/plugin-import.d.ts +3 -42
- package/dist/catalog/plugin-import.js +26 -195
- package/dist/catalog/plugin-install.js +1 -6
- package/dist/catalog/plugin-package.d.ts +1 -0
- package/dist/catalog/plugin-package.js +5 -0
- package/dist/catalog/plugin-upgrade.d.ts +3 -26
- package/dist/catalog/plugin-upgrade.js +20 -103
- package/dist/catalog/request-rules.js +4 -6
- package/dist/catalog/scope-sync.js +2 -4
- package/dist/catalog/scope.d.ts +2 -5
- package/dist/channels/jobs.d.ts +3 -3
- package/dist/channels/jobs.js +4 -3
- package/dist/channels/outbound.d.ts +1 -0
- package/dist/channels/outbound.js +32 -8
- package/dist/config/load.d.ts +0 -25
- package/dist/config/load.js +0 -57
- package/dist/config/schema.js +2 -3
- package/dist/conversations/attachments.service.js +3 -5
- package/dist/conversations/conversations.service.d.ts +3 -3
- package/dist/conversations/conversations.service.js +3 -3
- package/dist/conversations/job-org.d.ts +3 -0
- package/dist/conversations/job-org.js +11 -0
- package/dist/conversations/prompt-suggestions.d.ts +2 -7
- package/dist/conversations/prompt-suggestions.js +29 -27
- package/dist/conversations/titles.d.ts +3 -4
- package/dist/conversations/titles.js +19 -30
- package/dist/db/kernel-schema.d.ts +6 -16
- package/dist/db/pool.js +7 -2
- package/dist/devices/devices.controller.d.ts +0 -5
- package/dist/devices/devices.controller.js +2 -20
- package/dist/devices/devices.service.d.ts +1 -17
- package/dist/devices/devices.service.js +0 -22
- package/dist/errors.d.ts +1 -5
- package/dist/errors.js +1 -5
- package/dist/evals/judge.d.ts +3 -0
- package/dist/evals/judge.js +1 -1
- package/dist/evals/run-replay.d.ts +1 -1
- package/dist/evals/run-replay.js +26 -29
- package/dist/evals/step-replay.d.ts +3 -1
- package/dist/evals/step-replay.js +10 -1
- package/dist/evals/worker.d.ts +3 -1
- package/dist/evals/worker.js +53 -21
- package/dist/extensions/deployment-config-store.js +18 -14
- package/dist/extensions/effective-config.d.ts +1 -5
- package/dist/extensions/effective-config.js +1 -5
- package/dist/extensions/hooks.d.ts +3 -1
- package/dist/extensions/hooks.js +7 -2
- package/dist/extensions/installs.d.ts +2 -14
- package/dist/extensions/installs.js +10 -32
- package/dist/extensions/org-config.d.ts +3 -4
- package/dist/extensions/org-config.js +3 -4
- package/dist/extensions/plugin-guides.d.ts +0 -1
- package/dist/extensions/plugin-guides.js +0 -1
- package/dist/extensions/plugin-icons.d.ts +0 -1
- package/dist/extensions/plugin-icons.js +0 -3
- package/dist/files/blob-sweep.job.d.ts +2 -11
- package/dist/files/blob-sweep.job.js +7 -21
- package/dist/files/hash-job.d.ts +5 -15
- package/dist/files/hash-job.js +14 -33
- package/dist/files/library-jobs.module.d.ts +1 -6
- package/dist/files/library-jobs.module.js +3 -9
- package/dist/identity/api-tokens.js +54 -40
- package/dist/identity/auth.guard.js +2 -2
- package/dist/identity/sessions.js +7 -3
- package/dist/identity/settings.js +5 -21
- package/dist/inbox/inbox.service.d.ts +2 -3
- package/dist/inbox/org-notices.d.ts +0 -14
- package/dist/inbox/platform-inbox.service.d.ts +1 -8
- package/dist/inbox/platform-inbox.service.js +2 -6
- package/dist/inbox/platform-notices.d.ts +3 -3
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -3
- package/dist/infra/database/database.module.js +2 -1
- package/dist/infra/database/org-scope.d.ts +5 -3
- package/dist/infra/database/org-scope.js +7 -1
- package/dist/infra/database/scoped-dialect.d.ts +3 -1
- package/dist/infra/database/scoped-dialect.js +17 -5
- package/dist/infra/events/kernel-events.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.js +10 -0
- package/dist/infra/outbox/registry.d.ts +0 -41
- package/dist/infra/outbox/registry.js +0 -37
- package/dist/models/embeddings.d.ts +0 -5
- package/dist/models/embeddings.js +28 -35
- package/dist/models/images.d.ts +3 -8
- package/dist/models/images.js +19 -37
- package/dist/models/purposes.d.ts +7 -2
- package/dist/models/purposes.js +16 -3
- package/dist/orgs/device-network-setting.d.ts +0 -44
- package/dist/orgs/device-network-setting.js +0 -83
- package/dist/orgs/invitations.service.js +34 -30
- package/dist/orgs/offboarding.d.ts +2 -2
- package/dist/orgs/offboarding.js +2 -2
- package/dist/orgs/orgs.service.d.ts +1 -1
- package/dist/orgs/orgs.service.js +19 -15
- package/dist/orgs/settings.service.d.ts +19 -14
- package/dist/orgs/settings.service.js +12 -37
- package/dist/platform/exclusions.js +0 -11
- package/dist/platform/ops/catalog-admin.ops.js +0 -8
- package/dist/platform/ops/devices.ops.js +0 -28
- package/dist/platform/ops/extensions-admin.ops.js +3 -3
- package/dist/platform/ops/inbox.ops.js +5 -22
- package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
- package/dist/platform/ops/org-plugins.ops.js +11 -67
- package/dist/roles/worker.module.js +0 -9
- package/dist/runtime/hook-calls.d.ts +13 -6
- package/dist/runtime/hook-calls.js +26 -4
- package/dist/runtime/maintenance.d.ts +3 -12
- package/dist/runtime/maintenance.js +25 -55
- package/dist/runtime/model-call.d.ts +4 -2
- package/dist/runtime/model-call.js +59 -58
- package/dist/runtime/providers.d.ts +27 -1
- package/dist/runtime/providers.js +57 -0
- package/dist/runtime/run-jobs.d.ts +1 -1
- package/dist/runtime/run-processors.d.ts +3 -9
- package/dist/runtime/run-worker.d.ts +2 -0
- package/dist/runtime/run-worker.js +23 -8
- package/dist/runtime/subagents/deliveries.js +6 -1
- package/dist/runtime/subagents/dispatch.d.ts +3 -3
- package/dist/runtime/write-base.service.d.ts +2 -3
- package/dist/runtime/write-base.service.js +3 -5
- package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
- package/dist/sandbox/device-sandbox-settings.js +19 -325
- package/dist/sandbox/jobs.d.ts +3 -14
- package/dist/sandbox/jobs.js +2 -20
- package/dist/sandbox/modes.d.ts +5 -45
- package/dist/sandbox/modes.js +3 -60
- package/dist/sandbox/operation-authority.js +0 -11
- package/dist/sandbox/operation-intents.d.ts +32 -9
- package/dist/sandbox/operation-intents.js +241 -32
- package/dist/sandbox/operation-intents.module.js +2 -1
- package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
- package/dist/sandbox/operation-reconcile.job.js +119 -33
- package/dist/sandbox/operation-revoke.d.ts +20 -0
- package/dist/sandbox/operation-revoke.js +3 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
- package/dist/sandbox/permission-ceiling-writes.js +3 -6
- package/dist/sandbox/permission-config-publication.d.ts +1 -28
- package/dist/sandbox/permission-config-publication.js +14 -211
- package/dist/sandbox/permission-facts.d.ts +4 -15
- package/dist/sandbox/permission-facts.js +7 -29
- package/dist/sandbox/permission-instance-writes.d.ts +1 -4
- package/dist/sandbox/permission-instance-writes.js +1 -55
- package/dist/sandbox/providers.d.ts +1 -6
- package/dist/sandbox/providers.js +1 -15
- package/dist/sandbox/review/classifier.js +12 -13
- package/dist/sandbox/sandbox.module.js +3 -6
- package/dist/sandbox/sandbox.service.d.ts +17 -123
- package/dist/sandbox/sandbox.service.js +239 -998
- package/dist/shares/liveness.d.ts +1 -2
- package/dist/shares/liveness.js +1 -2
- package/dist/shares/shares.module.d.ts +1 -2
- package/dist/shares/shares.module.js +2 -5
- package/dist/shares/shares.service.js +1 -2
- package/dist/tools/builtins/image/generate.js +7 -15
- package/dist/tools/builtins/sandbox/common.d.ts +0 -2
- package/dist/tools/builtins/sandbox/common.js +1 -27
- package/dist/tools/builtins/sandbox/task-list.js +10 -10
- package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
- package/dist/tools/builtins/sandbox/task-output.js +13 -83
- package/dist/tools/builtins/sandbox/task-stop.js +18 -22
- package/dist/tools/builtins/vision/read-image.js +9 -10
- package/dist/tools/builtins/web/extract.js +9 -10
- package/package.json +3 -3
- package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
- package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
- package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
- package/dist/background/retire-legacy-tasks.job.js +0 -149
- package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
- package/dist/catalog/owned-plugin-cleanup.js +0 -140
- package/dist/config/permission-migration.d.ts +0 -34
- package/dist/config/permission-migration.js +0 -115
- package/dist/devices/legacy-cleanup.job.d.ts +0 -34
- package/dist/devices/legacy-cleanup.job.js +0 -147
- package/dist/files/library-backfill.d.ts +0 -63
- package/dist/files/library-backfill.js +0 -143
- package/dist/infra/cli/permission-cutover.d.ts +0 -59
- package/dist/infra/cli/permission-cutover.js +0 -107
- package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
- package/dist/sandbox/cloud-permission-snapshot.js +0 -430
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
- package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
- package/dist/sandbox/legacy-retirement.d.ts +0 -284
- package/dist/sandbox/legacy-retirement.js +0 -1165
- package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
- package/dist/sandbox/legacy-retirement.module.js +0 -25
- package/dist/shares/share-objects.d.ts +0 -47
- package/dist/shares/share-objects.js +0 -93
|
@@ -12,13 +12,12 @@ import { appearanceIssues, PLUGIN_MANIFEST_FILE, parseSkillMd, pluginDescription
|
|
|
12
12
|
import { Inject, Injectable } 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
15
|
import { checkClientFiles } from "../client/client-files.js";
|
|
17
16
|
import { ApiError } from "../errors.js";
|
|
18
17
|
import { ExtensionAdminOps } from "../extensions/admin-ops.js";
|
|
19
18
|
import { ExtensionAdmin } from "../extensions/admin-view.js";
|
|
20
19
|
import { writeSnapshot } from "../extensions/approvals.js";
|
|
21
|
-
import {
|
|
20
|
+
import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
22
21
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
23
22
|
import { PluginApproveLock, PluginInstallLock } from "../extensions/locks.js";
|
|
24
23
|
import { unrunMigrations } from "../extensions/migrate-lock.js";
|
|
@@ -30,7 +29,6 @@ import { audit } from "../identity/audit.js";
|
|
|
30
29
|
import { assertCustomAllowed } from "../identity/settings.js";
|
|
31
30
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
32
31
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
33
|
-
import { afterCommit } from "../infra/database/after-commit.js";
|
|
34
32
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
35
33
|
import { asPlatform } from "../infra/database/org-scope.js";
|
|
36
34
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -51,9 +49,9 @@ import { CLAUDE_MCP_CONNECTOR } from "./claude/mcp.js";
|
|
|
51
49
|
import { item as reportItem, sortItems, } from "./claude/report.js";
|
|
52
50
|
import { isClaudePluginTree, translateClaudePlugin } from "./claude/translate.js";
|
|
53
51
|
import { CatalogItemLock } from "./locks.js";
|
|
54
|
-
import { assertNameFree, assertPackageFree, assertShareable, packageOwner,
|
|
52
|
+
import { assertNameFree, assertPackageFree, assertShareable, packageOwner, shareGate, usableBy, } from "./ownership.js";
|
|
55
53
|
import { PlanStale, PlatformComponents } from "./platform-components.js";
|
|
56
|
-
import { PluginPackageError, readPluginFiles, readPluginPackage, themeApiError, } from "./plugin-package.js";
|
|
54
|
+
import { assertDeclarativeUpload, PluginPackageError, readPluginFiles, readPluginPackage, themeApiError, } from "./plugin-package.js";
|
|
57
55
|
import { hasImportRequests, importRequestOf, resolveImportRequests } from "./request-rules.js";
|
|
58
56
|
import { assertNameNotReserved } from "./reserved-names.js";
|
|
59
57
|
import { oweScopeItem } from "./scope-jobs.js";
|
|
@@ -160,7 +158,6 @@ let PluginImport = class PluginImport {
|
|
|
160
158
|
log;
|
|
161
159
|
txHost;
|
|
162
160
|
platform;
|
|
163
|
-
clientBuilds;
|
|
164
161
|
outbox;
|
|
165
162
|
/** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
|
|
166
163
|
files;
|
|
@@ -181,8 +178,6 @@ let PluginImport = class PluginImport {
|
|
|
181
178
|
registry, log, txHost,
|
|
182
179
|
/** The platform rows of a new item's components, written in the confirm's transaction. */
|
|
183
180
|
platform,
|
|
184
|
-
/** The client build of a dropped org upload's package is deleted with it. */
|
|
185
|
-
clientBuilds,
|
|
186
181
|
/** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
|
|
187
182
|
outbox) {
|
|
188
183
|
this.kdb = kdb;
|
|
@@ -200,7 +195,6 @@ let PluginImport = class PluginImport {
|
|
|
200
195
|
this.log = log;
|
|
201
196
|
this.txHost = txHost;
|
|
202
197
|
this.platform = platform;
|
|
203
|
-
this.clientBuilds = clientBuilds;
|
|
204
198
|
this.outbox = outbox;
|
|
205
199
|
this.files = storage;
|
|
206
200
|
}
|
|
@@ -335,6 +329,8 @@ let PluginImport = class PluginImport {
|
|
|
335
329
|
}
|
|
336
330
|
// 1. Every check (nothing written)
|
|
337
331
|
const m = pkg.manifest;
|
|
332
|
+
if (owner !== undefined)
|
|
333
|
+
assertDeclarativeUpload(m);
|
|
338
334
|
const packageName = packageNameOf(pkg);
|
|
339
335
|
const format = opts.claude !== undefined ? "claude-code" : "capybara";
|
|
340
336
|
this.checkExpected(pkg, opts.expect, format);
|
|
@@ -373,7 +369,7 @@ let PluginImport = class PluginImport {
|
|
|
373
369
|
await assertCustomContent(this.db, content);
|
|
374
370
|
}
|
|
375
371
|
// An org's own version imported but not applied: its update is retried (pre-flight F4)
|
|
376
|
-
const retry = owner !== undefined
|
|
372
|
+
const retry = owner !== undefined
|
|
377
373
|
? await unappliedOwnVersion(this.db, m.name, owner.orgId, {
|
|
378
374
|
packageName,
|
|
379
375
|
version: m.version,
|
|
@@ -481,8 +477,6 @@ let PluginImport = class PluginImport {
|
|
|
481
477
|
}, {
|
|
482
478
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
483
479
|
...(bootstrap && { store: "pg" }),
|
|
484
|
-
// an org upload only stores the package (nothing runs until the super admin confirms)
|
|
485
|
-
...(owner !== undefined && { owner }),
|
|
486
480
|
});
|
|
487
481
|
}
|
|
488
482
|
let objectPrefix = null;
|
|
@@ -627,7 +621,7 @@ let PluginImport = class PluginImport {
|
|
|
627
621
|
const staged = row.manifest;
|
|
628
622
|
const item = await this.db
|
|
629
623
|
.selectFrom("catalog_items")
|
|
630
|
-
.select(
|
|
624
|
+
.select("id")
|
|
631
625
|
.where("id", "=", staged.itemId)
|
|
632
626
|
.where("deleted_at", "is", null)
|
|
633
627
|
.where((eb) => owner === undefined ? eb("owner_org_id", "is", null) : eb("owner_org_id", "=", owner.orgId))
|
|
@@ -644,9 +638,7 @@ let PluginImport = class PluginImport {
|
|
|
644
638
|
itemId: staged.itemId,
|
|
645
639
|
version: staged.version,
|
|
646
640
|
reviewHash: review.reviewHash,
|
|
647
|
-
extension: review.extension !== undefined,
|
|
648
641
|
existing: item !== undefined,
|
|
649
|
-
awaiting: item?.awaiting_confirmation === true,
|
|
650
642
|
retry: staged.retry === true,
|
|
651
643
|
target: imported !== undefined
|
|
652
644
|
? {
|
|
@@ -679,9 +671,7 @@ let PluginImport = class PluginImport {
|
|
|
679
671
|
* An org upload (`opts.owner`, spec §14): only that org's staging; the actor re-checked as its
|
|
680
672
|
* admin; `scope` / `orgs` are not taken: a new item is owned by the org, scope `named: [owner]`,
|
|
681
673
|
* not shown to other orgs, `shareable` as given (default false). Custom deny, the name owner and
|
|
682
|
-
* the dependencies are checked again under the item name's lock.
|
|
683
|
-
* is stored and its extension name claimed, nothing approved or installed: the version waits
|
|
684
|
-
* for the super admin (`pending`, ruling P3-10; see {@link commit}).
|
|
674
|
+
* the dependencies are checked again under the item name's lock.
|
|
685
675
|
*/
|
|
686
676
|
async confirm(actor, stagingId, input, opts = {}) {
|
|
687
677
|
if (!UUID_RE.test(stagingId))
|
|
@@ -727,40 +717,25 @@ let PluginImport = class PluginImport {
|
|
|
727
717
|
if (input.reviewHash !== review.reviewHash)
|
|
728
718
|
throw reviewStale(review);
|
|
729
719
|
const manifest = staged.manifest;
|
|
720
|
+
if (owner !== undefined)
|
|
721
|
+
assertDeclarativeUpload(manifest);
|
|
730
722
|
const reviewed = review.extension;
|
|
731
|
-
// Read the stored package outside the transaction
|
|
732
|
-
|
|
733
|
-
const stored = reviewed && reviewed.action !== "keep" && owner === undefined
|
|
734
|
-
? await this.readStored(reviewed.sha256)
|
|
735
|
-
: undefined;
|
|
723
|
+
// Read the stored package outside the transaction unless it was already installed as is
|
|
724
|
+
const stored = reviewed && reviewed.action !== "keep" ? await this.readStored(reviewed.sha256) : undefined;
|
|
736
725
|
// The platform components of the item's first usable version: planned and their files copied
|
|
737
726
|
// (keyed by content) before the transaction, their rows written in it
|
|
738
|
-
const prepared = staged.retry === true
|
|
739
|
-
? undefined
|
|
740
|
-
: await this.prepareFirstVersion(staged, row.object_prefix, owner);
|
|
727
|
+
const prepared = staged.retry === true ? undefined : await this.prepareFirstVersion(staged, row.object_prefix);
|
|
741
728
|
const committed = await this.commit(actor, { stagingId, review, staged, src, manifest, objectPrefix: row.object_prefix }, {
|
|
742
729
|
scope,
|
|
743
730
|
orgs: [...new Set(orgs ?? [])].sort(),
|
|
744
731
|
...(owner !== undefined && { owner, shareable: input.shareable ?? false }),
|
|
745
732
|
}, stored, opts, prepared, input.updateFollows === true);
|
|
746
733
|
const { now } = committed;
|
|
747
|
-
if (committed.pending) {
|
|
748
|
-
// Waits for the super admin (P3-10): no platform components, nothing deployed
|
|
749
|
-
return {
|
|
750
|
-
item: await this.itemView(committed.itemId),
|
|
751
|
-
created: committed.created,
|
|
752
|
-
deploy: null,
|
|
753
|
-
pending: true,
|
|
754
|
-
firstVersion: false,
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
734
|
if (input.deploy === false) {
|
|
758
735
|
return {
|
|
759
736
|
item: await this.itemView(committed.itemId),
|
|
760
737
|
created: committed.created,
|
|
761
738
|
deploy: null,
|
|
762
|
-
pending: false,
|
|
763
|
-
firstVersion: committed.firstVersion,
|
|
764
739
|
...(now &&
|
|
765
740
|
committed.previous !== undefined && {
|
|
766
741
|
approval: { review, extension: now, previous: committed.previous },
|
|
@@ -774,29 +749,25 @@ let PluginImport = class PluginImport {
|
|
|
774
749
|
item: await this.itemView(committed.itemId),
|
|
775
750
|
created: committed.created,
|
|
776
751
|
deploy,
|
|
777
|
-
pending: false,
|
|
778
|
-
firstVersion: committed.firstVersion,
|
|
779
752
|
};
|
|
780
753
|
}
|
|
781
754
|
/**
|
|
782
755
|
* The platform components of the staged version when its confirm will most likely make it the
|
|
783
756
|
* item's first usable version ({@link commit} decides under its locks): no live item of the name
|
|
784
|
-
* yet
|
|
757
|
+
* yet. Planned from
|
|
785
758
|
* the staged content and their files copied, outside any transaction; otherwise undefined.
|
|
786
759
|
*/
|
|
787
|
-
async prepareFirstVersion(staged, objectPrefix
|
|
760
|
+
async prepareFirstVersion(staged, objectPrefix) {
|
|
788
761
|
const live = await this.db
|
|
789
762
|
.selectFrom("catalog_items")
|
|
790
|
-
.select(
|
|
763
|
+
.select("id")
|
|
791
764
|
.where("name", "=", staged.manifest.name)
|
|
792
765
|
.where("deleted_at", "is", null)
|
|
793
766
|
.executeTakeFirst();
|
|
794
|
-
|
|
795
|
-
(owner !== undefined && live.awaiting_confirmation && live.owner_org_id === owner.orgId);
|
|
796
|
-
if (!first)
|
|
767
|
+
if (live !== undefined)
|
|
797
768
|
return undefined;
|
|
798
769
|
return this.platform.prepareImport({
|
|
799
|
-
itemId:
|
|
770
|
+
itemId: staged.itemId,
|
|
800
771
|
plugin: staged.manifest.name,
|
|
801
772
|
version: staged.version,
|
|
802
773
|
manifest: staged.manifest,
|
|
@@ -810,17 +781,7 @@ let PluginImport = class PluginImport {
|
|
|
810
781
|
* its install lock (stale -> `plugin.review_stale`), its snapshot approved, and the catalog
|
|
811
782
|
* version written under the item name's lock.
|
|
812
783
|
*
|
|
813
|
-
*
|
|
814
|
-
* claims the extension name for its package (another package's -> 409
|
|
815
|
-
* `extension.name_conflict` naming its owner, before anything is written), and the version
|
|
816
|
-
* written becomes the item's pending one (`pending_version` / `_by` / `_at`; a first version
|
|
817
|
-
* also `awaiting_confirmation`). A later upload replaces the pending version (P3-11). An org
|
|
818
|
-
* upload without an extension for an item whose first version still waits (plan Task 6) replaces
|
|
819
|
-
* that upload and applies at once: the item stops waiting and the claim is released (nothing
|
|
820
|
-
* was installed under it).
|
|
821
|
-
*
|
|
822
|
-
* The item's first usable version (a new item not waiting, or an awaiting first upload replaced)
|
|
823
|
-
* writes the platform rows of its skills, agent templates, connector templates and themes
|
|
784
|
+
* The first version writes the platform rows of its skills, agent templates, connector templates and themes
|
|
824
785
|
* (plugin scope phase 2) from `prepared` (their files copied before the transaction, keyed by
|
|
825
786
|
* content): a failure rolls the whole confirm back, and a retry copies nothing again. A plan made
|
|
826
787
|
* for another item or version, or a component changed since it -> `plugin.review_stale`. A new
|
|
@@ -867,7 +828,7 @@ let PluginImport = class PluginImport {
|
|
|
867
828
|
// of a live item (which keeps its scope)
|
|
868
829
|
const existing = await t
|
|
869
830
|
.selectFrom("catalog_items")
|
|
870
|
-
.select(["id", "scope"
|
|
831
|
+
.select(["id", "scope"])
|
|
871
832
|
.where("name", "=", m.name)
|
|
872
833
|
.where("deleted_at", "is", null)
|
|
873
834
|
.forUpdate()
|
|
@@ -886,21 +847,12 @@ let PluginImport = class PluginImport {
|
|
|
886
847
|
if (pluginReviewHash({ ...review, extension: now }, staged.files) !== review.reviewHash) {
|
|
887
848
|
throw stale();
|
|
888
849
|
}
|
|
889
|
-
if (owner !== undefined) {
|
|
890
|
-
// An org upload only claims the name (P3-10): the super admin approves and installs it
|
|
891
|
-
await t
|
|
892
|
-
.insertInto("extension_name_owners")
|
|
893
|
-
.values({ name: reviewed.name, package_name: staged.packageName })
|
|
894
|
-
.onConflict((oc) => oc.column("name").doNothing())
|
|
895
|
-
.execute();
|
|
896
|
-
await assertPluginNameOwner(t, reviewed.name, staged.packageName);
|
|
897
|
-
}
|
|
898
850
|
// A foreseeable deploy failure (a downgrade to a version with unrun migrations) is refused
|
|
899
851
|
// before anything is written
|
|
900
852
|
if (now.action === "upgrade" && stored) {
|
|
901
853
|
await assertDowngradable(t, now, stored.migrationSql);
|
|
902
854
|
}
|
|
903
|
-
if (
|
|
855
|
+
if (now.action === "install" || now.action === "upgrade") {
|
|
904
856
|
previous = await this.approve(actor, review, staged, now, stored, opts);
|
|
905
857
|
}
|
|
906
858
|
}
|
|
@@ -940,8 +892,6 @@ let PluginImport = class PluginImport {
|
|
|
940
892
|
return {
|
|
941
893
|
itemId: existing.id,
|
|
942
894
|
created: false,
|
|
943
|
-
firstVersion: false,
|
|
944
|
-
pending: false,
|
|
945
895
|
now,
|
|
946
896
|
previous,
|
|
947
897
|
};
|
|
@@ -1029,42 +979,9 @@ let PluginImport = class PluginImport {
|
|
|
1029
979
|
for (const org of requestOrgs)
|
|
1030
980
|
await addScopeOrg(t, actor, item, org, opts);
|
|
1031
981
|
}
|
|
1032
|
-
|
|
1033
|
-
// An org's first version without an extension is installed at once: applied (P3-52)
|
|
1034
|
-
if (owner !== undefined && created && !pending)
|
|
982
|
+
if (owner !== undefined && created)
|
|
1035
983
|
await markVersionApplied(t, itemId, staged.version);
|
|
1036
|
-
if (
|
|
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) {
|
|
984
|
+
if (created) {
|
|
1068
985
|
if (prepared?.plan.itemId !== itemId || prepared.plan.version !== staged.version) {
|
|
1069
986
|
throw stale();
|
|
1070
987
|
}
|
|
@@ -1082,7 +999,7 @@ let PluginImport = class PluginImport {
|
|
|
1082
999
|
// its deploy owes it (`oweDeployedExtensionSync`), so no sync runs before it is enabled; or a
|
|
1083
1000
|
// platform update to this version follows: its commit owes it
|
|
1084
1001
|
const deploys = now !== undefined && now.action !== "keep";
|
|
1085
|
-
if (!
|
|
1002
|
+
if (!deploys && !updateFollows) {
|
|
1086
1003
|
const item = await t
|
|
1087
1004
|
.selectFrom("catalog_items")
|
|
1088
1005
|
.select("scope")
|
|
@@ -1095,8 +1012,6 @@ let PluginImport = class PluginImport {
|
|
|
1095
1012
|
return {
|
|
1096
1013
|
itemId,
|
|
1097
1014
|
created,
|
|
1098
|
-
firstVersion,
|
|
1099
|
-
pending,
|
|
1100
1015
|
now,
|
|
1101
1016
|
previous,
|
|
1102
1017
|
};
|
|
@@ -1325,7 +1240,7 @@ let PluginImport = class PluginImport {
|
|
|
1325
1240
|
const t = this.db;
|
|
1326
1241
|
const locked = await t
|
|
1327
1242
|
.selectFrom("plugin_import_staging")
|
|
1328
|
-
.select(
|
|
1243
|
+
.select("id")
|
|
1329
1244
|
.where("id", "=", r.id)
|
|
1330
1245
|
.where("expires_at", "<=", sql `now()`)
|
|
1331
1246
|
.forUpdate()
|
|
@@ -1336,88 +1251,9 @@ let PluginImport = class PluginImport {
|
|
|
1336
1251
|
if (r.object_prefix)
|
|
1337
1252
|
await this.files.deployment().deletePrefix(r.object_prefix);
|
|
1338
1253
|
await t.deleteFrom("plugin_import_staging").where("id", "=", r.id).execute();
|
|
1339
|
-
await this.dropOrgPackage(locked);
|
|
1340
1254
|
return true;
|
|
1341
1255
|
});
|
|
1342
1256
|
}
|
|
1343
|
-
/**
|
|
1344
|
-
* An expired org staging's extension package (an org upload stores it at prepare, P3-10): removed
|
|
1345
|
-
* with the staging unless something else uses it — an install (running or migrated), a catalog
|
|
1346
|
-
* version, another staging — or it was stored by anyone else (the package row's source must be
|
|
1347
|
-
* this staging's own `catalog` ref). A platform staging keeps its package, as before. Its object
|
|
1348
|
-
* is deleted after the commit.
|
|
1349
|
-
*/
|
|
1350
|
-
async dropOrgPackage(row) {
|
|
1351
|
-
const sha = row.review.extension?.sha256;
|
|
1352
|
-
if (row.org_id === null || sha === undefined)
|
|
1353
|
-
return;
|
|
1354
|
-
const staged = row.manifest;
|
|
1355
|
-
const t = this.db;
|
|
1356
|
-
const pkg = await t
|
|
1357
|
-
.selectFrom("extension_packages")
|
|
1358
|
-
.select("blob_store")
|
|
1359
|
-
.where("sha256", "=", sha)
|
|
1360
|
-
.where("source", "=", "catalog")
|
|
1361
|
-
.where("source_ref", "=", `${staged.itemId}@${staged.version}`)
|
|
1362
|
-
.forUpdate()
|
|
1363
|
-
.executeTakeFirst();
|
|
1364
|
-
if (!pkg)
|
|
1365
|
-
return;
|
|
1366
|
-
// org-filter: whether any staging of any org still uses the package (content-addressed sha)
|
|
1367
|
-
const used = (await t
|
|
1368
|
-
.selectFrom("extension_installs")
|
|
1369
|
-
.select("name")
|
|
1370
|
-
.where((eb) => eb.or([eb("sha256", "=", sha), eb("migrated_sha", "=", sha)]))
|
|
1371
|
-
.executeTakeFirst()) ??
|
|
1372
|
-
(await t
|
|
1373
|
-
.selectFrom("catalog_item_versions")
|
|
1374
|
-
.select("version")
|
|
1375
|
-
.where("extension_sha256", "=", sha)
|
|
1376
|
-
.executeTakeFirst()) ??
|
|
1377
|
-
(await t
|
|
1378
|
-
.selectFrom("plugin_import_staging")
|
|
1379
|
-
.select("id")
|
|
1380
|
-
.where(sql `review->'extension'->>'sha256' = ${sha}`)
|
|
1381
|
-
.executeTakeFirst());
|
|
1382
|
-
if (used !== undefined)
|
|
1383
|
-
return;
|
|
1384
|
-
const build = await t
|
|
1385
|
-
.selectFrom("extension_client_builds")
|
|
1386
|
-
.select("object_prefix")
|
|
1387
|
-
.where("package_sha256", "=", sha)
|
|
1388
|
-
.executeTakeFirst();
|
|
1389
|
-
// extension_blobs (a PG-stored package) and extension_client_builds go with the row (ON
|
|
1390
|
-
// DELETE CASCADE)
|
|
1391
|
-
await t.deleteFrom("extension_packages").where("sha256", "=", sha).execute();
|
|
1392
|
-
if (build !== undefined) {
|
|
1393
|
-
afterCommit(async () => {
|
|
1394
|
-
try {
|
|
1395
|
-
await this.clientBuilds.deleteFiles(sha, build.object_prefix);
|
|
1396
|
-
}
|
|
1397
|
-
catch (err) {
|
|
1398
|
-
this.log.warn("cannot delete an expired org upload's client build objects", {
|
|
1399
|
-
sha256: sha,
|
|
1400
|
-
err,
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
// The object only once the row is gone for good: a failure leaves an unreferenced object
|
|
1406
|
-
// (harmless; a later upload of the same bytes rewrites it), never a row without its bytes
|
|
1407
|
-
if (pkg.blob_store === "object") {
|
|
1408
|
-
afterCommit(async () => {
|
|
1409
|
-
try {
|
|
1410
|
-
await this.files.deployment().delete(blobKey(sha));
|
|
1411
|
-
}
|
|
1412
|
-
catch (err) {
|
|
1413
|
-
this.log.warn("cannot delete an expired org upload's extension package object", {
|
|
1414
|
-
sha256: sha,
|
|
1415
|
-
err,
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
1257
|
// ---------------------------------------------------------------------------------------------
|
|
1422
1258
|
/** npm / marketplace imports: the package must be the one that was asked for. */
|
|
1423
1259
|
checkExpected(pkg, expect, format = "capybara") {
|
|
@@ -1631,7 +1467,6 @@ let PluginImport = class PluginImport {
|
|
|
1631
1467
|
"i.builtin",
|
|
1632
1468
|
"i.disabled",
|
|
1633
1469
|
"i.deleted_at",
|
|
1634
|
-
"i.awaiting_confirmation",
|
|
1635
1470
|
"i.owner_org_id",
|
|
1636
1471
|
"i.shareable",
|
|
1637
1472
|
"so.org_id as listed",
|
|
@@ -1742,9 +1577,6 @@ __decorate([
|
|
|
1742
1577
|
__decorate([
|
|
1743
1578
|
Transactional()
|
|
1744
1579
|
], PluginImport.prototype, "cleanupOne", null);
|
|
1745
|
-
__decorate([
|
|
1746
|
-
Transactional({ propagation: "mandatory" })
|
|
1747
|
-
], PluginImport.prototype, "dropOrgPackage", null);
|
|
1748
1580
|
PluginImport = __decorate([
|
|
1749
1581
|
Injectable(),
|
|
1750
1582
|
__param(0, Inject(KernelDb)),
|
|
@@ -1763,8 +1595,7 @@ PluginImport = __decorate([
|
|
|
1763
1595
|
__param(13, Inject(KERNEL_LOGGER)),
|
|
1764
1596
|
__param(14, Inject(TransactionHost)),
|
|
1765
1597
|
__param(15, Inject(PlatformComponents)),
|
|
1766
|
-
__param(16, Inject(
|
|
1767
|
-
__param(17, Inject(OutboxService))
|
|
1598
|
+
__param(16, Inject(OutboxService))
|
|
1768
1599
|
], PluginImport);
|
|
1769
1600
|
export { PluginImport };
|
|
1770
1601
|
/**
|
|
@@ -117,7 +117,6 @@ async function resolveOne(db, d) {
|
|
|
117
117
|
"disabled",
|
|
118
118
|
"platform_synced_version",
|
|
119
119
|
"marketplace_id",
|
|
120
|
-
"awaiting_confirmation",
|
|
121
120
|
"owner_org_id",
|
|
122
121
|
"latest_version",
|
|
123
122
|
])
|
|
@@ -129,13 +128,9 @@ async function resolveOne(db, d) {
|
|
|
129
128
|
}
|
|
130
129
|
if (item.disabled)
|
|
131
130
|
throw dependencyDisabled(d.name);
|
|
132
|
-
// An org upload waiting for the super admin is no dependency target (ruling P3-9)
|
|
133
|
-
if (item.awaiting_confirmation) {
|
|
134
|
-
throw unresolved(d.name, d.version, "it waits for a super admin to confirm its extension");
|
|
135
|
-
}
|
|
136
131
|
const versions = await db
|
|
137
132
|
.selectFrom("catalog_item_versions")
|
|
138
|
-
.select(["version", "manifest", "imported_at", "applied_at"
|
|
133
|
+
.select(["version", "manifest", "imported_at", "applied_at"])
|
|
139
134
|
.where("item_id", "=", item.id)
|
|
140
135
|
.execute();
|
|
141
136
|
let v;
|
|
@@ -183,3 +183,4 @@ export declare function pluginThemeError(problems: PluginThemeProblem[]): Plugin
|
|
|
183
183
|
* `[{ theme, errors }]`, or 400 `theme.unreadable` with details `[{ theme, issues }]`.
|
|
184
184
|
*/
|
|
185
185
|
export declare function themeApiError(e: PluginPackageError): ApiError;
|
|
186
|
+
export declare function assertDeclarativeUpload(manifest: PluginManifest): void;
|
|
@@ -574,3 +574,8 @@ function readThemes(files, manifest) {
|
|
|
574
574
|
}
|
|
575
575
|
return { themes, themePaths, themeProblems };
|
|
576
576
|
}
|
|
577
|
+
export function assertDeclarativeUpload(manifest) {
|
|
578
|
+
if (manifest.extension === undefined)
|
|
579
|
+
return;
|
|
580
|
+
throw new ApiError("catalog.org_upload_code", "Remove the extension and its browser client code before uploading to an organization, or ask a super admin to import the package on the platform.");
|
|
581
|
+
}
|
|
@@ -310,7 +310,7 @@ export declare class PlatformPluginUpdater {
|
|
|
310
310
|
* re-checked under the org row lock in the transaction), then the platform update as
|
|
311
311
|
* {@link update} does, also removing the extension when the target drops it. In the update's
|
|
312
312
|
* transaction the orgs using the shared plugin are told (`shared_item_updated`, one notice per
|
|
313
|
-
* plugin)
|
|
313
|
+
* plugin).
|
|
314
314
|
*/
|
|
315
315
|
updateAsOwner(orgId: string, actor: string, itemId: string, version: string, diffHash: string, opts?: {
|
|
316
316
|
actorTokenId?: string;
|
|
@@ -319,30 +319,9 @@ export declare class PlatformPluginUpdater {
|
|
|
319
319
|
private authorizeOwner;
|
|
320
320
|
/** Runs `f` holding the item's update lock (another update -> `plugin.install_in_progress`). */
|
|
321
321
|
private locked;
|
|
322
|
-
/**
|
|
323
|
-
* The super admin's confirmation of an org upload's pending new version (rulings P3-10, P3-21,
|
|
324
|
-
* pre-flight F8): the update to `version` as {@link update} does it (the super admin's, the
|
|
325
|
-
* extension installed or upgraded on the deployment), with the version allowed although it is
|
|
326
|
-
* pending. Its transaction re-reads the item under the row lock: removed meanwhile -> 409
|
|
327
|
-
* `catalog.item_removed`, the pending version replaced -> 409 `extension.approval_stale` (both
|
|
328
|
-
* undo the extension step); then the pending state is cleared and the owner told
|
|
329
|
-
* (`upload_confirmed`). The caller checked the digest of the version's package.
|
|
330
|
-
*/
|
|
331
|
-
updateToPending(actor: string, itemId: string, version: string, opts?: {
|
|
332
|
-
actorTokenId?: string;
|
|
333
|
-
}): Promise<PlatformUpdateResult>;
|
|
334
|
-
/**
|
|
335
|
-
* {@link updateToPending} for a caller already holding the item's update lock
|
|
336
|
-
* ({@link withItemLock}): the super admin's confirmation runs all its steps under it (ruling
|
|
337
|
-
* P3-35).
|
|
338
|
-
*/
|
|
339
|
-
updateToPendingLocked(actor: string, itemId: string, version: string, opts?: {
|
|
340
|
-
actorTokenId?: string;
|
|
341
|
-
}): Promise<PlatformUpdateResult>;
|
|
342
322
|
/**
|
|
343
323
|
* Runs `f` holding the item's update lock (the one every platform update of the item takes;
|
|
344
|
-
* another holder -> 409 `plugin.install_in_progress`)
|
|
345
|
-
* upload runs every step under it (ruling P3-35).
|
|
324
|
+
* another holder -> 409 `plugin.install_in_progress`).
|
|
346
325
|
*/
|
|
347
326
|
withItemLock<T>(itemId: string, f: () => Promise<T>): Promise<T>;
|
|
348
327
|
/**
|
|
@@ -357,9 +336,7 @@ export declare class PlatformPluginUpdater {
|
|
|
357
336
|
auditDetail?: Record<string, unknown>;
|
|
358
337
|
}): Promise<PlatformUpdateResult>;
|
|
359
338
|
/**
|
|
360
|
-
* Runs an update confirmed with the preview's `diffHash` (see the class comment).
|
|
361
|
-
* org upload waits with, or an item whose first version waits, -> 409 `catalog.item_pending`
|
|
362
|
-
* (confirmed in the admin console's pending confirmations instead, pre-flight F8). `actor`
|
|
339
|
+
* Runs an update confirmed with the preview's `diffHash` (see the class comment). `actor`
|
|
363
340
|
* null: the kernel itself (the bootstrap step raising a pinned plugin without an extension): no
|
|
364
341
|
* super admin is re-checked and the audits name no account.
|
|
365
342
|
*/
|