@capybara-hq/kernel 0.1.0-rc.54 → 0.1.0-rc.55

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 (154) hide show
  1. package/dist/admin/admin.schemas.d.ts +11 -1
  2. package/dist/catalog/catalog.module.js +1 -1
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/catalog/requests.service.d.ts +5 -5
  5. package/dist/catalog/requests.service.js +9 -9
  6. package/dist/channels/cards.d.ts +4 -3
  7. package/dist/channels/cards.js +25 -16
  8. package/dist/channels/phrases.d.ts +15 -4
  9. package/dist/channels/phrases.js +15 -1
  10. package/dist/config/load.d.ts +26 -7
  11. package/dist/config/load.js +60 -9
  12. package/dist/config/permission-migration.d.ts +17 -9
  13. package/dist/config/permission-migration.js +60 -9
  14. package/dist/config/schema.d.ts +11 -1
  15. package/dist/config/schema.js +37 -11
  16. package/dist/conversations/events.d.ts +247 -5
  17. package/dist/conversations/events.js +127 -16
  18. package/dist/conversations/permission-profiles.controller.d.ts +12 -2
  19. package/dist/conversations/permission-profiles.service.d.ts +12 -2
  20. package/dist/conversations/permission-profiles.service.js +11 -4
  21. package/dist/db/kernel-schema.d.ts +8 -2
  22. package/dist/devices/device-projects.service.d.ts +1 -1
  23. package/dist/devices/device-projects.service.js +6 -6
  24. package/dist/devices/devices.controller.d.ts +10 -8
  25. package/dist/devices/devices.controller.js +14 -18
  26. package/dist/devices/devices.schemas.d.ts +5 -5
  27. package/dist/devices/devices.schemas.js +5 -5
  28. package/dist/devices/devices.service.d.ts +188 -175
  29. package/dist/devices/devices.service.js +284 -292
  30. package/dist/devices/dto.d.ts +43 -23
  31. package/dist/devices/dto.js +45 -49
  32. package/dist/devices/project-rules.d.ts +0 -10
  33. package/dist/devices/project-rules.js +0 -5
  34. package/dist/errors.d.ts +24 -19
  35. package/dist/errors.js +24 -19
  36. package/dist/evals/reconstruct.d.ts +12 -3
  37. package/dist/evals/reconstruct.js +10 -6
  38. package/dist/evals/recorded-permission-context.d.ts +6 -4
  39. package/dist/evals/recorded-permission-context.js +15 -9
  40. package/dist/evals/run-replay.d.ts +6 -1
  41. package/dist/evals/run-replay.js +7 -2
  42. package/dist/evals/worker.js +3 -1
  43. package/dist/identity/settings.d.ts +45 -18
  44. package/dist/identity/settings.js +151 -51
  45. package/dist/infra/config/kernel-config.service.d.ts +1 -1
  46. package/dist/infra/config/kernel-config.service.js +17 -5
  47. package/dist/local-devices/device-auth.controller.d.ts +1 -1
  48. package/dist/local-devices/device-auth.controller.js +1 -1
  49. package/dist/local-devices/device-auth.d.ts +4 -4
  50. package/dist/local-devices/device-auth.js +1 -1
  51. package/dist/local-devices/device-policy.service.d.ts +18 -9
  52. package/dist/local-devices/device-policy.service.js +21 -61
  53. package/dist/local-devices/device-routes.d.ts +3 -1
  54. package/dist/local-devices/device-routes.js +15 -4
  55. package/dist/local-devices/instance-bindings.js +5 -2
  56. package/dist/local-devices/local-device-gateway.d.ts +2 -2
  57. package/dist/local-devices/local-device-gateway.js +3 -3
  58. package/dist/local-devices/local-device-provider.d.ts +4 -4
  59. package/dist/local-devices/local-device-provider.js +23 -9
  60. package/dist/local-devices/local-devices.module.d.ts +1 -1
  61. package/dist/local-devices/local-devices.module.js +1 -1
  62. package/dist/local-devices/machines.d.ts +40 -16
  63. package/dist/local-devices/machines.js +89 -61
  64. package/dist/local-devices/owner-report.d.ts +16 -14
  65. package/dist/local-devices/owner-report.js +24 -30
  66. package/dist/local-devices/owner-reports.js +26 -8
  67. package/dist/local-devices/policy-summary.d.ts +25 -44
  68. package/dist/local-devices/policy-summary.js +26 -71
  69. package/dist/local-devices/relay.d.ts +6 -6
  70. package/dist/local-devices/relay.js +10 -8
  71. package/dist/net/public-address.d.ts +1 -1
  72. package/dist/net/public-address.js +5 -2
  73. package/dist/orgs/device-network-setting.d.ts +82 -0
  74. package/dist/orgs/device-network-setting.js +142 -0
  75. package/dist/orgs/settings.service.d.ts +103 -66
  76. package/dist/orgs/settings.service.js +201 -137
  77. package/dist/overrides.d.ts +5 -1
  78. package/dist/overrides.js +2 -0
  79. package/dist/platform/exclusions.js +1 -1
  80. package/dist/platform/operation.js +1 -1
  81. package/dist/platform/ops/admin.ops.js +20 -11
  82. package/dist/platform/ops/devices.ops.js +70 -5
  83. package/dist/platform/ops/org-settings.ops.js +10 -6
  84. package/dist/platform/ops/orgs.ops.js +2 -1
  85. package/dist/runtime/context/permission-profile.d.ts +17 -8
  86. package/dist/runtime/context/permission-profile.js +126 -45
  87. package/dist/runtime/permission-context.service.d.ts +1 -1
  88. package/dist/runtime/permission-context.service.js +5 -3
  89. package/dist/runtime/project/knowledge.d.ts +5 -4
  90. package/dist/runtime/project/knowledge.js +2 -1
  91. package/dist/runtime/project/knowledge.service.js +16 -13
  92. package/dist/sandbox/cloud-permission-snapshot.js +22 -3
  93. package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
  94. package/dist/sandbox/device-sandbox-settings.js +470 -0
  95. package/dist/sandbox/device-sandbox.d.ts +187 -0
  96. package/dist/sandbox/device-sandbox.js +236 -0
  97. package/dist/sandbox/held-operations.js +15 -7
  98. package/dist/sandbox/modes.d.ts +49 -24
  99. package/dist/sandbox/modes.js +27 -19
  100. package/dist/sandbox/operation-authority-types.d.ts +6 -5
  101. package/dist/sandbox/operation-authority-types.js +7 -8
  102. package/dist/sandbox/operation-authority.d.ts +23 -9
  103. package/dist/sandbox/operation-authority.js +179 -97
  104. package/dist/sandbox/permission-auto-grants.d.ts +42 -0
  105. package/dist/sandbox/permission-auto-grants.js +145 -0
  106. package/dist/sandbox/permission-call-grants.d.ts +12 -4
  107. package/dist/sandbox/permission-call-grants.js +84 -35
  108. package/dist/sandbox/permission-call-grants.module.js +10 -3
  109. package/dist/sandbox/permission-call-types.d.ts +39 -5
  110. package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
  111. package/dist/sandbox/permission-ceiling-writes.js +38 -4
  112. package/dist/sandbox/permission-config-publication.d.ts +44 -2
  113. package/dist/sandbox/permission-config-publication.js +230 -59
  114. package/dist/sandbox/permission-context-types.d.ts +2 -2
  115. package/dist/sandbox/permission-facts.d.ts +144 -15
  116. package/dist/sandbox/permission-facts.js +258 -70
  117. package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
  118. package/dist/sandbox/permission-runtime-reports.js +19 -29
  119. package/dist/sandbox/review/classifier.d.ts +8 -0
  120. package/dist/sandbox/review/classifier.js +10 -0
  121. package/dist/sandbox/review/permission-candidate.d.ts +69 -5
  122. package/dist/sandbox/review/permission-candidate.js +153 -30
  123. package/dist/sandbox/review/review.service.d.ts +19 -3
  124. package/dist/sandbox/review/review.service.js +59 -11
  125. package/dist/sandbox/review/rules.js +23 -3
  126. package/dist/sandbox/sandbox.service.d.ts +29 -11
  127. package/dist/sandbox/sandbox.service.js +51 -26
  128. package/dist/skills/invoke.js +3 -2
  129. package/dist/tools/approvals.service.d.ts +26 -116
  130. package/dist/tools/approvals.service.js +42 -346
  131. package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
  132. package/dist/tools/builtins/sandbox/bash.js +80 -28
  133. package/dist/tools/builtins/sandbox/common.d.ts +39 -14
  134. package/dist/tools/builtins/sandbox/common.js +47 -24
  135. package/dist/tools/builtins/sandbox/deliver.js +7 -4
  136. package/dist/tools/builtins/skill-load.d.ts +2 -2
  137. package/dist/tools/builtins/skill-load.js +4 -3
  138. package/dist/tools/device-op-resolver.d.ts +4 -10
  139. package/dist/tools/device-op-resolver.js +8 -19
  140. package/dist/tools/network-asks.d.ts +52 -15
  141. package/dist/tools/network-asks.js +55 -25
  142. package/dist/tools/pipeline.d.ts +26 -14
  143. package/dist/tools/pipeline.js +144 -61
  144. package/dist/tools/registry.d.ts +6 -0
  145. package/dist/tools/tools.module.js +1 -1
  146. package/package.json +4 -4
  147. package/src/migrations/0165_device_network_columns.sql +50 -0
  148. package/src/migrations/0166_permission_grant_full_access.sql +17 -0
  149. package/src/migrations/0167_device_network_backfill.sql +32 -0
  150. package/src/migrations/0168_binding_installed_connection.sql +6 -0
  151. package/dist/orgs/cloud-network-setting.d.ts +0 -33
  152. package/dist/orgs/cloud-network-setting.js +0 -47
  153. package/dist/sandbox/platform-full-access.d.ts +0 -110
  154. package/dist/sandbox/platform-full-access.js +0 -198
