switchroom 0.12.4 → 0.12.6
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/package.json +1 -1
- package/telegram-plugin/gateway/gateway.ts +50 -10
- package/telegram-plugin/gateway/hostd-dispatch.ts +38 -0
- package/telegram-plugin/gateway/update-status-line.ts +61 -0
- package/telegram-plugin/tests/update-status-line.test.ts +70 -0
- package/dist/agent-scheduler/index.js +0 -12657
- package/dist/auth-broker/index.js +0 -14133
- package/dist/cli/autoaccept-poll.js +0 -128
- package/dist/cli/drive-write-pretool.mjs +0 -5451
- package/dist/cli/skill-validate-pretool.mjs +0 -7209
- package/dist/cli/switchroom.js +0 -76015
- package/dist/cli/ui/index.html +0 -1281
- package/dist/host-control/main.js +0 -16041
- package/dist/vault/approvals/kernel-server.js +0 -13121
- package/dist/vault/broker/server.js +0 -17177
- package/telegram-plugin/dist/bridge/bridge.js +0 -24996
- package/telegram-plugin/dist/gateway/gateway.js +0 -55480
- package/telegram-plugin/dist/server.js +0 -24786
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
// @bun
|
|
3
|
-
|
|
4
|
-
// src/agents/autoaccept.ts
|
|
5
|
-
import { execFileSync } from "node:child_process";
|
|
6
|
-
var PROMPTS = [
|
|
7
|
-
{
|
|
8
|
-
name: "dev-channels-loading",
|
|
9
|
-
match: /Loading.{1,30}development.{1,30}channels/,
|
|
10
|
-
keys: ["Enter"]
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: "dev-channels-local",
|
|
14
|
-
match: /using this for local development/,
|
|
15
|
-
keys: ["Enter"]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "dev-channels",
|
|
19
|
-
match: /I.{0,5}accept.{0,80}development.{0,10}channels/,
|
|
20
|
-
keys: ["Down", "Enter"]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: "mcp-trust",
|
|
24
|
-
match: /Use this and all future MCP servers/,
|
|
25
|
-
keys: ["Enter"]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "theme",
|
|
29
|
-
match: /Choose.{1,30}text.{1,30}style/,
|
|
30
|
-
keys: ["Enter"]
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "provider",
|
|
34
|
-
match: /Anthropic.{1,80}Bedrock/,
|
|
35
|
-
keys: ["Enter"]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "enter-to-confirm",
|
|
39
|
-
match: /Enter.{1,30}confirm/,
|
|
40
|
-
keys: ["Enter"]
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
|
-
var DEFAULT_IDLE_MS = 30000;
|
|
44
|
-
var DEFAULT_POLL_MS = 250;
|
|
45
|
-
function defaultSleep(ms) {
|
|
46
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
47
|
-
}
|
|
48
|
-
function capturePane(agentName) {
|
|
49
|
-
const socket = `switchroom-${agentName}`;
|
|
50
|
-
try {
|
|
51
|
-
const out = execFileSync("tmux", ["-L", socket, "capture-pane", "-p", "-t", agentName], {
|
|
52
|
-
timeout: 3000,
|
|
53
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
54
|
-
maxBuffer: 4 * 1024 * 1024
|
|
55
|
-
});
|
|
56
|
-
return out.toString("utf8");
|
|
57
|
-
} catch (err) {
|
|
58
|
-
console.error(`[autoaccept] ${agentName}: capture-pane failed: ${err.message}`);
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function sendKeys(agentName, keys) {
|
|
63
|
-
const socket = `switchroom-${agentName}`;
|
|
64
|
-
try {
|
|
65
|
-
execFileSync("tmux", ["-L", socket, "send-keys", "-t", agentName, ...keys], { timeout: 3000, stdio: ["ignore", "pipe", "pipe"] });
|
|
66
|
-
return true;
|
|
67
|
-
} catch (err) {
|
|
68
|
-
console.error(`[autoaccept] ${agentName}: send-keys ${keys.join(" ")} failed: ${err.message}`);
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function runAutoaccept(opts) {
|
|
73
|
-
const idleTimeoutMs = opts.idleTimeoutMs ?? DEFAULT_IDLE_MS;
|
|
74
|
-
const pollIntervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_MS;
|
|
75
|
-
const rules = (opts.prompts ?? PROMPTS).map((r) => ({
|
|
76
|
-
rule: r,
|
|
77
|
-
fired: 0,
|
|
78
|
-
cap: r.maxFires ?? 1
|
|
79
|
-
}));
|
|
80
|
-
const fired = [];
|
|
81
|
-
const now = opts.now ?? Date.now;
|
|
82
|
-
const sleep = opts.sleep ?? defaultSleep;
|
|
83
|
-
const maxPolls = opts.maxPolls ?? Number.POSITIVE_INFINITY;
|
|
84
|
-
let lastFire = now();
|
|
85
|
-
let polls = 0;
|
|
86
|
-
while (polls < maxPolls) {
|
|
87
|
-
polls++;
|
|
88
|
-
const text = capturePane(opts.agentName);
|
|
89
|
-
let matchedThisPoll = false;
|
|
90
|
-
if (text) {
|
|
91
|
-
for (const entry of rules) {
|
|
92
|
-
if (entry.fired >= entry.cap)
|
|
93
|
-
continue;
|
|
94
|
-
if (entry.rule.match.test(text)) {
|
|
95
|
-
entry.fired++;
|
|
96
|
-
matchedThisPoll = true;
|
|
97
|
-
fired.push(entry.rule.name);
|
|
98
|
-
console.error(`[autoaccept] ${opts.agentName}: fired ${entry.rule.name} (${entry.rule.keys.join("+")})`);
|
|
99
|
-
sendKeys(opts.agentName, entry.rule.keys);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (matchedThisPoll) {
|
|
104
|
-
lastFire = now();
|
|
105
|
-
} else if (now() - lastFire >= idleTimeoutMs) {
|
|
106
|
-
return { fired, reason: "idle-timeout" };
|
|
107
|
-
}
|
|
108
|
-
await sleep(pollIntervalMs);
|
|
109
|
-
}
|
|
110
|
-
return { fired, reason: "manual-stop" };
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/cli/autoaccept-poll.ts
|
|
114
|
-
async function main() {
|
|
115
|
-
const agentName = process.argv[2];
|
|
116
|
-
if (!agentName) {
|
|
117
|
-
console.error("[autoaccept-poll] missing agent name argv");
|
|
118
|
-
process.exit(0);
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
const res = await runAutoaccept({ agentName });
|
|
122
|
-
console.error(`[autoaccept-poll] ${agentName}: done reason=${res.reason} fired=${res.fired.length ? res.fired.join(",") : "(none)"}`);
|
|
123
|
-
} catch (err) {
|
|
124
|
-
console.error(`[autoaccept-poll] ${agentName}: unexpected throw: ${err.message}`);
|
|
125
|
-
}
|
|
126
|
-
process.exit(0);
|
|
127
|
-
}
|
|
128
|
-
main();
|