@roll-agent/core 0.11.0 → 0.13.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/bin/roll.js +18 -1
- package/dist/cli/chat/ink/app.d.ts +15 -0
- package/dist/cli/chat/ink/app.js +1 -0
- package/dist/cli/chat/ink/commands.d.ts +6 -0
- package/dist/cli/chat/ink/commands.js +1 -0
- package/dist/cli/chat/ink/confirm-select.d.ts +6 -0
- package/dist/cli/chat/ink/confirm-select.js +1 -0
- package/dist/cli/chat/ink/history-from-messages.d.ts +3 -0
- package/dist/cli/chat/ink/history-from-messages.js +1 -0
- package/dist/cli/chat/ink/history-item.d.ts +5 -0
- package/dist/cli/chat/ink/history-item.js +1 -0
- package/dist/cli/chat/ink/live-region.d.ts +5 -0
- package/dist/cli/chat/ink/live-region.js +1 -0
- package/dist/cli/chat/ink/markdown.d.ts +5 -0
- package/dist/cli/chat/ink/markdown.js +1 -0
- package/dist/cli/chat/ink/run-ink-repl.d.ts +13 -0
- package/dist/cli/chat/ink/run-ink-repl.js +1 -0
- package/dist/cli/chat/ink/slash-popup.d.ts +7 -0
- package/dist/cli/chat/ink/slash-popup.js +1 -0
- package/dist/cli/chat/ink/spinner.d.ts +2 -0
- package/dist/cli/chat/ink/spinner.js +1 -0
- package/dist/cli/chat/ink/state.d.ts +103 -0
- package/dist/cli/chat/ink/state.js +1 -0
- package/dist/cli/chat/ink/status-line.d.ts +16 -0
- package/dist/cli/chat/ink/status-line.js +1 -0
- package/dist/cli/chat/ink/text-prompt.d.ts +12 -0
- package/dist/cli/chat/ink/text-prompt.js +1 -0
- package/dist/cli/chat/ink/thinking-text.d.ts +10 -0
- package/dist/cli/chat/ink/thinking-text.js +1 -0
- package/dist/cli/chat/ink/thinking.d.ts +3 -0
- package/dist/cli/chat/ink/thinking.js +1 -0
- package/dist/cli/chat/ink/tool-label.d.ts +4 -0
- package/dist/cli/chat/ink/tool-label.js +1 -0
- package/dist/cli/chat/ink/use-session.d.ts +20 -0
- package/dist/cli/chat/ink/use-session.js +1 -0
- package/dist/cli/chat/title.d.ts +1 -0
- package/dist/cli/chat/title.js +1 -0
- package/dist/cli/commands/browser-stop.d.ts +4 -4
- package/dist/cli/commands/chat.d.ts +9 -0
- package/dist/cli/commands/chat.js +1 -1
- package/dist/cli/commands/config-guidance.d.ts +2 -2
- package/dist/cli/utils/chat-renderer.d.ts +7 -1
- package/dist/cli/utils/chat-renderer.js +1 -1
- package/dist/cli/utils/output.d.ts +1 -0
- package/dist/cli/utils/output.js +1 -1
- package/dist/cli/utils/package-manager.d.ts +5 -0
- package/dist/cli/utils/package-manager.js +1 -1
- package/dist/cli/utils/token-format.d.ts +23 -0
- package/dist/cli/utils/token-format.js +1 -0
- package/dist/cli/utils/tool-format.d.ts +1 -0
- package/dist/cli/utils/tool-format.js +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/key-codec.js +1 -1
- package/dist/config/schema.d.ts +164 -40
- package/dist/config/schema.js +1 -1
- package/dist/llm/engine.d.ts +1 -1
- package/dist/llm/providers.d.ts +9 -6
- package/dist/llm/providers.js +1 -1
- package/dist/mcp/client-manager.d.ts +4 -2
- package/dist/mcp/client-manager.js +1 -1
- package/dist/mcp/sampling-handler.d.ts +2 -2
- package/dist/router/llm-router.d.ts +2 -2
- package/dist/tool-runtime/argument-extractor.d.ts +2 -2
- package/dist/types/chat.d.ts +12 -0
- package/package.json +15 -10
package/dist/config/schema.d.ts
CHANGED
|
@@ -67,45 +67,107 @@ export declare const runtimeApprovalConfigSchema: z.ZodObject<{
|
|
|
67
67
|
default: z.ZodDefault<z.ZodEnum<["guarded", "auto", "deny"]>>;
|
|
68
68
|
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<["auto", "confirm", "deny"]>>>;
|
|
69
69
|
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
default: "
|
|
70
|
+
default: "auto" | "guarded" | "deny";
|
|
71
71
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
72
72
|
}, {
|
|
73
|
-
default?: "
|
|
73
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
74
74
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
75
75
|
}>;
|
|
76
|
+
export declare const runtimeCompactionConfigSchema: z.ZodObject<{
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
strategy: z.ZodDefault<z.ZodEnum<["summarize", "truncate"]>>;
|
|
79
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
80
|
+
keepRecentTurns: z.ZodDefault<z.ZodNumber>;
|
|
81
|
+
keepRecentTokens: z.ZodDefault<z.ZodNumber>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
strategy: "summarize" | "truncate";
|
|
85
|
+
threshold: number;
|
|
86
|
+
keepRecentTurns: number;
|
|
87
|
+
keepRecentTokens: number;
|
|
88
|
+
}, {
|
|
89
|
+
enabled?: boolean | undefined;
|
|
90
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
91
|
+
threshold?: number | undefined;
|
|
92
|
+
keepRecentTurns?: number | undefined;
|
|
93
|
+
keepRecentTokens?: number | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const runtimeThinkingLevels: readonly ["off", "low", "medium", "high"];
|
|
76
96
|
export declare const runtimeConfigSchema: z.ZodObject<{
|
|
77
97
|
provider: z.ZodOptional<z.ZodString>;
|
|
78
98
|
model: z.ZodOptional<z.ZodString>;
|
|
79
99
|
maxSteps: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
turnTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
80
101
|
threadsDir: z.ZodDefault<z.ZodString>;
|
|
102
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
thinkingLevel: z.ZodDefault<z.ZodEnum<["off", "low", "medium", "high"]>>;
|
|
81
104
|
approval: z.ZodDefault<z.ZodObject<{
|
|
82
105
|
default: z.ZodDefault<z.ZodEnum<["guarded", "auto", "deny"]>>;
|
|
83
106
|
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<["auto", "confirm", "deny"]>>>;
|
|
84
107
|
}, "strip", z.ZodTypeAny, {
|
|
85
|
-
default: "
|
|
108
|
+
default: "auto" | "guarded" | "deny";
|
|
86
109
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
87
110
|
}, {
|
|
88
|
-
default?: "
|
|
111
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
89
112
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
90
113
|
}>>;
|
|
114
|
+
compaction: z.ZodDefault<z.ZodObject<{
|
|
115
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
+
strategy: z.ZodDefault<z.ZodEnum<["summarize", "truncate"]>>;
|
|
117
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
118
|
+
keepRecentTurns: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
keepRecentTokens: z.ZodDefault<z.ZodNumber>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
strategy: "summarize" | "truncate";
|
|
123
|
+
threshold: number;
|
|
124
|
+
keepRecentTurns: number;
|
|
125
|
+
keepRecentTokens: number;
|
|
126
|
+
}, {
|
|
127
|
+
enabled?: boolean | undefined;
|
|
128
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
129
|
+
threshold?: number | undefined;
|
|
130
|
+
keepRecentTurns?: number | undefined;
|
|
131
|
+
keepRecentTokens?: number | undefined;
|
|
132
|
+
}>>;
|
|
91
133
|
}, "strip", z.ZodTypeAny, {
|
|
92
134
|
maxSteps: number;
|
|
135
|
+
turnTimeoutMs: number;
|
|
93
136
|
threadsDir: string;
|
|
137
|
+
thinkingLevel: "off" | "low" | "medium" | "high";
|
|
94
138
|
approval: {
|
|
95
|
-
default: "
|
|
139
|
+
default: "auto" | "guarded" | "deny";
|
|
96
140
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
97
141
|
};
|
|
98
|
-
|
|
142
|
+
compaction: {
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
strategy: "summarize" | "truncate";
|
|
145
|
+
threshold: number;
|
|
146
|
+
keepRecentTurns: number;
|
|
147
|
+
keepRecentTokens: number;
|
|
148
|
+
};
|
|
99
149
|
model?: string | undefined;
|
|
100
|
-
}, {
|
|
101
150
|
provider?: string | undefined;
|
|
151
|
+
contextWindow?: number | undefined;
|
|
152
|
+
}, {
|
|
102
153
|
model?: string | undefined;
|
|
154
|
+
provider?: string | undefined;
|
|
103
155
|
maxSteps?: number | undefined;
|
|
156
|
+
turnTimeoutMs?: number | undefined;
|
|
104
157
|
threadsDir?: string | undefined;
|
|
158
|
+
contextWindow?: number | undefined;
|
|
159
|
+
thinkingLevel?: "off" | "low" | "medium" | "high" | undefined;
|
|
105
160
|
approval?: {
|
|
106
|
-
default?: "
|
|
161
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
107
162
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
108
163
|
} | undefined;
|
|
164
|
+
compaction?: {
|
|
165
|
+
enabled?: boolean | undefined;
|
|
166
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
167
|
+
threshold?: number | undefined;
|
|
168
|
+
keepRecentTurns?: number | undefined;
|
|
169
|
+
keepRecentTokens?: number | undefined;
|
|
170
|
+
} | undefined;
|
|
109
171
|
}>;
|
|
110
172
|
export declare const agentsConfigSchema: z.ZodObject<{
|
|
111
173
|
dataDir: z.ZodString;
|
|
@@ -181,12 +243,12 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
181
243
|
channel: "chrome" | "chromium" | "msedge";
|
|
182
244
|
userDataDir: string;
|
|
183
245
|
platform?: "zhipin" | "yupao" | undefined;
|
|
246
|
+
args?: string[] | undefined;
|
|
184
247
|
headless?: boolean | undefined;
|
|
185
248
|
cdpUrl?: string | undefined;
|
|
186
249
|
cdpPort?: number | undefined;
|
|
187
250
|
executablePath?: string | undefined;
|
|
188
251
|
sessionsDir?: string | undefined;
|
|
189
|
-
args?: string[] | undefined;
|
|
190
252
|
profileName?: string | undefined;
|
|
191
253
|
profileColor?: string | undefined;
|
|
192
254
|
windowBounds?: {
|
|
@@ -200,6 +262,7 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
200
262
|
userDataDir: string;
|
|
201
263
|
platform?: "zhipin" | "yupao" | undefined;
|
|
202
264
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
265
|
+
args?: string[] | undefined;
|
|
203
266
|
headless?: boolean | undefined;
|
|
204
267
|
cdpUrl?: string | undefined;
|
|
205
268
|
cdpHost?: string | undefined;
|
|
@@ -207,7 +270,6 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
207
270
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
208
271
|
executablePath?: string | undefined;
|
|
209
272
|
sessionsDir?: string | undefined;
|
|
210
|
-
args?: string[] | undefined;
|
|
211
273
|
profileName?: string | undefined;
|
|
212
274
|
profileColor?: string | undefined;
|
|
213
275
|
windowBounds?: {
|
|
@@ -223,12 +285,12 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
223
285
|
channel: "chrome" | "chromium" | "msedge";
|
|
224
286
|
userDataDir: string;
|
|
225
287
|
platform?: "zhipin" | "yupao" | undefined;
|
|
288
|
+
args?: string[] | undefined;
|
|
226
289
|
headless?: boolean | undefined;
|
|
227
290
|
cdpUrl?: string | undefined;
|
|
228
291
|
cdpPort?: number | undefined;
|
|
229
292
|
executablePath?: string | undefined;
|
|
230
293
|
sessionsDir?: string | undefined;
|
|
231
|
-
args?: string[] | undefined;
|
|
232
294
|
profileName?: string | undefined;
|
|
233
295
|
profileColor?: string | undefined;
|
|
234
296
|
windowBounds?: {
|
|
@@ -242,6 +304,7 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
242
304
|
userDataDir: string;
|
|
243
305
|
platform?: "zhipin" | "yupao" | undefined;
|
|
244
306
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
307
|
+
args?: string[] | undefined;
|
|
245
308
|
headless?: boolean | undefined;
|
|
246
309
|
cdpUrl?: string | undefined;
|
|
247
310
|
cdpHost?: string | undefined;
|
|
@@ -249,7 +312,6 @@ export declare const browserInstanceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
249
312
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
250
313
|
executablePath?: string | undefined;
|
|
251
314
|
sessionsDir?: string | undefined;
|
|
252
|
-
args?: string[] | undefined;
|
|
253
315
|
profileName?: string | undefined;
|
|
254
316
|
profileColor?: string | undefined;
|
|
255
317
|
windowBounds?: {
|
|
@@ -299,12 +361,12 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
299
361
|
channel: "chrome" | "chromium" | "msedge";
|
|
300
362
|
userDataDir: string;
|
|
301
363
|
platform?: "zhipin" | "yupao" | undefined;
|
|
364
|
+
args?: string[] | undefined;
|
|
302
365
|
headless?: boolean | undefined;
|
|
303
366
|
cdpUrl?: string | undefined;
|
|
304
367
|
cdpPort?: number | undefined;
|
|
305
368
|
executablePath?: string | undefined;
|
|
306
369
|
sessionsDir?: string | undefined;
|
|
307
|
-
args?: string[] | undefined;
|
|
308
370
|
profileName?: string | undefined;
|
|
309
371
|
profileColor?: string | undefined;
|
|
310
372
|
windowBounds?: {
|
|
@@ -318,6 +380,7 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
318
380
|
userDataDir: string;
|
|
319
381
|
platform?: "zhipin" | "yupao" | undefined;
|
|
320
382
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
383
|
+
args?: string[] | undefined;
|
|
321
384
|
headless?: boolean | undefined;
|
|
322
385
|
cdpUrl?: string | undefined;
|
|
323
386
|
cdpHost?: string | undefined;
|
|
@@ -325,7 +388,6 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
325
388
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
326
389
|
executablePath?: string | undefined;
|
|
327
390
|
sessionsDir?: string | undefined;
|
|
328
|
-
args?: string[] | undefined;
|
|
329
391
|
profileName?: string | undefined;
|
|
330
392
|
profileColor?: string | undefined;
|
|
331
393
|
windowBounds?: {
|
|
@@ -341,12 +403,12 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
341
403
|
channel: "chrome" | "chromium" | "msedge";
|
|
342
404
|
userDataDir: string;
|
|
343
405
|
platform?: "zhipin" | "yupao" | undefined;
|
|
406
|
+
args?: string[] | undefined;
|
|
344
407
|
headless?: boolean | undefined;
|
|
345
408
|
cdpUrl?: string | undefined;
|
|
346
409
|
cdpPort?: number | undefined;
|
|
347
410
|
executablePath?: string | undefined;
|
|
348
411
|
sessionsDir?: string | undefined;
|
|
349
|
-
args?: string[] | undefined;
|
|
350
412
|
profileName?: string | undefined;
|
|
351
413
|
profileColor?: string | undefined;
|
|
352
414
|
windowBounds?: {
|
|
@@ -360,6 +422,7 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
360
422
|
userDataDir: string;
|
|
361
423
|
platform?: "zhipin" | "yupao" | undefined;
|
|
362
424
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
425
|
+
args?: string[] | undefined;
|
|
363
426
|
headless?: boolean | undefined;
|
|
364
427
|
cdpUrl?: string | undefined;
|
|
365
428
|
cdpHost?: string | undefined;
|
|
@@ -367,7 +430,6 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
367
430
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
368
431
|
executablePath?: string | undefined;
|
|
369
432
|
sessionsDir?: string | undefined;
|
|
370
|
-
args?: string[] | undefined;
|
|
371
433
|
profileName?: string | undefined;
|
|
372
434
|
profileColor?: string | undefined;
|
|
373
435
|
windowBounds?: {
|
|
@@ -385,12 +447,12 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
385
447
|
channel: "chrome" | "chromium" | "msedge";
|
|
386
448
|
userDataDir: string;
|
|
387
449
|
platform?: "zhipin" | "yupao" | undefined;
|
|
450
|
+
args?: string[] | undefined;
|
|
388
451
|
headless?: boolean | undefined;
|
|
389
452
|
cdpUrl?: string | undefined;
|
|
390
453
|
cdpPort?: number | undefined;
|
|
391
454
|
executablePath?: string | undefined;
|
|
392
455
|
sessionsDir?: string | undefined;
|
|
393
|
-
args?: string[] | undefined;
|
|
394
456
|
profileName?: string | undefined;
|
|
395
457
|
profileColor?: string | undefined;
|
|
396
458
|
windowBounds?: {
|
|
@@ -408,6 +470,7 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
408
470
|
userDataDir: string;
|
|
409
471
|
platform?: "zhipin" | "yupao" | undefined;
|
|
410
472
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
473
|
+
args?: string[] | undefined;
|
|
411
474
|
headless?: boolean | undefined;
|
|
412
475
|
cdpUrl?: string | undefined;
|
|
413
476
|
cdpHost?: string | undefined;
|
|
@@ -415,7 +478,6 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
415
478
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
416
479
|
executablePath?: string | undefined;
|
|
417
480
|
sessionsDir?: string | undefined;
|
|
418
|
-
args?: string[] | undefined;
|
|
419
481
|
profileName?: string | undefined;
|
|
420
482
|
profileColor?: string | undefined;
|
|
421
483
|
windowBounds?: {
|
|
@@ -433,12 +495,12 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
433
495
|
channel: "chrome" | "chromium" | "msedge";
|
|
434
496
|
userDataDir: string;
|
|
435
497
|
platform?: "zhipin" | "yupao" | undefined;
|
|
498
|
+
args?: string[] | undefined;
|
|
436
499
|
headless?: boolean | undefined;
|
|
437
500
|
cdpUrl?: string | undefined;
|
|
438
501
|
cdpPort?: number | undefined;
|
|
439
502
|
executablePath?: string | undefined;
|
|
440
503
|
sessionsDir?: string | undefined;
|
|
441
|
-
args?: string[] | undefined;
|
|
442
504
|
profileName?: string | undefined;
|
|
443
505
|
profileColor?: string | undefined;
|
|
444
506
|
windowBounds?: {
|
|
@@ -456,6 +518,7 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
456
518
|
userDataDir: string;
|
|
457
519
|
platform?: "zhipin" | "yupao" | undefined;
|
|
458
520
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
521
|
+
args?: string[] | undefined;
|
|
459
522
|
headless?: boolean | undefined;
|
|
460
523
|
cdpUrl?: string | undefined;
|
|
461
524
|
cdpHost?: string | undefined;
|
|
@@ -463,7 +526,6 @@ export declare const browserConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
463
526
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
464
527
|
executablePath?: string | undefined;
|
|
465
528
|
sessionsDir?: string | undefined;
|
|
466
|
-
args?: string[] | undefined;
|
|
467
529
|
profileName?: string | undefined;
|
|
468
530
|
profileColor?: string | undefined;
|
|
469
531
|
windowBounds?: {
|
|
@@ -518,35 +580,77 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
518
580
|
provider: z.ZodOptional<z.ZodString>;
|
|
519
581
|
model: z.ZodOptional<z.ZodString>;
|
|
520
582
|
maxSteps: z.ZodDefault<z.ZodNumber>;
|
|
583
|
+
turnTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
521
584
|
threadsDir: z.ZodDefault<z.ZodString>;
|
|
585
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
586
|
+
thinkingLevel: z.ZodDefault<z.ZodEnum<["off", "low", "medium", "high"]>>;
|
|
522
587
|
approval: z.ZodDefault<z.ZodObject<{
|
|
523
588
|
default: z.ZodDefault<z.ZodEnum<["guarded", "auto", "deny"]>>;
|
|
524
589
|
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<["auto", "confirm", "deny"]>>>;
|
|
525
590
|
}, "strip", z.ZodTypeAny, {
|
|
526
|
-
default: "
|
|
591
|
+
default: "auto" | "guarded" | "deny";
|
|
527
592
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
528
593
|
}, {
|
|
529
|
-
default?: "
|
|
594
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
530
595
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
531
596
|
}>>;
|
|
597
|
+
compaction: z.ZodDefault<z.ZodObject<{
|
|
598
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
599
|
+
strategy: z.ZodDefault<z.ZodEnum<["summarize", "truncate"]>>;
|
|
600
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
601
|
+
keepRecentTurns: z.ZodDefault<z.ZodNumber>;
|
|
602
|
+
keepRecentTokens: z.ZodDefault<z.ZodNumber>;
|
|
603
|
+
}, "strip", z.ZodTypeAny, {
|
|
604
|
+
enabled: boolean;
|
|
605
|
+
strategy: "summarize" | "truncate";
|
|
606
|
+
threshold: number;
|
|
607
|
+
keepRecentTurns: number;
|
|
608
|
+
keepRecentTokens: number;
|
|
609
|
+
}, {
|
|
610
|
+
enabled?: boolean | undefined;
|
|
611
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
612
|
+
threshold?: number | undefined;
|
|
613
|
+
keepRecentTurns?: number | undefined;
|
|
614
|
+
keepRecentTokens?: number | undefined;
|
|
615
|
+
}>>;
|
|
532
616
|
}, "strip", z.ZodTypeAny, {
|
|
533
617
|
maxSteps: number;
|
|
618
|
+
turnTimeoutMs: number;
|
|
534
619
|
threadsDir: string;
|
|
620
|
+
thinkingLevel: "off" | "low" | "medium" | "high";
|
|
535
621
|
approval: {
|
|
536
|
-
default: "
|
|
622
|
+
default: "auto" | "guarded" | "deny";
|
|
537
623
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
538
624
|
};
|
|
539
|
-
|
|
625
|
+
compaction: {
|
|
626
|
+
enabled: boolean;
|
|
627
|
+
strategy: "summarize" | "truncate";
|
|
628
|
+
threshold: number;
|
|
629
|
+
keepRecentTurns: number;
|
|
630
|
+
keepRecentTokens: number;
|
|
631
|
+
};
|
|
540
632
|
model?: string | undefined;
|
|
541
|
-
}, {
|
|
542
633
|
provider?: string | undefined;
|
|
634
|
+
contextWindow?: number | undefined;
|
|
635
|
+
}, {
|
|
543
636
|
model?: string | undefined;
|
|
637
|
+
provider?: string | undefined;
|
|
544
638
|
maxSteps?: number | undefined;
|
|
639
|
+
turnTimeoutMs?: number | undefined;
|
|
545
640
|
threadsDir?: string | undefined;
|
|
641
|
+
contextWindow?: number | undefined;
|
|
642
|
+
thinkingLevel?: "off" | "low" | "medium" | "high" | undefined;
|
|
546
643
|
approval?: {
|
|
547
|
-
default?: "
|
|
644
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
548
645
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
549
646
|
} | undefined;
|
|
647
|
+
compaction?: {
|
|
648
|
+
enabled?: boolean | undefined;
|
|
649
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
650
|
+
threshold?: number | undefined;
|
|
651
|
+
keepRecentTurns?: number | undefined;
|
|
652
|
+
keepRecentTokens?: number | undefined;
|
|
653
|
+
} | undefined;
|
|
550
654
|
}>>;
|
|
551
655
|
agents: z.ZodObject<{
|
|
552
656
|
dataDir: z.ZodString;
|
|
@@ -618,12 +722,12 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
618
722
|
channel: "chrome" | "chromium" | "msedge";
|
|
619
723
|
userDataDir: string;
|
|
620
724
|
platform?: "zhipin" | "yupao" | undefined;
|
|
725
|
+
args?: string[] | undefined;
|
|
621
726
|
headless?: boolean | undefined;
|
|
622
727
|
cdpUrl?: string | undefined;
|
|
623
728
|
cdpPort?: number | undefined;
|
|
624
729
|
executablePath?: string | undefined;
|
|
625
730
|
sessionsDir?: string | undefined;
|
|
626
|
-
args?: string[] | undefined;
|
|
627
731
|
profileName?: string | undefined;
|
|
628
732
|
profileColor?: string | undefined;
|
|
629
733
|
windowBounds?: {
|
|
@@ -637,6 +741,7 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
637
741
|
userDataDir: string;
|
|
638
742
|
platform?: "zhipin" | "yupao" | undefined;
|
|
639
743
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
744
|
+
args?: string[] | undefined;
|
|
640
745
|
headless?: boolean | undefined;
|
|
641
746
|
cdpUrl?: string | undefined;
|
|
642
747
|
cdpHost?: string | undefined;
|
|
@@ -644,7 +749,6 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
644
749
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
645
750
|
executablePath?: string | undefined;
|
|
646
751
|
sessionsDir?: string | undefined;
|
|
647
|
-
args?: string[] | undefined;
|
|
648
752
|
profileName?: string | undefined;
|
|
649
753
|
profileColor?: string | undefined;
|
|
650
754
|
windowBounds?: {
|
|
@@ -660,12 +764,12 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
660
764
|
channel: "chrome" | "chromium" | "msedge";
|
|
661
765
|
userDataDir: string;
|
|
662
766
|
platform?: "zhipin" | "yupao" | undefined;
|
|
767
|
+
args?: string[] | undefined;
|
|
663
768
|
headless?: boolean | undefined;
|
|
664
769
|
cdpUrl?: string | undefined;
|
|
665
770
|
cdpPort?: number | undefined;
|
|
666
771
|
executablePath?: string | undefined;
|
|
667
772
|
sessionsDir?: string | undefined;
|
|
668
|
-
args?: string[] | undefined;
|
|
669
773
|
profileName?: string | undefined;
|
|
670
774
|
profileColor?: string | undefined;
|
|
671
775
|
windowBounds?: {
|
|
@@ -679,6 +783,7 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
679
783
|
userDataDir: string;
|
|
680
784
|
platform?: "zhipin" | "yupao" | undefined;
|
|
681
785
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
786
|
+
args?: string[] | undefined;
|
|
682
787
|
headless?: boolean | undefined;
|
|
683
788
|
cdpUrl?: string | undefined;
|
|
684
789
|
cdpHost?: string | undefined;
|
|
@@ -686,7 +791,6 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
686
791
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
687
792
|
executablePath?: string | undefined;
|
|
688
793
|
sessionsDir?: string | undefined;
|
|
689
|
-
args?: string[] | undefined;
|
|
690
794
|
profileName?: string | undefined;
|
|
691
795
|
profileColor?: string | undefined;
|
|
692
796
|
windowBounds?: {
|
|
@@ -704,12 +808,12 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
704
808
|
channel: "chrome" | "chromium" | "msedge";
|
|
705
809
|
userDataDir: string;
|
|
706
810
|
platform?: "zhipin" | "yupao" | undefined;
|
|
811
|
+
args?: string[] | undefined;
|
|
707
812
|
headless?: boolean | undefined;
|
|
708
813
|
cdpUrl?: string | undefined;
|
|
709
814
|
cdpPort?: number | undefined;
|
|
710
815
|
executablePath?: string | undefined;
|
|
711
816
|
sessionsDir?: string | undefined;
|
|
712
|
-
args?: string[] | undefined;
|
|
713
817
|
profileName?: string | undefined;
|
|
714
818
|
profileColor?: string | undefined;
|
|
715
819
|
windowBounds?: {
|
|
@@ -727,6 +831,7 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
727
831
|
userDataDir: string;
|
|
728
832
|
platform?: "zhipin" | "yupao" | undefined;
|
|
729
833
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
834
|
+
args?: string[] | undefined;
|
|
730
835
|
headless?: boolean | undefined;
|
|
731
836
|
cdpUrl?: string | undefined;
|
|
732
837
|
cdpHost?: string | undefined;
|
|
@@ -734,7 +839,6 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
734
839
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
735
840
|
executablePath?: string | undefined;
|
|
736
841
|
sessionsDir?: string | undefined;
|
|
737
|
-
args?: string[] | undefined;
|
|
738
842
|
profileName?: string | undefined;
|
|
739
843
|
profileColor?: string | undefined;
|
|
740
844
|
windowBounds?: {
|
|
@@ -752,12 +856,12 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
752
856
|
channel: "chrome" | "chromium" | "msedge";
|
|
753
857
|
userDataDir: string;
|
|
754
858
|
platform?: "zhipin" | "yupao" | undefined;
|
|
859
|
+
args?: string[] | undefined;
|
|
755
860
|
headless?: boolean | undefined;
|
|
756
861
|
cdpUrl?: string | undefined;
|
|
757
862
|
cdpPort?: number | undefined;
|
|
758
863
|
executablePath?: string | undefined;
|
|
759
864
|
sessionsDir?: string | undefined;
|
|
760
|
-
args?: string[] | undefined;
|
|
761
865
|
profileName?: string | undefined;
|
|
762
866
|
profileColor?: string | undefined;
|
|
763
867
|
windowBounds?: {
|
|
@@ -775,6 +879,7 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
775
879
|
userDataDir: string;
|
|
776
880
|
platform?: "zhipin" | "yupao" | undefined;
|
|
777
881
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
882
|
+
args?: string[] | undefined;
|
|
778
883
|
headless?: boolean | undefined;
|
|
779
884
|
cdpUrl?: string | undefined;
|
|
780
885
|
cdpHost?: string | undefined;
|
|
@@ -782,7 +887,6 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
782
887
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
783
888
|
executablePath?: string | undefined;
|
|
784
889
|
sessionsDir?: string | undefined;
|
|
785
|
-
args?: string[] | undefined;
|
|
786
890
|
profileName?: string | undefined;
|
|
787
891
|
profileColor?: string | undefined;
|
|
788
892
|
windowBounds?: {
|
|
@@ -812,12 +916,12 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
812
916
|
channel: "chrome" | "chromium" | "msedge";
|
|
813
917
|
userDataDir: string;
|
|
814
918
|
platform?: "zhipin" | "yupao" | undefined;
|
|
919
|
+
args?: string[] | undefined;
|
|
815
920
|
headless?: boolean | undefined;
|
|
816
921
|
cdpUrl?: string | undefined;
|
|
817
922
|
cdpPort?: number | undefined;
|
|
818
923
|
executablePath?: string | undefined;
|
|
819
924
|
sessionsDir?: string | undefined;
|
|
820
|
-
args?: string[] | undefined;
|
|
821
925
|
profileName?: string | undefined;
|
|
822
926
|
profileColor?: string | undefined;
|
|
823
927
|
windowBounds?: {
|
|
@@ -840,13 +944,23 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
840
944
|
};
|
|
841
945
|
runtime: {
|
|
842
946
|
maxSteps: number;
|
|
947
|
+
turnTimeoutMs: number;
|
|
843
948
|
threadsDir: string;
|
|
949
|
+
thinkingLevel: "off" | "low" | "medium" | "high";
|
|
844
950
|
approval: {
|
|
845
|
-
default: "
|
|
951
|
+
default: "auto" | "guarded" | "deny";
|
|
846
952
|
overrides: Record<string, "auto" | "deny" | "confirm">;
|
|
847
953
|
};
|
|
848
|
-
|
|
954
|
+
compaction: {
|
|
955
|
+
enabled: boolean;
|
|
956
|
+
strategy: "summarize" | "truncate";
|
|
957
|
+
threshold: number;
|
|
958
|
+
keepRecentTurns: number;
|
|
959
|
+
keepRecentTokens: number;
|
|
960
|
+
};
|
|
849
961
|
model?: string | undefined;
|
|
962
|
+
provider?: string | undefined;
|
|
963
|
+
contextWindow?: number | undefined;
|
|
850
964
|
};
|
|
851
965
|
agents: {
|
|
852
966
|
dataDir: string;
|
|
@@ -881,6 +995,7 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
881
995
|
userDataDir: string;
|
|
882
996
|
platform?: "zhipin" | "yupao" | undefined;
|
|
883
997
|
mode?: "managed-cdp" | "remote-cdp" | "existing-session" | undefined;
|
|
998
|
+
args?: string[] | undefined;
|
|
884
999
|
headless?: boolean | undefined;
|
|
885
1000
|
cdpUrl?: string | undefined;
|
|
886
1001
|
cdpHost?: string | undefined;
|
|
@@ -888,7 +1003,6 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
888
1003
|
channel?: "chrome" | "chromium" | "msedge" | undefined;
|
|
889
1004
|
executablePath?: string | undefined;
|
|
890
1005
|
sessionsDir?: string | undefined;
|
|
891
|
-
args?: string[] | undefined;
|
|
892
1006
|
profileName?: string | undefined;
|
|
893
1007
|
profileColor?: string | undefined;
|
|
894
1008
|
windowBounds?: {
|
|
@@ -901,14 +1015,24 @@ export declare const rollConfigSchema: z.ZodObject<{
|
|
|
901
1015
|
}> | undefined;
|
|
902
1016
|
} | undefined;
|
|
903
1017
|
runtime?: {
|
|
904
|
-
provider?: string | undefined;
|
|
905
1018
|
model?: string | undefined;
|
|
1019
|
+
provider?: string | undefined;
|
|
906
1020
|
maxSteps?: number | undefined;
|
|
1021
|
+
turnTimeoutMs?: number | undefined;
|
|
907
1022
|
threadsDir?: string | undefined;
|
|
1023
|
+
contextWindow?: number | undefined;
|
|
1024
|
+
thinkingLevel?: "off" | "low" | "medium" | "high" | undefined;
|
|
908
1025
|
approval?: {
|
|
909
|
-
default?: "
|
|
1026
|
+
default?: "auto" | "guarded" | "deny" | undefined;
|
|
910
1027
|
overrides?: Record<string, "auto" | "deny" | "confirm"> | undefined;
|
|
911
1028
|
} | undefined;
|
|
1029
|
+
compaction?: {
|
|
1030
|
+
enabled?: boolean | undefined;
|
|
1031
|
+
strategy?: "summarize" | "truncate" | undefined;
|
|
1032
|
+
threshold?: number | undefined;
|
|
1033
|
+
keepRecentTurns?: number | undefined;
|
|
1034
|
+
keepRecentTokens?: number | undefined;
|
|
1035
|
+
} | undefined;
|
|
912
1036
|
} | undefined;
|
|
913
1037
|
}>;
|
|
914
1038
|
export type RollConfig = z.infer<typeof rollConfigSchema>;
|
package/dist/config/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const
|
|
1
|
+
import{z as e}from"zod";const t=["zhipin","yupao"],o=["managed-cdp","remote-cdp","existing-session"],n=["chrome","chromium","msedge"],i=["guarded","auto","deny"],r=["auto","confirm","deny"],a=["summarize","truncate"],s=e.string().trim().regex(/^#[\da-fA-F]{6}$/,"profileColor must be a hex RGB color such as #2563EB").transform(e=>e.toUpperCase());export const browserWindowBoundsSchema=e.object({x:e.number().int().optional(),y:e.number().int().optional(),width:e.number().int().positive().optional(),height:e.number().int().positive().optional()});export const providerConfigSchema=e.object({apiKey:e.string(),baseUrl:e.string().optional()});export const llmConfigSchema=e.object({defaultProvider:e.string(),defaultModel:e.string(),providers:e.record(e.string(),providerConfigSchema)});export const askConfigSchema=e.object({llmModel:e.string().optional(),confirmThreshold:e.number().optional()});export const runtimeApprovalConfigSchema=e.object({default:e.enum(i).default("guarded"),overrides:e.record(e.string(),e.enum(r)).default({})});export const runtimeCompactionConfigSchema=e.object({enabled:e.boolean().default(!0),strategy:e.enum(a).default("summarize"),threshold:e.number().min(.1).max(.95).default(.75),keepRecentTurns:e.number().int().min(1).default(4),keepRecentTokens:e.number().int().min(1).default(32e3)});export const runtimeThinkingLevels=["off","low","medium","high"];export const runtimeConfigSchema=e.object({provider:e.string().optional(),model:e.string().optional(),maxSteps:e.number().int().min(1).default(80),turnTimeoutMs:e.number().int().min(1e4).default(3e5),threadsDir:e.string().default("~/.roll-agent/threads"),contextWindow:e.number().int().min(1).optional(),thinkingLevel:e.enum(runtimeThinkingLevels).default("medium"),approval:runtimeApprovalConfigSchema.default({}),compaction:runtimeCompactionConfigSchema.default({})});export const agentsConfigSchema=e.object({dataDir:e.string(),env:e.record(e.string(),e.record(e.string(),e.string())).optional()});export const installConfigSchema=e.object({registry:e.string().trim().url().optional(),fetchRetries:e.number().int().min(0).max(10).default(3),preferOffline:e.boolean().default(!1),networkTimeoutMs:e.number().int().min(1e4).default(12e4)});export const browserInstanceConfigSchema=e.object({platform:e.enum(t).optional(),mode:e.enum(o).default("managed-cdp"),headless:e.boolean().optional(),cdpUrl:e.string().optional(),cdpHost:e.string().default("127.0.0.1"),cdpPort:e.number().int().min(1).max(65535).optional(),channel:e.enum(n).default("chrome"),executablePath:e.string().optional(),userDataDir:e.string().trim().min(1),sessionsDir:e.string().trim().min(1).optional(),args:e.array(e.string()).optional(),profileName:e.string().trim().min(1).optional(),profileColor:s.optional(),windowBounds:browserWindowBoundsSchema.optional(),trackingAgentId:e.string().trim().min(1).optional()}).superRefine((t,o)=>{"managed-cdp"===t.mode&&void 0===t.cdpPort&&o.addIssue({code:e.ZodIssueCode.custom,path:["cdpPort"],message:"managed-cdp browser instance requires cdpPort"}),"remote-cdp"!==t.mode&&"existing-session"!==t.mode||void 0!==t.cdpUrl||o.addIssue({code:e.ZodIssueCode.custom,path:["cdpUrl"],message:`${t.mode} browser instance requires cdpUrl`})});export const browserConfigSchema=e.object({defaultInstance:e.string().trim().min(1).optional(),instances:e.record(e.string(),browserInstanceConfigSchema).default({})}).superRefine((t,o)=>{const n=Object.entries(t.instances);void 0!==t.defaultInstance&&void 0===t.instances[t.defaultInstance]&&o.addIssue({code:e.ZodIssueCode.custom,path:["defaultInstance"],message:`defaultInstance "${t.defaultInstance}" is not declared in browser.instances`});const i=new Map,r=new Map;for(const[t,a]of n){if(void 0!==a.cdpPort){const n=i.get(a.cdpPort);void 0!==n?o.addIssue({code:e.ZodIssueCode.custom,path:["instances",t,"cdpPort"],message:`cdpPort ${String(a.cdpPort)} is already used by browser instance "${n}"`}):i.set(a.cdpPort,t)}const n=r.get(a.userDataDir);void 0!==n?o.addIssue({code:e.ZodIssueCode.custom,path:["instances",t,"userDataDir"],message:`userDataDir is already used by browser instance "${n}"`}):r.set(a.userDataDir,t)}});export const rollConfigSchema=e.object({llm:llmConfigSchema,ask:askConfigSchema,runtime:runtimeConfigSchema.default({}),agents:agentsConfigSchema,install:installConfigSchema.default({}),browser:browserConfigSchema.default({})});
|
package/dist/llm/engine.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare class LLMEngine {
|
|
|
13
13
|
/**
|
|
14
14
|
* 生成文本(非流式)。
|
|
15
15
|
*
|
|
16
|
-
* 使用 AI SDK
|
|
16
|
+
* 使用 AI SDK v7 的 generateText,支持 Anthropic provider。
|
|
17
17
|
*/
|
|
18
18
|
generateText(prompt: string, options?: LLMEngineOptions): Promise<string>;
|
|
19
19
|
/** 解析 provider + model,创建 AI SDK LanguageModel 实例 */
|
package/dist/llm/providers.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV4, SharedV4ProviderOptions } from "@ai-sdk/provider";
|
|
2
|
+
import { runtimeThinkingLevels } from "../config/schema.ts";
|
|
3
|
+
export type ThinkingLevel = (typeof runtimeThinkingLevels)[number];
|
|
4
|
+
export declare function thinkingProviderOptions(providerName: string, modelName: string, level: ThinkingLevel): SharedV4ProviderOptions | undefined;
|
|
2
5
|
/**
|
|
3
6
|
* 根据 provider 名称创建 AI SDK LanguageModel 实例。
|
|
4
7
|
*
|
|
5
8
|
* 支持: anthropic, openai, deepseek, qwen
|
|
6
9
|
*/
|
|
7
|
-
export declare function createProviderModel(providerName: string, modelName: string, apiKey: string, baseURL?: string):
|
|
10
|
+
export declare function createProviderModel(providerName: string, modelName: string, apiKey: string, baseURL?: string): LanguageModelV4;
|
|
8
11
|
/** generateText 调用目的 */
|
|
9
|
-
export type LLMCallPurpose = "structured-output" | "text" | "sampling";
|
|
12
|
+
export type LLMCallPurpose = "structured-output" | "text" | "sampling" | "chat";
|
|
10
13
|
/** resolveLLMCall 的返回值 */
|
|
11
14
|
export interface ResolvedLLMCall {
|
|
12
|
-
readonly model:
|
|
13
|
-
readonly providerOptions?:
|
|
15
|
+
readonly model: LanguageModelV4;
|
|
16
|
+
readonly providerOptions?: SharedV4ProviderOptions;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* 按 provider + 调用目的解析 generateText 的完整调用上下文。
|
|
@@ -18,4 +21,4 @@ export interface ResolvedLLMCall {
|
|
|
18
21
|
* structured-output 场景下,对 qwen provider 自动注入 enableThinking: false,
|
|
19
22
|
* 因为阿里云 thinking mode 不支持 structured output。
|
|
20
23
|
*/
|
|
21
|
-
export declare function resolveLLMCall(providerName: string, modelName: string, apiKey: string, purpose: LLMCallPurpose, baseURL?: string): ResolvedLLMCall;
|
|
24
|
+
export declare function resolveLLMCall(providerName: string, modelName: string, apiKey: string, purpose: LLMCallPurpose, baseURL?: string, thinkingLevel?: ThinkingLevel): ResolvedLLMCall;
|
package/dist/llm/providers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAlibaba as e}from"@ai-sdk/alibaba";import{createAnthropic as
|
|
1
|
+
import{createAlibaba as e}from"@ai-sdk/alibaba";import{createAnthropic as i}from"@ai-sdk/anthropic";import{createOpenAI as n}from"@ai-sdk/openai";import{createDeepSeek as o}from"@ai-sdk/deepseek";import{runtimeThinkingLevels as t}from"../config/schema.js";const a={low:2048,medium:8192,high:16384},r=["gpt-5.1","gpt-5.2","gpt-5.3","gpt-5.4"];function p(e){return r.some(i=>e.startsWith(i))}function s(e){const i=/^claude-[a-z]+-(\d+)(?:-(\d+))?(?:\b|-)/.exec(e),n=i?.[1];if(!n)return!1;const o=Number(n),t=i?.[2],a=void 0!==t&&t.length<=2?Number(t):0;return o>4||4===o&&a>=6}export function thinkingProviderOptions(e,i,n){return"openai"===e?"off"===n?p(i)?{openai:{reasoningEffort:"none"}}:void 0:{openai:{reasoningEffort:n}}:"anthropic"===e?"off"===n?{anthropic:{thinking:{type:"disabled"}}}:s(i)?{anthropic:{thinking:{type:"adaptive"},effort:n}}:{anthropic:{thinking:{type:"enabled",budgetTokens:a[n]}}}:"qwen"===e?"off"===n?{alibaba:{enableThinking:!1}}:{alibaba:{enableThinking:!0,thinkingBudget:a[n]}}:"deepseek"===e?{deepseek:{thinking:{type:"off"===n?"disabled":"enabled"}}}:void 0}const d="https://dashscope.aliyuncs.com/compatible-mode/v1",c={anthropic:(e,{apiKey:n,baseURL:o})=>i({apiKey:n,...o?{baseURL:o}:{}})(e),openai:(e,{apiKey:i,baseURL:o})=>n({apiKey:i,...o?{baseURL:o}:{}})(e),deepseek:(e,{apiKey:i,baseURL:n})=>o({apiKey:i,...n?{baseURL:n}:{}})(e),qwen:(i,{apiKey:n,baseURL:o})=>e({apiKey:n,baseURL:o??d})(i)};export function createProviderModel(e,i,n,o){const t=c[e];if(!t){const i=Object.keys(c).join(", ");throw new Error(`Unknown LLM provider "${e}". Supported: ${i}`)}return t(i,{apiKey:n,baseURL:o})}export function resolveLLMCall(e,i,n,o,t,a="medium"){const r=createProviderModel(e,i,n,t);if("structured-output"===o&&"qwen"===e)return{model:r,providerOptions:{alibaba:{enableThinking:!1}}};if("chat"===o){const n=thinkingProviderOptions(e,i,a);return n?{model:r,providerOptions:n}:{model:r}}return{model:r}}
|