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

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 (359) 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 +4 -1
  38. package/dist/config/schema.js +41 -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 +307 -4
  47. package/dist/conversations/events.js +286 -32
  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/ctx/create-ctx.d.ts +12 -5
  59. package/dist/ctx/create-ctx.js +21 -5
  60. package/dist/db/kernel-schema.d.ts +248 -3
  61. package/dist/devices/access.js +1 -1
  62. package/dist/devices/access.module.d.ts +2 -0
  63. package/dist/devices/access.module.js +19 -0
  64. package/dist/devices/conversation-devices.d.ts +8 -29
  65. package/dist/devices/conversation-devices.js +37 -73
  66. package/dist/devices/device-projects.service.d.ts +26 -28
  67. package/dist/devices/device-projects.service.js +123 -127
  68. package/dist/devices/devices.controller.js +3 -1
  69. package/dist/devices/devices.module.js +11 -9
  70. package/dist/devices/devices.service.d.ts +116 -8
  71. package/dist/devices/devices.service.js +252 -20
  72. package/dist/devices/dto.d.ts +16 -0
  73. package/dist/devices/dto.js +34 -6
  74. package/dist/devices/errors.d.ts +8 -0
  75. package/dist/devices/errors.js +10 -0
  76. package/dist/devices/project-rules.d.ts +44 -0
  77. package/dist/devices/project-rules.js +27 -0
  78. package/dist/devices/working-root.d.ts +6 -0
  79. package/dist/devices/working-root.js +12 -1
  80. package/dist/errors.d.ts +31 -0
  81. package/dist/errors.js +31 -0
  82. package/dist/evals/reconstruct.d.ts +19 -2
  83. package/dist/evals/reconstruct.js +40 -2
  84. package/dist/evals/recorded-permission-context.d.ts +77 -0
  85. package/dist/evals/recorded-permission-context.js +151 -0
  86. package/dist/evals/recorded-tools.d.ts +10 -1
  87. package/dist/evals/recorded-tools.js +27 -3
  88. package/dist/evals/run-replay.d.ts +8 -2
  89. package/dist/evals/run-replay.js +18 -2
  90. package/dist/evals/trajectory.d.ts +1 -1
  91. package/dist/evals/worker.d.ts +10 -1
  92. package/dist/evals/worker.js +23 -14
  93. package/dist/extensions/host.d.ts +4 -1
  94. package/dist/extensions/host.js +10 -6
  95. package/dist/http/api.module.js +2 -0
  96. package/dist/identity/accounts.d.ts +14 -1
  97. package/dist/identity/accounts.js +61 -5
  98. package/dist/identity/identity.module.js +2 -0
  99. package/dist/identity/settings.d.ts +28 -12
  100. package/dist/identity/settings.js +89 -33
  101. package/dist/index.d.ts +6 -0
  102. package/dist/index.js +5 -0
  103. package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
  104. package/dist/infra/cli/kernel-cli.module.js +5 -2
  105. package/dist/infra/cli/permission-cutover.d.ts +59 -0
  106. package/dist/infra/cli/permission-cutover.js +107 -0
  107. package/dist/infra/config/kernel-config.service.d.ts +2 -2
  108. package/dist/infra/config/kernel-config.service.js +35 -11
  109. package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
  110. package/dist/infra/database/startup-activation-transaction.js +242 -0
  111. package/dist/infra/database/transaction-host.d.ts +47 -0
  112. package/dist/infra/database/transaction-host.js +119 -0
  113. package/dist/infra/database/xact-lock.d.ts +1 -0
  114. package/dist/infra/database/xact-lock.js +6 -0
  115. package/dist/infra/outbox/registry.d.ts +39 -0
  116. package/dist/infra/outbox/registry.js +18 -0
  117. package/dist/kernel.module.js +2 -0
  118. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  119. package/dist/lifecycle/kernel-lifecycle.js +55 -28
  120. package/dist/local-devices/device-auth.js +1 -1
  121. package/dist/local-devices/device-policy.service.d.ts +35 -5
  122. package/dist/local-devices/device-policy.service.js +188 -13
  123. package/dist/local-devices/instance-bindings.d.ts +82 -0
  124. package/dist/local-devices/instance-bindings.js +304 -0
  125. package/dist/local-devices/keys.d.ts +5 -0
  126. package/dist/local-devices/keys.js +5 -0
  127. package/dist/local-devices/local-device-gateway.d.ts +19 -4
  128. package/dist/local-devices/local-device-gateway.js +185 -17
  129. package/dist/local-devices/local-device-provider.d.ts +42 -7
  130. package/dist/local-devices/local-device-provider.js +185 -10
  131. package/dist/local-devices/local-devices.module.d.ts +17 -2
  132. package/dist/local-devices/local-devices.module.js +49 -8
  133. package/dist/local-devices/machines.d.ts +35 -12
  134. package/dist/local-devices/machines.js +203 -8
  135. package/dist/local-devices/network-grants.js +3 -3
  136. package/dist/local-devices/network-grants.module.d.ts +2 -0
  137. package/dist/local-devices/network-grants.module.js +14 -0
  138. package/dist/local-devices/owner-report.d.ts +79 -0
  139. package/dist/local-devices/owner-report.js +155 -0
  140. package/dist/local-devices/owner-reports.d.ts +48 -0
  141. package/dist/local-devices/owner-reports.js +190 -0
  142. package/dist/local-devices/policy-summary.d.ts +24 -1
  143. package/dist/local-devices/policy-summary.js +48 -0
  144. package/dist/local-devices/relay.d.ts +82 -6
  145. package/dist/local-devices/relay.js +187 -16
  146. package/dist/local-devices/targets.d.ts +16 -1
  147. package/dist/local-devices/targets.js +35 -2
  148. package/dist/models/image-usable.d.ts +22 -0
  149. package/dist/models/image-usable.js +29 -0
  150. package/dist/models/images.d.ts +125 -0
  151. package/dist/models/images.js +440 -0
  152. package/dist/models/models.module.d.ts +3 -2
  153. package/dist/models/models.module.js +16 -5
  154. package/dist/models/org-models.schemas.js +1 -0
  155. package/dist/models/purposes.controller.d.ts +7 -0
  156. package/dist/models/purposes.controller.js +9 -0
  157. package/dist/models/purposes.d.ts +28 -3
  158. package/dist/models/purposes.js +40 -13
  159. package/dist/orgs/cloud-network-setting.d.ts +33 -0
  160. package/dist/orgs/cloud-network-setting.js +47 -0
  161. package/dist/orgs/offboarding.d.ts +3 -1
  162. package/dist/orgs/offboarding.js +8 -2
  163. package/dist/orgs/org-lock.d.ts +10 -4
  164. package/dist/orgs/org-lock.js +10 -4
  165. package/dist/orgs/orgs.service.d.ts +3 -1
  166. package/dist/orgs/orgs.service.js +8 -2
  167. package/dist/orgs/settings.controller.d.ts +4 -1
  168. package/dist/orgs/settings.controller.js +3 -3
  169. package/dist/orgs/settings.service.d.ts +48 -56
  170. package/dist/orgs/settings.service.js +144 -101
  171. package/dist/overrides.d.ts +6 -1
  172. package/dist/overrides.js +2 -0
  173. package/dist/platform/exclusions.js +20 -0
  174. package/dist/platform/ops/admin.ops.js +14 -11
  175. package/dist/platform/ops/agent-skills.ops.js +2 -0
  176. package/dist/platform/ops/devices.ops.js +10 -2
  177. package/dist/platform/ops/models.ops.js +10 -0
  178. package/dist/platform/ops/org-settings.ops.js +6 -6
  179. package/dist/platform/ops/orgs.ops.js +1 -0
  180. package/dist/roles/worker.module.js +4 -0
  181. package/dist/runtime/context/build.d.ts +3 -1
  182. package/dist/runtime/context/build.js +19 -3
  183. package/dist/runtime/context/compaction.js +5 -0
  184. package/dist/runtime/context/device-paths.d.ts +9 -2
  185. package/dist/runtime/context/device-paths.js +20 -0
  186. package/dist/runtime/context/permission-profile.d.ts +46 -0
  187. package/dist/runtime/context/permission-profile.js +194 -0
  188. package/dist/runtime/hook-calls.d.ts +11 -1
  189. package/dist/runtime/hook-calls.js +24 -1
  190. package/dist/runtime/maintenance.d.ts +7 -1
  191. package/dist/runtime/maintenance.js +43 -15
  192. package/dist/runtime/model-call.d.ts +32 -0
  193. package/dist/runtime/model-call.js +67 -0
  194. package/dist/runtime/permission-context-errors.d.ts +39 -0
  195. package/dist/runtime/permission-context-errors.js +67 -0
  196. package/dist/runtime/permission-context.service.d.ts +60 -0
  197. package/dist/runtime/permission-context.service.js +286 -0
  198. package/dist/runtime/project/knowledge.d.ts +7 -2
  199. package/dist/runtime/project/knowledge.js +5 -2
  200. package/dist/runtime/project/knowledge.service.d.ts +17 -2
  201. package/dist/runtime/project/knowledge.service.js +76 -12
  202. package/dist/runtime/providers.d.ts +9 -5
  203. package/dist/runtime/providers.js +22 -3
  204. package/dist/runtime/run-execution.d.ts +4 -1
  205. package/dist/runtime/run-execution.js +14 -5
  206. package/dist/runtime/run-steps.d.ts +11 -3
  207. package/dist/runtime/run-steps.js +27 -4
  208. package/dist/runtime/runtime.module.js +11 -0
  209. package/dist/runtime/usage-report.d.ts +10 -6
  210. package/dist/runtime/usage-report.js +31 -11
  211. package/dist/sandbox/attachments-path.d.ts +15 -0
  212. package/dist/sandbox/attachments-path.js +15 -0
  213. package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
  214. package/dist/sandbox/cloud-permission-snapshot.js +407 -0
  215. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
  216. package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
  217. package/dist/sandbox/held-operations.d.ts +39 -0
  218. package/dist/sandbox/held-operations.js +119 -0
  219. package/dist/sandbox/jobs.d.ts +14 -3
  220. package/dist/sandbox/jobs.js +20 -2
  221. package/dist/sandbox/kernel-read.d.ts +55 -0
  222. package/dist/sandbox/kernel-read.js +57 -0
  223. package/dist/sandbox/legacy-retirement.d.ts +336 -0
  224. package/dist/sandbox/legacy-retirement.js +1063 -0
  225. package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
  226. package/dist/sandbox/legacy-retirement.module.js +25 -0
  227. package/dist/sandbox/managed-device-context.d.ts +94 -0
  228. package/dist/sandbox/managed-device-context.js +308 -0
  229. package/dist/sandbox/managed-device-context.module.d.ts +6 -0
  230. package/dist/sandbox/managed-device-context.module.js +33 -0
  231. package/dist/sandbox/modes.d.ts +56 -8
  232. package/dist/sandbox/modes.js +92 -8
  233. package/dist/sandbox/operation-authority-types.d.ts +8 -0
  234. package/dist/sandbox/operation-authority-types.js +32 -0
  235. package/dist/sandbox/operation-authority.d.ts +145 -0
  236. package/dist/sandbox/operation-authority.js +783 -0
  237. package/dist/sandbox/operation-authority.module.d.ts +2 -0
  238. package/dist/sandbox/operation-authority.module.js +29 -0
  239. package/dist/sandbox/operation-intents.d.ts +206 -0
  240. package/dist/sandbox/operation-intents.js +1252 -0
  241. package/dist/sandbox/operation-intents.module.d.ts +2 -0
  242. package/dist/sandbox/operation-intents.module.js +21 -0
  243. package/dist/sandbox/operation-payloads.d.ts +33 -0
  244. package/dist/sandbox/operation-payloads.js +332 -0
  245. package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
  246. package/dist/sandbox/operation-reconcile.job.js +247 -0
  247. package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
  248. package/dist/sandbox/permission-authority-epochs.js +83 -0
  249. package/dist/sandbox/permission-authority-lock.d.ts +38 -0
  250. package/dist/sandbox/permission-authority-lock.js +147 -0
  251. package/dist/sandbox/permission-authority.module.d.ts +9 -0
  252. package/dist/sandbox/permission-authority.module.js +55 -0
  253. package/dist/sandbox/permission-availability.d.ts +18 -0
  254. package/dist/sandbox/permission-availability.js +19 -0
  255. package/dist/sandbox/permission-call-grants.d.ts +34 -0
  256. package/dist/sandbox/permission-call-grants.js +349 -0
  257. package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
  258. package/dist/sandbox/permission-call-grants.module.js +21 -0
  259. package/dist/sandbox/permission-call-types.d.ts +82 -0
  260. package/dist/sandbox/permission-call-types.js +1 -0
  261. package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
  262. package/dist/sandbox/permission-ceiling-writes.js +223 -0
  263. package/dist/sandbox/permission-config-publication.d.ts +76 -0
  264. package/dist/sandbox/permission-config-publication.js +339 -0
  265. package/dist/sandbox/permission-context-types.d.ts +64 -0
  266. package/dist/sandbox/permission-context-types.js +24 -0
  267. package/dist/sandbox/permission-facts.d.ts +206 -0
  268. package/dist/sandbox/permission-facts.js +627 -0
  269. package/dist/sandbox/permission-facts.module.d.ts +2 -0
  270. package/dist/sandbox/permission-facts.module.js +20 -0
  271. package/dist/sandbox/permission-instance-writes.d.ts +90 -0
  272. package/dist/sandbox/permission-instance-writes.js +305 -0
  273. package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
  274. package/dist/sandbox/permission-runtime-reports.js +354 -0
  275. package/dist/sandbox/permission-transitions.d.ts +31 -0
  276. package/dist/sandbox/permission-transitions.js +155 -0
  277. package/dist/sandbox/platform-full-access.d.ts +128 -0
  278. package/dist/sandbox/platform-full-access.js +210 -0
  279. package/dist/sandbox/providers.d.ts +22 -0
  280. package/dist/sandbox/providers.js +10 -2
  281. package/dist/sandbox/providers.module.d.ts +2 -0
  282. package/dist/sandbox/providers.module.js +19 -0
  283. package/dist/sandbox/request-not-sent.d.ts +13 -0
  284. package/dist/sandbox/request-not-sent.js +13 -0
  285. package/dist/sandbox/review/classifier.d.ts +2 -0
  286. package/dist/sandbox/review/classifier.js +8 -0
  287. package/dist/sandbox/review/permission-candidate.d.ts +12 -0
  288. package/dist/sandbox/review/permission-candidate.js +145 -0
  289. package/dist/sandbox/review/review.service.d.ts +5 -2
  290. package/dist/sandbox/review/review.service.js +60 -15
  291. package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
  292. package/dist/sandbox/sandbox-file-reader.js +51 -7
  293. package/dist/sandbox/sandbox.module.js +26 -6
  294. package/dist/sandbox/sandbox.service.d.ts +230 -34
  295. package/dist/sandbox/sandbox.service.js +1368 -199
  296. package/dist/sandbox/unreachable.js +17 -3
  297. package/dist/sandbox/use-context.d.ts +17 -0
  298. package/dist/sandbox/use-context.js +1 -0
  299. package/dist/skills/invoke.d.ts +27 -4
  300. package/dist/skills/invoke.js +72 -7
  301. package/dist/tools/approvals.controller.d.ts +1 -0
  302. package/dist/tools/approvals.schemas.d.ts +1 -0
  303. package/dist/tools/approvals.schemas.js +3 -1
  304. package/dist/tools/approvals.service.d.ts +23 -10
  305. package/dist/tools/approvals.service.js +104 -26
  306. package/dist/tools/builtin-names.d.ts +3 -1
  307. package/dist/tools/builtin-names.js +5 -1
  308. package/dist/tools/builtins/artifacts.d.ts +43 -0
  309. package/dist/tools/builtins/artifacts.js +67 -0
  310. package/dist/tools/builtins/builtin-tools.d.ts +20 -2
  311. package/dist/tools/builtins/builtin-tools.js +61 -10
  312. package/dist/tools/builtins/image/generate.d.ts +59 -0
  313. package/dist/tools/builtins/image/generate.js +535 -0
  314. package/dist/tools/builtins/image/index.d.ts +2 -0
  315. package/dist/tools/builtins/image/index.js +2 -0
  316. package/dist/tools/builtins/image/paths.d.ts +12 -0
  317. package/dist/tools/builtins/image/paths.js +26 -0
  318. package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
  319. package/dist/tools/builtins/sandbox/bash.js +201 -5
  320. package/dist/tools/builtins/sandbox/common.d.ts +92 -20
  321. package/dist/tools/builtins/sandbox/common.js +201 -17
  322. package/dist/tools/builtins/sandbox/deliver.js +9 -51
  323. package/dist/tools/builtins/sandbox/edit.js +2 -2
  324. package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
  325. package/dist/tools/builtins/sandbox/glob.js +2 -2
  326. package/dist/tools/builtins/sandbox/grep.js +2 -2
  327. package/dist/tools/builtins/sandbox/read.js +2 -2
  328. package/dist/tools/builtins/sandbox/task-list.js +7 -1
  329. package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
  330. package/dist/tools/builtins/sandbox/task-output.js +172 -0
  331. package/dist/tools/builtins/sandbox/task-stop.js +25 -3
  332. package/dist/tools/builtins/sandbox/write.js +2 -2
  333. package/dist/tools/builtins/skill-load.js +9 -6
  334. package/dist/tools/device-op-resolver.d.ts +1 -1
  335. package/dist/tools/device-op-resolver.js +13 -3
  336. package/dist/tools/permission-approval-jobs.d.ts +18 -0
  337. package/dist/tools/permission-approval-jobs.js +92 -0
  338. package/dist/tools/pipeline.d.ts +17 -2
  339. package/dist/tools/pipeline.js +315 -26
  340. package/dist/tools/registry.d.ts +9 -0
  341. package/dist/tools/tools.module.js +15 -0
  342. package/package.json +4 -3
  343. package/src/migrations/0146_permission_authority_epochs.sql +6 -0
  344. package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
  345. package/src/migrations/0148_first_message_request_hash.sql +2 -0
  346. package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
  347. package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
  348. package/src/migrations/0151_starting_execution_grants.sql +8 -0
  349. package/src/migrations/0152_background_launch_identity.sql +66 -0
  350. package/src/migrations/0153_background_cancel_requester.sql +13 -0
  351. package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
  352. package/src/migrations/0155_device_instance_generations.sql +30 -0
  353. package/src/migrations/0156_device_owner_report.sql +7 -0
  354. package/src/migrations/0157_legacy_retirement.sql +116 -0
  355. package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
  356. package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
  357. package/src/migrations/0160_model_usage_image_kind.sql +10 -0
  358. package/dist/sandbox/platform-auto-mode.d.ts +0 -63
  359. package/dist/sandbox/platform-auto-mode.js +0 -63
