@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38

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 (351) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -2
  3. package/dist/admin/admin.module.js +9 -5
  4. package/dist/admin/audit-log.service.d.ts +51 -0
  5. package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
  6. package/dist/admin/audit.controller.d.ts +18 -6
  7. package/dist/admin/audit.controller.js +36 -6
  8. package/dist/admin/audit.schemas.d.ts +9 -1
  9. package/dist/admin/audit.schemas.js +22 -2
  10. package/dist/admin/org-network.controller.d.ts +30 -0
  11. package/dist/admin/org-network.controller.js +77 -0
  12. package/dist/admin/org-network.schemas.d.ts +16 -0
  13. package/dist/admin/org-network.schemas.js +27 -0
  14. package/dist/admin/org-network.service.d.ts +41 -0
  15. package/dist/admin/org-network.service.js +101 -0
  16. package/dist/admin/outbox-dead.controller.d.ts +4 -6
  17. package/dist/admin/outbox-dead.controller.js +9 -6
  18. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  19. package/dist/admin/outbox-dead.schemas.js +25 -1
  20. package/dist/admin/outbox-dead.service.d.ts +16 -7
  21. package/dist/admin/outbox-dead.service.js +34 -10
  22. package/dist/admin/overview.service.d.ts +3 -3
  23. package/dist/admin/overview.service.js +0 -1
  24. package/dist/agents/agent-lookup.js +2 -10
  25. package/dist/agents/agents.service.js +9 -20
  26. package/dist/agents/definition.d.ts +3 -51
  27. package/dist/agents/definition.js +4 -254
  28. package/dist/agents/org-templates.js +2 -6
  29. package/dist/agents/readiness.controller.d.ts +4 -12
  30. package/dist/agents/readiness.controller.js +4 -12
  31. package/dist/agents/readiness.service.d.ts +23 -11
  32. package/dist/agents/readiness.service.js +31 -14
  33. package/dist/agents/templates.d.ts +0 -6
  34. package/dist/agents/templates.js +8 -34
  35. package/dist/background/store.d.ts +2 -0
  36. package/dist/background/store.js +3 -1
  37. package/dist/background/wake-rules.js +2 -1
  38. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  39. package/dist/catalog/admin-catalog.controller.js +1 -2
  40. package/dist/catalog/appearance.service.js +1 -3
  41. package/dist/catalog/catalog-content.d.ts +1 -1
  42. package/dist/catalog/catalog-content.js +1 -4
  43. package/dist/catalog/catalog-items.js +3 -3
  44. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  45. package/dist/catalog/catalog-scope.service.js +22 -73
  46. package/dist/catalog/cli.d.ts +0 -11
  47. package/dist/catalog/cli.js +0 -20
  48. package/dist/catalog/component-scope.service.js +0 -2
  49. package/dist/catalog/component-state.js +2 -2
  50. package/dist/catalog/install-status.d.ts +6 -0
  51. package/dist/catalog/install-status.js +6 -0
  52. package/dist/catalog/job-ids.d.ts +0 -4
  53. package/dist/catalog/job-ids.js +0 -4
  54. package/dist/catalog/marketplaces.service.d.ts +1 -1
  55. package/dist/catalog/org-catalog.service.d.ts +2 -0
  56. package/dist/catalog/org-catalog.service.js +8 -3
  57. package/dist/catalog/org-extension-switch.d.ts +7 -2
  58. package/dist/catalog/org-extension-switch.js +56 -9
  59. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  60. package/dist/catalog/org-plugin-uploads.js +9 -27
  61. package/dist/catalog/owned-items.js +1 -3
  62. package/dist/catalog/platform-import-update.js +1 -1
  63. package/dist/catalog/plugin-import.d.ts +15 -13
  64. package/dist/catalog/plugin-import.js +21 -30
  65. package/dist/catalog/plugin-install.d.ts +3 -43
  66. package/dist/catalog/plugin-install.js +8 -150
  67. package/dist/catalog/plugin-package.d.ts +5 -10
  68. package/dist/catalog/plugin-package.js +12 -33
  69. package/dist/catalog/plugin-upgrade.js +5 -4
  70. package/dist/catalog/scope-jobs.d.ts +34 -34
  71. package/dist/catalog/scope-jobs.js +50 -37
  72. package/dist/catalog/scope-orgs.d.ts +1 -1
  73. package/dist/catalog/scope-orgs.js +1 -2
  74. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  75. package/dist/catalog/scope-sync-workers.js +18 -6
  76. package/dist/catalog/scope-sync.d.ts +56 -59
  77. package/dist/catalog/scope-sync.js +96 -166
  78. package/dist/catalog/unshare.d.ts +3 -4
  79. package/dist/catalog/unshare.js +5 -8
  80. package/dist/channels/job-ids.d.ts +2 -6
  81. package/dist/channels/job-ids.js +2 -6
  82. package/dist/channels/outbound.d.ts +1 -1
  83. package/dist/channels/outbound.js +1 -1
  84. package/dist/channels/supervisor.d.ts +2 -3
  85. package/dist/channels/supervisor.js +2 -3
  86. package/dist/client/client-access.service.js +1 -1
  87. package/dist/config/env.js +19 -1
  88. package/dist/config/load.d.ts +0 -6
  89. package/dist/config/load.js +8 -27
  90. package/dist/config/schema.d.ts +54 -47
  91. package/dist/config/schema.js +198 -42
  92. package/dist/conversations/attachments.service.d.ts +10 -3
  93. package/dist/conversations/attachments.service.js +49 -16
  94. package/dist/conversations/conversations.controller.d.ts +0 -39
  95. package/dist/conversations/conversations.controller.js +0 -39
  96. package/dist/conversations/event-log.js +4 -1
  97. package/dist/conversations/events.d.ts +71 -46
  98. package/dist/conversations/events.js +124 -112
  99. package/dist/conversations/media-types.d.ts +25 -0
  100. package/dist/conversations/media-types.js +38 -0
  101. package/dist/conversations/queue.d.ts +3 -1
  102. package/dist/conversations/queue.service.js +9 -2
  103. package/dist/conversations/titles.js +6 -0
  104. package/dist/ctx/create-ctx.d.ts +8 -1
  105. package/dist/ctx/create-ctx.js +13 -3
  106. package/dist/ctx/net.d.ts +50 -0
  107. package/dist/ctx/net.js +67 -0
  108. package/dist/ctx/secrets.d.ts +24 -7
  109. package/dist/ctx/secrets.js +97 -30
  110. package/dist/db/kernel-schema.d.ts +27 -6
  111. package/dist/devices/devices.service.js +2 -1
  112. package/dist/errors.d.ts +10 -2
  113. package/dist/errors.js +10 -2
  114. package/dist/evals/reconstruct.d.ts +4 -17
  115. package/dist/evals/reconstruct.js +13 -53
  116. package/dist/evals/recorded-tools.d.ts +0 -27
  117. package/dist/evals/recorded-tools.js +2 -92
  118. package/dist/evals/run-replay.d.ts +1 -6
  119. package/dist/evals/run-replay.js +10 -17
  120. package/dist/evals/sets.service.d.ts +17 -5
  121. package/dist/evals/sets.service.js +33 -12
  122. package/dist/evals/snapshot.d.ts +1 -2
  123. package/dist/evals/snapshot.js +4 -17
  124. package/dist/extensions/admin-ops.d.ts +6 -1
  125. package/dist/extensions/admin-ops.js +17 -4
  126. package/dist/extensions/admin-view.d.ts +7 -4
  127. package/dist/extensions/admin-view.js +27 -21
  128. package/dist/extensions/bootstrap.js +0 -1
  129. package/dist/extensions/cli.js +0 -1
  130. package/dist/extensions/extensions.module.js +3 -0
  131. package/dist/extensions/host.d.ts +9 -4
  132. package/dist/extensions/host.js +14 -8
  133. package/dist/extensions/installs.d.ts +1 -3
  134. package/dist/extensions/instance.d.ts +0 -2
  135. package/dist/extensions/instance.js +0 -3
  136. package/dist/extensions/org-config.d.ts +4 -4
  137. package/dist/extensions/org-config.js +13 -22
  138. package/dist/extensions/package.d.ts +6 -6
  139. package/dist/extensions/package.js +3 -7
  140. package/dist/extensions/permission-view.d.ts +2 -4
  141. package/dist/extensions/plugin-items.d.ts +21 -1
  142. package/dist/extensions/plugin-items.js +28 -0
  143. package/dist/extensions/sync.js +5 -10
  144. package/dist/extensions/unavailable.js +0 -1
  145. package/dist/http/api.module.js +4 -1
  146. package/dist/identity/audit.d.ts +0 -12
  147. package/dist/identity/audit.js +0 -27
  148. package/dist/identity/auth.controller.js +5 -9
  149. package/dist/identity/cookies.d.ts +4 -9
  150. package/dist/identity/cookies.js +8 -32
  151. package/dist/identity/initial-passwords.d.ts +1 -1
  152. package/dist/identity/initial-passwords.js +1 -2
  153. package/dist/identity/sessions.d.ts +0 -6
  154. package/dist/identity/sessions.js +0 -18
  155. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  156. package/dist/inbox/platform-inbox.service.js +56 -6
  157. package/dist/index.d.ts +4 -2
  158. package/dist/index.js +4 -2
  159. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  160. package/dist/infra/cli/master-key-rewrap.js +24 -0
  161. package/dist/infra/config/kernel-config.service.js +0 -17
  162. package/dist/infra/database/transaction-host.d.ts +32 -1
  163. package/dist/infra/database/transaction-host.js +30 -4
  164. package/dist/infra/database/xact-lock.d.ts +16 -0
  165. package/dist/infra/database/xact-lock.js +28 -1
  166. package/dist/infra/health/health.controller.js +8 -0
  167. package/dist/infra/health/process-fault.d.ts +16 -0
  168. package/dist/infra/health/process-fault.js +49 -0
  169. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  170. package/dist/infra/lifecycle/process-guards.js +12 -3
  171. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  172. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  173. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  174. package/dist/infra/outbox/outbox.service.js +22 -26
  175. package/dist/infra/outbox/registry.d.ts +15 -7
  176. package/dist/infra/outbox/registry.js +39 -23
  177. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  178. package/dist/models/enablement.d.ts +5 -6
  179. package/dist/models/enablement.js +7 -14
  180. package/dist/net/public-address.d.ts +21 -1
  181. package/dist/net/public-address.js +56 -10
  182. package/dist/net/safe-fetch.d.ts +4 -1
  183. package/dist/net/safe-fetch.js +15 -4
  184. package/dist/orgs/directory-sync.js +2 -0
  185. package/dist/orgs/members.service.js +5 -0
  186. package/dist/orgs/network-allowances.service.d.ts +79 -0
  187. package/dist/orgs/network-allowances.service.js +371 -0
  188. package/dist/orgs/offboarding.d.ts +3 -1
  189. package/dist/orgs/offboarding.js +9 -2
  190. package/dist/orgs/org-lock.d.ts +28 -2
  191. package/dist/orgs/org-lock.js +59 -4
  192. package/dist/orgs/orgs.controller.d.ts +11 -2
  193. package/dist/orgs/orgs.controller.js +19 -3
  194. package/dist/orgs/orgs.module.d.ts +3 -2
  195. package/dist/orgs/orgs.module.js +6 -2
  196. package/dist/orgs/orgs.schemas.d.ts +12 -0
  197. package/dist/orgs/orgs.schemas.js +5 -0
  198. package/dist/orgs/orgs.service.js +6 -1
  199. package/dist/orgs/settings.controller.d.ts +3 -2
  200. package/dist/orgs/settings.service.d.ts +59 -14
  201. package/dist/orgs/settings.service.js +102 -20
  202. package/dist/overrides.d.ts +7 -7
  203. package/dist/overrides.js +4 -4
  204. package/dist/packages/tgz.d.ts +0 -2
  205. package/dist/packages/tgz.js +0 -2
  206. package/dist/platform/exclusions.js +0 -5
  207. package/dist/platform/operation.js +1 -1
  208. package/dist/platform/ops/admin.ops.d.ts +2 -2
  209. package/dist/platform/ops/admin.ops.js +9 -6
  210. package/dist/platform/ops/agents.ops.js +1 -1
  211. package/dist/platform/ops/connectors.ops.js +46 -1
  212. package/dist/platform/ops/evals.ops.js +1 -64
  213. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  214. package/dist/platform/ops/inbox.ops.js +16 -3
  215. package/dist/platform/ops/org-plugins.ops.js +1 -1
  216. package/dist/platform/ops/orgs.ops.d.ts +11 -3
  217. package/dist/platform/ops/orgs.ops.js +139 -5
  218. package/dist/platform/ops/outbox.ops.js +5 -5
  219. package/dist/platform/route-schemas.js +3 -0
  220. package/dist/roles/worker-role.d.ts +2 -3
  221. package/dist/roles/worker-role.js +3 -13
  222. package/dist/runtime/checkpointer.d.ts +3 -0
  223. package/dist/runtime/checkpointer.js +7 -4
  224. package/dist/runtime/context/build.d.ts +56 -18
  225. package/dist/runtime/context/build.js +143 -50
  226. package/dist/runtime/context/compaction.d.ts +1 -3
  227. package/dist/runtime/context/compaction.js +42 -8
  228. package/dist/runtime/context/run-context.js +1 -2
  229. package/dist/runtime/context/skills.d.ts +27 -56
  230. package/dist/runtime/context/skills.js +42 -114
  231. package/dist/runtime/context/tool-changes.d.ts +3 -3
  232. package/dist/runtime/context/tool-changes.js +6 -16
  233. package/dist/runtime/hook-calls.d.ts +6 -6
  234. package/dist/runtime/hook-calls.js +7 -7
  235. package/dist/runtime/langgraph-loop.js +9 -3
  236. package/dist/runtime/maintenance.d.ts +3 -11
  237. package/dist/runtime/maintenance.js +5 -20
  238. package/dist/runtime/model-call.d.ts +5 -0
  239. package/dist/runtime/model-call.js +48 -36
  240. package/dist/runtime/providers.d.ts +33 -35
  241. package/dist/runtime/providers.js +64 -109
  242. package/dist/runtime/run-context.service.js +7 -22
  243. package/dist/runtime/run-deletion.d.ts +6 -0
  244. package/dist/runtime/run-deletion.js +39 -16
  245. package/dist/runtime/run-execution.d.ts +56 -3
  246. package/dist/runtime/run-execution.js +81 -11
  247. package/dist/runtime/run-finish.js +2 -1
  248. package/dist/runtime/run-liveness.d.ts +11 -0
  249. package/dist/runtime/run-liveness.js +19 -0
  250. package/dist/runtime/run-orphan-check.job.js +2 -1
  251. package/dist/runtime/run-queue.js +8 -16
  252. package/dist/runtime/run-worker.d.ts +2 -2
  253. package/dist/runtime/run-worker.js +8 -6
  254. package/dist/runtime/step-log.d.ts +5 -0
  255. package/dist/runtime/step-log.js +9 -4
  256. package/dist/runtime/subagents/definition.d.ts +16 -20
  257. package/dist/runtime/subagents/definition.js +27 -27
  258. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  259. package/dist/runtime/subagents/dispatch.js +17 -3
  260. package/dist/runtime/subagents/org-agents.js +1 -2
  261. package/dist/runtime/subagents/preamble.d.ts +3 -2
  262. package/dist/runtime/subagents/preamble.js +3 -2
  263. package/dist/runtime/subagents/render.d.ts +1 -2
  264. package/dist/runtime/subagents/render.js +1 -2
  265. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  266. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  267. package/dist/runtime/subagents/template-skills.js +76 -0
  268. package/dist/runtime/waits.js +3 -1
  269. package/dist/schedules/effective-settings.d.ts +9 -3
  270. package/dist/schedules/effective-settings.js +5 -4
  271. package/dist/schedules/fire.js +11 -0
  272. package/dist/schedules/scheduled-tasks.service.js +5 -0
  273. package/dist/schedules/unattended.d.ts +2 -0
  274. package/dist/schedules/unattended.js +6 -1
  275. package/dist/skills/agent-skills.service.js +1 -2
  276. package/dist/skills/catalog.d.ts +1 -3
  277. package/dist/skills/catalog.js +1 -3
  278. package/dist/skills/conversation-catalog.d.ts +1 -2
  279. package/dist/skills/conversation-catalog.js +1 -2
  280. package/dist/skills/usable.js +2 -3
  281. package/dist/storage/storage.service.js +9 -1
  282. package/dist/tools/approvals.service.js +2 -4
  283. package/dist/tools/builtin-names.d.ts +2 -9
  284. package/dist/tools/builtin-names.js +4 -13
  285. package/dist/tools/builtins/sandbox/bash.js +3 -3
  286. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  287. package/dist/tools/builtins/sandbox/common.js +8 -115
  288. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  289. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  290. package/dist/tools/builtins/sandbox/glob.js +1 -3
  291. package/dist/tools/builtins/sandbox/grep.js +3 -5
  292. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  293. package/dist/tools/builtins/sandbox/index.js +10 -5
  294. package/dist/tools/builtins/sandbox/read.js +3 -2
  295. package/dist/tools/builtins/tool-search.d.ts +4 -7
  296. package/dist/tools/builtins/tool-search.js +6 -10
  297. package/dist/tools/connector-account-policies.d.ts +30 -3
  298. package/dist/tools/connector-account-policies.js +54 -7
  299. package/dist/tools/connector-content.js +1 -0
  300. package/dist/tools/connectors.controller.d.ts +24 -11
  301. package/dist/tools/connectors.controller.js +35 -6
  302. package/dist/tools/connectors.schemas.d.ts +14 -1
  303. package/dist/tools/connectors.schemas.js +14 -2
  304. package/dist/tools/connectors.service.d.ts +22 -0
  305. package/dist/tools/connectors.service.js +65 -6
  306. package/dist/tools/drift.d.ts +6 -2
  307. package/dist/tools/drift.js +10 -5
  308. package/dist/tools/git-push-policy.d.ts +4 -1
  309. package/dist/tools/git-push-policy.js +3 -1
  310. package/dist/tools/info.d.ts +1 -7
  311. package/dist/tools/info.js +5 -18
  312. package/dist/tools/job-ids.d.ts +0 -4
  313. package/dist/tools/job-ids.js +1 -6
  314. package/dist/tools/pipeline.d.ts +4 -10
  315. package/dist/tools/pipeline.js +17 -62
  316. package/dist/tools/policy.d.ts +6 -2
  317. package/dist/tools/policy.js +14 -12
  318. package/dist/tools/registry.js +1 -5
  319. package/dist/ui/views.d.ts +5 -5
  320. package/dist/ui/views.js +10 -16
  321. package/package.json +3 -3
  322. package/src/migrations/0137_audit_org_idx.sql +5 -0
  323. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  324. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  325. package/src/migrations/0140_retire_history_forms.sql +148 -0
  326. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  327. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  328. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  329. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  330. package/src/migrations/0145_org_network_allowances.sql +12 -0
  331. package/dist/admin/platform-audit.service.d.ts +0 -41
  332. package/dist/conversations/job-ids.d.ts +0 -6
  333. package/dist/conversations/job-ids.js +0 -6
  334. package/dist/extensions/job-ids.d.ts +0 -6
  335. package/dist/extensions/job-ids.js +0 -6
  336. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  337. package/dist/infra/queue/retired-schedulers.js +0 -9
  338. package/dist/orgs/job-ids.d.ts +0 -8
  339. package/dist/orgs/job-ids.js +0 -8
  340. package/dist/runtime/context/legacy-text.d.ts +0 -22
  341. package/dist/runtime/context/legacy-text.js +0 -37
  342. package/dist/runtime/job-ids.d.ts +0 -10
  343. package/dist/runtime/job-ids.js +0 -10
  344. package/dist/runtime/retired-schedulers.d.ts +0 -7
  345. package/dist/runtime/retired-schedulers.js +0 -31
  346. package/dist/storage/job-ids.d.ts +0 -6
  347. package/dist/storage/job-ids.js +0 -6
  348. package/dist/tools/legacy-data.d.ts +0 -34
  349. package/dist/tools/legacy-data.js +0 -76
  350. package/dist/tools/legacy-keys.d.ts +0 -51
  351. package/dist/tools/legacy-keys.js +0 -114
