@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
@@ -0,0 +1,44 @@
1
+ import { createErrorCatalog } from './catalog.js';
2
+ import { createErrorReporter } from './reporter.js';
3
+ /** A logger that keeps every call exactly as made, original error objects included. */
4
+ export function createRecordingLogger() {
5
+ const entries = [];
6
+ const write = (level) => (required, optional = {}) => {
7
+ entries.push({ level, message: required.message, ...optional });
8
+ };
9
+ return { logger: { info: write('info'), warn: write('warn'), error: write('error') }, entries };
10
+ }
11
+ /** A tracker that keeps every report. */
12
+ export function createRecordingTracker() {
13
+ const reports = [];
14
+ return { tracker: { reportError: report => { reports.push(report); } }, reports };
15
+ }
16
+ /** Hands out the given IDs in order; throws when a test asks for more than it listed. */
17
+ export function createSequenceIds(required) {
18
+ let next = 0;
19
+ return {
20
+ newId: () => {
21
+ const id = required.ids[next];
22
+ if (id === undefined)
23
+ throw new RangeError(`createSequenceIds: the test asked for ID ${next + 1} but listed ${required.ids.length}.`);
24
+ next += 1;
25
+ return id;
26
+ },
27
+ };
28
+ }
29
+ /** A clock fixed at one instant. */
30
+ export function createFixedClock(required) {
31
+ return { nowMs: () => Date.parse(required.iso) };
32
+ }
33
+ /**
34
+ * A real reporter over recording ports, for a test that needs to see what an incident wrote.
35
+ * @example const { reporter, entries, reports } = createRecordingReporter({ ids: ['ERR-0000-0000-0000-0001'], iso: '2026-01-01T00:00:00.000Z' });
36
+ */
37
+ export function createRecordingReporter(required, optional = {}) {
38
+ const { logger, entries } = createRecordingLogger();
39
+ const { tracker, reports } = createRecordingTracker();
40
+ const { catalog = createErrorCatalog({ sentences: [], scopes: [] }), versions = { app: '0.0.0-test', jini: '0.0.0-test' }, ...reporterOptions } = optional;
41
+ const reporter = createErrorReporter({ ids: createSequenceIds({ ids: required.ids }), clock: createFixedClock({ iso: required.iso }), logger, tracker, catalog, versions }, reporterOptions);
42
+ return { reporter, entries, reports };
43
+ }
44
+ //# sourceMappingURL=testing.js.map
@@ -30,9 +30,11 @@ export interface FetchQueryEnvironmentPort {
30
30
  listener: () => void;
31
31
  }): () => void;
32
32
  }
33
+ export interface FetchQueryCacheRequired {
34
+ clock: Clock;
35
+ scheduler: QueryCacheSchedulerPort;
36
+ }
33
37
  export interface FetchQueryCacheOptions {
34
- clock?: Clock;
35
- scheduler?: QueryCacheSchedulerPort;
36
38
  environment?: FetchQueryEnvironmentPort;
37
39
  }
