@namzu/sdk 5.0.0 → 5.2.0

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 (181) hide show
  1. package/CHANGELOG.md +463 -0
  2. package/README.md +2 -2
  3. package/dist/agents/__tests__/run-agent-forwarding.test.d.ts +2 -0
  4. package/dist/agents/__tests__/run-agent-forwarding.test.d.ts.map +1 -0
  5. package/dist/agents/__tests__/run-agent-forwarding.test.js +76 -0
  6. package/dist/agents/__tests__/run-agent-forwarding.test.js.map +1 -0
  7. package/dist/agents/__tests__/run-completed-stop-reason.test.d.ts +2 -0
  8. package/dist/agents/__tests__/run-completed-stop-reason.test.d.ts.map +1 -0
  9. package/dist/agents/__tests__/run-completed-stop-reason.test.js +50 -0
  10. package/dist/agents/__tests__/run-completed-stop-reason.test.js.map +1 -0
  11. package/dist/agents/index.d.ts +1 -0
  12. package/dist/agents/index.d.ts.map +1 -1
  13. package/dist/agents/index.js +4 -0
  14. package/dist/agents/index.js.map +1 -1
  15. package/dist/agents/runAgent.d.ts +34 -0
  16. package/dist/agents/runAgent.d.ts.map +1 -1
  17. package/dist/agents/runAgent.js +5 -3
  18. package/dist/agents/runAgent.js.map +1 -1
  19. package/dist/config/runtime.d.ts +30 -30
  20. package/dist/constants/tools/__tests__/dangerous-patterns.test.d.ts +2 -0
  21. package/dist/constants/tools/__tests__/dangerous-patterns.test.d.ts.map +1 -0
  22. package/dist/constants/tools/__tests__/dangerous-patterns.test.js +54 -0
  23. package/dist/constants/tools/__tests__/dangerous-patterns.test.js.map +1 -0
  24. package/dist/constants/tools/index.d.ts.map +1 -1
  25. package/dist/constants/tools/index.js +28 -1
  26. package/dist/constants/tools/index.js.map +1 -1
  27. package/dist/contracts/a2a.d.ts +44 -44
  28. package/dist/directory/__tests__/derive.test.d.ts +2 -0
  29. package/dist/directory/__tests__/derive.test.d.ts.map +1 -0
  30. package/dist/directory/__tests__/derive.test.js +111 -0
  31. package/dist/directory/__tests__/derive.test.js.map +1 -0
  32. package/dist/directory/__tests__/load-diagnostics.test.d.ts +2 -0
  33. package/dist/directory/__tests__/load-diagnostics.test.d.ts.map +1 -0
  34. package/dist/directory/__tests__/load-diagnostics.test.js +106 -0
  35. package/dist/directory/__tests__/load-diagnostics.test.js.map +1 -0
  36. package/dist/directory/__tests__/load-directory.test.d.ts +2 -0
  37. package/dist/directory/__tests__/load-directory.test.d.ts.map +1 -0
  38. package/dist/directory/__tests__/load-directory.test.js +196 -0
  39. package/dist/directory/__tests__/load-directory.test.js.map +1 -0
  40. package/dist/directory/__tests__/subagents.test.d.ts +2 -0
  41. package/dist/directory/__tests__/subagents.test.d.ts.map +1 -0
  42. package/dist/directory/__tests__/subagents.test.js +117 -0
  43. package/dist/directory/__tests__/subagents.test.js.map +1 -0
  44. package/dist/directory/__tests__/supervisor-budget.test.d.ts +2 -0
  45. package/dist/directory/__tests__/supervisor-budget.test.d.ts.map +1 -0
  46. package/dist/directory/__tests__/supervisor-budget.test.js +97 -0
  47. package/dist/directory/__tests__/supervisor-budget.test.js.map +1 -0
  48. package/dist/directory/derive-supervisor.d.ts +58 -0
  49. package/dist/directory/derive-supervisor.d.ts.map +1 -0
  50. package/dist/directory/derive-supervisor.js +88 -0
  51. package/dist/directory/derive-supervisor.js.map +1 -0
  52. package/dist/directory/derive.d.ts +12 -0
  53. package/dist/directory/derive.d.ts.map +1 -0
  54. package/dist/directory/derive.js +58 -0
  55. package/dist/directory/derive.js.map +1 -0
  56. package/dist/directory/index.d.ts +7 -0
  57. package/dist/directory/index.d.ts.map +1 -0
  58. package/dist/directory/index.js +5 -0
  59. package/dist/directory/index.js.map +1 -0
  60. package/dist/directory/load.d.ts +14 -0
  61. package/dist/directory/load.d.ts.map +1 -0
  62. package/dist/directory/load.js +488 -0
  63. package/dist/directory/load.js.map +1 -0
  64. package/dist/directory/scan.d.ts +36 -0
  65. package/dist/directory/scan.d.ts.map +1 -0
  66. package/dist/directory/scan.js +136 -0
  67. package/dist/directory/scan.js.map +1 -0
  68. package/dist/directory/types.d.ts +215 -0
  69. package/dist/directory/types.d.ts.map +1 -0
  70. package/dist/directory/types.js +8 -0
  71. package/dist/directory/types.js.map +1 -0
  72. package/dist/plugin/__tests__/path-containment.test.d.ts +2 -0
  73. package/dist/plugin/__tests__/path-containment.test.d.ts.map +1 -0
  74. package/dist/plugin/__tests__/path-containment.test.js +91 -0
  75. package/dist/plugin/__tests__/path-containment.test.js.map +1 -0
  76. package/dist/plugin/lifecycle.d.ts.map +1 -1
  77. package/dist/plugin/lifecycle.js +3 -3
  78. package/dist/plugin/lifecycle.js.map +1 -1
  79. package/dist/plugin/loader.d.ts.map +1 -1
  80. package/dist/plugin/loader.js +12 -2
  81. package/dist/plugin/loader.js.map +1 -1
  82. package/dist/provider/__tests__/model-version.test.d.ts +2 -0
  83. package/dist/provider/__tests__/model-version.test.d.ts.map +1 -0
  84. package/dist/provider/__tests__/model-version.test.js +80 -0
  85. package/dist/provider/__tests__/model-version.test.js.map +1 -0
  86. package/dist/provider/__tests__/strict-schema.test.d.ts +2 -0
  87. package/dist/provider/__tests__/strict-schema.test.d.ts.map +1 -0
  88. package/dist/provider/__tests__/strict-schema.test.js +109 -0
  89. package/dist/provider/__tests__/strict-schema.test.js.map +1 -0
  90. package/dist/provider/__tests__/typed-error-classification.test.d.ts +2 -0
  91. package/dist/provider/__tests__/typed-error-classification.test.d.ts.map +1 -0
  92. package/dist/provider/__tests__/typed-error-classification.test.js +123 -0
  93. package/dist/provider/__tests__/typed-error-classification.test.js.map +1 -0
  94. package/dist/provider/model-version.d.ts +60 -0
  95. package/dist/provider/model-version.d.ts.map +1 -0
  96. package/dist/provider/model-version.js +64 -0
  97. package/dist/provider/model-version.js.map +1 -0
  98. package/dist/provider/retry.d.ts.map +1 -1
  99. package/dist/provider/retry.js +23 -7
  100. package/dist/provider/retry.js.map +1 -1
  101. package/dist/provider/strict-schema.d.ts +49 -0
  102. package/dist/provider/strict-schema.d.ts.map +1 -0
  103. package/dist/provider/strict-schema.js +112 -0
  104. package/dist/provider/strict-schema.js.map +1 -0
  105. package/dist/public-runtime.d.ts +6 -1
  106. package/dist/public-runtime.d.ts.map +1 -1
  107. package/dist/public-runtime.js +21 -1
  108. package/dist/public-runtime.js.map +1 -1
  109. package/dist/public-tools.d.ts +1 -0
  110. package/dist/public-tools.d.ts.map +1 -1
  111. package/dist/public-tools.js +4 -0
  112. package/dist/public-tools.js.map +1 -1
  113. package/dist/public-types.d.ts +2 -0
  114. package/dist/public-types.d.ts.map +1 -1
  115. package/dist/registry/tool/__tests__/strict-registration.test.d.ts +2 -0
  116. package/dist/registry/tool/__tests__/strict-registration.test.d.ts.map +1 -0
  117. package/dist/registry/tool/__tests__/strict-registration.test.js +82 -0
  118. package/dist/registry/tool/__tests__/strict-registration.test.js.map +1 -0
  119. package/dist/registry/tool/execute.d.ts.map +1 -1
  120. package/dist/registry/tool/execute.js +16 -0
  121. package/dist/registry/tool/execute.js.map +1 -1
  122. package/dist/runtime/query/__tests__/stream-recovery.test.js +5 -0
  123. package/dist/runtime/query/__tests__/stream-recovery.test.js.map +1 -1
  124. package/dist/runtime/query/result.d.ts.map +1 -1
  125. package/dist/runtime/query/result.js +5 -0
  126. package/dist/runtime/query/result.js.map +1 -1
  127. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js +7 -1
  128. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js.map +1 -1
  129. package/dist/tools/builtins/__tests__/edit.test.js +1 -1
  130. package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
  131. package/dist/tools/builtins/edit.d.ts.map +1 -1
  132. package/dist/tools/builtins/edit.js +20 -2
  133. package/dist/tools/builtins/edit.js.map +1 -1
  134. package/dist/types/plugin/index.d.ts +4 -4
  135. package/dist/types/provider/errors.d.ts +0 -17
  136. package/dist/types/provider/errors.d.ts.map +1 -1
  137. package/dist/types/provider/errors.js +60 -0
  138. package/dist/types/provider/errors.js.map +1 -1
  139. package/dist/types/run/events.d.ts +17 -2
  140. package/dist/types/run/events.d.ts.map +1 -1
  141. package/dist/types/run/events.js.map +1 -1
  142. package/dist/types/verification/index.d.ts +6 -6
  143. package/package.json +1 -1
  144. package/src/agents/__tests__/run-agent-forwarding.test.ts +85 -0
  145. package/src/agents/__tests__/run-completed-stop-reason.test.ts +59 -0
  146. package/src/agents/index.ts +8 -0
  147. package/src/agents/runAgent.ts +30 -4
  148. package/src/constants/tools/__tests__/dangerous-patterns.test.ts +62 -0
  149. package/src/constants/tools/index.ts +28 -1
  150. package/src/directory/__tests__/derive.test.ts +135 -0
  151. package/src/directory/__tests__/load-diagnostics.test.ts +126 -0
  152. package/src/directory/__tests__/load-directory.test.ts +243 -0
  153. package/src/directory/__tests__/subagents.test.ts +155 -0
  154. package/src/directory/__tests__/supervisor-budget.test.ts +117 -0
  155. package/src/directory/derive-supervisor.ts +149 -0
  156. package/src/directory/derive.ts +70 -0
  157. package/src/directory/index.ts +27 -0
  158. package/src/directory/load.ts +556 -0
  159. package/src/directory/scan.ts +163 -0
  160. package/src/directory/types.ts +254 -0
  161. package/src/plugin/__tests__/path-containment.test.ts +107 -0
  162. package/src/plugin/lifecycle.ts +3 -3
  163. package/src/plugin/loader.ts +12 -2
  164. package/src/provider/__tests__/model-version.test.ts +93 -0
  165. package/src/provider/__tests__/strict-schema.test.ts +133 -0
  166. package/src/provider/__tests__/typed-error-classification.test.ts +143 -0
  167. package/src/provider/model-version.ts +98 -0
  168. package/src/provider/retry.ts +23 -7
  169. package/src/provider/strict-schema.ts +125 -0
  170. package/src/public-runtime.ts +31 -0
  171. package/src/public-tools.ts +4 -0
  172. package/src/public-types.ts +8 -0
  173. package/src/registry/tool/__tests__/strict-registration.test.ts +115 -0
  174. package/src/registry/tool/execute.ts +16 -0
  175. package/src/runtime/query/__tests__/stream-recovery.test.ts +5 -0
  176. package/src/runtime/query/result.ts +5 -0
  177. package/src/tools/builtins/__tests__/edit-insert-reachable.test.ts +8 -2
  178. package/src/tools/builtins/__tests__/edit.test.ts +1 -1
  179. package/src/tools/builtins/edit.ts +20 -2
  180. package/src/types/provider/errors.ts +71 -0
  181. package/src/types/run/events.ts +15 -2
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,0BAA0B,CAAA;AAKpF;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAwB1E;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOnF;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAQ/D;AAED,6GAA6G;AAC7G,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;IAChC,yDAAyD;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,qBAAqB,CAC1C,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6BhD"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,0BAA0B,CAAA;AAKpF;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkC1E;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAOnF;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAQ/D;AAED,6GAA6G;AAC7G,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;IAChC,yDAAyD;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,qBAAqB,CAC1C,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6BhD"}
@@ -1,4 +1,4 @@
1
- import { readFile, readdir, stat } from 'node:fs/promises';
1
+ import { lstat, readFile, readdir, stat } from 'node:fs/promises';
2
2
  import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { PLUGIN_MANIFEST_FILENAME, PROJECT_PLUGIN_DIR, USER_PLUGIN_DIR, } from '../constants/plugin/index.js';
