@capybara-hq/kernel 0.1.0-rc.68 → 0.1.0-rc.69

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 (215) hide show
  1. package/dist/admin/admin.module.js +2 -0
  2. package/dist/admin/health.service.d.ts +11 -4
  3. package/dist/admin/health.service.js +33 -17
  4. package/dist/background/poll.job.js +2 -2
  5. package/dist/background/tasks.service.d.ts +5 -5
  6. package/dist/background/tasks.service.js +9 -8
  7. package/dist/catalog/marketplaces.service.d.ts +1 -1
  8. package/dist/catalog/requests.service.js +1 -1
  9. package/dist/config/schema.d.ts +1 -1
  10. package/dist/config/schema.js +9 -9
  11. package/dist/conversations/conversations.controller.d.ts +8 -3
  12. package/dist/conversations/conversations.controller.js +8 -3
  13. package/dist/conversations/conversations.service.d.ts +33 -15
  14. package/dist/conversations/conversations.service.js +60 -10
  15. package/dist/conversations/events.d.ts +21 -41
  16. package/dist/conversations/events.js +57 -31
  17. package/dist/conversations/permission-profiles.controller.d.ts +6 -4
  18. package/dist/conversations/permission-profiles.service.d.ts +6 -4
  19. package/dist/ctx/create-ctx.d.ts +20 -1
  20. package/dist/ctx/create-ctx.js +77 -6
  21. package/dist/ctx/device-provider-check.d.ts +6 -2
  22. package/dist/ctx/device-provider-check.js +17 -2
  23. package/dist/db/kernel-schema.d.ts +10 -48
  24. package/dist/devices/access.d.ts +3 -4
  25. package/dist/devices/access.js +3 -4
  26. package/dist/devices/conversation-devices.d.ts +1 -3
  27. package/dist/devices/conversation-devices.js +2 -7
  28. package/dist/devices/device-projects.service.js +24 -29
  29. package/dist/devices/device-provider-selection.d.ts +5 -6
  30. package/dist/devices/device-provider-selection.js +8 -9
  31. package/dist/devices/devices.controller.d.ts +8 -21
  32. package/dist/devices/devices.controller.js +9 -34
  33. package/dist/devices/devices.module.js +6 -4
  34. package/dist/devices/devices.schemas.d.ts +1 -5
  35. package/dist/devices/devices.schemas.js +1 -5
  36. package/dist/devices/devices.service.d.ts +84 -147
  37. package/dist/devices/devices.service.js +134 -229
  38. package/dist/devices/dto.d.ts +5 -32
  39. package/dist/devices/dto.js +5 -37
  40. package/dist/devices/errors.d.ts +6 -5
  41. package/dist/devices/errors.js +7 -8
  42. package/dist/devices/project-rules.d.ts +9 -11
  43. package/dist/devices/project-rules.js +7 -7
  44. package/dist/devices/working-root.d.ts +3 -6
  45. package/dist/devices/working-root.js +3 -8
  46. package/dist/dial-in/access.d.ts +23 -0
  47. package/dist/dial-in/access.js +64 -0
  48. package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
  49. package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
  50. package/dist/dial-in/auth.module.d.ts +7 -0
  51. package/dist/dial-in/auth.module.js +27 -0
  52. package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
  53. package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
  54. package/dist/dial-in/dial-in.module.d.ts +9 -0
  55. package/dist/dial-in/dial-in.module.js +37 -0
  56. package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
  57. package/dist/{local-devices → dial-in}/dto.js +14 -2
  58. package/dist/dial-in/envelope.d.ts +95 -0
  59. package/dist/dial-in/envelope.js +89 -0
  60. package/dist/dial-in/gateway.d.ts +214 -0
  61. package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
  62. package/dist/dial-in/handlers.d.ts +47 -0
  63. package/dist/dial-in/handlers.js +84 -0
  64. package/dist/dial-in/machines.d.ts +155 -0
  65. package/dist/dial-in/machines.js +383 -0
  66. package/dist/dial-in/relay.d.ts +135 -0
  67. package/dist/dial-in/relay.js +444 -0
  68. package/dist/dial-in/relay.module.d.ts +7 -0
  69. package/dist/dial-in/relay.module.js +24 -0
  70. package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
  71. package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
  72. package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
  73. package/dist/{local-devices → dial-in}/targets.js +3 -48
  74. package/dist/errors.d.ts +8 -27
  75. package/dist/errors.js +8 -27
  76. package/dist/extensions/bootstrap.d.ts +5 -0
  77. package/dist/extensions/bootstrap.js +10 -1
  78. package/dist/extensions/extensions.module.js +6 -0
  79. package/dist/extensions/host.d.ts +6 -0
  80. package/dist/extensions/host.js +12 -2
  81. package/dist/extensions/permission-set.d.ts +15 -1
  82. package/dist/extensions/permission-set.js +11 -1
  83. package/dist/extensions/permission-view.d.ts +1 -1
  84. package/dist/extensions/permission-view.js +4 -1
  85. package/dist/http/api.module.js +4 -4
  86. package/dist/http/gateway-routes.d.ts +1 -1
  87. package/dist/http/gateway-routes.js +1 -1
  88. package/dist/http/meta.controller.js +1 -1
  89. package/dist/identity/settings.d.ts +1 -1
  90. package/dist/identity/settings.js +6 -8
  91. package/dist/infra/config/kernel-config.service.js +2 -2
  92. package/dist/infra/outbox/registry.d.ts +0 -14
  93. package/dist/infra/outbox/registry.js +0 -15
  94. package/dist/infra/throttler/named-throttlers.d.ts +1 -1
  95. package/dist/infra/throttler/named-throttlers.js +1 -1
  96. package/dist/kernel.module.js +0 -3
  97. package/dist/orgs/settings.service.js +5 -10
  98. package/dist/overrides.d.ts +0 -4
  99. package/dist/overrides.js +0 -2
  100. package/dist/platform/exclusions.js +5 -5
  101. package/dist/platform/ops/admin.ops.js +1 -1
  102. package/dist/platform/ops/conversations.ops.js +5 -2
  103. package/dist/platform/ops/devices.ops.js +11 -24
  104. package/dist/platform/ops/inbox.ops.js +1 -1
  105. package/dist/roles/gateway-role.d.ts +3 -3
  106. package/dist/roles/gateway-role.js +4 -4
  107. package/dist/roles/gateway.module.d.ts +1 -1
  108. package/dist/roles/gateway.module.js +5 -5
  109. package/dist/runtime/context/device-paths.d.ts +4 -1
  110. package/dist/runtime/context/permission-profile.js +5 -5
  111. package/dist/runtime/maintenance.d.ts +2 -5
  112. package/dist/runtime/maintenance.js +9 -19
  113. package/dist/runtime/project/knowledge.js +4 -5
  114. package/dist/runtime/project/knowledge.service.js +2 -1
  115. package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
  116. package/dist/sandbox/cloud-permission-snapshot.js +1 -3
  117. package/dist/sandbox/device-reports.d.ts +74 -14
  118. package/dist/sandbox/device-reports.js +190 -33
  119. package/dist/sandbox/device-reports.module.d.ts +7 -0
  120. package/dist/sandbox/device-reports.module.js +25 -0
  121. package/dist/sandbox/device-sandbox.d.ts +39 -41
  122. package/dist/sandbox/device-sandbox.js +44 -83
  123. package/dist/sandbox/kernel-read.d.ts +2 -2
  124. package/dist/sandbox/legacy-retirement.d.ts +11 -59
  125. package/dist/sandbox/legacy-retirement.js +34 -186
  126. package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
  127. package/dist/sandbox/legacy-retirement.module.js +2 -2
  128. package/dist/sandbox/managed-device-context.d.ts +16 -4
  129. package/dist/sandbox/managed-device-context.js +25 -8
  130. package/dist/sandbox/managed-device-context.module.js +4 -0
  131. package/dist/sandbox/modes.d.ts +3 -12
  132. package/dist/sandbox/modes.js +2 -14
  133. package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
  134. package/dist/{local-devices → sandbox}/network-grants.js +4 -49
  135. package/dist/sandbox/operation-authority-types.d.ts +2 -1
  136. package/dist/sandbox/operation-authority.d.ts +6 -20
  137. package/dist/sandbox/operation-authority.js +43 -104
  138. package/dist/sandbox/operation-authority.module.js +1 -1
  139. package/dist/sandbox/operation-intents.d.ts +4 -1
  140. package/dist/sandbox/operation-intents.js +11 -2
  141. package/dist/sandbox/operation-reconcile.job.js +2 -4
  142. package/dist/sandbox/permission-availability.d.ts +6 -7
  143. package/dist/sandbox/permission-availability.js +7 -10
  144. package/dist/sandbox/permission-call-grants.d.ts +2 -1
  145. package/dist/sandbox/permission-call-grants.js +1 -7
  146. package/dist/sandbox/permission-call-types.d.ts +4 -4
  147. package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
  148. package/dist/sandbox/permission-ceiling-writes.js +8 -35
  149. package/dist/sandbox/permission-config-publication.d.ts +9 -1
  150. package/dist/sandbox/permission-config-publication.js +29 -21
  151. package/dist/sandbox/permission-context-types.d.ts +17 -10
  152. package/dist/sandbox/permission-facts.d.ts +98 -95
  153. package/dist/sandbox/permission-facts.js +160 -314
  154. package/dist/sandbox/permission-instance-writes.d.ts +23 -37
  155. package/dist/sandbox/permission-instance-writes.js +44 -121
  156. package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
  157. package/dist/sandbox/permission-runtime-reports.js +105 -122
  158. package/dist/sandbox/providers.d.ts +26 -38
  159. package/dist/sandbox/providers.js +36 -18
  160. package/dist/sandbox/request-not-sent.d.ts +2 -13
  161. package/dist/sandbox/request-not-sent.js +2 -13
  162. package/dist/sandbox/review/permission-candidate.d.ts +13 -8
  163. package/dist/sandbox/review/permission-candidate.js +38 -48
  164. package/dist/sandbox/sandbox.module.js +7 -3
  165. package/dist/sandbox/sandbox.service.d.ts +49 -59
  166. package/dist/sandbox/sandbox.service.js +139 -259
  167. package/dist/schedules/fire.d.ts +15 -6
  168. package/dist/schedules/fire.js +27 -13
  169. package/dist/schedules/grant-rules.js +1 -1
  170. package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
  171. package/dist/schedules/scheduled-tasks.service.js +1 -4
  172. package/dist/schedules/schedules.module.js +5 -3
  173. package/dist/skills/invoke.d.ts +1 -1
  174. package/dist/skills/invoke.js +2 -3
  175. package/dist/tools/approvals.service.d.ts +8 -5
  176. package/dist/tools/approvals.service.js +5 -5
  177. package/dist/tools/builtins/sandbox/bash.js +1 -2
  178. package/dist/tools/builtins/sandbox/common.d.ts +15 -9
  179. package/dist/tools/builtins/sandbox/common.js +37 -38
  180. package/dist/tools/network-asks.d.ts +19 -22
  181. package/dist/tools/network-asks.js +15 -21
  182. package/dist/tools/pipeline.d.ts +6 -7
  183. package/dist/tools/pipeline.js +17 -21
  184. package/dist/tools/tools.module.js +3 -7
  185. package/package.json +3 -4
  186. package/src/migrations/0177_dial_in_contract.sql +32 -0
  187. package/dist/local-devices/device-auth.module.d.ts +0 -7
  188. package/dist/local-devices/device-auth.module.js +0 -25
  189. package/dist/local-devices/device-policy.service.d.ts +0 -213
  190. package/dist/local-devices/device-policy.service.js +0 -605
  191. package/dist/local-devices/instance-bindings.d.ts +0 -82
  192. package/dist/local-devices/instance-bindings.js +0 -307
  193. package/dist/local-devices/local-device-gateway.d.ts +0 -153
  194. package/dist/local-devices/local-device-provider.d.ts +0 -122
  195. package/dist/local-devices/local-device-provider.js +0 -326
  196. package/dist/local-devices/local-devices.module.d.ts +0 -31
  197. package/dist/local-devices/local-devices.module.js +0 -100
  198. package/dist/local-devices/machines.d.ts +0 -211
  199. package/dist/local-devices/machines.js +0 -766
  200. package/dist/local-devices/owner-report.d.ts +0 -81
  201. package/dist/local-devices/owner-report.js +0 -150
  202. package/dist/local-devices/owner-reports.d.ts +0 -48
  203. package/dist/local-devices/owner-reports.js +0 -208
  204. package/dist/local-devices/policy-op-jobs.d.ts +0 -15
  205. package/dist/local-devices/policy-op-jobs.js +0 -12
  206. package/dist/local-devices/policy-summary.d.ts +0 -102
  207. package/dist/local-devices/policy-summary.js +0 -155
  208. package/dist/local-devices/relay.d.ts +0 -166
  209. package/dist/local-devices/relay.js +0 -559
  210. package/dist/tools/device-op-resolver.d.ts +0 -34
  211. package/dist/tools/device-op-resolver.js +0 -120
  212. /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
  213. /package/dist/{local-devices → dial-in}/keys.js +0 -0
  214. /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
  215. /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
