@cognipeer/agent-sdk 0.8.2 → 0.8.4

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
@@ -2468,6 +2468,12 @@ declare function resolveToolApprovalState(state: SmartState, resolution: ToolApp
2468
2468
 
2469
2469
  declare function resolveUserQuestionState(state: SmartState, resolution: UserQuestionResolution): SmartState;
2470
2470
 
2471
+ /**
2472
+ * The built-in ask-user tool's name. Exported because more than one layer has to
2473
+ * recognise it: `createSmartAgent` builds the tool into the list it hands to
2474
+ * `createAgent`, which must then not attach a second one of its own.
2475
+ */
2476
+ declare const ASK_USER_TOOL_NAME = "ask_user_question";
2471
2477
  type AskUserStateRef = {
2472
2478
  pendingUserQuestions?: PendingUserQuestion[];
2473
2479
  ctx?: Record<string, any>;
@@ -2555,9 +2561,48 @@ type ImageContent = {
2555
2561
  } | {
2556
2562
  type: "url";
2557
2563
  url: string;
2564
+ mediaType?: string;
2565
+ };
2566
+ };
2567
+ /**
2568
+ * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
2569
+ * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
2570
+ * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
2571
+ * Bedrock Converse `document`. Providers without document support degrade
2572
+ * to a text placeholder referencing the file name/URL.
2573
+ */
2574
+ type FileContent = {
2575
+ type: "file";
2576
+ source: {
2577
+ type: "base64";
2578
+ mediaType: string;
2579
+ data: string;
2580
+ } | {
2581
+ type: "url";
2582
+ url: string;
2583
+ mediaType?: string;
2584
+ };
2585
+ /** Original file name, when known (required by some providers, e.g. Bedrock). */
2586
+ fileName?: string;
2587
+ };
2588
+ /**
2589
+ * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
2590
+ * audio-capable models as `input_audio`. Providers without audio support
2591
+ * degrade to a text placeholder.
2592
+ */
2593
+ type AudioContent = {
2594
+ type: "audio";
2595
+ source: {
2596
+ type: "base64";
2597
+ mediaType: string;
2598
+ data: string;
2599
+ } | {
2600
+ type: "url";
2601
+ url: string;
2602
+ mediaType?: string;
2558
2603
  };
2559
2604
  };
2560
- type ContentPart = TextContent | ImageContent;
2605
+ type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
2561
2606
  type ToolCall = {
2562
2607
  id: string;
2563
2608
  name: string;
@@ -2971,4 +3016,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
2971
3016
  */
2972
3017
  declare function createProvider(config: ProviderConfig): BaseProvider;
2973
3018
 
2974
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, 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 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, 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 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -2468,6 +2468,12 @@ declare function resolveToolApprovalState(state: SmartState, resolution: ToolApp
2468
2468
 
2469
2469
  declare function resolveUserQuestionState(state: SmartState, resolution: UserQuestionResolution): SmartState;
2470
2470
 
2471
+ /**
2472
+ * The built-in ask-user tool's name. Exported because more than one layer has to
2473
+ * recognise it: `createSmartAgent` builds the tool into the list it hands to
2474
+ * `createAgent`, which must then not attach a second one of its own.
2475
+ */
2476
+ declare const ASK_USER_TOOL_NAME = "ask_user_question";
2471
2477
  type AskUserStateRef = {
2472
2478
  pendingUserQuestions?: PendingUserQuestion[];
2473
2479
  ctx?: Record<string, any>;
@@ -2555,9 +2561,48 @@ type ImageContent = {
2555
2561
  } | {
2556
2562
  type: "url";
2557
2563
  url: string;
2564
+ mediaType?: string;
2565
+ };
2566
+ };
2567
+ /**
2568
+ * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
2569
+ * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
2570
+ * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
2571
+ * Bedrock Converse `document`. Providers without document support degrade
2572
+ * to a text placeholder referencing the file name/URL.
2573
+ */
2574
+ type FileContent = {
2575
+ type: "file";
2576
+ source: {
2577
+ type: "base64";
2578
+ mediaType: string;
2579
+ data: string;
2580
+ } | {
2581
+ type: "url";
2582
+ url: string;
2583
+ mediaType?: string;
2584
+ };
2585
+ /** Original file name, when known (required by some providers, e.g. Bedrock). */
2586
+ fileName?: string;
2587
+ };
2588
+ /**
2589
+ * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
2590
+ * audio-capable models as `input_audio`. Providers without audio support
2591
+ * degrade to a text placeholder.
2592
+ */
2593
+ type AudioContent = {
2594
+ type: "audio";
2595
+ source: {
2596
+ type: "base64";
2597
+ mediaType: string;
2598
+ data: string;
2599
+ } | {
2600
+ type: "url";
2601
+ url: string;
2602
+ mediaType?: string;
2558
2603
  };
2559
2604
  };
2560
- type ContentPart = TextContent | ImageContent;
2605
+ type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
2561
2606
  type ToolCall = {
2562
2607
  id: string;
2563
2608
  name: string;
@@ -2971,4 +3016,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
2971
3016
  */
2972
3017
  declare function createProvider(config: ProviderConfig): BaseProvider;
2973
3018
 
2974
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, 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 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, 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 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 };
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 };
package/dist/index.mjs CHANGED
@@ -4563,6 +4563,7 @@ function resolveUserQuestionState(state, resolution) {
4563
4563
  ctx
4564
4564
  };
4565
4565
  }
4566
+ var ASK_USER_TOOL_NAME = "ask_user_question";
4566
4567
  var DEFAULT_DESCRIPTION_WITH_FREETEXT = "Pause the agent and surface a structured prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Prefer concrete options the user can pick over open-ended free-text \u2014 list `options` whenever you can anticipate the choices. The user may type a custom answer for any question. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user answers, their selections come back as the tool result.";
4567
4568
  var DEFAULT_DESCRIPTION_NO_FREETEXT = "Pause the agent and surface a structured multi-choice prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Every question MUST include at least two `options` \u2014 free-text answers are disabled for this agent. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user picks, their selections come back as the tool result.";
4568
4569
  function buildOptionSchema() {
@@ -4598,7 +4599,7 @@ function createAskUserQuestionTool(stateRef, config) {
4598
4599
  const description = config.promptOverride ?? (allowFreeText ? DEFAULT_DESCRIPTION_WITH_FREETEXT : DEFAULT_DESCRIPTION_NO_FREETEXT);
4599
4600
  const questionSchema = buildQuestionSchema(allowFreeText);
4600
4601
  const askUser = createTool({
4601
- name: "ask_user_question",
4602
+ name: ASK_USER_TOOL_NAME,
4602
4603
  description,
4603
4604
  schema: z.object({
4604
4605
  questions: z.array(questionSchema).min(1).max(4).describe("1-4 related questions to ask in a single pause.")
@@ -4614,7 +4615,7 @@ function createAskUserQuestionTool(stateRef, config) {
4614
4615
  const entry = {
4615
4616
  id: nanoid(),
4616
4617
  toolCallId,
4617
- toolName: "ask_user_question",
4618
+ toolName: ASK_USER_TOOL_NAME,
4618
4619
  questions,
4619
4620
  status: "pending",
4620
4621
  requestedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -4970,14 +4971,15 @@ function createAgent(opts) {
4970
4971
  })();
4971
4972
  const askUserOnQuestion = typeof opts.humanInTheLoop?.askUser === "object" ? opts.humanInTheLoop?.askUser?.onQuestion : void 0;
4972
4973
  const askUserStateRef = askUserConfig ? { pendingUserQuestions: void 0, ctx: void 0, __onEvent: void 0, __currentToolCallId: void 0 } : void 0;
4973
- if (askUserConfig && askUserStateRef) {
4974
+ const hasTool = (name) => toolsBase.some((tool) => tool?.name === name);
4975
+ if (askUserConfig && askUserStateRef && !hasTool(ASK_USER_TOOL_NAME)) {
4974
4976
  toolsBase.push(createAskUserQuestionTool(askUserStateRef, askUserConfig));
4975
4977
  }
4976
4978
  const soManager = opts.outputSchema ? new StructuredOutputManager(opts.outputSchema, resolveStrategy(opts.model)) : void 0;
4977
4979
  if (soManager) {
4978
4980
  const modelCapabilities = getModelCapabilities(opts.model);
4979
4981
  const responseTool = soManager.getResponseTool();
4980
- if (responseTool && modelCapabilities.structuredOutput !== "native") {
4982
+ if (responseTool && modelCapabilities.structuredOutput !== "native" && !hasTool(responseTool.name)) {
4981
4983
  toolsBase.push(responseTool);
4982
4984
  }
4983
4985
  }
@@ -8590,6 +8592,78 @@ function resolveBudget(reasoning, effortBudget) {
8590
8592
  return void 0;
8591
8593
  }
8592
8594
 
8595
+ // src/providers/utils/media.ts
8596
+ var EXTENSION_MIME = {
8597
+ jpg: "image/jpeg",
8598
+ jpeg: "image/jpeg",
8599
+ png: "image/png",
8600
+ gif: "image/gif",
8601
+ webp: "image/webp",
8602
+ svg: "image/svg+xml",
8603
+ bmp: "image/bmp",
8604
+ tif: "image/tiff",
8605
+ tiff: "image/tiff",
8606
+ heic: "image/heic",
8607
+ heif: "image/heif",
8608
+ pdf: "application/pdf",
8609
+ csv: "text/csv",
8610
+ txt: "text/plain",
8611
+ md: "text/markdown",
8612
+ html: "text/html",
8613
+ doc: "application/msword",
8614
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
8615
+ xls: "application/vnd.ms-excel",
8616
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
8617
+ ppt: "application/vnd.ms-powerpoint",
8618
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
8619
+ mp3: "audio/mpeg",
8620
+ mpga: "audio/mpeg",
8621
+ wav: "audio/wav",
8622
+ ogg: "audio/ogg",
8623
+ flac: "audio/flac",
8624
+ aac: "audio/aac",
8625
+ m4a: "audio/mp4",
8626
+ webm: "audio/webm",
8627
+ mp4: "video/mp4",
8628
+ mov: "video/quicktime",
8629
+ avi: "video/x-msvideo"
8630
+ };
8631
+ function inferMediaTypeFromUrl(urlOrName) {
8632
+ if (!urlOrName) return void 0;
8633
+ const cleaned = urlOrName.split("?")[0].split("#")[0];
8634
+ const ext = cleaned.split(".").pop()?.toLowerCase();
8635
+ if (!ext || ext === cleaned.toLowerCase()) return void 0;
8636
+ return EXTENSION_MIME[ext];
8637
+ }
8638
+ function audioMimeToOpenAIFormat(mediaType) {
8639
+ const m = (mediaType ?? "").toLowerCase();
8640
+ if (m.includes("wav")) return "wav";
8641
+ return "mp3";
8642
+ }
8643
+ var BEDROCK_DOC_FORMATS = {
8644
+ "application/pdf": "pdf",
8645
+ "text/csv": "csv",
8646
+ "application/msword": "doc",
8647
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
8648
+ "application/vnd.ms-excel": "xls",
8649
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
8650
+ "text/html": "html",
8651
+ "text/plain": "txt",
8652
+ "text/markdown": "md"
8653
+ };
8654
+ function documentMimeToBedrockFormat(mediaType, fileName) {
8655
+ if (mediaType && BEDROCK_DOC_FORMATS[mediaType.toLowerCase()]) {
8656
+ return BEDROCK_DOC_FORMATS[mediaType.toLowerCase()];
8657
+ }
8658
+ const inferred = inferMediaTypeFromUrl(fileName);
8659
+ if (inferred && BEDROCK_DOC_FORMATS[inferred]) return BEDROCK_DOC_FORMATS[inferred];
8660
+ return void 0;
8661
+ }
8662
+ function sanitizeBedrockDocName(name, fallback = "document") {
8663
+ const cleaned = (name ?? "").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9\s\-()[\]]/g, " ").replace(/\s+/g, " ").trim();
8664
+ return cleaned || fallback;
8665
+ }
8666
+
8593
8667
  // src/providers/openai.ts
8594
8668
  var OpenAIProvider = class extends BaseProvider {
8595
8669
  constructor(config) {
@@ -8812,6 +8886,27 @@ var OpenAIProvider = class extends BaseProvider {
8812
8886
  const url = src.type === "url" ? src.url : `data:${src.mediaType};base64,${src.data}`;
8813
8887
  return { type: "input_image", image_url: url };
8814
8888
  }
8889
+ if (part.type === "file") {
8890
+ const src = part.source;
8891
+ if (src.type === "base64") {
8892
+ return {
8893
+ type: "input_file",
8894
+ filename: part.fileName ?? "file",
8895
+ file_data: `data:${src.mediaType};base64,${src.data}`
8896
+ };
8897
+ }
8898
+ return { type: "input_file", file_url: src.url };
8899
+ }
8900
+ if (part.type === "audio") {
8901
+ const src = part.source;
8902
+ if (src.type === "base64") {
8903
+ return {
8904
+ type: "input_audio",
8905
+ input_audio: { data: src.data, format: audioMimeToOpenAIFormat(src.mediaType) }
8906
+ };
8907
+ }
8908
+ return { type: textType, text: `[audio: ${src.url}]` };
8909
+ }
8815
8910
  return { type: textType, text: "" };
8816
8911
  });
8817
8912
  return { role, content };
@@ -8896,6 +8991,29 @@ var OpenAIProvider = class extends BaseProvider {
8896
8991
  const url = src.type === "url" ? src.url : `data:${src.mediaType};base64,${src.data}`;
8897
8992
  return { type: "image_url", image_url: { url } };
8898
8993
  }
8994
+ if (part.type === "file") {
8995
+ const src = part.source;
8996
+ if (src.type === "base64") {
8997
+ return {
8998
+ type: "file",
8999
+ file: {
9000
+ filename: part.fileName ?? "file",
9001
+ file_data: `data:${src.mediaType};base64,${src.data}`
9002
+ }
9003
+ };
9004
+ }
9005
+ return { type: "text", text: `[file: ${src.url}]` };
9006
+ }
9007
+ if (part.type === "audio") {
9008
+ const src = part.source;
9009
+ if (src.type === "base64") {
9010
+ return {
9011
+ type: "input_audio",
9012
+ input_audio: { data: src.data, format: audioMimeToOpenAIFormat(src.mediaType) }
9013
+ };
9014
+ }
9015
+ return { type: "text", text: `[audio: ${src.url}]` };
9016
+ }
8899
9017
  return part;
8900
9018
  });
8901
9019
  }
@@ -9293,6 +9411,22 @@ var AnthropicProvider = class extends BaseProvider {
9293
9411
  source: { type: "url", url: src.url }
9294
9412
  };
9295
9413
  }
9414
+ if (part.type === "file") {
9415
+ const src = part.source;
9416
+ const title = part.fileName ? { title: part.fileName } : {};
9417
+ if (src.type === "base64") {
9418
+ return {
9419
+ type: "document",
9420
+ source: { type: "base64", media_type: src.mediaType, data: src.data },
9421
+ ...title
9422
+ };
9423
+ }
9424
+ return { type: "document", source: { type: "url", url: src.url }, ...title };
9425
+ }
9426
+ if (part.type === "audio") {
9427
+ const src = part.source;
9428
+ return { type: "text", text: src.type === "url" ? `[audio: ${src.url}]` : "[audio attachment omitted: not supported by this model]" };
9429
+ }
9296
9430
  return part;
9297
9431
  });
9298
9432
  }
@@ -9760,6 +9894,24 @@ var BedrockProvider = class extends BaseProvider {
9760
9894
  }
9761
9895
  });
