@cognipeer/agent-sdk 0.8.4 → 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.cjs +88 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -13
- package/dist/index.d.ts +67 -13
- package/dist/index.mjs +87 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
244
|
-
* cheap one-line `header
|
|
245
|
-
* and (for small skills) bind its tools, or
|
|
246
|
-
* bind a chosen subset of a fat skill. This
|
|
247
|
-
* step small — the property small models
|
|
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
|
|
910
|
-
*
|
|
911
|
-
* the
|
|
912
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
244
|
-
* cheap one-line `header
|
|
245
|
-
* and (for small skills) bind its tools, or
|
|
246
|
-
* bind a chosen subset of a fat skill. This
|
|
247
|
-
* step small — the property small models
|
|
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
|
|
910
|
-
*
|
|
911
|
-
* the
|
|
912
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
@@ -6912,6 +6912,42 @@ async function resolveAvailableSkills(skills, opts = {}) {
|
|
|
6912
6912
|
}
|
|
6913
6913
|
return out;
|
|
6914
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
|
+
}
|
|
6915
6951
|
function buildSkillHeaderBlock(skills) {
|
|
6916
6952
|
if (skills.length === 0) return "";
|
|
6917
6953
|
const lines = skills.map((skill) => `- ${skill.key}: ${skill.header}`);
|
|
@@ -6935,24 +6971,65 @@ function dedupeToolsByName(tools) {
|
|
|
6935
6971
|
|
|
6936
6972
|
// src/smart/skills/skillTools.ts
|
|
6937
6973
|
var MAX_RETURNED_INDEX = 40;
|
|
6938
|
-
var
|
|
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.`;
|
|
6939
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.';
|
|
6940
6981
|
function findSkill(deps, key) {
|
|
6941
6982
|
return deps.skills.find((skill) => skill.key === key);
|
|
6942
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
|
+
}
|
|
6943
7018
|
function createOpenSkillTool(deps) {
|
|
6944
7019
|
const tool = createTool({
|
|
6945
7020
|
name: "open_skill",
|
|
6946
|
-
description:
|
|
7021
|
+
description: openSkillDescription(deps.policy),
|
|
6947
7022
|
schema: z.object({
|
|
6948
|
-
skillKey: z.string().min(1).describe(
|
|
7023
|
+
skillKey: z.string().min(1).describe(`A key from ${keySource(deps.policy)}.`),
|
|
6949
7024
|
query: z.string().optional().describe("What you need from the skill \u2014 used to rank a large skill's tools.")
|
|
6950
7025
|
}).strict(),
|
|
6951
7026
|
func: async ({ skillKey, query }) => {
|
|
6952
7027
|
const { registryRef: ref, policy } = tool._deps;
|
|
6953
7028
|
const skill = findSkill(tool._deps, skillKey);
|
|
6954
7029
|
if (!skill) {
|
|
6955
|
-
return {
|
|
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
|
+
};
|
|
6956
7033
|
}
|
|
6957
7034
|
if (skill.isAvailable && !await skill.isAvailable()) {
|
|
6958
7035
|
return { error: `Skill ${skillKey} is not available in this workspace.` };
|
|
@@ -7041,7 +7118,9 @@ function createBindSkillToolsTool(deps) {
|
|
|
7041
7118
|
return tool;
|
|
7042
7119
|
}
|
|
7043
7120
|
function createSkillTools(deps) {
|
|
7044
|
-
|
|
7121
|
+
const tools = [createOpenSkillTool(deps), createBindSkillToolsTool(deps)];
|
|
7122
|
+
if (isSearchDisclosure(deps.policy)) tools.unshift(createSearchSkillsTool(deps));
|
|
7123
|
+
return tools;
|
|
7045
7124
|
}
|
|
7046
7125
|
|
|
7047
7126
|
// src/smart/subagents/types.ts
|
|
@@ -7721,7 +7800,8 @@ function createSmartAgent(opts) {
|
|
|
7721
7800
|
if (changed) toolSet.skillRegistryRef.__onToolsChanged?.();
|
|
7722
7801
|
}
|
|
7723
7802
|
const syncPlanFromRef = (state2) => syncPlanStateWith(stateRef, state2);
|
|
7724
|
-
const
|
|
7803
|
+
const catalogDisclosure = skillPolicy.disclosure !== "search";
|
|
7804
|
+
const availableSkills = skillsEnabled && catalogDisclosure ? await resolveAvailableSkills(skills, { modelTier: skillPolicy.modelTier }) : [];
|
|
7725
7805
|
const skillBlock = availableSkills.length > 0 ? buildSkillHeaderBlock(availableSkills) : void 0;
|
|
7726
7806
|
let subagentBlock;
|
|
7727
7807
|
if (subagentsEnabled) {
|
|
@@ -10939,6 +11019,6 @@ function createProvider(config) {
|
|
|
10939
11019
|
}
|
|
10940
11020
|
}
|
|
10941
11021
|
|
|
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 };
|
|
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 };
|
|
10943
11023
|
//# sourceMappingURL=index.mjs.map
|
|
10944
11024
|
//# sourceMappingURL=index.mjs.map
|