package/bootstrap.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schemaVersion": 1,
4
4
  "marketplace": {
5
5
  "url": "https://github.com/capybara-hq/plugins.git",
6
- "commit": "85aaf6598bee6f27ed9da9836084e2295eb29e03"
6
+ "commit": "05d00a946d26e9e519a258583c2f2468f7b7fcb5"
7
7
  },
8
8
  "plugins": [
9
9
  {
@@ -18,8 +18,8 @@
18
18
  "name": "object-store-s3",
19
19
  "source": "npm",
20
20
  "npm": "@capybara-hq/plugin-object-store-s3",
21
- "version": "0.1.0-rc.9",
22
- "integrity": "sha512-yqW5gM5+4sdY/nJWDyu7ltDLdUm6b4q9+R/yrCLJhMRCI7HQbxeqDWky29EiDjjsJD5BaiQ6N3a5Ua75ANll7g==",
21
+ "version": "0.1.0-rc.10",
22
+ "integrity": "sha512-uzpvEixkXcngBr33iXSgsupTGG8wLkLTo9JeA134rCeknrUX1IhkfkJKw6L2mwpnefyuBwt9l/vb+eiSZrZXCw==",
23
23
  "required": true
24
24
  },
25
25
  {
@@ -98,8 +98,8 @@
98
98
  "name": "todo",
99
99
  "source": "npm",
100
100
  "npm": "@capybara-hq/plugin-todo",
101
- "version": "0.1.0-rc.10",
102
- "integrity": "sha512-9sRVd7MaUsUF5Uk0EDsRqIae492TDEGjOcH5IM+SxTY2NcQCiXVs4ck/N6kRuV65x5LzVcrGLBfyx/Zi+2229w==",
101
+ "version": "0.1.0-rc.11",
102
+ "integrity": "sha512-9vS5wRiX4Rk255T51WWfFDNB3SjVsJx2DNikaZr3yUVnzowHRH+SQ90OHdh7GK4RuFzVZxNaafPaGMgJZ++mLw==",
103
103
  "required": false
104
104
  },
105
105
  {
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Deployment administration: the setup wizard, the platform-level audit log and the admin overview
3
- * with its health read, seven-day usage aggregate and dead outbox rows (its controllers are the api
2
+ * Deployment administration: the setup wizard, the audit log reader (the platform's and each
3
+ * org's) and the admin overview with its health read, seven-day usage aggregate and dead outbox
4
+ * rows, and the super admin's side of the org network allowances (its controllers are the api
4
5
  * role's, `ApiModule`).
5
6
  */
6
7
  export declare class AdminModule {
@@ -18,16 +18,18 @@ import { OrgsModule } from "../orgs/orgs.module.js";
18
18
  import { ProvidersModule } from "../runtime/providers.js";
19
19
  import { RunJobsModule } from "../runtime/run-jobs.js";
20
20
  import { UsageReportModule } from "../runtime/usage-report.js";
21
+ import { AuditLogService } from "./audit-log.service.js";
21
22
  import { AdminHealthService } from "./health.service.js";
23
+ import { OrgNetworkAdmin } from "./org-network.service.js";
22
24
  import { OutboxDeadService } from "./outbox-dead.service.js";
23
25
  import { AdminOverviewService } from "./overview.service.js";
24
- import { PlatformAuditService } from "./platform-audit.service.js";
25
26
  import { SetupService } from "./setup.service.js";
26
27
  import { SetupLockModule } from "./setup-lock.js";
27
28
  import { AdminUsageService } from "./usage.service.js";
28
29
  /**
29
- * Deployment administration: the setup wizard, the platform-level audit log and the admin overview
30
- * with its health read, seven-day usage aggregate and dead outbox rows (its controllers are the api
30
+ * Deployment administration: the setup wizard, the audit log reader (the platform's and each
31
+ * org's) and the admin overview with its health read, seven-day usage aggregate and dead outbox
32
+ * rows, and the super admin's side of the org network allowances (its controllers are the api
31
33
  * role's, `ApiModule`).
32
34
  */
33
35
  let AdminModule = class AdminModule {
@@ -55,19 +57,21 @@ AdminModule = __decorate([
55
57
  ],
56
58
  providers: [
57
59
  SetupService,
58
- PlatformAuditService,
60
+ AuditLogService,
59
61
  AdminOverviewService,
60
62
  AdminHealthService,
61
63
  AdminUsageService,
62
64
  OutboxDeadService,
65
+ OrgNetworkAdmin,
63
66
  ],
64
67
  exports: [
65
68
  SetupService,
66
- PlatformAuditService,
69
+ AuditLogService,
67
70
  AdminOverviewService,
68
71
  AdminHealthService,
69
72
  AdminUsageService,
70
73
  OutboxDeadService,
74
+ OrgNetworkAdmin,
71
75
  ],
72
76
  })
73
77
  ], AdminModule);
@@ -0,0 +1,51 @@
1
+ import { KernelDb } from "../infra/database/kernel-db.js";
2
+ /**
3
+ * One audit event (admin overview spec §5.2, §9): who, what, on what and when, and two flags.
4
+ * Never the event's `detail` (it may carry config field names, ids or values); a deleted actor
5
+ * account reads as its id with a null name and email; `actor` is null for the kernel itself.
6
+ */
7
+ export interface AuditEvent {
8
+ /** The event id (a bigserial, as a decimal string); also the keyset cursor. */
9
+ id: string;
10
+ at: string;
11
+ actor: {
12
+ id: string;
13
+ name: string | null;
14
+ email: string | null;
15
+ } | null;
16
+ /** Done with a personal access token. */
17
+ viaToken: boolean;
18
+ /** Done through the Platform tool by the actor's own agent (`detail.via === "agent"`). */
19
+ viaAgent: boolean;
20
+ /** The action. */
21
+ action: string;
22
+ target: string | null;
23
+ }
24
+ /** A page of {@link AuditEvent}s; `next` is the `after` of the next page, null at the end. */
25
+ export interface AuditPage {
26
+ events: AuditEvent[];
27
+ next: string | null;
28
+ }
29
+ /** Whose events: the platform's (`org_id IS NULL`, decision D3) or one org's. */
30
+ export type AuditScope = {
31
+ platform: true;
32
+ } | {
33
+ orgId: string;
34
+ };
35
+ export interface AuditListQuery {
36
+ after?: string | undefined;
37
+ limit: number;
38
+ /** Only actions starting with this prefix. */
39
+ action?: string | undefined;
40
+ }
41
+ /**
42
+ * Reads the audit log of one scope: the platform's (the admin console's Audit log) or one org's (the
43
+ * org settings' Audit log, and the super admin's view of an org), newest first by id, keyset paged
44
+ * (`audit_events_platform_idx` / `audit_events_org_id_idx`). Read-only and not audited (D5).
45
+ */
46
+ export declare class AuditLogService {
47
+ private readonly kdb;
48
+ constructor(kdb: KernelDb);
49
+ /** `limit` events with an id below `after` (from the newest without it); one extra row tells `next`. */
50
+ list(scope: AuditScope, q: AuditListQuery): Promise<AuditPage>;
51
+ }
@@ -9,19 +9,21 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { sql } from "kysely";
12
- import { LEGACY_AUDIT_ACTIONS } from "../identity/audit.js";
13
12
  import { KernelDb } from "../infra/database/kernel-db.js";
13
+ /** `prefix` as a LIKE pattern matching the strings that start with it. */
14
+ const likePrefix = (prefix) => `${prefix.replace(/[\\%_]/g, "\\$&")}%`;
14
15
  /**
15
- * Reads the platform-level audit log: events with no org (`org_id IS NULL`, decision D3), newest
16
- * first by id, keyset paged (`audit_events_platform_idx`). Read-only and not audited (D5).
16
+ * Reads the audit log of one scope: the platform's (the admin console's Audit log) or one org's (the
17
+ * org settings' Audit log, and the super admin's view of an org), newest first by id, keyset paged
18
+ * (`audit_events_platform_idx` / `audit_events_org_id_idx`). Read-only and not audited (D5).
17
19
  */
18
- let PlatformAuditService = class PlatformAuditService {
20
+ let AuditLogService = class AuditLogService {
19
21
  kdb;
20
22
  constructor(kdb) {
21
23
  this.kdb = kdb;
22
24
  }
23
25
  /** `limit` events with an id below `after` (from the newest without it); one extra row tells `next`. */
24
- async list(q) {
26
+ async list(scope, q) {
25
27
  let query = this.kdb.db
26
28
  .selectFrom("audit_events as a")
27
29
  .leftJoin("accounts as ac", "ac.id", "a.actor_account_id")
@@ -34,12 +36,18 @@ let PlatformAuditService = class PlatformAuditService {
34
36
  "a.target",
35
37
  "ac.display_name",
36
38
  "ac.email",
37
- // only the one flag the overview shows, never the whole detail (spec §9)
39
+ // only the one flag the log shows, never the whole detail (spec §9)
38
40
  sql `a.detail->>'via'`.as("via"),
39
- ])
40
- .where("a.org_id", "is", null);
41
+ ]);
42
+ query =
43
+ "orgId" in scope
44
+ ? query.where("a.org_id", "=", scope.orgId)
45
+ : query.where("a.org_id", "is", null);
41
46
  if (q.after !== undefined)
42
47
  query = query.where("a.id", "<", q.after);
48
+ if (q.action !== undefined) {
49
+ query = query.where("a.action", "like", likePrefix(q.action));
50
+ }
43
51
  const rows = await query
44
52
  .orderBy("a.id", "desc")
45
53
  .limit(q.limit + 1)
@@ -56,15 +64,15 @@ let PlatformAuditService = class PlatformAuditService {
56
64
  },
57
65
  viaToken: r.actor_token_id !== null,
58
66
  viaAgent: r.via === "agent",
59
- action: LEGACY_AUDIT_ACTIONS[r.action] ?? r.action,
67
+ action: r.action,
60
68
  target: r.target,
61
69
  }));
62
70
  const next = rows.length > q.limit ? (events.at(-1)?.id ?? null) : null;
63
71
  return { events, next };
64
72
  }
