@capybara-hq/kernel 0.1.0-rc.76 → 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 +36 -4
- package/dist/extensions/bootstrap.js +103 -16
- 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/skill-load.d.ts +10 -9
- package/dist/tools/builtins/skill-load.js +15 -19
- 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";
|
|
@@ -150,7 +151,7 @@ export declare const BOOTSTRAP_LOCK_TTL: unique symbol;
|
|
|
150
151
|
/** What a run imports a declarative entry or an entry's catalog version with. */
|
|
151
152
|
export type BootstrapImports = Pick<PluginImport, "prepare" | "prepareGit" | "confirm">;
|
|
152
153
|
/**
|
|
153
|
-
* What a run moves the platform to a raised pin
|
|
154
|
+
* What a run moves the platform to a raised pin with, with or without an extension (the
|
|
154
155
|
* platform plugin update, acting as the kernel).
|
|
155
156
|
*/
|
|
156
157
|
export type BootstrapUpdater = Pick<PlatformPluginUpdater, "preview" | "update">;
|
|
@@ -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
|
|
@@ -227,7 +229,7 @@ export declare class BootstrapService {
|
|
|
227
229
|
packages?: ReadonlyMap<string, Uint8Array>;
|
|
228
230
|
/** The plugin import a declarative entry (or an entry's catalog version) goes through. */
|
|
229
231
|
imports: BootstrapImports;
|
|
230
|
-
/** The platform update a raised pin
|
|
232
|
+
/** The platform update a raised pin goes through (after the extension step, if any). */
|
|
231
233
|
updater: BootstrapUpdater;
|
|
232
234
|
}): Promise<BootstrapResult>;
|
|
233
235
|
/**
|
|
@@ -255,6 +257,23 @@ export declare class BootstrapService {
|
|
|
255
257
|
/** The entry names the last completed run handled (undefined before any run completed). */
|
|
256
258
|
private lastRunNames;
|
|
257
259
|
private entry;
|
|
260
|
+
/**
|
|
261
|
+
* After the extension step: when the install record runs the pin from `bootstrap` and the
|
|
262
|
+
* plugin's platform version came from `bootstrap` at a lower version (raised just now, or by a
|
|
263
|
+
* run before core#727 that moved only the extension), the platform update moves the platform to
|
|
264
|
+
* the pin, acting as the kernel. A version the super admin moved to stays; a disabled item gets
|
|
265
|
+
* none (the update refuses it; the super admin applies the version once they enable it).
|
|
266
|
+
* Returns whether the platform moved.
|
|
267
|
+
*/
|
|
268
|
+
private raisePlatform;
|
|
269
|
+
/**
|
|
270
|
+
* The platform update to the pin, acting as the kernel (actor `null`). The update recomputes its
|
|
271
|
+
* preview under the item's lock; a scope sync the extension step owed may run between the two
|
|
272
|
+
* and change the orgs the preview covers (409 `plugin.upgrade_stale`): previewed again, a few
|
|
273
|
+
* times.
|
|
274
|
+
*/
|
|
275
|
+
private applyPlatform;
|
|
276
|
+
private logDisabled;
|
|
258
277
|
/**
|
|
259
278
|
* The live (not deleted) platform catalog item of this name: its platform version (the one orgs
|
|
260
279
|
* install, else its latest) and where that version came from. undefined: no such item.
|
|
@@ -267,8 +286,18 @@ export declare class BootstrapService {
|
|
|
267
286
|
* builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
|
|
268
287
|
* Only the platform item: an org-owned item of the same name (the entry then fails with
|
|
269
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.
|
|
270
293
|
*/
|
|
271
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;
|
|
272
301
|
/**
|
|
273
302
|
* The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
|
|
274
303
|
* rules refuse is `catalog.invalid_manifest`.
|
|
@@ -312,6 +341,9 @@ export declare class BootstrapService {
|
|
|
312
341
|
private leftDisabled;
|
|
313
342
|
/** The permission snapshot of a stored package (source `bootstrap`), under the approve lock. */
|
|
314
343
|
private approveStored;
|
|
315
|
-
/**
|
|
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
|
+
*/
|
|
316
348
|
private clearRemoved;
|
|
317
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;
|
|
@@ -436,22 +440,18 @@ let BootstrapService = class BootstrapService {
|
|
|
436
440
|
if (live !== undefined) {
|
|
437
441
|
// As the extension path does: a version the bootstrap put there is raised to the pin; one
|
|
438
442
|
// the super admin moved to (another source, or a higher version) stays
|
|
439
|
-
if (
|
|
443
|
+
if (!raisable(live, e.version)) {
|
|
440
444
|
return { name: e.name, action: "kept", version: live.version };
|
|
441
445
|
}
|
|
442
446
|
if (live.disabled) {
|
|
443
447
|
// The update refuses a disabled item: the version waits in the catalog, and the super
|
|
444
448
|
// admin applies it once they enable the plugin
|
|
445
449
|
await this.importOnly(e, bytes, source, imports, git);
|
|
446
|
-
this.
|
|
450
|
+
this.logDisabled(e, live.version);
|
|
447
451
|
return { name: e.name, action: "kept", version: live.version };
|
|
448
452
|
}
|
|
449
453
|
await this.importOnly(e, bytes, source, imports, git, true);
|
|
450
|
-
|
|
451
|
-
await updater.update(null, live.itemId, {
|
|
452
|
-
version: e.version,
|
|
453
|
-
diffHash: preview.diffHash,
|
|
454
|
-
});
|
|
454
|
+
await this.applyPlatform(updater, live.itemId, e.version);
|
|
455
455
|
return { name: e.name, action: "upgraded", version: e.version };
|
|
456
456
|
}
|
|
457
457
|
// A builtin entry a super admin removed is put back; an optional one stays out (Ruling 5)
|
|
@@ -509,8 +509,62 @@ let BootstrapService = class BootstrapService {
|
|
|
509
509
|
leftDisabled = await this.enableOrWarn(e);
|
|
510
510
|
}
|
|
511
511
|
await this.markBuiltin(e.name, builtin);
|
|
512
|
+
// The catalog version of the pin is imported now; the platform (its skills, templates, themes
|
|
513
|
+
// and org installs) follows the extension the same way a declarative entry does (core#727)
|
|
514
|
+
if (await this.raisePlatform(e, updater)) {
|
|
515
|
+
result = { name: e.name, action: "upgraded", version: e.version };
|
|
516
|
+
}
|
|
512
517
|
return leftDisabled === undefined ? result : { ...result, leftDisabled };
|
|
513
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* After the extension step: when the install record runs the pin from `bootstrap` and the
|
|
521
|
+
* plugin's platform version came from `bootstrap` at a lower version (raised just now, or by a
|
|
522
|
+
* run before core#727 that moved only the extension), the platform update moves the platform to
|
|
523
|
+
* the pin, acting as the kernel. A version the super admin moved to stays; a disabled item gets
|
|
524
|
+
* none (the update refuses it; the super admin applies the version once they enable it).
|
|
525
|
+
* Returns whether the platform moved.
|
|
526
|
+
*/
|
|
527
|
+
async raisePlatform(e, updater) {
|
|
528
|
+
const row = await this.db
|
|
529
|
+
.selectFrom("extension_installs")
|
|
530
|
+
.select(["version", "source"])
|
|
531
|
+
.where("name", "=", e.name)
|
|
532
|
+
.executeTakeFirst();
|
|
533
|
+
if (row?.source !== "bootstrap" || row.version !== e.version)
|
|
534
|
+
return false;
|
|
535
|
+
const live = await this.platformVersion(e.name);
|
|
536
|
+
if (live === undefined || !raisable(live, e.version))
|
|
537
|
+
return false;
|
|
538
|
+
if (live.disabled) {
|
|
539
|
+
this.logDisabled(e, live.version);
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
await this.applyPlatform(updater, live.itemId, e.version);
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* The platform update to the pin, acting as the kernel (actor `null`). The update recomputes its
|
|
547
|
+
* preview under the item's lock; a scope sync the extension step owed may run between the two
|
|
548
|
+
* and change the orgs the preview covers (409 `plugin.upgrade_stale`): previewed again, a few
|
|
549
|
+
* times.
|
|
550
|
+
*/
|
|
551
|
+
async applyPlatform(updater, itemId, version) {
|
|
552
|
+
for (let attempt = 1;; attempt++) {
|
|
553
|
+
const preview = await updater.preview(itemId, version);
|
|
554
|
+
try {
|
|
555
|
+
await updater.update(null, itemId, { version, diffHash: preview.diffHash });
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
catch (err) {
|
|
559
|
+
if (attempt >= 3 || !(err instanceof ApiError) || err.code !== "plugin.upgrade_stale") {
|
|
560
|
+
throw err;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
logDisabled(e, current) {
|
|
566
|
+
this.log.info("bootstrap: the plugin is disabled on the deployment; the pinned version is imported, not applied", { plugin: e.name, version: e.version, current });
|
|
567
|
+
}
|
|
514
568
|
/**
|
|
515
569
|
* The live (not deleted) platform catalog item of this name: its platform version (the one orgs
|
|
516
570
|
* install, else its latest) and where that version came from. undefined: no such item.
|
|
@@ -545,6 +599,10 @@ let BootstrapService = class BootstrapService {
|
|
|
545
599
|
* builtin is no longer builtin and keeps scope `all` (the admin may change it from then on).
|
|
546
600
|
* Only the platform item: an org-owned item of the same name (the entry then fails with
|
|
547
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.
|
|
548
606
|
*/
|
|
549
607
|
async markBuiltin(name, builtin) {
|
|
550
608
|
const touch = { updated_at: sql `now()` };
|
|
@@ -564,14 +622,25 @@ let BootstrapService = class BootstrapService {
|
|
|
564
622
|
.execute();
|
|
565
623
|
return;
|
|
566
624
|
}
|
|
567
|
-
await this.db
|
|
625
|
+
const rows = await this.db
|
|
568
626
|
.updateTable("catalog_items")
|
|
569
627
|
.set({ builtin: false, ...touch })
|
|
570
628
|
.where("name", "=", name)
|
|
571
629
|
.where("owner_org_id", "is", null)
|
|
572
630
|
.where("deleted_at", "is", null)
|
|
573
631
|
.where("builtin", "=", true)
|
|
632
|
+
.returning("id")
|
|
574
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);
|
|
575
644
|
}
|
|
576
645
|
/**
|
|
577
646
|
* The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
|
|
@@ -752,7 +821,10 @@ let BootstrapService = class BootstrapService {
|
|
|
752
821
|
audit: { added, removed, sha256 },
|
|
753
822
|
});
|
|
754
823
|
}
|
|
755
|
-
/**
|
|
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
|
+
*/
|
|
756
828
|
async clearRemoved(manifest) {
|
|
757
829
|
const names = manifest.plugins.map((p) => p.name);
|
|
758
830
|
let q = this.db
|
|
@@ -773,7 +845,7 @@ let BootstrapService = class BootstrapService {
|
|
|
773
845
|
.where("deleted_at", "is", null);
|
|
774
846
|
if (names.length > 0)
|
|
775
847
|
items = items.where("name", "not in", names);
|
|
776
|
-
await items.execute();
|
|
848
|
+
await this.demoted((await items.returning("id").execute()).map((r) => r.id));
|
|
777
849
|
return rows.map((r) => ({ name: r.name, action: "required_cleared", version: r.version }));
|
|
778
850
|
}
|
|
779
851
|
};
|
|
@@ -783,9 +855,18 @@ __decorate([
|
|
|
783
855
|
__decorate([
|
|
784
856
|
Transactional()
|
|
785
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);
|
|
786
864
|
__decorate([
|
|
787
865
|
Transactional()
|
|
788
866
|
], BootstrapService.prototype, "approveStored", null);
|
|
867
|
+
__decorate([
|
|
868
|
+
Transactional()
|
|
869
|
+
], BootstrapService.prototype, "clearRemoved", null);
|
|
789
870
|
BootstrapService = __decorate([
|
|
790
871
|
Injectable(),
|
|
791
872
|
__param(0, Inject(KernelDb)),
|
|
@@ -794,11 +875,12 @@ BootstrapService = __decorate([
|
|
|
794
875
|
__param(3, Inject(PluginApproveLock)),
|
|
795
876
|
__param(4, Inject(ExtensionInstalls)),
|
|
796
877
|
__param(5, Inject(ExtensionAdminOps)),
|
|
797
|
-
__param(6, Inject(
|
|
798
|
-
__param(7, Inject(
|
|
799
|
-
__param(8, Inject(
|
|
800
|
-
__param(9,
|
|
801
|
-
__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))
|
|
802
884
|
], BootstrapService);
|
|
803
885
|
export { BootstrapService };
|
|
804
886
|
/** A `kept` result whose entry an earlier pass of the same start installed / upgraded / imported. */
|
|
@@ -812,3 +894,8 @@ function carried(r, carry) {
|
|
|
812
894
|
}
|
|
813
895
|
/** `installed` is below `pinned` (a version that is not semver is never upgraded). */
|
|
814
896
|
const isLower = (installed, pinned) => semver.valid(installed) !== null && semver.valid(pinned) !== null && semver.lt(installed, pinned);
|
|
897
|
+
/**
|
|
898
|
+
* A platform version the bootstrap raises to the pin: one the bootstrap put there, below the pin
|
|
899
|
+
* (one the super admin moved to, from another source or at a higher version, stays).
|
|
900
|
+
*/
|
|
901
|
+
const raisable = (live, pinned) => live.source === "bootstrap" && isLower(live.version, pinned);
|
|
@@ -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
|