@sixb/core 0.1.8 → 0.1.9
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 +192 -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 +79 -88
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/index.js +8 -10
- package/dist/broker/index.js.map +1 -1
- package/dist/{chunk-k34z5rvh.js → chunk-0rdrecsb.js} +18 -18
- package/dist/{chunk-k34z5rvh.js.map → chunk-0rdrecsb.js.map} +2 -2
- package/dist/{chunk-q0k9nc5a.js → chunk-0w35wavj.js} +98 -98
- package/dist/{chunk-q0k9nc5a.js.map → chunk-0w35wavj.js.map} +2 -2
- 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-aa2pen2v.js → chunk-1enhpacz.js} +188 -175
- package/dist/{chunk-aa2pen2v.js.map → chunk-1enhpacz.js.map} +2 -2
- package/dist/{chunk-5gd7tpv6.js → chunk-2c4j899j.js} +4 -4
- package/dist/{chunk-5gd7tpv6.js.map → chunk-2c4j899j.js.map} +2 -2
- 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-8m5ejdpn.js → chunk-3f7veca0.js} +4 -4
- package/dist/{chunk-8m5ejdpn.js.map → chunk-3f7veca0.js.map} +2 -2
- package/dist/chunk-3frsnm7x.js +32 -0
- package/dist/chunk-3frsnm7x.js.map +11 -0
- package/dist/{chunk-n2w475r0.js → chunk-3tgwrcyh.js} +81 -81
- package/dist/{chunk-n2w475r0.js.map → chunk-3tgwrcyh.js.map} +2 -2
- package/dist/{chunk-mwsxn98e.js → chunk-52hbv0ak.js} +170 -170
- package/dist/{chunk-mwsxn98e.js.map → chunk-52hbv0ak.js.map} +4 -4
- 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-rte5sm3z.js → chunk-5hz0fnca.js} +23 -23
- package/dist/{chunk-rte5sm3z.js.map → chunk-5hz0fnca.js.map} +2 -2
- 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-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-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-f26bck4t.js → chunk-an5tt9y0.js} +353 -353
- package/dist/{chunk-f26bck4t.js.map → chunk-an5tt9y0.js.map} +2 -2
- 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-ka3a2ft3.js → chunk-b19g04jk.js} +12 -12
- package/dist/{chunk-ka3a2ft3.js.map → chunk-b19g04jk.js.map} +2 -2
- 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-wtf06et8.js → chunk-emyyk7dx.js} +55 -55
- package/dist/{chunk-wtf06et8.js.map → chunk-emyyk7dx.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-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-51fjndv0.js → chunk-gfdh9kqa.js} +4 -4
- package/dist/{chunk-51fjndv0.js.map → chunk-gfdh9kqa.js.map} +2 -2
- package/dist/chunk-h1gfhhbh.js +602 -0
- package/dist/chunk-h1gfhhbh.js.map +18 -0
- package/dist/chunk-h3v76ams.js +32 -0
- package/dist/{chunk-08m3b6w8.js.map → chunk-h3v76ams.js.map} +2 -2
- package/dist/{chunk-xajtptbw.js → chunk-hpr1r6av.js} +1367 -418
- package/dist/chunk-hpr1r6av.js.map +44 -0
- 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-w9tg6yyb.js → chunk-jjy0fhrn.js} +36 -36
- package/dist/{chunk-w9tg6yyb.js.map → chunk-jjy0fhrn.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-ajnan18g.js → chunk-k3cqkkn2.js} +58 -55
- package/dist/chunk-k3cqkkn2.js.map +12 -0
- package/dist/{chunk-s5y30bc9.js → chunk-kxwa347f.js} +51 -49
- package/dist/{chunk-s5y30bc9.js.map → chunk-kxwa347f.js.map} +4 -4
- 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-3z1qec12.js → chunk-m3z3x9v0.js} +107 -64
- package/dist/{chunk-3z1qec12.js.map → chunk-m3z3x9v0.js.map} +3 -3
- package/dist/{chunk-sbzzr4kx.js → chunk-mjbk2djy.js} +1061 -1195
- package/dist/{chunk-sbzzr4kx.js.map → chunk-mjbk2djy.js.map} +9 -15
- 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-rv2hkwwa.js → chunk-ppytyr6w.js} +156 -179
- package/dist/{chunk-rv2hkwwa.js.map → chunk-ppytyr6w.js.map} +3 -5
- 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-mth82m8t.js → chunk-qhcpj9wc.js} +77 -77
- package/dist/{chunk-mth82m8t.js.map → chunk-qhcpj9wc.js.map} +2 -2
- package/dist/{chunk-tpnd31c1.js → chunk-r29fxdhn.js} +12 -12
- package/dist/{chunk-tpnd31c1.js.map → chunk-r29fxdhn.js.map} +2 -2
- 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-3xep5cjx.js → chunk-r4tfx1sf.js} +104 -86
- package/dist/chunk-r4tfx1sf.js.map +15 -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-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-r8jrnexe.js → chunk-v4jbb3rs.js} +4 -4
- package/dist/{chunk-r8jrnexe.js.map → chunk-v4jbb3rs.js.map} +2 -2
- package/dist/{chunk-v1xppd0y.js → chunk-vf691g1r.js} +60 -60
- package/dist/{chunk-v1xppd0y.js.map → chunk-vf691g1r.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-8tsf6dmc.js → chunk-x57ycxq0.js} +204 -204
- package/dist/{chunk-8tsf6dmc.js.map → chunk-x57ycxq0.js.map} +2 -2
- package/dist/{chunk-z4ccwbkz.js → chunk-x9v4cx1d.js} +1 -1
- package/dist/{chunk-gbejpkex.js → chunk-xfbydgzy.js} +26 -26
- package/dist/{chunk-gbejpkex.js.map → chunk-xfbydgzy.js.map} +2 -2
- package/dist/{chunk-gzasd5b6.js → chunk-xyr8kppc.js} +22 -22
- package/dist/{chunk-gzasd5b6.js.map → chunk-xyr8kppc.js.map} +2 -2
- package/dist/{chunk-h5vqbfmd.js → chunk-ypbtykv6.js} +117 -117
- package/dist/{chunk-h5vqbfmd.js.map → chunk-ypbtykv6.js.map} +3 -3
- 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-xhy826cz.js → chunk-zcnq6105.js} +7 -7
- package/dist/{chunk-xhy826cz.js.map → chunk-zcnq6105.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/internal.js +9 -10
- package/dist/connectors/connections/internal.js.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/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/execution/agent.d.ts +3 -3
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +70 -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 +63 -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 +65 -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 +14 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +455 -477
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +38 -42
- package/dist/lake-storage/index.js.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.js +46 -49
- package/dist/materialization/index.js.map +1 -1
- package/dist/materializer/index.js +137 -145
- package/dist/materializer/index.js.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/projections/internal.js +58 -67
- package/dist/projections/internal.js.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/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/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/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/provider.js +34 -36
- package/dist/storage/connector-connections/provider.js.map +2 -2
- 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 +6 -7
- 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/provider.js +105 -109
- package/dist/storage/ontology/provider.js.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/provider.js +66 -70
- package/dist/storage/projection-runs/provider.js.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 +55 -65
- package/dist/syncs/index.js.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/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.js +911 -799
- package/dist/testing/index.js.map +9 -9
- package/dist/testing/workflow-execution.d.ts +1 -0
- package/dist/testing/workflow-execution.d.ts.map +1 -1
- package/dist/webhooks/internal.js +51 -59
- package/dist/webhooks/internal.js.map +2 -2
- 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 +135 -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 +0 -1
- 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/errors/internal.ts +90 -10
- package/src/errors/redaction.ts +98 -0
- package/src/errors/types.ts +4 -0
- 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 +20 -18
- package/src/logging/index.ts +2 -33
- package/src/logging/internal.ts +43 -0
- 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/projections/run-dispatch.ts +1 -0
- package/src/query.ts +0 -1
- package/src/queues/index.ts +4 -2
- package/src/queues/types.ts +6 -25
- package/src/runtime/create.ts +2 -1
- package/src/runtime/host.ts +2 -1
- 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/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 +3 -29
- package/src/storage/internal.ts +20 -0
- package/src/storage/workflow-runs/in-memory.ts +0 -2
- package/src/storage/workflow-runs/types.ts +0 -3
- 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/execution-storage-contract.ts +59 -1
- package/src/testing/execution.ts +6 -0
- package/src/testing/workflow-execution.ts +4 -0
- package/src/workflows/failure.ts +62 -1
- package/src/workflows/request.ts +0 -9
- package/src/workflows/run-dispatch.ts +0 -3
- 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-7y0f6rf1.js.map +0 -10
- 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-k522z7v6.js.map +0 -10
- 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-xajtptbw.js.map +0 -40
- 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,139 +1,162 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
agentServiceAccountId2,
|
|
4
|
+
assertObjectReadOutputWithinLimit2,
|
|
5
|
+
createAgentRuntimeAuthorization,
|
|
6
|
+
resolveRuntimeAuthorizationForProject,
|
|
7
|
+
getAuthorizationRef,
|
|
8
|
+
resolveExecutionScopeAuthorization,
|
|
9
|
+
AuthorizationError2,
|
|
10
|
+
isAllowed2,
|
|
11
|
+
assertAuthorized2,
|
|
12
|
+
isRuntimeAllowed2,
|
|
13
|
+
assertCanManageConnector2,
|
|
14
|
+
assertPrivileged2,
|
|
15
|
+
assertProviderAccess2,
|
|
16
|
+
canViewEvent2,
|
|
17
|
+
canViewActionRun2,
|
|
18
|
+
canViewWorkflowRun2,
|
|
19
|
+
canViewWorkflowIntervention2,
|
|
20
|
+
canViewPipelineRun2,
|
|
21
|
+
canViewProjectionRun2,
|
|
22
|
+
canViewProjection2
|
|
23
|
+
} from "./chunk-dz5h08xv.js";
|
|
7
24
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
aiUsageLimitUnavailableError,
|
|
11
|
-
applicableAiLimitPolicyStatuses
|
|
12
|
-
} from "./chunk-c15dr03f.js";
|
|
25
|
+
captureSixbFailure2
|
|
26
|
+
} from "./chunk-f4w3yp4f.js";
|
|
13
27
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
isRecord2,
|
|
29
|
+
normalizeSchemaValue2,
|
|
30
|
+
coerceSchemaValueToTyped2,
|
|
31
|
+
assertObjectTypeRegistered2
|
|
32
|
+
} from "./chunk-ms2tmn1k.js";
|
|
16
33
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
34
|
+
isActionDefinition2,
|
|
35
|
+
SYSTEM_PRINCIPAL2,
|
|
36
|
+
principalsEqual2
|
|
37
|
+
} from "./chunk-g00bfdq6.js";
|
|
20
38
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
getTelemetryHistoryBatch,
|
|
25
|
-
listObjects,
|
|
26
|
-
removeLink1 as removeLink,
|
|
27
|
-
upsertLink1 as upsertLink,
|
|
28
|
-
upsertLinkBatch1 as upsertLinkBatch,
|
|
29
|
-
upsertObject1 as upsertObject,
|
|
30
|
-
upsertObjectBatch1 as upsertObjectBatch
|
|
31
|
-
} from "./chunk-aa2pen2v.js";
|
|
39
|
+
isModelReasoning2,
|
|
40
|
+
modelReasoningSupportIssue2
|
|
41
|
+
} from "./chunk-pqajwytd.js";
|
|
32
42
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
RuntimeError2,
|
|
44
|
+
ModelProviderError2,
|
|
45
|
+
ModelStreamError2,
|
|
46
|
+
UnsupportedModelFeatureError2,
|
|
47
|
+
StructuredOutputError2,
|
|
48
|
+
estimateModelCall,
|
|
49
|
+
rateModelCall2
|
|
50
|
+
} from "./chunk-e0d1rzef.js";
|
|
35
51
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
AgentStorageError2,
|
|
53
|
+
AGENT_REASONING_LEVELS2
|
|
54
|
+
} from "./chunk-7bs40fe1.js";
|
|
55
|
+
import {
|
|
56
|
+
ObjectNotFoundError2
|
|
57
|
+
} from "./chunk-8vj0rjgs.js";
|
|
38
58
|
import {
|
|
39
|
-
|
|
40
|
-
} from "./chunk-
|
|
59
|
+
ExecutionStorageError2
|
|
60
|
+
} from "./chunk-93csa55g.js";
|
|
41
61
|
import {
|
|
42
|
-
|
|
43
|
-
} from "./chunk-
|
|
62
|
+
WORKFLOW_RUN_FAILURE_CODES2
|
|
63
|
+
} from "./chunk-mjbk2djy.js";
|
|
64
|
+
import {
|
|
65
|
+
WorkflowRunError2
|
|
66
|
+
} from "./chunk-pr2h4bv4.js";
|
|
44
67
|
import {
|
|
45
68
|
assertAuthorizedObjectReaderBinding,
|
|
46
|
-
canDelegationAccessActionRun,
|
|
47
69
|
getAuthorizedOntologyView,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
canDelegationAccessActionRun,
|
|
71
|
+
requestAction3,
|
|
72
|
+
requestActionAndWait2
|
|
73
|
+
} from "./chunk-ypbtykv6.js";
|
|
51
74
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} from "./chunk-k522z7v6.js";
|
|
75
|
+
shareSixbErrorReporter2,
|
|
76
|
+
reportRunFailure2
|
|
77
|
+
} from "./chunk-7apz6hg4.js";
|
|
56
78
|
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
aiLimitSubjectsFromAttribution2,
|
|
80
|
+
applicableAiLimitPolicyStatuses2,
|
|
81
|
+
aiUsageLimitExceededError2,
|
|
82
|
+
aiUsageLimitUnavailableError2
|
|
83
|
+
} from "./chunk-0y39rgsb.js";
|
|
60
84
|
import {
|
|
61
|
-
|
|
62
|
-
|
|
85
|
+
AgentRequestError2,
|
|
86
|
+
normalizeAgentContextEntries2
|
|
87
|
+
} from "./chunk-dmn70ztd.js";
|
|
63
88
|
import {
|
|
64
|
-
|
|
65
|
-
} from "./chunk-
|
|
89
|
+
publishAgentRunActivity2
|
|
90
|
+
} from "./chunk-92vk7gta.js";
|
|
66
91
|
import {
|
|
67
|
-
|
|
68
|
-
} from "./chunk-
|
|
92
|
+
registerConnectorConnectionsRuntime
|
|
93
|
+
} from "./chunk-5a4a52tq.js";
|
|
69
94
|
import {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
95
|
+
createConnectorRuntime,
|
|
96
|
+
SyncValidationError2,
|
|
97
|
+
requestSyncRun2
|
|
98
|
+
} from "./chunk-emyyk7dx.js";
|
|
73
99
|
import {
|
|
74
|
-
|
|
75
|
-
} from "./chunk-
|
|
100
|
+
writeDataset2
|
|
101
|
+
} from "./chunk-mrp7k0pw.js";
|
|
76
102
|
import {
|
|
77
|
-
|
|
78
|
-
} from "./chunk-
|
|
103
|
+
shareOntologyMutationRuntime2
|
|
104
|
+
} from "./chunk-zcnq6105.js";
|
|
79
105
|
import {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} from "./chunk-jq43kdvk.js";
|
|
106
|
+
compileShareAccessPlan
|
|
107
|
+
} from "./chunk-awbhdqyc.js";
|
|
83
108
|
import {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
109
|
+
getTelemetryHistoryBatch2,
|
|
110
|
+
getLatestTelemetryPoint,
|
|
111
|
+
createObjectSet2,
|
|
112
|
+
upsertLink3,
|
|
113
|
+
upsertLinkBatch3,
|
|
114
|
+
removeLink3,
|
|
115
|
+
listObjects,
|
|
116
|
+
upsertObject3,
|
|
117
|
+
upsertObjectBatch3,
|
|
118
|
+
appendTelemetry
|
|
119
|
+
} from "./chunk-1enhpacz.js";
|
|
87
120
|
import {
|
|
88
|
-
|
|
89
|
-
} from "./chunk-
|
|
121
|
+
schemaRecordToJsonSchema2
|
|
122
|
+
} from "./chunk-7zgecwy1.js";
|
|
90
123
|
import {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} from "./chunk-4sm0aznx.js";
|
|
124
|
+
PipelineError2,
|
|
125
|
+
requestPipelineRun2
|
|
126
|
+
} from "./chunk-jjy0fhrn.js";
|
|
95
127
|
import {
|
|
96
|
-
|
|
97
|
-
|
|
128
|
+
requireAccountingCapabilities,
|
|
129
|
+
aiModelCallOutputTokenAllowance,
|
|
130
|
+
createAiModelCallLimitController2,
|
|
131
|
+
AiModelCallRecorder2,
|
|
132
|
+
enqueueAiModelCallRecovery2,
|
|
133
|
+
resolveLanguageModel2
|
|
134
|
+
} from "./chunk-h1gfhhbh.js";
|
|
98
135
|
import {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} from "./chunk-2dw777qw.js";
|
|
136
|
+
getDatasetPrimaryKeyColumns2
|
|
137
|
+
} from "./chunk-9qsh3p5y.js";
|
|
102
138
|
import {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
assertObjectReadOutputWithinLimit,
|
|
108
|
-
assertPrivileged,
|
|
109
|
-
assertProviderAccess,
|
|
110
|
-
canViewActionRun,
|
|
111
|
-
canViewEvent,
|
|
112
|
-
canViewPipelineRun,
|
|
113
|
-
canViewProjection,
|
|
114
|
-
canViewProjectionRun,
|
|
115
|
-
canViewWorkflowIntervention,
|
|
116
|
-
canViewWorkflowRun,
|
|
117
|
-
createAgentRuntimeAuthorization,
|
|
118
|
-
getAuthorizationRef,
|
|
119
|
-
isAllowed,
|
|
120
|
-
isRuntimeAllowed,
|
|
121
|
-
resolveExecutionScopeAuthorization,
|
|
122
|
-
resolveRuntimeAuthorizationForProject
|
|
123
|
-
} from "./chunk-p1x242ad.js";
|
|
139
|
+
executionRecordInputFromRuntime,
|
|
140
|
+
ensureExecutionRecord2,
|
|
141
|
+
createPrimitiveExecutionRecord
|
|
142
|
+
} from "./chunk-17kfctj6.js";
|
|
124
143
|
import {
|
|
125
|
-
|
|
126
|
-
} from "./chunk-
|
|
144
|
+
ShareGrantStorageError2
|
|
145
|
+
} from "./chunk-br3k6qbf.js";
|
|
127
146
|
import {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} from "./chunk-
|
|
147
|
+
isObjectRefSchema2,
|
|
148
|
+
validateSchemaOrRefValue2
|
|
149
|
+
} from "./chunk-f0rwz2vh.js";
|
|
131
150
|
import {
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
supportsDirectUpload2,
|
|
152
|
+
supportsRangeRead2
|
|
153
|
+
} from "./chunk-h3v76ams.js";
|
|
134
154
|
import {
|
|
155
|
+
isJsonValue2,
|
|
156
|
+
assertJsonValue2,
|
|
157
|
+
assertJsonObject2,
|
|
135
158
|
isPlainRecord
|
|
136
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-wy0qdqfm.js";
|
|
137
160
|
|
|
138
161
|
// src/actions/descriptor.ts
|
|
139
162
|
function snapshotActionDescriptor(action) {
|
|
@@ -185,14 +208,14 @@ function createActionsRuntime(runtime, execution) {
|
|
|
185
208
|
}
|
|
186
209
|
if (authorization.type === "unrestricted")
|
|
187
210
|
return true;
|
|
188
|
-
return
|
|
211
|
+
return isAllowed2(authorization.context, { kind: "action.apply", actionId: action.id }) && (action.binding.kind === "global" || isAllowed2(authorization.context, {
|
|
189
212
|
kind: "object.view",
|
|
190
213
|
objectTypeId: action.binding.objectType.id
|
|
191
214
|
}));
|
|
192
215
|
};
|
|
193
216
|
const release = (value) => {
|
|
194
217
|
if (authorization.type === "delegated") {
|
|
195
|
-
|
|
218
|
+
assertObjectReadOutputWithinLimit2(value, authorization.objectRead.limits);
|
|
196
219
|
}
|
|
197
220
|
return value;
|
|
198
221
|
};
|
|
@@ -205,8 +228,8 @@ function createActionsRuntime(runtime, execution) {
|
|
|
205
228
|
},
|
|
206
229
|
listGlobal: () => describeAll(runtime.actionRegistry.listGlobal()),
|
|
207
230
|
listForType: (objectType) => describeAll(runtime.actionRegistry.listForType(objectType).filter((action) => authorization.type !== "delegated" || action.binding.kind === "object" && action.binding.objectType.id === objectType.id)),
|
|
208
|
-
request: (input) =>
|
|
209
|
-
requestAndWait: (input) =>
|
|
231
|
+
request: (input) => requestAction3(runtime, execution, input),
|
|
232
|
+
requestAndWait: (input) => requestActionAndWait2(runtime, execution, input),
|
|
210
233
|
runs: {
|
|
211
234
|
getById: async (runId) => {
|
|
212
235
|
if (authorization.type === "denied" || authorization.type === "delegated" && (!authorization.delegation || authorization.actionApply.length === 0))
|
|
@@ -215,7 +238,7 @@ function createActionsRuntime(runtime, execution) {
|
|
|
215
238
|
projectId,
|
|
216
239
|
id: runId
|
|
217
240
|
}) ?? null;
|
|
218
|
-
return run && (authorization.type === "unrestricted" || authorization.type === "principal" &&
|
|
241
|
+
return run && (authorization.type === "unrestricted" || authorization.type === "principal" && canViewActionRun2(authorization.context, run) || authorization.type === "delegated" && await canDelegationAccessActionRun({
|
|
219
242
|
storage: runtime.storage,
|
|
220
243
|
projectId,
|
|
221
244
|
authority: authorization,
|
|
@@ -271,26 +294,26 @@ async function resolveExecutionUsage(input) {
|
|
|
271
294
|
|
|
272
295
|
// src/agents/ids.ts
|
|
273
296
|
import { createHash, randomUUID } from "crypto";
|
|
274
|
-
function
|
|
297
|
+
function createAgentThreadId2() {
|
|
275
298
|
return `agt_thr_${randomUUID()}`;
|
|
276
299
|
}
|
|
277
|
-
function
|
|
300
|
+
function createAgentRunId2() {
|
|
278
301
|
return `agt_run_${randomUUID()}`;
|
|
279
302
|
}
|
|
280
|
-
function
|
|
303
|
+
function createSubagentRunId2(parentRunId, spawnKey) {
|
|
281
304
|
const digest = createHash("sha256").update(parentRunId).update("\x00").update(spawnKey).digest("hex");
|
|
282
305
|
return `agt_run_child_${digest}`;
|
|
283
306
|
}
|
|
284
|
-
function
|
|
307
|
+
function createSubagentExecutionId2(runId) {
|
|
285
308
|
return `exec_${runId}`;
|
|
286
309
|
}
|
|
287
|
-
function
|
|
310
|
+
function createAgentMessageId2() {
|
|
288
311
|
return `agt_msg_${randomUUID()}`;
|
|
289
312
|
}
|
|
290
|
-
function
|
|
313
|
+
function agentContextCheckpointId2(runId) {
|
|
291
314
|
return `agt_ctx_${runId}`;
|
|
292
315
|
}
|
|
293
|
-
function
|
|
316
|
+
function createAgentRunExecutionToken2() {
|
|
294
317
|
return `agt_exec_${randomUUID()}`;
|
|
295
318
|
}
|
|
296
319
|
|
|
@@ -298,8 +321,8 @@ function createAgentRunExecutionToken() {
|
|
|
298
321
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
299
322
|
|
|
300
323
|
// src/agents/context-resolution.ts
|
|
301
|
-
async function
|
|
302
|
-
const entries =
|
|
324
|
+
async function resolveAgentContextParts2(runtime, input) {
|
|
325
|
+
const entries = normalizeAgentContextEntries2(input);
|
|
303
326
|
for (const entry of entries) {
|
|
304
327
|
if (entry.context.kind !== "object")
|
|
305
328
|
continue;
|
|
@@ -320,20 +343,20 @@ async function resolveAgentContextParts(runtime, input) {
|
|
|
320
343
|
return entries.map((entry) => ({ type: "context", ...entry }));
|
|
321
344
|
}
|
|
322
345
|
function invalidContext(message) {
|
|
323
|
-
throw new
|
|
346
|
+
throw new AgentRequestError2("invalid_context", `[Sixb] Invalid agent context: ${message}.`);
|
|
324
347
|
}
|
|
325
348
|
|
|
326
349
|
// src/agents/dispatch.ts
|
|
327
|
-
function
|
|
350
|
+
function agentRunQueueJobId2(runId) {
|
|
328
351
|
return `agt_job_${runId}`;
|
|
329
352
|
}
|
|
330
|
-
function
|
|
353
|
+
function subagentRunQueueJobId2(runId) {
|
|
331
354
|
return `agt_child_job_${runId}`;
|
|
332
355
|
}
|
|
333
|
-
function
|
|
356
|
+
function workflowAgentNodeQueueJobId2(nodeRunId) {
|
|
334
357
|
return `wfa_job_${nodeRunId}`;
|
|
335
358
|
}
|
|
336
|
-
async function
|
|
359
|
+
async function dispatchQueuedAgentRuns2(input) {
|
|
337
360
|
const limit = normalizeLimit(input.limit);
|
|
338
361
|
const runs = input.runIds ? await input.storage.runs.getByIds({
|
|
339
362
|
projectId: input.projectId,
|
|
@@ -353,14 +376,14 @@ async function dispatchQueuedAgentRuns(input) {
|
|
|
353
376
|
const jobs = await input.queue.enqueue({
|
|
354
377
|
projectId: input.projectId,
|
|
355
378
|
jobs: queued.map((run) => ({
|
|
356
|
-
id:
|
|
379
|
+
id: agentRunQueueJobId2(run.id),
|
|
357
380
|
type: "agent.run.requested",
|
|
358
381
|
payload: { runId: run.id }
|
|
359
382
|
}))
|
|
360
383
|
});
|
|
361
384
|
const jobsById = new Map(jobs.map((job) => [job.id, job]));
|
|
362
385
|
const dispatched = queued.map((run) => {
|
|
363
|
-
const jobId =
|
|
386
|
+
const jobId = agentRunQueueJobId2(run.id);
|
|
364
387
|
if (!jobsById.has(jobId)) {
|
|
365
388
|
throw new Error(`[Sixb] Agent queue did not return job '${jobId}'.`);
|
|
366
389
|
}
|
|
@@ -375,7 +398,7 @@ async function dispatchQueuedAgentRuns(input) {
|
|
|
375
398
|
};
|
|
376
399
|
}
|
|
377
400
|
}
|
|
378
|
-
async function
|
|
401
|
+
async function dispatchQueuedSubagentRuns2(input) {
|
|
379
402
|
const limit = normalizeLimit(input.limit);
|
|
380
403
|
const runs = input.runIds ? await input.storage.runs.getByIds({
|
|
381
404
|
projectId: input.projectId,
|
|
@@ -394,14 +417,14 @@ async function dispatchQueuedSubagentRuns(input) {
|
|
|
394
417
|
const jobs = await input.queue.enqueue({
|
|
395
418
|
projectId: input.projectId,
|
|
396
419
|
jobs: queued.map((run) => ({
|
|
397
|
-
id:
|
|
420
|
+
id: subagentRunQueueJobId2(run.id),
|
|
398
421
|
type: "agent.subagent-run.requested",
|
|
399
422
|
payload: { runId: run.id }
|
|
400
423
|
}))
|
|
401
424
|
});
|
|
402
425
|
const jobsById = new Set(jobs.map((job) => job.id));
|
|
403
426
|
const dispatched = queued.map((run) => {
|
|
404
|
-
const jobId =
|
|
427
|
+
const jobId = subagentRunQueueJobId2(run.id);
|
|
405
428
|
if (!jobsById.has(jobId)) {
|
|
406
429
|
throw new Error(`[Sixb] Subagent queue did not return job '${jobId}'.`);
|
|
407
430
|
}
|
|
@@ -428,37 +451,32 @@ function normalizeLimit(value) {
|
|
|
428
451
|
// src/agents/retired-config.ts
|
|
429
452
|
function assertNoAgentDefinitions(input) {
|
|
430
453
|
if ("agents" in input) {
|
|
431
|
-
throw new
|
|
454
|
+
throw new RuntimeError2("[Sixb] Agent definitions are no longer supported. Configure 'models' and 'tools' on createSixb() instead.");
|
|
432
455
|
}
|
|
433
456
|
}
|
|
434
457
|
function assertNoAgentSelector(input) {
|
|
435
458
|
if ("agentId" in input || "agentIds" in input) {
|
|
436
|
-
throw new
|
|
459
|
+
throw new AgentRequestError2("agent_selector_removed", "[Sixb] There is one project Agent. Remove the agentId selector and use sixb.agent.");
|
|
437
460
|
}
|
|
438
461
|
}
|
|
439
462
|
|
|
440
463
|
// src/agents/request.ts
|
|
441
|
-
async function
|
|
464
|
+
async function requestAgentRun2(runtime, execution, models, input) {
|
|
442
465
|
const authority = resolveExecutionScopeAuthorization(runtime.projectId, {
|
|
443
466
|
execution,
|
|
444
467
|
authorization: runtime.runtimeAuthorization
|
|
445
468
|
});
|
|
446
469
|
assertNoAgentSelector(input);
|
|
447
|
-
|
|
470
|
+
assertAuthorized2(runtime, { kind: "agent.run" });
|
|
448
471
|
assertRequestAuthorityCanRunAgent(runtime);
|
|
449
472
|
const spec = resolveConversationRunSpec({ models, input });
|
|
450
|
-
const contextParts = await
|
|
473
|
+
const contextParts = await resolveAgentContextParts2(runtime, input.context);
|
|
451
474
|
const agents = requireAgentStorage(runtime);
|
|
452
475
|
const projectId = runtime.projectId;
|
|
453
|
-
const principal = authority.type === "principal" ? authority.context.principal : input.principal ??
|
|
454
|
-
const runId =
|
|
476
|
+
const principal = authority.type === "principal" ? authority.context.principal : input.principal ?? SYSTEM_PRINCIPAL2;
|
|
477
|
+
const runId = createAgentRunId2();
|
|
455
478
|
const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
|
|
456
|
-
|
|
457
|
-
auth: runtime.storage.auth,
|
|
458
|
-
projectId,
|
|
459
|
-
principal: durableExecution.requestedBy
|
|
460
|
-
}) : [];
|
|
461
|
-
await assertAiLimitPreflight(runtime, durableExecution, requesterGroupIds);
|
|
479
|
+
await assertAiLimitPreflight(runtime, durableExecution);
|
|
462
480
|
const { thread, createdThread } = await resolveThread(agents, {
|
|
463
481
|
projectId,
|
|
464
482
|
threadId: input.threadId,
|
|
@@ -466,18 +484,18 @@ async function requestAgentRun(runtime, execution, models, input) {
|
|
|
466
484
|
principal
|
|
467
485
|
});
|
|
468
486
|
if (thread.activeRunId !== null) {
|
|
469
|
-
throw new
|
|
487
|
+
throw new AgentRequestError2("active_run_exists", `[Sixb] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`);
|
|
470
488
|
}
|
|
471
|
-
const triggerMessageId = input.messageId ??
|
|
489
|
+
const triggerMessageId = input.messageId ?? createAgentMessageId2();
|
|
472
490
|
let run;
|
|
473
491
|
try {
|
|
474
492
|
run = await runtime.storage.transaction(async (tx) => {
|
|
475
|
-
const
|
|
476
|
-
if (!
|
|
477
|
-
throw new
|
|
493
|
+
const agents = tx.agents;
|
|
494
|
+
if (!agents) {
|
|
495
|
+
throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
478
496
|
}
|
|
479
497
|
await tx.executions.create(durableExecution);
|
|
480
|
-
await
|
|
498
|
+
await agents.messages.append({
|
|
481
499
|
id: triggerMessageId,
|
|
482
500
|
projectId,
|
|
483
501
|
threadId: thread.id,
|
|
@@ -490,19 +508,18 @@ async function requestAgentRun(runtime, execution, models, input) {
|
|
|
490
508
|
],
|
|
491
509
|
authorPrincipal: principal
|
|
492
510
|
});
|
|
493
|
-
return
|
|
511
|
+
return agents.runs.create({
|
|
494
512
|
id: runId,
|
|
495
513
|
projectId,
|
|
496
514
|
executionId: durableExecution.id,
|
|
497
515
|
threadId: thread.id,
|
|
498
516
|
triggerMessageId,
|
|
499
|
-
spec
|
|
500
|
-
requesterGroupIds
|
|
517
|
+
spec
|
|
501
518
|
});
|
|
502
519
|
});
|
|
503
520
|
} catch (error) {
|
|
504
|
-
if (error instanceof
|
|
505
|
-
throw new
|
|
521
|
+
if (error instanceof AgentStorageError2 && error.code === "active_run_exists") {
|
|
522
|
+
throw new AgentRequestError2("active_run_exists", error.message);
|
|
506
523
|
}
|
|
507
524
|
throw error;
|
|
508
525
|
}
|
|
@@ -514,15 +531,15 @@ async function requestAgentRun(runtime, execution, models, input) {
|
|
|
514
531
|
createdThread
|
|
515
532
|
};
|
|
516
533
|
}
|
|
517
|
-
async function
|
|
534
|
+
async function retryAgentRun2(runtime, execution, models, failedRun) {
|
|
518
535
|
resolveExecutionScopeAuthorization(runtime.projectId, {
|
|
519
536
|
execution,
|
|
520
537
|
authorization: runtime.runtimeAuthorization
|
|
521
538
|
});
|
|
522
|
-
|
|
539
|
+
assertAuthorized2(runtime, { kind: "agent.run" });
|
|
523
540
|
assertRequestAuthorityCanRunAgent(runtime);
|
|
524
541
|
if (failedRun.status !== "failed") {
|
|
525
|
-
throw new
|
|
542
|
+
throw new AgentRequestError2("run_not_retryable", `[Sixb] Only failed Agent runs can be retried.`);
|
|
526
543
|
}
|
|
527
544
|
const agents = requireAgentStorage(runtime);
|
|
528
545
|
const thread = await agents.threads.getById({
|
|
@@ -530,28 +547,23 @@ async function retryAgentRun(runtime, execution, models, failedRun) {
|
|
|
530
547
|
id: failedRun.threadId
|
|
531
548
|
});
|
|
532
549
|
if (!thread) {
|
|
533
|
-
throw new
|
|
550
|
+
throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${failedRun.threadId}' was not found.`);
|
|
534
551
|
}
|
|
535
|
-
const runId =
|
|
552
|
+
const runId = createAgentRunId2();
|
|
536
553
|
const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
|
|
537
|
-
|
|
538
|
-
auth: runtime.storage.auth,
|
|
539
|
-
projectId: runtime.projectId,
|
|
540
|
-
principal: durableExecution.requestedBy
|
|
541
|
-
}) : [];
|
|
542
|
-
await assertAiLimitPreflight(runtime, durableExecution, requesterGroupIds);
|
|
554
|
+
await assertAiLimitPreflight(runtime, durableExecution);
|
|
543
555
|
const run = await runtime.storage.transaction(async (tx) => {
|
|
544
|
-
const
|
|
545
|
-
if (!
|
|
546
|
-
throw new
|
|
556
|
+
const agents = tx.agents;
|
|
557
|
+
if (!agents) {
|
|
558
|
+
throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
547
559
|
}
|
|
548
|
-
await
|
|
560
|
+
await agents.messages.deleteByRunId({
|
|
549
561
|
projectId: runtime.projectId,
|
|
550
562
|
threadId: failedRun.threadId,
|
|
551
563
|
runId: failedRun.id
|
|
552
564
|
});
|
|
553
565
|
await tx.executions.create(durableExecution);
|
|
554
|
-
return
|
|
566
|
+
return agents.runs.create({
|
|
555
567
|
id: runId,
|
|
556
568
|
projectId: runtime.projectId,
|
|
557
569
|
executionId: durableExecution.id,
|
|
@@ -560,47 +572,46 @@ async function retryAgentRun(runtime, execution, models, failedRun) {
|
|
|
560
572
|
spec: failedRun.spec ?? resolveConversationRunSpec({
|
|
561
573
|
models,
|
|
562
574
|
input: {}
|
|
563
|
-
})
|
|
564
|
-
requesterGroupIds
|
|
575
|
+
})
|
|
565
576
|
});
|
|
566
577
|
});
|
|
567
578
|
await publishRunActivity(runtime, run);
|
|
568
579
|
const jobId = await dispatchAgentRun(runtime, agents, runId);
|
|
569
580
|
return { run, ...jobId ? { jobId } : {}, createdThread: false };
|
|
570
581
|
}
|
|
571
|
-
async function assertAiLimitPreflight(runtime, execution
|
|
582
|
+
async function assertAiLimitPreflight(runtime, execution) {
|
|
572
583
|
const limits = runtime.storage.aiLimits;
|
|
573
584
|
if (!limits)
|
|
574
|
-
throw
|
|
575
|
-
const subjects =
|
|
585
|
+
throw aiUsageLimitUnavailableError2(["limitStorageUnavailable"]);
|
|
586
|
+
const subjects = aiLimitSubjectsFromAttribution2(execution.requestedBy, execution.requesterGroupIds);
|
|
576
587
|
let applicable;
|
|
577
588
|
try {
|
|
578
|
-
applicable =
|
|
589
|
+
applicable = applicableAiLimitPolicyStatuses2(await limits.listPolicyStatuses({ projectId: runtime.projectId }), subjects);
|
|
579
590
|
} catch {
|
|
580
|
-
throw
|
|
591
|
+
throw aiUsageLimitUnavailableError2(["limitStorageUnavailable"]);
|
|
581
592
|
}
|
|
582
593
|
const unavailable = applicable.filter((status) => status.accountingStatus === "unavailable");
|
|
583
594
|
if (unavailable.length > 0) {
|
|
584
|
-
throw
|
|
595
|
+
throw aiUsageLimitUnavailableError2(["incompleteAccounting"]);
|
|
585
596
|
}
|
|
586
597
|
const exhausted = applicable.filter((status) => status.exhausted);
|
|
587
598
|
if (exhausted.length > 0) {
|
|
588
599
|
const resetAt = new Date(Math.min(...exhausted.map((status) => status.period.resetAt.getTime())));
|
|
589
|
-
throw
|
|
600
|
+
throw aiUsageLimitExceededError2(resetAt);
|
|
590
601
|
}
|
|
591
602
|
}
|
|
592
603
|
function resolveConversationRunSpec(input) {
|
|
593
604
|
if (!input.models) {
|
|
594
|
-
throw new
|
|
605
|
+
throw new AgentRequestError2("model_not_found", "[Sixb] Configure models.language before starting the Agent.");
|
|
595
606
|
}
|
|
596
607
|
const selected = input.input.model ?? input.models.default;
|
|
597
608
|
const model = input.models.getByRef(selected);
|
|
598
609
|
if (model === null) {
|
|
599
|
-
throw new
|
|
610
|
+
throw new AgentRequestError2("model_not_found", `[Sixb] Language model '${selected.provider}/${selected.modelId}' is not in the project model catalog.`);
|
|
600
611
|
}
|
|
601
612
|
const reasoning = input.input.reasoning;
|
|
602
|
-
if (reasoning !== undefined && !
|
|
603
|
-
throw new
|
|
613
|
+
if (reasoning !== undefined && !isModelReasoning2(reasoning)) {
|
|
614
|
+
throw new AgentRequestError2("invalid_model_selection", `[Sixb] Agent reasoning must be one of: ${AGENT_REASONING_LEVELS2.join(", ")}, or a nonnegative budgetTokens object.`);
|
|
604
615
|
}
|
|
605
616
|
return Object.freeze({
|
|
606
617
|
model: Object.freeze({ provider: selected.provider, modelId: selected.modelId }),
|
|
@@ -608,24 +619,24 @@ function resolveConversationRunSpec(input) {
|
|
|
608
619
|
});
|
|
609
620
|
}
|
|
610
621
|
async function prepareDurableAgentExecution(runtime, execution, runId) {
|
|
611
|
-
const parent = await
|
|
622
|
+
const parent = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
612
623
|
execution,
|
|
613
624
|
runtimeAuthorization: runtime.runtimeAuthorization
|
|
614
625
|
}));
|
|
615
|
-
return
|
|
626
|
+
return createInheritedAgentExecutionRecord2({
|
|
616
627
|
id: `exec_${randomUUID2()}`,
|
|
617
628
|
parent,
|
|
618
629
|
runId
|
|
619
630
|
});
|
|
620
631
|
}
|
|
621
632
|
function assertRequestAuthorityCanRunAgent(runtime) {
|
|
622
|
-
if (!
|
|
623
|
-
throw new
|
|
633
|
+
if (!canInheritAgentRequestAuthorization2(runtime.runtimeAuthorization)) {
|
|
634
|
+
throw new AgentRequestError2("authority_not_inheritable", "[Sixb] The Agent requires an authenticated user request or disabled authorization.");
|
|
624
635
|
}
|
|
625
636
|
}
|
|
626
637
|
async function dispatchAgentRun(runtime, agents, runId) {
|
|
627
638
|
try {
|
|
628
|
-
const dispatch = await
|
|
639
|
+
const dispatch = await dispatchQueuedAgentRuns2({
|
|
629
640
|
projectId: runtime.projectId,
|
|
630
641
|
storage: agents,
|
|
631
642
|
queue: runtime.queues.agents,
|
|
@@ -643,7 +654,7 @@ async function dispatchAgentRun(runtime, agents, runId) {
|
|
|
643
654
|
}
|
|
644
655
|
async function publishRunActivity(runtime, run) {
|
|
645
656
|
try {
|
|
646
|
-
await
|
|
657
|
+
await publishAgentRunActivity2(runtime.broker, run);
|
|
647
658
|
} catch (error) {
|
|
648
659
|
console.error(`[Sixb] Agent run '${run.id}' activity stream publish failed:`, error);
|
|
649
660
|
}
|
|
@@ -659,7 +670,7 @@ async function resolveThread(agents, params) {
|
|
|
659
670
|
}
|
|
660
671
|
}
|
|
661
672
|
const thread = await agents.threads.create({
|
|
662
|
-
id: params.threadId ??
|
|
673
|
+
id: params.threadId ?? createAgentThreadId2(),
|
|
663
674
|
projectId: params.projectId,
|
|
664
675
|
ownerPrincipal: params.principal,
|
|
665
676
|
...params.title === undefined ? {} : { title: params.title }
|
|
@@ -669,7 +680,7 @@ async function resolveThread(agents, params) {
|
|
|
669
680
|
function requireAgentStorage(runtime) {
|
|
670
681
|
const agents = runtime.storage.agents;
|
|
671
682
|
if (!agents) {
|
|
672
|
-
throw new
|
|
683
|
+
throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
673
684
|
}
|
|
674
685
|
return agents;
|
|
675
686
|
}
|
|
@@ -677,8 +688,8 @@ function requireAgentStorage(runtime) {
|
|
|
677
688
|
// src/agents/execution.ts
|
|
678
689
|
function createAgentRuntime(runtime, execution, models) {
|
|
679
690
|
const authority = resolveRuntimeAuthorizationForProject(runtime);
|
|
680
|
-
const principal = authority.type === "principal" ? authority.context.principal :
|
|
681
|
-
const allowed = () =>
|
|
691
|
+
const principal = authority.type === "principal" ? authority.context.principal : SYSTEM_PRINCIPAL2;
|
|
692
|
+
const allowed = () => isRuntimeAllowed2(runtime, { kind: "agent.run" });
|
|
682
693
|
const getVisibleThreadRecord = async (threadId) => {
|
|
683
694
|
if (authority.type === "denied" || authority.type === "delegated")
|
|
684
695
|
return null;
|
|
@@ -688,7 +699,7 @@ function createAgentRuntime(runtime, execution, models) {
|
|
|
688
699
|
}) ?? null;
|
|
689
700
|
if (!thread || !allowed())
|
|
690
701
|
return null;
|
|
691
|
-
return authority.type === "principal" && !
|
|
702
|
+
return authority.type === "principal" && !principalsEqual2(principal, thread.ownerPrincipal) ? null : thread;
|
|
692
703
|
};
|
|
693
704
|
const getAgent = () => {
|
|
694
705
|
if (authority.type === "denied" || authority.type === "delegated")
|
|
@@ -724,14 +735,14 @@ function createAgentRuntime(runtime, execution, models) {
|
|
|
724
735
|
assertNoAgentSelector(input);
|
|
725
736
|
const agent = getAgent();
|
|
726
737
|
if (!agent) {
|
|
727
|
-
throw new
|
|
738
|
+
throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
728
739
|
}
|
|
729
740
|
const storage = runtime.storage.agents;
|
|
730
741
|
if (!storage) {
|
|
731
|
-
throw new
|
|
742
|
+
throw new AgentRequestError2("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
732
743
|
}
|
|
733
744
|
return storage.threads.create({
|
|
734
|
-
id: input.id ??
|
|
745
|
+
id: input.id ?? createAgentThreadId2(),
|
|
735
746
|
projectId: runtime.projectId,
|
|
736
747
|
ownerPrincipal: principal,
|
|
737
748
|
...input.title === undefined ? {} : { title: input.title }
|
|
@@ -758,13 +769,13 @@ function createAgentRuntime(runtime, execution, models) {
|
|
|
758
769
|
assertNoAgentSelector(input);
|
|
759
770
|
const agent = getAgent();
|
|
760
771
|
if (!agent) {
|
|
761
|
-
throw new
|
|
772
|
+
throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
762
773
|
}
|
|
763
|
-
|
|
774
|
+
assertAuthorized2(runtime, { kind: "agent.run" });
|
|
764
775
|
if (input.threadId && !await getVisibleThreadRecord(input.threadId)) {
|
|
765
|
-
throw new
|
|
776
|
+
throw new AgentRequestError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found.`);
|
|
766
777
|
}
|
|
767
|
-
const result = await
|
|
778
|
+
const result = await requestAgentRun2(runtime, execution, models?.language, {
|
|
768
779
|
...input,
|
|
769
780
|
principal
|
|
770
781
|
});
|
|
@@ -773,13 +784,13 @@ function createAgentRuntime(runtime, execution, models) {
|
|
|
773
784
|
retry: async (runId) => {
|
|
774
785
|
const failedRun = await getVisibleRunRecord(runId);
|
|
775
786
|
if (!failedRun) {
|
|
776
|
-
throw new
|
|
787
|
+
throw new AgentRequestError2("run_not_found", `[Sixb] Agent run '${runId}' was not found.`);
|
|
777
788
|
}
|
|
778
789
|
const agent = getAgent();
|
|
779
790
|
if (!agent) {
|
|
780
|
-
throw new
|
|
791
|
+
throw new AgentRequestError2("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
781
792
|
}
|
|
782
|
-
const result = await
|
|
793
|
+
const result = await retryAgentRun2(runtime, execution, models?.language, failedRun);
|
|
783
794
|
return { ...result, run: await attachRunView(runtime, result.run) };
|
|
784
795
|
},
|
|
785
796
|
getById: getRun,
|
|
@@ -844,10 +855,10 @@ async function attachRunViews(runtime, runs) {
|
|
|
844
855
|
// src/ai-usage/execution.ts
|
|
845
856
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
846
857
|
function createAiUsageRuntime(runtime, security) {
|
|
847
|
-
const assertObservable = () =>
|
|
848
|
-
const assertManageable = () =>
|
|
858
|
+
const assertObservable = () => assertAuthorized2(runtime, { kind: "aiUsage.observe" });
|
|
859
|
+
const assertManageable = () => assertAuthorized2(runtime, { kind: "aiUsage.manage" });
|
|
849
860
|
const assertPolicyReadable = () => {
|
|
850
|
-
if (!
|
|
861
|
+
if (!isRuntimeAllowed2(runtime, { kind: "aiUsage.observe" }) && !isRuntimeAllowed2(runtime, { kind: "aiUsage.manage" })) {
|
|
851
862
|
assertObservable();
|
|
852
863
|
}
|
|
853
864
|
};
|
|
@@ -868,7 +879,7 @@ function createAiUsageRuntime(runtime, security) {
|
|
|
868
879
|
limitsConfigured: runtime.storage.aiLimits !== undefined,
|
|
869
880
|
assertObservable,
|
|
870
881
|
assertManageable,
|
|
871
|
-
canManageLimits: () =>
|
|
882
|
+
canManageLimits: () => isRuntimeAllowed2(runtime, { kind: "aiUsage.manage" }),
|
|
872
883
|
queryOverview: (input) => {
|
|
873
884
|
assertObservable();
|
|
874
885
|
return requireCosts().queryProjectOverview({ ...input, projectId: runtime.projectId });
|
|
@@ -943,7 +954,7 @@ function createAiUsageRuntime(runtime, security) {
|
|
|
943
954
|
}
|
|
944
955
|
// src/blob-storage/execution.ts
|
|
945
956
|
function createBlobsRuntime(runtime, execution, blobStorage) {
|
|
946
|
-
const assertAccess = () =>
|
|
957
|
+
const assertAccess = () => assertProviderAccess2(runtime, execution, "blobs.access");
|
|
947
958
|
const executionBlobs = {
|
|
948
959
|
put: (input) => {
|
|
949
960
|
assertAccess();
|
|
@@ -958,13 +969,13 @@ function createBlobsRuntime(runtime, execution, blobStorage) {
|
|
|
958
969
|
return blobStorage.stat(blobId);
|
|
959
970
|
}
|
|
960
971
|
};
|
|
961
|
-
if (
|
|
972
|
+
if (supportsRangeRead2(blobStorage)) {
|
|
962
973
|
executionBlobs.openRange = (blobId, range) => {
|
|
963
974
|
assertAccess();
|
|
964
975
|
return blobStorage.openRange(blobId, range);
|
|
965
976
|
};
|
|
966
977
|
}
|
|
967
|
-
if (
|
|
978
|
+
if (supportsDirectUpload2(blobStorage)) {
|
|
968
979
|
executionBlobs.createUpload = (input) => {
|
|
969
980
|
assertAccess();
|
|
970
981
|
return blobStorage.createUpload(input);
|
|
@@ -1010,12 +1021,12 @@ function commandContext(runtime, execution, connectorId) {
|
|
|
1010
1021
|
authorization: runtime.runtimeAuthorization
|
|
1011
1022
|
});
|
|
1012
1023
|
if (execution.executor.type !== "request" || resolved.type !== "principal" || resolved.ref.type !== "principal") {
|
|
1013
|
-
throw new
|
|
1024
|
+
throw new AuthorizationError2(`manage:connector:${connectorId}`, "[Sixb] Connector connections can only be managed by an authenticated request.");
|
|
1014
1025
|
}
|
|
1015
1026
|
if (!resolved.ref.credential) {
|
|
1016
|
-
throw new
|
|
1027
|
+
throw new AuthorizationError2(`manage:connector:${connectorId}`, "[Sixb] Connector connection management requires a session or access token.");
|
|
1017
1028
|
}
|
|
1018
|
-
|
|
1029
|
+
assertCanManageConnector2(runtime, connectorId);
|
|
1019
1030
|
return Object.freeze({
|
|
1020
1031
|
execution: Object.freeze(executionRecordInputFromRuntime({
|
|
1021
1032
|
execution,
|
|
@@ -1027,7 +1038,7 @@ function commandContext(runtime, execution, connectorId) {
|
|
|
1027
1038
|
// src/datasets/execution.ts
|
|
1028
1039
|
function createDatasetsRuntime(runtime, execution, source, lakeStorage, blobStorage) {
|
|
1029
1040
|
const authority = resolveRuntimeAuthorizationForProject(runtime);
|
|
1030
|
-
const allowed = (datasetId) =>
|
|
1041
|
+
const allowed = (datasetId) => isRuntimeAllowed2(runtime, { kind: "dataset.view", datasetId });
|
|
1031
1042
|
return {
|
|
1032
1043
|
list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((dataset) => allowed(dataset.id)),
|
|
1033
1044
|
getById: (datasetId) => {
|
|
@@ -1037,18 +1048,18 @@ function createDatasetsRuntime(runtime, execution, source, lakeStorage, blobStor
|
|
|
1037
1048
|
return dataset && allowed(datasetId) ? dataset : null;
|
|
1038
1049
|
},
|
|
1039
1050
|
async ingest(dataset, input) {
|
|
1040
|
-
|
|
1051
|
+
assertPrivileged2(runtime, "datasets.ingest");
|
|
1041
1052
|
const registered = source.getById(dataset.id);
|
|
1042
1053
|
if (!registered)
|
|
1043
1054
|
throw new Error(`[Sixb] Dataset '${dataset.id}' is not registered.`);
|
|
1044
|
-
if (
|
|
1055
|
+
if (getDatasetPrimaryKeyColumns2(registered) === null) {
|
|
1045
1056
|
throw new Error(`[Sixb] Dataset '${dataset.id}' must define a primaryKey before ingestion.`);
|
|
1046
1057
|
}
|
|
1047
1058
|
if (typeof lakeStorage.beginMerge !== "function") {
|
|
1048
1059
|
throw new Error("[Sixb] Dataset ingestion requires a lake provider with merge support.");
|
|
1049
1060
|
}
|
|
1050
1061
|
const producer = { kind: "ingest", id: execution.id };
|
|
1051
|
-
const result = await
|
|
1062
|
+
const result = await writeDataset2({
|
|
1052
1063
|
lakeStorage,
|
|
1053
1064
|
blobStorage,
|
|
1054
1065
|
dataset: registered,
|
|
@@ -1090,7 +1101,7 @@ function createEventsRuntime(runtime) {
|
|
|
1090
1101
|
case "delegated":
|
|
1091
1102
|
return [];
|
|
1092
1103
|
case "principal":
|
|
1093
|
-
return events.filter((event) =>
|
|
1104
|
+
return events.filter((event) => canViewEvent2(authority.context, event));
|
|
1094
1105
|
case "unrestricted":
|
|
1095
1106
|
return [...events];
|
|
1096
1107
|
}
|
|
@@ -1102,17 +1113,17 @@ function createEventsRuntime(runtime) {
|
|
|
1102
1113
|
case "delegated":
|
|
1103
1114
|
return false;
|
|
1104
1115
|
case "principal":
|
|
1105
|
-
return
|
|
1116
|
+
return canViewEvent2(authority.context, event);
|
|
1106
1117
|
case "unrestricted":
|
|
1107
1118
|
return true;
|
|
1108
1119
|
}
|
|
1109
1120
|
},
|
|
1110
1121
|
append: (input) => {
|
|
1111
|
-
|
|
1122
|
+
assertPrivileged2(runtime, "events.append");
|
|
1112
1123
|
return runtime.events.append(input);
|
|
1113
1124
|
},
|
|
1114
1125
|
emit: (input, options) => {
|
|
1115
|
-
|
|
1126
|
+
assertPrivileged2(runtime, "events.emit");
|
|
1116
1127
|
return runtime.events.emit(input, options);
|
|
1117
1128
|
},
|
|
1118
1129
|
read: async (input) => {
|
|
@@ -1157,7 +1168,7 @@ function createEventsRuntime(runtime) {
|
|
|
1157
1168
|
|
|
1158
1169
|
// src/logging/execution.ts
|
|
1159
1170
|
function createLogsRuntime(runtime, source) {
|
|
1160
|
-
const assertObservable = () =>
|
|
1171
|
+
const assertObservable = () => assertAuthorized2(runtime, { kind: "logs.observe" });
|
|
1161
1172
|
return {
|
|
1162
1173
|
assertObservable,
|
|
1163
1174
|
read: (input) => {
|
|
@@ -1171,6 +1182,949 @@ function createLogsRuntime(runtime, source) {
|
|
|
1171
1182
|
};
|
|
1172
1183
|
}
|
|
1173
1184
|
|
|
1185
|
+
// src/agents/model-loop.ts
|
|
1186
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
1187
|
+
var MAX_PROVIDER_DATA_BYTES = 256 * 1024;
|
|
1188
|
+
async function runModelLoop2(input) {
|
|
1189
|
+
assertLoopInput(input);
|
|
1190
|
+
const tools = indexTools(input.tools ?? []);
|
|
1191
|
+
const toolSpecifications = [...tools.values()].map((tool) => ({
|
|
1192
|
+
name: tool.name,
|
|
1193
|
+
description: tool.description,
|
|
1194
|
+
inputSchema: tool.inputSchema
|
|
1195
|
+
}));
|
|
1196
|
+
let messages = [...input.messages];
|
|
1197
|
+
const steps = [];
|
|
1198
|
+
const generateCallId = input.generateCallId ?? (() => `model_call_${randomUUID4()}`);
|
|
1199
|
+
const callIds = new Set;
|
|
1200
|
+
for (let stepIndex = 0;stepIndex < input.maxSteps; stepIndex += 1) {
|
|
1201
|
+
if (input.signal.aborted) {
|
|
1202
|
+
return { status: "aborted", steps, partialContent: [] };
|
|
1203
|
+
}
|
|
1204
|
+
await input.onEvent?.({ type: "start-step" });
|
|
1205
|
+
let requestMessages;
|
|
1206
|
+
try {
|
|
1207
|
+
const prepared = await input.prepareStep?.({
|
|
1208
|
+
stepIndex,
|
|
1209
|
+
messages,
|
|
1210
|
+
model: input.model,
|
|
1211
|
+
signal: input.signal
|
|
1212
|
+
});
|
|
1213
|
+
requestMessages = prepared?.messages ?? messages;
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
if (!input.signal.aborted && !isAbortError(error))
|
|
1216
|
+
throw error;
|
|
1217
|
+
return { status: "aborted", steps, partialContent: [] };
|
|
1218
|
+
}
|
|
1219
|
+
if (input.signal.aborted) {
|
|
1220
|
+
return { status: "aborted", steps, partialContent: [] };
|
|
1221
|
+
}
|
|
1222
|
+
let requestTools = toolSpecifications;
|
|
1223
|
+
if (input.finalStepInstruction !== undefined && stepIndex === input.maxSteps - 1) {
|
|
1224
|
+
requestMessages = [
|
|
1225
|
+
...requestMessages,
|
|
1226
|
+
{ role: "user", content: [{ type: "text", text: input.finalStepInstruction }] }
|
|
1227
|
+
];
|
|
1228
|
+
requestTools = [];
|
|
1229
|
+
}
|
|
1230
|
+
const callId = generateCallId();
|
|
1231
|
+
if (!callId || callIds.has(callId)) {
|
|
1232
|
+
throw new ModelStreamError2(`[SixbModels] Model call IDs must be nonempty and unique.`);
|
|
1233
|
+
}
|
|
1234
|
+
callIds.add(callId);
|
|
1235
|
+
const accumulator = new StreamAccumulator(input.onEvent);
|
|
1236
|
+
let accepted = false;
|
|
1237
|
+
let cost = { status: "unpriceable", reason: "missing-usage" };
|
|
1238
|
+
let terminalStreamError;
|
|
1239
|
+
try {
|
|
1240
|
+
const stream = await input.model.stream({
|
|
1241
|
+
callId,
|
|
1242
|
+
messages: requestMessages,
|
|
1243
|
+
tools: requestTools,
|
|
1244
|
+
...input.reasoning === undefined ? {} : { reasoning: input.reasoning },
|
|
1245
|
+
...input.maxOutputTokens === undefined ? {} : { maxOutputTokens: input.maxOutputTokens },
|
|
1246
|
+
...input.caching === undefined ? {} : { caching: input.caching },
|
|
1247
|
+
...input.output === undefined ? {} : {
|
|
1248
|
+
responseFormat: {
|
|
1249
|
+
type: "json",
|
|
1250
|
+
name: input.output.name,
|
|
1251
|
+
...input.output.description === undefined ? {} : { description: input.output.description },
|
|
1252
|
+
schema: input.output.schema
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
signal: input.signal
|
|
1256
|
+
});
|
|
1257
|
+
accepted = true;
|
|
1258
|
+
for await (const event of stream.events) {
|
|
1259
|
+
await accumulator.accept(event);
|
|
1260
|
+
}
|
|
1261
|
+
} catch (error) {
|
|
1262
|
+
const aborted = input.signal.aborted || isAbortError(error);
|
|
1263
|
+
if (accumulator.isFinished()) {
|
|
1264
|
+
if (!aborted)
|
|
1265
|
+
terminalStreamError = { error };
|
|
1266
|
+
} else if (!aborted) {
|
|
1267
|
+
throw error;
|
|
1268
|
+
} else {
|
|
1269
|
+
return {
|
|
1270
|
+
status: "aborted",
|
|
1271
|
+
steps,
|
|
1272
|
+
partialContent: accumulator.partialContent()
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
} finally {
|
|
1276
|
+
if (accepted) {
|
|
1277
|
+
const facts = accumulator.accounting();
|
|
1278
|
+
const estimate = accumulator.isFinished() ? estimateModelCall(input.model, facts) : cost;
|
|
1279
|
+
cost = facts.reportedCost ? rateModelCall2({ usage: facts.usage, reported: facts.reportedCost }) : estimate;
|
|
1280
|
+
await input.onModelCallEnd?.({
|
|
1281
|
+
callId,
|
|
1282
|
+
providerId: input.model.providerId,
|
|
1283
|
+
modelId: input.model.modelId,
|
|
1284
|
+
responseId: facts.responseId ?? `${callId}:response`,
|
|
1285
|
+
providerIds: facts.providerIds,
|
|
1286
|
+
responseModelId: facts.responseModelId,
|
|
1287
|
+
usage: facts.usage,
|
|
1288
|
+
cost,
|
|
1289
|
+
...facts.reportedCost === undefined ? {} : { estimate },
|
|
1290
|
+
...input.reasoning === undefined ? {} : { requestedReasoning: input.reasoning },
|
|
1291
|
+
...facts.route === undefined ? {} : { route: facts.route }
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
if (input.signal.aborted && !accumulator.isFinished()) {
|
|
1296
|
+
return { status: "aborted", steps, partialContent: accumulator.partialContent() };
|
|
1297
|
+
}
|
|
1298
|
+
const response = accumulator.complete();
|
|
1299
|
+
const responseId = response.responseId ?? `${callId}:response`;
|
|
1300
|
+
if (terminalStreamError)
|
|
1301
|
+
throw terminalStreamError.error;
|
|
1302
|
+
if (response.projectionError)
|
|
1303
|
+
throw response.projectionError;
|
|
1304
|
+
if (input.signal.aborted) {
|
|
1305
|
+
return { status: "aborted", steps, partialContent: response.content };
|
|
1306
|
+
}
|
|
1307
|
+
const localCalls = response.toolCalls.filter((call) => call.part.providerExecuted !== true);
|
|
1308
|
+
if (input.rejectLocalToolCalls && (localCalls.length > 0 || response.finishReason === "tool-calls")) {
|
|
1309
|
+
throw new ModelStreamError2("[SixbModels] Direct generation cannot continue local tool calls.");
|
|
1310
|
+
}
|
|
1311
|
+
if (response.finishReason === "pause" && localCalls.length === 0) {
|
|
1312
|
+
const step = modelStep(response, responseId, response.content, cost);
|
|
1313
|
+
steps.push(step);
|
|
1314
|
+
await input.onStepEnd?.(step);
|
|
1315
|
+
messages = [...requestMessages, { role: "assistant", content: response.content }];
|
|
1316
|
+
if (stepIndex + 1 === input.maxSteps) {
|
|
1317
|
+
throw new ModelStreamError2("[SixbModels] Model reached the step limit while a provider continuation was pending.");
|
|
1318
|
+
}
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
if (localCalls.length === 0) {
|
|
1322
|
+
const step = modelStep(response, responseId, response.content, cost);
|
|
1323
|
+
steps.push(step);
|
|
1324
|
+
await input.onStepEnd?.(step);
|
|
1325
|
+
if (input.output) {
|
|
1326
|
+
const text = responseText(response);
|
|
1327
|
+
if (response.finishReason !== "stop") {
|
|
1328
|
+
throw new StructuredOutputError2(`[SixbModels] Structured output did not complete successfully (${response.finishReason}).`, structuredOutputErrorContext(input, response, responseId, cost, text));
|
|
1329
|
+
}
|
|
1330
|
+
let raw;
|
|
1331
|
+
try {
|
|
1332
|
+
raw = JSON.parse(text);
|
|
1333
|
+
} catch (error) {
|
|
1334
|
+
throw new StructuredOutputError2("[SixbModels] Model did not produce valid JSON output.", {
|
|
1335
|
+
cause: error,
|
|
1336
|
+
...structuredOutputErrorContext(input, response, responseId, cost, text)
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
try {
|
|
1340
|
+
return {
|
|
1341
|
+
status: "completed",
|
|
1342
|
+
output: input.output.validate(raw),
|
|
1343
|
+
steps,
|
|
1344
|
+
finishReason: response.finishReason
|
|
1345
|
+
};
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
throw new StructuredOutputError2("[SixbModels] Structured output validation failed.", {
|
|
1348
|
+
cause: error,
|
|
1349
|
+
...structuredOutputErrorContext(input, response, responseId, cost, text)
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
const output = responseText(response);
|
|
1354
|
+
return { status: "completed", output, steps, finishReason: response.finishReason };
|
|
1355
|
+
}
|
|
1356
|
+
const toolResults = await Promise.all(localCalls.map((call) => executeToolCall(call, tools, callId, input.signal, input.onEvent)));
|
|
1357
|
+
const step = modelStep(response, responseId, [...response.content, ...toolResults], cost);
|
|
1358
|
+
steps.push(step);
|
|
1359
|
+
await input.onStepEnd?.(step);
|
|
1360
|
+
if (input.signal.aborted) {
|
|
1361
|
+
return {
|
|
1362
|
+
status: "aborted",
|
|
1363
|
+
steps,
|
|
1364
|
+
partialContent: []
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
const assistantContent = response.content.filter((part) => part.type !== "tool-result" || part.providerExecuted === true);
|
|
1368
|
+
messages = [
|
|
1369
|
+
...requestMessages,
|
|
1370
|
+
{ role: "assistant", content: assistantContent },
|
|
1371
|
+
{ role: "tool", content: toolResults }
|
|
1372
|
+
];
|
|
1373
|
+
if (stepIndex + 1 === input.maxSteps) {
|
|
1374
|
+
if (input.output) {
|
|
1375
|
+
throw new StructuredOutputError2("[SixbModels] Model reached the step limit without structured output.", structuredOutputErrorContext(input, response, responseId, cost, responseText(response)));
|
|
1376
|
+
}
|
|
1377
|
+
const output = responseText(response);
|
|
1378
|
+
return { status: "completed", output, steps, finishReason: response.finishReason };
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
throw new ModelStreamError2("[SixbModels] Model loop exited without a terminal result.");
|
|
1382
|
+
}
|
|
1383
|
+
function assertLoopInput(input) {
|
|
1384
|
+
if (input.maxOutputTokens !== undefined && (!Number.isSafeInteger(input.maxOutputTokens) || input.maxOutputTokens <= 0)) {
|
|
1385
|
+
throw new TypeError("[SixbModels] maxOutputTokens must be a positive safe integer.");
|
|
1386
|
+
}
|
|
1387
|
+
if (!Number.isInteger(input.maxSteps) || input.maxSteps <= 0) {
|
|
1388
|
+
throw new TypeError("[SixbModels] maxSteps must be a positive integer.");
|
|
1389
|
+
}
|
|
1390
|
+
if (!input.model.providerId.trim() || !input.model.modelId.trim()) {
|
|
1391
|
+
throw new TypeError("[SixbModels] Model providerId and modelId must not be empty.");
|
|
1392
|
+
}
|
|
1393
|
+
if (input.model.definition.providerId !== input.model.providerId || input.model.definition.modelId !== input.model.modelId) {
|
|
1394
|
+
throw new TypeError(`[SixbModels] Model definition for '${input.model.providerId}/${input.model.modelId}' has a different identity.`);
|
|
1395
|
+
}
|
|
1396
|
+
if (input.output) {
|
|
1397
|
+
if (!input.output.name.trim()) {
|
|
1398
|
+
throw new TypeError("[SixbModels] Structured output names must not be empty.");
|
|
1399
|
+
}
|
|
1400
|
+
assertJsonObject2(input.output.schema, "structured output schema");
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
function indexTools(tools) {
|
|
1404
|
+
const result = new Map;
|
|
1405
|
+
for (const tool of tools) {
|
|
1406
|
+
if (!tool.name.trim())
|
|
1407
|
+
throw new TypeError("[SixbModels] Tool names must not be empty.");
|
|
1408
|
+
if (result.has(tool.name)) {
|
|
1409
|
+
throw new TypeError(`[SixbModels] Duplicate tool name '${tool.name}'.`);
|
|
1410
|
+
}
|
|
1411
|
+
assertJsonObject2(tool.inputSchema, `tool '${tool.name}' input schema`);
|
|
1412
|
+
result.set(tool.name, tool);
|
|
1413
|
+
}
|
|
1414
|
+
return result;
|
|
1415
|
+
}
|
|
1416
|
+
function responseText(response) {
|
|
1417
|
+
return response.content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
1418
|
+
}
|
|
1419
|
+
function structuredOutputErrorContext(input, response, responseId, cost, text) {
|
|
1420
|
+
return {
|
|
1421
|
+
text,
|
|
1422
|
+
providerId: input.model.providerId,
|
|
1423
|
+
modelId: input.model.modelId,
|
|
1424
|
+
responseId,
|
|
1425
|
+
...response.responseModelId === undefined ? {} : { responseModelId: response.responseModelId },
|
|
1426
|
+
finishReason: response.finishReason,
|
|
1427
|
+
usage: response.usage,
|
|
1428
|
+
cost
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
function modelStep(response, responseId, content, cost) {
|
|
1432
|
+
return {
|
|
1433
|
+
content,
|
|
1434
|
+
finishReason: response.finishReason,
|
|
1435
|
+
...response.rawFinishReason === undefined ? {} : { rawFinishReason: response.rawFinishReason },
|
|
1436
|
+
usage: response.usage,
|
|
1437
|
+
responseId,
|
|
1438
|
+
...response.responseModelId === undefined ? {} : { responseModelId: response.responseModelId },
|
|
1439
|
+
cost,
|
|
1440
|
+
...response.route === undefined ? {} : { route: response.route }
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
async function executeToolCall(call, tools, callId, signal, onEvent) {
|
|
1444
|
+
const { part } = call;
|
|
1445
|
+
if (call.inputError) {
|
|
1446
|
+
const errorText = `Tool input is not valid JSON: ${call.inputError.message}`;
|
|
1447
|
+
await onEvent?.({
|
|
1448
|
+
type: "tool-input-error",
|
|
1449
|
+
toolCallId: part.toolCallId,
|
|
1450
|
+
toolName: part.toolName,
|
|
1451
|
+
input: part.input,
|
|
1452
|
+
errorText
|
|
1453
|
+
});
|
|
1454
|
+
return toolErrorResult(part, errorText);
|
|
1455
|
+
}
|
|
1456
|
+
const tool = tools.get(part.toolName);
|
|
1457
|
+
if (!tool) {
|
|
1458
|
+
const errorText = `Tool '${part.toolName}' is not available.`;
|
|
1459
|
+
await onEvent?.({
|
|
1460
|
+
type: "tool-output-error",
|
|
1461
|
+
toolCallId: part.toolCallId,
|
|
1462
|
+
toolName: part.toolName,
|
|
1463
|
+
errorText
|
|
1464
|
+
});
|
|
1465
|
+
return toolErrorResult(part, errorText);
|
|
1466
|
+
}
|
|
1467
|
+
let parsed;
|
|
1468
|
+
try {
|
|
1469
|
+
parsed = tool.parseInput(part.input);
|
|
1470
|
+
} catch (error) {
|
|
1471
|
+
const errorText = error instanceof Error ? error.message : "Tool input validation failed.";
|
|
1472
|
+
await onEvent?.({
|
|
1473
|
+
type: "tool-input-error",
|
|
1474
|
+
toolCallId: part.toolCallId,
|
|
1475
|
+
toolName: part.toolName,
|
|
1476
|
+
input: part.input,
|
|
1477
|
+
errorText
|
|
1478
|
+
});
|
|
1479
|
+
return toolErrorResult(part, errorText);
|
|
1480
|
+
}
|
|
1481
|
+
await onEvent?.({
|
|
1482
|
+
type: "tool-input-available",
|
|
1483
|
+
toolCallId: part.toolCallId,
|
|
1484
|
+
toolName: part.toolName,
|
|
1485
|
+
input: part.input
|
|
1486
|
+
});
|
|
1487
|
+
let output;
|
|
1488
|
+
let modelOutput;
|
|
1489
|
+
try {
|
|
1490
|
+
const context = { signal, callId, toolCallId: part.toolCallId };
|
|
1491
|
+
output = await tool.execute(parsed, context);
|
|
1492
|
+
assertJsonValue2(output, `tool '${part.toolName}' output`);
|
|
1493
|
+
modelOutput = tool.toModelOutput ? await tool.toModelOutput(output, context) : modelToolOutput(output);
|
|
1494
|
+
validateModelToolOutput(modelOutput, part.toolName);
|
|
1495
|
+
} catch (error) {
|
|
1496
|
+
const errorText = tool.errorText(error);
|
|
1497
|
+
await onEvent?.({
|
|
1498
|
+
type: "tool-output-error",
|
|
1499
|
+
toolCallId: part.toolCallId,
|
|
1500
|
+
toolName: part.toolName,
|
|
1501
|
+
errorText
|
|
1502
|
+
});
|
|
1503
|
+
return toolErrorResult(part, errorText);
|
|
1504
|
+
}
|
|
1505
|
+
await onEvent?.({
|
|
1506
|
+
type: "tool-output-available",
|
|
1507
|
+
toolCallId: part.toolCallId,
|
|
1508
|
+
toolName: part.toolName,
|
|
1509
|
+
output
|
|
1510
|
+
});
|
|
1511
|
+
return {
|
|
1512
|
+
type: "tool-result",
|
|
1513
|
+
toolCallId: part.toolCallId,
|
|
1514
|
+
toolName: part.toolName,
|
|
1515
|
+
output: modelOutput,
|
|
1516
|
+
...modelOutputMatchesOriginal(modelOutput, output) ? {} : { originalOutput: output }
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
function validateModelToolOutput(output, toolName) {
|
|
1520
|
+
if (output.type === "text" || output.type === "error-text") {
|
|
1521
|
+
if (typeof output.value !== "string") {
|
|
1522
|
+
throw new TypeError(`[SixbModels] Tool '${toolName}' model output must contain text.`);
|
|
1523
|
+
}
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
if (output.type !== "json" && output.type !== "error-json") {
|
|
1527
|
+
throw new TypeError(`[SixbModels] Tool '${toolName}' returned an unsupported model output type.`);
|
|
1528
|
+
}
|
|
1529
|
+
assertJsonValue2(output.value, `tool '${toolName}' model output`);
|
|
1530
|
+
}
|
|
1531
|
+
function modelOutputMatchesOriginal(output, original) {
|
|
1532
|
+
if (output.type === "text")
|
|
1533
|
+
return typeof original === "string" && output.value === original;
|
|
1534
|
+
if (output.type === "json")
|
|
1535
|
+
return output.value === original;
|
|
1536
|
+
return false;
|
|
1537
|
+
}
|
|
1538
|
+
function modelToolOutput(value) {
|
|
1539
|
+
return typeof value === "string" ? { type: "text", value } : { type: "json", value };
|
|
1540
|
+
}
|
|
1541
|
+
function toolErrorResult(part, errorText) {
|
|
1542
|
+
if (typeof errorText !== "string") {
|
|
1543
|
+
throw new TypeError(`[SixbModels] Tool '${part.toolName}' error text must be a string.`);
|
|
1544
|
+
}
|
|
1545
|
+
return {
|
|
1546
|
+
type: "tool-result",
|
|
1547
|
+
toolCallId: part.toolCallId,
|
|
1548
|
+
toolName: part.toolName,
|
|
1549
|
+
output: { type: "error-text", value: errorText }
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
class StreamAccumulator {
|
|
1554
|
+
onEvent;
|
|
1555
|
+
parts = [];
|
|
1556
|
+
spans = new Map;
|
|
1557
|
+
toolCalls = new Map;
|
|
1558
|
+
started = false;
|
|
1559
|
+
finished = false;
|
|
1560
|
+
finishReason;
|
|
1561
|
+
rawFinishReason;
|
|
1562
|
+
usage = {};
|
|
1563
|
+
responseId;
|
|
1564
|
+
providerIds;
|
|
1565
|
+
responseModelId;
|
|
1566
|
+
projectionError;
|
|
1567
|
+
reportedCost;
|
|
1568
|
+
route;
|
|
1569
|
+
constructor(onEvent) {
|
|
1570
|
+
this.onEvent = onEvent;
|
|
1571
|
+
}
|
|
1572
|
+
isFinished() {
|
|
1573
|
+
return this.finished;
|
|
1574
|
+
}
|
|
1575
|
+
async accept(event) {
|
|
1576
|
+
if (this.finished) {
|
|
1577
|
+
throw new ModelStreamError2(`[SixbModels] Received '${event.type}' after stream finish.`);
|
|
1578
|
+
}
|
|
1579
|
+
switch (event.type) {
|
|
1580
|
+
case "stream-start":
|
|
1581
|
+
if (this.started)
|
|
1582
|
+
throw new ModelStreamError2("[SixbModels] Duplicate stream-start event.");
|
|
1583
|
+
this.started = true;
|
|
1584
|
+
return;
|
|
1585
|
+
case "response-metadata":
|
|
1586
|
+
this.requireStarted(event.type);
|
|
1587
|
+
this.responseId = event.id ?? this.responseId;
|
|
1588
|
+
if (event.providerIds)
|
|
1589
|
+
this.providerIds = { ...this.providerIds, ...event.providerIds };
|
|
1590
|
+
this.responseModelId = event.modelId ?? this.responseModelId;
|
|
1591
|
+
return;
|
|
1592
|
+
case "text-start":
|
|
1593
|
+
await this.startText(event);
|
|
1594
|
+
return;
|
|
1595
|
+
case "text-delta":
|
|
1596
|
+
await this.appendText(event, "text");
|
|
1597
|
+
return;
|
|
1598
|
+
case "text-end":
|
|
1599
|
+
await this.endText(event, "text");
|
|
1600
|
+
return;
|
|
1601
|
+
case "reasoning-start":
|
|
1602
|
+
await this.startReasoning(event);
|
|
1603
|
+
return;
|
|
1604
|
+
case "reasoning-delta":
|
|
1605
|
+
await this.appendText(event, "reasoning");
|
|
1606
|
+
return;
|
|
1607
|
+
case "reasoning-end":
|
|
1608
|
+
await this.endText(event, "reasoning");
|
|
1609
|
+
return;
|
|
1610
|
+
case "tool-input-start":
|
|
1611
|
+
await this.startTool(event);
|
|
1612
|
+
return;
|
|
1613
|
+
case "tool-input-delta":
|
|
1614
|
+
await this.appendTool(event);
|
|
1615
|
+
return;
|
|
1616
|
+
case "tool-input-end":
|
|
1617
|
+
this.endTool(event);
|
|
1618
|
+
return;
|
|
1619
|
+
case "tool-call":
|
|
1620
|
+
await this.completeTool(event);
|
|
1621
|
+
return;
|
|
1622
|
+
case "tool-result":
|
|
1623
|
+
this.addProviderToolResult(event);
|
|
1624
|
+
return;
|
|
1625
|
+
case "provider-state":
|
|
1626
|
+
if (typeof event.providerId !== "string" || event.providerId.length === 0) {
|
|
1627
|
+
this.captureProjectionError(new ModelStreamError2("[SixbModels] Provider state requires a nonempty provider ID."));
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
if (this.captureProviderState(event.data)) {
|
|
1631
|
+
this.parts.push({
|
|
1632
|
+
type: "provider-state",
|
|
1633
|
+
providerId: event.providerId,
|
|
1634
|
+
data: event.data
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
return;
|
|
1638
|
+
case "finish":
|
|
1639
|
+
this.requireStarted(event.type);
|
|
1640
|
+
validateUsage(event.usage);
|
|
1641
|
+
this.captureProviderData(event.providerData);
|
|
1642
|
+
this.finished = true;
|
|
1643
|
+
this.finishReason = event.finishReason;
|
|
1644
|
+
this.rawFinishReason = event.rawFinishReason;
|
|
1645
|
+
this.usage = event.usage;
|
|
1646
|
+
this.reportedCost = event.reportedCost;
|
|
1647
|
+
this.route = event.route;
|
|
1648
|
+
return;
|
|
1649
|
+
case "error":
|
|
1650
|
+
throw event.error instanceof Error ? event.error : new ModelProviderError2("[SixbModels] Provider stream failed.", "unknown", "unknown", {
|
|
1651
|
+
cause: event.error
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
complete() {
|
|
1656
|
+
if (!this.started)
|
|
1657
|
+
throw new ModelStreamError2("[SixbModels] Stream did not start.");
|
|
1658
|
+
if (!this.finished || !this.finishReason) {
|
|
1659
|
+
throw new ModelStreamError2("[SixbModels] Stream ended without a finish event.");
|
|
1660
|
+
}
|
|
1661
|
+
for (const part of this.parts) {
|
|
1662
|
+
if ("complete" in part && !part.complete) {
|
|
1663
|
+
throw new ModelStreamError2(`[SixbModels] Stream finished with incomplete ${part.type} content.`);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
const parsed = this.parseParts(false);
|
|
1667
|
+
return {
|
|
1668
|
+
content: parsed.content,
|
|
1669
|
+
toolCalls: parsed.toolCalls,
|
|
1670
|
+
finishReason: this.finishReason,
|
|
1671
|
+
...this.rawFinishReason === undefined ? {} : { rawFinishReason: this.rawFinishReason },
|
|
1672
|
+
...this.accounting(),
|
|
1673
|
+
...this.projectionError === undefined ? {} : { projectionError: this.projectionError }
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
accounting() {
|
|
1677
|
+
return {
|
|
1678
|
+
usage: this.usage,
|
|
1679
|
+
...this.responseId === undefined ? {} : { responseId: this.responseId },
|
|
1680
|
+
...this.providerIds === undefined ? {} : { providerIds: this.providerIds },
|
|
1681
|
+
...this.responseModelId === undefined ? {} : { responseModelId: this.responseModelId },
|
|
1682
|
+
...this.reportedCost === undefined ? {} : { reportedCost: this.reportedCost },
|
|
1683
|
+
...this.route === undefined ? {} : { route: this.route }
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
partialContent() {
|
|
1687
|
+
return this.parseParts(true).content;
|
|
1688
|
+
}
|
|
1689
|
+
parseParts(partial) {
|
|
1690
|
+
const content = [];
|
|
1691
|
+
const toolCalls = [];
|
|
1692
|
+
for (const part of this.parts) {
|
|
1693
|
+
if (part.type === "text") {
|
|
1694
|
+
if ((!partial || part.text.length > 0) && (part.complete || partial)) {
|
|
1695
|
+
content.push({
|
|
1696
|
+
type: "text",
|
|
1697
|
+
text: part.text,
|
|
1698
|
+
...part.providerData === undefined ? {} : { providerData: part.providerData }
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
} else if (part.type === "reasoning") {
|
|
1702
|
+
if (part.complete) {
|
|
1703
|
+
content.push({
|
|
1704
|
+
type: "reasoning",
|
|
1705
|
+
text: part.text,
|
|
1706
|
+
...part.providerData === undefined ? {} : { providerData: part.providerData }
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
} else if (part.type === "tool-call") {
|
|
1710
|
+
if (!part.complete)
|
|
1711
|
+
continue;
|
|
1712
|
+
let value = null;
|
|
1713
|
+
let inputError;
|
|
1714
|
+
try {
|
|
1715
|
+
const parsed = JSON.parse(part.inputText);
|
|
1716
|
+
if (!isJsonValue2(parsed))
|
|
1717
|
+
throw new TypeError("input is not a JSON value");
|
|
1718
|
+
value = parsed;
|
|
1719
|
+
} catch (error) {
|
|
1720
|
+
inputError = error instanceof Error ? error : new Error(String(error));
|
|
1721
|
+
}
|
|
1722
|
+
const call = {
|
|
1723
|
+
type: "tool-call",
|
|
1724
|
+
toolCallId: part.toolCallId,
|
|
1725
|
+
toolName: part.toolName,
|
|
1726
|
+
input: value,
|
|
1727
|
+
...part.providerData === undefined ? {} : { providerData: part.providerData },
|
|
1728
|
+
...part.providerExecuted === undefined ? {} : { providerExecuted: part.providerExecuted },
|
|
1729
|
+
...part.dynamic === undefined ? {} : { dynamic: part.dynamic }
|
|
1730
|
+
};
|
|
1731
|
+
content.push(call);
|
|
1732
|
+
toolCalls.push({ part: call, ...inputError === undefined ? {} : { inputError } });
|
|
1733
|
+
} else {
|
|
1734
|
+
content.push(part);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return { content, toolCalls };
|
|
1738
|
+
}
|
|
1739
|
+
async startText(event) {
|
|
1740
|
+
this.requireStarted(event.type);
|
|
1741
|
+
this.assertNewSpan(event.id);
|
|
1742
|
+
const providerData = this.captureProviderData(event.providerData);
|
|
1743
|
+
const part = {
|
|
1744
|
+
type: "text",
|
|
1745
|
+
text: "",
|
|
1746
|
+
complete: false,
|
|
1747
|
+
...providerData === undefined ? {} : { providerData }
|
|
1748
|
+
};
|
|
1749
|
+
this.spans.set(event.id, part);
|
|
1750
|
+
this.parts.push(part);
|
|
1751
|
+
await this.onEvent?.({ type: "text-start", id: event.id });
|
|
1752
|
+
}
|
|
1753
|
+
async startReasoning(event) {
|
|
1754
|
+
this.requireStarted(event.type);
|
|
1755
|
+
this.assertNewSpan(event.id);
|
|
1756
|
+
const providerData = this.captureProviderData(event.providerData);
|
|
1757
|
+
const part = {
|
|
1758
|
+
type: "reasoning",
|
|
1759
|
+
text: "",
|
|
1760
|
+
complete: false,
|
|
1761
|
+
...providerData === undefined ? {} : { providerData }
|
|
1762
|
+
};
|
|
1763
|
+
this.spans.set(event.id, part);
|
|
1764
|
+
this.parts.push(part);
|
|
1765
|
+
await this.onEvent?.({ type: "reasoning-start", id: event.id });
|
|
1766
|
+
}
|
|
1767
|
+
async appendText(event, expected) {
|
|
1768
|
+
const part = this.spans.get(event.id);
|
|
1769
|
+
if (!part || part.type !== expected || part.complete) {
|
|
1770
|
+
throw new ModelStreamError2(`[SixbModels] ${event.type} references unopened ${expected} span '${event.id}'.`);
|
|
1771
|
+
}
|
|
1772
|
+
part.text += event.delta;
|
|
1773
|
+
await this.onEvent?.({ type: event.type, id: event.id, delta: event.delta });
|
|
1774
|
+
}
|
|
1775
|
+
async endText(event, expected) {
|
|
1776
|
+
const part = this.spans.get(event.id);
|
|
1777
|
+
if (!part || part.type !== expected || part.complete) {
|
|
1778
|
+
throw new ModelStreamError2(`[SixbModels] ${event.type} references unopened ${expected} span '${event.id}'.`);
|
|
1779
|
+
}
|
|
1780
|
+
part.providerData = mergeProviderData(part.providerData, this.captureProviderData(event.providerData));
|
|
1781
|
+
part.complete = true;
|
|
1782
|
+
this.spans.delete(event.id);
|
|
1783
|
+
await this.onEvent?.({ type: event.type, id: event.id });
|
|
1784
|
+
}
|
|
1785
|
+
async startTool(event) {
|
|
1786
|
+
this.requireStarted(event.type);
|
|
1787
|
+
if (typeof event.id !== "string" || !event.id || typeof event.toolName !== "string" || !event.toolName) {
|
|
1788
|
+
throw new ModelStreamError2("[SixbModels] Tool calls require nonempty IDs and names.");
|
|
1789
|
+
}
|
|
1790
|
+
if (this.toolCalls.has(event.id)) {
|
|
1791
|
+
throw new ModelStreamError2(`[SixbModels] Duplicate tool call ID '${event.id}'.`);
|
|
1792
|
+
}
|
|
1793
|
+
const providerData = this.captureProviderData(event.providerData);
|
|
1794
|
+
const part = {
|
|
1795
|
+
type: "tool-call",
|
|
1796
|
+
toolCallId: event.id,
|
|
1797
|
+
toolName: event.toolName,
|
|
1798
|
+
inputText: "",
|
|
1799
|
+
complete: false,
|
|
1800
|
+
...providerData === undefined ? {} : { providerData },
|
|
1801
|
+
...event.providerExecuted === undefined ? {} : { providerExecuted: event.providerExecuted },
|
|
1802
|
+
...event.dynamic === undefined ? {} : { dynamic: event.dynamic }
|
|
1803
|
+
};
|
|
1804
|
+
this.toolCalls.set(event.id, part);
|
|
1805
|
+
this.parts.push(part);
|
|
1806
|
+
await this.onEvent?.({
|
|
1807
|
+
type: "tool-input-start",
|
|
1808
|
+
toolCallId: event.id,
|
|
1809
|
+
toolName: event.toolName
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
async appendTool(event) {
|
|
1813
|
+
const part = this.toolCalls.get(event.id);
|
|
1814
|
+
if (!part || part.complete) {
|
|
1815
|
+
throw new ModelStreamError2(`[SixbModels] tool-input-delta references unopened tool call '${event.id}'.`);
|
|
1816
|
+
}
|
|
1817
|
+
part.inputText += event.delta;
|
|
1818
|
+
await this.onEvent?.({
|
|
1819
|
+
type: "tool-input-delta",
|
|
1820
|
+
toolCallId: event.id,
|
|
1821
|
+
toolName: part.toolName,
|
|
1822
|
+
inputTextDelta: event.delta
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
endTool(event) {
|
|
1826
|
+
const part = this.toolCalls.get(event.id);
|
|
1827
|
+
if (!part || part.complete) {
|
|
1828
|
+
throw new ModelStreamError2(`[SixbModels] tool-input-end references unopened tool call '${event.id}'.`);
|
|
1829
|
+
}
|
|
1830
|
+
part.providerData = mergeProviderData(part.providerData, this.captureProviderData(event.providerData));
|
|
1831
|
+
part.complete = true;
|
|
1832
|
+
}
|
|
1833
|
+
async completeTool(event) {
|
|
1834
|
+
await this.startTool({
|
|
1835
|
+
type: "tool-input-start",
|
|
1836
|
+
id: event.toolCallId,
|
|
1837
|
+
toolName: event.toolName,
|
|
1838
|
+
...event.providerData === undefined ? {} : { providerData: event.providerData },
|
|
1839
|
+
...event.providerExecuted === undefined ? {} : { providerExecuted: event.providerExecuted },
|
|
1840
|
+
...event.dynamic === undefined ? {} : { dynamic: event.dynamic }
|
|
1841
|
+
});
|
|
1842
|
+
const part = this.toolCalls.get(event.toolCallId);
|
|
1843
|
+
if (!part)
|
|
1844
|
+
throw new ModelStreamError2("[SixbModels] Failed to index completed tool call.");
|
|
1845
|
+
part.inputText = event.input;
|
|
1846
|
+
part.complete = true;
|
|
1847
|
+
}
|
|
1848
|
+
addProviderToolResult(event) {
|
|
1849
|
+
if (!this.captureJsonValue(event.output, "provider tool result"))
|
|
1850
|
+
return;
|
|
1851
|
+
const providerData = this.captureProviderData(event.providerData);
|
|
1852
|
+
this.parts.push({
|
|
1853
|
+
type: "tool-result",
|
|
1854
|
+
toolCallId: event.toolCallId,
|
|
1855
|
+
toolName: event.toolName,
|
|
1856
|
+
output: event.isError ? { type: "error-json", value: event.output } : modelToolOutput(event.output),
|
|
1857
|
+
providerExecuted: event.providerExecuted ?? true,
|
|
1858
|
+
...event.dynamic === undefined ? {} : { dynamic: event.dynamic },
|
|
1859
|
+
...providerData === undefined ? {} : { providerData }
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
captureProviderData(data) {
|
|
1863
|
+
if (data === undefined)
|
|
1864
|
+
return;
|
|
1865
|
+
try {
|
|
1866
|
+
return normalizeProviderData(data);
|
|
1867
|
+
} catch (error) {
|
|
1868
|
+
this.captureProjectionError(error);
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
captureProviderState(value) {
|
|
1873
|
+
if (!this.captureJsonValue(value, "provider state"))
|
|
1874
|
+
return false;
|
|
1875
|
+
if (JSON.stringify(value).length > MAX_PROVIDER_DATA_BYTES) {
|
|
1876
|
+
this.captureProjectionError(new ModelStreamError2(`[SixbModels] Provider state exceeds the ${MAX_PROVIDER_DATA_BYTES}-byte response limit.`));
|
|
1877
|
+
return false;
|
|
1878
|
+
}
|
|
1879
|
+
return true;
|
|
1880
|
+
}
|
|
1881
|
+
captureJsonValue(value, label) {
|
|
1882
|
+
try {
|
|
1883
|
+
assertJsonValue2(value, label);
|
|
1884
|
+
return true;
|
|
1885
|
+
} catch (error) {
|
|
1886
|
+
this.captureProjectionError(error);
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
captureProjectionError(error) {
|
|
1891
|
+
this.projectionError ??= error instanceof Error ? error : new Error(String(error));
|
|
1892
|
+
}
|
|
1893
|
+
requireStarted(type) {
|
|
1894
|
+
if (!this.started) {
|
|
1895
|
+
throw new ModelStreamError2(`[SixbModels] Received '${type}' before stream-start.`);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
assertNewSpan(id) {
|
|
1899
|
+
if (!id)
|
|
1900
|
+
throw new ModelStreamError2("[SixbModels] Content span IDs must not be empty.");
|
|
1901
|
+
if (this.spans.has(id)) {
|
|
1902
|
+
throw new ModelStreamError2(`[SixbModels] Duplicate open content span '${id}'.`);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
function validateUsage(usage) {
|
|
1907
|
+
for (const [key, value] of Object.entries(usage)) {
|
|
1908
|
+
if (key === "raw") {
|
|
1909
|
+
if (value !== undefined)
|
|
1910
|
+
assertJsonValue2(value, "raw model usage");
|
|
1911
|
+
continue;
|
|
1912
|
+
}
|
|
1913
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
|
|
1914
|
+
throw new ModelStreamError2(`[SixbModels] Usage field '${key}' must be a nonnegative integer.`);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
function normalizeProviderData(value) {
|
|
1919
|
+
const data = omitUndefinedObjectProperties(value);
|
|
1920
|
+
assertJsonValue2(data, "provider data");
|
|
1921
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
1922
|
+
throw new TypeError("[SixbModels] provider data must be a JSON object.");
|
|
1923
|
+
}
|
|
1924
|
+
if (JSON.stringify(data).length > MAX_PROVIDER_DATA_BYTES) {
|
|
1925
|
+
throw new ModelStreamError2(`[SixbModels] Provider data exceeds the ${MAX_PROVIDER_DATA_BYTES}-byte response limit.`);
|
|
1926
|
+
}
|
|
1927
|
+
return data;
|
|
1928
|
+
}
|
|
1929
|
+
function omitUndefinedObjectProperties(value, seen = new Set) {
|
|
1930
|
+
if (typeof value !== "object" || value === null || seen.has(value))
|
|
1931
|
+
return value;
|
|
1932
|
+
seen.add(value);
|
|
1933
|
+
try {
|
|
1934
|
+
if (Array.isArray(value)) {
|
|
1935
|
+
return value.map((entry) => omitUndefinedObjectProperties(entry, seen));
|
|
1936
|
+
}
|
|
1937
|
+
if (!isPlainRecord(value))
|
|
1938
|
+
return value;
|
|
1939
|
+
return Object.fromEntries(Reflect.ownKeys(value).filter((key) => Object.prototype.propertyIsEnumerable.call(value, key)).map((key) => [key, Reflect.get(value, key)]).filter(([, entry]) => entry !== undefined).map(([key, entry]) => [key, omitUndefinedObjectProperties(entry, seen)]));
|
|
1940
|
+
} finally {
|
|
1941
|
+
seen.delete(value);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
function mergeProviderData(first, second) {
|
|
1945
|
+
if (first === undefined)
|
|
1946
|
+
return second;
|
|
1947
|
+
if (second === undefined)
|
|
1948
|
+
return first;
|
|
1949
|
+
return { ...first, ...second };
|
|
1950
|
+
}
|
|
1951
|
+
function isAbortError(error) {
|
|
1952
|
+
return error instanceof DOMException && error.name === "AbortError" || error instanceof Error && error.name === "AbortError";
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// src/models/execution/binding.ts
|
|
1956
|
+
var bindings = new WeakMap;
|
|
1957
|
+
function registerModelExecutionBinding(models, bind) {
|
|
1958
|
+
bindings.set(models, bind);
|
|
1959
|
+
}
|
|
1960
|
+
function bindModelExecutionAttempt(models, input) {
|
|
1961
|
+
const bind = bindings.get(models);
|
|
1962
|
+
if (!bind)
|
|
1963
|
+
throw new Error("[SixbModels] Model runtime has no execution binding.");
|
|
1964
|
+
if (!Number.isSafeInteger(input.attempt) || input.attempt < 1) {
|
|
1965
|
+
throw new TypeError("[SixbModels] Execution attempt must be a positive safe integer.");
|
|
1966
|
+
}
|
|
1967
|
+
bind(input);
|
|
1968
|
+
bindings.delete(models);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// src/models/output.ts
|
|
1972
|
+
function languageModelOutput(shape, valueTypesById) {
|
|
1973
|
+
if (!isRecord2(shape))
|
|
1974
|
+
throw new TypeError("[SixbModels] output must be a Sixb schema record.");
|
|
1975
|
+
const schema = schemaRecordToJsonSchema2({ shape, valueTypesById });
|
|
1976
|
+
assertJsonObject2(schema, "model output schema");
|
|
1977
|
+
return {
|
|
1978
|
+
name: "sixb_output",
|
|
1979
|
+
schema,
|
|
1980
|
+
validate(value) {
|
|
1981
|
+
if (!isRecord2(value))
|
|
1982
|
+
throw new TypeError("[SixbModels] Output must be an object.");
|
|
1983
|
+
for (const key of Object.keys(value)) {
|
|
1984
|
+
if (!Object.hasOwn(shape, key)) {
|
|
1985
|
+
throw new TypeError(`[SixbModels] Unknown output field '${key}'.`);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
return Object.fromEntries(Object.entries(shape).map(([key, field]) => {
|
|
1989
|
+
if (!Object.hasOwn(value, key)) {
|
|
1990
|
+
throw new TypeError(`[SixbModels] Missing output field '${key}'.`);
|
|
1991
|
+
}
|
|
1992
|
+
validateSchemaOrRefValue2(field, value[key], `output.${key}`, valueTypesById);
|
|
1993
|
+
const output = isObjectRefSchema2(field) ? value[key] : coerceSchemaValueToTyped2(field, normalizeSchemaValue2(field, value[key], `output.${key}`, valueTypesById), valueTypesById);
|
|
1994
|
+
return [key, output];
|
|
1995
|
+
}));
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
// src/models/execution.ts
|
|
2001
|
+
function createModelsRuntime(runtime, execution, catalog) {
|
|
2002
|
+
let binding;
|
|
2003
|
+
let recorder;
|
|
2004
|
+
async function createRecorder() {
|
|
2005
|
+
const storage = {
|
|
2006
|
+
...requireAccountingCapabilities(runtime.storage),
|
|
2007
|
+
transaction: runtime.storage.transaction.bind(runtime.storage)
|
|
2008
|
+
};
|
|
2009
|
+
if (!binding) {
|
|
2010
|
+
throw new Error("[SixbModels] Generation requires a bound request or worker execution attempt.");
|
|
2011
|
+
}
|
|
2012
|
+
const { requesterGroupIds } = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
2013
|
+
execution,
|
|
2014
|
+
runtimeAuthorization: runtime.runtimeAuthorization
|
|
2015
|
+
}));
|
|
2016
|
+
return new AiModelCallRecorder2({
|
|
2017
|
+
storage,
|
|
2018
|
+
projectId: runtime.projectId,
|
|
2019
|
+
executionId: execution.id,
|
|
2020
|
+
attempt: binding.attempt,
|
|
2021
|
+
requesterGroupIds,
|
|
2022
|
+
limits: createAiModelCallLimitController2({
|
|
2023
|
+
storage,
|
|
2024
|
+
projectId: runtime.projectId,
|
|
2025
|
+
requestedBy: execution.requestedBy,
|
|
2026
|
+
requesterGroupIds
|
|
2027
|
+
}),
|
|
2028
|
+
recoverAiModelCall: (input) => enqueueAiModelCallRecovery2(runtime.queues.agents, input)
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
async function generate(input) {
|
|
2032
|
+
assertProviderAccess2(runtime, execution, "models.language.generate");
|
|
2033
|
+
const messages = generationMessages(input);
|
|
2034
|
+
if (!binding) {
|
|
2035
|
+
throw new Error("[SixbModels] Generation requires a bound request or worker execution attempt.");
|
|
2036
|
+
}
|
|
2037
|
+
const signal = input.signal ? AbortSignal.any([binding.signal, input.signal]) : binding.signal;
|
|
2038
|
+
signal.throwIfAborted();
|
|
2039
|
+
const selected = input.model ? catalog ? catalog.language.getByRef({
|
|
2040
|
+
provider: input.model.providerId,
|
|
2041
|
+
modelId: input.model.modelId
|
|
2042
|
+
})?.model : input.model : catalog?.language.default.model;
|
|
2043
|
+
if (!selected) {
|
|
2044
|
+
throw new Error(input.model ? `[SixbModels] Model '${input.model.providerId}/${input.model.modelId}' is not configured in models.language.` : "[SixbModels] Configure models.language in createSixb() or supply a model to generate().");
|
|
2045
|
+
}
|
|
2046
|
+
const output = input.output === undefined ? undefined : languageModelOutput(input.output, runtime.ontology.getValueTypesById());
|
|
2047
|
+
const model = await resolveLanguageModel2(selected);
|
|
2048
|
+
const reasoningIssue = modelReasoningSupportIssue2(model.definition.capabilities.reasoning, input.reasoning);
|
|
2049
|
+
if (reasoningIssue)
|
|
2050
|
+
throw new UnsupportedModelFeatureError2(`[SixbModels] ${reasoningIssue}.`);
|
|
2051
|
+
if (output && model.definition.capabilities.nativeStructuredOutput === false) {
|
|
2052
|
+
throw new UnsupportedModelFeatureError2("[SixbModels] Model does not support native structured output.");
|
|
2053
|
+
}
|
|
2054
|
+
const maxOutputTokens = Math.min(aiModelCallOutputTokenAllowance(input.maxOutputTokens ?? model.definition.maxOutputTokens), model.definition.maxOutputTokens ?? Infinity);
|
|
2055
|
+
if (typeof input.reasoning === "object" && input.reasoning.budgetTokens >= maxOutputTokens) {
|
|
2056
|
+
throw new TypeError("[SixbModels] Output allowance must exceed the reasoning token budget.");
|
|
2057
|
+
}
|
|
2058
|
+
recorder ??= createRecorder();
|
|
2059
|
+
const accounting = await recorder;
|
|
2060
|
+
accounting.assertHealthy();
|
|
2061
|
+
signal.throwIfAborted();
|
|
2062
|
+
let event;
|
|
2063
|
+
const options = {
|
|
2064
|
+
model: accounting.wrapModel(model),
|
|
2065
|
+
messages,
|
|
2066
|
+
maxSteps: 1,
|
|
2067
|
+
rejectLocalToolCalls: true,
|
|
2068
|
+
maxOutputTokens,
|
|
2069
|
+
reasoning: input.reasoning,
|
|
2070
|
+
caching: input.caching,
|
|
2071
|
+
signal,
|
|
2072
|
+
onModelCallEnd: async (completed) => {
|
|
2073
|
+
await accounting.onModelCallEnd(completed);
|
|
2074
|
+
event = completed;
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
const result = output ? await runModelLoop2({ ...options, output }) : await runModelLoop2(options);
|
|
2078
|
+
if (result.status === "aborted") {
|
|
2079
|
+
signal.throwIfAborted();
|
|
2080
|
+
throw new DOMException("Model generation aborted", "AbortError");
|
|
2081
|
+
}
|
|
2082
|
+
if (result.finishReason === "error" || result.finishReason === "content-filter") {
|
|
2083
|
+
throw new ModelProviderError2(`[SixbModels] Generation ended with '${result.finishReason}'.`, model.providerId, model.modelId);
|
|
2084
|
+
}
|
|
2085
|
+
if (!event)
|
|
2086
|
+
throw new ModelStreamError2("[SixbModels] Generation completed without accounting metadata.");
|
|
2087
|
+
return {
|
|
2088
|
+
output: result.output,
|
|
2089
|
+
usage: event.usage,
|
|
2090
|
+
cost: event.cost,
|
|
2091
|
+
callId: event.callId,
|
|
2092
|
+
finishReason: result.finishReason
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
const models = {
|
|
2096
|
+
language: { generate }
|
|
2097
|
+
};
|
|
2098
|
+
registerModelExecutionBinding(models, (input) => {
|
|
2099
|
+
binding = { attempt: input.attempt, signal: input.signal };
|
|
2100
|
+
});
|
|
2101
|
+
return models;
|
|
2102
|
+
}
|
|
2103
|
+
function generationMessages(input) {
|
|
2104
|
+
if (input.prompt === undefined === (input.messages === undefined)) {
|
|
2105
|
+
throw new TypeError("[SixbModels] Supply exactly one of prompt or messages.");
|
|
2106
|
+
}
|
|
2107
|
+
if (input.prompt !== undefined && typeof input.prompt !== "string") {
|
|
2108
|
+
throw new TypeError("[SixbModels] prompt must be a string.");
|
|
2109
|
+
}
|
|
2110
|
+
if (input.messages !== undefined && !Array.isArray(input.messages)) {
|
|
2111
|
+
throw new TypeError("[SixbModels] messages must be an array.");
|
|
2112
|
+
}
|
|
2113
|
+
if (input.instructions !== undefined && typeof input.instructions !== "string") {
|
|
2114
|
+
throw new TypeError("[SixbModels] instructions must be a string.");
|
|
2115
|
+
}
|
|
2116
|
+
if (input.maxOutputTokens !== undefined && (!Number.isSafeInteger(input.maxOutputTokens) || input.maxOutputTokens <= 0)) {
|
|
2117
|
+
throw new TypeError("[SixbModels] maxOutputTokens must be a positive safe integer.");
|
|
2118
|
+
}
|
|
2119
|
+
if (input.caching !== undefined && input.caching !== "auto" && input.caching !== "off") {
|
|
2120
|
+
throw new TypeError("[SixbModels] caching must be 'auto' or 'off'.");
|
|
2121
|
+
}
|
|
2122
|
+
return [
|
|
2123
|
+
...input.instructions === undefined ? [] : [{ role: "system", content: input.instructions }],
|
|
2124
|
+
...input.prompt !== undefined ? [{ role: "user", content: [{ type: "text", text: input.prompt }] }] : input.messages ?? []
|
|
2125
|
+
];
|
|
2126
|
+
}
|
|
2127
|
+
|
|
1174
2128
|
// src/objects/execution.ts
|
|
1175
2129
|
function createObjectsRuntime(runtime, execution) {
|
|
1176
2130
|
const runtimeAuthorization = runtime.runtimeAuthorization;
|
|
@@ -1192,13 +2146,13 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
1192
2146
|
objectReader,
|
|
1193
2147
|
...authorization === undefined ? {} : { authorization }
|
|
1194
2148
|
};
|
|
1195
|
-
|
|
1196
|
-
|
|
2149
|
+
shareOntologyMutationRuntime2(runtime, capturedRuntime);
|
|
2150
|
+
shareSixbErrorReporter2(runtime, capturedRuntime);
|
|
1197
2151
|
Object.freeze(capturedRuntime);
|
|
1198
2152
|
const ontologyView = () => getAuthorizedOntologyView(objectReader);
|
|
1199
2153
|
const objects = Object.assign((objectType) => {
|
|
1200
|
-
|
|
1201
|
-
return
|
|
2154
|
+
assertObjectTypeRegistered2(capturedRuntime.ontology.getObjectTypesById(), objectType);
|
|
2155
|
+
return createObjectSet2({ ...capturedRuntime, execution, objectType });
|
|
1202
2156
|
}, {
|
|
1203
2157
|
listTypes: () => ontologyView().listObjectTypes(),
|
|
1204
2158
|
getTypeById: (objectTypeId) => ontologyView().getObjectTypeById(objectTypeId),
|
|
@@ -1216,7 +2170,7 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
1216
2170
|
},
|
|
1217
2171
|
getTelemetryHistoryBatch: (input) => {
|
|
1218
2172
|
const timeseries = capturedRuntime.storage.timeseries;
|
|
1219
|
-
return
|
|
2173
|
+
return getTelemetryHistoryBatch2(input, { storage: timeseries, objectReader });
|
|
1220
2174
|
},
|
|
1221
2175
|
getTelemetryHistory: async (input) => {
|
|
1222
2176
|
const timeseries = capturedRuntime.storage.timeseries;
|
|
@@ -1227,7 +2181,7 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
1227
2181
|
const to = input.to;
|
|
1228
2182
|
const limit = input.limit;
|
|
1229
2183
|
const order = input.order;
|
|
1230
|
-
const [result] = await
|
|
2184
|
+
const [result] = await getTelemetryHistoryBatch2({
|
|
1231
2185
|
series: [{ objectTypeId, objectId, propertyId }],
|
|
1232
2186
|
...from === undefined ? {} : { from },
|
|
1233
2187
|
...to === undefined ? {} : { to },
|
|
@@ -1248,11 +2202,11 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
1248
2202
|
getPrimaryPropertyId: (objectTypeId) => {
|
|
1249
2203
|
return ontologyView().getPrimaryPropertyId(objectTypeId);
|
|
1250
2204
|
},
|
|
1251
|
-
upsert: (objectTypeId, properties) =>
|
|
1252
|
-
upsertBatch: (objectTypeId, items) =>
|
|
1253
|
-
upsertLink: (objectTypeId, sourceId, linkId, target) =>
|
|
1254
|
-
upsertLinkBatch: (items) =>
|
|
1255
|
-
removeLink: (objectTypeId, sourceId, linkId, target) =>
|
|
2205
|
+
upsert: (objectTypeId, properties) => upsertObject3(capturedRuntime, objectTypeId, properties),
|
|
2206
|
+
upsertBatch: (objectTypeId, items) => upsertObjectBatch3(capturedRuntime, objectTypeId, items),
|
|
2207
|
+
upsertLink: (objectTypeId, sourceId, linkId, target) => upsertLink3(capturedRuntime, objectTypeId, sourceId, linkId, target),
|
|
2208
|
+
upsertLinkBatch: (items) => upsertLinkBatch3(capturedRuntime, items),
|
|
2209
|
+
removeLink: (objectTypeId, sourceId, linkId, target) => removeLink3(capturedRuntime, objectTypeId, sourceId, linkId, target),
|
|
1256
2210
|
appendTelemetry: (objectTypeId, items) => appendTelemetry(capturedRuntime, objectTypeId, items)
|
|
1257
2211
|
});
|
|
1258
2212
|
return objects;
|
|
@@ -1261,7 +2215,7 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
1261
2215
|
// src/pipelines/execution.ts
|
|
1262
2216
|
function createPipelinesRuntime(runtime, execution, source) {
|
|
1263
2217
|
const authority = resolveRuntimeAuthorizationForProject(runtime);
|
|
1264
|
-
const allowed = (pipelineId) =>
|
|
2218
|
+
const allowed = (pipelineId) => isRuntimeAllowed2(runtime, { kind: "pipeline.run", pipelineId });
|
|
1265
2219
|
const visibleIds = () => source.list().filter((pipeline) => allowed(pipeline.id)).map((pipeline) => pipeline.id);
|
|
1266
2220
|
const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
|
|
1267
2221
|
const getRun = async (runId) => {
|
|
@@ -1273,7 +2227,7 @@ function createPipelinesRuntime(runtime, execution, source) {
|
|
|
1273
2227
|
}) ?? null;
|
|
1274
2228
|
if (!run)
|
|
1275
2229
|
return null;
|
|
1276
|
-
return authority.type === "unrestricted" ||
|
|
2230
|
+
return authority.type === "unrestricted" || canViewPipelineRun2(authority.context, run) ? run : null;
|
|
1277
2231
|
};
|
|
1278
2232
|
return {
|
|
1279
2233
|
list: () => authority.type === "denied" || authority.type === "delegated" ? [] : source.list().filter((pipeline) => allowed(pipeline.id)),
|
|
@@ -1284,11 +2238,11 @@ function createPipelinesRuntime(runtime, execution, source) {
|
|
|
1284
2238
|
return pipeline && allowed(pipelineId) ? pipeline : null;
|
|
1285
2239
|
},
|
|
1286
2240
|
request: async (input) => {
|
|
1287
|
-
|
|
2241
|
+
assertAuthorized2(runtime, { kind: "pipeline.run", pipelineId: input.pipelineId });
|
|
1288
2242
|
const pipeline = source.getById(input.pipelineId);
|
|
1289
2243
|
if (!pipeline)
|
|
1290
|
-
throw new
|
|
1291
|
-
return
|
|
2244
|
+
throw new PipelineError2(`[Sixb] Unknown pipeline '${input.pipelineId}'`);
|
|
2245
|
+
return requestPipelineRun2(runtime, execution, pipeline, input);
|
|
1292
2246
|
},
|
|
1293
2247
|
runs: {
|
|
1294
2248
|
getById: getRun,
|
|
@@ -1341,7 +2295,7 @@ function createProjectionsRuntime(runtime, source) {
|
|
|
1341
2295
|
case "delegated":
|
|
1342
2296
|
return [];
|
|
1343
2297
|
case "principal":
|
|
1344
|
-
return list().filter((projection) =>
|
|
2298
|
+
return list().filter((projection) => canViewProjection2(authority.context, projection));
|
|
1345
2299
|
case "unrestricted":
|
|
1346
2300
|
return [...list()];
|
|
1347
2301
|
}
|
|
@@ -1352,7 +2306,7 @@ function createProjectionsRuntime(runtime, source) {
|
|
|
1352
2306
|
case "delegated":
|
|
1353
2307
|
return false;
|
|
1354
2308
|
case "principal":
|
|
1355
|
-
return
|
|
2309
|
+
return canViewProjection2(authority.context, projection);
|
|
1356
2310
|
case "unrestricted":
|
|
1357
2311
|
return true;
|
|
1358
2312
|
}
|
|
@@ -1394,7 +2348,7 @@ function createProjectionsRuntime(runtime, source) {
|
|
|
1394
2348
|
}) ?? null;
|
|
1395
2349
|
if (!run)
|
|
1396
2350
|
return null;
|
|
1397
|
-
return authority.type === "unrestricted" ||
|
|
2351
|
+
return authority.type === "unrestricted" || canViewProjectionRun2(authority.context, run.target) ? run : null;
|
|
1398
2352
|
},
|
|
1399
2353
|
list: (input = {}) => {
|
|
1400
2354
|
switch (authority.type) {
|
|
@@ -1439,7 +2393,7 @@ function createRulesRuntime(runtime, source) {
|
|
|
1439
2393
|
const visible = (rule) => {
|
|
1440
2394
|
if (authority.type === "denied" || authority.type === "delegated")
|
|
1441
2395
|
return false;
|
|
1442
|
-
return
|
|
2396
|
+
return isRuntimeAllowed2(runtime, {
|
|
1443
2397
|
kind: "object.view",
|
|
1444
2398
|
objectTypeId: rule.subject.objectTypeId
|
|
1445
2399
|
});
|
|
@@ -1498,10 +2452,10 @@ function createSchedulesRuntime(runtime, schedules) {
|
|
|
1498
2452
|
}
|
|
1499
2453
|
|
|
1500
2454
|
// src/shares/execution.ts
|
|
1501
|
-
import { createHash as createHash2, randomBytes, randomUUID as
|
|
2455
|
+
import { createHash as createHash2, randomBytes, randomUUID as randomUUID5 } from "crypto";
|
|
1502
2456
|
var MAX_CREATE_ATTEMPTS = 5;
|
|
1503
2457
|
|
|
1504
|
-
class
|
|
2458
|
+
class ShareError2 extends Error {
|
|
1505
2459
|
reason;
|
|
1506
2460
|
name = "ShareError";
|
|
1507
2461
|
constructor(reason, message, options) {
|
|
@@ -1516,7 +2470,7 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1516
2470
|
authorization: runtime.runtimeAuthorization
|
|
1517
2471
|
});
|
|
1518
2472
|
if (authority.type !== "principal" || authority.context.principal.type === "system") {
|
|
1519
|
-
throw new
|
|
2473
|
+
throw new ShareError2("unauthenticated", "[Sixb] Shared access grants require user or service-account authority.");
|
|
1520
2474
|
}
|
|
1521
2475
|
return {
|
|
1522
2476
|
type: authority.context.principal.type,
|
|
@@ -1526,7 +2480,7 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1526
2480
|
const canManage = (shareId) => {
|
|
1527
2481
|
try {
|
|
1528
2482
|
managementPrincipal();
|
|
1529
|
-
return
|
|
2483
|
+
return isRuntimeAllowed2(runtime, { kind: "share.manage", shareId });
|
|
1530
2484
|
} catch {
|
|
1531
2485
|
return false;
|
|
1532
2486
|
}
|
|
@@ -1550,7 +2504,7 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1550
2504
|
primaryId: target.primaryId
|
|
1551
2505
|
});
|
|
1552
2506
|
if (!object) {
|
|
1553
|
-
throw new
|
|
2507
|
+
throw new ObjectNotFoundError2(target.objectTypeId, target.primaryId, "Share target not found");
|
|
1554
2508
|
}
|
|
1555
2509
|
const authoritySnapshot = {
|
|
1556
2510
|
version: 1,
|
|
@@ -1565,7 +2519,7 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1565
2519
|
const secret = randomBytes(32).toString("base64url");
|
|
1566
2520
|
try {
|
|
1567
2521
|
const grant = await storage.create({
|
|
1568
|
-
id: `shr_${
|
|
2522
|
+
id: `shr_${randomUUID5()}`,
|
|
1569
2523
|
projectId: runtime.projectId,
|
|
1570
2524
|
definitionId: definition.id,
|
|
1571
2525
|
target,
|
|
@@ -1578,10 +2532,10 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1578
2532
|
});
|
|
1579
2533
|
return { grant: publicGrant(grant), secret };
|
|
1580
2534
|
} catch (error) {
|
|
1581
|
-
if (error instanceof
|
|
1582
|
-
throw new
|
|
2535
|
+
if (error instanceof ShareGrantStorageError2 && error.code === "invalid_input") {
|
|
2536
|
+
throw new ShareError2("invalid_input", error.message, { cause: error });
|
|
1583
2537
|
}
|
|
1584
|
-
if (!(error instanceof
|
|
2538
|
+
if (!(error instanceof ShareGrantStorageError2) || error.code !== "duplicate" || attempt === MAX_CREATE_ATTEMPTS - 1) {
|
|
1585
2539
|
throw storageFailure("issue", error);
|
|
1586
2540
|
}
|
|
1587
2541
|
}
|
|
@@ -1607,8 +2561,8 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1607
2561
|
});
|
|
1608
2562
|
return { ...result, grants: result.grants.map(publicGrant) };
|
|
1609
2563
|
} catch (error) {
|
|
1610
|
-
if (error instanceof
|
|
1611
|
-
throw new
|
|
2564
|
+
if (error instanceof ShareGrantStorageError2 && error.code === "invalid_input") {
|
|
2565
|
+
throw new ShareError2("invalid_input", error.message, { cause: error });
|
|
1612
2566
|
}
|
|
1613
2567
|
throw storageFailure("list", error);
|
|
1614
2568
|
}
|
|
@@ -1650,7 +2604,7 @@ function createSharesRuntime(runtime, execution, definitions) {
|
|
|
1650
2604
|
const actor = managementPrincipal();
|
|
1651
2605
|
const storage = requireShareStorage(runtime);
|
|
1652
2606
|
if (typeof grantId !== "string" || !grantId.trim()) {
|
|
1653
|
-
throw new
|
|
2607
|
+
throw new ShareError2("invalid_input", "[Sixb] Shared access grant id must not be empty.");
|
|
1654
2608
|
}
|
|
1655
2609
|
let current;
|
|
1656
2610
|
try {
|
|
@@ -1682,50 +2636,50 @@ function definitionIdFromReference(value) {
|
|
|
1682
2636
|
}
|
|
1683
2637
|
function assertInputObject(value, label) {
|
|
1684
2638
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1685
|
-
throw new
|
|
2639
|
+
throw new ShareError2("invalid_input", `[Sixb] ${label} must be an object.`);
|
|
1686
2640
|
}
|
|
1687
2641
|
}
|
|
1688
2642
|
function resolveDefinition(definitions, definitionId) {
|
|
1689
2643
|
const id = validDefinitionId(definitionId);
|
|
1690
2644
|
const definition = definitions.getById(id);
|
|
1691
2645
|
if (!definition) {
|
|
1692
|
-
throw new
|
|
2646
|
+
throw new ShareError2("not_found", `[Sixb] Unknown Share definition '${id}'.`);
|
|
1693
2647
|
}
|
|
1694
2648
|
return definition;
|
|
1695
2649
|
}
|
|
1696
2650
|
function validDefinitionId(value) {
|
|
1697
2651
|
if (typeof value !== "string" || !value.trim()) {
|
|
1698
|
-
throw new
|
|
2652
|
+
throw new ShareError2("invalid_input", "[Sixb] Share definition id must not be empty.");
|
|
1699
2653
|
}
|
|
1700
2654
|
return value;
|
|
1701
2655
|
}
|
|
1702
2656
|
function assertCanManage(runtime, shareId) {
|
|
1703
|
-
|
|
2657
|
+
assertAuthorized2(runtime, { kind: "share.manage", shareId });
|
|
1704
2658
|
}
|
|
1705
2659
|
function requireShareStorage(runtime) {
|
|
1706
2660
|
const storage = runtime.storage.shareGrants;
|
|
1707
2661
|
if (!storage) {
|
|
1708
|
-
throw new
|
|
2662
|
+
throw new ShareError2("storage_unavailable", "[Sixb] Share grant storage is not configured on this runtime.");
|
|
1709
2663
|
}
|
|
1710
2664
|
return storage;
|
|
1711
2665
|
}
|
|
1712
2666
|
function exactTarget(definition, value) {
|
|
1713
2667
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1714
|
-
throw new
|
|
2668
|
+
throw new ShareError2("invalid_input", "[Sixb] Share target must be an exact object reference.");
|
|
1715
2669
|
}
|
|
1716
2670
|
const objectTypeId = value.objectTypeId;
|
|
1717
2671
|
const primaryId = value.primaryId;
|
|
1718
2672
|
if (typeof objectTypeId !== "string" || typeof primaryId !== "string" || !primaryId.trim()) {
|
|
1719
|
-
throw new
|
|
2673
|
+
throw new ShareError2("invalid_input", "[Sixb] Share target must be an exact object reference.");
|
|
1720
2674
|
}
|
|
1721
2675
|
if (objectTypeId !== definition.target.objectTypeId) {
|
|
1722
|
-
throw new
|
|
2676
|
+
throw new ShareError2("invalid_input", `[Sixb] Share '${definition.id}' targets '${definition.target.objectTypeId}', not '${objectTypeId}'.`);
|
|
1723
2677
|
}
|
|
1724
2678
|
return Object.freeze({ objectTypeId, primaryId });
|
|
1725
2679
|
}
|
|
1726
2680
|
function validFutureDate(value, now) {
|
|
1727
2681
|
if (!(value instanceof Date) || !Number.isFinite(value.getTime()) || value <= now) {
|
|
1728
|
-
throw new
|
|
2682
|
+
throw new ShareError2("invalid_input", "[Sixb] Shared access expiry must be a valid future date.");
|
|
1729
2683
|
}
|
|
1730
2684
|
return new Date(value);
|
|
1731
2685
|
}
|
|
@@ -1743,7 +2697,7 @@ function publicGrant(record) {
|
|
|
1743
2697
|
return structuredClone(grant);
|
|
1744
2698
|
}
|
|
1745
2699
|
function storageFailure(operation, cause) {
|
|
1746
|
-
return new
|
|
2700
|
+
return new ShareError2("storage_failure", `[Sixb] Share grant storage failed to ${operation}.`, {
|
|
1747
2701
|
cause
|
|
1748
2702
|
});
|
|
1749
2703
|
}
|
|
@@ -1751,7 +2705,7 @@ function storageFailure(operation, cause) {
|
|
|
1751
2705
|
// src/syncs/execution.ts
|
|
1752
2706
|
function createSyncsRuntime(runtime, execution, source) {
|
|
1753
2707
|
const authority = resolveRuntimeAuthorizationForProject(runtime);
|
|
1754
|
-
const allowed = (syncId) =>
|
|
2708
|
+
const allowed = (syncId) => isRuntimeAllowed2(runtime, { kind: "sync.run", syncId });
|
|
1755
2709
|
const visibleIds = () => source.list().filter((sync) => allowed(sync.id)).map((sync) => sync.id);
|
|
1756
2710
|
const historyFilterIds = () => authority.type === "unrestricted" ? undefined : authority.type === "principal" ? visibleIds() : [];
|
|
1757
2711
|
return {
|
|
@@ -1763,11 +2717,11 @@ function createSyncsRuntime(runtime, execution, source) {
|
|
|
1763
2717
|
return sync && allowed(syncId) ? sync : null;
|
|
1764
2718
|
},
|
|
1765
2719
|
request: async (input) => {
|
|
1766
|
-
|
|
2720
|
+
assertAuthorized2(runtime, { kind: "sync.run", syncId: input.syncId });
|
|
1767
2721
|
const sync = source.getById(input.syncId);
|
|
1768
2722
|
if (!sync)
|
|
1769
|
-
throw new
|
|
1770
|
-
return
|
|
2723
|
+
throw new SyncValidationError2(`[Sixb] Unknown sync '${input.syncId}'`);
|
|
2724
|
+
return requestSyncRun2(runtime, execution, sync, input);
|
|
1771
2725
|
},
|
|
1772
2726
|
runs: {
|
|
1773
2727
|
getById: async (runId) => {
|
|
@@ -1807,11 +2761,11 @@ function createSyncsRuntime(runtime, execution, source) {
|
|
|
1807
2761
|
}
|
|
1808
2762
|
|
|
1809
2763
|
// src/workflows/errors.ts
|
|
1810
|
-
class
|
|
2764
|
+
class WorkflowDefinitionError2 extends Error {
|
|
1811
2765
|
name = "WorkflowDefinitionError";
|
|
1812
2766
|
}
|
|
1813
2767
|
|
|
1814
|
-
class
|
|
2768
|
+
class WorkflowValidationError2 extends Error {
|
|
1815
2769
|
name = "WorkflowValidationError";
|
|
1816
2770
|
cause;
|
|
1817
2771
|
constructor(message, options) {
|
|
@@ -1821,58 +2775,58 @@ class WorkflowValidationError extends Error {
|
|
|
1821
2775
|
}
|
|
1822
2776
|
|
|
1823
2777
|
// src/workflows/run-dispatch.ts
|
|
1824
|
-
import { randomUUID as
|
|
2778
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
1825
2779
|
import { isDeepStrictEqual } from "util";
|
|
1826
2780
|
|
|
1827
2781
|
// src/workflows/validation.ts
|
|
1828
2782
|
function assertNonEmpty(value, subject, field) {
|
|
1829
2783
|
if (!value.trim()) {
|
|
1830
|
-
throw new
|
|
2784
|
+
throw new WorkflowDefinitionError2(`${subject} ${field} must not be empty.`);
|
|
1831
2785
|
}
|
|
1832
2786
|
}
|
|
1833
|
-
function
|
|
2787
|
+
function isStepDefinition2(value) {
|
|
1834
2788
|
return isRecord(value) && value.kind === "step" && typeof value.id === "string" && isRecord(value.input) && isRecord(value.output) && typeof value.handler === "function";
|
|
1835
2789
|
}
|
|
1836
|
-
function
|
|
1837
|
-
return isRecord(value) && value.kind === "agentStep" && typeof value.id === "string" && (value.model === undefined || isLanguageModel(value.model)) && (value.reasoning === undefined ||
|
|
2790
|
+
function isAgentStepDefinition2(value) {
|
|
2791
|
+
return isRecord(value) && value.kind === "agentStep" && typeof value.id === "string" && (value.model === undefined || isLanguageModel(value.model)) && (value.reasoning === undefined || isModelReasoning2(value.reasoning)) && typeof value.instructions === "string" && isStringArray(value.groupIds) && isStringArray(value.toolNames) && isRecord(value.input) && isRecord(value.output) && typeof value.prompt === "function";
|
|
1838
2792
|
}
|
|
1839
|
-
function
|
|
2793
|
+
function isInterventionDefinition2(value) {
|
|
1840
2794
|
return isRecord(value) && value.kind === "intervention" && typeof value.id === "string" && isRecord(value.input) && isRecord(value.response) && (value.defaults === undefined || typeof value.defaults === "function");
|
|
1841
2795
|
}
|
|
1842
|
-
function
|
|
2796
|
+
function isWorkflowDefinition2(value) {
|
|
1843
2797
|
return isRecord(value) && value.kind === "workflow" && typeof value.id === "string" && isRecord(value.input) && Array.isArray(value.triggers) && Array.isArray(value.nodes);
|
|
1844
2798
|
}
|
|
1845
|
-
function
|
|
1846
|
-
if (!
|
|
1847
|
-
throw new
|
|
2799
|
+
function validateWorkflowDefinition2(value) {
|
|
2800
|
+
if (!isWorkflowDefinition2(value)) {
|
|
2801
|
+
throw new WorkflowDefinitionError2("Invalid workflow definition.");
|
|
1848
2802
|
}
|
|
1849
2803
|
assertNonEmpty(value.id, "Workflow", "id");
|
|
1850
2804
|
if (value.nodes.length === 0) {
|
|
1851
|
-
throw new
|
|
2805
|
+
throw new WorkflowDefinitionError2(`Workflow "${value.id}" must contain at least one node.`);
|
|
1852
2806
|
}
|
|
1853
2807
|
const nodeIds = new Set;
|
|
1854
2808
|
const nodeKeys = new Set;
|
|
1855
2809
|
for (const node of value.nodes) {
|
|
1856
2810
|
validateWorkflowNodeDefinition(value.id, node);
|
|
1857
2811
|
if (nodeIds.has(node.id)) {
|
|
1858
|
-
throw new
|
|
2812
|
+
throw new WorkflowDefinitionError2(`Duplicate workflow node id "${node.id}" in workflow "${value.id}".`);
|
|
1859
2813
|
}
|
|
1860
2814
|
nodeIds.add(node.id);
|
|
1861
2815
|
if (nodeKeys.has(node.key)) {
|
|
1862
|
-
throw new
|
|
2816
|
+
throw new WorkflowDefinitionError2(`Duplicate workflow node key "${node.key}" in workflow "${value.id}".`);
|
|
1863
2817
|
}
|
|
1864
2818
|
nodeKeys.add(node.key);
|
|
1865
2819
|
}
|
|
1866
2820
|
}
|
|
1867
|
-
function
|
|
2821
|
+
function validateWorkflowsAtStartup2(options) {
|
|
1868
2822
|
for (const workflow of options.workflows) {
|
|
1869
|
-
|
|
2823
|
+
validateWorkflowDefinition2(workflow);
|
|
1870
2824
|
for (const trigger of workflow.triggers) {
|
|
1871
2825
|
validateWorkflowTriggerAtStartup(workflow.id, trigger, options.registeredSchedules, Object.keys(workflow.input));
|
|
1872
2826
|
}
|
|
1873
2827
|
for (const node of workflow.nodes) {
|
|
1874
2828
|
if (node.type === "action" && !options.registeredActionIds.has(node.action.id)) {
|
|
1875
|
-
throw new
|
|
2829
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflow.id}" references unknown action "${node.action.id}". Add it to 'actions' in createSixb() or export it from 'actions/'.`);
|
|
1876
2830
|
}
|
|
1877
2831
|
if (node.type === "agent") {
|
|
1878
2832
|
validateWorkflowAgentStepRuntimeReferences(workflow.id, node.agentStep, options);
|
|
@@ -1881,14 +2835,14 @@ function validateWorkflowsAtStartup(options) {
|
|
|
1881
2835
|
}
|
|
1882
2836
|
return options.workflows;
|
|
1883
2837
|
}
|
|
1884
|
-
function
|
|
2838
|
+
function validateWorkflowAgentStepGroupReferences2(workflows, security) {
|
|
1885
2839
|
for (const workflow of workflows) {
|
|
1886
2840
|
for (const node of workflow.nodes) {
|
|
1887
2841
|
if (node.type !== "agent")
|
|
1888
2842
|
continue;
|
|
1889
2843
|
for (const groupId of node.agentStep.groupIds) {
|
|
1890
2844
|
if (!security.getGroupById(groupId)) {
|
|
1891
|
-
throw new
|
|
2845
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflow.id}" agent step "${node.id}" references unknown group "${groupId}". Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
1892
2846
|
}
|
|
1893
2847
|
}
|
|
1894
2848
|
}
|
|
@@ -1896,21 +2850,21 @@ function validateWorkflowAgentStepGroupReferences(workflows, security) {
|
|
|
1896
2850
|
}
|
|
1897
2851
|
function validateWorkflowAgentStepRuntimeReferences(workflowId, step, options) {
|
|
1898
2852
|
if (step.model === undefined && options.models === undefined) {
|
|
1899
|
-
throw new
|
|
2853
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${step.id}" needs a model. Configure 'models.language' or pass 'model' to defineAgentStep().`);
|
|
1900
2854
|
}
|
|
1901
2855
|
if (step.model !== undefined && options.models !== undefined) {
|
|
1902
2856
|
const ref = { provider: step.model.providerId, modelId: step.model.modelId };
|
|
1903
2857
|
if (options.models.language.getByRef(ref) === null) {
|
|
1904
|
-
throw new
|
|
2858
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${step.id}" uses unknown language model "${ref.provider}/${ref.modelId}". Add it to 'models.language' in createSixb().`);
|
|
1905
2859
|
}
|
|
1906
2860
|
}
|
|
1907
2861
|
for (const toolName of step.toolNames) {
|
|
1908
2862
|
if (options.tools.getByName(toolName) === null) {
|
|
1909
|
-
throw new
|
|
2863
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${step.id}" uses unknown project tool "${toolName}". Add it to 'tools' in createSixb().`);
|
|
1910
2864
|
}
|
|
1911
2865
|
}
|
|
1912
2866
|
}
|
|
1913
|
-
function
|
|
2867
|
+
function validateWorkflowInput2(params) {
|
|
1914
2868
|
return validateWorkflowContractRecord({
|
|
1915
2869
|
shape: params.workflow.input,
|
|
1916
2870
|
value: params.value,
|
|
@@ -1918,7 +2872,7 @@ function validateWorkflowInput(params) {
|
|
|
1918
2872
|
valueTypesById: params.valueTypesById
|
|
1919
2873
|
});
|
|
1920
2874
|
}
|
|
1921
|
-
function
|
|
2875
|
+
function validateWorkflowStepInput2(params) {
|
|
1922
2876
|
return validateWorkflowContractRecord({
|
|
1923
2877
|
shape: params.step.input,
|
|
1924
2878
|
value: params.value,
|
|
@@ -1926,7 +2880,7 @@ function validateWorkflowStepInput(params) {
|
|
|
1926
2880
|
valueTypesById: params.valueTypesById
|
|
1927
2881
|
});
|
|
1928
2882
|
}
|
|
1929
|
-
function
|
|
2883
|
+
function validateWorkflowStepOutput2(params) {
|
|
1930
2884
|
return validateWorkflowContractRecord({
|
|
1931
2885
|
shape: params.step.output,
|
|
1932
2886
|
value: params.value,
|
|
@@ -1934,7 +2888,7 @@ function validateWorkflowStepOutput(params) {
|
|
|
1934
2888
|
valueTypesById: params.valueTypesById
|
|
1935
2889
|
});
|
|
1936
2890
|
}
|
|
1937
|
-
function
|
|
2891
|
+
function validateWorkflowInterventionInput2(params) {
|
|
1938
2892
|
return validateWorkflowContractRecord({
|
|
1939
2893
|
shape: params.intervention.input,
|
|
1940
2894
|
value: params.value,
|
|
@@ -1942,7 +2896,7 @@ function validateWorkflowInterventionInput(params) {
|
|
|
1942
2896
|
valueTypesById: params.valueTypesById
|
|
1943
2897
|
});
|
|
1944
2898
|
}
|
|
1945
|
-
function
|
|
2899
|
+
function validateWorkflowInterventionResponse2(params) {
|
|
1946
2900
|
return validateWorkflowInterventionResponseRecord({
|
|
1947
2901
|
response: params.intervention.response,
|
|
1948
2902
|
value: params.value,
|
|
@@ -1951,7 +2905,7 @@ function validateWorkflowInterventionResponse(params) {
|
|
|
1951
2905
|
valueTypesById: params.valueTypesById
|
|
1952
2906
|
});
|
|
1953
2907
|
}
|
|
1954
|
-
function
|
|
2908
|
+
function validateWorkflowInterventionDefaultResponse2(params) {
|
|
1955
2909
|
return validateWorkflowInterventionResponseRecord({
|
|
1956
2910
|
response: params.intervention.response,
|
|
1957
2911
|
value: params.value,
|
|
@@ -1962,31 +2916,31 @@ function validateWorkflowInterventionDefaultResponse(params) {
|
|
|
1962
2916
|
}
|
|
1963
2917
|
function validateWorkflowTriggerAtStartup(workflowId, trigger, registeredSchedules, inputFields) {
|
|
1964
2918
|
if (!isRecord(trigger) || trigger.type !== "schedule") {
|
|
1965
|
-
throw new
|
|
2919
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an unsupported trigger.`);
|
|
1966
2920
|
}
|
|
1967
2921
|
validateScheduleWorkflowTrigger(workflowId, trigger, registeredSchedules, inputFields);
|
|
1968
2922
|
}
|
|
1969
2923
|
function validateScheduleWorkflowTrigger(workflowId, trigger, registeredSchedules, inputFields) {
|
|
1970
2924
|
if (typeof trigger.scheduleId !== "string" || !trigger.scheduleId.trim()) {
|
|
1971
|
-
throw new
|
|
2925
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains a schedule trigger with an empty schedule id.`);
|
|
1972
2926
|
}
|
|
1973
2927
|
const schedule = registeredSchedules.get(trigger.scheduleId);
|
|
1974
2928
|
if (!schedule) {
|
|
1975
|
-
throw new
|
|
2929
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" references unknown schedule "${trigger.scheduleId}". Add it to 'schedules' in createSixb() or export it from 'schedules/'.`);
|
|
1976
2930
|
}
|
|
1977
2931
|
if (trigger.mapper !== undefined && typeof trigger.mapper !== "function") {
|
|
1978
|
-
throw new
|
|
2932
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" schedule "${trigger.scheduleId}" mapper must be a function.`);
|
|
1979
2933
|
}
|
|
1980
2934
|
if (trigger.mapper !== undefined && schedule.trigger.type !== "event") {
|
|
1981
|
-
throw new
|
|
2935
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" cron schedule "${trigger.scheduleId}" does not accept a mapper.`);
|
|
1982
2936
|
}
|
|
1983
2937
|
if (trigger.mapper === undefined && inputFields.length > 0) {
|
|
1984
|
-
throw new
|
|
2938
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" schedule "${trigger.scheduleId}" requires a mapper because workflow input is not empty: ${inputFields.join(", ")}.`);
|
|
1985
2939
|
}
|
|
1986
2940
|
}
|
|
1987
2941
|
function validateWorkflowNodeDefinition(workflowId, node) {
|
|
1988
2942
|
if (!isRecord(node)) {
|
|
1989
|
-
throw new
|
|
2943
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an invalid node.`);
|
|
1990
2944
|
}
|
|
1991
2945
|
if (node.type === "step") {
|
|
1992
2946
|
validateStepNodeDefinition(workflowId, node);
|
|
@@ -2004,38 +2958,38 @@ function validateWorkflowNodeDefinition(workflowId, node) {
|
|
|
2004
2958
|
validateActionNodeDefinition(workflowId, node);
|
|
2005
2959
|
return;
|
|
2006
2960
|
}
|
|
2007
|
-
throw new
|
|
2961
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an unsupported node type.`);
|
|
2008
2962
|
}
|
|
2009
2963
|
function validateAgentNodeDefinition(workflowId, node) {
|
|
2010
2964
|
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
2011
|
-
throw new
|
|
2965
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an agent step with an empty id.`);
|
|
2012
2966
|
}
|
|
2013
2967
|
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
2014
|
-
throw new
|
|
2968
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains agent step "${node.id}" with an empty derived key.`);
|
|
2015
2969
|
}
|
|
2016
|
-
if (!
|
|
2017
|
-
throw new
|
|
2970
|
+
if (!isAgentStepDefinition2(node.agentStep)) {
|
|
2971
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an invalid agent node "${node.id}".`);
|
|
2018
2972
|
}
|
|
2019
2973
|
if (node.id !== node.agentStep.id) {
|
|
2020
|
-
throw new
|
|
2974
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent node id "${node.id}" does not match agent step definition id "${node.agentStep.id}".`);
|
|
2021
2975
|
}
|
|
2022
2976
|
if (!node.agentStep.instructions.trim()) {
|
|
2023
|
-
throw new
|
|
2977
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${node.id}" instructions must not be empty.`);
|
|
2024
2978
|
}
|
|
2025
2979
|
assertUniqueNonEmptyAgentStepValues(workflowId, node.id, "group", node.agentStep.groupIds);
|
|
2026
2980
|
assertUniqueNonEmptyAgentStepValues(workflowId, node.id, "tool", node.agentStep.toolNames);
|
|
2027
2981
|
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
2028
|
-
throw new
|
|
2982
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent node "${node.id}" mapper must be a function.`);
|
|
2029
2983
|
}
|
|
2030
2984
|
}
|
|
2031
2985
|
function assertUniqueNonEmptyAgentStepValues(workflowId, stepId, kind, values) {
|
|
2032
2986
|
const seen = new Set;
|
|
2033
2987
|
for (const value of values) {
|
|
2034
2988
|
if (!value.trim()) {
|
|
2035
|
-
throw new
|
|
2989
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${stepId}" has an empty ${kind} id.`);
|
|
2036
2990
|
}
|
|
2037
2991
|
if (seen.has(value)) {
|
|
2038
|
-
throw new
|
|
2992
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" agent step "${stepId}" has duplicate ${kind} '${value}'.`);
|
|
2039
2993
|
}
|
|
2040
2994
|
seen.add(value);
|
|
2041
2995
|
}
|
|
@@ -2052,7 +3006,7 @@ function isStringArray(value) {
|
|
|
2052
3006
|
}
|
|
2053
3007
|
return true;
|
|
2054
3008
|
}
|
|
2055
|
-
function
|
|
3009
|
+
function validateWorkflowAgentStepInput2(params) {
|
|
2056
3010
|
return validateWorkflowContractRecord({
|
|
2057
3011
|
shape: params.agentStep.input,
|
|
2058
3012
|
value: params.value,
|
|
@@ -2060,7 +3014,7 @@ function validateWorkflowAgentStepInput(params) {
|
|
|
2060
3014
|
valueTypesById: params.valueTypesById
|
|
2061
3015
|
});
|
|
2062
3016
|
}
|
|
2063
|
-
function
|
|
3017
|
+
function validateWorkflowAgentStepOutput2(params) {
|
|
2064
3018
|
return validateWorkflowContractRecord({
|
|
2065
3019
|
shape: params.agentStep.output,
|
|
2066
3020
|
value: params.value,
|
|
@@ -2070,72 +3024,72 @@ function validateWorkflowAgentStepOutput(params) {
|
|
|
2070
3024
|
}
|
|
2071
3025
|
function validateStepNodeDefinition(workflowId, node) {
|
|
2072
3026
|
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
2073
|
-
throw new
|
|
3027
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains a step with an empty id.`);
|
|
2074
3028
|
}
|
|
2075
3029
|
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
2076
|
-
throw new
|
|
3030
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains step "${node.id}" with an empty derived key.`);
|
|
2077
3031
|
}
|
|
2078
|
-
if (!
|
|
2079
|
-
throw new
|
|
3032
|
+
if (!isStepDefinition2(node.step)) {
|
|
3033
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an invalid step node "${node.id}".`);
|
|
2080
3034
|
}
|
|
2081
3035
|
if (node.id !== node.step.id) {
|
|
2082
|
-
throw new
|
|
3036
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" step node id "${node.id}" does not match step definition id "${node.step.id}".`);
|
|
2083
3037
|
}
|
|
2084
3038
|
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
2085
|
-
throw new
|
|
3039
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" step node "${node.id}" mapper must be a function.`);
|
|
2086
3040
|
}
|
|
2087
3041
|
}
|
|
2088
3042
|
function validateInterventionNodeDefinition(workflowId, node) {
|
|
2089
3043
|
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
2090
|
-
throw new
|
|
3044
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an intervention with an empty id.`);
|
|
2091
3045
|
}
|
|
2092
3046
|
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
2093
|
-
throw new
|
|
3047
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains intervention "${node.id}" with an empty derived key.`);
|
|
2094
3048
|
}
|
|
2095
|
-
if (!
|
|
2096
|
-
throw new
|
|
3049
|
+
if (!isInterventionDefinition2(node.intervention)) {
|
|
3050
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an invalid intervention node "${node.id}".`);
|
|
2097
3051
|
}
|
|
2098
3052
|
if (node.id !== node.intervention.id) {
|
|
2099
|
-
throw new
|
|
3053
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" intervention node id "${node.id}" does not match intervention definition id "${node.intervention.id}".`);
|
|
2100
3054
|
}
|
|
2101
3055
|
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
2102
|
-
throw new
|
|
3056
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" intervention node "${node.id}" mapper must be a function.`);
|
|
2103
3057
|
}
|
|
2104
3058
|
}
|
|
2105
3059
|
function validateActionNodeDefinition(workflowId, node) {
|
|
2106
3060
|
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
2107
|
-
throw new
|
|
3061
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an action with an empty id.`);
|
|
2108
3062
|
}
|
|
2109
3063
|
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
2110
|
-
throw new
|
|
3064
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains action "${node.id}" with an empty derived key.`);
|
|
2111
3065
|
}
|
|
2112
|
-
if (!
|
|
2113
|
-
throw new
|
|
3066
|
+
if (!isActionDefinition2(node.action)) {
|
|
3067
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" contains an invalid action node "${node.id}".`);
|
|
2114
3068
|
}
|
|
2115
3069
|
if (node.id !== node.action.id) {
|
|
2116
|
-
throw new
|
|
3070
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" action node id "${node.id}" does not match action definition id "${node.action.id}".`);
|
|
2117
3071
|
}
|
|
2118
3072
|
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
2119
|
-
throw new
|
|
3073
|
+
throw new WorkflowDefinitionError2(`Workflow "${workflowId}" action node "${node.id}" mapper must be a function.`);
|
|
2120
3074
|
}
|
|
2121
3075
|
}
|
|
2122
3076
|
function validateWorkflowContractRecord(params) {
|
|
2123
3077
|
if (!isRecord(params.value)) {
|
|
2124
|
-
throw new
|
|
3078
|
+
throw new WorkflowValidationError2(`[Sixb] ${params.path} must be an object`);
|
|
2125
3079
|
}
|
|
2126
3080
|
const fieldIds = new Set(Object.keys(params.shape));
|
|
2127
3081
|
for (const fieldId of Object.keys(params.value)) {
|
|
2128
3082
|
if (!fieldIds.has(fieldId)) {
|
|
2129
|
-
throw new
|
|
3083
|
+
throw new WorkflowValidationError2(`[Sixb] Unknown field '${params.path}.${fieldId}'`);
|
|
2130
3084
|
}
|
|
2131
3085
|
}
|
|
2132
3086
|
for (const [fieldId, schema] of Object.entries(params.shape)) {
|
|
2133
3087
|
const fieldValue = params.value[fieldId];
|
|
2134
3088
|
if (fieldValue === undefined) {
|
|
2135
|
-
throw new
|
|
3089
|
+
throw new WorkflowValidationError2(`[Sixb] Missing required field '${params.path}.${fieldId}'`);
|
|
2136
3090
|
}
|
|
2137
3091
|
try {
|
|
2138
|
-
|
|
3092
|
+
validateSchemaOrRefValue2(schema, fieldValue, `${params.path}.${fieldId}`, params.valueTypesById);
|
|
2139
3093
|
} catch (error) {
|
|
2140
3094
|
throw toWorkflowValidationError(error);
|
|
2141
3095
|
}
|
|
@@ -2144,24 +3098,24 @@ function validateWorkflowContractRecord(params) {
|
|
|
2144
3098
|
}
|
|
2145
3099
|
function validateWorkflowInterventionResponseRecord(params) {
|
|
2146
3100
|
if (!isRecord(params.value)) {
|
|
2147
|
-
throw new
|
|
3101
|
+
throw new WorkflowValidationError2(`[Sixb] ${params.path} must be an object`);
|
|
2148
3102
|
}
|
|
2149
3103
|
const fieldIds = new Set(Object.keys(params.response));
|
|
2150
3104
|
for (const fieldId of Object.keys(params.value)) {
|
|
2151
3105
|
if (!fieldIds.has(fieldId)) {
|
|
2152
|
-
throw new
|
|
3106
|
+
throw new WorkflowValidationError2(`[Sixb] Unknown field '${params.path}.${fieldId}'`);
|
|
2153
3107
|
}
|
|
2154
3108
|
}
|
|
2155
3109
|
for (const [fieldId, field] of Object.entries(params.response)) {
|
|
2156
3110
|
const fieldValue = params.value[fieldId];
|
|
2157
3111
|
if (fieldValue === undefined) {
|
|
2158
3112
|
if (!params.partial && isInterventionResponseFieldRequired(field)) {
|
|
2159
|
-
throw new
|
|
3113
|
+
throw new WorkflowValidationError2(`[Sixb] Missing required field '${params.path}.${fieldId}'`);
|
|
2160
3114
|
}
|
|
2161
3115
|
continue;
|
|
2162
3116
|
}
|
|
2163
3117
|
try {
|
|
2164
|
-
|
|
3118
|
+
validateSchemaOrRefValue2(interventionResponseFieldSchema(field), fieldValue, `${params.path}.${fieldId}`, params.valueTypesById);
|
|
2165
3119
|
} catch (error) {
|
|
2166
3120
|
throw toWorkflowValidationError(error);
|
|
2167
3121
|
}
|
|
@@ -2178,21 +3132,21 @@ function isInterventionResponseFieldRequired(field) {
|
|
|
2178
3132
|
return !isInterventionFieldConfig(field) || field.required !== false;
|
|
2179
3133
|
}
|
|
2180
3134
|
function toWorkflowValidationError(error) {
|
|
2181
|
-
if (error instanceof
|
|
3135
|
+
if (error instanceof WorkflowValidationError2) {
|
|
2182
3136
|
return error;
|
|
2183
3137
|
}
|
|
2184
3138
|
if (error instanceof Error) {
|
|
2185
|
-
return new
|
|
3139
|
+
return new WorkflowValidationError2(error.message, { cause: error });
|
|
2186
3140
|
}
|
|
2187
|
-
return new
|
|
3141
|
+
return new WorkflowValidationError2(String(error), { cause: error });
|
|
2188
3142
|
}
|
|
2189
3143
|
function isRecord(value) {
|
|
2190
3144
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2191
3145
|
}
|
|
2192
3146
|
|
|
2193
3147
|
// src/workflows/snapshot.ts
|
|
2194
|
-
function
|
|
2195
|
-
const value =
|
|
3148
|
+
function snapshotWorkflowAgentStepInput2(params) {
|
|
3149
|
+
const value = validateWorkflowAgentStepInput2(params);
|
|
2196
3150
|
return snapshotWorkflowContractRecord({
|
|
2197
3151
|
shape: params.agentStep.input,
|
|
2198
3152
|
value,
|
|
@@ -2200,8 +3154,8 @@ function snapshotWorkflowAgentStepInput(params) {
|
|
|
2200
3154
|
valueTypesById: params.valueTypesById
|
|
2201
3155
|
});
|
|
2202
3156
|
}
|
|
2203
|
-
function
|
|
2204
|
-
const value =
|
|
3157
|
+
function snapshotWorkflowAgentStepOutput2(params) {
|
|
3158
|
+
const value = validateWorkflowAgentStepOutput2(params);
|
|
2205
3159
|
return snapshotWorkflowContractRecord({
|
|
2206
3160
|
shape: params.agentStep.output,
|
|
2207
3161
|
value,
|
|
@@ -2209,8 +3163,8 @@ function snapshotWorkflowAgentStepOutput(params) {
|
|
|
2209
3163
|
valueTypesById: params.valueTypesById
|
|
2210
3164
|
});
|
|
2211
3165
|
}
|
|
2212
|
-
function
|
|
2213
|
-
const value =
|
|
3166
|
+
function snapshotWorkflowInput2(params) {
|
|
3167
|
+
const value = validateWorkflowInput2(params);
|
|
2214
3168
|
return snapshotWorkflowContractRecord({
|
|
2215
3169
|
shape: params.workflow.input,
|
|
2216
3170
|
value,
|
|
@@ -2218,8 +3172,8 @@ function snapshotWorkflowInput(params) {
|
|
|
2218
3172
|
valueTypesById: params.valueTypesById
|
|
2219
3173
|
});
|
|
2220
3174
|
}
|
|
2221
|
-
function
|
|
2222
|
-
const value =
|
|
3175
|
+
function snapshotWorkflowStepInput2(params) {
|
|
3176
|
+
const value = validateWorkflowStepInput2(params);
|
|
2223
3177
|
return snapshotWorkflowContractRecord({
|
|
2224
3178
|
shape: params.step.input,
|
|
2225
3179
|
value,
|
|
@@ -2227,8 +3181,8 @@ function snapshotWorkflowStepInput(params) {
|
|
|
2227
3181
|
valueTypesById: params.valueTypesById
|
|
2228
3182
|
});
|
|
2229
3183
|
}
|
|
2230
|
-
function
|
|
2231
|
-
const value =
|
|
3184
|
+
function snapshotWorkflowStepOutput2(params) {
|
|
3185
|
+
const value = validateWorkflowStepOutput2(params);
|
|
2232
3186
|
return snapshotWorkflowContractRecord({
|
|
2233
3187
|
shape: params.step.output,
|
|
2234
3188
|
value,
|
|
@@ -2236,8 +3190,8 @@ function snapshotWorkflowStepOutput(params) {
|
|
|
2236
3190
|
valueTypesById: params.valueTypesById
|
|
2237
3191
|
});
|
|
2238
3192
|
}
|
|
2239
|
-
function
|
|
2240
|
-
const value =
|
|
3193
|
+
function snapshotWorkflowInterventionInput2(params) {
|
|
3194
|
+
const value = validateWorkflowInterventionInput2(params);
|
|
2241
3195
|
return snapshotWorkflowContractRecord({
|
|
2242
3196
|
shape: params.intervention.input,
|
|
2243
3197
|
value,
|
|
@@ -2245,8 +3199,8 @@ function snapshotWorkflowInterventionInput(params) {
|
|
|
2245
3199
|
valueTypesById: params.valueTypesById
|
|
2246
3200
|
});
|
|
2247
3201
|
}
|
|
2248
|
-
function
|
|
2249
|
-
const value =
|
|
3202
|
+
function snapshotWorkflowInterventionResponse2(params) {
|
|
3203
|
+
const value = validateWorkflowInterventionResponse2(params);
|
|
2250
3204
|
return snapshotWorkflowInterventionResponseRecord({
|
|
2251
3205
|
response: params.intervention.response,
|
|
2252
3206
|
value,
|
|
@@ -2254,8 +3208,8 @@ function snapshotWorkflowInterventionResponse(params) {
|
|
|
2254
3208
|
valueTypesById: params.valueTypesById
|
|
2255
3209
|
});
|
|
2256
3210
|
}
|
|
2257
|
-
function
|
|
2258
|
-
const value =
|
|
3211
|
+
function snapshotWorkflowInterventionDefaultResponse2(params) {
|
|
3212
|
+
const value = validateWorkflowInterventionDefaultResponse2(params);
|
|
2259
3213
|
return snapshotWorkflowInterventionResponseRecord({
|
|
2260
3214
|
response: params.intervention.response,
|
|
2261
3215
|
value,
|
|
@@ -2263,7 +3217,7 @@ function snapshotWorkflowInterventionDefaultResponse(params) {
|
|
|
2263
3217
|
valueTypesById: params.valueTypesById
|
|
2264
3218
|
});
|
|
2265
3219
|
}
|
|
2266
|
-
function
|
|
3220
|
+
function snapshotWorkflowActionInput2(params) {
|
|
2267
3221
|
const snapshot = {
|
|
2268
3222
|
params: snapshotJsonValue(params.params, "Workflow action params")
|
|
2269
3223
|
};
|
|
@@ -2300,8 +3254,8 @@ function snapshotWorkflowInterventionResponseRecord(params) {
|
|
|
2300
3254
|
return snapshot;
|
|
2301
3255
|
}
|
|
2302
3256
|
function snapshotSchemaOrRefValue(params) {
|
|
2303
|
-
if (
|
|
2304
|
-
if (!
|
|
3257
|
+
if (isObjectRefSchema2(params.schema)) {
|
|
3258
|
+
if (!isRecord3(params.value)) {
|
|
2305
3259
|
throw cannotSerialize(params.path);
|
|
2306
3260
|
}
|
|
2307
3261
|
return {
|
|
@@ -2342,7 +3296,7 @@ function snapshotSchemaValue(params) {
|
|
|
2342
3296
|
}));
|
|
2343
3297
|
}
|
|
2344
3298
|
if (schema.type === "map") {
|
|
2345
|
-
if (!
|
|
3299
|
+
if (!isRecord3(value)) {
|
|
2346
3300
|
throw cannotSerialize(path);
|
|
2347
3301
|
}
|
|
2348
3302
|
const snapshot = {};
|
|
@@ -2357,7 +3311,7 @@ function snapshotSchemaValue(params) {
|
|
|
2357
3311
|
return snapshot;
|
|
2358
3312
|
}
|
|
2359
3313
|
if (schema.type === "object") {
|
|
2360
|
-
if (!
|
|
3314
|
+
if (!isRecord3(value)) {
|
|
2361
3315
|
throw cannotSerialize(path);
|
|
2362
3316
|
}
|
|
2363
3317
|
const snapshot = {};
|
|
@@ -2382,7 +3336,7 @@ function snapshotSchemaValue(params) {
|
|
|
2382
3336
|
if (schema.type === "valueTypeRef") {
|
|
2383
3337
|
const valueType = valueTypesById.get(schema.valueTypeId);
|
|
2384
3338
|
if (!valueType) {
|
|
2385
|
-
throw new
|
|
3339
|
+
throw new WorkflowValidationError2(`[Sixb] Unknown valueTypeRef '${schema.valueTypeId}' at ${path}`);
|
|
2386
3340
|
}
|
|
2387
3341
|
return snapshotSchemaValue({
|
|
2388
3342
|
schema: valueType.schema,
|
|
@@ -2425,14 +3379,14 @@ function snapshotDate(value, path) {
|
|
|
2425
3379
|
return value.toISOString();
|
|
2426
3380
|
}
|
|
2427
3381
|
function cannotSerialize(path) {
|
|
2428
|
-
return new
|
|
3382
|
+
return new WorkflowValidationError2(`[Sixb] ${path} cannot be serialized as workflow IO`);
|
|
2429
3383
|
}
|
|
2430
|
-
function
|
|
3384
|
+
function isRecord3(value) {
|
|
2431
3385
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2432
3386
|
}
|
|
2433
3387
|
|
|
2434
3388
|
// src/workflows/run-dispatch.ts
|
|
2435
|
-
class
|
|
3389
|
+
class WorkflowRunDispatcher2 {
|
|
2436
3390
|
dependencies;
|
|
2437
3391
|
constructor(dependencies) {
|
|
2438
3392
|
this.dependencies = dependencies;
|
|
@@ -2441,7 +3395,7 @@ class WorkflowRunDispatcher {
|
|
|
2441
3395
|
assertAutomaticDispatchInput(input);
|
|
2442
3396
|
const workflow = this.dependencies.definitions.workflows.getById(input.workflowId);
|
|
2443
3397
|
if (!workflow) {
|
|
2444
|
-
throw new
|
|
3398
|
+
throw new WorkflowValidationError2(`[Sixb] Unknown workflow '${input.workflowId}'`);
|
|
2445
3399
|
}
|
|
2446
3400
|
const result = await dispatchWorkflowRun({
|
|
2447
3401
|
errorReporterHost: this.dependencies,
|
|
@@ -2457,9 +3411,8 @@ class WorkflowRunDispatcher {
|
|
|
2457
3411
|
type: "schedule",
|
|
2458
3412
|
scheduleId: input.scheduleId,
|
|
2459
3413
|
eventId: input.source.eventId,
|
|
2460
|
-
principal:
|
|
3414
|
+
principal: SYSTEM_PRINCIPAL2
|
|
2461
3415
|
},
|
|
2462
|
-
requesterGroupIds: [],
|
|
2463
3416
|
metadata: input.metadata,
|
|
2464
3417
|
queueJobId: input.runId,
|
|
2465
3418
|
createExecution: async (executionId, runId) => createPrimitiveExecutionRecord({
|
|
@@ -2490,7 +3443,7 @@ function prepareWorkflowRun(input) {
|
|
|
2490
3443
|
const value = input.input ?? {};
|
|
2491
3444
|
return {
|
|
2492
3445
|
runId: resolveWorkflowRunId(input.runId),
|
|
2493
|
-
snapshot:
|
|
3446
|
+
snapshot: snapshotWorkflowInput2({
|
|
2494
3447
|
workflow: input.workflow,
|
|
2495
3448
|
value,
|
|
2496
3449
|
valueTypesById: input.valueTypesById
|
|
@@ -2500,7 +3453,7 @@ function prepareWorkflowRun(input) {
|
|
|
2500
3453
|
async function persistWorkflowRun(input, request) {
|
|
2501
3454
|
const workflowRuns = input.storage.workflowRuns;
|
|
2502
3455
|
if (!workflowRuns) {
|
|
2503
|
-
throw new
|
|
3456
|
+
throw new WorkflowValidationError2("[Sixb] Workflow run storage is not configured.");
|
|
2504
3457
|
}
|
|
2505
3458
|
const existing = await workflowRuns.getById({
|
|
2506
3459
|
projectId: input.projectId,
|
|
@@ -2510,7 +3463,7 @@ async function persistWorkflowRun(input, request) {
|
|
|
2510
3463
|
assertExistingWorkflowRun(existing, input.workflow.id, request.snapshot);
|
|
2511
3464
|
return { run: existing, created: false };
|
|
2512
3465
|
}
|
|
2513
|
-
const execution = await input.createExecution(`exec_${
|
|
3466
|
+
const execution = await input.createExecution(`exec_${randomUUID6()}`, request.runId);
|
|
2514
3467
|
const queuedAt = new Date;
|
|
2515
3468
|
try {
|
|
2516
3469
|
return await input.storage.transaction(async (tx) => {
|
|
@@ -2523,7 +3476,7 @@ async function persistWorkflowRun(input, request) {
|
|
|
2523
3476
|
return { run: raced, created: false };
|
|
2524
3477
|
}
|
|
2525
3478
|
if (!tx.workflowRuns) {
|
|
2526
|
-
throw new
|
|
3479
|
+
throw new WorkflowValidationError2("[Sixb] Workflow run storage is not configured.");
|
|
2527
3480
|
}
|
|
2528
3481
|
await tx.executions.create(execution);
|
|
2529
3482
|
const run = await tx.workflowRuns.queue({
|
|
@@ -2532,13 +3485,12 @@ async function persistWorkflowRun(input, request) {
|
|
|
2532
3485
|
executionId: execution.id,
|
|
2533
3486
|
workflowId: input.workflow.id,
|
|
2534
3487
|
input: request.snapshot,
|
|
2535
|
-
queuedAt
|
|
2536
|
-
requesterGroupIds: input.requesterGroupIds
|
|
3488
|
+
queuedAt
|
|
2537
3489
|
});
|
|
2538
3490
|
return { run, execution, queuedAt, created: true };
|
|
2539
3491
|
}, { isolation: "serializable" });
|
|
2540
3492
|
} catch (error) {
|
|
2541
|
-
if (!(error instanceof
|
|
3493
|
+
if (!(error instanceof WorkflowRunError2))
|
|
2542
3494
|
throw error;
|
|
2543
3495
|
const raced = await workflowRuns.getById({
|
|
2544
3496
|
projectId: input.projectId,
|
|
@@ -2595,10 +3547,10 @@ async function publishWorkflowRun(input, persisted) {
|
|
|
2595
3547
|
async function failWorkflowRunPublication(input, run, error) {
|
|
2596
3548
|
const workflowRuns = input.storage.workflowRuns;
|
|
2597
3549
|
if (!workflowRuns) {
|
|
2598
|
-
throw new
|
|
3550
|
+
throw new WorkflowValidationError2("[Sixb] Workflow run storage is not configured.");
|
|
2599
3551
|
}
|
|
2600
|
-
const failure =
|
|
2601
|
-
allowedCodes:
|
|
3552
|
+
const failure = captureSixbFailure2(error, {
|
|
3553
|
+
allowedCodes: WORKFLOW_RUN_FAILURE_CODES2,
|
|
2602
3554
|
defaultCode: "internal.unexpected",
|
|
2603
3555
|
details: { workflowId: run.workflowId, runId: run.id }
|
|
2604
3556
|
});
|
|
@@ -2608,7 +3560,7 @@ async function failWorkflowRunPublication(input, run, error) {
|
|
|
2608
3560
|
status: "failed",
|
|
2609
3561
|
error: failure
|
|
2610
3562
|
});
|
|
2611
|
-
|
|
3563
|
+
reportRunFailure2(input.errorReporterHost, error, {
|
|
2612
3564
|
projectId: input.projectId,
|
|
2613
3565
|
runKind: "workflow",
|
|
2614
3566
|
run: { runId: run.id, workflowId: run.workflowId },
|
|
@@ -2617,15 +3569,15 @@ async function failWorkflowRunPublication(input, run, error) {
|
|
|
2617
3569
|
}
|
|
2618
3570
|
function resolveWorkflowRunId(runId) {
|
|
2619
3571
|
if (runId === undefined)
|
|
2620
|
-
return `run_${
|
|
3572
|
+
return `run_${randomUUID6()}`;
|
|
2621
3573
|
if (!runId.trim()) {
|
|
2622
|
-
throw new
|
|
3574
|
+
throw new WorkflowValidationError2("[Sixb] Workflow run id must not be empty");
|
|
2623
3575
|
}
|
|
2624
3576
|
return runId;
|
|
2625
3577
|
}
|
|
2626
3578
|
function assertExistingWorkflowRun(existing, workflowId, input) {
|
|
2627
3579
|
if (existing.workflowId !== workflowId || !isDeepStrictEqual(existing.input, input)) {
|
|
2628
|
-
throw new
|
|
3580
|
+
throw new WorkflowValidationError2(`[Sixb] Workflow run '${existing.id}' already exists with a different request payload.`);
|
|
2629
3581
|
}
|
|
2630
3582
|
}
|
|
2631
3583
|
function existingWorkflowRunResult(existing) {
|
|
@@ -2653,26 +3605,21 @@ async function assertAutomaticExecutionIdentity(dependencies, input, runId) {
|
|
|
2653
3605
|
id: run.executionId
|
|
2654
3606
|
}) : null;
|
|
2655
3607
|
if (!execution || execution.source.type !== input.source.type || execution.source.eventId !== input.source.eventId || execution.correlationId !== input.correlationId || execution.requestedBy !== undefined) {
|
|
2656
|
-
throw new
|
|
3608
|
+
throw new WorkflowValidationError2(`[Sixb] Workflow run '${runId}' already exists with different automatic provenance.`);
|
|
2657
3609
|
}
|
|
2658
3610
|
}
|
|
2659
3611
|
function assertNonBlank(value, label) {
|
|
2660
3612
|
if (!value.trim())
|
|
2661
|
-
throw new
|
|
3613
|
+
throw new WorkflowValidationError2(`[Sixb] ${label} must not be empty.`);
|
|
2662
3614
|
}
|
|
2663
3615
|
|
|
2664
3616
|
// src/workflows/request.ts
|
|
2665
|
-
async function
|
|
3617
|
+
async function requestWorkflowRun2(runtime, execution, workflow, options = {}) {
|
|
2666
3618
|
resolveExecutionScopeAuthorization(runtime.projectId, {
|
|
2667
3619
|
execution,
|
|
2668
3620
|
authorization: runtime.runtimeAuthorization
|
|
2669
3621
|
});
|
|
2670
|
-
|
|
2671
|
-
const requesterGroupIds = execution.requestedBy ? await snapshotRequesterGroupIds({
|
|
2672
|
-
auth: runtime.storage.auth,
|
|
2673
|
-
projectId: runtime.projectId,
|
|
2674
|
-
principal: execution.requestedBy
|
|
2675
|
-
}) : [];
|
|
3622
|
+
assertAuthorized2(runtime, { kind: "workflow.run", workflowId: workflow.id });
|
|
2676
3623
|
return dispatchWorkflowRun({
|
|
2677
3624
|
errorReporterHost: runtime,
|
|
2678
3625
|
projectId: runtime.projectId,
|
|
@@ -2684,9 +3631,8 @@ async function requestWorkflowRun(runtime, execution, workflow, options = {}) {
|
|
|
2684
3631
|
runId: options.runId,
|
|
2685
3632
|
input: options.input,
|
|
2686
3633
|
source: options.source,
|
|
2687
|
-
requesterGroupIds,
|
|
2688
3634
|
createExecution: async (executionId, runId) => {
|
|
2689
|
-
const caller = await
|
|
3635
|
+
const caller = await ensureExecutionRecord2(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
2690
3636
|
execution,
|
|
2691
3637
|
runtimeAuthorization: runtime.runtimeAuthorization
|
|
2692
3638
|
}));
|
|
@@ -2702,7 +3648,7 @@ async function requestWorkflowRun(runtime, execution, workflow, options = {}) {
|
|
|
2702
3648
|
// src/workflows/execution.ts
|
|
2703
3649
|
function createWorkflowsRuntime(runtime, execution, source) {
|
|
2704
3650
|
const authority = resolveRuntimeAuthorizationForProject(runtime);
|
|
2705
|
-
const allowed = (workflowId) =>
|
|
3651
|
+
const allowed = (workflowId) => isRuntimeAllowed2(runtime, { kind: "workflow.run", workflowId });
|
|
2706
3652
|
const canAccessHistory = (workflowId) => {
|
|
2707
3653
|
switch (authority.type) {
|
|
2708
3654
|
case "denied":
|
|
@@ -2725,7 +3671,7 @@ function createWorkflowsRuntime(runtime, execution, source) {
|
|
|
2725
3671
|
}) ?? null;
|
|
2726
3672
|
if (!run || !canAccessHistory(run.workflowId))
|
|
2727
3673
|
return null;
|
|
2728
|
-
return authority.type === "unrestricted" ||
|
|
3674
|
+
return authority.type === "unrestricted" || canViewWorkflowRun2(authority.context, run) ? run : null;
|
|
2729
3675
|
};
|
|
2730
3676
|
const getRun = async (runId) => {
|
|
2731
3677
|
const run = await getVisibleRunRecord(runId);
|
|
@@ -2753,14 +3699,14 @@ function createWorkflowsRuntime(runtime, execution, source) {
|
|
|
2753
3699
|
const workflow = source.getById(workflowId);
|
|
2754
3700
|
return workflow && allowed(workflowId) ? workflow : null;
|
|
2755
3701
|
},
|
|
2756
|
-
request: (workflow, options) =>
|
|
3702
|
+
request: (workflow, options) => requestWorkflowRun2(runtime, execution, workflow, options),
|
|
2757
3703
|
requestById: async (input) => {
|
|
2758
|
-
|
|
3704
|
+
assertAuthorized2(runtime, { kind: "workflow.run", workflowId: input.workflowId });
|
|
2759
3705
|
const workflow = source.getById(input.workflowId);
|
|
2760
3706
|
if (!workflow) {
|
|
2761
|
-
throw new
|
|
3707
|
+
throw new WorkflowValidationError2(`[Sixb] Unknown workflow '${input.workflowId}'`);
|
|
2762
3708
|
}
|
|
2763
|
-
return
|
|
3709
|
+
return requestWorkflowRun2(runtime, execution, workflow, input);
|
|
2764
3710
|
},
|
|
2765
3711
|
runs: {
|
|
2766
3712
|
getById: getRun,
|
|
@@ -2811,7 +3757,7 @@ function createWorkflowsRuntime(runtime, execution, source) {
|
|
|
2811
3757
|
}) ?? null;
|
|
2812
3758
|
if (!intervention || !canAccessHistory(intervention.workflowId))
|
|
2813
3759
|
return null;
|
|
2814
|
-
return authority.type === "unrestricted" ||
|
|
3760
|
+
return authority.type === "unrestricted" || canViewWorkflowIntervention2(authority.context, intervention) ? intervention : null;
|
|
2815
3761
|
},
|
|
2816
3762
|
list: (input = {}) => {
|
|
2817
3763
|
if (authority.type === "denied" || authority.type === "delegated") {
|
|
@@ -2914,7 +3860,7 @@ function createBoundSixb(runtime, dependencies, execution) {
|
|
|
2914
3860
|
execution,
|
|
2915
3861
|
...createExecutionFacades(runtime, execution, dependencies)
|
|
2916
3862
|
};
|
|
2917
|
-
|
|
3863
|
+
shareOntologyMutationRuntime2(runtime, sixb);
|
|
2918
3864
|
if (dependencies.connectorConnections) {
|
|
2919
3865
|
registerConnectorConnectionsRuntime(sixb, createConnectorConnectionsRuntime(runtime, execution, dependencies.connectorConnections));
|
|
2920
3866
|
}
|
|
@@ -2935,6 +3881,7 @@ function createExecutionFacades(runtime, execution, dependencies) {
|
|
|
2935
3881
|
projections: createProjectionsRuntime(runtime, dependencies.definitions.projections),
|
|
2936
3882
|
rules: createRulesRuntime(runtime, dependencies.definitions.rules),
|
|
2937
3883
|
agent: createAgentRuntime(runtime, execution, dependencies.definitions.models),
|
|
3884
|
+
models: createModelsRuntime(runtime, execution, dependencies.definitions.models),
|
|
2938
3885
|
aiUsage: createAiUsageRuntime(runtime, dependencies.definitions.security),
|
|
2939
3886
|
events: createEventsRuntime(runtime),
|
|
2940
3887
|
logs: createLogsRuntime(runtime, dependencies.logging),
|
|
@@ -2945,15 +3892,16 @@ function createExecutionFacades(runtime, execution, dependencies) {
|
|
|
2945
3892
|
};
|
|
2946
3893
|
}
|
|
2947
3894
|
// src/execution/agent.ts
|
|
2948
|
-
function
|
|
3895
|
+
function canInheritAgentRequestAuthorization2(authorization) {
|
|
2949
3896
|
const ref = getAuthorizationRef(authorization);
|
|
2950
3897
|
return ref.type === "disabled" || ref.type === "principal" && ref.principal.type === "user" && ref.credential !== undefined;
|
|
2951
3898
|
}
|
|
2952
|
-
function
|
|
3899
|
+
function createAgentExecutionRecord2(input) {
|
|
2953
3900
|
assertAgentPrincipal(input.actorId, input.principal);
|
|
2954
3901
|
return {
|
|
2955
3902
|
id: input.id,
|
|
2956
3903
|
projectId: input.parent.projectId,
|
|
3904
|
+
requesterGroupIds: [...input.parent.requesterGroupIds],
|
|
2957
3905
|
...input.parent.requestedBy === undefined ? {} : { requestedBy: structuredClone(input.parent.requestedBy) },
|
|
2958
3906
|
executor: { type: "agent", runId: input.runId },
|
|
2959
3907
|
source: { type: "execution", executionId: input.parent.id },
|
|
@@ -2964,14 +3912,15 @@ function createAgentExecutionRecord(input) {
|
|
|
2964
3912
|
}
|
|
2965
3913
|
};
|
|
2966
3914
|
}
|
|
2967
|
-
function
|
|
3915
|
+
function createInheritedAgentExecutionRecord2(input) {
|
|
2968
3916
|
const authority = input.parent.authorizationRef;
|
|
2969
3917
|
if (authority.type !== "disabled" && !(authority.type === "principal" && authority.principal.type === "user" && authority.credential !== undefined)) {
|
|
2970
|
-
throw new
|
|
3918
|
+
throw new ExecutionStorageError2("invalid_input", `[Sixb] Agent run '${input.runId}' requires inheritable user or auth-disabled authority.`);
|
|
2971
3919
|
}
|
|
2972
3920
|
return {
|
|
2973
3921
|
id: input.id,
|
|
2974
3922
|
projectId: input.parent.projectId,
|
|
3923
|
+
requesterGroupIds: [...input.parent.requesterGroupIds],
|
|
2975
3924
|
...input.parent.requestedBy === undefined ? {} : { requestedBy: structuredClone(input.parent.requestedBy) },
|
|
2976
3925
|
executor: { type: "agent", runId: input.runId },
|
|
2977
3926
|
source: { type: "execution", executionId: input.parent.id },
|
|
@@ -2979,16 +3928,16 @@ function createInheritedAgentExecutionRecord(input) {
|
|
|
2979
3928
|
authorizationRef: structuredClone(authority)
|
|
2980
3929
|
};
|
|
2981
3930
|
}
|
|
2982
|
-
function
|
|
2983
|
-
const scope =
|
|
3931
|
+
function bindDurableAgentExecution2(host, input) {
|
|
3932
|
+
const scope = restoreAgentExecutionScope2(input);
|
|
2984
3933
|
const sixb = host.withScope(scope);
|
|
2985
3934
|
if (!isBoundSixb(sixb)) {
|
|
2986
3935
|
throw new Error("[Sixb] Agent execution host returned an invalid bound SDK.");
|
|
2987
3936
|
}
|
|
2988
3937
|
return sixb;
|
|
2989
3938
|
}
|
|
2990
|
-
function
|
|
2991
|
-
|
|
3939
|
+
function restoreAgentExecutionScope2(input) {
|
|
3940
|
+
assertAgentExecutionRecord2(input);
|
|
2992
3941
|
const context = Object.freeze({
|
|
2993
3942
|
id: input.execution.id,
|
|
2994
3943
|
projectId: input.execution.projectId,
|
|
@@ -3013,7 +3962,7 @@ function restoreAgentExecutionScope(input) {
|
|
|
3013
3962
|
})
|
|
3014
3963
|
});
|
|
3015
3964
|
}
|
|
3016
|
-
function
|
|
3965
|
+
function assertAgentExecutionRecord2(input) {
|
|
3017
3966
|
const authority = input.execution.authorizationRef;
|
|
3018
3967
|
if (input.execution.executor.type !== "agent" || input.execution.executor.runId !== input.runId || input.execution.source.type !== "execution") {
|
|
3019
3968
|
invalidAgentExecution(input.execution.id, input.runId);
|
|
@@ -3043,15 +3992,15 @@ function assertInheritedAgentAuthority(execution, runId, authorization) {
|
|
|
3043
3992
|
}
|
|
3044
3993
|
}
|
|
3045
3994
|
function assertAgentPrincipal(actorId, principal) {
|
|
3046
|
-
const expectedId =
|
|
3995
|
+
const expectedId = agentServiceAccountId2(actorId);
|
|
3047
3996
|
if (principal.id !== expectedId) {
|
|
3048
|
-
throw new
|
|
3997
|
+
throw new ExecutionStorageError2("invalid_input", `[Sixb] Agent '${actorId}' execution authority must reference service account '${expectedId}'.`);
|
|
3049
3998
|
}
|
|
3050
3999
|
}
|
|
3051
4000
|
function invalidAgentExecution(executionId, runId) {
|
|
3052
|
-
throw new
|
|
4001
|
+
throw new ExecutionStorageError2("invalid_input", `[Sixb] Execution '${executionId}' does not authorize Agent run '${runId}'.`);
|
|
3053
4002
|
}
|
|
3054
4003
|
|
|
3055
|
-
export {
|
|
4004
|
+
export { resolveAgentContextParts2, agentRunQueueJobId2, subagentRunQueueJobId2, workflowAgentNodeQueueJobId2, dispatchQueuedAgentRuns2, dispatchQueuedSubagentRuns2, createAgentThreadId2, createAgentRunId2, createSubagentRunId2, createSubagentExecutionId2, createAgentMessageId2, agentContextCheckpointId2, createAgentRunExecutionToken2, runModelLoop2, assertNoAgentDefinitions, bindModelExecutionAttempt, ShareError2, WorkflowDefinitionError2, WorkflowValidationError2, assertNonEmpty, isStepDefinition2, isAgentStepDefinition2, isInterventionDefinition2, isWorkflowDefinition2, validateWorkflowDefinition2, validateWorkflowsAtStartup2, validateWorkflowAgentStepGroupReferences2, validateWorkflowInput2, validateWorkflowStepInput2, validateWorkflowStepOutput2, validateWorkflowInterventionInput2, validateWorkflowInterventionResponse2, validateWorkflowInterventionDefaultResponse2, validateWorkflowAgentStepInput2, validateWorkflowAgentStepOutput2, snapshotWorkflowAgentStepInput2, snapshotWorkflowAgentStepOutput2, snapshotWorkflowInput2, snapshotWorkflowStepInput2, snapshotWorkflowStepOutput2, snapshotWorkflowInterventionInput2, snapshotWorkflowInterventionResponse2, snapshotWorkflowInterventionDefaultResponse2, snapshotWorkflowActionInput2, WorkflowRunDispatcher2, requestWorkflowRun2, createBoundSixb, isBoundSixb, canInheritAgentRequestAuthorization2, createAgentExecutionRecord2, createInheritedAgentExecutionRecord2, bindDurableAgentExecution2, restoreAgentExecutionScope2, assertAgentExecutionRecord2, requestAgentRun2, retryAgentRun2 };
|
|
3056
4005
|
|
|
3057
|
-
//# debugId=
|
|
4006
|
+
//# debugId=8A992C0F00F3BAC264756E2164756E21
|