@alvin0/ai-agent-sdk-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/dist/agent/accounting/common.js +2 -0
- package/dist/agent/accounting/common.js.map +1 -0
- package/dist/agent/accounting/config.js +2 -0
- package/dist/agent/accounting/config.js.map +1 -0
- package/dist/agent/accounting/contracts.d.ts +36 -0
- package/dist/agent/accounting/contracts.d.ts.map +1 -0
- package/dist/agent/accounting/delivery/accounting-data.js +2 -0
- package/dist/agent/accounting/delivery/accounting-data.js.map +1 -0
- package/dist/agent/accounting/delivery/config.js +2 -0
- package/dist/agent/accounting/delivery/config.js.map +1 -0
- package/dist/agent/accounting/delivery/data.js +2 -0
- package/dist/agent/accounting/delivery/data.js.map +1 -0
- package/dist/agent/accounting/delivery/support-errors.js +2 -0
- package/dist/agent/accounting/delivery/support-errors.js.map +1 -0
- package/dist/agent/accounting/delivery/terminal.js +2 -0
- package/dist/agent/accounting/delivery/terminal.js.map +1 -0
- package/dist/agent/accounting/delivery-types.d.ts +43 -0
- package/dist/agent/accounting/delivery-types.d.ts.map +1 -0
- package/dist/agent/accounting/error.d.ts +18 -0
- package/dist/agent/accounting/error.d.ts.map +1 -0
- package/dist/agent/accounting/error.js +2 -0
- package/dist/agent/accounting/error.js.map +1 -0
- package/dist/agent/accounting/estimate.js +2 -0
- package/dist/agent/accounting/estimate.js.map +1 -0
- package/dist/agent/accounting/event-buffer.js +2 -0
- package/dist/agent/accounting/event-buffer.js.map +1 -0
- package/dist/agent/accounting/ledger.js +2 -0
- package/dist/agent/accounting/ledger.js.map +1 -0
- package/dist/agent/accounting/report.d.ts +70 -0
- package/dist/agent/accounting/report.d.ts.map +1 -0
- package/dist/agent/accounting/usage.d.ts +13 -0
- package/dist/agent/accounting/usage.d.ts.map +1 -0
- package/dist/agent/accounting/usage.js +2 -0
- package/dist/agent/accounting/usage.js.map +1 -0
- package/dist/agent/context/section.d.ts +15 -0
- package/dist/agent/context/section.d.ts.map +1 -0
- package/dist/agent/context/section.js +2 -0
- package/dist/agent/context/section.js.map +1 -0
- package/dist/agent/context/types.d.ts +98 -0
- package/dist/agent/context/types.d.ts.map +1 -0
- package/dist/agent/define/definition.d.ts +110 -0
- package/dist/agent/define/definition.d.ts.map +1 -0
- package/dist/agent/define/definition.js +2 -0
- package/dist/agent/define/definition.js.map +1 -0
- package/dist/agent/define/instructions.js +2 -0
- package/dist/agent/define/instructions.js.map +1 -0
- package/dist/agent/define/output-format.js +2 -0
- package/dist/agent/define/output-format.js.map +1 -0
- package/dist/agent/define/session/accounting.js +2 -0
- package/dist/agent/define/session/accounting.js.map +1 -0
- package/dist/agent/define/session/common.js +2 -0
- package/dist/agent/define/session/common.js.map +1 -0
- package/dist/agent/define/session/config.js +2 -0
- package/dist/agent/define/session/config.js.map +1 -0
- package/dist/agent/define/session/model-config.js +2 -0
- package/dist/agent/define/session/model-config.js.map +1 -0
- package/dist/agent/define/session/observer.js +2 -0
- package/dist/agent/define/session/observer.js.map +1 -0
- package/dist/agent/define/session/run-seal.js +2 -0
- package/dist/agent/define/session/run-seal.js.map +1 -0
- package/dist/agent/define/session/runtime-binding.js +2 -0
- package/dist/agent/define/session/runtime-binding.js.map +1 -0
- package/dist/agent/define/session/runtime-compaction.js +2 -0
- package/dist/agent/define/session/runtime-compaction.js.map +1 -0
- package/dist/agent/define/session/runtime-memory.js +2 -0
- package/dist/agent/define/session/runtime-memory.js.map +1 -0
- package/dist/agent/define/session/skills.js +2 -0
- package/dist/agent/define/session/skills.js.map +1 -0
- package/dist/agent/define/session/trace-accounting.js +2 -0
- package/dist/agent/define/session/trace-accounting.js.map +1 -0
- package/dist/agent/define/session/types.d.ts +217 -0
- package/dist/agent/define/session/types.d.ts.map +1 -0
- package/dist/agent/define/session/validation.js +2 -0
- package/dist/agent/define/session/validation.js.map +1 -0
- package/dist/agent/define/session.d.ts +77 -0
- package/dist/agent/define/session.d.ts.map +1 -0
- package/dist/agent/define/session.js +2 -0
- package/dist/agent/define/session.js.map +1 -0
- package/dist/agent/history/config.js +2 -0
- package/dist/agent/history/config.js.map +1 -0
- package/dist/agent/history/history.d.ts +33 -0
- package/dist/agent/history/history.d.ts.map +1 -0
- package/dist/agent/history/history.js +2 -0
- package/dist/agent/history/history.js.map +1 -0
- package/dist/agent/history/normalize.d.ts +7 -0
- package/dist/agent/history/normalize.d.ts.map +1 -0
- package/dist/agent/history/normalize.js +2 -0
- package/dist/agent/history/normalize.js.map +1 -0
- package/dist/agent/history/project.d.ts +14 -0
- package/dist/agent/history/project.d.ts.map +1 -0
- package/dist/agent/history/project.js +2 -0
- package/dist/agent/history/project.js.map +1 -0
- package/dist/agent/history/types.d.ts +85 -0
- package/dist/agent/history/types.d.ts.map +1 -0
- package/dist/agent/history/validation.js +2 -0
- package/dist/agent/history/validation.js.map +1 -0
- package/dist/agent/loop/events.d.ts +213 -0
- package/dist/agent/loop/events.d.ts.map +1 -0
- package/dist/agent/loop/queue.js +2 -0
- package/dist/agent/loop/queue.js.map +1 -0
- package/dist/agent/loop/run-turn.d.ts +8 -0
- package/dist/agent/loop/run-turn.d.ts.map +1 -0
- package/dist/agent/loop/run-turn.js +2 -0
- package/dist/agent/loop/run-turn.js.map +1 -0
- package/dist/agent/loop/schedule.d.ts +62 -0
- package/dist/agent/loop/schedule.d.ts.map +1 -0
- package/dist/agent/loop/schedule.js +3 -0
- package/dist/agent/loop/schedule.js.map +1 -0
- package/dist/agent/loop/turn/cancellation.js +2 -0
- package/dist/agent/loop/turn/cancellation.js.map +1 -0
- package/dist/agent/loop/turn/common.js +2 -0
- package/dist/agent/loop/turn/common.js.map +1 -0
- package/dist/agent/loop/turn/config.js +2 -0
- package/dist/agent/loop/turn/config.js.map +1 -0
- package/dist/agent/loop/turn/content.js +4 -0
- package/dist/agent/loop/turn/content.js.map +1 -0
- package/dist/agent/loop/turn/hooks.js +2 -0
- package/dist/agent/loop/turn/hooks.js.map +1 -0
- package/dist/agent/loop/turn/model-round.js +2 -0
- package/dist/agent/loop/turn/model-round.js.map +1 -0
- package/dist/agent/loop/turn/repetition.js +2 -0
- package/dist/agent/loop/turn/repetition.js.map +1 -0
- package/dist/agent/loop/turn/types.d.ts +82 -0
- package/dist/agent/loop/turn/types.d.ts.map +1 -0
- package/dist/agent/loop/turn/usage-stop.js +2 -0
- package/dist/agent/loop/turn/usage-stop.js.map +1 -0
- package/dist/agent/loop/turn/validation.js +2 -0
- package/dist/agent/loop/turn/validation.js.map +1 -0
- package/dist/agent/loop/types.d.ts +82 -0
- package/dist/agent/loop/types.d.ts.map +1 -0
- package/dist/agent/memory/accounting-binding.js +2 -0
- package/dist/agent/memory/accounting-binding.js.map +1 -0
- package/dist/agent/memory/compaction-config.d.ts +63 -0
- package/dist/agent/memory/compaction-config.d.ts.map +1 -0
- package/dist/agent/memory/compaction-config.js +2 -0
- package/dist/agent/memory/compaction-config.js.map +1 -0
- package/dist/agent/memory/compaction.d.ts +62 -0
- package/dist/agent/memory/compaction.d.ts.map +1 -0
- package/dist/agent/memory/compaction.js +6 -0
- package/dist/agent/memory/compaction.js.map +1 -0
- package/dist/agent/memory/memory.d.ts +61 -0
- package/dist/agent/memory/memory.d.ts.map +1 -0
- package/dist/agent/memory/memory.js +5 -0
- package/dist/agent/memory/memory.js.map +1 -0
- package/dist/agent/memory/persistence-types.d.ts +44 -0
- package/dist/agent/memory/persistence-types.d.ts.map +1 -0
- package/dist/agent/memory/surface-compaction.d.ts +6 -0
- package/dist/agent/memory/surface-compaction.d.ts.map +1 -0
- package/dist/agent/memory/surface-compaction.js +4 -0
- package/dist/agent/memory/surface-compaction.js.map +1 -0
- package/dist/agent/memory/token-estimator.d.ts +12 -0
- package/dist/agent/memory/token-estimator.d.ts.map +1 -0
- package/dist/agent/memory/token-estimator.js +2 -0
- package/dist/agent/memory/token-estimator.js.map +1 -0
- package/dist/agent/mode/run-agent.d.ts +79 -0
- package/dist/agent/mode/run-agent.d.ts.map +1 -0
- package/dist/agent/mode/run-agent.js +4 -0
- package/dist/agent/mode/run-agent.js.map +1 -0
- package/dist/agent/mode/user-input.d.ts +61 -0
- package/dist/agent/mode/user-input.d.ts.map +1 -0
- package/dist/agent/mode/user-input.js +2 -0
- package/dist/agent/mode/user-input.js.map +1 -0
- package/dist/agent/skill/catalog.d.ts +53 -0
- package/dist/agent/skill/catalog.d.ts.map +1 -0
- package/dist/agent/skill/catalog.js +2 -0
- package/dist/agent/skill/catalog.js.map +1 -0
- package/dist/agent/skill/definition.d.ts +106 -0
- package/dist/agent/skill/definition.d.ts.map +1 -0
- package/dist/agent/skill/definition.js +2 -0
- package/dist/agent/skill/definition.js.map +1 -0
- package/dist/agent/skill/provider/config.d.ts +11 -0
- package/dist/agent/skill/provider/config.d.ts.map +1 -0
- package/dist/agent/skill/provider/config.js +2 -0
- package/dist/agent/skill/provider/config.js.map +1 -0
- package/dist/agent/skill/provider/context.js +2 -0
- package/dist/agent/skill/provider/context.js.map +1 -0
- package/dist/agent/skill/provider/definition.d.ts +6 -0
- package/dist/agent/skill/provider/definition.d.ts.map +1 -0
- package/dist/agent/skill/provider/definition.js +2 -0
- package/dist/agent/skill/provider/definition.js.map +1 -0
- package/dist/agent/skill/provider/snapshot.js +2 -0
- package/dist/agent/skill/provider/snapshot.js.map +1 -0
- package/dist/agent/skill/provider/types.d.ts +49 -0
- package/dist/agent/skill/provider/types.d.ts.map +1 -0
- package/dist/agent/skill/tools.d.ts +45 -0
- package/dist/agent/skill/tools.d.ts.map +1 -0
- package/dist/agent/skill/tools.js +14 -0
- package/dist/agent/skill/tools.js.map +1 -0
- package/dist/agent/team/common.d.ts +26 -0
- package/dist/agent/team/common.d.ts.map +1 -0
- package/dist/agent/team/common.js +2 -0
- package/dist/agent/team/common.js.map +1 -0
- package/dist/agent/team/composed.d.ts +45 -0
- package/dist/agent/team/composed.d.ts.map +1 -0
- package/dist/agent/team/composed.js +2 -0
- package/dist/agent/team/composed.js.map +1 -0
- package/dist/agent/team/contracts.d.ts +54 -0
- package/dist/agent/team/contracts.d.ts.map +1 -0
- package/dist/agent/team/managed.d.ts +527 -0
- package/dist/agent/team/managed.d.ts.map +1 -0
- package/dist/agent/team/managed.js +4 -0
- package/dist/agent/team/managed.js.map +1 -0
- package/dist/agent/team/team.d.ts +142 -0
- package/dist/agent/team/team.d.ts.map +1 -0
- package/dist/agent/team/team.js +2 -0
- package/dist/agent/team/team.js.map +1 -0
- package/dist/agent/team/types.d.ts +170 -0
- package/dist/agent/team/types.d.ts.map +1 -0
- package/dist/agent/tool/approval.d.ts +106 -0
- package/dist/agent/tool/approval.d.ts.map +1 -0
- package/dist/agent/tool/approval.js +2 -0
- package/dist/agent/tool/approval.js.map +1 -0
- package/dist/agent/tool/capture.js +2 -0
- package/dist/agent/tool/capture.js.map +1 -0
- package/dist/agent/tool/config.js +2 -0
- package/dist/agent/tool/config.js.map +1 -0
- package/dist/agent/tool/definition.d.ts +227 -0
- package/dist/agent/tool/definition.d.ts.map +1 -0
- package/dist/agent/tool/definition.js +2 -0
- package/dist/agent/tool/definition.js.map +1 -0
- package/dist/agent/tool/errors.d.ts +82 -0
- package/dist/agent/tool/errors.d.ts.map +1 -0
- package/dist/agent/tool/errors.js +2 -0
- package/dist/agent/tool/errors.js.map +1 -0
- package/dist/agent/tool/execution.d.ts +60 -0
- package/dist/agent/tool/execution.d.ts.map +1 -0
- package/dist/agent/tool/execution.js +2 -0
- package/dist/agent/tool/execution.js.map +1 -0
- package/dist/agent/tool/output-budget.d.ts +159 -0
- package/dist/agent/tool/output-budget.d.ts.map +1 -0
- package/dist/agent/tool/output-budget.js +3 -0
- package/dist/agent/tool/output-budget.js.map +1 -0
- package/dist/agent/tool/pipeline.d.ts +98 -0
- package/dist/agent/tool/pipeline.d.ts.map +1 -0
- package/dist/agent/tool/pipeline.js +4 -0
- package/dist/agent/tool/pipeline.js.map +1 -0
- package/dist/agent/tool/registry.d.ts +70 -0
- package/dist/agent/tool/registry.d.ts.map +1 -0
- package/dist/agent/tool/registry.js +2 -0
- package/dist/agent/tool/registry.js.map +1 -0
- package/dist/agent/tool/schema.d.ts +12 -0
- package/dist/agent/tool/schema.d.ts.map +1 -0
- package/dist/agent/tool/schema.js +2 -0
- package/dist/agent/tool/schema.js.map +1 -0
- package/dist/agent/tool/source-types.d.ts +25 -0
- package/dist/agent/tool/source-types.d.ts.map +1 -0
- package/dist/agent/trace/trace.d.ts +63 -0
- package/dist/agent/trace/trace.d.ts.map +1 -0
- package/dist/agent/trace/trace.js +2 -0
- package/dist/agent/trace/trace.js.map +1 -0
- package/dist/agent.d.ts +52 -0
- package/dist/agent.js +1 -0
- package/dist/async/settlement.d.ts +6 -0
- package/dist/async/settlement.d.ts.map +1 -0
- package/dist/async/settlement.js +2 -0
- package/dist/async/settlement.js.map +1 -0
- package/dist/capability/common/config.js +2 -0
- package/dist/capability/common/config.js.map +1 -0
- package/dist/capability/common/data.js +2 -0
- package/dist/capability/common/data.js.map +1 -0
- package/dist/composition/agent/author.d.ts +12 -0
- package/dist/composition/agent/author.d.ts.map +1 -0
- package/dist/composition/agent/author.js +2 -0
- package/dist/composition/agent/author.js.map +1 -0
- package/dist/composition/agent/definition.js +2 -0
- package/dist/composition/agent/definition.js.map +1 -0
- package/dist/composition/agent/native-event.js +2 -0
- package/dist/composition/agent/native-event.js.map +1 -0
- package/dist/composition/agent/native-tools.js +2 -0
- package/dist/composition/agent/native-tools.js.map +1 -0
- package/dist/composition/agent/options.js +2 -0
- package/dist/composition/agent/options.js.map +1 -0
- package/dist/composition/agent/policy.js +2 -0
- package/dist/composition/agent/policy.js.map +1 -0
- package/dist/composition/agent/public-message.js +2 -0
- package/dist/composition/agent/public-message.js.map +1 -0
- package/dist/composition/agent/session.js +2 -0
- package/dist/composition/agent/session.js.map +1 -0
- package/dist/composition/agent/types.d.ts +218 -0
- package/dist/composition/agent/types.d.ts.map +1 -0
- package/dist/composition/common/counter.js +2 -0
- package/dist/composition/common/counter.js.map +1 -0
- package/dist/composition/common/errors.d.ts +15 -0
- package/dist/composition/common/errors.d.ts.map +1 -0
- package/dist/composition/common/errors.js +2 -0
- package/dist/composition/common/errors.js.map +1 -0
- package/dist/composition/common/json-data.js +2 -0
- package/dist/composition/common/json-data.js.map +1 -0
- package/dist/composition/credential/config.d.ts +5 -0
- package/dist/composition/credential/config.d.ts.map +1 -0
- package/dist/composition/credential/config.js +2 -0
- package/dist/composition/credential/config.js.map +1 -0
- package/dist/composition/credential/definition.d.ts +9 -0
- package/dist/composition/credential/definition.d.ts.map +1 -0
- package/dist/composition/credential/definition.js +2 -0
- package/dist/composition/credential/definition.js.map +1 -0
- package/dist/composition/credential/types.d.ts +38 -0
- package/dist/composition/credential/types.d.ts.map +1 -0
- package/dist/composition/delivery/ack.js +2 -0
- package/dist/composition/delivery/ack.js.map +1 -0
- package/dist/composition/delivery/attempt.js +2 -0
- package/dist/composition/delivery/attempt.js.map +1 -0
- package/dist/composition/delivery/batch.js +2 -0
- package/dist/composition/delivery/batch.js.map +1 -0
- package/dist/composition/delivery/checkpoint.js +2 -0
- package/dist/composition/delivery/checkpoint.js.map +1 -0
- package/dist/composition/delivery/event.js +2 -0
- package/dist/composition/delivery/event.js.map +1 -0
- package/dist/composition/delivery/resource.d.ts +11 -0
- package/dist/composition/delivery/resource.d.ts.map +1 -0
- package/dist/composition/delivery/resource.js +2 -0
- package/dist/composition/delivery/resource.js.map +1 -0
- package/dist/composition/delivery/staging.js +2 -0
- package/dist/composition/delivery/staging.js.map +1 -0
- package/dist/composition/diagnostics/config.js +2 -0
- package/dist/composition/diagnostics/config.js.map +1 -0
- package/dist/composition/diagnostics/ring.d.ts +12 -0
- package/dist/composition/diagnostics/ring.d.ts.map +1 -0
- package/dist/composition/diagnostics/ring.js +2 -0
- package/dist/composition/diagnostics/ring.js.map +1 -0
- package/dist/composition/exporter/definition.d.ts +7 -0
- package/dist/composition/exporter/definition.d.ts.map +1 -0
- package/dist/composition/exporter/definition.js +2 -0
- package/dist/composition/exporter/definition.js.map +1 -0
- package/dist/composition/exporter/lifecycle.js +2 -0
- package/dist/composition/exporter/lifecycle.js.map +1 -0
- package/dist/composition/exporter/preflight.js +2 -0
- package/dist/composition/exporter/preflight.js.map +1 -0
- package/dist/composition/exporter/types.d.ts +25 -0
- package/dist/composition/exporter/types.d.ts.map +1 -0
- package/dist/composition/exporter/types.js +2 -0
- package/dist/composition/exporter/types.js.map +1 -0
- package/dist/composition/identity/agent.js +2 -0
- package/dist/composition/identity/agent.js.map +1 -0
- package/dist/composition/lifecycle/bounded.js +2 -0
- package/dist/composition/lifecycle/bounded.js.map +1 -0
- package/dist/composition/lifecycle/operations.js +2 -0
- package/dist/composition/lifecycle/operations.js.map +1 -0
- package/dist/composition/lifecycle/types.d.ts +13 -0
- package/dist/composition/lifecycle/types.d.ts.map +1 -0
- package/dist/composition/lifecycle/types.js +2 -0
- package/dist/composition/lifecycle/types.js.map +1 -0
- package/dist/composition/logging/config.js +2 -0
- package/dist/composition/logging/config.js.map +1 -0
- package/dist/composition/logging/integration.js +2 -0
- package/dist/composition/logging/integration.js.map +1 -0
- package/dist/composition/logging/logger.d.ts +9 -0
- package/dist/composition/logging/logger.d.ts.map +1 -0
- package/dist/composition/logging/logger.js +2 -0
- package/dist/composition/logging/logger.js.map +1 -0
- package/dist/composition/memory/config.d.ts +10 -0
- package/dist/composition/memory/config.d.ts.map +1 -0
- package/dist/composition/memory/config.js +2 -0
- package/dist/composition/memory/config.js.map +1 -0
- package/dist/composition/memory/definition.d.ts +7 -0
- package/dist/composition/memory/definition.d.ts.map +1 -0
- package/dist/composition/memory/definition.js +2 -0
- package/dist/composition/memory/definition.js.map +1 -0
- package/dist/composition/memory/key.js +2 -0
- package/dist/composition/memory/key.js.map +1 -0
- package/dist/composition/memory/resume.js +2 -0
- package/dist/composition/memory/resume.js.map +1 -0
- package/dist/composition/memory/run.js +2 -0
- package/dist/composition/memory/run.js.map +1 -0
- package/dist/composition/model-catalog/config.js +2 -0
- package/dist/composition/model-catalog/config.js.map +1 -0
- package/dist/composition/model-catalog/manager.js +2 -0
- package/dist/composition/model-catalog/manager.js.map +1 -0
- package/dist/composition/model-catalog/options.js +2 -0
- package/dist/composition/model-catalog/options.js.map +1 -0
- package/dist/composition/model-catalog/types.d.ts +9 -0
- package/dist/composition/model-catalog/types.d.ts.map +1 -0
- package/dist/composition/observation/config.js +2 -0
- package/dist/composition/observation/config.js.map +1 -0
- package/dist/composition/observation/extensions.js +2 -0
- package/dist/composition/observation/extensions.js.map +1 -0
- package/dist/composition/observation/final-report.d.ts +6 -0
- package/dist/composition/observation/final-report.d.ts.map +1 -0
- package/dist/composition/observation/final-report.js +2 -0
- package/dist/composition/observation/final-report.js.map +1 -0
- package/dist/composition/observation/health.d.ts +13 -0
- package/dist/composition/observation/health.d.ts.map +1 -0
- package/dist/composition/observation/port.d.ts +11 -0
- package/dist/composition/observation/port.d.ts.map +1 -0
- package/dist/composition/observation/port.js +2 -0
- package/dist/composition/observation/port.js.map +1 -0
- package/dist/composition/preflight.js +2 -0
- package/dist/composition/preflight.js.map +1 -0
- package/dist/composition/provider/activation.js +2 -0
- package/dist/composition/provider/activation.js.map +1 -0
- package/dist/composition/provider/definition.d.ts +7 -0
- package/dist/composition/provider/definition.d.ts.map +1 -0
- package/dist/composition/provider/definition.js +2 -0
- package/dist/composition/provider/definition.js.map +1 -0
- package/dist/composition/provider/model-selection.js +2 -0
- package/dist/composition/provider/model-selection.js.map +1 -0
- package/dist/composition/provider/preflight.js +2 -0
- package/dist/composition/provider/preflight.js.map +1 -0
- package/dist/composition/provider/types.d.ts +38 -0
- package/dist/composition/provider/types.d.ts.map +1 -0
- package/dist/composition/provider/types.js +2 -0
- package/dist/composition/provider/types.js.map +1 -0
- package/dist/composition/queue/config.js +2 -0
- package/dist/composition/queue/config.js.map +1 -0
- package/dist/composition/queue/scheduler.js +2 -0
- package/dist/composition/queue/scheduler.js.map +1 -0
- package/dist/composition/queue/store.js +2 -0
- package/dist/composition/queue/store.js.map +1 -0
- package/dist/composition/runtime/config.js +2 -0
- package/dist/composition/runtime/config.js.map +1 -0
- package/dist/composition/runtime/owner.js +2 -0
- package/dist/composition/runtime/owner.js.map +1 -0
- package/dist/composition/runtime/public.d.ts +7 -0
- package/dist/composition/runtime/public.d.ts.map +1 -0
- package/dist/composition/runtime/public.js +2 -0
- package/dist/composition/runtime/public.js.map +1 -0
- package/dist/composition/runtime/types.d.ts +76 -0
- package/dist/composition/runtime/types.d.ts.map +1 -0
- package/dist/composition/startup.js +2 -0
- package/dist/composition/startup.js.map +1 -0
- package/dist/composition/team/config.js +2 -0
- package/dist/composition/team/config.js.map +1 -0
- package/dist/composition/team/options.js +2 -0
- package/dist/composition/team/options.js.map +1 -0
- package/dist/composition/team/runtime.js +2 -0
- package/dist/composition/team/runtime.js.map +1 -0
- package/dist/composition/team/types.d.ts +63 -0
- package/dist/composition/team/types.d.ts.map +1 -0
- package/dist/composition/tool-source/config.d.ts +5 -0
- package/dist/composition/tool-source/config.d.ts.map +1 -0
- package/dist/composition/tool-source/config.js +2 -0
- package/dist/composition/tool-source/config.js.map +1 -0
- package/dist/composition/tool-source/definition.d.ts +7 -0
- package/dist/composition/tool-source/definition.d.ts.map +1 -0
- package/dist/composition/tool-source/definition.js +2 -0
- package/dist/composition/tool-source/definition.js.map +1 -0
- package/dist/composition/tool-source/snapshot.js +2 -0
- package/dist/composition/tool-source/snapshot.js.map +1 -0
- package/dist/contract/adapter.d.ts +91 -0
- package/dist/contract/adapter.d.ts.map +1 -0
- package/dist/contract/adapter.js +2 -0
- package/dist/contract/adapter.js.map +1 -0
- package/dist/contract/call-config.d.ts +36 -0
- package/dist/contract/call-config.d.ts.map +1 -0
- package/dist/contract/call-config.js +2 -0
- package/dist/contract/call-config.js.map +1 -0
- package/dist/contract/generate-options.d.ts +41 -0
- package/dist/contract/generate-options.d.ts.map +1 -0
- package/dist/contract/model-info.d.ts +99 -0
- package/dist/contract/model-info.d.ts.map +1 -0
- package/dist/contract/output-format.d.ts +18 -0
- package/dist/contract/output-format.d.ts.map +1 -0
- package/dist/contract/retry-policy.d.ts +104 -0
- package/dist/contract/retry-policy.d.ts.map +1 -0
- package/dist/contract/retry-policy.js +2 -0
- package/dist/contract/retry-policy.js.map +1 -0
- package/dist/contract/tool.d.ts +65 -0
- package/dist/contract/tool.d.ts.map +1 -0
- package/dist/contract/tool.js +2 -0
- package/dist/contract/tool.js.map +1 -0
- package/dist/errors/agent-sdk-error.d.ts +88 -0
- package/dist/errors/agent-sdk-error.d.ts.map +1 -0
- package/dist/errors/agent-sdk-error.js +2 -0
- package/dist/errors/agent-sdk-error.js.map +1 -0
- package/dist/errors/capability-identity.d.ts +10 -0
- package/dist/errors/capability-identity.d.ts.map +1 -0
- package/dist/errors/capability-identity.js +2 -0
- package/dist/errors/capability-identity.js.map +1 -0
- package/dist/errors/failure.d.ts +33 -0
- package/dist/errors/failure.d.ts.map +1 -0
- package/dist/errors/failure.js +2 -0
- package/dist/errors/failure.js.map +1 -0
- package/dist/errors/model-error.d.ts +83 -0
- package/dist/errors/model-error.d.ts.map +1 -0
- package/dist/errors/model-error.js +2 -0
- package/dist/errors/model-error.js.map +1 -0
- package/dist/http/api-key.d.ts +47 -0
- package/dist/http/api-key.d.ts.map +1 -0
- package/dist/http/api-key.js +2 -0
- package/dist/http/api-key.js.map +1 -0
- package/dist/http/attribution.d.ts +51 -0
- package/dist/http/attribution.d.ts.map +1 -0
- package/dist/http/attribution.js +2 -0
- package/dist/http/attribution.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +1 -0
- package/dist/logging/types.d.ts +53 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +2 -0
- package/dist/logging/types.js.map +1 -0
- package/dist/memory.d.ts +10 -0
- package/dist/memory.js +1 -0
- package/dist/message/content.d.ts +125 -0
- package/dist/message/content.d.ts.map +1 -0
- package/dist/message/message.d.ts +154 -0
- package/dist/message/message.d.ts.map +1 -0
- package/dist/message/message.js +2 -0
- package/dist/message/message.js.map +1 -0
- package/dist/message/projection.d.ts +34 -0
- package/dist/message/projection.d.ts.map +1 -0
- package/dist/message/projection.js +2 -0
- package/dist/message/projection.js.map +1 -0
- package/dist/observability/bus.d.ts +7 -0
- package/dist/observability/bus.d.ts.map +1 -0
- package/dist/observability/bus.js +2 -0
- package/dist/observability/bus.js.map +1 -0
- package/dist/observability/exporters.d.ts +39 -0
- package/dist/observability/exporters.d.ts.map +1 -0
- package/dist/observability/exporters.js +2 -0
- package/dist/observability/exporters.js.map +1 -0
- package/dist/observability/logger.js +2 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/projections.d.ts +12 -0
- package/dist/observability/projections.d.ts.map +1 -0
- package/dist/observability/projections.js +2 -0
- package/dist/observability/projections.js.map +1 -0
- package/dist/observability/types.d.ts +103 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability.d.ts +20 -0
- package/dist/observability.js +1 -0
- package/dist/observation/boundaries.js +2 -0
- package/dist/observation/boundaries.js.map +1 -0
- package/dist/observation/context.d.ts +39 -0
- package/dist/observation/context.d.ts.map +1 -0
- package/dist/observation/context.js +2 -0
- package/dist/observation/context.js.map +1 -0
- package/dist/observation/event.d.ts +50 -0
- package/dist/observation/event.d.ts.map +1 -0
- package/dist/observation/event.js +2 -0
- package/dist/observation/event.js.map +1 -0
- package/dist/observation/port.d.ts +56 -0
- package/dist/observation/port.d.ts.map +1 -0
- package/dist/observation/port.js +2 -0
- package/dist/observation/port.js.map +1 -0
- package/dist/observation/privacy.js +2 -0
- package/dist/observation/privacy.js.map +1 -0
- package/dist/observation/report.d.ts +117 -0
- package/dist/observation/report.d.ts.map +1 -0
- package/dist/observation/report.js +2 -0
- package/dist/observation/report.js.map +1 -0
- package/dist/observation/telemetry-types.d.ts +29 -0
- package/dist/observation/telemetry-types.d.ts.map +1 -0
- package/dist/observation/usage.d.ts +52 -0
- package/dist/observation/usage.d.ts.map +1 -0
- package/dist/observation/usage.js +2 -0
- package/dist/observation/usage.js.map +1 -0
- package/dist/platform/adapter.js +2 -0
- package/dist/platform/adapter.js.map +1 -0
- package/dist/platform/capability-operation.js +2 -0
- package/dist/platform/capability-operation.js.map +1 -0
- package/dist/platform/config.js +2 -0
- package/dist/platform/config.js.map +1 -0
- package/dist/platform/logger-platform.js +2 -0
- package/dist/platform/logger-platform.js.map +1 -0
- package/dist/platform/resources.js +2 -0
- package/dist/platform/resources.js.map +1 -0
- package/dist/plugin/provider-plugin.d.ts +37 -0
- package/dist/plugin/provider-plugin.d.ts.map +1 -0
- package/dist/plugin/provider-plugin.js +2 -0
- package/dist/plugin/provider-plugin.js.map +1 -0
- package/dist/primitives/brand.d.ts +61 -0
- package/dist/primitives/brand.d.ts.map +1 -0
- package/dist/primitives/brand.js +2 -0
- package/dist/primitives/brand.js.map +1 -0
- package/dist/primitives/freeze.d.ts +20 -0
- package/dist/primitives/freeze.d.ts.map +1 -0
- package/dist/primitives/freeze.js +2 -0
- package/dist/primitives/freeze.js.map +1 -0
- package/dist/primitives/json-snapshot.js +2 -0
- package/dist/primitives/json-snapshot.js.map +1 -0
- package/dist/primitives/json.d.ts +32 -0
- package/dist/primitives/json.d.ts.map +1 -0
- package/dist/primitives/json.js +2 -0
- package/dist/primitives/json.js.map +1 -0
- package/dist/primitives/never.d.ts +22 -0
- package/dist/primitives/never.d.ts.map +1 -0
- package/dist/primitives/never.js +2 -0
- package/dist/primitives/never.js.map +1 -0
- package/dist/primitives/snapshot.d.ts +10 -0
- package/dist/primitives/snapshot.d.ts.map +1 -0
- package/dist/primitives/snapshot.js +2 -0
- package/dist/primitives/snapshot.js.map +1 -0
- package/dist/primitives/version.d.ts +6 -0
- package/dist/primitives/version.d.ts.map +1 -0
- package/dist/primitives/version.js +2 -0
- package/dist/primitives/version.js.map +1 -0
- package/dist/provider.d.ts +19 -0
- package/dist/provider.js +1 -0
- package/dist/runtime/model-call-handle.js +2 -0
- package/dist/runtime/model-call-handle.js.map +1 -0
- package/dist/runtime/model-metadata.js +2 -0
- package/dist/runtime/model-metadata.js.map +1 -0
- package/dist/runtime/model-stream.js +2 -0
- package/dist/runtime/model-stream.js.map +1 -0
- package/dist/runtime/registry.d.ts +171 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +2 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime/with-retry.d.ts +45 -0
- package/dist/runtime/with-retry.d.ts.map +1 -0
- package/dist/runtime/with-retry.js +2 -0
- package/dist/runtime/with-retry.js.map +1 -0
- package/dist/skills.d.ts +8 -0
- package/dist/skills.js +1 -0
- package/dist/stream/assembler.d.ts +86 -0
- package/dist/stream/assembler.d.ts.map +1 -0
- package/dist/stream/assembler.js +2 -0
- package/dist/stream/assembler.js.map +1 -0
- package/dist/stream/chunk.d.ts +135 -0
- package/dist/stream/chunk.d.ts.map +1 -0
- package/dist/stream/idle-timeout.d.ts +30 -0
- package/dist/stream/idle-timeout.d.ts.map +1 -0
- package/dist/stream/idle-timeout.js +2 -0
- package/dist/stream/idle-timeout.js.map +1 -0
- package/dist/support-safe/error.d.ts +29 -0
- package/dist/support-safe/error.d.ts.map +1 -0
- package/dist/support-safe/error.js +2 -0
- package/dist/support-safe/error.js.map +1 -0
- package/dist/tools.d.ts +15 -0
- package/dist/tools.js +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","names":[],"sources":["../../../src/composition/delivery/batch.ts"],"sourcesContent":["import type { ObservationEvent } from '../../observation/index.ts'\nimport type { RuntimePlatform } from '../../platform/adapter.ts'\nimport { arrayData } from '../common/data.ts'\nimport type { ObservationDeliveryBatch, RunTerminalRecord } from '../exporter/delivery-types.ts'\nimport { DELIVERY_LIMITS } from './config.ts'\nimport { bytes, count, DeliveryDataError } from './data.ts'\nimport { isRuntimeResource, type RuntimeObservationResource } from './resource.ts'\nimport { isPreparedTerminal } from './terminal.ts'\nimport { isPreparedEvent, prepareDeliveryEvent } from './event.ts'\n\nconst prepared = new WeakSet<ObservationDeliveryBatch>()\nexport function isPreparedBatch(batch: ObservationDeliveryBatch): boolean { return prepared.has(batch) }\n\nexport interface DeliveryBatchOptions {\n readonly content?: 'none' | 'metadata'\n readonly maxItems?: number\n readonly maxBytes?: number\n}\n\n/** Exact one-item wire size without allocating an ID; generated batch IDs have this fixed width. */\nexport function deliveryBatchItemBytes(resource: RuntimeObservationResource, item: ObservationEvent | RunTerminalRecord): number {\n if (!isRuntimeResource(resource)) throw new DeliveryDataError()\n const event = isPreparedTerminal(item as RunTerminalRecord) ? undefined : item as ObservationEvent\n if (event !== undefined && (!isPreparedEvent(event) || event.resource !== resource)) throw new DeliveryDataError()\n return bytes({ id: '0'.repeat(32), resource,\n events: event === undefined ? [] : [event], runRecords: event === undefined ? [item] : [] })\n}\n\nexport function deliveryBatchItemsBytes(\n resource: RuntimeObservationResource, events: readonly ObservationEvent[], records: readonly RunTerminalRecord[],\n): number {\n if (!isRuntimeResource(resource) || events.some(event => !isPreparedEvent(event) || event.resource !== resource)\n || records.some(record => !isPreparedTerminal(record))) throw new DeliveryDataError()\n return bytes({ id: '0'.repeat(32), resource, events, runRecords: records })\n}\n\n/** Privacy and canonical resource stamping happen before the first exporter sees the batch. */\nexport function createDeliveryBatch(\n resource: RuntimeObservationResource, events: readonly ObservationEvent[], records: readonly RunTerminalRecord[],\n platform: RuntimePlatform, options: DeliveryBatchOptions = {},\n): ObservationDeliveryBatch {\n try {\n if (!isRuntimeResource(resource)) throw new DeliveryDataError()\n const maxItems = count(options.maxItems ?? DELIVERY_LIMITS.batchItems)\n const maxBytes = count(options.maxBytes ?? DELIVERY_LIMITS.batchBytes)\n const content = options.content ?? 'none'\n if (maxItems === 0 || maxItems > DELIVERY_LIMITS.maxBatchItems || maxBytes === 0 || maxBytes > DELIVERY_LIMITS.maxBatchBytes\n || (content !== 'none' && content !== 'metadata')) throw new DeliveryDataError()\n const rawEvents = arrayData(events, maxItems), rawRecords = arrayData(records, maxItems)\n if (rawEvents.length + rawRecords.length === 0 || rawEvents.length + rawRecords.length > maxItems) throw new DeliveryDataError()\n let usedBytes = bytes(resource)\n const consume = (value: unknown): void => { usedBytes += bytes(value); if (usedBytes > maxBytes) throw new DeliveryDataError() }\n const safeEvents = rawEvents.map(value => {\n const event = prepareDeliveryEvent(value as ObservationEvent, resource, content)\n consume(event)\n return event\n })\n const runRecords = rawRecords.map(value => {\n if (!isPreparedTerminal(value as RunTerminalRecord)) throw new DeliveryDataError()\n consume(value)\n return value as RunTerminalRecord\n })\n if (new Set(safeEvents.map(event => event.eventId)).size !== safeEvents.length\n || new Set(runRecords.map(record => record.runId)).size !== runRecords.length) throw new DeliveryDataError()\n const batch: ObservationDeliveryBatch = Object.freeze({ id: platform.randomHex(16), resource,\n events: Object.freeze(safeEvents), runRecords: Object.freeze(runRecords) })\n if (bytes(batch) > maxBytes) throw new DeliveryDataError()\n prepared.add(batch)\n return batch\n } catch { throw new DeliveryDataError() }\n}\n"],"mappings":"obAUA,MAAM,EAAW,IAAI,QACrB,SAAgB,EAAgB,EAA0C,CAAE,OAAO,EAAS,IAAI,CAAK,CAAE,CASvG,SAAgB,EAAuB,EAAsC,EAAoD,CAC/H,GAAI,CAAC,EAAkB,CAAQ,EAAG,MAAM,IAAI,EAC5C,IAAM,EAAQ,EAAmB,CAAyB,EAAI,IAAA,GAAY,EAC1E,GAAI,IAAU,IAAA,KAAc,CAAC,EAAgB,CAAK,GAAK,EAAM,WAAa,GAAW,MAAM,IAAI,EAC/F,OAAO,EAAM,CAAE,GAAI,IAAI,OAAO,EAAE,EAAG,WACjC,OAAQ,IAAU,IAAA,GAAY,CAAC,EAAI,CAAC,CAAK,EAAG,WAAY,IAAU,IAAA,GAAY,CAAC,CAAI,EAAI,CAAC,CAAE,CAAC,CAC/F,CAEA,SAAgB,EACd,EAAsC,EAAqC,EACnE,CACR,GAAI,CAAC,EAAkB,CAAQ,GAAK,EAAO,KAAK,GAAS,CAAC,EAAgB,CAAK,GAAK,EAAM,WAAa,CAAQ,GAC1G,EA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,OAAO,OAAO,CAAE,GAAI,EAAS,UAAU,EAAE,EAAG,WAClF,OAAQ,OAAO,OAAO,CAAU,EAAG,WAAY,OAAO,OAAO,CAAU,CAAE,CAAC,EAC5E,GAAI,EAAM,CAAK,EAAI,EAAU,MAAM,IAAI,EAEvC,OADA,EAAS,IAAI,CAAK,EACX,CACT,MAAQ,CAAE,MAAM,IAAI,CAAoB,CAC1C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{arrayData as e}from"../../capability/common/data.js";import{COMPOSITION_LIMITS as t}from"../../capability/common/config.js";import{DELIVERY_ERROR_CODES as n}from"../../agent/accounting/delivery/config.js";import{DeliveryDataError as r}from"../../agent/accounting/delivery/data.js";import{isPreparedBatch as i}from"./batch.js";import{DeliveryAttempt as a}from"./attempt.js";var o=class{registrations;attempts;inFlight;sealed=!1;constructor(n,o,s){try{if(!i(n)||(this.registrations=e(o,t.exporters).map(e=>e),new Set(this.registrations.map(e=>e.exporter.id)).size!==this.registrations.length))throw new r;this.attempts=Object.freeze(this.registrations.map(e=>new a(n,e,s)))}catch{throw new r}}run(e,t){return this.inFlight===void 0?this.sealed?Promise.resolve(this.closedReport()):(this.inFlight=this.runOnce(e,t).finally(()=>{this.inFlight=void 0}),this.inFlight):this.inFlight}seal(){if(!this.sealed){this.sealed=!0;for(let e of this.attempts)e.seal()}}async runOnce(e,t){let n=[];for(let r=0;r<this.attempts.length;r++){let i=this.registrations[r],a=await this.attempts[r].send(e,t);n.push(Object.freeze({exporterIndex:r,requirement:i.requirement,selectedBoundary:i.boundary,delivery:a}))}return this.report(n)}report(e){let t=e.filter(e=>e.requirement===`required`),n=t.every(e=>e.delivery.complete),r=e.every(e=>e.delivery.complete),i=n&&t.length>0?t.map(e=>e.selectedBoundary).reduce(s):`none`;return Object.freeze({status:this.sealed?`closed`:r?`complete`:n?`required-complete`:`incomplete`,requiredComplete:!this.sealed&&n,complete:!this.sealed&&r,reachedBoundary:this.sealed?`none`:i,exporters:Object.freeze([...e])})}closedReport(){return this.report(this.registrations.map((e,t)=>Object.freeze({exporterIndex:t,requirement:e.requirement,selectedBoundary:e.boundary,delivery:Object.freeze({status:`closed`,complete:!1,boundary:`none`,acceptedEventIds:[],acceptedRunIds:[],error:Object.freeze({code:n.CLOSED,stage:`export`,message:`Observation delivery did not complete`})})})))}};function s(e,t){return c(e)<=c(t)?e:t}function c(e){return e===`remote-acknowledged`?2:+(e===`local-durable`)}export{o as DeliveryCheckpoint};
|
|
2
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","names":[],"sources":["../../../src/composition/delivery/checkpoint.ts"],"sourcesContent":["import type { ObservationBoundary } from '../../observation/index.ts'\nimport { RuntimeResources } from '../../platform/resources.ts'\nimport { COMPOSITION_LIMITS } from '../common/config.ts'\nimport { arrayData } from '../common/data.ts'\nimport type { ObservationDeliveryBatch } from '../exporter/delivery-types.ts'\nimport type { RuntimeObservationExporterRegistration } from '../exporter/types.ts'\nimport { DeliveryAttempt, type DeliveryAttemptReport } from './attempt.ts'\nimport { isPreparedBatch } from './batch.ts'\nimport { DELIVERY_ERROR_CODES } from './config.ts'\nimport { DeliveryDataError } from './data.ts'\n\nexport interface ExporterCheckpointReport {\n readonly exporterIndex: number\n readonly requirement: 'required' | 'best-effort'\n readonly selectedBoundary: ObservationBoundary\n readonly delivery: DeliveryAttemptReport\n}\n\nexport interface BatchCheckpointReport {\n readonly status: 'complete' | 'required-complete' | 'incomplete' | 'closed'\n readonly requiredComplete: boolean\n readonly complete: boolean\n readonly reachedBoundary: ObservationBoundary\n readonly exporters: readonly ExporterCheckpointReport[]\n}\n\n/** Fan out one stable batch. Required exporters form the checkpoint barrier; best-effort rows remain observable. */\nexport class DeliveryCheckpoint {\n private readonly registrations: readonly RuntimeObservationExporterRegistration[]\n private readonly attempts: readonly DeliveryAttempt[]\n private inFlight: Promise<BatchCheckpointReport> | undefined\n private sealed = false\n\n constructor(batch: ObservationDeliveryBatch, registrations: readonly RuntimeObservationExporterRegistration[], resources: RuntimeResources) {\n try {\n if (!isPreparedBatch(batch)) throw new DeliveryDataError()\n this.registrations = arrayData(registrations, COMPOSITION_LIMITS.exporters).map(value => value as RuntimeObservationExporterRegistration)\n if (new Set(this.registrations.map(value => value.exporter.id)).size !== this.registrations.length) throw new DeliveryDataError()\n this.attempts = Object.freeze(this.registrations.map(value => new DeliveryAttempt(batch, value, resources)))\n } catch { throw new DeliveryDataError() }\n }\n\n run(deadlineAt: number, caller?: AbortSignal): Promise<BatchCheckpointReport> {\n if (this.inFlight !== undefined) return this.inFlight\n if (this.sealed) return Promise.resolve(this.closedReport())\n this.inFlight = this.runOnce(deadlineAt, caller).finally(() => { this.inFlight = undefined })\n return this.inFlight\n }\n\n seal(): void {\n if (this.sealed) return\n this.sealed = true\n for (const attempt of this.attempts) attempt.seal()\n }\n\n private async runOnce(deadlineAt: number, caller?: AbortSignal): Promise<BatchCheckpointReport> {\n const reports: ExporterCheckpointReport[] = []\n for (let index = 0; index < this.attempts.length; index++) {\n const registration = this.registrations[index]!\n const delivery = await this.attempts[index]!.send(deadlineAt, caller)\n reports.push(Object.freeze({ exporterIndex: index, requirement: registration.requirement,\n selectedBoundary: registration.boundary, delivery }))\n }\n return this.report(reports)\n }\n\n private report(rows: readonly ExporterCheckpointReport[]): BatchCheckpointReport {\n const required = rows.filter(row => row.requirement === 'required')\n const requiredComplete = required.every(row => row.delivery.complete)\n const complete = rows.every(row => row.delivery.complete)\n const reachedBoundary = requiredComplete && required.length > 0\n ? required.map(row => row.selectedBoundary).reduce(weakerBoundary)\n : 'none'\n return Object.freeze({ status: this.sealed ? 'closed' : complete ? 'complete' : requiredComplete ? 'required-complete' : 'incomplete',\n requiredComplete: !this.sealed && requiredComplete, complete: !this.sealed && complete,\n reachedBoundary: this.sealed ? 'none' : reachedBoundary, exporters: Object.freeze([...rows]) })\n }\n\n private closedReport(): BatchCheckpointReport {\n return this.report(this.registrations.map((registration, index) => Object.freeze({ exporterIndex: index,\n requirement: registration.requirement, selectedBoundary: registration.boundary,\n delivery: Object.freeze({ status: 'closed', complete: false, boundary: 'none', acceptedEventIds: [], acceptedRunIds: [],\n error: Object.freeze({ code: DELIVERY_ERROR_CODES.CLOSED, stage: 'export', message: 'Observation delivery did not complete' }) }),\n })))\n }\n}\n\nfunction weakerBoundary(left: ObservationBoundary, right: ObservationBoundary): ObservationBoundary {\n return boundaryRank(left) <= boundaryRank(right) ? left : right\n}\n\nfunction boundaryRank(value: ObservationBoundary): number {\n return value === 'remote-acknowledged' ? 2 : value === 'local-durable' ? 1 : 0\n}\n"],"mappings":"4XA2BA,IAAa,EAAb,KAAgC,CAC9B,cACA,SACA,SACA,OAAiB,GAEjB,YAAY,EAAiC,EAAkE,EAA6B,CAC1I,GAAI,CAGF,GAFI,CAAC,EAAgB,CAAK,IAC1B,KAAK,cAAgB,EAAU,EAAe,EAAmB,SAAS,CAAC,CAAC,IAAI,GAAS,CAA+C,EACpI,IAAI,IAAI,KAAK,cAAc,IAAI,GAAS,EAAM,SAAS,EAAE,CAAC,CAAC,CAAC,OAAS,KAAK,cAAc,QAAQ,MAAM,IAAI,EAC9G,KAAK,SAAW,OAAO,OAAO,KAAK,cAAc,IAAI,GAAS,IAAI,EAAgB,EAAO,EAAO,CAAS,CAAC,CAAC,CAC7G,MAAQ,CAAE,MAAM,IAAI,CAAoB,CAC1C,CAEA,IAAI,EAAoB,EAAsD,CAI5E,OAHI,KAAK,WAAa,IAAA,GAClB,KAAK,OAAe,QAAQ,QAAQ,KAAK,aAAa,CAAC,GAC3D,KAAK,SAAW,KAAK,QAAQ,EAAY,CAAM,CAAC,CAAC,YAAc,CAAE,KAAK,SAAW,IAAA,EAAU,CAAC,EACrF,KAAK,UAH4B,KAAK,QAI/C,CAEA,MAAa,CACP,SAAK,OACT,MAAK,OAAS,GACd,IAAK,IAAM,KAAW,KAAK,SAAU,EAAQ,KAAK,CADpC,CAEhB,CAEA,MAAc,QAAQ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,CACF,EAEA,SAAS,EAAe,EAA2B,EAAiD,CAClG,OAAO,EAAa,CAAI,GAAK,EAAa,CAAK,EAAI,EAAO,CAC5D,CAEA,SAAS,EAAa,EAAoC,CACxD,OAAO,IAAU,sBAAwB,EAAI,MAAU,gBACzD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{sanitizeObservationEvent as e}from"../../observation/privacy.js";import{DeliveryDataError as t,bytes as n}from"../../agent/accounting/delivery/data.js";import{isRuntimeResource as r}from"./resource.js";const i=new WeakMap;function a(e){return i.has(e)}function o(a,o,s=`none`){try{if(!r(o)||s!==`none`&&s!==`metadata`)throw new t;let c=i.get(a);if(c?.resource===o&&c.content===s)return a;let l=Object.freeze({...e(a,{content:s,redactors:[],includeErrorStacks:!1}),resource:o});if(n(l)>65536)throw new t;return i.set(l,{resource:o,content:s}),l}catch{throw new t}}export{a as isPreparedEvent,o as prepareDeliveryEvent};
|
|
2
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","names":[],"sources":["../../../src/composition/delivery/event.ts"],"sourcesContent":["import type { ObservationEvent } from '../../observation/index.ts'\nimport { MAX_EVENT_BYTES, sanitizeObservationEvent } from '../../observation/privacy.ts'\nimport { bytes, DeliveryDataError } from './data.ts'\nimport { isRuntimeResource, type RuntimeObservationResource } from './resource.ts'\n\nconst prepared = new WeakMap<ObservationEvent, { resource: RuntimeObservationResource; content: 'none' | 'metadata' }>()\n\nexport function isPreparedEvent(event: ObservationEvent): boolean { return prepared.has(event) }\n\n/** Capture, staging and batching share one immutable, privacy-processed event identity. */\nexport function prepareDeliveryEvent(\n input: ObservationEvent, resource: RuntimeObservationResource, content: 'none' | 'metadata' = 'none',\n): ObservationEvent {\n try {\n if (!isRuntimeResource(resource) || (content !== 'none' && content !== 'metadata')) throw new DeliveryDataError()\n const previous = prepared.get(input)\n if (previous?.resource === resource && previous.content === content) return input\n const event = Object.freeze({ ...sanitizeObservationEvent(input, { content, redactors: [], includeErrorStacks: false }), resource })\n if (bytes(event) > MAX_EVENT_BYTES) throw new DeliveryDataError()\n prepared.set(event, { resource, content })\n return event\n } catch { throw new DeliveryDataError() }\n}\n"],"mappings":"iNAKA,MAAM,EAAW,IAAI,QAErB,SAAgB,EAAgB,EAAkC,CAAE,OAAO,EAAS,IAAI,CAAK,CAAE,CAG/F,SAAgB,EACd,EAAyB,EAAsC,EAA+B,OAC5E,CAClB,GAAI,CACF,GAAI,CAAC,EAAkB,CAAQ,GAAM,IAAY,QAAU,IAAY,WAAa,MAAM,IAAI,EAC9F,IAAM,EAAW,EAAS,IAAI,CAAK,EACnC,GAAI,GAAU,WAAa,GAAY,EAAS,UAAY,EAAS,OAAO,EAC5E,IAAM,EAAQ,OAAO,OAAO,CAAE,GAAG,EAAyB,EAAO,CAAE,UAAS,UAAW,CAAC,EAAG,mBAAoB,EAAM,CAAC,EAAG,UAAS,CAAC,EACnI,GAAI,EAAM,CAAK,EAAA,MAAqB,MAAM,IAAI,EAE9C,OADA,EAAS,IAAI,EAAO,CAAE,WAAU,SAAQ,CAAC,EAClC,CACT,MAAQ,CAAE,MAAM,IAAI,CAAoB,CAC1C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JsonValue } from "../../primitives/json.js";
|
|
2
|
+
import { ObservationResource } from "../../observation/event.js";
|
|
3
|
+
//#region src/composition/delivery/resource.d.ts
|
|
4
|
+
interface RuntimeObservationResource extends ObservationResource {
|
|
5
|
+
readonly runtimeId: string;
|
|
6
|
+
readonly environment?: string;
|
|
7
|
+
readonly attributes?: Readonly<Record<string, JsonValue>>;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RuntimeObservationResource };
|
|
11
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","names":[],"sources":["../../../src/composition/delivery/resource.ts"],"mappings":";;;UAOiB,mCAAmC;WACzC;WACA;WACA,aAAa,SAAS,eAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{SDK_VERSION as e}from"../../primitives/version.js";import{arrayData as t,boundedText as n,objectValue as r,ownData as i}from"../../capability/common/data.js";import{isSecretKey as a,redactInlineSecrets as o}from"../../observation/privacy.js";import{DeliveryDataError as s,bytes as c,optional as l}from"../../agent/accounting/delivery/data.js";const u=Object.freeze({fields:64,depth:8,nodes:4096,array:100,text:2048,bytes:16384}),d=new Set([`serviceName`,`serviceVersion`,`environment`,`attributes`]),f=new Set([`prompt`,`completion`,`body`,`content`,`messages`,`path`,`filepath`,`cwd`,`directory`]),p=/credential|secret|token/,m=new WeakSet;function h(e){return m.has(e)}function g(h,g){try{let _=0,v=new Set,y=e=>{if(typeof e!=`string`||e.length>u.text||o(e)!==e)throw new s;return e},b=(e,o)=>{if(++_>u.nodes||o>u.depth)throw new s;if(e===null||typeof e==`boolean`)return e;if(typeof e==`string`)return y(e);if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e)){if(v.has(e))throw new s;v.add(e);try{return Object.freeze(t(e,u.array).map(e=>b(e,o+1)))}finally{v.delete(e)}}let c=r(e);if(v.has(c))throw new s;v.add(c);try{let e=Object.getPrototypeOf(c);if(e!==Object.prototype&&e!==null)throw new s;let t=Object.keys(c);if(t.length>u.fields)throw new s;let r=Object.create(null);for(let e of t){n(e,128);let t=e.toLowerCase().replace(/[^a-z0-9]/g,``);if(a(e)||f.has(t)||p.test(t))throw new s;let l=i(c,e);r[e]=b(l,o+1)}return Object.freeze(r)}finally{v.delete(c)}},x=h===void 0?{}:r(h),S=Object.getPrototypeOf(x);if(S!==Object.prototype&&S!==null||Object.keys(x).some(e=>!d.has(e)))throw new s;let C={...l(x,`serviceName`,e=>n(y(e),128)),...l(x,`serviceVersion`,e=>n(y(e),128)),...l(x,`environment`,e=>n(y(e),128)),...l(x,`attributes`,e=>b(r(e),0))};if(c(C)>u.bytes)throw new s;let w=Object.freeze({sdkName:`ai-agent-sdk`,sdkVersion:e,runtime:`unknown`,runtimeId:g.randomHex(16),...C});return m.add(w),w}catch{throw new s}}export{g as createRuntimeResource,h as isRuntimeResource};
|
|
2
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","names":[],"sources":["../../../src/composition/delivery/resource.ts"],"sourcesContent":["import { SDK_VERSION, type JsonValue } from '../../primitives/index.ts'\nimport type { ObservationResource } from '../../observation/index.ts'\nimport { isSecretKey, redactInlineSecrets } from '../../observation/privacy.ts'\nimport type { RuntimePlatform } from '../../platform/adapter.ts'\nimport { arrayData, boundedText, objectValue, ownData } from '../common/data.ts'\nimport { bytes, DeliveryDataError, optional } from './data.ts'\n\nexport interface RuntimeObservationResource extends ObservationResource {\n readonly runtimeId: string\n readonly environment?: string\n readonly attributes?: Readonly<Record<string, JsonValue>>\n}\n\nconst RESOURCE_LIMITS = Object.freeze({ fields: 64, depth: 8, nodes: 4_096, array: 100, text: 2_048, bytes: 16 * 1024 })\nconst INPUT_KEYS = new Set(['serviceName', 'serviceVersion', 'environment', 'attributes'])\nconst PRIVATE_KEYS = new Set(['prompt', 'completion', 'body', 'content', 'messages', 'path', 'filepath', 'cwd', 'directory'])\nconst CREDENTIAL_KEY = /credential|secret|token/\nconst prepared = new WeakSet<RuntimeObservationResource>()\n\nexport function isRuntimeResource(value: RuntimeObservationResource): boolean { return prepared.has(value) }\n\n/** Constructor metadata, not a general-purpose host-object serializer. */\nexport function createRuntimeResource(input: unknown, platform: RuntimePlatform): RuntimeObservationResource {\n try {\n let nodes = 0\n const seen = new Set<object>()\n const text = (value: unknown): string => {\n if (typeof value !== 'string' || value.length > RESOURCE_LIMITS.text || redactInlineSecrets(value) !== value) throw new DeliveryDataError()\n return value\n }\n const clone = (value: unknown, depth: number): JsonValue => {\n if (++nodes > RESOURCE_LIMITS.nodes || depth > RESOURCE_LIMITS.depth) throw new DeliveryDataError()\n if (value === null || typeof value === 'boolean') return value\n if (typeof value === 'string') return text(value)\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (Array.isArray(value)) {\n if (seen.has(value)) throw new DeliveryDataError()\n seen.add(value)\n try { return Object.freeze(arrayData(value, RESOURCE_LIMITS.array).map(entry => clone(entry, depth + 1))) as unknown as JsonValue }\n finally { seen.delete(value) }\n }\n const source = objectValue(value)\n if (seen.has(source)) throw new DeliveryDataError()\n seen.add(source)\n try {\n const prototype: unknown = Object.getPrototypeOf(source)\n if (prototype !== Object.prototype && prototype !== null) throw new DeliveryDataError()\n const keys = Object.keys(source)\n if (keys.length > RESOURCE_LIMITS.fields) throw new DeliveryDataError()\n const result: Record<string, JsonValue> = Object.create(null) as Record<string, JsonValue>\n for (const key of keys) {\n boundedText(key, 128)\n const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, '')\n if (isSecretKey(key) || PRIVATE_KEYS.has(normalized) || CREDENTIAL_KEY.test(normalized)) throw new DeliveryDataError()\n const child = ownData(source, key)\n result[key] = clone(child, depth + 1)\n }\n return Object.freeze(result)\n } finally { seen.delete(source) }\n }\n const source = input === undefined ? {} : objectValue(input)\n const prototype: unknown = Object.getPrototypeOf(source)\n if (prototype !== Object.prototype && prototype !== null) throw new DeliveryDataError()\n if (Object.keys(source).some(key => !INPUT_KEYS.has(key))) throw new DeliveryDataError()\n const metadata = {\n ...optional(source, 'serviceName', value => boundedText(text(value), 128)),\n ...optional(source, 'serviceVersion', value => boundedText(text(value), 128)),\n ...optional(source, 'environment', value => boundedText(text(value), 128)),\n ...optional(source, 'attributes', value => clone(objectValue(value), 0) as Readonly<Record<string, JsonValue>>),\n }\n if (bytes(metadata) > RESOURCE_LIMITS.bytes) throw new DeliveryDataError()\n const resource = Object.freeze({ sdkName: 'ai-agent-sdk' as const, sdkVersion: SDK_VERSION,\n runtime: 'unknown' as const, runtimeId: platform.randomHex(16), ...metadata })\n prepared.add(resource)\n return resource\n } catch { throw new DeliveryDataError() }\n}\n"],"mappings":"8VAaA,M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,EAC7E,QAAS,UAAoB,UAAW,EAAS,UAAU,EAAE,EAAG,GAAG,CAAS,CAAC,EAE/E,OADA,EAAS,IAAI,CAAQ,EACd,CACT,MAAQ,CAAE,MAAM,IAAI,CAAoB,CAC1C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{capturedOptionalMethod as e}from"../../capability/common/data.js";import{DELIVERY_ERROR_CODES as t}from"../../agent/accounting/delivery/config.js";import{DeliveryDataError as n}from"../../agent/accounting/delivery/data.js";import{isPreparedEvent as r}from"./event.js";import{isPreparedTerminal as i}from"../../agent/accounting/delivery/terminal.js";var a=class{onFailure;sealed=!1;hooks;constructor(t,n){this.onFailure=n,this.hooks=Object.freeze(t.map(t=>Object.freeze({invoke:e(t.exporter,`stage`),required:t.requirement===`required`})))}stage(e){if(!this.sealed){if(!r(e)&&!i(e))throw new n;for(let[t,n]of this.hooks.entries()){if(this.sealed)break;if(n.invoke===void 0)continue;let r=()=>this.failure(t,n.required);try{let t=n.invoke(e);t!==void 0&&Promise.resolve(t).then(e=>{e!==void 0&&r()},r)}catch{r()}}}}seal(){this.sealed=!0}failure(e,n){if(this.sealed)return;let r=Object.freeze({exporterIndex:e,required:n,code:t.STAGE_FAILED,stage:`stage`,message:`Observation staging failed`});try{this.onFailure(r)}catch{}}};export{a as DeliveryStaging};
|
|
2
|
+
//# sourceMappingURL=staging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staging.js","names":[],"sources":["../../../src/composition/delivery/staging.ts"],"sourcesContent":["import type { ObservationEvent } from '../../observation/index.ts'\nimport { capturedOptionalMethod } from '../common/data.ts'\nimport type { ObservationExportItem, RunTerminalRecord } from '../exporter/delivery-types.ts'\nimport type { RuntimeObservationExporterRegistration } from '../exporter/types.ts'\nimport { DELIVERY_ERROR_CODES } from './config.ts'\nimport { DeliveryDataError } from './data.ts'\nimport { isPreparedEvent } from './event.ts'\nimport { isPreparedTerminal } from './terminal.ts'\n\nexport interface StagingFailure {\n readonly exporterIndex: number\n readonly required: boolean\n readonly code: typeof DELIVERY_ERROR_CODES.STAGE_FAILED\n readonly stage: 'stage'\n readonly message: string\n}\n\n/** Local write initiation only. The queue owner calls this after admission, never as a durability receipt. */\nexport class DeliveryStaging {\n private sealed = false\n private readonly hooks: readonly {\n readonly invoke: ((item: ObservationExportItem) => void | Promise<void>) | undefined\n readonly required: boolean\n }[]\n\n constructor(\n registrations: readonly RuntimeObservationExporterRegistration[],\n private readonly onFailure: (failure: StagingFailure) => void,\n ) {\n this.hooks = Object.freeze(registrations.map(registration => Object.freeze({\n invoke: capturedOptionalMethod<[ObservationExportItem], void | Promise<void>>(registration.exporter, 'stage'),\n required: registration.requirement === 'required',\n })))\n }\n\n stage(item: ObservationExportItem): void {\n if (this.sealed) return\n if (!isPreparedEvent(item as ObservationEvent) && !isPreparedTerminal(item as RunTerminalRecord)) throw new DeliveryDataError()\n for (const [index, hook] of this.hooks.entries()) {\n if (this.sealed) break\n if (hook.invoke === undefined) continue\n const fail = (): void => this.failure(index, hook.required)\n try {\n // Invoke directly: deferring this call to a microtask would violate capture-time staging.\n const pending = hook.invoke(item)\n if (pending !== undefined) void Promise.resolve(pending).then(value => {\n if (value !== undefined) fail()\n }, fail)\n } catch { fail() }\n }\n }\n\n seal(): void { this.sealed = true }\n\n private failure(exporterIndex: number, required: boolean): void {\n if (this.sealed) return\n const failure: StagingFailure = Object.freeze({ exporterIndex, required,\n code: DELIVERY_ERROR_CODES.STAGE_FAILED, stage: 'stage', message: 'Observation staging failed' })\n try { this.onFailure(failure) } catch { /* Health failure cannot escape a synchronous capture call. */ }\n }\n}\n"],"mappings":"oWAkBA,IAAa,EAAb,KAA6B,CASR,UARnB,OAAiB,GACjB,MAKA,YACE,EACA,EACA,CADiB,KAAA,UAAA,EAEjB,KAAK,MAAQ,OAAO,OAAO,EAAc,IAAI,GAAgB,OAAO,OAAO,CACzE,OAAQ,EAAsE,EAAa,SAAU,OAAO,EAC5G,SAAU,EAAa,cAAgB,UACzC,CAAC,CAAC,CAAC,CACL,CAEA,MAAM,EAAmC,CACnC,SAAK,OACT,IAAI,CAAC,EAAgB,CAAwB,GAAK,CAAC,EAAmB,CAAyB,EAAG,MAAM,IAAI,EAC5G,IAAK,GAAM,CAAC,EAAO,KAAS,KAAK,MAAM,QAAQ,EAAG,CAChD,GAAI,KAAK,OAAQ,MACjB,GAAI,EAAK,SAAW,IAAA,GAAW,SAC/B,IAAM,MAAmB,KAAK,QAAQ,EAAO,EAAK,QAAQ,EAC1D,GAAI,CAEF,IAAM,EAAU,EAAK,OAAO,CAAI,EAC5B,IAAY,IAAA,IAAW,QAAa,QAAQ,CAAO,CAAC,CAAC,KAAK,GAAS,CACjE,IAAU,IAAA,IAAW,EAAK,CAChC,EAAG,CAAI,CACT,MAAQ,CAAE,EAAK,CAAE,CACnB,CAZ8H,CAahI,CAEA,MAAa,CAAE,KAAK,OAAS,EAAK,CAElC,QAAgB,EAAuB,EAAyB,CAC9D,GAAI,KAAK,OAAQ,OACjB,IAAM,EAA0B,OAAO,OAAO,CAAE,gBAAe,WAC7D,KAAM,EAAqB,aAAc,MAAO,QAAS,QAAS,4BAA6B,CAAC,EAClG,GAAI,CAAE,KAAK,UAAU,CAAO,CAAE,MAAQ,CAAiE,CACzG,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../src/composition/diagnostics/config.ts"],"sourcesContent":["export const DIAGNOSTIC_LIMITS = Object.freeze({\n events: 256,\n bytes: 1024 * 1024,\n maxEvents: 4_096,\n maxBytes: 16 * 1024 * 1024,\n})\n"],"mappings":"AAAA,MAAa,EAAoB,OAAO,OAAO,CAC7C,OAAQ,IACR,MAAO,QACP,UAAW,KACX,SAAU,QACZ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ObservationEvent } from "../../observation/event.js";
|
|
2
|
+
//#region src/composition/diagnostics/ring.d.ts
|
|
3
|
+
interface DiagnosticRingSnapshot {
|
|
4
|
+
readonly events: readonly ObservationEvent[];
|
|
5
|
+
readonly retainedEvents: number;
|
|
6
|
+
readonly retainedBytes: number;
|
|
7
|
+
readonly evictedEvents: number;
|
|
8
|
+
readonly evictedBytes: number;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DiagnosticRingSnapshot };
|
|
12
|
+
//# sourceMappingURL=ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring.d.ts","names":[],"sources":["../../../src/composition/diagnostics/ring.ts"],"mappings":";;UAciB;WACN,iBAAiB;WACjB;WACA;WACA;WACA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{serializedEventBytes as e}from"../../observation/privacy.js";import{DeliveryDataError as t,count as n}from"../../agent/accounting/delivery/data.js";import{isPreparedEvent as r}from"../delivery/event.js";import{DIAGNOSTIC_LIMITS as i}from"./config.js";import{saturatingCounterAdd as a}from"../common/counter.js";var o=class{maxEvents;maxBytes;entries=[];cursor=0;retainedBytes=0;evictedEvents=0;evictedBytes=0;constructor(e={}){try{if(this.maxEvents=n(e.maxEvents??i.events),this.maxBytes=n(e.maxBytes??i.bytes),this.maxEvents===0||this.maxEvents>i.maxEvents||this.maxBytes===0||this.maxBytes>i.maxBytes)throw new t}catch{throw new t}}record(n){if(!r(n))throw new t;let i=e(n);if(i>this.maxBytes)return!1;for(;this.length>=this.maxEvents||this.retainedBytes+i>this.maxBytes;)this.evict();return this.entries.push({event:n,bytes:i}),this.retainedBytes+=i,!0}snapshot(){let e=Object.freeze(this.entries.slice(this.cursor).map(e=>e.event));return Object.freeze({events:e,retainedEvents:e.length,retainedBytes:this.retainedBytes,evictedEvents:this.evictedEvents,evictedBytes:this.evictedBytes})}get length(){return this.entries.length-this.cursor}evict(){let e=this.entries[this.cursor];if(e===void 0)throw new t;this.cursor++,this.retainedBytes-=e.bytes,this.evictedEvents=a(this.evictedEvents,1),this.evictedBytes=a(this.evictedBytes,e.bytes),this.cursor>=256&&this.cursor*2>=this.entries.length&&(this.entries.splice(0,this.cursor),this.cursor=0)}};export{o as DiagnosticRing};
|
|
2
|
+
//# sourceMappingURL=ring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring.js","names":[],"sources":["../../../src/composition/diagnostics/ring.ts"],"sourcesContent":["import type { ObservationEvent } from '../../observation/index.ts'\nimport { serializedEventBytes } from '../../observation/privacy.ts'\nimport { isPreparedEvent } from '../delivery/event.ts'\nimport { count, DeliveryDataError } from '../delivery/data.ts'\nimport { DIAGNOSTIC_LIMITS } from './config.ts'\nimport { saturatingCounterAdd } from '../common/counter.ts'\n\ninterface RingEntry { readonly event: ObservationEvent; readonly bytes: number }\n\nexport interface DiagnosticRingOptions {\n readonly maxEvents?: number\n readonly maxBytes?: number\n}\n\nexport interface DiagnosticRingSnapshot {\n readonly events: readonly ObservationEvent[]\n readonly retainedEvents: number\n readonly retainedBytes: number\n readonly evictedEvents: number\n readonly evictedBytes: number\n}\n\n/** Metadata-only support view. Eviction here never removes canonical accounting or exporter work. */\nexport class DiagnosticRing {\n private readonly maxEvents: number\n private readonly maxBytes: number\n private readonly entries: RingEntry[] = []\n private cursor = 0\n private retainedBytes = 0\n private evictedEvents = 0\n private evictedBytes = 0\n\n constructor(options: DiagnosticRingOptions = {}) {\n try {\n this.maxEvents = count(options.maxEvents ?? DIAGNOSTIC_LIMITS.events)\n this.maxBytes = count(options.maxBytes ?? DIAGNOSTIC_LIMITS.bytes)\n if (this.maxEvents === 0 || this.maxEvents > DIAGNOSTIC_LIMITS.maxEvents\n || this.maxBytes === 0 || this.maxBytes > DIAGNOSTIC_LIMITS.maxBytes) throw new DeliveryDataError()\n } catch { throw new DeliveryDataError() }\n }\n\n /** False means the already-safe event cannot fit even in an empty ring. */\n record(event: ObservationEvent): boolean {\n if (!isPreparedEvent(event)) throw new DeliveryDataError()\n const size = serializedEventBytes(event)\n if (size > this.maxBytes) return false\n while (this.length >= this.maxEvents || this.retainedBytes + size > this.maxBytes) this.evict()\n this.entries.push({ event, bytes: size })\n this.retainedBytes += size\n return true\n }\n\n snapshot(): DiagnosticRingSnapshot {\n const events = Object.freeze(this.entries.slice(this.cursor).map(entry => entry.event))\n return Object.freeze({ events, retainedEvents: events.length, retainedBytes: this.retainedBytes,\n evictedEvents: this.evictedEvents, evictedBytes: this.evictedBytes })\n }\n\n private get length(): number { return this.entries.length - this.cursor }\n\n private evict(): void {\n const entry = this.entries[this.cursor]\n if (entry === undefined) throw new DeliveryDataError()\n this.cursor++\n this.retainedBytes -= entry.bytes\n this.evictedEvents = saturatingCounterAdd(this.evictedEvents, 1)\n this.evictedBytes = saturatingCounterAdd(this.evictedBytes, entry.bytes)\n if (this.cursor >= 256 && this.cursor * 2 >= this.entries.length) {\n this.entries.splice(0, this.cursor)\n this.cursor = 0\n }\n }\n}\n"],"mappings":"8TAuBA,IAAa,EAAb,KAA4B,CAC1B,UACA,SACA,QAAwC,CAAC,EACzC,OAAiB,EACjB,cAAwB,EACxB,cAAwB,EACxB,aAAuB,EAEvB,YAAY,EAAiC,CAAC,EAAG,CAC/C,GAAI,CAGF,GAFA,KAAK,UAAY,EAAM,EAAQ,WAAa,EAAkB,MAAM,EACpE,KAAK,SAAW,EAAM,EAAQ,UAAY,EAAkB,KAAK,EAC7D,KAAK,YAAc,GAAK,KAAK,UAAY,EAAkB,WAC1D,KAAK,WAAa,GAAK,KAAK,SAAW,EAAkB,SAAU,MAAM,IAAI,CACpF,MAAQ,CAAE,MAAM,IAAI,CAAoB,CAC1C,CAGA,OAAO,EAAkC,CACvC,GAAI,CAAC,EAAgB,CAAK,EAAG,MAAM,IAAI,EACvC,IAAM,EAAO,EAAqB,CAAK,EACvC,GAAI,EAAO,KAAK,SAAU,MAAO,GACjC,KAAO,KAAK,QAAU,KAAK,WAAa,KAAK,cAAgB,EAAO,KAAK,UAAU,KAAK,MAAM,EAG9F,OAFA,KAAK,QAAQ,KAAK,CAAE,QAAO,MAAO,CAAK,CAAC,EACxC,KAAK,eAAiB,EACf,EACT,CAEA,UAAmC,CACjC,IAAM,EAAS,OAAO,OAAO,KAAK,QAAQ,MAAM,KAAK,MAAM,CAAC,CAAC,IAAI,GAAS,EAAM,KAAK,CAAC,EACtF,OAAO,OAAO,OAAO,CAAE,SAAQ,eAAgB,EAAO,OAAQ,cAAe,KAAK,cAChF,cAAe,KAAK,cAAe,aAAc,KAAK,YAAa,CAAC,CACxE,CAEA,IAAY,QAAiB,CAAE,OAAO,KAAK,QAAQ,OAAS,KAAK,MAAO,CAExE,OAAsB,CACpB,IAAM,EAAQ,KAAK,QAAQ,KAAK,QAChC,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EACnC,KAAK,SACL,KAAK,eAAiB,EAAM,MAC5B,KAAK,cAAgB,EAAqB,KAAK,cAAe,CAAC,EAC/D,KAAK,aAAe,EAAqB,KAAK,aAAc,EAAM,KAAK,EACnE,KAAK,QAAU,KAAO,KAAK,OAAS,GAAK,KAAK,QAAQ,SACxD,KAAK,QAAQ,OAAO,EAAG,KAAK,MAAM,EAClC,KAAK,OAAS,EAElB,CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ObservationExporterPlugin, ObservationExporterPluginDefinition } from "./types.js";
|
|
2
|
+
//#region src/composition/exporter/definition.d.ts
|
|
3
|
+
/** A new frozen execution view, not a resource acquisition or mutation of the caller. */
|
|
4
|
+
declare function defineObservationExporter(definition: ObservationExporterPluginDefinition): ObservationExporterPlugin;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { defineObservationExporter };
|
|
7
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","names":[],"sources":["../../../src/composition/exporter/definition.ts"],"mappings":";;;iBAMgB,0BAA0B,YAAY,sCAAsC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{objectValue as e}from"../../capability/common/data.js";import{invalidPreflight as t}from"../common/errors.js";import{captureExporter as n,exporterMetadata as r}from"./preflight.js";function i(i){try{let t=e(i);return n(t,r(t))}catch{throw t()}}export{i as defineObservationExporter};
|
|
2
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","names":[],"sources":["../../../src/composition/exporter/definition.ts"],"sourcesContent":["import { objectValue } from '../common/data.ts'\nimport { invalidPreflight } from '../common/errors.ts'\nimport { captureExporter, exporterMetadata } from './preflight.ts'\nimport type { ObservationExporterPlugin, ObservationExporterPluginDefinition } from './types.ts'\n\n/** A new frozen execution view, not a resource acquisition or mutation of the caller. */\nexport function defineObservationExporter(definition: ObservationExporterPluginDefinition): ObservationExporterPlugin {\n try {\n const source = objectValue(definition)\n return captureExporter(source, exporterMetadata(source))\n } catch { throw invalidPreflight() }\n}\n"],"mappings":"4LAMA,SAAgB,EAA0B,EAA4E,CACpH,GAAI,CACF,IAAM,EAAS,EAAY,CAAU,EACrC,OAAO,EAAgB,EAAQ,EAAiB,CAAM,CAAC,CACzD,MAAQ,CAAE,MAAM,EAAiB,CAAE,CACrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{BoundaryFailure as e,atDeadline as t}from"../lifecycle/bounded.js";import{AgentRuntimeConstructionError as n}from"../common/errors.js";function r(t,r){let i=r instanceof e?r.reason:`failed`;return new n({failureCode:i===`aborted`?`CAPABILITY_STARTUP_ABORTED`:i===`timed-out`?`CAPABILITY_STARTUP_TIMEOUT`:`CAPABILITY_STARTUP_FAILED`,reason:i,stage:`exporter-ready`,component:{kind:`observation-exporter`,id:`exporter-${t}`}})}var i=class{registrations;resources;abort;readiness;closing;constructor(e,t){this.registrations=e,this.resources=t,this.abort=t.platform.controller()}ready(e,t){return this.readiness===void 0?(this.readiness=this.start(e,t),this.readiness.catch(()=>void 0),this.readiness):this.readiness}async start(e,n){let i=this.resources.cancellation([this.abort.signal,...n===void 0?[]:[n]]);try{for(let[n,a]of this.registrations.entries())try{await t(this.resources,e,e=>a.exporter.ready?.(e),i.signal)}catch(e){throw r(n,e)}}finally{i.dispose()}}close(e){if(this.closing!==void 0)return this.closing;let t;return this.closing=new Promise(e=>{t=e}),this.abort.abort(Error(`Runtime exporters are closing`)),this.shutdown(e).then(t),this.closing}async shutdown(n){let r=[];for(let i=this.registrations.length-1;i>=0;i--){let a=this.registrations[i];if(a.ownership!==`owned`)continue;let o={kind:`observation-exporter`,id:`exporter-${i}`};try{a.exporter.shutdown!==void 0&&await t(this.resources,n,a.exporter.shutdown),r.push(Object.freeze({...o,status:`closed`}))}catch(t){let n=t instanceof e&&t.reason===`timed-out`;r.push(Object.freeze({...o,status:n?`timed-out`:`failed`,error:Object.freeze({code:n?`CAPABILITY_CLEANUP_TIMEOUT`:`CAPABILITY_CLEANUP_FAILED`,stage:`exporter-shutdown`,message:`Observation exporter shutdown did not complete`})}))}}return Object.freeze(r)}};export{i as RuntimeExporters};
|
|
2
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","names":[],"sources":["../../../src/composition/exporter/lifecycle.ts"],"sourcesContent":["import { RuntimeResources } from '../../platform/resources.ts'\nimport { AgentRuntimeConstructionError, type RuntimeComponentCloseReport } from '../common/errors.ts'\nimport { atDeadline, BoundaryFailure } from '../lifecycle/bounded.ts'\nimport type { RuntimeObservationExporterRegistration } from './types.ts'\n\nfunction failedReady(index: number, error: unknown): AgentRuntimeConstructionError {\n const reason = error instanceof BoundaryFailure ? error.reason : 'failed'\n return new AgentRuntimeConstructionError({\n failureCode: reason === 'aborted' ? 'CAPABILITY_STARTUP_ABORTED'\n : reason === 'timed-out' ? 'CAPABILITY_STARTUP_TIMEOUT' : 'CAPABILITY_STARTUP_FAILED',\n reason, stage: 'exporter-ready', component: { kind: 'observation-exporter', id: `exporter-${index}` },\n })\n}\n\n/** Construct only after whole-runtime preflight. This is the explicit ownership-transfer boundary. */\nexport class RuntimeExporters {\n private readonly abort: AbortController\n private readiness: Promise<void> | undefined\n private closing: Promise<readonly RuntimeComponentCloseReport[]> | undefined\n\n constructor(\n readonly registrations: readonly RuntimeObservationExporterRegistration[],\n private readonly resources: RuntimeResources,\n ) { this.abort = resources.platform.controller() }\n\n ready(deadlineAt: number, caller?: AbortSignal): Promise<void> {\n if (this.readiness !== undefined) return this.readiness\n this.readiness = this.start(deadlineAt, caller)\n void this.readiness.catch(() => undefined)\n return this.readiness\n }\n\n private async start(deadlineAt: number, caller?: AbortSignal): Promise<void> {\n const scope = this.resources.cancellation([this.abort.signal, ...caller === undefined ? [] : [caller]])\n try {\n for (const [index, registration] of this.registrations.entries()) {\n try {\n await atDeadline(this.resources, deadlineAt, signal => registration.exporter.ready?.(signal), scope.signal)\n } catch (error) { throw failedReady(index, error) }\n }\n } finally { scope.dispose() }\n }\n\n /** No caller-abort signal here: cleanup must proceed even when startup/run cancellation requested it. */\n close(deadlineAt: number): Promise<readonly RuntimeComponentCloseReport[]> {\n if (this.closing !== undefined) return this.closing\n let resolve!: (rows: readonly RuntimeComponentCloseReport[]) => void\n this.closing = new Promise(done => { resolve = done })\n // Store the promise before abort dispatch so reentrant close joins it.\n this.abort.abort(new Error('Runtime exporters are closing'))\n void this.shutdown(deadlineAt).then(resolve)\n return this.closing\n }\n\n private async shutdown(deadlineAt: number): Promise<readonly RuntimeComponentCloseReport[]> {\n const rows: RuntimeComponentCloseReport[] = []\n for (let index = this.registrations.length - 1; index >= 0; index--) {\n const registration = this.registrations[index]!\n if (registration.ownership !== 'owned') continue\n const component = { kind: 'observation-exporter' as const, id: `exporter-${index}` }\n try {\n if (registration.exporter.shutdown !== undefined) {\n await atDeadline(this.resources, deadlineAt, registration.exporter.shutdown)\n }\n rows.push(Object.freeze({ ...component, status: 'closed' }))\n } catch (error) {\n const timedOut = error instanceof BoundaryFailure && error.reason === 'timed-out'\n rows.push(Object.freeze({\n ...component, status: timedOut ? 'timed-out' : 'failed',\n error: Object.freeze({ code: timedOut ? 'CAPABILITY_CLEANUP_TIMEOUT' : 'CAPABILITY_CLEANUP_FAILED',\n stage: 'exporter-shutdown', message: 'Observation exporter shutdown did not complete' }),\n }))\n }\n }\n return Object.freeze(rows)\n }\n}\n"],"mappings":"8IAKA,SAAS,EAAY,EAAe,EAA+C,CACjF,IAAM,EAAS,aAAiB,EAAkB,EAAM,OAAS,SACjE,OAAO,IAAI,EAA8B,CACvC,YAAa,IAAW,UAAY,6BAChC,IAAW,YAAc,6BAA+B,4BAC5D,SAAQ,MAAO,iBAAkB,UAAW,CAAE,KAAM,uBAAwB,GAAI,YAAY,GAAQ,CACtG,CAAC,CACH,CAGA,IAAa,EAAb,KAA8B,CAMjB,cACQ,UANnB,MACA,UACA,QAEA,YACE,EACA,EACA,CAFS,KAAA,cAAA,EACQ,KAAA,UAAA,EACf,KAAK,MAAQ,EAAU,SAAS,WAAW,CAAE,CAEjD,MAAM,EAAoB,EAAqC,CAI7D,OAHI,KAAK,YAAc,IAAA,IACvB,KAAK,UAAY,KAAK,MAAM,EAAY,CAAM,EAC9C,KAAU,UAAU,UAAY,IAAA,EAAS,EAClC,KAAK,WAH6B,KAAK,SAIhD,CAEA,MAAc,MAAM,EAAoB,EAAqC,CAC3E,IAAM,EAAQ,KAAK,UAAU,aAAa,CAAC,KAAK,MAAM,OAAQ,GAAG,IAAW,IAAA,GAAY,CAAC,EAAI,CAAC,CAAM,CAAC,CAAC,EACtG,GAAI,CACF,IAAK,GAAM,CAAC,EAAO,KAAiB,KAAK,cAAc,QAAQ,EAC7D,GAAI,CACF,MAAM,EAAW,KAAK,UAAW,EAAY,GAAU,EAAa,SAAS,QAAQ,CAAM,EAAG,EAAM,MAAM,CAC5G,OAAS,EAAO,CAAE,MAAM,EAAY,EAAO,CAAK,CAAE,CAEtD,QAAU,CAAE,EAAM,QAAQ,CAAE,CAC9B,CAGA,MAAM,EAAqE,CACzE,GAAI,KAAK,UAAY,IAAA,GAAW,OAAO,KAAK,QAC5C,IAAI,EAKJ,MAJA,MAAK,QAAU,IAAI,QAAQ,GAAQ,CAAE,EAAU,CAAK,CAAC,EAErD,KAAK,MAAM,MAAU,MAAM,+BAA+B,CAAC,EAC3D,KAAU,SAAS,CAAU,CAAC,CAAC,KAAK,CAAO,EACpC,KAAK,OACd,CAEA,MAAc,SAAS,EAAqE,CAC1F,IAAM,EAAsC,CAAC,EAC7C,IAAK,IAAI,EAAQ,KAAK,cAAc,OAAS,EAAG,GAAS,EAAG,IAAS,CACnE,IAAM,EAAe,KAAK,cAAc,GACxC,GAAI,EAAa,YAAc,QAAS,SACxC,IAAM,EAAY,CAAE,KAAM,uBAAiC,GAAI,YAAY,GAAQ,EACnF,GAAI,CACE,EAAa,SAAS,WAAa,IAAA,IACrC,MAAM,EAAW,KAAK,UAAW,EAAY,EAAa,SAAS,QAAQ,EAE7E,EAAK,KAAK,OAAO,OAAO,CAAE,GAAG,EAAW,OAAQ,QAAS,CAAC,CAAC,CAC7D,OAAS,EAAO,CACd,IAAM,EAAW,aAAiB,GAAmB,EAAM,SAAW,YACtE,EAAK,KAAK,OAAO,OAAO,CACtB,GAAG,EAAW,OAAQ,EAAW,YAAc,SAC/C,MAAO,OAAO,OAAO,CAAE,KAAM,EAAW,6BAA+B,4BACrE,MAAO,oBAAqB,QAAS,gDAAiD,CAAC,CAC3F,CAAC,CAAC,CACJ,CACF,CACA,OAAO,OAAO,OAAO,CAAI,CAC3B,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{arrayData as e,boundedText as t,capturedMethod as n,capturedOptionalMethod as r,objectValue as i,ownData as a}from"../../capability/common/data.js";import{capabilityIdentityConflict as o}from"../../errors/capability-identity.js";import{COMPOSITION_LIMITS as s}from"../../capability/common/config.js";import{EXPORTER_BOUNDARIES as c}from"../../observation/boundaries.js";import{checkPreflightAbort as l,invalidPreflight as u}from"../common/errors.js";import"./types.js";const d=new WeakMap,f=new WeakMap;function p(e){if(!c.includes(e))throw TypeError(`Invalid observation boundary`);return e}function m(n){let r=t(a(n,`id`),s.identityBytes),i=e(a(n,`supportedBoundaries`),c.length).map(p);if(i.length===0||new Set(i).size!==i.length)throw TypeError(`Exporter boundaries must be non-empty and unique`);return Object.freeze({id:r,supportedBoundaries:Object.freeze(i)})}function h(e,t,i){l(i);let a=r(e,`ready`);l(i);let o=r(e,`stage`);l(i);let s=n(e,`export`);l(i);let c=r(e,`shutdown`);return l(i),Object.freeze({kind:`observation-exporter`,apiVersion:1,...t,...a===void 0?{}:{ready:a},...o===void 0?{}:{stage:o},export:s,...c===void 0?{}:{shutdown:c}})}function g(t,n){l(n);let r=new Set,c=e=>{throw r.add(e),e};try{let r=[],f=new Map,h=e(t,s.exporters).map((e,t)=>{l(n);let s=i(e),d=i(a(s,`exporter`));a(d,`kind`,!1)!==`observation-exporter`&&c(u(`CAPABILITY_KIND_MISMATCH`)),a(d,`apiVersion`,!1)!==1&&c(u(`CAPABILITY_API_UNSUPPORTED`));let h=m(d),g=f.get(h.id);g!==void 0&&c(u(`CAPABILITY_ID_CONFLICT`,o(`observation-exporter-id`,g,t))),f.set(h.id,t);let _=a(s,`ownership`),v=a(s,`requirement`),y=p(a(s,`boundary`));if(_!==`owned`&&_!==`borrowed`)throw TypeError(`Explicit exporter ownership is required`);if(v!==`required`&&v!==`best-effort`)throw TypeError(`Invalid exporter requirement`);return h.supportedBoundaries.includes(y)||c(u(`OBSERVATION_BOUNDARY_UNSUPPORTED`)),r.push(d),Object.freeze({exporter:h,ownership:_,requirement:v,boundary:y})});l(n);let g=Object.freeze({registrations:Object.freeze(h)});return d.set(g,Object.freeze(r)),g}catch(e){throw l(n),r.has(e)?e:u()}}function _(e,t){l(t);let n=f.get(e);if(n!==void 0)return n;let r=d.get(e);if(r===void 0)throw u();d.delete(e);try{let n=Object.freeze(e.registrations.map((e,n)=>(l(t),Object.freeze({...e,exporter:h(r[n],e.exporter,t)}))));return l(t),f.set(e,n),n}catch{throw l(t),u()}}export{h as captureExporter,_ as captureExporterMethods,m as exporterMetadata,g as preflightExporterIdentities};
|
|
2
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","names":[],"sources":["../../../src/composition/exporter/preflight.ts"],"sourcesContent":["import type { ObservationBoundary } from '../../observation/index.ts'\nimport { COMPOSITION_LIMITS } from '../common/config.ts'\nimport { arrayData, boundedText, capturedMethod, capturedOptionalMethod, objectValue, ownData } from '../common/data.ts'\nimport { checkPreflightAbort, invalidPreflight } from '../common/errors.ts'\nimport { EXPORTER_BOUNDARIES } from './config.ts'\nimport { capabilityIdentityConflict } from '../identity/error.ts'\nimport type { ObservationDeliveryAck, ObservationDeliveryBatch, ObservationExportItem } from './delivery-types.ts'\nimport {\n OBSERVATION_EXPORTER_API_VERSION, type ExporterMetadata, type ExporterRegistrationMetadata,\n type ObservationExporterPlugin, type RuntimeObservationExporterRegistration,\n} from './types.ts'\n\nexport interface ExporterIdentityPlan {\n readonly registrations: readonly ExporterRegistrationMetadata[]\n}\nconst sourcesByPlan = new WeakMap<ExporterIdentityPlan, readonly object[]>()\nconst methodsByPlan = new WeakMap<ExporterIdentityPlan, readonly RuntimeObservationExporterRegistration[]>()\n\nfunction boundary(value: unknown): ObservationBoundary {\n if (!EXPORTER_BOUNDARIES.includes(value as ObservationBoundary)) throw new TypeError('Invalid observation boundary')\n return value as ObservationBoundary\n}\n\nexport function exporterMetadata(source: object): ExporterMetadata {\n const id = boundedText(ownData(source, 'id'), COMPOSITION_LIMITS.identityBytes)\n const supportedBoundaries = arrayData(ownData(source, 'supportedBoundaries'), EXPORTER_BOUNDARIES.length).map(boundary)\n if (supportedBoundaries.length === 0 || new Set(supportedBoundaries).size !== supportedBoundaries.length) {\n throw new TypeError('Exporter boundaries must be non-empty and unique')\n }\n return Object.freeze({ id, supportedBoundaries: Object.freeze(supportedBoundaries) })\n}\n\nexport function captureExporter(source: object, metadata: ExporterMetadata, signal?: AbortSignal): ObservationExporterPlugin {\n checkPreflightAbort(signal)\n const ready = capturedOptionalMethod<[AbortSignal], Promise<void>>(source, 'ready')\n checkPreflightAbort(signal)\n const stage = capturedOptionalMethod<[ObservationExportItem], void | Promise<void>>(source, 'stage')\n checkPreflightAbort(signal)\n const send = capturedMethod<[ObservationDeliveryBatch, AbortSignal], Promise<ObservationDeliveryAck>>(source, 'export')\n checkPreflightAbort(signal)\n const shutdown = capturedOptionalMethod<[AbortSignal], Promise<void>>(source, 'shutdown')\n checkPreflightAbort(signal)\n return Object.freeze({\n kind: 'observation-exporter', apiVersion: OBSERVATION_EXPORTER_API_VERSION, ...metadata,\n ...(ready === undefined ? {} : { ready }), ...(stage === undefined ? {} : { stage }),\n export: send, ...(shutdown === undefined ? {} : { shutdown }),\n })\n}\n\n/** Entire metadata pass is inert: no lifecycle method lookup and no ownership transfer. */\nexport function preflightExporterIdentities(input: unknown, signal?: AbortSignal): ExporterIdentityPlan {\n checkPreflightAbort(signal)\n const failures = new Set<unknown>()\n const fail = (error: Error): never => { failures.add(error); throw error }\n try {\n const sources: object[] = []\n const ids = new Map<string, number>()\n const registrations = arrayData(input, COMPOSITION_LIMITS.exporters).map((input, index) => {\n checkPreflightAbort(signal)\n const registration = objectValue(input)\n const source = objectValue(ownData(registration, 'exporter'))\n if (ownData(source, 'kind', false) !== 'observation-exporter') fail(invalidPreflight('CAPABILITY_KIND_MISMATCH'))\n if (ownData(source, 'apiVersion', false) !== OBSERVATION_EXPORTER_API_VERSION) fail(invalidPreflight('CAPABILITY_API_UNSUPPORTED'))\n const exporter = exporterMetadata(source)\n const first = ids.get(exporter.id)\n if (first !== undefined) fail(invalidPreflight('CAPABILITY_ID_CONFLICT',\n capabilityIdentityConflict('observation-exporter-id', first, index)))\n ids.set(exporter.id, index)\n const ownership = ownData(registration, 'ownership')\n const requirement = ownData(registration, 'requirement')\n const selected = boundary(ownData(registration, 'boundary'))\n if (ownership !== 'owned' && ownership !== 'borrowed') throw new TypeError('Explicit exporter ownership is required')\n if (requirement !== 'required' && requirement !== 'best-effort') throw new TypeError('Invalid exporter requirement')\n if (!exporter.supportedBoundaries.includes(selected)) fail(invalidPreflight('OBSERVATION_BOUNDARY_UNSUPPORTED'))\n sources.push(source)\n return Object.freeze({ exporter, ownership, requirement, boundary: selected })\n })\n checkPreflightAbort(signal)\n const plan = Object.freeze({ registrations: Object.freeze(registrations) })\n sourcesByPlan.set(plan, Object.freeze(sources))\n return plan\n } catch (error) {\n checkPreflightAbort(signal)\n if (failures.has(error)) throw error\n throw invalidPreflight()\n }\n}\n\n/** Only after all runtime provider/exporter identities have passed. A failed capture cannot be retried. */\nexport function captureExporterMethods(plan: ExporterIdentityPlan, signal?: AbortSignal): readonly RuntimeObservationExporterRegistration[] {\n checkPreflightAbort(signal)\n const previous = methodsByPlan.get(plan)\n if (previous !== undefined) return previous\n const sources = sourcesByPlan.get(plan)\n if (sources === undefined) throw invalidPreflight()\n sourcesByPlan.delete(plan)\n try {\n const registrations = Object.freeze(plan.registrations.map((registration, index) => {\n checkPreflightAbort(signal)\n return Object.freeze({ ...registration, exporter: captureExporter(sources[index]!, registration.exporter, signal) })\n }))\n checkPreflightAbort(signal)\n methodsByPlan.set(plan, registrations)\n return registrations\n } catch {\n checkPreflightAbort(signal)\n throw invalidPreflight()\n }\n}\n"],"mappings":"4dAeA,MAAM,EAAgB,IAAI,QACpB,EAAgB,IAAI,QAE1B,SAAS,EAAS,EAAqC,CACrD,GAAI,CAAC,EAAoB,SAAS,CAA4B,EAAG,MAAU,UAAU,8BAA8B,EACnH,OAAO,CACT,CAEA,SAAgB,EAAiB,EAAkC,CACjE,IAAM,EAAK,EAAY,EAAQ,EAAQ,IAAI,EAAG,EAAmB,aAAa,EACxE,EAAsB,EAAU,EAAQ,EAAQ,qBAAqB,EAAG,EAAoB,MAAM,CAAC,CAAC,IAAI,CAAQ,EACtH,GAAI,EAAoB,SAAW,GAAK,IAAI,IAAI,CAAmB,CAAC,CAAC,OAAS,EAAoB,OAChG,MAAU,UAAU,kDAAkD,EAExE,OAAO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C9B,CACT,MAAQ,CAEN,MADA,EAAoB,CAAM,EACpB,EAAiB,CACzB,CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ObservationBoundary } from "../../observation/port.js";
|
|
2
|
+
import { ObservationDeliveryAck, ObservationDeliveryBatch, ObservationExportItem } from "../../agent/accounting/delivery-types.js";
|
|
3
|
+
//#region src/composition/exporter/types.d.ts
|
|
4
|
+
declare const OBSERVATION_EXPORTER_API_VERSION: 1;
|
|
5
|
+
/** Distinct from the preserved marker-free advanced-bus ObservationExporter. */
|
|
6
|
+
interface ObservationExporterPlugin {
|
|
7
|
+
readonly kind: 'observation-exporter';
|
|
8
|
+
readonly apiVersion: typeof OBSERVATION_EXPORTER_API_VERSION;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly supportedBoundaries: readonly ObservationBoundary[];
|
|
11
|
+
readonly ready?: (signal: AbortSignal) => Promise<void>;
|
|
12
|
+
readonly stage?: (item: ObservationExportItem) => void | Promise<void>;
|
|
13
|
+
readonly export: (batch: ObservationDeliveryBatch, signal: AbortSignal) => Promise<ObservationDeliveryAck>;
|
|
14
|
+
readonly shutdown?: (signal: AbortSignal) => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
type ObservationExporterPluginDefinition = Omit<ObservationExporterPlugin, 'kind' | 'apiVersion'>;
|
|
17
|
+
interface RuntimeObservationExporterRegistration {
|
|
18
|
+
readonly exporter: ObservationExporterPlugin;
|
|
19
|
+
readonly ownership: 'borrowed' | 'owned';
|
|
20
|
+
readonly requirement: 'required' | 'best-effort';
|
|
21
|
+
readonly boundary: ObservationBoundary;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { OBSERVATION_EXPORTER_API_VERSION, ObservationExporterPlugin, ObservationExporterPluginDefinition, RuntimeObservationExporterRegistration };
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/composition/exporter/types.ts"],"mappings":";;;cAGa;;UAGI;WACN;WACA,mBAAmB;WACnB;WACA,8BAA8B;WAC9B,SAAS,QAAQ,gBAAgB;WACjC,SAAS,MAAM,iCAAiC;WAChD,SAAS,OAAO,0BAA0B,QAAQ,gBAAgB,QAAQ;WAC1E,YAAY,QAAQ,gBAAgB;;KAGnC,sCAAsC,KAAK;UAEtC;WACN,UAAU;WACV;WACA;WACA,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/composition/exporter/types.ts"],"sourcesContent":["import type { ObservationBoundary } from '../../observation/index.ts'\nimport type { ObservationDeliveryAck, ObservationDeliveryBatch, ObservationExportItem } from './delivery-types.ts'\n\nexport const OBSERVATION_EXPORTER_API_VERSION = 1 as const\n\n/** Distinct from the preserved marker-free advanced-bus ObservationExporter. */\nexport interface ObservationExporterPlugin {\n readonly kind: 'observation-exporter'\n readonly apiVersion: typeof OBSERVATION_EXPORTER_API_VERSION\n readonly id: string\n readonly supportedBoundaries: readonly ObservationBoundary[]\n readonly ready?: (signal: AbortSignal) => Promise<void>\n readonly stage?: (item: ObservationExportItem) => void | Promise<void>\n readonly export: (batch: ObservationDeliveryBatch, signal: AbortSignal) => Promise<ObservationDeliveryAck>\n readonly shutdown?: (signal: AbortSignal) => Promise<void>\n}\n\nexport type ObservationExporterPluginDefinition = Omit<ObservationExporterPlugin, 'kind' | 'apiVersion'>\n\nexport interface RuntimeObservationExporterRegistration {\n readonly exporter: ObservationExporterPlugin\n readonly ownership: 'borrowed' | 'owned'\n readonly requirement: 'required' | 'best-effort'\n readonly boundary: ObservationBoundary\n}\n\nexport interface ExporterMetadata {\n readonly id: string\n readonly supportedBoundaries: readonly ObservationBoundary[]\n}\n\nexport interface ExporterRegistrationMetadata extends Omit<RuntimeObservationExporterRegistration, 'exporter'> {\n readonly exporter: ExporterMetadata\n}\n"],"mappings":"AAGA,MAAa,EAAmC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{assertCapabilityIdentityNamespace as e}from"../../errors/capability-identity.js";import{SKILL_TOOL_NAMES as t}from"../../agent/skill/tools.js";function n(n){let r=n.skills??[],i=n.allowedSkillIds?.length!==0&&(r.length>0||(n.allowedSkillIds?.length??0)>0);e(`TOOL_NAME_CONFLICT`,`tool-name`,[...n.tools?.map(e=>e.name)??[],...n.nativeTools?.map(e=>e.name)??[],...n.additionalToolNames??[],...i?t:[]]),e(`SKILL_ID_CONFLICT`,`skill-id`,r.filter(e=>e.kind===`skill`).map(e=>e.id)),e(`SKILL_PROVIDER_ID_CONFLICT`,`skill-provider-id`,r.filter(e=>e.kind===`skill-provider`).map(e=>e.id))}export{n as assertAgentIdentitySnapshot};
|
|
2
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","names":[],"sources":["../../../src/composition/identity/agent.ts"],"sourcesContent":["import type { NativeToolSchema } from '../../contract/tool.ts'\nimport { SKILL_TOOL_NAMES } from '../../agent/skill/tools.ts'\nimport type { ToolDefinition } from '../../agent/tool/definition.ts'\nimport type { RuntimeSkillSource } from '../skill-provider/types.ts'\nimport { assertCapabilityIdentityNamespace } from './error.ts'\n\ninterface AgentIdentitySnapshot {\n readonly tools?: readonly ToolDefinition[]\n readonly nativeTools?: readonly NativeToolSchema[]\n readonly skills?: readonly RuntimeSkillSource[]\n readonly allowedSkillIds?: readonly string[]\n readonly additionalToolNames?: readonly string[]\n}\n\n/** Validate the executable identities visible in one immutable agent/session snapshot. */\nexport function assertAgentIdentitySnapshot(input: AgentIdentitySnapshot): void {\n const skills = input.skills ?? []\n const skillRuntimeEnabled = input.allowedSkillIds?.length !== 0\n && (skills.length > 0 || (input.allowedSkillIds?.length ?? 0) > 0)\n assertCapabilityIdentityNamespace('TOOL_NAME_CONFLICT', 'tool-name', [\n ...input.tools?.map(tool => tool.name) ?? [],\n ...input.nativeTools?.map(tool => tool.name) ?? [],\n ...input.additionalToolNames ?? [],\n ...(skillRuntimeEnabled ? SKILL_TOOL_NAMES : []),\n ])\n assertCapabilityIdentityNamespace('SKILL_ID_CONFLICT', 'skill-id', skills\n .filter(source => source.kind === 'skill').map(source => source.id))\n assertCapabilityIdentityNamespace('SKILL_PROVIDER_ID_CONFLICT', 'skill-provider-id', skills\n .filter(source => source.kind === 'skill-provider').map(source => source.id))\n}\n"],"mappings":"sJAeA,SAAgB,EAA4B,EAAoC,CAC9E,IAAM,EAAS,EAAM,QAAU,CAAC,EAC1B,EAAsB,EAAM,iBAAiB,SAAW,IACxD,EAAO,OAAS,IAAM,EAAM,iBAAiB,QAAU,GAAK,GAClE,EAAkC,qBAAsB,YAAa,CACnE,GAAG,EAAM,OAAO,IAAI,GAAQ,EAAK,IAAI,GAAK,CAAC,EAC3C,GAAG,EAAM,aAAa,IAAI,GAAQ,EAAK,IAAI,GAAK,CAAC,EACjD,GAAG,EAAM,qBAAuB,CAAC,EACjC,GAAI,EAAsB,EAAmB,CAAC,CAChD,CAAC,EACD,EAAkC,oBAAqB,WAAY,EAChE,OAAO,GAAU,EAAO,OAAS,OAAO,CAAC,CAAC,IAAI,GAAU,EAAO,EAAE,CAAC,EACrE,EAAkC,6BAA8B,oBAAqB,EAClF,OAAO,GAAU,EAAO,OAAS,gBAAgB,CAAC,CAAC,IAAI,GAAU,EAAO,EAAE,CAAC,CAChF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=class extends Error{reason;constructor(e){super(`Capability operation did not complete`),this.reason=e,this.name=`BoundaryFailure`}};async function t(t,n,r,i){let a=n-t.platform.monotonicNow();if(i?.aborted)throw new e(`aborted`);if(!Number.isFinite(a)||a<=0)throw new e(`timed-out`);let o=t.cancellation(i===void 0?[]:[i],Math.ceil(a)),s=()=>i?.aborted?`aborted`:o.signal.aborted||t.platform.monotonicNow()>=n?`timed-out`:`failed`,c=()=>{if(t.platform.monotonicNow()>=n&&o.cancel(),o.signal.aborted)throw new e(s())},l=()=>void 0;try{let n=new Promise((n,r)=>{l=t.onAbort(o.signal,()=>r(new e(s())))}),i=Promise.resolve().then(()=>(c(),r(o.signal))).then(e=>(c(),e),()=>{throw new e(s())});return await Promise.race([i,n])}finally{l(),o.dispose()}}export{e as BoundaryFailure,t as atDeadline};
|
|
2
|
+
//# sourceMappingURL=bounded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded.js","names":[],"sources":["../../../src/composition/lifecycle/bounded.ts"],"sourcesContent":["import { RuntimeResources } from '../../platform/resources.ts'\n\nexport class BoundaryFailure extends Error {\n constructor(readonly reason: 'failed' | 'timed-out' | 'aborted') {\n super('Capability operation did not complete')\n this.name = 'BoundaryFailure'\n }\n}\n\n/** One absolute deadline across sequential work; detached late promises stay observed. */\nexport async function atDeadline<T>(\n resources: RuntimeResources,\n deadlineAt: number,\n work: (signal: AbortSignal) => T | Promise<T>,\n caller?: AbortSignal,\n): Promise<T> {\n const remaining = deadlineAt - resources.platform.monotonicNow()\n if (caller?.aborted) throw new BoundaryFailure('aborted')\n if (!Number.isFinite(remaining) || remaining <= 0) throw new BoundaryFailure('timed-out')\n const scope = resources.cancellation(caller === undefined ? [] : [caller], Math.ceil(remaining))\n const reason = (): BoundaryFailure['reason'] => caller?.aborted ? 'aborted'\n : scope.signal.aborted || resources.platform.monotonicNow() >= deadlineAt ? 'timed-out' : 'failed'\n const checkDeadline = (): void => {\n if (resources.platform.monotonicNow() >= deadlineAt) scope.cancel()\n if (scope.signal.aborted) throw new BoundaryFailure(reason())\n }\n let release = (): void => undefined\n try {\n const interrupted = new Promise<never>((_resolve, reject) => {\n release = resources.onAbort(scope.signal, () => reject(new BoundaryFailure(reason())))\n })\n const task = Promise.resolve().then(() => {\n checkDeadline()\n return work(scope.signal)\n }).then(value => {\n checkDeadline()\n return value\n }, () => { throw new BoundaryFailure(reason()) })\n return await Promise.race([task, interrupted])\n } finally { release(); scope.dispose() }\n}\n"],"mappings":"AAEA,IAAa,EAAb,cAAqC,KAAM,CACpB,OAArB,YAAY,EAAqD,CAC/D,MAAM,uCAAuC,EAD1B,KAAA,OAAA,EAEnB,KAAK,KAAO,iBACd,CACF,EAGA,eAAsB,EACpB,EACA,EACA,EACA,EACY,CACZ,IAAM,EAAY,EAAa,EAAU,SAAS,aAAa,EAC/D,GAAI,GAAQ,QAAS,MAAM,IAAI,EAAgB,SAAS,EACxD,GAAI,CAAC,OAAO,SAAS,CAAS,GAAK,GAAa,EAAG,MAAM,IAAI,EAAgB,WAAW,EACxF,IAAM,EAAQ,EAAU,aAAa,IAAW,IAAA,GAAY,CAAC,EAAI,CAAC,CAAM,EAAG,KAAK,KAAK,CAAS,CAAC,EACzF,MAA0C,GAAQ,QAAU,UAC9D,EAAM,OAAO,SAAW,EAAU,SAAS,aAAa,GAAK,EAAa,YAAc,SACtF,MAA4B,CAEhC,GADI,EAAU,SAAS,aAAa,GAAK,GAAY,EAAM,OAAO,EAC9D,EAAM,OAAO,QAAS,MAAM,IAAI,EAAgB,EAAO,CAAC,CAC9D,EACI,MAAsB,IAAA,GAC1B,GAAI,CACF,IAAM,EAAc,IAAI,SAAgB,EAAU,IAAW,CAC3D,EAAU,EAAU,QAAQ,EAAM,WAAc,EAAO,IAAI,EAAgB,EAAO,CAAC,CAAC,CAAC,CACvF,CAAC,EACK,EAAO,QAAQ,QAAQ,CAAC,CAAC,UAC7B,EAAc,EACP,EAAK,EAAM,MAAM,EACzB,CAAC,CAAC,KAAK,IACN,EAAc,EACP,OACA,CAAE,MAAM,IAAI,EAAgB,EAAO,CAAC,CAAE,CAAC,EAChD,OAAO,MAAM,QAAQ,KAAK,CAAC,EAAM,CAAW,CAAC,CAC/C,QAAU,CAAE,EAAQ,EAAG,EAAM,QAAQ,CAAE,CACzC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{timeoutValue as e}from"../../platform/config.js";import{AgentSdkError as t}from"../../errors/agent-sdk-error.js";import{RUNTIME_OPERATION_KINDS as n}from"./types.js";function r(){return new t(`Runtime operation was cancelled`,`RUNTIME_OPERATION_ABORTED`)}var i=class{resources;state=`active`;root;active=new Set;settledListeners=new Set;quiescence;quiesced=!1;deadlineAt;constructor(e){this.resources=e,this.root=e.platform.controller()}get status(){return this.state}get activeCount(){return this.active.size}assertActive(){if(this.state!==`active`)throw new t(`Runtime is not accepting operations`,this.state===`closed`?`RUNTIME_CLOSED`:`RUNTIME_CLOSING`)}acquire(t,i={}){if(this.assertActive(),!n.includes(t))throw TypeError(`Unknown runtime operation kind`);let a=i.signal,o=i.timeoutMs;if(o!==void 0&&e(o),a?.aborted)throw r();this.assertActive();let s=this.resources.cancellation([this.root.signal,...a===void 0?[]:[a]],o),c=()=>void 0,l=new Promise(e=>{c=e}),u={kind:t,cancellation:s,seal:c,settled:!1,sealed:!1};try{this.assertActive()}catch(e){throw s.dispose(),e}return this.active.add(u),Object.freeze({signal:s.signal,whenSealed:l,publish:e=>u.sealed||u.settled||this.state===`closed`?!1:(e(),!0),settle:()=>{if(!u.settled){u.settled=!0,this.active.delete(u),s.dispose();for(let e of[...this.settledListeners])e()}}})}execute(e,t,n){let i=this.acquire(e,t),a=Promise.resolve().then(()=>{if(i.signal.aborted)throw r();return n(i)}).then(e=>{if(i.signal.aborted)throw r();return e}),o=i.whenSealed.then(()=>{throw r()}),s=Promise.race([a,o]).finally(()=>i.settle());return s.catch(()=>void 0),s}beginClose(t){if(this.quiescence!==void 0)return this.quiescence;let r=e(t.timeoutMs),i=t.signal,a=this.resources.platform.monotonicNow()+r,o;this.quiescence=new Promise(e=>{o=e}),this.deadlineAt=a,this.state=`closing`;let s=[...this.active],c=!1,l=!1,u=[],d=e=>{if(c)return;c=!0,this.settledListeners.delete(f);for(let e of u.splice(0).reverse())e();for(let e of s)e.settled||(e.sealed=!0,e.cancellation.dispose(),this.active.delete(e),e.seal());let t=Object.freeze(n.map(e=>{let t=s.filter(t=>t.kind===e),n=t.filter(e=>e.settled).length;return Object.freeze({kind:e,activeAtClose:t.length,aborted:t.filter(e=>e.cancellation.signal.aborted).length,settled:n,unsettled:t.length-n})})),r=t[0];this.quiesced=!0,o(Object.freeze({quiescenceEnd:e,deadlineReached:e===`timeout`,operations:t,activeRunsAtClose:r.activeAtClose,abortedRuns:r.aborted,unsettledRuns:r.unsettled}))},f=()=>{l&&(i?.aborted?d(`caller-abort`):s.every(e=>e.settled)&&d(`settled`))};if(this.settledListeners.add(f),this.root.abort(Error(`Runtime is closing`)),l=!0,f(),!c&&i!==void 0){let e=this.resources.onAbort(i,()=>d(`caller-abort`));c?e():u.push(e)}if(!c){let e=Math.max(0,a-this.resources.platform.monotonicNow());e===0?d(`timeout`):u.push(this.resources.after(Math.ceil(e),()=>d(`timeout`)))}return this.quiescence}remainingCloseMs(){if(this.deadlineAt===void 0)throw Error(`Runtime close has not started`);return Math.max(0,this.deadlineAt-this.resources.platform.monotonicNow())}closeDeadlineAt(){if(this.deadlineAt===void 0)throw Error(`Runtime close has not started`);return this.deadlineAt}finishClose(){if(this.state!==`closed`){if(!this.quiesced)throw Error(`Runtime operations have not quiesced`);this.state=`closed`,this.resources.close()}}};export{i as RuntimeOperations};
|
|
2
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","names":[],"sources":["../../../src/composition/lifecycle/operations.ts"],"sourcesContent":["import { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { timeoutValue } from '../../platform/config.ts'\nimport { RuntimeResources, type CancellationScope } from '../../platform/resources.ts'\nimport {\n RUNTIME_OPERATION_KINDS, type OperationLease, type OperationOptions,\n type QuiescenceReport, type RuntimeOperationKind,\n} from './types.ts'\n\ninterface Entry {\n readonly kind: RuntimeOperationKind\n readonly cancellation: CancellationScope\n readonly seal: () => void\n settled: boolean\n sealed: boolean\n}\n\nfunction operationCancelled(): AgentSdkError {\n return new AgentSdkError('Runtime operation was cancelled', 'RUNTIME_OPERATION_ABORTED')\n}\n\n/** Atomic admission, quiescence and generation sealing shared by every runtime operation. */\nexport class RuntimeOperations {\n private state: 'active' | 'closing' | 'closed' = 'active'\n private readonly root: AbortController\n private readonly active = new Set<Entry>()\n private readonly settledListeners = new Set<() => void>()\n private quiescence: Promise<QuiescenceReport> | undefined\n private quiesced = false\n private deadlineAt: number | undefined\n\n constructor(private readonly resources: RuntimeResources) {\n this.root = resources.platform.controller()\n }\n\n get status(): 'active' | 'closing' | 'closed' { return this.state }\n get activeCount(): number { return this.active.size }\n\n assertActive(): void {\n if (this.state !== 'active') throw new AgentSdkError(\n 'Runtime is not accepting operations', this.state === 'closed' ? 'RUNTIME_CLOSED' : 'RUNTIME_CLOSING',\n )\n }\n\n acquire(kind: RuntimeOperationKind, options: OperationOptions = {}): OperationLease {\n this.assertActive()\n if (!RUNTIME_OPERATION_KINDS.includes(kind)) throw new TypeError('Unknown runtime operation kind')\n const signal = options.signal\n const timeoutMs = options.timeoutMs\n if (timeoutMs !== undefined) timeoutValue(timeoutMs)\n if (signal?.aborted) throw operationCancelled()\n this.assertActive()\n const cancellation = this.resources.cancellation(\n [this.root.signal, ...signal === undefined ? [] : [signal]], timeoutMs,\n )\n let seal = (): void => undefined\n const whenSealed = new Promise<void>(resolve => { seal = resolve })\n const entry: Entry = { kind, cancellation, seal, settled: false, sealed: false }\n // Recheck after captured platform calls; even a reentrant host cannot admit work after close.\n try { this.assertActive() } catch (error) { cancellation.dispose(); throw error }\n this.active.add(entry)\n return Object.freeze({\n signal: cancellation.signal, whenSealed,\n publish: (commit: () => void): boolean => {\n if (entry.sealed || entry.settled || this.state === 'closed') return false\n commit()\n return true\n },\n settle: (): void => {\n if (entry.settled) return\n entry.settled = true\n this.active.delete(entry)\n cancellation.dispose()\n for (const notify of [...this.settledListeners]) notify()\n },\n })\n }\n\n /** Admit before evaluating an executable callback and settle public waits even if its work ignores abort. */\n execute<T>(kind: RuntimeOperationKind, options: OperationOptions, work: (lease: OperationLease) => Promise<T>): Promise<T> {\n const lease = this.acquire(kind, options)\n const task = Promise.resolve().then(() => {\n if (lease.signal.aborted) throw operationCancelled()\n return work(lease)\n }).then(value => {\n if (lease.signal.aborted) throw operationCancelled()\n return value\n })\n const sealed = lease.whenSealed.then((): never => { throw operationCancelled() })\n const result = Promise.race([task, sealed]).finally(() => lease.settle())\n // Observing internal promises does not replace the caller's rejecting result promise.\n void result.catch(() => undefined)\n return result\n }\n\n /** First call locks admission synchronously. Later calls do not read or replace options. */\n beginClose(options: { readonly timeoutMs: number; readonly signal?: AbortSignal }): Promise<QuiescenceReport> {\n if (this.quiescence !== undefined) return this.quiescence\n const timeoutMs = timeoutValue(options.timeoutMs)\n const caller = options.signal\n const deadline = this.resources.platform.monotonicNow() + timeoutMs\n let resolve!: (report: QuiescenceReport) => void\n this.quiescence = new Promise<QuiescenceReport>(done => { resolve = done })\n this.deadlineAt = deadline\n this.state = 'closing'\n const entries = [...this.active]\n let ended = false\n let rootAbortComplete = false\n const releases: (() => void)[] = []\n const finish = (reason: QuiescenceReport['quiescenceEnd']): void => {\n if (ended) return\n ended = true\n this.settledListeners.delete(checkSettled)\n for (const release of releases.splice(0).reverse()) release()\n for (const entry of entries) {\n if (entry.settled) continue\n entry.sealed = true\n entry.cancellation.dispose()\n this.active.delete(entry)\n entry.seal()\n }\n const operations = Object.freeze(RUNTIME_OPERATION_KINDS.map(kind => {\n const rows = entries.filter(entry => entry.kind === kind)\n const settled = rows.filter(entry => entry.settled).length\n return Object.freeze({\n kind, activeAtClose: rows.length, aborted: rows.filter(entry => entry.cancellation.signal.aborted).length,\n settled, unsettled: rows.length - settled,\n })\n }))\n const runs = operations[0]!\n this.quiesced = true\n resolve(Object.freeze({\n quiescenceEnd: reason, deadlineReached: reason === 'timeout', operations,\n activeRunsAtClose: runs.activeAtClose, abortedRuns: runs.aborted, unsettledRuns: runs.unsettled,\n }))\n }\n const checkSettled = (): void => {\n // Settlement callbacks run inside root abort dispatch. Do not remove later\n // leases' root listeners until all of them have received cancellation.\n if (!rootAbortComplete) return\n if (caller?.aborted) finish('caller-abort')\n else if (entries.every(entry => entry.settled)) finish('settled')\n }\n this.settledListeners.add(checkSettled)\n this.root.abort(new Error('Runtime is closing'))\n rootAbortComplete = true\n checkSettled()\n if (!ended && caller !== undefined) {\n const release = this.resources.onAbort(caller, () => finish('caller-abort'))\n if (ended) release(); else releases.push(release)\n }\n if (!ended) {\n const remaining = Math.max(0, deadline - this.resources.platform.monotonicNow())\n if (remaining === 0) finish('timeout')\n else releases.push(this.resources.after(Math.ceil(remaining), () => finish('timeout')))\n }\n return this.quiescence\n }\n\n /** Shared deadline continues across team/provider cleanup and observation flush/shutdown. */\n remainingCloseMs(): number {\n if (this.deadlineAt === undefined) throw new Error('Runtime close has not started')\n return Math.max(0, this.deadlineAt - this.resources.platform.monotonicNow())\n }\n\n /** Absolute shared deadline used by every cleanup phase after quiescence. */\n closeDeadlineAt(): number {\n if (this.deadlineAt === undefined) throw new Error('Runtime close has not started')\n return this.deadlineAt\n }\n\n /** Called only after component cleanup and final observation delivery. */\n finishClose(): void {\n if (this.state === 'closed') return\n if (!this.quiesced) throw new Error('Runtime operations have not quiesced')\n this.state = 'closed'\n this.resources.close()\n }\n}\n"],"mappings":"6KAgBA,SAAS,GAAoC,CAC3C,OAAO,IAAI,EAAc,kCAAmC,2BAA2B,CACzF,CAGA,IAAa,EAAb,KAA+B,CASA,UAR7B,MAAiD,SACjD,KACA,OAA0B,IAAI,IAC9B,iBAAoC,IAAI,IACxC,WACA,SAAmB,GACnB,WAEA,YAAY,EAA8C,CAA7B,KAAA,UAAA,EAC3B,KAAK,KAAO,EAAU,SAAS,WAAW,CAC5C,CAEA,IAAI,QAA0C,CAAE,OAAO,KAAK,KAAM,CAClE,IAAI,aAAsB,CAAE,OAAO,KAAK,OAAO,IAAK,CAEpD,cAAqB,CACnB,GAAI,KAAK,QAAU,SAAU,MAAM,IAAI,EACrC,sCAAuC,KAAK,QAAU,SAAW,iBAAmB,iBACtF,CACF,CAEA,QAAQ,EAA4B,EAA4B,CAAC,EA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ction", "team-operation"];
|
|
3
|
+
type RuntimeOperationKind = typeof RUNTIME_OPERATION_KINDS[number];
|
|
4
|
+
interface RuntimeOperationCloseSummary {
|
|
5
|
+
readonly kind: RuntimeOperationKind;
|
|
6
|
+
readonly activeAtClose: number;
|
|
7
|
+
readonly aborted: number;
|
|
8
|
+
readonly settled: number;
|
|
9
|
+
readonly unsettled: number;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { RUNTIME_OPERATION_KINDS, RuntimeOperationCloseSummary, RuntimeOperationKind };
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/composition/lifecycle/types.ts"],"mappings":";cAAa;KAID,8BAA8B;UAEzB;WACN,MAAM;WACN;WACA;WACA;WACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/composition/lifecycle/types.ts"],"sourcesContent":["export const RUNTIME_OPERATION_KINDS = Object.freeze([\n 'agent-run', 'model-catalog', 'manual-compaction', 'team-operation',\n] as const)\n\nexport type RuntimeOperationKind = typeof RUNTIME_OPERATION_KINDS[number]\n\nexport interface RuntimeOperationCloseSummary {\n readonly kind: RuntimeOperationKind\n readonly activeAtClose: number\n readonly aborted: number\n readonly settled: number\n readonly unsettled: number\n}\n\nexport interface QuiescenceReport {\n readonly quiescenceEnd: 'settled' | 'timeout' | 'caller-abort'\n readonly deadlineReached: boolean\n readonly activeRunsAtClose: number\n readonly abortedRuns: number\n readonly unsettledRuns: number\n readonly operations: readonly RuntimeOperationCloseSummary[]\n}\n\nexport interface OperationLease {\n readonly signal: AbortSignal\n readonly whenSealed: Promise<void>\n /** The callback must commit synchronously and must not perform user code or await. */\n publish(commit: () => void): boolean\n settle(): void\n}\n\nexport interface OperationOptions {\n readonly signal?: AbortSignal\n readonly timeoutMs?: number\n}\n"],"mappings":"AAAA,MAAa,EAA0B,OAAO,OAAO,CACnD,YAAa,gBAAiB,oBAAqB,gBACrD,CAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../src/composition/logging/config.ts"],"sourcesContent":["import type { LogLevel } from '../../logging/types.ts'\n\nexport const LOG_LEVEL_RANK: Readonly<Record<LogLevel, number>> = Object.freeze({\n trace: 0, debug: 1, info: 2, warn: 3, error: 4, fatal: 5,\n})\nexport const RUNTIME_LOG_LIMITS = Object.freeze({ scopeBytes: 64, messageCharacters: 2_048, identityBytes: 128 })\n"],"mappings":"AAEA,MAAa,EAAqD,OAAO,OAAO,CAC9E,MAAO,EAAG,MAAO,EAAG,KAAM,EAAG,KAAM,EAAG,MAAO,EAAG,MAAO,CACzD,CAAC,EACY,EAAqB,OAAO,OAAO,CAAE,WAAY,GAAI,kBAAmB,KAAO,cAAe,GAAI,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{boundedText as e,objectValue as t,ownData as n}from"../../capability/common/data.js";import{RUNTIME_LOG_LIMITS as r}from"./config.js";const i=new Set([`logical-start`,`attempt-start`,`attempt-terminal`,`logical-terminal`]),a=new Set([`success`,`error`,`aborted`,`rejected`,`unknown`]);function o(o){let s=Object.getOwnPropertyDescriptor(o,`integrationSchemaVersion`);if(s===void 0)return!1;if(!(`value`in s)||s.value!==1)throw TypeError(`Invalid integration evidence`);try{let s=t(o);e(n(s,`integrationFamily`),64),e(n(s,`integrationOperation`),64),e(n(s,`operationId`),r.identityBytes);let c=n(s,`kind`);if(!i.has(c))throw TypeError(`Invalid integration evidence`);if(c===`attempt-start`||c===`attempt-terminal`){e(n(s,`attemptId`),r.identityBytes);let t=n(s,`attemptNumber`);if(!Number.isSafeInteger(t)||Number(t)<1)throw TypeError(`Invalid integration evidence`)}if(c===`attempt-terminal`||c===`logical-terminal`){if(!a.has(n(s,`status`)))throw TypeError(`Invalid integration evidence`);let t=n(s,`durationMs`);if(typeof t!=`number`||!Number.isFinite(t)||t<0)throw TypeError(`Invalid integration evidence`);let i=n(s,`errorCode`,!1);i!==void 0&&e(i,r.identityBytes)}return!0}catch{throw TypeError(`Invalid integration evidence`)}}function s(e){try{if(e.name!==`sdk.log`)return!1;let t=Object.getOwnPropertyDescriptor(e.data,`fields`);return t!==void 0&&`value`in t&&o(t.value)}catch{return!1}}export{s as eventHasIntegrationEvidence,o as validateIntegrationEvidence};
|
|
2
|
+
//# sourceMappingURL=integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.js","names":[],"sources":["../../../src/composition/logging/integration.ts"],"sourcesContent":["import type { JsonObject } from '../../primitives/index.ts'\nimport type { ObservationEvent, OperationStatus } from '../../observation/index.ts'\nimport { boundedText, objectValue, ownData } from '../common/data.ts'\nimport { RUNTIME_LOG_LIMITS } from './config.ts'\n\nconst KINDS = new Set(['logical-start', 'attempt-start', 'attempt-terminal', 'logical-terminal'])\nconst STATUSES = new Set<OperationStatus>(['success', 'error', 'aborted', 'rejected', 'unknown'])\n\n/** False is an ordinary log. A present integration marker is validated or rejected, never silently downgraded. */\nexport function validateIntegrationEvidence(fields: Readonly<JsonObject>): boolean {\n const marker = Object.getOwnPropertyDescriptor(fields, 'integrationSchemaVersion')\n if (marker === undefined) return false\n if (!('value' in marker) || marker.value !== 1) throw new TypeError('Invalid integration evidence')\n try {\n const source = objectValue(fields)\n boundedText(ownData(source, 'integrationFamily'), 64)\n boundedText(ownData(source, 'integrationOperation'), 64)\n boundedText(ownData(source, 'operationId'), RUNTIME_LOG_LIMITS.identityBytes)\n const kind = ownData(source, 'kind')\n if (!KINDS.has(kind as string)) throw new TypeError('Invalid integration evidence')\n if (kind === 'attempt-start' || kind === 'attempt-terminal') {\n boundedText(ownData(source, 'attemptId'), RUNTIME_LOG_LIMITS.identityBytes)\n const attempt = ownData(source, 'attemptNumber')\n if (!Number.isSafeInteger(attempt) || Number(attempt) < 1) throw new TypeError('Invalid integration evidence')\n }\n if (kind === 'attempt-terminal' || kind === 'logical-terminal') {\n if (!STATUSES.has(ownData(source, 'status') as OperationStatus)) throw new TypeError('Invalid integration evidence')\n const duration = ownData(source, 'durationMs')\n if (typeof duration !== 'number' || !Number.isFinite(duration) || duration < 0) throw new TypeError('Invalid integration evidence')\n const code = ownData(source, 'errorCode', false)\n if (code !== undefined) boundedText(code, RUNTIME_LOG_LIMITS.identityBytes)\n }\n return true\n } catch { throw new TypeError('Invalid integration evidence') }\n}\n\nexport function eventHasIntegrationEvidence(event: ObservationEvent): boolean {\n try {\n if (event.name !== 'sdk.log') return false\n const fields = Object.getOwnPropertyDescriptor(event.data, 'fields')\n return fields !== undefined && 'value' in fields && validateIntegrationEvidence(fields.value as Readonly<JsonObject>)\n } catch { return false }\n}\n"],"mappings":"6IAKA,MAAM,EAAQ,IAAI,IAAI,CAAC,gBAAiB,gBAAiB,mBAAoB,kBAAkB,CAAC,EAC1F,EAAW,IAAI,IAAqB,CAAC,UAAW,QAAS,UAAW,WAAY,SAAS,CAAC,EAGhG,SAAgB,EAA4B,EAAuC,CACjF,IAAM,EAAS,OAAO,yBAAyB,EAAQ,0BAA0B,EACjF,GAAI,IAAW,IAAA,GAAW,MAAO,GACjC,GAAI,EAAE,UAAW,IAAW,EAAO,QAAU,EAAG,MAAU,UAAU,8BAA8B,EAClG,GAAI,CACF,IAAM,EAAS,EAAY,CAAM,EACjC,EAAY,EAAQ,EAAQ,mBAAmB,EAAG,EAAE,EACpD,EAAY,EAAQ,EAAQ,sBAAsB,EAAG,EAAE,EACvD,EAAY,EAAQ,EAAQ,aAAa,EAAG,EAAmB,aAAa,EAC5E,IAAM,EAAO,EAAQ,EAAQ,MAAM,EACnC,GAAI,CAAC,EAAM,IAAI,CAAc,EAAG,MAAU,UAAU,8BAA8B,EAClF,GAAI,IAAS,iBAAmB,IAAS,mBAAoB,CAC3D,EAAY,EAAQ,EAAQ,WAAW,EAAG,EAAmB,aAAa,EAC1E,IAAM,EAAU,EAAQ,EAAQ,eAAe,EAC/C,GAAI,CAAC,OAAO,cAAc,CAAO,GAAK,OAAO,CAAO,EAAI,EAAG,MAAU,UAAU,8BAA8B,CAC/G,CACA,GAAI,IAAS,oBAAsB,IAAS,mBAAoB,CAC9D,GAAI,CAAC,EAAS,IAAI,EAAQ,EAAQ,QAAQ,CAAoB,EAAG,MAAU,UAAU,8BAA8B,EACnH,IAAM,EAAW,EAAQ,EAAQ,YAAY,EAC7C,GAAI,OAAO,GAAa,UAAY,CAAC,OAAO,SAAS,CAAQ,GAAK,EAAW,EAAG,MAAU,UAAU,8BAA8B,EAClI,IAAM,EAAO,EAAQ,EAAQ,YAAa,EAAK,EAC3C,IAAS,IAAA,IAAW,EAAY,EAAM,EAAmB,aAAa,CAC5E,CACA,MAAO,EACT,MAAQ,CAAE,MAAU,UAAU,8BAA8B,CAAE,CAChE,CAEA,SAAgB,EAA4B,EAAkC,CAC5E,GAAI,CACF,GAAI,EAAM,OAAS,UAAW,MAAO,GACrC,IAAM,EAAS,OAAO,yBAAyB,EAAM,KAAM,QAAQ,EACnE,OAAO,IAAW,IAAA,IAAa,UAAW,GAAU,EAA4B,EAAO,KAA6B,CACtH,MAAQ,CAAE,MAAO,EAAM,CACzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JsonObject } from "../../primitives/json.js";
|
|
2
|
+
//#region src/composition/logging/logger.d.ts
|
|
3
|
+
interface RuntimeLoggerContext {
|
|
4
|
+
readonly scope?: string;
|
|
5
|
+
readonly fields?: Readonly<JsonObject>;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { RuntimeLoggerContext };
|
|
9
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","names":[],"sources":["../../../src/composition/logging/logger.ts"],"mappings":";;UAiBiB;WACN;WACA,SAAS,SAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{deepFreeze as e}from"../../primitives/freeze.js";import{boundedText as t,objectValue as n,ownData as r}from"../../capability/common/data.js";import{bindRuntimeLoggerPlatform as i}from"../../platform/logger-platform.js";import{CLOSED_RUNTIME_LOGGER as a}from"../../logging/types.js";import{redactInlineSecrets as o,sanitizeObservationData as s}from"../../observation/privacy.js";import{cloneJsonObject as c}from"../common/json-data.js";import{LOG_LEVEL_RANK as l,RUNTIME_LOG_LIMITS as u}from"./config.js";import{validateIntegrationEvidence as d}from"./integration.js";function f(e,t={}){return m(e,t)}function p(t,n,r={}){return m(t,r,e({...n}))}function m(i,a,o){let s=n(a);if(Reflect.ownKeys(s).some(e=>typeof e!=`string`||e!==`scope`&&e!==`fields`))throw TypeError(`Invalid runtime logger context`);let c=r(s,`scope`,!1),l=r(s,`fields`,!1),d=c===void 0?void 0:t(c,u.scopeBytes),f=g(l??{},i),p=i.platform.monotonicNow(),m=1;return new h(i,o??e({traceId:i.platform.randomHex(16),spanId:i.platform.randomHex(8),parentSpanId:null,runId:i.platform.randomHex(16)}),p,()=>{if(!Number.isSafeInteger(m))throw RangeError(`Runtime logger sequence exhausted`);return m++},d,f)}var h=class t{target;correlation;origin;nextSequence;scope;bound;constructor(e,t,n,r,a,o){this.target=e,this.correlation=t,this.origin=n,this.nextSequence=r,this.scope=a,this.bound=o,i(this,e.platform)}child(e){return this.target.isClosed()?this:new t(this.target,this.correlation,this.origin,this.nextSequence,this.scope,g({...this.bound,...c(e)},this.target))}trace(e,t){this.write(`trace`,e,t)}debug(e,t){this.write(`debug`,e,t)}info(e,t){this.write(`info`,e,t)}warn(e,t){this.write(`warn`,e,t)}error(e,t){this.write(`error`,e,t)}fatal(e,t){this.write(`fatal`,e,t)}write(t,n,r={}){if(this.target.isClosed())return;if(typeof n!=`string`||n.length>u.messageCharacters)throw TypeError(`Invalid runtime log message`);let i=g({...this.bound,...c(r)},this.target),a=!1;try{a=d(i)}catch(e){throw this.target.integration(`rejected`),e}if(l[t]<l[this.target.minimumLevel]){a&&this.target.integration(`filtered`);return}let s=t===`trace`||t===`debug`?`verbose`:t===`error`||t===`fatal`?`critical`:`normal`,f=this.target.capture(e({schemaVersion:1,eventId:this.target.platform.randomHex(16),sequence:this.nextSequence(),name:`sdk.log`,phase:`point`,occurredAt:new Date(this.target.platform.wallNow()).toISOString(),monotonicMs:Math.max(0,this.target.platform.monotonicNow()-this.origin),priority:s,resource:this.target.resource,correlation:this.correlation,data:{level:t,message:o(n),...this.scope===void 0?{}:{scope:this.scope},fields:i}}));a&&this.target.integration(f.status===`accepted`?`accepted`:`rejected`)}};function g(e,t){let n=c(e);return s({fields:n},t).fields}export{a as CLOSED_RUNTIME_LOGGER,p as createCorrelatedRuntimeLogger,f as createRuntimeLogger};
|
|
2
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","names":[],"sources":["../../../src/composition/logging/logger.ts"],"sourcesContent":["import type { JsonObject } from '../../primitives/index.ts'\nimport { deepFreeze } from '../../primitives/index.ts'\nimport type { CorrelationContext, ObservationEvent, ObservationResource } from '../../observation/index.ts'\nimport type { LogLevel } from '../../logging/types.ts'\nimport type { ContentRedactor } from '../../observation/telemetry-types.ts'\nimport type { SdkLogger } from '../../logging/types.ts'\nimport { redactInlineSecrets, sanitizeObservationData } from '../../observation/privacy.ts'\nimport type { RuntimePlatform } from '../../platform/adapter.ts'\nimport {\n bindRuntimeLoggerPlatform,\n runtimePlatformForLogger as capturedRuntimePlatformForLogger,\n} from '../../platform/logger-platform.ts'\nimport { cloneJsonObject } from '../common/json-data.ts'\nimport { boundedText, objectValue, ownData } from '../common/data.ts'\nimport { LOG_LEVEL_RANK, RUNTIME_LOG_LIMITS } from './config.ts'\nimport { validateIntegrationEvidence } from './integration.ts'\n\nexport interface RuntimeLoggerContext {\n readonly scope?: string\n readonly fields?: Readonly<JsonObject>\n}\nexport interface RuntimeLoggerTarget {\n readonly resource: ObservationResource\n readonly platform: RuntimePlatform\n readonly content: 'none' | 'metadata'\n readonly minimumLevel: LogLevel\n readonly redactors: readonly ContentRedactor[]\n readonly includeErrorStacks: boolean\n isClosed(): boolean\n capture(event: ObservationEvent): { readonly status: 'accepted' | 'rejected' | 'disabled' }\n integration(outcome: 'accepted' | 'filtered' | 'rejected'): void\n}\n\nexport { CLOSED_RUNTIME_LOGGER } from '../../logging/types.ts'\n\nexport function createRuntimeLogger(target: RuntimeLoggerTarget, context: RuntimeLoggerContext = {}): SdkLogger {\n return createLogger(target, context)\n}\n\n/** Internal capability instrumentation reuses the runtime's captured clock/entropy source. */\nexport function runtimePlatformForLogger(logger: SdkLogger): RuntimePlatform | undefined {\n return capturedRuntimePlatformForLogger(logger)\n}\n\n/** Internal run binding; public RuntimeLoggerContext deliberately cannot provide correlation IDs. */\nexport function createCorrelatedRuntimeLogger(\n target: RuntimeLoggerTarget,\n correlation: CorrelationContext,\n context: RuntimeLoggerContext = {},\n): SdkLogger {\n return createLogger(target, context, deepFreeze({ ...correlation }))\n}\n\nfunction createLogger(\n target: RuntimeLoggerTarget, context: RuntimeLoggerContext,\n fixedCorrelation?: CorrelationContext,\n): SdkLogger {\n const source = objectValue(context)\n const keys = Reflect.ownKeys(source)\n if (keys.some(key => typeof key !== 'string' || (key !== 'scope' && key !== 'fields'))) throw new TypeError('Invalid runtime logger context')\n const rawScope = ownData(source, 'scope', false), rawFields = ownData(source, 'fields', false)\n const scope = rawScope === undefined ? undefined : boundedText(rawScope, RUNTIME_LOG_LIMITS.scopeBytes)\n const fields = safeFields((rawFields ?? {}) as Readonly<JsonObject>, target)\n const origin = target.platform.monotonicNow()\n let sequence = 1\n const correlation = fixedCorrelation ?? deepFreeze<CorrelationContext>({\n traceId: target.platform.randomHex(16) as CorrelationContext['traceId'],\n spanId: target.platform.randomHex(8) as CorrelationContext['spanId'],\n parentSpanId: null,\n runId: target.platform.randomHex(16),\n })\n const nextSequence = (): number => {\n if (!Number.isSafeInteger(sequence)) throw new RangeError('Runtime logger sequence exhausted')\n return sequence++\n }\n return new RuntimeBoundLogger(target, correlation, origin, nextSequence, scope, fields)\n}\n\nclass RuntimeBoundLogger implements SdkLogger {\n constructor(\n private readonly target: RuntimeLoggerTarget,\n private readonly correlation: CorrelationContext,\n private readonly origin: number,\n private readonly nextSequence: () => number,\n private readonly scope: string | undefined,\n private readonly bound: Readonly<JsonObject>,\n ) { bindRuntimeLoggerPlatform(this, target.platform) }\n\n child(fields: Readonly<JsonObject>): SdkLogger {\n if (this.target.isClosed()) return this\n return new RuntimeBoundLogger(this.target, this.correlation, this.origin, this.nextSequence,\n this.scope, safeFields({ ...this.bound, ...cloneJsonObject(fields) }, this.target))\n }\n trace(message: string, fields?: Readonly<JsonObject>): void { this.write('trace', message, fields) }\n debug(message: string, fields?: Readonly<JsonObject>): void { this.write('debug', message, fields) }\n info(message: string, fields?: Readonly<JsonObject>): void { this.write('info', message, fields) }\n warn(message: string, fields?: Readonly<JsonObject>): void { this.write('warn', message, fields) }\n error(message: string, fields?: Readonly<JsonObject>): void { this.write('error', message, fields) }\n fatal(message: string, fields?: Readonly<JsonObject>): void { this.write('fatal', message, fields) }\n\n private write(level: LogLevel, message: string, fields: Readonly<JsonObject> = {}): void {\n if (this.target.isClosed()) return\n if (typeof message !== 'string' || message.length > RUNTIME_LOG_LIMITS.messageCharacters) throw new TypeError('Invalid runtime log message')\n const merged = safeFields({ ...this.bound, ...cloneJsonObject(fields) }, this.target)\n let integration = false\n try { integration = validateIntegrationEvidence(merged) }\n catch (error) { this.target.integration('rejected'); throw error }\n if (LOG_LEVEL_RANK[level] < LOG_LEVEL_RANK[this.target.minimumLevel]) {\n if (integration) this.target.integration('filtered')\n return\n }\n const priority = level === 'trace' || level === 'debug' ? 'verbose'\n : level === 'error' || level === 'fatal' ? 'critical' : 'normal'\n const result = this.target.capture(deepFreeze({\n schemaVersion: 1, eventId: this.target.platform.randomHex(16), sequence: this.nextSequence(), name: 'sdk.log', phase: 'point',\n occurredAt: new Date(this.target.platform.wallNow()).toISOString(),\n monotonicMs: Math.max(0, this.target.platform.monotonicNow() - this.origin), priority,\n resource: this.target.resource, correlation: this.correlation,\n data: { level, message: redactInlineSecrets(message), ...(this.scope === undefined ? {} : { scope: this.scope }), fields: merged },\n }))\n if (integration) this.target.integration(result.status === 'accepted' ? 'accepted' : 'rejected')\n }\n}\n\nfunction safeFields(\n fields: Readonly<JsonObject>,\n target: Pick<RuntimeLoggerTarget, 'content' | 'redactors' | 'includeErrorStacks'>,\n): Readonly<JsonObject> {\n const cloned = cloneJsonObject(fields)\n const wrapped = sanitizeObservationData({ fields: cloned }, target)\n return wrapped.fields as Readonly<JsonObject>\n}\n"],"mappings":"8jBAmCA,SAAgB,EAAoB,EAA6B,EAAgC,CAAC,EAAc,CAC9G,OAAO,EAAa,EAAQ,CAAO,CACrC,CAQA,SAAgB,EACd,EACA,EACA,EAAgC,CAAC,EACtB,CACX,OAAO,EAAa,EAAQ,EAAS,EAAW,CAAE,GAAG,CAAY,CAAC,CAAC,CACrE,CAEA,SAAS,EACP,EAA6B,EAC7B,EACW,CACX,IAAM,EAAS,EAAY,CAAO,EAElC,GADa,QAAQ,QAAQ,CACtB,CAAC,CAAC,KAAK,GAAO,OAAO,GAAQ,UAAa,IAAQ,SAAW,IAAQ,QAAS,EAAG,MAAU,UAAU,gCAAgC,EAC5I,IAAM,EAAW,EAAQ,EAAQ,QAAS,EAAK,EAAG,EAAY,EAAQ,EAAQ,SAAU,EAAK,EACvF,EAAQ,IAAa,IAAA,GAAY,IAAA,GAAY,EAAY,EAAU,EAAmB,UAAU,EAChG,EAAS,EAAY,GAAa,CAAC,EAA4B,CAAM,EACrE,EAAS,EAAO,SAAS,aAAa,EACxC,EAAW,EAWf,OAAO,IAAI,EAAmB,EAVV,GAAoB,EAA+B,CACrE,QAAS,EAAO,SAAS,UAAU,EAAE,EACrC,OAAQ,EAAO,SAAS,UAAU,CAAC,EACnC,aAAc,KACd,MAAO,EAAO,SAAS,UAAU,EAAE,CACrC,CAAC,EAKkD,MAJhB,CACjC,GAAI,CAA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EAAc,GAClB,GAAI,CAAE,EAAc,EAA4B,CAAM,CAAE,OACjD,EAAO,CAAuC,MAArC,KAAK,OAAO,YAAY,UAAU,EAAS,CAAM,CACjE,GAAI,EAAe,GAAS,EAAe,KAAK,OAAO,cAAe,CAChE,GAAa,KAAK,OAAO,YAAY,UAAU,EACnD,MACF,CACA,IAAM,EAAW,IAAU,SAAW,IAAU,QAAU,UACtD,IAAU,SAAW,IAAU,QAAU,WAAa,SACpD,EAAS,KAAK,OAAO,QAAQ,EAAW,CAC5C,cAAe,EAAG,QAAS,KAAK,OAAO,SAAS,UAAU,EAAE,EAAG,SAAU,KAAK,aAAa,EAAG,KAAM,UAAW,MAAO,QACtH,WAAY,IAAI,KAAK,KAAK,OAAO,SAAS,QAAQ,CAAC,CAAC,CAAC,YAAY,EACjE,YAAa,KAAK,IAAI,EAAG,KAAK,OAAO,SAAS,aAAa,EAAI,KAAK,MAAM,EAAG,WAC7E,SAAU,KAAK,OAAO,SAAU,YAAa,KAAK,YAClD,KAAM,CAAE,QAAO,QAAS,EAAoB,CAAO,EAAG,GAAI,KAAK,QAAU,IAAA,GAAY,CAAC,EAAI,CAAE,MAAO,KAAK,KAAM,EAAI,OAAQ,CAAO,CACnI,CAAC,CAAC,EACE,GAAa,KAAK,OAAO,YAAY,EAAO,SAAW,WAAa,WAAa,UAAU,CACjG,CACF,EAEA,SAAS,EACP,EACA,EACsB,CACtB,IAAM,EAAS,EAAgB,CAAM,EAErC,OADgB,EAAwB,CAAE,OAAQ,CAAO,EAAG,CAC/C,CAAC,CAAC,MACjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/composition/memory/config.d.ts
|
|
2
|
+
declare const MEMORY_STORE_API_VERSION: 1;
|
|
3
|
+
declare const MEMORY_ERROR_CODES: Readonly<{
|
|
4
|
+
readonly BINDING_REQUIRED: 'MEMORY_BINDING_REQUIRED';
|
|
5
|
+
readonly BINDING_MISMATCH: 'MEMORY_BINDING_MISMATCH';
|
|
6
|
+
readonly INVALID_SCOPE: 'MEMORY_INVALID_SCOPE';
|
|
7
|
+
}>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { MEMORY_ERROR_CODES, MEMORY_STORE_API_VERSION };
|
|
10
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../../../src/composition/memory/config.ts"],"mappings":";cAAa;cAQA,oBAAkB;WACX;WACA;WACH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=1,t=Object.freeze({identityBytes:256,scopeValueBytes:8192,revisionBytes:1024}),n=Object.freeze({BINDING_REQUIRED:`MEMORY_BINDING_REQUIRED`,BINDING_MISMATCH:`MEMORY_BINDING_MISMATCH`,INVALID_SCOPE:`MEMORY_INVALID_SCOPE`}),r=Object.freeze({KIND_MISMATCH:`MEMORY_STORE_KIND_MISMATCH`,API_UNSUPPORTED:`MEMORY_STORE_API_UNSUPPORTED`,STORE_INVALID:`MEMORY_STORE_INVALID`,BINDING_INVALID:`MEMORY_BINDING_INVALID`,LOAD_FAILED:`MEMORY_LOAD_FAILED`,COMMIT_FAILED:`MEMORY_COMMIT_FAILED`,LOAD_TIMEOUT:`MEMORY_LOAD_TIMEOUT`,COMMIT_TIMEOUT:`MEMORY_COMMIT_TIMEOUT`,COMMIT_OUTCOME_UNKNOWN:`MEMORY_COMMIT_OUTCOME_UNKNOWN`,ABORTED:`RUNTIME_OPERATION_ABORTED`});export{n as MEMORY_ERROR_CODES,t as MEMORY_LIMITS,r as MEMORY_OPERATION_ERROR_CODES,e as MEMORY_STORE_API_VERSION};
|
|
2
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../src/composition/memory/config.ts"],"sourcesContent":["export const MEMORY_STORE_API_VERSION = 1 as const\n\nexport const MEMORY_LIMITS = Object.freeze({\n identityBytes: 256,\n scopeValueBytes: 8_192,\n revisionBytes: 1_024,\n})\n\nexport const MEMORY_ERROR_CODES = Object.freeze({\n BINDING_REQUIRED: 'MEMORY_BINDING_REQUIRED',\n BINDING_MISMATCH: 'MEMORY_BINDING_MISMATCH',\n INVALID_SCOPE: 'MEMORY_INVALID_SCOPE',\n} as const)\n\nexport const MEMORY_OPERATION_ERROR_CODES = Object.freeze({\n KIND_MISMATCH: 'MEMORY_STORE_KIND_MISMATCH',\n API_UNSUPPORTED: 'MEMORY_STORE_API_UNSUPPORTED',\n STORE_INVALID: 'MEMORY_STORE_INVALID',\n BINDING_INVALID: 'MEMORY_BINDING_INVALID',\n LOAD_FAILED: 'MEMORY_LOAD_FAILED',\n COMMIT_FAILED: 'MEMORY_COMMIT_FAILED',\n LOAD_TIMEOUT: 'MEMORY_LOAD_TIMEOUT',\n COMMIT_TIMEOUT: 'MEMORY_COMMIT_TIMEOUT',\n COMMIT_OUTCOME_UNKNOWN: 'MEMORY_COMMIT_OUTCOME_UNKNOWN',\n ABORTED: 'RUNTIME_OPERATION_ABORTED',\n} as const)\n"],"mappings":"AAAA,MAAa,EAA2B,EAE3B,EAAgB,OAAO,OAAO,CACzC,cAAe,IACf,gBAAiB,KACjB,cAAe,IACjB,CAAC,EAEY,EAAqB,OAAO,OAAO,CAC9C,iBAAkB,0BAClB,iBAAkB,0BAClB,cAAe,sBACjB,CAAU,EAEG,EAA+B,OAAO,OAAO,CACxD,cAAe,6BACf,gBAAiB,+BACjB,cAAe,uBACf,gBAAiB,yBACjB,YAAa,qBACb,cAAe,uBACf,aAAc,sBACd,eAAgB,wBAChB,uBAAwB,gCACxB,QAAS,2BACX,CAAU"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MemoryStore, MemoryStoreDefinition } from "../../agent/memory/persistence-types.js";
|
|
2
|
+
//#region src/composition/memory/definition.d.ts
|
|
3
|
+
/** Side-effect-free author helper. It captures methods but never freezes the caller's store. */
|
|
4
|
+
declare function defineMemoryStore(definition: MemoryStoreDefinition): MemoryStore;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { defineMemoryStore };
|
|
7
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","names":[],"sources":["../../../src/composition/memory/definition.ts"],"mappings":";;;iBAagB,kBAAkB,YAAY,wBAAwB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AgentSdkError as e}from"../../errors/agent-sdk-error.js";import{MEMORY_ERROR_CODES as t,MEMORY_LIMITS as n,MEMORY_OPERATION_ERROR_CODES as r}from"./config.js";import{boundedText as i,objectValue as a,ownData as o}from"../../capability/common/data.js";const s=new Set([`store`,`bindingId`,`scope`,`requirement`]);function c(e){return u(e,!1)}function l(t){try{let e=f(t,s),r=u(o(e,`store`),!0),a=i(o(e,`bindingId`),n.identityBytes),c=o(e,`requirement`);if(c!==`required`&&c!==`best-effort`)throw h();let l=d(o(e,`scope`));return Object.freeze({store:r,bindingId:a,scope:l,requirement:c})}catch(t){throw t instanceof e?t:h()}}function u(t,s){try{let c=a(t);if(s){if(o(c,`kind`)!==`memory-store`)throw new e(`Memory store kind is unsupported`,r.KIND_MISMATCH);if(o(c,`apiVersion`)!==1)throw new e(`Memory store API version is unsupported`,r.API_UNSUPPORTED)}let l=i(o(c,`id`),n.identityBytes),u=m(c,`load`),d=m(c,`commit`);return Object.freeze({kind:`memory-store`,apiVersion:1,id:l,load:(e,t)=>Reflect.apply(u,c,[e,t]),commit:(e,t)=>Reflect.apply(d,c,[e,t])})}catch(t){throw t instanceof e?t:new e(`Memory store definition is invalid`,r.STORE_INVALID)}}function d(r){let s=a(r),c=o(s,`kind`);if(c===`conversation`)return p(s,new Set([`kind`,`namespace`])),Object.freeze({kind:c,namespace:i(o(s,`namespace`),n.scopeValueBytes)});if(c===`fixed`){if(p(s,new Set([`kind`,`key`,`sharedAcrossSessions`])),o(s,`sharedAcrossSessions`)!==!0)throw new e(`Fixed memory scope requires explicit cross-session sharing`,t.INVALID_SCOPE);return Object.freeze({kind:c,key:i(o(s,`key`),n.scopeValueBytes),sharedAcrossSessions:!0})}throw new e(`Memory scope is invalid`,t.INVALID_SCOPE)}function f(e,t){let n=a(e);return p(n,t),n}function p(e,t){if(Reflect.ownKeys(e).some(e=>typeof e!=`string`||!t.has(e)))throw TypeError(`Unsupported field`)}function m(e,t){let n;try{n=Reflect.get(e,t)}catch{throw TypeError(`Method capture failed`)}if(typeof n!=`function`)throw TypeError(`Method is invalid`);return n}function h(){return new e(`Memory binding is invalid`,r.BINDING_INVALID)}export{l as captureMemoryBinding,c as defineMemoryStore};
|
|
2
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","names":[],"sources":["../../../src/composition/memory/definition.ts"],"sourcesContent":["import { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { boundedText, objectValue, ownData } from '../common/data.ts'\nimport {\n MEMORY_ERROR_CODES, MEMORY_LIMITS, MEMORY_OPERATION_ERROR_CODES, MEMORY_STORE_API_VERSION,\n} from './config.ts'\nimport type {\n CapturedMemoryBinding, MemoryBinding, MemoryCommitInput, MemoryCommitResult,\n MemoryLoadResult, MemoryStore, MemoryStoreDefinition, MemoryStoreOptions,\n} from './types.ts'\n\nconst BINDING_KEYS = new Set(['store', 'bindingId', 'scope', 'requirement'])\n\n/** Side-effect-free author helper. It captures methods but never freezes the caller's store. */\nexport function defineMemoryStore(definition: MemoryStoreDefinition): MemoryStore {\n return captureStore(definition, false)\n}\n\nexport function captureMemoryBinding(value: unknown): CapturedMemoryBinding {\n try {\n const source = exactObject(value, BINDING_KEYS)\n const store = captureStore(ownData(source, 'store'), true)\n const bindingId = boundedText(ownData(source, 'bindingId'), MEMORY_LIMITS.identityBytes)\n const requirement = ownData(source, 'requirement')\n if (requirement !== 'required' && requirement !== 'best-effort') throw invalidBinding()\n const scope = captureScope(ownData(source, 'scope'))\n return Object.freeze({ store, bindingId, scope, requirement })\n } catch (error) {\n if (error instanceof AgentSdkError) throw error\n throw invalidBinding()\n }\n}\n\nfunction captureStore(value: unknown, requireMarker: boolean): MemoryStore {\n try {\n const source = objectValue(value)\n if (requireMarker) {\n if (ownData(source, 'kind') !== 'memory-store') {\n throw new AgentSdkError('Memory store kind is unsupported', MEMORY_OPERATION_ERROR_CODES.KIND_MISMATCH)\n }\n if (ownData(source, 'apiVersion') !== MEMORY_STORE_API_VERSION) {\n throw new AgentSdkError('Memory store API version is unsupported', MEMORY_OPERATION_ERROR_CODES.API_UNSUPPORTED)\n }\n }\n const id = boundedText(ownData(source, 'id'), MEMORY_LIMITS.identityBytes)\n const loadMethod = method(source, 'load')\n const commitMethod = method(source, 'commit')\n const load = (key: string, options: MemoryStoreOptions): Promise<MemoryLoadResult | undefined> =>\n Reflect.apply(loadMethod, source, [key, options]) as Promise<MemoryLoadResult | undefined>\n const commit = (input: MemoryCommitInput, options: MemoryStoreOptions): Promise<MemoryCommitResult> =>\n Reflect.apply(commitMethod, source, [input, options]) as Promise<MemoryCommitResult>\n return Object.freeze({ kind: 'memory-store', apiVersion: MEMORY_STORE_API_VERSION, id, load, commit })\n } catch (error) {\n if (error instanceof AgentSdkError) throw error\n throw new AgentSdkError('Memory store definition is invalid', MEMORY_OPERATION_ERROR_CODES.STORE_INVALID)\n }\n}\n\nfunction captureScope(value: unknown): MemoryBinding['scope'] {\n const source = objectValue(value)\n const kind = ownData(source, 'kind')\n if (kind === 'conversation') {\n exactKeys(source, new Set(['kind', 'namespace']))\n return Object.freeze({ kind, namespace: boundedText(ownData(source, 'namespace'), MEMORY_LIMITS.scopeValueBytes) })\n }\n if (kind === 'fixed') {\n exactKeys(source, new Set(['kind', 'key', 'sharedAcrossSessions']))\n if (ownData(source, 'sharedAcrossSessions') !== true) {\n throw new AgentSdkError('Fixed memory scope requires explicit cross-session sharing', MEMORY_ERROR_CODES.INVALID_SCOPE)\n }\n return Object.freeze({ kind, key: boundedText(ownData(source, 'key'), MEMORY_LIMITS.scopeValueBytes), sharedAcrossSessions: true })\n }\n throw new AgentSdkError('Memory scope is invalid', MEMORY_ERROR_CODES.INVALID_SCOPE)\n}\n\nfunction exactObject(value: unknown, keys: ReadonlySet<string>): object {\n const source = objectValue(value)\n exactKeys(source, keys)\n return source\n}\n\nfunction exactKeys(value: object, allowed: ReadonlySet<string>): void {\n if (Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.has(key))) throw new TypeError('Unsupported field')\n}\n\nfunction method(value: object, key: string): Function {\n let result: unknown\n try { result = Reflect.get(value, key) } catch { throw new TypeError('Method capture failed') }\n if (typeof result !== 'function') throw new TypeError('Method is invalid')\n return result\n}\n\nfunction invalidBinding(): AgentSdkError {\n return new AgentSdkError('Memory binding is invalid', MEMORY_OPERATION_ERROR_CODES.BINDING_INVALID)\n}\n"],"mappings":"kQAUA,MAAM,EAAe,IAAI,IAAI,CAAC,QAAS,YAAa,QAAS,aAAa,CAAC,EAG3E,SAAgB,EAAkB,EAAgD,CAChF,OAAO,EAAa,EAAY,EAAK,CACvC,CAEA,SAAgB,EAAqB,EAAuC,CAC1E,GAAI,CACF,IAAM,EAAS,EAAY,EAAO,CAAY,EACxC,EAAQ,EAAa,EAAQ,EAAQ,OAAO,EAAG,EAAI,EACnD,EAAY,EAAY,EAAQ,EAAQ,WAAW,EAAG,EAAc,aAAa,EACjF,EAAc,EAAQ,EAAQ,aAAa,EACjD,GAAI,IAAgB,YAAc,IAAgB,cAAe,MAAM,EAAe,EACtF,IAAM,EAAQ,EAAa,EAAQ,EAAQ,OAAO,CAAC,EACnD,OAAO,OAAO,OAAO,CAAE,QAAO,YAAW,QAAO,aAAY,CAAC,CAC/D,OAAS,EAAO,CAEd,MADI,aAAiB,EAAqB,EACpC,EAAe,CACvB,CACF,CAEA,SAAS,EAAa,EAAgB,EAAqC,CACzE,GAAI,CACF,IAAM,EAAS,EAAY,CAAK,EAChC,GAAI,EAAe,CACjB,GAAI,EAAQ,EAAQ,MA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AY,EAAgB,EAAmC,CACtE,IAAM,EAAS,EAAY,CAAK,EAEhC,OADA,EAAU,EAAQ,CAAI,EACf,CACT,CAEA,SAAS,EAAU,EAAe,EAAoC,CACpE,GAAI,QAAQ,QAAQ,CAAK,CAAC,CAAC,KAAK,GAAO,OAAO,GAAQ,UAAY,CAAC,EAAQ,IAAI,CAAG,CAAC,EAAG,MAAU,UAAU,mBAAmB,CAC/H,CAEA,SAAS,EAAO,EAAe,EAAuB,CACpD,IAAI,EACJ,GAAI,CAAE,EAAS,QAAQ,IAAI,EAAO,CAAG,CAAE,MAAQ,CAAE,MAAU,UAAU,uBAAuB,CAAE,CAC9F,GAAI,OAAO,GAAW,WAAY,MAAU,UAAU,mBAAmB,EACzE,OAAO,CACT,CAEA,SAAS,GAAgC,CACvC,OAAO,IAAI,EAAc,4BAA6B,EAA6B,eAAe,CACpG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{MEMORY_LIMITS as e}from"./config.js";const t=new TextEncoder;function n(e,t,n){return e.scope.kind===`fixed`?e.scope.key:(r(t),r(n),JSON.stringify([`ai-agent-sdk-memory`,1,e.scope.namespace,t,n]))}function r(n){if(typeof n!=`string`||n.length===0||t.encode(n).byteLength>e.scopeValueBytes)throw TypeError(`Memory key identity is invalid`)}export{n as memoryStoreKey};
|
|
2
|
+
//# sourceMappingURL=key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.js","names":[],"sources":["../../../src/composition/memory/key.ts"],"sourcesContent":["import { MEMORY_LIMITS } from './config.ts'\nimport type { CapturedMemoryBinding } from './types.ts'\n\nconst encoder = new TextEncoder()\n\n/** JSON tuple encoding is versioned and unambiguous even when parts contain delimiters. */\nexport function memoryStoreKey(\n binding: CapturedMemoryBinding,\n agentId: string,\n conversationId: string,\n): string {\n if (binding.scope.kind === 'fixed') return binding.scope.key\n boundedPart(agentId)\n boundedPart(conversationId)\n return JSON.stringify(['ai-agent-sdk-memory', 1, binding.scope.namespace, agentId, conversationId])\n}\n\nfunction boundedPart(value: string): void {\n if (typeof value !== 'string' || value.length === 0\n || encoder.encode(value).byteLength > MEMORY_LIMITS.scopeValueBytes) {\n throw new TypeError('Memory key identity is invalid')\n }\n}\n"],"mappings":"4CAGA,MAAM,EAAU,IAAI,YAGpB,SAAgB,EACd,EACA,EACA,EACQ,CAIR,OAHI,EAAQ,MAAM,OAAS,QAAgB,EAAQ,MAAM,KACzD,EAAY,CAAO,EACnB,EAAY,CAAc,EACnB,KAAK,UAAU,CAAC,sBAAuB,EAAG,EAAQ,MAAM,UAAW,EAAS,CAAc,CAAC,EACpG,CAEA,SAAS,EAAY,EAAqB,CACxC,GAAI,OAAO,GAAU,UAAY,EAAM,SAAW,GAC7C,EAAQ,OAAO,CAAK,CAAC,CAAC,WAAa,EAAc,gBACpD,MAAU,UAAU,gCAAgC,CAExD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AgentSdkError as e}from"../../errors/agent-sdk-error.js";import{MEMORY_ERROR_CODES as t,MEMORY_LIMITS as n}from"./config.js";function r(r,a){let o=Object.getOwnPropertyDescriptor(r,`memoryBindingId`);if(o!==void 0&&!(`value`in o))throw i();let s=o!==void 0&&`value`in o?o.value:void 0;if(s===void 0){if(a!==void 0)throw i();return}if(typeof s!=`string`||s.length===0||s.trim()!==s||new TextEncoder().encode(s).byteLength>n.identityBytes)throw i();if(a===void 0)throw new e(`The persisted memory binding must be supplied to resume this session`,t.BINDING_REQUIRED);if(s!==a.bindingId)throw i()}function i(){return new e(`The supplied memory binding does not match the persisted session`,t.BINDING_MISMATCH)}export{r as validateMemoryResumeBinding};
|
|
2
|
+
//# sourceMappingURL=resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.js","names":[],"sources":["../../../src/composition/memory/resume.ts"],"sourcesContent":["import { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { MEMORY_ERROR_CODES } from './config.ts'\nimport { MEMORY_LIMITS } from './config.ts'\nimport type { CapturedMemoryBinding } from './types.ts'\n\nexport function validateMemoryResumeBinding(\n snapshot: { readonly memoryBindingId?: unknown },\n binding: CapturedMemoryBinding | undefined,\n): void {\n const persisted = Object.getOwnPropertyDescriptor(snapshot, 'memoryBindingId')\n if (persisted !== undefined && !('value' in persisted)) throw mismatch()\n const id = persisted !== undefined && 'value' in persisted ? persisted.value : undefined\n if (id === undefined) {\n if (binding !== undefined) throw mismatch()\n return\n }\n if (typeof id !== 'string' || id.length === 0 || id.trim() !== id\n || new TextEncoder().encode(id).byteLength > MEMORY_LIMITS.identityBytes) throw mismatch()\n if (binding === undefined) {\n throw new AgentSdkError('The persisted memory binding must be supplied to resume this session', MEMORY_ERROR_CODES.BINDING_REQUIRED)\n }\n if (id !== binding.bindingId) throw mismatch()\n}\n\nfunction mismatch(): AgentSdkError {\n return new AgentSdkError('The supplied memory binding does not match the persisted session', MEMORY_ERROR_CODES.BINDING_MISMATCH)\n}\n"],"mappings":"oIAKA,SAAgB,EACd,EACA,EACM,CACN,IAAM,EAAY,OAAO,yBAAyB,EAAU,iBAAiB,EAC7E,GAAI,IAAc,IAAA,IAAa,EAAE,UAAW,GAAY,MAAM,EAAS,EACvE,IAAM,EAAK,IAAc,IAAA,IAAa,UAAW,EAAY,EAAU,MAAQ,IAAA,GAC/E,GAAI,IAAO,IAAA,GAAW,CACpB,GAAI,IAAY,IAAA,GAAW,MAAM,EAAS,EAC1C,MACF,CACA,GAAI,OAAO,GAAO,UAAY,EAAG,SAAW,GAAK,EAAG,KAAK,IAAM,GAC1D,IAAI,YAAY,CAAC,CAAC,OAAO,CAAE,CAAC,CAAC,WAAa,EAAc,cAAe,MAAM,EAAS,EAC3F,GAAI,IAAY,IAAA,GACd,MAAM,IAAI,EAAc,uEAAwE,EAAmB,gBAAgB,EAErI,GAAI,IAAO,EAAQ,UAAW,MAAM,EAAS,CAC/C,CAEA,SAAS,GAA0B,CACjC,OAAO,IAAI,EAAc,mEAAoE,EAAmB,gBAAgB,CAClI"}
|