@sixb/core 0.1.7 → 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/delegated-admission.d.ts +24 -0
- package/dist/actions/delegated-admission.d.ts.map +1 -0
- package/dist/actions/descriptor.d.ts +29 -0
- package/dist/actions/descriptor.d.ts.map +1 -0
- package/dist/actions/execution.d.ts +5 -5
- package/dist/actions/execution.d.ts.map +1 -1
- package/dist/actions/index.js +78 -84
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run-authorization.d.ts +20 -0
- package/dist/actions/run-authorization.d.ts.map +1 -0
- package/dist/actions/run-dispatch.d.ts +3 -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 +8 -125
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +1 -1
- package/dist/agents/authority.d.ts.map +1 -1
- 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/errors.d.ts +0 -9
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/identity.d.ts +3 -0
- package/dist/agents/identity.d.ts.map +1 -0
- package/dist/agents/index.d.ts +7 -7
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +193 -205
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +5 -6
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +4 -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/tool-definition.d.ts +0 -1
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/types.d.ts +1 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +0 -4
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/ai-usage/execution.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 -105
- 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/decision.d.ts +10 -2
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +2 -1
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +51 -53
- 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 +20 -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 -81
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/ontology-type-manifest.d.ts.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-3fqt22c4.js → chunk-0w35wavj.js} +360 -168
- package/dist/chunk-0w35wavj.js.map +14 -0
- package/dist/chunk-0y39rgsb.js +43 -0
- package/dist/{chunk-c15dr03f.js.map → chunk-0y39rgsb.js.map} +2 -2
- package/dist/{chunk-hdz94br2.js → chunk-17kfctj6.js} +23 -13
- package/dist/chunk-17kfctj6.js.map +10 -0
- package/dist/{chunk-e4rvtvpw.js → chunk-1enhpacz.js} +418 -233
- package/dist/chunk-1enhpacz.js.map +34 -0
- 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-7ds9620f.js → chunk-38zv5rkr.js} +24 -8
- package/dist/chunk-38zv5rkr.js.map +10 -0
- 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-qv38twt8.js → chunk-52hbv0ak.js} +192 -171
- package/dist/{chunk-qv38twt8.js.map → chunk-52hbv0ak.js.map} +6 -6
- 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-08twe8m6.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-tn7xcs2n.js → chunk-860dwwy0.js} +93 -30
- package/dist/chunk-860dwwy0.js.map +14 -0
- 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-gbrpsx4m.js → chunk-93csa55g.js} +72 -16
- 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-9qsh3p5y.js +111 -0
- package/dist/chunk-9qsh3p5y.js.map +11 -0
- package/dist/{chunk-4a849fr1.js → chunk-9tc8dxmn.js} +1 -1
- package/dist/{chunk-z2sery1b.js → chunk-9vx5e9g1.js} +68 -28
- package/dist/chunk-9vx5e9g1.js.map +11 -0
- package/dist/{chunk-9aehf39w.js → chunk-an5tt9y0.js} +353 -353
- package/dist/{chunk-9aehf39w.js.map → chunk-an5tt9y0.js.map} +2 -2
- package/dist/{chunk-x0qhkqje.js → chunk-ap0g1g74.js} +37 -37
- package/dist/{chunk-x0qhkqje.js.map → chunk-ap0g1g74.js.map} +2 -2
- package/dist/chunk-awbhdqyc.js +252 -0
- package/dist/chunk-awbhdqyc.js.map +10 -0
- package/dist/{chunk-ka3a2ft3.js → chunk-b19g04jk.js} +12 -12
- package/dist/{chunk-ka3a2ft3.js.map → chunk-b19g04jk.js.map} +2 -2
- package/dist/chunk-br3k6qbf.js +436 -0
- package/dist/chunk-br3k6qbf.js.map +12 -0
- 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-atmkaf60.js → chunk-dmn70ztd.js} +30 -34
- package/dist/chunk-dmn70ztd.js.map +11 -0
- package/dist/chunk-dz5h08xv.js +1887 -0
- package/dist/chunk-dz5h08xv.js.map +25 -0
- 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-ha58tjtt.js → chunk-emyyk7dx.js} +59 -55
- package/dist/{chunk-ha58tjtt.js.map → chunk-emyyk7dx.js.map} +3 -3
- package/dist/{chunk-3kv70xwp.js → chunk-ey1nk510.js} +18 -2
- package/dist/chunk-ey1nk510.js.map +10 -0
- package/dist/chunk-f0rwz2vh.js +152 -0
- 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-rre42skh.js → chunk-g00bfdq6.js} +729 -296
- package/dist/{chunk-rre42skh.js.map → chunk-g00bfdq6.js.map} +11 -7
- 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-hpr1r6av.js +4006 -0
- 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-rp1mvzb4.js → chunk-jjy0fhrn.js} +40 -35
- package/dist/{chunk-rp1mvzb4.js.map → chunk-jjy0fhrn.js.map} +3 -3
- package/dist/{chunk-4nxeacx7.js → chunk-jmfet9r4.js} +6 -6
- package/dist/{chunk-4nxeacx7.js.map → chunk-jmfet9r4.js.map} +2 -2
- package/dist/{chunk-64sr682n.js → chunk-k3cqkkn2.js} +61 -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-qjycjdj6.js → chunk-m3z3x9v0.js} +106 -65
- package/dist/{chunk-qjycjdj6.js.map → chunk-m3z3x9v0.js.map} +3 -3
- package/dist/{chunk-6ed5bwnd.js → chunk-mjbk2djy.js} +2092 -1714
- package/dist/chunk-mjbk2djy.js.map +57 -0
- package/dist/{chunk-5jcdmjam.js → chunk-mmagke4x.js} +6 -6
- package/dist/{chunk-5jcdmjam.js.map → chunk-mmagke4x.js.map} +2 -2
- package/dist/chunk-mrp7k0pw.js +147 -0
- package/dist/chunk-mrp7k0pw.js.map +10 -0
- package/dist/{chunk-d63tybny.js → chunk-ms2tmn1k.js} +139 -139
- package/dist/{chunk-d63tybny.js.map → chunk-ms2tmn1k.js.map} +2 -2
- package/dist/{chunk-xdpwpkha.js → chunk-ppytyr6w.js} +156 -179
- package/dist/{chunk-xdpwpkha.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-qjzp9xyb.js → chunk-pr2h4bv4.js} +33 -35
- package/dist/chunk-pr2h4bv4.js.map +12 -0
- 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-agsvg9ar.js → chunk-qf954wje.js} +6 -6
- package/dist/{chunk-agsvg9ar.js.map → chunk-qf954wje.js.map} +2 -2
- package/dist/{chunk-wjgm6jjt.js → chunk-qhcpj9wc.js} +166 -132
- package/dist/chunk-qhcpj9wc.js.map +14 -0
- 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-2b5qtban.js → chunk-r4tfx1sf.js} +142 -89
- 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-v4jbb3rs.js +403 -0
- package/dist/chunk-v4jbb3rs.js.map +10 -0
- package/dist/{chunk-d2ndstdf.js → chunk-vf691g1r.js} +61 -59
- package/dist/{chunk-d2ndstdf.js.map → chunk-vf691g1r.js.map} +2 -2
- package/dist/{chunk-1kamz6j0.js → chunk-vsj3mdfj.js} +8 -8
- package/dist/{chunk-1kamz6j0.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-x9v4cx1d.js +139 -0
- package/dist/chunk-x9v4cx1d.js.map +10 -0
- package/dist/{chunk-kt81c11h.js → chunk-xfbydgzy.js} +27 -27
- package/dist/{chunk-kt81c11h.js.map → chunk-xfbydgzy.js.map} +2 -2
- package/dist/{chunk-vjjv9mrb.js → chunk-xyr8kppc.js} +22 -22
- package/dist/{chunk-vjjv9mrb.js.map → chunk-xyr8kppc.js.map} +3 -3
- package/dist/chunk-ypbtykv6.js +1537 -0
- package/dist/chunk-ypbtykv6.js.map +19 -0
- 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-xc7hq65b.js → chunk-z30bv4ga.js} +80 -33
- package/dist/chunk-z30bv4ga.js.map +11 -0
- 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-z8fx5cgb.js +159 -0
- package/dist/chunk-z8fx5cgb.js.map +11 -0
- 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/builders.d.ts +11 -2
- package/dist/datasets/builders.d.ts.map +1 -1
- package/dist/datasets/changes.d.ts +14 -4
- package/dist/datasets/changes.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +15 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/index.d.ts +1 -0
- package/dist/datasets/index.d.ts.map +1 -1
- package/dist/datasets/sequence.d.ts +7 -0
- package/dist/datasets/sequence.d.ts.map +1 -0
- package/dist/datasets/types.d.ts +1 -0
- package/dist/datasets/types.d.ts.map +1 -1
- package/dist/datasets/validation.d.ts.map +1 -1
- package/dist/datasets/write.d.ts +37 -0
- package/dist/datasets/write.d.ts.map +1 -0
- package/dist/datasets/write.js +13 -0
- package/dist/datasets/write.js.map +9 -0
- package/dist/edits/index.js +7 -8
- package/dist/edits/index.js.map +1 -1
- package/dist/error-reporting/internal.js +22 -24
- package/dist/error-reporting/internal.js.map +1 -1
- package/dist/errors/internal.d.ts +1 -1
- package/dist/errors/internal.d.ts.map +1 -1
- package/dist/errors/internal.js +22 -24
- package/dist/errors/internal.js.map +1 -1
- package/dist/errors/redaction.d.ts +8 -0
- package/dist/errors/redaction.d.ts.map +1 -0
- package/dist/errors/types.d.ts +4 -0
- package/dist/errors/types.d.ts.map +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +60 -63
- package/dist/events/index.js.map +1 -1
- package/dist/events/scope.js +4 -5
- package/dist/events/scope.js.map +1 -1
- package/dist/events/selectors/index.js +9 -10
- package/dist/events/selectors/index.js.map +1 -1
- package/dist/events/types/datasets.d.ts +2 -6
- package/dist/events/types/datasets.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +3 -3
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +70 -75
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts +58 -20
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +69 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -0
- package/dist/execution/durable.d.ts +1 -0
- package/dist/execution/durable.d.ts.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.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 -64
- package/dist/execution/primitive.js.map +3 -3
- package/dist/execution/request.d.ts +12 -0
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +97 -71
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/scopes.d.ts +16 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/types.d.ts +9 -0
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts +2 -0
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +10 -11
- package/dist/http/index.js.map +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +455 -463
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/definition-updates.d.ts.map +1 -1
- package/dist/lake-storage/errors.d.ts +5 -1
- package/dist/lake-storage/errors.d.ts.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +1 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +6 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +40 -27
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/merge-validation.d.ts.map +1 -1
- package/dist/lake-storage/merge.d.ts +13 -2
- package/dist/lake-storage/merge.d.ts.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +19 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -0
- package/dist/lake-storage/sql-transforms.d.ts +2 -1
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +10 -5
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +4 -0
- package/dist/lake-storage/version-inputs.d.ts.map +1 -0
- 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 -142
- 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/authorized-ontology-view.d.ts +25 -0
- package/dist/objects/authorized-ontology-view.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +1 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +75 -84
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/authorization.d.ts +2 -7
- package/dist/objects/link/authorization.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +4 -2
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.js +67 -73
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/links.d.ts +22 -1
- package/dist/objects/query/links.d.ts.map +1 -1
- package/dist/objects/query/selected-read-admission.d.ts +27 -0
- package/dist/objects/query/selected-read-admission.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +60 -2
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +2 -7
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -1
- package/dist/objects/service/list-service.d.ts +2 -3
- package/dist/objects/service/list-service.d.ts.map +1 -1
- package/dist/objects/telemetry/history.d.ts +8 -6
- package/dist/objects/telemetry/history.d.ts.map +1 -1
- package/dist/objects/telemetry/index.d.ts +2 -2
- package/dist/objects/telemetry/index.d.ts.map +1 -1
- package/dist/objects/telemetry/workload.d.ts +11 -0
- package/dist/objects/telemetry/workload.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +2 -2
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +61 -111
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/inference/index.d.ts +2 -1
- package/dist/ontology/inference/index.d.ts.map +1 -1
- package/dist/ontology/internal.d.ts +7 -1
- package/dist/ontology/internal.d.ts.map +1 -1
- package/dist/ontology/internal.js +65 -121
- package/dist/ontology/internal.js.map +3 -4
- package/dist/ontology/json-schema.d.ts +10 -6
- package/dist/ontology/json-schema.d.ts.map +1 -1
- package/dist/ontology/link-path-selection.d.ts +35 -0
- package/dist/ontology/link-path-selection.d.ts.map +1 -0
- package/dist/ontology/refs.d.ts +2 -0
- package/dist/ontology/refs.d.ts.map +1 -1
- package/dist/ontology/tokens.d.ts +2 -1
- package/dist/ontology/tokens.d.ts.map +1 -1
- package/dist/pipelines/execution.d.ts.map +1 -1
- package/dist/pipelines/index.js +57 -63
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/request.d.ts.map +1 -1
- package/dist/projections/execution.d.ts.map +1 -1
- package/dist/projections/internal.js +58 -64
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +11 -15
- package/dist/query.js.map +1 -1
- package/dist/queues/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/execution.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 +6 -2
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +2 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +4 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +13 -14
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +6 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +3 -0
- package/dist/runtime/types.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/execution.d.ts +2 -1
- package/dist/schedules/execution.d.ts.map +1 -1
- package/dist/schedules/index.js +31 -33
- package/dist/schedules/index.js.map +1 -1
- package/dist/security/every.d.ts +4 -1
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +7 -2
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +1 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +7 -1
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +2 -0
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/access-plan.d.ts +22 -0
- package/dist/shares/access-plan.d.ts.map +1 -0
- package/dist/shares/builders.d.ts +14 -0
- package/dist/shares/builders.d.ts.map +1 -0
- package/dist/shares/compiler.d.ts +14 -0
- package/dist/shares/compiler.d.ts.map +1 -0
- package/dist/shares/errors.d.ts +4 -0
- package/dist/shares/errors.d.ts.map +1 -0
- package/dist/shares/execution.d.ts +57 -0
- package/dist/shares/execution.d.ts.map +1 -0
- package/dist/shares/index.d.ts +10 -0
- package/dist/shares/index.d.ts.map +1 -0
- package/dist/shares/internal.d.ts +3 -0
- package/dist/shares/internal.d.ts.map +1 -0
- package/dist/shares/internal.js +231 -0
- package/dist/shares/internal.js.map +10 -0
- package/dist/shares/intersection.d.ts +9 -0
- package/dist/shares/intersection.d.ts.map +1 -0
- package/dist/shares/session-protocol.d.ts +41 -0
- package/dist/shares/session-protocol.d.ts.map +1 -0
- package/dist/shares/types.d.ts +51 -0
- package/dist/shares/types.d.ts.map +1 -0
- package/dist/shares/validation.d.ts +11 -0
- package/dist/shares/validation.d.ts.map +1 -0
- 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 +3 -0
- package/dist/storage/executions/in-memory.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +6 -2
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +35 -12
- package/dist/storage/executions/provider.js.map +3 -3
- package/dist/storage/executions/run-link.d.ts +7 -0
- package/dist/storage/executions/run-link.d.ts.map +1 -1
- 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 +8 -0
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +8 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +14 -9
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +221 -227
- 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/objects/execution-limits.d.ts +25 -0
- package/dist/storage/objects/execution-limits.d.ts.map +1 -0
- package/dist/storage/objects/guard.d.ts +16 -0
- package/dist/storage/objects/guard.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/index.d.ts +3 -0
- package/dist/storage/objects/in-memory/index.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/keys.d.ts +10 -0
- package/dist/storage/objects/in-memory/keys.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/query.d.ts +31 -0
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts +18 -0
- package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/read-source.d.ts +10 -0
- package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts +9 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -0
- package/dist/storage/objects/{in-memory.d.ts → in-memory/storage.d.ts} +13 -10
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -0
- package/dist/storage/objects/index.d.ts +4 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +1 -1
- package/dist/storage/objects/keys.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts +25 -0
- package/dist/storage/objects/read-scope.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +114 -22
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +105 -109
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/operation-scope.d.ts +3 -0
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +18 -17
- 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/errors.d.ts +8 -0
- package/dist/storage/share-grants/errors.d.ts.map +1 -0
- package/dist/storage/share-grants/in-memory.d.ts +11 -0
- package/dist/storage/share-grants/in-memory.d.ts.map +1 -0
- package/dist/storage/share-grants/index.d.ts +5 -0
- package/dist/storage/share-grants/index.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.d.ts +4 -0
- package/dist/storage/share-grants/provider.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +22 -0
- package/dist/storage/share-grants/provider.js.map +9 -0
- package/dist/storage/share-grants/record.d.ts +11 -0
- package/dist/storage/share-grants/record.d.ts.map +1 -0
- package/dist/storage/share-grants/types.d.ts +97 -0
- package/dist/storage/share-grants/types.d.ts.map +1 -0
- package/dist/storage/share-sessions/errors.d.ts +8 -0
- package/dist/storage/share-sessions/errors.d.ts.map +1 -0
- package/dist/storage/share-sessions/in-memory.d.ts +14 -0
- package/dist/storage/share-sessions/in-memory.d.ts.map +1 -0
- package/dist/storage/share-sessions/index.d.ts +5 -0
- package/dist/storage/share-sessions/index.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.d.ts +3 -0
- package/dist/storage/share-sessions/provider.d.ts.map +1 -0
- package/dist/storage/share-sessions/provider.js +19 -0
- package/dist/storage/share-sessions/provider.js.map +9 -0
- package/dist/storage/share-sessions/record.d.ts +8 -0
- package/dist/storage/share-sessions/record.d.ts.map +1 -0
- package/dist/storage/share-sessions/types.d.ts +50 -0
- package/dist/storage/share-sessions/types.d.ts.map +1 -0
- package/dist/storage/sync-runs/provider.js +4 -6
- package/dist/storage/sync-runs/provider.js.map +1 -1
- package/dist/storage/transaction.d.ts +2 -1
- package/dist/storage/transaction.d.ts.map +1 -1
- package/dist/storage/types.d.ts +8 -0
- package/dist/storage/types.d.ts.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 -18
- 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/execution.d.ts.map +1 -1
- package/dist/syncs/index.js +55 -62
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/testing/action-execution.d.ts +4 -1
- package/dist/testing/action-execution.d.ts.map +1 -1
- package/dist/testing/agent-execution.d.ts +1 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts +4 -0
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -0
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts +4 -0
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution.d.ts +1 -0
- package/dist/testing/execution.d.ts.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3087 -1328
- package/dist/testing/index.js.map +17 -13
- package/dist/testing/lake-merge-storage-contract.d.ts +1 -0
- package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-read-scope-contract.d.ts +22 -0
- package/dist/testing/object-read-scope-contract.d.ts.map +1 -0
- package/dist/testing/share-grant-storage-contract.d.ts +10 -0
- package/dist/testing/share-grant-storage-contract.d.ts.map +1 -0
- package/dist/testing/share-session-storage-contract.d.ts +9 -0
- package/dist/testing/share-session-storage-contract.d.ts.map +1 -0
- 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 -56
- 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/execution.d.ts.map +1 -1
- package/dist/workflows/failure.d.ts +2 -0
- package/dist/workflows/failure.d.ts.map +1 -1
- package/dist/workflows/index.js +135 -140
- 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 +72 -30
- package/src/actions/delegated-admission.ts +72 -0
- package/src/actions/descriptor.ts +58 -0
- package/src/actions/execution.ts +99 -24
- package/src/actions/request.ts +136 -19
- package/src/actions/run-authorization.ts +53 -0
- package/src/actions/run-dispatch.ts +10 -7
- package/src/actions/types/context.ts +2 -0
- package/src/actions/validation.ts +2 -1
- package/src/agents/adapters.ts +34 -429
- package/src/agents/authority.ts +3 -4
- 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 +2 -5
- package/src/agents/errors.ts +0 -10
- package/src/agents/execution.ts +13 -5
- package/src/agents/identity.ts +4 -0
- package/src/agents/index.ts +5 -24
- package/src/agents/message.ts +5 -6
- package/src/agents/model-loop.ts +62 -6
- package/src/agents/request.ts +27 -29
- 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/tool-definition.ts +0 -19
- package/src/agents/types.ts +1 -1
- package/src/agents/validation.ts +9 -72
- package/src/ai-usage/execution.ts +4 -11
- package/src/auth/index.ts +0 -1
- package/src/authorization/decision.ts +29 -14
- package/src/authorization/grant-kinds.ts +10 -0
- package/src/authorization/index.ts +1 -0
- package/src/bootstrap/discovery.ts +84 -24
- package/src/bootstrap/index.ts +8 -1
- package/src/bootstrap/ontology-type-manifest.ts +12 -6
- package/src/datasets/builders.ts +23 -2
- package/src/datasets/changes.ts +16 -4
- package/src/datasets/execution.ts +76 -5
- package/src/datasets/index.ts +1 -0
- package/src/datasets/sequence.ts +77 -0
- package/src/datasets/types.ts +1 -0
- package/src/datasets/validation.ts +26 -0
- package/src/datasets/write.ts +240 -0
- package/src/errors/internal.ts +90 -10
- package/src/errors/redaction.ts +98 -0
- package/src/errors/types.ts +4 -0
- package/src/events/execution.ts +57 -7
- package/src/events/types/datasets.ts +2 -6
- package/src/execution/agent.ts +6 -7
- package/src/execution/authorization.ts +470 -90
- package/src/execution/authorized-object-reader.ts +695 -0
- package/src/execution/durable.ts +21 -3
- package/src/execution/index.ts +1 -0
- package/src/execution/primitive.ts +5 -1
- package/src/execution/request.ts +66 -13
- package/src/execution/scopes.ts +36 -6
- package/src/execution/types.ts +8 -0
- package/src/http/api-routes.ts +45 -0
- package/src/index.ts +56 -33
- package/src/lake-storage/definition-updates.ts +9 -0
- package/src/lake-storage/errors.ts +6 -1
- package/src/lake-storage/in-memory.ts +53 -17
- package/src/lake-storage/index.ts +10 -1
- package/src/lake-storage/merge-validation.ts +12 -2
- package/src/lake-storage/merge.ts +40 -2
- package/src/lake-storage/source-ordering.ts +95 -0
- package/src/lake-storage/sql-transforms.ts +2 -1
- package/src/lake-storage/types.ts +10 -5
- package/src/lake-storage/version-inputs.ts +14 -0
- 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/authorized-ontology-view.ts +512 -0
- package/src/objects/execution.ts +99 -144
- package/src/objects/link/authorization.ts +3 -2
- package/src/objects/query/executor.ts +45 -34
- package/src/objects/query/links.ts +84 -25
- package/src/objects/query/selected-read-admission.ts +310 -0
- package/src/objects/query/validate.ts +353 -36
- package/src/objects/sdk/object-handle.ts +2 -8
- package/src/objects/sdk/object-set.ts +10 -11
- package/src/objects/sdk/runtime-query-executor.ts +8 -28
- package/src/objects/sdk/telemetry-channel.ts +11 -7
- package/src/objects/service/list-service.ts +15 -29
- package/src/objects/telemetry/history.ts +297 -17
- package/src/objects/telemetry/index.ts +2 -2
- package/src/objects/telemetry/workload.ts +79 -0
- package/src/ontology/index.ts +7 -2
- package/src/ontology/inference/index.ts +4 -1
- package/src/ontology/internal.ts +35 -1
- package/src/ontology/json-schema.ts +13 -12
- package/src/ontology/link-path-selection.ts +193 -0
- package/src/ontology/refs.ts +19 -0
- package/src/ontology/tokens.ts +15 -8
- package/src/pipelines/execution.ts +30 -7
- package/src/pipelines/request.ts +5 -0
- package/src/projections/execution.ts +72 -11
- package/src/projections/run-dispatch.ts +7 -12
- package/src/query.ts +0 -1
- package/src/queues/index.ts +4 -2
- package/src/queues/types.ts +6 -25
- package/src/rules/execution.ts +20 -8
- package/src/runtime/create.ts +7 -2
- package/src/runtime/definitions.ts +2 -0
- package/src/runtime/host.ts +27 -7
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +9 -0
- package/src/runtime/sixb.ts +27 -2
- package/src/runtime/types.ts +3 -0
- package/src/sandboxes/errors.ts +5 -0
- package/src/sandboxes/index.ts +3 -0
- package/src/sandboxes/sandbox.ts +35 -7
- package/src/schedules/execution.ts +24 -2
- package/src/security/every.ts +4 -0
- package/src/security/grants.ts +45 -3
- package/src/security/index.ts +1 -0
- package/src/security/registry.ts +3 -0
- package/src/security/types.ts +8 -0
- package/src/security/validation.ts +3 -0
- package/src/shares/access-plan.ts +225 -0
- package/src/shares/builders.ts +381 -0
- package/src/shares/compiler.ts +359 -0
- package/src/shares/errors.ts +3 -0
- package/src/shares/execution.ts +394 -0
- package/src/shares/index.ts +28 -0
- package/src/shares/internal.ts +9 -0
- package/src/shares/intersection.ts +178 -0
- package/src/shares/session-protocol.ts +258 -0
- package/src/shares/types.ts +76 -0
- package/src/shares/validation.ts +40 -0
- 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 +13 -10
- package/src/storage/executions/provider.ts +34 -1
- package/src/storage/executions/run-link.ts +29 -0
- package/src/storage/executions/types.ts +6 -2
- package/src/storage/executions/validation.ts +78 -1
- package/src/storage/in-memory/index.ts +37 -3
- package/src/storage/index.ts +54 -29
- package/src/storage/internal.ts +20 -0
- package/src/storage/objects/execution-limits.ts +283 -0
- package/src/storage/objects/guard.ts +55 -0
- package/src/storage/objects/in-memory/index.ts +2 -0
- package/src/storage/objects/in-memory/keys.ts +46 -0
- package/src/storage/objects/in-memory/query.ts +754 -0
- package/src/storage/objects/in-memory/read-scope.ts +211 -0
- package/src/storage/objects/in-memory/read-source.ts +10 -0
- package/src/storage/objects/in-memory/selected-reader.ts +252 -0
- package/src/storage/objects/in-memory/storage.ts +589 -0
- package/src/storage/objects/index.ts +21 -0
- package/src/storage/objects/keys.ts +1 -1
- package/src/storage/objects/read-scope.ts +672 -0
- package/src/storage/objects/types.ts +123 -19
- package/src/storage/operation-scope.ts +16 -0
- package/src/storage/share-grants/errors.ts +14 -0
- package/src/storage/share-grants/in-memory.ts +107 -0
- package/src/storage/share-grants/index.ts +14 -0
- package/src/storage/share-grants/provider.ts +11 -0
- package/src/storage/share-grants/record.ts +347 -0
- package/src/storage/share-grants/types.ts +112 -0
- package/src/storage/share-sessions/errors.ts +14 -0
- package/src/storage/share-sessions/in-memory.ts +105 -0
- package/src/storage/share-sessions/index.ts +11 -0
- package/src/storage/share-sessions/provider.ts +9 -0
- package/src/storage/share-sessions/record.ts +176 -0
- package/src/storage/share-sessions/types.ts +57 -0
- package/src/storage/transaction.ts +14 -2
- package/src/storage/types.ts +27 -0
- package/src/storage/workflow-runs/in-memory.ts +0 -2
- package/src/storage/workflow-runs/types.ts +0 -3
- package/src/syncs/execution.ts +25 -5
- package/src/syncs/request.ts +5 -0
- 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/dataset-sequence-contract.ts +373 -0
- package/src/testing/effective-storage-contract.ts +34 -0
- package/src/testing/execution-storage-contract.ts +138 -1
- package/src/testing/execution.ts +6 -0
- package/src/testing/index.ts +16 -0
- package/src/testing/lake-merge-storage-contract.ts +3 -0
- package/src/testing/lake-storage-contract.ts +58 -0
- package/src/testing/object-read-scope-contract.ts +939 -0
- package/src/testing/share-grant-storage-contract.ts +325 -0
- package/src/testing/share-session-storage-contract.ts +235 -0
- package/src/testing/workflow-execution.ts +4 -0
- package/src/workflows/execution.ts +53 -14
- package/src/workflows/failure.ts +62 -1
- package/src/workflows/request.ts +5 -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-08twe8m6.js +0 -218
- package/dist/chunk-2b5qtban.js.map +0 -14
- package/dist/chunk-2xns679x.js.map +0 -11
- package/dist/chunk-37wk412q.js +0 -1370
- package/dist/chunk-37wk412q.js.map +0 -23
- package/dist/chunk-3fqt22c4.js.map +0 -14
- package/dist/chunk-3kv70xwp.js.map +0 -10
- package/dist/chunk-407j3msh.js +0 -60
- package/dist/chunk-64sr682n.js.map +0 -12
- package/dist/chunk-6ed5bwnd.js.map +0 -57
- package/dist/chunk-7ds9620f.js.map +0 -10
- package/dist/chunk-7y0f6rf1.js.map +0 -10
- package/dist/chunk-atmkaf60.js.map +0 -11
- package/dist/chunk-c15dr03f.js +0 -43
- package/dist/chunk-d8qkxt2v.js.map +0 -10
- package/dist/chunk-dqn23610.js +0 -72
- package/dist/chunk-dqn23610.js.map +0 -11
- package/dist/chunk-e4rvtvpw.js.map +0 -34
- package/dist/chunk-gbrpsx4m.js.map +0 -11
- package/dist/chunk-h0knpbz5.js +0 -2486
- package/dist/chunk-h0knpbz5.js.map +0 -38
- package/dist/chunk-hdz94br2.js.map +0 -10
- package/dist/chunk-jq43kdvk.js +0 -50
- package/dist/chunk-n2arzn6e.js +0 -1745
- package/dist/chunk-n2arzn6e.js.map +0 -20
- package/dist/chunk-p03r0h5s.js.map +0 -16
- package/dist/chunk-qjzp9xyb.js.map +0 -12
- package/dist/chunk-tn7xcs2n.js.map +0 -13
- package/dist/chunk-wjgm6jjt.js.map +0 -13
- package/dist/chunk-xc7hq65b.js.map +0 -10
- package/dist/chunk-y35ma3mj.js +0 -551
- package/dist/chunk-y35ma3mj.js.map +0 -15
- package/dist/chunk-y64skrwp.js +0 -19
- package/dist/chunk-z2sery1b.js.map +0 -11
- package/dist/chunk-zcnhxkvd.js +0 -7
- package/dist/logging/types.js +0 -27
- package/dist/logging/types.js.map +0 -9
- package/dist/storage/objects/in-memory.d.ts.map +0 -1
- package/src/storage/objects/in-memory.ts +0 -1241
- /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-h0knpbz5.js
DELETED
|
@@ -1,2486 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
SyncValidationError,
|
|
4
|
-
createConnectorRuntime,
|
|
5
|
-
requestSyncRun
|
|
6
|
-
} from "./chunk-ha58tjtt.js";
|
|
7
|
-
import {
|
|
8
|
-
aiLimitSubjectsFromAttribution,
|
|
9
|
-
aiUsageLimitExceededError,
|
|
10
|
-
aiUsageLimitUnavailableError,
|
|
11
|
-
applicableAiLimitPolicyStatuses
|
|
12
|
-
} from "./chunk-c15dr03f.js";
|
|
13
|
-
import {
|
|
14
|
-
PipelineError,
|
|
15
|
-
requestPipelineRun
|
|
16
|
-
} from "./chunk-rp1mvzb4.js";
|
|
17
|
-
import {
|
|
18
|
-
appendTelemetry,
|
|
19
|
-
createObjectSet,
|
|
20
|
-
getTelemetryHistoryBatch,
|
|
21
|
-
listObjects,
|
|
22
|
-
removeLink1 as removeLink,
|
|
23
|
-
upsertLink1 as upsertLink,
|
|
24
|
-
upsertLinkBatch1 as upsertLinkBatch,
|
|
25
|
-
upsertObject1 as upsertObject,
|
|
26
|
-
upsertObjectBatch1 as upsertObjectBatch
|
|
27
|
-
} from "./chunk-e4rvtvpw.js";
|
|
28
|
-
import {
|
|
29
|
-
shareOntologyMutationRuntime
|
|
30
|
-
} from "./chunk-xhy826cz.js";
|
|
31
|
-
import {
|
|
32
|
-
countObjects,
|
|
33
|
-
executeObjectQuery,
|
|
34
|
-
executeObjectQueryLinks,
|
|
35
|
-
existsObjects,
|
|
36
|
-
facetObjects
|
|
37
|
-
} from "./chunk-3fqt22c4.js";
|
|
38
|
-
import {
|
|
39
|
-
registerConnectorConnectionsRuntime
|
|
40
|
-
} from "./chunk-nf4r78r4.js";
|
|
41
|
-
import {
|
|
42
|
-
isActionDefinition,
|
|
43
|
-
requestAction,
|
|
44
|
-
requestActionAndWait
|
|
45
|
-
} from "./chunk-y35ma3mj.js";
|
|
46
|
-
import {
|
|
47
|
-
createPrimitiveExecutionRecord,
|
|
48
|
-
ensureExecutionRecord,
|
|
49
|
-
executionRecordInputFromRuntime
|
|
50
|
-
} from "./chunk-hdz94br2.js";
|
|
51
|
-
import {
|
|
52
|
-
WORKFLOW_RUN_FAILURE_CODES
|
|
53
|
-
} from "./chunk-6ed5bwnd.js";
|
|
54
|
-
import {
|
|
55
|
-
WorkflowRunError,
|
|
56
|
-
agentServiceAccountId
|
|
57
|
-
} from "./chunk-qjzp9xyb.js";
|
|
58
|
-
import {
|
|
59
|
-
ExecutionStorageError
|
|
60
|
-
} from "./chunk-gbrpsx4m.js";
|
|
61
|
-
import {
|
|
62
|
-
AGENT_REASONING_LEVELS,
|
|
63
|
-
AgentStorageError
|
|
64
|
-
} from "./chunk-08twe8m6.js";
|
|
65
|
-
import {
|
|
66
|
-
isObjectRefSchema,
|
|
67
|
-
validateSchemaOrRefValue
|
|
68
|
-
} from "./chunk-dqn23610.js";
|
|
69
|
-
import {
|
|
70
|
-
RuntimeError
|
|
71
|
-
} from "./chunk-p2vqaxkc.js";
|
|
72
|
-
import {
|
|
73
|
-
isModelReasoning
|
|
74
|
-
} from "./chunk-trxxmgnf.js";
|
|
75
|
-
import {
|
|
76
|
-
reportRunFailure
|
|
77
|
-
} from "./chunk-jq43kdvk.js";
|
|
78
|
-
import {
|
|
79
|
-
AgentRequestError,
|
|
80
|
-
normalizeAgentContextEntries
|
|
81
|
-
} from "./chunk-atmkaf60.js";
|
|
82
|
-
import {
|
|
83
|
-
publishAgentRunActivity
|
|
84
|
-
} from "./chunk-7y0f6rf1.js";
|
|
85
|
-
import {
|
|
86
|
-
SYSTEM_PRINCIPAL,
|
|
87
|
-
principalsEqual
|
|
88
|
-
} from "./chunk-rre42skh.js";
|
|
89
|
-
import {
|
|
90
|
-
snapshotRequesterGroupIds
|
|
91
|
-
} from "./chunk-4a849fr1.js";
|
|
92
|
-
import {
|
|
93
|
-
AuthorizationError,
|
|
94
|
-
assertAuthorized,
|
|
95
|
-
assertCanManageConnector,
|
|
96
|
-
assertPrivileged,
|
|
97
|
-
assertProviderAccess,
|
|
98
|
-
assertRuntimeAuthorizationBound,
|
|
99
|
-
canViewActionRun,
|
|
100
|
-
canViewEvent,
|
|
101
|
-
canViewPipelineRun,
|
|
102
|
-
canViewProjection,
|
|
103
|
-
canViewProjectionRun,
|
|
104
|
-
canViewWorkflowIntervention,
|
|
105
|
-
canViewWorkflowRun,
|
|
106
|
-
createAgentRuntimeAuthorization,
|
|
107
|
-
getAuthorizationRef,
|
|
108
|
-
isAllowed,
|
|
109
|
-
resolveExecutionScopeAuthorization
|
|
110
|
-
} from "./chunk-37wk412q.js";
|
|
111
|
-
import {
|
|
112
|
-
assertObjectTypeRegistered
|
|
113
|
-
} from "./chunk-d63tybny.js";
|
|
114
|
-
import {
|
|
115
|
-
supportsDirectUpload,
|
|
116
|
-
supportsRangeRead
|
|
117
|
-
} from "./chunk-08m3b6w8.js";
|
|
118
|
-
import {
|
|
119
|
-
captureSixbFailure
|
|
120
|
-
} from "./chunk-2xns679x.js";
|
|
121
|
-
import {
|
|
122
|
-
isPlainRecord
|
|
123
|
-
} from "./chunk-n6jxh8sw.js";
|
|
124
|
-
|
|
125
|
-
// src/actions/execution.ts
|
|
126
|
-
function createActionsRuntime(runtime, execution) {
|
|
127
|
-
const canList = (action) => isAllowed(runtime.authorization, { kind: "action.apply", actionId: action.id }) && (action.binding.kind === "global" || isAllowed(runtime.authorization, {
|
|
128
|
-
kind: "object.view",
|
|
129
|
-
objectTypeId: action.binding.objectType.id
|
|
130
|
-
}));
|
|
131
|
-
return {
|
|
132
|
-
list: () => runtime.actionRegistry.list().filter(canList),
|
|
133
|
-
getById: (actionId) => {
|
|
134
|
-
const action = runtime.actionRegistry.getById(actionId);
|
|
135
|
-
return action && canList(action) ? action : null;
|
|
136
|
-
},
|
|
137
|
-
listGlobal: () => runtime.actionRegistry.listGlobal().filter(canList),
|
|
138
|
-
listForType: (objectType) => runtime.actionRegistry.listForType(objectType).filter(canList),
|
|
139
|
-
request: (input) => requestAction(runtime, execution, input),
|
|
140
|
-
requestAndWait: (input) => requestActionAndWait(runtime, execution, input),
|
|
141
|
-
runs: {
|
|
142
|
-
getById: async (runId) => {
|
|
143
|
-
const run = await runtime.storage.actionRuns?.getById({
|
|
144
|
-
projectId: runtime.projectId,
|
|
145
|
-
id: runId
|
|
146
|
-
}) ?? null;
|
|
147
|
-
return run && canViewActionRun(runtime.authorization, run) ? run : null;
|
|
148
|
-
},
|
|
149
|
-
list: (input = {}) => {
|
|
150
|
-
const storage = runtime.storage.actionRuns;
|
|
151
|
-
if (!storage)
|
|
152
|
-
return Promise.resolve({ runs: [], hasMore: false, total: 0 });
|
|
153
|
-
return storage.list({
|
|
154
|
-
projectId: runtime.projectId,
|
|
155
|
-
...input,
|
|
156
|
-
actionIds: runtime.authorization ? [...runtime.authorization.grants["apply:action"]] : undefined,
|
|
157
|
-
objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/runtime/ai-cost.ts
|
|
165
|
-
async function resolveExecutionCosts(input) {
|
|
166
|
-
if (input.executionIds.length === 0)
|
|
167
|
-
return [];
|
|
168
|
-
if (!input.storage)
|
|
169
|
-
return input.executionIds.map(() => {
|
|
170
|
-
return;
|
|
171
|
-
});
|
|
172
|
-
return input.storage.summarizeExecutions({
|
|
173
|
-
projectId: input.projectId,
|
|
174
|
-
executionIds: input.executionIds
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/runtime/ai-usage.ts
|
|
179
|
-
async function resolveExecutionUsage(input) {
|
|
180
|
-
if (input.executionIds.length === 0)
|
|
181
|
-
return [];
|
|
182
|
-
if (!input.storage)
|
|
183
|
-
return input.executionIds.map(() => {
|
|
184
|
-
return;
|
|
185
|
-
});
|
|
186
|
-
const summaries = await input.storage.summarizeExecutions({
|
|
187
|
-
projectId: input.projectId,
|
|
188
|
-
executionIds: input.executionIds
|
|
189
|
-
});
|
|
190
|
-
return summaries.map((summary) => summary.modelCallCount === 0 ? undefined : summary.usage);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/agents/ids.ts
|
|
194
|
-
import { createHash, randomUUID } from "crypto";
|
|
195
|
-
function createAgentThreadId() {
|
|
196
|
-
return `agt_thr_${randomUUID()}`;
|
|
197
|
-
}
|
|
198
|
-
function createAgentRunId() {
|
|
199
|
-
return `agt_run_${randomUUID()}`;
|
|
200
|
-
}
|
|
201
|
-
function createSubagentRunId(parentRunId, spawnKey) {
|
|
202
|
-
const digest = createHash("sha256").update(parentRunId).update("\x00").update(spawnKey).digest("hex");
|
|
203
|
-
return `agt_run_child_${digest}`;
|
|
204
|
-
}
|
|
205
|
-
function createSubagentExecutionId(runId) {
|
|
206
|
-
return `exec_${runId}`;
|
|
207
|
-
}
|
|
208
|
-
function createAgentMessageId() {
|
|
209
|
-
return `agt_msg_${randomUUID()}`;
|
|
210
|
-
}
|
|
211
|
-
function agentContextCheckpointId(runId) {
|
|
212
|
-
return `agt_ctx_${runId}`;
|
|
213
|
-
}
|
|
214
|
-
function createAgentRunExecutionToken() {
|
|
215
|
-
return `agt_exec_${randomUUID()}`;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// src/agents/request.ts
|
|
219
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
220
|
-
|
|
221
|
-
// src/agents/context-resolution.ts
|
|
222
|
-
async function resolveAgentContextParts(runtime, input) {
|
|
223
|
-
const entries = normalizeAgentContextEntries(input);
|
|
224
|
-
for (const entry of entries) {
|
|
225
|
-
if (entry.context.kind !== "object")
|
|
226
|
-
continue;
|
|
227
|
-
const { objectTypeId, primaryId } = entry.context.ref;
|
|
228
|
-
try {
|
|
229
|
-
runtime.ontology.resolveObjectType(objectTypeId);
|
|
230
|
-
} catch {
|
|
231
|
-
invalidContext(`context references an unknown object type '${objectTypeId}'`);
|
|
232
|
-
}
|
|
233
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId });
|
|
234
|
-
const object = await runtime.storage.objects.getByPrimaryId({
|
|
235
|
-
projectId: runtime.projectId,
|
|
236
|
-
objectTypeId,
|
|
237
|
-
primaryId
|
|
238
|
-
});
|
|
239
|
-
if (!object) {
|
|
240
|
-
invalidContext(`context references an unknown object '${objectTypeId}:${primaryId}'`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return entries.map((entry) => ({ type: "context", ...entry }));
|
|
244
|
-
}
|
|
245
|
-
function invalidContext(message) {
|
|
246
|
-
throw new AgentRequestError("invalid_context", `[Sixb] Invalid agent context: ${message}.`);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// src/agents/dispatch.ts
|
|
250
|
-
function agentRunQueueJobId(runId) {
|
|
251
|
-
return `agt_job_${runId}`;
|
|
252
|
-
}
|
|
253
|
-
function subagentRunQueueJobId(runId) {
|
|
254
|
-
return `agt_child_job_${runId}`;
|
|
255
|
-
}
|
|
256
|
-
function workflowAgentNodeQueueJobId(nodeRunId) {
|
|
257
|
-
return `wfa_job_${nodeRunId}`;
|
|
258
|
-
}
|
|
259
|
-
async function dispatchQueuedAgentRuns(input) {
|
|
260
|
-
const limit = normalizeLimit(input.limit);
|
|
261
|
-
const runs = input.runIds ? await input.storage.runs.getByIds({
|
|
262
|
-
projectId: input.projectId,
|
|
263
|
-
ids: [...new Set(input.runIds)].slice(0, limit)
|
|
264
|
-
}) : (await input.storage.runs.list({
|
|
265
|
-
projectId: input.projectId,
|
|
266
|
-
kinds: ["conversation"],
|
|
267
|
-
statuses: ["queued"],
|
|
268
|
-
order: "asc",
|
|
269
|
-
limit
|
|
270
|
-
})).runs;
|
|
271
|
-
const queued = runs.filter((run) => run.kind === "conversation" && run.status === "queued");
|
|
272
|
-
if (queued.length === 0) {
|
|
273
|
-
return { scanned: 0, dispatched: [], failures: [] };
|
|
274
|
-
}
|
|
275
|
-
try {
|
|
276
|
-
const jobs = await input.queue.enqueue({
|
|
277
|
-
projectId: input.projectId,
|
|
278
|
-
jobs: queued.map((run) => ({
|
|
279
|
-
id: agentRunQueueJobId(run.id),
|
|
280
|
-
type: "agent.run.requested",
|
|
281
|
-
payload: { runId: run.id }
|
|
282
|
-
}))
|
|
283
|
-
});
|
|
284
|
-
const jobsById = new Map(jobs.map((job) => [job.id, job]));
|
|
285
|
-
const dispatched = queued.map((run) => {
|
|
286
|
-
const jobId = agentRunQueueJobId(run.id);
|
|
287
|
-
if (!jobsById.has(jobId)) {
|
|
288
|
-
throw new Error(`[Sixb] Agent queue did not return job '${jobId}'.`);
|
|
289
|
-
}
|
|
290
|
-
return { runId: run.id, jobId };
|
|
291
|
-
});
|
|
292
|
-
return { scanned: queued.length, dispatched, failures: [] };
|
|
293
|
-
} catch (error) {
|
|
294
|
-
return {
|
|
295
|
-
scanned: queued.length,
|
|
296
|
-
dispatched: [],
|
|
297
|
-
failures: queued.map((run) => ({ runId: run.id, error }))
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
async function dispatchQueuedSubagentRuns(input) {
|
|
302
|
-
const limit = normalizeLimit(input.limit);
|
|
303
|
-
const runs = input.runIds ? await input.storage.runs.getByIds({
|
|
304
|
-
projectId: input.projectId,
|
|
305
|
-
ids: [...new Set(input.runIds)].slice(0, limit)
|
|
306
|
-
}) : (await input.storage.runs.list({
|
|
307
|
-
projectId: input.projectId,
|
|
308
|
-
kinds: ["subagent"],
|
|
309
|
-
statuses: ["queued"],
|
|
310
|
-
order: "asc",
|
|
311
|
-
limit
|
|
312
|
-
})).runs;
|
|
313
|
-
const queued = runs.filter((run) => run.kind === "subagent" && run.status === "queued");
|
|
314
|
-
if (queued.length === 0)
|
|
315
|
-
return { scanned: 0, dispatched: [], failures: [] };
|
|
316
|
-
try {
|
|
317
|
-
const jobs = await input.queue.enqueue({
|
|
318
|
-
projectId: input.projectId,
|
|
319
|
-
jobs: queued.map((run) => ({
|
|
320
|
-
id: subagentRunQueueJobId(run.id),
|
|
321
|
-
type: "agent.subagent-run.requested",
|
|
322
|
-
payload: { runId: run.id }
|
|
323
|
-
}))
|
|
324
|
-
});
|
|
325
|
-
const jobsById = new Set(jobs.map((job) => job.id));
|
|
326
|
-
const dispatched = queued.map((run) => {
|
|
327
|
-
const jobId = subagentRunQueueJobId(run.id);
|
|
328
|
-
if (!jobsById.has(jobId)) {
|
|
329
|
-
throw new Error(`[Sixb] Subagent queue did not return job '${jobId}'.`);
|
|
330
|
-
}
|
|
331
|
-
return { runId: run.id, jobId };
|
|
332
|
-
});
|
|
333
|
-
return { scanned: queued.length, dispatched, failures: [] };
|
|
334
|
-
} catch (error) {
|
|
335
|
-
return {
|
|
336
|
-
scanned: queued.length,
|
|
337
|
-
dispatched: [],
|
|
338
|
-
failures: queued.map((run) => ({ runId: run.id, error }))
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
function normalizeLimit(value) {
|
|
343
|
-
if (value === undefined)
|
|
344
|
-
return 100;
|
|
345
|
-
if (!Number.isFinite(value) || value < 1) {
|
|
346
|
-
throw new Error("[Sixb] Agent dispatch limit must be at least 1.");
|
|
347
|
-
}
|
|
348
|
-
return Math.floor(value);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// src/agents/retired-config.ts
|
|
352
|
-
function assertNoAgentDefinitions(input) {
|
|
353
|
-
if ("agents" in input) {
|
|
354
|
-
throw new RuntimeError("[Sixb] Agent definitions are no longer supported. Configure 'models' and 'tools' on createSixb() instead.");
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
function assertNoAgentSelector(input) {
|
|
358
|
-
if ("agentId" in input || "agentIds" in input) {
|
|
359
|
-
throw new AgentRequestError("agent_selector_removed", "[Sixb] There is one project Agent. Remove the agentId selector and use sixb.agent.");
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// src/agents/request.ts
|
|
364
|
-
async function requestAgentRun(runtime, execution, models, input) {
|
|
365
|
-
assertNoAgentSelector(input);
|
|
366
|
-
assertAuthorized(runtime, { kind: "agent.run" });
|
|
367
|
-
assertRequestAuthorityCanRunAgent(runtime);
|
|
368
|
-
const spec = resolveConversationRunSpec({ models, input });
|
|
369
|
-
const contextParts = await resolveAgentContextParts(runtime, input.context);
|
|
370
|
-
const agents = requireAgentStorage(runtime);
|
|
371
|
-
const projectId = runtime.projectId;
|
|
372
|
-
const principal = runtime.authorization?.principal ?? input.principal ?? SYSTEM_PRINCIPAL;
|
|
373
|
-
const runId = createAgentRunId();
|
|
374
|
-
const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
|
|
375
|
-
const requesterGroupIds = durableExecution.requestedBy ? await snapshotRequesterGroupIds({
|
|
376
|
-
auth: runtime.storage.auth,
|
|
377
|
-
projectId,
|
|
378
|
-
principal: durableExecution.requestedBy
|
|
379
|
-
}) : [];
|
|
380
|
-
await assertAiLimitPreflight(runtime, durableExecution, requesterGroupIds);
|
|
381
|
-
const { thread, createdThread } = await resolveThread(agents, {
|
|
382
|
-
projectId,
|
|
383
|
-
threadId: input.threadId,
|
|
384
|
-
title: input.title,
|
|
385
|
-
principal
|
|
386
|
-
});
|
|
387
|
-
if (thread.activeRunId !== null) {
|
|
388
|
-
throw new AgentRequestError("active_run_exists", `[Sixb] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`);
|
|
389
|
-
}
|
|
390
|
-
const triggerMessageId = input.messageId ?? createAgentMessageId();
|
|
391
|
-
let run;
|
|
392
|
-
try {
|
|
393
|
-
run = await runtime.storage.transaction(async (tx) => {
|
|
394
|
-
const agents2 = tx.agents;
|
|
395
|
-
if (!agents2) {
|
|
396
|
-
throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
397
|
-
}
|
|
398
|
-
await tx.executions.create(durableExecution);
|
|
399
|
-
await agents2.messages.append({
|
|
400
|
-
id: triggerMessageId,
|
|
401
|
-
projectId,
|
|
402
|
-
threadId: thread.id,
|
|
403
|
-
runId: null,
|
|
404
|
-
role: "user",
|
|
405
|
-
parts: [
|
|
406
|
-
...contextParts,
|
|
407
|
-
{ type: "text", text: input.text },
|
|
408
|
-
...(input.attachments ?? []).map((fileRef) => ({ type: "file", fileRef }))
|
|
409
|
-
],
|
|
410
|
-
authorPrincipal: principal
|
|
411
|
-
});
|
|
412
|
-
return agents2.runs.create({
|
|
413
|
-
id: runId,
|
|
414
|
-
projectId,
|
|
415
|
-
executionId: durableExecution.id,
|
|
416
|
-
threadId: thread.id,
|
|
417
|
-
triggerMessageId,
|
|
418
|
-
spec,
|
|
419
|
-
requesterGroupIds
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
} catch (error) {
|
|
423
|
-
if (error instanceof AgentStorageError && error.code === "active_run_exists") {
|
|
424
|
-
throw new AgentRequestError("active_run_exists", error.message);
|
|
425
|
-
}
|
|
426
|
-
throw error;
|
|
427
|
-
}
|
|
428
|
-
await publishRunActivity(runtime, run);
|
|
429
|
-
const jobId = await dispatchAgentRun(runtime, agents, runId);
|
|
430
|
-
return {
|
|
431
|
-
run,
|
|
432
|
-
...jobId ? { jobId } : {},
|
|
433
|
-
createdThread
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
async function retryAgentRun(runtime, execution, models, failedRun) {
|
|
437
|
-
assertAuthorized(runtime, { kind: "agent.run" });
|
|
438
|
-
assertRequestAuthorityCanRunAgent(runtime);
|
|
439
|
-
if (failedRun.status !== "failed") {
|
|
440
|
-
throw new AgentRequestError("run_not_retryable", `[Sixb] Only failed Agent runs can be retried.`);
|
|
441
|
-
}
|
|
442
|
-
const agents = requireAgentStorage(runtime);
|
|
443
|
-
const thread = await agents.threads.getById({
|
|
444
|
-
projectId: runtime.projectId,
|
|
445
|
-
id: failedRun.threadId
|
|
446
|
-
});
|
|
447
|
-
if (!thread) {
|
|
448
|
-
throw new AgentRequestError("thread_not_found", `[Sixb] Agent thread '${failedRun.threadId}' was not found.`);
|
|
449
|
-
}
|
|
450
|
-
const runId = createAgentRunId();
|
|
451
|
-
const durableExecution = await prepareDurableAgentExecution(runtime, execution, runId);
|
|
452
|
-
const requesterGroupIds = durableExecution.requestedBy ? await snapshotRequesterGroupIds({
|
|
453
|
-
auth: runtime.storage.auth,
|
|
454
|
-
projectId: runtime.projectId,
|
|
455
|
-
principal: durableExecution.requestedBy
|
|
456
|
-
}) : [];
|
|
457
|
-
await assertAiLimitPreflight(runtime, durableExecution, requesterGroupIds);
|
|
458
|
-
const run = await runtime.storage.transaction(async (tx) => {
|
|
459
|
-
const agents2 = tx.agents;
|
|
460
|
-
if (!agents2) {
|
|
461
|
-
throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
462
|
-
}
|
|
463
|
-
await agents2.messages.deleteByRunId({
|
|
464
|
-
projectId: runtime.projectId,
|
|
465
|
-
threadId: failedRun.threadId,
|
|
466
|
-
runId: failedRun.id
|
|
467
|
-
});
|
|
468
|
-
await tx.executions.create(durableExecution);
|
|
469
|
-
return agents2.runs.create({
|
|
470
|
-
id: runId,
|
|
471
|
-
projectId: runtime.projectId,
|
|
472
|
-
executionId: durableExecution.id,
|
|
473
|
-
threadId: failedRun.threadId,
|
|
474
|
-
triggerMessageId: failedRun.triggerMessageId,
|
|
475
|
-
spec: failedRun.spec ?? resolveConversationRunSpec({
|
|
476
|
-
models,
|
|
477
|
-
input: {}
|
|
478
|
-
}),
|
|
479
|
-
requesterGroupIds
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
await publishRunActivity(runtime, run);
|
|
483
|
-
const jobId = await dispatchAgentRun(runtime, agents, runId);
|
|
484
|
-
return { run, ...jobId ? { jobId } : {}, createdThread: false };
|
|
485
|
-
}
|
|
486
|
-
async function assertAiLimitPreflight(runtime, execution, requesterGroupIds) {
|
|
487
|
-
const limits = runtime.storage.aiLimits;
|
|
488
|
-
if (!limits)
|
|
489
|
-
throw aiUsageLimitUnavailableError(["limitStorageUnavailable"]);
|
|
490
|
-
const subjects = aiLimitSubjectsFromAttribution(execution.requestedBy, requesterGroupIds);
|
|
491
|
-
let applicable;
|
|
492
|
-
try {
|
|
493
|
-
applicable = applicableAiLimitPolicyStatuses(await limits.listPolicyStatuses({ projectId: runtime.projectId }), subjects);
|
|
494
|
-
} catch {
|
|
495
|
-
throw aiUsageLimitUnavailableError(["limitStorageUnavailable"]);
|
|
496
|
-
}
|
|
497
|
-
const unavailable = applicable.filter((status) => status.accountingStatus === "unavailable");
|
|
498
|
-
if (unavailable.length > 0) {
|
|
499
|
-
throw aiUsageLimitUnavailableError(["incompleteAccounting"]);
|
|
500
|
-
}
|
|
501
|
-
const exhausted = applicable.filter((status) => status.exhausted);
|
|
502
|
-
if (exhausted.length > 0) {
|
|
503
|
-
const resetAt = new Date(Math.min(...exhausted.map((status) => status.period.resetAt.getTime())));
|
|
504
|
-
throw aiUsageLimitExceededError(resetAt);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
function resolveConversationRunSpec(input) {
|
|
508
|
-
if (!input.models) {
|
|
509
|
-
throw new AgentRequestError("model_not_found", "[Sixb] Configure models.language before starting the Agent.");
|
|
510
|
-
}
|
|
511
|
-
const selected = input.input.model ?? input.models.default;
|
|
512
|
-
const model = input.models.getByRef(selected);
|
|
513
|
-
if (model === null) {
|
|
514
|
-
throw new AgentRequestError("model_not_found", `[Sixb] Language model '${selected.provider}/${selected.modelId}' is not in the project model catalog.`);
|
|
515
|
-
}
|
|
516
|
-
const reasoning = input.input.reasoning;
|
|
517
|
-
if (reasoning !== undefined && !isModelReasoning(reasoning)) {
|
|
518
|
-
throw new AgentRequestError("invalid_model_selection", `[Sixb] Agent reasoning must be one of: ${AGENT_REASONING_LEVELS.join(", ")}, or a nonnegative budgetTokens object.`);
|
|
519
|
-
}
|
|
520
|
-
return Object.freeze({
|
|
521
|
-
model: Object.freeze({ provider: selected.provider, modelId: selected.modelId }),
|
|
522
|
-
...reasoning === undefined ? {} : { reasoning }
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
async function prepareDurableAgentExecution(runtime, execution, runId) {
|
|
526
|
-
const parent = await ensureExecutionRecord(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
527
|
-
execution,
|
|
528
|
-
runtimeAuthorization: runtime.runtimeAuthorization
|
|
529
|
-
}));
|
|
530
|
-
return createInheritedAgentExecutionRecord({
|
|
531
|
-
id: `exec_${randomUUID2()}`,
|
|
532
|
-
parent,
|
|
533
|
-
runId
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
function assertRequestAuthorityCanRunAgent(runtime) {
|
|
537
|
-
if (!canInheritAgentRequestAuthorization(runtime.runtimeAuthorization)) {
|
|
538
|
-
throw new AgentRequestError("authority_not_inheritable", "[Sixb] The Agent requires an authenticated user request or disabled authorization.");
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
async function dispatchAgentRun(runtime, agents, runId) {
|
|
542
|
-
try {
|
|
543
|
-
const dispatch = await dispatchQueuedAgentRuns({
|
|
544
|
-
projectId: runtime.projectId,
|
|
545
|
-
storage: agents,
|
|
546
|
-
queue: runtime.queues.agents,
|
|
547
|
-
runIds: [runId]
|
|
548
|
-
});
|
|
549
|
-
const failure = dispatch.failures[0];
|
|
550
|
-
if (failure) {
|
|
551
|
-
console.error(`[Sixb] Could not dispatch queued agent run '${runId}'; retrying later.`, failure.error);
|
|
552
|
-
}
|
|
553
|
-
return dispatch.dispatched[0]?.jobId;
|
|
554
|
-
} catch (error) {
|
|
555
|
-
console.error(`[Sixb] Could not dispatch queued agent run '${runId}'; retrying later.`, error);
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
async function publishRunActivity(runtime, run) {
|
|
560
|
-
try {
|
|
561
|
-
await publishAgentRunActivity(runtime.broker, run);
|
|
562
|
-
} catch (error) {
|
|
563
|
-
console.error(`[Sixb] Agent run '${run.id}' activity stream publish failed:`, error);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
async function resolveThread(agents, params) {
|
|
567
|
-
if (params.threadId) {
|
|
568
|
-
const existing = await agents.threads.getById({
|
|
569
|
-
projectId: params.projectId,
|
|
570
|
-
id: params.threadId
|
|
571
|
-
});
|
|
572
|
-
if (existing) {
|
|
573
|
-
return { thread: existing, createdThread: false };
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
const thread = await agents.threads.create({
|
|
577
|
-
id: params.threadId ?? createAgentThreadId(),
|
|
578
|
-
projectId: params.projectId,
|
|
579
|
-
ownerPrincipal: params.principal,
|
|
580
|
-
...params.title === undefined ? {} : { title: params.title }
|
|
581
|
-
});
|
|
582
|
-
return { thread, createdThread: true };
|
|
583
|
-
}
|
|
584
|
-
function requireAgentStorage(runtime) {
|
|
585
|
-
const agents = runtime.storage.agents;
|
|
586
|
-
if (!agents) {
|
|
587
|
-
throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
588
|
-
}
|
|
589
|
-
return agents;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// src/agents/execution.ts
|
|
593
|
-
function createAgentRuntime(runtime, execution, models) {
|
|
594
|
-
const principal = runtime.authorization?.principal ?? SYSTEM_PRINCIPAL;
|
|
595
|
-
const allowed = () => isAllowed(runtime.authorization, { kind: "agent.run" });
|
|
596
|
-
const getVisibleThreadRecord = async (threadId) => {
|
|
597
|
-
const thread = await runtime.storage.agents?.threads.getById({
|
|
598
|
-
projectId: runtime.projectId,
|
|
599
|
-
id: threadId
|
|
600
|
-
}) ?? null;
|
|
601
|
-
if (!thread || !allowed())
|
|
602
|
-
return null;
|
|
603
|
-
return runtime.authorization && !principalsEqual(principal, thread.ownerPrincipal) ? null : thread;
|
|
604
|
-
};
|
|
605
|
-
const getAgent = () => {
|
|
606
|
-
const model = models?.language.default;
|
|
607
|
-
if (!model || !allowed())
|
|
608
|
-
return null;
|
|
609
|
-
return {
|
|
610
|
-
name: "Sixb",
|
|
611
|
-
model: { provider: model.provider, modelId: model.modelId }
|
|
612
|
-
};
|
|
613
|
-
};
|
|
614
|
-
const getVisibleRunRecord = async (runId) => {
|
|
615
|
-
const run = await runtime.storage.agents?.runs.getById({
|
|
616
|
-
projectId: runtime.projectId,
|
|
617
|
-
id: runId
|
|
618
|
-
}) ?? null;
|
|
619
|
-
if (!run || run.kind !== "conversation")
|
|
620
|
-
return null;
|
|
621
|
-
const thread = await getVisibleThreadRecord(run.threadId);
|
|
622
|
-
return thread ? run : null;
|
|
623
|
-
};
|
|
624
|
-
const getRun = async (runId) => {
|
|
625
|
-
const run = await getVisibleRunRecord(runId);
|
|
626
|
-
return run ? attachRunView(runtime, run) : null;
|
|
627
|
-
};
|
|
628
|
-
return {
|
|
629
|
-
get: getAgent,
|
|
630
|
-
threads: {
|
|
631
|
-
create: async (input) => {
|
|
632
|
-
assertNoAgentSelector(input);
|
|
633
|
-
const agent = getAgent();
|
|
634
|
-
if (!agent) {
|
|
635
|
-
throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
636
|
-
}
|
|
637
|
-
const storage = runtime.storage.agents;
|
|
638
|
-
if (!storage) {
|
|
639
|
-
throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
640
|
-
}
|
|
641
|
-
return storage.threads.create({
|
|
642
|
-
id: input.id ?? createAgentThreadId(),
|
|
643
|
-
projectId: runtime.projectId,
|
|
644
|
-
ownerPrincipal: principal,
|
|
645
|
-
...input.title === undefined ? {} : { title: input.title }
|
|
646
|
-
});
|
|
647
|
-
},
|
|
648
|
-
getById: getVisibleThreadRecord,
|
|
649
|
-
list: async (input = {}) => {
|
|
650
|
-
assertNoAgentSelector(input);
|
|
651
|
-
const storage = runtime.storage.agents;
|
|
652
|
-
if (!storage || !allowed())
|
|
653
|
-
return { threads: [], hasMore: false, total: 0 };
|
|
654
|
-
return storage.threads.list({
|
|
655
|
-
...input,
|
|
656
|
-
projectId: runtime.projectId,
|
|
657
|
-
ownerPrincipal: runtime.authorization ? principal : undefined
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
runs: {
|
|
662
|
-
request: async (input) => {
|
|
663
|
-
assertNoAgentSelector(input);
|
|
664
|
-
const agent = getAgent();
|
|
665
|
-
if (!agent) {
|
|
666
|
-
throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
667
|
-
}
|
|
668
|
-
assertAuthorized(runtime, { kind: "agent.run" });
|
|
669
|
-
if (input.threadId && !await getVisibleThreadRecord(input.threadId)) {
|
|
670
|
-
throw new AgentRequestError("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found.`);
|
|
671
|
-
}
|
|
672
|
-
const result = await requestAgentRun(runtime, execution, models?.language, {
|
|
673
|
-
...input,
|
|
674
|
-
principal
|
|
675
|
-
});
|
|
676
|
-
return { ...result, run: await attachRunView(runtime, result.run) };
|
|
677
|
-
},
|
|
678
|
-
retry: async (runId) => {
|
|
679
|
-
const failedRun = await getVisibleRunRecord(runId);
|
|
680
|
-
if (!failedRun) {
|
|
681
|
-
throw new AgentRequestError("run_not_found", `[Sixb] Agent run '${runId}' was not found.`);
|
|
682
|
-
}
|
|
683
|
-
const agent = getAgent();
|
|
684
|
-
if (!agent) {
|
|
685
|
-
throw new AgentRequestError("agent_not_found", "[Sixb] The project Agent is unavailable.");
|
|
686
|
-
}
|
|
687
|
-
const result = await retryAgentRun(runtime, execution, models?.language, failedRun);
|
|
688
|
-
return { ...result, run: await attachRunView(runtime, result.run) };
|
|
689
|
-
},
|
|
690
|
-
getById: getRun,
|
|
691
|
-
listForThread: async (threadId, input = {}) => {
|
|
692
|
-
assertNoAgentSelector(input);
|
|
693
|
-
const storage = runtime.storage.agents;
|
|
694
|
-
if (!storage || !await getVisibleThreadRecord(threadId))
|
|
695
|
-
return null;
|
|
696
|
-
const result = await storage.runs.list({
|
|
697
|
-
...input,
|
|
698
|
-
projectId: runtime.projectId,
|
|
699
|
-
threadId
|
|
700
|
-
});
|
|
701
|
-
return {
|
|
702
|
-
...result,
|
|
703
|
-
runs: await attachRunViews(runtime, result.runs.filter((run) => run.kind === "conversation"))
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
async function attachRunView(runtime, run) {
|
|
710
|
-
const [view] = await attachRunViews(runtime, [run]);
|
|
711
|
-
if (!view)
|
|
712
|
-
throw new Error(`[Sixb] Could not build Agent run '${run.id}' view.`);
|
|
713
|
-
return view;
|
|
714
|
-
}
|
|
715
|
-
async function attachRunViews(runtime, runs) {
|
|
716
|
-
const executionIds = runs.map((run) => run.executionId);
|
|
717
|
-
const [executions, usages, costs] = await Promise.all([
|
|
718
|
-
Promise.all(runs.map((run) => runtime.storage.executions.getById({
|
|
719
|
-
projectId: runtime.projectId,
|
|
720
|
-
id: run.executionId
|
|
721
|
-
}))),
|
|
722
|
-
resolveExecutionUsage({
|
|
723
|
-
storage: runtime.storage.aiUsage,
|
|
724
|
-
projectId: runtime.projectId,
|
|
725
|
-
executionIds
|
|
726
|
-
}),
|
|
727
|
-
resolveExecutionCosts({
|
|
728
|
-
storage: runtime.storage.aiCosts,
|
|
729
|
-
projectId: runtime.projectId,
|
|
730
|
-
executionIds
|
|
731
|
-
})
|
|
732
|
-
]);
|
|
733
|
-
return runs.map((run, index) => {
|
|
734
|
-
const execution = executions[index];
|
|
735
|
-
if (!execution) {
|
|
736
|
-
throw new Error(`[Sixb] Agent run '${run.id}' references missing execution '${run.executionId}'.`);
|
|
737
|
-
}
|
|
738
|
-
const usage = usages[index];
|
|
739
|
-
const cost = usage === undefined ? undefined : costs[index];
|
|
740
|
-
return {
|
|
741
|
-
...run,
|
|
742
|
-
...execution.requestedBy === undefined ? {} : { requestedBy: structuredClone(execution.requestedBy) },
|
|
743
|
-
...usage === undefined ? {} : { usage },
|
|
744
|
-
...cost === undefined ? {} : { cost }
|
|
745
|
-
};
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// src/ai-usage/execution.ts
|
|
750
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
751
|
-
function createAiUsageRuntime(runtime, security) {
|
|
752
|
-
const assertObservable = () => assertAuthorized(runtime, { kind: "aiUsage.observe" });
|
|
753
|
-
const assertManageable = () => assertAuthorized(runtime, { kind: "aiUsage.manage" });
|
|
754
|
-
const assertPolicyReadable = () => {
|
|
755
|
-
const resolved = assertRuntimeAuthorizationBound(runtime);
|
|
756
|
-
if (resolved.type === "principal" && !isAllowed(resolved.context, { kind: "aiUsage.observe" }) && !isAllowed(resolved.context, { kind: "aiUsage.manage" })) {
|
|
757
|
-
assertObservable();
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
const requireCosts = () => {
|
|
761
|
-
if (!runtime.storage.aiCosts) {
|
|
762
|
-
throw new Error("[Sixb] AI cost storage is not configured.");
|
|
763
|
-
}
|
|
764
|
-
return runtime.storage.aiCosts;
|
|
765
|
-
};
|
|
766
|
-
const requireLimits = () => {
|
|
767
|
-
if (!runtime.storage.aiLimits) {
|
|
768
|
-
throw new Error("[Sixb] AI limit storage is not configured.");
|
|
769
|
-
}
|
|
770
|
-
return runtime.storage.aiLimits;
|
|
771
|
-
};
|
|
772
|
-
return {
|
|
773
|
-
accountingConfigured: runtime.storage.aiCosts !== undefined,
|
|
774
|
-
limitsConfigured: runtime.storage.aiLimits !== undefined,
|
|
775
|
-
assertObservable,
|
|
776
|
-
assertManageable,
|
|
777
|
-
canManageLimits: () => {
|
|
778
|
-
const resolved = assertRuntimeAuthorizationBound(runtime);
|
|
779
|
-
return resolved.type !== "principal" || isAllowed(resolved.context, { kind: "aiUsage.manage" });
|
|
780
|
-
},
|
|
781
|
-
queryOverview: (input) => {
|
|
782
|
-
assertObservable();
|
|
783
|
-
return requireCosts().queryProjectOverview({ ...input, projectId: runtime.projectId });
|
|
784
|
-
},
|
|
785
|
-
listModelCalls: (input) => {
|
|
786
|
-
assertObservable();
|
|
787
|
-
return requireCosts().listModelCalls({ ...input, projectId: runtime.projectId });
|
|
788
|
-
},
|
|
789
|
-
listModelCallGroups: (input) => {
|
|
790
|
-
assertObservable();
|
|
791
|
-
return requireCosts().listModelCallGroups({ ...input, projectId: runtime.projectId });
|
|
792
|
-
},
|
|
793
|
-
listLimitPolicies: (input = {}) => {
|
|
794
|
-
assertPolicyReadable();
|
|
795
|
-
return requireLimits().listPolicies({ ...input, projectId: runtime.projectId });
|
|
796
|
-
},
|
|
797
|
-
listLimitStatuses: (input = {}) => {
|
|
798
|
-
assertObservable();
|
|
799
|
-
return requireLimits().listPolicyStatuses({
|
|
800
|
-
...input.includeDisabled === undefined ? {} : { includeDisabled: input.includeDisabled },
|
|
801
|
-
projectId: runtime.projectId,
|
|
802
|
-
existingGroupIds: security.listGroups().map((group) => group.id)
|
|
803
|
-
});
|
|
804
|
-
},
|
|
805
|
-
listLimitSubjectOptions: async () => {
|
|
806
|
-
assertManageable();
|
|
807
|
-
const groups = security.listGroups().map((group) => ({
|
|
808
|
-
id: group.id,
|
|
809
|
-
...group.label === undefined ? {} : { label: group.label },
|
|
810
|
-
...group.description === undefined ? {} : { description: group.description }
|
|
811
|
-
}));
|
|
812
|
-
const auth = runtime.storage.auth;
|
|
813
|
-
if (!auth)
|
|
814
|
-
return { groups, users: [], serviceAccounts: [] };
|
|
815
|
-
const [users, serviceAccounts] = await Promise.all([
|
|
816
|
-
auth.users.list({ projectId: runtime.projectId, order: "asc" }),
|
|
817
|
-
auth.serviceAccounts.list({ projectId: runtime.projectId, order: "asc" })
|
|
818
|
-
]);
|
|
819
|
-
return {
|
|
820
|
-
groups,
|
|
821
|
-
users: users.users.map((user) => ({
|
|
822
|
-
id: user.id,
|
|
823
|
-
email: user.email,
|
|
824
|
-
...user.displayName === undefined ? {} : { displayName: user.displayName },
|
|
825
|
-
status: user.status
|
|
826
|
-
})),
|
|
827
|
-
serviceAccounts: serviceAccounts.serviceAccounts.map((serviceAccount) => ({
|
|
828
|
-
id: serviceAccount.id,
|
|
829
|
-
name: serviceAccount.name,
|
|
830
|
-
...serviceAccount.description === undefined ? {} : { description: serviceAccount.description },
|
|
831
|
-
status: serviceAccount.status
|
|
832
|
-
}))
|
|
833
|
-
};
|
|
834
|
-
},
|
|
835
|
-
createLimitPolicy: (input) => {
|
|
836
|
-
assertManageable();
|
|
837
|
-
return requireLimits().createPolicy({
|
|
838
|
-
...input,
|
|
839
|
-
id: input.id ?? `ailim_${randomUUID3()}`,
|
|
840
|
-
projectId: runtime.projectId
|
|
841
|
-
});
|
|
842
|
-
},
|
|
843
|
-
updateLimitPolicy: (input) => {
|
|
844
|
-
assertManageable();
|
|
845
|
-
return requireLimits().updatePolicy({ ...input, projectId: runtime.projectId });
|
|
846
|
-
},
|
|
847
|
-
deleteLimitPolicy: (id) => {
|
|
848
|
-
assertManageable();
|
|
849
|
-
return requireLimits().deletePolicy({ id, projectId: runtime.projectId });
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
// src/blob-storage/execution.ts
|
|
854
|
-
function createBlobsRuntime(runtime, execution, blobStorage) {
|
|
855
|
-
const assertAccess = () => assertProviderAccess(runtime, execution, "blobs.access");
|
|
856
|
-
const executionBlobs = {
|
|
857
|
-
put: (input) => {
|
|
858
|
-
assertAccess();
|
|
859
|
-
return blobStorage.put(input);
|
|
860
|
-
},
|
|
861
|
-
open: (blobId) => {
|
|
862
|
-
assertAccess();
|
|
863
|
-
return blobStorage.open(blobId);
|
|
864
|
-
},
|
|
865
|
-
stat: (blobId) => {
|
|
866
|
-
assertAccess();
|
|
867
|
-
return blobStorage.stat(blobId);
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
if (supportsRangeRead(blobStorage)) {
|
|
871
|
-
executionBlobs.openRange = (blobId, range) => {
|
|
872
|
-
assertAccess();
|
|
873
|
-
return blobStorage.openRange(blobId, range);
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
|
-
if (supportsDirectUpload(blobStorage)) {
|
|
877
|
-
executionBlobs.createUpload = (input) => {
|
|
878
|
-
assertAccess();
|
|
879
|
-
return blobStorage.createUpload(input);
|
|
880
|
-
};
|
|
881
|
-
executionBlobs.signUploadPart = (input) => {
|
|
882
|
-
assertAccess();
|
|
883
|
-
return blobStorage.signUploadPart(input);
|
|
884
|
-
};
|
|
885
|
-
executionBlobs.completeUpload = (input) => {
|
|
886
|
-
assertAccess();
|
|
887
|
-
return blobStorage.completeUpload(input);
|
|
888
|
-
};
|
|
889
|
-
executionBlobs.abortUpload = (input) => {
|
|
890
|
-
assertAccess();
|
|
891
|
-
return blobStorage.abortUpload(input);
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
return Object.freeze(executionBlobs);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// src/connectors/connections/execution.ts
|
|
898
|
-
function createConnectorConnectionsRuntime(runtime, execution, process) {
|
|
899
|
-
const contextFor = (connectorId) => commandContext(runtime, execution, connectorId);
|
|
900
|
-
const connections = {
|
|
901
|
-
listConnections: (connectorId) => process.listConnections(contextFor(connectorId), connectorId),
|
|
902
|
-
startConnectionRun: (connectorId, input) => process.startConnectionRun(contextFor(connectorId), connectorId, input),
|
|
903
|
-
addConnection: (connectorId, input) => process.addConnection(contextFor(connectorId), connectorId, input),
|
|
904
|
-
getConnectionRun: (connectorId, runId) => process.getConnectionRun(contextFor(connectorId), connectorId, runId),
|
|
905
|
-
selectConnectionRunAccount: (connectorId, input) => process.selectConnectionRunAccount(contextFor(connectorId), connectorId, input),
|
|
906
|
-
startReauthorization: (connectorId, connectionId, input) => process.startReauthorization(contextFor(connectorId), connectorId, connectionId, input),
|
|
907
|
-
revokeConnection: (connectorId, connectionId) => process.revokeConnection(contextFor(connectorId), connectorId, connectionId),
|
|
908
|
-
startAuthorization: (connectorId, input) => process.startAuthorization(contextFor(connectorId), connectorId, input),
|
|
909
|
-
completeAuthorization: (connectorId, input) => process.completeAuthorization(contextFor(connectorId), connectorId, input),
|
|
910
|
-
selectAccount: (connectorId, input) => process.selectAccount(contextFor(connectorId), connectorId, input),
|
|
911
|
-
disconnect: (connectorId, connectionId) => process.disconnect(contextFor(connectorId), connectorId, connectionId),
|
|
912
|
-
revokeAuthorization: (connectorId, authorizationId) => process.revokeAuthorization(contextFor(connectorId), connectorId, authorizationId)
|
|
913
|
-
};
|
|
914
|
-
return Object.freeze(connections);
|
|
915
|
-
}
|
|
916
|
-
function commandContext(runtime, execution, connectorId) {
|
|
917
|
-
const resolved = resolveExecutionScopeAuthorization(runtime.projectId, {
|
|
918
|
-
execution,
|
|
919
|
-
authorization: runtime.runtimeAuthorization
|
|
920
|
-
});
|
|
921
|
-
if (execution.executor.type !== "request" || resolved.type !== "principal" || resolved.ref.type !== "principal") {
|
|
922
|
-
throw new AuthorizationError(`manage:connector:${connectorId}`, "[Sixb] Connector connections can only be managed by an authenticated request.");
|
|
923
|
-
}
|
|
924
|
-
if (!resolved.ref.credential) {
|
|
925
|
-
throw new AuthorizationError(`manage:connector:${connectorId}`, "[Sixb] Connector connection management requires a session or access token.");
|
|
926
|
-
}
|
|
927
|
-
assertCanManageConnector(runtime, connectorId);
|
|
928
|
-
return Object.freeze({
|
|
929
|
-
execution: Object.freeze(executionRecordInputFromRuntime({
|
|
930
|
-
execution,
|
|
931
|
-
runtimeAuthorization: runtime.runtimeAuthorization
|
|
932
|
-
}))
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
// src/datasets/execution.ts
|
|
937
|
-
function createDatasetsRuntime(runtime, source) {
|
|
938
|
-
const allowed = (datasetId) => isAllowed(runtime.authorization, { kind: "dataset.view", datasetId });
|
|
939
|
-
return {
|
|
940
|
-
list: () => source.list().filter((dataset) => allowed(dataset.id)),
|
|
941
|
-
getById: (datasetId) => {
|
|
942
|
-
const dataset = source.getById(datasetId);
|
|
943
|
-
return dataset && allowed(datasetId) ? dataset : null;
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// src/events/execution.ts
|
|
949
|
-
function createEventsRuntime(runtime) {
|
|
950
|
-
return {
|
|
951
|
-
canRead: (event) => canViewEvent(runtime.authorization, event),
|
|
952
|
-
append: (input) => {
|
|
953
|
-
assertPrivileged(runtime, "events.append");
|
|
954
|
-
return runtime.events.append(input);
|
|
955
|
-
},
|
|
956
|
-
emit: (input, options) => {
|
|
957
|
-
assertPrivileged(runtime, "events.emit");
|
|
958
|
-
return runtime.events.emit(input, options);
|
|
959
|
-
},
|
|
960
|
-
read: async (input) => {
|
|
961
|
-
const events = await runtime.events.read(input);
|
|
962
|
-
return events.filter((event) => canViewEvent(runtime.authorization, event));
|
|
963
|
-
},
|
|
964
|
-
latestCursor: () => runtime.events.latestCursor(),
|
|
965
|
-
subscribe: (input, handler) => runtime.events.subscribe(input, (events) => {
|
|
966
|
-
const visible = events.filter((event) => canViewEvent(runtime.authorization, event));
|
|
967
|
-
if (visible.length > 0)
|
|
968
|
-
handler(visible);
|
|
969
|
-
})
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
// src/logging/execution.ts
|
|
974
|
-
function createLogsRuntime(runtime, source) {
|
|
975
|
-
const assertObservable = () => assertAuthorized(runtime, { kind: "logs.observe" });
|
|
976
|
-
return {
|
|
977
|
-
assertObservable,
|
|
978
|
-
read: (input) => {
|
|
979
|
-
assertObservable();
|
|
980
|
-
return source.read(input);
|
|
981
|
-
},
|
|
982
|
-
tail: (input) => {
|
|
983
|
-
assertObservable();
|
|
984
|
-
return source.tail(input);
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
// src/objects/execution.ts
|
|
990
|
-
function createObjectsRuntime(runtime, execution) {
|
|
991
|
-
const objects = Object.assign((objectType) => {
|
|
992
|
-
assertObjectTypeRegistered(runtime.ontology.getObjectTypesById(), objectType);
|
|
993
|
-
return createObjectSet({ ...runtime, execution, objectType });
|
|
994
|
-
}, {
|
|
995
|
-
listTypes: () => runtime.ontology.listObjectTypes().filter((objectType) => isAllowed(runtime.authorization, {
|
|
996
|
-
kind: "object.view",
|
|
997
|
-
objectTypeId: objectType.id
|
|
998
|
-
})),
|
|
999
|
-
getTypeById: (objectTypeId) => {
|
|
1000
|
-
const objectType = runtime.ontology.getObjectTypeById(objectTypeId);
|
|
1001
|
-
return objectType && isAllowed(runtime.authorization, { kind: "object.view", objectTypeId }) ? objectType : null;
|
|
1002
|
-
},
|
|
1003
|
-
resolveType: (objectTypeId) => {
|
|
1004
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId });
|
|
1005
|
-
return runtime.ontology.resolveObjectType(objectTypeId);
|
|
1006
|
-
},
|
|
1007
|
-
getValueTypesById: () => runtime.ontology.getValueTypesById(),
|
|
1008
|
-
listSubTypes: (objectTypeId) => runtime.ontology.listSubTypes(objectTypeId),
|
|
1009
|
-
isValidLinkTarget: (expected, actual) => runtime.ontology.isValidLinkTarget(expected, actual),
|
|
1010
|
-
executeQuery: (input) => executeObjectQuery({ projectId: runtime.projectId, ...input }, {
|
|
1011
|
-
ontology: runtime.ontology,
|
|
1012
|
-
storage: runtime.storage.objects,
|
|
1013
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1014
|
-
authorization: runtime.authorization
|
|
1015
|
-
}),
|
|
1016
|
-
queryLinks: (input) => executeObjectQueryLinks({ projectId: runtime.projectId, ...input }, {
|
|
1017
|
-
ontology: runtime.ontology,
|
|
1018
|
-
storage: runtime.storage.objects,
|
|
1019
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1020
|
-
authorization: runtime.authorization
|
|
1021
|
-
}),
|
|
1022
|
-
count: (input) => countObjects({ projectId: runtime.projectId, ...input }, {
|
|
1023
|
-
ontology: runtime.ontology,
|
|
1024
|
-
storage: runtime.storage.objects,
|
|
1025
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1026
|
-
authorization: runtime.authorization
|
|
1027
|
-
}),
|
|
1028
|
-
exists: (input) => existsObjects({ projectId: runtime.projectId, ...input }, {
|
|
1029
|
-
ontology: runtime.ontology,
|
|
1030
|
-
storage: runtime.storage.objects,
|
|
1031
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1032
|
-
authorization: runtime.authorization
|
|
1033
|
-
}),
|
|
1034
|
-
facet: (input) => facetObjects({ projectId: runtime.projectId, ...input }, {
|
|
1035
|
-
ontology: runtime.ontology,
|
|
1036
|
-
storage: runtime.storage.objects,
|
|
1037
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1038
|
-
authorization: runtime.authorization
|
|
1039
|
-
}),
|
|
1040
|
-
listLinks: async (input) => {
|
|
1041
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
|
|
1042
|
-
const links = await runtime.storage.objects.listLinks({
|
|
1043
|
-
projectId: runtime.projectId,
|
|
1044
|
-
...input
|
|
1045
|
-
});
|
|
1046
|
-
return links.filter((link) => isAllowed(runtime.authorization, {
|
|
1047
|
-
kind: "object.view",
|
|
1048
|
-
objectTypeId: link.sourceTypeId
|
|
1049
|
-
}) && isAllowed(runtime.authorization, {
|
|
1050
|
-
kind: "object.view",
|
|
1051
|
-
objectTypeId: link.targetTypeId
|
|
1052
|
-
}));
|
|
1053
|
-
},
|
|
1054
|
-
getTelemetryHistoryBatch: (input) => getTelemetryHistoryBatch({ projectId: runtime.projectId, ...input }, {
|
|
1055
|
-
storage: runtime.storage.timeseries,
|
|
1056
|
-
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
1057
|
-
authorization: runtime.authorization
|
|
1058
|
-
}),
|
|
1059
|
-
getTelemetryHistory: (input) => {
|
|
1060
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
|
|
1061
|
-
return runtime.storage.timeseries.getHistory({
|
|
1062
|
-
projectId: runtime.projectId,
|
|
1063
|
-
...input
|
|
1064
|
-
});
|
|
1065
|
-
},
|
|
1066
|
-
getLatestTelemetry: (input) => {
|
|
1067
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId: input.objectTypeId });
|
|
1068
|
-
return runtime.storage.timeseries.getLatest({
|
|
1069
|
-
projectId: runtime.projectId,
|
|
1070
|
-
...input
|
|
1071
|
-
});
|
|
1072
|
-
},
|
|
1073
|
-
list: (params) => listObjects(runtime, params),
|
|
1074
|
-
get: async (objectTypeId, primaryId) => {
|
|
1075
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId });
|
|
1076
|
-
return runtime.storage.objects.getByPrimaryId({
|
|
1077
|
-
projectId: runtime.projectId,
|
|
1078
|
-
objectTypeId,
|
|
1079
|
-
primaryId
|
|
1080
|
-
});
|
|
1081
|
-
},
|
|
1082
|
-
getPrimaryPropertyId: (objectTypeId) => {
|
|
1083
|
-
assertAuthorized(runtime, { kind: "object.view", objectTypeId });
|
|
1084
|
-
return runtime.ontology.getPrimaryPropertyId(objectTypeId);
|
|
1085
|
-
},
|
|
1086
|
-
upsert: (objectTypeId, properties) => upsertObject(runtime, objectTypeId, properties),
|
|
1087
|
-
upsertBatch: (objectTypeId, items) => upsertObjectBatch(runtime, objectTypeId, items),
|
|
1088
|
-
upsertLink: (objectTypeId, sourceId, linkId, target) => upsertLink(runtime, objectTypeId, sourceId, linkId, target),
|
|
1089
|
-
upsertLinkBatch: (items) => upsertLinkBatch(runtime, items),
|
|
1090
|
-
removeLink: (objectTypeId, sourceId, linkId, target) => removeLink(runtime, objectTypeId, sourceId, linkId, target),
|
|
1091
|
-
appendTelemetry: (objectTypeId, items) => appendTelemetry(runtime, objectTypeId, items)
|
|
1092
|
-
});
|
|
1093
|
-
return objects;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
// src/pipelines/execution.ts
|
|
1097
|
-
function createPipelinesRuntime(runtime, execution, source) {
|
|
1098
|
-
const allowed = (pipelineId) => isAllowed(runtime.authorization, { kind: "pipeline.run", pipelineId });
|
|
1099
|
-
const visibleIds = () => source.list().filter((pipeline) => allowed(pipeline.id)).map((pipeline) => pipeline.id);
|
|
1100
|
-
const getRun = async (runId) => {
|
|
1101
|
-
const run = await runtime.storage.pipelineRuns?.getById({
|
|
1102
|
-
projectId: runtime.projectId,
|
|
1103
|
-
id: runId
|
|
1104
|
-
}) ?? null;
|
|
1105
|
-
return run && canViewPipelineRun(runtime.authorization, run) ? run : null;
|
|
1106
|
-
};
|
|
1107
|
-
return {
|
|
1108
|
-
list: () => source.list().filter((pipeline) => allowed(pipeline.id)),
|
|
1109
|
-
getById: (pipelineId) => {
|
|
1110
|
-
const pipeline = source.getById(pipelineId);
|
|
1111
|
-
return pipeline && allowed(pipelineId) ? pipeline : null;
|
|
1112
|
-
},
|
|
1113
|
-
request: async (input) => {
|
|
1114
|
-
const pipeline = source.getById(input.pipelineId);
|
|
1115
|
-
if (!pipeline)
|
|
1116
|
-
throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`);
|
|
1117
|
-
return requestPipelineRun(runtime, execution, pipeline, input);
|
|
1118
|
-
},
|
|
1119
|
-
runs: {
|
|
1120
|
-
getById: getRun,
|
|
1121
|
-
list: (input = {}) => {
|
|
1122
|
-
const storage = runtime.storage.pipelineRuns;
|
|
1123
|
-
if (!storage)
|
|
1124
|
-
return Promise.resolve({ runs: [], hasMore: false, total: 0 });
|
|
1125
|
-
return storage.list({
|
|
1126
|
-
projectId: runtime.projectId,
|
|
1127
|
-
...input,
|
|
1128
|
-
pipelineIds: runtime.authorization ? visibleIds() : undefined
|
|
1129
|
-
});
|
|
1130
|
-
},
|
|
1131
|
-
listLatest: (pipelineIds) => {
|
|
1132
|
-
const storage = runtime.storage.pipelineRuns;
|
|
1133
|
-
if (!storage || pipelineIds.length === 0)
|
|
1134
|
-
return Promise.resolve({ runs: [] });
|
|
1135
|
-
const allowedIds = pipelineIds.filter(allowed);
|
|
1136
|
-
return allowedIds.length === 0 ? Promise.resolve({ runs: [] }) : storage.listLatestByPipelineIds({
|
|
1137
|
-
projectId: runtime.projectId,
|
|
1138
|
-
pipelineIds: allowedIds
|
|
1139
|
-
});
|
|
1140
|
-
},
|
|
1141
|
-
listSteps: async (runId, input = {}) => {
|
|
1142
|
-
const storage = runtime.storage.pipelineRuns;
|
|
1143
|
-
if (!storage || !await getRun(runId))
|
|
1144
|
-
return null;
|
|
1145
|
-
return storage.listSteps({
|
|
1146
|
-
projectId: runtime.projectId,
|
|
1147
|
-
...input,
|
|
1148
|
-
pipelineRunId: runId
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
// src/projections/execution.ts
|
|
1156
|
-
function createProjectionsRuntime(runtime, source) {
|
|
1157
|
-
const visible = (projection) => canViewProjection(runtime.authorization, projection);
|
|
1158
|
-
const visibleIds = (projectionIds) => projectionIds.filter((projectionId) => {
|
|
1159
|
-
const projection = source.getById(projectionId);
|
|
1160
|
-
return projection !== null && visible(projection);
|
|
1161
|
-
});
|
|
1162
|
-
return {
|
|
1163
|
-
list: () => source.list().filter(visible),
|
|
1164
|
-
listObjects: () => source.listObjects().filter(visible),
|
|
1165
|
-
listLinks: () => source.listLinks().filter(visible),
|
|
1166
|
-
listTelemetry: () => source.listTelemetry().filter(visible),
|
|
1167
|
-
getById: (projectionId) => {
|
|
1168
|
-
const projection = source.getById(projectionId);
|
|
1169
|
-
return projection && visible(projection) ? projection : null;
|
|
1170
|
-
},
|
|
1171
|
-
runs: {
|
|
1172
|
-
getById: async (runId) => {
|
|
1173
|
-
const run = await runtime.storage.projectionRuns?.getById({
|
|
1174
|
-
projectId: runtime.projectId,
|
|
1175
|
-
id: runId
|
|
1176
|
-
}) ?? null;
|
|
1177
|
-
return run && canViewProjectionRun(runtime.authorization, run.target) ? run : null;
|
|
1178
|
-
},
|
|
1179
|
-
list: (input = {}) => {
|
|
1180
|
-
const storage = runtime.storage.projectionRuns;
|
|
1181
|
-
if (!storage)
|
|
1182
|
-
return Promise.resolve({ runs: [], hasMore: false, total: 0 });
|
|
1183
|
-
return storage.list({
|
|
1184
|
-
projectId: runtime.projectId,
|
|
1185
|
-
...input,
|
|
1186
|
-
objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
|
|
1187
|
-
});
|
|
1188
|
-
},
|
|
1189
|
-
listLatest: (projectionIds) => {
|
|
1190
|
-
const storage = runtime.storage.projectionRuns;
|
|
1191
|
-
if (!storage || projectionIds.length === 0)
|
|
1192
|
-
return Promise.resolve({ runs: [] });
|
|
1193
|
-
const ids = visibleIds(projectionIds);
|
|
1194
|
-
return ids.length === 0 ? Promise.resolve({ runs: [] }) : storage.listLatestByProjectionIds({ projectId: runtime.projectId, projectionIds: ids });
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
// src/rules/execution.ts
|
|
1201
|
-
function createRulesRuntime(runtime, source) {
|
|
1202
|
-
const visible = (rule) => isAllowed(runtime.authorization, {
|
|
1203
|
-
kind: "object.view",
|
|
1204
|
-
objectTypeId: rule.subject.objectTypeId
|
|
1205
|
-
});
|
|
1206
|
-
return {
|
|
1207
|
-
list: () => source.list().filter(visible),
|
|
1208
|
-
getById: (ruleId) => {
|
|
1209
|
-
const rule = source.getById(ruleId);
|
|
1210
|
-
return rule && visible(rule) ? rule : null;
|
|
1211
|
-
},
|
|
1212
|
-
states: {
|
|
1213
|
-
list: (input = {}) => {
|
|
1214
|
-
const storage = runtime.storage.rules;
|
|
1215
|
-
if (!storage)
|
|
1216
|
-
return Promise.resolve({ states: [], hasMore: false, total: 0 });
|
|
1217
|
-
return storage.listActive({
|
|
1218
|
-
projectId: runtime.projectId,
|
|
1219
|
-
...input,
|
|
1220
|
-
objectTypeIds: runtime.authorization ? [...runtime.authorization.grants["view:object"]] : undefined
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
// src/schedules/execution.ts
|
|
1228
|
-
function createSchedulesRuntime(schedules) {
|
|
1229
|
-
return {
|
|
1230
|
-
list: () => schedules.list(),
|
|
1231
|
-
getById: (scheduleId) => schedules.getById(scheduleId)
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
// src/syncs/execution.ts
|
|
1236
|
-
function createSyncsRuntime(runtime, execution, source) {
|
|
1237
|
-
const allowed = (syncId) => isAllowed(runtime.authorization, { kind: "sync.run", syncId });
|
|
1238
|
-
const visibleIds = () => source.list().filter((sync) => allowed(sync.id)).map((sync) => sync.id);
|
|
1239
|
-
return {
|
|
1240
|
-
list: () => source.list().filter((sync) => allowed(sync.id)),
|
|
1241
|
-
getById: (syncId) => {
|
|
1242
|
-
const sync = source.getById(syncId);
|
|
1243
|
-
return sync && allowed(syncId) ? sync : null;
|
|
1244
|
-
},
|
|
1245
|
-
request: async (input) => {
|
|
1246
|
-
const sync = source.getById(input.syncId);
|
|
1247
|
-
if (!sync)
|
|
1248
|
-
throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`);
|
|
1249
|
-
return requestSyncRun(runtime, execution, sync, input);
|
|
1250
|
-
},
|
|
1251
|
-
runs: {
|
|
1252
|
-
getById: async (runId) => {
|
|
1253
|
-
const run = await runtime.storage.syncRuns?.getById({
|
|
1254
|
-
projectId: runtime.projectId,
|
|
1255
|
-
id: runId
|
|
1256
|
-
}) ?? null;
|
|
1257
|
-
return run && allowed(run.syncId) ? run : null;
|
|
1258
|
-
},
|
|
1259
|
-
list: (input = {}) => {
|
|
1260
|
-
const storage = runtime.storage.syncRuns;
|
|
1261
|
-
if (!storage)
|
|
1262
|
-
return Promise.resolve({ runs: [], hasMore: false, total: 0 });
|
|
1263
|
-
return storage.list({
|
|
1264
|
-
projectId: runtime.projectId,
|
|
1265
|
-
...input,
|
|
1266
|
-
syncIds: runtime.authorization ? visibleIds() : undefined
|
|
1267
|
-
});
|
|
1268
|
-
},
|
|
1269
|
-
listLatest: (syncIds) => {
|
|
1270
|
-
const storage = runtime.storage.syncRuns;
|
|
1271
|
-
if (!storage || syncIds.length === 0)
|
|
1272
|
-
return Promise.resolve({ runs: [] });
|
|
1273
|
-
const allowedIds = syncIds.filter(allowed);
|
|
1274
|
-
return allowedIds.length === 0 ? Promise.resolve({ runs: [] }) : storage.listLatestBySyncIds({ projectId: runtime.projectId, syncIds: allowedIds });
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// src/workflows/errors.ts
|
|
1281
|
-
class WorkflowDefinitionError extends Error {
|
|
1282
|
-
name = "WorkflowDefinitionError";
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
class WorkflowValidationError extends Error {
|
|
1286
|
-
name = "WorkflowValidationError";
|
|
1287
|
-
cause;
|
|
1288
|
-
constructor(message, options) {
|
|
1289
|
-
super(message);
|
|
1290
|
-
this.cause = options?.cause;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
// src/workflows/run-dispatch.ts
|
|
1295
|
-
import { randomUUID as randomUUID4 } from "crypto";
|
|
1296
|
-
import { isDeepStrictEqual } from "util";
|
|
1297
|
-
|
|
1298
|
-
// src/workflows/validation.ts
|
|
1299
|
-
function assertNonEmpty(value, subject, field) {
|
|
1300
|
-
if (!value.trim()) {
|
|
1301
|
-
throw new WorkflowDefinitionError(`${subject} ${field} must not be empty.`);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function isStepDefinition(value) {
|
|
1305
|
-
return isRecord(value) && value.kind === "step" && typeof value.id === "string" && isRecord(value.input) && isRecord(value.output) && typeof value.handler === "function";
|
|
1306
|
-
}
|
|
1307
|
-
function isAgentStepDefinition(value) {
|
|
1308
|
-
return isRecord(value) && value.kind === "agentStep" && typeof value.id === "string" && (value.model === undefined || isLanguageModel(value.model)) && (value.reasoning === undefined || isModelReasoning(value.reasoning)) && typeof value.instructions === "string" && isStringArray(value.groupIds) && isStringArray(value.toolNames) && isRecord(value.input) && isRecord(value.output) && typeof value.prompt === "function";
|
|
1309
|
-
}
|
|
1310
|
-
function isInterventionDefinition(value) {
|
|
1311
|
-
return isRecord(value) && value.kind === "intervention" && typeof value.id === "string" && isRecord(value.input) && isRecord(value.response) && (value.defaults === undefined || typeof value.defaults === "function");
|
|
1312
|
-
}
|
|
1313
|
-
function isWorkflowDefinition(value) {
|
|
1314
|
-
return isRecord(value) && value.kind === "workflow" && typeof value.id === "string" && isRecord(value.input) && Array.isArray(value.triggers) && Array.isArray(value.nodes);
|
|
1315
|
-
}
|
|
1316
|
-
function validateWorkflowDefinition(value) {
|
|
1317
|
-
if (!isWorkflowDefinition(value)) {
|
|
1318
|
-
throw new WorkflowDefinitionError("Invalid workflow definition.");
|
|
1319
|
-
}
|
|
1320
|
-
assertNonEmpty(value.id, "Workflow", "id");
|
|
1321
|
-
if (value.nodes.length === 0) {
|
|
1322
|
-
throw new WorkflowDefinitionError(`Workflow "${value.id}" must contain at least one node.`);
|
|
1323
|
-
}
|
|
1324
|
-
const nodeIds = new Set;
|
|
1325
|
-
const nodeKeys = new Set;
|
|
1326
|
-
for (const node of value.nodes) {
|
|
1327
|
-
validateWorkflowNodeDefinition(value.id, node);
|
|
1328
|
-
if (nodeIds.has(node.id)) {
|
|
1329
|
-
throw new WorkflowDefinitionError(`Duplicate workflow node id "${node.id}" in workflow "${value.id}".`);
|
|
1330
|
-
}
|
|
1331
|
-
nodeIds.add(node.id);
|
|
1332
|
-
if (nodeKeys.has(node.key)) {
|
|
1333
|
-
throw new WorkflowDefinitionError(`Duplicate workflow node key "${node.key}" in workflow "${value.id}".`);
|
|
1334
|
-
}
|
|
1335
|
-
nodeKeys.add(node.key);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
function validateWorkflowsAtStartup(options) {
|
|
1339
|
-
for (const workflow of options.workflows) {
|
|
1340
|
-
validateWorkflowDefinition(workflow);
|
|
1341
|
-
for (const trigger of workflow.triggers) {
|
|
1342
|
-
validateWorkflowTriggerAtStartup(workflow.id, trigger, options.registeredSchedules, Object.keys(workflow.input));
|
|
1343
|
-
}
|
|
1344
|
-
for (const node of workflow.nodes) {
|
|
1345
|
-
if (node.type === "action" && !options.registeredActionIds.has(node.action.id)) {
|
|
1346
|
-
throw new WorkflowDefinitionError(`Workflow "${workflow.id}" references unknown action "${node.action.id}". Add it to 'actions' in createSixb() or export it from 'actions/'.`);
|
|
1347
|
-
}
|
|
1348
|
-
if (node.type === "agent") {
|
|
1349
|
-
validateWorkflowAgentStepRuntimeReferences(workflow.id, node.agentStep, options);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
return options.workflows;
|
|
1354
|
-
}
|
|
1355
|
-
function validateWorkflowAgentStepGroupReferences(workflows, security) {
|
|
1356
|
-
for (const workflow of workflows) {
|
|
1357
|
-
for (const node of workflow.nodes) {
|
|
1358
|
-
if (node.type !== "agent")
|
|
1359
|
-
continue;
|
|
1360
|
-
for (const groupId of node.agentStep.groupIds) {
|
|
1361
|
-
if (!security.getGroupById(groupId)) {
|
|
1362
|
-
throw new WorkflowDefinitionError(`Workflow "${workflow.id}" agent step "${node.id}" references unknown group "${groupId}". Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
function validateWorkflowAgentStepRuntimeReferences(workflowId, step, options) {
|
|
1369
|
-
if (step.model === undefined && options.models === undefined) {
|
|
1370
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${step.id}" needs a model. Configure 'models.language' or pass 'model' to defineAgentStep().`);
|
|
1371
|
-
}
|
|
1372
|
-
if (step.model !== undefined && options.models !== undefined) {
|
|
1373
|
-
const ref = { provider: step.model.providerId, modelId: step.model.modelId };
|
|
1374
|
-
if (options.models.language.getByRef(ref) === null) {
|
|
1375
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${step.id}" uses unknown language model "${ref.provider}/${ref.modelId}". Add it to 'models.language' in createSixb().`);
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
for (const toolName of step.toolNames) {
|
|
1379
|
-
if (options.tools.getByName(toolName) === null) {
|
|
1380
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${step.id}" uses unknown project tool "${toolName}". Add it to 'tools' in createSixb().`);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
function validateWorkflowInput(params) {
|
|
1385
|
-
return validateWorkflowContractRecord({
|
|
1386
|
-
shape: params.workflow.input,
|
|
1387
|
-
value: params.value,
|
|
1388
|
-
path: `Workflow "${params.workflow.id}" input`,
|
|
1389
|
-
valueTypesById: params.valueTypesById
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
function validateWorkflowStepInput(params) {
|
|
1393
|
-
return validateWorkflowContractRecord({
|
|
1394
|
-
shape: params.step.input,
|
|
1395
|
-
value: params.value,
|
|
1396
|
-
path: `Workflow "${params.workflowId}" step "${params.step.id}" input`,
|
|
1397
|
-
valueTypesById: params.valueTypesById
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
function validateWorkflowStepOutput(params) {
|
|
1401
|
-
return validateWorkflowContractRecord({
|
|
1402
|
-
shape: params.step.output,
|
|
1403
|
-
value: params.value,
|
|
1404
|
-
path: `Workflow "${params.workflowId}" step "${params.step.id}" output`,
|
|
1405
|
-
valueTypesById: params.valueTypesById
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
function validateWorkflowInterventionInput(params) {
|
|
1409
|
-
return validateWorkflowContractRecord({
|
|
1410
|
-
shape: params.intervention.input,
|
|
1411
|
-
value: params.value,
|
|
1412
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" input`,
|
|
1413
|
-
valueTypesById: params.valueTypesById
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
|
-
function validateWorkflowInterventionResponse(params) {
|
|
1417
|
-
return validateWorkflowInterventionResponseRecord({
|
|
1418
|
-
response: params.intervention.response,
|
|
1419
|
-
value: params.value,
|
|
1420
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" response`,
|
|
1421
|
-
partial: false,
|
|
1422
|
-
valueTypesById: params.valueTypesById
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
function validateWorkflowInterventionDefaultResponse(params) {
|
|
1426
|
-
return validateWorkflowInterventionResponseRecord({
|
|
1427
|
-
response: params.intervention.response,
|
|
1428
|
-
value: params.value,
|
|
1429
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" defaultResponse`,
|
|
1430
|
-
partial: true,
|
|
1431
|
-
valueTypesById: params.valueTypesById
|
|
1432
|
-
});
|
|
1433
|
-
}
|
|
1434
|
-
function validateWorkflowTriggerAtStartup(workflowId, trigger, registeredSchedules, inputFields) {
|
|
1435
|
-
if (!isRecord(trigger) || trigger.type !== "schedule") {
|
|
1436
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an unsupported trigger.`);
|
|
1437
|
-
}
|
|
1438
|
-
validateScheduleWorkflowTrigger(workflowId, trigger, registeredSchedules, inputFields);
|
|
1439
|
-
}
|
|
1440
|
-
function validateScheduleWorkflowTrigger(workflowId, trigger, registeredSchedules, inputFields) {
|
|
1441
|
-
if (typeof trigger.scheduleId !== "string" || !trigger.scheduleId.trim()) {
|
|
1442
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains a schedule trigger with an empty schedule id.`);
|
|
1443
|
-
}
|
|
1444
|
-
const schedule = registeredSchedules.get(trigger.scheduleId);
|
|
1445
|
-
if (!schedule) {
|
|
1446
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" references unknown schedule "${trigger.scheduleId}". Add it to 'schedules' in createSixb() or export it from 'schedules/'.`);
|
|
1447
|
-
}
|
|
1448
|
-
if (trigger.mapper !== undefined && typeof trigger.mapper !== "function") {
|
|
1449
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" schedule "${trigger.scheduleId}" mapper must be a function.`);
|
|
1450
|
-
}
|
|
1451
|
-
if (trigger.mapper !== undefined && schedule.trigger.type !== "event") {
|
|
1452
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" cron schedule "${trigger.scheduleId}" does not accept a mapper.`);
|
|
1453
|
-
}
|
|
1454
|
-
if (trigger.mapper === undefined && inputFields.length > 0) {
|
|
1455
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" schedule "${trigger.scheduleId}" requires a mapper because workflow input is not empty: ${inputFields.join(", ")}.`);
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
function validateWorkflowNodeDefinition(workflowId, node) {
|
|
1459
|
-
if (!isRecord(node)) {
|
|
1460
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an invalid node.`);
|
|
1461
|
-
}
|
|
1462
|
-
if (node.type === "step") {
|
|
1463
|
-
validateStepNodeDefinition(workflowId, node);
|
|
1464
|
-
return;
|
|
1465
|
-
}
|
|
1466
|
-
if (node.type === "agent") {
|
|
1467
|
-
validateAgentNodeDefinition(workflowId, node);
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
1470
|
-
if (node.type === "intervention") {
|
|
1471
|
-
validateInterventionNodeDefinition(workflowId, node);
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
if (node.type === "action") {
|
|
1475
|
-
validateActionNodeDefinition(workflowId, node);
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an unsupported node type.`);
|
|
1479
|
-
}
|
|
1480
|
-
function validateAgentNodeDefinition(workflowId, node) {
|
|
1481
|
-
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
1482
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an agent step with an empty id.`);
|
|
1483
|
-
}
|
|
1484
|
-
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
1485
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains agent step "${node.id}" with an empty derived key.`);
|
|
1486
|
-
}
|
|
1487
|
-
if (!isAgentStepDefinition(node.agentStep)) {
|
|
1488
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an invalid agent node "${node.id}".`);
|
|
1489
|
-
}
|
|
1490
|
-
if (node.id !== node.agentStep.id) {
|
|
1491
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent node id "${node.id}" does not match agent step definition id "${node.agentStep.id}".`);
|
|
1492
|
-
}
|
|
1493
|
-
if (!node.agentStep.instructions.trim()) {
|
|
1494
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${node.id}" instructions must not be empty.`);
|
|
1495
|
-
}
|
|
1496
|
-
assertUniqueNonEmptyAgentStepValues(workflowId, node.id, "group", node.agentStep.groupIds);
|
|
1497
|
-
assertUniqueNonEmptyAgentStepValues(workflowId, node.id, "tool", node.agentStep.toolNames);
|
|
1498
|
-
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
1499
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent node "${node.id}" mapper must be a function.`);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
function assertUniqueNonEmptyAgentStepValues(workflowId, stepId, kind, values) {
|
|
1503
|
-
const seen = new Set;
|
|
1504
|
-
for (const value of values) {
|
|
1505
|
-
if (!value.trim()) {
|
|
1506
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${stepId}" has an empty ${kind} id.`);
|
|
1507
|
-
}
|
|
1508
|
-
if (seen.has(value)) {
|
|
1509
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" agent step "${stepId}" has duplicate ${kind} '${value}'.`);
|
|
1510
|
-
}
|
|
1511
|
-
seen.add(value);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
function isLanguageModel(value) {
|
|
1515
|
-
return (typeof value === "object" || typeof value === "function") && value !== null;
|
|
1516
|
-
}
|
|
1517
|
-
function isStringArray(value) {
|
|
1518
|
-
if (!Array.isArray(value))
|
|
1519
|
-
return false;
|
|
1520
|
-
for (let index = 0;index < value.length; index += 1) {
|
|
1521
|
-
if (!Object.hasOwn(value, index) || typeof value[index] !== "string")
|
|
1522
|
-
return false;
|
|
1523
|
-
}
|
|
1524
|
-
return true;
|
|
1525
|
-
}
|
|
1526
|
-
function validateWorkflowAgentStepInput(params) {
|
|
1527
|
-
return validateWorkflowContractRecord({
|
|
1528
|
-
shape: params.agentStep.input,
|
|
1529
|
-
value: params.value,
|
|
1530
|
-
path: `Workflow "${params.workflowId}" agent step "${params.agentStep.id}" input`,
|
|
1531
|
-
valueTypesById: params.valueTypesById
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
function validateWorkflowAgentStepOutput(params) {
|
|
1535
|
-
return validateWorkflowContractRecord({
|
|
1536
|
-
shape: params.agentStep.output,
|
|
1537
|
-
value: params.value,
|
|
1538
|
-
path: `Workflow "${params.workflowId}" agent step "${params.agentStep.id}" output`,
|
|
1539
|
-
valueTypesById: params.valueTypesById
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
function validateStepNodeDefinition(workflowId, node) {
|
|
1543
|
-
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
1544
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains a step with an empty id.`);
|
|
1545
|
-
}
|
|
1546
|
-
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
1547
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains step "${node.id}" with an empty derived key.`);
|
|
1548
|
-
}
|
|
1549
|
-
if (!isStepDefinition(node.step)) {
|
|
1550
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an invalid step node "${node.id}".`);
|
|
1551
|
-
}
|
|
1552
|
-
if (node.id !== node.step.id) {
|
|
1553
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" step node id "${node.id}" does not match step definition id "${node.step.id}".`);
|
|
1554
|
-
}
|
|
1555
|
-
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
1556
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" step node "${node.id}" mapper must be a function.`);
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
function validateInterventionNodeDefinition(workflowId, node) {
|
|
1560
|
-
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
1561
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an intervention with an empty id.`);
|
|
1562
|
-
}
|
|
1563
|
-
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
1564
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains intervention "${node.id}" with an empty derived key.`);
|
|
1565
|
-
}
|
|
1566
|
-
if (!isInterventionDefinition(node.intervention)) {
|
|
1567
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an invalid intervention node "${node.id}".`);
|
|
1568
|
-
}
|
|
1569
|
-
if (node.id !== node.intervention.id) {
|
|
1570
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" intervention node id "${node.id}" does not match intervention definition id "${node.intervention.id}".`);
|
|
1571
|
-
}
|
|
1572
|
-
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
1573
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" intervention node "${node.id}" mapper must be a function.`);
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
function validateActionNodeDefinition(workflowId, node) {
|
|
1577
|
-
if (typeof node.id !== "string" || !node.id.trim()) {
|
|
1578
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an action with an empty id.`);
|
|
1579
|
-
}
|
|
1580
|
-
if (typeof node.key !== "string" || !node.key.trim()) {
|
|
1581
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains action "${node.id}" with an empty derived key.`);
|
|
1582
|
-
}
|
|
1583
|
-
if (!isActionDefinition(node.action)) {
|
|
1584
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" contains an invalid action node "${node.id}".`);
|
|
1585
|
-
}
|
|
1586
|
-
if (node.id !== node.action.id) {
|
|
1587
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" action node id "${node.id}" does not match action definition id "${node.action.id}".`);
|
|
1588
|
-
}
|
|
1589
|
-
if (node.mapper !== undefined && typeof node.mapper !== "function") {
|
|
1590
|
-
throw new WorkflowDefinitionError(`Workflow "${workflowId}" action node "${node.id}" mapper must be a function.`);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
function validateWorkflowContractRecord(params) {
|
|
1594
|
-
if (!isRecord(params.value)) {
|
|
1595
|
-
throw new WorkflowValidationError(`[Sixb] ${params.path} must be an object`);
|
|
1596
|
-
}
|
|
1597
|
-
const fieldIds = new Set(Object.keys(params.shape));
|
|
1598
|
-
for (const fieldId of Object.keys(params.value)) {
|
|
1599
|
-
if (!fieldIds.has(fieldId)) {
|
|
1600
|
-
throw new WorkflowValidationError(`[Sixb] Unknown field '${params.path}.${fieldId}'`);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
for (const [fieldId, schema] of Object.entries(params.shape)) {
|
|
1604
|
-
const fieldValue = params.value[fieldId];
|
|
1605
|
-
if (fieldValue === undefined) {
|
|
1606
|
-
throw new WorkflowValidationError(`[Sixb] Missing required field '${params.path}.${fieldId}'`);
|
|
1607
|
-
}
|
|
1608
|
-
try {
|
|
1609
|
-
validateSchemaOrRefValue(schema, fieldValue, `${params.path}.${fieldId}`, params.valueTypesById);
|
|
1610
|
-
} catch (error) {
|
|
1611
|
-
throw toWorkflowValidationError(error);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
return params.value;
|
|
1615
|
-
}
|
|
1616
|
-
function validateWorkflowInterventionResponseRecord(params) {
|
|
1617
|
-
if (!isRecord(params.value)) {
|
|
1618
|
-
throw new WorkflowValidationError(`[Sixb] ${params.path} must be an object`);
|
|
1619
|
-
}
|
|
1620
|
-
const fieldIds = new Set(Object.keys(params.response));
|
|
1621
|
-
for (const fieldId of Object.keys(params.value)) {
|
|
1622
|
-
if (!fieldIds.has(fieldId)) {
|
|
1623
|
-
throw new WorkflowValidationError(`[Sixb] Unknown field '${params.path}.${fieldId}'`);
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
for (const [fieldId, field] of Object.entries(params.response)) {
|
|
1627
|
-
const fieldValue = params.value[fieldId];
|
|
1628
|
-
if (fieldValue === undefined) {
|
|
1629
|
-
if (!params.partial && isInterventionResponseFieldRequired(field)) {
|
|
1630
|
-
throw new WorkflowValidationError(`[Sixb] Missing required field '${params.path}.${fieldId}'`);
|
|
1631
|
-
}
|
|
1632
|
-
continue;
|
|
1633
|
-
}
|
|
1634
|
-
try {
|
|
1635
|
-
validateSchemaOrRefValue(interventionResponseFieldSchema(field), fieldValue, `${params.path}.${fieldId}`, params.valueTypesById);
|
|
1636
|
-
} catch (error) {
|
|
1637
|
-
throw toWorkflowValidationError(error);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
return params.value;
|
|
1641
|
-
}
|
|
1642
|
-
function isInterventionFieldConfig(value) {
|
|
1643
|
-
return isRecord(value) && "schema" in value;
|
|
1644
|
-
}
|
|
1645
|
-
function interventionResponseFieldSchema(field) {
|
|
1646
|
-
return isInterventionFieldConfig(field) ? field.schema : field;
|
|
1647
|
-
}
|
|
1648
|
-
function isInterventionResponseFieldRequired(field) {
|
|
1649
|
-
return !isInterventionFieldConfig(field) || field.required !== false;
|
|
1650
|
-
}
|
|
1651
|
-
function toWorkflowValidationError(error) {
|
|
1652
|
-
if (error instanceof WorkflowValidationError) {
|
|
1653
|
-
return error;
|
|
1654
|
-
}
|
|
1655
|
-
if (error instanceof Error) {
|
|
1656
|
-
return new WorkflowValidationError(error.message, { cause: error });
|
|
1657
|
-
}
|
|
1658
|
-
return new WorkflowValidationError(String(error), { cause: error });
|
|
1659
|
-
}
|
|
1660
|
-
function isRecord(value) {
|
|
1661
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
// src/workflows/snapshot.ts
|
|
1665
|
-
function snapshotWorkflowAgentStepInput(params) {
|
|
1666
|
-
const value = validateWorkflowAgentStepInput(params);
|
|
1667
|
-
return snapshotWorkflowContractRecord({
|
|
1668
|
-
shape: params.agentStep.input,
|
|
1669
|
-
value,
|
|
1670
|
-
path: `Workflow "${params.workflowId}" agent step "${params.agentStep.id}" input`,
|
|
1671
|
-
valueTypesById: params.valueTypesById
|
|
1672
|
-
});
|
|
1673
|
-
}
|
|
1674
|
-
function snapshotWorkflowAgentStepOutput(params) {
|
|
1675
|
-
const value = validateWorkflowAgentStepOutput(params);
|
|
1676
|
-
return snapshotWorkflowContractRecord({
|
|
1677
|
-
shape: params.agentStep.output,
|
|
1678
|
-
value,
|
|
1679
|
-
path: `Workflow "${params.workflowId}" agent step "${params.agentStep.id}" output`,
|
|
1680
|
-
valueTypesById: params.valueTypesById
|
|
1681
|
-
});
|
|
1682
|
-
}
|
|
1683
|
-
function snapshotWorkflowInput(params) {
|
|
1684
|
-
const value = validateWorkflowInput(params);
|
|
1685
|
-
return snapshotWorkflowContractRecord({
|
|
1686
|
-
shape: params.workflow.input,
|
|
1687
|
-
value,
|
|
1688
|
-
path: `Workflow "${params.workflow.id}" input`,
|
|
1689
|
-
valueTypesById: params.valueTypesById
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
function snapshotWorkflowStepInput(params) {
|
|
1693
|
-
const value = validateWorkflowStepInput(params);
|
|
1694
|
-
return snapshotWorkflowContractRecord({
|
|
1695
|
-
shape: params.step.input,
|
|
1696
|
-
value,
|
|
1697
|
-
path: `Workflow "${params.workflowId}" step "${params.step.id}" input`,
|
|
1698
|
-
valueTypesById: params.valueTypesById
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
function snapshotWorkflowStepOutput(params) {
|
|
1702
|
-
const value = validateWorkflowStepOutput(params);
|
|
1703
|
-
return snapshotWorkflowContractRecord({
|
|
1704
|
-
shape: params.step.output,
|
|
1705
|
-
value,
|
|
1706
|
-
path: `Workflow "${params.workflowId}" step "${params.step.id}" output`,
|
|
1707
|
-
valueTypesById: params.valueTypesById
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
function snapshotWorkflowInterventionInput(params) {
|
|
1711
|
-
const value = validateWorkflowInterventionInput(params);
|
|
1712
|
-
return snapshotWorkflowContractRecord({
|
|
1713
|
-
shape: params.intervention.input,
|
|
1714
|
-
value,
|
|
1715
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" input`,
|
|
1716
|
-
valueTypesById: params.valueTypesById
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1719
|
-
function snapshotWorkflowInterventionResponse(params) {
|
|
1720
|
-
const value = validateWorkflowInterventionResponse(params);
|
|
1721
|
-
return snapshotWorkflowInterventionResponseRecord({
|
|
1722
|
-
response: params.intervention.response,
|
|
1723
|
-
value,
|
|
1724
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" response`,
|
|
1725
|
-
valueTypesById: params.valueTypesById
|
|
1726
|
-
});
|
|
1727
|
-
}
|
|
1728
|
-
function snapshotWorkflowInterventionDefaultResponse(params) {
|
|
1729
|
-
const value = validateWorkflowInterventionDefaultResponse(params);
|
|
1730
|
-
return snapshotWorkflowInterventionResponseRecord({
|
|
1731
|
-
response: params.intervention.response,
|
|
1732
|
-
value,
|
|
1733
|
-
path: `Workflow "${params.workflowId}" intervention "${params.intervention.id}" defaultResponse`,
|
|
1734
|
-
valueTypesById: params.valueTypesById
|
|
1735
|
-
});
|
|
1736
|
-
}
|
|
1737
|
-
function snapshotWorkflowActionInput(params) {
|
|
1738
|
-
const snapshot = {
|
|
1739
|
-
params: snapshotJsonValue(params.params, "Workflow action params")
|
|
1740
|
-
};
|
|
1741
|
-
if (params.subject && params.subject.kind !== "none") {
|
|
1742
|
-
snapshot.subject = snapshotJsonValue(params.subject, "Workflow action subject");
|
|
1743
|
-
}
|
|
1744
|
-
return snapshot;
|
|
1745
|
-
}
|
|
1746
|
-
function snapshotWorkflowContractRecord(params) {
|
|
1747
|
-
const snapshot = {};
|
|
1748
|
-
for (const [fieldId, schema] of Object.entries(params.shape)) {
|
|
1749
|
-
snapshot[fieldId] = snapshotSchemaOrRefValue({
|
|
1750
|
-
schema,
|
|
1751
|
-
value: params.value[fieldId],
|
|
1752
|
-
path: `${params.path}.${fieldId}`,
|
|
1753
|
-
valueTypesById: params.valueTypesById
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
return snapshot;
|
|
1757
|
-
}
|
|
1758
|
-
function snapshotWorkflowInterventionResponseRecord(params) {
|
|
1759
|
-
const snapshot = {};
|
|
1760
|
-
for (const [fieldId, value] of Object.entries(params.value)) {
|
|
1761
|
-
if (value === undefined) {
|
|
1762
|
-
continue;
|
|
1763
|
-
}
|
|
1764
|
-
snapshot[fieldId] = snapshotSchemaOrRefValue({
|
|
1765
|
-
schema: interventionResponseFieldSchema(params.response[fieldId]),
|
|
1766
|
-
value,
|
|
1767
|
-
path: `${params.path}.${fieldId}`,
|
|
1768
|
-
valueTypesById: params.valueTypesById
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
return snapshot;
|
|
1772
|
-
}
|
|
1773
|
-
function snapshotSchemaOrRefValue(params) {
|
|
1774
|
-
if (isObjectRefSchema(params.schema)) {
|
|
1775
|
-
if (!isRecord2(params.value)) {
|
|
1776
|
-
throw cannotSerialize(params.path);
|
|
1777
|
-
}
|
|
1778
|
-
return {
|
|
1779
|
-
objectTypeId: String(params.value.objectTypeId),
|
|
1780
|
-
primaryId: String(params.value.primaryId)
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
return snapshotSchemaValue({
|
|
1784
|
-
schema: params.schema,
|
|
1785
|
-
value: params.value,
|
|
1786
|
-
path: params.path,
|
|
1787
|
-
valueTypesById: params.valueTypesById
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
function snapshotSchemaValue(params) {
|
|
1791
|
-
const { schema, value, path, valueTypesById } = params;
|
|
1792
|
-
if (typeof schema === "string") {
|
|
1793
|
-
if (schema === "date" || schema === "timestamp") {
|
|
1794
|
-
if (value instanceof Date) {
|
|
1795
|
-
return snapshotDate(value, path);
|
|
1796
|
-
}
|
|
1797
|
-
return snapshotJsonValue(value, path);
|
|
1798
|
-
}
|
|
1799
|
-
return snapshotJsonValue(value, path);
|
|
1800
|
-
}
|
|
1801
|
-
if (schema.type === "enum") {
|
|
1802
|
-
return snapshotJsonValue(value, path);
|
|
1803
|
-
}
|
|
1804
|
-
if (schema.type === "array") {
|
|
1805
|
-
if (!Array.isArray(value)) {
|
|
1806
|
-
throw cannotSerialize(path);
|
|
1807
|
-
}
|
|
1808
|
-
return value.map((item, index) => snapshotSchemaValue({
|
|
1809
|
-
schema: schema.items,
|
|
1810
|
-
value: item,
|
|
1811
|
-
path: `${path}[${index}]`,
|
|
1812
|
-
valueTypesById
|
|
1813
|
-
}));
|
|
1814
|
-
}
|
|
1815
|
-
if (schema.type === "map") {
|
|
1816
|
-
if (!isRecord2(value)) {
|
|
1817
|
-
throw cannotSerialize(path);
|
|
1818
|
-
}
|
|
1819
|
-
const snapshot = {};
|
|
1820
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
1821
|
-
snapshot[key] = snapshotSchemaValue({
|
|
1822
|
-
schema: schema.valueSchema,
|
|
1823
|
-
value: entry,
|
|
1824
|
-
path: `${path}.${key}`,
|
|
1825
|
-
valueTypesById
|
|
1826
|
-
});
|
|
1827
|
-
}
|
|
1828
|
-
return snapshot;
|
|
1829
|
-
}
|
|
1830
|
-
if (schema.type === "object") {
|
|
1831
|
-
if (!isRecord2(value)) {
|
|
1832
|
-
throw cannotSerialize(path);
|
|
1833
|
-
}
|
|
1834
|
-
const snapshot = {};
|
|
1835
|
-
for (const [fieldId, field] of Object.entries(schema.properties)) {
|
|
1836
|
-
const fieldValue = value[fieldId];
|
|
1837
|
-
if (fieldValue === undefined) {
|
|
1838
|
-
continue;
|
|
1839
|
-
}
|
|
1840
|
-
if (fieldValue === null) {
|
|
1841
|
-
snapshot[fieldId] = null;
|
|
1842
|
-
continue;
|
|
1843
|
-
}
|
|
1844
|
-
snapshot[fieldId] = snapshotSchemaValue({
|
|
1845
|
-
schema: field.schema,
|
|
1846
|
-
value: fieldValue,
|
|
1847
|
-
path: `${path}.${fieldId}`,
|
|
1848
|
-
valueTypesById
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
return snapshot;
|
|
1852
|
-
}
|
|
1853
|
-
if (schema.type === "valueTypeRef") {
|
|
1854
|
-
const valueType = valueTypesById.get(schema.valueTypeId);
|
|
1855
|
-
if (!valueType) {
|
|
1856
|
-
throw new WorkflowValidationError(`[Sixb] Unknown valueTypeRef '${schema.valueTypeId}' at ${path}`);
|
|
1857
|
-
}
|
|
1858
|
-
return snapshotSchemaValue({
|
|
1859
|
-
schema: valueType.schema,
|
|
1860
|
-
value,
|
|
1861
|
-
path,
|
|
1862
|
-
valueTypesById
|
|
1863
|
-
});
|
|
1864
|
-
}
|
|
1865
|
-
return snapshotJsonValue(value, path);
|
|
1866
|
-
}
|
|
1867
|
-
function snapshotJsonValue(value, path) {
|
|
1868
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
1869
|
-
return value;
|
|
1870
|
-
}
|
|
1871
|
-
if (typeof value === "number") {
|
|
1872
|
-
if (!Number.isFinite(value)) {
|
|
1873
|
-
throw cannotSerialize(path);
|
|
1874
|
-
}
|
|
1875
|
-
return value;
|
|
1876
|
-
}
|
|
1877
|
-
if (value instanceof Date) {
|
|
1878
|
-
return snapshotDate(value, path);
|
|
1879
|
-
}
|
|
1880
|
-
if (Array.isArray(value)) {
|
|
1881
|
-
return value.map((item, index) => snapshotJsonValue(item, `${path}[${index}]`));
|
|
1882
|
-
}
|
|
1883
|
-
if (isPlainRecord(value)) {
|
|
1884
|
-
const snapshot = {};
|
|
1885
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
1886
|
-
snapshot[key] = snapshotJsonValue(entry, `${path}.${key}`);
|
|
1887
|
-
}
|
|
1888
|
-
return snapshot;
|
|
1889
|
-
}
|
|
1890
|
-
throw cannotSerialize(path);
|
|
1891
|
-
}
|
|
1892
|
-
function snapshotDate(value, path) {
|
|
1893
|
-
if (Number.isNaN(value.getTime())) {
|
|
1894
|
-
throw cannotSerialize(path);
|
|
1895
|
-
}
|
|
1896
|
-
return value.toISOString();
|
|
1897
|
-
}
|
|
1898
|
-
function cannotSerialize(path) {
|
|
1899
|
-
return new WorkflowValidationError(`[Sixb] ${path} cannot be serialized as workflow IO`);
|
|
1900
|
-
}
|
|
1901
|
-
function isRecord2(value) {
|
|
1902
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
// src/workflows/run-dispatch.ts
|
|
1906
|
-
class WorkflowRunDispatcher {
|
|
1907
|
-
dependencies;
|
|
1908
|
-
constructor(dependencies) {
|
|
1909
|
-
this.dependencies = dependencies;
|
|
1910
|
-
}
|
|
1911
|
-
async dispatch(input) {
|
|
1912
|
-
assertAutomaticDispatchInput(input);
|
|
1913
|
-
const workflow = this.dependencies.definitions.workflows.getById(input.workflowId);
|
|
1914
|
-
if (!workflow) {
|
|
1915
|
-
throw new WorkflowValidationError(`[Sixb] Unknown workflow '${input.workflowId}'`);
|
|
1916
|
-
}
|
|
1917
|
-
const result = await dispatchWorkflowRun({
|
|
1918
|
-
errorReporterHost: this.dependencies,
|
|
1919
|
-
projectId: this.dependencies.id,
|
|
1920
|
-
workflow,
|
|
1921
|
-
valueTypesById: this.dependencies.definitions.ontology.getValueTypesById(),
|
|
1922
|
-
storage: this.dependencies.storage,
|
|
1923
|
-
queue: this.dependencies.queues.workflows,
|
|
1924
|
-
events: this.dependencies.events,
|
|
1925
|
-
runId: input.runId,
|
|
1926
|
-
input: input.input,
|
|
1927
|
-
source: {
|
|
1928
|
-
type: "schedule",
|
|
1929
|
-
scheduleId: input.scheduleId,
|
|
1930
|
-
eventId: input.source.eventId,
|
|
1931
|
-
principal: SYSTEM_PRINCIPAL
|
|
1932
|
-
},
|
|
1933
|
-
requesterGroupIds: [],
|
|
1934
|
-
metadata: input.metadata,
|
|
1935
|
-
queueJobId: input.runId,
|
|
1936
|
-
createExecution: async (executionId, runId) => createPrimitiveExecutionRecord({
|
|
1937
|
-
id: executionId,
|
|
1938
|
-
primitive: { kind: "workflow", id: workflow.id, runId },
|
|
1939
|
-
origin: {
|
|
1940
|
-
type: "automatic",
|
|
1941
|
-
projectId: this.dependencies.id,
|
|
1942
|
-
source: input.source,
|
|
1943
|
-
correlationId: input.correlationId
|
|
1944
|
-
}
|
|
1945
|
-
})
|
|
1946
|
-
});
|
|
1947
|
-
if (!result.created) {
|
|
1948
|
-
await assertAutomaticExecutionIdentity(this.dependencies, input, result.runId);
|
|
1949
|
-
}
|
|
1950
|
-
return result;
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
async function dispatchWorkflowRun(input) {
|
|
1954
|
-
const request = prepareWorkflowRun(input);
|
|
1955
|
-
const persisted = await persistWorkflowRun(input, request);
|
|
1956
|
-
if (!persisted.created)
|
|
1957
|
-
return existingWorkflowRunResult(persisted.run);
|
|
1958
|
-
return publishWorkflowRun(input, persisted);
|
|
1959
|
-
}
|
|
1960
|
-
function prepareWorkflowRun(input) {
|
|
1961
|
-
const value = input.input ?? {};
|
|
1962
|
-
return {
|
|
1963
|
-
runId: resolveWorkflowRunId(input.runId),
|
|
1964
|
-
snapshot: snapshotWorkflowInput({
|
|
1965
|
-
workflow: input.workflow,
|
|
1966
|
-
value,
|
|
1967
|
-
valueTypesById: input.valueTypesById
|
|
1968
|
-
})
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
async function persistWorkflowRun(input, request) {
|
|
1972
|
-
const workflowRuns = input.storage.workflowRuns;
|
|
1973
|
-
if (!workflowRuns) {
|
|
1974
|
-
throw new WorkflowValidationError("[Sixb] Workflow run storage is not configured.");
|
|
1975
|
-
}
|
|
1976
|
-
const existing = await workflowRuns.getById({
|
|
1977
|
-
projectId: input.projectId,
|
|
1978
|
-
id: request.runId
|
|
1979
|
-
});
|
|
1980
|
-
if (existing) {
|
|
1981
|
-
assertExistingWorkflowRun(existing, input.workflow.id, request.snapshot);
|
|
1982
|
-
return { run: existing, created: false };
|
|
1983
|
-
}
|
|
1984
|
-
const execution = await input.createExecution(`exec_${randomUUID4()}`, request.runId);
|
|
1985
|
-
const queuedAt = new Date;
|
|
1986
|
-
try {
|
|
1987
|
-
return await input.storage.transaction(async (tx) => {
|
|
1988
|
-
const raced = await tx.workflowRuns?.getById({
|
|
1989
|
-
projectId: input.projectId,
|
|
1990
|
-
id: request.runId
|
|
1991
|
-
});
|
|
1992
|
-
if (raced) {
|
|
1993
|
-
assertExistingWorkflowRun(raced, input.workflow.id, request.snapshot);
|
|
1994
|
-
return { run: raced, created: false };
|
|
1995
|
-
}
|
|
1996
|
-
if (!tx.workflowRuns) {
|
|
1997
|
-
throw new WorkflowValidationError("[Sixb] Workflow run storage is not configured.");
|
|
1998
|
-
}
|
|
1999
|
-
await tx.executions.create(execution);
|
|
2000
|
-
const run = await tx.workflowRuns.queue({
|
|
2001
|
-
projectId: input.projectId,
|
|
2002
|
-
id: request.runId,
|
|
2003
|
-
executionId: execution.id,
|
|
2004
|
-
workflowId: input.workflow.id,
|
|
2005
|
-
input: request.snapshot,
|
|
2006
|
-
queuedAt,
|
|
2007
|
-
requesterGroupIds: input.requesterGroupIds
|
|
2008
|
-
});
|
|
2009
|
-
return { run, execution, queuedAt, created: true };
|
|
2010
|
-
}, { isolation: "serializable" });
|
|
2011
|
-
} catch (error) {
|
|
2012
|
-
if (!(error instanceof WorkflowRunError))
|
|
2013
|
-
throw error;
|
|
2014
|
-
const raced = await workflowRuns.getById({
|
|
2015
|
-
projectId: input.projectId,
|
|
2016
|
-
id: request.runId
|
|
2017
|
-
});
|
|
2018
|
-
if (!raced)
|
|
2019
|
-
throw error;
|
|
2020
|
-
assertExistingWorkflowRun(raced, input.workflow.id, request.snapshot);
|
|
2021
|
-
return { run: raced, created: false };
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
async function publishWorkflowRun(input, persisted) {
|
|
2025
|
-
let job;
|
|
2026
|
-
try {
|
|
2027
|
-
const jobs = await input.queue.enqueue({
|
|
2028
|
-
projectId: input.projectId,
|
|
2029
|
-
jobs: [
|
|
2030
|
-
{
|
|
2031
|
-
...input.queueJobId === undefined ? {} : { id: input.queueJobId },
|
|
2032
|
-
type: "workflow.run.requested",
|
|
2033
|
-
payload: { runId: persisted.run.id },
|
|
2034
|
-
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
2035
|
-
}
|
|
2036
|
-
]
|
|
2037
|
-
});
|
|
2038
|
-
job = jobs[0];
|
|
2039
|
-
} catch (error) {
|
|
2040
|
-
await failWorkflowRunPublication(input, persisted.run, error);
|
|
2041
|
-
throw error;
|
|
2042
|
-
}
|
|
2043
|
-
await input.events.emit({
|
|
2044
|
-
events: [
|
|
2045
|
-
{
|
|
2046
|
-
type: "workflow.run.queued",
|
|
2047
|
-
payload: {
|
|
2048
|
-
workflowId: persisted.run.workflowId,
|
|
2049
|
-
runId: persisted.run.id,
|
|
2050
|
-
queuedAt: persisted.queuedAt.toISOString(),
|
|
2051
|
-
...job?.id ? { jobId: job.id } : {},
|
|
2052
|
-
...input.source === undefined ? {} : { source: input.source }
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
],
|
|
2056
|
-
correlationId: persisted.execution.correlationId
|
|
2057
|
-
}, { source: "Sixb" });
|
|
2058
|
-
return {
|
|
2059
|
-
workflowId: persisted.run.workflowId,
|
|
2060
|
-
runId: persisted.run.id,
|
|
2061
|
-
queuedAt: persisted.queuedAt.toISOString(),
|
|
2062
|
-
jobId: job?.id,
|
|
2063
|
-
created: true
|
|
2064
|
-
};
|
|
2065
|
-
}
|
|
2066
|
-
async function failWorkflowRunPublication(input, run, error) {
|
|
2067
|
-
const workflowRuns = input.storage.workflowRuns;
|
|
2068
|
-
if (!workflowRuns) {
|
|
2069
|
-
throw new WorkflowValidationError("[Sixb] Workflow run storage is not configured.");
|
|
2070
|
-
}
|
|
2071
|
-
const failure = captureSixbFailure(error, {
|
|
2072
|
-
allowedCodes: WORKFLOW_RUN_FAILURE_CODES,
|
|
2073
|
-
defaultCode: "internal.unexpected",
|
|
2074
|
-
details: { workflowId: run.workflowId, runId: run.id }
|
|
2075
|
-
});
|
|
2076
|
-
await workflowRuns.finish({
|
|
2077
|
-
projectId: input.projectId,
|
|
2078
|
-
id: run.id,
|
|
2079
|
-
status: "failed",
|
|
2080
|
-
error: failure
|
|
2081
|
-
});
|
|
2082
|
-
reportRunFailure(input.errorReporterHost, error, {
|
|
2083
|
-
projectId: input.projectId,
|
|
2084
|
-
runKind: "workflow",
|
|
2085
|
-
run: { runId: run.id, workflowId: run.workflowId },
|
|
2086
|
-
failure
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
function resolveWorkflowRunId(runId) {
|
|
2090
|
-
if (runId === undefined)
|
|
2091
|
-
return `run_${randomUUID4()}`;
|
|
2092
|
-
if (!runId.trim()) {
|
|
2093
|
-
throw new WorkflowValidationError("[Sixb] Workflow run id must not be empty");
|
|
2094
|
-
}
|
|
2095
|
-
return runId;
|
|
2096
|
-
}
|
|
2097
|
-
function assertExistingWorkflowRun(existing, workflowId, input) {
|
|
2098
|
-
if (existing.workflowId !== workflowId || !isDeepStrictEqual(existing.input, input)) {
|
|
2099
|
-
throw new WorkflowValidationError(`[Sixb] Workflow run '${existing.id}' already exists with a different request payload.`);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
function existingWorkflowRunResult(existing) {
|
|
2103
|
-
return {
|
|
2104
|
-
workflowId: existing.workflowId,
|
|
2105
|
-
runId: existing.id,
|
|
2106
|
-
queuedAt: (existing.queuedAt ?? existing.startedAt).toISOString(),
|
|
2107
|
-
created: false
|
|
2108
|
-
};
|
|
2109
|
-
}
|
|
2110
|
-
function assertAutomaticDispatchInput(input) {
|
|
2111
|
-
assertNonBlank(input.workflowId, "Workflow id");
|
|
2112
|
-
assertNonBlank(input.runId, "Workflow run id");
|
|
2113
|
-
assertNonBlank(input.scheduleId, "Workflow schedule id");
|
|
2114
|
-
assertNonBlank(input.source.eventId, "Workflow source event id");
|
|
2115
|
-
assertNonBlank(input.correlationId, "Workflow correlation id");
|
|
2116
|
-
}
|
|
2117
|
-
async function assertAutomaticExecutionIdentity(dependencies, input, runId) {
|
|
2118
|
-
const run = await dependencies.storage.workflowRuns?.getById({
|
|
2119
|
-
projectId: dependencies.id,
|
|
2120
|
-
id: runId
|
|
2121
|
-
});
|
|
2122
|
-
const execution = run ? await dependencies.storage.executions.getById({
|
|
2123
|
-
projectId: dependencies.id,
|
|
2124
|
-
id: run.executionId
|
|
2125
|
-
}) : null;
|
|
2126
|
-
if (!execution || execution.source.type !== input.source.type || execution.source.eventId !== input.source.eventId || execution.correlationId !== input.correlationId || execution.requestedBy !== undefined) {
|
|
2127
|
-
throw new WorkflowValidationError(`[Sixb] Workflow run '${runId}' already exists with different automatic provenance.`);
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
function assertNonBlank(value, label) {
|
|
2131
|
-
if (!value.trim())
|
|
2132
|
-
throw new WorkflowValidationError(`[Sixb] ${label} must not be empty.`);
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
// src/workflows/request.ts
|
|
2136
|
-
async function requestWorkflowRun(runtime, execution, workflow, options = {}) {
|
|
2137
|
-
assertAuthorized(runtime, { kind: "workflow.run", workflowId: workflow.id });
|
|
2138
|
-
const requesterGroupIds = execution.requestedBy ? await snapshotRequesterGroupIds({
|
|
2139
|
-
auth: runtime.storage.auth,
|
|
2140
|
-
projectId: runtime.projectId,
|
|
2141
|
-
principal: execution.requestedBy
|
|
2142
|
-
}) : [];
|
|
2143
|
-
return dispatchWorkflowRun({
|
|
2144
|
-
errorReporterHost: runtime,
|
|
2145
|
-
projectId: runtime.projectId,
|
|
2146
|
-
workflow,
|
|
2147
|
-
valueTypesById: runtime.ontology.getValueTypesById(),
|
|
2148
|
-
storage: runtime.storage,
|
|
2149
|
-
queue: runtime.queues.workflows,
|
|
2150
|
-
events: runtime.events,
|
|
2151
|
-
runId: options.runId,
|
|
2152
|
-
input: options.input,
|
|
2153
|
-
source: options.source,
|
|
2154
|
-
requesterGroupIds,
|
|
2155
|
-
createExecution: async (executionId, runId) => {
|
|
2156
|
-
const caller = await ensureExecutionRecord(runtime.storage.executions, executionRecordInputFromRuntime({
|
|
2157
|
-
execution,
|
|
2158
|
-
runtimeAuthorization: runtime.runtimeAuthorization
|
|
2159
|
-
}));
|
|
2160
|
-
return createPrimitiveExecutionRecord({
|
|
2161
|
-
id: executionId,
|
|
2162
|
-
primitive: { kind: "workflow", id: workflow.id, runId },
|
|
2163
|
-
origin: { type: "execution", parent: caller }
|
|
2164
|
-
});
|
|
2165
|
-
}
|
|
2166
|
-
});
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
// src/workflows/execution.ts
|
|
2170
|
-
function createWorkflowsRuntime(runtime, execution, source) {
|
|
2171
|
-
const allowed = (workflowId) => isAllowed(runtime.authorization, { kind: "workflow.run", workflowId });
|
|
2172
|
-
const canAccessHistory = (workflowId) => allowed(workflowId) && (!runtime.authorization || source.getById(workflowId) !== null);
|
|
2173
|
-
const visibleIds = () => source.list().filter((workflow) => allowed(workflow.id)).map((workflow) => workflow.id);
|
|
2174
|
-
const getVisibleRunRecord = async (runId) => {
|
|
2175
|
-
const run = await runtime.storage.workflowRuns?.getById({
|
|
2176
|
-
projectId: runtime.projectId,
|
|
2177
|
-
id: runId
|
|
2178
|
-
}) ?? null;
|
|
2179
|
-
return run && canViewWorkflowRun(runtime.authorization, run) && canAccessHistory(run.workflowId) ? run : null;
|
|
2180
|
-
};
|
|
2181
|
-
const getRun = async (runId) => {
|
|
2182
|
-
const run = await getVisibleRunRecord(runId);
|
|
2183
|
-
return run ? attachRequestedBy(runtime, run) : null;
|
|
2184
|
-
};
|
|
2185
|
-
const listNodes = async (runId, input = {}) => {
|
|
2186
|
-
const storage = runtime.storage.workflowRuns;
|
|
2187
|
-
if (!storage || !await getVisibleRunRecord(runId))
|
|
2188
|
-
return null;
|
|
2189
|
-
const result = await storage.nodes.list({
|
|
2190
|
-
projectId: runtime.projectId,
|
|
2191
|
-
...input,
|
|
2192
|
-
workflowRunId: runId
|
|
2193
|
-
});
|
|
2194
|
-
return {
|
|
2195
|
-
...result,
|
|
2196
|
-
nodes: await attachWorkflowNodeViews(runtime, storage, result.nodes)
|
|
2197
|
-
};
|
|
2198
|
-
};
|
|
2199
|
-
return {
|
|
2200
|
-
list: () => source.list().filter((workflow) => allowed(workflow.id)),
|
|
2201
|
-
getById: (workflowId) => {
|
|
2202
|
-
const workflow = source.getById(workflowId);
|
|
2203
|
-
return workflow && allowed(workflowId) ? workflow : null;
|
|
2204
|
-
},
|
|
2205
|
-
request: (workflow, options) => requestWorkflowRun(runtime, execution, workflow, options),
|
|
2206
|
-
requestById: async (input) => {
|
|
2207
|
-
const workflow = source.getById(input.workflowId);
|
|
2208
|
-
if (!workflow) {
|
|
2209
|
-
throw new WorkflowValidationError(`[Sixb] Unknown workflow '${input.workflowId}'`);
|
|
2210
|
-
}
|
|
2211
|
-
return requestWorkflowRun(runtime, execution, workflow, input);
|
|
2212
|
-
},
|
|
2213
|
-
runs: {
|
|
2214
|
-
getById: getRun,
|
|
2215
|
-
list: async (input = {}) => {
|
|
2216
|
-
const storage = runtime.storage.workflowRuns;
|
|
2217
|
-
if (!storage)
|
|
2218
|
-
return { runs: [], hasMore: false, total: 0 };
|
|
2219
|
-
const result = await storage.list({
|
|
2220
|
-
projectId: runtime.projectId,
|
|
2221
|
-
...input,
|
|
2222
|
-
workflowIds: runtime.authorization ? visibleIds() : undefined
|
|
2223
|
-
});
|
|
2224
|
-
return {
|
|
2225
|
-
...result,
|
|
2226
|
-
runs: await Promise.all(result.runs.map((run) => attachRequestedBy(runtime, run)))
|
|
2227
|
-
};
|
|
2228
|
-
},
|
|
2229
|
-
listLatest: async (workflowIds) => {
|
|
2230
|
-
const storage = runtime.storage.workflowRuns;
|
|
2231
|
-
if (!storage || workflowIds.length === 0)
|
|
2232
|
-
return { runs: [] };
|
|
2233
|
-
const allowedIds = workflowIds.filter(canAccessHistory);
|
|
2234
|
-
if (allowedIds.length === 0)
|
|
2235
|
-
return { runs: [] };
|
|
2236
|
-
const result = await storage.listLatestByWorkflowIds({
|
|
2237
|
-
projectId: runtime.projectId,
|
|
2238
|
-
workflowIds: allowedIds
|
|
2239
|
-
});
|
|
2240
|
-
return {
|
|
2241
|
-
runs: await Promise.all(result.runs.map((run) => attachRequestedBy(runtime, run)))
|
|
2242
|
-
};
|
|
2243
|
-
},
|
|
2244
|
-
listNodes
|
|
2245
|
-
},
|
|
2246
|
-
interventions: {
|
|
2247
|
-
getById: async (interventionId) => {
|
|
2248
|
-
const intervention = await runtime.storage.workflowInterventions?.getById({
|
|
2249
|
-
projectId: runtime.projectId,
|
|
2250
|
-
id: interventionId
|
|
2251
|
-
}) ?? null;
|
|
2252
|
-
return intervention && canViewWorkflowIntervention(runtime.authorization, intervention) && canAccessHistory(intervention.workflowId) ? intervention : null;
|
|
2253
|
-
},
|
|
2254
|
-
list: (input = {}) => {
|
|
2255
|
-
const storage = runtime.storage.workflowInterventions;
|
|
2256
|
-
if (!storage)
|
|
2257
|
-
return Promise.resolve({ interventions: [], hasMore: false, total: 0 });
|
|
2258
|
-
return storage.list({
|
|
2259
|
-
projectId: runtime.projectId,
|
|
2260
|
-
...input,
|
|
2261
|
-
workflowIds: runtime.authorization ? visibleIds() : undefined
|
|
2262
|
-
});
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
|
-
async function attachWorkflowNodeViews(runtime, storage, nodes) {
|
|
2268
|
-
const executions = await Promise.all(nodes.map((node) => node.nodeType === "agent" ? storage.agentNodes.getByNodeRunId({
|
|
2269
|
-
projectId: runtime.projectId,
|
|
2270
|
-
nodeRunId: node.id
|
|
2271
|
-
}) : null));
|
|
2272
|
-
const agentExecutions = executions.filter((execution) => execution !== null);
|
|
2273
|
-
if (agentExecutions.length === 0)
|
|
2274
|
-
return nodes;
|
|
2275
|
-
const executionIds = agentExecutions.map((execution) => execution.executionId);
|
|
2276
|
-
const [usages, costs] = await Promise.all([
|
|
2277
|
-
resolveExecutionUsage({
|
|
2278
|
-
storage: runtime.storage.aiUsage,
|
|
2279
|
-
projectId: runtime.projectId,
|
|
2280
|
-
executionIds
|
|
2281
|
-
}),
|
|
2282
|
-
resolveExecutionCosts({
|
|
2283
|
-
storage: runtime.storage.aiCosts,
|
|
2284
|
-
projectId: runtime.projectId,
|
|
2285
|
-
executionIds
|
|
2286
|
-
})
|
|
2287
|
-
]);
|
|
2288
|
-
const accountingByExecutionId = new Map(agentExecutions.map((execution, index) => [
|
|
2289
|
-
execution.executionId,
|
|
2290
|
-
{ usage: usages[index], cost: costs[index] }
|
|
2291
|
-
]));
|
|
2292
|
-
return nodes.map((node, index) => {
|
|
2293
|
-
const execution = executions[index];
|
|
2294
|
-
if (!execution)
|
|
2295
|
-
return node;
|
|
2296
|
-
const accounting = accountingByExecutionId.get(execution.executionId);
|
|
2297
|
-
return {
|
|
2298
|
-
...node,
|
|
2299
|
-
agentExecution: toWorkflowAgentNodeRunView(execution, accounting?.usage, accounting?.usage === undefined ? undefined : accounting.cost)
|
|
2300
|
-
};
|
|
2301
|
-
});
|
|
2302
|
-
}
|
|
2303
|
-
function toWorkflowAgentNodeRunView(execution, usage, cost) {
|
|
2304
|
-
return {
|
|
2305
|
-
projectId: execution.projectId,
|
|
2306
|
-
nodeRunId: execution.nodeRunId,
|
|
2307
|
-
executionId: execution.executionId,
|
|
2308
|
-
status: execution.status,
|
|
2309
|
-
prompt: execution.prompt,
|
|
2310
|
-
modelId: execution.modelId,
|
|
2311
|
-
finishReason: execution.finishReason,
|
|
2312
|
-
trace: execution.trace,
|
|
2313
|
-
diagnostics: execution.diagnostics,
|
|
2314
|
-
error: execution.error,
|
|
2315
|
-
attempt: execution.attempt,
|
|
2316
|
-
createdAt: execution.createdAt,
|
|
2317
|
-
startedAt: execution.startedAt,
|
|
2318
|
-
completedAt: execution.completedAt,
|
|
2319
|
-
...usage === undefined ? {} : { usage },
|
|
2320
|
-
...usage === undefined || cost === undefined ? {} : { cost }
|
|
2321
|
-
};
|
|
2322
|
-
}
|
|
2323
|
-
async function attachRequestedBy(runtime, run) {
|
|
2324
|
-
const execution = await runtime.storage.executions.getById({
|
|
2325
|
-
projectId: runtime.projectId,
|
|
2326
|
-
id: run.executionId
|
|
2327
|
-
});
|
|
2328
|
-
if (!execution) {
|
|
2329
|
-
throw new Error(`[Sixb] Workflow run '${run.id}' references missing execution '${run.executionId}'.`);
|
|
2330
|
-
}
|
|
2331
|
-
return {
|
|
2332
|
-
...run,
|
|
2333
|
-
...execution.requestedBy === undefined ? {} : { requestedBy: structuredClone(execution.requestedBy) }
|
|
2334
|
-
};
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
// src/runtime/sixb.ts
|
|
2338
|
-
var boundSixbInstances = new WeakSet;
|
|
2339
|
-
function createBoundSixb(runtime, dependencies, execution) {
|
|
2340
|
-
const sixb = {
|
|
2341
|
-
execution,
|
|
2342
|
-
...createExecutionFacades(runtime, execution, dependencies)
|
|
2343
|
-
};
|
|
2344
|
-
shareOntologyMutationRuntime(runtime, sixb);
|
|
2345
|
-
if (dependencies.connectorConnections) {
|
|
2346
|
-
registerConnectorConnectionsRuntime(sixb, createConnectorConnectionsRuntime(runtime, execution, dependencies.connectorConnections));
|
|
2347
|
-
}
|
|
2348
|
-
boundSixbInstances.add(sixb);
|
|
2349
|
-
return sixb;
|
|
2350
|
-
}
|
|
2351
|
-
function isBoundSixb(value) {
|
|
2352
|
-
return typeof value === "object" && value !== null && boundSixbInstances.has(value);
|
|
2353
|
-
}
|
|
2354
|
-
function createExecutionFacades(runtime, execution, dependencies) {
|
|
2355
|
-
return {
|
|
2356
|
-
objects: createObjectsRuntime(runtime, execution),
|
|
2357
|
-
actions: createActionsRuntime(runtime, execution),
|
|
2358
|
-
datasets: createDatasetsRuntime(runtime, dependencies.definitions.datasets),
|
|
2359
|
-
workflows: createWorkflowsRuntime(runtime, execution, dependencies.definitions.workflows),
|
|
2360
|
-
syncs: createSyncsRuntime(runtime, execution, dependencies.definitions.syncs),
|
|
2361
|
-
pipelines: createPipelinesRuntime(runtime, execution, dependencies.definitions.pipelines),
|
|
2362
|
-
projections: createProjectionsRuntime(runtime, dependencies.definitions.projections),
|
|
2363
|
-
rules: createRulesRuntime(runtime, dependencies.definitions.rules),
|
|
2364
|
-
agent: createAgentRuntime(runtime, execution, dependencies.definitions.models),
|
|
2365
|
-
aiUsage: createAiUsageRuntime(runtime, dependencies.definitions.security),
|
|
2366
|
-
events: createEventsRuntime(runtime),
|
|
2367
|
-
logs: createLogsRuntime(runtime, dependencies.logging),
|
|
2368
|
-
schedules: createSchedulesRuntime(dependencies.definitions.schedules),
|
|
2369
|
-
connector: createConnectorRuntime(runtime, execution, dependencies.connectorService),
|
|
2370
|
-
blobs: createBlobsRuntime(runtime, execution, dependencies.blobStorage)
|
|
2371
|
-
};
|
|
2372
|
-
}
|
|
2373
|
-
// src/execution/agent.ts
|
|
2374
|
-
function canInheritAgentRequestAuthorization(authorization) {
|
|
2375
|
-
const ref = getAuthorizationRef(authorization);
|
|
2376
|
-
return ref.type === "disabled" || ref.type === "principal" && ref.principal.type === "user" && ref.credential !== undefined;
|
|
2377
|
-
}
|
|
2378
|
-
function createAgentExecutionRecord(input) {
|
|
2379
|
-
assertAgentPrincipal(input.actorId, input.principal);
|
|
2380
|
-
return {
|
|
2381
|
-
id: input.id,
|
|
2382
|
-
projectId: input.parent.projectId,
|
|
2383
|
-
...input.parent.requestedBy === undefined ? {} : { requestedBy: structuredClone(input.parent.requestedBy) },
|
|
2384
|
-
executor: { type: "agent", runId: input.runId },
|
|
2385
|
-
source: { type: "execution", executionId: input.parent.id },
|
|
2386
|
-
correlationId: input.parent.correlationId,
|
|
2387
|
-
authorizationRef: {
|
|
2388
|
-
type: "principal",
|
|
2389
|
-
principal: structuredClone(input.principal)
|
|
2390
|
-
}
|
|
2391
|
-
};
|
|
2392
|
-
}
|
|
2393
|
-
function createInheritedAgentExecutionRecord(input) {
|
|
2394
|
-
const authority = input.parent.authorizationRef;
|
|
2395
|
-
if (authority.type !== "disabled" && !(authority.type === "principal" && authority.principal.type === "user" && authority.credential !== undefined)) {
|
|
2396
|
-
throw new ExecutionStorageError("invalid_input", `[Sixb] Agent run '${input.runId}' requires inheritable user or auth-disabled authority.`);
|
|
2397
|
-
}
|
|
2398
|
-
return {
|
|
2399
|
-
id: input.id,
|
|
2400
|
-
projectId: input.parent.projectId,
|
|
2401
|
-
...input.parent.requestedBy === undefined ? {} : { requestedBy: structuredClone(input.parent.requestedBy) },
|
|
2402
|
-
executor: { type: "agent", runId: input.runId },
|
|
2403
|
-
source: { type: "execution", executionId: input.parent.id },
|
|
2404
|
-
correlationId: input.parent.correlationId,
|
|
2405
|
-
authorizationRef: structuredClone(authority)
|
|
2406
|
-
};
|
|
2407
|
-
}
|
|
2408
|
-
function bindDurableAgentExecution(host, input) {
|
|
2409
|
-
const scope = restoreAgentExecutionScope(input);
|
|
2410
|
-
const sixb = host.withScope(scope);
|
|
2411
|
-
if (!isBoundSixb(sixb)) {
|
|
2412
|
-
throw new Error("[Sixb] Agent execution host returned an invalid bound SDK.");
|
|
2413
|
-
}
|
|
2414
|
-
return sixb;
|
|
2415
|
-
}
|
|
2416
|
-
function restoreAgentExecutionScope(input) {
|
|
2417
|
-
assertAgentExecutionRecord(input);
|
|
2418
|
-
const context = Object.freeze({
|
|
2419
|
-
id: input.execution.id,
|
|
2420
|
-
projectId: input.execution.projectId,
|
|
2421
|
-
...input.execution.requestedBy === undefined ? {} : { requestedBy: Object.freeze(structuredClone(input.execution.requestedBy)) },
|
|
2422
|
-
executor: Object.freeze({
|
|
2423
|
-
type: "agent",
|
|
2424
|
-
...input.actorId === undefined ? {} : { actorId: input.actorId },
|
|
2425
|
-
runId: input.runId
|
|
2426
|
-
}),
|
|
2427
|
-
source: Object.freeze(structuredClone(input.execution.source)),
|
|
2428
|
-
correlationId: input.execution.correlationId
|
|
2429
|
-
});
|
|
2430
|
-
return Object.freeze({
|
|
2431
|
-
execution: context,
|
|
2432
|
-
authorization: createAgentRuntimeAuthorization({
|
|
2433
|
-
projectId: input.execution.projectId,
|
|
2434
|
-
executionId: input.execution.id,
|
|
2435
|
-
...input.actorId === undefined ? {} : { actorId: input.actorId },
|
|
2436
|
-
runId: input.runId,
|
|
2437
|
-
authority: input.authorization.type === "principal" ? {
|
|
2438
|
-
type: "principal",
|
|
2439
|
-
context: input.authorization.context,
|
|
2440
|
-
...input.execution.authorizationRef.type === "principal" && input.execution.authorizationRef.credential !== undefined ? { credential: input.execution.authorizationRef.credential } : {}
|
|
2441
|
-
} : { type: "disabled" }
|
|
2442
|
-
})
|
|
2443
|
-
});
|
|
2444
|
-
}
|
|
2445
|
-
function assertAgentExecutionRecord(input) {
|
|
2446
|
-
const authority = input.execution.authorizationRef;
|
|
2447
|
-
if (input.execution.executor.type !== "agent" || input.execution.executor.runId !== input.runId || input.execution.source.type !== "execution") {
|
|
2448
|
-
invalidAgentExecution(input.execution.id, input.runId);
|
|
2449
|
-
}
|
|
2450
|
-
if (input.authorization.type === "disabled" || input.authorization.context.principal.type === "user") {
|
|
2451
|
-
assertInheritedAgentAuthority(input.execution, input.runId, input.authorization);
|
|
2452
|
-
return;
|
|
2453
|
-
}
|
|
2454
|
-
if (input.authorization.type !== "principal" || authority.type !== "principal" || authority.principal.type !== "serviceAccount" || input.authorization.context.principal.type !== "serviceAccount" || authority.principal.id !== input.authorization.context.principal.id || authority.credential !== undefined) {
|
|
2455
|
-
invalidAgentExecution(input.execution.id, input.runId);
|
|
2456
|
-
}
|
|
2457
|
-
if (input.actorId === undefined) {
|
|
2458
|
-
invalidAgentExecution(input.execution.id, input.runId);
|
|
2459
|
-
}
|
|
2460
|
-
assertAgentPrincipal(input.actorId, authority.principal);
|
|
2461
|
-
}
|
|
2462
|
-
function assertInheritedAgentAuthority(execution, runId, authorization) {
|
|
2463
|
-
const authority = execution.authorizationRef;
|
|
2464
|
-
if (authorization.type === "disabled") {
|
|
2465
|
-
if (authority.type !== "disabled")
|
|
2466
|
-
invalidAgentExecution(execution.id, runId);
|
|
2467
|
-
return;
|
|
2468
|
-
}
|
|
2469
|
-
const principal = authorization.context.principal;
|
|
2470
|
-
if (authority.type !== "principal" || authority.principal.type !== "user" || principal.type !== "user" || authority.principal.id !== principal.id || authority.credential === undefined || (authority.credential.type === "session" ? authorization.context.sessionId !== authority.credential.id : authorization.context.sessionId !== undefined)) {
|
|
2471
|
-
invalidAgentExecution(execution.id, runId);
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
function assertAgentPrincipal(actorId, principal) {
|
|
2475
|
-
const expectedId = agentServiceAccountId(actorId);
|
|
2476
|
-
if (principal.id !== expectedId) {
|
|
2477
|
-
throw new ExecutionStorageError("invalid_input", `[Sixb] Agent '${actorId}' execution authority must reference service account '${expectedId}'.`);
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
function invalidAgentExecution(executionId, runId) {
|
|
2481
|
-
throw new ExecutionStorageError("invalid_input", `[Sixb] Execution '${executionId}' does not authorize Agent run '${runId}'.`);
|
|
2482
|
-
}
|
|
2483
|
-
|
|
2484
|
-
export { resolveAgentContextParts, agentRunQueueJobId, subagentRunQueueJobId, workflowAgentNodeQueueJobId, dispatchQueuedAgentRuns, dispatchQueuedSubagentRuns, createAgentThreadId, createAgentRunId, createSubagentRunId, createSubagentExecutionId, createAgentMessageId, agentContextCheckpointId, createAgentRunExecutionToken, assertNoAgentDefinitions, WorkflowDefinitionError, WorkflowValidationError, assertNonEmpty, isStepDefinition, isAgentStepDefinition, isInterventionDefinition, isWorkflowDefinition, validateWorkflowDefinition, validateWorkflowsAtStartup, validateWorkflowAgentStepGroupReferences, validateWorkflowInput, validateWorkflowStepInput, validateWorkflowStepOutput, validateWorkflowInterventionInput, validateWorkflowInterventionResponse, validateWorkflowInterventionDefaultResponse, validateWorkflowAgentStepInput, validateWorkflowAgentStepOutput, snapshotWorkflowAgentStepInput, snapshotWorkflowAgentStepOutput, snapshotWorkflowInput, snapshotWorkflowStepInput, snapshotWorkflowStepOutput, snapshotWorkflowInterventionInput, snapshotWorkflowInterventionResponse, snapshotWorkflowInterventionDefaultResponse, snapshotWorkflowActionInput, WorkflowRunDispatcher, requestWorkflowRun, createBoundSixb, isBoundSixb, canInheritAgentRequestAuthorization, createAgentExecutionRecord, createInheritedAgentExecutionRecord, bindDurableAgentExecution, restoreAgentExecutionScope, assertAgentExecutionRecord, requestAgentRun, retryAgentRun };
|
|
2485
|
-
|
|
2486
|
-
//# debugId=00C5E0281CC5D43264756E2164756E21
|