kimiflare 0.52.0 → 0.53.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 +40 -24
- package/dist/index.js.map +1 -1
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2803,6 +2803,7 @@ ${sandboxResult.output}` : `${warningPrefix}${sandboxResult.output}`;
|
|
|
2803
2803
|
recentToolCalls.push(loopSignature);
|
|
2804
2804
|
if (recentToolCalls.length > LOOP_WINDOW) recentToolCalls.shift();
|
|
2805
2805
|
} else {
|
|
2806
|
+
opts2.callbacks.onToolWillExecute?.(tc.id, tc.function.name);
|
|
2806
2807
|
logger.debug("turn:tool_start", { sessionId: opts2.sessionId, tool: tc.function.name, toolCallId: tc.id });
|
|
2807
2808
|
const result = await opts2.executor.run(
|
|
2808
2809
|
{ id: tc.id, name: tc.function.name, arguments: tc.function.arguments },
|
|
@@ -10173,12 +10174,14 @@ var init_tool_view = __esm({
|
|
|
10173
10174
|
const id = setInterval(() => setNow(Date.now()), 1e3);
|
|
10174
10175
|
return () => clearInterval(id);
|
|
10175
10176
|
}, [evt.status, evt.startedAt]);
|
|
10176
|
-
const statusIcon = evt.status === "running" ? /* @__PURE__ */ jsx3(Text2, { color: theme.info.color, children: /* @__PURE__ */ jsx3(Spinner, { type: "dots" }) }) : evt.status === "error" ? /* @__PURE__ */ jsx3(Text2, { color: theme.palette.error, children: "
|
|
10177
|
+
const statusIcon = evt.status === "queued" ? /* @__PURE__ */ jsx3(Text2, { color: theme.muted?.color ?? theme.info.color, children: "[ ]" }) : evt.status === "running" ? /* @__PURE__ */ jsx3(Text2, { color: theme.info.color, children: /* @__PURE__ */ jsx3(Spinner, { type: "dots" }) }) : evt.status === "error" ? /* @__PURE__ */ jsx3(Text2, { color: theme.palette.error, children: "[err]" }) : evt.status === "cancelled" ? /* @__PURE__ */ jsx3(Text2, { color: theme.info.color, children: "[x]" }) : evt.status === "rejected" ? /* @__PURE__ */ jsx3(Text2, { color: theme.palette.error, children: "[!]" }) : /* @__PURE__ */ jsx3(Text2, { color: theme.palette.success, children: "[ok]" });
|
|
10177
10178
|
const rawTitle = evt.render?.title ?? `${evt.name}(${compactArgs(evt.args)})`;
|
|
10178
10179
|
let title = humanizeToolTitle(evt.name, rawTitle, intentTier);
|
|
10179
|
-
if (evt.startedAt !== void 0) {
|
|
10180
|
+
if (evt.startedAt !== void 0 && (evt.status === "running" || evt.status === "done" || evt.status === "error")) {
|
|
10180
10181
|
title += ` \xB7 ${formatElapsed(now2 - evt.startedAt)}`;
|
|
10181
10182
|
}
|
|
10183
|
+
const statusLabel = evt.status === "rejected" ? /* @__PURE__ */ jsx3(Text2, { color: theme.palette.error, children: " rejected" }) : evt.status === "cancelled" ? /* @__PURE__ */ jsx3(Text2, { color: theme.info.color, children: " cancelled" }) : null;
|
|
10184
|
+
const showItalic = evt.status === "queued" || evt.status === "cancelled" || evt.status === "rejected";
|
|
10182
10185
|
const expand = Boolean(evt.expanded || verbose);
|
|
10183
10186
|
const lines = evt.result ? evt.result.split("\n") : [];
|
|
10184
10187
|
const showLimit = verbose ? 200 : 20;
|
|
@@ -10186,8 +10189,9 @@ var init_tool_view = __esm({
|
|
|
10186
10189
|
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
10187
10190
|
statusIcon,
|
|
10188
10191
|
" ",
|
|
10189
|
-
/* @__PURE__ */ jsx3(Text2, { color: theme.info.color, children: title }),
|
|
10190
|
-
|
|
10192
|
+
/* @__PURE__ */ jsx3(Text2, { color: theme.info.color, italic: showItalic, children: title }),
|
|
10193
|
+
statusLabel,
|
|
10194
|
+
isRepeated ? /* @__PURE__ */ jsx3(Text2, { color: theme.warn, children: " [warn] repeated" }) : null
|
|
10191
10195
|
] }),
|
|
10192
10196
|
evt.render?.diff ? /* @__PURE__ */ jsx3(Box2, { marginLeft: 2, children: /* @__PURE__ */ jsx3(DiffView, { ...evt.render.diff }) }) : null,
|
|
10193
10197
|
evt.result && expand ? /* @__PURE__ */ jsxs2(
|
|
@@ -10209,7 +10213,7 @@ var init_tool_view = __esm({
|
|
|
10209
10213
|
]
|
|
10210
10214
|
}
|
|
10211
10215
|
) : null,
|
|
10212
|
-
evt.result && !expand && evt.status !== "running" ? /* @__PURE__ */ jsxs2(Text2, { color: theme.info.color, children: [
|
|
10216
|
+
evt.result && !expand && evt.status !== "running" && evt.status !== "queued" && evt.status !== "cancelled" && evt.status !== "rejected" ? /* @__PURE__ */ jsxs2(Text2, { color: theme.info.color, children: [
|
|
10213
10217
|
" ",
|
|
10214
10218
|
firstLine(evt.result)
|
|
10215
10219
|
] }) : null
|
|
@@ -17734,8 +17738,11 @@ ${wcagWarnings.join("\n")}` }
|
|
|
17734
17738
|
isAbortingRef.current = true;
|
|
17735
17739
|
supervisorRef.current.killTurn();
|
|
17736
17740
|
activeScopeRef.current.abort("user_stopped");
|
|
17737
|
-
setQueue([]);
|
|
17738
17741
|
setEvents((e) => [...e, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
17742
|
+
for (const [toolId] of pendingToolCallsRef.current) {
|
|
17743
|
+
updateTool(toolId, { status: "cancelled" });
|
|
17744
|
+
}
|
|
17745
|
+
pendingToolCallsRef.current.clear();
|
|
17739
17746
|
void saveSessionSafe();
|
|
17740
17747
|
setTasks([]);
|
|
17741
17748
|
setTasksStartedAt(null);
|
|
@@ -17765,8 +17772,11 @@ ${wcagWarnings.join("\n")}` }
|
|
|
17765
17772
|
setLimitModal(null);
|
|
17766
17773
|
}
|
|
17767
17774
|
activeScopeRef.current.abort("user_stopped");
|
|
17768
|
-
setQueue([]);
|
|
17769
17775
|
setEvents((e) => [...e, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
17776
|
+
for (const [toolId] of pendingToolCallsRef.current) {
|
|
17777
|
+
updateTool(toolId, { status: "cancelled" });
|
|
17778
|
+
}
|
|
17779
|
+
pendingToolCallsRef.current.clear();
|
|
17770
17780
|
setTasks([]);
|
|
17771
17781
|
setTasksStartedAt(null);
|
|
17772
17782
|
setTasksStartTokens(0);
|
|
@@ -17811,7 +17821,6 @@ ${wcagWarnings.join("\n")}` }
|
|
|
17811
17821
|
isAbortingRef.current = true;
|
|
17812
17822
|
supervisorRef.current.killTurn();
|
|
17813
17823
|
activeScopeRef.current.abort("user_stopped");
|
|
17814
|
-
setQueue([]);
|
|
17815
17824
|
setEvents((e) => [...e, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
17816
17825
|
void saveSessionSafe();
|
|
17817
17826
|
setTasks([]);
|
|
@@ -18082,15 +18091,27 @@ ${wcagWarnings.join("\n")}` }
|
|
|
18082
18091
|
id: call.id,
|
|
18083
18092
|
name: call.function.name,
|
|
18084
18093
|
args: call.function.arguments,
|
|
18085
|
-
status: "
|
|
18094
|
+
status: "queued",
|
|
18086
18095
|
render: renderMeta,
|
|
18087
18096
|
expanded: false
|
|
18088
18097
|
}
|
|
18089
18098
|
]);
|
|
18090
18099
|
},
|
|
18100
|
+
onToolWillExecute: (id) => {
|
|
18101
|
+
setTurnPhase("executing");
|
|
18102
|
+
setCurrentToolName(pendingToolCallsRef.current.get(id) ?? null);
|
|
18103
|
+
setLastActivityAt(Date.now());
|
|
18104
|
+
updateTool(id, { status: "running", startedAt: Date.now() });
|
|
18105
|
+
},
|
|
18091
18106
|
onToolResult: (r) => {
|
|
18092
18107
|
pendingToolCallsRef.current.delete(r.tool_call_id);
|
|
18093
|
-
|
|
18108
|
+
setLastActivityAt(Date.now());
|
|
18109
|
+
if (pendingToolCallsRef.current.size === 0) {
|
|
18110
|
+
setTurnPhase("waiting");
|
|
18111
|
+
setCurrentToolName(null);
|
|
18112
|
+
}
|
|
18113
|
+
const isDenied = typeof r.content === "string" && r.content.startsWith("Permission denied");
|
|
18114
|
+
updateTool(r.tool_call_id, { status: isDenied ? "rejected" : r.ok ? "done" : "error", result: r.content });
|
|
18094
18115
|
},
|
|
18095
18116
|
onUsage: (u) => {
|
|
18096
18117
|
usageRef.current = u;
|
|
@@ -19498,13 +19519,18 @@ ${lines.join("\n")}` }]);
|
|
|
19498
19519
|
id: call.id,
|
|
19499
19520
|
name: call.function.name,
|
|
19500
19521
|
args: call.function.arguments,
|
|
19501
|
-
status: "
|
|
19522
|
+
status: "queued",
|
|
19502
19523
|
render: renderMeta,
|
|
19503
|
-
expanded: false
|
|
19504
|
-
startedAt: Date.now()
|
|
19524
|
+
expanded: false
|
|
19505
19525
|
}
|
|
19506
19526
|
]);
|
|
19507
19527
|
},
|
|
19528
|
+
onToolWillExecute: (id, name) => {
|
|
19529
|
+
setTurnPhase("executing");
|
|
19530
|
+
setCurrentToolName(name);
|
|
19531
|
+
setLastActivityAt(Date.now());
|
|
19532
|
+
updateTool(id, { status: "running", startedAt: Date.now() });
|
|
19533
|
+
},
|
|
19508
19534
|
onToolResult: (r) => {
|
|
19509
19535
|
pendingToolCallsRef.current.delete(r.tool_call_id);
|
|
19510
19536
|
setLastActivityAt(Date.now());
|
|
@@ -19513,7 +19539,7 @@ ${lines.join("\n")}` }]);
|
|
|
19513
19539
|
setCurrentToolName(null);
|
|
19514
19540
|
}
|
|
19515
19541
|
updateTool(r.tool_call_id, {
|
|
19516
|
-
status: r.ok ? "done" : "error",
|
|
19542
|
+
status: !r.ok && typeof r.content === "string" && r.content.startsWith("Permission denied") ? "rejected" : r.ok ? "done" : "error",
|
|
19517
19543
|
result: r.content
|
|
19518
19544
|
});
|
|
19519
19545
|
},
|
|
@@ -19812,16 +19838,6 @@ ${lines.join("\n")}` }]);
|
|
|
19812
19838
|
const trimmedDisplay = (display ?? full).trim() || trimmedFull;
|
|
19813
19839
|
const historyEntry = trimmedDisplay;
|
|
19814
19840
|
if (busyRef.current) {
|
|
19815
|
-
if (activeScopeRef.current && !isAbortingRef.current) {
|
|
19816
|
-
isAbortingRef.current = true;
|
|
19817
|
-
supervisorRef.current.killTurn();
|
|
19818
|
-
activeScopeRef.current.abort("new_message");
|
|
19819
|
-
setEvents((e) => [...e, { kind: "info", key: mkKey(), text: "(preempted)" }]);
|
|
19820
|
-
setTasks([]);
|
|
19821
|
-
setTasksStartedAt(null);
|
|
19822
|
-
setTasksStartTokens(0);
|
|
19823
|
-
tasksRef.current = [];
|
|
19824
|
-
}
|
|
19825
19841
|
const key = mkKey();
|
|
19826
19842
|
setEvents((e) => [...e, { kind: "user", key, text: trimmedDisplay, queued: true }]);
|
|
19827
19843
|
setQueue((q) => [...q, { full: trimmedFull, display: trimmedDisplay, key }]);
|