@dreb/ai 2.43.2 → 2.44.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.
package/README.md CHANGED
@@ -830,16 +830,27 @@ await streamAnthropic(claude, context, options);
830
830
 
831
831
  ## Cross-Provider Handoffs
832
832
 
833
- The library supports seamless handoffs between different LLM providers within the same conversation. This allows you to switch models mid-conversation while preserving context, including thinking blocks, tool calls, and tool results.
833
+ The library can prepare one conversation for another model without changing the stored `Context`. User messages, visible assistant text, tool calls, and tool results remain available, while model-bound tool signatures and IDs are normalized for the destination. Provider-specific reasoning state is handled conservatively.
834
834
 
835
- ### How It Works
835
+ ### Reasoning State Compatibility
836
836
 
837
- When messages from one provider are sent to a different provider, the library automatically transforms them for compatibility:
837
+ - **Exact model:** signed, encrypted, and redacted reasoning state is replayed unchanged.
838
+ - **Compatible model switch:** structured reasoning is preserved only when source and target share a provider, both use `openai-completions`, the destination accepts structured reasoning, and the source uses a recognized plain field: `reasoning_content`, `reasoning`, or `reasoning_text`.
839
+ - **Other readable reasoning:** it is retained as labelled plaintext inside `<reformatted-pre-switch-reasoning>` markers, with incompatible protocol metadata stripped.
840
+ - **Opaque state:** redacted or encrypted-only reasoning is omitted for incompatible targets.
838
841
 
839
- - **User and tool result messages** are passed through unchanged
840
- - **Assistant messages from the same provider/API** are preserved as-is
841
- - **Assistant messages from different providers** have their thinking blocks converted to text with `<thinking>` tags
842
- - **Tool calls and regular text** are preserved unchanged
842
+ Compatibility depends on provider, API, and signature behavior. This includes custom models: two models at the same endpoint are not compatible merely because their IDs or URLs match; they must share the configured provider identity as well.
843
+
844
+ The transformation applies only to the outbound request. It does not mutate `Context.messages`, so a later switch back to the original model can replay its original reasoning state unless that history has been compacted or pruned by the caller.
845
+
846
+ ### Examples
847
+
848
+ | Source and target | Outbound reasoning state |
849
+ |---|---|
850
+ | The same model | Original signed, encrypted, or redacted state is replayed unchanged. |
851
+ | Two models under the same custom provider, both using `openai-completions`, where the destination accepts the source's `reasoning_content`, `reasoning`, or `reasoning_text` field | Recognized plain structured reasoning is preserved. |
852
+ | Different providers or APIs with readable reasoning | Reasoning is sent as labelled plaintext in `<reformatted-pre-switch-reasoning>` markers. |
853
+ | An incompatible target with redacted or encrypted-only reasoning | Opaque reasoning state is omitted. |
843
854
 
844
855
  ### Example: Multi-Provider Conversation
845
856
 
@@ -858,32 +869,17 @@ const claudeResponse = await complete(claude, context, {
858
869
  });
859
870
  context.messages.push(claudeResponse);
860
871
 
861
- // Switch to GPT-5 - it will see Claude's thinking as <thinking> tagged text
872
+ // Switch to GPT-5. Readable Claude reasoning is reformatted for this outbound request.
862
873
  const gpt5 = getModel('openai', 'gpt-5-mini');
863
874
  context.messages.push({ role: 'user', content: 'Is that calculation correct?' });
864
875
  const gptResponse = await complete(gpt5, context);
865
876
  context.messages.push(gptResponse);
866
877
 
867
- // Switch to Gemini
868
- const gemini = getModel('google', 'gemini-2.5-flash');
878
+ // Switching back to Claude can use the original Claude state in context.
869
879
  context.messages.push({ role: 'user', content: 'What was the original question?' });