@@ -1110,8 +1110,8 @@ type InstanceHandle = ColumnType<{
1110
1110
  [k: string]: unknown;
1111
1111
  } | null, string | null | undefined, string | null>;
1112
1112
  /**
1113
- * 0088_environments.sql, renamed in 0105: a device. A cloud device is one instance plus a kept file
1114
- * system; a local device is a person's machine (device_machines).
1113
+ * 0088_environments.sql, renamed in 0105: a device, served by its provider (`provider`): one
1114
+ * instance plus a kept file system; a dial-in device's machine signs in (device_machines).
1115
1115
  */
1116
1116
  export interface DevicesTable {
1117
1117
  id: string;
@@ -1120,8 +1120,6 @@ export interface DevicesTable {
1120
1120
  owner_account_id: string;
1121
1121
  name: ColumnType<string | null, string | null | undefined, string | null>;
1122
1122
  is_default: ColumnType<boolean, boolean | undefined, boolean>;
1123
- /** 0093, renamed in 0105: `local` is a person's machine (device_machines). */
1124
- source: "cloud" | "local";
1125
1123
  provider: ColumnType<string | null, string | null | undefined, string | null>;
1126
1124
  /** 0096: the provider a demoted default was demoted from; null for every other device. */
1127
1125
  demoted_from_provider: ColumnType<string | null, string | null | undefined, string | null>;
@@ -1140,8 +1138,10 @@ export interface DevicesTable {
1140
1138
  /** 0165: a cloud device's allowlist hosts (a JSON array), used while the mode is `allowlist`. */
1141
1139
  network_hosts: ColumnType<string[], string | undefined, string>;
1142
1140
  /**
1143
- * 0176: what the device's provider last reported (a `DeviceReport` as JSON; read back through
1144
- * `parseDeviceReport`, see `DeviceReports`); null until the first create or resume stores one.
1141
+ * 0176: what the device's provider last reported (a `DeviceReport` as JSON, with the instance's
1142
+ * permission support under the key `support` or null; read back through `parseDeviceReport`,
1143
+ * see `DeviceReports`); null until the first report is stored. Its `revision` drives the device
1144
+ * authority epoch.
1145
1145
  */
1146
1146
  report: ColumnType<unknown, string | null | undefined, string | null>;
1147
1147
  /** 0176: when {@link report} was stored. */
@@ -1186,12 +1186,13 @@ export interface DeviceInstancesTable {
1186
1186
  instance_limits: ColumnType<unknown | null, string | null | undefined, string | null>;
1187
1187
  }
1188
1188
  /**
1189
- * 0093_connected_environments.sql, renamed in 0105: the machine of a local device. At most one
1190
- * unrevoked row per device; revoking sets `revoked_at` and keeps the row.
1189
+ * 0093_connected_environments.sql, renamed in 0105: the signed-in machine of a dial-in device. At
1190
+ * most one unrevoked row per device; revoking sets `revoked_at` and keeps the row. 0177 dropped
1191
+ * what the kernel's former local provider kept here (a provider keeps its own machine facts).
1191
1192
  */
1192
1193
  export interface DeviceMachinesTable {
1193
1194
  id: Generated<string>;
1194
- /** 0157: the machine's current OS boot identity (the latest first seen); null: none reported. */
1195
+ /** 0157: the OS boot identity its last connection reported; null: none reported. */
1195
1196
  boot_id: ColumnType<string | null, string | null | undefined, string | null>;
1196
1197
  org_id: string;
1197
1198
  device_id: string;
@@ -1202,23 +1203,9 @@ export interface DeviceMachinesTable {
1202
1203
  os: string;
1203
1204
  arch: string;
1204
1205
  program_version: ColumnType<string | null, string | null | undefined, string | null>;
1205
- mode: ColumnType<"os" | "docker" | null, "os" | "docker" | null | undefined, "os" | "docker" | null>;
1206
- /** The roots the program exposes, as it reported them (a JSON array). */
1207
- roots: ColumnType<unknown, string | null | undefined, string | null>;
1208
- session_isolation: ColumnType<boolean, boolean | undefined, boolean>;
1209
1206
  last_seen_at: TsNullable;
1210
1207
  created_at: Ts;
1211
1208
  revoked_at: TsNullable;
1212
- /** 0114: the features the program reported in its hello (`networkReport`, `policyOp`). */
1213
- features: ColumnType<string[], string[] | undefined, string[]>;
1214
- /** 0114: the program's local network policy summary (hello, refreshed by each `policy` op). */
1215
- local_policy: ColumnType<unknown | null, string | null | undefined, string | null>;
1216
- /** 0118: the `policy` ops sent whose answer is not recorded yet (`PendingPolicyOp[]`). */
1217
- pending_policy_ops: ColumnType<unknown, string | undefined, string>;
1218
- /** 0133: the owner's home directory the program reported in its hello; null when not reported. */
1219
- home: ColumnType<string | null, string | null | undefined, string | null>;
1220
- /** 0156: the authenticated owner report (`StoredOwnerReport`, B2); null before any. */
1221
- owner_report: ColumnType<unknown | null, string | null | undefined, string | null>;
1222
1209
  }
1223
1210
  /** 0133: a device's projects (project root design §4.1), written only by the kernel. */
1224
1211
  export interface DeviceProjectsTable {
@@ -1598,20 +1585,6 @@ export interface DeviceGenerationHighWaterTable {
1598
1585
  high_water_ms: ColumnType<string, string | number, string | number>;
1599
1586
  updated_at: Ts;
1600
1587
  }
1601
- export interface DeviceInstanceBindingsTable {
1602
- device_id: string;
1603
- instance_generation: string;
1604
- binding_id: string;
1605
- provider: string;
1606
- previous_generation: string | null;
1607
- status: "awaiting-device" | "installed";
1608
- machine_id: string | null;
1609
- runtime_identity: ColumnType<PermissionRuntimeIdentity | null, string | null | undefined, string | null>;
1610
- created_at: Ts;
1611
- installed_at: TsNullable;
1612
- /** Migration 0168: the device connection whose bind answer installed it. */
1613
- installed_connection_id: string | null;
1614
- }
1615
1588
  export interface LegacyLaunchFreezeTable {
1616
1589
  id: "platform";
1617
1590
  frozen_at: Generated<Date>;
@@ -1647,13 +1620,6 @@ export interface DeviceRetirementMembersTable {
1647
1620
  settled: ColumnType<boolean, boolean | undefined, boolean>;
1648
1621
  created_at: Generated<Date>;
1649
1622
  }
1650
- export interface DeviceMachineBootsTable {
1651
- machine_id: string;
1652
- boot_id: string;
1653
- /** bigserial: read as a decimal string. */
1654
- seq: ColumnType<string, string | number | undefined, never>;
1655
- first_seen_at: Generated<Date>;
1656
- }
1657
1623
  export interface DeviceInstanceDestructionsTable {
1658
1624
  device_id: string;
1659
1625
  provider: string;
@@ -1679,16 +1645,12 @@ export interface KernelDatabase {
1679
1645
  device_permission_reports: DevicePermissionReportsTable;
1680
1646
  /** Migration 0155: per-device generation high-water mark; outlives instance rows. */
1681
1647
  device_generation_high_water: DeviceGenerationHighWaterTable;
1682
- /** Migration 0155: post-commit binding of a local instance generation. */
1683
- device_instance_bindings: DeviceInstanceBindingsTable;
1684
1648
  /** Migration 0157: the durable legacy-launch freeze (one row, never removed). */
1685
1649
  legacy_launch_freeze: LegacyLaunchFreezeTable;
1686
1650
  /** Migration 0157: the physical no-reuse obligation of one old instance incarnation. */
1687
1651
  device_retirement_obligations: DeviceRetirementObligationsTable;
1688
1652
  /** Migration 0157: what put a retirement obligation there. */
1689
1653
  device_retirement_members: DeviceRetirementMembersTable;
1690
- /** Migration 0157: the OS boot identities a machine reported, in the order first seen. */
1691
- device_machine_boots: DeviceMachineBootsTable;
1692
1654
  /** Migration 0157: provider-confirmed destruction of a cloud instance incarnation. */
1693
1655
  device_instance_destructions: DeviceInstanceDestructionsTable;
1694
1656
  sandbox_operation_intents: SandboxOperationIntentsTable;
@@ -24,10 +24,9 @@ export declare class DeviceAccess {
24
24
  * The device if `accountId` may use it in `orgId` now: `device.not_found` when it is
25
25
  * missing, deleted, in another org or someone else's; `device.unavailable` when it has no
26
26
  * provider, its provider (`devices.provider`, fixed at creation) does not serve the org now
27
- * ({@link DeviceProviderSelection.isOnInOrg}: off in the org, not installed, invalid config;
28
- * `@local` not registered), or its instance row names another provider (never written by this
29
- * kernel). A local device is usable while `@local` is registered: whether its machine is online
30
- * is the relay's concern, not access.
27
+ * ({@link DeviceProviderSelection.isOnInOrg}: off in the org, not installed, invalid config),
28
+ * or its instance row names another provider (never written by this kernel). Whether a dial-in
29
+ * device's machine is online is its provider's concern, not access.
31
30
  */
32
31
  usable(orgId: string, accountId: string, deviceId: string): Promise<{
33
32
  id: string;
@@ -40,10 +40,9 @@ let DeviceAccess = class DeviceAccess {
40
40
  * The device if `accountId` may use it in `orgId` now: `device.not_found` when it is
41
41
  * missing, deleted, in another org or someone else's; `device.unavailable` when it has no
42
42
  * provider, its provider (`devices.provider`, fixed at creation) does not serve the org now
43
- * ({@link DeviceProviderSelection.isOnInOrg}: off in the org, not installed, invalid config;
44
- * `@local` not registered), or its instance row names another provider (never written by this
45
- * kernel). A local device is usable while `@local` is registered: whether its machine is online
46
- * is the relay's concern, not access.
43
+ * ({@link DeviceProviderSelection.isOnInOrg}: off in the org, not installed, invalid config),
44
+ * or its instance row names another provider (never written by this kernel). Whether a dial-in
45
+ * device's machine is online is its provider's concern, not access.
47
46
  */
48
47
  async usable(orgId, accountId, deviceId) {
49
48
  const row = await this.db
@@ -83,14 +83,12 @@ export declare class ConversationDevices {
83
83
  private readonly devices;
84
84
  private readonly facts;
85
85
  private readonly ceilings;
86
- constructor(db: KernelDb, txHost: TransactionHost, selection: Pick<DeviceProviderSelection, "onInOrg" | "isOnInOrg" | "defaultFor">, access: Pick<DeviceAccess, "usable">, devices: Pick<DevicesService, "ensureDefault" | "modeLevel" | "projectReach">, facts: Pick<PermissionFacts, "readWorkingFacts" | "workingProject">, ceilings: PermissionCeilingWrites);
86
+ constructor(db: KernelDb, txHost: TransactionHost, selection: Pick<DeviceProviderSelection, "onInOrg" | "isOnInOrg" | "defaultFor">, access: Pick<DeviceAccess, "usable">, devices: Pick<DevicesService, "ensureDefault" | "modeLevel">, facts: Pick<PermissionFacts, "readWorkingFacts" | "workingProject">, ceilings: PermissionCeilingWrites);
87
87
  /**
88
88
  * The mode and network a call in the device runs at now ({@link DevicesService.modeLevel}),
89
89
  * recorded for the model in `device_paths` (auto mode spec §4.2).
90
90
  */
91
91
  modeLevel(orgId: string, deviceId: string): Promise<DeviceModeLevel | null>;
92
- /** How far restricted work may root outside the workspace now (B2; {@link DevicesService.projectReach}). */
93
- projectReach(orgId: string, deviceId: string): Promise<"workspace" | "os-user">;
94
92
  /**
95
93
  * The facts the command review reads for a call in the conversation tree rooted at
96
94
  * `rootConversationId` (auto mode spec §5.1): the device `forTool` would enter, its mode and
@@ -63,10 +63,6 @@ let ConversationDevices = class ConversationDevices {
63
63
  modeLevel(orgId, deviceId) {
64
64
  return this.devices.modeLevel(orgId, deviceId);
65
65
  }
66
- /** How far restricted work may root outside the workspace now (B2; {@link DevicesService.projectReach}). */
67
- projectReach(orgId, deviceId) {
68
- return this.devices.projectReach(orgId, deviceId);
69
- }
70
66
  /**
71
67
  * The facts the command review reads for a call in the conversation tree rooted at
72
68
  * `rootConversationId` (auto mode spec §5.1): the device `forTool` would enter, its mode and
@@ -95,7 +91,7 @@ let ConversationDevices = class ConversationDevices {
95
91
  return null;
96
92
  throw e;
97
93
  }
98
- const [device, level, reach] = await Promise.all([
94
+ const [device, level] = await Promise.all([
99
95
  this.db
100
96
  .selectFrom("devices")
101
97
  .select("name")
@@ -103,7 +99,6 @@ let ConversationDevices = class ConversationDevices {
103
99
  .where("org_id", "=", orgId)
104
100
  .executeTakeFirst(),
105
101
  this.modeLevel(orgId, deviceId),
106
- this.projectReach(orgId, deviceId),
107
102
  ]);
108
103
  if (device === undefined)
109
104
  return null;
@@ -118,7 +113,7 @@ let ConversationDevices = class ConversationDevices {
118
113
  workspace,
119
114
  home,
120
115
  deviceHome: homeOf(workspace),
121
- workingRoot: workingRootOf(project, { mode, reach, workspace, home }),
116
+ workingRoot: workingRootOf(project, { workspace, home }),
122
117
  };
123
118
  }
124
119
  /**
@@ -8,24 +8,25 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { posix } from "node:path";
11
- import { DeviceProtocolError, isDeviceProjectName, isFileSystemGoneError, isProjectPathRefusedError, isSandboxGoneError, isSandboxScopeDeniedError, MAX_DEVICE_SCAN_RESULTS, ToolError, validateSandboxPathShape, } from "@capybara-hq/plugin-sdk";
11
+ import { isDeviceOfflineError, isDeviceProjectName, isFileSystemGoneError, isProjectPathRefusedError, isSandboxGoneError, isSandboxScopeDeniedError, MAX_DEVICE_SCAN_RESULTS, ToolError, validateSandboxPathShape, } from "@capybara-hq/plugin-sdk";
12
+ import { DeviceProtocolError } from "@capybara-hq/plugin-sdk/device-protocol";
12
13
  import { Inject, Injectable, Optional } from "@nestjs/common";
13
14
  import { sql } from "kysely";
15
+ import { deviceOffline } from "../dial-in/relay.js";
14
16
  import { ApiError } from "../errors.js";
15
17
  import { audit } from "../identity/audit.js";
16
18
  import { KernelDb } from "../infra/database/kernel-db.js";
17
19
  import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
18
20
  import { Transactional } from "../infra/database/transactional.decorator.js";
19
21
  import { KERNEL_LOGGER } from "../infra/tokens.js";
20
- import { projectsUnsupported } from "../local-devices/local-device-provider.js";
21
- import { POLICY_REFUSAL_PREFIX } from "../local-devices/relay.js";
22
22
  import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
23
23
  import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
24
24
  import { PermissionFacts } from "../sandbox/permission-facts.js";
25
25
  import { deviceNotFound, SandboxService } from "../sandbox/sandbox.service.js";
26
26
  import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
27
27
  import { DeviceAccess } from "./access.js";
28
- import { baseOf, clipped, homeUnknown, nameInvalid, nameTaken, outsideMode, tooBroad, withinMode, } from "./project-rules.js";
28
+ import { projectsUnsupported } from "./errors.js";
29
+ import { baseOf, clipped, nameInvalid, nameTaken, outsideMode, tooBroad, withinMode, } from "./project-rules.js";
29
30
  // a path above the owner's home is never stored as a project: the working root would fall back for
30
31
  // it anyway (project root §4.3), so both use the one rule; the home itself may be one
31
32
  import { aboveHome } from "./working-root.js";
@@ -128,14 +129,12 @@ let DeviceProjectsService = class DeviceProjectsService {
128
129
  if (!scope.supported) {
129
130
  return { candidates: [], mode: scope.mode, base: baseOf(scope), supported: false };
130
131
  }
131
- if (baseOf(scope) === null)
132
- throw homeUnknown();
133
132
  return this.onDevice(orgId, accountId, deviceId, scope, signal, async (r, sig) => {
134
133
  const workspace = r.workspace;
135
134
  const base = baseOf(scope, workspace);
136
135
  const scan = r.scan;
137
136
  if (scan === undefined)
138
- throw projectsUnsupported(false);
137
+ throw projectsUnsupported();
139
138
  let found;
140
139
  try {
141
140
  found = await scan(base, sig);
@@ -176,9 +175,7 @@ let DeviceProjectsService = class DeviceProjectsService {
176
175
  await this.access.usable(orgId, accountId, deviceId);
177
176
  const scope = await this.scope(orgId, accountId, deviceId);
178
177
  if (!scope.supported)
179
- throw projectsUnsupported(scope.source === "local");
180
- if (baseOf(scope) === null)
181
- throw homeUnknown();
178
+ throw projectsUnsupported();
182
179
  if (name !== undefined && !isDeviceProjectName(name))
183
180
  throw nameInvalid(name);
184
181
  const rows = await this.db
@@ -205,12 +202,10 @@ let DeviceProjectsService = class DeviceProjectsService {
205
202
  // a path too broad for any project is refused before the device is leased (a cloud device
206
203
  // started): against the last known base; the held instance's base is checked again inside
207
204
  const early = baseOf(scope);
208
- if (early !== null) {
209
- const path = trimSlash(posix.normalize(posix.join(early, input.path === "" ? "." : input.path)));
210
- // outside the mode stays the device-side refusal it is (the held workspace decides it)
211
- if (withinMode(scope, path) && aboveHome(path, scope.home))
212
- throw tooBroad(path);
213
- }
205
+ const path = trimSlash(posix.normalize(posix.join(early, input.path === "" ? "." : input.path)));
206
+ // outside the mode stays the device-side refusal it is (the held workspace decides it)
207
+ if (withinMode(scope, path) && aboveHome(path, scope.home))
208
+ throw tooBroad(path);
214
209
  const resolved = await this.onDevice(orgId, accountId, deviceId, scope, signal, async (r, sig) => {
215
210
  const path = resolve(scope, r.workspace, input.path);
216
211
  const name = input.name ?? posix.basename(path);
@@ -218,7 +213,7 @@ let DeviceProjectsService = class DeviceProjectsService {
218
213
  throw nameInvalid(name);
219
214
  const list = r.list;
220
215
  if (list === undefined)
221
- throw projectsUnsupported(false);
216
+ throw projectsUnsupported();
222
217
  let answer;
223
218
  try {
224
219
  answer = await list(path, 1, sig);
@@ -382,6 +377,9 @@ let DeviceProjectsService = class DeviceProjectsService {
382
377
  catch (e) {
383
378
  if (e instanceof ApiError)
384
379
  throw e;
380
+ // a dial-in device's machine that is not connected: the relay's offline error
381
+ if (isDeviceOfflineError(e))
382
+ throw deviceOffline();
385
383
  if (e instanceof SandboxProviderUnreachableError)
386
384
  throw providerUnreachable();
387
385
  // the answer hides the cause (a provider's text is not for people): ops read it here
@@ -436,14 +434,12 @@ const limitReached = () => new ApiError("device.project_limit_reached", `This de
436
434
  /** `path` without a trailing `/` (except `/` itself). */
437
435
  const trimSlash = (path) => path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
438
436
  /**
439
- * The absolute path of `relative` against the scope's base (the instance's `workspace` in sandbox
440
- * mode and on a cloud device, the owner's home in auto mode), normalized; refused when the base is
441
- * unknown, the result is not a valid path, or it leaves what the mode reads.
437
+ * The absolute path of `relative` against the scope's base (the home its provider reported, else
438
+ * the instance's `workspace`), normalized; refused when the result is not a valid path, or it
439
+ * leaves what the scope reaches.
442
440
  */
443
441
  function resolve(scope, workspace, relative) {
444
442
  const base = baseOf(scope, workspace);
445
- if (base === null)
446
- throw homeUnknown();
447
443
  const path = trimSlash(posix.normalize(posix.join(base, relative === "" ? "." : relative)));
448
444
  if (validateSandboxPathShape(path).length > 0 || !withinMode(scope, path, workspace)) {
449
445
  throw outsideMode(path, scope.mode);
@@ -464,7 +460,7 @@ function passThrough(e) {
464
460
  if (e instanceof SandboxProviderUnreachableError)
465
461
  return e;
466
462
  if (e instanceof DeviceProtocolError) {
467
- return new ApiError("device.projects_unavailable", "The device answered in a form this kernel does not accept; update capybara-device on that machine");
463
+ return new ApiError("device.projects_unavailable", "The device answered in a form this kernel does not accept; update its device program or plugin");
468
464
  }
469
465
  return undefined;
470
466
  }
@@ -480,10 +476,10 @@ function unavailable(e) {
480
476
  }
481
477
  const pathMissing = (path) => new ApiError("device.project_path_missing", `${clipped(path)} does not exist on the device; check the path`);
482
478
  /**
483
- * What a failed `list(path)` becomes. A machine's policy refusal is the device refusing the path
484
- * in its mode (`device.project_outside_mode`); a provider's `ProjectPathRefusedError` is
485
- * `device.project_refused` with its reason. Any other error alone cannot tell a file or an
486
- * unreadable directory from a failure on the device, so the device is asked `stat(path)`: a file
479
+ * What a failed `list(path)` becomes. A provider's `ProjectPathRefusedError` is
480
+ * `device.project_refused` with its reason; the owner browse scope refusing the path is the
481
+ * device refusing it (`device.project_outside_mode`). Any other error alone cannot tell a file or
482
+ * an unreadable directory from a failure on the device, so the device is asked `stat(path)`: a file
487
483
  * or a directory it cannot list is the path's problem (422 `device.project_path_unreadable`), a
488
484
  * missing path `device.project_path_missing`, and a `stat` that fails too means the device could
489
485
  * not be asked (503 `device.projects_unavailable`).
@@ -498,8 +494,7 @@ async function listFailure(e, r, path, mode, signal, logUnavailable) {
498
494
  }
499
495
  const why = e instanceof ToolError ? ` (${clipped(e.message)})` : "";
500
496
  // the owner browse scope refusing the path is the device refusing it (gate on only)
501
- if ((e instanceof ToolError && e.message.startsWith(POLICY_REFUSAL_PREFIX)) ||
502
- (r.browse && isSandboxScopeDeniedError(e))) {
497
+ if (r.browse && isSandboxScopeDeniedError(e)) {
503
498
  return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)} in ${mode} mode${why}`);
504
499
  }
505
500
  let st;
@@ -7,7 +7,7 @@ import { type DeviceProviderEntry, DeviceProviders } from "../sandbox/providers.
7
7
  /**
8
8
  * Which device providers serve an org: the loaded `device-provider@1` extensions switched on in it
9
9
  * (valid config), and the provider a new device gets by default. Everything is read at every call
10
- * (PG; no in-process cache). Internal providers (`@local`) are never listed here.
10
+ * (PG; no in-process cache). In-process providers (`DeviceProviders.register`) are never listed.
11
11
  */
12
12
  export declare class DeviceProviderSelection {
13
13
  private readonly providers;
@@ -16,15 +16,14 @@ export declare class DeviceProviderSelection {
16
16
  private readonly config;
17
17
  private readonly kdb;
18
18
  private readonly log;
19
- constructor(providers: Pick<DeviceProviders, "forDevice">, points: Pick<ExtensionPointDefaults, "providersFor" | "serves">, orgSettings: Pick<OrgSettingsService, "get">, config: Pick<KernelConfigService, "get" | "fieldSource">, kdb: Pick<KernelDb, "db">, log: KernelLogger);
19
+ constructor(providers: Pick<DeviceProviders, "forDevice" | "registered">, points: Pick<ExtensionPointDefaults, "providersFor" | "serves">, orgSettings: Pick<OrgSettingsService, "get">, config: Pick<KernelConfigService, "get" | "fieldSource">, kdb: Pick<KernelDb, "db">, log: KernelLogger);
20
20
  /** The providers that serve `orgId` now, in extension-name order. */
21
21
  onInOrg(orgId: string): Promise<DeviceProviderEntry[]>;
22
22
  /**
23
23
  * Whether the provider `plugin` (a device's `devices.provider`) serves `orgId` now: an extension
24
- * that {@link onInOrg} lists; a kernel-internal provider (`@local`) is no catalog item and has
25
- * no org switch, so for it "on in the org" means registered in this process (until phase 2 of
26
- * the device-provider plan moves local devices into the `device-local` plugin). Evaluates only
27
- * that provider ({@link ExtensionPointDefaults.serves}, the criteria {@link onInOrg} applies).
24
+ * that {@link onInOrg} lists; an in-process provider is no catalog item and has no org switch,
25
+ * so for it "on in the org" means registered in this process. Evaluates only that provider
26
+ * ({@link ExtensionPointDefaults.serves}, the criteria {@link onInOrg} applies).
28
27
  */
29
28
  isOnInOrg(orgId: string, plugin: string): Promise<boolean>;
30
29
  /**
@@ -13,12 +13,12 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
13
13
  import { KernelDb } from "../infra/database/kernel-db.js";
14
14
  import { KERNEL_LOGGER } from "../infra/tokens.js";
15
15
  import { OrgSettingsService } from "../orgs/settings.service.js";
16
- import { DeviceProviders, isInternalProvider, } from "../sandbox/providers.js";
16
+ import { DeviceProviders } from "../sandbox/providers.js";
17
17
  import { readPlatformDefaultProvider } from "./default-provider-setting.js";
18
18
  /**
19
19
  * Which device providers serve an org: the loaded `device-provider@1` extensions switched on in it
20
20
  * (valid config), and the provider a new device gets by default. Everything is read at every call
21
- * (PG; no in-process cache). Internal providers (`@local`) are never listed here.
21
+ * (PG; no in-process cache). In-process providers (`DeviceProviders.register`) are never listed.
22
22
  */
23
23
  let DeviceProviderSelection = class DeviceProviderSelection {
24
24
  providers;
@@ -41,21 +41,20 @@ let DeviceProviderSelection = class DeviceProviderSelection {
41
41
  const out = [];
42
42
  for (const p of providers) {
43
43
  const e = this.providers.forDevice(p.extension);
44
- if (e && !isInternalProvider(e.plugin))
44
+ if (e)
45
45
  out.push(e);
46
46
  }
47
47
  return out;
48
48
  }
49
49
  /**
50
50
  * Whether the provider `plugin` (a device's `devices.provider`) serves `orgId` now: an extension
51
- * that {@link onInOrg} lists; a kernel-internal provider (`@local`) is no catalog item and has
52
- * no org switch, so for it "on in the org" means registered in this process (until phase 2 of
53
- * the device-provider plan moves local devices into the `device-local` plugin). Evaluates only
54
- * that provider ({@link ExtensionPointDefaults.serves}, the criteria {@link onInOrg} applies).
51
+ * that {@link onInOrg} lists; an in-process provider is no catalog item and has no org switch,
52
+ * so for it "on in the org" means registered in this process. Evaluates only that provider
53
+ * ({@link ExtensionPointDefaults.serves}, the criteria {@link onInOrg} applies).
55
54
  */
56
55
  async isOnInOrg(orgId, plugin) {
57
- if (isInternalProvider(plugin))
58
- return this.providers.forDevice(plugin) !== undefined;
56
+ if (this.providers.registered(plugin))
57
+ return true;
59
58
  if (this.providers.forDevice(plugin) === undefined)
60
59
  return false;
61
60
  return this.points.serves(orgId, "device-provider", plugin);
@@ -1,10 +1,9 @@
1
- import type { DeviceLocalPolicySummary } from "@capybara-hq/plugin-sdk";
2
1
  import type { z } from "zod";
3
2
  import { type Principal } from "../identity/principal.js";
4
3
  import { type OrgContext } from "../orgs/org.guard.js";
5
4
  import { type DeviceProjectCandidates, type DeviceProjectList, DeviceProjectsService, type DeviceProjectView } from "./device-projects.service.js";
6
5
  import { type DeviceList, DevicesService, type DeviceView } from "./devices.service.js";
7
- import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type DevicePolicyBody, type DeviceProjectAddBody, type DeviceProjectParams } from "./dto.js";
6
+ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type DeviceProjectAddBody, type DeviceProjectParams } from "./dto.js";
8
7
  /**
9
8
  * A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
10
9
  * 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
@@ -16,25 +15,16 @@ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type De
16
15
  * - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
17
16
  * `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
18
17
  * `device.provider_required`); `GET /:id` → `{ device }`;
19
- * - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
20
- * network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
21
- * "Settings model") within its org's and the platform's ceilings (400
22
- * `device.network_not_allowed` above them). A local device's network lives on its machine (409
23
- * `device.ceiling_on_machine`; narrow it with `POST /:id/policy`). An API token may only narrow
24
- * it (400 `device.network_not_allowed`);
18
+ * - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets its sandbox network
19
+ * (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design, "Settings
20
+ * model") within its org's and the platform's ceilings (400 `device.network_not_allowed` above
21
+ * them), whatever its provider. An API token may only narrow it (400
22
+ * `device.network_not_allowed`);
25
23
  * - `DELETE /:id` → 202 (destroyed by a job after the response);
26
24
  * - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
27
- * starts empty);
28
- * - `DELETE /:id/machine` → 204: a local device's machine is disconnected (its credential
25
+ * starts empty; 409 `device.files_on_device` when its provider's report offers no reset);
26
+ * - `DELETE /:id/machine` → 204: a dial-in device's machine is disconnected (its credential
29
27
  * revoked; it must sign in again);
30
- * - `POST /:id/policy { remove?, ownerCeiling? }` → `{ policy }`: the owner narrows the local
31
- * device's sandbox on its machine (hosts removed; `outsideSandbox: false`, `network:
32
- * "allowlist"`, `restrictedProjectReach: "workspace"`); widening happens on the machine only.
33
- * Web session only
34
- * (`@SessionOnly`: a personal access token → 403 `auth.session_required`, a service token → 403):
35
- * a person changes their own machine's network policy, nothing model-driven does. Offline → 503
36
- * `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
37
- * refusal → 409 `device.policy_refused`.
38
28
  * - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
39
29
  * `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
40
30
  * `GET /:id/projects/candidates` → the device's suggestions under its base;
@@ -58,9 +48,6 @@ export declare class DevicesController {
58
48
  remove(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
59
49
  resetFiles(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
60
50
  revokeMachine(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
61
- changePolicy(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DevicePolicyBody>): Promise<{
62
- policy: DeviceLocalPolicySummary;
63
- }>;
64
51
  listProjects(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectList>;
65
52
  projectCandidates(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectCandidates>;
66
53
  addProject(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DeviceProjectAddBody>): Promise<{
@@ -8,12 +8,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Controller, Delete, Get, HttpCode, Inject, Patch, Post } from "@nestjs/common";
11
- import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../identity/principal.js";
11
+ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
12
12
  import { ZBody, ZParam } from "../infra/validation/zod-params.js";
13
13
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
14
14
  import { DeviceProjectsService, } from "./device-projects.service.js";
15
15
  import { DevicesService } from "./devices.service.js";
16
- import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyBodyDto, DeviceProjectAddBodyDto, DeviceProjectParamsDto, } from "./dto.js";
16
+ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProjectAddBodyDto, DeviceProjectParamsDto, } from "./dto.js";
17
17
  /**
18
18
  * A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
19
19
  * 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
@@ -25,25 +25,16 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyB
25
25
  * - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
26
26
  * `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
27
27
  * `device.provider_required`); `GET /:id` → `{ device }`;
28
- * - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
29
- * network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
30
- * "Settings model") within its org's and the platform's ceilings (400
31
- * `device.network_not_allowed` above them). A local device's network lives on its machine (409
32
- * `device.ceiling_on_machine`; narrow it with `POST /:id/policy`). An API token may only narrow
33
- * it (400 `device.network_not_allowed`);
28
+ * - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets its sandbox network
29
+ * (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design, "Settings
30
+ * model") within its org's and the platform's ceilings (400 `device.network_not_allowed` above
31
+ * them), whatever its provider. An API token may only narrow it (400
32
+ * `device.network_not_allowed`);
34
33
  * - `DELETE /:id` → 202 (destroyed by a job after the response);
35
34
  * - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
36
- * starts empty);
37
- * - `DELETE /:id/machine` → 204: a local device's machine is disconnected (its credential
35
+ * starts empty; 409 `device.files_on_device` when its provider's report offers no reset);
36
+ * - `DELETE /:id/machine` → 204: a dial-in device's machine is disconnected (its credential
38
37
  * revoked; it must sign in again);
39
- * - `POST /:id/policy { remove?, ownerCeiling? }` → `{ policy }`: the owner narrows the local
40
- * device's sandbox on its machine (hosts removed; `outsideSandbox: false`, `network:
41
- * "allowlist"`, `restrictedProjectReach: "workspace"`); widening happens on the machine only.
42
- * Web session only
43
- * (`@SessionOnly`: a personal access token → 403 `auth.session_required`, a service token → 403):
44
- * a person changes their own machine's network policy, nothing model-driven does. Offline → 503
45
- * `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
46
- * refusal → 409 `device.policy_refused`.
47
38
  * - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
48
39
  * `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
49
40
  * `GET /:id/projects/candidates` → the device's suggestions under its base;
@@ -95,12 +86,6 @@ let DevicesController = class DevicesController {
95
86
  const p = requireUser(principal);
96
87
  await this.devices.revokeMachine(org.orgId, p.account.id, params.id, patTokenId(p));
97
88
  }
98
- async changePolicy(principal, org, params, body) {
99
- const p = requireUser(principal);
100
- return {
101
- policy: await this.devices.changePolicy(org.orgId, p.account, params.id, body),
102
- };
103
- }
104
89
  async listProjects(principal, org, params) {
105
90
  const p = requireUser(principal);
106
91
  return this.projects.list(org.orgId, p.account.id, params.id);
@@ -172,16 +157,6 @@ __decorate([
172
157
  __param(1, CurrentOrg()),
173
158
  __param(2, ZParam(DeviceParamsDto))
174
159
  ], DevicesController.prototype, "revokeMachine", null);
175
- __decorate([
176
- Post(":id/policy"),
177
- HttpCode(200),
178
- SessionOnly(),
179
- OrgAction("agents.use"),
180
- __param(0, CurrentPrincipal()),
181
- __param(1, CurrentOrg()),
182
- __param(2, ZParam(DeviceParamsDto)),
183
- __param(3, ZBody(DevicePolicyBodyDto))
184
- ], DevicesController.prototype, "changePolicy", null);
185
160
  __decorate([
186
161
  Get(":id/projects"),
187
162
  OrgAction("agents.use"),
@@ -5,9 +5,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Module } from "@nestjs/common";
8
+ import { DialInModule } from "../dial-in/dial-in.module.js";
8
9
  import { ExtensionsModule } from "../extensions/extensions.module.js";
9
- import { LocalDevicesModule } from "../local-devices/local-devices.module.js";
10
10
  import { PermissionFactsModule } from "../sandbox/permission-facts.module.js";
11
+ import { SandboxProviderRegistryModule } from "../sandbox/providers.module.js";
11
12
  import { SandboxModule } from "../sandbox/sandbox.module.js";
12
13
  import { SandboxFileReader } from "../sandbox/sandbox-file-reader.js";
13
14
  import { DeviceAccess } from "./access.js";
@@ -26,12 +27,13 @@ let DevicesModule = class DevicesModule {
26
27
  };
27
28
  DevicesModule = __decorate([
28
29
  Module({
29
- // ExtensionsModule: the provider display names; LocalDevicesModule: deleting
30
- // a local device revokes its machine
30
+ // ExtensionsModule: the provider display names; DialInModule: deleting a dial-in device
31
+ // revokes its machine, and whether its machine is online
31
32
  imports: [
32
33
  SandboxModule,
34
+ SandboxProviderRegistryModule,
33
35
  ExtensionsModule,
34
- LocalDevicesModule,
36
+ DialInModule,
35
37
  DeviceAccessModule,
36
38
  DeviceProviderSelectionModule,
37
39
  PermissionFactsModule,
@@ -1,10 +1,6 @@
1
1
  import type { RouteSchemas } from "../platform/route-schemas.js";
2
- /** The body of the excluded `POST /devices/:id/policy` route (human-only). */
3
- export { DevicePolicyBody } from "./dto.js";
4
2
  /**
5
- * The devices routes the Platform operations mirror (`check:platform-ops` keys). Narrowing a local
6
- * machine's sandbox (`POST /devices/:id/policy`, body {@link DevicePolicyBody}) is a person's act
7
- * on their own machine and stays excluded, so it has no entry here. `PATCH /devices/:id`
3
+ * The devices routes the Platform operations mirror (`check:platform-ops` keys). `PATCH /devices/:id`
8
4
  * ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
9
5
  * (a cloud device's network, narrow only).
10
6
  */
@@ -1,10 +1,6 @@
1
1
  import { DeviceCreateBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, DeviceProjectParams, } from "./dto.js";
2
- /** The body of the excluded `POST /devices/:id/policy` route (human-only). */
3
- export { DevicePolicyBody } from "./dto.js";
4
2
  /**
5
- * The devices routes the Platform operations mirror (`check:platform-ops` keys). Narrowing a local
6
- * machine's sandbox (`POST /devices/:id/policy`, body {@link DevicePolicyBody}) is a person's act
7
- * on their own machine and stays excluded, so it has no entry here. `PATCH /devices/:id`
3
+ * The devices routes the Platform operations mirror (`check:platform-ops` keys). `PATCH /devices/:id`
8
4
  * ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
9
5
  * (a cloud device's network, narrow only).
10
6
  */