38
40
  export interface QueryState {
@@ -63,7 +65,9 @@ export interface CacheEntry {
63
65
  retention: number;
64
66
  eviction: unknown;
65
67
  }
66
- export declare function toQueryError(value: unknown): Error;
68
+ export declare function toQueryError({ value }: {
69
+ value: unknown;
70
+ }, _optional?: Record<string, never>): Error;
67
71
  /** One provider-owned cache. Requests are shared by structural primitive keys.
68
72
  * Failed reads retain earlier data; replacement writes supersede older requests.
69
73
  * Idle entries live for at least five minutes or their declared freshness period. */
@@ -76,7 +80,7 @@ export declare class FetchQueryCache {
76
80
  private online;
77
81
  private readonly onlineWaiters;
78
82
  private releaseEnvironment;
79
- constructor(_required?: Record<string, never>, { clock, scheduler, environment }?: FetchQueryCacheOptions);
83
+ constructor({ clock, scheduler }: FetchQueryCacheRequired, { environment }?: FetchQueryCacheOptions);
80
84
  entry({ key }: {
81
85
  key: QueryKey;
82
86
  }, { staleTime }?: {
@@ -96,13 +100,16 @@ export declare class FetchQueryCache {
96
100
  }): () => void;
97
101
  /** Cache hits respect freshness; explicit refreshes restart background reads.
98
102
  * Initial reads still deduplicate because no earlier successful data exists to refresh. */
99
- load<T>({ entry, fetch, staleTime }: {
103
+ load<T>({ entry, fetch: read, staleTime }: {
100
104
  entry: CacheEntry;
101
105
  fetch: () => Promise<T>;
102
106
  staleTime: number;
103
107
  }, { force }?: {
104
108
  force?: boolean;
105
109
  }): Promise<T>;
110
+ private settleSuccess;
111
+ private settleFailure;
112
+ private finishPending;
106
113
  replace({ entry, data }: {
107
114
  entry: CacheEntry;
108
115
  data: unknown;
@@ -9,13 +9,9 @@
9
9
  export const DEFAULT_STALE_TIME = 10_000;
10
10
  /** Minimum time an unobserved entry is kept; both adapters retain max(this, staleTime). */
11
11
  export const IDLE_RETENTION = 5 * 60_000;
12
- const browserScheduler = {
13
- schedule: ({ callback, delayMs }) => setTimeout(callback, delayMs),
14
- cancel: ({ handle }) => clearTimeout(handle),
15
- };
16
12
  // Normalize unknown promise rejections once so consumers receive Error without repeating
17
13
  // the same narrowing boilerplate at every read and write call site.
18
- export function toQueryError(value) {
14
+ export function toQueryError({ value }, _optional = {}) {
19
15
  if (value instanceof Error)
20
16
  return value;
21
17
  return new Error(typeof value === 'string' && value.trim() ? value : 'request failed');
@@ -32,7 +28,7 @@ export class FetchQueryCache {
32
28
  online;
33
29
  onlineWaiters = new Set();
34
30
  releaseEnvironment;
35
- constructor(_required = {}, { clock = { nowMs: () => Date.now() }, scheduler = browserScheduler, environment } = {}) {
31
+ constructor({ clock, scheduler }, { environment } = {}) {
36
32
  this.clock = clock;
37
33
  this.scheduler = scheduler;
38
34
  this.environment = environment;
@@ -69,7 +65,7 @@ export class FetchQueryCache {
69
65
  }
70
66
  /** Cache hits respect freshness; explicit refreshes restart background reads.
71
67
  * Initial reads still deduplicate because no earlier successful data exists to refresh. */
72
- load({ entry, fetch, staleTime }, { force = false } = {}) {
68
+ load({ entry, fetch: read, staleTime }, { force = false } = {}) {
73
69
  this.cancelEviction(entry);
74
70
  if (entry.pending && (!force || entry.state.data === undefined))
75
71
  return entry.pending;
@@ -85,7 +81,7 @@ export class FetchQueryCache {
85
81
  if (entry.pending !== pending)
86
82
  return this.supersedingResult({ entry });
87
83
  this.publish(entry, { ...entry.state, isFetching: true });
88
- return fetch();
84
+ return read();
89
85
  };
90
86
  const pending = Promise.resolve().then(() => {
91
87
  if (this.online)
@@ -98,46 +94,9 @@ export class FetchQueryCache {
98
94
  if (value === undefined)
99
95
  throw new Error(`${JSON.stringify(entry.key)} data is undefined`);
100
96
  return value;
101
- }).then(value => {
102
- // Only the current request may publish or clear invalidation. An older transport
103
- // need not support abort: its callers follow the replacement request instead.
104
- if (entry.pending !== pending)
105
- return this.supersedingResult({ entry });
106
- // Arbitration and publication share this continuation: a microtask between them would
107
- // let an older result overwrite a replacement accepted after arbitration.
108
- if (replacement !== entry.replacement) {
109
- this.publish(entry, { ...entry.state, isFetching: false });
110
- return entry.state.data;
111
- }
112
- entry.updatedAt = this.clock.nowMs();
113
- entry.invalidated = false;
114
- this.publish(entry, { data: value, error: null, status: 'success', isFetching: false });
115
- return value;
116
- }, error => {
117
- if (entry.pending !== pending)
118
- return this.supersedingResult({ entry });
119
- // A replacement write is newer than this read's failure as well as its data.
120
- // Keep the write's timestamp and freshness; only settle the obsolete fetch flag.
121
- if (replacement !== entry.replacement) {
122
- this.publish(entry, { ...entry.state, isFetching: false });
123
- return entry.state.data;
124
- }
125
- entry.invalidated = true;
126
- this.publish(entry, { ...entry.state, error: toQueryError(error), status: 'error', isFetching: false });
127
- throw error;
128
- }).finally(() => {
129
- if (entry.pending !== pending)
130
- return;
131
- entry.pending = undefined;
132
- entry.pendingRead = undefined;
133
- if (entry.refreshAfterPending) {
134
- entry.refreshAfterPending = false;
135
- this.refresh(entry);
136
- }
137
- this.scheduleEviction(entry);
138
- });
97
+ }).then(value => this.settleSuccess({ entry, pending, replacement, value }), error => this.settleFailure({ entry, pending, replacement, error })).finally(() => this.finishPending({ entry, pending }));
139
98
  entry.pending = pending;
140
- entry.pendingRead = { fetch, staleTime };
99
+ entry.pendingRead = { fetch: read, staleTime };
141
100
  // Mark handled even when a UI caller deliberately discards the promise.
142
101
  void pending.catch(() => { });
143
102
  // Like TanStack's background refetches, retain the last error until success clears it
@@ -147,6 +106,46 @@ export class FetchQueryCache {
147
106
  this.publish(entry, { ...state, isFetching: this.online });
148
107
  return pending;
149
108
  }
109
+ settleSuccess({ entry, pending, replacement, value }) {
110
+ // Only the current request may publish or clear invalidation. An older transport
111
+ // need not support abort: its callers follow the replacement request instead.
112
+ if (entry.pending !== pending)
113
+ return this.supersedingResult({ entry });
114
+ // Arbitration and publication share this continuation: a microtask between them would
115
+ // let an older result overwrite a replacement accepted after arbitration.
116
+ if (replacement !== entry.replacement) {
117
+ this.publish(entry, { ...entry.state, isFetching: false });
118
+ return entry.state.data;
119
+ }
120
+ entry.updatedAt = this.clock.nowMs();
121
+ entry.invalidated = false;
122
+ this.publish(entry, { data: value, error: null, status: 'success', isFetching: false });
123
+ return value;
124
+ }
125
+ settleFailure({ entry, pending, replacement, error }) {
126
+ if (entry.pending !== pending)
127
+ return this.supersedingResult({ entry });
128
+ // A replacement write is newer than this read's failure as well as its data.
129
+ // Keep the write's timestamp and freshness; only settle the obsolete fetch flag.
130
+ if (replacement !== entry.replacement) {
131
+ this.publish(entry, { ...entry.state, isFetching: false });
132
+ return entry.state.data;
133
+ }
134
+ entry.invalidated = true;
135
+ this.publish(entry, { ...entry.state, error: toQueryError({ value: error }), status: 'error', isFetching: false });
136
+ throw error;
137
+ }
138
+ finishPending({ entry, pending }) {
139
+ if (entry.pending !== pending)
140
+ return;
141
+ entry.pending = undefined;
142
+ entry.pendingRead = undefined;
143
+ if (entry.refreshAfterPending) {
144
+ entry.refreshAfterPending = false;
145
+ this.refresh(entry);
146
+ }
147
+ this.scheduleEviction(entry);
148
+ }
150
149
  replace({ entry, data }) {
151
150
  entry.replacement += 1;
152
151
  entry.updatedAt = this.clock.nowMs();
@@ -1,6 +1,6 @@
1
1
  /** Framework-neutral query contracts and cache; hosts supply transport callbacks and environment ports. */
2
2
  export { DEFAULT_STALE_TIME, IDLE_RETENTION, FetchQueryCache, toQueryError } from './cache.js';
3
- export type { QueryCacheSchedulerPort, FetchQueryEnvironmentPort, FetchQueryCacheOptions, QueryState, QueryObserver, CacheEntry } from './cache.js';
3
+ export type { QueryCacheSchedulerPort, FetchQueryEnvironmentPort, FetchQueryCacheOptions, FetchQueryCacheRequired, QueryState, QueryObserver, CacheEntry } from './cache.js';
4
4
  export type { QueryKey, QueryStatus, QueryResult, FetchQueryOptions, MutationStatus, MutationResult, FetchMutationOptions, CachedLoaderOptions, CachedLoaderDefaults, CachedLoader, FetchQueryAdapter } from './types.js';
5
5
  export { missingCachedLoaderFetchError, withCachedLoaderFetch } from './loader-read.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -4,7 +4,9 @@ import type { CachedLoaderDefaults, CachedLoaderOptions, QueryKey } from './type
4
4
  * `fetch`. Named, rather than left to a `TypeError: fetch is not a function` from deep inside a cache
5
5
  * adapter, so the misuse points at the call site that needs to pass `{ key, fetch }`.
6
6
  */
7
- export declare function missingCachedLoaderFetchError(key: QueryKey): Error;
7
+ export declare function missingCachedLoaderFetchError({ key }: {
8
+ key: QueryKey;
9
+ }, _optional?: Record<string, never>): Error;
8
10
  /**
9
11
  * Runs `read` with a fully specified `{ key, fetch }`, or rejects with
10
12
  * {@link missingCachedLoaderFetchError} when `required` (a loader's own defaults, for an argument-less
@@ -12,5 +14,7 @@ export declare function missingCachedLoaderFetchError(key: QueryKey): Error;
12
14
  * a failed fetch there would publish an error state to every observer of that key.
13
15
  * Shared by every `FetchQueryAdapter` so each adapter's `load` stays a single straight-line call.
14
16
  */
15
- export declare function withCachedLoaderFetch<T>(required: CachedLoaderDefaults<T>, read: (resolved: Pick<CachedLoaderOptions<T>, 'key' | 'fetch'>) => Promise<T>): Promise<T>;
17
+ export declare function withCachedLoaderFetch<T>(required: CachedLoaderDefaults<T> & {
18
+ read: (resolved: Pick<CachedLoaderOptions<T>, 'key' | 'fetch'>) => Promise<T>;
19
+ }, _optional?: Record<string, never>): Promise<T>;
16
20
  //# sourceMappingURL=loader-read.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * `fetch`. Named, rather than left to a `TypeError: fetch is not a function` from deep inside a cache
4
4
  * adapter, so the misuse points at the call site that needs to pass `{ key, fetch }`.
5
5
  */
6
- export function missingCachedLoaderFetchError(key) {
6
+ export function missingCachedLoaderFetchError({ key }, _optional = {}) {
7
7
  return new Error(`Cached loader for key ${JSON.stringify(key)} has no default fetch: call load({ key, fetch }) with a fetch of its own`);
8
8
  }
9
9
  /**
@@ -13,10 +13,10 @@ export function missingCachedLoaderFetchError(key) {
13
13
  * a failed fetch there would publish an error state to every observer of that key.
14
14
  * Shared by every `FetchQueryAdapter` so each adapter's `load` stays a single straight-line call.
15
15
  */
16
- export function withCachedLoaderFetch(required, read) {
17
- const { key, fetch } = required;
16
+ export function withCachedLoaderFetch(required, _optional = {}) {
17
+ const { key, fetch, read } = required;
18
18
  if (fetch === undefined)
19
- return Promise.reject(missingCachedLoaderFetchError(key));
19
+ return Promise.reject(missingCachedLoaderFetchError({ key }));
20
20
  return read({ key, fetch });
21
21
  }
22
22
  //# sourceMappingURL=loader-read.js.map
@@ -0,0 +1,15 @@
1
+ import type { SecretRedactionOptions } from './redaction-patterns.js';
2
+ /**
3
+ * Universal diagnostic text for any thrown value. Keeps native stacks and structured metadata,
4
+ * then applies the shared credential policy (PII stays readable unless explicitly requested).
5
+ * Diagnostic getters, serialization and coercion can themselves fail; fixed fallback text keeps
6
+ * those failures from replacing the original error or interrupting the caller's recovery.
7
+ * @param required.error - Untrusted thrown value; never mutated.
8
+ * @param options - Shared redaction options, including caller-owned exact secrets.
9
+ * @returns Redacted text; never throws, including for circular objects and hostile accessors.
10
+ * @complexity O(n) serialization in the diagnostic's fields/characters, plus shared redaction passes.
11
+ */
12
+ export declare function formatErrorForLog(required: {
13
+ error: unknown;
14
+ }, options?: SecretRedactionOptions): string;
15
+ //# sourceMappingURL=format-error-for-log.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { redactSecrets } from './redact.js';
2
+ /**
3
+ * Universal diagnostic text for any thrown value. Keeps native stacks and structured metadata,
4
+ * then applies the shared credential policy (PII stays readable unless explicitly requested).
5
+ * Diagnostic getters, serialization and coercion can themselves fail; fixed fallback text keeps
6
+ * those failures from replacing the original error or interrupting the caller's recovery.
7
+ * @param required.error - Untrusted thrown value; never mutated.
8
+ * @param options - Shared redaction options, including caller-owned exact secrets.
9
+ * @returns Redacted text; never throws, including for circular objects and hostile accessors.
10
+ * @complexity O(n) serialization in the diagnostic's fields/characters, plus shared redaction passes.
11
+ */
12
+ export function formatErrorForLog(required, options = {}) {
13
+ try {
14
+ const { error } = required;
15
+ let text;
16
+ if (error instanceof Error) {
17
+ const message = String(error.message);
18
+ text = String(error.stack ?? `${error.name}: ${message}`);
19
+ if (!text.includes(message))
20
+ text += `\n${message}`;
21
+ const fields = Object.fromEntries(Object.getOwnPropertyNames(error)
22
+ .filter(key => !['name', 'message', 'stack'].includes(key)).map(key => [key, Reflect.get(error, key)]));
23
+ if (Object.keys(fields).length)
24
+ text += `\n${diagnosticJson({ error: fields }, options)}`;
25
+ }
26
+ else {
27
+ text = error !== null && typeof error === 'object' ? diagnosticJson({ error }, options) : String(error);
28
+ }
29
+ return redactSecrets({ input: text }, { redactPii: false, ...options });
30
+ }
31
+ catch {
32
+ return '[Unformattable error]';
33
+ }
34
+ }
35
+ /** JSON preserves structured fields without coercing objects; track cycles and native Error fields.
36
+ * Property access remains inside formatErrorForLog's recovery boundary. O(n) visited fields. */
37
+ function diagnosticJson({ error }, options = {}) {
38
+ const seen = new WeakSet();
39
+ return JSON.stringify(error, (_key, value) => {
40
+ if (value !== null && typeof value === 'object') {
41
+ if (seen.has(value))
42
+ return '[Circular]';
43
+ seen.add(value);
44
+ if (value instanceof Error)
45
+ return Object.fromEntries(Object.getOwnPropertyNames(value).map(key => [key, Reflect.get(value, key)]));
46
+ }
47
+ // Scrub string contents before JSON escapes their credential labels. Exact-only is kept
48
+ // for the final pass so a caller's literal marker is never reprocessed as a supplied secret.
49
+ if (typeof value === 'string' && options.policy !== 'exact-only') {
50
+ return redactSecrets({ input: value }, { redactPii: false, ...options });
51
+ }
52
+ return typeof value === 'bigint' ? String(value) : value;
53
+ }) ?? String(error);
54
+ }
55
+ //# sourceMappingURL=format-error-for-log.js.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file The host's read-tool vocabulary: how model-facing domain-package text names the host's tool that reads
3
+ * an entity back ("call X to list valid terms", "as returned by X").
4
+ *
5
+ * Why this is a port: the read tool is a host product's tool id (a host publishes its reads as one
6
+ * family, and the engine may not name any host tool — `scripts/check-engine-boundaries.ts`'s
7
+ * `HOST_TOOL_NAMES`). The package text therefore names an *entity* and the host says how it reads it;
8
+ * a host that binds nothing gets neutral wording, so no tool id the host never registered reaches a
9
+ * model. Same mechanism as the daemon's `ToolFamilyPort`: product names reach a model through a
10
+ * host-supplied port, never through engine source.
11
+ *
12
+ * Architectural role: tool kit (with `model-facing-tool-errors`) — domain catalogs write `{{read:<entity>}}` placeholders
13
+ * in static text and `resolveHostReadRefs` fills them when a domain's registrations are built.
14
+ */
15
+ /** An entity whose read-back a domain's tool text points a model at, named by the domain (e.g. `redirect`, `seo_entry_meta`). */
16
+ export type HostReadEntity = string;
17
+ /** How the host names the tool call that reads an entity back. */
18
+ export interface HostReadVocabulary {
19
+ /** The text a model should see for "read this entity", e.g. a host tool id. */
20
+ readonly readRef: (required: {
21
+ entity: HostReadEntity;
22
+ }, optional?: Record<string, never>) => string;
23
+ }
24
+ /** Wording for a host that binds no vocabulary: names the read, never a tool id. */
25
+ export declare const NEUTRAL_HOST_READ_VOCABULARY: HostReadVocabulary;
26
+ /** The placeholder a static catalog text carries for `entity`. */
27
+ export declare function hostReadRef({ entity }: {
28
+ entity: HostReadEntity;
29
+ }, _optional?: {}): string;
30
+ /** Resolves every placeholder in `text` through `hostReads`; text without one is returned as is. */
31
+ export declare function resolveHostReadText({ text }: {
32
+ text: string;
33
+ }, { hostReads }?: {
34
+ hostReads?: HostReadVocabulary | undefined;
35
+ }): string;
36
+ /**
37
+ * Deep-copies `value` with every string resolved by {@link resolveHostReadText}. Used on a domain's
38
+ * static catalog when its registrations are built; the input is never mutated.
39
+ *
40
+ * @complexity O(n) in the catalog's nodes.
41
+ */
42
+ export declare function resolveHostReadRefs<T>({ value }: {
43
+ value: T;
44
+ }, optional?: {
45
+ hostReads?: HostReadVocabulary | undefined;
46
+ }): T;
47
+ //# sourceMappingURL=host-read-vocabulary.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @file The host's read-tool vocabulary: how model-facing domain-package text names the host's tool that reads
3
+ * an entity back ("call X to list valid terms", "as returned by X").
4
+ *
5
+ * Why this is a port: the read tool is a host product's tool id (a host publishes its reads as one
6
+ * family, and the engine may not name any host tool — `scripts/check-engine-boundaries.ts`'s
7
+ * `HOST_TOOL_NAMES`). The package text therefore names an *entity* and the host says how it reads it;
8
+ * a host that binds nothing gets neutral wording, so no tool id the host never registered reaches a
9
+ * model. Same mechanism as the daemon's `ToolFamilyPort`: product names reach a model through a
10
+ * host-supplied port, never through engine source.
11
+ *
12
+ * Architectural role: tool kit (with `model-facing-tool-errors`) — domain catalogs write `{{read:<entity>}}` placeholders
13
+ * in static text and `resolveHostReadRefs` fills them when a domain's registrations are built.
14
+ */
15
+ /** Wording for a host that binds no vocabulary: names the read, never a tool id. */
16
+ export const NEUTRAL_HOST_READ_VOCABULARY = {
17
+ readRef: ({ entity }) => `the ${entity.replaceAll("_", " ")} read tool`,
18
+ };
19
+ /** The placeholder a static catalog text carries for `entity`. */
20
+ export function hostReadRef({ entity }, _optional = {}) {
21
+ return `{{read:${entity}}}`;
22
+ }
23
+ const PLACEHOLDER = /\{\{read:([a-z_]+)\}\}/g;
24
+ /** Resolves every placeholder in `text` through `hostReads`; text without one is returned as is. */
25
+ export function resolveHostReadText({ text }, { hostReads = NEUTRAL_HOST_READ_VOCABULARY } = {}) {
26
+ return text.replace(PLACEHOLDER, (_whole, entity) => hostReads.readRef({ entity: entity }));
27
+ }
28
+ /**
29
+ * Deep-copies `value` with every string resolved by {@link resolveHostReadText}. Used on a domain's
30
+ * static catalog when its registrations are built; the input is never mutated.
31
+ *
32
+ * @complexity O(n) in the catalog's nodes.
33
+ */
34
+ export function resolveHostReadRefs({ value }, optional = {}) {
35
+ if (typeof value === "string")
36
+ return resolveHostReadText({ text: value }, optional);
37
+ if (Array.isArray(value))
38
+ return value.map((item) => resolveHostReadRefs({ value: item }, optional));
39
+ if (value !== null && typeof value === "object") {
40
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, resolveHostReadRefs({ value: item }, optional)]));
41
+ }
42
+ return value;
43
+ }
44
+ //# sourceMappingURL=host-read-vocabulary.js.map
package/dist/index.d.ts CHANGED
@@ -7,6 +7,9 @@ export { createDaemon } from './daemon.js';
7
7
  export type { PackDisposalFailure } from './pack-lifecycle.js';
8
8
  export { disposePacks, registerPackTools } from './pack-lifecycle.js';
9
9
  export * from './redact.js';
10
+ export { type SecretShapePattern, PEM_PATTERN_NAME, SECRET_SHAPE_PATTERNS, createPrivateKeyLineRedactor, AGENT_FAILURE_SECRET_SHAPE_RE, CREDENTIAL_FILE_DENY_SEGMENTS, LOCAL_OWNER_PROXY_MARKER_PREFIXES, LOCAL_OWNER_PROXY_MARKER_HEADERS } from './secret-shapes.js';
11
+ export { type SecretRedactionPattern, GENERATED_MARKER_RE, type SecretRedactionOptions, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE } from './redaction-patterns.js';
12
+ export { formatErrorForLog } from './format-error-for-log.js';
10
13
  export * from './user-facing-error.js';
11
14
  export { onTeardown, runTeardownSteps, type TeardownHost, type TeardownStep } from './teardown.js';
12
15
  export * from './api-token-auth.js';
@@ -20,6 +23,7 @@ export * from './tool-tokens.js';
20
23
  export * from './tool-exposure.js';
21
24
  export * from './gated-mutations.js';
22
25
  export * from './model-facing-tool-errors.js';
26
+ export * from './host-read-vocabulary.js';
23
27
  export { createContributionRegistry } from './contribution-registry.js';
24
28
  export type { ContributionRegistry, ToolContributor, DerivedToolContributor, ToolContributions } from './contribution-registry.js';
25
29
  export * from './provider-registry.js';
@@ -30,7 +34,7 @@ export * from "./registration-kit.js";
30
34
  export * from "./approval.js";
31
35
  export * from './target-scope.js';
32
36
  export * from "./native-regexp.js";
33
- export { ForbiddenError as ToolPermissionDeniedError, requireToolPermission, adaptLegacyAuthorize, type LegacyToolAuthorizeFn, type AuthorizationPort as ToolPermissionAuthorizationPort, type RequireToolPermissionRequired, type RequireToolPermissionOptional, } from "./tool-permissions.js";
37
+ export { ForbiddenError as ToolPermissionDeniedError, requireToolPermission, adaptLegacyAuthorize, type LegacyToolAuthorizeFn, type AuthorizationPort as ToolPermissionAuthorizationPort, type AuthorizationRequired as ToolPermissionAuthorizationRequired, type AuthorizationOptional as ToolPermissionAuthorizationOptional, type RequireToolPermissionRequired, type RequireToolPermissionOptional, } from "./tool-permissions.js";
34
38
  export { evaluateFeatureFlag, type FeatureFlagDecision } from './feature-flags.js';
35
39
  export { normalizeToolInput, withNormalizationNotes, ToolInputNormalizationError, type NormalizedToolInput, type ToolInputNormalizer } from './tool-input-normalization.js';
36
40
  export { decodeToolInputObject, unwrapToolInputEnvelope } from './tool-input-envelope.js';
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ export * from './bindings.js';
5
5
  export { createDaemon } from './daemon.js';
6
6
  export { disposePacks, registerPackTools } from './pack-lifecycle.js';
7
7
  export * from './redact.js';
8
+ export { PEM_PATTERN_NAME, SECRET_SHAPE_PATTERNS, createPrivateKeyLineRedactor, AGENT_FAILURE_SECRET_SHAPE_RE, CREDENTIAL_FILE_DENY_SEGMENTS, LOCAL_OWNER_PROXY_MARKER_PREFIXES, LOCAL_OWNER_PROXY_MARKER_HEADERS } from './secret-shapes.js';
9
+ export { GENERATED_MARKER_RE, LABELED_SECRET_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE } from './redaction-patterns.js';
10
+ export { formatErrorForLog } from './format-error-for-log.js';
8
11
  export * from './user-facing-error.js';
9
12
  export { onTeardown, runTeardownSteps } from './teardown.js';
10
13
  export * from './api-token-auth.js';
@@ -16,6 +19,7 @@ export * from './tool-tokens.js';
16
19
  export * from './tool-exposure.js';
17
20
  export * from './gated-mutations.js';
18
21
  export * from './model-facing-tool-errors.js';
22
+ export * from './host-read-vocabulary.js';
19
23
  export { createContributionRegistry } from './contribution-registry.js';
20
24
  export * from './provider-registry.js';
21
25
  export * from './object-store.js';
@@ -0,0 +1,93 @@
1
+ /** One page of a list. `nextCursor === null` means there is nothing after these items. */
2
+ export interface ListPage<T> {
3
+ readonly items: readonly T[];
4
+ readonly nextCursor: string | null;
5
+ }
6
+ /** A keyset position: the row's sort values, ending with its unique id as the tie-breaker. */
7
+ export type ListPosition = readonly (string | number)[];
8
+ /** The type of each position component, sort keys then id. Given by the caller, never learned from a row. */
9
+ export type ListPositionShape = readonly ('string' | 'number')[];
10
+ /** Hard ceiling when a caller names none — big enough for any screen, small enough for one response. */
11
+ export declare const DEFAULT_MAX_LIST_LIMIT = 200;
12
+ /** Default page size when a caller names none. */
13
+ export declare const DEFAULT_LIST_LIMIT = 50;
14
+ /**
15
+ * Builds the opaque cursor for the row a page ended on.
16
+ * @complexity O(position size).
17
+ */
18
+ export declare function encodeListCursor(required: {
19
+ position: ListPosition;
20
+ }, _optional?: Record<string, never>): string;
21
+ /**
22
+ * Reads a cursor {@link encodeListCursor} built. Refuses anything else instead of restarting from the
23
+ * first page — a silently restarted scan repeats rows forever.
24
+ *
25
+ * @param required.shape - The type of each value in the position (sort keys + id).
26
+ * @throws {ToolInputError} `invalid cursor` (a 400 on HTTP, a correctable input error for a tool).
27
+ * @complexity O(cursor length).
28
+ */
29
+ export declare function decodeListCursor(required: {
30
+ cursor: string;
31
+ shape: ListPositionShape;
32
+ }, _optional?: Record<string, never>): ListPosition;
33
+ /**
34
+ * Reads `{ limit, cursor }` off an untrusted request (query string or tool input). An absent limit
35
+ * becomes the default; a limit above the ceiling is clamped (a caller asking for "everything" gets
36
+ * the most one page holds plus a cursor, never an error); anything malformed is refused.
37
+ *
38
+ * @throws {ToolInputError} for a non-integer/non-positive limit or a non-string cursor.
39
+ * @complexity O(1).
40
+ */
41
+ export declare function parseListPageRequest(required: {
42
+ value: {
43
+ limit?: unknown;
44
+ cursor?: unknown;
45
+ };
46
+ }, optional?: {
47
+ defaultLimit?: number;
48
+ maxLimit?: number;
49
+ }): {
50
+ limit: number;
51
+ cursor: string | null;
52
+ };
53
+ /**
54
+ * Cuts a page from a query that fetched `limit + 1` rows in keyset order. The extra row only proves
55
+ * more exist; it is never returned.
56
+ *
57
+ * @complexity O(limit).
58
+ */
59
+ export declare function pageFromOverfetch<T>(required: {
60
+ rows: readonly T[];
61
+ limit: number;
62
+ positionOf: (row: T) => ListPosition;
63
+ }, _optional?: Record<string, never>): ListPage<T>;
64
+ /**
65
+ * The in-memory twin of a keyset query: sorts by position, keeps rows strictly after the cursor, and
66
+ * cuts a page — so a memory repo and its SQL sibling answer the same contract test identically.
67
+ * Ascending order only; a descending list negates or reverses its sort key in `positionOf`.
68
+ *
69
+ * @complexity O(n log n).
70
+ */
71
+ export declare function pageFromArray<T>(required: {
72
+ rows: readonly T[];
73
+ limit: number;
74
+ cursor: string | null;
75
+ positionOf: (row: T) => ListPosition;
76
+ shape: ListPositionShape;
77
+ }, _optional?: Record<string, never>): ListPage<T>;
78
+ /**
79
+ * What an assistant tool returns for a page: the items, the cursor, and — only when more exist — a
80
+ * plain sentence telling the model the list is NOT complete and exactly how to continue. Without
81
+ * that sentence a model reads 100 rows as "all members".
82
+ *
83
+ * @complexity O(1).
84
+ */
85
+ export declare function listPageForModel<T>(required: {
86
+ page: ListPage<T>;
87
+ toolId: string;
88
+ }, _optional?: Record<string, never>): {
89
+ items: readonly T[];
90
+ nextCursor: string | null;
91
+ more?: string;
92
+ };
93
+ //# sourceMappingURL=list-page.d.ts.map