@jini-ai/core 0.7.1 → 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 (339) hide show
  1. package/README.md +40 -12
  2. package/dist/admin-runtime/admin-api-error.d.ts +68 -0
  3. package/dist/admin-runtime/admin-api-error.js +72 -0
  4. package/dist/admin-runtime/admin-config-error.d.ts +8 -0
  5. package/dist/admin-runtime/admin-config-error.js +11 -0
  6. package/dist/admin-runtime/controller-store.d.ts +20 -0
  7. package/dist/admin-runtime/controller-store.js +32 -0
  8. package/dist/admin-runtime/index.d.ts +13 -0
  9. package/dist/admin-runtime/index.js +12 -0
  10. package/dist/admin-runtime/panel-access.d.ts +88 -0
  11. package/dist/admin-runtime/panel-access.js +76 -0
  12. package/dist/admin-runtime/query-suffix.d.ts +5 -0
  13. package/dist/admin-runtime/query-suffix.js +5 -0
  14. package/dist/agent-handles/element-handles.d.ts +134 -0
  15. package/dist/agent-handles/element-handles.js +45 -0
  16. package/dist/agent-handles/field-descriptor.d.ts +28 -0
  17. package/dist/agent-handles/field-descriptor.js +3 -0
  18. package/dist/agent-handles/handle.d.ts +109 -0
  19. package/dist/agent-handles/handle.js +109 -0
  20. package/dist/agent-handles/index.d.ts +9 -0
  21. package/dist/agent-handles/index.js +6 -0
  22. package/dist/agent-handles/list-handles.d.ts +46 -0
  23. package/dist/agent-handles/list-handles.js +67 -0
  24. package/dist/agent-handles/secret-attrs.d.ts +14 -0
  25. package/dist/agent-handles/secret-attrs.js +13 -0
  26. package/dist/approval-batch-chain.d.ts +45 -0
  27. package/dist/approval-batch-chain.js +75 -0
  28. package/dist/approval.d.ts +33 -14
  29. package/dist/approval.js +57 -43
  30. package/dist/batch-tool-inputs.js +24 -20
  31. package/dist/contracts/admin-module.d.ts +166 -0
  32. package/dist/contracts/admin-module.js +14 -0
  33. package/dist/contracts/agents/definition.d.ts +459 -0
  34. package/dist/contracts/agents/definition.js +2 -0
  35. package/dist/contracts/agents/index.d.ts +7 -0
  36. package/dist/contracts/agents/index.js +2 -0
  37. package/dist/contracts/agents/launch.d.ts +64 -0
  38. package/dist/contracts/agents/launch.js +2 -0
  39. package/dist/contracts/agents/model-catalog.d.ts +213 -0
  40. package/dist/contracts/agents/model-catalog.js +4 -0
  41. package/dist/contracts/agents/native-tool-policy.d.ts +42 -0
  42. package/dist/contracts/agents/native-tool-policy.js +2 -0
  43. package/dist/contracts/ai-trace/capture.d.ts +17 -0
  44. package/dist/contracts/ai-trace/capture.js +43 -0
  45. package/dist/contracts/ai-trace/classify.d.ts +12 -0
  46. package/dist/contracts/ai-trace/classify.js +16 -0
  47. package/dist/contracts/ai-trace/index.d.ts +13 -0
  48. package/dist/contracts/ai-trace/index.js +6 -0
  49. package/dist/contracts/ai-trace/recorder.d.ts +64 -0
  50. package/dist/contracts/ai-trace/recorder.js +283 -0
  51. package/dist/contracts/ai-trace/sinks.d.ts +51 -0
  52. package/dist/contracts/ai-trace/sinks.js +153 -0
  53. package/dist/contracts/ai-trace/types.d.ts +123 -0
  54. package/dist/contracts/ai-trace/types.js +17 -0
  55. package/dist/contracts/ai-trace/usage.d.ts +16 -0
  56. package/dist/contracts/ai-trace/usage.js +45 -0
  57. package/dist/contracts/blob.d.ts +31 -0
  58. package/dist/contracts/blob.js +10 -0
  59. package/dist/contracts/capabilities.d.ts +95 -0
  60. package/dist/contracts/capabilities.js +111 -0
  61. package/dist/contracts/charts.d.ts +75 -0
  62. package/dist/contracts/charts.js +4 -0
  63. package/dist/contracts/env.d.ts +96 -0
  64. package/dist/contracts/env.js +6 -0
  65. package/dist/contracts/events/change-set.d.ts +106 -0
  66. package/dist/contracts/events/change-set.js +2 -0
  67. package/dist/contracts/events/command.d.ts +118 -0
  68. package/dist/contracts/events/command.js +2 -0
  69. package/dist/contracts/events/ports.d.ts +172 -0
  70. package/dist/contracts/events/ports.js +2 -0
  71. package/dist/contracts/events.d.ts +5 -0
  72. package/dist/contracts/events.js +2 -0
  73. package/dist/contracts/forms.d.ts +110 -0
  74. package/dist/contracts/forms.js +4 -0
  75. package/dist/contracts/hosted-mcp/config.d.ts +19 -0
  76. package/dist/contracts/hosted-mcp/record.d.ts +61 -4
  77. package/dist/contracts/mail/email-sender.d.ts +118 -0
  78. package/dist/contracts/mail/email-sender.js +20 -0
  79. package/dist/contracts/mail/smtp-payload.d.ts +32 -0
  80. package/dist/contracts/mail/smtp-payload.js +2 -0
  81. package/dist/contracts/mail.d.ts +2 -0
  82. package/dist/contracts/mail.js +1 -1
  83. package/dist/contracts/observability.d.ts +232 -0
  84. package/dist/contracts/observability.js +27 -0
  85. package/dist/contracts/plugin-sdk.d.ts +186 -0
  86. package/dist/contracts/plugin-sdk.js +39 -0
  87. package/dist/contracts/runtime/command.d.ts +41 -0
  88. package/dist/contracts/runtime/command.js +60 -0
  89. package/dist/contracts/runtime/environment.d.ts +18 -0
  90. package/dist/contracts/runtime/environment.js +26 -0
  91. package/dist/contracts/runtime/file-lock.d.ts +94 -0
  92. package/dist/contracts/runtime/file-lock.js +25 -0
  93. package/dist/contracts/runtime/fs.d.ts +33 -0
  94. package/dist/contracts/runtime/fs.js +2 -0
  95. package/dist/contracts/runtime/http.d.ts +89 -0
  96. package/dist/contracts/runtime/http.js +2 -0
  97. package/dist/contracts/runtime/platform.d.ts +3 -0
  98. package/dist/contracts/runtime/platform.js +2 -0
  99. package/dist/contracts/runtime/process.d.ts +40 -0
  100. package/dist/contracts/runtime/process.js +31 -0
  101. package/dist/contracts/runtime/reader.d.ts +11 -0
  102. package/dist/contracts/runtime/reader.js +2 -0
  103. package/dist/contracts/runtime/terminal.d.ts +99 -0
  104. package/dist/contracts/runtime/terminal.js +2 -0
  105. package/dist/contracts/runtime/testing.d.ts +84 -0
  106. package/dist/contracts/runtime/testing.js +116 -0
  107. package/dist/contracts/runtime.d.ts +10 -0
  108. package/dist/contracts/runtime.js +10 -0
  109. package/dist/contracts/server/api-error.d.ts +43 -0
  110. package/dist/contracts/server/api-error.js +49 -0
  111. package/dist/contracts/server/auth.d.ts +20 -0
  112. package/dist/contracts/server/auth.js +21 -0
  113. package/dist/contracts/server/conformance.d.ts +25 -0
  114. package/dist/contracts/server/conformance.js +50 -0
  115. package/dist/contracts/server/json-route.d.ts +176 -0
  116. package/dist/contracts/server/json-route.js +155 -0
  117. package/dist/contracts/server/middleware.d.ts +35 -0
  118. package/dist/contracts/server/middleware.js +56 -0
  119. package/dist/contracts/server/origin.d.ts +44 -0
  120. package/dist/contracts/server/origin.js +32 -0
  121. package/dist/contracts/server/query.d.ts +16 -0
  122. package/dist/contracts/server/query.js +69 -0
  123. package/dist/contracts/server/rate-limit.d.ts +20 -0
  124. package/dist/contracts/server/rate-limit.js +8 -0
  125. package/dist/contracts/server/request-body.d.ts +26 -0
  126. package/dist/contracts/server/request-body.js +82 -0
  127. package/dist/contracts/server/result.d.ts +17 -0
  128. package/dist/contracts/server/result.js +5 -0
  129. package/dist/contracts/server/route-table.d.ts +54 -0
  130. package/dist/contracts/server/route-table.js +119 -0
  131. package/dist/contracts/server/same-origin-write.d.ts +18 -0
  132. package/dist/contracts/server/same-origin-write.js +31 -0
  133. package/dist/contracts/server/security-headers.d.ts +30 -0
  134. package/dist/contracts/server/security-headers.js +35 -0
  135. package/dist/contracts/server/sse.d.ts +82 -0
  136. package/dist/contracts/server/sse.js +103 -0
  137. package/dist/contracts/server/testing.d.ts +59 -0
  138. package/dist/contracts/server/testing.js +68 -0
  139. package/dist/contracts/server/verified-origin/configured-origin.d.ts +37 -0
  140. package/dist/contracts/server/verified-origin/configured-origin.js +103 -0
  141. package/dist/contracts/server/verified-origin/index.d.ts +7 -0
  142. package/dist/contracts/server/verified-origin/index.js +6 -0
  143. package/dist/contracts/server/verified-origin/loopback-host.d.ts +9 -0
  144. package/dist/contracts/server/verified-origin/loopback-host.js +17 -0
  145. package/dist/contracts/server/verified-origin/origin.d.ts +64 -0
  146. package/dist/contracts/server/verified-origin/origin.js +162 -0
  147. package/dist/contracts/server/verified-origin/ports.d.ts +38 -0
  148. package/dist/contracts/server/verified-origin/ports.js +2 -0
  149. package/dist/contracts/server/verified-origin/repo.memory.d.ts +32 -0
  150. package/dist/contracts/server/verified-origin/repo.memory.js +34 -0
  151. package/dist/contracts/server/verified-origin/site-path.d.ts +113 -0
  152. package/dist/contracts/server/verified-origin/site-path.js +188 -0
  153. package/dist/contracts/server/verified-origin/types.d.ts +33 -0
  154. package/dist/contracts/server/verified-origin/types.js +30 -0
  155. package/dist/contracts/server.d.ts +46 -2
  156. package/dist/contracts/server.js +17 -3
  157. package/dist/contracts/storage/kernel.d.ts +86 -0
  158. package/dist/contracts/storage/kernel.js +38 -0
  159. package/dist/contracts/storage/migration.d.ts +32 -0
  160. package/dist/contracts/storage/migration.js +2 -0
  161. package/dist/contracts/storage/rows.d.ts +33 -0
  162. package/dist/contracts/storage/rows.js +42 -0
  163. package/dist/contracts/storage/sqlite.d.ts +113 -0
  164. package/dist/contracts/storage/sqlite.js +8 -0
  165. package/dist/contracts/storage/values.d.ts +25 -0
  166. package/dist/contracts/storage/values.js +25 -0
  167. package/dist/contracts/storage.d.ts +8 -0
  168. package/dist/contracts/storage.js +6 -0
  169. package/dist/contracts/vault/invariants.d.ts +26 -0
  170. package/dist/contracts/vault/invariants.js +49 -0
  171. package/dist/contracts/vault.d.ts +1 -0
  172. package/dist/contracts/vault.js +1 -1
  173. package/dist/env/coercers.d.ts +21 -0
  174. package/dist/env/coercers.js +68 -0
  175. package/dist/env/describe-env-for-diagnostics.d.ts +16 -0
  176. package/dist/env/describe-env-for-diagnostics.js +23 -0
  177. package/dist/env/format-env-issue.d.ts +13 -0
  178. package/dist/env/format-env-issue.js +22 -0
  179. package/dist/env/parse-env.d.ts +24 -0
  180. package/dist/env/parse-env.js +102 -0
  181. package/dist/env/value-echo.d.ts +17 -0
  182. package/dist/env/value-echo.js +42 -0
  183. package/dist/errors/approved-cause.d.ts +36 -0
  184. package/dist/errors/approved-cause.js +17 -0
  185. package/dist/errors/bindings.d.ts +61 -0
  186. package/dist/errors/bindings.js +57 -0
  187. package/dist/errors/catalog.d.ts +84 -0
  188. package/dist/errors/catalog.js +151 -0
  189. package/dist/errors/disclosure.d.ts +48 -0
  190. package/dist/errors/disclosure.js +27 -0
  191. package/dist/errors/error-id.d.ts +26 -0
  192. package/dist/errors/error-id.js +23 -0
  193. package/dist/errors/idioms.d.ts +73 -0
  194. package/dist/errors/idioms.js +85 -0
  195. package/dist/errors/incident-text.d.ts +16 -0
  196. package/dist/errors/incident-text.js +77 -0
  197. package/dist/errors/reporter.d.ts +94 -0
  198. package/dist/errors/reporter.js +152 -0
  199. package/dist/errors/sentences.d.ts +68 -0
  200. package/dist/errors/sentences.js +93 -0
  201. package/dist/errors/testing.d.ts +50 -0
  202. package/dist/errors/testing.js +44 -0
  203. package/dist/fetch/cache.d.ts +12 -5
  204. package/dist/fetch/cache.js +46 -47
  205. package/dist/fetch/index.d.ts +1 -1
  206. package/dist/fetch/loader-read.d.ts +6 -2
  207. package/dist/fetch/loader-read.js +4 -4
  208. package/dist/format-error-for-log.d.ts +15 -0
  209. package/dist/format-error-for-log.js +55 -0
  210. package/dist/host-read-vocabulary.d.ts +47 -0
  211. package/dist/host-read-vocabulary.js +44 -0
  212. package/dist/index.d.ts +5 -1
  213. package/dist/index.js +4 -0
  214. package/dist/list-page.d.ts +93 -0
  215. package/dist/list-page.js +154 -0
  216. package/dist/model-facing-tool-errors.d.ts +67 -5
  217. package/dist/model-facing-tool-errors.js +155 -19
  218. package/dist/net/endpoint-policy.d.ts +39 -0
  219. package/dist/net/endpoint-policy.js +218 -0
  220. package/dist/net/fetch-timeouts.d.ts +38 -0
  221. package/dist/net/fetch-timeouts.js +31 -0
  222. package/dist/net/index.d.ts +4 -0
  223. package/dist/net/index.js +4 -0
  224. package/dist/net/loopback.d.ts +13 -0
  225. package/dist/net/loopback.js +39 -0
  226. package/dist/optimistic-concurrency.d.ts +183 -0
  227. package/dist/optimistic-concurrency.js +222 -0
  228. package/dist/primitives/errors.d.ts +9 -0
  229. package/dist/primitives/errors.js +12 -0
  230. package/dist/primitives/ids.d.ts +0 -2
  231. package/dist/primitives/ids.js +1 -4
  232. package/dist/primitives/index.d.ts +3 -0
  233. package/dist/primitives/index.js +2 -0
  234. package/dist/primitives/logger.d.ts +36 -1
  235. package/dist/primitives/logger.js +125 -9
  236. package/dist/primitives/node-shape.d.ts +24 -0
  237. package/dist/primitives/node-shape.js +21 -0
  238. package/dist/primitives/time.d.ts +9 -2
  239. package/dist/primitives/time.js +4 -3
  240. package/dist/provider-registry.js +26 -20
  241. package/dist/records.d.ts +40 -7
  242. package/dist/records.js +37 -3
  243. package/dist/redact.d.ts +1 -84
  244. package/dist/redact.js +2 -826
  245. package/dist/redaction-collectors.d.ts +7 -0
  246. package/dist/redaction-collectors.js +152 -0
  247. package/dist/redaction-exact-secrets.d.ts +14 -0
  248. package/dist/redaction-exact-secrets.js +115 -0
  249. package/dist/redaction-labels.d.ts +14 -0
  250. package/dist/redaction-labels.js +156 -0
  251. package/dist/redaction-patterns.d.ts +54 -0
  252. package/dist/redaction-patterns.js +178 -0
  253. package/dist/redaction-spans.d.ts +31 -0
  254. package/dist/redaction-spans.js +83 -0
  255. package/dist/registration-kit.d.ts +1 -1
  256. package/dist/revision-conflict-error.d.ts +18 -0
  257. package/dist/revision-conflict-error.js +20 -0
  258. package/dist/secret-shapes.d.ts +50 -0
  259. package/dist/secret-shapes.js +105 -0
  260. package/dist/settings/agent-tools.js +22 -8
  261. package/dist/settings/agent-value-write-tools.d.ts +4 -1
  262. package/dist/settings/agent-value-write-tools.js +7 -6
  263. package/dist/settings/agent-writable-preferences.d.ts +3 -1
  264. package/dist/settings/agent-writable-preferences.js +1 -1
  265. package/dist/settings/agent-write-denylist.d.ts +7 -4
  266. package/dist/settings/agent-write-denylist.js +1 -1
  267. package/dist/settings/{express/cms-adapter.d.ts → cms-adapter.d.ts} +3 -2
  268. package/dist/settings/{express/cms-adapter.js → cms-adapter.js} +21 -11
  269. package/dist/settings/definitions-dispatch.js +3 -1
  270. package/dist/settings/ensure-definitions.js +3 -1
  271. package/dist/settings/errors.d.ts +1 -13
  272. package/dist/settings/errors.js +2 -15
  273. package/dist/settings/index.d.ts +11 -2
  274. package/dist/settings/index.js +10 -2
  275. package/dist/settings/purge-service.js +63 -86
  276. package/dist/settings/{express/contracts.d.ts → route-policy.d.ts} +53 -47
  277. package/dist/settings/{express/shared.js → route-policy.js} +1 -16
  278. package/dist/settings/settings.d.ts +19 -11
  279. package/dist/settings/settings.js +9 -11
  280. package/dist/settings/tool-registrations.d.ts +3 -3
  281. package/dist/settings/tool-registrations.js +130 -125
  282. package/dist/settings/types.d.ts +1 -1
  283. package/dist/settings/write-definition-rename.d.ts +37 -0
  284. package/dist/settings/write-definition-rename.js +119 -0
  285. package/dist/settings/write-definition-retype.d.ts +61 -0
  286. package/dist/settings/write-definition-retype.js +109 -0
  287. package/dist/settings/write-definition-status.d.ts +81 -0
  288. package/dist/settings/write-definition-status.js +121 -0
  289. package/dist/settings/write-reset.d.ts +34 -0
  290. package/dist/settings/write-reset.js +73 -0
  291. package/dist/settings/write-service.d.ts +16 -287
  292. package/dist/settings/write-service.js +49 -681
  293. package/dist/settings/write-value-revisions.d.ts +68 -0
  294. package/dist/settings/write-value-revisions.js +124 -0
  295. package/dist/settings/write-values.d.ts +96 -0
  296. package/dist/settings/write-values.js +83 -0
  297. package/dist/surface-exchanges.d.ts +2 -2
  298. package/dist/text/dictionary-translator.d.ts +19 -0
  299. package/dist/text/dictionary-translator.js +14 -0
  300. package/dist/text/format-byte-size.d.ts +25 -0
  301. package/dist/text/format-byte-size.js +25 -0
  302. package/dist/text/format-timestamp.d.ts +22 -0
  303. package/dist/text/format-timestamp.js +57 -0
  304. package/dist/text/index.d.ts +12 -0
  305. package/dist/text/index.js +9 -0
  306. package/dist/text/is-abort-error.d.ts +5 -0
  307. package/dist/text/is-abort-error.js +5 -0
  308. package/dist/text/mime.d.ts +5 -0
  309. package/dist/text/mime.js +21 -0
  310. package/dist/text/redact-urls.d.ts +7 -0
  311. package/dist/text/redact-urls.js +5 -0
  312. package/dist/text/resolve-active-tab-id.d.ts +13 -0
  313. package/dist/text/resolve-active-tab-id.js +15 -0
  314. package/dist/text/sanitize-untrusted-text.d.ts +1 -1
  315. package/dist/text/sanitize-untrusted-text.js +2 -1
  316. package/dist/text/tagged-text-suppression.d.ts +103 -0
  317. package/dist/text/tagged-text-suppression.js +143 -0
  318. package/dist/text/template-i18n.d.ts +37 -0
  319. package/dist/text/template-i18n.js +48 -0
  320. package/dist/tool-call-text.d.ts +59 -0
  321. package/dist/tool-call-text.js +62 -0
  322. package/dist/tool-input-envelope.js +8 -4
  323. package/dist/tool-input-normalization.js +8 -1
  324. package/dist/tool-input-repairs.d.ts +58 -0
  325. package/dist/tool-input-repairs.js +154 -0
  326. package/dist/tool-tokens.js +1 -1
  327. package/dist/user-facing-error.d.ts +1 -1
  328. package/dist/user-facing-error.js +3 -1
  329. package/package.json +234 -13
  330. package/dist/settings/express/contracts.js +0 -2
  331. package/dist/settings/express/http-request.d.ts +0 -33
  332. package/dist/settings/express/http-request.js +0 -50
  333. package/dist/settings/express/http.d.ts +0 -10
  334. package/dist/settings/express/http.js +0 -196
  335. package/dist/settings/express/index.d.ts +0 -5
  336. package/dist/settings/express/index.js +0 -4
  337. package/dist/settings/express/shared.d.ts +0 -68
  338. package/dist/settings/express/stream.d.ts +0 -24
  339. package/dist/settings/express/stream.js +0 -171