@@ -18,16 +18,16 @@ import { KernelDb } from "../infra/database/kernel-db.js";
18
18
  import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
19
19
  import { Transactional } from "../infra/database/transactional.decorator.js";
20
20
  import { KERNEL_LOGGER } from "../infra/tokens.js";
21
+ import { hostGrantable, hostGrantCeiling, } from "../sandbox/device-sandbox.js";
22
+ import { keepOrgLegacyKeysInStep, orgDeviceSandboxOf, readDeviceSandboxSettingsView, } from "../sandbox/device-sandbox-settings.js";
21
23
  import { coversHost, orgCloudMode, orgEffectiveHosts, orgHostOutsideCeiling, } from "../sandbox/modes.js";
22
- import { isExecutionMethod } from "../sandbox/operation-authority-types.js";
23
24
  import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
24
- import { localMachineRoots, needsFullCeiling, needsWiderDeviceCeiling, PermissionCeilingWrites, } from "../sandbox/permission-ceiling-writes.js";
25
- import { narrowedOrgFullAccess, readDevicesFullAccess, } from "../sandbox/platform-full-access.js";
25
+ import { cloudDevicesFollowingDefault, hostsNarrowed, localMachineRoots, needsFullCeiling, needsOpenNetwork, needsWiderDeviceCeiling, PermissionCeilingWrites, } from "../sandbox/permission-ceiling-writes.js";
26
26
  import { readExternalSharing, readShareMaxExpiry, } from "../shares/settings.js";
27
27
  import { assertThemeOnIn } from "../themes/theme-state.js";
28
28
  import { IanaTimeZone } from "../time-zone.js";
29
29
  import { mergeArrangement, OrgUiArrangementPatchSchema, UiArrangementSchema, } from "../ui/arrangement.js";
30
- import { CloudNetworkSettingSchema, invalidCloudNetwork, } from "./cloud-network-setting.js";
30
+ import { DeviceNetworkSettingSchema, invalidDeviceNetwork, } from "./device-network-setting.js";
31
31
  import { OrgLock, OrgLockModule } from "./org-lock.js";
