@capybara-hq/kernel 0.1.0-rc.72 → 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.controller.d.ts +1 -1
- package/dist/dial-in/auth.controller.js +1 -1
- package/dist/dial-in/auth.service.d.ts +4 -0
- package/dist/dial-in/auth.service.js +16 -2
- 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/permission-set.d.ts +1 -1
- package/dist/extensions/permission-set.js +1 -1
- 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
|
@@ -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). */
|