@@ -0,0 +1,154 @@
1
+ /**
2
+ * @file The one cursor contract for capped lists (refactor pattern "lists cut off at a limit",
3
+ * 2026-11-13).
4
+ *
5
+ * Why it exists: list calls with a limit and no cursor (members 100, newsletter 100, other-site keys
6
+ * 50, visitor assistant 20) returned the first N rows and said nothing, so the admin screen and the
7
+ * assistant both believed they had everything. Forms submissions, trash, comments and the admin
8
+ * entity list already page as `{ items, nextCursor }` over a keyset; this module is that contract
9
+ * once, generic over the sort key, so every remaining list applies the same shape.
10
+ *
11
+ * Contract: request `{ limit?, cursor? }`; response `{ items, nextCursor }` where `nextCursor` is
12
+ * `null` on the last page. The cursor is opaque and carries the POSITION (sort values + id), never a
13
+ * row id to look up, so a page still resumes after the row it ended on is deleted. Forward-only.
14
+ *
15
+ * Storage- and server-neutral: a repo over-fetches `limit + 1` rows in its own query language and
16
+ * hands them to {@link pageFromOverfetch}.
17
+ */
18
+ import { ToolInputError } from './tool-input-errors.js';
19
+ /** Hard ceiling when a caller names none — big enough for any screen, small enough for one response. */
20
+ export const DEFAULT_MAX_LIST_LIMIT = 200;
21
+ /** Default page size when a caller names none. */
22
+ export const DEFAULT_LIST_LIMIT = 50;
23
+ function toBase64Url(text) {
24
+ let binary = '';
25
+ for (const byte of new TextEncoder().encode(text))
26
+ binary += String.fromCharCode(byte);
27
+ return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
28
+ }
29
+ function fromBase64Url(text) {
30
+ const binary = atob(text.replace(/-/g, '+').replace(/_/g, '/'));
31
+ return new TextDecoder('utf-8', { fatal: true }).decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
32
+ }
33
+ /**
34
+ * Builds the opaque cursor for the row a page ended on.
35
+ * @complexity O(position size).
36
+ */
37
+ export function encodeListCursor(required, _optional = {}) {
38
+ return toBase64Url(JSON.stringify(required.position));
39
+ }
40
+ /**
41
+ * Reads a cursor {@link encodeListCursor} built. Refuses anything else instead of restarting from the
42
+ * first page — a silently restarted scan repeats rows forever.
43
+ *
44
+ * @param required.shape - The type of each value in the position (sort keys + id).
45
+ * @throws {ToolInputError} `invalid cursor` (a 400 on HTTP, a correctable input error for a tool).
46
+ * @complexity O(cursor length).
47
+ */
48
+ export function decodeListCursor(required, _optional = {}) {
49
+ let parsed;
50
+ try {
51
+ parsed = JSON.parse(fromBase64Url(required.cursor));
52
+ }
53
+ catch {
54
+ throw new ToolInputError({ message: 'invalid cursor: pass the nextCursor value from the previous page unchanged' });
55
+ }
56
+ if (!Array.isArray(parsed) ||
57
+ parsed.length !== required.shape.length ||
58
+ !parsed.every((value, index) => required.shape[index] === 'number' ? typeof value === 'number' && Number.isFinite(value) : typeof value === 'string')) {
59
+ throw new ToolInputError({ message: 'invalid cursor: pass the nextCursor value from the previous page unchanged' });
60
+ }
61
+ return parsed;
62
+ }
63
+ /**
64
+ * Reads `{ limit, cursor }` off an untrusted request (query string or tool input). An absent limit
65
+ * becomes the default; a limit above the ceiling is clamped (a caller asking for "everything" gets
66
+ * the most one page holds plus a cursor, never an error); anything malformed is refused.
67
+ *
68
+ * @throws {ToolInputError} for a non-integer/non-positive limit or a non-string cursor.
69
+ * @complexity O(1).
70
+ */
71
+ export function parseListPageRequest(required, optional = {}) {
72
+ const maxLimit = optional.maxLimit ?? DEFAULT_MAX_LIST_LIMIT;
73
+ const defaultLimit = Math.min(optional.defaultLimit ?? DEFAULT_LIST_LIMIT, maxLimit);
74
+ const rawLimit = readRawLimit({ limit: required.value.limit });
75
+ const rawCursor = readRawCursor({ cursor: required.value.cursor });
76
+ return { limit: Math.min(rawLimit ?? defaultLimit, maxLimit), cursor: typeof rawCursor === 'string' ? rawCursor : null };
77
+ }
78
+ /** A digit-only string limit is coerced; anything that is not a positive safe integer is refused. */
79
+ function readRawLimit({ limit }, _optional = {}) {
80
+ const rawLimit = typeof limit === 'string' && /^\d+$/.test(limit) ? Number(limit) : limit;
81
+ if (rawLimit !== undefined && (typeof rawLimit !== 'number' || !Number.isSafeInteger(rawLimit) || rawLimit < 1)) {
82
+ throw new ToolInputError({ message: "'limit' must be a whole number of at least 1" });
83
+ }
84
+ return rawLimit;
85
+ }
86
+ /** A cursor is absent (undefined/null) or a non-empty string; anything else is refused. */
87
+ function readRawCursor({ cursor }, _optional = {}) {
88
+ if (cursor !== undefined && cursor !== null && (typeof cursor !== 'string' || cursor.length === 0)) {
89
+ throw new ToolInputError({ message: "'cursor' must be the nextCursor string from the previous page" });
90
+ }
91
+ return cursor;
92
+ }
93
+ /**
94
+ * Cuts a page from a query that fetched `limit + 1` rows in keyset order. The extra row only proves
95
+ * more exist; it is never returned.
96
+ *
97
+ * @complexity O(limit).
98
+ */
99
+ export function pageFromOverfetch(required, _optional = {}) {
100
+ const items = required.rows.slice(0, required.limit);
101
+ const last = items[items.length - 1];
102
+ const hasMore = required.rows.length > required.limit;
103
+ return { items, nextCursor: hasMore && last !== undefined ? encodeListCursor({ position: required.positionOf(last) }) : null };
104
+ }
105
+ function comparePositions(left, right) {
106
+ for (let index = 0; index < left.length; index += 1) {
107
+ const a = left[index];
108
+ const b = right[index];
109
+ if (a === b)
110
+ continue;
111
+ return compareUnequal(a, b);
112
+ }
113
+ return 0;
114
+ }
115
+ /** Orders two unequal position parts: numerically when both are numbers, else by string. */
116
+ function compareUnequal(a, b) {
117
+ if (typeof a === 'number' && typeof b === 'number')
118
+ return a < b ? -1 : 1;
119
+ return String(a) < String(b) ? -1 : 1;
120
+ }
121
+ /**
122
+ * The in-memory twin of a keyset query: sorts by position, keeps rows strictly after the cursor, and
123
+ * cuts a page — so a memory repo and its SQL sibling answer the same contract test identically.
124
+ * Ascending order only; a descending list negates or reverses its sort key in `positionOf`.
125
+ *
126
+ * @complexity O(n log n).
127
+ */
128
+ export function pageFromArray(required, _optional = {}) {
129
+ // The shape comes from the caller, never from a row, so an empty list still validates the cursor.
130
+ const marker = required.cursor === null ? null : decodeListCursor({ cursor: required.cursor, shape: required.shape });
131
+ const sorted = [...required.rows].sort((a, b) => comparePositions(required.positionOf(a), required.positionOf(b)));
132
+ const after = marker === null ? sorted : sorted.filter((row) => comparePositions(required.positionOf(row), marker) > 0);
133
+ return pageFromOverfetch({ rows: after.slice(0, required.limit + 1), limit: required.limit, positionOf: required.positionOf });
134
+ }
135
+ /**
136
+ * What an assistant tool returns for a page: the items, the cursor, and — only when more exist — a
137
+ * plain sentence telling the model the list is NOT complete and exactly how to continue. Without
138
+ * that sentence a model reads 100 rows as "all members".
139
+ *
140
+ * @complexity O(1).
141
+ */
142
+ export function listPageForModel(required, _optional = {}) {
143
+ const { page } = required;
144
+ if (page.nextCursor === null)
145
+ return { items: page.items, nextCursor: null };
146
+ return {
147
+ items: page.items,
148
+ nextCursor: page.nextCursor,
149
+ more: `This is NOT the full list: ${page.items.length} shown and more exist. ` +
150
+ `To see the rest, call ${required.toolId} again with the same filters and cursor set to nextCursor. ` +
151
+ 'Do not tell the person this is everything.',
152
+ };
153
+ }
154
+ //# sourceMappingURL=list-page.js.map
@@ -171,19 +171,81 @@ export declare function callerSafeErrorMessage(required: {
171
171
  rules: readonly CallerSafeErrorRule[];
172
172
  fallback: string;
173
173
  }): string;
