kimiflare 0.13.5 → 0.13.7
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 +182 -317
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/kimiflare"><img src="https://img.shields.io/npm/v/kimiflare?style=flat-square&color=cb3837" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/kimiflare"><img src="https://img.shields.io/npm/dm/kimiflare?style=flat-square&color=cb3837" alt="npm downloads"></a>
|
|
7
8
|
<a href="https://github.com/sinameraji/kimiflare/blob/main/LICENSE"><img src="https://img.shields.io/github/license/sinameraji/kimiflare?style=flat-square&color=2ea44f" alt="license"></a>
|
|
8
9
|
<img src="https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js >= 20">
|
|
9
10
|
<img src="https://img.shields.io/badge/typescript-5.7-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript">
|
package/dist/index.js
CHANGED
|
@@ -230,87 +230,57 @@ async function* parseStream(body, signal) {
|
|
|
230
230
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
231
231
|
let lastUsage = null;
|
|
232
232
|
let finishReason = null;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
let chunk = null;
|
|
253
|
-
try {
|
|
254
|
-
chunk = JSON.parse(dataStr);
|
|
255
|
-
} catch {
|
|
256
|
-
continue;
|
|
233
|
+
for await (const dataStr of readSSE(body, signal)) {
|
|
234
|
+
if (dataStr === "[DONE]") break;
|
|
235
|
+
let chunk = null;
|
|
236
|
+
try {
|
|
237
|
+
chunk = JSON.parse(dataStr);
|
|
238
|
+
} catch {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (!chunk) continue;
|
|
242
|
+
if (chunk.usage) {
|
|
243
|
+
lastUsage = chunk.usage;
|
|
244
|
+
yield { type: "usage", usage: chunk.usage };
|
|
245
|
+
}
|
|
246
|
+
const choice = chunk.choices?.[0];
|
|
247
|
+
if (!choice) continue;
|
|
248
|
+
const d = choice.delta;
|
|
249
|
+
if (d) {
|
|
250
|
+
if (typeof d.reasoning_content === "string" && d.reasoning_content.length) {
|
|
251
|
+
yield { type: "reasoning", delta: d.reasoning_content };
|
|
257
252
|
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
lastUsage = chunk.usage;
|
|
261
|
-
yield { type: "usage", usage: chunk.usage };
|
|
253
|
+
if (typeof d.content === "string" && d.content.length) {
|
|
254
|
+
yield { type: "text", delta: d.content };
|
|
262
255
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
for (const tc of d.tool_calls) {
|
|
275
|
-
const idx = typeof tc.index === "number" ? tc.index : 0;
|
|
276
|
-
let buf = toolCalls.get(idx);
|
|
277
|
-
const incomingName = tc.function?.name ?? null;
|
|
278
|
-
const incomingId = tc.id ?? null;
|
|
279
|
-
if (!buf) {
|
|
280
|
-
buf = { id: incomingId ?? `tc_${idx}`, name: incomingName ?? "", args: "" };
|
|
281
|
-
toolCalls.set(idx, buf);
|
|
282
|
-
if (buf.name) {
|
|
283
|
-
yield { type: "tool_call_start", index: idx, id: buf.id, name: buf.name };
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
if (!buf.name && incomingName) {
|
|
287
|
-
buf.name = incomingName;
|
|
288
|
-
yield { type: "tool_call_start", index: idx, id: buf.id, name: buf.name };
|
|
289
|
-
}
|
|
290
|
-
if (buf.id.startsWith("tc_") && incomingId) buf.id = incomingId;
|
|
256
|
+
if (Array.isArray(d.tool_calls)) {
|
|
257
|
+
for (const tc of d.tool_calls) {
|
|
258
|
+
const idx = typeof tc.index === "number" ? tc.index : 0;
|
|
259
|
+
let buf = toolCalls.get(idx);
|
|
260
|
+
const incomingName = tc.function?.name ?? null;
|
|
261
|
+
const incomingId = tc.id ?? null;
|
|
262
|
+
if (!buf) {
|
|
263
|
+
buf = { id: incomingId ?? `tc_${idx}`, name: incomingName ?? "", args: "" };
|
|
264
|
+
toolCalls.set(idx, buf);
|
|
265
|
+
if (buf.name) {
|
|
266
|
+
yield { type: "tool_call_start", index: idx, id: buf.id, name: buf.name };
|
|
291
267
|
}
|
|
292
|
-
|
|
293
|
-
if (
|
|
294
|
-
buf.
|
|
295
|
-
yield { type: "
|
|
268
|
+
} else {
|
|
269
|
+
if (!buf.name && incomingName) {
|
|
270
|
+
buf.name = incomingName;
|
|
271
|
+
yield { type: "tool_call_start", index: idx, id: buf.id, name: buf.name };
|
|
296
272
|
}
|
|
273
|
+
if (buf.id.startsWith("tc_") && incomingId) buf.id = incomingId;
|
|
274
|
+
}
|
|
275
|
+
const argDelta = tc.function?.arguments;
|
|
276
|
+
if (typeof argDelta === "string" && argDelta.length) {
|
|
277
|
+
buf.args += argDelta;
|
|
278
|
+
yield { type: "tool_call_args", index: idx, argsDelta: argDelta };
|
|
297
279
|
}
|
|
298
280
|
}
|
|
299
281
|
}
|
|
300
|
-
if (choice.finish_reason) finishReason = choice.finish_reason;
|
|
301
282
|
}
|
|
302
|
-
|
|
303
|
-
if (!buf.name) continue;
|
|
304
|
-
yield {
|
|
305
|
-
type: "tool_call_complete",
|
|
306
|
-
index: idx,
|
|
307
|
-
id: buf.id,
|
|
308
|
-
name: buf.name,
|
|
309
|
-
arguments: buf.args
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
} finally {
|
|
313
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
283
|
+
if (choice.finish_reason) finishReason = choice.finish_reason;
|
|
314
284
|
}
|
|
315
285
|
for (const [idx, buf] of [...toolCalls.entries()].sort((a, b) => a[0] - b[0])) {
|
|
316
286
|
if (!buf.name) continue;
|
|
@@ -384,7 +354,7 @@ function sleep(ms, signal) {
|
|
|
384
354
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
385
355
|
});
|
|
386
356
|
}
|
|
387
|
-
var RETRYABLE_CODES, MAX_ATTEMPTS
|
|
357
|
+
var RETRYABLE_CODES, MAX_ATTEMPTS;
|
|
388
358
|
var init_client = __esm({
|
|
389
359
|
"src/agent/client.ts"() {
|
|
390
360
|
"use strict";
|
|
@@ -393,7 +363,6 @@ var init_client = __esm({
|
|
|
393
363
|
init_messages();
|
|
394
364
|
RETRYABLE_CODES = /* @__PURE__ */ new Set([3040]);
|
|
395
365
|
MAX_ATTEMPTS = 5;
|
|
396
|
-
STREAM_TIMEOUT_MS = 6e4;
|
|
397
366
|
}
|
|
398
367
|
});
|
|
399
368
|
|
|
@@ -3247,233 +3216,201 @@ function themeNames() {
|
|
|
3247
3216
|
function themeList() {
|
|
3248
3217
|
return Object.values(THEMES);
|
|
3249
3218
|
}
|
|
3250
|
-
var dark, light, highContrast, dracula, nord,
|
|
3219
|
+
var dark, light, highContrast, dracula, nord, monokai, solarizedDark, solarizedLight, tokyoNight, gruvboxDark, catppuccinMocha, rosePine, THEMES, DEFAULT_THEME_NAME;
|
|
3251
3220
|
var init_theme = __esm({
|
|
3252
3221
|
"src/ui/theme.ts"() {
|
|
3253
3222
|
"use strict";
|
|
3254
3223
|
dark = {
|
|
3255
3224
|
name: "dark",
|
|
3256
3225
|
label: "dark (default \u2014 for dark terminals)",
|
|
3257
|
-
user: "
|
|
3226
|
+
user: "#61afef",
|
|
3258
3227
|
assistant: void 0,
|
|
3259
|
-
reasoning: { color: "
|
|
3260
|
-
info: { color: "
|
|
3261
|
-
error: "
|
|
3262
|
-
warn: "
|
|
3263
|
-
tool: "
|
|
3264
|
-
spinner: "
|
|
3265
|
-
permission: "
|
|
3266
|
-
queue: { color: "
|
|
3267
|
-
accent: "
|
|
3268
|
-
modeBadge: { plan: "
|
|
3228
|
+
reasoning: { color: "#5c6370", dim: true },
|
|
3229
|
+
info: { color: "#5c6370", dim: true },
|
|
3230
|
+
error: "#e06c75",
|
|
3231
|
+
warn: "#e5c07b",
|
|
3232
|
+
tool: "#61afef",
|
|
3233
|
+
spinner: "#e5c07b",
|
|
3234
|
+
permission: "#e5c07b",
|
|
3235
|
+
queue: { color: "#5c6370", dim: true },
|
|
3236
|
+
accent: "#56b6c2",
|
|
3237
|
+
modeBadge: { plan: "#61afef", auto: "#98c379", edit: "#56b6c2" }
|
|
3269
3238
|
};
|
|
3270
3239
|
light = {
|
|
3271
3240
|
name: "light",
|
|
3272
3241
|
label: "light (for bright terminal backgrounds)",
|
|
3273
|
-
user: "
|
|
3242
|
+
user: "#4078f2",
|
|
3274
3243
|
assistant: void 0,
|
|
3275
|
-
reasoning: { color: "
|
|
3276
|
-
info: { color: "
|
|
3277
|
-
error: "
|
|
3278
|
-
warn: "
|
|
3279
|
-
tool: "
|
|
3280
|
-
spinner: "
|
|
3281
|
-
permission: "
|
|
3282
|
-
queue: { color: "
|
|
3283
|
-
accent: "
|
|
3284
|
-
modeBadge: { plan: "
|
|
3244
|
+
reasoning: { color: "#a0a1a7", dim: false },
|
|
3245
|
+
info: { color: "#a0a1a7", dim: false },
|
|
3246
|
+
error: "#e45649",
|
|
3247
|
+
warn: "#986801",
|
|
3248
|
+
tool: "#a626a4",
|
|
3249
|
+
spinner: "#4078f2",
|
|
3250
|
+
permission: "#986801",
|
|
3251
|
+
queue: { color: "#a0a1a7", dim: false },
|
|
3252
|
+
accent: "#4078f2",
|
|
3253
|
+
modeBadge: { plan: "#4078f2", auto: "#50a14f", edit: "#a626a4" }
|
|
3285
3254
|
};
|
|
3286
3255
|
highContrast = {
|
|
3287
3256
|
name: "high-contrast",
|
|
3288
3257
|
label: "high-contrast (bold, bright colors for low-vision)",
|
|
3289
|
-
user: "
|
|
3290
|
-
assistant: "
|
|
3291
|
-
reasoning: { color: "
|
|
3292
|
-
info: { color: "
|
|
3293
|
-
error: "
|
|
3294
|
-
warn: "
|
|
3295
|
-
tool: "
|
|
3296
|
-
spinner: "
|
|
3297
|
-
permission: "
|
|
3298
|
-
queue: { color: "
|
|
3299
|
-
accent: "
|
|
3300
|
-
modeBadge: { plan: "
|
|
3258
|
+
user: "#00ffff",
|
|
3259
|
+
assistant: "#ffffff",
|
|
3260
|
+
reasoning: { color: "#ffffff", dim: false },
|
|
3261
|
+
info: { color: "#ffffff", dim: false },
|
|
3262
|
+
error: "#ff0000",
|
|
3263
|
+
warn: "#ffff00",
|
|
3264
|
+
tool: "#ff00ff",
|
|
3265
|
+
spinner: "#ffff00",
|
|
3266
|
+
permission: "#ffff00",
|
|
3267
|
+
queue: { color: "#ffffff", dim: false },
|
|
3268
|
+
accent: "#00ffff",
|
|
3269
|
+
modeBadge: { plan: "#0000ff", auto: "#00ff00", edit: "#00ffff" }
|
|
3301
3270
|
};
|
|
3302
3271
|
dracula = {
|
|
3303
3272
|
name: "dracula",
|
|
3304
|
-
label: "dracula (
|
|
3305
|
-
user: "
|
|
3273
|
+
label: "dracula (pink & cyan, popular dark)",
|
|
3274
|
+
user: "#8be9fd",
|
|
3306
3275
|
assistant: void 0,
|
|
3307
|
-
reasoning: { color: "
|
|
3308
|
-
info: { color: "
|
|
3309
|
-
error: "
|
|
3310
|
-
warn: "
|
|
3311
|
-
tool: "
|
|
3312
|
-
spinner: "
|
|
3313
|
-
permission: "
|
|
3314
|
-
queue: { color: "
|
|
3315
|
-
accent: "
|
|
3316
|
-
modeBadge: { plan: "
|
|
3276
|
+
reasoning: { color: "#6272a4", dim: true },
|
|
3277
|
+
info: { color: "#6272a4", dim: true },
|
|
3278
|
+
error: "#ff5555",
|
|
3279
|
+
warn: "#f1fa8c",
|
|
3280
|
+
tool: "#bd93f9",
|
|
3281
|
+
spinner: "#8be9fd",
|
|
3282
|
+
permission: "#f1fa8c",
|
|
3283
|
+
queue: { color: "#6272a4", dim: true },
|
|
3284
|
+
accent: "#ff79c6",
|
|
3285
|
+
modeBadge: { plan: "#8be9fd", auto: "#50fa7b", edit: "#ff79c6" }
|
|
3317
3286
|
};
|
|
3318
3287
|
nord = {
|
|
3319
3288
|
name: "nord",
|
|
3320
3289
|
label: "nord (arctic blue & frost, calm dark)",
|
|
3321
|
-
user: "
|
|
3322
|
-
assistant: void 0,
|
|
3323
|
-
reasoning: { color: "blue", dim: true },
|
|
3324
|
-
info: { color: "blue", dim: true },
|
|
3325
|
-
error: "red",
|
|
3326
|
-
warn: "yellow",
|
|
3327
|
-
tool: "cyan",
|
|
3328
|
-
spinner: "cyan",
|
|
3329
|
-
permission: "yellow",
|
|
3330
|
-
queue: { color: "blue", dim: true },
|
|
3331
|
-
accent: "cyan",
|
|
3332
|
-
modeBadge: { plan: "blue", auto: "green", edit: "cyan" }
|
|
3333
|
-
};
|
|
3334
|
-
oneDark = {
|
|
3335
|
-
name: "one-dark",
|
|
3336
|
-
label: "one-dark (Atom's classic dark)",
|
|
3337
|
-
user: "cyan",
|
|
3290
|
+
user: "#88c0d0",
|
|
3338
3291
|
assistant: void 0,
|
|
3339
|
-
reasoning: { color: "
|
|
3340
|
-
info: { color: "
|
|
3341
|
-
error: "
|
|
3342
|
-
warn: "
|
|
3343
|
-
tool: "
|
|
3344
|
-
spinner: "
|
|
3345
|
-
permission: "
|
|
3346
|
-
queue: { color: "
|
|
3347
|
-
accent: "
|
|
3348
|
-
modeBadge: { plan: "
|
|
3292
|
+
reasoning: { color: "#4c566a", dim: true },
|
|
3293
|
+
info: { color: "#4c566a", dim: true },
|
|
3294
|
+
error: "#bf616a",
|
|
3295
|
+
warn: "#ebcb8b",
|
|
3296
|
+
tool: "#88c0d0",
|
|
3297
|
+
spinner: "#88c0d0",
|
|
3298
|
+
permission: "#ebcb8b",
|
|
3299
|
+
queue: { color: "#4c566a", dim: true },
|
|
3300
|
+
accent: "#88c0d0",
|
|
3301
|
+
modeBadge: { plan: "#5e81ac", auto: "#a3be8c", edit: "#88c0d0" }
|
|
3349
3302
|
};
|
|
3350
3303
|
monokai = {
|
|
3351
3304
|
name: "monokai",
|
|
3352
|
-
label: "monokai (vibrant
|
|
3353
|
-
user: "
|
|
3305
|
+
label: "monokai (vibrant pink & yellow)",
|
|
3306
|
+
user: "#f92672",
|
|
3354
3307
|
assistant: void 0,
|
|
3355
|
-
reasoning: { color: "
|
|
3356
|
-
info: { color: "
|
|
3357
|
-
error: "
|
|
3358
|
-
warn: "
|
|
3359
|
-
tool: "
|
|
3360
|
-
spinner: "
|
|
3361
|
-
permission: "
|
|
3362
|
-
queue: { color: "
|
|
3363
|
-
accent: "
|
|
3364
|
-
modeBadge: { plan: "
|
|
3308
|
+
reasoning: { color: "#75715e", dim: true },
|
|
3309
|
+
info: { color: "#75715e", dim: true },
|
|
3310
|
+
error: "#f92672",
|
|
3311
|
+
warn: "#e6db74",
|
|
3312
|
+
tool: "#66d9ef",
|
|
3313
|
+
spinner: "#e6db74",
|
|
3314
|
+
permission: "#e6db74",
|
|
3315
|
+
queue: { color: "#75715e", dim: true },
|
|
3316
|
+
accent: "#f92672",
|
|
3317
|
+
modeBadge: { plan: "#66d9ef", auto: "#a6e22e", edit: "#f92672" }
|
|
3365
3318
|
};
|
|
3366
3319
|
solarizedDark = {
|
|
3367
3320
|
name: "solarized-dark",
|
|
3368
3321
|
label: "solarized-dark (muted blue & yellow)",
|
|
3369
|
-
user: "
|
|
3322
|
+
user: "#2aa198",
|
|
3370
3323
|
assistant: void 0,
|
|
3371
|
-
reasoning: { color: "
|
|
3372
|
-
info: { color: "
|
|
3373
|
-
error: "
|
|
3374
|
-
warn: "
|
|
3375
|
-
tool: "
|
|
3376
|
-
spinner: "
|
|
3377
|
-
permission: "
|
|
3378
|
-
queue: { color: "
|
|
3379
|
-
accent: "
|
|
3380
|
-
modeBadge: { plan: "
|
|
3324
|
+
reasoning: { color: "#586e75", dim: true },
|
|
3325
|
+
info: { color: "#586e75", dim: true },
|
|
3326
|
+
error: "#dc322f",
|
|
3327
|
+
warn: "#b58900",
|
|
3328
|
+
tool: "#2aa198",
|
|
3329
|
+
spinner: "#b58900",
|
|
3330
|
+
permission: "#b58900",
|
|
3331
|
+
queue: { color: "#586e75", dim: true },
|
|
3332
|
+
accent: "#2aa198",
|
|
3333
|
+
modeBadge: { plan: "#268bd2", auto: "#859900", edit: "#2aa198" }
|
|
3381
3334
|
};
|
|
3382
3335
|
solarizedLight = {
|
|
3383
3336
|
name: "solarized-light",
|
|
3384
3337
|
label: "solarized-light (light beige & cyan)",
|
|
3385
|
-
user: "
|
|
3338
|
+
user: "#268bd2",
|
|
3386
3339
|
assistant: void 0,
|
|
3387
|
-
reasoning: { color: "
|
|
3388
|
-
info: { color: "
|
|
3389
|
-
error: "
|
|
3390
|
-
warn: "
|
|
3391
|
-
tool: "
|
|
3392
|
-
spinner: "
|
|
3393
|
-
permission: "
|
|
3394
|
-
queue: { color: "
|
|
3395
|
-
accent: "
|
|
3396
|
-
modeBadge: { plan: "
|
|
3340
|
+
reasoning: { color: "#93a1a1", dim: false },
|
|
3341
|
+
info: { color: "#93a1a1", dim: false },
|
|
3342
|
+
error: "#dc322f",
|
|
3343
|
+
warn: "#b58900",
|
|
3344
|
+
tool: "#268bd2",
|
|
3345
|
+
spinner: "#268bd2",
|
|
3346
|
+
permission: "#b58900",
|
|
3347
|
+
queue: { color: "#93a1a1", dim: false },
|
|
3348
|
+
accent: "#268bd2",
|
|
3349
|
+
modeBadge: { plan: "#268bd2", auto: "#859900", edit: "#268bd2" }
|
|
3397
3350
|
};
|
|
3398
3351
|
tokyoNight = {
|
|
3399
3352
|
name: "tokyo-night",
|
|
3400
3353
|
label: "tokyo-night (deep blue & purple)",
|
|
3401
|
-
user: "
|
|
3354
|
+
user: "#7dcfff",
|
|
3402
3355
|
assistant: void 0,
|
|
3403
|
-
reasoning: { color: "
|
|
3404
|
-
info: { color: "
|
|
3405
|
-
error: "
|
|
3406
|
-
warn: "
|
|
3407
|
-
tool: "
|
|
3408
|
-
spinner: "
|
|
3409
|
-
permission: "
|
|
3410
|
-
queue: { color: "
|
|
3411
|
-
accent: "
|
|
3412
|
-
modeBadge: { plan: "
|
|
3356
|
+
reasoning: { color: "#565f89", dim: true },
|
|
3357
|
+
info: { color: "#565f89", dim: true },
|
|
3358
|
+
error: "#f7768e",
|
|
3359
|
+
warn: "#e0af68",
|
|
3360
|
+
tool: "#bb9af7",
|
|
3361
|
+
spinner: "#7dcfff",
|
|
3362
|
+
permission: "#e0af68",
|
|
3363
|
+
queue: { color: "#565f89", dim: true },
|
|
3364
|
+
accent: "#bb9af7",
|
|
3365
|
+
modeBadge: { plan: "#7aa2f7", auto: "#9ece6a", edit: "#bb9af7" }
|
|
3413
3366
|
};
|
|
3414
3367
|
gruvboxDark = {
|
|
3415
3368
|
name: "gruvbox-dark",
|
|
3416
3369
|
label: "gruvbox-dark (warm retro dark)",
|
|
3417
|
-
user: "
|
|
3370
|
+
user: "#fabd2f",
|
|
3418
3371
|
assistant: void 0,
|
|
3419
|
-
reasoning: { color: "
|
|
3420
|
-
info: { color: "
|
|
3421
|
-
error: "
|
|
3422
|
-
warn: "
|
|
3423
|
-
tool: "
|
|
3424
|
-
spinner: "
|
|
3425
|
-
permission: "
|
|
3426
|
-
queue: { color: "
|
|
3427
|
-
accent: "
|
|
3428
|
-
modeBadge: { plan: "
|
|
3429
|
-
};
|
|
3430
|
-
gruvboxLight = {
|
|
3431
|
-
name: "gruvbox-light",
|
|
3432
|
-
label: "gruvbox-light (warm retro light)",
|
|
3433
|
-
user: "blue",
|
|
3434
|
-
assistant: void 0,
|
|
3435
|
-
reasoning: { color: "blackBright", dim: false },
|
|
3436
|
-
info: { color: "blackBright", dim: false },
|
|
3437
|
-
error: "red",
|
|
3438
|
-
warn: "yellow",
|
|
3439
|
-
tool: "cyan",
|
|
3440
|
-
spinner: "blue",
|
|
3441
|
-
permission: "yellow",
|
|
3442
|
-
queue: { color: "blackBright", dim: false },
|
|
3443
|
-
accent: "blue",
|
|
3444
|
-
modeBadge: { plan: "blue", auto: "green", edit: "blue" }
|
|
3372
|
+
reasoning: { color: "#928374", dim: true },
|
|
3373
|
+
info: { color: "#928374", dim: true },
|
|
3374
|
+
error: "#fb4934",
|
|
3375
|
+
warn: "#fe8019",
|
|
3376
|
+
tool: "#83a598",
|
|
3377
|
+
spinner: "#fabd2f",
|
|
3378
|
+
permission: "#fe8019",
|
|
3379
|
+
queue: { color: "#928374", dim: true },
|
|
3380
|
+
accent: "#fabd2f",
|
|
3381
|
+
modeBadge: { plan: "#83a598", auto: "#b8bb26", edit: "#fabd2f" }
|
|
3445
3382
|
};
|
|
3446
3383
|
catppuccinMocha = {
|
|
3447
3384
|
name: "catppuccin-mocha",
|
|
3448
3385
|
label: "catppuccin-mocha (pastel pink & lavender)",
|
|
3449
|
-
user: "
|
|
3386
|
+
user: "#f5c2e7",
|
|
3450
3387
|
assistant: void 0,
|
|
3451
|
-
reasoning: { color: "
|
|
3452
|
-
info: { color: "
|
|
3453
|
-
error: "
|
|
3454
|
-
warn: "
|
|
3455
|
-
tool: "
|
|
3456
|
-
spinner: "
|
|
3457
|
-
permission: "
|
|
3458
|
-
queue: { color: "
|
|
3459
|
-
accent: "
|
|
3460
|
-
modeBadge: { plan: "
|
|
3388
|
+
reasoning: { color: "#6c7086", dim: true },
|
|
3389
|
+
info: { color: "#6c7086", dim: true },
|
|
3390
|
+
error: "#f38ba8",
|
|
3391
|
+
warn: "#f9e2af",
|
|
3392
|
+
tool: "#89dceb",
|
|
3393
|
+
spinner: "#89dceb",
|
|
3394
|
+
permission: "#f9e2af",
|
|
3395
|
+
queue: { color: "#6c7086", dim: true },
|
|
3396
|
+
accent: "#cba6f7",
|
|
3397
|
+
modeBadge: { plan: "#89b4fa", auto: "#a6e3a1", edit: "#f5c2e7" }
|
|
3461
3398
|
};
|
|
3462
3399
|
rosePine = {
|
|
3463
3400
|
name: "rose-pine",
|
|
3464
3401
|
label: "rose-pine (soft rose & foam)",
|
|
3465
|
-
user: "
|
|
3402
|
+
user: "#ebbcba",
|
|
3466
3403
|
assistant: void 0,
|
|
3467
|
-
reasoning: { color: "
|
|
3468
|
-
info: { color: "
|
|
3469
|
-
error: "
|
|
3470
|
-
warn: "
|
|
3471
|
-
tool: "
|
|
3472
|
-
spinner: "
|
|
3473
|
-
permission: "
|
|
3474
|
-
queue: { color: "
|
|
3475
|
-
accent: "
|
|
3476
|
-
modeBadge: { plan: "
|
|
3404
|
+
reasoning: { color: "#6e6a86", dim: true },
|
|
3405
|
+
info: { color: "#6e6a86", dim: true },
|
|
3406
|
+
error: "#eb6f92",
|
|
3407
|
+
warn: "#f6c177",
|
|
3408
|
+
tool: "#9ccfd8",
|
|
3409
|
+
spinner: "#ebbcba",
|
|
3410
|
+
permission: "#f6c177",
|
|
3411
|
+
queue: { color: "#6e6a86", dim: true },
|
|
3412
|
+
accent: "#ebbcba",
|
|
3413
|
+
modeBadge: { plan: "#31748f", auto: "#9ccfd8", edit: "#ebbcba" }
|
|
3477
3414
|
};
|
|
3478
3415
|
THEMES = {
|
|
3479
3416
|
dark,
|
|
@@ -3481,13 +3418,11 @@ var init_theme = __esm({
|
|
|
3481
3418
|
"high-contrast": highContrast,
|
|
3482
3419
|
dracula,
|
|
3483
3420
|
nord,
|
|
3484
|
-
"one-dark": oneDark,
|
|
3485
3421
|
monokai,
|
|
3486
3422
|
"solarized-dark": solarizedDark,
|
|
3487
3423
|
"solarized-light": solarizedLight,
|
|
3488
3424
|
"tokyo-night": tokyoNight,
|
|
3489
3425
|
"gruvbox-dark": gruvboxDark,
|
|
3490
|
-
"gruvbox-light": gruvboxLight,
|
|
3491
3426
|
"catppuccin-mocha": catppuccinMocha,
|
|
3492
3427
|
"rose-pine": rosePine
|
|
3493
3428
|
};
|
|
@@ -3623,60 +3558,6 @@ function findImagePaths(text) {
|
|
|
3623
3558
|
}
|
|
3624
3559
|
return [...new Set(paths)];
|
|
3625
3560
|
}
|
|
3626
|
-
function stripImagesFromHistory(messages) {
|
|
3627
|
-
for (const m of messages) {
|
|
3628
|
-
if (!Array.isArray(m.content)) continue;
|
|
3629
|
-
let changed = false;
|
|
3630
|
-
const next = [];
|
|
3631
|
-
for (const part of m.content) {
|
|
3632
|
-
if (part.type === "image_url") {
|
|
3633
|
-
changed = true;
|
|
3634
|
-
next.push({ type: "text", text: "[image]" });
|
|
3635
|
-
} else {
|
|
3636
|
-
next.push(part);
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
|
-
if (changed) {
|
|
3640
|
-
m.content = next;
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
|
-
}
|
|
3644
|
-
function truncateOldToolResults(messages, keepRecent) {
|
|
3645
|
-
const toolIndices = [];
|
|
3646
|
-
for (let i = 0; i < messages.length; i++) {
|
|
3647
|
-
if (messages[i].role === "tool") toolIndices.push(i);
|
|
3648
|
-
}
|
|
3649
|
-
const cutoff = toolIndices.length - keepRecent;
|
|
3650
|
-
for (let i = 0; i < cutoff; i++) {
|
|
3651
|
-
const idx = toolIndices[i];
|
|
3652
|
-
const m = messages[idx];
|
|
3653
|
-
const text = typeof m.content === "string" ? m.content : "";
|
|
3654
|
-
if (text.length > 500) {
|
|
3655
|
-
m.content = text.slice(0, 500) + "\n\u2026 [truncated]";
|
|
3656
|
-
}
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
|
-
async function maybeAutoCompact(messages, cfg, onInfo) {
|
|
3660
|
-
const heapUsed = process.memoryUsage().heapUsed;
|
|
3661
|
-
if (heapUsed < HEAP_AUTO_COMPACT_THRESHOLD || messages.length <= MSG_AUTO_COMPACT_THRESHOLD) {
|
|
3662
|
-
return false;
|
|
3663
|
-
}
|
|
3664
|
-
onInfo("auto-compacting to reduce memory usage");
|
|
3665
|
-
const result = await compactMessages({
|
|
3666
|
-
accountId: cfg.accountId,
|
|
3667
|
-
apiToken: cfg.apiToken,
|
|
3668
|
-
model: cfg.model,
|
|
3669
|
-
messages,
|
|
3670
|
-
keepLastTurns: 2
|
|
3671
|
-
});
|
|
3672
|
-
if (result.replacedCount > 0) {
|
|
3673
|
-
messages.length = 0;
|
|
3674
|
-
messages.push(...result.newMessages);
|
|
3675
|
-
onInfo(`compacted ${result.replacedCount} messages into a summary`);
|
|
3676
|
-
return true;
|
|
3677
|
-
}
|
|
3678
|
-
return false;
|
|
3679
|
-
}
|
|
3680
3561
|
function App({ initialCfg, initialUpdateResult }) {
|
|
3681
3562
|
const { exit } = useApp();
|
|
3682
3563
|
const [cfg, setCfg] = useState6(initialCfg);
|
|
@@ -4096,13 +3977,6 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
4096
3977
|
})
|
|
4097
3978
|
}
|
|
4098
3979
|
});
|
|
4099
|
-
stripImagesFromHistory(messagesRef.current);
|
|
4100
|
-
truncateOldToolResults(messagesRef.current, 8);
|
|
4101
|
-
await maybeAutoCompact(
|
|
4102
|
-
messagesRef.current,
|
|
4103
|
-
cfg,
|
|
4104
|
-
(text) => setEvents((es) => [...es, { kind: "info", key: mkKey(), text }])
|
|
4105
|
-
);
|
|
4106
3980
|
if (existsSync(join6(cwd, "KIMI.md"))) {
|
|
4107
3981
|
messagesRef.current[0] = {
|
|
4108
3982
|
role: "system",
|
|
@@ -4545,14 +4419,7 @@ use: /thinking low | medium | high`
|
|
|
4545
4419
|
})
|
|
4546
4420
|
}
|
|
4547
4421
|
});
|
|
4548
|
-
|
|
4549
|
-
truncateOldToolResults(messagesRef.current, 8);
|
|
4550
|
-
await maybeAutoCompact(
|
|
4551
|
-
messagesRef.current,
|
|
4552
|
-
cfg,
|
|
4553
|
-
(text2) => setEvents((es) => [...es, { kind: "info", key: mkKey(), text: text2 }])
|
|
4554
|
-
);
|
|
4555
|
-
void saveSessionSafe();
|
|
4422
|
+
await saveSessionSafe();
|
|
4556
4423
|
} catch (e) {
|
|
4557
4424
|
if (e.name === "AbortError") {
|
|
4558
4425
|
setEvents((es) => [...es, { kind: "info", key: mkKey(), text: "(aborted)" }]);
|
|
@@ -4742,7 +4609,7 @@ async function renderApp(cfg, updateResult) {
|
|
|
4742
4609
|
const instance = render(/* @__PURE__ */ jsx13(App, { initialCfg: cfg, initialUpdateResult: updateResult }));
|
|
4743
4610
|
await instance.waitUntilExit();
|
|
4744
4611
|
}
|
|
4745
|
-
var CONTEXT_LIMIT, AUTO_COMPACT_SUGGEST_PCT, MAX_EVENTS, nextAssistantId, nextKey, mkKey, MAX_IMAGES_PER_MESSAGE, EFFORT_DESCRIPTIONS
|
|
4612
|
+
var CONTEXT_LIMIT, AUTO_COMPACT_SUGGEST_PCT, MAX_EVENTS, nextAssistantId, nextKey, mkKey, MAX_IMAGES_PER_MESSAGE, EFFORT_DESCRIPTIONS;
|
|
4746
4613
|
var init_app = __esm({
|
|
4747
4614
|
"src/app.tsx"() {
|
|
4748
4615
|
"use strict";
|
|
@@ -4779,8 +4646,6 @@ var init_app = __esm({
|
|
|
4779
4646
|
medium: "medium \u2014 balanced (default). Solid quality on most edits, fast on trivial prompts.",
|
|
4780
4647
|
high: "high \u2014 deepest reasoning; slowest. Best for complex debugging, architecture, multi-file refactors."
|
|
4781
4648
|
};
|
|
4782
|
-
HEAP_AUTO_COMPACT_THRESHOLD = 2e9;
|
|
4783
|
-
MSG_AUTO_COMPACT_THRESHOLD = 50;
|
|
4784
4649
|
}
|
|
4785
4650
|
});
|
|
4786
4651
|
|