@combycode/llm-sdk 2.3.0 → 3.0.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 (67) hide show
  1. package/CHANGELOG.md +373 -0
  2. package/MIGRATION.md +130 -0
  3. package/dist/bus/hook-bus.d.ts +13 -3
  4. package/dist/bus/hook-map.d.ts +24 -0
  5. package/dist/catalog/catalog.d.ts +8 -23
  6. package/dist/helpers/client-resolver.d.ts +21 -2
  7. package/dist/helpers/count-tokens.d.ts +1 -1
  8. package/dist/helpers/engine.d.ts +27 -5
  9. package/dist/index.browser.js +17131 -4291
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +17131 -4291
  12. package/dist/llm/client-config.d.ts +8 -0
  13. package/dist/llm/client.d.ts +2 -0
  14. package/dist/llm/providers/anthropic/batch.d.ts +13 -2
  15. package/dist/llm/providers/anthropic/constants.d.ts +8 -43
  16. package/dist/llm/providers/anthropic/files.d.ts +13 -2
  17. package/dist/llm/providers/anthropic/messages.d.ts +18 -1
  18. package/dist/llm/providers/google/batch.d.ts +14 -1
  19. package/dist/llm/providers/google/constants.d.ts +6 -15
  20. package/dist/llm/providers/google/embeddings.d.ts +8 -1
  21. package/dist/llm/providers/google/files.d.ts +19 -1
  22. package/dist/llm/providers/google/generate.d.ts +15 -1
  23. package/dist/llm/providers/google/interactions.d.ts +5 -1
  24. package/dist/llm/providers/google/media.d.ts +26 -3
  25. package/dist/llm/providers/openai/batch.d.ts +19 -2
  26. package/dist/llm/providers/openai/completions.d.ts +13 -1
  27. package/dist/llm/providers/openai/embeddings.d.ts +13 -1
  28. package/dist/llm/providers/openai/files.d.ts +13 -2
  29. package/dist/llm/providers/openai/media.d.ts +21 -1
  30. package/dist/llm/providers/openai/moderations.d.ts +11 -1
  31. package/dist/llm/providers/openai/realtime.d.ts +3 -0
  32. package/dist/llm/providers/openai/responses.d.ts +10 -2
  33. package/dist/llm/providers/openai/transcription.d.ts +7 -1
  34. package/dist/llm/providers/openrouter/completions.d.ts +5 -3
  35. package/dist/llm/providers/openrouter/embeddings.d.ts +3 -0
  36. package/dist/llm/providers/openrouter/media.d.ts +14 -4
  37. package/dist/llm/providers/openrouter/responses.d.ts +5 -3
  38. package/dist/llm/providers/xai/batch.d.ts +13 -2
  39. package/dist/llm/providers/xai/completions.d.ts +5 -3
  40. package/dist/llm/providers/xai/files.d.ts +13 -2
  41. package/dist/llm/providers/xai/media.d.ts +28 -10
  42. package/dist/llm/providers/xai/responses.d.ts +5 -3
  43. package/dist/llm/response-shape.d.ts +96 -0
  44. package/dist/llm/types/provider.d.ts +6 -0
  45. package/dist/llm/types/request.d.ts +5 -6
  46. package/dist/llm/wire-multipart.d.ts +26 -0
  47. package/dist/{wire/transforms.d.ts → llm/wire-transforms.d.ts} +11 -5
  48. package/dist/plugins/context-measurer/counter/count-api.d.ts +39 -5
  49. package/dist/plugins/context-measurer/counter/hybrid.d.ts +33 -0
  50. package/dist/plugins/context-measurer/counter/tiktoken.d.ts +7 -0
  51. package/dist/plugins/mcp/transport-http.d.ts +13 -7
  52. package/dist/plugins/mcp/wire-rules.d.ts +21 -0
  53. package/dist/plugins/retrieval/document-file.d.ts +15 -0
  54. package/dist/plugins/retrieval/hosted-google.d.ts +8 -3
  55. package/dist/plugins/retrieval/hosted-openai.d.ts +9 -1
  56. package/dist/plugins/retrieval/hosted-xai.d.ts +8 -2
  57. package/dist/wire/chat-specs.d.ts +32 -0
  58. package/dist/wire/inherit.d.ts +0 -4
  59. package/dist/wire/interpreter.d.ts +44 -1
  60. package/dist/wire/mcp-specs.d.ts +13 -0
  61. package/dist/wire/media-specs.d.ts +20 -0
  62. package/dist/wire/pins.d.ts +34 -0
  63. package/dist/wire/registry.d.ts +6 -4
  64. package/dist/wire/retrieval-specs.d.ts +14 -0
  65. package/dist/wire/service-specs.d.ts +18 -0
  66. package/dist/wire/utility-specs.d.ts +10 -0
  67. package/package.json +4 -1
@@ -65,6 +65,9 @@ export interface EngineHandle {
65
65
  * createMediaOutput, complete) read these to wire LLM clients without
66
66
  * the caller passing apiKey explicitly. */
67
67
  apiKeys: Partial<Record<ProviderName, string>>;
68
+ /** Whether clients built from this engine check response shapes. Read by
69
+ * `createLLM`; see `checkResponseShapes` on the options. */
70
+ checkResponseShapes: boolean;
68
71
  /** Build an LLMClient bound to this engine.
69
72
  *
70
73
  * Exists so lower layers can obtain a client without importing the helpers
@@ -100,12 +103,31 @@ export interface EngineConfig {
100
103
  /** Custom low-level fetch transport — forwarded to the NetworkEngine's queue
101
104
  * (so retry/rate-limit/hooks still apply). Defaults to globalThis.fetch. */
102
105
  fetch?: FetchFn;
103
- /** Catalog wiring. Pass:
104
- * - `true` / 'defaults' load every bundled provider catalog.json
106
+ /** Warn when a provider's response stops looking like the one we learned to
107
+ * read: a field never seen before, a field that was always present and is now
108
+ * absent, or a discriminator carrying a value nothing branches on.
109
+ *
110
+ * OFF by default. It never changes what is parsed — it only emits `onWarning`,
111
+ * so subscribe with `hooks.on('onWarning', …)` and look for codes starting
112
+ * `response_shape_`. Each distinct finding is reported ONCE per client.
113
+ *
114
+ * Worth turning on in staging and in your test suite: response drift is the
115
+ * failure this library gives you the least warning about, because a renamed
116
+ * field still parses — into `undefined`. */
117
+ checkResponseShapes?: boolean;
118
+ /** Catalog wiring. **Defaults to the bundled provider catalogs.**
119
+ *
120
+ * The catalog is what the adapters read per model: which wire spec builds the
121
+ * request, what the model costs, which tokenizer counts it. Starting empty
122
+ * meant every one of those silently fell back — the id-derived spec, an
123
+ * unknown price, an estimated token count — and nothing said so. The data is
124
+ * statically imported either way, so leaving it unloaded saved no bytes.
125
+ *
126
+ * - undefined (default) / `true` / 'defaults' → every bundled catalog.json
105
127
  * - existing ModelCatalog instance → use as-is
106
- * - `{ entries: {...} }` → build empty + load() the entries
107
- * - undefined empty catalog */
108
- catalog?: ModelCatalog | true | 'defaults' | {
128
+ * - `{ entries: {...} }` → the given entries only
129
+ * - `false` / 'empty' no entries. Everything falls back; say so on purpose. */
130
+ catalog?: ModelCatalog | boolean | 'defaults' | 'empty' | {
109
131
  entries: Record<string, unknown>;
110
132
  };
111
133
  /** Per-provider API keys. Helpers consult this when no apiKey is passed