@capybara-hq/kernel 0.1.0-rc.11 → 0.1.0-rc.13

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.
Files changed (220) hide show
  1. package/dist/admin/admin.schemas.d.ts +13 -0
  2. package/dist/agents/agent-lookup.d.ts +5 -0
  3. package/dist/agents/agent-lookup.js +15 -0
  4. package/dist/agents/agents.schemas.d.ts +3 -0
  5. package/dist/agents/agents.service.js +11 -1
  6. package/dist/agents/definition.d.ts +1 -0
  7. package/dist/agents/definition.js +7 -3
  8. package/dist/agents/org-templates.js +4 -0
  9. package/dist/agents/pending-connectors.service.js +1 -1
  10. package/dist/background/background.module.js +2 -2
  11. package/dist/background/launch-lock.d.ts +1 -1
  12. package/dist/background/launch-lock.js +1 -1
  13. package/dist/background/poll.job.d.ts +2 -2
  14. package/dist/background/poll.job.js +10 -10
  15. package/dist/background/stop.d.ts +1 -1
  16. package/dist/background/stop.js +3 -3
  17. package/dist/background/store.d.ts +5 -5
  18. package/dist/background/store.js +5 -5
  19. package/dist/background/tasks.service.d.ts +6 -6
  20. package/dist/background/tasks.service.js +13 -13
  21. package/dist/catalog/component-scope.controller.d.ts +18 -6
  22. package/dist/catalog/component-scope.controller.js +36 -13
  23. package/dist/catalog/component-scope.service.d.ts +11 -0
  24. package/dist/catalog/component-scope.service.js +4 -0
  25. package/dist/catalog/component-state.d.ts +8 -0
  26. package/dist/catalog/component-state.js +19 -11
  27. package/dist/catalog/marketplaces.service.d.ts +1 -1
  28. package/dist/catalog/plugin-import.js +4 -1
  29. package/dist/channels/channels.module.js +2 -2
  30. package/dist/channels/inbound.d.ts +8 -8
  31. package/dist/channels/inbound.js +31 -31
  32. package/dist/channels/phrases.d.ts +27 -27
  33. package/dist/channels/phrases.js +27 -27
  34. package/dist/config/docs.js +1 -1
  35. package/dist/config/schema.d.ts +2 -2
  36. package/dist/config/schema.js +21 -21
  37. package/dist/conversations/conversations.controller.d.ts +11 -11
  38. package/dist/conversations/conversations.controller.js +15 -15
  39. package/dist/conversations/conversations.module.d.ts +1 -1
  40. package/dist/conversations/conversations.module.js +7 -7
  41. package/dist/conversations/conversations.schemas.js +1 -1
  42. package/dist/conversations/conversations.service.d.ts +23 -14
  43. package/dist/conversations/conversations.service.js +28 -21
  44. package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
  45. package/dist/conversations/{environment-status.js → device-status.js} +18 -18
  46. package/dist/conversations/event-log.d.ts +1 -1
  47. package/dist/conversations/event-log.js +1 -1
  48. package/dist/conversations/events.d.ts +2 -1
  49. package/dist/conversations/events.js +2 -2
  50. package/dist/ctx/create-ctx.d.ts +10 -1
  51. package/dist/ctx/create-ctx.js +86 -25
  52. package/dist/db/kernel-schema.d.ts +39 -23
  53. package/dist/{environments → devices}/access.d.ts +19 -19
  54. package/dist/{environments → devices}/access.js +28 -28
  55. package/dist/devices/conversation-devices.d.ts +75 -0
  56. package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
  57. package/dist/devices/devices.controller.d.ts +36 -0
  58. package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
  59. package/dist/devices/devices.module.d.ts +5 -13
  60. package/dist/devices/devices.module.js +16 -29
  61. package/dist/devices/devices.schemas.d.ts +3 -0
  62. package/dist/devices/devices.schemas.js +14 -0
  63. package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
  64. package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
  65. package/dist/devices/dto.d.ts +13 -54
  66. package/dist/devices/dto.js +7 -39
  67. package/dist/devices/label.d.ts +11 -0
  68. package/dist/{environments → devices}/label.js +7 -7
  69. package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
  70. package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
  71. package/dist/errors.d.ts +27 -25
  72. package/dist/errors.js +27 -25
  73. package/dist/evals/recorded-tools.d.ts +2 -2
  74. package/dist/evals/recorded-tools.js +6 -6
  75. package/dist/extensions/admin-ops.js +1 -0
  76. package/dist/extensions/admin-view.js +2 -0
  77. package/dist/extensions/effective-config.d.ts +6 -0
  78. package/dist/extensions/effective-config.js +18 -7
  79. package/dist/extensions/host.d.ts +13 -2
  80. package/dist/extensions/host.js +24 -3
  81. package/dist/extensions/instance.d.ts +12 -1
  82. package/dist/extensions/instance.js +13 -0
  83. package/dist/extensions/permission-view.d.ts +10 -1
  84. package/dist/files/previewers.d.ts +1 -1
  85. package/dist/files/previewers.js +1 -1
  86. package/dist/http/api.module.js +10 -6
  87. package/dist/http/gateway-routes.d.ts +1 -1
  88. package/dist/http/gateway-routes.js +1 -1
  89. package/dist/identity/settings.d.ts +32 -0
  90. package/dist/identity/settings.js +26 -2
  91. package/dist/infra/config/kernel-config.service.js +4 -4
  92. package/dist/kernel.module.js +3 -3
  93. package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
  94. package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
  95. package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
  96. package/dist/{devices → local-devices}/device-auth.js +51 -53
  97. package/dist/local-devices/device-auth.module.d.ts +7 -0
  98. package/dist/{devices → local-devices}/device-auth.module.js +5 -5
  99. package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
  100. package/dist/{devices → local-devices}/device-routes.js +2 -2
  101. package/dist/local-devices/dto.d.ts +66 -0
  102. package/dist/local-devices/dto.js +44 -0
  103. package/dist/{devices → local-devices}/keys.d.ts +11 -11
  104. package/dist/{devices → local-devices}/keys.js +11 -11
  105. package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
  106. package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
  107. package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
  108. package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
  109. package/dist/local-devices/local-devices.module.d.ts +16 -0
  110. package/dist/local-devices/local-devices.module.js +44 -0
  111. package/dist/{devices → local-devices}/machines.d.ts +26 -26
  112. package/dist/{devices → local-devices}/machines.js +71 -71
  113. package/dist/{devices → local-devices}/relay.d.ts +15 -15
  114. package/dist/{devices → local-devices}/relay.js +55 -55
  115. package/dist/{devices → local-devices}/targets.d.ts +8 -8
  116. package/dist/{devices → local-devices}/targets.js +14 -14
  117. package/dist/orgs/offboarding.d.ts +6 -6
  118. package/dist/orgs/offboarding.js +12 -12
  119. package/dist/orgs/settings.service.d.ts +28 -0
  120. package/dist/orgs/settings.service.js +20 -1
  121. package/dist/platform/exclusions.js +48 -3
  122. package/dist/platform/operation.js +6 -2
  123. package/dist/platform/ops/admin.ops.js +8 -2
  124. package/dist/platform/ops/agents.ops.js +19 -6
  125. package/dist/platform/ops/conversations.ops.d.ts +3 -3
  126. package/dist/platform/ops/conversations.ops.js +9 -9
  127. package/dist/platform/ops/devices.ops.d.ts +26 -0
  128. package/dist/platform/ops/devices.ops.js +311 -0
  129. package/dist/platform/ops/org-settings.ops.js +2 -2
  130. package/dist/platform/ops/orgs.ops.js +1 -0
  131. package/dist/platform/ops/ui.ops.d.ts +8 -0
  132. package/dist/platform/ops/ui.ops.js +41 -0
  133. package/dist/platform/platform-ops.module.d.ts +3 -2
  134. package/dist/platform/platform-ops.module.js +8 -5
  135. package/dist/platform/route-schemas.js +6 -3
  136. package/dist/roles/gateway-role.d.ts +3 -3
  137. package/dist/roles/gateway-role.js +4 -4
  138. package/dist/roles/gateway.module.d.ts +1 -1
  139. package/dist/roles/gateway.module.js +5 -5
  140. package/dist/roles/worker.module.js +1 -1
  141. package/dist/runtime/context/build.d.ts +1 -1
  142. package/dist/runtime/context/build.js +6 -6
  143. package/dist/runtime/context/compaction.js +1 -1
  144. package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
  145. package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
  146. package/dist/runtime/maintenance.d.ts +1 -1
  147. package/dist/runtime/subagents/definition.d.ts +3 -2
  148. package/dist/runtime/subagents/definition.js +2 -1
  149. package/dist/sandbox/jobs.d.ts +13 -13
  150. package/dist/sandbox/jobs.js +20 -20
  151. package/dist/sandbox/leases.d.ts +9 -9
  152. package/dist/sandbox/leases.js +14 -14
  153. package/dist/sandbox/providers.d.ts +8 -8
  154. package/dist/sandbox/providers.js +8 -8
  155. package/dist/sandbox/sandbox.module.d.ts +1 -1
  156. package/dist/sandbox/sandbox.module.js +1 -1
  157. package/dist/sandbox/sandbox.service.d.ts +76 -76
  158. package/dist/sandbox/sandbox.service.js +230 -230
  159. package/dist/tools/builtins/builtin-tools.d.ts +2 -2
  160. package/dist/tools/builtins/builtin-tools.js +5 -5
  161. package/dist/tools/builtins/platform.js +1 -1
  162. package/dist/tools/builtins/sandbox/bash.js +6 -6
  163. package/dist/tools/builtins/sandbox/common.d.ts +25 -25
  164. package/dist/tools/builtins/sandbox/common.js +51 -51
  165. package/dist/tools/builtins/sandbox/edit.js +2 -2
  166. package/dist/tools/builtins/sandbox/index.d.ts +1 -1
  167. package/dist/tools/builtins/sandbox/index.js +1 -1
  168. package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
  169. package/dist/tools/builtins/sandbox/task-output.js +10 -10
  170. package/dist/tools/builtins/sandbox/task-stop.js +2 -2
  171. package/dist/tools/builtins/sandbox/write.js +2 -2
  172. package/dist/tools/builtins/skill-load.d.ts +1 -1
  173. package/dist/tools/builtins/skill-load.js +2 -2
  174. package/dist/tools/connector-account-policies.d.ts +51 -0
  175. package/dist/tools/connector-account-policies.js +165 -0
  176. package/dist/tools/connectors.controller.d.ts +35 -4
  177. package/dist/tools/connectors.controller.js +66 -7
  178. package/dist/tools/connectors.schemas.d.ts +11 -0
  179. package/dist/tools/connectors.schemas.js +11 -0
  180. package/dist/tools/connectors.service.d.ts +2 -0
  181. package/dist/tools/connectors.service.js +1 -0
  182. package/dist/tools/pipeline.d.ts +1 -1
  183. package/dist/tools/pipeline.js +4 -3
  184. package/dist/tools/policy.d.ts +23 -1
  185. package/dist/tools/policy.js +99 -24
  186. package/dist/tools/registry.d.ts +2 -2
  187. package/dist/tools/tools.module.js +6 -3
  188. package/dist/ui/admin-ui.controller.d.ts +56 -0
  189. package/dist/ui/admin-ui.controller.js +192 -0
  190. package/dist/ui/arrangement.d.ts +74 -0
  191. package/dist/ui/arrangement.js +98 -0
  192. package/dist/ui/embed-token.d.ts +2 -2
  193. package/dist/ui/embed-token.js +30 -5
  194. package/dist/ui/registry.d.ts +29 -14
  195. package/dist/ui/registry.js +31 -10
  196. package/dist/ui/slots.controller.d.ts +11 -0
  197. package/dist/ui/slots.controller.js +25 -0
  198. package/dist/ui/ui-stream.d.ts +20 -3
  199. package/dist/ui/ui-stream.js +25 -7
  200. package/dist/ui/ui.schemas.d.ts +66 -0
  201. package/dist/ui/ui.schemas.js +65 -0
  202. package/dist/ui/views.controller.d.ts +35 -49
  203. package/dist/ui/views.controller.js +48 -70
  204. package/dist/ui/views.d.ts +84 -18
  205. package/dist/ui/views.js +201 -38
  206. package/package.json +3 -3
  207. package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
  208. package/src/migrations/0105_devices_rename.sql +136 -0
  209. package/dist/devices/device-auth.module.d.ts +0 -7
  210. package/dist/environments/conversation-environments.d.ts +0 -75
  211. package/dist/environments/dto.d.ts +0 -25
  212. package/dist/environments/dto.js +0 -12
  213. package/dist/environments/environments.controller.d.ts +0 -36
  214. package/dist/environments/environments.module.d.ts +0 -8
  215. package/dist/environments/environments.module.js +0 -31
  216. package/dist/environments/environments.schemas.d.ts +0 -3
  217. package/dist/environments/environments.schemas.js +0 -14
  218. package/dist/environments/label.d.ts +0 -11
  219. package/dist/platform/ops/environments.ops.d.ts +0 -26
  220. 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 { EnvironmentInstancesTable } from "../db/kernel-schema.js";
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 environment had an instance before that is no longer there (destroyed after inactivity,
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 environment's files were reset since this holder last used it (on request, or after they
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
- environmentId: string;
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<EnvironmentInstancesTable>;
45
+ type Row = Selectable<DeviceInstancesTable>;
46
46
  type ExecArgs = Parameters<SandboxProvider["exec"]>[1];
47
47
  /**
48
- * One instance of an environment: its handle and the row's `created_at`, which the fenced write
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 environment now records another instance (a rebuild). */
83
+ /** The device now records another instance (a rebuild). */
84
84
  | {
85
85
  kind: "other_instance";
86
86
  };
87
- /** The provider-side name of an environment's file system and instance. */
88
- export declare const environmentResourceName: (environmentId: string) => string;
89
- /** The environment is missing, deleted, or not in the caller's org (404; ids cannot be probed). */
90
- export declare const environmentNotFound: () => ApiError;
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 environment's file system is gone at the provider (409); never replaced silently. On a
93
- * connected machine (`device`, details `[{ source: "device" }]`) the directory is the machine
94
- * owner's: `capybara-device logout`, then `login` into the environment, recreates it (ruling R24).
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 environmentFilesLost: (device?: boolean) => ApiError;
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 **environment** (spec
119
- * 2026-11-07-environments-design §4.2, §5.1): one file system kept until the environment is
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
- * environment (and their sub-agents) share both.
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-env-<environmentId>`) and then the instance on it; state lives
125
- * in `environment_instances`. A file system gone at the provider is never replaced silently:
126
- * `fs_status` becomes `lost` and uses fail with `environment.files_lost` until
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 environment id: using an
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 environment) run at once. Every
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
- * environment with any holder; one past `maxRunningMinutes` gets the intent for a short window
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 environment or org loses its files too.
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 environment may be running
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 environment** (environments spec §6): each call resolves the provider from
164
- * the environment's `environments.provider` ({@link providerForEnvironment}): a `device`
165
- * environment runs on the kernel-internal `@device` provider (never the cloud one), a cloud
166
- * environment on the loaded `sandbox@2` extension. A `@device` instance is never suspended or
167
- * destroyed for inactivity; a deleted `@device` environment (or one of a deleted org) is
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 environment unusable
171
- * (`environment.unavailable`) until that provider is back; deleting it still works while that
172
- * provider is loaded ({@link SandboxProviders.forName}). Without the environment's provider
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 environment yet (tool listing, skill files); a call on an environment asks
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 environment's provider is there (`@device` registered, or a cloud provider). */
203
- availableFor(environmentId: string): Promise<boolean>;
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 environment works with, read from its row ({@link providerForEnvironment});
206
- * a missing row (or one of another org, with `orgId`) reads as a cloud environment, whose use
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 environment (`sandbox.maxConcurrentCommands`, read at every use). */
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 environments use
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 environment's instance state as shown to people (read only, no lease): `running` /
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, environmentId: string): Promise<{
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 environment records now (its `created_at`), while it has one that runs or is
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(environmentId: string): Promise<{
235
+ currentInstance(deviceId: string): Promise<{
236
236
  createdAt: Date;
237
237
  } | null>;
238
238
  /**
239
- * Runs `fn` on the environment's instance only while it runs the instance created at
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>(environmentId: string, instance: {
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 environment around the kernel's own read-modify-write of
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(environmentId: string, path: string, signal: AbortSignal): Promise<SandboxPathLease>;
258
+ pathLease(deviceId: string, path: string, signal: AbortSignal): Promise<SandboxPathLease>;
259
259
  /**
260
- * Runs `fn` on the environment's instance: take a lease → make sure the instance runs (file
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 `environment.files_lost` (409), also when `fn` throws
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
- * `environment.files_lost` to throw. Uses then fail until the files are reset (a connected
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 environment). Best effort: a Redis error only
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 an environment with any holder; one past
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
- * environment that was deleted, or whose org was deleted, loses its instance and its file system
347
- * and its row is deleted (as {@link destroyEnvironment} does). Environments with any holder are
348
- * skipped. Inactivity never destroys a `@device` instance; a gone `@device` environment is
349
- * destroyed like any other while `@device` is registered. Returns how many it destroyed. Called
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 environment's instance, then its file system, then deletes its instance row
355
- * (environment deletion, offboarding); nothing to do without a row. Waits for the exclusive lease
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
- * environment's provider it throws and the row stays, marked `sweep_failed_at` (the job is
358
- * retried, and the destruction sweep finishes a deleted environment once the provider is back).
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
- destroyEnvironment(environmentId: string): Promise<void>;
362
+ destroyDevice(deviceId: string): Promise<void>;
363
363
  /**
364
- * Starts the environment over with empty files (after `environment.files_lost`, or on request):
365
- * under the exclusive lease (waited for like {@link destroyEnvironment}) destroys any instance and
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(environmentId: string): Promise<void>;
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 environment gets the intent for about a second, so new commands
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 environment's instance run. `gone`: the instance a holder
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 `environment.files_lost`. When the instance handle cannot be written (lease lost), the
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 environment's name without
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 environment stays
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); `environment` also destroys the file system and deletes the row.
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 (`@device`) by name, else the cloud 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 (`@device` instances live on
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 environment was deleted, or its org was: the instance and the files go. */
454
- private environmentGone;
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
  }