@cognipeer/agent-sdk 0.8.2 → 0.8.3

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
@@ -2555,9 +2555,48 @@ type ImageContent = {
2555
2555
  } | {
2556
2556
  type: "url";
2557
2557
  url: string;
2558
+ mediaType?: string;
2558
2559
  };
2559
2560
  };
2560
- type ContentPart = TextContent | ImageContent;
2561
+ /**
2562
+ * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
2563
+ * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
2564
+ * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
2565
+ * Bedrock Converse `document`. Providers without document support degrade
2566
+ * to a text placeholder referencing the file name/URL.
2567
+ */
2568
+ type FileContent = {
2569
+ type: "file";
2570
+ source: {
2571
+ type: "base64";
2572
+ mediaType: string;
2573
+ data: string;
2574
+ } | {
2575
+ type: "url";
2576
+ url: string;
2577
+ mediaType?: string;
2578
+ };
2579
+ /** Original file name, when known (required by some providers, e.g. Bedrock). */
2580
+ fileName?: string;
2581
+ };
2582
+ /**
2583
+ * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
2584
+ * audio-capable models as `input_audio`. Providers without audio support
2585
+ * degrade to a text placeholder.
2586
+ */
2587
+ type AudioContent = {
2588
+ type: "audio";
2589
+ source: {
2590
+ type: "base64";
2591
+ mediaType: string;
2592
+ data: string;
2593
+ } | {
2594
+ type: "url";
2595
+ url: string;
2596
+ mediaType?: string;
2597
+ };
2598
+ };
2599
+ type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
2561
2600
  type ToolCall = {
2562
2601
  id: string;
2563
2602
  name: string;
@@ -2971,4 +3010,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
2971
3010
  */
2972
3011
  declare function createProvider(config: ProviderConfig): BaseProvider;
2973
3012
 
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 };
3013
+ export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
package/dist/index.d.ts CHANGED
@@ -2555,9 +2555,48 @@ type ImageContent = {
2555
2555
  } | {
2556
2556
  type: "url";
2557
2557
  url: string;
2558
+ mediaType?: string;
2558
2559
  };
2559
2560
  };
