kimiflare 0.74.1 → 0.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12886,7 +12886,7 @@ var init_chat = __esm({
12886
12886
  }
12887
12887
  return /* @__PURE__ */ jsx6(Box5, { flexDirection: "column", children: events.map((e, i) => {
12888
12888
  const prev = events[i - 1];
12889
- const showSeparator = !!(e.kind === "user" && prev && (prev.kind === "assistant" || prev.kind === "tool"));
12889
+ const showSeparator = !!(prev && (e.kind === "user" && prev.kind !== "user" || e.kind === "assistant" && prev.kind !== "assistant" && prev.kind !== "tool"));
12890
12890
  return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
12891
12891
  showSeparator && /* @__PURE__ */ jsx6(Box5, { marginY: 1, children: /* @__PURE__ */ jsx6(Text5, { color: theme.info.color, children: "\u2500".repeat(40) }) }),
12892
12892
  /* @__PURE__ */ jsx6(EventView, { evt: e, showReasoning, verbose, repeatedSigs, intentTier })
@@ -12919,7 +12919,7 @@ var init_chat = __esm({
12919
12919
  return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
12920
12920
  /* @__PURE__ */ jsxs5(Box5, { children: [
12921
12921
  /* @__PURE__ */ jsxs5(Text5, { bold: true, color: theme.user, children: [
12922
- "\u203A",
12922
+ "You:",
12923
12923
  " "
12924
12924
  ] }),
12925
12925
  /* @__PURE__ */ jsx6(Text5, { bold: true, children: evt.text })
@@ -12931,15 +12931,21 @@ var init_chat = __esm({
12931
12931
  ] });
12932
12932
  }
12933
12933
  if (evt.kind === "assistant") {
12934
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingLeft: 2, children: [
12935
- showReasoning && evt.reasoning ? /* @__PURE__ */ jsx6(Box5, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs5(Text5, { color: theme.reasoning.color, children: [
12936
- "thinking\u2026",
12937
- " ",
12938
- evt.reasoning.length > 400 ? evt.reasoning.slice(0, 400) + "\u2026" : evt.reasoning
12939
- ] }) }) : null,
12940
- evt.text ? /* @__PURE__ */ jsx6(MD, { text: evt.text }) : null,
12941
- evt.streaming && /* @__PURE__ */ jsx6(Text5, { color: theme.spinner, children: /* @__PURE__ */ jsx6(Spinner2, { type: "dots" }) })
12942
- ] });
12934
+ return /* @__PURE__ */ jsx6(Box5, { flexDirection: "column", children: /* @__PURE__ */ jsxs5(Box5, { children: [
12935
+ /* @__PURE__ */ jsxs5(Text5, { bold: true, color: theme.assistant ?? theme.info.color, children: [
12936
+ "kimiflare:",
12937
+ " "
12938
+ ] }),
12939
+ /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
12940
+ showReasoning && evt.reasoning ? /* @__PURE__ */ jsx6(Box5, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs5(Text5, { color: theme.reasoning.color, children: [
12941
+ "thinking\u2026",
12942
+ " ",
12943
+ evt.reasoning.length > 400 ? evt.reasoning.slice(0, 400) + "\u2026" : evt.reasoning
12944
+ ] }) }) : null,
12945
+ evt.text ? /* @__PURE__ */ jsx6(MD, { text: evt.text }) : null,
12946
+ evt.streaming && /* @__PURE__ */ jsx6(Text5, { color: theme.spinner, children: /* @__PURE__ */ jsx6(Spinner2, { type: "dots" }) })
12947
+ ] })
12948
+ ] }) });
12943
12949
  }
12944
12950
  if (evt.kind === "tool") {
12945
12951
  const isRepeated = repeatedSigs?.has(toolSignature(evt.name, evt.args)) ?? false;
@@ -13021,9 +13027,10 @@ function StatusBar({ usage, sessionUsage, thinking, turnStartedAt, mode, context
13021
13027
  metaParts.push("memory");
13022
13028
  }
13023
13029
  const phaseLabel = phase === "generating" ? humanizePhase("generating", intentTier) : phase === "executing" ? `${humanizePhase("executing", intentTier)} ${currentTool ?? ""}` : phase === "waiting" ? humanizePhase("waiting", intentTier) : humanizePhase("generating", intentTier);
13030
+ const activePhaseLabel = thinking && phase === "waiting" ? humanizePhase("generating", intentTier) : phaseLabel;
13024
13031
  const idleMs = lastActivityAt && thinking ? now2 - lastActivityAt : 0;
13025
13032
  const idleLabel = idleMs > 3e4 ? ` (idle ${formatElapsed2(Math.floor(idleMs / 1e3))})` : "";
13026
- const thinkingText = metaParts.length > 0 ? `${phaseLabel}${elapsed ? ` \xB7 ${elapsed}` : ""}${idleLabel} \xB7 ${metaParts.join(" \xB7 ")}` : `${phaseLabel}${elapsed ? ` \xB7 ${elapsed}` : ""}${idleLabel}`;
13033
+ const thinkingText = metaParts.length > 0 ? `${activePhaseLabel}${elapsed ? ` \xB7 ${elapsed}` : ""}${idleLabel} \xB7 ${metaParts.join(" \xB7 ")}` : `${activePhaseLabel}${elapsed ? ` \xB7 ${elapsed}` : ""}${idleLabel}`;
13027
13034
  const readyText = idleParts.length > 0 ? `${idleParts.join(" \xB7 ")} \xB7 ready` : "ready";
13028
13035
  return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
13029
13036
  /* @__PURE__ */ jsxs6(Box6, { children: [
@@ -16594,7 +16601,7 @@ var init_everforest_dark = __esm({
16594
16601
  error: "#e67e80"
16595
16602
  },
16596
16603
  user: "#a7c080",
16597
- assistant: null,
16604
+ assistant: "#e69875",
16598
16605
  reasoning: {
16599
16606
  color: "#8c968a",
16600
16607
  dim: false
@@ -16650,7 +16657,7 @@ var init_everforest_light = __esm({
16650
16657
  error: "#cf4745"
16651
16658
  },
16652
16659
  user: "#6f7e01",
16653
- assistant: null,
16660
+ assistant: "#c4715a",
16654
16661
  reasoning: {
16655
16662
  color: "#70796f",
16656
16663
  dim: false
@@ -16706,7 +16713,7 @@ var init_kanagawa_dark = __esm({
16706
16713
  error: "#ff5d62"
16707
16714
  },
16708
16715
  user: "#7e9cd8",
16709
- assistant: null,
16716
+ assistant: "#d27e99",
16710
16717
  reasoning: {
16711
16718
  color: "#93938b",
16712
16719
  dim: false
@@ -16762,7 +16769,7 @@ var init_dracula_dark = __esm({
16762
16769
  error: "#ff5858"
16763
16770
  },
16764
16771
  user: "#ff79c6",
16765
- assistant: null,
16772
+ assistant: "#bd93f9",
16766
16773
  reasoning: {
16767
16774
  color: "#8191c2",
16768
16775
  dim: false
@@ -16818,7 +16825,7 @@ var init_tokyo_night = __esm({
16818
16825
  error: "#f7768e"
16819
16826
  },
16820
16827
  user: "#7aa2f7",
16821
- assistant: null,
16828
+ assistant: "#ff9e64",
16822
16829
  reasoning: {
16823
16830
  color: "#8991b5",
16824
16831
  dim: false
@@ -16874,7 +16881,7 @@ var init_catppuccin_mocha = __esm({
16874
16881
  error: "#f38ba8"
16875
16882
  },
16876
16883
  user: "#89b4fa",
16877
- assistant: null,
16884
+ assistant: "#f5c2e7",
16878
16885
  reasoning: {
16879
16886
  color: "#8e91a7",
16880
16887
  dim: false
@@ -16930,7 +16937,7 @@ var init_catppuccin_latte = __esm({
16930
16937
  error: "#d20f39"
16931
16938
  },
16932
16939
  user: "#1e66f5",
16933
- assistant: null,
16940
+ assistant: "#ea76cb",
16934
16941
  reasoning: {
16935
16942
  color: "#737685",
16936
16943
  dim: false
@@ -16986,7 +16993,7 @@ var init_solarized_dark = __esm({
16986
16993
  error: "#ff5956"
16987
16994
  },
16988
16995
  user: "#359ae1",
16989
- assistant: null,
16996
+ assistant: "#d33682",
16990
16997
  reasoning: {
16991
16998
  color: "#81969c",
16992
16999
  dim: false
@@ -17042,7 +17049,7 @@ var init_solarized_light = __esm({
17042
17049
  error: "#c0392b"
17043
17050
  },
17044
17051
  user: "#227bbb",
17045
- assistant: null,
17052
+ assistant: "#c61b6e",
17046
17053
  reasoning: {
17047
17054
  color: "#6e7878",
17048
17055
  dim: false
@@ -17098,7 +17105,7 @@ var init_nord = __esm({
17098
17105
  error: "#d08770"
17099
17106
  },
17100
17107
  user: "#88c0d0",
17101
- assistant: null,
17108
+ assistant: "#b48ead",
17102
17109
  reasoning: {
17103
17110
  color: "#8a96a8",
17104
17111
  dim: false
@@ -17154,7 +17161,7 @@ var init_gruvbox_dark = __esm({
17154
17161
  error: "#ff5b46"
17155
17162
  },
17156
17163
  user: "#b8bb26",
17157
- assistant: null,
17164
+ assistant: "#fe8019",
17158
17165
  reasoning: {
17159
17166
  color: "#a19283",
17160
17167
  dim: false
@@ -17210,7 +17217,7 @@ var init_gruvbox_light = __esm({
17210
17217
  error: "#9d0006"
17211
17218
  },
17212
17219
  user: "#79740e",
17213
- assistant: null,
17220
+ assistant: "#af3a03",
17214
17221
  reasoning: {
17215
17222
  color: "#827467",
17216
17223
  dim: false
@@ -17266,7 +17273,7 @@ var init_one_dark = __esm({
17266
17273
  error: "#e36f78"
17267
17274
  },
17268
17275
  user: "#61afef",
17269
- assistant: null,
17276
+ assistant: "#c678dd",
17270
17277
  reasoning: {
17271
17278
  color: "#8c939e",
17272
17279
  dim: false
@@ -21732,7 +21739,7 @@ function clearLimitLoopResolvers(deps) {
21732
21739
  function interruptTurn(deps) {
21733
21740
  const hadPermission = deps.denyPendingPermission();
21734
21741
  const { hadLimit, hadLoop } = clearLimitLoopResolvers(deps);
21735
- if (deps.busyRef.current && deps.activeScopeRef.current && !deps.isAbortingRef.current) {
21742
+ if ((deps.busyRef.current || deps.supervisorRef.current.isRunning) && deps.activeScopeRef.current && !deps.isAbortingRef.current) {
21736
21743
  deps.isAbortingRef.current = true;
21737
21744
  deps.supervisorRef.current.killTurn();
21738
21745
  deps.activeScopeRef.current.abort("user_stopped");
@@ -25786,7 +25793,7 @@ ${wcagWarnings.join("\n")}` }
25786
25793
  if (key.escape) {
25787
25794
  const now2 = Date.now();
25788
25795
  const modalOpen = perm !== null || limitModal !== null || loopModal !== null || showLspWizard || showCommandList || commandWizard !== null || commandToDelete !== null || resumeSessions !== null || checkpointSession !== null || showThemePicker;
25789
- if (!modalOpen && busyRef.current && activeScopeRef.current && !isAbortingRef.current && now2 - lastEscapeAtRef.current > 500) {
25796
+ if (!modalOpen && (busyRef.current || supervisorRef.current.isRunning) && activeScopeRef.current && !isAbortingRef.current && now2 - lastEscapeAtRef.current > 500) {
25790
25797
  lastEscapeAtRef.current = now2;
25791
25798
  interruptTurn(interruptDepsRef.current);
25792
25799
  return;
@@ -26441,6 +26448,7 @@ ${wcagWarnings.join("\n")}` }
26441
26448
  onAssistantStart: () => {
26442
26449
  const id = mkAssistantId();
26443
26450
  activeAsstIdRef.current = id;
26451
+ beginTurn();
26444
26452
  setTurnPhase("generating");
26445
26453
  setLastActivityAt(Date.now());
26446
26454
  setEvents((e) => [
@@ -26462,6 +26470,9 @@ ${wcagWarnings.join("\n")}` }
26462
26470
  const id = activeAsstIdRef.current;
26463
26471
  if (id !== null) updateAssistant(id, () => ({ streaming: false }));
26464
26472
  setTurnPhase("waiting");
26473
+ if (pendingToolCallsRef.current.size === 0) {
26474
+ endTurn();
26475
+ }
26465
26476
  },
26466
26477
  onToolCallFinalized: (call) => {
26467
26478
  pendingToolCallsRef.current.set(call.id, call.function.name);
@@ -26501,6 +26512,7 @@ ${wcagWarnings.join("\n")}` }
26501
26512
  if (pendingToolCallsRef.current.size === 0) {
26502
26513
  setTurnPhase("waiting");
26503
26514
  setCurrentToolName(null);
26515
+ endTurn();
26504
26516
  }
26505
26517
  updateTool(r.tool_call_id, {
26506
26518
  status: !r.ok && typeof r.content === "string" && r.content.startsWith("Permission denied") ? "rejected" : r.ok ? "done" : "error",
@@ -26643,105 +26655,111 @@ ${wcagWarnings.join("\n")}` }
26643
26655
  callbacks: sharedCallbacks
26644
26656
  },
26645
26657
  {
26646
- onDone: async () => {
26647
- await saveSessionSafe();
26648
- if (turnScope.signal.aborted) {
26649
- cleanupTurn();
26650
- return;
26651
- }
26652
- if (shouldCompact({ messages: messagesRef.current })) {
26653
- if (hooksManagerRef.current.hasEnabledHooks("PreCompact")) {
26654
- void hooksManagerRef.current.fire(
26655
- "PreCompact",
26656
- {
26657
- event: "PreCompact",
26658
- session_id: sessionIdRef.current,
26659
- cwd: process.cwd()
26660
- },
26661
- null
26662
- ).catch(() => {
26663
- });
26658
+ onDone: () => {
26659
+ void (async () => {
26660
+ await saveSessionSafe();
26661
+ if (turnScope.signal.aborted) {
26662
+ return;
26664
26663
  }
26665
- if (compiledContextRef.current) {
26666
- const store = artifactStoreRef.current;
26667
- const result = compactMessagesViaArtifacts({
26668
- messages: messagesRef.current,
26669
- state: sessionStateRef.current,
26670
- store
26671
- });
26672
- if (result.metrics.rawTurnsRemoved > 0) {
26673
- messagesRef.current = result.newMessages;
26674
- sessionStateRef.current = result.newState;
26675
- setEvents((e) => [
26676
- ...e,
26664
+ let didCompact = false;
26665
+ if (shouldCompact({ messages: messagesRef.current })) {
26666
+ if (hooksManagerRef.current.hasEnabledHooks("PreCompact")) {
26667
+ void hooksManagerRef.current.fire(
26668
+ "PreCompact",
26677
26669
  {
26678
- kind: "info",
26679
- key: mkKey(),
26680
- text: `auto-compacted: ${result.metrics.estimatedTokensBefore} \u2192 ${result.metrics.estimatedTokensAfter} tokens (${result.metrics.archivedArtifacts} artifacts)`
26681
- }
26682
- ]);
26683
- await saveSessionSafe();
26670
+ event: "PreCompact",
26671
+ session_id: sessionIdRef.current,
26672
+ cwd: process.cwd()
26673
+ },
26674
+ null
26675
+ ).catch(() => {
26676
+ });
26684
26677
  }
26685
- } else {
26686
- try {
26687
- const result = await summarizeMessagesViaLlm({
26688
- accountId: cfg.accountId,
26689
- apiToken: cfg.apiToken,
26690
- model: cfg.model,
26678
+ if (compiledContextRef.current) {
26679
+ const store = artifactStoreRef.current;
26680
+ const result = compactMessagesViaArtifacts({
26691
26681
  messages: messagesRef.current,
26692
- signal: turnScope.signal,
26693
- gateway: gatewayFromConfig(cfg)
26682
+ state: sessionStateRef.current,
26683
+ store
26694
26684
  });
26695
- if (result.replacedCount > 0) {
26685
+ if (result.metrics.rawTurnsRemoved > 0) {
26696
26686
  messagesRef.current = result.newMessages;
26687
+ sessionStateRef.current = result.newState;
26697
26688
  setEvents((e) => [
26698
26689
  ...e,
26699
26690
  {
26700
26691
  kind: "info",
26701
26692
  key: mkKey(),
26702
- text: `auto-compacted: ${result.replacedCount} messages summarized`
26693
+ text: `auto-compacted: ${result.metrics.estimatedTokensBefore} \u2192 ${result.metrics.estimatedTokensAfter} tokens (${result.metrics.archivedArtifacts} artifacts)`
26703
26694
  }
26704
26695
  ]);
26705
26696
  await saveSessionSafe();
26697
+ didCompact = true;
26706
26698
  }
26707
- } catch (compactErr) {
26708
- if (compactErr.name !== "AbortError") {
26709
- setEvents((es) => [
26710
- ...es,
26711
- {
26712
- kind: "info",
26713
- key: mkKey(),
26714
- text: `auto-compact failed: ${compactErr.message ?? String(compactErr)}`
26715
- }
26716
- ]);
26699
+ } else {
26700
+ try {
26701
+ const result = await summarizeMessagesViaLlm({
26702
+ accountId: cfg.accountId,
26703
+ apiToken: cfg.apiToken,
26704
+ model: cfg.model,
26705
+ messages: messagesRef.current,
26706
+ signal: turnScope.signal,
26707
+ gateway: gatewayFromConfig(cfg)
26708
+ });
26709
+ if (result.replacedCount > 0) {
26710
+ messagesRef.current = result.newMessages;
26711
+ setEvents((e) => [
26712
+ ...e,
26713
+ {
26714
+ kind: "info",
26715
+ key: mkKey(),
26716
+ text: `auto-compacted: ${result.replacedCount} messages summarized`
26717
+ }
26718
+ ]);
26719
+ await saveSessionSafe();
26720
+ didCompact = true;
26721
+ }
26722
+ } catch (compactErr) {
26723
+ if (compactErr.name !== "AbortError") {
26724
+ setEvents((es) => [
26725
+ ...es,
26726
+ {
26727
+ kind: "info",
26728
+ key: mkKey(),
26729
+ text: `auto-compact failed: ${compactErr.message ?? String(compactErr)}`
26730
+ }
26731
+ ]);
26732
+ }
26717
26733
  }
26718
26734
  }
26719
- }
26720
- }
26721
- const manager = memoryManagerRef.current;
26722
- if (manager) {
26723
- try {
26724
- const cwd = process.cwd();
26725
- const queryText = sessionStateRef.current.task || cwd;
26726
- const results = await manager.recall({ text: queryText, repoPath: cwd, limit: 5 });
26727
- if (results.length > 0) {
26728
- const text2 = await manager.synthesizeRecalled(results);
26729
- const lastSystemIdx = messagesRef.current.findLastIndex((m) => m.role === "system");
26730
- const insertIdx = lastSystemIdx >= 0 ? lastSystemIdx + 1 : messagesRef.current.length;
26731
- messagesRef.current.splice(insertIdx, 0, { role: "system", content: text2 });
26732
- setEvents((e) => [
26733
- ...e,
26734
- {
26735
- kind: "memory",
26736
- key: mkKey(),
26737
- text: `recalled ${results.length} memory${results.length === 1 ? "" : "ies"} after compaction`
26735
+ if (didCompact) {
26736
+ const manager = memoryManagerRef.current;
26737
+ if (manager) {
26738
+ try {
26739
+ const cwd = process.cwd();
26740
+ const queryText = sessionStateRef.current.task || cwd;
26741
+ const results = await manager.recall({ text: queryText, repoPath: cwd, limit: 5 });
26742
+ if (results.length > 0) {
26743
+ const text2 = await manager.synthesizeRecalled(results);
26744
+ const lastSystemIdx = messagesRef.current.findLastIndex((m) => m.role === "system");
26745
+ const insertIdx = lastSystemIdx >= 0 ? lastSystemIdx + 1 : messagesRef.current.length;
26746
+ messagesRef.current.splice(insertIdx, 0, { role: "system", content: text2 });
26747
+ setEvents((e) => [
26748
+ ...e,
26749
+ {
26750
+ kind: "memory",
26751
+ key: mkKey(),
26752
+ text: `recalled ${results.length} memory${results.length === 1 ? "" : "ies"} after compaction`
26753
+ }
26754
+ ]);
26755
+ await saveSessionSafe();
26756
+ }
26757
+ } catch {
26738
26758
  }
26739
- ]);
26740
- await saveSessionSafe();
26759
+ }
26741
26760
  }
26742
- } catch {
26743
26761
  }
26744
- }
26762
+ })();
26745
26763
  cleanupTurn();
26746
26764
  },
26747
26765
  onError: async (e) => {