@demlik/tea 0.13.0 → 0.14.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 +11 -9
- package/dist/agent/index.d.ts +637 -45
- package/dist/agent/index.js +9 -19
- package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
- package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
- package/dist/chunk-AQ6ZIMEA.js +421 -0
- package/dist/chunk-AQ6ZIMEA.js.map +1 -0
- package/dist/{chunk-MUUROGIH.js → chunk-BLJ2JQSH.js} +62 -12
- package/dist/chunk-BLJ2JQSH.js.map +1 -0
- package/dist/{chunk-RH5EFRVJ.js → chunk-F2US5BW6.js} +25 -5
- package/dist/chunk-F2US5BW6.js.map +1 -0
- package/dist/{batch-window/index.js → chunk-F7FMAWLA.js} +4 -8
- package/dist/chunk-F7FMAWLA.js.map +1 -0
- package/dist/{chunk-O4MVQTEJ.js → chunk-HUKZQX6U.js} +20 -16
- package/dist/chunk-HUKZQX6U.js.map +1 -0
- package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
- package/dist/chunk-HWVW4AXC.js.map +1 -0
- package/dist/{chunk-DMYGQB4O.js → chunk-HYDWG35Q.js} +23 -6
- package/dist/chunk-HYDWG35Q.js.map +1 -0
- package/dist/{chunk-YUXP55T2.js → chunk-I5MQMJDW.js} +57 -7
- package/dist/chunk-I5MQMJDW.js.map +1 -0
- package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
- package/dist/chunk-LFZUK6J2.js.map +1 -0
- package/dist/{chunk-ZVJZ72HY.js → chunk-LYLTKJWM.js} +25 -11
- package/dist/chunk-LYLTKJWM.js.map +1 -0
- package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
- package/dist/chunk-MYXFNWAJ.js.map +1 -0
- package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
- package/dist/chunk-PR6TB3BL.js.map +1 -0
- package/dist/chunk-RQULHGYH.js +1804 -0
- package/dist/chunk-RQULHGYH.js.map +1 -0
- package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
- package/dist/chunk-TXN2KFHF.js.map +1 -0
- package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
- package/dist/chunk-VBDU4JL6.js.map +1 -0
- package/dist/chunk-Z2L3LSNV.js +1470 -0
- package/dist/chunk-Z2L3LSNV.js.map +1 -0
- package/dist/{core-Co0LWkIA.d.ts → core-CTzMJ82M.d.ts} +72 -23
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +207 -2
- package/dist/devtools/index.js.map +1 -1
- package/dist/do/index.d.ts +42 -29
- package/dist/do/index.js +36 -25
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-B0-qGQDy.d.ts} +2 -2
- package/dist/extension/index.d.ts +300 -3
- package/dist/extension/index.js +596 -5
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +1295 -0
- package/dist/flow/index.js +732 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/idempotency/index.d.ts +90 -116
- package/dist/idempotency/index.js +4 -1
- package/dist/{batch-window/index.d.ts → index-4vZzljCD.d.ts} +7 -12
- package/dist/{fan-out/index.d.ts → index-6A7dB8f6.d.ts} +7 -9
- package/dist/index-B5BZ-_cT.d.ts +616 -0
- package/dist/index-Bc40JWVl.d.ts +131 -0
- package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
- package/dist/index-DJWIER_3.d.ts +69 -0
- package/dist/{snapshot/index.d.ts → index-DMCeMPMJ.d.ts} +15 -78
- package/dist/{monitored-run/index.d.ts → index-NjrT3fL2.d.ts} +37 -13
- package/dist/{recorder/index.d.ts → index-TvRb1KVf.d.ts} +4 -7
- package/dist/{deadline/index.d.ts → index-q0hXFeZ0.d.ts} +155 -9
- package/dist/index.d.ts +711 -6
- package/dist/index.js +1 -2
- package/dist/jev/index.d.ts +634 -0
- package/dist/jev/index.js +433 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/machine-CdIcN2Xm.d.ts +1773 -0
- package/dist/machine-viz/index.d.ts +1 -1
- package/dist/machine-viz/index.js +12 -5
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +18 -3
- package/dist/mem/index.js +22 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +104 -6
- package/dist/node/index.js +132 -9
- package/dist/node/index.js.map +1 -1
- package/dist/{paginator → paginate}/index.d.ts +151 -6
- package/dist/paginate/index.js +7 -0
- package/dist/parity/index.d.ts +4 -10
- package/dist/parity/index.js +4 -7
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +247 -5
- package/dist/pbt/index.js +124 -5
- package/dist/pbt/index.js.map +1 -1
- package/dist/{trace-replay → persistence}/index.d.ts +7 -5
- package/dist/persistence/index.js +6 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -2
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +743 -0
- package/dist/resilience/index.js +657 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/retry-backoff/index.d.ts +3 -2
- package/dist/retry-backoff/index.js +1 -1
- package/dist/runtime-types-LWDoi943.d.ts +998 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/index.js.map +1 -1
- package/dist/{throttled-input → timing}/index.d.ts +143 -12
- package/dist/{throttled-input → timing}/index.js +57 -12
- package/dist/timing/index.js.map +1 -0
- package/dist/{types-XS_miRnB.d.ts → types-DP3f5NIl.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +130 -54
- package/dist/work-queue/index.js +3 -2
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +45 -218
- package/dist/authed-call/index.d.ts +0 -120
- package/dist/authed-call/index.js +0 -134
- package/dist/authed-call/index.js.map +0 -1
- package/dist/await-terminal/index.d.ts +0 -101
- package/dist/await-terminal/index.js +0 -76
- package/dist/await-terminal/index.js.map +0 -1
- package/dist/batch-window/index.js.map +0 -1
- package/dist/cache/index.d.ts +0 -152
- package/dist/cache/index.js +0 -8
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -16
- package/dist/chart/index.js.map +0 -1
- package/dist/chart/inspect/index.d.ts +0 -86
- package/dist/chart/inspect/index.js +0 -5
- package/dist/chart/inspect/react.d.ts +0 -113
- package/dist/chart/inspect/react.js +0 -11
- package/dist/chart/inspect/react.js.map +0 -1
- package/dist/chart/inspect/styles.css +0 -286
- package/dist/chart/lane/index.d.ts +0 -362
- package/dist/chart/lane/index.js +0 -9
- package/dist/chart/lane/index.js.map +0 -1
- package/dist/chart/lane/react.d.ts +0 -84
- package/dist/chart/lane/react.js +0 -559
- package/dist/chart/lane/react.js.map +0 -1
- package/dist/chart/lane/server.d.ts +0 -148
- package/dist/chart/lane/server.js +0 -209
- package/dist/chart/lane/server.js.map +0 -1
- package/dist/chart/lane/styles.css +0 -498
- package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
- package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
- package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
- package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
- package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
- package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
- package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
- package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
- package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
- package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
- package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
- package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/index.html +0 -15
- package/dist/chart/report/index.d.ts +0 -117
- package/dist/chart/report/index.js +0 -32
- package/dist/chart/report/index.js.map +0 -1
- package/dist/chunk-2YFLOCWX.js +0 -15
- package/dist/chunk-2YFLOCWX.js.map +0 -1
- package/dist/chunk-3I52QZZ5.js +0 -519
- package/dist/chunk-3I52QZZ5.js.map +0 -1
- package/dist/chunk-3ZAFFRRB.js +0 -457
- package/dist/chunk-3ZAFFRRB.js.map +0 -1
- package/dist/chunk-4EQZ76JC.js +0 -33
- package/dist/chunk-4EQZ76JC.js.map +0 -1
- package/dist/chunk-4KLG43GY.js +0 -223
- package/dist/chunk-4KLG43GY.js.map +0 -1
- package/dist/chunk-7FRZ2CT2.js +0 -424
- package/dist/chunk-7FRZ2CT2.js.map +0 -1
- package/dist/chunk-AZZLE7XR.js +0 -62
- package/dist/chunk-AZZLE7XR.js.map +0 -1
- package/dist/chunk-BYQUGDD3.js +0 -16
- package/dist/chunk-BYQUGDD3.js.map +0 -1
- package/dist/chunk-CIQG5L42.js +0 -685
- package/dist/chunk-CIQG5L42.js.map +0 -1
- package/dist/chunk-CLM6ERNO.js +0 -61
- package/dist/chunk-CLM6ERNO.js.map +0 -1
- package/dist/chunk-COS5MSTO.js +0 -88
- package/dist/chunk-COS5MSTO.js.map +0 -1
- package/dist/chunk-CRPZJVD2.js +0 -71
- package/dist/chunk-CRPZJVD2.js.map +0 -1
- package/dist/chunk-D62FDQKE.js +0 -53
- package/dist/chunk-D62FDQKE.js.map +0 -1
- package/dist/chunk-D736QUGF.js.map +0 -1
- package/dist/chunk-DGE4PV4A.js +0 -26
- package/dist/chunk-DGE4PV4A.js.map +0 -1
- package/dist/chunk-DMYGQB4O.js.map +0 -1
- package/dist/chunk-EWJP3YYP.js.map +0 -1
- package/dist/chunk-FV3Z5MBE.js.map +0 -1
- package/dist/chunk-HCEVHFJ7.js +0 -54
- package/dist/chunk-HCEVHFJ7.js.map +0 -1
- package/dist/chunk-J6527VRQ.js.map +0 -1
- package/dist/chunk-JELSZN25.js +0 -47
- package/dist/chunk-JELSZN25.js.map +0 -1
- package/dist/chunk-K575PT4S.js.map +0 -1
- package/dist/chunk-L57ZOT5K.js +0 -184
- package/dist/chunk-L57ZOT5K.js.map +0 -1
- package/dist/chunk-MU6MCIAC.js +0 -15
- package/dist/chunk-MU6MCIAC.js.map +0 -1
- package/dist/chunk-MUUROGIH.js.map +0 -1
- package/dist/chunk-NR7BU22N.js +0 -758
- package/dist/chunk-NR7BU22N.js.map +0 -1
- package/dist/chunk-O4MVQTEJ.js.map +0 -1
- package/dist/chunk-OOYD44JI.js +0 -317
- package/dist/chunk-OOYD44JI.js.map +0 -1
- package/dist/chunk-Q2UM7BXU.js.map +0 -1
- package/dist/chunk-RH5EFRVJ.js.map +0 -1
- package/dist/chunk-S2EGRPCM.js +0 -47
- package/dist/chunk-S2EGRPCM.js.map +0 -1
- package/dist/chunk-SINXE47Y.js +0 -55
- package/dist/chunk-SINXE47Y.js.map +0 -1
- package/dist/chunk-UF4MZSLT.js +0 -53
- package/dist/chunk-UF4MZSLT.js.map +0 -1
- package/dist/chunk-UOC2PL46.js +0 -13
- package/dist/chunk-UOC2PL46.js.map +0 -1
- package/dist/chunk-VYFAZN3F.js +0 -372
- package/dist/chunk-VYFAZN3F.js.map +0 -1
- package/dist/chunk-WRAA7GVZ.js +0 -209
- package/dist/chunk-WRAA7GVZ.js.map +0 -1
- package/dist/chunk-XGELA764.js +0 -163
- package/dist/chunk-XGELA764.js.map +0 -1
- package/dist/chunk-YUXP55T2.js.map +0 -1
- package/dist/chunk-YWIKDKHY.js +0 -307
- package/dist/chunk-YWIKDKHY.js.map +0 -1
- package/dist/chunk-ZJ5AOYBH.js +0 -8
- package/dist/chunk-ZJ5AOYBH.js.map +0 -1
- package/dist/chunk-ZSUUOEPL.js +0 -731
- package/dist/chunk-ZSUUOEPL.js.map +0 -1
- package/dist/chunk-ZVJZ72HY.js.map +0 -1
- package/dist/circuit-breaker/index.d.ts +0 -197
- package/dist/circuit-breaker/index.js +0 -3
- package/dist/circuit-breaker/index.js.map +0 -1
- package/dist/deadline/index.js +0 -6
- package/dist/deadline/index.js.map +0 -1
- package/dist/debounce/index.js +0 -3
- package/dist/debounce/index.js.map +0 -1
- package/dist/extension/react.d.ts +0 -121
- package/dist/extension/react.js +0 -75
- package/dist/extension/react.js.map +0 -1
- package/dist/extension/subs/index.d.ts +0 -45
- package/dist/extension/subs/index.js +0 -80
- package/dist/extension/subs/index.js.map +0 -1
- package/dist/extension/test-utils.d.ts +0 -128
- package/dist/extension/test-utils.js +0 -277
- package/dist/extension/test-utils.js.map +0 -1
- package/dist/fan-out/index.js +0 -5
- package/dist/fan-out/index.js.map +0 -1
- package/dist/fold-BJPdjc9w.d.ts +0 -435
- package/dist/graph-B3L5e0N1.d.ts +0 -923
- package/dist/idempotency/adapter.d.ts +0 -62
- package/dist/idempotency/adapter.js +0 -4
- package/dist/idempotency/adapter.js.map +0 -1
- package/dist/idempotent-intake/index.d.ts +0 -188
- package/dist/idempotent-intake/index.js +0 -7
- package/dist/idempotent-intake/index.js.map +0 -1
- package/dist/journal/index.d.ts +0 -373
- package/dist/journal/index.js +0 -3
- package/dist/journal/index.js.map +0 -1
- package/dist/llm-call/index.d.ts +0 -311
- package/dist/llm-call/index.js +0 -16
- package/dist/llm-call/index.js.map +0 -1
- package/dist/machine-BtFWQmmq.d.ts +0 -804
- package/dist/monitored-run/index.js +0 -10
- package/dist/monitored-run/index.js.map +0 -1
- package/dist/paginated-walk/index.d.ts +0 -235
- package/dist/paginated-walk/index.js +0 -16
- package/dist/paginated-walk/index.js.map +0 -1
- package/dist/paginator/index.js +0 -3
- package/dist/paginator/index.js.map +0 -1
- package/dist/pbt/arbitraries/index.d.ts +0 -136
- package/dist/pbt/arbitraries/index.js +0 -3
- package/dist/pbt/arbitraries/index.js.map +0 -1
- package/dist/pbt/runners/index.d.ts +0 -118
- package/dist/pbt/runners/index.js +0 -5
- package/dist/pbt/runners/index.js.map +0 -1
- package/dist/poller/index.d.ts +0 -352
- package/dist/poller/index.js +0 -115
- package/dist/poller/index.js.map +0 -1
- package/dist/prediction/index.d.ts +0 -131
- package/dist/prediction/index.js +0 -4
- package/dist/prediction/index.js.map +0 -1
- package/dist/protocol-B5YmJr0d.d.ts +0 -45
- package/dist/pure/index.d.ts +0 -3
- package/dist/pure/index.js +0 -4
- package/dist/pure/index.js.map +0 -1
- package/dist/rate-limit/index.d.ts +0 -115
- package/dist/rate-limit/index.js +0 -3
- package/dist/rate-limit/index.js.map +0 -1
- package/dist/reconciler/index.d.ts +0 -193
- package/dist/reconciler/index.js +0 -164
- package/dist/reconciler/index.js.map +0 -1
- package/dist/recorder/index.js +0 -3
- package/dist/recorder/index.js.map +0 -1
- package/dist/reducer-4GNR6b8B.d.ts +0 -447
- package/dist/resilient-call/index.d.ts +0 -320
- package/dist/resilient-call/index.js +0 -14
- package/dist/resilient-call/index.js.map +0 -1
- package/dist/retry-to-success/index.d.ts +0 -109
- package/dist/retry-to-success/index.js +0 -37
- package/dist/retry-to-success/index.js.map +0 -1
- package/dist/run-pAcmBpah.d.ts +0 -713
- package/dist/runtime-types-CNLmhWif.d.ts +0 -517
- package/dist/saga/index.d.ts +0 -241
- package/dist/saga/index.js +0 -150
- package/dist/saga/index.js.map +0 -1
- package/dist/samples-B3My5oh2.d.ts +0 -59
- package/dist/snapshot/index.js +0 -5
- package/dist/snapshot/index.js.map +0 -1
- package/dist/subs/index.d.ts +0 -472
- package/dist/subs/index.js +0 -7
- package/dist/subs/index.js.map +0 -1
- package/dist/throttle/index.d.ts +0 -134
- package/dist/throttle/index.js +0 -3
- package/dist/throttle/index.js.map +0 -1
- package/dist/throttled-input/index.js.map +0 -1
- package/dist/token-refresh/index.d.ts +0 -216
- package/dist/token-refresh/index.js +0 -6
- package/dist/token-refresh/index.js.map +0 -1
- package/dist/trace-replay/index.js +0 -6
- package/dist/trace-replay/index.js.map +0 -1
- package/dist/with-deadline/index.d.ts +0 -197
- package/dist/with-deadline/index.js +0 -111
- package/dist/with-deadline/index.js.map +0 -1
- package/dist/with-resilience/index.d.ts +0 -225
- package/dist/with-resilience/index.js +0 -240
- package/dist/with-resilience/index.js.map +0 -1
- package/dist/with-telemetry/index.d.ts +0 -150
- package/dist/with-telemetry/index.js +0 -70
- package/dist/with-telemetry/index.js.map +0 -1
- package/dist/work-queue/adapter.d.ts +0 -84
- package/dist/work-queue/adapter.js +0 -4
- package/dist/work-queue/adapter.js.map +0 -1
- package/dist/work-queue/ops.d.ts +0 -71
- package/dist/work-queue/ops.js +0 -3
- package/dist/work-queue/ops.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -485
- package/dist/workflow/index.js +0 -244
- package/dist/workflow/index.js.map +0 -1
- /package/dist/{cache → paginate}/index.js.map +0 -0
- /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,22 +1,605 @@
|
|
|
1
|
-
import { C as Cmd } from '../core-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
1
|
+
import { R as RequiredCtx, M as Machine, I as Interpret, C as Cmd } from '../core-CTzMJ82M.js';
|
|
2
|
+
import { T as ToolCall, a as ToolOutcome, C as Conversation, A as AnyToolDef, P as PlainModel, b as AgentTurn, S as StreamingModel, c as AgentState, d as ToolResult, e as ToolFailureOf, f as ToolCmd, g as AgentEvent, h as TurnChunk, i as AgentMachineMsg, W as WiredToolMsg, j as AgentCmd, k as AgentConfigCore, l as CompactionPolicy, m as AgentKnob } from '../machine-CdIcN2Xm.js';
|
|
3
|
+
export { n as AgentBootMsg, o as AgentCancelMsg, p as AgentCompactErrMsg, q as AgentCompactOkMsg, r as AgentCompactRunCmd, s as AgentCompactionConfig, t as AgentConfig, u as AgentDetachedHandlers, v as AgentFailure, w as AgentLlmErrMsg, x as AgentLlmOkMsg, y as AgentLlmRunCmd, z as AgentPorts, B as AgentSnapshotConfig, D as AgentStatus, E as AgentTerminalFailure, F as AgentTimerMsg, G as AgentToMachine, H as Awaiting, I as COMPACTION_PURPOSE, J as CompactInterpret, K as CompactionOutputs, L as CompactionPurpose, M as CompactionSummary, N as LlmCall, O as LlmErr, Q as LlmFailMsg, R as LlmOk, U as LlmRunCmd, V as LlmSucceedMsg, X as MessageLoader, Y as ModelFactory, Z as ModelPort, _ as ModelStream, $ as PLAIN_MODEL_MISROUTE_REASON, a0 as ReservedToolName, a1 as Schema, a2 as SnapshotInterpret, a3 as TOOL_RETRY_EXHAUSTED_TAG, a4 as TOOL_TIMEOUT_TAG, a5 as TaggedFailure, a6 as ToolConstructors, a7 as ToolDef, a8 as ToolError, a9 as ToolFail, aa as ToolFailure, ab as ToolHandler, ac as ToolInput, ad as ToolMsg, ae as ToolOk, af as ToolRecord, ag as ToolRejectedCmd, ah as ToolRejection, ai as ToolResilience, aj as ToolResilienceError, ak as ToolRetryExhausted, al as ToolRouter, am as ToolSettlement, an as ToolThrown, ao as ToolTimedOut, ap as WiredToolCmd, aq as agentBootMsg, ar as agentCancelMsg, as as agentEvents, at as agentTurnSchema, au as compactionSummarySchema, av as fanOutInterpret, aw as isAgentTurn, ax as isCompactionSummary, ay as isReservedToolName, az as isStreamingModel, aA as liftAgent, aB as mergeInterpret, aC as plainModel, aD as status, aE as tool, aF as toolErrorReason, aG as toolRouter } from '../machine-CdIcN2Xm.js';
|
|
4
|
+
import { a as ScopedCtxArg, S as Store } from '../runtime-types-LWDoi943.js';
|
|
5
|
+
import { E as EndedRun } from '../index-NjrT3fL2.js';
|
|
6
|
+
export { M as MonitoredRunCmd, R as RunFailure } from '../index-NjrT3fL2.js';
|
|
7
|
+
import { RetryPolicy } from '../retry-backoff/index.js';
|
|
8
|
+
import { a as DeadlineSub } from '../index-q0hXFeZ0.js';
|
|
9
|
+
export { b as deadlineSub, s as subscribeDeadline } from '../index-q0hXFeZ0.js';
|
|
7
10
|
import 'zod';
|
|
8
|
-
import '../
|
|
9
|
-
import '../
|
|
10
|
-
import '../
|
|
11
|
-
import '../circuit-breaker/index.js';
|
|
12
|
-
import '../protocol-B5YmJr0d.js';
|
|
13
|
-
import '../rate-limit/index.js';
|
|
14
|
-
import '../retry-backoff/index.js';
|
|
15
|
-
import '../fan-out/index.js';
|
|
16
|
-
import '../work-queue/index.js';
|
|
17
|
-
import '../runtime-types-CNLmhWif.js';
|
|
11
|
+
import '../index-B5BZ-_cT.js';
|
|
12
|
+
import '../index-6A7dB8f6.js';
|
|
13
|
+
import '../index-DJWIER_3.js';
|
|
18
14
|
import 'better-result';
|
|
19
|
-
import '../
|
|
15
|
+
import '../index-DMCeMPMJ.js';
|
|
16
|
+
import '../types-DP3f5NIl.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @demlik/tea/agent — `defineAgent`, the convenience layer over `createAgent`.
|
|
20
|
+
*
|
|
21
|
+
* `defineAgent({ model, tools, instructions })` is the three-line door: it
|
|
22
|
+
* defaults the single-stage wiring (`stages`, `turnOf`, `schemas`), derives the
|
|
23
|
+
* tool handlers from `toolRouter`, renders the prompt off the Model, and absorbs
|
|
24
|
+
* the drive loop through `driveToDone`. It hides wiring, never state (ADR
|
|
25
|
+
* 0015): the Model it runs is the same `AgentState` a hand-wired `createAgent`
|
|
26
|
+
* produces, under the same keys, and `machine(input)` is the door down to the
|
|
27
|
+
* raw kernel `run`. Each hidden thing is a named helper below.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One message a `defineAgent` `model` receives. Plain data the adapter renders into
|
|
32
|
+
* its provider's shape: the head is the `instructions` (when set) and the
|
|
33
|
+
* run's `input`; then, per model turn, the `assistant` turn followed by the
|
|
34
|
+
* `tool` outcomes that turn asked for. A tool outcome rides as data — the
|
|
35
|
+
* adapter decides how a failure reads to its model. An `assistant` message
|
|
36
|
+
* carries the turn's opaque `provider` slot exactly as the adapter returned it
|
|
37
|
+
* (see `AgentTurn`), present only when the stored turn has one.
|
|
38
|
+
*/
|
|
39
|
+
type AgentMessage = {
|
|
40
|
+
readonly role: "system";
|
|
41
|
+
readonly content: string;
|
|
42
|
+
} | {
|
|
43
|
+
readonly role: "user";
|
|
44
|
+
readonly content: string;
|
|
45
|
+
} | {
|
|
46
|
+
readonly role: "assistant";
|
|
47
|
+
readonly content: string;
|
|
48
|
+
readonly toolCalls: readonly ToolCall[];
|
|
49
|
+
readonly provider?: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
readonly role: "tool";
|
|
52
|
+
readonly callId: string;
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly outcome: ToolOutcome<unknown>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The brain-call payload `defineAgent` builds from the durable state — everything
|
|
58
|
+
* `messagesOf` renders, so the prompt is a pure function of the Model and the
|
|
59
|
+
* resilient slice carries exactly what was sent.
|
|
60
|
+
*/
|
|
61
|
+
interface AgentPrompt<R> {
|
|
62
|
+
readonly instructions: string | null;
|
|
63
|
+
readonly input: string | null;
|
|
64
|
+
readonly conversation: Conversation<R>;
|
|
65
|
+
}
|
|
66
|
+
/** The one purpose a `defineAgent` agent runs. */
|
|
67
|
+
type LidPurpose = "act";
|
|
68
|
+
type LidOutputs = {
|
|
69
|
+
readonly [K in LidPurpose]: AgentTurn;
|
|
70
|
+
};
|
|
71
|
+
/** The Model a defined agent runs — a hand-wired `createAgent`'s, key for key. */
|
|
72
|
+
type DefinedAgentState<T extends AnyToolDef> = AgentState<string, LidPurpose, LidOutputs, ToolResult<T>>;
|
|
73
|
+
/**
|
|
74
|
+
* The Model `run` RESOLVES with — {@link DefinedAgentState} whose `run` slice is
|
|
75
|
+
* narrowed to the ended phases ({@link EndedRun}).
|
|
76
|
+
*
|
|
77
|
+
* `run`'s terminal predicate is `done || cancelled` and its `failed` one rejects,
|
|
78
|
+
* so the never-started `idle` arm is unreachable on the resolved value. Typing
|
|
79
|
+
* the promise as the whole Model published that unreachable arm anyway, and
|
|
80
|
+
* `idle` carries no `runId` — so `(await agent.run(input)).run.runId`, a field
|
|
81
|
+
* every resolved run has, did not typecheck (#155). The narrow is on what `run`
|
|
82
|
+
* can RESOLVE; the `idle` arm is untouched and still carries no `runId`.
|
|
83
|
+
*
|
|
84
|
+
* `DefinedAgentState` itself stays wide, because it is the DURABLE Model: an
|
|
85
|
+
* `init` slice is `idle`, and a `Store<DefinedAgentState<T>>` has to hold one.
|
|
86
|
+
*/
|
|
87
|
+
type DefinedAgentResolvedState<T extends AnyToolDef> = Omit<DefinedAgentState<T>, "run"> & {
|
|
88
|
+
readonly run: EndedRun<string>;
|
|
89
|
+
};
|
|
90
|
+
/** The ctx the tools' `needs` demand, intersected — what `run` asks for. */
|
|
91
|
+
type DefinedAgentCtx<T extends AnyToolDef> = RequiredCtx<ToolCmd<T>>;
|
|
92
|
+
/** The Msg union a defined agent's machine folds. */
|
|
93
|
+
type DefinedAgentMsg<T extends AnyToolDef> = AgentMachineMsg<LidPurpose, LidOutputs, ToolResult<T>> | WiredToolMsg<T>;
|
|
94
|
+
/**
|
|
95
|
+
* The Cmd union a defined agent's machine emits — one interpret cell per member.
|
|
96
|
+
*
|
|
97
|
+
* Snapshotting is fixed OFF (the lid checkpoints through the run's `store`, not
|
|
98
|
+
* the monitored-run cadence), so `snapshot_write` is out of the union.
|
|
99
|
+
* Compaction is fixed ON, which is the SUPERSET of the two machines
|
|
100
|
+
* `defineAgent` builds: with the knob set the `compact_run` cell is the one the
|
|
101
|
+
* lid wires, and without it the reducer provably emits no such Cmd, so the
|
|
102
|
+
* machine carries no cell for it and the union simply has a member nothing
|
|
103
|
+
* reaches. Naming the superset is what lets one type describe both arms — and
|
|
104
|
+
* it is why `with` may wrap `compact_run` on a compacting agent and gets
|
|
105
|
+
* `overlaid`'s "this machine has none of that cell" throw on one without.
|
|
106
|
+
*/
|
|
107
|
+
type DefinedAgentCmd<T extends AnyToolDef> = AgentCmd<LidPurpose, ToolCmd<T>, false, true>;
|
|
108
|
+
/**
|
|
109
|
+
* The interpret table of the machine `defineAgent` wired: one cell per
|
|
110
|
+
* {@link DefinedAgentCmd}, keyed by its `type` — a tool's own Cmd type, the
|
|
111
|
+
* router's `tool_rejected`, and the agent-owned brain call.
|
|
112
|
+
*/
|
|
113
|
+
type DefinedAgentInterpret<T extends AnyToolDef> = Interpret<DefinedAgentMsg<T>, DefinedAgentCmd<T>, DefinedAgentCtx<T>>;
|
|
114
|
+
/** The wired machine `defineAgent` builds per `input` — feed it to the raw `run`. */
|
|
115
|
+
type DefinedAgentMachine<T extends AnyToolDef> = Machine<DefinedAgentState<T>, DefinedAgentMsg<T>, DefinedAgentCmd<T>, DeadlineSub, DefinedAgentCtx<T>>;
|
|
116
|
+
/**
|
|
117
|
+
* The brain a defined agent runs, in either of its two shapes:
|
|
118
|
+
*
|
|
119
|
+
* - `async (messages) => turn` — the plain port, and the common path.
|
|
120
|
+
* - `async (messages, { onChunk }) => turn` — the same call, plus a side
|
|
121
|
+
* channel it may write token deltas to while the turn is in flight.
|
|
122
|
+
*
|
|
123
|
+
* `defineAgent` takes one field for both and tells them apart by arity
|
|
124
|
+
* (`isStreamingModel`), so there is no config flag saying which you passed and
|
|
125
|
+
* no way for that flag to disagree with the function. Whichever shape you
|
|
126
|
+
* write, the run's Model is the same: the turn it RESOLVES is what the reducer
|
|
127
|
+
* folds, and the deltas end at the `onChunk` run option (see
|
|
128
|
+
* {@link DefinedAgentRunOptions}).
|
|
129
|
+
*
|
|
130
|
+
* Both members are unions of one signature so a model written inline still gets
|
|
131
|
+
* its `messages` parameter typed from the config field.
|
|
132
|
+
*/
|
|
133
|
+
type DefinedAgentModel = PlainModel<AgentMessage, AgentTurn> | StreamingModel<AgentMessage, AgentTurn>;
|
|
134
|
+
/**
|
|
135
|
+
* What `defineAgent` takes: the model, the tools and the instructions, plus the
|
|
136
|
+
* four optional guards that stop a run — `maxTurns`, `deadlineMs`,
|
|
137
|
+
* `maxElapsedMs` and `stopWhen` — and the one that keeps a run going, `retry`,
|
|
138
|
+
* the brain call's backoff ladder. Omit every guard and the run is unbounded:
|
|
139
|
+
* it ends only when the model stops asking for tools.
|
|
140
|
+
*
|
|
141
|
+
* Two more knobs bound what a run COSTS rather than whether it ends:
|
|
142
|
+
* `compaction`, which stops the transcript growing, and `toolConcurrency`,
|
|
143
|
+
* which says how many of a turn's tool calls go out at once.
|
|
144
|
+
*/
|
|
145
|
+
interface DefineAgentConfig<T extends AnyToolDef> {
|
|
146
|
+
/** The brain — either {@link DefinedAgentModel} shape. */
|
|
147
|
+
readonly model: DefinedAgentModel;
|
|
148
|
+
/** The `tool()`s the model may call. */
|
|
149
|
+
readonly tools: readonly T[];
|
|
150
|
+
/**
|
|
151
|
+
* The system prompt — stored on the Model at `init` (ADR 0004) and never
|
|
152
|
+
* re-read, so a resumed run keeps the prompt it started with even across a
|
|
153
|
+
* redeploy that changed this string; to replace a bad prompt already in
|
|
154
|
+
* flight, end that run and start a new one rather than resuming it.
|
|
155
|
+
*/
|
|
156
|
+
readonly instructions: string;
|
|
157
|
+
/**
|
|
158
|
+
* Stops a run that keeps going: the maximum number of model round-trips it
|
|
159
|
+
* may take. Once the completed-turn count reaches it the run fails rather
|
|
160
|
+
* than calling the model again. Omit → no limit on turns.
|
|
161
|
+
*/
|
|
162
|
+
readonly maxTurns?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Stops a run that stops progressing: milliseconds the run may sit without
|
|
165
|
+
* advancing before it fails. The budget is a no-progress watchdog, not a
|
|
166
|
+
* total wall-clock cap — it restarts each time the run moves. Omit → no
|
|
167
|
+
* watchdog.
|
|
168
|
+
*/
|
|
169
|
+
readonly deadlineMs?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Stops a run that keeps going, by the clock: total milliseconds from the
|
|
172
|
+
* run's start it may take before it fails. This is the total wall-clock cap
|
|
173
|
+
* `deadlineMs` is not — the budget never restarts, so a run that keeps
|
|
174
|
+
* progressing is bounded by it where `deadlineMs` would let it run forever,
|
|
175
|
+
* and it counts elapsed time where `maxTurns` counts round-trips. It is read
|
|
176
|
+
* at the turn boundary, so like both of those it stops the run rather than
|
|
177
|
+
* cancelling the work already in flight. Omit → no wall-clock cap.
|
|
178
|
+
*
|
|
179
|
+
* The run's start time is on the durable Model, so a run killed and resumed
|
|
180
|
+
* continues the ORIGINAL budget — the time it spent dead counts against it.
|
|
181
|
+
*
|
|
182
|
+
* The same name on a `DurationRetryPolicy` (`retry`, and a tool's own) is the
|
|
183
|
+
* same idea one altitude down: that one bounds how long ONE call's retry
|
|
184
|
+
* ladder may keep climbing, this one how long the whole run may take.
|
|
185
|
+
*/
|
|
186
|
+
readonly maxElapsedMs?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Stops a run on a condition only you can see: a predicate consulted at the
|
|
189
|
+
* turn boundary, after the other three guards have passed, over the run's
|
|
190
|
+
* durable Model. Answer `true` and the run ends there — settled `cancelled`,
|
|
191
|
+
* the same terminal an aborted `signal` reaches, with the transcript intact
|
|
192
|
+
* and no further model call made. Where `maxTurns` and `maxElapsedMs` bound
|
|
193
|
+
* a quantity the agent counts for you and `deadlineMs` watches for a stall,
|
|
194
|
+
* this bounds whatever you name — a token ledger you keep, an external flag,
|
|
195
|
+
* a condition on the turns so far. Omit → no predicate.
|
|
196
|
+
*
|
|
197
|
+
* It must be PURE: the reducer calls it, so a replay hands it the same state
|
|
198
|
+
* and must get the same answer. And it is config rather than Model — a
|
|
199
|
+
* resumed run consults the predicate the config passed to THIS boot, exactly
|
|
200
|
+
* as it uses the `maxTurns` passed to this boot.
|
|
201
|
+
*/
|
|
202
|
+
readonly stopWhen?: (state: DefinedAgentState<T>) => boolean;
|
|
203
|
+
/**
|
|
204
|
+
* The backoff ladder a FAILED BRAIN CALL climbs — the same `RetryPolicy`
|
|
205
|
+
* shape `AgentConfigCore.retry` takes, threaded straight to it, so the ladder
|
|
206
|
+
* runs in the resilient slice that already exists and lives on the Model:
|
|
207
|
+
* each failure is recorded there and the next attempt is armed as a timer
|
|
208
|
+
* Sub, which is what makes the wait durable and the attempt count survive a
|
|
209
|
+
* reload.
|
|
210
|
+
*
|
|
211
|
+
* The per-tool knob grows no lid option because a `tool()` is a spec object
|
|
212
|
+
* that declares its own policy (`ToolResilience.retry`). A
|
|
213
|
+
* `defineAgent` `model` is a bare function with no spec object, so the lid is
|
|
214
|
+
* the only declaration site a brain-call policy has.
|
|
215
|
+
*
|
|
216
|
+
* Omit → NO backoff, exactly as before: one throw from `model` ends the run
|
|
217
|
+
* after a single attempt. Nothing is defaulted on your behalf — a silent
|
|
218
|
+
* default would change the failure timing of every existing caller.
|
|
219
|
+
*/
|
|
220
|
+
readonly retry?: RetryPolicy;
|
|
221
|
+
/**
|
|
222
|
+
* Observe a tool call that failed, typed against THIS agent's tools: the
|
|
223
|
+
* outcome is `{ kind: "error", _tag, …payload, reason }` over
|
|
224
|
+
* `ToolError`'s union — declared tags, `thrown`, `malformed_result`,
|
|
225
|
+
* `unknown_tool`, `malformed_args` — so a `switch` on `_tag` is exhaustive and an
|
|
226
|
+
* unhandled failure mode is a compile error rather than a silent turn (#115).
|
|
227
|
+
* The model still reads `reason` next turn either way — this is the host's
|
|
228
|
+
* channel beside it, never instead of it.
|
|
229
|
+
*
|
|
230
|
+
* Called ONCE per failed call, at the interpret boundary: after the handler
|
|
231
|
+
* settled, before the failure is folded into the conversation. It is awaited,
|
|
232
|
+
* so an async hook holds the settle until it resolves — keep it short, and put
|
|
233
|
+
* anything slow on your own queue.
|
|
234
|
+
*
|
|
235
|
+
* A resume calls it for the calls THIS process runs and no others: an outcome
|
|
236
|
+
* a previous process already folded is in the Model the Store handed back and
|
|
237
|
+
* is never re-interpreted, so a durable run does not re-fire the hook over its
|
|
238
|
+
* history.
|
|
239
|
+
*
|
|
240
|
+
* The hook is CONTAINED, exactly as `onEvent` is: a throw (or a rejected
|
|
241
|
+
* promise) is warned about and the run goes on, so `run`'s contract does not
|
|
242
|
+
* depend on the hook's.
|
|
243
|
+
*
|
|
244
|
+
* Omit → the router is wired unwrapped and nothing observes failures.
|
|
245
|
+
*/
|
|
246
|
+
readonly onToolError?: (outcome: ToolFailureOf<T>, ctx: ToolErrorContext) => void | Promise<void>;
|
|
247
|
+
/**
|
|
248
|
+
* Bounds a run that keeps going without ever failing: the transcript budget,
|
|
249
|
+
* past which the OLDEST turns are folded into one model-written summary
|
|
250
|
+
* before the next brain call, so a long run's prompt stops growing instead of
|
|
251
|
+
* climbing until the provider rejects it.
|
|
252
|
+
*
|
|
253
|
+
* The knob is a THRESHOLD, not a policy function — see
|
|
254
|
+
* {@link DefineAgentCompaction}. `compaction` is what a run tolerates, and the
|
|
255
|
+
* summarize round-trip that enforces it is wiring, so the lid takes the
|
|
256
|
+
* former and supplies the latter from the `model` it already has.
|
|
257
|
+
*
|
|
258
|
+
* Omit → NO compaction, exactly as before: the transcript grows for as long
|
|
259
|
+
* as the model keeps asking for tools. Nothing is defaulted on your behalf —
|
|
260
|
+
* a silent budget would change the prompt every existing caller sends.
|
|
261
|
+
*/
|
|
262
|
+
readonly compaction?: DefineAgentCompaction;
|
|
263
|
+
/**
|
|
264
|
+
* How many of ONE turn's tool calls a transition launches at once. At the
|
|
265
|
+
* default `1` a turn's calls go out one at a time, each waiting for the last
|
|
266
|
+
* to settle; raise it and up to that many are launched together, so they are
|
|
267
|
+
* all in flight in the fan-out ledger rather than queued behind each other.
|
|
268
|
+
* A turn asking for more calls than this runs them in waves.
|
|
269
|
+
*
|
|
270
|
+
* Launched together means overlapping on the clock: a turn of two slow tools
|
|
271
|
+
* costs the slower of them, not their sum. The overlap lives inside the tool
|
|
272
|
+
* Cmds' own handlers and NOT in the kernel — `runInterpret` still interprets
|
|
273
|
+
* a transition's Cmds one after another and never interleaves two handlers,
|
|
274
|
+
* which is ADR 0018's ruling and the reason a replay is unaffected. Settle
|
|
275
|
+
* Msgs fold in Cmd-EMISSION order whichever call finishes first, so raising
|
|
276
|
+
* the knob changes the turn's latency and nothing about its Model.
|
|
277
|
+
*
|
|
278
|
+
* Omit (or `1`) → serial dispatch, exactly as before.
|
|
279
|
+
*/
|
|
280
|
+
readonly toolConcurrency?: number;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The lid's compaction budget: the two numbers that say when a transcript is
|
|
284
|
+
* too long and how much of it survives the fold. Both are plain counts, so the
|
|
285
|
+
* trigger they build is PURE — a replay re-decides identically, and no clock or
|
|
286
|
+
* token estimate enters the Model (ADR 0004).
|
|
287
|
+
*
|
|
288
|
+
* This is deliberately a threshold rather than the core's `planCompaction`
|
|
289
|
+
* function: a policy function is a second place a lid agent would have to learn
|
|
290
|
+
* the conversation shape, and the lid hides wiring, never state (ADR 0015). A
|
|
291
|
+
* run that needs its own heuristic descends to `createAgent`, whose
|
|
292
|
+
* `CompactionPolicy` this is built from.
|
|
293
|
+
*/
|
|
294
|
+
interface DefineAgentCompaction {
|
|
295
|
+
/**
|
|
296
|
+
* Fold once the conversation holds at least this many turns, counted BEFORE
|
|
297
|
+
* the brain call about to fire. Must be at least `1`.
|
|
298
|
+
*/
|
|
299
|
+
readonly afterTurns: number;
|
|
300
|
+
/**
|
|
301
|
+
* How many of the NEWEST turns survive the fold intact, beside the summary.
|
|
302
|
+
* Everything older becomes the summary's one synthetic head turn. Omit → `0`:
|
|
303
|
+
* the whole transcript folds into the summary.
|
|
304
|
+
*
|
|
305
|
+
* A fold worth fewer than two turns is skipped by the agent itself — one turn
|
|
306
|
+
* replaced by one summary shrinks nothing — so `keepTurns` within one of
|
|
307
|
+
* `afterTurns` is a policy that never fires.
|
|
308
|
+
*/
|
|
309
|
+
readonly keepTurns?: number;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Which call an `onToolError` failure belongs to: the model's `callId` — the
|
|
313
|
+
* fan-out identity the outcome folds back on — and the tool `name` the model
|
|
314
|
+
* asked for, which for an `unknown_tool` is the name it invented rather than
|
|
315
|
+
* any declared tool.
|
|
316
|
+
*/
|
|
317
|
+
interface ToolErrorContext {
|
|
318
|
+
readonly callId: string;
|
|
319
|
+
readonly name: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* One lifecycle event a defined agent's run emits — {@link AgentEvent} with the
|
|
323
|
+
* tool results typed against this agent's own tool set.
|
|
324
|
+
*/
|
|
325
|
+
type DefinedAgentEvent<T extends AnyToolDef> = AgentEvent<ToolResult<T>>;
|
|
326
|
+
/**
|
|
327
|
+
* Host wiring for one `run`: the store, the ctx the tools need, a runId, a clock.
|
|
328
|
+
*
|
|
329
|
+
* `ctx` is `ScopedCtxArg`, the same widening `run` itself takes: an agent's tools
|
|
330
|
+
* are exactly the handlers a scoped resource is for, so a `provide({ … })` graph
|
|
331
|
+
* is accepted here in place of the object and gets the same acquire-at-boot /
|
|
332
|
+
* release-at-terminal lifetime.
|
|
333
|
+
*/
|
|
334
|
+
type DefinedAgentRunOptions<T extends AnyToolDef> = ScopedCtxArg<DefinedAgentCtx<T>> & {
|
|
335
|
+
readonly store?: Store<DefinedAgentState<T>>;
|
|
336
|
+
/** The run's identity. Omit → a fresh UUID. */
|
|
337
|
+
readonly runId?: string;
|
|
338
|
+
/** The clock that stamps `at`. Omit → `Date.now`. */
|
|
339
|
+
readonly clock?: () => number;
|
|
340
|
+
/**
|
|
341
|
+
* Observe the run's turn-level lifecycle events — `TurnSettled`,
|
|
342
|
+
* `ToolSettled`, `RunDone` — in the order the kernel settles them. This is
|
|
343
|
+
* the progress seam: without it the only way to see anything mid-run is
|
|
344
|
+
* `machine(input)` plus the raw kernel loop.
|
|
345
|
+
*
|
|
346
|
+
* It forwards the runtime's existing semantic stream (`agentEvents()` /
|
|
347
|
+
* `runtime.on`); it mints no vocabulary of its own, so a consumer folds the
|
|
348
|
+
* same {@link AgentEvent}s a hand-wired `run` would.
|
|
349
|
+
*
|
|
350
|
+
* The listener is CONTAINED: a throw is caught and warned, never allowed to
|
|
351
|
+
* take the run down, and never observable in `run`'s resolution. Only
|
|
352
|
+
* transitions applied by THIS process project events, so a store-backed
|
|
353
|
+
* resume replays nothing that settled before the boot.
|
|
354
|
+
*
|
|
355
|
+
* Omit → no projector is wired and the run behaves exactly as before.
|
|
356
|
+
*/
|
|
357
|
+
readonly onEvent?: (event: DefinedAgentEvent<T>) => void;
|
|
358
|
+
/**
|
|
359
|
+
* Observe the token deltas of the turn being produced right now — the
|
|
360
|
+
* granularity below `onEvent`'s. Wired only when the configured `model` is
|
|
361
|
+
* the streaming shape (`async (messages, { onChunk }) => turn`); a plain
|
|
362
|
+
* model has no deltas to give, so passing this beside one is silent.
|
|
363
|
+
*
|
|
364
|
+
* Chunks ride a SIDE CHANNEL, never state. They are not projected off
|
|
365
|
+
* transitions like an {@link AgentEvent} is, because nothing about a chunk is
|
|
366
|
+
* a transition: it is never journaled, never written to the `Store`, and
|
|
367
|
+
* never folded into the Model. That is the whole rule this option obeys — a
|
|
368
|
+
* delta that has not settled is not an outcome, so a run that dies mid-turn
|
|
369
|
+
* loses its chunks and resumes from the last SETTLED turn, and a resumed run
|
|
370
|
+
* re-emits nothing it did not itself re-produce.
|
|
371
|
+
*
|
|
372
|
+
* The listener is CONTAINED exactly as `onEvent`'s is: a throw is caught and
|
|
373
|
+
* warned, never allowed to fail the model call it fired from.
|
|
374
|
+
*
|
|
375
|
+
* Omit → the streaming model is still invoked in its streaming shape, with a
|
|
376
|
+
* sink that drops every chunk.
|
|
377
|
+
*/
|
|
378
|
+
readonly onChunk?: (chunk: TurnChunk) => void;
|
|
379
|
+
/**
|
|
380
|
+
* Stop the run from outside — the stop button's seam. On abort the run settles
|
|
381
|
+
* on a CANCELLED terminal Model and `run` RESOLVES with it; it does not reject,
|
|
382
|
+
* and no `DriveFailedError` is thrown. Read the outcome with `status(state)`,
|
|
383
|
+
* which answers `{ kind: "cancelled", at }` — distinct from `failed`, because a
|
|
384
|
+
* run someone stopped did not fail.
|
|
385
|
+
*
|
|
386
|
+
* The outcome is durable, so it is also the answer on the next boot: a process
|
|
387
|
+
* killed after an abort resumes reading a run that ENDED, not one to restart.
|
|
388
|
+
* A signal already aborted when `run` is called ends it before the first model
|
|
389
|
+
* call is made.
|
|
390
|
+
*
|
|
391
|
+
* It stops DISPATCH, not the work already in flight — a promise cannot be
|
|
392
|
+
* cancelled, so a tool handler mid-call runs to its own end. Those late results
|
|
393
|
+
* reach no `onEvent`, no `onToolError` and no Model, and they do not hold the
|
|
394
|
+
* runtime's teardown. Propagating the signal INTO handlers is a separate seam
|
|
395
|
+
* this option does not open.
|
|
396
|
+
*
|
|
397
|
+
* Omit → the run has no stop button and every path behaves exactly as before.
|
|
398
|
+
*/
|
|
399
|
+
readonly signal?: AbortSignal;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* One decorator per interpret cell you name: it receives the cell the agent
|
|
403
|
+
* wired (`next`) and returns the cell that runs in its place. Every key is
|
|
404
|
+
* optional and a cell nobody names is passed through by REFERENCE, so an
|
|
405
|
+
* overlay that wraps one tool leaves the others the exact functions
|
|
406
|
+
* `defineAgent` built.
|
|
407
|
+
*
|
|
408
|
+
* The wrapper's signature is the cell's, so calling `next(cmd, ctx, dispatch)`
|
|
409
|
+
* is how the wrapped work happens — that is the typed Cmd→Msg edge
|
|
410
|
+
* (`Cmd.define`'s `_ok` / `_err` Msgs), and returning its Msg is what keeps the
|
|
411
|
+
* fold, and therefore a replay, identical to the unwrapped run's.
|
|
412
|
+
*/
|
|
413
|
+
type InterpretOverlay<T extends AnyToolDef> = CellWrappers<DefinedAgentInterpret<T>>;
|
|
414
|
+
/**
|
|
415
|
+
* The decorator table over an interpret table `I`. Written over a bare type
|
|
416
|
+
* parameter because `I[K]` is only indexable when `I` is one: applying the
|
|
417
|
+
* mapped type to `DefinedAgentInterpret<T>` inline leaves TypeScript indexing
|
|
418
|
+
* an unreduced generic mapped type, which it refuses.
|
|
419
|
+
*/
|
|
420
|
+
type CellWrappers<I> = {
|
|
421
|
+
readonly [K in keyof I]?: (next: I[K]) => I[K];
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* What `defineAgent(cfg).with(...)` takes — the one documented wrap point over
|
|
425
|
+
* the machine the lid built.
|
|
426
|
+
*/
|
|
427
|
+
interface DefinedAgentOverlay<T extends AnyToolDef> {
|
|
428
|
+
readonly interpret: InterpretOverlay<T>;
|
|
429
|
+
}
|
|
430
|
+
/** What `defineAgent` returns. */
|
|
431
|
+
interface DefinedAgent<T extends AnyToolDef> {
|
|
432
|
+
/**
|
|
433
|
+
* Run `input` to its terminal Model. Resolves on `run.phase: "done"`; a
|
|
434
|
+
* failed run rejects with `DriveFailedError` carrying the failed Model.
|
|
435
|
+
*
|
|
436
|
+
* With a `store`, the same call is also the resume: a Model the Store hands
|
|
437
|
+
* back mid-run is booted (`agent_boot`) at its one outstanding effect —
|
|
438
|
+
* same `runId`, no tool re-run — and one already `done` resolves as it is.
|
|
439
|
+
* A fresh start needs an empty Store.
|
|
440
|
+
*
|
|
441
|
+
* It resolves with {@link DefinedAgentResolvedState} — the Model whose `run`
|
|
442
|
+
* slice is narrowed to the ENDED phases, so `(await agent.run(i)).run.runId`
|
|
443
|
+
* reads without a guard against an `idle` arm this promise cannot produce.
|
|
444
|
+
*/
|
|
445
|
+
readonly run: (input: string, ...opts: [Record<never, never>] extends [DefinedAgentCtx<T>] ? [opts?: DefinedAgentRunOptions<T>] : [opts: DefinedAgentRunOptions<T>]) => Promise<DefinedAgentResolvedState<T>>;
|
|
446
|
+
/** The machine `run` drives for `input` — the door down to the raw kernel. */
|
|
447
|
+
readonly machine: (input: string) => DefinedAgentMachine<T>;
|
|
448
|
+
/**
|
|
449
|
+
* The ramp between the lid and `createAgent`: wrap ONE interpret cell of the
|
|
450
|
+
* machine this agent builds and get back a NEW defined agent that runs the
|
|
451
|
+
* wrapped table. The agent it is called on is untouched, and so is every cell
|
|
452
|
+
* the overlay does not name.
|
|
453
|
+
*
|
|
454
|
+
* const traced = agent.with({
|
|
455
|
+
* interpret: {
|
|
456
|
+
* fetch_rate: (next) => async (cmd, ctx, dispatch) => {
|
|
457
|
+
* console.time(cmd.callId);
|
|
458
|
+
* try { return await next(cmd, ctx, dispatch); }
|
|
459
|
+
* finally { console.timeEnd(cmd.callId); }
|
|
460
|
+
* },
|
|
461
|
+
* },
|
|
462
|
+
* });
|
|
463
|
+
*
|
|
464
|
+
* The wrapped cell settles through the SAME typed Cmd→Msg edge as the cell it
|
|
465
|
+
* wraps — it returns whatever `next` returned — so the reducer folds the same
|
|
466
|
+
* Msgs and a replay of a wrapped run is the unwrapped run's replay. That is
|
|
467
|
+
* the whole contract: the door is one over the effect boundary, never over
|
|
468
|
+
* the fold. A cell that must settle DIFFERENTLY is a different machine, and
|
|
469
|
+
* `createAgent` is still where you build one.
|
|
470
|
+
*
|
|
471
|
+
* `with` composes — `agent.with(a).with(b)` puts `b`'s wrapper OUTSIDE `a`'s,
|
|
472
|
+
* so `b` is entered first and `a`'s cell is what its `next` calls. Naming a
|
|
473
|
+
* cell the machine has none of throws at `machine(input)`, where the table it
|
|
474
|
+
* is checked against exists.
|
|
475
|
+
*/
|
|
476
|
+
readonly with: (overlay: DefinedAgentOverlay<T>) => DefinedAgent<T>;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Define an agent from a model, the tools it may call and its instructions, and
|
|
480
|
+
* get back `run(input)` — a promise of the finished state — plus `machine(input)`
|
|
481
|
+
* for driving the same run yourself, which is the entry point a newcomer picks,
|
|
482
|
+
* `createAgent` being the layer underneath that you drop to only to walk a stage
|
|
483
|
+
* pipeline of your own.
|
|
484
|
+
*
|
|
485
|
+
* Add `maxTurns`, `deadlineMs`, `maxElapsedMs` or `stopWhen` to bound the run;
|
|
486
|
+
* all four are described on `DefineAgentConfig`. The run's `input` is its single stage, so it is durable
|
|
487
|
+
* beside `instructions`, and the prompt is rendered from those two and the
|
|
488
|
+
* conversation on every model call.
|
|
489
|
+
*
|
|
490
|
+
* One unusual requirement does not cost you the lid: `.with({ interpret })`
|
|
491
|
+
* wraps one interpret cell of the machine this built and hands back another
|
|
492
|
+
* defined agent, so `createAgent` is for a rebuild rather than for a detour.
|
|
493
|
+
*/
|
|
494
|
+
declare function defineAgent<T extends AnyToolDef>(config: DefineAgentConfig<T>): DefinedAgent<T>;
|
|
495
|
+
/** The prompt as messages: the head, then each turn with its tool outcomes. PURE. */
|
|
496
|
+
declare function renderPrompt(prompt: AgentPrompt<unknown>): AgentMessage[];
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @packageDocumentation
|
|
500
|
+
* The transcript collector — the built-in way to KEEP a run's turns, given that
|
|
501
|
+
* a finished run's Model does not.
|
|
502
|
+
*
|
|
503
|
+
* A run that reaches `phase: "done"` clears `conversation` to `null` on
|
|
504
|
+
* purpose: the terminating turn is stamped onto `output` first, so the answer
|
|
505
|
+
* survives, and the history that would otherwise grow without bound in storage
|
|
506
|
+
* kept for its state is dropped (`docs/explanation/durability-model.md`). That
|
|
507
|
+
* policy is not what this module changes. What it changes is that every
|
|
508
|
+
* consumer wanting the history had to hand-write the same fold over `onEvent`.
|
|
509
|
+
*
|
|
510
|
+
* So this is a COLLECTOR over the event stream that already exists, not a knob
|
|
511
|
+
* on the Model. Nothing here is durable, nothing here is written to a `Store`,
|
|
512
|
+
* and a run with a collector attached is byte for byte the run it was without
|
|
513
|
+
* one — the same reason `onChunk` rides a side channel rather than state.
|
|
514
|
+
*
|
|
515
|
+
* const t = transcript<ToolResult<typeof tools>>();
|
|
516
|
+
* const final = await agent.run(input, { store, onEvent: t.onEvent });
|
|
517
|
+
* t.read().turns; // every turn this process settled
|
|
518
|
+
*
|
|
519
|
+
* ## What a resume needs from you
|
|
520
|
+
*
|
|
521
|
+
* Events are projected off the transitions THIS process applies, so a run
|
|
522
|
+
* resumed from a `Store` re-emits nothing the killed process already settled.
|
|
523
|
+
* A collector that only ever listened would therefore hold the tail of a
|
|
524
|
+
* resumed run and call it the whole thing. Hence the seed: hand
|
|
525
|
+
* {@link transcript} the Model the `Store` handed back and it starts from that
|
|
526
|
+
* Model's live conversation, so the resumed collector reads as the whole run
|
|
527
|
+
* rather than its last leg.
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* One tool call the run settled OK, as the transcript keeps it — the `callId`
|
|
532
|
+
* and the result, which is exactly what the `ToolSettled` event carries.
|
|
533
|
+
*
|
|
534
|
+
* A tool that FAILED is absent, and that is the event stream's shape rather
|
|
535
|
+
* than a choice made here: `ToolSettled` is projected off the OK settle alone.
|
|
536
|
+
* Branch on failures through `onToolError`, whose argument is typed per tag.
|
|
537
|
+
*/
|
|
538
|
+
interface TranscriptToolResult<R> {
|
|
539
|
+
readonly callId: string;
|
|
540
|
+
readonly result: R;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Whether the run has finished, and its terminal turn once it has.
|
|
544
|
+
*
|
|
545
|
+
* The two cases are a union rather than a nullable `output` field because
|
|
546
|
+
* `output` is legitimately `null` on a finished run — a `RunDone` with no
|
|
547
|
+
* terminating turn — and a single field would make "not finished yet" and
|
|
548
|
+
* "finished with nothing" the same reading.
|
|
549
|
+
*/
|
|
550
|
+
type TranscriptOutcome = {
|
|
551
|
+
readonly kind: "running";
|
|
552
|
+
} | {
|
|
553
|
+
readonly kind: "done";
|
|
554
|
+
readonly output: AgentTurn | null;
|
|
555
|
+
};
|
|
556
|
+
/** What a collector holds right now — a plain, immutable read. */
|
|
557
|
+
interface TranscriptSnapshot<R> {
|
|
558
|
+
/** Every model turn the transcript holds, in order. */
|
|
559
|
+
readonly turns: readonly AgentTurn[];
|
|
560
|
+
/** Every tool call that settled OK, in settle order. */
|
|
561
|
+
readonly tools: readonly TranscriptToolResult<R>[];
|
|
562
|
+
/** Whether `RunDone` has been seen, and the terminal turn if so. */
|
|
563
|
+
readonly outcome: TranscriptOutcome;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* The Model a resumed collector starts from — structural on purpose, so any
|
|
567
|
+
* agent state (`DefinedAgentState<T>`, `AgentState<…>`) satisfies it without
|
|
568
|
+
* this module importing the lid, and a bare `{ conversation }` object works in
|
|
569
|
+
* a test.
|
|
570
|
+
*/
|
|
571
|
+
interface TranscriptSeed<R> {
|
|
572
|
+
readonly conversation: Conversation<R> | null;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* A live transcript: the listener you wire, and the read you take off it.
|
|
576
|
+
*
|
|
577
|
+
* `onEvent` is a bound function, so `{ onEvent: t.onEvent }` is the whole
|
|
578
|
+
* wiring — there is no `this` to lose.
|
|
579
|
+
*/
|
|
580
|
+
interface Transcript<R> {
|
|
581
|
+
/** Wire this to `run`'s `onEvent`. */
|
|
582
|
+
readonly onEvent: (event: AgentEvent<R>) => void;
|
|
583
|
+
/** The transcript as of now. Each call returns a fresh immutable snapshot. */
|
|
584
|
+
readonly read: () => TranscriptSnapshot<R>;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Open a transcript collector over an agent run's event stream.
|
|
588
|
+
*
|
|
589
|
+
* Wire `onEvent` to `run`'s `onEvent` option and `read()` gives you the turns
|
|
590
|
+
* and settled tool results afterwards — the transcript the finished Model no
|
|
591
|
+
* longer carries.
|
|
592
|
+
*
|
|
593
|
+
* Pass `seed` when the run is a RESUME: the Model the `Store` handed back still
|
|
594
|
+
* holds the live conversation the killed process built, and seeding from it is
|
|
595
|
+
* what makes the collector hold the whole run rather than the leg this process
|
|
596
|
+
* ran. One collector per process is the honest unit; a fresh run needs no seed.
|
|
597
|
+
*
|
|
598
|
+
* A seed taken from an already-finished Model contributes nothing, and
|
|
599
|
+
* correctly so: that Model's `conversation` is `null` and its answer is its
|
|
600
|
+
* `output`, which you already hold.
|
|
601
|
+
*/
|
|
602
|
+
declare function transcript<R>(seed?: TranscriptSeed<R>): Transcript<R>;
|
|
20
603
|
|
|
21
604
|
/**
|
|
22
605
|
* @packageDocumentation
|
|
@@ -25,16 +608,15 @@ import '../snapshot/index.js';
|
|
|
25
608
|
* drives the classic loop `llm → tools → fold → llm` until the model stops
|
|
26
609
|
* asking for tools.
|
|
27
610
|
*
|
|
28
|
-
* This
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* and the model. `createAgent(config)` returns the uniform knob contract every
|
|
611
|
+
* This generalizes a production audit agent: the domain specifics are stripped,
|
|
612
|
+
* and what remains — the loop, the durability, the boot-reconcile crash
|
|
613
|
+
* recovery, the serial-vs-fanned tool dispatch — is yours. The consumer
|
|
614
|
+
* supplies the only things that are genuinely domain: the tools, the prompts
|
|
615
|
+
* (via the llm-call message loader), the schemas, and the model. `createAgent(config)` returns the uniform handle contract every
|
|
34
616
|
* composition exposes (`init` / verbs returning `readonly [State, Cmd[]]` /
|
|
35
617
|
* `subs`) AND a ready-to-`run` `defineMachine` (`toMachine`) — THE one wired
|
|
36
618
|
* path. (`unsafeDetachedHandlers` is the hand-wiring escape hatch; its name
|
|
37
|
-
* advertises that it does not drive the retry loop
|
|
619
|
+
* advertises that it does not drive the retry loop.)
|
|
38
620
|
*
|
|
39
621
|
* ## The composition (three siblings wired into ONE machine)
|
|
40
622
|
*
|
|
@@ -43,18 +625,21 @@ import '../snapshot/index.js';
|
|
|
43
625
|
* position survives eviction, the no-progress deadline auto-fails a wedged
|
|
44
626
|
* run, and `boot` resumes mid-pipeline. The agent slice OWNS this slice and
|
|
45
627
|
* delegates `start` / `advance` / `progress` / `onDeadline` / `boot` to it.
|
|
46
|
-
* - `../llm-call` — every brain call
|
|
628
|
+
* - `../llm-call` — every brain call. One
|
|
47
629
|
* `LlmCall` per turn, structured-output parsed, retry composed in. The agent
|
|
48
630
|
* delegates the resilient slice + verbs and reuses the detached handler.
|
|
49
|
-
* - `../fan-out` — the tool calls a turn produced.
|
|
50
|
-
*
|
|
51
|
-
* `config.toolConcurrency
|
|
631
|
+
* - `../fan-out` — the tool calls a turn produced. Tools dispatch SERIALLY by
|
|
632
|
+
* default (concurrency 1); fan-out generalizes that to a bounded number
|
|
633
|
+
* LAUNCHED per transition, `config.toolConcurrency`. Above `1` a router's
|
|
634
|
+
* tool cells overlap on the clock while `runInterpret` stays serial — the
|
|
635
|
+
* fan-out is inside the Cmd handler, and its settles fold in emission
|
|
636
|
+
* order (ADR 0018). Each
|
|
52
637
|
* tool is an `of(call)` Cmd the consumer's own interpret performs; results
|
|
53
638
|
* route back through `toolOk` / `toolErr`. When the batch drains, the agent
|
|
54
639
|
* folds the gathered results back into the conversation and fires the next
|
|
55
640
|
* brain call (`fold → llm`).
|
|
56
641
|
*
|
|
57
|
-
* ## The flow loop, as TEA
|
|
642
|
+
* ## The flow loop, as TEA
|
|
58
643
|
*
|
|
59
644
|
* 1. `start` enters the pipeline; the consumer wires the per-stage outstanding
|
|
60
645
|
* effect (often a `call_llm` for the agentic stage) off the current stage.
|
|
@@ -68,10 +653,12 @@ import '../snapshot/index.js';
|
|
|
68
653
|
* queued tool. When the batch drains, fold the gathered outcomes into the
|
|
69
654
|
* conversation, bump the turn count (livelock guard), and fire the next
|
|
70
655
|
* brain call — `awaiting` flips back to `llm`.
|
|
71
|
-
* 4. The watchdog
|
|
72
|
-
*
|
|
656
|
+
* 4. The watchdog bounds a stall and the turn boundary's own stop conditions
|
|
657
|
+
* bound the loop: the deadline fires `failed`, the turn limit fires
|
|
658
|
+
* `failed { turn_limit }`, the wall-clock cap `failed { elapsed_limit }`,
|
|
659
|
+
* and the consumer's `stopWhen` settles the run `cancelled`.
|
|
73
660
|
*
|
|
74
|
-
* ## Boot reconcile (crash recovery
|
|
661
|
+
* ## Boot reconcile (crash recovery)
|
|
75
662
|
*
|
|
76
663
|
* Cold wake re-derives the ONE outstanding effect from `phase × awaiting`: a
|
|
77
664
|
* brain call in flight re-fires `call_llm`; tools in flight re-fire the in-flight
|
|
@@ -98,11 +685,13 @@ import '../snapshot/index.js';
|
|
|
98
685
|
* type RunTool = { readonly type: "run_tool" } & ToolCall;
|
|
99
686
|
* const agent = createAgent<Stage, Purpose, Outputs, Result, RunTool, Msg>({
|
|
100
687
|
* stages: ["plan", "act", "report"],
|
|
101
|
-
*
|
|
688
|
+
* // The brain: a plain `async (messages) => turn` (the common path), or the
|
|
689
|
+
* // `(id) => Llm` factory when the model binds the schema itself.
|
|
690
|
+
* model: async (messages) => client.chat(messages),
|
|
102
691
|
* schemas: { plan: planSchema, act: turnSchema, report: reportSchema },
|
|
103
692
|
* turnOf: (stage) => stageToPurpose[stage], // which brain call a stage runs
|
|
104
693
|
* toolOf: (call): RunTool => ({ type: "run_tool", ...call }),
|
|
105
|
-
* toolConcurrency: 1, //
|
|
694
|
+
* toolConcurrency: 1, // launched per transition
|
|
106
695
|
* deadlineMs: 10 * 60_000,
|
|
107
696
|
* maxTurns: 60,
|
|
108
697
|
* retry: defaultRetryPolicy,
|
|
@@ -115,21 +704,24 @@ import '../snapshot/index.js';
|
|
|
115
704
|
*/
|
|
116
705
|
|
|
117
706
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* to
|
|
707
|
+
* Assemble an agent from `config` — the model, the stages it walks, and how a
|
|
708
|
+
* tool call is turned into a command — and get back its `init`, verbs and `subs`
|
|
709
|
+
* plus a `toMachine()` that wires all of it into one machine you hand to `run`,
|
|
710
|
+
* which is the layer to reach for only once `defineAgent` cannot express the run
|
|
711
|
+
* you want — a newcomer starts there, not here.
|
|
122
712
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* `
|
|
713
|
+
* Pass `snapshotEvery` to have the run persist itself every N steps, and
|
|
714
|
+
* `compaction` to have long conversations summarized as they grow; each one you
|
|
715
|
+
* pass obliges you to supply the matching handler at `toMachine`, and each one
|
|
716
|
+
* you omit forbids it. `rng` is the determinism seam for the retry backoff —
|
|
717
|
+
* pass a fixed `() => 0` to pin it in tests; omit for `Math.random`.
|
|
718
|
+
* `unsafeDetachedHandlers` is the hand-wiring escape hatch.
|
|
126
719
|
*
|
|
127
|
-
*
|
|
128
|
-
* (#55) and the compaction (#85) one — so each `toMachine` obligation is derived
|
|
720
|
+
* The four overloads exist because the two obligations are derived
|
|
129
721
|
* from the `config` VALUE, never inferred. `{ snapshotEvery: number }` REQUIRES
|
|
130
722
|
* the `snapshot_write` cell, `{ snapshotEvery?: never }` FORBIDS it; `{ compaction:
|
|
131
723
|
* policy }` REQUIRES the `compact_run` cell, `{ compaction?: never }` FORBIDS it.
|
|
132
|
-
*
|
|
724
|
+
* They enumerate the snapshot × compaction grid: overload resolution
|
|
133
725
|
* reads the two fields off `config`, so the right `Snap`/`Compact` pair is fixed
|
|
134
726
|
* even when the call site passes explicit type arguments (TS does not infer
|
|
135
727
|
* trailing type params — a `Cfg`-inference scheme would silently fall back to OFF
|
|
@@ -152,4 +744,4 @@ declare function createAgent<Stage, P extends string, O extends Record<P, AgentT
|
|
|
152
744
|
readonly compaction?: never;
|
|
153
745
|
}): AgentKnob<Stage, P, O, R, TC, false, false>;
|
|
154
746
|
|
|
155
|
-
export { AgentConfigCore, AgentKnob, AgentTurn, CompactionPolicy, createAgent };
|
|
747
|
+
export { AgentCmd, AgentConfigCore, AgentEvent, AgentKnob, AgentMachineMsg, type AgentMessage, type AgentPrompt, AgentState, AgentTurn, AnyToolDef, CompactionPolicy, Conversation, DeadlineSub, type DefineAgentCompaction, type DefineAgentConfig, type DefinedAgent, type DefinedAgentCmd, type DefinedAgentCtx, type DefinedAgentEvent, type DefinedAgentInterpret, type DefinedAgentMachine, type DefinedAgentModel, type DefinedAgentMsg, type DefinedAgentOverlay, type DefinedAgentResolvedState, type DefinedAgentRunOptions, type DefinedAgentState, EndedRun, type InterpretOverlay, type LidPurpose, PlainModel, StreamingModel, ToolCall, ToolCmd, type ToolErrorContext, ToolFailureOf, ToolOutcome, ToolResult, type Transcript, type TranscriptOutcome, type TranscriptSeed, type TranscriptSnapshot, type TranscriptToolResult, TurnChunk, WiredToolMsg, createAgent, defineAgent, renderPrompt, transcript };
|