kimiflare 0.29.0 → 0.29.1

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
@@ -5091,7 +5091,9 @@ async function compactMessages(opts2) {
5091
5091
  prefixEnd++;
5092
5092
  }
5093
5093
  const prefix = messages.slice(0, prefixEnd);
5094
- if (prefix.length === 0) throw new Error("compact: no system message found");
5094
+ if (prefix.length === 0) {
5095
+ return { summary: "", newMessages: messages, replacedCount: 0 };
5096
+ }
5095
5097
  const cutoffUserIdx = indexOfNthUserFromEnd(messages, keep);
5096
5098
  const firstKeepIdx = cutoffUserIdx >= 0 ? cutoffUserIdx : messages.length;
5097
5099
  const toSummarize = messages.slice(prefixEnd, firstKeepIdx);
@@ -11647,6 +11649,7 @@ function App({
11647
11649
  const memoryManagerRef = useRef3(null);
11648
11650
  const sessionStartRecallRef = useRef3(null);
11649
11651
  const orchestratorRef = useRef3(null);
11652
+ const pendingOrchestratorStateRef = useRef3(null);
11650
11653
  const pendingTextRef = useRef3(/* @__PURE__ */ new Map());
11651
11654
  const flushTimeoutRef = useRef3(null);
11652
11655
  const customCommandsRef = useRef3([]);
@@ -12562,58 +12565,15 @@ function App({
12562
12565
  } else {
12563
12566
  artifactStoreRef.current = new ArtifactStore();
12564
12567
  }
12565
- if (file.multiAgentState && cfg?.multiAgent) {
12566
- if (!orchestratorRef.current) {
12567
- orchestratorRef.current = new AgentOrchestrator({
12568
- accountId: cfg.accountId,
12569
- apiToken: cfg.apiToken,
12570
- model: cfg.model,
12571
- orchestratorModel: cfg.orchestratorModel ?? cfg.plumbingModel ?? "@cf/meta/llama-4-scout-17b-16e-instruct",
12572
- gateway: gatewayFromConfig(cfg),
12573
- cwd: process.cwd(),
12574
- signal: new AbortController().signal,
12575
- reasoningEffort: effortRef.current,
12576
- coauthor: cfg.coauthor !== false ? { name: cfg.coauthorName || "kimiflare", email: cfg.coauthorEmail || "kimiflare@proton.me" } : void 0,
12577
- sessionId: file.id,
12578
- memoryManager: memoryManagerRef.current,
12579
- keepLastImageTurns: cfg.imageHistoryTurns ?? 2,
12580
- codeMode,
12581
- callbacks: {
12582
- onAssistantStart: () => {
12583
- },
12584
- onReasoningDelta: () => {
12585
- },
12586
- onTextDelta: () => {
12587
- },
12588
- onToolCallStart: () => {
12589
- },
12590
- onToolCallArgs: () => {
12591
- },
12592
- onToolCallFinalized: () => {
12593
- },
12594
- onUsage: () => {
12595
- },
12596
- onUsageFinal: () => {
12597
- },
12598
- onGatewayMeta: () => {
12599
- },
12600
- onAssistantFinal: () => {
12601
- },
12602
- onToolResult: () => {
12603
- },
12604
- onTasks: () => {
12605
- },
12606
- askPermission: async () => "allow"
12607
- },
12608
- executor: executorRef.current,
12609
- mcpTools: mcpToolsRef.current,
12610
- lspTools: lspToolsRef.current,
12611
- autoSwitch: cfg.autoSwitch ?? false,
12612
- autoSwitchConfirm: cfg.autoSwitchConfirm ?? false,
12613
- customAgents: cfg.customAgents
12614
- });
12568
+ if (cfg?.multiAgent) {
12569
+ if (file.multiAgentState) {
12570
+ pendingOrchestratorStateRef.current = file.multiAgentState;
12571
+ } else {
12572
+ pendingOrchestratorStateRef.current = {
12573
+ activeRole: "generalist",
12574
+ agents: [{ role: "generalist", messages: file.messages, recentToolCalls: [] }]
12575
+ };
12615
12576
  }
12616
- orchestratorRef.current.deserialize(file.multiAgentState);
12617
12577
  }
12618
12578
  const manager = memoryManagerRef.current;
12619
12579
  if (manager) {
@@ -12699,6 +12659,7 @@ function App({
12699
12659
  artifactStoreRef.current = new ArtifactStore();
12700
12660
  executorRef.current.clearArtifacts();
12701
12661
  orchestratorRef.current = null;
12662
+ pendingOrchestratorStateRef.current = null;
12702
12663
  setEvents([]);
12703
12664
  setUsage(null);
12704
12665
  setSessionUsage(null);
@@ -13599,6 +13560,20 @@ ${lines.join("\n")}` }]);
13599
13560
  },
13600
13561
  customAgents: cfg.customAgents
13601
13562
  });
13563
+ if (pendingOrchestratorStateRef.current) {
13564
+ orchestratorRef.current.deserialize(pendingOrchestratorStateRef.current);
13565
+ pendingOrchestratorStateRef.current = null;
13566
+ }
13567
+ const activeSession2 = orchestratorRef.current.getActiveSession();
13568
+ if (!activeSession2.messages.some((m) => m.role === "system")) {
13569
+ const prefix = makePrefixMessages(
13570
+ cacheStableRef.current,
13571
+ overrideModel ?? cfg.model,
13572
+ modeRef.current,
13573
+ [...ALL_TOOLS, ...mcpToolsRef.current, ...lspToolsRef.current]
13574
+ );
13575
+ activeSession2.messages.unshift(...prefix);
13576
+ }
13602
13577
  }
13603
13578
  await orchestratorRef.current.runTurn({ role: "user", content });
13604
13579
  const activeSession = orchestratorRef.current.getActiveSession();