@capybara-hq/kernel 0.1.0-rc.65 → 0.1.0-rc.67
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 +0 -8
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/admin-agents.d.ts +2 -2
- package/dist/agents/admin-agents.js +2 -1
- package/dist/agents/agent-lookup.js +2 -1
- package/dist/agents/agent-profile.service.d.ts +5 -2
- package/dist/agents/agent-profile.service.js +13 -2
- package/dist/agents/agents.controller.d.ts +4 -3
- package/dist/agents/agents.controller.js +7 -3
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.schemas.d.ts +6 -6
- package/dist/agents/agents.service.d.ts +23 -2
- package/dist/agents/agents.service.js +61 -6
- package/dist/agents/avatar-view.d.ts +8 -0
- package/dist/agents/avatar-view.js +12 -0
- package/dist/agents/profile.d.ts +38 -13
- package/dist/agents/profile.js +31 -20
- package/dist/attribution/platform-attribution.d.ts +15 -6
- package/dist/attribution/platform-attribution.js +31 -14
- package/dist/background/poll.job.d.ts +1 -1
- package/dist/background/poll.job.js +8 -6
- package/dist/background/tasks.service.js +1 -1
- package/dist/catalog/catalog-content.d.ts +6 -3
- package/dist/catalog/catalog-content.js +7 -8
- package/dist/catalog/claude/translate.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/marketplaces.service.js +2 -1
- package/dist/catalog/plugin-package.d.ts +3 -2
- package/dist/channels/file-delivery.d.ts +2 -0
- package/dist/channels/file-delivery.js +1 -1
- package/dist/channels/inbound.d.ts +8 -4
- package/dist/channels/inbound.js +14 -7
- package/dist/channels/outbound.js +11 -5
- package/dist/channels/phrases.d.ts +21 -13
- package/dist/channels/phrases.js +21 -14
- package/dist/client/client-files.js +1 -1
- package/dist/config/product-name.d.ts +8 -0
- package/dist/config/product-name.js +9 -0
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +17 -4
- package/dist/conversations/conversations.service.d.ts +4 -3
- package/dist/conversations/conversations.service.js +15 -2
- package/dist/ctx/create-ctx.js +5 -2
- package/dist/ctx/device-provider-check.d.ts +7 -0
- package/dist/ctx/device-provider-check.js +21 -0
- package/dist/db/kernel-schema.d.ts +7 -0
- package/dist/devices/access.d.ts +16 -46
- package/dist/devices/access.js +26 -62
- package/dist/devices/access.module.js +2 -2
- package/dist/devices/conversation-devices.d.ts +38 -18
- package/dist/devices/conversation-devices.js +69 -51
- package/dist/devices/default-provider-setting.d.ts +45 -0
- package/dist/devices/default-provider-setting.js +59 -0
- package/dist/devices/device-projects.service.js +7 -2
- package/dist/devices/device-provider-selection.d.ts +37 -0
- package/dist/devices/device-provider-selection.js +86 -0
- package/dist/devices/device-provider-selection.module.d.ts +3 -0
- package/dist/devices/device-provider-selection.module.js +22 -0
- package/dist/devices/devices.controller.d.ts +8 -5
- package/dist/devices/devices.controller.js +7 -4
- package/dist/devices/devices.module.js +3 -1
- package/dist/devices/devices.schemas.js +2 -2
- package/dist/devices/devices.service.d.ts +72 -83
- package/dist/devices/devices.service.js +139 -248
- package/dist/devices/dto.d.ts +9 -0
- package/dist/devices/dto.js +15 -2
- package/dist/devices/label.d.ts +3 -5
- package/dist/devices/label.js +3 -14
- package/dist/devices/legacy-cleanup.job.d.ts +2 -2
- package/dist/devices/legacy-cleanup.job.js +6 -6
- package/dist/errors.d.ts +15 -1
- package/dist/errors.js +15 -1
- package/dist/extensions/guide-places.d.ts +2 -1
- package/dist/extensions/guide-places.js +8 -2
- package/dist/extensions/locks.d.ts +1 -1
- package/dist/extensions/locks.js +1 -1
- package/dist/extensions/org-config.d.ts +20 -4
- package/dist/extensions/org-config.js +23 -6
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permission-view.js +2 -2
- package/dist/extensions/plugin-guides.d.ts +1 -1
- package/dist/extensions/plugin-guides.js +11 -3
- package/dist/extensions/point-defaults.d.ts +14 -0
- package/dist/extensions/point-defaults.js +70 -47
- package/dist/extensions/resolve.js +7 -2
- package/dist/git/gateway.d.ts +9 -0
- package/dist/git/gateway.js +36 -17
- package/dist/git/gateway.route.d.ts +1 -1
- package/dist/git/gateway.route.js +1 -3
- package/dist/http/app.d.ts +1 -1
- package/dist/identity/app-auth.d.ts +4 -3
- package/dist/identity/app-auth.js +7 -8
- package/dist/identity/settings.d.ts +8 -0
- package/dist/identity/settings.js +30 -3
- package/dist/identity/sso.d.ts +13 -7
- package/dist/identity/sso.js +21 -7
- package/dist/infra/config/kernel-config.service.js +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +7 -6
- package/dist/local-devices/device-routes.d.ts +1 -1
- package/dist/local-devices/device-routes.js +2 -2
- package/dist/local-devices/local-device-provider.d.ts +14 -11
- package/dist/local-devices/local-device-provider.js +14 -0
- package/dist/local-devices/local-devices.module.d.ts +4 -4
- package/dist/local-devices/local-devices.module.js +5 -3
- package/dist/local-devices/owner-report.js +2 -1
- package/dist/local-devices/targets.d.ts +2 -0
- package/dist/local-devices/targets.js +10 -0
- package/dist/orgs/offboarding.js +9 -0
- package/dist/orgs/settings.service.d.ts +26 -1
- package/dist/orgs/settings.service.js +44 -3
- package/dist/platform/ops/admin.ops.js +8 -3
- package/dist/platform/ops/agents.ops.d.ts +6 -1
- package/dist/platform/ops/agents.ops.js +38 -11
- package/dist/platform/ops/devices.ops.js +25 -20
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/platform-icons.ops.js +4 -4
- package/dist/platform/ops/platform.ops.js +2 -1
- package/dist/platform/ops/themes.ops.js +1 -1
- package/dist/runtime/plugin-context.service.js +1 -12
- package/dist/sandbox/cloud-permission-snapshot.d.ts +2 -2
- package/dist/sandbox/cloud-permission-snapshot.js +3 -3
- package/dist/sandbox/device-reports.d.ts +50 -0
- package/dist/sandbox/device-reports.js +157 -0
- package/dist/sandbox/held-operations.d.ts +8 -8
- package/dist/sandbox/leases.d.ts +1 -1
- package/dist/sandbox/leases.js +1 -1
- package/dist/sandbox/operation-authority.d.ts +5 -2
- package/dist/sandbox/operation-authority.js +12 -11
- package/dist/sandbox/operation-reconcile.job.d.ts +2 -2
- package/dist/sandbox/operation-reconcile.job.js +5 -5
- package/dist/sandbox/permission-availability.d.ts +2 -2
- package/dist/sandbox/permission-call-types.d.ts +5 -0
- package/dist/sandbox/permission-facts.d.ts +2 -2
- package/dist/sandbox/permission-facts.js +5 -5
- package/dist/sandbox/providers.d.ts +23 -24
- package/dist/sandbox/providers.js +38 -46
- package/dist/sandbox/providers.module.js +3 -3
- package/dist/sandbox/review/classifier.d.ts +6 -0
- package/dist/sandbox/review/classifier.js +12 -1
- package/dist/sandbox/review/index.d.ts +1 -1
- package/dist/sandbox/review/index.js +1 -1
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +7 -2
- package/dist/sandbox/sandbox.service.d.ts +95 -68
- package/dist/sandbox/sandbox.service.js +212 -208
- package/dist/setup/setup-guides.service.d.ts +4 -1
- package/dist/setup/setup-guides.service.js +6 -1
- package/dist/themes/avatar-preset-key.d.ts +6 -0
- package/dist/themes/avatar-preset-key.js +9 -0
- package/dist/themes/platform-icon.service.js +1 -1
- package/dist/themes/theme-delivery.service.d.ts +10 -2
- package/dist/themes/theme-delivery.service.js +26 -11
- package/dist/themes/theme-state.d.ts +43 -2
- package/dist/themes/theme-state.js +61 -4
- package/dist/themes/themes-public.controller.d.ts +3 -3
- package/dist/themes/themes-public.controller.js +3 -3
- package/dist/themes/themes.service.d.ts +28 -1
- package/dist/themes/themes.service.js +36 -2
- package/dist/tools/builtins/image/generate.d.ts +3 -0
- package/dist/tools/builtins/image/generate.js +21 -11
- package/dist/tools/builtins/image/index.d.ts +1 -1
- package/dist/tools/builtins/image/index.js +1 -1
- package/dist/tools/builtins/platform.js +25 -17
- package/dist/tools/builtins/sandbox/common.d.ts +37 -13
- package/dist/tools/builtins/sandbox/common.js +63 -19
- package/dist/tools/builtins/sandbox/read.d.ts +5 -2
- package/dist/tools/builtins/sandbox/read.js +9 -6
- package/dist/tools/builtins/sandbox/task-output.d.ts +2 -2
- package/dist/tools/builtins/sandbox/task-output.js +6 -5
- package/dist/tools/builtins/skill-load.js +13 -4
- package/dist/tools/connectors.service.js +2 -1
- package/dist/tools/oauth/discovery.d.ts +2 -0
- package/dist/tools/oauth/discovery.js +3 -1
- package/dist/until-aborted.d.ts +5 -0
- package/dist/until-aborted.js +16 -0
- package/package.json +4 -4
- package/src/migrations/0176_device_report.sql +6 -0
|
@@ -4,16 +4,18 @@ import { SandboxOperationAuthority } from "./operation-authority.js";
|
|
|
4
4
|
import { type OperationInvocation, SandboxOperationIntents } from "./operation-intents.js";
|
|
5
5
|
import { PermissionInstanceWrites } from "./permission-instance-writes.js";
|
|
6
6
|
export type { HeldProvider } from "./held-operations.js";
|
|
7
|
-
import { type
|
|
7
|
+
import { type DeviceProvider, type ExecResult, type SandboxHandle, type SandboxLimits, type SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
8
8
|
import type { Redis } from "ioredis";
|
|
9
9
|
import { type Selectable } from "kysely";
|
|
10
10
|
import type { KernelConfig } from "../config/schema.js";
|
|
11
11
|
import type { DeviceInstancesTable } from "../db/kernel-schema.js";
|
|
12
|
+
import { DeviceProviderSelection } from "../devices/device-provider-selection.js";
|
|
12
13
|
import { ApiError } from "../errors.js";
|
|
13
14
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
14
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
16
|
import type { KernelLogger } from "../log.js";
|
|
16
17
|
import { CloudPermissionSnapshots, type CloudSnapshotOutcome } from "./cloud-permission-snapshot.js";
|
|
18
|
+
import { DeviceReports } from "./device-reports.js";
|
|
17
19
|
import type { DeviceSandbox, HostGrantCeiling } from "./device-sandbox.js";
|
|
18
20
|
import { type KernelReadInvocation } from "./kernel-read.js";
|
|
19
21
|
import { SandboxLeases, type SandboxPathLease } from "./leases.js";
|
|
@@ -21,7 +23,7 @@ import { LegacyRetirementStore } from "./legacy-retirement.js";
|
|
|
21
23
|
import { type AppliedLimits, type DeviceLimits, type EffectiveDevicePolicy } from "./modes.js";
|
|
22
24
|
import type { HeldDeviceContextEvidence } from "./permission-context-types.js";
|
|
23
25
|
import { PermissionFacts } from "./permission-facts.js";
|
|
24
|
-
import {
|
|
26
|
+
import { DeviceProviders } from "./providers.js";
|
|
25
27
|
import type { SandboxUseContext } from "./use-context.js";
|
|
26
28
|
export { deviceNotFound } from "../devices/errors.js";
|
|
27
29
|
export { SANDBOX_LOCK_PREFIX, SANDBOX_LOCK_TTL_MS, SandboxLockLostError, sandboxBusy, } from "./leases.js";
|
|
@@ -54,9 +56,8 @@ export interface SandboxUseInfo {
|
|
|
54
56
|
*/
|
|
55
57
|
contextEvidence?: HeldDeviceContextEvidence;
|
|
56
58
|
}
|
|
57
|
-
export type { SandboxProviderEntry } from "./providers.js";
|
|
58
59
|
type Row = Selectable<DeviceInstancesTable>;
|
|
59
|
-
type ExecArgs = Parameters<
|
|
60
|
+
type ExecArgs = Parameters<DeviceProvider["exec"]>[1];
|
|
60
61
|
/**
|
|
61
62
|
* One instance of a device: its handle and the row's `created_at`, which the fenced write
|
|
62
63
|
* after every `create` sets. The handle alone is not enough: sandbox-docker's handle is the
|
|
@@ -74,7 +75,7 @@ interface Instance {
|
|
|
74
75
|
* The provider {@link SandboxService.ifRunning} passes to its callback: every `exec` carries the
|
|
75
76
|
* holder's tag; the caller names the actor.
|
|
76
77
|
*/
|
|
77
|
-
export type TaggedProvider = Omit<
|
|
78
|
+
export type TaggedProvider = Omit<DeviceProvider, "exec"> & {
|
|
78
79
|
exec(h: SandboxHandle, args: Omit<ExecArgs, "tag">): Promise<ExecResult>;
|
|
79
80
|
};
|
|
80
81
|
/** What {@link SandboxService.ifRunning} did. */
|
|
@@ -135,8 +136,8 @@ export declare const isInstance: (row: Pick<Row, "handle" | "created_at">, gone:
|
|
|
135
136
|
* Sandbox config problems to tell operators at startup (English log lines):
|
|
136
137
|
* - `runtime.maxRunSeconds` below `sandbox.limits.maxCommandSeconds`: long commands are cut by the
|
|
137
138
|
* run time limit (Ruling M20);
|
|
138
|
-
* -
|
|
139
|
-
* startup config) while an org can be on it: auto mode always is, and a sandbox-mode cloud device
|
|
139
|
+
* - a loaded provider plugin refuses the open public network (`refuseOpenNetwork: true` in its
|
|
140
|
+
* startup config; one line per such provider) while an org can be on it: auto mode always is, and a sandbox-mode cloud device
|
|
140
141
|
* keeps its org's cloud network, open by default, so turning auto mode off does not avoid it
|
|
141
142
|
* (auto mode hardening spec K3). Only the kill switch (`sandbox.limits.egress: none`) does.
|
|
142
143
|
* - `sandbox.limits.orgHosts: within` while the startup config does not turn auto mode off: the
|
|
@@ -145,11 +146,11 @@ export declare const isInstance: (row: Pick<Row, "handle" | "created_at">, gone:
|
|
|
145
146
|
* No run duration limit (`runtime.maxRunSeconds` 0, the default) cuts no command, so there is
|
|
146
147
|
* nothing to tell.
|
|
147
148
|
*/
|
|
148
|
-
export declare function sandboxConfigWarnings(cfg: Pick<KernelConfig, "runtime" | "sandbox" | "extensionConfig"> & Partial<Pick<KernelConfig, "devices">>,
|
|
149
|
+
export declare function sandboxConfigWarnings(cfg: Pick<KernelConfig, "runtime" | "sandbox" | "extensionConfig"> & Partial<Pick<KernelConfig, "devices">>, providerPlugins?: readonly string[]): {
|
|
149
150
|
level: "warn";
|
|
150
151
|
message: string;
|
|
151
152
|
}[];
|
|
152
|
-
/** No
|
|
153
|
+
/** No device to run on: none bound and none can be made (no device provider on in the org; 503). */
|
|
153
154
|
export declare const sandboxUnavailable: () => ApiError;
|
|
154
155
|
/**
|
|
155
156
|
* An owner browse found no running instance of the device (409): the picker starts the device
|
|
@@ -184,7 +185,7 @@ export declare const recreateRequired: () => ApiError;
|
|
|
184
185
|
*/
|
|
185
186
|
export declare const replaceRequired: () => ApiError;
|
|
186
187
|
/**
|
|
187
|
-
* The kernel's sandbox service over the `
|
|
188
|
+
* The kernel's sandbox service over the `device-provider@1` provider, keyed by **device** (spec
|
|
188
189
|
* 2026-11-07-environments-design §4.2, §5.1): one file system kept until the device is
|
|
189
190
|
* deleted, plus one instance attached to it that comes and goes; all conversations bound to the
|
|
190
191
|
* device (and their sub-agents) share both.
|
|
@@ -195,7 +196,7 @@ export declare const replaceRequired: () => ApiError;
|
|
|
195
196
|
* `fs_status` becomes `lost` and uses fail with `device.files_lost` until
|
|
196
197
|
* {@link resetFileSystem}.
|
|
197
198
|
* - **Leases** (phase C, spec §10, {@link SandboxLeases}), keyed by device id: using an
|
|
198
|
-
* instance recorded `running` with the
|
|
199
|
+
* instance recorded `running` with the device's provider takes a **shared** lease, so up to
|
|
199
200
|
* `sandbox.maxConcurrentCommands` holders (all sessions of the device) run at once. Every
|
|
200
201
|
* lifecycle change (create, resume, rebuild, suspend, destroy, reset) takes the **exclusive**
|
|
201
202
|
* lease, alone; a caller that needs one on the use path sets the intent so new shared leases wait
|
|
@@ -231,18 +232,20 @@ export declare const replaceRequired: () => ApiError;
|
|
|
231
232
|
* row's `created_at` (set by the fenced write after each `create`); the handle alone is the same
|
|
232
233
|
* after a rebuild on providers whose handle is the instance name (sandbox-docker).
|
|
233
234
|
*
|
|
234
|
-
* - **Provider per device** (
|
|
235
|
-
*
|
|
236
|
-
* device runs on the kernel-internal `@local`
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
235
|
+
* - **Provider per device** (device-provider spec §6.1): a device is bound to its provider
|
|
236
|
+
* (`devices.provider`, fixed at creation) for life, resolved at every call
|
|
237
|
+
* ({@link DeviceProviders.forDevice}): a local device runs on the kernel-internal `@local`
|
|
238
|
+
* provider, any other on the loaded `device-provider@1` extension of that name. Several
|
|
239
|
+
* providers serve one org side by side. A use needs the provider loaded **and** on in the
|
|
240
|
+
* device's org ({@link DeviceProviderSelection.isOnInOrg}); otherwise, and for an instance row
|
|
241
|
+
* naming another provider, the use fails `device.unavailable` (503) and nothing changes: the
|
|
242
|
+
* files and instance stay, nothing is demoted, recreated or moved to another provider.
|
|
243
|
+
* Lifecycle cleanup (destroy, sweeps, reset) only needs the provider loaded. The sweeps run
|
|
244
|
+
* per loaded provider over its own rows; rows of a provider that is not loaded are never
|
|
245
|
+
* touched. A `@local` instance is never suspended or destroyed for inactivity; a deleted
|
|
246
|
+
* `@local` device (or one of a deleted org) is destroyed by the sweep like any other.
|
|
240
247
|
*
|
|
241
|
-
*
|
|
242
|
-
* (`device.unavailable`) until that provider is back; deleting it still works while that
|
|
243
|
-
* provider is loaded ({@link SandboxProviders.forName}). Without the device's provider
|
|
244
|
-
* {@link availableFor} is false and uses throw `sandbox.unavailable` (503). No in-process state:
|
|
245
|
-
* replicas share it through PG and Redis.
|
|
248
|
+
* No in-process state: replicas share it through PG and Redis.
|
|
246
249
|
*/
|
|
247
250
|
/** Available only to kernel staging callbacks, never to a held user-operation callback. */
|
|
248
251
|
export interface SandboxStaging {
|
|
@@ -260,6 +263,8 @@ export declare class SandboxService {
|
|
|
260
263
|
private readonly leases;
|
|
261
264
|
/** The providers (read at every call: providers are ready after the extension load). */
|
|
262
265
|
private readonly providers;
|
|
266
|
+
/** Whether a device's provider serves its org now (read at every use, never cached). */
|
|
267
|
+
private readonly selection;
|
|
263
268
|
private readonly config;
|
|
264
269
|
private readonly log;
|
|
265
270
|
private readonly facts;
|
|
@@ -270,33 +275,57 @@ export declare class SandboxService {
|
|
|
270
275
|
private readonly retirement;
|
|
271
276
|
/** The cloud snapshot writer's reconcile, for the lifecycle reconcile of marked devices (B-12). */
|
|
272
277
|
private readonly snapshots;
|
|
278
|
+
/** The stored device report, refreshed after a create or a resume (never fails the use). */
|
|
279
|
+
private readonly reports;
|
|
273
280
|
constructor(db: KernelDb,
|
|
274
281
|
/** The record of the instance each holder last used (`capk:sandbox-seen:…`). */
|
|
275
282
|
redis: Pick<Redis, "get" | "set" | "getdel">, leases: SandboxLeases,
|
|
276
283
|
/** The providers (read at every call: providers are ready after the extension load). */
|
|
277
|
-
providers: Pick<
|
|
284
|
+
providers: Pick<DeviceProviders, "forDevice" | "loaded">,
|
|
285
|
+
/** Whether a device's provider serves its org now (read at every use, never cached). */
|
|
286
|
+
selection: Pick<DeviceProviderSelection, "isOnInOrg">, config: Pick<KernelConfigService, "get" | "fieldSource">, log: Pick<KernelLogger, "info" | "warn">, facts: Pick<PermissionFacts, "devicePolicy" | "assertCloudReconciled" | "readHeldEnvironment" | "readDevice" | "deviceSandbox" | "deviceSandboxFacts" | "orgHostGrantCeiling">, operationIntents: SandboxOperationIntents, authority: SandboxOperationAuthority, instanceWrites: PermissionInstanceWrites,
|
|
278
287
|
/** The retirement obligations every lifecycle acquisition is gated on (8.5). */
|
|
279
288
|
retirement: Pick<LegacyRetirementStore, "unresolved" | "hasUnresolved" | "settleRebooted" | "scanUntilStable" | "frozen" | "frozenAt" | "quarantine" | "noteFailure" | "resolveDestroyed" | "resolveCancelled" | "membersOf" | "recordDestruction" | "destructionRecorded">,
|
|
280
289
|
/** The cloud snapshot writer's reconcile, for the lifecycle reconcile of marked devices (B-12). */
|
|
281
|
-
snapshots: Pick<CloudPermissionSnapshots, "reconcileHeld"
|
|
290
|
+
snapshots: Pick<CloudPermissionSnapshots, "reconcileHeld">,
|
|
291
|
+
/** The stored device report, refreshed after a create or a resume (never fails the use). */
|
|
292
|
+
reports: Pick<DeviceReports, "refresh">);
|
|
282
293
|
/** Poll interval while waiting for a lease (the leases' own). */
|
|
283
294
|
private get pollMs();
|
|
284
295
|
/**
|
|
285
|
-
* Whether
|
|
286
|
-
*
|
|
287
|
-
*
|
|
296
|
+
* Whether the device of `orgId` can be used now: its provider is loaded and on in the org
|
|
297
|
+
* ({@link DeviceProviderSelection.isOnInOrg}; `@local`: registered). A missing device, one of
|
|
298
|
+
* another org or one without a provider is not.
|
|
288
299
|
*/
|
|
289
|
-
|
|
290
|
-
/** Whether the device's provider is there (`@local` registered, or a cloud provider). */
|
|
291
|
-
availableFor(deviceId: string): Promise<boolean>;
|
|
300
|
+
availableFor(deviceId: string, orgId: string): Promise<boolean>;
|
|
292
301
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
302
|
+
* Whether the provider the device is bound to is loaded here (`@local`: registered), whatever
|
|
303
|
+
* its org says: for lifecycle work that goes on while the org has the provider off (owed
|
|
304
|
+
* revocations, cleanup).
|
|
305
|
+
*/
|
|
306
|
+
providerLoaded(deviceId: string): Promise<boolean>;
|
|
307
|
+
/**
|
|
308
|
+
* The device's `devices.provider` (null: none recorded; undefined: no such device, or one of
|
|
309
|
+
* another org with `orgId`).
|
|
310
|
+
*/
|
|
311
|
+
private deviceProvider;
|
|
312
|
+
/**
|
|
313
|
+
* The loaded provider the device is bound to (no org check: lifecycle work and reads that
|
|
314
|
+
* need no use); undefined when the device is missing, has none or its provider is not loaded.
|
|
296
315
|
*/
|
|
297
316
|
private providerOf;
|
|
298
|
-
/**
|
|
317
|
+
/**
|
|
318
|
+
* The provider a use of the device of `orgId` runs on: loaded and on in the org, else
|
|
319
|
+
* `device.unavailable` (503, files kept); a missing device or one of another org is
|
|
320
|
+
* `device.not_found`.
|
|
321
|
+
*/
|
|
299
322
|
private require;
|
|
323
|
+
/**
|
|
324
|
+
* The loaded provider for lifecycle work on the device (no org check: cleanup and maintenance
|
|
325
|
+
* go on while its org has the provider off), else `device.unavailable`; a missing device is
|
|
326
|
+
* `device.not_found`.
|
|
327
|
+
*/
|
|
328
|
+
private loadedFor;
|
|
300
329
|
/** Concurrent holders of one device (`sandbox.maxConcurrentCommands`, read at every use). */
|
|
301
330
|
private get cap();
|
|
302
331
|
/**
|
|
@@ -545,7 +574,7 @@ export declare class SandboxService {
|
|
|
545
574
|
private readHeldContextEvidence;
|
|
546
575
|
/**
|
|
547
576
|
* Becomes a holder: loops until it has a shared lease on a running instance, or `sandbox.busy`.
|
|
548
|
-
* An instance recorded `running` (with the
|
|
577
|
+
* An instance recorded `running` (with the device's provider, not the `gone` instance) is used
|
|
549
578
|
* under a shared lease; otherwise the exclusive lease (with intent) makes it run and is
|
|
550
579
|
* downgraded. One token serves both, so the waiter passes its own intent. `wantNow` reads the
|
|
551
580
|
* limits this use wants ({@link wantedLimits}), again after each wait, so a mode narrowed
|
|
@@ -583,7 +612,7 @@ export declare class SandboxService {
|
|
|
583
612
|
/** The instance row belongs to another org: reported as not found, so ids cannot be probed. */
|
|
584
613
|
private foreign;
|
|
585
614
|
/**
|
|
586
|
-
* Recorded running with the
|
|
615
|
+
* Recorded running with the device's provider on files not lost (lost ones go through the
|
|
587
616
|
* exclusive path, which refuses them), and not the instance found gone.
|
|
588
617
|
*/
|
|
589
618
|
private usable;
|
|
@@ -652,6 +681,8 @@ export declare class SandboxService {
|
|
|
652
681
|
* many it suspended. Called every minute by the `sandbox-suspend-idle` cron.
|
|
653
682
|
*/
|
|
654
683
|
suspendIdle(now: Date): Promise<number>;
|
|
684
|
+
/** {@link suspendIdle} for the rows of one provider. */
|
|
685
|
+
private suspendIdleOf;
|
|
655
686
|
/**
|
|
656
687
|
* Destruction sweep: an instance unused for longer than `destroyAfterInactiveDays` is destroyed
|
|
657
688
|
* (the instance only; the file system is kept and the next use builds a new instance on it); an
|
|
@@ -662,21 +693,27 @@ export declare class SandboxService {
|
|
|
662
693
|
* hourly by the `sandbox-destroy-inactive` cron.
|
|
663
694
|
*/
|
|
664
695
|
destroyInactive(now: Date): Promise<number>;
|
|
696
|
+
/**
|
|
697
|
+
* One destruction sweep over the rows of provider `p` matching `due` (never another provider's
|
|
698
|
+
* row: the row's provider is part of the condition, read again under the lease).
|
|
699
|
+
*/
|
|
700
|
+
private sweepRows;
|
|
665
701
|
/**
|
|
666
702
|
* Destroys the device's instance, then its file system, then deletes its instance row
|
|
667
703
|
* (device deletion, offboarding); nothing to do without a row. Waits for the exclusive lease
|
|
668
704
|
* (with intent, so running commands finish and new ones wait) up to 10 minutes. Without the
|
|
669
|
-
*
|
|
670
|
-
* retried, and the destruction sweep finishes a deleted device once the provider is
|
|
671
|
-
*
|
|
672
|
-
*
|
|
705
|
+
* provider of its instance row loaded it throws and the row stays, marked `sweep_failed_at` (the
|
|
706
|
+
* job is retried, and the destruction sweep finishes a deleted device once the provider is
|
|
707
|
+
* back). The provider only needs to be loaded: a device is deleted while its org has the
|
|
708
|
+
* provider off too.
|
|
673
709
|
*/
|
|
674
710
|
destroyDevice(deviceId: string): Promise<void>;
|
|
675
711
|
/**
|
|
676
712
|
* Starts the device over with empty files (after `device.files_lost`, or on request):
|
|
677
713
|
* under the exclusive lease (waited for like {@link destroyDevice}) destroys any instance and
|
|
678
714
|
* the file system (a `lost` one is only dropped), and records no file system; the next use
|
|
679
|
-
* creates a new one. Nothing to do without a row. Throws `
|
|
715
|
+
* creates a new one. Nothing to do without a row. Throws `device.unavailable` while the device's
|
|
716
|
+
* provider is not loaded, or when its instance row names another provider.
|
|
680
717
|
*/
|
|
681
718
|
resetFileSystem(deviceId: string): Promise<void>;
|
|
682
719
|
/**
|
|
@@ -704,13 +741,16 @@ export declare class SandboxService {
|
|
|
704
741
|
*/
|
|
705
742
|
reconcileLimits(deviceId: string, signal?: AbortSignal): Promise<CloudSnapshotOutcome | "busy">;
|
|
706
743
|
/**
|
|
707
|
-
* The worker's sweep of {@link reconcileLimits} (`sandbox-reconcile-limits`):
|
|
708
|
-
* live cloud devices of
|
|
709
|
-
* id order from
|
|
710
|
-
* once per {@link RECONCILE_RETRY_SECONDS} across replicas (a
|
|
711
|
-
*
|
|
744
|
+
* The worker's sweep of {@link reconcileLimits} (`sandbox-reconcile-limits`): for each loaded
|
|
745
|
+
* provider that can `update`, up to `limit` live cloud devices of its own carrying the marker on
|
|
746
|
+
* a live instance, in id order from that provider's shared keyset cursor that wraps around (no
|
|
747
|
+
* starvation), each tried at most once per {@link RECONCILE_RETRY_SECONDS} across replicas (a
|
|
748
|
+
* Redis marker). Rows of a provider that is not loaded are never touched. Returns how many it
|
|
749
|
+
* reconciled.
|
|
712
750
|
*/
|
|
713
751
|
reconcileMarked(limit?: number): Promise<number>;
|
|
752
|
+
/** {@link reconcileMarked} for the devices of one provider. */
|
|
753
|
+
private reconcileMarkedOf;
|
|
714
754
|
/**
|
|
715
755
|
* The retirement gate (permission runtime cutover 8.5), under the exclusive lifecycle lease and
|
|
716
756
|
* before the instance is used, resumed, rebuilt, switched to another provider, bound or
|
|
@@ -786,28 +826,20 @@ export declare class SandboxService {
|
|
|
786
826
|
/** Runs `call` with its own short signal; a failure is warned and returns false. */
|
|
787
827
|
private bestEffort;
|
|
788
828
|
/**
|
|
789
|
-
* Destroys
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
* usable; an abort is thrown.
|
|
793
|
-
*/
|
|
794
|
-
private dropUnrecordedFiles;
|
|
795
|
-
/**
|
|
796
|
-
* Destroys an instance of another provider with that provider: still loaded and destroyed →
|
|
797
|
-
* false; otherwise warns and returns true (the record must be kept).
|
|
829
|
+
* Destroys an instance an earlier kernel recorded in `prev_*` (left by a provider replaced back
|
|
830
|
+
* then) with that provider: still loaded and destroyed → false; otherwise warns and returns true
|
|
831
|
+
* (the record must be kept).
|
|
798
832
|
*/
|
|
799
833
|
private retire;
|
|
800
834
|
/**
|
|
801
|
-
* Under the lease: destroys the row's instance
|
|
802
|
-
* instance without a handle (a create that ended before
|
|
803
|
-
* name. Returns the `prev_*` patch
|
|
835
|
+
* Under the lease: destroys the row's instance with its own provider `p` (and an instance an
|
|
836
|
+
* earlier kernel recorded in `prev_*`). An instance without a handle (a create that ended before
|
|
837
|
+
* the handle was recorded) is destroyed by name. Returns the `prev_*` patch.
|
|
804
838
|
*/
|
|
805
839
|
private destroyInstance;
|
|
806
840
|
/**
|
|
807
|
-
* Under the lease: destroys the row's file system with
|
|
808
|
-
*
|
|
809
|
-
* that provider not loaded it throws (the row must stay for a retry), or with `lenient` only
|
|
810
|
-
* warns (the files leak at that provider).
|
|
841
|
+
* Under the lease: destroys the row's file system with its own provider `p` (by name when no
|
|
842
|
+
* handle was recorded: `createFileSystem` may have finished before the kernel stopped).
|
|
811
843
|
*/
|
|
812
844
|
private destroyFiles;
|
|
813
845
|
/**
|
|
@@ -817,13 +849,8 @@ export declare class SandboxService {
|
|
|
817
849
|
private destroyRow;
|
|
818
850
|
/** Due for suspension: made by this provider, running, and idle or running for too long. */
|
|
819
851
|
private suspendDue;
|
|
820
|
-
/** The provider of an instance row
|
|
852
|
+
/** The loaded provider of an instance row (its own `provider`); undefined when not loaded. */
|
|
821
853
|
private rowProvider;
|
|
822
|
-
/**
|
|
823
|
-
* A row the idle sweeps may touch: not on a kernel-internal provider (`@local` instances live on
|
|
824
|
-
* people's machines and are never suspended or destroyed for inactivity).
|
|
825
|
-
*/
|
|
826
|
-
private cloudRow;
|
|
827
854
|
/** The device was deleted, or its org was: the instance and the files go. */
|
|
828
855
|
private deviceGone;
|
|
829
856
|
/** Due for instance destruction: an instance (or a create in progress) unused for too long. */
|