174
+ /** The built-in approved codes `describeErrorForLog` may print. Never written after load. */
175
+ export declare const LOGGABLE_ERROR_CODES: ReadonlySet<string>;
176
+ type ErrorClass = abstract new (...args: never[]) => Error;
177
+ /** A registered error class and the fixed label it is logged as. */
178
+ type LabelledErrorClass = {
179
+ readonly error: ErrorClass;
180
+ readonly label: string;
181
+ };
182
+ /** One package's additions to what a describer may print. */
183
+ export interface ErrorDescriberVocabulary {
184
+ /** Constant codes the package's own errors set (`PLUGIN_ID_CONFLICT`). */
185
+ readonly codes?: readonly string[];
186
+ /** The package's own error classes and the fixed label each is logged as. */
187
+ readonly classes?: readonly LabelledErrorClass[];
188
+ }
189
+ /** The describers returned by {@link createErrorDescriber}. */
190
+ export interface ErrorDescriber {
191
+ describeErrorParts(required: {
192
+ err: unknown;
193
+ }, _optional?: Record<string, never>): ErrorLogParts;
194
+ describeErrorForLog(required: {
195
+ err: unknown;
196
+ }, _optional?: Record<string, never>): string;
197
+ }
198
+ /** The fixed class label and approved code of one value, as {@link describeErrorForLog} prints them. */
199
+ export interface ErrorLogParts {
200
+ /** A fixed class label (`TypeError`, a registered label), `typeof` for a non-`Error`, or `[diagnostic unavailable]`. */
201
+ readonly label: string;
202
+ /** An approved code (`ECONNREFUSED`); absent when the value has none. */
203
+ readonly code?: string;
204
+ }
174
205
  /**
175
- * What a server-side log line may say about an error whose message is NOT known to be safe: its class
176
- * name, a constant-token `code`, and the same for its direct `cause`. Never the message, which can
177
- * quote a secret — `JSON.parse` quotes its input, and a sealer is handed plaintext.
206
+ * The same fixed class label and approved code {@link describeErrorForLog} prints, as fields, without
207
+ * the cause. For a caller that needs one low-cardinality label (a telemetry `error.type`) rather than a
208
+ * log line, so it never parses `Label(CODE) cause=…`. Same guarantee: no message, no raw `name`, no
209
+ * unapproved code.
210
+ * @param required.err - The caught value.
211
+ * @returns `{ label }` or `{ label, code }`. Never throws.
212
+ * @complexity O(registered classes).
213
+ */
214
+ export declare function describeErrorParts(required: {
215
+ err: unknown;
216
+ }, _optional?: Record<string, never>): ErrorLogParts;
217
+ /**
218
+ * What a log line may say about an error whose message is NOT known to be safe: a fixed class label
219
+ * (built-in classes, core's `ToolInputError`, classes packages registered, or the well-known
220
+ * `AbortError`/`TimeoutError` names), an approved `code`, and the same for its direct `cause`. Never
221
+ * the message, the stack, the class's or instance's own `name`, or any other field: they can quote
222
+ * a secret — `JSON.parse` quotes its input, a sealer is handed plaintext, a class name is just text.
178
223
  *
179
224
  * Use it wherever the raw message could carry a credential. Where a class's message is designed for
180
225
  * logs (`EgressRefusedError.message`), log that instead.
181
226
  *
182
227
  * @param required.err - The caught value.
183
- * @returns e.g. `SqliteError(SQLITE_BUSY)`, or `TypeError cause=Error(ECONNREFUSED)`.
184
- * @complexity O(1).
228
+ * Never throws: an error that cannot be inspected is described as `[diagnostic unavailable]` (an
229
+ * unreadable cause as `cause=[diagnostic unavailable]`, an unreadable code is left out), so call it
230
+ * directly inside a catch block. Full detail belongs to a host sink, which receives the error object.
231
+ *
232
+ * @returns e.g. `Error(SQLITE_BUSY)`, or `TypeError cause=Error(ECONNREFUSED)`.
233
+ * @complexity O(registered classes); reads only the value and its direct cause, each field once.
185
234
  */
