@jini-ai/core 0.7.2 → 0.7.3-next.1

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 (340) hide show
  1. package/CHANGELOG.md +0 -2
  2. package/README.md +40 -12
  3. package/dist/admin-runtime/admin-api-error.d.ts +68 -0
  4. package/dist/admin-runtime/admin-api-error.js +72 -0
  5. package/dist/admin-runtime/admin-config-error.d.ts +8 -0
  6. package/dist/admin-runtime/admin-config-error.js +11 -0
  7. package/dist/admin-runtime/controller-store.d.ts +20 -0
  8. package/dist/admin-runtime/controller-store.js +32 -0
  9. package/dist/admin-runtime/index.d.ts +13 -0
  10. package/dist/admin-runtime/index.js +12 -0
  11. package/dist/admin-runtime/panel-access.d.ts +88 -0
  12. package/dist/admin-runtime/panel-access.js +76 -0
  13. package/dist/admin-runtime/query-suffix.d.ts +5 -0
  14. package/dist/admin-runtime/query-suffix.js +5 -0
  15. package/dist/agent-handles/element-handles.d.ts +134 -0
  16. package/dist/agent-handles/element-handles.js +45 -0
  17. package/dist/agent-handles/field-descriptor.d.ts +28 -0
  18. package/dist/agent-handles/field-descriptor.js +3 -0
  19. package/dist/agent-handles/handle.d.ts +109 -0
  20. package/dist/agent-handles/handle.js +109 -0
  21. package/dist/agent-handles/index.d.ts +9 -0
  22. package/dist/agent-handles/index.js +6 -0
  23. package/dist/agent-handles/list-handles.d.ts +46 -0
  24. package/dist/agent-handles/list-handles.js +67 -0
  25. package/dist/agent-handles/secret-attrs.d.ts +14 -0
  26. package/dist/agent-handles/secret-attrs.js +13 -0
  27. package/dist/approval-batch-chain.d.ts +45 -0
  28. package/dist/approval-batch-chain.js +75 -0
  29. package/dist/approval.d.ts +33 -14
  30. package/dist/approval.js +57 -43
  31. package/dist/batch-tool-inputs.js +24 -20
  32. package/dist/contracts/admin-module.d.ts +166 -0
  33. package/dist/contracts/admin-module.js +14 -0
  34. package/dist/contracts/agents/definition.d.ts +459 -0
  35. package/dist/contracts/agents/definition.js +2 -0
  36. package/dist/contracts/agents/index.d.ts +7 -0
  37. package/dist/contracts/agents/index.js +2 -0
  38. package/dist/contracts/agents/launch.d.ts +64 -0
  39. package/dist/contracts/agents/launch.js +2 -0
  40. package/dist/contracts/agents/model-catalog.d.ts +213 -0
  41. package/dist/contracts/agents/model-catalog.js +4 -0
  42. package/dist/contracts/agents/native-tool-policy.d.ts +42 -0
  43. package/dist/contracts/agents/native-tool-policy.js +2 -0
  44. package/dist/contracts/ai-trace/capture.d.ts +17 -0
  45. package/dist/contracts/ai-trace/capture.js +43 -0
  46. package/dist/contracts/ai-trace/classify.d.ts +12 -0
  47. package/dist/contracts/ai-trace/classify.js +16 -0
  48. package/dist/contracts/ai-trace/index.d.ts +13 -0
  49. package/dist/contracts/ai-trace/index.js +6 -0
  50. package/dist/contracts/ai-trace/recorder.d.ts +64 -0
  51. package/dist/contracts/ai-trace/recorder.js +283 -0
  52. package/dist/contracts/ai-trace/sinks.d.ts +51 -0
  53. package/dist/contracts/ai-trace/sinks.js +153 -0
  54. package/dist/contracts/ai-trace/types.d.ts +123 -0
  55. package/dist/contracts/ai-trace/types.js +17 -0
  56. package/dist/contracts/ai-trace/usage.d.ts +16 -0
  57. package/dist/contracts/ai-trace/usage.js +45 -0
  58. package/dist/contracts/blob.d.ts +31 -0
  59. package/dist/contracts/blob.js +10 -0
  60. package/dist/contracts/capabilities.d.ts +95 -0
  61. package/dist/contracts/capabilities.js +111 -0
  62. package/dist/contracts/charts.d.ts +75 -0
  63. package/dist/contracts/charts.js +4 -0
  64. package/dist/contracts/env.d.ts +96 -0
  65. package/dist/contracts/env.js +6 -0
  66. package/dist/contracts/events/change-set.d.ts +106 -0
  67. package/dist/contracts/events/change-set.js +2 -0
  68. package/dist/contracts/events/command.d.ts +118 -0
  69. package/dist/contracts/events/command.js +2 -0
  70. package/dist/contracts/events/ports.d.ts +172 -0
  71. package/dist/contracts/events/ports.js +2 -0
  72. package/dist/contracts/events.d.ts +5 -0
  73. package/dist/contracts/events.js +2 -0
  74. package/dist/contracts/forms.d.ts +110 -0
  75. package/dist/contracts/forms.js +4 -0
  76. package/dist/contracts/hosted-mcp/config.d.ts +19 -0
  77. package/dist/contracts/hosted-mcp/record.d.ts +61 -4
  78. package/dist/contracts/mail/email-sender.d.ts +118 -0
  79. package/dist/contracts/mail/email-sender.js +20 -0
  80. package/dist/contracts/mail/smtp-payload.d.ts +32 -0
  81. package/dist/contracts/mail/smtp-payload.js +2 -0
  82. package/dist/contracts/mail.d.ts +2 -0
  83. package/dist/contracts/mail.js +1 -1
  84. package/dist/contracts/observability.d.ts +232 -0
  85. package/dist/contracts/observability.js +27 -0
  86. package/dist/contracts/plugin-sdk.d.ts +186 -0
  87. package/dist/contracts/plugin-sdk.js +39 -0
  88. package/dist/contracts/runtime/command.d.ts +41 -0
  89. package/dist/contracts/runtime/command.js +60 -0
  90. package/dist/contracts/runtime/environment.d.ts +18 -0
  91. package/dist/contracts/runtime/environment.js +26 -0
  92. package/dist/contracts/runtime/file-lock.d.ts +94 -0
  93. package/dist/contracts/runtime/file-lock.js +25 -0
  94. package/dist/contracts/runtime/fs.d.ts +33 -0
  95. package/dist/contracts/runtime/fs.js +2 -0
  96. package/dist/contracts/runtime/http.d.ts +89 -0
  97. package/dist/contracts/runtime/http.js +2 -0
  98. package/dist/contracts/runtime/platform.d.ts +3 -0
  99. package/dist/contracts/runtime/platform.js +2 -0
  100. package/dist/contracts/runtime/process.d.ts +40 -0
  101. package/dist/contracts/runtime/process.js +31 -0
  102. package/dist/contracts/runtime/reader.d.ts +11 -0
  103. package/dist/contracts/runtime/reader.js +2 -0
  104. package/dist/contracts/runtime/terminal.d.ts +99 -0
  105. package/dist/contracts/runtime/terminal.js +2 -0
  106. package/dist/contracts/runtime/testing.d.ts +84 -0
  107. package/dist/contracts/runtime/testing.js +116 -0
  108. package/dist/contracts/runtime.d.ts +10 -0
  109. package/dist/contracts/runtime.js +10 -0
  110. package/dist/contracts/server/api-error.d.ts +43 -0
  111. package/dist/contracts/server/api-error.js +49 -0
  112. package/dist/contracts/server/auth.d.ts +20 -0
  113. package/dist/contracts/server/auth.js +21 -0
  114. package/dist/contracts/server/conformance.d.ts +25 -0
  115. package/dist/contracts/server/conformance.js +50 -0
  116. package/dist/contracts/server/json-route.d.ts +176 -0
  117. package/dist/contracts/server/json-route.js +155 -0
  118. package/dist/contracts/server/middleware.d.ts +35 -0
  119. package/dist/contracts/server/middleware.js +56 -0
  120. package/dist/contracts/server/origin.d.ts +44 -0
  121. package/dist/contracts/server/origin.js +32 -0
  122. package/dist/contracts/server/query.d.ts +16 -0
  123. package/dist/contracts/server/query.js +69 -0
  124. package/dist/contracts/server/rate-limit.d.ts +20 -0
  125. package/dist/contracts/server/rate-limit.js +8 -0
  126. package/dist/contracts/server/request-body.d.ts +26 -0
  127. package/dist/contracts/server/request-body.js +82 -0
  128. package/dist/contracts/server/result.d.ts +17 -0
  129. package/dist/contracts/server/result.js +5 -0
  130. package/dist/contracts/server/route-table.d.ts +54 -0
  131. package/dist/contracts/server/route-table.js +119 -0
  132. package/dist/contracts/server/same-origin-write.d.ts +18 -0
  133. package/dist/contracts/server/same-origin-write.js +31 -0
  134. package/dist/contracts/server/security-headers.d.ts +30 -0
  135. package/dist/contracts/server/security-headers.js +35 -0
  136. package/dist/contracts/server/sse.d.ts +82 -0
  137. package/dist/contracts/server/sse.js +103 -0
  138. package/dist/contracts/server/testing.d.ts +59 -0
  139. package/dist/contracts/server/testing.js +68 -0
  140. package/dist/contracts/server/verified-origin/configured-origin.d.ts +37 -0
  141. package/dist/contracts/server/verified-origin/configured-origin.js +103 -0
  142. package/dist/contracts/server/verified-origin/index.d.ts +7 -0
  143. package/dist/contracts/server/verified-origin/index.js +6 -0
  144. package/dist/contracts/server/verified-origin/loopback-host.d.ts +9 -0
  145. package/dist/contracts/server/verified-origin/loopback-host.js +17 -0
  146. package/dist/contracts/server/verified-origin/origin.d.ts +64 -0
  147. package/dist/contracts/server/verified-origin/origin.js +162 -0
  148. package/dist/contracts/server/verified-origin/ports.d.ts +38 -0
  149. package/dist/contracts/server/verified-origin/ports.js +2 -0
  150. package/dist/contracts/server/verified-origin/repo.memory.d.ts +32 -0
  151. package/dist/contracts/server/verified-origin/repo.memory.js +34 -0
  152. package/dist/contracts/server/verified-origin/site-path.d.ts +113 -0
  153. package/dist/contracts/server/verified-origin/site-path.js +188 -0
  154. package/dist/contracts/server/verified-origin/types.d.ts +33 -0
  155. package/dist/contracts/server/verified-origin/types.js +30 -0
  156. package/dist/contracts/server.d.ts +46 -2
  157. package/dist/contracts/server.js +17 -3
  158. package/dist/contracts/storage/kernel.d.ts +86 -0
  159. package/dist/contracts/storage/kernel.js +38 -0
  160. package/dist/contracts/storage/migration.d.ts +32 -0
  161. package/dist/contracts/storage/migration.js +2 -0
  162. package/dist/contracts/storage/rows.d.ts +33 -0
  163. package/dist/contracts/storage/rows.js +42 -0
  164. package/dist/contracts/storage/sqlite.d.ts +113 -0
  165. package/dist/contracts/storage/sqlite.js +8 -0
  166. package/dist/contracts/storage/values.d.ts +25 -0
  167. package/dist/contracts/storage/values.js +25 -0
  168. package/dist/contracts/storage.d.ts +8 -0
  169. package/dist/contracts/storage.js +6 -0
  170. package/dist/contracts/vault/invariants.d.ts +26 -0
  171. package/dist/contracts/vault/invariants.js +49 -0
  172. package/dist/contracts/vault.d.ts +1 -0
  173. package/dist/contracts/vault.js +1 -1
  174. package/dist/env/coercers.d.ts +21 -0
  175. package/dist/env/coercers.js +68 -0
  176. package/dist/env/describe-env-for-diagnostics.d.ts +16 -0
  177. package/dist/env/describe-env-for-diagnostics.js +23 -0
  178. package/dist/env/format-env-issue.d.ts +13 -0
  179. package/dist/env/format-env-issue.js +22 -0
  180. package/dist/env/parse-env.d.ts +24 -0
  181. package/dist/env/parse-env.js +102 -0
  182. package/dist/env/value-echo.d.ts +17 -0
  183. package/dist/env/value-echo.js +42 -0
  184. package/dist/errors/approved-cause.d.ts +36 -0
  185. package/dist/errors/approved-cause.js +17 -0
  186. package/dist/errors/bindings.d.ts +61 -0
  187. package/dist/errors/bindings.js +57 -0
  188. package/dist/errors/catalog.d.ts +84 -0
  189. package/dist/errors/catalog.js +151 -0
  190. package/dist/errors/disclosure.d.ts +48 -0
  191. package/dist/errors/disclosure.js +27 -0
  192. package/dist/errors/error-id.d.ts +26 -0
  193. package/dist/errors/error-id.js +23 -0
  194. package/dist/errors/idioms.d.ts +73 -0
  195. package/dist/errors/idioms.js +85 -0
  196. package/dist/errors/incident-text.d.ts +16 -0
  197. package/dist/errors/incident-text.js +77 -0
  198. package/dist/errors/reporter.d.ts +94 -0
  199. package/dist/errors/reporter.js +152 -0
  200. package/dist/errors/sentences.d.ts +68 -0
  201. package/dist/errors/sentences.js +93 -0
  202. package/dist/errors/testing.d.ts +50 -0
  203. package/dist/errors/testing.js +44 -0
  204. package/dist/fetch/cache.d.ts +12 -5
  205. package/dist/fetch/cache.js +46 -47
  206. package/dist/fetch/index.d.ts +1 -1
  207. package/dist/fetch/loader-read.d.ts +6 -2
  208. package/dist/fetch/loader-read.js +4 -4
  209. package/dist/format-error-for-log.d.ts +15 -0
  210. package/dist/format-error-for-log.js +55 -0
  211. package/dist/host-read-vocabulary.d.ts +47 -0
  212. package/dist/host-read-vocabulary.js +44 -0
  213. package/dist/index.d.ts +5 -1
  214. package/dist/index.js +4 -0
  215. package/dist/list-page.d.ts +93 -0
  216. package/dist/list-page.js +154 -0
  217. package/dist/model-facing-tool-errors.d.ts +67 -5
  218. package/dist/model-facing-tool-errors.js +155 -19
  219. package/dist/net/endpoint-policy.d.ts +39 -0
  220. package/dist/net/endpoint-policy.js +218 -0
  221. package/dist/net/fetch-timeouts.d.ts +38 -0
  222. package/dist/net/fetch-timeouts.js +31 -0
  223. package/dist/net/index.d.ts +4 -0
  224. package/dist/net/index.js +4 -0
  225. package/dist/net/loopback.d.ts +13 -0
  226. package/dist/net/loopback.js +39 -0
  227. package/dist/optimistic-concurrency.d.ts +183 -0
  228. package/dist/optimistic-concurrency.js +222 -0
  229. package/dist/primitives/errors.d.ts +9 -0
  230. package/dist/primitives/errors.js +12 -0
  231. package/dist/primitives/ids.d.ts +0 -2
  232. package/dist/primitives/ids.js +1 -4
  233. package/dist/primitives/index.d.ts +3 -0
  234. package/dist/primitives/index.js +2 -0
  235. package/dist/primitives/logger.d.ts +36 -1
  236. package/dist/primitives/logger.js +125 -9
  237. package/dist/primitives/node-shape.d.ts +24 -0
  238. package/dist/primitives/node-shape.js +21 -0
  239. package/dist/primitives/time.d.ts +9 -2
  240. package/dist/primitives/time.js +4 -3
  241. package/dist/provider-registry.js +26 -20
  242. package/dist/records.d.ts +40 -7
  243. package/dist/records.js +37 -3
  244. package/dist/redact.d.ts +1 -84
  245. package/dist/redact.js +2 -826
  246. package/dist/redaction-collectors.d.ts +7 -0
  247. package/dist/redaction-collectors.js +152 -0
  248. package/dist/redaction-exact-secrets.d.ts +14 -0
  249. package/dist/redaction-exact-secrets.js +115 -0
  250. package/dist/redaction-labels.d.ts +14 -0
  251. package/dist/redaction-labels.js +156 -0
  252. package/dist/redaction-patterns.d.ts +54 -0
  253. package/dist/redaction-patterns.js +178 -0
  254. package/dist/redaction-spans.d.ts +31 -0
  255. package/dist/redaction-spans.js +83 -0
  256. package/dist/registration-kit.d.ts +1 -1
  257. package/dist/revision-conflict-error.d.ts +18 -0
  258. package/dist/revision-conflict-error.js +20 -0
  259. package/dist/secret-shapes.d.ts +50 -0
  260. package/dist/secret-shapes.js +105 -0
  261. package/dist/settings/agent-tools.js +22 -8
  262. package/dist/settings/agent-value-write-tools.d.ts +4 -1
  263. package/dist/settings/agent-value-write-tools.js +7 -6
  264. package/dist/settings/agent-writable-preferences.d.ts +3 -1
  265. package/dist/settings/agent-writable-preferences.js +1 -1
  266. package/dist/settings/agent-write-denylist.d.ts +7 -4
  267. package/dist/settings/agent-write-denylist.js +1 -1
  268. package/dist/settings/{express/cms-adapter.d.ts → cms-adapter.d.ts} +3 -2
  269. package/dist/settings/{express/cms-adapter.js → cms-adapter.js} +21 -11
  270. package/dist/settings/definitions-dispatch.js +3 -1
  271. package/dist/settings/ensure-definitions.js +3 -1
  272. package/dist/settings/errors.d.ts +1 -13
  273. package/dist/settings/errors.js +2 -15
  274. package/dist/settings/index.d.ts +11 -2
  275. package/dist/settings/index.js +10 -2
  276. package/dist/settings/purge-service.js +63 -86
  277. package/dist/settings/{express/contracts.d.ts → route-policy.d.ts} +53 -47
  278. package/dist/settings/{express/shared.js → route-policy.js} +1 -16
  279. package/dist/settings/settings.d.ts +19 -11
  280. package/dist/settings/settings.js +9 -11
  281. package/dist/settings/tool-registrations.d.ts +3 -3
  282. package/dist/settings/tool-registrations.js +130 -125
  283. package/dist/settings/types.d.ts +1 -1
  284. package/dist/settings/write-definition-rename.d.ts +37 -0
  285. package/dist/settings/write-definition-rename.js +119 -0
  286. package/dist/settings/write-definition-retype.d.ts +61 -0
  287. package/dist/settings/write-definition-retype.js +109 -0
  288. package/dist/settings/write-definition-status.d.ts +81 -0
  289. package/dist/settings/write-definition-status.js +121 -0
  290. package/dist/settings/write-reset.d.ts +34 -0
  291. package/dist/settings/write-reset.js +73 -0
  292. package/dist/settings/write-service.d.ts +16 -287
  293. package/dist/settings/write-service.js +49 -681
  294. package/dist/settings/write-value-revisions.d.ts +68 -0
  295. package/dist/settings/write-value-revisions.js +124 -0
  296. package/dist/settings/write-values.d.ts +96 -0
  297. package/dist/settings/write-values.js +83 -0
  298. package/dist/surface-exchanges.d.ts +2 -2
  299. package/dist/text/dictionary-translator.d.ts +19 -0
  300. package/dist/text/dictionary-translator.js +14 -0
  301. package/dist/text/format-byte-size.d.ts +25 -0
  302. package/dist/text/format-byte-size.js +25 -0
  303. package/dist/text/format-timestamp.d.ts +22 -0
  304. package/dist/text/format-timestamp.js +57 -0
  305. package/dist/text/index.d.ts +12 -0
  306. package/dist/text/index.js +9 -0
  307. package/dist/text/is-abort-error.d.ts +5 -0
  308. package/dist/text/is-abort-error.js +5 -0
  309. package/dist/text/mime.d.ts +5 -0
  310. package/dist/text/mime.js +21 -0
  311. package/dist/text/redact-urls.d.ts +7 -0
  312. package/dist/text/redact-urls.js +5 -0
  313. package/dist/text/resolve-active-tab-id.d.ts +13 -0
  314. package/dist/text/resolve-active-tab-id.js +15 -0
  315. package/dist/text/sanitize-untrusted-text.d.ts +1 -1
  316. package/dist/text/sanitize-untrusted-text.js +2 -1
  317. package/dist/text/tagged-text-suppression.d.ts +103 -0
  318. package/dist/text/tagged-text-suppression.js +143 -0
  319. package/dist/text/template-i18n.d.ts +37 -0
  320. package/dist/text/template-i18n.js +48 -0
  321. package/dist/tool-call-text.d.ts +59 -0
  322. package/dist/tool-call-text.js +62 -0
  323. package/dist/tool-input-envelope.js +8 -4
  324. package/dist/tool-input-normalization.js +8 -1
  325. package/dist/tool-input-repairs.d.ts +58 -0
  326. package/dist/tool-input-repairs.js +154 -0
  327. package/dist/tool-tokens.js +1 -1
  328. package/dist/user-facing-error.d.ts +1 -1
  329. package/dist/user-facing-error.js +3 -1
  330. package/package.json +234 -13
  331. package/dist/settings/express/contracts.js +0 -2
  332. package/dist/settings/express/http-request.d.ts +0 -33
  333. package/dist/settings/express/http-request.js +0 -50
  334. package/dist/settings/express/http.d.ts +0 -10
  335. package/dist/settings/express/http.js +0 -196
  336. package/dist/settings/express/index.d.ts +0 -5
  337. package/dist/settings/express/index.js +0 -4
  338. package/dist/settings/express/shared.d.ts +0 -68
  339. package/dist/settings/express/stream.d.ts +0 -24
  340. package/dist/settings/express/stream.js +0 -171
