@sixb/core 0.1.25 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +52 -52
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/context.d.ts +1 -0
- package/dist/actions/run/context.d.ts.map +1 -1
- package/dist/actions/run/execute.d.ts +3 -0
- package/dist/actions/run/execute.d.ts.map +1 -1
- package/dist/actions/run/executor.d.ts +3 -0
- package/dist/actions/run/executor.d.ts.map +1 -1
- package/dist/actions/run/types.d.ts +5 -0
- package/dist/actions/run/types.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +11 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/agents/adapters.d.ts +30 -4
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/approvals.d.ts +8 -0
- package/dist/agents/approvals.d.ts.map +1 -1
- package/dist/agents/attachment-keys.d.ts +25 -0
- package/dist/agents/attachment-keys.d.ts.map +1 -0
- package/dist/agents/cancel.d.ts +12 -0
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/children.d.ts.map +1 -1
- package/dist/agents/context-budget.d.ts +48 -0
- package/dist/agents/context-budget.d.ts.map +1 -0
- package/dist/agents/context-compaction.d.ts +89 -9
- package/dist/agents/context-compaction.d.ts.map +1 -1
- package/dist/agents/context-files.d.ts +12 -0
- package/dist/agents/context-files.d.ts.map +1 -0
- package/dist/agents/context-parts.d.ts +41 -0
- package/dist/agents/context-parts.d.ts.map +1 -0
- package/dist/agents/context-request.d.ts +47 -0
- package/dist/agents/context-request.d.ts.map +1 -0
- package/dist/agents/context-token-rate.d.ts +98 -0
- package/dist/agents/context-token-rate.d.ts.map +1 -0
- package/dist/agents/context-use.d.ts +51 -0
- package/dist/agents/context-use.d.ts.map +1 -0
- package/dist/agents/dispatch.d.ts +1 -9
- package/dist/agents/dispatch.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +18 -1
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.d.ts +51 -12
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +227 -85
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/inline-images.d.ts +17 -0
- package/dist/agents/inline-images.d.ts.map +1 -0
- package/dist/agents/message.d.ts +55 -0
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +25 -7
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/model-routing.d.ts +4 -1
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/request.d.ts +15 -2
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +11 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -0
- package/dist/agents/run-artifacts.d.ts +56 -0
- package/dist/agents/run-artifacts.d.ts.map +1 -0
- package/dist/agents/run-events.d.ts +50 -0
- package/dist/agents/run-events.d.ts.map +1 -0
- package/dist/agents/run-fence.d.ts +38 -0
- package/dist/agents/run-fence.d.ts.map +1 -0
- package/dist/agents/run-liveness.d.ts +36 -0
- package/dist/agents/run-liveness.d.ts.map +1 -0
- package/dist/agents/run-plan.d.ts +120 -0
- package/dist/agents/run-plan.d.ts.map +1 -0
- package/dist/agents/run-session-children.d.ts +89 -0
- package/dist/agents/run-session-children.d.ts.map +1 -0
- package/dist/agents/run-session-http.d.ts +40 -0
- package/dist/agents/run-session-http.d.ts.map +1 -0
- package/dist/agents/run-session-serve.d.ts +40 -0
- package/dist/agents/run-session-serve.d.ts.map +1 -0
- package/dist/agents/run-session-wire.d.ts +31 -0
- package/dist/agents/run-session-wire.d.ts.map +1 -0
- package/dist/agents/run-session.d.ts +241 -0
- package/dist/agents/run-session.d.ts.map +1 -0
- package/dist/agents/run-token.d.ts +40 -0
- package/dist/agents/run-token.d.ts.map +1 -0
- package/dist/agents/run-tools.d.ts +75 -0
- package/dist/agents/run-tools.d.ts.map +1 -0
- package/dist/agents/run-turn.d.ts +94 -0
- package/dist/agents/run-turn.d.ts.map +1 -0
- package/dist/agents/skills.d.ts +9 -2
- package/dist/agents/skills.d.ts.map +1 -1
- package/dist/agents/step-limits.d.ts +18 -0
- package/dist/agents/step-limits.d.ts.map +1 -0
- package/dist/agents/streams/index.d.ts +1 -1
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +2 -2
- package/dist/agents/streams/internal.d.ts +1 -1
- package/dist/agents/streams/internal.d.ts.map +1 -1
- package/dist/agents/streams/internal.js +7 -5
- package/dist/agents/streams/internal.js.map +1 -1
- package/dist/agents/streams/protocol.d.ts +37 -97
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/subagent-runs.d.ts +7 -1
- package/dist/agents/subagent-runs.d.ts.map +1 -1
- package/dist/agents/thread-context-projection.d.ts +10 -0
- package/dist/agents/thread-context-projection.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +56 -0
- package/dist/agents/tool-files.d.ts.map +1 -0
- package/dist/agents/workflow-node-session.d.ts +99 -0
- package/dist/agents/workflow-node-session.d.ts.map +1 -0
- package/dist/artifacts/frames/index.js +1 -1
- package/dist/artifacts/frames/index.js.map +1 -1
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/publish/index.d.ts +1 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +30 -30
- package/dist/auth/index.js +14 -14
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/runtime.d.ts +2 -0
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/types.d.ts +5 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +2 -0
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +2 -2
- 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 +9 -7
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/run-visibility.d.ts +17 -0
- package/dist/authorization/run-visibility.d.ts.map +1 -1
- package/dist/bootstrap/index.js +60 -58
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-0xmt5p5y.js → chunk-0g5nyx0k.js} +181 -31
- package/dist/chunk-0g5nyx0k.js.map +14 -0
- package/dist/{chunk-j936th07.js → chunk-0k1h5hmr.js} +59 -58
- package/dist/chunk-0k1h5hmr.js.map +12 -0
- package/dist/{chunk-c0vk1djt.js → chunk-165c9wm6.js} +1 -1
- package/dist/chunk-16a9dmfy.js.map +1 -1
- package/dist/{chunk-3qms4nax.js → chunk-1vg43g9q.js} +20 -20
- package/dist/{chunk-3qms4nax.js.map → chunk-1vg43g9q.js.map} +4 -4
- package/dist/{chunk-6n69k945.js → chunk-21q0j5f2.js} +2 -2
- package/dist/{chunk-24bqx0dx.js → chunk-23s66j86.js} +1 -1
- package/dist/{chunk-24bqx0dx.js.map → chunk-23s66j86.js.map} +1 -1
- package/dist/{chunk-cdk3egjj.js → chunk-2g0r46hy.js} +2 -2
- package/dist/{chunk-cdk3egjj.js.map → chunk-2g0r46hy.js.map} +1 -1
- package/dist/{chunk-fm62y49k.js → chunk-2pk5hjj9.js} +5 -3
- package/dist/{chunk-fm62y49k.js.map → chunk-2pk5hjj9.js.map} +5 -5
- package/dist/{chunk-rap5w0x0.js → chunk-31khg3g0.js} +1 -1
- package/dist/{chunk-rap5w0x0.js.map → chunk-31khg3g0.js.map} +1 -1
- package/dist/{chunk-gqm0b7vd.js → chunk-3x3bebz7.js} +182 -90
- package/dist/chunk-3x3bebz7.js.map +49 -0
- package/dist/{chunk-tdxfsg1c.js → chunk-47e09r7z.js} +2 -2
- package/dist/{chunk-tdxfsg1c.js.map → chunk-47e09r7z.js.map} +1 -1
- package/dist/chunk-4zm1k3xj.js +367 -0
- package/dist/chunk-4zm1k3xj.js.map +13 -0
- package/dist/chunk-58geavnf.js.map +1 -1
- package/dist/{chunk-npcr0228.js → chunk-5kyvrtjh.js} +1 -1
- package/dist/{chunk-npcr0228.js.map → chunk-5kyvrtjh.js.map} +1 -1
- package/dist/chunk-5taem5aw.js +290 -0
- package/dist/chunk-5taem5aw.js.map +10 -0
- package/dist/{chunk-1t6k1avb.js → chunk-6b61s40c.js} +1 -1
- package/dist/{chunk-4ymrcdbm.js → chunk-7hd2ez3q.js} +1 -1
- package/dist/{chunk-4ymrcdbm.js.map → chunk-7hd2ez3q.js.map} +1 -1
- package/dist/{chunk-4f3ydv7t.js → chunk-80nh73br.js} +1 -1
- package/dist/{chunk-4f3ydv7t.js.map → chunk-80nh73br.js.map} +1 -1
- package/dist/{chunk-m2nevja0.js → chunk-855n80en.js} +1 -1
- package/dist/{chunk-m2nevja0.js.map → chunk-855n80en.js.map} +1 -1
- package/dist/{chunk-hk38wahh.js → chunk-8dcfj58k.js} +24 -14
- package/dist/chunk-8dcfj58k.js.map +18 -0
- package/dist/{chunk-8z4726jz.js → chunk-8hvfs0fr.js} +11 -11
- package/dist/{chunk-8z4726jz.js.map → chunk-8hvfs0fr.js.map} +2 -2
- package/dist/chunk-8ncg20rd.js.map +1 -1
- package/dist/{chunk-m36fw8ft.js → chunk-8wsjr52f.js} +1 -1
- package/dist/chunk-9mab3dvg.js.map +1 -1
- package/dist/{chunk-vrf90dkv.js → chunk-9rh8ncs5.js} +2 -2
- package/dist/{chunk-vrf90dkv.js.map → chunk-9rh8ncs5.js.map} +1 -1
- package/dist/chunk-9tc8dxmn.js.map +1 -1
- package/dist/chunk-9x8dybsb.js.map +2 -2
- package/dist/chunk-a3faa34j.js.map +1 -1
- package/dist/{chunk-pgrf64hp.js → chunk-agn8d8ys.js} +1 -1
- package/dist/{chunk-2x19q6k6.js → chunk-c78jjzhy.js} +326 -159
- package/dist/chunk-c78jjzhy.js.map +18 -0
- package/dist/{chunk-6bkbyer5.js → chunk-cgznz22f.js} +3 -3
- package/dist/{chunk-6bkbyer5.js.map → chunk-cgznz22f.js.map} +1 -1
- package/dist/chunk-cwdzcv37.js.map +1 -1
- package/dist/{chunk-2fn60nvs.js → chunk-d3t26vah.js} +2 -2
- package/dist/{chunk-2fn60nvs.js.map → chunk-d3t26vah.js.map} +1 -1
- package/dist/{chunk-vhbw5sqm.js → chunk-d7v97qxq.js} +7 -1
- package/dist/chunk-d7v97qxq.js.map +10 -0
- package/dist/chunk-de5sfbc3.js +3 -0
- package/dist/chunk-de5sfbc3.js.map +9 -0
- package/dist/{chunk-65pyhyas.js → chunk-djs3hw9p.js} +7 -9
- package/dist/{chunk-65pyhyas.js.map → chunk-djs3hw9p.js.map} +2 -2
- package/dist/{chunk-n9w3n38q.js → chunk-dz7a4t3a.js} +78 -11
- package/dist/chunk-dz7a4t3a.js.map +23 -0
- package/dist/chunk-e5wf5vz0.js.map +1 -1
- package/dist/{chunk-bab05bhg.js → chunk-e7v3trpz.js} +1 -1
- package/dist/{chunk-68wghpdf.js → chunk-e99kp9jh.js} +194 -32
- package/dist/{chunk-68wghpdf.js.map → chunk-e99kp9jh.js.map} +10 -10
- package/dist/{chunk-nydf3dbe.js → chunk-edx8xcsm.js} +142 -25
- package/dist/chunk-edx8xcsm.js.map +13 -0
- package/dist/{chunk-9ntbsnke.js → chunk-ekkpzcka.js} +8 -8
- package/dist/{chunk-9ntbsnke.js.map → chunk-ekkpzcka.js.map} +2 -2
- package/dist/chunk-eptrvnby.js.map +1 -1
- package/dist/{chunk-zbc929zg.js → chunk-escedwyt.js} +9 -1
- package/dist/{chunk-zbc929zg.js.map → chunk-escedwyt.js.map} +3 -3
- package/dist/chunk-ey1nk510.js.map +1 -1
- package/dist/{chunk-vr3j63jq.js → chunk-f2w6328x.js} +79 -79
- package/dist/{chunk-vr3j63jq.js.map → chunk-f2w6328x.js.map} +4 -4
- package/dist/chunk-fb3feg1e.js.map +1 -1
- package/dist/{chunk-z3ryd53f.js → chunk-fb3m4sa1.js} +35 -11
- package/dist/{chunk-z3ryd53f.js.map → chunk-fb3m4sa1.js.map} +3 -3
- package/dist/{chunk-xe0732g0.js → chunk-fdkpkkpw.js} +94 -44
- package/dist/{chunk-xe0732g0.js.map → chunk-fdkpkkpw.js.map} +5 -5
- package/dist/chunk-ff5xkv0p.js.map +1 -1
- package/dist/{chunk-r6szek0x.js → chunk-fg1db9xx.js} +46 -139
- package/dist/chunk-fg1db9xx.js.map +10 -0
- package/dist/chunk-fntqb7qy.js.map +1 -1
- package/dist/{chunk-73v685wb.js → chunk-frsz8wxd.js} +4 -4
- package/dist/{chunk-73v685wb.js.map → chunk-frsz8wxd.js.map} +3 -3
- package/dist/{chunk-bnr4a734.js → chunk-he7g39e5.js} +26 -24
- package/dist/{chunk-bnr4a734.js.map → chunk-he7g39e5.js.map} +5 -5
- package/dist/chunk-hjy3dsws.js +4049 -0
- package/dist/chunk-hjy3dsws.js.map +45 -0
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-6y0mkhex.js → chunk-jbw70d6t.js} +2 -2
- package/dist/{chunk-6y0mkhex.js.map → chunk-jbw70d6t.js.map} +1 -1
- package/dist/{chunk-661ezhks.js → chunk-jftd33rc.js} +107 -28
- package/dist/chunk-jftd33rc.js.map +11 -0
- package/dist/{chunk-2gjj5dx3.js → chunk-jhbk10wf.js} +1 -1
- package/dist/{chunk-18sk89cg.js → chunk-jk97v21j.js} +7 -2
- package/dist/chunk-jk97v21j.js.map +10 -0
- package/dist/chunk-jmfet9r4.js.map +1 -1
- package/dist/{chunk-4y26vs3v.js → chunk-jspskey0.js} +16 -3
- package/dist/chunk-jspskey0.js.map +10 -0
- package/dist/chunk-kcqpk9w1.js.map +2 -2
- package/dist/chunk-kfee1h52.js.map +1 -1
- package/dist/{chunk-qx00vjrj.js → chunk-kwfhd1g0.js} +23 -23
- package/dist/{chunk-qx00vjrj.js.map → chunk-kwfhd1g0.js.map} +4 -4
- package/dist/{chunk-7ny9mjgm.js → chunk-m3qe54bb.js} +1 -1
- package/dist/chunk-m427qgq0.js.map +1 -1
- package/dist/chunk-mbsbxarb.js.map +1 -1
- package/dist/chunk-mmagke4x.js.map +1 -1
- package/dist/chunk-mzx71snp.js.map +1 -1
- package/dist/{chunk-vd1rk42q.js → chunk-n54k068r.js} +22 -18
- package/dist/chunk-n54k068r.js.map +12 -0
- package/dist/chunk-n8q5j6y5.js.map +1 -1
- package/dist/{chunk-97wr6p2g.js → chunk-neftrg0n.js} +9 -9
- package/dist/{chunk-97wr6p2g.js.map → chunk-neftrg0n.js.map} +4 -4
- package/dist/{chunk-07kkp2e1.js → chunk-nghc7eq0.js} +2 -2
- package/dist/{chunk-07kkp2e1.js.map → chunk-nghc7eq0.js.map} +1 -1
- package/dist/{chunk-hqsp2sx4.js → chunk-nz7815t3.js} +48 -34
- package/dist/chunk-nz7815t3.js.map +14 -0
- package/dist/{chunk-fe8zwt8b.js → chunk-peggaard.js} +2 -2
- package/dist/{chunk-1j6j0rht.js → chunk-qbrmpgvv.js} +1 -1
- package/dist/{chunk-1j6j0rht.js.map → chunk-qbrmpgvv.js.map} +1 -1
- package/dist/chunk-qf954wje.js.map +1 -1
- package/dist/{chunk-dp0cdtj2.js → chunk-qsg8rw04.js} +2 -2
- package/dist/{chunk-et017krg.js → chunk-qya541bk.js} +10374 -9471
- package/dist/chunk-qya541bk.js.map +129 -0
- package/dist/{chunk-d2m879s4.js → chunk-r1cxq7vv.js} +27 -27
- package/dist/chunk-r1cxq7vv.js.map +12 -0
- package/dist/{chunk-kyjcwqz6.js → chunk-rtkqczbr.js} +3 -1
- package/dist/{chunk-kyjcwqz6.js.map → chunk-rtkqczbr.js.map} +3 -3
- package/dist/{chunk-nzapm6p0.js → chunk-s3we74h8.js} +1 -2
- package/dist/chunk-s3we74h8.js.map +12 -0
- package/dist/{chunk-2adz0h75.js → chunk-s7xqfxs9.js} +35 -3
- package/dist/chunk-s7xqfxs9.js.map +11 -0
- package/dist/{chunk-g663fahq.js → chunk-scyq22td.js} +1 -1
- package/dist/{chunk-g663fahq.js.map → chunk-scyq22td.js.map} +1 -1
- package/dist/{chunk-yecwnwpq.js → chunk-semf1yqn.js} +92 -53
- package/dist/{chunk-yecwnwpq.js.map → chunk-semf1yqn.js.map} +10 -10
- package/dist/chunk-t5608tkq.js.map +1 -1
- package/dist/{chunk-pdt5cw8z.js → chunk-tvefbgvw.js} +5 -2
- package/dist/{chunk-pdt5cw8z.js.map → chunk-tvefbgvw.js.map} +3 -3
- package/dist/{chunk-rp9wwk7b.js → chunk-vkweppkw.js} +30 -30
- package/dist/{chunk-rp9wwk7b.js.map → chunk-vkweppkw.js.map} +4 -4
- package/dist/{chunk-45ngkxkp.js → chunk-w122ymx4.js} +2 -2
- package/dist/{chunk-45ngkxkp.js.map → chunk-w122ymx4.js.map} +1 -1
- package/dist/{chunk-48jezz3j.js → chunk-w976a4me.js} +1 -1
- package/dist/{chunk-48jezz3j.js.map → chunk-w976a4me.js.map} +1 -1
- package/dist/chunk-waqk73p1.js.map +1 -1
- package/dist/{chunk-c844dkwd.js → chunk-wx7smkn2.js} +4 -5
- package/dist/{chunk-c844dkwd.js.map → chunk-wx7smkn2.js.map} +2 -2
- package/dist/chunk-x0v3jd47.js.map +1 -1
- package/dist/{chunk-3p93tb91.js → chunk-xj97s5js.js} +105 -105
- package/dist/{chunk-3p93tb91.js.map → chunk-xj97s5js.js.map} +4 -4
- package/dist/{chunk-sqfvnvqj.js → chunk-y2x2935j.js} +3 -3
- package/dist/{chunk-sqfvnvqj.js.map → chunk-y2x2935j.js.map} +1 -1
- package/dist/{chunk-5tfev0fv.js → chunk-ytzcxtpt.js} +171 -171
- package/dist/{chunk-5tfev0fv.js.map → chunk-ytzcxtpt.js.map} +4 -4
- package/dist/chunk-yw9pyg66.js.map +1 -1
- package/dist/{chunk-62a63pr6.js → chunk-ztf5vtmp.js} +8 -8
- package/dist/{chunk-62a63pr6.js.map → chunk-ztf5vtmp.js.map} +2 -2
- package/dist/connectors/connections/authorizations.d.ts +2 -2
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/connections/tokens.d.ts +2 -2
- package/dist/connectors/connections/tokens.d.ts.map +1 -1
- package/dist/connectors/connections/validation.d.ts +5 -0
- package/dist/connectors/connections/validation.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +9 -2
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +26 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/index.d.ts +1 -1
- package/dist/datasets/index.d.ts.map +1 -1
- package/dist/datasets/lineage.d.ts +55 -0
- package/dist/datasets/lineage.d.ts.map +1 -0
- package/dist/datasets/write.js +5 -5
- package/dist/deploy/internal.js +2 -5
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/types.d.ts +8 -3
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/env/index.d.ts +36 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +17 -0
- package/dist/env/index.js.map +10 -0
- package/dist/error-reporting/internal.js +3 -3
- package/dist/errors/catalog.d.ts +8 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.js +1 -1
- package/dist/events/index.js +3 -3
- package/dist/execution/agent.d.ts +2 -2
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +55 -55
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/primitive.js +52 -52
- package/dist/execution/request-client.d.ts +21 -0
- package/dist/execution/request-client.d.ts.map +1 -0
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +54 -52
- package/dist/execution/request.js.map +3 -3
- package/dist/http/api-routes.d.ts +12 -11
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -70
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +5 -5
- package/dist/lineage/commits.d.ts +45 -0
- package/dist/lineage/commits.d.ts.map +1 -0
- package/dist/lineage/executors.d.ts +14 -0
- package/dist/lineage/executors.d.ts.map +1 -0
- package/dist/lineage/link.d.ts +10 -0
- package/dist/lineage/link.d.ts.map +1 -0
- package/dist/lineage/object.d.ts +10 -0
- package/dist/lineage/object.d.ts.map +1 -0
- package/dist/lineage/projections.d.ts +34 -0
- package/dist/lineage/projections.d.ts.map +1 -0
- package/dist/lineage/reader.d.ts +34 -0
- package/dist/lineage/reader.d.ts.map +1 -0
- package/dist/lineage/sources.d.ts +62 -0
- package/dist/lineage/sources.d.ts.map +1 -0
- package/dist/lineage/types.d.ts +140 -0
- package/dist/lineage/types.d.ts.map +1 -0
- package/dist/logging/internal.js +1 -1
- package/dist/materializer/effective/resolve.d.ts +63 -6
- package/dist/materializer/effective/resolve.d.ts.map +1 -1
- package/dist/materializer/index.js +30 -30
- package/dist/models/errors.d.ts +8 -0
- package/dist/models/errors.d.ts.map +1 -1
- package/dist/models/events.d.ts +10 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/errors.d.ts +5 -0
- package/dist/models/execution/errors.d.ts.map +1 -1
- package/dist/models/execution/index.d.ts +3 -1
- package/dist/models/execution/index.d.ts.map +1 -1
- package/dist/models/execution/index.js +60 -52
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +9 -2
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/index.d.ts +2 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +3 -3
- package/dist/models/language-call.d.ts +51 -0
- package/dist/models/language-call.d.ts.map +1 -0
- package/dist/models/language-model.d.ts +29 -2
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/objects/execution.d.ts +4 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +52 -52
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -0
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +33 -31
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +16 -0
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/link-endpoints.d.ts +11 -0
- package/dist/objects/query/link-endpoints.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts +5 -0
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +2 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts +2 -0
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/ontology/docs-markdown.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +6 -6
- package/dist/ontology/internal.js +8 -275
- package/dist/ontology/internal.js.map +3 -4
- package/dist/ontology/user-ref.d.ts +21 -3
- package/dist/ontology/user-ref.d.ts.map +1 -1
- package/dist/pipelines/index.js +34 -34
- package/dist/projections/builders.d.ts +13 -2
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +30 -30
- package/dist/projections/types.d.ts +7 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +2 -0
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/in-memory.d.ts +1 -2
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +0 -8
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/internal.js +37 -37
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +16 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/configuration.d.ts +4 -6
- package/dist/sandboxes/configuration.d.ts.map +1 -1
- package/dist/sandboxes/environment.d.ts.map +1 -1
- package/dist/sandboxes/exec.d.ts +5 -3
- package/dist/sandboxes/exec.d.ts.map +1 -1
- package/dist/sandboxes/guest-credentials.d.ts +61 -0
- package/dist/sandboxes/guest-credentials.d.ts.map +1 -0
- package/dist/sandboxes/index.d.ts +2 -0
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +23 -9
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +18 -4
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/security/grants.d.ts +1 -1
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/internal.js +1 -1
- package/dist/security/internal.js.map +1 -1
- package/dist/security/project.d.ts.map +1 -1
- package/dist/security/public.js +2 -2
- package/dist/security/types.d.ts +10 -3
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/execution.d.ts +9 -0
- package/dist/shares/execution.d.ts.map +1 -1
- package/dist/shares/index.d.ts +1 -1
- package/dist/shares/index.d.ts.map +1 -1
- package/dist/shares/internal.js +28 -28
- package/dist/shares/internal.js.map +1 -1
- package/dist/storage/action-runs/failure.js +2 -2
- package/dist/storage/agents/in-memory.d.ts +40 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +45 -1
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +34 -4
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +186 -8
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +13 -5
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +19 -2
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/in-memory.d.ts +6 -1
- package/dist/storage/ai-cost/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-cost/index.d.ts +1 -1
- package/dist/storage/ai-cost/index.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +1 -1
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +7 -5
- package/dist/storage/ai-cost/provider.js.map +1 -1
- package/dist/storage/ai-cost/types.d.ts +65 -9
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +4 -4
- package/dist/storage/ai-limits/provider.js +2 -2
- package/dist/storage/connector-connections/provider.js +1 -1
- package/dist/storage/connector-connections/provider.js.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +12 -12
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +34 -34
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.js +6 -6
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/query-preparation.d.ts +5 -0
- package/dist/storage/objects/query-preparation.d.ts.map +1 -1
- package/dist/storage/ontology/commits.d.ts +6 -1
- package/dist/storage/ontology/commits.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/commits.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +2 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +16 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +6 -1
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +4 -2
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/operation-scope.d.ts +10 -0
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +7 -3
- package/dist/storage/operation-scope.js.map +1 -1
- package/dist/storage/projection-runs/provider.js +2 -2
- package/dist/storage/share-grants/provider.js +3 -3
- package/dist/storage/types.d.ts +1 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +12 -12
- package/dist/syncs/index.js +35 -35
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/agent-token-rate-storage-contract.d.ts +14 -0
- package/dist/testing/agent-token-rate-storage-contract.d.ts.map +1 -0
- package/dist/testing/ai-model-call-groups-contract.d.ts +1 -1
- package/dist/testing/ai-model-call-groups-contract.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 +4671 -3499
- package/dist/testing/index.js.map +14 -11
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/testing/ontology-contract-fixture.d.ts +3 -3
- package/dist/testing/ontology-contract-fixture.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/sandbox-credentials-contract.d.ts +27 -0
- package/dist/testing/sandbox-credentials-contract.d.ts.map +1 -0
- package/dist/testing/sandboxes-contract.d.ts.map +1 -1
- package/dist/testing/users.d.ts +20 -0
- package/dist/testing/users.d.ts.map +1 -0
- package/dist/users/execution.d.ts +6 -2
- package/dist/users/execution.d.ts.map +1 -1
- package/dist/users/index.d.ts +1 -1
- package/dist/users/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +28 -28
- package/dist/webhooks/internal.js.map +1 -1
- package/dist/workers/index.js +1 -1
- package/dist/workers/index.js.map +1 -1
- package/dist/workflows/builders.d.ts.map +1 -1
- package/dist/workflows/index.js +58 -56
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/types.d.ts +6 -0
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +7 -1
- package/src/actions/request.ts +6 -0
- package/src/actions/run/context.ts +6 -0
- package/src/actions/run/execute.ts +8 -2
- package/src/actions/run/executor.ts +4 -0
- package/src/actions/run/types.ts +5 -0
- package/src/actions/types/context.ts +11 -0
- package/src/agents/README.md +144 -0
- package/src/agents/adapters.ts +73 -23
- package/src/agents/approvals.ts +22 -0
- package/src/agents/attachment-keys.ts +83 -0
- package/src/agents/cancel.ts +16 -1
- package/src/agents/children.ts +5 -3
- package/src/agents/context-budget.ts +121 -0
- package/src/agents/context-compaction.ts +317 -150
- package/src/agents/context-files.ts +48 -0
- package/src/agents/context-parts.ts +219 -0
- package/src/agents/context-request.ts +100 -0
- package/src/agents/context-token-rate.ts +224 -0
- package/src/agents/context-use.ts +187 -0
- package/src/agents/dispatch.ts +8 -58
- package/src/agents/execution.ts +123 -0
- package/src/agents/index.ts +173 -23
- package/src/agents/inline-images.ts +17 -0
- package/src/agents/message.ts +70 -1
- package/src/agents/model-loop.ts +209 -128
- package/src/agents/model-routing.ts +7 -2
- package/src/agents/request.ts +87 -21
- package/src/agents/run-after-finish.ts +133 -0
- package/src/agents/run-artifacts.ts +257 -0
- package/src/agents/run-events.ts +303 -0
- package/src/agents/run-fence.ts +71 -0
- package/src/agents/run-liveness.ts +122 -0
- package/src/agents/run-plan.ts +335 -0
- package/src/agents/run-session-children.ts +303 -0
- package/src/agents/run-session-http.ts +400 -0
- package/src/agents/run-session-serve.ts +603 -0
- package/src/agents/run-session-wire.ts +189 -0
- package/src/agents/run-session.ts +828 -0
- package/src/agents/run-token.ts +124 -0
- package/src/agents/run-tools.ts +188 -0
- package/src/agents/run-turn.ts +355 -0
- package/src/agents/skills.ts +9 -2
- package/src/agents/step-limits.ts +27 -0
- package/src/agents/streams/index.ts +2 -0
- package/src/agents/streams/internal.ts +2 -1
- package/src/agents/streams/protocol.ts +125 -294
- package/src/agents/subagent-runs.ts +19 -1
- package/src/agents/thread-context-projection.ts +25 -17
- package/src/agents/tool-files.ts +263 -0
- package/src/agents/workflow-node-session.ts +387 -0
- package/src/artifacts/publish/index.ts +1 -0
- package/src/auth/runtime.ts +30 -1
- package/src/auth/types.ts +5 -0
- package/src/authorization/decision.ts +5 -0
- package/src/authorization/grant-kinds.ts +8 -0
- package/src/authorization/index.ts +2 -0
- package/src/authorization/run-visibility.ts +37 -0
- package/src/connectors/connections/authorizations.ts +3 -2
- package/src/connectors/connections/service.ts +5 -1
- package/src/connectors/connections/tokens.ts +41 -5
- package/src/connectors/connections/validation.ts +21 -0
- package/src/connectors/types.ts +12 -2
- package/src/datasets/execution.ts +89 -2
- package/src/datasets/index.ts +1 -0
- package/src/datasets/lineage.ts +194 -0
- package/src/deploy/types.ts +8 -3
- package/src/deploy/validation.ts +1 -4
- package/src/env/index.ts +46 -0
- package/src/errors/catalog.ts +12 -0
- package/src/execution/agent.ts +2 -2
- package/src/execution/authorized-object-reader.ts +28 -1
- package/src/execution/index.ts +1 -0
- package/src/execution/request-client.ts +44 -0
- package/src/execution/request.ts +2 -0
- package/src/http/api-routes.ts +136 -50
- package/src/index.ts +35 -1
- package/src/lineage/README.md +107 -0
- package/src/lineage/commits.ts +173 -0
- package/src/lineage/executors.ts +103 -0
- package/src/lineage/link.ts +138 -0
- package/src/lineage/object.ts +218 -0
- package/src/lineage/projections.ts +174 -0
- package/src/lineage/reader.ts +89 -0
- package/src/lineage/sources.ts +156 -0
- package/src/lineage/types.ts +149 -0
- package/src/materializer/effective/resolve.ts +198 -50
- package/src/models/errors.ts +10 -0
- package/src/models/events.ts +13 -1
- package/src/models/execution/README.md +15 -1
- package/src/models/execution/errors.ts +14 -0
- package/src/models/execution/index.ts +3 -1
- package/src/models/execution/model-call-recorder.ts +19 -11
- package/src/models/execution.ts +9 -11
- package/src/models/index.ts +3 -0
- package/src/models/language-call.ts +247 -0
- package/src/models/language-model.ts +34 -2
- package/src/objects/execution.ts +6 -1
- package/src/objects/query/executor.ts +28 -13
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/ir.ts +16 -0
- package/src/objects/query/link-endpoints.ts +29 -0
- package/src/objects/query/normalize.ts +3 -0
- package/src/objects/query/planner.ts +5 -0
- package/src/objects/query/validate.ts +73 -3
- package/src/objects/sdk/object-set.ts +33 -1
- package/src/ontology/docs-markdown.ts +14 -0
- package/src/ontology/index.ts +1 -1
- package/src/ontology/user-ref.ts +40 -6
- package/src/projections/builders.ts +48 -4
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +10 -0
- package/src/projections/types.ts +8 -0
- package/src/projections/validation.ts +52 -6
- package/src/queues/in-memory.ts +0 -5
- package/src/queues/index.ts +0 -2
- package/src/queues/types.ts +0 -13
- package/src/runtime/create.ts +6 -0
- package/src/runtime/host.ts +1 -1
- package/src/runtime/resolve-definitions.ts +7 -0
- package/src/runtime/sixb.ts +4 -1
- package/src/runtime/types.ts +18 -0
- package/src/sandboxes/README.md +17 -6
- package/src/sandboxes/configuration.ts +7 -9
- package/src/sandboxes/environment.ts +1 -0
- package/src/sandboxes/exec.ts +36 -9
- package/src/sandboxes/guest-credentials.ts +262 -0
- package/src/sandboxes/index.ts +14 -0
- package/src/sandboxes/sandbox.ts +19 -4
- package/src/security/grants.ts +3 -0
- package/src/security/project.ts +1 -0
- package/src/security/types.ts +8 -3
- package/src/security/validation.ts +5 -4
- package/src/shares/execution.ts +35 -3
- package/src/shares/index.ts +1 -0
- package/src/storage/agents/in-memory.ts +225 -1
- package/src/storage/agents/index.ts +10 -0
- package/src/storage/agents/provider.ts +270 -12
- package/src/storage/agents/types.ts +195 -7
- package/src/storage/ai-cost/analytics.ts +177 -10
- package/src/storage/ai-cost/groups.ts +122 -35
- package/src/storage/ai-cost/in-memory.ts +10 -4
- package/src/storage/ai-cost/index.ts +5 -0
- package/src/storage/ai-cost/provider.ts +5 -1
- package/src/storage/ai-cost/types.ts +65 -9
- package/src/storage/in-memory/index.ts +10 -0
- package/src/storage/index.ts +17 -0
- package/src/storage/objects/in-memory/query.ts +5 -1
- package/src/storage/objects/query-preparation.ts +10 -0
- package/src/storage/ontology/commits.ts +6 -1
- package/src/storage/ontology/in-memory/commits.ts +7 -0
- package/src/storage/ontology/in-memory/materializations.ts +24 -0
- package/src/storage/ontology/index.ts +2 -0
- package/src/storage/ontology/materializations.ts +21 -0
- package/src/storage/ontology/provider.ts +41 -1
- package/src/storage/operation-scope.ts +41 -0
- package/src/storage/types.ts +1 -0
- package/src/testing/agent-storage-contract.ts +581 -2
- package/src/testing/agent-token-rate-storage-contract.ts +171 -0
- package/src/testing/ai-model-call-groups-contract.ts +225 -8
- package/src/testing/index.ts +10 -0
- package/src/testing/materializer-storage-contract.ts +294 -10
- package/src/testing/object-query-contract.ts +48 -0
- package/src/testing/ontology-contract-fixture.ts +18 -7
- package/src/testing/ontology-storage-contract.ts +42 -0
- package/src/testing/queues-contract.ts +0 -16
- package/src/testing/sandbox-credentials-contract.ts +284 -0
- package/src/testing/sandboxes-contract.ts +21 -0
- package/src/testing/users.ts +39 -0
- package/src/users/execution.ts +33 -7
- package/src/users/index.ts +7 -1
- package/src/workflows/builders.ts +8 -1
- package/src/workflows/types.ts +6 -0
- package/src/workflows/validation.ts +1 -0
- package/dist/agents/api-gateway.d.ts +0 -26
- package/dist/agents/api-gateway.d.ts.map +0 -1
- package/dist/chunk-0xmt5p5y.js.map +0 -14
- package/dist/chunk-18sk89cg.js.map +0 -10
- package/dist/chunk-2adz0h75.js.map +0 -11
- package/dist/chunk-2x19q6k6.js.map +0 -17
- package/dist/chunk-4y26vs3v.js.map +0 -10
- package/dist/chunk-661ezhks.js.map +0 -11
- package/dist/chunk-d2m879s4.js.map +0 -12
- package/dist/chunk-et017krg.js.map +0 -120
- package/dist/chunk-gqm0b7vd.js.map +0 -48
- package/dist/chunk-hk38wahh.js.map +0 -18
- package/dist/chunk-hqsp2sx4.js.map +0 -14
- package/dist/chunk-j936th07.js.map +0 -12
- package/dist/chunk-n9w3n38q.js.map +0 -23
- package/dist/chunk-nydf3dbe.js.map +0 -13
- package/dist/chunk-nzapm6p0.js.map +0 -12
- package/dist/chunk-r6szek0x.js.map +0 -10
- package/dist/chunk-vabga7fk.js +0 -176
- package/dist/chunk-vabga7fk.js.map +0 -12
- package/dist/chunk-vd1rk42q.js.map +0 -12
- package/dist/chunk-vhbw5sqm.js.map +0 -10
- package/dist/chunk-vpgwq5nf.js +0 -810
- package/dist/chunk-vpgwq5nf.js.map +0 -21
- package/src/agents/api-gateway.ts +0 -68
- /package/dist/{chunk-c0vk1djt.js.map → chunk-165c9wm6.js.map} +0 -0
- /package/dist/{chunk-6n69k945.js.map → chunk-21q0j5f2.js.map} +0 -0
- /package/dist/{chunk-1t6k1avb.js.map → chunk-6b61s40c.js.map} +0 -0
- /package/dist/{chunk-m36fw8ft.js.map → chunk-8wsjr52f.js.map} +0 -0
- /package/dist/{chunk-pgrf64hp.js.map → chunk-agn8d8ys.js.map} +0 -0
- /package/dist/{chunk-bab05bhg.js.map → chunk-e7v3trpz.js.map} +0 -0
- /package/dist/{chunk-2gjj5dx3.js.map → chunk-jhbk10wf.js.map} +0 -0
- /package/dist/{chunk-7ny9mjgm.js.map → chunk-m3qe54bb.js.map} +0 -0
- /package/dist/{chunk-fe8zwt8b.js.map → chunk-peggaard.js.map} +0 -0
- /package/dist/{chunk-dp0cdtj2.js.map → chunk-qsg8rw04.js.map} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/ai-usage/in-memory.ts", "../src/storage/ai-cost/analytics.ts", "../src/storage/ai-cost/attribution.ts", "../src/storage/ai-cost/groups.ts", "../src/storage/ai-cost/validation.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ExecutionStorage } from \"../executions\"\nimport { AiUsageStorageError } from \"./errors\"\nimport {\n assertAiUsageExecutionId,\n assertSameCallExecution,\n normalizeAiModelCallFilesRecord,\n normalizeAiModelCallRecord,\n} from \"./record\"\nimport type {\n AiModelCallFilesRecord,\n AiModelCallUsageRecord,\n AiUsageExecutionSummary,\n AiUsageStorage,\n GetAiModelCallFilesInput,\n GetLatestAiModelCallForExecutionInput,\n RecordAiModelCallFilesInput,\n RecordAiModelCallInput,\n RecordAiModelCallResult,\n SummarizeAiUsageExecutionInput,\n SummarizeAiUsageExecutionsInput,\n} from \"./types\"\nimport { aggregateAiModelCallUsage } from \"./usage\"\n\nexport interface InMemoryAiUsageGroupRow {\n readonly projectId: string\n readonly usageRecordId: string\n readonly groupId: string\n readonly occurredAt: Date\n}\n\nexport interface InMemoryAiUsageStorageSnapshot {\n readonly records: Map<string, AiModelCallUsageRecord>\n readonly recordKeysByIdempotencyKey: Map<string, string>\n readonly groupRows: Map<string, InMemoryAiUsageGroupRow>\n readonly callFiles: Map<string, AiModelCallFilesRecord>\n}\n\n/** In-memory model-call ledger used by development runtimes and storage contract tests. */\nexport class InMemoryAiUsageStorage implements AiUsageStorage {\n private readonly records = new Map<string, AiModelCallUsageRecord>()\n private readonly recordKeysByIdempotencyKey = new Map<string, string>()\n private readonly groupRows = new Map<string, InMemoryAiUsageGroupRow>()\n private readonly callFiles = new Map<string, AiModelCallFilesRecord>()\n\n constructor(private readonly executions: Pick<ExecutionStorage, \"getById\">) {}\n\n async recordModelCall(input: RecordAiModelCallInput): Promise<RecordAiModelCallResult> {\n const record = normalizeAiModelCallRecord(input)\n await this.assertExecutionExists(record.projectId, record.executionId)\n const idempotencyKey = modelCallIdempotencyKey(record)\n const existingRecordKey = this.recordKeysByIdempotencyKey.get(idempotencyKey)\n if (existingRecordKey !== undefined) {\n const existing = this.records.get(existingRecordKey)\n if (!existing) {\n throw new Error(\"[Sixb] In-memory AI usage idempotency index is inconsistent.\")\n }\n return { record: structuredClone(existing), created: false }\n }\n\n const recordKey = modelCallRecordKey(record.projectId, record.id)\n if (this.records.has(recordKey)) {\n throw new AiUsageStorageError(\n \"duplicate_id\",\n `[Sixb] AI usage record '${record.id}' already exists for project '${record.projectId}'.`\n )\n }\n\n this.records.set(recordKey, structuredClone(record))\n this.recordKeysByIdempotencyKey.set(idempotencyKey, recordKey)\n for (const groupId of record.requesterGroupIds) {\n const row: InMemoryAiUsageGroupRow = {\n projectId: record.projectId,\n usageRecordId: record.id,\n groupId,\n occurredAt: record.occurredAt,\n }\n this.groupRows.set(groupRowKey(row), row)\n }\n\n return { record: structuredClone(record), created: true }\n }\n\n async getLatestForExecution(\n input: GetLatestAiModelCallForExecutionInput\n ): Promise<AiModelCallUsageRecord | null> {\n assertAiUsageExecutionId(input.executionId)\n if (typeof input.projectId !== \"string\" || input.projectId.trim().length === 0) {\n throw new TypeError(\"[Sixb] AI usage projectId must be nonblank.\")\n }\n\n let latest: AiModelCallUsageRecord | null = null\n for (const record of this.records.values()) {\n if (record.projectId !== input.projectId || record.executionId !== input.executionId) continue\n if (\n !latest ||\n record.occurredAt.getTime() > latest.occurredAt.getTime() ||\n (record.occurredAt.getTime() === latest.occurredAt.getTime() && record.id > latest.id)\n ) {\n latest = record\n }\n }\n return latest ? structuredClone(latest) : null\n }\n\n async summarizeExecution(\n input: SummarizeAiUsageExecutionInput\n ): Promise<AiUsageExecutionSummary> {\n const [summary] = await this.summarizeExecutions({\n projectId: input.projectId,\n executionIds: [input.executionId],\n })\n return summary!\n }\n\n async summarizeExecutions(\n input: SummarizeAiUsageExecutionsInput\n ): Promise<readonly AiUsageExecutionSummary[]> {\n if (typeof input.projectId !== \"string\" || input.projectId.trim().length === 0) {\n throw new TypeError(\"[Sixb] AI usage projectId must be nonblank.\")\n }\n\n const usageByExecutionId = new Map<string, AiModelCallUsageRecord[\"usage\"][]>()\n for (const executionId of input.executionIds) {\n assertAiUsageExecutionId(executionId)\n usageByExecutionId.set(executionId, [])\n }\n if (usageByExecutionId.size === 0) return []\n\n for (const record of this.records.values()) {\n if (record.projectId !== input.projectId) continue\n usageByExecutionId.get(record.executionId)?.push(record.usage)\n }\n\n return input.executionIds.map((executionId) => {\n const usages = usageByExecutionId.get(executionId) ?? []\n return {\n modelCallCount: usages.length,\n usage: aggregateAiModelCallUsage(usages),\n }\n })\n }\n\n async recordModelCallFiles(input: RecordAiModelCallFilesInput): Promise<AiModelCallFilesRecord> {\n const record = normalizeAiModelCallFilesRecord(input)\n const key = modelCallRecordKey(record.projectId, record.callId)\n const existing = this.callFiles.get(key)\n if (existing) return structuredClone(assertSameCallExecution(existing, record))\n await this.assertExecutionExists(record.projectId, record.executionId)\n this.callFiles.set(key, structuredClone(record))\n return structuredClone(record)\n }\n\n async getModelCallFiles(input: GetAiModelCallFilesInput): Promise<AiModelCallFilesRecord | null> {\n const record = this.callFiles.get(modelCallRecordKey(input.projectId, input.callId))\n return record ? structuredClone(record) : null\n }\n\n snapshot(): InMemoryAiUsageStorageSnapshot {\n return structuredClone({\n records: this.records,\n recordKeysByIdempotencyKey: this.recordKeysByIdempotencyKey,\n groupRows: this.groupRows,\n callFiles: this.callFiles,\n })\n }\n\n restore(snapshot: InMemoryAiUsageStorageSnapshot): void {\n replaceMap(this.records, snapshot.records)\n replaceMap(this.recordKeysByIdempotencyKey, snapshot.recordKeysByIdempotencyKey)\n replaceMap(this.groupRows, snapshot.groupRows)\n replaceMap(this.callFiles, snapshot.callFiles)\n }\n\n /** @internal Immutable accounting source used by in-memory AI limit enforcement. */\n getRecord(projectId: string, id: string): AiModelCallUsageRecord | null {\n const record = this.records.get(modelCallRecordKey(projectId, id))\n return record ? structuredClone(record) : null\n }\n\n /** @internal Immutable accounting source used by in-memory AI limit status reads. */\n listRecords(projectId: string): readonly AiModelCallUsageRecord[] {\n return [...this.records.values()]\n .filter((record) => record.projectId === projectId)\n .map((record) => structuredClone(record))\n }\n\n private async assertExecutionExists(projectId: string, executionId: string): Promise<void> {\n const execution = await this.executions.getById({ projectId, id: executionId })\n if (execution) return\n throw new AiUsageStorageError(\n \"missing_execution\",\n `[Sixb] AI usage execution '${executionId}' does not exist in project '${projectId}'.`\n )\n }\n}\n\nfunction modelCallRecordKey(projectId: string, id: string): string {\n return JSON.stringify([projectId, id])\n}\n\nfunction modelCallIdempotencyKey(\n record: Pick<\n AiModelCallUsageRecord,\n \"projectId\" | \"executionId\" | \"attempt\" | \"callId\" | \"responseId\"\n >\n): string {\n return JSON.stringify([\n record.projectId,\n record.executionId,\n record.attempt,\n record.callId,\n record.responseId,\n ])\n}\n\nfunction groupRowKey(row: InMemoryAiUsageGroupRow): string {\n return JSON.stringify([row.projectId, row.usageRecordId, row.groupId])\n}\n\nfunction replaceMap<TKey, TValue>(target: Map<TKey, TValue>, source: Map<TKey, TValue>): void {\n target.clear()\n for (const [key, value] of structuredClone(source)) {\n target.set(key, value)\n }\n}\n",
|
|
6
|
-
"import { MODEL_KINDS, type ModelKind } from \"../../models/definitions\"\nimport { type AiModelCallUsageRecord, normalizeAiModelCallUsage } from \"../ai-usage\"\nimport type {\n AiAccountingAgentBreakdown,\n AiAccountingAggregate,\n AiAccountingAttribution,\n AiAccountingBucket,\n AiAccountingKindBreakdown,\n AiAccountingModelBreakdown,\n AiAccountingOverview,\n AiAccountingTimeBucket,\n AiAccountingWorkflowBreakdown,\n AiCostSummary,\n AiModelCallAccountingItem,\n AiModelCallCostRecord,\n AiMoney,\n ListAiModelCallAccountingInput,\n ListAiModelCallAccountingResult,\n QueryAiAccountingOverviewInput,\n} from \"./types\"\n\nconst DEFAULT_MODEL_CALL_PAGE_SIZE = 50\nconst MAX_MODEL_CALL_PAGE_SIZE = 200\nconst MAX_CHART_BUCKETS = 10_000\n\n/** One joined immutable model-call row used by in-memory analytics and bounded SQL pages. */\nexport interface AiAccountingRecordSetItem {\n readonly usage: AiModelCallUsageRecord\n readonly attribution?: AiAccountingAttribution\n readonly cost?: AiModelCallCostRecord\n}\n\nexport interface NormalizedAiAccountingQuery {\n readonly projectId: string\n readonly from: Date\n readonly to: Date\n readonly providerId?: string\n readonly modelId?: string\n}\n\nexport interface NormalizedAiModelCallAccountingQuery extends NormalizedAiAccountingQuery {\n readonly executionId?: string\n readonly valuationStatus?: ListAiModelCallAccountingInput[\"valuationStatus\"]\n readonly limit: number\n readonly offset: number\n}\n\ninterface AiAccountingUsageMeterFragment {\n readonly presentCallCount: string\n readonly total: string | null\n}\n\n/** One SQL-aggregated currency fragment; providers merge fragments without loading model calls. */\nexport interface AiAccountingAggregateFragment {\n readonly dimension: \"totals\" | \"series\" | \"model\" | \"kind\" | \"agent\" | \"workflow\"\n readonly start?: Date\n readonly providerId?: string\n readonly modelId?: string\n /** The `kind` dimension's key; absent for calls recorded before their kind was captured. */\n readonly modelKind?: ModelKind\n readonly agentKind?: \"agent\" | \"workflowAgent\"\n readonly agentStepId?: string\n readonly workflowId?: string\n readonly modelCallCount: string\n readonly usage: {\n readonly reportedCallCount: string\n readonly completeCallCount: string\n readonly inputTokens: AiAccountingUsageMeterFragment\n readonly outputTokens: AiAccountingUsageMeterFragment\n readonly uncachedInputTokens: AiAccountingUsageMeterFragment\n readonly cacheReadInputTokens: AiAccountingUsageMeterFragment\n readonly cacheWriteInputTokens: AiAccountingUsageMeterFragment\n readonly textOutputTokens: AiAccountingUsageMeterFragment\n readonly reasoningOutputTokens: AiAccountingUsageMeterFragment\n readonly audioDurationMs: AiAccountingUsageMeterFragment\n readonly imageOutputTokens: AiAccountingUsageMeterFragment\n readonly audioOutputTokens: AiAccountingUsageMeterFragment\n readonly outputImages: AiAccountingUsageMeterFragment\n readonly inputCharacters: AiAccountingUsageMeterFragment\n }\n readonly costs: {\n readonly amount?: AiMoney\n readonly ratedCallCount: string\n readonly unpriceableCallCount: string\n readonly unvaluedCallCount: string\n }\n}\n\nexport function normalizeAiAccountingQuery(\n input: Omit<QueryAiAccountingOverviewInput, \"bucket\"> | ListAiModelCallAccountingInput\n): NormalizedAiAccountingQuery {\n assertNonBlank(input.projectId, \"accounting projectId\")\n assertDate(input.from, \"accounting from\")\n assertDate(input.to, \"accounting to\")\n if (input.from.getTime() >= input.to.getTime()) {\n throw new TypeError(\"[Sixb] AI accounting from must be before to.\")\n }\n if (input.providerId !== undefined) assertNonBlank(input.providerId, \"accounting providerId\")\n if (input.modelId !== undefined) assertNonBlank(input.modelId, \"accounting modelId\")\n return {\n projectId: input.projectId,\n from: new Date(input.from),\n to: new Date(input.to),\n ...(input.providerId === undefined ? {} : { providerId: input.providerId }),\n ...(input.modelId === undefined ? {} : { modelId: input.modelId }),\n }\n}\n\nexport function normalizeAiModelCallAccountingQuery(\n input: ListAiModelCallAccountingInput\n): NormalizedAiModelCallAccountingQuery {\n const query = normalizeAiAccountingQuery(input)\n if (input.executionId !== undefined) {\n assertNonBlank(input.executionId, \"accounting executionId\")\n }\n const { limit, offset } = normalizePage(input.limit, input.offset)\n return {\n ...query,\n ...(input.executionId === undefined ? {} : { executionId: input.executionId }),\n ...(input.valuationStatus === undefined ? {} : { valuationStatus: input.valuationStatus }),\n limit,\n offset,\n }\n}\n\nexport function aiAccountingItemMatchesQuery(\n item: AiAccountingRecordSetItem,\n query: NormalizedAiAccountingQuery\n): boolean {\n const occurredAt = item.usage.occurredAt.getTime()\n return (\n item.usage.projectId === query.projectId &&\n occurredAt >= query.from.getTime() &&\n occurredAt < query.to.getTime() &&\n (query.providerId === undefined || item.usage.providerId === query.providerId) &&\n (query.modelId === undefined || item.usage.requestedModelId === query.modelId)\n )\n}\n\nexport function buildAiAccountingOverview(\n input: QueryAiAccountingOverviewInput,\n source: Iterable<AiAccountingRecordSetItem>\n): AiAccountingOverview {\n const query = normalizeAiAccountingQuery(input)\n assertAiAccountingBucket(input.bucket)\n const items = Array.from(source).filter((item) => aiAccountingItemMatchesQuery(item, query))\n const periods = accountingPeriods(query.from, query.to, input.bucket)\n const periodItems = new Map<number, AiAccountingRecordSetItem[]>(\n periods.map((period) => [period.start.getTime(), []])\n )\n const modelItems = new Map<string, AiAccountingRecordSetItem[]>()\n // An empty key collects calls recorded before their kind was captured.\n const kindItems = new Map<ModelKind | \"\", AiAccountingRecordSetItem[]>()\n const agentItems = new Map<string, AiAccountingRecordSetItem[]>()\n const workflowItems = new Map<string, AiAccountingRecordSetItem[]>()\n\n for (const item of items) {\n const periodStart = aiAccountingBucketStart(item.usage.occurredAt, input.bucket).getTime()\n periodItems.get(periodStart)?.push(item)\n appendGrouped(\n modelItems,\n JSON.stringify([item.usage.providerId, item.usage.requestedModelId]),\n item\n )\n appendGrouped(kindItems, item.usage.modelKind ?? \"\", item)\n if (item.attribution?.kind === \"agent\") {\n appendGrouped(agentItems, JSON.stringify([\"agent\"]), item)\n } else if (item.attribution?.kind === \"workflowAgent\") {\n appendGrouped(\n agentItems,\n JSON.stringify([\n \"workflowAgent\",\n item.attribution.workflowId,\n item.attribution.agentStepId,\n ]),\n item\n )\n }\n if (item.attribution?.kind === \"workflowAgent\" || item.attribution?.kind === \"workflow\") {\n appendGrouped(workflowItems, item.attribution.workflowId, item)\n }\n }\n\n const series: AiAccountingTimeBucket[] = periods.map((period) => ({\n ...period,\n ...aggregateAccountingItems(periodItems.get(period.start.getTime()) ?? []),\n }))\n const models: AiAccountingModelBreakdown[] = [...modelItems]\n .map(([key, grouped]) => {\n const [providerId, modelId] = JSON.parse(key) as [string, string]\n return { providerId, modelId, ...aggregateAccountingItems(grouped) }\n })\n .sort(compareModelBreakdowns)\n const kinds: AiAccountingKindBreakdown[] = [...kindItems]\n .map(([kind, grouped]) => kindBreakdown(kind, aggregateAccountingItems(grouped)))\n .sort(compareKindBreakdowns)\n const agents: AiAccountingAgentBreakdown[] = [...agentItems]\n .map(([key, grouped]) => {\n const [kind, workflowId, agentStepId] = JSON.parse(key) as [\n \"agent\" | \"workflowAgent\",\n string?,\n string?,\n ]\n return kind === \"agent\"\n ? { kind, ...aggregateAccountingItems(grouped) }\n : {\n kind,\n workflowId: requiredFragmentString(workflowId, \"workflowId\"),\n agentStepId: requiredFragmentString(agentStepId, \"agentStepId\"),\n ...aggregateAccountingItems(grouped),\n }\n })\n .sort(compareAgentBreakdowns)\n const workflows: AiAccountingWorkflowBreakdown[] = [...workflowItems]\n .map(([workflowId, grouped]) => ({ workflowId, ...aggregateAccountingItems(grouped) }))\n .sort(compareWorkflowBreakdowns)\n\n return structuredClone({\n range: { from: query.from, to: query.to },\n bucket: input.bucket,\n totals: aggregateAccountingItems(items),\n series,\n models,\n kinds,\n agents,\n workflows,\n })\n}\n\n/** A stored `kind` dimension key; null for calls recorded before their kind was captured. */\nexport function aiAccountingModelKind(value: string | null): ModelKind | undefined {\n if (value === null) return undefined\n const kind = MODEL_KINDS.find((candidate) => candidate === value)\n if (!kind) throw new TypeError(`[Sixb] AI accounting returned an unknown model kind '${value}'.`)\n return kind\n}\n\nexport function buildAiAccountingOverviewFromFragments(\n input: QueryAiAccountingOverviewInput,\n fragments: Iterable<AiAccountingAggregateFragment>\n): AiAccountingOverview {\n const query = normalizeAiAccountingQuery(input)\n const periods = accountingPeriods(query.from, query.to, input.bucket)\n const totals = aggregateFragmentAccumulator()\n const series = new Map<number, AggregateFragmentAccumulator>(\n periods.map((period) => [period.start.getTime(), aggregateFragmentAccumulator()])\n )\n const models = new Map<string, AggregateFragmentAccumulator>()\n const kinds = new Map<ModelKind | \"\", AggregateFragmentAccumulator>()\n const agents = new Map<string, AggregateFragmentAccumulator>()\n const workflows = new Map<string, AggregateFragmentAccumulator>()\n\n for (const fragment of fragments) {\n let target: AggregateFragmentAccumulator\n switch (fragment.dimension) {\n case \"totals\":\n target = totals\n break\n case \"series\": {\n const start = requiredFragmentDate(fragment.start, \"series start\")\n const existing = series.get(start.getTime())\n if (!existing) {\n throw new TypeError(\"[Sixb] AI accounting SQL series returned an unexpected bucket.\")\n }\n target = existing\n break\n }\n case \"model\":\n target = getFragmentAccumulator(\n models,\n JSON.stringify([\n requiredFragmentString(fragment.providerId, \"providerId\"),\n requiredFragmentString(fragment.modelId, \"modelId\"),\n ])\n )\n break\n case \"kind\":\n target = getFragmentAccumulator(kinds, fragment.modelKind ?? \"\")\n break\n case \"agent\":\n target = getFragmentAccumulator(\n agents,\n JSON.stringify([\n requiredFragmentString(fragment.agentKind, \"agentKind\"),\n fragment.workflowId,\n fragment.agentStepId,\n ])\n )\n break\n case \"workflow\":\n target = getFragmentAccumulator(\n workflows,\n requiredFragmentString(fragment.workflowId, \"workflowId\")\n )\n break\n }\n appendAggregateFragment(target, fragment)\n }\n\n return structuredClone({\n range: { from: query.from, to: query.to },\n bucket: input.bucket,\n totals: finishAggregateFragment(totals),\n series: periods.map((period) => ({\n ...period,\n ...finishAggregateFragment(series.get(period.start.getTime())!),\n })),\n models: [...models]\n .map(([key, value]) => {\n const [providerId, modelId] = JSON.parse(key) as [string, string]\n return { providerId, modelId, ...finishAggregateFragment(value) }\n })\n .sort(compareModelBreakdowns),\n kinds: [...kinds]\n .map(([kind, value]) => kindBreakdown(kind, finishAggregateFragment(value)))\n .sort(compareKindBreakdowns),\n agents: [...agents]\n .map(([key, value]) => {\n const [kind, workflowId, agentStepId] = JSON.parse(key) as [\n \"agent\" | \"workflowAgent\",\n string?,\n string?,\n ]\n return kind === \"agent\"\n ? { kind, ...finishAggregateFragment(value) }\n : {\n kind,\n workflowId: requiredFragmentString(workflowId, \"workflowId\"),\n agentStepId: requiredFragmentString(agentStepId, \"agentStepId\"),\n ...finishAggregateFragment(value),\n }\n })\n .sort(compareAgentBreakdowns),\n workflows: [...workflows]\n .map(([workflowId, value]) => ({ workflowId, ...finishAggregateFragment(value) }))\n .sort(compareWorkflowBreakdowns),\n })\n}\n\nexport function buildAiModelCallAccountingList(\n input: ListAiModelCallAccountingInput,\n source: Iterable<AiAccountingRecordSetItem>\n): ListAiModelCallAccountingResult {\n const query = normalizeAiModelCallAccountingQuery(input)\n const { limit, offset } = query\n const items = Array.from(source)\n .filter((item) => aiAccountingItemMatchesQuery(item, query))\n .map(toAccountingItem)\n .filter(\n (item) =>\n (input.executionId === undefined || item.usage.executionId === input.executionId) &&\n (input.valuationStatus === undefined || item.valuationStatus === input.valuationStatus)\n )\n .sort(compareAccountingItems)\n const page = items.slice(offset, offset + limit)\n return structuredClone({\n items: page,\n hasMore: offset + page.length < items.length,\n total: items.length,\n })\n}\n\nexport function toAccountingItem(item: AiAccountingRecordSetItem): AiModelCallAccountingItem {\n return {\n usage: item.usage,\n ...(item.attribution === undefined ? {} : { attribution: item.attribution }),\n ...(item.cost === undefined ? {} : { cost: item.cost }),\n valuationStatus: item.cost?.status ?? \"unvalued\",\n }\n}\n\nexport function aiAccountingBucketStart(at: Date, bucket: AiAccountingBucket): Date {\n assertDate(at, \"accounting bucket timestamp\")\n assertAiAccountingBucket(bucket)\n const start = new Date(at)\n start.setUTCMinutes(0, 0, 0)\n if (bucket === \"hour\") return start\n start.setUTCHours(0)\n if (bucket === \"day\") return start\n const mondayOffset = (start.getUTCDay() + 6) % 7\n start.setUTCDate(start.getUTCDate() - mondayOffset)\n return start\n}\n\nfunction aggregateAccountingItems(\n items: readonly AiAccountingRecordSetItem[]\n): AiAccountingAggregate {\n const value = aggregateFragmentAccumulator()\n value.modelCallCount = BigInt(items.length)\n for (const item of items) {\n const usage = normalizeAiModelCallUsage(item.usage.usage)\n if (usage.reportingStatus !== \"unavailable\") value.reportedUsageCallCount += 1n\n if (usage.reportingStatus === \"complete\") value.completeUsageCallCount += 1n\n for (const field of AGGREGATE_USAGE_FIELDS) {\n if (usage[field] === undefined) continue\n value.usage[field].presentCallCount += 1n\n value.usage[field].total += BigInt(usage[field])\n }\n }\n return {\n modelCallCount: items.length,\n ...finishAggregateUsage(value),\n costs: aggregateCosts(items),\n }\n}\n\nfunction aggregateCosts(items: readonly AiAccountingRecordSetItem[]): AiCostSummary {\n const amounts = new Map<string, bigint>()\n let ratedCallCount = 0\n let unpriceableCallCount = 0\n let unvaluedCallCount = 0\n for (const item of items) {\n if (item.cost?.status === \"rated\") {\n ratedCallCount += 1\n addAmount(amounts, item.cost.money.currency, item.cost.money.amountNanos)\n } else if (item.cost?.status === \"unpriceable\") {\n unpriceableCallCount += 1\n } else {\n unvaluedCallCount += 1\n }\n }\n return {\n amounts: [...amounts]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([currency, amountNanos]) => ({ currency, amountNanos: amountNanos.toString() })),\n ratedCallCount,\n unpriceableCallCount,\n unvaluedCallCount,\n }\n}\n\nconst AGGREGATE_USAGE_FIELDS = [\n \"inputTokens\",\n \"outputTokens\",\n \"uncachedInputTokens\",\n \"cacheReadInputTokens\",\n \"cacheWriteInputTokens\",\n \"textOutputTokens\",\n \"reasoningOutputTokens\",\n \"audioDurationMs\",\n \"imageOutputTokens\",\n \"audioOutputTokens\",\n \"outputImages\",\n \"inputCharacters\",\n] as const\n\ntype AggregateUsageField = (typeof AGGREGATE_USAGE_FIELDS)[number]\n\ninterface AggregateFragmentAccumulator {\n modelCallCount: bigint\n reportedUsageCallCount: bigint\n completeUsageCallCount: bigint\n usage: Record<AggregateUsageField, { presentCallCount: bigint; total: bigint }>\n amounts: Map<string, bigint>\n ratedCallCount: bigint\n unpriceableCallCount: bigint\n unvaluedCallCount: bigint\n}\n\nfunction aggregateFragmentAccumulator(): AggregateFragmentAccumulator {\n return {\n modelCallCount: 0n,\n reportedUsageCallCount: 0n,\n completeUsageCallCount: 0n,\n usage: Object.fromEntries(\n AGGREGATE_USAGE_FIELDS.map((field) => [field, { presentCallCount: 0n, total: 0n }])\n ) as AggregateFragmentAccumulator[\"usage\"],\n amounts: new Map(),\n ratedCallCount: 0n,\n unpriceableCallCount: 0n,\n unvaluedCallCount: 0n,\n }\n}\n\nfunction getFragmentAccumulator<TKey extends string>(\n values: Map<TKey, AggregateFragmentAccumulator>,\n key: TKey\n): AggregateFragmentAccumulator {\n const existing = values.get(key)\n if (existing) return existing\n const created = aggregateFragmentAccumulator()\n values.set(key, created)\n return created\n}\n\nfunction appendAggregateFragment(\n target: AggregateFragmentAccumulator,\n fragment: AiAccountingAggregateFragment\n): void {\n target.modelCallCount += naturalBigInt(fragment.modelCallCount, \"modelCallCount\")\n target.reportedUsageCallCount += naturalBigInt(\n fragment.usage.reportedCallCount,\n \"reported usage call count\"\n )\n target.completeUsageCallCount += naturalBigInt(\n fragment.usage.completeCallCount,\n \"complete usage call count\"\n )\n for (const field of AGGREGATE_USAGE_FIELDS) {\n const source = fragment.usage[field]\n const presentCallCount = naturalBigInt(source.presentCallCount, `${field} call count`)\n target.usage[field].presentCallCount += presentCallCount\n if (source.total !== null) {\n target.usage[field].total += naturalBigInt(source.total, `${field} total`)\n } else if (presentCallCount !== 0n) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} total is missing.`)\n }\n }\n target.ratedCallCount += naturalBigInt(fragment.costs.ratedCallCount, \"rated call count\")\n target.unpriceableCallCount += naturalBigInt(\n fragment.costs.unpriceableCallCount,\n \"unpriceable call count\"\n )\n target.unvaluedCallCount += naturalBigInt(fragment.costs.unvaluedCallCount, \"unvalued call count\")\n if (fragment.costs.amount) {\n addAmount(target.amounts, fragment.costs.amount.currency, fragment.costs.amount.amountNanos)\n }\n}\n\nfunction finishAggregateFragment(value: AggregateFragmentAccumulator): AiAccountingAggregate {\n const classifiedCallCount =\n value.ratedCallCount + value.unpriceableCallCount + value.unvaluedCallCount\n if (\n classifiedCallCount !== value.modelCallCount ||\n value.reportedUsageCallCount > value.modelCallCount ||\n value.completeUsageCallCount > value.reportedUsageCallCount ||\n AGGREGATE_USAGE_FIELDS.some(\n (field) => value.usage[field].presentCallCount > value.modelCallCount\n )\n ) {\n throw new TypeError(\"[Sixb] AI accounting SQL aggregate counts are inconsistent.\")\n }\n const modelCallCount = safeAggregateNumber(value.modelCallCount, \"model-call count\")\n return {\n modelCallCount,\n ...finishAggregateUsage(value),\n costs: {\n amounts: [...value.amounts]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([currency, amountNanos]) => ({ currency, amountNanos: amountNanos.toString() })),\n ratedCallCount: safeAggregateNumber(value.ratedCallCount, \"rated call count\"),\n unpriceableCallCount: safeAggregateNumber(\n value.unpriceableCallCount,\n \"unpriceable call count\"\n ),\n unvaluedCallCount: safeAggregateNumber(value.unvaluedCallCount, \"unvalued call count\"),\n },\n }\n}\n\nfunction finishAggregateUsage(\n value: AggregateFragmentAccumulator\n): Pick<AiAccountingAggregate, \"usage\" | \"usageCoverage\"> {\n const counts: Partial<Record<AggregateUsageField | \"totalTokens\", number>> = {}\n const fieldCallCounts = {} as Record<AggregateUsageField, number>\n for (const field of AGGREGATE_USAGE_FIELDS) {\n const aggregate = value.usage[field]\n fieldCallCounts[field] = safeAggregateNumber(aggregate.presentCallCount, `${field} call count`)\n if (aggregate.presentCallCount > 0n) {\n counts[field] = safeAggregateNumber(aggregate.total, field)\n }\n }\n // Only the top-level meters contribute: cache/reasoning partitions overlap them.\n if (counts.inputTokens !== undefined || counts.outputTokens !== undefined) {\n counts.totalTokens = safeAggregateNumber(\n value.usage.inputTokens.total + value.usage.outputTokens.total,\n \"totalTokens\"\n )\n }\n return {\n usage: {\n ...counts,\n reportingStatus:\n value.reportedUsageCallCount === 0n\n ? \"unavailable\"\n : value.completeUsageCallCount === value.modelCallCount\n ? \"complete\"\n : \"partial\",\n },\n usageCoverage: {\n completeCallCount: safeAggregateNumber(value.completeUsageCallCount, \"complete call count\"),\n fieldCallCounts,\n },\n }\n}\n\nfunction naturalBigInt(value: string, field: string): bigint {\n if (!/^(0|[1-9]\\d*)$/.test(value)) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} must be a natural integer.`)\n }\n return BigInt(value)\n}\n\nfunction safeAggregateNumber(value: bigint, field: string): number {\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new TypeError(`[Sixb] AI accounting ${field} exceeds the safe integer range.`)\n }\n return Number(value)\n}\n\nfunction requiredFragmentString(value: string | undefined, field: string): string {\n if (value === undefined || value.length === 0) {\n throw new TypeError(`[Sixb] AI accounting SQL ${field} is missing.`)\n }\n return value\n}\n\nfunction requiredFragmentDate(value: Date | undefined, field: string): Date {\n if (value === undefined) throw new TypeError(`[Sixb] AI accounting SQL ${field} is missing.`)\n assertDate(value, field)\n return value\n}\n\nfunction accountingPeriods(\n from: Date,\n to: Date,\n bucket: AiAccountingBucket\n): Array<{ start: Date; end: Date }> {\n const result: Array<{ start: Date; end: Date }> = []\n let cursor = aiAccountingBucketStart(from, bucket)\n while (cursor.getTime() < to.getTime()) {\n if (result.length >= MAX_CHART_BUCKETS) {\n throw new RangeError(`[Sixb] AI accounting query exceeds ${MAX_CHART_BUCKETS} chart buckets.`)\n }\n const next = nextBucket(cursor, bucket)\n result.push({ start: new Date(cursor), end: next })\n cursor = next\n }\n return result\n}\n\nfunction nextBucket(start: Date, bucket: AiAccountingBucket): Date {\n const next = new Date(start)\n if (bucket === \"hour\") next.setUTCHours(next.getUTCHours() + 1)\n else if (bucket === \"day\") next.setUTCDate(next.getUTCDate() + 1)\n else next.setUTCDate(next.getUTCDate() + 7)\n return next\n}\n\nfunction appendGrouped<TKey extends string>(\n groups: Map<TKey, AiAccountingRecordSetItem[]>,\n key: TKey,\n item: AiAccountingRecordSetItem\n): void {\n const existing = groups.get(key)\n if (existing) existing.push(item)\n else groups.set(key, [item])\n}\n\nfunction addAmount(amounts: Map<string, bigint>, currency: string, amountNanos: string): void {\n amounts.set(currency, (amounts.get(currency) ?? 0n) + BigInt(amountNanos))\n}\n\nfunction normalizePage(\n requestedLimit: number | undefined,\n requestedOffset: number | undefined\n): { limit: number; offset: number } {\n const limit = requestedLimit ?? DEFAULT_MODEL_CALL_PAGE_SIZE\n const offset = requestedOffset ?? 0\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > MAX_MODEL_CALL_PAGE_SIZE) {\n throw new TypeError(\n `[Sixb] AI accounting list limit must be an integer between 1 and ${MAX_MODEL_CALL_PAGE_SIZE}.`\n )\n }\n if (!Number.isSafeInteger(offset) || offset < 0) {\n throw new TypeError(\"[Sixb] AI accounting list offset must be a non-negative integer.\")\n }\n return { limit, offset }\n}\n\nfunction compareAccountingItems(\n left: AiModelCallAccountingItem,\n right: AiModelCallAccountingItem\n): number {\n return (\n right.usage.occurredAt.getTime() - left.usage.occurredAt.getTime() ||\n left.usage.id.localeCompare(right.usage.id)\n )\n}\n\nfunction compareAgentBreakdowns(\n left: AiAccountingAgentBreakdown,\n right: AiAccountingAgentBreakdown\n): number {\n return (\n right.modelCallCount - left.modelCallCount ||\n agentBreakdownKey(left).localeCompare(agentBreakdownKey(right))\n )\n}\n\nfunction agentBreakdownKey(value: AiAccountingAgentBreakdown): string {\n return value.kind === \"agent\"\n ? \"agent\"\n : JSON.stringify([\"workflowAgent\", value.workflowId, value.agentStepId])\n}\n\nfunction compareWorkflowBreakdowns(\n left: AiAccountingWorkflowBreakdown,\n right: AiAccountingWorkflowBreakdown\n): number {\n return (\n right.modelCallCount - left.modelCallCount || left.workflowId.localeCompare(right.workflowId)\n )\n}\n\nfunction kindBreakdown(\n kind: ModelKind | \"\",\n aggregate: AiAccountingAggregate\n): AiAccountingKindBreakdown {\n return kind ? { modelKind: kind, ...aggregate } : aggregate\n}\n\nfunction compareKindBreakdowns(\n left: AiAccountingKindBreakdown,\n right: AiAccountingKindBreakdown\n): number {\n // Calls recorded before their kind was captured sort after every kind.\n return (\n right.modelCallCount - left.modelCallCount ||\n Number(left.modelKind === undefined) - Number(right.modelKind === undefined) ||\n (left.modelKind ?? \"\").localeCompare(right.modelKind ?? \"\")\n )\n}\n\nfunction compareModelBreakdowns(\n left: AiAccountingModelBreakdown,\n right: AiAccountingModelBreakdown\n): number {\n return (\n right.modelCallCount - left.modelCallCount ||\n left.providerId.localeCompare(right.providerId) ||\n left.modelId.localeCompare(right.modelId)\n )\n}\n\nfunction assertAiAccountingBucket(bucket: AiAccountingBucket): void {\n if (bucket !== \"hour\" && bucket !== \"day\" && bucket !== \"week\") {\n throw new TypeError(\"[Sixb] AI accounting bucket must be hour, day, or week.\")\n }\n}\n\nfunction assertDate(value: Date, label: string): void {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI ${label} must be a valid Date.`)\n }\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI ${label} must be nonblank.`)\n }\n}\n",
|
|
7
|
-
"import type { AiAccountingAttribution } from \"./types\"\n\n/** Direct calls are identified by durable provenance, even when their run has been removed. */\nexport function directModelCallAttribution(\n kind: string | null,\n id: string | null,\n primitiveId: string | null\n): AiAccountingAttribution | undefined {\n if (!id) return undefined\n if (kind === \"request\") return { kind, requestId: id }\n if (kind === \"action\" && primitiveId) return { kind, actionId: primitiveId, actionRunId: id }\n if (kind === \"workflow\" && primitiveId)\n return { kind, workflowId: primitiveId, workflowRunId: id }\n return undefined\n}\n",
|
|
8
|
-
"import { TOKENLESS_MODEL_KINDS } from \"../../models/definitions\"\nimport type { AiAccountingRecordSetItem } from \"./analytics\"\nimport { aiAccountingItemMatchesQuery, normalizeAiModelCallAccountingQuery } from \"./analytics\"\nimport { directModelCallAttribution } from \"./attribution\"\nimport type {\n AiAccountingAttribution,\n AiBillingIdentity,\n AiCostSummary,\n AiModelCallExecutionSummary,\n AiModelCallGroup,\n AiModelCallGroupSummary,\n AiMoney,\n ListAiModelCallGroupsInput,\n ListAiModelCallGroupsResult,\n} from \"./types\"\n\nexport interface AiAccountingGroupIdentity {\n readonly executionId: string\n readonly attribution?: AiAccountingAttribution\n}\n\n/** A compact SQL aggregate, never the raw provider response or a page of individual calls. */\nexport interface AiModelCallGroupFragment {\n readonly root: AiAccountingGroupIdentity\n readonly execution: AiAccountingGroupIdentity\n readonly model: AiBillingIdentity\n readonly firstCallAt: Date\n readonly lastCallAt: Date\n readonly callCount: string\n readonly tokenCount: string\n /** Calls of a tokenless kind that reported no tokens, which leave no gap in the total. */\n readonly tokenlessCount: string\n readonly totalTokens: string | null\n readonly outputImages: string | null\n readonly inputCharacters: string | null\n readonly audioDurationMs: string | null\n readonly valuationStatus: \"rated\" | \"unpriceable\" | \"unvalued\"\n readonly money?: AiMoney\n}\n\n/** Common provider projection; SQL groups meters before returning rows to the runtime. */\nexport interface AiModelCallGroupRow {\n readonly root_execution_id: string\n readonly execution_id: string\n readonly provider_id: string\n readonly requested_model_id: string\n readonly first_call_at: Date | string\n readonly last_call_at: Date | string\n readonly call_count: string\n readonly token_count: string\n readonly tokenless_count: string\n readonly total_tokens: string | null\n readonly output_images: string | null\n readonly input_characters: string | null\n readonly audio_duration_ms: string | null\n readonly valuation_status: AiModelCallGroupFragment[\"valuationStatus\"]\n readonly amount_currency: string | null\n readonly amount_high: string | null\n readonly amount_middle: string | null\n readonly amount_low: string | null\n readonly root_agent_run_id: string | null\n readonly root_thread_id: string | null\n readonly direct_kind: string | null\n readonly direct_run_id: string | null\n readonly parent_run_id: string | null\n readonly workflow_agent_step_id: string | null\n readonly workflow_node_run_id: string | null\n readonly workflow_id: string | null\n readonly workflow_run_id: string | null\n readonly executor_kind: string | null\n readonly executor_id: string | null\n readonly primitive_id: string | null\n}\n\nexport function aiModelCallGroupFragmentFromRow(\n row: AiModelCallGroupRow\n): AiModelCallGroupFragment {\n let attribution = directModelCallAttribution(row.executor_kind, row.executor_id, row.primitive_id)\n if (row.root_agent_run_id && row.root_thread_id) {\n attribution = {\n kind: \"agent\",\n agentRunId: row.root_agent_run_id,\n threadId: row.root_thread_id,\n }\n } else if (\n row.workflow_agent_step_id &&\n row.workflow_node_run_id &&\n row.workflow_id &&\n row.workflow_run_id\n ) {\n attribution = {\n kind: \"workflowAgent\",\n agentStepId: row.workflow_agent_step_id,\n nodeRunId: row.workflow_node_run_id,\n workflowId: row.workflow_id,\n workflowRunId: row.workflow_run_id,\n }\n }\n const executionAttribution: AiAccountingAttribution | undefined =\n row.direct_kind === \"subagent\" && row.direct_run_id && row.parent_run_id\n ? { kind: \"subagent\", subagentRunId: row.direct_run_id, parentRunId: row.parent_run_id }\n : attribution\n return {\n root: { executionId: row.root_execution_id, attribution },\n execution: { executionId: row.execution_id, attribution: executionAttribution },\n model: { providerId: row.provider_id, modelId: row.requested_model_id },\n firstCallAt: new Date(row.first_call_at),\n lastCallAt: new Date(row.last_call_at),\n callCount: row.call_count,\n tokenCount: row.token_count,\n tokenlessCount: row.tokenless_count,\n totalTokens: row.total_tokens,\n outputImages: row.output_images,\n inputCharacters: row.input_characters,\n audioDurationMs: row.audio_duration_ms,\n valuationStatus: row.valuation_status,\n ...(row.amount_currency === null\n ? {}\n : {\n money: {\n currency: row.amount_currency,\n amountNanos: (\n BigInt(row.amount_high ?? \"0\") * 1_000_000_000_000n +\n BigInt(row.amount_middle ?? \"0\") * 1_000_000n +\n BigInt(row.amount_low ?? \"0\")\n ).toString(),\n },\n }),\n }\n}\n\nexport function buildAiModelCallGroupsFromFragments(\n fragments: readonly AiModelCallGroupFragment[]\n): readonly AiModelCallGroup[] {\n const roots = new Map<string, AiModelCallGroupFragment[]>()\n for (const fragment of fragments) append(roots, fragment.root.executionId, fragment)\n return [...roots.values()]\n .map((rootFragments): AiModelCallGroup => {\n const first = rootFragments[0]!\n const executions = new Map<string, AiModelCallGroupFragment[]>()\n for (const fragment of rootFragments)\n append(executions, fragment.execution.executionId, fragment)\n return {\n ...first.root,\n ...summarize(rootFragments),\n ...timeRange(rootFragments),\n executions: [...executions.values()]\n .map(\n (items): AiModelCallExecutionSummary => ({\n ...items[0]!.execution,\n ...summarize(items),\n ...timeRange(items),\n models: [\n ...new Map(items.map(({ model }) => [JSON.stringify(model), model])).values(),\n ].sort(\n (a, b) =>\n compareText(a.providerId, b.providerId) || compareText(a.modelId, b.modelId)\n ),\n })\n )\n .sort(\n (a, b) =>\n a.firstCallAt.getTime() - b.firstCallAt.getTime() ||\n compareText(a.executionId, b.executionId)\n ),\n }\n })\n .sort(\n (a, b) =>\n b.lastCallAt.getTime() - a.lastCallAt.getTime() || compareText(a.executionId, b.executionId)\n )\n}\n\nexport function buildAiModelCallGroups(\n input: ListAiModelCallGroupsInput,\n source: readonly (AiAccountingRecordSetItem & { readonly root: AiAccountingGroupIdentity })[]\n): ListAiModelCallGroupsResult {\n const query = normalizeAiModelCallAccountingQuery(input)\n const fragments = source\n .filter(\n (item) =>\n aiAccountingItemMatchesQuery(item, query) &&\n (query.valuationStatus === undefined ||\n (item.cost?.status ?? \"unvalued\") === query.valuationStatus)\n )\n .map(\n (item): AiModelCallGroupFragment => ({\n root: item.root,\n execution: { executionId: item.usage.executionId, attribution: item.attribution },\n model: { providerId: item.usage.providerId, modelId: item.usage.requestedModelId },\n firstCallAt: item.usage.occurredAt,\n lastCallAt: item.usage.occurredAt,\n callCount: \"1\",\n tokenCount: item.usage.usage.totalTokens === undefined ? \"0\" : \"1\",\n tokenlessCount:\n item.usage.usage.totalTokens === undefined &&\n item.usage.modelKind !== undefined &&\n TOKENLESS_MODEL_KINDS.includes(item.usage.modelKind)\n ? \"1\"\n : \"0\",\n totalTokens: item.usage.usage.totalTokens?.toString() ?? null,\n outputImages: item.usage.usage.outputImages?.toString() ?? null,\n inputCharacters: item.usage.usage.inputCharacters?.toString() ?? null,\n audioDurationMs: item.usage.usage.audioDurationMs?.toString() ?? null,\n valuationStatus: item.cost?.status ?? \"unvalued\",\n ...(item.cost && item.cost.status !== \"unpriceable\" ? { money: item.cost.money } : {}),\n })\n )\n const groups = buildAiModelCallGroupsFromFragments(fragments)\n const items = groups.slice(query.offset, query.offset + query.limit)\n return structuredClone({\n items,\n total: groups.length,\n hasMore: query.offset + items.length < groups.length,\n })\n}\n\nfunction summarize(items: readonly AiModelCallGroupFragment[]): AiModelCallGroupSummary {\n let calls = 0n\n let tokenCount = 0n\n let tokenless = 0n\n let tokens = 0n\n const media = {\n outputImages: undefined as bigint | undefined,\n inputCharacters: undefined as bigint | undefined,\n audioDurationMs: undefined as bigint | undefined,\n }\n const counts = { rated: 0n, unpriceable: 0n, unvalued: 0n }\n const money = new Map<string, bigint>()\n for (const item of items) {\n const count = BigInt(item.callCount)\n calls += count\n tokenCount += BigInt(item.tokenCount)\n tokenless += BigInt(item.tokenlessCount)\n tokens += BigInt(item.totalTokens ?? \"0\")\n for (const field of [\"outputImages\", \"inputCharacters\", \"audioDurationMs\"] as const) {\n const value = item[field]\n if (value !== null) media[field] = (media[field] ?? 0n) + BigInt(value)\n }\n counts[item.valuationStatus] += count\n if (item.money)\n money.set(\n item.money.currency,\n (money.get(item.money.currency) ?? 0n) + BigInt(item.money.amountNanos)\n )\n }\n const costs: AiCostSummary = {\n amounts: [...money]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([currency, amount]) => ({ currency, amountNanos: amount.toString() })),\n ratedCallCount: safeCount(counts.rated),\n unpriceableCallCount: safeCount(counts.unpriceable),\n unvaluedCallCount: safeCount(counts.unvalued),\n }\n return {\n modelCallCount: safeCount(calls),\n ...(tokenCount > 0n && calls === tokenCount + tokenless\n ? { totalTokens: safeCount(tokens) }\n : {}),\n ...(media.outputImages === undefined ? {} : { outputImages: safeCount(media.outputImages) }),\n ...(media.inputCharacters === undefined\n ? {}\n : { inputCharacters: safeCount(media.inputCharacters) }),\n ...(media.audioDurationMs === undefined\n ? {}\n : { audioDurationMs: safeCount(media.audioDurationMs) }),\n costs,\n }\n}\n\nfunction timeRange(items: readonly AiModelCallGroupFragment[]) {\n let first = items[0]!.firstCallAt.getTime()\n let last = items[0]!.lastCallAt.getTime()\n for (const item of items) {\n first = Math.min(first, item.firstCallAt.getTime())\n last = Math.max(last, item.lastCallAt.getTime())\n }\n return { firstCallAt: new Date(first), lastCallAt: new Date(last) }\n}\n\nfunction compareText(a: string, b: string): number {\n return a === b ? 0 : a < b ? -1 : 1\n}\n\nfunction safeCount(value: bigint): number {\n if (value < 0n || value > BigInt(Number.MAX_SAFE_INTEGER))\n throw new RangeError(\"[Sixb] AI accounting group count exceeds the safe integer range.\")\n return Number(value)\n}\n\nfunction append<T>(map: Map<string, T[]>, key: string, item: T): void {\n const items = map.get(key)\n if (items) items.push(item)\n else map.set(key, [item])\n}\n",
|
|
9
|
-
"import { assertJsonObject } from \"../../json\"\nimport type { AiModelCallUsage, AiModelCallUsageRecord } from \"../ai-usage\"\nimport { normalizeAiModelCallUsage } from \"../ai-usage\"\nimport type {\n AiBillableMeter,\n AiBillingIdentity,\n AiCostComponent,\n AiCostEstimate,\n AiModelCallCostRecord,\n AiPriceSource,\n AiPricingContext,\n AiRatedModelCallCostRecord,\n AiUnpriceableModelCallCostRecord,\n AiUnpriceableReason,\n} from \"./types\"\n\nconst SIGNED_INT64_MAX = 9_223_372_036_854_775_807n\nconst UNITS_PER_MILLION = 1_000_000n\nconst HALF_MILLION = UNITS_PER_MILLION / 2n\nconst MAX_NUMERIC_TEXT_LENGTH = 128\nconst METER_ORDER: Readonly<Record<AiBillableMeter, number>> = {\n \"tokens.input.total\": 0,\n \"tokens.input.uncached\": 1,\n \"tokens.input.cacheRead\": 2,\n \"tokens.input.cacheWrite\": 3,\n \"tokens.input.cacheWrite5m\": 4,\n \"tokens.input.cacheWrite1h\": 5,\n \"tokens.output.total\": 6,\n \"tokens.output.text\": 7,\n \"tokens.output.reasoning\": 8,\n \"audio.input.milliseconds\": 9,\n \"tokens.output.image\": 10,\n \"tokens.output.audio\": 11,\n \"images.output\": 12,\n \"characters.input\": 13,\n}\nconst METERS = new Set(Object.keys(METER_ORDER) as AiBillableMeter[])\nconst UNPRICEABLE_REASONS = new Set<AiUnpriceableReason>([\n \"missingBillingIdentity\",\n \"missingRateCard\",\n \"missingUsageMeter\",\n \"unsupportedPricingDimension\",\n \"invalidUsageForFormula\",\n])\nconst CONTEXT_STRING_FIELDS = [\n \"serviceTier\",\n \"region\",\n \"inferenceGeo\",\n \"routedProviderId\",\n \"routedModelId\",\n \"deploymentId\",\n \"inferenceProfileId\",\n \"mode\",\n] as const\n\nexport function normalizeAiPricingContext(input: AiPricingContext): AiPricingContext {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) {\n throw new TypeError(\"[Sixb] AI pricing context must be an object.\")\n }\n const result: Record<string, string | boolean | number> = {}\n for (const field of CONTEXT_STRING_FIELDS) {\n const value = input[field]\n if (value !== undefined) {\n assertNonBlank(value, `pricingContext.${field}`)\n result[field] = value\n }\n }\n if (input.batch !== undefined) {\n if (typeof input.batch !== \"boolean\") {\n throw new TypeError(\"[Sixb] AI pricingContext.batch must be boolean.\")\n }\n result.batch = input.batch\n }\n if (input.cacheWriteTtlSeconds !== undefined) {\n if (!Number.isSafeInteger(input.cacheWriteTtlSeconds) || input.cacheWriteTtlSeconds <= 0) {\n throw new TypeError(\n \"[Sixb] AI pricingContext.cacheWriteTtlSeconds must be a positive safe integer.\"\n )\n }\n result.cacheWriteTtlSeconds = input.cacheWriteTtlSeconds\n }\n return result\n}\n\nexport function normalizeAiModelCallCostRecord(\n input: AiModelCallCostRecord\n): AiModelCallCostRecord {\n assertNonBlank(input.projectId, \"cost record projectId\")\n assertNonBlank(input.usageRecordId, \"cost record usageRecordId\")\n const base = {\n ...(input.estimate === undefined ? {} : { estimate: normalizeAiCostEstimate(input.estimate) }),\n projectId: input.projectId,\n usageRecordId: input.usageRecordId,\n pricingContext: normalizeAiPricingContext(input.pricingContext),\n ratedAt: cloneDate(input.ratedAt, \"cost record ratedAt\"),\n }\n\n if (input.status === \"rated\") {\n return normalizeRatedCost(input, {\n ...base,\n priceSource: normalizePriceSource(input.priceSource),\n })\n }\n if (input.status === \"unpriceable\") {\n return normalizeUnpriceableCost(input, {\n ...base,\n ...(input.priceSource === undefined\n ? {}\n : { priceSource: normalizePriceSource(input.priceSource) }),\n })\n }\n throw new TypeError(\"[Sixb] AI cost status is invalid.\")\n}\n\n/** Verify that a normalized valuation's billed quantities describe its usage record. */\nexport function aiModelCallCostMatchesUsage(\n record: AiModelCallCostRecord,\n usageRecord: AiModelCallUsageRecord\n): boolean {\n if (record.projectId !== usageRecord.projectId || record.usageRecordId !== usageRecord.id) {\n return false\n }\n if (record.estimate?.status === \"rated\") {\n const usage = normalizeAiModelCallUsage(usageRecord.usage)\n const components = new Map(\n record.estimate.components.map((component) => [component.meter, component])\n )\n if (!componentsMatchUsage(components, usage)) return false\n }\n if (record.status === \"unpriceable\") return true\n if (record.components.length === 0 && isExternalValuationSource(record.priceSource.sourceId)) {\n return true\n }\n\n const usage = normalizeAiModelCallUsage(usageRecord.usage)\n const components = new Map(record.components.map((component) => [component.meter, component]))\n return componentsMatchUsage(components, usage)\n}\n\nconst UNIT_METERS = [\n [\"audio.input.milliseconds\", \"audioDurationMs\"],\n [\"characters.input\", \"inputCharacters\"],\n [\"images.output\", \"outputImages\"],\n] as const\n\nfunction componentsMatchUsage(\n components: ReadonlyMap<AiBillableMeter, AiCostComponent>,\n usage: AiModelCallUsage\n): boolean {\n for (const [meter, field] of UNIT_METERS) {\n const component = components.get(meter)\n const expected = usage[field]\n if (component && (expected === undefined || BigInt(component.quantity) !== BigInt(expected))) {\n return false\n }\n }\n // A call billed only by units carries no token components.\n if (![...components.keys()].some((meter) => meter.startsWith(\"tokens.\"))) {\n return components.size > 0\n }\n\n return (\n inputComponentsMatchUsage(components, usage) && outputComponentsMatchUsage(components, usage)\n )\n}\n\nfunction inputComponentsMatchUsage(\n components: ReadonlyMap<AiBillableMeter, AiCostComponent>,\n usage: AiModelCallUsage\n): boolean {\n if (usage.inputTokens === undefined) return false\n const total = components.get(\"tokens.input.total\")\n const directPartitions = [\n [\"tokens.input.uncached\", usage.uncachedInputTokens],\n [\"tokens.input.cacheRead\", usage.cacheReadInputTokens],\n [\"tokens.input.cacheWrite\", usage.cacheWriteInputTokens],\n ] as const\n const presentDirect = directPartitions.filter(([meter]) => components.has(meter))\n const specificWrites = [\n components.get(\"tokens.input.cacheWrite5m\"),\n components.get(\"tokens.input.cacheWrite1h\"),\n ].filter((component): component is AiCostComponent => component !== undefined)\n\n if (total) {\n return (\n presentDirect.length === 0 &&\n specificWrites.length === 0 &&\n BigInt(total.quantity) === BigInt(usage.inputTokens)\n )\n }\n if (presentDirect.length === 0 && specificWrites.length === 0) return false\n if (components.has(\"tokens.input.cacheWrite\") && specificWrites.length > 0) return false\n\n let quantity = 0n\n for (const [meter, expected] of presentDirect) {\n if (expected === undefined) return false\n const component = components.get(meter)!\n if (BigInt(component.quantity) !== BigInt(expected)) return false\n quantity += BigInt(component.quantity)\n }\n if (specificWrites.length > 0) {\n if (usage.cacheWriteInputTokens === undefined) return false\n const specificWriteQuantity = specificWrites.reduce(\n (sum, component) => sum + BigInt(component.quantity),\n 0n\n )\n if (specificWriteQuantity !== BigInt(usage.cacheWriteInputTokens)) return false\n quantity += specificWriteQuantity\n }\n return quantity === BigInt(usage.inputTokens)\n}\n\nfunction outputComponentsMatchUsage(\n components: ReadonlyMap<AiBillableMeter, AiCostComponent>,\n usage: AiModelCallUsage\n): boolean {\n if (usage.outputTokens === undefined) return false\n const total = components.get(\"tokens.output.total\")\n // Per-image prices cover the image tokens of a call that returned images.\n const images = components.get(\"images.output\")\n const covered = images && BigInt(images.quantity) > 0n ? usage.imageOutputTokens : 0\n if (covered === undefined) return false\n const partitions = [\n [\"tokens.output.text\", usage.textOutputTokens],\n [\"tokens.output.reasoning\", usage.reasoningOutputTokens],\n [\"tokens.output.image\", usage.imageOutputTokens],\n [\"tokens.output.audio\", usage.audioOutputTokens],\n ] as const\n const presentPartitions = partitions.filter(([meter]) => components.has(meter))\n\n if (total) {\n return (\n presentPartitions.length === 0 &&\n covered === 0 &&\n BigInt(total.quantity) === BigInt(usage.outputTokens)\n )\n }\n if (presentPartitions.length === 0 && covered === 0) return false\n\n let quantity = BigInt(covered)\n for (const [meter, expected] of presentPartitions) {\n if (expected === undefined) return false\n const component = components.get(meter)!\n if (BigInt(component.quantity) !== BigInt(expected)) return false\n quantity += BigInt(component.quantity)\n }\n return quantity === BigInt(usage.outputTokens)\n}\n\nfunction normalizeRatedCost(\n input: AiRatedModelCallCostRecord,\n base: Pick<\n AiRatedModelCallCostRecord,\n \"projectId\" | \"usageRecordId\" | \"pricingContext\" | \"priceSource\" | \"ratedAt\"\n >\n): AiRatedModelCallCostRecord {\n const billingIdentity = normalizeBillingIdentity(input.billingIdentity)\n const components = input.components.map(normalizeCostComponent).sort(compareComponents)\n if (components.length === 0 && !isExternalValuationSource(base.priceSource.sourceId)) {\n throw new TypeError(\"[Sixb] AI rated cost requires components.\")\n }\n if (new Set(components.map((component) => component.meter)).size !== components.length) {\n throw new TypeError(\"[Sixb] AI rated cost cannot contain duplicate meters.\")\n }\n const amountNanos = parseNonnegativeInt64(input.money.amountNanos, \"money amountNanos\").toString()\n if (components.length > 0 && amountNanos !== sumComponents(components)) {\n throw new TypeError(\"[Sixb] AI cost total does not equal its component charges.\")\n }\n return {\n ...base,\n status: \"rated\",\n billingIdentity,\n money: { currency: normalizeCurrency(input.money.currency), amountNanos },\n components,\n }\n}\n\nexport function normalizeAiCostEstimate(value: unknown): AiCostEstimate {\n assertJsonObject(value, \"AI cost estimate\")\n if (value.status === \"rated\") {\n assertJsonObject(value.money, \"estimate money\")\n const { currency, amountNanos } = value.money\n if (\n typeof currency !== \"string\" ||\n typeof amountNanos !== \"string\" ||\n !Array.isArray(value.components)\n )\n throw new TypeError(\"[Sixb] Invalid cost estimate money or components.\")\n const components = value.components\n .map((component) => {\n assertJsonObject(component, \"estimate component\")\n const meter = [...METERS].find((meter) => meter === component.meter)\n if (\n !meter ||\n typeof component.quantity !== \"string\" ||\n typeof component.rateAmountNanosPerMillion !== \"string\" ||\n typeof component.chargeAmountNanos !== \"string\" ||\n (component.variant !== undefined && typeof component.variant !== \"string\")\n )\n throw new TypeError(\"[Sixb] Invalid cost estimate component.\")\n return normalizeCostComponent({\n meter,\n quantity: component.quantity,\n rateAmountNanosPerMillion: component.rateAmountNanosPerMillion,\n chargeAmountNanos: component.chargeAmountNanos,\n ...(component.variant === undefined ? {} : { variant: component.variant }),\n })\n })\n .sort(compareComponents)\n if (\n !components.length ||\n new Set(components.map((c) => c.meter)).size !== components.length ||\n parseNonnegativeInt64(amountNanos, \"estimate amountNanos\").toString() !==\n sumComponents(components)\n )\n throw new TypeError(\n \"[Sixb] Estimate must contain unique meters whose charges equal its total.\"\n )\n return {\n status: \"rated\",\n money: { currency: normalizeCurrency(currency), amountNanos },\n components,\n }\n }\n const reason = [...UNPRICEABLE_REASONS].find((reason) => reason === value.reason)\n if (value.status !== \"unpriceable\" || !reason)\n throw new TypeError(\"[Sixb] Invalid cost estimate status or reason.\")\n let missingMeters: readonly AiBillableMeter[] | undefined\n if (value.missingMeters !== undefined) {\n if (!Array.isArray(value.missingMeters))\n throw new TypeError(\"[Sixb] Invalid estimate missing meters.\")\n missingMeters = normalizeMissingMeters(\n value.missingMeters.map((input) => {\n const meter = [...METERS].find((meter) => meter === input)\n if (!meter) throw new TypeError(\"[Sixb] Invalid estimate missing meter.\")\n return meter\n })\n )\n }\n if (reason === \"missingUsageMeter\" && !missingMeters)\n throw new TypeError(\"[Sixb] Missing usage estimate requires missingMeters.\")\n return {\n status: \"unpriceable\",\n reason,\n ...(missingMeters === undefined ? {} : { missingMeters }),\n }\n}\n\nfunction isExternalValuationSource(sourceId: string): boolean {\n return sourceId === \"provider-reported\"\n}\n\nfunction normalizeUnpriceableCost(\n input: AiUnpriceableModelCallCostRecord,\n base: Pick<\n AiUnpriceableModelCallCostRecord,\n \"projectId\" | \"usageRecordId\" | \"pricingContext\" | \"priceSource\" | \"ratedAt\"\n >\n): AiUnpriceableModelCallCostRecord {\n if (!UNPRICEABLE_REASONS.has(input.reason)) {\n throw new TypeError(`[Sixb] AI unpriceable reason '${String(input.reason)}' is invalid.`)\n }\n const billingIdentity = input.billingIdentity\n ? normalizeBillingIdentity(input.billingIdentity)\n : undefined\n if (input.reason === \"missingBillingIdentity\" && billingIdentity !== undefined) {\n throw new TypeError(\"[Sixb] AI missingBillingIdentity cannot contain a billing identity.\")\n }\n if (input.reason !== \"missingBillingIdentity\" && billingIdentity === undefined) {\n throw new TypeError(`[Sixb] AI ${input.reason} requires a billing identity.`)\n }\n const missingMeters = normalizeMissingMeters(input.missingMeters)\n if (input.reason === \"missingUsageMeter\" && !missingMeters) {\n throw new TypeError(\"[Sixb] AI missingUsageMeter requires missingMeters.\")\n }\n return {\n ...base,\n status: \"unpriceable\",\n ...(billingIdentity ? { billingIdentity } : {}),\n reason: input.reason,\n ...(missingMeters ? { missingMeters } : {}),\n }\n}\n\nfunction normalizeCostComponent(input: AiCostComponent): AiCostComponent {\n if (!METERS.has(input.meter)) {\n throw new TypeError(`[Sixb] AI cost meter '${String(input.meter)}' is invalid.`)\n }\n const expected = calculateComponent(input.meter, input.quantity, input.rateAmountNanosPerMillion)\n if (expected.chargeAmountNanos !== input.chargeAmountNanos) {\n throw new TypeError(`[Sixb] AI cost component '${input.meter}' charge is invalid.`)\n }\n if (input.variant === undefined) return expected\n assertNonBlank(input.variant, `cost component '${input.meter}' variant`)\n return { ...expected, variant: input.variant }\n}\n\nfunction calculateComponent(\n meter: AiBillableMeter,\n quantity: number | string,\n rateAmountNanosPerMillion: string\n): AiCostComponent {\n const normalizedQuantity = parseQuantity(quantity, `${meter} quantity`)\n const rate = parseNonnegativeInt64(rateAmountNanosPerMillion, `${meter} rate`)\n const charge = (normalizedQuantity * rate + HALF_MILLION) / UNITS_PER_MILLION\n assertSignedInt64(charge, `${meter} charge`)\n return {\n meter,\n quantity: normalizedQuantity.toString(),\n rateAmountNanosPerMillion: rate.toString(),\n chargeAmountNanos: charge.toString(),\n }\n}\n\nfunction normalizePriceSource(input: AiPriceSource): AiPriceSource {\n assertNonBlank(input.sourceId, \"price sourceId\")\n assertNonBlank(input.sourceEntryId, \"price sourceEntryId\")\n assertNonBlank(input.sourceVersion, \"price sourceVersion\")\n if (input.sourceUrl !== undefined) assertNonBlank(input.sourceUrl, \"price sourceUrl\")\n return {\n sourceId: input.sourceId,\n sourceEntryId: input.sourceEntryId,\n sourceVersion: input.sourceVersion,\n ...(input.sourceUrl === undefined ? {} : { sourceUrl: input.sourceUrl }),\n observedAt: cloneDate(input.observedAt, \"price source observedAt\"),\n }\n}\n\nfunction normalizeBillingIdentity(input: AiBillingIdentity): AiBillingIdentity {\n assertNonBlank(input.providerId, \"billingIdentity.providerId\")\n assertNonBlank(input.modelId, \"billingIdentity.modelId\")\n return { providerId: input.providerId, modelId: input.modelId }\n}\n\nfunction normalizeMissingMeters(\n input: readonly AiBillableMeter[] | undefined\n): readonly AiBillableMeter[] | undefined {\n if (!input?.length) return undefined\n const result = [...new Set(input)]\n for (const meter of result) {\n if (!METERS.has(meter)) throw new TypeError(`[Sixb] AI missing meter '${meter}' is invalid.`)\n }\n return result.sort((left, right) => METER_ORDER[left] - METER_ORDER[right])\n}\n\nfunction sumComponents(components: readonly AiCostComponent[]): string {\n let total = 0n\n for (const component of components) {\n total += parseNonnegativeInt64(component.chargeAmountNanos, \"component charge\")\n assertSignedInt64(total, \"cost total\")\n }\n return total.toString()\n}\n\nfunction parseQuantity(value: number | string, field: string): bigint {\n if (typeof value === \"number\") {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`[Sixb] AI ${field} must be a non-negative safe integer.`)\n }\n return BigInt(value)\n }\n return parseNonnegativeInt64(value, field)\n}\n\nfunction parseNonnegativeInt64(value: string, field: string): bigint {\n if (\n typeof value !== \"string\" ||\n value.length === 0 ||\n value.length > MAX_NUMERIC_TEXT_LENGTH ||\n !/^\\d+$/.test(value)\n ) {\n throw new TypeError(`[Sixb] AI ${field} must be a non-negative integer string.`)\n }\n const parsed = BigInt(value)\n assertSignedInt64(parsed, field)\n return parsed\n}\n\nfunction compareComponents(left: AiCostComponent, right: AiCostComponent): number {\n return METER_ORDER[left.meter] - METER_ORDER[right.meter]\n}\n\nfunction normalizeCurrency(value: string): string {\n if (!/^[A-Z]{3}$/.test(value)) {\n throw new TypeError(\"[Sixb] AI currency must be a three-letter uppercase code.\")\n }\n return value\n}\n\nfunction assertSignedInt64(value: bigint, field: string): void {\n if (value < 0n || value > SIGNED_INT64_MAX) {\n throw new TypeError(`[Sixb] AI ${field} exceeds the signed 64-bit range.`)\n }\n}\n\nfunction assertNonBlank(value: string, field: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new TypeError(`[Sixb] AI ${field} must be nonblank.`)\n }\n}\n\nfunction cloneDate(value: Date, field: string): Date {\n if (!(value instanceof Date) || !Number.isFinite(value.getTime())) {\n throw new TypeError(`[Sixb] AI ${field} must be a valid Date.`)\n }\n return new Date(value)\n}\n"
|
|
10
|
-
],
|
|
11
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAsCO,MAAM,wBAAiD;AAAA,EAM/B;AAAA,EALZ,UAAU,IAAI;AAAA,EACd,6BAA6B,IAAI;AAAA,EACjC,YAAY,IAAI;AAAA,EAChB,YAAY,IAAI;AAAA,EAEjC,WAAW,CAAkB,YAA+C;AAAA,IAA/C;AAAA;AAAA,OAEvB,gBAAe,CAAC,OAAiE;AAAA,IACrF,MAAM,SAAS,4BAA2B,KAAK;AAAA,IAC/C,MAAM,KAAK,sBAAsB,OAAO,WAAW,OAAO,WAAW;AAAA,IACrE,MAAM,iBAAiB,wBAAwB,MAAM;AAAA,IACrD,MAAM,oBAAoB,KAAK,2BAA2B,IAAI,cAAc;AAAA,IAC5E,IAAI,sBAAsB,WAAW;AAAA,MACnC,MAAM,WAAW,KAAK,QAAQ,IAAI,iBAAiB;AAAA,MACnD,IAAI,CAAC,UAAU;AAAA,QACb,MAAM,IAAI,MAAM,8DAA8D;AAAA,MAChF;AAAA,MACA,OAAO,EAAE,QAAQ,gBAAgB,QAAQ,GAAG,SAAS,MAAM;AAAA,IAC7D;AAAA,IAEA,MAAM,YAAY,mBAAmB,OAAO,WAAW,OAAO,EAAE;AAAA,IAChE,IAAI,KAAK,QAAQ,IAAI,SAAS,GAAG;AAAA,MAC/B,MAAM,IAAI,qBACR,gBACA,2BAA2B,OAAO,mCAAmC,OAAO,aAC9E;AAAA,IACF;AAAA,IAEA,KAAK,QAAQ,IAAI,WAAW,gBAAgB,MAAM,CAAC;AAAA,IACnD,KAAK,2BAA2B,IAAI,gBAAgB,SAAS;AAAA,IAC7D,WAAW,WAAW,OAAO,mBAAmB;AAAA,MAC9C,MAA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",
|
|
12
|
-
"debugId": "80C7102506D0436E64756E2164756E21",
|
|
13
|
-
"names": []
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/agents/types.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ActionSubject } from \"../../actions/types\"\nimport type { AgentMessage, AgentMessagePart, AgentMessageRole } from \"../../agents/message\"\nimport type { AgentReasoning } from \"../../agents/types\"\nimport type { Principal, UserPrincipal } from \"../../auth\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { JsonObject, JsonValue } from \"../../json\"\nimport type {\n LanguageModelRef,\n LanguageModelTier,\n LanguageModelTierProbabilities,\n} from \"../../models\"\nimport type { ActionRunFailure, ActionRunParams } from \"../action-runs/types\"\n\n// ── agent_threads — one conversation with an agent ──────────────────────────────────────────────\n\nexport type AgentThreadStatus = \"active\" | \"archived\"\n\n/** Immutable, non-secret application input. Never store resolved env or credentials here. */\nexport type AgentThreadSandboxParams = Readonly<Record<string, JsonValue>>\n\n/** Worker-owned state, independent from the immutable application binding. */\nexport interface AgentThreadSandboxState {\n /** Exact name passed to the provider. Replacements always receive a fresh name. */\n readonly name: string\n readonly status: \"new\" | \"busy\" | \"ready\" | \"blocked\" | \"unavailable\"\n readonly sourceFingerprint?: string\n readonly initialized: boolean\n /** Durable context boundary: local files from before this reset are no longer available. */\n readonly resetAt?: string\n /** Never expires automatically: a delayed provider operation must not reach a successor. */\n readonly owner?: { readonly runId: string; readonly executionToken: string }\n}\n\nexport type TransitionAgentThreadSandboxInput = {\n readonly projectId: string\n readonly id: string\n} & (\n | {\n readonly action: \"acquire\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly sourceFingerprint: string\n }\n | {\n readonly action: \"replace\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly nextName: string\n }\n | {\n readonly action: \"settle\"\n readonly runId: string\n readonly executionToken: string\n readonly name: string\n readonly status: \"ready\" | \"blocked\" | \"unavailable\"\n readonly initialized: boolean\n }\n | {\n readonly action: \"recreate\"\n readonly expectedSandboxName: string\n readonly name: string\n }\n)\n\n/**\n * A conversation, or the thread a sub-agent works in. A sub-agent's thread is never listed, and\n * whoever reads its conversation reads it.\n */\nexport type AgentThreadKind = \"conversation\" | \"subagent\"\n\n/** Where a sub-agent's thread comes from: its conversation, the turn that spawned it, and its key. */\nexport interface AgentThreadParent {\n readonly threadId: string\n /** The turn that spawned it. Its later runs work under the turns that go on with it. */\n readonly spawnedBy: string\n readonly key: string\n}\n\nexport interface AgentThreadRecord {\n readonly id: string\n readonly projectId: string\n readonly kind: AgentThreadKind\n /** Set exactly on a sub-agent's thread. */\n readonly parent?: AgentThreadParent\n /** Who owns/opened the thread. Reuses the canonical auth principal (gains `agent` later for free). */\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly sandboxState?: AgentThreadSandboxState\n readonly status: AgentThreadStatus\n /** Single-flight anchor: the id of the one run currently allowed to write, or `null` when idle. */\n readonly activeRunId: string | null\n readonly lastMessageAt?: Date\n readonly messageCount: number\n readonly createdAt: Date\n readonly updatedAt: Date\n}\n\nexport interface CreateAgentThreadInput {\n readonly id: string\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n readonly status?: AgentThreadStatus\n readonly createdAt?: Date\n readonly updatedAt?: Date\n}\n\n/**\n * A new thread holding a copy of another thread's finished messages. A turn still running is left\n * behind: what came from its trigger message on is not copied. Copies keep their `seq`, content,\n * author and `runId`, and get new ids. Runs are not copied, so the fork's runs, usage and cost are\n * its own; copied answers still show their run's diagnostics.\n *\n * Only the latest checkpoint the copy can use comes along, so the markers of earlier compactions\n * are not in the fork. The fork has no `lastMessageAt` until its first new message, so it sorts\n * by its creation.\n */\nexport interface ForkAgentThreadInput {\n readonly projectId: string\n /** The thread whose history is copied. */\n readonly sourceThreadId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly title?: string\n readonly sandboxParams?: AgentThreadSandboxParams\n /** Provider name of the fork's new sandbox; given exactly when `sandboxParams` is. */\n readonly sandboxName?: string\n /**\n * The source's shared artifacts, each id mapped to its copy's: the copied messages and summary\n * name the copies instead.\n */\n readonly artifactCopies?: Readonly<Record<string, string>>\n readonly createdAt?: Date\n}\n\n/** A conversation's sub-agent threads, oldest first. */\nexport interface ListAgentThreadChildrenInput {\n readonly projectId: string\n /** The conversation. */\n readonly parentThreadId: string\n /** Only those this turn spawned. */\n readonly parentRunId?: string\n /** At most this many, 100 by default. */\n readonly limit?: number\n readonly offset?: number\n}\n\n/** Conversations only: a sub-agent's thread is read through its conversation. */\nexport interface ListAgentThreadsInput {\n readonly projectId: string\n readonly statuses?: readonly AgentThreadStatus[]\n readonly ownerPrincipal?: Principal\n /** Only the threads this user takes part in. */\n readonly participantPrincipal?: UserPrincipal\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentThreadsResult {\n readonly threads: readonly AgentThreadRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_thread_participants — the users a thread's owner added to it ─────────────────────────\n\nexport interface AgentThreadParticipantRecord {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n readonly addedAt: Date\n readonly addedBy: Principal\n}\n\nexport interface AddAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadId: string\n /**\n * Distinct users, checked by the caller. Someone already taking part keeps when and by whom they\n * were first added.\n */\n readonly principals: readonly UserPrincipal[]\n readonly addedBy: Principal\n /** Refused with `participant_limit`, adding no one, when the thread would hold more. */\n readonly maxParticipants: number\n readonly addedAt?: Date\n}\n\nexport interface RemoveAgentThreadParticipantInput {\n readonly projectId: string\n readonly threadId: string\n readonly principal: UserPrincipal\n}\n\nexport interface ListAgentThreadParticipantsInput {\n readonly projectId: string\n readonly threadIds: readonly string[]\n}\n\n// ── agent_runs — one loop execution (the worker job; attribution + fencing) ───────────────────\n\n/** Lifecycle shared by every durable agent execution, conversational or workflow-owned. */\nexport type AgentExecutionStatus = \"queued\" | \"running\" | \"succeeded\" | \"failed\" | \"cancelled\"\n\nexport type AgentRunStatus = AgentExecutionStatus\nexport type AgentRunKind = \"conversation\" | \"subagent\"\n\n/** Error codes an agent execution can persist and expose through its public contract. */\nexport const AGENT_RUN_FAILURE_CODES = [\n \"internal.unexpected\",\n \"runtime.cancelled\",\n \"agent.execution_failed\",\n \"ai.usage_limit_exceeded\",\n \"ai.usage_limit_unavailable\",\n] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]\n\nexport type AgentRunFailureCode = (typeof AGENT_RUN_FAILURE_CODES)[number]\n\n/**\n * Why a run ended — Sixb's provider-independent vocabulary. It includes model-loop reasons plus\n * platform-level endings such as `timeout`, `interrupted` for a turn whose worker died before\n * finishing it, `awaiting_approval` for a succeeded turn that paused on calls waiting for its\n * requester, or `awaiting_answer` for a succeeded sub-agent that paused on a question its parent\n * answers in a later turn, so reads remain typed and exhaustive. `other` and `unknown` preserve terminal state\n * when a provider adds a new reason.\n */\nexport const AGENT_RUN_FINISH_REASONS = [\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"timeout\",\n \"interrupted\",\n \"awaiting_approval\",\n \"awaiting_answer\",\n \"error\",\n \"other\",\n \"unknown\",\n] as const\n\nexport type AgentRunFinishReason = (typeof AGENT_RUN_FINISH_REASONS)[number]\n\n/**\n * Coerce an external finish-reason string — a DB column or an SDK value — to {@link\n * AgentRunFinishReason}. An unrecognised value becomes `\"unknown\"` rather than being dropped.\n */\nexport function coerceAgentRunFinishReason(\n value: string | null | undefined\n): AgentRunFinishReason | undefined {\n if (value === null || value === undefined) {\n return undefined\n }\n return (AGENT_RUN_FINISH_REASONS as readonly string[]).includes(value)\n ? (value as AgentRunFinishReason)\n : \"unknown\"\n}\n\n/** Stable, user-facing diagnostics emitted by the platform while executing a run. */\nexport const AGENT_RUN_DIAGNOSTIC_CODES = [\"step_limit_reached\", \"output_limit_reached\"] as const\n\n/**\n * Closed on purpose, and the wire is closed with it.\n *\n * Sixb writes these codes and the generated client is what reads them, so an open union would only\n * be honest if the HTTP schema were open too — and that costs the OpenAPI enum, the client's\n * autocompletion, and the app's exhaustive `switch`. Sixb owns both ends, so a new code is a minor\n * version bump: cheap here, and a broken `switch` is better than a 500 from `z.enum`.\n */\nexport type AgentRunDiagnosticCode = (typeof AGENT_RUN_DIAGNOSTIC_CODES)[number]\nexport type AgentRunDiagnosticSeverity = \"warning\" | \"error\"\n\nexport interface AgentRunDiagnostic {\n readonly code: AgentRunDiagnosticCode\n readonly severity: AgentRunDiagnosticSeverity\n /** What the diagnostic is about: the turn as a whole. */\n readonly scope: \"run\"\n /** Sanitized, stable copy suitable for display to an end user. */\n readonly message: string\n}\n\n/**\n * Authorization state for the current queue delivery.\n *\n * `queueLeaseExpiresAt` is a persisted projection of `ClaimedQueueJob.leaseExpiresAt`, not an\n * independently managed run lease. It may only be extended from a successful queue lease renewal.\n */\nexport interface AgentRunExecution {\n readonly token: string\n readonly queueLeaseExpiresAt: Date\n}\n\ninterface AgentRunRecordBase {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly status: AgentRunStatus\n readonly modelId?: string\n /** Why the run ended (our own SDK-independent enum). */\n readonly finishReason?: AgentRunFinishReason\n /** Platform diagnostics are transcript annotations, never agent-authored message content. */\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n /** Portable failure snapshot when the run did not succeed. */\n readonly error?: SixbFailure<AgentRunFailureCode>\n /** Execution attempts: `0` while queued, `1` on first start, incremented on redelivery. */\n readonly attempt: number\n readonly execution?: AgentRunExecution\n readonly createdAt: Date\n readonly startedAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface ConversationAgentRunRecord extends AgentRunRecordBase {\n readonly kind: \"conversation\"\n readonly threadId: string\n readonly triggerMessageId: string\n /** Immutable model selection captured at admission. Absent only on runs predating this field. */\n readonly spec?: ConversationAgentRunSpec\n}\n\n/** Immutable, serialisable model selection and requester settings for one conversational turn. */\nexport interface ConversationAgentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the turn runs on. */\n readonly tier?: LanguageModelTier\n /**\n * How likely the decision model judged each tier, when Sixb picked the turn's model. Kept to\n * calibrate the thresholds the tier is picked from (`heavy` from 0.4, `light` from 0.8).\n */\n readonly tierProbabilities?: LanguageModelTierProbabilities\n readonly reasoning?: AgentReasoning\n /** Canonical IANA time zone of the requester. Absent uses the project time zone. */\n readonly timeZone?: string\n /** Canonical BCP 47 language of the requester. Absent uses the project locale. */\n readonly locale?: string\n /** What the turn may change without asking its requester. Absent on older runs: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n}\n\n/** Immutable, serialisable child configuration captured before dispatch. */\nexport interface SubagentRunSpec {\n readonly model: LanguageModelRef\n /** With tiers, the tier of the model the child runs on. Absent on children admitted before it. */\n readonly tier?: LanguageModelTier\n readonly reasoning?: AgentReasoning\n /** Focused task supplied by the parent Agent. */\n readonly task: string\n /** Project tools available when the child was admitted. Runtime tools are injected separately. */\n readonly toolNames: readonly string[]\n readonly maxSteps: number\n /** The parent turn's mode, copied when the child was admitted. Absent: `auto`. */\n readonly approvalMode?: AgentApprovalMode\n /**\n * ISO time the parent turn times out at. The child's wall clock ends there, so its wait in the\n * queue counts against it. Absent on children admitted before it: the worker's turn timeout.\n */\n readonly deadline?: string\n /** The parent turn's requester settings. Absent uses the project's. */\n readonly timeZone?: string\n readonly locale?: string\n /** Files the parent handed over, copied into the child's sandbox at these paths. */\n readonly files?: readonly SubagentRunFile[]\n}\n\n/** A file a parent and its child hand each other, stored once and copied into a sandbox. */\nexport interface SubagentRunFile {\n /** Relative, `/`-separated, without `.` or `..` segments. */\n readonly path: string\n readonly fileRef: FileRef\n}\n\n/** Durable child output returned to its parent by `wait_agent`. */\nexport interface SubagentRunResult {\n /** Empty only for a child that paused on its held calls before it answered. */\n readonly text: string\n /** What the child wrote under `out/`, by path relative to it. */\n readonly files?: readonly SubagentRunFile[]\n /** Why none of what it wrote under `out/` came back, and what to do about it. */\n readonly filesError?: string\n}\n\nexport interface SubagentRunRecord extends AgentRunRecordBase {\n readonly kind: \"subagent\"\n /** The child's own thread, which holds its task and its work. */\n readonly threadId: string\n /** The message of its thread that started the run. */\n readonly triggerMessageId: string\n /** The conversation turn the child runs under: its deadline, mode and cancellation. */\n readonly parentRunId: string\n /** Stable parent-selected key that makes repeated tool execution idempotent. */\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n readonly result?: SubagentRunResult\n}\n\nexport type AgentRunRecord = ConversationAgentRunRecord | SubagentRunRecord\n\nexport interface CreateAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly threadId: string\n readonly triggerMessageId: string\n readonly spec: ConversationAgentRunSpec\n readonly createdAt?: Date\n}\n\nexport interface CreateSubagentRunInput {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly parentRunId: string\n /** Current parent delivery token. New children are admitted only while that delivery owns it. */\n readonly parentExecutionToken: string\n readonly spawnKey: string\n readonly spec: SubagentRunSpec\n /**\n * The child's thread. Its first run creates it, owned by the conversation's owner; a later run\n * goes into it, and is refused while another run of the thread is active.\n */\n readonly thread: { readonly id: string; readonly create: boolean }\n /** The user message that starts the run, appended to the child's thread with the run's id. */\n readonly trigger: Pick<AppendAgentMessageInput, \"id\" | \"parts\" | \"metadata\">\n /** Internal safety bound enforced atomically across worker processes. */\n readonly maxActiveChildren: number\n readonly createdAt?: Date\n}\n\nexport interface StartAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly modelId?: string\n readonly execution: AgentRunExecution\n readonly startedAt?: Date\n}\n\nexport interface FinishQueuedAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly status: \"failed\" | \"cancelled\"\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n}\n\nexport interface ReclaimAgentRunInput {\n readonly id: string\n readonly projectId: string\n readonly execution: AgentRunExecution\n}\n\nexport interface ConfirmAgentRunExecutionOwnershipInput {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n /** Exact expiration returned by the queue claim or its latest successful renewal. */\n readonly queueLeaseExpiresAt: Date\n}\n\nexport type FinishAgentRunInput =\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"succeeded\"\n readonly modelId?: string\n readonly finishReason?: AgentRunFinishReason\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly result?: SubagentRunResult\n readonly completedAt?: Date\n }\n | {\n readonly id: string\n readonly projectId: string\n readonly executionToken: string\n readonly status: \"failed\" | \"cancelled\"\n readonly modelId?: string\n /** Only a succeeded run pauses. */\n readonly finishReason?: Exclude<AgentRunFinishReason, \"awaiting_approval\" | \"awaiting_answer\">\n readonly diagnostics?: readonly AgentRunDiagnostic[]\n readonly error?: SixbFailure<AgentRunFailureCode>\n readonly completedAt?: Date\n }\n\nexport interface ListAgentRunsInput {\n readonly projectId: string\n readonly kinds?: readonly AgentRunKind[]\n readonly threadId?: string\n readonly parentRunId?: string\n readonly statuses?: readonly AgentRunStatus[]\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedAfter?: Date\n /** Effective start time; runs that never started use `createdAt`. */\n readonly startedBefore?: Date\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListThreadSubagentsInput {\n readonly projectId: string\n /** The conversation whose turns spawned them. */\n readonly threadId: string\n readonly spawnKey?: string\n readonly finishReason?: AgentRunFinishReason\n /** At most this many, 100 by default. */\n readonly limit?: number\n}\n\nexport interface ListAgentRunsResult {\n readonly runs: readonly AgentRunRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_messages — one message (assistant messages inserted only once finalized) ─────────────\n\nexport type { AgentMessageRole }\n\nexport interface AgentMessageRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /**\n * The run that produced this message; `null` for user-authored messages. In a sub-agent's thread\n * every message has one, its trigger too, so a run's messages are deleted whole. A message copied\n * by a fork keeps the run that produced it, which belongs to the thread it was copied from.\n */\n readonly runId: string | null\n readonly role: AgentMessageRole\n /** Principal that authored this persisted message: caller for user messages, agent identity later for assistant messages. */\n readonly authorPrincipal?: Principal\n /** Monotonic per thread, assigned by the store. */\n readonly seq: number\n /** Structured message content — text / reasoning / step boundaries / tool calls. */\n readonly parts: readonly AgentMessagePart[]\n /** Message-level metadata (mirrors `UIMessage.metadata`). */\n readonly metadata?: JsonValue\n /** Versions the `parts` shape so it can be migrated; stamped from `AGENT_MESSAGE_CONTENT_VERSION`. */\n readonly contentVersion: number\n readonly createdAt: Date\n readonly completedAt?: Date\n}\n\n/** Append a message: a {@link AgentMessage} (role + parts + metadata) plus its storage identity. */\nexport interface AppendAgentMessageInput extends AgentMessage {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly runId: string | null\n readonly authorPrincipal?: Principal\n readonly createdAt?: Date\n readonly completedAt?: Date\n}\n\nexport interface DeleteAgentMessagesByRunInput {\n readonly projectId: string\n readonly threadId: string\n readonly runId: string\n}\n\nexport interface ListAgentMessagesInput {\n readonly projectId: string\n readonly threadId: string\n /** Return only messages whose per-thread sequence is greater than this retained boundary. */\n readonly afterSeq?: number\n readonly roles?: readonly AgentMessageRole[]\n readonly limit?: number\n readonly offset?: number\n readonly order?: \"asc\" | \"desc\"\n}\n\nexport interface ListAgentMessagesResult {\n readonly messages: readonly AgentMessageRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n// ── agent_context_checkpoints — append-only model-context boundaries ──────────────────────────\n\nexport type AgentContextCheckpointReason = \"threshold\" | \"overflow\"\n\n/**\n * A durable summary boundary used only when projecting a thread into model context.\n *\n * Checkpoints never replace or mutate transcript messages. Normal thread reads remain authoritative\n * and complete; the worker reads the latest checkpoint and only the retained message tail.\n */\nexport interface AgentContextCheckpointRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** A fork's copy keeps the run that wrote the summary, in the thread it was copied from. */\n readonly createdByRunId: string\n readonly previousCheckpointId?: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt: Date\n}\n\nexport interface CreateAgentContextCheckpointInput {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n readonly createdByRunId: string\n /** Compare-and-swap anchor. `null` means the thread must not have a prior checkpoint. */\n readonly expectedPreviousCheckpointId: string | null\n /** Compare-and-swap anchor for the complete transcript observed by the summarizer. */\n readonly expectedHeadSeq: number\n /** Current delivery token for `createdByRunId`; stale redeliveries must not write. */\n readonly executionToken: string\n readonly reason: AgentContextCheckpointReason\n readonly summary: string\n readonly summaryFormatVersion: 1\n readonly summarizedThroughSeq: number\n readonly observedHeadSeq: number\n readonly estimatedInputTokensBefore: number\n readonly estimatedInputTokensAfter: number\n readonly summaryModelId: string\n readonly createdAt?: Date\n}\n\n// ── Store ───────────────────────────────────────────────────────────────────────────────────────\n\nexport interface AgentThreadStore {\n /** Atomic run-fenced transition, or explicit idle-thread recreation. */\n transitionSandbox(input: TransitionAgentThreadSandboxInput): Promise<AgentThreadSandboxState>\n create(input: CreateAgentThreadInput): Promise<AgentThreadRecord>\n /**\n * Create a thread holding a copy of another's finished history, in one transaction. The source's\n * sub-agent threads are not copied, and a sub-agent's thread is refused.\n */\n fork(input: ForkAgentThreadInput): Promise<AgentThreadRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentThreadRecord | null>\n /** The threads found, in first-occurrence input order; a missing one is omitted. */\n getByIds(params: {\n readonly projectId: string\n readonly ids: readonly string[]\n }): Promise<readonly AgentThreadRecord[]>\n list(input: ListAgentThreadsInput): Promise<ListAgentThreadsResult>\n /** The sub-agents' threads of a conversation, by creation and id, all of them or one turn's. */\n listChildren(input: ListAgentThreadChildrenInput): Promise<readonly AgentThreadRecord[]>\n /**\n * Add users atomically and return every participant of the thread afterwards. A sub-agent's\n * thread has none: its readers are its conversation's.\n */\n addParticipants(\n input: AddAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n /** Whether the user took part until now. */\n removeParticipant(input: RemoveAgentThreadParticipantInput): Promise<boolean>\n /** The participants of these threads, oldest first, then by user id and thread id. */\n listParticipants(\n input: ListAgentThreadParticipantsInput\n ): Promise<readonly AgentThreadParticipantRecord[]>\n}\n\nexport interface AgentRunStore {\n /**\n * Persist a queued turn and atomically claim the thread's single-flight slot. A sub-agent's\n * thread takes only child runs.\n */\n create(input: CreateAgentRunInput): Promise<ConversationAgentRunRecord>\n /**\n * Persist or replay one idempotent child run while atomically enforcing parent fan-out. In one\n * transaction it creates the child's thread or takes it (single-flight, as a conversation), then\n * appends the trigger and the run.\n */\n createSubagent(input: CreateSubagentRunInput): Promise<SubagentRunRecord>\n /** Transition a queued run to running and install the first delivery's execution token. */\n start(input: StartAgentRunInput): Promise<AgentRunRecord>\n /** Finish a queued run before execution and release the thread's single-flight slot. */\n finishQueued(input: FinishQueuedAgentRunInput): Promise<AgentRunRecord>\n /** Rotate the execution token for a redelivered running job (`attempt++`). */\n reclaim(input: ReclaimAgentRunInput): Promise<AgentRunRecord>\n /**\n * Project the queue's latest confirmed ownership expiration onto the current execution.\n * Implementations must fence by token and must never move the expiration backwards.\n */\n confirmExecutionOwnership(input: ConfirmAgentRunExecutionOwnershipInput): Promise<AgentRunRecord>\n /**\n * Finalize a run and release the thread's `activeRunId`. `finishReason: \"awaiting_approval\"`\n * needs a call the run holds (see `approvals.holdsRun`). A turn that ends any other way cancels\n * its pending approvals and stops resuming on the rest; a child that fails or is cancelled\n * cancels its own pending ones.\n */\n finish(input: FinishAgentRunInput): Promise<AgentRunRecord>\n getById(params: { projectId: string; id: string }): Promise<AgentRunRecord | null>\n getByIds(params: {\n projectId: string\n ids: readonly string[]\n }): Promise<readonly AgentRunRecord[]>\n /**\n * The children of a conversation's turns, the latest turn's first, by its effective start, and\n * within a turn the latest admitted first. Read by key (one per turn) or by finish reason.\n */\n listThreadSubagents(input: ListThreadSubagentsInput): Promise<readonly SubagentRunRecord[]>\n list(input: ListAgentRunsInput): Promise<ListAgentRunsResult>\n}\n\nexport interface AgentMessageStore {\n /** Insert a message (its `parts` are the canonical content) and bump thread stats. */\n append(input: AppendAgentMessageInput): Promise<AgentMessageRecord>\n /** Delete every message produced by one run and repair the thread's message stats. */\n deleteByRunId(input: DeleteAgentMessagesByRunInput): Promise<number>\n getById(params: { projectId: string; id: string }): Promise<AgentMessageRecord | null>\n list(input: ListAgentMessagesInput): Promise<ListAgentMessagesResult>\n}\n\nexport interface AgentContextCheckpointStore {\n /**\n * Append one checkpoint after atomically validating run ownership and both transcript anchors.\n * Repeating the same payload for the same creating run is idempotent.\n */\n create(input: CreateAgentContextCheckpointInput): Promise<AgentContextCheckpointRecord>\n /** The thread's checkpoints created by the requested runs, in first-occurrence input order. */\n getByRunIds(input: {\n readonly projectId: string\n readonly threadId: string\n readonly runIds: readonly string[]\n }): Promise<readonly AgentContextCheckpointRecord[]>\n getLatest(input: {\n readonly projectId: string\n readonly threadId: string\n }): Promise<AgentContextCheckpointRecord | null>\n}\n\n// ── agent_approvals — calls of the Agent that wait for whoever asked ───────────────────────────\n\n/**\n * What the Agent may change without asking its requester: `manual` asks for every action and\n * workflow, `accept-edits` runs the actions that only change Sixb, `auto` runs everything.\n */\nexport const AGENT_APPROVAL_MODES = [\"manual\", \"accept-edits\", \"auto\"] as const\n\nexport type AgentApprovalMode = (typeof AGENT_APPROVAL_MODES)[number]\n\n/** The modes that hold some calls: the one that held a call is recorded on its approval. */\nexport const AGENT_HOLDING_APPROVAL_MODES = [\n \"manual\",\n \"accept-edits\",\n] as const satisfies readonly AgentApprovalMode[]\n\nexport type AgentHoldingApprovalMode = (typeof AGENT_HOLDING_APPROVAL_MODES)[number]\n\nexport const AGENT_APPROVAL_STATUSES = [\n \"pending\",\n \"approved\",\n \"denied\",\n \"cancelled\",\n \"superseded\",\n \"expired\",\n] as const\n\nexport type AgentApprovalStatus = (typeof AGENT_APPROVAL_STATUSES)[number]\n\n/** The statuses a pending approval is settled to without a decision. */\nexport type AgentApprovalSettledStatus = Extract<\n AgentApprovalStatus,\n \"cancelled\" | \"superseded\" | \"expired\"\n>\n\n/**\n * The held call, as it runs once approved. An action's params are normalized: what the user\n * approves is exactly what runs. Its run id is the one the Agent named, so a repeated request finds\n * the same approval and the same run.\n */\nexport type AgentApprovalCall =\n | {\n readonly kind: \"action\"\n readonly actionId: string\n readonly subject: ActionSubject\n readonly params: ActionRunParams\n readonly actionRunId: string\n /** `external` when the action has a writeback or effects: it reaches beyond Sixb. */\n readonly effect: \"ontology\" | \"external\"\n }\n | {\n readonly kind: \"workflow\"\n readonly workflowId: string\n readonly input: JsonObject\n readonly workflowRunId: string\n }\n\n/** What running an approved call gave. */\nexport type AgentApprovalOutcome =\n | {\n readonly kind: \"action-run\"\n readonly runId: string\n readonly status: \"succeeded\" | \"failed\"\n readonly error?: ActionRunFailure\n }\n | { readonly kind: \"workflow-run\"; readonly runId: string; readonly queuedAt: string }\n /** The call was refused when it ran, for example because its requester lost a grant. */\n | { readonly kind: \"error\"; readonly error: SixbFailure }\n\nexport interface AgentApprovalRecord {\n readonly id: string\n readonly projectId: string\n readonly threadId: string\n /** The conversation turn the call belongs to. */\n readonly runId: string\n /** The run that made the call: the turn itself, or one of its children. */\n readonly callerRunId: string\n /** Who asked for the turn: the only one who decides, as the call runs with their rights. */\n readonly requestedBy: Principal\n /** The mode that held the call. */\n readonly mode: AgentHoldingApprovalMode\n /** The call's run id, unique among a thread's pending, approved and denied approvals. */\n readonly callKey: string\n readonly call: AgentApprovalCall\n readonly status: AgentApprovalStatus\n readonly createdAt: Date\n readonly expiresAt: Date\n readonly decidedAt?: Date\n readonly decidedBy?: Principal\n /** Set once an approved call ran. */\n readonly outcome?: AgentApprovalOutcome\n /** The user message that told the model how the approval ended. */\n readonly reportedInMessageId?: string\n /** \"Always allow\": the mode its requester raised the turn's calls to when deciding this one. */\n readonly raisedMode?: AgentApprovalMode\n /**\n * The turn will not resume for it: stopped, its requester left, or another of its calls was set\n * aside. The thread's next message still reports it.\n */\n readonly turnStoppedAt?: Date\n /** When a process last took the approved call to run it; a stale claim can be taken again. */\n readonly executionClaimedAt?: Date\n}\n\nexport interface RequestAgentApprovalInput {\n readonly id: string\n readonly projectId: string\n readonly runId: string\n readonly callerRunId: string\n /** The caller run's current delivery token: a stale delivery holds nothing. */\n readonly executionToken: string\n readonly requestedBy: Principal\n readonly mode: AgentHoldingApprovalMode\n readonly call: AgentApprovalCall\n readonly createdAt?: Date\n readonly expiresAt: Date\n}\n\nexport interface RequestAgentApprovalResult {\n readonly approval: AgentApprovalRecord\n /** `false` when a pending, approved or denied approval of the thread had the same call key. */\n readonly created: boolean\n}\n\nexport interface DecideAgentApprovalInput {\n readonly projectId: string\n readonly id: string\n readonly decision: \"approved\" | \"denied\"\n readonly decidedBy: Principal\n readonly decidedAt?: Date\n /** With `approved`: \"Always allow\" raised the turn's mode to this one. */\n readonly raisedMode?: AgentApprovalMode\n}\n\nexport interface DecideAgentApprovalResult {\n /** The approval afterwards: `expired` when its time ran out before this decision. */\n readonly approval: AgentApprovalRecord\n /** Whether this call moved it out of `pending` with the decision. */\n readonly decided: boolean\n}\n\nexport interface SettleAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n readonly status: AgentApprovalSettledStatus\n}\n\n/** Stop a thread's turn, or a requester's turns there, from resuming on their calls. */\nexport interface StopAgentApprovalsInput {\n readonly projectId: string\n readonly threadId: string\n /** Only the calls of this conversation turn. */\n readonly runId?: string\n /** Only the calls this principal asked for. */\n readonly requestedBy?: Principal\n readonly stoppedAt?: Date\n}\n\nexport interface StopAgentApprovalsResult {\n /** The pending approvals it cancelled. */\n readonly cancelled: readonly AgentApprovalRecord[]\n /** How many unreported approvals it stopped, the cancelled ones included. */\n readonly stopped: number\n}\n\n/** Where a keyset listing resumes: after this approval, in the order approvals are listed. */\nexport interface AgentApprovalCursor {\n readonly createdAt: Date\n readonly id: string\n}\n\nexport interface MarkAgentApprovalsReportedInput {\n readonly projectId: string\n readonly threadId: string\n readonly ids: readonly string[]\n readonly messageId: string\n /** A resume: an approval whose turn was stopped is not marked. */\n readonly resuming?: boolean\n}\n\nexport interface ListAgentApprovalsInput {\n readonly projectId: string\n readonly threadId?: string\n readonly runId?: string\n readonly requestedBy?: Principal\n readonly statuses?: readonly AgentApprovalStatus[]\n /** `false`: only the approvals no message reported yet. */\n readonly reported?: boolean\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentApprovalsResult {\n /** Oldest first. */\n readonly approvals: readonly AgentApprovalRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Held calls and their decisions. `runs.finish` settles a run's approvals in its own transaction:\n * a turn that pauses keeps them for their decision, any other ending cancels its pending ones.\n */\nexport interface AgentApprovalStore {\n /**\n * Fenced like a checkpoint: the caller run is running with `executionToken`, and is the\n * conversation turn `runId` or one of its children. Returns the thread's pending, approved or\n * denied approval with the same call key when there is one, and creates one otherwise.\n */\n request(input: RequestAgentApprovalInput): Promise<RequestAgentApprovalResult>\n /** Compare-and-swap from `pending`; `null` when no such approval exists. */\n decide(input: DecideAgentApprovalInput): Promise<DecideAgentApprovalResult | null>\n /** Record what an approved call gave, once: an approval with an outcome is returned unchanged. */\n recordOutcome(input: {\n readonly projectId: string\n readonly id: string\n readonly outcome: AgentApprovalOutcome\n }): Promise<AgentApprovalRecord>\n /** Settle the thread's pending approvals, and return the ones it settled. */\n settle(input: SettleAgentApprovalsInput): Promise<readonly AgentApprovalRecord[]>\n /** Expire the project's pending approvals whose time ran out by `now`, and return them. */\n expireDue(input: {\n readonly projectId: string\n readonly now: Date\n readonly limit?: number\n }): Promise<readonly AgentApprovalRecord[]>\n /**\n * Cancel the matching pending approvals and mark every matching one no message reported yet as\n * stopped: their turn never resumes on them.\n */\n stop(input: StopAgentApprovalsInput): Promise<StopAgentApprovalsResult>\n /** Mark the ones no message reported yet, and return their ids. */\n markReported(input: MarkAgentApprovalsReportedInput): Promise<readonly string[]>\n /**\n * Whether the run holds a call: one of its approvals, or one it made for its turn, pending, or\n * decided and not reported yet. `runs.finish` checks the same before `awaiting_approval`.\n */\n holdsRun(input: { readonly projectId: string; readonly runId: string }): Promise<boolean>\n /**\n * Take an approved call without an outcome to run it, unless another process took it after\n * `staleBefore`; its decision is its first claim. `null` when it is not there to take.\n */\n claimExecution(input: {\n readonly projectId: string\n readonly id: string\n readonly claimedAt: Date\n readonly staleBefore: Date\n }): Promise<AgentApprovalRecord | null>\n /**\n * What a repair pass works on, oldest first: approved calls without an outcome whose claim is\n * older than `claimableBefore`, and decided calls no message reported whose turn is not stopped.\n */\n listRepairable(input: {\n readonly projectId: string\n readonly claimableBefore: Date\n readonly after?: AgentApprovalCursor\n readonly limit: number\n }): Promise<readonly AgentApprovalRecord[]>\n getById(params: {\n readonly projectId: string\n readonly id: string\n }): Promise<AgentApprovalRecord | null>\n list(input: ListAgentApprovalsInput): Promise<ListAgentApprovalsResult>\n}\n\n/** Each user's approval mode: a default, and their own choice in each thread. */\nexport interface AgentApprovalModeStore {\n getDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n setDefault(input: {\n readonly projectId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode\n readonly updatedAt?: Date\n }): Promise<void>\n getForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n }): Promise<AgentApprovalMode | null>\n /**\n * `null` clears the choice: the user's turns in the thread follow their default again. Throws\n * `thread_not_found` when the thread does not exist.\n */\n setForThread(input: {\n readonly projectId: string\n readonly threadId: string\n readonly principal: Principal\n readonly mode: AgentApprovalMode | null\n readonly updatedAt?: Date\n }): Promise<void>\n}\n\n// ── Memory ──────────────────────────────────────────────────────────────────────────────────────\n\n/** One file of a memory repo, at its path from the repo root. */\nexport interface AgentMemoryFile {\n readonly path: string\n readonly contents: string\n}\n\n/** A memory repo as of its latest revision. */\nexport interface AgentMemoryRepoRecord {\n /** 0 before the first save. */\n readonly revision: number\n /** Ordered by path. */\n readonly files: readonly AgentMemoryFile[]\n}\n\n/** One change of a save: the file's new contents, or `null` to delete it. */\nexport interface AgentMemoryChange {\n readonly path: string\n readonly contents: string | null\n}\n\nexport interface SaveAgentMemoryInput {\n readonly projectId: string\n /** `user:<userId>` or `project`. */\n readonly repoId: string\n /** The revision the caller loaded. */\n readonly baseRevision: number\n readonly message: string\n readonly author: Principal\n /** The conversation the save came from, `/agents/<threadId>`. */\n readonly source?: string\n readonly changes: readonly AgentMemoryChange[]\n readonly createdAt?: Date\n}\n\nexport type SaveAgentMemoryResult =\n | { readonly saved: true; readonly revision: number }\n | {\n readonly saved: false\n /** The repo's latest revision. */\n readonly revision: number\n /** Files in `changes` that another save changed after `baseRevision`, as they are now. */\n readonly conflicts: readonly AgentMemoryChange[]\n }\n\n/** One save: who made it, why, and which paths it wrote. A revision never changes. */\nexport interface AgentMemoryRevisionRecord {\n readonly revision: number\n readonly message: string\n readonly author: Principal\n readonly source?: string\n /** Ordered by path. */\n readonly changes: readonly { readonly path: string; readonly deleted: boolean }[]\n readonly createdAt: Date\n}\n\nexport interface ListAgentMemoryRevisionsInput {\n readonly projectId: string\n readonly repoId: string\n readonly limit?: number\n readonly offset?: number\n}\n\nexport interface ListAgentMemoryRevisionsResult {\n /** Newest first. */\n readonly revisions: readonly AgentMemoryRevisionRecord[]\n readonly hasMore: boolean\n readonly total: number\n}\n\n/**\n * Memory repos as append-only revisions: a save inserts one revision and the files it wrote, and\n * never updates a row. Paths, sizes and who may save are decided in Core before a call reaches\n * storage.\n */\nexport interface AgentMemoryStore {\n /**\n * The repo at its latest revision, or with `asOf` at the latest revision saved by then, and with\n * `revision` at the latest up to that one: revision 0 and no files when none was. File versions\n * pruned from the history are missing from it.\n */\n get(input: {\n readonly projectId: string\n readonly repoId: string\n readonly asOf?: Date\n readonly revision?: number\n }): Promise<AgentMemoryRepoRecord>\n /**\n * In one transaction: reports a conflict when a path in `changes` was written after\n * `baseRevision`, or when the repo is behind `baseRevision` because it was deleted; otherwise\n * stores the next revision. The same transaction removes file versions older than\n * {@link AGENT_MEMORY_HISTORY_DAYS} days that are not their path's latest.\n */\n save(input: SaveAgentMemoryInput): Promise<SaveAgentMemoryResult>\n listRevisions(input: ListAgentMemoryRevisionsInput): Promise<ListAgentMemoryRevisionsResult>\n /** Deletes the repo with its history. */\n delete(input: { readonly projectId: string; readonly repoId: string }): Promise<void>\n}\n\n/** How long a file version that is not its path's latest stays in a repo's history. */\nexport const AGENT_MEMORY_HISTORY_DAYS = 90\n\nexport interface AgentStorage {\n readonly threads: AgentThreadStore\n readonly runs: AgentRunStore\n readonly messages: AgentMessageStore\n readonly checkpoints: AgentContextCheckpointStore\n readonly memory: AgentMemoryStore\n readonly approvals: AgentApprovalStore\n readonly approvalModes: AgentApprovalModeStore\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AAsNO,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAYO,IAAM,4BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,SAAS,2BAA0B,CACxC,OACkC;AAAA,EAClC,IAAI,UAAU,QAAQ,UAAU,WAAW;AAAA,IACzC;AAAA,EACF;AAAA,EACA,OAAQ,0BAA+C,SAAS,KAAK,IAChE,QACD;AAAA;AAIC,IAAM,8BAA6B,CAAC,sBAAsB,sBAAsB;AA+dhF,IAAM,wBAAuB,CAAC,UAAU,gBAAgB,MAAM;AAK9D,IAAM,gCAA+B;AAAA,EAC1C;AAAA,EACA;AACF;AAIO,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAmXO,IAAM,4BAA4B;",
|
|
8
|
-
"debugId": "CFEE1A61093E1DAC64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/operation-scope.ts", "../src/storage/objects/guard.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { AsyncLocalStorage } from \"node:async_hooks\"\nimport type { AgentStorage } from \"./agents\"\nimport type { AuthStorage } from \"./auth\"\nimport type { ObjectStorage } from \"./objects\"\nimport { createGuardedObjectReadStorage, requireObjectReadScopeFactory } from \"./objects/guard\"\nimport type { OntologyStorage } from \"./ontology\"\nimport type { WorkflowRunStorage } from \"./workflow-runs\"\n\nexport type StorageOperationRunner = <TResult>(\n run: () => Promise<TResult> | TResult\n) => Promise<TResult>\n\n/** Provider-owned execution boundary for root storage operations. */\nexport interface StorageOperationScope {\n assertAvailable(): void\n run<TResult>(operation: () => Promise<TResult> | TResult): Promise<TResult>\n}\n\nexport function createStorageOperationScope(\n run: StorageOperationRunner,\n assertAvailable: () => void = () => undefined\n): StorageOperationScope {\n const executions = new AsyncLocalStorage<{ active: boolean }>()\n return {\n assertAvailable,\n async run(operation) {\n const inherited = executions.getStore()\n if (inherited?.active) {\n assertAvailable()\n return operation()\n }\n\n const execution = { active: true }\n try {\n return await executions.run(execution, () => run(operation))\n } finally {\n execution.active = false\n }\n },\n }\n}\n\nconst operationScopeTargets = new WeakMap<object, object>()\n\n/**\n * Give every async operation exposed by a store one provider-owned execution scope.\n *\n * Storage contracts use `async` methods for I/O and reserve synchronous methods for local\n * capabilities such as `queryCapabilities()`. Discovering the former from their implementation\n * removes the second, manually synchronized method registry that previously coupled every storage\n * primitive to the SQLite/InMemory lock.\n */\nexport function createOperationScopedFacade<T extends object>(\n target: T,\n scope: StorageOperationScope,\n propertyOverrides: Partial<T> = {}\n): T {\n const methodKinds = discoverMethodKinds(target)\n const overrideKeys = new Set(Reflect.ownKeys(propertyOverrides))\n const methodCache = new Map<\n PropertyKey,\n { implementation: (...args: unknown[]) => unknown; exposed: (...args: unknown[]) => unknown }\n >()\n\n const facade = new Proxy(target, {\n get(current, property) {\n if (overrideKeys.has(property)) {\n return Reflect.get(propertyOverrides, property, propertyOverrides)\n }\n\n const value = Reflect.get(current, property, current)\n const kind = methodKinds.get(property)\n if (!kind || typeof value !== \"function\") return value\n const implementation = value as (...args: unknown[]) => unknown\n\n const cached = methodCache.get(property)\n if (cached?.implementation === implementation) return cached.exposed\n\n const exposed = scopeMethod(implementation, kind, current, scope)\n methodCache.set(property, { implementation, exposed })\n return exposed\n },\n set(current, property, value) {\n if (overrideKeys.has(property)) return false\n return Reflect.set(current, property, value, current)\n },\n defineProperty(current, property, attributes) {\n if (overrideKeys.has(property)) return false\n return Reflect.defineProperty(current, property, attributes)\n },\n deleteProperty(current, property) {\n if (overrideKeys.has(property)) return false\n return Reflect.deleteProperty(current, property)\n },\n })\n operationScopeTargets.set(facade, target)\n return facade\n}\n\ntype StorageMethod = (...args: never[]) => unknown\ntype StorageMethodKey<T> = {\n [TKey in keyof T]-?: T[TKey] extends StorageMethod ? TKey : never\n}[keyof T]\n\n/** Replace a provider method behind its scoped facade without exposing the raw provider. */\nexport function decorateOperationScopedMethodForTesting<\n T extends object,\n TKey extends StorageMethodKey<T>,\n>(\n facade: T,\n property: TKey,\n decorate: (implementation: Extract<T[TKey], StorageMethod>) => Extract<T[TKey], StorageMethod>\n): () => void {\n const target = operationScopeTargets.get(facade)\n if (!target) throw new Error(\"[Sixb] Expected an operation-scoped storage facade.\")\n\n const previousDescriptor = Reflect.getOwnPropertyDescriptor(target, property)\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") {\n throw new Error(`[Sixb] Storage property '${String(property)}' is not a method.`)\n }\n\n const boundImplementation = ((...args: never[]) =>\n Reflect.apply(implementation, target, args)) as Extract<T[TKey], StorageMethod>\n const decorated = decorate(boundImplementation)\n Reflect.defineProperty(target, property, {\n configurable: true,\n enumerable: previousDescriptor?.enumerable ?? false,\n writable: true,\n value: decorated,\n })\n\n return () => {\n if (previousDescriptor) {\n Reflect.defineProperty(target, property, previousDescriptor)\n } else {\n Reflect.deleteProperty(target, property)\n }\n }\n}\n\ntype StorageMethodKind = \"async\" | \"async-generator\" | \"sync\"\n\nfunction discoverMethodKinds(target: object): ReadonlyMap<PropertyKey, StorageMethodKind> {\n const methodKeys = new Set<PropertyKey>()\n for (\n let current: object | null = target;\n current && current !== Object.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n for (const property of Reflect.ownKeys(current)) {\n if (property !== \"constructor\") methodKeys.add(property)\n }\n }\n\n const methodKinds = new Map<PropertyKey, StorageMethodKind>()\n for (const property of methodKeys) {\n const implementation = Reflect.get(target, property, target)\n if (typeof implementation !== \"function\") continue\n methodKinds.set(property, methodKind(implementation))\n }\n return methodKinds\n}\n\nfunction methodKind(implementation: (...args: unknown[]) => unknown): StorageMethodKind {\n if (isAsyncFunction(implementation)) return \"async\"\n if (isAsyncGeneratorFunction(implementation)) return \"async-generator\"\n return \"sync\"\n}\n\nfunction scopeMethod(\n implementation: (...args: unknown[]) => unknown,\n kind: StorageMethodKind,\n target: object,\n scope: StorageOperationScope\n): (...args: unknown[]) => unknown {\n if (kind === \"async\") {\n return (...args: unknown[]) => scope.run(() => Reflect.apply(implementation, target, args))\n }\n\n if (kind === \"async-generator\") {\n return (...args: unknown[]) => {\n scope.assertAvailable()\n return scopeSteps(\n Reflect.apply(implementation, target, args) as AsyncIterable<unknown>,\n scope\n )\n }\n }\n\n return implementation.bind(target)\n}\n\n/**\n * Each step of a stream runs in its own operation scope, released between steps: a page holds the\n * provider's lock while it reads, never while its consumer works on it.\n */\nfunction scopeSteps<T>(\n stream: AsyncIterable<T>,\n scope: StorageOperationScope\n): AsyncIterableIterator<T> {\n let iterator: AsyncIterator<T> | undefined\n const steps = () => {\n iterator ??= stream[Symbol.asyncIterator]()\n return iterator\n }\n const scoped: AsyncIterableIterator<T> = {\n next: (...args) => scope.run(() => steps().next(...args)),\n return: (value) =>\n scope.run(async () => (await steps().return?.(value)) ?? { done: true, value }),\n throw: (error) =>\n scope.run(async () => {\n const current = steps()\n if (!current.throw) throw error\n return current.throw(error)\n }),\n [Symbol.asyncIterator]: () => scoped,\n }\n return scoped\n}\n\nexport function createAuthOperationScope<T extends AuthStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AuthStorage>(target, scope, {\n users: createOperationScopedFacade(target.users, scope),\n identities: createOperationScopedFacade(target.identities, scope),\n serviceAccounts: createOperationScopedFacade(target.serviceAccounts, scope),\n serviceAccountGroupMemberships: createOperationScopedFacade(\n target.serviceAccountGroupMemberships,\n scope\n ),\n sessions: createOperationScopedFacade(target.sessions, scope),\n accessTokens: createOperationScopedFacade(target.accessTokens, scope),\n invitations: createOperationScopedFacade(target.invitations, scope),\n groupMemberships: createOperationScopedFacade(target.groupMemberships, scope),\n magicLinks: createOperationScopedFacade(target.magicLinks, scope),\n oidcAuthorizationAttempts: createOperationScopedFacade(target.oidcAuthorizationAttempts, scope),\n deviceAuthorizations: createOperationScopedFacade(target.deviceAuthorizations, scope),\n }) as T\n}\n\nexport function createAgentOperationScope<T extends AgentStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<AgentStorage>(target, scope, {\n threads: createOperationScopedFacade(target.threads, scope),\n runs: createOperationScopedFacade(target.runs, scope),\n messages: createOperationScopedFacade(target.messages, scope),\n checkpoints: createOperationScopedFacade(target.checkpoints, scope),\n memory: createOperationScopedFacade(target.memory, scope),\n approvals: createOperationScopedFacade(target.approvals, scope),\n approvalModes: createOperationScopedFacade(target.approvalModes, scope),\n }) as T\n}\n\nexport function createOntologyOperationScope<T extends OntologyStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<OntologyStorage>(target, scope, {\n commits: createOperationScopedFacade(target.commits, scope),\n sources: createOperationScopedFacade(target.sources, scope),\n materializations: createOperationScopedFacade(target.materializations, scope),\n replacementPlans: createOperationScopedFacade(target.replacementPlans, scope),\n outbox: createOperationScopedFacade(target.outbox, scope),\n uniqueValues: createOperationScopedFacade(target.uniqueValues, scope),\n ...(target.vectors ? { vectors: createOperationScopedFacade(target.vectors, scope) } : {}),\n }) as T\n}\n\n/** Keep synchronously created scoped readers inside the provider's root operation scope. */\nexport function createObjectOperationScope<T extends ObjectStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n const factory = requireObjectReadScopeFactory(target)\n return createOperationScopedFacade<ObjectStorage>(target, scope, {\n createSelectedReadScope: (params) => {\n scope.assertAvailable()\n return createGuardedObjectReadStorage(factory.createSelectedReadScope(params), scope)\n },\n createConditionalReadScope: (params) => {\n scope.assertAvailable()\n return createGuardedObjectReadStorage(factory.createConditionalReadScope(params), scope)\n },\n }) as T\n}\n\nexport function createWorkflowRunOperationScope<T extends WorkflowRunStorage>(\n target: T,\n scope: StorageOperationScope\n): T {\n return createOperationScopedFacade<WorkflowRunStorage>(target, scope, {\n nodes: createOperationScopedFacade(target.nodes, scope),\n agentNodes: createOperationScopedFacade(target.agentNodes, scope),\n }) as T\n}\n\nfunction isAsyncFunction(value: unknown): value is (...args: unknown[]) => Promise<unknown> {\n return typeof value === \"function\" && value.constructor.name === \"AsyncFunction\"\n}\n\nfunction isAsyncGeneratorFunction(value: unknown): boolean {\n return typeof value === \"function\" && value.constructor.name === \"AsyncGeneratorFunction\"\n}\n",
|
|
6
|
-
"import type { ObjectReadScopeFactory, ObjectReadStorage, ObjectStorage } from \"./types\"\n\nexport interface ObjectReadStorageCallGuard {\n assertAvailable(): void\n run<TResult>(operation: () => Promise<TResult>): Promise<TResult>\n}\n\n/** Validate the required runtime capability before any facade can expose broad object reads. */\nexport function requireObjectReadScopeFactory(storage: ObjectStorage): ObjectReadScopeFactory {\n if (\n typeof storage.createSelectedReadScope !== \"function\" ||\n typeof storage.createConditionalReadScope !== \"function\"\n ) {\n throw new Error(\n \"[Sixb] Object storage provider must implement ObjectReadScopeFactory to create selected and conditional object readers.\"\n )\n }\n return storage\n}\n\n/**\n * Guard every scoped-reader terminal without proxying the provider reader.\n *\n * First-party providers freeze their readers. A Proxy cannot substitute a frozen own method\n * without violating JavaScript's invariants, so operation and lifetime guards use this explicit\n * facade instead.\n */\nexport function createGuardedObjectReadStorage(\n reader: ObjectReadStorage,\n guard: ObjectReadStorageCallGuard\n): ObjectReadStorage {\n const guarded: ObjectReadStorage = {\n queryCapabilities: () => {\n guard.assertAvailable()\n return reader.queryCapabilities()\n },\n getByPrimaryId: (input) => guard.run(() => reader.getByPrimaryId(input)),\n getByUniqueValue: (input) => guard.run(() => reader.getByUniqueValue(input)),\n selectsObjectProperties: (input) => guard.run(() => reader.selectsObjectProperties(input)),\n listLinks: (input) => guard.run(() => reader.listLinks(input)),\n getByPrimaryIdBatch: (input) => guard.run(() => reader.getByPrimaryIdBatch(input)),\n listLinksBatch: (input) => guard.run(() => reader.listLinksBatch(input)),\n queryLinks: (input) => guard.run(() => reader.queryLinks(input)),\n list: (input) => guard.run(() => reader.list(input)),\n }\n if (reader.queryObjects) {\n guarded.queryObjects = (input) => guard.run(() => reader.queryObjects!(input))\n }\n if (reader.countObjects) {\n guarded.countObjects = (input) => guard.run(() => reader.countObjects!(input))\n }\n if (reader.existsObjects) {\n guarded.existsObjects = (input) => guard.run(() => reader.existsObjects!(input))\n }\n if (reader.facetObjects) {\n guarded.facetObjects = (input) => guard.run(() => reader.facetObjects!(input))\n }\n return Object.freeze(guarded)\n}\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": ";;AAAA;;;ACQO,SAAS,6BAA6B,CAAC,SAAgD;AAAA,EAC5F,IACE,OAAO,QAAQ,4BAA4B,cAC3C,OAAO,QAAQ,+BAA+B,YAC9C;AAAA,IACA,MAAM,IAAI,MACR,yHACF;AA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A+B,QAAQ,wBAAwB,MAAM,GAAG,KAAK;AAAA;AAAA,IAEtF,4BAA4B,CAAC,WAAW;AAAA,MACtC,MAAM,gBAAgB;AAAA,MACtB,OAAO,+BAA+B,QAAQ,2BAA2B,MAAM,GAAG,KAAK;AAAA;AAAA,EAE3F,CAAC;AAAA;AAGI,SAAS,gCAA6D,CAC3E,QACA,OACG;AAAA,EACH,OAAO,6BAAgD,QAAQ,OAAO;AAAA,IACpE,OAAO,6BAA4B,OAAO,OAAO,KAAK;AAAA,IACtD,YAAY,6BAA4B,OAAO,YAAY,KAAK;AAAA,EAClE,CAAC;AAAA;AAGH,SAAS,eAAe,CAAC,OAAmE;AAAA,EAC1F,OAAO,OAAO,UAAU,cAAc,MAAM,YAAY,SAAS;AAAA;AAGnE,SAAS,wBAAwB,CAAC,OAAyB;AAAA,EACzD,OAAO,OAAO,UAAU,cAAc,MAAM,YAAY,SAAS;AAAA;",
|
|
9
|
-
"debugId": "B768222FF5DAE8C564756E2164756E21",
|
|
10
|
-
"names": []
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/models/execution/model-call-limits.ts", "../src/models/execution/errors.ts", "../src/models/execution/model-call-accounting.ts", "../src/models/execution/usage.ts", "../src/models/execution/model-call-recovery.ts", "../src/models/execution/model-call-recorder.ts", "../src/models/execution/model-call-admission.ts", "../src/models/execution/recovery-queue.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { isSixbError } from \"../../errors/internal\"\nimport type { AuthorizablePrincipal } from \"../../execution\"\nimport type {\n AiLimitPolicy,\n AiLimitQuantity,\n AiModelCallReservationIdentity,\n ReserveAiModelCallResult,\n} from \"../../storage\"\nimport {\n aiLimitSubjectsFromAttribution,\n aiUsageLimitExceededError,\n aiUsageLimitUnavailableError,\n applicableAiLimitPolicies,\n} from \"../../storage/ai-limits/enforcement\"\nimport { aiLimitMeterApplies } from \"../../storage/ai-limits/provider\"\nimport type {\n AiModelCallAdmissionDecision,\n AiModelCallAdmissionInput,\n BeforeAiModelCall,\n MarkAiModelCallUnknown,\n} from \"./model-call-admission\"\nimport type { ModelCallAccountingStorage } from \"./types\"\n\nexport interface AiModelCallLimitController {\n readonly beforeModelCall: BeforeAiModelCall\n readonly markModelCallUnknown: MarkAiModelCallUnknown\n}\n\n/** Build the reservation lifecycle for model calls from any execution. */\nexport function createAiModelCallLimitController(input: {\n readonly storage: Pick<ModelCallAccountingStorage, \"aiLimits\">\n readonly projectId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly requesterGroupIds: readonly string[]\n}): AiModelCallLimitController {\n const subjects = aiLimitSubjectsFromAttribution(input.requestedBy, input.requesterGroupIds)\n\n return {\n beforeModelCall: async (admission) => {\n let applicable: readonly AiLimitPolicy[]\n try {\n const policies = await input.storage.aiLimits.listPolicies({\n projectId: input.projectId,\n })\n applicable = applicableAiLimitPolicies(policies, subjects).filter((policy) =>\n aiLimitMeterApplies(policy.limit.meter, admission.modelKind)\n )\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n // This read is the fast no-policy path. A concurrently created policy linearizes after it;\n // every later call will see it, while existing policies always continue to atomic reserve.\n if (applicable.length === 0) return { reservation: \"none\" }\n\n const estimates = reservationEstimates(\n admission,\n applicable.some((policy) => policy.limit.meter === \"cost.catalogEstimated\")\n )\n if (estimates.length === 0) {\n throw aiUsageLimitUnavailableError([\"missingEstimate\"])\n }\n\n let result: ReserveAiModelCallResult\n try {\n result = await input.storage.aiLimits.reserveModelCall({\n ...reservationIdentity(admission),\n subjects,\n estimates,\n ...(admission.modelKind === undefined ? {} : { modelKind: admission.modelKind }),\n })\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n switch (result.status) {\n case \"reserved\":\n return { reservation: \"active\" } satisfies AiModelCallAdmissionDecision\n case \"notRequired\":\n return { reservation: \"none\" } satisfies AiModelCallAdmissionDecision\n case \"denied\":\n throw aiUsageLimitExceededError(result.resetAt)\n case \"unavailable\":\n throw aiUsageLimitUnavailableError(result.reasons)\n case \"terminal\":\n throw aiUsageLimitUnavailableError([\"terminalReservationReplay\"])\n }\n },\n markModelCallUnknown: async (identity) => {\n try {\n await input.storage.aiLimits.markReservationUnknown(identity)\n } catch (error) {\n throw limitStorageUnavailable(error)\n }\n },\n }\n}\n\nfunction reservationEstimates(\n input: AiModelCallAdmissionInput,\n needsCost: boolean\n): readonly AiLimitQuantity[] {\n const estimates: AiLimitQuantity[] = []\n if (input.inputTokens.status === \"estimated\" && input.estimatedTotalTokens !== undefined) {\n estimates.push({ meter: \"tokens.total\", amount: input.estimatedTotalTokens })\n }\n\n if (needsCost) {\n try {\n let money = input.reservationCost\n if (money == null && input.inputTokens.status === \"estimated\") {\n money = input.costEstimator?.estimateReservation?.({\n inputTokens: input.inputTokens.tokens,\n outputTokens: input.outputTokenAllowance,\n })\n }\n\n if (money) {\n estimates.push({ meter: \"cost.catalogEstimated\", amount: money })\n }\n } catch {\n // An unavailable price must not prevent a token-only policy from being evaluated.\n return estimates\n }\n }\n\n return estimates\n}\n\nfunction reservationIdentity(input: AiModelCallAdmissionInput): AiModelCallReservationIdentity {\n return {\n projectId: input.projectId,\n executionId: input.executionId,\n attempt: input.attempt,\n callId: input.callId,\n }\n}\n\nfunction limitStorageUnavailable(error: unknown): unknown {\n if (\n isSixbError(error) &&\n (error.code === \"ai.usage_limit_exceeded\" || error.code === \"ai.usage_limit_unavailable\")\n ) {\n return error\n }\n return aiUsageLimitUnavailableError([\"limitStorageUnavailable\"])\n}\n",
|
|
6
|
-
"/** A provider call was not recorded synchronously, so its execution must stop. */\nexport class ModelUsageRecordingError extends Error {\n readonly name = \"ModelUsageRecordingError\"\n\n constructor(\n readonly executionId: string,\n readonly callId: string,\n readonly recoveryScheduled: boolean,\n options?: ErrorOptions\n ) {\n super(\n recoveryScheduled\n ? `[SixbModels] AI usage for call '${callId}' in execution '${executionId}' was deferred to durable recovery.`\n : `[SixbModels] Could not preserve AI usage for call '${callId}' in execution '${executionId}'.`,\n options\n )\n }\n}\n",
|
|
7
|
-
"import { createHash } from \"node:crypto\"\nimport { assertJsonObject } from \"../../json\"\nimport type {\n AiBillableMeter,\n AiCostStorage,\n AiLimitStorage,\n AiModelCallCostRecord,\n AiModelCallUsageRecord,\n AiPricingContext,\n AiUsageStorage,\n RecordAiModelCallResult,\n Storage,\n} from \"../../storage\"\nimport {\n aiModelCallCostMatchesUsage,\n normalizeAiModelCallCostRecord,\n} from \"../../storage/ai-cost/provider\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport type { ModelCostEstimate } from \"../pricing\"\nimport type { ModelCallAccountingStorage, RecoverAiModelCallInput } from \"./types\"\n\ninterface RecordAiModelCallAccountingInput extends RecoverAiModelCallInput {\n readonly storage: Pick<ModelCallAccountingStorage, \"transaction\">\n}\n\ninterface AiAccountingCapabilities {\n readonly aiUsage: AiUsageStorage\n readonly aiCosts: AiCostStorage\n readonly aiLimits: AiLimitStorage\n}\n\n/** Atomically append one provider call's usage and the valuation captured by the model runtime. */\nexport async function recordAiModelCallAccounting(\n input: RecordAiModelCallAccountingInput\n): Promise<RecordAiModelCallResult> {\n return input.storage.transaction(async (tx) => {\n const { aiUsage, aiCosts, aiLimits } = requireAccountingCapabilities(tx)\n const usage = await aiUsage.recordModelCall(input.usage)\n // Usage deduplicates provider lifecycle replays by execution/call identity. Always attach the\n // valuation to the canonical row it returns, not the fresh candidate ID from a replay.\n const canonical = normalizeModelCallAccounting({\n ...input,\n usage: usage.record,\n ratedAt: usage.record.recordedAt,\n })\n const record = modelCostRecord(canonical, usage.record.id)\n const estimate =\n canonical.cost.status !== \"reported\" || canonical.estimate === undefined\n ? undefined\n : modelCostRecord({ ...canonical, cost: canonical.estimate }, usage.record.id)\n await aiCosts.recordModelCallCost({\n ...record,\n ...(estimate === undefined\n ? {}\n : {\n estimate:\n estimate.status === \"rated\"\n ? { status: \"rated\", money: estimate.money, components: estimate.components }\n : {\n status: \"unpriceable\",\n reason: estimate.reason,\n ...(estimate.missingMeters === undefined\n ? {}\n : { missingMeters: estimate.missingMeters }),\n },\n }),\n })\n if (usage.created) {\n await aiLimits.recordModelCallActuals({\n projectId: usage.record.projectId,\n usageRecordId: usage.record.id,\n recordedAt: input.ratedAt,\n })\n }\n if (input.reconcileLimitReservation) {\n await aiLimits.reconcileModelCall({\n projectId: usage.record.projectId,\n executionId: usage.record.executionId,\n attempt: usage.record.attempt,\n callId: usage.record.callId,\n usageRecordId: usage.record.id,\n reconciledAt: input.ratedAt,\n })\n }\n return usage\n })\n}\n\n/** Sanitize optional enrichment before either persistence or a JSON-safe recovery handoff. */\nexport function normalizeModelCallAccounting(\n input: RecoverAiModelCallInput\n): RecoverAiModelCallInput {\n const usage = normalizeAiModelCallRecord(input.usage)\n return {\n ...input,\n cost:\n input.cost.status === \"reported\" ? input.cost : validatedEstimate(input.cost, input, usage),\n ...(input.estimate === undefined\n ? {}\n : { estimate: validatedEstimate(input.estimate, input, usage) }),\n }\n}\n\nfunction validatedEstimate(\n cost: ModelCostEstimate,\n input: RecoverAiModelCallInput,\n usage: AiModelCallUsageRecord\n): ModelCostEstimate {\n try {\n assertJsonObject(cost, \"model cost estimate\")\n const record = normalizeAiModelCallCostRecord(modelCostRecord({ ...input, cost }, usage.id))\n if (!aiModelCallCostMatchesUsage(record, usage)) {\n throw new TypeError(\"Estimate quantities do not match recorded usage.\")\n }\n return structuredClone(cost)\n } catch {\n console.warn(\n \"[SixbModels] Invalid model cost estimate; preserving call usage and provider cost.\"\n )\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n}\n\nfunction modelCostRecord(\n input: RecoverAiModelCallInput,\n usageRecordId: string\n): AiModelCallCostRecord {\n const billingIdentity = {\n providerId: input.usage.providerId,\n modelId: input.usage.requestedModelId,\n }\n const pricingContext: AiPricingContext = {\n ...(input.route?.providerId === undefined ? {} : { routedProviderId: input.route.providerId }),\n ...(input.route?.modelId === undefined ? {} : { routedModelId: input.route.modelId }),\n }\n if (input.cost.status === \"reported\" || input.cost.status === \"rated\") {\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"rated\",\n billingIdentity,\n pricingContext,\n priceSource: costPriceSource(input.usage, input.cost),\n money: input.cost.money,\n components: input.cost.status === \"rated\" ? input.cost.components : [],\n ratedAt: new Date(input.ratedAt),\n }\n }\n\n const reason =\n input.cost.reason === \"missing-rate-card\"\n ? \"missingRateCard\"\n : input.cost.reason === \"missing-usage\"\n ? \"missingUsageMeter\"\n : input.cost.reason === \"unsupported-pricing-dimension\"\n ? \"unsupportedPricingDimension\"\n : \"invalidUsageForFormula\"\n const missingMeters =\n reason === \"missingUsageMeter\" ? normalizeMissingMeters(input.cost.missingMeters) : undefined\n return {\n projectId: input.usage.projectId,\n usageRecordId,\n status: \"unpriceable\",\n billingIdentity,\n pricingContext,\n reason,\n ...(missingMeters === undefined ? {} : { missingMeters }),\n ratedAt: new Date(input.ratedAt),\n }\n}\n\nfunction costPriceSource(\n usage: RecoverAiModelCallInput[\"usage\"],\n cost: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"reported\" | \"rated\" }>\n) {\n if (cost.status === \"reported\") {\n return {\n sourceId: \"provider-reported\",\n sourceEntryId: `${usage.providerId}/${usage.responseId}`,\n sourceVersion: \"response-v1\",\n observedAt: new Date(usage.occurredAt),\n }\n }\n const rates = cost.components.map(({ meter, rateAmountNanosPerMillion }) => ({\n meter,\n rateAmountNanosPerMillion,\n }))\n const version = createHash(\"sha256\").update(JSON.stringify(rates)).digest(\"hex\")\n return {\n sourceId: \"model-rate-card\",\n sourceEntryId: `${usage.providerId}/${usage.requestedModelId}`,\n sourceVersion: `sha256:${version}`,\n observedAt: new Date(usage.occurredAt),\n }\n}\n\nfunction normalizeMissingMeters(\n meters: Extract<RecoverAiModelCallInput[\"cost\"], { status: \"unpriceable\" }>[\"missingMeters\"]\n): readonly AiBillableMeter[] {\n const fallback: readonly AiBillableMeter[] = [\"tokens.input.total\", \"tokens.output.total\"]\n return [...new Set<AiBillableMeter>(meters ?? fallback)]\n}\n\nexport function requireAccountingCapabilities(\n storage: Pick<Storage, \"aiUsage\" | \"aiCosts\" | \"aiLimits\">\n): AiAccountingCapabilities {\n if (!storage.aiUsage || !storage.aiCosts || !storage.aiLimits) {\n throw new Error(\n \"[SixbModels] AI model-call accounting requires storage.aiUsage, storage.aiCosts, and storage.aiLimits.\"\n )\n }\n return { aiUsage: storage.aiUsage, aiCosts: storage.aiCosts, aiLimits: storage.aiLimits }\n}\n",
|
|
8
|
-
"import type { AiModelCallUsageInput } from \"../../storage\"\nimport type { ModelUsage } from \"../events\"\n\n/** Map one provider-neutral model call into Sixb's durable accounting vocabulary. */\nexport function aiModelCallUsageFromModel(usage: ModelUsage): AiModelCallUsageInput {\n return {\n ...(usage.audioDurationMs === undefined ? {} : { audioDurationMs: usage.audioDurationMs }),\n ...(usage.inputTokens === undefined ? {} : { inputTokens: usage.inputTokens }),\n ...(usage.outputTokens === undefined ? {} : { outputTokens: usage.outputTokens }),\n ...(usage.uncachedInputTokens === undefined\n ? {}\n : { uncachedInputTokens: usage.uncachedInputTokens }),\n ...(usage.cacheReadInputTokens === undefined\n ? {}\n : { cacheReadInputTokens: usage.cacheReadInputTokens }),\n ...(usage.cacheWriteInputTokens === undefined\n ? {}\n : { cacheWriteInputTokens: usage.cacheWriteInputTokens }),\n ...(usage.textOutputTokens === undefined ? {} : { textOutputTokens: usage.textOutputTokens }),\n ...(usage.reasoningOutputTokens === undefined\n ? {}\n : { reasoningOutputTokens: usage.reasoningOutputTokens }),\n ...(usage.imageOutputTokens === undefined\n ? {}\n : { imageOutputTokens: usage.imageOutputTokens }),\n ...(usage.audioOutputTokens === undefined\n ? {}\n : { audioOutputTokens: usage.audioOutputTokens }),\n ...(usage.outputImages === undefined ? {} : { outputImages: usage.outputImages }),\n ...(usage.inputCharacters === undefined ? {} : { inputCharacters: usage.inputCharacters }),\n }\n}\n",
|
|
9
|
-
"import type { RecordAiModelCallInput, RecordAiModelCallResult } from \"../../storage\"\nimport { AiCostStorageError, AiLimitStorageError, AiUsageStorageError } from \"../../storage\"\nimport { normalizeAiModelCallRecord } from \"../../storage/ai-usage/record\"\nimport { recordAiModelCallAccounting } from \"./model-call-accounting\"\nimport type {\n AiModelCallAccountingPayload,\n AiModelCallRecordPayload,\n AiModelCallRecoveryRecord,\n ModelCallAccountingStorage,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nclass InvalidAiUsageRecoveryJobError extends Error {\n readonly name = \"InvalidAiUsageRecoveryJobError\"\n\n constructor(message: string, options?: ErrorOptions) {\n super(`[SixbModels] ${message}`, options)\n }\n}\n\n/** Encode one failed accounting transaction for a durable, JSON-safe handoff. */\nexport function modelCallRecoveryPayload(input: RecoverAiModelCallInput): {\n readonly record: AiModelCallRecordPayload\n readonly accounting: AiModelCallAccountingPayload\n} {\n normalizeAiModelCallRecord(input.usage)\n return {\n record: toQueuePayload(input.usage),\n accounting: toAccountingPayload(input),\n }\n}\n\n/** Replay one durable handoff through the idempotent atomic accounting boundary. */\nexport async function recordRecoveredAiModelCall(\n storage: Pick<ModelCallAccountingStorage, \"transaction\">,\n job: AiModelCallRecoveryRecord\n): Promise<RecordAiModelCallResult> {\n const usage = fromQueuePayload(job)\n const accounting = accountingFromQueuePayload(job)\n return recordAiModelCallAccounting({ storage, usage, ...accounting })\n}\n\n/** Validation and referential-integrity failures cannot become valid through queue redelivery. */\nexport function isPermanentAiUsageRecoveryError(error: unknown): boolean {\n return (\n error instanceof InvalidAiUsageRecoveryJobError ||\n error instanceof TypeError ||\n (error instanceof AiUsageStorageError &&\n (error.code === \"duplicate_id\" || error.code === \"missing_execution\")) ||\n (error instanceof AiCostStorageError &&\n (error.code === \"missing_usage\" || error.code === \"cost_mismatch\")) ||\n (error instanceof AiLimitStorageError &&\n (error.code === \"missing_execution\" ||\n error.code === \"missing_reservation\" ||\n error.code === \"missing_usage_record\" ||\n error.code === \"usage_mismatch\" ||\n error.code === \"reservation_conflict\" ||\n error.code === \"reconciliation_conflict\" ||\n error.code === \"invalid_reservation_state\"))\n )\n}\n\nfunction toQueuePayload(record: RecordAiModelCallInput): AiModelCallRecordPayload {\n return {\n id: record.id,\n executionId: record.executionId,\n attempt: record.attempt,\n callId: record.callId,\n requesterGroupIds: [...record.requesterGroupIds],\n providerId: record.providerId,\n ...(record.providerIds === undefined\n ? {}\n : { providerIds: structuredClone(record.providerIds) }),\n requestedModelId: record.requestedModelId,\n ...(record.modelKind === undefined ? {} : { modelKind: record.modelKind }),\n ...(record.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: structuredClone(record.requestedReasoning) }),\n ...(record.responseModelId === undefined ? {} : { responseModelId: record.responseModelId }),\n responseId: record.responseId,\n usage: aiModelCallUsageFromModel(record.usage),\n ...(record.rawUsage === undefined ? {} : { rawUsage: structuredClone(record.rawUsage) }),\n occurredAt: record.occurredAt.toISOString(),\n }\n}\n\nfunction toAccountingPayload(input: RecoverAiModelCallInput): AiModelCallAccountingPayload {\n return {\n cost: structuredClone(input.cost),\n ...(input.estimate === undefined ? {} : { estimate: structuredClone(input.estimate) }),\n ...(input.route === undefined ? {} : { route: structuredClone(input.route) }),\n ratedAt: input.ratedAt.toISOString(),\n ...(input.reconcileLimitReservation ? { reconcileLimitReservation: true } : {}),\n }\n}\n\nfunction fromQueuePayload(job: AiModelCallRecoveryRecord): RecordAiModelCallInput {\n const occurredAt = parseDate(job.payload.record.occurredAt, job.id, \"occurredAt\")\n return { ...job.payload.record, projectId: job.projectId, occurredAt }\n}\n\nfunction accountingFromQueuePayload(\n job: AiModelCallRecoveryRecord\n): Omit<RecoverAiModelCallInput, \"usage\"> {\n const accounting = job.payload.accounting\n return {\n cost: structuredClone(accounting.cost),\n ...(accounting.estimate === undefined\n ? {}\n : { estimate: structuredClone(accounting.estimate) }),\n ...(accounting.route === undefined ? {} : { route: structuredClone(accounting.route) }),\n ratedAt: parseDate(accounting.ratedAt, job.id, \"ratedAt\"),\n reconcileLimitReservation: accounting.reconcileLimitReservation === true,\n }\n}\n\nfunction parseDate(value: string, jobId: string, field: string): Date {\n const date = new Date(value)\n if (!Number.isFinite(date.getTime())) {\n throw new InvalidAiUsageRecoveryJobError(\n `AI usage recovery job '${jobId}' has an invalid ${field} timestamp.`\n )\n }\n return date\n}\n",
|
|
10
|
-
"import { randomUUID } from \"node:crypto\"\nimport type { FileRef } from \"../../blob-storage/types\"\nimport {\n AiUsageStorageError,\n type ReadonlyJsonObject,\n type RecordAiModelCallInput,\n} from \"../../storage\"\nimport type { ModelCallEndEvent, ModelUsage } from \"../events\"\nimport type { LanguageModel } from \"../language-model\"\nimport { ModelUsageRecordingError } from \"./errors\"\nimport {\n normalizeModelCallAccounting,\n recordAiModelCallAccounting,\n requireAccountingCapabilities,\n} from \"./model-call-accounting\"\nimport {\n type AiModelCallAdmissionInput,\n aiModelCallOutputTokenAllowance,\n estimateAiModelCallInputTokens,\n estimatedAiModelCallTotalTokens,\n} from \"./model-call-admission\"\nimport type { AiModelCallLimitController } from \"./model-call-limits\"\nimport { isPermanentAiUsageRecoveryError } from \"./model-call-recovery\"\nimport type {\n ModelCallAccountingStorage,\n RecoverAiModelCall,\n RecoverAiModelCallInput,\n} from \"./types\"\nimport { aiModelCallUsageFromModel } from \"./usage\"\n\nconst STORAGE_RETRY_DELAYS_MS = [50, 200, 600] as const\n\nexport interface AiModelCallRecorderInput {\n readonly storage: ModelCallAccountingStorage\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly limits: AiModelCallLimitController\n readonly recoverAiModelCall: RecoverAiModelCall\n}\n\ninterface AiModelCallRecorderInternals {\n readonly generateId?: () => string\n readonly now?: () => Date\n readonly retryDelaysMs?: readonly number[]\n readonly sleep?: (ms: number) => Promise<void>\n readonly recordAccounting?: (input: RecoverAiModelCallInput) => Promise<void>\n}\n\n/** Persist every completed provider call before another billable loop step can start. */\nexport class AiModelCallRecorder {\n private readonly generateId: () => string\n private readonly now: () => Date\n private readonly retryDelaysMs: readonly number[]\n private readonly sleep: (ms: number) => Promise<void>\n private readonly recordAccounting: (input: RecoverAiModelCallInput) => Promise<void>\n private readonly reservations = new Set<string>()\n private admissionError: unknown\n private recordingError: ModelUsageRecordingError | undefined\n\n constructor(\n private readonly input: AiModelCallRecorderInput,\n internals: AiModelCallRecorderInternals = {}\n ) {\n requireAccountingCapabilities(input.storage)\n this.generateId = internals.generateId ?? (() => `ai_usage_${randomUUID()}`)\n this.now = internals.now ?? (() => new Date())\n this.retryDelaysMs = internals.retryDelaysMs ?? STORAGE_RETRY_DELAYS_MS\n this.sleep = internals.sleep ?? sleep\n this.recordAccounting =\n internals.recordAccounting ??\n (async (recovery) => {\n await recordAiModelCallAccounting({ storage: this.input.storage, ...recovery })\n })\n }\n\n /** The execution every call this recorder admits is attributed to. */\n get executionId(): string {\n return this.input.executionId\n }\n\n /** The execution attempt every call this recorder admits is attributed to. */\n get attempt(): number {\n return this.input.attempt\n }\n\n /** Wrap the resolved model so all calls in an execution share admission. */\n wrapModel(model: LanguageModel): LanguageModel {\n return {\n providerId: model.providerId,\n modelId: model.modelId,\n definition: model.definition,\n costEstimator: model.costEstimator,\n ...(model.validateResponseFormat === undefined\n ? {}\n : { validateResponseFormat: model.validateResponseFormat.bind(model) }),\n stream: async (request) => {\n this.assertHealthy()\n const inputTokens = estimateAiModelCallInputTokens({\n prompt: request.messages,\n tools: request.tools,\n responseFormat: request.responseFormat,\n })\n const outputTokenAllowance = aiModelCallOutputTokenAllowance(request.maxOutputTokens)\n await this.admitCall({\n callId: request.callId,\n providerId: model.providerId,\n modelId: model.modelId,\n costEstimator: model.costEstimator,\n inputTokens,\n outputTokenAllowance,\n estimatedTotalTokens: estimatedAiModelCallTotalTokens(inputTokens, outputTokenAllowance),\n })\n try {\n return await model.stream(request)\n } catch (error) {\n await this.markCallUnknown(request.callId)\n throw error\n }\n },\n }\n }\n\n /** Admit one provider attempt, independently of its language or embedding protocol. */\n async admitCall(\n call: Omit<\n AiModelCallAdmissionInput,\n \"projectId\" | \"executionId\" | \"attempt\" | \"requesterGroupIds\"\n >\n ): Promise<void> {\n this.assertHealthy()\n try {\n const decision = await this.input.limits.beforeModelCall({\n ...call,\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n requesterGroupIds: this.input.requesterGroupIds,\n })\n if (decision.reservation === \"active\") this.reservations.add(call.callId)\n } catch (error) {\n // Execution boundaries must retain the original coded admission failure.\n this.admissionError = error\n throw error\n }\n }\n\n /** Keep an unresolved reservation when an attempted call's billable outcome is unknown. */\n private async markCallUnknown(callId: string): Promise<void> {\n if (!this.reservations.has(callId)) return\n await this.input.limits.markModelCallUnknown({\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId,\n })\n }\n\n readonly onModelCallEnd = async (event: ModelCallEndEvent): Promise<void> => {\n // Calls already in flight still need their own accounting after another call fails.\n // Only admission is gated by the execution's sticky failure.\n try {\n const occurredAt = this.now()\n const record: RecordAiModelCallInput = {\n id: this.generateId(),\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n attempt: this.input.attempt,\n callId: event.callId,\n requesterGroupIds: this.input.requesterGroupIds,\n providerId: event.providerId,\n ...(event.providerIds === undefined ? {} : { providerIds: event.providerIds }),\n requestedModelId: event.modelId,\n ...(event.modelKind === undefined ? {} : { modelKind: event.modelKind }),\n ...(event.requestedReasoning === undefined\n ? {}\n : { requestedReasoning: event.requestedReasoning }),\n ...(event.responseModelId === undefined ? {} : { responseModelId: event.responseModelId }),\n responseId: event.responseId,\n usage: aiModelCallUsageFromModel(event.usage),\n ...(event.usage.raw === undefined ? {} : { rawUsage: rawUsage(event.usage) }),\n occurredAt,\n }\n const recoveryInput = normalizeModelCallAccounting({\n usage: record,\n cost: event.cost,\n ...(event.estimate === undefined ? {} : { estimate: event.estimate }),\n ...(event.route === undefined ? {} : { route: event.route }),\n ratedAt: new Date(occurredAt),\n ...(this.reservations.has(event.callId) ? { reconcileLimitReservation: true } : {}),\n })\n\n try {\n await retryOperation(\n () => this.recordAccounting(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (storageError) {\n if (isPermanentAiUsageRecoveryError(storageError)) throw storageError\n\n try {\n await retryOperation(\n () => this.input.recoverAiModelCall(recoveryInput),\n this.retryDelaysMs,\n this.sleep,\n (error) => !isPermanentAiUsageRecoveryError(error)\n )\n } catch (recoveryError) {\n throw new AggregateError(\n [storageError, recoveryError],\n \"Direct AI accounting and durable recovery both failed.\"\n )\n }\n throw new ModelUsageRecordingError(this.input.executionId, event.callId, true, {\n cause: storageError,\n })\n }\n } catch (error) {\n const recordingError =\n error instanceof ModelUsageRecordingError\n ? error\n : new ModelUsageRecordingError(this.input.executionId, event.callId, false, {\n cause: error,\n })\n this.recordingError ??= recordingError\n throw recordingError\n }\n }\n\n /** Record the files a completed call produced; the call's readers download them through it. */\n async recordFiles(callId: string, files: readonly FileRef[]): Promise<void> {\n try {\n await retryOperation(\n () =>\n this.input.storage.aiUsage.recordModelCallFiles({\n projectId: this.input.projectId,\n executionId: this.input.executionId,\n callId,\n files,\n }),\n this.retryDelaysMs,\n this.sleep,\n (error) => !(error instanceof TypeError || error instanceof AiUsageStorageError)\n )\n } catch (error) {\n throw new Error(\n `[SixbModels] Model call '${callId}' completed, but its files could not be recorded.`,\n { cause: error }\n )\n }\n }\n\n assertHealthy(): void {\n if (this.admissionError !== undefined) throw this.admissionError\n if (this.recordingError) throw this.recordingError\n }\n}\n\nfunction rawUsage(usage: ModelUsage): ReadonlyJsonObject {\n return structuredClone(usage.raw ?? {})\n}\n\nasync function retryOperation<TResult>(\n operation: () => Promise<TResult>,\n retryDelaysMs: readonly number[],\n wait: (ms: number) => Promise<void>,\n shouldRetry: (error: unknown) => boolean\n): Promise<TResult> {\n for (let attempt = 0; ; attempt += 1) {\n try {\n return await operation()\n } catch (error) {\n if (!shouldRetry(error)) throw error\n const delay = retryDelaysMs[attempt]\n if (delay === undefined) throw error\n await wait(delay)\n }\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n",
|
|
11
|
-
"import type { AiModelCallReservationIdentity } from \"../../storage\"\nimport type { ModelKind } from \"../definitions\"\nimport type { ModelCostEstimator, ModelMoney } from \"../pricing\"\n\n/** Default output ceiling when a call and its resolved model supply no limit. */\nexport const AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE = 4_096\n\nexport type AiModelCallInputTokenEstimate =\n | {\n readonly status: \"estimated\"\n readonly tokens: number\n readonly method: \"utf8BytesDividedByFour\"\n }\n | {\n readonly status: \"unavailable\"\n readonly reason: \"nonTextInput\" | \"unserializableInput\"\n }\n\n/** Provider-neutral snapshot passed to aggregate-budget admission before a provider request. */\nexport interface AiModelCallAdmissionInput {\n readonly projectId: string\n readonly executionId: string\n readonly attempt: number\n readonly requesterGroupIds: readonly string[]\n readonly callId: string\n readonly providerId: string\n readonly modelId: string\n /** Selects the applicable limit meters; transcription and reranking skip token limits. */\n readonly modelKind?: ModelKind\n readonly costEstimator?: ModelCostEstimator\n /** A non-token estimate, computed by the resolved binding before inference. */\n readonly reservationCost?: ModelMoney\n readonly inputTokens: AiModelCallInputTokenEstimate\n readonly outputTokenAllowance: number\n readonly estimatedTotalTokens?: number\n}\n\nexport interface AiModelCallAdmissionDecision {\n /** Active means accounting must reconcile the reservation for this provider attempt. */\n readonly reservation: \"active\" | \"none\"\n}\n\nexport type BeforeAiModelCall = (\n input: AiModelCallAdmissionInput\n) => AiModelCallAdmissionDecision | Promise<AiModelCallAdmissionDecision>\n\nexport type MarkAiModelCallUnknown = (input: AiModelCallReservationIdentity) => void | Promise<void>\n\n/**\n * Estimate the exact, prepared provider request without requiring a provider-specific tokenizer.\n *\n * The heuristic is intentionally explicit so reservations are reproducible. Non-text inputs are\n * reported as unavailable; an enforced token or cost policy can then fail closed instead of\n * pretending that an image, file, or provider-defined payload has no token cost.\n */\nexport function estimateAiModelCallInputTokens(input: {\n readonly prompt: unknown\n readonly tools: unknown\n readonly responseFormat: unknown\n}): AiModelCallInputTokenEstimate {\n if (containsNonTextInput(input.prompt)) {\n return { status: \"unavailable\", reason: \"nonTextInput\" }\n }\n\n let serialized: string | undefined\n try {\n serialized = JSON.stringify(input)\n } catch {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n if (serialized === undefined) {\n return { status: \"unavailable\", reason: \"unserializableInput\" }\n }\n\n const bytes = new TextEncoder().encode(serialized).byteLength\n return {\n status: \"estimated\",\n tokens: Math.ceil(bytes / 4),\n method: \"utf8BytesDividedByFour\",\n }\n}\n\nexport function aiModelCallOutputTokenAllowance(maxOutputTokens: number | undefined): number {\n if (maxOutputTokens === undefined) return AI_MODEL_CALL_OUTPUT_TOKEN_ALLOWANCE\n if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens <= 0) {\n throw new TypeError(\n \"[SixbModels] AI model-call maxOutputTokens must be a positive safe integer.\"\n )\n }\n return maxOutputTokens\n}\n\nexport function estimatedAiModelCallTotalTokens(\n inputTokens: AiModelCallInputTokenEstimate,\n outputTokenAllowance: number\n): number | undefined {\n if (inputTokens.status !== \"estimated\") return undefined\n const total = inputTokens.tokens + outputTokenAllowance\n if (!Number.isSafeInteger(total)) {\n throw new TypeError(\"[SixbModels] AI model-call token estimate exceeds the safe range.\")\n }\n return total\n}\n\nfunction containsNonTextInput(value: unknown, seen = new WeakSet<object>()): boolean {\n if (value === null || typeof value !== \"object\") return false\n if (\n value instanceof URL ||\n value instanceof ArrayBuffer ||\n ArrayBuffer.isView(value) ||\n (typeof Blob !== \"undefined\" && value instanceof Blob)\n ) {\n return true\n }\n if (seen.has(value)) return false\n seen.add(value)\n\n if (!Array.isArray(value)) {\n const type = Reflect.get(value, \"type\")\n if (\n type === \"image\" ||\n type === \"file\" ||\n type === \"reasoning-file\" ||\n type === \"custom\" ||\n type === \"provider-state\"\n ) {\n return true\n }\n }\n\n return Object.values(value).some((entry) => containsNonTextInput(entry, seen))\n}\n",
|
|
12
|
-
"import { createSixbError } from \"../../errors/internal\"\nimport type { AgentQueueJob, Queue } from \"../../queues\"\nimport { modelCallRecoveryPayload } from \"./model-call-recovery\"\nimport type { RecoverAiModelCallInput } from \"./types\"\n\n/** Stable queue identity: a lost enqueue response can safely retry the same accounting handoff. */\nfunction agentAiUsageRecoveryJobId(recordId: string): string {\n return `agt_usage_job_${recordId}`\n}\n\n/** Transport adapter for the agent worker's existing durable recovery lane. */\nexport async function enqueueAiModelCallRecovery(\n queue: Pick<Queue<AgentQueueJob>, \"enqueue\">,\n input: RecoverAiModelCallInput\n): Promise<void> {\n const payload = modelCallRecoveryPayload(input)\n const record = input.usage\n const jobId = agentAiUsageRecoveryJobId(record.id)\n const [job] = await queue.enqueue({\n projectId: record.projectId,\n jobs: [{ id: jobId, type: \"agent.ai-usage.record.requested\", payload }],\n })\n\n if (job?.id !== jobId || job.type !== \"agent.ai-usage.record.requested\") {\n throw createSixbError(\n \"internal.unexpected\",\n `[SixbModels] Agent queue did not confirm AI usage recovery job '${jobId}'.`,\n { details: { jobId } }\n )\n }\n}\n"
|
|
13
|
-
],
|
|
14
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,SAAS,iCAAgC,CAAC,OAKlB;AAAA,EAC7B,MAAM,WAAW,gCAA+B,MAAM,aAAa,MAAM,iBAAiB;AAAA,EAE1F,OAAO;AAAA,IACL,iBAAiB,OAAO,cAAc;AAAA,MACpC,IAAI;AAAA,MACJ,IAAI;AAAA,QACF,MAAM,WAAW,MAAM,MAAM,QAAQ,SAAS,aAAa;AAAA,UACzD,WAAW,MAAM;AAAA,QACnB,CAAC;AAAA,QACD,aAAa,2BAA0B,UAAU,QAAQ,EAAE,OAAO,CAAC,WACjE,qBAAoB,OAAO,MAAM,OAAO,UAAU,SAAS,CAC7D;AAAA,QACA,OAAO,OAAO;AAAA,QACd,MAAM,wB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