186
235
  export declare function describeErrorForLog(required: {
187
236
  err: unknown;
188
237
  }, _optional?: Record<string, never>): string;
238
+ /**
239
+ * Builds a describer that also names a package's own error classes and constant codes. The built-in
240
+ * describers are untouched: the returned one reads a new set (built-in codes plus `codes`), so a
241
+ * code added for one describer is not loggable through another. Nothing a caught value carries can
242
+ * extend the vocabulary.
243
+ * @param required.codes Constant tokens (`[A-Z][A-Z0-9_]*`, at most 64 chars).
244
+ * @param required.classes Error classes with an identifier label.
245
+ * @returns `{ describeErrorParts, describeErrorForLog }` over the extended vocabulary.
246
+ * @throws TypeError for a code or label of any other shape (a programming error).
247
+ * @complexity O(codes + classes) to build; O(classes) per described value.
248
+ */
249
+ export declare function createErrorDescriber(required: ErrorDescriberVocabulary, _optional?: Record<string, never>): ErrorDescriber;
250
+ export {};
189
251
  //# sourceMappingURL=model-facing-tool-errors.d.ts.map
@@ -163,33 +163,169 @@ export function callerSafeErrorMessage(required) {
163
163
  }
164
164
  return fallback;
165
165
  }
166
- /** A driver/system error code worth logging (`SQLITE_READONLY`, `ECONNREFUSED`, `ERR_INVALID_CHAR`) —
167
- * a short constant token, never free text that could carry a value. */
168
- const LOGGABLE_ERROR_CODE = /^[A-Z][A-Z0-9_]{0,63}$/;
169
- /** `ClassName` or `ClassName(CODE)` for one thrown value; `typeof` for a non-`Error` throw. */
170
- function describeOneErrorForLog(value) {
171
- if (!(value instanceof Error))
172
- return typeof value;
173
- const className = value.constructor.name || "Error";
174
- const code = value.code;
175
- return typeof code === "string" && LOGGABLE_ERROR_CODE.test(code) ? `${className}(${code})` : className;
166
+ /** A constant token: the only shape a registered code may have (checked once, at registration). */
167
+ const CONSTANT_TOKEN = /^[A-Z][A-Z0-9_]{0,63}$/;
168
+ /** A class label: an identifier, checked once when a describer is built. */
169
+ const CLASS_LABEL = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
170
+ // Codes are approved by listing, never by shape: an uppercase run is not evidence that a value is a
171
+ // code (a token or key can look exactly like one). A package adds its own constants through
172
+ // `createErrorDescriber`, which builds a separate describer and never mutates this built-in list.
173
+ const LOGGABLE_CODES = new Set([
174
+ // Node system errors: every libuv errno name (`util.getSystemErrorMap()`), plus dns's ENOTFOUND.
175
+ // why: owner ruling 2026-11-15: errno names are fixed vocabulary, not user text. Kept as a list,
176
+ // not an `E[A-Z0-9_]+` rule, because a thrown value's `code` is caller text and could be a secret.
177
+ "E2BIG", "EACCES", "EADDRINUSE", "EADDRNOTAVAIL", "EAFNOSUPPORT", "EAGAIN", "EAI_ADDRFAMILY", "EAI_AGAIN",
178
+ "EAI_BADFLAGS", "EAI_BADHINTS", "EAI_CANCELED", "EAI_FAIL", "EAI_FAMILY", "EAI_MEMORY", "EAI_NODATA",
179
+ "EAI_NONAME", "EAI_OVERFLOW", "EAI_PROTOCOL", "EAI_SERVICE", "EAI_SOCKTYPE", "EALREADY", "EBADF", "EBUSY",
180
+ "ECANCELED", "ECHARSET", "ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "EDESTADDRREQ", "EEXIST", "EFAULT",
181
+ "EFBIG", "EFTYPE", "EHOSTDOWN", "EHOSTUNREACH", "EILSEQ", "EINTR", "EINVAL", "EIO", "EISCONN", "EISDIR",
182
+ "ELOOP", "EMFILE", "EMLINK", "EMSGSIZE", "ENAMETOOLONG", "ENETDOWN", "ENETUNREACH", "ENFILE", "ENOBUFS",
183
+ "ENODATA", "ENODEV", "ENOENT", "ENOEXEC", "ENOMEM", "ENONET", "ENOPROTOOPT", "ENOSPC", "ENOSYS",
184
+ "ENOTCONN", "ENOTDIR", "ENOTEMPTY", "ENOTFOUND", "ENOTSOCK", "ENOTSUP", "ENOTTY", "ENXIO", "EOF",
185
+ "EOVERFLOW", "EPERM", "EPIPE", "EPROTO", "EPROTONOSUPPORT", "EPROTOTYPE", "ERANGE", "EREMOTEIO", "EROFS",
186
+ "ESHUTDOWN", "ESOCKTNOSUPPORT", "ESPIPE", "ESRCH", "ETIMEDOUT", "ETXTBSY", "EUNATCH", "EXDEV",
187
+ // Node and undici (fetch)
188
+ "ABORT_ERR", "ERR_INVALID_ARG_TYPE", "ERR_INVALID_ARG_VALUE", "ERR_INVALID_CHAR", "ERR_INVALID_URL",
189
+ "ERR_SOCKET_CLOSED", "ERR_STREAM_PREMATURE_CLOSE", "UND_ERR_ABORTED", "UND_ERR_BODY_TIMEOUT",
190
+ "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_SOCKET",
191
+ // SQLite
192
+ "SQLITE_BUSY", "SQLITE_CANTOPEN", "SQLITE_CONSTRAINT", "SQLITE_CONSTRAINT_UNIQUE", "SQLITE_CORRUPT",
193
+ "SQLITE_FULL", "SQLITE_IOERR", "SQLITE_LOCKED", "SQLITE_READONLY",
194
+ ]);
195
+ /** The built-in approved codes `describeErrorForLog` may print. Never written after load. */
196
+ export const LOGGABLE_ERROR_CODES = LOGGABLE_CODES;
197
+ /** Built-in classes, most specific first. The label is a literal, never read from the value: a
198
+ * class's or an instance's `name` is caller-controlled text and can carry a credential. */
199
+ const BUILT_IN_ERROR_LABELS = [
200
+ [ToolInputError, "ToolInputError"],
201
+ [AggregateError, "AggregateError"],
202
+ [TypeError, "TypeError"],
203
+ [RangeError, "RangeError"],
204
+ [SyntaxError, "SyntaxError"],
205
+ [ReferenceError, "ReferenceError"],
206
+ [URIError, "URIError"],
207
+ [EvalError, "EvalError"],
208
+ ];
209
+ /** `name` values worth naming (DOMException and Node abort/timeout errors). Printed only when the
210
+ * value equals one of these fixed strings. */
211
+ const WELL_KNOWN_ERROR_NAMES = new Set(["AbortError", "TimeoutError"]);
212
+ const BUILT_IN_VOCABULARY = { codes: LOGGABLE_CODES, classes: [] };
213
+ /** Fixed text logged when an error object cannot even be inspected. */
214
+ const UNDESCRIBABLE_ERROR = "[diagnostic unavailable]";
215
+ /** A field whose getter threw. */
216
+ const UNREADABLE = Symbol("unreadable field");
217
+ // A log call sits inside a catch block. If describing the error throws (a throwing getter, a revoked
218
+ // Proxy), the logger replaces the real failure with its own, so every read of the caught value is
219
+ // guarded HERE, once — callers must not wrap this in try/catch. Each field is read at most once, so a
220
+ // getter cannot pass a check with one value and be printed with another.
221
+ /** One field of a caught error, read once; `UNREADABLE` when its getter throws. */
222
+ function readFieldOnce({ value, key }) {
223
+ try {
224
+ return value[key];
225
+ }
226
+ catch {
227
+ return UNREADABLE;
228
+ }
229
+ }
230
+ /** A fixed label chosen by class checks. Throws only when `instanceof` itself throws. */
231
+ function errorClassLabel({ value, vocabulary }) {
232
+ for (let index = vocabulary.classes.length - 1; index >= 0; index -= 1) {
233
+ const entry = vocabulary.classes[index];
234
+ if (entry !== undefined && value instanceof entry.error)
235
+ return entry.label;
236
+ }
237
+ const builtIn = BUILT_IN_ERROR_LABELS.find(([errorClass]) => value instanceof errorClass);
238
+ if (builtIn !== undefined)
239
+ return builtIn[1];
240
+ const name = readFieldOnce({ value, key: "name" });
241
+ return typeof name === "string" && WELL_KNOWN_ERROR_NAMES.has(name) ? name : "Error";
242
+ }
243
+ /** Label and approved code for one thrown value, plus its direct cause when asked for. Never throws. */
244
+ function readErrorParts({ value, vocabulary }, { withCause = false } = {}) {
245
+ try {
246
+ if (!(value instanceof Error))
247
+ return { label: typeof value };
248
+ const label = errorClassLabel({ value, vocabulary });
249
+ const code = readFieldOnce({ value, key: "code" });
250
+ const parts = typeof code === "string" && vocabulary.codes.has(code) ? { label, code } : { label };
251
+ return withCause ? { ...parts, cause: readFieldOnce({ value, key: "cause" }) } : parts;
252
+ }
253
+ catch {
254
+ return { label: UNDESCRIBABLE_ERROR };
255
+ }
256
+ }
257
+ /** `Label` or `Label(CODE)` for one thrown value, plus its direct cause when asked for. Never throws. */
258
+ function describeValueForLog({ value, vocabulary }, { withCause = false } = {}) {
259
+ const { label, code, cause } = readErrorParts({ value, vocabulary }, { withCause });
260
+ const text = code === undefined ? label : `${label}(${code})`;
261
+ return withCause ? { text, cause } : { text };
176
262
  }
177
263
  /**
178
- * What a server-side log line may say about an error whose message is NOT known to be safe: its class
179
- * name, a constant-token `code`, and the same for its direct `cause`. Never the message, which can
180
- * quote a secret — `JSON.parse` quotes its input, and a sealer is handed plaintext.
264
+ * The same fixed class label and approved code {@link describeErrorForLog} prints, as fields, without
265
+ * the cause. For a caller that needs one low-cardinality label (a telemetry `error.type`) rather than a
266
+ * log line, so it never parses `Label(CODE) cause=…`. Same guarantee: no message, no raw `name`, no
267
+ * unapproved code.
268
+ * @param required.err - The caught value.
269
+ * @returns `{ label }` or `{ label, code }`. Never throws.
270
+ * @complexity O(registered classes).
271
+ */
272
+ export function describeErrorParts(required, _optional = {}) {
273
+ return partsFor({ err: required.err, vocabulary: BUILT_IN_VOCABULARY });
274
+ }
275
+ function partsFor({ err, vocabulary }) {
276
+ const { label, code } = readErrorParts({ value: err, vocabulary });
277
+ return code === undefined ? { label } : { label, code };
278
+ }
279
+ /**
280
+ * What a log line may say about an error whose message is NOT known to be safe: a fixed class label
281
+ * (built-in classes, core's `ToolInputError`, classes packages registered, or the well-known
282
+ * `AbortError`/`TimeoutError` names), an approved `code`, and the same for its direct `cause`. Never
283
+ * the message, the stack, the class's or instance's own `name`, or any other field: they can quote
284
+ * a secret — `JSON.parse` quotes its input, a sealer is handed plaintext, a class name is just text.
181
285
  *
182
286
  * Use it wherever the raw message could carry a credential. Where a class's message is designed for
183
287
  * logs (`EgressRefusedError.message`), log that instead.
184
288
  *
185
289
  * @param required.err - The caught value.
186
- * @returns e.g. `SqliteError(SQLITE_BUSY)`, or `TypeError cause=Error(ECONNREFUSED)`.
187
- * @complexity O(1).
290
+ * Never throws: an error that cannot be inspected is described as `[diagnostic unavailable]` (an
291
+ * unreadable cause as `cause=[diagnostic unavailable]`, an unreadable code is left out), so call it
292
+ * directly inside a catch block. Full detail belongs to a host sink, which receives the error object.
293
+ *
294
+ * @returns e.g. `Error(SQLITE_BUSY)`, or `TypeError cause=Error(ECONNREFUSED)`.
295
+ * @complexity O(registered classes); reads only the value and its direct cause, each field once.
188
296
  */
189
297
  export function describeErrorForLog(required, _optional = {}) {
190
- const { err } = required;
191
- const described = describeOneErrorForLog(err);
192
- const cause = err instanceof Error ? err.cause : undefined;
193
- return cause === undefined ? described : `${described} cause=${describeOneErrorForLog(cause)}`;
298
+ return lineFor({ err: required.err, vocabulary: BUILT_IN_VOCABULARY });
299
+ }
300
+ function lineFor({ err, vocabulary }) {
301
+ const head = describeValueForLog({ value: err, vocabulary }, { withCause: true });
302
+ if (head.cause === undefined)
303
+ return head.text;
304
+ const cause = head.cause === UNREADABLE ? UNDESCRIBABLE_ERROR : describeValueForLog({ value: head.cause, vocabulary }).text;
305
+ return `${head.text} cause=${cause}`;
306
+ }
307
+ /**
308
+ * Builds a describer that also names a package's own error classes and constant codes. The built-in
309
+ * describers are untouched: the returned one reads a new set (built-in codes plus `codes`), so a
310
+ * code added for one describer is not loggable through another. Nothing a caught value carries can
311
+ * extend the vocabulary.
312
+ * @param required.codes Constant tokens (`[A-Z][A-Z0-9_]*`, at most 64 chars).
313
+ * @param required.classes Error classes with an identifier label.
314
+ * @returns `{ describeErrorParts, describeErrorForLog }` over the extended vocabulary.
315
+ * @throws TypeError for a code or label of any other shape (a programming error).
316
+ * @complexity O(codes + classes) to build; O(classes) per described value.
317
+ */
318
+ export function createErrorDescriber(required, _optional = {}) {
319
+ const { codes = [], classes = [] } = required;
320
+ const badCode = codes.find(code => !CONSTANT_TOKEN.test(code));
321
+ if (badCode !== undefined)
322
+ throw new TypeError("createErrorDescriber: a code must be a constant token like PLUGIN_ID_CONFLICT.");
323
+ if (classes.some(entry => !CLASS_LABEL.test(entry.label)))
324
+ throw new TypeError("createErrorDescriber: a class label must be an identifier.");
325
+ const vocabulary = { codes: new Set([...LOGGABLE_CODES, ...codes]), classes: [...classes] };
326
+ return {
327
+ describeErrorParts: (args, _optional = {}) => partsFor({ err: args.err, vocabulary }),
328
+ describeErrorForLog: (args, _optional = {}) => lineFor({ err: args.err, vocabulary }),
329
+ };
194
330
  }
195
331
  //# sourceMappingURL=model-facing-tool-errors.js.map
@@ -0,0 +1,39 @@
1
+ /** Expand an IPv6 literal (with `::` compression and/or an embedded dotted
2
+ * IPv4 tail) into its eight 16-bit groups, or null if it does not parse.
3
+ * Node's URL parser normalizes mapped literals to hex (`::ffff:127.0.0.1` →
4
+ * `::ffff:7f00:1`), so a string regex can't reliably spot the mapped range —
5
+ * we have to canonicalize.
6
+ *
7
+ * Exported (previously module-private) so its parse-failure guards are
8
+ * directly unit-testable: the IP classifier and guarded client gate
9
+ * calls behind `net.isIP(addr) === 6`, and Node's `isIP` already fully
10
+ * validates IPv6 syntax (including embedded-IPv4-tail octet ranges) before
11
+ * returning 6 — empirically verified in the original extraction by fuzzing ~10k
12
+ * `isIP`-accepted v6 literals through this function's guards with zero
13
+ * hits — so none of these guards are reachable through that path. They stay
14
+ * as real defense-in-depth (fail closed with `null` rather than trust a
15
+ * platform primitive never changing behavior), matching the asset cache's
16
+ * exported-for-direct-testing precedent (`readBodyCapped`'s abort parameter). */
17
+ export declare function expandIpv6({ address: addr }: {
18
+ address: string;
19
+ }): number[] | null;
20
+ export type AddressClass = 'public' | 'private' | 'loopback' | 'link-local' | 'reserved';
21
+ /** Pure literal classifier; null means malformed input or a hostname requiring DNS. */
22
+ export declare function classifyAddressLiteral({ address }: {
23
+ address: string;
24
+ }, _options?: Record<string, never>): AddressClass | null;
25
+ /** True for localhost and literal loopback, including embedded IPv4 forms. */
26
+ export declare function isLoopbackApiHost({ hostname }: {
27
+ hostname: string;
28
+ }): boolean;
29
+ /** Private/reserved literal hosts are blocked; configured local servers keep their loopback exception. */
30
+ export declare function isBlockedExternalApiHostname({ hostname }: {
31
+ hostname: string;
32
+ }): boolean;
33
+ /** Literal policy for a hostname from a deployed endpoint URL: local names and reserved
34
+ * addresses are excluded. DNS reachability remains the deployment host's responsibility.
35
+ * @complexity O(hostname length), no DNS or other I/O. */
36
+ export declare function isDeployedApiHostname({ hostname }: {
37
+ hostname: string;
38
+ }, _optional?: Record<string, never>): boolean;
39
+ //# sourceMappingURL=endpoint-policy.d.ts.map