package/CHANGELOG.md CHANGED
@@ -1,5 +1,3 @@
1
- ## 0.7.2
2
-
3
1
  ## 0.7.1
4
2
 
5
3
  ### Patch Changes
package/README.md CHANGED
@@ -15,9 +15,8 @@ set of tokens, and fails to typecheck if any pack's declared dependency is left
15
15
  npm install @jini-ai/core
16
16
  ```
17
17
 
18
- The root has no runtime dependencies and never loads settings or Express. The
19
- `@jini-ai/core/settings/express` adapter uses Express types and the host's injected app; it never
20
- loads the Express runtime, so this package declares no Express peer.
18
+ The root has no runtime dependencies and never loads settings or Express.
19
+ The settings Express adapter lives in `@jini-ai/http-kit/settings`; core declares no Express peer.
21
20
 
22
21
  ## What you get
23
22
 
@@ -100,8 +99,20 @@ Tool handlers receive required execution context first and optional `{ emitSurfa
100
99
 
101
100
  | subpath | what's behind it |
102
101
  |---|---|
102
+ | `./env/describe-env-for-diagnostics` | `describeEnvForDiagnostics({ schema, env })`: pure env-name descriptions with explicit value display, presence-only secrets and unknown names, URL credential stripping and secret-shape redaction. For host-owned diagnostics. |
103
103
  | `./fetch` | Framework-neutral query contracts and `FetchQueryCache`; inject transport callbacks, `Clock`, scheduler and connectivity/focus ports. No React, DOM or TanStack dependency. |
104
- | `./records` | `canonicalJson({ value })`, async WebCrypto `canonicalArgumentDigest({ args }, { crypto? })`, and `CanonicalJsonError`; recursively sorted Unicode code-point keys, strict JSON validation, and lowercase SHA-256 hex. |
104
+ | `./net` | Literal host classification (loopback, blocked and deployed API hosts) and the `FETCH_TIMEOUT_MS` classes. Pure, no Node imports. |
105
+ | `./contracts/capabilities` | Agent capability vocabulary (`CapabilityDef`, input-schema types) and the pure `findCapability`/`findCapabilityInputError`/`availableCapabilities` helpers. |
106
+ | `./contracts/observability` | The vendor-neutral observability vocabulary: `ObservabilityPort`, its request/DB/outbound/agent-run/operation trackers, `ErrorReport`, `TraceIds`, the product-analytics port (`ProductAnalyticsPort` and its event types, `BrowserAnalyticsContribution`) and the frozen disabled port (`createNoopObservabilityPort`, `isNoopObservabilityPort`). Guards, fan-out and vendor adapters live in `@jini-ai/diagnostics` and `@jini-ai/analytics`. |
107
+ | `./contracts/blob` | Backend-agnostic blob storage port and `StorageError`. |
108
+ | `./contracts/admin-module` | `adminPort` token and the admin module contract types (`defineAdminModule`, `AdminModule`, `AdminDescription`, port map types). Admin hosts and plugin authors import it from core; `@jini-ai/admin` consumes it. |
109
+ | `./contracts/runtime` | Fs-lock, atomic-writer, process, command, pty, http and guarded-reader port types plus pure helpers (`planCommandInvocation`, `omitEnvironmentKeys`, `collectProcessTreePids`). Node implementations live in `@jini-ai/platform`. |
110
+ | `./contracts/runtime/testing` | Test-only in-memory fakes of the runtime ports (`fakeFileLock`, `fakeAtomicWriter`, `fakeProcessControl`, `fakeHttpFetch`, `fakeGuardedHttp`): each records the arguments it was given, in order, and does no I/O. For tests of other packages; never import from production code. |
111
+ | `./records` | `canonicalJson({ value })`, async WebCrypto `canonicalArgumentDigest({ args, crypto })`, and `CanonicalJsonError`; recursively sorted Unicode code-point keys, strict JSON validation, and lowercase SHA-256 hex. |
112
+ | `./contracts/storage` | Library-neutral storage kernel (`StorageKernel<Handle, Schema>`, generic over the host's query handle), row/value helpers, SQLite client shapes and the migration-step type. Kernels and drivers live in `@jini-ai/db`; the command/event vocabulary is `./contracts/events`. |
113
+ | `./contracts/agents` | The agent-runtime vocabulary, types only: `RuntimeAgentDef` and its closure, the model catalog and provider-model shapes, native-tool policy and run-plan types, launch results, `PromptAugmenter`, plus the data-only `RuntimeSelectionError`. `@jini-ai/agent-runtime` implements it; `@jini-ai/daemon` consumes it through `AgentRuntimePort`. No Node imports. |
114
+ | `./contracts/ai-trace` | The AI trace vocabulary and its pure helpers: `createAiTraceRecorder` (takes `now`), `normalizeAiUsage`, classification, capture with secret redaction, and the sinks. Used by the daemon, analytics and the provider plugins. No Node imports, no timers. |
115
+ | `./contracts/forms`, `./contracts/charts`, `./contracts/plugin-sdk` | What form-collection, chart and plugin providers implement. Types and pure helpers only. |
105
116
  | `.` | The public surface above: tokens, packs, daemon composition, tool registry (descriptors only), principal, redact, auth primitives. |
106
117
  | `./composition` | **Not part of the public contract.** Exposes `authorizeToolInvocation` (resolves a registry's tool and runs its authorization gate — a security-sensitive value export, but one that only ever hands back a handler alongside an `'allow'` decision) plus type-only `AnyPack`/`RequiredTokenIds`/`MissingTokenIds` re-derivation helpers. Its sole intended consumers are `@jini-ai/daemon`'s `ToolExecutor` and `@jini-ai/server`'s `createLocalNodeDaemon`. Node's resolver will happily let any consumer import it — the boundary is enforced by `scripts/check-engine-boundaries.ts`, not by the exports map — so external adopters should treat it as off-limits regardless. |
107
118
 
@@ -125,16 +136,24 @@ See the archived provenance ledger for per-file provenance and scope decisions.
125
136
 
126
137
  ## Additional entry points
127
138
 
128
- The four entries below also have named exports from the package root. Each is universal
139
+ `./contracts/server` also holds the route vocabulary (`Result`, `jsonRoute`, `readJsonBody`, `readQuery`, `createSseStream`, origin checks). `./contracts/server/testing` is an in-memory `Server`; `./contracts/server/conformance` checks any `Server` adapter; `./contracts/server/verified-origin` is the canonical-origin registry.
140
+
141
+ `./contracts/server` exports `DeclaredPageHosts`, `SecurityHeaderSet`, `CSP_REPORT_ONLY_HEADER`, `isDeclaredOrigin`, `addDeclaredHostsToPolicy`, `withDeclaredHosts`, and `isSameOriginBrowserWrite`: pure report-only CSP declared-host helpers and a host-only browser-write predicate with Fetch Metadata checks.
142
+
143
+ The entries below also have named exports from the package root. Each is universal
129
144
  and has no runtime dependency. Importing the root and a subpath shares the same
130
145
  class and factory identities.
131
146
 
132
147
  | Subpath | API and required ports |
133
148
  |---|---|
134
149
  | `./gated-mutations` | `plan`, `confirm`, `execute`, `authorizeForHooks`; authorization, clock, ID generation, complete opaque token generation, TTL, token store and mutation hooks. Includes token lifecycle and composite actor-reference helpers. |
150
+ | `./approval-batch-chain` | `createChainedBatchHandler({ prepare, run, targetKey, successor }, { maxItems, targetNoun })`; direct batch whose same-target items apply in order, each pinned to the version the batch's own previous write reported (`run` returns `{ output, committed }`; `successor` is synchronous, no I/O). |
135
151
  | `./model-facing-tool-errors` | `forbiddenRule`, `reclassifyToolError`, `withModelFacingErrors`, `withModelFacingRegistrationErrors`, `callerSafeErrorMessage`; callers own ordered error allowlists and fallback wording. |
152
+ | `./tool-call-text` | `unknownToolSentence`, `toolFamilySentence`, `toolCallText`; the one wording of an unknown-tool answer, of a group-of-tools answer, and of how to call a tool (wire name or gateway form), shared by the daemon route and the MCP host. |
153
+ | `./tool-input-repairs` | `clampDeclaredBounds`, `assertRepairKeywords`, `missingArgumentGuidance`; opt-in `clamp: true` on a bounded numeric property (applied by `normalizeToolInput` on every registry path); `obtainFrom: "<tool id>"` on a required property (read by the typed MCP validator and the delegated-tool routes). |
136
154
  | `./contribution-registry` | `createContributionRegistry({ keyOf })`; instance-owned replacement by key, with detached array snapshots. |
137
155
  | `./naming` | `deriveAvailableName`, `deriveDuplicateName`, `MAX_SUFFIX_ATTEMPTS`; required collision predicate, suffix formatter and exhaustion message policy. |
156
+ | `./agent-handles` | `agentHandle`/`agentHandleProps`/`buildAgentListHandles`, the `data-agent-*` attribute names and handle grammar, `FieldDescriptor`. Pure data, no DOM. |
138
157
 
139
158
  Contribution registries use `register({ contribution })`, `list({})` and `clear({})`.
140
159
  Approval clock/ID ports use the shared zero-argument `Clock.nowMs()` and
@@ -190,12 +209,17 @@ UUIDs and timestamps remain unbranded strings. The HTTP contract includes binary
190
209
  bytes, redirect provenance, socket idle budgets and an optional total deadline. Platform
191
210
  supplies the guarded HTTP implementation; core defines the port only.
192
211
 
193
- Default adapters are `createSystemClock()`, `createRandomUuidGenerator()` and
194
- `createConsoleLogger({ prefix })`. Clock/ID getters take no arguments. Time helpers are
212
+ Default adapter is `createConsoleLogger({ prefix })`; `createSystemClock()` and
213
+ `createRandomUuidGenerator()` live in `@jini-ai/platform/system`. Clock/ID getters take no arguments. Time helpers are
195
214
  `toIsoDateTime({ epochMs })` and `nowIso({ clock })`. The UUID adapter requires a host
196
215
  cryptographic UUID implementation and fails if unavailable. The console adapter routes
197
216
  info/warn/error with optional `{ meta, error }` to the same console severity.
198
217
 
218
+ `@jini-ai/core/contracts/events` holds the type-only command/event/outbox vocabulary: `DomainEvent`, `EventBusPort`,
219
+ `OutboxPort`, `OutboxRecord`, `TransactionalRepoPort`, the change-set records and `ChangeSetRepoPort`, the command
220
+ envelope types, `AuthorizeFn` and `ExecuteCommandFn`. Hosts supply the implementations; `@jini-ai/cms/core` supplies the
221
+ `executeCommand` gateway.
222
+
199
223
  Agent-tool catalogs import `AgentToolSideEffect`, `AgentToolActorClassRule` and
200
224
  `AgentToolDefinition` from the core root. Delete is a separate side-effect classification;
201
225
  domains may tighten the shared interface, including making `inputSchema` required.
@@ -206,6 +230,8 @@ sequences, masks labeled/opaque credentials and caps the complete output at 500
206
230
  by default. Correlation IDs and the delegated-tool route remain visible. This sanitizer
207
231
  keeps its existing policy; the telemetry redactor additionally masks PII.
208
232
 
233
+ `@jini-ai/core/text` also exports `formatByteSize({ bytes }, { locale?, megabyteLabel? })`: 1024-based, whole B/KB and one decimal from MB up.
234
+
209
235
  `redactSecrets` and `redactSecretsWithCounts` cover the core, CLI and provider rule union.
210
236
  Exact secrets are literal strings (including regex metacharacters), applied longest first;
211
237
  null/undefined/empty entries are ignored. Extra patterns are `{ name, regex }` entries, cloned
@@ -256,11 +282,13 @@ boot-time definition registration, dictionaries and agent tools. Hosts inject se
256
282
  active-principal lookup, authorization, clocks and IDs; no CMS or database adapter is required.
257
283
  The keys, scopes, permissions and tool IDs are unchanged by the relocation.
258
284
 
259
- `@jini-ai/core/settings/express` exports `registerSettingsRoutes`, HTTP policy contracts and
285
+ `@jini-ai/core/settings` also exports the neutral route policy contracts and
260
286
  `createCmsSettingsService` / `createCmsSettingsChangeFeed` (factory names retained for compatibility).
287
+ `@jini-ai/http-kit/settings` exports `registerSettingsRoutes`, Express contracts and error mapping.
261
288
  Hosts provide route paths, readiness, principal resolution, scheduler, service and feed ports.
262
- Registration returns a disposer that closes active feeds. The universal settings entry never
263
- loads this adapter; neither entry is re-exported by the kernel root.
289
+ Registration returns a disposer that closes active feeds.
290
+
291
+ `@jini-ai/cms/settings` remains a compatibility entry for the neutral core settings owner.
292
+ The former core and CMS `./settings/express` entries have been removed.
264
293
 
265
- The former `@jini-ai/cms/settings` and `@jini-ai/cms/settings/express` entries re-export these
266
- owners for one release. New consumers should import the core subpaths directly.
294
+ `@jini-ai/core/text` also exports `redactOAuthUrls({ text, pattern, replacement })`: replaces every match of a provider-owned pattern and leaves all other bytes intact (a non-global pattern replaces only its first match). The caller owns the pattern and the replacement.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @file The error contract every admin route group throws, host-supplied or Jini-shipped.
3
+ *
4
+ * Ported from the reference implementation's `lib/api.ts` (`ApiError`, `describeApiError`), which is the
5
+ * only implementation of this shape that has been through real operator use. Two decisions from
6
+ * that file are carried across deliberately, because both were arrived at by an audit and both
7
+ * look like oversights if you only read the code:
8
+ *
9
+ * 1. **`body` is kept raw.** A caller sometimes needs a route-specific field beyond
10
+ * `code`/`message` (a 409's `currentVersion`, a validation route's field list). Exposing the
11
+ * parsed body means that never requires an `AdminApiError` subclass per route.
12
+ *
13
+ * 2. **There is deliberately NO shared `code` -> message table.** The same `code` means
14
+ * genuinely different things in different domains — in the reference implementation,
15
+ * `RESOURCE_CONFLICT` is "still
16
+ * referenced elsewhere" on Roles, "that slug is already taken" on Workspace, and "that
17
+ * username is already in use" on Users. Three correct operator-facing sentences for one code.
18
+ * A shared table could only pick one, which is a regression dressed as consolidation. So
19
+ * `describeApiError` is only the *base case*: it decides what to show when the server sent no
20
+ * message, or when the thrown value is not an `AdminApiError` at all (a port's own exception or
21
+ * a thrown non-Error: never shown, logged by class and code only). Panels layer their own
22
+ * per-code copy on top and fall through to this.
23
+ */
24
+ /** A failed admin API call: a non-2xx response, or a network/timeout failure with status 0. */
25
+ export declare class AdminApiError extends Error {
26
+ readonly status: number;
27
+ /**
28
+ * Canonical error `code` from the response body when the server sent one. Not enumerated here
29
+ * on purpose — the vocabulary belongs to the host's API, and a union type in this package would
30
+ * have to be widened by a Jini release every time a product added a code.
31
+ */
32
+ readonly code?: string | undefined;
33
+ /** Raw parsed JSON error body, when present. See decision 1 in the file header. */
34
+ readonly body?: Record<string, unknown> | undefined;
35
+ constructor({ message, status }: {
36
+ readonly message: string;
37
+ readonly status: number;
38
+ }, { code, body }?: {
39
+ readonly code?: string | undefined;
40
+ readonly body?: Record<string, unknown> | undefined;
41
+ });
42
+ }
43
+ /**
44
+ * Base-case translation from a thrown request error to operator-facing copy.
45
+ *
46
+ * This is the "opt-out by default" fallback, not a complete message catalog — see decision 2 in
47
+ * the file header. A panel with real per-code handling checks its own codes first and falls
48
+ * through here for the rest:
49
+ *
50
+ * ```ts
51
+ * function describe(e: unknown, fallback: string): string {
52
+ * if (e instanceof AdminApiError && e.code === 'PANEL_SPECIFIC_CODE') return '...';
53
+ * return describeApiError({ e, fallback });
54
+ * }
55
+ * ```
56
+ *
57
+ * Only an `AdminApiError` (the host API's contract, network failures included as status 0) shows its
58
+ * own words; any other thrown value shows `fallback` and is logged by class and code only.
59
+ *
60
+ * @complexity O(1) — one `instanceof` check, no iteration.
61
+ */
62
+ export declare function describeApiError({ e, fallback }: {
63
+ readonly e: unknown;
64
+ readonly fallback: string;
65
+ }, { warn }?: {
66
+ readonly warn?: (line: string) => void;
67
+ }): string;
68
+ //# sourceMappingURL=admin-api-error.d.ts.map
@@ -0,0 +1,72 @@
1
+ import { describeErrorForLog } from '../model-facing-tool-errors.js';
2
+ import { createConsoleLogger } from '../primitives/logger.js';
3
+ /**
4
+ * @file The error contract every admin route group throws, host-supplied or Jini-shipped.
5
+ *
6
+ * Ported from the reference implementation's `lib/api.ts` (`ApiError`, `describeApiError`), which is the
7
+ * only implementation of this shape that has been through real operator use. Two decisions from
8
+ * that file are carried across deliberately, because both were arrived at by an audit and both
9
+ * look like oversights if you only read the code:
10
+ *
11
+ * 1. **`body` is kept raw.** A caller sometimes needs a route-specific field beyond
12
+ * `code`/`message` (a 409's `currentVersion`, a validation route's field list). Exposing the
13
+ * parsed body means that never requires an `AdminApiError` subclass per route.
14
+ *
15
+ * 2. **There is deliberately NO shared `code` -> message table.** The same `code` means
16
+ * genuinely different things in different domains — in the reference implementation,
17
+ * `RESOURCE_CONFLICT` is "still
18
+ * referenced elsewhere" on Roles, "that slug is already taken" on Workspace, and "that
19
+ * username is already in use" on Users. Three correct operator-facing sentences for one code.
20
+ * A shared table could only pick one, which is a regression dressed as consolidation. So
21
+ * `describeApiError` is only the *base case*: it decides what to show when the server sent no
22
+ * message, or when the thrown value is not an `AdminApiError` at all (a port's own exception or
23
+ * a thrown non-Error: never shown, logged by class and code only). Panels layer their own
24
+ * per-code copy on top and fall through to this.
25
+ */
26
+ /** A failed admin API call: a non-2xx response, or a network/timeout failure with status 0. */
27
+ export class AdminApiError extends Error {
28
+ status;
29
+ /**
30
+ * Canonical error `code` from the response body when the server sent one. Not enumerated here
31
+ * on purpose — the vocabulary belongs to the host's API, and a union type in this package would
32
+ * have to be widened by a Jini release every time a product added a code.
33
+ */
34
+ code;
35
+ /** Raw parsed JSON error body, when present. See decision 1 in the file header. */
36
+ body;
37
+ constructor({ message, status }, { code, body } = {}) {
38
+ super(message);
39
+ this.name = 'AdminApiError';
40
+ this.status = status;
41
+ this.code = code;
42
+ this.body = body;
43
+ }
44
+ }
45
+ /**
46
+ * Base-case translation from a thrown request error to operator-facing copy.
47
+ *
48
+ * This is the "opt-out by default" fallback, not a complete message catalog — see decision 2 in
49
+ * the file header. A panel with real per-code handling checks its own codes first and falls
50
+ * through here for the rest:
51
+ *
52
+ * ```ts
53
+ * function describe(e: unknown, fallback: string): string {
54
+ * if (e instanceof AdminApiError && e.code === 'PANEL_SPECIFIC_CODE') return '...';
55
+ * return describeApiError({ e, fallback });
56
+ * }
57
+ * ```
58
+ *
59
+ * Only an `AdminApiError` (the host API's contract, network failures included as status 0) shows its
60
+ * own words; any other thrown value shows `fallback` and is logged by class and code only.
61
+ *
62
+ * @complexity O(1) — one `instanceof` check, no iteration.
63
+ */
64
+ export function describeApiError({ e, fallback }, { warn = line => createConsoleLogger({ prefix: '' }).warn({ message: line }) } = {}) {
65
+ if (e instanceof AdminApiError)
66
+ return e.message || fallback;
67
+ // Anything else is not approved copy: a port's own exception can quote private values, so the
68
+ // operator sees the specific fallback and the log gets only the error's class and code.
69
+ warn(`[admin] ${fallback} Cause: ${describeErrorForLog({ err: e })}`);
70
+ return fallback;
71
+ }
72
+ //# sourceMappingURL=admin-api-error.js.map
@@ -0,0 +1,8 @@
1
+ /** A module graph or React scope that cannot boot: lists every issue found, one per bullet. */
2
+ export declare class AdminConfigError extends Error {
3
+ readonly issues: readonly string[];
4
+ constructor({ issues }: {
5
+ issues: readonly string[];
6
+ }, _optional?: Record<string, never>);
7
+ }
8
+ //# sourceMappingURL=admin-config-error.d.ts.map
@@ -0,0 +1,11 @@
1
+ const bulletLine = (issue) => `- ${issue}`;
2
+ /** A module graph or React scope that cannot boot: lists every issue found, one per bullet. */
3
+ export class AdminConfigError extends Error {
4
+ issues;
5
+ constructor({ issues }, _optional = {}) {
6
+ super(`Invalid admin configuration:\n${issues.map(bulletLine).join('\n')}`);
7
+ this.name = 'AdminConfigError';
8
+ this.issues = Object.freeze([...issues]);
9
+ }
10
+ }
11
+ //# sourceMappingURL=admin-config-error.js.map
@@ -0,0 +1,20 @@
1
+ export interface ControllerStore<S> {
2
+ getSnapshot(required?: Record<string, never>, optional?: Record<string, never>): S;
3
+ subscribe(required: {
4
+ listener: () => void;
5
+ }, optional?: Record<string, never>): () => void;
6
+ dispose(required?: Record<string, never>, optional?: Record<string, never>): void;
7
+ }
8
+ /** What an owner's controller holds: the read-only store contract plus its single write and its abort signal. */
9
+ export interface WritableControllerStore<S extends object> extends ControllerStore<S> {
10
+ set(required: {
11
+ patch: Partial<S>;
12
+ }, optional?: Record<string, never>): void;
13
+ /** Aborted by `dispose`, so an in-flight call can stop instead of settling into a retired scope. */
14
+ readonly signal: AbortSignal;
15
+ }
16
+ /** Snapshot identity changes only on a write: useSyncExternalStore requires a cached snapshot. */
17
+ export declare function createControllerStore<S extends object>({ initial }: {
18
+ initial: S;
19
+ }, _optional?: Record<string, never>): WritableControllerStore<S>;
20
+ //# sourceMappingURL=controller-store.d.ts.map
@@ -0,0 +1,32 @@
1
+ /** Snapshot identity changes only on a write: useSyncExternalStore requires a cached snapshot. */
2
+ export function createControllerStore({ initial }, _optional = {}) {
3
+ let state = Object.freeze(initial), disposed = false;
4
+ const listeners = new Set();
5
+ const abort = new AbortController();
6
+ return {
7
+ getSnapshot: () => state,
8
+ subscribe: ({ listener }) => {
9
+ if (!disposed)
10
+ listeners.add(listener);
11
+ return () => {
12
+ listeners.delete(listener);
13
+ };
14
+ },
15
+ set: ({ patch }) => {
16
+ if (disposed)
17
+ return;
18
+ state = Object.freeze({ ...state, ...patch });
19
+ for (const listener of listeners)
20
+ listener();
21
+ },
22
+ signal: abort.signal,
23
+ dispose: () => {
24
+ if (disposed)
25
+ return;
26
+ disposed = true;
27
+ abort.abort();
28
+ listeners.clear();
29
+ },
30
+ };
31
+ }
32
+ //# sourceMappingURL=controller-store.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file `@jini-ai/core/admin-runtime` — the pure runtime every admin module owner needs, placed where
3
+ * an owner package may import it (an owner imports only itself, core and protocol). No React, no
4
+ * DOM, no I/O. The React halves (`useController`, `bindReact`) live in `@jini-ai/ui-kit/react`.
5
+ */
6
+ export { AdminConfigError } from './admin-config-error.js';
7
+ export { AdminApiError, describeApiError } from './admin-api-error.js';
8
+ export { createControllerStore } from './controller-store.js';
9
+ export type { ControllerStore, WritableControllerStore } from './controller-store.js';
10
+ export { hasPermission, isPanelAccessible, withoutInaccessiblePanels } from './panel-access.js';
11
+ export type { AdminNavGroupShape, AdminPanelAccessDeclaration, AdminPanelAccessEntry } from './panel-access.js';
12
+ export { querySuffix } from './query-suffix.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file `@jini-ai/core/admin-runtime` — the pure runtime every admin module owner needs, placed where
3
+ * an owner package may import it (an owner imports only itself, core and protocol). No React, no
4
+ * DOM, no I/O. The React halves (`useController`, `bindReact`) live in `@jini-ai/ui-kit/react`.
5
+ */
6
+ export { AdminConfigError } from './admin-config-error.js';
7
+ export { AdminApiError, describeApiError } from './admin-api-error.js';
8
+ export { createControllerStore } from './controller-store.js';
9
+ // Permissions — affordance only, never an authorization boundary.
10
+ export { hasPermission, isPanelAccessible, withoutInaccessiblePanels } from './panel-access.js';
11
+ export { querySuffix } from './query-suffix.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @file Client-side permission-affordance helper.
3
+ *
4
+ * Ported verbatim in behaviour from the reference implementation's `lib/permissions.ts`. The bug that file
5
+ * exists to prevent is worth restating, because it is not obvious and it cost a real lockout:
6
+ *
7
+ * A host's "effective permissions" list is typically flattened to bare permission strings, and an
8
+ * unconstrained owner grant appears in it as the literal `"*"`. A plain
9
+ * `permissions.includes(permission)` check treats `"*"` as just another permission *name* and
10
+ * never matches it against a real permission like `"comments.read"` — which locked the workspace
11
+ * owner out of every permission-gated affordance in the admin. Every call site that checks a
12
+ * permission string should route through this helper rather than reintroducing a literal
13
+ * `.includes()`.
14
+ *
15
+ * ## NOT A SECURITY BOUNDARY
16
+ *
17
+ * This decides whether a button, section, or form renders. It never runs on the server and is
18
+ * never consulted by any route or command handler. A bug here — too permissive or too
19
+ * restrictive — can only show or hide a control; it cannot grant or block the underlying
20
+ * operation, because every mutation and tool call must be independently re-checked server-side.
21
+ * Do not import this into server code, and do not treat a passing call here as proof an action is
22
+ * actually allowed.
23
+ */
24
+ /**
25
+ * True iff `permissions` grants `permission` — either an exact match, or the unconstrained owner
26
+ * wildcard `"*"`.
27
+ *
28
+ * @complexity O(n) array scan, n = `permissions.length` (a handful of grant strings for a real
29
+ * principal; never a caller-unbounded collection).
30
+ */
31
+ export declare function hasPermission({ permissions, permission }: {
32
+ readonly permissions: readonly string[];
33
+ readonly permission: string;
34
+ }): boolean;
35
+ /** What {@link isPanelAccessible} reads from a panel: its two permission declarations. */
36
+ export interface AdminPanelAccessDeclaration {
37
+ /** All-of: every one must be held. */
38
+ readonly permissions?: readonly string[];
39
+ /** Any-of: at least one must be held. */
40
+ readonly anyOfPermissions?: readonly string[];
41
+ }
42
+ /** The part of a nav group this rule reads: rows that carry the id of the panel they open. */
43
+ export interface AdminNavGroupShape {
44
+ readonly items: readonly {
45
+ readonly id: string;
46
+ }[];
47
+ }
48
+ /** A declaration plus the id that ties it to a nav row. */
49
+ export type AdminPanelAccessEntry = AdminPanelAccessDeclaration & {
50
+ readonly id: string;
51
+ };
52
+ /**
53
+ * True when the operator may use a panel, from the panel's own permission declarations.
54
+ *
55
+ * `permissions` is a **required key whose value may be `undefined`**: `undefined` means the session
56
+ * has not said yet (fresh sign-in before the host's permission read answers), and every panel shows
57
+ * then rather than flashing an empty nav or a no-access screen at someone who has access. An empty
58
+ * list is a known, empty grant and is not the same thing (it hides every gated panel). It is
59
+ * therefore never an optional property: absent and unknown must not be confusable.
60
+ *
61
+ * Rules: no declaration is accessible; `anyOfPermissions` needs at least one held (or `"*"`);
62
+ * `permissions` (all-of) needs every one held; when both are declared both must pass.
63
+ *
64
+ * Client-side visibility only, never an authorization boundary: the server stays the authority
65
+ * (see the file header).
66
+ *
67
+ * @complexity O(d * m): d declared ids, m held permissions.
68
+ */
69
+ export declare function isPanelAccessible({ panel, permissions }: {
70
+ readonly panel: AdminPanelAccessDeclaration;
71
+ readonly permissions: readonly string[] | undefined;
72
+ }, _options?: Record<string, never>): boolean;
73
+ /**
74
+ * The nav with every row the operator cannot use removed.
75
+ *
76
+ * Returns `groups` itself (same reference) while `permissions` is `undefined`. Drops a group once all
77
+ * its rows are hidden, so no heading sits over nothing, and keeps a row whose id names no panel in
78
+ * `panels` (there is nothing to check it against). Client-side visibility only, like
79
+ * {@link isPanelAccessible}.
80
+ *
81
+ * @complexity O(n + p + n * d * m): a Map over p panels, then n nav rows.
82
+ */
83
+ export declare function withoutInaccessiblePanels<G extends AdminNavGroupShape>({ groups, panels, permissions }: {
84
+ readonly groups: readonly G[];
85
+ readonly panels: readonly AdminPanelAccessEntry[];
86
+ readonly permissions: readonly string[] | undefined;
87
+ }, _options?: Record<string, never>): readonly G[];
88
+ //# sourceMappingURL=panel-access.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @file Client-side permission-affordance helper.
3
+ *
4
+ * Ported verbatim in behaviour from the reference implementation's `lib/permissions.ts`. The bug that file
5
+ * exists to prevent is worth restating, because it is not obvious and it cost a real lockout:
6
+ *
7
+ * A host's "effective permissions" list is typically flattened to bare permission strings, and an
8
+ * unconstrained owner grant appears in it as the literal `"*"`. A plain
9
+ * `permissions.includes(permission)` check treats `"*"` as just another permission *name* and
10
+ * never matches it against a real permission like `"comments.read"` — which locked the workspace
11
+ * owner out of every permission-gated affordance in the admin. Every call site that checks a
12
+ * permission string should route through this helper rather than reintroducing a literal
13
+ * `.includes()`.
14
+ *
15
+ * ## NOT A SECURITY BOUNDARY
16
+ *
17
+ * This decides whether a button, section, or form renders. It never runs on the server and is
18
+ * never consulted by any route or command handler. A bug here — too permissive or too
19
+ * restrictive — can only show or hide a control; it cannot grant or block the underlying
20
+ * operation, because every mutation and tool call must be independently re-checked server-side.
21
+ * Do not import this into server code, and do not treat a passing call here as proof an action is
22
+ * actually allowed.
23
+ */
24
+ /**
25
+ * True iff `permissions` grants `permission` — either an exact match, or the unconstrained owner
26
+ * wildcard `"*"`.
27
+ *
28
+ * @complexity O(n) array scan, n = `permissions.length` (a handful of grant strings for a real
29
+ * principal; never a caller-unbounded collection).
30
+ */
31
+ export function hasPermission({ permissions, permission }) {
32
+ return permissions.includes('*') || permissions.includes(permission);
33
+ }
34
+ /**
35
+ * True when the operator may use a panel, from the panel's own permission declarations.
36
+ *
37
+ * `permissions` is a **required key whose value may be `undefined`**: `undefined` means the session
38
+ * has not said yet (fresh sign-in before the host's permission read answers), and every panel shows
39
+ * then rather than flashing an empty nav or a no-access screen at someone who has access. An empty
40
+ * list is a known, empty grant and is not the same thing (it hides every gated panel). It is
41
+ * therefore never an optional property: absent and unknown must not be confusable.
42
+ *
43
+ * Rules: no declaration is accessible; `anyOfPermissions` needs at least one held (or `"*"`);
44
+ * `permissions` (all-of) needs every one held; when both are declared both must pass.
45
+ *
46
+ * Client-side visibility only, never an authorization boundary: the server stays the authority
47
+ * (see the file header).
48
+ *
49
+ * @complexity O(d * m): d declared ids, m held permissions.
50
+ */
51
+ export function isPanelAccessible({ panel, permissions }, _options = {}) {
52
+ if (permissions === undefined)
53
+ return true;
54
+ const holds = (permission) => hasPermission({ permissions, permission });
55
+ const anyOf = panel.anyOfPermissions ?? [];
56
+ return (anyOf.length === 0 || anyOf.some(holds)) && (panel.permissions ?? []).every(holds);
57
+ }
58
+ /**
59
+ * The nav with every row the operator cannot use removed.
60
+ *
61
+ * Returns `groups` itself (same reference) while `permissions` is `undefined`. Drops a group once all
62
+ * its rows are hidden, so no heading sits over nothing, and keeps a row whose id names no panel in
63
+ * `panels` (there is nothing to check it against). Client-side visibility only, like
64
+ * {@link isPanelAccessible}.
65
+ *
66
+ * @complexity O(n + p + n * d * m): a Map over p panels, then n nav rows.
67
+ */
68
+ export function withoutInaccessiblePanels({ groups, panels, permissions }, _options = {}) {
69
+ if (permissions === undefined)
70
+ return groups;
71
+ const panelsById = new Map(panels.map((panel) => [panel.id, panel]));
72
+ return groups
73
+ .map((group) => ({ ...group, items: group.items.filter((item) => isPanelAccessible({ panel: panelsById.get(item.id) ?? {}, permissions })) }))
74
+ .filter((group) => group.items.length > 0);
75
+ }
76
+ //# sourceMappingURL=panel-access.js.map
@@ -0,0 +1,5 @@
1
+ /** `{ query: "a=1" }` -> `"?a=1"`; an empty query string adds nothing to the path. */
2
+ export declare function querySuffix({ query }: {
3
+ readonly query: string;
4
+ }, _optional?: Record<string, never>): string;
5
+ //# sourceMappingURL=query-suffix.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** `{ query: "a=1" }` -> `"?a=1"`; an empty query string adds nothing to the path. */
2
+ export function querySuffix({ query }, _optional = {}) {
3
+ return query ? `?${query}` : '';
4
+ }
5
+ //# sourceMappingURL=query-suffix.js.map