65
73
  };
66
- PlatformAuditService = __decorate([
74
+ AuditLogService = __decorate([
67
75
  Injectable(),
68
76
  __param(0, Inject(KernelDb))
69
- ], PlatformAuditService);
70
- export { PlatformAuditService };
77
+ ], AuditLogService);
78
+ export { AuditLogService };
@@ -1,14 +1,26 @@
1
1
  import type { z } from "zod";
2
- import { AuditListQuery } from "./audit.schemas.js";
3
- import { type PlatformAuditPage, PlatformAuditService } from "./platform-audit.service.js";
2
+ import { type OrgContext } from "../orgs/org.guard.js";
3
+ import { AuditListQuery, OrgAuditListQuery } from "./audit.schemas.js";
4
+ import { AuditLogService, type AuditPage } from "./audit-log.service.js";
4
5
  /**
5
6
  * The platform-level audit log (`GET /api/v1/admin/audit`, admin overview spec §5.2, decision D2):
6
- * events with no org, newest first, keyset paged; never an event's `detail`. Super admins only;
7
- * the read itself is not audited (D5).
7
+ * events with no org, or with `orgId` that org's, newest first, keyset paged; never an event's
8
+ * `detail`. Super admins only; the read itself is not audited (D5).
8
9
  */
9
10
  export declare class AdminAuditController {
10
11
  private readonly audit;
11
- constructor(audit: PlatformAuditService);
12
+ constructor(audit: AuditLogService);
12
13
  /** `next` is the `after` of the next page, null at the end. */
13
- list(q: z.infer<typeof AuditListQuery>): Promise<PlatformAuditPage>;
14
+ list(q: z.infer<typeof AuditListQuery>): Promise<AuditPage>;
15
+ }
16
+ /**
17
+ * The org's audit log (`GET /api/v1/orgs/:orgId/audit`): the org's own events, newest first,
18
+ * keyset paged, the same rows as the platform log (never `detail`). Org admins (`org.update`, a
19
+ * person: service tokens are refused); a non-member gets 404. The read is not audited.
20
+ */
21
+ export declare class OrgAuditController {
22
+ private readonly audit;
23
+ constructor(audit: AuditLogService);
24
+ /** `next` is the `after` of the next page, null at the end. */
25
+ list(org: OrgContext, q: z.infer<typeof OrgAuditListQuery>): Promise<AuditPage>;
14
26
  }
