kimiflare 0.13.2 → 0.13.3
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 +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87,6 +87,8 @@ async function* readSSE(stream, signal) {
|
|
|
87
87
|
const reader = stream.getReader();
|
|
88
88
|
const decoder = new TextDecoder("utf-8");
|
|
89
89
|
let buffer = "";
|
|
90
|
+
const onAbort = () => reader.cancel(new DOMException("aborted", "AbortError"));
|
|
91
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
90
92
|
try {
|
|
91
93
|
while (true) {
|
|
92
94
|
if (signal?.aborted) throw new DOMException("aborted", "AbortError");
|
|
@@ -106,6 +108,7 @@ async function* readSSE(stream, signal) {
|
|
|
106
108
|
const tail = extractData(buffer.trim());
|
|
107
109
|
if (tail !== null) yield tail;
|
|
108
110
|
} finally {
|
|
111
|
+
signal?.removeEventListener("abort", onAbort);
|
|
109
112
|
reader.releaseLock();
|
|
110
113
|
}
|
|
111
114
|
}
|
|
@@ -3737,6 +3740,7 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3737
3740
|
const updateCheckedRef = useRef3(false);
|
|
3738
3741
|
const updateNudgedRef = useRef3(false);
|
|
3739
3742
|
const compactSuggestedRef = useRef3(false);
|
|
3743
|
+
const interruptRequestedRef = useRef3(false);
|
|
3740
3744
|
useEffect4(() => {
|
|
3741
3745
|
if (!cfg || updateCheckedRef.current) return;
|
|
3742
3746
|
updateCheckedRef.current = true;
|
|
@@ -3871,6 +3875,10 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3871
3875
|
useInput2((inputChar, key) => {
|
|
3872
3876
|
if (key.ctrl && inputChar === "c") {
|
|
3873
3877
|
if (busy) {
|
|
3878
|
+
if (interruptRequestedRef.current) {
|
|
3879
|
+
process.exit(0);
|
|
3880
|
+
}
|
|
3881
|
+
interruptRequestedRef.current = true;
|
|
3874
3882
|
activeControllerRef.current?.abort();
|
|
3875
3883
|
permResolveRef.current?.("deny");
|
|
3876
3884
|
permResolveRef.current = null;
|
|
@@ -3966,6 +3974,7 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3966
3974
|
setBusy(false);
|
|
3967
3975
|
setTurnStartedAt(null);
|
|
3968
3976
|
activeControllerRef.current = null;
|
|
3977
|
+
interruptRequestedRef.current = false;
|
|
3969
3978
|
}
|
|
3970
3979
|
}, [cfg, busy, saveSessionSafe]);
|
|
3971
3980
|
const openResumePicker = useCallback(async () => {
|
|
@@ -4146,6 +4155,7 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
4146
4155
|
activeAsstIdRef.current = null;
|
|
4147
4156
|
activeControllerRef.current = null;
|
|
4148
4157
|
permResolveRef.current = null;
|
|
4158
|
+
interruptRequestedRef.current = false;
|
|
4149
4159
|
}
|
|
4150
4160
|
}, [cfg, busy, updateAssistant, updateTool]);
|
|
4151
4161
|
const handleResumePick = useCallback(
|
|
@@ -4606,10 +4616,18 @@ use: /thinking low | medium | high`
|
|
|
4606
4616
|
activeAsstIdRef.current = null;
|
|
4607
4617
|
activeControllerRef.current = null;
|
|
4608
4618
|
permResolveRef.current = null;
|
|
4619
|
+
interruptRequestedRef.current = false;
|
|
4609
4620
|
}
|
|
4610
4621
|
},
|
|
4611
4622
|
[cfg, handleSlash, updateAssistant, updateTool, saveSessionSafe]
|
|
4612
4623
|
);
|
|
4624
|
+
useEffect4(() => {
|
|
4625
|
+
const onSigint = () => exit();
|
|
4626
|
+
process.on("SIGINT", onSigint);
|
|
4627
|
+
return () => {
|
|
4628
|
+
process.off("SIGINT", onSigint);
|
|
4629
|
+
};
|
|
4630
|
+
}, [exit]);
|
|
4613
4631
|
useEffect4(() => {
|
|
4614
4632
|
if (!busy && queue.length > 0) {
|
|
4615
4633
|
const next = queue[0];
|
|
@@ -4884,7 +4902,10 @@ async function runPrintMode(opts2) {
|
|
|
4884
4902
|
{ role: "user", content: opts2.prompt }
|
|
4885
4903
|
];
|
|
4886
4904
|
const controller = new AbortController();
|
|
4887
|
-
process.
|
|
4905
|
+
process.once("SIGINT", () => {
|
|
4906
|
+
controller.abort();
|
|
4907
|
+
setTimeout(() => process.exit(1), 500);
|
|
4908
|
+
});
|
|
4888
4909
|
let printedReasoningHeader = false;
|
|
4889
4910
|
let printedAnswerHeader = false;
|
|
4890
4911
|
await runAgentTurn({
|