870
- const geminiResponse = await complete(gemini, context);
880
+ const finalClaudeResponse = await complete(claude, context);
871
881
  ```
872
882
 
873
- ### Provider Compatibility
874
-
875
- All providers can handle messages from other providers, including:
876
- - Text content
877
- - Tool calls and tool results (including images in tool results)
878
- - Thinking/reasoning blocks (transformed to tagged text for cross-provider compatibility)
879
- - Aborted messages with partial content
880
-
881
- This enables flexible workflows where you can:
882
- - Start with a fast model for initial responses
883
- - Switch to a more capable model for complex reasoning
884
- - Use specialized models for specific tasks
885
- - Maintain conversation continuity across provider outages
886
-
887
883
  ## Context Serialization
888
884
 
889
885
  The `Context` object can be easily serialized and deserialized using standard JSON methods, making it simple to persist conversations, implement chat history, or transfer contexts between services:
@@ -3827,6 +3827,40 @@ export declare const MODELS: {
3827
3827
  contextWindow: number;
3828
3828
  maxTokens: number;
3829
3829
  };
3830
+ readonly "gemini-3.5-flash-lite": {
3831
+ id: string;
3832
+ name: string;
3833
+ api: "google-generative-ai";
3834
+ provider: string;
3835
+ baseUrl: string;
3836
+ reasoning: true;
3837
+ input: ("image" | "text")[];
3838
+ cost: {
3839
+ input: number;
3840
+ output: number;
3841
+ cacheRead: number;
3842
+ cacheWrite: number;
3843
+ };
3844
+ contextWindow: number;
3845
+ maxTokens: number;
3846
+ };
3847
+ readonly "gemini-3.6-flash": {
3848
+ id: string;
3849
+ name: string;
3850
+ api: "google-generative-ai";
3851
+ provider: string;
3852
+ baseUrl: string;
3853
+ reasoning: true;
3854
+ input: ("image" | "text")[];
3855
+ cost: {
3856
+ input: number;
3857
+ output: number;
3858
+ cacheRead: number;
3859
+ cacheWrite: number;
3860
+ };
3861
+ contextWindow: number;
3862
+ maxTokens: number;
3863
+ };
3830
3864
  readonly "gemini-flash-latest": {
3831
3865
  id: string;
3832
3866
  name: string;
@@ -4903,6 +4937,26 @@ export declare const MODELS: {
4903
4937
  contextWindow: number;
4904
4938
  maxTokens: number;
4905
4939
  };
4940
+ readonly "XiaomiMiMo/MiMo-V2.5": {
4941
+ id: string;
4942
+ name: string;
4943
+ api: "openai-completions";
4944
+ provider: string;
4945
+ baseUrl: string;
4946
+ compat: {
4947
+ supportsDeveloperRole: false;
4948
+ };
4949
+ reasoning: true;
4950
+ input: "text"[];
4951
+ cost: {
4952
+ input: number;
4953
+ output: number;
4954
+ cacheRead: number;
4955
+ cacheWrite: number;
4956
+ };
4957
+ contextWindow: number;
4958
+ maxTokens: number;
4959
+ };
4906
4960
  readonly "XiaomiMiMo/MiMo-V2.5-Pro": {
4907
4961
  id: string;
4908
4962
  name: string;
@@ -5482,7 +5536,7 @@ export declare const MODELS: {
5482
5536
  contextWindow: number;
5483
5537
  maxTokens: number;
5484
5538
  };
5485
- readonly k2p7: {
5539
+ readonly k3: {
5486
5540
  id: string;
5487
5541
  name: string;
5488
5542
  api: "anthropic-messages";
@@ -5499,7 +5553,7 @@ export declare const MODELS: {
5499
5553
  contextWindow: number;
5500
5554
  maxTokens: number;
5501
5555
  };
5502
- readonly k3: {
5556
+ readonly "kimi-for-coding": {
5503
5557
  id: string;
5504
5558
  name: string;
5505
5559
  api: "anthropic-messages";
@@ -7501,6 +7555,40 @@ export declare const MODELS: {
7501
7555
  contextWindow: number;
7502
7556
  maxTokens: number;
7503
7557
  };
7558
+ readonly "gemini-3.5-flash-lite": {
7559
+ id: string;
7560
+ name: string;
7561
+ api: "google-generative-ai";
7562
+ provider: string;
7563
+ baseUrl: string;
7564
+ reasoning: true;
7565
+ input: ("image" | "text")[];
7566
+ cost: {
7567
+ input: number;
7568
+ output: number;
7569
+ cacheRead: number;
7570
+ cacheWrite: number;
7571
+ };
7572
+ contextWindow: number;
7573
+ maxTokens: number;
7574
+ };
7575
+ readonly "gemini-3.6-flash": {
7576
+ id: string;
7577
+ name: string;
7578
+ api: "google-generative-ai";
7579
+ provider: string;
7580
+ baseUrl: string;
7581
+ reasoning: true;
7582
+ input: ("image" | "text")[];
7583
+ cost: {
7584
+ input: number;
7585
+ output: number;
7586
+ cacheRead: number;
7587
+ cacheWrite: number;
7588
+ };
7589
+ contextWindow: number;
7590
+ maxTokens: number;
7591
+ };
7504
7592
  readonly "glm-5": {
7505
7593
  id: string;
7506
7594
  name: string;
@@ -7878,7 +7966,7 @@ export declare const MODELS: {
7878
7966
  readonly "grok-4.5": {
7879
7967
  id: string;
7880
7968
  name: string;
7881
- api: "openai-completions";
7969
+ api: "openai-responses";
7882
7970
  provider: string;
7883
7971
  baseUrl: string;
7884
7972
  reasoning: true;
@@ -7909,14 +7997,14 @@ export declare const MODELS: {
7909
7997
  contextWindow: number;
7910
7998
  maxTokens: number;
7911
7999
  };
7912
- readonly "hy3-free": {
8000
+ readonly "kimi-k2.5": {
7913
8001
  id: string;
7914
8002
  name: string;
7915
8003
  api: "openai-completions";
7916
8004
  provider: string;
7917
8005
  baseUrl: string;
7918
8006
  reasoning: true;
7919
- input: "text"[];
8007
+ input: ("image" | "text")[];
7920
8008
  cost: {
7921
8009
  input: number;
7922
8010
  output: number;
@@ -7926,7 +8014,7 @@ export declare const MODELS: {
7926
8014
  contextWindow: number;
7927
8015
  maxTokens: number;
7928
8016
  };
7929
- readonly "kimi-k2.5": {
8017
+ readonly "kimi-k2.6": {
7930
8018
  id: string;
7931
8019
  name: string;
7932
8020
  api: "openai-completions";
@@ -7943,7 +8031,7 @@ export declare const MODELS: {
7943
8031
  contextWindow: number;
7944
8032
  maxTokens: number;
7945
8033
  };
7946
- readonly "kimi-k2.6": {
8034
+ readonly "kimi-k2.7-code": {
7947
8035
  id: string;
7948
8036
  name: string;
7949
8037
  api: "openai-completions";
@@ -7960,14 +8048,14 @@ export declare const MODELS: {
7960
8048
  contextWindow: number;
7961
8049
  maxTokens: number;
7962
8050
  };
7963
- readonly "kimi-k2.7-code": {
8051
+ readonly "laguna-s-2.1-free": {
7964
8052
  id: string;
7965
8053
  name: string;
7966
8054
  api: "openai-completions";
7967
8055
  provider: string;
7968
8056
  baseUrl: string;
7969
8057
  reasoning: true;
7970
- input: ("image" | "text")[];
8058
+ input: "text"[];
7971
8059
  cost: {
7972
8060
  input: number;
7973
8061
  output: number;
@@ -8186,7 +8274,7 @@ export declare const MODELS: {
8186
8274
  readonly "grok-4.5": {
8187
8275
  id: string;
8188
8276
  name: string;
8189
- api: "openai-completions";
8277
+ api: "openai-responses";
8190
8278
  provider: string;
8191
8279
  baseUrl: string;
8192
8280
  reasoning: true;
@@ -8200,6 +8288,23 @@ export declare const MODELS: {
8200
8288
  contextWindow: number;
8201
8289
  maxTokens: number;
8202
8290
  };
8291
+ readonly hy3: {
8292
+ id: string;
8293
+ name: string;
8294
+ api: "openai-completions";
8295
+ provider: string;
8296
+ baseUrl: string;
8297
+ reasoning: true;
8298
+ input: "text"[];
8299
+ cost: {
8300
+ input: number;
8301
+ output: number;
8302
+ cacheRead: number;
8303
+ cacheWrite: number;
8304
+ };
8305
+ contextWindow: number;
8306
+ maxTokens: number;
8307
+ };
8203
8308
  readonly "kimi-k2.6": {
8204
8309
  id: string;
8205
8310
  name: string;
@@ -9324,6 +9429,40 @@ export declare const MODELS: {
9324
9429
  contextWindow: number;
9325
9430
  maxTokens: number;
9326
9431
  };
9432
+ readonly "google/gemini-3.5-flash-lite": {
9433
+ id: string;
9434
+ name: string;
9435
+ api: "openai-completions";
9436
+ provider: string;
9437
+ baseUrl: string;
9438
+ reasoning: true;
9439
+ input: ("image" | "text")[];
9440
+ cost: {
9441
+ input: number;
9442
+ output: number;
9443
+ cacheRead: number;
9444
+ cacheWrite: number;
9445
+ };
9446
+ contextWindow: number;
9447
+ maxTokens: number;
9448
+ };
9449
+ readonly "google/gemini-3.6-flash": {
9450
+ id: string;
9451
+ name: string;
9452
+ api: "openai-completions";
9453
+ provider: string;
9454
+ baseUrl: string;
9455
+ reasoning: true;
9456
+ input: ("image" | "text")[];
9457
+ cost: {
9458
+ input: number;
9459
+ output: number;
9460
+ cacheRead: number;
9461
+ cacheWrite: number;
9462
+ };
9463
+ contextWindow: number;
9464
+ maxTokens: number;
9465
+ };
9327
9466
  readonly "google/gemma-3-12b-it": {
9328
9467
  id: string;
9329
9468
  name: string;
@@ -9562,13 +9701,13 @@ export declare const MODELS: {
9562
9701
  contextWindow: number;
9563
9702
  maxTokens: number;
9564
9703
  };
9565
- readonly "meta-llama/llama-3.1-70b-instruct": {
9704
+ readonly "meituan/longcat-2.0": {
9566
9705
  id: string;
9567
9706
  name: string;
9568
9707
  api: "openai-completions";
9569
9708
  provider: string;
9570
9709
  baseUrl: string;
9571
- reasoning: false;
9710
+ reasoning: true;
9572
9711
  input: "text"[];
9573
9712
  cost: {
9574
9713
  input: number;
@@ -9579,7 +9718,7 @@ export declare const MODELS: {
9579
9718
  contextWindow: number;
9580
9719
  maxTokens: number;
9581
9720
  };
9582
- readonly "meta-llama/llama-3.1-8b-instruct": {
9721
+ readonly "meta-llama/llama-3.1-70b-instruct": {
9583
9722
  id: string;
9584
9723
  name: string;
9585
9724
  api: "openai-completions";
@@ -9596,7 +9735,7 @@ export declare const MODELS: {
9596
9735
  contextWindow: number;
9597
9736
  maxTokens: number;
9598
9737
  };
9599
- readonly "meta-llama/llama-3.3-70b-instruct": {
9738
+ readonly "meta-llama/llama-3.1-8b-instruct": {
9600
9739
  id: string;
9601
9740
  name: string;
9602
9741
  api: "openai-completions";
@@ -9613,7 +9752,7 @@ export declare const MODELS: {
9613
9752
  contextWindow: number;
9614
9753
  maxTokens: number;
9615
9754
  };
9616
- readonly "meta-llama/llama-3.3-70b-instruct:free": {
9755
+ readonly "meta-llama/llama-3.3-70b-instruct": {
9617
9756
  id: string;
9618
9757
  name: string;
9619
9758
  api: "openai-completions";
@@ -11466,6 +11605,40 @@ export declare const MODELS: {
11466
11605
  contextWindow: number;
11467
11606
  maxTokens: number;
11468
11607
  };
11608
+ readonly "poolside/laguna-s-2.1": {
11609
+ id: string;
11610
+ name: string;
11611
+ api: "openai-completions";
11612
+ provider: string;
11613
+ baseUrl: string;
11614
+ reasoning: true;
11615
+ input: "text"[];
11616
+ cost: {
11617
+ input: number;
11618
+ output: number;
11619
+ cacheRead: number;
11620
+ cacheWrite: number;
11621
+ };
11622
+ contextWindow: number;
11623
+ maxTokens: number;
11624
+ };
11625
+ readonly "poolside/laguna-s-2.1:free": {
11626
+ id: string;
11627
+ name: string;
11628
+ api: "openai-completions";
11629
+ provider: string;
11630
+ baseUrl: string;
11631
+ reasoning: true;
11632
+ input: "text"[];
11633
+ cost: {
11634
+ input: number;
11635
+ output: number;
11636
+ cacheRead: number;
11637
+ cacheWrite: number;
11638
+ };
11639
+ contextWindow: number;
11640
+ maxTokens: number;
11641
+ };
11469
11642
  readonly "poolside/laguna-xs-2.1": {
11470
11643
  id: string;
11471
11644
  name: string;
@@ -11823,23 +11996,6 @@ export declare const MODELS: {
11823
11996
  contextWindow: number;
11824
11997
  maxTokens: number;
11825
11998
  };
11826
- readonly "qwen/qwen3-coder:free": {
11827
- id: string;
11828
- name: string;
11829
- api: "openai-completions";
11830
- provider: string;
11831
- baseUrl: string;
11832
- reasoning: false;
11833
- input: "text"[];
11834
- cost: {
11835
- input: number;
11836
- output: number;
11837
- cacheRead: number;
11838
- cacheWrite: number;
11839
- };
11840
- contextWindow: number;
11841
- maxTokens: number;
11842
- };
11843
11999
  readonly "qwen/qwen3-max": {
11844
12000
  id: string;
11845
12001
  name: string;
@@ -11891,23 +12047,6 @@ export declare const MODELS: {
11891
12047
  contextWindow: number;
11892
12048
  maxTokens: number;
11893
12049
  };
11894
- readonly "qwen/qwen3-next-80b-a3b-instruct:free": {
11895
- id: string;
11896
- name: string;
11897
- api: "openai-completions";
11898
- provider: string;
11899
- baseUrl: string;
11900
- reasoning: false;
11901
- input: "text"[];
11902
- cost: {
11903
- input: number;
11904
- output: number;
11905
- cacheRead: number;
11906
- cacheWrite: number;
11907
- };
11908
- contextWindow: number;
11909
- maxTokens: number;
11910
- };
11911
12050
  readonly "qwen/qwen3-next-80b-a3b-thinking": {
11912
12051
  id: string;
11913
12052
  name: string;
@@ -12435,23 +12574,6 @@ export declare const MODELS: {
12435
12574
  contextWindow: number;
12436
12575
  maxTokens: number;
12437
12576
  };
12438
- readonly "tencent/hy3:free": {
12439
- id: string;
12440
- name: string;
12441
- api: "openai-completions";
12442
- provider: string;
12443
- baseUrl: string;
12444
- reasoning: true;
12445
- input: "text"[];
12446
- cost: {
12447
- input: number;
12448
- output: number;
12449
- cacheRead: number;
12450
- cacheWrite: number;
12451
- };
12452
- contextWindow: number;
12453
- maxTokens: number;
12454
- };
12455
12577
  readonly "thedrummer/unslopnemo-12b": {
12456
12578
  id: string;
12457
12579
  name: string;
@@ -14086,6 +14208,40 @@ export declare const MODELS: {
14086
14208
  contextWindow: number;
14087
14209
  maxTokens: number;
14088
14210
  };
14211
+ readonly "google/gemini-3.5-flash-lite": {
14212
+ id: string;
14213
+ name: string;
14214
+ api: "anthropic-messages";
14215
+ provider: string;
14216
+ baseUrl: string;
14217
+ reasoning: true;
14218
+ input: ("image" | "text")[];
14219
+ cost: {
14220
+ input: number;
14221
+ output: number;
14222
+ cacheRead: number;
14223
+ cacheWrite: number;
14224
+ };
14225
+ contextWindow: number;
14226
+ maxTokens: number;
14227
+ };
14228
+ readonly "google/gemini-3.6-flash": {
14229
+ id: string;
14230
+ name: string;
14231
+ api: "anthropic-messages";
14232
+ provider: string;
14233
+ baseUrl: string;
14234
+ reasoning: true;
14235
+ input: ("image" | "text")[];
14236
+ cost: {
14237
+ input: number;
14238
+ output: number;
14239
+ cacheRead: number;
14240
+ cacheWrite: number;
14241
+ };
14242
+ contextWindow: number;
14243
+ maxTokens: number;
14244
+ };
14089
14245
  readonly "google/gemma-4-26b-a4b-it": {
14090
14246
  id: string;
14091
14247
  name: string;
@@ -14154,6 +14310,23 @@ export declare const MODELS: {
14154
14310
  contextWindow: number;
14155
14311
  maxTokens: number;
14156
14312
  };
14313
+ readonly "inclusionai/ling-3.0-flash-free": {
14314
+ id: string;
14315
+ name: string;
14316
+ api: "anthropic-messages";
14317
+ provider: string;
14318
+ baseUrl: string;
14319
+ reasoning: true;
14320
+ input: "text"[];
14321
+ cost: {
14322
+ input: number;
14323
+ output: number;
14324
+ cacheRead: number;
14325
+ cacheWrite: number;
14326
+ };
14327
+ contextWindow: number;
14328
+ maxTokens: number;
14329
+ };
14157
14330
  readonly "interfaze/interfaze-beta": {
14158
14331
  id: string;
14159
14332
  name: string;
@@ -15633,6 +15806,40 @@ export declare const MODELS: {
15633
15806
  contextWindow: number;
15634
15807
  maxTokens: number;
15635
15808
  };
15809
+ readonly "poolside/laguna-s-2.1": {
15810
+ id: string;
15811
+ name: string;
15812
+ api: "anthropic-messages";
15813
+ provider: string;
15814
+ baseUrl: string;
15815
+ reasoning: true;
15816
+ input: "text"[];
15817
+ cost: {
15818
+ input: number;
15819
+ output: number;
15820
+ cacheRead: number;
15821
+ cacheWrite: number;
15822
+ };
15823
+ contextWindow: number;
15824
+ maxTokens: number;
15825
+ };
15826
+ readonly "poolside/laguna-s-2.1-free": {
15827
+ id: string;
15828
+ name: string;
15829
+ api: "anthropic-messages";
15830
+ provider: string;
15831
+ baseUrl: string;
15832
+ reasoning: true;
15833
+ input: "text"[];
15834
+ cost: {
15835
+ input: number;
15836
+ output: number;
15837
+ cacheRead: number;
15838
+ cacheWrite: number;
15839
+ };
15840
+ contextWindow: number;
15841
+ maxTokens: number;
15842
+ };
15636
15843
  readonly "sakana/fugu-ultra": {
15637
15844
  id: string;
15638
15845
  name: string;
@@ -15684,6 +15891,23 @@ export declare const MODELS: {
15684
15891
  contextWindow: number;
15685
15892
  maxTokens: number;
15686
15893
  };
15894
+ readonly "tencent/hy3": {
15895
+ id: string;
15896
+ name: string;
15897
+ api: "anthropic-messages";
15898
+ provider: string;
15899
+ baseUrl: string;
15900
+ reasoning: true;
15901
+ input: "text"[];
15902
+ cost: {
15903
+ input: number;
15904
+ output: number;
15905
+ cacheRead: number;
15906
+ cacheWrite: number;
15907
+ };
15908
+ contextWindow: number;
15909
+ maxTokens: number;
15910
+ };
15687
15911
  readonly "thinkingmachines/inkling": {
15688
15912
  id: string;
15689
15913
  name: string;