agent-rooms 0.1.4 → 0.1.5
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/spawn.js +63 -7
- package/dist/spawn.js.map +1 -1
- package/package.json +1 -1
package/dist/spawn.js
CHANGED
|
@@ -1,15 +1,51 @@
|
|
|
1
|
-
// Spawn a host's headless command for a wake,
|
|
2
|
-
// extract the session id (for resume), and bound it with a timeout.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// Spawn a host's headless command for a wake, watch its streamed output to
|
|
2
|
+
// extract the session id (for resume), and bound it with a timeout. The agent's
|
|
3
|
+
// raw stream-json is NOT echoed to the terminal — we parse it and print a few
|
|
4
|
+
// clean progress lines instead (set AGENT_ROOMS_DEBUG=1 to see the raw stream).
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { log } from "./log.js";
|
|
7
|
+
const DEBUG = process.env.AGENT_ROOMS_DEBUG === "1";
|
|
8
|
+
// The room actions worth surfacing to the operator; everything else (thinking,
|
|
9
|
+
// workspace Read/Grep/Glob, tool results) is internal noise and stays hidden.
|
|
10
|
+
const TOOL_LABEL = {
|
|
11
|
+
"mcp__agent-rooms__check_mentions": "reading its mentions",
|
|
12
|
+
"mcp__agent-rooms__read_room": "reading the room",
|
|
13
|
+
"mcp__agent-rooms__send_message": "posting a reply",
|
|
14
|
+
"mcp__agent-rooms__ack_mentions": "clearing the mention"
|
|
15
|
+
};
|
|
16
|
+
/** Turn one stream-json line into a clean progress line (or nothing). */
|
|
17
|
+
function summarise(rawLine) {
|
|
18
|
+
let event;
|
|
19
|
+
try {
|
|
20
|
+
event = JSON.parse(rawLine);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (event.type === "rate_limit_event") {
|
|
26
|
+
const info = event.rate_limit_info;
|
|
27
|
+
if (info && (info.status !== "allowed" || info.overageStatus === "rejected")) {
|
|
28
|
+
log.warn(`Claude usage limit: ${info.rateLimitType ?? "?"} ${info.status ?? "?"}${info.overageDisabledReason ? ` (${info.overageDisabledReason})` : ""}`);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (event.type === "assistant" && Array.isArray(event.message?.content)) {
|
|
33
|
+
for (const block of event.message.content) {
|
|
34
|
+
if (block.type === "tool_use" && block.name && TOOL_LABEL[block.name]) {
|
|
35
|
+
log.info(` · ${TOOL_LABEL[block.name]}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
7
40
|
export function runWake(adapter, spec, timeoutMs = 10 * 60 * 1000) {
|
|
8
41
|
const { command, args, cwd, stdin } = adapter.buildWake(spec);
|
|
9
42
|
log.info(`spawn ${adapter.name}: ${command} ${args.filter((a) => !a.includes("\n")).slice(0, 6).join(" ")}… (cwd ${cwd})`);
|
|
43
|
+
const startedAt = Date.now();
|
|
10
44
|
return new Promise((resolve) => {
|
|
11
45
|
let buffer = "";
|
|
46
|
+
let pending = "";
|
|
12
47
|
let settled = false;
|
|
48
|
+
const secs = () => Math.round((Date.now() - startedAt) / 1000);
|
|
13
49
|
// When the prompt rides stdin, open stdin as a pipe; otherwise ignore it.
|
|
14
50
|
const child = spawn(command, args, { cwd, stdio: [stdin != null ? "pipe" : "ignore", "pipe", "pipe"], shell: process.platform === "win32" });
|
|
15
51
|
if (stdin != null && child.stdin) {
|
|
@@ -29,9 +65,24 @@ export function runWake(adapter, spec, timeoutMs = 10 * 60 * 1000) {
|
|
|
29
65
|
buffer += text;
|
|
30
66
|
if (buffer.length > 2_000_000)
|
|
31
67
|
buffer = buffer.slice(-1_000_000);
|
|
32
|
-
|
|
68
|
+
if (DEBUG) {
|
|
69
|
+
process.stdout.write(text);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// Parse complete JSON lines for clean progress; keep the partial remainder.
|
|
73
|
+
pending += text;
|
|
74
|
+
let nl;
|
|
75
|
+
while ((nl = pending.indexOf("\n")) >= 0) {
|
|
76
|
+
const line = pending.slice(0, nl).trim();
|
|
77
|
+
pending = pending.slice(nl + 1);
|
|
78
|
+
if (line)
|
|
79
|
+
summarise(line);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
child.stderr?.on("data", (chunk) => {
|
|
83
|
+
if (DEBUG)
|
|
84
|
+
process.stderr.write(chunk);
|
|
33
85
|
});
|
|
34
|
-
child.stderr?.on("data", (chunk) => process.stderr.write(chunk));
|
|
35
86
|
child.on("error", (err) => {
|
|
36
87
|
if (settled)
|
|
37
88
|
return;
|
|
@@ -46,7 +97,12 @@ export function runWake(adapter, spec, timeoutMs = 10 * 60 * 1000) {
|
|
|
46
97
|
settled = true;
|
|
47
98
|
clearTimeout(timer);
|
|
48
99
|
const sessionId = adapter.parseSessionId(buffer);
|
|
49
|
-
|
|
100
|
+
const status = code === 0 ? "replied" : "error";
|
|
101
|
+
if (status === "replied")
|
|
102
|
+
log.info(`${adapter.name} done (${secs()}s)`);
|
|
103
|
+
else
|
|
104
|
+
log.warn(`${adapter.name} exited ${code} (${secs()}s)`);
|
|
105
|
+
resolve({ status, sessionId, code });
|
|
50
106
|
});
|
|
51
107
|
});
|
|
52
108
|
}
|
package/dist/spawn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,GAAG,CAAC;AAEpD,+EAA+E;AAC/E,8E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BACnE,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,WAAW,IAAI,KAAK,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7D,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-rooms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Companion listener for Agent Rooms — wakes your idle local agents (Claude Code, Codex) when they're mentioned in a room. Optional upgrade over the pull-only remote MCP connector.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-rooms",
|