2560
- type ContentPart = TextContent | ImageContent;
2561
+ /**
2562
+ * A document attachment (PDF, DOCX, CSV, …). Providers map this to their
2563
+ * native document blocks: Gemini `inlineData`/`fileData`, Anthropic
2564
+ * `document`, OpenAI Chat Completions `file` / Responses `input_file`,
2565
+ * Bedrock Converse `document`. Providers without document support degrade
2566
+ * to a text placeholder referencing the file name/URL.
2567
+ */
2568
+ type FileContent = {
2569
+ type: "file";
2570
+ source: {
2571
+ type: "base64";
2572
+ mediaType: string;
2573
+ data: string;
2574
+ } | {
2575
+ type: "url";
2576
+ url: string;
2577
+ mediaType?: string;
2578
+ };
2579
+ /** Original file name, when known (required by some providers, e.g. Bedrock). */
2580
+ fileName?: string;
2581
+ };
2582
+ /**
2583
+ * An audio attachment. Gemini accepts it as `inlineData`/`fileData`; OpenAI
2584
+ * audio-capable models as `input_audio`. Providers without audio support
2585
+ * degrade to a text placeholder.
2586
+ */
2587
+ type AudioContent = {
2588
+ type: "audio";
2589
+ source: {
2590
+ type: "base64";
2591
+ mediaType: string;
2592
+ data: string;
2593
+ } | {
2594
+ type: "url";
2595
+ url: string;
2596
+ mediaType?: string;
2597
+ };
2598
+ };
2599
+ type ContentPart = TextContent | ImageContent | FileContent | AudioContent;
2561
2600
  type ToolCall = {
2562
2601
  id: string;
2563
2602
  name: string;
@@ -2971,4 +3010,4 @@ declare function fromNativeProvider(provider: BaseProvider, options?: NativeMode
2971
3010
  */
2972
3011
  declare function createProvider(config: ProviderConfig): BaseProvider;
2973
3012
 
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 };
3013
+ export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, type AudioContent, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuildChildConfig, type BuiltInRuntimeProfile, CCRStore, CONTEXT_PILOT_JSON_MARKER_KEY, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type CompressToolOutputParams, type ContextPilotCCRConfig, type ContextPilotCacheAlignmentConfig, type ContextPilotCompressionConfig, type ContextPilotCompressionStats, type ContextPilotCompressorKind, type ContextPilotConfig, type ContextPilotDedupConfig, type ContextPilotDiffCompressionConfig, type ContextPilotJsonCompressionConfig, type ContextPilotLogCompressionConfig, type ContextPilotResult, type ContextPilotRuntime, type ContextPilotSearchCompressionConfig, type ContextPilotTextCompressionConfig, type ContextPolicy, type ContextToolsStateRef, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DedupTracker, type DelegationEventStamp, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FileContent, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, type HumanInTheLoopAskUserConfig, type HumanInTheLoopOptions, type HumanInTheLoopRuntimeConfig, type ImageContent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type LoadSkillsOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, type NativeReasoningConfig, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PendingUserQuestion, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type PromptHooks, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type ReasoningConfig, type ReasoningLevel, type ReflectionCadence, type ReflectionConfig, type ReflectionEvent, type ReflectionHookContext, type ReflectionRecord, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedContextPilotConfig, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, SMALL_TIER_SKILL_POLICY, type SerializableSmartState, type Skill, type SkillExecutionContext, type SkillFrontmatter, type SkillFs, type SkillModelTier, type SkillPolicy, type SkillRegistryRef, type SkillToolDeps, type SkillToolHeader, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SubagentDef, type SubagentEvent, type SubagentMode, type SubagentPendingRecord, type SubagentPolicy, type SubagentRegistryRef, type SubagentResult, type SubagentToolDeps, type SubagentToolNames, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TextContent, type TokenCounter, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCachePolicy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type ToolRetryPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolDetails, type TraceToolResponseSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, type UserQuestionAnswer, type UserQuestionAnswerSet, type UserQuestionEvent, type UserQuestionItem, type UserQuestionOption, type UserQuestionResolution, type UserQuestionStatus, VertexProvider, type VertexProviderConfig, type VolatileContentFinding, type VolatileContentPattern, agentVerdictRule, appendBoundTools, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, canOpenSkill, canSpawn, captureSnapshot, codePresenceRule, cognipeerSink, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createJsonGuardrail, createManageTodoTool, createOpenSkillTool, createParallelTool, createProvider, createRegexGuardrail, createResolverNode, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, dedupeToolsByName, defaultTokenCounter, detectTextFormat, detectVolatileContent, emptyUsage, evaluateGuardrails, extractLatestUserQuery, fileSink, findSubagent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasToolResponseRecoveryReference, httpSink, isSmartModel, jsonSchemaRule, loadSkillsFromDisk, normalizeSmartAgentOptions, otlpSink, parseSkillFrontmatter, readMemoryFacts, regexRule, resolveAvailableSkills, resolveAvailableSubagents, resolveMemoryStore, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveToolApprovalState, resolveUserQuestionState, restoreSnapshot, runSmartAgentEvalHarness, scoreItemsByRelevance, seedChildMessages, selectTopIndicesInOrder, setTokenCounter, startStreamingSession, tokenize, traceSessionToOtlp, validateReasoningConfig, withTools, withinDepth, writeSummaryFactsToMemory };
package/dist/index.mjs CHANGED
@@ -8590,6 +8590,78 @@ function resolveBudget(reasoning, effortBudget) {
8590
8590
  return void 0;
8591
8591
  }
8592
8592
 
