@capybara-hq/kernel 0.1.0-rc.20 → 0.1.0-rc.22

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 (247) hide show
  1. package/bootstrap.json +10 -1
  2. package/dist/agents/admin-agents.d.ts +16 -3
  3. package/dist/agents/admin-agents.js +65 -7
  4. package/dist/agents/agents.schemas.d.ts +24 -6
  5. package/dist/agents/agents.service.d.ts +4 -3
  6. package/dist/agents/agents.service.js +39 -26
  7. package/dist/agents/definition.d.ts +44 -6
  8. package/dist/agents/definition.js +86 -18
  9. package/dist/agents/from-template.d.ts +6 -3
  10. package/dist/agents/from-template.js +57 -44
  11. package/dist/agents/org-templates.js +97 -41
  12. package/dist/agents/templates.d.ts +6 -0
  13. package/dist/agents/templates.js +15 -1
  14. package/dist/catalog/admin-catalog.controller.d.ts +2 -4
  15. package/dist/catalog/admin-catalog.controller.js +2 -6
  16. package/dist/catalog/catalog.module.js +3 -0
  17. package/dist/catalog/claude/report.d.ts +9 -2
  18. package/dist/catalog/claude/report.js +1 -0
  19. package/dist/catalog/claude/translate.js +1 -1
  20. package/dist/catalog/component-promotion.js +1 -2
  21. package/dist/catalog/component-state.d.ts +13 -1
  22. package/dist/catalog/component-state.js +14 -5
  23. package/dist/catalog/marketplaces.service.d.ts +1 -1
  24. package/dist/catalog/marketplaces.service.js +2 -1
  25. package/dist/catalog/org-catalog.controller.d.ts +13 -3
  26. package/dist/catalog/org-catalog.controller.js +26 -4
  27. package/dist/catalog/org-catalog.schemas.d.ts +13 -0
  28. package/dist/catalog/org-catalog.schemas.js +34 -0
  29. package/dist/catalog/org-plugin-uploads.controller.js +0 -1
  30. package/dist/catalog/org-plugin-uploads.d.ts +0 -1
  31. package/dist/catalog/org-plugin-uploads.js +0 -3
  32. package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
  33. package/dist/catalog/org-plugin-uploads.schemas.js +0 -2
  34. package/dist/catalog/platform-components.d.ts +0 -1
  35. package/dist/catalog/platform-components.js +3 -8
  36. package/dist/catalog/plugin-import.d.ts +0 -8
  37. package/dist/catalog/plugin-import.js +4 -35
  38. package/dist/catalog/plugin-install.d.ts +2 -2
  39. package/dist/catalog/plugin-install.js +2 -2
  40. package/dist/catalog/plugin-package.d.ts +7 -0
  41. package/dist/catalog/plugin-package.js +27 -1
  42. package/dist/catalog/plugin-upgrade.d.ts +5 -6
  43. package/dist/catalog/plugin-upgrade.js +5 -23
  44. package/dist/catalog/requests.service.d.ts +66 -10
  45. package/dist/catalog/requests.service.js +196 -15
  46. package/dist/channels/actions.d.ts +2 -0
  47. package/dist/channels/actions.js +19 -4
  48. package/dist/channels/cards.d.ts +16 -2
  49. package/dist/channels/cards.js +40 -7
  50. package/dist/channels/channels.module.js +3 -0
  51. package/dist/channels/outbound.d.ts +22 -1
  52. package/dist/channels/outbound.js +116 -7
  53. package/dist/channels/phrases.d.ts +25 -0
  54. package/dist/channels/phrases.js +19 -0
  55. package/dist/channels/threads.d.ts +12 -0
  56. package/dist/channels/threads.js +34 -0
  57. package/dist/config/schema.d.ts +23 -1
  58. package/dist/config/schema.js +105 -5
  59. package/dist/conversations/conversations.service.d.ts +42 -9
  60. package/dist/conversations/conversations.service.js +57 -25
  61. package/dist/conversations/events.d.ts +106 -11
  62. package/dist/conversations/events.js +121 -18
  63. package/dist/conversations/message-context.d.ts +6 -3
  64. package/dist/conversations/message-context.js +14 -10
  65. package/dist/conversations/queue.d.ts +15 -2
  66. package/dist/conversations/queue.js +22 -3
  67. package/dist/conversations/queue.service.d.ts +12 -6
  68. package/dist/conversations/queue.service.js +36 -13
  69. package/dist/db/kernel-schema.d.ts +105 -3
  70. package/dist/devices/conversation-devices.d.ts +8 -1
  71. package/dist/devices/conversation-devices.js +8 -0
  72. package/dist/devices/devices.controller.d.ts +21 -4
  73. package/dist/devices/devices.controller.js +46 -8
  74. package/dist/devices/devices.schemas.d.ts +9 -1
  75. package/dist/devices/devices.schemas.js +11 -3
  76. package/dist/devices/devices.service.d.ts +176 -4
  77. package/dist/devices/devices.service.js +341 -6
  78. package/dist/devices/dto.d.ts +56 -3
  79. package/dist/devices/dto.js +51 -1
  80. package/dist/devices/public-suffix.d.ts +6 -0
  81. package/dist/devices/public-suffix.js +79 -0
  82. package/dist/errors.d.ts +46 -5
  83. package/dist/errors.js +46 -5
  84. package/dist/evals/reconstruct.d.ts +18 -13
  85. package/dist/evals/reconstruct.js +50 -36
  86. package/dist/evals/recorded-tools.d.ts +7 -7
  87. package/dist/evals/recorded-tools.js +4 -3
  88. package/dist/evals/trajectory.d.ts +6 -1
  89. package/dist/evals/trajectory.js +7 -0
  90. package/dist/extensions/bootstrap.d.ts +49 -10
  91. package/dist/extensions/bootstrap.js +104 -27
  92. package/dist/extensions/package.js +2 -2
  93. package/dist/http/api.module.js +5 -0
  94. package/dist/inbox/inbox.module.js +2 -1
  95. package/dist/inbox/inbox.service.d.ts +19 -4
  96. package/dist/inbox/inbox.service.js +14 -3
  97. package/dist/infra/config/kernel-config.service.js +11 -0
  98. package/dist/infra/events/kernel-events.d.ts +2 -1
  99. package/dist/lifecycle/kernel-lifecycle.d.ts +5 -1
  100. package/dist/lifecycle/kernel-lifecycle.js +16 -4
  101. package/dist/local-devices/device-policy.service.d.ts +65 -0
  102. package/dist/local-devices/device-policy.service.js +217 -0
  103. package/dist/local-devices/local-device-gateway.js +4 -1
  104. package/dist/local-devices/local-device-provider.d.ts +40 -3
  105. package/dist/local-devices/local-device-provider.js +109 -7
  106. package/dist/local-devices/local-devices.module.d.ts +2 -1
  107. package/dist/local-devices/local-devices.module.js +19 -3
  108. package/dist/local-devices/machines.d.ts +14 -3
  109. package/dist/local-devices/machines.js +41 -3
  110. package/dist/local-devices/network-grants.d.ts +104 -0
  111. package/dist/local-devices/network-grants.js +288 -0
  112. package/dist/local-devices/policy-summary.d.ts +20 -0
  113. package/dist/local-devices/policy-summary.js +63 -0
  114. package/dist/orgs/orgs.module.js +4 -10
  115. package/dist/orgs/roles.d.ts +1 -1
  116. package/dist/orgs/roles.js +4 -0
  117. package/dist/orgs/settings.controller.js +2 -1
  118. package/dist/orgs/settings.service.d.ts +164 -12
  119. package/dist/orgs/settings.service.js +212 -24
  120. package/dist/platform/exclusions.js +11 -1
  121. package/dist/platform/operation.js +4 -0
  122. package/dist/platform/ops/admin-items.ops.js +1 -1
  123. package/dist/platform/ops/agent-skills.ops.js +2 -2
  124. package/dist/platform/ops/agent-templates.ops.js +2 -2
  125. package/dist/platform/ops/agents.ops.js +11 -15
  126. package/dist/platform/ops/devices.ops.js +3 -1
  127. package/dist/platform/ops/inbox.ops.js +19 -0
  128. package/dist/platform/ops/org-settings.ops.js +14 -5
  129. package/dist/platform/ops/platform.ops.d.ts +9 -1
  130. package/dist/platform/ops/platform.ops.js +34 -12
  131. package/dist/platform/ops/requests.ops.js +3 -2
  132. package/dist/platform/ops/schedules.ops.d.ts +21 -0
  133. package/dist/platform/ops/schedules.ops.js +470 -0
  134. package/dist/platform/ops/skills.ops.js +3 -3
  135. package/dist/platform/platform-ops.module.d.ts +2 -1
  136. package/dist/platform/platform-ops.module.js +5 -0
  137. package/dist/platform/route-schemas.js +3 -0
  138. package/dist/roles/worker.module.js +3 -0
  139. package/dist/runtime/context/build.js +13 -4
  140. package/dist/runtime/context/compaction.js +6 -3
  141. package/dist/runtime/context/device-paths.d.ts +43 -21
  142. package/dist/runtime/context/device-paths.js +104 -21
  143. package/dist/runtime/context/run-context.d.ts +9 -0
  144. package/dist/runtime/context/run-context.js +8 -0
  145. package/dist/runtime/context/skills.d.ts +14 -1
  146. package/dist/runtime/context/skills.js +36 -5
  147. package/dist/runtime/maintenance.d.ts +4 -2
  148. package/dist/runtime/maintenance.js +16 -5
  149. package/dist/runtime/run-finish.d.ts +6 -1
  150. package/dist/runtime/run-finish.js +16 -2
  151. package/dist/runtime/run-queue.js +21 -2
  152. package/dist/runtime/run-worker.js +14 -33
  153. package/dist/runtime/runtime.module.js +3 -0
  154. package/dist/runtime/subagents/definition.d.ts +32 -14
  155. package/dist/runtime/subagents/definition.js +106 -109
  156. package/dist/runtime/subagents/dispatch.js +4 -3
  157. package/dist/runtime/subagents/preamble.d.ts +2 -1
  158. package/dist/runtime/subagents/preamble.js +2 -1
  159. package/dist/runtime/waits.js +14 -4
  160. package/dist/sandbox/sandbox.service.d.ts +120 -10
  161. package/dist/sandbox/sandbox.service.js +335 -28
  162. package/dist/sandbox/tiers.d.ts +86 -0
  163. package/dist/sandbox/tiers.js +96 -0
  164. package/dist/schedules/effective-settings.d.ts +16 -0
  165. package/dist/schedules/effective-settings.js +17 -0
  166. package/dist/schedules/errors.d.ts +8 -0
  167. package/dist/schedules/errors.js +8 -0
  168. package/dist/schedules/fire.d.ts +118 -0
  169. package/dist/schedules/fire.js +625 -0
  170. package/dist/schedules/grant-rules.d.ts +94 -0
  171. package/dist/schedules/grant-rules.js +126 -0
  172. package/dist/schedules/job-ids.d.ts +32 -0
  173. package/dist/schedules/job-ids.js +27 -0
  174. package/dist/schedules/pause.d.ts +9 -0
  175. package/dist/schedules/pause.js +33 -0
  176. package/dist/schedules/run-tracker.d.ts +81 -0
  177. package/dist/schedules/run-tracker.js +333 -0
  178. package/dist/schedules/scan.job.d.ts +64 -0
  179. package/dist/schedules/scan.job.js +303 -0
  180. package/dist/schedules/schedule-math.d.ts +31 -0
  181. package/dist/schedules/schedule-math.js +223 -0
  182. package/dist/schedules/scheduled-tasks.service.d.ts +351 -0
  183. package/dist/schedules/scheduled-tasks.service.js +1193 -0
  184. package/dist/schedules/schedules.controller.d.ts +68 -0
  185. package/dist/schedules/schedules.controller.js +242 -0
  186. package/dist/schedules/schedules.module.d.ts +16 -0
  187. package/dist/schedules/schedules.module.js +65 -0
  188. package/dist/schedules/schedules.schemas.d.ts +316 -0
  189. package/dist/schedules/schedules.schemas.js +186 -0
  190. package/dist/schedules/store.d.ts +81 -0
  191. package/dist/schedules/store.js +390 -0
  192. package/dist/schedules/store.module.d.ts +6 -0
  193. package/dist/schedules/store.module.js +21 -0
  194. package/dist/schedules/types.d.ts +108 -0
  195. package/dist/schedules/types.js +1 -0
  196. package/dist/schedules/unattended.d.ts +117 -0
  197. package/dist/schedules/unattended.js +228 -0
  198. package/dist/setup/oauth-token-probe.js +8 -4
  199. package/dist/skills/agent-skills.service.d.ts +4 -8
  200. package/dist/skills/agent-skills.service.js +18 -53
  201. package/dist/skills/catalog.d.ts +65 -62
  202. package/dist/skills/catalog.js +109 -206
  203. package/dist/skills/conversation-catalog.d.ts +3 -3
  204. package/dist/skills/conversation-catalog.js +5 -12
  205. package/dist/skills/invoke.d.ts +2 -2
  206. package/dist/skills/skills.controller.d.ts +3 -1
  207. package/dist/skills/skills.service.d.ts +38 -37
  208. package/dist/skills/skills.service.js +168 -107
  209. package/dist/skills/usable.d.ts +57 -8
  210. package/dist/skills/usable.js +172 -38
  211. package/dist/tools/approvals.controller.d.ts +4 -2
  212. package/dist/tools/approvals.controller.js +17 -2
  213. package/dist/tools/approvals.schemas.d.ts +1 -0
  214. package/dist/tools/approvals.schemas.js +3 -1
  215. package/dist/tools/approvals.service.d.ts +182 -7
  216. package/dist/tools/approvals.service.js +597 -13
  217. package/dist/tools/builtin-names.d.ts +25 -4
  218. package/dist/tools/builtin-names.js +45 -4
  219. package/dist/tools/builtins/builtin-tools.d.ts +8 -0
  220. package/dist/tools/builtins/builtin-tools.js +23 -2
  221. package/dist/tools/builtins/sandbox/bash.js +16 -7
  222. package/dist/tools/builtins/sandbox/common.d.ts +1 -1
  223. package/dist/tools/builtins/sandbox/common.js +33 -10
  224. package/dist/tools/builtins/sandbox/edit.js +7 -3
  225. package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
  226. package/dist/tools/builtins/sandbox/file-state.js +33 -3
  227. package/dist/tools/builtins/sandbox/write.js +8 -4
  228. package/dist/tools/builtins/schedules.d.ts +107 -0
  229. package/dist/tools/builtins/schedules.js +789 -0
  230. package/dist/tools/elicitation.d.ts +2 -0
  231. package/dist/tools/elicitation.js +1 -1
  232. package/dist/tools/fixed-ask.d.ts +7 -0
  233. package/dist/tools/fixed-ask.js +9 -0
  234. package/dist/tools/network-asks.d.ts +109 -0
  235. package/dist/tools/network-asks.js +221 -0
  236. package/dist/tools/pipeline.d.ts +53 -6
  237. package/dist/tools/pipeline.js +202 -13
  238. package/dist/tools/policy.d.ts +21 -8
  239. package/dist/tools/policy.js +63 -9
  240. package/dist/tools/registry.d.ts +10 -1
  241. package/dist/tools/tools.module.js +12 -0
  242. package/package.json +2 -2
  243. package/src/migrations/0113_scheduled_tasks.sql +108 -0
  244. package/src/migrations/0114_network_asks.sql +23 -0
  245. package/src/migrations/0115_network_requests.sql +28 -0
  246. package/src/migrations/0116_skills_default_on.sql +37 -0
  247. package/src/migrations/0117_sandbox_tiers.sql +11 -0
