@cspeach/cli 1.1.28 → 1.1.29
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.
|
@@ -82,6 +82,33 @@ function describeApiError(err, msg) {
|
|
|
82
82
|
const label = status ? `service error ${status}` : 'service error';
|
|
83
83
|
return (text ? `${label}: ${text}` : label).slice(0, 200);
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The proxy's `409 {"error":"upgrade_required",min_cli_version,current}`, from
|
|
87
|
+
* the SDK error's parsed `.error` body or, failing that, its message text.
|
|
88
|
+
*/
|
|
89
|
+
function upgradeRequired(err) {
|
|
90
|
+
const e = err;
|
|
91
|
+
let body = e && typeof e.error === 'object' ? e.error : null;
|
|
92
|
+
if (body?.error !== 'upgrade_required') {
|
|
93
|
+
const msg = typeof e?.message === 'string' ? e.message : '';
|
|
94
|
+
const brace = msg.indexOf('{');
|
|
95
|
+
if (!/^409\b/.test(msg) || brace < 0)
|
|
96
|
+
return null;
|
|
97
|
+
try {
|
|
98
|
+
body = JSON.parse(msg.slice(brace, msg.lastIndexOf('}') + 1));
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
if (body?.error !== 'upgrade_required')
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (e?.status != null && e.status !== 409)
|
|
107
|
+
return null;
|
|
108
|
+
const min = typeof body.min_cli_version === 'string' ? body.min_cli_version : 'a newer version';
|
|
109
|
+
const current = typeof body.current === 'string' ? body.current : 'an older version';
|
|
110
|
+
return { min, current };
|
|
111
|
+
}
|
|
85
112
|
/**
|
|
86
113
|
* Write a full diagnostic log to ~/.cspeach/logs/<sessionId>-<ts>.log.
|
|
87
114
|
* Best-effort — failure here is silent, the user-facing block still renders.
|
|
@@ -164,6 +191,19 @@ export async function renderTurnError(input) {
|
|
|
164
191
|
print('');
|
|
165
192
|
return;
|
|
166
193
|
}
|
|
194
|
+
// 1.1.29 — the proxy's 409 upgrade_required (skill needs a newer CLI). It
|
|
195
|
+
// reaches here, not loop.ts's create-time check: the SDK raises it while
|
|
196
|
+
// the stream is read. "type continue" would only repeat the 409.
|
|
197
|
+
const upgrade = upgradeRequired(input.err);
|
|
198
|
+
if (upgrade) {
|
|
199
|
+
printBlock(print, formatFailure({
|
|
200
|
+
what: 'This needs a newer CSPeach',
|
|
201
|
+
detail: [`needs ${upgrade.min} or later · you have ${upgrade.current}`],
|
|
202
|
+
next: input.inSession ? 'type /exit, then run: cspeach --upgrade' : 'cspeach --upgrade',
|
|
203
|
+
}));
|
|
204
|
+
print('');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
167
207
|
const reason = describeError(input.err);
|
|
168
208
|
const logPath = await writeErrorLog(id, input.err);
|
|
169
209
|
const detail = [reason, `Session: ${id}`];
|