kimiflare 0.12.0 → 0.13.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 +32 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3626,6 +3626,7 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3626
3626
|
const executorRef = useRef3(new ToolExecutor(ALL_TOOLS));
|
|
3627
3627
|
const activeAsstIdRef = useRef3(null);
|
|
3628
3628
|
const activeControllerRef = useRef3(null);
|
|
3629
|
+
const permResolveRef = useRef3(null);
|
|
3629
3630
|
const sessionIdRef = useRef3(null);
|
|
3630
3631
|
const modeRef = useRef3(mode);
|
|
3631
3632
|
const effortRef = useRef3(effort);
|
|
@@ -3767,8 +3768,11 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3767
3768
|
}, [cfg]);
|
|
3768
3769
|
useInput2((inputChar, key) => {
|
|
3769
3770
|
if (key.ctrl && inputChar === "c") {
|
|
3770
|
-
if (busy
|
|
3771
|
-
activeControllerRef.current
|
|
3771
|
+
if (busy) {
|
|
3772
|
+
activeControllerRef.current?.abort();
|
|
3773
|
+
permResolveRef.current?.("deny");
|
|
3774
|
+
permResolveRef.current = null;
|
|
3775
|
+
setPerm(null);
|
|
3772
3776
|
setQueue([]);
|
|
3773
3777
|
setEvents((e) => [...e, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
3774
3778
|
} else {
|
|
@@ -3990,7 +3994,11 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
3990
3994
|
resolve2("deny");
|
|
3991
3995
|
return;
|
|
3992
3996
|
}
|
|
3993
|
-
|
|
3997
|
+
permResolveRef.current = resolve2;
|
|
3998
|
+
setPerm({ tool: req.tool, args: req.args, resolve: (d) => {
|
|
3999
|
+
permResolveRef.current = null;
|
|
4000
|
+
resolve2(d);
|
|
4001
|
+
} });
|
|
3994
4002
|
})
|
|
3995
4003
|
}
|
|
3996
4004
|
});
|
|
@@ -4010,17 +4018,25 @@ function App({ initialCfg, initialUpdateResult }) {
|
|
|
4010
4018
|
]);
|
|
4011
4019
|
}
|
|
4012
4020
|
} catch (e) {
|
|
4013
|
-
if (e.name
|
|
4021
|
+
if (e.name === "AbortError") {
|
|
4022
|
+
setEvents((es) => [...es, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
4023
|
+
setEvents(
|
|
4024
|
+
(evts) => evts.map((e2) => e2.kind === "tool" && e2.status === "running" ? { ...e2, status: "error", result: "(interrupted)" } : e2)
|
|
4025
|
+
);
|
|
4026
|
+
} else {
|
|
4014
4027
|
setEvents((es) => [
|
|
4015
4028
|
...es,
|
|
4016
4029
|
{ kind: "error", key: mkKey(), text: `init failed: ${e.message}` }
|
|
4017
4030
|
]);
|
|
4018
4031
|
}
|
|
4019
4032
|
} finally {
|
|
4033
|
+
const asstId = activeAsstIdRef.current;
|
|
4034
|
+
if (asstId !== null) updateAssistant(asstId, () => ({ streaming: false }));
|
|
4020
4035
|
setBusy(false);
|
|
4021
4036
|
setTurnStartedAt(null);
|
|
4022
4037
|
activeAsstIdRef.current = null;
|
|
4023
4038
|
activeControllerRef.current = null;
|
|
4039
|
+
permResolveRef.current = null;
|
|
4024
4040
|
}
|
|
4025
4041
|
}, [cfg, busy, updateAssistant, updateTool]);
|
|
4026
4042
|
const handleResumePick = useCallback(
|
|
@@ -4432,14 +4448,21 @@ use: /thinking low | medium | high`
|
|
|
4432
4448
|
resolve2("deny");
|
|
4433
4449
|
return;
|
|
4434
4450
|
}
|
|
4435
|
-
|
|
4451
|
+
permResolveRef.current = resolve2;
|
|
4452
|
+
setPerm({ tool: req.tool, args: req.args, resolve: (d) => {
|
|
4453
|
+
permResolveRef.current = null;
|
|
4454
|
+
resolve2(d);
|
|
4455
|
+
} });
|
|
4436
4456
|
})
|
|
4437
4457
|
}
|
|
4438
4458
|
});
|
|
4439
4459
|
await saveSessionSafe();
|
|
4440
4460
|
} catch (e) {
|
|
4441
4461
|
if (e.name === "AbortError") {
|
|
4442
|
-
setEvents((es) => [...es, { kind: "info", key: mkKey(), text: "(
|
|
4462
|
+
setEvents((es) => [...es, { kind: "info", key: mkKey(), text: "(interrupted)" }]);
|
|
4463
|
+
setEvents(
|
|
4464
|
+
(evts) => evts.map((e2) => e2.kind === "tool" && e2.status === "running" ? { ...e2, status: "error", result: "(interrupted)" } : e2)
|
|
4465
|
+
);
|
|
4443
4466
|
} else {
|
|
4444
4467
|
const isInvalidJson400 = e instanceof KimiApiError && e.httpStatus === 400 && e.message.includes("invalid escaped character");
|
|
4445
4468
|
if (isInvalidJson400) {
|
|
@@ -4460,10 +4483,13 @@ use: /thinking low | medium | high`
|
|
|
4460
4483
|
}
|
|
4461
4484
|
}
|
|
4462
4485
|
} finally {
|
|
4486
|
+
const asstId = activeAsstIdRef.current;
|
|
4487
|
+
if (asstId !== null) updateAssistant(asstId, () => ({ streaming: false }));
|
|
4463
4488
|
setBusy(false);
|
|
4464
4489
|
setTurnStartedAt(null);
|
|
4465
4490
|
activeAsstIdRef.current = null;
|
|
4466
4491
|
activeControllerRef.current = null;
|
|
4492
|
+
permResolveRef.current = null;
|
|
4467
4493
|
}
|
|
4468
4494
|
},
|
|
4469
4495
|
[cfg, handleSlash, updateAssistant, updateTool, saveSessionSafe]
|