kimiflare 0.78.0 → 0.79.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
@@ -12134,6 +12134,17 @@ var init_supervisor = __esm({
12134
12134
  continue;
12135
12135
  }
12136
12136
  const progress = await progressRes.json();
12137
+ const allSteps = [];
12138
+ for (let i = 0; i < progress.totalSteps; i++) {
12139
+ const isCompleted = i < progress.completedSteps.length;
12140
+ const isActive = i === progress.stepIndex - 1 && !isCompleted && progress.status === "running";
12141
+ const isFailed = progress.status === "failed" && i === progress.stepIndex - 1;
12142
+ allSteps.push({
12143
+ label: progress.completedSteps[i] ?? progress.step,
12144
+ status: isFailed ? "failed" : isCompleted ? "completed" : isActive ? "active" : "pending"
12145
+ });
12146
+ }
12147
+ worker.steps = allSteps;
12137
12148
  const newLogs = progress.logs.slice(lastLogCount);
12138
12149
  lastLogCount = progress.logs.length;
12139
12150
  for (const logLine of newLogs) {
@@ -12175,6 +12186,13 @@ var init_supervisor = __esm({
12175
12186
  worker.result = data;
12176
12187
  worker.rawOutput = data.rawOutput;
12177
12188
  worker.reasoning = data.reasoning;
12189
+ if (worker.steps && worker.steps.length > 0) {
12190
+ for (const s of worker.steps) {
12191
+ if (s.status === "pending" || s.status === "active") {
12192
+ s.status = worker.status === "completed" ? "completed" : "failed";
12193
+ }
12194
+ }
12195
+ }
12178
12196
  worker.logs.push(`[coordinator] Worker finished with status: ${data.status}`);
12179
12197
  if (data.phases && data.phases.length > 0) {
12180
12198
  const timeline = data.phases.map((p) => `${p.name}: ${Math.round(p.ms / 1e3)}s`).join(" \xB7 ");
@@ -12292,13 +12310,18 @@ var init_supervisor = __esm({
12292
12310
  *
12293
12311
  * Returns the synthesized plan after all workers complete.
12294
12312
  */
12295
- async autoSpawnWorkers(prompt, context, onUpdate, onPhaseChange, signal) {
12313
+ async autoSpawnWorkers(prompt, context, onUpdate, onPhaseChange, signal, onNarration) {
12296
12314
  if (this._activeWorkers.size > 0) {
12297
12315
  throw new Error(
12298
12316
  `Multi-agent already active (${this._activeWorkers.size} worker(s) in flight). Wait for completion or cancel before starting a new heavy task.`
12299
12317
  );
12300
12318
  }
12301
12319
  const workers = decomposePrompt(prompt, context);
12320
+ const narrationLines = [
12321
+ `Decomposing your request into ${workers.length} parallel research task${workers.length > 1 ? "s" : ""}:`,
12322
+ ...workers.map((w, i) => ` ${i + 1}. ${w.task.slice(0, 200)}${w.task.length > 200 ? "\u2026" : ""}`)
12323
+ ];
12324
+ onNarration?.(narrationLines.join("\n"));
12302
12325
  onPhaseChange?.("spawning");
12303
12326
  try {
12304
12327
  const results = await this.spawnWorkers(workers, onUpdate, signal);
@@ -20675,15 +20698,19 @@ import { useEffect as useEffect5, useState as useState9 } from "react";
20675
20698
  import { Box as Box11, Text as Text12 } from "ink";
20676
20699
  import Spinner5 from "ink-spinner";
20677
20700
  import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
20678
- function WorkerList({ workers, isSynthesizing }) {
20701
+ function WorkerList({ workers, isSynthesizing, narration }) {
20679
20702
  const theme = useTheme();
20680
- if (workers.length === 0) return null;
20703
+ if (workers.length === 0 && !narration) return null;
20681
20704
  const running = workers.filter((w) => w.status === "running").length;
20682
20705
  const completed = workers.filter((w) => w.status === "completed").length;
20683
20706
  const failed = workers.filter((w) => w.status === "failed").length;
20684
20707
  const pending = workers.filter((w) => w.status === "pending").length;
20685
20708
  const showSynthesis = isSynthesizing && running === 0;
20686
20709
  return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginBottom: 1, children: [
20710
+ narration && /* @__PURE__ */ jsx13(Box11, { marginBottom: 1, children: /* @__PURE__ */ jsx13(Text12, { color: theme.info.color, italic: true, children: narration.split("\n").map((line, i) => /* @__PURE__ */ jsxs11(Text12, { children: [
20711
+ line,
20712
+ "\n"
20713
+ ] }, `narration-${i}`)) }) }),
20687
20714
  /* @__PURE__ */ jsx13(Box11, { children: /* @__PURE__ */ jsxs11(Text12, { color: theme.accent, bold: true, children: [
20688
20715
  "Workers: ",
20689
20716
  pending > 0 ? `${pending} todo \xB7 ` : "",
@@ -20713,7 +20740,7 @@ function WorkerRow({ worker }) {
20713
20740
  const statusIcon = worker.status === "pending" ? /* @__PURE__ */ jsx13(Text12, { color: theme.muted?.color ?? theme.info.color, children: "\u2610" }) : worker.status === "running" ? /* @__PURE__ */ jsx13(Text12, { color: theme.info.color, children: /* @__PURE__ */ jsx13(Spinner5, { type: "line" }) }) : worker.status === "completed" ? /* @__PURE__ */ jsx13(Text12, { color: theme.palette.success, children: "\u2611" }) : /* @__PURE__ */ jsx13(Text12, { color: theme.palette.error, children: "\u2612" });
20714
20741
  const statusLabel = worker.status === "pending" ? "todo" : worker.status === "running" ? "ongoing" : worker.status === "completed" ? "done" : "failed";
20715
20742
  const isDone = worker.status === "completed" || worker.status === "failed";
20716
- const visibleLogs = worker.status === "running" ? worker.logs.slice(-5) : worker.status === "pending" ? [] : worker.logs.slice(-8);
20743
+ const hasSteps = worker.steps && worker.steps.length > 0;
20717
20744
  return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", marginLeft: 2, children: [
20718
20745
  /* @__PURE__ */ jsx13(Box11, { children: /* @__PURE__ */ jsxs11(Text12, { children: [
20719
20746
  statusIcon,
@@ -20746,7 +20773,37 @@ function WorkerRow({ worker }) {
20746
20773
  worker.error.slice(0, 60)
20747
20774
  ] }) : null
20748
20775
  ] }) }),
20749
- visibleLogs.length > 0 && /* @__PURE__ */ jsx13(Box11, { flexDirection: "column", marginLeft: 4, children: visibleLogs.map((line, i) => /* @__PURE__ */ jsx13(Text12, { color: theme.muted?.color ?? theme.info.color, dimColor: true, children: line.slice(0, 120) }, `${worker.id}-log-${i}`)) })
20776
+ hasSteps && /* @__PURE__ */ jsx13(Box11, { flexDirection: "column", marginLeft: 4, children: worker.steps.map((step, i) => /* @__PURE__ */ jsx13(StepRow, { step, theme }, `${worker.id}-step-${i}`)) }),
20777
+ worker.logs.length > 0 && /* @__PURE__ */ jsx13(Box11, { flexDirection: "column", marginLeft: 4, children: worker.logs.slice(-3).map((line, i) => /* @__PURE__ */ jsx13(Text12, { color: theme.muted?.color ?? theme.info.color, dimColor: true, children: line.slice(0, 120) }, `${worker.id}-log-${i}`)) })
20778
+ ] });
20779
+ }
20780
+ function StepRow({ step, theme }) {
20781
+ if (step.status === "completed") {
20782
+ return /* @__PURE__ */ jsxs11(Text12, { color: theme.palette.success, children: [
20783
+ " ",
20784
+ "\u2713 ",
20785
+ /* @__PURE__ */ jsx13(Text12, { strikethrough: true, children: step.label })
20786
+ ] });
20787
+ }
20788
+ if (step.status === "active") {
20789
+ return /* @__PURE__ */ jsxs11(Text12, { color: theme.accent, bold: true, children: [
20790
+ " ",
20791
+ /* @__PURE__ */ jsx13(Spinner5, { type: "line" }),
20792
+ " ",
20793
+ step.label
20794
+ ] });
20795
+ }
20796
+ if (step.status === "failed") {
20797
+ return /* @__PURE__ */ jsxs11(Text12, { color: theme.palette.error, children: [
20798
+ " ",
20799
+ "\u2612 ",
20800
+ step.label
20801
+ ] });
20802
+ }
20803
+ return /* @__PURE__ */ jsxs11(Text12, { color: theme.muted?.color ?? theme.info.color, dimColor: true, children: [
20804
+ " ",
20805
+ "\u2610 ",
20806
+ step.label
20750
20807
  ] });
20751
20808
  }
20752
20809
  function formatElapsed6(ms) {
@@ -29917,6 +29974,7 @@ function App({
29917
29974
  const [lastSessionTopic, setLastSessionTopic] = useState27(null);
29918
29975
  const [activeWorkers, setActiveWorkers] = useState27([]);
29919
29976
  const [isSynthesizing, setIsSynthesizing] = useState27(false);
29977
+ const [coordinatorNarration, setCoordinatorNarration] = useState27("");
29920
29978
  useEffect11(() => {
29921
29979
  setGitBranch(detectGitBranch());
29922
29980
  }, []);
@@ -31102,6 +31160,7 @@ ${wcagWarnings.join("\n")}` }
31102
31160
  ...e,
31103
31161
  { kind: "info", key: mkKey(), text: "multi-agent mode: spawning parallel research workers..." }
31104
31162
  ]);
31163
+ setCoordinatorNarration("");
31105
31164
  const controller = new AbortController();
31106
31165
  multiAgentAbortRef.current = controller;
31107
31166
  try {
@@ -31110,13 +31169,27 @@ ${wcagWarnings.join("\n")}` }
31110
31169
  `Current project: ${process.cwd()}`,
31111
31170
  (workers) => setActiveWorkers(workers),
31112
31171
  (phase) => setIsSynthesizing(phase === "synthesizing"),
31113
- controller.signal
31172
+ controller.signal,
31173
+ (text2) => setCoordinatorNarration(text2)
31114
31174
  );
31175
+ setCoordinatorNarration("");
31115
31176
  setEvents((e) => [
31116
31177
  ...e,
31117
31178
  { kind: "info", key: mkKey(), text: "workers completed \u2014 synthesizing findings" }
31118
31179
  ]);
31119
- messagesRef.current.push({ role: "system", content: plan });
31180
+ const asstId = mkAssistantId();
31181
+ setEvents((e) => [
31182
+ ...e,
31183
+ {
31184
+ kind: "assistant",
31185
+ key: `asst_${asstId}`,
31186
+ id: asstId,
31187
+ text: plan,
31188
+ reasoning: "",
31189
+ streaming: false
31190
+ }
31191
+ ]);
31192
+ messagesRef.current.push({ role: "assistant", content: plan });
31120
31193
  if (conflicts.length > 0) {
31121
31194
  setEvents((e) => [
31122
31195
  ...e,
@@ -31139,6 +31212,7 @@ ${conflicts.join("\n")}` }
31139
31212
  return;
31140
31213
  } catch (e) {
31141
31214
  setIsSynthesizing(false);
31215
+ setCoordinatorNarration("");
31142
31216
  const err = e;
31143
31217
  if (err.message === "Cancelled by user") {
31144
31218
  setEvents((e2) => [
@@ -31770,7 +31844,7 @@ ${conflicts.join("\n")}` }
31770
31844
  }
31771
31845
  }
31772
31846
  ) : /* @__PURE__ */ jsxs39(Box39, { flexDirection: "column", marginTop: 1, children: [
31773
- activeWorkers.length > 0 && /* @__PURE__ */ jsx41(WorkerList, { workers: activeWorkers, isSynthesizing }),
31847
+ (activeWorkers.length > 0 || coordinatorNarration) && /* @__PURE__ */ jsx41(WorkerList, { workers: activeWorkers, isSynthesizing, narration: coordinatorNarration }),
31774
31848
  tasks.length > 0 && /* @__PURE__ */ jsx41(
31775
31849
  TaskList,
31776
31850
  {