@agentforge/core 0.12.6 → 0.14.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/dist/index.cjs +898 -28
- package/dist/index.d.cts +685 -2
- package/dist/index.d.ts +685 -2
- package/dist/index.js +881 -28
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,12 @@ declare enum ToolCategory {
|
|
|
58
58
|
* Custom/user-defined tools
|
|
59
59
|
* Use this for tools that don't fit other categories
|
|
60
60
|
*/
|
|
61
|
-
CUSTOM = "custom"
|
|
61
|
+
CUSTOM = "custom",
|
|
62
|
+
/**
|
|
63
|
+
* Tools for Agent Skills activation and resource loading
|
|
64
|
+
* Examples: activate-skill, read-skill-resource
|
|
65
|
+
*/
|
|
66
|
+
SKILLS = "skills"
|
|
62
67
|
}
|
|
63
68
|
/**
|
|
64
69
|
* ToolExample - Example usage of a tool
|
|
@@ -5477,4 +5482,682 @@ declare function renderTemplate(template: string, options: RenderTemplateOptions
|
|
|
5477
5482
|
*/
|
|
5478
5483
|
declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | Record<string, any>, promptsDir?: string): string;
|
|
5479
5484
|
|
|
5480
|
-
|
|
5485
|
+
/**
|
|
5486
|
+
* Skill System Types
|
|
5487
|
+
*
|
|
5488
|
+
* Core type definitions for the AgentForge Agent Skills system.
|
|
5489
|
+
* These types align with the Agent Skills specification (https://agentskills.io/specification).
|
|
5490
|
+
*/
|
|
5491
|
+
/**
|
|
5492
|
+
* Trust level for a skill root directory.
|
|
5493
|
+
*
|
|
5494
|
+
* - `workspace` — Skills from the project workspace (highest trust, scripts allowed)
|
|
5495
|
+
* - `trusted` — Explicitly trusted skill roots (scripts allowed)
|
|
5496
|
+
* - `untrusted` — Untrusted roots like community packs (scripts blocked by default)
|
|
5497
|
+
*/
|
|
5498
|
+
type TrustLevel = 'workspace' | 'trusted' | 'untrusted';
|
|
5499
|
+
/**
|
|
5500
|
+
* Configuration for a skill root with an explicit trust level.
|
|
5501
|
+
*
|
|
5502
|
+
* @example
|
|
5503
|
+
* ```ts
|
|
5504
|
+
* const roots: SkillRootConfig[] = [
|
|
5505
|
+
* { path: '.agentskills', trust: 'workspace' },
|
|
5506
|
+
* { path: '~/.agentskills', trust: 'trusted' },
|
|
5507
|
+
* { path: '/shared/community-skills', trust: 'untrusted' },
|
|
5508
|
+
* ];
|
|
5509
|
+
* ```
|
|
5510
|
+
*/
|
|
5511
|
+
interface SkillRootConfig {
|
|
5512
|
+
/** Directory path to scan for skills */
|
|
5513
|
+
path: string;
|
|
5514
|
+
/** Trust level assigned to all skills discovered from this root */
|
|
5515
|
+
trust: TrustLevel;
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* Policy decision returned by trust enforcement checks.
|
|
5519
|
+
*/
|
|
5520
|
+
interface TrustPolicyDecision {
|
|
5521
|
+
/** Whether the action is allowed */
|
|
5522
|
+
allowed: boolean;
|
|
5523
|
+
/** Machine-readable reason code for auditing */
|
|
5524
|
+
reason: TrustPolicyReason;
|
|
5525
|
+
/** Human-readable explanation */
|
|
5526
|
+
message: string;
|
|
5527
|
+
}
|
|
5528
|
+
/**
|
|
5529
|
+
* Reason codes for trust policy decisions.
|
|
5530
|
+
*
|
|
5531
|
+
* Used for structured logging and auditing of guardrail behavior.
|
|
5532
|
+
*/
|
|
5533
|
+
declare enum TrustPolicyReason {
|
|
5534
|
+
/** Resource is not a script — no trust check needed */
|
|
5535
|
+
NOT_SCRIPT = "not-script",
|
|
5536
|
+
/** Skill root has workspace trust — scripts allowed */
|
|
5537
|
+
WORKSPACE_TRUST = "workspace-trust",
|
|
5538
|
+
/** Skill root has explicit trusted status — scripts allowed */
|
|
5539
|
+
TRUSTED_ROOT = "trusted-root",
|
|
5540
|
+
/** Skill root is untrusted — scripts denied by default */
|
|
5541
|
+
UNTRUSTED_SCRIPT_DENIED = "untrusted-script-denied",
|
|
5542
|
+
/** Untrusted script access was explicitly allowed via config override */
|
|
5543
|
+
UNTRUSTED_SCRIPT_ALLOWED = "untrusted-script-allowed-override",
|
|
5544
|
+
/** Trust level is unknown — treated as untrusted for security */
|
|
5545
|
+
UNKNOWN_TRUST_LEVEL = "unknown-trust-level"
|
|
5546
|
+
}
|
|
5547
|
+
/**
|
|
5548
|
+
* Parsed metadata from a SKILL.md frontmatter block.
|
|
5549
|
+
*
|
|
5550
|
+
* Required fields: `name`, `description`.
|
|
5551
|
+
* All other fields are optional per the Agent Skills spec.
|
|
5552
|
+
*/
|
|
5553
|
+
interface SkillMetadata {
|
|
5554
|
+
/** Skill name (1-64 chars, lowercase alphanumeric + hyphens, must match parent dir name) */
|
|
5555
|
+
name: string;
|
|
5556
|
+
/** Human-readable description (1-1024 chars) */
|
|
5557
|
+
description: string;
|
|
5558
|
+
/** SPDX license identifier */
|
|
5559
|
+
license?: string;
|
|
5560
|
+
/** List of compatible agent frameworks / tool hosts */
|
|
5561
|
+
compatibility?: string[];
|
|
5562
|
+
/** Arbitrary key-value metadata (author, version, etc.) */
|
|
5563
|
+
metadata?: Record<string, unknown>;
|
|
5564
|
+
/** Tools that this skill is allowed to use */
|
|
5565
|
+
allowedTools?: string[];
|
|
5566
|
+
}
|
|
5567
|
+
/**
|
|
5568
|
+
* A fully resolved skill entry in the registry.
|
|
5569
|
+
*
|
|
5570
|
+
* Contains parsed metadata plus internal tracking fields
|
|
5571
|
+
* that are not part of the SKILL.md frontmatter.
|
|
5572
|
+
*/
|
|
5573
|
+
interface Skill {
|
|
5574
|
+
/** Parsed frontmatter metadata */
|
|
5575
|
+
metadata: SkillMetadata;
|
|
5576
|
+
/** Absolute path to the skill directory */
|
|
5577
|
+
skillPath: string;
|
|
5578
|
+
/** Which configured skill root this was discovered from */
|
|
5579
|
+
rootPath: string;
|
|
5580
|
+
/** Trust level assigned to this skill (inherited from root config) */
|
|
5581
|
+
trustLevel: TrustLevel;
|
|
5582
|
+
}
|
|
5583
|
+
/**
|
|
5584
|
+
* Configuration for the SkillRegistry.
|
|
5585
|
+
*/
|
|
5586
|
+
interface SkillRegistryConfig {
|
|
5587
|
+
/**
|
|
5588
|
+
* Array of directory paths to scan for skills.
|
|
5589
|
+
*
|
|
5590
|
+
* Each entry can be a plain string (defaults to `'untrusted'` trust level)
|
|
5591
|
+
* or a `SkillRootConfig` object with an explicit trust level.
|
|
5592
|
+
*
|
|
5593
|
+
* Paths may be absolute or relative (resolved against `cwd`).
|
|
5594
|
+
* The `~` prefix is expanded to `$HOME`.
|
|
5595
|
+
*
|
|
5596
|
+
* @example
|
|
5597
|
+
* ```ts
|
|
5598
|
+
* // Simple string roots (default to 'untrusted')
|
|
5599
|
+
* skillRoots: ['.agentskills', '~/.agentskills']
|
|
5600
|
+
*
|
|
5601
|
+
* // Trust-aware roots
|
|
5602
|
+
* skillRoots: [
|
|
5603
|
+
* { path: '.agentskills', trust: 'workspace' },
|
|
5604
|
+
* { path: '~/.agentskills', trust: 'trusted' },
|
|
5605
|
+
* { path: '/shared/community', trust: 'untrusted' },
|
|
5606
|
+
* ]
|
|
5607
|
+
* ```
|
|
5608
|
+
*/
|
|
5609
|
+
skillRoots: Array<string | SkillRootConfig>;
|
|
5610
|
+
/**
|
|
5611
|
+
* Feature flag to enable Agent Skills in system prompts.
|
|
5612
|
+
*
|
|
5613
|
+
* When `false` (default), `generatePrompt()` returns an empty string
|
|
5614
|
+
* so agents operate with unmodified system prompts.
|
|
5615
|
+
*
|
|
5616
|
+
* @default false
|
|
5617
|
+
*/
|
|
5618
|
+
enabled?: boolean;
|
|
5619
|
+
/**
|
|
5620
|
+
* Maximum number of skills to include in generated prompts.
|
|
5621
|
+
*
|
|
5622
|
+
* Caps prompt token usage when many skills are discovered.
|
|
5623
|
+
* Skills are included in discovery order (first root first).
|
|
5624
|
+
* When undefined, all discovered skills are included.
|
|
5625
|
+
*/
|
|
5626
|
+
maxDiscoveredSkills?: number;
|
|
5627
|
+
/**
|
|
5628
|
+
* Allow script resources from untrusted roots.
|
|
5629
|
+
*
|
|
5630
|
+
* When `true`, scripts from `scripts/` directories in untrusted
|
|
5631
|
+
* skill roots are returned instead of being denied. This disables
|
|
5632
|
+
* the default-deny policy for untrusted scripts.
|
|
5633
|
+
*
|
|
5634
|
+
* **Security warning:** Only enable when you have reviewed all
|
|
5635
|
+
* skill packs from untrusted roots.
|
|
5636
|
+
*
|
|
5637
|
+
* @default false
|
|
5638
|
+
*/
|
|
5639
|
+
allowUntrustedScripts?: boolean;
|
|
5640
|
+
}
|
|
5641
|
+
/**
|
|
5642
|
+
* Options for `SkillRegistry.generatePrompt()`.
|
|
5643
|
+
*/
|
|
5644
|
+
interface SkillPromptOptions {
|
|
5645
|
+
/**
|
|
5646
|
+
* Subset of skill names to include in the generated prompt.
|
|
5647
|
+
*
|
|
5648
|
+
* When provided, only skills matching these names appear in the
|
|
5649
|
+
* `<available_skills>` XML block. This enables creating focused
|
|
5650
|
+
* agents with different skill sets from the same registry.
|
|
5651
|
+
*
|
|
5652
|
+
* When omitted or empty, all discovered skills are included.
|
|
5653
|
+
*
|
|
5654
|
+
* @example ['code-review', 'testing-strategy']
|
|
5655
|
+
*/
|
|
5656
|
+
skills?: string[];
|
|
5657
|
+
}
|
|
5658
|
+
/**
|
|
5659
|
+
* Events emitted by the SkillRegistry during discovery and usage.
|
|
5660
|
+
*/
|
|
5661
|
+
declare enum SkillRegistryEvent {
|
|
5662
|
+
/** Emitted when a valid skill is discovered during scanning */
|
|
5663
|
+
SKILL_DISCOVERED = "skill:discovered",
|
|
5664
|
+
/** Emitted when a skill parse or validation issue is encountered */
|
|
5665
|
+
SKILL_WARNING = "skill:warning",
|
|
5666
|
+
/** Emitted when a skill is activated (full body loaded) */
|
|
5667
|
+
SKILL_ACTIVATED = "skill:activated",
|
|
5668
|
+
/** Emitted when a skill resource file is loaded */
|
|
5669
|
+
SKILL_RESOURCE_LOADED = "skill:resource-loaded",
|
|
5670
|
+
/** Emitted when a trust policy denies access to a resource */
|
|
5671
|
+
TRUST_POLICY_DENIED = "trust:policy-denied",
|
|
5672
|
+
/** Emitted when a trust policy allows access (for auditing) */
|
|
5673
|
+
TRUST_POLICY_ALLOWED = "trust:policy-allowed"
|
|
5674
|
+
}
|
|
5675
|
+
/**
|
|
5676
|
+
* Event handler type for skill registry events.
|
|
5677
|
+
*/
|
|
5678
|
+
type SkillEventHandler = (data: unknown) => void;
|
|
5679
|
+
/**
|
|
5680
|
+
* Result of parsing a single SKILL.md file.
|
|
5681
|
+
*/
|
|
5682
|
+
interface SkillParseResult {
|
|
5683
|
+
/** Whether parsing and validation succeeded */
|
|
5684
|
+
success: boolean;
|
|
5685
|
+
/** Parsed metadata (present when success is true) */
|
|
5686
|
+
metadata?: SkillMetadata;
|
|
5687
|
+
/** The raw markdown body below the frontmatter (present when success is true) */
|
|
5688
|
+
body?: string;
|
|
5689
|
+
/** Error description (present when success is false) */
|
|
5690
|
+
error?: string;
|
|
5691
|
+
}
|
|
5692
|
+
/**
|
|
5693
|
+
* Validation error detail.
|
|
5694
|
+
*/
|
|
5695
|
+
interface SkillValidationError {
|
|
5696
|
+
/** Which field failed validation */
|
|
5697
|
+
field: string;
|
|
5698
|
+
/** Human-readable error message */
|
|
5699
|
+
message: string;
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
/**
|
|
5703
|
+
* SKILL.md Frontmatter Parser
|
|
5704
|
+
*
|
|
5705
|
+
* Parses YAML frontmatter from SKILL.md files and validates
|
|
5706
|
+
* against the Agent Skills specification constraints.
|
|
5707
|
+
*
|
|
5708
|
+
* @see https://agentskills.io/specification
|
|
5709
|
+
*/
|
|
5710
|
+
|
|
5711
|
+
/**
|
|
5712
|
+
* Validate the `name` field per the Agent Skills spec.
|
|
5713
|
+
*
|
|
5714
|
+
* @param name - The name value from frontmatter
|
|
5715
|
+
* @returns Array of validation errors (empty = valid)
|
|
5716
|
+
*/
|
|
5717
|
+
declare function validateSkillName(name: unknown): SkillValidationError[];
|
|
5718
|
+
/**
|
|
5719
|
+
* Validate the `description` field per the Agent Skills spec.
|
|
5720
|
+
*
|
|
5721
|
+
* @param description - The description value from frontmatter
|
|
5722
|
+
* @returns Array of validation errors (empty = valid)
|
|
5723
|
+
*/
|
|
5724
|
+
declare function validateSkillDescription(description: unknown): SkillValidationError[];
|
|
5725
|
+
/**
|
|
5726
|
+
* Validate that the skill name matches its parent directory name (per spec).
|
|
5727
|
+
*
|
|
5728
|
+
* @param name - The name from frontmatter
|
|
5729
|
+
* @param dirName - The parent directory name
|
|
5730
|
+
* @returns Array of validation errors (empty = valid)
|
|
5731
|
+
*/
|
|
5732
|
+
declare function validateSkillNameMatchesDir(name: string, dirName: string): SkillValidationError[];
|
|
5733
|
+
/**
|
|
5734
|
+
* Parse and validate a SKILL.md file's raw content.
|
|
5735
|
+
*
|
|
5736
|
+
* Extracts YAML frontmatter using gray-matter, then validates
|
|
5737
|
+
* required and optional fields against spec constraints.
|
|
5738
|
+
*
|
|
5739
|
+
* @param content - Raw file content of the SKILL.md
|
|
5740
|
+
* @param dirName - Parent directory name for name-match validation
|
|
5741
|
+
* @returns Parse result with metadata or error
|
|
5742
|
+
*/
|
|
5743
|
+
declare function parseSkillContent(content: string, dirName: string): SkillParseResult;
|
|
5744
|
+
|
|
5745
|
+
/**
|
|
5746
|
+
* Skill Directory Scanner
|
|
5747
|
+
*
|
|
5748
|
+
* Scans configured skill roots for directories containing valid SKILL.md files.
|
|
5749
|
+
* Returns a list of candidate skill paths for the parser to process.
|
|
5750
|
+
*/
|
|
5751
|
+
/**
|
|
5752
|
+
* Discovered skill candidate — a directory containing a SKILL.md file.
|
|
5753
|
+
*/
|
|
5754
|
+
interface SkillCandidate {
|
|
5755
|
+
/** Absolute path to the skill directory */
|
|
5756
|
+
skillPath: string;
|
|
5757
|
+
/** The parent directory name (expected to match the skill name) */
|
|
5758
|
+
dirName: string;
|
|
5759
|
+
/** Raw content of the SKILL.md file */
|
|
5760
|
+
content: string;
|
|
5761
|
+
/** Which configured root this came from */
|
|
5762
|
+
rootPath: string;
|
|
5763
|
+
}
|
|
5764
|
+
/**
|
|
5765
|
+
* Expand `~` prefix to the user's home directory.
|
|
5766
|
+
*/
|
|
5767
|
+
declare function expandHome(p: string): string;
|
|
5768
|
+
/**
|
|
5769
|
+
* Scan a single skill root for directories containing SKILL.md.
|
|
5770
|
+
*
|
|
5771
|
+
* @param rootPath - The root directory to scan (may not exist)
|
|
5772
|
+
* @returns Array of valid skill candidates found under this root
|
|
5773
|
+
*/
|
|
5774
|
+
declare function scanSkillRoot(rootPath: string): SkillCandidate[];
|
|
5775
|
+
/**
|
|
5776
|
+
* Scan multiple skill roots for directories containing SKILL.md.
|
|
5777
|
+
*
|
|
5778
|
+
* @param skillRoots - Array of root paths to scan
|
|
5779
|
+
* @returns Array of all skill candidates found across all roots
|
|
5780
|
+
*/
|
|
5781
|
+
declare function scanAllSkillRoots(skillRoots: string[]): SkillCandidate[];
|
|
5782
|
+
|
|
5783
|
+
/**
|
|
5784
|
+
* Skill Activation Tools
|
|
5785
|
+
*
|
|
5786
|
+
* Provides `activate-skill` and `read-skill-resource` tools built with
|
|
5787
|
+
* the AgentForge tool builder API. These tools enable agents to load
|
|
5788
|
+
* skill instructions on demand and access skill resources at runtime.
|
|
5789
|
+
*
|
|
5790
|
+
* @see https://agentskills.io/specification
|
|
5791
|
+
*
|
|
5792
|
+
* @example
|
|
5793
|
+
* ```ts
|
|
5794
|
+
* const [activateSkill, readSkillResource] = createSkillActivationTools(registry);
|
|
5795
|
+
* // activateSkill — load full SKILL.md body
|
|
5796
|
+
* // readSkillResource — load a resource file from a skill
|
|
5797
|
+
*
|
|
5798
|
+
* // Or use the convenience method:
|
|
5799
|
+
* const [activateSkill, readSkillResource] = registry.toActivationTools();
|
|
5800
|
+
* ```
|
|
5801
|
+
*/
|
|
5802
|
+
|
|
5803
|
+
declare const activateSkillSchema: z.ZodObject<{
|
|
5804
|
+
name: z.ZodString;
|
|
5805
|
+
}, "strip", z.ZodTypeAny, {
|
|
5806
|
+
name: string;
|
|
5807
|
+
}, {
|
|
5808
|
+
name: string;
|
|
5809
|
+
}>;
|
|
5810
|
+
declare const readSkillResourceSchema: z.ZodObject<{
|
|
5811
|
+
name: z.ZodString;
|
|
5812
|
+
path: z.ZodString;
|
|
5813
|
+
}, "strip", z.ZodTypeAny, {
|
|
5814
|
+
path: string;
|
|
5815
|
+
name: string;
|
|
5816
|
+
}, {
|
|
5817
|
+
path: string;
|
|
5818
|
+
name: string;
|
|
5819
|
+
}>;
|
|
5820
|
+
/**
|
|
5821
|
+
* Resolve a resource path within a skill root, blocking path traversal.
|
|
5822
|
+
*
|
|
5823
|
+
* @param skillPath - Absolute path to the skill directory
|
|
5824
|
+
* @param resourcePath - Relative path to the resource file
|
|
5825
|
+
* @returns Absolute path to the resource, or an error string
|
|
5826
|
+
*/
|
|
5827
|
+
declare function resolveResourcePath(skillPath: string, resourcePath: string): {
|
|
5828
|
+
success: true;
|
|
5829
|
+
resolvedPath: string;
|
|
5830
|
+
} | {
|
|
5831
|
+
success: false;
|
|
5832
|
+
error: string;
|
|
5833
|
+
};
|
|
5834
|
+
/**
|
|
5835
|
+
* Create the `activate-skill` tool bound to a registry instance.
|
|
5836
|
+
*
|
|
5837
|
+
* Resolves the skill by name, reads the full SKILL.md file, and returns
|
|
5838
|
+
* the body content (below frontmatter).
|
|
5839
|
+
*
|
|
5840
|
+
* @param registry - The SkillRegistry to resolve skills from
|
|
5841
|
+
* @returns An AgentForge Tool
|
|
5842
|
+
*/
|
|
5843
|
+
declare function createActivateSkillTool(registry: SkillRegistry): Tool<z.infer<typeof activateSkillSchema>, string>;
|
|
5844
|
+
/**
|
|
5845
|
+
* Create the `read-skill-resource` tool bound to a registry instance.
|
|
5846
|
+
*
|
|
5847
|
+
* Resolves the skill by name, validates the resource path (blocking
|
|
5848
|
+
* traversal), and returns the file content.
|
|
5849
|
+
*
|
|
5850
|
+
* @param registry - The SkillRegistry to resolve skills from
|
|
5851
|
+
* @returns An AgentForge Tool
|
|
5852
|
+
*/
|
|
5853
|
+
declare function createReadSkillResourceTool(registry: SkillRegistry): Tool<z.infer<typeof readSkillResourceSchema>, string>;
|
|
5854
|
+
/**
|
|
5855
|
+
* Create both skill activation tools bound to a registry instance.
|
|
5856
|
+
*
|
|
5857
|
+
* @param registry - The SkillRegistry to bind tools to
|
|
5858
|
+
* @returns Array of both tools [activate-skill, read-skill-resource]
|
|
5859
|
+
*/
|
|
5860
|
+
declare function createSkillActivationTools(registry: SkillRegistry): [Tool<z.infer<typeof activateSkillSchema>, string>, Tool<z.infer<typeof readSkillResourceSchema>, string>];
|
|
5861
|
+
|
|
5862
|
+
/**
|
|
5863
|
+
* Skill Registry
|
|
5864
|
+
*
|
|
5865
|
+
* Central registry for discovering, storing, and querying Agent Skills.
|
|
5866
|
+
* Mirrors ToolRegistry but uses folder-based auto-discovery instead
|
|
5867
|
+
* of programmatic registration.
|
|
5868
|
+
*
|
|
5869
|
+
* @see https://agentskills.io/specification
|
|
5870
|
+
*
|
|
5871
|
+
* @example
|
|
5872
|
+
* ```ts
|
|
5873
|
+
* const registry = new SkillRegistry({
|
|
5874
|
+
* skillRoots: ['.agentskills', '~/.agentskills'],
|
|
5875
|
+
* });
|
|
5876
|
+
*
|
|
5877
|
+
* // Query discovered skills
|
|
5878
|
+
* const skill = registry.get('code-review');
|
|
5879
|
+
* const allSkills = registry.getAll();
|
|
5880
|
+
*
|
|
5881
|
+
* // Listen for events
|
|
5882
|
+
* registry.on(SkillRegistryEvent.SKILL_DISCOVERED, (skill) => {
|
|
5883
|
+
* console.log('Found skill:', skill.metadata.name);
|
|
5884
|
+
* });
|
|
5885
|
+
* ```
|
|
5886
|
+
*/
|
|
5887
|
+
|
|
5888
|
+
/**
|
|
5889
|
+
* Skill Registry — auto-discovers skills from configured folder paths.
|
|
5890
|
+
*
|
|
5891
|
+
* Parallel to ToolRegistry:
|
|
5892
|
+
* | ToolRegistry | SkillRegistry |
|
|
5893
|
+
* |--------------------------|------------------------------------------|
|
|
5894
|
+
* | registry.register(tool) | new SkillRegistry({ skillRoots }) |
|
|
5895
|
+
* | registry.get('name') | skillRegistry.get('name') |
|
|
5896
|
+
* | registry.getAll() | skillRegistry.getAll() |
|
|
5897
|
+
* | registry.has('name') | skillRegistry.has('name') |
|
|
5898
|
+
* | registry.size() | skillRegistry.size() |
|
|
5899
|
+
* | registry.generatePrompt()| skillRegistry.generatePrompt() |
|
|
5900
|
+
* | registry.toLangChainTools()| skillRegistry.toActivationTools() |
|
|
5901
|
+
*/
|
|
5902
|
+
declare class SkillRegistry {
|
|
5903
|
+
private skills;
|
|
5904
|
+
private eventHandlers;
|
|
5905
|
+
private readonly config;
|
|
5906
|
+
private scanErrors;
|
|
5907
|
+
/** Maps resolved root paths → trust levels for skill trust assignment */
|
|
5908
|
+
private rootTrustMap;
|
|
5909
|
+
/**
|
|
5910
|
+
* Create a SkillRegistry and immediately scan configured roots for skills.
|
|
5911
|
+
*
|
|
5912
|
+
* @param config - Registry configuration with skill root paths
|
|
5913
|
+
*
|
|
5914
|
+
* @example
|
|
5915
|
+
* ```ts
|
|
5916
|
+
* const registry = new SkillRegistry({
|
|
5917
|
+
* skillRoots: ['.agentskills', '~/.agentskills', './project-skills'],
|
|
5918
|
+
* });
|
|
5919
|
+
* console.log(`Discovered ${registry.size()} skills`);
|
|
5920
|
+
* ```
|
|
5921
|
+
*/
|
|
5922
|
+
constructor(config: SkillRegistryConfig);
|
|
5923
|
+
/**
|
|
5924
|
+
* Scan all configured roots and populate the registry.
|
|
5925
|
+
*
|
|
5926
|
+
* Called automatically during construction. Can be called again
|
|
5927
|
+
* to re-scan (clears existing skills first).
|
|
5928
|
+
*/
|
|
5929
|
+
discover(): void;
|
|
5930
|
+
/**
|
|
5931
|
+
* Get a skill by name.
|
|
5932
|
+
*
|
|
5933
|
+
* @param name - The skill name
|
|
5934
|
+
* @returns The skill, or undefined if not found
|
|
5935
|
+
*
|
|
5936
|
+
* @example
|
|
5937
|
+
* ```ts
|
|
5938
|
+
* const skill = registry.get('code-review');
|
|
5939
|
+
* if (skill) {
|
|
5940
|
+
* console.log(skill.metadata.description);
|
|
5941
|
+
* }
|
|
5942
|
+
* ```
|
|
5943
|
+
*/
|
|
5944
|
+
get(name: string): Skill | undefined;
|
|
5945
|
+
/**
|
|
5946
|
+
* Get all discovered skills.
|
|
5947
|
+
*
|
|
5948
|
+
* @returns Array of all skills
|
|
5949
|
+
*
|
|
5950
|
+
* @example
|
|
5951
|
+
* ```ts
|
|
5952
|
+
* const allSkills = registry.getAll();
|
|
5953
|
+
* console.log(`Total skills: ${allSkills.length}`);
|
|
5954
|
+
* ```
|
|
5955
|
+
*/
|
|
5956
|
+
getAll(): Skill[];
|
|
5957
|
+
/**
|
|
5958
|
+
* Check if a skill exists in the registry.
|
|
5959
|
+
*
|
|
5960
|
+
* @param name - The skill name
|
|
5961
|
+
* @returns True if the skill exists
|
|
5962
|
+
*
|
|
5963
|
+
* @example
|
|
5964
|
+
* ```ts
|
|
5965
|
+
* if (registry.has('code-review')) {
|
|
5966
|
+
* console.log('Skill available!');
|
|
5967
|
+
* }
|
|
5968
|
+
* ```
|
|
5969
|
+
*/
|
|
5970
|
+
has(name: string): boolean;
|
|
5971
|
+
/**
|
|
5972
|
+
* Get the number of discovered skills.
|
|
5973
|
+
*
|
|
5974
|
+
* @returns Number of skills in the registry
|
|
5975
|
+
*
|
|
5976
|
+
* @example
|
|
5977
|
+
* ```ts
|
|
5978
|
+
* console.log(`Registry has ${registry.size()} skills`);
|
|
5979
|
+
* ```
|
|
5980
|
+
*/
|
|
5981
|
+
size(): number;
|
|
5982
|
+
/**
|
|
5983
|
+
* Get all skill names.
|
|
5984
|
+
*
|
|
5985
|
+
* @returns Array of skill names
|
|
5986
|
+
*/
|
|
5987
|
+
getNames(): string[];
|
|
5988
|
+
/**
|
|
5989
|
+
* Get errors/warnings from the last scan.
|
|
5990
|
+
*
|
|
5991
|
+
* Useful for diagnostics and observability.
|
|
5992
|
+
*
|
|
5993
|
+
* @returns Array of scan errors with paths
|
|
5994
|
+
*/
|
|
5995
|
+
getScanErrors(): ReadonlyArray<{
|
|
5996
|
+
path: string;
|
|
5997
|
+
error: string;
|
|
5998
|
+
}>;
|
|
5999
|
+
/**
|
|
6000
|
+
* Check whether untrusted script access is allowed via config override.
|
|
6001
|
+
*
|
|
6002
|
+
* Used by activation tools to pass the override flag to trust policy checks.
|
|
6003
|
+
*
|
|
6004
|
+
* @returns True if `allowUntrustedScripts` is set in config
|
|
6005
|
+
*/
|
|
6006
|
+
getAllowUntrustedScripts(): boolean;
|
|
6007
|
+
/**
|
|
6008
|
+
* Get the `allowed-tools` list for a skill.
|
|
6009
|
+
*
|
|
6010
|
+
* Returns the `allowedTools` array from the skill's frontmatter metadata,
|
|
6011
|
+
* enabling agents to filter their tool set based on what the skill expects.
|
|
6012
|
+
*
|
|
6013
|
+
* @param name - The skill name
|
|
6014
|
+
* @returns Array of allowed tool names, or undefined if skill not found or field not set
|
|
6015
|
+
*
|
|
6016
|
+
* @example
|
|
6017
|
+
* ```ts
|
|
6018
|
+
* const allowed = registry.getAllowedTools('code-review');
|
|
6019
|
+
* if (allowed) {
|
|
6020
|
+
* const filteredTools = allTools.filter(t => allowed.includes(t.name));
|
|
6021
|
+
* }
|
|
6022
|
+
* ```
|
|
6023
|
+
*/
|
|
6024
|
+
getAllowedTools(name: string): string[] | undefined;
|
|
6025
|
+
/**
|
|
6026
|
+
* Generate an `<available_skills>` XML block for system prompt injection.
|
|
6027
|
+
*
|
|
6028
|
+
* Returns an empty string when:
|
|
6029
|
+
* - `config.enabled` is `false` (default) — agents operate with unmodified prompts
|
|
6030
|
+
* - No skills match the filter criteria
|
|
6031
|
+
*
|
|
6032
|
+
* The output composes naturally with `toolRegistry.generatePrompt()` —
|
|
6033
|
+
* simply concatenate both into the system prompt.
|
|
6034
|
+
*
|
|
6035
|
+
* @param options - Optional filtering (subset of skill names)
|
|
6036
|
+
* @returns XML string or empty string
|
|
6037
|
+
*
|
|
6038
|
+
* @example
|
|
6039
|
+
* ```ts
|
|
6040
|
+
* // All skills
|
|
6041
|
+
* const xml = registry.generatePrompt();
|
|
6042
|
+
*
|
|
6043
|
+
* // Subset for a focused agent
|
|
6044
|
+
* const xml = registry.generatePrompt({ skills: ['code-review', 'testing'] });
|
|
6045
|
+
*
|
|
6046
|
+
* // Compose with tool prompt
|
|
6047
|
+
* const systemPrompt = [
|
|
6048
|
+
* toolRegistry.generatePrompt(),
|
|
6049
|
+
* skillRegistry.generatePrompt(),
|
|
6050
|
+
* ].filter(Boolean).join('\n\n');
|
|
6051
|
+
* ```
|
|
6052
|
+
*/
|
|
6053
|
+
generatePrompt(options?: SkillPromptOptions): string;
|
|
6054
|
+
/**
|
|
6055
|
+
* Register an event handler.
|
|
6056
|
+
*
|
|
6057
|
+
* @param event - The event to listen for
|
|
6058
|
+
* @param handler - The handler function
|
|
6059
|
+
*
|
|
6060
|
+
* @example
|
|
6061
|
+
* ```ts
|
|
6062
|
+
* registry.on(SkillRegistryEvent.SKILL_DISCOVERED, (skill) => {
|
|
6063
|
+
* console.log('Found skill:', skill.metadata.name);
|
|
6064
|
+
* });
|
|
6065
|
+
* ```
|
|
6066
|
+
*/
|
|
6067
|
+
on(event: SkillRegistryEvent, handler: SkillEventHandler): void;
|
|
6068
|
+
/**
|
|
6069
|
+
* Unregister an event handler.
|
|
6070
|
+
*
|
|
6071
|
+
* @param event - The event to stop listening for
|
|
6072
|
+
* @param handler - The handler function to remove
|
|
6073
|
+
*/
|
|
6074
|
+
off(event: SkillRegistryEvent, handler: SkillEventHandler): void;
|
|
6075
|
+
/**
|
|
6076
|
+
* Emit an event to all registered handlers.
|
|
6077
|
+
*
|
|
6078
|
+
* @param event - The event to emit
|
|
6079
|
+
* @param data - The event data
|
|
6080
|
+
* @private
|
|
6081
|
+
*/
|
|
6082
|
+
private emit;
|
|
6083
|
+
/**
|
|
6084
|
+
* Emit an event (public API for activation tools).
|
|
6085
|
+
*
|
|
6086
|
+
* Used by skill activation tools to emit `skill:activated` and
|
|
6087
|
+
* `skill:resource-loaded` events through the registry's event system.
|
|
6088
|
+
*
|
|
6089
|
+
* @param event - The event to emit
|
|
6090
|
+
* @param data - The event data
|
|
6091
|
+
*/
|
|
6092
|
+
emitEvent(event: SkillRegistryEvent, data: unknown): void;
|
|
6093
|
+
/**
|
|
6094
|
+
* Create activation tools pre-wired to this registry instance.
|
|
6095
|
+
*
|
|
6096
|
+
* Returns `activate-skill` and `read-skill-resource` tools that
|
|
6097
|
+
* agents can use to load skill instructions and resources on demand.
|
|
6098
|
+
*
|
|
6099
|
+
* @returns Array of [activate-skill, read-skill-resource] tools
|
|
6100
|
+
*
|
|
6101
|
+
* @example
|
|
6102
|
+
* ```ts
|
|
6103
|
+
* const agent = createReActAgent({
|
|
6104
|
+
* model: llm,
|
|
6105
|
+
* tools: [
|
|
6106
|
+
* ...toolRegistry.toLangChainTools(),
|
|
6107
|
+
* ...skillRegistry.toActivationTools(),
|
|
6108
|
+
* ],
|
|
6109
|
+
* });
|
|
6110
|
+
* ```
|
|
6111
|
+
*/
|
|
6112
|
+
toActivationTools(): ReturnType<typeof createSkillActivationTools>;
|
|
6113
|
+
}
|
|
6114
|
+
|
|
6115
|
+
/**
|
|
6116
|
+
* Skill Trust Policy Engine
|
|
6117
|
+
*
|
|
6118
|
+
* Enforces trust-level-based access control for skill resources.
|
|
6119
|
+
* Scripts from untrusted roots are denied by default unless explicitly allowed.
|
|
6120
|
+
*
|
|
6121
|
+
* Trust levels:
|
|
6122
|
+
* - `workspace` — Project-local skills, highest trust. Scripts always allowed.
|
|
6123
|
+
* - `trusted` — Explicitly trusted roots. Scripts allowed.
|
|
6124
|
+
* - `untrusted` — Community or third-party skills. Scripts denied by default.
|
|
6125
|
+
*
|
|
6126
|
+
* @see https://agentskills.io/specification
|
|
6127
|
+
*/
|
|
6128
|
+
|
|
6129
|
+
/**
|
|
6130
|
+
* Normalize a skill root config entry.
|
|
6131
|
+
*
|
|
6132
|
+
* String entries default to `'untrusted'` trust level for safe defaults.
|
|
6133
|
+
*
|
|
6134
|
+
* @param root - A string path or SkillRootConfig object
|
|
6135
|
+
* @returns Normalized SkillRootConfig with explicit trust level
|
|
6136
|
+
*/
|
|
6137
|
+
declare function normalizeRootConfig(root: string | SkillRootConfig): SkillRootConfig;
|
|
6138
|
+
/**
|
|
6139
|
+
* Check whether a resource path refers to a script.
|
|
6140
|
+
*
|
|
6141
|
+
* A resource is considered a script if its relative path starts with
|
|
6142
|
+
* `scripts/` or is exactly `scripts`, after normalizing path separators,
|
|
6143
|
+
* stripping leading "./" segments, and ignoring case.
|
|
6144
|
+
*
|
|
6145
|
+
* @param resourcePath - Relative path within the skill directory
|
|
6146
|
+
* @returns True if the resource is in the scripts/ directory
|
|
6147
|
+
*/
|
|
6148
|
+
declare function isScriptResource(resourcePath: string): boolean;
|
|
6149
|
+
/**
|
|
6150
|
+
* Evaluate the trust policy for a resource access request.
|
|
6151
|
+
*
|
|
6152
|
+
* Non-script resources are always allowed regardless of trust level.
|
|
6153
|
+
* Script resources require `workspace` or `trusted` trust, or the
|
|
6154
|
+
* `allowUntrustedScripts` override to be enabled.
|
|
6155
|
+
*
|
|
6156
|
+
* @param resourcePath - Relative path to the resource within the skill directory
|
|
6157
|
+
* @param trustLevel - Trust level of the skill's root directory
|
|
6158
|
+
* @param allowUntrustedScripts - Override flag to permit untrusted scripts
|
|
6159
|
+
* @returns Policy decision with allow/deny, reason code, and message
|
|
6160
|
+
*/
|
|
6161
|
+
declare function evaluateTrustPolicy(resourcePath: string, trustLevel: TrustLevel, allowUntrustedScripts?: boolean): TrustPolicyDecision;
|
|
6162
|
+
|
|
6163
|
+
export { AgentError, type AgentResumedEventData, type AgentWaitingEventData, type AggregateNode, type Alert, type AlertChannel, AlertManager, type AlertManagerOptions, type AlertRule, type AlertSeverity, type AnyInterrupt, type ApprovalRequiredInterrupt, type AuditLogEntry, type AuditLogQuery, AuditLogger, type AuditLoggerOptions, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CacheKeyGenerator, type CachingOptions, type CheckInterruptOptions, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConcurrencyOptions, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type CustomInterrupt, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DevelopmentPresetOptions, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type EvictionStrategy, type ExecutionMetrics, type HealthCheck, type HealthCheckConfig, type HealthCheckResult, HealthChecker, type HealthCheckerOptions, type HealthReport, type HealthStatus, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type HumanInLoopEventData, type HumanInLoopEventType, type HumanRequest, type HumanRequestEventData, type HumanRequestInterrupt, type HumanRequestPriority, type HumanRequestStatus, type HumanResponseEventData, type InterruptData, type InterruptEventData, type InterruptType, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, type LoggingOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority$1 as Priority, type ProductionPresetOptions, type ProfileReport, type ProfileSample, type ProfileStats, Profiler, type ProfilerOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type RateLimitOptions, type RateLimitStrategy, type ReducerFunction, RegistryEvent, type RenderTemplateOptions, type RequestConfig, type ResumeCommand, type ResumeEventData, type ResumeOptions, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type Skill, type SkillCandidate, type SkillEventHandler, type SkillMetadata, type SkillParseResult, type SkillPromptOptions, SkillRegistry, type SkillRegistryConfig, SkillRegistryEvent, type SkillRootConfig, type SkillValidationError, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThreadInfo, type ThreadStatus, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolHealthCheckResult, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type TrustLevel, type TrustPolicyDecision, TrustPolicyReason, type ValidationErrorHandler, type ValidationMode, type ValidationOptions, type ValidatorFunction, type WebSocketHandlerOptions, type WebSocketMessage, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createActivateSkillTool, createAlertManager, createApprovalRequiredInterrupt, createAuditLogger, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createCustomInterrupt, createDatabasePool, createErrorReporter, createHealthChecker, createHeartbeat, createHttpPool, createHumanRequestInterrupt, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProfiler, createProgressTracker, createReadSkillResourceTool, createSSEFormatter, createSequentialWorkflow, createSharedCache, createSharedConcurrencyController, createSharedRateLimiter, createSkillActivationTools, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, evaluateTrustPolicy, expandHome, filter, formatAgentResumedEvent, formatAgentWaitingEvent, formatHumanRequestEvent, formatHumanResponseEvent, formatInterruptEvent, formatResumeEvent, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getThreadStatus, getToolDescription, getToolJsonSchema, isApprovalRequiredInterrupt, isCustomInterrupt, isHumanRequestInterrupt, isMemoryCheckpointer, isScriptResource, isTracingEnabled, loadPrompt, map, merge, mergeState, normalizeRootConfig, parallel, parseSSEEvent, parseSkillContent, presets, production, reduce, renderTemplate, resolveResourcePath, retry, safeValidateSchemaDescriptions, sanitizeValue, scanAllSkillRoots, scanSkillRoot, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateSkillDescription, validateSkillName, validateSkillNameMatchesDir, validateState, validateTool, validateToolMetadata, validateToolName, withCache, withConcurrency, withErrorHandler, withLogging, withMetrics, withRateLimit, withRetry, withTimeout, withTracing, withValidation };
|