@co0ontty/wand 1.63.0 → 1.63.1-beta.gc173e20
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/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
3
|
-
"builtAt": "2026-06-14T06:
|
|
4
|
-
"version": "1.63.
|
|
5
|
-
"channel": "
|
|
2
|
+
"commit": "c173e20f2e7e864991c953a06e6187e84f422e67",
|
|
3
|
+
"builtAt": "2026-06-14T06:57:15.075Z",
|
|
4
|
+
"version": "1.63.1-beta.gc173e20",
|
|
5
|
+
"channel": "beta"
|
|
6
6
|
}
|
|
@@ -1700,6 +1700,25 @@ export class StructuredSessionManager {
|
|
|
1700
1700
|
// saveSession serializes the full messages array.
|
|
1701
1701
|
this.saveStreamingSnapshot(patched);
|
|
1702
1702
|
};
|
|
1703
|
+
// 关键修复:claude -p 的 session_id 出现在 system(init) / assistant / user /
|
|
1704
|
+
// result 全部事件里,并非只在最终的 result。若本轮被中断(用户打断、
|
|
1705
|
+
// AskUserQuestion 主动 kill、ExitPlanMode 自续接)或进程异常退出而没走到
|
|
1706
|
+
// result,旧逻辑只在 result 里取 session_id 会让 claudeSessionId 一直为 null,
|
|
1707
|
+
// 下一轮(含排队消息续接)就不带 --resume → 丢掉全部历史上下文。这里从任何带
|
|
1708
|
+
// session_id 的事件即时捕获并落库,保证 resume 链不因缺少 result 事件而断裂。
|
|
1709
|
+
const captureSessionId = (sid) => {
|
|
1710
|
+
if (typeof sid !== "string" || !sid)
|
|
1711
|
+
return;
|
|
1712
|
+
if (turnState.sessionId === sid)
|
|
1713
|
+
return;
|
|
1714
|
+
turnState.sessionId = sid;
|
|
1715
|
+
const current = this.sessions.get(sessionId);
|
|
1716
|
+
if (current && current.claudeSessionId !== sid) {
|
|
1717
|
+
const patched = { ...current, claudeSessionId: sid };
|
|
1718
|
+
this.sessions.set(sessionId, patched);
|
|
1719
|
+
this.saveStreamingSnapshot(patched);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1703
1722
|
const processLine = (line) => {
|
|
1704
1723
|
const trimmed = line.trim();
|
|
1705
1724
|
if (!trimmed)
|
|
@@ -1712,6 +1731,8 @@ export class StructuredSessionManager {
|
|
|
1712
1731
|
return;
|
|
1713
1732
|
}
|
|
1714
1733
|
this.logger?.appendStreamEvent(sessionId, parsed);
|
|
1734
|
+
// 所有事件都可能带顶层 session_id(含 system init);立即捕获,不等 result。
|
|
1735
|
+
captureSessionId(parsed?.session_id);
|
|
1715
1736
|
if (parsed && parsed.type === "assistant" && parsed.message) {
|
|
1716
1737
|
const extracted = this.extractAssistantMessage(parsed.message);
|
|
1717
1738
|
// 用 message.id 作为 key:claude -p 流式重发同一条消息时整段覆盖
|
|
@@ -1787,9 +1808,7 @@ export class StructuredSessionManager {
|
|
|
1787
1808
|
if (typeof parsed.result === "string") {
|
|
1788
1809
|
turnState.result = parsed.result.trim();
|
|
1789
1810
|
}
|
|
1790
|
-
|
|
1791
|
-
turnState.sessionId = parsed.session_id;
|
|
1792
|
-
}
|
|
1811
|
+
// session_id 已由顶部 captureSessionId 统一捕获,这里不再重复赋值。
|
|
1793
1812
|
turnState.model = this.extractModelName(parsed.modelUsage) ?? turnState.model;
|
|
1794
1813
|
turnState.usage = this.extractUsage(parsed) ?? turnState.usage;
|
|
1795
1814
|
syncSnapshot();
|
|
@@ -2227,6 +2246,20 @@ export class StructuredSessionManager {
|
|
|
2227
2246
|
for await (const msg of queryHandle) {
|
|
2228
2247
|
if (abortController.signal.aborted)
|
|
2229
2248
|
break;
|
|
2249
|
+
// 同 CLI runner 的关键修复:从任何带 session_id 的 SDK 消息(system / assistant /
|
|
2250
|
+
// user / result)即时捕获并落库。AskUserQuestion 的 interrupt 发生在 assistant
|
|
2251
|
+
// 之后、result 之前,若只在 result 捕获,被 interrupt 的轮次会丢掉 session_id,
|
|
2252
|
+
// 续接时不 resume → 上下文丢失。stream_event 等无 session_id 的消息被 guard 跳过。
|
|
2253
|
+
const msgSessionId = msg.session_id;
|
|
2254
|
+
if (typeof msgSessionId === "string" && msgSessionId && turnState.sessionId !== msgSessionId) {
|
|
2255
|
+
turnState.sessionId = msgSessionId;
|
|
2256
|
+
const cur = this.sessions.get(sessionId);
|
|
2257
|
+
if (cur && cur.claudeSessionId !== msgSessionId) {
|
|
2258
|
+
const patched = { ...cur, claudeSessionId: msgSessionId };
|
|
2259
|
+
this.sessions.set(sessionId, patched);
|
|
2260
|
+
this.saveStreamingSnapshot(patched);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2230
2263
|
// Incremental streaming events (opt-in via includePartialMessages: true)
|
|
2231
2264
|
if (msg.type === "stream_event") {
|
|
2232
2265
|
const partial = msg;
|