@sixb/core 0.2.4 → 0.2.5
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 +28 -28
- package/dist/agents/execution.d.ts +34 -2
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +6 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +51 -33
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/queued-turn.d.ts +16 -0
- package/dist/agents/queued-turn.d.ts.map +1 -0
- package/dist/agents/request.d.ts +79 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +10 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +0 -38
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +6 -1
- package/dist/agents/run-events.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -1
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/run-turn.d.ts.map +1 -1
- 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 +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/streams/protocol.d.ts +16 -0
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/turn-answered.d.ts +7 -0
- package/dist/agents/turn-answered.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/canvas-display.d.ts +3 -5
- package/dist/artifacts/canvas-display.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +14 -3
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/document-fill.d.ts +18 -0
- package/dist/artifacts/document-fill.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/events.d.ts +3 -2
- package/dist/artifacts/events.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +40 -4
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +8 -1
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/document-data.d.ts +98 -0
- package/dist/artifacts/frames/document-data.d.ts.map +1 -0
- package/dist/artifacts/frames/entries.d.ts +12 -7
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +2 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +22 -13
- package/dist/artifacts/frames/index.js.map +4 -4
- package/dist/artifacts/frames/kit.d.ts +15 -0
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +12 -1
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +24 -4
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +3 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +9 -3
- package/dist/artifacts/index.js.map +3 -3
- package/dist/artifacts/live/blocks.d.ts +62 -0
- package/dist/artifacts/live/blocks.d.ts.map +1 -0
- package/dist/artifacts/live/board.d.ts +6 -0
- package/dist/artifacts/live/board.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +12 -0
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +2 -0
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +148 -44
- package/dist/artifacts/live/index.js.map +3 -3
- package/dist/artifacts/live/page.d.ts +49 -0
- package/dist/artifacts/live/page.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.d.ts +5 -0
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +2 -2
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +23 -19
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +4 -1
- package/dist/artifacts/live/state.d.ts.map +1 -1
- package/dist/artifacts/outline.d.ts +16 -0
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/paper.d.ts +22 -0
- package/dist/artifacts/paper.d.ts.map +1 -0
- package/dist/artifacts/pdf-job.d.ts +9 -0
- package/dist/artifacts/pdf-job.d.ts.map +1 -0
- package/dist/artifacts/publish/fields.d.ts +25 -0
- package/dist/artifacts/publish/fields.d.ts.map +1 -0
- package/dist/artifacts/publish/index.d.ts +2 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +26 -18
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +5 -5
- package/dist/artifacts/publish/merge.d.ts.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts +28 -0
- package/dist/artifacts/publish/pdf.d.ts.map +1 -0
- package/dist/artifacts/publish/previews.d.ts +12 -20
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/queries.d.ts +6 -1
- package/dist/artifacts/publish/queries.d.ts.map +1 -1
- package/dist/artifacts/publish/query-answers.d.ts +5 -2
- package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
- package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/document.d.ts +5 -3
- package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +16 -2
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/blob-storage/index.js +1 -1
- package/dist/bootstrap/index.js +38 -38
- package/dist/{chunk-8bns0y68.js → chunk-0hkdtwqk.js} +5 -5
- package/dist/{chunk-p8pgnq8d.js → chunk-0mvjpgvm.js} +5 -5
- package/dist/{chunk-2bn6813a.js → chunk-1yh6jgtz.js} +1 -1
- package/dist/{chunk-msyevpp3.js → chunk-5t9gm5tt.js} +4 -4
- package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
- package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
- package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
- package/dist/{chunk-td26wjr5.js → chunk-68hm50qh.js} +3 -3
- package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
- package/dist/chunk-8tv3qd65.js.map +12 -0
- package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
- package/dist/{chunk-3z1vxzcm.js → chunk-aw1z0gre.js} +4 -4
- package/dist/{chunk-evj5jxz3.js → chunk-b4escq4c.js} +62 -14
- package/dist/{chunk-evj5jxz3.js.map → chunk-b4escq4c.js.map} +7 -7
- package/dist/chunk-bqr703h4.js +1799 -0
- package/dist/chunk-bqr703h4.js.map +13 -0
- package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
- package/dist/chunk-c29729me.js.map +12 -0
- package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
- package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
- package/dist/{chunk-3014rfjz.js → chunk-ewqn51gr.js} +25 -7
- package/dist/{chunk-3014rfjz.js.map → chunk-ewqn51gr.js.map} +3 -3
- package/dist/{chunk-t0s7b3d1.js → chunk-ey1p8w68.js} +173 -4
- package/dist/chunk-ey1p8w68.js.map +13 -0
- package/dist/{chunk-gxwy4c3s.js → chunk-fpf57gca.js} +316 -57
- package/dist/chunk-fpf57gca.js.map +47 -0
- package/dist/{chunk-r9rtavg9.js → chunk-fzae1jpq.js} +7 -7
- package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
- package/dist/chunk-fzbhybya.js.map +11 -0
- package/dist/{chunk-w1wq7gfr.js → chunk-gjhrz66x.js} +225 -17
- package/dist/{chunk-w1wq7gfr.js.map → chunk-gjhrz66x.js.map} +5 -5
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-vepea5c3.js → chunk-k29n4176.js} +6 -6
- package/dist/{chunk-48c1z8nj.js → chunk-k3jh8gsg.js} +10 -2
- package/dist/chunk-k3jh8gsg.js.map +10 -0
- package/dist/{chunk-yy914zfr.js → chunk-m3qx2pns.js} +751 -93
- package/dist/chunk-m3qx2pns.js.map +34 -0
- package/dist/{chunk-smnt672s.js → chunk-m9ketb51.js} +20 -4
- package/dist/chunk-m9ketb51.js.map +10 -0
- package/dist/chunk-mbwsgjn7.js +40 -0
- package/dist/chunk-mbwsgjn7.js.map +11 -0
- package/dist/{chunk-sysnvjce.js → chunk-naxjka9v.js} +2 -2
- package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
- package/dist/chunk-nxysqbt0.js.map +10 -0
- package/dist/{chunk-vzkxqf8h.js → chunk-paxabbqd.js} +49 -5
- package/dist/chunk-paxabbqd.js.map +23 -0
- package/dist/{chunk-8tqnsx3q.js → chunk-pc7kra3k.js} +5 -3
- package/dist/{chunk-8tqnsx3q.js.map → chunk-pc7kra3k.js.map} +3 -3
- package/dist/{chunk-6ef4esq4.js → chunk-pqvvqc65.js} +4 -4
- package/dist/chunk-pvpq483h.js.map +2 -2
- package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
- package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
- package/dist/{chunk-8t2ynwg0.js → chunk-q8d9p0tb.js} +24 -1
- package/dist/{chunk-8t2ynwg0.js.map → chunk-q8d9p0tb.js.map} +3 -3
- package/dist/{chunk-wa05txmk.js → chunk-qavwr628.js} +49 -5
- package/dist/chunk-qavwr628.js.map +12 -0
- package/dist/{chunk-rsrc7vtw.js → chunk-rg725hry.js} +174 -30
- package/dist/{chunk-rsrc7vtw.js.map → chunk-rg725hry.js.map} +9 -8
- package/dist/{chunk-rsxb14an.js → chunk-s1mqyqmm.js} +3 -3
- package/dist/{chunk-p351afzm.js → chunk-s5pj68fa.js} +2 -2
- package/dist/{chunk-855w9nvw.js → chunk-vehcr9eb.js} +1 -1
- package/dist/{chunk-hvbvq7p4.js → chunk-vs2s3p8n.js} +731 -10
- package/dist/chunk-vs2s3p8n.js.map +20 -0
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-n68vz95m.js → chunk-wqe9shx2.js} +1 -1
- package/dist/{chunk-0k3r5kb3.js → chunk-xcrnrpfh.js} +1 -1
- package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
- package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
- package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
- package/dist/chunk-xxfj0rr2.js.map +13 -0
- package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
- package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
- package/dist/{chunk-rtm1jq00.js → chunk-z1njfqqs.js} +439 -48
- package/dist/{chunk-rtm1jq00.js.map → chunk-z1njfqqs.js.map} +10 -8
- package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
- package/dist/chunk-z4jqb44a.js.map +10 -0
- package/dist/{chunk-s7xqfxs9.js → chunk-zft9bzbc.js} +2 -1
- package/dist/{chunk-s7xqfxs9.js.map → chunk-zft9bzbc.js.map} +3 -3
- package/dist/{chunk-7kpqntgw.js → chunk-zxhym8tr.js} +1 -1
- package/dist/connectors/connection-handles.d.ts +9 -0
- package/dist/connectors/connection-handles.d.ts.map +1 -0
- package/dist/connectors/connections/authorizations.d.ts +9 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/events.d.ts +17 -0
- package/dist/connectors/connections/events.d.ts.map +1 -0
- package/dist/connectors/connections/runs.d.ts +3 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +4 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +7 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +22 -1
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +3 -2
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/services.d.ts.map +1 -1
- package/dist/deploy/types.d.ts +18 -1
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/events/definitions.d.ts +4 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -3
- package/dist/events/outbox-dispatcher.d.ts +7 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/scope.d.ts +1 -0
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +9 -1
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/selectors/types.d.ts +18 -3
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/types/artifacts.d.ts +7 -1
- package/dist/events/types/artifacts.d.ts.map +1 -1
- package/dist/events/types/connectors.d.ts +32 -0
- package/dist/events/types/connectors.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/execution/agent.js +28 -28
- package/dist/execution/authorization.d.ts +5 -0
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/primitive.js +28 -28
- package/dist/execution/request.js +29 -29
- package/dist/execution/scopes.d.ts +8 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/script.d.ts +7 -0
- package/dist/execution/script.d.ts.map +1 -0
- package/dist/execution/types.d.ts +16 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -44
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +1 -1
- package/dist/lineage/executors.d.ts +1 -1
- package/dist/lineage/executors.d.ts.map +1 -1
- package/dist/maintenance/index.js +1 -1
- package/dist/materialization/event-envelopes.d.ts +3 -3
- package/dist/materialization/event-envelopes.d.ts.map +1 -1
- package/dist/materialization/events.d.ts +6 -0
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.js +1 -1
- package/dist/materialization/model.d.ts +6 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.js +13 -13
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +2 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +1 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/execution/index.js +12 -12
- package/dist/objects/index.js +28 -28
- package/dist/objects/query/index.js +12 -12
- package/dist/pipelines/index.js +18 -18
- package/dist/projections/builders.d.ts +7 -1
- 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 +13 -13
- package/dist/projections/types.d.ts +10 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +2 -1
- 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 +40 -13
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +13 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +39 -18
- package/dist/runtime/internal.js.map +4 -3
- package/dist/runtime/resolve-definitions.d.ts +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/script.d.ts +39 -0
- package/dist/runtime/script.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts +2 -0
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/shares/internal.js +12 -12
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +26 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +12 -3
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +25 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +155 -0
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +7 -1
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +1 -1
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +2 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +34 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +3 -3
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +1 -1
- package/dist/storage/executions/types.d.ts +6 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +18 -14
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -6
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +8 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/workflow-runs/provider.js +3 -3
- package/dist/syncs/index.js +19 -19
- package/dist/testing/agent-execution.d.ts +3 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
- package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5524 -4555
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +3 -4
- package/dist/webhooks/connections.d.ts.map +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +16 -49
- package/dist/webhooks/internal.js.map +3 -3
- package/dist/webhooks/types.d.ts +2 -11
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
- package/dist/workflows/index.js +35 -35
- package/package.json +6 -1
- package/src/agents/README.md +6 -2
- package/src/agents/execution.ts +167 -29
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +18 -4
- package/src/agents/queued-turn.ts +46 -0
- package/src/agents/request.ts +517 -2
- package/src/agents/run-after-finish.ts +259 -2
- package/src/agents/run-artifacts.ts +3 -93
- package/src/agents/run-events.ts +26 -1
- package/src/agents/run-session-http.ts +9 -2
- package/src/agents/run-session-serve.ts +2 -8
- package/src/agents/run-session.ts +142 -3
- package/src/agents/run-turn.ts +8 -0
- package/src/agents/streams/index.ts +1 -0
- package/src/agents/streams/protocol.ts +41 -1
- package/src/agents/turn-answered.ts +31 -0
- package/src/agents/validation.ts +2 -0
- package/src/artifacts/canvas-display.ts +4 -6
- package/src/artifacts/comments.ts +70 -17
- package/src/artifacts/document-fill.ts +103 -0
- package/src/artifacts/errors.ts +2 -0
- package/src/artifacts/events.ts +4 -1
- package/src/artifacts/execution.ts +265 -31
- package/src/artifacts/frames/assets.ts +42 -7
- package/src/artifacts/frames/document-data.ts +353 -0
- package/src/artifacts/frames/entries.ts +22 -16
- package/src/artifacts/frames/grants.ts +2 -2
- package/src/artifacts/frames/index.ts +3 -0
- package/src/artifacts/frames/kit.ts +102 -0
- package/src/artifacts/frames/protocol.ts +12 -1
- package/src/artifacts/frames/runtime.ts +413 -6
- package/src/artifacts/index.ts +3 -0
- package/src/artifacts/live/blocks.ts +889 -0
- package/src/artifacts/live/board.ts +195 -42
- package/src/artifacts/live/document.ts +170 -5
- package/src/artifacts/live/index.ts +7 -0
- package/src/artifacts/live/page.ts +807 -0
- package/src/artifacts/live/protocol.ts +5 -0
- package/src/artifacts/live/server.ts +2 -2
- package/src/artifacts/live/state.ts +9 -4
- package/src/artifacts/outline.ts +17 -0
- package/src/artifacts/paper.ts +173 -0
- package/src/artifacts/pdf-job.ts +11 -0
- package/src/artifacts/publish/fields.ts +177 -0
- package/src/artifacts/publish/index.ts +6 -1
- package/src/artifacts/publish/merge.ts +14 -12
- package/src/artifacts/publish/pdf.ts +82 -0
- package/src/artifacts/publish/previews.ts +24 -34
- package/src/artifacts/publish/publish.ts +26 -3
- package/src/artifacts/publish/queries.ts +20 -4
- package/src/artifacts/publish/query-answers.ts +14 -3
- package/src/artifacts/publish/validate/document-html.ts +245 -0
- package/src/artifacts/publish/validate/document.ts +34 -3
- package/src/artifacts/queries.ts +59 -13
- package/src/authorization/event-visibility.ts +13 -0
- package/src/connectors/connection-handles.ts +71 -0
- package/src/connectors/connections/authorizations.ts +50 -2
- package/src/connectors/connections/events.ts +57 -0
- package/src/connectors/connections/runs.ts +5 -0
- package/src/connectors/connections/service.ts +19 -1
- package/src/connectors/execution.ts +30 -2
- package/src/connectors/index.ts +3 -0
- package/src/connectors/types.ts +29 -1
- package/src/deploy/index.ts +1 -0
- package/src/deploy/services.ts +1 -0
- package/src/deploy/types.ts +26 -1
- package/src/events/definitions.ts +14 -0
- package/src/events/execution.ts +9 -2
- package/src/events/index.ts +8 -0
- package/src/events/outbox-dispatcher.ts +12 -2
- package/src/events/scope.ts +3 -0
- package/src/events/selectors/builder.ts +49 -0
- package/src/events/selectors/index.ts +5 -0
- package/src/events/selectors/predicate.ts +2 -0
- package/src/events/selectors/types.ts +30 -1
- package/src/events/types/artifacts.ts +7 -1
- package/src/events/types/connectors.ts +36 -0
- package/src/events/types/index.ts +7 -0
- package/src/execution/authorization.ts +45 -0
- package/src/execution/durable.ts +2 -0
- package/src/execution/scopes.ts +24 -0
- package/src/execution/script.ts +27 -0
- package/src/execution/types.ts +7 -1
- package/src/http/api-routes.ts +25 -0
- package/src/index.ts +21 -2
- package/src/lineage/executors.ts +3 -1
- package/src/materialization/event-envelopes.ts +10 -5
- package/src/materialization/events.ts +2 -0
- package/src/materialization/model.ts +6 -0
- package/src/materializer/README.md +10 -0
- package/src/materializer/projections/replace.ts +42 -1
- package/src/materializer/projections/replacement-plan.ts +44 -4
- package/src/materializer/shared/normalize.ts +4 -0
- package/src/projections/builders.ts +20 -0
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +2 -0
- package/src/projections/types.ts +11 -0
- package/src/projections/validation.ts +6 -0
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +3 -1
- package/src/queues/types.ts +45 -14
- package/src/runtime/host.ts +112 -4
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +4 -1
- package/src/runtime/script.ts +62 -0
- package/src/runtime/sixb.ts +3 -3
- package/src/schedules/builders.ts +4 -1
- package/src/schedules/runtime.ts +3 -0
- package/src/schedules/validation.ts +20 -2
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +229 -1
- package/src/storage/agents/index.ts +16 -0
- package/src/storage/agents/provider.ts +284 -2
- package/src/storage/agents/types.ts +167 -0
- package/src/storage/artifacts/in-memory.ts +32 -1
- package/src/storage/artifacts/index.ts +2 -0
- package/src/storage/artifacts/record.ts +25 -2
- package/src/storage/artifacts/types.ts +37 -0
- package/src/storage/executions/provider.ts +22 -2
- package/src/storage/executions/types.ts +2 -0
- package/src/storage/executions/validation.ts +27 -0
- package/src/storage/index.ts +18 -0
- package/src/storage/internal.ts +1 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
- package/src/storage/ontology/replacement-plans.ts +6 -0
- package/src/storage/operation-scope.ts +1 -0
- package/src/testing/agent-execution.ts +45 -2
- package/src/testing/agent-inbox-storage-contract.ts +815 -0
- package/src/testing/agent-storage-contract.ts +103 -0
- package/src/testing/artifact-storage-contract.ts +72 -4
- package/src/testing/execution-storage-contract.ts +31 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/materializer-storage-contract.ts +139 -1
- package/src/testing/queues-contract.ts +22 -0
- package/src/webhooks/connections.ts +9 -50
- package/src/webhooks/index.ts +0 -2
- package/src/webhooks/types.ts +2 -13
- package/src/workers/queued-run-dispatch.ts +8 -1
- package/dist/chunk-48c1z8nj.js.map +0 -10
- package/dist/chunk-58geavnf.js +0 -29
- package/dist/chunk-58geavnf.js.map +0 -10
- package/dist/chunk-9nsjjd44.js.map +0 -12
- package/dist/chunk-b9qfh2ya.js.map +0 -11
- package/dist/chunk-eptrvnby.js.map +0 -12
- package/dist/chunk-f6ahf5gf.js.map +0 -13
- package/dist/chunk-gxwy4c3s.js.map +0 -47
- package/dist/chunk-hvbvq7p4.js.map +0 -18
- package/dist/chunk-m2jerfef.js +0 -474
- package/dist/chunk-m2jerfef.js.map +0 -11
- package/dist/chunk-n4zzaf6q.js.map +0 -10
- package/dist/chunk-smnt672s.js.map +0 -10
- package/dist/chunk-t0s7b3d1.js.map +0 -13
- package/dist/chunk-vzkxqf8h.js.map +0 -23
- package/dist/chunk-wa05txmk.js.map +0 -11
- package/dist/chunk-yv8hv4wq.js.map +0 -10
- package/dist/chunk-yy914zfr.js.map +0 -30
- /package/dist/{chunk-8bns0y68.js.map → chunk-0hkdtwqk.js.map} +0 -0
- /package/dist/{chunk-p8pgnq8d.js.map → chunk-0mvjpgvm.js.map} +0 -0
- /package/dist/{chunk-2bn6813a.js.map → chunk-1yh6jgtz.js.map} +0 -0
- /package/dist/{chunk-msyevpp3.js.map → chunk-5t9gm5tt.js.map} +0 -0
- /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
- /package/dist/{chunk-td26wjr5.js.map → chunk-68hm50qh.js.map} +0 -0
- /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
- /package/dist/{chunk-3z1vxzcm.js.map → chunk-aw1z0gre.js.map} +0 -0
- /package/dist/{chunk-r9rtavg9.js.map → chunk-fzae1jpq.js.map} +0 -0
- /package/dist/{chunk-vepea5c3.js.map → chunk-k29n4176.js.map} +0 -0
- /package/dist/{chunk-sysnvjce.js.map → chunk-naxjka9v.js.map} +0 -0
- /package/dist/{chunk-6ef4esq4.js.map → chunk-pqvvqc65.js.map} +0 -0
- /package/dist/{chunk-rsxb14an.js.map → chunk-s1mqyqmm.js.map} +0 -0
- /package/dist/{chunk-p351afzm.js.map → chunk-s5pj68fa.js.map} +0 -0
- /package/dist/{chunk-855w9nvw.js.map → chunk-vehcr9eb.js.map} +0 -0
- /package/dist/{chunk-n68vz95m.js.map → chunk-wqe9shx2.js.map} +0 -0
- /package/dist/{chunk-0k3r5kb3.js.map → chunk-xcrnrpfh.js.map} +0 -0
- /package/dist/{chunk-7kpqntgw.js.map → chunk-zxhym8tr.js.map} +0 -0
|
@@ -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\n/** The computer a thread runs on, and the folder there its turns work in. */\nexport interface AgentThreadComputer {\n /** The CLI's id for the computer: a thread's turns are claimed by that computer alone. */\n readonly id: string\n /** What its owner calls the computer, such as \"Anthony's MacBook Pro\". */\n readonly name: string\n /** The absolute path its turns work in, on that computer. */\n readonly folder: string\n}\n\n/** Where a thread runs: which of its owner's computers, and the folder there. */\nexport type AgentThreadPlace = Pick<AgentThreadComputer, \"id\" | \"folder\">\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 /**\n * Where its turns run: on its owner's computer, which claims them, or, when absent, in the cloud.\n * A computer's thread takes turns from its owner alone.\n */\n readonly runsOn?: \"computer\"\n /**\n * Where on its owner's computers a computer's thread runs: set when it is created, and when its\n * owner moves it. Only that computer, open in that folder, claims its turns. A computer's thread\n * created before folders were kept has none until its owner moves it.\n */\n readonly computer?: AgentThreadComputer\n /**\n * When its turns last moved to where they run now, from a computer to the cloud or between\n * folders: the files earlier turns worked on are not here.\n */\n readonly movedAt?: Date\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 runsOn?: \"computer\"\n /** Where a computer's thread runs: required with `runsOn: \"computer\"`, refused without it. */\n readonly computer?: AgentThreadComputer\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 /** Only the threads that run on this computer, in this folder, with a turn active. */\n readonly activeOnComputer?: AgentThreadPlace\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 AssignAgentThreadComputerInput {\n readonly projectId: string\n readonly id: string\n /** Where the thread's turns run from now on. */\n readonly computer: AgentThreadComputer\n /** Its `movedAt` when this changes the computer or folder of a thread that had one. */\n readonly movedAt?: Date\n}\n\nexport interface MoveAgentThreadToCloudInput {\n readonly projectId: string\n readonly id: string\n readonly movedAt?: Date\n}\n\n/** A computer's thread, now in the cloud, and its queued turn, now the cloud's to run. */\nexport interface MoveAgentThreadToCloudResult {\n readonly thread: AgentThreadRecord\n readonly queued?: ConversationAgentRunRecord\n}\n\n/**\n * An open `sixb` on its owner's computer: while it is live, the threads that run on that computer\n * in its folder are reachable there. It ends when `sixb` closes, or lapses when it stops renewing.\n */\nexport interface AgentComputerSessionRecord {\n readonly projectId: string\n /** Chosen by the computer, once per open `sixb`; unique among its owner's sessions. */\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly computer: AgentThreadComputer\n readonly expiresAt: Date\n /** Its threads' background commands, as its latest renewal reported them. */\n readonly backgroundCommands?: readonly AgentComputerBackgroundCommand[]\n /** The commands someone asked to stop: each renewal hands back those still running. */\n readonly stopRequests?: readonly AgentBackgroundCommandRef[]\n}\n\n/** How many background commands a computer session reports, and keeps stop requests for. */\nexport const AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX = 64\n\n/**\n * A background command an open `sixb` runs for one of its threads, which outlives the turn that\n * started it: the web shows how it stands between turns.\n */\nexport interface AgentComputerBackgroundCommand {\n readonly threadId: string\n /** `bg_<hex>`, as the agent's tools name it. */\n readonly id: string\n readonly command: string\n readonly status: \"running\" | \"exited\" | \"stopped\"\n readonly exitCode?: number\n /** ISO timestamps. */\n readonly startedAt: string\n readonly endedAt?: string\n}\n\n/** A background command by its start: its id comes again once `sixb` restarts. */\nexport interface AgentBackgroundCommandRef {\n readonly threadId: string\n readonly id: string\n readonly startedAt: string\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.context_limit_exceeded\",\n \"agent.execution_failed\",\n \"agent.step_limit_reached\",\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 /**\n * When someone asked a running run to stop. Its run token stops working at once, and its runner\n * learns of it at its next lease renewal if the broker's cancel never reached it.\n */\n readonly cancelRequestedAt?: Date\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 /** Its thread's `runsOn` when it was asked for: a computer's turn never reaches the agent queue. */\n readonly runsOn?: \"computer\"\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 /** At most this many steps per run, as its parent asked: the project's limit still applies. */\n readonly maxSteps?: number\n /** Project tools available when the child was admitted. Runtime tools are injected separately. */\n readonly toolNames: readonly string[]\n /** The parent turn's mode, copied when the child was admitted. Absent: `auto`. */\n readonly approvalMode?: AgentApprovalMode\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`. */\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 * What its parent sent a paused child that it had not read: the run that continues it reads it\n * first.\n */\n readonly unread?: readonly { readonly id: string; readonly text: 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 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 * Start it only as a computer's turn, there and in that folder: one whose thread moved meanwhile\n * is refused with `invalid_state`, so it never starts where its thread no longer runs.\n */\n readonly onComputer?: AgentThreadPlace\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 * Take the run over only if the lease last recorded on it ran out by then, checked in the same\n * write: a renewal that lands first keeps it its runner's. Otherwise `invalid_state`.\n */\n readonly ifLapsedBy?: Date\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 interface RequestAgentRunCancelInput {\n readonly id: string\n readonly projectId: string\n readonly at?: 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 /** Leave out the turns that wait for a computer: only a worker's to run. */\n readonly excludeComputerTurns?: boolean\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 * The run that deletes them, when one does: refused with `execution_lost` unless it still runs\n * under this token, checked in the same transaction as the delete.\n */\n readonly fence?: { readonly runId: string; readonly executionToken: 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 /**\n * Move a computer's thread to another computer or folder, and return the thread after. A cloud\n * thread runs on none, and is refused.\n */\n assignComputer(input: AssignAgentThreadComputerInput): Promise<AgentThreadRecord>\n /**\n * Move a computer's thread to the cloud, in one transaction with its queued turn, which the cloud\n * runs instead. Refused with `active_run_exists` while a turn runs on the computer, and\n * `invalid_input` for a thread already in the cloud.\n */\n moveToCloud(input: MoveAgentThreadToCloudInput): Promise<MoveAgentThreadToCloudResult>\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 * Record that a running run was asked to stop, keeping the first time it was. A run in any other\n * state is returned as it is: a queued one is cancelled with `finishQueued`.\n */\n requestCancel(input: RequestAgentRunCancelInput): 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\n/** Each open `sixb` on its owner's computers, as a lease it renews. */\nexport interface AgentComputerSessionStore {\n /**\n * Open the session, or renew it until `expiresAt`; its computer, folder and background commands\n * are kept as given, and its stop requests as they are.\n */\n hold(input: Omit<AgentComputerSessionRecord, \"stopRequests\">): Promise<void>\n /**\n * Record that someone asked to stop one of its commands, once, keeping the newest\n * {@link AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX}. Null when the owner holds no such session.\n */\n requestStop(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n readonly command: AgentBackgroundCommandRef\n }): Promise<AgentComputerSessionRecord | null>\n /** End the owner's session; null when it is not open. */\n release(input: {\n readonly projectId: string\n readonly id: string\n readonly ownerPrincipal: Principal\n }): Promise<AgentComputerSessionRecord | null>\n /** The owner's sessions live at `now`. */\n listLive(input: {\n readonly projectId: string\n readonly ownerPrincipal: Principal\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n /** Remove every session that lapsed before `now`, and return them. */\n removeLapsed(input: {\n readonly projectId: string\n readonly now: Date\n }): Promise<readonly AgentComputerSessionRecord[]>\n}\n\n// ── agent_token_rates — what each model's tokenizer measured on the project's agent runs ──────\n\n/** How many measurements a project keeps per model: its newest. */\nexport const AGENT_TOKEN_RATE_SAMPLES = 20\n\n/**\n * The band of bytes per token a measurement may show. Every tokenizer measured on agent turns\n * reads 2.1 to 4.7; a value outside is a broken measurement, and a single one would set its\n * model's rate for the whole project.\n */\nexport const AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN = 1\nexport const AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN = 8\n\n/**\n * One run's measurement of its model's tokenizer: the UTF-8 bytes of a request's text, as the\n * Agent's context estimator weighs them, against the text tokens the provider counted for it.\n */\nexport interface AgentTokenRateRecord {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n /** The agent run or workflow step that measured it: one measurement each. */\n readonly runId: string\n readonly bytes: number\n readonly tokens: number\n readonly measuredAt: Date\n}\n\n/**\n * The newest measurements of each model's bytes per token, per project. Agent runs start their\n * context estimate from them; losing them only makes the next estimates more conservative.\n */\nexport interface AgentTokenRateStore {\n /**\n * Keep a run's measurement, in place of one it recorded before, and drop the model's\n * measurements past its newest {@link AGENT_TOKEN_RATE_SAMPLES}.\n */\n record(input: AgentTokenRateRecord): Promise<void>\n /** The model's measurements, newest first: at most {@link AGENT_TOKEN_RATE_SAMPLES}. */\n listLatest(input: {\n readonly projectId: string\n readonly providerId: string\n readonly modelId: string\n }): Promise<readonly AgentTokenRateRecord[]>\n}\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 readonly computers: AgentComputerSessionStore\n readonly tokenRates: AgentTokenRateStore\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AA2QO,IAAM,0CAAyC;AA6C/C,IAAM,2BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;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;AA8gBhF,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;AAyClC,IAAM,4BAA2B;AAOjC,IAAM,wCAAuC;AAC7C,IAAM,uCAAuC;",
|
|
8
|
-
"debugId": "FF93B7FDB906D87364756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/execution/scopes.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport type { ObjectReadExecutionLimits, SelectedObjectReadScope } from \"../storage\"\nimport {\n createDelegatedRuntimeAuthorization,\n createDisabledRuntimeAuthorization,\n createKernelRuntimeAuthorization,\n createPrincipalRuntimeAuthorization,\n type DelegatedActionApplyTarget,\n} from \"./authorization\"\nimport type {\n AuthorizablePrincipal,\n AuthorizationRef,\n ExecutionContext,\n ExecutionScope,\n ExecutionSource,\n KernelOperation,\n} from \"./types\"\n\nexport function createPrincipalRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n}): ExecutionScope {\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId: input.requestId,\n correlationId: input.correlationId,\n requestedBy: asAuthorizablePrincipal(input.context.principal),\n })\n\n return Object.freeze({\n execution,\n authorization: createPrincipalRuntimeAuthorization({\n execution,\n context: input.context,\n ...(input.credential === undefined ? {} : { credential: input.credential }),\n }),\n })\n}\n\nexport function createDisabledRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n return Object.freeze({\n execution,\n authorization: createDisabledRuntimeAuthorization(execution),\n })\n}\n\n/** Internal request scope carrying only a finite object-read selection. */\nexport function createDelegatedRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly objectRead: {\n readonly selection: SelectedObjectReadScope\n readonly limits: ObjectReadExecutionLimits\n }\n readonly actionApply?: readonly DelegatedActionApplyTarget[]\n readonly delegation?: Extract<AuthorizationRef, { readonly type: \"delegated\" }>[\"delegation\"]\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n const actionApply = input.actionApply\n const delegation = input.delegation\n return Object.freeze({\n execution,\n authorization: createDelegatedRuntimeAuthorization({\n execution,\n objectRead: input.objectRead,\n ...(actionApply === undefined ? {} : { actionApply }),\n ...(delegation === undefined ? {} : { delegation }),\n }),\n })\n}\n\nexport function createKernelScope(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionScope {\n const operation = Object.freeze({ ...input.operation })\n const execution = createKernelExecution({\n projectId: input.projectId,\n operation,\n source: input.source,\n correlationId: input.correlationId,\n })\n return Object.freeze({\n execution,\n authorization: createKernelRuntimeAuthorization({ execution, operation }),\n })\n}\n\nfunction createKernelExecution(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionContext {\n const source = snapshotExecutionSource(input.source)\n assertNestedProvenance(source, input.correlationId)\n return freezeExecution({\n id: `exec_${randomUUID()}`,\n projectId: input.projectId,\n executor: Object.freeze({ type: \"kernel\", operation: input.operation }),\n source,\n correlationId: input.correlationId ?? `corr_${randomUUID()}`,\n })\n}\n\nfunction assertNestedProvenance(source: ExecutionSource, correlationId: string | undefined): void {\n if (source.type === \"execution\" && correlationId === undefined) {\n throw new Error(\"[Sixb] Nested execution must preserve its parent correlation id.\")\n }\n}\n\nexport function createTestingScope(input: {\n readonly projectId: string\n readonly context?: AuthorizationContext\n readonly executionId?: string\n readonly requestId?: string\n readonly correlationId?: string\n}): ExecutionScope {\n const context = input.context ? withoutSession(input.context) : undefined\n const requestId = input.requestId ?? `test_request_${randomUUID()}`\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId,\n correlationId: input.correlationId ?? `test_correlation_${randomUUID()}`,\n ...(context === undefined ? {} : { requestedBy: asAuthorizablePrincipal(context.principal) }),\n executionId: input.executionId,\n })\n return Object.freeze({\n execution,\n authorization: context\n ? createPrincipalRuntimeAuthorization({ execution, context })\n : createDisabledRuntimeAuthorization(execution),\n })\n}\n\nfunction withoutSession(context: AuthorizationContext): AuthorizationContext {\n const { sessionId: _sessionId, ...withoutSessionId } = context\n return withoutSessionId\n}\n\nfunction createRequestExecution(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly executionId?: string\n}): ExecutionContext {\n assertNonEmpty(input.projectId, \"Execution project id\")\n assertNonEmpty(input.requestId, \"Execution request id\")\n assertNonEmpty(input.correlationId, \"Execution correlation id\")\n const id = input.executionId ?? `exec_${randomUUID()}`\n assertNonEmpty(id, \"Execution id\")\n return freezeExecution({\n id,\n projectId: input.projectId,\n ...(input.requestedBy === undefined ? {} : { requestedBy: input.requestedBy }),\n executor: Object.freeze({ type: \"request\", requestId: input.requestId }),\n source: Object.freeze({ type: \"http\", requestId: input.requestId }),\n correlationId: input.correlationId,\n })\n}\n\nfunction freezeExecution(execution: ExecutionContext): ExecutionContext {\n assertNonEmpty(execution.id, \"Execution id\")\n assertNonEmpty(execution.projectId, \"Execution project id\")\n assertNonEmpty(execution.correlationId, \"Execution correlation id\")\n return Object.freeze(execution)\n}\n\nfunction snapshotExecutionSource(source: ExecutionSource): ExecutionSource {\n const field = sourceIdentifier(source)\n assertNonEmpty(field.value, field.label)\n if (source.type === \"datasetVersion\") {\n assertNonEmpty(source.datasetId, \"Execution source dataset id\")\n }\n return Object.freeze({ ...source })\n}\n\nfunction sourceIdentifier(source: ExecutionSource): {\n readonly label: string\n readonly value: string\n} {\n switch (source.type) {\n case \"ontologyCommit\":\n return { label: \"Execution source commit id\", value: source.commitId }\n case \"http\":\n return { label: \"Execution source request id\", value: source.requestId }\n case \"webhook\":\n return { label: \"Execution source delivery id\", value: source.deliveryId }\n case \"schedule\":\n case \"event\":\n return { label: \"Execution source event id\", value: source.eventId }\n case \"datasetVersion\":\n return { label: \"Execution source dataset version id\", value: source.versionId }\n case \"execution\":\n return { label: \"Execution source execution id\", value: source.executionId }\n }\n}\n\nfunction asAuthorizablePrincipal(\n principal: AuthorizationContext[\"principal\"]\n): AuthorizablePrincipal {\n if (principal.type !== \"user\" && principal.type !== \"serviceAccount\") {\n throw new Error(`[Sixb] Principal type '${principal.type}' cannot hold runtime authorization.`)\n }\n assertNonEmpty(principal.id, \"Execution principal id\")\n return Object.freeze({ type: principal.type, id: principal.id })\n}\n\nfunction assertNonEmpty(value: string, label: string): void {\n if (!value.trim()) {\n throw new Error(`[Sixb] ${label} must not be empty.`)\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;AAAA;AAmBO,SAAS,2BAA2B,CAAC,OAMzB;AAAA,EACjB,MAAM,YAAY,uBAAuB;AAAA,IACvC,WAAW,MAAM;AAAA,IACjB,WAAW,MAAM;AAAA,IACjB,eAAe,MAAM;AAAA,IACrB,aAAa,wBAAwB,MAAM,QAAQ,SAAS;AAAA,EAC9D,CAAC;AAAA,EAED,OAAO,OAAO,OAAO;AAA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I,MAAM,UAAU,0BAA0B;AAAA,EACtD;AAAA;",
|
|
8
|
-
"debugId": "1E19649F1CE57F6964756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/agents/errors.ts", "../src/storage/agents/provider.ts", "../src/agents/ids.ts", "../src/agents/types.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export type AgentStorageErrorCode =\n | \"thread_not_found\"\n /** A conversation's operation on a sub-agent's thread: a turn, a fork, a participant. */\n | \"thread_not_conversation\"\n | \"active_run_exists\"\n | \"active_child_limit\"\n | \"run_not_found\"\n | \"invalid_input\"\n | \"invalid_state\"\n | \"execution_lost\"\n | \"duplicate_id\"\n | \"participant_limit\"\n\n/**\n * Error for agent-storage invariants and invalid state transitions (single-flight, execution\n * ownership, run lifecycle, message append). Callers branch on `code` rather than message text.\n */\nexport class AgentStorageError extends Error {\n readonly name = \"AgentStorageError\"\n\n constructor(\n readonly code: AgentStorageErrorCode,\n message: string\n ) {\n super(message)\n }\n}\n",
|
|
6
|
-
"import { isDeepStrictEqual } from \"node:util\"\nimport { createAgentMessageId, createCopiedAgentContextCheckpointId } from \"../../agents/ids\"\nimport { AGENT_REASONING_LEVELS } from \"../../agents/types\"\nimport type { Principal, UserPrincipal } from \"../../auth\"\nimport { isFileRef } from \"../../blob-storage/validation\"\nimport { isJsonObject, isPlainRecord } from \"../../json\"\nimport { isLanguageModelTier, LANGUAGE_MODEL_TIERS } from \"../../models/catalog\"\nimport { isModelReasoning } from \"../../models/language-model\"\nimport type { ExecutionRecord, ExecutionStorage } from \"../executions\"\nimport { findAgentRunExecution } from \"../executions/run-link\"\nimport { AgentStorageError } from \"./errors\"\nimport { AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX } from \"./types\"\n\nexport { AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX }\n\nimport type {\n AddAgentThreadParticipantsInput,\n AgentApprovalCall,\n AgentApprovalMode,\n AgentApprovalRecord,\n AgentApprovalStatus,\n AgentBackgroundCommandRef,\n AgentComputerSessionRecord,\n AgentContextCheckpointRecord,\n AgentMemoryChange,\n AgentMessageRecord,\n AgentRunRecord,\n AgentThreadComputer,\n AgentThreadParticipantRecord,\n AgentThreadPlace,\n AgentThreadRecord,\n AgentThreadSandboxParams,\n AgentThreadSandboxState,\n AgentTokenRateRecord,\n ConversationAgentRunRecord,\n ConversationAgentRunSpec,\n CreateAgentContextCheckpointInput,\n CreateSubagentRunInput,\n FinishAgentRunInput,\n ForkAgentThreadInput,\n ListAgentApprovalsInput,\n RequestAgentApprovalInput,\n SaveAgentMemoryInput,\n StopAgentApprovalsInput,\n SubagentRunFile,\n SubagentRunRecord,\n SubagentRunResult,\n TransitionAgentThreadSandboxInput,\n} from \"./types\"\nimport {\n AGENT_APPROVAL_MODES,\n AGENT_HOLDING_APPROVAL_MODES,\n AGENT_MEMORY_HISTORY_DAYS,\n AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN,\n AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN,\n} from \"./types\"\n\nconst SANDBOX_NAME_PATTERN = /^[a-zA-Z0-9-]{1,80}$/\n\n/**\n * Shared state machine. Providers must lock the run, then thread, around this decision/write.\n *\n * A conversation has a workspace once its sandbox is configured. A sub-agent's thread may keep a\n * blank one while the sub-agent pauses, fenced by the thread's active run as a turn's is. Its\n * next run starts a fresh one where a conversation's would need an explicit recreation.\n */\nexport function transitionAgentThreadSandbox(\n thread: AgentThreadRecord | null,\n run: AgentRunRecord | null,\n input: TransitionAgentThreadSandboxInput\n): AgentThreadSandboxState {\n const fail = (message: string): never => {\n throw new AgentStorageError(\"invalid_state\", `[Sixb] Sandbox ${message}`)\n }\n if (!thread || (!thread.sandboxParams && thread.kind !== \"subagent\")) {\n return fail(\"is not configured on this thread.\")\n }\n if (!SANDBOX_NAME_PATTERN.test(input.name)) return fail(\"name is invalid.\")\n const state = thread.sandboxState\n if (input.action === \"recreate\") {\n if (thread.activeRunId !== null) return fail(\"cannot be recreated during an active run.\")\n if (!state || state.name !== input.expectedSandboxName || input.name === state.name)\n return fail(\"changed; reload before recreating.\")\n if (![\"busy\", \"blocked\", \"unavailable\"].includes(state.status)) {\n return fail(\"does not require recovery.\")\n }\n return {\n name: input.name,\n status: \"new\",\n initialized: false,\n resetAt: new Date().toISOString(),\n }\n }\n if (\n !run ||\n run.threadId !== thread.id ||\n run.status !== \"running\" ||\n thread.activeRunId !== run.id ||\n run.id !== input.runId ||\n run.execution?.token !== input.executionToken ||\n run.execution.queueLeaseExpiresAt.getTime() <= Date.now()\n ) {\n throw new AgentStorageError(\"execution_lost\", \"[Sixb] Sandbox execution ownership was lost.\")\n }\n if (input.action === \"acquire\") {\n if (state && state.status !== \"new\" && state.status !== \"ready\") {\n if (thread.kind === \"subagent\" && state.name !== input.name) {\n return startSubagentWorkspaceAgain(input)\n }\n return fail(\"requires recovery; previous operations may still be in flight.\")\n }\n if (state && state.name !== input.name) return fail(\"name changed.\")\n if (!/^[a-f0-9]{64}$/.test(input.sourceFingerprint))\n return fail(\"source fingerprint is invalid.\")\n if (state?.sourceFingerprint && state.sourceFingerprint !== input.sourceFingerprint) {\n return fail(\"source identity changed; the existing checkout was not opened.\")\n }\n return {\n name: input.name,\n status: \"busy\",\n initialized: state?.initialized ?? false,\n ...(state?.resetAt ? { resetAt: state.resetAt } : {}),\n sourceFingerprint: input.sourceFingerprint,\n owner: { runId: input.runId, executionToken: input.executionToken },\n }\n }\n if (\n state?.status !== \"busy\" ||\n state.name !== input.name ||\n state.owner?.runId !== input.runId ||\n state.owner.executionToken !== input.executionToken\n ) {\n return fail(\"is not owned by this execution.\")\n }\n if (input.action === \"replace\") {\n if (\n !state.initialized ||\n input.nextName === state.name ||\n !SANDBOX_NAME_PATTERN.test(input.nextName)\n ) {\n return fail(\"replacement requires initialized state and a fresh valid name.\")\n }\n // Only the owning worker may report confirmed loss; retain its fence across replacement.\n return {\n ...state,\n name: input.nextName,\n initialized: false,\n resetAt: new Date().toISOString(),\n }\n }\n if (input.status === \"ready\" && !input.initialized) return fail(\"initialization is incomplete.\")\n return {\n name: state.name,\n status: input.status,\n initialized: input.initialized,\n sourceFingerprint: state.sourceFingerprint,\n ...(state.resetAt ? { resetAt: state.resetAt } : {}),\n }\n}\n\n/**\n * A sub-agent's thread whose workspace an ended run left destroyed, unsaved or in doubt: the run\n * that continues it starts from a fresh one, under a new name, and is told its files were reset.\n * Nobody can recreate a sub-agent's workspace, and the thread's single active run is this one, so\n * whatever the old name still holds is never opened again.\n */\nfunction startSubagentWorkspaceAgain(\n input: Extract<TransitionAgentThreadSandboxInput, { readonly action: \"acquire\" }>\n): AgentThreadSandboxState {\n if (!/^[a-f0-9]{64}$/.test(input.sourceFingerprint)) {\n throw new AgentStorageError(\"invalid_state\", \"[Sixb] Sandbox source fingerprint is invalid.\")\n }\n return {\n name: input.name,\n status: \"busy\",\n initialized: false,\n resetAt: new Date().toISOString(),\n sourceFingerprint: input.sourceFingerprint,\n owner: { runId: input.runId, executionToken: input.executionToken },\n }\n}\n\n/** Snapshot application parameters independently of worker-owned sandbox state. */\nexport function snapshotAgentThreadSandboxParams(value: unknown): AgentThreadSandboxParams {\n if (!isPlainRecord(value) || !isJsonObject(value)) {\n throw new AgentStorageError(\n \"invalid_input\",\n \"[Sixb] Thread sandbox must contain only JSON params.\"\n )\n }\n return structuredClone(value)\n}\n\n/**\n * The users an add actually adds: those not already taking part. Providers call it under the\n * thread's lock with the participants they read there, so the cap holds across concurrent adds.\n * Who may be added is the caller's decision; this enforces only the cap.\n */\nexport function participantsToAdd(\n input: AddAgentThreadParticipantsInput,\n existing: readonly AgentThreadParticipantRecord[],\n prefix = \"Sixb\"\n): readonly UserPrincipal[] {\n const taken = new Set(existing.map((participant) => participant.principal.id))\n const added = input.principals.filter((principal) => !taken.has(principal.id))\n\n if (existing.length + added.length > input.maxParticipants) {\n throw new AgentStorageError(\n \"participant_limit\",\n `[${prefix}] Agent thread '${input.threadId}' can have at most ${input.maxParticipants} participants.`\n )\n }\n\n return added\n}\n\n/**\n * Participants oldest first, then by user id and thread id compared as UTF-8 bytes: the order\n * PostgreSQL's \"C\" collation and SQLite's binary one give, so every provider lists them alike.\n */\nexport function compareAgentThreadParticipants(\n left: AgentThreadParticipantRecord,\n right: AgentThreadParticipantRecord\n): number {\n return (\n left.addedAt.getTime() - right.addedAt.getTime() ||\n Buffer.compare(Buffer.from(left.principal.id), Buffer.from(right.principal.id)) ||\n Buffer.compare(Buffer.from(left.threadId), Buffer.from(right.threadId))\n )\n}\n\nconst ARTIFACT_ID_TOKEN = /art_[0-9a-z]{10}/g\n\n/**\n * Text with each artifact id the copies map replaced by its copy's: a copied message's parts, as\n * JSON, or a summary. Ids are fixed-length tokens, so one never matches inside another.\n */\nexport function remapArtifactIds(\n text: string,\n copies: Readonly<Record<string, string>> | undefined\n): string {\n if (!copies || Object.keys(copies).length === 0) return text\n return text.replace(ARTIFACT_ID_TOKEN, (id) => copies[id] ?? id)\n}\n\n/** What a fork reads from its source thread, inside the provider's transaction. */\nexport interface AgentThreadForkSource {\n /** Where the source runs: a fork starts in the cloud, without the files its turns worked on. */\n readonly workspace: {\n readonly runsOn?: string | null\n readonly movedAt?: Date | string | null\n }\n /** The active run's trigger message, when a turn is running. */\n readonly triggerMessageId?: string\n /**\n * Every message of the source, ordered by ascending `seq`. `counted: false` marks one the thread\n * does not count ({@link countsAsThreadMessage}); a provider reads it from the parts it copies.\n */\n readonly messages: readonly (Pick<AgentMessageRecord, \"id\" | \"seq\"> & {\n readonly counted?: boolean\n })[]\n /** Every checkpoint of the source, latest first, in `getLatest` order. */\n readonly checkpoints: readonly AgentContextCheckpointRecord[]\n}\n\n/** The rows a provider writes for a fork. */\nexport interface AgentThreadForkPlan {\n readonly thread: AgentThreadRecord\n /** The source messages to copy, in `seq` order, with the id of each copy. */\n readonly messages: readonly { readonly sourceId: string; readonly id: string }[]\n readonly checkpoint?: AgentContextCheckpointRecord\n}\n\n/**\n * Decide what a fork copies. While a turn is running, the fork copies what came before its trigger\n * message, so the copy never has a gap; otherwise it copies everything. Copies keep their `seq`,\n * so the latest checkpoint whose observed head was copied projects unchanged.\n *\n * The plan mints the ids of the copies: which messages are copied is only known here, under the\n * provider's lock, so the caller cannot supply them.\n */\n/**\n * Whether a message counts in its thread's `messageCount`, which reads as what the conversation\n * shows. The message Sixb writes to resume a paused turn carries only how its calls ended, which the\n * chat shows on their cards: it is not counted.\n */\nexport function countsAsThreadMessage(message: Pick<AgentMessageRecord, \"parts\">): boolean {\n return !(\n message.parts.length > 0 && message.parts.every((part) => part.type === \"approval-outcome\")\n )\n}\n\nexport function planAgentThreadFork(\n input: ForkAgentThreadInput,\n source: AgentThreadForkSource,\n prefix = \"Sixb\"\n): AgentThreadForkPlan {\n const createdAt = new Date(input.createdAt ?? new Date())\n const sandboxState = forkedSandboxState(input, createdAt, prefix)\n\n const trigger = source.messages.find((message) => message.id === source.triggerMessageId)\n const copied =\n trigger === undefined\n ? source.messages\n : source.messages.filter((message) => message.seq < trigger.seq)\n const lastCopiedSeq = copied.at(-1)?.seq ?? 0\n\n const checkpoint = source.checkpoints.find(\n (candidate) => candidate.observedHeadSeq <= lastCopiedSeq\n )\n\n const { runsOn, movedAt: moved } = source.workspace\n const movedAt = moved ? new Date(moved) : runsOn === \"computer\" ? createdAt : undefined\n const thread: AgentThreadRecord = {\n id: input.id,\n projectId: input.projectId,\n kind: \"conversation\",\n ownerPrincipal: structuredClone(input.ownerPrincipal),\n ...(input.title === undefined ? {} : { title: input.title }),\n ...(movedAt === undefined ? {} : { movedAt }),\n ...(input.sandboxParams === undefined\n ? {}\n : { sandboxParams: snapshotAgentThreadSandboxParams(input.sandboxParams) }),\n ...(sandboxState === undefined ? {} : { sandboxState }),\n status: \"active\",\n activeRunId: null,\n // No `lastMessageAt` until the fork's first new message: threads sort by it, else by their\n // creation, so a fork of an old conversation sorts with what its owner just did.\n messageCount: copied.filter((message) => message.counted !== false).length,\n createdAt,\n updatedAt: createdAt,\n }\n\n return {\n thread,\n messages: copied.map((message) => ({ sourceId: message.id, id: createAgentMessageId() })),\n ...(checkpoint === undefined\n ? {}\n : {\n checkpoint: {\n ...copyCheckpoint(checkpoint, input.id),\n summary: remapArtifactIds(checkpoint.summary, input.artifactCopies),\n },\n }),\n }\n}\n\n/**\n * The copy starts the fork's chain: its predecessors stay in the source. Its `createdByRunId`\n * still names the source run, under a foreign key that restricts deletion: deleting runs or\n * threads later must account for the forks that copied their checkpoints.\n */\nfunction copyCheckpoint(\n checkpoint: AgentContextCheckpointRecord,\n threadId: string\n): AgentContextCheckpointRecord {\n const { previousCheckpointId: _previous, ...copied } = structuredClone(checkpoint)\n return { ...copied, id: createCopiedAgentContextCheckpointId(), threadId }\n}\n\n/** A fresh sandbox, reset at the fork, so the Agent knows earlier local files are not there. */\nfunction forkedSandboxState(\n input: ForkAgentThreadInput,\n createdAt: Date,\n prefix: string\n): AgentThreadSandboxState | undefined {\n if ((input.sandboxParams === undefined) !== (input.sandboxName === undefined)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A forked thread needs a sandbox name exactly when it has sandbox params.`\n )\n }\n\n if (input.sandboxName === undefined) return undefined\n\n if (!SANDBOX_NAME_PATTERN.test(input.sandboxName)) {\n throw new AgentStorageError(\"invalid_input\", `[${prefix}] Sandbox name is invalid.`)\n }\n\n return {\n name: input.sandboxName,\n status: \"new\",\n initialized: false,\n resetAt: createdAt.toISOString(),\n }\n}\n\n/** Validate the provider-neutral model selection captured for a conversational turn. */\nexport function assertConversationAgentRunSpec(\n spec: ConversationAgentRunSpec,\n prefix = \"Sixb\"\n): void {\n if (!isRecord(spec) || !isRecord(spec.model)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run spec must contain a model reference.`\n )\n }\n for (const [name, value] of [\n [\"model.provider\", spec.model.provider],\n [\"model.modelId\", spec.model.modelId],\n ] as const) {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run '${name}' must not be empty.`\n )\n }\n }\n if (spec.reasoning !== undefined && !isModelReasoning(spec.reasoning)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent reasoning must be one of: ${AGENT_REASONING_LEVELS.join(\", \")}, or a nonnegative budgetTokens object.`\n )\n }\n\n if (spec.tier !== undefined && !isLanguageModelTier(spec.tier)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run 'tier' must be one of: ${LANGUAGE_MODEL_TIERS.join(\", \")}.`\n )\n }\n if (spec.tierProbabilities !== undefined && !isTierProbabilities(spec.tierProbabilities)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run 'tierProbabilities' must give each tier a probability.`\n )\n }\n\n for (const [name, value] of [\n [\"timeZone\", spec.timeZone],\n [\"locale\", spec.locale],\n ] as const) {\n if (value !== undefined && (typeof value !== \"string\" || value.trim().length === 0)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run '${name}' must be a non-empty string.`\n )\n }\n }\n assertApprovalModeField(spec.approvalMode, \"Conversational Agent run\", prefix)\n assertRunsOn(spec.runsOn, \"Conversational Agent run\", prefix)\n}\n\n/** Validate where a thread or turn runs: `computer`, or absent for the cloud. */\nexport function assertRunsOn(value: unknown, subject: string, prefix = \"Sixb\"): void {\n if (value !== undefined && value !== \"computer\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] ${subject} 'runsOn' must be \"computer\", or absent for the cloud.`\n )\n }\n}\n\n/**\n * Validate where on a computer a thread runs: the CLI's id for the computer, its name, and the\n * folder there. All are shown back to its owner, so none holds a control character.\n */\nexport function assertAgentThreadComputer(\n value: unknown,\n prefix = \"Sixb\"\n): asserts value is AgentThreadComputer {\n const computer = value as Partial<AgentThreadComputer> | null\n const fields = [\n [\"id\", computer?.id, 200],\n [\"name\", computer?.name, 120],\n [\"folder\", computer?.folder, 4096],\n ] as const\n for (const [field, text, max] of fields) {\n if (\n typeof text !== \"string\" ||\n text.trim() === \"\" ||\n text.length > max ||\n CONTROL_CHARACTER.test(text)\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] An Agent thread's computer '${field}' must be a non-blank string of at most ${max} characters, without control characters.`\n )\n }\n }\n}\n\n/** A thread runs on a computer exactly when it names the computer and folder. */\nexport function assertComputerPlace(runsOn: unknown, computer: unknown, prefix = \"Sixb\"): void {\n assertRunsOn(runsOn, \"Agent thread\", prefix)\n if (runsOn === \"computer\") assertAgentThreadComputer(computer, prefix)\n else if (computer !== undefined) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Only a thread that runs on a computer names one.`\n )\n }\n}\n\n/** Validate a computer session before a store keeps it. */\nexport function assertAgentComputerSession(\n session: Omit<AgentComputerSessionRecord, \"stopRequests\">,\n prefix = \"Sixb\"\n): void {\n if (typeof session.id !== \"string\" || session.id.trim() === \"\" || session.id.length > 200) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A computer session's 'id' must be a non-blank string of at most 200 characters.`\n )\n }\n if (!(session.expiresAt instanceof Date) || Number.isNaN(session.expiresAt.getTime())) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A computer session's 'expiresAt' must be a valid date.`\n )\n }\n assertAgentThreadComputer(session.computer, prefix)\n\n const commands = session.backgroundCommands ?? []\n if (!Array.isArray(commands) || commands.length > AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A computer session reports at most ${AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX} background commands.`\n )\n }\n for (const command of commands) {\n assertAgentBackgroundCommandRef(command, prefix)\n if (\n typeof command.command !== \"string\" ||\n ![\"running\", \"exited\", \"stopped\"].includes(command.status) ||\n (command.exitCode !== undefined && !Number.isInteger(command.exitCode)) ||\n (command.endedAt !== undefined && typeof command.endedAt !== \"string\")\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A background command names its command, its status (running, exited or stopped), and an integer exit code once it ended.`\n )\n }\n }\n}\n\n/** Validate which background command a stop names. */\nexport function assertAgentBackgroundCommandRef(\n ref: AgentBackgroundCommandRef,\n prefix = \"Sixb\"\n): void {\n const fields = [ref?.threadId, ref?.id, ref?.startedAt]\n if (fields.some((field) => typeof field !== \"string\" || field === \"\" || field.length > 200)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] A background command is named by its thread, its id and its start, each a non-empty string of at most 200 characters.`\n )\n }\n}\n\n/** The stop requests a session keeps with `command` added: once, the newest ones. */\nexport function withStopRequest(\n requests: readonly AgentBackgroundCommandRef[],\n command: AgentBackgroundCommandRef\n): AgentBackgroundCommandRef[] {\n const same = (other: AgentBackgroundCommandRef) =>\n other.threadId === command.threadId &&\n other.id === command.id &&\n other.startedAt === command.startedAt\n if (requests.some(same)) return [...requests]\n\n const ref = { threadId: command.threadId, id: command.id, startedAt: command.startedAt }\n return [...requests, ref].slice(-AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX)\n}\n\n/** C0 and C1 controls, DEL, and the marks that reorder text where a terminal or page shows it. */\nexport const CONTROL_CHARACTER =\n /[\\u0000-\\u001f\\u007f-\\u009f\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]/\n\n/**\n * Refuse to assign a computer to a thread that runs in the cloud, or does not exist, or to move one\n * while a turn runs in its folder.\n */\nexport function assertAssignableComputer(\n thread: AgentThreadRecord | null,\n activeRun: AgentRunRecord | null,\n computer: AgentThreadComputer,\n id: string,\n prefix = \"Sixb\"\n): asserts thread is AgentThreadRecord {\n if (!thread) {\n throw new AgentStorageError(\"thread_not_found\", `[${prefix}] Agent thread '${id}' not found.`)\n }\n if (thread.runsOn !== \"computer\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent thread '${id}' runs in the cloud: no computer runs its turns.`\n )\n }\n if (movesComputerPlace(thread, computer)) assertNoTurnRunning(activeRun, id, prefix)\n}\n\n/**\n * Refuse to move a thread to the cloud unless it runs on a computer and no turn runs there now. A\n * queued turn moves with it.\n */\nexport function assertMovableToCloud(\n thread: AgentThreadRecord | null,\n activeRun: AgentRunRecord | null,\n id: string,\n prefix = \"Sixb\"\n): asserts thread is AgentThreadRecord {\n if (!thread) {\n throw new AgentStorageError(\"thread_not_found\", `[${prefix}] Agent thread '${id}' not found.`)\n }\n if (thread.runsOn !== \"computer\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent thread '${id}' runs in the cloud already.`\n )\n }\n assertNoTurnRunning(activeRun, id, prefix)\n}\n\n/** A turn works in its thread's folder until it ends: its thread moves after that. */\nfunction assertNoTurnRunning(activeRun: AgentRunRecord | null, id: string, prefix: string): void {\n if (activeRun?.status === \"running\") {\n throw new AgentStorageError(\n \"active_run_exists\",\n `[${prefix}] A turn of Agent thread '${id}' is running on its computer: stop it, or let it end, first.`\n )\n }\n}\n\n/**\n * A turn runs where its thread runs: one asked for before the thread moved, and created after, is\n * refused rather than left where nothing claims it.\n */\nexport function assertTurnInThreadPlace(\n threadRunsOn: unknown,\n spec: ConversationAgentRunSpec,\n threadId: string,\n prefix = \"Sixb\"\n): void {\n if ((threadRunsOn ?? undefined) !== spec.runsOn) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${threadId}' moved while this turn was asked for: send it again.`\n )\n }\n}\n\n/** Refuse to start a computer's turn that moved to the cloud before it started. */\nexport function assertStartsOnComputer(\n run: AgentRunRecord,\n threadPlace: AgentThreadPlace | undefined,\n place: AgentThreadPlace,\n prefix = \"Sixb\"\n): void {\n if (run.kind !== \"conversation\" || run.spec?.runsOn !== \"computer\") {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${run.id}' runs in the cloud now: no computer starts it.`\n )\n }\n if (!threadPlace || !sameComputerPlace(threadPlace, place)) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${run.id}' moved to another folder or computer: it starts there.`\n )\n }\n}\n\n/** Whether `computer` takes a thread's turns away from the computer or folder it had. */\nexport function movesComputerPlace(\n thread: AgentThreadRecord,\n computer: AgentThreadComputer\n): boolean {\n // One from before folders were kept ran somewhere unknown: its first folder is a move too.\n return !thread.computer || !sameComputerPlace(thread.computer, computer)\n}\n\n/** The queued turn of a thread that moves to the cloud, as the cloud runs it. */\nexport function queuedTurnInCloud(\n active: AgentRunRecord | null\n): ConversationAgentRunRecord | undefined {\n if (active?.kind !== \"conversation\" || active.status !== \"queued\") return undefined\n if (active.spec?.runsOn !== \"computer\") return undefined\n const { runsOn: _runsOn, ...cloud } = active.spec\n return { ...active, spec: cloud }\n}\n\n/** Whether two places are the same folder of the same computer, whatever they call it. */\nexport function sameComputerPlace(a: AgentThreadPlace, b: AgentThreadPlace): boolean {\n return a.id === b.id && a.folder === b.folder\n}\n\nexport function isAgentApprovalMode(value: unknown): value is AgentApprovalMode {\n return (AGENT_APPROVAL_MODES as readonly unknown[]).includes(value)\n}\n\n/** Validate a mode a store is asked to keep, before it writes anything. */\nexport function assertAgentApprovalModeInput(\n mode: unknown,\n prefix = \"Sixb\"\n): asserts mode is AgentApprovalMode {\n if (!isAgentApprovalMode(mode)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent approval mode must be one of: ${AGENT_APPROVAL_MODES.join(\", \")}.`\n )\n }\n}\n\nfunction assertApprovalModeField(value: unknown, owner: string, prefix: string): void {\n if (value !== undefined && !isAgentApprovalMode(value)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] ${owner} 'approvalMode' must be one of: ${AGENT_APPROVAL_MODES.join(\", \")}.`\n )\n }\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nfunction isTierProbabilities(value: unknown): boolean {\n if (!isRecord(value) || Object.keys(value).length !== LANGUAGE_MODEL_TIERS.length) return false\n\n return LANGUAGE_MODEL_TIERS.every((tier) => {\n const probability = value[tier]\n return typeof probability === \"number\" && probability >= 0 && probability <= 1\n })\n}\n\n/** Validate the semantic link between a conversational Agent run and its immutable execution. */\nexport async function assertAgentRunExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n}): Promise<ExecutionRecord> {\n const execution = await findAgentRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n runId: input.runId,\n authority: { type: \"inherited\" },\n })\n if (!execution) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[Sixb] Execution '${input.executionId}' does not authorize Agent run '${input.runId}'.`\n )\n }\n return execution\n}\n\n/** Validate the provider-neutral payload of an idempotent child admission. */\nexport function assertCreateSubagentRunInput(input: CreateSubagentRunInput, prefix = \"Sixb\"): void {\n for (const [name, value] of [\n [\"id\", input.id],\n [\"projectId\", input.projectId],\n [\"executionId\", input.executionId],\n [\"parentRunId\", input.parentRunId],\n [\"parentExecutionToken\", input.parentExecutionToken],\n [\"spawnKey\", input.spawnKey],\n [\"model.provider\", input.spec.model.provider],\n [\"model.modelId\", input.spec.model.modelId],\n [\"task\", input.spec.task],\n [\"thread.id\", input.thread.id],\n [\"trigger.id\", input.trigger.id],\n ] as const) {\n if (value.trim().length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run '${name}' must not be empty.`\n )\n }\n }\n if (input.spawnKey.length > 128) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent spawn key must not exceed 128 characters.`\n )\n }\n if (!Number.isSafeInteger(input.maxActiveChildren) || input.maxActiveChildren < 1) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run 'maxActiveChildren' must be a positive safe integer.`\n )\n }\n if (new Set(input.spec.toolNames).size !== input.spec.toolNames.length) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run tool names must be unique.`\n )\n }\n if (input.spec.reasoning !== undefined && !isModelReasoning(input.spec.reasoning)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent reasoning must be one of: ${AGENT_REASONING_LEVELS.join(\", \")}, or a nonnegative budgetTokens object.`\n )\n }\n if (\n input.spec.maxSteps !== undefined &&\n (!Number.isSafeInteger(input.spec.maxSteps) || input.spec.maxSteps < 1)\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run 'maxSteps' must be a positive safe integer.`\n )\n }\n assertApprovalModeField(input.spec.approvalMode, \"Subagent run\", prefix)\n\n assertSubagentRunFiles(input.spec.files, \"spec.files\", prefix)\n\n if (input.spec.toolNames.some((name) => !name.trim())) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run tool names must not be empty.`\n )\n }\n if (!Array.isArray(input.trigger.parts) || input.trigger.parts.length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run trigger must have at least one part.`\n )\n }\n if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run createdAt must be a valid date.`\n )\n }\n}\n\n/** Exact semantic match required when a durable spawn key is replayed. */\nexport function subagentRunMatchesCreateInput(\n run: AgentRunRecord,\n input: CreateSubagentRunInput\n): run is SubagentRunRecord {\n return (\n run.kind === \"subagent\" &&\n run.id === input.id &&\n run.projectId === input.projectId &&\n run.executionId === input.executionId &&\n run.parentRunId === input.parentRunId &&\n run.spawnKey === input.spawnKey &&\n run.threadId === input.thread.id &&\n isDeepStrictEqual(run.spec, input.spec)\n )\n}\n\n/** Refuse what only a conversation does on a sub-agent's thread. */\nexport function assertConversationThreadRow(\n thread: Pick<AgentThreadRecord, \"id\" | \"kind\">,\n /** What is refused, completing \"only a conversation …\". */\n operation: string,\n prefix = \"Sixb\"\n): void {\n if (thread.kind === \"conversation\") return\n throw new AgentStorageError(\n \"thread_not_conversation\",\n `[${prefix}] Agent thread '${thread.id}' is a sub-agent's: only a conversation ${operation}.`\n )\n}\n\n/**\n * The thread a child's first run creates. Its conversation's owner owns it, and its run is active\n * in it from the start: the trigger is its first and only message.\n */\nexport function newSubagentThreadRecord(\n input: CreateSubagentRunInput,\n conversation: { readonly id: string; readonly ownerPrincipal: Principal },\n createdAt: Date\n): AgentThreadRecord {\n return {\n id: input.thread.id,\n projectId: input.projectId,\n kind: \"subagent\",\n parent: { threadId: conversation.id, spawnedBy: input.parentRunId, key: input.spawnKey },\n ownerPrincipal: structuredClone(conversation.ownerPrincipal),\n status: \"active\",\n activeRunId: input.id,\n lastMessageAt: createdAt,\n messageCount: 1,\n createdAt,\n updatedAt: createdAt,\n }\n}\n\n/**\n * A later run of a child goes into its thread: the same child of the same conversation, and only\n * once the thread's previous run has ended, as in a conversation.\n */\nexport function assertSubagentThreadTakesRun(\n thread: AgentThreadRecord | null,\n input: CreateSubagentRunInput,\n conversationId: string,\n prefix = \"Sixb\"\n): asserts thread is AgentThreadRecord {\n if (!thread) {\n throw new AgentStorageError(\n \"thread_not_found\",\n `[${prefix}] Agent thread '${input.thread.id}' not found for project '${input.projectId}'.`\n )\n }\n if (\n thread.kind !== \"subagent\" ||\n thread.parent?.threadId !== conversationId ||\n thread.parent.key !== input.spawnKey\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent thread '${thread.id}' is not the thread of child '${input.spawnKey}' of this conversation.`\n )\n }\n if (thread.activeRunId !== null) {\n throw new AgentStorageError(\n \"active_run_exists\",\n `[${prefix}] Agent thread '${thread.id}' already has an active run '${thread.activeRunId}'.`\n )\n }\n}\n\n/**\n * Validate what a finish keeps: a child's result once it succeeded. A child that paused, on its\n * held calls or on a question, may not have answered yet, so its text may be empty. A conversation\n * turn keeps none, and has no parent to wait for.\n */\nexport function assertAgentRunFinishPayload(\n kind: AgentRunRecord[\"kind\"],\n input: FinishAgentRunInput,\n runId: string,\n prefix = \"Sixb\"\n): void {\n if (kind === \"conversation\") {\n if (input.status === \"succeeded\" && input.result !== undefined) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run '${runId}' cannot persist a subagent result.`\n )\n }\n if (input.finishReason === \"awaiting_answer\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Conversational Agent run '${runId}' has no parent to wait for: only a subagent finishes awaiting_answer.`\n )\n }\n return\n }\n\n if (input.status === \"succeeded\") {\n const paused =\n input.finishReason === \"awaiting_approval\" || input.finishReason === \"awaiting_answer\"\n assertSubagentRunResult(input.result, runId, prefix, paused)\n }\n}\n\n/**\n * Validate the small durable result returned by a successful child. A child that paused on its held\n * calls may not have answered yet, so its text may be empty.\n */\nexport function assertSubagentRunResult(\n result: SubagentRunResult | undefined,\n runId: string,\n prefix = \"Sixb\",\n paused = false\n): asserts result is SubagentRunResult {\n if (typeof result?.text !== \"string\" || (!paused && result.text.trim().length === 0)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Succeeded subagent run '${runId}' requires text.`\n )\n }\n assertSubagentRunFiles(result.files, \"result.files\", prefix)\n if (\n result.filesError !== undefined &&\n (typeof result.filesError !== \"string\" || !result.filesError.trim() || result.files?.length)\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run '${runId}' result.filesError must say why it returned no files.`\n )\n }\n if (\n result.unread !== undefined &&\n (!paused ||\n !Array.isArray(result.unread) ||\n !result.unread.every((mail) => typeof mail?.id === \"string\" && typeof mail.text === \"string\"))\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Only a paused subagent run keeps unread mail, each with its id and text: '${runId}'.`\n )\n }\n}\n\n/** Each file a parent and its child exchange: a safe relative path, once, and a valid FileRef. */\nfunction assertSubagentRunFiles(\n files: readonly SubagentRunFile[] | undefined,\n field: string,\n prefix: string\n): void {\n if (files === undefined) return\n\n if (!Array.isArray(files)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run ${field} must be a list.`\n )\n }\n\n const paths = new Set<string>()\n for (const file of files) {\n const segments: readonly string[] = typeof file?.path === \"string\" ? file.path.split(\"/\") : []\n const safe =\n segments.length > 0 &&\n !file.path.includes(\"\\0\") &&\n segments.every((segment) => segment !== \"\" && segment !== \".\" && segment !== \"..\")\n if (!safe || paths.has(file.path) || !isFileRef(file.fileRef)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Subagent run ${field} must hold unique relative paths, each with a valid FileRef.`\n )\n }\n paths.add(file.path)\n }\n}\n\n/** Validate provider-independent checkpoint fields before entering a storage critical section. */\nexport function assertCreateAgentContextCheckpointInput(\n input: CreateAgentContextCheckpointInput,\n prefix = \"Sixb\"\n): void {\n for (const [name, value] of [\n [\"id\", input.id],\n [\"projectId\", input.projectId],\n [\"threadId\", input.threadId],\n [\"createdByRunId\", input.createdByRunId],\n [\"executionToken\", input.executionToken],\n [\"summary\", input.summary],\n [\"summaryModelId\", input.summaryModelId],\n ] as const) {\n if (value.trim().length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint '${name}' must not be empty.`\n )\n }\n }\n\n if (input.summaryFormatVersion !== 1) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint summary format version must be 1.`\n )\n }\n if (input.reason !== \"threshold\" && input.reason !== \"overflow\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint reason must be 'threshold' or 'overflow'.`\n )\n }\n if (\n input.expectedPreviousCheckpointId !== null &&\n input.expectedPreviousCheckpointId.trim().length === 0\n ) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint expected previous id must not be empty.`\n )\n }\n if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint createdAt must be a valid date.`\n )\n }\n\n for (const [name, value, minimum] of [\n [\"expectedHeadSeq\", input.expectedHeadSeq, 1],\n [\"summarizedThroughSeq\", input.summarizedThroughSeq, 1],\n [\"observedHeadSeq\", input.observedHeadSeq, 1],\n [\"estimatedInputTokensBefore\", input.estimatedInputTokensBefore, 0],\n [\"estimatedInputTokensAfter\", input.estimatedInputTokensAfter, 0],\n ] as const) {\n if (!Number.isSafeInteger(value) || value < minimum) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint '${name}' must be a safe integer greater than or equal to ${minimum}.`\n )\n }\n }\n\n if (input.observedHeadSeq !== input.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint observed head must equal its expected message head.`\n )\n }\n if (input.summarizedThroughSeq >= input.observedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint must retain the triggering head message.`\n )\n }\n}\n\n/** Assert that the current delivery still owns the active conversational run. */\nexport function assertAgentContextCheckpointAuthority(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly run: AgentRunRecord | null\n readonly thread: AgentThreadRecord | null\n readonly prefix?: string\n}): asserts input is typeof input & {\n readonly run: AgentRunRecord\n readonly thread: AgentThreadRecord\n} {\n const { create, run, thread } = input\n const prefix = input.prefix ?? \"Sixb\"\n if (!run) {\n throw new AgentStorageError(\n \"run_not_found\",\n `[${prefix}] Agent run '${create.createdByRunId}' not found for project '${create.projectId}'.`\n )\n }\n if (!thread) {\n throw new AgentStorageError(\n \"thread_not_found\",\n `[${prefix}] Agent thread '${create.threadId}' not found for project '${create.projectId}'.`\n )\n }\n // A conversation's turn checkpoints its conversation, a child its own thread.\n if (run.threadId !== create.threadId) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent run '${run.id}' does not belong to thread '${create.threadId}'.`\n )\n }\n // A run that ended no longer holds its execution, as a reclaimed one does not.\n if (run.status !== \"running\") {\n throw new AgentStorageError(\n \"execution_lost\",\n `[${prefix}] Agent run '${run.id}' is not running (status '${run.status}').`\n )\n }\n if (!run.execution || run.execution.token !== create.executionToken) {\n throw new AgentStorageError(\n \"execution_lost\",\n `[${prefix}] Execution token is no longer current on agent run '${run.id}'.`\n )\n }\n if (thread.activeRunId !== run.id) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${run.id}' no longer owns thread '${thread.id}'.`\n )\n }\n}\n\n/** Assert both compare-and-swap anchors and the retained-turn boundary. */\nexport function assertAgentContextCheckpointAnchors(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly latest: AgentContextCheckpointRecord | null\n readonly headSeq: number\n readonly firstRetained: AgentMessageRecord | null\n readonly prefix?: string\n}): void {\n const { create, latest, headSeq, firstRetained } = input\n const prefix = input.prefix ?? \"Sixb\"\n if (headSeq !== create.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${create.threadId}' message head changed from ${create.expectedHeadSeq} to ${headSeq}.`\n )\n }\n\n const latestId = latest?.id ?? null\n if (latestId !== create.expectedPreviousCheckpointId) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${create.threadId}' checkpoint head changed.`\n )\n }\n if (latest && create.summarizedThroughSeq <= latest.summarizedThroughSeq) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint boundary must advance beyond sequence ${latest.summarizedThroughSeq}.`\n )\n }\n if (!firstRetained || firstRetained.seq !== create.summarizedThroughSeq + 1) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent context checkpoint boundary does not align with stored thread messages.`\n )\n }\n if (firstRetained.role !== \"user\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent context checkpoint must retain a complete turn beginning with a user message.`\n )\n }\n}\n\n/** Validate the mutable anchors again before returning an idempotently created checkpoint. */\nexport function assertAgentContextCheckpointReplayState(input: {\n readonly create: CreateAgentContextCheckpointInput\n readonly existing: AgentContextCheckpointRecord\n readonly latest: AgentContextCheckpointRecord | null\n readonly headSeq: number\n readonly prefix?: string\n}): void {\n const prefix = input.prefix ?? \"Sixb\"\n if (input.headSeq !== input.create.expectedHeadSeq) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${input.create.threadId}' message head changed from ${input.create.expectedHeadSeq} to ${input.headSeq}.`\n )\n }\n if (input.latest?.id !== input.existing.id) {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent thread '${input.create.threadId}' checkpoint head changed after '${input.existing.id}'.`\n )\n }\n}\n\n/** Compare the durable semantic payload; delivery token and generated timestamp are not content. */\nexport function agentContextCheckpointMatchesCreateInput(\n record: AgentContextCheckpointRecord,\n input: CreateAgentContextCheckpointInput\n): boolean {\n return (\n record.id === input.id &&\n record.projectId === input.projectId &&\n record.threadId === input.threadId &&\n record.createdByRunId === input.createdByRunId &&\n (record.previousCheckpointId ?? null) === input.expectedPreviousCheckpointId &&\n record.reason === input.reason &&\n record.summary === input.summary &&\n record.summaryFormatVersion === input.summaryFormatVersion &&\n record.summarizedThroughSeq === input.summarizedThroughSeq &&\n record.observedHeadSeq === input.observedHeadSeq &&\n record.estimatedInputTokensBefore === input.estimatedInputTokensBefore &&\n record.estimatedInputTokensAfter === input.estimatedInputTokensAfter &&\n record.summaryModelId === input.summaryModelId\n )\n}\n\n/** Validate the fields of a save that storage relies on, before entering its transaction. */\nexport function assertSaveAgentMemoryInput(input: SaveAgentMemoryInput, prefix = \"Sixb\"): void {\n const fail = (message: string): never => {\n throw new AgentStorageError(\"invalid_input\", `[${prefix}] Agent memory ${message}`)\n }\n if (input.projectId.trim().length === 0) fail(\"project id must not be empty.\")\n if (input.repoId.trim().length === 0) fail(\"repo id must not be empty.\")\n if (!Number.isSafeInteger(input.baseRevision) || input.baseRevision < 0) {\n fail(\"base revision must be a non-negative integer.\")\n }\n if (input.message.trim().length === 0) fail(\"save message must not be empty.\")\n if (input.changes.length === 0) fail(\"save must change at least one file.\")\n const paths = new Set<string>()\n for (const change of input.changes) {\n if (change.path.length === 0) fail(\"paths must not be empty.\")\n if (paths.has(change.path)) fail(`save changes '${change.path}' more than once.`)\n paths.add(change.path)\n }\n if (input.createdAt && !Number.isFinite(input.createdAt.getTime())) {\n fail(\"save time must be a valid date.\")\n }\n}\n\n/** A path's highest-revision version; `contents: null` when that revision deleted it. */\nexport interface LatestAgentMemoryFile {\n readonly revision: number\n readonly contents: string | null\n}\n\n/**\n * The changes of a save that would overwrite another save's work, as their files are now: every\n * change when the repo is behind the base revision (it was deleted since), otherwise each change\n * whose path was written after the base revision. Ordered by path.\n */\nexport function agentMemoryConflicts(\n input: SaveAgentMemoryInput,\n head: number,\n latest: ReadonlyMap<string, LatestAgentMemoryFile>\n): AgentMemoryChange[] {\n return input.changes\n .filter(\n (change) =>\n input.baseRevision > head || (latest.get(change.path)?.revision ?? 0) > input.baseRevision\n )\n .map((change) => ({ path: change.path, contents: latest.get(change.path)?.contents ?? null }))\n .sort((left, right) => compareAgentMemoryPaths(left.path, right.path))\n}\n\n/** Code-unit order, as SQLite and Postgres (with `COLLATE \"C\"`) compare paths. */\nexport function compareAgentMemoryPaths(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0\n}\n\n/** File versions written before this time leave the history once a newer version exists. */\nexport function agentMemoryHistoryCutoff(savedAt: Date): Date {\n return new Date(savedAt.getTime() - AGENT_MEMORY_HISTORY_DAYS * 24 * 60 * 60 * 1000)\n}\n\n// ── token rates ───────────────────────────────────────────────────────────────────────────────\n\nexport { AGENT_TOKEN_RATE_SAMPLES } from \"./types\"\n\n/** Validate a measurement before a store keeps it: it comes from whichever runner ran the run. */\nexport function assertAgentTokenRateRecord(input: AgentTokenRateRecord, prefix = \"Sixb\"): void {\n const fail = (message: string): never => {\n throw new AgentStorageError(\"invalid_input\", `[${prefix}] Agent token rate ${message}`)\n }\n\n for (const field of [\"projectId\", \"providerId\", \"modelId\", \"runId\"] as const) {\n const value: unknown = input[field]\n if (typeof value !== \"string\" || value.trim().length === 0) fail(`${field} must not be empty.`)\n }\n for (const field of [\"bytes\", \"tokens\"] as const) {\n const value: unknown = input[field]\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0) {\n fail(`${field} must be a positive integer.`)\n }\n }\n if (!(input.measuredAt instanceof Date) || !Number.isFinite(input.measuredAt.getTime())) {\n fail(\"measurement time must be a valid date.\")\n }\n\n const rate = input.bytes / input.tokens\n if (rate < AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN || rate > AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN) {\n fail(\n `bytes per token must be between ${AGENT_TOKEN_RATE_MIN_BYTES_PER_TOKEN} and ${AGENT_TOKEN_RATE_MAX_BYTES_PER_TOKEN}.`\n )\n }\n}\n\n// ── approvals ─────────────────────────────────────────────────────────────────────────────────\n\n/** An approval that still answers for its call key: a settled one asks again. */\nexport const LIVE_AGENT_APPROVAL_STATUSES = [\n \"pending\",\n \"approved\",\n \"denied\",\n] as const satisfies readonly AgentApprovalStatus[]\n\n/**\n * Whether an approval keeps its run paused: still waiting, or decided and not reported to the model\n * yet. A run finishes `awaiting_approval` only while it holds one.\n */\nexport function agentApprovalHoldsRun(approval: AgentApprovalRecord, runId: string): boolean {\n return (\n (approval.runId === runId || approval.callerRunId === runId) &&\n (LIVE_AGENT_APPROVAL_STATUSES as readonly string[]).includes(approval.status) &&\n approval.reportedInMessageId === undefined\n )\n}\n\n/** Refuse a paused finish that holds no call, or a paused finish that did not succeed. */\nexport function assertAwaitingApprovalFinish(input: {\n readonly runId: string\n readonly status: string\n readonly holdsApproval: boolean\n readonly prefix?: string\n}): void {\n const prefix = input.prefix ?? \"Sixb\"\n if (input.status !== \"succeeded\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent run '${input.runId}' can only pause for approval when it succeeds.`\n )\n }\n if (!input.holdsApproval) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent run '${input.runId}' holds no call waiting for approval, so it cannot finish awaiting one.`\n )\n }\n}\n\n/**\n * Whether a run can have approvals: its mode holds some calls. A turn from before approval modes,\n * or in `auto`, holds none, and neither do its children, which copy its mode.\n */\nexport function agentRunMayHoldCalls(run: AgentRunRecord): boolean {\n return (AGENT_HOLDING_APPROVAL_MODES as readonly unknown[]).includes(run.spec?.approvalMode)\n}\n\n/** Whether a stop request reaches this approval. */\nexport function agentApprovalStops(\n approval: AgentApprovalRecord,\n input: StopAgentApprovalsInput\n): boolean {\n return (\n approval.projectId === input.projectId &&\n approval.threadId === input.threadId &&\n approval.reportedInMessageId === undefined &&\n (input.runId === undefined || approval.runId === input.runId) &&\n (input.requestedBy === undefined ||\n (approval.requestedBy.type === input.requestedBy.type &&\n approval.requestedBy.id === input.requestedBy.id))\n )\n}\n\n/** Whether a repair pass has work on this approval; providers run the same filter in SQL. */\nexport function agentApprovalRepairable(\n approval: AgentApprovalRecord,\n claimableBefore: Date\n): boolean {\n const unfinished =\n approval.status === \"approved\" &&\n approval.outcome === undefined &&\n (approval.executionClaimedAt ?? approval.decidedAt ?? new Date(0)) <= claimableBefore\n const resumable =\n (approval.status === \"approved\" || approval.status === \"denied\") &&\n approval.reportedInMessageId === undefined &&\n approval.turnStoppedAt === undefined\n return unfinished || resumable\n}\n\n/** Whether an approved call without an outcome can be claimed now. */\nexport function agentApprovalClaimable(approval: AgentApprovalRecord, staleBefore: Date): boolean {\n return (\n approval.status === \"approved\" &&\n approval.outcome === undefined &&\n (approval.executionClaimedAt ?? approval.decidedAt ?? new Date(0)) <= staleBefore\n )\n}\n\n/** The run id the call names: unique among a thread's live approvals. */\nexport function agentApprovalCallKey(call: AgentApprovalCall): string {\n return call.kind === \"action\" ? call.actionRunId : call.workflowRunId\n}\n\nexport function assertRequestAgentApprovalInput(\n input: RequestAgentApprovalInput,\n prefix = \"Sixb\"\n): void {\n for (const [name, value] of [\n [\"id\", input.id],\n [\"projectId\", input.projectId],\n [\"runId\", input.runId],\n [\"callerRunId\", input.callerRunId],\n [\"executionToken\", input.executionToken],\n [\"call key\", agentApprovalCallKey(input.call)],\n ] as const) {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent approval '${name}' must not be empty.`\n )\n }\n }\n if (!(AGENT_HOLDING_APPROVAL_MODES as readonly unknown[]).includes(input.mode)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent approval mode must be one of: ${AGENT_HOLDING_APPROVAL_MODES.join(\", \")}.`\n )\n }\n}\n\n/**\n * Fence a held call: the caller run is running with the request's token, and is the turn or one of\n * its children. Returns the turn's thread.\n */\nexport function assertAgentApprovalCaller(input: {\n readonly request: RequestAgentApprovalInput\n readonly turn: AgentRunRecord | null\n readonly caller: AgentRunRecord | null\n readonly prefix?: string\n}): string {\n const { request, turn, caller } = input\n const prefix = input.prefix ?? \"Sixb\"\n if (!turn || !caller) {\n throw new AgentStorageError(\n \"run_not_found\",\n `[${prefix}] Agent run '${turn ? request.callerRunId : request.runId}' not found for project '${request.projectId}'.`\n )\n }\n if (turn.kind !== \"conversation\") {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent approval run '${turn.id}' must be a conversation turn.`\n )\n }\n if (caller.id !== turn.id && !(caller.kind === \"subagent\" && caller.parentRunId === turn.id)) {\n throw new AgentStorageError(\n \"invalid_input\",\n `[${prefix}] Agent run '${caller.id}' does not belong to turn '${turn.id}'.`\n )\n }\n if (caller.status !== \"running\") {\n throw new AgentStorageError(\n \"invalid_state\",\n `[${prefix}] Agent run '${caller.id}' is not running (status '${caller.status}').`\n )\n }\n if (!caller.execution || caller.execution.token !== request.executionToken) {\n throw new AgentStorageError(\n \"execution_lost\",\n `[${prefix}] Execution token is no longer current on agent run '${caller.id}'.`\n )\n }\n return turn.threadId\n}\n\n/** The approval a request creates, before any provider writes it. */\nexport function newAgentApprovalRecord(\n input: RequestAgentApprovalInput,\n threadId: string\n): AgentApprovalRecord {\n return {\n id: input.id,\n projectId: input.projectId,\n threadId,\n runId: input.runId,\n callerRunId: input.callerRunId,\n requestedBy: structuredClone(input.requestedBy),\n mode: input.mode,\n callKey: agentApprovalCallKey(input.call),\n call: structuredClone(input.call),\n status: \"pending\",\n createdAt: new Date(input.createdAt ?? new Date()),\n expiresAt: new Date(input.expiresAt),\n }\n}\n\n/** Whether an approval matches a list filter; providers run the same filter in SQL. */\nexport function agentApprovalMatches(\n approval: AgentApprovalRecord,\n input: ListAgentApprovalsInput\n): boolean {\n return (\n approval.projectId === input.projectId &&\n (input.threadId === undefined || approval.threadId === input.threadId) &&\n (input.runId === undefined || approval.runId === input.runId) &&\n (input.requestedBy === undefined ||\n (approval.requestedBy.type === input.requestedBy.type &&\n approval.requestedBy.id === input.requestedBy.id)) &&\n (input.statuses === undefined || input.statuses.includes(approval.status)) &&\n (input.reported === undefined ||\n (approval.reportedInMessageId !== undefined) === input.reported)\n )\n}\n",
|
|
7
|
-
"import { createHash, randomUUID } from \"node:crypto\"\n\n/**\n * Id helpers for agent persistence. Threads, the run id, and the user (trigger) message are minted\n * by the trigger; the queued run is persisted with the user message, and the assistant message id\n * is minted when the turn finalizes. Prefixes make ids self-describing in logs.\n */\n\nexport function createAgentThreadId(): string {\n return `agt_thr_${randomUUID()}`\n}\n\n/** A fresh provider name, scoped to one project's thread; never a filesystem revision. */\nexport function createAgentThreadSandboxName(projectId: string, threadId: string): string {\n const digest = createHash(\"sha256\")\n .update(JSON.stringify([projectId, threadId, randomUUID()]))\n .digest(\"hex\")\n return `sixb-sb-${digest}`\n}\n\nexport function createAgentRunId(): string {\n return `agt_run_${randomUUID()}`\n}\n\n/** How every child's first run id starts: told apart from the key the Agent spawned it under. */\nexport const SUBAGENT_RUN_ID_PREFIX = \"agt_run_child_\"\n\n/** One stable child identity per parent-selected spawn key. */\nexport function createSubagentRunId(parentRunId: string, spawnKey: string): string {\n return `${SUBAGENT_RUN_ID_PREFIX}${spawnDigest(parentRunId, spawnKey)}`\n}\n\n/**\n * The thread a child works in, named after the turn that spawned it and its key. It shares its\n * first run's digest: migration `subagent-threads` names the threads of earlier children so.\n */\nexport function createSubagentThreadId(spawningRunId: string, spawnKey: string): string {\n return `agt_thr_child_${spawnDigest(spawningRunId, spawnKey)}`\n}\n\nfunction spawnDigest(runId: string, spawnKey: string): string {\n return createHash(\"sha256\").update(runId).update(\"\\0\").update(spawnKey).digest(\"hex\")\n}\n\n/** Stable execution identity paired with a deterministic child run. */\nexport function createSubagentExecutionId(runId: string): string {\n return `exec_${runId}`\n}\n\nexport function createAgentMessageId(): string {\n return `agt_msg_${randomUUID()}`\n}\n\n/** One deterministic context-checkpoint identity per conversational run. */\nexport function agentContextCheckpointId(runId: string): string {\n return `agt_ctx_${runId}`\n}\n\n/** A checkpoint copied into a fork; the source's checkpoint keeps its run-derived id. */\nexport function createCopiedAgentContextCheckpointId(): string {\n return `agt_ctx_copy_${randomUUID()}`\n}\n\n/** A queue delivery's fencing token for writes to an `agent_runs` record. */\nexport function createAgentRunExecutionToken(): string {\n return `agt_exec_${randomUUID()}`\n}\n",
|
|
8
|
-
"import type { ActionsRuntime } from \"../actions/execution\"\nimport type { BlobBody, FileRef, OpenedFileRef } from \"../blob-storage\"\nimport type { ConnectorRuntime } from \"../connectors\"\nimport type { JsonPrimitive, JsonValue, ReadonlyJsonValue } from \"../json\"\nimport type { Logger } from \"../logging\"\nimport { type LanguageModelRef, MODEL_REASONING_LEVELS, type ModelReasoning } from \"../models\"\nimport type { ModelsRuntime } from \"../models/generation-types\"\nimport type { InferSchema } from \"../ontology/inference\"\nimport type { Schema } from \"../ontology/types\"\nimport type { ObjectReader } from \"../runtime/types\"\nimport type { UsersRuntime } from \"../users\"\n\nexport type {\n AgentContextEntryInput,\n AgentContextInput,\n AgentContextOrigin,\n AgentContextPart,\n} from \"./context/entries\"\n\n/** Public capability reference used by security grants such as `can.run(agent)`. */\nexport interface AgentReference {\n readonly kind: \"agent\"\n readonly usage: AgentUsageReference\n readonly threads: AgentThreadsReference\n readonly memory: AgentMemoryReference\n}\n\n/** Project-wide AI accounting and limit capability, independent of permission to run the Agent. */\nexport interface AgentUsageReference {\n readonly kind: \"aiUsage\"\n}\n\n/** Every user's conversations with the Agent, as `can.observe(agent.threads)` reads them. */\nexport interface AgentThreadsReference {\n readonly kind: \"agentThreads\"\n}\n\n/** The project's shared Agent memory, which every conversation reads. */\nexport interface AgentMemoryReference {\n readonly kind: \"agentMemory\"\n}\n\n/** Public metadata for the project's conversational Agent. */\nexport interface AgentDescriptor {\n readonly name: string\n readonly model: LanguageModelRef\n}\n\nexport type AgentReasoning = ModelReasoning\n\nexport const AGENT_REASONING_LEVELS = MODEL_REASONING_LEVELS\n\ntype Simplify<T> = { [K in keyof T]: T[K] } & {}\ntype JsonifyAgentToolInput<T> = unknown extends T\n ? ReadonlyJsonValue\n : T extends Date\n ? string\n : T extends readonly (infer TItem)[]\n ? readonly JsonifyAgentToolInput<TItem>[]\n : T extends JsonPrimitive\n ? T\n : T extends object\n ? { readonly [K in keyof T]: JsonifyAgentToolInput<T[K]> }\n : never\n\n/** A model-facing object shape expressed with Sixb's schema DSL. */\nexport type AgentToolInputSchema = Readonly<Record<string, Schema>>\n\n/** Infer the handler input represented by an agent tool schema. */\nexport type InferAgentToolInputSchema<TInput extends AgentToolInputSchema> =\n string extends keyof TInput\n ? Readonly<Record<string, unknown>>\n : Simplify<{\n readonly [K in keyof TInput]: JsonifyAgentToolInput<InferSchema<TInput[K]>>\n }>\n\n/** Identifies the conversational, workflow, or child Agent execution that invoked a tool. */\nexport type AgentToolRunInfo =\n | {\n readonly kind: \"conversation\"\n readonly id: string\n readonly threadId: string\n }\n | {\n readonly kind: \"subagent\"\n readonly id: string\n readonly parentRunId: string\n }\n | {\n readonly kind: \"workflow\"\n readonly id: string\n readonly workflowId: string\n readonly stepId: string\n }\n\n/** Input accepted by the run-scoped file publisher exposed to agent tools. */\nexport interface AgentToolFilePutInput {\n readonly body: BlobBody\n readonly fileName: string\n readonly mediaType?: string\n}\n\n/** A file a tool stored durably, and the path of its copy inside the current run sandbox. */\nexport interface AgentToolFile {\n readonly fileRef: FileRef\n readonly sandboxPath: string\n}\n\n/** The narrow file-writing surface available to an agent tool call. */\nexport interface AgentToolFiles {\n put(input: AgentToolFilePutInput): Promise<AgentToolFile>\n}\n\n/**\n * The files attached to the run that invoked a tool: the messages of a chat's thread, or the input\n * files of a workflow AI task. A child Agent has none.\n */\nexport interface AgentToolAttachments {\n /**\n * Open an attachment by the `key` the Agent sees in `$SIXB_ATTACHMENTS`. Returns null when its\n * stored file is gone, and throws an `AgentToolPublicError` for a key that is not one of this\n * run's attachments.\n */\n open(key: string): Promise<OpenedFileRef | null>\n}\n\nexport type AgentToolTextContent = {\n readonly type: \"text\"\n readonly text: string\n}\n\nexport type AgentToolFileContent = {\n readonly type: \"file\"\n readonly fileRef: FileRef\n}\n\n/** Durable model-facing content returned by a file-aware tool. */\nexport type AgentToolContent = AgentToolTextContent | AgentToolFileContent\n\n/**\n * A file-aware tool result. The tag distinguishes this envelope from an ordinary JSON result while\n * keeping the whole value safe to persist in the durable tool-call trace.\n */\nexport type AgentToolResult = {\n readonly kind: \"agentToolResult\"\n readonly content: readonly AgentToolContent[]\n}\n\n/**\n * The run's domain SDK as an agent tool sees it. Unlike workflow steps and actions, it acts as the\n * run's requester: the signed-in user in a chat, that same user in a child Agent, and the step's\n * groups in a workflow AI task.\n *\n * A structural view of the public `Sixb` SDK, like `WorkflowRuntimeFacade`: the handler receives the\n * run's bound SDK, and this type guides it to what a tool should do. It reads objects and changes\n * them by requesting actions, which validate and record the change. Authority comes from the run,\n * not from this view.\n */\nexport interface AgentToolRuntimeFacade extends ObjectReader {\n readonly actions: ActionsRuntime\n readonly models: ModelsRuntime\n readonly connector: ConnectorRuntime\n readonly users: UsersRuntime\n}\n\n/** The narrow, run-scoped surface passed to an agent tool handler. */\nexport interface AgentToolRunContext<\n TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,\n> {\n readonly input: TInput\n readonly toolCallId: string\n readonly signal: AbortSignal\n readonly run: AgentToolRunInfo\n readonly sixb: AgentToolRuntimeFacade\n readonly logger: Logger\n readonly files: AgentToolFiles\n readonly attachments: AgentToolAttachments\n}\n\n/** Agent tool handlers may return only values safe to persist in agent messages. */\nexport type AgentToolHandlerResult<\n TOutput extends ReadonlyJsonValue | AgentToolResult = ReadonlyJsonValue | AgentToolResult,\n> = TOutput | Promise<TOutput>\n\nexport type AgentToolHandler<\n TInput extends Readonly<Record<string, unknown>>,\n TOutput extends ReadonlyJsonValue | AgentToolResult = ReadonlyJsonValue | AgentToolResult,\n> = (context: AgentToolRunContext<TInput>) => AgentToolHandlerResult<TOutput>\n\n/**\n * Runtime definitions are stored heterogeneously. Keep variance erasure at this\n * boundary only; authoring through `run()` remains strictly contravariant.\n */\ntype StoredAgentToolHandler<TInput extends Readonly<Record<string, unknown>>> = {\n bivarianceHack(context: AgentToolRunContext<TInput>): JsonValue | Promise<JsonValue>\n}[\"bivarianceHack\"]\n\ndeclare const agentToolOutputValueType: unique symbol\n\n/** A reusable, inert model tool definition selected explicitly by an agent. */\nexport interface AgentToolDefinition<\n TName extends string = string,\n TInput extends AgentToolInputSchema = AgentToolInputSchema,\n TOutput extends ReadonlyJsonValue | AgentToolResult = ReadonlyJsonValue | AgentToolResult,\n> {\n readonly kind: \"agentTool\"\n readonly name: TName\n readonly description: string\n readonly input: TInput\n readonly handler: StoredAgentToolHandler<InferAgentToolInputSchema<TInput>>\n readonly [agentToolOutputValueType]?: TOutput\n}\n\n/** Infer the input received by a tool definition's handler. */\nexport type InferAgentToolInput<TTool extends AgentToolDefinition> = InferAgentToolInputSchema<\n TTool[\"input\"]\n>\n\n/**\n * Infer the output a chat receives from a tool: its handler's return value, saved on the message\n * and streamed live as is. A file-aware tool's output is its `AgentToolResult` envelope.\n */\nexport type InferAgentToolOutput<TTool extends AgentToolDefinition> =\n TTool extends AgentToolDefinition<string, AgentToolInputSchema, infer TOutput> ? TOutput : never\n\nexport interface AgentToolRunBuilder<TName extends string, TInput extends AgentToolInputSchema> {\n run<TOutput extends ReadonlyJsonValue | AgentToolResult>(\n handler: AgentToolHandler<InferAgentToolInputSchema<TInput>, TOutput>\n ): AgentToolDefinition<TName, TInput, TOutput>\n}\n\nexport interface AgentToolInputBuilder<TName extends string> {\n input<const TInput extends AgentToolInputSchema>(\n input: TInput\n ): AgentToolRunBuilder<TName, TInput>\n}\n\nexport interface AgentToolDescriptionBuilder<TName extends string> {\n description(description: string): AgentToolInputBuilder<TName>\n}\n"
|
|
9
|
-
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAM,2BAA0B,MAAM;AAAA,EAIhC;AAAA,EAHF,OAAO;AAAA,EAEhB,WAAW,CACA,MACT,SACA;AAAA,IACA,MAAM,OAAO;AAAA,IAHJ;AAAA;AAKb;;;AC1BA;;;ACAA;AAQO,SAAS,oBAAmB,GAAW;AAAA,EAC5C,OAAO,WAAW,WAAW;AAAA;AAIxB,SAAS,6BAA4B,CAAC,WAAmB,UAA0B;AAAA,EACxF,MAAM,SAAS,WAAW,QAAQ,EAC/B,OAAO,KAAK,UAAU,CAAC,WAAW,UAAU,WAAW,CAAC,CAAC,CAAC,EAC1D,OAAO,KAAK;AAAA,EACf,OAAO,WAAW;AAAA;AAGb,SAAS,iBAAgB,GAAW;AAAA,EACzC,OAAO,WAAW,WAAW;AAAA;AAIxB,IAAM,0BAAyB;AAG/B,SAAS,oBAAmB,CAAC,aAAqB,UAA0B;AAAA,EACjF,OAAO,GAAG,0BAAyB,YAAY,aAAa,QAAQ;AAAA;AAO/D,SAAS,uBAAsB,CAAC,eAAuB,UAA0B;AAAA,EACtF,OAAO,iBAAiB,YAAY,eAAe,QAAQ;AAAA;AAG7D,SAAS,WAAW,CAAC,OAAe,UAA0B;AAAA,EAC5D,OAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAK;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