@@ -1,14 +1,17 @@
1
- import type { LocalizedName, SandboxLimits } from "@capybara-hq/plugin-sdk";
1
+ import { type DeviceFeature, type DeviceLocalPolicySummary, type LocalizedName, type SandboxLimits, type SandboxTier } from "@capybara-hq/plugin-sdk";
2
2
  import { ExtensionDisplayNames } from "../extensions/display-name.js";
3
3
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
6
  import { LockService } from "../infra/lock/lock.service.js";
7
+ import { DevicePolicyService } from "../local-devices/device-policy.service.js";
7
8
  import { MachinesService } from "../local-devices/machines.js";
8
9
  import type { KernelLogger } from "../log.js";
10
+ import type { DeviceSandboxLevel } from "../runtime/context/device-paths.js";
9
11
  import { SandboxJobs } from "../sandbox/jobs.js";
10
12
  import { SandboxProviders } from "../sandbox/providers.js";
11
13
  import { SandboxService } from "../sandbox/sandbox.service.js";
14
+ import { type EffectiveSandboxPolicy } from "../sandbox/tiers.js";
12
15
  import { DeviceAccess } from "./access.js";
13
16
  /** A device as its owner sees it (`GET /orgs/:orgId/devices`). */
14
17
  export interface DeviceView {
@@ -42,6 +45,17 @@ export interface DeviceView {
42
45
  online: boolean | null;
43
46
  /** A local device's connected machine (its unrevoked one); null for cloud or none. */
44
47
  machine: DeviceMachineView | null;
48
+ /**
49
+ * A local device's network facts as its connected machine last reported them (network
50
+ * ask-to-allow spec §5.4): the program's features and its local policy summary (null when
51
+ * unknown). null for a cloud device or a local one without a connected machine.
52
+ */
53
+ network: {
54
+ features: string[];
55
+ policy: DeviceLocalPolicySummary | null;
56
+ } | null;
57
+ /** Its sandbox level (sandbox dev tiers spec §4, §11.1). */
58
+ sandbox: DeviceSandboxView;
45
59
  sessionIsolation: boolean;
46
60
  /** Its file system is gone at the provider; reset the files to use it again. */
47
61
  filesLost: boolean;
@@ -49,10 +63,92 @@ export interface DeviceView {
49
63
  status: "running" | "suspended";
50
64
  lastUsedAt: string;
51
65
  } | null;
52
- /** The org's effective sandbox limits (phase 1 devices use them unchanged, spec §8.4). */
66
+ /**
67
+ * The sandbox limits of its effective tier (sandbox dev tiers spec §4.2): what a cloud
68
+ * instance is created with; for a local device the network of the org's default tier.
69
+ */
53
70
  limits: SandboxLimits;
54
71
  createdAt: string;
55
72
  }
73
+ /**
74
+ * A device's sandbox level as its owner sees it (sandbox dev tiers spec §4, §11.1).
75
+ */
76
+ export interface DeviceSandboxView {
77
+ /**
78
+ * The tier the owner chose: a cloud device's stored one, a local device's as its machine last
79
+ * reported it; null follows the org's default.
80
+ */
81
+ tier: SandboxTier | null;
82
+ /**
83
+ * The tier its commands run at: min(chosen ?? the org's default, ceiling); `strict` for a local
84
+ * device whose program lacks the `tiers` feature (it runs as before tiers).
85
+ */
86
+ effectiveTier: SandboxTier;
87
+ /** The highest tier the device may reach: min(the org's max, the platform's max). */
88
+ ceiling: SandboxTier;
89
+ /** Which ceiling lowered the chosen tier; null when none did. */
90
+ cappedBy: "org" | "platform" | null;
91
+ /** The org's default tier for devices that choose none (at most {@link ceiling}). */
92
+ defaultTier: SandboxTier;
93
+ /** The org and the platform let a local device run without a sandbox (its ceiling is `open`). */
94
+ allowUnsandboxed: boolean;
95
+ /** `none`: a local device runs its commands without a sandbox (its owner set it locally). */
96
+ isolation: "sandbox" | "none";
97
+ /**
98
+ * A cloud device's instance runs another tier or network than {@link effectiveTier}: its next
99
+ * use updates or recreates it, files kept (「下次使用时生效,文件保留」).
100
+ */
101
+ pendingNextUse: boolean;
102
+ /**
103
+ * A cloud device's new tier waits for a file reset: its provider applies limits only when the
104
+ * file system is made (`limitsApplyAt: "fileSystem"`) and cannot update them.
105
+ */
106
+ pendingFilesReset: boolean;
107
+ /** Its last {@link RECENT_POLICY_CHANGES} sandbox changes, newest first (§10.4). */
108
+ recent: DeviceSandboxChangeView[];
109
+ }
110
+ /** How many recent sandbox changes a device view lists. */
111
+ export declare const RECENT_POLICY_CHANGES = 10;
112
+ /**
113
+ * One sandbox change of a device, as its owner sees it on the device page (§10.4):
114
+ * - `policy` (`device.policy_changed`): a local policy change sent to the machine;
115
+ * - `tier` (`device.tier_changed`): a cloud device's tier set by its owner;
116
+ * - `isolation` (`device.isolation_reported`): the machine reported running without a sandbox,
117
+ * or with one again.
118
+ */
119
+ export interface DeviceSandboxChangeView {
120
+ at: string;
121
+ kind: "policy" | "tier" | "isolation";
122
+ /** Hosts added to / removed from the local allowlist (`policy` only; else empty). */
123
+ add: string[];
124
+ remove: string[];
125
+ /** The tier set (`to: null`: follow the org's default); null when the tier did not change. */
126
+ tier: {
127
+ to: SandboxTier | null;
128
+ } | null;
129
+ /** The isolation set or reported; null when it did not change. */
130
+ isolation: "sandbox" | "none" | null;
131
+ /** The deciding account's display name (null when the account is gone). */
132
+ by: string | null;
133
+ /** `device`: reported by the machine itself (`isolation`). */
134
+ via: "web" | "im" | "device";
135
+ /** The machine answered with the policy as written (false: the answer never came). */
136
+ confirmed: boolean;
137
+ }
138
+ /** A change of a local device's policy by its owner (`POST /devices/:id/policy`). */
139
+ export interface DevicePolicyChange {
140
+ add?: string[] | undefined;
141
+ remove?: string[] | undefined;
142
+ /** null: follow the org's default. */
143
+ tier?: SandboxTier | null | undefined;
144
+ isolation?: "sandbox" | undefined;
145
+ }
146
+ /** What `PATCH /devices/:id` changes. */
147
+ export interface DevicePatch {
148
+ name?: string;
149
+ /** A cloud device's tier; null follows the org's default. */
150
+ tier?: SandboxTier | null;
151
+ }
56
152
  /** The machine connected to a local device, as its owner sees it. */
57
153
  export interface DeviceMachineView {
58
154
  id: string;
@@ -92,9 +188,10 @@ export declare class DevicesService {
92
188
  /** Reads the device relay's lease (`online`). */
93
189
  private readonly locks;
94
190
  private readonly machines;
95
- constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, providers: Pick<SandboxProviders, "cloud" | "forName">, sandbox: Pick<SandboxService, "orgLimits">, sandboxJobs: Pick<SandboxJobs, "destroy" | "resetFiles">, access: Pick<DeviceAccess, "usable">, displayNames: Pick<ExtensionDisplayNames, "many">, log: Pick<KernelLogger, "warn">,
191
+ private readonly policies;
192
+ constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, providers: Pick<SandboxProviders, "cloud" | "forName">, sandbox: Pick<SandboxService, "deviceLimits" | "limitsState">, sandboxJobs: Pick<SandboxJobs, "destroy" | "resetFiles">, access: Pick<DeviceAccess, "usable">, displayNames: Pick<ExtensionDisplayNames, "many">, log: Pick<KernelLogger, "warn">,
96
193
  /** Reads the device relay's lease (`online`). */
97
- locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">);
194
+ locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">, policies: Pick<DevicePolicyService, "apply" | "summary">);
98
195
  /**
99
196
  * The person's live devices in the org, the default first, then by creation. With a
100
197
  * current sandbox provider the default device is created first if missing (its first need,
@@ -149,6 +246,34 @@ export declare class DevicesService {
149
246
  */
150
247
  rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<DeviceView>;
151
248
  private renameIn;
249
+ /**
250
+ * `PATCH /devices/:id` (sandbox dev tiers spec §7.2): renames one of the person's live devices
251
+ * ({@link rename}) and sets a cloud device's sandbox tier, in one transaction. The tier: null
252
+ * follows the org's default; above the device's ceiling (the org's or the platform's max) →
253
+ * `device.tier_not_allowed`; a local device → `device.tier_on_device` (its tier is its
254
+ * machine's, changed with {@link changePolicy}). A changed tier is audited `device.tier_changed`
255
+ * (`from` / `to`); the device's next use applies it (the instance is updated, or recreated on
256
+ * the kept files). Callers make sure only a person in a session sets the tier.
257
+ */
258
+ update(orgId: string, accountId: string, id: string, patch: DevicePatch, actorTokenId?: string): Promise<DeviceView>;
259
+ private updateIn;
260
+ /** The org's sandbox policy for a device choosing `tier` (null: the org's default). */
261
+ private policyFor;
262
+ /**
263
+ * The sandbox level a sandbox call in the device runs at now, for the model (`device_paths`,
264
+ * spec §11.5): see {@link sandboxStateOf}, plus
265
+ * - `network: "none"` when the org's or the platform's sandbox network is off;
266
+ * - a cloud device whose new limits wait for a file reset: the tier and network its instance
267
+ * still runs with (`limitsState(...).applied`; open with its network on when unrecorded);
268
+ * - a local device: its machine's localhost and unix socket facts; in a scheduled run without
269
+ * a person (`runId`, {@link unattendedTierOf}) and without the task's `tier:open` grant its
270
+ * tier is capped at `dev`, as the exec args cap it;
271
+ * - `unattended` in such a run: nobody can approve a domain.
272
+ * Null when the device is not a live device of the org.
273
+ */
274
+ sandboxLevel(orgId: string, deviceId: string, runId?: string): Promise<DeviceSandboxLevel | null>;
275
+ /** Renames the device locked by {@link lockOwn} (`before`); see {@link rename}. */
276
+ private renameLocked;
152
277
  /**
153
278
  * Deletes one of the person's live devices: soft delete, its IM default row cleared, and
154
279
  * after the commit a `sandbox-destroy-for` job (the worker waits for running commands, then
@@ -163,6 +288,23 @@ export declare class DevicesService {
163
288
  * again); see {@link MachinesService.revoke}.
164
289
  */
165
290
  revokeMachine(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
291
+ /**
292
+ * The owner changes one of their own devices' local policy (network ask-to-allow spec §7, §13
293
+ * Q6; sandbox dev tiers spec §7.3): sent to the machine with the `policy` op, which is the
294
+ * authority and answers with the policy as written. Anyone but the owner gets
295
+ * `device.not_found`. A `tier` above the device's ceiling → `device.tier_not_allowed`. A widening
296
+ * change (`add`; a `tier` that may raise the machine's, judged as the machine judges it) is
297
+ * refused up front with `device.policy_refused` when the machine last reported
298
+ * `remoteGrants: "off"` (otherwise the machine decides); narrowing is always sent, and
299
+ * `isolation` is only ever `sandbox`. The machine offline → `device.offline`; a cloud device or a
300
+ * program without the `policyOp` feature → `device.policy_unsupported`; the machine's refusal →
301
+ * `device.policy_refused` with its message. Callers are human sessions only (no personal access
302
+ * token, no service token, no Platform op).
303
+ */
304
+ changePolicy(orgId: string, account: {
305
+ id: string;
306
+ displayName: string;
307
+ }, id: string, change: DevicePolicyChange): Promise<DeviceLocalPolicySummary>;
166
308
  /**
167
309
  * Starts one of the person's devices over with empty files (after
168
310
  * `device.files_lost`): records the request (audit), then, after the commit, enqueues the
@@ -238,6 +380,12 @@ export declare class DevicesService {
238
380
  private stranded;
239
381
  /** The person's live devices (or the one `id`) as views. */
240
382
  private views;
383
+ /**
384
+ * The last {@link RECENT_POLICY_CHANGES} sandbox changes of each device in the org (audit rows
385
+ * `device.policy_changed`, `device.tier_changed`, `device.isolation_reported`), newest first,
386
+ * with the deciding account's display name.
387
+ */
388
+ private recentSandboxChanges;
241
389
  /**
242
390
  * Serializes the person's device writes in the org: the org row (`FOR SHARE`), then their
243
391
  * membership row (`FOR NO KEY UPDATE`, or `FOR SHARE` with `mode` share: enough to keep the
@@ -249,3 +397,27 @@ export declare class DevicesService {
249
397
  private lockOwn;
250
398
  private assertNameFree;
251
399
  }
400
+ /** What {@link sandboxStateOf} reads of a device. */
401
+ export interface DeviceSandboxFacts {
402
+ source: "cloud" | "local";
403
+ /** A cloud device's stored tier (ignored for a local device). */
404
+ tier: SandboxTier | null;
405
+ /** A local device's connected machine's features ([] when none is connected). */
406
+ features: readonly DeviceFeature[];
407
+ /** A local device's policy summary as last reported (null when unknown or none connected). */
408
+ policy: DeviceLocalPolicySummary | null;
409
+ }
410
+ /**
411
+ * A device's sandbox level (spec §4.2, §4.4): its chosen tier (a cloud device's stored one, a
412
+ * local device's reported one) under the org's policy (`policyOf`). A local device whose program
413
+ * lacks the `tiers` feature runs `strict` (it ignores the tier the kernel sends); it runs without
414
+ * a sandbox only when it reports `isolation: "none"` and its effective tier is `open` (the device
415
+ * keeps the sandbox at any lower tier).
416
+ */
417
+ export declare function sandboxStateOf(policyOf: (tier: SandboxTier | null) => EffectiveSandboxPolicy, d: DeviceSandboxFacts): Omit<DeviceSandboxView, "pendingNextUse" | "pendingFilesReset" | "recent">;
418
+ /**
419
+ * Whether setting a local device's tier to `next` (null: follow the org's default) may raise it,
420
+ * not knowing the org's default at the machine: a tier above the reported one, any tier but
421
+ * `strict` when it reports none, and following the default when it reports `strict` or `dev`.
422
+ */
423
+ export declare function tierWidens(reported: SandboxTier | undefined, next: SandboxTier | null | undefined): boolean;