@@ -11,14 +11,17 @@ import { Controller, Get, Inject } from "@nestjs/common";
11
11
  import { SuperAdmin } from "../identity/principal.js";
12
12
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
13
13
  import { ZQuery } from "../infra/validation/zod-params.js";
14
- import { AuditListQuery } from "./audit.schemas.js";
15
- import { PlatformAuditService } from "./platform-audit.service.js";
14
+ import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
15
+ import { AuditListQuery, OrgAuditListQuery } from "./audit.schemas.js";
16
+ import { AuditLogService } from "./audit-log.service.js";
16
17
  class AuditListQueryDto extends createZodDto(AuditListQuery, "AuditListQuery") {
17
18
  }
19
+ class OrgAuditListQueryDto extends createZodDto(OrgAuditListQuery, "OrgAuditListQuery") {
20
+ }
18
21
  /**
19
22
  * The platform-level audit log (`GET /api/v1/admin/audit`, admin overview spec §5.2, decision D2):
20
- * events with no org, newest first, keyset paged; never an event's `detail`. Super admins only;
21
- * the read itself is not audited (D5).
23
+ * events with no org, or with `orgId` that org's, newest first, keyset paged; never an event's
24
+ * `detail`. Super admins only; the read itself is not audited (D5).
22
25
  */