8593
+ // src/providers/utils/media.ts
8594
+ var EXTENSION_MIME = {
8595
+ jpg: "image/jpeg",
8596
+ jpeg: "image/jpeg",
8597
+ png: "image/png",
8598
+ gif: "image/gif",
8599
+ webp: "image/webp",
8600
+ svg: "image/svg+xml",
8601
+ bmp: "image/bmp",
8602
+ tif: "image/tiff",
8603
+ tiff: "image/tiff",
8604
+ heic: "image/heic",
8605
+ heif: "image/heif",
8606
+ pdf: "application/pdf",
8607
+ csv: "text/csv",
8608
+ txt: "text/plain",
8609
+ md: "text/markdown",
8610
+ html: "text/html",
8611
+ doc: "application/msword",
8612
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
8613
+ xls: "application/vnd.ms-excel",
8614
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
8615
+ ppt: "application/vnd.ms-powerpoint",
8616
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
8617
+ mp3: "audio/mpeg",
8618
+ mpga: "audio/mpeg",
8619
+ wav: "audio/wav",
8620
+ ogg: "audio/ogg",
8621
+ flac: "audio/flac",
8622
+ aac: "audio/aac",
8623
+ m4a: "audio/mp4",
8624
+ webm: "audio/webm",
8625
+ mp4: "video/mp4",
8626
+ mov: "video/quicktime",
8627
+ avi: "video/x-msvideo"
8628
+ };
8629
+ function inferMediaTypeFromUrl(urlOrName) {
8630
+ if (!urlOrName) return void 0;
8631
+ const cleaned = urlOrName.split("?")[0].split("#")[0];
8632
+ const ext = cleaned.split(".").pop()?.toLowerCase();
8633
+ if (!ext || ext === cleaned.toLowerCase()) return void 0;
8634
+ return EXTENSION_MIME[ext];
8635
+ }
8636
+ function audioMimeToOpenAIFormat(mediaType) {
8637
+ const m = (mediaType ?? "").toLowerCase();
8638
+ if (m.includes("wav")) return "wav";
8639
+ return "mp3";
8640
+ }
8641
+ var BEDROCK_DOC_FORMATS = {
8642
+ "application/pdf": "pdf",
8643
+ "text/csv": "csv",
8644
+ "application/msword": "doc",
8645
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
8646
+ "application/vnd.ms-excel": "xls",
8647
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
8648
+ "text/html": "html",
8649
+ "text/plain": "txt",
8650
+ "text/markdown": "md"
8651
+ };
8652
+ function documentMimeToBedrockFormat(mediaType, fileName) {
8653
+ if (mediaType && BEDROCK_DOC_FORMATS[mediaType.toLowerCase()]) {
8654
+ return BEDROCK_DOC_FORMATS[mediaType.toLowerCase()];
8655
+ }
8656
+ const inferred = inferMediaTypeFromUrl(fileName);
8657
+ if (inferred && BEDROCK_DOC_FORMATS[inferred]) return BEDROCK_DOC_FORMATS[inferred];
8658
+ return void 0;
8659
+ }
8660
+ function sanitizeBedrockDocName(name, fallback = "document") {
8661
+ const cleaned = (name ?? "").replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9\s\-()[\]]/g, " ").replace(/\s+/g, " ").trim();
8662
+ return cleaned || fallback;
8663
+ }
8664
+
8593
8665
  // src/providers/openai.ts
8594
8666
  var OpenAIProvider = class extends BaseProvider {
8595
8667
  constructor(config) {
@@ -8812,6 +8884,27 @@ var OpenAIProvider = class extends BaseProvider {
8812
8884
  const url = src.type === "url" ? src.url : `data:${src.mediaType};base64,${src.data}`;
8813
8885
  return { type: "input_image", image_url: url };
8814
8886
  }
8887
+ if (part.type === "file") {
8888
+ const src = part.source;
8889
+ if (src.type === "base64") {
8890
+ return {
8891
+ type: "input_file",
8892
+ filename: part.fileName ?? "file",
8893
+ file_data: `data:${src.mediaType};base64,${src.data}`
8894
+ };
8895
+ }
8896
+ return { type: "input_file", file_url: src.url };
8897
+ }
8898
+ if (part.type === "audio") {
8899
+ const src = part.source;
8900
+ if (src.type === "base64") {
8901
+ return {
8902
+ type: "input_audio",
8903
+ input_audio: { data: src.data, format: audioMimeToOpenAIFormat(src.mediaType) }
8904
+ };
8905
+ }
8906
+ return { type: textType, text: `[audio: ${src.url}]` };
8907
+ }
8815
8908
  return { type: textType, text: "" };
8816
8909
  });
