claude-code-controller 0.5.0 → 0.5.1
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/api/index.cjs +44 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +44 -0
- package/dist/api/index.js.map +1 -1
- package/dist/{claude-CSXlMCvP.d.cts → claude-0cg912ch.d.cts} +5 -0
- package/dist/{claude-CSXlMCvP.d.ts → claude-0cg912ch.d.ts} +5 -0
- package/dist/index.cjs +44 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/api/index.cjs
CHANGED
|
@@ -134,6 +134,8 @@ var import_hono = require("hono");
|
|
|
134
134
|
var import_node_events = require("events");
|
|
135
135
|
var import_node_child_process3 = require("child_process");
|
|
136
136
|
var import_node_crypto2 = require("crypto");
|
|
137
|
+
var import_node_fs4 = require("fs");
|
|
138
|
+
var import_node_path3 = require("path");
|
|
137
139
|
|
|
138
140
|
// src/team-manager.ts
|
|
139
141
|
var import_promises = require("fs/promises");
|
|
@@ -466,6 +468,8 @@ if pid == 0:
|
|
|
466
468
|
else:
|
|
467
469
|
signal.signal(signal.SIGTERM, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
468
470
|
signal.signal(signal.SIGINT, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
471
|
+
buf = b""
|
|
472
|
+
trust_sent = False
|
|
469
473
|
try:
|
|
470
474
|
while True:
|
|
471
475
|
r, _, _ = select.select([fd, 0], [], [], 1.0)
|
|
@@ -475,6 +479,12 @@ else:
|
|
|
475
479
|
if not data:
|
|
476
480
|
break
|
|
477
481
|
os.write(1, data)
|
|
482
|
+
if not trust_sent:
|
|
483
|
+
buf += data
|
|
484
|
+
if b"Yes" in buf and b"trust" in buf:
|
|
485
|
+
os.write(fd, b"\\r")
|
|
486
|
+
trust_sent = True
|
|
487
|
+
buf = b""
|
|
478
488
|
except OSError:
|
|
479
489
|
break
|
|
480
490
|
if 0 in r:
|
|
@@ -939,6 +949,7 @@ var ClaudeCodeController = class extends import_node_events.EventEmitter {
|
|
|
939
949
|
subscriptions: []
|
|
940
950
|
};
|
|
941
951
|
await this.team.addMember(member);
|
|
952
|
+
this.ensureWorkspaceTrusted(cwd);
|
|
942
953
|
const env = Object.keys(this.defaultEnv).length > 0 || opts.env ? { ...this.defaultEnv, ...opts.env } : void 0;
|
|
943
954
|
const proc = this.processes.spawn({
|
|
944
955
|
teamName: this.teamName,
|
|
@@ -1206,6 +1217,19 @@ var ClaudeCodeController = class extends import_node_events.EventEmitter {
|
|
|
1206
1217
|
}
|
|
1207
1218
|
}
|
|
1208
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Ensure the agent's cwd has a .claude/settings.local.json so the
|
|
1222
|
+
* CLI skips the interactive workspace trust prompt.
|
|
1223
|
+
*/
|
|
1224
|
+
ensureWorkspaceTrusted(cwd) {
|
|
1225
|
+
const claudeDir = (0, import_node_path3.join)(cwd, ".claude");
|
|
1226
|
+
const settingsPath = (0, import_node_path3.join)(claudeDir, "settings.local.json");
|
|
1227
|
+
if (!(0, import_node_fs4.existsSync)(settingsPath)) {
|
|
1228
|
+
(0, import_node_fs4.mkdirSync)(claudeDir, { recursive: true });
|
|
1229
|
+
(0, import_node_fs4.writeFileSync)(settingsPath, "{}\n");
|
|
1230
|
+
this.log.debug(`Created ${settingsPath} for workspace trust`);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1209
1233
|
ensureInitialized() {
|
|
1210
1234
|
if (!this.initialized) {
|
|
1211
1235
|
throw new Error(
|
|
@@ -1385,14 +1409,22 @@ var Agent = class _Agent extends import_node_events2.EventEmitter {
|
|
|
1385
1409
|
this.ensureNotDisposed();
|
|
1386
1410
|
const timeout = opts?.timeout ?? 12e4;
|
|
1387
1411
|
const responsePromise = new Promise((resolve, reject) => {
|
|
1412
|
+
let gotMessage = false;
|
|
1388
1413
|
const timer = setTimeout(() => {
|
|
1389
1414
|
cleanup();
|
|
1390
1415
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1391
1416
|
}, timeout);
|
|
1392
1417
|
const onMsg = (text) => {
|
|
1418
|
+
gotMessage = true;
|
|
1393
1419
|
cleanup();
|
|
1394
1420
|
resolve(text);
|
|
1395
1421
|
};
|
|
1422
|
+
const onIdle = () => {
|
|
1423
|
+
if (!gotMessage) {
|
|
1424
|
+
cleanup();
|
|
1425
|
+
resolve("");
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1396
1428
|
const onExit = (code) => {
|
|
1397
1429
|
cleanup();
|
|
1398
1430
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1400,9 +1432,11 @@ var Agent = class _Agent extends import_node_events2.EventEmitter {
|
|
|
1400
1432
|
const cleanup = () => {
|
|
1401
1433
|
clearTimeout(timer);
|
|
1402
1434
|
this.removeListener("message", onMsg);
|
|
1435
|
+
this.removeListener("idle", onIdle);
|
|
1403
1436
|
this.removeListener("exit", onExit);
|
|
1404
1437
|
};
|
|
1405
1438
|
this.on("message", onMsg);
|
|
1439
|
+
this.on("idle", onIdle);
|
|
1406
1440
|
this.on("exit", onExit);
|
|
1407
1441
|
});
|
|
1408
1442
|
const wrapped = `${question}
|
|
@@ -1421,14 +1455,22 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1421
1455
|
this.ensureNotDisposed();
|
|
1422
1456
|
const timeout = opts?.timeout ?? 12e4;
|
|
1423
1457
|
return new Promise((resolve, reject) => {
|
|
1458
|
+
let gotMessage = false;
|
|
1424
1459
|
const timer = setTimeout(() => {
|
|
1425
1460
|
cleanup();
|
|
1426
1461
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1427
1462
|
}, timeout);
|
|
1428
1463
|
const onMsg = (text) => {
|
|
1464
|
+
gotMessage = true;
|
|
1429
1465
|
cleanup();
|
|
1430
1466
|
resolve(text);
|
|
1431
1467
|
};
|
|
1468
|
+
const onIdle = () => {
|
|
1469
|
+
if (!gotMessage) {
|
|
1470
|
+
cleanup();
|
|
1471
|
+
resolve("");
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1432
1474
|
const onExit = (code) => {
|
|
1433
1475
|
cleanup();
|
|
1434
1476
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1436,9 +1478,11 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1436
1478
|
const cleanup = () => {
|
|
1437
1479
|
clearTimeout(timer);
|
|
1438
1480
|
this.removeListener("message", onMsg);
|
|
1481
|
+
this.removeListener("idle", onIdle);
|
|
1439
1482
|
this.removeListener("exit", onExit);
|
|
1440
1483
|
};
|
|
1441
1484
|
this.on("message", onMsg);
|
|
1485
|
+
this.on("idle", onIdle);
|
|
1442
1486
|
this.on("exit", onExit);
|
|
1443
1487
|
});
|
|
1444
1488
|
}
|