@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":"catalog.js","names":[],"sources":["../../../src/agent/skill/catalog.ts"],"sourcesContent":["/** Merged, refreshable skill catalog shared by web and filesystem sources. */\n\nimport {\n MAX_SKILL_RESOURCE_CHARS,\n defineSkill,\n skillSummary,\n validateCandidate,\n validateSkillId,\n validateSkillResourcePath,\n validateSkillSource,\n type SkillCandidate,\n type SkillDefinition,\n type SkillDefinitionInput,\n type SkillLookupOptions,\n type SkillProvider,\n type SkillProviderListOptions,\n type SkillResourceSummary,\n type SkillSummary,\n} from './definition.ts'\nimport { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { captureSkillProviderPlugin } from './provider/definition.ts'\nimport { skillProviderLogger } from './provider/context.ts'\nimport { capabilityIdentityError } from '../../errors/capability-identity.ts'\nimport { SKILL_ERROR_CODES, SKILL_PROVIDER_API_VERSION } from './provider/config.ts'\nimport {\n captureSkillCatalogSnapshot, captureSkillReference,\n} from './provider/snapshot.ts'\nimport type {\n ActivatedSkillSnapshot, CapturedSkillProviderPlugin, RuntimeSkillCandidate,\n RuntimeSkillLookupOptions, RuntimeSkillSource, SkillReference,\n} from './provider/types.ts'\n\ninterface CatalogEntry {\n readonly summary: SkillSummary\n readonly direct?: SkillDefinition\n readonly provider?: SkillProvider\n readonly candidate?: SkillCandidate\n readonly runtimeProvider?: CapturedSkillProviderPlugin\n readonly reference?: SkillReference\n}\n\nexport interface SkillCatalogOptions {\n /** When present, only these skill ids are visible or loadable. */\n readonly allowedSkillIds?: readonly string[]\n readonly maxSkills?: number\n readonly maxCatalogBytes?: number\n}\n\nexport class SkillCatalog {\n private readonly sources: readonly RuntimeSkillSource[]\n private readonly allowedSkillIds: readonly string[] | undefined\n private readonly allowedSkillIdSet: ReadonlySet<string> | undefined\n private readonly maxSkills: number\n private readonly maxCatalogBytes: number\n private entries = new Map<string, CatalogEntry>()\n private visible: readonly SkillSummary[] = Object.freeze([])\n private readonly activated = new Map<string, readonly SkillResourceSummary[]>()\n private readonly activatedReferences = new Map<string, ActivatedSkillSnapshot>()\n private discoveryTail: Promise<void> = Promise.resolve()\n private discovered = false\n\n constructor(sources: readonly RuntimeSkillSource[], options: SkillCatalogOptions = {}) {\n this.maxSkills = positiveSafeInteger(options.maxSkills ?? 1_024, 'skill catalog maxSkills')\n this.maxCatalogBytes = positiveSafeInteger(options.maxCatalogBytes ?? 4 * 1024 * 1024, 'skill catalog maxCatalogBytes')\n this.sources = captureCatalogSources(sources)\n if (options.allowedSkillIds === undefined) {\n this.allowedSkillIds = undefined\n this.allowedSkillIdSet = undefined\n } else {\n const ids = [...options.allowedSkillIds]\n const seen = new Set<string>()\n for (const id of ids) {\n validateSkillId(id, 'allowed skill')\n if (seen.has(id)) throw new TypeError(`duplicate allowed skill '${id}'`)\n seen.add(id)\n }\n this.allowedSkillIds = Object.freeze(ids)\n this.allowedSkillIdSet = seen\n }\n this.installDirectSkills()\n }\n\n /** Refresh provider metadata. Direct definitions remain available without I/O. */\n async discover(options: SkillLookupOptions = {}): Promise<readonly SkillSummary[]> {\n const previous = this.discoveryTail\n const run = raceAbort(previous, options.signal)\n .then(() => this.performDiscovery(options))\n // An aborted waiter must not detach the queue from a discovery still in\n // progress, otherwise the next caller could overlap the original provider I/O.\n this.discoveryTail = Promise.allSettled([previous, run]).then(() => undefined)\n return await run\n }\n\n private async performDiscovery(options: SkillLookupOptions): Promise<readonly SkillSummary[]> {\n throwIfAborted(options.signal)\n const next = new Map<string, CatalogEntry>()\n let catalogBytes = 0\n if (this.allowedSkillIds?.length === 0) {\n this.activated.clear()\n this.entries = next\n this.visible = Object.freeze([])\n this.discovered = true\n return this.visible\n }\n for (const source of this.sources) {\n if (source.kind === 'skill') {\n if (!this.isAllowed(source.id)) continue\n catalogBytes = addCatalogBytes(catalogBytes, source, this.maxCatalogBytes)\n if (next.size >= this.maxSkills) throw new RangeError(`skill catalog exceeds ${this.maxSkills} entries`)\n addUnique(next, source.id, { summary: skillSummary(source), direct: source })\n continue\n }\n if (isRuntimeProvider(source)) {\n const raw = await raceAbort(source.list(this.runtimeProviderListOptions(options)), options.signal)\n throwIfAborted(options.signal)\n const snapshot = captureSkillCatalogSnapshot(source, raw, this.maxSkills, this.maxCatalogBytes)\n for (let index = 0; index < snapshot.candidates.length; index++) {\n const candidate = snapshot.candidates[index]!\n if (!this.isAllowed(candidate.id)) continue\n catalogBytes = addCatalogBytes(catalogBytes, candidate, this.maxCatalogBytes)\n if (next.size >= this.maxSkills) throw new RangeError(`skill catalog exceeds ${this.maxSkills} entries`)\n addUnique(next, candidate.id, { summary: summaryOfRuntimeCandidate(candidate),\n runtimeProvider: source, reference: snapshot.references[index]! })\n }\n continue\n }\n const candidates = await raceAbort(source.list(this.providerListOptions(options)), options.signal)\n throwIfAborted(options.signal)\n if (candidates.length > this.maxSkills) {\n throw new RangeError(`skill provider '${source.id}' exceeds the ${this.maxSkills}-candidate limit`)\n }\n for (const candidate of candidates) {\n validateCandidate(candidate, source.id)\n if (!this.isAllowed(candidate.id)) continue\n catalogBytes = addCatalogBytes(catalogBytes, candidate, this.maxCatalogBytes)\n if (next.size >= this.maxSkills) throw new RangeError(`skill catalog exceeds ${this.maxSkills} entries`)\n addUnique(next, candidate.id, {\n summary: summaryOfCandidate(candidate), provider: source, candidate,\n })\n }\n }\n this.assertAllowedSkillsAvailable(next)\n for (const id of this.activated.keys()) {\n const previous = this.entries.get(id)\n const current = next.get(id)\n if (previous === undefined || current === undefined\n || !sameCatalogEntry(previous, current)) {\n this.activated.delete(id)\n this.activatedReferences.delete(id)\n }\n }\n this.entries = next\n this.visible = freezeSummaries(next)\n this.discovered = true\n return this.visible\n }\n\n /** Last successfully discovered catalog. Direct skills are present immediately. */\n summaries(): readonly SkillSummary[] { return this.visible }\n\n /** Load a complete body on demand. Provider definitions are intentionally not cached. */\n async load(id: string, options: SkillLookupOptions = {}): Promise<SkillDefinition | undefined> {\n throwIfAborted(options.signal)\n if (!this.discovered && (this.allowedSkillIds !== undefined\n || this.sources.some(source => source.kind === 'skill-provider'))) {\n await this.discover(options)\n }\n const entry = this.entries.get(id)\n if (entry?.direct !== undefined) return entry.direct\n if (entry?.runtimeProvider !== undefined && entry.reference !== undefined) {\n const input = await raceAbort(\n entry.runtimeProvider.load(entry.reference, this.runtimeLookupOptions(options)), options.signal,\n )\n throwIfAborted(options.signal)\n if (input === undefined) return undefined\n return this.resolveRuntimeSkill(input, entry)\n }\n if (entry?.provider === undefined || entry.candidate === undefined) return undefined\n const input = await raceAbort(entry.provider.load(entry.candidate, options), options.signal)\n throwIfAborted(options.signal)\n if (input === undefined) return undefined\n const resourceBase = input.resourceBase ?? entry.summary.resourceBase\n const resolved = defineSkill({\n ...input,\n source: entry.summary.source,\n provider: entry.provider.id,\n invocation: entry.summary.invocation,\n ...(resourceBase === undefined ? {} : { resourceBase }),\n })\n if (resolved.id !== id) {\n throw new TypeError(`skill provider '${entry.provider.id}' loaded '${resolved.id}' for candidate '${id}'`)\n }\n return resolved\n }\n\n /** Load one selected skill and remember only its small resource manifest. */\n async activate(id: string, options: SkillLookupOptions = {}): Promise<SkillDefinition | undefined> {\n if (!this.discovered && (this.allowedSkillIds !== undefined\n || this.sources.some(source => source.kind === 'skill-provider'))) {\n await this.discover(options)\n }\n const selected = this.entries.get(id)\n const skill = await this.load(id, options)\n const current = this.entries.get(id)\n if (skill !== undefined && (selected === undefined || current === undefined\n || !sameCatalogEntry(selected, current))) {\n throw new Error(`skill '${id}' changed while its instructions were loading; load it again`)\n }\n if (skill !== undefined) {\n this.activated.set(id, skill.resourceManifest)\n if (current?.reference !== undefined) this.activatedReferences.set(id, Object.freeze({\n ...current.reference,\n ...(skill.resourceBase === undefined ? {} : { resourceBase: Object.freeze({ ...skill.resourceBase }) }),\n }))\n }\n return skill\n }\n\n isActivated(id: string): boolean { return this.activated.has(id) }\n\n activatedResources(id: string): readonly SkillResourceSummary[] | undefined {\n return this.activated.get(id)\n }\n\n /** Activated identities in deterministic catalog order, suitable for session persistence. */\n activatedSummaries(): readonly SkillSummary[] {\n return Object.freeze(this.visible.filter(summary => this.activated.has(summary.id)))\n }\n\n activatedSkillReferences(): readonly ActivatedSkillSnapshot[] {\n return Object.freeze([...this.activatedReferences.values()]\n .sort((left, right) => left.id.localeCompare(right.id)))\n }\n\n /** Forget conversation-scoped activation without rebuilding provider configuration. */\n clearActivations(): void { this.activated.clear(); this.activatedReferences.clear() }\n\n validateReferenceOwner(value: unknown): ActivatedSkillSnapshot {\n const reference = captureSkillReference(value)\n if (!this.sources.some(source => isRuntimeProvider(source) && source.id === reference.provider)) {\n throw new AgentSdkError('Persisted skill reference has no matching provider', SKILL_ERROR_CODES.REFERENCE_INVALID)\n }\n return reference\n }\n\n async restoreReference(value: unknown, options: SkillLookupOptions = {}): Promise<SkillDefinition> {\n throwIfAborted(options.signal)\n const reference = this.validateReferenceOwner(value)\n const provider = this.sources.find((source): source is CapturedSkillProviderPlugin =>\n isRuntimeProvider(source) && source.id === reference.provider)\n if (provider === undefined) throw referenceInvalid()\n const input = await raceAbort(\n provider.load(referenceOnly(reference), this.runtimeLookupOptions(options)), options.signal,\n )\n throwIfAborted(options.signal)\n if (input === undefined) throw referenceUnavailable()\n const entry: CatalogEntry = { summary: summaryFromReferenceInput(input, reference),\n runtimeProvider: provider, reference: referenceOnly(reference) }\n const skill = this.resolveRuntimeSkill(input, entry)\n if (reference.resourceBase?.kind !== skill.resourceBase?.kind\n || reference.resourceBase?.value !== skill.resourceBase?.value) throw referenceUnavailable()\n this.entries.set(reference.id, entry)\n this.visible = freezeSummaries(this.entries)\n this.activated.set(reference.id, skill.resourceManifest)\n this.activatedReferences.set(reference.id, reference)\n return skill\n }\n\n /** Read one advertised resource without hydrating the rest of the bundle. */\n async readResource(\n id: string,\n path: string,\n options: SkillLookupOptions = {},\n ): Promise<string | undefined> {\n throwIfAborted(options.signal)\n validateSkillResourcePath(path, id)\n if (!this.isActivated(id)) {\n throw new Error(`skill '${id}' must be activated before reading resources`)\n }\n const entry = this.entries.get(id)\n let skill = entry?.direct\n const lazyManifest = this.activated.get(id)\n if (skill === undefined && (lazyManifest === undefined || entry?.provider?.readResource === undefined)) {\n skill = await this.load(id, options)\n }\n if (skill !== undefined && skill.id !== id) {\n throw new TypeError(`loaded skill '${skill.id}' does not match '${id}'`)\n }\n const manifest = skill?.resourceManifest ?? lazyManifest\n if (manifest === undefined || !manifest.some(resource => resource.path === path)) return undefined\n const embedded = skill?.resources[path]\n if (embedded !== undefined) return embedded\n if (entry?.runtimeProvider !== undefined && entry.reference !== undefined) {\n if (entry.runtimeProvider.readResource === undefined) return undefined\n const content = await raceAbort(entry.runtimeProvider.readResource(\n entry.reference, path, this.runtimeLookupOptions(options),\n ), options.signal)\n return validateResourceContent(content, path)\n }\n if (entry?.provider?.readResource === undefined || entry.candidate === undefined) return undefined\n const content = await raceAbort(\n entry.provider.readResource(entry.candidate, path, options), options.signal,\n )\n if (content === undefined) return undefined\n if (typeof content !== 'string') {\n throw new TypeError(`skill provider '${entry.provider.id}' returned a non-text resource '${path}'`)\n }\n if (content.length > MAX_SKILL_RESOURCE_CHARS) {\n throw new RangeError(`skill resource '${path}' exceeds ${MAX_SKILL_RESOURCE_CHARS} characters`)\n }\n return content\n }\n\n private installDirectSkills(): void {\n const direct = new Map<string, CatalogEntry>()\n let catalogBytes = 0\n for (const source of this.sources) {\n if (source.kind === 'skill' && this.isAllowed(source.id)) {\n catalogBytes = addCatalogBytes(catalogBytes, source, this.maxCatalogBytes)\n if (direct.size >= this.maxSkills) throw new RangeError(`skill catalog exceeds ${this.maxSkills} entries`)\n addUnique(direct, source.id, { summary: skillSummary(source), direct: source })\n }\n }\n this.entries = direct\n this.visible = freezeSummaries(direct)\n }\n\n private isAllowed(id: string): boolean {\n return this.allowedSkillIdSet?.has(id) ?? true\n }\n\n private providerListOptions(options: SkillLookupOptions): SkillProviderListOptions {\n return this.allowedSkillIds === undefined\n ? options\n : { ...options, allowedSkillIds: this.allowedSkillIds }\n }\n\n private runtimeLookupOptions(options: SkillLookupOptions): RuntimeSkillLookupOptions {\n return Object.freeze({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n signal: options.signal ?? new AbortController().signal,\n logger: skillProviderLogger(this),\n })\n }\n\n private runtimeProviderListOptions(options: SkillLookupOptions): RuntimeSkillLookupOptions & {\n readonly allowedSkillIds?: readonly string[]\n } {\n return Object.freeze({ ...this.runtimeLookupOptions(options),\n ...(this.allowedSkillIds === undefined ? {} : { allowedSkillIds: this.allowedSkillIds }) })\n }\n\n private resolveRuntimeSkill(input: SkillDefinitionInput, entry: CatalogEntry): SkillDefinition {\n const reference = entry.reference\n if (reference === undefined) throw referenceInvalid()\n const resolved = defineSkill({ ...input, id: reference.id, source: reference.source,\n provider: reference.provider, invocation: entry.summary.invocation })\n if (input.id !== reference.id) throw referenceUnavailable()\n return resolved\n }\n\n private assertAllowedSkillsAvailable(entries: ReadonlyMap<string, CatalogEntry>): void {\n if (this.allowedSkillIds === undefined) return\n const missing = this.allowedSkillIds.filter(id => !entries.has(id))\n if (missing.length > 0) {\n throw new Error(`configured skill${missing.length === 1 ? '' : 's'} not available: ${missing.join(', ')}`)\n }\n }\n}\n\nfunction summaryOfCandidate(candidate: SkillCandidate): SkillSummary {\n return Object.freeze({\n id: candidate.id,\n name: candidate.name,\n description: candidate.description,\n ...(candidate.whenToUse === undefined ? {} : { whenToUse: candidate.whenToUse }),\n invocation: Object.freeze({ ...candidate.invocation }),\n source: candidate.source,\n provider: candidate.provider,\n ...(candidate.resourceBase === undefined ? {} : { resourceBase: candidate.resourceBase }),\n })\n}\n\nfunction summaryOfRuntimeCandidate(candidate: RuntimeSkillCandidate): SkillSummary {\n return Object.freeze({\n id: candidate.id, name: candidate.name, description: candidate.description,\n ...(candidate.whenToUse === undefined ? {} : { whenToUse: candidate.whenToUse }),\n invocation: candidate.invocation ?? Object.freeze({ modelInvocable: true, userInvocable: true }),\n source: candidate.source, provider: candidate.provider,\n })\n}\n\nfunction summaryFromReferenceInput(input: SkillDefinitionInput, reference: ActivatedSkillSnapshot): SkillSummary {\n return skillSummary(defineSkill({ ...input, id: reference.id, source: reference.source, provider: reference.provider }))\n}\n\nfunction captureCatalogSources(sources: readonly RuntimeSkillSource[]): readonly RuntimeSkillSource[] {\n const captured = sources.map(source => {\n if (source.kind === 'skill') { validateSkillSource(source); return source }\n const descriptor = Object.getOwnPropertyDescriptor(source, 'apiVersion')\n if (descriptor === undefined) {\n validateSkillSource(source as SkillProvider)\n return source\n }\n if (!('value' in descriptor)) throw referenceInvalid()\n return captureSkillProviderPlugin(source)\n })\n const ids = new Map<string, number>()\n for (const [index, source] of captured.entries()) {\n if (source.kind === 'skill') continue\n const first = ids.get(source.id)\n if (first !== undefined) throw capabilityIdentityError(\n 'SKILL_PROVIDER_ID_CONFLICT', 'skill-provider-id', first, index,\n )\n ids.set(source.id, index)\n }\n return Object.freeze(captured)\n}\n\nfunction isRuntimeProvider(source: RuntimeSkillSource): source is CapturedSkillProviderPlugin {\n return source.kind === 'skill-provider'\n && Object.getOwnPropertyDescriptor(source, 'apiVersion')?.value === SKILL_PROVIDER_API_VERSION\n}\n\nfunction referenceOnly(value: ActivatedSkillSnapshot): SkillReference {\n return Object.freeze({ id: value.id, source: value.source, provider: value.provider,\n catalogRevision: value.catalogRevision,\n ...(value.locator === undefined ? {} : { locator: value.locator }) })\n}\n\nfunction validateResourceContent(content: string | undefined, path: string): string | undefined {\n if (content === undefined) return undefined\n if (typeof content !== 'string') throw new TypeError(`skill provider returned a non-text resource '${path}'`)\n if (content.length > MAX_SKILL_RESOURCE_CHARS) {\n throw new RangeError(`skill resource '${path}' exceeds ${MAX_SKILL_RESOURCE_CHARS} characters`)\n }\n return content\n}\n\nfunction referenceInvalid(): AgentSdkError {\n return new AgentSdkError('Persisted skill reference is invalid', SKILL_ERROR_CODES.REFERENCE_INVALID)\n}\n\nfunction referenceUnavailable(): AgentSdkError {\n return new AgentSdkError('Persisted skill reference is unavailable', SKILL_ERROR_CODES.REFERENCE_UNAVAILABLE)\n}\n\nfunction addUnique(\n entries: Map<string, CatalogEntry>,\n id: string,\n entry: CatalogEntry,\n): void {\n const existing = entries.get(id)\n if (existing !== undefined) {\n throw capabilityIdentityError(\n 'SKILL_ID_CONFLICT', 'skill-id', [...entries.keys()].indexOf(id), entries.size,\n )\n }\n entries.set(id, entry)\n}\n\nfunction freezeSummaries(entries: ReadonlyMap<string, CatalogEntry>): readonly SkillSummary[] {\n return Object.freeze([...entries.values()].map(entry => entry.summary)\n .sort((left, right) => left.id.localeCompare(right.id)))\n}\n\n/**\n * Preserve activation only when shallow discovery describes the same definition.\n * Providers can put an etag/version in locator or metadata to invalidate an\n * activated body without making discovery hydrate that body again.\n */\nfunction sameCatalogEntry(previous: CatalogEntry, current: CatalogEntry): boolean {\n if (previous.direct !== undefined || current.direct !== undefined) {\n return previous.direct === current.direct\n }\n if (previous.provider !== current.provider) return false\n if (previous.runtimeProvider !== undefined || current.runtimeProvider !== undefined) {\n return previous.runtimeProvider === current.runtimeProvider\n && previous.reference?.id === current.reference?.id\n && previous.reference?.source === current.reference?.source\n && previous.reference?.provider === current.reference?.provider\n && previous.reference?.catalogRevision === current.reference?.catalogRevision\n && sameRevisionValue(previous.reference?.locator, current.reference?.locator)\n }\n if (!sameSummary(previous.summary, current.summary)) return false\n const left = previous.candidate\n const right = current.candidate\n if (left === undefined || right === undefined) return left === right\n return left.path === right.path\n && sameRevisionValue(left.locator, right.locator)\n && sameRevisionValue(left.metadata, right.metadata)\n}\n\nfunction sameSummary(left: SkillSummary, right: SkillSummary): boolean {\n return left.id === right.id\n && left.name === right.name\n && left.description === right.description\n && left.whenToUse === right.whenToUse\n && left.source === right.source\n && left.provider === right.provider\n && left.invocation.modelInvocable === right.invocation.modelInvocable\n && left.invocation.userInvocable === right.invocation.userInvocable\n && left.resourceBase?.kind === right.resourceBase?.kind\n && left.resourceBase?.value === right.resourceBase?.value\n}\n\n/** Bounded structural equality for provider-owned JSON-like revision handles. */\nfunction sameRevisionValue(left: unknown, right: unknown): boolean {\n const pending: [unknown, unknown][] = [[left, right]]\n const seen = new WeakMap<object, WeakSet<object>>()\n let visited = 0\n try {\n while (pending.length > 0) {\n const pair = pending.pop()\n if (pair === undefined) break\n const [a, b] = pair\n if (Object.is(a, b)) continue\n if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) return false\n if (++visited > 2_048) return false\n let matches = seen.get(a)\n if (matches?.has(b) === true) continue\n if (matches === undefined) { matches = new WeakSet<object>(); seen.set(a, matches) }\n matches.add(b)\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n for (let index = 0; index < a.length; index++) pending.push([a[index], b[index]])\n continue\n }\n const aPrototype = Object.getPrototypeOf(a) as unknown\n const bPrototype = Object.getPrototypeOf(b) as unknown\n if (aPrototype !== bPrototype\n || (aPrototype !== Object.prototype && aPrototype !== null)) return false\n const aRecord = a as Record<string, unknown>\n const bRecord = b as Record<string, unknown>\n const aKeys = Object.keys(aRecord).sort()\n const bKeys = Object.keys(bRecord).sort()\n if (aKeys.length !== bKeys.length\n || aKeys.some((key, index) => key !== bKeys[index])) return false\n for (const key of aKeys) pending.push([aRecord[key], bRecord[key]])\n }\n return true\n } catch {\n // A getter/proxy or exotic provider handle is not a stable revision signal.\n return false\n }\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted === true) throw signal.reason ?? new Error('skill discovery aborted')\n}\n\nfunction addCatalogBytes(total: number, value: unknown, maxBytes: number): number {\n const serialized = JSON.stringify(value)\n if (serialized === undefined) throw new TypeError('skill catalog entry is not JSON serializable')\n const next = total + new TextEncoder().encode(serialized).byteLength\n if (next > maxBytes) throw new RangeError(`skill catalog exceeds ${maxBytes} serialized bytes`)\n return next\n}\n\nfunction positiveSafeInteger(value: number, label: string): number {\n if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(`${label} must be a positive safe integer`)\n return value\n}\n\nfunction raceAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {\n if (signal === undefined) return promise\n throwIfAborted(signal)\n return new Promise<T>((resolve, reject) => {\n const onAbort = (): void => { cleanup(); reject(signal.reason ?? new Error('skill discovery aborted')) }\n const cleanup = (): void => { signal.removeEventListener('abort', onAbort) }\n signal.addEventListener('abort', onAbort, { once: true })\n void promise.then(\n value => { cleanup(); resolve(value) },\n error => { cleanup(); reject(error) },\n )\n })\n}\n"],"mappings":"2mBAgDA,IAAa,EAAb,KAA0B,CACxB,QACA,gBACA,kBACA,UACA,gBACA,QAAkB,IAAI,IACtB,QAA2C,OAAO,OAAO,CAAC,CAAC,EAC3D,UAA6B,IAAI,IACjC,oBAAuC,IAAI,IAC3C,cAAuC,Q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CAAO,CAAE,EAC3E,EAAO,iBAAiB,QAAS,EAAS,CAAE,KAAM,EAAK,CAAC,EACxD,EAAa,KACX,GAAS,CAAE,EAAQ,EAAG,EAAQ,CAAK,CAAE,EACrC,GAAS,CAAE,EAAQ,EAAG,EAAO,CAAK,CAAE,CACtC,CACF,CAAC,EACH"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region src/agent/skill/definition.d.ts
|
|
2
|
+
/** Environment-neutral skill definitions and provider contracts. */
|
|
3
|
+
declare const SKILL_ID_PATTERN: RegExp;
|
|
4
|
+
declare const MAX_SKILL_INSTRUCTIONS_CHARS = 40000;
|
|
5
|
+
declare const MAX_SKILL_RESOURCE_CHARS = 40000;
|
|
6
|
+
declare const MAX_SKILL_ID_CHARS = 128;
|
|
7
|
+
declare const MAX_SKILL_NAME_CHARS = 256;
|
|
8
|
+
declare const MAX_SKILL_DESCRIPTION_CHARS = 2048;
|
|
9
|
+
declare const MAX_SKILL_RESOURCE_PATH_CHARS = 512;
|
|
10
|
+
interface SkillInvocationPolicy {
|
|
11
|
+
/** Whether the model may discover and load this skill. Defaults to true. */
|
|
12
|
+
readonly modelInvocable: boolean;
|
|
13
|
+
/** Whether a host UI may offer this skill for explicit invocation. Defaults to true. */
|
|
14
|
+
readonly userInvocable: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface SkillResourceBase {
|
|
17
|
+
readonly kind: 'directory' | 'url' | 'opaque';
|
|
18
|
+
readonly value: string;
|
|
19
|
+
}
|
|
20
|
+
/** Metadata only. Resource contents stay behind SkillProvider.readResource(). */
|
|
21
|
+
interface SkillResourceSummary {
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly sizeBytes?: number;
|
|
24
|
+
readonly sizeChars?: number;
|
|
25
|
+
}
|
|
26
|
+
interface SkillDefinitionInput {
|
|
27
|
+
/** Kebab-case stable identity used by model tools and host UIs. */
|
|
28
|
+
readonly id: string;
|
|
29
|
+
/** Human-readable title; defaults to id. */
|
|
30
|
+
readonly name?: string;
|
|
31
|
+
/** Short routing signal shown before the body is loaded. */
|
|
32
|
+
readonly description: string;
|
|
33
|
+
/** Optional extra selection boundary. */
|
|
34
|
+
readonly whenToUse?: string;
|
|
35
|
+
/** Instructions loaded only after this skill is selected. */
|
|
36
|
+
readonly instructions: string;
|
|
37
|
+
/** Addressable text resources. Keys are skill-relative POSIX paths. */
|
|
38
|
+
readonly resources?: Readonly<Record<string, string>>;
|
|
39
|
+
/** Lazy resources advertised without embedding their contents. */
|
|
40
|
+
readonly resourceManifest?: readonly SkillResourceSummary[];
|
|
41
|
+
readonly invocation?: Partial<SkillInvocationPolicy>;
|
|
42
|
+
/** Origin label useful to catalogs and UIs. Defaults to runtime. */
|
|
43
|
+
readonly source?: string;
|
|
44
|
+
/** Provider label useful to diagnostics. Defaults to inline. */
|
|
45
|
+
readonly provider?: string;
|
|
46
|
+
readonly resourceBase?: SkillResourceBase;
|
|
47
|
+
/** Absolute or provider-native location when one exists. */
|
|
48
|
+
readonly path?: string;
|
|
49
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
50
|
+
}
|
|
51
|
+
interface SkillDefinition {
|
|
52
|
+
readonly kind: 'skill';
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly description: string;
|
|
56
|
+
readonly whenToUse?: string;
|
|
57
|
+
readonly instructions: string;
|
|
58
|
+
readonly resources: Readonly<Record<string, string>>;
|
|
59
|
+
readonly resourceManifest: readonly SkillResourceSummary[];
|
|
60
|
+
readonly invocation: SkillInvocationPolicy;
|
|
61
|
+
readonly source: string;
|
|
62
|
+
readonly provider: string;
|
|
63
|
+
readonly resourceBase?: SkillResourceBase;
|
|
64
|
+
readonly path?: string;
|
|
65
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
66
|
+
}
|
|
67
|
+
/** Lightweight discovery row. Skill instructions deliberately do not live here. */
|
|
68
|
+
type SkillSummary = Omit<SkillDefinition, 'kind' | 'instructions' | 'resources' | 'resourceManifest' | 'path' | 'metadata'>;
|
|
69
|
+
interface SkillCandidate extends SkillSummary {
|
|
70
|
+
/** Opaque provider-owned handle returned unchanged to load(). */
|
|
71
|
+
readonly locator?: unknown;
|
|
72
|
+
readonly path?: string;
|
|
73
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
74
|
+
}
|
|
75
|
+
interface SkillLookupOptions {
|
|
76
|
+
readonly cwd?: string;
|
|
77
|
+
readonly signal?: AbortSignal;
|
|
78
|
+
}
|
|
79
|
+
/** Discovery hints supplied by a scoped catalog to lazy providers. */
|
|
80
|
+
interface SkillProviderListOptions extends SkillLookupOptions {
|
|
81
|
+
/** Definition-owned allowlist. Providers may use it to avoid unrelated metadata I/O. */
|
|
82
|
+
readonly allowedSkillIds?: readonly string[];
|
|
83
|
+
}
|
|
84
|
+
interface SkillProvider {
|
|
85
|
+
readonly kind: 'skill-provider';
|
|
86
|
+
readonly id: string;
|
|
87
|
+
/** Discover metadata without loading instruction bodies or resources. */
|
|
88
|
+
list(options: SkillProviderListOptions): Promise<readonly SkillCandidate[]>;
|
|
89
|
+
/** Load the complete body for a candidate previously returned by list(). */
|
|
90
|
+
load(candidate: SkillCandidate, options: SkillLookupOptions): Promise<SkillDefinitionInput | undefined>;
|
|
91
|
+
/** Read one advertised resource. Providers should not preload these in load(). */
|
|
92
|
+
readResource?(candidate: SkillCandidate, path: string, options: SkillLookupOptions): Promise<string | undefined>;
|
|
93
|
+
}
|
|
94
|
+
type SkillSource = SkillDefinition | SkillProvider;
|
|
95
|
+
/** Define an immutable in-memory skill. This path is safe in browsers and edge runtimes. */
|
|
96
|
+
declare function defineSkill(input: SkillDefinitionInput): SkillDefinition;
|
|
97
|
+
/** Typed pass-through for custom browser, remote, database, or filesystem providers. */
|
|
98
|
+
declare function defineSkillProvider(provider: SkillProvider): SkillProvider;
|
|
99
|
+
declare function validateSkillSource(source: SkillSource): void;
|
|
100
|
+
/** Validate one public skill identity without constructing a definition. */
|
|
101
|
+
declare function validateSkillId(id: string, label?: string): void;
|
|
102
|
+
declare function validateCandidate(candidate: SkillCandidate, providerId: string): void;
|
|
103
|
+
declare function validateSkillResourcePath(path: string, skillId: string): void;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { MAX_SKILL_DESCRIPTION_CHARS, MAX_SKILL_ID_CHARS, MAX_SKILL_INSTRUCTIONS_CHARS, MAX_SKILL_NAME_CHARS, MAX_SKILL_RESOURCE_CHARS, MAX_SKILL_RESOURCE_PATH_CHARS, SKILL_ID_PATTERN, SkillCandidate, SkillDefinition, SkillDefinitionInput, SkillInvocationPolicy, SkillLookupOptions, SkillProvider, SkillProviderListOptions, SkillResourceBase, SkillResourceSummary, SkillSource, SkillSummary, defineSkill, defineSkillProvider, validateCandidate, validateSkillId, validateSkillResourcePath, validateSkillSource };
|
|
106
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","names":[],"sources":["../../../src/agent/skill/definition.ts"],"mappings":";;cAIa,kBAAgB;cAChB;cACA;cACA;cACA;cACA;cACA;UAEI;;WAEN;;WAEA;;UAGM;WACN;WACA;;;UAIM;WACN;WACA;WACA;;UAGM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,YAAY,SAAS;;WAErB,4BAA4B;WAC5B,aAAa,QAAQ;;WAErB;;WAEA;WACA,eAAe;;WAEf;WACA,WAAW,SAAS;;UAGd;WACN;WACA;WACA;WACA;WACA;WACA;WACA,WAAW,SAAS;WACpB,2BAA2B;WAC3B,YAAY;WACZ;WACA;WACA,eAAe;WACf;WACA,WAAW,SAAS;;;KAInB,eAAe,KACzB;UAIe,uBAAuB;;WAE7B;WACA;WACA,WAAW,SAAS;;UAGd;WACN;WACA,SAAS;;;UAIH,iCAAiC;;WAEvC;;UAGM;WACN;WACA;;EAET,KAAK,SAAS,2BAA2B,iBAAiB;;EAE1D,KAAK,WAAW,gBAAgB,SAAS,qBAAqB,QAAQ;;EAEtE,cACE,WAAW,gBACX,cACA,SAAS,qBACR;;KAGO,cAAc,kBAAkB;;iBAG5B,YAAY,OAAO,uBAAuB;;iBAuC1C,oBAAoB,UAAU,gBAAgB;iBAkB9C,oBAAoB,QAAQ;;iBAa5B,gBAAgB,YAAY;iBAI5B,kBAAkB,WAAW,gBAAgB;iBAyE7C,0BAA0B,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{deepFreeze as e}from"../../primitives/freeze.js";const t=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,n=4e4,r=4e4,i=128,a=256,o=2048,s=512;function c(t){m(t);let n=Object.fromEntries(Object.entries(t.resources??{}).map(([e,n])=>(v(e,n,t.id),[e,n]))),r=new Map;for(let e of t.resourceManifest??[]){if(b(e,t.id),r.has(e.path))throw TypeError(`skill '${t.id}' has duplicate resource '${e.path}'`);r.set(e.path,Object.freeze({...e}))}for(let[e,t]of Object.entries(n))r.set(e,Object.freeze({path:e,sizeChars:t.length}));return e({kind:`skill`,id:t.id,name:t.name??t.id,description:t.description,...t.whenToUse===void 0?{}:{whenToUse:t.whenToUse},instructions:t.instructions,resources:n,resourceManifest:[...r.values()].sort((e,t)=>e.path.localeCompare(t.path)),invocation:{modelInvocable:t.invocation?.modelInvocable??!0,userInvocable:t.invocation?.userInvocable??!0},source:t.source??`runtime`,provider:t.provider??`inline`,...t.resourceBase===void 0?{}:{resourceBase:t.resourceBase},...t.path===void 0?{}:{path:t.path},...t.metadata===void 0?{}:{metadata:structuredClone(t.metadata)}})}function l(e){return h(e),e}function u(e){return Object.freeze({id:e.id,name:e.name,description:e.description,...e.whenToUse===void 0?{}:{whenToUse:e.whenToUse},invocation:e.invocation,source:e.source,provider:e.provider,...e.resourceBase===void 0?{}:{resourceBase:e.resourceBase}})}function d(e){if(e.kind===`skill`){m(e);for(let[t,n]of Object.entries(e.resources))v(t,n,e.id);for(let t of e.resourceManifest)b(t,e.id);return}h(e)}function f(e,t=`skill`){g(e,t)}function p(e,t){if(g(e.id,`skill from provider '${t}'`),w(e.name,`skill '${e.id}' name`,256),w(e.description,`skill '${e.id}' description`,o),e.whenToUse!==void 0&&w(e.whenToUse,`skill '${e.id}' whenToUse`,o),w(e.source,`skill '${e.id}' source`,256),w(e.provider,`skill '${e.id}' provider`,256),e.provider!==t)throw TypeError(`skill '${e.id}' declares provider '${e.provider}', expected '${t}'`);_(e.invocation,`skill '${e.id}'`)}function m(e){if(g(e.id,`skill`),e.name!==void 0&&w(e.name,`skill '${e.id}' name`,256),w(e.description,`skill '${e.id}' description`,o),e.whenToUse!==void 0&&w(e.whenToUse,`skill '${e.id}' whenToUse`,o),C(e.instructions,`skill '${e.id}' instructions`),e.instructions.length>4e4)throw RangeError(`skill '${e.id}' instructions exceed ${n} characters`);if(e.invocation!==void 0){for(let[t,n]of Object.entries(e.invocation))if(n!==void 0&&typeof n!=`boolean`)throw TypeError(`skill '${e.id}' invocation.${t} must be boolean`)}e.source!==void 0&&C(e.source,`skill '${e.id}' source`),e.provider!==void 0&&C(e.provider,`skill '${e.id}' provider`),e.path!==void 0&&C(e.path,`skill '${e.id}' path`),e.resourceBase!==void 0&&C(e.resourceBase.value,`skill '${e.id}' resourceBase.value`)}function h(e){if(e.kind!==`skill-provider`)throw TypeError(`skill provider kind must be skill-provider`);if(C(e.id,`skill provider id`),typeof e.list!=`function`)throw TypeError(`skill provider '${e.id}' must implement list()`);if(typeof e.load!=`function`)throw TypeError(`skill provider '${e.id}' must implement load()`);if(e.readResource!==void 0&&typeof e.readResource!=`function`)throw TypeError(`skill provider '${e.id}' readResource must be a function`)}function g(e,n){if(typeof e!=`string`||e.length>128||!t.test(e))throw TypeError(`${n} id must be kebab-case`)}function _(e,t){if(typeof e?.modelInvocable!=`boolean`||typeof e.userInvocable!=`boolean`)throw TypeError(`${t} must declare boolean invocation policy`)}function v(e,t,n){if(y(e,n),typeof t!=`string`)throw TypeError(`skill '${n}' resource '${e}' must be text`);if(t.length>4e4)throw RangeError(`skill '${n}' resource '${e}' exceeds ${r} characters`)}function y(e,t){if(e.length>512||/[\u0000-\u001f\u007f]/.test(e)||!S(e))throw TypeError(`skill '${t}' resource '${e}' must be a normalized relative path`)}function b(e,t){y(e.path,t),x(e.sizeBytes,`skill '${t}' resource '${e.path}' sizeBytes`),x(e.sizeChars,`skill '${t}' resource '${e.path}' sizeChars`)}function x(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<0))throw TypeError(`${t} must be a non-negative safe integer`)}function S(e){if(e.length===0||e.startsWith(`/`)||e.startsWith(`\\`))return!1;let t=e.replace(/\\/g,`/`);return t!==e||/^[a-zA-Z]:/.test(e)?!1:t.split(`/`).every(e=>e.length>0&&e!==`.`&&e!==`..`)}function C(e,t){if(typeof e!=`string`||e.trim().length===0)throw TypeError(`${t} must be a non-empty string`)}function w(e,t,n){if(C(e,t),e.length>n)throw RangeError(`${t} exceeds ${n} characters`)}export{o as MAX_SKILL_DESCRIPTION_CHARS,i as MAX_SKILL_ID_CHARS,n as MAX_SKILL_INSTRUCTIONS_CHARS,a as MAX_SKILL_NAME_CHARS,r as MAX_SKILL_RESOURCE_CHARS,s as MAX_SKILL_RESOURCE_PATH_CHARS,t as SKILL_ID_PATTERN,c as defineSkill,l as defineSkillProvider,u as skillSummary,p as validateCandidate,f as validateSkillId,y as validateSkillResourcePath,d as validateSkillSource};
|
|
2
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","names":[],"sources":["../../../src/agent/skill/definition.ts"],"sourcesContent":["/** Environment-neutral skill definitions and provider contracts. */\n\nimport { deepFreeze } from '../../primitives/index.ts'\n\nexport const SKILL_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\nexport const MAX_SKILL_INSTRUCTIONS_CHARS = 40_000\nexport const MAX_SKILL_RESOURCE_CHARS = 40_000\nexport const MAX_SKILL_ID_CHARS = 128\nexport const MAX_SKILL_NAME_CHARS = 256\nexport const MAX_SKILL_DESCRIPTION_CHARS = 2_048\nexport const MAX_SKILL_RESOURCE_PATH_CHARS = 512\n\nexport interface SkillInvocationPolicy {\n /** Whether the model may discover and load this skill. Defaults to true. */\n readonly modelInvocable: boolean\n /** Whether a host UI may offer this skill for explicit invocation. Defaults to true. */\n readonly userInvocable: boolean\n}\n\nexport interface SkillResourceBase {\n readonly kind: 'directory' | 'url' | 'opaque'\n readonly value: string\n}\n\n/** Metadata only. Resource contents stay behind SkillProvider.readResource(). */\nexport interface SkillResourceSummary {\n readonly path: string\n readonly sizeBytes?: number\n readonly sizeChars?: number\n}\n\nexport interface SkillDefinitionInput {\n /** Kebab-case stable identity used by model tools and host UIs. */\n readonly id: string\n /** Human-readable title; defaults to id. */\n readonly name?: string\n /** Short routing signal shown before the body is loaded. */\n readonly description: string\n /** Optional extra selection boundary. */\n readonly whenToUse?: string\n /** Instructions loaded only after this skill is selected. */\n readonly instructions: string\n /** Addressable text resources. Keys are skill-relative POSIX paths. */\n readonly resources?: Readonly<Record<string, string>>\n /** Lazy resources advertised without embedding their contents. */\n readonly resourceManifest?: readonly SkillResourceSummary[]\n readonly invocation?: Partial<SkillInvocationPolicy>\n /** Origin label useful to catalogs and UIs. Defaults to runtime. */\n readonly source?: string\n /** Provider label useful to diagnostics. Defaults to inline. */\n readonly provider?: string\n readonly resourceBase?: SkillResourceBase\n /** Absolute or provider-native location when one exists. */\n readonly path?: string\n readonly metadata?: Readonly<Record<string, unknown>>\n}\n\nexport interface SkillDefinition {\n readonly kind: 'skill'\n readonly id: string\n readonly name: string\n readonly description: string\n readonly whenToUse?: string\n readonly instructions: string\n readonly resources: Readonly<Record<string, string>>\n readonly resourceManifest: readonly SkillResourceSummary[]\n readonly invocation: SkillInvocationPolicy\n readonly source: string\n readonly provider: string\n readonly resourceBase?: SkillResourceBase\n readonly path?: string\n readonly metadata?: Readonly<Record<string, unknown>>\n}\n\n/** Lightweight discovery row. Skill instructions deliberately do not live here. */\nexport type SkillSummary = Omit<\n SkillDefinition,\n 'kind' | 'instructions' | 'resources' | 'resourceManifest' | 'path' | 'metadata'\n>\n\nexport interface SkillCandidate extends SkillSummary {\n /** Opaque provider-owned handle returned unchanged to load(). */\n readonly locator?: unknown\n readonly path?: string\n readonly metadata?: Readonly<Record<string, unknown>>\n}\n\nexport interface SkillLookupOptions {\n readonly cwd?: string\n readonly signal?: AbortSignal\n}\n\n/** Discovery hints supplied by a scoped catalog to lazy providers. */\nexport interface SkillProviderListOptions extends SkillLookupOptions {\n /** Definition-owned allowlist. Providers may use it to avoid unrelated metadata I/O. */\n readonly allowedSkillIds?: readonly string[]\n}\n\nexport interface SkillProvider {\n readonly kind: 'skill-provider'\n readonly id: string\n /** Discover metadata without loading instruction bodies or resources. */\n list(options: SkillProviderListOptions): Promise<readonly SkillCandidate[]>\n /** Load the complete body for a candidate previously returned by list(). */\n load(candidate: SkillCandidate, options: SkillLookupOptions): Promise<SkillDefinitionInput | undefined>\n /** Read one advertised resource. Providers should not preload these in load(). */\n readResource?(\n candidate: SkillCandidate,\n path: string,\n options: SkillLookupOptions,\n ): Promise<string | undefined>\n}\n\nexport type SkillSource = SkillDefinition | SkillProvider\n\n/** Define an immutable in-memory skill. This path is safe in browsers and edge runtimes. */\nexport function defineSkill(input: SkillDefinitionInput): SkillDefinition {\n validateSkillInput(input)\n const resources = Object.fromEntries(Object.entries(input.resources ?? {}).map(([path, content]) => {\n validateResource(path, content, input.id)\n return [path, content]\n }))\n const manifest = new Map<string, SkillResourceSummary>()\n for (const resource of input.resourceManifest ?? []) {\n validateResourceSummary(resource, input.id)\n if (manifest.has(resource.path)) {\n throw new TypeError(`skill '${input.id}' has duplicate resource '${resource.path}'`)\n }\n manifest.set(resource.path, Object.freeze({ ...resource }))\n }\n for (const [path, content] of Object.entries(resources)) {\n manifest.set(path, Object.freeze({ path, sizeChars: content.length }))\n }\n return deepFreeze({\n kind: 'skill' as const,\n id: input.id,\n name: input.name ?? input.id,\n description: input.description,\n ...(input.whenToUse === undefined ? {} : { whenToUse: input.whenToUse }),\n instructions: input.instructions,\n resources,\n resourceManifest: [...manifest.values()].sort((left, right) => left.path.localeCompare(right.path)),\n invocation: {\n modelInvocable: input.invocation?.modelInvocable ?? true,\n userInvocable: input.invocation?.userInvocable ?? true,\n },\n source: input.source ?? 'runtime',\n provider: input.provider ?? 'inline',\n ...(input.resourceBase === undefined ? {} : { resourceBase: input.resourceBase }),\n ...(input.path === undefined ? {} : { path: input.path }),\n ...(input.metadata === undefined ? {} : { metadata: structuredClone(input.metadata) }),\n })\n}\n\n/** Typed pass-through for custom browser, remote, database, or filesystem providers. */\nexport function defineSkillProvider(provider: SkillProvider): SkillProvider {\n validateProvider(provider)\n return provider\n}\n\nexport function skillSummary(skill: SkillDefinition): SkillSummary {\n return Object.freeze({\n id: skill.id,\n name: skill.name,\n description: skill.description,\n ...(skill.whenToUse === undefined ? {} : { whenToUse: skill.whenToUse }),\n invocation: skill.invocation,\n source: skill.source,\n provider: skill.provider,\n ...(skill.resourceBase === undefined ? {} : { resourceBase: skill.resourceBase }),\n })\n}\n\nexport function validateSkillSource(source: SkillSource): void {\n if (source.kind === 'skill') {\n validateSkillInput(source)\n for (const [path, content] of Object.entries(source.resources)) {\n validateResource(path, content, source.id)\n }\n for (const resource of source.resourceManifest) validateResourceSummary(resource, source.id)\n return\n }\n validateProvider(source)\n}\n\n/** Validate one public skill identity without constructing a definition. */\nexport function validateSkillId(id: string, label = 'skill'): void {\n validateIdentity(id, label)\n}\n\nexport function validateCandidate(candidate: SkillCandidate, providerId: string): void {\n validateIdentity(candidate.id, `skill from provider '${providerId}'`)\n boundedNonEmpty(candidate.name, `skill '${candidate.id}' name`, MAX_SKILL_NAME_CHARS)\n boundedNonEmpty(candidate.description, `skill '${candidate.id}' description`, MAX_SKILL_DESCRIPTION_CHARS)\n if (candidate.whenToUse !== undefined) {\n boundedNonEmpty(candidate.whenToUse, `skill '${candidate.id}' whenToUse`, MAX_SKILL_DESCRIPTION_CHARS)\n }\n boundedNonEmpty(candidate.source, `skill '${candidate.id}' source`, MAX_SKILL_NAME_CHARS)\n boundedNonEmpty(candidate.provider, `skill '${candidate.id}' provider`, MAX_SKILL_NAME_CHARS)\n if (candidate.provider !== providerId) {\n throw new TypeError(\n `skill '${candidate.id}' declares provider '${candidate.provider}', expected '${providerId}'`,\n )\n }\n validateInvocation(candidate.invocation, `skill '${candidate.id}'`)\n}\n\nfunction validateSkillInput(input: SkillDefinitionInput): void {\n validateIdentity(input.id, 'skill')\n if (input.name !== undefined) boundedNonEmpty(input.name, `skill '${input.id}' name`, MAX_SKILL_NAME_CHARS)\n boundedNonEmpty(input.description, `skill '${input.id}' description`, MAX_SKILL_DESCRIPTION_CHARS)\n if (input.whenToUse !== undefined) {\n boundedNonEmpty(input.whenToUse, `skill '${input.id}' whenToUse`, MAX_SKILL_DESCRIPTION_CHARS)\n }\n nonEmpty(input.instructions, `skill '${input.id}' instructions`)\n if (input.instructions.length > MAX_SKILL_INSTRUCTIONS_CHARS) {\n throw new RangeError(`skill '${input.id}' instructions exceed ${MAX_SKILL_INSTRUCTIONS_CHARS} characters`)\n }\n if (input.invocation !== undefined) {\n for (const [field, value] of Object.entries(input.invocation)) {\n if (value !== undefined && typeof value !== 'boolean') {\n throw new TypeError(`skill '${input.id}' invocation.${field} must be boolean`)\n }\n }\n }\n if (input.source !== undefined) nonEmpty(input.source, `skill '${input.id}' source`)\n if (input.provider !== undefined) nonEmpty(input.provider, `skill '${input.id}' provider`)\n if (input.path !== undefined) nonEmpty(input.path, `skill '${input.id}' path`)\n if (input.resourceBase !== undefined) {\n nonEmpty(input.resourceBase.value, `skill '${input.id}' resourceBase.value`)\n }\n}\n\nfunction validateProvider(provider: SkillProvider): void {\n if (provider.kind !== 'skill-provider') throw new TypeError('skill provider kind must be skill-provider')\n nonEmpty(provider.id, 'skill provider id')\n if (typeof provider.list !== 'function') throw new TypeError(`skill provider '${provider.id}' must implement list()`)\n if (typeof provider.load !== 'function') throw new TypeError(`skill provider '${provider.id}' must implement load()`)\n if (provider.readResource !== undefined && typeof provider.readResource !== 'function') {\n throw new TypeError(`skill provider '${provider.id}' readResource must be a function`)\n }\n}\n\nfunction validateIdentity(id: string, label: string): void {\n if (typeof id !== 'string' || id.length > MAX_SKILL_ID_CHARS || !SKILL_ID_PATTERN.test(id)) {\n throw new TypeError(`${label} id must be kebab-case`)\n }\n}\n\nfunction validateInvocation(value: SkillInvocationPolicy, label: string): void {\n if (typeof value?.modelInvocable !== 'boolean' || typeof value.userInvocable !== 'boolean') {\n throw new TypeError(`${label} must declare boolean invocation policy`)\n }\n}\n\nfunction validateResource(path: string, content: string, skillId: string): void {\n validateSkillResourcePath(path, skillId)\n if (typeof content !== 'string') throw new TypeError(`skill '${skillId}' resource '${path}' must be text`)\n if (content.length > MAX_SKILL_RESOURCE_CHARS) {\n throw new RangeError(`skill '${skillId}' resource '${path}' exceeds ${MAX_SKILL_RESOURCE_CHARS} characters`)\n }\n}\n\nexport function validateSkillResourcePath(path: string, skillId: string): void {\n if (path.length > MAX_SKILL_RESOURCE_PATH_CHARS || /[\\u0000-\\u001f\\u007f]/.test(path)\n || !isRelativeResourcePath(path)) {\n throw new TypeError(`skill '${skillId}' resource '${path}' must be a normalized relative path`)\n }\n}\n\nfunction validateResourceSummary(resource: SkillResourceSummary, skillId: string): void {\n validateSkillResourcePath(resource.path, skillId)\n optionalSize(resource.sizeBytes, `skill '${skillId}' resource '${resource.path}' sizeBytes`)\n optionalSize(resource.sizeChars, `skill '${skillId}' resource '${resource.path}' sizeChars`)\n}\n\nfunction optionalSize(value: number | undefined, label: string): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new TypeError(`${label} must be a non-negative safe integer`)\n }\n}\n\nfunction isRelativeResourcePath(path: string): boolean {\n if (path.length === 0 || path.startsWith('/') || path.startsWith('\\\\')) return false\n const normalized = path.replace(/\\\\/g, '/')\n if (normalized !== path || /^[a-zA-Z]:/.test(path)) return false\n return normalized.split('/').every(segment => segment.length > 0 && segment !== '.' && segment !== '..')\n}\n\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.trim().length === 0) {\n throw new TypeError(`${label} must be a non-empty string`)\n }\n}\n\nfunction boundedNonEmpty(value: unknown, label: string, max: number): asserts value is string {\n nonEmpty(value, label)\n if (value.length > max) throw new RangeError(`${label} exceeds ${max} characters`)\n}\n"],"mappings":"wDAIA,MAAa,EAAmB,6BACnB,EAA+B,IAC/B,EAA2B,IAC3B,EAAqB,IACrB,EAAuB,IACvB,EAA8B,KAC9B,EAAgC,IA0G7C,SAAgB,EAAY,EAA8C,CACxE,EAAmB,CAAK,EACxB,IAAM,EAAY,OAAO,YAAY,OAAO,QAAQ,EAAM,WAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAM,MACrF,EAAiB,EAAM,EAAS,EAAM,EAAE,EACjC,CAAC,EAAM,CAAO,EACtB,CAAC,EACI,EAAW,IAAI,IACrB,IAAK,IAAM,KAAY,EAAM,kBAAoB,CAAC,EAAG,CAEnD,GADA,EAAwB,EAAU,EAAM,EAAE,EACtC,EAAS,IAAI,EAAS,IAAI,EAC5B,MAAU,UAAU,UAAU,EAAM,GAAG,4BAA4B,EAAS,KAAK,EAAE,EAErF,EAAS,IAAI,EAAS,KAAM,OAAO,OAAO,CAAE,GAAG,CAAS,CAAC,CAAC,CAC5D,CACA,IAAK,GAAM,CAAC,EAAM,KAAY,OAAO,QAAQ,CAAS,EACpD,EAAS,IAAI,EAAM,OAAO,OAAO,CAAE,OAAM,UAAW,EAAQ,MAAO,CAAC,CAAC,EAEvE,OAAO,EAAW,CAChB,KAAM,QACN,GAAI,EAAM,GACV,KAAM,EAAM,MAAQ,EAAM,GAC1B,YAAa,EAAM,YACnB,GAAI,EAAM,YAAc,IAAA,GAAY,CAAC,EAAI,CAAE,UAAW,EAAM,SAAU,EACtE,aAAc,EAAM,aACpB,YACA,iBAAkB,CAAC,GAAG,EAAS,OAAO,CAAC,CAAC,CAAC,MAAM,EAAM,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CAAqC,CAElG,CAEA,SAAS,EAAwB,EAAgC,EAAuB,CACtF,EAA0B,EAAS,KAAM,CAAO,EAChD,EAAa,EAAS,UAAW,UAAU,EAAQ,cAAc,EAAS,KAAK,YAAY,EAC3F,EAAa,EAAS,UAAW,UAAU,EAAQ,cAAc,EAAS,KAAK,YAAY,CAC7F,CAEA,SAAS,EAAa,EAA2B,EAAqB,CACpE,GAAI,IAAU,IAAA,KAAc,CAAC,OAAO,cAAc,CAAK,GAAK,EAAQ,GAClE,MAAU,UAAU,GAAG,EAAM,qCAAqC,CAEtE,CAEA,SAAS,EAAuB,EAAuB,CACrD,GAAI,EAAK,SAAW,GAAK,EAAK,WAAW,GAAG,GAAK,EAAK,WAAW,IAAI,EAAG,MAAO,GAC/E,IAAM,EAAa,EAAK,QAAQ,MAAO,GAAG,EAE1C,OADI,IAAe,GAAQ,aAAa,KAAK,CAAI,EAAU,GACpD,EAAW,MAAM,GAAG,CAAC,CAAC,MAAM,GAAW,EAAQ,OAAS,GAAK,IAAY,KAAO,IAAY,IAAI,CACzG,CAEA,SAAS,EAAS,EAAgB,EAAwC,CACxE,GAAI,OAAO,GAAU,UAAY,EAAM,KAAK,CAAC,CAAC,SAAW,EACvD,MAAU,UAAU,GAAG,EAAM,4BAA4B,CAE7D,CAEA,SAAS,EAAgB,EAAgB,EAAe,EAAsC,CAE5F,GADA,EAAS,EAAO,CAAK,EACjB,EAAM,OAAS,EAAK,MAAU,WAAW,GAAG,EAAM,WAAW,EAAI,YAAY,CACnF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/agent/skill/provider/config.d.ts
|
|
2
|
+
declare const SKILL_PROVIDER_API_VERSION: 1;
|
|
3
|
+
declare const SKILL_ERROR_CODES: Readonly<{
|
|
4
|
+
readonly CATALOG_INVALID: 'SKILL_CATALOG_INVALID';
|
|
5
|
+
readonly ID_CONFLICT: 'SKILL_ID_CONFLICT';
|
|
6
|
+
readonly REFERENCE_INVALID: 'SKILL_REFERENCE_INVALID';
|
|
7
|
+
readonly REFERENCE_UNAVAILABLE: 'SKILL_REFERENCE_UNAVAILABLE';
|
|
8
|
+
}>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { SKILL_ERROR_CODES, SKILL_PROVIDER_API_VERSION };
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../../../../src/agent/skill/provider/config.ts"],"mappings":";cAAa;cAcA,mBAAiB;WACX;WACJ;WACM;WACI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=1,t=Object.freeze({providers:128,identityBytes:256,revisionBytes:1024,locatorBytes:65536,locatorFields:128,locatorArrayItems:1024,locatorDepth:16,locatorNodes:8192,locatorKeyBytes:256}),n=Object.freeze({CATALOG_INVALID:`SKILL_CATALOG_INVALID`,ID_CONFLICT:`SKILL_ID_CONFLICT`,REFERENCE_INVALID:`SKILL_REFERENCE_INVALID`,REFERENCE_UNAVAILABLE:`SKILL_REFERENCE_UNAVAILABLE`}),r=Object.freeze({KIND_MISMATCH:`SKILL_PROVIDER_KIND_MISMATCH`,API_UNSUPPORTED:`SKILL_PROVIDER_API_UNSUPPORTED`,DEFINITION_INVALID:`SKILL_PROVIDER_INVALID`,ID_CONFLICT:`SKILL_PROVIDER_ID_CONFLICT`,ABORTED:`RUNTIME_OPERATION_ABORTED`});export{n as SKILL_ERROR_CODES,e as SKILL_PROVIDER_API_VERSION,r as SKILL_PROVIDER_ERROR_CODES,t as SKILL_PROVIDER_LIMITS};
|
|
2
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../../src/agent/skill/provider/config.ts"],"sourcesContent":["export const SKILL_PROVIDER_API_VERSION = 1 as const\n\nexport const SKILL_PROVIDER_LIMITS = Object.freeze({\n providers: 128,\n identityBytes: 256,\n revisionBytes: 1_024,\n locatorBytes: 64 * 1_024,\n locatorFields: 128,\n locatorArrayItems: 1_024,\n locatorDepth: 16,\n locatorNodes: 8_192,\n locatorKeyBytes: 256,\n})\n\nexport const SKILL_ERROR_CODES = Object.freeze({\n CATALOG_INVALID: 'SKILL_CATALOG_INVALID',\n ID_CONFLICT: 'SKILL_ID_CONFLICT',\n REFERENCE_INVALID: 'SKILL_REFERENCE_INVALID',\n REFERENCE_UNAVAILABLE: 'SKILL_REFERENCE_UNAVAILABLE',\n} as const)\n\nexport const SKILL_PROVIDER_ERROR_CODES = Object.freeze({\n KIND_MISMATCH: 'SKILL_PROVIDER_KIND_MISMATCH',\n API_UNSUPPORTED: 'SKILL_PROVIDER_API_UNSUPPORTED',\n DEFINITION_INVALID: 'SKILL_PROVIDER_INVALID',\n ID_CONFLICT: 'SKILL_PROVIDER_ID_CONFLICT',\n ABORTED: 'RUNTIME_OPERATION_ABORTED',\n} as const)\n"],"mappings":"AAAA,MAAa,EAA6B,EAE7B,EAAwB,OAAO,OAAO,CACjD,UAAW,IACX,cAAe,IACf,cAAe,KACf,aAAc,MACd,cAAe,IACf,kBAAmB,KACnB,aAAc,GACd,aAAc,KACd,gBAAiB,GACnB,CAAC,EAEY,EAAoB,OAAO,OAAO,CAC7C,gBAAiB,wBACjB,YAAa,oBACb,kBAAmB,0BACnB,sBAAuB,6BACzB,CAAU,EAEG,EAA6B,OAAO,OAAO,CACtD,cAAe,+BACf,gBAAiB,iCACjB,mBAAoB,yBACpB,YAAa,6BACb,QAAS,2BACX,CAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../../src/agent/skill/provider/context.ts"],"sourcesContent":["import { CLOSED_RUNTIME_LOGGER, type SdkLogger } from '../../../logging/types.ts'\n\nconst loggers = new WeakMap<object, SdkLogger>()\n\nexport function bindSkillProviderLogger(catalog: object, logger: SdkLogger | undefined): void {\n if (logger === undefined) loggers.delete(catalog)\n else loggers.set(catalog, logger)\n}\n\nexport function skillProviderLogger(catalog: object): SdkLogger {\n return loggers.get(catalog) ?? CLOSED_RUNTIME_LOGGER\n}\n"],"mappings":"kEAEA,MAAM,EAAU,IAAI,QAEpB,SAAgB,EAAwB,EAAiB,EAAqC,CACxF,IAAW,IAAA,GAAW,EAAQ,OAAO,CAAO,EAC3C,EAAQ,IAAI,EAAS,CAAM,CAClC,CAEA,SAAgB,EAAoB,EAA4B,CAC9D,OAAO,EAAQ,IAAI,CAAO,GAAK,CACjC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SkillProviderPlugin, SkillProviderPluginDefinition } from "./types.js";
|
|
2
|
+
//#region src/agent/skill/provider/definition.d.ts
|
|
3
|
+
declare function defineSkillProviderPlugin(provider: SkillProviderPluginDefinition): SkillProviderPlugin;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { defineSkillProviderPlugin };
|
|
6
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","names":[],"sources":["../../../../src/agent/skill/provider/definition.ts"],"mappings":";;iBAgBgB,0BACd,UAAU,gCACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AgentSdkError as e}from"../../../errors/agent-sdk-error.js";import{arrayData as t,boundedText as n,objectValue as r,ownData as i}from"../../../capability/common/data.js";import{validateSkillId as a,validateSkillSource as o}from"../definition.js";import{capabilityIdentityError as s}from"../../../errors/capability-identity.js";import{runCoreCapabilityMaybeAsync as c}from"../../../platform/capability-operation.js";import{SKILL_PROVIDER_ERROR_CODES as l,SKILL_PROVIDER_LIMITS as u}from"./config.js";function d(e){return f(e,!1)}function f(t,o=!0){try{let s=r(t);if(o){if(i(s,`kind`)!==`skill-provider`)throw new e(`Skill provider kind is unsupported`,l.KIND_MISMATCH);if(i(s,`apiVersion`)!==1)throw new e(`Skill provider API version is unsupported`,l.API_UNSUPPORTED)}let d=n(i(s,`id`),u.identityBytes);a(d,`skill provider`);let f=m(s,`list`,!0),p=m(s,`load`,!0),h=m(s,`readResource`,!1),g=e=>c(e.logger,`core-skill-provider`,`list`,e.signal,()=>Reflect.apply(f,s,[e])),_=(e,t)=>c(t.logger,`core-skill-provider`,`load`,t.signal,()=>Reflect.apply(p,s,[e,t])),v=h===void 0?void 0:(e,t,n)=>c(n.logger,`core-skill-provider`,`read-resource`,n.signal,()=>Reflect.apply(h,s,[e,t,n]));return Object.freeze({kind:`skill-provider`,apiVersion:1,id:d,list:g,load:_,...v===void 0?{}:{readResource:v}})}catch(t){throw t instanceof e?t:new e(`Skill provider definition is invalid`,l.DEFINITION_INVALID)}}function p(n){if(n===void 0)return Object.freeze([]);let a=t(n,u.providers).map(t=>{let n=r(t),a=i(n,`kind`);if(a===`skill`)return o(n),n;if(a!==`skill-provider`)throw new e(`Skill provider kind is unsupported`,l.KIND_MISMATCH);return i(n,`apiVersion`,!1)===void 0?(o(n),n):f(n)}),c=a.filter(e=>e.kind===`skill-provider`),d=new Map;for(let[e,t]of c.entries()){let n=d.get(t.id);if(n!==void 0)throw s(l.ID_CONFLICT,`skill-provider-id`,n,e);d.set(t.id,e)}return Object.freeze(a)}function m(e,t,n){let r;try{r=Reflect.get(e,t)}catch{throw TypeError(`Method capture failed`)}if(!(r===void 0&&!n)){if(typeof r!=`function`)throw TypeError(`Method is invalid`);return r}}export{p as captureRuntimeSkillSources,f as captureSkillProviderPlugin,d as defineSkillProviderPlugin};
|
|
2
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","names":[],"sources":["../../../../src/agent/skill/provider/definition.ts"],"sourcesContent":["import { AgentSdkError } from '../../../errors/agent-sdk-error.ts'\nimport { arrayData, boundedText, objectValue, ownData } from '../../../capability/common/data.ts'\nimport { capabilityIdentityError } from '../../../errors/capability-identity.ts'\nimport { runCoreCapabilityMaybeAsync } from '../../../platform/capability-operation.ts'\nimport { validateSkillId, validateSkillSource, type SkillProvider } from '../definition.ts'\nimport {\n SKILL_PROVIDER_API_VERSION, SKILL_PROVIDER_ERROR_CODES, SKILL_PROVIDER_LIMITS,\n} from './config.ts'\nimport type {\n CapturedSkillProviderPlugin, SkillCatalogSnapshot, SkillProviderPlugin,\n SkillProviderPluginDefinition, SkillReference, RuntimeSkillLookupOptions,\n RuntimeSkillSource,\n} from './types.ts'\n\ntype SkillResourceResult = ReturnType<NonNullable<SkillProviderPlugin['readResource']>>\n\nexport function defineSkillProviderPlugin(\n provider: SkillProviderPluginDefinition,\n): SkillProviderPlugin {\n return captureSkillProviderPlugin(provider, false)\n}\n\nexport function captureSkillProviderPlugin(\n value: unknown,\n requireMarker = true,\n): CapturedSkillProviderPlugin {\n try {\n const source = objectValue(value)\n if (requireMarker) {\n if (ownData(source, 'kind') !== 'skill-provider') throw new AgentSdkError(\n 'Skill provider kind is unsupported', SKILL_PROVIDER_ERROR_CODES.KIND_MISMATCH,\n )\n if (ownData(source, 'apiVersion') !== SKILL_PROVIDER_API_VERSION) throw new AgentSdkError(\n 'Skill provider API version is unsupported', SKILL_PROVIDER_ERROR_CODES.API_UNSUPPORTED,\n )\n }\n const id = boundedText(ownData(source, 'id'), SKILL_PROVIDER_LIMITS.identityBytes)\n validateSkillId(id, 'skill provider')\n const listMethod = method(source, 'list', true)\n const loadMethod = method(source, 'load', true)\n const resourceMethod = method(source, 'readResource', false)\n const list = (options: RuntimeSkillLookupOptions & { readonly allowedSkillIds?: readonly string[] }) =>\n runCoreCapabilityMaybeAsync(options.logger, 'core-skill-provider', 'list', options.signal,\n () => Reflect.apply(listMethod!, source, [options]) as Promise<SkillCatalogSnapshot>)\n const load = (reference: SkillReference, options: RuntimeSkillLookupOptions) =>\n runCoreCapabilityMaybeAsync(options.logger, 'core-skill-provider', 'load', options.signal,\n () => Reflect.apply(loadMethod!, source, [reference, options]) as ReturnType<SkillProviderPlugin['load']>)\n const readResource = resourceMethod === undefined ? undefined\n : (reference: SkillReference, path: string, options: RuntimeSkillLookupOptions) =>\n runCoreCapabilityMaybeAsync(options.logger, 'core-skill-provider', 'read-resource', options.signal,\n () => Reflect.apply(resourceMethod, source, [reference, path, options]) as SkillResourceResult)\n return Object.freeze({ kind: 'skill-provider', apiVersion: SKILL_PROVIDER_API_VERSION,\n id, list, load, ...(readResource === undefined ? {} : { readResource }) })\n } catch (error) {\n if (error instanceof AgentSdkError) throw error\n throw new AgentSdkError('Skill provider definition is invalid', SKILL_PROVIDER_ERROR_CODES.DEFINITION_INVALID)\n }\n}\n\nexport function captureSkillProviderPlugins(value: unknown): readonly CapturedSkillProviderPlugin[] {\n if (value === undefined) return Object.freeze([])\n const providers = arrayData(value, SKILL_PROVIDER_LIMITS.providers)\n .map(entry => captureSkillProviderPlugin(entry))\n const seen = new Map<string, number>()\n for (const [index, provider] of providers.entries()) {\n const first = seen.get(provider.id)\n if (first !== undefined) throw capabilityIdentityError(\n SKILL_PROVIDER_ERROR_CODES.ID_CONFLICT, 'skill-provider-id', first, index,\n )\n seen.set(provider.id, index)\n }\n return Object.freeze(providers)\n}\n\nexport function captureRuntimeSkillSources(value: unknown): readonly RuntimeSkillSource[] {\n if (value === undefined) return Object.freeze([])\n const entries = arrayData(value, SKILL_PROVIDER_LIMITS.providers)\n const sources = entries.map(entry => {\n const source = objectValue(entry)\n const kind = ownData(source, 'kind')\n if (kind === 'skill') {\n validateSkillSource(source as RuntimeSkillSource & { readonly kind: 'skill' })\n return source as RuntimeSkillSource\n }\n if (kind !== 'skill-provider') throw new AgentSdkError(\n 'Skill provider kind is unsupported', SKILL_PROVIDER_ERROR_CODES.KIND_MISMATCH,\n )\n const version = ownData(source, 'apiVersion', false)\n if (version === undefined) {\n validateSkillSource(source as SkillProvider)\n return source as RuntimeSkillSource\n }\n return captureSkillProviderPlugin(source)\n })\n const providers = sources.filter(source => source.kind === 'skill-provider')\n const ids = new Map<string, number>()\n for (const [index, provider] of providers.entries()) {\n const first = ids.get(provider.id)\n if (first !== undefined) throw capabilityIdentityError(\n SKILL_PROVIDER_ERROR_CODES.ID_CONFLICT, 'skill-provider-id', first, index,\n )\n ids.set(provider.id, index)\n }\n return Object.freeze(sources)\n}\n\nfunction method(value: object, key: string, required: boolean): Function | undefined {\n let result: unknown\n try { result = Reflect.get(value, key) } catch { throw new TypeError('Method capture failed') }\n if (result === undefined && !required) return undefined\n if (typeof result !== 'function') throw new TypeError('Method is invalid')\n return result\n}\n"],"mappings":"0fAgBA,SAAgB,EACd,EACqB,CACrB,OAAO,EAA2B,EAAU,EAAK,CACnD,CAEA,SAAgB,EACd,EACA,EAAgB,GACa,CAC7B,GAAI,CACF,IAAM,EAAS,EAAY,CAAK,EAChC,GAAI,EAAe,CACjB,GAAI,EAAQ,EAAQ,MAAM,IAAM,iBAAkB,MAAM,IAAI,EAC1D,qCAAsC,EAA2B,aACnE,EACA,GAAI,EAAQ,EAAQ,YAAY,IAAA,EAAkC,MAAM,IAAI,EAC1E,4CAA6C,EAA2B,eAC1E,CACF,CACA,IAAM,EAAK,EAAY,EAAQ,EAAQ,IAAI,EAAG,EAAsB,aAAa,EACjF,EAAgB,EAAI,gBAAgB,EACpC,IAAM,EAAa,EAAO,EAAQ,OAAQ,EAAI,EACxC,EAAa,EAAO,EAAQ,OAAQ,EAAI,EACxC,EAAiB,EAAO,EAAQ,eAAgB,EAAK,EACrD,EAAQ,GACZ,EAA4B,EAAQ,OAAQ,sBAAuB,OAAQ,EAAQ,WAC3E,QAAQ,MAAM,EAAa,EAAQ,CAAC,CAAO,CAAC,CAAkC,EAClF,GAAQ,EAA2B,IACvC,EAA4B,EAAQ,OAAQ,sBAAuB,OAAQ,EAAQ,WAC3E,QAAQ,MAAM,EAAa,EAAQ,CAAC,EAAW,CAAO,CAAC,CAA4C,EACvG,EAAe,IAAmB,IAAA,GAAY,IAAA,IAC/C,EAA2B,EAAc,IAC1C,EAA4B,EAAQ,OAAQ,sBAAuB,gBAAiB,EAAQ,WACpF,QAAQ,MAAM,EAAgB,EAAQ,CAAC,EAAW,EAAM,CAAO,CAAC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AmB,EACzE,OAAO,CADkE,CAE3E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AgentSdkError as e}from"../../../errors/agent-sdk-error.js";import{arrayData as t,boundedText as n,objectValue as r,ownData as i}from"../../../capability/common/data.js";import{MAX_SKILL_DESCRIPTION_CHARS as a,validateSkillId as o}from"../definition.js";import{capabilityIdentityError as s}from"../../../errors/capability-identity.js";import{SKILL_ERROR_CODES as c,SKILL_PROVIDER_LIMITS as l}from"./config.js";import{snapshotJsonValue as u}from"../../../primitives/json-snapshot.js";const d=new Set([`id`,`name`,`description`,`whenToUse`,`invocation`,`source`,`provider`,`locator`]),f=new Set([`id`,`source`,`provider`,`catalogRevision`,`locator`,`resourceBase`]);function p(a,o,u,d){try{let e=r(o);S(e,new Set([`revision`,`candidates`]));let f=n(i(e,`revision`),l.revisionBytes),p=t(i(e,`candidates`),u).map(e=>h(e,a.id)),m=new Map;for(let[e,t]of p.entries()){let n=m.get(t.id);if(n!==void 0)throw s(c.ID_CONFLICT,`skill-id`,n,e);m.set(t.id,e)}let _=p.map(e=>g(e,f)),v=Object.freeze({revision:f,candidates:Object.freeze(p),references:Object.freeze(_)});if(new TextEncoder().encode(JSON.stringify(v)).byteLength>d)throw C();return v}catch(t){throw t instanceof e?t:C()}}function m(t){try{let e=r(t);S(e,f);let a=x(i(e,`id`),256);o(a);let s=x(i(e,`provider`),l.identityBytes);return o(s,`skill provider`),Object.freeze({id:a,source:x(i(e,`source`),256),provider:s,catalogRevision:n(i(e,`catalogRevision`),l.revisionBytes),..._(e),...y(e)})}catch(t){throw t instanceof e&&t.code===c.REFERENCE_INVALID?t:w()}}function h(e,t){let n=r(e);S(n,d);let s=x(i(n,`id`),256);o(s);let c=x(i(n,`provider`),l.identityBytes);if(c!==t)throw C();let u=v(i(n,`invocation`,!1));return Object.freeze({id:s,name:x(i(n,`name`),256),description:x(i(n,`description`),a),...b(n,`whenToUse`,a),...u===void 0?{}:{invocation:u},source:x(i(n,`source`),256),provider:c,..._(n)})}function g(e,t){return Object.freeze({id:e.id,source:e.source,provider:e.provider,catalogRevision:t,...e.locator===void 0?{}:{locator:e.locator}})}function _(e){let t=i(e,`locator`,!1);return t===void 0?{}:{locator:u(t,{maxObjectFields:l.locatorFields,maxArrayItems:l.locatorArrayItems,maxDepth:l.locatorDepth,maxNodes:l.locatorNodes,maxKeyBytes:l.locatorKeyBytes,maxBytes:l.locatorBytes})}}function v(e){if(e===void 0)return;let t=r(e);S(t,new Set([`modelInvocable`,`userInvocable`]));let n=i(t,`modelInvocable`),a=i(t,`userInvocable`);if(typeof n!=`boolean`||typeof a!=`boolean`)throw C();return Object.freeze({modelInvocable:n,userInvocable:a})}function y(e){let t=i(e,`resourceBase`,!1);if(t===void 0)return{};let n=r(t);S(n,new Set([`kind`,`value`]));let a=i(n,`kind`);if(a!==`directory`&&a!==`url`&&a!==`opaque`)throw w();return{resourceBase:Object.freeze({kind:a,value:x(i(n,`value`),l.locatorBytes)})}}function b(e,t,n){let r=i(e,t,!1);return r===void 0?{}:{[t]:x(r,n)}}function x(e,t){if(typeof e!=`string`||e.trim().length===0||e.length>t||new TextEncoder().encode(e).byteLength>t)throw TypeError(`Invalid skill text`);return e}function S(e,t){if(Reflect.ownKeys(e).some(e=>typeof e!=`string`||!t.has(e)))throw TypeError(`Unsupported skill field`)}function C(){return new e(`Skill catalog snapshot is invalid`,c.CATALOG_INVALID)}function w(){return new e(`Persisted skill reference is invalid`,c.REFERENCE_INVALID)}export{p as captureSkillCatalogSnapshot,m as captureSkillReference};
|
|
2
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","names":[],"sources":["../../../../src/agent/skill/provider/snapshot.ts"],"sourcesContent":["import { AgentSdkError } from '../../../errors/agent-sdk-error.ts'\nimport { snapshotJsonValue } from '../../../primitives/json-snapshot.ts'\nimport type { JsonValue } from '../../../primitives/index.ts'\nimport { arrayData, boundedText, objectValue, ownData } from '../../../capability/common/data.ts'\nimport { capabilityIdentityError } from '../../../errors/capability-identity.ts'\nimport {\n MAX_SKILL_DESCRIPTION_CHARS, MAX_SKILL_NAME_CHARS, validateSkillId,\n type SkillResourceBase,\n} from '../definition.ts'\nimport { SKILL_ERROR_CODES, SKILL_PROVIDER_LIMITS } from './config.ts'\nimport type {\n ActivatedSkillSnapshot, CapturedSkillProviderPlugin, RuntimeSkillCandidate,\n SkillReference,\n} from './types.ts'\n\nconst CANDIDATE_KEYS = new Set([\n 'id', 'name', 'description', 'whenToUse', 'invocation', 'source', 'provider', 'locator',\n])\nconst REFERENCE_KEYS = new Set(['id', 'source', 'provider', 'catalogRevision', 'locator', 'resourceBase'])\n\nexport interface CapturedSkillCatalogSnapshot {\n readonly revision: string\n readonly candidates: readonly RuntimeSkillCandidate[]\n readonly references: readonly SkillReference[]\n}\n\nexport function captureSkillCatalogSnapshot(\n provider: CapturedSkillProviderPlugin,\n value: unknown,\n maxSkills: number,\n maxBytes: number,\n): CapturedSkillCatalogSnapshot {\n try {\n const source = objectValue(value)\n exactKeys(source, new Set(['revision', 'candidates']))\n const revision = boundedText(ownData(source, 'revision'), SKILL_PROVIDER_LIMITS.revisionBytes)\n const entries = arrayData(ownData(source, 'candidates'), maxSkills)\n const candidates = entries.map(entry => captureCandidate(entry, provider.id))\n const ids = new Map<string, number>()\n for (const [index, candidate] of candidates.entries()) {\n const first = ids.get(candidate.id)\n if (first !== undefined) throw capabilityIdentityError(\n SKILL_ERROR_CODES.ID_CONFLICT, 'skill-id', first, index,\n )\n ids.set(candidate.id, index)\n }\n const references = candidates.map(candidate => referenceFromCandidate(candidate, revision))\n const captured = Object.freeze({\n revision, candidates: Object.freeze(candidates), references: Object.freeze(references),\n })\n if (new TextEncoder().encode(JSON.stringify(captured)).byteLength > maxBytes) throw invalidCatalog()\n return captured\n } catch (error) {\n if (error instanceof AgentSdkError) throw error\n throw invalidCatalog()\n }\n}\n\nexport function captureSkillReference(value: unknown): ActivatedSkillSnapshot {\n try {\n const source = objectValue(value)\n exactKeys(source, REFERENCE_KEYS)\n const id = text(ownData(source, 'id'), MAX_SKILL_NAME_CHARS)\n validateSkillId(id)\n const provider = text(ownData(source, 'provider'), SKILL_PROVIDER_LIMITS.identityBytes)\n validateSkillId(provider, 'skill provider')\n return Object.freeze({\n id,\n source: text(ownData(source, 'source'), MAX_SKILL_NAME_CHARS),\n provider,\n catalogRevision: boundedText(ownData(source, 'catalogRevision'), SKILL_PROVIDER_LIMITS.revisionBytes),\n ...captureOptionalLocator(source),\n ...captureResourceBase(source),\n })\n } catch (error) {\n if (error instanceof AgentSdkError && error.code === SKILL_ERROR_CODES.REFERENCE_INVALID) throw error\n throw invalidReference()\n }\n}\n\nfunction captureCandidate(value: unknown, providerId: string): RuntimeSkillCandidate {\n const source = objectValue(value)\n exactKeys(source, CANDIDATE_KEYS)\n const id = text(ownData(source, 'id'), MAX_SKILL_NAME_CHARS)\n validateSkillId(id)\n const provider = text(ownData(source, 'provider'), SKILL_PROVIDER_LIMITS.identityBytes)\n if (provider !== providerId) throw invalidCatalog()\n const invocation = captureInvocation(ownData(source, 'invocation', false))\n return Object.freeze({\n id, name: text(ownData(source, 'name'), MAX_SKILL_NAME_CHARS),\n description: text(ownData(source, 'description'), MAX_SKILL_DESCRIPTION_CHARS),\n ...optionalText(source, 'whenToUse', MAX_SKILL_DESCRIPTION_CHARS),\n ...(invocation === undefined ? {} : { invocation }),\n source: text(ownData(source, 'source'), MAX_SKILL_NAME_CHARS), provider,\n ...captureOptionalLocator(source),\n })\n}\n\nfunction referenceFromCandidate(candidate: RuntimeSkillCandidate, revision: string): SkillReference {\n return Object.freeze({ id: candidate.id, source: candidate.source, provider: candidate.provider,\n catalogRevision: revision, ...(candidate.locator === undefined ? {} : { locator: candidate.locator }) })\n}\n\nfunction captureOptionalLocator(source: object): { readonly locator?: JsonValue } {\n const locator = ownData(source, 'locator', false)\n return locator === undefined ? {} : { locator: snapshotJsonValue(locator, {\n maxObjectFields: SKILL_PROVIDER_LIMITS.locatorFields,\n maxArrayItems: SKILL_PROVIDER_LIMITS.locatorArrayItems,\n maxDepth: SKILL_PROVIDER_LIMITS.locatorDepth,\n maxNodes: SKILL_PROVIDER_LIMITS.locatorNodes,\n maxKeyBytes: SKILL_PROVIDER_LIMITS.locatorKeyBytes,\n maxBytes: SKILL_PROVIDER_LIMITS.locatorBytes,\n }) }\n}\n\nfunction captureInvocation(value: unknown): RuntimeSkillCandidate['invocation'] {\n if (value === undefined) return undefined\n const source = objectValue(value)\n exactKeys(source, new Set(['modelInvocable', 'userInvocable']))\n const modelInvocable = ownData(source, 'modelInvocable')\n const userInvocable = ownData(source, 'userInvocable')\n if (typeof modelInvocable !== 'boolean' || typeof userInvocable !== 'boolean') throw invalidCatalog()\n return Object.freeze({ modelInvocable, userInvocable })\n}\n\nfunction captureResourceBase(source: object): { readonly resourceBase?: SkillResourceBase } {\n const value = ownData(source, 'resourceBase', false)\n if (value === undefined) return {}\n const base = objectValue(value)\n exactKeys(base, new Set(['kind', 'value']))\n const kind = ownData(base, 'kind')\n if (kind !== 'directory' && kind !== 'url' && kind !== 'opaque') throw invalidReference()\n return { resourceBase: Object.freeze({\n kind, value: text(ownData(base, 'value'), SKILL_PROVIDER_LIMITS.locatorBytes),\n }) }\n}\n\nfunction optionalText(source: object, key: string, max: number): { readonly [key: string]: string } {\n const value = ownData(source, key, false)\n return value === undefined ? {} : { [key]: text(value, max) }\n}\n\nfunction text(value: unknown, max: number): string {\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > max\n || new TextEncoder().encode(value).byteLength > max) throw new TypeError('Invalid skill text')\n return value\n}\n\nfunction exactKeys(value: object, allowed: ReadonlySet<string>): void {\n if (Reflect.ownKeys(value).some(key => typeof key !== 'string' || !allowed.has(key))) {\n throw new TypeError('Unsupported skill field')\n }\n}\n\nfunction invalidCatalog(): AgentSdkError {\n return new AgentSdkError('Skill catalog snapshot is invalid', SKILL_ERROR_CODES.CATALOG_INVALID)\n}\n\nfunction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EAAa,EAAiD,CAClG,IAAM,EAAQ,EAAQ,EAAQ,EAAK,EAAK,EACxC,OAAO,IAAU,IAAA,GAAY,CAAC,EAAI,EAAG,GAAM,EAAK,EAAO,CAAG,CAAE,CAC9D,CAEA,SAAS,EAAK,EAAgB,EAAqB,CACjD,GAAI,OAAO,GAAU,UAAY,EAAM,KAAK,CAAC,CAAC,SAAW,GAAK,EAAM,OAAS,GACxE,IAAI,YAAY,CAAC,CAAC,OAAO,CAAK,CAAC,CAAC,WAAa,EAAK,MAAU,UAAU,oBAAoB,EAC/F,OAAO,CACT,CAEA,SAAS,EAAU,EAAe,EAAoC,CACpE,GAAI,QAAQ,QAAQ,CAAK,CAAC,CAAC,KAAK,GAAO,OAAO,GAAQ,UAAY,CAAC,EAAQ,IAAI,CAAG,CAAC,EACjF,MAAU,UAAU,yBAAyB,CAEjD,CAEA,SAAS,GAAgC,CACvC,OAAO,IAAI,EAAc,oCAAqC,EAAkB,eAAe,CACjG,CAEA,SAAS,GAAkC,CACzC,OAAO,IAAI,EAAc,uCAAwC,EAAkB,iBAAiB,CACtG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { JsonValue } from "../../../primitives/json.js";
|
|
2
|
+
import { SdkLogger } from "../../../logging/types.js";
|
|
3
|
+
import { SkillDefinition, SkillDefinitionInput, SkillInvocationPolicy, SkillLookupOptions, SkillProvider, SkillResourceBase } from "../definition.js";
|
|
4
|
+
import { SKILL_PROVIDER_API_VERSION } from "./config.js";
|
|
5
|
+
//#region src/agent/skill/provider/types.d.ts
|
|
6
|
+
interface RuntimeSkillCandidate {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly whenToUse?: string;
|
|
11
|
+
readonly invocation?: SkillInvocationPolicy;
|
|
12
|
+
readonly source: string;
|
|
13
|
+
readonly provider: string;
|
|
14
|
+
readonly locator?: JsonValue;
|
|
15
|
+
}
|
|
16
|
+
interface SkillCatalogSnapshot {
|
|
17
|
+
readonly revision: string;
|
|
18
|
+
readonly candidates: readonly RuntimeSkillCandidate[];
|
|
19
|
+
}
|
|
20
|
+
interface SkillReference {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly source: string;
|
|
23
|
+
readonly provider: string;
|
|
24
|
+
readonly catalogRevision: string;
|
|
25
|
+
readonly locator?: JsonValue;
|
|
26
|
+
}
|
|
27
|
+
interface ActivatedSkillSnapshot extends SkillReference {
|
|
28
|
+
readonly resourceBase?: SkillResourceBase;
|
|
29
|
+
}
|
|
30
|
+
type RuntimeSkillLookupOptions = Omit<SkillLookupOptions, 'signal'> & {
|
|
31
|
+
readonly signal: AbortSignal;
|
|
32
|
+
readonly logger: SdkLogger;
|
|
33
|
+
};
|
|
34
|
+
interface SkillProviderPlugin {
|
|
35
|
+
readonly kind: 'skill-provider';
|
|
36
|
+
readonly apiVersion: typeof SKILL_PROVIDER_API_VERSION;
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly list: (options: RuntimeSkillLookupOptions & {
|
|
39
|
+
readonly allowedSkillIds?: readonly string[];
|
|
40
|
+
}) => Promise<SkillCatalogSnapshot>;
|
|
41
|
+
readonly load: (reference: SkillReference, options: RuntimeSkillLookupOptions) => Promise<SkillDefinitionInput | undefined>;
|
|
42
|
+
readonly readResource?: (reference: SkillReference, path: string, options: RuntimeSkillLookupOptions) => Promise<string | undefined>;
|
|
43
|
+
}
|
|
44
|
+
type SkillProviderPluginDefinition = Omit<SkillProviderPlugin, 'kind' | 'apiVersion'>;
|
|
45
|
+
type SkillProviderDefinition = SkillProviderPluginDefinition;
|
|
46
|
+
type RuntimeSkillSource = SkillDefinition | SkillProvider | SkillProviderPlugin;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ActivatedSkillSnapshot, RuntimeSkillCandidate, RuntimeSkillLookupOptions, RuntimeSkillSource, SkillCatalogSnapshot, SkillProviderDefinition, SkillProviderPlugin, SkillProviderPluginDefinition, SkillReference };
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../../src/agent/skill/provider/types.ts"],"mappings":";;;;;UAQiB;WACN;WACA;WACA;WACA;WACA,aAAa;WACb;WACA;WACA,UAAU;;UAGJ;WACN;WACA,qBAAqB;;UAGf;WACN;WACA;WACA;WACA;WACA,UAAU;;UAGJ,+BAA+B;WACrC,eAAe;;KAGd,4BAA4B,KAAK;WAClC,QAAQ;WACR,QAAQ;;UAGF;WACN;WACA,mBAAmB;WACnB;WACA,OAAO,SAAS;aACd;QACL,QAAQ;WACL,OACP,WAAW,gBACX,SAAS,8BACN,QAAQ;WACJ,gBACP,WAAW,gBACX,cACA,SAAS,8BACN;;KAGK,gCAAgC,KAAK;KACrC,0BAA0B;KAE1B,qBAAqB,kBAAkB,gBAAgB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ToolDefinition } from "../tool/definition.js";
|
|
2
|
+
import { SkillLookupOptions, SkillSummary } from "./definition.js";
|
|
3
|
+
import { SkillCatalog } from "./catalog.js";
|
|
4
|
+
//#region src/agent/skill/tools.d.ts
|
|
5
|
+
declare const SKILL_TOOL_NAMES: readonly ["load_skill", "search_skill_resources", "read_skill_resource"];
|
|
6
|
+
interface AgentSkillOptions {
|
|
7
|
+
/** Maximum catalog characters appended to system instructions. Defaults to 8000. */
|
|
8
|
+
readonly maxCatalogChars?: number;
|
|
9
|
+
/** Search matches returned per call. Defaults to 12. */
|
|
10
|
+
readonly searchLimit?: number;
|
|
11
|
+
/** Maximum resource text returned by one tool call. Defaults to 10000. */
|
|
12
|
+
readonly maxWholeResourceChars?: number;
|
|
13
|
+
/** Maximum resource-manifest text returned by load_skill. Defaults to 4000. */
|
|
14
|
+
readonly maxManifestChars?: number;
|
|
15
|
+
/** Maximum search result text returned by one tool call. Defaults to 8000. */
|
|
16
|
+
readonly maxSearchResultChars?: number;
|
|
17
|
+
/** Maximum resource files hydrated by one search. Defaults to 32. */
|
|
18
|
+
readonly maxSearchResources?: number;
|
|
19
|
+
/** Maximum resource characters inspected by one search. Defaults to 200000. */
|
|
20
|
+
readonly maxSearchInputChars?: number;
|
|
21
|
+
/** Deadline for one skill discovery/load/read/search operation. Defaults to 120 seconds. */
|
|
22
|
+
readonly operationTimeoutMs?: number;
|
|
23
|
+
/** Maximum entries accepted in the merged skill catalog. Defaults to 1,024. */
|
|
24
|
+
readonly maxSkills?: number;
|
|
25
|
+
/** Maximum serialized bytes accepted while discovering a catalog. Defaults to 4 MiB. */
|
|
26
|
+
readonly maxDiscoveryBytes?: number;
|
|
27
|
+
}
|
|
28
|
+
interface ResolvedAgentSkillOptions {
|
|
29
|
+
readonly maxCatalogChars: number;
|
|
30
|
+
readonly searchLimit: number;
|
|
31
|
+
readonly maxWholeResourceChars: number;
|
|
32
|
+
readonly maxManifestChars: number;
|
|
33
|
+
readonly maxSearchResultChars: number;
|
|
34
|
+
readonly maxSearchResources: number;
|
|
35
|
+
readonly maxSearchInputChars: number;
|
|
36
|
+
readonly operationTimeoutMs: number;
|
|
37
|
+
readonly maxSkills: number;
|
|
38
|
+
readonly maxDiscoveryBytes: number;
|
|
39
|
+
}
|
|
40
|
+
declare function resolveSkillOptions(input: AgentSkillOptions | undefined): ResolvedAgentSkillOptions;
|
|
41
|
+
declare function renderSkillCatalog(instructions: string, summaries: readonly SkillSummary[], options: ResolvedAgentSkillOptions): string;
|
|
42
|
+
declare function createSkillTools(catalog: SkillCatalog, options: ResolvedAgentSkillOptions, lookup: () => SkillLookupOptions): readonly ToolDefinition<any>[];
|
|
43
|
+
//#endregion
|
|
44
|
+
export { AgentSkillOptions, ResolvedAgentSkillOptions, SKILL_TOOL_NAMES, createSkillTools, renderSkillCatalog, resolveSkillOptions };
|
|
45
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","names":[],"sources":["../../../src/agent/skill/tools.ts"],"mappings":";;;;cAMa;UAII;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;iBAGK,oBAAoB,OAAO,gCAAgC;iBAyB3D,mBACd,sBACA,oBAAoB,gBACpB,SAAS;iBAsCK,iBACd,SAAS,cACT,SAAS,2BACT,cAAc,8BACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{defineTool as e}from"../tool/definition.js";const t=Object.freeze([`load_skill`,`search_skill_resources`,`read_skill_resource`]);function n(e){return Object.freeze({maxCatalogChars:C(e?.maxCatalogChars,8e3,512,1e5,`maxCatalogChars`),searchLimit:C(e?.searchLimit,12,1,100,`searchLimit`),maxWholeResourceChars:C(e?.maxWholeResourceChars,1e4,256,4e4,`maxWholeResourceChars`),maxManifestChars:C(e?.maxManifestChars,4e3,256,4e4,`maxManifestChars`),maxSearchResultChars:C(e?.maxSearchResultChars,8e3,256,4e4,`maxSearchResultChars`),maxSearchResources:C(e?.maxSearchResources,32,1,256,`maxSearchResources`),maxSearchInputChars:C(e?.maxSearchInputChars,2e5,256,1024e4,`maxSearchInputChars`),operationTimeoutMs:C(e?.operationTimeoutMs,12e4,1,2147483647,`operationTimeoutMs`),maxSkills:C(e?.maxSkills,1024,1,1e5,`maxSkills`),maxDiscoveryBytes:C(e?.maxDiscoveryBytes,4194304,1024,134217728,`maxDiscoveryBytes`)})}function r(e,t,n){let r=t.filter(e=>e.invocation.modelInvocable);if(r.length===0)return e;let i=[`<available_skills>`,`Skills contain instructions not loaded yet. When a request matches one, call load_skill before acting. Only the ids below are valid.`],a=`</available_skills>`,o=[],s=0;for(let e of r){let t=[`- id: ${w(e.id)}`,` name: ${w(e.name)}`,` description: ${w(e.description)}`,...e.whenToUse===void 0?[]:[` when_to_use: ${w(e.whenToUse)}`]],r=`- omitted: ${s+1} additional skills; ask the host to narrow the catalog`;if([...i,...o.flat(),...t,r,a].join(`
|
|
2
|
+
`).length>n.maxCatalogChars){s++;continue}o.push(t)}for(;s>0;){let e=`- omitted: ${s} additional skills; ask the host to narrow the catalog`;if([...i,...o.flat(),e,a].join(`
|
|
3
|
+
`).length<=n.maxCatalogChars||o.length===0)break;o.pop(),s++}let c=[...i,...o.flat()];return s>0&&c.push(`- omitted: ${s} additional skills; ask the host to narrow the catalog`),c.push(a),`${e}\n\n${c.join(`
|
|
4
|
+
`)}`}function i(t,n,r){let i=e({name:`load_skill`,description:`Load the complete instructions for one available skill before following it.`,parameters:{type:`object`,properties:{skillId:{type:`string`}},required:[`skillId`],additionalProperties:!1},parse:g,async execute({skillId:e},i){return s(await a(t,e,{...r(),signal:i.signal}),n.maxManifestChars)},meta:(e,{skillId:t})=>({kind:`skill`,skillId:t,resourcePath:null}),timeoutMs:n.operationTimeoutMs}),c=e({name:`read_skill_resource`,description:`Read one text resource or one Markdown section bundled with a loaded skill.`,parameters:{type:`object`,properties:{skillId:{type:`string`},path:{type:`string`},section:{type:[`string`,`null`],description:`Exact Markdown heading, or null for the whole file.`},offset:{type:`integer`,minimum:0,description:`Character offset within the file or selected section.`},maxChars:{type:`integer`,minimum:1,description:`Requested chunk size, capped by the agent policy.`}},required:[`skillId`,`path`],additionalProperties:!1},parse:_,async execute({skillId:e,path:i,section:a,offset:s,maxChars:c},u){let f={...r(),signal:u.signal};o(t,e);let p=await t.readResource(e,i,f);if(p===void 0)throw Error(`skill '${e}' has no resource '${i}'`);let g=m(p),_=p;if(a!==null){let e=h(p,a);if(e===void 0)throw Error(`resource '${i}' has no section '${a}'; sections: ${d(g)}`);_=e}return l(_,s,Math.min(c??n.maxWholeResourceChars,n.maxWholeResourceChars))},meta:(e,{skillId:t,path:n,section:r})=>({kind:`skill`,skillId:t,resourcePath:r===null?n:`${n}#${r}`}),timeoutMs:n.operationTimeoutMs}),u=e({name:`search_skill_resources`,description:`Search resources from one skill already loaded with load_skill; never searches the whole catalog.`,parameters:{type:`object`,properties:{query:{type:`string`},skillId:{type:`string`,description:`One skill already activated with load_skill.`}},required:[`query`,`skillId`],additionalProperties:!1},parse:v,async execute({query:e,skillId:i},a){o(t,i);let s=t.activatedResources(i);if(s===void 0)throw Error(`skill '${i}' must be loaded before its resources are searched`);let c=[],l=0,u=0,d=0,m=!1,h={...r(),signal:a.signal};for(let r of s){if(u>=n.maxSearchResources||d>=n.maxSearchInputChars){m=!0;break}let a=r.path;u++;let o=await t.readResource(i,a,h);if(o===void 0)continue;let s=n.maxSearchInputChars-d,p=o.slice(0,s);d+=p.length,p.length<o.length&&(m=!0);let g=`(root)`,_=p.split(/\r?\n/);for(let t=0;t<_.length;t++){let r=_[t]??``,o=/^#{1,6}\s+(.+?)\s*$/.exec(r)?.[1];if(o!==void 0&&(g=o),r.toLocaleLowerCase().includes(e.toLocaleLowerCase())){let e=f(c,`${i}/${a}:${t+1} [${g}] ${r.trim()}`,l,n.maxSearchResultChars);if(l=e.total,!e.complete||c.length>=n.searchLimit)return c.join(`
|
|
5
|
+
`)}}if(m)break}let g=m?`Search stopped at the configured budget (${u} resources, ${d} characters). Narrow the query or read a named resource.`:void 0;return c.length===0?p([`No skill resource matched '${e}'.`,...g===void 0?[]:[g]].join(`
|
|
6
|
+
`),n.maxSearchResultChars):(g===void 0||f(c,g,l,n.maxSearchResultChars),c.join(`
|
|
7
|
+
`))},meta:(e,{skillId:t})=>({kind:`skill-search`,skillId:t}),timeoutMs:n.operationTimeoutMs});return Object.freeze([i,u,c])}async function a(e,t,n){let r=e.summaries().find(e=>e.id===t);if(r===void 0)throw Error(`unknown skill '${t}'`);if(!r.invocation.modelInvocable)throw Error(`skill '${t}' is not model-invocable`);let i=await e.activate(t,n);if(i===void 0)throw Error(`skill '${t}' is no longer available`);if(!i.invocation.modelInvocable)throw Error(`skill '${t}' is no longer model-invocable`);return i}function o(e,t){let n=e.summaries().find(e=>e.id===t);if(n===void 0)throw Error(`unknown skill '${t}'`);if(!n.invocation.modelInvocable)throw Error(`skill '${t}' is not model-invocable`);if(!e.isActivated(t))throw Error(`skill '${t}' must be loaded with load_skill first`)}function s(e,t){let n=e.resourceManifest,r=n.length===0?`Bundled resources: none.`:c([`Bundled resources (use search_skill_resources or read_skill_resource):`,...n.map(e=>`- ${w(e.path)}${e.sizeChars===void 0?e.sizeBytes===void 0?``:`: ${e.sizeBytes} bytes`:`: ${e.sizeChars} chars`}`)],t);return[`<skill_content id="${w(e.id)}">`,r,`<skill_instructions>`,e.instructions,`</skill_instructions>`,`</skill_content>`].join(`
|
|
8
|
+
`)}function c(e,t){if(e.join(`
|
|
9
|
+
`).length<=t)return e.join(`
|
|
10
|
+
`);let n=[e[0]??`Bundled resources:`],r=Math.max(0,e.length-1);for(let i of e.slice(1)){let e=`- omitted: ${r-1} additional resources`;if([...n,i,e].join(`
|
|
11
|
+
`).length>t)break;n.push(i),r--}return r>0&&n.push(`- omitted: ${r} additional resources`),p(n.join(`
|
|
12
|
+
`),t)}function l(e,t,n){if(t>e.length)throw RangeError(`offset ${t} exceeds resource length ${e.length}`);if(t===0&&e.length<=n)return e;let r=Math.min(e.length,t+Math.max(1,n-160)),i=u(t,r,e.length);r=Math.min(e.length,t+Math.max(1,n-i.length-1)),i=u(t,r,e.length);let a=e.slice(t,r);return p(`${i}\n${a}`,n)}function u(e,t,n){return`[resource chunk ${e}:${t} of ${n}; ${t<n?`next offset ${t}`:`end`}]`}function d(e){return e.length===0?`none`:p(e.join(`, `),1e3)}function f(e,t,n,r){let i=e.length===0?0:1,a=r-n-i;if(a<=0)return{total:n,complete:!1};let o=p(t,a);return e.push(o),{total:n+i+o.length,complete:o.length===t.length}}function p(e,t){return e.length<=t?e:t<=14?e.slice(0,t):e.slice(0,t-14)+`...[truncated]`}function m(e){return e.split(/\r?\n/).flatMap(e=>{let t=/^#{1,6}\s+(.+?)\s*$/.exec(e)?.[1];return t===void 0?[]:[t]})}function h(e,t){let n=e.split(/\r?\n/),r=-1,i=0;for(let e=0;e<n.length;e++){let a=/^(#{1,6})\s+(.+?)\s*$/.exec(n[e]??``);if(a?.[2]===t){r=e,i=a[1]?.length??0;break}}if(r<0)return;let a=n.length;for(let e=r+1;e<n.length;e++){let t=/^(#{1,6})\s+/.exec(n[e]??``);if(t!==null&&(t[1]?.length??7)<=i){a=e;break}}return n.slice(r,a).join(`
|
|
13
|
+
`).trim()}function g(e){return{skillId:b(y(e).skillId,`skillId`)}}function _(e){let t=y(e);return{skillId:b(t.skillId,`skillId`),path:b(t.path,`path`),section:t.section===void 0||t.section===null?null:b(t.section,`section`),offset:S(t.offset,0,0,2**53-1,`offset`),...t.maxChars===void 0?{}:{maxChars:S(t.maxChars,0,1,4e4,`maxChars`)}}}function v(e){let t=y(e);return{query:x(t.query,`query`,1024),skillId:b(t.skillId,`skillId`)}}function y(e){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`arguments must be an object`);return e}function b(e,t){if(typeof e!=`string`||e.trim().length===0)throw TypeError(`${t} must be a non-empty string`);return e}function x(e,t,n){let r=b(e,t);if(r.length>n)throw RangeError(`${t} must not exceed ${n} characters`);return r}function S(e,t,n,r,i){let a=e??t;if(typeof a!=`number`||!Number.isSafeInteger(a)||a<n||a>r)throw RangeError(`${i} must be an integer between ${n} and ${r}`);return a}function C(e,t,n,r,i){let a=e??t;if(!Number.isInteger(a)||a<n||a>r)throw RangeError(`skill ${i} must be an integer between ${n} and ${r}`);return a}function w(e){return e.replace(/\s+/g,` `).trim().replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}export{t as SKILL_TOOL_NAMES,i as createSkillTools,r as renderSkillCatalog,n as resolveSkillOptions};
|
|
14
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","names":[],"sources":["../../../src/agent/skill/tools.ts"],"sourcesContent":["/** Progressive-disclosure prompt and tools for a SkillCatalog. */\n\nimport { defineTool, type ToolDefinition } from '../tool/definition.ts'\nimport type { SkillCatalog } from './catalog.ts'\nimport type { SkillDefinition, SkillLookupOptions, SkillSummary } from './definition.ts'\n\nexport const SKILL_TOOL_NAMES = Object.freeze([\n 'load_skill', 'search_skill_resources', 'read_skill_resource',\n] as const)\n\nexport interface AgentSkillOptions {\n /** Maximum catalog characters appended to system instructions. Defaults to 8000. */\n readonly maxCatalogChars?: number\n /** Search matches returned per call. Defaults to 12. */\n readonly searchLimit?: number\n /** Maximum resource text returned by one tool call. Defaults to 10000. */\n readonly maxWholeResourceChars?: number\n /** Maximum resource-manifest text returned by load_skill. Defaults to 4000. */\n readonly maxManifestChars?: number\n /** Maximum search result text returned by one tool call. Defaults to 8000. */\n readonly maxSearchResultChars?: number\n /** Maximum resource files hydrated by one search. Defaults to 32. */\n readonly maxSearchResources?: number\n /** Maximum resource characters inspected by one search. Defaults to 200000. */\n readonly maxSearchInputChars?: number\n /** Deadline for one skill discovery/load/read/search operation. Defaults to 120 seconds. */\n readonly operationTimeoutMs?: number\n /** Maximum entries accepted in the merged skill catalog. Defaults to 1,024. */\n readonly maxSkills?: number\n /** Maximum serialized bytes accepted while discovering a catalog. Defaults to 4 MiB. */\n readonly maxDiscoveryBytes?: number\n}\n\nexport interface ResolvedAgentSkillOptions {\n readonly maxCatalogChars: number\n readonly searchLimit: number\n readonly maxWholeResourceChars: number\n readonly maxManifestChars: number\n readonly maxSearchResultChars: number\n readonly maxSearchResources: number\n readonly maxSearchInputChars: number\n readonly operationTimeoutMs: number\n readonly maxSkills: number\n readonly maxDiscoveryBytes: number\n}\n\nexport function resolveSkillOptions(input: AgentSkillOptions | undefined): ResolvedAgentSkillOptions {\n return Object.freeze({\n maxCatalogChars: integer(input?.maxCatalogChars, 8_000, 512, 100_000, 'maxCatalogChars'),\n searchLimit: integer(input?.searchLimit, 12, 1, 100, 'searchLimit'),\n maxWholeResourceChars: integer(\n input?.maxWholeResourceChars, 10_000, 256, 40_000, 'maxWholeResourceChars',\n ),\n maxManifestChars: integer(input?.maxManifestChars, 4_000, 256, 40_000, 'maxManifestChars'),\n maxSearchResultChars: integer(\n input?.maxSearchResultChars, 8_000, 256, 40_000, 'maxSearchResultChars',\n ),\n maxSearchResources: integer(\n input?.maxSearchResources, 32, 1, 256, 'maxSearchResources',\n ),\n maxSearchInputChars: integer(\n input?.maxSearchInputChars, 200_000, 256, 10_240_000, 'maxSearchInputChars',\n ),\n operationTimeoutMs: integer(input?.operationTimeoutMs, 120_000, 1, 2_147_483_647, 'operationTimeoutMs'),\n maxSkills: integer(input?.maxSkills, 1_024, 1, 100_000, 'maxSkills'),\n maxDiscoveryBytes: integer(\n input?.maxDiscoveryBytes, 4 * 1024 * 1024, 1_024, 128 * 1024 * 1024, 'maxDiscoveryBytes',\n ),\n })\n}\n\nexport function renderSkillCatalog(\n instructions: string,\n summaries: readonly SkillSummary[],\n options: ResolvedAgentSkillOptions,\n): string {\n const available = summaries.filter(skill => skill.invocation.modelInvocable)\n if (available.length === 0) return instructions\n const header = [\n '<available_skills>',\n 'Skills contain instructions not loaded yet. When a request matches one, call load_skill before acting. Only the ids below are valid.',\n ]\n const footer = '</available_skills>'\n const entries: string[][] = []\n let omitted = 0\n for (const skill of available) {\n const entry = [\n `- id: ${escapePrompt(skill.id)}`,\n ` name: ${escapePrompt(skill.name)}`,\n ` description: ${escapePrompt(skill.description)}`,\n ...(skill.whenToUse === undefined ? [] : [` when_to_use: ${escapePrompt(skill.whenToUse)}`]),\n ]\n const omission = `- omitted: ${omitted + 1} additional skills; ask the host to narrow the catalog`\n if ([...header, ...entries.flat(), ...entry, omission, footer].join('\\n').length > options.maxCatalogChars) {\n omitted++\n continue\n }\n entries.push(entry)\n }\n while (omitted > 0) {\n const omission = `- omitted: ${omitted} additional skills; ask the host to narrow the catalog`\n const rendered = [...header, ...entries.flat(), omission, footer].join('\\n')\n if (rendered.length <= options.maxCatalogChars || entries.length === 0) break\n entries.pop()\n omitted++\n }\n const lines = [...header, ...entries.flat()]\n if (omitted > 0) lines.push(`- omitted: ${omitted} additional skills; ask the host to narrow the catalog`)\n lines.push(footer)\n return `${instructions}\\n\\n${lines.join('\\n')}`\n}\n\nexport function createSkillTools(\n catalog: SkillCatalog,\n options: ResolvedAgentSkillOptions,\n lookup: () => SkillLookupOptions,\n): readonly ToolDefinition<any>[] {\n const load = defineTool({\n name: 'load_skill',\n description: 'Load the complete instructions for one available skill before following it.',\n parameters: {\n type: 'object', properties: { skillId: { type: 'string' } }, required: ['skillId'], additionalProperties: false,\n },\n parse: parseSkillId,\n async execute({ skillId }, context) {\n const skill = await activateModelSkill(catalog, skillId, { ...lookup(), signal: context.signal })\n return renderSkill(skill, options.maxManifestChars)\n },\n meta: (_value, { skillId }) => ({ kind: 'skill', skillId, resourcePath: null }),\n timeoutMs: options.operationTimeoutMs,\n })\n\n const read = defineTool({\n name: 'read_skill_resource',\n description: 'Read one text resource or one Markdown section bundled with a loaded skill.',\n parameters: {\n type: 'object',\n properties: {\n skillId: { type: 'string' }, path: { type: 'string' },\n section: { type: ['string', 'null'], description: 'Exact Markdown heading, or null for the whole file.' },\n offset: { type: 'integer', minimum: 0, description: 'Character offset within the file or selected section.' },\n maxChars: { type: 'integer', minimum: 1, description: 'Requested chunk size, capped by the agent policy.' },\n },\n required: ['skillId', 'path'], additionalProperties: false,\n },\n parse: parseResourceRead,\n async execute({ skillId, path, section, offset, maxChars }, context) {\n const request = { ...lookup(), signal: context.signal }\n requireActivatedModelSkill(catalog, skillId)\n const resource = await catalog.readResource(skillId, path, request)\n if (resource === undefined) throw new Error(`skill '${skillId}' has no resource '${path}'`)\n const headings = markdownSections(resource)\n let selected = resource\n if (section !== null) {\n const sectionText = extractSection(resource, section)\n if (sectionText === undefined) {\n throw new Error(`resource '${path}' has no section '${section}'; sections: ${boundedHeadings(headings)}`)\n }\n selected = sectionText\n }\n return resourceChunk(\n selected, offset, Math.min(maxChars ?? options.maxWholeResourceChars, options.maxWholeResourceChars),\n )\n },\n meta: (_value, { skillId, path, section }) => ({\n kind: 'skill', skillId, resourcePath: section === null ? path : `${path}#${section}`,\n }),\n timeoutMs: options.operationTimeoutMs,\n })\n\n const search = defineTool({\n name: 'search_skill_resources',\n description: 'Search resources from one skill already loaded with load_skill; never searches the whole catalog.',\n parameters: {\n type: 'object',\n properties: {\n query: { type: 'string' },\n skillId: { type: 'string', description: 'One skill already activated with load_skill.' },\n },\n required: ['query', 'skillId'], additionalProperties: false,\n },\n parse: parseSearch,\n async execute({ query, skillId }, context) {\n requireActivatedModelSkill(catalog, skillId)\n const resources = catalog.activatedResources(skillId)\n if (resources === undefined) throw new Error(`skill '${skillId}' must be loaded before its resources are searched`)\n const hits: string[] = []\n let resultChars = 0\n let resourcesRead = 0\n let inputChars = 0\n let truncated = false\n const request = { ...lookup(), signal: context.signal }\n for (const resource of resources) {\n if (resourcesRead >= options.maxSearchResources\n || inputChars >= options.maxSearchInputChars) {\n truncated = true\n break\n }\n const path = resource.path\n resourcesRead++\n const content = await catalog.readResource(skillId, path, request)\n if (content === undefined) continue\n const remaining = options.maxSearchInputChars - inputChars\n const searchable = content.slice(0, remaining)\n inputChars += searchable.length\n if (searchable.length < content.length) truncated = true\n let heading = '(root)'\n const lines = searchable.split(/\\r?\\n/)\n for (let index = 0; index < lines.length; index++) {\n const line = lines[index] ?? ''\n const parsedHeading = /^#{1,6}\\s+(.+?)\\s*$/.exec(line)?.[1]\n if (parsedHeading !== undefined) heading = parsedHeading\n if (line.toLocaleLowerCase().includes(query.toLocaleLowerCase())) {\n const hit = `${skillId}/${path}:${index + 1} [${heading}] ${line.trim()}`\n const appended = appendBoundedHit(hits, hit, resultChars, options.maxSearchResultChars)\n resultChars = appended.total\n if (!appended.complete || hits.length >= options.searchLimit) return hits.join('\\n')\n }\n }\n if (truncated) break\n }\n const limit = truncated\n ? `Search stopped at the configured budget (${resourcesRead} resources, ${inputChars} characters). Narrow the query or read a named resource.`\n : undefined\n if (hits.length === 0) {\n return bounded([\n `No skill resource matched '${query}'.`,\n ...(limit === undefined ? [] : [limit]),\n ].join('\\n'), options.maxSearchResultChars)\n }\n if (limit === undefined) return hits.join('\\n')\n appendBoundedHit(hits, limit, resultChars, options.maxSearchResultChars)\n return hits.join('\\n')\n },\n meta: (_value, { skillId }) => ({ kind: 'skill-search', skillId }),\n timeoutMs: options.operationTimeoutMs,\n })\n\n return Object.freeze([load, search, read])\n}\n\nasync function activateModelSkill(\n catalog: SkillCatalog,\n id: string,\n lookup: SkillLookupOptions,\n): Promise<SkillDefinition> {\n const summary = catalog.summaries().find(skill => skill.id === id)\n if (summary === undefined) throw new Error(`unknown skill '${id}'`)\n if (!summary.invocation.modelInvocable) throw new Error(`skill '${id}' is not model-invocable`)\n const skill = await catalog.activate(id, lookup)\n if (skill === undefined) throw new Error(`skill '${id}' is no longer available`)\n if (!skill.invocation.modelInvocable) throw new Error(`skill '${id}' is no longer model-invocable`)\n return skill\n}\n\nfunction requireActivatedModelSkill(catalog: SkillCatalog, id: string): void {\n const summary = catalog.summaries().find(skill => skill.id === id)\n if (summary === undefined) throw new Error(`unknown skill '${id}'`)\n if (!summary.invocation.modelInvocable) throw new Error(`skill '${id}' is not model-invocable`)\n if (!catalog.isActivated(id)) throw new Error(`skill '${id}' must be loaded with load_skill first`)\n}\n\nfunction renderSkill(skill: SkillDefinition, maxManifestChars: number): string {\n const resources = skill.resourceManifest\n const manifest = resources.length === 0\n ? 'Bundled resources: none.'\n : boundedManifest([\n 'Bundled resources (use search_skill_resources or read_skill_resource):',\n ...resources.map(resource => `- ${escapePrompt(resource.path)}${resource.sizeChars === undefined\n ? resource.sizeBytes === undefined ? '' : `: ${resource.sizeBytes} bytes`\n : `: ${resource.sizeChars} chars`}`),\n ], maxManifestChars)\n return [\n `<skill_content id=\"${escapePrompt(skill.id)}\">`, manifest,\n '<skill_instructions>', skill.instructions, '</skill_instructions>', '</skill_content>',\n ].join('\\n')\n}\n\nfunction boundedManifest(lines: readonly string[], maxChars: number): string {\n if (lines.join('\\n').length <= maxChars) return lines.join('\\n')\n const kept = [lines[0] ?? 'Bundled resources:']\n let omitted = Math.max(0, lines.length - 1)\n for (const line of lines.slice(1)) {\n const marker = `- omitted: ${omitted - 1} additional resources`\n if ([...kept, line, marker].join('\\n').length > maxChars) break\n kept.push(line)\n omitted--\n }\n if (omitted > 0) kept.push(`- omitted: ${omitted} additional resources`)\n return bounded(kept.join('\\n'), maxChars)\n}\n\nfunction resourceChunk(content: string, offset: number, maxChars: number): string {\n if (offset > content.length) {\n throw new RangeError(`offset ${offset} exceeds resource length ${content.length}`)\n }\n if (offset === 0 && content.length <= maxChars) return content\n let end = Math.min(content.length, offset + Math.max(1, maxChars - 160))\n let header = chunkHeader(offset, end, content.length)\n end = Math.min(content.length, offset + Math.max(1, maxChars - header.length - 1))\n header = chunkHeader(offset, end, content.length)\n const body = content.slice(offset, end)\n return bounded(`${header}\\n${body}`, maxChars)\n}\n\nfunction chunkHeader(offset: number, end: number, total: number): string {\n return `[resource chunk ${offset}:${end} of ${total}; ${end < total ? `next offset ${end}` : 'end'}]`\n}\n\nfunction boundedHeadings(headings: readonly string[]): string {\n return headings.length === 0 ? 'none' : bounded(headings.join(', '), 1_000)\n}\n\nfunction appendBoundedHit(\n hits: string[], hit: string, current: number, max: number,\n): { total: number; complete: boolean } {\n const separator = hits.length === 0 ? 0 : 1\n const remaining = max - current - separator\n if (remaining <= 0) return { total: current, complete: false }\n const clipped = bounded(hit, remaining)\n hits.push(clipped)\n return { total: current + separator + clipped.length, complete: clipped.length === hit.length }\n}\n\nfunction bounded(value: string, max: number): string {\n if (value.length <= max) return value\n const suffix = '...[truncated]'\n if (max <= suffix.length) return value.slice(0, max)\n return value.slice(0, max - suffix.length) + suffix\n}\n\nfunction markdownSections(content: string): string[] {\n return content.split(/\\r?\\n/).flatMap(line => {\n const title = /^#{1,6}\\s+(.+?)\\s*$/.exec(line)?.[1]\n return title === undefined ? [] : [title]\n })\n}\n\nfunction extractSection(content: string, title: string): string | undefined {\n const lines = content.split(/\\r?\\n/)\n let start = -1\n let level = 0\n for (let index = 0; index < lines.length; index++) {\n const match = /^(#{1,6})\\s+(.+?)\\s*$/.exec(lines[index] ?? '')\n if (match?.[2] === title) { start = index; level = match[1]?.length ?? 0; break }\n }\n if (start < 0) return undefined\n let end = lines.length\n for (let index = start + 1; index < lines.length; index++) {\n const match = /^(#{1,6})\\s+/.exec(lines[index] ?? '')\n if (match !== null && (match[1]?.length ?? 7) <= level) { end = index; break }\n }\n return lines.slice(start, end).join('\\n').trim()\n}\n\nfunction parseSkillId(raw: unknown): { skillId: string } {\n const value = record(raw)\n return { skillId: requiredString(value.skillId, 'skillId') }\n}\n\nfunction parseResourceRead(raw: unknown): {\n skillId: string; path: string; section: string | null; offset: number; maxChars?: number\n} {\n const value = record(raw)\n return {\n skillId: requiredString(value.skillId, 'skillId'),\n path: requiredString(value.path, 'path'),\n section: value.section === undefined || value.section === null\n ? null : requiredString(value.section, 'section'),\n offset: optionalInteger(value.offset, 0, 0, Number.MAX_SAFE_INTEGER, 'offset'),\n ...(value.maxChars === undefined ? {} : {\n maxChars: optionalInteger(value.maxChars, 0, 1, 40_000, 'maxChars'),\n }),\n }\n}\n\nfunction parseSearch(raw: unknown): { query: string; skillId: string } {\n const value = record(raw)\n return {\n query: boundedInputString(value.query, 'query', 1_024),\n skillId: requiredString(value.skillId, 'skillId'),\n }\n}\n\nfunction record(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) throw new TypeError('arguments must be an object')\n return value as Record<string, unknown>\n}\n\nfunction requiredString(value: unknown, name: string): string {\n if (typeof value !== 'string' || value.trim().length === 0) throw new TypeError(`${name} must be a non-empty string`)\n return value\n}\n\nfunction boundedInputString(value: unknown, name: string, max: number): string {\n const result = requiredString(value, name)\n if (result.length > max) throw new RangeError(`${name} must not exceed ${max} characters`)\n return result\n}\n\nfunction optionalInteger(\n value: unknown, fallback: number, min: number, max: number, name: string,\n): number {\n const resolved = value ?? fallback\n if (typeof resolved !== 'number' || !Number.isSafeInteger(resolved) || resolved < min || resolved > max) {\n throw new RangeError(`${name} must be an integer between ${min} and ${max}`)\n }\n return resolved\n}\n\nfunction integer(value: number | undefined, fallback: number, min: number, max: number, name: string): number {\n const resolved = value ?? fallback\n if (!Number.isInteger(resolved) || resolved < min || resolved > max) {\n throw new RangeError(`skill ${name} must be an integer between ${min} and ${max}`)\n }\n return resolved\n}\n\nfunction escapePrompt(value: string): string {\n return value.replace(/\\s+/g, ' ').trim()\n .replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')\n}\n"],"mappings":"mDAMA,MAAa,EAAmB,OAAO,OAAO,CAC5C,aAAc,yBAA0B,qBAC1C,CAAU,EAsCV,SAAgB,EAAoB,EAAiE,CACnG,OAAO,OAAO,OAAO,CACnB,gBAAiB,EAAQ,GAAO,gBAAiB,IAAO,IAAK,IAAS,iBAAiB,EACvF,YAAa,EAAQ,GAAO,YAAa,GAAI,EAAG,IAAK,aAAa,EAClE,sBAAuB,EACrB,GAAO,sBAAuB,IAAQ,IAAK,IAAQ,uBACrD,EACA,iBAAkB,EAAQ,GAAO,iBAAkB,IAAO,IAAK,IAAQ,kBAAkB,EACzF,qBAAsB,EACpB,GAAO,qBAAsB,IAAO,IAAK,IAAQ,sBACnD,EACA,mBAAoB,EAClB,GAAO,mBAAoB,GAAI,EAAG,IAAK,oBACzC,EACA,oBAAqB,EACnB,GAAO,oBAAqB,IAAS,IAAK,OAAY,qBACxD,EACA,mBAAoB,EAAQ,GAAO,mBAAoB,KAAS,EAAG,WAAe,oBAAoB,EACtG,UAAW,EAAQ,GAAO,UAAW,KAAO,EAAG,IAAS,WAAW,EACnE,kBAAmB,EACjB,GAAO,kBAAmB,QAAiB,KAAO,UAAmB,mBACvE,CACF,CAAC,CACH,CAEA,SAAgB,EACd,EACA,EACA,EACQ,CACR,IAAM,EAAY,EAAU,OAAO,GAAS,EAAM,WAAW,cAAc,EAC3E,GAAI,EAAU,SAAW,EAAG,OAAO,EACnC,IAAM,EAAS,CACb,qBACA,sIACF,EACM,EAAS,sBACT,EAAsB,CAAC,EACzB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