@capybara-hq/kernel 0.1.0-rc.75 → 0.1.0-rc.77
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/agents/readiness.controller.d.ts +4 -3
- package/dist/agents/readiness.controller.js +4 -3
- package/dist/agents/readiness.service.d.ts +44 -11
- package/dist/agents/readiness.service.js +59 -16
- package/dist/catalog/catalog-import.module.d.ts +1 -1
- package/dist/catalog/catalog-import.module.js +1 -1
- package/dist/catalog/cli.d.ts +9 -2
- package/dist/catalog/cli.js +10 -4
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-upgrade.d.ts +4 -2
- package/dist/catalog/plugin-upgrade.js +9 -3
- package/dist/db/kernel-schema.d.ts +5 -0
- package/dist/devices/device-projects.service.d.ts +3 -12
- package/dist/devices/device-projects.service.js +16 -59
- package/dist/extensions/bootstrap.d.ts +34 -3
- package/dist/extensions/bootstrap.js +111 -14
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +16 -11
- package/dist/overrides.d.ts +0 -5
- package/dist/overrides.js +0 -2
- package/dist/platform/file-ref.d.ts +6 -5
- package/dist/platform/ops/agent-skills.ops.js +1 -1
- package/dist/platform/ops/agents.ops.js +1 -1
- package/dist/runtime/model-call.d.ts +2 -2
- package/dist/runtime/project/knowledge.d.ts +1 -1
- package/dist/runtime/project/knowledge.js +1 -1
- package/dist/runtime/project/knowledge.service.d.ts +5 -11
- package/dist/runtime/project/knowledge.service.js +12 -23
- package/dist/runtime/providers.d.ts +34 -1
- package/dist/runtime/providers.js +56 -7
- package/dist/runtime/run-steps.d.ts +4 -6
- package/dist/runtime/run-steps.js +7 -15
- package/dist/runtime/runtime.module.js +1 -1
- package/dist/sandbox/held-operations.d.ts +2 -5
- package/dist/sandbox/held-operations.js +0 -14
- package/dist/sandbox/managed-device-context.d.ts +1 -1
- package/dist/sandbox/managed-device-context.js +1 -1
- package/dist/sandbox/permission-context-types.d.ts +0 -11
- package/dist/sandbox/permission-context-types.js +0 -13
- package/dist/sandbox/providers.d.ts +5 -0
- package/dist/sandbox/providers.js +1 -1
- package/dist/sandbox/sandbox-file-reader.d.ts +7 -12
- package/dist/sandbox/sandbox-file-reader.js +12 -29
- package/dist/sandbox/sandbox.service.d.ts +53 -32
- package/dist/sandbox/sandbox.service.js +217 -141
- package/dist/sandbox/use-context.d.ts +4 -1
- package/dist/skills/invoke.d.ts +13 -35
- package/dist/skills/invoke.js +23 -162
- package/dist/tools/builtins/builtin-tools.d.ts +2 -11
- package/dist/tools/builtins/builtin-tools.js +5 -23
- package/dist/tools/builtins/image/generate.js +2 -2
- package/dist/tools/builtins/sandbox/common.d.ts +32 -80
- package/dist/tools/builtins/sandbox/common.js +61 -173
- package/dist/tools/builtins/sandbox/deliver.js +2 -2
- package/dist/tools/builtins/sandbox/device-owner.d.ts +4 -5
- package/dist/tools/builtins/sandbox/device-owner.js +5 -6
- package/dist/tools/builtins/sandbox/fetch-attachment.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +1 -1
- package/dist/tools/builtins/sandbox/grep.js +1 -1
- package/dist/tools/builtins/sandbox/index.d.ts +2 -2
- package/dist/tools/builtins/sandbox/index.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +3 -3
- package/dist/tools/builtins/sandbox/task-output.js +4 -4
- package/dist/tools/builtins/sandbox/task-stop.js +1 -1
- package/dist/tools/builtins/skill-load.d.ts +10 -9
- package/dist/tools/builtins/skill-load.js +15 -19
- package/dist/tools/connectors.service.d.ts +4 -2
- package/dist/tools/connectors.service.js +15 -3
- package/dist/tools/pipeline.d.ts +0 -2
- package/dist/tools/pipeline.js +7 -14
- package/dist/tools/tools.module.js +1 -1
- package/package.json +2 -2
- package/src/migrations/0179_device_report_limit_text.sql +28 -0
- package/src/migrations/0180_device_instance_abandoned.sql +6 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PluginImport } from "../catalog/plugin-import.js";
|
|
2
|
+
import type { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
|
|
2
3
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -148,6 +149,11 @@ export declare const BOOTSTRAP_LOCK_TTL_MS = 120000;
|
|
|
148
149
|
export declare const BOOTSTRAP_LOCK_TTL: unique symbol;
|
|
149
150
|
/** What a run imports a declarative entry or an entry's catalog version with. */
|
|
150
151
|
export type BootstrapImports = Pick<PluginImport, "prepare" | "prepareGit" | "confirm">;
|
|
152
|
+
/**
|
|
153
|
+
* What a run moves the platform to a raised pin with, with or without an extension (the
|
|
154
|
+
* platform plugin update, acting as the kernel).
|
|
155
|
+
*/
|
|
156
|
+
export type BootstrapUpdater = Pick<PlatformPluginUpdater, "preview" | "update">;
|
|
151
157
|
export declare class BootstrapService {
|
|
152
158
|
private readonly kdb;
|
|
153
159
|
readonly txHost: TransactionHost;
|
|
@@ -221,6 +227,8 @@ export declare class BootstrapService {
|
|
|
221
227
|
packages?: ReadonlyMap<string, Uint8Array>;
|
|
222
228
|
/** The plugin import a declarative entry (or an entry's catalog version) goes through. */
|
|
223
229
|
imports: BootstrapImports;
|
|
230
|
+
/** The platform update a raised pin goes through (after the extension step, if any). */
|
|
231
|
+
updater: BootstrapUpdater;
|
|
224
232
|
}): Promise<BootstrapResult>;
|
|
225
233
|
/**
|
|
226
234
|
* A pin whose plugin name an org holds (a live org-owned catalog item): the bootstrap takes no
|
|
@@ -247,8 +255,28 @@ export declare class BootstrapService {
|
|
|
247
255
|
/** The entry names the last completed run handled (undefined before any run completed). */
|
|
248
256
|
private lastRunNames;
|
|
249
257
|
private entry;
|
|
250
|
-
/**
|
|
251
|
-
|
|
258
|
+
/**
|
|
259
|
+
* After the extension step: when the install record runs the pin from `bootstrap` and the
|
|
260
|
+
* plugin's platform version came from `bootstrap` at a lower version (raised just now, or by a
|
|
261
|
+
* run before core#727 that moved only the extension), the platform update moves the platform to
|
|
262
|
+
* the pin, acting as the kernel. A version the super admin moved to stays; a disabled item gets
|
|
263
|
+
* none (the update refuses it; the super admin applies the version once they enable it).
|
|
264
|
+
* Returns whether the platform moved.
|
|
265
|
+
*/
|
|
266
|
+
private raisePlatform;
|
|
267
|
+
/**
|
|
268
|
+
* The platform update to the pin, acting as the kernel (actor `null`). The update recomputes its
|
|
269
|
+
* preview under the item's lock; a scope sync the extension step owed may run between the two
|
|
270
|
+
* and change the orgs the preview covers (409 `plugin.upgrade_stale`): previewed again, a few
|
|
271
|
+
* times.
|
|
272
|
+
*/
|
|
273
|
+
private applyPlatform;
|
|
274
|
+
private logDisabled;
|
|
275
|
+
/**
|
|
276
|
+
* The live (not deleted) platform catalog item of this name: its platform version (the one orgs
|
|
277
|
+
* install, else its latest) and where that version came from. undefined: no such item.
|
|
278
|
+
*/
|
|
279
|
+
private platformVersion;
|
|
252
280
|
/**
|
|
253
281
|
* The catalog item of a bootstrap entry follows `required` / `builtin`: such an entry is builtin,
|
|
254
282
|
* offered to every org (scope `all`, which an org admin cannot switch off) and not disabled
|
|
@@ -272,7 +300,10 @@ export declare class BootstrapService {
|
|
|
272
300
|
private gitPlugin;
|
|
273
301
|
/** Stages a git entry from its files as an admin git import would (translation included). */
|
|
274
302
|
private prepareGitEntry;
|
|
275
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* A declarative plugin: catalog only. Returns false when that version is already imported.
|
|
305
|
+
* `updateFollows`: a platform update to this version follows (it owes the scope sync).
|
|
306
|
+
*/
|
|
276
307
|
private importOnly;
|
|
277
308
|
/**
|
|
278
309
|
* Imports, approves, installs and enables (one review; its confirm deploys the extension). When
|
|
@@ -244,7 +244,7 @@ let BootstrapService = class BootstrapService {
|
|
|
244
244
|
const fetchErr = fetchFailed.get(e.name);
|
|
245
245
|
if (fetchErr !== undefined)
|
|
246
246
|
throw fetchErr;
|
|
247
|
-
const r = await this.entry(e, files.get(e.name), handled, o
|
|
247
|
+
const r = await this.entry(e, files.get(e.name), handled, o, {
|
|
248
248
|
manifest: o.manifest,
|
|
249
249
|
tree: gitTrees.get(e.name),
|
|
250
250
|
});
|
|
@@ -370,7 +370,7 @@ let BootstrapService = class BootstrapService {
|
|
|
370
370
|
return undefined;
|
|
371
371
|
return new Set(results.filter((r) => r.action !== "required_cleared").map((r) => r.name));
|
|
372
372
|
}
|
|
373
|
-
async entry(e, bytes, handled, imports,
|
|
373
|
+
async entry(e, bytes, handled, { imports, updater },
|
|
374
374
|
/** For a git entry: the manifest (its marketplaces) and the tree oid when read from git now. */
|
|
375
375
|
at) {
|
|
376
376
|
let plugin;
|
|
@@ -432,9 +432,27 @@ let BootstrapService = class BootstrapService {
|
|
|
432
432
|
const builtin = e.required || e.builtin === true;
|
|
433
433
|
if (!plugin.extension) {
|
|
434
434
|
await this.markBuiltin(e.name, builtin);
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
const live = await this.platformVersion(e.name);
|
|
436
|
+
if (live !== undefined) {
|
|
437
|
+
// As the extension path does: a version the bootstrap put there is raised to the pin; one
|
|
438
|
+
// the super admin moved to (another source, or a higher version) stays
|
|
439
|
+
if (!raisable(live, e.version)) {
|
|
440
|
+
return { name: e.name, action: "kept", version: live.version };
|
|
441
|
+
}
|
|
442
|
+
if (live.disabled) {
|
|
443
|
+
// The update refuses a disabled item: the version waits in the catalog, and the super
|
|
444
|
+
// admin applies it once they enable the plugin
|
|
445
|
+
await this.importOnly(e, bytes, source, imports, git);
|
|
446
|
+
this.logDisabled(e, live.version);
|
|
447
|
+
return { name: e.name, action: "kept", version: live.version };
|
|
448
|
+
}
|
|
449
|
+
await this.importOnly(e, bytes, source, imports, git, true);
|
|
450
|
+
await this.applyPlatform(updater, live.itemId, e.version);
|
|
451
|
+
return { name: e.name, action: "upgraded", version: e.version };
|
|
437
452
|
}
|
|
453
|
+
// A builtin entry a super admin removed is put back; an optional one stays out (Ruling 5)
|
|
454
|
+
if (!isNew && !builtin)
|
|
455
|
+
return { name: e.name, action: "kept", version: e.version };
|
|
438
456
|
const imported = await this.importOnly(e, bytes, source, imports, git);
|
|
439
457
|
await this.markBuiltin(e.name, builtin);
|
|
440
458
|
return { name: e.name, action: imported ? "imported" : "kept", version: e.version };
|
|
@@ -487,18 +505,88 @@ let BootstrapService = class BootstrapService {
|
|
|
487
505
|
leftDisabled = await this.enableOrWarn(e);
|
|
488
506
|
}
|
|
489
507
|
await this.markBuiltin(e.name, builtin);
|
|
508
|
+
// The catalog version of the pin is imported now; the platform (its skills, templates, themes
|
|
509
|
+
// and org installs) follows the extension the same way a declarative entry does (core#727)
|
|
510
|
+
if (await this.raisePlatform(e, updater)) {
|
|
511
|
+
result = { name: e.name, action: "upgraded", version: e.version };
|
|
512
|
+
}
|
|
490
513
|
return leftDisabled === undefined ? result : { ...result, leftDisabled };
|
|
491
514
|
}
|
|
492
|
-
/**
|
|
493
|
-
|
|
515
|
+
/**
|
|
516
|
+
* After the extension step: when the install record runs the pin from `bootstrap` and the
|
|
517
|
+
* plugin's platform version came from `bootstrap` at a lower version (raised just now, or by a
|
|
518
|
+
* run before core#727 that moved only the extension), the platform update moves the platform to
|
|
519
|
+
* the pin, acting as the kernel. A version the super admin moved to stays; a disabled item gets
|
|
520
|
+
* none (the update refuses it; the super admin applies the version once they enable it).
|
|
521
|
+
* Returns whether the platform moved.
|
|
522
|
+
*/
|
|
523
|
+
async raisePlatform(e, updater) {
|
|
494
524
|
const row = await this.db
|
|
495
|
-
.selectFrom("
|
|
496
|
-
.select("
|
|
497
|
-
.where("name", "=", name)
|
|
498
|
-
.
|
|
499
|
-
|
|
525
|
+
.selectFrom("extension_installs")
|
|
526
|
+
.select(["version", "source"])
|
|
527
|
+
.where("name", "=", e.name)
|
|
528
|
+
.executeTakeFirst();
|
|
529
|
+
if (row?.source !== "bootstrap" || row.version !== e.version)
|
|
530
|
+
return false;
|
|
531
|
+
const live = await this.platformVersion(e.name);
|
|
532
|
+
if (live === undefined || !raisable(live, e.version))
|
|
533
|
+
return false;
|
|
534
|
+
if (live.disabled) {
|
|
535
|
+
this.logDisabled(e, live.version);
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
await this.applyPlatform(updater, live.itemId, e.version);
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* The platform update to the pin, acting as the kernel (actor `null`). The update recomputes its
|
|
543
|
+
* preview under the item's lock; a scope sync the extension step owed may run between the two
|
|
544
|
+
* and change the orgs the preview covers (409 `plugin.upgrade_stale`): previewed again, a few
|
|
545
|
+
* times.
|
|
546
|
+
*/
|
|
547
|
+
async applyPlatform(updater, itemId, version) {
|
|
548
|
+
for (let attempt = 1;; attempt++) {
|
|
549
|
+
const preview = await updater.preview(itemId, version);
|
|
550
|
+
try {
|
|
551
|
+
await updater.update(null, itemId, { version, diffHash: preview.diffHash });
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
catch (err) {
|
|
555
|
+
if (attempt >= 3 || !(err instanceof ApiError) || err.code !== "plugin.upgrade_stale") {
|
|
556
|
+
throw err;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
logDisabled(e, current) {
|
|
562
|
+
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 });
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* The live (not deleted) platform catalog item of this name: its platform version (the one orgs
|
|
566
|
+
* install, else its latest) and where that version came from. undefined: no such item.
|
|
567
|
+
*/
|
|
568
|
+
async platformVersion(name) {
|
|
569
|
+
const row = await this.db
|
|
570
|
+
.selectFrom("catalog_items as i")
|
|
571
|
+
.leftJoin("catalog_item_versions as v", (j) => j
|
|
572
|
+
.onRef("v.item_id", "=", "i.id")
|
|
573
|
+
.on("v.version", "=", sql `coalesce(i.platform_synced_version, i.latest_version)`))
|
|
574
|
+
.select([
|
|
575
|
+
"i.id",
|
|
576
|
+
sql `coalesce(i.platform_synced_version, i.latest_version)`.as("version"),
|
|
577
|
+
"v.source",
|
|
578
|
+
"i.disabled",
|
|
579
|
+
])
|
|
580
|
+
.where("i.name", "=", name)
|
|
581
|
+
.where("i.owner_org_id", "is", null)
|
|
582
|
+
.where("i.deleted_at", "is", null)
|
|
500
583
|
.executeTakeFirst();
|
|
501
|
-
return row
|
|
584
|
+
return (row && {
|
|
585
|
+
itemId: row.id,
|
|
586
|
+
version: row.version,
|
|
587
|
+
source: row.source ?? null,
|
|
588
|
+
disabled: row.disabled,
|
|
589
|
+
});
|
|
502
590
|
}
|
|
503
591
|
/**
|
|
504
592
|
* The catalog item of a bootstrap entry follows `required` / `builtin`: such an entry is builtin,
|
|
@@ -585,8 +673,11 @@ let BootstrapService = class BootstrapService {
|
|
|
585
673
|
}
|
|
586
674
|
return staged;
|
|
587
675
|
}
|
|
588
|
-
/**
|
|
589
|
-
|
|
676
|
+
/**
|
|
677
|
+
* A declarative plugin: catalog only. Returns false when that version is already imported.
|
|
678
|
+
* `updateFollows`: a platform update to this version follows (it owes the scope sync).
|
|
679
|
+
*/
|
|
680
|
+
async importOnly(e, bytes, source, imports, git, updateFollows = false) {
|
|
590
681
|
try {
|
|
591
682
|
const { stagingId, review } = git !== undefined
|
|
592
683
|
? await this.prepareGitEntry(e, git, source, imports)
|
|
@@ -594,6 +685,7 @@ let BootstrapService = class BootstrapService {
|
|
|
594
685
|
await imports.confirm(null, stagingId, {
|
|
595
686
|
reviewHash: review.reviewHash,
|
|
596
687
|
scope: e.scope ?? "optional",
|
|
688
|
+
...(updateFollows && { updateFollows: true }),
|
|
597
689
|
});
|
|
598
690
|
return true;
|
|
599
691
|
}
|
|
@@ -770,3 +862,8 @@ function carried(r, carry) {
|
|
|
770
862
|
}
|
|
771
863
|
/** `installed` is below `pinned` (a version that is not semver is never upgraded). */
|
|
772
864
|
const isLower = (installed, pinned) => semver.valid(installed) !== null && semver.valid(pinned) !== null && semver.lt(installed, pinned);
|
|
865
|
+
/**
|
|
866
|
+
* A platform version the bootstrap raises to the pin: one the bootstrap put there, below the pin
|
|
867
|
+
* (one the super admin moved to, from another source or at a higher version, stays).
|
|
868
|
+
*/
|
|
869
|
+
const raisable = (live, pinned) => live.source === "bootstrap" && isLower(live.version, pinned);
|
|
@@ -5,6 +5,7 @@ import { type Kysely } from "kysely";
|
|
|
5
5
|
import type { KernelAppOptions } from "../app.js";
|
|
6
6
|
import { MarketplacesService } from "../catalog/marketplaces.service.js";
|
|
7
7
|
import { PluginImport } from "../catalog/plugin-import.js";
|
|
8
|
+
import { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
|
|
8
9
|
import { ChannelJobs } from "../channels/jobs.js";
|
|
9
10
|
import { ChannelOutbound } from "../channels/outbound.js";
|
|
10
11
|
import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
|
|
@@ -84,6 +85,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
|
|
|
84
85
|
private readonly bootstrapDefaults;
|
|
85
86
|
private readonly marketplaces;
|
|
86
87
|
private readonly pluginImport;
|
|
88
|
+
private readonly pluginUpdater;
|
|
87
89
|
private readonly bus;
|
|
88
90
|
private readonly usageReport;
|
|
89
91
|
private readonly titles;
|
|
@@ -109,7 +111,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
|
|
|
109
111
|
private bootstrapPackages;
|
|
110
112
|
/** The merged bootstrap manifest, read once per start. */
|
|
111
113
|
private mergedManifest;
|
|
112
|
-
constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
|
|
114
|
+
constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
|
|
113
115
|
/** The kernel HTTP application (set up by `buildKernelApp` before `init()`). */
|
|
114
116
|
get http(): KernelHttpApp;
|
|
115
117
|
attachHttp(http: KernelHttpApp): void;
|
|
@@ -12,6 +12,7 @@ import { Inject, Injectable, Optional, } from "@nestjs/common";
|
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { MarketplacesService } from "../catalog/marketplaces.service.js";
|
|
14
14
|
import { PluginImport } from "../catalog/plugin-import.js";
|
|
15
|
+
import { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
|
|
15
16
|
import { ChannelJobs } from "../channels/jobs.js";
|
|
16
17
|
import { ChannelOutbound } from "../channels/outbound.js";
|
|
17
18
|
import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
|
|
@@ -105,6 +106,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
105
106
|
bootstrapDefaults;
|
|
106
107
|
marketplaces;
|
|
107
108
|
pluginImport;
|
|
109
|
+
pluginUpdater;
|
|
108
110
|
bus;
|
|
109
111
|
usageReport;
|
|
110
112
|
titles;
|
|
@@ -132,7 +134,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
132
134
|
mergedManifest;
|
|
133
135
|
constructor(permissionConfig, accounts, configService, log, options,
|
|
134
136
|
// biome-ignore lint/suspicious/noExplicitAny: the pool carries no schema types
|
|
135
|
-
pool, redis, kdb, shutdown, host, registry, installs, blobs, extensionLifecycle, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, bus,
|
|
137
|
+
pool, redis, kdb, shutdown, host, registry, installs, blobs, extensionLifecycle, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, bus,
|
|
136
138
|
// the producers closed on every role (their consumers are the worker role's)
|
|
137
139
|
usageReport, titles, suggestions, channelJobs, channelOutbound,
|
|
138
140
|
// this process's presence beat, on every role (admin overview spec §5.1)
|
|
@@ -159,6 +161,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
159
161
|
this.bootstrapDefaults = bootstrapDefaults;
|
|
160
162
|
this.marketplaces = marketplaces;
|
|
161
163
|
this.pluginImport = pluginImport;
|
|
164
|
+
this.pluginUpdater = pluginUpdater;
|
|
162
165
|
this.bus = bus;
|
|
163
166
|
this.usageReport = usageReport;
|
|
164
167
|
this.titles = titles;
|
|
@@ -387,6 +390,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
387
390
|
await bootstrap.run({
|
|
388
391
|
manifest,
|
|
389
392
|
imports: this.pluginImport,
|
|
393
|
+
updater: this.pluginUpdater,
|
|
390
394
|
...(dir !== undefined && { dir }),
|
|
391
395
|
signal: this.shutdown.signal,
|
|
392
396
|
...(this.bootstrapCarry !== undefined && { carry: this.bootstrapCarry }),
|
|
@@ -557,16 +561,17 @@ KernelLifecycle = __decorate([
|
|
|
557
561
|
__param(16, Inject(BootstrapDefaultsService)),
|
|
558
562
|
__param(17, Inject(MarketplacesService)),
|
|
559
563
|
__param(18, Inject(PluginImport)),
|
|
560
|
-
__param(19, Inject(
|
|
561
|
-
__param(20, Inject(
|
|
562
|
-
__param(21, Inject(
|
|
563
|
-
__param(22, Inject(
|
|
564
|
-
__param(23, Inject(
|
|
565
|
-
__param(24, Inject(
|
|
566
|
-
__param(25, Inject(
|
|
567
|
-
__param(26,
|
|
568
|
-
__param(26, Inject(WorkerRole)),
|
|
564
|
+
__param(19, Inject(PlatformPluginUpdater)),
|
|
565
|
+
__param(20, Inject(KERNEL_BUS)),
|
|
566
|
+
__param(21, Inject(UsageReporter)),
|
|
567
|
+
__param(22, Inject(TitleQueue)),
|
|
568
|
+
__param(23, Inject(PromptSuggestionQueue)),
|
|
569
|
+
__param(24, Inject(ChannelJobs)),
|
|
570
|
+
__param(25, Inject(ChannelOutbound)),
|
|
571
|
+
__param(26, Inject(ReplicaPresence)),
|
|
569
572
|
__param(27, Optional()),
|
|
570
|
-
__param(27, Inject(
|
|
573
|
+
__param(27, Inject(WorkerRole)),
|
|
574
|
+
__param(28, Optional()),
|
|
575
|
+
__param(28, Inject(GatewayRole))
|
|
571
576
|
], KernelLifecycle);
|
|
572
577
|
export { KernelLifecycle };
|
package/dist/overrides.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ import { RUN_HOOKS, type RunHooks } from "./runtime/run-worker.js";
|
|
|
28
28
|
import { SUBAGENT_MESSAGES_HOOKS, type SubagentMessagesHooks } from "./runtime/subagents/messages.js";
|
|
29
29
|
import { SANDBOX_LEASE_TIMINGS, type SandboxLeaseTimings } from "./sandbox/leases.js";
|
|
30
30
|
import { PERMISSION_AUTO_GRANT_HOOKS, type PermissionAutoGrantHooks } from "./sandbox/permission-auto-grants.js";
|
|
31
|
-
import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
|
|
32
31
|
import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
|
|
33
32
|
import { TOOL_PIPELINE_HOOKS, type ToolPipelineHooks } from "./tools/pipeline.js";
|
|
34
33
|
import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
@@ -68,9 +67,6 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
|
68
67
|
* - `EXTENSION_NET_SEAMS`: `ctx.net`'s DNS and dispatcher (a hostname resolving to a private address
|
|
69
68
|
* served by a loopback fake);
|
|
70
69
|
* - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes);
|
|
71
|
-
* - `PERMISSION_CONTEXT_ACTIVATION`: the recorded permission context producers (the request
|
|
72
|
-
* boundary and the managed device context writer); production leaves them on, and a test may
|
|
73
|
-
* turn them off to exercise the dormant state;
|
|
74
70
|
* - `PERMISSION_AUTO_GRANT_HOOKS`: a barrier after a Full access auto-grant's precheck (two
|
|
75
71
|
* replicas racing the same crossing).
|
|
76
72
|
*/
|
|
@@ -104,7 +100,6 @@ interface KernelSeams {
|
|
|
104
100
|
[PLUGIN_PUBLIC_WRITE_LIMIT]: number;
|
|
105
101
|
[EXTENSION_NET_SEAMS]: ExtensionNetSeams;
|
|
106
102
|
[APP_INTERCEPTOR]: NestInterceptor;
|
|
107
|
-
[PERMISSION_CONTEXT_ACTIVATION]: boolean;
|
|
108
103
|
[PERMISSION_AUTO_GRANT_HOOKS]: PermissionAutoGrantHooks;
|
|
109
104
|
}
|
|
110
105
|
/**
|
package/dist/overrides.js
CHANGED
|
@@ -25,7 +25,6 @@ import { RUN_HOOKS } from "./runtime/run-worker.js";
|
|
|
25
25
|
import { SUBAGENT_MESSAGES_HOOKS, } from "./runtime/subagents/messages.js";
|
|
26
26
|
import { SANDBOX_LEASE_TIMINGS } from "./sandbox/leases.js";
|
|
27
27
|
import { PERMISSION_AUTO_GRANT_HOOKS, } from "./sandbox/permission-auto-grants.js";
|
|
28
|
-
import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
|
|
29
28
|
import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
|
|
30
29
|
import { TOOL_PIPELINE_HOOKS } from "./tools/pipeline.js";
|
|
31
30
|
import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
@@ -59,7 +58,6 @@ const SEAM_TOKENS = [
|
|
|
59
58
|
PLUGIN_PUBLIC_WRITE_LIMIT,
|
|
60
59
|
EXTENSION_NET_SEAMS,
|
|
61
60
|
APP_INTERCEPTOR,
|
|
62
|
-
PERMISSION_CONTEXT_ACTIVATION,
|
|
63
61
|
PERMISSION_AUTO_GRANT_HOOKS,
|
|
64
62
|
];
|
|
65
63
|
const allSeamsListed = true;
|
|
@@ -5,11 +5,12 @@ import { StorageService } from "../storage/storage.service.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* File references (platform web parity spec §5): a `Platform` write the web does with an upload
|
|
7
7
|
* takes a file the agent already has instead, a conversation file (`fileId`: an attachment, a
|
|
8
|
-
* generated or delivered artifact, a `read` copy). A file on the conversation's device is
|
|
9
|
-
* first (`Deliver`: the device rules, the command review and the
|
|
10
|
-
* by the delivered file's id, so device files have one reading path. The tool
|
|
11
|
-
* policy step (limits, sha256, a thumbnail for an image: the card's
|
|
12
|
-
* before the run, which refuses bytes that differ from the ones the
|
|
8
|
+
* generated or delivered artifact, a `read` copy). A file on the conversation's device is
|
|
9
|
+
* delivered first (`Deliver`: the device rules, the command review and the permission profile
|
|
10
|
+
* apply) and passed by the delivered file's id, so device files have one reading path. The tool
|
|
11
|
+
* resolves it at the policy step (limits, sha256, a thumbnail for an image: the card's
|
|
12
|
+
* `detail.file`) and again right before the run, which refuses bytes that differ from the ones the
|
|
13
|
+
* person confirmed.
|
|
13
14
|
*/
|
|
14
15
|
export type FileRef = {
|
|
15
16
|
fileId: string;
|
|
@@ -475,7 +475,7 @@ let AgentSkillsOperations = class AgentSkillsOperations {
|
|
|
475
475
|
path: input.filePath,
|
|
476
476
|
maxBytes: SKILL_PACKAGE_MAX_BYTES,
|
|
477
477
|
signal: ctx.signal,
|
|
478
|
-
// the read is this call's managed operation
|
|
478
|
+
// the read is this call's managed operation
|
|
479
479
|
...(ctx.callId !== undefined && { callId: ctx.callId }),
|
|
480
480
|
});
|
|
481
481
|
const o = await this.agentSkills.register({
|
|
@@ -779,7 +779,7 @@ let AgentsOperations = class AgentsOperations {
|
|
|
779
779
|
}),
|
|
780
780
|
defineOperation({
|
|
781
781
|
id: "agents.readiness",
|
|
782
|
-
description: "Whether the org can run agents: modelProvider is ready when a model provider
|
|
782
|
+
description: "Whether the org can run agents: modelProvider is ready when the org has a chat model an agent can pick (the list agents.create chooses from); no_models when model providers are on but none gives one (unusableProviders names each provider and its reason: list_failed with errorKind, e.g. auth for a rejected key, or no_chat_models; orgCanFix says whether an org admin can fix it on Settings > Models, else only the super admin can on the admin Models page); org_fixable when no provider is on but an org admin can make one available on Settings > Models (orgFixableProviders names each provider and its reason: not_enabled, switch it on; needs_config, fill the org's config); none when only the super admin can help; and how many agents you can see.",
|
|
783
783
|
input: z.object({}).strict(),
|
|
784
784
|
example: {},
|
|
785
785
|
authz: { orgAction: "org.read" },
|
|
@@ -96,8 +96,8 @@ export interface ModelStepDeps {
|
|
|
96
96
|
* before each agent-history request construction, record (live) or feed (full-run replay) the
|
|
97
97
|
* permission context, then rebuild from the complete log. Called at every request construction
|
|
98
98
|
* of the attempt ladder (a retry, a fallback, the rebuild after a forced compaction, wrap-up);
|
|
99
|
-
* absent, no call and no reread (old requests build byte for byte). Live runs get the
|
|
100
|
-
*
|
|
99
|
+
* absent, no call and no reread (old requests build byte for byte). Live runs always get the
|
|
100
|
+
* recorder (`RunSteps`); full-run replays strip any live one and
|
|
101
101
|
* install only the recorded feeder (`evals/recorded-permission-context.ts`).
|
|
102
102
|
*/
|
|
103
103
|
permissionContext?: PermissionContextPort;
|
|
@@ -88,7 +88,7 @@ export declare const projectUnavailable: {
|
|
|
88
88
|
reason: "gone" | "outside_mode" | "removed" | "unreadable" | "unsupported";
|
|
89
89
|
message: string;
|
|
90
90
|
};
|
|
91
|
-
/** A host machine whose runtime cannot enforce the kernel's read-only read
|
|
91
|
+
/** A host machine whose runtime cannot enforce the kernel's read-only read. */
|
|
92
92
|
readonly notEnforceable: (root: string) => {
|
|
93
93
|
reason: "gone" | "outside_mode" | "removed" | "unreadable" | "unsupported";
|
|
94
94
|
message: string;
|
|
@@ -41,7 +41,7 @@ export const projectUnavailable = {
|
|
|
41
41
|
/** The device's own error text is logged, never recorded: the message stays the same per root. */
|
|
42
42
|
unreadable: (root) => unavailable("unreadable", `The project's root ${clipped(root)} could not be read.`),
|
|
43
43
|
removed: (project) => unavailable("removed", `The project "${clipped(project, 80)}" was removed from the device's projects.`),
|
|
44
|
-
/** A host machine whose runtime cannot enforce the kernel's read-only read
|
|
44
|
+
/** A host machine whose runtime cannot enforce the kernel's read-only read. */
|
|
45
45
|
notEnforceable: (root) => unavailable("unreadable", `The project's root ${clipped(root)} was not read: this device's runtime cannot enforce a read-only read on its host; turn on its sandbox enforcement or use another device.`),
|
|
46
46
|
/** A device runtime that refused the kernel's read-only read scope (its text is logged). */
|
|
47
47
|
refused: (root) => unavailable("unreadable", `The project's root ${clipped(root)} was not read: this device's runtime refused the kernel's read-only read.`),
|
|
@@ -42,9 +42,8 @@ export interface ProjectKnowledgeInput {
|
|
|
42
42
|
* latest snapshot differs from the child's latest; the renderer then shows it to the child as is.
|
|
43
43
|
*
|
|
44
44
|
* Reads in the device's effective mode (`DeviceProjectsService.scopeFor`, the same scope the
|
|
45
|
-
* binding was checked against) and through `SandboxService.
|
|
46
|
-
*
|
|
47
|
-
* activation gate is on the read goes through `SandboxService.withKernelRead` instead: every
|
|
45
|
+
* binding was checked against) and through `SandboxService.withKernelRead`, so a bound
|
|
46
|
+
* conversation starts its device eagerly (the accepted cost, spec §4.4): every
|
|
48
47
|
* stat / readFile / list a kernel read under the run's current execution claim while the run is
|
|
49
48
|
* still queued, acting for the run's trigger, its scope narrowed to the root, `AGENTS.md` and
|
|
50
49
|
* `.agents/skills` (permission activation L2). A project the
|
|
@@ -64,11 +63,7 @@ export declare class ProjectKnowledgeService {
|
|
|
64
63
|
private readonly sandbox;
|
|
65
64
|
private readonly log;
|
|
66
65
|
private readonly timeoutMs;
|
|
67
|
-
|
|
68
|
-
private readonly activation?;
|
|
69
|
-
constructor(db: KernelDb, eventLog: Pick<EventLog, "appendIn" | "notify">, txHost: TransactionHost, devices: Pick<ConversationDevices, "forTool">, projects: Pick<DeviceProjectsService, "scopeFor" | "keeps">, sandbox: Pick<SandboxService, "withSandbox" | "withKernelRead">, log: KernelLogger, timeoutMs?: () => number,
|
|
70
|
-
/** The paired activation gate: once on, the read is a set of kernel reads. */
|
|
71
|
-
activation?: boolean | undefined);
|
|
66
|
+
constructor(db: KernelDb, eventLog: Pick<EventLog, "appendIn" | "notify">, txHost: TransactionHost, devices: Pick<ConversationDevices, "forTool">, projects: Pick<DeviceProjectsService, "scopeFor" | "keeps">, sandbox: Pick<SandboxService, "withKernelRead">, log: KernelLogger, timeoutMs?: () => number);
|
|
72
67
|
/**
|
|
73
68
|
* Reads and records (see the class); notifies after the commit. False: the run had ended under
|
|
74
69
|
* the locks (a stop landed while the device was read), so nothing was appended and the run must
|
|
@@ -84,9 +79,8 @@ export declare class ProjectKnowledgeService {
|
|
|
84
79
|
/** The snapshot read on the device, or null when the device could not be asked (logged). */
|
|
85
80
|
private read;
|
|
86
81
|
/**
|
|
87
|
-
* How the read enters the device
|
|
88
|
-
*
|
|
89
|
-
* start runs inside it; another run's claim or none admits nothing), acting for the run's
|
|
82
|
+
* How the read enters the device: `withKernelRead` under the run's current execution claim (the
|
|
83
|
+
* run start runs inside it; another run's claim or none admits nothing), acting for the run's
|
|
90
84
|
* trigger, reading the bound root only.
|
|
91
85
|
*/
|
|
92
86
|
private entry;
|
|
@@ -21,9 +21,8 @@ import { Transactional } from "../../infra/database/transactional.decorator.js";
|
|
|
21
21
|
import { KERNEL_LOGGER } from "../../infra/tokens.js";
|
|
22
22
|
import { KernelReadNotAdmitted, KernelReadUnsupported } from "../../sandbox/kernel-read.js";
|
|
23
23
|
import { SandboxLockLostError, SandboxPathBusyError } from "../../sandbox/leases.js";
|
|
24
|
-
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../../sandbox/permission-context-types.js";
|
|
25
24
|
import { homeOf } from "../../sandbox/review/rules.js";
|
|
26
|
-
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
25
|
+
import { SandboxService, } from "../../sandbox/sandbox.service.js";
|
|
27
26
|
import { providerConnectionFailure } from "../../sandbox/unreachable.js";
|
|
28
27
|
import { currentExecutionClaim } from "../run-execution.js";
|
|
29
28
|
import { runEndedIn } from "../run-status.js";
|
|
@@ -48,8 +47,8 @@ class KnowledgeClaimMissing extends Error {
|
|
|
48
47
|
/**
|
|
49
48
|
* An error that says the device could not be asked, not that the project is unreadable: the
|
|
50
49
|
* provider unreachable, a kernel refusal (the device offline, gone or busy, a relay given up), a
|
|
51
|
-
* malformed device answer, a lost lease, a kernel read that was not admitted (
|
|
52
|
-
*
|
|
50
|
+
* malformed device answer, a lost lease, a kernel read that was not admitted (nothing was sent
|
|
51
|
+
* to the device).
|
|
53
52
|
*/
|
|
54
53
|
function isDeviceFailure(e) {
|
|
55
54
|
return (providerConnectionFailure(e) !== undefined ||
|
|
@@ -72,9 +71,8 @@ function isDeviceFailure(e) {
|
|
|
72
71
|
* latest snapshot differs from the child's latest; the renderer then shows it to the child as is.
|
|
73
72
|
*
|
|
74
73
|
* Reads in the device's effective mode (`DeviceProjectsService.scopeFor`, the same scope the
|
|
75
|
-
* binding was checked against) and through `SandboxService.
|
|
76
|
-
*
|
|
77
|
-
* activation gate is on the read goes through `SandboxService.withKernelRead` instead: every
|
|
74
|
+
* binding was checked against) and through `SandboxService.withKernelRead`, so a bound
|
|
75
|
+
* conversation starts its device eagerly (the accepted cost, spec §4.4): every
|
|
78
76
|
* stat / readFile / list a kernel read under the run's current execution claim while the run is
|
|
79
77
|
* still queued, acting for the run's trigger, its scope narrowed to the root, `AGENTS.md` and
|
|
80
78
|
* `.agents/skills` (permission activation L2). A project the
|
|
@@ -94,10 +92,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
94
92
|
sandbox;
|
|
95
93
|
log;
|
|
96
94
|
timeoutMs;
|
|
97
|
-
|
|
98
|
-
constructor(db, eventLog, txHost, devices, projects, sandbox, log, timeoutMs = () => PROJECT_KNOWLEDGE_TIMEOUT_MS,
|
|
99
|
-
/** The paired activation gate: once on, the read is a set of kernel reads. */
|
|
100
|
-
activation) {
|
|
95
|
+
constructor(db, eventLog, txHost, devices, projects, sandbox, log, timeoutMs = () => PROJECT_KNOWLEDGE_TIMEOUT_MS) {
|
|
101
96
|
this.db = db;
|
|
102
97
|
this.eventLog = eventLog;
|
|
103
98
|
this.txHost = txHost;
|
|
@@ -106,7 +101,6 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
106
101
|
this.sandbox = sandbox;
|
|
107
102
|
this.log = log;
|
|
108
103
|
this.timeoutMs = timeoutMs;
|
|
109
|
-
this.activation = activation;
|
|
110
104
|
}
|
|
111
105
|
/**
|
|
112
106
|
* Reads and records (see the class); notifies after the commit. False: the run had ended under
|
|
@@ -195,7 +189,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
195
189
|
});
|
|
196
190
|
return unavailableProject(bound.project, bound.root, projectUnavailable.unsupported());
|
|
197
191
|
}
|
|
198
|
-
const enter = await this.entry(input, bound.
|
|
192
|
+
const enter = await this.entry(input, bound.root);
|
|
199
193
|
return await enter({
|
|
200
194
|
orgId: input.orgId,
|
|
201
195
|
deviceId,
|
|
@@ -246,7 +240,7 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
246
240
|
});
|
|
247
241
|
return unavailableProject(bound.project, bound.root, projectUnavailable.refused(bound.root));
|
|
248
242
|
}
|
|
249
|
-
//
|
|
243
|
+
// a host runtime without restricted enforcement gets no kernel read; the
|
|
250
244
|
// project is recorded unreadable with the reason and the run goes on
|
|
251
245
|
if (!(e instanceof KernelReadUnsupported))
|
|
252
246
|
throw e;
|
|
@@ -268,14 +262,11 @@ let ProjectKnowledgeService = class ProjectKnowledgeService {
|
|
|
268
262
|
}
|
|
269
263
|
}
|
|
270
264
|
/**
|
|
271
|
-
* How the read enters the device
|
|
272
|
-
*
|
|
273
|
-
* start runs inside it; another run's claim or none admits nothing), acting for the run's
|
|
265
|
+
* How the read enters the device: `withKernelRead` under the run's current execution claim (the
|
|
266
|
+
* run start runs inside it; another run's claim or none admits nothing), acting for the run's
|
|
274
267
|
* trigger, reading the bound root only.
|
|
275
268
|
*/
|
|
276
|
-
async entry(input,
|
|
277
|
-
if (!permissionContextActive(this.activation))
|
|
278
|
-
return Object.assign(this.sandbox.withSandbox.bind(this.sandbox), { accountId: owner });
|
|
269
|
+
async entry(input, root) {
|
|
279
270
|
const claim = currentExecutionClaim();
|
|
280
271
|
if (!claim ||
|
|
281
272
|
claim.runId !== input.runId ||
|
|
@@ -350,8 +341,6 @@ ProjectKnowledgeService = __decorate([
|
|
|
350
341
|
__param(5, Inject(SandboxService)),
|
|
351
342
|
__param(6, Inject(KERNEL_LOGGER)),
|
|
352
343
|
__param(7, Optional()),
|
|
353
|
-
__param(7, Inject(PROJECT_KNOWLEDGE_TIMEOUT))
|
|
354
|
-
__param(8, Optional()),
|
|
355
|
-
__param(8, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
344
|
+
__param(7, Inject(PROJECT_KNOWLEDGE_TIMEOUT))
|
|
356
345
|
], ProjectKnowledgeService);
|
|
357
346
|
export { ProjectKnowledgeService };
|