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
|
@@ -424,6 +424,11 @@ declare class ClaudeCodeController extends EventEmitter<ControllerEvents> implem
|
|
|
424
424
|
version: string | null;
|
|
425
425
|
};
|
|
426
426
|
private handlePollEvents;
|
|
427
|
+
/**
|
|
428
|
+
* Ensure the agent's cwd has a .claude/settings.local.json so the
|
|
429
|
+
* CLI skips the interactive workspace trust prompt.
|
|
430
|
+
*/
|
|
431
|
+
private ensureWorkspaceTrusted;
|
|
427
432
|
private ensureInitialized;
|
|
428
433
|
}
|
|
429
434
|
|
|
@@ -424,6 +424,11 @@ declare class ClaudeCodeController extends EventEmitter<ControllerEvents> implem
|
|
|
424
424
|
version: string | null;
|
|
425
425
|
};
|
|
426
426
|
private handlePollEvents;
|
|
427
|
+
/**
|
|
428
|
+
* Ensure the agent's cwd has a .claude/settings.local.json so the
|
|
429
|
+
* CLI skips the interactive workspace trust prompt.
|
|
430
|
+
*/
|
|
431
|
+
private ensureWorkspaceTrusted;
|
|
427
432
|
private ensureInitialized;
|
|
428
433
|
}
|
|
429
434
|
|
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,8 @@ var import_node_crypto3 = require("crypto");
|
|
|
54
54
|
var import_node_events = require("events");
|
|
55
55
|
var import_node_child_process3 = require("child_process");
|
|
56
56
|
var import_node_crypto2 = require("crypto");
|
|
57
|
+
var import_node_fs4 = require("fs");
|
|
58
|
+
var import_node_path3 = require("path");
|
|
57
59
|
|
|
58
60
|
// src/team-manager.ts
|
|
59
61
|
var import_promises = require("fs/promises");
|
|
@@ -386,6 +388,8 @@ if pid == 0:
|
|
|
386
388
|
else:
|
|
387
389
|
signal.signal(signal.SIGTERM, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
388
390
|
signal.signal(signal.SIGINT, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
391
|
+
buf = b""
|
|
392
|
+
trust_sent = False
|
|
389
393
|
try:
|
|
390
394
|
while True:
|
|
391
395
|
r, _, _ = select.select([fd, 0], [], [], 1.0)
|
|
@@ -395,6 +399,12 @@ else:
|
|
|
395
399
|
if not data:
|
|
396
400
|
break
|
|
397
401
|
os.write(1, data)
|
|
402
|
+
if not trust_sent:
|
|
403
|
+
buf += data
|
|
404
|
+
if b"Yes" in buf and b"trust" in buf:
|
|
405
|
+
os.write(fd, b"\\r")
|
|
406
|
+
trust_sent = True
|
|
407
|
+
buf = b""
|
|
398
408
|
except OSError:
|
|
399
409
|
break
|
|
400
410
|
if 0 in r:
|
|
@@ -875,6 +885,7 @@ var ClaudeCodeController = class extends import_node_events.EventEmitter {
|
|
|
875
885
|
subscriptions: []
|
|
876
886
|
};
|
|
877
887
|
await this.team.addMember(member);
|
|
888
|
+
this.ensureWorkspaceTrusted(cwd);
|
|
878
889
|
const env = Object.keys(this.defaultEnv).length > 0 || opts.env ? { ...this.defaultEnv, ...opts.env } : void 0;
|
|
879
890
|
const proc = this.processes.spawn({
|
|
880
891
|
teamName: this.teamName,
|
|
@@ -1142,6 +1153,19 @@ var ClaudeCodeController = class extends import_node_events.EventEmitter {
|
|
|
1142
1153
|
}
|
|
1143
1154
|
}
|
|
1144
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Ensure the agent's cwd has a .claude/settings.local.json so the
|
|
1158
|
+
* CLI skips the interactive workspace trust prompt.
|
|
1159
|
+
*/
|
|
1160
|
+
ensureWorkspaceTrusted(cwd) {
|
|
1161
|
+
const claudeDir = (0, import_node_path3.join)(cwd, ".claude");
|
|
1162
|
+
const settingsPath = (0, import_node_path3.join)(claudeDir, "settings.local.json");
|
|
1163
|
+
if (!(0, import_node_fs4.existsSync)(settingsPath)) {
|
|
1164
|
+
(0, import_node_fs4.mkdirSync)(claudeDir, { recursive: true });
|
|
1165
|
+
(0, import_node_fs4.writeFileSync)(settingsPath, "{}\n");
|
|
1166
|
+
this.log.debug(`Created ${settingsPath} for workspace trust`);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1145
1169
|
ensureInitialized() {
|
|
1146
1170
|
if (!this.initialized) {
|
|
1147
1171
|
throw new Error(
|
|
@@ -1319,14 +1343,22 @@ var Agent = class _Agent extends import_node_events2.EventEmitter {
|
|
|
1319
1343
|
this.ensureNotDisposed();
|
|
1320
1344
|
const timeout = opts?.timeout ?? 12e4;
|
|
1321
1345
|
const responsePromise = new Promise((resolve, reject) => {
|
|
1346
|
+
let gotMessage = false;
|
|
1322
1347
|
const timer = setTimeout(() => {
|
|
1323
1348
|
cleanup();
|
|
1324
1349
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1325
1350
|
}, timeout);
|
|
1326
1351
|
const onMsg = (text) => {
|
|
1352
|
+
gotMessage = true;
|
|
1327
1353
|
cleanup();
|
|
1328
1354
|
resolve(text);
|
|
1329
1355
|
};
|
|
1356
|
+
const onIdle = () => {
|
|
1357
|
+
if (!gotMessage) {
|
|
1358
|
+
cleanup();
|
|
1359
|
+
resolve("");
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1330
1362
|
const onExit = (code) => {
|
|
1331
1363
|
cleanup();
|
|
1332
1364
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1334,9 +1366,11 @@ var Agent = class _Agent extends import_node_events2.EventEmitter {
|
|
|
1334
1366
|
const cleanup = () => {
|
|
1335
1367
|
clearTimeout(timer);
|
|
1336
1368
|
this.removeListener("message", onMsg);
|
|
1369
|
+
this.removeListener("idle", onIdle);
|
|
1337
1370
|
this.removeListener("exit", onExit);
|
|
1338
1371
|
};
|
|
1339
1372
|
this.on("message", onMsg);
|
|
1373
|
+
this.on("idle", onIdle);
|
|
1340
1374
|
this.on("exit", onExit);
|
|
1341
1375
|
});
|
|
1342
1376
|
const wrapped = `${question}
|
|
@@ -1355,14 +1389,22 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1355
1389
|
this.ensureNotDisposed();
|
|
1356
1390
|
const timeout = opts?.timeout ?? 12e4;
|
|
1357
1391
|
return new Promise((resolve, reject) => {
|
|
1392
|
+
let gotMessage = false;
|
|
1358
1393
|
const timer = setTimeout(() => {
|
|
1359
1394
|
cleanup();
|
|
1360
1395
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1361
1396
|
}, timeout);
|
|
1362
1397
|
const onMsg = (text) => {
|
|
1398
|
+
gotMessage = true;
|
|
1363
1399
|
cleanup();
|
|
1364
1400
|
resolve(text);
|
|
1365
1401
|
};
|
|
1402
|
+
const onIdle = () => {
|
|
1403
|
+
if (!gotMessage) {
|
|
1404
|
+
cleanup();
|
|
1405
|
+
resolve("");
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1366
1408
|
const onExit = (code) => {
|
|
1367
1409
|
cleanup();
|
|
1368
1410
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1370,9 +1412,11 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1370
1412
|
const cleanup = () => {
|
|
1371
1413
|
clearTimeout(timer);
|
|
1372
1414
|
this.removeListener("message", onMsg);
|
|
1415
|
+
this.removeListener("idle", onIdle);
|
|
1373
1416
|
this.removeListener("exit", onExit);
|
|
1374
1417
|
};
|
|
1375
1418
|
this.on("message", onMsg);
|
|
1419
|
+
this.on("idle", onIdle);
|
|
1376
1420
|
this.on("exit", onExit);
|
|
1377
1421
|
});
|
|
1378
1422
|
}
|