@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.42

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 (326) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/admin/admin.schemas.d.ts +6 -0
  3. package/dist/admin/org-network.service.d.ts +3 -1
  4. package/dist/admin/org-network.service.js +10 -2
  5. package/dist/app.d.ts +4 -0
  6. package/dist/app.js +2 -0
  7. package/dist/background/finish.d.ts +9 -1
  8. package/dist/background/finish.js +57 -4
  9. package/dist/background/launch.d.ts +23 -0
  10. package/dist/background/launch.js +55 -1
  11. package/dist/background/managed-output.d.ts +110 -0
  12. package/dist/background/managed-output.js +219 -0
  13. package/dist/background/managed.d.ts +52 -0
  14. package/dist/background/managed.js +128 -0
  15. package/dist/background/poll.job.d.ts +35 -1
  16. package/dist/background/poll.job.js +174 -9
  17. package/dist/background/render.js +1 -0
  18. package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
  19. package/dist/background/retire-legacy-tasks.job.js +149 -0
  20. package/dist/background/session.d.ts +15 -5
  21. package/dist/background/session.js +22 -6
  22. package/dist/background/stop.d.ts +35 -5
  23. package/dist/background/stop.js +94 -8
  24. package/dist/background/store.d.ts +110 -3
  25. package/dist/background/store.js +205 -3
  26. package/dist/background/tasks.service.d.ts +18 -1
  27. package/dist/background/tasks.service.js +99 -9
  28. package/dist/catalog/marketplaces.service.d.ts +1 -1
  29. package/dist/channels/cards.js +1 -1
  30. package/dist/channels/inbound.js +2 -0
  31. package/dist/channels/phrases.d.ts +4 -0
  32. package/dist/channels/phrases.js +4 -0
  33. package/dist/config/load.d.ts +18 -0
  34. package/dist/config/load.js +39 -1
  35. package/dist/config/permission-migration.d.ts +26 -0
  36. package/dist/config/permission-migration.js +64 -0
  37. package/dist/config/schema.d.ts +1 -1
  38. package/dist/config/schema.js +11 -10
  39. package/dist/conversations/conversations.controller.d.ts +1 -1
  40. package/dist/conversations/conversations.controller.js +1 -1
  41. package/dist/conversations/conversations.module.js +12 -0
  42. package/dist/conversations/conversations.service.d.ts +11 -2
  43. package/dist/conversations/conversations.service.js +97 -27
  44. package/dist/conversations/event-log.d.ts +1 -1
  45. package/dist/conversations/event-log.js +10 -2
  46. package/dist/conversations/events.d.ts +304 -4
  47. package/dist/conversations/events.js +279 -29
  48. package/dist/conversations/permission-profile-store.d.ts +50 -0
  49. package/dist/conversations/permission-profile-store.js +67 -0
  50. package/dist/conversations/permission-profile-store.module.d.ts +2 -0
  51. package/dist/conversations/permission-profile-store.module.js +19 -0
  52. package/dist/conversations/permission-profiles.controller.d.ts +84 -0
  53. package/dist/conversations/permission-profiles.controller.js +105 -0
  54. package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
  55. package/dist/conversations/permission-profiles.schemas.js +23 -0
  56. package/dist/conversations/permission-profiles.service.d.ts +56 -0
  57. package/dist/conversations/permission-profiles.service.js +179 -0
  58. package/dist/db/kernel-schema.d.ts +238 -3
  59. package/dist/devices/access.js +1 -1
  60. package/dist/devices/access.module.d.ts +2 -0
  61. package/dist/devices/access.module.js +19 -0
  62. package/dist/devices/conversation-devices.d.ts +8 -29
  63. package/dist/devices/conversation-devices.js +37 -73
  64. package/dist/devices/device-projects.service.d.ts +26 -28
  65. package/dist/devices/device-projects.service.js +123 -127
  66. package/dist/devices/devices.controller.js +3 -1
  67. package/dist/devices/devices.module.js +11 -9
  68. package/dist/devices/devices.service.d.ts +116 -8
  69. package/dist/devices/devices.service.js +252 -20
  70. package/dist/devices/dto.d.ts +16 -0
  71. package/dist/devices/dto.js +34 -6
  72. package/dist/devices/errors.d.ts +8 -0
  73. package/dist/devices/errors.js +10 -0
  74. package/dist/devices/project-rules.d.ts +44 -0
  75. package/dist/devices/project-rules.js +27 -0
  76. package/dist/devices/working-root.d.ts +6 -0
  77. package/dist/devices/working-root.js +12 -1
  78. package/dist/errors.d.ts +31 -0
  79. package/dist/errors.js +31 -0
  80. package/dist/evals/reconstruct.d.ts +19 -2
  81. package/dist/evals/reconstruct.js +40 -2
  82. package/dist/evals/recorded-permission-context.d.ts +77 -0
  83. package/dist/evals/recorded-permission-context.js +151 -0
  84. package/dist/evals/recorded-tools.d.ts +10 -1
  85. package/dist/evals/recorded-tools.js +27 -3
  86. package/dist/evals/run-replay.d.ts +8 -2
  87. package/dist/evals/run-replay.js +18 -2
  88. package/dist/evals/trajectory.d.ts +1 -1
  89. package/dist/evals/worker.d.ts +10 -1
  90. package/dist/evals/worker.js +23 -14
  91. package/dist/http/api.module.js +2 -0
  92. package/dist/identity/accounts.d.ts +14 -1
  93. package/dist/identity/accounts.js +61 -5
  94. package/dist/identity/identity.module.js +2 -0
  95. package/dist/identity/settings.d.ts +28 -12
  96. package/dist/identity/settings.js +89 -33
  97. package/dist/index.d.ts +6 -0
  98. package/dist/index.js +5 -0
  99. package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
  100. package/dist/infra/cli/kernel-cli.module.js +5 -2
  101. package/dist/infra/cli/permission-cutover.d.ts +59 -0
  102. package/dist/infra/cli/permission-cutover.js +107 -0
  103. package/dist/infra/config/kernel-config.service.d.ts +2 -2
  104. package/dist/infra/config/kernel-config.service.js +31 -11
  105. package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
  106. package/dist/infra/database/startup-activation-transaction.js +242 -0
  107. package/dist/infra/database/transaction-host.d.ts +47 -0
  108. package/dist/infra/database/transaction-host.js +119 -0
  109. package/dist/infra/database/xact-lock.d.ts +1 -0
  110. package/dist/infra/database/xact-lock.js +6 -0
  111. package/dist/infra/outbox/registry.d.ts +39 -0
  112. package/dist/infra/outbox/registry.js +18 -0
  113. package/dist/kernel.module.js +2 -0
  114. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  115. package/dist/lifecycle/kernel-lifecycle.js +55 -28
  116. package/dist/local-devices/device-auth.js +1 -1
  117. package/dist/local-devices/device-policy.service.d.ts +35 -5
  118. package/dist/local-devices/device-policy.service.js +188 -13
  119. package/dist/local-devices/instance-bindings.d.ts +82 -0
  120. package/dist/local-devices/instance-bindings.js +304 -0
  121. package/dist/local-devices/keys.d.ts +5 -0
  122. package/dist/local-devices/keys.js +5 -0
  123. package/dist/local-devices/local-device-gateway.d.ts +19 -4
  124. package/dist/local-devices/local-device-gateway.js +185 -17
  125. package/dist/local-devices/local-device-provider.d.ts +42 -7
  126. package/dist/local-devices/local-device-provider.js +185 -10
  127. package/dist/local-devices/local-devices.module.d.ts +17 -2
  128. package/dist/local-devices/local-devices.module.js +49 -8
  129. package/dist/local-devices/machines.d.ts +35 -12
  130. package/dist/local-devices/machines.js +203 -8
  131. package/dist/local-devices/network-grants.js +3 -3
  132. package/dist/local-devices/network-grants.module.d.ts +2 -0
  133. package/dist/local-devices/network-grants.module.js +14 -0
  134. package/dist/local-devices/owner-report.d.ts +79 -0
  135. package/dist/local-devices/owner-report.js +155 -0
  136. package/dist/local-devices/owner-reports.d.ts +48 -0
  137. package/dist/local-devices/owner-reports.js +190 -0
  138. package/dist/local-devices/policy-summary.d.ts +24 -1
  139. package/dist/local-devices/policy-summary.js +48 -0
  140. package/dist/local-devices/relay.d.ts +82 -6
  141. package/dist/local-devices/relay.js +187 -16
  142. package/dist/local-devices/targets.d.ts +16 -1
  143. package/dist/local-devices/targets.js +35 -2
  144. package/dist/orgs/cloud-network-setting.d.ts +33 -0
  145. package/dist/orgs/cloud-network-setting.js +47 -0
  146. package/dist/orgs/offboarding.d.ts +3 -1
  147. package/dist/orgs/offboarding.js +8 -2
  148. package/dist/orgs/org-lock.d.ts +10 -4
  149. package/dist/orgs/org-lock.js +10 -4
  150. package/dist/orgs/orgs.service.d.ts +3 -1
  151. package/dist/orgs/orgs.service.js +8 -2
  152. package/dist/orgs/settings.controller.d.ts +4 -1
  153. package/dist/orgs/settings.controller.js +3 -3
  154. package/dist/orgs/settings.service.d.ts +48 -56
  155. package/dist/orgs/settings.service.js +144 -101
  156. package/dist/overrides.d.ts +6 -1
  157. package/dist/overrides.js +2 -0
  158. package/dist/platform/exclusions.js +20 -0
  159. package/dist/platform/ops/admin.ops.js +14 -11
  160. package/dist/platform/ops/agent-skills.ops.js +2 -0
  161. package/dist/platform/ops/devices.ops.js +10 -2
  162. package/dist/platform/ops/org-settings.ops.js +6 -6
  163. package/dist/platform/ops/orgs.ops.js +1 -0
  164. package/dist/roles/worker.module.js +4 -0
  165. package/dist/runtime/context/build.d.ts +3 -1
  166. package/dist/runtime/context/build.js +19 -3
  167. package/dist/runtime/context/compaction.js +5 -0
  168. package/dist/runtime/context/device-paths.d.ts +9 -2
  169. package/dist/runtime/context/device-paths.js +20 -0
  170. package/dist/runtime/context/permission-profile.d.ts +46 -0
  171. package/dist/runtime/context/permission-profile.js +194 -0
  172. package/dist/runtime/maintenance.d.ts +7 -1
  173. package/dist/runtime/maintenance.js +43 -15
  174. package/dist/runtime/model-call.d.ts +32 -0
  175. package/dist/runtime/model-call.js +67 -0
  176. package/dist/runtime/permission-context-errors.d.ts +39 -0
  177. package/dist/runtime/permission-context-errors.js +67 -0
  178. package/dist/runtime/permission-context.service.d.ts +60 -0
  179. package/dist/runtime/permission-context.service.js +286 -0
  180. package/dist/runtime/project/knowledge.d.ts +7 -2
  181. package/dist/runtime/project/knowledge.js +5 -2
  182. package/dist/runtime/project/knowledge.service.d.ts +17 -2
  183. package/dist/runtime/project/knowledge.service.js +76 -12
  184. package/dist/runtime/run-execution.d.ts +4 -1
  185. package/dist/runtime/run-execution.js +14 -5
  186. package/dist/runtime/run-steps.d.ts +11 -3
  187. package/dist/runtime/run-steps.js +27 -4
  188. package/dist/runtime/runtime.module.js +11 -0
  189. package/dist/sandbox/attachments-path.d.ts +15 -0
  190. package/dist/sandbox/attachments-path.js +15 -0
  191. package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
  192. package/dist/sandbox/cloud-permission-snapshot.js +407 -0
  193. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
  194. package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
  195. package/dist/sandbox/held-operations.d.ts +39 -0
  196. package/dist/sandbox/held-operations.js +119 -0
  197. package/dist/sandbox/jobs.d.ts +14 -3
  198. package/dist/sandbox/jobs.js +20 -2
  199. package/dist/sandbox/kernel-read.d.ts +55 -0
  200. package/dist/sandbox/kernel-read.js +57 -0
  201. package/dist/sandbox/legacy-retirement.d.ts +336 -0
  202. package/dist/sandbox/legacy-retirement.js +1063 -0
  203. package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
  204. package/dist/sandbox/legacy-retirement.module.js +25 -0
  205. package/dist/sandbox/managed-device-context.d.ts +94 -0
  206. package/dist/sandbox/managed-device-context.js +308 -0
  207. package/dist/sandbox/managed-device-context.module.d.ts +6 -0
  208. package/dist/sandbox/managed-device-context.module.js +33 -0
  209. package/dist/sandbox/modes.d.ts +56 -8
  210. package/dist/sandbox/modes.js +92 -8
  211. package/dist/sandbox/operation-authority-types.d.ts +8 -0
  212. package/dist/sandbox/operation-authority-types.js +32 -0
  213. package/dist/sandbox/operation-authority.d.ts +145 -0
  214. package/dist/sandbox/operation-authority.js +783 -0
  215. package/dist/sandbox/operation-authority.module.d.ts +2 -0
  216. package/dist/sandbox/operation-authority.module.js +29 -0
  217. package/dist/sandbox/operation-intents.d.ts +206 -0
  218. package/dist/sandbox/operation-intents.js +1252 -0
  219. package/dist/sandbox/operation-intents.module.d.ts +2 -0
  220. package/dist/sandbox/operation-intents.module.js +21 -0
  221. package/dist/sandbox/operation-payloads.d.ts +33 -0
  222. package/dist/sandbox/operation-payloads.js +332 -0
  223. package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
  224. package/dist/sandbox/operation-reconcile.job.js +247 -0
  225. package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
  226. package/dist/sandbox/permission-authority-epochs.js +83 -0
  227. package/dist/sandbox/permission-authority-lock.d.ts +38 -0
  228. package/dist/sandbox/permission-authority-lock.js +147 -0
  229. package/dist/sandbox/permission-authority.module.d.ts +9 -0
  230. package/dist/sandbox/permission-authority.module.js +55 -0
  231. package/dist/sandbox/permission-availability.d.ts +18 -0
  232. package/dist/sandbox/permission-availability.js +19 -0
  233. package/dist/sandbox/permission-call-grants.d.ts +34 -0
  234. package/dist/sandbox/permission-call-grants.js +349 -0
  235. package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
  236. package/dist/sandbox/permission-call-grants.module.js +21 -0
  237. package/dist/sandbox/permission-call-types.d.ts +82 -0
  238. package/dist/sandbox/permission-call-types.js +1 -0
  239. package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
  240. package/dist/sandbox/permission-ceiling-writes.js +223 -0
  241. package/dist/sandbox/permission-config-publication.d.ts +76 -0
  242. package/dist/sandbox/permission-config-publication.js +339 -0
  243. package/dist/sandbox/permission-context-types.d.ts +64 -0
  244. package/dist/sandbox/permission-context-types.js +24 -0
  245. package/dist/sandbox/permission-facts.d.ts +206 -0
  246. package/dist/sandbox/permission-facts.js +627 -0
  247. package/dist/sandbox/permission-facts.module.d.ts +2 -0
  248. package/dist/sandbox/permission-facts.module.js +20 -0
  249. package/dist/sandbox/permission-instance-writes.d.ts +90 -0
  250. package/dist/sandbox/permission-instance-writes.js +305 -0
  251. package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
  252. package/dist/sandbox/permission-runtime-reports.js +354 -0
  253. package/dist/sandbox/permission-transitions.d.ts +31 -0
  254. package/dist/sandbox/permission-transitions.js +155 -0
  255. package/dist/sandbox/platform-full-access.d.ts +128 -0
  256. package/dist/sandbox/platform-full-access.js +210 -0
  257. package/dist/sandbox/providers.d.ts +22 -0
  258. package/dist/sandbox/providers.js +10 -2
  259. package/dist/sandbox/providers.module.d.ts +2 -0
  260. package/dist/sandbox/providers.module.js +19 -0
  261. package/dist/sandbox/request-not-sent.d.ts +13 -0
  262. package/dist/sandbox/request-not-sent.js +13 -0
  263. package/dist/sandbox/review/classifier.d.ts +2 -0
  264. package/dist/sandbox/review/classifier.js +8 -0
  265. package/dist/sandbox/review/permission-candidate.d.ts +12 -0
  266. package/dist/sandbox/review/permission-candidate.js +129 -0
  267. package/dist/sandbox/review/review.service.d.ts +4 -1
  268. package/dist/sandbox/review/review.service.js +19 -5
  269. package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
  270. package/dist/sandbox/sandbox-file-reader.js +51 -7
  271. package/dist/sandbox/sandbox.module.js +26 -6
  272. package/dist/sandbox/sandbox.service.d.ts +230 -34
  273. package/dist/sandbox/sandbox.service.js +1368 -199
  274. package/dist/sandbox/unreachable.js +17 -3
  275. package/dist/sandbox/use-context.d.ts +17 -0
  276. package/dist/sandbox/use-context.js +1 -0
  277. package/dist/skills/invoke.d.ts +27 -4
  278. package/dist/skills/invoke.js +72 -7
  279. package/dist/tools/approvals.controller.d.ts +1 -0
  280. package/dist/tools/approvals.schemas.d.ts +1 -0
  281. package/dist/tools/approvals.schemas.js +3 -1
  282. package/dist/tools/approvals.service.d.ts +23 -10
  283. package/dist/tools/approvals.service.js +104 -26
  284. package/dist/tools/builtins/builtin-tools.d.ts +16 -2
  285. package/dist/tools/builtins/builtin-tools.js +38 -10
  286. package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
  287. package/dist/tools/builtins/sandbox/bash.js +201 -5
  288. package/dist/tools/builtins/sandbox/common.d.ts +92 -20
  289. package/dist/tools/builtins/sandbox/common.js +201 -17
  290. package/dist/tools/builtins/sandbox/deliver.js +2 -2
  291. package/dist/tools/builtins/sandbox/edit.js +2 -2
  292. package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
  293. package/dist/tools/builtins/sandbox/glob.js +2 -2
  294. package/dist/tools/builtins/sandbox/grep.js +2 -2
  295. package/dist/tools/builtins/sandbox/read.js +2 -2
  296. package/dist/tools/builtins/sandbox/task-list.js +7 -1
  297. package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
  298. package/dist/tools/builtins/sandbox/task-output.js +172 -0
  299. package/dist/tools/builtins/sandbox/task-stop.js +25 -3
  300. package/dist/tools/builtins/sandbox/write.js +2 -2
  301. package/dist/tools/builtins/skill-load.js +9 -6
  302. package/dist/tools/device-op-resolver.d.ts +1 -1
  303. package/dist/tools/device-op-resolver.js +13 -3
  304. package/dist/tools/permission-approval-jobs.d.ts +18 -0
  305. package/dist/tools/permission-approval-jobs.js +92 -0
  306. package/dist/tools/pipeline.d.ts +17 -2
  307. package/dist/tools/pipeline.js +300 -19
  308. package/dist/tools/registry.d.ts +9 -0
  309. package/dist/tools/tools.module.js +12 -0
  310. package/package.json +4 -3
  311. package/src/migrations/0146_permission_authority_epochs.sql +6 -0
  312. package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
  313. package/src/migrations/0148_first_message_request_hash.sql +2 -0
  314. package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
  315. package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
  316. package/src/migrations/0151_starting_execution_grants.sql +8 -0
  317. package/src/migrations/0152_background_launch_identity.sql +66 -0
  318. package/src/migrations/0153_background_cancel_requester.sql +13 -0
  319. package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
  320. package/src/migrations/0155_device_instance_generations.sql +30 -0
  321. package/src/migrations/0156_device_owner_report.sql +7 -0
  322. package/src/migrations/0157_legacy_retirement.sql +116 -0
  323. package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
  324. package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
  325. package/dist/sandbox/platform-auto-mode.d.ts +0 -63
  326. package/dist/sandbox/platform-auto-mode.js +0 -63
