llmist 16.1.0 → 16.2.1

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.d.ts CHANGED
@@ -1896,6 +1896,8 @@ interface Observers {
1896
1896
  onRateLimitThrottle?: (context: ObserveRateLimitThrottleContext) => void | Promise<void>;
1897
1897
  /** Called when a retry attempt is made after a failed LLM call */
1898
1898
  onRetryAttempt?: (context: ObserveRetryAttemptContext) => void | Promise<void>;
1899
+ /** Called when a skill is activated (via UseSkill gadget or pre-activation) */
1900
+ onSkillActivated?: (context: ObserveSkillActivatedContext) => void | Promise<void>;
1899
1901
  }
1900
1902
  /**
1901
1903
  * Context provided when context compaction occurs.
@@ -1963,6 +1965,53 @@ interface ObserveRetryAttemptContext {
1963
1965
  /** Present when event is from a subagent (undefined for top-level agent) */
1964
1966
  subagentContext?: SubagentContext;
1965
1967
  }
1968
+ /**
1969
+ * Context provided when a skill is activated.
1970
+ * Read-only observation point.
1971
+ */
1972
+ interface ObserveSkillActivatedContext {
1973
+ /** Name of the activated skill */
1974
+ skillName: string;
1975
+ /** Arguments passed to the skill (if any) */
1976
+ arguments?: string;
1977
+ /** Current iteration when activation occurred */
1978
+ iteration: number;
1979
+ /** Logger instance */
1980
+ logger: Logger<ILogObj>;
1981
+ }
1982
+ /**
1983
+ * Context for skill activation controller.
1984
+ */
1985
+ interface SkillActivationControllerContext {
1986
+ /** Name of the skill being activated */
1987
+ skillName: string;
1988
+ /** Arguments passed to the skill */
1989
+ arguments?: string;
1990
+ /** Current iteration */
1991
+ iteration: number;
1992
+ /** Logger instance */
1993
+ logger: Logger<ILogObj>;
1994
+ }
1995
+ /**
1996
+ * Action returned by beforeSkillActivation controller.
1997
+ */
1998
+ type BeforeSkillActivationAction = {
1999
+ action: "proceed";
2000
+ } | {
2001
+ action: "skip";
2002
+ reason?: string;
2003
+ };
2004
+ /**
2005
+ * Context for skill instruction interception.
2006
+ */
2007
+ interface SkillInstructionInterceptorContext {
2008
+ /** Name of the skill being activated */
2009
+ skillName: string;
2010
+ /** Arguments passed to the skill */
2011
+ arguments?: string;
2012
+ /** Logger instance */
2013
+ logger: Logger<ILogObj>;
2014
+ }
1966
2015
  /**
1967
2016
  * Context for chunk interception.
1968
2017
  */
@@ -2055,6 +2104,14 @@ interface Interceptors {
2055
2104
  * @returns Transformed text (cannot be suppressed)
2056
2105
  */
2057
2106
  interceptGadgetResult?: (result: string, context: GadgetResultInterceptorContext) => string;
2107
+ /**
2108
+ * Intercept and transform skill instructions before they are returned to the LLM.
2109
+ *
2110
+ * @param instructions - The resolved skill instructions
2111
+ * @param context - Context including skill name and arguments
2112
+ * @returns Transformed instructions, or null to suppress the skill activation
2113
+ */
2114
+ interceptSkillInstructions?: (instructions: string, context: SkillInstructionInterceptorContext) => string | null;
2058
2115
  }
2059
2116
  /**
2060
2117
  * Context for LLM call controller.
@@ -2248,6 +2305,11 @@ interface Controllers {
2248
2305
  * Can override the default skip behavior to execute anyway or provide a fallback.
2249
2306
  */
2250
2307
  onDependencySkipped?: (context: DependencySkipControllerContext) => Promise<DependencySkipAction>;