8817
8910
  return { role, content };
@@ -8896,6 +8989,29 @@ var OpenAIProvider = class extends BaseProvider {
8896
8989
  const url = src.type === "url" ? src.url : `data:${src.mediaType};base64,${src.data}`;
8897
8990
  return { type: "image_url", image_url: { url } };
8898
8991
  }
8992
+ if (part.type === "file") {
8993
+ const src = part.source;
8994
+ if (src.type === "base64") {
8995
+ return {
8996
+ type: "file",
8997
+ file: {
8998
+ filename: part.fileName ?? "file",
8999
+ file_data: `data:${src.mediaType};base64,${src.data}`
9000
+ }
9001
+ };
9002
+ }
9003
+ return { type: "text", text: `[file: ${src.url}]` };
9004
+ }
9005
+ if (part.type === "audio") {
9006
+ const src = part.source;
9007
+ if (src.type === "base64") {
9008
+ return {
9009
+ type: "input_audio",
9010
+ input_audio: { data: src.data, format: audioMimeToOpenAIFormat(src.mediaType) }
9011
+ };
9012
+ }
9013
+ return { type: "text", text: `[audio: ${src.url}]` };
9014
+ }
8899
9015
  return part;
8900
9016
  });
8901
9017
  }
@@ -9293,6 +9409,22 @@ var AnthropicProvider = class extends BaseProvider {
9293
9409
  source: { type: "url", url: src.url }
9294
9410
  };
9295
9411
  }
9412
+ if (part.type === "file") {
9413
+ const src = part.source;
9414
+ const title = part.fileName ? { title: part.fileName } : {};
9415
+ if (src.type === "base64") {
9416
+ return {
9417
+ type: "document",
9418
+ source: { type: "base64", media_type: src.mediaType, data: src.data },
9419
+ ...title
9420
+ };
9421
+ }
9422
+ return { type: "document", source: { type: "url", url: src.url }, ...title };
9423
+ }
9424
+ if (part.type === "audio") {
9425
+ const src = part.source;
9426
+ return { type: "text", text: src.type === "url" ? `[audio: ${src.url}]` : "[audio attachment omitted: not supported by this model]" };
9427
+ }
9296
9428
  return part;
9297
9429
  });
9298
9430
  }
@@ -9760,6 +9892,24 @@ var BedrockProvider = class extends BaseProvider {
9760
9892
  }
9761
9893
  });
9762
9894
  }
9895
+ } else if (part.type === "file") {
9896
+ const src = part.source;
9897
+ const format = documentMimeToBedrockFormat(src.mediaType, part.fileName);
9898
+ if (src.type === "base64" && format) {
9899
+ content.push({
9900
+ document: {
9901
+ format,
9902
+ name: sanitizeBedrockDocName(part.fileName),
9903
+ source: { bytes: src.data }
9904
+ }
9905
+ });
9906
+ } else {
9907
+ const ref = src.type === "url" ? src.url : part.fileName ?? "attachment";
9908
+ content.push({ text: `[file: ${ref}]` });
9909
+ }
9910
+ } else if (part.type === "audio") {
9911
+ const src = part.source;
9912
+ content.push({ text: src.type === "url" ? `[audio: ${src.url}]` : "[audio attachment omitted: not supported by this model]" });
9763
9913
  }
9764
9914
  }
9765
9915
  }
@@ -10103,7 +10253,25 @@ var VertexProvider = class extends BaseProvider {
10103
10253
  });
