dsh-client-auto-continue 0.14.0 → 0.14.2

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/docs/demo-zh.svg CHANGED
@@ -1 +1,147 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="720" height="420" font-family="system-ui, -apple-system, 'Segoe UI', sans-serif" viewBox="0 0 720 420"><defs><linearGradient id="bg" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stop-color="#0b1220"/><stop offset="100%" stop-color="#0e1a2e"/></linearGradient><linearGradient id="accent" x1="0" x2="1" y1="0" y2="0"><stop offset="0%" stop-color="#38bdf8"/><stop offset="100%" stop-color="#818cf8"/></linearGradient></defs><rect width="720" height="420" fill="url(#bg)" rx="20"/><rect width="720" height="46" x="0" y="0" fill="#111c30" rx="20"/><rect width="720" height="16" x="0" y="30" fill="#111c30"/><circle cx="22" cy="23" r="5" fill="#f87171"/><circle cx="38" cy="23" r="5" fill="#fbbf24"/><circle cx="54" cy="23" r="5" fill="#34d399"/><text x="600" y="28" fill="#64748b" font-size="13" text-anchor="end">dsh web — 会话</text><rect width="720" height="3" x="0" y="46" fill="url(#accent)" opacity=".7"/><text x="40" y="92" fill="#94a3b8" font-size="14">你</text><rect width="300" height="34" x="40" y="100" fill="#1e293b" rx="10"/><text x="52" y="121" fill="#e2e8f0" font-size="13">优化一下这个函数</text><text x="40" y="164" fill="#94a3b8" font-size="14">助手</text><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.24;0.28;0.5;0.6;0.84;0.88;1;1" repeatCount="indefinite" values="1;1;0;0;0;0;1;1;0"/><rect width="150" height="34" x="40" y="172" fill="#0f1b2e" stroke="#23324a" rx="10"/><circle cx="70" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle><circle cx="88" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" begin="0.3s" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle><circle cx="106" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" begin="0.6s" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle></g><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.28;0.32;0.48;0.52;1" repeatCount="indefinite" values="0;0;1;1;0;0"/><rect width="420" height="40" x="40" y="236" fill="#2a1215" stroke="#b91c1c" rx="10"/><circle cx="64" cy="256" r="7" fill="#f87171"/><text x="82" y="261" fill="#fecaca" font-size="13">请求中断 — 网络错误 (UPSTREAM)</text></g><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.32;0.5;0.54;0.72;0.76;1" repeatCount="indefinite" values="0;0;0;1;1;0;0"/><rect width="150" height="36" x="40" y="300" fill="#0c4a6e" stroke="#38bdf8" stroke-width="1.5" rx="10"/><text x="52" y="323" fill="#e0f2fe" font-size="13">⏳ 自动发送: 继续</text><text x="210" y="323" fill="#38bdf8" font-size="12">来自 dsh-auto-continue</text></g><rect width="720" height="18" x="0" y="402" fill="#0d1524"/><text x="360" y="414" fill="#475569" font-size="11" text-anchor="middle">宽限 3s → 自动「继续」→ 恢复 — 循环演示</text></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="960" height="660" viewBox="0 0 960 660" role="img" lang="zh" aria-labelledby="title description">
2
+ <title id="title">自动继续:中断恢复演示</title>
3
+ <desc id="description">示意动画:助手因网络错误中断,插件等待 3 秒后自动发送“继续”,助手恢复工作。输入框旁的自动继续开关保持开启。减少动态效果时展示完整的静态过程。</desc>
4
+ <style>
5
+ text { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif; }
6
+ .body { font-size: 24px; }
7
+ .compact { display: none; }
8
+ /* One 12-second cycle: work 0–2s, wait 2–5s, send 5–6.5s, resume 6.5–12s. */
9
+ .notice { animation: notice 12s linear infinite; }
10
+ .auto-message { animation: sent 12s ease-out infinite; }
11
+ .resumed-message { animation: resumed 12s ease-out infinite; }
12
+ .countdown, .step-active, .state-result { opacity: 0; animation: 12s linear infinite; }
13
+ .count-3 { animation-name: count3; }
14
+ .count-2 { animation-name: count2; }
15
+ .count-1 { animation-name: count1; }
16
+ .state-result { animation-name: result; }
17
+ .progress { stroke-dasharray: 100; stroke-dashoffset: 0; animation: progress 12s linear infinite; }
18
+ .step-1 { animation-name: step1; }
19
+ .step-2 { animation-name: step2; }
20
+ .step-3 { animation-name: step3; }
21
+ .step-4 { animation-name: step4; }
22
+ @keyframes notice { 0%, 16% { opacity: 0; } 17%, 96% { opacity: 1; } 98%, 100% { opacity: 0; } }
23
+ @keyframes sent { 0%, 41.66% { opacity: 0; transform: translateY(5px); } 44%, 96% { opacity: 1; transform: translateY(0); } 98%, 100% { opacity: 0; transform: translateY(0); } }
24
+ @keyframes resumed { 0%, 54.16% { opacity: 0; transform: translateY(5px); } 57%, 96% { opacity: 1; transform: translateY(0); } 98%, 100% { opacity: 0; transform: translateY(0); } }
25
+ @keyframes count3 { 0%, 16.66% { opacity: 0; } 16.67%, 24.99% { opacity: 1; } 25%, 100% { opacity: 0; } }
26
+ @keyframes count2 { 0%, 24.99% { opacity: 0; } 25%, 33.32% { opacity: 1; } 33.33%, 100% { opacity: 0; } }
27
+ @keyframes count1 { 0%, 33.32% { opacity: 0; } 33.33%, 41.66% { opacity: 1; } 41.67%, 100% { opacity: 0; } }
28
+ @keyframes result { 0%, 54.16% { opacity: 0; } 54.17%, 100% { opacity: 1; } }
29
+ @keyframes progress { 0%, 16.67% { stroke-dashoffset: 100; } 41.67%, 100% { stroke-dashoffset: 0; } }
30
+ @keyframes step1 { 0%, 16.66% { opacity: 1; } 16.67%, 100% { opacity: 0; } }
31
+ @keyframes step2 { 0%, 16.66% { opacity: 0; } 16.67%, 41.66% { opacity: 1; } 41.67%, 100% { opacity: 0; } }
32
+ @keyframes step3 { 0%, 41.66% { opacity: 0; } 41.67%, 54.16% { opacity: 1; } 54.17%, 100% { opacity: 0; } }
33
+ @keyframes step4 { 0%, 54.16% { opacity: 0; } 54.17%, 100% { opacity: 1; } }
34
+ @media (max-width: 520px) {
35
+ .full { display: none; }
36
+ .compact { display: inline; }
37
+ .body { font-size: 34px; }
38
+ .heading { font-size: 28px; }
39
+ .role, .annotation, .status, .toggle-label { font-size: 26px; }
40
+ .step-label { font-size: 29px; }
41
+ .step-number { display: none; }
42
+ .step-label { transform: translateX(-32px); }
43
+ .footnote { font-size: 24px; }
44
+ .composer-switch { transform: translate(212px, 532px); }
45
+ }
46
+ @media (prefers-reduced-motion: reduce) {
47
+ .notice, .auto-message, .resumed-message, .state-result { animation: none; opacity: 1; transform: none; }
48
+ .countdown { display: none; }
49
+ .progress { animation: none; stroke-dashoffset: 0; }
50
+ .step-active { animation: none; opacity: 0; }
51
+ .step-4 { opacity: 1; }
52
+ }
53
+ </style>
54
+ <rect width="960" height="660" rx="18" fill="#141414"/>
55
+ <path d="M18 0H942Q960 0 960 18V68H0V18Q0 0 18 0Z" fill="#23262c"/>
56
+ <g transform="translate(28 18) scale(.5)"><path d="M49 17A24 24 0 1 0 56 38" fill="none" stroke="#f4f4f5" stroke-width="5" stroke-linecap="round"/>
57
+ <path d="M49 6v12H37" fill="none" stroke="#f4f4f5" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
58
+ <path d="M27 22l16 10-16 10Z" fill="#f4f4f5" stroke="#f4f4f5" stroke-width="2" stroke-linejoin="round"/></g>
59
+ <text class="heading" x="74" y="42" fill="#f4f4f5" font-size="20" font-weight="600">自动继续</text>
60
+ <text class="annotation" x="920" y="42" fill="#b9bec8" font-size="14" text-anchor="end" letter-spacing=".7">恢复过程示意</text>
61
+
62
+ <!-- A simplified conversation, not a recording of a live DSH session. -->
63
+ <rect x="402" y="96" width="518" height="56" rx="16" fill="#2b2b2b"/>
64
+ <text class="body full" x="426" y="132" fill="#f4f4f5">优化一下这个函数。</text>
65
+ <text class="body compact" x="426" y="132" fill="#f4f4f5">优化这个函数。</text>
66
+ <text class="role" x="40" y="196" fill="#f4f4f5" font-size="17" font-weight="600">DSH</text>
67
+ <text class="body full" x="40" y="231" fill="#c4c7ce">我先把校验逻辑和更新操作分开。</text>
68
+ <text class="body compact" x="40" y="231" fill="#c4c7ce">先整理校验逻辑……</text>
69
+
70
+ <g class="notice">
71
+ <rect x="40" y="254" width="880" height="52" rx="9" fill="#23262c"/>
72
+ <g fill="none" stroke="#d0bd96" stroke-width="1.8" stroke-linecap="round">
73
+ <circle cx="62" cy="280" r="8"/>
74
+ <path d="M62 275v5m0 4v.2"/>
75
+ </g>
76
+ <text class="status" x="83" y="287" fill="#d0bd96" font-size="21">网络中断</text>
77
+ <g fill="#d7d9de" font-size="20" text-anchor="end">
78
+ <text class="status countdown count-3" x="898" y="287">等待重试 · 3 s</text>
79
+ <text class="status countdown count-2" x="898" y="287">等待重试 · 2 s</text>
80
+ <text class="status countdown count-1" x="898" y="287">等待重试 · 1 s</text>
81
+ <text class="status state-result" x="898" y="287">已续跑</text>
82
+ </g>
83
+ <path class="progress" d="M84 305H904" pathLength="100" fill="none" stroke="#b9a987" stroke-width="2"/>
84
+ </g>
85
+
86
+ <g class="auto-message">
87
+ <text class="annotation" x="710" y="360" fill="#b9bec8" font-size="18" text-anchor="end">自动发送</text>
88
+ <rect x="732" y="326" width="188" height="54" rx="16" fill="#2b2b2b"/>
89
+ <text class="body" x="796" y="361" fill="#f4f4f5">继续</text>
90
+ </g>
91
+ <g class="resumed-message">
92
+ <text class="role" x="40" y="418" fill="#f4f4f5" font-size="17" font-weight="600">DSH</text>
93
+ <text class="body full" x="40" y="451" fill="#f4f4f5">接着刚才的思路,继续处理。</text>
94
+ <text class="body compact" x="40" y="451" fill="#f4f4f5">接着刚才的思路继续。</text>
95
+ </g>
96
+
97
+ <rect x="40" y="482" width="880" height="86" rx="20" fill="#2b2b2b"/>
98
+ <text class="full" x="61" y="514" fill="#b5b5bd" font-size="21">描述你想构建的内容……</text>
99
+ <text class="body compact" x="61" y="516" fill="#b5b5bd">发送消息……</text>
100
+ <path d="M62 537v14m-7-7h14" fill="none" stroke="#c4c7ce" stroke-width="1.8" stroke-linecap="round"/>
101
+ <text class="toggle-label" x="92" y="551" fill="#d7d9de" font-size="18">自动继续</text>
102
+ <g class="composer-switch" transform="translate(176 532)">
103
+ <rect width="44" height="24" rx="12" fill="#f4f4f5"/>
104
+ <circle cx="32" cy="12" r="9" fill="#141414"/>
105
+ </g>
106
+ <circle cx="888" cy="540" r="16" fill="#44464c"/>
107
+ <path d="M888 547v-14m-5 5 5-5 5 5" fill="none" stroke="#e4e4e7" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
108
+
109
+ <g><g transform="translate(40 602)">
110
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">01</text>
111
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">工作中</text>
112
+ <g class="step-active step-1">
113
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">01</text>
114
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">工作中</text>
115
+ <path d="M0 12H150" stroke="#f4f4f5" stroke-width="2"/>
116
+ </g>
117
+ </g>
118
+ <g transform="translate(272 602)">
119
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">02</text>
120
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">等待恢复</text>
121
+ <g class="step-active step-2">
122
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">02</text>
123
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">等待恢复</text>
124
+ <path d="M0 12H150" stroke="#f4f4f5" stroke-width="2"/>
125
+ </g>
126
+ </g>
127
+ <g transform="translate(504 602)">
128
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">03</text>
129
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">发送继续</text>
130
+ <g class="step-active step-3">
131
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">03</text>
132
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">发送继续</text>
133
+ <path d="M0 12H150" stroke="#f4f4f5" stroke-width="2"/>
134
+ </g>
135
+ </g>
136
+ <g transform="translate(736 602)">
137
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">04</text>
138
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">继续工作</text>
139
+ <g class="step-active step-4">
140
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">04</text>
141
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">继续工作</text>
142
+ <path d="M0 12H150" stroke="#f4f4f5" stroke-width="2"/>
143
+ </g>
144
+ </g></g>
145
+ <text class="footnote full" x="40" y="642" fill="#a1a4ad" font-size="14">过程示意 · 使用默认的 3 秒宽限期</text>
146
+ <text class="footnote compact" x="40" y="642" fill="#a1a4ad" font-size="24">恢复示意 · 等待 3 秒</text>
147
+ </svg>
package/docs/demo.svg CHANGED
@@ -1 +1,147 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="720" height="420" font-family="system-ui, -apple-system, 'Segoe UI', sans-serif" viewBox="0 0 720 420"><defs><linearGradient id="bg" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stop-color="#0b1220"/><stop offset="100%" stop-color="#0e1a2e"/></linearGradient><linearGradient id="accent" x1="0" x2="1" y1="0" y2="0"><stop offset="0%" stop-color="#38bdf8"/><stop offset="100%" stop-color="#818cf8"/></linearGradient></defs><rect width="720" height="420" fill="url(#bg)" rx="20"/><rect width="720" height="46" x="0" y="0" fill="#111c30" rx="20"/><rect width="720" height="16" x="0" y="30" fill="#111c30"/><circle cx="22" cy="23" r="5" fill="#f87171"/><circle cx="38" cy="23" r="5" fill="#fbbf24"/><circle cx="54" cy="23" r="5" fill="#34d399"/><text x="600" y="28" fill="#64748b" font-size="13" text-anchor="end">dsh web — session</text><rect width="720" height="3" x="0" y="46" fill="url(#accent)" opacity=".7"/><text x="40" y="92" fill="#94a3b8" font-size="14">you</text><rect width="300" height="34" x="40" y="100" fill="#1e293b" rx="10"/><text x="52" y="121" fill="#e2e8f0" font-size="13">Refactor this function</text><text x="40" y="164" fill="#94a3b8" font-size="14">agent</text><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.24;0.28;0.5;0.6;0.84;0.88;1;1" repeatCount="indefinite" values="1;1;0;0;0;0;1;1;0"/><rect width="150" height="34" x="40" y="172" fill="#0f1b2e" stroke="#23324a" rx="10"/><circle cx="70" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle><circle cx="88" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" begin="0.3s" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle><circle cx="106" cy="189" r="4" fill="#64748b"><animate attributeName="opacity" begin="0.6s" dur="0.9s" repeatCount="indefinite" values="0.3;1;0.3"/></circle></g><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.28;0.32;0.48;0.52;1" repeatCount="indefinite" values="0;0;1;1;0;0"/><rect width="420" height="40" x="40" y="236" fill="#2a1215" stroke="#b91c1c" rx="10"/><circle cx="64" cy="256" r="7" fill="#f87171"/><text x="82" y="261" fill="#fecaca" font-size="13">Request interrupted — network error (UPSTREAM)</text></g><g><animate attributeName="opacity" dur="5.2s" keyTimes="0;0.32;0.5;0.54;0.72;0.76;1" repeatCount="indefinite" values="0;0;0;1;1;0;0"/><rect width="150" height="36" x="40" y="300" fill="#0c4a6e" stroke="#38bdf8" stroke-width="1.5" rx="10"/><text x="52" y="323" fill="#e0f2fe" font-size="13">⏳ auto-sent: 继续</text><text x="210" y="323" fill="#38bdf8" font-size="12">by dsh-auto-continue</text></g><rect width="720" height="18" x="0" y="402" fill="#0d1524"/><text x="360" y="414" fill="#475569" font-size="11" text-anchor="middle">grace 3s → auto 继续 → resume — looped demo</text></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="960" height="660" viewBox="0 0 960 660" role="img" lang="en" aria-labelledby="title description">
2
+ <title id="title">Auto-continue: interruption recovery demo</title>
3
+ <desc id="description">Illustrated example: a network error interrupts the assistant. After a 3-second grace period, the plugin sends Continue and the assistant resumes work. The auto-continue switch beside the composer stays on. Reduced motion shows the complete sequence as a still image.</desc>
4
+ <style>
5
+ text { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif; }
6
+ .body { font-size: 24px; }
7
+ .compact { display: none; }
8
+ /* One 12-second cycle: work 0–2s, wait 2–5s, send 5–6.5s, resume 6.5–12s. */
9
+ .notice { animation: notice 12s linear infinite; }
10
+ .auto-message { animation: sent 12s ease-out infinite; }
11
+ .resumed-message { animation: resumed 12s ease-out infinite; }
12
+ .countdown, .step-active, .state-result { opacity: 0; animation: 12s linear infinite; }
13
+ .count-3 { animation-name: count3; }
14
+ .count-2 { animation-name: count2; }
15
+ .count-1 { animation-name: count1; }
16
+ .state-result { animation-name: result; }
17
+ .progress { stroke-dasharray: 100; stroke-dashoffset: 0; animation: progress 12s linear infinite; }
18
+ .step-1 { animation-name: step1; }
19
+ .step-2 { animation-name: step2; }
20
+ .step-3 { animation-name: step3; }
21
+ .step-4 { animation-name: step4; }
22
+ @keyframes notice { 0%, 16% { opacity: 0; } 17%, 96% { opacity: 1; } 98%, 100% { opacity: 0; } }
23
+ @keyframes sent { 0%, 41.66% { opacity: 0; transform: translateY(5px); } 44%, 96% { opacity: 1; transform: translateY(0); } 98%, 100% { opacity: 0; transform: translateY(0); } }
24
+ @keyframes resumed { 0%, 54.16% { opacity: 0; transform: translateY(5px); } 57%, 96% { opacity: 1; transform: translateY(0); } 98%, 100% { opacity: 0; transform: translateY(0); } }
25
+ @keyframes count3 { 0%, 16.66% { opacity: 0; } 16.67%, 24.99% { opacity: 1; } 25%, 100% { opacity: 0; } }
26
+ @keyframes count2 { 0%, 24.99% { opacity: 0; } 25%, 33.32% { opacity: 1; } 33.33%, 100% { opacity: 0; } }
27
+ @keyframes count1 { 0%, 33.32% { opacity: 0; } 33.33%, 41.66% { opacity: 1; } 41.67%, 100% { opacity: 0; } }
28
+ @keyframes result { 0%, 54.16% { opacity: 0; } 54.17%, 100% { opacity: 1; } }
29
+ @keyframes progress { 0%, 16.67% { stroke-dashoffset: 100; } 41.67%, 100% { stroke-dashoffset: 0; } }
30
+ @keyframes step1 { 0%, 16.66% { opacity: 1; } 16.67%, 100% { opacity: 0; } }
31
+ @keyframes step2 { 0%, 16.66% { opacity: 0; } 16.67%, 41.66% { opacity: 1; } 41.67%, 100% { opacity: 0; } }
32
+ @keyframes step3 { 0%, 41.66% { opacity: 0; } 41.67%, 54.16% { opacity: 1; } 54.17%, 100% { opacity: 0; } }
33
+ @keyframes step4 { 0%, 54.16% { opacity: 0; } 54.17%, 100% { opacity: 1; } }
34
+ @media (max-width: 520px) {
35
+ .full { display: none; }
36
+ .compact { display: inline; }
37
+ .body { font-size: 34px; }
38
+ .heading { font-size: 28px; }
39
+ .role, .annotation, .status, .toggle-label { font-size: 26px; }
40
+ .step-label { font-size: 29px; }
41
+ .step-number { display: none; }
42
+ .step-label { transform: translateX(-32px); }
43
+ .footnote { font-size: 24px; }
44
+ .composer-switch { transform: translate(276px, 532px); }
45
+ }
46
+ @media (prefers-reduced-motion: reduce) {
47
+ .notice, .auto-message, .resumed-message, .state-result { animation: none; opacity: 1; transform: none; }
48
+ .countdown { display: none; }
49
+ .progress { animation: none; stroke-dashoffset: 0; }
50
+ .step-active { animation: none; opacity: 0; }
51
+ .step-4 { opacity: 1; }
52
+ }
53
+ </style>
54
+ <rect width="960" height="660" rx="18" fill="#141414"/>
55
+ <path d="M18 0H942Q960 0 960 18V68H0V18Q0 0 18 0Z" fill="#23262c"/>
56
+ <g transform="translate(28 18) scale(.5)"><path d="M49 17A24 24 0 1 0 56 38" fill="none" stroke="#f4f4f5" stroke-width="5" stroke-linecap="round"/>
57
+ <path d="M49 6v12H37" fill="none" stroke="#f4f4f5" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
58
+ <path d="M27 22l16 10-16 10Z" fill="#f4f4f5" stroke="#f4f4f5" stroke-width="2" stroke-linejoin="round"/></g>
59
+ <text class="heading" x="74" y="42" fill="#f4f4f5" font-size="20" font-weight="600">Auto-continue</text>
60
+ <text class="annotation" x="920" y="42" fill="#b9bec8" font-size="14" text-anchor="end" letter-spacing=".7">RECOVERY DEMO</text>
61
+
62
+ <!-- A simplified conversation, not a recording of a live DSH session. -->
63
+ <rect x="402" y="96" width="518" height="56" rx="16" fill="#2b2b2b"/>
64
+ <text class="body full" x="426" y="132" fill="#f4f4f5">Refactor this function.</text>
65
+ <text class="body compact" x="426" y="132" fill="#f4f4f5">Refactor this function.</text>
66
+ <text class="role" x="40" y="196" fill="#f4f4f5" font-size="17" font-weight="600">DSH</text>
67
+ <text class="body full" x="40" y="231" fill="#c4c7ce">I’ll separate validation from the update.</text>
68
+ <text class="body compact" x="40" y="231" fill="#c4c7ce">Refactoring the function…</text>
69
+
70
+ <g class="notice">
71
+ <rect x="40" y="254" width="880" height="52" rx="9" fill="#23262c"/>
72
+ <g fill="none" stroke="#d0bd96" stroke-width="1.8" stroke-linecap="round">
73
+ <circle cx="62" cy="280" r="8"/>
74
+ <path d="M62 275v5m0 4v.2"/>
75
+ </g>
76
+ <text class="status" x="83" y="287" fill="#d0bd96" font-size="21">Network interrupted</text>
77
+ <g fill="#d7d9de" font-size="20" text-anchor="end">
78
+ <text class="status countdown count-3" x="898" y="287">Waiting to retry · 3 s</text>
79
+ <text class="status countdown count-2" x="898" y="287">Waiting to retry · 2 s</text>
80
+ <text class="status countdown count-1" x="898" y="287">Waiting to retry · 1 s</text>
81
+ <text class="status state-result" x="898" y="287">Resumed</text>
82
+ </g>
83
+ <path class="progress" d="M84 305H904" pathLength="100" fill="none" stroke="#b9a987" stroke-width="2"/>
84
+ </g>
85
+
86
+ <g class="auto-message">
87
+ <text class="annotation" x="710" y="360" fill="#b9bec8" font-size="18" text-anchor="end">Sent automatically</text>
88
+ <rect x="732" y="326" width="188" height="54" rx="16" fill="#2b2b2b"/>
89
+ <text class="body" x="756" y="361" fill="#f4f4f5">Continue</text>
90
+ </g>
91
+ <g class="resumed-message">
92
+ <text class="role" x="40" y="418" fill="#f4f4f5" font-size="17" font-weight="600">DSH</text>
93
+ <text class="body full" x="40" y="451" fill="#f4f4f5">Picking up where I left off.</text>
94
+ <text class="body compact" x="40" y="451" fill="#f4f4f5">Picking up where I left off.</text>
95
+ </g>
96
+
97
+ <rect x="40" y="482" width="880" height="86" rx="20" fill="#2b2b2b"/>
98
+ <text class="full" x="61" y="514" fill="#b5b5bd" font-size="21">Message the agent…</text>
99
+ <text class="body compact" x="61" y="516" fill="#b5b5bd">Send a message…</text>
100
+ <path d="M62 537v14m-7-7h14" fill="none" stroke="#c4c7ce" stroke-width="1.8" stroke-linecap="round"/>
101
+ <text class="toggle-label" x="92" y="551" fill="#d7d9de" font-size="18">Auto-continue</text>
102
+ <g class="composer-switch" transform="translate(230 532)">
103
+ <rect width="44" height="24" rx="12" fill="#f4f4f5"/>
104
+ <circle cx="32" cy="12" r="9" fill="#141414"/>
105
+ </g>
106
+ <circle cx="888" cy="540" r="16" fill="#44464c"/>
107
+ <path d="M888 547v-14m-5 5 5-5 5 5" fill="none" stroke="#e4e4e7" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
108
+
109
+ <g><g transform="translate(40 602)">
110
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">01</text>
111
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">Working</text>
112
+ <g class="step-active step-1">
113
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">01</text>
114
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">Working</text>
115
+ <path d="M0 12H142" stroke="#f4f4f5" stroke-width="2"/>
116
+ </g>
117
+ </g>
118
+ <g transform="translate(272 602)">
119
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">02</text>
120
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">Waiting</text>
121
+ <g class="step-active step-2">
122
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">02</text>
123
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">Waiting</text>
124
+ <path d="M0 12H142" stroke="#f4f4f5" stroke-width="2"/>
125
+ </g>
126
+ </g>
127
+ <g transform="translate(504 602)">
128
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">03</text>
129
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">Continue</text>
130
+ <g class="step-active step-3">
131
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">03</text>
132
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">Continue</text>
133
+ <path d="M0 12H142" stroke="#f4f4f5" stroke-width="2"/>
134
+ </g>
135
+ </g>
136
+ <g transform="translate(736 602)">
137
+ <text x="0" y="0" fill="#9a9da5" font-size="16" class="step-number">04</text>
138
+ <text x="32" y="0" fill="#9a9da5" font-size="20" class="step-label">Resumed</text>
139
+ <g class="step-active step-4">
140
+ <text x="0" y="0" fill="#f4f4f5" font-size="16" class="step-number">04</text>
141
+ <text x="32" y="0" fill="#f4f4f5" font-size="20" class="step-label">Resumed</text>
142
+ <path d="M0 12H142" stroke="#f4f4f5" stroke-width="2"/>
143
+ </g>
144
+ </g></g>
145
+ <text class="footnote full" x="40" y="642" fill="#a1a4ad" font-size="14">Illustrated example · Default 3-second grace period</text>
146
+ <text class="footnote compact" x="40" y="642" fill="#a1a4ad" font-size="24">Example · 3-second grace</text>
147
+ </svg>
package/lib/index.js CHANGED
@@ -639,9 +639,16 @@ var STREAM_NEAR_DUPLICATE_MAX_CHARS = 2048;
639
639
  var STREAM_TAIL_MAX_CHARS = 4096;