23
26
  let AdminAuditController = class AdminAuditController {
24
27
  audit;
@@ -27,7 +30,8 @@ let AdminAuditController = class AdminAuditController {
27
30
  }
28
31
  /** `next` is the `after` of the next page, null at the end. */
29
32
  list(q) {
30
- return this.audit.list(q);
33
+ const { orgId, ...page } = q;
34
+ return this.audit.list(orgId === undefined ? { platform: true } : { orgId }, page);
31
35
  }
32
36
  };
33
37
  __decorate([
@@ -37,6 +41,32 @@ __decorate([
37
41
  AdminAuditController = __decorate([
38
42
  Controller("api/v1/admin/audit"),
39
43
  SuperAdmin(),
40
- __param(0, Inject(PlatformAuditService))
44
+ __param(0, Inject(AuditLogService))
41
45
  ], AdminAuditController);
42
46
  export { AdminAuditController };
47
+ /**
48
+ * The org's audit log (`GET /api/v1/orgs/:orgId/audit`): the org's own events, newest first,
49
+ * keyset paged, the same rows as the platform log (never `detail`). Org admins (`org.update`, a
50
+ * person: service tokens are refused); a non-member gets 404. The read is not audited.
51
+ */
52
+ let OrgAuditController = class OrgAuditController {
53
+ audit;
54
+ constructor(audit) {
55
+ this.audit = audit;
56
+ }
57
+ /** `next` is the `after` of the next page, null at the end. */
58
+ list(org, q) {
59
+ return this.audit.list({ orgId: org.orgId }, q);
60
+ }
61
+ };
62
+ __decorate([
63
+ Get(),
64
+ OrgAction("org.update"),
65
+ __param(0, CurrentOrg()),
66
+ __param(1, ZQuery(OrgAuditListQueryDto))
67
+ ], OrgAuditController.prototype, "list", null);
68
+ OrgAuditController = __decorate([
69
+ Controller("api/v1/orgs/:orgId/audit"),
70
+ __param(0, Inject(AuditLogService))
71
+ ], OrgAuditController);
72
+ export { OrgAuditController };
@@ -1,8 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import type { RouteSchemas } from "../platform/route-schemas.js";
3
- /** `GET /api/v1/admin/audit`: keyset paging by event id, newest first (admin overview spec §5.2). */
3
+ /** `GET /api/v1/admin/audit`: the platform's events, or with `orgId` that org's. */
4
4
  export declare const AuditListQuery: z.ZodObject<{
5
5
  after: z.ZodOptional<z.ZodString>;
6
6
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
7
+ action: z.ZodOptional<z.ZodString>;
8
+ orgId: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ /** `GET /api/v1/orgs/:orgId/audit`: the org's own events (org admins). */
11
+ export declare const OrgAuditListQuery: z.ZodObject<{
12
+ after: z.ZodOptional<z.ZodString>;
13
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
14
+ action: z.ZodOptional<z.ZodString>;
7
15
  }, z.core.$strip>;
8
16
  export declare const AUDIT_ROUTES: readonly RouteSchemas[];
@@ -1,8 +1,11 @@
1
1
  import { z } from "zod";
2
2
  /** The largest `bigserial` id; a larger `after` would make PG refuse the comparison. */
3
3
  const MAX_BIGINT = 9223372036854775807n;
4
- /** `GET /api/v1/admin/audit`: keyset paging by event id, newest first (admin overview spec §5.2). */
5
- export const AuditListQuery = z.object({
4
+ /**
5
+ * A page of an audit log: keyset paging by event id, newest first (admin overview spec §5.2), and
6
+ * an optional action prefix.
7
+ */
8
+ const AuditPageQuery = z.object({
6
9
  after: z
7
10
  .string()
8
11
  .regex(/^\d{1,19}$/, "after must be an event id (digits)")
@@ -11,7 +14,24 @@ export const AuditListQuery = z.object({
11
14
  .optional()
12
15
  .describe("The id of the last event of the previous page (its next); absent: the newest."),
13
16
  limit: z.coerce.number().int().min(1).max(100).default(20),
17
+ action: z
18
+ .string()
19
+ .regex(/^[a-z][a-z0-9_.]{0,63}$/, "action must be an action name or its prefix (a-z 0-9 _ .)")
20
+ .optional()
21
+ .describe("Only actions starting with this, e.g. connector. or org.member.added."),
22
+ });
23
+ /** `GET /api/v1/admin/audit`: the platform's events, or with `orgId` that org's. */
24
+ export const AuditListQuery = AuditPageQuery.extend({
25
+ orgId: z
26
+ .string()
27
+ .min(1)
28
+ .max(100)
29
+ .optional()
30
+ .describe("Read this org's events instead of the platform's."),
14
31
  });
32
+ /** `GET /api/v1/orgs/:orgId/audit`: the org's own events (org admins). */
33
+ export const OrgAuditListQuery = AuditPageQuery;
15
34
  export const AUDIT_ROUTES = [
16
35
  { route: "GET /api/v1/admin/audit", query: AuditListQuery },
36
+ { route: "GET /api/v1/orgs/:orgId/audit", query: OrgAuditListQuery },
17
37
  ];
@@ -0,0 +1,30 @@
1
+ import type { z } from "zod";
2
+ import { type Principal } from "../identity/principal.js";
3
+ import { type NetworkAllowanceView } from "../orgs/orgs.schemas.js";
4
+ import { AdminOrgParams } from "./admin.schemas.js";
5
+ import { NetworkAllowanceBody, NetworkAllowanceParams } from "./org-network.schemas.js";
6
+ import { OrgNetworkAdmin } from "./org-network.service.js";
7
+ /**
8
+ * An org's network allowances (`/api/v1/admin/orgs/:orgId/network-allowances`, plugin safe fetch
9
+ * spec): the internal endpoints the org's extension requests may reach although they resolve to
10
+ * private or loopback addresses. Super admins only (service tokens 403); adding and removing are
11
+ * audited `org.network_allowance_added` / `org.network_allowance_removed`. Org admins read their
12
+ * org's list at `GET /api/v1/orgs/:orgId/network-allowances`.
13
+ */
14
+ export declare class AdminOrgNetworkController {
15
+ private readonly admin;
16
+ constructor(admin: OrgNetworkAdmin);
17
+ /** The org's entries, oldest first; a missing or deleted org → `org.not_found`. */
18
+ list({ orgId }: z.infer<typeof AdminOrgParams>): Promise<{
19
+ allowances: NetworkAllowanceView[];
20
+ }>;
21
+ /**
22
+ * Adds an entry; an invalid one → 400 `org.network_allowance_invalid` with the reason. Only a
23
+ * person widens: a personal access token → 400 `org.network_allowance_widen_not_allowed`.
24
+ */
25
+ add(principal: Principal, { orgId }: z.infer<typeof AdminOrgParams>, body: z.infer<typeof NetworkAllowanceBody>): Promise<{
26
+ allowance: NetworkAllowanceView;
27
+ }>;
28
+ /** Removes an entry; an id the org does not list → 404 `org.network_allowance_not_found`. */
29
+ remove(principal: Principal, { orgId, id }: z.infer<typeof AdminOrgParams> & z.infer<typeof NetworkAllowanceParams>): Promise<void>;
30
+ }
@@ -0,0 +1,77 @@
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 { Controller, Delete, Get, HttpCode, Inject, Post } from "@nestjs/common";
11
+ import { CurrentPrincipal, SuperAdmin } from "../identity/principal.js";
12
+ import { writeActorOf } from "../identity/write-actor.js";
13
+ import { createZodDto } from "../infra/validation/create-zod-dto.js";
14
+ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
15
+ import { networkAllowanceView } from "../orgs/orgs.schemas.js";
16
+ import { AdminOrgParams } from "./admin.schemas.js";
17
+ import { NetworkAllowanceBody, NetworkAllowanceParams } from "./org-network.schemas.js";
18
+ import { OrgNetworkAdmin } from "./org-network.service.js";
19
+ class AdminOrgNetworkParamsDto extends createZodDto(AdminOrgParams, "AdminOrgNetworkParams") {
20
+ }
21
+ class NetworkAllowanceItemParamsDto extends createZodDto(AdminOrgParams.extend(NetworkAllowanceParams.shape), "NetworkAllowanceItemParams") {
22
+ }
23
+ class NetworkAllowanceBodyDto extends createZodDto(NetworkAllowanceBody, "NetworkAllowanceBody") {
24
+ }
25
+ /**
26
+ * An org's network allowances (`/api/v1/admin/orgs/:orgId/network-allowances`, plugin safe fetch
27
+ * spec): the internal endpoints the org's extension requests may reach although they resolve to
28
+ * private or loopback addresses. Super admins only (service tokens 403); adding and removing are
29
+ * audited `org.network_allowance_added` / `org.network_allowance_removed`. Org admins read their
30
+ * org's list at `GET /api/v1/orgs/:orgId/network-allowances`.
31
+ */
32
+ let AdminOrgNetworkController = class AdminOrgNetworkController {
33
+ admin;
34
+ constructor(admin) {
35
+ this.admin = admin;
36
+ }
37
+ /** The org's entries, oldest first; a missing or deleted org → `org.not_found`. */
38
+ async list({ orgId }) {
39
+ return { allowances: (await this.admin.list(orgId)).map(networkAllowanceView) };
40
+ }
41
+ /**
42
+ * Adds an entry; an invalid one → 400 `org.network_allowance_invalid` with the reason. Only a
43
+ * person widens: a personal access token → 400 `org.network_allowance_widen_not_allowed`.
44
+ */
45
+ async add(principal, { orgId }, body) {
46
+ const actor = writeActorOf(principal);
47
+ const allowance = await this.admin.add(orgId, body.entry, actor, actor.tokenId !== undefined);
48
+ return { allowance: networkAllowanceView(allowance) };
49
+ }
50
+ /** Removes an entry; an id the org does not list → 404 `org.network_allowance_not_found`. */
51
+ async remove(principal, { orgId, id }) {
52
+ await this.admin.remove(orgId, id, writeActorOf(principal));
53
+ }
54
+ };
55
+ __decorate([
56
+ Get(),
57
+ __param(0, ZParam(AdminOrgNetworkParamsDto))
58
+ ], AdminOrgNetworkController.prototype, "list", null);
59
+ __decorate([
60
+ Post(),
61
+ HttpCode(201),
62
+ __param(0, CurrentPrincipal()),
63
+ __param(1, ZParam(AdminOrgNetworkParamsDto)),
64
+ __param(2, ZBody(NetworkAllowanceBodyDto))
65
+ ], AdminOrgNetworkController.prototype, "add", null);
66
+ __decorate([
67
+ Delete(":id"),
68
+ HttpCode(204),
69
+ __param(0, CurrentPrincipal()),
70
+ __param(1, ZParam(NetworkAllowanceItemParamsDto))
71
+ ], AdminOrgNetworkController.prototype, "remove", null);
72
+ AdminOrgNetworkController = __decorate([
73
+ Controller("api/v1/admin/orgs/:orgId/network-allowances"),
74
+ SuperAdmin(),
75
+ __param(0, Inject(OrgNetworkAdmin))
76
+ ], AdminOrgNetworkController);
77
+ export { AdminOrgNetworkController };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { RouteSchemas } from "../platform/route-schemas.js";
3
+ /**
4
+ * `POST /api/v1/admin/orgs/:orgId/network-allowances`: one internal endpoint the org's extension
5
+ * requests may reach (plugin safe fetch spec). The service checks and normalizes the entry and
6
+ * refuses an invalid one with `org.network_allowance_invalid`.
7
+ */
8
+ export declare const NetworkAllowanceBody: z.ZodObject<{
9
+ entry: z.ZodString;
10
+ }, z.core.$strip>;
11
+ /** `DELETE /api/v1/admin/orgs/:orgId/network-allowances/:id`. */
12
+ export declare const NetworkAllowanceParams: z.ZodObject<{
13
+ id: z.ZodString;
14
+ }, z.core.$strip>;
15
+ /** The super admin's org network allowance routes (the org admins' read is in `ORG_ROUTES`). */
16
+ export declare const ORG_NETWORK_ROUTES: readonly RouteSchemas[];
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * `POST /api/v1/admin/orgs/:orgId/network-allowances`: one internal endpoint the org's extension
4
+ * requests may reach (plugin safe fetch spec). The service checks and normalizes the entry and
5
+ * refuses an invalid one with `org.network_allowance_invalid`.
6
+ */
7
+ export const NetworkAllowanceBody = z.object({
8
+ entry: z
9
+ .string()
10
+ .min(1)
11
+ .max(300)
12
+ .describe("A hostname or *.domain wildcard (https, any port), an IP address or CIDR (e.g. 10.1.0.0/16), or an origin such as http://mcp.internal:8080 (exactly that origin, plain http allowed)."),
13
+ });
14
+ /** `DELETE /api/v1/admin/orgs/:orgId/network-allowances/:id`. */
15
+ export const NetworkAllowanceParams = z.object({
16
+ id: z.string().min(1).max(100).describe("The allowance id (from the list)."),
17
+ });
18
+ /** The super admin's org network allowance routes (the org admins' read is in `ORG_ROUTES`). */
19
+ export const ORG_NETWORK_ROUTES = [
20
+ // `:orgId` is never compared: the admin operations name the org with an `orgId` extra
21
+ { route: "GET /api/v1/admin/orgs/:orgId/network-allowances" },
22
+ { route: "POST /api/v1/admin/orgs/:orgId/network-allowances", body: NetworkAllowanceBody },
23
+ {
24
+ route: "DELETE /api/v1/admin/orgs/:orgId/network-allowances/:id",
25
+ params: NetworkAllowanceParams,
26
+ },
27
+ ];
@@ -0,0 +1,41 @@
1
+ import { SuperAdminLock } from "../identity/super-admin.js";
2
+ import type { WriteActor } from "../identity/write-actor.js";
3
+ import { TransactionHost } from "../infra/database/transaction-host.js";
4
+ import { type OrgNetworkAllowance, OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
5
+ import { OrgsService } from "../orgs/orgs.service.js";
6
+ /**
7
+ * The super admin's side of the org network allowances (plugin safe fetch spec): the admin routes
8
+ * and their Platform operations call it. Writes take the super admin lock and re-check the actor
9
+ * in the same transaction as the store's write (`OrgNetworkAllowances` joins it).
10
+ *
11
+ * Only a person widens: an add is refused for an API token or the Platform tool (`onlyNarrows`)
12
+ * with `org.network_allowance_widen_not_allowed`; listing and removing stay open to both.
13
+ */
14
+ export declare class OrgNetworkAdmin {
15
+ private readonly allowances;
16
+ private readonly orgs;
17
+ private readonly adminLock;
18
+ readonly txHost: TransactionHost;
19
+ constructor(allowances: OrgNetworkAllowances, orgs: OrgsService, adminLock: SuperAdminLock, txHost: TransactionHost);
20
+ /** The org's entries, oldest first; a missing or deleted org is `org.not_found`. */
21
+ list(orgId: string): Promise<OrgNetworkAllowance[]>;
22
+ /**
23
+ * The read-only preconditions of {@link add}, throwing its own refusals: `onlyNarrows` →
24
+ * `org.network_allowance_widen_not_allowed`, a missing org → `org.not_found`, an invalid entry →
25
+ * `org.network_allowance_invalid` (the cap is checked by the write only).
26
+ */
27
+ checkAdd(orgId: string, entry: string, onlyNarrows: boolean): Promise<void>;
28
+ /**
29
+ * Adds an entry (audited `org.network_allowance_added`); an entry already listed is returned.
30
+ * `onlyNarrows` (an API token, the Platform tool) refuses it: only a person widens. The actor's
31
+ * token id and `auditDetail` go into the audit event.
32
+ */
33
+ add(orgId: string, entry: string, actor: WriteActor, onlyNarrows: boolean, auditDetail?: Record<string, unknown>): Promise<OrgNetworkAllowance>;
34
+ /**
35
+ * Removes the org's entry `id` (audited `org.network_allowance_removed`); a missing or deleted
36
+ * org is `org.not_found`, an id the org does not list `org.network_allowance_not_found`. The
37
+ * actor's token id and `auditDetail` go into the audit event.
38
+ */
39
+ remove(orgId: string, id: string, actor: WriteActor, auditDetail?: Record<string, unknown>): Promise<void>;
40
+ private assertOrg;
41
+ }