@ljoukov/llm 7.0.13 → 7.0.14
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/README.md +22 -3
- package/dist/index.cjs +187 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +184 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -44,6 +44,9 @@ declare function isOpenAiModelId(value: string): value is OpenAiModelId;
|
|
|
44
44
|
declare const OPENAI_IMAGE_MODEL_IDS: readonly ["gpt-image-2"];
|
|
45
45
|
type OpenAiImageModelId = (typeof OPENAI_IMAGE_MODEL_IDS)[number];
|
|
46
46
|
declare function isOpenAiImageModelId(value: string): value is OpenAiImageModelId;
|
|
47
|
+
declare const CHATGPT_IMAGE_MODEL_IDS: readonly ["chatgpt-gpt-image-2"];
|
|
48
|
+
type ChatGptImageModelId = (typeof CHATGPT_IMAGE_MODEL_IDS)[number];
|
|
49
|
+
declare function isChatGptImageModelId(value: string): value is ChatGptImageModelId;
|
|
47
50
|
declare const OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS: readonly ["1024x1024", "1536x1024", "1024x1536", "2048x2048", "2048x1152", "3840x2160", "2160x3840"];
|
|
48
51
|
type OpenAiGptImage2PopularResolution = (typeof OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS)[number];
|
|
49
52
|
declare const OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION: "auto";
|
|
@@ -85,6 +88,7 @@ type ExperimentalChatGptModelId = `${typeof EXPERIMENTAL_CHATGPT_MODEL_PREFIX}${
|
|
|
85
88
|
type ChatGptModelId = ListedChatGptModelId | ExperimentalChatGptModelId;
|
|
86
89
|
declare function isExperimentalChatGptModelId(value: string): value is ExperimentalChatGptModelId;
|
|
87
90
|
declare function isChatGptModelId(value: string): value is ChatGptModelId;
|
|
91
|
+
declare function resolveChatGptImageProviderModel(_model: ChatGptImageModelId): string;
|
|
88
92
|
|
|
89
93
|
type LlmTelemetryOperation = "generateText" | "streamText" | "generateJson" | "streamJson" | "generateImages";
|
|
90
94
|
type LlmTelemetryBaseEvent = {
|
|
@@ -304,9 +308,9 @@ type LlmStreamEvent = LlmTextDeltaEvent | LlmUsageEvent | LlmModelEvent | LlmBlo
|
|
|
304
308
|
type LlmProvider = "openai" | "chatgpt" | "gemini" | "fireworks";
|
|
305
309
|
declare const LLM_TEXT_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
306
310
|
type LlmTextModelId = (typeof LLM_TEXT_MODEL_IDS)[number] | ExperimentalChatGptModelId;
|
|
307
|
-
declare const LLM_IMAGE_MODEL_IDS: readonly ["gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
311
|
+
declare const LLM_IMAGE_MODEL_IDS: readonly ["gpt-image-2", "chatgpt-gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
308
312
|
type LlmImageModelId = (typeof LLM_IMAGE_MODEL_IDS)[number];
|
|
309
|
-
declare const LLM_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest", "gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
313
|
+
declare const LLM_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest", "gpt-image-2", "chatgpt-gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
310
314
|
type LlmModelId = LlmTextModelId | LlmImageModelId;
|
|
311
315
|
declare function isLlmTextModelId(value: string): value is LlmTextModelId;
|
|
312
316
|
declare function isLlmImageModelId(value: string): value is LlmImageModelId;
|
|
@@ -445,6 +449,10 @@ type LlmOpenAiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
|
445
449
|
readonly partialImages?: LlmOpenAiImagePartialImageCount;
|
|
446
450
|
readonly numImages?: LlmOpenAiImageNumImages;
|
|
447
451
|
};
|
|
452
|
+
type LlmChatGptGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
453
|
+
readonly model: ChatGptImageModelId;
|
|
454
|
+
readonly numImages?: LlmOpenAiImageNumImages;
|
|
455
|
+
};
|
|
448
456
|
type LlmGeminiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
449
457
|
readonly model: GeminiImageModelId;
|
|
450
458
|
readonly imageGradingPrompt: string;
|
|
@@ -452,7 +460,7 @@ type LlmGeminiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
|
452
460
|
readonly imageAspectRatio?: string;
|
|
453
461
|
readonly imageSize?: LlmImageSize;
|
|
454
462
|
};
|
|
455
|
-
type LlmGenerateImagesRequest = LlmOpenAiGenerateImagesRequest | LlmGeminiGenerateImagesRequest;
|
|
463
|
+
type LlmGenerateImagesRequest = LlmOpenAiGenerateImagesRequest | LlmChatGptGenerateImagesRequest | LlmGeminiGenerateImagesRequest;
|
|
456
464
|
type LlmFunctionTool<Schema extends z.ZodType, Output> = {
|
|
457
465
|
readonly type?: "function";
|
|
458
466
|
readonly description?: string;
|
|
@@ -1100,4 +1108,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
|
|
|
1100
1108
|
declare function isFireworksModelId(value: string): value is FireworksModelId;
|
|
1101
1109
|
declare function resolveFireworksModelId(model: string): string | undefined;
|
|
1102
1110
|
|
|
1103
|
-
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_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 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 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, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, validateOpenAiGptImage2Resolution };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,9 @@ declare function isOpenAiModelId(value: string): value is OpenAiModelId;
|
|
|
44
44
|
declare const OPENAI_IMAGE_MODEL_IDS: readonly ["gpt-image-2"];
|
|
45
45
|
type OpenAiImageModelId = (typeof OPENAI_IMAGE_MODEL_IDS)[number];
|
|
46
46
|
declare function isOpenAiImageModelId(value: string): value is OpenAiImageModelId;
|
|
47
|
+
declare const CHATGPT_IMAGE_MODEL_IDS: readonly ["chatgpt-gpt-image-2"];
|
|
48
|
+
type ChatGptImageModelId = (typeof CHATGPT_IMAGE_MODEL_IDS)[number];
|
|
49
|
+
declare function isChatGptImageModelId(value: string): value is ChatGptImageModelId;
|
|
47
50
|
declare const OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS: readonly ["1024x1024", "1536x1024", "1024x1536", "2048x2048", "2048x1152", "3840x2160", "2160x3840"];
|
|
48
51
|
type OpenAiGptImage2PopularResolution = (typeof OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS)[number];
|
|
49
52
|
declare const OPENAI_GPT_IMAGE_2_AUTO_RESOLUTION: "auto";
|
|
@@ -85,6 +88,7 @@ type ExperimentalChatGptModelId = `${typeof EXPERIMENTAL_CHATGPT_MODEL_PREFIX}${
|
|
|
85
88
|
type ChatGptModelId = ListedChatGptModelId | ExperimentalChatGptModelId;
|
|
86
89
|
declare function isExperimentalChatGptModelId(value: string): value is ExperimentalChatGptModelId;
|
|
87
90
|
declare function isChatGptModelId(value: string): value is ChatGptModelId;
|
|
91
|
+
declare function resolveChatGptImageProviderModel(_model: ChatGptImageModelId): string;
|
|
88
92
|
|
|
89
93
|
type LlmTelemetryOperation = "generateText" | "streamText" | "generateJson" | "streamJson" | "generateImages";
|
|
90
94
|
type LlmTelemetryBaseEvent = {
|
|
@@ -304,9 +308,9 @@ type LlmStreamEvent = LlmTextDeltaEvent | LlmUsageEvent | LlmModelEvent | LlmBlo
|
|
|
304
308
|
type LlmProvider = "openai" | "chatgpt" | "gemini" | "fireworks";
|
|
305
309
|
declare const LLM_TEXT_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
306
310
|
type LlmTextModelId = (typeof LLM_TEXT_MODEL_IDS)[number] | ExperimentalChatGptModelId;
|
|
307
|
-
declare const LLM_IMAGE_MODEL_IDS: readonly ["gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
311
|
+
declare const LLM_IMAGE_MODEL_IDS: readonly ["gpt-image-2", "chatgpt-gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
308
312
|
type LlmImageModelId = (typeof LLM_IMAGE_MODEL_IDS)[number];
|
|
309
|
-
declare const LLM_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest", "gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
313
|
+
declare const LLM_MODEL_IDS: readonly ["gpt-5.5", "gpt-5.5-fast", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "chatgpt-gpt-5.5", "chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4", "chatgpt-gpt-5.4-fast", "chatgpt-gpt-5.4-mini", "chatgpt-gpt-5.3-codex-spark", "kimi-k2.5", "glm-5", "minimax-m2.1", "gpt-oss-120b", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest", "gpt-image-2", "chatgpt-gpt-image-2", "gemini-3-pro-image-preview", "gemini-3.1-flash-image-preview"];
|
|
310
314
|
type LlmModelId = LlmTextModelId | LlmImageModelId;
|
|
311
315
|
declare function isLlmTextModelId(value: string): value is LlmTextModelId;
|
|
312
316
|
declare function isLlmImageModelId(value: string): value is LlmImageModelId;
|
|
@@ -445,6 +449,10 @@ type LlmOpenAiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
|
445
449
|
readonly partialImages?: LlmOpenAiImagePartialImageCount;
|
|
446
450
|
readonly numImages?: LlmOpenAiImageNumImages;
|
|
447
451
|
};
|
|
452
|
+
type LlmChatGptGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
453
|
+
readonly model: ChatGptImageModelId;
|
|
454
|
+
readonly numImages?: LlmOpenAiImageNumImages;
|
|
455
|
+
};
|
|
448
456
|
type LlmGeminiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
449
457
|
readonly model: GeminiImageModelId;
|
|
450
458
|
readonly imageGradingPrompt: string;
|
|
@@ -452,7 +460,7 @@ type LlmGeminiGenerateImagesRequest = LlmGenerateImagesRequestBase & {
|
|
|
452
460
|
readonly imageAspectRatio?: string;
|
|
453
461
|
readonly imageSize?: LlmImageSize;
|
|
454
462
|
};
|
|
455
|
-
type LlmGenerateImagesRequest = LlmOpenAiGenerateImagesRequest | LlmGeminiGenerateImagesRequest;
|
|
463
|
+
type LlmGenerateImagesRequest = LlmOpenAiGenerateImagesRequest | LlmChatGptGenerateImagesRequest | LlmGeminiGenerateImagesRequest;
|
|
456
464
|
type LlmFunctionTool<Schema extends z.ZodType, Output> = {
|
|
457
465
|
readonly type?: "function";
|
|
458
466
|
readonly description?: string;
|
|
@@ -1100,4 +1108,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
|
|
|
1100
1108
|
declare function isFireworksModelId(value: string): value is FireworksModelId;
|
|
1101
1109
|
declare function resolveFireworksModelId(model: string): string | undefined;
|
|
1102
1110
|
|
|
1103
|
-
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_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 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 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, isChatGptModelId, isExperimentalChatGptModelId, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiImageModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool, validateOpenAiGptImage2Resolution };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -221,6 +221,10 @@ var OPENAI_IMAGE_MODEL_IDS = ["gpt-image-2"];
|
|
|
221
221
|
function isOpenAiImageModelId(value) {
|
|
222
222
|
return OPENAI_IMAGE_MODEL_IDS.includes(value);
|
|
223
223
|
}
|
|
224
|
+
var CHATGPT_IMAGE_MODEL_IDS = ["chatgpt-gpt-image-2"];
|
|
225
|
+
function isChatGptImageModelId(value) {
|
|
226
|
+
return CHATGPT_IMAGE_MODEL_IDS.includes(value);
|
|
227
|
+
}
|
|
224
228
|
var OPENAI_GPT_IMAGE_2_POPULAR_RESOLUTIONS = [
|
|
225
229
|
"1024x1024",
|
|
226
230
|
"1536x1024",
|
|
@@ -303,6 +307,7 @@ var CHATGPT_MODEL_IDS = [
|
|
|
303
307
|
var FAST_MODEL_SUFFIX = "-fast";
|
|
304
308
|
var OPENAI_PRIORITY_MODEL_IDS = ["gpt-5.5-fast"];
|
|
305
309
|
var CHATGPT_PRIORITY_MODEL_IDS = ["chatgpt-gpt-5.5-fast", "chatgpt-gpt-5.4-fast"];
|
|
310
|
+
var CHATGPT_IMAGE_GENERATION_PROVIDER_MODEL = "gpt-5.4";
|
|
306
311
|
var EXPERIMENTAL_CHATGPT_MODEL_PREFIX = "experimental-chatgpt-";
|
|
307
312
|
function isExperimentalChatGptModelId(value) {
|
|
308
313
|
return value.startsWith(EXPERIMENTAL_CHATGPT_MODEL_PREFIX) && value.length > EXPERIMENTAL_CHATGPT_MODEL_PREFIX.length;
|
|
@@ -329,6 +334,9 @@ function resolveChatGptProviderModel(model) {
|
|
|
329
334
|
const providerModel = stripChatGptPrefix(model);
|
|
330
335
|
return CHATGPT_PRIORITY_MODEL_IDS.includes(model) ? stripFastSuffix(providerModel) : providerModel;
|
|
331
336
|
}
|
|
337
|
+
function resolveChatGptImageProviderModel(_model) {
|
|
338
|
+
return CHATGPT_IMAGE_GENERATION_PROVIDER_MODEL;
|
|
339
|
+
}
|
|
332
340
|
function resolveChatGptServiceTier(model) {
|
|
333
341
|
return CHATGPT_PRIORITY_MODEL_IDS.includes(model) ? "priority" : void 0;
|
|
334
342
|
}
|
|
@@ -423,7 +431,7 @@ function getOpenAiPricing(modelId) {
|
|
|
423
431
|
return void 0;
|
|
424
432
|
}
|
|
425
433
|
function getOpenAiImagePricing(modelId) {
|
|
426
|
-
return isOpenAiImageModelId(modelId) ? OPENAI_GPT_IMAGE_2_PRICING : void 0;
|
|
434
|
+
return isOpenAiImageModelId(modelId) || isChatGptImageModelId(modelId) ? OPENAI_GPT_IMAGE_2_PRICING : void 0;
|
|
427
435
|
}
|
|
428
436
|
|
|
429
437
|
// src/utils/cost.ts
|
|
@@ -1698,6 +1706,8 @@ async function collectChatGptCodexStream(options) {
|
|
|
1698
1706
|
const toolCallOrder = [];
|
|
1699
1707
|
const webSearchCalls = /* @__PURE__ */ new Map();
|
|
1700
1708
|
const webSearchCallOrder = [];
|
|
1709
|
+
const imageGenerationCalls = /* @__PURE__ */ new Map();
|
|
1710
|
+
const imageGenerationCallOrder = [];
|
|
1701
1711
|
let text = "";
|
|
1702
1712
|
const reasoningText = "";
|
|
1703
1713
|
let reasoningSummaryText = "";
|
|
@@ -1768,6 +1778,20 @@ async function collectChatGptCodexStream(options) {
|
|
|
1768
1778
|
action: item.action && typeof item.action === "object" ? item.action : void 0
|
|
1769
1779
|
});
|
|
1770
1780
|
}
|
|
1781
|
+
} else if (item.type === "image_generation_call") {
|
|
1782
|
+
const id = typeof item.id === "string" ? item.id : "";
|
|
1783
|
+
const result = typeof item.result === "string" ? item.result : "";
|
|
1784
|
+
if (id && result) {
|
|
1785
|
+
if (!imageGenerationCalls.has(id)) {
|
|
1786
|
+
imageGenerationCallOrder.push(id);
|
|
1787
|
+
}
|
|
1788
|
+
imageGenerationCalls.set(id, {
|
|
1789
|
+
id,
|
|
1790
|
+
status: typeof item.status === "string" ? item.status : void 0,
|
|
1791
|
+
revisedPrompt: typeof item.revised_prompt === "string" ? item.revised_prompt : void 0,
|
|
1792
|
+
result
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1771
1795
|
}
|
|
1772
1796
|
}
|
|
1773
1797
|
continue;
|
|
@@ -1807,12 +1831,14 @@ async function collectChatGptCodexStream(options) {
|
|
|
1807
1831
|
}
|
|
1808
1832
|
const orderedToolCalls = toolCallOrder.map((id) => toolCalls.get(id)).filter((call) => call !== void 0);
|
|
1809
1833
|
const orderedWebSearchCalls = webSearchCallOrder.map((id) => webSearchCalls.get(id)).filter((call) => call !== void 0);
|
|
1834
|
+
const orderedImageGenerationCalls = imageGenerationCallOrder.map((id) => imageGenerationCalls.get(id)).filter((call) => call !== void 0);
|
|
1810
1835
|
return {
|
|
1811
1836
|
text,
|
|
1812
1837
|
reasoningText,
|
|
1813
1838
|
reasoningSummaryText,
|
|
1814
1839
|
toolCalls: orderedToolCalls,
|
|
1815
1840
|
webSearchCalls: orderedWebSearchCalls,
|
|
1841
|
+
imageGenerationCalls: orderedImageGenerationCalls,
|
|
1816
1842
|
usage,
|
|
1817
1843
|
id: responseId,
|
|
1818
1844
|
model,
|
|
@@ -4524,13 +4550,17 @@ var LLM_TEXT_MODEL_IDS = [
|
|
|
4524
4550
|
...FIREWORKS_MODEL_IDS,
|
|
4525
4551
|
...GEMINI_TEXT_MODEL_IDS
|
|
4526
4552
|
];
|
|
4527
|
-
var LLM_IMAGE_MODEL_IDS = [
|
|
4553
|
+
var LLM_IMAGE_MODEL_IDS = [
|
|
4554
|
+
...OPENAI_IMAGE_MODEL_IDS,
|
|
4555
|
+
...CHATGPT_IMAGE_MODEL_IDS,
|
|
4556
|
+
...GEMINI_IMAGE_MODEL_IDS
|
|
4557
|
+
];
|
|
4528
4558
|
var LLM_MODEL_IDS = [...LLM_TEXT_MODEL_IDS, ...LLM_IMAGE_MODEL_IDS];
|
|
4529
4559
|
function isLlmTextModelId(value) {
|
|
4530
4560
|
return isOpenAiModelId(value) || isChatGptModelId(value) || isFireworksModelId(value) || isGeminiTextModelId(value);
|
|
4531
4561
|
}
|
|
4532
4562
|
function isLlmImageModelId(value) {
|
|
4533
|
-
return isOpenAiImageModelId(value) || isGeminiImageModelId(value);
|
|
4563
|
+
return isOpenAiImageModelId(value) || isChatGptImageModelId(value) || isGeminiImageModelId(value);
|
|
4534
4564
|
}
|
|
4535
4565
|
function isLlmModelId(value) {
|
|
4536
4566
|
return isLlmTextModelId(value) || isLlmImageModelId(value);
|
|
@@ -4545,6 +4575,9 @@ var LlmJsonCallError = class extends Error {
|
|
|
4545
4575
|
function isOpenAiGenerateImagesRequest(request) {
|
|
4546
4576
|
return isOpenAiImageModelId(request.model);
|
|
4547
4577
|
}
|
|
4578
|
+
function isChatGptGenerateImagesRequest(request) {
|
|
4579
|
+
return isChatGptImageModelId(request.model);
|
|
4580
|
+
}
|
|
4548
4581
|
function tool(options) {
|
|
4549
4582
|
return {
|
|
4550
4583
|
type: "function",
|
|
@@ -5138,6 +5171,12 @@ function resolveProvider(model) {
|
|
|
5138
5171
|
if (isOpenAiImageModelId(model)) {
|
|
5139
5172
|
return { provider: "openai", model };
|
|
5140
5173
|
}
|
|
5174
|
+
if (isChatGptImageModelId(model)) {
|
|
5175
|
+
return {
|
|
5176
|
+
provider: "chatgpt",
|
|
5177
|
+
model: resolveChatGptImageProviderModel(model)
|
|
5178
|
+
};
|
|
5179
|
+
}
|
|
5141
5180
|
if (isOpenAiModelId(model)) {
|
|
5142
5181
|
return {
|
|
5143
5182
|
provider: "openai",
|
|
@@ -8044,6 +8083,11 @@ async function runTextCall(params) {
|
|
|
8044
8083
|
}
|
|
8045
8084
|
}, modelForProvider);
|
|
8046
8085
|
} else if (provider === "chatgpt") {
|
|
8086
|
+
if (isChatGptImageModelId(request.model)) {
|
|
8087
|
+
throw new Error(
|
|
8088
|
+
"chatgpt-gpt-image-2 is an image generation model; use generateImages()."
|
|
8089
|
+
);
|
|
8090
|
+
}
|
|
8047
8091
|
const chatGptInput = toChatGptInput(contents, {
|
|
8048
8092
|
defaultMediaResolution: request.mediaResolution,
|
|
8049
8093
|
model: request.model
|
|
@@ -10497,10 +10541,144 @@ async function generateImagesWithOpenAiImageApi(request) {
|
|
|
10497
10541
|
await telemetry.flush();
|
|
10498
10542
|
}
|
|
10499
10543
|
}
|
|
10544
|
+
function buildChatGptImageInputContent(params) {
|
|
10545
|
+
const parts = [
|
|
10546
|
+
{
|
|
10547
|
+
type: "text",
|
|
10548
|
+
text: params.prompt
|
|
10549
|
+
}
|
|
10550
|
+
];
|
|
10551
|
+
for (const [index, image] of (params.styleImages ?? []).entries()) {
|
|
10552
|
+
const mimeType = image.mimeType ?? "image/png";
|
|
10553
|
+
parts.push({
|
|
10554
|
+
type: "inlineData",
|
|
10555
|
+
data: image.data.toString("base64"),
|
|
10556
|
+
mimeType,
|
|
10557
|
+
filename: `style-${index + 1}.${resolveAttachmentExtension(mimeType)}`
|
|
10558
|
+
});
|
|
10559
|
+
}
|
|
10560
|
+
return [{ role: "user", parts }];
|
|
10561
|
+
}
|
|
10562
|
+
async function generateImagesWithChatGptImageTool(request) {
|
|
10563
|
+
const promptEntries = Array.from(request.imagePrompts, (rawPrompt, index) => {
|
|
10564
|
+
const prompt = rawPrompt.trim();
|
|
10565
|
+
if (!prompt) {
|
|
10566
|
+
throw new Error(`imagePrompts[${index}] must be a non-empty string`);
|
|
10567
|
+
}
|
|
10568
|
+
return prompt;
|
|
10569
|
+
});
|
|
10570
|
+
if (promptEntries.length === 0) {
|
|
10571
|
+
return [];
|
|
10572
|
+
}
|
|
10573
|
+
const providerInfo = resolveProvider(request.model);
|
|
10574
|
+
const telemetry = createLlmTelemetryEmitter({
|
|
10575
|
+
telemetry: request.telemetry,
|
|
10576
|
+
operation: "generateImages",
|
|
10577
|
+
provider: providerInfo.provider,
|
|
10578
|
+
model: request.model
|
|
10579
|
+
});
|
|
10580
|
+
const startedAtMs = Date.now();
|
|
10581
|
+
const numImagesPerPrompt = request.numImages ?? 1;
|
|
10582
|
+
let totalUsage;
|
|
10583
|
+
let costUsd = 0;
|
|
10584
|
+
let outputImages = 0;
|
|
10585
|
+
telemetry.emit({
|
|
10586
|
+
type: "llm.call.started",
|
|
10587
|
+
imagePromptCount: promptEntries.length,
|
|
10588
|
+
styleImageCount: request.styleImages?.length ?? 0,
|
|
10589
|
+
numImagesPerPrompt
|
|
10590
|
+
});
|
|
10591
|
+
try {
|
|
10592
|
+
const images = [];
|
|
10593
|
+
for (const imagePrompt of promptEntries) {
|
|
10594
|
+
const prompt = buildOpenAiImagePrompt({
|
|
10595
|
+
stylePrompt: request.stylePrompt,
|
|
10596
|
+
imagePrompt,
|
|
10597
|
+
hasStyleImages: Boolean(request.styleImages && request.styleImages.length > 0)
|
|
10598
|
+
});
|
|
10599
|
+
for (let imageIndex = 0; imageIndex < numImagesPerPrompt; imageIndex += 1) {
|
|
10600
|
+
const chatGptInput = toChatGptInput(
|
|
10601
|
+
buildChatGptImageInputContent({
|
|
10602
|
+
prompt,
|
|
10603
|
+
styleImages: request.styleImages
|
|
10604
|
+
}),
|
|
10605
|
+
{ model: request.model }
|
|
10606
|
+
);
|
|
10607
|
+
const preparedInput = await maybePrepareOpenAiPromptInput(chatGptInput.input, {
|
|
10608
|
+
model: request.model,
|
|
10609
|
+
provider: "chatgpt"
|
|
10610
|
+
});
|
|
10611
|
+
const result = await collectChatGptCodexResponseWithRetry({
|
|
10612
|
+
request: {
|
|
10613
|
+
model: providerInfo.model,
|
|
10614
|
+
store: false,
|
|
10615
|
+
stream: true,
|
|
10616
|
+
instructions: chatGptInput.instructions ?? "Use the image_generation tool to generate exactly one PNG image. Do not return prose instead of the image.",
|
|
10617
|
+
input: preparedInput,
|
|
10618
|
+
tool_choice: "required",
|
|
10619
|
+
parallel_tool_calls: false,
|
|
10620
|
+
tools: [{ type: "image_generation", output_format: "png" }]
|
|
10621
|
+
},
|
|
10622
|
+
signal: request.signal
|
|
10623
|
+
});
|
|
10624
|
+
if (result.status && result.status !== "completed") {
|
|
10625
|
+
throw new Error(`ChatGPT image generation response status ${result.status}`);
|
|
10626
|
+
}
|
|
10627
|
+
if (result.imageGenerationCalls.length === 0) {
|
|
10628
|
+
throw new Error("ChatGPT image generation returned no image_generation_call result.");
|
|
10629
|
+
}
|
|
10630
|
+
for (const call of result.imageGenerationCalls) {
|
|
10631
|
+
images.push({
|
|
10632
|
+
mimeType: "image/png",
|
|
10633
|
+
data: Buffer5.from(call.result, "base64")
|
|
10634
|
+
});
|
|
10635
|
+
}
|
|
10636
|
+
outputImages = images.length;
|
|
10637
|
+
const usage = extractChatGptUsageTokens(result.usage);
|
|
10638
|
+
totalUsage = sumUsageTokens(totalUsage, usage);
|
|
10639
|
+
costUsd += estimateCallCostUsd({
|
|
10640
|
+
modelId: request.model,
|
|
10641
|
+
tokens: usage,
|
|
10642
|
+
responseImages: result.imageGenerationCalls.length,
|
|
10643
|
+
imageSize: "1024x1024",
|
|
10644
|
+
imageQuality: "medium"
|
|
10645
|
+
});
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10648
|
+
telemetry.emit({
|
|
10649
|
+
type: "llm.call.completed",
|
|
10650
|
+
success: true,
|
|
10651
|
+
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
10652
|
+
modelVersion: request.model,
|
|
10653
|
+
usage: totalUsage,
|
|
10654
|
+
costUsd,
|
|
10655
|
+
imageCount: images.length,
|
|
10656
|
+
attempts: promptEntries.length * numImagesPerPrompt
|
|
10657
|
+
});
|
|
10658
|
+
return images;
|
|
10659
|
+
} catch (error) {
|
|
10660
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
10661
|
+
telemetry.emit({
|
|
10662
|
+
type: "llm.call.completed",
|
|
10663
|
+
success: false,
|
|
10664
|
+
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
10665
|
+
usage: totalUsage,
|
|
10666
|
+
costUsd,
|
|
10667
|
+
imageCount: outputImages,
|
|
10668
|
+
error: err.message
|
|
10669
|
+
});
|
|
10670
|
+
throw err;
|
|
10671
|
+
} finally {
|
|
10672
|
+
await telemetry.flush();
|
|
10673
|
+
}
|
|
10674
|
+
}
|
|
10500
10675
|
async function generateImages(request) {
|
|
10501
10676
|
if (isOpenAiGenerateImagesRequest(request)) {
|
|
10502
10677
|
return await generateImagesWithOpenAiImageApi(request);
|
|
10503
10678
|
}
|
|
10679
|
+
if (isChatGptGenerateImagesRequest(request)) {
|
|
10680
|
+
return await generateImagesWithChatGptImageTool(request);
|
|
10681
|
+
}
|
|
10504
10682
|
const maxAttempts = Math.max(1, Math.floor(request.maxAttempts ?? 4));
|
|
10505
10683
|
const promptList = Array.from(request.imagePrompts);
|
|
10506
10684
|
if (promptList.length === 0) {
|
|
@@ -14527,6 +14705,7 @@ async function runCandidateEvolution(options) {
|
|
|
14527
14705
|
};
|
|
14528
14706
|
}
|
|
14529
14707
|
export {
|
|
14708
|
+
CHATGPT_IMAGE_MODEL_IDS,
|
|
14530
14709
|
CHATGPT_MODEL_IDS,
|
|
14531
14710
|
CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION,
|
|
14532
14711
|
CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION,
|
|
@@ -14598,6 +14777,7 @@ export {
|
|
|
14598
14777
|
generateText,
|
|
14599
14778
|
getChatGptAuthProfile,
|
|
14600
14779
|
getCurrentToolCallContext,
|
|
14780
|
+
isChatGptImageModelId,
|
|
14601
14781
|
isChatGptModelId,
|
|
14602
14782
|
isExperimentalChatGptModelId,
|
|
14603
14783
|
isFireworksModelId,
|
|
@@ -14615,6 +14795,7 @@ export {
|
|
|
14615
14795
|
refreshChatGptOauthToken,
|
|
14616
14796
|
resetModelConcurrencyConfig,
|
|
14617
14797
|
resetTelemetry,
|
|
14798
|
+
resolveChatGptImageProviderModel,
|
|
14618
14799
|
resolveFilesystemToolProfile,
|
|
14619
14800
|
resolveFireworksModelId,
|
|
14620
14801
|
runAgentLoop,
|