@capybara-hq/kernel 0.1.0-rc.12 → 0.1.0-rc.14
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/dist/admin/admin.schemas.d.ts +13 -0
- package/dist/agents/agent-lookup.d.ts +5 -0
- package/dist/agents/agent-lookup.js +15 -0
- package/dist/background/background.module.js +2 -2
- package/dist/background/launch-lock.d.ts +1 -1
- package/dist/background/launch-lock.js +1 -1
- package/dist/background/poll.job.d.ts +2 -2
- package/dist/background/poll.job.js +10 -10
- package/dist/background/stop.d.ts +1 -1
- package/dist/background/stop.js +3 -3
- package/dist/background/store.d.ts +5 -5
- package/dist/background/store.js +5 -5
- package/dist/background/tasks.service.d.ts +6 -6
- package/dist/background/tasks.service.js +13 -13
- package/dist/catalog/admin-catalog.controller.d.ts +13 -2
- package/dist/catalog/admin-catalog.controller.js +24 -3
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +7 -0
- package/dist/catalog/catalog-content.d.ts +9 -1
- package/dist/catalog/catalog-content.js +2 -1
- package/dist/catalog/catalog-files.d.ts +3 -2
- package/dist/catalog/catalog-files.js +8 -5
- package/dist/catalog/component-scope.service.d.ts +14 -1
- package/dist/catalog/component-scope.service.js +12 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +5 -4
- package/dist/catalog/org-catalog.controller.js +5 -4
- package/dist/catalog/org-catalog.schemas.d.ts +18 -2
- package/dist/catalog/org-catalog.schemas.js +16 -2
- package/dist/catalog/org-catalog.service.js +8 -2
- package/dist/catalog/plugin-import.js +1 -1
- package/dist/catalog/plugin-package.js +37 -9
- package/dist/catalog/plugin-upgrade.d.ts +15 -1
- package/dist/catalog/plugin-upgrade.js +18 -5
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +1 -1
- package/dist/channels/connections.service.d.ts +22 -5
- package/dist/channels/connections.service.js +56 -10
- package/dist/channels/inbound.d.ts +8 -8
- package/dist/channels/inbound.js +31 -31
- package/dist/channels/phrases.d.ts +27 -27
- package/dist/channels/phrases.js +27 -27
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +21 -21
- package/dist/conversations/conversations.controller.d.ts +11 -11
- package/dist/conversations/conversations.controller.js +15 -15
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.js +1 -1
- package/dist/conversations/conversations.service.d.ts +14 -14
- package/dist/conversations/conversations.service.js +19 -19
- package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
- package/dist/conversations/{environment-status.js → device-status.js} +18 -18
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +1 -1
- package/dist/conversations/events.d.ts +1 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +26 -3
- package/dist/ctx/create-ctx.js +134 -26
- package/dist/db/kernel-schema.d.ts +37 -25
- package/dist/{environments → devices}/access.d.ts +19 -19
- package/dist/{environments → devices}/access.js +28 -28
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
- package/dist/devices/devices.module.d.ts +5 -13
- package/dist/devices/devices.module.js +16 -29
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
- package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
- package/dist/devices/dto.d.ts +13 -54
- package/dist/devices/dto.js +7 -39
- package/dist/devices/label.d.ts +11 -0
- package/dist/{environments → devices}/label.js +7 -7
- package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
- package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
- package/dist/errors.d.ts +29 -25
- package/dist/errors.js +29 -25
- package/dist/evals/recorded-tools.d.ts +2 -2
- package/dist/evals/recorded-tools.js +6 -6
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +2 -0
- package/dist/extensions/effective-config.d.ts +6 -0
- package/dist/extensions/effective-config.js +18 -7
- package/dist/extensions/guide-places.d.ts +66 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +27 -6
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +16 -2
- package/dist/extensions/permission-set.js +17 -3
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/extensions/plugin-guides.d.ts +207 -54
- package/dist/extensions/plugin-guides.js +436 -165
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +16 -6
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/identity/settings.d.ts +32 -0
- package/dist/identity/settings.js +26 -2
- package/dist/infra/config/kernel-config.service.js +4 -4
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/throttler/named-throttlers.d.ts +4 -1
- package/dist/infra/throttler/named-throttlers.js +16 -1
- package/dist/infra/throttler/throttler.guard.js +1 -1
- package/dist/kernel.module.js +3 -3
- package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
- package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
- package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
- package/dist/{devices → local-devices}/device-auth.js +51 -53
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/{devices → local-devices}/device-auth.module.js +5 -5
- package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
- package/dist/{devices → local-devices}/device-routes.js +2 -2
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/{devices → local-devices}/keys.d.ts +11 -11
- package/dist/{devices → local-devices}/keys.js +11 -11
- package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
- package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
- package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
- package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/{devices → local-devices}/machines.d.ts +26 -26
- package/dist/{devices → local-devices}/machines.js +71 -71
- package/dist/{devices → local-devices}/relay.d.ts +15 -15
- package/dist/{devices → local-devices}/relay.js +55 -55
- package/dist/{devices → local-devices}/targets.d.ts +8 -8
- package/dist/{devices → local-devices}/targets.js +14 -14
- package/dist/orgs/offboarding.d.ts +6 -6
- package/dist/orgs/offboarding.js +12 -12
- package/dist/orgs/settings.service.d.ts +28 -0
- package/dist/orgs/settings.service.js +20 -1
- package/dist/overrides.d.ts +3 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +48 -8
- package/dist/platform/operation.js +10 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/connectors.ops.js +2 -0
- package/dist/platform/ops/conversations.ops.d.ts +3 -3
- package/dist/platform/ops/conversations.ops.js +9 -9
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/platform-ops.module.d.ts +4 -2
- package/dist/platform/platform-ops.module.js +13 -5
- package/dist/platform/route-schemas.js +11 -3
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/roles/worker.module.js +1 -1
- package/dist/runtime/context/build.d.ts +1 -1
- package/dist/runtime/context/build.js +6 -6
- package/dist/runtime/context/compaction.js +1 -1
- package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
- package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/sandbox/jobs.d.ts +13 -13
- package/dist/sandbox/jobs.js +20 -20
- package/dist/sandbox/leases.d.ts +9 -9
- package/dist/sandbox/leases.js +14 -14
- package/dist/sandbox/providers.d.ts +8 -8
- package/dist/sandbox/providers.js +8 -8
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +76 -76
- package/dist/sandbox/sandbox.service.js +230 -230
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +295 -0
- package/dist/setup/oauth-token-probe.d.ts +47 -0
- package/dist/setup/oauth-token-probe.js +108 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/tools/builtins/builtin-tools.d.ts +2 -2
- package/dist/tools/builtins/builtin-tools.js +5 -5
- package/dist/tools/builtins/platform.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +6 -6
- package/dist/tools/builtins/sandbox/common.d.ts +25 -25
- package/dist/tools/builtins/sandbox/common.js +51 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
- package/dist/tools/builtins/sandbox/task-output.js +10 -10
- package/dist/tools/builtins/sandbox/task-stop.js +2 -2
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +1 -1
- package/dist/tools/builtins/skill-load.js +2 -2
- package/dist/tools/connectors.controller.d.ts +28 -11
- package/dist/tools/connectors.controller.js +49 -14
- package/dist/tools/connectors.schemas.d.ts +4 -0
- package/dist/tools/connectors.schemas.js +4 -0
- package/dist/tools/connectors.service.d.ts +30 -2
- package/dist/tools/connectors.service.js +98 -3
- package/dist/tools/credentials.d.ts +20 -0
- package/dist/tools/credentials.js +90 -1
- package/dist/tools/oauth/tokens.d.ts +20 -0
- package/dist/tools/oauth/tokens.js +49 -24
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +3 -3
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +74 -0
- package/dist/ui/arrangement.js +98 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +29 -14
- package/dist/ui/registry.js +31 -10
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +66 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +84 -18
- package/dist/ui/views.js +201 -38
- package/package.json +3 -3
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/dist/devices/device-auth.module.d.ts +0 -7
- package/dist/environments/conversation-environments.d.ts +0 -75
- package/dist/environments/dto.d.ts +0 -25
- package/dist/environments/dto.js +0 -12
- package/dist/environments/environments.controller.d.ts +0 -36
- package/dist/environments/environments.module.d.ts +0 -8
- package/dist/environments/environments.module.js +0 -31
- package/dist/environments/environments.schemas.d.ts +0 -3
- package/dist/environments/environments.schemas.js +0 -14
- package/dist/environments/label.d.ts +0 -11
- package/dist/platform/ops/environments.ops.d.ts +0 -26
- package/dist/platform/ops/environments.ops.js +0 -311
|
@@ -3,7 +3,7 @@ import type { Redis } from "ioredis";
|
|
|
3
3
|
import { type Selectable } from "kysely";
|
|
4
4
|
import { BackgroundTaskStore } from "../background/store.js";
|
|
5
5
|
import { type KernelConfig } from "../config/schema.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { DeviceInstancesTable } from "../db/kernel-schema.js";
|
|
7
7
|
import { ApiError } from "../errors.js";
|
|
8
8
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
9
9
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -16,13 +16,13 @@ export interface SandboxUseInfo {
|
|
|
16
16
|
/** This call created the instance (first use, or a rebuild). */
|
|
17
17
|
fresh: boolean;
|
|
18
18
|
/**
|
|
19
|
-
* The
|
|
19
|
+
* The device had an instance before that is no longer there (destroyed after inactivity,
|
|
20
20
|
* gone at the provider, or rebuilt by another holder since this holder last used it): this is a
|
|
21
21
|
* new instance on the kept files, so earlier processes are gone.
|
|
22
22
|
*/
|
|
23
23
|
restarted: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* The
|
|
25
|
+
* The device's files were reset since this holder last used it (on request, or after they
|
|
26
26
|
* were lost): earlier files are gone too. Set only when true; `restarted` is then false.
|
|
27
27
|
*/
|
|
28
28
|
filesReset?: true;
|
|
@@ -35,17 +35,17 @@ export interface SandboxUseInfo {
|
|
|
35
35
|
/** Who uses the sandbox in {@link SandboxService.withSandbox}. */
|
|
36
36
|
export interface SandboxUseContext {
|
|
37
37
|
orgId: string;
|
|
38
|
-
|
|
38
|
+
deviceId: string;
|
|
39
39
|
/** The agent conversation using it (a sub-agent's own for a child): what it last saw is tracked. */
|
|
40
40
|
holderConversationId: string;
|
|
41
41
|
/** Passed with every `exec` (audit and attribution). */
|
|
42
42
|
actor: SandboxActor;
|
|
43
43
|
}
|
|
44
44
|
export type { SandboxProviderEntry } from "./providers.js";
|
|
45
|
-
type Row = Selectable<
|
|
45
|
+
type Row = Selectable<DeviceInstancesTable>;
|
|
46
46
|
type ExecArgs = Parameters<SandboxProvider["exec"]>[1];
|
|
47
47
|
/**
|
|
48
|
-
* One instance of
|
|
48
|
+
* One instance of a device: its handle and the row's `created_at`, which the fenced write
|
|
49
49
|
* after every `create` sets. The handle alone is not enough: sandbox-docker's handle is the
|
|
50
50
|
* instance name, the same after a rebuild (spec §10.10).
|
|
51
51
|
*/
|
|
@@ -80,20 +80,20 @@ export type IfRunningResult<T> = {
|
|
|
80
80
|
kind: "not_running";
|
|
81
81
|
status: Row["status"] | "gone";
|
|
82
82
|
}
|
|
83
|
-
/** The
|
|
83
|
+
/** The device now records another instance (a rebuild). */
|
|
84
84
|
| {
|
|
85
85
|
kind: "other_instance";
|
|
86
86
|
};
|
|
87
|
-
/** The provider-side name of
|
|
88
|
-
export declare const
|
|
89
|
-
/** The
|
|
90
|
-
export declare const
|
|
87
|
+
/** The provider-side name of a device's file system and instance. */
|
|
88
|
+
export declare const deviceResourceName: (deviceId: string) => string;
|
|
89
|
+
/** The device is missing, deleted, or not in the caller's org (404; ids cannot be probed). */
|
|
90
|
+
export declare const deviceNotFound: () => ApiError;
|
|
91
91
|
/**
|
|
92
|
-
* The
|
|
93
|
-
* connected machine (`
|
|
94
|
-
* owner's: `capybara-device logout`, then `login` into the
|
|
92
|
+
* The device's file system is gone at the provider (409); never replaced silently. On a
|
|
93
|
+
* connected machine (`local`, details `[{ source: "local" }]`) the directory is the machine
|
|
94
|
+
* owner's: `capybara-device logout`, then `login` into the device, recreates it (ruling R24).
|
|
95
95
|
*/
|
|
96
|
-
export declare const
|
|
96
|
+
export declare const deviceFilesLost: (local?: boolean) => ApiError;
|
|
97
97
|
/**
|
|
98
98
|
* The row still records the instance `gone` (same handle and same `created_at`). Handles compare
|
|
99
99
|
* canonically: a jsonb round trip reorders a multi-key handle's keys (final review m9).
|
|
@@ -115,19 +115,19 @@ export declare function sandboxConfigWarnings(cfg: Pick<KernelConfig, "runtime"
|
|
|
115
115
|
/** No sandbox provider (503). */
|
|
116
116
|
export declare const sandboxUnavailable: () => ApiError;
|
|
117
117
|
/**
|
|
118
|
-
* The kernel's sandbox service over the `sandbox@2` provider, keyed by **
|
|
119
|
-
* 2026-11-07-environments-design §4.2, §5.1): one file system kept until the
|
|
118
|
+
* The kernel's sandbox service over the `sandbox@2` provider, keyed by **device** (spec
|
|
119
|
+
* 2026-11-07-environments-design §4.2, §5.1): one file system kept until the device is
|
|
120
120
|
* deleted, plus one instance attached to it that comes and goes; all conversations bound to the
|
|
121
|
-
*
|
|
121
|
+
* device (and their sub-agents) share both.
|
|
122
122
|
*
|
|
123
123
|
* - **Lazy creation**: the first {@link withSandbox} creates the file system
|
|
124
|
-
* (`createFileSystem`, name `cap-
|
|
125
|
-
* in `
|
|
126
|
-
* `fs_status` becomes `lost` and uses fail with `
|
|
124
|
+
* (`createFileSystem`, name `cap-device-<deviceId>`) and then the instance on it; state lives
|
|
125
|
+
* in `device_instances`. A file system gone at the provider is never replaced silently:
|
|
126
|
+
* `fs_status` becomes `lost` and uses fail with `device.files_lost` until
|
|
127
127
|
* {@link resetFileSystem}.
|
|
128
|
-
* - **Leases** (phase C, spec §10, {@link SandboxLeases}), keyed by
|
|
128
|
+
* - **Leases** (phase C, spec §10, {@link SandboxLeases}), keyed by device id: using an
|
|
129
129
|
* instance recorded `running` with the current provider takes a **shared** lease, so up to
|
|
130
|
-
* `sandbox.maxConcurrentCommands` holders (all sessions of the
|
|
130
|
+
* `sandbox.maxConcurrentCommands` holders (all sessions of the device) run at once. Every
|
|
131
131
|
* lifecycle change (create, resume, rebuild, suspend, destroy, reset) takes the **exclusive**
|
|
132
132
|
* lease, alone; a caller that needs one on the use path sets the intent so new shared leases wait
|
|
133
133
|
* for it, and downgrades to a shared lease to run its own command once the instance runs.
|
|
@@ -140,9 +140,9 @@ export declare const sandboxUnavailable: () => ApiError;
|
|
|
140
140
|
* provider calls.
|
|
141
141
|
* - **Suspension and destruction**: the sweeps (`SandboxSweepJobs`, crons) call
|
|
142
142
|
* {@link suspendIdle} / {@link destroyInactive}; they try the exclusive lease once and skip an
|
|
143
|
-
*
|
|
143
|
+
* device with any holder; one past `maxRunningMinutes` gets the intent for a short window
|
|
144
144
|
* (about a second) so the suspension can get in when its commands end. Inactivity destroys only
|
|
145
|
-
* the instance (files kept); a deleted
|
|
145
|
+
* the instance (files kept); a deleted device or org loses its files too.
|
|
146
146
|
* - **Transparent recovery**: a suspended instance is resumed on next use; when `resume` returns
|
|
147
147
|
* `gone`, the instance was destroyed, or `fn` throws `SandboxGoneError` (retried once), a new
|
|
148
148
|
* instance is created on the kept files and `restarted` is true. Several holders hitting `gone`
|
|
@@ -150,7 +150,7 @@ export declare const sandboxUnavailable: () => ApiError;
|
|
|
150
150
|
* - **Takeover** (spec §10.5; environments spec §4.2): every holder records itself in
|
|
151
151
|
* `capk:sandbox-holders:<env>` (again before each `exec`) and its commands carry its lease token
|
|
152
152
|
* as `tag`. An acquirer that finds a record without a live lease (a crashed holder) kills only
|
|
153
|
-
* that holder's commands (`killTagged`): other conversations of the
|
|
153
|
+
* that holder's commands (`killTagged`): other conversations of the device may be running
|
|
154
154
|
* commands. `killAll` runs only under the exclusive lease, before the downgrade, on an instance
|
|
155
155
|
* this holder just resumed from `suspended` (nobody else can hold it; a provider that keeps
|
|
156
156
|
* memory across a pause brings old commands back); it also covers crashed holders' records,
|
|
@@ -160,16 +160,16 @@ export declare const sandboxUnavailable: () => ApiError;
|
|
|
160
160
|
* row's `created_at` (set by the fenced write after each `create`); the handle alone is the same
|
|
161
161
|
* after a rebuild on providers whose handle is the instance name (sandbox-docker).
|
|
162
162
|
*
|
|
163
|
-
* - **Provider per
|
|
164
|
-
* the
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* destroyed for inactivity; a deleted `@
|
|
163
|
+
* - **Provider per device** (environments spec §6): each call resolves the provider from
|
|
164
|
+
* the device's `devices.provider` ({@link providerForDevice}): a `device`
|
|
165
|
+
* device runs on the kernel-internal `@local` provider (never the cloud one), a cloud
|
|
166
|
+
* device on the loaded `sandbox@2` extension. A `@local` instance is never suspended or
|
|
167
|
+
* destroyed for inactivity; a deleted `@local` device (or one of a deleted org) is
|
|
168
168
|
* destroyed by the sweep like any other.
|
|
169
169
|
*
|
|
170
|
-
* Files kept by another provider than the current one make the
|
|
171
|
-
* (`
|
|
172
|
-
* provider is loaded ({@link SandboxProviders.forName}). Without the
|
|
170
|
+
* Files kept by another provider than the current one make the device unusable
|
|
171
|
+
* (`device.unavailable`) until that provider is back; deleting it still works while that
|
|
172
|
+
* provider is loaded ({@link SandboxProviders.forName}). Without the device's provider
|
|
173
173
|
* {@link availableFor} is false and uses throw `sandbox.unavailable` (503). No in-process state:
|
|
174
174
|
* replicas share it through PG and Redis.
|
|
175
175
|
*/
|
|
@@ -195,48 +195,48 @@ export declare class SandboxService {
|
|
|
195
195
|
private get pollMs();
|
|
196
196
|
/**
|
|
197
197
|
* Whether there is a cloud sandbox provider (a loaded `sandbox@2` extension). For gates that have
|
|
198
|
-
* no
|
|
198
|
+
* no device yet (tool listing, skill files); a call on a device asks
|
|
199
199
|
* {@link availableFor}.
|
|
200
200
|
*/
|
|
201
201
|
get cloudAvailable(): boolean;
|
|
202
|
-
/** Whether the
|
|
203
|
-
availableFor(
|
|
202
|
+
/** Whether the device's provider is there (`@local` registered, or a cloud provider). */
|
|
203
|
+
availableFor(deviceId: string): Promise<boolean>;
|
|
204
204
|
/**
|
|
205
|
-
* The provider the
|
|
206
|
-
* a missing row (or one of another org, with `orgId`) reads as a cloud
|
|
205
|
+
* The provider the device works with, read from its row ({@link providerForDevice});
|
|
206
|
+
* a missing row (or one of another org, with `orgId`) reads as a cloud device, whose use
|
|
207
207
|
* then fails as not found.
|
|
208
208
|
*/
|
|
209
209
|
private providerOf;
|
|
210
210
|
/** {@link providerOf}, or `sandbox.unavailable` (503) without it. */
|
|
211
211
|
private require;
|
|
212
|
-
/** Concurrent holders of one
|
|
212
|
+
/** Concurrent holders of one device (`sandbox.maxConcurrentCommands`, read at every use). */
|
|
213
213
|
private get cap();
|
|
214
214
|
/**
|
|
215
215
|
* The org's effective sandbox limits (spec §8.4): the deployment's `sandbox.limits`, egress
|
|
216
216
|
* narrowed by the org setting `sandboxEgress` (Ruling M19), cpu / memory per the super admin's
|
|
217
|
-
* org override (C19 / Ruling M16). Instances are created with them; phase 1
|
|
217
|
+
* org override (C19 / Ruling M16). Instances are created with them; phase 1 devices use
|
|
218
218
|
* them unchanged.
|
|
219
219
|
*/
|
|
220
220
|
orgLimits(orgId: string): Promise<SandboxLimits>;
|
|
221
221
|
/**
|
|
222
|
-
* The
|
|
222
|
+
* The device's instance state as shown to people (read only, no lease): `running` /
|
|
223
223
|
* `suspended` and the last use. No instance, a destroyed one, or one stuck in `creating` (being
|
|
224
224
|
* created, or a failed create the next use retries) is null.
|
|
225
225
|
*/
|
|
226
|
-
status(orgId: string,
|
|
226
|
+
status(orgId: string, deviceId: string): Promise<{
|
|
227
227
|
status: "running" | "suspended";
|
|
228
228
|
lastUsedAt: Date;
|
|
229
229
|
} | null>;
|
|
230
230
|
/**
|
|
231
|
-
* The instance the
|
|
231
|
+
* The instance the device records now (its `created_at`), while it has one that runs or is
|
|
232
232
|
* suspended; null otherwise. Read without a lease: a caller inside `withSandbox` reads the
|
|
233
233
|
* instance its own lease keeps.
|
|
234
234
|
*/
|
|
235
|
-
currentInstance(
|
|
235
|
+
currentInstance(deviceId: string): Promise<{
|
|
236
236
|
createdAt: Date;
|
|
237
237
|
} | null>;
|
|
238
238
|
/**
|
|
239
|
-
* Runs `fn` on the
|
|
239
|
+
* Runs `fn` on the device's instance only while it runs the instance created at
|
|
240
240
|
* `instance.createdAt` (background tasks, spec 2026-11-05-background-bash-design §4.3). It never
|
|
241
241
|
* creates, resumes or rebuilds one: an instance that is missing, suspended, being created or
|
|
242
242
|
* destroyed (or recorded with another provider) is `not_running`, one that records another
|
|
@@ -247,17 +247,17 @@ export declare class SandboxService {
|
|
|
247
247
|
* to `fn` aborts with `signal` or when the lease is lost. Errors of `fn` (`SandboxGoneError`
|
|
248
248
|
* too) are thrown as they are.
|
|
249
249
|
*/
|
|
250
|
-
ifRunning<T>(
|
|
250
|
+
ifRunning<T>(deviceId: string, instance: {
|
|
251
251
|
createdAt: Date;
|
|
252
252
|
}, fn: (p: TaggedProvider, h: SandboxHandle, signal: AbortSignal) => Promise<T>, signal?: AbortSignal): Promise<IfRunningResult<T>>;
|
|
253
253
|
/**
|
|
254
|
-
* A short lease on one path of the
|
|
254
|
+
* A short lease on one path of the device around the kernel's own read-modify-write of
|
|
255
255
|
* that file (spec §10.4); waits up to 30 s, then throws `SandboxPathBusyError`. Its `signal`
|
|
256
256
|
* aborts when a renewal finds it lost.
|
|
257
257
|
*/
|
|
258
|
-
pathLease(
|
|
258
|
+
pathLease(deviceId: string, path: string, signal: AbortSignal): Promise<SandboxPathLease>;
|
|
259
259
|
/**
|
|
260
|
-
* Runs `fn` on the
|
|
260
|
+
* Runs `fn` on the device's instance: take a lease → make sure the instance runs (file
|
|
261
261
|
* system, create / resume / rebuild, under the exclusive lease) → `fn` under a shared lease →
|
|
262
262
|
* update `last_used_at` → release.
|
|
263
263
|
* - Waiting longer than `sandbox.lockWaitSeconds` throws `sandbox.busy` (409); `signal` aborts
|
|
@@ -268,7 +268,7 @@ export declare class SandboxService {
|
|
|
268
268
|
* - When `fn` throws `SandboxGoneError` (the instance is gone) the instance is rebuilt on the
|
|
269
269
|
* kept files (or the one another holder rebuilt is taken) and `fn` runs once more with
|
|
270
270
|
* `restarted: true`; a second `gone` is thrown. Other errors are thrown as they are.
|
|
271
|
-
* - Lost files throw `
|
|
271
|
+
* - Lost files throw `device.files_lost` (409), also when `fn` throws
|
|
272
272
|
* `FileSystemGoneError` (the files are then recorded lost, ruling R24).
|
|
273
273
|
* - When `ctx.holderConversationId` last used another instance (another holder rebuilt it
|
|
274
274
|
* meanwhile), `info.restarted` is true, so it learns its processes are gone (final review m5).
|
|
@@ -278,7 +278,7 @@ export declare class SandboxService {
|
|
|
278
278
|
* Ruling R24: an operation on the held instance `e` found its file system gone. Records
|
|
279
279
|
* `fs_status = 'lost'` while the row still records that instance on its file system (the
|
|
280
280
|
* instance handle stays, so a reset still destroys it), moving the fence on, and returns
|
|
281
|
-
* `
|
|
281
|
+
* `device.files_lost` to throw. Uses then fail until the files are reset (a connected
|
|
282
282
|
* machine: until a new login, which resets the row). A failed write only logs.
|
|
283
283
|
*/
|
|
284
284
|
private filesGone;
|
|
@@ -288,7 +288,7 @@ export declare class SandboxService {
|
|
|
288
288
|
* holder last used another instance under the same reset count `e` is marked restarted (files
|
|
289
289
|
* kept); under another count it is marked `filesReset` instead. The count, not the provider's
|
|
290
290
|
* file system id, tells them apart: a provider may give the new file system the old id
|
|
291
|
-
* (sandbox-docker's volumes are named after the
|
|
291
|
+
* (sandbox-docker's volumes are named after the device). Best effort: a Redis error only
|
|
292
292
|
* logs.
|
|
293
293
|
*/
|
|
294
294
|
private seenBy;
|
|
@@ -335,7 +335,7 @@ export declare class SandboxService {
|
|
|
335
335
|
private kill;
|
|
336
336
|
/**
|
|
337
337
|
* Suspends running instances idle longer than `suspendAfterIdleMinutes` or running continuously
|
|
338
|
-
* longer than `maxRunningMinutes`. Skips
|
|
338
|
+
* longer than `maxRunningMinutes`. Skips a device with any holder; one past
|
|
339
339
|
* `maxRunningMinutes` gets the intent for one poll window (about a second) first. Returns how
|
|
340
340
|
* many it suspended. Called every minute by the `sandbox-suspend-idle` cron.
|
|
341
341
|
*/
|
|
@@ -343,30 +343,30 @@ export declare class SandboxService {
|
|
|
343
343
|
/**
|
|
344
344
|
* Destruction sweep: an instance unused for longer than `destroyAfterInactiveDays` is destroyed
|
|
345
345
|
* (the instance only; the file system is kept and the next use builds a new instance on it); an
|
|
346
|
-
*
|
|
347
|
-
* and its row is deleted (as {@link
|
|
348
|
-
* skipped. Inactivity never destroys a `@
|
|
349
|
-
* destroyed like any other while `@
|
|
346
|
+
* device that was deleted, or whose org was deleted, loses its instance and its file system
|
|
347
|
+
* and its row is deleted (as {@link destroyDevice} does). Devices with any holder are
|
|
348
|
+
* skipped. Inactivity never destroys a `@local` instance; a gone `@local` device is
|
|
349
|
+
* destroyed like any other while `@local` is registered. Returns how many it destroyed. Called
|
|
350
350
|
* hourly by the `sandbox-destroy-inactive` cron.
|
|
351
351
|
*/
|
|
352
352
|
destroyInactive(now: Date): Promise<number>;
|
|
353
353
|
/**
|
|
354
|
-
* Destroys the
|
|
355
|
-
* (
|
|
354
|
+
* Destroys the device's instance, then its file system, then deletes its instance row
|
|
355
|
+
* (device deletion, offboarding); nothing to do without a row. Waits for the exclusive lease
|
|
356
356
|
* (with intent, so running commands finish and new ones wait) up to 10 minutes. Without the
|
|
357
|
-
*
|
|
358
|
-
* retried, and the destruction sweep finishes a deleted
|
|
357
|
+
* device's provider it throws and the row stays, marked `sweep_failed_at` (the job is
|
|
358
|
+
* retried, and the destruction sweep finishes a deleted device once the provider is back).
|
|
359
359
|
* Files kept by another provider that is not loaded cannot be destroyed: it throws and the row
|
|
360
360
|
* stays.
|
|
361
361
|
*/
|
|
362
|
-
|
|
362
|
+
destroyDevice(deviceId: string): Promise<void>;
|
|
363
363
|
/**
|
|
364
|
-
* Starts the
|
|
365
|
-
* under the exclusive lease (waited for like {@link
|
|
364
|
+
* Starts the device over with empty files (after `device.files_lost`, or on request):
|
|
365
|
+
* under the exclusive lease (waited for like {@link destroyDevice}) destroys any instance and
|
|
366
366
|
* the file system (a `lost` one is only dropped), and records no file system; the next use
|
|
367
367
|
* creates a new one. Nothing to do without a row. Throws `sandbox.unavailable` without a provider.
|
|
368
368
|
*/
|
|
369
|
-
resetFileSystem(
|
|
369
|
+
resetFileSystem(deviceId: string): Promise<void>;
|
|
370
370
|
/**
|
|
371
371
|
* Under the exclusive lease (before the downgrade), on an instance just resumed from
|
|
372
372
|
* `suspended`: kills every command left in it (`killAll`), crashed holders' (`dead`, already
|
|
@@ -392,13 +392,13 @@ export declare class SandboxService {
|
|
|
392
392
|
private candidates;
|
|
393
393
|
/**
|
|
394
394
|
* One try at the exclusive lease: null → false; else runs `fn`. With `overdue` (past
|
|
395
|
-
* `maxRunningMinutes`) a busy
|
|
395
|
+
* `maxRunningMinutes`) a busy device gets the intent for about a second, so new commands
|
|
396
396
|
* wait briefly and the sweep gets in if the running ones end. Failures are warned, recorded in
|
|
397
397
|
* `sweep_failed_at` (sorted last next time) and return false.
|
|
398
398
|
*/
|
|
399
399
|
private tryLocked;
|
|
400
400
|
/**
|
|
401
|
-
* Under the exclusive lease: make the
|
|
401
|
+
* Under the exclusive lease: make the device's instance run. `gone`: the instance a holder
|
|
402
402
|
* found gone; when it is still the recorded one it is rebuilt, when another holder already
|
|
403
403
|
* rebuilt it the new one is used.
|
|
404
404
|
*/
|
|
@@ -407,14 +407,14 @@ export declare class SandboxService {
|
|
|
407
407
|
* Under the lease: fenced reset to `creating`, the file system when there is none
|
|
408
408
|
* (`createFileSystem`, its handle written fenced), then the instance on it, then a fenced write
|
|
409
409
|
* of the instance handle. `FileSystemGoneError` from `create` records `fs_status = 'lost'` and
|
|
410
|
-
* throws `
|
|
410
|
+
* throws `device.files_lost`. When the instance handle cannot be written (lease lost), the
|
|
411
411
|
* new instance is destroyed (best effort) before {@link SandboxLockLostError} is thrown.
|
|
412
412
|
*/
|
|
413
413
|
private create;
|
|
414
414
|
/**
|
|
415
|
-
* Destroys the file system another provider may have made under the
|
|
415
|
+
* Destroys the file system another provider may have made under the device's name without
|
|
416
416
|
* the kernel recording it (`destroyFileSystemByName`; not there is success). That provider not
|
|
417
|
-
* loaded, or a failure, is only warned (the files may leak there) so the
|
|
417
|
+
* loaded, or a failure, is only warned (the files may leak there) so the device stays
|
|
418
418
|
* usable; an abort is thrown.
|
|
419
419
|
*/
|
|
420
420
|
private dropUnrecordedFiles;
|
|
@@ -438,20 +438,20 @@ export declare class SandboxService {
|
|
|
438
438
|
private destroyFiles;
|
|
439
439
|
/**
|
|
440
440
|
* Under the lease: `instance` destroys the instance and marks the row `destroyed` (the file
|
|
441
|
-
* system stays); `
|
|
441
|
+
* system stays); `device` also destroys the file system and deletes the row.
|
|
442
442
|
*/
|
|
443
443
|
private destroyRow;
|
|
444
444
|
/** Due for suspension: made by this provider, running, and idle or running for too long. */
|
|
445
445
|
private suspendDue;
|
|
446
|
-
/** The provider of an instance row: an internal one (`@
|
|
446
|
+
/** The provider of an instance row: an internal one (`@local`) by name, else the cloud one. */
|
|
447
447
|
private rowProvider;
|
|
448
448
|
/**
|
|
449
|
-
* A row the idle sweeps may touch: not on a kernel-internal provider (`@
|
|
449
|
+
* A row the idle sweeps may touch: not on a kernel-internal provider (`@local` instances live on
|
|
450
450
|
* people's machines and are never suspended or destroyed for inactivity).
|
|
451
451
|
*/
|
|
452
452
|
private cloudRow;
|
|
453
|
-
/** The
|
|
454
|
-
private
|
|
453
|
+
/** The device was deleted, or its org was: the instance and the files go. */
|
|
454
|
+
private deviceGone;
|
|
455
455
|
/** Due for instance destruction: an instance (or a create in progress) unused for too long. */
|
|
456
456
|
private instanceDue;
|
|
457
457
|
}
|