@fungi.computer/mule 0.1.0 → 0.1.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.
@@ -108,9 +108,9 @@ Decode and authorize one exact Pi tool call before it can execute.
108
108
 
109
109
  ###### Parameters
110
110
 
111
- | Parameter | Type |
112
- | --------- | ---------- |
113
- | `call` | `ToolCall` |
111
+ | Parameter | Type |
112
+ | --------- | ----------------------- |
113
+ | `call` | [`ToolCall`](#toolcall) |
114
114
 
115
115
  ###### Returns
116
116
 
@@ -150,16 +150,16 @@ fiber; the run then ends with a `cancelled` `run_end`.
150
150
 
151
151
  #### Type Declaration
152
152
 
153
- | Name | Type | Description |
154
- | ------------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
155
- | `prepareSystemPrompt()?` | () => `Effect.Effect`\<`string`, [`MuleError`](index.md#muleerror)\> | Rebuild the model system prompt immediately before each provider request. |
156
- | `tools?` | readonly [`MuleTool`](#muletool)[] | - |
157
- | `resolveApiKey()?` | (`provider`) => `Effect.Effect`\<`string` \| `undefined`, [`MuleError`](index.md#muleerror)\> | Resolve a fresh provider credential immediately before each Pi call. |
158
- | `getSteeringMessages()?` | () => `Effect.Effect`\<readonly `Message`[], [`MuleError`](index.md#muleerror)\> | Pull messages that should steer the active run at Pi's safe point. |
159
- | `getFollowUpMessages()?` | () => `Effect.Effect`\<readonly `Message`[], [`MuleError`](index.md#muleerror)\> | Pull messages queued until the run would otherwise finish. |
160
- | `prepareNextTurn()?` | (`turn`) => `Effect.Effect`\<readonly `Message`[] \| `undefined`, [`MuleError`](index.md#muleerror)\> | Pi's between-turn point: after a turn's tool results and before the next assistant request of the same run. Return a replacement context, such as one rebuilt after compaction, or `undefined` to keep the current one. |
161
- | `shouldStopAfterTurn()?` | (`turn`) => `Effect.Effect`\<`boolean`, [`MuleError`](index.md#muleerror)\> | Request a graceful stop after the current Pi turn has fully settled. |
162
- | `onRetry()?` | (`event`) => `Effect.Effect`\<`void`, [`MuleError`](index.md#muleerror)\> | Effect-native observation sink for Pi's retry policy (`retry`), one call per scheduled or finished retry. |
153
+ | Name | Type | Description |
154
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
155
+ | `prepareSystemPrompt()?` | () => `Effect.Effect`\<`string`, [`MuleError`](index.md#muleerror)\> | Rebuild the model system prompt immediately before each provider request. |
156
+ | `tools?` | readonly [`MuleTool`](#muletool)[] | - |
157
+ | `resolveApiKey()?` | (`provider`) => `Effect.Effect`\<`string` \| `undefined`, [`MuleError`](index.md#muleerror)\> | Resolve a fresh provider credential immediately before each Pi call. |
158
+ | `getSteeringMessages()?` | () => `Effect.Effect`\<readonly [`Message`](#message)[], [`MuleError`](index.md#muleerror)\> | Pull messages that should steer the active run at Pi's safe point. |
159
+ | `getFollowUpMessages()?` | () => `Effect.Effect`\<readonly [`Message`](#message)[], [`MuleError`](index.md#muleerror)\> | Pull messages queued until the run would otherwise finish. |
160
+ | `prepareNextTurn()?` | (`turn`) => `Effect.Effect`\<readonly [`Message`](#message)[] \| `undefined`, [`MuleError`](index.md#muleerror)\> | Pi's between-turn point: after a turn's tool results and before the next assistant request of the same run. Return a replacement context, such as one rebuilt after compaction, or `undefined` to keep the current one. |
161
+ | `shouldStopAfterTurn()?` | (`turn`) => `Effect.Effect`\<`boolean`, [`MuleError`](index.md#muleerror)\> | Request a graceful stop after the current Pi turn has fully settled. |
162
+ | `onRetry()?` | (`event`) => `Effect.Effect`\<`void`, [`MuleError`](index.md#muleerror)\> | Effect-native observation sink for Pi's retry policy (`retry`), one call per scheduled or finished retry. |
163
163
 
164
164
  ---
165
165
 
@@ -193,6 +193,1645 @@ Run one complete Pi model/tool loop.
193
193
  `Effect.Effect`\<[`MuleRunOutcome`](index.md#mulerunoutcome),
194
194
  [`MuleError`](index.md#muleerror)\>
195
195
 
196
+ ---
197
+
198
+ ### ThinkingLevel
199
+
200
+ ```ts
201
+ type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
202
+ ```
203
+
204
+ Provider-neutral reasoning effort requested by a caller.
205
+
206
+ ---
207
+
208
+ ### ModelThinkingLevel
209
+
210
+ ```ts
211
+ type ModelThinkingLevel = "off" | ThinkingLevel;
212
+ ```
213
+
214
+ Effective reasoning effort, including disabled thinking.
215
+
216
+ ---
217
+
218
+ ### KnownApi
219
+
220
+ ```ts
221
+ type KnownApi =
222
+ | "openai-completions"
223
+ | "mistral-conversations"
224
+ | "openai-responses"
225
+ | "azure-openai-responses"
226
+ | "openai-codex-responses"
227
+ | "anthropic-messages"
228
+ | "bedrock-converse-stream"
229
+ | "google-generative-ai"
230
+ | "google-vertex"
231
+ | "pi-messages";
232
+ ```
233
+
234
+ Built-in chat APIs recognized by the pinned Pi adapter.
235
+
236
+ ---
237
+
238
+ ### Api
239
+
240
+ ```ts
241
+ type Api = KnownApi | (string & object);
242
+ ```
243
+
244
+ Built-in or caller-defined chat API identifier.
245
+
246
+ ---
247
+
248
+ ### ProviderId
249
+
250
+ ```ts
251
+ type ProviderId = string;
252
+ ```
253
+
254
+ Provider identifier carried with a model or assistant message.
255
+
256
+ ---
257
+
258
+ ### ToolChoice
259
+
260
+ ```ts
261
+ type ToolChoice = "auto" | "none";
262
+ ```
263
+
264
+ Provider-neutral choice to allow or disable tools.
265
+
266
+ ---
267
+
268
+ ### SamplingParams
269
+
270
+ ```ts
271
+ type SamplingParams = JsonObject;
272
+ ```
273
+
274
+ Provider sampling fields passed through unchanged.
275
+
276
+ ---
277
+
278
+ ### SamplingParamsByThinkingLevel
279
+
280
+ ```ts
281
+ type SamplingParamsByThinkingLevel = Partial<
282
+ Record<ModelThinkingLevel, SamplingParams>
283
+ >;
284
+ ```
285
+
286
+ Sampling overrides selected by reasoning effort.
287
+
288
+ ---
289
+
290
+ ### ThinkingBudgets
291
+
292
+ ```ts
293
+ type ThinkingBudgets = object;
294
+ ```
295
+
296
+ Token budgets for providers that meter reasoning separately.
297
+
298
+ #### Properties
299
+
300
+ ##### minimal?
301
+
302
+ ```ts
303
+ optional minimal?: number;
304
+ ```
305
+
306
+ ##### low?
307
+
308
+ ```ts
309
+ optional low?: number;
310
+ ```
311
+
312
+ ##### medium?
313
+
314
+ ```ts
315
+ optional medium?: number;
316
+ ```
317
+
318
+ ##### high?
319
+
320
+ ```ts
321
+ optional high?: number;
322
+ ```
323
+
324
+ ---
325
+
326
+ ### Transport
327
+
328
+ ```ts
329
+ type Transport = "sse" | "websocket" | "websocket-cached" | "auto";
330
+ ```
331
+
332
+ Preferred provider stream transport.
333
+
334
+ ---
335
+
336
+ ### ProviderEnv
337
+
338
+ ```ts
339
+ type ProviderEnv = Record<string, string>;
340
+ ```
341
+
342
+ Request-scoped provider environment overrides.
343
+
344
+ ---
345
+
346
+ ### ProviderHeaders
347
+
348
+ ```ts
349
+ type ProviderHeaders = Record<string, string | null>;
350
+ ```
351
+
352
+ Provider headers; null removes a default header.
353
+
354
+ ---
355
+
356
+ ### FetchFunction
357
+
358
+ ```ts
359
+ type FetchFunction = typeof globalThis.fetch;
360
+ ```
361
+
362
+ Fetch implementation supplied to the provider adapter.
363
+
364
+ ---
365
+
366
+ ### ProviderResponse
367
+
368
+ ```ts
369
+ type ProviderResponse = object;
370
+ ```
371
+
372
+ HTTP status and headers observed before stream consumption.
373
+
374
+ #### Properties
375
+
376
+ ##### status
377
+
378
+ ```ts
379
+ status: number;
380
+ ```
381
+
382
+ ##### headers
383
+
384
+ ```ts
385
+ headers: Record<string, string>;
386
+ ```
387
+
388
+ ---
389
+
390
+ ### ProviderRequestOptions
391
+
392
+ ```ts
393
+ type ProviderRequestOptions<TModel> = object;
394
+ ```
395
+
396
+ Authentication, transport and lifecycle hooks for one provider request.
397
+
398
+ #### Type Parameters
399
+
400
+ | Type Parameter | Default type |
401
+ | -------------- | ------------------------------------ |
402
+ | `TModel` | [`Model`](#model-1)\<[`Api`](#api)\> |
403
+
404
+ #### Properties
405
+
406
+ ##### signal?
407
+
408
+ ```ts
409
+ optional signal?: AbortSignal;
410
+ ```
411
+
412
+ ##### telemetryContext?
413
+
414
+ ```ts
415
+ optional telemetryContext?: TelemetryContext;
416
+ ```
417
+
418
+ ##### apiKey?
419
+
420
+ ```ts
421
+ optional apiKey?: string;
422
+ ```
423
+
424
+ ##### fetch?
425
+
426
+ ```ts
427
+ optional fetch?: FetchFunction;
428
+ ```
429
+
430
+ Override HTTP transport for this request.
431
+
432
+ ##### env?
433
+
434
+ ```ts
435
+ optional env?: ProviderEnv;
436
+ ```
437
+
438
+ ##### onPayload?
439
+
440
+ ```ts
441
+ optional onPayload?: (payload, model) =>
442
+ | ProviderData
443
+ | undefined
444
+ | Promise<ProviderData | undefined>;
445
+ ```
446
+
447
+ Observe or replace the provider payload before dispatch.
448
+
449
+ ###### Parameters
450
+
451
+ | Parameter | Type |
452
+ | --------- | ------------------------------- |
453
+ | `payload` | [`ProviderData`](#providerdata) |
454
+ | `model` | `TModel` |
455
+
456
+ ###### Returns
457
+
458
+ \| [`ProviderData`](#providerdata) \| `undefined` \|
459
+ `Promise`\<[`ProviderData`](#providerdata) \| `undefined`\>
460
+
461
+ ##### onResponse?
462
+
463
+ ```ts
464
+ optional onResponse?: (response, model) => void | Promise<void>;
465
+ ```
466
+
467
+ Observe status and headers before provider stream consumption.
468
+
469
+ ###### Parameters
470
+
471
+ | Parameter | Type |
472
+ | ---------- | --------------------------------------- |
473
+ | `response` | [`ProviderResponse`](#providerresponse) |
474
+ | `model` | `TModel` |
475
+
476
+ ###### Returns
477
+
478
+ `void` \| `Promise`\<`void`\>
479
+
480
+ ##### headers?
481
+
482
+ ```ts
483
+ optional headers?: ProviderHeaders;
484
+ ```
485
+
486
+ ##### timeoutMs?
487
+
488
+ ```ts
489
+ optional timeoutMs?: number;
490
+ ```
491
+
492
+ ##### maxRetries?
493
+
494
+ ```ts
495
+ optional maxRetries?: number;
496
+ ```
497
+
498
+ ##### maxRetryDelayMs?
499
+
500
+ ```ts
501
+ optional maxRetryDelayMs?: number;
502
+ ```
503
+
504
+ ---
505
+
506
+ ### StreamOptions
507
+
508
+ ```ts
509
+ type StreamOptions = object & ProviderRequestOptions;
510
+ ```
511
+
512
+ Common provider stream controls, independent of any SDK.
513
+
514
+ #### Type Declaration
515
+
516
+ | Name | Type | Description |
517
+ | ---------------------------- | -------------------------------------------------- | -------------------------------------------------------- |
518
+ | `onProviderStreamEvent()?` | (`data`, `model`) => `void` \| `Promise`\<`void`\> | Observe an adapter-parsed event before Pi normalizes it. |
519
+ | `temperature?` | `number` | - |
520
+ | `samplingParams?` | [`SamplingParams`](#samplingparams) | - |
521
+ | `maxTokens?` | `number` | - |
522
+ | `transport?` | [`Transport`](#transport) | - |
523
+ | `cacheRetention?` | `CacheRetention` | - |
524
+ | `sessionId?` | `string` | - |
525
+ | `websocketConnectTimeoutMs?` | `number` | - |
526
+ | `metadata?` | [`JsonObject`](#jsonobject) | - |
527
+
528
+ ---
529
+
530
+ ### SimpleStreamOptions
531
+
532
+ ```ts
533
+ type SimpleStreamOptions = object & StreamOptions;
534
+ ```
535
+
536
+ Provider-neutral model request options used by Mule.
537
+
538
+ #### Type Declaration
539
+
540
+ | Name | Type |
541
+ | ------------------ | -------------------------------------------------------------- |
542
+ | `toolChoice?` | [`ToolChoice`](#toolchoice) |
543
+ | `reasoning?` | [`ThinkingLevel`](#thinkinglevel) |
544
+ | `deferred?` | \| `boolean` \| \{ `window?`: `"15m"` \| `"1h"` \| `"24h"`; \} |
545
+ | `thinkingBudgets?` | [`ThinkingBudgets`](#thinkingbudgets) |
546
+
547
+ ---
548
+
549
+ ### TextContent
550
+
551
+ ```ts
552
+ type TextContent = object;
553
+ ```
554
+
555
+ Text block with an optional provider continuity signature.
556
+
557
+ #### Properties
558
+
559
+ ##### type
560
+
561
+ ```ts
562
+ type: "text";
563
+ ```
564
+
565
+ ##### text
566
+
567
+ ```ts
568
+ text: string;
569
+ ```
570
+
571
+ ##### textSignature?
572
+
573
+ ```ts
574
+ optional textSignature?: string;
575
+ ```
576
+
577
+ ---
578
+
579
+ ### ThinkingContent
580
+
581
+ ```ts
582
+ type ThinkingContent = object;
583
+ ```
584
+
585
+ Reasoning block, including opaque redacted provider thinking.
586
+
587
+ #### Properties
588
+
589
+ ##### type
590
+
591
+ ```ts
592
+ type: "thinking";
593
+ ```
594
+
595
+ ##### thinking
596
+
597
+ ```ts
598
+ thinking: string;
599
+ ```
600
+
601
+ ##### thinkingSignature?
602
+
603
+ ```ts
604
+ optional thinkingSignature?: string;
605
+ ```
606
+
607
+ ##### redacted?
608
+
609
+ ```ts
610
+ optional redacted?: boolean;
611
+ ```
612
+
613
+ ---
614
+
615
+ ### ImageContent
616
+
617
+ ```ts
618
+ type ImageContent = object;
619
+ ```
620
+
621
+ Base64 image bytes with their media type.
622
+
623
+ #### Properties
624
+
625
+ ##### type
626
+
627
+ ```ts
628
+ type: "image";
629
+ ```
630
+
631
+ ##### data
632
+
633
+ ```ts
634
+ data: string;
635
+ ```
636
+
637
+ ##### mimeType
638
+
639
+ ```ts
640
+ mimeType: string;
641
+ ```
642
+
643
+ ---
644
+
645
+ ### ToolCall
646
+
647
+ ```ts
648
+ type ToolCall = object;
649
+ ```
650
+
651
+ Model-requested tool invocation with JSON arguments.
652
+
653
+ #### Properties
654
+
655
+ ##### type
656
+
657
+ ```ts
658
+ type: "toolCall";
659
+ ```
660
+
661
+ ##### id
662
+
663
+ ```ts
664
+ id: string;
665
+ ```
666
+
667
+ ##### name
668
+
669
+ ```ts
670
+ name: string;
671
+ ```
672
+
673
+ ##### arguments
674
+
675
+ ```ts
676
+ arguments: JsonObject;
677
+ ```
678
+
679
+ ##### thoughtSignature?
680
+
681
+ ```ts
682
+ optional thoughtSignature?: string;
683
+ ```
684
+
685
+ ##### namespace?
686
+
687
+ ```ts
688
+ optional namespace?: string;
689
+ ```
690
+
691
+ ##### argumentsError?
692
+
693
+ ```ts
694
+ optional argumentsError?: string;
695
+ ```
696
+
697
+ ---
698
+
699
+ ### Usage
700
+
701
+ ```ts
702
+ type Usage = object;
703
+ ```
704
+
705
+ Token counts and provider costs for one response or tool result.
706
+
707
+ #### Properties
708
+
709
+ ##### input
710
+
711
+ ```ts
712
+ input: number;
713
+ ```
714
+
715
+ ##### output
716
+
717
+ ```ts
718
+ output: number;
719
+ ```
720
+
721
+ ##### cacheRead
722
+
723
+ ```ts
724
+ cacheRead: number;
725
+ ```
726
+
727
+ ##### cacheWrite
728
+
729
+ ```ts
730
+ cacheWrite: number;
731
+ ```
732
+
733
+ ##### cacheWrite1h?
734
+
735
+ ```ts
736
+ optional cacheWrite1h?: number;
737
+ ```
738
+
739
+ ##### reasoning?
740
+
741
+ ```ts
742
+ optional reasoning?: number;
743
+ ```
744
+
745
+ ##### totalTokens
746
+
747
+ ```ts
748
+ totalTokens: number;
749
+ ```
750
+
751
+ ##### cost
752
+
753
+ ```ts
754
+ cost: object;
755
+ ```
756
+
757
+ ###### input
758
+
759
+ ```ts
760
+ input: number;
761
+ ```
762
+
763
+ ###### output
764
+
765
+ ```ts
766
+ output: number;
767
+ ```
768
+
769
+ ###### cacheRead
770
+
771
+ ```ts
772
+ cacheRead: number;
773
+ ```
774
+
775
+ ###### cacheWrite
776
+
777
+ ```ts
778
+ cacheWrite: number;
779
+ ```
780
+
781
+ ###### total
782
+
783
+ ```ts
784
+ total: number;
785
+ ```
786
+
787
+ ---
788
+
789
+ ### StopReason
790
+
791
+ ```ts
792
+ type StopReason =
793
+ "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
794
+ ```
795
+
796
+ Provider outcome for an assistant response.
797
+
798
+ ---
799
+
800
+ ### JsonValue
801
+
802
+ ```ts
803
+ type JsonValue =
804
+ null | boolean | number | string | readonly JsonValue[] | JsonObject;
805
+ ```
806
+
807
+ JSON data carried by messages and tool results.
808
+
809
+ ---
810
+
811
+ ### ProviderValue
812
+
813
+ ```ts
814
+ type ProviderValue =
815
+ | undefined
816
+ | null
817
+ | boolean
818
+ | number
819
+ | string
820
+ | Uint8Array
821
+ | AbortSignal
822
+ | readonly ProviderValue[]
823
+ | ProviderData;
824
+ ```
825
+
826
+ Provider request/event values, including optional fields, binary bytes and
827
+ cancellation.
828
+
829
+ ---
830
+
831
+ ### ProviderData
832
+
833
+ ```ts
834
+ type ProviderData = object;
835
+ ```
836
+
837
+ Parsed provider request or event fields; Pi owns the provider-specific grammar.
838
+
839
+ #### Index Signature
840
+
841
+ ```ts
842
+ [key: string]: ProviderValue
843
+ ```
844
+
845
+ ---
846
+
847
+ ### JsonObject
848
+
849
+ ```ts
850
+ type JsonObject = object;
851
+ ```
852
+
853
+ Named JSON properties in tool arguments or message metadata.
854
+
855
+ #### Index Signature
856
+
857
+ ```ts
858
+ [key: string]: JsonValue
859
+ ```
860
+
861
+ ---
862
+
863
+ ### DeferredHandle
864
+
865
+ ```ts
866
+ type DeferredHandle = object;
867
+ ```
868
+
869
+ Provider receipt used to recover a deferred assistant response.
870
+
871
+ #### Properties
872
+
873
+ ##### provider
874
+
875
+ ```ts
876
+ provider: string;
877
+ ```
878
+
879
+ ##### modelId
880
+
881
+ ```ts
882
+ modelId: string;
883
+ ```
884
+
885
+ ##### api
886
+
887
+ ```ts
888
+ api: string;
889
+ ```
890
+
891
+ ##### id
892
+
893
+ ```ts
894
+ id: string;
895
+ ```
896
+
897
+ ##### expiresAt?
898
+
899
+ ```ts
900
+ optional expiresAt?: number;
901
+ ```
902
+
903
+ ##### pollAfterMs?
904
+
905
+ ```ts
906
+ optional pollAfterMs?: number;
907
+ ```
908
+
909
+ ##### data?
910
+
911
+ ```ts
912
+ optional data?: JsonValue;
913
+ ```
914
+
915
+ ---
916
+
917
+ ### SystemMessage
918
+
919
+ ```ts
920
+ type SystemMessage = object;
921
+ ```
922
+
923
+ Prompt and tool-set update at a point in the transcript.
924
+
925
+ #### Properties
926
+
927
+ ##### role
928
+
929
+ ```ts
930
+ role: "system";
931
+ ```
932
+
933
+ ##### content
934
+
935
+ ```ts
936
+ content: string | TextContent[];
937
+ ```
938
+
939
+ ##### sections?
940
+
941
+ ```ts
942
+ optional sections?: Record<string, string | null>;
943
+ ```
944
+
945
+ ##### toolsAdded?
946
+
947
+ ```ts
948
+ optional toolsAdded?: Tool[];
949
+ ```
950
+
951
+ ##### toolsRemoved?
952
+
953
+ ```ts
954
+ optional toolsRemoved?: ToolReference[];
955
+ ```
956
+
957
+ ##### timestamp
958
+
959
+ ```ts
960
+ timestamp: number;
961
+ ```
962
+
963
+ ---
964
+
965
+ ### UserMessage
966
+
967
+ ```ts
968
+ type UserMessage = object;
969
+ ```
970
+
971
+ User text and image input with its timestamp.
972
+
973
+ #### Properties
974
+
975
+ ##### role
976
+
977
+ ```ts
978
+ role: "user";
979
+ ```
980
+
981
+ ##### content
982
+
983
+ ```ts
984
+ content:
985
+ | string
986
+ | (TextContent | ImageContent)[];
987
+ ```
988
+
989
+ ##### timestamp
990
+
991
+ ```ts
992
+ timestamp: number;
993
+ ```
994
+
995
+ ---
996
+
997
+ ### AssistantMessage
998
+
999
+ ```ts
1000
+ type AssistantMessage = object;
1001
+ ```
1002
+
1003
+ Provider response, usage and terminal reason, preserved by Mule.
1004
+
1005
+ #### Properties
1006
+
1007
+ ##### role
1008
+
1009
+ ```ts
1010
+ role: "assistant";
1011
+ ```
1012
+
1013
+ ##### content
1014
+
1015
+ ```ts
1016
+ content: (
1017
+ | TextContent
1018
+ | ThinkingContent
1019
+ | ToolCall)[];
1020
+ ```
1021
+
1022
+ ##### api
1023
+
1024
+ ```ts
1025
+ api: Api;
1026
+ ```
1027
+
1028
+ ##### provider
1029
+
1030
+ ```ts
1031
+ provider: ProviderId;
1032
+ ```
1033
+
1034
+ ##### model
1035
+
1036
+ ```ts
1037
+ model: string;
1038
+ ```
1039
+
1040
+ ##### responseModel?
1041
+
1042
+ ```ts
1043
+ optional responseModel?: string;
1044
+ ```
1045
+
1046
+ ##### responseId?
1047
+
1048
+ ```ts
1049
+ optional responseId?: string;
1050
+ ```
1051
+
1052
+ ##### providerThinkingLevel?
1053
+
1054
+ ```ts
1055
+ optional providerThinkingLevel?: string;
1056
+ ```
1057
+
1058
+ ##### thinkingLevel?
1059
+
1060
+ ```ts
1061
+ optional thinkingLevel?: ModelThinkingLevel;
1062
+ ```
1063
+
1064
+ ##### diagnostics?
1065
+
1066
+ ```ts
1067
+ optional diagnostics?: AssistantMessageDiagnostic[];
1068
+ ```
1069
+
1070
+ ##### usage
1071
+
1072
+ ```ts
1073
+ usage: Usage;
1074
+ ```
1075
+
1076
+ ##### stopReason
1077
+
1078
+ ```ts
1079
+ stopReason: StopReason;
1080
+ ```
1081
+
1082
+ ##### deferred?
1083
+
1084
+ ```ts
1085
+ optional deferred?: DeferredHandle;
1086
+ ```
1087
+
1088
+ ##### errorMessage?
1089
+
1090
+ ```ts
1091
+ optional errorMessage?: string;
1092
+ ```
1093
+
1094
+ ##### rawStopReason?
1095
+
1096
+ ```ts
1097
+ optional rawStopReason?: string;
1098
+ ```
1099
+
1100
+ ##### endTurn?
1101
+
1102
+ ```ts
1103
+ optional endTurn?: boolean;
1104
+ ```
1105
+
1106
+ ##### timestamp
1107
+
1108
+ ```ts
1109
+ timestamp: number;
1110
+ ```
1111
+
1112
+ ##### durationMs?
1113
+
1114
+ ```ts
1115
+ optional durationMs?: number;
1116
+ ```
1117
+
1118
+ ---
1119
+
1120
+ ### NestedToolCallRecord
1121
+
1122
+ ```ts
1123
+ type NestedToolCallRecord = object;
1124
+ ```
1125
+
1126
+ Bounded evidence of a tool invocation made inside another tool.
1127
+
1128
+ #### Properties
1129
+
1130
+ ##### id
1131
+
1132
+ ```ts
1133
+ id: string;
1134
+ ```
1135
+
1136
+ ##### name
1137
+
1138
+ ```ts
1139
+ name: string;
1140
+ ```
1141
+
1142
+ ##### arguments?
1143
+
1144
+ ```ts
1145
+ optional arguments?: JsonObject;
1146
+ ```
1147
+
1148
+ ##### argumentsBytes?
1149
+
1150
+ ```ts
1151
+ optional argumentsBytes?: number;
1152
+ ```
1153
+
1154
+ ##### status
1155
+
1156
+ ```ts
1157
+ status: "ok" | "error" | "unfinished";
1158
+ ```
1159
+
1160
+ ##### durationMs?
1161
+
1162
+ ```ts
1163
+ optional durationMs?: number;
1164
+ ```
1165
+
1166
+ ##### error?
1167
+
1168
+ ```ts
1169
+ optional error?: string;
1170
+ ```
1171
+
1172
+ ---
1173
+
1174
+ ### NestedToolCalls
1175
+
1176
+ ```ts
1177
+ type NestedToolCalls = object;
1178
+ ```
1179
+
1180
+ Recorded nested invocations and whether the record is complete.
1181
+
1182
+ #### Properties
1183
+
1184
+ ##### calls
1185
+
1186
+ ```ts
1187
+ calls: NestedToolCallRecord[];
1188
+ ```
1189
+
1190
+ ##### complete
1191
+
1192
+ ```ts
1193
+ complete: boolean;
1194
+ ```
1195
+
1196
+ ---
1197
+
1198
+ ### ToolResultMessage
1199
+
1200
+ ```ts
1201
+ type ToolResultMessage = object;
1202
+ ```
1203
+
1204
+ Correlated tool output with optional JSON details and usage.
1205
+
1206
+ #### Properties
1207
+
1208
+ ##### role
1209
+
1210
+ ```ts
1211
+ role: "toolResult";
1212
+ ```
1213
+
1214
+ ##### toolCallId
1215
+
1216
+ ```ts
1217
+ toolCallId: string;
1218
+ ```
1219
+
1220
+ ##### toolName
1221
+
1222
+ ```ts
1223
+ toolName: string;
1224
+ ```
1225
+
1226
+ ##### content
1227
+
1228
+ ```ts
1229
+ content: (TextContent | ImageContent)[];
1230
+ ```
1231
+
1232
+ ##### details?
1233
+
1234
+ ```ts
1235
+ optional details?: JsonValue;
1236
+ ```
1237
+
1238
+ ##### usage?
1239
+
1240
+ ```ts
1241
+ optional usage?: Usage;
1242
+ ```
1243
+
1244
+ ##### nestedCalls?
1245
+
1246
+ ```ts
1247
+ optional nestedCalls?: NestedToolCalls;
1248
+ ```
1249
+
1250
+ ##### isError
1251
+
1252
+ ```ts
1253
+ isError: boolean;
1254
+ ```
1255
+
1256
+ ##### timestamp
1257
+
1258
+ ```ts
1259
+ timestamp: number;
1260
+ ```
1261
+
1262
+ ##### durationMs?
1263
+
1264
+ ```ts
1265
+ optional durationMs?: number;
1266
+ ```
1267
+
1268
+ ---
1269
+
1270
+ ### Message
1271
+
1272
+ ```ts
1273
+ type Message =
1274
+ SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;
1275
+ ```
1276
+
1277
+ One system, user, assistant or tool-result transcript entry.
1278
+
1279
+ ---
1280
+
1281
+ ### GrammarFormat
1282
+
1283
+ ```ts
1284
+ type GrammarFormat = "openai_lark" | "openai_regex";
1285
+ ```
1286
+
1287
+ Provider grammar formats available for constrained sampling.
1288
+
1289
+ ---
1290
+
1291
+ ### GrammarVariants
1292
+
1293
+ ```ts
1294
+ type GrammarVariants = Partial<Record<GrammarFormat, string>>;
1295
+ ```
1296
+
1297
+ Grammar text supplied for each supported provider format.
1298
+
1299
+ ---
1300
+
1301
+ ### ConstrainedSamplingConfig
1302
+
1303
+ ```ts
1304
+ type ConstrainedSamplingConfig =
1305
+ | {
1306
+ type: "json_schema";
1307
+ strict: "prefer" | "require";
1308
+ }
1309
+ | {
1310
+ type: "grammar";
1311
+ variants: GrammarVariants;
1312
+ };
1313
+ ```
1314
+
1315
+ Provider constraint for a tool declaration.
1316
+
1317
+ ---
1318
+
1319
+ ### Tool
1320
+
1321
+ ```ts
1322
+ type Tool<TParameters> = object;
1323
+ ```
1324
+
1325
+ Model-visible tool name, description and TypeBox argument schema.
1326
+
1327
+ #### Type Parameters
1328
+
1329
+ | Type Parameter | Default type |
1330
+ | --------------------------------- | ------------ |
1331
+ | `TParameters` _extends_ `TSchema` | `TSchema` |
1332
+
1333
+ #### Properties
1334
+
1335
+ ##### name
1336
+
1337
+ ```ts
1338
+ name: string;
1339
+ ```
1340
+
1341
+ ##### description
1342
+
1343
+ ```ts
1344
+ description: string;
1345
+ ```
1346
+
1347
+ ##### parameters
1348
+
1349
+ ```ts
1350
+ parameters: TParameters;
1351
+ ```
1352
+
1353
+ ##### constrainedSampling?
1354
+
1355
+ ```ts
1356
+ optional constrainedSampling?: false | ConstrainedSamplingConfig;
1357
+ ```
1358
+
1359
+ ---
1360
+
1361
+ ### ToolReference
1362
+
1363
+ ```ts
1364
+ type ToolReference = object;
1365
+ ```
1366
+
1367
+ Named tool removed by a transcript system update.
1368
+
1369
+ #### Properties
1370
+
1371
+ ##### name
1372
+
1373
+ ```ts
1374
+ name: string;
1375
+ ```
1376
+
1377
+ ---
1378
+
1379
+ ### Context
1380
+
1381
+ ```ts
1382
+ type Context = object;
1383
+ ```
1384
+
1385
+ Model request context; Pi adapters normalize it before provider dispatch.
1386
+
1387
+ #### Properties
1388
+
1389
+ ##### systemPrompt?
1390
+
1391
+ ```ts
1392
+ optional systemPrompt?: string;
1393
+ ```
1394
+
1395
+ ##### messages
1396
+
1397
+ ```ts
1398
+ messages: Message[];
1399
+ ```
1400
+
1401
+ ##### tools?
1402
+
1403
+ ```ts
1404
+ optional tools?: Tool[];
1405
+ ```
1406
+
1407
+ ---
1408
+
1409
+ ### AssistantMessageEvent
1410
+
1411
+ ```ts
1412
+ type AssistantMessageEvent =
1413
+ | {
1414
+ type: "start";
1415
+ partial: AssistantMessage;
1416
+ }
1417
+ | {
1418
+ type: "text_start";
1419
+ contentIndex: number;
1420
+ partial: AssistantMessage;
1421
+ }
1422
+ | {
1423
+ type: "text_delta";
1424
+ contentIndex: number;
1425
+ delta: string;
1426
+ partial: AssistantMessage;
1427
+ }
1428
+ | {
1429
+ type: "text_end";
1430
+ contentIndex: number;
1431
+ content: string;
1432
+ partial: AssistantMessage;
1433
+ }
1434
+ | {
1435
+ type: "thinking_start";
1436
+ contentIndex: number;
1437
+ partial: AssistantMessage;
1438
+ }
1439
+ | {
1440
+ type: "thinking_delta";
1441
+ contentIndex: number;
1442
+ delta: string;
1443
+ partial: AssistantMessage;
1444
+ }
1445
+ | {
1446
+ type: "thinking_end";
1447
+ contentIndex: number;
1448
+ content: string;
1449
+ partial: AssistantMessage;
1450
+ }
1451
+ | {
1452
+ type: "toolcall_start";
1453
+ contentIndex: number;
1454
+ partial: AssistantMessage;
1455
+ }
1456
+ | {
1457
+ type: "toolcall_delta";
1458
+ contentIndex: number;
1459
+ delta: string;
1460
+ partial: AssistantMessage;
1461
+ }
1462
+ | {
1463
+ type: "toolcall_end";
1464
+ contentIndex: number;
1465
+ toolCall: ToolCall;
1466
+ partial: AssistantMessage;
1467
+ }
1468
+ | {
1469
+ type: "done";
1470
+ reason: Extract<StopReason, "stop" | "length" | "toolUse" | "deferred">;
1471
+ message: AssistantMessage;
1472
+ }
1473
+ | {
1474
+ type: "error";
1475
+ reason: Extract<StopReason, "aborted" | "error">;
1476
+ error: AssistantMessage;
1477
+ };
1478
+ ```
1479
+
1480
+ Partial updates and the terminal event for an assistant stream.
1481
+
1482
+ ---
1483
+
1484
+ ### BaseModel
1485
+
1486
+ ```ts
1487
+ type BaseModel<TApi> = object;
1488
+ ```
1489
+
1490
+ Catalog fields shared by chat model definitions.
1491
+
1492
+ #### Type Parameters
1493
+
1494
+ | Type Parameter |
1495
+ | ------------------------- |
1496
+ | `TApi` _extends_ `string` |
1497
+
1498
+ #### Properties
1499
+
1500
+ ##### id
1501
+
1502
+ ```ts
1503
+ id: string;
1504
+ ```
1505
+
1506
+ ##### name
1507
+
1508
+ ```ts
1509
+ name: string;
1510
+ ```
1511
+
1512
+ ##### api
1513
+
1514
+ ```ts
1515
+ api: TApi;
1516
+ ```
1517
+
1518
+ ##### provider
1519
+
1520
+ ```ts
1521
+ provider: ProviderId;
1522
+ ```
1523
+
1524
+ ##### baseUrl
1525
+
1526
+ ```ts
1527
+ baseUrl: string;
1528
+ ```
1529
+
1530
+ ##### input
1531
+
1532
+ ```ts
1533
+ input: ModelInputModality[];
1534
+ ```
1535
+
1536
+ ##### inputLimits?
1537
+
1538
+ ```ts
1539
+ optional inputLimits?: ModelInputLimits;
1540
+ ```
1541
+
1542
+ ##### cost
1543
+
1544
+ ```ts
1545
+ cost: ModelCost;
1546
+ ```
1547
+
1548
+ ##### headers?
1549
+
1550
+ ```ts
1551
+ optional headers?: Record<string, string>;
1552
+ ```
1553
+
1554
+ ---
1555
+
1556
+ ### Model
1557
+
1558
+ ```ts
1559
+ type Model<TApi> = object & BaseModel<TApi>;
1560
+ ```
1561
+
1562
+ Chat model configuration accepted by Mule and its Pi adapter.
1563
+
1564
+ #### Type Declaration
1565
+
1566
+ | Name | Type |
1567
+ | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1568
+ | `type?` | `"chat"` |
1569
+ | `reasoning` | `boolean` |
1570
+ | `thinkingLevelMap?` | `ThinkingLevelMap` |
1571
+ | `promptCache?` | `ModelPromptCache` |
1572
+ | `contextWindow` | `number` |
1573
+ | `maxTokens` | `number` |
1574
+ | `samplingParams?` | [`SamplingParams`](#samplingparams) |
1575
+ | `samplingParamsByThinkingLevel?` | [`SamplingParamsByThinkingLevel`](#samplingparamsbythinkinglevel) |
1576
+ | `compat?` | `TApi` _extends_ `"openai-completions"` ? `OpenAICompletionsCompat` : `TApi` _extends_ \| `"openai-responses"` \| `"azure-openai-responses"` \| `"openai-codex-responses"` ? `OpenAIResponsesCompat` : `TApi` _extends_ `"anthropic-messages"` ? `AnthropicMessagesCompat` : `TApi` _extends_ `"bedrock-converse-stream"` ? `BedrockCompat` : `TApi` _extends_ `"mistral-conversations"` ? `MistralConversationsCompat` : `never` |
1577
+
1578
+ #### Type Parameters
1579
+
1580
+ | Type Parameter |
1581
+ | ------------------------------ |
1582
+ | `TApi` _extends_ [`Api`](#api) |
1583
+
1584
+ ---
1585
+
1586
+ ### DiagnosticErrorInfo
1587
+
1588
+ ```ts
1589
+ type DiagnosticErrorInfo = object;
1590
+ ```
1591
+
1592
+ Serializable diagnostic information retained with an assistant message.
1593
+
1594
+ #### Properties
1595
+
1596
+ ##### name?
1597
+
1598
+ ```ts
1599
+ optional name?: string;
1600
+ ```
1601
+
1602
+ ##### message
1603
+
1604
+ ```ts
1605
+ message: string;
1606
+ ```
1607
+
1608
+ ##### stack?
1609
+
1610
+ ```ts
1611
+ optional stack?: string;
1612
+ ```
1613
+
1614
+ ##### code?
1615
+
1616
+ ```ts
1617
+ optional code?: string | number;
1618
+ ```
1619
+
1620
+ ---
1621
+
1622
+ ### AssistantMessageDiagnostic
1623
+
1624
+ ```ts
1625
+ type AssistantMessageDiagnostic = object;
1626
+ ```
1627
+
1628
+ Timestamped provider diagnostic with optional JSON details.
1629
+
1630
+ #### Properties
1631
+
1632
+ ##### type
1633
+
1634
+ ```ts
1635
+ type: string;
1636
+ ```
1637
+
1638
+ ##### timestamp
1639
+
1640
+ ```ts
1641
+ timestamp: number;
1642
+ ```
1643
+
1644
+ ##### error?
1645
+
1646
+ ```ts
1647
+ optional error?: DiagnosticErrorInfo;
1648
+ ```
1649
+
1650
+ ##### details?
1651
+
1652
+ ```ts
1653
+ optional details?: JsonObject;
1654
+ ```
1655
+
1656
+ ---
1657
+
1658
+ ### AssistantMessageEventStream
1659
+
1660
+ ```ts
1661
+ type AssistantMessageEventStream = object &
1662
+ AsyncIterable<AssistantMessageEvent>;
1663
+ ```
1664
+
1665
+ Only the stream operations consumed by Mule. Pi's concrete stream satisfies this
1666
+ port.
1667
+
1668
+ #### Type Declaration
1669
+
1670
+ | Name | Type | Description |
1671
+ | ---------- | ---------------------------------------------------------- | ------------------------------------------------ |
1672
+ | `result()` | () => `Promise`\<[`AssistantMessage`](#assistantmessage)\> | Await the authoritative final assistant message. |
1673
+
1674
+ ---
1675
+
1676
+ ### RetryPolicy
1677
+
1678
+ ```ts
1679
+ type RetryPolicy = object;
1680
+ ```
1681
+
1682
+ Bounded assistant-call retries with capped exponential delays.
1683
+
1684
+ #### Properties
1685
+
1686
+ ##### enabled
1687
+
1688
+ ```ts
1689
+ enabled: boolean;
1690
+ ```
1691
+
1692
+ ##### maxRetries
1693
+
1694
+ ```ts
1695
+ maxRetries: number;
1696
+ ```
1697
+
1698
+ ##### baseDelayMs
1699
+
1700
+ ```ts
1701
+ baseDelayMs: number;
1702
+ ```
1703
+
1704
+ ##### maxAgentDelayMs?
1705
+
1706
+ ```ts
1707
+ optional maxAgentDelayMs?: number;
1708
+ ```
1709
+
1710
+ ---
1711
+
1712
+ ### AttributeValue
1713
+
1714
+ ```ts
1715
+ type AttributeValue =
1716
+ | string
1717
+ | number
1718
+ | boolean
1719
+ | readonly string[]
1720
+ | readonly number[]
1721
+ | readonly boolean[];
1722
+ ```
1723
+
1724
+ Scalar or homogeneous-array telemetry attribute.
1725
+
1726
+ ---
1727
+
1728
+ ### SpanAttributes
1729
+
1730
+ ```ts
1731
+ type SpanAttributes = Record<string, AttributeValue | undefined>;
1732
+ ```
1733
+
1734
+ Named telemetry attributes, with undefined values omitted by the owner.
1735
+
1736
+ ---
1737
+
1738
+ ### SpanOptions
1739
+
1740
+ ```ts
1741
+ type SpanOptions = object;
1742
+ ```
1743
+
1744
+ Name and initial attributes of a request telemetry span.
1745
+
1746
+ #### Properties
1747
+
1748
+ ##### name
1749
+
1750
+ ```ts
1751
+ name: string;
1752
+ ```
1753
+
1754
+ ##### attributes?
1755
+
1756
+ ```ts
1757
+ optional attributes?: SpanAttributes;
1758
+ ```
1759
+
1760
+ ---
1761
+
1762
+ ### SpanStatus
1763
+
1764
+ ```ts
1765
+ type SpanStatus =
1766
+ | {
1767
+ status: "ok";
1768
+ }
1769
+ | {
1770
+ status: "error";
1771
+ error?: {
1772
+ name: string;
1773
+ message: string;
1774
+ };
1775
+ };
1776
+ ```
1777
+
1778
+ Successful or failed telemetry completion.
1779
+
1780
+ ---
1781
+
1782
+ ### TelemetryContext
1783
+
1784
+ ```ts
1785
+ type TelemetryContext = object;
1786
+ ```
1787
+
1788
+ Parent context through which a provider opens telemetry spans.
1789
+
1790
+ #### Methods
1791
+
1792
+ ##### startSpan()
1793
+
1794
+ ```ts
1795
+ startSpan<T>(options, callback): Promise<T>;
1796
+ ```
1797
+
1798
+ Run provider work under a child span.
1799
+
1800
+ ###### Type Parameters
1801
+
1802
+ | Type Parameter |
1803
+ | -------------- |
1804
+ | `T` |
1805
+
1806
+ ###### Parameters
1807
+
1808
+ | Parameter | Type |
1809
+ | ---------- | ----------------------------------- |
1810
+ | `options` | [`SpanOptions`](#spanoptions) |
1811
+ | `callback` | (`span`) => `T` \| `Promise`\<`T`\> |
1812
+
1813
+ ###### Returns
1814
+
1815
+ `Promise`\<`T`\>
1816
+
1817
+ ---
1818
+
1819
+ ### TelemetrySpan
1820
+
1821
+ ```ts
1822
+ type TelemetrySpan = object & TelemetryContext;
1823
+ ```
1824
+
1825
+ Provider telemetry span with events, attributes and completion status.
1826
+
1827
+ #### Type Declaration
1828
+
1829
+ | Name | Type | Description |
1830
+ | ----------------- | --------------------------------- | ------------------------------------------ |
1831
+ | `addEvent()` | (`name`, `attributes?`) => `void` | Record a timestamped event on this span. |
1832
+ | `setAttributes()` | (`attributes`) => `void` | Add or replace attributes on this span. |
1833
+ | `setStatus()` | (`status`) => `void` | Record the completion status of this span. |
1834
+
196
1835
  ## Variables
197
1836
 
198
1837
  ### piCodingAgentRetryDefaults
@@ -240,10 +1879,10 @@ Apply Pi's maintained context-overflow semantics to an exact Pi message.
240
1879
 
241
1880
  #### Parameters
242
1881
 
243
- | Parameter | Type |
244
- | ---------------- | ------------------ |
245
- | `message` | `AssistantMessage` |
246
- | `contextWindow?` | `number` |
1882
+ | Parameter | Type |
1883
+ | ---------------- | --------------------------------------- |
1884
+ | `message` | [`AssistantMessage`](#assistantmessage) |
1885
+ | `contextWindow?` | `number` |
247
1886
 
248
1887
  #### Returns
249
1888
 
@@ -273,6 +1912,18 @@ Run Pi's model/tool loop inside Effect without changing Pi's values.
273
1912
 
274
1913
  ## References
275
1914
 
1915
+ ### decodeProviderData
1916
+
1917
+ Re-exports [decodeProviderData](index.md#decodeproviderdata)
1918
+
1919
+ ---
1920
+
1921
+ ### streamModel
1922
+
1923
+ Re-exports [streamModel](index.md#streammodel)
1924
+
1925
+ ---
1926
+
276
1927
  ### observeProviderStatus
277
1928
 
278
1929
  Re-exports [observeProviderStatus](index.md#observeproviderstatus)
@@ -291,6 +1942,12 @@ Re-exports [ProviderStatusRecorder](index.md#providerstatusrecorder)
291
1942
 
292
1943
  ---
293
1944
 
1945
+ ### normalizeModel
1946
+
1947
+ Re-exports [normalizeModel](index.md#normalizemodel)
1948
+
1949
+ ---
1950
+
294
1951
  ### MuleCompletedTurn
295
1952
 
296
1953
  Re-exports [MuleCompletedTurn](index.md#mulecompletedturn)