@@ -0,0 +1,34 @@
1
+ import { type DeviceExecGrants, type SandboxOperationScope } from "@capybara-hq/plugin-sdk";
2
+ import type { Selectable } from "kysely";
3
+ import { PermissionProfileStore } from "../conversations/permission-profile-store.js";
4
+ import type { PermissionCallGrantsTable } from "../db/kernel-schema.js";
5
+ import { KernelDb } from "../infra/database/kernel-db.js";
6
+ import { TransactionHost } from "../infra/database/transaction-host.js";
7
+ import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
8
+ import { PermissionAuthorityLock } from "./permission-authority-lock.js";
9
+ import type { PermissionCallBinding, PermissionCandidate, PermissionGrantDecision } from "./permission-call-types.js";
10
+ import { PermissionFacts } from "./permission-facts.js";
11
+ type GrantRow = Selectable<PermissionCallGrantsTable>;
12
+ export declare function bindingOfGrant(r: GrantRow): PermissionCallBinding;
13
+ export declare class PermissionCallGrants {
14
+ private readonly db;
15
+ readonly txHost: TransactionHost;
16
+ private readonly locks;
17
+ private readonly epochs;
18
+ private readonly profiles;
19
+ private readonly facts;
20
+ constructor(db: KernelDb, txHost: TransactionHost, locks: PermissionAuthorityLock, epochs: PermissionAuthorityEpochStore, profiles: PermissionProfileStore, facts: PermissionFacts);
21
+ /** The caller takes authority before conversation/approval/run locks. No I/O occurs here. */
22
+ assertCurrent(binding: PermissionCallBinding): Promise<void>;
23
+ issueLocked(candidate: PermissionCandidate, decision: PermissionGrantDecision): Promise<{
24
+ id: string;
25
+ }>;
26
+ private verifyEvidence;
27
+ findForAdmission(binding: PermissionCallBinding): Promise<{
28
+ id: string;
29
+ expansion: PermissionCandidate["permissionScope"];
30
+ } | null>;
31
+ /** Starting authority belongs to this admitted exec, never to another call or native method. */
32
+ forExecution(operationId: string, deviceId: string, method: "exec" | "backgroundStart", scope: SandboxOperationScope, input: unknown): Promise<DeviceExecGrants | undefined>;
33
+ }
34
+ export {};
@@ -0,0 +1,349 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { randomUUID } from "node:crypto";
11
+ import { SandboxOperationOutcomeUnknownError, } from "@capybara-hq/plugin-sdk";
12
+ import { Inject, Injectable } from "@nestjs/common";
13
+ import { PermissionProfileStore } from "../conversations/permission-profile-store.js";
14
+ import { ApiError } from "../errors.js";
15
+ import { KernelDb } from "../infra/database/kernel-db.js";
16
+ import { TransactionHost } from "../infra/database/transaction-host.js";
17
+ import { Transactional } from "../infra/database/transactional.decorator.js";
18
+ import { coversHost } from "./modes.js";
19
+ import { isExecutionMethod, parseStartingExecutionGrants } from "./operation-authority-types.js";
20
+ import { describeOperationPayload } from "./operation-payloads.js";
21
+ import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
22
+ import { PermissionAuthorityLock } from "./permission-authority-lock.js";
23
+ import { PermissionFacts, permissionScopeHash } from "./permission-facts.js";
24
+ import { normalizePermissionExpansion, permissionCandidateHash, } from "./review/permission-candidate.js";
25
+ export function bindingOfGrant(r) {
26
+ return {
27
+ orgId: r.org_id,
28
+ rootConversationId: r.root_conversation_id,
29
+ conversationId: r.conversation_id,
30
+ deviceId: r.device_id,
31
+ accountId: r.account_id,
32
+ runId: r.run_id,
33
+ callId: r.call_id,
34
+ toolKey: r.tool_key,
35
+ specHash: r.spec_hash,
36
+ callInputHash: r.call_input_hash,
37
+ resolvedInputHash: r.resolved_input_hash,
38
+ profile: r.profile,
39
+ profileRevision: r.profile_revision,
40
+ scopeRevision: r.scope_revision,
41
+ authorityRevision: r.authority_revision,
42
+ };
43
+ }
44
+ let PermissionCallGrants = class PermissionCallGrants {
45
+ db;
46
+ txHost;
47
+ locks;
48
+ epochs;
49
+ profiles;
50
+ facts;
51
+ constructor(db, txHost, locks, epochs, profiles, facts) {
52
+ this.db = db;
53
+ this.txHost = txHost;
54
+ this.locks = locks;
55
+ this.epochs = epochs;
56
+ this.profiles = profiles;
57
+ this.facts = facts;
58
+ }
59
+ /** The caller takes authority before conversation/approval/run locks. No I/O occurs here. */
60
+ async assertCurrent(binding) {
61
+ this.locks.assertHeld("root", binding.rootConversationId);
62
+ const root = await this.profiles.readOwnedRoot(binding.orgId, binding.conversationId, binding.accountId);
63
+ const view = await this.facts.view(binding.orgId, binding.accountId, root);
64
+ const run = await this.db
65
+ .selectFrom("runs")
66
+ .selectAll()
67
+ .where("id", "=", binding.runId)
68
+ .executeTakeFirst();
69
+ const device = await this.db
70
+ .selectFrom("devices")
71
+ .select("owner_account_id")
72
+ .where("id", "=", binding.deviceId)
73
+ .where("org_id", "=", binding.orgId)
74
+ .executeTakeFirst();
75
+ const vector = await this.epochs.readLocked({
76
+ orgId: binding.orgId,
77
+ deviceId: binding.deviceId,
78
+ rootConversationId: binding.rootConversationId,
79
+ });
80
+ if (root.id !== binding.rootConversationId ||
81
+ root.device_id !== binding.deviceId ||
82
+ root.scheduled_task_id ||
83
+ !run ||
84
+ run.conversation_id !== binding.conversationId ||
85
+ run.trigger_account_id !== binding.accountId ||
86
+ run.scheduled_task_run_id ||
87
+ !["running", "waiting", "queued"].includes(run.status) ||
88
+ device?.owner_account_id !== binding.accountId ||
89
+ view.availability.state !== "supported" ||
90
+ view.profile !== binding.profile ||
91
+ view.revision !== binding.profileRevision ||
92
+ view.scopeRevision !== binding.scopeRevision ||
93
+ permissionScopeHash({ scopeRevision: view.scopeRevision, vector }) !==
94
+ binding.authorityRevision)
95
+ throw new ApiError("conflict", "Permissions changed or the call is unattended; review the current call again");
96
+ const messages = await this.db
97
+ .selectFrom("conversation_events")
98
+ .select("payload")
99
+ .where("conversation_id", "=", binding.conversationId)
100
+ .where("run_id", "=", binding.runId)
101
+ .where("type", "=", "assistant_message")
102
+ .execute();
103
+ const calls = messages.flatMap((row) => Array.isArray(row.payload.content)
104
+ ? row.payload.content
105
+ : []);
106
+ if (!calls.some((call) => call.type === "tool_call" &&
107
+ call.id === binding.callId &&
108
+ call.name === binding.toolKey &&
109
+ permissionScopeHash(call.input) === binding.callInputHash))
110
+ throw new ApiError("forbidden", "Permission proposal does not match the recorded tool input");
111
+ }
112
+ async issueLocked(candidate, decision) {
113
+ const b = candidate.binding;
114
+ await this.assertCurrent(b);
115
+ const { candidateHash, ...presentation } = candidate;
116
+ if (candidate.scopeKind !== "directories-and-hosts" ||
117
+ permissionCandidateHash(presentation) !== candidateHash)
118
+ throw new ApiError("forbidden", "Permission proposal evidence does not match its exact directory scope");
119
+ if (b.profile === "full-access" ||
120
+ (decision.source === "review-model" && b.profile !== "approve-for-me"))
121
+ throw new ApiError("forbidden", "This profile cannot issue an automated expansion grant");
122
+ const root = await this.profiles.readOwnedRoot(b.orgId, b.conversationId, b.accountId);
123
+ const view = await this.facts.view(b.orgId, b.accountId, root);
124
+ const working = await this.facts.readWorkingFacts({
125
+ orgId: b.orgId,
126
+ rootConversationId: b.rootConversationId,
127
+ holderConversationId: b.conversationId,
128
+ deviceId: b.deviceId,
129
+ });
130
+ const { policy, owner } = await this.facts.readDevice(b.orgId, b.deviceId);
131
+ const device = await this.db
132
+ .selectFrom("devices")
133
+ .select("source")
134
+ .where("id", "=", b.deviceId)
135
+ .executeTakeFirstOrThrow();
136
+ const network = device.source === "local"
137
+ ? { kind: "allowlist", hosts: policy.localAllowedDomains }
138
+ : policy.network;
139
+ if ((!view.broadProjectReach &&
140
+ (candidate.permissionScope.readDirectories.length ||
141
+ candidate.permissionScope.writeDirectories.length)) ||
142
+ candidate.permissionScope.hosts.some((host) => network.kind !== "open-public" &&
143
+ !network.hosts.some((pattern) => coversHost(pattern, host))))
144
+ throw new ApiError("forbidden", "Permission proposal exceeds the current owner or organization ceiling");
145
+ const baseRoot = root.project_path ?? working.workspace;
146
+ const normalized = normalizePermissionExpansion(candidate.permissionScope, {
147
+ baseReadDirectories: [baseRoot],
148
+ baseWriteDirectories: [baseRoot],
149
+ baseHosts: (owner?.allowedDomains ?? policy.localAllowedDomains).filter((host) => network.kind === "open-public" ||
150
+ network.hosts.some((pattern) => coversHost(pattern, host))),
151
+ });
152
+ if (permissionScopeHash(normalized) !== permissionScopeHash(candidate.permissionScope))
153
+ throw new ApiError("forbidden", "Permission scope is not normalized");
154
+ await this.verifyEvidence(candidate, decision);
155
+ const bindingHash = permissionScopeHash(b), expansionHash = permissionScopeHash(candidate.permissionScope);
156
+ await this.db
157
+ .insertInto("permission_call_grants")
158
+ .values({
159
+ id: randomUUID(),
160
+ org_id: b.orgId,
161
+ root_conversation_id: b.rootConversationId,
162
+ conversation_id: b.conversationId,
163
+ device_id: b.deviceId,
164
+ account_id: b.accountId,
165
+ run_id: b.runId,
166
+ call_id: b.callId,
167
+ tool_key: b.toolKey,
168
+ spec_hash: b.specHash,
169
+ call_input_hash: b.callInputHash,
170
+ resolved_input_hash: b.resolvedInputHash,
171
+ profile: b.profile,
172
+ profile_revision: b.profileRevision,
173
+ scope_revision: b.scopeRevision,
174
+ authority_revision: b.authorityRevision,
175
+ binding_hash: bindingHash,
176
+ expansion: JSON.stringify(candidate.permissionScope),
177
+ expansion_hash: expansionHash,
178
+ candidate_hash: candidateHash,
179
+ target_path: candidate.targetPath ?? null,
180
+ scope_kind: candidate.scopeKind,
181
+ source: decision.source,
182
+ approval_id: decision.source === "human" ? decision.approvalId : null,
183
+ review_event_seq: decision.source === "review-model" ? decision.reviewEventSeq : null,
184
+ decided_by: decision.decidedBy,
185
+ })
186
+ .onConflict((oc) => oc.column("binding_hash").doNothing())
187
+ .execute();
188
+ const row = await this.db
189
+ .selectFrom("permission_call_grants")
190
+ .selectAll()
191
+ .where("binding_hash", "=", bindingHash)
192
+ .executeTakeFirstOrThrow();
193
+ if (permissionScopeHash(bindingOfGrant(row)) !== bindingHash ||
194
+ row.expansion_hash !== expansionHash ||
195
+ row.candidate_hash !== candidateHash ||
196
+ row.target_path !== (candidate.targetPath ?? null) ||
197
+ row.scope_kind !== candidate.scopeKind ||
198
+ row.source !== decision.source ||
199
+ row.approval_id !== (decision.source === "human" ? decision.approvalId : null) ||
200
+ row.review_event_seq !==
201
+ (decision.source === "review-model" ? decision.reviewEventSeq : null) ||
202
+ row.decided_by !== decision.decidedBy)
203
+ throw new ApiError("conflict", "This call already has different immutable permission evidence");
204
+ return { id: row.id };
205
+ }
206
+ async verifyEvidence(candidate, decision) {
207
+ const b = candidate.binding;
208
+ let evidence;
209
+ if (decision.source === "human") {
210
+ const approval = await this.db
211
+ .selectFrom("approvals")
212
+ .selectAll()
213
+ .where("id", "=", decision.approvalId)
214
+ .executeTakeFirst();
215
+ if (approval?.status !== "approved" ||
216
+ approval.kind !== "command" ||
217
+ approval.org_id !== b.orgId ||
218
+ approval.conversation_id !== b.conversationId ||
219
+ approval.run_id !== b.runId ||
220
+ approval.call_id !== b.callId ||
221
+ approval.requested_for !== b.accountId ||
222
+ approval.decided_by !== decision.decidedBy ||
223
+ decision.decidedBy !== b.accountId ||
224
+ approval.scope !== "once")
225
+ throw new ApiError("forbidden", "Permission grant requires this owner's exact approved call");
226
+ evidence = approval.detail?.permissionCandidate;
227
+ }
228
+ else {
229
+ const event = await this.db
230
+ .selectFrom("conversation_events")
231
+ .selectAll()
232
+ .where("conversation_id", "=", b.conversationId)
233
+ .where("seq", "=", String(decision.reviewEventSeq))
234
+ .where("run_id", "=", b.runId)
235
+ .where("type", "=", "permission_reviewed")
236
+ .executeTakeFirst();
237
+ if (!event ||
238
+ event.payload.outcome !== "allow" ||
239
+ event.payload.decisionSource !== "review-model")
240
+ throw new ApiError("forbidden", "Permission grant requires its recorded allow verdict");
241
+ const { outcome: _outcome, reason: _reason, decisionSource: _source, ...proposal } = event.payload;
242
+ evidence = proposal;
243
+ }
244
+ if (permissionScopeHash(evidence) !== permissionScopeHash(candidate))
245
+ throw new ApiError("forbidden", "The approved directory and host proposal does not match");
246
+ }
247
+ async findForAdmission(binding) {
248
+ const hash = permissionScopeHash(binding);
249
+ const row = await this.db
250
+ .selectFrom("permission_call_grants")
251
+ .selectAll()
252
+ .where("binding_hash", "=", hash)
253
+ .executeTakeFirst();
254
+ if (!row || permissionScopeHash(bindingOfGrant(row)) !== hash)
255
+ return null;
256
+ await this.assertCurrent(binding);
257
+ if (row.source === "human" && (!row.approval_id || !row.decided_by))
258
+ throw new ApiError("forbidden", "The human permission evidence is incomplete");
259
+ if (row.source === "review-model" && row.review_event_seq === null)
260
+ throw new ApiError("forbidden", "The review permission evidence is incomplete");
261
+ await this.verifyEvidence({
262
+ binding,
263
+ permissionScope: row.expansion,
264
+ ...(row.target_path ? { targetPath: row.target_path } : {}),
265
+ scopeKind: row.scope_kind,
266
+ candidateHash: row.candidate_hash,
267
+ }, row.source === "human"
268
+ ? { source: "human", approvalId: row.approval_id ?? "", decidedBy: row.decided_by ?? "" }
269
+ : { source: "review-model", reviewEventSeq: row.review_event_seq ?? -1, decidedBy: null });
270
+ return { id: row.id, expansion: row.expansion };
271
+ }
272
+ /** Starting authority belongs to this admitted exec, never to another call or native method. */
273
+ async forExecution(operationId, deviceId, method, scope, input) {
274
+ const intent = await this.db
275
+ .selectFrom("sandbox_operation_intents")
276
+ .selectAll()
277
+ .where("operation_id", "=", operationId)
278
+ .executeTakeFirst();
279
+ if (!intent ||
280
+ intent.device_id !== deviceId ||
281
+ !(["admitted", "dispatching", "started-or-unknown"].includes(intent.state) ||
282
+ // an acknowledged start keeps its starting authority while it runs: a retried start of
283
+ // the same operation (the provider returns the same ref) reuses it, never a new envelope
284
+ (intent.state === "background-running" && intent.method === "backgroundStart")))
285
+ throw new ApiError("forbidden", "The operation has no current admitted execution identity");
286
+ if (!isExecutionMethod(intent.method) ||
287
+ intent.method !== method ||
288
+ permissionScopeHash(scope) !== permissionScopeHash(intent.scope))
289
+ throw new ApiError("forbidden", "The execution does not match its exact admitted method and scope");
290
+ if (intent.execution_grants === null || intent.execution_grants === undefined) {
291
+ const message = "Starting grant provenance is unavailable; check the original operation before retrying";
292
+ if (intent.state === "admitted")
293
+ throw new ApiError("forbidden", message);
294
+ throw new SandboxOperationOutcomeUnknownError(message);
295
+ }
296
+ const metadata = parseStartingExecutionGrants(intent.execution_grants);
297
+ const inputDigest = describeOperationPayload(input).digest;
298
+ if (intent.input_hash !== permissionScopeHash({ method, inputDigest }) ||
299
+ intent.admission_hash !==
300
+ permissionScopeHash({ method, inputDigest, scope, executionGrants: metadata }) ||
301
+ permissionScopeHash(metadata.grants?.hosts ?? []) !==
302
+ permissionScopeHash(intent.granted_hosts))
303
+ throw new ApiError("forbidden", "Starting grants or input do not match the exact admitted execution");
304
+ if (!intent.permission_grant_id)
305
+ return metadata.grants ?? undefined;
306
+ const grant = await this.db
307
+ .selectFrom("permission_call_grants")
308
+ .selectAll()
309
+ .where("id", "=", intent.permission_grant_id)
310
+ .executeTakeFirstOrThrow();
311
+ const admittedScope = intent.scope;
312
+ if (!("profileRevision" in admittedScope) ||
313
+ grant.device_id !== deviceId ||
314
+ grant.org_id !== intent.org_id ||
315
+ grant.account_id !== intent.account_id ||
316
+ grant.run_id !== intent.run_id ||
317
+ grant.call_id !== intent.call_id ||
318
+ grant.conversation_id !== intent.conversation_id ||
319
+ grant.root_conversation_id !== intent.root_conversation_id ||
320
+ grant.profile_revision !== admittedScope.profileRevision ||
321
+ grant.authority_revision !== admittedScope.ceilingRevision ||
322
+ grant.expansion.hosts.some((host) => !intent.granted_hosts.includes(host)))
323
+ throw new ApiError("forbidden", "The operation's explicit host evidence does not match its admitted call");
324
+ if (grant.expansion.hosts.length &&
325
+ permissionScopeHash(metadata.grants?.source) !==
326
+ permissionScopeHash({ kind: "run", id: grant.run_id, accountId: grant.account_id }))
327
+ throw new ApiError("forbidden", "Starting grant source does not match the admitted call evidence");
328
+ return metadata.grants ?? undefined;
329
+ }
330
+ };
331
+ __decorate([
332
+ Transactional({ propagation: "mandatory" })
333
+ ], PermissionCallGrants.prototype, "assertCurrent", null);
334
+ __decorate([
335
+ Transactional({ propagation: "mandatory" })
336
+ ], PermissionCallGrants.prototype, "issueLocked", null);
337
+ __decorate([
338
+ Transactional({ propagation: "mandatory" })
339
+ ], PermissionCallGrants.prototype, "findForAdmission", null);
340
+ PermissionCallGrants = __decorate([
341
+ Injectable(),
342
+ __param(0, Inject(KernelDb)),
343
+ __param(1, Inject(TransactionHost)),
344
+ __param(2, Inject(PermissionAuthorityLock)),
345
+ __param(3, Inject(PermissionAuthorityEpochStore)),
346
+ __param(4, Inject(PermissionProfileStore)),
347
+ __param(5, Inject(PermissionFacts))
348
+ ], PermissionCallGrants);
349
+ export { PermissionCallGrants };
@@ -0,0 +1,2 @@
1
+ export declare class PermissionCallGrantsModule {
2
+ }
@@ -0,0 +1,21 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Module } from "@nestjs/common";
8
+ import { PermissionProfileStoreModule } from "../conversations/permission-profile-store.module.js";
9
+ import { PermissionAuthorityModule } from "./permission-authority.module.js";
10
+ import { PermissionCallGrants } from "./permission-call-grants.js";
11
+ import { PermissionFactsModule } from "./permission-facts.module.js";
12
+ let PermissionCallGrantsModule = class PermissionCallGrantsModule {
13
+ };
14
+ PermissionCallGrantsModule = __decorate([
15
+ Module({
16
+ imports: [PermissionAuthorityModule, PermissionFactsModule, PermissionProfileStoreModule],
17
+ providers: [PermissionCallGrants],
18
+ exports: [PermissionCallGrants],
19
+ })
20
+ ], PermissionCallGrantsModule);
21
+ export { PermissionCallGrantsModule };
@@ -0,0 +1,82 @@
1
+ import type { PermissionProfile } from "@capybara-hq/plugin-sdk";
2
+ import type { EffectiveDevicePolicy } from "./modes.js";
3
+ import type { AppliedOuterNetwork } from "./permission-context-types.js";
4
+ export type PermissionCallRef = {
5
+ runId: string;
6
+ callId: string;
7
+ };
8
+ export type PermissionExpansion = Readonly<{
9
+ readDirectories: readonly string[];
10
+ writeDirectories: readonly string[];
11
+ hosts: readonly string[];
12
+ }>;
13
+ export type PermissionCallBinding = Readonly<{
14
+ orgId: string;
15
+ rootConversationId: string;
16
+ conversationId: string;
17
+ deviceId: string;
18
+ accountId: string;
19
+ runId: string;
20
+ callId: string;
21
+ toolKey: string;
22
+ specHash: string;
23
+ callInputHash: string;
24
+ resolvedInputHash: string;
25
+ profile: PermissionProfile;
26
+ profileRevision: number;
27
+ scopeRevision: string;
28
+ authorityRevision: string;
29
+ }>;
30
+ export type PermissionGrantDecision = {
31
+ source: "human";
32
+ approvalId: string;
33
+ decidedBy: string;
34
+ } | {
35
+ source: "review-model";
36
+ reviewEventSeq: number;
37
+ decidedBy: null;
38
+ };
39
+ export type PermissionCandidate = Readonly<{
40
+ binding: PermissionCallBinding;
41
+ permissionScope: PermissionExpansion;
42
+ targetPath?: string;
43
+ scopeKind: "directories-and-hosts";
44
+ candidateHash: string;
45
+ }>;
46
+ export type PermissionCandidateResult = {
47
+ kind: "in-scope";
48
+ } | {
49
+ kind: "proposal";
50
+ candidate: PermissionCandidate;
51
+ } | {
52
+ kind: "unsupported";
53
+ code: "unbounded-scope";
54
+ message: string;
55
+ };
56
+ export type PermissionReviewSnapshot = Readonly<Omit<PermissionCallBinding, "toolKey" | "specHash" | "callInputHash" | "resolvedInputHash"> & {
57
+ baseReadDirectories: readonly string[];
58
+ baseWriteDirectories: readonly string[];
59
+ baseHosts: readonly string[];
60
+ workingRoot: string;
61
+ fullAccessCeiling: boolean;
62
+ /** Restricted directory expansions beyond the working root (B2 broad project reach). */
63
+ broadProjectReach: boolean;
64
+ unattended: boolean;
65
+ fullConsent: boolean;
66
+ availability: {
67
+ state: string;
68
+ reason?: string;
69
+ };
70
+ /**
71
+ * The reason admission refuses this device (B-16): the recorded permission context withholds
72
+ * its scope for the same state. Null or absent when admission may proceed.
73
+ */
74
+ admissionRefusal?: string | null;
75
+ /**
76
+ * The applied outer boundary of the device's installed environment (B-15): restricted hosts
77
+ * outside a cloud allowlist are cut from the base, accepted additions and new proposals alike.
78
+ * Null or absent when not proved.
79
+ */
80
+ outerNetwork?: AppliedOuterNetwork | null;
81
+ policy: EffectiveDevicePolicy;
82
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { SandboxBrowseScope, SandboxOperationScope } from "@capybara-hq/plugin-sdk";
2
+ import type { Selectable } from "kysely";
3
+ import type { KernelSchemaDb, SandboxOperationIntentsTable } from "../db/kernel-schema.js";
4
+ import { KernelDb } from "../infra/database/kernel-db.js";
5
+ import { TransactionHost } from "../infra/database/transaction-host.js";
6
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
7
+ import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
8
+ import { type AuthoritySubject, PermissionAuthorityLock } from "./permission-authority-lock.js";
9
+ import { PermissionTransitions } from "./permission-transitions.js";
10
+ /** Lower-level publication shared by ceiling writers; imports no facts, profiles or lifecycle. */
11
+ export declare class PermissionCeilingWrites {
12
+ private readonly transitions;
13
+ private readonly db;
14
+ readonly txHost: TransactionHost;
15
+ private readonly locks;
16
+ private readonly epochs;
17
+ private readonly outbox;
18
+ constructor(transitions: PermissionTransitions, db: KernelDb, txHost: TransactionHost, locks: PermissionAuthorityLock, epochs: PermissionAuthorityEpochStore, outbox: OutboxService);
19
+ lock(subject: AuthoritySubject, level: "platform" | "org" | "device" | "root"): Promise<void>;
20
+ /** The platform writer excludes every descendant; only these environments changed Full reach. */
21
+ invalidateDeviceConsentUnderPlatform(deviceIds: readonly string[]): Promise<void>;
22
+ publishLocked(subject: AuthoritySubject, level: "platform" | "org" | "device" | "root", revoke?: boolean | ((scope: SandboxOperationScope | SandboxBrowseScope, row: Selectable<SandboxOperationIntentsTable>) => boolean), invalidateFullConsent?: boolean): Promise<void>;
23
+ private resetRoot;
24
+ }
25
+ /**
26
+ * The active local machines' reported roots by device (one org, or all): what the Full-off writers
27
+ * compare running restricted scopes against (B2 reach narrowing). Cloud devices have none.
28
+ */
29
+ export declare function localMachineRoots(db: KernelSchemaDb, orgId?: string): Promise<Map<string, string[]>>;
30
+ /**
31
+ * What a platform or org Full ceiling turning off takes away (B2, same split as the owner writer):
32
+ * Full execution, broad browsing, and running restricted work outside the machine's roots, since
33
+ * the effective restricted reach narrows to the workspace.
34
+ */
35
+ export declare const needsWiderDeviceCeiling: (scope: SandboxOperationScope | SandboxBrowseScope, machineRoots: readonly string[] | undefined) => boolean;
36
+ /** Full execution: a Full-profile operation (B2: decided by Full permission alone). */
37
+ export declare const requiresFullExecution: (scope: SandboxOperationScope | SandboxBrowseScope) => boolean;
38
+ /**
39
+ * Broad project reach: owner browsing outside the restricted workspace (B2: decided by the reach
40
+ * and the platform/org device ceiling, never by the owner's Full permission).
41
+ */
42
+ export declare const requiresBroadProjectReach: (scope: SandboxOperationScope | SandboxBrowseScope) => boolean;
43
+ /**
44
+ * What a platform or org Full ceiling turning off takes away: Full execution and, as before, the
45
+ * wider device ceiling restricted reach depended on.
46
+ */
47
+ export declare const needsFullCeiling: (scope: SandboxOperationScope | SandboxBrowseScope) => boolean;