@ljoukov/llm 4.1.0 → 5.0.0

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
@@ -19,6 +19,92 @@ declare function estimateCallCostUsd({ modelId, tokens, responseImages, imageSiz
19
19
  imageSize?: string;
20
20
  }): number;
21
21
 
22
+ type LlmTelemetryOperation = "generateText" | "streamText" | "generateJson" | "streamJson" | "generateImages";
23
+ type LlmTelemetryBaseEvent = {
24
+ readonly timestamp: string;
25
+ readonly callId: string;
26
+ readonly operation: LlmTelemetryOperation;
27
+ readonly provider: LlmProvider;
28
+ readonly model: LlmModelId;
29
+ };
30
+ type LlmCallStartedTelemetryEvent = LlmTelemetryBaseEvent & {
31
+ readonly type: "llm.call.started";
32
+ readonly inputMode?: "string" | "messages";
33
+ readonly toolCount?: number;
34
+ readonly responseModalities?: readonly string[];
35
+ readonly imagePromptCount?: number;
36
+ readonly styleImageCount?: number;
37
+ readonly maxAttempts?: number;
38
+ readonly streamMode?: "partial" | "final";
39
+ };
40
+ type LlmCallStreamTelemetryEvent = LlmTelemetryBaseEvent & {
41
+ readonly type: "llm.call.stream";
42
+ readonly event: LlmStreamEvent;
43
+ };
44
+ type LlmCallCompletedTelemetryEvent = LlmTelemetryBaseEvent & {
45
+ readonly type: "llm.call.completed";
46
+ readonly success: boolean;
47
+ readonly durationMs: number;
48
+ readonly modelVersion?: string;
49
+ readonly blocked?: boolean;
50
+ readonly usage?: LlmUsageTokens;
51
+ readonly costUsd?: number;
52
+ readonly outputTextChars?: number;
53
+ readonly thoughtChars?: number;
54
+ readonly responseImages?: number;
55
+ readonly rawTextChars?: number;
56
+ readonly imageCount?: number;
57
+ readonly attempts?: number;
58
+ readonly uploadCount?: number;
59
+ readonly uploadBytes?: number;
60
+ readonly uploadLatencyMs?: number;
61
+ readonly error?: string;
62
+ };
63
+ type AgentTelemetryBaseEvent = {
64
+ readonly timestamp: string;
65
+ readonly runId: string;
66
+ readonly parentRunId?: string;
67
+ readonly depth: number;
68
+ readonly model: LlmModelId;
69
+ };
70
+ type AgentRunStartedTelemetryEvent = AgentTelemetryBaseEvent & {
71
+ readonly type: "agent.run.started";
72
+ readonly inputMode: "string" | "messages";
73
+ readonly customToolCount: number;
74
+ readonly mergedToolCount: number;
75
+ readonly filesystemToolsEnabled: boolean;
76
+ readonly subagentToolsEnabled: boolean;
77
+ };
78
+ type AgentRunStreamTelemetryEvent = AgentTelemetryBaseEvent & {
79
+ readonly type: "agent.run.stream";
80
+ readonly event: LlmStreamEvent;
81
+ };
82
+ type AgentRunCompletedTelemetryEvent = AgentTelemetryBaseEvent & {
83
+ readonly type: "agent.run.completed";
84
+ readonly success: boolean;
85
+ readonly durationMs: number;
86
+ readonly stepCount?: number;
87
+ readonly toolCallCount?: number;
88
+ readonly totalCostUsd?: number;
89
+ readonly usage?: LlmUsageTokens;
90
+ readonly uploadCount?: number;
91
+ readonly uploadBytes?: number;
92
+ readonly uploadLatencyMs?: number;
93
+ readonly error?: string;
94
+ };
95
+ type TelemetryEvent = LlmCallStartedTelemetryEvent | LlmCallStreamTelemetryEvent | LlmCallCompletedTelemetryEvent | AgentRunStartedTelemetryEvent | AgentRunStreamTelemetryEvent | AgentRunCompletedTelemetryEvent;
96
+ type TelemetrySink = {
97
+ readonly emit: (event: TelemetryEvent) => void | Promise<void>;
98
+ readonly flush?: () => void | Promise<void>;
99
+ };
100
+ type TelemetryConfig = {
101
+ readonly sink: TelemetrySink;
102
+ readonly includeStreamEvents?: boolean;
103
+ };
104
+ type TelemetrySelection = false | TelemetryConfig;
105
+ declare function configureTelemetry(telemetry?: TelemetrySelection | undefined): void;
106
+ declare function resetTelemetry(): void;
107
+
22
108
  type LlmToolCallContext = {
23
109
  readonly toolName: string;
24
110
  readonly toolId: string;
@@ -196,6 +282,7 @@ type LlmBaseRequest = {
196
282
  readonly imageSize?: LlmImageSize;
197
283
  readonly thinkingLevel?: LlmThinkingLevel;
198
284
  readonly openAiTextFormat?: ResponseTextConfig["format"];
285
+ readonly telemetry?: TelemetrySelection;
199
286
  readonly signal?: AbortSignal;
200
287
  };
201
288
  type LlmTextRequest = LlmInput & LlmBaseRequest;
@@ -245,6 +332,7 @@ type LlmGenerateImagesRequest = {
245
332
  readonly maxAttempts?: number;
246
333
  readonly imageAspectRatio?: string;
247
334
  readonly imageSize?: LlmImageSize;
335
+ readonly telemetry?: TelemetrySelection;
248
336
  readonly signal?: AbortSignal;
249
337
  };
250
338
  type LlmFunctionTool<Schema extends z.ZodType, Output> = {
@@ -671,7 +759,7 @@ type RunAgentLoopRequest = Omit<LlmToolLoopRequest, "tools"> & {
671
759
  readonly subagentTool?: AgentSubagentToolSelection;
672
760
  readonly subagent_tool?: AgentSubagentToolSelection;
673
761
  readonly subagents?: AgentSubagentToolSelection;
674
- readonly telemetry?: AgentTelemetrySelection;
762
+ readonly telemetry?: TelemetrySelection;
675
763
  readonly logging?: AgentLoggingSelection;
676
764
  };
677
765
  type AgentLoopStream = {
@@ -684,48 +772,6 @@ type AgentLoopStream = {
684
772
  };
685
773
  declare function runAgentLoop(request: RunAgentLoopRequest): Promise<LlmToolLoopResult>;
686
774
  declare function streamAgentLoop(request: RunAgentLoopRequest): AgentLoopStream;
687
- type AgentTelemetryBaseEvent = {
688
- readonly timestamp: string;
689
- readonly runId: string;
690
- readonly parentRunId?: string;
691
- readonly depth: number;
692
- readonly model: LlmToolLoopRequest["model"];
693
- };
694
- type AgentRunStartedTelemetryEvent = AgentTelemetryBaseEvent & {
695
- readonly type: "agent.run.started";
696
- readonly inputMode: "string" | "messages";
697
- readonly customToolCount: number;
698
- readonly mergedToolCount: number;
699
- readonly filesystemToolsEnabled: boolean;
700
- readonly subagentToolsEnabled: boolean;
701
- };
702
- type AgentRunStreamTelemetryEvent = AgentTelemetryBaseEvent & {
703
- readonly type: "agent.run.stream";
704
- readonly event: LlmStreamEvent;
705
- };
706
- type AgentRunCompletedTelemetryEvent = AgentTelemetryBaseEvent & {
707
- readonly type: "agent.run.completed";
708
- readonly success: boolean;
709
- readonly durationMs: number;
710
- readonly stepCount?: number;
711
- readonly toolCallCount?: number;
712
- readonly totalCostUsd?: number;
713
- readonly usage?: LlmUsageTokens;
714
- readonly uploadCount?: number;
715
- readonly uploadBytes?: number;
716
- readonly uploadLatencyMs?: number;
717
- readonly error?: string;
718
- };
719
- type AgentTelemetryEvent = AgentRunStartedTelemetryEvent | AgentRunStreamTelemetryEvent | AgentRunCompletedTelemetryEvent;
720
- type AgentTelemetrySink = {
721
- readonly emit: (event: AgentTelemetryEvent) => void | Promise<void>;
722
- readonly flush?: () => void | Promise<void>;
723
- };
724
- type AgentTelemetryConfig = {
725
- readonly sink: AgentTelemetrySink;
726
- readonly includeLlmStreamEvents?: boolean;
727
- };
728
- type AgentTelemetrySelection = AgentTelemetrySink | AgentTelemetryConfig;
729
775
 
730
776
  declare const CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION = "Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
731
777
  declare const CODEX_APPLY_PATCH_LARK_GRAMMAR: string;
@@ -952,4 +998,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
952
998
  declare function isFireworksModelId(value: string): value is FireworksModelId;
953
999
  declare function resolveFireworksModelId(model: string): string | undefined;
954
1000
 
955
- 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 AgentTelemetryConfig, type AgentTelemetryEvent, type AgentTelemetrySelection, type AgentTelemetrySink, 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, 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 LlmBaseRequest, type LlmBlockedEvent, 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 LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmModelId, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, 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_MODEL_IDS, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, 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, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool };
1001
+ 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, 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 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 LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmModelId, 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_MODEL_IDS, 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, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,92 @@ declare function estimateCallCostUsd({ modelId, tokens, responseImages, imageSiz
19
19
  imageSize?: string;
20
20
  }): number;
21
21
 
22
+ type LlmTelemetryOperation = "generateText" | "streamText" | "generateJson" | "streamJson" | "generateImages";
23
+ type LlmTelemetryBaseEvent = {
24
+ readonly timestamp: string;
25
+ readonly callId: string;
26
+ readonly operation: LlmTelemetryOperation;
27
+ readonly provider: LlmProvider;
28
+ readonly model: LlmModelId;
29
+ };
30
+ type LlmCallStartedTelemetryEvent = LlmTelemetryBaseEvent & {
31
+ readonly type: "llm.call.started";
32
+ readonly inputMode?: "string" | "messages";
33
+ readonly toolCount?: number;
34
+ readonly responseModalities?: readonly string[];
35
+ readonly imagePromptCount?: number;
36
+ readonly styleImageCount?: number;
37
+ readonly maxAttempts?: number;
38
+ readonly streamMode?: "partial" | "final";
39
+ };
40
+ type LlmCallStreamTelemetryEvent = LlmTelemetryBaseEvent & {
41
+ readonly type: "llm.call.stream";
42
+ readonly event: LlmStreamEvent;
43
+ };
44
+ type LlmCallCompletedTelemetryEvent = LlmTelemetryBaseEvent & {
45
+ readonly type: "llm.call.completed";
46
+ readonly success: boolean;
47
+ readonly durationMs: number;
48
+ readonly modelVersion?: string;
49
+ readonly blocked?: boolean;
50
+ readonly usage?: LlmUsageTokens;
51
+ readonly costUsd?: number;
52
+ readonly outputTextChars?: number;
53
+ readonly thoughtChars?: number;
54
+ readonly responseImages?: number;
55
+ readonly rawTextChars?: number;
56
+ readonly imageCount?: number;
57
+ readonly attempts?: number;
58
+ readonly uploadCount?: number;
59
+ readonly uploadBytes?: number;
60
+ readonly uploadLatencyMs?: number;
61
+ readonly error?: string;
62
+ };
63
+ type AgentTelemetryBaseEvent = {
64
+ readonly timestamp: string;
65
+ readonly runId: string;
66
+ readonly parentRunId?: string;
67
+ readonly depth: number;
68
+ readonly model: LlmModelId;
69
+ };
70
+ type AgentRunStartedTelemetryEvent = AgentTelemetryBaseEvent & {
71
+ readonly type: "agent.run.started";
72
+ readonly inputMode: "string" | "messages";
73
+ readonly customToolCount: number;
74
+ readonly mergedToolCount: number;
75
+ readonly filesystemToolsEnabled: boolean;
76
+ readonly subagentToolsEnabled: boolean;
77
+ };
78
+ type AgentRunStreamTelemetryEvent = AgentTelemetryBaseEvent & {
79
+ readonly type: "agent.run.stream";
80
+ readonly event: LlmStreamEvent;
81
+ };
82
+ type AgentRunCompletedTelemetryEvent = AgentTelemetryBaseEvent & {
83
+ readonly type: "agent.run.completed";
84
+ readonly success: boolean;
85
+ readonly durationMs: number;
86
+ readonly stepCount?: number;
87
+ readonly toolCallCount?: number;
88
+ readonly totalCostUsd?: number;
89
+ readonly usage?: LlmUsageTokens;
90
+ readonly uploadCount?: number;
91
+ readonly uploadBytes?: number;
92
+ readonly uploadLatencyMs?: number;
93
+ readonly error?: string;
94
+ };
95
+ type TelemetryEvent = LlmCallStartedTelemetryEvent | LlmCallStreamTelemetryEvent | LlmCallCompletedTelemetryEvent | AgentRunStartedTelemetryEvent | AgentRunStreamTelemetryEvent | AgentRunCompletedTelemetryEvent;
96
+ type TelemetrySink = {
97
+ readonly emit: (event: TelemetryEvent) => void | Promise<void>;
98
+ readonly flush?: () => void | Promise<void>;
99
+ };
100
+ type TelemetryConfig = {
101
+ readonly sink: TelemetrySink;
102
+ readonly includeStreamEvents?: boolean;
103
+ };
104
+ type TelemetrySelection = false | TelemetryConfig;
105
+ declare function configureTelemetry(telemetry?: TelemetrySelection | undefined): void;
106
+ declare function resetTelemetry(): void;
107
+
22
108
  type LlmToolCallContext = {
23
109
  readonly toolName: string;
24
110
  readonly toolId: string;
@@ -196,6 +282,7 @@ type LlmBaseRequest = {
196
282
  readonly imageSize?: LlmImageSize;
197
283
  readonly thinkingLevel?: LlmThinkingLevel;
198
284
  readonly openAiTextFormat?: ResponseTextConfig["format"];
285
+ readonly telemetry?: TelemetrySelection;
199
286
  readonly signal?: AbortSignal;
200
287
  };
201
288
  type LlmTextRequest = LlmInput & LlmBaseRequest;
@@ -245,6 +332,7 @@ type LlmGenerateImagesRequest = {
245
332
  readonly maxAttempts?: number;
246
333
  readonly imageAspectRatio?: string;
247
334
  readonly imageSize?: LlmImageSize;
335
+ readonly telemetry?: TelemetrySelection;
248
336
  readonly signal?: AbortSignal;
249
337
  };
250
338
  type LlmFunctionTool<Schema extends z.ZodType, Output> = {
@@ -671,7 +759,7 @@ type RunAgentLoopRequest = Omit<LlmToolLoopRequest, "tools"> & {
671
759
  readonly subagentTool?: AgentSubagentToolSelection;
672
760
  readonly subagent_tool?: AgentSubagentToolSelection;
673
761
  readonly subagents?: AgentSubagentToolSelection;
674
- readonly telemetry?: AgentTelemetrySelection;
762
+ readonly telemetry?: TelemetrySelection;
675
763
  readonly logging?: AgentLoggingSelection;
676
764
  };
677
765
  type AgentLoopStream = {
@@ -684,48 +772,6 @@ type AgentLoopStream = {
684
772
  };
685
773
  declare function runAgentLoop(request: RunAgentLoopRequest): Promise<LlmToolLoopResult>;
686
774
  declare function streamAgentLoop(request: RunAgentLoopRequest): AgentLoopStream;
687
- type AgentTelemetryBaseEvent = {
688
- readonly timestamp: string;
689
- readonly runId: string;
690
- readonly parentRunId?: string;
691
- readonly depth: number;
692
- readonly model: LlmToolLoopRequest["model"];
693
- };
694
- type AgentRunStartedTelemetryEvent = AgentTelemetryBaseEvent & {
695
- readonly type: "agent.run.started";
696
- readonly inputMode: "string" | "messages";
697
- readonly customToolCount: number;
698
- readonly mergedToolCount: number;
699
- readonly filesystemToolsEnabled: boolean;
700
- readonly subagentToolsEnabled: boolean;
701
- };
702
- type AgentRunStreamTelemetryEvent = AgentTelemetryBaseEvent & {
703
- readonly type: "agent.run.stream";
704
- readonly event: LlmStreamEvent;
705
- };
706
- type AgentRunCompletedTelemetryEvent = AgentTelemetryBaseEvent & {
707
- readonly type: "agent.run.completed";
708
- readonly success: boolean;
709
- readonly durationMs: number;
710
- readonly stepCount?: number;
711
- readonly toolCallCount?: number;
712
- readonly totalCostUsd?: number;
713
- readonly usage?: LlmUsageTokens;
714
- readonly uploadCount?: number;
715
- readonly uploadBytes?: number;
716
- readonly uploadLatencyMs?: number;
717
- readonly error?: string;
718
- };
719
- type AgentTelemetryEvent = AgentRunStartedTelemetryEvent | AgentRunStreamTelemetryEvent | AgentRunCompletedTelemetryEvent;
720
- type AgentTelemetrySink = {
721
- readonly emit: (event: AgentTelemetryEvent) => void | Promise<void>;
722
- readonly flush?: () => void | Promise<void>;
723
- };
724
- type AgentTelemetryConfig = {
725
- readonly sink: AgentTelemetrySink;
726
- readonly includeLlmStreamEvents?: boolean;
727
- };
728
- type AgentTelemetrySelection = AgentTelemetrySink | AgentTelemetryConfig;
729
775
 
730
776
  declare const CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION = "Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
731
777
  declare const CODEX_APPLY_PATCH_LARK_GRAMMAR: string;
@@ -952,4 +998,4 @@ declare const FIREWORKS_DEFAULT_GPT_OSS_120B_MODEL: FireworksModelId;
952
998
  declare function isFireworksModelId(value: string): value is FireworksModelId;
953
999
  declare function resolveFireworksModelId(model: string): string | undefined;
954
1000
 
955
- 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 AgentTelemetryConfig, type AgentTelemetryEvent, type AgentTelemetrySelection, type AgentTelemetrySink, 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, 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 LlmBaseRequest, type LlmBlockedEvent, 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 LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmModelId, type LlmProvider, type LlmStoredFile, type LlmStreamEvent, 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_MODEL_IDS, type OpenAiModelId, type ParentSelectionConfig, type ParentSelectionMidpoint, type PostCheckRejection, type PostGenerationCheckInput, type RunAgentLoopRequest, appendMarkdownSourcesSection, applyPatch, configureGemini, configureModelConcurrency, 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, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool };
1001
+ 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, 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 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 LlmImageData, type LlmImageModelId, type LlmImageSize, type LlmInput, type LlmInputFilePart, type LlmInputImagePart, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmModelId, 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_MODEL_IDS, 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, isFireworksModelId, isGeminiImageModelId, isGeminiModelId, isGeminiTextModelId, isLlmImageModelId, isLlmModelId, isLlmTextModelId, isOpenAiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resetModelConcurrencyConfig, resetTelemetry, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runCandidateEvolution, runToolLoop, sanitisePartForLogging, streamAgentLoop, streamJson, streamText, streamToolLoop, stripCodexCitationMarkers, toGeminiJsonSchema, tool };