2308
+ /**
2309
+ * Called before activating a skill.
2310
+ * Can skip the activation (e.g., for permission checks or cost limits).
2311
+ */
2312
+ beforeSkillActivation?: (context: SkillActivationControllerContext) => Promise<BeforeSkillActivationAction>;
2251
2313
  }
2252
2314
  /**
2253
2315
  * Clean hooks system with three distinct categories:
@@ -4598,6 +4660,258 @@ declare class GadgetRegistry {
4598
4660
  clear(): void;
4599
4661
  }
4600
4662
 
4663
+ /**
4664
+ * Core type definitions for the Skills system.
4665
+ *
4666
+ * Skills follow the Agent Skills open standard (agentskills.io) — markdown-based
4667
+ * instruction packages that extend agent capabilities through prompt injection
4668
+ * and context management, not code execution.
4669
+ *
4670
+ * Three-tier progressive disclosure:
4671
+ * - Tier 1 (metadata): ~100 tokens, always loaded for discovery
4672
+ * - Tier 2 (instructions): <5K tokens, loaded on activation
4673
+ * - Tier 3 (resources): unlimited, loaded on demand
4674
+ *
4675
+ * @module skills/types
4676
+ */
4677
+
4678
+ /**
4679
+ * Parsed YAML frontmatter from a SKILL.md file.
4680
+ * Follows the Agent Skills open standard with llmist-specific extensions.
4681
+ */
4682
+ interface SkillMetadata {
4683
+ /** Skill identifier. Lowercase letters, numbers, hyphens only. Max 64 chars. */
4684
+ name: string;
4685
+ /** What the skill does and when to use it. Max 1024 chars. Used for auto-triggering. */
4686
+ description: string;
4687
+ /** Hint shown during autocomplete, e.g., "[issue-number]" or "<filename> [format]". */
4688
+ argumentHint?: string;
4689
+ /** Tools the agent can use when this skill is active. */
4690
+ allowedTools?: string[];
4691
+ /** Model override when skill is active, e.g., "sonnet", "flash". */
4692
+ model?: string;
4693
+ /** Execution context. "fork" runs in an isolated subagent. */
4694
+ context?: "fork" | "inline";
4695
+ /** Subagent type for fork mode, e.g., "Explore", "Plan", "general-purpose". */
4696
+ agent?: string;
4697
+ /** Glob patterns for auto-activation based on files being worked on. */
4698
+ paths?: string[];
4699
+ /** Bundled gadget specifiers loaded when skill activates. */
4700
+ gadgets?: string[];
4701
+ /** If true, only the user can invoke this skill (LLM cannot auto-trigger). */
4702
+ disableModelInvocation?: boolean;
4703
+ /** If false, skill is background knowledge only — hidden from user invocation. */
4704
+ userInvocable?: boolean;
4705
+ /** Shell for !`command` preprocessing. */
4706
+ shell?: "bash" | "powershell";
4707
+ /** Semantic version number. */
4708
+ version?: string;
4709
+ }
4710
+ /**
4711
+ * A resource file within a skill's directory (Tier 3).
4712
+ */
4713
+ interface SkillResource {
4714
+ /** Path relative to the skill directory. */
4715
+ relativePath: string;
4716
+ /** Absolute path on disk. */
4717
+ absolutePath: string;
4718
+ /** Category based on parent directory. */
4719
+ category: "scripts" | "references" | "assets";
4720
+ }
4721
+ /**
4722
+ * Where a skill was discovered from.
4723
+ */
4724
+ type SkillSource = {
4725
+ type: "project";
4726
+ path: string;
4727
+ } | {
4728
+ type: "user";
4729
+ path: string;
4730
+ } | {
4731
+ type: "npm";
4732
+ package: string;
4733
+ } | {
4734
+ type: "git";
4735
+ url: string;
4736
+ } | {
4737
+ type: "directory";
4738
+ path: string;
4739
+ };
4740
+ /**
4741
+ * Fully parsed skill representation (all three tiers).
4742
+ */
4743
+ interface ParsedSkill {
4744
+ /** Tier 1: Always-loaded metadata from frontmatter. */
4745
+ metadata: SkillMetadata;
4746
+ /** Tier 2: Full SKILL.md body. null if not yet loaded. */
4747
+ instructions: string | null;
4748
+ /** Tier 3: Discovered resource manifests. */
4749
+ resources: SkillResource[];
4750
+ /** Absolute path to the SKILL.md file. */
4751
+ sourcePath: string;
4752
+ /** Directory containing the skill. */
4753
+ sourceDir: string;
4754
+ /** Origin for debugging and priority resolution. */
4755
+ source: SkillSource;
4756
+ }
4757
+ /**
4758
+ * Result of activating a skill.
4759
+ */
4760
+ interface SkillActivation {
4761
+ /** The skill that was activated. */
4762
+ skillName: string;
4763
+ /** Resolved instructions after $ARGUMENTS substitution and !`command` preprocessing. */
4764
+ resolvedInstructions: string;
4765
+ /** Gadgets made available by this skill (if any). */
4766
+ gadgets: AbstractGadget[];
4767
+ /** Resources loaded for this activation (Tier 3). Keyed by relative path. */
4768
+ loadedResources: Map<string, string>;
4769
+ }
4770
+ /**
4771
+ * Options for skill activation.
4772
+ */
4773
+ interface SkillActivationOptions {
4774
+ /** Arguments passed to the skill (substituted into $ARGUMENTS, $0, $1, etc.). */
4775
+ arguments?: string;
4776
+ /** Whether to load Tier 3 resources eagerly. Default: false. */
4777
+ eagerResources?: boolean;
4778
+ /** Working directory for !`command` preprocessing. */
4779
+ cwd?: string;
4780
+ /** Whether to execute !`command` preprocessing. Default: true. */
4781
+ enableShellPreprocessing?: boolean;
4782
+ /** Timeout for !`command` execution in milliseconds. Default: 10000. */
4783
+ shellTimeoutMs?: number;
4784
+ }
4785
+
4786
+ /**
4787
+ * Skill class with lazy-loading progressive disclosure.
4788
+ *
4789
+ * Tier 1 (metadata) is always available after construction.
4790
+ * Tier 2 (instructions) and Tier 3 (resources) are loaded on demand.
4791
+ *
4792
+ * @module skills/skill
4793
+ */
4794
+
4795
+ declare class Skill {
4796
+ readonly metadata: SkillMetadata;
4797
+ readonly sourcePath: string;
4798
+ readonly sourceDir: string;
4799
+ readonly source: SkillSource;
4800
+ private _instructions;
4801
+ private _resources;
4802
+ private readonly _resourceCache;
4803
+ private readonly _resourceLoading;
4804
+ constructor(parsed: ParsedSkill);
4805
+ /** Skill name for registry lookup. */
4806
+ get name(): string;
4807
+ /** Skill description for LLM matching. */
4808
+ get description(): string;
4809
+ /** Whether the LLM can auto-trigger this skill. */
4810
+ get isModelInvocable(): boolean;
4811
+ /** Whether the user can invoke this skill via /skill-name. */
4812
+ get isUserInvocable(): boolean;
4813
+ /**
4814
+ * Load and cache Tier 2 instructions.
4815
+ * If instructions were loaded during parsing, returns the cached value.
4816
+ */
4817
+ getInstructions(): Promise<string>;
4818
+ /**
4819
+ * List Tier 3 resources.
4820
+ * Resources are discovered at parse time but content is loaded on demand.
4821
+ */
4822
+ getResources(): SkillResource[];
4823
+ /**
4824
+ * Load a specific Tier 3 resource by relative path.
4825
+ * Results are cached for the lifetime of this Skill instance.
4826
+ * Concurrent calls for the same resource share a single read.
4827
+ */
4828
+ getResource(relativePath: string): Promise<string>;
4829
+ /**
4830
+ * Activate this skill with optional arguments.
4831
+ *
4832
+ * Performs:
4833
+ * 1. Variable substitution (${SKILL_DIR}, etc.)
4834
+ * 2. Argument substitution ($ARGUMENTS, $0, $1)
4835
+ * 3. Shell preprocessing (!`command`)
4836
+ * 4. Resource loading (if eagerResources is true)
4837
+ */
4838
+ activate(options?: SkillActivationOptions): Promise<SkillActivation>;
4839
+ /**
4840
+ * Create a Skill from a SKILL.md content string.
4841
+ * Useful for testing or dynamic skill creation.
4842
+ */
4843
+ static fromContent(content: string, sourcePath: string, source?: SkillSource): Skill;
4844
+ }
4845
+
4846
+ /**
4847
+ * SkillRegistry — manages skill discovery, lookup, and metadata summaries.
4848
+ *
4849
+ * Parallel to GadgetRegistry but with different semantics: skills are not
4850
+ * executable tools registered with the LLM directly. They are available
4851
+ * for activation by the agent or user, surfaced via metadata summaries.
4852
+ *
4853
+ * @module skills/registry
4854
+ */
4855
+
4856
+ declare class SkillRegistry {
4857
+ private readonly skills;
4858
+ /**
4859
+ * Register a skill. Overwrites any existing skill with the same name.
4860
+ *
4861
+ * Unlike GadgetRegistry (which throws on duplicates), SkillRegistry allows
4862
+ * overwriting because skills are loaded from multiple sources with intentional
4863
+ * priority ordering (project > user > default).
4864
+ */
4865
+ register(skill: Skill): void;
4866
+ /** Register multiple skills. */
4867
+ registerMany(skills: Skill[]): void;
4868
+ /** Remove a skill by name (case-insensitive). Returns true if removed. */
4869
+ remove(name: string): boolean;
4870
+ /** Remove all registered skills. */
4871
+ clear(): void;
4872
+ /** Get a skill by name (case-insensitive). */
4873
+ get(name: string): Skill | undefined;
4874
+ /** Check if a skill exists by name (case-insensitive). */
4875
+ has(name: string): boolean;
4876
+ /** Get all registered skills. */
4877
+ getAll(): Skill[];
4878
+ /** Get all skill names. */
4879
+ getNames(): string[];
4880
+ /** Number of registered skills. */
4881
+ get size(): number;
4882
+ /**
4883
+ * Get skills that are visible to the LLM for auto-triggering.
4884
+ * Excludes skills with disableModelInvocation: true.
4885
+ */
4886
+ getModelInvocable(): Skill[];
4887
+ /**
4888
+ * Get skills that the user can invoke via /skill-name.
4889
+ * Excludes skills with userInvocable: false.
4890
+ */
4891
+ getUserInvocable(): Skill[];
4892
+ /**
4893
+ * Generate metadata summaries for system prompt injection (Tier 1).
4894
+ *
4895
+ * Each skill contributes a one-line summary: "name — description".
4896
+ * Output is truncated to fit the character budget.
4897
+ *
4898
+ * @param charBudget - Maximum characters for all summaries combined.
4899
+ */
4900
+ getMetadataSummaries(charBudget?: number): string;
4901
+ /**
4902
+ * Find skills whose `paths` patterns match a given file path.
4903
+ * Used for auto-activation when the user is working on specific files.
4904
+ */
4905
+ findByFilePath(filePath: string): Skill[];
4906
+ /**
4907
+ * Merge another registry into this one.
4908
+ * Skills from the other registry overwrite existing skills with the same name.
4909
+ */
4910
+ merge(other: SkillRegistry): void;
4911
+ /** Create a registry from an array of skills. */
4912
+ static from(skills: Skill[]): SkillRegistry;
4913
+ }
4914
+
4601
4915
  /**
4602
4916
  * Context available to trailing message functions.
4603
4917
  * Provides iteration information for dynamic message generation.
@@ -4746,6 +5060,7 @@ declare class AgentBuilder {
4746
5060
  private retry;
4747
5061
  private subagents;
4748
5062
  private policies;
5063
+ private skills;
4749
5064
  constructor(client?: LLMist);
4750
5065
  /** Set the model to use. Supports aliases like "sonnet", "flash". */