@@ -19,21 +19,14 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
19
19
  import { KernelDb } from "../infra/database/kernel-db.js";
20
20
  import { TransactionHost } from "../infra/database/transaction-host.js";
21
21
  import { Transactional } from "../infra/database/transactional.decorator.js";
22
+ import { KERNEL_LOGGER } from "../infra/tokens.js";
22
23
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
23
24
  import { OrgLock } from "../orgs/org-lock.js";
24
25
  import { estimateTokens } from "../runtime/context/tokens.js";
25
26
  import { consumeModelStream } from "../runtime/model-call.js";
26
27
  import { ProviderListError, ProviderRegistry } from "../runtime/providers.js";
27
- /**
28
- * 模型用途映射(C9):内核与插件按「用途」取模型,不在代码里写死模型。
29
- * - 用途 = 内核用途 {@link KERNEL_PURPOSES}(目前只有评委 `eval`),或已加载插件 `permissions.models` 声明的;
30
- * - 映射 = 部署默认(`org_id` 为 null,超级管理员设)+ 组织覆盖(组织管理员设,`org.models.manage`);
31
- * 生效的映射先取组织覆盖、再取部署默认,都没有 → `model.unconfigured`;
32
- * - a target's kind must equal the purpose's kind; an org's override must be enabled in the org on
33
- * save (a deployment default: not disabled on the platform), and an effective target disabled in
34
- * the org (by either layer) counts as unconfigured there (spec B §5.3);参数按目标模型自己的声明严格校验;
35
- * - 每次都查 PG,不在进程内缓存(多副本下改映射立即生效)。`ctx.models` 仍预留,插件暂不能调用。
36
- */
28
+ import { StorageService } from "../storage/storage.service.js";
29
+ import { IMAGE_PURPOSE, imagePurposeUsable } from "./image-usable.js";
37
30
  /**
38
31
  * Purposes the kernel declares: the eval judge, and the three sub-agent model tiers (phase C,
39
32
  * spec §5.4: `fast` / `standard` / `capable` → `subagent_<tier>`; an unmapped tier runs on the
@@ -68,6 +61,8 @@ export const KERNEL_PURPOSES = [
68
61
  kind: "chat",
69
62
  label: { zh: "子智能体:最强", en: "Sub-agent: capable" },
70
63
  },
64
+ /** The `GenerateImage` tool's model; no fallback: unmapped → `model.unconfigured`. */
65
+ { purpose: "image", kind: "image_generation", label: { zh: "图片生成", en: "Image generation" } },
71
66
  ];
