@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
package/src/agents/streams.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SixbFailure } from "../errors/types"
|
|
|
4
4
|
import { isJsonValue, isPlainRecord, type JsonValue } from "../json"
|
|
5
5
|
import {
|
|
6
6
|
AGENT_RUN_FAILURE_CODES,
|
|
7
|
+
type AgentContextCheckpointReason,
|
|
7
8
|
type AgentRunFailureCode,
|
|
8
9
|
type AgentRunRecord,
|
|
9
10
|
} from "../storage/agents/types"
|
|
@@ -189,11 +190,35 @@ export async function subscribeAgentRunCancel(
|
|
|
189
190
|
/** Exact portable failure exposed by a terminal Agent run stream event. */
|
|
190
191
|
export type AgentRunFailure = SixbFailure<AgentRunFailureCode>
|
|
191
192
|
|
|
193
|
+
export const AGENT_COMPACTION_FAILURE_CODES = [
|
|
194
|
+
"context_limit_exceeded",
|
|
195
|
+
"summary_failed",
|
|
196
|
+
"checkpoint_failed",
|
|
197
|
+
] as const
|
|
198
|
+
export type AgentCompactionFailureCode = (typeof AGENT_COMPACTION_FAILURE_CODES)[number]
|
|
199
|
+
|
|
192
200
|
export type AgentRunStreamEvent =
|
|
193
201
|
| (AgentRunStreamEventBase & {
|
|
194
202
|
readonly type: "agent.run.started"
|
|
195
203
|
readonly modelId?: string
|
|
196
204
|
})
|
|
205
|
+
| (AgentRunStreamEventBase & {
|
|
206
|
+
readonly type: "agent.compaction.started"
|
|
207
|
+
readonly reason: AgentContextCheckpointReason
|
|
208
|
+
readonly estimatedInputTokensBefore: number
|
|
209
|
+
})
|
|
210
|
+
| (AgentRunStreamEventBase & {
|
|
211
|
+
readonly type: "agent.compaction.completed"
|
|
212
|
+
readonly reason: AgentContextCheckpointReason
|
|
213
|
+
readonly checkpointId: string
|
|
214
|
+
readonly estimatedInputTokensBefore: number
|
|
215
|
+
readonly estimatedInputTokensAfter: number
|
|
216
|
+
})
|
|
217
|
+
| (AgentRunStreamEventBase & {
|
|
218
|
+
readonly type: "agent.compaction.failed"
|
|
219
|
+
readonly reason: AgentContextCheckpointReason
|
|
220
|
+
readonly errorCode: AgentCompactionFailureCode
|
|
221
|
+
})
|
|
197
222
|
| (AgentRunStreamEventBase & {
|
|
198
223
|
readonly type: "agent.ui.chunk"
|
|
199
224
|
readonly chunkIndex: number
|
|
@@ -263,6 +288,23 @@ export function isAgentRunStreamEvent(value: unknown): value is AgentRunStreamEv
|
|
|
263
288
|
switch (value.type) {
|
|
264
289
|
case "agent.run.started":
|
|
265
290
|
return value.modelId === undefined || typeof value.modelId === "string"
|
|
291
|
+
case "agent.compaction.started":
|
|
292
|
+
return (
|
|
293
|
+
isAgentContextCheckpointReason(value.reason) &&
|
|
294
|
+
isTokenEstimate(value.estimatedInputTokensBefore)
|
|
295
|
+
)
|
|
296
|
+
case "agent.compaction.completed":
|
|
297
|
+
return (
|
|
298
|
+
isAgentContextCheckpointReason(value.reason) &&
|
|
299
|
+
typeof value.checkpointId === "string" &&
|
|
300
|
+
isTokenEstimate(value.estimatedInputTokensBefore) &&
|
|
301
|
+
isTokenEstimate(value.estimatedInputTokensAfter)
|
|
302
|
+
)
|
|
303
|
+
case "agent.compaction.failed":
|
|
304
|
+
return (
|
|
305
|
+
isAgentContextCheckpointReason(value.reason) &&
|
|
306
|
+
AGENT_COMPACTION_FAILURE_CODES.includes(value.errorCode as AgentCompactionFailureCode)
|
|
307
|
+
)
|
|
266
308
|
case "agent.ui.chunk":
|
|
267
309
|
return (
|
|
268
310
|
Number.isInteger(value.chunkIndex) &&
|
|
@@ -282,6 +324,14 @@ export function isAgentRunStreamEvent(value: unknown): value is AgentRunStreamEv
|
|
|
282
324
|
}
|
|
283
325
|
}
|
|
284
326
|
|
|
327
|
+
function isAgentContextCheckpointReason(value: unknown): value is AgentContextCheckpointReason {
|
|
328
|
+
return value === "threshold" || value === "overflow"
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function isTokenEstimate(value: unknown): value is number {
|
|
332
|
+
return Number.isSafeInteger(value) && (value as number) >= 0
|
|
333
|
+
}
|
|
334
|
+
|
|
285
335
|
function isTerminalAgentRunStatus(value: unknown): value is "succeeded" | "failed" | "cancelled" {
|
|
286
336
|
return value === "succeeded" || value === "failed" || value === "cancelled"
|
|
287
337
|
}
|
|
@@ -305,6 +355,12 @@ export function agentRunStreamIdempotencyKey(event: AgentRunStreamEvent): string
|
|
|
305
355
|
switch (event.type) {
|
|
306
356
|
case "agent.run.started":
|
|
307
357
|
return `${event.runId}:${event.attempt}:started`
|
|
358
|
+
case "agent.compaction.started":
|
|
359
|
+
return `${event.runId}:${event.attempt}:compaction:${event.reason}:started`
|
|
360
|
+
case "agent.compaction.completed":
|
|
361
|
+
return `${event.runId}:${event.attempt}:compaction:${event.checkpointId}:completed`
|
|
362
|
+
case "agent.compaction.failed":
|
|
363
|
+
return `${event.runId}:${event.attempt}:compaction:${event.reason}:failed:${event.errorCode}`
|
|
308
364
|
case "agent.ui.chunk":
|
|
309
365
|
return `${event.runId}:${event.attempt}:chunk:${event.chunkIndex}`
|
|
310
366
|
case "agent.message.finalized":
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AgentContextCheckpointRecord, AgentMessageRecord } from "../storage/agents/types"
|
|
2
|
+
import type { AgentMessage } from "./message"
|
|
3
|
+
|
|
4
|
+
/** A model-only message. Persisted tail messages carry `id`; the synthetic summary does not. */
|
|
5
|
+
export interface AgentThreadModelContextMessage extends AgentMessage {
|
|
6
|
+
readonly id?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ProjectAgentThreadModelContextInput {
|
|
10
|
+
readonly checkpoint: AgentContextCheckpointRecord | null
|
|
11
|
+
/** Complete retained tail, ordered by ascending per-thread sequence. */
|
|
12
|
+
readonly messages: readonly AgentMessageRecord[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Build the bounded, model-only view of a durable thread.
|
|
17
|
+
*
|
|
18
|
+
* The function is deliberately pure: storage chooses the latest checkpoint and reads its retained
|
|
19
|
+
* tail; this function validates that projection and prepends one synthetic user-role summary.
|
|
20
|
+
*/
|
|
21
|
+
export function projectAgentThreadModelContext(
|
|
22
|
+
input: ProjectAgentThreadModelContextInput
|
|
23
|
+
): readonly AgentThreadModelContextMessage[] {
|
|
24
|
+
const { checkpoint, messages } = input
|
|
25
|
+
if (!checkpoint) return messages
|
|
26
|
+
|
|
27
|
+
assertConsistentCheckpointProjection(checkpoint, messages)
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
role: "user",
|
|
31
|
+
parts: [{ type: "text", text: serializeThreadSummary(checkpoint.summary) }],
|
|
32
|
+
},
|
|
33
|
+
...messages,
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertConsistentCheckpointProjection(
|
|
38
|
+
checkpoint: AgentContextCheckpointRecord,
|
|
39
|
+
messages: readonly AgentMessageRecord[]
|
|
40
|
+
): void {
|
|
41
|
+
if (checkpoint.summaryFormatVersion !== 1 || checkpoint.summary.trim().length === 0) {
|
|
42
|
+
throw projectionError(checkpoint, "has an invalid summary")
|
|
43
|
+
}
|
|
44
|
+
if (checkpoint.summarizedThroughSeq >= checkpoint.observedHeadSeq) {
|
|
45
|
+
throw projectionError(checkpoint, "does not retain its observed head")
|
|
46
|
+
}
|
|
47
|
+
if (messages.length === 0) {
|
|
48
|
+
throw projectionError(checkpoint, "has no retained messages")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let expectedSeq = checkpoint.summarizedThroughSeq + 1
|
|
52
|
+
for (const message of messages) {
|
|
53
|
+
if (message.projectId !== checkpoint.projectId || message.threadId !== checkpoint.threadId) {
|
|
54
|
+
throw projectionError(checkpoint, "contains a message from another thread")
|
|
55
|
+
}
|
|
56
|
+
if (message.seq !== expectedSeq) {
|
|
57
|
+
throw projectionError(checkpoint, `has a sequence gap before message '${message.id}'`)
|
|
58
|
+
}
|
|
59
|
+
expectedSeq += 1
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (messages[0]?.role !== "user") {
|
|
63
|
+
throw projectionError(checkpoint, "does not begin at a user turn boundary")
|
|
64
|
+
}
|
|
65
|
+
if ((messages.at(-1)?.seq ?? 0) < checkpoint.observedHeadSeq) {
|
|
66
|
+
throw projectionError(checkpoint, "ends before the checkpoint's observed head")
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function serializeThreadSummary(summary: string): string {
|
|
71
|
+
return [
|
|
72
|
+
"The earlier conversation was compacted into this continuation summary.",
|
|
73
|
+
"",
|
|
74
|
+
"<sixb_thread_summary>",
|
|
75
|
+
escapeXml(summary),
|
|
76
|
+
"</sixb_thread_summary>",
|
|
77
|
+
].join("\n")
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function projectionError(checkpoint: AgentContextCheckpointRecord, detail: string): Error {
|
|
81
|
+
return new Error(
|
|
82
|
+
`[Sixb] Agent context checkpoint '${checkpoint.id}' for thread '${checkpoint.threadId}' ${detail}.`
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function escapeXml(value: string): string {
|
|
87
|
+
return value
|
|
88
|
+
.replaceAll("&", "&")
|
|
89
|
+
.replaceAll("<", "<")
|
|
90
|
+
.replaceAll(">", ">")
|
|
91
|
+
.replaceAll('"', """)
|
|
92
|
+
.replaceAll("'", "'")
|
|
93
|
+
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
cloneJsonValue,
|
|
3
|
+
getInvalidJsonValueReason,
|
|
4
|
+
type JsonValue,
|
|
5
|
+
type ReadonlyJsonValue,
|
|
6
|
+
} from "../json"
|
|
2
7
|
import { AgentDefinitionError, AgentToolResultValidationError } from "./errors"
|
|
8
|
+
import { getInvalidAgentToolResultReason } from "./tool-result"
|
|
3
9
|
import type {
|
|
4
10
|
AgentToolDefinition,
|
|
5
11
|
AgentToolHandler,
|
|
@@ -41,8 +47,12 @@ export function createAgentToolDefinition<
|
|
|
41
47
|
input,
|
|
42
48
|
handler: async (context) => {
|
|
43
49
|
const result = await definition.handler(context)
|
|
50
|
+
let snapshot: JsonValue
|
|
44
51
|
try {
|
|
45
|
-
|
|
52
|
+
// AgentToolResult is intentionally expressed with FileRef instead of a duplicate JSON-only
|
|
53
|
+
// shape. Runtime validation below proves that the complete envelope crosses the same JSON
|
|
54
|
+
// boundary as legacy results.
|
|
55
|
+
snapshot = cloneJsonValue(result as ReadonlyJsonValue, "result")
|
|
46
56
|
} catch (cause) {
|
|
47
57
|
throw new AgentToolResultValidationError(
|
|
48
58
|
definition.name,
|
|
@@ -50,6 +60,11 @@ export function createAgentToolDefinition<
|
|
|
50
60
|
{ cause }
|
|
51
61
|
)
|
|
52
62
|
}
|
|
63
|
+
const richResultReason = getInvalidAgentToolResultReason(snapshot)
|
|
64
|
+
if (richResultReason) {
|
|
65
|
+
throw new AgentToolResultValidationError(definition.name, richResultReason)
|
|
66
|
+
}
|
|
67
|
+
return snapshot
|
|
53
68
|
},
|
|
54
69
|
}
|
|
55
70
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isFileRef } from "../blob-storage/validation"
|
|
2
|
+
import { isPlainRecord } from "../json"
|
|
3
|
+
import type { AgentToolResult } from "./types"
|
|
4
|
+
|
|
5
|
+
/** Narrow a durable JSON tool output to Sixb's file-aware result envelope. */
|
|
6
|
+
export function isAgentToolResult(value: unknown): value is AgentToolResult {
|
|
7
|
+
return (
|
|
8
|
+
isPlainRecord(value) &&
|
|
9
|
+
value.kind === "agentToolResult" &&
|
|
10
|
+
getInvalidAgentToolResultReason(value) === undefined
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Return a precise path when a tagged result does not satisfy the public rich-result contract. */
|
|
15
|
+
export function getInvalidAgentToolResultReason(value: unknown): string | undefined {
|
|
16
|
+
if (!isPlainRecord(value) || value.kind !== "agentToolResult") {
|
|
17
|
+
return undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!Array.isArray(value.content)) {
|
|
21
|
+
return "result.content must be an array"
|
|
22
|
+
}
|
|
23
|
+
const unsupportedKey = Object.keys(value).find((key) => key !== "kind" && key !== "content")
|
|
24
|
+
if (unsupportedKey) {
|
|
25
|
+
return `result.${unsupportedKey} is not supported`
|
|
26
|
+
}
|
|
27
|
+
if (value.content.length === 0) {
|
|
28
|
+
return "result.content must contain at least one content part"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for (let index = 0; index < value.content.length; index += 1) {
|
|
32
|
+
const part = value.content[index]
|
|
33
|
+
const path = `result.content[${index}]`
|
|
34
|
+
if (!isPlainRecord(part)) {
|
|
35
|
+
return `${path} must be a text or file content part`
|
|
36
|
+
}
|
|
37
|
+
if (part.type === "text") {
|
|
38
|
+
if (typeof part.text !== "string") {
|
|
39
|
+
return `${path}.text must be a string`
|
|
40
|
+
}
|
|
41
|
+
const unsupportedKey = Object.keys(part).find((key) => key !== "type" && key !== "text")
|
|
42
|
+
if (unsupportedKey) {
|
|
43
|
+
return `${path}.${unsupportedKey} is not supported`
|
|
44
|
+
}
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
if (part.type === "file") {
|
|
48
|
+
if (!isFileRef(part.fileRef)) {
|
|
49
|
+
return `${path}.fileRef must be a valid FileRef`
|
|
50
|
+
}
|
|
51
|
+
const unsupportedKey = Object.keys(part).find((key) => key !== "type" && key !== "fileRef")
|
|
52
|
+
if (unsupportedKey) {
|
|
53
|
+
return `${path}.${unsupportedKey} is not supported`
|
|
54
|
+
}
|
|
55
|
+
continue
|
|
56
|
+
}
|
|
57
|
+
return `${path}.type must be 'text' or 'file'`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
package/src/agents/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LanguageModelV4, LanguageModelV4CallOptions } from "@ai-sdk/provider"
|
|
2
|
+
import type { BlobBody, FileRef } from "../blob-storage"
|
|
2
3
|
import type { ConnectorRuntime } from "../connectors"
|
|
3
4
|
import type { JsonPrimitive, JsonValue, ReadonlyJsonValue } from "../json"
|
|
4
5
|
import type { Logger } from "../logging"
|
|
@@ -25,6 +26,15 @@ export const AGENT_REASONING_LEVELS = [
|
|
|
25
26
|
"xhigh",
|
|
26
27
|
] as const satisfies readonly AgentReasoningLevel[]
|
|
27
28
|
|
|
29
|
+
export interface AgentContextConfig {
|
|
30
|
+
/** Override the provider context-window size inferred by the agent worker. */
|
|
31
|
+
readonly windowTokens?: number
|
|
32
|
+
/** Tokens reserved for the next response and compaction work. */
|
|
33
|
+
readonly reserveTokens?: number
|
|
34
|
+
/** Approximate recent-message budget retained verbatim after compaction. */
|
|
35
|
+
readonly keepRecentTokens?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* Loop / stop controls for an agent run.
|
|
30
40
|
*
|
|
@@ -34,6 +44,7 @@ export interface AgentLoopConfig {
|
|
|
34
44
|
readonly stopWhen?: {
|
|
35
45
|
readonly maxSteps?: number
|
|
36
46
|
}
|
|
47
|
+
readonly context?: AgentContextConfig
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
type Simplify<T> = { [K in keyof T]: T[K] } & {}
|
|
@@ -67,19 +78,64 @@ export interface AgentToolRunInfo {
|
|
|
67
78
|
readonly threadId?: string
|
|
68
79
|
}
|
|
69
80
|
|
|
81
|
+
/** Input accepted by the run-scoped artifact publisher exposed to agent tools. */
|
|
82
|
+
export interface AgentToolArtifactPutInput {
|
|
83
|
+
readonly body: BlobBody
|
|
84
|
+
readonly fileName: string
|
|
85
|
+
readonly mediaType?: string
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A durable artifact and its path inside the current run sandbox. */
|
|
89
|
+
export interface AgentToolArtifact {
|
|
90
|
+
readonly fileRef: FileRef
|
|
91
|
+
readonly sandboxPath: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The narrow artifact-writing surface available to an agent tool call. */
|
|
95
|
+
export interface AgentToolArtifacts {
|
|
96
|
+
put(input: AgentToolArtifactPutInput): Promise<AgentToolArtifact>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type AgentToolTextContent = {
|
|
100
|
+
readonly type: "text"
|
|
101
|
+
readonly text: string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type AgentToolFileContent = {
|
|
105
|
+
readonly type: "file"
|
|
106
|
+
readonly fileRef: FileRef
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Durable model-facing content returned by a file-aware tool. */
|
|
110
|
+
export type AgentToolContent = AgentToolTextContent | AgentToolFileContent
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A file-aware tool result. The tag distinguishes this envelope from an ordinary JSON result while
|
|
114
|
+
* keeping the whole value safe to persist in the durable tool-call trace.
|
|
115
|
+
*/
|
|
116
|
+
export type AgentToolResult = {
|
|
117
|
+
readonly kind: "agentToolResult"
|
|
118
|
+
readonly content: readonly AgentToolContent[]
|
|
119
|
+
}
|
|
120
|
+
|
|
70
121
|
/** The narrow, run-scoped surface passed to an agent tool handler. */
|
|
71
122
|
export interface AgentToolRunContext<
|
|
72
123
|
TInput extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>,
|
|
73
124
|
> {
|
|
74
125
|
readonly input: TInput
|
|
126
|
+
readonly toolCallId: string
|
|
75
127
|
readonly signal: AbortSignal
|
|
76
128
|
readonly run: AgentToolRunInfo
|
|
77
129
|
readonly connector: ConnectorRuntime
|
|
78
130
|
readonly logger: Logger
|
|
131
|
+
readonly artifacts: AgentToolArtifacts
|
|
79
132
|
}
|
|
80
133
|
|
|
81
134
|
/** Agent tool handlers may return only values safe to persist in agent messages. */
|
|
82
|
-
export type AgentToolHandlerResult =
|
|
135
|
+
export type AgentToolHandlerResult =
|
|
136
|
+
| ReadonlyJsonValue
|
|
137
|
+
| AgentToolResult
|
|
138
|
+
| Promise<ReadonlyJsonValue | AgentToolResult>
|
|
83
139
|
|
|
84
140
|
export type AgentToolHandler<TInput extends Readonly<Record<string, unknown>>> = (
|
|
85
141
|
context: AgentToolRunContext<TInput>
|
package/src/agents/validation.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { GroupDefinition, SecurityDefinitionCatalog } from "../security"
|
|
|
10
10
|
import { AgentDefinitionError } from "./errors"
|
|
11
11
|
import {
|
|
12
12
|
AGENT_REASONING_LEVELS,
|
|
13
|
+
type AgentContextConfig,
|
|
13
14
|
type AgentDefinition,
|
|
14
15
|
type AgentLoopConfig,
|
|
15
16
|
type AgentReasoningLevel,
|
|
@@ -31,7 +32,7 @@ const AGENT_TOOL_PRIMITIVE_SCHEMAS = new Set([
|
|
|
31
32
|
"fileRef",
|
|
32
33
|
])
|
|
33
34
|
|
|
34
|
-
export const AGENT_RESERVED_TOOL_NAMES = ["bash", "read"] as const
|
|
35
|
+
export const AGENT_RESERVED_TOOL_NAMES = ["bash", "read", "view_file"] as const
|
|
35
36
|
|
|
36
37
|
export function assertNonEmpty(value: string, field: string): void {
|
|
37
38
|
if (!value.trim()) {
|
|
@@ -159,14 +160,43 @@ export function validateAgentToolsAtStartup(agents: readonly AgentDefinition[]):
|
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
export function
|
|
163
|
+
export function resolveAgentLoopConfig(
|
|
164
|
+
loop: AgentLoopConfig | undefined
|
|
165
|
+
): AgentLoopConfig | undefined {
|
|
166
|
+
if (loop === undefined) return undefined
|
|
167
|
+
|
|
163
168
|
const maxSteps = loop?.stopWhen?.maxSteps
|
|
164
|
-
if (maxSteps
|
|
165
|
-
|
|
169
|
+
if (maxSteps !== undefined && (!Number.isSafeInteger(maxSteps) || maxSteps <= 0)) {
|
|
170
|
+
throw new AgentDefinitionError(
|
|
171
|
+
"[Sixb] Agent loop.stopWhen.maxSteps must be a positive safe integer."
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const context = loop.context ? snapshotAgentContextConfig(loop.context) : undefined
|
|
176
|
+
return Object.freeze({
|
|
177
|
+
...(loop.stopWhen === undefined
|
|
178
|
+
? {}
|
|
179
|
+
: { stopWhen: Object.freeze({ ...(maxSteps === undefined ? {} : { maxSteps }) }) }),
|
|
180
|
+
...(context === undefined ? {} : { context }),
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function snapshotAgentContextConfig(context: AgentContextConfig): AgentContextConfig {
|
|
185
|
+
const snapshot: Record<string, number> = {}
|
|
186
|
+
for (const field of ["windowTokens", "reserveTokens", "keepRecentTokens"] as const) {
|
|
187
|
+
const value = context[field]
|
|
188
|
+
if (value === undefined) continue
|
|
189
|
+
assertPositiveSafeInteger(value, field)
|
|
190
|
+
snapshot[field] = value
|
|
166
191
|
}
|
|
167
|
-
|
|
192
|
+
|
|
193
|
+
return Object.freeze(snapshot)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function assertPositiveSafeInteger(value: unknown, field: string): asserts value is number {
|
|
197
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
|
|
168
198
|
throw new AgentDefinitionError(
|
|
169
|
-
|
|
199
|
+
`[Sixb] Agent loop.context.${field} must be a positive safe integer.`
|
|
170
200
|
)
|
|
171
201
|
}
|
|
172
202
|
}
|
package/src/http/api-routes.ts
CHANGED
|
@@ -131,6 +131,13 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
|
|
|
131
131
|
accessToken: true,
|
|
132
132
|
agentApi: true,
|
|
133
133
|
},
|
|
134
|
+
{
|
|
135
|
+
operationId: "queryObjectLinks",
|
|
136
|
+
method: "POST",
|
|
137
|
+
path: "/api/objects/query/links",
|
|
138
|
+
accessToken: true,
|
|
139
|
+
agentApi: true,
|
|
140
|
+
},
|
|
134
141
|
{
|
|
135
142
|
operationId: "countObjects",
|
|
136
143
|
method: "POST",
|
|
@@ -159,13 +166,6 @@ export const SIXB_API_ROUTES: readonly SixbApiRoute[] = [
|
|
|
159
166
|
accessToken: true,
|
|
160
167
|
agentApi: true,
|
|
161
168
|
},
|
|
162
|
-
{
|
|
163
|
-
operationId: "listObjectLinks",
|
|
164
|
-
method: "GET",
|
|
165
|
-
path: "/api/objects/:objectTypeId/:objectId/links",
|
|
166
|
-
accessToken: true,
|
|
167
|
-
agentApi: true,
|
|
168
|
-
},
|
|
169
169
|
// The four write routes. Bearer-capable because their execution facade enforces authorization
|
|
170
170
|
// (`edit:object` / `append:telemetry`), which is exactly the precondition this table requires.
|
|
171
171
|
// NOT agent-proxied: letting an agent turn write objects on its own is a separate decision, and
|
package/src/index.ts
CHANGED
|
@@ -574,6 +574,7 @@ export type {
|
|
|
574
574
|
ObjectQueryPredicateIn,
|
|
575
575
|
ObjectQueryPredicateNot,
|
|
576
576
|
ObjectQueryProject,
|
|
577
|
+
ObjectQueryRefs,
|
|
577
578
|
ObjectQueryResultShape,
|
|
578
579
|
ObjectQuerySet,
|
|
579
580
|
ObjectQuerySetOperation,
|
|
@@ -854,6 +855,8 @@ export type {
|
|
|
854
855
|
export type {
|
|
855
856
|
ExecutionObjectByIdHandle,
|
|
856
857
|
ExecutionObjectSet,
|
|
858
|
+
ObjectQueryLinksInput,
|
|
859
|
+
ObjectQueryLinksResult,
|
|
857
860
|
ObjectsRuntime,
|
|
858
861
|
} from "./objects/execution"
|
|
859
862
|
export type { PipelineRunsRuntime, PipelinesRuntime } from "./pipelines/execution"
|
|
@@ -917,6 +920,7 @@ export type {
|
|
|
917
920
|
ActionRunFailureCode,
|
|
918
921
|
ActionRunPhase,
|
|
919
922
|
AgentRunFailureCode,
|
|
923
|
+
AiCostSummary,
|
|
920
924
|
PipelineRunFailureCode,
|
|
921
925
|
ProjectionRunFailureCode,
|
|
922
926
|
SyncRunFailureCode,
|
|
@@ -940,6 +944,7 @@ export type {
|
|
|
940
944
|
// ── Agents ──────────────────────────────────────────────────
|
|
941
945
|
|
|
942
946
|
export type {
|
|
947
|
+
AgentContextConfig,
|
|
943
948
|
AgentContextEntryInput,
|
|
944
949
|
AgentContextInput,
|
|
945
950
|
AgentContextOrigin,
|
|
@@ -968,17 +973,25 @@ export type {
|
|
|
968
973
|
AgentRequestErrorCode,
|
|
969
974
|
AgentStepStartPart,
|
|
970
975
|
AgentTextPart,
|
|
976
|
+
AgentToolArtifact,
|
|
977
|
+
AgentToolArtifactPutInput,
|
|
978
|
+
AgentToolArtifacts,
|
|
971
979
|
AgentToolCallPart,
|
|
972
980
|
AgentToolCallState,
|
|
981
|
+
AgentToolContent,
|
|
973
982
|
AgentToolDefinition,
|
|
974
983
|
AgentToolDescriptionBuilder,
|
|
984
|
+
AgentToolFileContent,
|
|
975
985
|
AgentToolHandler,
|
|
976
986
|
AgentToolHandlerResult,
|
|
977
987
|
AgentToolInputBuilder,
|
|
978
988
|
AgentToolInputSchema,
|
|
989
|
+
AgentToolResult,
|
|
990
|
+
AgentToolResultFileResolverInput,
|
|
979
991
|
AgentToolRunBuilder,
|
|
980
992
|
AgentToolRunContext,
|
|
981
993
|
AgentToolRunInfo,
|
|
994
|
+
AgentToolTextContent,
|
|
982
995
|
AgentUiMessage,
|
|
983
996
|
AgentUiMessagePart,
|
|
984
997
|
AgentUiToolPart,
|
|
@@ -1004,6 +1017,15 @@ export {
|
|
|
1004
1017
|
requestAgentRun,
|
|
1005
1018
|
} from "./agents"
|
|
1006
1019
|
|
|
1020
|
+
// ── Models ──────────────────────────────────────────────────
|
|
1021
|
+
|
|
1022
|
+
export type {
|
|
1023
|
+
LanguageModelCatalog,
|
|
1024
|
+
LanguageModelEntry,
|
|
1025
|
+
ModelCatalog,
|
|
1026
|
+
ModelCatalogInput,
|
|
1027
|
+
} from "./models"
|
|
1028
|
+
|
|
1007
1029
|
// ── Scheduling ──────────────────────────────────────────────
|
|
1008
1030
|
|
|
1009
1031
|
export { CronValidationError } from "./schedules"
|
|
@@ -1014,13 +1036,18 @@ export type {
|
|
|
1014
1036
|
ForeignKeyDescriptor,
|
|
1015
1037
|
LinkProjectionDefinition,
|
|
1016
1038
|
LinkProjectionTarget,
|
|
1039
|
+
ObjectProjectionBuilder,
|
|
1040
|
+
ObjectProjectionConflictResolution,
|
|
1017
1041
|
ObjectProjectionDefinition,
|
|
1018
1042
|
ObjectProjectionTarget,
|
|
1019
1043
|
ProjectionDefinition,
|
|
1020
1044
|
ProjectionDefinitionCatalog,
|
|
1045
|
+
ProjectionForeignKeyInput,
|
|
1021
1046
|
ProjectionTarget,
|
|
1022
1047
|
ProjectionTargetByKind,
|
|
1048
|
+
SourceEditConflictResolution,
|
|
1023
1049
|
TelemetryProjectionDefinition,
|
|
1050
|
+
TelemetryProjectionPropertyMapping,
|
|
1024
1051
|
} from "./projections"
|
|
1025
1052
|
|
|
1026
1053
|
export {
|
|
@@ -84,7 +84,8 @@ export interface DatasetWriteCommitResult extends DatasetVersion {
|
|
|
84
84
|
* report `unchanged` and reuse it for commits that cannot change visible
|
|
85
85
|
* dataset content: a snapshot whose rows equal the latest visible rows
|
|
86
86
|
* (order-insensitive, with equal duplicate counts), or an append of zero
|
|
87
|
-
* rows.
|
|
87
|
+
* rows. Without a latest version, an empty snapshot or append still creates
|
|
88
|
+
* the first addressable dataset version.
|
|
88
89
|
*/
|
|
89
90
|
readonly outcome: "created" | "unchanged"
|
|
90
91
|
}
|
|
@@ -152,6 +152,10 @@ export type ProjectionSourceAssertion =
|
|
|
152
152
|
readonly kind: "object"
|
|
153
153
|
readonly ref: OntologyObjectRef
|
|
154
154
|
readonly properties: Readonly<Record<string, JsonValue>>
|
|
155
|
+
/** Canonical source-system update time. Presence after validation pins `mostRecent`. */
|
|
156
|
+
readonly sourceUpdatedAt?: string
|
|
157
|
+
/** Projected properties represented by an absence candidate in this source row. */
|
|
158
|
+
readonly absentSourcePropertyIds?: readonly string[]
|
|
155
159
|
}
|
|
156
160
|
| {
|
|
157
161
|
readonly kind: "link"
|
|
@@ -25,6 +25,8 @@ interface ObjectEditInput {
|
|
|
25
25
|
readonly operation: ObjectEditOperation
|
|
26
26
|
readonly sourceProperties: Readonly<Record<string, JsonValue>> | null
|
|
27
27
|
readonly authority: ObjectOverride | null
|
|
28
|
+
readonly editedAt: Readonly<Record<string, string>>
|
|
29
|
+
readonly committedAt: string
|
|
28
30
|
readonly effectiveExists: boolean
|
|
29
31
|
readonly normalizedProperties?: Readonly<Record<string, JsonValue>>
|
|
30
32
|
readonly normalizedSet?: Readonly<Record<string, JsonValue>>
|
|
@@ -43,7 +45,11 @@ export interface AuthorityTransition<T> {
|
|
|
43
45
|
readonly changed: boolean
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
export
|
|
48
|
+
export interface ObjectAuthorityTransition extends AuthorityTransition<ObjectOverride> {
|
|
49
|
+
readonly editedAt: Readonly<Record<string, string>>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function applyObjectEdit(input: ObjectEditInput): ObjectAuthorityTransition {
|
|
47
53
|
const current = input.authority
|
|
48
54
|
let next: ObjectOverride | null
|
|
49
55
|
|
|
@@ -67,7 +73,54 @@ export function applyObjectEdit(input: ObjectEditInput): AuthorityTransition<Obj
|
|
|
67
73
|
throw new MaterializationValidationError("Expected an object edit operation.")
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
const editedAt = applyObjectEditTimes(input, next)
|
|
77
|
+
const authority = transition(current, next)
|
|
78
|
+
return {
|
|
79
|
+
...authority,
|
|
80
|
+
editedAt,
|
|
81
|
+
changed: authority.changed || !sameStringRecord(input.editedAt, editedAt),
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function applyObjectEditTimes(
|
|
86
|
+
input: ObjectEditInput,
|
|
87
|
+
next: ObjectOverride | null
|
|
88
|
+
): Readonly<Record<string, string>> {
|
|
89
|
+
if (!next || next.kind === "delete") return {}
|
|
90
|
+
const editedAt =
|
|
91
|
+
input.operation.kind === "object.create" || input.authority?.kind === "delete"
|
|
92
|
+
? {}
|
|
93
|
+
: { ...input.editedAt }
|
|
94
|
+
|
|
95
|
+
switch (input.operation.kind) {
|
|
96
|
+
case "object.create":
|
|
97
|
+
case "object.upsert": {
|
|
98
|
+
const properties = input.normalizedProperties ?? input.operation.properties
|
|
99
|
+
for (const propertyId of Object.keys(properties)) editedAt[propertyId] = input.committedAt
|
|
100
|
+
break
|
|
101
|
+
}
|
|
102
|
+
case "object.patch":
|
|
103
|
+
for (const propertyId of input.operation.reset) delete editedAt[propertyId]
|
|
104
|
+
for (const propertyId of input.operation.unset) editedAt[propertyId] = input.committedAt
|
|
105
|
+
for (const propertyId of Object.keys(input.normalizedSet ?? input.operation.set)) {
|
|
106
|
+
editedAt[propertyId] = input.committedAt
|
|
107
|
+
}
|
|
108
|
+
break
|
|
109
|
+
case "object.delete":
|
|
110
|
+
return editedAt
|
|
111
|
+
case "object.restore":
|
|
112
|
+
break
|
|
113
|
+
}
|
|
114
|
+
return editedAt
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function sameStringRecord(
|
|
118
|
+
left: Readonly<Record<string, string>>,
|
|
119
|
+
right: Readonly<Record<string, string>>
|
|
120
|
+
): boolean {
|
|
121
|
+
const leftKeys = Object.keys(left)
|
|
122
|
+
if (leftKeys.length !== Object.keys(right).length) return false
|
|
123
|
+
return leftKeys.every((key) => left[key] === right[key])
|
|
71
124
|
}
|
|
72
125
|
|
|
73
126
|
function applyObjectCreate(
|