@cognipeer/agent-sdk 0.8.3 → 0.8.5

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.cts CHANGED
@@ -240,18 +240,36 @@ declare const DEFAULT_SUBAGENT_TOOL_NAMES: SubagentToolNames;
240
240
  /**
241
241
  * Skill primitive — progressive capability disclosure for the smart agent.
242
242
  *
243
- * A Skill is a lazy, self-contained capability bundle. The model always sees a
244
- * cheap one-line `header`; it calls `open_skill(key)` to load the skill's prompt
245
- * and (for small skills) bind its tools, or `bind_skill_tools(key, names)` to
246
- * bind a chosen subset of a fat skill. This keeps the number of bound tools per
247
- * step small — the property small models need — and replaces an up-front
248
- * tool-selector pass with on-demand disclosure.
243
+ * A Skill is a lazy, self-contained capability bundle. The model discovers a
244
+ * skill by its cheap one-line `header`, then calls `open_skill(key)` to load the
245
+ * skill's prompt and (for small skills) bind its tools, or
246
+ * `bind_skill_tools(key, names)` to bind a chosen subset of a fat skill. This
247
+ * keeps the number of bound tools per step small — the property small models
248
+ * need — and replaces an up-front tool-selector pass with on-demand disclosure.
249
+ *
250
+ * Discovery itself comes in two flavors, see `SkillPolicy.disclosure`: the
251
+ * headers can be listed in the system prompt, or looked up with `search_skills`.
249
252
  */
250
253
  type SkillToolHeader = {
251
254
  name: string;
252
255
  description?: string;
253
256
  };
254
257
  type SkillModelTier = "small" | "large";