32
32
  /**
33
33
  * Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
@@ -42,13 +42,16 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
42
42
  * execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
43
43
  * - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
44
44
  * the deployment), see {@link effectiveWakeOnBackgroundTask}.
45
- * - `fullAccess`: whether devices of the org may run with Full permission (permission runtime
46
- * cutover B1, replacing `autoMode`); absent follows the platform's `devices.fullAccess`, and an
47
- * invalid stored value reads as `off` (narrower, never wider). Setting `allowed` while the
48
- * platform is `off` is refused.
49
- * - `cloudNetwork`: the org's sandbox-mode network as a delta over the platform's allowlist (org
50
- * egress ceiling spec §D1, {@link CloudNetworkSettingSchema}). An invalid stored value reads as
51
- * `{ mode: "allowlist", base: "none" }`, the empty allowlist (narrower, never wider).
45
+ * - `outsideSandbox`: whether devices of the org may be granted running a call outside their
46
+ * sandbox (approval-only profiles design, replacing `fullAccess`); absent follows the platform's
47
+ * `devices.outsideSandbox`, and an invalid stored value reads as `off` (narrower, never wider).
48
+ * Setting `allowed` while the platform is `off` is refused.
49
+ * - `deviceNetwork`: the org's device sandbox network, its default and ceiling and its hosts as a
50
+ * delta over the platform's allowlist ({@link DeviceNetworkSettingSchema}, replacing
51
+ * `cloudNetwork`). An invalid stored value reads as the empty allowlist (narrower, never wider);
52
+ * a default or ceiling above the platform's ceiling is refused.
53
+ * Old keys are read and kept in step until the permission configuration publication converts
54
+ * them ({@link orgDeviceSandboxOf}).
52
55
  * - `platformTool`: the `Platform` builtin for the whole org (Platform tool spec §3): `on`,
53
56
  * `read-only` (writes listed as unavailable) or `off` (default `on`).
54
57
  * - `timeZone`: the org's default time zone (IANA; absent = UTC) for senders without one of their
@@ -60,12 +63,12 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
60
63
  * - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
61
64
  * not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
62
65
  */
63
- export { CloudNetworkSettingSchema, invalidCloudNetwork, ORG_SANDBOX_ALLOW_HOSTS_MAX, } from "./cloud-network-setting.js";
66
+ export { DeviceNetworkSettingSchema, invalidDeviceNetwork, ORG_SANDBOX_ALLOW_HOSTS_MAX, } from "./device-network-setting.js";
64
67
  /**
65
- * The org's Full permission switch (B1): `allowed` or `off`; absent follows the platform's
66
- * `devices.fullAccess`. An invalid stored value reads as `off` (narrower, never wider).
68
+ * The org's outside-sandbox ceiling: `allowed` or `off`; absent follows the platform's
69
+ * `devices.outsideSandbox`. An invalid stored value reads as `off` (narrower, never wider).
67
70
  */
