@capybara-hq/kernel 0.1.0-rc.73 → 0.1.0-rc.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +5 -5
- package/dist/catalog/admin-catalog.schemas.d.ts +3 -1
- package/dist/catalog/admin-catalog.schemas.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.schemas.d.ts +3 -1
- package/dist/catalog/org-catalog.schemas.js +3 -1
- package/dist/catalog/plugin-package.js +7 -5
- package/dist/catalog/reserved-names.js +3 -9
- package/dist/channels/actions.js +4 -0
- package/dist/channels/cards.d.ts +10 -7
- package/dist/channels/cards.js +23 -12
- package/dist/channels/phrases.d.ts +24 -2
- package/dist/channels/phrases.js +12 -2
- package/dist/ctx/secrets.d.ts +4 -2
- package/dist/ctx/secrets.js +19 -5
- package/dist/db/kernel-schema.d.ts +14 -0
- package/dist/devices/conversation-devices.d.ts +3 -2
- package/dist/devices/conversation-devices.js +9 -4
- package/dist/devices/device-projects.service.d.ts +22 -27
- package/dist/devices/device-projects.service.js +36 -41
- package/dist/devices/devices.controller.d.ts +3 -5
- package/dist/devices/devices.controller.js +4 -17
- package/dist/devices/devices.schemas.d.ts +1 -1
- package/dist/devices/devices.schemas.js +1 -1
- package/dist/devices/devices.service.d.ts +72 -52
- package/dist/devices/devices.service.js +158 -93
- package/dist/devices/project-rules.d.ts +6 -8
- package/dist/devices/project-rules.js +5 -11
- package/dist/dial-in/auth.service.js +1 -1
- package/dist/dial-in/machines.d.ts +5 -4
- package/dist/dial-in/machines.js +5 -4
- package/dist/errors.d.ts +8 -3
- package/dist/errors.js +8 -3
- package/dist/extensions/admin-ops.js +2 -1
- package/dist/extensions/bootstrap-extra.d.ts +11 -1
- package/dist/extensions/bootstrap-extra.js +21 -1
- package/dist/extensions/bootstrap-manifest.d.ts +14 -0
- package/dist/extensions/bootstrap-manifest.js +23 -0
- package/dist/extensions/bootstrap-packages.d.ts +87 -0
- package/dist/extensions/bootstrap-packages.js +263 -0
- package/dist/extensions/bootstrap.d.ts +27 -71
- package/dist/extensions/bootstrap.js +85 -329
- package/dist/extensions/guide-places.d.ts +9 -0
- package/dist/extensions/guide-places.js +32 -22
- package/dist/extensions/plugin-guides.d.ts +20 -2
- package/dist/extensions/plugin-guides.js +39 -14
- package/dist/identity/sso-paths.d.ts +7 -0
- package/dist/identity/sso-paths.js +13 -0
- package/dist/identity/sso.js +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +2 -2
- package/dist/platform/exclusions.js +2 -7
- package/dist/platform/ops/devices.ops.js +11 -7
- package/dist/platform/ops/setup.ops.js +1 -1
- package/dist/runtime/project/knowledge.service.js +6 -5
- package/dist/sandbox/device-sandbox.d.ts +11 -0
- package/dist/sandbox/device-sandbox.js +29 -0
- package/dist/sandbox/modes.d.ts +16 -4
- package/dist/sandbox/modes.js +12 -0
- package/dist/sandbox/permission-facts.d.ts +12 -2
- package/dist/sandbox/permission-facts.js +14 -4
- package/dist/sandbox/sandbox.service.d.ts +18 -11
- package/dist/sandbox/sandbox.service.js +51 -24
- package/dist/setup/setup-guides.service.d.ts +2 -2
- package/dist/setup/setup-guides.service.js +1 -1
- package/dist/tools/approvals.service.d.ts +31 -11
- package/dist/tools/approvals.service.js +55 -19
- package/dist/tools/builtins/sandbox/common.d.ts +2 -2
- package/dist/tools/builtins/sandbox/common.js +2 -2
- package/dist/tools/network-asks.d.ts +103 -20
- package/dist/tools/network-asks.js +133 -18
- package/dist/tools/pipeline.d.ts +5 -0
- package/dist/tools/pipeline.js +15 -8
- package/package.json +3 -3
- package/src/migrations/0178_bootstrap_run_extra.sql +17 -0
package/dist/errors.js
CHANGED
|
@@ -455,6 +455,11 @@ export const ERROR_CODES = {
|
|
|
455
455
|
* message lists the providers on in the org.
|
|
456
456
|
*/
|
|
457
457
|
"device.provider_required": 400,
|
|
458
|
+
/**
|
|
459
|
+
* A new device is created on a dial-in provider (or the default is one): its devices are made
|
|
460
|
+
* by the machine signing in, following the provider's guide in the new-device dialog.
|
|
461
|
+
*/
|
|
462
|
+
"device.provider_dial_in": 409,
|
|
458
463
|
/** The person already has a live device with this name (case-insensitive). */
|
|
459
464
|
"device.name_taken": 409,
|
|
460
465
|
/** The person already has `devices.maxPersonal` live personal devices. */
|
|
@@ -505,8 +510,8 @@ export const ERROR_CODES = {
|
|
|
505
510
|
/** The device has no project with this name. */
|
|
506
511
|
"device.project_not_found": 404,
|
|
507
512
|
/**
|
|
508
|
-
* The project's path is outside what the device
|
|
509
|
-
*
|
|
513
|
+
* The project's path is outside what the device lets a project reach: its browse scope refused
|
|
514
|
+
* it (no reason given), or the resolved path is not one a device can hold.
|
|
510
515
|
*/
|
|
511
516
|
"device.project_outside_mode": 422,
|
|
512
517
|
/**
|
|
@@ -516,7 +521,7 @@ export const ERROR_CODES = {
|
|
|
516
521
|
"device.project_path_too_broad": 422,
|
|
517
522
|
/** The project's directory does not exist on the device. */
|
|
518
523
|
"device.project_path_missing": 422,
|
|
519
|
-
/** The project's path is a file
|
|
524
|
+
/** The project's path is a file or a directory the device cannot read. */
|
|
520
525
|
"device.project_path_unreadable": 422,
|
|
521
526
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
522
527
|
"device.project_refused": 422,
|
|
@@ -11,6 +11,7 @@ import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import semver from "semver";
|
|
14
|
+
import { itemRemovedError } from "../catalog/ownership.js";
|
|
14
15
|
import { oweDeployedExtensionSync } from "../catalog/scope-jobs.js";
|
|
15
16
|
import { pluginSchemaName } from "../ctx/create-ctx.js";
|
|
16
17
|
import { ApiError } from "../errors.js";
|
|
@@ -180,7 +181,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
180
181
|
.executeTakeFirst();
|
|
181
182
|
// The lock waits out a removal holding the row; the row read then is the removed one
|
|
182
183
|
if (opts.liveItem && (item === undefined || item.deleted_at !== null)) {
|
|
183
|
-
throw
|
|
184
|
+
throw itemRemovedError(name);
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
const row = await this.lockRow(name);
|
|
@@ -18,7 +18,9 @@ export type MergedBootstrapManifest = Omit<BootstrapManifest, "plugins"> & {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* What an extra manifest left in the deployment: the config-managed marketplaces and the entries
|
|
21
|
-
*
|
|
21
|
+
* an extra manifest contributed to the latest bootstrap run: the run that started writing and has
|
|
22
|
+
* not completed (`bootstrap_run_started`, ruling R19) when there is one, else the last completed
|
|
23
|
+
* run (flagged `extra` in its results, R17).
|
|
22
24
|
* A process without an extra manifest that finds any is configured differently from the ones that
|
|
23
25
|
* wrote them ({@link missingExtraManifestMessage}).
|
|
24
26
|
*/
|
|
@@ -40,6 +42,14 @@ export type LoadedBootstrapManifest = MergedBootstrapManifest;
|
|
|
40
42
|
export declare function readBootstrapExtraManifest(file: string): Promise<BootstrapExtraManifest>;
|
|
41
43
|
/** Built-in entries first, then the extra ones; a name in both is `bootstrap.extra_conflict`. */
|
|
42
44
|
export declare function mergeBootstrapManifests(builtin: BootstrapManifest, extra: BootstrapExtraManifest | undefined): MergedBootstrapManifest;
|
|
45
|
+
/**
|
|
46
|
+
* sha256 (hex) of the extra manifest's part of a merged manifest: its entries (as merged), its
|
|
47
|
+
* marketplaces and its default theme; null without an extra manifest. A recorded run counts as done
|
|
48
|
+
* only while the latest completed run has the same extra part (ruling R18), so a distribution
|
|
49
|
+
* removed (an empty extra manifest) and added back runs again, while a replica on another
|
|
50
|
+
* built-in manifest with the same extra manifest (a rolling upgrade) does not.
|
|
51
|
+
*/
|
|
52
|
+
export declare function bootstrapExtraSha256(manifest: MergedBootstrapManifest): string | null;
|
|
43
53
|
/** Loads the built-in manifest (a given one, else the file) and merges the extra file into it. */
|
|
44
54
|
export declare function loadBootstrapManifest(o: {
|
|
45
55
|
manifestFile?: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { readFile } from "node:fs/promises";
|
|
2
3
|
import { parseBootstrapExtraManifest, } from "@capybara-hq/plugin-sdk";
|
|
3
4
|
import { marketplaceForm } from "../catalog/marketplaces.service.js";
|
|
4
5
|
import { ApiError } from "../errors.js";
|
|
5
|
-
import { BOOTSTRAP_MANIFEST_FILE,
|
|
6
|
+
import { BOOTSTRAP_MANIFEST_FILE, readBootstrapManifest } from "./bootstrap-manifest.js";
|
|
7
|
+
const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
6
8
|
/** Whether `t` names anything: then a process without an extra manifest must not sync or run. */
|
|
7
9
|
export const hasExtraManifestTraces = (t) => t.marketplaces.length > 0 || t.plugins.length > 0;
|
|
8
10
|
/** Reads and parses an extra manifest; every problem (also a missing file) is `bootstrap.extra_invalid`. */
|
|
@@ -57,6 +59,24 @@ export function mergeBootstrapManifests(builtin, extra) {
|
|
|
57
59
|
},
|
|
58
60
|
};
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* sha256 (hex) of the extra manifest's part of a merged manifest: its entries (as merged), its
|
|
64
|
+
* marketplaces and its default theme; null without an extra manifest. A recorded run counts as done
|
|
65
|
+
* only while the latest completed run has the same extra part (ruling R18), so a distribution
|
|
66
|
+
* removed (an empty extra manifest) and added back runs again, while a replica on another
|
|
67
|
+
* built-in manifest with the same extra manifest (a rolling upgrade) does not.
|
|
68
|
+
*/
|
|
69
|
+
export function bootstrapExtraSha256(manifest) {
|
|
70
|
+
if (manifest.extra === undefined)
|
|
71
|
+
return null;
|
|
72
|
+
const names = new Set(manifest.extra.plugins);
|
|
73
|
+
const part = {
|
|
74
|
+
plugins: manifest.plugins.filter((p) => names.has(p.name)),
|
|
75
|
+
marketplaces: manifest.extra.marketplaces,
|
|
76
|
+
...(manifest.extra.defaultTheme !== undefined && { defaultTheme: manifest.extra.defaultTheme }),
|
|
77
|
+
};
|
|
78
|
+
return createHash("sha256").update(JSON.stringify(part)).digest("hex");
|
|
79
|
+
}
|
|
60
80
|
/** Loads the built-in manifest (a given one, else the file) and merges the extra file into it. */
|
|
61
81
|
export async function loadBootstrapManifest(o) {
|
|
62
82
|
const builtin = o.builtin ?? (await readBootstrapManifest(o.manifestFile ?? BOOTSTRAP_MANIFEST_FILE));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BootstrapManifest } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* The built-in bootstrap manifest: where it ships, how it is read and its run identity (spec
|
|
4
|
+
* 2026-11-20-bootstrap-extra-manifest §3). Shared by the kernel start and `capybara bootstrap`;
|
|
5
|
+
* merging an extra manifest into it is `bootstrap-extra.ts`.
|
|
6
|
+
*/
|
|
7
|
+
/** The bootstrap manifest that ships with the kernel package. */
|
|
8
|
+
export declare const BOOTSTRAP_MANIFEST_FILE: string;
|
|
9
|
+
/** sha256 (hex) of a manifest: of its JSON text as parsed (key order kept). */
|
|
10
|
+
export declare function bootstrapManifestSha256(manifest: Omit<BootstrapManifest, "plugins"> & {
|
|
11
|
+
plugins: readonly object[];
|
|
12
|
+
}): string;
|
|
13
|
+
/** Reads and parses a bootstrap manifest file; an invalid one throws with its problems. */
|
|
14
|
+
export declare function readBootstrapManifest(file?: string): Promise<BootstrapManifest>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { parseBootstrapManifest } from "@capybara-hq/plugin-sdk";
|
|
5
|
+
/**
|
|
6
|
+
* The built-in bootstrap manifest: where it ships, how it is read and its run identity (spec
|
|
7
|
+
* 2026-11-20-bootstrap-extra-manifest §3). Shared by the kernel start and `capybara bootstrap`;
|
|
8
|
+
* merging an extra manifest into it is `bootstrap-extra.ts`.
|
|
9
|
+
*/
|
|
10
|
+
/** The bootstrap manifest that ships with the kernel package. */
|
|
11
|
+
export const BOOTSTRAP_MANIFEST_FILE = fileURLToPath(new URL("../../bootstrap.json", import.meta.url));
|
|
12
|
+
/** sha256 (hex) of a manifest: of its JSON text as parsed (key order kept). */
|
|
13
|
+
export function bootstrapManifestSha256(manifest) {
|
|
14
|
+
return createHash("sha256").update(JSON.stringify(manifest)).digest("hex");
|
|
15
|
+
}
|
|
16
|
+
/** Reads and parses a bootstrap manifest file; an invalid one throws with its problems. */
|
|
17
|
+
export async function readBootstrapManifest(file = BOOTSTRAP_MANIFEST_FILE) {
|
|
18
|
+
const parsed = parseBootstrapManifest(JSON.parse(await readFile(file, "utf8")));
|
|
19
|
+
if ("errors" in parsed) {
|
|
20
|
+
throw new Error(`invalid bootstrap manifest ${file}: ${parsed.errors.join("; ")}`);
|
|
21
|
+
}
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type BootstrapExtraMarketplace, type Logger } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { KernelConfig } from "../config/schema.js";
|
|
3
|
+
import { ApiError } from "../errors.js";
|
|
4
|
+
import { fetchNpmPackage } from "../packages/npm.js";
|
|
5
|
+
import type { BootstrapGitRunEntry, MergedBootstrapEntry, MergedBootstrapManifest } from "./bootstrap-extra.js";
|
|
6
|
+
/**
|
|
7
|
+
* Obtaining the packages of a bootstrap run (spec 2026-11-20-bootstrap-extra-manifest §3, §8): the
|
|
8
|
+
* offline directory, npm and git entries, each verified against its pinned sha512 before anything
|
|
9
|
+
* reads it. Shared by the bootstrap step and `capybara bootstrap`.
|
|
10
|
+
*/
|
|
11
|
+
/** The sha512 integrity (`sha512-<base64>`) of a package's bytes. */
|
|
12
|
+
export declare const integrityOf: (bytes: Uint8Array) => string;
|
|
13
|
+
/** What {@link resolveBootstrapPackages} needs from the kernel config. */
|
|
14
|
+
export interface BootstrapResolveOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The offline directory: every `*.tgz` directly in it is matched to the entries by sha512.
|
|
17
|
+
* Omitted or missing: no offline packages.
|
|
18
|
+
*/
|
|
19
|
+
dir?: string;
|
|
20
|
+
config: Pick<KernelConfig, "packages" | "marketplaces" | "net">;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
log?: Pick<Logger, "warn">;
|
|
23
|
+
/** The npm download (default {@link fetchNpmPackage}; tests replace it). */
|
|
24
|
+
fetch?: typeof fetchNpmPackage;
|
|
25
|
+
/**
|
|
26
|
+
* Entries whose package failing to be obtained is that entry's failure only: the error goes into
|
|
27
|
+
* `failed` (by entry name) and the other entries are still obtained. Every other entry's failure
|
|
28
|
+
* throws, so nothing is written.
|
|
29
|
+
*/
|
|
30
|
+
soft?: (e: MergedBootstrapEntry) => boolean;
|
|
31
|
+
failed?: Map<string, ApiError>;
|
|
32
|
+
/**
|
|
33
|
+
* The credential of an extra-manifest marketplace (by name) for its git entries; default: the
|
|
34
|
+
* token `marketplaces.tokens[name]` (never the file or the secrets table) and the manifest's
|
|
35
|
+
* `username`. It is sent only to that marketplace URL's origin.
|
|
36
|
+
*/
|
|
37
|
+
gitCredentials?: (marketplace: string) => {
|
|
38
|
+
token?: string;
|
|
39
|
+
username?: string;
|
|
40
|
+
};
|
|
41
|
+
/** Filled with the git tree oid of each git entry read from git (by entry name). */
|
|
42
|
+
gitTrees?: Map<string, string>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The marketplace a git entry names, its URL expanded as the managed row's (`config:<name>`) is and
|
|
46
|
+
* checked as an admin-added one is (`bootstrap.extra_invalid` otherwise).
|
|
47
|
+
*/
|
|
48
|
+
export declare function bootstrapGitMarketplace(manifest: Pick<MergedBootstrapManifest, "extra">, e: BootstrapGitRunEntry, config: Pick<KernelConfig, "marketplaces">): BootstrapExtraMarketplace;
|
|
49
|
+
/**
|
|
50
|
+
* Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
|
|
51
|
+
* file there has that sha512, else (a `source: "npm"` entry) downloaded from the npm registry and
|
|
52
|
+
* verified against the pin (the packument's `dist.integrity` is not consulted), else (a
|
|
53
|
+
* `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
|
|
54
|
+
* re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
|
|
55
|
+
* pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
|
|
56
|
+
* marketplace's token and username go only to its URL's origin. Throws an {@link ApiError} naming
|
|
57
|
+
* the plugin for the first entry it cannot obtain (`bootstrap.missing_file`,
|
|
58
|
+
* `bootstrap.download_failed`, `bootstrap.git_read_failed`, `bootstrap.integrity_mismatch`), except
|
|
59
|
+
* for the `soft` entries (recorded in `failed`, left out of the result).
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveBootstrapPackages(manifest: MergedBootstrapManifest, o: BootstrapResolveOptions): Promise<Map<string, Uint8Array>>;
|
|
62
|
+
/** What a git entry's tree is, as the bootstrap import reads it ({@link readBootstrapGitPlugin}). */
|
|
63
|
+
export interface BootstrapGitPlugin {
|
|
64
|
+
/** `capybara`: `.capybara-plugin/plugin.json`; `claude`: a Claude Code plugin; `skills`: skills only. */
|
|
65
|
+
kind: "capybara" | "claude" | "skills";
|
|
66
|
+
name: string;
|
|
67
|
+
version: string;
|
|
68
|
+
/** The plugin has an extension (only a `capybara` tree can). */
|
|
69
|
+
extension: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Name, version and kind of a git entry's tree, as the bootstrap import identifies it (spec
|
|
73
|
+
* 2026-11-20-bootstrap-extra-manifest §9, "As built" R20): a tree with `.capybara-plugin/plugin.json`
|
|
74
|
+
* by that file (the import's manifest parser); a Claude Code plugin (`.claude-plugin/plugin.json`,
|
|
75
|
+
* or its other markers) by the import's translation with the entry as fallback, so its version is
|
|
76
|
+
* the Claude manifest's, else the entry's; a skills-only tree named and versioned by the entry. The
|
|
77
|
+
* kernel's bootstrap step and `capybara-plugin bootstrap --write` both call it, so the version a pin
|
|
78
|
+
* records is the one the import checks. Only the identity is read here: the import still checks the
|
|
79
|
+
* whole tree. An unreadable identity throws `PluginPackageError` (`catalog.invalid_manifest`).
|
|
80
|
+
*/
|
|
81
|
+
export declare function readBootstrapGitPlugin(files: ReadonlyMap<string, Uint8Array>, entry: {
|
|
82
|
+
name: string;
|
|
83
|
+
version: string;
|
|
84
|
+
}, o?: {
|
|
85
|
+
publisher?: string;
|
|
86
|
+
allowInsecureLoopback?: boolean;
|
|
87
|
+
}): BootstrapGitPlugin;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { PLUGIN_MANIFEST_FILE, parsePluginManifest, } from "@capybara-hq/plugin-sdk";
|
|
5
|
+
import { isClaudePluginTree, translateClaudePlugin } from "../catalog/claude/translate.js";
|
|
6
|
+
import { GitSourceError, normalGitPath, readGitTreeAndOids } from "../catalog/git-source.js";
|
|
7
|
+
import { marketplaceNetPolicy, marketplaceUrlProblem } from "../catalog/marketplace-fetch.js";
|
|
8
|
+
import { marketplaceForm } from "../catalog/marketplaces.service.js";
|
|
9
|
+
import { PluginPackageError, withoutRemovedManifestFields } from "../catalog/plugin-package.js";
|
|
10
|
+
import { ApiError } from "../errors.js";
|
|
11
|
+
import { fetchNpmPackage, IntegrityMismatchError, NpmFetchError, PackageTooLargeError, } from "../packages/npm.js";
|
|
12
|
+
import { packPackageTgz } from "../packages/tgz.js";
|
|
13
|
+
/**
|
|
14
|
+
* Obtaining the packages of a bootstrap run (spec 2026-11-20-bootstrap-extra-manifest §3, §8): the
|
|
15
|
+
* offline directory, npm and git entries, each verified against its pinned sha512 before anything
|
|
16
|
+
* reads it. Shared by the bootstrap step and `capybara bootstrap`.
|
|
17
|
+
*/
|
|
18
|
+
/** The sha512 integrity (`sha512-<base64>`) of a package's bytes. */
|
|
19
|
+
export const integrityOf = (bytes) => `sha512-${createHash("sha512").update(bytes).digest("base64")}`;
|
|
20
|
+
/**
|
|
21
|
+
* The marketplace a git entry names, its URL expanded as the managed row's (`config:<name>`) is and
|
|
22
|
+
* checked as an admin-added one is (`bootstrap.extra_invalid` otherwise).
|
|
23
|
+
*/
|
|
24
|
+
export function bootstrapGitMarketplace(manifest, e, config) {
|
|
25
|
+
const m = manifest.extra?.marketplaces.find((x) => x.name === e.marketplace);
|
|
26
|
+
const invalid = (why) => new ApiError("bootstrap.extra_invalid", `Bootstrap plugin ${e.name} ${e.version}: marketplace ${e.marketplace} ${why}`);
|
|
27
|
+
if (m === undefined)
|
|
28
|
+
throw invalid("is not declared in the extra bootstrap manifest");
|
|
29
|
+
const { form, url } = marketplaceForm(m.url);
|
|
30
|
+
if (form !== "git")
|
|
31
|
+
throw invalid("is not a git repository");
|
|
32
|
+
const problem = marketplaceUrlProblem(url, config.marketplaces.allowInsecureLoopback);
|
|
33
|
+
if (problem !== null)
|
|
34
|
+
throw invalid(`has an unusable url: ${problem}`);
|
|
35
|
+
return { ...m, url };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
|
|
39
|
+
* 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), else (a
|
|
41
|
+
* `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
|
|
42
|
+
* re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
|
|
43
|
+
* pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
|
|
44
|
+
* marketplace's token and username go only to its URL's origin. Throws an {@link ApiError} naming
|
|
45
|
+
* the plugin for the first entry it cannot obtain (`bootstrap.missing_file`,
|
|
46
|
+
* `bootstrap.download_failed`, `bootstrap.git_read_failed`, `bootstrap.integrity_mismatch`), except
|
|
47
|
+
* for the `soft` entries (recorded in `failed`, left out of the result).
|
|
48
|
+
*/
|
|
49
|
+
export async function resolveBootstrapPackages(manifest, o) {
|
|
50
|
+
const out = new Map();
|
|
51
|
+
if (manifest.plugins.length === 0)
|
|
52
|
+
return out;
|
|
53
|
+
const { npmRegistry, npmToken, maxBytes } = o.config.packages;
|
|
54
|
+
const offline = o.dir !== undefined ? await scanOfflineDir(o.dir, maxBytes, o.log) : new Map();
|
|
55
|
+
const fetchPackage = o.fetch ?? fetchNpmPackage;
|
|
56
|
+
const signal = o.signal ?? new AbortController().signal;
|
|
57
|
+
const where = o.dir !== undefined ? o.dir : "the bootstrap directory (config bootstrap.dir)";
|
|
58
|
+
for (const e of manifest.plugins) {
|
|
59
|
+
signal.throwIfAborted();
|
|
60
|
+
try {
|
|
61
|
+
out.set(e.name, await obtain(e));
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (signal.aborted || !(err instanceof ApiError) || o.soft?.(e) !== true)
|
|
65
|
+
throw err;
|
|
66
|
+
o.failed?.set(e.name, err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
async function obtain(e) {
|
|
71
|
+
const found = offline.get(e.integrity);
|
|
72
|
+
if (found !== undefined)
|
|
73
|
+
return found;
|
|
74
|
+
if (e.source === "git")
|
|
75
|
+
return obtainGit(e);
|
|
76
|
+
if (e.source === "workspace") {
|
|
77
|
+
throw new ApiError("bootstrap.missing_file", `Bootstrap plugin ${e.name} ${e.version}: no file in ${where} has its pinned sha512 (${e.integrity.slice(0, 19)}…), and a workspace entry cannot be downloaded; put its package tgz (pnpm pack-plugin ${e.path}) in that directory`);
|
|
78
|
+
}
|
|
79
|
+
const registry = registryOrigin(npmRegistry);
|
|
80
|
+
const offlineHint = `to install offline, put the package tgz (npm pack ${e.npm}@${e.version}, any file name) in ${where}`;
|
|
81
|
+
try {
|
|
82
|
+
const r = await fetchPackage({
|
|
83
|
+
registry: npmRegistry,
|
|
84
|
+
...(npmToken !== undefined && { token: npmToken }),
|
|
85
|
+
maxBytes,
|
|
86
|
+
net: marketplaceNetPolicy(o.config),
|
|
87
|
+
}, e.npm, e.version, signal, { expectedIntegrity: e.integrity });
|
|
88
|
+
return r.bytes;
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
if (signal.aborted)
|
|
92
|
+
throw err;
|
|
93
|
+
if (err instanceof IntegrityMismatchError) {
|
|
94
|
+
throw new ApiError("bootstrap.integrity_mismatch", `Bootstrap plugin ${e.name} ${e.version}: the package ${e.npm}@${e.version} downloaded from ${registry} does not match its pinned sha512 (expected ${e.integrity.slice(0, 19)}…, got ${err.actual.slice(0, 19)}…); refusing to install anything`);
|
|
95
|
+
}
|
|
96
|
+
const reason = err instanceof NpmFetchError || err instanceof PackageTooLargeError
|
|
97
|
+
? err.message
|
|
98
|
+
: err instanceof Error
|
|
99
|
+
? err.message
|
|
100
|
+
: 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`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function obtainGit(e) {
|
|
105
|
+
const m = bootstrapGitMarketplace(manifest, e, o.config);
|
|
106
|
+
const u = new URL(m.url);
|
|
107
|
+
const at = `${e.path} at ${e.commit.slice(0, 12)} of marketplace ${m.name} (${u.origin}${u.pathname})`;
|
|
108
|
+
const cred = (o.gitCredentials ?? defaultGitCredentials)(m.name);
|
|
109
|
+
const token = cred.token !== undefined && cred.token !== "" ? cred.token : undefined;
|
|
110
|
+
const dir = normalGitPath(e.path);
|
|
111
|
+
let read;
|
|
112
|
+
try {
|
|
113
|
+
read = await readGitTreeAndOids({ url: m.url, commit: e.commit, path: e.path }, {
|
|
114
|
+
net: marketplaceNetPolicy(o.config),
|
|
115
|
+
maxBytes,
|
|
116
|
+
signal,
|
|
117
|
+
...(token !== undefined && {
|
|
118
|
+
token,
|
|
119
|
+
tokenOrigin: u.origin,
|
|
120
|
+
...(cred.username !== undefined && cred.username !== "" && { username: cred.username }),
|
|
121
|
+
}),
|
|
122
|
+
trees: () => [dir],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (signal.aborted)
|
|
127
|
+
throw err;
|
|
128
|
+
// git-source messages never carry the token; redacted all the same, it is a credential
|
|
129
|
+
const reason = errMsg(err);
|
|
130
|
+
const redacted = token !== undefined ? reason.replaceAll(token, "***") : reason;
|
|
131
|
+
// A bootstrap entry pins a commit by its sha: a ref tip is not what it can change to
|
|
132
|
+
const message = err instanceof GitSourceError && err.refusedCommit !== undefined
|
|
133
|
+
? `the host refused to send commit ${err.refusedCommit} by its sha. The commit must be fetchable by its sha (GitHub: always; GitLab, Gitea and other hosts: only when fetching unadvertised commits is allowed, e.g. git's uploadpack.allowReachableSHA1InWant or the host's equivalent), or pin the commit of a tag and keep the tag, or put its pack (capybara-plugin bootstrap --write --out <dir>) in the offline directory, ${where}`
|
|
134
|
+
: `${redacted}; to install offline, put its pack (capybara-plugin bootstrap --write) in ${where}`;
|
|
135
|
+
throw new ApiError("bootstrap.git_read_failed", `Bootstrap plugin ${e.name} ${e.version}: cannot read ${at}: ${message}`);
|
|
136
|
+
}
|
|
137
|
+
const pack = await packPackageTgz(read.files);
|
|
138
|
+
const actual = integrityOf(pack);
|
|
139
|
+
if (actual !== e.integrity) {
|
|
140
|
+
throw new ApiError("bootstrap.integrity_mismatch", `Bootstrap plugin ${e.name} ${e.version}: ${at} packs to another sha512 than its pin (expected ${e.integrity.slice(0, 19)}…, got ${actual.slice(0, 19)}…); refusing to install anything`);
|
|
141
|
+
}
|
|
142
|
+
const tree = read.trees.get(dir);
|
|
143
|
+
if (tree !== undefined)
|
|
144
|
+
o.gitTrees?.set(e.name, tree);
|
|
145
|
+
return pack;
|
|
146
|
+
}
|
|
147
|
+
function defaultGitCredentials(name) {
|
|
148
|
+
const tokens = o.config.marketplaces.tokens;
|
|
149
|
+
const username = manifest.extra?.marketplaces.find((x) => x.name === name)?.username;
|
|
150
|
+
return {
|
|
151
|
+
...(Object.hasOwn(tokens, name) && { token: tokens[name] }),
|
|
152
|
+
...(username !== undefined && { username }),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
157
|
+
/** The registry's origin, for messages (never its credentials or path). */
|
|
158
|
+
function registryOrigin(registry) {
|
|
159
|
+
try {
|
|
160
|
+
return new URL(registry).origin;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return "the configured npm registry";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The `*.tgz` files directly in `dir` by their sha512 integrity. A missing directory is an empty
|
|
168
|
+
* one; a file larger than `maxBytes` is skipped with a warning.
|
|
169
|
+
*/
|
|
170
|
+
async function scanOfflineDir(dir, maxBytes, log) {
|
|
171
|
+
const out = new Map();
|
|
172
|
+
let names;
|
|
173
|
+
try {
|
|
174
|
+
names = await readdir(dir);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
const code = err.code;
|
|
178
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
179
|
+
return out;
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
for (const name of names.sort()) {
|
|
183
|
+
if (!name.endsWith(".tgz"))
|
|
184
|
+
continue;
|
|
185
|
+
const file = join(dir, name);
|
|
186
|
+
const st = await stat(file).catch(() => undefined);
|
|
187
|
+
if (!st?.isFile())
|
|
188
|
+
continue;
|
|
189
|
+
if (st.size > maxBytes) {
|
|
190
|
+
log?.warn("bootstrap: a file in the bootstrap directory exceeds packages.maxBytes; skipped", {
|
|
191
|
+
file,
|
|
192
|
+
size: st.size,
|
|
193
|
+
maxBytes,
|
|
194
|
+
});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const bytes = new Uint8Array(await readFile(file));
|
|
198
|
+
const integrity = integrityOf(bytes);
|
|
199
|
+
if (!out.has(integrity))
|
|
200
|
+
out.set(integrity, bytes);
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Name, version and kind of a git entry's tree, as the bootstrap import identifies it (spec
|
|
206
|
+
* 2026-11-20-bootstrap-extra-manifest §9, "As built" R20): a tree with `.capybara-plugin/plugin.json`
|
|
207
|
+
* by that file (the import's manifest parser); a Claude Code plugin (`.claude-plugin/plugin.json`,
|
|
208
|
+
* or its other markers) by the import's translation with the entry as fallback, so its version is
|
|
209
|
+
* the Claude manifest's, else the entry's; a skills-only tree named and versioned by the entry. The
|
|
210
|
+
* kernel's bootstrap step and `capybara-plugin bootstrap --write` both call it, so the version a pin
|
|
211
|
+
* records is the one the import checks. Only the identity is read here: the import still checks the
|
|
212
|
+
* whole tree. An unreadable identity throws `PluginPackageError` (`catalog.invalid_manifest`).
|
|
213
|
+
*/
|
|
214
|
+
export function readBootstrapGitPlugin(files, entry, o = {}) {
|
|
215
|
+
const own = files.get(PLUGIN_MANIFEST_FILE);
|
|
216
|
+
if (own !== undefined) {
|
|
217
|
+
const m = manifestOf(own, PLUGIN_MANIFEST_FILE);
|
|
218
|
+
return {
|
|
219
|
+
kind: "capybara",
|
|
220
|
+
name: m.name,
|
|
221
|
+
version: m.version,
|
|
222
|
+
extension: m.extension !== undefined,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
if (isClaudePluginTree(files)) {
|
|
226
|
+
const t = translateClaudePlugin(files, {
|
|
227
|
+
fallbackName: entry.name,
|
|
228
|
+
fallbackVersion: entry.version,
|
|
229
|
+
fallbackPublisher: o.publisher ?? entry.name,
|
|
230
|
+
entryVersion: entry.version,
|
|
231
|
+
...(o.allowInsecureLoopback !== undefined && {
|
|
232
|
+
allowInsecureLoopback: o.allowInsecureLoopback,
|
|
233
|
+
}),
|
|
234
|
+
});
|
|
235
|
+
const m = manifestOf(t.tree.get(PLUGIN_MANIFEST_FILE), `${PLUGIN_MANIFEST_FILE} (translated)`);
|
|
236
|
+
return { kind: "claude", name: m.name, version: m.version, extension: false };
|
|
237
|
+
}
|
|
238
|
+
if (![...files.keys()].some((p) => p.startsWith("skills/"))) {
|
|
239
|
+
throw new PluginPackageError("catalog.invalid_manifest", [
|
|
240
|
+
`${PLUGIN_MANIFEST_FILE} not found, and the tree is neither a Claude Code plugin nor a skills-only plugin (no skills/ directory)`,
|
|
241
|
+
]);
|
|
242
|
+
}
|
|
243
|
+
return { kind: "skills", name: entry.name, version: entry.version, extension: false };
|
|
244
|
+
}
|
|
245
|
+
/** A plugin manifest's bytes parsed as the import parses them. */
|
|
246
|
+
function manifestOf(bytes, where) {
|
|
247
|
+
let text;
|
|
248
|
+
try {
|
|
249
|
+
text =
|
|
250
|
+
bytes !== undefined ? new TextDecoder("utf-8", { fatal: true }).decode(bytes) : undefined;
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
text = undefined;
|
|
254
|
+
}
|
|
255
|
+
if (text === undefined) {
|
|
256
|
+
throw new PluginPackageError("catalog.invalid_manifest", [`${where} is not valid UTF-8 text`]);
|
|
257
|
+
}
|
|
258
|
+
const parsed = parsePluginManifest(withoutRemovedManifestFields(text));
|
|
259
|
+
if ("errors" in parsed) {
|
|
260
|
+
throw new PluginPackageError("catalog.invalid_manifest", parsed.errors.map((e) => `${where}: ${e}`));
|
|
261
|
+
}
|
|
262
|
+
return parsed;
|
|
263
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { type BootstrapExtraMarketplace, type BootstrapManifest, type Logger } from "@capybara-hq/plugin-sdk";
|
|
2
1
|
import { type PluginImport } from "../catalog/plugin-import.js";
|
|
3
|
-
import type { KernelConfig } from "../config/schema.js";
|
|
4
|
-
import { ApiError } from "../errors.js";
|
|
5
2
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
6
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
7
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
8
5
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
9
6
|
import type { KernelLogger } from "../log.js";
|
|
10
|
-
import { fetchNpmPackage } from "../packages/npm.js";
|
|
11
7
|
import { ExtensionAdminOps } from "./admin-ops.js";
|
|
12
|
-
import { type
|
|
8
|
+
import { type ExtraManifestTraces, type MergedBootstrapManifest } from "./bootstrap-extra.js";
|
|
13
9
|
import { ExtensionInstalls } from "./installs.js";
|
|
14
10
|
import { PluginApproveLock } from "./locks.js";
|
|
15
11
|
import { ExtensionRegistry } from "./registry.js";
|
|
@@ -39,7 +35,14 @@ import type { SingleProviderNote } from "./single-provider.js";
|
|
|
39
35
|
* together only one runs it; the others wait, then find it done. A lost lock (renewal failed
|
|
40
36
|
* until expiry) aborts the run at its next step. "Done" is a `bootstrap_runs` row for the
|
|
41
37
|
* manifest's sha256 (written with the audit `bootstrap.completed` only when every entry
|
|
42
|
-
* succeeded; otherwise the next start runs it again, which is idempotent)
|
|
38
|
+
* succeeded; otherwise the next start runs it again, which is idempotent) while the latest
|
|
39
|
+
* completed run has the same extra-manifest part ({@link bootstrapExtraSha256}, ruling R18): an
|
|
40
|
+
* extra manifest removed and added back runs again; another built-in manifest with the same
|
|
41
|
+
* extra part (a replica of the previous release) does not.
|
|
42
|
+
* - Before its first write a run records itself as started (`bootstrap_run_started`, with the
|
|
43
|
+
* names of its extra entries; ruling R19) and completing deletes the row, so the extra-manifest
|
|
44
|
+
* mismatch check ({@link BootstrapService.extraManifestTraces}) sees an extra manifest's entries
|
|
45
|
+
* from the first pass on, also while the run is not recorded done.
|
|
43
46
|
* - Two passes per start: the first runs before the extensions load (no object store yet), the
|
|
44
47
|
* second after them. A `builtin` entry (not required, but builtin in the catalog) is deferred by
|
|
45
48
|
* the first pass (`deferBuiltin`: skipped, not a failure; the run is then not recorded and the
|
|
@@ -87,8 +90,6 @@ import type { SingleProviderNote } from "./single-provider.js";
|
|
|
87
90
|
* loaded, and a plugin that must be builtin and ships them is a `builtin` entry, which only the
|
|
88
91
|
* pass after the extensions load imports).
|
|
89
92
|
*/
|
|
90
|
-
/** The bootstrap manifest that ships with the kernel package. */
|
|
91
|
-
export declare const BOOTSTRAP_MANIFEST_FILE: string;
|
|
92
93
|
/** What the bootstrap step did with one entry (or one install record that left the manifest). */
|
|
93
94
|
export interface BootstrapEntryResult {
|
|
94
95
|
name: string;
|
|
@@ -139,63 +140,6 @@ export declare class BootstrapFailedError extends Error {
|
|
|
139
140
|
/** A required entry failed: the kernel must not serve without it. */
|
|
140
141
|
get requiredFailed(): boolean;
|
|
141
142
|
}
|
|
142
|
-
/** sha256 (hex) of a manifest: of its JSON text as parsed (key order kept). */
|
|
143
|
-
export declare function bootstrapManifestSha256(manifest: Omit<BootstrapManifest, "plugins"> & {
|
|
144
|
-
plugins: readonly object[];
|
|
145
|
-
}): string;
|
|
146
|
-
/** Reads and parses a bootstrap manifest file; an invalid one throws with its problems. */
|
|
147
|
-
export declare function readBootstrapManifest(file?: string): Promise<BootstrapManifest>;
|
|
148
|
-
/** What {@link resolveBootstrapPackages} needs from the kernel config. */
|
|
149
|
-
export interface BootstrapResolveOptions {
|
|
150
|
-
/**
|
|
151
|
-
* The offline directory: every `*.tgz` directly in it is matched to the entries by sha512.
|
|
152
|
-
* Omitted or missing: no offline packages.
|
|
153
|
-
*/
|
|
154
|
-
dir?: string;
|
|
155
|
-
config: Pick<KernelConfig, "packages" | "marketplaces" | "net">;
|
|
156
|
-
signal?: AbortSignal;
|
|
157
|
-
log?: Pick<Logger, "warn">;
|
|
158
|
-
/** The npm download (default {@link fetchNpmPackage}; tests replace it). */
|
|
159
|
-
fetch?: typeof fetchNpmPackage;
|
|
160
|
-
/**
|
|
161
|
-
* Entries whose package failing to be obtained is that entry's failure only: the error goes into
|
|
162
|
-
* `failed` (by entry name) and the other entries are still obtained. Every other entry's failure
|
|
163
|
-
* throws, so nothing is written.
|
|
164
|
-
*/
|
|
165
|
-
soft?: (e: MergedBootstrapEntry) => boolean;
|
|
166
|
-
failed?: Map<string, ApiError>;
|
|
167
|
-
/**
|
|
168
|
-
* The credential of an extra-manifest marketplace (by name) for its git entries; default: the
|
|
169
|
-
* token `marketplaces.tokens[name]` (never the file or the secrets table) and the manifest's
|
|
170
|
-
* `username`. It is sent only to that marketplace URL's origin.
|
|
171
|
-
*/
|
|
172
|
-
gitCredentials?: (marketplace: string) => {
|
|
173
|
-
token?: string;
|
|
174
|
-
username?: string;
|
|
175
|
-
};
|
|
176
|
-
/** Filled with the git tree oid of each git entry read from git (by entry name). */
|
|
177
|
-
gitTrees?: Map<string, string>;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* The marketplace a git entry names, its URL expanded as the managed row's (`config:<name>`) is and
|
|
181
|
-
* checked as an admin-added one is (`bootstrap.extra_invalid` otherwise).
|
|
182
|
-
*/
|
|
183
|
-
export declare function bootstrapGitMarketplace(manifest: Pick<MergedBootstrapManifest, "extra">, e: BootstrapGitRunEntry, config: Pick<KernelConfig, "marketplaces">): BootstrapExtraMarketplace;
|
|
184
|
-
/**
|
|
185
|
-
* Obtains every entry's tgz, checked against its pinned sha512: from the offline directory when a
|
|
186
|
-
* file there has that sha512, else (a `source: "npm"` entry) downloaded from the npm registry and
|
|
187
|
-
* verified against the pin (the packument's `dist.integrity` is not consulted), else (a
|
|
188
|
-
* `source: "git"` entry) its marketplace's tree at the pinned commit, the files under `path`
|
|
189
|
-
* re-rooted and packed with `packPackageTgz` (the pin is defined on that pack), refused unless the
|
|
190
|
-
* pack's sha512 is the pin: nothing of an unverified tree is read, translated or imported. The
|
|
191
|
-
* marketplace's token and username go only to its URL's origin. Throws an {@link ApiError} naming
|
|
192
|
-
* the plugin for the first entry it cannot obtain (`bootstrap.missing_file`,
|
|
193
|
-
* `bootstrap.download_failed`, `bootstrap.git_read_failed`, `bootstrap.integrity_mismatch`), except
|
|
194
|
-
* for the `soft` entries (recorded in `failed`, left out of the result).
|
|
195
|
-
*/
|
|
196
|
-
export declare function resolveBootstrapPackages(manifest: MergedBootstrapManifest, o: BootstrapResolveOptions): Promise<Map<string, Uint8Array>>;
|
|
197
|
-
/** The message of a thrown value. */
|
|
198
|
-
export declare const errMsg: (e: unknown) => string;
|
|
199
143
|
/** The lock around a whole run (`lock:bootstrap`). */
|
|
200
144
|
export declare const BOOTSTRAP_LOCK_KEY = "bootstrap";
|
|
201
145
|
/** Its lifetime without renewal; a run keeps it by renewal, a crashed holder's expires. */
|
|
@@ -232,8 +176,13 @@ export declare class BootstrapService {
|
|
|
232
176
|
lockTtlMs?: number);
|
|
233
177
|
private get db();
|
|
234
178
|
private config;
|
|
235
|
-
/**
|
|
236
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Whether the bootstrap step is done for this manifest: a completed run of its sha256 while the
|
|
181
|
+
* latest completed run has the same extra-manifest part (ruling R18).
|
|
182
|
+
*/
|
|
183
|
+
isDone(manifest: MergedBootstrapManifest): Promise<boolean>;
|
|
184
|
+
/** The recorded result of the manifest's run when it counts as done ({@link isDone}). */
|
|
185
|
+
private recorded;
|
|
237
186
|
/**
|
|
238
187
|
* What an extra manifest left ({@link ExtraManifestTraces}): the config-managed marketplaces
|
|
239
188
|
* (`managed = 'config'`) and the entries the last completed run flagged `extra`. A process
|
|
@@ -279,7 +228,13 @@ export declare class BootstrapService {
|
|
|
279
228
|
* which org holds it (final review M4).
|
|
280
229
|
*/
|
|
281
230
|
private warnIfHeld;
|
|
282
|
-
/** The
|
|
231
|
+
/** The run has started writing: the `bootstrap_run_started` row names its extra entries. */
|
|
232
|
+
private recordStarted;
|
|
233
|
+
/**
|
|
234
|
+
* The `bootstrap_runs` row (again with the current time and results when the manifest ran before:
|
|
235
|
+
* it is then the latest completed run, R18), the `bootstrap.completed` audit and the end of the
|
|
236
|
+
* started run, in one transaction.
|
|
237
|
+
*/
|
|
283
238
|
private recordDone;
|
|
284
239
|
/**
|
|
285
240
|
* Runs `fn` holding `lock:bootstrap`: waits without bound while another replica holds it
|
|
@@ -309,9 +264,10 @@ export declare class BootstrapService {
|
|
|
309
264
|
*/
|
|
310
265
|
private unpackGit;
|
|
311
266
|
/**
|
|
312
|
-
* Name, version and extension of a git entry's tree
|
|
313
|
-
*
|
|
314
|
-
* import's review is checked against
|
|
267
|
+
* Name, version and extension of a git entry's tree ({@link readBootstrapGitPlugin}, which
|
|
268
|
+
* `capybara-plugin bootstrap --write` pins with): its `plugin.json`, a Claude Code plugin's
|
|
269
|
+
* manifest or the entry; its import's review is checked against the entry again
|
|
270
|
+
* ({@link prepareGitEntry}).
|
|
315
271
|
*/
|
|
316
272
|
private gitPlugin;
|
|
317
273
|
/** Stages a git entry from its files as an admin git import would (translation included). */
|