10104
10254
  } else {
10105
10255
  parts.push({
10106
- fileData: { mimeType: "image/jpeg", fileUri: src.url }
10256
+ fileData: {
10257
+ mimeType: src.mediaType ?? inferMediaTypeFromUrl(src.url) ?? "image/jpeg",
10258
+ fileUri: src.url
10259
+ }
10260
+ });
10261
+ }
10262
+ } else if (part.type === "file" || part.type === "audio") {
10263
+ const src = part.source;
10264
+ const fallbackMime = part.type === "audio" ? "audio/mpeg" : "application/pdf";
10265
+ if (src.type === "base64") {
10266
+ parts.push({
10267
+ inlineData: { mimeType: src.mediaType ?? fallbackMime, data: src.data }
10268
+ });
10269
+ } else {
10270
+ parts.push({
10271
+ fileData: {
10272
+ mimeType: src.mediaType ?? inferMediaTypeFromUrl(src.url) ?? inferMediaTypeFromUrl(part.fileName) ?? fallbackMime,
10273
+ fileUri: src.url
10274
+ }
10107
10275
  });
10108
10276
  }
10109
10277
  }
@@ -10448,9 +10616,50 @@ function convertContent(content) {
10448
10616
  }
10449
10617
  }
10450
10618
  }
10619
+ if (part.type === "file" || part.type === "document") {
10620
+ const source = extractBinarySource(part);
10621
+ if (source) {
10622
+ const fileName = part.metadata?.filename ?? part.metadata?.fileName ?? part.fileName ?? part.filename ?? part.name ?? part.file?.filename;
10623
+ return { type: "file", source, ...fileName ? { fileName } : {} };
10624
+ }
10625
+ }
10626
+ if (part.type === "audio" || part.type === "input_audio") {
10627
+ const ia = part.input_audio;
10628
+ if (ia?.data) {
10629
+ const mediaType = ia.format === "wav" ? "audio/wav" : "audio/mpeg";
10630
+ return { type: "audio", source: { type: "base64", mediaType, data: ia.data } };
10631
+ }
10632
+ const source = extractBinarySource(part);
10633
+ if (source) return { type: "audio", source };
10634
+ }
10451
10635
  return { type: "text", text: part.text ?? part.content ?? JSON.stringify(part) };
10452
10636
  });
10453
10637
  }
10638
+ function extractBinarySource(part) {
10639
+ const src = part.source;
10640
+ if (src?.type === "base64" && src.data) {
10641
+ return { type: "base64", mediaType: src.mediaType ?? src.media_type ?? src.mime_type ?? "application/octet-stream", data: src.data };
10642
+ }
10643
+ if (src?.type === "url" && src.url) {
10644
+ const mediaType2 = src.mediaType ?? src.media_type ?? src.mime_type;
10645
+ return { type: "url", url: src.url, ...mediaType2 ? { mediaType: mediaType2 } : {} };
10646
+ }
10647
+ const mediaType = part.mime_type ?? part.mimeType ?? part.media_type ?? part.mediaType;
10648
+ if (part.source_type === "base64" && part.data) {
10649
+ return { type: "base64", mediaType: mediaType ?? "application/octet-stream", data: part.data };
10650
+ }
10651
+ if (part.source_type === "url" && part.url) {
10652
+ return { type: "url", url: part.url, ...mediaType ? { mediaType } : {} };
10653
+ }
10654
+ const value = part.data ?? part.url ?? part.file?.file_data;
10655
+ if (typeof value === "string" && value) {
10656
+ const match = value.match(/^data:([^;]+);base64,(.+)$/);
10657
+ if (match) return { type: "base64", mediaType: mediaType ?? match[1], data: match[2] };
10658
+ if (/^https?:\/\//.test(value)) return { type: "url", url: value, ...mediaType ? { mediaType } : {} };
10659
+ if (mediaType) return { type: "base64", mediaType, data: value };
10660
+ }
10661
+ return void 0;
10662
+ }
10454
10663
  function isZodSchema(obj) {
10455
10664
  return obj != null && typeof obj === "object" && typeof obj.safeParse === "function" && "_def" in obj;
10456
10665
  }