68
- export const FullAccessSetting = z.enum([
71
+ export const OutsideSandboxSetting = z.enum([
69
72
  "allowed",
70
73
  "off",
71
74
  ]);
@@ -150,10 +153,10 @@ export const OrgSettingsSchema = z.object({
150
153
  /** Absent = `allow`; an invalid stored value reads as `ask` (narrower, never wider). */
151
154
  sandboxToolPolicy: z.enum(["allow", "ask"]).default("allow").catch("ask"),
152
155
  platformTool: z.enum(["on", "read-only", "off"]).default("on").catch("on"),
153
- /** The org's Full permission switch (B1); absent follows the platform. */
154
- fullAccess: FullAccessSetting.optional().catch("off"),
155
- /** The org's network for cloud devices (auto mode spec §4.3); absent = open (the default). */
156
- cloudNetwork: CloudNetworkSettingSchema.optional().catch(invalidCloudNetwork),
156
+ /** The org's outside-sandbox ceiling; absent follows the platform. */
157
+ outsideSandbox: OutsideSandboxSetting.optional().catch("off"),
158
+ /** The org's device sandbox network; absent follows the platform. */
159
+ deviceNetwork: DeviceNetworkSettingSchema.optional().catch(invalidDeviceNetwork),
157
160
  /** Overrides `runtime.wakeOnBackgroundTask`; absent follows the deployment. */
158
161
  wakeOnBackgroundTask: z.boolean().optional().catch(undefined),
159
162
  /** The org's default time zone (run context spec §3.3); absent = UTC. */
@@ -199,15 +202,16 @@ export const OrgSettingsPatchSchema = z
199
202
  /** null clears (follow the deployment again). */
200
203
  wakeOnBackgroundTask: z.boolean().nullable().optional(),
201
204
  /**
202
- * The org's Full permission switch; null clears it (follow the platform). `allowed` while the
203
- * platform is `off` -> 400 `org.full_access_not_allowed`.
205
+ * The org's outside-sandbox ceiling; null clears it (follow the platform). `allowed` while the
206
+ * platform is `off` -> 400 `org.outside_sandbox_not_allowed`.
204
207
  */
205
- fullAccess: FullAccessSetting.nullable().optional(),
208
+ outsideSandbox: OutsideSandboxSetting.nullable().optional(),
206
209
  /**
207
- * The org's network for cloud devices, replaced whole (hosts left out follow the deployment);
208
- * null clears it (open). Through the Platform tool or an API token it may only narrow.
210
+ * The org's device sandbox network, replaced whole (fields left out follow the platform); null
211
+ * clears it. A default or ceiling above the platform's ceiling -> 400 `org.network_not_allowed`.
212
+ * Through the Platform tool or an API token it may only narrow.
209
213
  */
210
- cloudNetwork: CloudNetworkSettingSchema.nullable().optional(),
214
+ deviceNetwork: DeviceNetworkSettingSchema.nullable().optional(),
211
215
  /** The org's default time zone (IANA); null clears it (UTC). */
212
216
  timeZone: IanaTimeZone.nullable().optional(),
213
217
  /**
@@ -255,22 +259,26 @@ export function effectiveSandboxLimits(deployment, override) {
255
259
  ...(override?.memoryMb !== undefined && { memoryMb: override.memoryMb }),
256
260
  };
257
261
  }
258
- /** Compare by value (`cloudNetwork` is an object); the schema fixes the key order. */
262
+ /** Compare by value (`deviceNetwork` is an object); the schema fixes the key order. */
259
263
  const sameSettings = (a, b) => JSON.stringify(OrgSettingsSchema.parse(a)) === JSON.stringify(OrgSettingsSchema.parse(b));
260
264
  const asObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
261
265
  /**
262
- * Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}). `fullAccess` is
263
- * read over both keys, the narrower of it and an old `autoMode` the permission configuration
264
- * publication has not converted yet ({@link narrowedOrgFullAccess}; fail closed).
266
+ * Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}).
267
+ * `outsideSandbox` and `deviceNetwork` are read over the new and the old keys the permission
268
+ * configuration publication has not converted yet ({@link orgDeviceSandboxOf}; fail closed).
265
269
  */
266
270
  export function parseOrgSettings(raw) {
267
271
  const stored = asObject(raw);
268
272
  const settings = OrgSettingsSchema.parse(stored);
269
- const fullAccess = narrowedOrgFullAccess(settings.fullAccess, stored.autoMode);
270
- if (fullAccess === undefined)
271
- delete settings.fullAccess;
273
+ const { outsideSandbox, deviceNetwork } = orgDeviceSandboxOf(stored);
274
+ if (outsideSandbox === undefined)
275
+ delete settings.outsideSandbox;
272
276
  else
273
- settings.fullAccess = fullAccess;
277
+ settings.outsideSandbox = outsideSandbox;
278
+ if (deviceNetwork === undefined)
279
+ delete settings.deviceNetwork;
280
+ else
281
+ settings.deviceNetwork = deviceNetwork;
274
282
  return settings;
275
283
  }
276
284
  /** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
@@ -333,7 +341,8 @@ export function logUnreadableSecuritySettings(log, orgId, raw) {
333
341
  log("org settings: stored scheduledTasks.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
334
342
  }
335
343
  }
336
- const fullAccessNotAllowed = (message) => new ApiError("org.full_access_not_allowed", message);
344
+ const outsideSandboxNotAllowed = (message) => new ApiError("org.outside_sandbox_not_allowed", message);
345
+ const networkNotAllowed = (message, field) => new ApiError("org.network_not_allowed", message, [{ path: `deviceNetwork.${field}` }]);
337
346
  const externalSharingNotAllowed = (message) => new ApiError("org.external_sharing_not_allowed", message);
338
347
  /** Whether a stored settings object holds an `externalSharing` this version reads as `off`. */
339
348
  export function invalidStoredExternalSharing(raw) {
@@ -345,28 +354,51 @@ export function invalidStoredPromptSuggestions(raw) {
345
354
  const v = asObject(raw).promptSuggestions;
346
355
  return v !== undefined && !PromptSuggestionsSetting.safeParse(v).success;
347
356
  }
348
- /** Whether a stored settings object holds a `fullAccess` this version reads as `off`. */
349
- export function invalidStoredFullAccess(raw) {
350
- const v = asObject(raw).fullAccess;
351
- return v !== undefined && !FullAccessSetting.safeParse(v).success;
357
+ /** Whether a stored settings object holds an `outsideSandbox` this version reads as `off`. */
358
+ export function invalidStoredOutsideSandbox(raw) {
359
+ const v = asObject(raw).outsideSandbox;
360
+ return v !== undefined && !OutsideSandboxSetting.safeParse(v).success;
361
+ }
362
+ /** Whether a stored settings object holds a `deviceNetwork` this version reads as an empty allowlist. */
363
+ export function invalidStoredDeviceNetwork(raw) {
364
+ const v = asObject(raw).deviceNetwork;
365
+ return v !== undefined && !DeviceNetworkSettingSchema.safeParse(v).success;
366
+ }
367
+ /**
368
+ * Whether `next`'s default or ceiling (absent: follow the platform, read as open, the widest the
369
+ * platform may relax to) opens where `prev`'s is the allowlist.
370
+ */
371
+ export function deviceNetworkModeWidens(prev, next) {
372
+ const mode = (v) => v ?? "open";
373
+ if (mode(next?.ceiling) === "open" && mode(prev?.ceiling) !== "open")
374
+ return "ceiling";
375
+ if (mode(next?.default) === "open" && mode(prev?.default) !== "open")
376
+ return "default";
377
+ return null;
378
+ }
379
+ /** The org's effective network default and ceiling: its own, within the platform's. */
380
+ export function effectiveOrgNetwork(platform, org) {
381
+ const ceiling = platform.ceiling === "allowlist" || org?.ceiling === "allowlist" ? "allowlist" : "open";
382
+ const def = ceiling === "allowlist" ? "allowlist" : (org?.default ?? platform.default);
383
+ return { default: def, ceiling };
352
384
  }
353
- /** Whether a stored settings object holds a `cloudNetwork` this version reads as an empty allowlist. */
354
- export function invalidStoredCloudNetwork(raw) {
355
- const v = asObject(raw).cloudNetwork;
356
- return v !== undefined && !CloudNetworkSettingSchema.safeParse(v).success;
385
+ /** Which effective field opens from `a` to `b`, if any. */
386
+ export function effectiveNetworkWidens(a, b) {
387
+ if (a.ceiling === "allowlist" && b.ceiling === "open")
388
+ return "ceiling";
389
+ if (a.default === "allowlist" && b.default === "open")
390
+ return "default";
391
+ return null;
357
392
  }
358
393
  /**
359
- * Whether `next` (absent: follow the platform) widens `prev` (spec §D3), both normalized (mode
360
- * open, base platform, empty lists): the open mode where it was the allowlist; base none to
361
- * platform; with base platform, dropping one of the stored exclusions; an extra host no stored
362
- * extra covers. Over-strict on purpose: moving to base none with a platform entry as an extra is a
363
- * narrowing these rules refuse (a token cannot pin a platform host the platform may drop later).
394
+ * Whether `next`'s hosts (absent: follow the platform) widen `prev`'s (org egress ceiling spec
395
+ * §D3), both normalized (base platform, empty lists): base none to platform; with base platform,
396
+ * dropping one of the stored exclusions; an extra host no stored extra covers. Over-strict on
397
+ * purpose: moving to base none with a platform entry as an extra is a narrowing these rules refuse
398
+ * (a token cannot pin a platform host the platform may drop later).
364
399
  */
365
- export function cloudNetworkWidens(prev, next) {
366
- const mode = (v) => v?.mode ?? "open";
400
+ export function deviceNetworkHostsWiden(prev, next) {
367
401
  const base = (v) => v?.base ?? "platform";
368
- if (mode(next) === "open" && mode(prev) !== "open")
369
- return true;
370
402
  if (base(next) === "platform" && base(prev) === "none")
371
403
  return true;
372
404
  if (base(next) === "platform") {
@@ -377,7 +409,7 @@ export function cloudNetworkWidens(prev, next) {
377
409
  const prevExtra = (prev?.extraHosts ?? []).map((h) => h.toLowerCase());
378
410
  return (next?.extraHosts ?? []).some((h) => !prevExtra.some((p) => coversHost(p, h.toLowerCase())));
379
411
  }
380
- /** 组织设置服务:读取与修改(修改需 `org.update`,锁内实时复核角色,写审计)。 */
412
+ /** Org settings: read and update (an update needs `org.update`, re-checks the role under the lock and is audited). */
381
413
  let OrgSettingsService = class OrgSettingsService {
382
414
  db;
383
415
  txHost;
@@ -387,8 +419,8 @@ let OrgSettingsService = class OrgSettingsService {
387
419
  log;
388
420
  constructor(db, txHost, orgLock,
389
421
  /**
390
- * The deployment config: `sandbox.limits` and the platform's Full switch
391
- * (`devices.fullAccess`; the org may follow it, never exceed it).
422
+ * The deployment config: `sandbox.limits` and the platform's device sandbox settings
423
+ * (`devices.outsideSandbox`, `devices.network`; the org may follow them, never exceed them).
392
424
  */
393
425
  config, ceilings, log) {
394
426
  this.db = db;
@@ -398,12 +430,12 @@ let OrgSettingsService = class OrgSettingsService {
398
430
  this.ceilings = ceilings;
399
431
  this.log = log;
400
432
  }
401
- /** Parses stored settings, warning when an invalid `fullAccess` narrows to `off`, an invalid
402
- * `cloudNetwork` to an empty allowlist, or a security setting reads narrower
433
+ /** Parses stored settings, warning when an invalid `outsideSandbox` narrows to `off`, an
434
+ * invalid `deviceNetwork` to an empty allowlist, or a security setting reads narrower
403
435
  * ({@link logUnreadableSecuritySettings}, warn). */
404
436
  parseStored(orgId, raw) {
405
- if (invalidStoredFullAccess(raw)) {
406
- this.log?.warn("org settings: stored fullAccess is invalid; it reads as off", { orgId });
437
+ if (invalidStoredOutsideSandbox(raw)) {
438
+ this.log?.warn("org settings: stored outsideSandbox is invalid; it reads as off", { orgId });
407
439
  }
408
440
  if (invalidStoredExternalSharing(raw)) {
409
441
  this.log?.warn("org settings: stored externalSharing is invalid; it reads as off", { orgId });
@@ -413,8 +445,8 @@ let OrgSettingsService = class OrgSettingsService {
413
445
  orgId,
414
446
  });
415
447
  }
416
- if (invalidStoredCloudNetwork(raw)) {
417
- this.log?.warn("org settings: stored cloudNetwork is invalid; it reads as an empty allowlist", {
448
+ if (invalidStoredDeviceNetwork(raw)) {
449
+ this.log?.warn("org settings: stored deviceNetwork is invalid; it reads as an empty allowlist", {
418
450
  orgId,
419
451
  });
420
452
  }
@@ -423,11 +455,11 @@ let OrgSettingsService = class OrgSettingsService {
423
455
  logUnreadableSecuritySettings((m, f) => log.warn(m, f), orgId, raw);
424
456
  return parseOrgSettings(raw);
425
457
  }
426
- /** 部署默认值(设置页展示「跟随部署」时的实际取值)。 */
458
+ /** The deployment defaults (what "follow the platform" means on the settings page). */
427
459
  async deployment() {
428
460
  const lim = this.config.get().sandbox.limits;
429
- const [fullAccess, attribution, compaction, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
430
- readDevicesFullAccess(this.db.db, this.config, this.log),
461
+ const [deviceSandbox, attribution, compaction, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
462
+ readDeviceSandboxSettingsView(this.db.db, this.config, this.log),
431
463
  readPlatformAttribution(this.db.db, this.config, this.log),
432
464
  readPlatformCompactionSettings(this.db.db),
433
465
  readExternalSharing(this.db.db, this.config, this.log),
@@ -435,8 +467,9 @@ let OrgSettingsService = class OrgSettingsService {
435
467
  readPromptSuggestions(this.db.db, this.log),
436
468
  ]);
437
469
  return {
438
- fullAccess,
439
- cloudNetwork: {
470
+ outsideSandbox: deviceSandbox.outsideSandbox,
471
+ deviceNetwork: {
472
+ ...deviceSandbox.network,
440
473
  allowHosts: [...lim.allowHosts],
441
474
  orgHosts: lim.orgHosts,
442
475
  off: lim.egress === "none",
@@ -465,14 +498,14 @@ let OrgSettingsService = class OrgSettingsService {
465
498
  return effectivePromptSuggestions(platform, parseOrgSettings(row.settings).promptSuggestions);
466
499
  }
467
500
  /**
468
- * The org's effective sandbox-mode network (spec §D3): the cloud network's mode and the hosts,
469
- * from the platform's `sandbox.limits` and the org's stored delta.
501
+ * The org's effective sandbox network (spec §D3): its mode and the hosts, from the platform's
502
+ * `sandbox.limits` and the org's stored delta.
470
503
  */
471
504
  effectiveNetwork(settings) {
472
505
  const lim = this.config.get().sandbox.limits;
473
506
  return {
474
- mode: orgCloudMode(lim, settings.cloudNetwork),
475
- hosts: orgEffectiveHosts(lim, settings.cloudNetwork),
507
+ mode: orgCloudMode(lim, settings.deviceNetwork),
508
+ hosts: orgEffectiveHosts(lim, settings.deviceNetwork),
476
509
  };
477
510
  }
478
511
  /** 组织实际生效的沙箱 cpu / 内存(只读;由超级管理员在部署设置里覆盖)。 */
@@ -498,14 +531,21 @@ let OrgSettingsService = class OrgSettingsService {
498
531
  }
499
532
  /**
500
533
  * The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
501
- * auto mode where the platform turned it off, external sharing where the platform denies it.
534
+ * running outside the sandbox where the platform turned it off, a network default or ceiling
535
+ * above the platform's ceiling, external sharing where the platform denies it.
502
536
  */
503
537
  async check(patch) {
504
- // allowing Full where the platform turned it off is wider than the platform allows
505
- if (patch.fullAccess === "allowed") {
506
- const platform = await readDevicesFullAccess(this.db.db, this.config, this.log);
507
- if (platform.permission === "off") {
508
- throw fullAccessNotAllowed("The platform does not allow Full permission");
538
+ if (patch.outsideSandbox === "allowed" || patch.deviceNetwork != null) {
539
+ const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
540
+ // allowing outside-sandbox runs where the platform turned them off is wider than it allows
541
+ if (patch.outsideSandbox === "allowed" && platform.outsideSandbox.permission === "off") {
542
+ throw outsideSandboxNotAllowed("The platform does not allow running outside the sandbox; a super admin must allow it in the admin console settings first");
543
+ }
544
+ const net = patch.deviceNetwork;
545
+ if (net != null && platform.network.ceiling === "allowlist") {
546
+ for (const field of ["ceiling", "default"])
547
+ if (net[field] === "open")
548
+ throw networkNotAllowed(`The platform limits device networks to the allowlist, so the organization's network ${field} cannot be open; a super admin sets devices.network.ceiling`, field);
509
549
  }
510
550
  }
511
551
  if (patch.externalSharing === "on") {
@@ -516,23 +556,20 @@ let OrgSettingsService = class OrgSettingsService {
516
556
  }
517
557
  }
518
558
  /**
519
- * Under `sandbox.limits.orgHosts: within` (spec §D2), refuses what would widen past the platform
520
- * ceiling compared with the stored value `before`: the open cloud network where the org did not
521
- * store it, or an extra host outside the platform's allowlist that the org did not store. Stored
522
- * values are sent back as they are (the PATCH replaces `cloudNetwork` whole) and have no effect
523
- * under the ceiling (they are filtered on read), so they never block a write.
559
+ * Under `sandbox.limits.orgHosts: within` (spec §D2), refuses an extra host outside the
560
+ * platform's allowlist that the org did not store. Stored values are sent back as they are (the
561
+ * PATCH replaces `deviceNetwork` whole) and have no effect under the ceiling (they are filtered on
562
+ * read), so they never block a write. Whether the network may be open is the network ceiling's
563
+ * (`devices.network.ceiling`, {@link check}), not `orgHosts`'.
524
564
  */
525
565
  assertWithinCeiling(before, patch) {
526
- const cn = patch.cloudNetwork;
566
+ const cn = patch.deviceNetwork;
527
567
  if (cn == null)
528
568
  return;
529
569
  const lim = this.config.get().sandbox.limits;
530
570
  if (lim.orgHosts !== "within")
531
571
  return;
532
- if (cn.mode === "open" && before.cloudNetwork?.mode !== "open") {
533
- throw new ApiError("org.sandbox_egress_not_allowed", "The platform limits sandbox networks to its allowlist; the open cloud network is not available", [{ reason: "open_not_allowed" }]);
534
- }
535
- const stored = new Set(before.cloudNetwork?.extraHosts ?? []);
572
+ const stored = new Set(before.deviceNetwork?.extraHosts ?? []);
536
573
  const outside = (cn.extraHosts ?? []).filter((h) => !stored.has(h) && orgHostOutsideCeiling(lim, h));
537
574
  if (outside.length > 0) {
538
575
  throw new ApiError("org.sandbox_egress_not_allowed", `The platform limits sandbox hosts to its allowlist; ask a super admin to add ${outside.join(", ")} to sandbox.limits.allowHosts`, [{ reason: "outside_ceiling", hosts: outside }]);
@@ -542,43 +579,55 @@ let OrgSettingsService = class OrgSettingsService {
542
579
  /** Merged into the audit detail (the Platform tool's `via: "agent"`). */
543
580
  auditDetail,
544
581
  /**
545
- * `onlyNarrows` (the Platform tool, API tokens): refuse a `fullAccess`, `cloudNetwork` or
582
+ * `onlyNarrows` (the Platform tool, API tokens): refuse an `outsideSandbox`, `deviceNetwork` or
546
583
  * `externalSharing` change that widens (see {@link assertOnlyNarrows}); only a person in a
547
584
  * session widens.
548
585
  */
549
586
  opts) {
550
587
  await this.check(patch);
551
- // the org row, then (for a Full or cloud network change) the org's permission authority lock:
588
+ // the org row, then (for a device sandbox change) the org's permission authority lock:
552
589
  // the ordered prelude, so inside a run's fence (the Platform tool's `org-settings.update`) they
553
590
  // precede the conversation rows; the patch decides the lock, so nothing can change it
554
591
  return withOrderedLocks(() => this.lockFor(orgId, patch, actorAccountId), () => this.updateIn(orgId, patch, actorAccountId, actorTokenId, auditDetail, opts));
555
592
  }
556
593
  async lockFor(orgId, patch, actorAccountId) {
557
594
  await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "org.update");
558
- if (patch.fullAccess !== undefined || patch.cloudNetwork !== undefined)
595
+ if (patch.outsideSandbox !== undefined || patch.deviceNetwork !== undefined)
559
596
  await this.ceilings.lock({ orgId }, "org");
560
597
  }
561
598
  /**
562
- * Refuses a patch that widens the org's sandbox (auto mode spec §4.3: only a person widens it,
563
- * never the Platform tool or an API token):
564
- * - `fullAccess`: `allowed` where the organization runs `off` (an absent value follows the
565
- * platform); clearing it follows the platform too, never wider than the platform allows;
566
- * - `cloudNetwork`: compared as stored deltas ({@link cloudNetworkWidens}), never as effective
567
- * values: under the kill switch or the platform ceiling the effective values hide a widening
568
- * that takes effect when the platform relaxes (org egress ceiling spec §D3);
599
+ * Refuses a patch that widens the org's sandbox (only a person widens it, never the Platform tool
600
+ * or an API token):
601
+ * - `outsideSandbox`: `allowed` where the organization runs `off` (an absent value follows the
602
+ * platform); clearing it follows the platform too, never wider than the platform allows
603
+ * (`org.outside_sandbox_not_allowed`);
604
+ * - `deviceNetwork`: compared as stored deltas, never as effective values (under the kill switch
605
+ * or a platform ceiling the effective values hide a widening that takes effect when the
606
+ * platform relaxes, org egress ceiling spec §D3): a default or ceiling opened
607
+ * ({@link deviceNetworkModeWidens}, `org.network_not_allowed`) or wider hosts
608
+ * ({@link deviceNetworkHostsWiden}, `org.sandbox_egress_not_allowed`);
569
609
  * - `externalSharing`: `on` where the org is off (absent = off).
570
610
  */
571
611
  async assertOnlyNarrows(before, patch) {
572
- if (patch.fullAccess !== undefined) {
573
- const platform = await readDevicesFullAccess(this.db.db, this.config, this.log);
574
- const next = patch.fullAccess === null ? platform.permission : patch.fullAccess;
575
- if ((before.fullAccess ?? platform.permission) !== "allowed" && next === "allowed") {
576
- throw fullAccessNotAllowed("Allowing Full permission needs a person in the organization settings.");
612
+ if (patch.outsideSandbox !== undefined) {
613
+ const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
614
+ const was = before.outsideSandbox ?? platform.outsideSandbox.permission;
615
+ const next = patch.outsideSandbox === null ? platform.outsideSandbox.permission : patch.outsideSandbox;
616
+ if (was !== "allowed" && next === "allowed") {
617
+ throw outsideSandboxNotAllowed("Allowing devices to run outside the sandbox needs a person in the organization settings.");
577
618
  }
578
619
  }
579
- if (patch.cloudNetwork !== undefined &&
580
- cloudNetworkWidens(before.cloudNetwork, patch.cloudNetwork ?? undefined)) {
581
- throw new ApiError("org.sandbox_egress_not_allowed", "Widening the cloud network needs a person in the organization settings.");
620
+ if (patch.deviceNetwork !== undefined) {
621
+ const next = patch.deviceNetwork ?? undefined;
622
+ // the stored delta (a widening that takes effect when the platform relaxes) and the
623
+ // effective value (an absent field follows the platform's) must both not open
624
+ const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
625
+ const field = deviceNetworkModeWidens(before.deviceNetwork, next) ??
626
+ effectiveNetworkWidens(effectiveOrgNetwork(platform.network, before.deviceNetwork), effectiveOrgNetwork(platform.network, next));
627
+ if (field !== null)
628
+ throw networkNotAllowed(`Opening the organization's network ${field} needs a person in the organization settings.`, field);
629
+ if (deviceNetworkHostsWiden(before.deviceNetwork, next))
630
+ throw new ApiError("org.sandbox_egress_not_allowed", "Widening the organization's device network hosts needs a person in the organization settings.");
582
631
  }
583
632
  if (patch.externalSharing === "on" && before.externalSharing !== "on") {
584
633
  throw externalSharingNotAllowed("Turning external sharing on needs a person in the organization settings on the web; an API token or the Platform tool may only turn it off.");
@@ -602,7 +651,7 @@ let OrgSettingsService = class OrgSettingsService {
602
651
  await this.assertOnlyNarrows(before, patch);
603
652
  const changes = Object.fromEntries(Object.entries(patch)
604
653
  .filter(([, v]) => v !== undefined)
605
- // null clears fullAccess / cloudNetwork / wakeOnBackgroundTask (follow the deployment
654
+ // null clears outsideSandbox / deviceNetwork / wakeOnBackgroundTask (follow the deployment
606
655
  // again), externalSharing (off) and promptSuggestions (follow the platform)
607
656
  .map(([k, v]) => [k, v === null ? undefined : v]));
608
657
  const arrangementPatch = patch.uiArrangement;
@@ -629,17 +678,15 @@ let OrgSettingsService = class OrgSettingsService {
629
678
  if (Object.keys(after.uiArrangement).length === 0)
630
679
  delete after.uiArrangement;
631
680
  }
632
- // A stored old `autoMode` is never dropped here: only the permission configuration
633
- // publication converts it (a mismatch window before activation keeps it). It is carried in
634
- // step with `fullAccess`; a write that does not choose the value stores what every reader
635
- // already sees: the narrower of the two (never refused, never wider).
636
- const legacy = "autoMode" in stored;
637
- if (legacy && patch.fullAccess === undefined)
638
- after.fullAccess = narrowedOrgFullAccess(before.fullAccess, stored.autoMode);
639
- if (after.fullAccess === undefined)
640
- delete after.fullAccess;
641
- if (after.cloudNetwork === undefined)
642
- delete after.cloudNetwork;
681
+ // Stored old keys (`autoMode`, `fullAccess`, `cloudNetwork`) are never dropped here: only the
682
+ // permission configuration publication converts them (a mismatch window before activation
683
+ // keeps them). `before` already reads them narrowed (orgDeviceSandboxOf), so a write that does
684
+ // not choose a value stores what every reader already sees (never refused, never wider), and
685
+ // the old keys are carried in step below.
686
+ if (after.outsideSandbox === undefined)
687
+ delete after.outsideSandbox;
688
+ if (after.deviceNetwork === undefined)
689
+ delete after.deviceNetwork;
643
690
  if (after.wakeOnBackgroundTask === undefined)
644
691
  delete after.wakeOnBackgroundTask;
645
692
  if (after.timeZone === undefined)
@@ -670,14 +717,11 @@ let OrgSettingsService = class OrgSettingsService {
670
717
  if (patch.theme?.id != null && patch.theme.id !== before.theme?.id) {
671
718
  await assertThemeOnIn(this.db.db, orgId, patch.theme.id);
672
719
  }
673
- // Merge with the stored value: keep the keys this version does not know (a cleared fullAccess /
674
- // cloudNetwork is not kept, nor the old name autoMode)
675
- const { autoMode: _legacyAutoMode, fullAccess: _oldFullAccess, cloudNetwork: _oldNetwork, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
676
- const written = {
677
- ...rest,
678
- ...after,
679
- ...(legacy && after.fullAccess !== undefined && { autoMode: after.fullAccess }),
680
- };
720
+ // Merge with the stored value: keep the keys this version does not know (a cleared
721
+ // outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
722
+ const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
723
+ const written = { ...rest, ...after };
724
+ keepOrgLegacyKeysInStep(written, stored);
681
725
  // An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
682
726
  // list keeps it unreadable (never healed to "nothing forbidden"); saving the list fixes it
683
727
  if (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools === undefined) {
@@ -700,24 +744,44 @@ let OrgSettingsService = class OrgSettingsService {
700
744
  target: orgId,
701
745
  detail: { before, after, ...(repairs && { repaired: true }), ...auditDetail },
702
746
  });
703
- if (patch.fullAccess !== undefined || patch.cloudNetwork !== undefined) {
747
+ if (patch.outsideSandbox !== undefined || patch.deviceNetwork !== undefined) {
748
+ // the consent reset follows the effective values as every reader sees them (re-read from
749
+ // what was written, within the platform), so a widening the platform hides resets nothing
750
+ const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
751
+ const effOutside = (o) => platform.outsideSandbox.permission === "off" ? "off" : (o.outsideSandbox ?? "allowed");
752
+ const reread = parseOrgSettings(written);
753
+ const prevNet = effectiveOrgNetwork(platform.network, before.deviceNetwork);
754
+ const nextNet = effectiveOrgNetwork(platform.network, reread.deviceNetwork);
755
+ // only a widening resets Full consent (running outside allowed again, a network or host
756
+ // list opening): a narrowing keeps what the consent covered
757
+ const resetConsent = (effOutside(before) === "off" && effOutside(reread) === "allowed") ||
758
+ effectiveNetworkWidens(prevNet, nextNet) !== null ||
759
+ deviceNetworkHostsWiden(before.deviceNetwork, reread.deviceNetwork);
704
760
  const machineRoots = await localMachineRoots(this.db.db, orgId);
761
+ // a network ceiling narrowed to the allowlist takes running open-network work; a default
762
+ // narrowed to the allowlist takes it from the cloud devices that follow the default
763
+ const networkNarrowed = prevNet.ceiling === "open" && nextNet.ceiling === "allowlist";
764
+ const following = !networkNarrowed && prevNet.default === "open" && nextNet.default === "allowlist"
765
+ ? await cloudDevicesFollowingDefault(this.db.db, orgId)
766
+ : null;
767
+ // the per-call hosts the org's new ceiling still allows (its hard allowlist ceiling and its
768
+ // exclusions): an independent grant keeps a removed host only within it
769
+ const lim = this.config.get().sandbox.limits;
770
+ const grantCeiling = hostGrantCeiling({ boundary: "operation", networkMode: "allowlist", networkCeiling: nextNet.ceiling }, lim, reread.deviceNetwork === undefined ? {} : { deviceNetwork: reread.deviceNetwork }, null);
771
+ const orgHosts = orgEffectiveHosts(lim, reread.deviceNetwork);
705
772
  await this.ceilings.publishLocked({ orgId }, "org", (scope, row) => {
706
- // Full off takes Full work and restricted work outside the machine's roots; anything
707
- // else (Full on) still goes through the host check below
708
- if (after.fullAccess === "off" &&
773
+ if (needsOpenNetwork(scope) &&
774
+ (networkNarrowed || following?.has(row.device_id) === true))
775
+ return true;
776
+ // outside off takes escalated work and restricted work outside the machine's roots;
777
+ // anything else still goes through the host check below
778
+ if (after.outsideSandbox === "off" &&
709
779
  needsWiderDeviceCeiling(scope, machineRoots.get(row.device_id)))
710
780
  return true;
711
781
  if (needsFullCeiling(scope))
712
- return after.fullAccess === "off";
713
- if (!("network" in scope) ||
714
- !isExecutionMethod(row.method) ||
715
- scope.network.kind !== "allowlist")
716
- return false;
717
- const hosts = this.effectiveNetwork(after).hosts;
718
- return scope.network.hosts.some((host) => !hosts.some((pattern) => coversHost(pattern, host)) &&
719
- !(this.effectiveNetwork(after).mode === "open" && row.granted_hosts.includes(host)));
720
- }, before.fullAccess !== after.fullAccess);
782
+ return after.outsideSandbox === "off";
783
+ return hostsNarrowed(scope, row, orgHosts, (host) => hostGrantable(grantCeiling, host));
784
+ }, resetConsent);
721
785
  }
722
786
  return viewOf(after, written);
723
787
  }
@@ -741,7 +805,7 @@ OrgSettingsService = __decorate([
741
805
  export { OrgSettingsService };
742
806
  /**
743
807
  * The one {@link OrgSettingsService}: the orgs module re-exports it, and the catalog imports it
744
- * directly (approving a network request writes the org's cloud network) without a cycle through
808
+ * directly (approving a network request writes the org's device network) without a cycle through
745
809
  * OrgsModule.
746
810
  */
747
811
  let OrgSettingsModule = class OrgSettingsModule {
@@ -27,6 +27,7 @@ import { AGENT_LOOP_FACTORY, type AgentLoopFactory } from "./runtime/run-steps.j
27
27
  import { RUN_HOOKS, type RunHooks } from "./runtime/run-worker.js";
28
28
  import { SUBAGENT_MESSAGES_HOOKS, type SubagentMessagesHooks } from "./runtime/subagents/messages.js";
29
29
  import { SANDBOX_LEASE_TIMINGS, type SandboxLeaseTimings } from "./sandbox/leases.js";
30
+ import { PERMISSION_AUTO_GRANT_HOOKS, type PermissionAutoGrantHooks } from "./sandbox/permission-auto-grants.js";
30
31
  import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
31
32
  import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
32
33
  import { TOOL_PIPELINE_HOOKS, type ToolPipelineHooks } from "./tools/pipeline.js";
@@ -69,7 +70,9 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
69
70
  * - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes);
70
71
  * - `PERMISSION_CONTEXT_ACTIVATION`: the recorded permission context producers (the request
71
72
  * boundary and the managed device context writer); production leaves them on, and a test may
72
- * turn them off to exercise the dormant state.
73
+ * turn them off to exercise the dormant state;
74
+ * - `PERMISSION_AUTO_GRANT_HOOKS`: a barrier after a Full access auto-grant's precheck (two
75
+ * replicas racing the same crossing).
73
76
  */
74
77
  interface KernelSeams {
75
78
  [AGENT_LOOP_FACTORY]: AgentLoopFactory;
@@ -102,6 +105,7 @@ interface KernelSeams {
102
105
  [EXTENSION_NET_SEAMS]: ExtensionNetSeams;
103
106
  [APP_INTERCEPTOR]: NestInterceptor;
104
107
  [PERMISSION_CONTEXT_ACTIVATION]: boolean;
108
+ [PERMISSION_AUTO_GRANT_HOOKS]: PermissionAutoGrantHooks;
105
109
  }
106
110
  /**
107
111
  * A seam of the kernel's own tests (`KernelAppOptions.overrides`): a value for one of the named
package/dist/overrides.js CHANGED
@@ -24,6 +24,7 @@ import { AGENT_LOOP_FACTORY } from "./runtime/run-steps.js";
24
24
  import { RUN_HOOKS } from "./runtime/run-worker.js";
25
25
  import { SUBAGENT_MESSAGES_HOOKS, } from "./runtime/subagents/messages.js";
26
26
  import { SANDBOX_LEASE_TIMINGS } from "./sandbox/leases.js";
27
+ import { PERMISSION_AUTO_GRANT_HOOKS, } from "./sandbox/permission-auto-grants.js";
27
28
  import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
28
29
  import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
29
30
  import { TOOL_PIPELINE_HOOKS } from "./tools/pipeline.js";
@@ -59,6 +60,7 @@ const SEAM_TOKENS = [
59
60
  EXTENSION_NET_SEAMS,
60
61
  APP_INTERCEPTOR,
61
62
  PERMISSION_CONTEXT_ACTIVATION,
63
+ PERMISSION_AUTO_GRANT_HOOKS,
62
64
  ];
63
65
  const allSeamsListed = true;
64
66
  void allSeamsListed;
@@ -334,7 +334,7 @@ export const PLATFORM_EXCLUSIONS = [
334
334
  {
335
335
  route: "POST /api/v1/orgs/:orgId/devices/:id/policy",
336
336
  category: "human-only",
337
- reason: "A person changes their own machine's mode and sandbox-mode network; enabling auto mode happens on the machine, never through an agent",
337
+ reason: "A person narrows their own machine's sandbox (hosts, network, running outside the sandbox) on its device page; widening happens on the machine, never through an agent",
338
338
  },
339
339
  {
340
340
  route: "POST /api/v1/device/authorize",