640
640
  function snapshotSessionEvents(session) {
641
641
  const compatible = session;
642
- if (typeof compatible.snapshotEvents === "function") return compatible.snapshotEvents();
643
- if (compatible.events !== void 0) return compatible.events;
644
- throw new TypeError("session exposes neither snapshotEvents() nor events");
642
+ const snapshot = compatible.snapshotEvents;
643
+ const events = typeof snapshot === "function" ? snapshot.call(session) : compatible.events;
644
+ if (!Array.isArray(events)) throw new TypeError("session history is not an event array");
645
+ for (let index = 0; index < events.length; index += 1) {
646
+ const event = events[index];
647
+ if (event === null || typeof event !== "object" || Array.isArray(event) || typeof event.type !== "string" || event.type === "" || !Number.isSafeInteger(event.seq) || event.seq < 0 || !Number.isFinite(event.time) || event.time < 0) {
648
+ throw new TypeError(`invalid session event envelope at index ${index}`);
649
+ }
650
+ }
651
+ return events;
645
652
  }
646
653
  function parseFailureFacts(value) {
647
654
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
@@ -683,6 +690,8 @@ var AutoContinueRunner = class {
683
690
  this.prioritizedFollowups = /* @__PURE__ */ new Set();
684
691
  this.disposed = false;
685
692
  this.bootScannedSessions = /* @__PURE__ */ new WeakSet();
693
+ /** Also bound diagnostics when even an agent's session getter is unavailable. */
694
+ this.bootScanErrors = /* @__PURE__ */ new WeakSet();
686
695
  this.disposeSessionEvents = ctx.on("session/event", (session, event) => {
687
696
  try {
688
697
  this.onHostEvent(session, event);
@@ -1502,80 +1511,108 @@ var AutoContinueRunner = class {
1502
1511
  const now = Date.now();
1503
1512
  const candidates = [];
1504
1513
  for (const agent of this.ctx.agents.list()) {
1505
- const session = agent.session;
1506
- if (session.header.origin === "subagent" || this.bootScannedSessions.has(session)) continue;
1507
- const state = this.state(session.id);
1508
- if (state.pendingTimer !== void 0 || state.consecutive >= config.maxConsecutive) continue;
1509
- if (now - state.lastAttemptAt < this.cooldownFor(state)) continue;
1510
- if (now < (this.pauseUntil.get(session.id) ?? 0)) continue;
1511
- const events = snapshotSessionEvents(session);
1512
- if (events.length === 0) continue;
1513
- let lastEnd;
1514
- for (let i = events.length - 1; i >= 0; i -= 1) {
1515
- const event = events[i];
1516
- if (event?.type === "turn/end") {
1517
- lastEnd = event;
1518
- break;
1514
+ let session;
1515
+ let sessionId;
1516
+ try {
1517
+ session = agent.session;
1518
+ if (this.bootScannedSessions.has(session) || session.header?.origin === "subagent") continue;
1519
+ sessionId = session.id;
1520
+ if (typeof sessionId !== "string" || sessionId === "") throw new TypeError("session id is unavailable");
1521
+ const state = this.state(sessionId);
1522
+ if (state.pendingTimer !== void 0 || state.consecutive >= config.maxConsecutive) continue;
1523
+ if (now - state.lastAttemptAt < this.cooldownFor(state)) continue;
1524
+ if (now < (this.pauseUntil.get(sessionId) ?? 0)) continue;
1525
+ const events = snapshotSessionEvents(session);
1526
+ if (events.length === 0) continue;
1527
+ let lastEnd;
1528
+ for (let i = events.length - 1; i >= 0; i -= 1) {
1529
+ const event = events[i];
1530
+ if (event?.type === "turn/end") {
1531
+ lastEnd = event;
1532
+ break;
1533
+ }
1519
1534
  }
1520
- }
1521
- const reasonKind = readReasonKind(lastEnd?.data.reason);
1522
- const silent = reasonKind === "no-visible-output" && config.resumeSilentTurns;
1523
- const superseded = lastEnd !== void 0 && events.some(
1524
- (event) => event.seq > lastEnd.seq && (event.type === "turn/start" || event.type === "user/message" && event.data.source.kind === "user")
1525
- );
1526
- if (lastEnd === void 0 || reasonKind === void 0 || !isNonHumanReason(reasonKind) && !silent || lastEnd.time < now - config.freshMs || superseded) {
1527
- this.bootScannedSessions.add(session);
1528
- continue;
1529
- }
1530
- let failure;
1531
- if (reasonKind === "error") {
1532
- failure = parseFailureFacts(lastEnd.data.reason.error);
1533
- if (failure === void 0) {
1535
+ const reasonKind = readReasonKind(lastEnd?.data.reason);
1536
+ const silent = reasonKind === "no-visible-output" && config.resumeSilentTurns;
1537
+ const superseded = lastEnd !== void 0 && events.some(
1538
+ (event) => event.seq > lastEnd.seq && (event.type === "turn/start" || event.type === "user/message" && event.data.source.kind === "user")
1539
+ );
1540
+ if (lastEnd === void 0 || reasonKind === void 0 || !isNonHumanReason(reasonKind) && !silent || lastEnd.time < now - config.freshMs || superseded) {
1534
1541
  this.bootScannedSessions.add(session);
1535
- console.error(`[auto-continue] 忽略畸形扫描 turn/end ${session.id}: error details 无法解释`);
1536
1542
  continue;
1537
1543
  }
1538
- if (config.classify && !isTransientFailure(failure, config.retryableErrorPatterns)) {
1539
- this.bootScannedSessions.add(session);
1540
- this.onTurnFailure(session.id, "scan:turn/end:error", failure);
1541
- continue;
1544
+ let failure;
1545
+ if (reasonKind === "error") {
1546
+ failure = parseFailureFacts(lastEnd.data.reason.error);
1547
+ if (failure === void 0) {
1548
+ this.bootScannedSessions.add(session);
1549
+ console.error(`[auto-continue] 忽略畸形扫描 turn/end ${sessionId}: error details 无法解释`);
1550
+ continue;
1551
+ }
1552
+ if (config.classify && !isTransientFailure(failure, config.retryableErrorPatterns)) {
1553
+ this.bootScannedSessions.add(session);
1554
+ this.onTurnFailure(sessionId, "scan:turn/end:error", failure);
1555
+ continue;
1556
+ }
1542
1557
  }
1558
+ candidates.push({
1559
+ session,
1560
+ sessionId,
1561
+ events,
1562
+ lastEnd,
1563
+ reasonKind,
1564
+ failure,
1565
+ lastActivityAt: events.reduce((latest, event) => Math.max(latest, event.time), 0),
1566
+ listIndex: candidates.length
1567
+ });
1568
+ } catch (error) {
1569
+ if (session !== null && typeof session === "object") this.bootScannedSessions.add(session);
1570
+ const identity = session ?? agent;
1571
+ if (identity !== null && typeof identity === "object") {
1572
+ if (this.bootScanErrors.has(identity)) continue;
1573
+ this.bootScanErrors.add(identity);
1574
+ }
1575
+ this.logBootScanFailure(sessionId, error);
1543
1576
  }
1544
- candidates.push({
1545
- session,
1546
- events,
1547
- lastEnd,
1548
- reasonKind,
1549
- failure,
1550
- lastActivityAt: events.reduce((latest, event) => Math.max(latest, event.time), 0),
1551
- listIndex: candidates.length
1552
- });
1553
1577
  }
1554
1578
  candidates.sort((left, right) => right.lastActivityAt - left.lastActivityAt || left.listIndex - right.listIndex);
1555
- for (const candidate of candidates.slice(0, config.scanLimit)) {
1579
+ let recoveries = 0;
1580
+ for (const candidate of candidates) {
1581
+ if (recoveries >= config.scanLimit) break;
1556
1582
  if (this.disposed) return true;
1557
- const { session, events, lastEnd, reasonKind, failure } = candidate;
1583
+ const { session, sessionId, events, lastEnd, reasonKind, failure } = candidate;
1558
1584
  this.bootScannedSessions.add(session);
1559
- const state = this.state(session.id);
1560
- this.applyGuardFromEvents(state, events, lastEnd.seq);
1561
- const scanReason = `scan:turn/end:${reasonKind}${reasonKind === "no-visible-output" ? ":silent" : ""}`;
1562
- this.log(`扫描发现中断 ${session.id}(turn/end:${reasonKind}), 交给恢复策略处理`);
1563
- if (failure !== void 0) {
1564
- state.lastFailure = failure;
1565
- state.lastTurn = lastEnd.data.turn;
1566
- state.lastFailureAt = lastEnd.time;
1567
- this.onTurnFailure(session.id, scanReason, failure);
1568
- } else {
1569
- if (reasonKind === "no-visible-output") {
1570
- state.lastFailure = void 0;
1585
+ const state = this.state(sessionId);
1586
+ try {
1587
+ this.applyGuardFromEvents(state, events, lastEnd.seq);
1588
+ const scanReason = `scan:turn/end:${reasonKind}${reasonKind === "no-visible-output" ? ":silent" : ""}`;
1589
+ this.log(`扫描发现中断 ${sessionId}(turn/end:${reasonKind}), 交给恢复策略处理`);
1590
+ if (failure !== void 0) {
1591
+ state.lastFailure = failure;
1571
1592
  state.lastTurn = lastEnd.data.turn;
1572
1593
  state.lastFailureAt = lastEnd.time;
1594
+ this.onTurnFailure(sessionId, scanReason, failure);
1595
+ } else {
1596
+ if (reasonKind === "no-visible-output") {
1597
+ state.lastFailure = void 0;
1598
+ state.lastTurn = lastEnd.data.turn;
1599
+ state.lastFailureAt = lastEnd.time;
1600
+ }
1601
+ this.schedule(sessionId, scanReason);
1573
1602
  }
1574
- this.schedule(session.id, scanReason);
1603
+ recoveries += 1;
1604
+ } catch (error) {
1605
+ state.tools.reset();
1606
+ this.cancelPending(sessionId, "启动扫描失败");
1607
+ this.logBootScanFailure(sessionId, error);
1575
1608
  }
1576
1609
  }
1577
1610
  return false;
1578
1611
  }
1612
+ /** Captured identity only: even session.id can throw when the header is damaged. */
1613
+ logBootScanFailure(sessionId, error) {
1614
+ console.error(`[auto-continue] 启动扫描跳过会话 ${sessionId ?? "(id unavailable)"}: ${error instanceof Error ? error.message : String(error)}`);
1615
+ }
1579
1616
  /** 从历史事件恢复上一步工具调用状态(扫描路径的幂等护栏)。 */
1580
1617
  applyGuardFromEvents(state, events, untilSeq) {
1581
1618
  state.tools.restore(events, untilSeq);
@@ -42,6 +42,8 @@ export declare class AutoContinueRunner {
42
42
  private readonly disposeInboxEvents;
43
43
  private disposed;
44
44
  private readonly bootScannedSessions;
45
+ /** Also bound diagnostics when even an agent's session getter is unavailable. */
46
+ private readonly bootScanErrors;
45
47
  private bootScanTimer;
46
48
  private wakeBootScan;
47
49
  /**
@@ -135,6 +137,8 @@ export declare class AutoContinueRunner {
135
137
  private bootScanLoop;
136
138
  /** Inspect newly available sessions; process each settled startup history once. */
137
139
  private scanInterrupted;
140
+ /** Captured identity only: even session.id can throw when the header is damaged. */
141
+ private logBootScanFailure;
138
142
  /** 从历史事件恢复上一步工具调用状态(扫描路径的幂等护栏)。 */
139
143
  private applyGuardFromEvents;
140
144
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-client-auto-continue",
3
3
  "description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
4
- "version": "0.14.0",
4
+ "version": "0.14.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -46,8 +46,8 @@
46
46
  "build": "node build.mjs && tsc -p tsconfig.build.json",
47
47
  "watch": "node build.mjs --watch",
48
48
  "typecheck": "tsc --noEmit",
49
- "test:runtime": "node tests/settings-host-live.mjs 0.1.7 && node tests/settings-host-live.mjs 0.2.0 && node tests/settings-host-live.mjs 0.2.1 && node tests/profile-compatibility.mjs 0.2.0 && node tests/profile-compatibility.mjs 0.2.1 && node tests/client-settings-services.mjs 0.2.0 && node tests/client-settings-services.mjs 0.2.1",
50
- "test": "node tests/scan-on-boot.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs",
49
+ "test:runtime": "node tests/settings-host-live.mjs 0.1.7 && node tests/settings-host-live.mjs 0.2.0 && node tests/settings-host-live.mjs 0.2.1 && node tests/profile-compatibility.mjs 0.2.0 && node tests/profile-compatibility.mjs 0.2.1 && node tests/client-settings-services.mjs 0.2.0 && node tests/client-settings-services.mjs 0.2.1 && node tests/boot-scan-host-live.mjs 0.2.0-rc.2 && node tests/boot-scan-host-live.mjs 0.2.1",
50
+ "test": "node tests/scan-on-boot.mjs && node tests/boot-scan-isolation.mjs && node tests/silent-turn-boundaries.mjs && node tests/autonomous-loop.mjs && node tests/manual-resume-pauses.mjs && node tests/stats-freshness.mjs && node tests/simulate-host.mjs && node tests/settings-host-compat.mjs && node tests/simulate-client-loader.mjs && node tests/client-settings-services.mjs && node tests/client-settings-form.mjs && node tests/locale-mirror-bounded.mjs && node tests/settings-card-ui.mjs && node tests/composer-toggle.mjs && node tests/settings-notifications.mjs && node tests/prepare-github-package.mjs",
51
51
  "prepack": "npm run build"
52
52
  },
53
53
  "keywords": [