@cognipeer/agent-sdk 0.8.4 → 0.8.6

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
  /**
@@ -3016,4 +3070,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
3016
3070
  */
3017
3071
  declare function createProvider(config: ProviderConfig): BaseProvider;
3018
3072
 
3019
- 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 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
  /**
@@ -3016,4 +3070,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
3016
3070
  */
3017
3071
  declare function createProvider(config: ProviderConfig): BaseProvider;
3018
3072
 
3019
- 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 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
@@ -798,6 +798,28 @@ function normalizeUsage(raw) {
798
798
  };
799
799
  return normalized;
800
800
  }
801
+ function recordUsage(state, modelName, normalized) {
802
+ const usageState = state.usage || { perRequest: [], totals: {} };
803
+ const id = `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
804
+ const cachedInput = normalized.prompt_tokens_details?.cached_tokens;
805
+ usageState.perRequest.push({
806
+ id,
807
+ modelName,
808
+ usage: normalized,
809
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
810
+ turn: usageState.perRequest.length + 1,
811
+ cachedInput
812
+ });
813
+ const previous = usageState.totals[modelName] || { input: 0, output: 0, total: 0, cachedInput: 0 };
814
+ usageState.totals[modelName] = {
815
+ input: previous.input + (Number(normalized.prompt_tokens) || 0),
816
+ output: previous.output + (Number(normalized.completion_tokens) || 0),
817
+ total: previous.total + (Number(normalized.total_tokens) || 0),
818
+ cachedInput: previous.cachedInput + (Number(cachedInput) || 0)
819
+ };
820
+ state.usage = usageState;
821
+ return id;
822
+ }
801
823
  function num(...vals) {
802
824
  for (const v of vals) {
803
825
  if (v === 0) return 0;
@@ -2936,24 +2958,7 @@ function createAgentCoreNode(opts) {
2936
2958
  messageList: messagesWithResponse
2937
2959
  });
2938
2960
  if (normalized) {
2939
- const usageState = state.usage || { perRequest: [], totals: {} };
2940
- const id = `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
2941
- const turn = usageState.perRequest.length + 1;
2942
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2943
- const cachedInputTok = normalized.prompt_tokens_details?.cached_tokens;
2944
- usageState.perRequest.push({ id, modelName, usage: normalized, timestamp, turn, cachedInput: cachedInputTok });
2945
- const inputTok = normalized.prompt_tokens;
2946
- const outputTok = normalized.completion_tokens;
2947
- const totalTok = normalized.total_tokens;
2948
- const key = modelName;
2949
- const agg = usageState.totals[key] || { input: 0, output: 0, total: 0, cachedInput: 0 };
2950
- usageState.totals[key] = {
2951
- input: agg.input + (Number(inputTok) || 0),
2952
- output: agg.output + (Number(outputTok) || 0),
2953
- total: agg.total + (Number(totalTok) || 0),
2954
- cachedInput: agg.cachedInput + (Number(cachedInputTok) || 0)
2955
- };
2956
- state.usage = usageState;
2961
+ recordUsage(state, modelName, normalized);
2957
2962
  }
2958
2963
  return { messages: messagesWithResponse, usage: state.usage };
2959
2964
  };
@@ -5736,24 +5741,7 @@ function createAgentNode(opts) {
5736
5741
  messageList: messagesWithResponse
5737
5742
  });