258
+ /**
259
+ * How the model finds out which skills exist.
260
+ *
261
+ * - `"catalog"` (default): every available skill's header is rendered into the
262
+ * system prompt as `<available_skills>`. Cheapest possible discovery — the
263
+ * model needs no tool call — but the prompt grows with the catalog, and the
264
+ * whole catalog is paid for on every single turn of every conversation.
265
+ * - `"search"`: nothing goes into the prompt. The model finds skills through
266
+ * the `search_skills` tool, whose description is the only always-on cost.
267
+ * Prompt cost is constant, so this is the mode for a catalog that is large,
268
+ * workspace-supplied, or mostly irrelevant to any one conversation. The
269
+ * trade-off is real: a model that never calls `search_skills` never learns
270
+ * the skills exist, so keep the tool description explicit about when to call.
271
+ */
272
+ type SkillDisclosure = "catalog" | "search";
255
273
  type Skill = {
256
274
  /** Stable key, e.g. "mcp:atlassian" | "integration:google" | "builtin:drawio". */
257
275
  key: string;
@@ -284,6 +302,8 @@ type SkillPolicy = {
284
302
  maxBoundToolsTotal: number;
285
303
  /** Current model tier; gates `minModelTier`. */
286
304
  modelTier?: SkillModelTier;
305
+ /** How the model discovers skills. Defaults to `"catalog"`. */
306
+ disclosure?: SkillDisclosure;
287
307
  };
288
308
  declare const DEFAULT_SKILL_POLICY: SkillPolicy;
289
309
  declare const SMALL_TIER_SKILL_POLICY: SkillPolicy;
@@ -906,13 +926,19 @@ type SmartAgentOptions = {
906
926
  /** See AgentOptions.humanInTheLoop. */
907
927
  humanInTheLoop?: HumanInTheLoopOptions;
908
928
  /**
909
- * Progressive capability disclosure. When provided, the agent exposes cheap
910
- * skill headers in its system prompt and binds a skill's tools on demand via
911
- * the built-in open_skill / bind_skill_tools tools. Keeps the bound-tool count
912
- * per step small. An empty array is a no-op.
929
+ * Progressive capability disclosure. When provided, the agent binds a skill's
930
+ * tools on demand via the built-in open_skill / bind_skill_tools tools, which
931
+ * keeps the bound-tool count per step small. An empty array is a no-op.
932
+ *
933
+ * How the model discovers the catalog is set by `skillPolicy.disclosure`:
934
+ * cheap skill headers in the system prompt (`"catalog"`, the default), or a
935
+ * `search_skills` tool with nothing in the prompt (`"search"`).
913
936
  */
914
937
  skills?: Skill[];
915
- /** Caps/tiering for skill disclosure. Defaults to DEFAULT_SKILL_POLICY. */
938
+ /**
939
+ * Caps, tiering and discovery mode for skills. Defaults to
940
+ * DEFAULT_SKILL_POLICY (i.e. `disclosure: "catalog"`).
941
+ */
916
942
  skillPolicy?: SkillPolicy;
917
943
  /**
918
944
  * Sub-agents for dynamic problem decomposition. When provided (or when
@@ -1907,6 +1933,20 @@ declare function canOpenSkill(ref: SkillRegistryRef, policy: SkillPolicy): {
1907
1933
  declare function resolveAvailableSkills(skills: Skill[], opts?: {
1908
1934
  modelTier?: SkillPolicy["modelTier"];
1909
1935
  }): Promise<Skill[]>;
1936
+ /**
1937
+ * Rank a catalog against a free-text task description. Pure, deterministic and
1938
+ * dependency-free: no embeddings, no I/O, so it costs nothing and behaves the
1939
+ * same on every run. Backs the `search_skills` tool.
1940
+ *
1941
+ * Skills covering MORE of the query rank first, and only then by field weight
1942
+ * (key > title > header) — matching two of the user's words in a header beats
1943
+ * matching one of them in a title. Ties keep catalog order so a repeated query
1944
+ * always returns the same list.
1945
+ *
1946
+ * An empty (or all-noise) query is a browse request and returns the head of the
1947
+ * catalog rather than nothing.
1948
+ */
1949
+ declare function searchSkills(skills: Skill[], query?: string, limit?: number): Skill[];
1910
1950
  /** The cheap header block the model always sees in its system prompt. */
1911
1951
  declare function buildSkillHeaderBlock(skills: Skill[]): string;
1912
1952
  declare function dedupeToolsByName(tools: ToolInterface[]): ToolInterface[];
@@ -1916,9 +1956,23 @@ type SkillToolDeps = {
1916
1956
  skills: Skill[];
1917
1957
  policy: SkillPolicy;
1918
1958
  };
1959
+ /**
1960
+ * Discovery for `disclosure: "search"`: the catalog stays out of the prompt and
1961
+ * the model looks it up instead, so prompt cost is constant no matter how many
1962
+ * skills a workspace has.
1963
+ *
1964
+ * Availability (`isAvailable` / `minModelTier`) is resolved HERE rather than at
1965
+ * prompt-assembly time, which means an integration that connects mid-run shows
1966
+ * up on the next search instead of being frozen out for the whole invoke.
1967
+ */
1968
+ declare function createSearchSkillsTool(deps: SkillToolDeps): ToolInterface;
1919
1969
  declare function createOpenSkillTool(deps: SkillToolDeps): ToolInterface;
1920
1970
  declare function createBindSkillToolsTool(deps: SkillToolDeps): ToolInterface;
1921
- /** Both skill tools for an invoke, sharing one registry ref. */
1971
+ /**
1972
+ * The skill meta-tools for an invoke, sharing one registry ref. `search_skills`
1973
+ * is only wired under `disclosure: "search"` — in catalog mode the headers are
1974
+ * already in the prompt and a search tool would be pure overhead.
1975
+ */
1922
1976
  declare function createSkillTools(deps: SkillToolDeps): ToolInterface[];
1923
1977
 
1924
1978
  /**
@@ -2468,6 +2522,12 @@ declare function resolveToolApprovalState(state: SmartState, resolution: ToolApp
2468
2522
 
2469
2523
  declare function resolveUserQuestionState(state: SmartState, resolution: UserQuestionResolution): SmartState;
2470
2524
 
2525
+ /**
2526
+ * The built-in ask-user tool's name. Exported because more than one layer has to
2527
+ * recognise it: `createSmartAgent` builds the tool into the list it hands to
2528
+ * `createAgent`, which must then not attach a second one of its own.
2529
+ */
2530
+ declare const ASK_USER_TOOL_NAME = "ask_user_question";
2471
2531
  type AskUserStateRef = {
2472
2532
  pendingUserQuestions?: PendingUserQuestion[];
2473
2533
  ctx?: Record<string, any>;
@@ -3010,4 +3070,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
3010
3070
  */
3011
3071
  declare function createProvider(config: ProviderConfig): BaseProvider;
3012
3072
 
3013
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
3073
+ export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
package/dist/index.d.ts CHANGED
@@ -240,18 +240,36 @@ declare const DEFAULT_SUBAGENT_TOOL_NAMES: SubagentToolNames;
240
240
  /**
241
241
  * Skill primitive — progressive capability disclosure for the smart agent.
242
242
  *
243
- * A Skill is a lazy, self-contained capability bundle. The model always sees a
244
- * cheap one-line `header`; it calls `open_skill(key)` to load the skill's prompt
245
- * and (for small skills) bind its tools, or `bind_skill_tools(key, names)` to
246
- * bind a chosen subset of a fat skill. This keeps the number of bound tools per
247
- * step small — the property small models need — and replaces an up-front
248
- * tool-selector pass with on-demand disclosure.
243
+ * A Skill is a lazy, self-contained capability bundle. The model discovers a
244
+ * skill by its cheap one-line `header`, then calls `open_skill(key)` to load the
245
+ * skill's prompt and (for small skills) bind its tools, or
246
+ * `bind_skill_tools(key, names)` to bind a chosen subset of a fat skill. This
247
+ * keeps the number of bound tools per step small — the property small models
248
+ * need — and replaces an up-front tool-selector pass with on-demand disclosure.
249
+ *
250
+ * Discovery itself comes in two flavors, see `SkillPolicy.disclosure`: the
251
+ * headers can be listed in the system prompt, or looked up with `search_skills`.
249
252
  */
250
253
  type SkillToolHeader = {
251
254
  name: string;
252
255
  description?: string;
253
256
  };
254
257
  type SkillModelTier = "small" | "large";
258
+ /**
259
+ * How the model finds out which skills exist.
260
+ *
261
+ * - `"catalog"` (default): every available skill's header is rendered into the
262
+ * system prompt as `<available_skills>`. Cheapest possible discovery — the
263
+ * model needs no tool call — but the prompt grows with the catalog, and the
264
+ * whole catalog is paid for on every single turn of every conversation.
265
+ * - `"search"`: nothing goes into the prompt. The model finds skills through
266
+ * the `search_skills` tool, whose description is the only always-on cost.
267
+ * Prompt cost is constant, so this is the mode for a catalog that is large,
268
+ * workspace-supplied, or mostly irrelevant to any one conversation. The
269
+ * trade-off is real: a model that never calls `search_skills` never learns
270
+ * the skills exist, so keep the tool description explicit about when to call.
271
+ */
272
+ type SkillDisclosure = "catalog" | "search";
255
273
  type Skill = {
256
274
  /** Stable key, e.g. "mcp:atlassian" | "integration:google" | "builtin:drawio". */
257
275
  key: string;
@@ -284,6 +302,8 @@ type SkillPolicy = {
284
302
  maxBoundToolsTotal: number;
285
303
  /** Current model tier; gates `minModelTier`. */
286
304
  modelTier?: SkillModelTier;
305
+ /** How the model discovers skills. Defaults to `"catalog"`. */
306
+ disclosure?: SkillDisclosure;
287
307
  };
288
308
  declare const DEFAULT_SKILL_POLICY: SkillPolicy;
289
309
  declare const SMALL_TIER_SKILL_POLICY: SkillPolicy;
@@ -906,13 +926,19 @@ type SmartAgentOptions = {
906
926
  /** See AgentOptions.humanInTheLoop. */
907
927
  humanInTheLoop?: HumanInTheLoopOptions;
908
928
  /**
909
- * Progressive capability disclosure. When provided, the agent exposes cheap
910
- * skill headers in its system prompt and binds a skill's tools on demand via
911
- * the built-in open_skill / bind_skill_tools tools. Keeps the bound-tool count
912
- * per step small. An empty array is a no-op.
929
+ * Progressive capability disclosure. When provided, the agent binds a skill's
930
+ * tools on demand via the built-in open_skill / bind_skill_tools tools, which
931
+ * keeps the bound-tool count per step small. An empty array is a no-op.
932
+ *
933
+ * How the model discovers the catalog is set by `skillPolicy.disclosure`:
934
+ * cheap skill headers in the system prompt (`"catalog"`, the default), or a
935
+ * `search_skills` tool with nothing in the prompt (`"search"`).
913
936
  */
914
937
  skills?: Skill[];
915
- /** Caps/tiering for skill disclosure. Defaults to DEFAULT_SKILL_POLICY. */
938
+ /**
939
+ * Caps, tiering and discovery mode for skills. Defaults to
940
+ * DEFAULT_SKILL_POLICY (i.e. `disclosure: "catalog"`).
941
+ */
916
942
  skillPolicy?: SkillPolicy;
917
943
  /**
918
944
  * Sub-agents for dynamic problem decomposition. When provided (or when
@@ -1907,6 +1933,20 @@ declare function canOpenSkill(ref: SkillRegistryRef, policy: SkillPolicy): {
1907
1933
  declare function resolveAvailableSkills(skills: Skill[], opts?: {
1908
1934
  modelTier?: SkillPolicy["modelTier"];
1909
1935
  }): Promise<Skill[]>;
1936
+ /**
1937
+ * Rank a catalog against a free-text task description. Pure, deterministic and
1938
+ * dependency-free: no embeddings, no I/O, so it costs nothing and behaves the
1939
+ * same on every run. Backs the `search_skills` tool.
1940
+ *
1941
+ * Skills covering MORE of the query rank first, and only then by field weight
1942
+ * (key > title > header) — matching two of the user's words in a header beats
1943
+ * matching one of them in a title. Ties keep catalog order so a repeated query
1944
+ * always returns the same list.
1945
+ *
1946
+ * An empty (or all-noise) query is a browse request and returns the head of the
1947
+ * catalog rather than nothing.
1948
+ */
1949
+ declare function searchSkills(skills: Skill[], query?: string, limit?: number): Skill[];
1910
1950
  /** The cheap header block the model always sees in its system prompt. */
1911
1951
  declare function buildSkillHeaderBlock(skills: Skill[]): string;
1912
1952
  declare function dedupeToolsByName(tools: ToolInterface[]): ToolInterface[];
@@ -1916,9 +1956,23 @@ type SkillToolDeps = {
1916
1956
  skills: Skill[];
1917
1957
  policy: SkillPolicy;
1918
1958
  };
1959
+ /**
1960
+ * Discovery for `disclosure: "search"`: the catalog stays out of the prompt and
1961
+ * the model looks it up instead, so prompt cost is constant no matter how many
1962
+ * skills a workspace has.
1963
+ *
1964
+ * Availability (`isAvailable` / `minModelTier`) is resolved HERE rather than at
1965
+ * prompt-assembly time, which means an integration that connects mid-run shows
1966
+ * up on the next search instead of being frozen out for the whole invoke.
1967
+ */
1968
+ declare function createSearchSkillsTool(deps: SkillToolDeps): ToolInterface;
1919
1969
  declare function createOpenSkillTool(deps: SkillToolDeps): ToolInterface;
1920
1970
  declare function createBindSkillToolsTool(deps: SkillToolDeps): ToolInterface;
1921
- /** Both skill tools for an invoke, sharing one registry ref. */
1971
+ /**
1972
+ * The skill meta-tools for an invoke, sharing one registry ref. `search_skills`
1973
+ * is only wired under `disclosure: "search"` — in catalog mode the headers are
1974
+ * already in the prompt and a search tool would be pure overhead.
1975
+ */
1922
1976
  declare function createSkillTools(deps: SkillToolDeps): ToolInterface[];
1923
1977
 
1924
1978
  /**
@@ -2468,6 +2522,12 @@ declare function resolveToolApprovalState(state: SmartState, resolution: ToolApp
2468
2522
 
2469
2523
  declare function resolveUserQuestionState(state: SmartState, resolution: UserQuestionResolution): SmartState;
2470
2524
 
2525
+ /**
2526
+ * The built-in ask-user tool's name. Exported because more than one layer has to
2527
+ * recognise it: `createSmartAgent` builds the tool into the list it hands to
2528
+ * `createAgent`, which must then not attach a second one of its own.
2529
+ */
2530
+ declare const ASK_USER_TOOL_NAME = "ask_user_question";
2471
2531
  type AskUserStateRef = {
2472
2532
  pendingUserQuestions?: PendingUserQuestion[];
2473
2533
  ctx?: Record<string, any>;
@@ -3010,4 +3070,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
3010
3070
  */
3011
3071
  declare function createProvider(config: ProviderConfig): BaseProvider;
3012
3072
 
3013
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
3073
+ export { type AIMessage, ASK_USER_TOOL_NAME, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillDisclosure, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
package/dist/index.mjs CHANGED
@@ -4563,6 +4563,7 @@ function resolveUserQuestionState(state, resolution) {
4563
4563
  ctx
4564
4564
  };
4565
4565
  }
4566
+ var ASK_USER_TOOL_NAME = "ask_user_question";
4566
4567
  var DEFAULT_DESCRIPTION_WITH_FREETEXT = "Pause the agent and surface a structured prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Prefer concrete options the user can pick over open-ended free-text \u2014 list `options` whenever you can anticipate the choices. The user may type a custom answer for any question. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user answers, their selections come back as the tool result.";
4567
4568
  var DEFAULT_DESCRIPTION_NO_FREETEXT = "Pause the agent and surface a structured multi-choice prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Every question MUST include at least two `options` \u2014 free-text answers are disabled for this agent. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user picks, their selections come back as the tool result.";
4568
4569
  function buildOptionSchema() {
@@ -4598,7 +4599,7 @@ function createAskUserQuestionTool(stateRef, config) {
4598
4599
  const description = config.promptOverride ?? (allowFreeText ? DEFAULT_DESCRIPTION_WITH_FREETEXT : DEFAULT_DESCRIPTION_NO_FREETEXT);
4599
4600
  const questionSchema = buildQuestionSchema(allowFreeText);
4600
4601
  const askUser = createTool({
4601
- name: "ask_user_question",
4602
+ name: ASK_USER_TOOL_NAME,
4602
4603
  description,
4603
4604
  schema: z.object({
4604
4605
  questions: z.array(questionSchema).min(1).max(4).describe("1-4 related questions to ask in a single pause.")
@@ -4614,7 +4615,7 @@ function createAskUserQuestionTool(stateRef, config) {
4614
4615
  const entry = {
4615
4616
  id: nanoid(),
4616
4617
  toolCallId,
4617
- toolName: "ask_user_question",
4618
+ toolName: ASK_USER_TOOL_NAME,
4618
4619
  questions,
4619
4620
  status: "pending",
4620
4621
  requestedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -4970,14 +4971,15 @@ function createAgent(opts) {
4970
4971
  })();
4971
4972
  const askUserOnQuestion = typeof opts.humanInTheLoop?.askUser === "object" ? opts.humanInTheLoop?.askUser?.onQuestion : void 0;
4972
4973
  const askUserStateRef = askUserConfig ? { pendingUserQuestions: void 0, ctx: void 0, __onEvent: void 0, __currentToolCallId: void 0 } : void 0;
4973
- if (askUserConfig && askUserStateRef) {
4974
+ const hasTool = (name) => toolsBase.some((tool) => tool?.name === name);
4975
+ if (askUserConfig && askUserStateRef && !hasTool(ASK_USER_TOOL_NAME)) {
4974
4976
  toolsBase.push(createAskUserQuestionTool(askUserStateRef, askUserConfig));
4975
4977
  }
4976
4978
  const soManager = opts.outputSchema ? new StructuredOutputManager(opts.outputSchema, resolveStrategy(opts.model)) : void 0;
4977
4979
  if (soManager) {
4978
4980
  const modelCapabilities = getModelCapabilities(opts.model);
4979
4981
  const responseTool = soManager.getResponseTool();
4980
- if (responseTool && modelCapabilities.structuredOutput !== "native") {
4982
+ if (responseTool && modelCapabilities.structuredOutput !== "native" && !hasTool(responseTool.name)) {
4981
4983
  toolsBase.push(responseTool);
4982
4984
  }
4983
4985
  }
@@ -6910,6 +6912,42 @@ async function resolveAvailableSkills(skills, opts = {}) {
6910
6912
  }
6911
6913
  return out;
6912
6914
  }
6915
+ var WORD_SPLIT = /[^\p{L}\p{N}]+/u;
6916
+ var MIN_TERM_LENGTH = 3;
6917
+ var FIELD_WEIGHTS = { key: 4, title: 3, header: 2 };
6918
+ var wordsOf = (text) => text.toLowerCase().split(WORD_SPLIT).filter((word) => word.length >= 2);
6919
+ var termHitsWord = (term, word) => word === term || word.startsWith(term) || word.length >= 3 && term.startsWith(word) || term.length >= 5 && word.length >= 5 && word.slice(0, 4) === term.slice(0, 4);
6920
+ function searchSkills(skills, query, limit = 10) {
6921
+ const cap = Math.max(1, limit);
6922
+ const normalized = (query || "").trim().toLowerCase();
6923
+ const terms = [
6924
+ ...new Set(normalized.split(WORD_SPLIT).filter((term) => term.length >= MIN_TERM_LENGTH))
6925
+ ];
6926
+ if (terms.length === 0) return skills.slice(0, cap);
6927
+ const scored = skills.map((skill, index) => {
6928
+ const fields = {
6929
+ key: wordsOf(skill.key),
6930
+ title: wordsOf(skill.title || ""),
6931
+ header: wordsOf(skill.header || "")
6932
+ };
6933
+ const exact = skill.key.toLowerCase() === normalized || (skill.title || "").toLowerCase() === normalized;
6934
+ let score = exact ? 100 : 0;
6935
+ let coverage = 0;
6936
+ for (const term of terms) {
6937
+ let hit = false;
6938
+ for (const [field, weight] of Object.entries(FIELD_WEIGHTS)) {
6939
+ if (fields[field].some((word) => termHitsWord(term, word))) {
6940
+ score += weight;
6941
+ hit = true;
6942
+ }
6943
+ }
6944
+ if (hit) coverage += 1;
6945
+ }
6946
+ return { skill, score, coverage, index };
6947
+ }).filter((entry) => entry.score > 0);
6948
+ scored.sort((a, b) => b.coverage - a.coverage || b.score - a.score || a.index - b.index);
6949
+ return scored.slice(0, cap).map((entry) => entry.skill);
6950
+ }
6913
6951
  function buildSkillHeaderBlock(skills) {
6914
6952
  if (skills.length === 0) return "";
6915
6953
  const lines = skills.map((skill) => `- ${skill.key}: ${skill.header}`);
@@ -6933,24 +6971,65 @@ function dedupeToolsByName(tools) {
6933
6971
 
6934
6972
  // src/smart/skills/skillTools.ts
6935
6973
  var MAX_RETURNED_INDEX = 40;
6936
- var OPEN_SKILL_DESCRIPTION = "Load a capability on demand. Pass a skillKey from <available_skills>. A small skill binds all its tools immediately; a large one returns a tool index \u2014 then call bind_skill_tools with only the tools you need. Open only what the task needs.";
6974
+ var DEFAULT_SEARCH_LIMIT = 10;
6975
+ var MAX_SEARCH_LIMIT = 25;
6976
+ var isSearchDisclosure = (policy) => policy.disclosure === "search";
6977
+ var keySource = (policy) => isSearchDisclosure(policy) ? "search_skills" : "<available_skills>";
6978
+ var openSkillDescription = (policy) => `Load a capability on demand. Pass a skillKey from ${keySource(policy)}. A small skill binds all its tools immediately; a large one returns a tool index \u2014 then call bind_skill_tools with only the tools you need. Open only what the task needs.`;
6937
6979
  var BIND_SKILL_TOOLS_DESCRIPTION = "After open_skill on a large skill, bind a chosen subset of its tools by name. Pick the few tools the task actually needs.";
6980
+ var SEARCH_SKILLS_DESCRIPTION = 'Find a reusable playbook (a "skill") for the task at hand. Skills are proven, pre-written procedures for specific kinds of work \u2014 each with its own tools, which are NOT in your tool list until you open the skill. Call this early whenever a request looks like an established procedure, or when you seem to be missing a capability you would expect to have: describe the task in `query`. Returns matching skill keys; pass one to open_skill to load its instructions and tools. An empty query lists what exists.';
6938
6981
  function findSkill(deps, key) {
6939
6982
  return deps.skills.find((skill) => skill.key === key);
6940
6983
  }
6984
+ function createSearchSkillsTool(deps) {
6985
+ const tool = createTool({
6986
+ name: "search_skills",
6987
+ description: SEARCH_SKILLS_DESCRIPTION,
6988
+ schema: z.object({
6989
+ query: z.string().optional().describe("What you are trying to do, in a few words. Omit to list available skills."),
6990
+ limit: z.number().int().positive().optional().describe(`Max results to return (default ${DEFAULT_SEARCH_LIMIT}).`)
6991
+ }).strict(),
6992
+ func: async ({ query, limit }) => {
6993
+ const { skills, policy, registryRef: ref } = tool._deps;
6994
+ const available = await resolveAvailableSkills(skills, { modelTier: policy.modelTier });
6995
+ if (available.length === 0) {
6996
+ return { skills: [], total: 0, hint: "No skills are available in this workspace." };
6997
+ }
6998
+ const capped = Math.min(limit || DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT);
6999
+ const matches = searchSkills(available, query, capped);
7000
+ const missed = matches.length === 0;
7001
+ const shown = missed ? available.slice(0, capped) : matches;
7002
+ return {
7003
+ skills: shown.map((skill) => ({
7004
+ skillKey: skill.key,
7005
+ title: skill.title,
7006
+ header: skill.header,
7007
+ ...ref.openedSkillKeys.includes(skill.key) ? { alreadyOpen: true } : {}
7008
+ })),
7009
+ total: available.length,
7010
+ hint: missed ? `Nothing matched "${query}" literally \u2014 listing ${shown.length} of ${available.length} instead. Judge them by their headers; call open_skill(skillKey) if one fits, otherwise carry on without a skill.` : "Call open_skill(skillKey) to load the one that fits."
7011
+ };
7012
+ }
7013
+ });
7014
+ tool._deps = deps;
7015
+ tool.__source = "smart-skills";
7016
+ return tool;
7017
+ }
6941
7018
  function createOpenSkillTool(deps) {
6942
7019
  const tool = createTool({
6943
7020
  name: "open_skill",
6944
- description: OPEN_SKILL_DESCRIPTION,
7021
+ description: openSkillDescription(deps.policy),
6945
7022
  schema: z.object({
6946
- skillKey: z.string().min(1).describe("A key from <available_skills>."),
7023
+ skillKey: z.string().min(1).describe(`A key from ${keySource(deps.policy)}.`),
6947
7024
  query: z.string().optional().describe("What you need from the skill \u2014 used to rank a large skill's tools.")
6948
7025
  }).strict(),
6949
7026
  func: async ({ skillKey, query }) => {
6950
7027
  const { registryRef: ref, policy } = tool._deps;
6951
7028
  const skill = findSkill(tool._deps, skillKey);
6952
7029
  if (!skill) {
6953
- return { error: `Unknown skill: ${skillKey}. Choose a key listed in <available_skills>.` };
7030
+ return {
7031
+ error: `Unknown skill: ${skillKey}. ${isSearchDisclosure(policy) ? "Call search_skills to get a valid key." : "Choose a key listed in <available_skills>."}`
7032
+ };
6954
7033
  }
6955
7034
  if (skill.isAvailable && !await skill.isAvailable()) {
6956
7035
  return { error: `Skill ${skillKey} is not available in this workspace.` };
@@ -7039,7 +7118,9 @@ function createBindSkillToolsTool(deps) {
7039
7118
  return tool;
7040
7119
  }
7041
7120
  function createSkillTools(deps) {
7042
- return [createOpenSkillTool(deps), createBindSkillToolsTool(deps)];
7121
+ const tools = [createOpenSkillTool(deps), createBindSkillToolsTool(deps)];
7122
+ if (isSearchDisclosure(deps.policy)) tools.unshift(createSearchSkillsTool(deps));
7123
+ return tools;
7043
7124
  }
7044
7125
 
7045
7126
  // src/smart/subagents/types.ts
@@ -7719,7 +7800,8 @@ function createSmartAgent(opts) {
7719
7800
  if (changed) toolSet.skillRegistryRef.__onToolsChanged?.();
7720
7801
  }
7721
7802
  const syncPlanFromRef = (state2) => syncPlanStateWith(stateRef, state2);
7722
- const availableSkills = skillsEnabled ? await resolveAvailableSkills(skills, { modelTier: skillPolicy.modelTier }) : [];
7803
+ const catalogDisclosure = skillPolicy.disclosure !== "search";
7804
+ const availableSkills = skillsEnabled && catalogDisclosure ? await resolveAvailableSkills(skills, { modelTier: skillPolicy.modelTier }) : [];
7723
7805
  const skillBlock = availableSkills.length > 0 ? buildSkillHeaderBlock(availableSkills) : void 0;
7724
7806
  let subagentBlock;
7725
7807
  if (subagentsEnabled) {
@@ -10937,6 +11019,6 @@ function createProvider(config) {
10937
11019
  }
10938
11020
  }
10939
11021
 
10940
- export { AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, GuardrailPhase, InMemoryMemoryStore, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, ToolBasedStrategy, VertexProvider, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
11022
+ export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, GuardrailPhase, InMemoryMemoryStore, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, ToolBasedStrategy, VertexProvider, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
10941
11023
  //# sourceMappingURL=index.mjs.map
10942
11024
  //# sourceMappingURL=index.mjs.map