operon-agents-core 0.1.0-alpha.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 +55 -0
- package/README.md +7 -0
- package/dist/agent/agent.d.ts +65 -0
- package/dist/agent/agent.js +39 -0
- package/dist/agent/compose-hooks.d.ts +13 -0
- package/dist/agent/compose-hooks.js +197 -0
- package/dist/agent/concurrency.d.ts +22 -0
- package/dist/agent/concurrency.js +70 -0
- package/dist/agent/context-report.d.ts +60 -0
- package/dist/agent/context-report.js +45 -0
- package/dist/agent/graph.d.ts +48 -0
- package/dist/agent/graph.js +129 -0
- package/dist/agent/guardrail.d.ts +105 -0
- package/dist/agent/guardrail.js +314 -0
- package/dist/agent/handoff-executor.d.ts +21 -0
- package/dist/agent/handoff-executor.js +95 -0
- package/dist/agent/handoff.d.ts +42 -0
- package/dist/agent/handoff.js +70 -0
- package/dist/agent/index.d.ts +25 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/instruction-context.d.ts +33 -0
- package/dist/agent/instruction-context.js +100 -0
- package/dist/agent/pause.d.ts +12 -0
- package/dist/agent/pause.js +82 -0
- package/dist/agent/profile-builtins.d.ts +8 -0
- package/dist/agent/profile-builtins.js +130 -0
- package/dist/agent/profiles.d.ts +94 -0
- package/dist/agent/profiles.js +264 -0
- package/dist/agent/recovery.d.ts +10 -0
- package/dist/agent/recovery.js +151 -0
- package/dist/agent/run-support.d.ts +79 -0
- package/dist/agent/run-support.js +211 -0
- package/dist/agent/runner.d.ts +246 -0
- package/dist/agent/runner.js +786 -0
- package/dist/agent/session.d.ts +363 -0
- package/dist/agent/session.js +937 -0
- package/dist/agent/subagent-tools.d.ts +18 -0
- package/dist/agent/subagent-tools.js +650 -0
- package/dist/agent/subagent.d.ts +56 -0
- package/dist/agent/subagent.js +50 -0
- package/dist/agent/toolset.d.ts +24 -0
- package/dist/agent/toolset.js +112 -0
- package/dist/agent/workflow/index.d.ts +9 -0
- package/dist/agent/workflow/index.js +8 -0
- package/dist/agent/workflow/journal.d.ts +180 -0
- package/dist/agent/workflow/journal.js +224 -0
- package/dist/agent/workflow/manager.d.ts +27 -0
- package/dist/agent/workflow/manager.js +33 -0
- package/dist/agent/workflow/parse.d.ts +17 -0
- package/dist/agent/workflow/parse.js +174 -0
- package/dist/agent/workflow/prompt.d.ts +8 -0
- package/dist/agent/workflow/prompt.js +84 -0
- package/dist/agent/workflow/runtime.d.ts +64 -0
- package/dist/agent/workflow/runtime.js +380 -0
- package/dist/agent/workflow/sandbox.d.ts +35 -0
- package/dist/agent/workflow/sandbox.js +90 -0
- package/dist/agent/workflow/snapshot.d.ts +36 -0
- package/dist/agent/workflow/snapshot.js +9 -0
- package/dist/agent/workflow/structured.d.ts +35 -0
- package/dist/agent/workflow/structured.js +79 -0
- package/dist/agent/workflow/tool.d.ts +14 -0
- package/dist/agent/workflow/tool.js +569 -0
- package/dist/agent/workflow/types.d.ts +100 -0
- package/dist/agent/workflow/types.js +17 -0
- package/dist/agent/worktree.d.ts +38 -0
- package/dist/agent/worktree.js +56 -0
- package/dist/capabilities/assembler.d.ts +39 -0
- package/dist/capabilities/assembler.js +171 -0
- package/dist/capabilities/background/agent-task.d.ts +51 -0
- package/dist/capabilities/background/agent-task.js +101 -0
- package/dist/capabilities/background/command-task.d.ts +43 -0
- package/dist/capabilities/background/command-task.js +86 -0
- package/dist/capabilities/background/index.d.ts +20 -0
- package/dist/capabilities/background/index.js +57 -0
- package/dist/capabilities/background/manager.d.ts +194 -0
- package/dist/capabilities/background/manager.js +1131 -0
- package/dist/capabilities/background/persist-disk.d.ts +17 -0
- package/dist/capabilities/background/persist-disk.js +66 -0
- package/dist/capabilities/background/persist.d.ts +61 -0
- package/dist/capabilities/background/persist.js +117 -0
- package/dist/capabilities/background/question-task.d.ts +32 -0
- package/dist/capabilities/background/question-task.js +56 -0
- package/dist/capabilities/background/registrar.d.ts +12 -0
- package/dist/capabilities/background/registrar.js +9 -0
- package/dist/capabilities/background/swappable-sink.d.ts +20 -0
- package/dist/capabilities/background/swappable-sink.js +20 -0
- package/dist/capabilities/background/task.d.ts +114 -0
- package/dist/capabilities/background/task.js +20 -0
- package/dist/capabilities/background/tools.d.ts +6 -0
- package/dist/capabilities/background/tools.js +190 -0
- package/dist/capabilities/background/workflow-task.d.ts +48 -0
- package/dist/capabilities/background/workflow-task.js +91 -0
- package/dist/capabilities/capability-state.d.ts +13 -0
- package/dist/capabilities/capability-state.js +37 -0
- package/dist/capabilities/capability.d.ts +145 -0
- package/dist/capabilities/capability.js +2 -0
- package/dist/capabilities/compaction/full.d.ts +27 -0
- package/dist/capabilities/compaction/full.js +155 -0
- package/dist/capabilities/compaction/index.d.ts +17 -0
- package/dist/capabilities/compaction/index.js +145 -0
- package/dist/capabilities/compaction/instruction.d.ts +2 -0
- package/dist/capabilities/compaction/instruction.js +31 -0
- package/dist/capabilities/compaction/micro.d.ts +17 -0
- package/dist/capabilities/compaction/micro.js +57 -0
- package/dist/capabilities/compaction/service.d.ts +28 -0
- package/dist/capabilities/compaction/service.js +52 -0
- package/dist/capabilities/compaction/strategy.d.ts +43 -0
- package/dist/capabilities/compaction/strategy.js +116 -0
- package/dist/capabilities/compaction/tokens.d.ts +5 -0
- package/dist/capabilities/compaction/tokens.js +28 -0
- package/dist/capabilities/goal/goal-store.d.ts +69 -0
- package/dist/capabilities/goal/goal-store.js +172 -0
- package/dist/capabilities/goal/index.d.ts +6 -0
- package/dist/capabilities/goal/index.js +31 -0
- package/dist/capabilities/goal/injector.d.ts +9 -0
- package/dist/capabilities/goal/injector.js +79 -0
- package/dist/capabilities/goal/tools.d.ts +6 -0
- package/dist/capabilities/goal/tools.js +86 -0
- package/dist/capabilities/index.d.ts +25 -0
- package/dist/capabilities/index.js +22 -0
- package/dist/capabilities/injection.d.ts +44 -0
- package/dist/capabilities/injection.js +112 -0
- package/dist/capabilities/plan/index.d.ts +6 -0
- package/dist/capabilities/plan/index.js +25 -0
- package/dist/capabilities/plan/injector.d.ts +13 -0
- package/dist/capabilities/plan/injector.js +83 -0
- package/dist/capabilities/plan/plan-mode.d.ts +38 -0
- package/dist/capabilities/plan/plan-mode.js +113 -0
- package/dist/capabilities/plan/policies.d.ts +6 -0
- package/dist/capabilities/plan/policies.js +89 -0
- package/dist/capabilities/plan/tools.d.ts +15 -0
- package/dist/capabilities/plan/tools.js +87 -0
- package/dist/capabilities/skills/flow-provider.d.ts +6 -0
- package/dist/capabilities/skills/flow-provider.js +50 -0
- package/dist/capabilities/skills/index.d.ts +43 -0
- package/dist/capabilities/skills/index.js +48 -0
- package/dist/capabilities/skills/injector.d.ts +11 -0
- package/dist/capabilities/skills/injector.js +27 -0
- package/dist/capabilities/skills/parser.d.ts +36 -0
- package/dist/capabilities/skills/parser.js +334 -0
- package/dist/capabilities/skills/registry.d.ts +33 -0
- package/dist/capabilities/skills/registry.js +118 -0
- package/dist/capabilities/skills/scanner.d.ts +26 -0
- package/dist/capabilities/skills/scanner.js +154 -0
- package/dist/capabilities/skills/service.d.ts +39 -0
- package/dist/capabilities/skills/service.js +68 -0
- package/dist/capabilities/skills/skill-tool.d.ts +13 -0
- package/dist/capabilities/skills/skill-tool.js +72 -0
- package/dist/capabilities/skills/types.d.ts +62 -0
- package/dist/capabilities/skills/types.js +26 -0
- package/dist/capabilities/task/index.d.ts +23 -0
- package/dist/capabilities/task/index.js +38 -0
- package/dist/capabilities/task/injector.d.ts +9 -0
- package/dist/capabilities/task/injector.js +62 -0
- package/dist/capabilities/task/persist-disk.d.ts +19 -0
- package/dist/capabilities/task/persist-disk.js +84 -0
- package/dist/capabilities/task/persist.d.ts +52 -0
- package/dist/capabilities/task/persist.js +84 -0
- package/dist/capabilities/task/task-store.d.ts +44 -0
- package/dist/capabilities/task/task-store.js +106 -0
- package/dist/capabilities/task/tools.d.ts +12 -0
- package/dist/capabilities/task/tools.js +164 -0
- package/dist/capabilities/todo/index.d.ts +8 -0
- package/dist/capabilities/todo/index.js +21 -0
- package/dist/capabilities/todo/injector.d.ts +9 -0
- package/dist/capabilities/todo/injector.js +68 -0
- package/dist/capabilities/todo/todo-store.d.ts +19 -0
- package/dist/capabilities/todo/todo-store.js +36 -0
- package/dist/capabilities/todo/tools.d.ts +6 -0
- package/dist/capabilities/todo/tools.js +70 -0
- package/dist/capabilities/tool-provider.d.ts +12 -0
- package/dist/capabilities/tool-provider.js +20 -0
- package/dist/capabilities/user-hooks/engine.d.ts +22 -0
- package/dist/capabilities/user-hooks/engine.js +105 -0
- package/dist/capabilities/user-hooks/index.d.ts +13 -0
- package/dist/capabilities/user-hooks/index.js +126 -0
- package/dist/capabilities/user-hooks/types.d.ts +26 -0
- package/dist/capabilities/user-hooks/types.js +19 -0
- package/dist/capabilities/workflow/index.d.ts +16 -0
- package/dist/capabilities/workflow/index.js +15 -0
- package/dist/commands/index.d.ts +31 -0
- package/dist/commands/index.js +318 -0
- package/dist/config/config-store.d.ts +29 -0
- package/dist/config/config-store.js +103 -0
- package/dist/config/file-source.d.ts +40 -0
- package/dist/config/file-source.js +78 -0
- package/dist/config/flags.d.ts +13 -0
- package/dist/config/flags.js +25 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +10 -0
- package/dist/config/merge.d.ts +5 -0
- package/dist/config/merge.js +57 -0
- package/dist/config/model-catalog.d.ts +17 -0
- package/dist/config/model-catalog.js +37 -0
- package/dist/config/paths.d.ts +31 -0
- package/dist/config/paths.js +28 -0
- package/dist/config/provider-manager.d.ts +57 -0
- package/dist/config/provider-manager.js +344 -0
- package/dist/config/resolver.d.ts +40 -0
- package/dist/config/resolver.js +52 -0
- package/dist/config/schema.d.ts +389 -0
- package/dist/config/schema.js +132 -0
- package/dist/events/events.d.ts +348 -0
- package/dist/events/events.js +146 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +5 -0
- package/dist/events/projection.d.ts +207 -0
- package/dist/events/projection.js +438 -0
- package/dist/events/publisher.d.ts +48 -0
- package/dist/events/publisher.js +404 -0
- package/dist/events/redacting-sink.d.ts +11 -0
- package/dist/events/redacting-sink.js +31 -0
- package/dist/home.d.ts +16 -0
- package/dist/home.js +20 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/internal.d.ts +33 -0
- package/dist/internal.js +29 -0
- package/dist/llm/auth.d.ts +22 -0
- package/dist/llm/auth.js +112 -0
- package/dist/llm/capability.d.ts +13 -0
- package/dist/llm/capability.js +45 -0
- package/dist/llm/define-model.d.ts +110 -0
- package/dist/llm/define-model.js +252 -0
- package/dist/llm/errors.d.ts +33 -0
- package/dist/llm/errors.js +154 -0
- package/dist/llm/index.d.ts +14 -0
- package/dist/llm/index.js +8 -0
- package/dist/llm/model.d.ts +43 -0
- package/dist/llm/model.js +9 -0
- package/dist/llm/retry.d.ts +35 -0
- package/dist/llm/retry.js +160 -0
- package/dist/llm/runtime.d.ts +25 -0
- package/dist/llm/runtime.js +38 -0
- package/dist/logging/diagnostics.d.ts +21 -0
- package/dist/logging/diagnostics.js +46 -0
- package/dist/logging/index.d.ts +11 -0
- package/dist/logging/index.js +7 -0
- package/dist/logging/logger.d.ts +25 -0
- package/dist/logging/logger.js +54 -0
- package/dist/logging/paths.d.ts +11 -0
- package/dist/logging/paths.js +20 -0
- package/dist/logging/policy.d.ts +5 -0
- package/dist/logging/policy.js +19 -0
- package/dist/logging/redact.d.ts +10 -0
- package/dist/logging/redact.js +95 -0
- package/dist/logging/sinks.d.ts +67 -0
- package/dist/logging/sinks.js +117 -0
- package/dist/loop/context.d.ts +69 -0
- package/dist/loop/context.js +129 -0
- package/dist/loop/errors.d.ts +8 -0
- package/dist/loop/errors.js +27 -0
- package/dist/loop/events.d.ts +14 -0
- package/dist/loop/events.js +2 -0
- package/dist/loop/index.d.ts +10 -0
- package/dist/loop/index.js +7 -0
- package/dist/loop/interruption.d.ts +118 -0
- package/dist/loop/interruption.js +191 -0
- package/dist/loop/run-turn.d.ts +54 -0
- package/dist/loop/run-turn.js +203 -0
- package/dist/loop/scheduler.d.ts +18 -0
- package/dist/loop/scheduler.js +71 -0
- package/dist/loop/steer.d.ts +122 -0
- package/dist/loop/steer.js +209 -0
- package/dist/loop/tool-call.d.ts +41 -0
- package/dist/loop/tool-call.js +326 -0
- package/dist/loop/turn-step.d.ts +57 -0
- package/dist/loop/turn-step.js +298 -0
- package/dist/loop/types.d.ts +217 -0
- package/dist/loop/types.js +2 -0
- package/dist/loop/usage.d.ts +6 -0
- package/dist/loop/usage.js +44 -0
- package/dist/mcp/auth-tool.d.ts +12 -0
- package/dist/mcp/auth-tool.js +92 -0
- package/dist/mcp/capability.d.ts +7 -0
- package/dist/mcp/capability.js +91 -0
- package/dist/mcp/config-loader.d.ts +28 -0
- package/dist/mcp/config-loader.js +115 -0
- package/dist/mcp/filter.d.ts +18 -0
- package/dist/mcp/filter.js +35 -0
- package/dist/mcp/index.d.ts +23 -0
- package/dist/mcp/index.js +13 -0
- package/dist/mcp/manager.d.ts +51 -0
- package/dist/mcp/manager.js +412 -0
- package/dist/mcp/mock-transport.d.ts +40 -0
- package/dist/mcp/mock-transport.js +68 -0
- package/dist/mcp/oauth/callback-server.d.ts +14 -0
- package/dist/mcp/oauth/callback-server.js +122 -0
- package/dist/mcp/oauth/index.d.ts +9 -0
- package/dist/mcp/oauth/index.js +5 -0
- package/dist/mcp/oauth/provider.d.ts +39 -0
- package/dist/mcp/oauth/provider.js +121 -0
- package/dist/mcp/oauth/service.d.ts +34 -0
- package/dist/mcp/oauth/service.js +130 -0
- package/dist/mcp/oauth/store.d.ts +40 -0
- package/dist/mcp/oauth/store.js +134 -0
- package/dist/mcp/output.d.ts +12 -0
- package/dist/mcp/output.js +110 -0
- package/dist/mcp/provider.d.ts +7 -0
- package/dist/mcp/provider.js +56 -0
- package/dist/mcp/sdk-transport.d.ts +25 -0
- package/dist/mcp/sdk-transport.js +228 -0
- package/dist/mcp/server.d.ts +77 -0
- package/dist/mcp/server.js +120 -0
- package/dist/mcp/tool-naming.d.ts +4 -0
- package/dist/mcp/tool-naming.js +26 -0
- package/dist/mcp/types.d.ts +75 -0
- package/dist/mcp/types.js +2 -0
- package/dist/net/index.d.ts +3 -0
- package/dist/net/index.js +2 -0
- package/dist/net/proxy.d.ts +16 -0
- package/dist/net/proxy.js +42 -0
- package/dist/permission/auto-approver/index.d.ts +3 -0
- package/dist/permission/auto-approver/index.js +3 -0
- package/dist/permission/auto-approver/llm-auto-approver.d.ts +53 -0
- package/dist/permission/auto-approver/llm-auto-approver.js +122 -0
- package/dist/permission/auto-approver/prompts-data.d.ts +9 -0
- package/dist/permission/auto-approver/prompts-data.js +155 -0
- package/dist/permission/auto-approver/prompts.d.ts +18 -0
- package/dist/permission/auto-approver/prompts.js +40 -0
- package/dist/permission/auto-approver/transcript.d.ts +22 -0
- package/dist/permission/auto-approver/transcript.js +75 -0
- package/dist/permission/auto-approver/xml.d.ts +5 -0
- package/dist/permission/auto-approver/xml.js +25 -0
- package/dist/permission/index.d.ts +7 -0
- package/dist/permission/index.js +5 -0
- package/dist/permission/manager.d.ts +74 -0
- package/dist/permission/manager.js +162 -0
- package/dist/permission/matches-rule.d.ts +27 -0
- package/dist/permission/matches-rule.js +54 -0
- package/dist/permission/policies.d.ts +14 -0
- package/dist/permission/policies.js +233 -0
- package/dist/permission/types.d.ts +84 -0
- package/dist/permission/types.js +2 -0
- package/dist/plugins/archive.d.ts +3 -0
- package/dist/plugins/archive.js +58 -0
- package/dist/plugins/github-resolver.d.ts +13 -0
- package/dist/plugins/github-resolver.js +20 -0
- package/dist/plugins/hooks.d.ts +28 -0
- package/dist/plugins/hooks.js +296 -0
- package/dist/plugins/index.d.ts +23 -0
- package/dist/plugins/index.js +23 -0
- package/dist/plugins/injector.d.ts +11 -0
- package/dist/plugins/injector.js +32 -0
- package/dist/plugins/manager.d.ts +37 -0
- package/dist/plugins/manager.js +330 -0
- package/dist/plugins/manifest.d.ts +9 -0
- package/dist/plugins/manifest.js +234 -0
- package/dist/plugins/marketplace.d.ts +85 -0
- package/dist/plugins/marketplace.js +205 -0
- package/dist/plugins/source.d.ts +23 -0
- package/dist/plugins/source.js +87 -0
- package/dist/plugins/store.d.ts +20 -0
- package/dist/plugins/store.js +30 -0
- package/dist/plugins/types.d.ts +118 -0
- package/dist/plugins/types.js +5 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +2 -0
- package/dist/protocol/tool-schema.d.ts +6 -0
- package/dist/protocol/tool-schema.js +2 -0
- package/dist/store/blob-store.d.ts +45 -0
- package/dist/store/blob-store.js +120 -0
- package/dist/store/catalog-store.d.ts +32 -0
- package/dist/store/catalog-store.js +73 -0
- package/dist/store/disk-store.d.ts +58 -0
- package/dist/store/disk-store.js +369 -0
- package/dist/store/index.d.ts +23 -0
- package/dist/store/index.js +15 -0
- package/dist/store/lock.d.ts +86 -0
- package/dist/store/lock.js +104 -0
- package/dist/store/log-store.d.ts +89 -0
- package/dist/store/log-store.js +296 -0
- package/dist/store/migrate.d.ts +26 -0
- package/dist/store/migrate.js +32 -0
- package/dist/store/origin.d.ts +89 -0
- package/dist/store/origin.js +16 -0
- package/dist/store/pg.d.ts +90 -0
- package/dist/store/pg.js +344 -0
- package/dist/store/redacting-store.d.ts +21 -0
- package/dist/store/redacting-store.js +46 -0
- package/dist/store/redis.d.ts +89 -0
- package/dist/store/redis.js +370 -0
- package/dist/store/repository.d.ts +150 -0
- package/dist/store/repository.js +508 -0
- package/dist/store/session-catalog.d.ts +32 -0
- package/dist/store/session-catalog.js +117 -0
- package/dist/store/storage.d.ts +27 -0
- package/dist/store/storage.js +54 -0
- package/dist/store/store.d.ts +262 -0
- package/dist/store/store.js +129 -0
- package/dist/store/workdir-key.d.ts +4 -0
- package/dist/store/workdir-key.js +28 -0
- package/dist/tool/access.d.ts +37 -0
- package/dist/tool/access.js +79 -0
- package/dist/tool/ask.d.ts +22 -0
- package/dist/tool/ask.js +38 -0
- package/dist/tool/background.d.ts +109 -0
- package/dist/tool/background.js +39 -0
- package/dist/tool/builtin/ask-user-question.d.ts +2 -0
- package/dist/tool/builtin/ask-user-question.js +175 -0
- package/dist/tool/builtin/bash.d.ts +2 -0
- package/dist/tool/builtin/bash.js +407 -0
- package/dist/tool/builtin/edit.d.ts +2 -0
- package/dist/tool/builtin/edit.js +202 -0
- package/dist/tool/builtin/glob.d.ts +3 -0
- package/dist/tool/builtin/glob.js +260 -0
- package/dist/tool/builtin/grep.d.ts +2 -0
- package/dist/tool/builtin/grep.js +574 -0
- package/dist/tool/builtin/line-endings.d.ts +10 -0
- package/dist/tool/builtin/line-endings.js +41 -0
- package/dist/tool/builtin/read.d.ts +28 -0
- package/dist/tool/builtin/read.js +498 -0
- package/dist/tool/builtin/write.d.ts +2 -0
- package/dist/tool/builtin/write.js +179 -0
- package/dist/tool/define.d.ts +46 -0
- package/dist/tool/define.js +45 -0
- package/dist/tool/file-freshness.d.ts +81 -0
- package/dist/tool/file-freshness.js +67 -0
- package/dist/tool/filesystem-tools.d.ts +16 -0
- package/dist/tool/filesystem-tools.js +19 -0
- package/dist/tool/git-context.d.ts +20 -0
- package/dist/tool/git-context.js +114 -0
- package/dist/tool/index.d.ts +37 -0
- package/dist/tool/index.js +34 -0
- package/dist/tool/machine-base.d.ts +138 -0
- package/dist/tool/machine-base.js +388 -0
- package/dist/tool/machine-local.d.ts +35 -0
- package/dist/tool/machine-local.js +316 -0
- package/dist/tool/machine-null.d.ts +36 -0
- package/dist/tool/machine-null.js +64 -0
- package/dist/tool/machine-ssh.d.ts +86 -0
- package/dist/tool/machine-ssh.js +576 -0
- package/dist/tool/machine.d.ts +333 -0
- package/dist/tool/machine.js +15 -0
- package/dist/tool/policies/path-access.d.ts +48 -0
- package/dist/tool/policies/path-access.js +186 -0
- package/dist/tool/policies/sensitive.d.ts +3 -0
- package/dist/tool/policies/sensitive.js +60 -0
- package/dist/tool/questions.d.ts +40 -0
- package/dist/tool/questions.js +8 -0
- package/dist/tool/search/activation.d.ts +13 -0
- package/dist/tool/search/activation.js +31 -0
- package/dist/tool/search/deferral.d.ts +37 -0
- package/dist/tool/search/deferral.js +128 -0
- package/dist/tool/search/search-tool.d.ts +9 -0
- package/dist/tool/search/search-tool.js +62 -0
- package/dist/tool/shell-env.d.ts +9 -0
- package/dist/tool/shell-env.js +34 -0
- package/dist/tool/support/bash-destructive.d.ts +24 -0
- package/dist/tool/support/bash-destructive.js +63 -0
- package/dist/tool/support/bash-paths.d.ts +7 -0
- package/dist/tool/support/bash-paths.js +247 -0
- package/dist/tool/support/bash-read-only.d.ts +8 -0
- package/dist/tool/support/bash-read-only.js +165 -0
- package/dist/tool/support/bash-rule-match.d.ts +20 -0
- package/dist/tool/support/bash-rule-match.js +191 -0
- package/dist/tool/support/file-type.d.ts +10 -0
- package/dist/tool/support/file-type.js +149 -0
- package/dist/tool/support/git-worktree.d.ts +10 -0
- package/dist/tool/support/git-worktree.js +63 -0
- package/dist/tool/support/image-compress.d.ts +69 -0
- package/dist/tool/support/image-compress.js +265 -0
- package/dist/tool/support/machine-ops.d.ts +34 -0
- package/dist/tool/support/machine-ops.js +34 -0
- package/dist/tool/support/path-glob-match.d.ts +12 -0
- package/dist/tool/support/path-glob-match.js +84 -0
- package/dist/tool/support/result-builder.d.ts +27 -0
- package/dist/tool/support/result-builder.js +108 -0
- package/dist/tool/support/rg-locator.d.ts +20 -0
- package/dist/tool/support/rg-locator.js +42 -0
- package/dist/tool/support/ripgrep-run.d.ts +65 -0
- package/dist/tool/support/ripgrep-run.js +40 -0
- package/dist/tool/support/rule-match.d.ts +6 -0
- package/dist/tool/support/rule-match.js +23 -0
- package/dist/tool/support/tool-path.d.ts +8 -0
- package/dist/tool/support/tool-path.js +28 -0
- package/dist/tool/support/workspace.d.ts +5 -0
- package/dist/tool/support/workspace.js +2 -0
- package/dist/tool/types.d.ts +131 -0
- package/dist/tool/types.js +2 -0
- package/dist/tool/web/fetch-url.d.ts +4 -0
- package/dist/tool/web/fetch-url.js +61 -0
- package/dist/tool/web/index.d.ts +11 -0
- package/dist/tool/web/index.js +7 -0
- package/dist/tool/web/providers/direct-fetch.d.ts +33 -0
- package/dist/tool/web/providers/direct-fetch.js +198 -0
- package/dist/tool/web/providers/firecrawl.d.ts +16 -0
- package/dist/tool/web/providers/firecrawl.js +59 -0
- package/dist/tool/web/providers/tavily.d.ts +14 -0
- package/dist/tool/web/providers/tavily.js +43 -0
- package/dist/tool/web/types.d.ts +41 -0
- package/dist/tool/web/types.js +7 -0
- package/dist/tool/web/web-search.d.ts +4 -0
- package/dist/tool/web/web-search.js +68 -0
- package/dist/tool/workspace-spec.d.ts +74 -0
- package/dist/tool/workspace-spec.js +177 -0
- package/dist/tracing/bridge.d.ts +7 -0
- package/dist/tracing/bridge.js +171 -0
- package/dist/tracing/index.d.ts +9 -0
- package/dist/tracing/index.js +5 -0
- package/dist/tracing/otel.d.ts +38 -0
- package/dist/tracing/otel.js +221 -0
- package/dist/tracing/processor.d.ts +47 -0
- package/dist/tracing/processor.js +94 -0
- package/dist/tracing/spans.d.ts +94 -0
- package/dist/tracing/spans.js +56 -0
- package/dist/ui/ai-sdk.d.ts +114 -0
- package/dist/ui/ai-sdk.js +175 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +101 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../../tool/define.js";
|
|
3
|
+
import { ToolAccesses } from "../../tool/access.js";
|
|
4
|
+
import { matchesGlobRuleSubject } from "../../tool/support/rule-match.js";
|
|
5
|
+
export function flowSkillToolName(skillName) {
|
|
6
|
+
const suffix = skillName.replace(/[^a-zA-Z0-9_-]+/g, "_").toLowerCase() || "skill";
|
|
7
|
+
return `skill_${suffix}`;
|
|
8
|
+
}
|
|
9
|
+
function flowSkillTool(skill, registry, executor) {
|
|
10
|
+
const toolName = flowSkillToolName(skill.name);
|
|
11
|
+
return defineTool({
|
|
12
|
+
name: toolName,
|
|
13
|
+
description: `${skill.description}${typeof skill.metadata.whenToUse === "string" && skill.metadata.whenToUse.length > 0
|
|
14
|
+
? ` When to use: ${skill.metadata.whenToUse}`
|
|
15
|
+
: ""} Runs the "${skill.name}" flow skill as a sub-agent and returns its result.`,
|
|
16
|
+
params: z.object({
|
|
17
|
+
input: z.string().describe(`The task / arguments for the "${skill.name}" flow skill.`),
|
|
18
|
+
}),
|
|
19
|
+
resolve: (args) => ({
|
|
20
|
+
approvalRule: toolName,
|
|
21
|
+
matchesRule: (ruleArgs) => matchesGlobRuleSubject(ruleArgs, skill.name),
|
|
22
|
+
accesses: ToolAccesses.all(),
|
|
23
|
+
controlFlow: true,
|
|
24
|
+
display: { kind: "skill_call", title: `Flow skill: ${skill.name}`, detail: args.input },
|
|
25
|
+
run: async (ctx) => {
|
|
26
|
+
if (executor === undefined) {
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `Flow skill "${skill.name}" cannot run here: no FlowSkillExecutor is wired. Provide one in skillsCapability({ flowExecutor }) to run flow skills as sub-agents.`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
isError: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const instructions = registry.renderSkillPrompt(skill, "");
|
|
38
|
+
const output = await executor({ skill, instructions, input: args.input, signal: ctx.signal });
|
|
39
|
+
return { content: [{ type: "text", text: output }], details: { skill: skill.name, source: skill.source } };
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function flowSkillProvider(registry, executor) {
|
|
45
|
+
return {
|
|
46
|
+
id: "skill-flow",
|
|
47
|
+
listTools: () => registry.listFlowSkills().map((skill) => flowSkillTool(skill, registry, executor)),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=flow-provider.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Capability } from "../capability.ts";
|
|
2
|
+
import { SkillRegistry } from "./registry.ts";
|
|
3
|
+
import type { FlowSkillExecutor, SkillDefinition, SkillRoot } from "./types.ts";
|
|
4
|
+
export type { SkillRegistryOptions } from "./registry.ts";
|
|
5
|
+
export { SkillRegistry, SkillNotFoundError } from "./registry.ts";
|
|
6
|
+
export { parseSkillText, parseSkillFromMachine, parseFrontmatter, expandSkillParameters, skillArgumentNames, SkillParseError, FrontmatterError, UnsupportedSkillTypeError, } from "./parser.ts";
|
|
7
|
+
export { discoverSkills, resolveSkillRoots } from "./scanner.ts";
|
|
8
|
+
export type { ResolveSkillRootsOptions, DiscoverSkillsOptions } from "./scanner.ts";
|
|
9
|
+
export { skillTool, MAX_SKILL_QUERY_DEPTH, NestedSkillTooDeepError } from "./skill-tool.ts";
|
|
10
|
+
export { flowSkillProvider, flowSkillToolName } from "./flow-provider.ts";
|
|
11
|
+
export { SkillCatalogInjector } from "./injector.ts";
|
|
12
|
+
export { SkillsService, UnsupportedSkillActivationError } from "./service.ts";
|
|
13
|
+
export type { ActivateSkillRequest, SkillActivationResult, SkillActivationTrigger } from "./service.ts";
|
|
14
|
+
export { normalizeSkillName, isInlineSkillType, isFlowSkillType, isUserActivatableSkillType, isSupportedSkillType, summarizeSkill, } from "./types.ts";
|
|
15
|
+
export type { SkillCatalog, SkillDefinition, SkillMetadata, SkillSource, SkillSummary, SkillRoot, SkillPluginContext, SkippedSkill, FlowSkillExecutor, FlowSkillRequest, } from "./types.ts";
|
|
16
|
+
export interface SkillsOptions {
|
|
17
|
+
readonly registry?: SkillRegistry;
|
|
18
|
+
readonly roots?: readonly SkillRoot[];
|
|
19
|
+
/**
|
|
20
|
+
* Additional skill roots resolved lazily at session-open (merged after `roots`). Use this for
|
|
21
|
+
* roots that aren't known at construction or change over time — e.g. installed plugins'
|
|
22
|
+
* skill dirs, whose owning manager loads on its own schedule. The provider should ensure its
|
|
23
|
+
* source is ready (await any load) and return an empty array when there's nothing to add.
|
|
24
|
+
*/
|
|
25
|
+
readonly dynamicRoots?: () => readonly SkillRoot[] | Promise<readonly SkillRoot[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Treat `roots`/`dynamicRoots` as ADDITIONS to the default `<projectDir>/.agents/skills` and
|
|
28
|
+
* `~/.agents/skills` roots instead of a replacement for them. Hosts that hand over plugin skill
|
|
29
|
+
* dirs want this — without it, installing one skill-bearing plugin silently hides every
|
|
30
|
+
* project- and user-level skill. Off by default so tests and fully-controlled hosts keep
|
|
31
|
+
* scanning exactly the roots they pass.
|
|
32
|
+
*/
|
|
33
|
+
readonly includeDefaultRoots?: boolean;
|
|
34
|
+
readonly projectDir?: string;
|
|
35
|
+
readonly userHomeDir?: string;
|
|
36
|
+
readonly builtinDir?: string;
|
|
37
|
+
readonly extraDirs?: readonly string[];
|
|
38
|
+
readonly builtinSkills?: readonly SkillDefinition[];
|
|
39
|
+
readonly flowExecutor?: FlowSkillExecutor;
|
|
40
|
+
readonly onWarning?: (message: string, cause?: unknown) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare function skillsCapability(options?: SkillsOptions): Capability;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SkillRegistry } from "./registry.js";
|
|
2
|
+
import { resolveSkillRoots } from "./scanner.js";
|
|
3
|
+
import { skillTool } from "./skill-tool.js";
|
|
4
|
+
import { flowSkillProvider } from "./flow-provider.js";
|
|
5
|
+
import { SkillCatalogInjector } from "./injector.js";
|
|
6
|
+
import { SkillsService } from "./service.js";
|
|
7
|
+
export { SkillRegistry, SkillNotFoundError } from "./registry.js";
|
|
8
|
+
export { parseSkillText, parseSkillFromMachine, parseFrontmatter, expandSkillParameters, skillArgumentNames, SkillParseError, FrontmatterError, UnsupportedSkillTypeError, } from "./parser.js";
|
|
9
|
+
export { discoverSkills, resolveSkillRoots } from "./scanner.js";
|
|
10
|
+
export { skillTool, MAX_SKILL_QUERY_DEPTH, NestedSkillTooDeepError } from "./skill-tool.js";
|
|
11
|
+
export { flowSkillProvider, flowSkillToolName } from "./flow-provider.js";
|
|
12
|
+
export { SkillCatalogInjector } from "./injector.js";
|
|
13
|
+
export { SkillsService, UnsupportedSkillActivationError } from "./service.js";
|
|
14
|
+
export { normalizeSkillName, isInlineSkillType, isFlowSkillType, isUserActivatableSkillType, isSupportedSkillType, summarizeSkill, } from "./types.js";
|
|
15
|
+
export function skillsCapability(options = {}) {
|
|
16
|
+
const registry = options.registry ?? new SkillRegistry({ onWarning: options.onWarning });
|
|
17
|
+
const service = new SkillsService(registry);
|
|
18
|
+
return {
|
|
19
|
+
name: "skills",
|
|
20
|
+
tools: [skillTool(registry)],
|
|
21
|
+
toolProviders: [flowSkillProvider(registry, options.flowExecutor)],
|
|
22
|
+
injectors: [new SkillCatalogInjector(registry)],
|
|
23
|
+
service,
|
|
24
|
+
openSession: async (ctx) => {
|
|
25
|
+
registry.setSessionId(ctx.sessionId);
|
|
26
|
+
for (const skill of options.builtinSkills ?? [])
|
|
27
|
+
registry.registerBuiltinSkill(skill);
|
|
28
|
+
// Static roots + any lazily-provided ones (e.g. enabled plugins' skill dirs). The provider
|
|
29
|
+
// runs per session-open so it reflects the current set even though the harness is shared.
|
|
30
|
+
const dynamic = options.dynamicRoots ? await options.dynamicRoots() : [];
|
|
31
|
+
const explicitRoots = [...(options.roots ?? []), ...dynamic];
|
|
32
|
+
const roots = await resolveSkillRoots(ctx.machine, {
|
|
33
|
+
...(explicitRoots.length > 0 ? { explicitRoots } : {}),
|
|
34
|
+
...(options.includeDefaultRoots === true ? { includeDefaults: true } : {}),
|
|
35
|
+
// Default the project root to the session's working directory so
|
|
36
|
+
// `<cwd>/.agents/skills` is scanned per-session (the harness is shared,
|
|
37
|
+
// so this can't be a static option).
|
|
38
|
+
projectDir: options.projectDir ?? ctx.machine.getcwd(),
|
|
39
|
+
...(options.userHomeDir !== undefined ? { userHomeDir: options.userHomeDir } : {}),
|
|
40
|
+
...(options.builtinDir !== undefined ? { builtinDir: options.builtinDir } : {}),
|
|
41
|
+
...(options.extraDirs !== undefined ? { extraDirs: options.extraDirs } : {}),
|
|
42
|
+
});
|
|
43
|
+
await registry.loadRoots(ctx.machine, roots);
|
|
44
|
+
service.attach({ sessionId: ctx.sessionId, events: ctx.events, steer: ctx.steer });
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BoundaryInjector, type InjectionContext, type InjectionResult } from "../injection.ts";
|
|
2
|
+
import type { SkillRegistry } from "./registry.ts";
|
|
3
|
+
export declare class SkillCatalogInjector extends BoundaryInjector {
|
|
4
|
+
readonly id = "skill_catalog";
|
|
5
|
+
private readonly registry;
|
|
6
|
+
private stale;
|
|
7
|
+
constructor(registry: SkillRegistry);
|
|
8
|
+
markStale(): void;
|
|
9
|
+
protected getInjection(ctx: InjectionContext): InjectionResult | null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=injector.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BoundaryInjector } from "../injection.js";
|
|
2
|
+
export class SkillCatalogInjector extends BoundaryInjector {
|
|
3
|
+
id = "skill_catalog";
|
|
4
|
+
registry;
|
|
5
|
+
stale = false;
|
|
6
|
+
constructor(registry) {
|
|
7
|
+
super();
|
|
8
|
+
this.registry = registry;
|
|
9
|
+
}
|
|
10
|
+
markStale() {
|
|
11
|
+
this.injectedAt = null;
|
|
12
|
+
this.stale = true;
|
|
13
|
+
}
|
|
14
|
+
getInjection(ctx) {
|
|
15
|
+
if (!this.stale && this.restoreInjectedAt(ctx, ["catalog"]))
|
|
16
|
+
return null;
|
|
17
|
+
this.stale = false;
|
|
18
|
+
const listing = this.registry.getModelSkillListing();
|
|
19
|
+
if (listing.trim().length === 0)
|
|
20
|
+
return null;
|
|
21
|
+
const text = "Available skills — load one with the Skill tool (inline) or call its skill_<name> tool (flow) " +
|
|
22
|
+
"when its description / when-to-use matches the task:\n\n" +
|
|
23
|
+
listing;
|
|
24
|
+
return { text, variant: "catalog" };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=injector.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Machine } from "../../tool/machine.ts";
|
|
2
|
+
import type { SkillDefinition, SkillMetadata, SkillSource } from "./types.ts";
|
|
3
|
+
export declare class FrontmatterError extends Error {
|
|
4
|
+
constructor(message: string, cause?: unknown);
|
|
5
|
+
}
|
|
6
|
+
export declare class SkillParseError extends Error {
|
|
7
|
+
readonly reason?: unknown;
|
|
8
|
+
constructor(message: string, cause?: unknown);
|
|
9
|
+
}
|
|
10
|
+
export declare class UnsupportedSkillTypeError extends Error {
|
|
11
|
+
readonly skillType: string;
|
|
12
|
+
constructor(skillType: string);
|
|
13
|
+
}
|
|
14
|
+
export interface ParseSkillOptions {
|
|
15
|
+
readonly skillMdPath: string;
|
|
16
|
+
readonly skillDirName: string;
|
|
17
|
+
readonly source: SkillSource;
|
|
18
|
+
}
|
|
19
|
+
export interface ParseSkillTextOptions extends ParseSkillOptions {
|
|
20
|
+
readonly text: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SkillExpandContext {
|
|
23
|
+
readonly skillDir: string;
|
|
24
|
+
readonly sessionId?: string;
|
|
25
|
+
readonly argumentNames?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export interface ParsedFrontmatter {
|
|
28
|
+
readonly data: Record<string, unknown> | null;
|
|
29
|
+
readonly body: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function parseSkillFromMachine(machine: Machine, options: ParseSkillOptions): Promise<SkillDefinition>;
|
|
32
|
+
export declare function parseFrontmatter(text: string): ParsedFrontmatter;
|
|
33
|
+
export declare function parseSkillText(options: ParseSkillTextOptions): SkillDefinition;
|
|
34
|
+
export declare function expandSkillParameters(body: string, rawArgs: string, context: SkillExpandContext): string;
|
|
35
|
+
export declare function skillArgumentNames(metadata: SkillMetadata): readonly string[];
|
|
36
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import path from "pathe";
|
|
2
|
+
import { isSupportedSkillType } from "./types.js";
|
|
3
|
+
import { readTextFile } from "../../tool/support/machine-ops.js";
|
|
4
|
+
export class FrontmatterError extends Error {
|
|
5
|
+
constructor(message, cause) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "FrontmatterError";
|
|
8
|
+
if (cause !== undefined)
|
|
9
|
+
Object.defineProperty(this, "cause", { value: cause, configurable: true });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class SkillParseError extends Error {
|
|
13
|
+
reason;
|
|
14
|
+
constructor(message, cause) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "SkillParseError";
|
|
17
|
+
if (cause !== undefined)
|
|
18
|
+
this.reason = cause;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class UnsupportedSkillTypeError extends Error {
|
|
22
|
+
skillType;
|
|
23
|
+
constructor(skillType) {
|
|
24
|
+
super(`Skill type "${skillType}" is not supported; only "prompt", "inline", and "flow" are supported.`);
|
|
25
|
+
this.name = "UnsupportedSkillTypeError";
|
|
26
|
+
this.skillType = skillType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const FENCE = "---";
|
|
30
|
+
const METADATA_ALIASES = {
|
|
31
|
+
"when-to-use": "whenToUse",
|
|
32
|
+
when_to_use: "whenToUse",
|
|
33
|
+
"disable-model-invocation": "disableModelInvocation",
|
|
34
|
+
disable_model_invocation: "disableModelInvocation",
|
|
35
|
+
};
|
|
36
|
+
export async function parseSkillFromMachine(machine, options) {
|
|
37
|
+
let text;
|
|
38
|
+
try {
|
|
39
|
+
text = await readTextFile(machine, options.skillMdPath);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new SkillParseError(`Failed to read ${options.skillMdPath}`, error);
|
|
43
|
+
}
|
|
44
|
+
return parseSkillText({ ...options, text });
|
|
45
|
+
}
|
|
46
|
+
export function parseFrontmatter(text) {
|
|
47
|
+
const lines = text.split(/\r?\n/);
|
|
48
|
+
if (lines[0]?.trim() !== FENCE)
|
|
49
|
+
return { data: null, body: text };
|
|
50
|
+
const close = lines.findIndex((line, index) => index > 0 && line.trim() === FENCE);
|
|
51
|
+
if (close === -1)
|
|
52
|
+
throw new FrontmatterError("Missing closing frontmatter fence");
|
|
53
|
+
const yamlLines = lines.slice(1, close);
|
|
54
|
+
const body = lines.slice(close + 1).join("\n");
|
|
55
|
+
if (yamlLines.join("").trim() === "")
|
|
56
|
+
return { data: {}, body };
|
|
57
|
+
try {
|
|
58
|
+
return { data: parseFrontmatterBlock(yamlLines), body };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
throw new FrontmatterError(message, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function parseSkillText(options) {
|
|
66
|
+
const isDirectorySkill = path.basename(options.skillMdPath) === "SKILL.md";
|
|
67
|
+
if (isDirectorySkill && options.text.split(/\r?\n/, 1)[0]?.trim() !== FENCE) {
|
|
68
|
+
throw new SkillParseError(`Missing frontmatter in ${options.skillMdPath}`);
|
|
69
|
+
}
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
parsed = parseFrontmatter(options.text);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof FrontmatterError) {
|
|
76
|
+
throw new SkillParseError(`Invalid frontmatter in ${options.skillMdPath}: ${error.message}`, error);
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
const frontmatter = parsed.data ?? {};
|
|
81
|
+
const metadata = normalizeMetadata(frontmatter);
|
|
82
|
+
if (!isSupportedSkillType(metadata.type)) {
|
|
83
|
+
throw new UnsupportedSkillTypeError(metadata.type ?? String(frontmatter["type"]));
|
|
84
|
+
}
|
|
85
|
+
const name = nonEmptyString(metadata.name);
|
|
86
|
+
const description = nonEmptyString(metadata.description);
|
|
87
|
+
if (isDirectorySkill && (name === undefined || description === undefined)) {
|
|
88
|
+
const field = name === undefined ? '"name"' : '"description"';
|
|
89
|
+
throw new SkillParseError(`Missing required frontmatter field ${field} in ${options.skillMdPath}`);
|
|
90
|
+
}
|
|
91
|
+
const skillPath = path.resolve(options.skillMdPath);
|
|
92
|
+
const content = parsed.body.trim();
|
|
93
|
+
return {
|
|
94
|
+
name: name ?? options.skillDirName,
|
|
95
|
+
description: description ?? descriptionFromBody(content),
|
|
96
|
+
path: skillPath,
|
|
97
|
+
dir: path.dirname(skillPath),
|
|
98
|
+
content,
|
|
99
|
+
metadata,
|
|
100
|
+
source: options.source,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function expandSkillParameters(body, rawArgs, context) {
|
|
104
|
+
const tokens = tokenizeArgs(rawArgs);
|
|
105
|
+
let content = body;
|
|
106
|
+
for (let index = 0; index < (context.argumentNames?.length ?? 0); index++) {
|
|
107
|
+
const argName = context.argumentNames?.[index];
|
|
108
|
+
if (argName === undefined)
|
|
109
|
+
continue;
|
|
110
|
+
const escaped = escapeRegExp(argName);
|
|
111
|
+
content = content.replaceAll(new RegExp(`\\$${escaped}(?![\\[\\w])`, "g"), escapeXmlTags(tokens[index] ?? ""));
|
|
112
|
+
}
|
|
113
|
+
content = content
|
|
114
|
+
.replaceAll(/\$ARGUMENTS\[(\d+)\]/g, (_m, idx) => escapeXmlTags(tokens[Number.parseInt(idx, 10)] ?? ""))
|
|
115
|
+
.replaceAll(/\$(\d+)(?!\w)/g, (_m, idx) => escapeXmlTags(tokens[Number.parseInt(idx, 10)] ?? ""))
|
|
116
|
+
.replaceAll("$ARGUMENTS", escapeXmlTags(rawArgs));
|
|
117
|
+
const hasPlaceholder = content !== body;
|
|
118
|
+
content = content
|
|
119
|
+
.replaceAll("${SKILL_DIR}", context.skillDir)
|
|
120
|
+
.replaceAll("${SESSION_ID}", context.sessionId ?? "");
|
|
121
|
+
if (!hasPlaceholder && rawArgs.length > 0)
|
|
122
|
+
return `${content}\n\nARGUMENTS: ${escapeXmlTags(rawArgs)}`;
|
|
123
|
+
return content;
|
|
124
|
+
}
|
|
125
|
+
export function skillArgumentNames(metadata) {
|
|
126
|
+
const value = metadata.arguments;
|
|
127
|
+
const isValidName = (name) => name.trim() !== "" && !/^\d+$/.test(name);
|
|
128
|
+
if (typeof value === "string")
|
|
129
|
+
return value.split(/\s+/).filter(isValidName);
|
|
130
|
+
if (!Array.isArray(value))
|
|
131
|
+
return [];
|
|
132
|
+
return value.filter((item) => typeof item === "string" && isValidName(item));
|
|
133
|
+
}
|
|
134
|
+
function parseFrontmatterBlock(lines) {
|
|
135
|
+
const out = {};
|
|
136
|
+
let i = 0;
|
|
137
|
+
while (i < lines.length) {
|
|
138
|
+
const raw = lines[i] ?? "";
|
|
139
|
+
const line = stripComment(raw);
|
|
140
|
+
if (line.trim() === "" || /^\s/.test(raw)) {
|
|
141
|
+
i += 1; // blank, comment, or a stray indented line with no owning key
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const match = /^([A-Za-z0-9_-]+):(.*)$/.exec(line);
|
|
145
|
+
if (match === null) {
|
|
146
|
+
i += 1;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const key = match[1];
|
|
150
|
+
const inline = (match[2] ?? "").trim();
|
|
151
|
+
if (inline === "|" || inline === ">" || /^[|>][+-]?$/.test(inline)) {
|
|
152
|
+
const { text, next } = collectBlockScalar(lines, i + 1, inline.startsWith(">"));
|
|
153
|
+
out[key] = text;
|
|
154
|
+
i = next;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (inline === "") {
|
|
158
|
+
const { value, next } = collectBlock(lines, i + 1);
|
|
159
|
+
out[key] = value;
|
|
160
|
+
i = next;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
out[key] = parseScalar(inline);
|
|
164
|
+
i += 1;
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function collectBlock(lines, start) {
|
|
169
|
+
const items = [];
|
|
170
|
+
let i = start;
|
|
171
|
+
for (; i < lines.length; i++) {
|
|
172
|
+
const raw = lines[i] ?? "";
|
|
173
|
+
if (raw.trim() === "")
|
|
174
|
+
continue;
|
|
175
|
+
if (!/^\s/.test(raw))
|
|
176
|
+
break; // dedent → block ended
|
|
177
|
+
const listMatch = /^\s*-\s*(.*)$/.exec(raw);
|
|
178
|
+
if (listMatch === null)
|
|
179
|
+
break; // not a list item (nested map etc.) — leave uninterpreted
|
|
180
|
+
items.push(parseScalar((listMatch[1] ?? "").trim()));
|
|
181
|
+
}
|
|
182
|
+
return { value: items, next: i };
|
|
183
|
+
}
|
|
184
|
+
function collectBlockScalar(lines, start, folded) {
|
|
185
|
+
const body = [];
|
|
186
|
+
let indent = null;
|
|
187
|
+
let i = start;
|
|
188
|
+
for (; i < lines.length; i++) {
|
|
189
|
+
const raw = lines[i] ?? "";
|
|
190
|
+
if (raw.trim() === "") {
|
|
191
|
+
body.push("");
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const lead = raw.length - raw.trimStart().length;
|
|
195
|
+
if (lead === 0)
|
|
196
|
+
break; // dedent to column 0 → block ended
|
|
197
|
+
if (indent === null)
|
|
198
|
+
indent = lead;
|
|
199
|
+
body.push(raw.slice(Math.min(indent, lead)));
|
|
200
|
+
}
|
|
201
|
+
while (body.length > 0 && body[body.length - 1] === "")
|
|
202
|
+
body.pop();
|
|
203
|
+
const text = folded ? body.join(" ").replace(/\s+/g, " ").trim() : body.join("\n");
|
|
204
|
+
return { text, next: i };
|
|
205
|
+
}
|
|
206
|
+
function parseScalar(value) {
|
|
207
|
+
if (value === "")
|
|
208
|
+
return "";
|
|
209
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
210
|
+
return value.slice(1, -1);
|
|
211
|
+
}
|
|
212
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
213
|
+
const inner = value.slice(1, -1).trim();
|
|
214
|
+
if (inner === "")
|
|
215
|
+
return [];
|
|
216
|
+
return splitTopLevelCommas(inner).map((item) => parseScalar(item.trim()));
|
|
217
|
+
}
|
|
218
|
+
if (value === "true")
|
|
219
|
+
return true;
|
|
220
|
+
if (value === "false")
|
|
221
|
+
return false;
|
|
222
|
+
if (value === "null" || value === "~")
|
|
223
|
+
return null;
|
|
224
|
+
if (/^-?\d+$/.test(value))
|
|
225
|
+
return Number.parseInt(value, 10);
|
|
226
|
+
if (/^-?\d*\.\d+$/.test(value))
|
|
227
|
+
return Number.parseFloat(value);
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
function splitTopLevelCommas(text) {
|
|
231
|
+
const out = [];
|
|
232
|
+
let current = "";
|
|
233
|
+
let quote;
|
|
234
|
+
for (const char of text) {
|
|
235
|
+
if (quote !== undefined) {
|
|
236
|
+
if (char === quote)
|
|
237
|
+
quote = undefined;
|
|
238
|
+
current += char;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (char === '"' || char === "'") {
|
|
242
|
+
quote = char;
|
|
243
|
+
current += char;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (char === ",") {
|
|
247
|
+
out.push(current);
|
|
248
|
+
current = "";
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
current += char;
|
|
252
|
+
}
|
|
253
|
+
if (current.trim() !== "")
|
|
254
|
+
out.push(current);
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
257
|
+
function stripComment(line) {
|
|
258
|
+
// A `#` only starts a comment when preceded by whitespace or at line start (not inside a URL/value).
|
|
259
|
+
const match = /(^|\s)#.*$/.exec(line);
|
|
260
|
+
if (match === null)
|
|
261
|
+
return line;
|
|
262
|
+
// Don't strip when the `#` is inside a quoted scalar.
|
|
263
|
+
const before = line.slice(0, match.index);
|
|
264
|
+
const quotes = (before.match(/["']/g) ?? []).length;
|
|
265
|
+
if (quotes % 2 === 1)
|
|
266
|
+
return line;
|
|
267
|
+
return before;
|
|
268
|
+
}
|
|
269
|
+
function normalizeMetadata(raw) {
|
|
270
|
+
const out = {};
|
|
271
|
+
for (const [rawKey, value] of Object.entries(raw)) {
|
|
272
|
+
out[METADATA_ALIASES[rawKey] ?? rawKey] = value;
|
|
273
|
+
}
|
|
274
|
+
for (const field of ["type", "name", "description", "whenToUse"]) {
|
|
275
|
+
const normalized = nonEmptyString(out[field]);
|
|
276
|
+
if (normalized !== undefined)
|
|
277
|
+
out[field] = normalized;
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
}
|
|
281
|
+
function descriptionFromBody(body) {
|
|
282
|
+
const firstLine = body
|
|
283
|
+
.split(/\r?\n/)
|
|
284
|
+
.map((line) => line.trim())
|
|
285
|
+
.find((line) => line.length > 0);
|
|
286
|
+
if (firstLine === undefined)
|
|
287
|
+
return "No description provided.";
|
|
288
|
+
return firstLine.length > 240 ? `${firstLine.slice(0, 239)}…` : firstLine;
|
|
289
|
+
}
|
|
290
|
+
function tokenizeArgs(raw) {
|
|
291
|
+
const out = [];
|
|
292
|
+
let current = "";
|
|
293
|
+
let quote;
|
|
294
|
+
let hasContent = false;
|
|
295
|
+
for (const char of raw) {
|
|
296
|
+
if (quote !== undefined) {
|
|
297
|
+
if (char === quote)
|
|
298
|
+
quote = undefined;
|
|
299
|
+
else {
|
|
300
|
+
current += char;
|
|
301
|
+
hasContent = true;
|
|
302
|
+
}
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (char === '"' || char === "'") {
|
|
306
|
+
quote = char;
|
|
307
|
+
hasContent = true;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (/\s/.test(char)) {
|
|
311
|
+
if (hasContent) {
|
|
312
|
+
out.push(current);
|
|
313
|
+
current = "";
|
|
314
|
+
hasContent = false;
|
|
315
|
+
}
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
current += char;
|
|
319
|
+
hasContent = true;
|
|
320
|
+
}
|
|
321
|
+
if (hasContent)
|
|
322
|
+
out.push(current);
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
function nonEmptyString(value) {
|
|
326
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
327
|
+
}
|
|
328
|
+
function escapeXmlTags(text) {
|
|
329
|
+
return text.replaceAll("<", "<").replaceAll(">", ">");
|
|
330
|
+
}
|
|
331
|
+
function escapeRegExp(text) {
|
|
332
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Machine } from "../../tool/machine.ts";
|
|
2
|
+
import type { SkillCatalog, SkillDefinition, SkillRoot, SkippedSkill } from "./types.ts";
|
|
3
|
+
export declare class SkillNotFoundError extends Error {
|
|
4
|
+
readonly skillName: string;
|
|
5
|
+
constructor(skillName: string);
|
|
6
|
+
}
|
|
7
|
+
export interface SkillRegistryOptions {
|
|
8
|
+
readonly onWarning?: (message: string, cause?: unknown) => void;
|
|
9
|
+
readonly sessionId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class SkillRegistry implements SkillCatalog {
|
|
12
|
+
private readonly byName;
|
|
13
|
+
private readonly roots;
|
|
14
|
+
private readonly skipped;
|
|
15
|
+
private readonly onWarning;
|
|
16
|
+
private sessionId?;
|
|
17
|
+
constructor(options?: SkillRegistryOptions);
|
|
18
|
+
setSessionId(sessionId: string): void;
|
|
19
|
+
loadRoots(machine: Machine, roots: readonly SkillRoot[]): Promise<void>;
|
|
20
|
+
registerBuiltinSkill(skill: SkillDefinition): void;
|
|
21
|
+
register(skill: SkillDefinition, options?: {
|
|
22
|
+
readonly replace?: boolean;
|
|
23
|
+
}): void;
|
|
24
|
+
getSkill(name: string): SkillDefinition | undefined;
|
|
25
|
+
listSkills(): readonly SkillDefinition[];
|
|
26
|
+
listInvocableSkills(): readonly SkillDefinition[];
|
|
27
|
+
listFlowSkills(): readonly SkillDefinition[];
|
|
28
|
+
getSkillRoots(): readonly string[];
|
|
29
|
+
getSkippedByPolicy(): readonly SkippedSkill[];
|
|
30
|
+
renderSkillPrompt(skill: SkillDefinition, rawArgs: string): string;
|
|
31
|
+
getModelSkillListing(): string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=registry.d.ts.map
|