5738
5743
  if (normalized) {
5739
- const usageState = state.usage || { perRequest: [], totals: {} };
5740
- const id = `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
5741
- const turn = usageState.perRequest.length + 1;
5742
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
5743
- const cachedInputTok = normalized.prompt_tokens_details.cached_tokens;
5744
- usageState.perRequest.push({ id, modelName, usage: normalized, timestamp, turn, cachedInput: cachedInputTok });
5745
- const inputTok = normalized.prompt_tokens;
5746
- const outputTok = normalized.completion_tokens;
5747
- const totalTok = normalized.total_tokens;
5748
- const key = modelName;
5749
- const agg = usageState.totals[key] || { input: 0, output: 0, total: 0, cachedInput: 0 };
5750
- usageState.totals[key] = {
5751
- input: agg.input + (Number(inputTok) || 0),
5752
- output: agg.output + (Number(outputTok) || 0),
5753
- total: agg.total + (Number(totalTok) || 0),
5754
- cachedInput: agg.cachedInput + (Number(cachedInputTok) || 0)
5755
- };
5756
- state.usage = usageState;
5744
+ recordUsage(state, modelName, normalized);
5757
5745
  }
5758
5746
  return { messages: messagesWithResponse, usage: state.usage };
5759
5747
  };
@@ -6197,6 +6185,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
6197
6185
  outputTokensActual = normalized.completion_tokens;
6198
6186
  totalTokensActual = normalized.total_tokens;
6199
6187
  cachedInputTokens = normalized.prompt_tokens_details?.cached_tokens;
6188
+ recordUsage(state, getModelName(model) || "unknown_model", normalized);
6200
6189
  }
6201
6190
  } catch (err) {
6202
6191
  durationMs = Date.now() - startTime;
@@ -6912,6 +6901,42 @@ async function resolveAvailableSkills(skills, opts = {}) {
6912
6901
  }
6913
6902
  return out;
6914
6903
  }
6904
+ var WORD_SPLIT = /[^\p{L}\p{N}]+/u;
6905
+ var MIN_TERM_LENGTH = 3;
6906
+ var FIELD_WEIGHTS = { key: 4, title: 3, header: 2 };
6907
+ var wordsOf = (text) => text.toLowerCase().split(WORD_SPLIT).filter((word) => word.length >= 2);
6908
+ 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);
6909
+ function searchSkills(skills, query, limit = 10) {
6910
+ const cap = Math.max(1, limit);
6911
+ const normalized = (query || "").trim().toLowerCase();
6912
+ const terms = [
6913
+ ...new Set(normalized.split(WORD_SPLIT).filter((term) => term.length >= MIN_TERM_LENGTH))
6914
+ ];
6915
+ if (terms.length === 0) return skills.slice(0, cap);
6916
+ const scored = skills.map((skill, index) => {
6917
+ const fields = {
6918
+ key: wordsOf(skill.key),
6919
+ title: wordsOf(skill.title || ""),
6920
+ header: wordsOf(skill.header || "")
6921
+ };
6922
+ const exact = skill.key.toLowerCase() === normalized || (skill.title || "").toLowerCase() === normalized;
6923
+ let score = exact ? 100 : 0;
6924
+ let coverage = 0;
6925
+ for (const term of terms) {
6926
+ let hit = false;
6927
+ for (const [field, weight] of Object.entries(FIELD_WEIGHTS)) {
6928
+ if (fields[field].some((word) => termHitsWord(term, word))) {
6929
+ score += weight;
6930
+ hit = true;
6931
+ }
6932
+ }
6933
+ if (hit) coverage += 1;
6934
+ }
6935
+ return { skill, score, coverage, index };
6936
+ }).filter((entry) => entry.score > 0);
6937
+ scored.sort((a, b) => b.coverage - a.coverage || b.score - a.score || a.index - b.index);
6938
+ return scored.slice(0, cap).map((entry) => entry.skill);
6939
+ }
6915
6940
  function buildSkillHeaderBlock(skills) {
6916
6941
  if (skills.length === 0) return "";
6917
6942
  const lines = skills.map((skill) => `- ${skill.key}: ${skill.header}`);
@@ -6935,24 +6960,65 @@ function dedupeToolsByName(tools) {
6935
6960
 
6936
6961
  // src/smart/skills/skillTools.ts
6937
6962
  var MAX_RETURNED_INDEX = 40;
6938
- 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.";
6963
+ var DEFAULT_SEARCH_LIMIT = 10;
6964
+ var MAX_SEARCH_LIMIT = 25;
6965
+ var isSearchDisclosure = (policy) => policy.disclosure === "search";
6966
+ var keySource = (policy) => isSearchDisclosure(policy) ? "search_skills" : "<available_skills>";
6967
+ 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.`;
6939
6968
  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.";
6969
+ 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.';
6940
6970
  function findSkill(deps, key) {
6941
6971
  return deps.skills.find((skill) => skill.key === key);
6942
6972
  }
6973
+ function createSearchSkillsTool(deps) {
6974
+ const tool = createTool({
6975
+ name: "search_skills",
6976
+ description: SEARCH_SKILLS_DESCRIPTION,
6977
+ schema: z.object({
6978
+ query: z.string().optional().describe("What you are trying to do, in a few words. Omit to list available skills."),
6979
+ limit: z.number().int().positive().optional().describe(`Max results to return (default ${DEFAULT_SEARCH_LIMIT}).`)
6980
+ }).strict(),
6981
+ func: async ({ query, limit }) => {
6982
+ const { skills, policy, registryRef: ref } = tool._deps;
6983
+ const available = await resolveAvailableSkills(skills, { modelTier: policy.modelTier });
6984
+ if (available.length === 0) {
6985
+ return { skills: [], total: 0, hint: "No skills are available in this workspace." };
6986
+ }
6987
+ const capped = Math.min(limit || DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT);
6988
+ const matches = searchSkills(available, query, capped);
6989
+ const missed = matches.length === 0;
6990
+ const shown = missed ? available.slice(0, capped) : matches;
6991
+ return {
6992
+ skills: shown.map((skill) => ({
6993
+ skillKey: skill.key,
6994
+ title: skill.title,
6995
+ header: skill.header,
6996
+ ...ref.openedSkillKeys.includes(skill.key) ? { alreadyOpen: true } : {}
6997
+ })),
6998
+ total: available.length,
6999
+ 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."
7000
+ };
7001
+ }
7002
+ });
7003
+ tool._deps = deps;
7004
+ tool.__source = "smart-skills";
7005
+ return tool;
7006
+ }
6943
7007
  function createOpenSkillTool(deps) {
6944
7008
  const tool = createTool({
6945
7009
  name: "open_skill",
6946
- description: OPEN_SKILL_DESCRIPTION,
7010
+ description: openSkillDescription(deps.policy),
6947
7011
  schema: z.object({
6948
- skillKey: z.string().min(1).describe("A key from <available_skills>."),
7012
+ skillKey: z.string().min(1).describe(`A key from ${keySource(deps.policy)}.`),
6949
7013
  query: z.string().optional().describe("What you need from the skill \u2014 used to rank a large skill's tools.")
6950
7014
  }).strict(),
6951
7015
  func: async ({ skillKey, query }) => {
6952
7016
  const { registryRef: ref, policy } = tool._deps;
6953
7017
  const skill = findSkill(tool._deps, skillKey);
6954
7018
  if (!skill) {
6955
- return { error: `Unknown skill: ${skillKey}. Choose a key listed in <available_skills>.` };
7019
+ return {
7020
+ error: `Unknown skill: ${skillKey}. ${isSearchDisclosure(policy) ? "Call search_skills to get a valid key." : "Choose a key listed in <available_skills>."}`
7021
+ };
6956
7022
  }
6957
7023
  if (skill.isAvailable && !await skill.isAvailable()) {
6958
7024
  return { error: `Skill ${skillKey} is not available in this workspace.` };
@@ -7041,7 +7107,9 @@ function createBindSkillToolsTool(deps) {
7041
7107
  return tool;
7042
7108
  }
7043
7109
  function createSkillTools(deps) {
7044
- return [createOpenSkillTool(deps), createBindSkillToolsTool(deps)];
7110
+ const tools = [createOpenSkillTool(deps), createBindSkillToolsTool(deps)];
7111
+ if (isSearchDisclosure(deps.policy)) tools.unshift(createSearchSkillsTool(deps));
7112
+ return tools;
7045
7113
  }
7046
7114
 
7047
7115
  // src/smart/subagents/types.ts
@@ -7721,7 +7789,8 @@ function createSmartAgent(opts) {
7721
7789
  if (changed) toolSet.skillRegistryRef.__onToolsChanged?.();
7722
7790
  }
7723
7791
  const syncPlanFromRef = (state2) => syncPlanStateWith(stateRef, state2);
7724
- const availableSkills = skillsEnabled ? await resolveAvailableSkills(skills, { modelTier: skillPolicy.modelTier }) : [];
7792
+ const catalogDisclosure = skillPolicy.disclosure !== "search";
7793
+ const availableSkills = skillsEnabled && catalogDisclosure ? await resolveAvailableSkills(skills, { modelTier: skillPolicy.modelTier }) : [];
7725
7794
  const skillBlock = availableSkills.length > 0 ? buildSkillHeaderBlock(availableSkills) : void 0;
7726
7795
  let subagentBlock;
7727
7796
  if (subagentsEnabled) {
@@ -10939,6 +11008,6 @@ function createProvider(config) {
10939
11008
  }
10940
11009
  }
10941
11010
 
10942
- 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, 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 };
11011
+ 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 };
10943
11012
  //# sourceMappingURL=index.mjs.map
10944
11013
  //# sourceMappingURL=index.mjs.map