4751
5066
  withModel(model: string): this;
@@ -4803,6 +5118,20 @@ declare class AgentBuilder {
4803
5118
  withCompaction(config: CompactionConfig): this;
4804
5119
  /** Disable context compaction. */
4805
5120
  withoutCompaction(): this;
5121
+ /** Register a skill registry for this agent. */
5122
+ withSkills(registry: SkillRegistry): this;
5123
+ /**
5124
+ * Pre-activate a specific skill before the agent starts.
5125
+ * Instructions are injected into the system prompt.
5126
+ *
5127
+ * Note: each call replaces (not appends) the pre-activated skill for that name.
5128
+ * This is safe for REPL loops where the same builder is reused.
5129
+ */
5130
+ withSkill(name: string, args?: string): this;
5131
+ /** Clear all pre-activated skills. Call between REPL iterations. */
5132
+ clearPreActivatedSkills(): this;
5133
+ /** Add a directory to scan for skills. */
5134
+ withSkillsFrom(dir: string): this;
4806
5135
  /** Configure retry behavior for LLM API calls. */
4807
5136
  withRetry(config: RetryConfig): this;
4808
5137
  /** Disable automatic retry for LLM API calls. */
@@ -4828,6 +5157,12 @@ declare class AgentBuilder {
4828
5157
  /** Add a synthetic gadget call to the conversation history for in-context learning. */
4829
5158
  withSyntheticGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string, invocationId: string): this;
4830
5159
  private composeHooks;
5160
+ private resolveSkillRegistry;
5161
+ /**
5162
+ * Resolve pre-activated skill instructions synchronously.
5163
+ * Reads SKILL.md from disk via readFileSync (skills are local files).
5164
+ */
5165
+ private resolvePreActivatedInstructions;
4831
5166
  private buildAgentOptions;
4832
5167
  /** Create agent and start with a user prompt. */
4833
5168
  ask(userPrompt: string): Agent;
@@ -7341,6 +7676,8 @@ interface StreamProcessorOptions {
7341
7676
  requestHumanInput?: (question: string) => Promise<string>;
7342
7677
  /** Default gadget timeout */
7343
7678
  defaultGadgetTimeoutMs?: number;
7679
+ /** Maximum time (ms) to wait for in-flight gadgets to complete. Default: 300s. */
7680
+ inFlightTimeoutMs?: number;
7344
7681
  /** Gadget execution mode ('parallel' | 'sequential') */
7345
7682
  gadgetExecutionMode?: GadgetExecutionMode;
7346
7683
  /** LLMist client for ExecutionContext.llmist */
@@ -8235,8 +8572,9 @@ declare class GadgetCallParser {
8235
8572
  * - `GadgetName` - Auto-generate ID, no dependencies
8236
8573
  * - `GadgetName:my_id` - Explicit ID, no dependencies
8237
8574
  * - `GadgetName:my_id:dep1,dep2` - Explicit ID with dependencies
8575
+ * - `GadgetName:my_id:dep1:dep2:dep3` - Colons treated as dep separators (LLM resilience)
8238
8576
  *
8239
- * Dependencies must be comma-separated invocation IDs.
8577
+ * Dependencies can be comma-separated or colon-separated invocation IDs.
8240
8578
  */
8241
8579
  private parseInvocationMetadata;
8242
8580
  /**
@@ -8756,6 +9094,12 @@ interface LLMistPackageManifest {
8756
9094
  * Session factory metadata.
8757
9095
  */
8758
9096
  session?: SessionManifestEntry;
9097
+ /**
9098
+ * Skills directory relative to package root.
9099
+ * Contains subdirectories with SKILL.md files.
9100
+ * @example "./skills"
9101
+ */
9102
+ skills?: string;
8759
9103
  }
8760
9104
  /**
8761
9105
  * Factory function types that packages can export.
@@ -9653,6 +9997,146 @@ declare class SimpleSessionManager<TSession> extends BaseSessionManager<TSession
9653
9997
  setSession(id: string, data: TSession): void;
9654
9998
  }
9655
9999
 
10000
+ /**
10001
+ * Skill activation logic.
10002
+ *
10003
+ * Handles $ARGUMENTS substitution and !`command` shell preprocessing
10004
+ * to resolve skill instructions before injection into agent context.
10005
+ *
10006
+ * @module skills/activation
10007
+ */
10008
+ /**
10009
+ * Substitute $ARGUMENTS and positional $0, $1, etc. in skill instructions.
10010
+ */
10011
+ declare function substituteArguments(instructions: string, args?: string): string;
10012
+ /**
10013
+ * Substitute ${VARIABLE} environment-style variables in skill instructions.
10014
+ *
10015
+ * Supported variables:
10016
+ * - ${CLAUDE_SKILL_DIR} / ${SKILL_DIR} - directory containing SKILL.md
10017
+ * - ${CLAUDE_SESSION_ID} / ${SESSION_ID} - current session ID (if provided)
10018
+ */
10019
+ declare function substituteVariables(instructions: string, variables: Record<string, string>): string;
10020
+ /**
10021
+ * Full activation pipeline: variables -> arguments -> shell preprocessing.
10022
+ */
10023
+ declare function resolveInstructions(instructions: string, options?: {
10024
+ arguments?: string;
10025
+ variables?: Record<string, string>;
10026
+ cwd?: string;
10027
+ shell?: "bash" | "powershell";
10028
+ shellTimeoutMs?: number;
10029
+ enableShellPreprocessing?: boolean;
10030
+ }): string;
10031
+
10032
+ /**
10033
+ * Filesystem-based skill discovery and loading.
10034
+ *
10035
+ * Scans directories for subdirectories containing SKILL.md files.
10036
+ * Supports standard discovery locations and custom directories.
10037
+ *
10038
+ * @module skills/loader
10039
+ */
10040
+
10041
+ /**
10042
+ * Load skills from a directory.
10043
+ *
10044
+ * Recursively scans for subdirectories containing a SKILL.md file.
10045
+ * Each such directory is treated as a single skill.
10046
+ *
10047
+ * @param dir - Directory to scan
10048
+ * @param source - Origin for all discovered skills
10049
+ */
10050
+ declare function loadSkillsFromDirectory(dir: string, source: SkillSource, onWarning?: (msg: string) => void): Skill[];
10051
+ /**
10052
+ * Discover skills from standard locations.
10053
+ *
10054
+ * Discovery order (later sources overwrite earlier on name collision):
10055
+ * 1. User skills: ~/.llmist/skills/
10056
+ * 2. Project skills: <projectDir>/.llmist/skills/
10057
+ * 3. Additional directories (explicit)
10058
+ */
10059
+ declare function discoverSkills(options?: {
10060
+ projectDir?: string;
10061
+ userDir?: string;
10062
+ additionalDirs?: string[];
10063
+ }): SkillRegistry;
10064
+
10065
+ /**
10066
+ * SKILL.md parser for the Agent Skills open standard.
10067
+ *
10068
+ * Parses YAML frontmatter (between --- markers) and markdown body.
10069
+ * Scans skill directories for Tier 3 resources (scripts/, references/, assets/).
10070
+ *
10071
+ * @module skills/parser
10072
+ */
10073
+
10074
+ /**
10075
+ * Parse YAML frontmatter from SKILL.md content.
10076
+ *
10077
+ * Extracts the YAML block between the first pair of `---` markers
10078
+ * and the remaining markdown body.
10079
+ */
10080
+ declare function parseFrontmatter(content: string): {
10081
+ frontmatter: Record<string, unknown>;
10082
+ body: string;
10083
+ };
10084
+ /**
10085
+ * Convert raw frontmatter to validated SkillMetadata.
10086
+ *
10087
+ * Maps kebab-case YAML keys to camelCase TypeScript properties.
10088
+ * Falls back to directory name for missing name field.
10089
+ */
10090
+ declare function parseMetadata(frontmatter: Record<string, unknown>, fallbackName?: string): SkillMetadata;
10091
+ /**
10092
+ * Scan a skill directory for Tier 3 resource files.
10093
+ */
10094
+ declare function scanResources(skillDir: string): SkillResource[];
10095
+ /**
10096
+ * Parse a SKILL.md file from disk.
10097
+ *
10098
+ * This performs Tier 1 parsing (metadata) and optionally Tier 2 (instructions).
10099
+ * Resources are discovered but not loaded.
10100
+ *
10101
+ * @param skillMdPath - Absolute path to SKILL.md
10102
+ * @param source - Where this skill was discovered from
10103
+ * @param loadInstructions - Whether to load Tier 2 body (default: false for lazy loading)
10104
+ */
10105
+ declare function parseSkillFile(skillMdPath: string, source: SkillSource, loadInstructions?: boolean): ParsedSkill;
10106
+ /**
10107
+ * Parse SKILL.md content from a string.
10108
+ *
10109
+ * Useful for testing without filesystem access.
10110
+ */
10111
+ declare function parseSkillContent(content: string, sourcePath: string, source: SkillSource, loadInstructions?: boolean): ParsedSkill;
10112
+ /**
10113
+ * Validate skill metadata.
10114
+ * Returns an array of validation issues (empty if valid).
10115
+ */
10116
+ declare function validateMetadata(metadata: SkillMetadata): string[];
10117
+
10118
+ /**
10119
+ * UseSkill meta-gadget — bridges the skill system into the gadget execution pipeline.
10120
+ *
10121
+ * When skills are registered with an agent, this gadget is auto-created and added
10122
+ * to the gadget registry. The LLM can invoke it like any other gadget, and the
10123
+ * skill's instructions are returned as the gadget result.
10124
+ *
10125
+ * This approach requires zero changes to the stream processor or agent loop.
10126
+ *
10127
+ * @module skills/use-skill-gadget
10128
+ */
10129
+
10130
+ /** Name for the auto-generated UseSkill gadget. */
10131
+ declare const USE_SKILL_GADGET_NAME = "UseSkill";
10132
+ /**
10133
+ * Create the UseSkill meta-gadget from a skill registry.
10134
+ *
10135
+ * The gadget description includes a summary of all available skills,
10136
+ * so the LLM knows what skills exist and when to use them.
10137
+ */
10138
+ declare function createUseSkillGadget(registry: SkillRegistry): AbstractGadget;
10139
+
9656
10140
  /**
9657
10141
  * Config resolution utility for subagent gadgets.
9658
10142
  *
@@ -10082,4 +10566,4 @@ declare const timing: {
10082
10566
  */
10083
10567
  declare function getHostExports(ctx: ExecutionContext): HostExports;
10084
10568
 
10085
- export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetExecutorOptions, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type PrefixConfig, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseManifest, parseRetryAfterHeader, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, schemaToJSONSchema, stream, stripProviderPrefix, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, withErrorHandling, withRetry, withTimeout };
10569
+ export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, type BeforeSkillActivationAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetExecutorOptions, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, USE_SKILL_GADGET_NAME, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, createUseSkillGadget, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, loadSkillsFromDirectory, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, scanResources, schemaToJSONSchema, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };