@ljoukov/llm 7.0.14 → 7.0.15

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
@@ -326,6 +326,17 @@ type LlmTextResult = {
326
326
  readonly usage?: LlmUsageTokens;
327
327
  readonly costUsd: number;
328
328
  readonly grounding?: GroundingMetadata;
329
+ readonly openAi?: LlmOpenAiResponseMetadata;
330
+ };
331
+ type LlmOpenAiResponseContainerReference = {
332
+ readonly containerId: string;
333
+ readonly toolType: "shell" | "code_interpreter";
334
+ readonly itemId?: string;
335
+ readonly callId?: string;
336
+ };
337
+ type LlmOpenAiResponseMetadata = {
338
+ readonly responseId?: string;
339
+ readonly containers: readonly LlmOpenAiResponseContainerReference[];
329
340
  };
330
341
  type LlmTextStream = {
331
342
  readonly events: AsyncIterable<LlmStreamEvent>;
@@ -663,6 +674,59 @@ declare const files: {
663
674
  readonly content: typeof filesContent;
664
675
  };
665
676
 
677
+ type LlmOpenAiContainerNetworkPolicy = {
678
+ readonly type: "disabled";
679
+ } | {
680
+ readonly type: "allowlist";
681
+ readonly allowedDomains: readonly string[];
682
+ readonly domainSecrets?: readonly {
683
+ readonly domain: string;
684
+ readonly name: string;
685
+ readonly value: string;
686
+ }[];
687
+ };
688
+ type LlmOpenAiContainerCreateOptions = {
689
+ readonly name: string;
690
+ readonly fileIds?: readonly string[];
691
+ readonly memoryLimit?: "1g" | "4g" | "16g" | "64g";
692
+ readonly networkPolicy?: LlmOpenAiContainerNetworkPolicy;
693
+ readonly expiresAfterMinutes?: number;
694
+ };
695
+ type LlmOpenAiContainer = {
696
+ readonly id: string;
697
+ readonly name: string;
698
+ readonly status: string;
699
+ readonly createdAt?: number;
700
+ readonly lastActiveAt?: number;
701
+ readonly memoryLimit?: "1g" | "4g" | "16g" | "64g";
702
+ };
703
+ type LlmOpenAiContainerFile = {
704
+ readonly id: string;
705
+ readonly containerId: string;
706
+ readonly path: string;
707
+ readonly bytes?: number | null;
708
+ readonly createdAt?: number;
709
+ readonly source?: string;
710
+ };
711
+ type LlmOpenAiContainerFileUpload = {
712
+ readonly containerId: string;
713
+ readonly filename: string;
714
+ readonly data: ArrayBuffer | ArrayBufferView | Blob | Response | AsyncIterable<ArrayBufferView>;
715
+ readonly mimeType?: string;
716
+ };
717
+ declare function createOpenAiContainer(options: LlmOpenAiContainerCreateOptions): Promise<LlmOpenAiContainer>;
718
+ declare function deleteOpenAiContainer(containerId: string): Promise<void>;
719
+ declare function listOpenAiContainerFiles(containerId: string): Promise<readonly LlmOpenAiContainerFile[]>;
720
+ declare function uploadOpenAiContainerFile(upload: LlmOpenAiContainerFileUpload): Promise<LlmOpenAiContainerFile>;
721
+ declare function downloadOpenAiContainerFile(params: {
722
+ readonly containerId: string;
723
+ readonly fileId: string;
724
+ }): Promise<Uint8Array>;
725
+ declare function downloadOpenAiContainerFileText(params: {
726
+ readonly containerId: string;
727
+ readonly fileId: string;
728
+ }): Promise<string>;
729
+
666
730
  /**
667
731
  * Loads `.env.local` from `process.cwd()` once.
668
732
  *
@@ -1108,4 +1172,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
1108
1172
  declare function isFireworksModelId(value: string): value is FireworksModelId;
1109
1173
  declare function resolveFireworksModelId(model: string): string | undefined;
1110
1174
 
1111
- export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentLogLineSink, type AgentLoggingConfig, type AgentLoggingSelection, type AgentLoopStream, type AgentPathInfo, type AgentPathKind, type AgentRunCompletedTelemetryEvent, type AgentRunStartedTelemetryEvent, type AgentRunStreamTelemetryEvent, type AgentSubagentToolConfig, type AgentSubagentToolPromptPattern, type AgentSubagentToolSelection, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, type AssessmentSubagentInput, CHATGPT_IMAGE_MODEL_IDS, CHATGPT_MODEL_IDS, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type CandidateAssessment, type CandidateEvolutionOptions, type CandidateEvolutionResult, type CandidateEvolutionSnapshot, type CandidateEvolutionStats, type CandidateFeedbackEntry, type CandidateIssue, type CandidateProposal, type CandidateRecord, type ChatGptAuthProfile, type ChatGptImageModelId, type ChatGptModelId, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CodexViewImageToolInput, type CreateApplyPatchToolOptions, DEFAULT_FILE_TTL_SECONDS, DEFAULT_SIGNED_URL_TTL_SECONDS, EXPERIMENTAL_CHATGPT_MODEL_PREFIX, type ExperimentalChatGptModelId, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FeedbackScope, type FireworksModelId, GEMINI_IMAGE_MODEL_IDS, GEMINI_MODEL_IDS, GEMINI_TEXT_MODEL_IDS, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiImageModelId, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiTextModelId, type GeminiWriteFileToolInput, type GenerationSubagent, type GenerationSubagentInput, InMemoryAgentFilesystem, type JsonSchema, LLM_IMAGE_MODEL_IDS, LLM_MODEL_IDS, LLM_TEXT_MODEL_IDS, type ListedChatGptModelId, type LlmBaseRequest, type LlmBlockedEvent, type LlmCallCompletedTelemetryEvent, type LlmCallStartedTelemetryEvent, type LlmCallStreamTelemetryEvent, type LlmChatGptGenerateImagesRequest, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFileCreateParams, type LlmFileDeleted, type LlmFileUploadBackend, type LlmFileUploadEvent, type LlmFileUploadMetrics, type LlmFileUploadMode, type LlmFileUploadSource, type LlmFunctionTool, type LlmGeminiGenerateImagesRequest, type LlmGenerateImagesRequest, type LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmMediaResolution, type LlmModelEvent, type LlmModelId, type LlmOpenAiGenerateImagesRequest, type LlmOpenAiImageBackground, type LlmOpenAiImageModeration, type LlmOpenAiImageNumImages, type LlmOpenAiImageOutputFormat, type LlmOpenAiImagePartialImageCount, type LlmOpenAiImageQuality, type LlmOpenAiImageResolution, type LlmOpenAiShellEnvironment, type LlmOpenAiShellNetworkPolicy, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, type LlmTelemetryOperation, type LlmTextDeltaEvent, type LlmTextModelId, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmThinkingLevel, type LlmToolCallCompletedEvent, type LlmToolCallContext, type LlmToolCallResult, type LlmToolCallStartedEvent, type LlmToolCallStreamEvent, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopSteeringAppendResult, type LlmToolLoopSteeringChannel, type LlmToolLoopSteeringInput, type LlmToolLoopSteeringMessage, type LlmToolLoopStep, type LlmToolLoopStream, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type ModelConcurrencyConfig, type ModelConcurrencyProvider, OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION, OPENAI_GPT_IMAGE_2_BACKGROUNDS, OPENAI_GPT_IMAGE_2_MODERATION_LEVELS, OPENAI_GPT_IMAGE_2_NUM_IMAGES, OPENAI_GPT_IMAGE_2_OUTPUT_FORMATS, OPENAI_GPT_IMAGE_2_PARTIAL_IMAGE_COUNTS, OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS, OPENAI_GPT_IMAGE_2_QUALITY_LEVELS, OPENAI_GPT_IMAGE_2_RESOLUTIONS, OPENAI_GPT_IMAGE_2_SIZE_CONSTRAINTS, OPENAI_IMAGE_MODEL_IDS, OPENAI_MODEL_IDS, type OpenAiGptImage2Background, type OpenAiGptImage2CustomResolution, type OpenAiGptImage2ListedResolution, type OpenAiGptImage2Moderation, type OpenAiGptImage2NumImages, type OpenAiGptImage2OutputFormat, type OpenAiGptImage2PartialImageCount, type OpenAiGptImage2PopularResolution, type OpenAiGptImage2Quality, type OpenAiGptImage2Resolution, type OpenAiGptImage2ResolutionValidationResult, type OpenAiImageModelId, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, type TelemetryConfig, type TelemetryEvent, type TelemetrySelection, type TelemetrySink, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, configureTelemetry, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createReplaceTool, createRgSearchTool, createToolLoopSteeringChannel, createViewImageTool, createWriteFileTool, customTool, emptyFileUploadMetrics, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, files, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isChatGptImageModelId, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveChatGptImageProviderModel, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, validateOpenAiGptImage2Resolution };
1175
+ export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentLogLineSink, type AgentLoggingConfig, type AgentLoggingSelection, type AgentLoopStream, type AgentPathInfo, type AgentPathKind, type AgentRunCompletedTelemetryEvent, type AgentRunStartedTelemetryEvent, type AgentRunStreamTelemetryEvent, type AgentSubagentToolConfig, type AgentSubagentToolPromptPattern, type AgentSubagentToolSelection, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, type AssessmentSubagentInput, CHATGPT_IMAGE_MODEL_IDS, CHATGPT_MODEL_IDS, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type CandidateAssessment, type CandidateEvolutionOptions, type CandidateEvolutionResult, type CandidateEvolutionSnapshot, type CandidateEvolutionStats, type CandidateFeedbackEntry, type CandidateIssue, type CandidateProposal, type CandidateRecord, type ChatGptAuthProfile, type ChatGptImageModelId, type ChatGptModelId, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CodexViewImageToolInput, type CreateApplyPatchToolOptions, DEFAULT_FILE_TTL_SECONDS, DEFAULT_SIGNED_URL_TTL_SECONDS, EXPERIMENTAL_CHATGPT_MODEL_PREFIX, type ExperimentalChatGptModelId, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FeedbackScope, type FireworksModelId, GEMINI_IMAGE_MODEL_IDS, GEMINI_MODEL_IDS, GEMINI_TEXT_MODEL_IDS, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiImageModelId, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiTextModelId, type GeminiWriteFileToolInput, type GenerationSubagent, type GenerationSubagentInput, InMemoryAgentFilesystem, type JsonSchema, LLM_IMAGE_MODEL_IDS, LLM_MODEL_IDS, LLM_TEXT_MODEL_IDS, type ListedChatGptModelId, type LlmBaseRequest, type LlmBlockedEvent, type LlmCallCompletedTelemetryEvent, type LlmCallStartedTelemetryEvent, type LlmCallStreamTelemetryEvent, type LlmChatGptGenerateImagesRequest, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFileCreateParams, type LlmFileDeleted, type LlmFileUploadBackend, type LlmFileUploadEvent, type LlmFileUploadMetrics, type LlmFileUploadMode, type LlmFileUploadSource, type LlmFunctionTool, type LlmGeminiGenerateImagesRequest, type LlmGenerateImagesRequest, type LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmMediaResolution, type LlmModelEvent, type LlmModelId, type LlmOpenAiContainer, type LlmOpenAiContainerCreateOptions, type LlmOpenAiContainerFile, type LlmOpenAiContainerFileUpload, type LlmOpenAiContainerNetworkPolicy, type LlmOpenAiGenerateImagesRequest, type LlmOpenAiImageBackground, type LlmOpenAiImageModeration, type LlmOpenAiImageNumImages, type LlmOpenAiImageOutputFormat, type LlmOpenAiImagePartialImageCount, type LlmOpenAiImageQuality, type LlmOpenAiImageResolution, type LlmOpenAiResponseContainerReference, type LlmOpenAiResponseMetadata, type LlmOpenAiShellEnvironment, type LlmOpenAiShellNetworkPolicy, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, type LlmTelemetryOperation, type LlmTextDeltaEvent, type LlmTextModelId, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmThinkingLevel, type LlmToolCallCompletedEvent, type LlmToolCallContext, type LlmToolCallResult, type LlmToolCallStartedEvent, type LlmToolCallStreamEvent, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopSteeringAppendResult, type LlmToolLoopSteeringChannel, type LlmToolLoopSteeringInput, type LlmToolLoopSteeringMessage, type LlmToolLoopStep, type LlmToolLoopStream, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type ModelConcurrencyConfig, type ModelConcurrencyProvider, OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION, OPENAI_GPT_IMAGE_2_BACKGROUNDS, OPENAI_GPT_IMAGE_2_MODERATION_LEVELS, OPENAI_GPT_IMAGE_2_NUM_IMAGES, OPENAI_GPT_IMAGE_2_OUTPUT_FORMATS, OPENAI_GPT_IMAGE_2_PARTIAL_IMAGE_COUNTS, OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS, OPENAI_GPT_IMAGE_2_QUALITY_LEVELS, OPENAI_GPT_IMAGE_2_RESOLUTIONS, OPENAI_GPT_IMAGE_2_SIZE_CONSTRAINTS, OPENAI_IMAGE_MODEL_IDS, OPENAI_MODEL_IDS, type OpenAiGptImage2Background, type OpenAiGptImage2CustomResolution, type OpenAiGptImage2ListedResolution, type OpenAiGptImage2Moderation, type OpenAiGptImage2NumImages, type OpenAiGptImage2OutputFormat, type OpenAiGptImage2PartialImageCount, type OpenAiGptImage2PopularResolution, type OpenAiGptImage2Quality, type OpenAiGptImage2Resolution, type OpenAiGptImage2ResolutionValidationResult, type OpenAiImageModelId, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, type TelemetryConfig, type TelemetryEvent, type TelemetrySelection, type TelemetrySink, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, configureTelemetry, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createOpenAiContainer, createReplaceTool, createRgSearchTool, createToolLoopSteeringChannel, createViewImageTool, createWriteFileTool, customTool, deleteOpenAiContainer, downloadOpenAiContainerFile, downloadOpenAiContainerFileText, emptyFileUploadMetrics, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, files, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isChatGptImageModelId, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, listOpenAiContainerFiles, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveChatGptImageProviderModel, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, uploadOpenAiContainerFile, validateOpenAiGptImage2Resolution };
package/dist/index.d.ts CHANGED
@@ -326,6 +326,17 @@ type LlmTextResult = {
326
326
  readonly usage?: LlmUsageTokens;
327
327
  readonly costUsd: number;
328
328
  readonly grounding?: GroundingMetadata;
329
+ readonly openAi?: LlmOpenAiResponseMetadata;
330
+ };
331
+ type LlmOpenAiResponseContainerReference = {
332
+ readonly containerId: string;
333
+ readonly toolType: "shell" | "code_interpreter";
334
+ readonly itemId?: string;
335
+ readonly callId?: string;
336
+ };
337
+ type LlmOpenAiResponseMetadata = {
338
+ readonly responseId?: string;
339
+ readonly containers: readonly LlmOpenAiResponseContainerReference[];
329
340
  };
330
341
  type LlmTextStream = {
331
342
  readonly events: AsyncIterable<LlmStreamEvent>;
@@ -663,6 +674,59 @@ declare const files: {
663
674
  readonly content: typeof filesContent;
664
675
  };
665
676
 
677
+ type LlmOpenAiContainerNetworkPolicy = {
678
+ readonly type: "disabled";
679
+ } | {
680
+ readonly type: "allowlist";
681
+ readonly allowedDomains: readonly string[];
682
+ readonly domainSecrets?: readonly {
683
+ readonly domain: string;
684
+ readonly name: string;
685
+ readonly value: string;
686
+ }[];
687
+ };
688
+ type LlmOpenAiContainerCreateOptions = {
689
+ readonly name: string;
690
+ readonly fileIds?: readonly string[];
691
+ readonly memoryLimit?: "1g" | "4g" | "16g" | "64g";
692
+ readonly networkPolicy?: LlmOpenAiContainerNetworkPolicy;
693
+ readonly expiresAfterMinutes?: number;
694
+ };
695
+ type LlmOpenAiContainer = {
696
+ readonly id: string;
697
+ readonly name: string;
698
+ readonly status: string;
699
+ readonly createdAt?: number;
700
+ readonly lastActiveAt?: number;
701
+ readonly memoryLimit?: "1g" | "4g" | "16g" | "64g";
702
+ };
703
+ type LlmOpenAiContainerFile = {
704
+ readonly id: string;
705
+ readonly containerId: string;
706
+ readonly path: string;
707
+ readonly bytes?: number | null;
708
+ readonly createdAt?: number;
709
+ readonly source?: string;
710
+ };
711
+ type LlmOpenAiContainerFileUpload = {
712
+ readonly containerId: string;
713
+ readonly filename: string;
714
+ readonly data: ArrayBuffer | ArrayBufferView | Blob | Response | AsyncIterable<ArrayBufferView>;
715
+ readonly mimeType?: string;
716
+ };
717
+ declare function createOpenAiContainer(options: LlmOpenAiContainerCreateOptions): Promise<LlmOpenAiContainer>;
718
+ declare function deleteOpenAiContainer(containerId: string): Promise<void>;
719
+ declare function listOpenAiContainerFiles(containerId: string): Promise<readonly LlmOpenAiContainerFile[]>;
720
+ declare function uploadOpenAiContainerFile(upload: LlmOpenAiContainerFileUpload): Promise<LlmOpenAiContainerFile>;
721
+ declare function downloadOpenAiContainerFile(params: {
722
+ readonly containerId: string;
723
+ readonly fileId: string;
724
+ }): Promise<Uint8Array>;
725
+ declare function downloadOpenAiContainerFileText(params: {
726
+ readonly containerId: string;
727
+ readonly fileId: string;
728
+ }): Promise<string>;
729
+
666
730
  /**
667
731
  * Loads `.env.local` from `process.cwd()` once.
668
732
  *
@@ -1108,4 +1172,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
1108
1172
  declare function isFireworksModelId(value: string): value is FireworksModelId;
1109
1173
  declare function resolveFireworksModelId(model: string): string | undefined;
1110
1174
 
1111
- export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentLogLineSink, type AgentLoggingConfig, type AgentLoggingSelection, type AgentLoopStream, type AgentPathInfo, type AgentPathKind, type AgentRunCompletedTelemetryEvent, type AgentRunStartedTelemetryEvent, type AgentRunStreamTelemetryEvent, type AgentSubagentToolConfig, type AgentSubagentToolPromptPattern, type AgentSubagentToolSelection, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, type AssessmentSubagentInput, CHATGPT_IMAGE_MODEL_IDS, CHATGPT_MODEL_IDS, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type CandidateAssessment, type CandidateEvolutionOptions, type CandidateEvolutionResult, type CandidateEvolutionSnapshot, type CandidateEvolutionStats, type CandidateFeedbackEntry, type CandidateIssue, type CandidateProposal, type CandidateRecord, type ChatGptAuthProfile, type ChatGptImageModelId, type ChatGptModelId, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CodexViewImageToolInput, type CreateApplyPatchToolOptions, DEFAULT_FILE_TTL_SECONDS, DEFAULT_SIGNED_URL_TTL_SECONDS, EXPERIMENTAL_CHATGPT_MODEL_PREFIX, type ExperimentalChatGptModelId, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FeedbackScope, type FireworksModelId, GEMINI_IMAGE_MODEL_IDS, GEMINI_MODEL_IDS, GEMINI_TEXT_MODEL_IDS, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiImageModelId, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiTextModelId, type GeminiWriteFileToolInput, type GenerationSubagent, type GenerationSubagentInput, InMemoryAgentFilesystem, type JsonSchema, LLM_IMAGE_MODEL_IDS, LLM_MODEL_IDS, LLM_TEXT_MODEL_IDS, type ListedChatGptModelId, type LlmBaseRequest, type LlmBlockedEvent, type LlmCallCompletedTelemetryEvent, type LlmCallStartedTelemetryEvent, type LlmCallStreamTelemetryEvent, type LlmChatGptGenerateImagesRequest, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFileCreateParams, type LlmFileDeleted, type LlmFileUploadBackend, type LlmFileUploadEvent, type LlmFileUploadMetrics, type LlmFileUploadMode, type LlmFileUploadSource, type LlmFunctionTool, type LlmGeminiGenerateImagesRequest, type LlmGenerateImagesRequest, type LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmMediaResolution, type LlmModelEvent, type LlmModelId, type LlmOpenAiGenerateImagesRequest, type LlmOpenAiImageBackground, type LlmOpenAiImageModeration, type LlmOpenAiImageNumImages, type LlmOpenAiImageOutputFormat, type LlmOpenAiImagePartialImageCount, type LlmOpenAiImageQuality, type LlmOpenAiImageResolution, type LlmOpenAiShellEnvironment, type LlmOpenAiShellNetworkPolicy, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, type LlmTelemetryOperation, type LlmTextDeltaEvent, type LlmTextModelId, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmThinkingLevel, type LlmToolCallCompletedEvent, type LlmToolCallContext, type LlmToolCallResult, type LlmToolCallStartedEvent, type LlmToolCallStreamEvent, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopSteeringAppendResult, type LlmToolLoopSteeringChannel, type LlmToolLoopSteeringInput, type LlmToolLoopSteeringMessage, type LlmToolLoopStep, type LlmToolLoopStream, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type ModelConcurrencyConfig, type ModelConcurrencyProvider, OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION, OPENAI_GPT_IMAGE_2_BACKGROUNDS, OPENAI_GPT_IMAGE_2_MODERATION_LEVELS, OPENAI_GPT_IMAGE_2_NUM_IMAGES, OPENAI_GPT_IMAGE_2_OUTPUT_FORMATS, OPENAI_GPT_IMAGE_2_PARTIAL_IMAGE_COUNTS, OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS, OPENAI_GPT_IMAGE_2_QUALITY_LEVELS, OPENAI_GPT_IMAGE_2_RESOLUTIONS, OPENAI_GPT_IMAGE_2_SIZE_CONSTRAINTS, OPENAI_IMAGE_MODEL_IDS, OPENAI_MODEL_IDS, type OpenAiGptImage2Background, type OpenAiGptImage2CustomResolution, type OpenAiGptImage2ListedResolution, type OpenAiGptImage2Moderation, type OpenAiGptImage2NumImages, type OpenAiGptImage2OutputFormat, type OpenAiGptImage2PartialImageCount, type OpenAiGptImage2PopularResolution, type OpenAiGptImage2Quality, type OpenAiGptImage2Resolution, type OpenAiGptImage2ResolutionValidationResult, type OpenAiImageModelId, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, type TelemetryConfig, type TelemetryEvent, type TelemetrySelection, type TelemetrySink, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, configureTelemetry, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createReplaceTool, createRgSearchTool, createToolLoopSteeringChannel, createViewImageTool, createWriteFileTool, customTool, emptyFileUploadMetrics, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, files, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isChatGptImageModelId, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveChatGptImageProviderModel, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, validateOpenAiGptImage2Resolution };
1175
+ export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentLogLineSink, type AgentLoggingConfig, type AgentLoggingSelection, type AgentLoopStream, type AgentPathInfo, type AgentPathKind, type AgentRunCompletedTelemetryEvent, type AgentRunStartedTelemetryEvent, type AgentRunStreamTelemetryEvent, type AgentSubagentToolConfig, type AgentSubagentToolPromptPattern, type AgentSubagentToolSelection, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, type AssessmentSubagentInput, CHATGPT_IMAGE_MODEL_IDS, CHATGPT_MODEL_IDS, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type CandidateAssessment, type CandidateEvolutionOptions, type CandidateEvolutionResult, type CandidateEvolutionSnapshot, type CandidateEvolutionStats, type CandidateFeedbackEntry, type CandidateIssue, type CandidateProposal, type CandidateRecord, type ChatGptAuthProfile, type ChatGptImageModelId, type ChatGptModelId, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CodexViewImageToolInput, type CreateApplyPatchToolOptions, DEFAULT_FILE_TTL_SECONDS, DEFAULT_SIGNED_URL_TTL_SECONDS, EXPERIMENTAL_CHATGPT_MODEL_PREFIX, type ExperimentalChatGptModelId, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FeedbackScope, type FireworksModelId, GEMINI_IMAGE_MODEL_IDS, GEMINI_MODEL_IDS, GEMINI_TEXT_MODEL_IDS, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiImageModelId, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiTextModelId, type GeminiWriteFileToolInput, type GenerationSubagent, type GenerationSubagentInput, InMemoryAgentFilesystem, type JsonSchema, LLM_IMAGE_MODEL_IDS, LLM_MODEL_IDS, LLM_TEXT_MODEL_IDS, type ListedChatGptModelId, type LlmBaseRequest, type LlmBlockedEvent, type LlmCallCompletedTelemetryEvent, type LlmCallStartedTelemetryEvent, type LlmCallStreamTelemetryEvent, type LlmChatGptGenerateImagesRequest, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFileCreateParams, type LlmFileDeleted, type LlmFileUploadBackend, type LlmFileUploadEvent, type LlmFileUploadMetrics, type LlmFileUploadMode, type LlmFileUploadSource, type LlmFunctionTool, type LlmGeminiGenerateImagesRequest, type LlmGenerateImagesRequest, type LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmMediaResolution, type LlmModelEvent, type LlmModelId, type LlmOpenAiContainer, type LlmOpenAiContainerCreateOptions, type LlmOpenAiContainerFile, type LlmOpenAiContainerFileUpload, type LlmOpenAiContainerNetworkPolicy, type LlmOpenAiGenerateImagesRequest, type LlmOpenAiImageBackground, type LlmOpenAiImageModeration, type LlmOpenAiImageNumImages, type LlmOpenAiImageOutputFormat, type LlmOpenAiImagePartialImageCount, type LlmOpenAiImageQuality, type LlmOpenAiImageResolution, type LlmOpenAiResponseContainerReference, type LlmOpenAiResponseMetadata, type LlmOpenAiShellEnvironment, type LlmOpenAiShellNetworkPolicy, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, type LlmTelemetryOperation, type LlmTextDeltaEvent, type LlmTextModelId, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmThinkingLevel, type LlmToolCallCompletedEvent, type LlmToolCallContext, type LlmToolCallResult, type LlmToolCallStartedEvent, type LlmToolCallStreamEvent, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopSteeringAppendResult, type LlmToolLoopSteeringChannel, type LlmToolLoopSteeringInput, type LlmToolLoopSteeringMessage, type LlmToolLoopStep, type LlmToolLoopStream, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type ModelConcurrencyConfig, type ModelConcurrencyProvider, OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION, OPENAI_GPT_IMAGE_2_BACKGROUNDS, OPENAI_GPT_IMAGE_2_MODERATION_LEVELS, OPENAI_GPT_IMAGE_2_NUM_IMAGES, OPENAI_GPT_IMAGE_2_OUTPUT_FORMATS, OPENAI_GPT_IMAGE_2_PARTIAL_IMAGE_COUNTS, OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS, OPENAI_GPT_IMAGE_2_QUALITY_LEVELS, OPENAI_GPT_IMAGE_2_RESOLUTIONS, OPENAI_GPT_IMAGE_2_SIZE_CONSTRAINTS, OPENAI_IMAGE_MODEL_IDS, OPENAI_MODEL_IDS, type OpenAiGptImage2Background, type OpenAiGptImage2CustomResolution, type OpenAiGptImage2ListedResolution, type OpenAiGptImage2Moderation, type OpenAiGptImage2NumImages, type OpenAiGptImage2OutputFormat, type OpenAiGptImage2PartialImageCount, type OpenAiGptImage2PopularResolution, type OpenAiGptImage2Quality, type OpenAiGptImage2Resolution, type OpenAiGptImage2ResolutionValidationResult, type OpenAiImageModelId, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, type TelemetryConfig, type TelemetryEvent, type TelemetrySelection, type TelemetrySink, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, configureTelemetry, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createOpenAiContainer, createReplaceTool, createRgSearchTool, createToolLoopSteeringChannel, createViewImageTool, createWriteFileTool, customTool, deleteOpenAiContainer, downloadOpenAiContainerFile, downloadOpenAiContainerFileText, emptyFileUploadMetrics, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, files, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isChatGptImageModelId, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, listOpenAiContainerFiles, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveChatGptImageProviderModel, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, uploadOpenAiContainerFile, validateOpenAiGptImage2Resolution };
package/dist/index.js CHANGED
@@ -555,7 +555,7 @@ function resolveOpenAiImagePriceResolution(imageSize) {
555
555
 
556
556
  // src/openai/chatgpt-codex.ts
557
557
  import os2 from "os";
558
- import { TextDecoder } from "util";
558
+ import { TextDecoder as TextDecoder2 } from "util";
559
559
 
560
560
  // src/utils/runtimeSingleton.ts
561
561
  var runtimeSingletonStoreKey = /* @__PURE__ */ Symbol.for("@ljoukov/llm.runtimeSingletonStore");
@@ -1886,7 +1886,7 @@ function buildUserAgent() {
1886
1886
  }
1887
1887
  async function* parseEventStream(stream) {
1888
1888
  const reader = stream.getReader();
1889
- const decoder = new TextDecoder();
1889
+ const decoder = new TextDecoder2();
1890
1890
  let buffer = "";
1891
1891
  while (true) {
1892
1892
  const { done, value } = await reader.read();
@@ -6331,6 +6331,50 @@ function toOpenAiTools(tools, options) {
6331
6331
  }
6332
6332
  });
6333
6333
  }
6334
+ function extractOpenAiResponseMetadata(response) {
6335
+ if (!response || typeof response !== "object") {
6336
+ return void 0;
6337
+ }
6338
+ const record = response;
6339
+ const responseId = typeof record.id === "string" ? record.id : void 0;
6340
+ const output = Array.isArray(record.output) ? record.output : [];
6341
+ const containers = [];
6342
+ const seen = /* @__PURE__ */ new Set();
6343
+ const addContainer = (container) => {
6344
+ const key = `${container.toolType}:${container.containerId}:${container.itemId ?? ""}:${container.callId ?? ""}`;
6345
+ if (seen.has(key)) {
6346
+ return;
6347
+ }
6348
+ seen.add(key);
6349
+ containers.push(container);
6350
+ };
6351
+ for (const item of output) {
6352
+ if (!item || typeof item !== "object") {
6353
+ continue;
6354
+ }
6355
+ const itemRecord = item;
6356
+ const itemId = typeof itemRecord.id === "string" ? itemRecord.id : void 0;
6357
+ const callId = typeof itemRecord.call_id === "string" ? itemRecord.call_id : void 0;
6358
+ if (itemRecord.type === "shell_call") {
6359
+ const environment = itemRecord.environment && typeof itemRecord.environment === "object" ? itemRecord.environment : void 0;
6360
+ const containerId = environment?.type === "container_reference" && typeof environment.container_id === "string" ? environment.container_id : void 0;
6361
+ if (containerId) {
6362
+ addContainer({ containerId, toolType: "shell", itemId, callId });
6363
+ }
6364
+ continue;
6365
+ }
6366
+ if (itemRecord.type === "code_interpreter_call") {
6367
+ const containerId = typeof itemRecord.container_id === "string" ? itemRecord.container_id : void 0;
6368
+ if (containerId) {
6369
+ addContainer({ containerId, toolType: "code_interpreter", itemId, callId });
6370
+ }
6371
+ }
6372
+ }
6373
+ if (!responseId && containers.length === 0) {
6374
+ return void 0;
6375
+ }
6376
+ return { ...responseId ? { responseId } : {}, containers };
6377
+ }
6334
6378
  function mergeTokenUpdates(current, next) {
6335
6379
  if (!next) {
6336
6380
  return current;
@@ -7942,6 +7986,7 @@ async function runTextCall(params) {
7942
7986
  let modelVersion = request.model;
7943
7987
  let blocked = false;
7944
7988
  let grounding;
7989
+ let openAi;
7945
7990
  const responseParts = [];
7946
7991
  let responseRole;
7947
7992
  let latestUsage;
@@ -8052,6 +8097,7 @@ async function runTextCall(params) {
8052
8097
  }
8053
8098
  }
8054
8099
  const finalResponse = await stream.finalResponse();
8100
+ openAi = extractOpenAiResponseMetadata(finalResponse);
8055
8101
  modelVersion = typeof finalResponse.model === "string" ? finalResponse.model : request.model;
8056
8102
  pushEvent({ type: "model", modelVersion });
8057
8103
  if (finalResponse.error) {
@@ -8295,6 +8341,7 @@ async function runTextCall(params) {
8295
8341
  costUsd,
8296
8342
  usage: latestUsage,
8297
8343
  grounding: grounding ? sanitiseLogValue(grounding) : void 0,
8344
+ openAi: openAi ? sanitiseLogValue(openAi) : void 0,
8298
8345
  responseChars: text.length,
8299
8346
  thoughtChars: thoughts.length,
8300
8347
  responseImages,
@@ -8311,7 +8358,8 @@ async function runTextCall(params) {
8311
8358
  blocked,
8312
8359
  usage: latestUsage,
8313
8360
  costUsd,
8314
- grounding
8361
+ grounding,
8362
+ openAi
8315
8363
  };
8316
8364
  } catch (error) {
8317
8365
  const partialParts = mergeConsecutiveTextParts(responseParts);
@@ -10960,6 +11008,104 @@ function appendMarkdownSourcesSection(value, sources) {
10960
11008
  ${lines}`;
10961
11009
  }
10962
11010
 
11011
+ // src/openai/containers.ts
11012
+ import { toFile as toFile2 } from "openai";
11013
+ function toOpenAiContainerNetworkPolicy(policy) {
11014
+ if (!policy) {
11015
+ return void 0;
11016
+ }
11017
+ if (policy.type === "disabled") {
11018
+ return { type: "disabled" };
11019
+ }
11020
+ return {
11021
+ type: "allowlist",
11022
+ allowed_domains: Array.from(policy.allowedDomains),
11023
+ ...policy.domainSecrets ? {
11024
+ domain_secrets: policy.domainSecrets.map((secret) => ({
11025
+ domain: secret.domain,
11026
+ name: secret.name,
11027
+ value: secret.value
11028
+ }))
11029
+ } : {}
11030
+ };
11031
+ }
11032
+ function toContainer(container) {
11033
+ return {
11034
+ id: String(container.id),
11035
+ name: typeof container.name === "string" ? container.name : "",
11036
+ status: typeof container.status === "string" ? container.status : "",
11037
+ ...typeof container.created_at === "number" ? { createdAt: container.created_at } : {},
11038
+ ...typeof container.last_active_at === "number" ? { lastActiveAt: container.last_active_at } : {},
11039
+ ...typeof container.memory_limit === "string" ? { memoryLimit: container.memory_limit } : {}
11040
+ };
11041
+ }
11042
+ function toContainerFile(file) {
11043
+ return {
11044
+ id: String(file.id),
11045
+ containerId: typeof file.container_id === "string" ? file.container_id : "",
11046
+ path: typeof file.path === "string" ? file.path : "",
11047
+ ...typeof file.bytes === "number" || file.bytes === null ? { bytes: file.bytes } : {},
11048
+ ...typeof file.created_at === "number" ? { createdAt: file.created_at } : {},
11049
+ ...typeof file.source === "string" ? { source: file.source } : {}
11050
+ };
11051
+ }
11052
+ async function createOpenAiContainer(options) {
11053
+ const container = await runOpenAiCall(
11054
+ async (client) => await client.containers.create({
11055
+ name: options.name,
11056
+ ...options.fileIds ? { file_ids: Array.from(options.fileIds) } : {},
11057
+ ...options.memoryLimit ? { memory_limit: options.memoryLimit } : {},
11058
+ ...options.networkPolicy ? { network_policy: toOpenAiContainerNetworkPolicy(options.networkPolicy) } : {},
11059
+ ...options.expiresAfterMinutes ? {
11060
+ expires_after: {
11061
+ anchor: "last_active_at",
11062
+ minutes: options.expiresAfterMinutes
11063
+ }
11064
+ } : {}
11065
+ }),
11066
+ "openai-containers"
11067
+ );
11068
+ return toContainer(container);
11069
+ }
11070
+ async function deleteOpenAiContainer(containerId) {
11071
+ await runOpenAiCall(
11072
+ async (client) => await client.containers.delete(containerId),
11073
+ "openai-containers"
11074
+ );
11075
+ }
11076
+ async function listOpenAiContainerFiles(containerId) {
11077
+ const files2 = [];
11078
+ await runOpenAiCall(async (client) => {
11079
+ for await (const file of client.containers.files.list(containerId)) {
11080
+ files2.push(toContainerFile(file));
11081
+ }
11082
+ }, "openai-containers");
11083
+ return files2;
11084
+ }
11085
+ async function uploadOpenAiContainerFile(upload) {
11086
+ const file = await toFile2(upload.data, upload.filename, {
11087
+ ...upload.mimeType ? { type: upload.mimeType } : {}
11088
+ });
11089
+ const created = await runOpenAiCall(
11090
+ async (client) => await client.containers.files.create(upload.containerId, { file }),
11091
+ "openai-containers"
11092
+ );
11093
+ return toContainerFile(created);
11094
+ }
11095
+ async function downloadOpenAiContainerFile(params) {
11096
+ const response = await runOpenAiCall(
11097
+ async (client) => await client.containers.files.content.retrieve(params.fileId, {
11098
+ container_id: params.containerId
11099
+ }),
11100
+ "openai-containers"
11101
+ );
11102
+ return new Uint8Array(await response.arrayBuffer());
11103
+ }
11104
+ async function downloadOpenAiContainerFileText(params) {
11105
+ const bytes = await downloadOpenAiContainerFile(params);
11106
+ return new TextDecoder().decode(bytes);
11107
+ }
11108
+
10963
11109
  // src/agent.ts
10964
11110
  import { randomBytes as randomBytes3 } from "crypto";
10965
11111
  import path9 from "path";
@@ -14759,12 +14905,16 @@ export {
14759
14905
  createListDirectoryTool,
14760
14906
  createModelAgnosticFilesystemToolSet,
14761
14907
  createNodeAgentFilesystem,
14908
+ createOpenAiContainer,
14762
14909
  createReplaceTool,
14763
14910
  createRgSearchTool,
14764
14911
  createToolLoopSteeringChannel,
14765
14912
  createViewImageTool,
14766
14913
  createWriteFileTool,
14767
14914
  customTool,
14915
+ deleteOpenAiContainer,
14916
+ downloadOpenAiContainerFile,
14917
+ downloadOpenAiContainerFileText,
14768
14918
  emptyFileUploadMetrics,
14769
14919
  encodeChatGptAuthJson,
14770
14920
  encodeChatGptAuthJsonB64,
@@ -14789,6 +14939,7 @@ export {
14789
14939
  isLlmTextModelId,
14790
14940
  isOpenAiImageModelId,
14791
14941
  isOpenAiModelId,
14942
+ listOpenAiContainerFiles,
14792
14943
  loadEnvFromFile,
14793
14944
  loadLocalEnv,
14794
14945
  parseJsonFromLlmText,
@@ -14809,6 +14960,7 @@ export {
14809
14960
  stripCodexCitationMarkers,
14810
14961
  toGeminiJsonSchema,
14811
14962
  tool,
14963
+ uploadOpenAiContainerFile,
14812
14964
  validateOpenAiGptImage2Resolution
14813
14965
  };
14814
14966
  //# sourceMappingURL=index.js.map