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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { C as ClaudeCodeController, j as PermissionPreset, E as TaskStatus, a as LogLevel, d as AgentType } from '../claude-
|
|
2
|
+
import { C as ClaudeCodeController, j as PermissionPreset, E as TaskStatus, a as LogLevel, d as AgentType } from '../claude-0cg912ch.cjs';
|
|
3
3
|
import 'node:events';
|
|
4
4
|
|
|
5
5
|
interface PendingApproval {
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { C as ClaudeCodeController, j as PermissionPreset, E as TaskStatus, a as LogLevel, d as AgentType } from '../claude-
|
|
2
|
+
import { C as ClaudeCodeController, j as PermissionPreset, E as TaskStatus, a as LogLevel, d as AgentType } from '../claude-0cg912ch.js';
|
|
3
3
|
import 'node:events';
|
|
4
4
|
|
|
5
5
|
interface PendingApproval {
|
package/dist/api/index.js
CHANGED
|
@@ -109,6 +109,8 @@ import { Hono } from "hono";
|
|
|
109
109
|
import { EventEmitter } from "events";
|
|
110
110
|
import { execSync as execSync2 } from "child_process";
|
|
111
111
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
112
|
+
import { mkdirSync, existsSync as existsSync4, writeFileSync } from "fs";
|
|
113
|
+
import { join as join2 } from "path";
|
|
112
114
|
|
|
113
115
|
// src/team-manager.ts
|
|
114
116
|
import { readFile, writeFile, mkdir, rm } from "fs/promises";
|
|
@@ -441,6 +443,8 @@ if pid == 0:
|
|
|
441
443
|
else:
|
|
442
444
|
signal.signal(signal.SIGTERM, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
443
445
|
signal.signal(signal.SIGINT, lambda *a: (os.kill(pid, signal.SIGTERM), sys.exit(0)))
|
|
446
|
+
buf = b""
|
|
447
|
+
trust_sent = False
|
|
444
448
|
try:
|
|
445
449
|
while True:
|
|
446
450
|
r, _, _ = select.select([fd, 0], [], [], 1.0)
|
|
@@ -450,6 +454,12 @@ else:
|
|
|
450
454
|
if not data:
|
|
451
455
|
break
|
|
452
456
|
os.write(1, data)
|
|
457
|
+
if not trust_sent:
|
|
458
|
+
buf += data
|
|
459
|
+
if b"Yes" in buf and b"trust" in buf:
|
|
460
|
+
os.write(fd, b"\\r")
|
|
461
|
+
trust_sent = True
|
|
462
|
+
buf = b""
|
|
453
463
|
except OSError:
|
|
454
464
|
break
|
|
455
465
|
if 0 in r:
|
|
@@ -914,6 +924,7 @@ var ClaudeCodeController = class extends EventEmitter {
|
|
|
914
924
|
subscriptions: []
|
|
915
925
|
};
|
|
916
926
|
await this.team.addMember(member);
|
|
927
|
+
this.ensureWorkspaceTrusted(cwd);
|
|
917
928
|
const env = Object.keys(this.defaultEnv).length > 0 || opts.env ? { ...this.defaultEnv, ...opts.env } : void 0;
|
|
918
929
|
const proc = this.processes.spawn({
|
|
919
930
|
teamName: this.teamName,
|
|
@@ -1181,6 +1192,19 @@ var ClaudeCodeController = class extends EventEmitter {
|
|
|
1181
1192
|
}
|
|
1182
1193
|
}
|
|
1183
1194
|
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Ensure the agent's cwd has a .claude/settings.local.json so the
|
|
1197
|
+
* CLI skips the interactive workspace trust prompt.
|
|
1198
|
+
*/
|
|
1199
|
+
ensureWorkspaceTrusted(cwd) {
|
|
1200
|
+
const claudeDir = join2(cwd, ".claude");
|
|
1201
|
+
const settingsPath = join2(claudeDir, "settings.local.json");
|
|
1202
|
+
if (!existsSync4(settingsPath)) {
|
|
1203
|
+
mkdirSync(claudeDir, { recursive: true });
|
|
1204
|
+
writeFileSync(settingsPath, "{}\n");
|
|
1205
|
+
this.log.debug(`Created ${settingsPath} for workspace trust`);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1184
1208
|
ensureInitialized() {
|
|
1185
1209
|
if (!this.initialized) {
|
|
1186
1210
|
throw new Error(
|
|
@@ -1360,14 +1384,22 @@ var Agent = class _Agent extends EventEmitter2 {
|
|
|
1360
1384
|
this.ensureNotDisposed();
|
|
1361
1385
|
const timeout = opts?.timeout ?? 12e4;
|
|
1362
1386
|
const responsePromise = new Promise((resolve, reject) => {
|
|
1387
|
+
let gotMessage = false;
|
|
1363
1388
|
const timer = setTimeout(() => {
|
|
1364
1389
|
cleanup();
|
|
1365
1390
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1366
1391
|
}, timeout);
|
|
1367
1392
|
const onMsg = (text) => {
|
|
1393
|
+
gotMessage = true;
|
|
1368
1394
|
cleanup();
|
|
1369
1395
|
resolve(text);
|
|
1370
1396
|
};
|
|
1397
|
+
const onIdle = () => {
|
|
1398
|
+
if (!gotMessage) {
|
|
1399
|
+
cleanup();
|
|
1400
|
+
resolve("");
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1371
1403
|
const onExit = (code) => {
|
|
1372
1404
|
cleanup();
|
|
1373
1405
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1375,9 +1407,11 @@ var Agent = class _Agent extends EventEmitter2 {
|
|
|
1375
1407
|
const cleanup = () => {
|
|
1376
1408
|
clearTimeout(timer);
|
|
1377
1409
|
this.removeListener("message", onMsg);
|
|
1410
|
+
this.removeListener("idle", onIdle);
|
|
1378
1411
|
this.removeListener("exit", onExit);
|
|
1379
1412
|
};
|
|
1380
1413
|
this.on("message", onMsg);
|
|
1414
|
+
this.on("idle", onIdle);
|
|
1381
1415
|
this.on("exit", onExit);
|
|
1382
1416
|
});
|
|
1383
1417
|
const wrapped = `${question}
|
|
@@ -1396,14 +1430,22 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1396
1430
|
this.ensureNotDisposed();
|
|
1397
1431
|
const timeout = opts?.timeout ?? 12e4;
|
|
1398
1432
|
return new Promise((resolve, reject) => {
|
|
1433
|
+
let gotMessage = false;
|
|
1399
1434
|
const timer = setTimeout(() => {
|
|
1400
1435
|
cleanup();
|
|
1401
1436
|
reject(new Error(`Timeout (${timeout}ms) waiting for response`));
|
|
1402
1437
|
}, timeout);
|
|
1403
1438
|
const onMsg = (text) => {
|
|
1439
|
+
gotMessage = true;
|
|
1404
1440
|
cleanup();
|
|
1405
1441
|
resolve(text);
|
|
1406
1442
|
};
|
|
1443
|
+
const onIdle = () => {
|
|
1444
|
+
if (!gotMessage) {
|
|
1445
|
+
cleanup();
|
|
1446
|
+
resolve("");
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1407
1449
|
const onExit = (code) => {
|
|
1408
1450
|
cleanup();
|
|
1409
1451
|
reject(new Error(`Agent exited (code=${code}) before responding`));
|
|
@@ -1411,9 +1453,11 @@ IMPORTANT: You MUST send your complete answer back using the SendMessage tool. D
|
|
|
1411
1453
|
const cleanup = () => {
|
|
1412
1454
|
clearTimeout(timer);
|
|
1413
1455
|
this.removeListener("message", onMsg);
|
|
1456
|
+
this.removeListener("idle", onIdle);
|
|
1414
1457
|
this.removeListener("exit", onExit);
|
|
1415
1458
|
};
|
|
1416
1459
|
this.on("message", onMsg);
|
|
1460
|
+
this.on("idle", onIdle);
|
|
1417
1461
|
this.on("exit", onExit);
|
|
1418
1462
|
});
|
|
1419
1463
|
}
|