9762
9896
  }
9897
+ } else if (part.type === "file") {
9898
+ const src = part.source;
9899
+ const format = documentMimeToBedrockFormat(src.mediaType, part.fileName);
9900
+ if (src.type === "base64" && format) {
9901
+ content.push({
9902
+ document: {
9903
+ format,
9904
+ name: sanitizeBedrockDocName(part.fileName),
9905
+ source: { bytes: src.data }
9906
+ }
9907
+ });
9908
+ } else {
9909
+ const ref = src.type === "url" ? src.url : part.fileName ?? "attachment";
9910
+ content.push({ text: `[file: ${ref}]` });
9911
+ }
9912
+ } else if (part.type === "audio") {
9913
+ const src = part.source;
9914
+ content.push({ text: src.type === "url" ? `[audio: ${src.url}]` : "[audio attachment omitted: not supported by this model]" });
9763
9915
  }
9764
9916
  }
9765
9917
  }
@@ -10103,7 +10255,25 @@ var VertexProvider = class extends BaseProvider {
10103
10255
  });
10104
10256
  } else {
10105
10257
  parts.push({
10106
- fileData: { mimeType: "image/jpeg", fileUri: src.url }
10258
+ fileData: {
10259
+ mimeType: src.mediaType ?? inferMediaTypeFromUrl(src.url) ?? "image/jpeg",
10260
+ fileUri: src.url
10261
+ }
10262
+ });
10263
+ }
10264
+ } else if (part.type === "file" || part.type === "audio") {
10265
+ const src = part.source;
10266
+ const fallbackMime = part.type === "audio" ? "audio/mpeg" : "application/pdf";
10267
+ if (src.type === "base64") {
10268
+ parts.push({
10269
+ inlineData: { mimeType: src.mediaType ?? fallbackMime, data: src.data }
10270
+ });
10271
+ } else {
10272
+ parts.push({
10273
+ fileData: {
10274
+ mimeType: src.mediaType ?? inferMediaTypeFromUrl(src.url) ?? inferMediaTypeFromUrl(part.fileName) ?? fallbackMime,
10275
+ fileUri: src.url
10276
+ }
10107
10277
  });
10108
10278
  }
10109
10279
  }