@@ -17,7 +17,17 @@ export async function discoverPlugins(parentDir) {
17
17
  if (entry.startsWith('.') || entry.startsWith('_'))
18
18
  continue;
19
19
  const fullPath = join(parentDir, entry);
20
- const s = await stat(fullPath);
20
+ // `lstat`, not `stat`: `stat` follows the link and reports on its
21
+ // TARGET, so a symlinked entry pointing anywhere on disk was
22
+ // admitted as a plugin directory and its manifest read from there.
23
+ // A plugins directory holds third-party code by definition, which
24
+ // makes following a link out of it the worse half of CWE-59 — the
25
+ // directory listed is not the directory loaded.
26
+ const s = await lstat(fullPath);
27
+ if (s.isSymbolicLink()) {
28
+ logger.warn('Refusing a symlinked plugin directory', { path: fullPath });
29
+ continue;
30
+ }
21
31
  if (!s.isDirectory())
22
32
  continue;
23
33
  const manifestPath = join(fullPath, PLUGIN_MANIFEST_FILENAME);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,GACf,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAuB,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAA;AAEnE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB;IACtD,MAAM,IAAI,GAAa,EAAE,CAAA;IAEzB,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;QACxC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAQ;YAC5D,MAAM,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AAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAElF,MAAM,UAAU,GAAG,gBAAgB;QAClC,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;QAC5C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAA;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAA;IAEhD,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;KAChE,CAAC,CAAA;IAEF,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE;QACzC,YAAY,EAAE,OAAO,CAAC,MAAM;QAC5B,SAAS,EAAE,IAAI,CAAC,MAAM;QACtB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC,CAAA;IAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=model-version.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-version.test.d.ts","sourceRoot":"","sources":["../../../src/provider/__tests__/model-version.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,80 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { modelVersionAtLeast, parseVersionedModelId } from '../model-version.js';
3
+ /**
4
+ * The defect this module exists to end: the minor-version group was `\d+`, so
5
+ * it swallowed the 8-digit release date. An id naming no minor therefore
6
+ * parsed as `major.<the date>` and compared as enormously NEWER than one that
7
+ * does, inverting every capability gate keyed on `minor >= n` — a model was
8
+ * told it supported features it does not.
9
+ *
10
+ * Three drivers had each written the same matcher, and all three had it. The
11
+ * vocabulary below is deliberately invented: the shape is what lives here, and
12
+ * a test that needed real product names would be testing the wrong layer.
13
+ */
14
+ const GRAMMAR = {
15
+ product: 'widget',
16
+ families: ['small', 'large'],
17
+ routingPrefix: 'vendor/',
18
+ };
19
+ describe('a date suffix is not a minor version', () => {
20
+ it.each([
21
+ ['widget-small-4-20250514', 'small', 4, 0],
22
+ ['widget-large-4-20250514', 'large', 4, 0],
23
+ ['widget-small-3-20240307', 'small', 3, 0],
24
+ ])('%s parses as %s %d.%d', (id, family, major, minor) => {
25
+ expect(parseVersionedModelId(id, GRAMMAR)).toEqual({ family, major, minor });
26
+ });
27
+ it('still reads a real minor that is followed by a date', () => {
28
+ expect(parseVersionedModelId('widget-large-4-1-20250805', GRAMMAR)).toEqual({
29
+ family: 'large',
30
+ major: 4,
31
+ minor: 1,
32
+ });
33
+ expect(parseVersionedModelId('widget-small-4-5-20250929', GRAMMAR)?.minor).toBe(5);
34
+ });
35
+ it('treats a missing minor as .0 rather than as absent', () => {
36
+ expect(parseVersionedModelId('widget-large-5', GRAMMAR)).toEqual({
37
+ family: 'large',
38
+ major: 5,
39
+ minor: 0,
40
+ });
41
+ });
42
+ it('tolerates the routing prefix, the other separators, and case', () => {
43
+ expect(parseVersionedModelId('vendor/widget-large-4-5', GRAMMAR)?.minor).toBe(5);
44
+ expect(parseVersionedModelId('widget-large-4.5', GRAMMAR)?.minor).toBe(5);
45
+ expect(parseVersionedModelId('WIDGET-LARGE-4-5', GRAMMAR)?.major).toBe(4);
46
+ });
47
+ it('returns undefined for what the grammar does not describe', () => {
48
+ for (const id of ['other-large-4', 'widget', 'widget-large', 'widget-medium-4', '']) {
49
+ expect(parseVersionedModelId(id, GRAMMAR)).toBeUndefined();
50
+ }
51
+ });
52
+ it('escapes regex metacharacters in the grammar', () => {
53
+ // A product or prefix containing `.` or `+` must match literally, not
54
+ // as a wildcard. `.map(escape)` — the global, deprecated one — would
55
+ // percent-encode instead, and pass every other test in this file
56
+ // because no ordinary name contains a character it changes.
57
+ const odd = { product: 'a.b', families: ['c+d'] };
58
+ expect(parseVersionedModelId('a.b-c+d-4', odd)?.major).toBe(4);
59
+ expect(parseVersionedModelId('axb-cxd-4', odd)).toBeUndefined();
60
+ });
61
+ });
62
+ describe('modelVersionAtLeast', () => {
63
+ it('does not let a dated id clear a gate it is below', () => {
64
+ // The whole point. With the old `\d+` minor this was `true`, because
65
+ // 4.20250514 >= 4.5.
66
+ expect(modelVersionAtLeast('widget-small-4-20250514', GRAMMAR, 4, 5)).toBe(false);
67
+ expect(modelVersionAtLeast('widget-large-4-20250514', GRAMMAR, 4, 7)).toBe(false);
68
+ });
69
+ it('admits versions that genuinely clear it', () => {
70
+ expect(modelVersionAtLeast('widget-small-4-5-20250929', GRAMMAR, 4, 5)).toBe(true);
71
+ expect(modelVersionAtLeast('widget-large-5', GRAMMAR, 4, 7)).toBe(true);
72
+ expect(modelVersionAtLeast('widget-large-4-1', GRAMMAR, 4, 5)).toBe(false);
73
+ });
74
+ it('refuses a name it cannot parse rather than opening the gate', () => {
75
+ // Fail-safe: a capability gate must not open for an id it does not
76
+ // understand.
77
+ expect(modelVersionAtLeast('something-else', GRAMMAR, 4, 5)).toBe(false);
78
+ });
79
+ });
80
+ //# sourceMappingURL=model-version.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-version.test.js","sourceRoot":"","sources":["../../../src/provider/__tests__/model-version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAGhF;;;;;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kD,EAAE,GAAG,EAAE;QAC3D,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjF,MAAM,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAClD,MAAM,CAAC,mBAAmB,CAAC,2BAA2B,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClF,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvE,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACtE,mEAAmE;QACnE,cAAc;QACd,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=strict-schema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-schema.test.d.ts","sourceRoot":"","sources":["../../../src/provider/__tests__/strict-schema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,109 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getBuiltinTools } from '../../tools/builtins/index.js';
3
+ import { assertStrictSchema, findStrictSchemaViolations } from '../strict-schema.js';
4
+ /**
5
+ * Strict tool input validates against a SUBSET of JSON Schema, and a keyword
6
+ * outside that subset is not degraded — the vendor rejects the entire request,
7
+ * so one unexpressible field in one tool takes down every tool in the call and
8
+ * the turn dies before producing a token.
9
+ *
10
+ * That shipped. The edit tool declared its integer-or-`"end"` field with
11
+ * `oneOf`, which is outside the subset while the equivalent `anyOf` is inside
12
+ * it, and the driver marked the tool strict without asking whether the schema
13
+ * it was vouching for could be said in that dialect.
14
+ *
15
+ * Measured against the live API:
16
+ *
17
+ * | body | result |
18
+ * |------------------------|----------|
19
+ * | strict: true + oneOf | 400 |
20
+ * | strict: false + oneOf | accepted |
21
+ * | strict: true + anyOf | accepted |
22
+ *
23
+ * The middle row is why nothing caught it. Neither half is wrong alone — the
24
+ * schema is valid JSON Schema, and turning strict on is correct policy — so no
25
+ * test of either one fails. Only the pairing does, and the pairing had no
26
+ * owner. The sweep below is that owner.
27
+ */
28
+ describe('every tool that asks for strict validation can be expressed strictly', () => {
29
+ // The regression test that matters. Checking only the tool that broke
30
+ // would leave the next one to be found in production, which is how this
31
+ // one was found.
32
+ it.each(getBuiltinTools()
33
+ .filter((t) => t.enforceModelInput)
34
+ .map((t) => [t.name, t]))('%s', (name, tool) => {
35
+ const violations = findStrictSchemaViolations(tool.modelInputSchema);
36
+ expect(violations, violations.map((v) => `${name}.${v.path}: ${v.remedy}`).join('\n')).toEqual([]);
37
+ });
38
+ it('found at least one tool to check', () => {
39
+ // Guards the sweep itself: a filter that matches nothing passes
40
+ // vacuously, and a rename of `enforceModelInput` would silently turn
41
+ // this whole file into a no-op.
42
+ expect(getBuiltinTools().filter((t) => t.enforceModelInput).length).toBeGreaterThan(0);
43
+ });
44
+ });
45
+ describe('the violation report names the exact path', () => {
46
+ it('points at the keyword inside a nested property', () => {
47
+ const schema = {
48
+ type: 'object',
49
+ properties: {
50
+ insertLine: { oneOf: [{ type: 'integer' }, { const: 'end' }] },
51
+ },
52
+ };
53
+ expect(findStrictSchemaViolations(schema)).toEqual([
54
+ {
55
+ path: 'properties.insertLine.oneOf',
56
+ keyword: 'oneOf',
57
+ remedy: 'use `anyOf` — for disjoint branches the two are equivalent',
58
+ },
59
+ ]);
60
+ });
61
+ it('accepts the anyOf spelling of the same union', () => {
62
+ const schema = {
63
+ type: 'object',
64
+ properties: {
65
+ insertLine: { anyOf: [{ type: 'integer' }, { const: 'end' }] },
66
+ },
67
+ };
68
+ expect(findStrictSchemaViolations(schema)).toEqual([]);
69
+ });
70
+ it('reports numeric and string bounds, which are also outside the subset', () => {
71
+ const schema = {
72
+ type: 'object',
73
+ properties: {
74
+ n: { type: 'integer', minimum: 0 },
75
+ s: { type: 'string', maxLength: 10 },
76
+ },
77
+ };
78
+ expect(findStrictSchemaViolations(schema)
79
+ .map((v) => v.keyword)
80
+ .sort()).toEqual(['maxLength', 'minimum']);
81
+ });
82
+ it('admits additionalProperties only as false', () => {
83
+ expect(findStrictSchemaViolations({ additionalProperties: false })).toEqual([]);
84
+ expect(findStrictSchemaViolations({ additionalProperties: { type: 'string' } })).toHaveLength(1);
85
+ });
86
+ it('walks into arrays of subschemas', () => {
87
+ const schema = { anyOf: [{ type: 'string' }, { not: { type: 'null' } }] };
88
+ expect(findStrictSchemaViolations(schema)[0]?.path).toBe('anyOf[1].not');
89
+ });
90
+ it('leaves ordinary annotations alone', () => {
91
+ const schema = {
92
+ type: 'object',
93
+ description: 'a tool',
94
+ properties: { a: { type: 'string', description: 'x', enum: ['y'] } },
95
+ required: ['a'],
96
+ additionalProperties: false,
97
+ };
98
+ expect(findStrictSchemaViolations(schema)).toEqual([]);
99
+ });
100
+ });
101
+ describe('assertStrictSchema refuses rather than letting the request go', () => {
102
+ it('throws naming the tool, the path and the fix', () => {
103
+ expect(() => assertStrictSchema('edit', { properties: { insertLine: { oneOf: [] } } })).toThrow(/edit\.properties\.insertLine\.oneOf/);
104
+ });
105
+ it('says nothing about a schema that is expressible', () => {
106
+ expect(() => assertStrictSchema('edit', { type: 'object' })).not.toThrow();
107
+ });
108
+ });
109
+ //# sourceMappingURL=strict-schema.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strict-schema.test.js","sourceRoot":"","sources":["../../../src/provider/__tests__/strict-schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAEpF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,QAAQ,CAAC,sEAAsE,EAAE,GAAG,EAAE;IACrF,sEAAsE;IACtE,wEAAwE;IACxE,iBAAiB;IACjB,EAAE,CAAC,IAAI,CACN,eAAe,EAAE;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC;SAClC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAU,CAAC,CAClC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,UAAU,GAAG,0BAA0B,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACpE,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAC7F,EAAE,CACF,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC3C,gEAAgE;QAChE,qEAAqE;QACrE,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C,EAAE,EAAE;YACpE,QAAQ,EAAE,CAAC,GAAG,CAAC;YACf,oBAAoB,EAAE,KAAK;SAC3B,CAAA;QAED,MAAM,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,+DAA+D,EAAE,GAAG,EAAE;IAC9E,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAC9F,qCAAqC,CACrC,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IAC3E,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=typed-error-classification.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-error-classification.test.d.ts","sourceRoot":"","sources":["../../../src/provider/__tests__/typed-error-classification.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,123 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { classifyProviderError } from '../../types/provider/errors.js';
3
+ import { ProviderRequestError } from '../errors.js';
4
+ import { withProviderRetry } from '../retry.js';
5
+ /**
6
+ * A driver that classified its own failure was coming out WORSE than one that
7
+ * did not, in two independent places, and both shipped.
8
+ *
9
+ * `classifyProviderError` never read `kind`. A `ProviderRequestError` fell
10
+ * through to the status heuristics, where a carefully-diagnosed
11
+ * `context_overflow` carrying a 400 became `invalid_request` — so the run
12
+ * loop's overflow branch, which tests for `context_length_exceeded`, could
13
+ * never fire for a first-party driver, and compaction relief was unreachable
14
+ * for exactly the drivers that had diagnosed the problem correctly.
15
+ *
16
+ * And `withProviderRetry` rethrew any such error before the retry loop. Its
17
+ * comment justified preserving the classification, which is right; the code
18
+ * also skipped retrying, which is a different decision that nobody made.
19
+ */
20
+ function providerThatFails(err) {
21
+ let calls = 0;
22
+ const provider = {
23
+ id: 'test',
24
+ name: 'Test',
25
+ async *chatStream() {
26
+ calls++;
27
+ throw err;
28
+ // biome-ignore lint/correctness/useYield: it fails before producing anything
29
+ },
30
+ };
31
+ return { provider, calls: () => calls };
32
+ }
33
+ const typed = (kind, status) => new ProviderRequestError({ kind, providerId: 'test', status, message: `a ${kind}` });
34
+ describe('a driver that classified its own failure is believed', () => {
35
+ const cases = [
36
+ ['throttle', 429, 'rate_limit', true],
37
+ ['server', 500, 'server_error', true],
38
+ ['network', 0, 'network', true],
39
+ ['auth', 401, 'auth', false],
40
+ ['bad_request', 400, 'invalid_request', false],
41
+ // The one that mattered most: a 400 whose kind says the prompt was too
42
+ // long is not a bad request, and the difference decides whether the
43
+ // kernel reaches for compaction.
44
+ ['context_overflow', 400, 'context_length_exceeded', false],
45
+ ];
46
+ for (const [kind, status, code, retryable] of cases) {
47
+ it(`maps kind "${kind}" to ${code}`, () => {
48
+ const classified = classifyProviderError(typed(kind, status), 'test');
49
+ expect(classified.code).toBe(code);
50
+ expect(classified.retryable).toBe(retryable);
51
+ });
52
+ }
53
+ it('keeps the driver-supplied status and provider id', () => {
54
+ const classified = classifyProviderError(typed('throttle', 429), 'other');
55
+ expect(classified.status).toBe(429);
56
+ expect(classified.providerId).toBe('test');
57
+ });
58
+ });
59
+ describe('a classified failure still goes through the retry loop', () => {
60
+ it('retries a typed throttle', async () => {
61
+ // This is the regression: a first-party driver reporting a 429 as
62
+ // `kind: 'throttle'` used to get exactly one attempt, while the same
63
+ // failure from a driver that classified nothing got the full backoff.
64
+ const { provider, calls } = providerThatFails(typed('throttle', 429));
65
+ const wrapped = withProviderRetry(provider, {
66
+ config: { maxRetries: 2 },
67
+ sleepFn: async () => { },
68
+ random: () => 0,
69
+ });
70
+ await expect(async () => {
71
+ for await (const _ of wrapped.chatStream({})) {
72
+ // drain
73
+ }
74
+ }).rejects.toThrow();
75
+ expect(calls()).toBe(3);
76
+ });
77
+ it('does not retry a typed auth failure', async () => {
78
+ const { provider, calls } = providerThatFails(typed('auth', 401));
79
+ const wrapped = withProviderRetry(provider, {
80
+ config: { maxRetries: 2 },
81
+ sleepFn: async () => { },
82
+ });
83
+ await expect(async () => {
84
+ for await (const _ of wrapped.chatStream({})) {
85
+ // drain
86
+ }
87
+ }).rejects.toThrow();
88
+ expect(calls()).toBe(1);
89
+ });
90
+ it('does not retry a typed context overflow', async () => {
91
+ // Correctly non-retryable — an identical prompt overflows identically.
92
+ // The remedy is compaction, which the run loop reaches for once the
93
+ // code is `context_length_exceeded`.
94
+ const { provider, calls } = providerThatFails(typed('context_overflow', 400));
95
+ const wrapped = withProviderRetry(provider, {
96
+ config: { maxRetries: 2 },
97
+ sleepFn: async () => { },
98
+ });
99
+ await expect(async () => {
100
+ for await (const _ of wrapped.chatStream({})) {
101
+ // drain
102
+ }
103
+ // The ORIGINAL escapes, so the boundary still sees the driver's
104
+ // own kind rather than a wrapper's code.
105
+ }).rejects.toMatchObject({ kind: 'context_overflow', status: 400 });
106
+ expect(calls()).toBe(1);
107
+ });
108
+ it('leaves an abort alone', async () => {
109
+ const abort = Object.assign(new Error('aborted'), { name: 'AbortError' });
110
+ const { provider, calls } = providerThatFails(abort);
111
+ const wrapped = withProviderRetry(provider, {
112
+ config: { maxRetries: 2 },
113
+ sleepFn: async () => { },
114
+ });
115
+ await expect(async () => {
116
+ for await (const _ of wrapped.chatStream({})) {
117
+ // drain
118
+ }
119
+ }).rejects.toThrow(/aborted/);
120
+ expect(calls()).toBe(1);
121
+ });
122
+ });
123
+ //# sourceMappingURL=typed-error-classification.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-error-classification.test.js","sourceRoot":"","sources":["../../../src/provider/__tests__/typed-error-classification.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;;;;;;;;GAcG;AAEH,SAAS,iBAAiB,CAAC,GAAY;IACtC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,MAAM,QAAQ,GAAG;QAChB,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,MAAM;QACZ,KAAK,CAAC,CAAC,UAAU;YAChB,KAAK,EAAE,CAAA;YACP,MAAM,GAAG,CAAA;YACT,6EAA6E;QAC9E,CAAC;KACyB,CAAA;IAC3B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAA;AACxC,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE,CAC9C,IAAI,oBAAoB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE,EAAW,CAAC,CAAA;AAE9F,QAAQ,CAAC,sDAAsD,EAAE,GAAG,EAAE;IACrE,MAAM,KAAK,GAAiD;QAC3D,CAAC,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,CAAC;QACrC,CAAC,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC;QACrC,CAAC,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC;QAC/B,CAAC,MAAM,EAAE,GAAG,EA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CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,EAAW,CAAC,EAAE,CAAC;gBACvD,QAAQ;YACT,CAAC;QACF,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAE7B,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Parse a versioned model id, given the vocabulary that names one.
3
+ *
4
+ * Several vendors spell an id the same way — a product segment, a family, a
5
+ * major version, sometimes a minor, and sometimes an 8-digit release date:
6
+ *
7
+ * ```
8
+ * <product>-<family>-<major>[-<minor>][-<YYYYMMDD>]
9
+ * ```
10
+ *
11
+ * The SHAPE is general and lives here; the vocabulary is not, and is supplied
12
+ * by the driver that knows it. That split is deliberate: a driver package
13
+ * exists to speak one service's dialect, and the kernel has no business
14
+ * knowing whose ids these are.
15
+ *
16
+ * It exists at all because three drivers had each written the same matcher and
17
+ * all three had the same defect: the minor-version group was `\d+`, which
18
+ * happily swallowed the date. An id naming no minor therefore parsed as
19
+ * `major.<the date>` and compared as enormously NEWER than one that does, so
20
+ * every capability gate keyed on `minor >= n` inverted for exactly those ids —
21
+ * a model was told it supported features it does not.
22
+ *
23
+ * A real minor version is one to three digits; a date is exactly eight.
24
+ * Bounding the group is what stops it reaching across the separator, and the
25
+ * expression then backtracks into leaving the minor absent so the date suffix
26
+ * can match where it belongs.
27
+ */
28
+ export interface ModelVersion {
29
+ readonly family: string;
30
+ readonly major: number;
31
+ /** `0` when the id names no minor — a bare major is `<major>.0`. */
32
+ readonly minor: number;
33
+ }
34
+ /**
35
+ * What a driver must say to have its ids parsed.
36
+ *
37
+ * Every field is a wire value the driver already carries. Passing them in
38
+ * rather than hard-coding them is what keeps this module free of any one
39
+ * service's names.
40
+ */
41
+ export interface ModelIdGrammar {
42
+ /** The product segment an id begins with. */
43
+ readonly product: string;
44
+ /** The family segment that follows it. */
45
+ readonly families: readonly string[];
46
+ /** An optional routing segment a gateway may prepend, including its slash. */
47
+ readonly routingPrefix?: string;
48
+ }
49
+ /** `undefined` for anything the grammar does not describe — never a guess. */
50
+ export declare function parseVersionedModelId(id: string, grammar: ModelIdGrammar): ModelVersion | undefined;
51
+ /**
52
+ * Whether an id names a version at or above `major.minor`.
53
+ *
54
+ * The comparison every caller was writing by hand. An id this cannot parse
55
+ * returns `false`: a capability gate must not open for a name it does not
56
+ * understand, which is the fail-safe reading and the one those callers' own
57
+ * comments already claimed.
58
+ */
59
+ export declare function modelVersionAtLeast(id: string, grammar: ModelIdGrammar, major: number, minor: number): boolean;
60
+ //# sourceMappingURL=model-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-version.d.ts","sourceRoot":"","sources":["../../src/provider/model-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAC/B;AAiBD,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACpC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,cAAc,GACrB,YAAY,GAAG,SAAS,CAQ1B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO,CAIT"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Parse a versioned model id, given the vocabulary that names one.
3
+ *
4
+ * Several vendors spell an id the same way — a product segment, a family, a
5
+ * major version, sometimes a minor, and sometimes an 8-digit release date:
6
+ *
7
+ * ```
8
+ * <product>-<family>-<major>[-<minor>][-<YYYYMMDD>]
9
+ * ```
10
+ *
11
+ * The SHAPE is general and lives here; the vocabulary is not, and is supplied
12
+ * by the driver that knows it. That split is deliberate: a driver package
13
+ * exists to speak one service's dialect, and the kernel has no business
14
+ * knowing whose ids these are.
15
+ *
16
+ * It exists at all because three drivers had each written the same matcher and
17
+ * all three had the same defect: the minor-version group was `\d+`, which
18
+ * happily swallowed the date. An id naming no minor therefore parsed as
19
+ * `major.<the date>` and compared as enormously NEWER than one that does, so
20
+ * every capability gate keyed on `minor >= n` inverted for exactly those ids —
21
+ * a model was told it supported features it does not.
22
+ *
23
+ * A real minor version is one to three digits; a date is exactly eight.
24
+ * Bounding the group is what stops it reaching across the separator, and the
25
+ * expression then backtracks into leaving the minor absent so the date suffix
26
+ * can match where it belongs.
27
+ */
28
+ const quoteMeta = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
29
+ function expressionFor(grammar) {
30
+ const routing = grammar.routingPrefix ? `(?:${quoteMeta(grammar.routingPrefix)})?` : '';
31
+ // `.map(quoteMeta)` and not `.map(escape)`: the latter resolves to the
32
+ // global, deprecated `escape()`, which percent-encodes instead of escaping
33
+ // regex metacharacters — and would pass every test here, because no family
34
+ // name contains a character either function changes.
35
+ const families = grammar.families.map((f) => quoteMeta(f)).join('|');
36
+ // `\d{1,3}` on the minor, not `\d+`. That single bound is the whole fix.
37
+ return new RegExp(`^${routing}${quoteMeta(grammar.product)}-(${families})-(\\d+)(?:[-_.](\\d{1,3}))?(?:-\\d{8})?$`);
38
+ }
39
+ /** `undefined` for anything the grammar does not describe — never a guess. */
40
+ export function parseVersionedModelId(id, grammar) {
41
+ const match = id.toLowerCase().match(expressionFor(grammar));
42
+ if (!match)
43
+ return undefined;
44
+ return {
45
+ family: match[1],
46
+ major: Number(match[2]),
47
+ minor: match[3] === undefined ? 0 : Number(match[3]),
48
+ };
49
+ }
50
+ /**
51
+ * Whether an id names a version at or above `major.minor`.
52
+ *
53
+ * The comparison every caller was writing by hand. An id this cannot parse
54
+ * returns `false`: a capability gate must not open for a name it does not
55
+ * understand, which is the fail-safe reading and the one those callers' own
56
+ * comments already claimed.
57
+ */
58
+ export function modelVersionAtLeast(id, grammar, major, minor) {
59
+ const version = parseVersionedModelId(id, grammar);
60
+ if (!version)
61
+ return false;
62
+ return version.major > major || (version.major === major && version.minor >= minor);
63
+ }
64
+ //# sourceMappingURL=model-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-version.js","sourceRoot":"","sources":["../../src/provider/model-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAyBH,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;AAEzF,SAAS,aAAa,CAAC,OAAuB;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACvF,uEAAuE;IACvE,2EAA2E;IAC3E,2EAA2E;IAC3E,qDAAqD;IACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpE,yEAAyE;IACzE,OAAO,IAAI,MAAM,CAChB,IAAI,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,QAAQ,2CAA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AC9C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,oCAAoC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,wBAA6B,GACpC,WAAW,CAkIb"}
@@ -79,12 +79,19 @@ export function withProviderRetry(provider, options = {}) {
79
79
  catch (err) {
80
80
  if (isAbortError(err) || params.signal?.aborted)
81
81
  throw err;
82
- // A driver that already classified its own failure has said
83
- // everything this layer would: re-wrapping it would replace a
84
- // first-hand statement with a guess, and the run boundary reads
85
- // that classification to choose between a pause and a failure.
86
- if (isProviderRequestError(err))
87
- throw err;
82
+ // A driver that already classified its own failure keeps that
83
+ // classification `classifyProviderError` reads its `kind`
84
+ // first and does not re-guess.
85
+ //
86
+ // This used to rethrow such an error outright. The stated reason
87
+ // was sound and the code did more than it said: preserving a
88
+ // first-hand classification is one thing, and skipping the retry
89
+ // loop is another. A first-party driver that correctly reported
90
+ // a 429 as `kind: 'throttle'` got ZERO attempts, while the same
91
+ // failure from a driver that classified nothing got the full
92
+ // backoff — so diagnosing your own error was punished. Whether
93
+ // to retry is now decided the same way for both, by the
94
+ // classification's own `retryable`.
88
95
  const classified = classifyProviderError(err, provider.id);
89
96
  const exhausted = attempt >= config.maxRetries;
90
97
  if (produced || !classified.retryable || exhausted) {
@@ -100,7 +107,16 @@ export function withProviderRetry(provider, options = {}) {
100
107
  ? 'retries exhausted'
101
108
  : 'not retryable',
102
109
  });
103
- throw classified;
110
+ // The ORIGINAL escapes when the driver classified it. Two
111
+ // different consumers want two different things and both are
112
+ // right: this loop needs a retryable verdict, which the
113
+ // classification supplies, and the run boundary reports
114
+ // `lastProviderError` as the driver's own `{kind, status,
115
+ // retryAfterMs}`, which only survives if the error itself
116
+ // does. Wrapping here would have kept the retry fix and lost
117
+ // the vendor's `kind` at the boundary — the existing
118
+ // stream-recovery test caught exactly that.
119
+ throw isProviderRequestError(err) ? err : classified;
104
120
  }
105
121
  const serverDirected = classified.retryAfterMs;
106
122
  const delay = serverDirected !== undefined && serverDirected <= config.maxRetryAfterMs
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/provider/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAGjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAiBpD,MAAM,CAAC,MAAM,sBAAsB,GAAwB;IAC1D,UAAU,EAAE,CAAC;IACb,cAAc,EAAE,GAAG;IACnB,UAAU,EAAE,MAAM;IAClB,eAAe,EAAE,MAAM;CACvB,CAAA;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,OAAe,EAAE,MAA2B,EAAE,MAAoB;IAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IACrF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAA;AAC1C,CAAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,MAAoB;IAC9C,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IACrC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5C,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACrB,OAAM;QACP,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CA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