@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,527 @@
|
|
|
1
|
+
import { ToolDefinition } from "../tool/definition.js";
|
|
2
|
+
import { HistoryEntry, HistorySnapshot } from "../history/types.js";
|
|
3
|
+
import { ToolCatalog } from "../tool/registry.js";
|
|
4
|
+
import { ModelRegistry } from "../../runtime/registry.js";
|
|
5
|
+
import { AgentRunEvent } from "../mode/run-agent.js";
|
|
6
|
+
import { DefinedAgent } from "../define/definition.js";
|
|
7
|
+
import { AgentInput, AgentInvocationOptions, AgentResponse, AgentSessionOptions } from "../define/session/types.js";
|
|
8
|
+
import { AgentSession } from "../define/session.js";
|
|
9
|
+
import { AgentTeamOptions } from "./types.js";
|
|
10
|
+
import { AgentTeam } from "./team.js";
|
|
11
|
+
//#region src/agent/team/managed.d.ts
|
|
12
|
+
type DetachedSessionOptions = Omit<AgentSessionOptions, 'registry' | 'team' | 'tools'>;
|
|
13
|
+
/**
|
|
14
|
+
* Default bound on getting one worker RUNNING, overridable per harness with
|
|
15
|
+
* {@link ManagedAgentTeamOptions.spawnTimeoutMs}.
|
|
16
|
+
*
|
|
17
|
+
* Not the worker's deadline — that is `workerTimeoutMs`. This bounds only the
|
|
18
|
+
* setup, so a lead cannot be held for minutes by a call that no longer waits
|
|
19
|
+
* for any work.
|
|
20
|
+
*/
|
|
21
|
+
declare const DEFAULT_SPAWN_SETUP_TIMEOUT_MS = 30000;
|
|
22
|
+
/** Default bound on stopping one worker; see {@link ManagedAgentTeamOptions.closeTimeoutMs}. */
|
|
23
|
+
declare const DEFAULT_WORKER_CLOSE_TIMEOUT_MS = 30000;
|
|
24
|
+
/**
|
|
25
|
+
* How much of the lead's conversation a new worker starts from.
|
|
26
|
+
*
|
|
27
|
+
* `fresh` is one task and nothing else. `fork` copies the lead's completed
|
|
28
|
+
* conversation so far, so the worker begins already knowing what the lead
|
|
29
|
+
* learned — the state of the workspace, the decisions taken, what the other
|
|
30
|
+
* workers were given.
|
|
31
|
+
*
|
|
32
|
+
* The distinction exists because its absence is expensive in a specific way.
|
|
33
|
+
* With only a task string, every worker re-derives the same context from
|
|
34
|
+
* scratch: three workers spawned into an empty repository each listed the
|
|
35
|
+
* directory, each concluded independently that nothing was there, and each
|
|
36
|
+
* decided on its own to scaffold it. Both reference implementations offer the
|
|
37
|
+
* same choice — Codex as `fork_context`/`fork_turns`, the DeepSeek harness as
|
|
38
|
+
* `context: 'fresh' | 'fork'`, whose naming this follows.
|
|
39
|
+
*/
|
|
40
|
+
type ManagedAgentSpawnContext = 'fresh' | 'fork';
|
|
41
|
+
/**
|
|
42
|
+
* A worker kind the host declares up front.
|
|
43
|
+
*
|
|
44
|
+
* Without a declared set, `specialty` is free text the model invents at the
|
|
45
|
+
* moment it spawns: the harness is handed `"Code review, accessibility,
|
|
46
|
+
* security và quality audit"` and can make nothing of it — not that the role
|
|
47
|
+
* reads rather than writes, not that it needs code to exist first. So it
|
|
48
|
+
* cannot help order the work, and the lead is left inventing both the role and
|
|
49
|
+
* its place in the plan in the same breath.
|
|
50
|
+
*
|
|
51
|
+
* Declaring roles turns that into a choice from a list the host wrote, with
|
|
52
|
+
* `whenToUse` stating the precondition in the spawn schema where the lead
|
|
53
|
+
* reads it. Codex does the same thing with `agent_type` and its role registry.
|
|
54
|
+
*/
|
|
55
|
+
interface ManagedAgentRole {
|
|
56
|
+
/** Referred to by `spawn_agent`; the enum the lead chooses from. */
|
|
57
|
+
readonly name: string;
|
|
58
|
+
/** What this role is for. Shown to the lead in the spawn tool schema. */
|
|
59
|
+
readonly description: string;
|
|
60
|
+
/** When choosing it is correct — and when it is premature. */
|
|
61
|
+
readonly whenToUse?: string;
|
|
62
|
+
/** Added to the worker's own instructions; defaults to `description`. */
|
|
63
|
+
readonly instructions?: string;
|
|
64
|
+
}
|
|
65
|
+
/** What to do about two workers that would write the same files at once. */
|
|
66
|
+
type WriteScopeConflictPolicy = 'reject' | 'warn' | 'off';
|
|
67
|
+
interface ManagedAgentSpawnRequest {
|
|
68
|
+
/** Optional stable team address; generated as worker_N when omitted. */
|
|
69
|
+
readonly name?: string;
|
|
70
|
+
readonly task: string;
|
|
71
|
+
/** Short specialization added to the generated worker's instructions. */
|
|
72
|
+
readonly specialty?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Context the worker starts from; defaults to
|
|
75
|
+
* {@link ManagedAgentTeamOptions.defaultSpawnContext}.
|
|
76
|
+
*/
|
|
77
|
+
readonly context?: ManagedAgentSpawnContext;
|
|
78
|
+
/** One of {@link ManagedAgentTeamOptions.roles}, when the host declared any. */
|
|
79
|
+
readonly role?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Workers that must finish before this one starts.
|
|
82
|
+
*
|
|
83
|
+
* The harness holds it back until every one of them has settled, and then
|
|
84
|
+
* gives it what they produced. This is the difference between dividing
|
|
85
|
+
* agents and dividing work: a lead can spawn the whole plan in one step —
|
|
86
|
+
* which is what it wants to do — and the ORDER is still respected, because
|
|
87
|
+
* ordering is no longer something the model has to remember to enforce by
|
|
88
|
+
* spawning late.
|
|
89
|
+
*
|
|
90
|
+
* A dependency that fails still releases its dependents, and they are told
|
|
91
|
+
* it failed. Waiting only for success turns one broken worker into a
|
|
92
|
+
* permanently stalled plan.
|
|
93
|
+
*/
|
|
94
|
+
readonly dependsOn?: readonly string[];
|
|
95
|
+
/**
|
|
96
|
+
* Files and directories this worker may write, workspace-relative.
|
|
97
|
+
*
|
|
98
|
+
* Declared so the harness can refuse a division that cannot work. Two
|
|
99
|
+
* workers given overlapping scopes with no ordering between them will both
|
|
100
|
+
* write those files, and the later write erases the earlier one — observed
|
|
101
|
+
* as a UI worker announcing it would put its logic in the very page
|
|
102
|
+
* component the logic worker had been assigned.
|
|
103
|
+
*/
|
|
104
|
+
readonly writes?: readonly string[];
|
|
105
|
+
}
|
|
106
|
+
interface ResolvedManagedAgentSpawnRequest extends ManagedAgentSpawnRequest {
|
|
107
|
+
readonly name: string;
|
|
108
|
+
readonly context: ManagedAgentSpawnContext;
|
|
109
|
+
readonly dependsOn: readonly string[];
|
|
110
|
+
readonly writes: readonly string[];
|
|
111
|
+
}
|
|
112
|
+
interface ManagedAgentWorkerResult {
|
|
113
|
+
readonly worker: string;
|
|
114
|
+
readonly agentId: string;
|
|
115
|
+
readonly conversationId: string;
|
|
116
|
+
readonly text: string;
|
|
117
|
+
readonly succeeded: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Where a generated worker is in its life.
|
|
121
|
+
*
|
|
122
|
+
* `completed` and `failed` are final but NOT gone: a finished worker stays
|
|
123
|
+
* addressable and keeps occupying a `maxWorkers` slot until it is closed, so
|
|
124
|
+
* a lead that spawns without closing runs out of workers rather than silently
|
|
125
|
+
* accumulating them.
|
|
126
|
+
*/
|
|
127
|
+
type ManagedAgentWorkerStatus = 'pending' | 'running' | 'completed' | 'failed' | 'closed';
|
|
128
|
+
interface ManagedAgentWorker {
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly agentId: string;
|
|
131
|
+
readonly conversationId: string;
|
|
132
|
+
readonly task: string;
|
|
133
|
+
readonly specialty?: string;
|
|
134
|
+
/** Context this worker was started from. */
|
|
135
|
+
readonly context: ManagedAgentSpawnContext;
|
|
136
|
+
readonly role?: string;
|
|
137
|
+
/** Workers that had to settle before this one could start. */
|
|
138
|
+
readonly dependsOn: readonly string[];
|
|
139
|
+
/** Files this worker declared it would write. */
|
|
140
|
+
readonly writes: readonly string[];
|
|
141
|
+
readonly status: ManagedAgentWorkerStatus;
|
|
142
|
+
/** Non-fatal problems with the division of work, e.g. an accepted overlap. */
|
|
143
|
+
readonly warnings?: readonly string[];
|
|
144
|
+
readonly result?: ManagedAgentWorkerResult;
|
|
145
|
+
readonly error?: string;
|
|
146
|
+
}
|
|
147
|
+
interface ManagedAgentTeamOptions {
|
|
148
|
+
readonly registry: ModelRegistry;
|
|
149
|
+
readonly lead: DefinedAgent;
|
|
150
|
+
readonly leadName?: string;
|
|
151
|
+
readonly leadDescription?: string;
|
|
152
|
+
readonly team?: AgentTeam | AgentTeamOptions;
|
|
153
|
+
readonly maxWorkers?: number;
|
|
154
|
+
/** Maximum UTF-8 worker task bytes. Defaults to 64 KiB. */
|
|
155
|
+
readonly maxTaskBytes?: number;
|
|
156
|
+
/** Maximum UTF-8 specialty bytes. Defaults to 8 KiB. */
|
|
157
|
+
readonly maxSpecialtyBytes?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Context a `spawn_agent` call starts a worker from when it does not say.
|
|
160
|
+
* Defaults to `'fresh'`.
|
|
161
|
+
*
|
|
162
|
+
* `'fresh'` is the default because forking is not free: the worker pays for
|
|
163
|
+
* the lead's whole conversation in input tokens on every round it runs, and
|
|
164
|
+
* a worker whose task genuinely stands alone gains nothing for it. A host
|
|
165
|
+
* that knows its workers always operate on the lead's workspace — and so
|
|
166
|
+
* would otherwise watch each of them rediscover it — should set `'fork'`
|
|
167
|
+
* here rather than hope the lead remembers to ask.
|
|
168
|
+
*/
|
|
169
|
+
readonly defaultSpawnContext?: ManagedAgentSpawnContext;
|
|
170
|
+
/**
|
|
171
|
+
* Worker kinds the lead may choose from, with what each is for.
|
|
172
|
+
*
|
|
173
|
+
* Declaring them replaces free-text `specialty` with an enum, and puts each
|
|
174
|
+
* role's `whenToUse` in the spawn schema — the one place the lead is certain
|
|
175
|
+
* to read before choosing. Leave it unset and `specialty` behaves as before.
|
|
176
|
+
*/
|
|
177
|
+
readonly roles?: readonly ManagedAgentRole[];
|
|
178
|
+
/**
|
|
179
|
+
* What to do when a spawn declares `writes` overlapping a worker that would
|
|
180
|
+
* run at the same time. Defaults to `'reject'`.
|
|
181
|
+
*
|
|
182
|
+
* Rejecting is the default because the alternative is silent data loss: both
|
|
183
|
+
* workers write the file and the later write wins. The refusal names the
|
|
184
|
+
* conflicting worker and the overlap, so the lead's available fix — add it
|
|
185
|
+
* to `dependsOn`, or narrow the scope — is visible in the error itself.
|
|
186
|
+
* `'warn'` records it on the worker instead and lets it run; `'off'` skips
|
|
187
|
+
* the check.
|
|
188
|
+
*/
|
|
189
|
+
readonly writeScopePolicy?: WriteScopeConflictPolicy;
|
|
190
|
+
/**
|
|
191
|
+
* Cap on how much of a dependency's result is handed to its dependents.
|
|
192
|
+
* Defaults to 8 KiB per dependency.
|
|
193
|
+
*/
|
|
194
|
+
readonly maxDependencyReportBytes?: number;
|
|
195
|
+
/** End-to-end deadline for one generated worker. Defaults to 10 minutes. */
|
|
196
|
+
readonly workerTimeoutMs?: number;
|
|
197
|
+
/** Maximum wait per worker event observer callback. Defaults to 1 second. */
|
|
198
|
+
readonly observerTimeoutMs?: number;
|
|
199
|
+
/**
|
|
200
|
+
* How long closing one worker waits for it to stop.
|
|
201
|
+
* Defaults to {@link DEFAULT_WORKER_CLOSE_TIMEOUT_MS}.
|
|
202
|
+
*
|
|
203
|
+
* After that its slot is freed regardless. A worker that ignores its
|
|
204
|
+
* cancellation must not be able to hold the harness at its cap forever.
|
|
205
|
+
*/
|
|
206
|
+
readonly closeTimeoutMs?: number;
|
|
207
|
+
/**
|
|
208
|
+
* How long the lead's turn is held open waiting for a worker to report,
|
|
209
|
+
* before the lead is asked again. Defaults to {@link DEFAULT_HOLD_WAIT_MS}.
|
|
210
|
+
*
|
|
211
|
+
* Zero-length would be a spin: the lead answers, is told its workers are
|
|
212
|
+
* still running, answers again, and burns its budget before any result
|
|
213
|
+
* arrives. Codex blocks the parent inside its `wait_agent` tool for the same
|
|
214
|
+
* reason.
|
|
215
|
+
*/
|
|
216
|
+
readonly holdWaitMs?: number;
|
|
217
|
+
/** Allow model-invoked close_agent to cancel unfinished work (default true).
|
|
218
|
+
* Host closeWorker, disposal and user cancellation are always available. */
|
|
219
|
+
readonly allowModelWorkerCancellation?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* How long `spawn_agent` may take to get a worker running.
|
|
222
|
+
* Defaults to {@link DEFAULT_SPAWN_SETUP_TIMEOUT_MS}.
|
|
223
|
+
*
|
|
224
|
+
* Only the setup: the worker's own deadline is `workerTimeoutMs`, and how
|
|
225
|
+
* long the lead may WAIT for it is the team's `waitTimeoutMs` — pass it
|
|
226
|
+
* through `team: { waitTimeoutMs }` when building the harness.
|
|
227
|
+
*/
|
|
228
|
+
readonly spawnTimeoutMs?: number;
|
|
229
|
+
/** Defaults to cloning the lead definition under the generated worker id. */
|
|
230
|
+
readonly workerTemplate?: DefinedAgent;
|
|
231
|
+
readonly workerFactory?: (request: ResolvedManagedAgentSpawnRequest) => DefinedAgent | Promise<DefinedAgent>;
|
|
232
|
+
readonly leadSessionOptions?: DetachedSessionOptions & {
|
|
233
|
+
readonly tools?: ToolCatalog | readonly ToolDefinition<any>[];
|
|
234
|
+
};
|
|
235
|
+
readonly workerSessionOptions?: DetachedSessionOptions & {
|
|
236
|
+
readonly tools?: ToolCatalog | readonly ToolDefinition<any>[];
|
|
237
|
+
};
|
|
238
|
+
/** Per-worker runtime dependencies for least-privilege tools and workspace policy. */
|
|
239
|
+
readonly workerSessionOptionsFactory?: (request: ResolvedManagedAgentSpawnRequest) => (DetachedSessionOptions & {
|
|
240
|
+
readonly tools?: ToolCatalog | readonly ToolDefinition<any>[];
|
|
241
|
+
}) | Promise<DetachedSessionOptions & {
|
|
242
|
+
readonly tools?: ToolCatalog | readonly ToolDefinition<any>[];
|
|
243
|
+
}>;
|
|
244
|
+
/** Observe every generated worker's model, tool, trace, and compaction events. */
|
|
245
|
+
readonly onWorkerEvent?: (worker: string, event: AgentRunEvent) => void | Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A dynamic harness whose lead can create specialized workers with spawn_agent.
|
|
249
|
+
*
|
|
250
|
+
* `spawn_agent` blocks the lead for as long as its worker runs, so it declares
|
|
251
|
+
* that blocking to the team as a wait edge. Cycle detection is only as good as
|
|
252
|
+
* the graph it can see: an unrecorded edge does not merely go unchecked, it
|
|
253
|
+
* lets the cycle it completes through, and a worker waiting for the lead that
|
|
254
|
+
* is waiting for it deadlocks both until a timeout.
|
|
255
|
+
*
|
|
256
|
+
* Each worker is a real connected AgentSession and remains addressable afterward.
|
|
257
|
+
*/
|
|
258
|
+
declare class ManagedAgentTeam {
|
|
259
|
+
readonly team: AgentTeam;
|
|
260
|
+
readonly lead: AgentSession;
|
|
261
|
+
readonly leadName: string;
|
|
262
|
+
private readonly options;
|
|
263
|
+
private readonly maxWorkers;
|
|
264
|
+
private readonly maxTaskBytes;
|
|
265
|
+
private readonly maxSpecialtyBytes;
|
|
266
|
+
private readonly workerTimeoutMs;
|
|
267
|
+
private readonly observerTimeoutMs;
|
|
268
|
+
private readonly closeTimeoutMs;
|
|
269
|
+
private readonly holdWaitMs;
|
|
270
|
+
private readonly spawnTimeoutMs;
|
|
271
|
+
private readonly workerRuntimes;
|
|
272
|
+
private readonly reservedNames;
|
|
273
|
+
private workerSequence;
|
|
274
|
+
private readonly maxDependencyReportBytes;
|
|
275
|
+
private readonly roles;
|
|
276
|
+
constructor(options: ManagedAgentTeamOptions);
|
|
277
|
+
/**
|
|
278
|
+
* Hold the lead's turn open while a worker of its is unfinished.
|
|
279
|
+
*
|
|
280
|
+
* This is Codex's shape, arrived at from the other side: there the parent
|
|
281
|
+
* stays inside its turn and loops on its wait tool until it has what it
|
|
282
|
+
* needs. A lead that concludes while its workers are still running answers
|
|
283
|
+
* from nothing — and once the turn is over, the reports that arrive
|
|
284
|
+
* afterwards have no turn left to be read in, so the work stops with no
|
|
285
|
+
* synthesis at all.
|
|
286
|
+
*
|
|
287
|
+
* `runTurn` re-runs a turn whose `onTurnEnd` hook appended history, so
|
|
288
|
+
* saying so is enough to send the lead round again. Its own step and turn
|
|
289
|
+
* budgets bound this, and `canContinue` leaves an aborted or exhausted turn
|
|
290
|
+
* free to end.
|
|
291
|
+
* @param host - Hooks the host supplied; theirs run first and are kept.
|
|
292
|
+
* @returns The hooks to give the lead's session.
|
|
293
|
+
*/
|
|
294
|
+
private leadHooks;
|
|
295
|
+
/** Run the lead. It decides whether and how many workers to create. */
|
|
296
|
+
run(input: AgentInput, invocation?: AgentInvocationOptions): Promise<AgentResponse>;
|
|
297
|
+
/**
|
|
298
|
+
* Add a message to the lead's context, and make sure something reads it.
|
|
299
|
+
*
|
|
300
|
+
* Injection alone is enough only while the lead is mid-turn: its next model
|
|
301
|
+
* round rebuilds the request from history and picks the message up. Once the
|
|
302
|
+
* lead has answered and is only waiting on its workers, an injected message
|
|
303
|
+
* sits in history with nothing scheduled to read it — which is what happened
|
|
304
|
+
* to a user who typed a correction while the researchers were still running
|
|
305
|
+
* and never got an answer to it. Idle, the lead is scheduled one turn.
|
|
306
|
+
* @param text - What the user said.
|
|
307
|
+
* @returns True; the message is always accepted.
|
|
308
|
+
*/
|
|
309
|
+
steer(text: string): boolean;
|
|
310
|
+
/** Host-side equivalent of the model's spawn_agent tool. */
|
|
311
|
+
/**
|
|
312
|
+
* Create a worker and start it, WITHOUT waiting for it.
|
|
313
|
+
*
|
|
314
|
+
* Returns as soon as the worker is running. Use {@link awaitWorker} for its
|
|
315
|
+
* result, {@link workers} for its status, or let the worker's completion
|
|
316
|
+
* notification reach the lead on its own.
|
|
317
|
+
* @param request - Task, and optionally a name and a specialty.
|
|
318
|
+
* @param signal - Cancels the setup, not the worker's run.
|
|
319
|
+
* @returns The worker, in its `running` state.
|
|
320
|
+
*/
|
|
321
|
+
spawn(request: ManagedAgentSpawnRequest, signal?: AbortSignal): Promise<ManagedAgentWorker>;
|
|
322
|
+
/**
|
|
323
|
+
* Put a worker on the model, at last.
|
|
324
|
+
*
|
|
325
|
+
* Separate from `spawn` because a worker with dependencies is created now and
|
|
326
|
+
* started later; the two used to be the same moment.
|
|
327
|
+
*/
|
|
328
|
+
private beginWorker;
|
|
329
|
+
/**
|
|
330
|
+
* The `role` parameter, when the host declared any roles.
|
|
331
|
+
*
|
|
332
|
+
* Each role's purpose and precondition go in the description, which is where
|
|
333
|
+
* Codex puts its role registry too: the lead is choosing a role at the
|
|
334
|
+
* moment it reads this, so this is the only place the guidance can arrive in
|
|
335
|
+
* time to change the choice.
|
|
336
|
+
* @returns A one-property object to spread, or nothing.
|
|
337
|
+
*/
|
|
338
|
+
private roleSchema;
|
|
339
|
+
/** Resolve a declared role name, or say which ones exist. */
|
|
340
|
+
private requireRole;
|
|
341
|
+
/**
|
|
342
|
+
* Check the named dependencies and return them deduplicated.
|
|
343
|
+
*
|
|
344
|
+
* A dependency can only name a worker that already exists, and a new worker
|
|
345
|
+
* is not yet nameable by anything, so the graph cannot contain a cycle by
|
|
346
|
+
* construction — no cycle check is needed here, and a `dependsOn` that could
|
|
347
|
+
* name a future worker would need one.
|
|
348
|
+
*/
|
|
349
|
+
private resolveDependencies;
|
|
350
|
+
/**
|
|
351
|
+
* Judge a new worker's write scopes against the ones already in flight.
|
|
352
|
+
*
|
|
353
|
+
* Only workers that could run AT THE SAME TIME conflict. One that this
|
|
354
|
+
* worker depends on, directly or through others, writes its files before
|
|
355
|
+
* this one begins, so sharing a scope with it is ordinary sequential work —
|
|
356
|
+
* and is in fact the fix the refusal points at.
|
|
357
|
+
* @param request - The resolved spawn request.
|
|
358
|
+
* @returns Warnings to record; throws instead under the `reject` policy.
|
|
359
|
+
*/
|
|
360
|
+
private checkWriteScopes;
|
|
361
|
+
/**
|
|
362
|
+
* Say what actually happened to a worker, in words the lead can act on.
|
|
363
|
+
*
|
|
364
|
+
* A raw abort reads "The operation was aborted due to timeout", which tells
|
|
365
|
+
* the lead nothing about WHOSE timeout or whether re-delegating would help.
|
|
366
|
+
* Codex reports a status the parent can branch on; the DeepSeek harness
|
|
367
|
+
* records a blocker code with an explanation. This is the same idea at the
|
|
368
|
+
* size this harness needs.
|
|
369
|
+
* @param error - Whatever ended the run.
|
|
370
|
+
* @returns The explanation to record and report.
|
|
371
|
+
*/
|
|
372
|
+
private describeWorkerFailure;
|
|
373
|
+
/** The one explanation an expired worker deadline deserves. */
|
|
374
|
+
private deadlineFailure;
|
|
375
|
+
/**
|
|
376
|
+
* Block until a worker reports, or the hold deadline passes.
|
|
377
|
+
*
|
|
378
|
+
* Bounded on purpose. An unbounded wait would hand the whole run's liveness to
|
|
379
|
+
* the slowest worker and, since this runs inside a turn hook, would be cut off
|
|
380
|
+
* by the hook timeout rather than by anything that understands the work. When
|
|
381
|
+
* it expires the lead gets its turn back and decides for itself — wait again
|
|
382
|
+
* with `wait_agents`, close one, or answer with what it has.
|
|
383
|
+
* @param outstanding - Workers that have not settled.
|
|
384
|
+
*/
|
|
385
|
+
private awaitWorkerNews;
|
|
386
|
+
/** Every worker reachable through `dependsOn`, transitively. */
|
|
387
|
+
private ancestorsOf;
|
|
388
|
+
/** Whether every named worker has reached a final state. */
|
|
389
|
+
private dependenciesSettled;
|
|
390
|
+
/**
|
|
391
|
+
* Start whatever was waiting on the worker that just settled.
|
|
392
|
+
*
|
|
393
|
+
* Dependents are released when their dependencies SETTLE, not when they
|
|
394
|
+
* succeed. Requiring success would let one failed worker strand every step
|
|
395
|
+
* planned after it, and a plan that stalls silently is worse than one whose
|
|
396
|
+
* later stages are told the earlier ones broke — which is exactly what they
|
|
397
|
+
* are told: each dependent starts with what its dependencies produced.
|
|
398
|
+
*/
|
|
399
|
+
private releaseDependents;
|
|
400
|
+
/** What the dependencies produced, as context for a dependent about to start. */
|
|
401
|
+
private dependencyReport;
|
|
402
|
+
/**
|
|
403
|
+
* Watch a detached worker run to its end and report it.
|
|
404
|
+
*
|
|
405
|
+
* Never rejects: the run has no awaiting caller, so a throw here would be an
|
|
406
|
+
* unhandled rejection. Failures are recorded on the runtime and told to the
|
|
407
|
+
* lead instead, which is the same shape `AgentTeam.runWakeLoop` uses for the
|
|
408
|
+
* other kind of un-awaited member run.
|
|
409
|
+
*/
|
|
410
|
+
private followWorker;
|
|
411
|
+
/**
|
|
412
|
+
* Tell the lead what one of its workers did.
|
|
413
|
+
*
|
|
414
|
+
* Quiet WHILE THE LEAD IS STILL IN ITS TURN: the report appends to history
|
|
415
|
+
* and the next model round rebuilds its request from history, so the lead
|
|
416
|
+
* reads it without an extra turn being scheduled. Holding that turn open is
|
|
417
|
+
* {@link leadHooks}'s job.
|
|
418
|
+
*
|
|
419
|
+
* A wake-up once the lead has gone idle, because then nothing else will ever
|
|
420
|
+
* read the report. The hold cannot cover every case — a turn that ended on
|
|
421
|
+
* its step budget, or on an error, is not eligible to continue, and a worker
|
|
422
|
+
* that outlives the run reports into a conversation with no turn left. That
|
|
423
|
+
* is the failure this exists for: the transcript ends on a worker's own
|
|
424
|
+
* output, and the synthesis the lead was there to write never happens. One
|
|
425
|
+
* more turn is the point, not a duplicate answer.
|
|
426
|
+
*/
|
|
427
|
+
private notifyLead;
|
|
428
|
+
/**
|
|
429
|
+
* Quiet into an open turn, a wake-up into an idle conversation.
|
|
430
|
+
* @param worker - The worker whose report is being delivered.
|
|
431
|
+
* @returns The delivery the report needs to actually be read.
|
|
432
|
+
*/
|
|
433
|
+
private deliveryFor;
|
|
434
|
+
/** Set when a worker report was delivered quietly and no round has read it. */
|
|
435
|
+
private unreadReports;
|
|
436
|
+
/**
|
|
437
|
+
* Wait until no worker is outstanding and the lead has nothing left to do.
|
|
438
|
+
*
|
|
439
|
+
* The roster cannot answer this on its own. A worker's last event fires
|
|
440
|
+
* before its run resolves, and its completion report — the thing that wakes
|
|
441
|
+
* the lead — is delivered after that. For the moment in between, every member
|
|
442
|
+
* looks idle: a caller watching the roster sees a finished team and stops
|
|
443
|
+
* listening, exactly as the synthesis is about to be written. Waiting here
|
|
444
|
+
* covers that gap, because a worker's `settled` resolves only once its report
|
|
445
|
+
* has been delivered.
|
|
446
|
+
* @param signal - Gives up waiting; the work itself is not cancelled.
|
|
447
|
+
*/
|
|
448
|
+
whenQuiet(signal?: AbortSignal): Promise<void>;
|
|
449
|
+
/** Current detached worker lifecycle view. */
|
|
450
|
+
workers(): readonly ManagedAgentWorker[];
|
|
451
|
+
private workerView;
|
|
452
|
+
/**
|
|
453
|
+
* Wait for one worker to finish, for at most `timeoutMs`.
|
|
454
|
+
*
|
|
455
|
+
* Bounded on purpose. An unbounded wait is how a host loses the ability to
|
|
456
|
+
* tell a slow worker from a stuck one; a caller that gets `undefined` back
|
|
457
|
+
* still holds every other option.
|
|
458
|
+
* @param name - Worker address.
|
|
459
|
+
* @param options - Budget, default {@link DEFAULT_WAIT_TIMEOUT_MS}, and a signal.
|
|
460
|
+
* @returns Its result, or undefined if it had not finished in time.
|
|
461
|
+
*/
|
|
462
|
+
awaitWorker(name: string, options?: {
|
|
463
|
+
readonly timeoutMs?: number;
|
|
464
|
+
readonly signal?: AbortSignal;
|
|
465
|
+
}): Promise<ManagedAgentWorkerResult | undefined>;
|
|
466
|
+
/**
|
|
467
|
+
* Stop a worker and give up its slot.
|
|
468
|
+
*
|
|
469
|
+
* This is the stopping point a delegated agent otherwise lacks. A worker that
|
|
470
|
+
* has already finished is still occupying a `maxWorkers` slot, so closing is
|
|
471
|
+
* how a lead makes room for the next one.
|
|
472
|
+
* @param name - Worker address.
|
|
473
|
+
* @param reason - Cancellation reason for a worker still running.
|
|
474
|
+
* @returns The status it held before being closed.
|
|
475
|
+
*/
|
|
476
|
+
closeWorker(name: string, reason?: unknown): Promise<ManagedAgentWorkerStatus>;
|
|
477
|
+
/**
|
|
478
|
+
* Stop every worker this harness started.
|
|
479
|
+
*
|
|
480
|
+
* Workers outlive the lead's turn by design, so something has to end them:
|
|
481
|
+
* without this a detached run would keep calling the model after the host had
|
|
482
|
+
* moved on. Disposing the underlying `AgentTeam` is left to whoever owns it.
|
|
483
|
+
* @param reason - Cancellation reason handed to each worker.
|
|
484
|
+
*/
|
|
485
|
+
dispose(reason?: unknown): Promise<void>;
|
|
486
|
+
/** Remove one idle generated worker from the harness and shared roster. */
|
|
487
|
+
removeWorker(name: string): void;
|
|
488
|
+
private controlTools;
|
|
489
|
+
/**
|
|
490
|
+
* Build the history a `fork` worker starts from.
|
|
491
|
+
*
|
|
492
|
+
* Limits come from the WORKER's session options, not the lead's: this is the
|
|
493
|
+
* worker's own history from here on, and it is the worker's configured
|
|
494
|
+
* ceiling that has to hold it.
|
|
495
|
+
* @returns The lead's completed conversation as a fresh history.
|
|
496
|
+
*/
|
|
497
|
+
private forkLeadHistory;
|
|
498
|
+
private workerDefinition;
|
|
499
|
+
private nextWorkerName;
|
|
500
|
+
private observeWorkerEvent;
|
|
501
|
+
}
|
|
502
|
+
declare function createManagedAgentTeam(options: ManagedAgentTeamOptions): ManagedAgentTeam;
|
|
503
|
+
/**
|
|
504
|
+
* Copy the lead's conversation up to the last point it was complete.
|
|
505
|
+
*
|
|
506
|
+
* The lead is INSIDE a turn when it calls `spawn_agent`: the assistant message
|
|
507
|
+
* carrying that very call is already in history, and its result cannot be,
|
|
508
|
+
* because producing it is what this code is doing. Handing that tail to a
|
|
509
|
+
* worker gives it a conversation ending in an unanswered tool call — which
|
|
510
|
+
* providers reject, and which would turn a context optimisation into a spawn
|
|
511
|
+
* that fails outright.
|
|
512
|
+
*
|
|
513
|
+
* So the fork is cut at the last position where no tool call was outstanding.
|
|
514
|
+
* That is also the honest boundary in meaning: work still in flight is not yet
|
|
515
|
+
* something the lead knows. The DeepSeek harness names the same rule a
|
|
516
|
+
* "completed-turn prefix".
|
|
517
|
+
*
|
|
518
|
+
* A prefix is safe to hydrate as a history in its own right: `replace` surface
|
|
519
|
+
* ops and compaction records only ever reference earlier entries, so cutting
|
|
520
|
+
* from the end cannot orphan a reference.
|
|
521
|
+
* @param snapshot - The lead's history, taken mid-turn.
|
|
522
|
+
* @returns Entries up to that boundary; empty when nothing has completed.
|
|
523
|
+
*/
|
|
524
|
+
declare function completedHistoryPrefix(snapshot: HistorySnapshot): readonly HistoryEntry[];
|
|
525
|
+
//#endregion
|
|
526
|
+
export { DEFAULT_SPAWN_SETUP_TIMEOUT_MS, DEFAULT_WORKER_CLOSE_TIMEOUT_MS, ManagedAgentRole, ManagedAgentSpawnContext, ManagedAgentSpawnRequest, ManagedAgentTeam, ManagedAgentTeamOptions, ManagedAgentWorker, ManagedAgentWorkerResult, ManagedAgentWorkerStatus, ResolvedManagedAgentSpawnRequest, WriteScopeConflictPolicy, completedHistoryPrefix, createManagedAgentTeam };
|
|
527
|
+
//# sourceMappingURL=managed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed.d.ts","names":[],"sources":["../../../src/agent/team/managed.ts"],"mappings":";;;;;;;;;;;KAuBK,yBAAyB,KAAK;;;;;;;;;cAUtB;;cAGA;;;;;;;;;;;;;;;;;KA6ED;;;;;;;;;;;;;;;UAgBK;;WAEN;;WAEA;;WAEA;;WAEA;;;KAIC;UAEK;;WAEN;WACA;;WAEA;;;;;WAKA,UAAU;;WAEV;;;;;;;;;;;;;;;WAeA;;;;;;;;;;WAUA;;UAGM,yCAAyC;WAC/C;WACA,SAAS;WACT;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;;;;;;;;;;KAWC;UAGK;WACN;WACA;WACA;WACA;WACA;;WAEA,SAAS;WACT;;WAEA;;WAEA;WACA,QAAQ;;WAER;WACA,SAAS;WACT;;UAGM;WACN,UAAU;WACV,MAAM;WACN;WACA;WACA,OAAO,YAAY;WACnB;;WAEA;;WAEA;;;;;;;;;;;;WAYA,sBAAsB;;;;;;;;WAQtB,iBAAiB;;;;;;;;;;;;WAYjB,mBAAmB;;;;;WAKnB;;WAEA;;WAEA;;;;;;;;WAQA;;;;;;;;;;WAUA;;;WAGA;;;;;;;;;WASA;;WAEA,iBAAiB;WACjB,iBACP,SAAS,qCACN,eAAe,QAAQ;WACnB,qBAAqB;aAAoC,QAAQ,uBAAuB;;WACxF,uBAAuB;aAAoC,QAAQ,uBAAuB;;;WAE1F,+BACP,SAAS,sCACL;aAAoC,QAAQ,uBAAuB;OACrE,QAAQ;aAAoC,QAAQ,uBAAuB;;;WAEtE,iBACP,gBACA,OAAO,yBACG;;;;;;;;;;;;;cAsED;WACF,MAAM;WACN,MAAM;WACN;mBACQ;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;UACT;mBACS;mBACA;EAEjB,YAAY,SAAS;;;;;;;;;;;;;;;;;;UAyDb;;EA6DR,IAAI,OAAO,YAAY,aAAY,yBAA8B,QAAQ;;;;;;;;;;;;;EAgBzE,MAAM;;;;;;;;;;;;EAsBA,MACJ,SAAS,0BACT,SAAS,cACR,QAAQ;;;;;;;UAwHH;;;;;;;;;;UA2CA;;UAeA;;;;;;;;;UAqBA;;;;;;;;;;;UAsBA;;;;;;;;;;;;UAwCA;;UASA;;;;;;;;;;;UAeM;;UAgBN;;UAWA;;;;;;;;;;UAiBM;;UAyBN;;;;;;;;;UA2BM;;;;;;;;;;;;;;;;;UAgFA;;;;;;UAwBN;;UAWA;;;;;;;;;;;;;EAcF,UAAU,SAAS,cAAc;;EAcvC,oBAAoB;UAIZ;;;;;;;;;;;EA4BF,YACJ,cACA;aAAoB;aAA6B,SAAS;MACzD,QAAQ;;;;;;;;;;;EA4BL,YACJ,cACA,mBACC,QAAQ;;;;;;;;;EAmDL,QAAQ,mBAA6D;;EAM3E,aAAa;UAWL;;;;;;;;;UAyHA;UAQM;UAmBN;UAQM;;iBAMA,uBAAuB,SAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;iBAuF1D,uBACd,UAAU,2BACA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{waitForSettlement as e}from"../../async/settlement.js";import{timeoutValue as t}from"../../platform/config.js";import{createTextMessage as n}from"../../message/message.js";import{defineTool as r}from"../tool/definition.js";import{ToolRegistry as i}from"../tool/registry.js";import{History as a}from"../history/history.js";import{cloneAgent as o}from"../define/definition.js";import"./common.js";import{AgentTeam as s}from"./team.js";const c=3e4,l=3e4,u=15e3,d=[`You lead a managed dynamic team. Delegation buys parallelism; it is not a way to distribute a task you have not yet understood.`,`PLAN BEFORE YOU DELEGATE. State briefly what the objective needs, which steps block the others, and which can run alongside them, and decide what you will do yourself right now. Only then spawn.`,`Do the blocking step yourself. If your very next action depends on a result, producing it locally is faster than delegating it and waiting for it.`,`Delegate work that runs alongside your own: concrete, bounded, self-contained, and worth a whole worker.`,"GIVE EACH WORKER A DISJOINT SET OF FILES TO WRITE. Declare them in `writes`, and say which in its task. Two workers building different features of one file will each write that file, and the later write erases the earlier one; a spawn that would do this is refused.",'A WORKER THAT ONLY READS DECLARES NOTHING: leave `writes` out. Do not invent a placeholder such as "none" or "/tmp/no-write" — that claims a real scope, and several readers sharing one stand-in are refused for colliding over a file none of them writes.',"EXPRESS ORDER WITH `dependsOn`, NOT BY SPAWNING LATE. A worker that reviews, integrates, or builds on another names it there: it is created now, held until that work settles, and then given what it produced. Spawn the whole plan in one step and let the order be enforced rather than remembered.","Do not delegate review, audit or verification against nothing. Either the thing to be reviewed already exists, or the reviewer `dependsOn` whoever is producing it. A reviewer started over an empty workspace produces a checklist, not a review.",`When the work does not exist yet, the first step is yours: establish its shape — scaffold, layout, shared types — and then delegate the independent pieces of it.`,`Choose each worker context deliberately: fork when it needs what you have already found out, fresh when its task genuinely stands alone. Given neither, every worker rediscovers the workspace for itself.`,`Call spawn_agent several times in one step for work that is genuinely independent, and once for work that is not.`,`spawn_agent does not return a result: workers run while you keep working, and each one reports back to you when it finishes.`,`After delegating, do useful non-overlapping work. Do not wait by reflex, and do not redo what you delegated.`,`Use wait_agents only when you need a result to continue. It returns within its timeout whether or not anyone finished, so read the reported status and decide again.`,`Read a finished worker result from list_agents, then call close_agent to release its slot.`,`A send_message update or accepted self-check is not the worker final report. Wait for its completed/failed status before normal closure. Use cancelRunning only when deliberately abandoning its unfinished work.`,`Never answer as if a worker had reported when it has not; say what is still outstanding instead.`,`Synthesize worker results yourself and remain responsible for the final answer.`].join(` `);var f=class{team;lead;leadName;options;maxWorkers;maxTaskBytes;maxSpecialtyBytes;workerTimeoutMs;observerTimeoutMs;closeTimeoutMs;holdWaitMs;spawnTimeoutMs;workerRuntimes=new Map;reservedNames=new Set;workerSequence=0;maxDependencyReportBytes;roles;constructor(e){if(this.options=e,this.maxWorkers=w(e.maxWorkers??7,`maxWorkers`),this.maxTaskBytes=w(e.maxTaskBytes??65536,`maxTaskBytes`),this.maxSpecialtyBytes=w(e.maxSpecialtyBytes??8192,`maxSpecialtyBytes`),this.workerTimeoutMs=t(e.workerTimeoutMs??6e5),this.observerTimeoutMs=t(e.observerTimeoutMs??1e3),this.closeTimeoutMs=t(e.closeTimeoutMs??3e4),this.holdWaitMs=t(e.holdWaitMs??15e3),this.spawnTimeoutMs=t(e.spawnTimeoutMs??3e4),this.maxDependencyReportBytes=w(e.maxDependencyReportBytes??8192,`maxDependencyReportBytes`),this.roles=new Map((e.roles??[]).map(e=>[e.name,e])),this.roles.size!==(e.roles??[]).length)throw Error(`managed agent roles contain a duplicate name`);this.team=e.team instanceof s?e.team:new s({...e.team,maxMembers:e.team?.maxMembers??this.maxWorkers+1}),this.leadName=x(e.leadName??e.lead.id),this.lead=e.lead.createSession({...e.leadSessionOptions,hooks:this.leadHooks(e.leadSessionOptions?.hooks),registry:e.registry,tools:m(e.leadSessionOptions?.tools,this.controlTools()),team:{team:this.team,name:this.leadName,role:`lead`,instructions:d,...e.leadDescription===void 0?{}:{description:e.leadDescription}}})}leadHooks(e){return{...e,beforeStep:async t=>(this.unreadReports=!1,await e?.beforeStep?.(t)??{kind:`proceed`}),onTurnEnd:async t=>{if(await e?.onTurnEnd?.(t),!t.canContinue){if(this.unreadReports){this.unreadReports=!1;try{this.team.wake(this.leadName)}catch{}}return}let n=[...this.workerRuntimes.values()].filter(e=>e.status===`running`||e.status===`pending`);if(n.length===0)return;await this.awaitWorkerNews(n);let r=[...this.workerRuntimes.values()].filter(e=>e.status===`running`||e.status===`pending`).map(e=>e.request.name);if(r.length===0){this.lead.inject(`Every worker has reported. Read their results and write the answer you owe the user; do not delegate again unless something is genuinely missing.`);return}this.lead.inject(`Not finished: ${r.join(`, `)} ${r.length===1?`is`:`are`} still running. Use wait_agents to wait for them and read their results, or close_agent with cancelRunning: true to give up on one. Do not present a conclusion that depends on work they have not reported yet.`)}}}run(e,t={}){return this.lead.run(e,t)}steer(e){this.lead.inject(e);try{this.team.notifySteer(this.leadName)}catch{}if(!this.lead.isRunning)try{this.team.wake(this.leadName)}catch{}return!0}async spawn(e,t){t?.throwIfAborted();let r={name:x(e.name??this.nextWorkerName()),task:C(e.task,`worker task`,this.maxTaskBytes),...e.specialty===void 0?{}:{specialty:C(e.specialty,`worker specialty`,this.maxSpecialtyBytes)},context:e.context??this.options.defaultSpawnContext??`fresh`,...e.role===void 0?{}:{role:this.requireRole(e.role)},dependsOn:this.resolveDependencies(e.dependsOn??[]),writes:[...new Set((e.writes??[]).map(j))]};if(this.workerRuntimes.size+this.reservedNames.size>=this.maxWorkers)throw Error(`managed agent team reached its ${this.maxWorkers}-worker limit`);if(this.reservedNames.has(r.name)||this.workerRuntimes.has(r.name)||this.team.members().some(e=>e.name===r.name))throw Error(`managed worker '${r.name}' already exists`);this.reservedNames.add(r.name);let i;try{let e=this.checkWriteScopes(r),a=D(t,AbortSignal.timeout(this.workerTimeoutMs)),o=await E(this.workerDefinition(r),a);a.throwIfAborted();let s=this.options.workerSessionOptionsFactory===void 0?void 0:await E(Promise.resolve(this.options.workerSessionOptionsFactory(r)),a);a.throwIfAborted();let c=o.createSession({...this.options.workerSessionOptions,...s,...r.context===`fork`?{history:this.forkLeadHistory()}:{},registry:this.options.registry,team:{team:this.team,name:r.name,role:`peer`,tools:`reporting`,instructions:[`You are a dynamically created worker reporting to '${this.leadName}'.`,`Complete the delegated task independently and return a concise evidence-backed result.`,`Do not broaden the task or attempt to become team lead.`,`Your result is delivered to '${this.leadName}' when you finish, so do not use send_message to report it; that tool is only for passing context to a DIFFERENT worker, never to yourself.`,`If you lack information, state what is missing in your result rather than waiting for an answer.`].join(` `),...r.specialty===void 0?{}:{description:r.specialty}}}),l=new AbortController,u;if(i={request:r,session:c,status:`pending`,leadDriven:this.lead.isRunning,closing:!1,deadline:void 0,controller:l,settled:new Promise(e=>{u=e}),markSettled:u,start:void 0,warnings:e,result:void 0,error:void 0},this.workerRuntimes.set(r.name,i),this.reservedNames.delete(r.name),await this.team.sendMessage({from:this.leadName,target:r.name,message:r.task,delivery:`quiet`,signal:a}),o.memory.autoCaptureObjective&&c.memory.captureOriginalObjective(n(r.task)),r.dependsOn.length>0&&!this.dependenciesSettled(r.dependsOn)){let e=new Promise(e=>{i.start=e});return this.team.markPending(r.name,e),this.workerView(i)}return this.beginWorker(i),this.workerView(i)}catch(e){throw i!==void 0&&(i.status=`failed`,i.error=T(e),i.start=void 0,i.markSettled()),e}finally{this.reservedNames.delete(r.name)}}beginWorker(e){let t=e.request.name;if(e.start?.(),e.start=void 0,this.team.markPending(t,void 0),e.status!==`pending`)return;e.status=`running`;let n=AbortSignal.timeout(this.workerTimeoutMs);e.deadline=n;let r=e.session.runPending({signal:D(e.controller.signal,n),...this.options.onWorkerEvent===void 0?{}:{onEvent:e=>this.observeWorkerEvent(t,e)}});this.followWorker(e,r)}roleSchema(){if(this.roles.size===0)return{};let e=[...this.roles.values()].map(e=>`- ${e.name}: ${e.description}`+(e.whenToUse===void 0?``:` Use when: ${e.whenToUse}`));return{role:{type:`string`,enum:[...this.roles.keys()],description:`Which kind of worker this is.\n${e.join(`
|
|
2
|
+
`)}`}}}requireRole(e){let t=S(e,`worker role`);if(this.roles.size===0)throw Error(`this managed team declares no roles, so spawn_agent takes no role`);if(!this.roles.has(t))throw Error(`unknown worker role '${t}'; declared roles are ${[...this.roles.keys()].join(`, `)}`);return t}resolveDependencies(e){return[...new Set(e.map(e=>{let t=x(e);if(!this.workerRuntimes.has(t))throw Error(`unknown dependency '${t}'; a worker can only depend on one that already exists`);return t}))]}checkWriteScopes(e){let t=this.options.writeScopePolicy??`reject`;if(t===`off`||e.writes.length===0)return[];let n=this.ancestorsOf(e.dependsOn),r=[];for(let i of this.workerRuntimes.values()){if(i.status!==`pending`&&i.status!==`running`||n.has(i.request.name))continue;let a=e.writes.filter(e=>i.request.writes.some(t=>M(e,t)));if(a.length===0)continue;let o=`'${i.request.name}' also writes ${a.join(`, `)}`;if(t===`reject`)throw Error(`worker '${e.name}' would write files another running worker writes: ${o}. Add '${i.request.name}' to dependsOn so it runs after, or narrow the scopes — or omit writes entirely if this worker only reads.`);r.push(o)}return r}describeWorkerFailure(e,t){if(t?.deadline?.aborted===!0)return this.deadlineFailure();let n=e?.name;return n===`TimeoutError`?this.deadlineFailure():n===`AbortError`?`its work was cancelled before it finished`:T(e)}deadlineFailure(){return`it ran past its ${String(this.workerTimeoutMs)}ms deadline without finishing. Narrow the task, or split it, before delegating it again`}async awaitWorkerNews(e){let t,n=new Promise(e=>{t=setTimeout(e,this.holdWaitMs),t.unref?.()});try{await Promise.race([...e.map(e=>e.settled),n])}finally{t!==void 0&&clearTimeout(t)}}ancestorsOf(e,t=new Set){for(let n of e){if(t.has(n))continue;t.add(n);let e=this.workerRuntimes.get(n);e!==void 0&&this.ancestorsOf(e.request.dependsOn,t)}return t}dependenciesSettled(e){return e.every(e=>{let t=this.workerRuntimes.get(e);return t===void 0||k.has(t.status)})}async releaseDependents(e){let t=[...this.workerRuntimes.values()].filter(t=>t.status===`pending`&&t.request.dependsOn.includes(e)&&this.dependenciesSettled(t.request.dependsOn));for(let e of t){let t=this.dependencyReport(e.request.dependsOn);if(t!==void 0)try{await this.team.sendMessage({from:this.leadName,target:e.request.name,message:t,delivery:`quiet`})}catch{}this.beginWorker(e)}}dependencyReport(e){let t=e.map(e=>{let t=this.workerRuntimes.get(e);if(t===void 0)return`- ${e}: closed before reporting.`;if(t.error!==void 0){let n=t.result?.text;return`- ${e} FAILED: ${t.error}`+(n?`\nPartial findings (not a completed task): ${N(n,this.maxDependencyReportBytes)}`:``)}return`- ${e} finished: ${N(t.result?.text??``,this.maxDependencyReportBytes)}`});if(t.length!==0)return[`Work you depend on has finished. Its results follow; build on them rather than redoing them.`,...t].join(`
|
|
3
|
+
`)}async followWorker(e,t){let n=e.request.name;try{let r=await t;if(e.status!==`closed`&&!e.closing){let t=e.deadline?.aborted===!0?this.deadlineFailure():A(r);t===void 0?(e.status=`completed`,e.result=Object.freeze({worker:n,agentId:e.session.definition.id,conversationId:e.session.conversationId,text:r.text,succeeded:r.outcome.completed}),this.team.recordOutcome(n,{kind:`completed`,text:r.text}),await this.notifyLead(n,`finished: ${r.text}`)):(e.status=`failed`,e.error=t,r.text.trim()!==``&&(e.result=Object.freeze({worker:n,agentId:e.session.definition.id,conversationId:e.session.conversationId,text:r.text,succeeded:!1})),this.team.recordOutcome(n,{kind:`failed`,message:t}),await this.notifyLead(n,`failed: ${t}`+(e.result===void 0?``:`\nPartial findings (not a completed task): ${e.result.text}`)))}}catch(t){e.status!==`closed`&&!e.closing&&(e.status=`failed`,e.error=this.describeWorkerFailure(t,e),this.team.recordOutcome(n,{kind:`failed`,message:e.error}),await this.notifyLead(n,`failed: ${e.error}`))}finally{e.markSettled(),await this.releaseDependents(n)}}async notifyLead(e,t){let n=this.deliveryFor(e);n===`quiet`&&(this.unreadReports=!0);try{await this.team.sendMessage({from:e,target:this.leadName,message:`Worker '${e}' ${t}`,delivery:n})}catch{}}deliveryFor(e){return this.lead.isRunning||this.workerRuntimes.get(e)?.leadDriven!==!0?`quiet`:`wakeup`}unreadReports=!1;async whenQuiet(e){for(;;){e?.throwIfAborted();let t=[...this.workerRuntimes.values()].filter(e=>e.status===`pending`||e.status===`running`);if(t.length>0&&await Promise.all(t.map(e=>e.settled)),await this.team.whenIdle(this.leadName,e),![...this.workerRuntimes.values()].some(e=>e.status===`pending`||e.status===`running`))return}}workers(){return Object.freeze([...this.workerRuntimes.values()].map(e=>this.workerView(e)))}workerView(e){return Object.freeze({name:e.request.name,agentId:e.session.definition.id,conversationId:e.session.conversationId,task:e.request.task,status:e.status,context:e.request.context,dependsOn:e.request.dependsOn,writes:e.request.writes,...e.request.role===void 0?{}:{role:e.request.role},...e.warnings.length===0?{}:{warnings:e.warnings},...e.request.specialty===void 0?{}:{specialty:e.request.specialty},...e.result===void 0?{}:{result:e.result},...e.error===void 0?{}:{error:e.error}})}async awaitWorker(e,n={}){let r=x(e),i=this.workerRuntimes.get(r);if(i===void 0)throw Error(`unknown managed worker '${r}'`);let a=t(n.timeoutMs??3e4),o,s=new Promise(e=>{o=setTimeout(e,a)});try{await Promise.race([i.settled,s])}finally{clearTimeout(o)}return n.signal?.throwIfAborted(),i.result}async closeWorker(t,n=Error(`managed worker closed`)){let r=x(t),i=this.workerRuntimes.get(r);if(i===void 0)throw Error(`unknown managed worker '${r}'`);let a=i.status;i.closing=!0,i.controller.abort(n);try{await this.team.cancel(r,n)}catch{}a===`pending`?(i.status=`closed`,i.start=void 0,this.team.markPending(r,void 0),i.markSettled()):(await e(i.settled,this.closeTimeoutMs),i.status=`closed`),this.workerRuntimes.delete(r);try{this.team.detach(r)}catch{}return await this.releaseDependents(r),a}async dispose(e=Error(`managed agent team disposed`)){let t=[...this.workerRuntimes.keys()];await Promise.allSettled(t.map(t=>this.closeWorker(t,e)))}removeWorker(e){let t=x(e),n=this.workerRuntimes.get(t);if(n===void 0)throw Error(`unknown managed worker '${t}'`);if(n.status===`running`||n.session.isRunning)throw Error(`cannot remove running managed worker '${t}'`);this.team.detach(t),this.workerRuntimes.delete(t)}controlTools(){return Object.freeze([r({name:`spawn_agent`,description:[`Create a connected specialist worker and start one task on it.`,`Returns as soon as the worker is running, WITHOUT its result: keep working,`,`and you will be told when it finishes. Use wait_agents to pause for it,`,`list_agents to read its status and result, and close_agent when done with it.`,`Before the first call, plan: name the step that blocks the others and do that`,`one yourself. Then spawn the rest of the plan in one step: declare each`,"worker's `writes` so two never write the same file, and use `dependsOn` for",`anything that must follow another worker rather than waiting to spawn it.`].join(` `),parameters:{type:`object`,properties:{name:{type:`string`,description:`Optional unique worker address; omitted generates worker_N.`},task:{type:`string`,description:`Concrete bounded task assigned to the worker. State which files it owns and may write, so two workers never write the same one.`},specialty:{type:`string`,description:`Optional worker role or domain specialization.`},context:{type:`string`,enum:[`fresh`,`fork`],description:`fresh starts the worker from its task alone; fork also gives it your conversation so far, so it does not have to rediscover what you already established. Prefer fork when the task depends on findings of yours.`},dependsOn:{type:`array`,items:{type:`string`},description:`Names of workers that must finish before this one starts. The worker is created now and held until they do, then given what they produced — so spawn the whole plan at once and express the ORDER here rather than by spawning later. Use it for anything that reviews, integrates or builds on another worker.`},writes:{type:`array`,items:{type:`string`},description:`Files and directories this worker may write, workspace-relative. A spawn that would write what another worker running at the same time writes is refused, because both would write it and the later write wins. Declare them and the conflict is caught before any work is lost. OMIT this entirely for a worker that only reads — a stand-in path such as "none" or "/tmp/no-write" claims a real scope, and several readers sharing that stand-in collide with each other over a file none of them will ever write.`},...this.roleSchema()},required:[`task`],additionalProperties:!1},parse:g,execute:async(e,t)=>O(await this.spawn(e,t.signal)),timeoutMs:this.spawnTimeoutMs,isConcurrencySafe:()=>!0}),r({name:`close_agent`,budgetExempt:!0,description:[`Close a worker you no longer need and free its slot.`,`A finished worker still occupies one until closed, so close it once you have read its result.`,`A running or pending worker is kept alive by default so it can finish its final report.`,this.options.allowModelWorkerCancellation===!1?`The host requires worker reports: you cannot cancel unfinished workers. Wait for their result.`:`Set cancelRunning: true only to deliberately abandon unfinished work and cancel it.`,`Returns the status it held before closing.`].join(` `),parameters:{type:`object`,properties:{name:{type:`string`,description:`Worker address returned by spawn_agent.`},cancelRunning:{type:`boolean`,description:`Explicitly cancel an unfinished worker. Defaults to false.`}},required:[`name`],additionalProperties:!1},parse:h,execute:async({name:e,cancelRunning:t})=>{let n=this.workerRuntimes.get(e);return n!==void 0&&(!t||this.options.allowModelWorkerCancellation===!1)&&(n.status===`pending`||n.status===`running`||n.session.isRunning)?O({worker:e,closed:!1,status:n.status===`pending`?`pending`:`running`,instruction:`The worker has not finished its final report. Use wait_agents and read its completed result before closing.`+(this.options.allowModelWorkerCancellation===!1?` Model cancellation is disabled by the host.`:` To deliberately abandon this work, call close_agent with cancelRunning: true.`)}):O({worker:e,closed:!0,previousStatus:await this.closeWorker(e)})},timeoutMs:this.workerTimeoutMs})])}forkLeadHistory(){let e=y(this.lead.snapshot().history);return a.fromSnapshot({version:1,entries:e},this.options.workerSessionOptions?.historyLimits??{})}async workerDefinition(e){if(this.options.workerFactory!==void 0)return this.options.workerFactory(e);let t=this.options.workerTemplate??this.options.lead,n=e.role===void 0?void 0:this.roles.get(e.role),r=n===void 0?``:` You are the '${n.name}' worker. ${n.instructions??n.description}`,i=e.specialty===void 0?``:` Your specialization is: ${e.specialty}.`;return o(t,{id:e.name,name:e.name,instructions:`${t.instructions}\n\nYou are dynamically assigned worker '${e.name}'.${r}${i}`})}nextWorkerName(){for(;;){let e=`worker_${++this.workerSequence}`;if(!this.reservedNames.has(e)&&!this.workerRuntimes.has(e)&&!this.team.members().some(t=>t.name===e))return e}}async observeWorkerEvent(t,n){let r=Promise.resolve().then(()=>this.options.onWorkerEvent?.(t,n));await e(r,this.observerTimeoutMs)}};function p(e){return new f(e)}function m(e,t){let n=new i;if(e!==void 0){let t=`names`in e?e.names().map(t=>e.get(t)).filter(e=>e!==void 0):e;for(let e of t)n.register(e)}for(let e of t)n.register(e);return n}function h(e){let t=b(e,`close_agent arguments`);if(Object.keys(t).some(e=>e!==`name`&&e!==`cancelRunning`))throw TypeError(`close_agent arguments contain unknown fields`);if(t.cancelRunning!==void 0&&typeof t.cancelRunning!=`boolean`)throw TypeError(`close_agent cancelRunning must be a boolean`);return{name:x(t.name),cancelRunning:t.cancelRunning===!0}}function g(e){let t=b(e,`spawn_agent arguments`),n=new Set([`name`,`task`,`specialty`,`context`,`role`,`dependsOn`,`writes`]);if(Object.keys(t).some(e=>!n.has(e)))throw TypeError(`spawn_agent arguments contain unknown fields`);return{task:S(t.task,`worker task`),...t.name===void 0?{}:{name:x(t.name)},...t.specialty===void 0?{}:{specialty:S(t.specialty,`worker specialty`)},...t.context===void 0?{}:{context:v(t.context)},...t.role===void 0?{}:{role:S(t.role,`worker role`)},...t.dependsOn===void 0?{}:{dependsOn:_(t.dependsOn,`dependsOn`)},...t.writes===void 0?{}:{writes:_(t.writes,`writes`)}}}function _(e,t){if(!Array.isArray(e))throw TypeError(`${t} must be an array of strings`);return e.map(e=>S(e,`${t} entry`))}function v(e){if(e!==`fresh`&&e!==`fork`)throw TypeError(`worker context must be 'fresh' or 'fork'`);return e}function y(e){let t=new Set,n=0;return e.entries.forEach((e,r)=>{let i=e.event;if(i.kind===`tool-call`)t.add(i.callId);else if(i.kind===`tool-result`)t.delete(i.callId);else if(i.kind===`assistant`)for(let e of i.message.content)e.type===`tool-call`&&t.add(e.id);t.size===0&&(i.kind!==`assistant`||i.interrupted!==!0)&&(n=r+1)}),e.entries.slice(0,n)}function b(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`${t} must be an object`);return e}function x(e){let t=S(e,`managed agent name`);if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(t))throw TypeError(`managed agent name must start with a letter and contain only letters, digits, _ or -`);if(t.length>128)throw TypeError(`managed agent name must not exceed 128 characters`);return t}function S(e,t){if(typeof e!=`string`||e.trim().length===0)throw TypeError(`${t} must be a non-empty string`);return e}function C(e,t,n){let r=S(e,t);if(new TextEncoder().encode(r).byteLength>n)throw TypeError(`${t} exceeds the ${n}-byte limit`);return r}function w(e,t){if(!Number.isSafeInteger(e)||e<1)throw TypeError(`${t} must be a positive integer`);return e}function T(e){return e instanceof Error?e.message:String(e)}async function E(e,t){if(t.aborted)throw t.reason??Error(`managed worker aborted`);return await new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(t.reason??Error(`managed worker aborted`))};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function D(...e){let t=e.filter(e=>e!==void 0);return t.length===1?t[0]:AbortSignal.any(t)}function O(e){return e}const k=new Set([`completed`,`failed`,`closed`]);function A(e){let t=e.outcome.reason;if(t.kind===`error`)return t.failure.message;if(t.kind===`max-tokens`)return`the model stopped at its output limit`;if(t.kind===`usage-unavailable`)return`the provider reported no usage for a billed call`;if(t.kind===`aborted`)return`the run was aborted`;if(t.kind===`budget-exhausted`&&!e.outcome.completed)return`the run stopped at its ${t.budget} limit before completing the task`;if(e.text.trim()===``)return`it produced no answer`}function j(e){let t=S(e,`worker write scope`).trim().split(`\\`).join(`/`).replace(/^\.?\/+/,``).replace(/\/+$/,``);if(t.length===0||t===`.`)throw TypeError(`a worker write scope must name a file or directory, not the whole workspace`);return t}function M(e,t){return e===t||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)}function N(e,t){let n=new TextEncoder().encode(e);return n.byteLength<=t?e:`${new TextDecoder(`utf-8`,{fatal:!1}).decode(n.subarray(0,t)).replace(/�$/,``)}… (truncated)`}export{u as DEFAULT_HOLD_WAIT_MS,c as DEFAULT_SPAWN_SETUP_TIMEOUT_MS,l as DEFAULT_WORKER_CLOSE_TIMEOUT_MS,f as ManagedAgentTeam,y as completedHistoryPrefix,p as createManagedAgentTeam};
|
|
4
|
+
//# sourceMappingURL=managed.js.map
|