@gonzih/cc-discord 0.2.41 → 0.2.42
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/meta-agent-manager.js +10 -9
- package/package.json +1 -1
|
@@ -343,15 +343,15 @@ function spawnPersistentSession(ns, token, wire, onExit, onOutput) {
|
|
|
343
343
|
const claudeBin = resolveClaude();
|
|
344
344
|
const env = buildEnv(token);
|
|
345
345
|
console.log(`[meta-agent-manager] spawning persistent session (ns=${ns})`);
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
// --output-format stream-json ...` responds correctly; the -p variant does not.
|
|
346
|
+
// --input-format stream-json: Claude reads newline-delimited JSON messages from stdin.
|
|
347
|
+
// Each message must be: {"type":"user","message":{"role":"user","content":"..."}}
|
|
348
|
+
// Claude responds immediately to each message and stays alive waiting for the next one.
|
|
349
|
+
// DO NOT omit --input-format stream-json: without it, Claude ignores stdin when the
|
|
350
|
+
// pipe stays open (no TTY), producing no output until stdin is closed (EOF).
|
|
352
351
|
const proc = spawn(claudeBin, [
|
|
353
352
|
"--continue",
|
|
354
353
|
"--output-format", "stream-json",
|
|
354
|
+
"--input-format", "stream-json",
|
|
355
355
|
"--verbose",
|
|
356
356
|
"--dangerously-skip-permissions",
|
|
357
357
|
], { cwd: wsPath, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
@@ -402,13 +402,14 @@ export function createMetaAgentManager() {
|
|
|
402
402
|
* Resets the inactivity timer so the watchdog doesn't kill a session
|
|
403
403
|
* that just received a message but hasn't responded yet.
|
|
404
404
|
*/
|
|
405
|
-
function writeToStdin(ns,
|
|
405
|
+
function writeToStdin(ns, content) {
|
|
406
406
|
const session = sessions.get(ns);
|
|
407
407
|
if (!session)
|
|
408
408
|
return;
|
|
409
409
|
try {
|
|
410
|
-
//
|
|
411
|
-
|
|
410
|
+
// --input-format stream-json: each message must be a newline-delimited JSON object.
|
|
411
|
+
const jsonMsg = JSON.stringify({ type: "user", message: { role: "user", content } });
|
|
412
|
+
session.proc.stdin.write(`${jsonMsg}\n`);
|
|
412
413
|
// Reset inactivity timer — the session now has SESSION_INACTIVITY_MS to respond
|
|
413
414
|
session.lastOutputAt = Date.now();
|
|
414
415
|
}
|