@sixb/core 0.1.8 → 0.1.10
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/dist/actions/index.js +77 -89
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/run-dispatch.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +2 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/validation.d.ts +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/actions/worker.js +33 -37
- package/dist/actions/worker.js.map +2 -2
- package/dist/agents/adapters.d.ts +3 -3
- package/dist/agents/{context.d.ts → context/entries.d.ts} +3 -3
- package/dist/agents/context/entries.d.ts.map +1 -0
- package/dist/agents/context/index.d.ts +4 -0
- package/dist/agents/context/index.d.ts.map +1 -0
- package/dist/agents/context/index.js +19 -0
- package/dist/agents/{streams.js.map → context/index.js.map} +1 -1
- package/dist/agents/context-model.d.ts +1 -1
- package/dist/agents/context-model.d.ts.map +1 -1
- package/dist/agents/context-resolution.d.ts +1 -1
- package/dist/agents/context-resolution.d.ts.map +1 -1
- package/dist/agents/index.d.ts +4 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +193 -204
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +1 -1
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +2 -0
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/request.d.ts +1 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +4 -0
- package/dist/agents/streams/index.d.ts.map +1 -0
- package/dist/agents/streams/index.js +20 -0
- package/dist/{chunk-y64skrwp.js.map → agents/streams/index.js.map} +1 -1
- package/dist/agents/streams/internal.d.ts +3 -0
- package/dist/agents/streams/internal.d.ts.map +1 -0
- package/dist/agents/streams/internal.js +40 -0
- package/dist/agents/{context.js.map → streams/internal.js.map} +1 -1
- package/dist/agents/{streams.d.ts → streams/protocol.d.ts} +5 -5
- package/dist/agents/streams/protocol.d.ts.map +1 -0
- package/dist/agents/types.d.ts +1 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +96 -108
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/strategy.js +8 -9
- package/dist/auth/strategy.js.map +1 -1
- package/dist/authorization/index.js +51 -56
- package/dist/authorization/index.js.map +1 -1
- package/dist/blob-storage/browser.js +15 -17
- package/dist/blob-storage/browser.js.map +1 -1
- package/dist/blob-storage/index.js +36 -38
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/bootstrap/discovery.d.ts +14 -1
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.d.ts +2 -2
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +80 -88
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/in-memory.d.ts +8 -2
- package/dist/broker/in-memory.d.ts.map +1 -1
- package/dist/broker/index.d.ts +4 -2
- package/dist/broker/index.d.ts.map +1 -1
- package/dist/broker/index.js +12 -10
- package/dist/broker/index.js.map +1 -1
- package/dist/broker/retention.d.ts +4 -0
- package/dist/broker/retention.d.ts.map +1 -0
- package/dist/broker/subscriber.d.ts +10 -0
- package/dist/broker/subscriber.d.ts.map +1 -0
- package/dist/broker/types.d.ts +14 -1
- package/dist/broker/types.d.ts.map +1 -1
- package/dist/chunk-0y39rgsb.js +43 -0
- package/dist/{chunk-c15dr03f.js.map → chunk-0y39rgsb.js.map} +2 -2
- package/dist/{chunk-k522z7v6.js → chunk-17kfctj6.js} +16 -11
- package/dist/chunk-17kfctj6.js.map +10 -0
- package/dist/{chunk-ajnan18g.js → chunk-1824gssz.js} +74 -106
- package/dist/chunk-1824gssz.js.map +12 -0
- package/dist/chunk-28ja2cjs.js +602 -0
- package/dist/chunk-28ja2cjs.js.map +18 -0
- package/dist/{chunk-5gd7tpv6.js → chunk-2c4j899j.js} +4 -4
- package/dist/chunk-2c4j899j.js.map +11 -0
- package/dist/{chunk-rv2hkwwa.js → chunk-358caqf5.js} +157 -180
- package/dist/chunk-358caqf5.js.map +12 -0
- package/dist/{chunk-fvt9rjsa.js → chunk-38zv5rkr.js} +4 -4
- package/dist/{chunk-fvt9rjsa.js.map → chunk-38zv5rkr.js.map} +1 -1
- package/dist/{chunk-w3e09qqk.js → chunk-39tqv9hz.js} +24 -24
- package/dist/{chunk-w3e09qqk.js.map → chunk-39tqv9hz.js.map} +2 -2
- package/dist/{chunk-04b07a9q.js → chunk-3bh94gbw.js} +13 -13
- package/dist/{chunk-04b07a9q.js.map → chunk-3bh94gbw.js.map} +2 -2
- package/dist/{chunk-s5y30bc9.js → chunk-3qms4nax.js} +52 -50
- package/dist/{chunk-s5y30bc9.js.map → chunk-3qms4nax.js.map} +5 -5
- package/dist/{chunk-nf4r78r4.js → chunk-5a4a52tq.js} +4 -4
- package/dist/{chunk-nf4r78r4.js.map → chunk-5a4a52tq.js.map} +2 -2
- package/dist/{chunk-wtf06et8.js → chunk-5c7ga8zz.js} +54 -177
- package/dist/chunk-5c7ga8zz.js.map +12 -0
- package/dist/{chunk-rte5sm3z.js → chunk-5hz0fnca.js} +23 -23
- package/dist/{chunk-rte5sm3z.js.map → chunk-5hz0fnca.js.map} +2 -2
- package/dist/{chunk-xajtptbw.js → chunk-5p1v802y.js} +1401 -445
- package/dist/chunk-5p1v802y.js.map +44 -0
- package/dist/chunk-653vwrzr.js +39 -0
- package/dist/chunk-653vwrzr.js.map +10 -0
- package/dist/{chunk-qw9gvjv5.js → chunk-72w2pxk7.js} +13 -13
- package/dist/{chunk-qw9gvjv5.js.map → chunk-72w2pxk7.js.map} +2 -2
- package/dist/chunk-7apz6hg4.js +50 -0
- package/dist/{chunk-jq43kdvk.js.map → chunk-7apz6hg4.js.map} +2 -2
- package/dist/chunk-7bs40fe1.js +218 -0
- package/dist/{chunk-p1rzczbt.js.map → chunk-7bs40fe1.js.map} +3 -3
- package/dist/chunk-7zgecwy1.js +113 -0
- package/dist/chunk-7zgecwy1.js.map +10 -0
- package/dist/{chunk-xhy826cz.js → chunk-85cd7e8c.js} +8 -7
- package/dist/chunk-85cd7e8c.js.map +10 -0
- package/dist/{chunk-pc7ys28c.js → chunk-860dwwy0.js} +29 -29
- package/dist/{chunk-pc7ys28c.js.map → chunk-860dwwy0.js.map} +2 -2
- package/dist/chunk-8vj0rjgs.js +165 -0
- package/dist/chunk-8vj0rjgs.js.map +15 -0
- package/dist/{chunk-7y0f6rf1.js → chunk-92vk7gta.js} +58 -58
- package/dist/chunk-92vk7gta.js.map +10 -0
- package/dist/{chunk-rafagrwr.js → chunk-93csa55g.js} +45 -17
- package/dist/chunk-93csa55g.js.map +11 -0
- package/dist/{chunk-aa2pen2v.js → chunk-976rxdpx.js} +188 -175
- package/dist/{chunk-aa2pen2v.js.map → chunk-976rxdpx.js.map} +2 -2
- package/dist/{chunk-d8qkxt2v.js → chunk-98cw09sw.js} +7 -7
- package/dist/chunk-98cw09sw.js.map +10 -0
- package/dist/{chunk-n4khvw9n.js → chunk-9qsh3p5y.js} +17 -17
- package/dist/{chunk-n4khvw9n.js.map → chunk-9qsh3p5y.js.map} +2 -2
- package/dist/{chunk-4a849fr1.js → chunk-9tc8dxmn.js} +1 -1
- package/dist/{chunk-9nbmsvn5.js → chunk-9vx5e9g1.js} +9 -9
- package/dist/{chunk-9nbmsvn5.js.map → chunk-9vx5e9g1.js.map} +2 -2
- package/dist/{chunk-8m5ejdpn.js → chunk-9x8dybsb.js} +5 -5
- package/dist/chunk-9x8dybsb.js.map +10 -0
- package/dist/chunk-aa6z4a19.js +358 -0
- package/dist/chunk-aa6z4a19.js.map +12 -0
- package/dist/{chunk-3xep5cjx.js → chunk-agbbygvh.js} +104 -86
- package/dist/chunk-agbbygvh.js.map +15 -0
- package/dist/{chunk-2dw777qw.js → chunk-ap0g1g74.js} +37 -82
- package/dist/{chunk-2dw777qw.js.map → chunk-ap0g1g74.js.map} +3 -4
- package/dist/{chunk-v4en4jc2.js → chunk-awbhdqyc.js} +7 -7
- package/dist/{chunk-v4en4jc2.js.map → chunk-awbhdqyc.js.map} +2 -2
- package/dist/{chunk-w9tg6yyb.js → chunk-b0ec55a1.js} +54 -37
- package/dist/chunk-b0ec55a1.js.map +12 -0
- package/dist/{chunk-ka3a2ft3.js → chunk-b19g04jk.js} +12 -12
- package/dist/{chunk-ka3a2ft3.js.map → chunk-b19g04jk.js.map} +2 -2
- package/dist/{chunk-gbejpkex.js → chunk-bn138h9w.js} +27 -28
- package/dist/{chunk-gbejpkex.js.map → chunk-bn138h9w.js.map} +3 -3
- package/dist/{chunk-nx7k8tpr.js → chunk-br3k6qbf.js} +23 -23
- package/dist/{chunk-nx7k8tpr.js.map → chunk-br3k6qbf.js.map} +2 -2
- package/dist/{chunk-dbc80ad7.js → chunk-c5rkjrgp.js} +28 -28
- package/dist/{chunk-dbc80ad7.js.map → chunk-c5rkjrgp.js.map} +2 -2
- package/dist/{chunk-dktq02ne.js → chunk-cqr3acm1.js} +4 -4
- package/dist/{chunk-dktq02ne.js.map → chunk-cqr3acm1.js.map} +2 -2
- package/dist/chunk-d62kjtbg.js +7 -0
- package/dist/{chunk-zcnhxkvd.js.map → chunk-d62kjtbg.js.map} +2 -2
- package/dist/{chunk-74drx9gd.js → chunk-dfm066qg.js} +10 -10
- package/dist/{chunk-74drx9gd.js.map → chunk-dfm066qg.js.map} +2 -2
- package/dist/{chunk-5e3pq99w.js → chunk-dmn70ztd.js} +30 -30
- package/dist/chunk-dmn70ztd.js.map +11 -0
- package/dist/{chunk-p1x242ad.js → chunk-dz5h08xv.js} +175 -175
- package/dist/{chunk-p1x242ad.js.map → chunk-dz5h08xv.js.map} +2 -2
- package/dist/{chunk-p2vqaxkc.js → chunk-e0d1rzef.js} +27 -22
- package/dist/{chunk-p2vqaxkc.js.map → chunk-e0d1rzef.js.map} +3 -3
- package/dist/{chunk-5sz8ta9r.js → chunk-e1c18xjx.js} +52 -52
- package/dist/{chunk-5sz8ta9r.js.map → chunk-e1c18xjx.js.map} +2 -2
- package/dist/{chunk-19jp6g9d.js → chunk-f0rwz2vh.js} +54 -33
- package/dist/chunk-f0rwz2vh.js.map +11 -0
- package/dist/{chunk-2xns679x.js → chunk-f4w3yp4f.js} +171 -36
- package/dist/chunk-f4w3yp4f.js.map +12 -0
- package/dist/{chunk-979ww6b3.js → chunk-fb3feg1e.js} +29 -29
- package/dist/{chunk-979ww6b3.js.map → chunk-fb3feg1e.js.map} +2 -2
- package/dist/{chunk-f26bck4t.js → chunk-ftv470j8.js} +393 -355
- package/dist/{chunk-f26bck4t.js.map → chunk-ftv470j8.js.map} +7 -7
- package/dist/{chunk-4sm0aznx.js → chunk-g00bfdq6.js} +254 -256
- package/dist/{chunk-4sm0aznx.js.map → chunk-g00bfdq6.js.map} +3 -3
- package/dist/{chunk-p03r0h5s.js → chunk-g53f0e4j.js} +76 -202
- package/dist/chunk-g53f0e4j.js.map +15 -0
- package/dist/chunk-g6cke204.js +124 -0
- package/dist/chunk-g6cke204.js.map +10 -0
- package/dist/{chunk-q0k9nc5a.js → chunk-g7knyczr.js} +98 -98
- package/dist/{chunk-q0k9nc5a.js.map → chunk-g7knyczr.js.map} +2 -2
- package/dist/{chunk-51fjndv0.js → chunk-gfdh9kqa.js} +4 -4
- package/dist/{chunk-51fjndv0.js.map → chunk-gfdh9kqa.js.map} +2 -2
- package/dist/{chunk-8tsf6dmc.js → chunk-gqh45d2n.js} +244 -205
- package/dist/chunk-gqh45d2n.js.map +15 -0
- package/dist/chunk-h3v76ams.js +32 -0
- package/dist/{chunk-08m3b6w8.js.map → chunk-h3v76ams.js.map} +2 -2
- package/dist/{chunk-jecn6t54.js → chunk-jgwb25gc.js} +74 -74
- package/dist/{chunk-jecn6t54.js.map → chunk-jgwb25gc.js.map} +2 -2
- package/dist/{chunk-wdage1eb.js → chunk-jmfet9r4.js} +6 -6
- package/dist/{chunk-wdage1eb.js.map → chunk-jmfet9r4.js.map} +2 -2
- package/dist/{chunk-k34z5rvh.js → chunk-kfee1h52.js} +132 -48
- package/dist/chunk-kfee1h52.js.map +13 -0
- package/dist/{chunk-2ab72m2h.js → chunk-m2ca93my.js} +3 -3
- package/dist/{chunk-2ab72m2h.js.map → chunk-m2ca93my.js.map} +2 -2
- package/dist/{chunk-4jjp5k14.js → chunk-mmagke4x.js} +6 -6
- package/dist/{chunk-4jjp5k14.js.map → chunk-mmagke4x.js.map} +2 -2
- package/dist/{chunk-359jm1jw.js → chunk-mrp7k0pw.js} +20 -20
- package/dist/{chunk-359jm1jw.js.map → chunk-mrp7k0pw.js.map} +2 -2
- package/dist/{chunk-h0k55pc7.js → chunk-ms2tmn1k.js} +139 -139
- package/dist/{chunk-h0k55pc7.js.map → chunk-ms2tmn1k.js.map} +2 -2
- package/dist/{chunk-h5vqbfmd.js → chunk-nmbxcaqx.js} +117 -117
- package/dist/{chunk-h5vqbfmd.js.map → chunk-nmbxcaqx.js.map} +3 -3
- package/dist/{chunk-n2w475r0.js → chunk-nt99sxd6.js} +82 -82
- package/dist/{chunk-n2w475r0.js.map → chunk-nt99sxd6.js.map} +3 -3
- package/dist/{chunk-v1xppd0y.js → chunk-p5vcsw9c.js} +60 -60
- package/dist/{chunk-v1xppd0y.js.map → chunk-p5vcsw9c.js.map} +2 -2
- package/dist/{chunk-sbzzr4kx.js → chunk-p6a4npdx.js} +1260 -1289
- package/dist/chunk-p6a4npdx.js.map +58 -0
- package/dist/{chunk-trxxmgnf.js → chunk-pqajwytd.js} +10 -10
- package/dist/{chunk-trxxmgnf.js.map → chunk-pqajwytd.js.map} +3 -3
- package/dist/{chunk-nn0tekr1.js → chunk-pr2h4bv4.js} +33 -33
- package/dist/{chunk-nn0tekr1.js.map → chunk-pr2h4bv4.js.map} +2 -2
- package/dist/{chunk-xwnf87e1.js → chunk-q5gz3g2j.js} +64 -64
- package/dist/{chunk-xwnf87e1.js.map → chunk-q5gz3g2j.js.map} +2 -2
- package/dist/{chunk-5ntny1qx.js → chunk-qf954wje.js} +6 -6
- package/dist/{chunk-5ntny1qx.js.map → chunk-qf954wje.js.map} +2 -2
- package/dist/chunk-qma80ych.js +30 -0
- package/dist/chunk-qma80ych.js.map +11 -0
- package/dist/{chunk-mth82m8t.js → chunk-qyeptdyv.js} +171 -77
- package/dist/chunk-qyeptdyv.js.map +15 -0
- package/dist/{chunk-b49dgvsj.js → chunk-r2y23egw.js} +3 -3
- package/dist/{chunk-b49dgvsj.js.map → chunk-r2y23egw.js.map} +2 -2
- package/dist/{chunk-mwsxn98e.js → chunk-r7fj830t.js} +253 -200
- package/dist/chunk-r7fj830t.js.map +36 -0
- package/dist/{chunk-4rh2m6zg.js → chunk-rb1xx120.js} +13 -13
- package/dist/{chunk-4rh2m6zg.js.map → chunk-rb1xx120.js.map} +2 -2
- package/dist/{chunk-gzasd5b6.js → chunk-rtk71jzp.js} +22 -22
- package/dist/{chunk-gzasd5b6.js.map → chunk-rtk71jzp.js.map} +2 -2
- package/dist/chunk-s3csryxe.js +152 -0
- package/dist/chunk-s3csryxe.js.map +11 -0
- package/dist/chunk-s670k14v.js +60 -0
- package/dist/{chunk-407j3msh.js.map → chunk-s670k14v.js.map} +2 -2
- package/dist/chunk-skz0hst3.js +788 -0
- package/dist/chunk-skz0hst3.js.map +19 -0
- package/dist/{chunk-3z1qec12.js → chunk-t1f4f1ve.js} +107 -64
- package/dist/{chunk-3z1qec12.js.map → chunk-t1f4f1ve.js.map} +3 -3
- package/dist/chunk-v2vcg0w6.js +151 -0
- package/dist/chunk-v2vcg0w6.js.map +11 -0
- package/dist/{chunk-r8jrnexe.js → chunk-v4jbb3rs.js} +4 -4
- package/dist/{chunk-r8jrnexe.js.map → chunk-v4jbb3rs.js.map} +2 -2
- package/dist/{chunk-w1tvjszy.js → chunk-vsj3mdfj.js} +8 -8
- package/dist/{chunk-w1tvjszy.js.map → chunk-vsj3mdfj.js.map} +2 -2
- package/dist/{chunk-9dzba0f2.js → chunk-wjasrj67.js} +8 -8
- package/dist/{chunk-9dzba0f2.js.map → chunk-wjasrj67.js.map} +2 -2
- package/dist/{chunk-1evzqhks.js → chunk-wr8qp979.js} +6 -6
- package/dist/{chunk-1evzqhks.js.map → chunk-wr8qp979.js.map} +2 -2
- package/dist/{chunk-n6jxh8sw.js → chunk-wy0qdqfm.js} +18 -18
- package/dist/{chunk-n6jxh8sw.js.map → chunk-wy0qdqfm.js.map} +2 -2
- package/dist/{chunk-z4ccwbkz.js → chunk-x9v4cx1d.js} +1 -1
- package/dist/{chunk-ry24jbr1.js → chunk-yv79ncbv.js} +10 -10
- package/dist/{chunk-ry24jbr1.js.map → chunk-yv79ncbv.js.map} +2 -2
- package/dist/{chunk-yp8ee62z.js → chunk-z30bv4ga.js} +35 -35
- package/dist/{chunk-yp8ee62z.js.map → chunk-z30bv4ga.js.map} +2 -2
- package/dist/{chunk-8ydjhh27.js → chunk-z3y411fq.js} +11 -7
- package/dist/{chunk-8ydjhh27.js.map → chunk-z3y411fq.js.map} +3 -3
- package/dist/{chunk-9t8f5xfx.js → chunk-z5rnrmz1.js} +10 -10
- package/dist/{chunk-9t8f5xfx.js.map → chunk-z5rnrmz1.js.map} +2 -2
- package/dist/{chunk-96swp2wd.js → chunk-z667z3sg.js} +3 -3
- package/dist/{chunk-96swp2wd.js.map → chunk-z667z3sg.js.map} +2 -2
- package/dist/{chunk-4yqmp43v.js → chunk-z8fx5cgb.js} +12 -12
- package/dist/{chunk-4yqmp43v.js.map → chunk-z8fx5cgb.js.map} +2 -2
- package/dist/{chunk-yt8wphsx.js → chunk-zvx7h87b.js} +3 -3
- package/dist/{chunk-yt8wphsx.js.map → chunk-zvx7h87b.js.map} +2 -2
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/contracts.d.ts +3 -0
- package/dist/connectors/connections/contracts.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +9 -10
- package/dist/connectors/connections/internal.js.map +1 -1
- package/dist/connectors/connections/request.d.ts +3 -1
- package/dist/connectors/connections/request.d.ts.map +1 -1
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/tokens.d.ts.map +1 -1
- package/dist/connectors/connections/validation.d.ts +5 -1
- package/dist/connectors/connections/validation.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +19 -4
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +8 -12
- package/dist/datasets/write.js.map +1 -1
- package/dist/edits/index.js +7 -8
- package/dist/edits/index.js.map +1 -1
- package/dist/error-reporting/internal.js +22 -24
- package/dist/error-reporting/internal.js.map +1 -1
- package/dist/errors/internal.d.ts +1 -1
- package/dist/errors/internal.d.ts.map +1 -1
- package/dist/errors/internal.js +22 -24
- package/dist/errors/internal.js.map +1 -1
- package/dist/errors/redaction.d.ts +8 -0
- package/dist/errors/redaction.d.ts.map +1 -0
- package/dist/errors/types.d.ts +4 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/events/execution.d.ts +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +60 -63
- package/dist/events/index.js.map +1 -1
- package/dist/events/scope.js +4 -5
- package/dist/events/scope.js.map +1 -1
- package/dist/events/selectors/index.js +9 -10
- package/dist/events/selectors/index.js.map +1 -1
- package/dist/events/service.d.ts +2 -2
- package/dist/events/service.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +3 -3
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +71 -82
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/durable.d.ts +1 -0
- package/dist/execution/durable.d.ts.map +1 -1
- package/dist/execution/primitive.d.ts +2 -0
- package/dist/execution/primitive.d.ts.map +1 -1
- package/dist/execution/primitive.js +64 -71
- package/dist/execution/primitive.js.map +3 -3
- package/dist/execution/request.d.ts +1 -0
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +66 -75
- package/dist/execution/request.js.map +3 -3
- package/dist/http/index.js +10 -11
- package/dist/http/index.js.map +1 -1
- package/dist/index.d.ts +17 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +457 -477
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/changes.d.ts +5 -0
- package/dist/lake-storage/changes.d.ts.map +1 -0
- package/dist/lake-storage/in-memory.d.ts +2 -1
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +2 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +40 -42
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +36 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/logging/index.d.ts +3 -4
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +18 -40
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/internal.d.ts +5 -0
- package/dist/logging/internal.d.ts.map +1 -0
- package/dist/logging/internal.js +43 -0
- package/dist/logging/internal.js.map +9 -0
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +46 -49
- package/dist/materialization/index.js.map +1 -1
- package/dist/materialization/model.d.ts +12 -1
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.d.ts +1 -1
- package/dist/materializer/index.d.ts.map +1 -1
- package/dist/materializer/index.js +137 -145
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/materializer.d.ts +5 -1
- package/dist/materializer/materializer.d.ts.map +1 -1
- package/dist/materializer/projections/entry-validator.d.ts +2 -1
- package/dist/materializer/projections/entry-validator.d.ts.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/source-materialization.d.ts +4 -3
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +2 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/errors.d.ts +4 -0
- package/dist/models/errors.d.ts.map +1 -1
- package/dist/models/execution/binding.d.ts +9 -0
- package/dist/models/execution/binding.d.ts.map +1 -0
- package/dist/models/execution/errors.d.ts +9 -0
- package/dist/models/execution/errors.d.ts.map +1 -0
- package/dist/models/execution/index.d.ts +11 -0
- package/dist/models/execution/index.d.ts.map +1 -0
- package/dist/models/execution/index.js +55 -0
- package/dist/models/execution/index.js.map +9 -0
- package/dist/models/execution/model-call-accounting.d.ts +17 -0
- package/dist/models/execution/model-call-accounting.d.ts.map +1 -0
- package/dist/models/execution/model-call-admission.d.ts +47 -0
- package/dist/models/execution/model-call-admission.d.ts.map +1 -0
- package/dist/models/execution/model-call-limits.d.ts +15 -0
- package/dist/models/execution/model-call-limits.d.ts.map +1 -0
- package/dist/models/execution/model-call-recorder.d.ts +40 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -0
- package/dist/models/execution/model-call-recovery.d.ts +12 -0
- package/dist/models/execution/model-call-recovery.d.ts.map +1 -0
- package/dist/models/execution/recovery-queue.d.ts +5 -0
- package/dist/models/execution/recovery-queue.d.ts.map +1 -0
- package/dist/models/execution/types.d.ts +44 -0
- package/dist/models/execution/types.d.ts.map +1 -0
- package/dist/models/execution/usage.d.ts +5 -0
- package/dist/models/execution/usage.d.ts.map +1 -0
- package/dist/models/execution.d.ts +6 -0
- package/dist/models/execution.d.ts.map +1 -0
- package/dist/models/generation-types.d.ts +40 -0
- package/dist/models/generation-types.d.ts.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +42 -43
- package/dist/models/index.js.map +1 -1
- package/dist/models/language-model.d.ts +3 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/output.d.ts +5 -0
- package/dist/models/output.d.ts.map +1 -0
- package/dist/models/resolve.d.ts +4 -0
- package/dist/models/resolve.d.ts.map +1 -0
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +75 -87
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/index.js +67 -76
- package/dist/objects/query/index.js.map +1 -1
- package/dist/ontology/index.d.ts +1 -2
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +62 -113
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/internal.d.ts +7 -0
- package/dist/ontology/internal.d.ts.map +1 -1
- package/dist/ontology/internal.js +65 -116
- package/dist/ontology/internal.js.map +3 -4
- package/dist/pipelines/index.js +57 -66
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +56 -67
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +11 -15
- package/dist/query.js.map +1 -1
- package/dist/queues/in-memory.d.ts +7 -3
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +2 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +6 -7
- package/dist/queues/index.js.map +1 -1
- package/dist/queues/indexed-heap.d.ts +15 -0
- package/dist/queues/indexed-heap.d.ts.map +1 -0
- package/dist/queues/types.d.ts +3 -20
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/rules/internal.js +4 -5
- package/dist/rules/internal.js.map +1 -1
- package/dist/runtime/create.d.ts +2 -1
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +2 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.js +13 -14
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/ontology-mutations.d.ts +3 -1
- package/dist/runtime/ontology-mutations.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +2 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/errors.d.ts +4 -0
- package/dist/sandboxes/errors.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +2 -2
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +14 -13
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +35 -7
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/scheduler/index.js +9 -10
- package/dist/scheduler/index.js.map +1 -1
- package/dist/schedules/index.js +31 -33
- package/dist/schedules/index.js.map +1 -1
- package/dist/shares/internal.js +46 -54
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/action-runs/failure.js +7 -9
- package/dist/storage/action-runs/failure.js.map +1 -1
- package/dist/storage/action-runs/provider.js +4 -8
- package/dist/storage/action-runs/provider.js.map +1 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +26 -30
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +0 -3
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/attribution.d.ts +4 -0
- package/dist/storage/ai-cost/attribution.d.ts.map +1 -0
- package/dist/storage/ai-cost/groups.d.ts +3 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +1 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +30 -143
- package/dist/storage/ai-cost/provider.js.map +3 -4
- package/dist/storage/ai-cost/types.d.ts +15 -0
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +14 -16
- package/dist/storage/ai-limits/enforcement.js.map +1 -1
- package/dist/storage/ai-limits/provider.js +56 -57
- package/dist/storage/ai-limits/provider.js.map +1 -1
- package/dist/storage/auth/in-memory.d.ts +1 -1
- package/dist/storage/auth/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +35 -37
- package/dist/storage/connector-connections/provider.js.map +3 -3
- package/dist/storage/connector-connections/types.d.ts +3 -2
- package/dist/storage/connector-connections/types.d.ts.map +1 -1
- package/dist/storage/executions/in-memory.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +2 -1
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +14 -11
- package/dist/storage/executions/provider.js.map +3 -3
- package/dist/storage/executions/types.d.ts +6 -2
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts +2 -0
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +7 -8
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +221 -256
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +10 -0
- package/dist/storage/internal.d.ts.map +1 -0
- package/dist/storage/internal.js +47 -0
- package/dist/storage/internal.js.map +9 -0
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/shared-state.d.ts +15 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts +6 -0
- package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +16 -0
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +107 -109
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/sources.d.ts +13 -4
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +18 -19
- package/dist/storage/operation-scope.js.map +1 -1
- package/dist/storage/pipeline-runs/provider.js +4 -6
- package/dist/storage/pipeline-runs/provider.js.map +1 -1
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.js +66 -70
- package/dist/storage/projection-runs/provider.js.map +1 -1
- package/dist/storage/projection-runs/types.d.ts +2 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/storage/share-grants/provider.js +17 -19
- package/dist/storage/share-grants/provider.js.map +1 -1
- package/dist/storage/share-sessions/provider.js +14 -15
- package/dist/storage/share-sessions/provider.js.map +1 -1
- package/dist/storage/sync-runs/provider.js +4 -6
- package/dist/storage/sync-runs/provider.js.map +1 -1
- package/dist/storage/webhook-runs/provider.js +4 -6
- package/dist/storage/webhook-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +13 -21
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +0 -3
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +56 -65
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/action-execution.d.ts +4 -1
- package/dist/testing/action-execution.d.ts.map +1 -1
- package/dist/testing/agent-execution.d.ts +1 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution.d.ts +1 -0
- package/dist/testing/execution.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2282 -1662
- package/dist/testing/index.js.map +16 -15
- package/dist/testing/lake-changes-contract.d.ts +6 -0
- package/dist/testing/lake-changes-contract.d.ts.map +1 -0
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/workflow-execution.d.ts +1 -0
- package/dist/testing/workflow-execution.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +6 -0
- package/dist/webhooks/connections.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.d.ts +2 -0
- package/dist/webhooks/internal.d.ts.map +1 -1
- package/dist/webhooks/internal.js +98 -61
- package/dist/webhooks/internal.js.map +4 -3
- package/dist/webhooks/registry.d.ts +1 -1
- package/dist/webhooks/registry.d.ts.map +1 -1
- package/dist/webhooks/types.d.ts +15 -4
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/index.js +11 -13
- package/dist/workers/index.js.map +2 -2
- package/dist/workflows/failure.d.ts +2 -0
- package/dist/workflows/failure.d.ts.map +1 -1
- package/dist/workflows/index.js +136 -147
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +3 -2
- package/dist/workflows/run-dispatch.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +2 -0
- package/dist/workflows/types.d.ts.map +1 -1
- package/package.json +48 -30
- package/src/actions/run-dispatch.ts +2 -6
- package/src/actions/types/context.ts +2 -0
- package/src/actions/validation.ts +2 -1
- package/src/agents/adapters.ts +4 -9
- package/src/agents/{context.ts → context/entries.ts} +4 -4
- package/src/agents/context/index.ts +15 -0
- package/src/agents/context-model.ts +1 -1
- package/src/agents/context-resolution.ts +1 -1
- package/src/agents/index.ts +4 -4
- package/src/agents/message.ts +1 -1
- package/src/agents/model-loop.ts +8 -0
- package/src/agents/request.ts +11 -26
- package/src/agents/streams/index.ts +18 -0
- package/src/agents/streams/internal.ts +19 -0
- package/src/agents/{streams.ts → streams/protocol.ts} +5 -5
- package/src/agents/types.ts +1 -1
- package/src/agents/validation.ts +3 -7
- package/src/auth/index.ts +0 -1
- package/src/bootstrap/discovery.ts +81 -24
- package/src/bootstrap/index.ts +8 -1
- package/src/broker/in-memory.ts +104 -39
- package/src/broker/index.ts +4 -1
- package/src/broker/retention.ts +28 -0
- package/src/broker/subscriber.ts +21 -0
- package/src/broker/types.ts +15 -1
- package/src/connectors/builders.ts +0 -6
- package/src/connectors/connections/authorizations.ts +11 -5
- package/src/connectors/connections/contracts.ts +3 -0
- package/src/connectors/connections/request.ts +56 -22
- package/src/connectors/connections/runs.ts +1 -0
- package/src/connectors/connections/tokens.ts +4 -0
- package/src/connectors/connections/validation.ts +91 -5
- package/src/connectors/types.ts +19 -4
- package/src/errors/internal.ts +90 -10
- package/src/errors/redaction.ts +98 -0
- package/src/errors/types.ts +4 -0
- package/src/events/execution.ts +2 -2
- package/src/events/service.ts +3 -3
- package/src/execution/agent.ts +5 -3
- package/src/execution/durable.ts +11 -1
- package/src/execution/primitive.ts +5 -1
- package/src/execution/request.ts +3 -0
- package/src/index.ts +30 -20
- package/src/lake-storage/changes.ts +43 -0
- package/src/lake-storage/in-memory.ts +73 -0
- package/src/lake-storage/index.ts +4 -0
- package/src/lake-storage/types.ts +40 -0
- package/src/logging/index.ts +2 -33
- package/src/logging/internal.ts +43 -0
- package/src/logging/service.ts +1 -1
- package/src/materialization/index.ts +2 -0
- package/src/materialization/model.ts +14 -1
- package/src/materializer/index.ts +2 -0
- package/src/materializer/materializer.ts +10 -0
- package/src/materializer/projections/entry-validator.ts +19 -1
- package/src/materializer/projections/replace.ts +36 -1
- package/src/materializer/projections/source-materialization.ts +26 -6
- package/src/materializer/shared/normalize.ts +1 -1
- package/src/models/errors.ts +12 -0
- package/src/models/execution/binding.ts +29 -0
- package/src/models/execution/errors.ts +18 -0
- package/src/models/execution/index.ts +26 -0
- package/src/models/execution/model-call-accounting.ts +211 -0
- package/src/models/execution/model-call-admission.ts +127 -0
- package/src/models/execution/model-call-limits.ts +135 -0
- package/src/models/execution/model-call-recorder.ts +235 -0
- package/src/models/execution/model-call-recovery.ts +125 -0
- package/src/models/execution/recovery-queue.ts +31 -0
- package/src/models/execution/types.ts +58 -0
- package/src/models/execution/usage.ts +23 -0
- package/src/models/execution.ts +207 -0
- package/src/models/generation-types.ts +50 -0
- package/src/models/index.ts +8 -0
- package/src/models/language-model.ts +3 -0
- package/src/models/output.ts +45 -0
- package/src/models/resolve.ts +27 -0
- package/src/objects/execution.ts +1 -1
- package/src/ontology/index.ts +1 -2
- package/src/ontology/internal.ts +35 -0
- package/src/pipelines/run-dispatch.ts +21 -1
- package/src/projections/run-dispatch.ts +31 -68
- package/src/query.ts +0 -1
- package/src/queues/in-memory.ts +105 -62
- package/src/queues/index.ts +4 -2
- package/src/queues/indexed-heap.ts +74 -0
- package/src/queues/types.ts +6 -25
- package/src/runtime/create.ts +2 -1
- package/src/runtime/host.ts +2 -15
- package/src/runtime/ontology-mutations.ts +4 -0
- package/src/runtime/sixb.ts +4 -0
- package/src/sandboxes/errors.ts +5 -0
- package/src/sandboxes/index.ts +3 -0
- package/src/sandboxes/sandbox.ts +35 -7
- package/src/storage/agents/in-memory.ts +0 -3
- package/src/storage/agents/types.ts +0 -3
- package/src/storage/ai-cost/analytics.ts +1 -1
- package/src/storage/ai-cost/attribution.ts +15 -0
- package/src/storage/ai-cost/groups.ts +5 -1
- package/src/storage/ai-cost/provider.ts +1 -0
- package/src/storage/ai-cost/types.ts +7 -0
- package/src/storage/auth/in-memory.ts +1 -1
- package/src/storage/connector-connections/in-memory.ts +3 -1
- package/src/storage/connector-connections/provider/runs.ts +3 -1
- package/src/storage/connector-connections/types.ts +3 -2
- package/src/storage/executions/in-memory.ts +4 -9
- package/src/storage/executions/provider.ts +4 -0
- package/src/storage/executions/types.ts +6 -2
- package/src/storage/executions/validation.ts +32 -0
- package/src/storage/in-memory/index.ts +16 -1
- package/src/storage/index.ts +4 -29
- package/src/storage/internal.ts +20 -0
- package/src/storage/ontology/in-memory/materializations-state.ts +5 -18
- package/src/storage/ontology/in-memory/materializations.ts +73 -92
- package/src/storage/ontology/in-memory/shared-state.ts +26 -1
- package/src/storage/ontology/in-memory/source-roots.ts +123 -0
- package/src/storage/ontology/in-memory/sources.ts +78 -23
- package/src/storage/ontology/index.ts +1 -0
- package/src/storage/ontology/provider.ts +70 -0
- package/src/storage/ontology/sources.ts +14 -3
- package/src/storage/projection-runs/lifecycle.ts +5 -2
- package/src/storage/projection-runs/types.ts +4 -3
- package/src/storage/workflow-runs/in-memory.ts +0 -2
- package/src/storage/workflow-runs/types.ts +0 -3
- package/src/syncs/run-dispatch.ts +19 -1
- package/src/testing/action-execution.ts +9 -2
- package/src/testing/agent-execution.ts +3 -0
- package/src/testing/agent-storage-contract.ts +0 -5
- package/src/testing/ai-model-call-groups-contract.ts +74 -2
- package/src/testing/broker-contract.ts +95 -0
- package/src/testing/connector-connection-storage-contract.ts +18 -1
- package/src/testing/execution-storage-contract.ts +59 -1
- package/src/testing/execution.ts +6 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/lake-changes-contract.ts +240 -0
- package/src/testing/materializer-storage-contract.ts +172 -1
- package/src/testing/ontology-storage-contract.ts +7 -0
- package/src/testing/projection-run-storage-contract.ts +34 -0
- package/src/testing/workflow-execution.ts +4 -0
- package/src/webhooks/connections.ts +56 -0
- package/src/webhooks/index.ts +2 -0
- package/src/webhooks/internal.ts +2 -0
- package/src/webhooks/registry.ts +3 -4
- package/src/webhooks/types.ts +17 -4
- package/src/workflows/failure.ts +62 -1
- package/src/workflows/request.ts +0 -9
- package/src/workflows/run-dispatch.ts +42 -32
- package/src/workflows/types.ts +2 -0
- package/src/workflows/validation.ts +1 -1
- package/dist/agents/context.d.ts.map +0 -1
- package/dist/agents/context.js +0 -23
- package/dist/agents/streams.d.ts.map +0 -1
- package/dist/agents/streams.js +0 -55
- package/dist/chunk-08m3b6w8.js +0 -32
- package/dist/chunk-19jp6g9d.js.map +0 -11
- package/dist/chunk-2xns679x.js.map +0 -11
- package/dist/chunk-3xep5cjx.js.map +0 -15
- package/dist/chunk-407j3msh.js +0 -60
- package/dist/chunk-4qfkag59.js +0 -1568
- package/dist/chunk-4qfkag59.js.map +0 -20
- package/dist/chunk-5e3pq99w.js.map +0 -11
- package/dist/chunk-5gd7tpv6.js.map +0 -11
- package/dist/chunk-7y0f6rf1.js.map +0 -10
- package/dist/chunk-8m5ejdpn.js.map +0 -10
- package/dist/chunk-8tsf6dmc.js.map +0 -15
- package/dist/chunk-ajnan18g.js.map +0 -12
- package/dist/chunk-c15dr03f.js +0 -43
- package/dist/chunk-d8qkxt2v.js.map +0 -10
- package/dist/chunk-jq43kdvk.js +0 -50
- package/dist/chunk-k34z5rvh.js.map +0 -11
- package/dist/chunk-k522z7v6.js.map +0 -10
- package/dist/chunk-mth82m8t.js.map +0 -14
- package/dist/chunk-mwsxn98e.js.map +0 -36
- package/dist/chunk-p03r0h5s.js.map +0 -16
- package/dist/chunk-p1rzczbt.js +0 -218
- package/dist/chunk-rafagrwr.js.map +0 -11
- package/dist/chunk-rv2hkwwa.js.map +0 -14
- package/dist/chunk-sbzzr4kx.js.map +0 -63
- package/dist/chunk-tpnd31c1.js +0 -242
- package/dist/chunk-tpnd31c1.js.map +0 -11
- package/dist/chunk-w9tg6yyb.js.map +0 -12
- package/dist/chunk-wtf06et8.js.map +0 -14
- package/dist/chunk-xajtptbw.js.map +0 -40
- package/dist/chunk-xhy826cz.js.map +0 -10
- package/dist/chunk-y64skrwp.js +0 -19
- package/dist/chunk-zcnhxkvd.js +0 -7
- package/dist/logging/types.js +0 -27
- package/dist/logging/types.js.map +0 -9
- /package/dist/{chunk-zqqz8052.js → chunk-7n30ybym.js} +0 -0
- /package/dist/{chunk-zqqz8052.js.map → chunk-7n30ybym.js.map} +0 -0
- /package/dist/{chunk-4a849fr1.js.map → chunk-9tc8dxmn.js.map} +0 -0
- /package/dist/{chunk-j1sbhm7p.js → chunk-ey1nk510.js} +0 -0
- /package/dist/{chunk-j1sbhm7p.js.map → chunk-ey1nk510.js.map} +0 -0
- /package/dist/{chunk-z4ccwbkz.js.map → chunk-x9v4cx1d.js.map} +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/agents/context-model.ts", "../src/agents/tool-result.ts", "../src/agents/adapters.ts", "../src/agents/api-gateway.ts", "../src/agents/validation.ts", "../src/agents/tool-definition.ts", "../src/agents/builders.ts", "../src/agents/context-compaction.ts", "../src/agents/model-loop.ts", "../src/agents/reference.ts", "../src/agents/thread-context-projection.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { stableJsonStringify } from \"../json\"\nimport type { AgentContextPart } from \"./context\"\n\n/** Project persisted context into one deterministic, escaped data block for the model. */\nexport function serializeAgentContextForModel(\n parts: readonly AgentContextPart[]\n): string | undefined {\n if (parts.length === 0) return undefined\n\n const lines = [\"<sixb_user_context>\"]\n for (const part of parts) {\n if (part.context.kind === \"object\") {\n lines.push(\n \" <object_context>\",\n ` <object_type_id>${escapeXml(part.context.ref.objectTypeId)}</object_type_id>`,\n ` <primary_id>${escapeXml(part.context.ref.primaryId)}</primary_id>`,\n \" </object_context>\"\n )\n continue\n }\n\n lines.push(\n \" <app_state_context>\",\n ` <id>${escapeXml(part.context.id)}</id>`,\n ` <description>${escapeXml(part.context.description)}</description>`,\n ` <value format=\"json\">${escapeXml(stableJsonStringify(part.context.value))}</value>`,\n \" </app_state_context>\"\n )\n }\n lines.push(\"</sixb_user_context>\")\n return lines.join(\"\\n\")\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\")\n}\n",
|
|
6
|
-
"import { isFileRef } from \"../blob-storage/validation\"\nimport { isPlainRecord } from \"../json\"\nimport type { AgentToolResult } from \"./types\"\n\n/** Narrow a durable JSON tool output to Sixb's file-aware result envelope. */\nexport function isAgentToolResult(value: unknown): value is AgentToolResult {\n return (\n isPlainRecord(value) &&\n value.kind === \"agentToolResult\" &&\n getInvalidAgentToolResultReason(value) === undefined\n )\n}\n\n/** Return a precise path when a tagged result does not satisfy the public rich-result contract. */\nexport function getInvalidAgentToolResultReason(value: unknown): string | undefined {\n if (!isPlainRecord(value) || value.kind !== \"agentToolResult\") {\n return undefined\n }\n\n if (!Array.isArray(value.content)) {\n return \"result.content must be an array\"\n }\n const unsupportedKey = Object.keys(value).find((key) => key !== \"kind\" && key !== \"content\")\n if (unsupportedKey) {\n return `result.${unsupportedKey} is not supported`\n }\n if (value.content.length === 0) {\n return \"result.content must contain at least one content part\"\n }\n\n for (let index = 0; index < value.content.length; index += 1) {\n const part = value.content[index]\n const path = `result.content[${index}]`\n if (!isPlainRecord(part)) {\n return `${path} must be a text or file content part`\n }\n if (part.type === \"text\") {\n if (typeof part.text !== \"string\") {\n return `${path}.text must be a string`\n }\n const unsupportedKey = Object.keys(part).find((key) => key !== \"type\" && key !== \"text\")\n if (unsupportedKey) {\n return `${path}.${unsupportedKey} is not supported`\n }\n continue\n }\n if (part.type === \"file\") {\n if (!isFileRef(part.fileRef)) {\n return `${path}.fileRef must be a valid FileRef`\n }\n const unsupportedKey = Object.keys(part).find((key) => key !== \"type\" && key !== \"fileRef\")\n if (unsupportedKey) {\n return `${path}.${unsupportedKey} is not supported`\n }\n continue\n }\n return `${path}.type must be 'text' or 'file'`\n }\n\n return undefined\n}\n",
|
|
7
|
-
"import type { JsonValue } from \"../json\"\nimport type {\n ModelAssistantPart,\n ModelFilePart,\n ModelMessage,\n ModelTextPart,\n ModelToolCallPart,\n ModelToolOutput,\n ModelToolResultPart,\n ProviderData,\n} from \"../models\"\nimport { serializeAgentContextForModel } from \"./context-model\"\nimport type {\n AgentFilePart,\n AgentMessage,\n AgentMessagePart,\n AgentTextPart,\n AgentToolCallPart,\n} from \"./message\"\nimport { isAgentToolResult } from \"./tool-result\"\nimport type { AgentToolFileContent } from \"./types\"\n\nexport interface AgentFileDataResolverInput<TMessage extends AgentMessage = AgentMessage> {\n readonly message: TMessage\n readonly part: AgentFilePart\n readonly partIndex: number\n}\n\nexport interface AgentFileDataProjection {\n readonly data: URL\n readonly mediaType?: string\n readonly filename?: string\n}\n\nexport interface AgentToolResultFileResolverInput<TMessage extends AgentMessage = AgentMessage> {\n readonly message: TMessage\n readonly part: AgentToolCallPart\n readonly partIndex: number\n readonly contentPart: AgentToolFileContent\n readonly contentIndex: number\n}\n\nexport interface ToModelMessagesOptions<TMessage extends AgentMessage = AgentMessage> {\n /**\n * Convert a stored file reference into model-readable data. When omitted, file parts are skipped\n * rather than leaking blob ids or passing an unsupported Sixb-only shape to model providers.\n */\n readonly fileData?:\n | ((input: AgentFileDataResolverInput<TMessage>) => URL | AgentFileDataProjection | undefined)\n | undefined\n /**\n * Convert a stored file reference into model-readable text context. This is appended before any\n * file data part so metadata, truncation notes, and sandbox/API access hints stay visible even for\n * models that cannot consume inline files.\n */\n readonly fileText?: (input: AgentFileDataResolverInput<TMessage>) => string | undefined\n /** Add current metadata, sandbox paths, and projection notes for a tool-result file. */\n readonly toolResultFileText?: (\n input: AgentToolResultFileResolverInput<TMessage>\n ) => string | undefined\n}\n\n/**\n * Project durable messages into Sixb model messages. Assistant parts are grouped\n * into blocks at each `step-start`; each block yields one `assistant` message plus, for any\n * non-provider-executed tool calls, one `tool` message. Provider-executed tool results stay inline\n * in the assistant message. Without a tool registry, a string output maps to `text` and anything\n * else to `json`; this is the documented fidelity scope (a tool's custom `toModelOutput` is not\n * reproduced).\n */\nexport function toModelMessages<TMessage extends AgentMessage>(\n messages: readonly TMessage[],\n options: ToModelMessagesOptions<TMessage> = {}\n): ModelMessage[] {\n const result: ModelMessage[] = []\n for (const message of messages) {\n switch (message.role) {\n case \"system\":\n result.push(systemModelMessage(message))\n break\n case \"user\":\n result.push(userModelMessage(message, options))\n break\n case \"assistant\":\n appendAssistantModelMessages(result, message, options)\n break\n }\n }\n return result\n}\n\nfunction systemModelMessage(message: AgentMessage): ModelMessage {\n const textParts = message.parts.filter((part) => part.type === \"text\")\n const providerData = mergeProviderMetadata(textParts)\n return {\n role: \"system\",\n content: textParts.map((part) => part.text).join(\"\"),\n ...(providerData === undefined ? {} : { providerData }),\n }\n}\n\nfunction mergeProviderMetadata(parts: readonly AgentTextPart[]): ProviderData | undefined {\n let merged: Record<string, JsonValue> | undefined\n for (const part of parts) {\n const meta = part.providerMetadata\n if (meta !== undefined && typeof meta === \"object\" && meta !== null && !Array.isArray(meta)) {\n merged = { ...(merged ?? {}), ...meta }\n }\n }\n return merged\n}\n\nfunction userModelMessage<TMessage extends AgentMessage>(\n message: TMessage,\n options: ToModelMessagesOptions<TMessage>\n): ModelMessage {\n const content: (ModelTextPart | ModelFilePart)[] = []\n const serializedContext = serializeAgentContextForModel(\n message.parts.filter((part) => part.type === \"context\")\n )\n if (serializedContext) {\n content.push({ type: \"text\", text: `${serializedContext}\\n\\n` })\n }\n message.parts.forEach((part, partIndex) => {\n if (part.type === \"text\") {\n content.push({\n type: \"text\",\n text: part.text,\n ...(part.providerMetadata === undefined ? {} : { providerData: part.providerMetadata }),\n })\n return\n }\n if (part.type === \"file\") {\n const fileContext = options.fileText?.({ message, part, partIndex })\n if (fileContext) {\n content.push({ type: \"text\", text: fileContext })\n }\n const resolved = options.fileData?.({ message, part, partIndex })\n if (resolved) {\n const projection = resolved instanceof URL ? { data: resolved } : resolved\n content.push({\n type: \"file\",\n data: projection.data,\n mediaType: projection.mediaType ?? part.fileRef.mediaType ?? \"application/octet-stream\",\n ...(projection.filename !== undefined\n ? { filename: projection.filename }\n : part.fileRef.fileName === undefined\n ? {}\n : { filename: part.fileRef.fileName }),\n ...(part.providerMetadata === undefined ? {} : { providerData: part.providerMetadata }),\n })\n }\n }\n })\n return { role: \"user\", content }\n}\n\nfunction appendAssistantModelMessages<TMessage extends AgentMessage>(\n result: ModelMessage[],\n message: TMessage,\n options: ToModelMessagesOptions<TMessage>\n): void {\n let block: Array<{ readonly part: AgentMessagePart; readonly partIndex: number }> = []\n const flush = (): void => {\n if (block.length === 0) {\n return\n }\n const current = block\n block = []\n\n const content: ModelAssistantPart[] = []\n const toolResults: ModelToolResultPart[] = []\n for (const { part, partIndex } of current) {\n if (part.type === \"text\" || part.type === \"reasoning\") {\n content.push({\n type: part.type,\n text: part.text,\n ...(part.providerMetadata === undefined ? {} : { providerData: part.providerMetadata }),\n })\n } else if (part.type === \"file\") {\n const fileContext = options.fileText?.({ message, part, partIndex })\n if (fileContext) {\n content.push({ type: \"text\", text: fileContext })\n }\n } else if (part.type === \"tool-call\") {\n content.push(toolCallModelPart(part))\n if (part.providerExecuted === true) {\n content.push(toolResultModelPart(message, part, partIndex, \"json\", options))\n } else {\n toolResults.push(toolResultModelPart(message, part, partIndex, \"text\", options))\n }\n } else if (part.type === \"provider-state\") {\n content.push({\n type: \"provider-state\",\n providerId: part.providerId,\n data: part.data,\n })\n }\n }\n result.push({ role: \"assistant\", content })\n\n if (toolResults.length > 0) {\n result.push({ role: \"tool\", content: toolResults })\n }\n }\n\n message.parts.forEach((part, partIndex) => {\n if (part.type === \"step-start\") {\n flush()\n } else {\n block.push({ part, partIndex })\n }\n })\n flush()\n}\n\nfunction toolCallModelPart(part: AgentToolCallPart): ModelToolCallPart {\n return {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: part.input,\n ...(part.providerExecuted === undefined ? {} : { providerExecuted: part.providerExecuted }),\n ...(part.providerMetadata === undefined ? {} : { providerData: part.providerMetadata }),\n }\n}\n\nfunction toolResultModelPart<TMessage extends AgentMessage>(\n message: TMessage,\n part: AgentToolCallPart,\n partIndex: number,\n errorMode: \"text\" | \"json\",\n options: ToModelMessagesOptions<TMessage>\n): ModelToolResultPart {\n // Stored providerMetadata belongs to the call, not this synthesized result. Replaying it here\n // can replace the result with the provider's original tool-call block.\n return {\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n output: toolResultOutput(message, part, partIndex, errorMode, options),\n }\n}\n\nfunction toolResultOutput<TMessage extends AgentMessage>(\n message: TMessage,\n part: AgentToolCallPart,\n partIndex: number,\n errorMode: \"text\" | \"json\",\n options: ToModelMessagesOptions<TMessage>\n): ModelToolOutput {\n if (part.state === \"output-error\") {\n return errorMode === \"json\"\n ? { type: \"error-json\", value: part.errorText }\n : { type: \"error-text\", value: part.errorText }\n }\n if (isAgentToolResult(part.output)) {\n const value: string[] = []\n part.output.content.forEach((contentPart, contentIndex) => {\n if (contentPart.type === \"text\") {\n value.push(contentPart.text)\n return\n }\n\n const fileContext = options.toolResultFileText?.({\n message,\n part,\n partIndex,\n contentPart,\n contentIndex,\n })\n value.push(fileContext ?? toolResultFileFallbackText(contentPart))\n })\n return { type: \"text\", value: value.join(\"\\n\") }\n }\n return typeof part.output === \"string\"\n ? { type: \"text\", value: part.output }\n : { type: \"json\", value: part.output }\n}\n\nfunction toolResultFileFallbackText(part: AgentToolFileContent): string {\n const attributes = [\n part.fileRef.fileName ? `name=${JSON.stringify(part.fileRef.fileName)}` : undefined,\n part.fileRef.mediaType ? `mediaType=${JSON.stringify(part.fileRef.mediaType)}` : undefined,\n `sizeBytes=${part.fileRef.sizeBytes}`,\n ].filter((value): value is string => value !== undefined)\n return `[Tool-created file: ${attributes.join(\" \")}. Contents are not available inline.]`\n}\n",
|
|
8
|
-
"import { createHmac, timingSafeEqual } from \"node:crypto\"\nimport { SIXB_API_ROUTES } from \"../http/api-routes\"\nimport { matchesPathPattern, normalizeRoutePath } from \"../http/route-pattern\"\n\nexport const AGENT_API_GATEWAY_PREFIX = \"/__sixb/agent-api\"\n\nconst AGENT_API_GATEWAY_CAPABILITY_PREFIX = \"sixb_agw_v1_\"\n\nexport interface AgentApiGatewayCapabilityInput {\n readonly projectId: string\n readonly runId: string\n readonly executionToken: string\n}\n\nexport interface AgentApiRoute {\n readonly method: string\n readonly path: string\n}\n\n/**\n * The routes the agent API gateway may proxy — the `agentApi` projection of the canonical\n * {@link SIXB_API_ROUTES} table, so this list can never drift from (nor exceed) the bearer boundary.\n */\nexport const AGENT_API_ROUTES: readonly AgentApiRoute[] = SIXB_API_ROUTES.filter(\n (route) => route.agentApi\n).map((route) => ({ method: route.method, path: route.path }))\n\nexport function createAgentApiGatewayCapability(input: AgentApiGatewayCapabilityInput): string {\n return `${AGENT_API_GATEWAY_CAPABILITY_PREFIX}${capabilityDigest(input)}`\n}\n\nexport function isValidAgentApiGatewayCapability(\n input: AgentApiGatewayCapabilityInput & { readonly capability: string }\n): boolean {\n const expected = createAgentApiGatewayCapability(input)\n const actual = input.capability\n const expectedBuffer = Buffer.from(expected)\n const actualBuffer = Buffer.from(actual)\n return (\n expectedBuffer.byteLength === actualBuffer.byteLength &&\n timingSafeEqual(expectedBuffer, actualBuffer)\n )\n}\n\nexport function isAllowedAgentApiRequest(method: string, pathname: string): boolean {\n const normalizedMethod = method.toUpperCase()\n const normalizedPath = normalizeRoutePath(pathname)\n return AGENT_API_ROUTES.some(\n (route) => route.method === normalizedMethod && matchesPathPattern(normalizedPath, route.path)\n )\n}\n\nfunction capabilityDigest(input: AgentApiGatewayCapabilityInput): string {\n return createHmac(\"sha256\", input.executionToken)\n .update(`agent-api-gateway:${input.projectId}:${input.runId}`)\n .digest(\"base64url\")\n}\n",
|
|
9
|
-
"import { getInvalidJsonValueReason, isPlainRecord, type JsonValue } from \"../json\"\nimport {\n normalizeSchemaValue,\n type ObjectSchema,\n OntologyValidationError,\n type ValueType,\n validateSchemaValue,\n} from \"../ontology\"\nimport { AgentDefinitionError } from \"./errors\"\nimport type { AgentToolDefinition, AgentToolInputSchema } from \"./types\"\n\nconst AGENT_TOOL_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/\nconst AGENT_TOOL_PRIMITIVE_SCHEMAS = new Set([\n \"string\",\n \"integer\",\n \"double\",\n \"decimal\",\n \"boolean\",\n \"date\",\n \"timestamp\",\n \"uuid\",\n \"fileRef\",\n])\n\nexport const AGENT_RESERVED_TOOL_NAMES = [\n \"bash\",\n \"read\",\n \"view_file\",\n \"spawn_agent\",\n \"wait_agent\",\n] as const\n\nexport function isAgentToolDefinition(value: unknown): value is AgentToolDefinition {\n return (\n isRecord(value) &&\n value.kind === \"agentTool\" &&\n typeof value.name === \"string\" &&\n typeof value.description === \"string\" &&\n isPlainRecord(value.input) &&\n typeof value.handler === \"function\"\n )\n}\n\nexport function assertValidAgentToolName(name: unknown): asserts name is string {\n if (typeof name !== \"string\" || !AGENT_TOOL_NAME_PATTERN.test(name)) {\n throw new AgentDefinitionError(\n \"[Sixb] Agent tool name must be 1-64 characters, start with a letter or underscore, and contain only letters, numbers, underscores, or hyphens.\"\n )\n }\n if ((AGENT_RESERVED_TOOL_NAMES as readonly string[]).includes(name)) {\n throw new AgentDefinitionError(`[Sixb] Agent tool name '${name}' is reserved by the framework.`)\n }\n}\n\nexport function assertValidAgentToolDescription(name: string, description: unknown): void {\n if (typeof description !== \"string\" || !description.trim()) {\n throw new AgentDefinitionError(`[Sixb] Agent tool '${name}' description must not be empty.`)\n }\n}\n\nexport function assertValidAgentToolInput(name: string, input: unknown): void {\n if (!isPlainRecord(input)) {\n throw new AgentDefinitionError(`[Sixb] Agent tool '${name}' input must be a schema object.`)\n }\n\n for (const [field, schema] of Object.entries(input)) {\n if (!field.trim()) {\n throw new AgentDefinitionError(\n `[Sixb] Agent tool '${name}' input field names must not be empty.`\n )\n }\n assertValidAgentToolSchema(name, schema, `input.${field}`, new Set())\n }\n}\n\nexport function validateAndSnapshotAgentToolInput<TInput extends AgentToolInputSchema>(\n toolName: string,\n input: TInput\n): TInput {\n assertValidAgentToolInput(toolName, input)\n try {\n return deepFreeze(structuredClone(input))\n } catch {\n throw new AgentDefinitionError(\n `[Sixb] Agent tool '${toolName}' input must be safely snapshot-compatible.`\n )\n }\n}\n\n/** Validate model input against a tool schema, normalize it to JSON, and lock the snapshot. */\nexport function validateAndNormalizeAgentToolInput(\n toolName: string,\n shape: AgentToolInputSchema,\n value: unknown,\n valueTypesById: ReadonlyMap<string, ValueType>\n): Record<string, JsonValue> {\n const label = `Agent tool '${toolName}' input`\n if (!isPlainRecord(value)) {\n throw new OntologyValidationError(`[Sixb] ${label} must be a JSON object.`)\n }\n\n const reason = getInvalidJsonValueReason(value, label)\n if (reason) {\n throw new OntologyValidationError(`[Sixb] ${label} must be JSON-compatible; ${reason}.`)\n }\n\n const schema: ObjectSchema = {\n type: \"object\",\n properties: Object.fromEntries(\n Object.entries(shape).map(([field, fieldSchema]) => [\n field,\n { schema: fieldSchema, required: true },\n ])\n ),\n }\n validateSchemaValue(schema, value, label, valueTypesById)\n return deepFreeze(\n normalizeSchemaValue(schema, value, label, valueTypesById) as Record<string, JsonValue>\n )\n}\n\nfunction assertValidAgentToolSchema(\n toolName: string,\n schema: unknown,\n path: string,\n visiting: Set<object>\n): void {\n if (typeof schema === \"string\") {\n if (AGENT_TOOL_PRIMITIVE_SCHEMAS.has(schema)) {\n return\n }\n throw invalidAgentToolSchema(toolName, path)\n }\n if (!isPlainRecord(schema) || typeof schema.type !== \"string\" || visiting.has(schema)) {\n throw invalidAgentToolSchema(toolName, path)\n }\n\n visiting.add(schema)\n switch (schema.type) {\n case \"enum\": {\n const values = schema.values\n const validValues = isValidAgentToolEnumValues(values, schema.valueType)\n if (!validValues || new Set(values).size !== values.length) {\n throw invalidAgentToolSchema(toolName, path)\n }\n break\n }\n case \"array\":\n assertValidAgentToolSchema(toolName, schema.items, `${path}.items`, visiting)\n break\n case \"map\":\n if (schema.keySchema !== \"string\") {\n throw invalidAgentToolSchema(toolName, path)\n }\n assertValidAgentToolSchema(toolName, schema.valueSchema, `${path}.valueSchema`, visiting)\n break\n case \"object\": {\n if (!isPlainRecord(schema.properties)) {\n throw invalidAgentToolSchema(toolName, path)\n }\n for (const [fieldId, field] of Object.entries(schema.properties)) {\n if (!fieldId.trim() || !isPlainRecord(field) || !(\"schema\" in field)) {\n throw invalidAgentToolSchema(toolName, `${path}.properties.${fieldId}`)\n }\n if (\n (field.required !== undefined && typeof field.required !== \"boolean\") ||\n (field.nullable !== undefined && typeof field.nullable !== \"boolean\") ||\n (field.description !== undefined &&\n (typeof field.description !== \"string\" || !field.description.trim()))\n ) {\n throw invalidAgentToolSchema(toolName, `${path}.properties.${fieldId}`)\n }\n assertValidAgentToolSchema(\n toolName,\n field.schema,\n `${path}.properties.${fieldId}.schema`,\n visiting\n )\n }\n break\n }\n case \"valueTypeRef\":\n if (typeof schema.valueTypeId !== \"string\" || !schema.valueTypeId.trim()) {\n throw invalidAgentToolSchema(toolName, path)\n }\n if (schema._resolved !== undefined) {\n assertValidAgentToolSchema(toolName, schema._resolved, `${path}._resolved`, visiting)\n }\n break\n default:\n throw invalidAgentToolSchema(toolName, path)\n }\n visiting.delete(schema)\n}\n\nfunction invalidAgentToolSchema(toolName: string, path: string): AgentDefinitionError {\n return new AgentDefinitionError(\n `[Sixb] Agent tool '${toolName}' ${path} must be a valid Sixb schema.`\n )\n}\n\nexport function assertValidProjectAgentToolDefinitions(\n tools: readonly AgentToolDefinition[]\n): void {\n const seen = new Set<string>()\n for (let index = 0; index < tools.length; index += 1) {\n const tool = tools[index]\n if (!Object.hasOwn(tools, index) || !isAgentToolDefinition(tool)) {\n throw new AgentDefinitionError(\n \"[Sixb] Project tools must contain only agent tool definitions.\"\n )\n }\n\n assertValidAgentToolName(tool.name)\n assertValidAgentToolDescription(tool.name, tool.description)\n assertValidAgentToolInput(tool.name, tool.input)\n if (seen.has(tool.name)) {\n throw new AgentDefinitionError(\n `[Sixb] Project tools contain duplicate tool name '${tool.name}'.`\n )\n }\n seen.add(tool.name)\n }\n}\n\nfunction isValidAgentToolEnumValues(values: unknown, valueType: unknown): values is unknown[] {\n if (!Array.isArray(values) || values.length === 0) {\n return false\n }\n\n for (let index = 0; index < values.length; index += 1) {\n if (!Object.hasOwn(values, index)) {\n return false\n }\n const value = values[index]\n if (\n valueType === \"string\"\n ? typeof value !== \"string\"\n : valueType !== \"integer\" || typeof value !== \"number\" || !Number.isInteger(value)\n ) {\n return false\n }\n }\n return true\n}\n\nfunction deepFreeze<T>(value: T, seen: Set<object> = new Set()): T {\n if (value === null || typeof value !== \"object\" || seen.has(value)) {\n return value\n }\n\n seen.add(value)\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n if (descriptor && \"value\" in descriptor) {\n deepFreeze(descriptor.value, seen)\n }\n }\n return Object.freeze(value)\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n",
|
|
10
|
-
"import {\n cloneJsonValue,\n getInvalidJsonValueReason,\n type JsonValue,\n type ReadonlyJsonValue,\n} from \"../json\"\nimport { AgentDefinitionError, AgentToolResultValidationError } from \"./errors\"\nimport { getInvalidAgentToolResultReason } from \"./tool-result\"\nimport type {\n AgentToolDefinition,\n AgentToolHandler,\n AgentToolInputSchema,\n InferAgentToolInputSchema,\n} from \"./types\"\nimport {\n assertValidAgentToolDescription,\n assertValidAgentToolName,\n assertValidProjectAgentToolDefinitions,\n validateAndSnapshotAgentToolInput,\n} from \"./validation\"\n\nconst EMPTY_AGENT_TOOLS: readonly AgentToolDefinition[] = Object.freeze([])\nconst normalizedAgentTools = new WeakSet<AgentToolDefinition>()\n\nexport function createAgentToolDefinition<\n const TName extends string,\n const TInput extends AgentToolInputSchema,\n>(definition: {\n readonly name: TName\n readonly description: string\n readonly input: TInput\n readonly handler: AgentToolHandler<InferAgentToolInputSchema<TInput>>\n}): AgentToolDefinition<TName, TInput> {\n assertValidAgentToolName(definition.name)\n assertValidAgentToolDescription(definition.name, definition.description)\n if (typeof definition.handler !== \"function\") {\n throw new AgentDefinitionError(\n `[Sixb] Agent tool '${definition.name}' handler must be a function.`\n )\n }\n\n const input = validateAndSnapshotAgentToolInput(definition.name, definition.input)\n const tool: AgentToolDefinition<TName, TInput> = {\n kind: \"agentTool\",\n name: definition.name,\n description: definition.description,\n input,\n handler: async (context) => {\n const result = await definition.handler(context)\n let snapshot: JsonValue\n try {\n // AgentToolResult is intentionally expressed with FileRef instead of a duplicate JSON-only\n // shape. Runtime validation below proves that the complete envelope crosses the same JSON\n // boundary as legacy results.\n snapshot = cloneJsonValue(result as ReadonlyJsonValue, \"result\")\n } catch (cause) {\n throw new AgentToolResultValidationError(\n definition.name,\n getInvalidJsonValueReason(result, \"result\") ?? \"result could not be cloned safely\",\n { cause }\n )\n }\n const richResultReason = getInvalidAgentToolResultReason(snapshot)\n if (richResultReason) {\n throw new AgentToolResultValidationError(definition.name, richResultReason)\n }\n return snapshot\n },\n }\n\n normalizedAgentTools.add(tool)\n return Object.freeze(tool)\n}\n\nexport function toolsFromProjectConfig(\n tools: readonly AgentToolDefinition[] | undefined\n): readonly AgentToolDefinition[] {\n if (tools === undefined) {\n return EMPTY_AGENT_TOOLS\n }\n if (!Array.isArray(tools)) {\n throw new AgentDefinitionError(\n \"[Sixb] Project tools must be an array of agent tool definitions.\"\n )\n }\n\n assertValidProjectAgentToolDefinitions(tools)\n return normalizeAgentToolDefinitions(tools)\n}\n\nfunction normalizeAgentToolDefinitions(\n tools: readonly AgentToolDefinition[]\n): readonly AgentToolDefinition[] {\n const normalized: AgentToolDefinition[] = []\n for (const tool of tools) {\n normalized.push(normalizeAgentToolDefinition(tool))\n }\n return Object.freeze(normalized)\n}\n\nfunction normalizeAgentToolDefinition(tool: AgentToolDefinition): AgentToolDefinition {\n if (normalizedAgentTools.has(tool)) {\n return tool\n }\n\n return createAgentToolDefinition({\n name: tool.name,\n description: tool.description,\n input: tool.input,\n handler: (context) => tool.handler(context),\n })\n}\n",
|
|
11
|
-
"import { createAgentToolDefinition } from \"./tool-definition\"\nimport type {\n AgentToolDefinition,\n AgentToolDescriptionBuilder,\n AgentToolHandler,\n AgentToolInputBuilder,\n AgentToolInputSchema,\n AgentToolRunBuilder,\n InferAgentToolInputSchema,\n} from \"./types\"\nimport {\n assertValidAgentToolDescription,\n assertValidAgentToolInput,\n assertValidAgentToolName,\n} from \"./validation\"\n\n/**\n * Define a reusable tool registered through `createSixb({ tools })`.\n *\n * The returned definition is inert. The agent worker supplies its run-scoped\n * context and executes the handler only when a run calls the tool.\n */\nexport function defineAgentTool<const TName extends string>(\n name: TName\n): AgentToolDescriptionBuilder<TName> {\n assertValidAgentToolName(name)\n\n return {\n description(description: string): AgentToolInputBuilder<TName> {\n assertValidAgentToolDescription(name, description)\n\n return {\n input<const TInput extends AgentToolInputSchema>(\n input: TInput\n ): AgentToolRunBuilder<TName, TInput> {\n assertValidAgentToolInput(name, input)\n\n return {\n run(\n handler: AgentToolHandler<InferAgentToolInputSchema<TInput>>\n ): AgentToolDefinition<TName, TInput> {\n return createAgentToolDefinition({ name, description, input, handler })\n },\n }\n },\n }\n },\n }\n}\n",
|
|
12
|
-
"import { stableJsonStringify } from \"../json\"\nimport type { AgentMessageRecord } from \"../storage/agents/types\"\nimport type { AgentMessage, AgentMessagePart } from \"./message\"\n\nexport const AGENT_CONTEXT_ESTIMATOR_VERSION = 1 as const\n\nconst CHARS_PER_TOKEN = 4\nconst REQUEST_OVERHEAD_TOKENS = 8\nconst MESSAGE_OVERHEAD_TOKENS = 8\nconst TOOL_OVERHEAD_TOKENS = 16\nconst STEP_OVERHEAD_TOKENS = 2\nconst IMAGE_ALLOWANCE_TOKENS = 1_200\nconst FILE_TEXT_INLINE_MAX_BYTES = 50 * 1024\nconst FILE_TEXT_INLINE_TOTAL_MAX_BYTES = 200 * 1024\nconst TOOL_RESULT_SUMMARY_MAX_CHARS = 2_000\n\nexport interface AgentContextEstimateTool {\n readonly name: string\n readonly description: string\n /** Deterministic JSON-schema serialization sent for this tool. */\n readonly inputSchema: string\n}\n\nexport interface EstimateAgentContextRequestTokensInput {\n readonly systemPrompt: string\n readonly tools: readonly AgentContextEstimateTool[]\n readonly messages: readonly AgentMessage[]\n}\n\nexport interface AgentContextTokenEstimate {\n readonly tokens: number\n readonly estimatorVersion: typeof AGENT_CONTEXT_ESTIMATOR_VERSION\n}\n\nexport interface AgentContextCompactionBoundary {\n readonly messagesToSummarize: readonly AgentMessageRecord[]\n readonly retainedMessages: readonly AgentMessageRecord[]\n readonly summarizedThroughSeq: number\n}\n\n/** Compaction begins only once the estimated request crosses the reserved input budget. */\nexport function shouldCompactAgentContext(input: {\n readonly estimatedInputTokens: number\n readonly inputBudgetTokens: number\n}): boolean {\n return input.estimatedInputTokens > input.inputBudgetTokens\n}\n\n/** Estimate the provider request shape with one stable, conservative character heuristic. */\nexport function estimateAgentContextRequestTokens(\n input: EstimateAgentContextRequestTokensInput\n): AgentContextTokenEstimate {\n const toolTokens = input.tools.reduce(\n (total, tool) =>\n total +\n TOOL_OVERHEAD_TOKENS +\n textTokens(tool.name) +\n textTokens(tool.description) +\n textTokens(tool.inputSchema),\n 0\n )\n return {\n tokens:\n REQUEST_OVERHEAD_TOKENS +\n textTokens(input.systemPrompt) +\n toolTokens +\n estimateAgentContextMessagesTokens(input.messages).tokens,\n estimatorVersion: AGENT_CONTEXT_ESTIMATOR_VERSION,\n }\n}\n\n/** Estimate message-only growth after a provider-usage anchor. */\nexport function estimateAgentContextMessagesTokens(\n messages: readonly AgentMessage[]\n): AgentContextTokenEstimate {\n const attachments = { textBytesRemaining: FILE_TEXT_INLINE_TOTAL_MAX_BYTES }\n let tokens = 0\n for (const message of messages) {\n tokens += estimateMessageTokens(message, attachments)\n }\n return { tokens, estimatorVersion: AGENT_CONTEXT_ESTIMATOR_VERSION }\n}\n\n/** Select the safe user boundary whose retained tail is closest to the configured recent budget. */\nexport function selectAgentContextCompactionBoundary(input: {\n readonly messages: readonly AgentMessageRecord[]\n readonly keepRecentTokens: number\n}): AgentContextCompactionBoundary | null {\n if (input.messages.length < 2) return null\n\n let retainedTokens = 0\n let boundaryIndex: number | null = null\n let closestDistance = Number.POSITIVE_INFINITY\n for (let index = input.messages.length - 1; index > 0; index -= 1) {\n retainedTokens += estimateAgentContextMessagesTokens([input.messages[index]!]).tokens\n if (input.messages[index]?.role !== \"user\") continue\n\n const distance = Math.abs(input.keepRecentTokens - retainedTokens)\n if (distance <= closestDistance) {\n boundaryIndex = index\n closestDistance = distance\n }\n if (retainedTokens >= input.keepRecentTokens) break\n }\n\n if (boundaryIndex === null) return null\n\n const summarizedThroughSeq = input.messages[boundaryIndex - 1]?.seq\n if (summarizedThroughSeq === undefined) return null\n return {\n messagesToSummarize: input.messages.slice(0, boundaryIndex),\n retainedMessages: input.messages.slice(boundaryIndex),\n summarizedThroughSeq,\n }\n}\n\n/** Serialize durable conversation content as escaped quoted data for the summary model. */\nexport function serializeAgentMessagesForSummary(messages: readonly AgentMessageRecord[]): string {\n const lines = [\"<sixb_conversation_history>\"]\n for (const message of messages) {\n lines.push(\n ` <message id=\"${escapeXml(message.id)}\" seq=\"${message.seq}\" role=\"${message.role}\">`\n )\n message.parts.forEach((part, partIndex) => {\n lines.push(...serializeSummaryPart(message, part, partIndex))\n })\n lines.push(\" </message>\")\n }\n lines.push(\"</sixb_conversation_history>\")\n return lines.join(\"\\n\")\n}\n\nfunction estimateMessageTokens(\n message: AgentMessage,\n attachments: { textBytesRemaining: number }\n): number {\n let tokens = MESSAGE_OVERHEAD_TOKENS\n for (const part of message.parts) {\n switch (part.type) {\n case \"text\":\n case \"reasoning\":\n tokens += textTokens(part.text)\n break\n case \"step-start\":\n tokens += STEP_OVERHEAD_TOKENS\n break\n case \"context\":\n tokens += textTokens(stableJsonStringify(part.context))\n break\n case \"provider-state\":\n tokens += textTokens(stableJsonStringify(part.data))\n break\n case \"tool-call\":\n tokens +=\n TOOL_OVERHEAD_TOKENS +\n textTokens(part.toolName) +\n textTokens(stableJsonStringify(part.input)) +\n (part.state === \"output-available\"\n ? textTokens(stableJsonStringify(part.output))\n : textTokens(part.errorText))\n break\n case \"file\": {\n const file = part.fileRef\n tokens += textTokens(\n [file.blobId, file.digest, file.fileName, file.mediaType, file.logicalPath]\n .filter((value): value is string => value !== undefined)\n .join(\" \")\n )\n if (message.role !== \"assistant\") {\n if (looksLikeImage(file.mediaType, file.fileName)) {\n tokens += IMAGE_ALLOWANCE_TOKENS\n } else {\n const inlineBytes = Math.min(\n file.sizeBytes,\n FILE_TEXT_INLINE_MAX_BYTES,\n attachments.textBytesRemaining\n )\n attachments.textBytesRemaining -= inlineBytes\n tokens += Math.ceil(inlineBytes / CHARS_PER_TOKEN)\n }\n }\n break\n }\n }\n }\n return tokens\n}\n\nfunction serializeSummaryPart(\n message: AgentMessageRecord,\n part: AgentMessagePart,\n partIndex: number\n): string[] {\n const indent = \" \"\n switch (part.type) {\n case \"text\":\n return [`${indent}<text>${escapeXml(part.text)}</text>`]\n case \"reasoning\":\n case \"provider-state\":\n case \"step-start\":\n return []\n case \"context\":\n return part.context.kind === \"object\"\n ? [\n `${indent}<object_context origin=\"${part.origin}\" object_type_id=\"${escapeXml(part.context.ref.objectTypeId)}\" primary_id=\"${escapeXml(part.context.ref.primaryId)}\" />`,\n ]\n : [\n `${indent}<app_context origin=\"${part.origin}\" id=\"${escapeXml(part.context.id)}\" label=\"${escapeXml(part.context.label)}\">`,\n `${indent} <description>${escapeXml(part.context.description)}</description>`,\n `${indent} <value format=\"json\">${escapeXml(stableJsonStringify(part.context.value))}</value>`,\n `${indent}</app_context>`,\n ]\n case \"file\": {\n const file = part.fileRef\n const attributes = [\n `message_id=\"${escapeXml(message.id)}\"`,\n `part_index=\"${partIndex}\"`,\n `blob_id=\"${escapeXml(file.blobId)}\"`,\n `digest=\"${escapeXml(file.digest)}\"`,\n `size_bytes=\"${file.sizeBytes}\"`,\n ...(file.fileName === undefined ? [] : [`file_name=\"${escapeXml(file.fileName)}\"`]),\n ...(file.mediaType === undefined ? [] : [`media_type=\"${escapeXml(file.mediaType)}\"`]),\n ...(file.logicalPath === undefined\n ? []\n : [`logical_path=\"${escapeXml(file.logicalPath)}\"`]),\n ]\n return [`${indent}<file ${attributes.join(\" \")} />`]\n }\n case \"tool-call\": {\n const output =\n part.state === \"output-available\"\n ? truncateToolResult(stableJsonStringify(part.output))\n : truncateToolResult(part.errorText)\n return [\n `${indent}<tool_call id=\"${escapeXml(part.toolCallId)}\" name=\"${escapeXml(part.toolName)}\" state=\"${part.state}\">`,\n `${indent} <input format=\"json\">${escapeXml(stableJsonStringify(part.input))}</input>`,\n `${indent} <result>${escapeXml(output)}</result>`,\n `${indent}</tool_call>`,\n ]\n }\n }\n}\n\nfunction truncateToolResult(value: string): string {\n if (value.length <= TOOL_RESULT_SUMMARY_MAX_CHARS) return value\n return `${value.slice(0, TOOL_RESULT_SUMMARY_MAX_CHARS)}\\n[truncated ${value.length - TOOL_RESULT_SUMMARY_MAX_CHARS} characters]`\n}\n\nfunction looksLikeImage(mediaType: string | undefined, fileName: string | undefined): boolean {\n if (mediaType?.toLowerCase().startsWith(\"image/\")) return true\n return /\\.(?:avif|gif|jpe?g|png|webp)$/i.test(fileName ?? \"\")\n}\n\nfunction textTokens(value: string): number {\n return Math.ceil(new TextEncoder().encode(value).byteLength / CHARS_PER_TOKEN)\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\")\n}\n",
|
|
13
|
-
"import { randomUUID } from \"node:crypto\"\nimport {\n assertJsonObject,\n assertJsonValue,\n isJsonValue,\n isPlainRecord,\n type JsonValue,\n} from \"../json\"\nimport { ModelProviderError, ModelStreamError, StructuredOutputError } from \"../models/errors\"\nimport type {\n LanguageModelStreamEvent,\n ModelCallEndEvent,\n ModelFinishReason,\n ModelStep,\n ModelUiChunk,\n ModelUsage,\n} from \"../models/events\"\nimport type {\n LanguageModel,\n ModelReasoning,\n ModelToolSpecification,\n} from \"../models/language-model\"\nimport type {\n ModelAssistantPart,\n ModelMessage,\n ModelProviderStatePart,\n ModelTextPart,\n ModelToolCallPart,\n ModelToolOutput,\n ModelToolResultPart,\n ProviderData,\n} from \"../models/messages\"\nimport {\n estimateModelCall,\n type ModelCallCost,\n type ModelReportedCost,\n rateModelCall,\n} from \"../models/pricing\"\nimport type { ModelOutput, ModelTool } from \"../models/tools\"\n\nconst MAX_PROVIDER_DATA_BYTES = 256 * 1024\n\ninterface ModelLoopOptions {\n readonly model: LanguageModel\n readonly messages: readonly ModelMessage[]\n readonly tools?: readonly ModelTool[]\n readonly reasoning?: ModelReasoning\n readonly maxOutputTokens?: number\n readonly caching?: \"auto\" | \"off\"\n readonly maxSteps: number\n readonly signal: AbortSignal\n /** Reserve the final provider call for a tool-free synthesis response. */\n readonly finalStepInstruction?: string\n readonly prepareStep?: (\n input: PrepareModelStepInput\n ) => PrepareModelStepResult | undefined | Promise<PrepareModelStepResult | undefined>\n readonly onEvent?: (event: ModelUiChunk) => void | Promise<void>\n readonly onModelCallEnd?: (event: ModelCallEndEvent) => void | Promise<void>\n readonly onStepEnd?: (step: ModelStep) => void | Promise<void>\n readonly generateCallId?: () => string\n}\n\n/** Non-text output requires a validator; unvalidated text can only inhabit types accepting string. */\nexport type RunModelLoopInput<TOutput = string> = ModelLoopOptions &\n (\n | { readonly output: ModelOutput<TOutput> }\n | (string extends TOutput ? { readonly output?: undefined } : never)\n )\n\nexport interface PrepareModelStepInput {\n readonly stepIndex: number\n readonly messages: readonly ModelMessage[]\n readonly model: LanguageModel\n readonly signal: AbortSignal\n}\n\nexport interface PrepareModelStepResult {\n /** Replacement history retained for this request and subsequent steps. */\n readonly messages?: readonly ModelMessage[]\n}\n\nexport type ModelLoopResult<TOutput = string> =\n | {\n readonly status: \"completed\"\n readonly output: TOutput\n readonly steps: readonly ModelStep[]\n readonly finishReason: ModelFinishReason\n }\n | {\n readonly status: \"aborted\"\n readonly steps: readonly ModelStep[]\n readonly partialContent: readonly ModelAssistantPart[]\n }\n\ninterface CompletedResponse {\n readonly providerIds?: import(\"../models/events\").ModelProviderIds\n readonly content: readonly ModelAssistantPart[]\n readonly toolCalls: readonly ParsedToolCall[]\n readonly finishReason: ModelFinishReason\n readonly rawFinishReason?: string\n readonly usage: ModelUsage\n readonly responseId?: string\n readonly responseModelId?: string\n readonly projectionError?: Error\n readonly reportedCost?: ModelReportedCost\n readonly route?: import(\"../models/events\").ModelRoute\n}\n\ninterface ParsedToolCall {\n readonly part: ModelToolCallPart\n readonly inputError?: Error\n}\n\n/**\n * Run a provider-neutral, streaming model/tool loop.\n *\n * One step is exactly one provider call. Lifecycle and stream callbacks are awaited so the caller\n * controls backpressure and can fail closed before another billable call starts.\n * Completed steps and partial content contain validated JSON payloads and normalized provider\n * metadata. Trace adapters may project these results directly; storage owns write validation.\n */\nexport function runModelLoop<TOutput = string>(\n input: RunModelLoopInput<TOutput>\n): Promise<ModelLoopResult<TOutput>>\nexport async function runModelLoop(\n input: RunModelLoopInput<unknown>\n): Promise<ModelLoopResult<unknown>> {\n assertLoopInput(input)\n const tools = indexTools(input.tools ?? [])\n const toolSpecifications = [...tools.values()].map<ModelToolSpecification>((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n }))\n let messages: readonly ModelMessage[] = [...input.messages]\n const steps: ModelStep[] = []\n const generateCallId = input.generateCallId ?? (() => `model_call_${randomUUID()}`)\n const callIds = new Set<string>()\n\n for (let stepIndex = 0; stepIndex < input.maxSteps; stepIndex += 1) {\n if (input.signal.aborted) {\n return { status: \"aborted\", steps, partialContent: [] }\n }\n await input.onEvent?.({ type: \"start-step\" })\n\n let requestMessages: readonly ModelMessage[]\n try {\n const prepared = await input.prepareStep?.({\n stepIndex,\n messages,\n model: input.model,\n signal: input.signal,\n })\n requestMessages = prepared?.messages ?? messages\n } catch (error) {\n if (!input.signal.aborted && !isAbortError(error)) throw error\n return { status: \"aborted\", steps, partialContent: [] }\n }\n if (input.signal.aborted) {\n return { status: \"aborted\", steps, partialContent: [] }\n }\n let requestTools: readonly ModelToolSpecification[] = toolSpecifications\n if (input.finalStepInstruction !== undefined && stepIndex === input.maxSteps - 1) {\n requestMessages = [\n ...requestMessages,\n { role: \"user\", content: [{ type: \"text\", text: input.finalStepInstruction }] },\n ]\n requestTools = []\n }\n\n const callId = generateCallId()\n if (!callId || callIds.has(callId)) {\n throw new ModelStreamError(`[SixbModels] Model call IDs must be nonempty and unique.`)\n }\n callIds.add(callId)\n const accumulator = new StreamAccumulator(input.onEvent)\n let accepted = false\n let cost: ModelCallCost = { status: \"unpriceable\", reason: \"missing-usage\" }\n let terminalStreamError: { readonly error: unknown } | undefined\n try {\n const stream = await input.model.stream({\n callId,\n messages: requestMessages,\n tools: requestTools,\n ...(input.reasoning === undefined ? {} : { reasoning: input.reasoning }),\n ...(input.maxOutputTokens === undefined ? {} : { maxOutputTokens: input.maxOutputTokens }),\n ...(input.caching === undefined ? {} : { caching: input.caching }),\n ...(input.output === undefined\n ? {}\n : {\n responseFormat: {\n type: \"json\" as const,\n name: input.output.name,\n ...(input.output.description === undefined\n ? {}\n : { description: input.output.description }),\n schema: input.output.schema,\n },\n }),\n signal: input.signal,\n })\n accepted = true\n for await (const event of stream.events) {\n await accumulator.accept(event)\n }\n } catch (error) {\n const aborted = input.signal.aborted || isAbortError(error)\n if (accumulator.isFinished()) {\n if (!aborted) terminalStreamError = { error }\n } else if (!aborted) {\n throw error\n } else {\n return {\n status: \"aborted\",\n steps,\n partialContent: accumulator.partialContent(),\n }\n }\n } finally {\n // Once a stream is accepted, cancellation or protocol failure cannot erase the call.\n // Only a finish event establishes final meters; interrupted calls remain explicitly unknown.\n if (accepted) {\n const facts = accumulator.accounting()\n const estimate = accumulator.isFinished() ? estimateModelCall(input.model, facts) : cost\n cost = facts.reportedCost\n ? rateModelCall({ usage: facts.usage, reported: facts.reportedCost })\n : estimate\n await input.onModelCallEnd?.({\n callId,\n providerId: input.model.providerId,\n modelId: input.model.modelId,\n responseId: facts.responseId ?? `${callId}:response`,\n providerIds: facts.providerIds,\n responseModelId: facts.responseModelId,\n usage: facts.usage,\n cost,\n ...(facts.reportedCost === undefined ? {} : { estimate }),\n ...(input.reasoning === undefined ? {} : { requestedReasoning: input.reasoning }),\n ...(facts.route === undefined ? {} : { route: facts.route }),\n })\n }\n }\n\n if (input.signal.aborted && !accumulator.isFinished()) {\n return { status: \"aborted\", steps, partialContent: accumulator.partialContent() }\n }\n const response = accumulator.complete()\n const responseId = response.responseId ?? `${callId}:response`\n if (terminalStreamError) throw terminalStreamError.error\n if (response.projectionError) throw response.projectionError\n if (input.signal.aborted) {\n return { status: \"aborted\", steps, partialContent: response.content }\n }\n\n const localCalls = response.toolCalls.filter((call) => call.part.providerExecuted !== true)\n if (response.finishReason === \"pause\" && localCalls.length === 0) {\n const step = modelStep(response, responseId, response.content, cost)\n steps.push(step)\n await input.onStepEnd?.(step)\n messages = [...requestMessages, { role: \"assistant\", content: response.content }]\n if (stepIndex + 1 === input.maxSteps) {\n throw new ModelStreamError(\n \"[SixbModels] Model reached the step limit while a provider continuation was pending.\"\n )\n }\n continue\n }\n if (localCalls.length === 0) {\n const step = modelStep(response, responseId, response.content, cost)\n steps.push(step)\n await input.onStepEnd?.(step)\n if (input.output) {\n const text = responseText(response)\n if (response.finishReason !== \"stop\") {\n throw new StructuredOutputError(\n `[SixbModels] Structured output did not complete successfully (${response.finishReason}).`,\n structuredOutputErrorContext(input, response, responseId, cost, text)\n )\n }\n let raw: unknown\n try {\n raw = JSON.parse(text)\n } catch (error) {\n throw new StructuredOutputError(\"[SixbModels] Model did not produce valid JSON output.\", {\n cause: error,\n ...structuredOutputErrorContext(input, response, responseId, cost, text),\n })\n }\n try {\n return {\n status: \"completed\",\n output: input.output.validate(raw),\n steps,\n finishReason: response.finishReason,\n }\n } catch (error) {\n throw new StructuredOutputError(\"[SixbModels] Structured output validation failed.\", {\n cause: error,\n ...structuredOutputErrorContext(input, response, responseId, cost, text),\n })\n }\n }\n const output = responseText(response)\n return { status: \"completed\", output, steps, finishReason: response.finishReason }\n }\n\n const toolResults = await Promise.all(\n localCalls.map((call) => executeToolCall(call, tools, callId, input.signal, input.onEvent))\n )\n const step = modelStep(response, responseId, [...response.content, ...toolResults], cost)\n steps.push(step)\n await input.onStepEnd?.(step)\n\n if (input.signal.aborted) {\n return {\n status: \"aborted\",\n steps,\n partialContent: [],\n }\n }\n\n const assistantContent = response.content.filter(\n (part) => part.type !== \"tool-result\" || part.providerExecuted === true\n )\n messages = [\n ...requestMessages,\n { role: \"assistant\", content: assistantContent },\n { role: \"tool\", content: toolResults },\n ]\n\n if (stepIndex + 1 === input.maxSteps) {\n if (input.output) {\n throw new StructuredOutputError(\n \"[SixbModels] Model reached the step limit without structured output.\",\n structuredOutputErrorContext(input, response, responseId, cost, responseText(response))\n )\n }\n const output = responseText(response)\n return { status: \"completed\", output, steps, finishReason: response.finishReason }\n }\n }\n\n throw new ModelStreamError(\"[SixbModels] Model loop exited without a terminal result.\")\n}\n\nfunction assertLoopInput(input: RunModelLoopInput<unknown>): void {\n if (\n input.maxOutputTokens !== undefined &&\n (!Number.isSafeInteger(input.maxOutputTokens) || input.maxOutputTokens <= 0)\n ) {\n throw new TypeError(\"[SixbModels] maxOutputTokens must be a positive safe integer.\")\n }\n if (!Number.isInteger(input.maxSteps) || input.maxSteps <= 0) {\n throw new TypeError(\"[SixbModels] maxSteps must be a positive integer.\")\n }\n if (!input.model.providerId.trim() || !input.model.modelId.trim()) {\n throw new TypeError(\"[SixbModels] Model providerId and modelId must not be empty.\")\n }\n if (\n input.model.definition.providerId !== input.model.providerId ||\n input.model.definition.modelId !== input.model.modelId\n ) {\n throw new TypeError(\n `[SixbModels] Model definition for '${input.model.providerId}/${input.model.modelId}' has a different identity.`\n )\n }\n if (input.output) {\n if (!input.output.name.trim()) {\n throw new TypeError(\"[SixbModels] Structured output names must not be empty.\")\n }\n assertJsonObject(input.output.schema, \"structured output schema\")\n }\n}\n\nfunction indexTools(tools: readonly ModelTool[]): ReadonlyMap<string, ModelTool> {\n const result = new Map<string, ModelTool>()\n for (const tool of tools) {\n if (!tool.name.trim()) throw new TypeError(\"[SixbModels] Tool names must not be empty.\")\n if (result.has(tool.name)) {\n throw new TypeError(`[SixbModels] Duplicate tool name '${tool.name}'.`)\n }\n assertJsonObject(tool.inputSchema, `tool '${tool.name}' input schema`)\n result.set(tool.name, tool)\n }\n return result\n}\n\nfunction responseText(response: CompletedResponse): string {\n return response.content\n .filter((part): part is ModelTextPart => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\")\n}\n\nfunction structuredOutputErrorContext(\n input: RunModelLoopInput<unknown>,\n response: CompletedResponse,\n responseId: string,\n cost: ModelCallCost,\n text: string\n) {\n return {\n text,\n providerId: input.model.providerId,\n modelId: input.model.modelId,\n responseId,\n ...(response.responseModelId === undefined\n ? {}\n : { responseModelId: response.responseModelId }),\n finishReason: response.finishReason,\n usage: response.usage,\n cost,\n }\n}\n\nfunction modelStep(\n response: CompletedResponse,\n responseId: string,\n content: readonly ModelAssistantPart[],\n cost: import(\"../models/pricing\").ModelCallCost\n): ModelStep {\n return {\n content,\n finishReason: response.finishReason,\n ...(response.rawFinishReason === undefined\n ? {}\n : { rawFinishReason: response.rawFinishReason }),\n usage: response.usage,\n responseId,\n ...(response.responseModelId === undefined\n ? {}\n : { responseModelId: response.responseModelId }),\n cost,\n ...(response.route === undefined ? {} : { route: response.route }),\n }\n}\n\nasync function executeToolCall(\n call: ParsedToolCall,\n tools: ReadonlyMap<string, ModelTool>,\n callId: string,\n signal: AbortSignal,\n onEvent: RunModelLoopInput[\"onEvent\"]\n): Promise<ModelToolResultPart> {\n const { part } = call\n if (call.inputError) {\n const errorText = `Tool input is not valid JSON: ${call.inputError.message}`\n await onEvent?.({\n type: \"tool-input-error\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: part.input,\n errorText,\n })\n return toolErrorResult(part, errorText)\n }\n\n const tool = tools.get(part.toolName)\n if (!tool) {\n const errorText = `Tool '${part.toolName}' is not available.`\n await onEvent?.({\n type: \"tool-output-error\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n errorText,\n })\n return toolErrorResult(part, errorText)\n }\n\n let parsed: unknown\n try {\n parsed = tool.parseInput(part.input)\n } catch (error) {\n const errorText = error instanceof Error ? error.message : \"Tool input validation failed.\"\n await onEvent?.({\n type: \"tool-input-error\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: part.input,\n errorText,\n })\n return toolErrorResult(part, errorText)\n }\n\n await onEvent?.({\n type: \"tool-input-available\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: part.input,\n })\n let output: JsonValue\n let modelOutput: ModelToolOutput\n try {\n const context = { signal, callId, toolCallId: part.toolCallId }\n output = await tool.execute(parsed, context)\n assertJsonValue(output, `tool '${part.toolName}' output`)\n modelOutput = tool.toModelOutput\n ? await tool.toModelOutput(output, context)\n : modelToolOutput(output)\n validateModelToolOutput(modelOutput, part.toolName)\n } catch (error) {\n const errorText = tool.errorText(error)\n await onEvent?.({\n type: \"tool-output-error\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n errorText,\n })\n return toolErrorResult(part, errorText)\n }\n // Publication failures belong to the caller, not the tool's recoverable error channel.\n await onEvent?.({\n type: \"tool-output-available\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n output,\n })\n return {\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n output: modelOutput,\n ...(modelOutputMatchesOriginal(modelOutput, output) ? {} : { originalOutput: output }),\n }\n}\n\nfunction validateModelToolOutput(output: ModelToolOutput, toolName: string): void {\n if (output.type === \"text\" || output.type === \"error-text\") {\n if (typeof output.value !== \"string\") {\n throw new TypeError(`[SixbModels] Tool '${toolName}' model output must contain text.`)\n }\n return\n }\n if (output.type !== \"json\" && output.type !== \"error-json\") {\n throw new TypeError(\n `[SixbModels] Tool '${toolName}' returned an unsupported model output type.`\n )\n }\n assertJsonValue(output.value, `tool '${toolName}' model output`)\n}\n\nfunction modelOutputMatchesOriginal(output: ModelToolOutput, original: JsonValue): boolean {\n if (output.type === \"text\") return typeof original === \"string\" && output.value === original\n if (output.type === \"json\") return output.value === original\n return false\n}\n\nfunction modelToolOutput(value: JsonValue): ModelToolOutput {\n return typeof value === \"string\" ? { type: \"text\", value } : { type: \"json\", value }\n}\n\nfunction toolErrorResult(part: ModelToolCallPart, errorText: string): ModelToolResultPart {\n if (typeof errorText !== \"string\") {\n throw new TypeError(`[SixbModels] Tool '${part.toolName}' error text must be a string.`)\n }\n return {\n type: \"tool-result\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n output: { type: \"error-text\", value: errorText },\n }\n}\n\ntype MutableTextPart = {\n type: \"text\"\n text: string\n providerData?: ProviderData\n complete: boolean\n}\ntype MutableReasoningPart = {\n type: \"reasoning\"\n text: string\n providerData?: ProviderData\n complete: boolean\n}\ntype MutableToolCall = {\n type: \"tool-call\"\n toolCallId: string\n toolName: string\n inputText: string\n providerData?: ProviderData\n providerExecuted?: boolean\n dynamic?: boolean\n complete: boolean\n}\ntype MutablePart =\n | MutableTextPart\n | MutableReasoningPart\n | MutableToolCall\n | ModelToolResultPart\n | ModelProviderStatePart\n\nclass StreamAccumulator {\n private readonly parts: MutablePart[] = []\n private readonly spans = new Map<string, MutableTextPart | MutableReasoningPart>()\n private readonly toolCalls = new Map<string, MutableToolCall>()\n private started = false\n private finished = false\n private finishReason: ModelFinishReason | undefined\n private rawFinishReason: string | undefined\n private usage: ModelUsage = {}\n private responseId: string | undefined\n private providerIds: import(\"../models/events\").ModelProviderIds | undefined\n private responseModelId: string | undefined\n private projectionError: Error | undefined\n private reportedCost: ModelReportedCost | undefined\n private route: import(\"../models/events\").ModelRoute | undefined\n\n constructor(private readonly onEvent: RunModelLoopInput[\"onEvent\"]) {}\n\n isFinished(): boolean {\n return this.finished\n }\n\n async accept(event: LanguageModelStreamEvent): Promise<void> {\n if (this.finished) {\n throw new ModelStreamError(`[SixbModels] Received '${event.type}' after stream finish.`)\n }\n switch (event.type) {\n case \"stream-start\":\n if (this.started) throw new ModelStreamError(\"[SixbModels] Duplicate stream-start event.\")\n this.started = true\n return\n case \"response-metadata\":\n this.requireStarted(event.type)\n this.responseId = event.id ?? this.responseId\n if (event.providerIds) this.providerIds = { ...this.providerIds, ...event.providerIds }\n this.responseModelId = event.modelId ?? this.responseModelId\n return\n case \"text-start\":\n await this.startText(event)\n return\n case \"text-delta\":\n await this.appendText(event, \"text\")\n return\n case \"text-end\":\n await this.endText(event, \"text\")\n return\n case \"reasoning-start\":\n await this.startReasoning(event)\n return\n case \"reasoning-delta\":\n await this.appendText(event, \"reasoning\")\n return\n case \"reasoning-end\":\n await this.endText(event, \"reasoning\")\n return\n case \"tool-input-start\":\n await this.startTool(event)\n return\n case \"tool-input-delta\":\n await this.appendTool(event)\n return\n case \"tool-input-end\":\n this.endTool(event)\n return\n case \"tool-call\":\n await this.completeTool(event)\n return\n case \"tool-result\":\n this.addProviderToolResult(event)\n return\n case \"provider-state\":\n if (typeof event.providerId !== \"string\" || event.providerId.length === 0) {\n this.captureProjectionError(\n new ModelStreamError(\"[SixbModels] Provider state requires a nonempty provider ID.\")\n )\n return\n }\n if (this.captureProviderState(event.data)) {\n this.parts.push({\n type: \"provider-state\",\n providerId: event.providerId,\n data: event.data,\n })\n }\n return\n case \"finish\":\n this.requireStarted(event.type)\n validateUsage(event.usage)\n this.captureProviderData(event.providerData)\n this.finished = true\n this.finishReason = event.finishReason\n this.rawFinishReason = event.rawFinishReason\n this.usage = event.usage\n this.reportedCost = event.reportedCost\n this.route = event.route\n return\n case \"error\":\n throw event.error instanceof Error\n ? event.error\n : new ModelProviderError(\"[SixbModels] Provider stream failed.\", \"unknown\", \"unknown\", {\n cause: event.error,\n })\n }\n }\n\n complete(): CompletedResponse {\n if (!this.started) throw new ModelStreamError(\"[SixbModels] Stream did not start.\")\n if (!this.finished || !this.finishReason) {\n throw new ModelStreamError(\"[SixbModels] Stream ended without a finish event.\")\n }\n for (const part of this.parts) {\n if (\"complete\" in part && !part.complete) {\n throw new ModelStreamError(\n `[SixbModels] Stream finished with incomplete ${part.type} content.`\n )\n }\n }\n const parsed = this.parseParts(false)\n return {\n content: parsed.content,\n toolCalls: parsed.toolCalls,\n finishReason: this.finishReason,\n ...(this.rawFinishReason === undefined ? {} : { rawFinishReason: this.rawFinishReason }),\n ...this.accounting(),\n ...(this.projectionError === undefined ? {} : { projectionError: this.projectionError }),\n }\n }\n\n accounting() {\n return {\n usage: this.usage,\n ...(this.responseId === undefined ? {} : { responseId: this.responseId }),\n ...(this.providerIds === undefined ? {} : { providerIds: this.providerIds }),\n ...(this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId }),\n ...(this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost }),\n ...(this.route === undefined ? {} : { route: this.route }),\n }\n }\n\n partialContent(): readonly ModelAssistantPart[] {\n return this.parseParts(true).content\n }\n\n private parseParts(partial: boolean): {\n readonly content: ModelAssistantPart[]\n readonly toolCalls: ParsedToolCall[]\n } {\n const content: ModelAssistantPart[] = []\n const toolCalls: ParsedToolCall[] = []\n for (const part of this.parts) {\n if (part.type === \"text\") {\n if ((!partial || part.text.length > 0) && (part.complete || partial)) {\n content.push({\n type: \"text\",\n text: part.text,\n ...(part.providerData === undefined ? {} : { providerData: part.providerData }),\n })\n }\n } else if (part.type === \"reasoning\") {\n if (part.complete) {\n content.push({\n type: \"reasoning\",\n text: part.text,\n ...(part.providerData === undefined ? {} : { providerData: part.providerData }),\n })\n }\n } else if (part.type === \"tool-call\") {\n if (!part.complete) continue\n let value: JsonValue = null\n let inputError: Error | undefined\n try {\n const parsed: unknown = JSON.parse(part.inputText)\n if (!isJsonValue(parsed)) throw new TypeError(\"input is not a JSON value\")\n value = parsed\n } catch (error) {\n inputError = error instanceof Error ? error : new Error(String(error))\n }\n const call: ModelToolCallPart = {\n type: \"tool-call\",\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n input: value,\n ...(part.providerData === undefined ? {} : { providerData: part.providerData }),\n ...(part.providerExecuted === undefined\n ? {}\n : { providerExecuted: part.providerExecuted }),\n ...(part.dynamic === undefined ? {} : { dynamic: part.dynamic }),\n }\n content.push(call)\n toolCalls.push({ part: call, ...(inputError === undefined ? {} : { inputError }) })\n } else {\n content.push(part)\n }\n }\n return { content, toolCalls }\n }\n\n private async startText(\n event: Extract<LanguageModelStreamEvent, { type: \"text-start\" }>\n ): Promise<void> {\n this.requireStarted(event.type)\n this.assertNewSpan(event.id)\n const providerData = this.captureProviderData(event.providerData)\n const part: MutableTextPart = {\n type: \"text\",\n text: \"\",\n complete: false,\n ...(providerData === undefined ? {} : { providerData }),\n }\n this.spans.set(event.id, part)\n this.parts.push(part)\n await this.onEvent?.({ type: \"text-start\", id: event.id })\n }\n\n private async startReasoning(\n event: Extract<LanguageModelStreamEvent, { type: \"reasoning-start\" }>\n ): Promise<void> {\n this.requireStarted(event.type)\n this.assertNewSpan(event.id)\n const providerData = this.captureProviderData(event.providerData)\n const part: MutableReasoningPart = {\n type: \"reasoning\",\n text: \"\",\n complete: false,\n ...(providerData === undefined ? {} : { providerData }),\n }\n this.spans.set(event.id, part)\n this.parts.push(part)\n await this.onEvent?.({ type: \"reasoning-start\", id: event.id })\n }\n\n private async appendText(\n event: Extract<LanguageModelStreamEvent, { type: \"text-delta\" | \"reasoning-delta\" }>,\n expected: \"text\" | \"reasoning\"\n ): Promise<void> {\n const part = this.spans.get(event.id)\n if (!part || part.type !== expected || part.complete) {\n throw new ModelStreamError(\n `[SixbModels] ${event.type} references unopened ${expected} span '${event.id}'.`\n )\n }\n part.text += event.delta\n await this.onEvent?.({ type: event.type, id: event.id, delta: event.delta })\n }\n\n private async endText(\n event: Extract<LanguageModelStreamEvent, { type: \"text-end\" | \"reasoning-end\" }>,\n expected: \"text\" | \"reasoning\"\n ): Promise<void> {\n const part = this.spans.get(event.id)\n if (!part || part.type !== expected || part.complete) {\n throw new ModelStreamError(\n `[SixbModels] ${event.type} references unopened ${expected} span '${event.id}'.`\n )\n }\n part.providerData = mergeProviderData(\n part.providerData,\n this.captureProviderData(event.providerData)\n )\n part.complete = true\n this.spans.delete(event.id)\n await this.onEvent?.({ type: event.type, id: event.id })\n }\n\n private async startTool(\n event: Extract<LanguageModelStreamEvent, { type: \"tool-input-start\" }>\n ): Promise<void> {\n this.requireStarted(event.type)\n if (\n typeof event.id !== \"string\" ||\n !event.id ||\n typeof event.toolName !== \"string\" ||\n !event.toolName\n ) {\n throw new ModelStreamError(\"[SixbModels] Tool calls require nonempty IDs and names.\")\n }\n if (this.toolCalls.has(event.id)) {\n throw new ModelStreamError(`[SixbModels] Duplicate tool call ID '${event.id}'.`)\n }\n const providerData = this.captureProviderData(event.providerData)\n const part: MutableToolCall = {\n type: \"tool-call\",\n toolCallId: event.id,\n toolName: event.toolName,\n inputText: \"\",\n complete: false,\n ...(providerData === undefined ? {} : { providerData }),\n ...(event.providerExecuted === undefined ? {} : { providerExecuted: event.providerExecuted }),\n ...(event.dynamic === undefined ? {} : { dynamic: event.dynamic }),\n }\n this.toolCalls.set(event.id, part)\n this.parts.push(part)\n await this.onEvent?.({\n type: \"tool-input-start\",\n toolCallId: event.id,\n toolName: event.toolName,\n })\n }\n\n private async appendTool(\n event: Extract<LanguageModelStreamEvent, { type: \"tool-input-delta\" }>\n ): Promise<void> {\n const part = this.toolCalls.get(event.id)\n if (!part || part.complete) {\n throw new ModelStreamError(\n `[SixbModels] tool-input-delta references unopened tool call '${event.id}'.`\n )\n }\n part.inputText += event.delta\n await this.onEvent?.({\n type: \"tool-input-delta\",\n toolCallId: event.id,\n toolName: part.toolName,\n inputTextDelta: event.delta,\n })\n }\n\n private endTool(event: Extract<LanguageModelStreamEvent, { type: \"tool-input-end\" }>): void {\n const part = this.toolCalls.get(event.id)\n if (!part || part.complete) {\n throw new ModelStreamError(\n `[SixbModels] tool-input-end references unopened tool call '${event.id}'.`\n )\n }\n part.providerData = mergeProviderData(\n part.providerData,\n this.captureProviderData(event.providerData)\n )\n part.complete = true\n }\n\n private async completeTool(\n event: Extract<LanguageModelStreamEvent, { type: \"tool-call\" }>\n ): Promise<void> {\n await this.startTool({\n type: \"tool-input-start\",\n id: event.toolCallId,\n toolName: event.toolName,\n ...(event.providerData === undefined ? {} : { providerData: event.providerData }),\n ...(event.providerExecuted === undefined ? {} : { providerExecuted: event.providerExecuted }),\n ...(event.dynamic === undefined ? {} : { dynamic: event.dynamic }),\n })\n const part = this.toolCalls.get(event.toolCallId)\n if (!part) throw new ModelStreamError(\"[SixbModels] Failed to index completed tool call.\")\n part.inputText = event.input\n part.complete = true\n }\n\n private addProviderToolResult(\n event: Extract<LanguageModelStreamEvent, { type: \"tool-result\" }>\n ): void {\n if (!this.captureJsonValue(event.output, \"provider tool result\")) return\n const providerData = this.captureProviderData(event.providerData)\n this.parts.push({\n type: \"tool-result\",\n toolCallId: event.toolCallId,\n toolName: event.toolName,\n output: event.isError\n ? { type: \"error-json\", value: event.output }\n : modelToolOutput(event.output),\n providerExecuted: event.providerExecuted ?? true,\n ...(event.dynamic === undefined ? {} : { dynamic: event.dynamic }),\n ...(providerData === undefined ? {} : { providerData }),\n })\n }\n\n private captureProviderData(data: ProviderData | undefined): ProviderData | undefined {\n if (data === undefined) return undefined\n try {\n return normalizeProviderData(data)\n } catch (error) {\n this.captureProjectionError(error)\n return undefined\n }\n }\n\n private captureProviderState(value: unknown): value is JsonValue {\n if (!this.captureJsonValue(value, \"provider state\")) return false\n if (JSON.stringify(value).length > MAX_PROVIDER_DATA_BYTES) {\n this.captureProjectionError(\n new ModelStreamError(\n `[SixbModels] Provider state exceeds the ${MAX_PROVIDER_DATA_BYTES}-byte response limit.`\n )\n )\n return false\n }\n return true\n }\n\n private captureJsonValue(value: unknown, label: string): value is JsonValue {\n try {\n assertJsonValue(value, label)\n return true\n } catch (error) {\n this.captureProjectionError(error)\n return false\n }\n }\n\n private captureProjectionError(error: unknown): void {\n this.projectionError ??= error instanceof Error ? error : new Error(String(error))\n }\n\n private requireStarted(type: string): void {\n if (!this.started) {\n throw new ModelStreamError(`[SixbModels] Received '${type}' before stream-start.`)\n }\n }\n\n private assertNewSpan(id: string): void {\n if (!id) throw new ModelStreamError(\"[SixbModels] Content span IDs must not be empty.\")\n if (this.spans.has(id)) {\n throw new ModelStreamError(`[SixbModels] Duplicate open content span '${id}'.`)\n }\n }\n}\n\nfunction validateUsage(usage: ModelUsage): void {\n for (const [key, value] of Object.entries(usage)) {\n if (key === \"raw\") {\n if (value !== undefined) assertJsonValue(value, \"raw model usage\")\n continue\n }\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new ModelStreamError(`[SixbModels] Usage field '${key}' must be a nonnegative integer.`)\n }\n }\n}\n\nfunction normalizeProviderData(value: ProviderData): ProviderData {\n const data = omitUndefinedObjectProperties(value)\n assertJsonValue(data, \"provider data\")\n if (typeof data !== \"object\" || data === null || Array.isArray(data)) {\n throw new TypeError(\"[SixbModels] provider data must be a JSON object.\")\n }\n if (JSON.stringify(data).length > MAX_PROVIDER_DATA_BYTES) {\n throw new ModelStreamError(\n `[SixbModels] Provider data exceeds the ${MAX_PROVIDER_DATA_BYTES}-byte response limit.`\n )\n }\n return data\n}\n\n/** Normalize absent metadata fields at ingestion, leaving non-JSON values for validation. */\nfunction omitUndefinedObjectProperties(value: unknown, seen = new Set<object>()): unknown {\n if (typeof value !== \"object\" || value === null || seen.has(value)) return value\n seen.add(value)\n try {\n if (Array.isArray(value)) {\n return value.map((entry) => omitUndefinedObjectProperties(entry, seen))\n }\n if (!isPlainRecord(value)) return value\n return Object.fromEntries(\n Reflect.ownKeys(value)\n .filter((key) => Object.prototype.propertyIsEnumerable.call(value, key))\n .map((key) => [key, Reflect.get(value, key)] as const)\n .filter(([, entry]) => entry !== undefined)\n .map(([key, entry]) => [key, omitUndefinedObjectProperties(entry, seen)])\n )\n } finally {\n seen.delete(value)\n }\n}\n\nfunction mergeProviderData(\n first: ProviderData | undefined,\n second: ProviderData | undefined\n): ProviderData | undefined {\n if (first === undefined) return second\n if (second === undefined) return first\n return { ...first, ...second }\n}\n\nfunction isAbortError(error: unknown): boolean {\n return (\n (error instanceof DOMException && error.name === \"AbortError\") ||\n (error instanceof Error && error.name === \"AbortError\")\n )\n}\n",
|
|
14
|
-
"import type { AgentReference } from \"./types\"\n\n/** Project Agent capability used in security grants such as `can.run(agent)`. */\nexport const agent: AgentReference = Object.freeze({\n kind: \"agent\",\n usage: Object.freeze({ kind: \"aiUsage\" }),\n})\n",
|
|
15
|
-
"import type { AgentContextCheckpointRecord, AgentMessageRecord } from \"../storage/agents/types\"\nimport type { AgentMessage } from \"./message\"\n\n/** A model-only message. Persisted tail messages carry `id`; the synthetic summary does not. */\nexport interface AgentThreadModelContextMessage extends AgentMessage {\n readonly id?: string\n}\n\nexport interface ProjectAgentThreadModelContextInput {\n readonly checkpoint: AgentContextCheckpointRecord | null\n /** Complete retained tail, ordered by ascending per-thread sequence. */\n readonly messages: readonly AgentMessageRecord[]\n}\n\n/**\n * Build the bounded, model-only view of a durable thread.\n *\n * The function is deliberately pure: storage chooses the latest checkpoint and reads its retained\n * tail; this function validates that projection and prepends one synthetic user-role summary.\n */\nexport function projectAgentThreadModelContext(\n input: ProjectAgentThreadModelContextInput\n): readonly AgentThreadModelContextMessage[] {\n const { checkpoint, messages } = input\n if (!checkpoint) return messages\n\n assertConsistentCheckpointProjection(checkpoint, messages)\n return [\n {\n role: \"user\",\n parts: [{ type: \"text\", text: serializeThreadSummary(checkpoint.summary) }],\n },\n ...messages,\n ]\n}\n\nfunction assertConsistentCheckpointProjection(\n checkpoint: AgentContextCheckpointRecord,\n messages: readonly AgentMessageRecord[]\n): void {\n if (checkpoint.summaryFormatVersion !== 1 || checkpoint.summary.trim().length === 0) {\n throw projectionError(checkpoint, \"has an invalid summary\")\n }\n if (checkpoint.summarizedThroughSeq >= checkpoint.observedHeadSeq) {\n throw projectionError(checkpoint, \"does not retain its observed head\")\n }\n if (messages.length === 0) {\n throw projectionError(checkpoint, \"has no retained messages\")\n }\n\n let expectedSeq = checkpoint.summarizedThroughSeq + 1\n for (const message of messages) {\n if (message.projectId !== checkpoint.projectId || message.threadId !== checkpoint.threadId) {\n throw projectionError(checkpoint, \"contains a message from another thread\")\n }\n if (message.seq !== expectedSeq) {\n throw projectionError(checkpoint, `has a sequence gap before message '${message.id}'`)\n }\n expectedSeq += 1\n }\n\n if (messages[0]?.role !== \"user\") {\n throw projectionError(checkpoint, \"does not begin at a user turn boundary\")\n }\n if ((messages.at(-1)?.seq ?? 0) < checkpoint.observedHeadSeq) {\n throw projectionError(checkpoint, \"ends before the checkpoint's observed head\")\n }\n}\n\nfunction serializeThreadSummary(summary: string): string {\n return [\n \"The earlier conversation was compacted into this continuation summary.\",\n \"\",\n \"<sixb_thread_summary>\",\n escapeXml(summary),\n \"</sixb_thread_summary>\",\n ].join(\"\\n\")\n}\n\nfunction projectionError(checkpoint: AgentContextCheckpointRecord, detail: string): Error {\n return new Error(\n `[Sixb] Agent context checkpoint '${checkpoint.id}' for thread '${checkpoint.threadId}' ${detail}.`\n )\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\")\n}\n"
|
|
16
|
-
],
|
|
17
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,6BAA6B,CAC3C,OACoB;AAAA,EACpB,IAAI,MAAM,WAAW;AAAA,IAAG;AAAA,EAExB,MAAM,QAAQ,CAAC,qBAAqB;AAAA,EACpC,WAAW,QAAQ,OAAO;AAAA,IACxB,IAAI,KAAK,QAAQ,SAAS,UAAU;AAAA,MAClC,MAAM,KACJ,sBACA,uBAAuB,UAAU,KAAK,QAAQ,IAAI,YAAY,sBAC9D,mBAAmB,UAAU,KAAK,QAAQ,IAAI,SAAS,kBACvD,qBACF;AAAA,MACA;AAAA,IACF;AAAA,IAEA,MAAM,KACJ,yBACA,WAAW,UAAU,KAAK,QAAQ,EAAE,UACpC,oBAAoB,UAAU,KAAK,QAAQ,WAAW,mBACtD,4BAA4B,UAAU,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A,EACxF,OAAO,IAAI,MACT,oCAAoC,WAAW,mBAAmB,WAAW,aAAa,SAC5F;AAAA;AAGF,SAAS,UAAS,CAAC,OAAuB;AAAA,EACxC,OAAO,MACJ,WAAW,KAAK,OAAO,EACvB,WAAW,KAAK,MAAM,EACtB,WAAW,KAAK,MAAM,EACtB,WAAW,KAAK,QAAQ,EACxB,WAAW,KAAK,QAAQ;AAAA;",
|
|
18
|
-
"debugId": "5E06D21E695131D964756E2164756E21",
|
|
19
|
-
"names": []
|
|
20
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/agents/errors.ts", "../src/agents/context.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Base error for the agents module. Specific subclasses extend this so callers\n * can catch any agent-scoped failure with a single `instanceof AgentDefinitionError` check.\n */\nexport class AgentDefinitionError extends Error {\n readonly name: string = \"AgentDefinitionError\"\n}\n\n/**\n * An agent-tool failure whose message is intentionally safe to expose to the model and persist in\n * the durable trace. Tool authors must keep the message free of credentials and internal details;\n * unknown errors remain masked by the worker.\n */\nexport class AgentToolPublicError extends Error {\n readonly name: string = \"AgentToolPublicError\"\n}\n\n/** Raised when an agent tool result cannot cross the durable message boundary. */\nexport class AgentToolResultValidationError extends Error {\n readonly name = \"AgentToolResultValidationError\"\n\n constructor(\n readonly toolName: string,\n readonly reason: string,\n options?: ErrorOptions\n ) {\n super(`[Sixb] Agent tool '${toolName}' returned an invalid result; ${reason}.`, options)\n }\n}\n\nexport type AgentRequestErrorCode =\n | \"agent_selector_removed\"\n | \"agent_not_found\"\n | \"model_not_found\"\n | \"invalid_model_selection\"\n | \"run_not_found\"\n | \"run_not_retryable\"\n | \"thread_not_found\"\n | \"active_run_exists\"\n | \"authority_not_inheritable\"\n | \"invalid_context\"\n | \"storage_unavailable\"\n\n/**\n * Raised by {@link requestAgentRun} (the trigger). Callers branch on `code` rather than message text\n * — e.g. the HTTP layer maps `active_run_exists` to 409 and `agent_not_found` to 404.\n */\nexport class AgentRequestError extends Error {\n readonly name = \"AgentRequestError\"\n\n constructor(\n readonly code: AgentRequestErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n",
|
|
6
|
-
"import type { JsonValue } from \"../json\"\nimport { cloneJsonValue, getInvalidJsonValueReason, stableJsonStringify } from \"../json\"\nimport type { ObjectRef } from \"../ontology/refs\"\nimport { AgentRequestError } from \"./errors\"\n\nexport type AgentContextInput =\n | { readonly kind: \"object\"; readonly ref: ObjectRef }\n | {\n readonly kind: \"app-state\"\n readonly id: string\n readonly label: string\n readonly description: string\n readonly value: JsonValue\n }\n\nexport type AgentContextOrigin = \"ambient\" | \"explicit\"\n\nexport interface AgentContextEntryInput {\n readonly context: AgentContextInput\n readonly origin: AgentContextOrigin\n}\n\n/** Durable user-message part. Origin is display provenance, never an authorization grant. */\nexport interface AgentContextPart extends AgentContextEntryInput {\n readonly type: \"context\"\n}\n\nexport const MAX_AGENT_CONTEXT_ENTRIES = 12\nexport const MAX_AGENT_APP_STATE_ENTRY_BYTES = 16 * 1024\nexport const MAX_AGENT_APP_STATE_TOTAL_BYTES = 64 * 1024\n\n/** Typed constructors for context values shared by custom apps and agent clients. */\nexport const agentContext = {\n object<const TObjectTypeId extends string>(\n objectType: { readonly id: TObjectTypeId },\n primaryId: string\n ) {\n return {\n kind: \"object\" as const,\n ref: { objectTypeId: objectType.id, primaryId },\n }\n },\n\n appState<const TValue extends JsonValue>(\n id: string,\n input: {\n readonly label: string\n readonly description: string\n readonly value: TValue\n }\n ) {\n return { kind: \"app-state\" as const, id, ...input }\n },\n}\n\n/** Stable identity shared by core deduplication and context-aware clients. */\nexport function agentContextIdentity(context: AgentContextInput): string {\n return context.kind === \"object\"\n ? `object:${encodeURIComponent(context.ref.objectTypeId)}:${encodeURIComponent(context.ref.primaryId)}`\n : `app-state:${encodeURIComponent(context.id)}`\n}\n\n/** Stable semantic key for client-side comparisons. */\nexport function agentContextFingerprint(context: AgentContextInput): string {\n return stableJsonStringify(context)\n}\n\n/**\n * Validate transport-independent context rules and clone mutable app state before it can become\n * durable. Object existence and visibility are resolved separately because they require a runtime.\n */\nexport function normalizeAgentContextEntries(\n input: readonly AgentContextEntryInput[] | undefined\n): readonly AgentContextEntryInput[] {\n if (input === undefined) return []\n if (!Array.isArray(input)) invalidContext(\"context must be an array\")\n if (input.length > MAX_AGENT_CONTEXT_ENTRIES) {\n invalidContext(`context cannot contain more than ${MAX_AGENT_CONTEXT_ENTRIES} entries`)\n }\n\n const entries: AgentContextEntryInput[] = []\n const byIdentity = new Map<string, string>()\n let totalAppStateBytes = 0\n\n for (const [index, rawEntry] of input.entries()) {\n const entry = normalizeEntry(rawEntry, index)\n const identity = agentContextIdentity(entry.context)\n const serialized = stableJsonStringify(entry)\n const existing = byIdentity.get(identity)\n\n if (existing !== undefined) {\n if (existing === serialized) continue\n invalidContext(`context contains conflicting entries for '${identity}'`)\n }\n\n if (entry.context.kind === \"app-state\") {\n const bytes = utf8ByteLength(serialized)\n if (bytes > MAX_AGENT_APP_STATE_ENTRY_BYTES) {\n invalidContext(\n `context entry '${identity}' exceeds the ${MAX_AGENT_APP_STATE_ENTRY_BYTES}-byte limit`\n )\n }\n totalAppStateBytes += bytes\n if (totalAppStateBytes > MAX_AGENT_APP_STATE_TOTAL_BYTES) {\n invalidContext(\n `app-state context exceeds the ${MAX_AGENT_APP_STATE_TOTAL_BYTES}-byte message limit`\n )\n }\n }\n\n byIdentity.set(identity, serialized)\n entries.push(entry)\n }\n\n return entries\n}\n\nfunction normalizeEntry(rawEntry: unknown, index: number): AgentContextEntryInput {\n if (!isRecord(rawEntry)) invalidContext(`context[${index}] must be an object`)\n if (rawEntry.origin !== \"ambient\" && rawEntry.origin !== \"explicit\") {\n invalidContext(`context[${index}].origin must be 'ambient' or 'explicit'`)\n }\n if (!isRecord(rawEntry.context)) invalidContext(`context[${index}].context must be an object`)\n\n const context = rawEntry.context\n if (context.kind === \"object\") {\n if (!isRecord(context.ref)) invalidContext(`context[${index}].context.ref must be an object`)\n const objectTypeId = requireNonEmptyString(\n context.ref.objectTypeId,\n `context[${index}].context.ref.objectTypeId`\n )\n const primaryId = requireNonEmptyString(\n context.ref.primaryId,\n `context[${index}].context.ref.primaryId`\n )\n return {\n context: { kind: \"object\", ref: { objectTypeId, primaryId } },\n origin: rawEntry.origin,\n }\n }\n\n if (context.kind === \"app-state\") {\n const id = requireNonEmptyString(context.id, `context[${index}].context.id`)\n const label = requireNonEmptyString(context.label, `context[${index}].context.label`)\n const description = requireNonEmptyString(\n context.description,\n `context[${index}].context.description`\n )\n const reason = getInvalidJsonValueReason(context.value, `context[${index}].context.value`)\n if (reason) {\n invalidContext(`context[${index}].context.value must be a JSON value; ${reason}`)\n }\n return {\n context: {\n kind: \"app-state\",\n id,\n label,\n description,\n value: cloneJsonValue(context.value as JsonValue),\n },\n origin: rawEntry.origin,\n }\n }\n\n invalidContext(`context[${index}].context.kind must be 'object' or 'app-state'`)\n}\n\nfunction requireNonEmptyString(value: unknown, label: string): string {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n invalidContext(`${label} must be a non-empty string`)\n }\n return value\n}\n\nfunction utf8ByteLength(value: string): number {\n return new TextEncoder().encode(value).byteLength\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction invalidContext(message: string): never {\n throw new AgentRequestError(\"invalid_context\", `[Sixb] Invalid agent context: ${message}.`)\n}\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": ";;;;;;;;AAIO,MAAM,6BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAOO,MAAM,6BAA6B,MAAM;AAAA,EACrC,OAAe;AAC1B;AAAA;AAGO,MAAM,uCAAuC,MAAM;AAAA,EAI7C;AAAA,EACA;AAAA,EAJF,OAAO;AAAA,EAEhB,WAAW,CACA,UACA,QACT,SACA;AAAA,IACA,MAAM,sBAAsB,y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3,
|
|
3
|
-
"sources": ["../src/storage/connector-connections/errors.ts", "../src/storage/connector-connections/types.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export type ConnectorConnectionStorageErrorCode =\n | \"attempt_conflict\"\n | \"attempt_invalid\"\n | \"run_conflict\"\n | \"run_invalid\"\n | \"authorization_conflict\"\n | \"connection_conflict\"\n | \"invalid_input\"\n\n/**\n * Storage-provider control signal for atomic conflicts and invalid calls.\n *\n * These codes belong to the provider contract, not `SixbErrorCode`; Core translates errors that\n * cross the connector lifecycle boundary into documented `connector.*` failures.\n */\nexport class ConnectorConnectionStorageError extends Error {\n readonly code: ConnectorConnectionStorageErrorCode\n\n constructor(code: ConnectorConnectionStorageErrorCode, message: string) {\n super(message)\n this.name = \"ConnectorConnectionStorageError\"\n this.code = code\n }\n}\n",
|
|
6
|
-
"import type { ConnectorAccountCandidate, ConnectorConnectionSelector } from \"../../connectors\"\nimport type { SealedConnectorCredential } from \"../../connectors/credentials\"\nimport type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { AuthorizablePrincipal } from \"../../execution\"\n\nexport type {\n ConnectorConnectionOwner,\n ConnectorConnectionSelector,\n ProjectConnectorConnectionOwner,\n} from \"../../connectors\"\n\nexport const CONNECTOR_CONNECTION_RUN_FAILURE_CODES = [\n \"internal.unexpected\",\n \"connector.adapter_invalid\",\n \"connector.authorization_invalid\",\n \"connector.authorization_required\",\n \"connector.credentials_unavailable\",\n \"connector.not_found\",\n \"connector.operation_conflict\",\n \"connector.operation_in_progress\",\n \"connector.provider_failed\",\n \"connector.provider_unavailable\",\n] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]\n\nexport type ConnectorConnectionRunFailureCode =\n (typeof CONNECTOR_CONNECTION_RUN_FAILURE_CODES)[number]\nexport type ConnectorConnectionRunFailure = SixbFailure<ConnectorConnectionRunFailureCode>\nexport type ConnectorConnectionRunKind = \"connect\" | \"reauthorize\"\n\ninterface ConnectorConnectionRunBase extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly kind: ConnectorConnectionRunKind\n /** Durable request execution that initiated and is allowed to manage this run. */\n readonly initiatedByExecutionId: string\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface ConnectorConnectionRunAwaitingProviderRecord extends ConnectorConnectionRunBase {\n readonly status: \"waiting\"\n readonly waitingFor: \"provider_authorization\"\n readonly expiresAt: Date\n}\n\nexport interface ConnectorConnectionRunProcessingRecord extends ConnectorConnectionRunBase {\n readonly status: \"running\"\n /** Fences every callback-side write after the one-shot OAuth attempt was consumed. */\n readonly processingId: string\n readonly callbackStartedAt: Date\n readonly expiresAt: Date\n /** Internal grant handle, attached as soon as a new authorization is durably persisted. */\n readonly authorizationId?: string\n}\n\nexport interface ConnectorConnectionRunAwaitingSelectionRecord extends ConnectorConnectionRunBase {\n readonly status: \"waiting\"\n readonly waitingFor: \"account_selection\"\n readonly authorizationId: string\n readonly expiresAt: Date\n}\n\nexport interface ConnectorConnectionRunSucceededRecord extends ConnectorConnectionRunBase {\n readonly status: \"succeeded\"\n readonly authorizationId: string\n /** Internal handle for a replaced grant whose provider cleanup is still retryable. */\n readonly cleanupAuthorizationId?: string\n readonly connections: readonly ConnectorConnectionRecord[]\n readonly finishedAt: Date\n}\n\nexport interface ConnectorConnectionRunFailedRecord extends ConnectorConnectionRunBase {\n readonly status: \"failed\"\n readonly error: ConnectorConnectionRunFailure\n /** Internal cleanup handle; never serialized by the Headless API. */\n readonly authorizationId?: string\n readonly finishedAt: Date\n}\n\nexport interface ConnectorConnectionRunCancelledRecord extends ConnectorConnectionRunBase {\n readonly status: \"cancelled\"\n readonly authorizationId?: string\n readonly finishedAt: Date\n}\n\nexport interface ConnectorConnectionRunExpiredRecord extends ConnectorConnectionRunBase {\n readonly status: \"expired\"\n readonly authorizationId?: string\n readonly finishedAt: Date\n}\n\nexport type ConnectorConnectionRunRecord =\n | ConnectorConnectionRunAwaitingProviderRecord\n | ConnectorConnectionRunProcessingRecord\n | ConnectorConnectionRunAwaitingSelectionRecord\n | ConnectorConnectionRunSucceededRecord\n | ConnectorConnectionRunFailedRecord\n | ConnectorConnectionRunCancelledRecord\n | ConnectorConnectionRunExpiredRecord\n\nexport interface CreateConnectorConnectionRunInput extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly kind: ConnectorConnectionRunKind\n readonly initiatedByExecutionId: string\n readonly ttlMs: number\n}\n\nexport interface CreateConnectorConnectionSelectionRunInput extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly initiatedByExecutionId: string\n readonly authorizationId: string\n readonly ttlMs: number\n}\n\nexport interface ClaimConnectorConnectionRunCallbackInput {\n readonly projectId: string\n readonly attemptId: string\n readonly stateHash: string\n readonly callbackBindingHash: string\n readonly redirectUri: string\n readonly processingId: string\n readonly processingTtlMs: number\n}\n\nexport type ClaimConnectorConnectionRunCallbackResult =\n | {\n readonly type: \"claimed\"\n readonly run: ConnectorConnectionRunProcessingRecord\n readonly attempt: ConnectorAuthorizationAttemptRecord\n readonly returnTo: string\n }\n | {\n readonly type: \"expired\"\n readonly run: ConnectorConnectionRunExpiredRecord\n readonly returnTo: string\n }\n\nexport interface WaitForConnectorConnectionRunSelectionInput {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly processingId: string\n readonly authorizationId: string\n readonly expiresAt: Date\n}\n\nexport interface AttachConnectorConnectionRunAuthorizationInput {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly processingId: string\n readonly authorizationId: string\n}\n\nexport type FinishConnectorConnectionRunInput =\n | {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly processingId: string\n readonly status: \"succeeded\"\n readonly authorizationId: string\n readonly cleanupAuthorizationId?: string\n readonly connections: readonly ConnectorConnectionRecord[]\n }\n | {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly processingId: string\n readonly status: \"failed\"\n readonly error: ConnectorConnectionRunFailure\n readonly authorizationId?: string\n }\n | {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly processingId: string\n readonly status: \"cancelled\"\n }\n\nexport interface GetConnectorConnectionRunInput {\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n}\n\nexport interface ConnectorAuthorizationAttemptRecord extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n /** Durable execution that initiated and authorizes completion of this OAuth attempt. */\n readonly initiatedByExecutionId: string\n readonly stateHash: string\n readonly codeVerifier: SealedConnectorCredential\n readonly redirectUri: string\n /** Present only for attempts created by the headless connection-run API. */\n readonly connectionRunId?: string\n /** Fixed, allowlisted continuation consumed with a headless callback. */\n readonly returnTo?: string\n /** Hash of the one-shot browser callback binding secret. */\n readonly callbackBindingHash?: string\n readonly reauthorizationId?: string\n readonly reauthorizationRevision?: number\n readonly reauthorizationConnectionIds?: readonly string[]\n readonly createdAt: Date\n readonly expiresAt: Date\n}\n\nexport interface CreateConnectorAuthorizationAttemptInput extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly initiatedByExecutionId: string\n readonly stateHash: string\n readonly codeVerifier: SealedConnectorCredential\n readonly redirectUri: string\n readonly connectionRunId?: string\n readonly returnTo?: string\n readonly callbackBindingHash?: string\n readonly reauthorizationId?: string\n readonly reauthorizationRevision?: number\n readonly reauthorizationConnectionIds?: readonly string[]\n readonly ttlMs: number\n}\n\n/** Callback proof. The orchestration layer authorizes the returned initiating execution. */\nexport interface ConsumeConnectorAuthorizationAttemptInput {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly stateHash: string\n readonly redirectUri: string\n}\n\nexport type ConnectorAuthorizationStatus =\n | \"pending_selection\"\n | \"active\"\n | \"needs_reauthorization\"\n | \"revocation_pending\"\n | \"revoked\"\n\nexport type ConnectorCredentialMutationKind = \"refresh\" | \"reauthorization\" | \"revocation\"\nexport type ConnectorCredentialMutationPhase = \"prepared\" | \"executing\" | \"result_staged\"\n\nexport interface ConnectorStagedCredentials {\n readonly credentials: SealedConnectorCredential\n readonly credentialExpiresAt?: Date\n readonly scopes: readonly string[]\n}\n\n/** Durable fencing record for one provider-side OAuth credential mutation. */\nexport interface ConnectorCredentialMutation {\n readonly id: string\n readonly kind: ConnectorCredentialMutationKind\n readonly phase: ConnectorCredentialMutationPhase\n readonly holderId: string\n readonly expiresAt: Date\n readonly deadlineAt: Date\n readonly expectedConnectionIds?: readonly string[]\n readonly stagedCredentials?: ConnectorStagedCredentials\n}\n\nexport interface ConnectorAuthorizationRecord {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly authorizedBy: AuthorizablePrincipal\n /** Removed after provider revocation is confirmed. */\n readonly credentials?: SealedConnectorCredential\n readonly credentialExpiresAt?: Date\n readonly scopes: readonly string[]\n readonly accounts: readonly ConnectorAccountCandidate[]\n readonly status: ConnectorAuthorizationStatus\n /** Storage-authoritative deadline for the first account selection. */\n readonly selectionExpiresAt?: Date\n readonly revision: number\n readonly credentialMutation?: ConnectorCredentialMutation\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface CreateConnectorAuthorizationInput {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly authorizedBy: AuthorizablePrincipal\n readonly credentials: SealedConnectorCredential\n readonly credentialExpiresAt?: Date\n readonly scopes: readonly string[]\n readonly accounts: readonly ConnectorAccountCandidate[]\n readonly selectionTtlMs: number\n}\n\nexport interface InitializeConnectorAuthorizationAccountsInput {\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n readonly expectedRevision: number\n readonly accounts: readonly ConnectorAccountCandidate[]\n}\n\nexport interface ClaimConnectorCredentialMutationInput {\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n readonly expectedRevision: number\n readonly mutation: {\n readonly id: string\n readonly kind: ConnectorCredentialMutationKind\n readonly holderId: string\n }\n readonly expectedConnectionIds?: readonly string[]\n readonly leaseDurationMs: number\n readonly operationTimeoutMs: number\n}\n\nexport interface ClaimConnectorCredentialMutationResult {\n readonly authorization: ConnectorAuthorizationRecord\n readonly disconnected: readonly ConnectorConnectionRecord[]\n}\n\nexport interface ConnectorCredentialMutationFence {\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n readonly expectedRevision: number\n readonly mutationId: string\n}\n\nexport interface MarkConnectorCredentialMutationExecutingInput\n extends ConnectorCredentialMutationFence {\n readonly holderId: string\n}\n\nexport interface RenewConnectorCredentialMutationInput extends ConnectorCredentialMutationFence {\n readonly holderId: string\n readonly leaseDurationMs: number\n}\n\nexport interface StageConnectorCredentialMutationCredentialsInput\n extends ConnectorCredentialMutationFence {\n readonly holderId: string\n readonly credentials: SealedConnectorCredential\n readonly credentialExpiresAt?: Date\n readonly scopes: readonly string[]\n}\n\nexport interface StageConnectorCredentialMutationRevocationInput\n extends ConnectorCredentialMutationFence {\n readonly holderId: string\n}\n\nexport interface ReleaseConnectorCredentialMutationInput extends ConnectorCredentialMutationFence {\n readonly holderId: string\n}\n\nexport interface RecoverExpiredConnectorCredentialMutationInput {\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n}\n\nexport interface MarkConnectorAuthorizationNeedsReauthorizationInput\n extends ConnectorCredentialMutationFence {}\n\nexport interface FinalizeConnectorReauthorizationInput extends ConnectorCredentialMutationFence {\n readonly accounts: readonly ConnectorAccountCandidate[]\n}\n\nexport type ConnectorConnectionStatus = \"connected\" | \"disconnected\"\n\nexport interface ConnectorConnectionRecord extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n readonly account: ConnectorAccountCandidate\n readonly status: ConnectorConnectionStatus\n readonly disconnectedAt?: Date\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface PutConnectorConnectionInput extends ConnectorConnectionSelector {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n readonly account: ConnectorAccountCandidate\n readonly replace: boolean\n}\n\nexport interface PutConnectorConnectionResult {\n readonly connection: ConnectorConnectionRecord\n readonly authorization: ConnectorAuthorizationRecord\n readonly revocationPendingAuthorizationId?: string\n readonly created: boolean\n readonly replaced: boolean\n}\n\nexport interface DisconnectConnectorConnectionResult {\n readonly connection: ConnectorConnectionRecord\n readonly authorization: ConnectorAuthorizationRecord\n readonly revocationPendingAuthorizationId?: string\n}\n\nexport interface PutConnectorConnectionFromRunInput {\n readonly id: string\n readonly projectId: string\n readonly connectorId: string\n readonly runId: string\n readonly account: ConnectorAccountCandidate\n readonly replace: boolean\n}\n\nexport interface PutConnectorConnectionFromRunResult extends PutConnectorConnectionResult {\n readonly run: ConnectorConnectionRunSucceededRecord\n}\n\nexport interface GetConnectorConnectionInput extends ConnectorConnectionSelector {\n readonly projectId: string\n readonly connectorId: string\n}\n\nexport interface ListConnectorConnectionsInput {\n readonly projectId: string\n readonly connectorId: string\n}\n\n/** Tenant-scoped identity for one connector authorization. */\nexport interface ConnectorAuthorizationKey {\n readonly projectId: string\n readonly connectorId: string\n readonly authorizationId: string\n}\n\n/** Tenant-scoped identity for one selected connector connection. */\nexport interface ConnectorConnectionKey {\n readonly projectId: string\n readonly connectorId: string\n readonly connectionId: string\n}\n\n/** Persistent contract. Implementations must make every individual mutation atomic. */\nexport interface ConnectorConnectionStorage {\n readonly durability: \"ephemeral\" | \"durable\"\n\n createAuthorizationAttempt(\n input: CreateConnectorAuthorizationAttemptInput\n ): Promise<ConnectorAuthorizationAttemptRecord>\n consumeAuthorizationAttempt(\n input: ConsumeConnectorAuthorizationAttemptInput\n ): Promise<ConnectorAuthorizationAttemptRecord>\n\n createConnectionRun(\n input: CreateConnectorConnectionRunInput\n ): Promise<ConnectorConnectionRunRecord>\n createConnectionSelectionRun(\n input: CreateConnectorConnectionSelectionRunInput\n ): Promise<ConnectorConnectionRunAwaitingSelectionRecord>\n claimConnectionRunCallback(\n input: ClaimConnectorConnectionRunCallbackInput\n ): Promise<ClaimConnectorConnectionRunCallbackResult | null>\n attachConnectionRunAuthorization(\n input: AttachConnectorConnectionRunAuthorizationInput\n ): Promise<ConnectorConnectionRunProcessingRecord | null>\n waitForConnectionRunSelection(\n input: WaitForConnectorConnectionRunSelectionInput\n ): Promise<ConnectorConnectionRunAwaitingSelectionRecord | null>\n finishConnectionRun(\n input: FinishConnectorConnectionRunInput\n ): Promise<ConnectorConnectionRunRecord | null>\n getConnectionRun(\n input: GetConnectorConnectionRunInput\n ): Promise<ConnectorConnectionRunRecord | null>\n\n createAuthorization(\n input: CreateConnectorAuthorizationInput\n ): Promise<ConnectorAuthorizationRecord>\n initializeAuthorizationAccounts(\n input: InitializeConnectorAuthorizationAccountsInput\n ): Promise<ConnectorAuthorizationRecord | null>\n getAuthorization(input: ConnectorAuthorizationKey): Promise<ConnectorAuthorizationRecord | null>\n getAuthorizationByConnectionId(\n input: ConnectorConnectionKey\n ): Promise<ConnectorAuthorizationRecord | null>\n claimCredentialMutation(\n input: ClaimConnectorCredentialMutationInput\n ): Promise<ClaimConnectorCredentialMutationResult | null>\n markCredentialMutationExecuting(\n input: MarkConnectorCredentialMutationExecutingInput\n ): Promise<ConnectorAuthorizationRecord | null>\n renewCredentialMutation(\n input: RenewConnectorCredentialMutationInput\n ): Promise<ConnectorAuthorizationRecord | null>\n stageCredentialMutationCredentials(\n input: StageConnectorCredentialMutationCredentialsInput\n ): Promise<ConnectorAuthorizationRecord | null>\n stageCredentialMutationRevocation(\n input: StageConnectorCredentialMutationRevocationInput\n ): Promise<ConnectorAuthorizationRecord | null>\n releaseCredentialMutation(input: ReleaseConnectorCredentialMutationInput): Promise<boolean>\n /**\n * Recovers an expired mutation without replaying an unknown provider effect. Prepared work is\n * released, executing refresh/reauthorization fails closed, revocation stays retryable, and a\n * staged result remains available for finalization.\n */\n recoverExpiredCredentialMutation(\n input: RecoverExpiredConnectorCredentialMutationInput\n ): Promise<ConnectorAuthorizationRecord | null>\n markNeedsReauthorization(\n input: MarkConnectorAuthorizationNeedsReauthorizationInput\n ): Promise<ConnectorAuthorizationRecord | null>\n finalizeRefresh(\n input: ConnectorCredentialMutationFence\n ): Promise<ConnectorAuthorizationRecord | null>\n finalizeReauthorization(\n input: FinalizeConnectorReauthorizationInput\n ): Promise<ConnectorAuthorizationRecord | null>\n finalizeRevocation(\n input: ConnectorCredentialMutationFence\n ): Promise<ConnectorAuthorizationRecord | null>\n\n putConnection(input: PutConnectorConnectionInput): Promise<PutConnectorConnectionResult>\n putConnectionFromRun(\n input: PutConnectorConnectionFromRunInput\n ): Promise<PutConnectorConnectionFromRunResult>\n getConnection(input: GetConnectorConnectionInput): Promise<ConnectorConnectionRecord | null>\n getConnectionById(input: ConnectorConnectionKey): Promise<ConnectorConnectionRecord | null>\n listConnections(\n input: ListConnectorConnectionsInput\n ): Promise<readonly ConnectorConnectionRecord[]>\n listConnectionsByAuthorization(\n input: ConnectorAuthorizationKey\n ): Promise<readonly ConnectorConnectionRecord[]>\n disconnectConnection(\n input: ConnectorConnectionKey\n ): Promise<DisconnectConnectorConnectionResult | null>\n}\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": ";;AAeO,MAAM,wCAAwC,MAAM;AAAA,EAChD;AAAA,EAET,WAAW,CAAC,MAA2C,SAAiB;AAAA,IACtE,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ,KAAK,OAAO;AAAA;AAEhB;;;ACZO,IAAM,yCAAyC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
9
|
-
"debugId": "26D0DA75AEECB3FB64756E2164756E21",
|
|
10
|
-
"names": []
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/agents/streams.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { Broker, BrokerStreamDefinition } from \"../broker\"\nimport { parseSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport { isJsonValue, isPlainRecord, type JsonValue } from \"../json\"\nimport {\n AGENT_RUN_FAILURE_CODES,\n type AgentContextCheckpointReason,\n type AgentRunFailureCode,\n type AgentRunRecord,\n type ConversationAgentRunRecord,\n} from \"../storage/agents/types\"\n\nexport const AGENT_RUN_STREAM_SCHEMA_VERSION = 1 as const\nexport const DEFAULT_AGENT_RUN_STREAM_RETENTION = {\n maxAgeMs: 2 * 60 * 60 * 1000, // 2 hours\n maxRecords: 5_000,\n} as const\n\nexport const AGENT_ACTIVITY_STREAM_SCHEMA_VERSION = 1 as const\nexport const AGENT_ACTIVITY_STREAM_ID = \"agents.activity\" as const\nexport const DEFAULT_AGENT_ACTIVITY_STREAM_RETENTION = {\n maxAgeMs: 24 * 60 * 60 * 1000, // 24 hours\n maxRecords: 10_000,\n} as const\n\nexport interface AgentRunActivityEvent {\n readonly schemaVersion: typeof AGENT_ACTIVITY_STREAM_SCHEMA_VERSION\n readonly type: \"agent.run.activity\"\n readonly projectId: string\n readonly runId: string\n readonly threadId: string\n readonly status: AgentRunRecord[\"status\"]\n readonly attempt: number\n readonly occurredAt: string\n}\n\nexport function agentActivityStreamDefinition(): BrokerStreamDefinition {\n return {\n id: AGENT_ACTIVITY_STREAM_ID,\n retention: DEFAULT_AGENT_ACTIVITY_STREAM_RETENTION,\n }\n}\n\nexport function agentRunActivityEvent(\n run: ConversationAgentRunRecord,\n occurredAt: Date = new Date()\n): AgentRunActivityEvent {\n return {\n schemaVersion: AGENT_ACTIVITY_STREAM_SCHEMA_VERSION,\n type: \"agent.run.activity\",\n projectId: run.projectId,\n runId: run.id,\n threadId: run.threadId,\n status: run.status,\n attempt: run.attempt,\n occurredAt: occurredAt.toISOString(),\n }\n}\n\nexport function isAgentRunActivityEvent(value: unknown): value is AgentRunActivityEvent {\n return (\n isPlainRecord(value) &&\n value.schemaVersion === AGENT_ACTIVITY_STREAM_SCHEMA_VERSION &&\n value.type === \"agent.run.activity\" &&\n typeof value.projectId === \"string\" &&\n typeof value.runId === \"string\" &&\n typeof value.threadId === \"string\" &&\n isAgentRunStatus(value.status) &&\n typeof value.attempt === \"number\" &&\n Number.isFinite(value.attempt) &&\n typeof value.occurredAt === \"string\"\n )\n}\n\nexport async function publishAgentRunActivity(\n broker: Broker,\n run: ConversationAgentRunRecord\n): Promise<void> {\n const event = agentRunActivityEvent(run)\n await broker.ensureStream({\n projectId: run.projectId,\n stream: agentActivityStreamDefinition(),\n })\n await broker.append({\n projectId: run.projectId,\n streamId: AGENT_ACTIVITY_STREAM_ID,\n records: [\n {\n name: event.type,\n key: event.threadId,\n // The event is composed only of validated JSON primitives.\n payload: event as unknown as JsonValue,\n idempotencyKey: `${event.runId}:${event.attempt}:${event.status}`,\n },\n ],\n })\n}\n\nexport type AgentRunStreamId = `agents.runs.${string}`\n\nexport function agentRunStreamId(runId: string): AgentRunStreamId {\n return `agents.runs.${runId}`\n}\n\nexport function agentRunStreamDefinition(runId: string): BrokerStreamDefinition {\n return {\n id: agentRunStreamId(runId),\n retention: DEFAULT_AGENT_RUN_STREAM_RETENTION,\n }\n}\n\ntype AgentRunStreamEventBase = {\n readonly schemaVersion: typeof AGENT_RUN_STREAM_SCHEMA_VERSION\n readonly projectId: string\n readonly runId: string\n readonly attempt: number\n readonly occurredAt: string\n} & (\n | {\n readonly threadId: string\n readonly parentRunId?: never\n }\n | {\n readonly parentRunId: string\n readonly threadId?: never\n }\n)\n\n// ── Control stream (worker-inbound) ─────────────────────────────────────────────────────────────\n//\n// A per-run channel the API layer publishes to and the worker subscribes to — the reverse direction\n// of the event stream above. It carries only a cancel signal, and is addressed by `runId` (not a run\n// record), so a cancel works even before the worker has reserved the run. Kept separate from the\n// event stream so control records never reach the browser client.\n\nexport type AgentRunControlStreamId = `agents.runs.${string}.control`\n\nexport function agentRunControlStreamId(runId: string): AgentRunControlStreamId {\n return `agents.runs.${runId}.control`\n}\n\n/** The only control record: a request to stop the run. */\nexport const AGENT_RUN_CANCEL_RECORD = \"agent.run.cancel\"\n\n// A cancel only needs to outlive the queue wait plus one turn, so retention is short and tiny.\nconst AGENT_RUN_CONTROL_RETENTION = { maxAgeMs: 30 * 60 * 1000, maxRecords: 16 } as const\n\nexport function agentRunControlStreamDefinition(runId: string): BrokerStreamDefinition {\n return { id: agentRunControlStreamId(runId), retention: AGENT_RUN_CONTROL_RETENTION }\n}\n\n/**\n * Signal a run to stop. Publishing is addressed by `runId`, so it works whether the run is queued,\n * reserved, or being drained — the worker picks the record up when it subscribes.\n */\nexport async function publishAgentRunCancel(\n broker: Broker,\n params: { readonly projectId: string; readonly runId: string }\n): Promise<void> {\n await broker.ensureStream({\n projectId: params.projectId,\n stream: agentRunControlStreamDefinition(params.runId),\n })\n await broker.append({\n projectId: params.projectId,\n streamId: agentRunControlStreamId(params.runId),\n records: [\n {\n name: AGENT_RUN_CANCEL_RECORD,\n key: params.runId,\n payload: { runId: params.runId },\n idempotencyKey: `${params.runId}:cancel`,\n },\n ],\n })\n}\n\n/**\n * Watch a run's control stream and invoke `onCancel` when a cancel arrives. Reads from `earliest` so\n * a cancel published before the worker subscribed (a run stopped while still queued) is still seen.\n * Returns the unsubscribe handle.\n */\nexport async function subscribeAgentRunCancel(\n broker: Broker,\n params: { readonly projectId: string; readonly runId: string },\n onCancel: () => void\n): Promise<() => void> {\n await broker.ensureStream({\n projectId: params.projectId,\n stream: agentRunControlStreamDefinition(params.runId),\n })\n return broker.subscribe(\n {\n projectId: params.projectId,\n streamId: agentRunControlStreamId(params.runId),\n from: \"earliest\",\n names: [AGENT_RUN_CANCEL_RECORD],\n },\n () => onCancel()\n )\n}\n\n/** Exact portable failure exposed by a terminal Agent run stream event. */\nexport type AgentRunFailure = SixbFailure<AgentRunFailureCode>\n\nexport const AGENT_COMPACTION_FAILURE_CODES = [\n \"context_limit_exceeded\",\n \"summary_failed\",\n \"checkpoint_failed\",\n] as const\nexport type AgentCompactionFailureCode = (typeof AGENT_COMPACTION_FAILURE_CODES)[number]\n\nexport type AgentRunStreamEvent =\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.run.started\"\n readonly modelId?: string\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.compaction.started\"\n readonly reason: AgentContextCheckpointReason\n readonly estimatedInputTokensBefore: number\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.compaction.completed\"\n readonly reason: AgentContextCheckpointReason\n readonly checkpointId: string\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.compaction.failed\"\n readonly reason: AgentContextCheckpointReason\n readonly errorCode: AgentCompactionFailureCode\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.ui.chunk\"\n readonly chunkIndex: number\n readonly chunk: JsonValue\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.message.finalized\"\n readonly messageId: string\n })\n | (AgentRunStreamEventBase & {\n readonly type: \"agent.run.finished\"\n readonly status: \"succeeded\" | \"failed\" | \"cancelled\"\n readonly finishReason?: string\n readonly error?: AgentRunFailure\n })\n\nexport type AgentRunFinishedEvent = Extract<AgentRunStreamEvent, { type: \"agent.run.finished\" }>\n\n// ── Record construction ──────────────────────────────────────────────────────────────────────────\n//\n// The wire format of run stream records — event shape, record name/key, and the idempotency-key\n// vocabulary — is owned here so every producer (the worker's stream sink, the server's queued\n// cancellation) shares one definition and cannot drift.\n\n/** Build the terminal stream event for a finished run. Throws if the run is not terminal. */\nexport function agentRunFinishedEvent(\n run: AgentRunRecord,\n occurredAt: Date = new Date()\n): AgentRunFinishedEvent {\n if (run.status === \"queued\" || run.status === \"running\") {\n throw new Error(\n `[Sixb] Agent run '${run.id}' is not terminal (status '${run.status}'), so it has no finished event.`\n )\n }\n return {\n ...agentRunStreamEventBase(run, occurredAt),\n type: \"agent.run.finished\",\n status: run.status,\n ...(run.finishReason === undefined ? {} : { finishReason: run.finishReason }),\n ...(run.error === undefined ? {} : { error: run.error }),\n }\n}\n\n/** Shared lineage for stream records emitted by conversational and headless runs. */\nexport function agentRunStreamEventBase(\n run: AgentRunRecord,\n occurredAt: Date = new Date()\n): AgentRunStreamEventBase {\n const common = {\n schemaVersion: AGENT_RUN_STREAM_SCHEMA_VERSION,\n projectId: run.projectId,\n runId: run.id,\n attempt: run.attempt,\n occurredAt: occurredAt.toISOString(),\n }\n return run.kind === \"conversation\"\n ? { ...common, threadId: run.threadId }\n : { ...common, parentRunId: run.parentRunId }\n}\n\n/** Validate an Agent stream payload using the same contract its producers use. */\nexport function isAgentRunStreamEvent(value: unknown): value is AgentRunStreamEvent {\n if (\n !isPlainRecord(value) ||\n value.schemaVersion !== AGENT_RUN_STREAM_SCHEMA_VERSION ||\n typeof value.projectId !== \"string\" ||\n typeof value.runId !== \"string\" ||\n typeof value.attempt !== \"number\" ||\n !Number.isFinite(value.attempt) ||\n typeof value.occurredAt !== \"string\" ||\n typeof value.type !== \"string\"\n ) {\n return false\n }\n const hasConversationLineage =\n typeof value.threadId === \"string\" && value.parentRunId === undefined\n const hasSubagentLineage = typeof value.parentRunId === \"string\" && value.threadId === undefined\n if (!hasConversationLineage && !hasSubagentLineage) return false\n\n switch (value.type) {\n case \"agent.run.started\":\n return value.modelId === undefined || typeof value.modelId === \"string\"\n case \"agent.compaction.started\":\n return (\n isAgentContextCheckpointReason(value.reason) &&\n isTokenEstimate(value.estimatedInputTokensBefore)\n )\n case \"agent.compaction.completed\":\n return (\n isAgentContextCheckpointReason(value.reason) &&\n typeof value.checkpointId === \"string\" &&\n isTokenEstimate(value.estimatedInputTokensBefore) &&\n isTokenEstimate(value.estimatedInputTokensAfter)\n )\n case \"agent.compaction.failed\":\n return (\n isAgentContextCheckpointReason(value.reason) &&\n AGENT_COMPACTION_FAILURE_CODES.includes(value.errorCode as AgentCompactionFailureCode)\n )\n case \"agent.ui.chunk\":\n return (\n Number.isInteger(value.chunkIndex) &&\n Object.hasOwn(value, \"chunk\") &&\n isJsonValue(value.chunk)\n )\n case \"agent.message.finalized\":\n return typeof value.messageId === \"string\"\n case \"agent.run.finished\":\n return (\n isTerminalAgentRunStatus(value.status) &&\n (value.finishReason === undefined || typeof value.finishReason === \"string\") &&\n (value.error === undefined || isAgentRunFailure(value.error))\n )\n default:\n return false\n }\n}\n\nfunction isAgentContextCheckpointReason(value: unknown): value is AgentContextCheckpointReason {\n return value === \"threshold\" || value === \"overflow\"\n}\n\nfunction isTokenEstimate(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 0\n}\n\nfunction isTerminalAgentRunStatus(value: unknown): value is \"succeeded\" | \"failed\" | \"cancelled\" {\n return value === \"succeeded\" || value === \"failed\" || value === \"cancelled\"\n}\n\nfunction isAgentRunStatus(value: unknown): value is AgentRunRecord[\"status\"] {\n return value === \"queued\" || value === \"running\" || isTerminalAgentRunStatus(value)\n}\n\nfunction isAgentRunFailure(value: unknown): value is AgentRunFailure {\n if (!isPlainRecord(value)) return false\n try {\n parseSixbFailure(value, AGENT_RUN_FAILURE_CODES)\n return true\n } catch {\n return false\n }\n}\n\n/** Single owner of the idempotency-key vocabulary for agent run stream records. */\nexport function agentRunStreamIdempotencyKey(event: AgentRunStreamEvent): string {\n switch (event.type) {\n case \"agent.run.started\":\n return `${event.runId}:${event.attempt}:started`\n case \"agent.compaction.started\":\n return `${event.runId}:${event.attempt}:compaction:${event.reason}:started`\n case \"agent.compaction.completed\":\n return `${event.runId}:${event.attempt}:compaction:${event.checkpointId}:completed`\n case \"agent.compaction.failed\":\n return `${event.runId}:${event.attempt}:compaction:${event.reason}:failed:${event.errorCode}`\n case \"agent.ui.chunk\":\n return `${event.runId}:${event.attempt}:chunk:${event.chunkIndex}`\n case \"agent.message.finalized\":\n return `${event.runId}:${event.attempt}:message:${event.messageId}:finalized`\n case \"agent.run.finished\":\n return `${event.runId}:${event.attempt}:finished:${event.status}`\n }\n}\n\n/**\n * Ensure the run's stream and append its terminal record — mirrors {@link publishAgentRunCancel}.\n * Used where a terminal transition happens outside the worker (e.g. cancelling a queued run).\n */\nexport async function publishAgentRunFinished(broker: Broker, run: AgentRunRecord): Promise<void> {\n const event = agentRunFinishedEvent(run)\n await broker.ensureStream({\n projectId: run.projectId,\n stream: agentRunStreamDefinition(run.id),\n })\n await broker.append({\n projectId: run.projectId,\n streamId: agentRunStreamId(run.id),\n records: [\n {\n name: event.type,\n key: event.runId,\n // The event is built from JSON primitives only, so the round-trip is a safe narrowing.\n payload: JSON.parse(JSON.stringify(event)) as JsonValue,\n idempotencyKey: agentRunStreamIdempotencyKey(event),\n },\n ],\n })\n if (run.kind === \"conversation\") await publishAgentRunActivity(broker, run)\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;AAYO,IAAM,kCAAkC;AACxC,IAAM,qCAAqC;AAAA,EAChD,UAAU,IAAI,KAAK,KAAK;AAAA,EACxB,YAAY;AACd;AAEO,IAAM,uCAAuC;AAC7C,IAAM,2BAA2B;AACjC,IAAM,0CAA0C;AAAA,EACrD,UAAU,KAAK,KAAK,KAAK;AAAA,EACzB,YAAY;AACd;AAaO,SAAS,6BAA6B,GAA2B;AAAA,EACtE,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,WAAW;AAAA,EACb;AAAA;AAGK,SAAS,qBAAqB,CACnC,KACA,aAAmB,IAAI,MACA;AAAA,EACvB,OAAO;AAAA,IACL,eAAe;AAAA,IACf,MAAM;AAAA,IACN,WAAW,IAAI;AAAA,IACf,OAAO,IAAI;AAAA,IACX,UAAU,IAAI;AAAA,IACd,QAAQ,IAAI;AAAA,IACZ,SAAS,IAAI;AAAA,IACb,YAAY,WAAW,YAAY;AAAA,EACrC;AAAA;AAGK,SAAS,uBAAuB,CAAC,OAAgD;AAAA,EACtF,OACE,cAAc,KAAK,KACnB,MAAM,kBAAkB,wCACxB,MAAM,SAAS,wBACf,OAAO,MAAM,cAAc,YAC3B,OAAO,MAAM,UAAU,YACvB,OAAO,MAAM,aAAa,YAC1B,iB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AAsB,GAAG;AAAA,EACvC,MAAM,OAAO,aAAa;AAAA,IACxB,WAAW,IAAI;AAAA,IACf,QAAQ,yBAAyB,IAAI,EAAE;AAAA,EACzC,CAAC;AAAA,EACD,MAAM,OAAO,OAAO;AAAA,IAClB,WAAW,IAAI;AAAA,IACf,UAAU,iBAAiB,IAAI,EAAE;AAAA,IACjC,SAAS;AAAA,MACP;AAAA,QACE,MAAM,MAAM;AAAA,QACZ,KAAK,MAAM;AAAA,QAEX,SAAS,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AAAA,QACzC,gBAAgB,6BAA6B,KAAK;AAAA,MACpD;AAAA,IACF;AAAA,EACF,CAAC;AAAA,EACD,IAAI,IAAI,SAAS;AAAA,IAAgB,MAAM,wBAAwB,QAAQ,GAAG;AAAA;",
|
|
8
|
-
"debugId": "01E889A4551AE38464756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/connectors/types.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { WebhookDefinition } from \"../webhooks/types\"\n\n/**\n * Runtime context passed to connector adapters when Sixb establishes a connection.\n *\n * Connectors can use this to scope logs, build cache keys, or attach cancellation\n * to long-running startup work.\n */\nexport interface ConnectorContext {\n readonly projectId: string\n readonly connectorId: string\n readonly signal: AbortSignal\n}\n\n/**\n * Minimal contract for a Sixb connector adapter.\n *\n * Adapters are responsible for creating and optionally tearing down a client for an\n * external system. They should return the client shape that feels natural for that system.\n */\nexport interface ConnectorAdapter<TType extends string = string, TClient = unknown> {\n readonly type: TType\n readonly authentication?: never\n readonly webhooks?: readonly WebhookDefinition<unknown, TClient>[]\n connect(context: ConnectorContext): Promise<TClient> | TClient\n disconnect?(client: TClient): Promise<void> | void\n}\n\n/** One OAuth token set normalized by an OAuth connector adapter. */\nexport interface ConnectorOAuthCredentials {\n readonly accessToken: string\n readonly refreshToken?: string\n readonly tokenType?: string\n readonly scopes?: readonly string[]\n readonly expiresAt?: Date\n}\n\n/** Public, non-secret account information returned for framework-owned selection UI. */\nexport interface ConnectorAccountCandidate {\n readonly id: string\n readonly label: string\n readonly description?: string\n readonly avatarUrl?: string\n}\n\n/** V1 intentionally supports project-owned connector connections only. */\nexport interface ProjectConnectorConnectionOwner {\n readonly type: \"project\"\n}\n\nexport type ConnectorConnectionOwner = ProjectConnectorConnectionOwner\n\n/** Stable application-defined lookup key for one connector connection. */\nexport interface ConnectorConnectionSelector {\n readonly owner: ConnectorConnectionOwner\n readonly slot: string\n}\n\n/** Stable, non-secret metadata shared by connector connection consumers. */\nexport interface ConnectorConnectionMetadata extends ConnectorConnectionSelector {\n readonly id: string\n readonly connectorId: string\n readonly account: ConnectorAccountCandidate\n}\n\n/** Credential protection required when an OAuth connector uses durable connection storage. */\nexport interface ConnectorConnectionOptions {\n /** Canonical base64url encoding of exactly 32 random bytes, shared by storage replicas. */\n readonly encryptionKey: string\n}\n\nexport interface OAuthConnectorAuthorizationContext extends ConnectorContext {\n readonly redirectUri: string\n}\n\nexport interface OAuthConnectorAuthorizationUrlInput {\n readonly state: string\n readonly codeChallenge: string\n readonly codeChallengeMethod: \"S256\"\n}\n\nexport interface OAuthConnectorCodeExchangeInput {\n readonly code: string\n readonly codeVerifier: string\n}\n\nexport interface ConnectorConnectionClientContext extends ConnectorContext {\n readonly connectionId: string\n readonly account: ConnectorAccountCandidate\n readonly tokenSource: ConnectorTokenSource\n}\n\n/** One delivered token, bound to the credential revision that produced it. */\nexport interface ConnectorAccessToken {\n readonly accessToken: string\n readonly tokenType?: string\n /** Report this exact token as rejected so Sixb can refresh only its credential revision. */\n invalidate(): void\n}\n\n/** Live credential source owned by Sixb. Adapters must resolve a token for each request. */\nexport interface ConnectorTokenSource {\n get(): Promise<ConnectorAccessToken>\n}\n\n/**\n * OAuth-backed connector adapter. Sixb owns persistence, OAuth state, refresh coordination and UI;\n * the adapter owns provider protocol details and typed client creation.\n */\nexport interface ConnectorOAuth2Authentication {\n readonly type: \"oauth2\"\n authorizationUrl(\n context: OAuthConnectorAuthorizationContext,\n input: OAuthConnectorAuthorizationUrlInput\n ): Promise<string | URL> | string | URL\n exchangeCode(\n context: OAuthConnectorAuthorizationContext,\n input: OAuthConnectorCodeExchangeInput\n ): Promise<ConnectorOAuthCredentials> | ConnectorOAuthCredentials\n refresh(\n context: ConnectorContext,\n credentials: ConnectorOAuthCredentials\n ): Promise<ConnectorOAuthCredentials> | ConnectorOAuthCredentials\n /**\n * Revokes the grant idempotently. An already revoked or invalid grant must resolve successfully\n * so Sixb can converge after losing an earlier provider response.\n */\n revoke?(context: ConnectorContext, credentials: ConnectorOAuthCredentials): Promise<void> | void\n}\n\nexport interface OAuthConnectorAdapter<TType extends string = string, TClient = unknown> {\n readonly type: TType\n readonly authentication: ConnectorOAuth2Authentication\n readonly webhooks?: undefined\n discoverAccounts(\n context: ConnectorContext,\n credentials: ConnectorOAuthCredentials\n ): Promise<readonly ConnectorAccountCandidate[]> | readonly ConnectorAccountCandidate[]\n connect(context: ConnectorConnectionClientContext): Promise<TClient> | TClient\n}\n\nexport type AnyConnectorAdapter = ConnectorAdapter | OAuthConnectorAdapter\n\n/**\n * Inert connector definition registered with Sixb.\n *\n * Definitions are safe to export from `connectors/` modules. The runtime turns them into\n * live clients when `sixb.connector(...)` is called.\n */\nexport interface ConnectorDefinition<\n TId extends string = string,\n TAdapter extends AnyConnectorAdapter = AnyConnectorAdapter,\n> {\n readonly kind: \"connector\"\n readonly id: TId\n readonly adapter: TAdapter\n}\n\nexport type StaticConnectorDefinition = ConnectorDefinition<string, ConnectorAdapter>\n\n/** Infer the connected client type returned by a connector adapter. */\nexport type ConnectorClient<TAdapter extends AnyConnectorAdapter> = Awaited<\n ReturnType<TAdapter[\"connect\"]>\n>\n\nexport function isOAuthConnectorAdapter(\n value: AnyConnectorAdapter\n): value is OAuthConnectorAdapter {\n return \"authentication\" in value && value.authentication?.type === \"oauth2\"\n}\n\nexport function isOAuthConnectorDefinition(\n value: ConnectorDefinition\n): value is ConnectorDefinition<string, OAuthConnectorAdapter> {\n return isOAuthConnectorAdapter(value.adapter)\n}\n\nexport function isStaticConnectorDefinition(\n value: ConnectorDefinition\n): value is StaticConnectorDefinition {\n return !isOAuthConnectorDefinition(value)\n}\n\nexport function isConnectorDefinition(value: unknown): value is ConnectorDefinition {\n if (!isRecord(value)) {\n return false\n }\n\n const adapter = value.adapter\n if (\n value.kind === \"connector\" &&\n typeof value.id === \"string\" &&\n isRecord(adapter) &&\n typeof adapter.type === \"string\" &&\n typeof adapter.connect === \"function\"\n ) {\n if (adapter.authentication === undefined) return true\n const authentication = adapter.authentication\n if (!isRecord(authentication) || authentication.type !== \"oauth2\") return false\n return (\n typeof authentication.authorizationUrl === \"function\" &&\n typeof authentication.exchangeCode === \"function\" &&\n typeof authentication.refresh === \"function\" &&\n typeof adapter.discoverAccounts === \"function\"\n )\n }\n\n return false\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AAqKO,SAAS,uBAAuB,CACrC,OACgC;AAAA,EAChC,OAAO,oBAAoB,SAAS,MAAM,gBAAgB,SAAS;AAAA;AAG9D,SAAS,0BAA0B,CACxC,OAC6D;AAAA,EAC7D,OAAO,wBAAwB,MAAM,OAAO;AAAA;AAGvC,SAAS,2BAA2B,CACzC,OACoC;AAAA,EACpC,OAAO,CAAC,2BAA2B,KAAK;AAAA;AAGnC,SAAS,qBAAqB,CAAC,OAA8C;AAAA,EAClF,IAAI,CAAC,SAAS,KAAK,GAAG;AAAA,IACpB,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,UAAU,MAAM;AAAA,EACtB,IACE,MAAM,SAAS,eACf,OAAO,MAAM,OAAO,YACpB,SAAS,OAAO,KAChB,OAAO,QAAQ,SAAS,YACxB,OAAO,QAAQ,YAAY,YAC3B;AAAA,IACA,IAAI,QAAQ,mBAAmB;AAAA,MAAW,OAAO;AAAA,IACjD,MAAM,iBAAiB,QAAQ;AAAA,IAC/B,IAAI,CAAC,SAAS,cAAc,KAAK,eAAe,SAAS;AAAA,MAAU,OAAO;AAAA,IAC1E,OACE,OAAO,eAAe,qBAAqB,cAC3C,OAAO,eAAe,iBAAiB,cACvC,OAAO,eAAe,YAAY,cAClC,OAAO,QAAQ,qBAAqB;AAAA,EAExC;AAAA,EAEA,OAAO;AAAA;AAGT,SAAS,QAAQ,CAAC,OAAkD;AAAA,EAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAAA;",
|
|
8
|
-
"debugId": "39E9DA47E39EE2BC64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|