@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
@@ -28,6 +28,7 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
28
28
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
29
29
  import { STOP_DELETED_ORG_JOB } from "../runtime/run-deletion.js";
30
30
  import { USAGE_REPORT_QUEUE } from "../runtime/usage-report-jobs.js";
31
+ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
31
32
  import { OrgLock } from "./org-lock.js";
32
33
  /** 组织 slug:小写字母数字与 `-`,首尾不能是 `-`,1–40 个字符。 */
33
34
  export const SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;
@@ -92,6 +93,7 @@ let OrgsService = class OrgsService {
92
93
  scopeSync;
93
94
  ownedItems;
94
95
  lifecycle;
96
+ ceilings;
95
97
  constructor(db, outbox, txHost, settings, apiTokens, orgLock, events,
96
98
  /** Cancels the deleted org's running eval runs (in the delete's transaction). */
97
99
  evalBudget,
@@ -100,7 +102,7 @@ let OrgsService = class OrgsService {
100
102
  /** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
101
103
  ownedItems,
102
104
  /** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
103
- lifecycle) {
105
+ lifecycle, ceilings) {
104
106
  this.db = db;
105
107
  this.outbox = outbox;
106
108
  this.txHost = txHost;
@@ -112,6 +114,7 @@ let OrgsService = class OrgsService {
112
114
  this.scopeSync = scopeSync;
113
115
  this.ownedItems = ownedItems;
114
116
  this.lifecycle = lifecycle;
117
+ this.ceilings = ceilings;
115
118
  }
116
119
  /**
117
120
  * Creates an org with the actor as owner, in the caller's transaction when there is one (the
@@ -248,6 +251,8 @@ let OrgsService = class OrgsService {
248
251
  await this.orgLock.precheck(orgId, actor.id, "org.delete");
249
252
  await this.orgLock.lockForRemoval(orgId);
250
253
  await this.orgLock.lockAndAuthorize(orgId, actor.id, "org.delete");
254
+ await this.ceilings.lock({ orgId }, "org");
255
+ await this.ceilings.publishLocked({ orgId }, "org");
251
256
  await this.db
252
257
  .updateTable("orgs")
253
258
  .set({ deleted_at: sql `now()` })
@@ -316,6 +321,7 @@ OrgsService = __decorate([
316
321
  __param(7, Inject(EvalBudget)),
317
322
  __param(8, Inject(PluginScopeSync)),
318
323
  __param(9, Inject(OwnedItems)),
319
- __param(10, Inject(LifecycleHooks))
324
+ __param(10, Inject(LifecycleHooks)),
325
+ __param(11, Inject(PermissionCeilingWrites))
320
326
  ], OrgsService);
321
327
  export { OrgsService };
@@ -7,7 +7,10 @@ import { type OrgEffectiveNetwork, type OrgSandboxLimits, type OrgSettingsDeploy
7
7
  * 以及只读的 `sandboxLimits`(组织实际生效的沙箱 cpu / 内存与来源,超级管理员在部署设置里覆盖,C19)。
8
8
  */
9
9
  type SettingsResponse = {
10
- /** `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read. */
10
+ /**
11
+ * `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read; `autoMode`
12
+ * mirrors `fullAccess`.
13
+ */
11
14
  settings: OrgSettingsView;
12
15
  deployment: OrgSettingsDeployment;
13
16
  /** The org's effective sandbox-mode network (org egress ceiling spec §D4). */
@@ -12,7 +12,7 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
12
12
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
13
13
  import { ZBody } from "../infra/validation/zod-params.js";
14
14
  import { CurrentOrg, OrgAction } from "./org.guard.js";
15
- import { OrgSettingsPatchSchema, OrgSettingsService, } from "./settings.service.js";
15
+ import { OrgSettingsPatchSchema, OrgSettingsService, orgSettingsView, } from "./settings.service.js";
16
16
  class OrgSettingsPatchBody extends createZodDto(OrgSettingsPatchSchema, "OrgSettingsPatch") {
17
17
  }
18
18
  let OrgSettingsController = class OrgSettingsController {
@@ -23,7 +23,7 @@ let OrgSettingsController = class OrgSettingsController {
23
23
  async get(org) {
24
24
  const settings = await this.settings.get(org.orgId);
25
25
  return {
26
- settings,
26
+ settings: orgSettingsView(settings),
27
27
  deployment: await this.settings.deployment(),
28
28
  effectiveNetwork: this.settings.effectiveNetwork(settings),
29
29
  sandboxLimits: await this.settings.sandboxLimits(org.orgId),
@@ -34,7 +34,7 @@ let OrgSettingsController = class OrgSettingsController {
34
34
  // an API token may narrow auto mode and the cloud network, never widen them (auto mode spec §4.3)
35
35
  const settings = await this.settings.update(org.orgId, body, p.account.id, patTokenId(p), undefined, { onlyNarrows: patTokenId(p) !== undefined });
36
36
  return {
37
- settings,
37
+ settings: orgSettingsView(settings),
38
38
  deployment: await this.settings.deployment(),
39
39
  effectiveNetwork: this.settings.effectiveNetwork(settings),
40
40
  sandboxLimits: await this.settings.sandboxLimits(org.orgId),
@@ -1,4 +1,4 @@
1
- import { type SandboxLimits } from "@capybara-hq/plugin-sdk";
1
+ import type { SandboxLimits } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
3
  import { type PlatformAttribution } from "../attribution/platform-attribution.js";
4
4
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
@@ -7,7 +7,9 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
7
7
  import { KernelDb } from "../infra/database/kernel-db.js";
8
8
  import { TransactionHost } from "../infra/database/transaction-host.js";
9
9
  import type { KernelLogger } from "../log.js";
10
- import { type DevicesAutoModeView } from "../sandbox/platform-auto-mode.js";
10
+ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
11
+ import { type DevicesAutoModeView, type DevicesFullAccessView, type FullAccessPermission } from "../sandbox/platform-full-access.js";
12
+ import { type CloudNetworkSetting } from "./cloud-network-setting.js";
11
13
  import { OrgLock } from "./org-lock.js";
12
14
  /**
13
15
  * Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
@@ -22,9 +24,10 @@ import { OrgLock } from "./org-lock.js";
22
24
  * execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
23
25
  * - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
24
26
  * the deployment), see {@link effectiveWakeOnBackgroundTask}.
25
- * - `autoMode`: whether devices of the org may run in auto mode (auto mode spec §4.3); absent
26
- * follows the platform's `devices.autoMode`, and an invalid stored value reads as `off`
27
- * (narrower, never wider). Setting `allowed` while the platform is `off` is refused.
27
+ * - `fullAccess`: whether devices of the org may run with Full permission (permission runtime
28
+ * cutover B1, replacing `autoMode`); absent follows the platform's `devices.fullAccess`, and an
29
+ * invalid stored value reads as `off` (narrower, never wider). Setting `allowed` while the
30
+ * platform is `off` is refused.
28
31
  * - `cloudNetwork`: the org's sandbox-mode network as a delta over the platform's allowlist (org
29
32
  * egress ceiling spec §D1, {@link CloudNetworkSettingSchema}). An invalid stored value reads as
30
33
  * `{ mode: "allowlist", base: "none" }`, the empty allowlist (narrower, never wider).
@@ -39,43 +42,12 @@ import { OrgLock } from "./org-lock.js";
39
42
  * - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
40
43
  * not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
41
44
  */
42
- /** The org cloud-network allowlist's host limit. */
43
- export declare const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
45
+ export { type CloudNetworkSetting, CloudNetworkSettingSchema, invalidCloudNetwork, ORG_SANDBOX_ALLOW_HOSTS_MAX, } from "./cloud-network-setting.js";
44
46
  /**
45
- * The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
46
- * platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
47
- * org:
48
- * - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
49
- * private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
50
- * follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
51
- * - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
52
- * hosts).
53
- * - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
54
- * - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
55
- * platform may drop an entry later).
56
- * The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
57
- * device in sandbox mode reaches (the device intersects them with its own list).
47
+ * The org's Full permission switch (B1): `allowed` or `off`; absent follows the platform's
48
+ * `devices.fullAccess`. An invalid stored value reads as `off` (narrower, never wider).
58
49
  */
59
- export declare const CloudNetworkSettingSchema: z.ZodObject<{
60
- mode: z.ZodOptional<z.ZodEnum<{
61
- allowlist: "allowlist";
62
- open: "open";
63
- }>>;
64
- base: z.ZodOptional<z.ZodEnum<{
65
- none: "none";
66
- platform: "platform";
67
- }>>;
68
- extraHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
- excludedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
- }, z.core.$strict>;
71
- export type CloudNetworkSetting = z.infer<typeof CloudNetworkSettingSchema>;
72
- /** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
73
- export declare const invalidCloudNetwork: () => CloudNetworkSetting;
74
- /**
75
- * The org's auto-mode switch (auto mode spec §4.3): `allowed` or `off`; absent follows the
76
- * platform's `devices.autoMode`. An invalid stored value reads as `off` (narrower, never wider).
77
- */
78
- export declare const AutoModeSetting: z.ZodEnum<{
50
+ export declare const FullAccessSetting: z.ZodEnum<{
79
51
  allowed: "allowed";
80
52
  off: "off";
81
53
  }>;
@@ -168,7 +140,7 @@ export declare const OrgSettingsSchema: z.ZodObject<{
168
140
  on: "on";
169
141
  "read-only": "read-only";
170
142
  }>>>;
171
- autoMode: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
143
+ fullAccess: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
172
144
  allowed: "allowed";
173
145
  off: "off";
174
146
  }>>>;
@@ -232,6 +204,8 @@ export type OrgSettingsView = OrgSettings & {
232
204
  scheduledTasks: OrgSettings["scheduledTasks"] & {
233
205
  forbiddenToolsUnreadable?: true;
234
206
  };
207
+ /** The old public name of `fullAccess`, mirrored by {@link orgSettingsView}. */
208
+ autoMode?: FullAccessPermission;
235
209
  };
236
210
  /** PATCH 体:只改给出的字段;未知字段 → 400。 */
237
211
  export declare const OrgSettingsPatchSchema: z.ZodObject<{
@@ -253,6 +227,10 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
253
227
  "read-only": "read-only";
254
228
  }>>;
255
229
  wakeOnBackgroundTask: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
230
+ fullAccess: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
231
+ allowed: "allowed";
232
+ off: "off";
233
+ }>>>;
256
234
  autoMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
257
235
  allowed: "allowed";
258
236
  off: "off";
@@ -302,6 +280,13 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
302
280
  }, z.core.$strict>>>;
303
281
  }, z.core.$strict>;
304
282
  export type OrgSettingsPatch = z.infer<typeof OrgSettingsPatchSchema>;
283
+ /** A patch with the old `autoMode` moved to `fullAccess` (the schema refuses both together). */
284
+ export declare function normalizeOrgSettingsPatch(patch: OrgSettingsPatch): OrgSettingsPatch;
285
+ /**
286
+ * The settings as the API answers them ({@link OrgSettingsView}), plus the old public name
287
+ * `autoMode` mirroring `fullAccess` until the old public readers are removed.
288
+ */
289
+ export declare const orgSettingsView: (settings: OrgSettingsView) => OrgSettingsView;
305
290
  /** Whether a finished background task wakes an idle conversation: the org's setting, else the deployment's. */
306
291
  export declare function effectiveWakeOnBackgroundTask(deployment: boolean, org: OrgSettings["wakeOnBackgroundTask"]): boolean;
307
292
  /**
@@ -326,7 +311,9 @@ export interface OrgEffectiveNetwork {
326
311
  }
327
312
  /** The deployment defaults the settings page shows for "follow the platform" (`GET` returns them). */
328
313
  export interface OrgSettingsDeployment {
329
- /** The platform's auto-mode switch and where it comes from. */
314
+ /** The platform's Full permission switch and where it comes from. */
315
+ fullAccess: DevicesFullAccessView;
316
+ /** The same switch under its old public name (`{ mode, source }`). */
330
317
  autoMode: DevicesAutoModeView;
331
318
  /**
332
319
  * The platform's network: its allowlist (what an org's delta applies to), whether orgs may go
@@ -348,7 +335,10 @@ export interface OrgSettingsDeployment {
348
335
  /** The platform's conversation compaction settings (what "follow the platform" means). */
349
336
  compaction: CompactionSettings;
350
337
  }
351
- /** 把存储的 jsonb 解析为设置(宽松,见 {@link OrgSettingsSchema})。 */
338
+ /**
339
+ * Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}). Until 8.6 `fullAccess` is read
340
+ * over both keys, the narrower of it and the old `autoMode` ({@link narrowedOrgFullAccess}).
341
+ */
352
342
  export declare function parseOrgSettings(raw: unknown): OrgSettings;
353
343
  /** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
354
344
  export declare function readStoredOrgSettings(db: KernelSchemaDb, orgId: string): Promise<unknown>;
@@ -378,8 +368,8 @@ export declare const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization'
378
368
  * than written, with the org id.
379
369
  */
380
370
  export declare function logUnreadableSecuritySettings(log: (msg: string, fields: Record<string, unknown>) => void, orgId: string, raw: unknown): void;
381
- /** Whether a stored settings object holds an `autoMode` this version reads as `off`. */
382
- export declare function invalidStoredAutoMode(raw: unknown): boolean;
371
+ /** Whether a stored settings object holds a `fullAccess` this version reads as `off`. */
372
+ export declare function invalidStoredFullAccess(raw: unknown): boolean;
383
373
  /** Whether a stored settings object holds a `cloudNetwork` this version reads as an empty allowlist. */
384
374
  export declare function invalidStoredCloudNetwork(raw: unknown): boolean;
385
375
  /**
@@ -396,18 +386,19 @@ export declare class OrgSettingsService {
396
386
  readonly txHost: TransactionHost;
397
387
  private readonly orgLock;
398
388
  /**
399
- * The deployment config: `sandbox.limits` and the platform's auto-mode switch
400
- * (`devices.autoMode`; the org may follow it, never exceed it).
389
+ * The deployment config: `sandbox.limits` and the platform's Full switch
390
+ * (`devices.fullAccess`; the org may follow it, never exceed it).
401
391
  */
402
392
  private readonly config;
393
+ private readonly ceilings;
403
394
  private readonly log?;
404
395
  constructor(db: KernelDb, txHost: TransactionHost, orgLock: OrgLock,
405
396
  /**
406
- * The deployment config: `sandbox.limits` and the platform's auto-mode switch
407
- * (`devices.autoMode`; the org may follow it, never exceed it).
397
+ * The deployment config: `sandbox.limits` and the platform's Full switch
398
+ * (`devices.fullAccess`; the org may follow it, never exceed it).
408
399
  */
409
- config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
410
- /** Parses stored settings, warning when an invalid `autoMode` narrows to `off`, an invalid
400
+ config: Pick<KernelConfigService, "get" | "fieldSource">, ceilings: PermissionCeilingWrites, log?: KernelLogger | undefined);
401
+ /** Parses stored settings, warning when an invalid `fullAccess` narrows to `off`, an invalid
411
402
  * `cloudNetwork` to an empty allowlist, or a security setting reads narrower
412
403
  * ({@link logUnreadableSecuritySettings}, warn). */
413
404
  private parseStored;
@@ -425,7 +416,7 @@ export declare class OrgSettingsService {
425
416
  * The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
426
417
  * auto mode where the platform turned it off.
427
418
  */
428
- check(patch: OrgSettingsPatch): Promise<void>;
419
+ check(input: OrgSettingsPatch): Promise<void>;
429
420
  /**
430
421
  * Under `sandbox.limits.orgHosts: within` (spec §D2), refuses what would widen past the platform
431
422
  * ceiling compared with the stored value `before`: the open cloud network where the org did not
@@ -434,26 +425,27 @@ export declare class OrgSettingsService {
434
425
  * under the ceiling (they are filtered on read), so they never block a write.
435
426
  */
436
427
  assertWithinCeiling(before: OrgSettings, patch: OrgSettingsPatch): void;
437
- update(orgId: string, patch: OrgSettingsPatch, actorAccountId: string, actorTokenId?: string,
428
+ update(orgId: string, input: OrgSettingsPatch, actorAccountId: string, actorTokenId?: string,
438
429
  /** Merged into the audit detail (the Platform tool's `via: "agent"`). */
439
430
  auditDetail?: Record<string, unknown>,
440
431
  /**
441
- * `onlyNarrows` (the Platform tool, API tokens): refuse an `autoMode` or `cloudNetwork`
432
+ * `onlyNarrows` (the Platform tool, API tokens): refuse a `fullAccess` or `cloudNetwork`
442
433
  * change that widens (see {@link assertOnlyNarrows}); only a person in a session widens.
443
434
  */
444
435
  opts?: {
445
436
  onlyNarrows?: boolean;
446
437
  }): Promise<OrgSettingsView>;
438
+ private lockFor;
447
439
  /**
448
440
  * Refuses a patch that widens the org's sandbox (auto mode spec §4.3: only a person widens it,
449
441
  * never the Platform tool or an API token):
450
- * - `autoMode`: `allowed` where the organization runs `off` (an absent value follows the
442
+ * - `fullAccess`: `allowed` where the organization runs `off` (an absent value follows the
451
443
  * platform); clearing it follows the platform too, never wider than the platform allows;
452
444
  * - `cloudNetwork`: compared as stored deltas ({@link cloudNetworkWidens}), never as effective
453
445
  * values: under the kill switch or the platform ceiling the effective values hide a widening
454
446
  * that takes effect when the platform relaxes (org egress ceiling spec §D3).
455
447
  */
456
- assertOnlyNarrows(before: OrgSettings, patch: OrgSettingsPatch): Promise<void>;
448
+ assertOnlyNarrows(before: OrgSettings, input: OrgSettingsPatch): Promise<void>;
457
449
  private updateIn;
458
450
  }
459
451
  /**