@sixb/core 0.1.2 → 0.1.4
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 +19 -17
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/worker.js +4 -4
- package/dist/actions/worker.js.map +1 -1
- package/dist/agents/adapters.d.ts +11 -1
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/context-compaction.d.ts +40 -0
- package/dist/agents/context-compaction.d.ts.map +1 -0
- package/dist/agents/context.js +1 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +3 -0
- 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 +10 -6
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +51 -35
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/streams.d.ts +17 -1
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +5 -3
- package/dist/agents/streams.js.map +1 -1
- package/dist/agents/thread-context-projection.d.ts +19 -0
- package/dist/agents/thread-context-projection.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/tool-result.d.ts +6 -0
- package/dist/agents/tool-result.d.ts.map +1 -0
- package/dist/agents/types.d.ts +46 -1
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +2 -2
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/auth/index.js +11 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/index.js +6 -2
- package/dist/authorization/index.js.map +1 -1
- package/dist/bootstrap/index.js +33 -31
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/{chunk-ys1nse2v.js → chunk-1wk20wn3.js} +438 -246
- package/dist/{chunk-ys1nse2v.js.map → chunk-1wk20wn3.js.map} +11 -11
- package/dist/{chunk-sa4340y1.js → chunk-1yz3x65y.js} +7 -7
- package/dist/{chunk-gqdd7508.js → chunk-4rh2m6zg.js} +1 -1
- package/dist/{chunk-fmx1sz2h.js → chunk-72q2y8hn.js} +3 -3
- package/dist/{chunk-fmx1sz2h.js.map → chunk-72q2y8hn.js.map} +4 -4
- package/dist/{chunk-nnyp53zt.js → chunk-7gw7mepb.js} +259 -9
- package/dist/chunk-7gw7mepb.js.map +14 -0
- package/dist/{chunk-nten49ta.js → chunk-819wnjz8.js} +11 -5
- package/dist/chunk-819wnjz8.js.map +12 -0
- package/dist/chunk-96swp2wd.js +47 -0
- package/dist/chunk-96swp2wd.js.map +10 -0
- package/dist/{chunk-4x43bkbp.js → chunk-a09jx26t.js} +1 -1
- package/dist/{chunk-st4xgxey.js → chunk-afjpa2hs.js} +205 -48
- package/dist/chunk-afjpa2hs.js.map +45 -0
- package/dist/{chunk-0mbx247x.js → chunk-c43qr6s0.js} +427 -99
- package/dist/chunk-c43qr6s0.js.map +46 -0
- package/dist/{chunk-zg9yryhz.js → chunk-cbkm2vam.js} +3 -3
- package/dist/{chunk-57zpb99z.js → chunk-dm72y8wt.js} +26 -3
- package/dist/chunk-dm72y8wt.js.map +10 -0
- package/dist/chunk-drjqm1aa.js +913 -0
- package/dist/chunk-drjqm1aa.js.map +15 -0
- package/dist/chunk-dysw7nsm.js.map +1 -1
- package/dist/{chunk-8ryen3p3.js → chunk-f6erf2vv.js} +1 -1
- package/dist/{chunk-34bqh420.js → chunk-f83ka50g.js} +188 -44
- package/dist/chunk-f83ka50g.js.map +23 -0
- package/dist/{chunk-bct7hmfc.js → chunk-g13869yf.js} +3 -3
- package/dist/{chunk-0k4avqr2.js → chunk-hbeh8j9w.js} +2 -2
- package/dist/{chunk-qvybnnpe.js → chunk-nzw7sm3b.js} +2 -2
- package/dist/{chunk-k9pts48t.js → chunk-pn8n8sba.js} +16 -15
- package/dist/{chunk-k9pts48t.js.map → chunk-pn8n8sba.js.map} +3 -3
- package/dist/{chunk-63te770v.js → chunk-qewtks41.js} +8 -8
- package/dist/{chunk-63te770v.js.map → chunk-qewtks41.js.map} +2 -2
- package/dist/{chunk-85j5ybfj.js → chunk-rdeagz6b.js} +2 -2
- package/dist/{chunk-85j5ybfj.js.map → chunk-rdeagz6b.js.map} +3 -3
- package/dist/chunk-rhrbz7d4.js +36 -0
- package/dist/chunk-rhrbz7d4.js.map +10 -0
- package/dist/{chunk-bh6k3nc6.js → chunk-rs1wbvy6.js} +1 -1
- package/dist/{chunk-88ppkr54.js → chunk-rte5sm3z.js} +26 -2
- package/dist/chunk-rte5sm3z.js.map +12 -0
- package/dist/{chunk-n8herkry.js → chunk-s31d0qmq.js} +57 -20
- package/dist/{chunk-n8herkry.js.map → chunk-s31d0qmq.js.map} +8 -7
- package/dist/{chunk-7pc8b818.js → chunk-sxwk41qa.js} +1 -1
- package/dist/{chunk-663csy96.js → chunk-t0jjkep3.js} +2 -1
- package/dist/chunk-t0jjkep3.js.map +10 -0
- package/dist/{chunk-c6qd89g5.js → chunk-tek1qwgm.js} +6 -6
- package/dist/{chunk-c6qd89g5.js.map → chunk-tek1qwgm.js.map} +1 -1
- package/dist/{chunk-jaj13078.js → chunk-tkdscva6.js} +3 -33
- package/dist/{chunk-jaj13078.js.map → chunk-tkdscva6.js.map} +3 -4
- package/dist/{chunk-5egfka8j.js → chunk-tycbzedm.js} +2 -2
- package/dist/{chunk-g9t3kdtx.js → chunk-x2yw73hy.js} +1 -1
- package/dist/{chunk-57r1cpxx.js → chunk-xc7hq65b.js} +3 -2
- package/dist/{chunk-57r1cpxx.js.map → chunk-xc7hq65b.js.map} +3 -3
- package/dist/chunk-xdf9yswn.js +133 -0
- package/dist/chunk-xdf9yswn.js.map +11 -0
- package/dist/execution/agent.js +29 -27
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +29 -27
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +30 -28
- package/dist/execution/request.js.map +2 -2
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -58
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +2 -1
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/materialization/model.d.ts +4 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/edits/apply.d.ts +6 -1
- package/dist/materializer/edits/apply.d.ts.map +1 -1
- package/dist/materializer/edits/working-state.d.ts +2 -0
- package/dist/materializer/edits/working-state.d.ts.map +1 -1
- package/dist/materializer/effective/resolve.d.ts +3 -1
- package/dist/materializer/effective/resolve.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +19 -17
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/index.d.ts +40 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +6 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +21 -19
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/endpoints.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +1 -0
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/explain.d.ts +1 -0
- package/dist/objects/query/explain.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +3 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +30 -5
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +14 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/links.d.ts +25 -0
- package/dist/objects/query/links.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +1 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/pipelines/index.js +16 -15
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/builders.d.ts +52 -10
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +2 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.d.ts +4 -1
- package/dist/projections/internal.d.ts.map +1 -1
- package/dist/projections/internal.js +22 -17
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts +1 -0
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/projections/timestamp.d.ts +3 -0
- package/dist/projections/timestamp.d.ts.map +1 -0
- package/dist/projections/types.d.ts +21 -9
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +6 -5
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/query.d.ts +2 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/types.d.ts +7 -0
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/ai-cost.d.ts +8 -0
- package/dist/runtime/ai-cost.d.ts.map +1 -0
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +3 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +2 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +22 -4
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +31 -0
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +22 -7
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +75 -4
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +61 -0
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -0
- package/dist/storage/ai-cost/codec.d.ts +14 -0
- package/dist/storage/ai-cost/codec.d.ts.map +1 -0
- package/dist/storage/ai-cost/errors.d.ts +7 -0
- package/dist/storage/ai-cost/errors.d.ts.map +1 -0
- package/dist/storage/ai-cost/in-memory.d.ts +32 -0
- package/dist/storage/ai-cost/in-memory.d.ts.map +1 -0
- package/dist/storage/ai-cost/index.d.ts +6 -0
- package/dist/storage/ai-cost/index.d.ts.map +1 -0
- package/dist/storage/ai-cost/provider.d.ts +7 -0
- package/dist/storage/ai-cost/provider.d.ts.map +1 -0
- package/dist/storage/ai-cost/provider.js +132 -0
- package/dist/storage/ai-cost/provider.js.map +10 -0
- package/dist/storage/ai-cost/types.d.ts +154 -0
- package/dist/storage/ai-cost/types.d.ts.map +1 -0
- package/dist/storage/ai-cost/validation.d.ts +7 -0
- package/dist/storage/ai-cost/validation.d.ts.map +1 -0
- package/dist/storage/ai-usage/in-memory.d.ts +2 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +1 -1
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +6 -0
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/in-memory/index.d.ts +5 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +33 -21
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/objects/in-memory.d.ts +6 -3
- package/dist/storage/objects/in-memory.d.ts.map +1 -1
- package/dist/storage/objects/index.d.ts +3 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +16 -0
- package/dist/storage/objects/keys.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +33 -6
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +3 -0
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +10 -5
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +16 -15
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts +3 -2
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts +12 -0
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -0
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/effective-storage-contract.d.ts +1 -1
- package/dist/testing/effective-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 +2525 -1480
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +14 -13
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +12 -2
- package/dist/workers/index.js.map +3 -3
- package/dist/workers/queue-worker.d.ts +2 -0
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workflows/execution.d.ts +3 -0
- package/dist/workflows/execution.d.ts.map +1 -1
- package/dist/workflows/index.js +30 -28
- package/dist/workflows/index.js.map +1 -1
- package/package.json +7 -1
- package/src/agents/adapters.ts +64 -23
- package/src/agents/builders.ts +3 -3
- package/src/agents/context-compaction.ts +261 -0
- package/src/agents/errors.ts +2 -2
- package/src/agents/execution.ts +14 -2
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +32 -6
- package/src/agents/request.ts +5 -0
- package/src/agents/streams.ts +56 -0
- package/src/agents/thread-context-projection.ts +93 -0
- package/src/agents/tool-definition.ts +17 -2
- package/src/agents/tool-result.ts +61 -0
- package/src/agents/types.ts +57 -1
- package/src/agents/validation.ts +36 -6
- package/src/http/api-routes.ts +7 -7
- package/src/index.ts +27 -0
- package/src/lake-storage/types.ts +2 -1
- package/src/materialization/model.ts +4 -0
- package/src/materializer/edits/apply.ts +55 -2
- package/src/materializer/edits/operations.ts +8 -1
- package/src/materializer/edits/working-state.ts +7 -0
- package/src/materializer/effective/resolve.ts +78 -9
- package/src/materializer/execution/work-records.ts +3 -1
- package/src/materializer/projections/entry-validator.ts +23 -1
- package/src/materializer/projections/replacement-plan.ts +2 -0
- package/src/materializer/shared/normalize.ts +16 -0
- package/src/materializer/telemetry/append.ts +33 -16
- package/src/models/index.ts +71 -0
- package/src/objects/execution.ts +20 -0
- package/src/objects/link/endpoints.ts +2 -1
- package/src/objects/query/executor.ts +42 -11
- package/src/objects/query/explain.ts +11 -0
- package/src/objects/query/index.ts +6 -0
- package/src/objects/query/ir.ts +16 -0
- package/src/objects/query/links.ts +308 -0
- package/src/objects/query/normalize.ts +40 -1
- package/src/objects/query/planner.ts +5 -0
- package/src/objects/query/validate.ts +58 -2
- package/src/projections/builders.ts +320 -50
- package/src/projections/index.ts +7 -0
- package/src/projections/internal.ts +4 -1
- package/src/projections/ownership.ts +5 -5
- package/src/projections/registry.ts +16 -3
- package/src/projections/revision.ts +35 -5
- package/src/projections/run-dispatch.ts +10 -1
- package/src/projections/timestamp.ts +66 -0
- package/src/projections/types.ts +20 -9
- package/src/projections/validation.ts +85 -19
- package/src/query.ts +2 -0
- package/src/queues/index.ts +1 -0
- package/src/queues/types.ts +8 -0
- package/src/runtime/ai-cost.ts +15 -0
- package/src/runtime/create.ts +4 -0
- package/src/runtime/definitions.ts +3 -0
- package/src/runtime/host.ts +2 -0
- package/src/runtime/resolve-definitions.ts +28 -0
- package/src/storage/agents/in-memory.ts +186 -4
- package/src/storage/agents/index.ts +5 -0
- package/src/storage/agents/provider.ts +225 -0
- package/src/storage/agents/types.ts +82 -3
- package/src/storage/ai-cost/analytics.ts +602 -0
- package/src/storage/ai-cost/codec.ts +136 -0
- package/src/storage/ai-cost/errors.ts +12 -0
- package/src/storage/ai-cost/in-memory.ts +164 -0
- package/src/storage/ai-cost/index.ts +35 -0
- package/src/storage/ai-cost/provider.ts +20 -0
- package/src/storage/ai-cost/types.ts +193 -0
- package/src/storage/ai-cost/validation.ts +337 -0
- package/src/storage/ai-usage/in-memory.ts +23 -0
- package/src/storage/ai-usage/index.ts +1 -0
- package/src/storage/ai-usage/types.ts +10 -0
- package/src/storage/in-memory/index.ts +50 -0
- package/src/storage/index.ts +48 -0
- package/src/storage/objects/in-memory.ts +103 -16
- package/src/storage/objects/index.ts +9 -0
- package/src/storage/objects/keys.ts +36 -0
- package/src/storage/objects/types.ts +34 -6
- package/src/storage/ontology/in-memory/materializations.ts +1 -0
- package/src/storage/ontology/materializations.ts +3 -0
- package/src/storage/ontology/provider-header-validation.ts +2 -2
- package/src/storage/operation-scope.ts +1 -0
- package/src/storage/types.ts +2 -0
- package/src/testing/agent-storage-contract.ts +353 -2
- package/src/testing/ai-cost-storage-contract.ts +320 -0
- package/src/testing/ai-usage-storage-contract.ts +35 -0
- package/src/testing/effective-storage-contract.ts +194 -4
- package/src/testing/index.ts +5 -0
- package/src/testing/lake-storage-contract.ts +56 -0
- package/src/testing/materializer-storage-contract.ts +120 -2
- package/src/testing/object-query-contract.ts +208 -1
- package/src/workers/queue-worker.ts +14 -1
- package/src/workflows/execution.ts +31 -10
- package/dist/agents/prompt.d.ts +0 -15
- package/dist/agents/prompt.d.ts.map +0 -1
- package/dist/chunk-0mbx247x.js.map +0 -43
- package/dist/chunk-34bqh420.js.map +0 -23
- package/dist/chunk-57zpb99z.js.map +0 -10
- package/dist/chunk-663csy96.js.map +0 -10
- package/dist/chunk-6wetht33.js +0 -89
- package/dist/chunk-6wetht33.js.map +0 -10
- package/dist/chunk-88ppkr54.js.map +0 -12
- package/dist/chunk-nnyp53zt.js.map +0 -13
- package/dist/chunk-nten49ta.js.map +0 -12
- package/dist/chunk-st4xgxey.js.map +0 -45
- package/dist/chunk-vp1vc6ee.js +0 -35
- package/dist/chunk-vp1vc6ee.js.map +0 -11
- package/src/agents/prompt.ts +0 -57
- /package/dist/{chunk-sa4340y1.js.map → chunk-1yz3x65y.js.map} +0 -0
- /package/dist/{chunk-gqdd7508.js.map → chunk-4rh2m6zg.js.map} +0 -0
- /package/dist/{chunk-4x43bkbp.js.map → chunk-a09jx26t.js.map} +0 -0
- /package/dist/{chunk-zg9yryhz.js.map → chunk-cbkm2vam.js.map} +0 -0
- /package/dist/{chunk-8ryen3p3.js.map → chunk-f6erf2vv.js.map} +0 -0
- /package/dist/{chunk-bct7hmfc.js.map → chunk-g13869yf.js.map} +0 -0
- /package/dist/{chunk-0k4avqr2.js.map → chunk-hbeh8j9w.js.map} +0 -0
- /package/dist/{chunk-qvybnnpe.js.map → chunk-nzw7sm3b.js.map} +0 -0
- /package/dist/{chunk-bh6k3nc6.js.map → chunk-rs1wbvy6.js.map} +0 -0
- /package/dist/{chunk-7pc8b818.js.map → chunk-sxwk41qa.js.map} +0 -0
- /package/dist/{chunk-5egfka8j.js.map → chunk-tycbzedm.js.map} +0 -0
- /package/dist/{chunk-g9t3kdtx.js.map → chunk-x2yw73hy.js.map} +0 -0
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
SyncValidationError,
|
|
4
4
|
createConnectorRuntime,
|
|
5
5
|
requestSyncRun
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-g13869yf.js";
|
|
7
7
|
import {
|
|
8
8
|
PipelineError,
|
|
9
9
|
requestPipelineRun
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-cbkm2vam.js";
|
|
11
11
|
import {
|
|
12
12
|
appendTelemetry,
|
|
13
13
|
createObjectSet,
|
|
@@ -18,21 +18,22 @@ import {
|
|
|
18
18
|
upsertLinkBatch1 as upsertLinkBatch,
|
|
19
19
|
upsertObject1 as upsertObject,
|
|
20
20
|
upsertObjectBatch1 as upsertObjectBatch
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-pn8n8sba.js";
|
|
22
22
|
import {
|
|
23
23
|
shareOntologyMutationRuntime
|
|
24
24
|
} from "./chunk-xhy826cz.js";
|
|
25
25
|
import {
|
|
26
26
|
countObjects,
|
|
27
27
|
executeObjectQuery,
|
|
28
|
+
executeObjectQueryLinks,
|
|
28
29
|
existsObjects,
|
|
29
30
|
facetObjects
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-7gw7mepb.js";
|
|
31
32
|
import {
|
|
32
33
|
SIXB_API_ROUTES,
|
|
33
34
|
matchesPathPattern,
|
|
34
35
|
normalizeRoutePath
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-qewtks41.js";
|
|
36
37
|
import {
|
|
37
38
|
registerConnectorConnectionsRuntime
|
|
38
39
|
} from "./chunk-nf4r78r4.js";
|
|
@@ -40,26 +41,26 @@ import {
|
|
|
40
41
|
isActionDefinition,
|
|
41
42
|
requestAction,
|
|
42
43
|
requestActionAndWait
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-tek1qwgm.js";
|
|
44
45
|
import {
|
|
45
46
|
createPrimitiveExecutionRecord,
|
|
46
47
|
ensureExecutionRecord,
|
|
47
48
|
executionRecordInputFromRuntime
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-f6erf2vv.js";
|
|
49
50
|
import {
|
|
50
51
|
WORKFLOW_RUN_FAILURE_CODES
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-1wk20wn3.js";
|
|
52
53
|
import {
|
|
53
54
|
WorkflowRunError
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-a09jx26t.js";
|
|
55
56
|
import {
|
|
56
57
|
AgentStorageError
|
|
57
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-xdf9yswn.js";
|
|
58
59
|
import {
|
|
59
60
|
agentServiceAccountId,
|
|
60
61
|
ensureAgentExecutionIdentity,
|
|
61
62
|
resolveAgentExecutionAuthorization
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-nzw7sm3b.js";
|
|
63
64
|
import {
|
|
64
65
|
ExecutionStorageError
|
|
65
66
|
} from "./chunk-h9kxd41f.js";
|
|
@@ -70,34 +71,23 @@ import {
|
|
|
70
71
|
import {
|
|
71
72
|
reportRunFailure
|
|
72
73
|
} from "./chunk-dsrkgtnh.js";
|
|
73
|
-
import {
|
|
74
|
-
assertObjectTypeRegistered,
|
|
75
|
-
normalizeSchemaValue,
|
|
76
|
-
validateSchemaValue
|
|
77
|
-
} from "./chunk-rnshztfq.js";
|
|
78
|
-
import {
|
|
79
|
-
OntologyValidationError
|
|
80
|
-
} from "./chunk-dktq02ne.js";
|
|
81
|
-
import {
|
|
82
|
-
isFileRef,
|
|
83
|
-
supportsDirectUpload,
|
|
84
|
-
supportsRangeRead
|
|
85
|
-
} from "./chunk-zqysyfjt.js";
|
|
86
74
|
import {
|
|
87
75
|
AgentDefinitionError,
|
|
88
76
|
AgentMessageAdapterError,
|
|
89
77
|
AgentRequestError,
|
|
90
78
|
AgentToolResultValidationError,
|
|
91
79
|
normalizeAgentContextEntries
|
|
92
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-rdeagz6b.js";
|
|
93
81
|
import {
|
|
94
82
|
publishAgentRunActivity
|
|
95
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-dm72y8wt.js";
|
|
96
84
|
import {
|
|
97
85
|
SYSTEM_PRINCIPAL,
|
|
98
|
-
principalsEqual
|
|
86
|
+
principalsEqual
|
|
87
|
+
} from "./chunk-tkdscva6.js";
|
|
88
|
+
import {
|
|
99
89
|
snapshotRequesterGroupIds
|
|
100
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-rhrbz7d4.js";
|
|
101
91
|
import {
|
|
102
92
|
AuthorizationError,
|
|
103
93
|
assertAuthorized,
|
|
@@ -114,7 +104,20 @@ import {
|
|
|
114
104
|
createAgentRuntimeAuthorization,
|
|
115
105
|
isAllowed,
|
|
116
106
|
resolveExecutionScopeAuthorization
|
|
117
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-f83ka50g.js";
|
|
108
|
+
import {
|
|
109
|
+
assertObjectTypeRegistered,
|
|
110
|
+
normalizeSchemaValue,
|
|
111
|
+
validateSchemaValue
|
|
112
|
+
} from "./chunk-rnshztfq.js";
|
|
113
|
+
import {
|
|
114
|
+
OntologyValidationError
|
|
115
|
+
} from "./chunk-dktq02ne.js";
|
|
116
|
+
import {
|
|
117
|
+
isFileRef,
|
|
118
|
+
supportsDirectUpload,
|
|
119
|
+
supportsRangeRead
|
|
120
|
+
} from "./chunk-zqysyfjt.js";
|
|
118
121
|
import {
|
|
119
122
|
captureSixbFailure
|
|
120
123
|
} from "./chunk-0172wgm9.js";
|
|
@@ -164,6 +167,20 @@ function createActionsRuntime(runtime, execution) {
|
|
|
164
167
|
};
|
|
165
168
|
}
|
|
166
169
|
|
|
170
|
+
// src/runtime/ai-cost.ts
|
|
171
|
+
async function resolveExecutionCosts(input) {
|
|
172
|
+
if (input.executionIds.length === 0)
|
|
173
|
+
return [];
|
|
174
|
+
if (!input.storage)
|
|
175
|
+
return input.executionIds.map(() => {
|
|
176
|
+
return;
|
|
177
|
+
});
|
|
178
|
+
return input.storage.summarizeExecutions({
|
|
179
|
+
projectId: input.projectId,
|
|
180
|
+
executionIds: input.executionIds
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
167
184
|
// src/runtime/ai-usage.ts
|
|
168
185
|
async function resolveExecutionUsage(input) {
|
|
169
186
|
if (input.executionIds.length === 0)
|
|
@@ -190,6 +207,9 @@ function createAgentRunId() {
|
|
|
190
207
|
function createAgentMessageId() {
|
|
191
208
|
return `agt_msg_${randomUUID()}`;
|
|
192
209
|
}
|
|
210
|
+
function agentContextCheckpointId(runId) {
|
|
211
|
+
return `agt_ctx_${runId}`;
|
|
212
|
+
}
|
|
193
213
|
function createAgentRunExecutionToken() {
|
|
194
214
|
return `agt_exec_${randomUUID()}`;
|
|
195
215
|
}
|
|
@@ -373,6 +393,11 @@ async function retryAgentRun(runtime, execution, security, agent, failedRun) {
|
|
|
373
393
|
if (!agents2) {
|
|
374
394
|
throw new AgentRequestError("storage_unavailable", "[Sixb] Agent storage is not configured.");
|
|
375
395
|
}
|
|
396
|
+
await agents2.messages.deleteByRunId({
|
|
397
|
+
projectId: runtime.projectId,
|
|
398
|
+
threadId: failedRun.threadId,
|
|
399
|
+
runId: failedRun.id
|
|
400
|
+
});
|
|
376
401
|
await tx.executions.create(durableExecution);
|
|
377
402
|
return agents2.runs.create({
|
|
378
403
|
id: runId,
|
|
@@ -586,7 +611,8 @@ async function attachRunView(runtime, run) {
|
|
|
586
611
|
return view;
|
|
587
612
|
}
|
|
588
613
|
async function attachRunViews(runtime, runs) {
|
|
589
|
-
const
|
|
614
|
+
const executionIds = runs.map((run) => run.executionId);
|
|
615
|
+
const [executions, usages, costs] = await Promise.all([
|
|
590
616
|
Promise.all(runs.map((run) => runtime.storage.executions.getById({
|
|
591
617
|
projectId: runtime.projectId,
|
|
592
618
|
id: run.executionId
|
|
@@ -594,7 +620,12 @@ async function attachRunViews(runtime, runs) {
|
|
|
594
620
|
resolveExecutionUsage({
|
|
595
621
|
storage: runtime.storage.aiUsage,
|
|
596
622
|
projectId: runtime.projectId,
|
|
597
|
-
executionIds
|
|
623
|
+
executionIds
|
|
624
|
+
}),
|
|
625
|
+
resolveExecutionCosts({
|
|
626
|
+
storage: runtime.storage.aiCosts,
|
|
627
|
+
projectId: runtime.projectId,
|
|
628
|
+
executionIds
|
|
598
629
|
})
|
|
599
630
|
]);
|
|
600
631
|
return runs.map((run, index) => {
|
|
@@ -603,10 +634,12 @@ async function attachRunViews(runtime, runs) {
|
|
|
603
634
|
throw new Error(`[Sixb] Agent run '${run.id}' references missing execution '${run.executionId}'.`);
|
|
604
635
|
}
|
|
605
636
|
const usage = usages[index];
|
|
637
|
+
const cost = usage === undefined ? undefined : costs[index];
|
|
606
638
|
return {
|
|
607
639
|
...run,
|
|
608
640
|
...execution.requestedBy === undefined ? {} : { requestedBy: structuredClone(execution.requestedBy) },
|
|
609
|
-
...usage === undefined ? {} : { usage }
|
|
641
|
+
...usage === undefined ? {} : { usage },
|
|
642
|
+
...cost === undefined ? {} : { cost }
|
|
610
643
|
};
|
|
611
644
|
});
|
|
612
645
|
}
|
|
@@ -774,6 +807,12 @@ function createObjectsRuntime(runtime, execution) {
|
|
|
774
807
|
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
775
808
|
authorization: runtime.authorization
|
|
776
809
|
}),
|
|
810
|
+
queryLinks: (input) => executeObjectQueryLinks({ projectId: runtime.projectId, ...input }, {
|
|
811
|
+
ontology: runtime.ontology,
|
|
812
|
+
storage: runtime.storage.objects,
|
|
813
|
+
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
814
|
+
authorization: runtime.authorization
|
|
815
|
+
}),
|
|
777
816
|
count: (input) => countObjects({ projectId: runtime.projectId, ...input }, {
|
|
778
817
|
ontology: runtime.ontology,
|
|
779
818
|
storage: runtime.storage.objects,
|
|
@@ -1070,6 +1109,55 @@ function escapeXml(value) {
|
|
|
1070
1109
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1071
1110
|
}
|
|
1072
1111
|
|
|
1112
|
+
// src/agents/tool-result.ts
|
|
1113
|
+
function isAgentToolResult(value) {
|
|
1114
|
+
return isPlainRecord(value) && value.kind === "agentToolResult" && getInvalidAgentToolResultReason(value) === undefined;
|
|
1115
|
+
}
|
|
1116
|
+
function getInvalidAgentToolResultReason(value) {
|
|
1117
|
+
if (!isPlainRecord(value) || value.kind !== "agentToolResult") {
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
if (!Array.isArray(value.content)) {
|
|
1121
|
+
return "result.content must be an array";
|
|
1122
|
+
}
|
|
1123
|
+
const unsupportedKey = Object.keys(value).find((key) => key !== "kind" && key !== "content");
|
|
1124
|
+
if (unsupportedKey) {
|
|
1125
|
+
return `result.${unsupportedKey} is not supported`;
|
|
1126
|
+
}
|
|
1127
|
+
if (value.content.length === 0) {
|
|
1128
|
+
return "result.content must contain at least one content part";
|
|
1129
|
+
}
|
|
1130
|
+
for (let index = 0;index < value.content.length; index += 1) {
|
|
1131
|
+
const part = value.content[index];
|
|
1132
|
+
const path = `result.content[${index}]`;
|
|
1133
|
+
if (!isPlainRecord(part)) {
|
|
1134
|
+
return `${path} must be a text or file content part`;
|
|
1135
|
+
}
|
|
1136
|
+
if (part.type === "text") {
|
|
1137
|
+
if (typeof part.text !== "string") {
|
|
1138
|
+
return `${path}.text must be a string`;
|
|
1139
|
+
}
|
|
1140
|
+
const unsupportedKey2 = Object.keys(part).find((key) => key !== "type" && key !== "text");
|
|
1141
|
+
if (unsupportedKey2) {
|
|
1142
|
+
return `${path}.${unsupportedKey2} is not supported`;
|
|
1143
|
+
}
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if (part.type === "file") {
|
|
1147
|
+
if (!isFileRef(part.fileRef)) {
|
|
1148
|
+
return `${path}.fileRef must be a valid FileRef`;
|
|
1149
|
+
}
|
|
1150
|
+
const unsupportedKey2 = Object.keys(part).find((key) => key !== "type" && key !== "fileRef");
|
|
1151
|
+
if (unsupportedKey2) {
|
|
1152
|
+
return `${path}.${unsupportedKey2} is not supported`;
|
|
1153
|
+
}
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
return `${path}.type must be 'text' or 'file'`;
|
|
1157
|
+
}
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1073
1161
|
// src/agents/adapters.ts
|
|
1074
1162
|
var TOOL_TYPE_PREFIX = "tool-";
|
|
1075
1163
|
function assertAdapter(condition, message) {
|
|
@@ -1340,12 +1428,12 @@ function appendAssistantModelMessages(result, message, options) {
|
|
|
1340
1428
|
} else if (part.type === "tool-call") {
|
|
1341
1429
|
content.push(toolCallModelPart(part));
|
|
1342
1430
|
if (part.providerExecuted === true) {
|
|
1343
|
-
content.push(toolResultModelPart(part, "json"));
|
|
1431
|
+
content.push(toolResultModelPart(message, part, partIndex, "json", options));
|
|
1344
1432
|
}
|
|
1345
1433
|
}
|
|
1346
1434
|
}
|
|
1347
1435
|
result.push({ role: "assistant", content });
|
|
1348
|
-
const toolResults = current.
|
|
1436
|
+
const toolResults = current.flatMap(({ part, partIndex }) => part.type === "tool-call" && part.providerExecuted !== true ? [toolResultModelPart(message, part, partIndex, "text", options)] : []);
|
|
1349
1437
|
if (toolResults.length > 0) {
|
|
1350
1438
|
result.push({ role: "tool", content: toolResults });
|
|
1351
1439
|
}
|
|
@@ -1369,27 +1457,50 @@ function toolCallModelPart(part) {
|
|
|
1369
1457
|
...part.providerMetadata === undefined ? {} : { providerOptions: part.providerMetadata }
|
|
1370
1458
|
};
|
|
1371
1459
|
}
|
|
1372
|
-
function toolResultModelPart(part, errorMode) {
|
|
1460
|
+
function toolResultModelPart(message, part, partIndex, errorMode, options) {
|
|
1373
1461
|
return {
|
|
1374
1462
|
type: "tool-result",
|
|
1375
1463
|
toolCallId: part.toolCallId,
|
|
1376
1464
|
toolName: part.toolName,
|
|
1377
|
-
output: toolResultOutput(part, errorMode),
|
|
1465
|
+
output: toolResultOutput(message, part, partIndex, errorMode, options),
|
|
1378
1466
|
...part.providerMetadata === undefined ? {} : { providerOptions: part.providerMetadata }
|
|
1379
1467
|
};
|
|
1380
1468
|
}
|
|
1381
|
-
function toolResultOutput(part, errorMode) {
|
|
1469
|
+
function toolResultOutput(message, part, partIndex, errorMode, options) {
|
|
1382
1470
|
if (part.state === "output-error") {
|
|
1383
1471
|
return errorMode === "json" ? { type: "error-json", value: part.errorText } : { type: "error-text", value: part.errorText };
|
|
1384
1472
|
}
|
|
1473
|
+
if (isAgentToolResult(part.output)) {
|
|
1474
|
+
const value = [];
|
|
1475
|
+
part.output.content.forEach((contentPart, contentIndex) => {
|
|
1476
|
+
if (contentPart.type === "text") {
|
|
1477
|
+
value.push(contentPart.text);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
const resolverInput = { message, part, partIndex, contentPart, contentIndex };
|
|
1481
|
+
const fileContext = options.toolResultFileText?.(resolverInput);
|
|
1482
|
+
if (fileContext) {
|
|
1483
|
+
value.push(fileContext);
|
|
1484
|
+
} else {
|
|
1485
|
+
value.push(toolResultFileFallbackText(contentPart));
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
return { type: "text", value: value.join(`
|
|
1489
|
+
`) };
|
|
1490
|
+
}
|
|
1385
1491
|
return typeof part.output === "string" ? { type: "text", value: part.output } : { type: "json", value: part.output };
|
|
1386
1492
|
}
|
|
1493
|
+
function toolResultFileFallbackText(part) {
|
|
1494
|
+
const attributes = [
|
|
1495
|
+
part.fileRef.fileName ? `name=${JSON.stringify(part.fileRef.fileName)}` : undefined,
|
|
1496
|
+
part.fileRef.mediaType ? `mediaType=${JSON.stringify(part.fileRef.mediaType)}` : undefined,
|
|
1497
|
+
`sizeBytes=${part.fileRef.sizeBytes}`
|
|
1498
|
+
].filter((value) => value !== undefined);
|
|
1499
|
+
return `[Tool-created file: ${attributes.join(" ")}. Contents are not available inline.]`;
|
|
1500
|
+
}
|
|
1387
1501
|
function isTextPart(part) {
|
|
1388
1502
|
return part.type === "text";
|
|
1389
1503
|
}
|
|
1390
|
-
function isToolCallPart(part) {
|
|
1391
|
-
return part.type === "tool-call";
|
|
1392
|
-
}
|
|
1393
1504
|
// src/agents/api-gateway.ts
|
|
1394
1505
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
1395
1506
|
var AGENT_API_GATEWAY_PREFIX = "/__sixb/agent-api";
|
|
@@ -1437,7 +1548,7 @@ var AGENT_TOOL_PRIMITIVE_SCHEMAS = new Set([
|
|
|
1437
1548
|
"uuid",
|
|
1438
1549
|
"fileRef"
|
|
1439
1550
|
]);
|
|
1440
|
-
var AGENT_RESERVED_TOOL_NAMES = ["bash", "read"];
|
|
1551
|
+
var AGENT_RESERVED_TOOL_NAMES = ["bash", "read", "view_file"];
|
|
1441
1552
|
function assertNonEmpty(value, field) {
|
|
1442
1553
|
if (!value.trim()) {
|
|
1443
1554
|
throw new AgentDefinitionError(`[Sixb] Agent ${field} must not be empty.`);
|
|
@@ -1514,13 +1625,33 @@ function validateAgentToolsAtStartup(agents) {
|
|
|
1514
1625
|
Object.freeze(agent);
|
|
1515
1626
|
}
|
|
1516
1627
|
}
|
|
1517
|
-
function
|
|
1518
|
-
|
|
1519
|
-
if (maxSteps === undefined) {
|
|
1628
|
+
function resolveAgentLoopConfig(loop) {
|
|
1629
|
+
if (loop === undefined)
|
|
1520
1630
|
return;
|
|
1631
|
+
const maxSteps = loop?.stopWhen?.maxSteps;
|
|
1632
|
+
if (maxSteps !== undefined && (!Number.isSafeInteger(maxSteps) || maxSteps <= 0)) {
|
|
1633
|
+
throw new AgentDefinitionError("[Sixb] Agent loop.stopWhen.maxSteps must be a positive safe integer.");
|
|
1634
|
+
}
|
|
1635
|
+
const context = loop.context ? snapshotAgentContextConfig(loop.context) : undefined;
|
|
1636
|
+
return Object.freeze({
|
|
1637
|
+
...loop.stopWhen === undefined ? {} : { stopWhen: Object.freeze({ ...maxSteps === undefined ? {} : { maxSteps } }) },
|
|
1638
|
+
...context === undefined ? {} : { context }
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
function snapshotAgentContextConfig(context) {
|
|
1642
|
+
const snapshot = {};
|
|
1643
|
+
for (const field of ["windowTokens", "reserveTokens", "keepRecentTokens"]) {
|
|
1644
|
+
const value = context[field];
|
|
1645
|
+
if (value === undefined)
|
|
1646
|
+
continue;
|
|
1647
|
+
assertPositiveSafeInteger(value, field);
|
|
1648
|
+
snapshot[field] = value;
|
|
1521
1649
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1650
|
+
return Object.freeze(snapshot);
|
|
1651
|
+
}
|
|
1652
|
+
function assertPositiveSafeInteger(value, field) {
|
|
1653
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
1654
|
+
throw new AgentDefinitionError(`[Sixb] Agent loop.context.${field} must be a positive safe integer.`);
|
|
1524
1655
|
}
|
|
1525
1656
|
}
|
|
1526
1657
|
function assertValidReasoningLevel(reasoning) {
|
|
@@ -1725,11 +1856,17 @@ function createAgentToolDefinition(definition) {
|
|
|
1725
1856
|
input,
|
|
1726
1857
|
handler: async (context) => {
|
|
1727
1858
|
const result = await definition.handler(context);
|
|
1859
|
+
let snapshot;
|
|
1728
1860
|
try {
|
|
1729
|
-
|
|
1861
|
+
snapshot = cloneJsonValue(result, "result");
|
|
1730
1862
|
} catch (cause) {
|
|
1731
1863
|
throw new AgentToolResultValidationError(definition.name, getInvalidJsonValueReason(result, "result") ?? "result could not be cloned safely", { cause });
|
|
1732
1864
|
}
|
|
1865
|
+
const richResultReason = getInvalidAgentToolResultReason(snapshot);
|
|
1866
|
+
if (richResultReason) {
|
|
1867
|
+
throw new AgentToolResultValidationError(definition.name, richResultReason);
|
|
1868
|
+
}
|
|
1869
|
+
return snapshot;
|
|
1733
1870
|
}
|
|
1734
1871
|
};
|
|
1735
1872
|
normalizedAgentTools.add(tool);
|
|
@@ -1789,7 +1926,7 @@ function defineAgent(id, config) {
|
|
|
1789
1926
|
}
|
|
1790
1927
|
assertValidReasoningLevel(config.reasoning);
|
|
1791
1928
|
assertValidProviderOptions(config.providerOptions);
|
|
1792
|
-
|
|
1929
|
+
const loop = resolveAgentLoopConfig(config.loop);
|
|
1793
1930
|
const groupIds = groupIdsFromDefinitions(id, config.groups);
|
|
1794
1931
|
const tools = toolsFromDefinitions(id, config.tools);
|
|
1795
1932
|
return Object.freeze({
|
|
@@ -1803,51 +1940,230 @@ function defineAgent(id, config) {
|
|
|
1803
1940
|
groupIds,
|
|
1804
1941
|
tools,
|
|
1805
1942
|
...config.description !== undefined ? { description: config.description } : {},
|
|
1806
|
-
...
|
|
1943
|
+
...loop !== undefined ? { loop } : {}
|
|
1807
1944
|
});
|
|
1808
1945
|
}
|
|
1809
|
-
// src/agents/
|
|
1810
|
-
var
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1946
|
+
// src/agents/context-compaction.ts
|
|
1947
|
+
var AGENT_CONTEXT_ESTIMATOR_VERSION = 1;
|
|
1948
|
+
var CHARS_PER_TOKEN = 4;
|
|
1949
|
+
var REQUEST_OVERHEAD_TOKENS = 8;
|
|
1950
|
+
var MESSAGE_OVERHEAD_TOKENS = 8;
|
|
1951
|
+
var TOOL_OVERHEAD_TOKENS = 16;
|
|
1952
|
+
var STEP_OVERHEAD_TOKENS = 2;
|
|
1953
|
+
var IMAGE_ALLOWANCE_TOKENS = 1200;
|
|
1954
|
+
var FILE_TEXT_INLINE_MAX_BYTES = 50 * 1024;
|
|
1955
|
+
var FILE_TEXT_INLINE_TOTAL_MAX_BYTES = 200 * 1024;
|
|
1956
|
+
var TOOL_RESULT_SUMMARY_MAX_CHARS = 2000;
|
|
1957
|
+
function shouldCompactAgentContext(input) {
|
|
1958
|
+
return input.estimatedInputTokens > input.inputBudgetTokens;
|
|
1959
|
+
}
|
|
1960
|
+
function estimateAgentContextRequestTokens(input) {
|
|
1961
|
+
const toolTokens = input.tools.reduce((total, tool) => total + TOOL_OVERHEAD_TOKENS + textTokens(tool.name) + textTokens(tool.description) + textTokens(tool.inputSchema), 0);
|
|
1962
|
+
return {
|
|
1963
|
+
tokens: REQUEST_OVERHEAD_TOKENS + textTokens(input.systemPrompt) + toolTokens + estimateAgentContextMessagesTokens(input.messages).tokens,
|
|
1964
|
+
estimatorVersion: AGENT_CONTEXT_ESTIMATOR_VERSION
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
function estimateAgentContextMessagesTokens(messages) {
|
|
1968
|
+
const attachments = { textBytesRemaining: FILE_TEXT_INLINE_TOTAL_MAX_BYTES };
|
|
1969
|
+
let tokens = 0;
|
|
1970
|
+
for (const message of messages) {
|
|
1971
|
+
tokens += estimateMessageTokens(message, attachments);
|
|
1972
|
+
}
|
|
1973
|
+
return { tokens, estimatorVersion: AGENT_CONTEXT_ESTIMATOR_VERSION };
|
|
1974
|
+
}
|
|
1975
|
+
function selectAgentContextCompactionBoundary(input) {
|
|
1976
|
+
if (input.messages.length < 2)
|
|
1977
|
+
return null;
|
|
1978
|
+
let retainedTokens = 0;
|
|
1979
|
+
let boundaryIndex = null;
|
|
1980
|
+
let closestDistance = Number.POSITIVE_INFINITY;
|
|
1981
|
+
for (let index = input.messages.length - 1;index > 0; index -= 1) {
|
|
1982
|
+
retainedTokens += estimateAgentContextMessagesTokens([input.messages[index]]).tokens;
|
|
1983
|
+
if (input.messages[index]?.role !== "user")
|
|
1984
|
+
continue;
|
|
1985
|
+
const distance = Math.abs(input.keepRecentTokens - retainedTokens);
|
|
1986
|
+
if (distance <= closestDistance) {
|
|
1987
|
+
boundaryIndex = index;
|
|
1988
|
+
closestDistance = distance;
|
|
1989
|
+
}
|
|
1990
|
+
if (retainedTokens >= input.keepRecentTokens)
|
|
1991
|
+
break;
|
|
1992
|
+
}
|
|
1993
|
+
if (boundaryIndex === null)
|
|
1994
|
+
return null;
|
|
1995
|
+
const summarizedThroughSeq = input.messages[boundaryIndex - 1]?.seq;
|
|
1996
|
+
if (summarizedThroughSeq === undefined)
|
|
1997
|
+
return null;
|
|
1998
|
+
return {
|
|
1999
|
+
messagesToSummarize: input.messages.slice(0, boundaryIndex),
|
|
2000
|
+
retainedMessages: input.messages.slice(boundaryIndex),
|
|
2001
|
+
summarizedThroughSeq
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
function serializeAgentMessagesForSummary(messages) {
|
|
2005
|
+
const lines = ["<sixb_conversation_history>"];
|
|
2006
|
+
for (const message of messages) {
|
|
2007
|
+
lines.push(` <message id="${escapeXml2(message.id)}" seq="${message.seq}" role="${message.role}">`);
|
|
2008
|
+
message.parts.forEach((part, partIndex) => {
|
|
2009
|
+
lines.push(...serializeSummaryPart(message, part, partIndex));
|
|
2010
|
+
});
|
|
2011
|
+
lines.push(" </message>");
|
|
2012
|
+
}
|
|
2013
|
+
lines.push("</sixb_conversation_history>");
|
|
2014
|
+
return lines.join(`
|
|
1835
2015
|
`);
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
2016
|
+
}
|
|
2017
|
+
function estimateMessageTokens(message, attachments) {
|
|
2018
|
+
let tokens = MESSAGE_OVERHEAD_TOKENS;
|
|
2019
|
+
for (const part of message.parts) {
|
|
2020
|
+
switch (part.type) {
|
|
2021
|
+
case "text":
|
|
2022
|
+
case "reasoning":
|
|
2023
|
+
tokens += textTokens(part.text);
|
|
2024
|
+
break;
|
|
2025
|
+
case "step-start":
|
|
2026
|
+
tokens += STEP_OVERHEAD_TOKENS;
|
|
2027
|
+
break;
|
|
2028
|
+
case "context":
|
|
2029
|
+
tokens += textTokens(stableJsonStringify(part.context));
|
|
2030
|
+
break;
|
|
2031
|
+
case "tool-call":
|
|
2032
|
+
tokens += TOOL_OVERHEAD_TOKENS + textTokens(part.toolName) + textTokens(stableJsonStringify(part.input)) + (part.state === "output-available" ? textTokens(stableJsonStringify(part.output)) : textTokens(part.errorText));
|
|
2033
|
+
break;
|
|
2034
|
+
case "file": {
|
|
2035
|
+
const file = part.fileRef;
|
|
2036
|
+
tokens += textTokens([file.blobId, file.digest, file.fileName, file.mediaType, file.logicalPath].filter((value) => value !== undefined).join(" "));
|
|
2037
|
+
if (message.role !== "assistant") {
|
|
2038
|
+
if (looksLikeImage(file.mediaType, file.fileName)) {
|
|
2039
|
+
tokens += IMAGE_ALLOWANCE_TOKENS;
|
|
2040
|
+
} else {
|
|
2041
|
+
const inlineBytes = Math.min(file.sizeBytes, FILE_TEXT_INLINE_MAX_BYTES, attachments.textBytesRemaining);
|
|
2042
|
+
attachments.textBytesRemaining -= inlineBytes;
|
|
2043
|
+
tokens += Math.ceil(inlineBytes / CHARS_PER_TOKEN);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
break;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return tokens;
|
|
2051
|
+
}
|
|
2052
|
+
function serializeSummaryPart(message, part, partIndex) {
|
|
2053
|
+
const indent = " ";
|
|
2054
|
+
switch (part.type) {
|
|
2055
|
+
case "text":
|
|
2056
|
+
return [`${indent}<text>${escapeXml2(part.text)}</text>`];
|
|
2057
|
+
case "reasoning":
|
|
2058
|
+
case "step-start":
|
|
2059
|
+
return [];
|
|
2060
|
+
case "context":
|
|
2061
|
+
return part.context.kind === "object" ? [
|
|
2062
|
+
`${indent}<object_context origin="${part.origin}" object_type_id="${escapeXml2(part.context.ref.objectTypeId)}" primary_id="${escapeXml2(part.context.ref.primaryId)}" />`
|
|
2063
|
+
] : [
|
|
2064
|
+
`${indent}<app_context origin="${part.origin}" id="${escapeXml2(part.context.id)}" label="${escapeXml2(part.context.label)}">`,
|
|
2065
|
+
`${indent} <description>${escapeXml2(part.context.description)}</description>`,
|
|
2066
|
+
`${indent} <value format="json">${escapeXml2(stableJsonStringify(part.context.value))}</value>`,
|
|
2067
|
+
`${indent}</app_context>`
|
|
2068
|
+
];
|
|
2069
|
+
case "file": {
|
|
2070
|
+
const file = part.fileRef;
|
|
2071
|
+
const attributes = [
|
|
2072
|
+
`message_id="${escapeXml2(message.id)}"`,
|
|
2073
|
+
`part_index="${partIndex}"`,
|
|
2074
|
+
`blob_id="${escapeXml2(file.blobId)}"`,
|
|
2075
|
+
`digest="${escapeXml2(file.digest)}"`,
|
|
2076
|
+
`size_bytes="${file.sizeBytes}"`,
|
|
2077
|
+
...file.fileName === undefined ? [] : [`file_name="${escapeXml2(file.fileName)}"`],
|
|
2078
|
+
...file.mediaType === undefined ? [] : [`media_type="${escapeXml2(file.mediaType)}"`],
|
|
2079
|
+
...file.logicalPath === undefined ? [] : [`logical_path="${escapeXml2(file.logicalPath)}"`]
|
|
2080
|
+
];
|
|
2081
|
+
return [`${indent}<file ${attributes.join(" ")} />`];
|
|
2082
|
+
}
|
|
2083
|
+
case "tool-call": {
|
|
2084
|
+
const output = part.state === "output-available" ? truncateToolResult(stableJsonStringify(part.output)) : truncateToolResult(part.errorText);
|
|
2085
|
+
return [
|
|
2086
|
+
`${indent}<tool_call id="${escapeXml2(part.toolCallId)}" name="${escapeXml2(part.toolName)}" state="${part.state}">`,
|
|
2087
|
+
`${indent} <input format="json">${escapeXml2(stableJsonStringify(part.input))}</input>`,
|
|
2088
|
+
`${indent} <result>${escapeXml2(output)}</result>`,
|
|
2089
|
+
`${indent}</tool_call>`
|
|
2090
|
+
];
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
function truncateToolResult(value) {
|
|
2095
|
+
if (value.length <= TOOL_RESULT_SUMMARY_MAX_CHARS)
|
|
2096
|
+
return value;
|
|
2097
|
+
return `${value.slice(0, TOOL_RESULT_SUMMARY_MAX_CHARS)}
|
|
2098
|
+
[truncated ${value.length - TOOL_RESULT_SUMMARY_MAX_CHARS} characters]`;
|
|
2099
|
+
}
|
|
2100
|
+
function looksLikeImage(mediaType, fileName) {
|
|
2101
|
+
if (mediaType?.toLowerCase().startsWith("image/"))
|
|
2102
|
+
return true;
|
|
2103
|
+
return /\.(?:avif|gif|jpe?g|png|webp)$/i.test(fileName ?? "");
|
|
2104
|
+
}
|
|
2105
|
+
function textTokens(value) {
|
|
2106
|
+
return Math.ceil(new TextEncoder().encode(value).byteLength / CHARS_PER_TOKEN);
|
|
2107
|
+
}
|
|
2108
|
+
function escapeXml2(value) {
|
|
2109
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
2110
|
+
}
|
|
2111
|
+
// src/agents/thread-context-projection.ts
|
|
2112
|
+
function projectAgentThreadModelContext(input) {
|
|
2113
|
+
const { checkpoint, messages } = input;
|
|
2114
|
+
if (!checkpoint)
|
|
2115
|
+
return messages;
|
|
2116
|
+
assertConsistentCheckpointProjection(checkpoint, messages);
|
|
2117
|
+
return [
|
|
2118
|
+
{
|
|
2119
|
+
role: "user",
|
|
2120
|
+
parts: [{ type: "text", text: serializeThreadSummary(checkpoint.summary) }]
|
|
2121
|
+
},
|
|
2122
|
+
...messages
|
|
1842
2123
|
];
|
|
1843
|
-
|
|
1844
|
-
|
|
2124
|
+
}
|
|
2125
|
+
function assertConsistentCheckpointProjection(checkpoint, messages) {
|
|
2126
|
+
if (checkpoint.summaryFormatVersion !== 1 || checkpoint.summary.trim().length === 0) {
|
|
2127
|
+
throw projectionError(checkpoint, "has an invalid summary");
|
|
2128
|
+
}
|
|
2129
|
+
if (checkpoint.summarizedThroughSeq >= checkpoint.observedHeadSeq) {
|
|
2130
|
+
throw projectionError(checkpoint, "does not retain its observed head");
|
|
2131
|
+
}
|
|
2132
|
+
if (messages.length === 0) {
|
|
2133
|
+
throw projectionError(checkpoint, "has no retained messages");
|
|
2134
|
+
}
|
|
2135
|
+
let expectedSeq = checkpoint.summarizedThroughSeq + 1;
|
|
2136
|
+
for (const message of messages) {
|
|
2137
|
+
if (message.projectId !== checkpoint.projectId || message.threadId !== checkpoint.threadId) {
|
|
2138
|
+
throw projectionError(checkpoint, "contains a message from another thread");
|
|
2139
|
+
}
|
|
2140
|
+
if (message.seq !== expectedSeq) {
|
|
2141
|
+
throw projectionError(checkpoint, `has a sequence gap before message '${message.id}'`);
|
|
2142
|
+
}
|
|
2143
|
+
expectedSeq += 1;
|
|
2144
|
+
}
|
|
2145
|
+
if (messages[0]?.role !== "user") {
|
|
2146
|
+
throw projectionError(checkpoint, "does not begin at a user turn boundary");
|
|
2147
|
+
}
|
|
2148
|
+
if ((messages.at(-1)?.seq ?? 0) < checkpoint.observedHeadSeq) {
|
|
2149
|
+
throw projectionError(checkpoint, "ends before the checkpoint's observed head");
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
function serializeThreadSummary(summary) {
|
|
2153
|
+
return [
|
|
2154
|
+
"The earlier conversation was compacted into this continuation summary.",
|
|
2155
|
+
"",
|
|
2156
|
+
"<sixb_thread_summary>",
|
|
2157
|
+
escapeXml3(summary),
|
|
2158
|
+
"</sixb_thread_summary>"
|
|
2159
|
+
].join(`
|
|
1845
2160
|
`);
|
|
1846
2161
|
}
|
|
1847
|
-
function
|
|
1848
|
-
return
|
|
1849
|
-
|
|
1850
|
-
|
|
2162
|
+
function projectionError(checkpoint, detail) {
|
|
2163
|
+
return new Error(`[Sixb] Agent context checkpoint '${checkpoint.id}' for thread '${checkpoint.threadId}' ${detail}.`);
|
|
2164
|
+
}
|
|
2165
|
+
function escapeXml3(value) {
|
|
2166
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
1851
2167
|
}
|
|
1852
2168
|
// src/workflows/validation.ts
|
|
1853
2169
|
function assertNonEmpty2(value, subject, field) {
|
|
@@ -2768,24 +3084,35 @@ async function attachWorkflowNodeViews(runtime, storage, nodes) {
|
|
|
2768
3084
|
const agentExecutions = executions.filter((execution) => execution !== null);
|
|
2769
3085
|
if (agentExecutions.length === 0)
|
|
2770
3086
|
return nodes;
|
|
2771
|
-
const
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
3087
|
+
const executionIds = agentExecutions.map((execution) => execution.executionId);
|
|
3088
|
+
const [usages, costs] = await Promise.all([
|
|
3089
|
+
resolveExecutionUsage({
|
|
3090
|
+
storage: runtime.storage.aiUsage,
|
|
3091
|
+
projectId: runtime.projectId,
|
|
3092
|
+
executionIds
|
|
3093
|
+
}),
|
|
3094
|
+
resolveExecutionCosts({
|
|
3095
|
+
storage: runtime.storage.aiCosts,
|
|
3096
|
+
projectId: runtime.projectId,
|
|
3097
|
+
executionIds
|
|
3098
|
+
})
|
|
3099
|
+
]);
|
|
3100
|
+
const accountingByExecutionId = new Map(agentExecutions.map((execution, index) => [
|
|
3101
|
+
execution.executionId,
|
|
3102
|
+
{ usage: usages[index], cost: costs[index] }
|
|
3103
|
+
]));
|
|
2777
3104
|
return nodes.map((node, index) => {
|
|
2778
3105
|
const execution = executions[index];
|
|
2779
3106
|
if (!execution)
|
|
2780
3107
|
return node;
|
|
2781
|
-
const
|
|
3108
|
+
const accounting = accountingByExecutionId.get(execution.executionId);
|
|
2782
3109
|
return {
|
|
2783
3110
|
...node,
|
|
2784
|
-
agentExecution: toWorkflowAgentNodeRunView(execution, usage)
|
|
3111
|
+
agentExecution: toWorkflowAgentNodeRunView(execution, accounting?.usage, accounting?.usage === undefined ? undefined : accounting.cost)
|
|
2785
3112
|
};
|
|
2786
3113
|
});
|
|
2787
3114
|
}
|
|
2788
|
-
function toWorkflowAgentNodeRunView(execution, usage) {
|
|
3115
|
+
function toWorkflowAgentNodeRunView(execution, usage, cost) {
|
|
2789
3116
|
return {
|
|
2790
3117
|
projectId: execution.projectId,
|
|
2791
3118
|
nodeRunId: execution.nodeRunId,
|
|
@@ -2802,7 +3129,8 @@ function toWorkflowAgentNodeRunView(execution, usage) {
|
|
|
2802
3129
|
createdAt: execution.createdAt,
|
|
2803
3130
|
startedAt: execution.startedAt,
|
|
2804
3131
|
completedAt: execution.completedAt,
|
|
2805
|
-
...usage === undefined ? {} : { usage }
|
|
3132
|
+
...usage === undefined ? {} : { usage },
|
|
3133
|
+
...usage === undefined || cost === undefined ? {} : { cost }
|
|
2806
3134
|
};
|
|
2807
3135
|
}
|
|
2808
3136
|
async function attachRequestedBy(runtime, run) {
|
|
@@ -2917,6 +3245,6 @@ function invalidAgentExecution(executionId, runId) {
|
|
|
2917
3245
|
throw new ExecutionStorageError("invalid_input", `[Sixb] Execution '${executionId}' does not authorize Agent run '${runId}'.`);
|
|
2918
3246
|
}
|
|
2919
3247
|
|
|
2920
|
-
export { serializeAgentContextForModel, omitUndefinedObjectProperties, fromAiSdk, toUiMessage, toModelMessages, AGENT_API_GATEWAY_PREFIX, AGENT_API_ROUTES, createAgentApiGatewayCapability, isValidAgentApiGatewayCapability, isAllowedAgentApiRequest, AGENT_REASONING_LEVELS, AGENT_RESERVED_TOOL_NAMES, isAgentDefinition, isAgentToolDefinition, validateAndNormalizeAgentToolInput, validateAgentToolsAtStartup, validateAgentGroupReferences, defineAgentTool, defineAgent, resolveAgentContextParts, agentRunQueueJobId, workflowAgentNodeQueueJobId, dispatchQueuedAgentRuns, createAgentThreadId, createAgentRunId, createAgentMessageId,
|
|
3248
|
+
export { serializeAgentContextForModel, isAgentToolResult, omitUndefinedObjectProperties, fromAiSdk, toUiMessage, toModelMessages, AGENT_API_GATEWAY_PREFIX, AGENT_API_ROUTES, createAgentApiGatewayCapability, isValidAgentApiGatewayCapability, isAllowedAgentApiRequest, AGENT_REASONING_LEVELS, AGENT_RESERVED_TOOL_NAMES, isAgentDefinition, isAgentToolDefinition, validateAndNormalizeAgentToolInput, validateAgentToolsAtStartup, validateAgentGroupReferences, defineAgentTool, defineAgent, AGENT_CONTEXT_ESTIMATOR_VERSION, shouldCompactAgentContext, estimateAgentContextRequestTokens, estimateAgentContextMessagesTokens, selectAgentContextCompactionBoundary, serializeAgentMessagesForSummary, resolveAgentContextParts, agentRunQueueJobId, workflowAgentNodeQueueJobId, dispatchQueuedAgentRuns, createAgentThreadId, createAgentRunId, createAgentMessageId, agentContextCheckpointId, createAgentRunExecutionToken, WorkflowDefinitionError, WorkflowValidationError, assertNonEmpty2 as assertNonEmpty, isStepDefinition, isAgentStepDefinition, isInterventionDefinition, isWorkflowDefinition, validateWorkflowDefinition, validateWorkflowsAtStartup, validateWorkflowInput, validateWorkflowStepInput, validateWorkflowStepOutput, validateWorkflowInterventionInput, validateWorkflowInterventionResponse, validateWorkflowInterventionDefaultResponse, validateWorkflowAgentStepInput, validateWorkflowAgentStepOutput, snapshotWorkflowAgentStepInput, snapshotWorkflowAgentStepOutput, snapshotWorkflowInput, snapshotWorkflowStepInput, snapshotWorkflowStepOutput, snapshotWorkflowInterventionInput, snapshotWorkflowInterventionResponse, snapshotWorkflowInterventionDefaultResponse, snapshotWorkflowActionInput, WorkflowRunDispatcher, requestWorkflowRun, createBoundSixb, isBoundSixb, createAgentExecutionRecord, bindDurableAgentExecution, restoreAgentExecutionScope, assertAgentExecutionRecord, requestAgentRun, retryAgentRun, projectAgentThreadModelContext };
|
|
2921
3249
|
|
|
2922
|
-
//# debugId=
|
|
3250
|
+
//# debugId=24F26D476A24059264756E2164756E21
|