@ai-setting/roy-task-plugin 0.4.0 → 0.4.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/dist/cli.js +33 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1239,6 +1239,18 @@ class NdjsonAssembler {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
1241
|
// ../../../packages/cli/src/daemon/runners/claude-stream.ts
|
|
1242
|
+
function errorDetail(result) {
|
|
1243
|
+
if (typeof result.result === "string" && result.result.trim() !== "") {
|
|
1244
|
+
return result.result.trim();
|
|
1245
|
+
}
|
|
1246
|
+
if (Array.isArray(result.errors)) {
|
|
1247
|
+
const parts = result.errors.map((e) => typeof e === "string" ? e.trim() : "").filter((e) => e !== "");
|
|
1248
|
+
if (parts.length > 0)
|
|
1249
|
+
return parts.join("; ");
|
|
1250
|
+
}
|
|
1251
|
+
return result.subtype === undefined ? "claude reported is_error" : `claude reported ${result.subtype}`;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1242
1254
|
class ClaudeStreamDecoder {
|
|
1243
1255
|
lines = new LineSplitter;
|
|
1244
1256
|
state = { assistantText: [], tools: [] };
|
|
@@ -1300,7 +1312,7 @@ class ClaudeStreamDecoder {
|
|
|
1300
1312
|
const toolCalls = this.state.tools.length > 0 ? this.state.tools.length : undefined;
|
|
1301
1313
|
const tools = this.state.tools.length > 0 ? [...this.state.tools] : undefined;
|
|
1302
1314
|
if (result?.is_error) {
|
|
1303
|
-
const detail =
|
|
1315
|
+
const detail = errorDetail(result);
|
|
1304
1316
|
return { text: "", sessionId: this.state.sessionId, toolCalls, tools, error: detail.slice(0, 1000) };
|
|
1305
1317
|
}
|
|
1306
1318
|
if (typeof result?.result === "string" && result.result.trim() !== "") {
|
|
@@ -1387,29 +1399,37 @@ function makeClaudeRunner(opts = {}) {
|
|
|
1387
1399
|
return { text: "", error: errMsg(err) };
|
|
1388
1400
|
}
|
|
1389
1401
|
const result = decoder.finish();
|
|
1390
|
-
|
|
1391
|
-
|
|
1402
|
+
const stderrText = stderr.trim();
|
|
1403
|
+
const combined = result.error ? stderrText && !result.error.includes(stderrText) ? `${result.error} | ${stderrText}` : result.error : undefined;
|
|
1404
|
+
const effective = combined ? { ...result, error: combined.slice(0, 1000) } : result;
|
|
1405
|
+
if (input.sessionId && effective.sessionId) {
|
|
1406
|
+
sessions.set(input.sessionId, effective.sessionId);
|
|
1392
1407
|
}
|
|
1393
1408
|
if (code === 124) {
|
|
1394
|
-
return { ...
|
|
1409
|
+
return { ...effective, error: `claude timed out after ${timeoutMs}ms` };
|
|
1395
1410
|
}
|
|
1396
|
-
if (
|
|
1397
|
-
if (input.sessionId &&
|
|
1411
|
+
if (effective.error) {
|
|
1412
|
+
if (input.sessionId && STALE_SESSION_RE.test(effective.error)) {
|
|
1398
1413
|
sessions.delete(input.sessionId);
|
|
1399
1414
|
}
|
|
1400
|
-
return
|
|
1415
|
+
return effective;
|
|
1401
1416
|
}
|
|
1402
|
-
if (code !== 0 && !
|
|
1417
|
+
if (code !== 0 && !effective.text) {
|
|
1418
|
+
const error = `claude exited ${code}: ${(stderr || "no stderr").trim().slice(0, 1000)}`;
|
|
1419
|
+
if (input.sessionId && STALE_SESSION_RE.test(error)) {
|
|
1420
|
+
sessions.delete(input.sessionId);
|
|
1421
|
+
}
|
|
1403
1422
|
return {
|
|
1404
1423
|
text: "",
|
|
1405
|
-
toolCalls:
|
|
1406
|
-
tools:
|
|
1407
|
-
error
|
|
1424
|
+
toolCalls: effective.toolCalls,
|
|
1425
|
+
tools: effective.tools,
|
|
1426
|
+
error
|
|
1408
1427
|
};
|
|
1409
1428
|
}
|
|
1410
|
-
return
|
|
1429
|
+
return effective;
|
|
1411
1430
|
};
|
|
1412
1431
|
}
|
|
1432
|
+
var STALE_SESSION_RE = /No conversation found|not a UUID|session title/i;
|
|
1413
1433
|
function errMsg(err) {
|
|
1414
1434
|
if (err instanceof Error)
|
|
1415
1435
|
return err.message;
|
|
@@ -1855,7 +1875,7 @@ function formatStatus(report) {
|
|
|
1855
1875
|
}
|
|
1856
1876
|
|
|
1857
1877
|
// ../../../packages/cli/src/main.ts
|
|
1858
|
-
var VERSION = "0.4.
|
|
1878
|
+
var VERSION = "0.4.2";
|
|
1859
1879
|
async function main(argv) {
|
|
1860
1880
|
const parsed = parseArgs(argv);
|
|
1861
1881
|
switch (parsed.command) {
|