@agntk/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/README.md +227 -0
- package/dist/advanced/index.d.ts +35 -0
- package/dist/advanced/index.d.ts.map +1 -0
- package/dist/advanced/index.js +52 -0
- package/dist/advanced/index.js.map +1 -0
- package/dist/agent.d.ts +46 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +381 -0
- package/dist/agent.js.map +1 -0
- package/dist/config/defaults.d.ts +10 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +34 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +54 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +222 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +912 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +119 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/constants.d.ts +17 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/evals/assertions.d.ts +54 -0
- package/dist/evals/assertions.d.ts.map +1 -0
- package/dist/evals/assertions.js +200 -0
- package/dist/evals/assertions.js.map +1 -0
- package/dist/evals/index.d.ts +9 -0
- package/dist/evals/index.d.ts.map +1 -0
- package/dist/evals/index.js +8 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/runner.d.ts +34 -0
- package/dist/evals/runner.d.ts.map +1 -0
- package/dist/evals/runner.js +186 -0
- package/dist/evals/runner.js.map +1 -0
- package/dist/evals/types.d.ts +68 -0
- package/dist/evals/types.d.ts.map +1 -0
- package/dist/evals/types.js +5 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/guardrails/built-ins.d.ts +48 -0
- package/dist/guardrails/built-ins.d.ts.map +1 -0
- package/dist/guardrails/built-ins.js +149 -0
- package/dist/guardrails/built-ins.js.map +1 -0
- package/dist/guardrails/index.d.ts +8 -0
- package/dist/guardrails/index.d.ts.map +1 -0
- package/dist/guardrails/index.js +7 -0
- package/dist/guardrails/index.js.map +1 -0
- package/dist/guardrails/runner.d.ts +49 -0
- package/dist/guardrails/runner.d.ts.map +1 -0
- package/dist/guardrails/runner.js +148 -0
- package/dist/guardrails/runner.js.map +1 -0
- package/dist/guardrails/types.d.ts +63 -0
- package/dist/guardrails/types.d.ts.map +1 -0
- package/dist/guardrails/types.js +22 -0
- package/dist/guardrails/types.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/engine.d.ts +130 -0
- package/dist/memory/engine.d.ts.map +1 -0
- package/dist/memory/engine.js +227 -0
- package/dist/memory/engine.js.map +1 -0
- package/dist/memory/extraction.d.ts +24 -0
- package/dist/memory/extraction.d.ts.map +1 -0
- package/dist/memory/extraction.js +130 -0
- package/dist/memory/extraction.js.map +1 -0
- package/dist/memory/loader.d.ts +20 -0
- package/dist/memory/loader.d.ts.map +1 -0
- package/dist/memory/loader.js +73 -0
- package/dist/memory/loader.js.map +1 -0
- package/dist/memory/store.d.ts +42 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +120 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/tools.d.ts +39 -0
- package/dist/memory/tools.d.ts.map +1 -0
- package/dist/memory/tools.js +225 -0
- package/dist/memory/tools.js.map +1 -0
- package/dist/memory/types.d.ts +46 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +8 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/vectra-store.d.ts +31 -0
- package/dist/memory/vectra-store.d.ts.map +1 -0
- package/dist/memory/vectra-store.js +122 -0
- package/dist/memory/vectra-store.js.map +1 -0
- package/dist/models.d.ts +37 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +131 -0
- package/dist/models.js.map +1 -0
- package/dist/observability/index.d.ts +6 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/langfuse.d.ts +47 -0
- package/dist/observability/langfuse.d.ts.map +1 -0
- package/dist/observability/langfuse.js +112 -0
- package/dist/observability/langfuse.js.map +1 -0
- package/dist/observability/types.d.ts +37 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +5 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pool/index.d.ts +7 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +6 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/specialist-pool.d.ts +59 -0
- package/dist/pool/specialist-pool.d.ts.map +1 -0
- package/dist/pool/specialist-pool.js +224 -0
- package/dist/pool/specialist-pool.js.map +1 -0
- package/dist/pool/tools.d.ts +63 -0
- package/dist/pool/tools.d.ts.map +1 -0
- package/dist/pool/tools.js +83 -0
- package/dist/pool/tools.js.map +1 -0
- package/dist/pool/types.d.ts +79 -0
- package/dist/pool/types.d.ts.map +1 -0
- package/dist/pool/types.js +5 -0
- package/dist/pool/types.js.map +1 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +5 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/role-registry.d.ts +41 -0
- package/dist/presets/role-registry.d.ts.map +1 -0
- package/dist/presets/role-registry.js +213 -0
- package/dist/presets/role-registry.js.map +1 -0
- package/dist/presets/roles.d.ts +105 -0
- package/dist/presets/roles.d.ts.map +1 -0
- package/dist/presets/roles.js +207 -0
- package/dist/presets/roles.js.map +1 -0
- package/dist/presets/sub-agent-configs.d.ts +19 -0
- package/dist/presets/sub-agent-configs.d.ts.map +1 -0
- package/dist/presets/sub-agent-configs.js +71 -0
- package/dist/presets/sub-agent-configs.js.map +1 -0
- package/dist/presets/tool-preset-registry.d.ts +34 -0
- package/dist/presets/tool-preset-registry.d.ts.map +1 -0
- package/dist/presets/tool-preset-registry.js +107 -0
- package/dist/presets/tool-preset-registry.js.map +1 -0
- package/dist/presets/tools.d.ts +278 -0
- package/dist/presets/tools.d.ts.map +1 -0
- package/dist/presets/tools.js +108 -0
- package/dist/presets/tools.js.map +1 -0
- package/dist/prompts/context.d.ts +47 -0
- package/dist/prompts/context.d.ts.map +1 -0
- package/dist/prompts/context.js +187 -0
- package/dist/prompts/context.js.map +1 -0
- package/dist/prompts/template.d.ts +17 -0
- package/dist/prompts/template.d.ts.map +1 -0
- package/dist/prompts/template.js +32 -0
- package/dist/prompts/template.js.map +1 -0
- package/dist/prompts/templates.d.ts +11 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +115 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/reflection.d.ts +48 -0
- package/dist/reflection.d.ts.map +1 -0
- package/dist/reflection.js +91 -0
- package/dist/reflection.js.map +1 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +5 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loader.d.ts +84 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +400 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/types.d.ts +66 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +6 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/streaming/data-parts.d.ts +163 -0
- package/dist/streaming/data-parts.d.ts.map +1 -0
- package/dist/streaming/data-parts.js +14 -0
- package/dist/streaming/data-parts.js.map +1 -0
- package/dist/streaming/index.d.ts +8 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +10 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/transient.d.ts +136 -0
- package/dist/streaming/transient.d.ts.map +1 -0
- package/dist/streaming/transient.js +201 -0
- package/dist/streaming/transient.js.map +1 -0
- package/dist/tools/approval.d.ts +67 -0
- package/dist/tools/approval.d.ts.map +1 -0
- package/dist/tools/approval.js +113 -0
- package/dist/tools/approval.js.map +1 -0
- package/dist/tools/ast-grep/cli.d.ts +16 -0
- package/dist/tools/ast-grep/cli.d.ts.map +1 -0
- package/dist/tools/ast-grep/cli.js +198 -0
- package/dist/tools/ast-grep/cli.js.map +1 -0
- package/dist/tools/ast-grep/constants.d.ts +24 -0
- package/dist/tools/ast-grep/constants.d.ts.map +1 -0
- package/dist/tools/ast-grep/constants.js +247 -0
- package/dist/tools/ast-grep/constants.js.map +1 -0
- package/dist/tools/ast-grep/downloader.d.ts +6 -0
- package/dist/tools/ast-grep/downloader.d.ts.map +1 -0
- package/dist/tools/ast-grep/downloader.js +137 -0
- package/dist/tools/ast-grep/downloader.js.map +1 -0
- package/dist/tools/ast-grep/index.d.ts +7 -0
- package/dist/tools/ast-grep/index.d.ts.map +1 -0
- package/dist/tools/ast-grep/index.js +6 -0
- package/dist/tools/ast-grep/index.js.map +1 -0
- package/dist/tools/ast-grep/tools.d.ts +33 -0
- package/dist/tools/ast-grep/tools.d.ts.map +1 -0
- package/dist/tools/ast-grep/tools.js +140 -0
- package/dist/tools/ast-grep/tools.js.map +1 -0
- package/dist/tools/ast-grep/types.d.ts +68 -0
- package/dist/tools/ast-grep/types.d.ts.map +1 -0
- package/dist/tools/ast-grep/types.js +2 -0
- package/dist/tools/ast-grep/types.js.map +1 -0
- package/dist/tools/ast-grep/utils.d.ts +4 -0
- package/dist/tools/ast-grep/utils.d.ts.map +1 -0
- package/dist/tools/ast-grep/utils.js +55 -0
- package/dist/tools/ast-grep/utils.js.map +1 -0
- package/dist/tools/browser/index.d.ts +6 -0
- package/dist/tools/browser/index.d.ts.map +1 -0
- package/dist/tools/browser/index.js +5 -0
- package/dist/tools/browser/index.js.map +1 -0
- package/dist/tools/browser/stream.d.ts +112 -0
- package/dist/tools/browser/stream.d.ts.map +1 -0
- package/dist/tools/browser/stream.js +228 -0
- package/dist/tools/browser/stream.js.map +1 -0
- package/dist/tools/browser/tool.d.ts +144 -0
- package/dist/tools/browser/tool.d.ts.map +1 -0
- package/dist/tools/browser/tool.js +214 -0
- package/dist/tools/browser/tool.js.map +1 -0
- package/dist/tools/browser/types.d.ts +216 -0
- package/dist/tools/browser/types.d.ts.map +1 -0
- package/dist/tools/browser/types.js +146 -0
- package/dist/tools/browser/types.js.map +1 -0
- package/dist/tools/deep-reasoning/constants.d.ts +11 -0
- package/dist/tools/deep-reasoning/constants.d.ts.map +1 -0
- package/dist/tools/deep-reasoning/constants.js +35 -0
- package/dist/tools/deep-reasoning/constants.js.map +1 -0
- package/dist/tools/deep-reasoning/engine.d.ts +20 -0
- package/dist/tools/deep-reasoning/engine.d.ts.map +1 -0
- package/dist/tools/deep-reasoning/engine.js +77 -0
- package/dist/tools/deep-reasoning/engine.js.map +1 -0
- package/dist/tools/deep-reasoning/index.d.ts +5 -0
- package/dist/tools/deep-reasoning/index.d.ts.map +1 -0
- package/dist/tools/deep-reasoning/index.js +7 -0
- package/dist/tools/deep-reasoning/index.js.map +1 -0
- package/dist/tools/deep-reasoning/tools.d.ts +12 -0
- package/dist/tools/deep-reasoning/tools.d.ts.map +1 -0
- package/dist/tools/deep-reasoning/tools.js +23 -0
- package/dist/tools/deep-reasoning/tools.js.map +1 -0
- package/dist/tools/deep-reasoning/types.d.ts +66 -0
- package/dist/tools/deep-reasoning/types.d.ts.map +1 -0
- package/dist/tools/deep-reasoning/types.js +13 -0
- package/dist/tools/deep-reasoning/types.js.map +1 -0
- package/dist/tools/factory.d.ts +109 -0
- package/dist/tools/factory.d.ts.map +1 -0
- package/dist/tools/factory.js +166 -0
- package/dist/tools/factory.js.map +1 -0
- package/dist/tools/file/index.d.ts +8 -0
- package/dist/tools/file/index.d.ts.map +1 -0
- package/dist/tools/file/index.js +8 -0
- package/dist/tools/file/index.js.map +1 -0
- package/dist/tools/file/tools.d.ts +45 -0
- package/dist/tools/file/tools.d.ts.map +1 -0
- package/dist/tools/file/tools.js +206 -0
- package/dist/tools/file/tools.js.map +1 -0
- package/dist/tools/glob/cli.d.ts +8 -0
- package/dist/tools/glob/cli.d.ts.map +1 -0
- package/dist/tools/glob/cli.js +168 -0
- package/dist/tools/glob/cli.js.map +1 -0
- package/dist/tools/glob/constants.d.ts +7 -0
- package/dist/tools/glob/constants.d.ts.map +1 -0
- package/dist/tools/glob/constants.js +17 -0
- package/dist/tools/glob/constants.js.map +1 -0
- package/dist/tools/glob/index.d.ts +6 -0
- package/dist/tools/glob/index.d.ts.map +1 -0
- package/dist/tools/glob/index.js +5 -0
- package/dist/tools/glob/index.js.map +1 -0
- package/dist/tools/glob/tools.d.ts +15 -0
- package/dist/tools/glob/tools.d.ts.map +1 -0
- package/dist/tools/glob/tools.js +74 -0
- package/dist/tools/glob/tools.js.map +1 -0
- package/dist/tools/glob/types.d.ts +20 -0
- package/dist/tools/glob/types.d.ts.map +1 -0
- package/dist/tools/glob/types.js +2 -0
- package/dist/tools/glob/types.js.map +1 -0
- package/dist/tools/glob/utils.d.ts +3 -0
- package/dist/tools/glob/utils.d.ts.map +1 -0
- package/dist/tools/glob/utils.js +20 -0
- package/dist/tools/glob/utils.js.map +1 -0
- package/dist/tools/grep/cli.d.ts +4 -0
- package/dist/tools/grep/cli.d.ts.map +1 -0
- package/dist/tools/grep/cli.js +224 -0
- package/dist/tools/grep/cli.js.map +1 -0
- package/dist/tools/grep/constants.d.ts +19 -0
- package/dist/tools/grep/constants.d.ts.map +1 -0
- package/dist/tools/grep/constants.js +115 -0
- package/dist/tools/grep/constants.js.map +1 -0
- package/dist/tools/grep/downloader.d.ts +3 -0
- package/dist/tools/grep/downloader.d.ts.map +1 -0
- package/dist/tools/grep/downloader.js +164 -0
- package/dist/tools/grep/downloader.js.map +1 -0
- package/dist/tools/grep/index.d.ts +7 -0
- package/dist/tools/grep/index.d.ts.map +1 -0
- package/dist/tools/grep/index.js +6 -0
- package/dist/tools/grep/index.js.map +1 -0
- package/dist/tools/grep/tools.d.ts +19 -0
- package/dist/tools/grep/tools.d.ts.map +1 -0
- package/dist/tools/grep/tools.js +82 -0
- package/dist/tools/grep/tools.js.map +1 -0
- package/dist/tools/grep/types.d.ts +37 -0
- package/dist/tools/grep/types.d.ts.map +1 -0
- package/dist/tools/grep/types.js +2 -0
- package/dist/tools/grep/types.js.map +1 -0
- package/dist/tools/grep/utils.d.ts +4 -0
- package/dist/tools/grep/utils.d.ts.map +1 -0
- package/dist/tools/grep/utils.js +41 -0
- package/dist/tools/grep/utils.js.map +1 -0
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +33 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/model-retry.d.ts +54 -0
- package/dist/tools/model-retry.d.ts.map +1 -0
- package/dist/tools/model-retry.js +110 -0
- package/dist/tools/model-retry.js.map +1 -0
- package/dist/tools/plan/constants.d.ts +18 -0
- package/dist/tools/plan/constants.d.ts.map +1 -0
- package/dist/tools/plan/constants.js +13 -0
- package/dist/tools/plan/constants.js.map +1 -0
- package/dist/tools/plan/index.d.ts +5 -0
- package/dist/tools/plan/index.d.ts.map +1 -0
- package/dist/tools/plan/index.js +7 -0
- package/dist/tools/plan/index.js.map +1 -0
- package/dist/tools/plan/tools.d.ts +16 -0
- package/dist/tools/plan/tools.d.ts.map +1 -0
- package/dist/tools/plan/tools.js +217 -0
- package/dist/tools/plan/tools.js.map +1 -0
- package/dist/tools/plan/types.d.ts +75 -0
- package/dist/tools/plan/types.d.ts.map +1 -0
- package/dist/tools/plan/types.js +16 -0
- package/dist/tools/plan/types.js.map +1 -0
- package/dist/tools/plan/utils.d.ts +9 -0
- package/dist/tools/plan/utils.d.ts.map +1 -0
- package/dist/tools/plan/utils.js +27 -0
- package/dist/tools/plan/utils.js.map +1 -0
- package/dist/tools/progress/index.d.ts +53 -0
- package/dist/tools/progress/index.d.ts.map +1 -0
- package/dist/tools/progress/index.js +144 -0
- package/dist/tools/progress/index.js.map +1 -0
- package/dist/tools/provider.d.ts +97 -0
- package/dist/tools/provider.d.ts.map +1 -0
- package/dist/tools/provider.js +178 -0
- package/dist/tools/provider.js.map +1 -0
- package/dist/tools/search-skills.d.ts +44 -0
- package/dist/tools/search-skills.d.ts.map +1 -0
- package/dist/tools/search-skills.js +134 -0
- package/dist/tools/search-skills.js.map +1 -0
- package/dist/tools/shell/background.d.ts +38 -0
- package/dist/tools/shell/background.d.ts.map +1 -0
- package/dist/tools/shell/background.js +229 -0
- package/dist/tools/shell/background.js.map +1 -0
- package/dist/tools/shell/constants.d.ts +10 -0
- package/dist/tools/shell/constants.d.ts.map +1 -0
- package/dist/tools/shell/constants.js +55 -0
- package/dist/tools/shell/constants.js.map +1 -0
- package/dist/tools/shell/index.d.ts +7 -0
- package/dist/tools/shell/index.d.ts.map +1 -0
- package/dist/tools/shell/index.js +5 -0
- package/dist/tools/shell/index.js.map +1 -0
- package/dist/tools/shell/tools.d.ts +22 -0
- package/dist/tools/shell/tools.d.ts.map +1 -0
- package/dist/tools/shell/tools.js +70 -0
- package/dist/tools/shell/tools.js.map +1 -0
- package/dist/tools/shell/types.d.ts +30 -0
- package/dist/tools/shell/types.d.ts.map +1 -0
- package/dist/tools/shell/types.js +10 -0
- package/dist/tools/shell/types.js.map +1 -0
- package/dist/tools/shell/utils.d.ts +7 -0
- package/dist/tools/shell/utils.d.ts.map +1 -0
- package/dist/tools/shell/utils.js +26 -0
- package/dist/tools/shell/utils.js.map +1 -0
- package/dist/tools/spawn-agent/index.d.ts +96 -0
- package/dist/tools/spawn-agent/index.d.ts.map +1 -0
- package/dist/tools/spawn-agent/index.js +168 -0
- package/dist/tools/spawn-agent/index.js.map +1 -0
- package/dist/tools/utils/errors.d.ts +21 -0
- package/dist/tools/utils/errors.d.ts.map +1 -0
- package/dist/tools/utils/errors.js +29 -0
- package/dist/tools/utils/errors.js.map +1 -0
- package/dist/tools/utils/shell.d.ts +23 -0
- package/dist/tools/utils/shell.d.ts.map +1 -0
- package/dist/tools/utils/shell.js +99 -0
- package/dist/tools/utils/shell.js.map +1 -0
- package/dist/tools/utils/tool-result.d.ts +6 -0
- package/dist/tools/utils/tool-result.d.ts.map +1 -0
- package/dist/tools/utils/tool-result.js +22 -0
- package/dist/tools/utils/tool-result.js.map +1 -0
- package/dist/types/agent.d.ts +218 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +6 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lifecycle.d.ts +218 -0
- package/dist/types/lifecycle.d.ts.map +1 -0
- package/dist/types/lifecycle.js +99 -0
- package/dist/types/lifecycle.js.map +1 -0
- package/dist/types/streaming.d.ts +120 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +6 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/usage-limits.d.ts +63 -0
- package/dist/usage-limits.d.ts.map +1 -0
- package/dist/usage-limits.js +88 -0
- package/dist/usage-limits.js.map +1 -0
- package/dist/utils/logger.d.ts +35 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +149 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflow/builders/adapt.d.ts +20 -0
- package/dist/workflow/builders/adapt.d.ts.map +1 -0
- package/dist/workflow/builders/adapt.js +33 -0
- package/dist/workflow/builders/adapt.js.map +1 -0
- package/dist/workflow/builders/index.d.ts +8 -0
- package/dist/workflow/builders/index.d.ts.map +1 -0
- package/dist/workflow/builders/index.js +7 -0
- package/dist/workflow/builders/index.js.map +1 -0
- package/dist/workflow/builders/parallel.d.ts +25 -0
- package/dist/workflow/builders/parallel.d.ts.map +1 -0
- package/dist/workflow/builders/parallel.js +60 -0
- package/dist/workflow/builders/parallel.js.map +1 -0
- package/dist/workflow/builders/pipeline.d.ts +22 -0
- package/dist/workflow/builders/pipeline.d.ts.map +1 -0
- package/dist/workflow/builders/pipeline.js +48 -0
- package/dist/workflow/builders/pipeline.js.map +1 -0
- package/dist/workflow/builders/types.d.ts +54 -0
- package/dist/workflow/builders/types.d.ts.map +1 -0
- package/dist/workflow/builders/types.js +5 -0
- package/dist/workflow/builders/types.js.map +1 -0
- package/dist/workflow/durable-agent.d.ts +128 -0
- package/dist/workflow/durable-agent.d.ts.map +1 -0
- package/dist/workflow/durable-agent.js +323 -0
- package/dist/workflow/durable-agent.js.map +1 -0
- package/dist/workflow/durable-tool.d.ts +103 -0
- package/dist/workflow/durable-tool.d.ts.map +1 -0
- package/dist/workflow/durable-tool.js +173 -0
- package/dist/workflow/durable-tool.js.map +1 -0
- package/dist/workflow/hooks.d.ts +318 -0
- package/dist/workflow/hooks.d.ts.map +1 -0
- package/dist/workflow/hooks.js +629 -0
- package/dist/workflow/hooks.js.map +1 -0
- package/dist/workflow/index.d.ts +17 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +24 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/schedulers.d.ts +231 -0
- package/dist/workflow/schedulers.d.ts.map +1 -0
- package/dist/workflow/schedulers.js +250 -0
- package/dist/workflow/schedulers.js.map +1 -0
- package/dist/workflow/team/create-team.d.ts +34 -0
- package/dist/workflow/team/create-team.d.ts.map +1 -0
- package/dist/workflow/team/create-team.js +242 -0
- package/dist/workflow/team/create-team.js.map +1 -0
- package/dist/workflow/team/index.d.ts +9 -0
- package/dist/workflow/team/index.d.ts.map +1 -0
- package/dist/workflow/team/index.js +8 -0
- package/dist/workflow/team/index.js.map +1 -0
- package/dist/workflow/team/machines.d.ts +152 -0
- package/dist/workflow/team/machines.d.ts.map +1 -0
- package/dist/workflow/team/machines.js +197 -0
- package/dist/workflow/team/machines.js.map +1 -0
- package/dist/workflow/team/task-board.d.ts +47 -0
- package/dist/workflow/team/task-board.d.ts.map +1 -0
- package/dist/workflow/team/task-board.js +111 -0
- package/dist/workflow/team/task-board.js.map +1 -0
- package/dist/workflow/team/tools.d.ts +66 -0
- package/dist/workflow/team/tools.d.ts.map +1 -0
- package/dist/workflow/team/tools.js +100 -0
- package/dist/workflow/team/tools.js.map +1 -0
- package/dist/workflow/team/types.d.ts +109 -0
- package/dist/workflow/team/types.d.ts.map +1 -0
- package/dist/workflow/team/types.js +5 -0
- package/dist/workflow/team/types.js.map +1 -0
- package/dist/workflow/templates.d.ts +71 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +132 -0
- package/dist/workflow/templates.js.map +1 -0
- package/dist/workflow/utils.d.ts +29 -0
- package/dist/workflow/utils.d.ts.map +1 -0
- package/dist/workflow/utils.js +84 -0
- package/dist/workflow/utils.js.map +1 -0
- package/dist/wrappers/best-of-n.d.ts +69 -0
- package/dist/wrappers/best-of-n.d.ts.map +1 -0
- package/dist/wrappers/best-of-n.js +242 -0
- package/dist/wrappers/best-of-n.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - System Context Builder
|
|
3
|
+
* Builds dynamic context information for agent system prompts
|
|
4
|
+
*/
|
|
5
|
+
import { createLogger } from '@agntk/logger';
|
|
6
|
+
import { GEOLOCATION_API_URL, GEOLOCATION_ENABLED_DEFAULT } from '../constants.js';
|
|
7
|
+
const log = createLogger('@agntk/core:context');
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Runtime Detection
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const isNode = typeof process !== 'undefined' && process.versions?.node;
|
|
12
|
+
async function getNodeInfo() {
|
|
13
|
+
if (!isNode) {
|
|
14
|
+
return {
|
|
15
|
+
platform: 'browser',
|
|
16
|
+
hostname: 'browser',
|
|
17
|
+
username: 'user',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const os = await import('node:os');
|
|
21
|
+
return {
|
|
22
|
+
platform: os.platform(),
|
|
23
|
+
hostname: os.hostname(),
|
|
24
|
+
username: os.userInfo().username,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function getLocale() {
|
|
28
|
+
if (typeof Intl !== 'undefined') {
|
|
29
|
+
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
30
|
+
}
|
|
31
|
+
return 'en-US';
|
|
32
|
+
}
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Location (Optional)
|
|
35
|
+
// ============================================================================
|
|
36
|
+
async function fetchUserLocation() {
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(GEOLOCATION_API_URL);
|
|
39
|
+
if (!response.ok)
|
|
40
|
+
return undefined;
|
|
41
|
+
const data = await response.json();
|
|
42
|
+
return {
|
|
43
|
+
city: data.city,
|
|
44
|
+
region: data.regionName,
|
|
45
|
+
country: data.country,
|
|
46
|
+
countryCode: data.countryCode,
|
|
47
|
+
timezone: data.timezone,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Workspace Map
|
|
56
|
+
// ============================================================================
|
|
57
|
+
async function generateWorkspaceMap(workspaceRoot) {
|
|
58
|
+
if (!isNode)
|
|
59
|
+
return '';
|
|
60
|
+
try {
|
|
61
|
+
const fs = await import('node:fs');
|
|
62
|
+
const path = await import('node:path');
|
|
63
|
+
if (!fs.existsSync(workspaceRoot))
|
|
64
|
+
return '';
|
|
65
|
+
const entries = fs.readdirSync(workspaceRoot);
|
|
66
|
+
const topLevel = entries
|
|
67
|
+
.filter(e => !e.startsWith('.'))
|
|
68
|
+
.slice(0, 20)
|
|
69
|
+
.map(e => {
|
|
70
|
+
const fullPath = path.join(workspaceRoot, e);
|
|
71
|
+
const isDir = fs.statSync(fullPath).isDirectory();
|
|
72
|
+
if (isDir) {
|
|
73
|
+
const children = fs.readdirSync(fullPath).filter(c => !c.startsWith('.')).slice(0, 5);
|
|
74
|
+
return `${e}/: ${children.join(', ')}${children.length >= 5 ? '...' : ''}`;
|
|
75
|
+
}
|
|
76
|
+
return e;
|
|
77
|
+
});
|
|
78
|
+
return topLevel.join('\n');
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Context Builder
|
|
86
|
+
// ============================================================================
|
|
87
|
+
export async function buildSystemContext(options = {}) {
|
|
88
|
+
const { workspaceRoot, includeWorkspaceMap = false, userLocation, userPreferences, fetchLocation = GEOLOCATION_ENABLED_DEFAULT, } = options;
|
|
89
|
+
const now = new Date();
|
|
90
|
+
const nodeInfo = await getNodeInfo();
|
|
91
|
+
// Optionally fetch location
|
|
92
|
+
let location = userLocation;
|
|
93
|
+
if (!location && fetchLocation) {
|
|
94
|
+
location = await fetchUserLocation();
|
|
95
|
+
}
|
|
96
|
+
const preferences = userPreferences;
|
|
97
|
+
const context = {
|
|
98
|
+
currentTime: now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true }),
|
|
99
|
+
currentDate: now.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }),
|
|
100
|
+
timezone: location?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
101
|
+
platform: nodeInfo.platform,
|
|
102
|
+
hostname: nodeInfo.hostname,
|
|
103
|
+
username: nodeInfo.username,
|
|
104
|
+
locale: getLocale(),
|
|
105
|
+
workspaceRoot,
|
|
106
|
+
userLocation: location,
|
|
107
|
+
userPreferences: preferences,
|
|
108
|
+
};
|
|
109
|
+
if (includeWorkspaceMap && workspaceRoot) {
|
|
110
|
+
context.workspaceMap = await generateWorkspaceMap(workspaceRoot);
|
|
111
|
+
}
|
|
112
|
+
return context;
|
|
113
|
+
}
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Formatting
|
|
116
|
+
// ============================================================================
|
|
117
|
+
export function formatSystemContextBlock(context) {
|
|
118
|
+
const lines = [
|
|
119
|
+
'# Current Environment',
|
|
120
|
+
'',
|
|
121
|
+
`- **Date**: ${context.currentDate}`,
|
|
122
|
+
`- **Time**: ${context.currentTime} (${context.timezone})`,
|
|
123
|
+
`- **Locale**: ${context.locale}`,
|
|
124
|
+
`- **Platform**: ${context.platform}`,
|
|
125
|
+
`- **User**: ${context.username}`,
|
|
126
|
+
];
|
|
127
|
+
// Location
|
|
128
|
+
if (context.userLocation) {
|
|
129
|
+
const loc = context.userLocation;
|
|
130
|
+
const locationParts = [loc.city, loc.region, loc.country].filter(Boolean);
|
|
131
|
+
if (locationParts.length > 0) {
|
|
132
|
+
lines.push(`- **Location**: ${locationParts.join(', ')}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Workspace
|
|
136
|
+
if (context.workspaceRoot) {
|
|
137
|
+
lines.push(`- **Workspace**: ${context.workspaceRoot}`);
|
|
138
|
+
}
|
|
139
|
+
if (context.workspaceMap) {
|
|
140
|
+
lines.push('');
|
|
141
|
+
lines.push('## Workspace Structure');
|
|
142
|
+
lines.push('```');
|
|
143
|
+
lines.push(context.workspaceMap);
|
|
144
|
+
lines.push('```');
|
|
145
|
+
}
|
|
146
|
+
// User Preferences
|
|
147
|
+
if (context.userPreferences) {
|
|
148
|
+
const prefs = context.userPreferences;
|
|
149
|
+
lines.push('');
|
|
150
|
+
lines.push('## User Preferences');
|
|
151
|
+
if (prefs.name)
|
|
152
|
+
lines.push(`- **Name**: ${prefs.name}`);
|
|
153
|
+
if (prefs.language)
|
|
154
|
+
lines.push(`- **Preferred Language**: ${prefs.language}`);
|
|
155
|
+
if (prefs.communicationStyle)
|
|
156
|
+
lines.push(`- **Communication Style**: ${prefs.communicationStyle}`);
|
|
157
|
+
if (prefs.codeStyle) {
|
|
158
|
+
lines.push('- **Code Style**:');
|
|
159
|
+
if (prefs.codeStyle.indentation)
|
|
160
|
+
lines.push(` - Indentation: ${prefs.codeStyle.indentation}`);
|
|
161
|
+
if (prefs.codeStyle.indentSize)
|
|
162
|
+
lines.push(` - Indent Size: ${prefs.codeStyle.indentSize}`);
|
|
163
|
+
if (prefs.codeStyle.quoteStyle)
|
|
164
|
+
lines.push(` - Quote Style: ${prefs.codeStyle.quoteStyle}`);
|
|
165
|
+
}
|
|
166
|
+
if (prefs.customPreferences && Object.keys(prefs.customPreferences).length > 0) {
|
|
167
|
+
for (const [key, value] of Object.entries(prefs.customPreferences)) {
|
|
168
|
+
lines.push(`- **${key}**: ${String(value)}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Appended profile block (from memory system)
|
|
173
|
+
if (context.userProfileBlock) {
|
|
174
|
+
lines.push('');
|
|
175
|
+
lines.push(context.userProfileBlock);
|
|
176
|
+
}
|
|
177
|
+
return lines.join('\n');
|
|
178
|
+
}
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Convenience Function
|
|
181
|
+
// ============================================================================
|
|
182
|
+
export async function buildDynamicSystemPrompt(basePrompt, options = {}) {
|
|
183
|
+
const context = await buildSystemContext(options);
|
|
184
|
+
const contextBlock = formatSystemContextBlock(context);
|
|
185
|
+
return `${basePrompt}\n\n${contextBlock}`;
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/prompts/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhF,MAAM,GAAG,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AA2DhD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW,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IAAI,KAAK,CAAC,iBAAiB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACnE,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,UAAkB,EAClB,UAA0B,EAAE;IAE5B,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO,GAAG,UAAU,OAAO,YAAY,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Template engine for variable substitution in prompts.
|
|
3
|
+
*/
|
|
4
|
+
interface TemplateContext {
|
|
5
|
+
[key: string]: string | number | boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Apply template variables to a string.
|
|
9
|
+
* Replaces {{variableName}} with the value from context.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* applyTemplate('Hello {{name}}!', { name: 'World' })
|
|
13
|
+
* // => 'Hello World!'
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyTemplate(template: string, context?: TemplateContext): string;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,UAAU,eAAe;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAMD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,CAcrF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Template engine for variable substitution in prompts.
|
|
3
|
+
*/
|
|
4
|
+
import { createLogger } from '@agntk/logger';
|
|
5
|
+
import { getConfig } from '../config/index.js';
|
|
6
|
+
const log = createLogger('@agntk/core:templates');
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Template Engine
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Apply template variables to a string.
|
|
12
|
+
* Replaces {{variableName}} with the value from context.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* applyTemplate('Hello {{name}}!', { name: 'World' })
|
|
16
|
+
* // => 'Hello World!'
|
|
17
|
+
*/
|
|
18
|
+
export function applyTemplate(template, context = {}) {
|
|
19
|
+
// Merge config variables with explicit context (explicit takes precedence)
|
|
20
|
+
const config = getConfig();
|
|
21
|
+
const configVars = config.templates;
|
|
22
|
+
const mergedContext = { ...configVars?.variables, ...context };
|
|
23
|
+
return template.replace(/\{\{(\w+)\}\}/g, (match, varName) => {
|
|
24
|
+
const value = mergedContext[varName];
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
log.debug('Template variable not found', { variable: varName });
|
|
27
|
+
return match; // Leave unreplaced if not found
|
|
28
|
+
}
|
|
29
|
+
return String(value);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/prompts/template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,GAAG,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAUlD,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,UAA2B,EAAE;IAC3E,2EAA2E;IAC3E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAI,MAAkC,CAAC,SAAwD,CAAC;IAChH,MAAM,aAAa,GAAG,EAAE,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;IAE/D,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3D,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,GAAG,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAChE,OAAO,KAAK,CAAC,CAAC,gCAAgC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - System Prompt Templates
|
|
3
|
+
* Core system prompts for agent behavior
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Use `presets/role-registry.ts` instead. That module is the canonical
|
|
6
|
+
* source of truth for role prompts, used by `createAgent()` via `getRole()`.
|
|
7
|
+
* This file is kept for backward compatibility of public exports only.
|
|
8
|
+
*/
|
|
9
|
+
export declare const systemPrompt = "You are an autonomous agent. Your purpose is to accomplish the user's goal using whatever approach makes sense.\n\n# Philosophy\n\nYou have a mind and you have tools. Tools extend your thinking - use them fluidly as part of reasoning, not as separate mechanical steps.\n\nThere is no single correct workflow. Match your approach to the problem:\n- Reason through it, gather information, reason more, then act\n- Act immediately if the path is obvious\n- Start one approach, realize it's wrong, switch to another\n- Call multiple tools in parallel when they don't depend on each other\n\nWhen something doesn't work, adapt. When you need information, go get it. When uncertain, reason carefully. When clear, act directly.\n\nWhen errors occur, read them carefully. The error message usually points to the fix.\n\n# Action\n\nDo things, don't announce them. Instead of \"I'll search for X\", just search.\n\nBe autonomous. Complete tasks without asking permission at every step. Only ask the user when you genuinely need information only they can provide.\n\n# Thinking Out Loud\n\nBefore each action, briefly state:\n- **Goal**: What am I trying to accomplish?\n- **Approach**: Why is this the right tool/action?\n- **Risk**: What could go wrong?\n\nKeep it concise (1-2 sentences each). This helps the user understand your decisions.\n\n# Efficiency\n\nComplete tasks in the fewest steps possible:\n- Think first: What's the most direct path to the goal?\n- Use the right tool: Each tool's description explains when to use it\n- Chain when independent: Call multiple tools in parallel when they don't depend on each other\n- No random exploration: Every action should have a purpose\n\n# Tools\n\nYou have access to consolidated tools with multiple actions. Use the action parameter to specify what to do:\n\n**fs** - All file operations (read, write, edit, list, glob, grep, move, delete, info, mkdir)\n**shell** - Execute shell commands (with allowlisting for repeated commands)\n**web** - Search the internet (search) or fetch page content (fetch)\n**memory** - Knowledge graph operations (add, search, episodes, fact, entity, related)\n\n**delegate** - Parallel work: tool chains (steps), sub-agents (agent), or background processes (background)\n**task** - Manage background tasks (status, output, cancel, list, cleanup)\n\nAdditional tools: plan, ask_user, task_complete\n\nEach tool's description provides detailed guidance on when and how to use it. Read the descriptions to understand capabilities and constraints.\n\n# Delegation\n\nFor complex work, use the delegate tool:\n- **steps**: Execute multiple tool calls in sequence with dependency handling\n- **agent**: Spawn a specialized sub-agent (coder/researcher/analyst)\n- **background**: Start a long-running shell command\n\nAfter delegating, use the task tool to monitor progress and retrieve output.\n\n# Completion\n\nCall task_complete when you have fully accomplished what the user asked for.\n\nOnly call task_complete when truly done - not planned, not partially done, but actually complete.\n";
|
|
10
|
+
export declare const rolePrompts: Record<string, string>;
|
|
11
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,+/FAqExB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsC9C,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - System Prompt Templates
|
|
3
|
+
* Core system prompts for agent behavior
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Use `presets/role-registry.ts` instead. That module is the canonical
|
|
6
|
+
* source of truth for role prompts, used by `createAgent()` via `getRole()`.
|
|
7
|
+
* This file is kept for backward compatibility of public exports only.
|
|
8
|
+
*/
|
|
9
|
+
export const systemPrompt = `You are an autonomous agent. Your purpose is to accomplish the user's goal using whatever approach makes sense.
|
|
10
|
+
|
|
11
|
+
# Philosophy
|
|
12
|
+
|
|
13
|
+
You have a mind and you have tools. Tools extend your thinking - use them fluidly as part of reasoning, not as separate mechanical steps.
|
|
14
|
+
|
|
15
|
+
There is no single correct workflow. Match your approach to the problem:
|
|
16
|
+
- Reason through it, gather information, reason more, then act
|
|
17
|
+
- Act immediately if the path is obvious
|
|
18
|
+
- Start one approach, realize it's wrong, switch to another
|
|
19
|
+
- Call multiple tools in parallel when they don't depend on each other
|
|
20
|
+
|
|
21
|
+
When something doesn't work, adapt. When you need information, go get it. When uncertain, reason carefully. When clear, act directly.
|
|
22
|
+
|
|
23
|
+
When errors occur, read them carefully. The error message usually points to the fix.
|
|
24
|
+
|
|
25
|
+
# Action
|
|
26
|
+
|
|
27
|
+
Do things, don't announce them. Instead of "I'll search for X", just search.
|
|
28
|
+
|
|
29
|
+
Be autonomous. Complete tasks without asking permission at every step. Only ask the user when you genuinely need information only they can provide.
|
|
30
|
+
|
|
31
|
+
# Thinking Out Loud
|
|
32
|
+
|
|
33
|
+
Before each action, briefly state:
|
|
34
|
+
- **Goal**: What am I trying to accomplish?
|
|
35
|
+
- **Approach**: Why is this the right tool/action?
|
|
36
|
+
- **Risk**: What could go wrong?
|
|
37
|
+
|
|
38
|
+
Keep it concise (1-2 sentences each). This helps the user understand your decisions.
|
|
39
|
+
|
|
40
|
+
# Efficiency
|
|
41
|
+
|
|
42
|
+
Complete tasks in the fewest steps possible:
|
|
43
|
+
- Think first: What's the most direct path to the goal?
|
|
44
|
+
- Use the right tool: Each tool's description explains when to use it
|
|
45
|
+
- Chain when independent: Call multiple tools in parallel when they don't depend on each other
|
|
46
|
+
- No random exploration: Every action should have a purpose
|
|
47
|
+
|
|
48
|
+
# Tools
|
|
49
|
+
|
|
50
|
+
You have access to consolidated tools with multiple actions. Use the action parameter to specify what to do:
|
|
51
|
+
|
|
52
|
+
**fs** - All file operations (read, write, edit, list, glob, grep, move, delete, info, mkdir)
|
|
53
|
+
**shell** - Execute shell commands (with allowlisting for repeated commands)
|
|
54
|
+
**web** - Search the internet (search) or fetch page content (fetch)
|
|
55
|
+
**memory** - Knowledge graph operations (add, search, episodes, fact, entity, related)
|
|
56
|
+
|
|
57
|
+
**delegate** - Parallel work: tool chains (steps), sub-agents (agent), or background processes (background)
|
|
58
|
+
**task** - Manage background tasks (status, output, cancel, list, cleanup)
|
|
59
|
+
|
|
60
|
+
Additional tools: plan, ask_user, task_complete
|
|
61
|
+
|
|
62
|
+
Each tool's description provides detailed guidance on when and how to use it. Read the descriptions to understand capabilities and constraints.
|
|
63
|
+
|
|
64
|
+
# Delegation
|
|
65
|
+
|
|
66
|
+
For complex work, use the delegate tool:
|
|
67
|
+
- **steps**: Execute multiple tool calls in sequence with dependency handling
|
|
68
|
+
- **agent**: Spawn a specialized sub-agent (coder/researcher/analyst)
|
|
69
|
+
- **background**: Start a long-running shell command
|
|
70
|
+
|
|
71
|
+
After delegating, use the task tool to monitor progress and retrieve output.
|
|
72
|
+
|
|
73
|
+
# Completion
|
|
74
|
+
|
|
75
|
+
Call task_complete when you have fully accomplished what the user asked for.
|
|
76
|
+
|
|
77
|
+
Only call task_complete when truly done - not planned, not partially done, but actually complete.
|
|
78
|
+
`;
|
|
79
|
+
export const rolePrompts = {
|
|
80
|
+
generic: systemPrompt,
|
|
81
|
+
coder: `${systemPrompt}
|
|
82
|
+
|
|
83
|
+
# Specialized Role: Code Implementation
|
|
84
|
+
|
|
85
|
+
You are a code implementation specialist. Your focus areas:
|
|
86
|
+
- Writing clean, maintainable code
|
|
87
|
+
- Following existing patterns in the codebase
|
|
88
|
+
- Making minimal, targeted changes
|
|
89
|
+
- Running tests to verify your changes work
|
|
90
|
+
|
|
91
|
+
Always read relevant code before making changes. Match the existing style.`,
|
|
92
|
+
researcher: `${systemPrompt}
|
|
93
|
+
|
|
94
|
+
# Specialized Role: Research
|
|
95
|
+
|
|
96
|
+
You are a research specialist. Your focus areas:
|
|
97
|
+
- Gathering comprehensive information on topics
|
|
98
|
+
- Evaluating source credibility
|
|
99
|
+
- Synthesizing findings into clear summaries
|
|
100
|
+
- Identifying key insights and patterns
|
|
101
|
+
|
|
102
|
+
Be thorough but efficient. Focus on actionable information.`,
|
|
103
|
+
analyst: `${systemPrompt}
|
|
104
|
+
|
|
105
|
+
# Specialized Role: Analysis
|
|
106
|
+
|
|
107
|
+
You are an analysis specialist. Your focus areas:
|
|
108
|
+
- Breaking down complex problems
|
|
109
|
+
- Identifying patterns and relationships
|
|
110
|
+
- Evaluating trade-offs and options
|
|
111
|
+
- Providing data-driven recommendations
|
|
112
|
+
|
|
113
|
+
Be systematic and logical. Support conclusions with evidence.`,
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/prompts/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqE3B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,OAAO,EAAE,YAAY;IAErB,KAAK,EAAE,GAAG,YAAY;;;;;;;;;;2EAUmD;IAEzE,UAAU,EAAE,GAAG,YAAY;;;;;;;;;;4DAU+B;IAE1D,OAAO,EAAE,GAAG,YAAY;;;;;;;;;;8DAUoC;CAC7D,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Reflection Strategies
|
|
3
|
+
*
|
|
4
|
+
* Implements reflection strategies that inject goal-state prompts between
|
|
5
|
+
* agent steps, improving multi-step task completion (+27.7% success in research).
|
|
6
|
+
*
|
|
7
|
+
* Uses the AI SDK's `prepareStep` hook to augment the system prompt with
|
|
8
|
+
* reflection instructions — no extra LLM calls required.
|
|
9
|
+
*/
|
|
10
|
+
import type { Tool, StepResult } from 'ai';
|
|
11
|
+
/** Available reflection strategies. */
|
|
12
|
+
export type ReflectionStrategy = 'none' | 'reflact' | 'periodic';
|
|
13
|
+
/** Configuration for the reflection system. */
|
|
14
|
+
export interface ReflectionConfig {
|
|
15
|
+
/** Which strategy to use. Default: 'none' */
|
|
16
|
+
strategy: ReflectionStrategy;
|
|
17
|
+
/** For 'periodic' strategy: reflect every N steps. Default: 3 */
|
|
18
|
+
frequency?: number;
|
|
19
|
+
/** Custom reflection prompt template. Uses {goal} placeholder. */
|
|
20
|
+
promptTemplate?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Input to the prepareStep hook from the AI SDK. */
|
|
23
|
+
export interface PrepareStepInput<TOOLS extends Record<string, Tool> = Record<string, Tool>> {
|
|
24
|
+
steps: Array<StepResult<TOOLS>>;
|
|
25
|
+
stepNumber: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a reflection prompt for the given step, or return undefined if
|
|
29
|
+
* no reflection should be injected at this step.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildReflectionPrompt(config: ReflectionConfig, stepNumber: number): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Create a `prepareStep` function for the AI SDK that injects reflection
|
|
34
|
+
* prompts into the system message at appropriate steps.
|
|
35
|
+
*
|
|
36
|
+
* @param baseSystem - The original system prompt to augment.
|
|
37
|
+
* @param config - The reflection configuration.
|
|
38
|
+
* @returns A prepareStep function compatible with AI SDK's ToolLoopAgent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createReflectionPrepareStep<TOOLS extends Record<string, Tool> = Record<string, Tool>>(baseSystem: string, config: ReflectionConfig): (input: PrepareStepInput<TOOLS>) => {
|
|
41
|
+
system?: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Estimate the token overhead of a reflection injection.
|
|
45
|
+
* Rough estimate: ~4 chars per token for English text.
|
|
46
|
+
*/
|
|
47
|
+
export declare function estimateReflectionTokens(config: ReflectionConfig): number;
|
|
48
|
+
//# sourceMappingURL=reflection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection.d.ts","sourceRoot":"","sources":["../src/reflection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAM3C,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,EAAE,kBAAkB,CAAC;IAE7B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IACzF,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AA4BD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACnG,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,GACvB,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAerE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAQzE"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Reflection Strategies
|
|
3
|
+
*
|
|
4
|
+
* Implements reflection strategies that inject goal-state prompts between
|
|
5
|
+
* agent steps, improving multi-step task completion (+27.7% success in research).
|
|
6
|
+
*
|
|
7
|
+
* Uses the AI SDK's `prepareStep` hook to augment the system prompt with
|
|
8
|
+
* reflection instructions — no extra LLM calls required.
|
|
9
|
+
*/
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Defaults
|
|
12
|
+
// ============================================================================
|
|
13
|
+
const DEFAULT_FREQUENCY = 3;
|
|
14
|
+
const DEFAULT_REFLACT_TEMPLATE = `<reflection>
|
|
15
|
+
Before proceeding, reflect on your progress:
|
|
16
|
+
1. What is the user's original goal?
|
|
17
|
+
2. What have you accomplished so far?
|
|
18
|
+
3. What is the most important next action to take?
|
|
19
|
+
4. Are you on track, or do you need to adjust your approach?
|
|
20
|
+
</reflection>`;
|
|
21
|
+
const DEFAULT_PERIODIC_TEMPLATE = `<reflection>
|
|
22
|
+
Checkpoint — pause and evaluate:
|
|
23
|
+
1. Revisit the user's original request. Are you still aligned with their goal?
|
|
24
|
+
2. Summarize what you have done so far.
|
|
25
|
+
3. Identify any dead ends or wasted steps.
|
|
26
|
+
4. Plan your next 2-3 actions to reach completion efficiently.
|
|
27
|
+
</reflection>`;
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Reflection Builder
|
|
30
|
+
// ============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Build a reflection prompt for the given step, or return undefined if
|
|
33
|
+
* no reflection should be injected at this step.
|
|
34
|
+
*/
|
|
35
|
+
export function buildReflectionPrompt(config, stepNumber) {
|
|
36
|
+
const { strategy } = config;
|
|
37
|
+
if (strategy === 'none') {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (strategy === 'reflact') {
|
|
41
|
+
// reflact: inject after every step except the first (step 0 = initial call)
|
|
42
|
+
if (stepNumber === 0)
|
|
43
|
+
return undefined;
|
|
44
|
+
return config.promptTemplate ?? DEFAULT_REFLACT_TEMPLATE;
|
|
45
|
+
}
|
|
46
|
+
if (strategy === 'periodic') {
|
|
47
|
+
const frequency = config.frequency ?? DEFAULT_FREQUENCY;
|
|
48
|
+
// Inject at step N, 2N, 3N... (never step 0)
|
|
49
|
+
if (stepNumber === 0 || stepNumber % frequency !== 0)
|
|
50
|
+
return undefined;
|
|
51
|
+
return config.promptTemplate ?? DEFAULT_PERIODIC_TEMPLATE;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a `prepareStep` function for the AI SDK that injects reflection
|
|
57
|
+
* prompts into the system message at appropriate steps.
|
|
58
|
+
*
|
|
59
|
+
* @param baseSystem - The original system prompt to augment.
|
|
60
|
+
* @param config - The reflection configuration.
|
|
61
|
+
* @returns A prepareStep function compatible with AI SDK's ToolLoopAgent.
|
|
62
|
+
*/
|
|
63
|
+
export function createReflectionPrepareStep(baseSystem, config) {
|
|
64
|
+
// If no reflection, return a no-op
|
|
65
|
+
if (config.strategy === 'none') {
|
|
66
|
+
return () => undefined;
|
|
67
|
+
}
|
|
68
|
+
return ({ stepNumber }) => {
|
|
69
|
+
const reflection = buildReflectionPrompt(config, stepNumber);
|
|
70
|
+
if (!reflection)
|
|
71
|
+
return undefined;
|
|
72
|
+
// Augment the system prompt with the reflection block
|
|
73
|
+
return {
|
|
74
|
+
system: `${baseSystem}\n\n${reflection}`,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Estimate the token overhead of a reflection injection.
|
|
80
|
+
* Rough estimate: ~4 chars per token for English text.
|
|
81
|
+
*/
|
|
82
|
+
export function estimateReflectionTokens(config) {
|
|
83
|
+
const template = config.strategy === 'reflact'
|
|
84
|
+
? (config.promptTemplate ?? DEFAULT_REFLACT_TEMPLATE)
|
|
85
|
+
: config.strategy === 'periodic'
|
|
86
|
+
? (config.promptTemplate ?? DEFAULT_PERIODIC_TEMPLATE)
|
|
87
|
+
: '';
|
|
88
|
+
// ~4 chars per token, rough estimate
|
|
89
|
+
return Math.ceil(template.length / 4);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=reflection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection.js","sourceRoot":"","sources":["../src/reflection.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E,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAElC,sDAAsD;QACtD,OAAO;YACL,MAAM,EAAE,GAAG,UAAU,OAAO,UAAU,EAAE;SACzC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAwB;IAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC5C,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,IAAI,wBAAwB,CAAC;QACrD,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,UAAU;YAChC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,IAAI,yBAAyB,CAAC;YACtD,CAAC,CAAC,EAAE,CAAC;IACP,qCAAqC;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Skills module public API.
|
|
3
|
+
*/
|
|
4
|
+
export type { SkillMeta, SkillContent, SkillsConfig, SkillRequirements } from './types.js';
|
|
5
|
+
export { type ParsedSkillFrontmatter, type SkillSearchResult, discoverSkills, loadSkillContent, loadSkills, loadSkillsFromPaths, parseSkillFrontmatter, buildSkillsSystemPrompt, searchSkills, filterEligibleSkills, isSkillEligible, } from './loader.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Skills module public API.
|
|
3
|
+
*/
|
|
4
|
+
export { discoverSkills, loadSkillContent, loadSkills, loadSkillsFromPaths, parseSkillFrontmatter, buildSkillsSystemPrompt, searchSkills, filterEligibleSkills, isSkillEligible, } from './loader.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skills/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGL,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Skills discovery and loading.
|
|
3
|
+
* Scans directories for SKILL.md files, parses YAML frontmatter,
|
|
4
|
+
* and builds system prompt injections.
|
|
5
|
+
*/
|
|
6
|
+
import type { SkillMeta, SkillContent, SkillsConfig, SkillRequirements } from './types.js';
|
|
7
|
+
export interface ParsedSkillFrontmatter {
|
|
8
|
+
name?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
whenToUse?: string;
|
|
12
|
+
model?: 'fast' | 'standard' | 'reasoning' | 'powerful';
|
|
13
|
+
maxSteps?: number;
|
|
14
|
+
requires?: SkillRequirements;
|
|
15
|
+
license?: string;
|
|
16
|
+
compatibility?: string;
|
|
17
|
+
metadata?: Record<string, string>;
|
|
18
|
+
allowedTools?: string[];
|
|
19
|
+
toolsDeny?: string[];
|
|
20
|
+
extra?: Record<string, unknown>;
|
|
21
|
+
body: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse YAML frontmatter from a SKILL.md file.
|
|
25
|
+
* Accepts both native and skills.sh fields. Unknown fields are preserved in `extra`.
|
|
26
|
+
*
|
|
27
|
+
* Expects format:
|
|
28
|
+
* ---
|
|
29
|
+
* name: skill-name
|
|
30
|
+
* description: Short description
|
|
31
|
+
* license: MIT
|
|
32
|
+
* allowed-tools: [glob, grep, shell]
|
|
33
|
+
* ---
|
|
34
|
+
* ... markdown content ...
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseSkillFrontmatter(content: string): ParsedSkillFrontmatter;
|
|
37
|
+
/**
|
|
38
|
+
* Discover SKILL.md files in the given directories.
|
|
39
|
+
* Returns metadata for each discovered skill.
|
|
40
|
+
*/
|
|
41
|
+
export declare function discoverSkills(directories?: string[], basePath?: string): SkillMeta[];
|
|
42
|
+
/**
|
|
43
|
+
* Load the full content of a skill, including the markdown body.
|
|
44
|
+
*/
|
|
45
|
+
export declare function loadSkillContent(meta: SkillMeta): SkillContent;
|
|
46
|
+
/**
|
|
47
|
+
* Load skills based on configuration.
|
|
48
|
+
* Supports both explicit paths and auto-discovery.
|
|
49
|
+
*/
|
|
50
|
+
export declare function loadSkills(config: SkillsConfig, basePath?: string): SkillContent[];
|
|
51
|
+
/**
|
|
52
|
+
* Load skills from explicit directory paths (each path IS the skill directory).
|
|
53
|
+
*/
|
|
54
|
+
export declare function loadSkillsFromPaths(paths: string[]): SkillContent[];
|
|
55
|
+
/**
|
|
56
|
+
* Build a system prompt section from loaded skills.
|
|
57
|
+
* Injects skill descriptions and instructions for the LLM.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildSkillsSystemPrompt(skills: SkillContent[]): string;
|
|
60
|
+
/** A skill search result with relevance score. */
|
|
61
|
+
export interface SkillSearchResult {
|
|
62
|
+
skill: SkillMeta;
|
|
63
|
+
score: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Search skills by keyword against name, description, tags, and whenToUse.
|
|
67
|
+
* Returns top matches ranked by relevance score.
|
|
68
|
+
*/
|
|
69
|
+
export declare function searchSkills(skills: SkillMeta[], query: string, limit?: number): SkillSearchResult[];
|
|
70
|
+
/**
|
|
71
|
+
* Filter skills to only those whose runtime requirements are met.
|
|
72
|
+
*
|
|
73
|
+
* Checks:
|
|
74
|
+
* - `requires.binaries`: each binary is found on PATH
|
|
75
|
+
* - `requires.env`: each env var is defined in process.env
|
|
76
|
+
*
|
|
77
|
+
* Skills with no requirements are always eligible.
|
|
78
|
+
*/
|
|
79
|
+
export declare function filterEligibleSkills(skills: SkillMeta[]): SkillMeta[];
|
|
80
|
+
/**
|
|
81
|
+
* Check if a single skill's runtime requirements are met.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isSkillEligible(skill: SkillMeta): boolean;
|
|
84
|
+
//# sourceMappingURL=loader.d.ts.map
|