@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.
- package/THIRD_PARTY_NOTICES +8 -3
- package/dist/contract.d.ts +2 -2
- package/dist/effect.d.ts +5 -2
- package/dist/effect.js +6 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -0
- package/dist/pi-options.d.ts +6 -0
- package/dist/pi-options.js +35 -0
- package/dist/provider-data.d.ts +3 -0
- package/dist/provider-data.js +17 -0
- package/dist/provider-model.d.ts +3 -0
- package/dist/provider-model.js +18 -0
- package/dist/provider-status.d.ts +1 -1
- package/dist/provider.d.ts +3 -0
- package/dist/provider.js +7 -0
- package/dist/testing.d.ts +47 -4
- package/dist/testing.js +15 -7
- package/dist/types.d.ts +381 -0
- package/dist/types.js +1 -0
- package/docs/api/effect.md +1674 -17
- package/docs/api/index.md +100 -41
- package/docs/api/testing.md +232 -6
- package/package.json +1 -1
package/docs/api/index.md
CHANGED
|
@@ -24,15 +24,16 @@ Pi's model stream function, supplied explicitly by the caller.
|
|
|
24
24
|
|
|
25
25
|
#### Parameters
|
|
26
26
|
|
|
27
|
-
| Parameter | Type
|
|
28
|
-
| ---------- |
|
|
29
|
-
| `model` | `Model
|
|
30
|
-
| `context` | `
|
|
31
|
-
| `options?` | `SimpleStreamOptions` |
|
|
27
|
+
| Parameter | Type |
|
|
28
|
+
| ---------- | ------------------------------------------------------ |
|
|
29
|
+
| `model` | [`Model`](effect.md#model-1)\<[`Api`](effect.md#api)\> |
|
|
30
|
+
| `context` | [`Context`](effect.md#context) |
|
|
31
|
+
| `options?` | [`SimpleStreamOptions`](effect.md#simplestreamoptions) |
|
|
32
32
|
|
|
33
33
|
#### Returns
|
|
34
34
|
|
|
35
|
-
\| `AssistantMessageEventStream` \|
|
|
35
|
+
\| [`AssistantMessageEventStream`](effect.md#assistantmessageeventstream) \|
|
|
36
|
+
`Promise`\<[`AssistantMessageEventStream`](effect.md#assistantmessageeventstream)\>
|
|
36
37
|
|
|
37
38
|
---
|
|
38
39
|
|
|
@@ -128,7 +129,9 @@ Result produced by a tool before Mule forms Pi's correlated result message.
|
|
|
128
129
|
##### content
|
|
129
130
|
|
|
130
131
|
```ts
|
|
131
|
-
readonly content: (
|
|
132
|
+
readonly content: (
|
|
133
|
+
| TextContent
|
|
134
|
+
| ImageContent)[];
|
|
132
135
|
```
|
|
133
136
|
|
|
134
137
|
##### data?
|
|
@@ -410,14 +413,14 @@ Lifecycle emitted around Pi values. Pi messages and events are not rewritten.
|
|
|
410
413
|
}
|
|
411
414
|
```
|
|
412
415
|
|
|
413
|
-
| Name | Type
|
|
414
|
-
| --------- |
|
|
415
|
-
| `type` | `"message_end"`
|
|
416
|
-
| `run` | [`MuleIdentity`](#muleidentity)
|
|
417
|
-
| `turn` | [`MuleIdentity`](#muleidentity)
|
|
418
|
-
| `message` | [`MuleIdentity`](#muleidentity)
|
|
419
|
-
| `value` | `Message`
|
|
420
|
-
| `data?` | `JsonValue`
|
|
416
|
+
| Name | Type | Description |
|
|
417
|
+
| --------- | ---------------------------------- | --------------------------------------------------------------- |
|
|
418
|
+
| `type` | `"message_end"` | - |
|
|
419
|
+
| `run` | [`MuleIdentity`](#muleidentity) | - |
|
|
420
|
+
| `turn` | [`MuleIdentity`](#muleidentity) | - |
|
|
421
|
+
| `message` | [`MuleIdentity`](#muleidentity) | - |
|
|
422
|
+
| `value` | [`Message`](effect.md#message) | - |
|
|
423
|
+
| `data?` | [`JsonValue`](effect.md#jsonvalue) | Application payload independent of the completed model message. |
|
|
421
424
|
|
|
422
425
|
---
|
|
423
426
|
|
|
@@ -559,12 +562,12 @@ Durable evidence for a call in an interrupted assistant turn.
|
|
|
559
562
|
}
|
|
560
563
|
```
|
|
561
564
|
|
|
562
|
-
| Name | Type
|
|
563
|
-
| ---------- |
|
|
564
|
-
| `call` | `ToolCall`
|
|
565
|
-
| `state` | `"completed"`
|
|
566
|
-
| `result` | [`MuleToolResult`](#muletoolresult)
|
|
567
|
-
| `message?` | `ToolResultMessage`
|
|
565
|
+
| Name | Type | Description |
|
|
566
|
+
| ---------- | -------------------------------------------------- | ------------------------------------------------------ |
|
|
567
|
+
| `call` | [`ToolCall`](effect.md#toolcall) | - |
|
|
568
|
+
| `state` | `"completed"` | - |
|
|
569
|
+
| `result` | [`MuleToolResult`](#muletoolresult) | - |
|
|
570
|
+
| `message?` | [`ToolResultMessage`](effect.md#toolresultmessage) | Present when the transcript message was committed too. |
|
|
568
571
|
|
|
569
572
|
---
|
|
570
573
|
|
|
@@ -683,9 +686,9 @@ retry; unknown messages return false, never a decision from prose.
|
|
|
683
686
|
|
|
684
687
|
###### Parameters
|
|
685
688
|
|
|
686
|
-
| Parameter | Type
|
|
687
|
-
| --------- |
|
|
688
|
-
| `message` | `AssistantMessage` |
|
|
689
|
+
| Parameter | Type |
|
|
690
|
+
| --------- | ------------------------------------------------ |
|
|
691
|
+
| `message` | [`AssistantMessage`](effect.md#assistantmessage) |
|
|
689
692
|
|
|
690
693
|
###### Returns
|
|
691
694
|
|
|
@@ -701,9 +704,9 @@ Provider's bounded Retry-After evidence for the last assistant error.
|
|
|
701
704
|
|
|
702
705
|
###### Parameters
|
|
703
706
|
|
|
704
|
-
| Parameter | Type
|
|
705
|
-
| --------- |
|
|
706
|
-
| `message` | `AssistantMessage` |
|
|
707
|
+
| Parameter | Type |
|
|
708
|
+
| --------- | ------------------------------------------------ |
|
|
709
|
+
| `message` | [`AssistantMessage`](effect.md#assistantmessage) |
|
|
707
710
|
|
|
708
711
|
###### Returns
|
|
709
712
|
|
|
@@ -849,10 +852,10 @@ Decode and authorize one exact Pi tool call before it can execute.
|
|
|
849
852
|
|
|
850
853
|
###### Parameters
|
|
851
854
|
|
|
852
|
-
| Parameter | Type
|
|
853
|
-
| --------- |
|
|
854
|
-
| `call` | `ToolCall`
|
|
855
|
-
| `signal` | `AbortSignal`
|
|
855
|
+
| Parameter | Type |
|
|
856
|
+
| --------- | -------------------------------- |
|
|
857
|
+
| `call` | [`ToolCall`](effect.md#toolcall) |
|
|
858
|
+
| `signal` | `AbortSignal` |
|
|
856
859
|
|
|
857
860
|
###### Returns
|
|
858
861
|
|
|
@@ -870,13 +873,13 @@ Inputs for one complete Pi model/tool loop through the Promise facade.
|
|
|
870
873
|
|
|
871
874
|
#### Type Declaration
|
|
872
875
|
|
|
873
|
-
| Name | Type
|
|
874
|
-
| ------------------------ |
|
|
875
|
-
| `tools?` | readonly [`MuleTool`](#muletool)[]
|
|
876
|
-
| `resolveApiKey()?` | (`provider`, `signal`) => `Promise`\<`string` \| `undefined`\>
|
|
877
|
-
| `getSteeringMessages()?` | (`signal`) => `Promise`\<readonly `Message`[]\>
|
|
878
|
-
| `getFollowUpMessages()?` | (`signal`) => `Promise`\<readonly `Message`[]\>
|
|
879
|
-
| `shouldStopAfterTurn()?` | (`turn`, `signal`) => `Promise`\<`boolean`\>
|
|
876
|
+
| Name | Type | Description |
|
|
877
|
+
| ------------------------ | -------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
878
|
+
| `tools?` | readonly [`MuleTool`](#muletool)[] | - |
|
|
879
|
+
| `resolveApiKey()?` | (`provider`, `signal`) => `Promise`\<`string` \| `undefined`\> | Resolve a fresh provider credential immediately before each Pi call. |
|
|
880
|
+
| `getSteeringMessages()?` | (`signal`) => `Promise`\<readonly [`Message`](effect.md#message)[]\> | Pull messages that should steer the active run at Pi's safe point. |
|
|
881
|
+
| `getFollowUpMessages()?` | (`signal`) => `Promise`\<readonly [`Message`](effect.md#message)[]\> | Pull messages queued until the run would otherwise finish. |
|
|
882
|
+
| `shouldStopAfterTurn()?` | (`turn`, `signal`) => `Promise`\<`boolean`\> | Request a graceful stop after the current Pi turn has fully settled. |
|
|
880
883
|
|
|
881
884
|
---
|
|
882
885
|
|
|
@@ -959,8 +962,64 @@ const mule: Mule;
|
|
|
959
962
|
|
|
960
963
|
Default Promise-facing Mule interface.
|
|
961
964
|
|
|
965
|
+
---
|
|
966
|
+
|
|
967
|
+
### streamModel
|
|
968
|
+
|
|
969
|
+
```ts
|
|
970
|
+
const streamModel: MuleStreamFunction;
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
Pi's maintained stream behind Mule's structural provider port.
|
|
974
|
+
|
|
962
975
|
## Functions
|
|
963
976
|
|
|
977
|
+
### decodeProviderData()
|
|
978
|
+
|
|
979
|
+
```ts
|
|
980
|
+
function decodeProviderData(data): ProviderData;
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
Decode Pi's parsed request/event data before it enters an owned hook.
|
|
984
|
+
|
|
985
|
+
#### Parameters
|
|
986
|
+
|
|
987
|
+
| Parameter | Type |
|
|
988
|
+
| --------- | --------- |
|
|
989
|
+
| `data` | `unknown` |
|
|
990
|
+
|
|
991
|
+
#### Returns
|
|
992
|
+
|
|
993
|
+
[`ProviderData`](effect.md#providerdata)
|
|
994
|
+
|
|
995
|
+
---
|
|
996
|
+
|
|
997
|
+
### normalizeModel()
|
|
998
|
+
|
|
999
|
+
```ts
|
|
1000
|
+
function normalizeModel<TApi>(model): Model<TApi>;
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
Validate a catalog model's opaque sampling fields before it enters Mule.
|
|
1004
|
+
|
|
1005
|
+
#### Type Parameters
|
|
1006
|
+
|
|
1007
|
+
| Type Parameter |
|
|
1008
|
+
| --------------------------------------- |
|
|
1009
|
+
| `TApi` _extends_ [`Api`](effect.md#api) |
|
|
1010
|
+
|
|
1011
|
+
#### Parameters
|
|
1012
|
+
|
|
1013
|
+
| Parameter | Type |
|
|
1014
|
+
| --------- | --------------------------------------------------------------------------------------------------------- |
|
|
1015
|
+
| `model` | `Omit`\<[`Model`](effect.md#model-1)\<`TApi`\>, `"samplingParams"` \| `"samplingParamsByThinkingLevel"`\> |
|
|
1016
|
+
|
|
1017
|
+
#### Returns
|
|
1018
|
+
|
|
1019
|
+
[`Model`](effect.md#model-1)\<`TApi`\>
|
|
1020
|
+
|
|
1021
|
+
---
|
|
1022
|
+
|
|
964
1023
|
### observeProviderStatus()
|
|
965
1024
|
|
|
966
1025
|
```ts
|
|
@@ -972,9 +1031,9 @@ decoding; this module retains no provider prose.
|
|
|
972
1031
|
|
|
973
1032
|
#### Parameters
|
|
974
1033
|
|
|
975
|
-
| Parameter | Type
|
|
976
|
-
| ---------- |
|
|
977
|
-
| `options?` | `Pick
|
|
1034
|
+
| Parameter | Type |
|
|
1035
|
+
| ---------- | -------------------------------------------------------------------------------------------------------- |
|
|
1036
|
+
| `options?` | `Pick`\<[`SimpleStreamOptions`](effect.md#simplestreamoptions), `"onProviderStreamEvent"` \| `"fetch"`\> |
|
|
978
1037
|
|
|
979
1038
|
#### Returns
|
|
980
1039
|
|
package/docs/api/testing.md
CHANGED
|
@@ -10,15 +10,241 @@
|
|
|
10
10
|
|
|
11
11
|
## Type Aliases
|
|
12
12
|
|
|
13
|
+
### FauxModelDefinition
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type FauxModelDefinition = object;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Credential-free model definition for the scripted provider.
|
|
20
|
+
|
|
21
|
+
#### Properties
|
|
22
|
+
|
|
23
|
+
##### id
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
id: string;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
##### name?
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
optional name?: string;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
##### reasoning?
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
optional reasoning?: boolean;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
##### input?
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
optional input?: ("text" | "image")[];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
##### inputLimits?
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
optional inputLimits?: Model<Api>["inputLimits"];
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
##### cost?
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
optional cost?: object;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
###### input
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
input: number;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
###### output
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
output: number;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
###### cacheRead
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
cacheRead: number;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
###### cacheWrite
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
cacheWrite: number;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
##### contextWindow?
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
optional contextWindow?: number;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
##### maxTokens?
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
optional maxTokens?: number;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### RegisterFauxProviderOptions
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
type RegisterFauxProviderOptions = object;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Scripted provider configuration, independent of provider SDK declarations.
|
|
104
|
+
|
|
105
|
+
#### Properties
|
|
106
|
+
|
|
107
|
+
##### api?
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
optional api?: string;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
##### provider?
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
optional provider?: string;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
##### models?
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
optional models?: FauxModelDefinition[];
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
##### deferred?
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
optional deferred?: object;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
###### pendingFetches?
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
optional pendingFetches?: number;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
###### pollAfterMs?
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
optional pollAfterMs?: number;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
##### tokensPerSecond?
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
optional tokensPerSecond?: number;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
##### tokenSize?
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
optional tokenSize?: object;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
###### min?
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
optional min?: number;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
###### max?
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
optional max?: number;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### FauxProviderState
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
type FauxProviderState = object;
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Counters retained by the scripted provider.
|
|
176
|
+
|
|
177
|
+
#### Properties
|
|
178
|
+
|
|
179
|
+
##### callCount
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
callCount: number;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
##### deferredFetchCount
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
deferredFetchCount: number;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
##### cancelledDeferred
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
cancelledDeferred: NonNullable < AssistantMessage["deferred"] > [];
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### FauxResponseFactory
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
type FauxResponseFactory = (
|
|
203
|
+
context,
|
|
204
|
+
options,
|
|
205
|
+
state,
|
|
206
|
+
model,
|
|
207
|
+
) => AssistantMessage | Promise<AssistantMessage>;
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Function that observes a model request and supplies a scripted reply.
|
|
211
|
+
|
|
212
|
+
#### Parameters
|
|
213
|
+
|
|
214
|
+
| Parameter | Type |
|
|
215
|
+
| --------- | -------------------------------------------------------------------------- |
|
|
216
|
+
| `context` | [`Context`](effect.md#context) |
|
|
217
|
+
| `options` | `Parameters`\<[`MuleStreamFunction`](index.md#mulestreamfunction)\>\[`2`\] |
|
|
218
|
+
| `state` | [`FauxProviderState`](#fauxproviderstate) |
|
|
219
|
+
| `model` | [`Model`](effect.md#model-1)\<[`Api`](effect.md#api)\> |
|
|
220
|
+
|
|
221
|
+
#### Returns
|
|
222
|
+
|
|
223
|
+
\| [`AssistantMessage`](effect.md#assistantmessage) \|
|
|
224
|
+
`Promise`\<[`AssistantMessage`](effect.md#assistantmessage)\>
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### FauxResponseStep
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
type FauxResponseStep = AssistantMessage | FauxResponseFactory;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
A scripted reply or a factory that observes the normalized request.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
13
238
|
### FauxModel
|
|
14
239
|
|
|
15
240
|
```ts
|
|
16
241
|
type FauxModel = Readonly<{
|
|
17
242
|
model: Model<Api>;
|
|
18
|
-
stream:
|
|
243
|
+
stream: (...args) => AssistantMessageEventStream;
|
|
19
244
|
retryable: (message) => boolean;
|
|
20
245
|
setResponses: (replies) => void;
|
|
21
|
-
state:
|
|
246
|
+
state: FauxProviderState;
|
|
247
|
+
getPendingResponseCount: () => number;
|
|
22
248
|
}>;
|
|
23
249
|
```
|
|
24
250
|
|
|
@@ -36,10 +262,10 @@ Create a credential-free model for tests and runnable examples.
|
|
|
36
262
|
|
|
37
263
|
#### Parameters
|
|
38
264
|
|
|
39
|
-
| Parameter | Type
|
|
40
|
-
| --------- |
|
|
41
|
-
| `replies` | readonly `FauxResponseStep`[]
|
|
42
|
-
| `options` | `RegisterFauxProviderOptions` |
|
|
265
|
+
| Parameter | Type |
|
|
266
|
+
| --------- | ------------------------------------------------------------- |
|
|
267
|
+
| `replies` | readonly [`FauxResponseStep`](#fauxresponsestep)[] |
|
|
268
|
+
| `options` | [`RegisterFauxProviderOptions`](#registerfauxprovideroptions) |
|
|
43
269
|
|
|
44
270
|
#### Returns
|
|
45
271
|
|