@aeye/cletus 0.3.2 → 0.3.4
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 +1 -0
- package/dist/index.js +770 -386
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -141,10 +141,6 @@ var init_types = __esm({
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
// ../core/src/common.ts
|
|
144
|
-
import fs2 from "fs";
|
|
145
|
-
import path from "path";
|
|
146
|
-
import url from "url";
|
|
147
|
-
import { Readable } from "stream";
|
|
148
144
|
function resolveFn(fn, reprocess) {
|
|
149
145
|
if (!fn) {
|
|
150
146
|
return async () => void 0;
|
|
@@ -196,6 +192,239 @@ async function resolve(input) {
|
|
|
196
192
|
return input;
|
|
197
193
|
}
|
|
198
194
|
}
|
|
195
|
+
function accumulateUsage(target, add) {
|
|
196
|
+
if (!add) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (add.text) {
|
|
200
|
+
if (!target.text) {
|
|
201
|
+
target.text = {};
|
|
202
|
+
}
|
|
203
|
+
if (add.text.input !== void 0) {
|
|
204
|
+
target.text.input = (target.text.input || 0) + add.text.input;
|
|
205
|
+
}
|
|
206
|
+
if (add.text.output !== void 0) {
|
|
207
|
+
target.text.output = (target.text.output || 0) + add.text.output;
|
|
208
|
+
}
|
|
209
|
+
if (add.text.cached !== void 0) {
|
|
210
|
+
target.text.cached = (target.text.cached || 0) + add.text.cached;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (add.audio) {
|
|
214
|
+
if (!target.audio) {
|
|
215
|
+
target.audio = {};
|
|
216
|
+
}
|
|
217
|
+
if (add.audio.input !== void 0) {
|
|
218
|
+
target.audio.input = (target.audio.input || 0) + add.audio.input;
|
|
219
|
+
}
|
|
220
|
+
if (add.audio.output !== void 0) {
|
|
221
|
+
target.audio.output = (target.audio.output || 0) + add.audio.output;
|
|
222
|
+
}
|
|
223
|
+
if (add.audio.seconds !== void 0) {
|
|
224
|
+
target.audio.seconds = (target.audio.seconds || 0) + add.audio.seconds;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (add.image) {
|
|
228
|
+
if (!target.image) {
|
|
229
|
+
target.image = { output: [] };
|
|
230
|
+
}
|
|
231
|
+
if (add.image.input !== void 0) {
|
|
232
|
+
target.image.input = (target.image.input || 0) + add.image.input;
|
|
233
|
+
}
|
|
234
|
+
if (add.image.output) {
|
|
235
|
+
if (!target.image.output) {
|
|
236
|
+
target.image.output = [];
|
|
237
|
+
}
|
|
238
|
+
for (const addOutput of add.image.output) {
|
|
239
|
+
const existing = target.image.output.find(
|
|
240
|
+
(o4) => o4.quality === addOutput.quality && o4.size.width === addOutput.size.width && o4.size.height === addOutput.size.height
|
|
241
|
+
);
|
|
242
|
+
if (existing) {
|
|
243
|
+
existing.count += addOutput.count;
|
|
244
|
+
} else {
|
|
245
|
+
target.image.output.push({ ...addOutput });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (add.reasoning) {
|
|
251
|
+
if (!target.reasoning) {
|
|
252
|
+
target.reasoning = {};
|
|
253
|
+
}
|
|
254
|
+
if (add.reasoning.input !== void 0) {
|
|
255
|
+
target.reasoning.input = (target.reasoning.input || 0) + add.reasoning.input;
|
|
256
|
+
}
|
|
257
|
+
if (add.reasoning.output !== void 0) {
|
|
258
|
+
target.reasoning.output = (target.reasoning.output || 0) + add.reasoning.output;
|
|
259
|
+
}
|
|
260
|
+
if (add.reasoning.cached !== void 0) {
|
|
261
|
+
target.reasoning.cached = (target.reasoning.cached || 0) + add.reasoning.cached;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (add.embeddings) {
|
|
265
|
+
if (!target.embeddings) {
|
|
266
|
+
target.embeddings = {};
|
|
267
|
+
}
|
|
268
|
+
if (add.embeddings.count !== void 0) {
|
|
269
|
+
target.embeddings.count = (target.embeddings.count || 0) + add.embeddings.count;
|
|
270
|
+
}
|
|
271
|
+
if (add.embeddings.tokens !== void 0) {
|
|
272
|
+
target.embeddings.tokens = (target.embeddings.tokens || 0) + add.embeddings.tokens;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (add.cost !== void 0) {
|
|
276
|
+
target.cost = (target.cost || 0) + add.cost;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function getInputTokens(usage) {
|
|
280
|
+
if (!usage) return 0;
|
|
281
|
+
return (usage.text?.input || 0) + (usage.audio?.input || 0) + (usage.image?.input || 0) + (usage.reasoning?.input || 0) + (usage.embeddings?.tokens || 0);
|
|
282
|
+
}
|
|
283
|
+
function getOutputTokens(usage) {
|
|
284
|
+
if (!usage) return 0;
|
|
285
|
+
return (usage.text?.output || 0) + (usage.audio?.output || 0) + (usage.reasoning?.output || 0);
|
|
286
|
+
}
|
|
287
|
+
function getTotalTokens(usage) {
|
|
288
|
+
if (!usage) return 0;
|
|
289
|
+
return (usage.text?.input || 0) + (usage.text?.output || 0) + (usage.text?.cached || 0) + (usage.audio?.input || 0) + (usage.audio?.output || 0) + (usage.image?.input || 0) + (usage.reasoning?.input || 0) + (usage.reasoning?.output || 0) + (usage.reasoning?.cached || 0) + (usage.embeddings?.tokens || 0);
|
|
290
|
+
}
|
|
291
|
+
function getModel(input) {
|
|
292
|
+
return typeof input === "string" ? { id: input } : input;
|
|
293
|
+
}
|
|
294
|
+
function getResponseFromChunks(chunks, model = "unknown") {
|
|
295
|
+
const resp = {
|
|
296
|
+
content: "",
|
|
297
|
+
finishReason: "stop",
|
|
298
|
+
model
|
|
299
|
+
};
|
|
300
|
+
for (const chunk3 of chunks) {
|
|
301
|
+
if (chunk3.content) {
|
|
302
|
+
resp.content += chunk3.content;
|
|
303
|
+
}
|
|
304
|
+
if (chunk3.finishReason) {
|
|
305
|
+
resp.finishReason = chunk3.finishReason;
|
|
306
|
+
}
|
|
307
|
+
if (chunk3.reasoning) {
|
|
308
|
+
resp.reasoning = accumulateReasoning(resp.reasoning, chunk3.reasoning);
|
|
309
|
+
}
|
|
310
|
+
if (chunk3.model) {
|
|
311
|
+
resp.model = chunk3.model;
|
|
312
|
+
}
|
|
313
|
+
if (chunk3.refusal) {
|
|
314
|
+
resp.refusal = chunk3.refusal;
|
|
315
|
+
}
|
|
316
|
+
if (chunk3.toolCall) {
|
|
317
|
+
resp.toolCalls = resp.toolCalls || [];
|
|
318
|
+
resp.toolCalls.push(chunk3.toolCall);
|
|
319
|
+
}
|
|
320
|
+
if (chunk3.usage) {
|
|
321
|
+
resp.usage = resp.usage || {};
|
|
322
|
+
accumulateUsage(resp.usage, chunk3.usage);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return resp;
|
|
326
|
+
}
|
|
327
|
+
function getReasoningText(reasoning) {
|
|
328
|
+
if (!reasoning) {
|
|
329
|
+
return "";
|
|
330
|
+
}
|
|
331
|
+
const parts = [];
|
|
332
|
+
if (reasoning.content) {
|
|
333
|
+
parts.push(reasoning.content);
|
|
334
|
+
} else if (reasoning?.details) {
|
|
335
|
+
for (const detail of reasoning.details) {
|
|
336
|
+
if (detail.summary) {
|
|
337
|
+
parts.push(detail.summary);
|
|
338
|
+
}
|
|
339
|
+
if (detail.text) {
|
|
340
|
+
parts.push(detail.text);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return parts.join("\n\n");
|
|
345
|
+
}
|
|
346
|
+
function appendMaybe(x4, y2) {
|
|
347
|
+
if (!x4) {
|
|
348
|
+
return y2;
|
|
349
|
+
}
|
|
350
|
+
if (!y2) {
|
|
351
|
+
return x4;
|
|
352
|
+
}
|
|
353
|
+
if (!x4.includes(y2) && !y2.includes(x4)) {
|
|
354
|
+
return x4 + y2;
|
|
355
|
+
}
|
|
356
|
+
return x4;
|
|
357
|
+
}
|
|
358
|
+
function accumulateReasoning(target, add) {
|
|
359
|
+
if (!target) {
|
|
360
|
+
return add;
|
|
361
|
+
}
|
|
362
|
+
if (!add) {
|
|
363
|
+
return target;
|
|
364
|
+
}
|
|
365
|
+
if (add.content) {
|
|
366
|
+
target.content = appendMaybe(target.content || void 0, add.content);
|
|
367
|
+
}
|
|
368
|
+
if (add.details?.length) {
|
|
369
|
+
target.details = target.details || [];
|
|
370
|
+
for (const detail of add.details) {
|
|
371
|
+
let existing = target.details.find(
|
|
372
|
+
(d4) => detail.id && d4.id && detail.id === d4.id || detail.index !== void 0 && d4.index !== void 0 && detail.index === d4.index
|
|
373
|
+
);
|
|
374
|
+
const missingIdentifiers = add.details.every((d4) => !d4.id && d4.index === void 0) && target.details.every((d4) => !d4.id && d4.index === void 0);
|
|
375
|
+
if (missingIdentifiers) {
|
|
376
|
+
existing = target.details.find((d4) => d4.type === detail.type);
|
|
377
|
+
}
|
|
378
|
+
if (existing) {
|
|
379
|
+
if (detail.data) {
|
|
380
|
+
existing.data = appendMaybe(existing.data, detail.data);
|
|
381
|
+
}
|
|
382
|
+
if (detail.text) {
|
|
383
|
+
existing.text = appendMaybe(existing.text, detail.text);
|
|
384
|
+
if (detail.signature) {
|
|
385
|
+
existing.signature = detail.signature;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (detail.summary) {
|
|
389
|
+
existing.summary = appendMaybe(existing.summary, detail.summary);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
target.details.push(detail);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return target;
|
|
397
|
+
}
|
|
398
|
+
function getChunksFromResponse(response) {
|
|
399
|
+
const chunks = [];
|
|
400
|
+
if (response.reasoning || response.refusal) {
|
|
401
|
+
chunks.push({
|
|
402
|
+
refusal: response.refusal,
|
|
403
|
+
reasoning: response.reasoning
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
for (const toolCall of response.toolCalls || []) {
|
|
407
|
+
chunks.push({ toolCall, toolCallNamed: toolCall, toolCallArguments: toolCall });
|
|
408
|
+
}
|
|
409
|
+
chunks.push({
|
|
410
|
+
content: response.content,
|
|
411
|
+
finishReason: response.finishReason,
|
|
412
|
+
usage: response.usage,
|
|
413
|
+
model: response.model
|
|
414
|
+
});
|
|
415
|
+
return chunks;
|
|
416
|
+
}
|
|
417
|
+
var init_common = __esm({
|
|
418
|
+
"../core/src/common.ts"() {
|
|
419
|
+
"use strict";
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// ../core/src/to.ts
|
|
424
|
+
import fs2 from "fs";
|
|
425
|
+
import path from "path";
|
|
426
|
+
import { Readable } from "stream";
|
|
427
|
+
import url from "url";
|
|
199
428
|
function hasUrl(x4) {
|
|
200
429
|
return x4 && typeof x4.url === "function";
|
|
201
430
|
}
|
|
@@ -225,6 +454,7 @@ async function toBase64(input, mimeType, fallback) {
|
|
|
225
454
|
if (input.startsWith("data:")) {
|
|
226
455
|
return input;
|
|
227
456
|
}
|
|
457
|
+
[];
|
|
228
458
|
if (input.startsWith("http://") || input.startsWith("https://")) {
|
|
229
459
|
input = new URL(input);
|
|
230
460
|
} else if (input.startsWith("file://")) {
|
|
@@ -415,159 +645,8 @@ async function toFile(input, mimeType, filename) {
|
|
|
415
645
|
type: mimeType || "application/octet-stream"
|
|
416
646
|
});
|
|
417
647
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (add.text) {
|
|
423
|
-
if (!target.text) {
|
|
424
|
-
target.text = {};
|
|
425
|
-
}
|
|
426
|
-
if (add.text.input !== void 0) {
|
|
427
|
-
target.text.input = (target.text.input || 0) + add.text.input;
|
|
428
|
-
}
|
|
429
|
-
if (add.text.output !== void 0) {
|
|
430
|
-
target.text.output = (target.text.output || 0) + add.text.output;
|
|
431
|
-
}
|
|
432
|
-
if (add.text.cached !== void 0) {
|
|
433
|
-
target.text.cached = (target.text.cached || 0) + add.text.cached;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (add.audio) {
|
|
437
|
-
if (!target.audio) {
|
|
438
|
-
target.audio = {};
|
|
439
|
-
}
|
|
440
|
-
if (add.audio.input !== void 0) {
|
|
441
|
-
target.audio.input = (target.audio.input || 0) + add.audio.input;
|
|
442
|
-
}
|
|
443
|
-
if (add.audio.output !== void 0) {
|
|
444
|
-
target.audio.output = (target.audio.output || 0) + add.audio.output;
|
|
445
|
-
}
|
|
446
|
-
if (add.audio.seconds !== void 0) {
|
|
447
|
-
target.audio.seconds = (target.audio.seconds || 0) + add.audio.seconds;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (add.image) {
|
|
451
|
-
if (!target.image) {
|
|
452
|
-
target.image = { output: [] };
|
|
453
|
-
}
|
|
454
|
-
if (add.image.input !== void 0) {
|
|
455
|
-
target.image.input = (target.image.input || 0) + add.image.input;
|
|
456
|
-
}
|
|
457
|
-
if (add.image.output) {
|
|
458
|
-
if (!target.image.output) {
|
|
459
|
-
target.image.output = [];
|
|
460
|
-
}
|
|
461
|
-
for (const addOutput of add.image.output) {
|
|
462
|
-
const existing = target.image.output.find(
|
|
463
|
-
(o4) => o4.quality === addOutput.quality && o4.size.width === addOutput.size.width && o4.size.height === addOutput.size.height
|
|
464
|
-
);
|
|
465
|
-
if (existing) {
|
|
466
|
-
existing.count += addOutput.count;
|
|
467
|
-
} else {
|
|
468
|
-
target.image.output.push({ ...addOutput });
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
if (add.reasoning) {
|
|
474
|
-
if (!target.reasoning) {
|
|
475
|
-
target.reasoning = {};
|
|
476
|
-
}
|
|
477
|
-
if (add.reasoning.input !== void 0) {
|
|
478
|
-
target.reasoning.input = (target.reasoning.input || 0) + add.reasoning.input;
|
|
479
|
-
}
|
|
480
|
-
if (add.reasoning.output !== void 0) {
|
|
481
|
-
target.reasoning.output = (target.reasoning.output || 0) + add.reasoning.output;
|
|
482
|
-
}
|
|
483
|
-
if (add.reasoning.cached !== void 0) {
|
|
484
|
-
target.reasoning.cached = (target.reasoning.cached || 0) + add.reasoning.cached;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (add.embeddings) {
|
|
488
|
-
if (!target.embeddings) {
|
|
489
|
-
target.embeddings = {};
|
|
490
|
-
}
|
|
491
|
-
if (add.embeddings.count !== void 0) {
|
|
492
|
-
target.embeddings.count = (target.embeddings.count || 0) + add.embeddings.count;
|
|
493
|
-
}
|
|
494
|
-
if (add.embeddings.tokens !== void 0) {
|
|
495
|
-
target.embeddings.tokens = (target.embeddings.tokens || 0) + add.embeddings.tokens;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (add.cost !== void 0) {
|
|
499
|
-
target.cost = (target.cost || 0) + add.cost;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
function getInputTokens(usage) {
|
|
503
|
-
if (!usage) return 0;
|
|
504
|
-
return (usage.text?.input || 0) + (usage.audio?.input || 0) + (usage.image?.input || 0) + (usage.reasoning?.input || 0) + (usage.embeddings?.tokens || 0);
|
|
505
|
-
}
|
|
506
|
-
function getOutputTokens(usage) {
|
|
507
|
-
if (!usage) return 0;
|
|
508
|
-
return (usage.text?.output || 0) + (usage.audio?.output || 0) + (usage.reasoning?.output || 0);
|
|
509
|
-
}
|
|
510
|
-
function getTotalTokens(usage) {
|
|
511
|
-
if (!usage) return 0;
|
|
512
|
-
return (usage.text?.input || 0) + (usage.text?.output || 0) + (usage.text?.cached || 0) + (usage.audio?.input || 0) + (usage.audio?.output || 0) + (usage.image?.input || 0) + (usage.reasoning?.input || 0) + (usage.reasoning?.output || 0) + (usage.reasoning?.cached || 0) + (usage.embeddings?.tokens || 0);
|
|
513
|
-
}
|
|
514
|
-
function getModel(input) {
|
|
515
|
-
return typeof input === "string" ? { id: input } : input;
|
|
516
|
-
}
|
|
517
|
-
function getResponseFromChunks(chunks, model = "unknown") {
|
|
518
|
-
const resp = {
|
|
519
|
-
content: "",
|
|
520
|
-
finishReason: "stop",
|
|
521
|
-
model
|
|
522
|
-
};
|
|
523
|
-
for (const chunk3 of chunks) {
|
|
524
|
-
if (chunk3.content) {
|
|
525
|
-
resp.content += chunk3.content;
|
|
526
|
-
}
|
|
527
|
-
if (chunk3.finishReason) {
|
|
528
|
-
resp.finishReason = chunk3.finishReason;
|
|
529
|
-
}
|
|
530
|
-
if (chunk3.reasoning) {
|
|
531
|
-
resp.reasoning = (resp.reasoning || "") + chunk3.reasoning;
|
|
532
|
-
}
|
|
533
|
-
if (chunk3.model) {
|
|
534
|
-
resp.model = chunk3.model;
|
|
535
|
-
}
|
|
536
|
-
if (chunk3.refusal) {
|
|
537
|
-
resp.refusal = chunk3.refusal;
|
|
538
|
-
}
|
|
539
|
-
if (chunk3.toolCall) {
|
|
540
|
-
resp.toolCalls = resp.toolCalls || [];
|
|
541
|
-
resp.toolCalls.push(chunk3.toolCall);
|
|
542
|
-
}
|
|
543
|
-
if (chunk3.usage) {
|
|
544
|
-
resp.usage = resp.usage || {};
|
|
545
|
-
accumulateUsage(resp.usage, chunk3.usage);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return resp;
|
|
549
|
-
}
|
|
550
|
-
function getChunksFromResponse(response) {
|
|
551
|
-
const chunks = [];
|
|
552
|
-
if (response.reasoning || response.refusal) {
|
|
553
|
-
chunks.push({
|
|
554
|
-
refusal: response.refusal,
|
|
555
|
-
reasoning: response.reasoning
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
for (const toolCall of response.toolCalls || []) {
|
|
559
|
-
chunks.push({ toolCall, toolCallNamed: toolCall, toolCallArguments: toolCall });
|
|
560
|
-
}
|
|
561
|
-
chunks.push({
|
|
562
|
-
content: response.content,
|
|
563
|
-
finishReason: response.finishReason,
|
|
564
|
-
usage: response.usage,
|
|
565
|
-
model: response.model
|
|
566
|
-
});
|
|
567
|
-
return chunks;
|
|
568
|
-
}
|
|
569
|
-
var init_common = __esm({
|
|
570
|
-
"../core/src/common.ts"() {
|
|
648
|
+
var init_to = __esm({
|
|
649
|
+
"../core/src/to.ts"() {
|
|
571
650
|
"use strict";
|
|
572
651
|
}
|
|
573
652
|
});
|
|
@@ -20248,13 +20327,14 @@ function newToolExecution(ctx, toolCall, toolInfo) {
|
|
|
20248
20327
|
if (execution.status !== "ready") {
|
|
20249
20328
|
return execution;
|
|
20250
20329
|
}
|
|
20330
|
+
const args = execution.toolCall.arguments || "{}";
|
|
20251
20331
|
try {
|
|
20252
|
-
execution.args = await toolInfo.tool.parse(ctx,
|
|
20332
|
+
execution.args = await toolInfo.tool.parse(ctx, args, toolInfo.definition.parameters);
|
|
20253
20333
|
execution.status = "parsed";
|
|
20254
20334
|
start.ready = true;
|
|
20255
20335
|
} catch (e4) {
|
|
20256
20336
|
execution.status = "invalid";
|
|
20257
|
-
execution.error = `Error parsing tool arguments: ${e4.message}, args: ${
|
|
20337
|
+
execution.error = `Error parsing tool arguments: ${e4.message}, args: ${args}`;
|
|
20258
20338
|
error47.ready = true;
|
|
20259
20339
|
}
|
|
20260
20340
|
return execution;
|
|
@@ -20533,6 +20613,10 @@ var init_prompt = __esm({
|
|
|
20533
20613
|
return ev;
|
|
20534
20614
|
} : (ev) => ev;
|
|
20535
20615
|
const emitTool = (ev) => emit(ev);
|
|
20616
|
+
const emitMessage = (message) => {
|
|
20617
|
+
request.messages.push(message);
|
|
20618
|
+
return emit({ type: "message", message, request });
|
|
20619
|
+
};
|
|
20536
20620
|
while (iterations < maxIterations) {
|
|
20537
20621
|
const toolExecutors = [];
|
|
20538
20622
|
const toolExecutorMap = /* @__PURE__ */ new Map();
|
|
@@ -20540,7 +20624,7 @@ var init_prompt = __esm({
|
|
|
20540
20624
|
const toolParseErrorsPrevious = toolParseErrors;
|
|
20541
20625
|
let finishReason = void 0;
|
|
20542
20626
|
let refusal = "";
|
|
20543
|
-
let reasoning =
|
|
20627
|
+
let reasoning = void 0;
|
|
20544
20628
|
let content2 = "";
|
|
20545
20629
|
let disableTools = false;
|
|
20546
20630
|
const streamController = new AbortController();
|
|
@@ -20573,8 +20657,8 @@ var init_prompt = __esm({
|
|
|
20573
20657
|
yield emit({ type: "textPartial", content: chunk3.refusal, request });
|
|
20574
20658
|
}
|
|
20575
20659
|
if (chunk3.reasoning) {
|
|
20576
|
-
reasoning
|
|
20577
|
-
yield emit({ type: "reasonPartial",
|
|
20660
|
+
reasoning = accumulateReasoning(reasoning, chunk3.reasoning);
|
|
20661
|
+
yield emit({ type: "reasonPartial", reasoning, request });
|
|
20578
20662
|
}
|
|
20579
20663
|
if (chunk3.toolCallNamed) {
|
|
20580
20664
|
const toolExecutor = newToolExecution(ctx, chunk3.toolCallNamed, toolMap.get(chunk3.toolCallNamed.name));
|
|
@@ -20629,7 +20713,7 @@ var init_prompt = __esm({
|
|
|
20629
20713
|
}
|
|
20630
20714
|
ctx.signal?.removeEventListener("abort", streamAbort);
|
|
20631
20715
|
if (reasoning) {
|
|
20632
|
-
yield emit({ type: "reason",
|
|
20716
|
+
yield emit({ type: "reason", reasoning, request });
|
|
20633
20717
|
}
|
|
20634
20718
|
if (finishReason === "refusal" || refusal) {
|
|
20635
20719
|
yield emit({ type: "refusal", content: refusal || "unspecified", request });
|
|
@@ -20656,10 +20740,11 @@ var init_prompt = __esm({
|
|
|
20656
20740
|
yield emit({ type: "text", content: content2, request });
|
|
20657
20741
|
}
|
|
20658
20742
|
if (finishReason === "tool_calls" || toolExecutors.length) {
|
|
20659
|
-
|
|
20743
|
+
yield emitMessage({
|
|
20660
20744
|
role: "assistant",
|
|
20661
20745
|
content: content2,
|
|
20662
|
-
toolCalls: toolExecutors.map((te) => te.toolCall)
|
|
20746
|
+
toolCalls: toolExecutors.map((te) => te.toolCall),
|
|
20747
|
+
reasoning
|
|
20663
20748
|
});
|
|
20664
20749
|
let skip = false;
|
|
20665
20750
|
for (const toolExecutor of toolExecutors) {
|
|
@@ -20717,7 +20802,7 @@ var init_prompt = __esm({
|
|
|
20717
20802
|
}
|
|
20718
20803
|
for (const toolExecutor of toolExecutors) {
|
|
20719
20804
|
const content3 = toolExecutor.error ? toolExecutor.error : toolExecutor.result ? typeof toolExecutor.result === "string" ? toolExecutor.result : JSON.stringify(toolExecutor.result) : "";
|
|
20720
|
-
|
|
20805
|
+
yield emitMessage({
|
|
20721
20806
|
role: "tool",
|
|
20722
20807
|
content: content3,
|
|
20723
20808
|
toolCallId: toolExecutor.toolCall.id
|
|
@@ -20737,6 +20822,12 @@ var init_prompt = __esm({
|
|
|
20737
20822
|
disableTools = true;
|
|
20738
20823
|
}
|
|
20739
20824
|
}
|
|
20825
|
+
} else {
|
|
20826
|
+
yield emitMessage({
|
|
20827
|
+
role: "assistant",
|
|
20828
|
+
content: content2,
|
|
20829
|
+
reasoning
|
|
20830
|
+
});
|
|
20740
20831
|
}
|
|
20741
20832
|
const hadToolErrors = toolParseErrorsPrevious !== toolParseErrors;
|
|
20742
20833
|
const hitMax = this.input.toolsMax && toolSuccesses >= this.input.toolsMax;
|
|
@@ -20799,7 +20890,7 @@ ${parseError.message}`;
|
|
|
20799
20890
|
if (outputRetries > 0) {
|
|
20800
20891
|
outputRetries--;
|
|
20801
20892
|
yield emit({ type: "textReset", reason: resetReason, request });
|
|
20802
|
-
|
|
20893
|
+
yield emitMessage({
|
|
20803
20894
|
role: "user",
|
|
20804
20895
|
content: errorMessage
|
|
20805
20896
|
});
|
|
@@ -21148,6 +21239,7 @@ var init_src = __esm({
|
|
|
21148
21239
|
"use strict";
|
|
21149
21240
|
init_types();
|
|
21150
21241
|
init_common();
|
|
21242
|
+
init_to();
|
|
21151
21243
|
init_schema();
|
|
21152
21244
|
init_tool();
|
|
21153
21245
|
init_prompt();
|
|
@@ -56747,7 +56839,7 @@ var init_aws = __esm({
|
|
|
56747
56839
|
}
|
|
56748
56840
|
const result2 = {
|
|
56749
56841
|
content,
|
|
56750
|
-
reasoning,
|
|
56842
|
+
reasoning: { content: reasoning },
|
|
56751
56843
|
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
56752
56844
|
finishReason: this.mapAnthropicStopReason(responseBody.stop_reason),
|
|
56753
56845
|
model,
|
|
@@ -56802,7 +56894,7 @@ var init_aws = __esm({
|
|
|
56802
56894
|
case "thinking_delta":
|
|
56803
56895
|
accumulatedReasoning += chunk3.delta.thinking;
|
|
56804
56896
|
yield {
|
|
56805
|
-
reasoning: chunk3.delta.thinking
|
|
56897
|
+
reasoning: { content: chunk3.delta.thinking }
|
|
56806
56898
|
};
|
|
56807
56899
|
break;
|
|
56808
56900
|
case "input_json_delta":
|
|
@@ -99737,6 +99829,48 @@ var init_openai3 = __esm({
|
|
|
99737
99829
|
*/
|
|
99738
99830
|
augmentChatRequest(params, request, config3) {
|
|
99739
99831
|
}
|
|
99832
|
+
/**
|
|
99833
|
+
* Augment chat message with provider-specific data.
|
|
99834
|
+
*
|
|
99835
|
+
* @param chatMessage - OpenAI chat message
|
|
99836
|
+
* @param message - Original @aeye message
|
|
99837
|
+
* @param config - Provider configuration
|
|
99838
|
+
*/
|
|
99839
|
+
augmentChatMessage(chatMessage, message, config3) {
|
|
99840
|
+
}
|
|
99841
|
+
/**
|
|
99842
|
+
* Get augmented chat message with provider-specific data.
|
|
99843
|
+
*
|
|
99844
|
+
* @param chatMessage - OpenAI chat message
|
|
99845
|
+
* @param message - Original @aeye message
|
|
99846
|
+
* @param config - Provider configuration
|
|
99847
|
+
* @returns
|
|
99848
|
+
*/
|
|
99849
|
+
getChatMessage(chatMessage, message, config3) {
|
|
99850
|
+
this.augmentChatMessage(chatMessage, message, config3);
|
|
99851
|
+
return chatMessage;
|
|
99852
|
+
}
|
|
99853
|
+
/**
|
|
99854
|
+
* Augment chat content part with provider-specific data.
|
|
99855
|
+
*
|
|
99856
|
+
* @param chatContent - OpenAI chat content part
|
|
99857
|
+
* @param content - Original @aeye message content
|
|
99858
|
+
* @param config - Provider configuration
|
|
99859
|
+
*/
|
|
99860
|
+
augmentChatContent(chatContent, content, config3) {
|
|
99861
|
+
}
|
|
99862
|
+
/**
|
|
99863
|
+
* Get augmented chat content part with provider-specific data.
|
|
99864
|
+
*
|
|
99865
|
+
* @param chatContent - OpenAI chat content part
|
|
99866
|
+
* @param content - Original @aeye message content
|
|
99867
|
+
* @param config - Provider configuration
|
|
99868
|
+
* @returns
|
|
99869
|
+
*/
|
|
99870
|
+
getChatContent(chatContent, content, config3) {
|
|
99871
|
+
this.augmentChatContent(chatContent, content, config3);
|
|
99872
|
+
return chatContent;
|
|
99873
|
+
}
|
|
99740
99874
|
/**
|
|
99741
99875
|
* Augment chat chunk with provider-specific data.
|
|
99742
99876
|
*
|
|
@@ -99763,9 +99897,9 @@ var init_openai3 = __esm({
|
|
|
99763
99897
|
* @param name
|
|
99764
99898
|
* @returns
|
|
99765
99899
|
*/
|
|
99766
|
-
convertContentText(x4, name) {
|
|
99900
|
+
convertContentText(x4, name, config3) {
|
|
99767
99901
|
if (typeof x4 === "string") {
|
|
99768
|
-
return x4;
|
|
99902
|
+
return [{ type: "text", text: x4 }];
|
|
99769
99903
|
}
|
|
99770
99904
|
if (!Array.isArray(x4)) {
|
|
99771
99905
|
console.warn(`[OpenAIProvider] convertContentText: Unsupported content type from ${name}.`);
|
|
@@ -99773,15 +99907,15 @@ var init_openai3 = __esm({
|
|
|
99773
99907
|
}
|
|
99774
99908
|
return x4.map((part) => {
|
|
99775
99909
|
if (part.type === "text") {
|
|
99776
|
-
return { type: "text", text: String(part.content) };
|
|
99910
|
+
return this.getChatContent({ type: "text", text: String(part.content) }, part, config3);
|
|
99777
99911
|
} else if (part.type === "image") {
|
|
99778
|
-
return { type: "text", text: `Image sent by ${name} not included in content.` };
|
|
99912
|
+
return this.getChatContent({ type: "text", text: `Image sent by ${name} not included in content.` }, part, config3);
|
|
99779
99913
|
} else if (part.type === "file") {
|
|
99780
|
-
return { type: "text", text: `File sent by ${name} not included in content.` };
|
|
99914
|
+
return this.getChatContent({ type: "text", text: `File sent by ${name} not included in content.` }, part, config3);
|
|
99781
99915
|
} else if (part.type === "audio") {
|
|
99782
|
-
return { type: "text", text: `Audio sent by ${name} not included in content.` };
|
|
99916
|
+
return this.getChatContent({ type: "text", text: `Audio sent by ${name} not included in content.` }, part, config3);
|
|
99783
99917
|
}
|
|
99784
|
-
return { type: "text", text: `Unsupported content type from ${name}.` };
|
|
99918
|
+
return this.getChatContent({ type: "text", text: `Unsupported content type from ${name}.` }, part, config3);
|
|
99785
99919
|
});
|
|
99786
99920
|
}
|
|
99787
99921
|
/**
|
|
@@ -99790,67 +99924,69 @@ var init_openai3 = __esm({
|
|
|
99790
99924
|
* @param name
|
|
99791
99925
|
* @returns
|
|
99792
99926
|
*/
|
|
99793
|
-
async convertContent(x4, name) {
|
|
99927
|
+
async convertContent(x4, name, config3) {
|
|
99794
99928
|
if (typeof x4 === "string") {
|
|
99795
|
-
return x4;
|
|
99929
|
+
return [{ type: "text", text: x4 }];
|
|
99796
99930
|
}
|
|
99797
99931
|
return Promise.all(x4.map(async (part) => {
|
|
99798
99932
|
switch (part.type) {
|
|
99799
99933
|
case "text": {
|
|
99800
99934
|
const text = await toText(part.content).catch(() => `Text content sent by ${name} could not be converted to text.`);
|
|
99801
|
-
return {
|
|
99935
|
+
return this.getChatContent({
|
|
99802
99936
|
type: "text",
|
|
99803
99937
|
text
|
|
99804
|
-
};
|
|
99938
|
+
}, part, config3);
|
|
99805
99939
|
}
|
|
99806
99940
|
case "image": {
|
|
99807
99941
|
const url5 = await toURL(part.content, part.format, "INVALID").catch(() => "INVALID");
|
|
99808
99942
|
if (url5 === "INVALID") {
|
|
99809
|
-
return {
|
|
99943
|
+
return this.getChatContent({
|
|
99810
99944
|
type: "text",
|
|
99811
99945
|
text: `Image content sent by ${name} could not be converted to a URL.`
|
|
99812
|
-
};
|
|
99946
|
+
}, part, config3);
|
|
99813
99947
|
}
|
|
99814
|
-
return {
|
|
99948
|
+
return this.getChatContent({
|
|
99815
99949
|
type: "image_url",
|
|
99816
99950
|
image_url: { url: url5 }
|
|
99817
|
-
};
|
|
99951
|
+
}, part, config3);
|
|
99818
99952
|
}
|
|
99819
99953
|
case "audio": {
|
|
99820
99954
|
const base644 = await toBase64(part.content, void 0, "INVALID").catch(() => "INVALID");
|
|
99821
99955
|
if (base644 === "INVALID") {
|
|
99822
|
-
return {
|
|
99956
|
+
return this.getChatContent({
|
|
99823
99957
|
type: "text",
|
|
99824
99958
|
text: `Audio content sent by ${name} could not be converted to base64.`
|
|
99825
|
-
};
|
|
99959
|
+
}, part, config3);
|
|
99826
99960
|
}
|
|
99827
99961
|
const [, mimeType, data2] = /^data:([^;]+);base64,(.+)$/.exec(base644) || [null, "", ""];
|
|
99828
99962
|
const format3 = part.format || mimeType && mimeType.includes("wav") ? "wav" : "mp3";
|
|
99829
|
-
return {
|
|
99963
|
+
return this.getChatContent({
|
|
99830
99964
|
type: "input_audio",
|
|
99831
99965
|
input_audio: { data: data2, format: format3 }
|
|
99832
|
-
};
|
|
99966
|
+
}, part, config3);
|
|
99833
99967
|
}
|
|
99834
99968
|
case "file": {
|
|
99835
99969
|
const fileData = await toBase64(part.content, part.format, "INVALID").catch(() => "INVALID");
|
|
99836
99970
|
if (fileData === "INVALID") {
|
|
99837
|
-
return {
|
|
99971
|
+
return this.getChatContent({
|
|
99838
99972
|
type: "text",
|
|
99839
99973
|
text: `File content sent by ${name} could not be converted to base64.`
|
|
99840
|
-
};
|
|
99974
|
+
}, part, config3);
|
|
99841
99975
|
}
|
|
99842
|
-
return {
|
|
99976
|
+
return this.getChatContent({
|
|
99843
99977
|
type: "file",
|
|
99844
99978
|
file: {
|
|
99845
|
-
file_data: fileData
|
|
99979
|
+
file_data: fileData,
|
|
99980
|
+
// TODO add filename
|
|
99981
|
+
filename: "file" + (part.format ? `.${part.format}` : "")
|
|
99846
99982
|
}
|
|
99847
|
-
};
|
|
99983
|
+
}, part, config3);
|
|
99848
99984
|
}
|
|
99849
99985
|
default:
|
|
99850
|
-
return {
|
|
99986
|
+
return this.getChatContent({
|
|
99851
99987
|
type: "text",
|
|
99852
99988
|
text: `Unsupported content type from ${name}.`
|
|
99853
|
-
};
|
|
99989
|
+
}, part, config3);
|
|
99854
99990
|
}
|
|
99855
99991
|
}));
|
|
99856
99992
|
}
|
|
@@ -99891,55 +100027,55 @@ var init_openai3 = __esm({
|
|
|
99891
100027
|
* @param request @aeye request object
|
|
99892
100028
|
* @returns Array of OpenAI-formatted messages
|
|
99893
100029
|
*/
|
|
99894
|
-
async convertMessages(request) {
|
|
100030
|
+
async convertMessages(request, config3) {
|
|
99895
100031
|
return (await Promise.all(request.messages.map(async (msg) => {
|
|
99896
100032
|
switch (msg.role) {
|
|
99897
100033
|
case "system":
|
|
99898
|
-
return {
|
|
100034
|
+
return this.getChatMessage({
|
|
99899
100035
|
role: "developer",
|
|
99900
100036
|
name: this.convertName(msg.name),
|
|
99901
|
-
content: this.convertContentText(msg.content, msg.name || "system")
|
|
99902
|
-
};
|
|
100037
|
+
content: this.convertContentText(msg.content, msg.name || "system", config3)
|
|
100038
|
+
}, msg, config3);
|
|
99903
100039
|
case "tool":
|
|
99904
|
-
return {
|
|
100040
|
+
return this.getChatMessage({
|
|
99905
100041
|
role: "tool",
|
|
99906
100042
|
tool_call_id: msg.toolCallId,
|
|
99907
|
-
content: this.convertContentText(msg.content, msg.name || "tool")
|
|
99908
|
-
};
|
|
100043
|
+
content: this.convertContentText(msg.content, msg.name || "tool", config3)
|
|
100044
|
+
}, msg, config3);
|
|
99909
100045
|
case "assistant":
|
|
99910
|
-
const content = await this.convertContent(msg.content, msg.name || "assistant");
|
|
100046
|
+
const content = await this.convertContent(msg.content, msg.name || "assistant", config3);
|
|
99911
100047
|
if (!content || typeof content === "string" || content.every((c4) => c4.type === "text")) {
|
|
99912
|
-
return {
|
|
100048
|
+
return this.getChatMessage({
|
|
99913
100049
|
role: msg.role,
|
|
99914
100050
|
name: this.convertName(msg.name),
|
|
99915
100051
|
tool_calls: msg.toolCalls?.map((tc) => this.convertToolCall(tc)),
|
|
99916
100052
|
content
|
|
99917
|
-
};
|
|
100053
|
+
}, msg, config3);
|
|
99918
100054
|
} else {
|
|
99919
100055
|
const firstText = content.findIndex((c4) => c4.type === "text");
|
|
99920
100056
|
return content.map((contentPart, index) => {
|
|
99921
100057
|
if (contentPart.type === "text") {
|
|
99922
|
-
return {
|
|
100058
|
+
return this.getChatMessage({
|
|
99923
100059
|
role: "assistant",
|
|
99924
100060
|
name: this.convertName(msg.name),
|
|
99925
100061
|
tool_calls: index === firstText ? msg.toolCalls?.map((tc) => this.convertToolCall(tc)) : void 0,
|
|
99926
100062
|
content: [contentPart]
|
|
99927
|
-
};
|
|
100063
|
+
}, msg, config3);
|
|
99928
100064
|
} else {
|
|
99929
|
-
return {
|
|
100065
|
+
return this.getChatMessage({
|
|
99930
100066
|
role: "user",
|
|
99931
100067
|
name: this.convertName(msg.name),
|
|
99932
100068
|
content: [contentPart]
|
|
99933
|
-
};
|
|
100069
|
+
}, msg, config3);
|
|
99934
100070
|
}
|
|
99935
100071
|
});
|
|
99936
100072
|
}
|
|
99937
100073
|
case "user":
|
|
99938
|
-
return {
|
|
100074
|
+
return this.getChatMessage({
|
|
99939
100075
|
role: msg.role,
|
|
99940
100076
|
name: this.convertName(msg.name),
|
|
99941
|
-
content: await this.convertContent(msg.content, msg.name || "user")
|
|
99942
|
-
};
|
|
100077
|
+
content: await this.convertContent(msg.content, msg.name || "user", config3)
|
|
100078
|
+
}, msg, config3);
|
|
99943
100079
|
}
|
|
99944
100080
|
}))).flat();
|
|
99945
100081
|
}
|
|
@@ -100098,7 +100234,7 @@ var init_openai3 = __esm({
|
|
|
100098
100234
|
const client2 = this.createClient(effectiveConfig);
|
|
100099
100235
|
return async (request, ctx, metadata, requestSignal) => {
|
|
100100
100236
|
const { model, retry } = this.getRequestData(request, requestSignal, ctx, effectiveConfig, "chat", metadata?.model || effectiveConfig.defaultModels?.chat);
|
|
100101
|
-
const messages = await this.convertMessages(request);
|
|
100237
|
+
const messages = await this.convertMessages(request, effectiveConfig);
|
|
100102
100238
|
const tools = this.convertTools(request);
|
|
100103
100239
|
const tool_choice = tools?.length ? this.convertToolChoice(request) : void 0;
|
|
100104
100240
|
const parallel_tool_calls = tools?.length ? !request.toolsOneAtATime : void 0;
|
|
@@ -100189,7 +100325,7 @@ var init_openai3 = __esm({
|
|
|
100189
100325
|
const client2 = this.createClient(effectiveConfig);
|
|
100190
100326
|
return async function* (request, ctx, metadata, requestSignal) {
|
|
100191
100327
|
const { model, retry, signal } = this.getRequestData(request, requestSignal, ctx, effectiveConfig, "streaming chat", metadata?.model || effectiveConfig.defaultModels?.chat);
|
|
100192
|
-
const messages = await this.convertMessages(request);
|
|
100328
|
+
const messages = await this.convertMessages(request, effectiveConfig);
|
|
100193
100329
|
const tools = this.convertTools(request);
|
|
100194
100330
|
const tool_choice = tools?.length ? this.convertToolChoice(request) : void 0;
|
|
100195
100331
|
const parallel_tool_calls = tools?.length ? !request.toolsOneAtATime : void 0;
|
|
@@ -100254,9 +100390,7 @@ var init_openai3 = __esm({
|
|
|
100254
100390
|
}
|
|
100255
100391
|
const toolCallsMap = /* @__PURE__ */ new Map();
|
|
100256
100392
|
const toolCalls = [];
|
|
100257
|
-
|
|
100258
|
-
let finalUsage = void 0;
|
|
100259
|
-
let finishReason = void 0;
|
|
100393
|
+
const chunks = [];
|
|
100260
100394
|
try {
|
|
100261
100395
|
for await (const chunk3 of stream5) {
|
|
100262
100396
|
if (signal?.aborted) {
|
|
@@ -100270,15 +100404,6 @@ var init_openai3 = __esm({
|
|
|
100270
100404
|
refusal: delta?.refusal ?? void 0,
|
|
100271
100405
|
usage: chunk3.usage ? convertOpenAIUsage(chunk3.usage) : void 0
|
|
100272
100406
|
};
|
|
100273
|
-
if (delta?.content) {
|
|
100274
|
-
accumulatedContent += delta.content;
|
|
100275
|
-
}
|
|
100276
|
-
if (chunk3.usage) {
|
|
100277
|
-
finalUsage = convertOpenAIUsage(chunk3.usage);
|
|
100278
|
-
}
|
|
100279
|
-
if (choice?.finish_reason) {
|
|
100280
|
-
finishReason = choice.finish_reason;
|
|
100281
|
-
}
|
|
100282
100407
|
for (const toolCall of toolCalls) {
|
|
100283
100408
|
toolCall.updated = false;
|
|
100284
100409
|
}
|
|
@@ -100316,9 +100441,15 @@ var init_openai3 = __esm({
|
|
|
100316
100441
|
if (!toolCall.updated && !toolCall.finished) {
|
|
100317
100442
|
toolCall.finished = true;
|
|
100318
100443
|
yieldChunk.toolCall = toolCall;
|
|
100444
|
+
if (!toolCall.named) {
|
|
100445
|
+
yieldChunk.toolCallNamed = toolCall;
|
|
100446
|
+
yieldChunk.toolCallArguments = toolCall;
|
|
100447
|
+
toolCall.named = true;
|
|
100448
|
+
}
|
|
100319
100449
|
}
|
|
100320
100450
|
}
|
|
100321
100451
|
this.augmentChatChunk(chunk3, yieldChunk, effectiveConfig);
|
|
100452
|
+
chunks.push(yieldChunk);
|
|
100322
100453
|
yield yieldChunk;
|
|
100323
100454
|
}
|
|
100324
100455
|
} finally {
|
|
@@ -100327,18 +100458,19 @@ var init_openai3 = __esm({
|
|
|
100327
100458
|
toolCall.finished = true;
|
|
100328
100459
|
const chunk3 = { choices: [], created: 0, id: "", model: "", object: "chat.completion.chunk" };
|
|
100329
100460
|
const yieldChunk = { toolCall };
|
|
100461
|
+
if (!toolCall.named) {
|
|
100462
|
+
yieldChunk.toolCallNamed = toolCall;
|
|
100463
|
+
yieldChunk.toolCallArguments = toolCall;
|
|
100464
|
+
toolCall.named = true;
|
|
100465
|
+
}
|
|
100330
100466
|
this.augmentChatChunk(chunk3, yieldChunk, effectiveConfig);
|
|
100331
|
-
|
|
100467
|
+
chunks.push(yieldChunk);
|
|
100468
|
+
yield yieldChunk;
|
|
100332
100469
|
}
|
|
100333
100470
|
}
|
|
100334
100471
|
if (effectiveConfig.hooks?.chat?.afterRequest) {
|
|
100335
|
-
const finalResponse =
|
|
100336
|
-
|
|
100337
|
-
toolCalls: toolCalls.map((tc) => ({ id: tc.id, name: tc.name, arguments: tc.arguments })),
|
|
100338
|
-
finishReason: toolCalls.length ? "tool_calls" : finishReason || "stop",
|
|
100339
|
-
model,
|
|
100340
|
-
usage: finalUsage
|
|
100341
|
-
};
|
|
100472
|
+
const finalResponse = getResponseFromChunks(chunks);
|
|
100473
|
+
finalResponse.model = model;
|
|
100342
100474
|
await effectiveConfig.hooks.chat.afterRequest(request, params, finalResponse, ctx, metadata);
|
|
100343
100475
|
}
|
|
100344
100476
|
}
|
|
@@ -101051,7 +101183,7 @@ var init_openai3 = __esm({
|
|
|
101051
101183
|
maxTokens: request.maxTokens
|
|
101052
101184
|
};
|
|
101053
101185
|
const { model } = this.getRequestData(chatRequest, void 0, ctx, effectiveConfig, "analyze image", effectiveConfig.defaultModels?.imageAnalyze || "gpt-4-vision-preview");
|
|
101054
|
-
const messages = await this.convertMessages(chatRequest);
|
|
101186
|
+
const messages = await this.convertMessages(chatRequest, effectiveConfig);
|
|
101055
101187
|
const params = {
|
|
101056
101188
|
model: model.id,
|
|
101057
101189
|
messages,
|
|
@@ -101107,7 +101239,7 @@ var init_openai3 = __esm({
|
|
|
101107
101239
|
maxTokens: request.maxTokens
|
|
101108
101240
|
};
|
|
101109
101241
|
const { model } = this.getRequestData(chatRequest, void 0, ctx, effectiveConfig, "analyze image stream", effectiveConfig.defaultModels?.imageAnalyze || "gpt-4-vision-preview");
|
|
101110
|
-
const messages = await this.convertMessages(chatRequest);
|
|
101242
|
+
const messages = await this.convertMessages(chatRequest, effectiveConfig);
|
|
101111
101243
|
const params = {
|
|
101112
101244
|
model: model.id,
|
|
101113
101245
|
messages,
|
|
@@ -101330,6 +101462,7 @@ var init_openrouter2 = __esm({
|
|
|
101330
101462
|
"../openrouter/src/openrouter.ts"() {
|
|
101331
101463
|
"use strict";
|
|
101332
101464
|
init_src2();
|
|
101465
|
+
init_src();
|
|
101333
101466
|
init_src5();
|
|
101334
101467
|
init_openai2();
|
|
101335
101468
|
init_source();
|
|
@@ -101397,9 +101530,16 @@ var init_openrouter2 = __esm({
|
|
|
101397
101530
|
const message = expected.choices?.[0]?.message;
|
|
101398
101531
|
if (message) {
|
|
101399
101532
|
if (message.reasoning) {
|
|
101400
|
-
response.reasoning
|
|
101401
|
-
|
|
101402
|
-
|
|
101533
|
+
if (!response.reasoning) {
|
|
101534
|
+
response.reasoning = {};
|
|
101535
|
+
}
|
|
101536
|
+
response.reasoning.content = message.reasoning;
|
|
101537
|
+
}
|
|
101538
|
+
if (message.reasoning_details) {
|
|
101539
|
+
if (!response.reasoning) {
|
|
101540
|
+
response.reasoning = {};
|
|
101541
|
+
}
|
|
101542
|
+
response.reasoning.details = message.reasoning_details;
|
|
101403
101543
|
}
|
|
101404
101544
|
}
|
|
101405
101545
|
const usage = expected.usage;
|
|
@@ -101440,11 +101580,39 @@ var init_openrouter2 = __esm({
|
|
|
101440
101580
|
chunk3.usage.cost = usage.cost;
|
|
101441
101581
|
}
|
|
101442
101582
|
}
|
|
101443
|
-
|
|
101444
|
-
|
|
101445
|
-
|
|
101446
|
-
|
|
101583
|
+
const delta = expected.choices[0]?.delta;
|
|
101584
|
+
if (delta?.reasoning || delta?.reasoning_details?.length) {
|
|
101585
|
+
chunk3.reasoning = accumulateReasoning(chunk3.reasoning, {
|
|
101586
|
+
content: delta.reasoning,
|
|
101587
|
+
details: delta.reasoning_details
|
|
101588
|
+
});
|
|
101589
|
+
}
|
|
101590
|
+
}
|
|
101591
|
+
augmentChatMessage(chatMessage, message, config3) {
|
|
101592
|
+
if (message.reasoning?.content) {
|
|
101593
|
+
chatMessage.reasoning = message.reasoning.content;
|
|
101594
|
+
}
|
|
101595
|
+
if (message.reasoning?.details) {
|
|
101596
|
+
chatMessage.reasoning_details = message.reasoning.details;
|
|
101597
|
+
}
|
|
101598
|
+
}
|
|
101599
|
+
async convertMessages(request, config3) {
|
|
101600
|
+
const messages = await super.convertMessages(request, config3);
|
|
101601
|
+
for (let i4 = messages.length - 1; i4 >= 0; i4--) {
|
|
101602
|
+
const message = messages[i4];
|
|
101603
|
+
if (message.role === "assistant" && message.content?.length && (message.reasoning?.length || message.reasoning_details?.length)) {
|
|
101604
|
+
const { reasoning, reasoning_details } = message;
|
|
101605
|
+
delete message.reasoning;
|
|
101606
|
+
delete message.reasoning_details;
|
|
101607
|
+
messages.splice(i4, 0, {
|
|
101608
|
+
role: "assistant",
|
|
101609
|
+
name: message.name,
|
|
101610
|
+
reasoning,
|
|
101611
|
+
reasoning_details
|
|
101612
|
+
});
|
|
101613
|
+
}
|
|
101447
101614
|
}
|
|
101615
|
+
return messages;
|
|
101448
101616
|
}
|
|
101449
101617
|
/**
|
|
101450
101618
|
* OpenRouter does not support image generation
|
|
@@ -103305,15 +103473,11 @@ var init_replicate3 = __esm({
|
|
|
103305
103473
|
chunks.push(chunk3);
|
|
103306
103474
|
yield chunk3;
|
|
103307
103475
|
}
|
|
103308
|
-
|
|
103309
|
-
|
|
103310
|
-
|
|
103311
|
-
|
|
103312
|
-
|
|
103313
|
-
reasoning: chunks.map((c4) => c4.reasoning).filter(Boolean).join(""),
|
|
103314
|
-
refusal: chunks.map((c4) => c4.refusal).filter(Boolean).join(""),
|
|
103315
|
-
toolCalls: chunks.map((c4) => c4.toolCall).filter((tc) => !!tc)
|
|
103316
|
-
};
|
|
103476
|
+
const response = getResponseFromChunks(chunks);
|
|
103477
|
+
if (request.model) {
|
|
103478
|
+
response.model = request.model;
|
|
103479
|
+
}
|
|
103480
|
+
return response;
|
|
103317
103481
|
};
|
|
103318
103482
|
}
|
|
103319
103483
|
/**
|
|
@@ -458492,24 +458656,115 @@ function formatValueWithFormat(value, format3 = "yaml", alreadyIndented = false)
|
|
|
458492
458656
|
return formatValue(value, alreadyIndented);
|
|
458493
458657
|
}
|
|
458494
458658
|
async function convertMessage(msg) {
|
|
458495
|
-
|
|
458496
|
-
|
|
458497
|
-
|
|
458498
|
-
|
|
458659
|
+
if (msg.role !== "assistant") {
|
|
458660
|
+
const content = await Promise.all(
|
|
458661
|
+
msg.content.map((mc) => convertMessageContent(mc, msg.created))
|
|
458662
|
+
);
|
|
458663
|
+
return [{
|
|
458664
|
+
role: msg.role,
|
|
458665
|
+
name: msg.name,
|
|
458666
|
+
tokens: msg.tokens,
|
|
458667
|
+
content
|
|
458668
|
+
}];
|
|
458669
|
+
}
|
|
458670
|
+
const messages = [];
|
|
458671
|
+
let currentReasoning = void 0;
|
|
458672
|
+
let i4 = 0;
|
|
458673
|
+
while (i4 < msg.content.length) {
|
|
458674
|
+
const messageContent = msg.content[i4];
|
|
458675
|
+
if (messageContent.type === "reasoning") {
|
|
458676
|
+
currentReasoning = messageContent.reasoning;
|
|
458677
|
+
i4++;
|
|
458499
458678
|
continue;
|
|
458500
458679
|
}
|
|
458501
|
-
|
|
458502
|
-
|
|
458503
|
-
content.content
|
|
458680
|
+
if (messageContent.operationIndex !== void 0) {
|
|
458681
|
+
const operationIndices = [];
|
|
458682
|
+
while (i4 < msg.content.length && msg.content[i4].operationIndex !== void 0) {
|
|
458683
|
+
operationIndices.push(msg.content[i4].operationIndex);
|
|
458684
|
+
i4++;
|
|
458685
|
+
}
|
|
458686
|
+
const operations = operationIndices.map((index) => ({
|
|
458687
|
+
index,
|
|
458688
|
+
operation: msg.operations?.[index],
|
|
458689
|
+
toolCallId: `${msg.created}-${index}-${msg.operations?.[index].type}`
|
|
458690
|
+
}));
|
|
458691
|
+
messages.push({
|
|
458692
|
+
role: "assistant",
|
|
458693
|
+
name: msg.name,
|
|
458694
|
+
reasoning: currentReasoning,
|
|
458695
|
+
content: [],
|
|
458696
|
+
toolCalls: operations.map(({ toolCallId, operation: operation2 }) => ({
|
|
458697
|
+
id: toolCallId,
|
|
458698
|
+
name: operation2.type,
|
|
458699
|
+
arguments: JSON.stringify(operation2.input)
|
|
458700
|
+
}))
|
|
458701
|
+
});
|
|
458702
|
+
currentReasoning = void 0;
|
|
458703
|
+
const approvalOperations = operations.filter(({ operation: operation2 }) => operation2.analysis);
|
|
458704
|
+
for (const { operation: operation2, toolCallId } of operations) {
|
|
458705
|
+
const content2 = OperationManager.getContent(operation2, true);
|
|
458706
|
+
messages.push({
|
|
458707
|
+
role: "tool",
|
|
458708
|
+
content: content2,
|
|
458709
|
+
toolCallId
|
|
458710
|
+
});
|
|
458711
|
+
}
|
|
458712
|
+
if (approvalOperations.length > 0) {
|
|
458713
|
+
let approvalText = "Please approve or reject the proposed operations.";
|
|
458714
|
+
if (i4 < msg.content.length) {
|
|
458715
|
+
const nextContent = msg.content[i4];
|
|
458716
|
+
if (nextContent.type === "reasoning") {
|
|
458717
|
+
currentReasoning = nextContent.reasoning;
|
|
458718
|
+
i4++;
|
|
458719
|
+
if (i4 < msg.content.length && msg.content[i4].type === "text") {
|
|
458720
|
+
approvalText = msg.content[i4].content;
|
|
458721
|
+
i4++;
|
|
458722
|
+
}
|
|
458723
|
+
} else if (nextContent.type === "text") {
|
|
458724
|
+
approvalText = nextContent.content;
|
|
458725
|
+
i4++;
|
|
458726
|
+
}
|
|
458727
|
+
}
|
|
458728
|
+
messages.push({
|
|
458729
|
+
role: "assistant",
|
|
458730
|
+
name: msg.name,
|
|
458731
|
+
content: approvalText,
|
|
458732
|
+
reasoning: currentReasoning
|
|
458733
|
+
});
|
|
458734
|
+
currentReasoning = void 0;
|
|
458735
|
+
messages.push({
|
|
458736
|
+
role: "user",
|
|
458737
|
+
content: approvalOperations.map(({ operation: operation2, toolCallId }) => ({
|
|
458738
|
+
type: "text",
|
|
458739
|
+
content: operation2.status === "rejected" ? `<rejected-operation id="${toolCallId}" />` : `<approved-operation id="${toolCallId}">
|
|
458740
|
+
${OperationManager.getContent(operation2)}
|
|
458741
|
+
</approved-operation>`
|
|
458742
|
+
}))
|
|
458743
|
+
});
|
|
458744
|
+
}
|
|
458745
|
+
continue;
|
|
458504
458746
|
}
|
|
458747
|
+
const content = await convertMessageContent(messageContent, msg.created);
|
|
458748
|
+
messages.push({
|
|
458749
|
+
role: msg.role,
|
|
458750
|
+
name: msg.name,
|
|
458751
|
+
tokens: msg.tokens,
|
|
458752
|
+
content: [content],
|
|
458753
|
+
reasoning: currentReasoning
|
|
458754
|
+
});
|
|
458755
|
+
currentReasoning = void 0;
|
|
458505
458756
|
i4++;
|
|
458506
458757
|
}
|
|
458507
|
-
|
|
458508
|
-
|
|
458509
|
-
|
|
458510
|
-
|
|
458511
|
-
|
|
458512
|
-
|
|
458758
|
+
if (currentReasoning) {
|
|
458759
|
+
messages.push({
|
|
458760
|
+
role: msg.role,
|
|
458761
|
+
name: msg.name,
|
|
458762
|
+
tokens: msg.tokens,
|
|
458763
|
+
content: [],
|
|
458764
|
+
reasoning: currentReasoning
|
|
458765
|
+
});
|
|
458766
|
+
}
|
|
458767
|
+
return messages;
|
|
458513
458768
|
}
|
|
458514
458769
|
async function convertMessageContent(messageContent, messageTimestamp) {
|
|
458515
458770
|
const { type, content, operationIndex } = messageContent;
|
|
@@ -458537,6 +458792,12 @@ The operation summary has had <${truncatedSections.join(">, <")}> truncated for
|
|
|
458537
458792
|
}
|
|
458538
458793
|
return { type, content };
|
|
458539
458794
|
}
|
|
458795
|
+
if (type === "reasoning") {
|
|
458796
|
+
return {
|
|
458797
|
+
type: "text",
|
|
458798
|
+
content: `<reasoning-history>${content}</reasoning-history>`
|
|
458799
|
+
};
|
|
458800
|
+
}
|
|
458540
458801
|
if (content.startsWith("http://") || content.startsWith("https://")) {
|
|
458541
458802
|
return { type, content: new URL(content) };
|
|
458542
458803
|
}
|
|
@@ -458567,21 +458828,24 @@ function fileProtocol(path16) {
|
|
|
458567
458828
|
}
|
|
458568
458829
|
return path16;
|
|
458569
458830
|
}
|
|
458570
|
-
var INPUT_START, INPUT_END, ANALYSIS_START, ANALYSIS_END, OUTPUT_START, OUTPUT_END, INSTRUCTIONS_START, INSTRUCTIONS_END;
|
|
458831
|
+
var INPUT_START, INPUT_END, ANALYSIS_START, ANALYSIS_END, OUTPUT_START, OUTPUT_END, INSTRUCTIONS_START, INSTRUCTIONS_END, ERROR_START, ERROR_END;
|
|
458571
458832
|
var init_common5 = __esm({
|
|
458572
458833
|
"src/common.ts"() {
|
|
458573
458834
|
"use strict";
|
|
458574
458835
|
init_constants();
|
|
458575
458836
|
init_files4();
|
|
458837
|
+
init_manager2();
|
|
458576
458838
|
init_shared2();
|
|
458577
|
-
INPUT_START = "
|
|
458578
|
-
INPUT_END = "
|
|
458579
|
-
ANALYSIS_START = "
|
|
458580
|
-
ANALYSIS_END = "
|
|
458581
|
-
OUTPUT_START = "
|
|
458582
|
-
OUTPUT_END = "
|
|
458839
|
+
INPUT_START = "";
|
|
458840
|
+
INPUT_END = "";
|
|
458841
|
+
ANALYSIS_START = "Operation requires approval, this operation has NOT been performed yet. The analysis follows - you can ask for approval and talk about the results of the analysis but the user will approve the operation and respond back with the actual results.\n\nAnalysis:\n";
|
|
458842
|
+
ANALYSIS_END = "";
|
|
458843
|
+
OUTPUT_START = "Operation completed successfully! The output follows and you can discuss the results.\n\nOutput:\n";
|
|
458844
|
+
OUTPUT_END = "";
|
|
458583
458845
|
INSTRUCTIONS_START = "\n\n<instructions>\n";
|
|
458584
458846
|
INSTRUCTIONS_END = "\n</instructions>";
|
|
458847
|
+
ERROR_START = "Operation failed:";
|
|
458848
|
+
ERROR_END = "";
|
|
458585
458849
|
}
|
|
458586
458850
|
});
|
|
458587
458851
|
|
|
@@ -504815,7 +505079,7 @@ Do not return any additional text other than the matching description subset.`;
|
|
|
504815
505079
|
const fullPath = resolveImage(cwd, imagePath);
|
|
504816
505080
|
const imageLink = linkFile(fullPath);
|
|
504817
505081
|
if (chatMessage) {
|
|
504818
|
-
chatMessage.content.push({ type: "image", content: imageLink });
|
|
505082
|
+
chatMessage.content.push({ type: "image", content: imageLink, created: Date.now() });
|
|
504819
505083
|
}
|
|
504820
505084
|
return { fullPath, attached: true };
|
|
504821
505085
|
},
|
|
@@ -505350,12 +505614,13 @@ var init_libesm = __esm({
|
|
|
505350
505614
|
});
|
|
505351
505615
|
|
|
505352
505616
|
// src/schemas.ts
|
|
505353
|
-
var UserMemorySchema, UserSchema, OpenAIConfigSchema, OpenRouterConfigSchema, ReplicateConfigSchema, AWSBedrockConfigSchema, TavilyConfigSchema, CustomProviderConfigSchema, ProvidersSchema, AssistantSchema, TodoItemSchema, QuestionOptionSchema, QuestionSchema, ChatModeSchema, OperationModeSchema, AgentModeSchema, AgentNameSchema, ChatMetaSchema, FieldTypeSchema, TypeFieldSchema, TypeDefinitionSchema, ConfigSchema, KnowledgeEntrySchema, KnowledgeSchema, OperationStatusSchema, OperationKindSchema, OperationSchema2, MessageContentSchema, UsageSchema,
|
|
505617
|
+
var ReasoningLevelSchema, UserMemorySchema, UserSchema, OpenAIConfigSchema, OpenRouterConfigSchema, ReplicateConfigSchema, AWSBedrockConfigSchema, TavilyConfigSchema, CustomProviderConfigSchema, ProvidersSchema, AssistantSchema, TodoItemSchema, QuestionOptionSchema, QuestionSchema, ChatModeSchema, OperationModeSchema, AgentModeSchema, AgentNameSchema, ChatMetaSchema, FieldTypeSchema, TypeFieldSchema, TypeDefinitionSchema, ConfigSchema, KnowledgeEntrySchema, KnowledgeSchema, OperationStatusSchema, OperationKindSchema, OperationSchema2, ReasoningDetailSchema, ReasoningSchema, MessageContentTypeSchema, MessageContentSchema, UsageSchema, MessageSchema, ChatMessagesSchema, DataRecordSchema, DataFileSchema, SelectRecordSchema;
|
|
505354
505618
|
var init_schemas4 = __esm({
|
|
505355
505619
|
"src/schemas.ts"() {
|
|
505356
505620
|
"use strict";
|
|
505357
505621
|
init_zod();
|
|
505358
505622
|
init_constants();
|
|
505623
|
+
ReasoningLevelSchema = external_exports.enum(["none", "low", "medium", "high"]);
|
|
505359
505624
|
UserMemorySchema = external_exports.object({
|
|
505360
505625
|
text: external_exports.string(),
|
|
505361
505626
|
created: external_exports.number()
|
|
@@ -505388,7 +505653,8 @@ var init_schemas4 = __esm({
|
|
|
505388
505653
|
maxQuerySchemaTypes: external_exports.number().min(0).default(5),
|
|
505389
505654
|
showInput: external_exports.boolean().default(false),
|
|
505390
505655
|
showOutput: external_exports.boolean().default(false),
|
|
505391
|
-
showSystemMessages: external_exports.boolean().default(true)
|
|
505656
|
+
showSystemMessages: external_exports.boolean().default(true),
|
|
505657
|
+
reasoning: ReasoningLevelSchema.default("none")
|
|
505392
505658
|
});
|
|
505393
505659
|
OpenAIConfigSchema = external_exports.object({
|
|
505394
505660
|
apiKey: external_exports.string(),
|
|
@@ -505526,7 +505792,8 @@ var init_schemas4 = __esm({
|
|
|
505526
505792
|
created: external_exports.number(),
|
|
505527
505793
|
updated: external_exports.number(),
|
|
505528
505794
|
todos: external_exports.array(TodoItemSchema).default([]),
|
|
505529
|
-
questions: external_exports.array(QuestionSchema).default([])
|
|
505795
|
+
questions: external_exports.array(QuestionSchema).default([]),
|
|
505796
|
+
reasoning: ReasoningLevelSchema.nullable().default(null)
|
|
505530
505797
|
});
|
|
505531
505798
|
FieldTypeSchema = external_exports.union([external_exports.enum(["string", "number", "boolean", "date", "enum"]), external_exports.string()]);
|
|
505532
505799
|
TypeFieldSchema = external_exports.object({
|
|
@@ -505642,10 +505909,28 @@ var init_schemas4 = __esm({
|
|
|
505642
505909
|
error: external_exports.string().optional(),
|
|
505643
505910
|
message: external_exports.string().optional()
|
|
505644
505911
|
});
|
|
505912
|
+
ReasoningDetailSchema = external_exports.object({
|
|
505913
|
+
id: external_exports.string().nullable().optional(),
|
|
505914
|
+
type: external_exports.string(),
|
|
505915
|
+
format: external_exports.string(),
|
|
505916
|
+
index: external_exports.number().optional(),
|
|
505917
|
+
summary: external_exports.string().optional(),
|
|
505918
|
+
text: external_exports.string().optional(),
|
|
505919
|
+
data: external_exports.string().optional(),
|
|
505920
|
+
signature: external_exports.string().optional()
|
|
505921
|
+
});
|
|
505922
|
+
ReasoningSchema = external_exports.object({
|
|
505923
|
+
content: external_exports.string().optional().nullable(),
|
|
505924
|
+
details: external_exports.array(ReasoningDetailSchema).optional()
|
|
505925
|
+
});
|
|
505926
|
+
MessageContentTypeSchema = external_exports.enum(["text", "image", "file", "audio", "reasoning"]);
|
|
505645
505927
|
MessageContentSchema = external_exports.object({
|
|
505646
|
-
type:
|
|
505928
|
+
type: MessageContentTypeSchema,
|
|
505647
505929
|
content: external_exports.string(),
|
|
505648
|
-
|
|
505930
|
+
reasoning: ReasoningSchema.optional(),
|
|
505931
|
+
operationIndex: external_exports.number().optional(),
|
|
505932
|
+
created: external_exports.number().optional()
|
|
505933
|
+
// ideally not optional - but for backwards compatibility
|
|
505649
505934
|
});
|
|
505650
505935
|
UsageSchema = external_exports.object({
|
|
505651
505936
|
text: external_exports.object({
|
|
@@ -505680,12 +505965,6 @@ var init_schemas4 = __esm({
|
|
|
505680
505965
|
}).optional(),
|
|
505681
505966
|
cost: external_exports.number().optional()
|
|
505682
505967
|
}).optional();
|
|
505683
|
-
AgentRequest = external_exports.object({
|
|
505684
|
-
agent: AgentNameSchema,
|
|
505685
|
-
request: external_exports.string(),
|
|
505686
|
-
typeName: external_exports.string().optional(),
|
|
505687
|
-
simulateMode: OperationModeSchema.optional()
|
|
505688
|
-
});
|
|
505689
505968
|
MessageSchema = external_exports.object({
|
|
505690
505969
|
role: external_exports.enum(["user", "assistant", "system"]),
|
|
505691
505970
|
name: external_exports.string().optional(),
|
|
@@ -506497,7 +506776,7 @@ var init_clerk = __esm({
|
|
|
506497
506776
|
{
|
|
506498
506777
|
role: "system",
|
|
506499
506778
|
content: `You are a helpful assistant that edits file content. You will receive the current content and a request describing the changes. Respond with ONLY the new content, nothing else - no explanations, no markdown formatting, just the raw edited content.
|
|
506500
|
-
|
|
506779
|
+
|
|
506501
506780
|
${actualDescription}
|
|
506502
506781
|
|
|
506503
506782
|
<request>${input.request}</request>`
|
|
@@ -507080,9 +507359,9 @@ var init_clerk = __esm({
|
|
|
507080
507359
|
const isAudio = await isAudioFile(fullPath, filePath);
|
|
507081
507360
|
if (chatMessage) {
|
|
507082
507361
|
if (isAudio) {
|
|
507083
|
-
chatMessage.content.push({ type: "audio", content: fileLink });
|
|
507362
|
+
chatMessage.content.push({ type: "audio", content: fileLink, created: Date.now() });
|
|
507084
507363
|
} else {
|
|
507085
|
-
chatMessage.content.push({ type: "file", content: fileLink });
|
|
507364
|
+
chatMessage.content.push({ type: "file", content: fileLink, created: Date.now() });
|
|
507086
507365
|
}
|
|
507087
507366
|
}
|
|
507088
507367
|
return { fullPath, attached: true };
|
|
@@ -528806,7 +529085,7 @@ var init_manager2 = __esm({
|
|
|
528806
529085
|
update: 3,
|
|
528807
529086
|
delete: 4
|
|
528808
529087
|
};
|
|
528809
|
-
OperationManager = class {
|
|
529088
|
+
OperationManager = class _OperationManager {
|
|
528810
529089
|
constructor(mode, operations = [], onOperationAdded, onOperationUpdated) {
|
|
528811
529090
|
this.mode = mode;
|
|
528812
529091
|
this.operations = operations;
|
|
@@ -528918,28 +529197,37 @@ var init_manager2 = __esm({
|
|
|
528918
529197
|
* @param op - Operation to update
|
|
528919
529198
|
*/
|
|
528920
529199
|
updateMessage(op2) {
|
|
529200
|
+
const message = _OperationManager.getContent(op2);
|
|
529201
|
+
if (message !== op2.message) {
|
|
529202
|
+
op2.message = message;
|
|
529203
|
+
this.onOperationUpdated?.(op2, this.operations.indexOf(op2));
|
|
529204
|
+
}
|
|
529205
|
+
return op2.message;
|
|
529206
|
+
}
|
|
529207
|
+
/**
|
|
529208
|
+
* Get the content for an operation based on its state.
|
|
529209
|
+
*
|
|
529210
|
+
* @param op - Operation
|
|
529211
|
+
* @param prioritizeAnalysis - Whether to prioritize analysis content
|
|
529212
|
+
* @returns
|
|
529213
|
+
*/
|
|
529214
|
+
static getContent(op2, prioritizeAnalysis = false) {
|
|
528921
529215
|
const def = Operations[op2.type];
|
|
528922
|
-
|
|
528923
|
-
|
|
528924
|
-
|
|
528925
|
-
|
|
528926
|
-
|
|
529216
|
+
let content = "";
|
|
529217
|
+
if (op2.analysis && (prioritizeAnalysis || !def.content && !op2.error && op2.output === void 0)) {
|
|
529218
|
+
content = `${ANALYSIS_START}${formatValue(op2.analysis)}${ANALYSIS_END}`;
|
|
529219
|
+
} else if (def.content) {
|
|
529220
|
+
content = def.content(op2);
|
|
529221
|
+
} else if (op2.error) {
|
|
529222
|
+
content = `${ERROR_START}${op2.error}${ERROR_END}`;
|
|
529223
|
+
} else if (op2.output !== void 0) {
|
|
528927
529224
|
const outputFormat = def.outputFormat || "yaml";
|
|
528928
|
-
|
|
528929
|
-
|
|
528930
|
-
|
|
528931
|
-
if (op2.analysis && !op2.output) {
|
|
528932
|
-
op2.message += `${ANALYSIS_START}${formatValue(op2.analysis)}${ANALYSIS_END}`;
|
|
529225
|
+
content = `${OUTPUT_START}${formatValueWithFormat(op2.output, outputFormat)}${OUTPUT_END}`;
|
|
529226
|
+
if (def.instructions) {
|
|
529227
|
+
content += `${INSTRUCTIONS_START}${def.instructions}${INSTRUCTIONS_END}`;
|
|
528933
529228
|
}
|
|
528934
|
-
if (op2.output) {
|
|
528935
|
-
op2.message += `${OUTPUT_START}${formatValueWithFormat(op2.output, outputFormat)}${OUTPUT_END}`;
|
|
528936
|
-
}
|
|
528937
|
-
}
|
|
528938
|
-
if (def.instructions) {
|
|
528939
|
-
op2.message += `${INSTRUCTIONS_START}${def.instructions}${INSTRUCTIONS_END}`;
|
|
528940
529229
|
}
|
|
528941
|
-
|
|
528942
|
-
return op2.message;
|
|
529230
|
+
return content;
|
|
528943
529231
|
}
|
|
528944
529232
|
};
|
|
528945
529233
|
}
|
|
@@ -529125,6 +529413,9 @@ ${JSON.stringify(error47)}`);
|
|
|
529125
529413
|
if (value instanceof zod_default.ZodType) {
|
|
529126
529414
|
return toJSONSchema2(value, true);
|
|
529127
529415
|
}
|
|
529416
|
+
if (value instanceof Set) {
|
|
529417
|
+
return Array.from(value);
|
|
529418
|
+
}
|
|
529128
529419
|
return value;
|
|
529129
529420
|
};
|
|
529130
529421
|
const ai = AI.with().providers(providers).create({
|
|
@@ -534237,7 +534528,10 @@ Example usage for gathering project preferences:
|
|
|
534237
534528
|
]
|
|
534238
534529
|
}
|
|
534239
534530
|
|
|
534240
|
-
The user's answers will be formatted and submitted as a message, triggering the chat orchestrator to continue
|
|
534531
|
+
The user's answers will be formatted and submitted as a message, triggering the chat orchestrator to continue.
|
|
534532
|
+
|
|
534533
|
+
DO NOT use this tool for single, simple questions - only use it when you need to gather multiple pieces of information at once.
|
|
534534
|
+
DO NOT use this tool to ask for approval of operations - there is a separate mechanism for that.`,
|
|
534241
534535
|
schema: external_exports.object({
|
|
534242
534536
|
questions: external_exports.array(external_exports.object({
|
|
534243
534537
|
name: external_exports.string().describe("Short name for the question"),
|
|
@@ -534493,20 +534787,18 @@ Tools:
|
|
|
534493
534787
|
- If you need tools from a different toolset, use the 'retool' utility to switch or enable adaptive selection.
|
|
534494
534788
|
- The adaptive tool selection uses embedding similarity to find the most relevant tools for your current task.
|
|
534495
534789
|
- Use 'retool' with null to re-enable adaptive selection if you've been focused on a specific toolset.
|
|
534496
|
-
- Choose the simplest tool that accomplishes the task. Avoid over-engineering solutions.
|
|
534790
|
+
- Choose the simplest tool that accomplishes the task. Avoid over-engineering solutions.
|
|
534791
|
+
- Start with targeted tools before using more general ones if you aren't finding what you need.
|
|
534792
|
+
- AGGRESSIVELY use retool to switch toolsets as needed to accomplish user requests. If adaptive selection is enabled, the tool you need may not be available.
|
|
534497
534793
|
</rules>
|
|
534498
534794
|
|
|
534499
534795
|
<importantRules>
|
|
534500
|
-
- Assistant messages with <input> & <analysis> tags are preliminary tool outputs that is awaiting user approval or rejection before producing output. Do NOT treat these as final outputs. You will be notified when the user approves or rejects them.
|
|
534501
|
-
- Assistant messages with <output> tags are final results from approved operations. These can be presented to the user directly.
|
|
534502
|
-
- Don't present anything in <input>, <analysis>, or <output> tags - those are produced by the Cletus system and not by you even though they are marked as Assistant messages.
|
|
534503
534796
|
- Don't ask for permission to perform operations - if you need to do something, just do it. The user will be asked for approval automatically if needed.
|
|
534504
534797
|
- Todos are exclusively for Cletus's internal management of user requests. They are only referred to as todos - anything else should be assumed to be a separate data type.
|
|
534505
534798
|
- If you've executed ANY tools - DO NOT ask a question at the end of your response. You are either going to automatically continue your work OR the user will respond next. NEVER ask a question after executing tools. Only for clarifications.
|
|
534506
534799
|
</importantRules>
|
|
534507
534800
|
`,
|
|
534508
534801
|
tools: toolRegistry.getAllTools().map((t4) => t4.tool),
|
|
534509
|
-
// Dynamic tools based on adaptive selection using retool
|
|
534510
534802
|
retool: async (_3, ctx) => {
|
|
534511
534803
|
const activeTools = await getActiveTools(ctx);
|
|
534512
534804
|
return activeTools.map((t4) => t4.tool);
|
|
@@ -534519,6 +534811,14 @@ Tools:
|
|
|
534519
534811
|
}
|
|
534520
534812
|
},
|
|
534521
534813
|
dynamic: true,
|
|
534814
|
+
config: (_3, ctx) => {
|
|
534815
|
+
const request = {};
|
|
534816
|
+
const reasoning = ctx.chat?.reasoning || ctx.config.getData().user.reasoning || "none";
|
|
534817
|
+
if (reasoning !== "none") {
|
|
534818
|
+
request.reason = { effort: reasoning };
|
|
534819
|
+
}
|
|
534820
|
+
return request;
|
|
534821
|
+
},
|
|
534522
534822
|
metadataFn: (_3, { config: config3, chat }) => ({
|
|
534523
534823
|
model: chat?.model || config3.getData().user.models?.chat
|
|
534524
534824
|
}),
|
|
@@ -534583,7 +534883,7 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534583
534883
|
});
|
|
534584
534884
|
};
|
|
534585
534885
|
try {
|
|
534586
|
-
const currentMessages = await Promise.all(messages.filter((msg) => msg.role !== "system").map(convertMessage));
|
|
534886
|
+
const currentMessages = (await Promise.all(messages.filter((msg) => msg.role !== "system").map(convertMessage))).flat();
|
|
534587
534887
|
let loopIteration = 0;
|
|
534588
534888
|
let chatInterrupted = false;
|
|
534589
534889
|
while (loopIteration < loopMax) {
|
|
@@ -534606,25 +534906,25 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534606
534906
|
created: Date.now(),
|
|
534607
534907
|
operations: []
|
|
534608
534908
|
};
|
|
534609
|
-
const
|
|
534909
|
+
const getLastContent = (type, forceNew = false) => {
|
|
534610
534910
|
if (forceNew) {
|
|
534611
|
-
const newContent2 = { type: "
|
|
534911
|
+
const newContent2 = { type, content: "", created: Date.now() };
|
|
534612
534912
|
pending.content.push(newContent2);
|
|
534613
534913
|
lastTextIndex = pending.content.length - 1;
|
|
534614
534914
|
return newContent2;
|
|
534615
534915
|
}
|
|
534616
534916
|
const last2 = pending.content[pending.content.length - 1];
|
|
534617
|
-
if (last2 && last2.type ===
|
|
534917
|
+
if (last2 && last2.type === type && last2.operationIndex === void 0) {
|
|
534618
534918
|
lastTextIndex = pending.content.length - 1;
|
|
534619
534919
|
return last2;
|
|
534620
534920
|
}
|
|
534621
|
-
const newContent = { type: "
|
|
534921
|
+
const newContent = { type, content: "", created: Date.now() };
|
|
534622
534922
|
pending.content.push(newContent);
|
|
534623
534923
|
lastTextIndex = pending.content.length - 1;
|
|
534624
534924
|
return newContent;
|
|
534625
534925
|
};
|
|
534626
534926
|
const updateEstimatedTextOutputTokens = () => {
|
|
534627
|
-
const totalTextLength = pending.content.filter((c4) => c4.type === "text" && c4.operationIndex === void 0).reduce((sum, c4) => sum + c4.content.length, 0);
|
|
534927
|
+
const totalTextLength = pending.content.filter((c4) => (c4.type === "text" || c4.type === "reasoning") && c4.operationIndex === void 0).reduce((sum, c4) => sum + c4.content.length, 0);
|
|
534628
534928
|
const estimatedTokens = Math.ceil(totalTextLength / 4);
|
|
534629
534929
|
if (!currentUsage.text) {
|
|
534630
534930
|
currentUsage.text = {};
|
|
@@ -534636,7 +534936,7 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534636
534936
|
chatMeta.mode,
|
|
534637
534937
|
pending.operations,
|
|
534638
534938
|
(op2, operationIndex) => {
|
|
534639
|
-
pending.content.push({ type: "text", content: op2.message || "", operationIndex });
|
|
534939
|
+
pending.content.push({ type: "text", content: op2.message || "", operationIndex, created: Date.now() });
|
|
534640
534940
|
onEvent({ type: "pendingUpdate", pending });
|
|
534641
534941
|
},
|
|
534642
534942
|
(op2, operationIndex) => {
|
|
@@ -534712,7 +535012,7 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534712
535012
|
switch (chunk3.type) {
|
|
534713
535013
|
case "textPartial":
|
|
534714
535014
|
{
|
|
534715
|
-
const lastContent =
|
|
535015
|
+
const lastContent = getLastContent("text");
|
|
534716
535016
|
lastContent.content += chunk3.content;
|
|
534717
535017
|
updateEstimatedTextOutputTokens();
|
|
534718
535018
|
onEvent({ type: "pendingUpdate", pending });
|
|
@@ -534722,20 +535022,26 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534722
535022
|
break;
|
|
534723
535023
|
case "text":
|
|
534724
535024
|
{
|
|
534725
|
-
|
|
534726
|
-
|
|
534727
|
-
|
|
534728
|
-
|
|
535025
|
+
}
|
|
535026
|
+
break;
|
|
535027
|
+
case "reasonPartial":
|
|
535028
|
+
{
|
|
535029
|
+
const reasoningText = getReasoningText(chunk3.reasoning);
|
|
535030
|
+
if (!pending.content.some((c4) => c4.type === "reasoning" && getReasoningText(c4.reasoning) === reasoningText)) {
|
|
535031
|
+
const lastContent = getLastContent("reasoning");
|
|
535032
|
+
lastContent.reasoning = chunk3.reasoning;
|
|
535033
|
+
const status = chunk3.reasoning.details?.find((d4) => d4.type === "reasoning.summary")?.summary || "Thinking...";
|
|
535034
|
+
onEvent({ type: "pendingUpdate", pending });
|
|
535035
|
+
onEvent({ type: "status", status });
|
|
534729
535036
|
}
|
|
534730
|
-
|
|
534731
|
-
|
|
534732
|
-
|
|
535037
|
+
}
|
|
535038
|
+
break;
|
|
535039
|
+
case "reason":
|
|
535040
|
+
{
|
|
534733
535041
|
}
|
|
534734
535042
|
break;
|
|
534735
535043
|
case "toolOutput":
|
|
534736
535044
|
{
|
|
534737
|
-
getLastTextContent(true);
|
|
534738
|
-
onEvent({ type: "pendingUpdate", pending });
|
|
534739
535045
|
}
|
|
534740
535046
|
break;
|
|
534741
535047
|
case "toolParseName":
|
|
@@ -534760,14 +535066,6 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534760
535066
|
currentUsage.text.output = chunk3.tokens;
|
|
534761
535067
|
updateUsageEvent();
|
|
534762
535068
|
break;
|
|
534763
|
-
case "reason":
|
|
534764
|
-
const reasoningTokens = Math.ceil(chunk3.content.length / 4);
|
|
534765
|
-
if (!currentUsage.reasoning) {
|
|
534766
|
-
currentUsage.reasoning = {};
|
|
534767
|
-
}
|
|
534768
|
-
currentUsage.reasoning.output = reasoningTokens;
|
|
534769
|
-
updateUsageEvent();
|
|
534770
|
-
break;
|
|
534771
535069
|
case "toolStart":
|
|
534772
535070
|
toolTokens += Math.ceil((chunk3.tool.name.length + JSON.stringify(chunk3.args).length) / 4);
|
|
534773
535071
|
updateEstimatedTextOutputTokens();
|
|
@@ -534789,18 +535087,20 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534789
535087
|
}
|
|
534790
535088
|
} finally {
|
|
534791
535089
|
await chatResponse.return?.(void 0);
|
|
534792
|
-
|
|
534793
|
-
|
|
534794
|
-
|
|
534795
|
-
|
|
534796
|
-
|
|
534797
|
-
|
|
534798
|
-
|
|
534799
|
-
|
|
534800
|
-
|
|
534801
|
-
|
|
534802
|
-
|
|
534803
|
-
|
|
535090
|
+
if (stackTrace) {
|
|
535091
|
+
logger.log(`Cletus trace: ${JSON.stringify(stackTrace, (k4, v5) => {
|
|
535092
|
+
if (k4 === "context" || k4 === "parent") {
|
|
535093
|
+
return void 0;
|
|
535094
|
+
}
|
|
535095
|
+
if (k4 === "component") {
|
|
535096
|
+
return v5.name;
|
|
535097
|
+
}
|
|
535098
|
+
if ((k4 === "started" || k4 === "completed") && typeof v5 === "number") {
|
|
535099
|
+
return new Date(v5).toISOString();
|
|
535100
|
+
}
|
|
535101
|
+
return v5;
|
|
535102
|
+
}, 2)}`);
|
|
535103
|
+
}
|
|
534804
535104
|
const endUsage = getUsage();
|
|
534805
535105
|
messageUsage = {};
|
|
534806
535106
|
const endAccumulated = endUsage.accumulated;
|
|
@@ -534840,7 +535140,7 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534840
535140
|
if (needsApproval || noOperations || noTodos || chatInterrupted) {
|
|
534841
535141
|
break;
|
|
534842
535142
|
}
|
|
534843
|
-
currentMessages.push(await convertMessage(pending));
|
|
535143
|
+
currentMessages.push(...await convertMessage(pending));
|
|
534844
535144
|
loopIteration++;
|
|
534845
535145
|
currentUsage = {};
|
|
534846
535146
|
}
|
|
@@ -534851,7 +535151,7 @@ async function runChatOrchestrator(options2, onEvent) {
|
|
|
534851
535151
|
} catch (error47) {
|
|
534852
535152
|
if (error47.message !== "Aborted") {
|
|
534853
535153
|
logger.log(`orchestrator: error - ${JSON.stringify(error47)}`);
|
|
534854
|
-
onEvent({ type: "error", error: error47.message });
|
|
535154
|
+
onEvent({ type: "error", error: error47.error?.message || error47.message || String(error47) });
|
|
534855
535155
|
}
|
|
534856
535156
|
} finally {
|
|
534857
535157
|
logger.log("orchestrator: finished");
|
|
@@ -535056,7 +535356,8 @@ var init_config2 = __esm({
|
|
|
535056
535356
|
maxQuerySchemaTypes: 5,
|
|
535057
535357
|
showInput: false,
|
|
535058
535358
|
showOutput: false,
|
|
535059
|
-
showSystemMessages: true
|
|
535359
|
+
showSystemMessages: true,
|
|
535360
|
+
reasoning: "none"
|
|
535060
535361
|
},
|
|
535061
535362
|
providers: {
|
|
535062
535363
|
openai: null,
|
|
@@ -539038,6 +539339,14 @@ var init_connection_registry = __esm({
|
|
|
539038
539339
|
});
|
|
539039
539340
|
|
|
539040
539341
|
// src/browser/broadcast-manager.ts
|
|
539342
|
+
function serialize2(obj2) {
|
|
539343
|
+
return JSON.stringify(obj2, (k4, v5) => {
|
|
539344
|
+
if (v5 instanceof Set) {
|
|
539345
|
+
return { __type: "Set", values: Array.from(v5) };
|
|
539346
|
+
}
|
|
539347
|
+
return v5;
|
|
539348
|
+
});
|
|
539349
|
+
}
|
|
539041
539350
|
var BroadcastManager;
|
|
539042
539351
|
var init_broadcast_manager = __esm({
|
|
539043
539352
|
"src/browser/broadcast-manager.ts"() {
|
|
@@ -539052,7 +539361,7 @@ var init_broadcast_manager = __esm({
|
|
|
539052
539361
|
*/
|
|
539053
539362
|
broadcastToChat(chatId, message) {
|
|
539054
539363
|
const clients = this.registry.getClientsForChat(chatId);
|
|
539055
|
-
const messageStr =
|
|
539364
|
+
const messageStr = serialize2(message);
|
|
539056
539365
|
for (const ws of clients) {
|
|
539057
539366
|
if (ws.readyState === 1) {
|
|
539058
539367
|
ws.send(messageStr);
|
|
@@ -539066,7 +539375,8 @@ var init_broadcast_manager = __esm({
|
|
|
539066
539375
|
const connection = this.registry.getConnection(connectionId);
|
|
539067
539376
|
if (!connection) return;
|
|
539068
539377
|
if (connection.ws.readyState === 1) {
|
|
539069
|
-
|
|
539378
|
+
const serialized = serialize2(message);
|
|
539379
|
+
connection.ws.send(serialized);
|
|
539070
539380
|
}
|
|
539071
539381
|
}
|
|
539072
539382
|
/**
|
|
@@ -539382,7 +539692,21 @@ async function handleWebSocketConnection(ws) {
|
|
|
539382
539692
|
const messages = chatFile.getMessages();
|
|
539383
539693
|
const lastAssistantMsg = messages.filter((m4) => m4.role === "assistant").pop();
|
|
539384
539694
|
if (lastAssistantMsg) {
|
|
539695
|
+
if (event.error) {
|
|
539696
|
+
let lastText = lastAssistantMsg.content[lastAssistantMsg.content.length - 1];
|
|
539697
|
+
if (!lastText || lastText.type !== "text") {
|
|
539698
|
+
lastText = { type: "text", content: "", created: Date.now() };
|
|
539699
|
+
lastAssistantMsg.content.push(lastText);
|
|
539700
|
+
}
|
|
539701
|
+
lastText.content += `
|
|
539702
|
+
|
|
539703
|
+
**Error:** ${event.error}`;
|
|
539704
|
+
}
|
|
539385
539705
|
await chatFile.updateMessage(lastAssistantMsg);
|
|
539706
|
+
broadcastManager.broadcastToChat(chatId, {
|
|
539707
|
+
type: "message_updated",
|
|
539708
|
+
data: { chatId, message: lastAssistantMsg }
|
|
539709
|
+
});
|
|
539386
539710
|
}
|
|
539387
539711
|
});
|
|
539388
539712
|
break;
|
|
@@ -539457,7 +539781,7 @@ async function handleWebSocketConnection(ws) {
|
|
|
539457
539781
|
const { name } = message.data;
|
|
539458
539782
|
await withConfigUpdate(async (config4) => {
|
|
539459
539783
|
const now = Date.now();
|
|
539460
|
-
const chatId = new Date(now).toISOString().replace(/[-:]/g, "").slice(0, 15);
|
|
539784
|
+
const chatId = new Date(now).toISOString().replace(/[-:]/g, "").replace(/T/, "-").slice(0, 15);
|
|
539461
539785
|
const newChat = {
|
|
539462
539786
|
id: chatId,
|
|
539463
539787
|
title: name,
|
|
@@ -539470,7 +539794,8 @@ async function handleWebSocketConnection(ws) {
|
|
|
539470
539794
|
todos: [],
|
|
539471
539795
|
questions: [],
|
|
539472
539796
|
toolset: void 0,
|
|
539473
|
-
model: void 0
|
|
539797
|
+
model: void 0,
|
|
539798
|
+
reasoning: null
|
|
539474
539799
|
};
|
|
539475
539800
|
await config4.addChat(newChat);
|
|
539476
539801
|
const chatFile = new ChatFile(chatId);
|
|
@@ -539709,9 +540034,7 @@ async function handleWebSocketConnection(ws) {
|
|
|
539709
540034
|
(op2, opIndex) => {
|
|
539710
540035
|
const contentIndex = targetMessage.content.findIndex((c4) => c4.operationIndex === opIndex);
|
|
539711
540036
|
if (contentIndex !== -1) {
|
|
539712
|
-
|
|
539713
|
-
content.content = op2.message || "";
|
|
539714
|
-
targetMessage.content.push(content);
|
|
540037
|
+
targetMessage.content[contentIndex].content = op2.message || "";
|
|
539715
540038
|
chatFile.updateMessage(targetMessage);
|
|
539716
540039
|
broadcastMessageUpdate();
|
|
539717
540040
|
}
|
|
@@ -539760,6 +540083,9 @@ async function handleWebSocketConnection(ws) {
|
|
|
539760
540083
|
operations[idx].status = previousStatus[idx] || "analyzed";
|
|
539761
540084
|
await manager.execute(operations[idx], true, ctx);
|
|
539762
540085
|
hasExecutedOperations = true;
|
|
540086
|
+
if (abortController.signal.aborted) {
|
|
540087
|
+
break;
|
|
540088
|
+
}
|
|
539763
540089
|
}
|
|
539764
540090
|
}
|
|
539765
540091
|
chatOperationManager.completeOperation(chatId);
|
|
@@ -539840,7 +540166,7 @@ async function handleWebSocketConnection(ws) {
|
|
|
539840
540166
|
const questionMessage = {
|
|
539841
540167
|
role: "assistant",
|
|
539842
540168
|
name: chatMeta.assistant,
|
|
539843
|
-
content: [{ type: "text", content: questionText.trim() }],
|
|
540169
|
+
content: [{ type: "text", content: questionText.trim(), created: Date.now() }],
|
|
539844
540170
|
created: Date.now(),
|
|
539845
540171
|
operations: []
|
|
539846
540172
|
};
|
|
@@ -539852,7 +540178,7 @@ async function handleWebSocketConnection(ws) {
|
|
|
539852
540178
|
const answerMessage = {
|
|
539853
540179
|
role: "user",
|
|
539854
540180
|
name: config4.getData().user.name,
|
|
539855
|
-
content: [{ type: "text", content: answerText.trim() }],
|
|
540181
|
+
content: [{ type: "text", content: answerText.trim(), created: Date.now() }],
|
|
539856
540182
|
created: Date.now()
|
|
539857
540183
|
};
|
|
539858
540184
|
await chatFile.addMessage(answerMessage);
|
|
@@ -540111,6 +540437,7 @@ init_theme();
|
|
|
540111
540437
|
init_types9();
|
|
540112
540438
|
init_Markdown();
|
|
540113
540439
|
init_common5();
|
|
540440
|
+
init_src();
|
|
540114
540441
|
import { Box as Box4, Text as Text6 } from "ink";
|
|
540115
540442
|
import React6 from "react";
|
|
540116
540443
|
var MessageDisplay = ({ message, ai, showInput = false, showOutput = false }) => {
|
|
@@ -540130,7 +540457,7 @@ var MessageDisplay = ({ message, ai, showInput = false, showOutput = false }) =>
|
|
|
540130
540457
|
circleColor = COLORS.STATUS_IN_PROGRESS;
|
|
540131
540458
|
}
|
|
540132
540459
|
const mappedContent = message.content.map((c4) => ({ ...c4, operation: c4.operationIndex !== void 0 ? message.operations?.[c4.operationIndex] : void 0 }));
|
|
540133
|
-
const visibleContent = mappedContent.filter((c4) => (c4.content.trim().length > 0 || c4.operation) && c4.type === "text");
|
|
540460
|
+
const visibleContent = mappedContent.filter((c4) => (c4.content.trim().length > 0 || c4.operation || !!getReasoningText(c4.reasoning)) && (c4.type === "text" || c4.type === "reasoning"));
|
|
540134
540461
|
return /* @__PURE__ */ React6.createElement(Box4, { flexDirection: "column", marginBottom: 1, flexGrow: 1 }, /* @__PURE__ */ React6.createElement(Box4, null, /* @__PURE__ */ React6.createElement(Text6, { color: circleColor }, "\u25CF "), /* @__PURE__ */ React6.createElement(Text6, { bold: true, color: color2 }, prefix, ":")), isUser ? /* @__PURE__ */ React6.createElement(Box4, { borderStyle: "round", flexDirection: "row", flexGrow: 1 }, /* @__PURE__ */ React6.createElement(Box4, { width: 1 }, /* @__PURE__ */ React6.createElement(Text6, null, ">")), /* @__PURE__ */ React6.createElement(Box4, { flexDirection: "column", marginX: 1 }, message.content.map((part, i4) => /* @__PURE__ */ React6.createElement(Markdown, { key: i4 }, part.content)))) : /* @__PURE__ */ React6.createElement(Box4, { flexDirection: "column", marginLeft: 1, flexGrow: 1 }, visibleContent.map((c4, i4) => {
|
|
540135
540462
|
if (c4.operation) {
|
|
540136
540463
|
const operationDef = Operations[c4.operation.type];
|
|
@@ -540139,6 +540466,9 @@ var MessageDisplay = ({ message, ai, showInput = false, showOutput = false }) =>
|
|
|
540139
540466
|
} else {
|
|
540140
540467
|
return /* @__PURE__ */ React6.createElement(Box4, { key: i4, marginBottom: 1 }, /* @__PURE__ */ React6.createElement(Text6, { dimColor: true }, "[", formatName(c4.operation.type), "] - [", c4.operation.status, "]"));
|
|
540141
540468
|
}
|
|
540469
|
+
} else if (c4.type === "reasoning") {
|
|
540470
|
+
const content = getReasoningText(c4.reasoning);
|
|
540471
|
+
return /* @__PURE__ */ React6.createElement(Box4, { key: i4, marginBottom: 1, borderStyle: "round", borderColor: "yellow", paddingX: 1 }, /* @__PURE__ */ React6.createElement(Markdown, null, content));
|
|
540142
540472
|
} else {
|
|
540143
540473
|
return /* @__PURE__ */ React6.createElement(Markdown, { key: i4, marginBottom: 1, flexGrow: 1 }, c4.content);
|
|
540144
540474
|
}
|
|
@@ -540587,9 +540917,7 @@ var OperationApprovalMenu = ({
|
|
|
540587
540917
|
const updateMessageContent = (op2, operationIndex) => {
|
|
540588
540918
|
const contentIndex = message.content.findIndex((c4) => c4.operationIndex === operationIndex);
|
|
540589
540919
|
if (contentIndex !== -1) {
|
|
540590
|
-
|
|
540591
|
-
content.content = op2.message || "";
|
|
540592
|
-
message.content.push(content);
|
|
540920
|
+
message.content[contentIndex].content = op2.message || "";
|
|
540593
540921
|
onMessageUpdate?.(message);
|
|
540594
540922
|
}
|
|
540595
540923
|
};
|
|
@@ -541013,6 +541341,7 @@ var COMMANDS = [
|
|
|
541013
541341
|
{ name: "/model", description: "Select chat model", takesInput: false },
|
|
541014
541342
|
{ name: "/prompt", description: "Set custom prompt", takesInput: true, placeholder: "your prompt" },
|
|
541015
541343
|
{ name: "/title", description: "Change chat title", takesInput: true, placeholder: "new title" },
|
|
541344
|
+
{ name: "/reasoning", description: "Set reasoning level", takesInput: true, optionalInput: true, placeholder: "default|none|low|medium|high" },
|
|
541016
541345
|
{ name: "/todos", description: "View todos", takesInput: false },
|
|
541017
541346
|
{ name: "/do", description: "Add a todo", takesInput: true, placeholder: "todo description" },
|
|
541018
541347
|
{ name: "/done", description: "Mark a todo as done", takesInput: true, placeholder: "todo number" },
|
|
@@ -541122,7 +541451,7 @@ var ChatUI = ({ chat, config: config3, messages, onExit, onChatUpdate }) => {
|
|
|
541122
541451
|
return { accumulated: {}, accumulatedCost: 0 };
|
|
541123
541452
|
};
|
|
541124
541453
|
const addSystemMessage = (content) => {
|
|
541125
|
-
addMessage({ role: "system", content: [{ type: "text", content }], created: Date.now() });
|
|
541454
|
+
addMessage({ role: "system", content: [{ type: "text", content, created: Date.now() }], created: Date.now() });
|
|
541126
541455
|
};
|
|
541127
541456
|
const submitQuestionAnswers = async () => {
|
|
541128
541457
|
if (!chatMeta.questions || chatMeta.questions.length === 0) {
|
|
@@ -541176,14 +541505,14 @@ var ChatUI = ({ chat, config: config3, messages, onExit, onChatUpdate }) => {
|
|
|
541176
541505
|
addMessage({
|
|
541177
541506
|
role: "assistant",
|
|
541178
541507
|
name: chatMeta.assistant,
|
|
541179
|
-
content: [{ type: "text", content: questionText.trim() }],
|
|
541508
|
+
content: [{ type: "text", content: questionText.trim(), created: Date.now() }],
|
|
541180
541509
|
created: Date.now(),
|
|
541181
541510
|
operations: []
|
|
541182
541511
|
});
|
|
541183
541512
|
addMessage({
|
|
541184
541513
|
role: "user",
|
|
541185
541514
|
name: config3.getData().user.name,
|
|
541186
|
-
content: [{ type: "text", content: answerText.trim() }],
|
|
541515
|
+
content: [{ type: "text", content: answerText.trim(), created: Date.now() }],
|
|
541187
541516
|
created: Date.now()
|
|
541188
541517
|
});
|
|
541189
541518
|
await handleExecution();
|
|
@@ -541338,6 +541667,16 @@ var ChatUI = ({ chat, config: config3, messages, onExit, onChatUpdate }) => {
|
|
|
541338
541667
|
setChatMeta({ ...chatMeta, mode: newMode });
|
|
541339
541668
|
return interceptInput();
|
|
541340
541669
|
}
|
|
541670
|
+
if (key.meta && input === "r" && !isWaitingForResponse) {
|
|
541671
|
+
const levels = [null, "none", "low", "medium", "high"];
|
|
541672
|
+
const currentReasoning = chatMeta.reasoning;
|
|
541673
|
+
const currentIndex = levels.indexOf(currentReasoning);
|
|
541674
|
+
const nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % levels.length;
|
|
541675
|
+
const newReasoning = levels[nextIndex];
|
|
541676
|
+
onChatUpdate({ reasoning: newReasoning });
|
|
541677
|
+
setChatMeta({ ...chatMeta, reasoning: newReasoning });
|
|
541678
|
+
return interceptInput();
|
|
541679
|
+
}
|
|
541341
541680
|
if (key.meta && input === "m" && !isWaitingForResponse) {
|
|
541342
541681
|
const newAgentMode = chatMeta.agentMode === "plan" ? "default" : "plan";
|
|
541343
541682
|
onChatUpdate({ agentMode: newAgentMode });
|
|
@@ -541577,6 +541916,7 @@ AVAILABLE COMMANDS:
|
|
|
541577
541916
|
/model - Select a different AI model for this chat
|
|
541578
541917
|
/prompt - View or set a custom system prompt
|
|
541579
541918
|
/title - Change the chat title
|
|
541919
|
+
/reasoning - View or change the reasoning level (default/none/low/medium/high)
|
|
541580
541920
|
/transcribe - Voice input (press ESC or wait for silence to stop)
|
|
541581
541921
|
/todos - View all todos
|
|
541582
541922
|
/do - Add a new todo
|
|
@@ -541590,6 +541930,7 @@ KEYBOARD SHORTCUTS:
|
|
|
541590
541930
|
\u2022 Ctrl+C - Exit chat
|
|
541591
541931
|
\u2022 ESC - Interrupt AI response or stop transcription
|
|
541592
541932
|
\u2022 ${altKeyLabel}+C - Cycle through chat modes
|
|
541933
|
+
\u2022 ${altKeyLabel}+R - Cycle through reasoning levels
|
|
541593
541934
|
\u2022 ${altKeyLabel}+T - Start/stop voice transcription
|
|
541594
541935
|
\u2022 ${altKeyLabel}+M - Toggle agent mode (default/plan)
|
|
541595
541936
|
\u2022 ${altKeyLabel}+I - Toggle operation input details
|
|
@@ -541721,6 +542062,18 @@ ${todoList}`);
|
|
|
541721
542062
|
setShowClearConfirmation(true);
|
|
541722
542063
|
setClearConfirmationIndex(0);
|
|
541723
542064
|
break;
|
|
542065
|
+
case "/reasoning":
|
|
542066
|
+
if (args && ["default", "none", "low", "medium", "high"].includes(args)) {
|
|
542067
|
+
const reasoningValue = args === "default" ? void 0 : args;
|
|
542068
|
+
await onChatUpdate({ reasoning: reasoningValue });
|
|
542069
|
+
setChatMeta({ ...chatMeta, reasoning: reasoningValue });
|
|
542070
|
+
addSystemMessage(`\u2713 Reasoning level changed to: ${args}`);
|
|
542071
|
+
} else if (args) {
|
|
542072
|
+
addSystemMessage(`\u274C Invalid reasoning level. Valid options: default, none, low, medium, high`);
|
|
542073
|
+
} else {
|
|
542074
|
+
addSystemMessage(`Current reasoning level: ${chatMeta.reasoning || "default (user preference)"}. Valid options: default, none, low, medium, high`);
|
|
542075
|
+
}
|
|
542076
|
+
break;
|
|
541724
542077
|
default:
|
|
541725
542078
|
addSystemMessage(`\u274C Unknown command: ${cmd}`);
|
|
541726
542079
|
}
|
|
@@ -541970,7 +542323,7 @@ After installation and the SoX executable is in the path, restart Cletus and try
|
|
|
541970
542323
|
addMessage({
|
|
541971
542324
|
role: "user",
|
|
541972
542325
|
name: config3.getData().user.name,
|
|
541973
|
-
content: [{ type: "text", content: inputValue }],
|
|
542326
|
+
content: [{ type: "text", content: inputValue, created: Date.now() }],
|
|
541974
542327
|
created: Date.now()
|
|
541975
542328
|
});
|
|
541976
542329
|
setHistoryIndex(-1);
|
|
@@ -542140,7 +542493,7 @@ After installation and the SoX executable is in the path, restart Cletus and try
|
|
|
542140
542493
|
flexDirection: "column"
|
|
542141
542494
|
},
|
|
542142
542495
|
/* @__PURE__ */ React9.createElement(Text9, { bold: true, color: "cyan" }, "Quick Help (ESC to close):"),
|
|
542143
|
-
/* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React9.createElement(Text9, { bold: true, color: "cyan" }, "Shortcuts:"), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "row", gap: 2 }, /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Enter: send"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Shift+Enter: newline"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Ctrl+C: exit"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "ESC: interrupt")), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginLeft: 2 }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+C: cycle chat mode"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+T: transcribe"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+M: toggle agent mode"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+I: toggle inputs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+O: toggle outputs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+S: toggle system msgs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+\u2191\u2193: message history"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "/: commands ?: help")))),
|
|
542496
|
+
/* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React9.createElement(Text9, { bold: true, color: "cyan" }, "Shortcuts:"), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "row", gap: 2 }, /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Enter: send"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Shift+Enter: newline"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "Ctrl+C: exit"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "ESC: interrupt")), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginLeft: 2 }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+C: cycle chat mode"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+R: cycle reasoning"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+T: transcribe"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+M: toggle agent mode"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+I: toggle inputs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+O: toggle outputs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+S: toggle system msgs"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, altKeyLabel, "+\u2191\u2193: message history"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "/: commands ?: help")))),
|
|
542144
542497
|
/* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React9.createElement(Text9, { bold: true, color: "cyan" }, "Chat Modes:"), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "row", gap: 2 }, /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "none: local only"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "read: +read ops"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "create: +create ops")), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginLeft: 2 }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "update: +update ops"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "delete: +all ops"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "(use /mode to change)")))),
|
|
542145
542498
|
/* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React9.createElement(Text9, { bold: true, color: "cyan" }, "Agent Modes:"), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "row", gap: 2 }, /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "default: run mode"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "plan: plan mode")), /* @__PURE__ */ React9.createElement(Box7, { flexDirection: "column", marginLeft: 2 }, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "(", altKeyLabel, "+M to toggle)"))))
|
|
542146
542499
|
), (currentStatus || isWaitingForResponse) && /* @__PURE__ */ React9.createElement(Box7, null, currentStatus && /* @__PURE__ */ React9.createElement(Box7, { marginRight: 2 }, /* @__PURE__ */ React9.createElement(InkAnimatedText, { text: currentStatus })), isWaitingForResponse && /* @__PURE__ */ React9.createElement(Box7, null, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "( "), /* @__PURE__ */ React9.createElement(Text9, { color: "cyan" }, (elapsedTime / 1e3).toFixed(1), "s"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, " \u2502 "), /* @__PURE__ */ React9.createElement(Text9, { color: "green" }, "~", tokenCount >= 1e3 ? (tokenCount / 1e3).toFixed(1) + "k" : tokenCount.toFixed(0), " tokens"), accumulatedCost > 0 && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, " \u2502 "), /* @__PURE__ */ React9.createElement(Text9, { color: "yellow" }, "$", accumulatedCost.toFixed(4))), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, " \u2502 "), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, "esc to interrupt"), /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, " )"))), lastAssistantMessage && showApprovalMenu && /* @__PURE__ */ React9.createElement(
|
|
@@ -542178,7 +542531,7 @@ After installation and the SoX executable is in the path, restart Cletus and try
|
|
|
542178
542531
|
focus: !showExitPrompt && !operationApprovalPending
|
|
542179
542532
|
}
|
|
542180
542533
|
))
|
|
542181
|
-
), /* @__PURE__ */ React9.createElement(Box7, null, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, chatMeta.model || config3.getData().user.models?.chat || "no model", " \u2502 ", chatMeta.assistant ? `${chatMeta.assistant} \u2502 ` : "", MODETEXT[chatMeta.mode], " \u2502 ", AGENTMODETEXT[chatMeta.agentMode || "default"], " \u2502 ", chatMeta.toolset ? `${chatMeta.toolset} toolset` : "adaptive tools", " \u2502 ", chatMessages.length, " message", chatMessages.length !== 1 ? "s" : "", " \u2502", " ", chatMeta.todos.length ? `${chatMeta.todos.length} todo${chatMeta.todos.length !== 1 ? "s" : ""}` : "no todos", totalMessageCost > 0 && /* @__PURE__ */ React9.createElement(React9.Fragment, null, " \u2502 ", /* @__PURE__ */ React9.createElement(Text9, { color: "yellow" }, "$", totalMessageCost.toFixed(4))))));
|
|
542534
|
+
), /* @__PURE__ */ React9.createElement(Box7, null, /* @__PURE__ */ React9.createElement(Text9, { dimColor: true }, chatMeta.model || config3.getData().user.models?.chat || "no model", " \u2502 ", chatMeta.assistant ? `${chatMeta.assistant} \u2502 ` : "", MODETEXT[chatMeta.mode], " \u2502 ", AGENTMODETEXT[chatMeta.agentMode || "default"], " \u2502 reasoning: ", chatMeta.reasoning === void 0 ? "default" : chatMeta.reasoning, " \u2502 ", chatMeta.toolset ? `${chatMeta.toolset} toolset` : "adaptive tools", " \u2502 ", chatMessages.length, " message", chatMessages.length !== 1 ? "s" : "", " \u2502", " ", chatMeta.todos.length ? `${chatMeta.todos.length} todo${chatMeta.todos.length !== 1 ? "s" : ""}` : "no todos", totalMessageCost > 0 && /* @__PURE__ */ React9.createElement(React9.Fragment, null, " \u2502 ", /* @__PURE__ */ React9.createElement(Text9, { color: "yellow" }, "$", totalMessageCost.toFixed(4))))));
|
|
542182
542535
|
};
|
|
542183
542536
|
|
|
542184
542537
|
// src/components/InkChatView.tsx
|
|
@@ -542255,6 +542608,11 @@ var InkInitWizard = ({ onComplete }) => {
|
|
|
542255
542608
|
setApiKey("");
|
|
542256
542609
|
setError(null);
|
|
542257
542610
|
}, [step]);
|
|
542611
|
+
React11.useEffect(() => {
|
|
542612
|
+
if (step === "aws-test" && awsTestStatus === "idle") {
|
|
542613
|
+
testAWSCredentials();
|
|
542614
|
+
}
|
|
542615
|
+
}, [step]);
|
|
542258
542616
|
const testAWSCredentials = async () => {
|
|
542259
542617
|
setAwsTestStatus("testing");
|
|
542260
542618
|
setAwsTestMessage("Testing AWS credentials...");
|
|
@@ -542474,11 +542832,6 @@ var InkInitWizard = ({ onComplete }) => {
|
|
|
542474
542832
|
)), error47 && /* @__PURE__ */ React11.createElement(Box9, { marginTop: 1 }, /* @__PURE__ */ React11.createElement(Text11, { color: "red" }, error47)), /* @__PURE__ */ React11.createElement(Box9, { marginTop: 1 }, /* @__PURE__ */ React11.createElement(Text11, { dimColor: true }, "Enter to continue, ESC to skip")));
|
|
542475
542833
|
}
|
|
542476
542834
|
if (step === "aws-test") {
|
|
542477
|
-
React11.useEffect(() => {
|
|
542478
|
-
if (awsTestStatus === "idle") {
|
|
542479
|
-
testAWSCredentials();
|
|
542480
|
-
}
|
|
542481
|
-
}, []);
|
|
542482
542835
|
if (awsTestStatus === "testing") {
|
|
542483
542836
|
return /* @__PURE__ */ React11.createElement(Box9, { flexDirection: "column", padding: 1 }, /* @__PURE__ */ React11.createElement(Box9, { marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text11, { bold: true, color: "cyan" }, "AWS Bedrock Configuration")), /* @__PURE__ */ React11.createElement(Box9, { marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text11, { color: "yellow" }, awsTestMessage)));
|
|
542484
542837
|
}
|
|
@@ -543183,11 +543536,39 @@ var InkSettingsTabView = ({ config: config3, onExit }) => {
|
|
|
543183
543536
|
)), /* @__PURE__ */ React12.createElement(Box10, { marginTop: 1 }, /* @__PURE__ */ React12.createElement(Text12, { dimColor: true }, "Enter to save, Ctrl+C to cancel")));
|
|
543184
543537
|
}
|
|
543185
543538
|
if (activeTab === "user") {
|
|
543539
|
+
if (subView === "select-reasoning") {
|
|
543540
|
+
const reasoningItems = [
|
|
543541
|
+
{ label: "None", value: "none" },
|
|
543542
|
+
{ label: "Low", value: "low" },
|
|
543543
|
+
{ label: "Medium", value: "medium" },
|
|
543544
|
+
{ label: "High", value: "high" },
|
|
543545
|
+
{ label: "\u2190 Cancel", value: "__cancel__" }
|
|
543546
|
+
];
|
|
543547
|
+
return /* @__PURE__ */ React12.createElement(Box10, { flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Box10, { marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Text12, { bold: true, color: "cyan" }, "Select Reasoning Level")), /* @__PURE__ */ React12.createElement(Box10, { marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Text12, { dimColor: true }, "Controls the reasoning effort level for AI responses")), /* @__PURE__ */ React12.createElement(
|
|
543548
|
+
SelectInput2,
|
|
543549
|
+
{
|
|
543550
|
+
items: reasoningItems,
|
|
543551
|
+
isFocused: focusMode === "content",
|
|
543552
|
+
onSelect: async (item) => {
|
|
543553
|
+
if (item.value === "__cancel__") {
|
|
543554
|
+
setSubView(null);
|
|
543555
|
+
return;
|
|
543556
|
+
}
|
|
543557
|
+
await config3.save((data2) => {
|
|
543558
|
+
data2.user.reasoning = item.value;
|
|
543559
|
+
});
|
|
543560
|
+
setMessage(`\u2713 Reasoning level set to: ${item.value}`);
|
|
543561
|
+
setSubView(null);
|
|
543562
|
+
}
|
|
543563
|
+
}
|
|
543564
|
+
));
|
|
543565
|
+
}
|
|
543186
543566
|
const userData = config3.getData().user;
|
|
543187
543567
|
const items = [
|
|
543188
543568
|
{ label: `Change name (${userData.name})`, value: "name" },
|
|
543189
543569
|
{ label: `Change pronouns (${userData.pronouns || "(none)"})`, value: "pronouns" },
|
|
543190
|
-
{ label: "Change global prompt", value: "globalPrompt" }
|
|
543570
|
+
{ label: "Change global prompt", value: "globalPrompt" },
|
|
543571
|
+
{ label: `Change reasoning level (${userData.reasoning || "none"})`, value: "reasoning" }
|
|
543191
543572
|
];
|
|
543192
543573
|
return /* @__PURE__ */ React12.createElement(Box10, { flexDirection: "column" }, message && /* @__PURE__ */ React12.createElement(Box10, { marginBottom: 1 }, /* @__PURE__ */ React12.createElement(Text12, { color: "green" }, message)), /* @__PURE__ */ React12.createElement(
|
|
543193
543574
|
SelectInput2,
|
|
@@ -543201,6 +543582,8 @@ var InkSettingsTabView = ({ config: config3, onExit }) => {
|
|
|
543201
543582
|
startEdit("pronouns", userData.pronouns || "");
|
|
543202
543583
|
} else if (item.value === "globalPrompt") {
|
|
543203
543584
|
startEdit("globalPrompt", userData.globalPrompt || "");
|
|
543585
|
+
} else if (item.value === "reasoning") {
|
|
543586
|
+
setSubView("select-reasoning");
|
|
543204
543587
|
}
|
|
543205
543588
|
}
|
|
543206
543589
|
}
|
|
@@ -544128,7 +544511,7 @@ import BigText from "ink-big-text";
|
|
|
544128
544511
|
// package.json
|
|
544129
544512
|
var package_default2 = {
|
|
544130
544513
|
name: "@aeye/cletus",
|
|
544131
|
-
version: "0.3.
|
|
544514
|
+
version: "0.3.4",
|
|
544132
544515
|
description: "Interactive CLI demo showcasing @aeye capabilities",
|
|
544133
544516
|
type: "module",
|
|
544134
544517
|
main: "dist/index.js",
|
|
@@ -544198,13 +544581,13 @@ See: https://github.com/ClickerMonkey/aeye#readme
|
|
|
544198
544581
|
puppeteer: "^24.31.0"
|
|
544199
544582
|
},
|
|
544200
544583
|
devDependencies: {
|
|
544201
|
-
"@aeye/ai": "0.3.
|
|
544202
|
-
"@aeye/aws": "0.3.
|
|
544203
|
-
"@aeye/core": "0.3.
|
|
544204
|
-
"@aeye/models": "0.3.
|
|
544205
|
-
"@aeye/openai": "0.3.
|
|
544206
|
-
"@aeye/openrouter": "0.3.
|
|
544207
|
-
"@aeye/replicate": "0.3.
|
|
544584
|
+
"@aeye/ai": "0.3.4",
|
|
544585
|
+
"@aeye/aws": "0.3.4",
|
|
544586
|
+
"@aeye/core": "0.3.4",
|
|
544587
|
+
"@aeye/models": "0.3.4",
|
|
544588
|
+
"@aeye/openai": "0.3.4",
|
|
544589
|
+
"@aeye/openrouter": "0.3.4",
|
|
544590
|
+
"@aeye/replicate": "0.3.4",
|
|
544208
544591
|
"@babel/preset-env": "^7.26.0",
|
|
544209
544592
|
"@jest/globals": "^29.7.0",
|
|
544210
544593
|
"@langchain/core": "^0.3.79",
|
|
@@ -544377,7 +544760,8 @@ var InkMainMenu = ({ config: config3, onChatSelect, onExit }) => {
|
|
|
544377
544760
|
todos: [],
|
|
544378
544761
|
questions: [],
|
|
544379
544762
|
toolset: void 0,
|
|
544380
|
-
model: void 0
|
|
544763
|
+
model: void 0,
|
|
544764
|
+
reasoning: null
|
|
544381
544765
|
};
|
|
544382
544766
|
await config3.addChat(newChat);
|
|
544383
544767
|
const chatFile = new ChatFile(chatId);
|