@capybara-hq/kernel 0.1.0-rc.77 → 0.1.0-rc.78
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 +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-content.js +1 -0
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.js +8 -0
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +3 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +17 -2
- package/dist/extensions/bootstrap.js +41 -9
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +72 -1
- package/dist/extensions/plugin-icons.js +194 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +9 -1
- package/dist/packages/npm.js +37 -5
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +20 -8
- package/dist/tools/connectors.controller.js +30 -12
- package/dist/tools/connectors.service.d.ts +8 -0
- package/dist/tools/connectors.service.js +21 -1
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
4
5
|
import { PLUGIN_MANIFEST_FILE, parsePluginManifest, } from "@capybara-hq/plugin-sdk";
|
|
5
6
|
import { isClaudePluginTree, translateClaudePlugin } from "../catalog/claude/translate.js";
|
|
6
7
|
import { GitSourceError, normalGitPath, readGitTreeAndOids } from "../catalog/git-source.js";
|
|
@@ -17,6 +18,11 @@ import { packPackageTgz } from "../packages/tgz.js";
|
|
|
17
18
|
*/
|
|
18
19
|
/** The sha512 integrity (`sha512-<base64>`) of a package's bytes. */
|
|
19
20
|
export const integrityOf = (bytes) => `sha512-${createHash("sha512").update(bytes).digest("base64")}`;
|
|
21
|
+
/**
|
|
22
|
+
* The waits before the second, third and fourth attempt of an npm download that failed
|
|
23
|
+
* transiently ({@link NpmFetchError.transient}): four attempts in about 8 s per package.
|
|
24
|
+
*/
|
|
25
|
+
export const BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS = [500, 2_000, 5_000];
|
|
20
26
|
/**
|
|
21
27
|
* The marketplace a git entry names, its URL expanded as the managed row's (`config:<name>`) is and
|
|
22
28
|
* checked as an admin-added one is (`bootstrap.extra_invalid` otherwise).
|
|
@@ -37,7 +43,8 @@ export function bootstrapGitMarketplace(manifest, e, config) {
|
|
|
37
43
|
/**
|
|
38
44
|
* Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
|
|
39
45
|
* file there has that sha512, else (a `source: "npm"` entry) downloaded from the npm registry and
|
|
40
|
-
* verified against the pin (the packument's `dist.integrity` is not consulted
|
|
46
|
+
* verified against the pin (the packument's `dist.integrity` is not consulted; a transient failure
|
|
47
|
+
* is retried after each of `retryDelaysMs`; a 404, a refused connection or a mismatch is not), else (a
|
|
41
48
|
* `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
|
|
42
49
|
* re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
|
|
43
50
|
* pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
|
|
@@ -78,14 +85,37 @@ export async function resolveBootstrapPackages(manifest, o) {
|
|
|
78
85
|
}
|
|
79
86
|
const registry = registryOrigin(npmRegistry);
|
|
80
87
|
const offlineHint = `to install offline, put the package tgz (npm pack ${e.npm}@${e.version}, any file name) in ${where}`;
|
|
88
|
+
const delays = o.retryDelaysMs ?? BOOTSTRAP_DOWNLOAD_RETRY_DELAYS_MS;
|
|
89
|
+
let attempts = 0;
|
|
81
90
|
try {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
// The kernel's own download (not an extension's call): one registry hiccup must not fail a
|
|
92
|
+
// whole run of many packages, so a transient failure is retried; a 404, a refusal or a
|
|
93
|
+
// package that differs from its pin is final at once
|
|
94
|
+
for (;;) {
|
|
95
|
+
attempts++;
|
|
96
|
+
try {
|
|
97
|
+
const r = await fetchPackage({
|
|
98
|
+
registry: npmRegistry,
|
|
99
|
+
...(npmToken !== undefined && { token: npmToken }),
|
|
100
|
+
maxBytes,
|
|
101
|
+
net: marketplaceNetPolicy(o.config),
|
|
102
|
+
}, e.npm, e.version, signal, { expectedIntegrity: e.integrity });
|
|
103
|
+
return r.bytes;
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
const delay = delays[attempts - 1];
|
|
107
|
+
if (signal.aborted || delay === undefined || !isTransientDownloadError(err))
|
|
108
|
+
throw err;
|
|
109
|
+
o.log?.warn("bootstrap: a package download failed; retrying", {
|
|
110
|
+
plugin: e.name,
|
|
111
|
+
package: `${e.npm}@${e.version}`,
|
|
112
|
+
attempt: attempts,
|
|
113
|
+
retryInMs: delay,
|
|
114
|
+
error: errMsg(err),
|
|
115
|
+
});
|
|
116
|
+
await sleep(delay, undefined, { signal });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
89
119
|
}
|
|
90
120
|
catch (err) {
|
|
91
121
|
if (signal.aborted)
|
|
@@ -98,7 +128,7 @@ export async function resolveBootstrapPackages(manifest, o) {
|
|
|
98
128
|
: err instanceof Error
|
|
99
129
|
? err.message
|
|
100
130
|
: String(err);
|
|
101
|
-
throw new ApiError("bootstrap.download_failed", `Bootstrap plugin ${e.name} ${e.version}: cannot download ${e.npm}@${e.version} from ${registry} (${reason}); ${offlineHint}, or set packages.npmRegistry to a reachable mirror`);
|
|
131
|
+
throw new ApiError("bootstrap.download_failed", `Bootstrap plugin ${e.name} ${e.version}: cannot download ${e.npm}@${e.version} from ${registry} (${reason}${attempts > 1 ? `; ${attempts} attempts` : ""}); ${offlineHint}, or set packages.npmRegistry to a reachable mirror`);
|
|
102
132
|
}
|
|
103
133
|
}
|
|
104
134
|
async function obtainGit(e) {
|
|
@@ -154,6 +184,16 @@ export async function resolveBootstrapPackages(manifest, o) {
|
|
|
154
184
|
}
|
|
155
185
|
}
|
|
156
186
|
const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
187
|
+
/**
|
|
188
|
+
* A download failure worth another attempt: an {@link NpmFetchError} marked transient (network
|
|
189
|
+
* error, timeout, HTTP 408 / 429 / 5xx, a body cut off). Never an integrity mismatch, a package
|
|
190
|
+
* over the size limit, a 404 or a refusal by the network rules.
|
|
191
|
+
*/
|
|
192
|
+
function isTransientDownloadError(err) {
|
|
193
|
+
if (err instanceof IntegrityMismatchError || err instanceof PackageTooLargeError)
|
|
194
|
+
return false;
|
|
195
|
+
return err instanceof NpmFetchError && err.transient;
|
|
196
|
+
}
|
|
157
197
|
/** The registry's origin, for messages (never its credentials or path). */
|
|
158
198
|
function registryOrigin(registry) {
|
|
159
199
|
try {
|
|
@@ -4,6 +4,7 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
6
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
7
8
|
import type { KernelLogger } from "../log.js";
|
|
8
9
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
9
10
|
import { type ExtraManifestTraces, type MergedBootstrapManifest } from "./bootstrap-extra.js";
|
|
@@ -161,6 +162,7 @@ export declare class BootstrapService {
|
|
|
161
162
|
private readonly approveLock;
|
|
162
163
|
private readonly installs;
|
|
163
164
|
private readonly ops;
|
|
165
|
+
private readonly outbox;
|
|
164
166
|
/**
|
|
165
167
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
166
168
|
* install record is created): the start sequence records them before the bootstrap step, the
|
|
@@ -171,7 +173,7 @@ export declare class BootstrapService {
|
|
|
171
173
|
private readonly log;
|
|
172
174
|
/** The lock's lifetime without renewal. */
|
|
173
175
|
private readonly lockTtlMs;
|
|
174
|
-
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps,
|
|
176
|
+
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add">,
|
|
175
177
|
/**
|
|
176
178
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
177
179
|
* install record is created): the start sequence records them before the bootstrap step, the
|
|
@@ -284,8 +286,18 @@ export declare class BootstrapService {
|
|
|
284
286
|
* builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
|
|
285
287
|
* Only the platform item: an org-owned item of the same name (the entry then fails with
|
|
286
288
|
* `plugin.name_taken`) is never touched.
|
|
289
|
+
*
|
|
290
|
+
* A demoted item owes its scope sync in the same transaction ({@link demoted}): its extension
|
|
291
|
+
* was on in every org without an org row (always-on), and from now on the sync's org install
|
|
292
|
+
* keeps it on where the scope wants it.
|
|
287
293
|
*/
|
|
288
294
|
private markBuiltin;
|
|
295
|
+
/**
|
|
296
|
+
* Owes the scope sync of catalog items that just stopped being builtin, in the transaction in
|
|
297
|
+
* context. A builtin item's extension was enabled in every org without an org row and the sync
|
|
298
|
+
* left the item alone; without this sync the orgs its scope (`all`) wants it on in would lose it.
|
|
299
|
+
*/
|
|
300
|
+
private demoted;
|
|
289
301
|
/**
|
|
290
302
|
* The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
|
|
291
303
|
* rules refuse is `catalog.invalid_manifest`.
|
|
@@ -329,6 +341,9 @@ export declare class BootstrapService {
|
|
|
329
341
|
private leftDisabled;
|
|
330
342
|
/** The permission snapshot of a stored package (source `bootstrap`), under the approve lock. */
|
|
331
343
|
private approveStored;
|
|
332
|
-
/**
|
|
344
|
+
/**
|
|
345
|
+
* Install records still `required` whose entry left the manifest lose `required`; the catalog
|
|
346
|
+
* items of entries that left lose `builtin` and owe their scope sync ({@link demoted}).
|
|
347
|
+
*/
|
|
333
348
|
private clearRemoved;
|
|
334
349
|
}
|
|
@@ -17,6 +17,7 @@ import { CONFIG_MARKETPLACE_PREFIX } from "../catalog/marketplaces.service.js";
|
|
|
17
17
|
import { otherNameOwner } from "../catalog/ownership.js";
|
|
18
18
|
import { catalogPackageError, } from "../catalog/plugin-import.js";
|
|
19
19
|
import { PluginPackageError, readPluginPackage } from "../catalog/plugin-package.js";
|
|
20
|
+
import { oweScopeItem } from "../catalog/scope-jobs.js";
|
|
20
21
|
import { ApiError } from "../errors.js";
|
|
21
22
|
import { audit } from "../identity/audit.js";
|
|
22
23
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -24,6 +25,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
24
25
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
25
26
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
26
27
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
28
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
27
29
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
28
30
|
import { PackageTgzError, unpackPackageTgz } from "../packages/tgz.js";
|
|
29
31
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
@@ -84,11 +86,12 @@ let BootstrapService = class BootstrapService {
|
|
|
84
86
|
approveLock;
|
|
85
87
|
installs;
|
|
86
88
|
ops;
|
|
89
|
+
outbox;
|
|
87
90
|
registry;
|
|
88
91
|
configService;
|
|
89
92
|
log;
|
|
90
93
|
lockTtlMs;
|
|
91
|
-
constructor(kdb, txHost, locks, approveLock, installs, ops,
|
|
94
|
+
constructor(kdb, txHost, locks, approveLock, installs, ops, outbox,
|
|
92
95
|
/**
|
|
93
96
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
94
97
|
* install record is created): the start sequence records them before the bootstrap step, the
|
|
@@ -103,6 +106,7 @@ let BootstrapService = class BootstrapService {
|
|
|
103
106
|
this.approveLock = approveLock;
|
|
104
107
|
this.installs = installs;
|
|
105
108
|
this.ops = ops;
|
|
109
|
+
this.outbox = outbox;
|
|
106
110
|
this.registry = registry;
|
|
107
111
|
this.configService = configService;
|
|
108
112
|
this.log = log;
|
|
@@ -595,6 +599,10 @@ let BootstrapService = class BootstrapService {
|
|
|
595
599
|
* builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
|
|
596
600
|
* Only the platform item: an org-owned item of the same name (the entry then fails with
|
|
597
601
|
* `plugin.name_taken`) is never touched.
|
|
602
|
+
*
|
|
603
|
+
* A demoted item owes its scope sync in the same transaction ({@link demoted}): its extension
|
|
604
|
+
* was on in every org without an org row (always-on), and from now on the sync's org install
|
|
605
|
+
* keeps it on where the scope wants it.
|
|
598
606
|
*/
|
|
599
607
|
async markBuiltin(name, builtin) {
|
|
600
608
|
const touch = { updated_at: sql `now()` };
|
|
@@ -614,14 +622,25 @@ let BootstrapService = class BootstrapService {
|
|
|
614
622
|
.execute();
|
|
615
623
|
return;
|
|
616
624
|
}
|
|
617
|
-
await this.db
|
|
625
|
+
const rows = await this.db
|
|
618
626
|
.updateTable("catalog_items")
|
|
619
627
|
.set({ builtin: false, ...touch })
|
|
620
628
|
.where("name", "=", name)
|
|
621
629
|
.where("owner_org_id", "is", null)
|
|
622
630
|
.where("deleted_at", "is", null)
|
|
623
631
|
.where("builtin", "=", true)
|
|
632
|
+
.returning("id")
|
|
624
633
|
.execute();
|
|
634
|
+
await this.demoted(rows.map((r) => r.id));
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Owes the scope sync of catalog items that just stopped being builtin, in the transaction in
|
|
638
|
+
* context. A builtin item's extension was enabled in every org without an org row and the sync
|
|
639
|
+
* left the item alone; without this sync the orgs its scope (`all`) wants it on in would lose it.
|
|
640
|
+
*/
|
|
641
|
+
async demoted(itemIds) {
|
|
642
|
+
for (const id of itemIds)
|
|
643
|
+
await oweScopeItem(this.outbox, this.db, id);
|
|
625
644
|
}
|
|
626
645
|
/**
|
|
627
646
|
* The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
|
|
@@ -802,7 +821,10 @@ let BootstrapService = class BootstrapService {
|
|
|
802
821
|
audit: { added, removed, sha256 },
|
|
803
822
|
});
|
|
804
823
|
}
|
|
805
|
-
/**
|
|
824
|
+
/**
|
|
825
|
+
* Install records still `required` whose entry left the manifest lose `required`; the catalog
|
|
826
|
+
* items of entries that left lose `builtin` and owe their scope sync ({@link demoted}).
|
|
827
|
+
*/
|
|
806
828
|
async clearRemoved(manifest) {
|
|
807
829
|
const names = manifest.plugins.map((p) => p.name);
|
|
808
830
|
let q = this.db
|
|
@@ -823,7 +845,7 @@ let BootstrapService = class BootstrapService {
|
|
|
823
845
|
.where("deleted_at", "is", null);
|
|
824
846
|
if (names.length > 0)
|
|
825
847
|
items = items.where("name", "not in", names);
|
|
826
|
-
await items.execute();
|
|
848
|
+
await this.demoted((await items.returning("id").execute()).map((r) => r.id));
|
|
827
849
|
return rows.map((r) => ({ name: r.name, action: "required_cleared", version: r.version }));
|
|
828
850
|
}
|
|
829
851
|
};
|
|
@@ -833,9 +855,18 @@ __decorate([
|
|
|
833
855
|
__decorate([
|
|
834
856
|
Transactional()
|
|
835
857
|
], BootstrapService.prototype, "recordDone", null);
|
|
858
|
+
__decorate([
|
|
859
|
+
Transactional()
|
|
860
|
+
], BootstrapService.prototype, "markBuiltin", null);
|
|
861
|
+
__decorate([
|
|
862
|
+
Transactional({ propagation: "mandatory" })
|
|
863
|
+
], BootstrapService.prototype, "demoted", null);
|
|
836
864
|
__decorate([
|
|
837
865
|
Transactional()
|
|
838
866
|
], BootstrapService.prototype, "approveStored", null);
|
|
867
|
+
__decorate([
|
|
868
|
+
Transactional()
|
|
869
|
+
], BootstrapService.prototype, "clearRemoved", null);
|
|
839
870
|
BootstrapService = __decorate([
|
|
840
871
|
Injectable(),
|
|
841
872
|
__param(0, Inject(KernelDb)),
|
|
@@ -844,11 +875,12 @@ BootstrapService = __decorate([
|
|
|
844
875
|
__param(3, Inject(PluginApproveLock)),
|
|
845
876
|
__param(4, Inject(ExtensionInstalls)),
|
|
846
877
|
__param(5, Inject(ExtensionAdminOps)),
|
|
847
|
-
__param(6, Inject(
|
|
848
|
-
__param(7, Inject(
|
|
849
|
-
__param(8, Inject(
|
|
850
|
-
__param(9,
|
|
851
|
-
__param(
|
|
878
|
+
__param(6, Inject(OutboxService)),
|
|
879
|
+
__param(7, Inject(ExtensionRegistry)),
|
|
880
|
+
__param(8, Inject(KernelConfigService)),
|
|
881
|
+
__param(9, Inject(KERNEL_LOGGER)),
|
|
882
|
+
__param(10, Optional()),
|
|
883
|
+
__param(10, Inject(BOOTSTRAP_LOCK_TTL))
|
|
852
884
|
], BootstrapService);
|
|
853
885
|
export { BootstrapService };
|
|
854
886
|
/** A `kept` result whose entry an earlier pass of the same start installed / upgraded / imported. */
|
|
@@ -7,7 +7,7 @@ import { type ConfigUiProblem, type JsonSchema } from "@capybara-hq/plugin-sdk";
|
|
|
7
7
|
import type { z } from "zod";
|
|
8
8
|
export { configJsonSchema as configToJsonSchema, type JsonSchema } from "@capybara-hq/plugin-sdk";
|
|
9
9
|
/** The config level a schema belongs to (which hints `validateConfigUi` allows). */
|
|
10
|
-
export type ConfigLevel = "deployment" | "
|
|
10
|
+
export type ConfigLevel = "deployment" | "connection";
|
|
11
11
|
/** A config schema as served to forms, with the problems of its hints (empty = kept). */
|
|
12
12
|
export interface ConfigFormSchema {
|
|
13
13
|
/** Shared by every caller: clone it before handing it out or changing it. */
|
|
@@ -28,7 +28,7 @@ export declare function checkConfigUi(schema: JsonSchema, level: ConfigLevel): C
|
|
|
28
28
|
export declare function configFormSchema(schema: z.ZodTypeAny, level: ConfigLevel): ConfigFormSchema;
|
|
29
29
|
/**
|
|
30
30
|
* {@link configFormSchema} that never throws, for every caller that serves a form schema or reads
|
|
31
|
-
* its messages (deployment,
|
|
31
|
+
* its messages (deployment, connection, issues). A hint conversion that throws (a hand-made
|
|
32
32
|
* package, e.g. hints that won't serialize as JSON) drops the hints: the plain schema with every
|
|
33
33
|
* `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
|
|
34
34
|
* schema object and level on this replica (the caller's one warning); later calls reuse the result.
|
|
@@ -46,7 +46,6 @@ export function checkConfigUi(schema, level) {
|
|
|
46
46
|
/** Manifests are immutable: one conversion per zod schema object and level (read-only, per replica). */
|
|
47
47
|
const caches = {
|
|
48
48
|
deployment: new WeakMap(),
|
|
49
|
-
org: new WeakMap(),
|
|
50
49
|
connection: new WeakMap(),
|
|
51
50
|
};
|
|
52
51
|
/** A config schema's form JSON Schema ({@link checkConfigUi} applied), cached per schema object. */
|
|
@@ -63,12 +62,11 @@ export function configFormSchema(schema, level) {
|
|
|
63
62
|
/** The schemas whose hinted conversion threw: their fallback (plain schema, or null). */
|
|
64
63
|
const fallbacks = {
|
|
65
64
|
deployment: new WeakMap(),
|
|
66
|
-
org: new WeakMap(),
|
|
67
65
|
connection: new WeakMap(),
|
|
68
66
|
};
|
|
69
67
|
/**
|
|
70
68
|
* {@link configFormSchema} that never throws, for every caller that serves a form schema or reads
|
|
71
|
-
* its messages (deployment,
|
|
69
|
+
* its messages (deployment, connection, issues). A hint conversion that throws (a hand-made
|
|
72
70
|
* package, e.g. hints that won't serialize as JSON) drops the hints: the plain schema with every
|
|
73
71
|
* `x-ui` stripped, else `null` when even the plain conversion fails. `onFallback` runs once per
|
|
74
72
|
* schema object and level on this replica (the caller's one warning); later calls reuse the result.
|
|
@@ -19,6 +19,7 @@ import { ExtensionInstalls } from "./installs.js";
|
|
|
19
19
|
import { ExtensionLifecycle } from "./lifecycle.js";
|
|
20
20
|
import { PLUGIN_DEPLOYMENT_CONFIG_TOPIC } from "./lifecycle-topics.js";
|
|
21
21
|
import { PluginDeploymentConfigLock } from "./locks.js";
|
|
22
|
+
import { type FieldLevel } from "./org-levels.js";
|
|
22
23
|
export { DEPLOYMENT_SECRETS_ORG, type DeploymentSchemaInfo, mergeDeploymentConfig, readStoredDeploymentConfig, schemaFields, secretPathsOf, };
|
|
23
24
|
type Obj = Record<string, unknown>;
|
|
24
25
|
export type { ConfigIssue };
|
|
@@ -43,10 +44,11 @@ export interface DeploymentConfigField {
|
|
|
43
44
|
*/
|
|
44
45
|
keys?: string[];
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
47
|
+
* The field's org level (unified config spec §5.1, the level of its top-level key): `override`
|
|
48
|
+
* (orgs follow the platform's value or bring their own) or `platform` (platform-only, orgs never
|
|
49
|
+
* see it).
|
|
48
50
|
*/
|
|
49
|
-
|
|
51
|
+
level: FieldLevel;
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* One operation on a secret record drawn per item (spec §4.3), only for a path some
|
|
@@ -423,14 +423,14 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
423
423
|
value = d.value;
|
|
424
424
|
source = value === undefined ? "unset" : "default";
|
|
425
425
|
}
|
|
426
|
-
const level = levels.get(f.path.split(".")[0]);
|
|
427
426
|
const base = {
|
|
428
427
|
path: f.path,
|
|
429
428
|
secret: f.secret,
|
|
430
429
|
hot: f.hot,
|
|
431
430
|
source,
|
|
432
431
|
readonly: from !== undefined,
|
|
433
|
-
|
|
432
|
+
// a schema with no top-level keys (not an object) has nothing an org could override
|
|
433
|
+
level: levels.get(f.path.split(".")[0]) ?? "platform",
|
|
434
434
|
};
|
|
435
435
|
// a schema default (e.g. `secret(record).default({})`) is no secret anybody set
|
|
436
436
|
const set = value !== undefined && source !== "default";
|
|
@@ -528,7 +528,7 @@ function levelsOf(info) {
|
|
|
528
528
|
}
|
|
529
529
|
/**
|
|
530
530
|
* The required `override` keys `raw` leaves empty: by the zod schema, else (a static form schema)
|
|
531
|
-
* the `required` keys
|
|
531
|
+
* the `required` keys that are not platform-only and have no value.
|
|
532
532
|
*/
|
|
533
533
|
function orgMustConfigureOf(info, raw, levels) {
|
|
534
534
|
if (info.schema)
|
|
@@ -18,8 +18,9 @@ export declare const NEEDS_CONFIG_REASON = "needs configuration in this organiza
|
|
|
18
18
|
/** The kernel's own secrets namespace (`kernel` is a reserved plugin name). */
|
|
19
19
|
export declare const OVERRIDE_SECRETS_NAMESPACE = "kernel";
|
|
20
20
|
/**
|
|
21
|
-
* Where a copy's secret field lives in `capybara.secrets` (under the org): a
|
|
22
|
-
* distinct from the org
|
|
21
|
+
* Where a copy's secret field lives in `capybara.secrets` (under the org): a key prefix of its
|
|
22
|
+
* own, distinct from the retired org config secrets `plugin-config:<plugin>:<path>` (spec A §5.8;
|
|
23
|
+
* no longer read, purged by a later contract migration).
|
|
23
24
|
*/
|
|
24
25
|
export declare const overrideSecretKey: (plugin: string, path: string) => string;
|
|
25
26
|
/**
|
|
@@ -53,11 +54,11 @@ export declare function overrideSecretPaths(schema: z.ZodTypeAny, levels?: Map<s
|
|
|
53
54
|
export declare function platformOverrideValues(schema: z.ZodTypeAny, platform: unknown): Obj;
|
|
54
55
|
/**
|
|
55
56
|
* The deployment config an org with a copy runs with, before validation (spec A §5.4): the
|
|
56
|
-
* platform's values of the
|
|
57
|
-
* (its non-secret part and its own secrets). An
|
|
58
|
-
*
|
|
59
|
-
* removed: a copy never falls back to a platform
|
|
60
|
-
* are no longer `override` are ignored.
|
|
57
|
+
* platform's values of the platform-only keys (their secrets included: an org cannot set them),
|
|
58
|
+
* and for each `override` key the copy's value (its non-secret part and its own secrets). An
|
|
59
|
+
* `override` key the copy does not hold (one that became overridable after the copy was made)
|
|
60
|
+
* takes the platform's value with every secret leaf removed: a copy never falls back to a platform
|
|
61
|
+
* secret, required or not. Copy values of keys that are no longer `override` are ignored.
|
|
61
62
|
*/
|
|
62
63
|
export declare function mergeCopy(schema: z.ZodTypeAny, platform: unknown, copy: StoredCopy): Obj;
|
|
63
64
|
/**
|
|
@@ -33,8 +33,9 @@ export const NEEDS_CONFIG_REASON = "needs configuration in this organization";
|
|
|
33
33
|
export const OVERRIDE_SECRETS_NAMESPACE = "kernel";
|
|
34
34
|
const OVERRIDE_KEY_PREFIX = "plugin-override:";
|
|
35
35
|
/**
|
|
36
|
-
* Where a copy's secret field lives in `capybara.secrets` (under the org): a
|
|
37
|
-
* distinct from the org
|
|
36
|
+
* Where a copy's secret field lives in `capybara.secrets` (under the org): a key prefix of its
|
|
37
|
+
* own, distinct from the retired org config secrets `plugin-config:<plugin>:<path>` (spec A §5.8;
|
|
38
|
+
* no longer read, purged by a later contract migration).
|
|
38
39
|
*/
|
|
39
40
|
export const overrideSecretKey = (plugin, path) => `${OVERRIDE_KEY_PREFIX}${plugin}:${path}`;
|
|
40
41
|
const notRunning = () => ({
|
|
@@ -79,11 +80,11 @@ export function platformOverrideValues(schema, platform) {
|
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
82
|
* The deployment config an org with a copy runs with, before validation (spec A §5.4): the
|
|
82
|
-
* platform's values of the
|
|
83
|
-
* (its non-secret part and its own secrets). An
|
|
84
|
-
*
|
|
85
|
-
* removed: a copy never falls back to a platform
|
|
86
|
-
* are no longer `override` are ignored.
|
|
83
|
+
* platform's values of the platform-only keys (their secrets included: an org cannot set them),
|
|
84
|
+
* and for each `override` key the copy's value (its non-secret part and its own secrets). An
|
|
85
|
+
* `override` key the copy does not hold (one that became overridable after the copy was made)
|
|
86
|
+
* takes the platform's value with every secret leaf removed: a copy never falls back to a platform
|
|
87
|
+
* secret, required or not. Copy values of keys that are no longer `override` are ignored.
|
|
87
88
|
*/
|
|
88
89
|
export function mergeCopy(schema, platform, copy) {
|
|
89
90
|
const levels = fieldLevels(schema);
|
|
@@ -54,6 +54,7 @@ export function enabledExtensionsQuery(db, orgId) {
|
|
|
54
54
|
* `plugin`): `.innerJoin(enabledExtensionsByOrg(db).as("en"), (j) => j.onRef("en.org_id", …)…)`.
|
|
55
55
|
* Soft-deleted orgs are included, as their org config rows are; callers filter `orgs.deleted_at`.
|
|
56
56
|
*/
|
|
57
|
+
// org-filter: every (org, extension) pair by design; callers join it on their own org column
|
|
57
58
|
export function enabledExtensionsByOrg(db) {
|
|
58
59
|
return db
|
|
59
60
|
.selectFrom("extension_org_configs as eoc")
|
|
@@ -59,8 +59,9 @@ export interface InspectedExtension {
|
|
|
59
59
|
displayName: LocalizedName | null;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
62
|
+
* Every `secret()` in an extension's deployment schema must sit on an object field path (see
|
|
63
|
+
* `unreachableSecrets`); otherwise the kernel cannot store and mask it on its own and would keep
|
|
64
|
+
* and echo it in clear, so the load is refused, naming the extension and the path.
|
|
64
65
|
*/
|
|
65
66
|
export declare function assertSecretsReachable(manifest: ExtensionManifest): void;
|
|
66
67
|
/**
|
|
@@ -417,7 +418,7 @@ export declare class ExtensionHost {
|
|
|
417
418
|
*/
|
|
418
419
|
private loadDeferred;
|
|
419
420
|
/**
|
|
420
|
-
* Checks the config UI hints of a loaded module's deployment
|
|
421
|
+
* Checks the config UI hints of a loaded module's deployment schema (spec §4.1). Invalid
|
|
421
422
|
* hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
|
|
422
423
|
* per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
|
|
423
424
|
* every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
|
package/dist/extensions/host.js
CHANGED
|
@@ -189,18 +189,17 @@ async function migratePlugin(dbUrl, manifest, migrationsDir, connectTimeoutMs, s
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
192
|
+
* Every `secret()` in an extension's deployment schema must sit on an object field path (see
|
|
193
|
+
* `unreachableSecrets`); otherwise the kernel cannot store and mask it on its own and would keep
|
|
194
|
+
* and echo it in clear, so the load is refused, naming the extension and the path.
|
|
194
195
|
*/
|
|
195
196
|
export function assertSecretsReachable(manifest) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
throw new Error(`plugin ${manifest.name}: config.${level}: ${bad.map((p) => `secret() at "${p}"`).join(", ")} is not on an object field path; secret() inside union / intersection / transform / pipe / lazy / array / record / tuple is not supported — mark the whole enclosing object field secret instead`);
|
|
203
|
-
}
|
|
197
|
+
const schema = manifest.config?.deployment;
|
|
198
|
+
if (!schema)
|
|
199
|
+
return;
|
|
200
|
+
const bad = unreachableSecrets(schema);
|
|
201
|
+
if (bad.length > 0) {
|
|
202
|
+
throw new Error(`plugin ${manifest.name}: config.deployment: ${bad.map((p) => `secret() at "${p}"`).join(", ")} is not on an object field path; secret() inside union / intersection / transform / pipe / lazy / array / record / tuple is not supported — mark the whole enclosing object field secret instead`);
|
|
204
203
|
}
|
|
205
204
|
}
|
|
206
205
|
/** 按模块解析的插件(配置声明)的迁移目录:清单 `migrations` 相对模块所在目录。 */
|
|
@@ -1153,7 +1152,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1153
1152
|
}
|
|
1154
1153
|
}
|
|
1155
1154
|
/**
|
|
1156
|
-
* Checks the config UI hints of a loaded module's deployment
|
|
1155
|
+
* Checks the config UI hints of a loaded module's deployment schema (spec §4.1). Invalid
|
|
1157
1156
|
* hints never fail the load: the form schemas drop their `x-ui` (`configFormSchema`), one warning
|
|
1158
1157
|
* per `<name>@<version>` is logged, and the returned text goes into the status detail (null when
|
|
1159
1158
|
* every hint is valid). The packer refuses such a package; this covers hand-made ones. It never
|
|
@@ -1162,7 +1161,7 @@ let ExtensionHost = class ExtensionHost {
|
|
|
1162
1161
|
*/
|
|
1163
1162
|
checkConfigUi(manifest) {
|
|
1164
1163
|
const parts = [];
|
|
1165
|
-
for (const level of ["deployment"
|
|
1164
|
+
for (const level of ["deployment"]) {
|
|
1166
1165
|
const schema = manifest.config?.[level];
|
|
1167
1166
|
if (!schema)
|
|
1168
1167
|
continue;
|
|
@@ -11,7 +11,7 @@ export type { Registration, RegistrationKind } from "./ledger.js";
|
|
|
11
11
|
export declare class ManifestMismatchError extends Error {
|
|
12
12
|
constructor(plugin: string, moduleName: string);
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** Whether a module's manifest matches the reviewed static manifest (same name and {@link staticManifestOf}). */
|
|
15
15
|
export declare function matchesSection(manifest: ExtensionManifest, name: string, section: StaticExtensionManifest): boolean;
|
|
16
16
|
/** 导入一个插件模块(default 导出)并按 defineExtension 校验清单。 */
|
|
17
17
|
export declare function importExtensionModule(url: string, label: string, resolveFrom: string): Promise<ExtensionManifest>;
|
|
@@ -23,9 +23,24 @@ const canonical = (v) => {
|
|
|
23
23
|
}
|
|
24
24
|
return JSON.stringify(v) ?? "null";
|
|
25
25
|
};
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* A reviewed static manifest without the `config.org` list that packages packed before core#720
|
|
28
|
+
* carry (stored install records and catalog sections keep it as reviewed). The list is dropped, not
|
|
29
|
+
* compared: the SDK no longer has org-only config, and `defineExtension` drops the module's own
|
|
30
|
+
* `config.org` the same way. Removed with the other pre-core#720 readers once the official plugins are
|
|
31
|
+
* republished and re-pinned (core#720 plan Task 17).
|
|
32
|
+
*/
|
|
33
|
+
function withoutLegacyOrgConfig(section) {
|
|
34
|
+
const config = section.config;
|
|
35
|
+
if (config === undefined || !("org" in config))
|
|
36
|
+
return section;
|
|
37
|
+
const { org: _legacyOrg, ...rest } = config;
|
|
38
|
+
return { ...section, config: rest };
|
|
39
|
+
}
|
|
40
|
+
/** Whether a module's manifest matches the reviewed static manifest (same name and {@link staticManifestOf}). */
|
|
27
41
|
export function matchesSection(manifest, name, section) {
|
|
28
|
-
return manifest.name === name &&
|
|
42
|
+
return (manifest.name === name &&
|
|
43
|
+
canonical(staticManifestOf(manifest)) === canonical(withoutLegacyOrgConfig(section)));
|
|
29
44
|
}
|
|
30
45
|
/** 导入一个插件模块(default 导出)并按 defineExtension 校验清单。 */
|
|
31
46
|
export async function importExtensionModule(url, label, resolveFrom) {
|