@@ -10448,9 +10618,50 @@ function convertContent(content) {
10448
10618
  }
10449
10619
  }
10450
10620
  }
10621
+ if (part.type === "file" || part.type === "document") {
10622
+ const source = extractBinarySource(part);
10623
+ if (source) {
10624
+ const fileName = part.metadata?.filename ?? part.metadata?.fileName ?? part.fileName ?? part.filename ?? part.name ?? part.file?.filename;
10625
+ return { type: "file", source, ...fileName ? { fileName } : {} };
10626
+ }
10627
+ }
10628
+ if (part.type === "audio" || part.type === "input_audio") {
10629
+ const ia = part.input_audio;
10630
+ if (ia?.data) {
10631
+ const mediaType = ia.format === "wav" ? "audio/wav" : "audio/mpeg";
10632
+ return { type: "audio", source: { type: "base64", mediaType, data: ia.data } };
10633
+ }
10634
+ const source = extractBinarySource(part);
10635
+ if (source) return { type: "audio", source };
10636
+ }
10451
10637
  return { type: "text", text: part.text ?? part.content ?? JSON.stringify(part) };
10452
10638
  });
10453
10639
  }
10640
+ function extractBinarySource(part) {
10641
+ const src = part.source;
10642
+ if (src?.type === "base64" && src.data) {
10643
+ return { type: "base64", mediaType: src.mediaType ?? src.media_type ?? src.mime_type ?? "application/octet-stream", data: src.data };
10644
+ }
10645
+ if (src?.type === "url" && src.url) {
10646
+ const mediaType2 = src.mediaType ?? src.media_type ?? src.mime_type;
10647
+ return { type: "url", url: src.url, ...mediaType2 ? { mediaType: mediaType2 } : {} };
10648
+ }
10649
+ const mediaType = part.mime_type ?? part.mimeType ?? part.media_type ?? part.mediaType;
10650
+ if (part.source_type === "base64" && part.data) {
10651
+ return { type: "base64", mediaType: mediaType ?? "application/octet-stream", data: part.data };
10652
+ }
10653
+ if (part.source_type === "url" && part.url) {
10654
+ return { type: "url", url: part.url, ...mediaType ? { mediaType } : {} };
10655
+ }
10656
+ const value = part.data ?? part.url ?? part.file?.file_data;
10657
+ if (typeof value === "string" && value) {
10658
+ const match = value.match(/^data:([^;]+);base64,(.+)$/);
10659
+ if (match) return { type: "base64", mediaType: mediaType ?? match[1], data: match[2] };
10660
+ if (/^https?:\/\//.test(value)) return { type: "url", url: value, ...mediaType ? { mediaType } : {} };
10661
+ if (mediaType) return { type: "base64", mediaType, data: value };
10662
+ }
10663
+ return void 0;
10664
+ }
10454
10665
  function isZodSchema(obj) {
10455
10666
  return obj != null && typeof obj === "object" && typeof obj.safeParse === "function" && "_def" in obj;
10456
10667
  }
@@ -10728,6 +10939,6 @@ function createProvider(config) {
10728
10939
  }
10729
10940
  }
10730
10941
 
10731
- export { AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, GuardrailPhase, InMemoryMemoryStore, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, ToolBasedStrategy, VertexProvider, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
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 };
10732
10943
  //# sourceMappingURL=index.mjs.map
10733
10944
  //# sourceMappingURL=index.mjs.map