@ljoukov/llm 2.1.0 → 3.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/README.md +92 -49
- package/dist/index.cjs +1259 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -36
- package/dist/index.d.ts +92 -36
- package/dist/index.js +1246 -256
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -75,7 +75,7 @@ type LlmBlockedEvent = {
|
|
|
75
75
|
readonly type: "blocked";
|
|
76
76
|
};
|
|
77
77
|
type LlmStreamEvent = LlmTextDeltaEvent | LlmUsageEvent | LlmModelEvent | LlmBlockedEvent;
|
|
78
|
-
type LlmProvider = "openai" | "chatgpt" | "gemini";
|
|
78
|
+
type LlmProvider = "openai" | "chatgpt" | "gemini" | "fireworks";
|
|
79
79
|
type LlmTextResult = {
|
|
80
80
|
readonly provider: LlmProvider;
|
|
81
81
|
readonly model: string;
|
|
@@ -191,17 +191,37 @@ type LlmGenerateImagesRequest = {
|
|
|
191
191
|
readonly imageSize?: LlmImageSize;
|
|
192
192
|
readonly signal?: AbortSignal;
|
|
193
193
|
};
|
|
194
|
-
type
|
|
194
|
+
type LlmFunctionTool<Schema extends z.ZodType, Output> = {
|
|
195
|
+
readonly type?: "function";
|
|
195
196
|
readonly description?: string;
|
|
196
197
|
readonly inputSchema: Schema;
|
|
197
198
|
readonly execute: (input: z.output<Schema>) => Promise<Output> | Output;
|
|
198
199
|
};
|
|
200
|
+
type LlmCustomToolInputFormat = {
|
|
201
|
+
readonly type: "text";
|
|
202
|
+
} | {
|
|
203
|
+
readonly type: "grammar";
|
|
204
|
+
readonly syntax: "lark" | "regex";
|
|
205
|
+
readonly definition: string;
|
|
206
|
+
};
|
|
207
|
+
type LlmCustomTool<Output> = {
|
|
208
|
+
readonly type: "custom";
|
|
209
|
+
readonly description?: string;
|
|
210
|
+
readonly format?: LlmCustomToolInputFormat;
|
|
211
|
+
readonly execute: (input: string) => Promise<Output> | Output;
|
|
212
|
+
};
|
|
213
|
+
type LlmExecutableTool<Schema extends z.ZodType, Output> = LlmFunctionTool<Schema, Output> | LlmCustomTool<Output>;
|
|
199
214
|
type LlmToolSet = Record<string, LlmExecutableTool<z.ZodType, unknown>>;
|
|
200
215
|
declare function tool<Schema extends z.ZodType, Output>(options: {
|
|
201
216
|
readonly description?: string;
|
|
202
217
|
readonly inputSchema: Schema;
|
|
203
218
|
readonly execute: (input: z.output<Schema>) => Promise<Output> | Output;
|
|
204
|
-
}):
|
|
219
|
+
}): LlmFunctionTool<Schema, Output>;
|
|
220
|
+
declare function customTool<Output>(options: {
|
|
221
|
+
readonly description?: string;
|
|
222
|
+
readonly format?: LlmCustomToolInputFormat;
|
|
223
|
+
readonly execute: (input: string) => Promise<Output> | Output;
|
|
224
|
+
}): LlmCustomTool<Output>;
|
|
205
225
|
type LlmToolCallResult = {
|
|
206
226
|
readonly toolName: string;
|
|
207
227
|
readonly input: unknown;
|
|
@@ -304,7 +324,7 @@ declare function createNodeAgentFilesystem(): AgentFilesystem;
|
|
|
304
324
|
declare function createInMemoryAgentFilesystem(initialFiles?: Record<string, string>): InMemoryAgentFilesystem;
|
|
305
325
|
|
|
306
326
|
type AgentFilesystemToolProfile = "auto" | "model-agnostic" | "codex" | "gemini";
|
|
307
|
-
type AgentFilesystemToolName = "apply_patch" | "read_file" | "write_file" | "replace" | "list_dir" | "list_directory" | "grep_files" | "grep_search" | "glob";
|
|
327
|
+
type AgentFilesystemToolName = "apply_patch" | "read_file" | "read_files" | "write_file" | "replace" | "list_dir" | "list_directory" | "grep_files" | "rg_search" | "grep_search" | "glob";
|
|
308
328
|
type AgentFilesystemToolAction = "read" | "write" | "delete" | "move" | "list" | "search";
|
|
309
329
|
type AgentFilesystemToolAccessContext = {
|
|
310
330
|
readonly cwd: string;
|
|
@@ -361,8 +381,16 @@ declare const applyPatchInputSchema: z.ZodObject<{
|
|
|
361
381
|
}, z.core.$strip>;
|
|
362
382
|
declare const geminiReadFileInputSchema: z.ZodObject<{
|
|
363
383
|
file_path: z.ZodString;
|
|
364
|
-
offset: z.ZodOptional<z.ZodNumber
|
|
365
|
-
limit: z.ZodOptional<z.ZodNumber
|
|
384
|
+
offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
385
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
386
|
+
}, z.core.$strip>;
|
|
387
|
+
declare const geminiReadFilesInputSchema: z.ZodObject<{
|
|
388
|
+
paths: z.ZodArray<z.ZodString>;
|
|
389
|
+
line_offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
390
|
+
line_limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
391
|
+
char_offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
392
|
+
char_limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
393
|
+
include_line_numbers: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
366
394
|
}, z.core.$strip>;
|
|
367
395
|
declare const geminiWriteFileInputSchema: z.ZodObject<{
|
|
368
396
|
file_path: z.ZodString;
|
|
@@ -373,57 +401,71 @@ declare const geminiReplaceInputSchema: z.ZodObject<{
|
|
|
373
401
|
instruction: z.ZodString;
|
|
374
402
|
old_string: z.ZodString;
|
|
375
403
|
new_string: z.ZodString;
|
|
376
|
-
expected_replacements: z.ZodOptional<z.ZodNumber
|
|
404
|
+
expected_replacements: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
377
405
|
}, z.core.$strip>;
|
|
378
406
|
declare const geminiListDirectoryInputSchema: z.ZodObject<{
|
|
379
407
|
dir_path: z.ZodString;
|
|
380
|
-
ignore: z.ZodOptional<z.ZodArray<z.ZodString
|
|
381
|
-
file_filtering_options: z.ZodOptional<z.ZodObject<{
|
|
382
|
-
respect_git_ignore: z.ZodOptional<z.ZodBoolean
|
|
383
|
-
respect_gemini_ignore: z.ZodOptional<z.ZodBoolean
|
|
384
|
-
}, z.core.$strip
|
|
408
|
+
ignore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
409
|
+
file_filtering_options: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
410
|
+
respect_git_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
411
|
+
respect_gemini_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
412
|
+
}, z.core.$strip>>>;
|
|
413
|
+
}, z.core.$strip>;
|
|
414
|
+
declare const geminiRgSearchInputSchema: z.ZodObject<{
|
|
415
|
+
pattern: z.ZodString;
|
|
416
|
+
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
417
|
+
glob: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
418
|
+
case_sensitive: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
419
|
+
exclude_pattern: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
420
|
+
names_only: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
421
|
+
max_matches_per_file: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
422
|
+
max_results: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
385
423
|
}, z.core.$strip>;
|
|
386
424
|
declare const geminiGrepSearchInputSchema: z.ZodObject<{
|
|
387
425
|
pattern: z.ZodString;
|
|
388
|
-
dir_path: z.ZodOptional<z.ZodString
|
|
389
|
-
include: z.ZodOptional<z.ZodString
|
|
390
|
-
exclude_pattern: z.ZodOptional<z.ZodString
|
|
391
|
-
names_only: z.ZodOptional<z.ZodBoolean
|
|
392
|
-
max_matches_per_file: z.ZodOptional<z.ZodNumber
|
|
393
|
-
total_max_matches: z.ZodOptional<z.ZodNumber
|
|
426
|
+
dir_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
427
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
428
|
+
exclude_pattern: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
429
|
+
names_only: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
430
|
+
max_matches_per_file: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
431
|
+
total_max_matches: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
394
432
|
}, z.core.$strip>;
|
|
395
433
|
declare const geminiGlobInputSchema: z.ZodObject<{
|
|
396
434
|
pattern: z.ZodString;
|
|
397
|
-
dir_path: z.ZodOptional<z.ZodString
|
|
398
|
-
case_sensitive: z.ZodOptional<z.ZodBoolean
|
|
399
|
-
respect_git_ignore: z.ZodOptional<z.ZodBoolean
|
|
400
|
-
respect_gemini_ignore: z.ZodOptional<z.ZodBoolean
|
|
435
|
+
dir_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
436
|
+
case_sensitive: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
437
|
+
respect_git_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
438
|
+
respect_gemini_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
401
439
|
}, z.core.$strip>;
|
|
402
440
|
type CodexReadFileToolInput = z.output<typeof codexReadFileInputSchema>;
|
|
403
441
|
type CodexListDirToolInput = z.output<typeof codexListDirInputSchema>;
|
|
404
442
|
type CodexGrepFilesToolInput = z.output<typeof codexGrepFilesInputSchema>;
|
|
405
443
|
type CodexApplyPatchToolInput = z.output<typeof applyPatchInputSchema>;
|
|
406
444
|
type GeminiReadFileToolInput = z.output<typeof geminiReadFileInputSchema>;
|
|
445
|
+
type GeminiReadFilesToolInput = z.output<typeof geminiReadFilesInputSchema>;
|
|
407
446
|
type GeminiWriteFileToolInput = z.output<typeof geminiWriteFileInputSchema>;
|
|
408
447
|
type GeminiReplaceToolInput = z.output<typeof geminiReplaceInputSchema>;
|
|
409
448
|
type GeminiListDirectoryToolInput = z.output<typeof geminiListDirectoryInputSchema>;
|
|
410
449
|
type GeminiGrepSearchToolInput = z.output<typeof geminiGrepSearchInputSchema>;
|
|
450
|
+
type GeminiRgSearchToolInput = z.output<typeof geminiRgSearchInputSchema>;
|
|
411
451
|
type GeminiGlobToolInput = z.output<typeof geminiGlobInputSchema>;
|
|
412
452
|
declare function resolveFilesystemToolProfile(model: string, profile?: AgentFilesystemToolProfile): Exclude<AgentFilesystemToolProfile, "auto">;
|
|
413
453
|
declare function createFilesystemToolSetForModel(model: string, profileOrOptions?: AgentFilesystemToolProfile | AgentFilesystemToolsOptions, maybeOptions?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
414
454
|
declare function createCodexFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
415
455
|
declare function createGeminiFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
416
456
|
declare function createModelAgnosticFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
417
|
-
declare function createCodexApplyPatchTool(options?: AgentFilesystemToolsOptions):
|
|
418
|
-
declare function createCodexReadFileTool(options?: AgentFilesystemToolsOptions):
|
|
419
|
-
declare function createListDirTool(options?: AgentFilesystemToolsOptions):
|
|
420
|
-
declare function createGrepFilesTool(options?: AgentFilesystemToolsOptions):
|
|
421
|
-
declare function
|
|
422
|
-
declare function
|
|
423
|
-
declare function
|
|
424
|
-
declare function
|
|
425
|
-
declare function
|
|
426
|
-
declare function
|
|
457
|
+
declare function createCodexApplyPatchTool(options?: AgentFilesystemToolsOptions): LlmCustomTool<string>;
|
|
458
|
+
declare function createCodexReadFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexReadFileInputSchema, string>;
|
|
459
|
+
declare function createListDirTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexListDirInputSchema, string>;
|
|
460
|
+
declare function createGrepFilesTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexGrepFilesInputSchema, string>;
|
|
461
|
+
declare function createGeminiReadFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReadFileInputSchema, string>;
|
|
462
|
+
declare function createReadFilesTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReadFilesInputSchema, string>;
|
|
463
|
+
declare function createWriteFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiWriteFileInputSchema, string>;
|
|
464
|
+
declare function createReplaceTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReplaceInputSchema, string>;
|
|
465
|
+
declare function createListDirectoryTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiListDirectoryInputSchema, string>;
|
|
466
|
+
declare function createGrepSearchTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiGrepSearchInputSchema, string>;
|
|
467
|
+
declare function createRgSearchTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiRgSearchInputSchema, string>;
|
|
468
|
+
declare function createGlobTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiGlobInputSchema, string>;
|
|
427
469
|
|
|
428
470
|
type AgentFilesystemToolConfig = {
|
|
429
471
|
readonly enabled?: boolean;
|
|
@@ -438,6 +480,9 @@ type RunAgentLoopRequest = Omit<LlmToolLoopRequest, "tools"> & {
|
|
|
438
480
|
};
|
|
439
481
|
declare function runAgentLoop(request: RunAgentLoopRequest): Promise<LlmToolLoopResult>;
|
|
440
482
|
|
|
483
|
+
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.";
|
|
484
|
+
declare const CODEX_APPLY_PATCH_LARK_GRAMMAR: string;
|
|
485
|
+
declare const CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION: string;
|
|
441
486
|
type ApplyPatchAccessContext = {
|
|
442
487
|
readonly cwd: string;
|
|
443
488
|
readonly kind: "add" | "delete" | "update" | "move";
|
|
@@ -468,7 +513,7 @@ declare const applyPatchToolInputSchema: z.ZodObject<{
|
|
|
468
513
|
input: z.ZodString;
|
|
469
514
|
}, z.core.$strip>;
|
|
470
515
|
type ApplyPatchToolInput = z.output<typeof applyPatchToolInputSchema>;
|
|
471
|
-
declare function createApplyPatchTool(options?: CreateApplyPatchToolOptions):
|
|
516
|
+
declare function createApplyPatchTool(options?: CreateApplyPatchToolOptions): LlmFunctionTool<typeof applyPatchToolInputSchema, ApplyPatchResult>;
|
|
472
517
|
declare function applyPatch(request: ApplyPatchRequest): Promise<ApplyPatchResult>;
|
|
473
518
|
|
|
474
519
|
type ChatGptAuthProfile = {
|
|
@@ -485,10 +530,13 @@ declare function exchangeChatGptOauthCode({ code, verifier, redirectUri, }: {
|
|
|
485
530
|
verifier: string;
|
|
486
531
|
redirectUri?: string;
|
|
487
532
|
}): Promise<ChatGptAuthProfile>;
|
|
488
|
-
declare function refreshChatGptOauthToken(refreshToken: string
|
|
533
|
+
declare function refreshChatGptOauthToken(refreshToken: string, fallback?: {
|
|
534
|
+
accountId?: string;
|
|
535
|
+
idToken?: string;
|
|
536
|
+
}): Promise<ChatGptAuthProfile>;
|
|
489
537
|
declare function getChatGptAuthProfile(): Promise<ChatGptAuthProfile>;
|
|
490
538
|
|
|
491
|
-
declare const GEMINI_MODEL_IDS: readonly ["gemini-3-pro-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
539
|
+
declare const GEMINI_MODEL_IDS: readonly ["gemini-3-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
492
540
|
type GeminiModelId = (typeof GEMINI_MODEL_IDS)[number];
|
|
493
541
|
declare function isGeminiModelId(value: string): value is GeminiModelId;
|
|
494
542
|
type GeminiConfiguration = {
|
|
@@ -497,4 +545,12 @@ type GeminiConfiguration = {
|
|
|
497
545
|
};
|
|
498
546
|
declare function configureGemini(options?: GeminiConfiguration): void;
|
|
499
547
|
|
|
500
|
-
|
|
548
|
+
declare const FIREWORKS_MODEL_IDS: readonly ["kimi-k2.5", "glm-5", "minimax-m2.1"];
|
|
549
|
+
type FireworksModelId = (typeof FIREWORKS_MODEL_IDS)[number];
|
|
550
|
+
declare const FIREWORKS_DEFAULT_KIMI_MODEL: FireworksModelId;
|
|
551
|
+
declare const FIREWORKS_DEFAULT_GLM_MODEL: FireworksModelId;
|
|
552
|
+
declare const FIREWORKS_DEFAULT_MINIMAX_MODEL: FireworksModelId;
|
|
553
|
+
declare function isFireworksModelId(value: string): value is FireworksModelId;
|
|
554
|
+
declare function resolveFireworksModelId(model: string): string | undefined;
|
|
555
|
+
|
|
556
|
+
export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentPathInfo, type AgentPathKind, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type ChatGptAuthProfile, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CreateApplyPatchToolOptions, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FireworksModelId, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReadFilesToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiWriteFileToolInput, InMemoryAgentFilesystem, type JsonSchema, type LlmBaseRequest, type LlmBlockedEvent, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFunctionTool, type LlmImageData, type LlmImageSize, type LlmInput, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmProvider, type LlmStreamEvent, type LlmTextDeltaEvent, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmToolCallContext, type LlmToolCallResult, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopStep, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type RunAgentLoopRequest, appendMarkdownSourcesSection, applyPatch, configureGemini, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createReadFilesTool, createReplaceTool, createRgSearchTool, createWriteFileTool, customTool, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isFireworksModelId, isGeminiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runToolLoop, sanitisePartForLogging, streamJson, streamText, stripCodexCitationMarkers, toGeminiJsonSchema, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ type LlmBlockedEvent = {
|
|
|
75
75
|
readonly type: "blocked";
|
|
76
76
|
};
|
|
77
77
|
type LlmStreamEvent = LlmTextDeltaEvent | LlmUsageEvent | LlmModelEvent | LlmBlockedEvent;
|
|
78
|
-
type LlmProvider = "openai" | "chatgpt" | "gemini";
|
|
78
|
+
type LlmProvider = "openai" | "chatgpt" | "gemini" | "fireworks";
|
|
79
79
|
type LlmTextResult = {
|
|
80
80
|
readonly provider: LlmProvider;
|
|
81
81
|
readonly model: string;
|
|
@@ -191,17 +191,37 @@ type LlmGenerateImagesRequest = {
|
|
|
191
191
|
readonly imageSize?: LlmImageSize;
|
|
192
192
|
readonly signal?: AbortSignal;
|
|
193
193
|
};
|
|
194
|
-
type
|
|
194
|
+
type LlmFunctionTool<Schema extends z.ZodType, Output> = {
|
|
195
|
+
readonly type?: "function";
|
|
195
196
|
readonly description?: string;
|
|
196
197
|
readonly inputSchema: Schema;
|
|
197
198
|
readonly execute: (input: z.output<Schema>) => Promise<Output> | Output;
|
|
198
199
|
};
|
|
200
|
+
type LlmCustomToolInputFormat = {
|
|
201
|
+
readonly type: "text";
|
|
202
|
+
} | {
|
|
203
|
+
readonly type: "grammar";
|
|
204
|
+
readonly syntax: "lark" | "regex";
|
|
205
|
+
readonly definition: string;
|
|
206
|
+
};
|
|
207
|
+
type LlmCustomTool<Output> = {
|
|
208
|
+
readonly type: "custom";
|
|
209
|
+
readonly description?: string;
|
|
210
|
+
readonly format?: LlmCustomToolInputFormat;
|
|
211
|
+
readonly execute: (input: string) => Promise<Output> | Output;
|
|
212
|
+
};
|
|
213
|
+
type LlmExecutableTool<Schema extends z.ZodType, Output> = LlmFunctionTool<Schema, Output> | LlmCustomTool<Output>;
|
|
199
214
|
type LlmToolSet = Record<string, LlmExecutableTool<z.ZodType, unknown>>;
|
|
200
215
|
declare function tool<Schema extends z.ZodType, Output>(options: {
|
|
201
216
|
readonly description?: string;
|
|
202
217
|
readonly inputSchema: Schema;
|
|
203
218
|
readonly execute: (input: z.output<Schema>) => Promise<Output> | Output;
|
|
204
|
-
}):
|
|
219
|
+
}): LlmFunctionTool<Schema, Output>;
|
|
220
|
+
declare function customTool<Output>(options: {
|
|
221
|
+
readonly description?: string;
|
|
222
|
+
readonly format?: LlmCustomToolInputFormat;
|
|
223
|
+
readonly execute: (input: string) => Promise<Output> | Output;
|
|
224
|
+
}): LlmCustomTool<Output>;
|
|
205
225
|
type LlmToolCallResult = {
|
|
206
226
|
readonly toolName: string;
|
|
207
227
|
readonly input: unknown;
|
|
@@ -304,7 +324,7 @@ declare function createNodeAgentFilesystem(): AgentFilesystem;
|
|
|
304
324
|
declare function createInMemoryAgentFilesystem(initialFiles?: Record<string, string>): InMemoryAgentFilesystem;
|
|
305
325
|
|
|
306
326
|
type AgentFilesystemToolProfile = "auto" | "model-agnostic" | "codex" | "gemini";
|
|
307
|
-
type AgentFilesystemToolName = "apply_patch" | "read_file" | "write_file" | "replace" | "list_dir" | "list_directory" | "grep_files" | "grep_search" | "glob";
|
|
327
|
+
type AgentFilesystemToolName = "apply_patch" | "read_file" | "read_files" | "write_file" | "replace" | "list_dir" | "list_directory" | "grep_files" | "rg_search" | "grep_search" | "glob";
|
|
308
328
|
type AgentFilesystemToolAction = "read" | "write" | "delete" | "move" | "list" | "search";
|
|
309
329
|
type AgentFilesystemToolAccessContext = {
|
|
310
330
|
readonly cwd: string;
|
|
@@ -361,8 +381,16 @@ declare const applyPatchInputSchema: z.ZodObject<{
|
|
|
361
381
|
}, z.core.$strip>;
|
|
362
382
|
declare const geminiReadFileInputSchema: z.ZodObject<{
|
|
363
383
|
file_path: z.ZodString;
|
|
364
|
-
offset: z.ZodOptional<z.ZodNumber
|
|
365
|
-
limit: z.ZodOptional<z.ZodNumber
|
|
384
|
+
offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
385
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
386
|
+
}, z.core.$strip>;
|
|
387
|
+
declare const geminiReadFilesInputSchema: z.ZodObject<{
|
|
388
|
+
paths: z.ZodArray<z.ZodString>;
|
|
389
|
+
line_offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
390
|
+
line_limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
391
|
+
char_offset: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
392
|
+
char_limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
393
|
+
include_line_numbers: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
366
394
|
}, z.core.$strip>;
|
|
367
395
|
declare const geminiWriteFileInputSchema: z.ZodObject<{
|
|
368
396
|
file_path: z.ZodString;
|
|
@@ -373,57 +401,71 @@ declare const geminiReplaceInputSchema: z.ZodObject<{
|
|
|
373
401
|
instruction: z.ZodString;
|
|
374
402
|
old_string: z.ZodString;
|
|
375
403
|
new_string: z.ZodString;
|
|
376
|
-
expected_replacements: z.ZodOptional<z.ZodNumber
|
|
404
|
+
expected_replacements: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
377
405
|
}, z.core.$strip>;
|
|
378
406
|
declare const geminiListDirectoryInputSchema: z.ZodObject<{
|
|
379
407
|
dir_path: z.ZodString;
|
|
380
|
-
ignore: z.ZodOptional<z.ZodArray<z.ZodString
|
|
381
|
-
file_filtering_options: z.ZodOptional<z.ZodObject<{
|
|
382
|
-
respect_git_ignore: z.ZodOptional<z.ZodBoolean
|
|
383
|
-
respect_gemini_ignore: z.ZodOptional<z.ZodBoolean
|
|
384
|
-
}, z.core.$strip
|
|
408
|
+
ignore: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
409
|
+
file_filtering_options: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
410
|
+
respect_git_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
411
|
+
respect_gemini_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
412
|
+
}, z.core.$strip>>>;
|
|
413
|
+
}, z.core.$strip>;
|
|
414
|
+
declare const geminiRgSearchInputSchema: z.ZodObject<{
|
|
415
|
+
pattern: z.ZodString;
|
|
416
|
+
path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
417
|
+
glob: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
418
|
+
case_sensitive: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
419
|
+
exclude_pattern: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
420
|
+
names_only: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
421
|
+
max_matches_per_file: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
422
|
+
max_results: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
385
423
|
}, z.core.$strip>;
|
|
386
424
|
declare const geminiGrepSearchInputSchema: z.ZodObject<{
|
|
387
425
|
pattern: z.ZodString;
|
|
388
|
-
dir_path: z.ZodOptional<z.ZodString
|
|
389
|
-
include: z.ZodOptional<z.ZodString
|
|
390
|
-
exclude_pattern: z.ZodOptional<z.ZodString
|
|
391
|
-
names_only: z.ZodOptional<z.ZodBoolean
|
|
392
|
-
max_matches_per_file: z.ZodOptional<z.ZodNumber
|
|
393
|
-
total_max_matches: z.ZodOptional<z.ZodNumber
|
|
426
|
+
dir_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
427
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
428
|
+
exclude_pattern: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
429
|
+
names_only: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
430
|
+
max_matches_per_file: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
431
|
+
total_max_matches: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
394
432
|
}, z.core.$strip>;
|
|
395
433
|
declare const geminiGlobInputSchema: z.ZodObject<{
|
|
396
434
|
pattern: z.ZodString;
|
|
397
|
-
dir_path: z.ZodOptional<z.ZodString
|
|
398
|
-
case_sensitive: z.ZodOptional<z.ZodBoolean
|
|
399
|
-
respect_git_ignore: z.ZodOptional<z.ZodBoolean
|
|
400
|
-
respect_gemini_ignore: z.ZodOptional<z.ZodBoolean
|
|
435
|
+
dir_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
436
|
+
case_sensitive: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
437
|
+
respect_git_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
438
|
+
respect_gemini_ignore: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
401
439
|
}, z.core.$strip>;
|
|
402
440
|
type CodexReadFileToolInput = z.output<typeof codexReadFileInputSchema>;
|
|
403
441
|
type CodexListDirToolInput = z.output<typeof codexListDirInputSchema>;
|
|
404
442
|
type CodexGrepFilesToolInput = z.output<typeof codexGrepFilesInputSchema>;
|
|
405
443
|
type CodexApplyPatchToolInput = z.output<typeof applyPatchInputSchema>;
|
|
406
444
|
type GeminiReadFileToolInput = z.output<typeof geminiReadFileInputSchema>;
|
|
445
|
+
type GeminiReadFilesToolInput = z.output<typeof geminiReadFilesInputSchema>;
|
|
407
446
|
type GeminiWriteFileToolInput = z.output<typeof geminiWriteFileInputSchema>;
|
|
408
447
|
type GeminiReplaceToolInput = z.output<typeof geminiReplaceInputSchema>;
|
|
409
448
|
type GeminiListDirectoryToolInput = z.output<typeof geminiListDirectoryInputSchema>;
|
|
410
449
|
type GeminiGrepSearchToolInput = z.output<typeof geminiGrepSearchInputSchema>;
|
|
450
|
+
type GeminiRgSearchToolInput = z.output<typeof geminiRgSearchInputSchema>;
|
|
411
451
|
type GeminiGlobToolInput = z.output<typeof geminiGlobInputSchema>;
|
|
412
452
|
declare function resolveFilesystemToolProfile(model: string, profile?: AgentFilesystemToolProfile): Exclude<AgentFilesystemToolProfile, "auto">;
|
|
413
453
|
declare function createFilesystemToolSetForModel(model: string, profileOrOptions?: AgentFilesystemToolProfile | AgentFilesystemToolsOptions, maybeOptions?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
414
454
|
declare function createCodexFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
415
455
|
declare function createGeminiFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
416
456
|
declare function createModelAgnosticFilesystemToolSet(options?: AgentFilesystemToolsOptions): LlmToolSet;
|
|
417
|
-
declare function createCodexApplyPatchTool(options?: AgentFilesystemToolsOptions):
|
|
418
|
-
declare function createCodexReadFileTool(options?: AgentFilesystemToolsOptions):
|
|
419
|
-
declare function createListDirTool(options?: AgentFilesystemToolsOptions):
|
|
420
|
-
declare function createGrepFilesTool(options?: AgentFilesystemToolsOptions):
|
|
421
|
-
declare function
|
|
422
|
-
declare function
|
|
423
|
-
declare function
|
|
424
|
-
declare function
|
|
425
|
-
declare function
|
|
426
|
-
declare function
|
|
457
|
+
declare function createCodexApplyPatchTool(options?: AgentFilesystemToolsOptions): LlmCustomTool<string>;
|
|
458
|
+
declare function createCodexReadFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexReadFileInputSchema, string>;
|
|
459
|
+
declare function createListDirTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexListDirInputSchema, string>;
|
|
460
|
+
declare function createGrepFilesTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof codexGrepFilesInputSchema, string>;
|
|
461
|
+
declare function createGeminiReadFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReadFileInputSchema, string>;
|
|
462
|
+
declare function createReadFilesTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReadFilesInputSchema, string>;
|
|
463
|
+
declare function createWriteFileTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiWriteFileInputSchema, string>;
|
|
464
|
+
declare function createReplaceTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiReplaceInputSchema, string>;
|
|
465
|
+
declare function createListDirectoryTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiListDirectoryInputSchema, string>;
|
|
466
|
+
declare function createGrepSearchTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiGrepSearchInputSchema, string>;
|
|
467
|
+
declare function createRgSearchTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiRgSearchInputSchema, string>;
|
|
468
|
+
declare function createGlobTool(options?: AgentFilesystemToolsOptions): LlmFunctionTool<typeof geminiGlobInputSchema, string>;
|
|
427
469
|
|
|
428
470
|
type AgentFilesystemToolConfig = {
|
|
429
471
|
readonly enabled?: boolean;
|
|
@@ -438,6 +480,9 @@ type RunAgentLoopRequest = Omit<LlmToolLoopRequest, "tools"> & {
|
|
|
438
480
|
};
|
|
439
481
|
declare function runAgentLoop(request: RunAgentLoopRequest): Promise<LlmToolLoopResult>;
|
|
440
482
|
|
|
483
|
+
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.";
|
|
484
|
+
declare const CODEX_APPLY_PATCH_LARK_GRAMMAR: string;
|
|
485
|
+
declare const CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION: string;
|
|
441
486
|
type ApplyPatchAccessContext = {
|
|
442
487
|
readonly cwd: string;
|
|
443
488
|
readonly kind: "add" | "delete" | "update" | "move";
|
|
@@ -468,7 +513,7 @@ declare const applyPatchToolInputSchema: z.ZodObject<{
|
|
|
468
513
|
input: z.ZodString;
|
|
469
514
|
}, z.core.$strip>;
|
|
470
515
|
type ApplyPatchToolInput = z.output<typeof applyPatchToolInputSchema>;
|
|
471
|
-
declare function createApplyPatchTool(options?: CreateApplyPatchToolOptions):
|
|
516
|
+
declare function createApplyPatchTool(options?: CreateApplyPatchToolOptions): LlmFunctionTool<typeof applyPatchToolInputSchema, ApplyPatchResult>;
|
|
472
517
|
declare function applyPatch(request: ApplyPatchRequest): Promise<ApplyPatchResult>;
|
|
473
518
|
|
|
474
519
|
type ChatGptAuthProfile = {
|
|
@@ -485,10 +530,13 @@ declare function exchangeChatGptOauthCode({ code, verifier, redirectUri, }: {
|
|
|
485
530
|
verifier: string;
|
|
486
531
|
redirectUri?: string;
|
|
487
532
|
}): Promise<ChatGptAuthProfile>;
|
|
488
|
-
declare function refreshChatGptOauthToken(refreshToken: string
|
|
533
|
+
declare function refreshChatGptOauthToken(refreshToken: string, fallback?: {
|
|
534
|
+
accountId?: string;
|
|
535
|
+
idToken?: string;
|
|
536
|
+
}): Promise<ChatGptAuthProfile>;
|
|
489
537
|
declare function getChatGptAuthProfile(): Promise<ChatGptAuthProfile>;
|
|
490
538
|
|
|
491
|
-
declare const GEMINI_MODEL_IDS: readonly ["gemini-3-pro-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
539
|
+
declare const GEMINI_MODEL_IDS: readonly ["gemini-3-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-flash-latest", "gemini-flash-lite-latest"];
|
|
492
540
|
type GeminiModelId = (typeof GEMINI_MODEL_IDS)[number];
|
|
493
541
|
declare function isGeminiModelId(value: string): value is GeminiModelId;
|
|
494
542
|
type GeminiConfiguration = {
|
|
@@ -497,4 +545,12 @@ type GeminiConfiguration = {
|
|
|
497
545
|
};
|
|
498
546
|
declare function configureGemini(options?: GeminiConfiguration): void;
|
|
499
547
|
|
|
500
|
-
|
|
548
|
+
declare const FIREWORKS_MODEL_IDS: readonly ["kimi-k2.5", "glm-5", "minimax-m2.1"];
|
|
549
|
+
type FireworksModelId = (typeof FIREWORKS_MODEL_IDS)[number];
|
|
550
|
+
declare const FIREWORKS_DEFAULT_KIMI_MODEL: FireworksModelId;
|
|
551
|
+
declare const FIREWORKS_DEFAULT_GLM_MODEL: FireworksModelId;
|
|
552
|
+
declare const FIREWORKS_DEFAULT_MINIMAX_MODEL: FireworksModelId;
|
|
553
|
+
declare function isFireworksModelId(value: string): value is FireworksModelId;
|
|
554
|
+
declare function resolveFireworksModelId(model: string): string | undefined;
|
|
555
|
+
|
|
556
|
+
export { type AgentDirectoryEntry, type AgentFilesystem, type AgentFilesystemToolAccessContext, type AgentFilesystemToolAccessHook, type AgentFilesystemToolAction, type AgentFilesystemToolConfig, type AgentFilesystemToolName, type AgentFilesystemToolProfile, type AgentFilesystemToolSelection, type AgentFilesystemToolsOptions, type AgentPathInfo, type AgentPathKind, type ApplyPatchAccessContext, type ApplyPatchAccessHook, type ApplyPatchRequest, type ApplyPatchResult, type ApplyPatchToolInput, CODEX_APPLY_PATCH_FREEFORM_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_JSON_TOOL_DESCRIPTION, CODEX_APPLY_PATCH_LARK_GRAMMAR, type ChatGptAuthProfile, type CodexApplyPatchToolInput, type CodexGrepFilesToolInput, type CodexListDirToolInput, type CodexReadFileToolInput, type CreateApplyPatchToolOptions, FIREWORKS_DEFAULT_GLM_MODEL, FIREWORKS_DEFAULT_KIMI_MODEL, FIREWORKS_DEFAULT_MINIMAX_MODEL, FIREWORKS_MODEL_IDS, type FireworksModelId, type GeminiGlobToolInput, type GeminiGrepSearchToolInput, type GeminiListDirectoryToolInput, type GeminiModelId, type GeminiReadFileToolInput, type GeminiReadFilesToolInput, type GeminiReplaceToolInput, type GeminiRgSearchToolInput, type GeminiWriteFileToolInput, InMemoryAgentFilesystem, type JsonSchema, type LlmBaseRequest, type LlmBlockedEvent, type LlmContent, type LlmContentPart, type LlmCustomTool, type LlmCustomToolInputFormat, type LlmExecutableTool, type LlmFunctionTool, type LlmImageData, type LlmImageSize, type LlmInput, type LlmInputMessage, LlmJsonCallError, type LlmJsonRequest, type LlmJsonStream, type LlmJsonStreamEvent, type LlmJsonStreamRequest, type LlmModelEvent, type LlmProvider, type LlmStreamEvent, type LlmTextDeltaEvent, type LlmTextRequest, type LlmTextResult, type LlmTextStream, type LlmToolCallContext, type LlmToolCallResult, type LlmToolConfig, type LlmToolLoopRequest, type LlmToolLoopResult, type LlmToolLoopStep, type LlmToolSet, type LlmUsageEvent, type LlmUsageTokens, type LlmWebSearchMode, type RunAgentLoopRequest, appendMarkdownSourcesSection, applyPatch, configureGemini, convertGooglePartsToLlmParts, createApplyPatchTool, createCodexApplyPatchTool, createCodexFilesystemToolSet, createCodexReadFileTool, createFilesystemToolSetForModel, createGeminiFilesystemToolSet, createGeminiReadFileTool, createGlobTool, createGrepFilesTool, createGrepSearchTool, createInMemoryAgentFilesystem, createListDirTool, createListDirectoryTool, createModelAgnosticFilesystemToolSet, createNodeAgentFilesystem, createReadFilesTool, createReplaceTool, createRgSearchTool, createWriteFileTool, customTool, encodeChatGptAuthJson, encodeChatGptAuthJsonB64, estimateCallCostUsd, exchangeChatGptOauthCode, generateImageInBatches, generateImages, generateJson, generateText, getChatGptAuthProfile, getCurrentToolCallContext, isFireworksModelId, isGeminiModelId, loadEnvFromFile, loadLocalEnv, parseJsonFromLlmText, refreshChatGptOauthToken, resolveFilesystemToolProfile, resolveFireworksModelId, runAgentLoop, runToolLoop, sanitisePartForLogging, streamJson, streamText, stripCodexCitationMarkers, toGeminiJsonSchema, tool };
|