@fungi.computer/mule 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +120 -2
- package/THIRD_PARTY_NOTICES +15 -0
- package/dist/contract.d.ts +192 -0
- package/dist/contract.js +1 -0
- package/dist/effect.d.ts +73 -0
- package/dist/effect.js +767 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +97 -0
- package/dist/testing.d.ts +15 -0
- package/dist/testing.js +14 -0
- package/docs/api/README.md +15 -0
- package/docs/api/effect.md +350 -0
- package/docs/api/index.md +889 -0
- package/docs/api/testing.md +45 -0
- package/package.json +70 -3
|
@@ -0,0 +1,889 @@
|
|
|
1
|
+
<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
|
|
2
|
+
|
|
3
|
+
[**@fungi.computer/mule**](README.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[@fungi.computer/mule](README.md) / index
|
|
8
|
+
|
|
9
|
+
# index
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
### MuleStreamFunction
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type MuleStreamFunction = (
|
|
17
|
+
model,
|
|
18
|
+
context,
|
|
19
|
+
options?,
|
|
20
|
+
) => AssistantMessageEventStream | Promise<AssistantMessageEventStream>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Pi's model stream function, supplied explicitly by the caller.
|
|
24
|
+
|
|
25
|
+
#### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type |
|
|
28
|
+
| ---------- | --------------------- |
|
|
29
|
+
| `model` | `Model`\<`Api`\> |
|
|
30
|
+
| `context` | `TranscriptContext` |
|
|
31
|
+
| `options?` | `SimpleStreamOptions` |
|
|
32
|
+
|
|
33
|
+
#### Returns
|
|
34
|
+
|
|
35
|
+
\| `AssistantMessageEventStream` \| `Promise`\<`AssistantMessageEventStream`\>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### MuleIdentityKind
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
type MuleIdentityKind =
|
|
43
|
+
"run" | "turn" | "message" | "tool_call" | "tool_result" | "terminal";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Causal roles added around Pi's model and tool loop.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### MuleIdentity
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
type MuleIdentity = object;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
One run-local causal identity.
|
|
57
|
+
|
|
58
|
+
#### Properties
|
|
59
|
+
|
|
60
|
+
##### kind
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
readonly kind: MuleIdentityKind;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
##### value
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
readonly value: string;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
##### parent?
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
readonly optional parent?: MuleIdentity;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### MuleError
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
type MuleError = object;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Expected failure from Mule's model, tool, control, or listener work.
|
|
87
|
+
|
|
88
|
+
#### Properties
|
|
89
|
+
|
|
90
|
+
##### \_tag
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
readonly _tag: "MuleError";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
##### phase
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
readonly phase: "model" | "tool" | "control" | "listener";
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
##### message
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
readonly message: string;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
##### cause?
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
readonly optional cause?: unknown;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The underlying rejection or thrown value, when one exists.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### MuleToolResult
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
type MuleToolResult = object;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Result produced by a tool before Mule forms Pi's correlated result message.
|
|
125
|
+
|
|
126
|
+
#### Properties
|
|
127
|
+
|
|
128
|
+
##### content
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
readonly content: (TextContent | ImageContent)[];
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
##### details?
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
readonly optional details?: JsonValue;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
##### usage?
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
readonly optional usage?: Usage;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
##### isError
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
readonly isError: boolean;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
##### terminate?
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
readonly optional terminate?: boolean;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### MuleToolExecutionPart
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
type MuleToolExecutionPart =
|
|
164
|
+
| {
|
|
165
|
+
type: "update";
|
|
166
|
+
result: MuleToolResult;
|
|
167
|
+
}
|
|
168
|
+
| {
|
|
169
|
+
type: "result";
|
|
170
|
+
result: MuleToolResult;
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Progress or terminal output from one tool execution.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### MuleToolRejection
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
type MuleToolRejection = object;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
A real parser or authorization rejection produced before tool execution.
|
|
185
|
+
|
|
186
|
+
#### Properties
|
|
187
|
+
|
|
188
|
+
##### message
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
readonly message: string;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
##### terminate?
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
readonly optional terminate?: boolean;
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### MuleCompletedTurn
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
type MuleCompletedTurn = object;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Facts from a completed Pi turn supplied to the retained stop hook.
|
|
209
|
+
|
|
210
|
+
#### Properties
|
|
211
|
+
|
|
212
|
+
##### message
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
readonly message: AssistantMessage;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
##### toolResults
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
readonly toolResults: readonly ToolResultMessage[];
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
##### context
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
readonly context: readonly Message[];
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
##### newMessages
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
readonly newMessages: readonly Message[];
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### MuleEvent
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
type MuleEvent =
|
|
242
|
+
| {
|
|
243
|
+
type: "run_start";
|
|
244
|
+
run: MuleIdentity;
|
|
245
|
+
}
|
|
246
|
+
| {
|
|
247
|
+
type: "model_prompt";
|
|
248
|
+
run: MuleIdentity;
|
|
249
|
+
turn: MuleIdentity;
|
|
250
|
+
attempt: number;
|
|
251
|
+
systemPrompt: string;
|
|
252
|
+
}
|
|
253
|
+
| {
|
|
254
|
+
type: "turn_start";
|
|
255
|
+
run: MuleIdentity;
|
|
256
|
+
turn: MuleIdentity;
|
|
257
|
+
}
|
|
258
|
+
| {
|
|
259
|
+
type: "message_start";
|
|
260
|
+
run: MuleIdentity;
|
|
261
|
+
turn: MuleIdentity;
|
|
262
|
+
message: MuleIdentity;
|
|
263
|
+
value: Message;
|
|
264
|
+
}
|
|
265
|
+
| {
|
|
266
|
+
type: "message_update";
|
|
267
|
+
run: MuleIdentity;
|
|
268
|
+
turn: MuleIdentity;
|
|
269
|
+
message: MuleIdentity;
|
|
270
|
+
value: AssistantMessage;
|
|
271
|
+
event: AssistantMessageEvent;
|
|
272
|
+
}
|
|
273
|
+
| {
|
|
274
|
+
type: "message_end";
|
|
275
|
+
run: MuleIdentity;
|
|
276
|
+
turn: MuleIdentity;
|
|
277
|
+
message: MuleIdentity;
|
|
278
|
+
value: Message;
|
|
279
|
+
}
|
|
280
|
+
| {
|
|
281
|
+
type: "tool_execution_start";
|
|
282
|
+
replay: "safe" | "unsafe";
|
|
283
|
+
run: MuleIdentity;
|
|
284
|
+
turn: MuleIdentity;
|
|
285
|
+
toolCall: MuleIdentity;
|
|
286
|
+
call: ToolCall;
|
|
287
|
+
}
|
|
288
|
+
| {
|
|
289
|
+
type: "tool_execution_update";
|
|
290
|
+
run: MuleIdentity;
|
|
291
|
+
turn: MuleIdentity;
|
|
292
|
+
toolCall: MuleIdentity;
|
|
293
|
+
call: ToolCall;
|
|
294
|
+
result: MuleToolResult;
|
|
295
|
+
}
|
|
296
|
+
| {
|
|
297
|
+
type: "tool_execution_end";
|
|
298
|
+
run: MuleIdentity;
|
|
299
|
+
turn: MuleIdentity;
|
|
300
|
+
toolCall: MuleIdentity;
|
|
301
|
+
call: ToolCall;
|
|
302
|
+
result: MuleToolResult;
|
|
303
|
+
}
|
|
304
|
+
| {
|
|
305
|
+
type: "turn_end";
|
|
306
|
+
run: MuleIdentity;
|
|
307
|
+
turn: MuleIdentity;
|
|
308
|
+
message: AssistantMessage;
|
|
309
|
+
toolResults: readonly ToolResultMessage[];
|
|
310
|
+
}
|
|
311
|
+
| {
|
|
312
|
+
type: "run_end";
|
|
313
|
+
run: MuleIdentity;
|
|
314
|
+
terminal: MuleIdentity;
|
|
315
|
+
outcome: "completed" | "cancelled" | "failed";
|
|
316
|
+
};
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Lifecycle emitted around Pi values. Pi messages and events are not rewritten.
|
|
320
|
+
|
|
321
|
+
#### Union Members
|
|
322
|
+
|
|
323
|
+
##### Type Literal
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
{
|
|
327
|
+
type: "run_start";
|
|
328
|
+
run: MuleIdentity;
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
##### Type Literal
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
{
|
|
338
|
+
type: "model_prompt";
|
|
339
|
+
run: MuleIdentity;
|
|
340
|
+
turn: MuleIdentity;
|
|
341
|
+
attempt: number;
|
|
342
|
+
systemPrompt: string;
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
| Name | Type | Description |
|
|
347
|
+
| -------------- | ------------------------------- | ----------------------------------------------------------------- |
|
|
348
|
+
| `type` | `"model_prompt"` | Exact prompt sent on this model attempt, including after a retry. |
|
|
349
|
+
| `run` | [`MuleIdentity`](#muleidentity) | - |
|
|
350
|
+
| `turn` | [`MuleIdentity`](#muleidentity) | - |
|
|
351
|
+
| `attempt` | `number` | - |
|
|
352
|
+
| `systemPrompt` | `string` | - |
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
##### Type Literal
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
{
|
|
360
|
+
type: "turn_start";
|
|
361
|
+
run: MuleIdentity;
|
|
362
|
+
turn: MuleIdentity;
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
##### Type Literal
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
{
|
|
372
|
+
type: "message_start";
|
|
373
|
+
run: MuleIdentity;
|
|
374
|
+
turn: MuleIdentity;
|
|
375
|
+
message: MuleIdentity;
|
|
376
|
+
value: Message;
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
##### Type Literal
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
{
|
|
386
|
+
type: "message_update";
|
|
387
|
+
run: MuleIdentity;
|
|
388
|
+
turn: MuleIdentity;
|
|
389
|
+
message: MuleIdentity;
|
|
390
|
+
value: AssistantMessage;
|
|
391
|
+
event: AssistantMessageEvent;
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
##### Type Literal
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
{
|
|
401
|
+
type: "message_end";
|
|
402
|
+
run: MuleIdentity;
|
|
403
|
+
turn: MuleIdentity;
|
|
404
|
+
message: MuleIdentity;
|
|
405
|
+
value: Message;
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
##### Type Literal
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
{
|
|
415
|
+
type: "tool_execution_start";
|
|
416
|
+
replay: "safe" | "unsafe";
|
|
417
|
+
run: MuleIdentity;
|
|
418
|
+
turn: MuleIdentity;
|
|
419
|
+
toolCall: MuleIdentity;
|
|
420
|
+
call: ToolCall;
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
##### Type Literal
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
{
|
|
430
|
+
type: "tool_execution_update";
|
|
431
|
+
run: MuleIdentity;
|
|
432
|
+
turn: MuleIdentity;
|
|
433
|
+
toolCall: MuleIdentity;
|
|
434
|
+
call: ToolCall;
|
|
435
|
+
result: MuleToolResult;
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
##### Type Literal
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
{
|
|
445
|
+
type: "tool_execution_end";
|
|
446
|
+
run: MuleIdentity;
|
|
447
|
+
turn: MuleIdentity;
|
|
448
|
+
toolCall: MuleIdentity;
|
|
449
|
+
call: ToolCall;
|
|
450
|
+
result: MuleToolResult;
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
##### Type Literal
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
{
|
|
460
|
+
type: "turn_end";
|
|
461
|
+
run: MuleIdentity;
|
|
462
|
+
turn: MuleIdentity;
|
|
463
|
+
message: AssistantMessage;
|
|
464
|
+
toolResults: readonly ToolResultMessage[];
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
##### Type Literal
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
{
|
|
474
|
+
type: "run_end";
|
|
475
|
+
run: MuleIdentity;
|
|
476
|
+
terminal: MuleIdentity;
|
|
477
|
+
outcome: "completed" | "cancelled" | "failed";
|
|
478
|
+
}
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
| Name | Type | Description |
|
|
482
|
+
| ---------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
483
|
+
| `type` | `"run_end"` | The run's one terminal. A run interrupted after `run_start` ends `cancelled`; a run that fails with a non-listener `MuleError` ends `failed`. A listener failure ends the run without this event. |
|
|
484
|
+
| `run` | [`MuleIdentity`](#muleidentity) | - |
|
|
485
|
+
| `terminal` | [`MuleIdentity`](#muleidentity) | - |
|
|
486
|
+
| `outcome` | `"completed"` \| `"cancelled"` \| `"failed"` | - |
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
### MuleToolCheckpoint
|
|
491
|
+
|
|
492
|
+
```ts
|
|
493
|
+
type MuleToolCheckpoint =
|
|
494
|
+
| {
|
|
495
|
+
call: ToolCall;
|
|
496
|
+
state: "pending";
|
|
497
|
+
}
|
|
498
|
+
| {
|
|
499
|
+
call: ToolCall;
|
|
500
|
+
state: "started";
|
|
501
|
+
replay: "safe" | "unsafe";
|
|
502
|
+
}
|
|
503
|
+
| {
|
|
504
|
+
call: ToolCall;
|
|
505
|
+
state: "completed";
|
|
506
|
+
result: MuleToolResult;
|
|
507
|
+
message?: ToolResultMessage;
|
|
508
|
+
};
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
Durable evidence for a call in an interrupted assistant turn.
|
|
512
|
+
|
|
513
|
+
#### Union Members
|
|
514
|
+
|
|
515
|
+
##### Type Literal
|
|
516
|
+
|
|
517
|
+
```ts
|
|
518
|
+
{
|
|
519
|
+
call: ToolCall;
|
|
520
|
+
state: "pending";
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
##### Type Literal
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
{
|
|
530
|
+
call: ToolCall;
|
|
531
|
+
state: "started";
|
|
532
|
+
replay: "safe" | "unsafe";
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
##### Type Literal
|
|
539
|
+
|
|
540
|
+
```ts
|
|
541
|
+
{
|
|
542
|
+
call: ToolCall;
|
|
543
|
+
state: "completed";
|
|
544
|
+
result: MuleToolResult;
|
|
545
|
+
message?: ToolResultMessage;
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
| Name | Type | Description |
|
|
550
|
+
| ---------- | ----------------------------------- | ------------------------------------------------------ |
|
|
551
|
+
| `call` | `ToolCall` | - |
|
|
552
|
+
| `state` | `"completed"` | - |
|
|
553
|
+
| `result` | [`MuleToolResult`](#muletoolresult) | - |
|
|
554
|
+
| `message?` | `ToolResultMessage` | Present when the transcript message was committed too. |
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
### MuleResume
|
|
559
|
+
|
|
560
|
+
```ts
|
|
561
|
+
type MuleResume = object;
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
Completed assistant turn recovered by the transcript owner, before its next
|
|
565
|
+
model call.
|
|
566
|
+
|
|
567
|
+
#### Properties
|
|
568
|
+
|
|
569
|
+
##### message
|
|
570
|
+
|
|
571
|
+
```ts
|
|
572
|
+
readonly message: AssistantMessage;
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
##### tools
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
readonly tools: readonly MuleToolCheckpoint[];
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
### MuleRunSettings
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
type MuleRunSettings = object;
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
Run inputs that are identical on the Promise and Effect roots.
|
|
590
|
+
|
|
591
|
+
#### Properties
|
|
592
|
+
|
|
593
|
+
##### model
|
|
594
|
+
|
|
595
|
+
```ts
|
|
596
|
+
readonly model: Model<Api>;
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
##### stream?
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
readonly optional stream?: MuleStreamFunction;
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
Override Pi's default `streamSimple`, primarily for explicit providers and
|
|
606
|
+
tests.
|
|
607
|
+
|
|
608
|
+
##### systemPrompt
|
|
609
|
+
|
|
610
|
+
```ts
|
|
611
|
+
readonly systemPrompt: string;
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
##### messages
|
|
615
|
+
|
|
616
|
+
```ts
|
|
617
|
+
readonly messages: readonly Message[];
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
##### resume?
|
|
621
|
+
|
|
622
|
+
```ts
|
|
623
|
+
readonly optional resume?: MuleResume;
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
Continue a durable, completed assistant turn before requesting another response.
|
|
627
|
+
|
|
628
|
+
##### streamOptions?
|
|
629
|
+
|
|
630
|
+
```ts
|
|
631
|
+
readonly optional streamOptions?: Omit<SimpleStreamOptions, "signal">;
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
Pi stream options. Cancellation is the run's interruption, never a signal here.
|
|
635
|
+
|
|
636
|
+
##### modelStreamIdleTimeoutMs?
|
|
637
|
+
|
|
638
|
+
```ts
|
|
639
|
+
readonly optional modelStreamIdleTimeoutMs?: number;
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Maximum silence between provider stream events, in milliseconds.
|
|
643
|
+
|
|
644
|
+
##### toolExecution?
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
readonly optional toolExecution?: "parallel" | "sequential";
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
##### retry?
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
readonly optional retry?: RetryPolicy;
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
Pi's bounded retry policy around each assistant call (`retryAssistantCall`).
|
|
657
|
+
Undefined means no retry, matching pi-ai's own default. Hosts that want Pi
|
|
658
|
+
coding-agent's numbers pass `piCodingAgentRetryDefaults`.
|
|
659
|
+
|
|
660
|
+
##### retryAfterMs?
|
|
661
|
+
|
|
662
|
+
```ts
|
|
663
|
+
readonly optional retryAfterMs?: (message) => number | undefined;
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
Provider's bounded Retry-After evidence for the last assistant error.
|
|
667
|
+
|
|
668
|
+
###### Parameters
|
|
669
|
+
|
|
670
|
+
| Parameter | Type |
|
|
671
|
+
| --------- | ------------------ |
|
|
672
|
+
| `message` | `AssistantMessage` |
|
|
673
|
+
|
|
674
|
+
###### Returns
|
|
675
|
+
|
|
676
|
+
`number` \| `undefined`
|
|
677
|
+
|
|
678
|
+
---
|
|
679
|
+
|
|
680
|
+
### MuleRunOutcome
|
|
681
|
+
|
|
682
|
+
```ts
|
|
683
|
+
type MuleRunOutcome = object;
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
Honest terminal result of one Mule invocation.
|
|
687
|
+
|
|
688
|
+
#### Properties
|
|
689
|
+
|
|
690
|
+
##### status
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
readonly status: "completed" | "cancelled" | "failed";
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
##### run
|
|
697
|
+
|
|
698
|
+
```ts
|
|
699
|
+
readonly run: MuleIdentity;
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
##### terminal
|
|
703
|
+
|
|
704
|
+
```ts
|
|
705
|
+
readonly terminal: MuleIdentity;
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
##### message
|
|
709
|
+
|
|
710
|
+
```ts
|
|
711
|
+
readonly message: AssistantMessage;
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
##### messages
|
|
715
|
+
|
|
716
|
+
```ts
|
|
717
|
+
readonly messages: readonly Message[];
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
### MulePromiseListener
|
|
723
|
+
|
|
724
|
+
```ts
|
|
725
|
+
type MulePromiseListener = (event, signal) => Promise<void> | void;
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Promise listener adapted once into Mule's canonical Effect program.
|
|
729
|
+
|
|
730
|
+
#### Parameters
|
|
731
|
+
|
|
732
|
+
| Parameter | Type |
|
|
733
|
+
| --------- | ------------------------- |
|
|
734
|
+
| `event` | [`MuleEvent`](#muleevent) |
|
|
735
|
+
| `signal` | `AbortSignal` |
|
|
736
|
+
|
|
737
|
+
#### Returns
|
|
738
|
+
|
|
739
|
+
`Promise`\<`void`\> \| `void`
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
|
|
743
|
+
### MuleToolPreparation
|
|
744
|
+
|
|
745
|
+
```ts
|
|
746
|
+
type MuleToolPreparation =
|
|
747
|
+
| {
|
|
748
|
+
status: "prepared";
|
|
749
|
+
execute: (signal) => AsyncIterable<MuleToolExecutionPart>;
|
|
750
|
+
}
|
|
751
|
+
| (object & MuleToolRejection);
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
Outcome of preparing one exact Pi tool call.
|
|
755
|
+
|
|
756
|
+
#### Union Members
|
|
757
|
+
|
|
758
|
+
##### Type Literal
|
|
759
|
+
|
|
760
|
+
```ts
|
|
761
|
+
{
|
|
762
|
+
status: "prepared";
|
|
763
|
+
execute: (signal) => AsyncIterable<MuleToolExecutionPart>;
|
|
764
|
+
}
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
| Name | Type | Description |
|
|
768
|
+
| ----------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
769
|
+
| `status` | `"prepared"` | - |
|
|
770
|
+
| `execute()` | (`signal`) => `AsyncIterable`\<[`MuleToolExecutionPart`](#muletoolexecutionpart)\> | Run the already-decoded and authorized call; abort ends it early. |
|
|
771
|
+
|
|
772
|
+
---
|
|
773
|
+
|
|
774
|
+
`object` & [`MuleToolRejection`](#muletoolrejection)
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
### MuleTool
|
|
779
|
+
|
|
780
|
+
```ts
|
|
781
|
+
type MuleTool = object;
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
Pi tool declaration paired with its Promise preparation door.
|
|
785
|
+
|
|
786
|
+
#### Properties
|
|
787
|
+
|
|
788
|
+
##### descriptor
|
|
789
|
+
|
|
790
|
+
```ts
|
|
791
|
+
readonly descriptor: Tool;
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
##### replay?
|
|
795
|
+
|
|
796
|
+
```ts
|
|
797
|
+
readonly optional replay?: "safe" | "unsafe";
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
Only read-only or explicitly idempotent tools may opt into crash replay.
|
|
801
|
+
|
|
802
|
+
##### executionMode?
|
|
803
|
+
|
|
804
|
+
```ts
|
|
805
|
+
readonly optional executionMode?: "parallel" | "sequential";
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
##### prepare
|
|
809
|
+
|
|
810
|
+
```ts
|
|
811
|
+
readonly prepare: (call, signal) => Promise<MuleToolPreparation>;
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
Decode and authorize one exact Pi tool call before it can execute.
|
|
815
|
+
|
|
816
|
+
###### Parameters
|
|
817
|
+
|
|
818
|
+
| Parameter | Type |
|
|
819
|
+
| --------- | ------------- |
|
|
820
|
+
| `call` | `ToolCall` |
|
|
821
|
+
| `signal` | `AbortSignal` |
|
|
822
|
+
|
|
823
|
+
###### Returns
|
|
824
|
+
|
|
825
|
+
`Promise`\<[`MuleToolPreparation`](#muletoolpreparation)\>
|
|
826
|
+
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
### MuleRunInput
|
|
830
|
+
|
|
831
|
+
```ts
|
|
832
|
+
type MuleRunInput = MuleRunSettings & object;
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
Inputs for one complete Pi model/tool loop through the Promise facade.
|
|
836
|
+
|
|
837
|
+
#### Type Declaration
|
|
838
|
+
|
|
839
|
+
| Name | Type | Description |
|
|
840
|
+
| ------------------------ | -------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
841
|
+
| `tools?` | readonly [`MuleTool`](#muletool)[] | - |
|
|
842
|
+
| `resolveApiKey()?` | (`provider`, `signal`) => `Promise`\<`string` \| `undefined`\> | Resolve a fresh provider credential immediately before each Pi call. |
|
|
843
|
+
| `getSteeringMessages()?` | (`signal`) => `Promise`\<readonly `Message`[]\> | Pull messages that should steer the active run at Pi's safe point. |
|
|
844
|
+
| `getFollowUpMessages()?` | (`signal`) => `Promise`\<readonly `Message`[]\> | Pull messages queued until the run would otherwise finish. |
|
|
845
|
+
| `shouldStopAfterTurn()?` | (`turn`, `signal`) => `Promise`\<`boolean`\> | Request a graceful stop after the current Pi turn has fully settled. |
|
|
846
|
+
|
|
847
|
+
---
|
|
848
|
+
|
|
849
|
+
### Mule
|
|
850
|
+
|
|
851
|
+
```ts
|
|
852
|
+
type Mule = object;
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
Promise-facing Mule interface.
|
|
856
|
+
|
|
857
|
+
#### Properties
|
|
858
|
+
|
|
859
|
+
##### run
|
|
860
|
+
|
|
861
|
+
```ts
|
|
862
|
+
readonly run: (input, listener?, signal?) => Promise<MuleRunOutcome>;
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
Run one complete Pi model/tool loop. Rejects with the `MuleError` that failed
|
|
866
|
+
the run, or with the abort reason (an `AbortError` when the reason is not an
|
|
867
|
+
`Error`) after the caller aborts `signal`.
|
|
868
|
+
|
|
869
|
+
###### Parameters
|
|
870
|
+
|
|
871
|
+
| Parameter | Type |
|
|
872
|
+
| ----------- | --------------------------------------------- |
|
|
873
|
+
| `input` | [`MuleRunInput`](#muleruninput) |
|
|
874
|
+
| `listener?` | [`MulePromiseListener`](#mulepromiselistener) |
|
|
875
|
+
| `signal?` | `AbortSignal` |
|
|
876
|
+
|
|
877
|
+
###### Returns
|
|
878
|
+
|
|
879
|
+
`Promise`\<[`MuleRunOutcome`](#mulerunoutcome)\>
|
|
880
|
+
|
|
881
|
+
## Variables
|
|
882
|
+
|
|
883
|
+
### mule
|
|
884
|
+
|
|
885
|
+
```ts
|
|
886
|
+
const mule: Mule;
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
Default Promise-facing Mule interface.
|