72
67
  /** {@link PurposeListing}s of `views`, the display names read in one call. */
73
68
  export async function withDeclaredByNames(views, names) {
@@ -131,7 +126,11 @@ let ModelPurposesService = class ModelPurposesService {
131
126
  txHost;
132
127
  adminLock;
133
128
  orgLock;
134
- constructor(db, extensions, config, providers, txHost, adminLock, orgLock) {
129
+ storage;
130
+ log;
131
+ constructor(db, extensions, config, providers, txHost, adminLock, orgLock,
132
+ /** The `image` purpose's availability needs an object store (`GenerateImage` delivers there). */
133
+ storage, log) {
135
134
  this.db = db;
136
135
  this.extensions = extensions;
137
136
  this.config = config;
@@ -139,6 +138,8 @@ let ModelPurposesService = class ModelPurposesService {
139
138
  this.txHost = txHost;
140
139
  this.adminLock = adminLock;
141
140
  this.orgLock = orgLock;
141
+ this.storage = storage;
142
+ this.log = log;
142
143
  }
143
144
  /** 全部已声明的用途:内核的在前,其后按插件加载顺序。 */
144
145
  declared() {
@@ -196,6 +197,30 @@ let ModelPurposesService = class ModelPurposesService {
196
197
  async list(orgId) {
197
198
  return this.views(this.declared(), orgId);
198
199
  }
200
+ /**
201
+ * Whether each purpose (kernel and extension-declared) resolves to a usable model for the org
202
+ * now, as {@link resolve} decides, without naming the model (the agent form's gate for
203
+ * `GenerateImage`, readable by every member). The `image` purpose reads `GenerateImage`'s own
204
+ * predicate ({@link imagePurposeUsable}: an image model callable now and an object store).
205
+ */
206
+ async availability(orgId) {
207
+ const out = [];
208
+ for (const d of this.declared()) {
209
+ if (d.purpose === IMAGE_PURPOSE) {
210
+ // `GenerateImage`'s own predicate: the form offers the tool exactly when it is listed
211
+ const usable = await imagePurposeUsable({ purposes: this, providers: this.providers, storage: this.storage, log: this.log }, orgId);
212
+ out.push({ purpose: d.purpose, available: usable === "usable" });
213
+ continue;
214
+ }
215
+ const available = await this.resolve(orgId, d.purpose).then(() => true, (e) => {
216
+ if (e instanceof ApiError && e.code === "model.unconfigured")
217
+ return false;
218
+ throw e;
219
+ });
220
+ out.push({ purpose: d.purpose, available });
221
+ }
222
+ return out;
223
+ }
199
224
  /**
200
225
  * 校验目标:模型可解析且启用(an org's override for the org, a deployment default in the
201
226
  * platform view)、its kind is the purpose's `kind`、参数按它的声明严格通过。
@@ -220,7 +245,7 @@ let ModelPurposesService = class ModelPurposesService {
220
245
  throw invalid([
221
246
  {
222
247
  path: "target.model",
223
- message: `this purpose needs ${kind === "embedding" ? "an" : "a"} ${kind} model, not ${info.kind}`,
248
+ message: `this purpose needs ${/^[aeiou]/.test(kind) ? "an" : "a"} ${kind} model, not ${info.kind}`,
224
249
  },
225
250
  ]);
226
251
  }
@@ -398,6 +423,8 @@ ModelPurposesService = __decorate([
398
423
  __param(3, Inject(ProviderRegistry)),
399
424
  __param(4, Inject(TransactionHost)),
400
425
  __param(5, Inject(SuperAdminLock)),
401
- __param(6, Inject(OrgLock))
426
+ __param(6, Inject(OrgLock)),
427
+ __param(7, Inject(StorageService)),
428
+ __param(8, Inject(KERNEL_LOGGER))
402
429
  ], ModelPurposesService);
403
430
  export { ModelPurposesService };
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ /** The org cloud-network allowlist's host limit. */
3
+ export declare const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
4
+ /**
5
+ * The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
6
+ * platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
7
+ * org:
8
+ * - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
9
+ * private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
10
+ * follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
11
+ * - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
12
+ * hosts).
13
+ * - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
14
+ * - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
15
+ * platform may drop an entry later).
16
+ * The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
17
+ * device in sandbox mode reaches (the device intersects them with its own list).
18
+ */
19
+ export declare const CloudNetworkSettingSchema: z.ZodObject<{
20
+ mode: z.ZodOptional<z.ZodEnum<{
21
+ allowlist: "allowlist";
22
+ open: "open";
23
+ }>>;
24
+ base: z.ZodOptional<z.ZodEnum<{
25
+ none: "none";
26
+ platform: "platform";
27
+ }>>;
28
+ extraHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ excludedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ }, z.core.$strict>;
31
+ export type CloudNetworkSetting = z.infer<typeof CloudNetworkSettingSchema>;
32
+ /** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
33
+ export declare const invalidCloudNetwork: () => CloudNetworkSetting;
@@ -0,0 +1,47 @@
1
+ import { validateAllowHost } from "@capybara-hq/plugin-sdk";
2
+ import { z } from "zod";
3
+ /** The org cloud-network allowlist's host limit. */
4
+ export const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
5
+ /** One host list of the org's cloud network: at most {@link ORG_SANDBOX_ALLOW_HOSTS_MAX} valid, unique hosts. */
6
+ const orgHostList = (name) => z
7
+ .array(z.string())
8
+ .max(ORG_SANDBOX_ALLOW_HOSTS_MAX)
9
+ .superRefine((hosts, ctx) => {
10
+ hosts.forEach((h, i) => {
11
+ for (const message of validateAllowHost(h)) {
12
+ ctx.addIssue({ code: "custom", path: [i], message: `${h}: ${message}` });
13
+ }
14
+ });
15
+ if (new Set(hosts).size !== hosts.length) {
16
+ ctx.addIssue({ code: "custom", message: `${name} must not contain duplicates` });
17
+ }
18
+ })
19
+ .optional();
20
+ /**
21
+ * The org's sandbox-mode network (org egress ceiling spec §D1), stored as a delta over the
22
+ * platform's `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the
23
+ * org:
24
+ * - `mode`: the cloud network of a cloud device in sandbox mode, `open` (any public host; loopback,
25
+ * private and cloud metadata addresses are blocked outside the container) or `allowlist`; absent
26
+ * follows the platform's default (open). `sandbox.limits.orgHosts: within` makes it the allowlist.
27
+ * - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
28
+ * hosts).
29
+ * - `extraHosts`: hosts the org adds (ignored outside the platform list under `within`).
30
+ * - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
31
+ * platform may drop an entry later).
32
+ * The effective hosts ({@link orgEffectiveHosts} in `sandbox/modes.ts`) are also the ceiling a local
33
+ * device in sandbox mode reaches (the device intersects them with its own list).
34
+ */
35
+ export const CloudNetworkSettingSchema = z
36
+ .object({
37
+ mode: z.enum(["open", "allowlist"]).optional(),
38
+ base: z.enum(["platform", "none"]).optional(),
39
+ extraHosts: orgHostList("extraHosts"),
40
+ excludedHosts: orgHostList("excludedHosts"),
41
+ })
42
+ .strict();
43
+ /** What an invalid stored `cloudNetwork` reads as: the allowlist with no host (never wider). */
44
+ export const invalidCloudNetwork = () => ({
45
+ mode: "allowlist",
46
+ base: "none",
47
+ });
@@ -6,6 +6,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
6
6
  import { TransactionHost } from "../infra/database/transaction-host.js";
7
7
  import { OutboxService } from "../infra/outbox/outbox.service.js";
8
8
  import type { KernelLogger } from "../log.js";
9
+ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
9
10
  import { ApprovalsService } from "../tools/approvals.service.js";
10
11
  import { Credentials } from "../tools/credentials.js";
11
12
  import { QuestionsService } from "../tools/questions.service.js";
@@ -84,6 +85,7 @@ export declare class Offboarding {
84
85
  /** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
85
86
  private readonly lifecycle;
86
87
  readonly log: KernelLogger;
88
+ private readonly ceilings;
87
89
  private readonly orgLock;
88
90
  constructor(db: KernelDb, txHost: TransactionHost, sessions: Pick<SessionService, "markRevoked">, registry: Pick<ExtensionRegistry, "list">, eventLog: Pick<EventLog, "notify" | "publishChanged">,
89
91
  /** Owes the run stops and device destroys in the offboard transaction. */
@@ -91,7 +93,7 @@ export declare class Offboarding {
91
93
  /** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
92
94
  runs: OffboardingRunControl, credentials: Pick<Credentials, "clearAccount">, approvals: Pick<ApprovalsService, "pendingConversationsFor" | "cancelPendingFor">, questions: Pick<QuestionsService, "pendingConversationsFor" | "cancelPendingFor">,
93
95
  /** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
94
- lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, orgLock: Pick<OrgLock, "lockForRemoval">);
96
+ lifecycle: Pick<LifecycleHooks, "recordIn">, log: KernelLogger, ceilings: PermissionCeilingWrites, orgLock: Pick<OrgLock, "lockForRemoval">);
95
97
  /**
96
98
  * In the caller's transaction (`mandatory`: the caller holds the org row lock, order org row →
97
99
  * membership, and did the "last owner" checks):
@@ -27,6 +27,7 @@ import { KERNEL_LOGGER } from "../infra/tokens.js";
27
27
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
28
28
  import { RunControl } from "../runtime/run-control.js";
29
29
  import { oweDeviceDestroy } from "../sandbox/jobs.js";
30
+ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
30
31
  import { ApprovalsService } from "../tools/approvals.service.js";
31
32
  import { Credentials } from "../tools/credentials.js";
32
33
  import { QuestionsService } from "../tools/questions.service.js";
@@ -66,6 +67,7 @@ let Offboarding = class Offboarding {
66
67
  questions;
67
68
  lifecycle;
68
69
  log;
70
+ ceilings;
69
71
  orgLock;
70
72
  constructor(db, txHost, sessions, registry, eventLog,
71
73
  /** Owes the run stops and device destroys in the offboard transaction. */
@@ -73,7 +75,7 @@ let Offboarding = class Offboarding {
73
75
  /** Stops the departed member's runs (`by: null`, a system action) in the `run-stop` job. */
74
76
  runs, credentials, approvals, questions,
75
77
  /** Owes `org.member_removed` to the subscribing plugins, in the offboard transaction. */
76
- lifecycle, log, orgLock) {
78
+ lifecycle, log, ceilings, orgLock) {
77
79
  this.db = db;
78
80
  this.txHost = txHost;
79
81
  this.sessions = sessions;
@@ -86,6 +88,7 @@ let Offboarding = class Offboarding {
86
88
  this.questions = questions;
87
89
  this.lifecycle = lifecycle;
88
90
  this.log = log;
91
+ this.ceilings = ceilings;
89
92
  this.orgLock = orgLock;
90
93
  }
91
94
  /**
@@ -114,6 +117,8 @@ let Offboarding = class Offboarding {
114
117
  // the org admission lock exclusively (the callers take it first, before the org row; a no-op
115
118
  // then): it waits for the run writes the fence admitted shared and keeps new ones out
116
119
  await this.orgLock.lockForRemoval(orgId);
120
+ await this.ceilings.lock({ orgId }, "org");
121
+ await this.ceilings.publishLocked({ orgId }, "org", (_scope, row) => row.account_id === accountId);
117
122
  const deleted = await this.db
118
123
  .deleteFrom("memberships")
119
124
  .where("org_id", "=", orgId)
@@ -470,6 +475,7 @@ Offboarding = __decorate([
470
475
  __param(9, Inject(QuestionsService)),
471
476
  __param(10, Inject(LifecycleHooks)),
472
477
  __param(11, Inject(KERNEL_LOGGER)),
473
- __param(12, Inject(OrgLock))
478
+ __param(12, Inject(PermissionCeilingWrites)),
479
+ __param(13, Inject(OrgLock))
474
480
  ], Offboarding);
475
481
  export { Offboarding };
@@ -20,10 +20,16 @@ export interface LockedOrg {
20
20
  * `FOR UPDATE`: org deletion's `deleted_at` update is a no-key update too.
21
21
  *
22
22
  * The global lock order: the org admission lock ({@link lockForRemoval}; the run fence's shared
23
- * admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → the
24
- * root conversation → the conversation. A writer that locks several conversation or run rows of
25
- * one tree locks the tree's root conversation first. A transaction the run fence admitted shared
26
- * takes none of these org-level locks (each method throws in one, `assertNotSharedAdmission`).
23
+ * admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → a
24
+ * membership row → a device row (`DevicesService.lockOwn`, the device project writes, the cloud
25
+ * permission snapshot) → the super admin advisory lock (`SuperAdminLock`) → the permission
26
+ * authority locks (`PermissionAuthorityLock`: platform, org, device, root; inside a run's fence
27
+ * an ordered prelude takes them and the locks before them, `withOrderedLocks` /
28
+ * `withTransactionFencePrelude`) → the root conversation → the conversation (then what a writer
29
+ * locks under its conversation: an approval, a run, a machine row). A writer that locks several
30
+ * conversation or run rows of one tree locks the tree's root conversation first. A transaction
31
+ * the run fence admitted shared takes none of these org-level locks (each method throws in one,
32
+ * `assertNotSharedAdmission`).
27
33
  */
28
34
  export declare class OrgLock {
29
35
  private readonly db;
@@ -27,10 +27,16 @@ import { can } from "./roles.js";
27
27
  * `FOR UPDATE`: org deletion's `deleted_at` update is a no-key update too.
28
28
  *
29
29
  * The global lock order: the org admission lock ({@link lockForRemoval}; the run fence's shared
30
- * admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → the
31
- * root conversation → the conversation. A writer that locks several conversation or run rows of
32
- * one tree locks the tree's root conversation first. A transaction the run fence admitted shared
33
- * takes none of these org-level locks (each method throws in one, `assertNotSharedAdmission`).
30
+ * admission, `RunExecution`) → this org row lock (also the run fence's exclusive admission) → a
31
+ * membership row → a device row (`DevicesService.lockOwn`, the device project writes, the cloud
32
+ * permission snapshot) → the super admin advisory lock (`SuperAdminLock`) → the permission
33
+ * authority locks (`PermissionAuthorityLock`: platform, org, device, root; inside a run's fence
34
+ * an ordered prelude takes them and the locks before them, `withOrderedLocks` /
35
+ * `withTransactionFencePrelude`) → the root conversation → the conversation (then what a writer
36
+ * locks under its conversation: an approval, a run, a machine row). A writer that locks several
37
+ * conversation or run rows of one tree locks the tree's root conversation first. A transaction
38
+ * the run fence admitted shared takes none of these org-level locks (each method throws in one,
39
+ * `assertNotSharedAdmission`).
34
40
  */
35
41
  let OrgLock = class OrgLock {
36
42
  db;
@@ -9,6 +9,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
9
9
  import { TransactionHost } from "../infra/database/transaction-host.js";
10
10
  import { KernelEvents } from "../infra/events/kernel-events.js";
11
11
  import { OutboxService } from "../infra/outbox/outbox.service.js";
12
+ import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
12
13
  import { OrgLock } from "./org-lock.js";
13
14
  import type { OrgRole } from "./roles.js";
14
15
  export type Org = {
@@ -41,6 +42,7 @@ export declare class OrgsService {
41
42
  private readonly ownedItems;
42
43
  /** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
43
44
  private readonly lifecycle;
45
+ private readonly ceilings;
44
46
  constructor(db: KernelDb, outbox: Pick<OutboxService, "add">, txHost: TransactionHost, settings: SettingsService, apiTokens: ApiTokenService, orgLock: OrgLock, events: KernelEvents,
45
47
  /** Cancels the deleted org's running eval runs (in the delete's transaction). */
46
48
  evalBudget: Pick<EvalBudget, "cancelRuns">,
@@ -49,7 +51,7 @@ export declare class OrgsService {
49
51
  /** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
50
52
  ownedItems: Pick<OwnedItems, "onOrgDeleted">,
51
53
  /** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
52
- lifecycle: Pick<LifecycleHooks, "recordIn">);
54
+ lifecycle: Pick<LifecycleHooks, "recordIn">, ceilings: PermissionCeilingWrites);
53
55
  /**
54
56
  * Creates an org with the actor as owner, in the caller's transaction when there is one (the
55
57
  * setup wizard creates it with the account); a slug conflict is `org.slug_taken` either way, but
@@ -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),