switchroom 0.5.0 → 0.7.8
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/README.md +142 -121
- package/bin/autoaccept.exp +29 -6
- package/dist/agent-scheduler/index.js +12261 -0
- package/dist/cli/autoaccept-poll.js +10 -0
- package/dist/cli/switchroom.js +27250 -25324
- package/dist/vault/approvals/kernel-server.js +12709 -0
- package/dist/vault/broker/server.js +15724 -0
- package/package.json +4 -3
- package/profiles/_base/start.sh.hbs +133 -0
- package/profiles/_shared/telegram-style.md.hbs +3 -3
- package/profiles/default/CLAUDE.md +3 -3
- package/profiles/default/CLAUDE.md.hbs +2 -2
- package/profiles/default/workspace/CLAUDE.md.hbs +9 -0
- package/skills/docx/VENDORED.md +1 -1
- package/skills/mcp-builder/VENDORED.md +1 -1
- package/skills/pdf/VENDORED.md +1 -1
- package/skills/pptx/VENDORED.md +1 -1
- package/skills/skill-creator/VENDORED.md +1 -1
- package/skills/switchroom-architecture/SKILL.md +8 -7
- package/skills/switchroom-cli/SKILL.md +23 -15
- package/skills/switchroom-health/SKILL.md +7 -7
- package/skills/switchroom-install/SKILL.md +36 -39
- package/skills/switchroom-manage/SKILL.md +4 -4
- package/skills/switchroom-status/SKILL.md +1 -1
- package/skills/webapp-testing/VENDORED.md +1 -1
- package/skills/xlsx/VENDORED.md +1 -1
- package/telegram-plugin/admin-commands/dispatch.test.ts +119 -1
- package/telegram-plugin/admin-commands/index.ts +71 -0
- package/telegram-plugin/ask-user.ts +1 -0
- package/telegram-plugin/card-event-log.ts +138 -0
- package/telegram-plugin/dist/bridge/bridge.js +178 -31
- package/telegram-plugin/dist/foreman/foreman.js +6875 -6526
- package/telegram-plugin/dist/gateway/gateway.js +13862 -11834
- package/telegram-plugin/dist/server.js +202 -40
- package/telegram-plugin/fleet-state.ts +25 -10
- package/telegram-plugin/foreman/foreman.ts +38 -3
- package/telegram-plugin/gateway/approval-callback.ts +126 -0
- package/telegram-plugin/gateway/approval-card.test.ts +90 -0
- package/telegram-plugin/gateway/approval-card.ts +127 -0
- package/telegram-plugin/gateway/approvals-commands.ts +126 -0
- package/telegram-plugin/gateway/boot-card.ts +31 -6
- package/telegram-plugin/gateway/boot-probes.ts +503 -72
- package/telegram-plugin/gateway/gateway.ts +822 -94
- package/telegram-plugin/gateway/ipc-protocol.ts +34 -1
- package/telegram-plugin/gateway/ipc-server.ts +35 -0
- package/telegram-plugin/gateway/startup-mutex.ts +110 -2
- package/telegram-plugin/hooks/hooks.json +19 -0
- package/telegram-plugin/hooks/tool-label-pretool.mjs +216 -0
- package/telegram-plugin/hooks/tool-label-stop.mjs +63 -0
- package/telegram-plugin/package.json +4 -1
- package/telegram-plugin/plugin-logger.ts +20 -1
- package/telegram-plugin/progress-card-driver.ts +202 -13
- package/telegram-plugin/progress-card.ts +2 -2
- package/telegram-plugin/quota-check.ts +1 -0
- package/telegram-plugin/registry/subagents-schema.ts +37 -0
- package/telegram-plugin/registry/subagents.test.ts +64 -0
- package/telegram-plugin/session-tail.ts +58 -5
- package/telegram-plugin/shared/bot-runtime.ts +48 -2
- package/telegram-plugin/subagent-watcher.ts +139 -7
- package/telegram-plugin/tests/_progress-card-harness.ts +4 -0
- package/telegram-plugin/tests/bg-agent-progress-card-757.test.ts +201 -0
- package/telegram-plugin/tests/boot-card-probe-target.test.ts +10 -34
- package/telegram-plugin/tests/boot-card-render.test.ts +6 -5
- package/telegram-plugin/tests/boot-probes.test.ts +558 -0
- package/telegram-plugin/tests/card-event-log.test.ts +145 -0
- package/telegram-plugin/tests/gateway-startup-mutex.test.ts +102 -0
- package/telegram-plugin/tests/ipc-server-validate-inject-inbound.test.ts +134 -0
- package/telegram-plugin/tests/progress-card-delay-842.test.ts +160 -0
- package/telegram-plugin/tests/quota-check.test.ts +37 -1
- package/telegram-plugin/tests/subagent-registry-bugs.test.ts +5 -0
- package/telegram-plugin/tests/subagent-watcher-stall-notification.test.ts +104 -1
- package/telegram-plugin/tests/subagent-watcher.test.ts +5 -0
- package/telegram-plugin/tests/tool-label-sidecar.test.ts +114 -0
- package/telegram-plugin/tests/two-zone-bg-done-when-all-terminal.test.ts +5 -3
- package/telegram-plugin/tests/two-zone-card-header-phases.test.ts +10 -0
- package/telegram-plugin/tests/two-zone-snapshot-extras.test.ts +58 -14
- package/telegram-plugin/tests/welcome-text.test.ts +57 -0
- package/telegram-plugin/tool-label-sidecar.ts +140 -0
- package/telegram-plugin/tool-labels.ts +55 -0
- package/telegram-plugin/two-zone-card.ts +27 -7
- package/telegram-plugin/uat/SETUP.md +160 -0
- package/telegram-plugin/uat/assertions.ts +140 -0
- package/telegram-plugin/uat/driver.ts +174 -0
- package/telegram-plugin/uat/harness.ts +161 -0
- package/telegram-plugin/uat/login.ts +134 -0
- package/telegram-plugin/uat/port-allocator.ts +71 -0
- package/telegram-plugin/uat/scenarios/smoke-clerk-reply.test.ts +61 -0
- package/telegram-plugin/welcome-text.ts +44 -2
- package/bin/bridge-watchdog.sh +0 -967
|
@@ -22890,15 +22890,16 @@ var ServerResultSchema2 = union([
|
|
|
22890
22890
|
CreateTaskResultSchema2
|
|
22891
22891
|
]);
|
|
22892
22892
|
// bridge/bridge.ts
|
|
22893
|
-
import { dirname as dirname2, join as
|
|
22893
|
+
import { dirname as dirname2, join as join4 } from "path";
|
|
22894
22894
|
import { homedir as homedir3 } from "os";
|
|
22895
22895
|
|
|
22896
22896
|
// plugin-logger.ts
|
|
22897
|
-
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
22897
|
+
import { appendFileSync, mkdirSync, renameSync, statSync, existsSync } from "fs";
|
|
22898
22898
|
import { homedir } from "os";
|
|
22899
22899
|
import { dirname, join } from "path";
|
|
22900
22900
|
var DEFAULT_LOG_PATH = join(homedir(), ".switchroom", "logs", "telegram-plugin.log");
|
|
22901
|
-
var ROTATE_AT_BYTES =
|
|
22901
|
+
var ROTATE_AT_BYTES = 50 * 1024 * 1024;
|
|
22902
|
+
var ROTATION_BACKUPS = 5;
|
|
22902
22903
|
var activeHandle = null;
|
|
22903
22904
|
function resolveLogPath(env = process.env) {
|
|
22904
22905
|
const override = env.SWITCHROOM_TELEGRAM_LOG_PATH;
|
|
@@ -22916,6 +22917,14 @@ function rotateIfNeeded(path) {
|
|
|
22916
22917
|
const st = statSync(path);
|
|
22917
22918
|
if (st.size < ROTATE_AT_BYTES)
|
|
22918
22919
|
return;
|
|
22920
|
+
for (let i = ROTATION_BACKUPS - 1;i >= 1; i--) {
|
|
22921
|
+
const src = `${path}.${i}`;
|
|
22922
|
+
const dst = `${path}.${i + 1}`;
|
|
22923
|
+
try {
|
|
22924
|
+
if (existsSync(src))
|
|
22925
|
+
renameSync(src, dst);
|
|
22926
|
+
} catch {}
|
|
22927
|
+
}
|
|
22919
22928
|
const backup = `${path}.1`;
|
|
22920
22929
|
renameSync(path, backup);
|
|
22921
22930
|
} catch {}
|
|
@@ -22951,15 +22960,15 @@ function installPluginLogger(env = process.env) {
|
|
|
22951
22960
|
// session-tail.ts
|
|
22952
22961
|
import {
|
|
22953
22962
|
closeSync,
|
|
22954
|
-
existsSync as
|
|
22963
|
+
existsSync as existsSync3,
|
|
22955
22964
|
openSync,
|
|
22956
22965
|
readdirSync,
|
|
22957
22966
|
readSync,
|
|
22958
|
-
statSync as
|
|
22967
|
+
statSync as statSync3,
|
|
22959
22968
|
watch
|
|
22960
22969
|
} from "fs";
|
|
22961
22970
|
import { homedir as homedir2 } from "os";
|
|
22962
|
-
import { basename, join as
|
|
22971
|
+
import { basename, join as join3 } from "path";
|
|
22963
22972
|
|
|
22964
22973
|
// progress-card.ts
|
|
22965
22974
|
function isMultiAgentEnabled(env = process.env) {
|
|
@@ -23032,15 +23041,105 @@ function getNestedObj(obj, key) {
|
|
|
23032
23041
|
var DEFAULT_OPERATOR_EVENT_COOLDOWN_MS = 5 * 60000;
|
|
23033
23042
|
var cooldownMap = new Map;
|
|
23034
23043
|
|
|
23044
|
+
// tool-label-sidecar.ts
|
|
23045
|
+
import { existsSync as existsSync2, readFileSync, statSync as statSync2 } from "node:fs";
|
|
23046
|
+
import { join as join2 } from "node:path";
|
|
23047
|
+
function createToolLabelSidecar(opts) {
|
|
23048
|
+
const path = join2(opts.stateDir, `tool-labels-${opts.sessionId}.jsonl`);
|
|
23049
|
+
const labels = new Map;
|
|
23050
|
+
const subscribers = new Set;
|
|
23051
|
+
let offset = 0;
|
|
23052
|
+
let stopped = false;
|
|
23053
|
+
const sched = opts.scheduler ?? {
|
|
23054
|
+
setInterval: (cb, ms) => setInterval(cb, ms),
|
|
23055
|
+
clearInterval: (h) => clearInterval(h)
|
|
23056
|
+
};
|
|
23057
|
+
function ingestSuffix(text) {
|
|
23058
|
+
if (!text)
|
|
23059
|
+
return;
|
|
23060
|
+
const lines = text.split(`
|
|
23061
|
+
`);
|
|
23062
|
+
for (const raw of lines) {
|
|
23063
|
+
const line = raw.trim();
|
|
23064
|
+
if (!line)
|
|
23065
|
+
continue;
|
|
23066
|
+
let row = null;
|
|
23067
|
+
try {
|
|
23068
|
+
row = JSON.parse(line);
|
|
23069
|
+
} catch {
|
|
23070
|
+
continue;
|
|
23071
|
+
}
|
|
23072
|
+
if (!row || typeof row.tool_use_id !== "string" || typeof row.label !== "string")
|
|
23073
|
+
continue;
|
|
23074
|
+
if (labels.has(row.tool_use_id))
|
|
23075
|
+
continue;
|
|
23076
|
+
labels.set(row.tool_use_id, row.label);
|
|
23077
|
+
for (const cb of subscribers) {
|
|
23078
|
+
try {
|
|
23079
|
+
cb(row.tool_use_id, row.label);
|
|
23080
|
+
} catch {}
|
|
23081
|
+
}
|
|
23082
|
+
}
|
|
23083
|
+
}
|
|
23084
|
+
function poll() {
|
|
23085
|
+
if (stopped)
|
|
23086
|
+
return;
|
|
23087
|
+
if (!existsSync2(path))
|
|
23088
|
+
return;
|
|
23089
|
+
let size = 0;
|
|
23090
|
+
try {
|
|
23091
|
+
size = statSync2(path).size;
|
|
23092
|
+
} catch {
|
|
23093
|
+
return;
|
|
23094
|
+
}
|
|
23095
|
+
if (size <= offset) {
|
|
23096
|
+
if (size < offset)
|
|
23097
|
+
offset = 0;
|
|
23098
|
+
else
|
|
23099
|
+
return;
|
|
23100
|
+
}
|
|
23101
|
+
let text = "";
|
|
23102
|
+
try {
|
|
23103
|
+
const buf = readFileSync(path);
|
|
23104
|
+
text = buf.subarray(offset).toString("utf8");
|
|
23105
|
+
offset = buf.length;
|
|
23106
|
+
} catch {
|
|
23107
|
+
return;
|
|
23108
|
+
}
|
|
23109
|
+
ingestSuffix(text);
|
|
23110
|
+
}
|
|
23111
|
+
poll();
|
|
23112
|
+
const handle = sched.setInterval(poll, opts.pollMs ?? 250);
|
|
23113
|
+
return {
|
|
23114
|
+
getLabel(toolUseId) {
|
|
23115
|
+
return labels.get(toolUseId);
|
|
23116
|
+
},
|
|
23117
|
+
onLabel(cb) {
|
|
23118
|
+
subscribers.add(cb);
|
|
23119
|
+
return () => subscribers.delete(cb);
|
|
23120
|
+
},
|
|
23121
|
+
poll,
|
|
23122
|
+
stop() {
|
|
23123
|
+
if (stopped)
|
|
23124
|
+
return;
|
|
23125
|
+
stopped = true;
|
|
23126
|
+
try {
|
|
23127
|
+
sched.clearInterval(handle);
|
|
23128
|
+
} catch {}
|
|
23129
|
+
subscribers.clear();
|
|
23130
|
+
}
|
|
23131
|
+
};
|
|
23132
|
+
}
|
|
23133
|
+
|
|
23035
23134
|
// session-tail.ts
|
|
23036
23135
|
function sanitizeCwdToProjectName(cwd) {
|
|
23037
23136
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
23038
23137
|
}
|
|
23039
|
-
function getProjectsDirForCwd(cwd = process.cwd(), claudeHome = process.env.CLAUDE_CONFIG_DIR ??
|
|
23040
|
-
return
|
|
23138
|
+
function getProjectsDirForCwd(cwd = process.cwd(), claudeHome = process.env.CLAUDE_CONFIG_DIR ?? join3(homedir2(), ".claude")) {
|
|
23139
|
+
return join3(claudeHome, "projects", sanitizeCwdToProjectName(cwd));
|
|
23041
23140
|
}
|
|
23042
23141
|
function findActiveSessionFile(projectsDir) {
|
|
23043
|
-
if (!
|
|
23142
|
+
if (!existsSync3(projectsDir))
|
|
23044
23143
|
return null;
|
|
23045
23144
|
let entries;
|
|
23046
23145
|
try {
|
|
@@ -23053,9 +23152,9 @@ function findActiveSessionFile(projectsDir) {
|
|
|
23053
23152
|
for (const e of entries) {
|
|
23054
23153
|
if (!e.endsWith(".jsonl"))
|
|
23055
23154
|
continue;
|
|
23056
|
-
const p =
|
|
23155
|
+
const p = join3(projectsDir, e);
|
|
23057
23156
|
try {
|
|
23058
|
-
const s =
|
|
23157
|
+
const s = statSync3(p);
|
|
23059
23158
|
if (s.mtimeMs > bestMtime) {
|
|
23060
23159
|
bestMtime = s.mtimeMs;
|
|
23061
23160
|
bestPath = p;
|
|
@@ -23282,13 +23381,53 @@ function extractDetailMessage(obj) {
|
|
|
23282
23381
|
}
|
|
23283
23382
|
function startSessionTail(config2) {
|
|
23284
23383
|
const cwd = config2.cwd ?? process.cwd();
|
|
23285
|
-
const claudeHome = config2.claudeHome ?? process.env.CLAUDE_CONFIG_DIR ??
|
|
23384
|
+
const claudeHome = config2.claudeHome ?? process.env.CLAUDE_CONFIG_DIR ?? join3(homedir2(), ".claude");
|
|
23286
23385
|
const projectsDir = getProjectsDirForCwd(cwd, claudeHome);
|
|
23287
23386
|
const rescanMs = config2.rescanIntervalMs ?? 500;
|
|
23288
23387
|
const log = config2.log;
|
|
23289
|
-
const
|
|
23388
|
+
const rawOnEvent = config2.onEvent;
|
|
23290
23389
|
const onOperatorEvent = config2.onOperatorEvent;
|
|
23291
23390
|
log?.(`session-tail: projectsDir=${projectsDir}`);
|
|
23391
|
+
const sidecars = new Map;
|
|
23392
|
+
const stateDirForSidecar = process.env.TELEGRAM_STATE_DIR ?? null;
|
|
23393
|
+
function sessionIdForFile(file) {
|
|
23394
|
+
if (!file)
|
|
23395
|
+
return null;
|
|
23396
|
+
const b = file.endsWith(".jsonl") ? basename(file, ".jsonl") : null;
|
|
23397
|
+
return b && b.length > 0 ? b : null;
|
|
23398
|
+
}
|
|
23399
|
+
function ensureSidecar(sessionId) {
|
|
23400
|
+
if (!stateDirForSidecar)
|
|
23401
|
+
return null;
|
|
23402
|
+
const existing = sidecars.get(sessionId);
|
|
23403
|
+
if (existing)
|
|
23404
|
+
return existing;
|
|
23405
|
+
try {
|
|
23406
|
+
const s = createToolLabelSidecar({ stateDir: stateDirForSidecar, sessionId });
|
|
23407
|
+
sidecars.set(sessionId, s);
|
|
23408
|
+
return s;
|
|
23409
|
+
} catch (err) {
|
|
23410
|
+
log?.(`session-tail: sidecar create failed: ${err.message}`);
|
|
23411
|
+
return null;
|
|
23412
|
+
}
|
|
23413
|
+
}
|
|
23414
|
+
function decorate(ev, sessionId) {
|
|
23415
|
+
if (!sessionId)
|
|
23416
|
+
return ev;
|
|
23417
|
+
if (ev.kind !== "tool_use" && ev.kind !== "sub_agent_tool_use")
|
|
23418
|
+
return ev;
|
|
23419
|
+
if (!ev.toolUseId)
|
|
23420
|
+
return ev;
|
|
23421
|
+
const s = ensureSidecar(sessionId);
|
|
23422
|
+
if (!s)
|
|
23423
|
+
return ev;
|
|
23424
|
+
s.poll();
|
|
23425
|
+
const label = s.getLabel(ev.toolUseId);
|
|
23426
|
+
if (!label)
|
|
23427
|
+
return ev;
|
|
23428
|
+
return { ...ev, precomputedLabel: label };
|
|
23429
|
+
}
|
|
23430
|
+
const onEvent = (ev) => rawOnEvent(ev);
|
|
23292
23431
|
let currentFile = null;
|
|
23293
23432
|
let cursor = 0;
|
|
23294
23433
|
let watcher = null;
|
|
@@ -23300,7 +23439,7 @@ function startSessionTail(config2) {
|
|
|
23300
23439
|
if (stopped || !currentFile)
|
|
23301
23440
|
return;
|
|
23302
23441
|
try {
|
|
23303
|
-
const stat =
|
|
23442
|
+
const stat = statSync3(currentFile);
|
|
23304
23443
|
if (stat.size < cursor) {
|
|
23305
23444
|
cursor = 0;
|
|
23306
23445
|
pendingPartial = "";
|
|
@@ -23325,9 +23464,10 @@ function startSessionTail(config2) {
|
|
|
23325
23464
|
if (!line)
|
|
23326
23465
|
continue;
|
|
23327
23466
|
const events = projectTranscriptLine(line);
|
|
23467
|
+
const sid = sessionIdForFile(currentFile);
|
|
23328
23468
|
for (const ev of events) {
|
|
23329
23469
|
try {
|
|
23330
|
-
onEvent(ev);
|
|
23470
|
+
onEvent(decorate(ev, sid));
|
|
23331
23471
|
} catch (err) {
|
|
23332
23472
|
log?.(`session-tail: onEvent threw: ${err.message}`);
|
|
23333
23473
|
}
|
|
@@ -23368,7 +23508,7 @@ function startSessionTail(config2) {
|
|
|
23368
23508
|
} else {
|
|
23369
23509
|
pendingPartial = "";
|
|
23370
23510
|
try {
|
|
23371
|
-
cursor =
|
|
23511
|
+
cursor = statSync3(file).size;
|
|
23372
23512
|
} catch {
|
|
23373
23513
|
cursor = 0;
|
|
23374
23514
|
}
|
|
@@ -23388,7 +23528,7 @@ function startSessionTail(config2) {
|
|
|
23388
23528
|
if (stopped)
|
|
23389
23529
|
return;
|
|
23390
23530
|
try {
|
|
23391
|
-
const stat =
|
|
23531
|
+
const stat = statSync3(t.file);
|
|
23392
23532
|
if (stat.size < t.cursor) {
|
|
23393
23533
|
t.cursor = 0;
|
|
23394
23534
|
t.pendingPartial = "";
|
|
@@ -23429,7 +23569,8 @@ function startSessionTail(config2) {
|
|
|
23429
23569
|
t.hasSeenTerminal = true;
|
|
23430
23570
|
}
|
|
23431
23571
|
try {
|
|
23432
|
-
|
|
23572
|
+
const subSid = sessionIdForFile(t.file);
|
|
23573
|
+
onEvent(decorate(ev, subSid));
|
|
23433
23574
|
} catch (err) {
|
|
23434
23575
|
log?.(`session-tail: sub onEvent threw: ${err.message}`);
|
|
23435
23576
|
}
|
|
@@ -23445,7 +23586,7 @@ function startSessionTail(config2) {
|
|
|
23445
23586
|
return;
|
|
23446
23587
|
let cursor2 = 0;
|
|
23447
23588
|
try {
|
|
23448
|
-
cursor2 =
|
|
23589
|
+
cursor2 = statSync3(file).size;
|
|
23449
23590
|
} catch {}
|
|
23450
23591
|
const t = {
|
|
23451
23592
|
agentId,
|
|
@@ -23500,8 +23641,8 @@ function startSessionTail(config2) {
|
|
|
23500
23641
|
if (!currentFile)
|
|
23501
23642
|
return;
|
|
23502
23643
|
const sessionId = basename(currentFile, ".jsonl");
|
|
23503
|
-
const subDir =
|
|
23504
|
-
if (!
|
|
23644
|
+
const subDir = join3(projectsDir, sessionId, "subagents");
|
|
23645
|
+
if (!existsSync3(subDir))
|
|
23505
23646
|
return;
|
|
23506
23647
|
let entries;
|
|
23507
23648
|
try {
|
|
@@ -23513,7 +23654,7 @@ function startSessionTail(config2) {
|
|
|
23513
23654
|
if (!e.startsWith("agent-") || !e.endsWith(".jsonl"))
|
|
23514
23655
|
continue;
|
|
23515
23656
|
const agentId = e.slice("agent-".length, -".jsonl".length);
|
|
23516
|
-
const file =
|
|
23657
|
+
const file = join3(subDir, e);
|
|
23517
23658
|
if (!subTails.has(file)) {
|
|
23518
23659
|
attachSub(file, agentId);
|
|
23519
23660
|
} else {
|
|
@@ -23554,6 +23695,12 @@ function startSessionTail(config2) {
|
|
|
23554
23695
|
}
|
|
23555
23696
|
}
|
|
23556
23697
|
subTails.clear();
|
|
23698
|
+
for (const s of sidecars.values()) {
|
|
23699
|
+
try {
|
|
23700
|
+
s.stop();
|
|
23701
|
+
} catch {}
|
|
23702
|
+
}
|
|
23703
|
+
sidecars.clear();
|
|
23557
23704
|
if (pollTimer) {
|
|
23558
23705
|
clearInterval(pollTimer);
|
|
23559
23706
|
pollTimer = null;
|
|
@@ -23567,7 +23714,7 @@ function startSessionTail(config2) {
|
|
|
23567
23714
|
|
|
23568
23715
|
// pty-tail.ts
|
|
23569
23716
|
var import_headless = __toESM(require_xterm_headless(), 1);
|
|
23570
|
-
import { existsSync as
|
|
23717
|
+
import { existsSync as existsSync4, statSync as statSync4, watch as watch2, openSync as openSync2, readSync as readSync2, closeSync as closeSync2 } from "fs";
|
|
23571
23718
|
var PRELOAD_BYTES = 1e6;
|
|
23572
23719
|
var PTY_DEBUG = process.env.SWITCHROOM_PTY_DEBUG === "1";
|
|
23573
23720
|
var lastDebugDumpAt = 0;
|
|
@@ -23842,11 +23989,11 @@ function startPtyTail(config2) {
|
|
|
23842
23989
|
function readNew() {
|
|
23843
23990
|
if (stopped)
|
|
23844
23991
|
return;
|
|
23845
|
-
if (!
|
|
23992
|
+
if (!existsSync4(config2.logFile))
|
|
23846
23993
|
return;
|
|
23847
23994
|
let stat;
|
|
23848
23995
|
try {
|
|
23849
|
-
stat =
|
|
23996
|
+
stat = statSync4(config2.logFile);
|
|
23850
23997
|
} catch {
|
|
23851
23998
|
return;
|
|
23852
23999
|
}
|
|
@@ -23875,13 +24022,13 @@ function startPtyTail(config2) {
|
|
|
23875
24022
|
});
|
|
23876
24023
|
}
|
|
23877
24024
|
function attachWatcher() {
|
|
23878
|
-
if (!
|
|
24025
|
+
if (!existsSync4(config2.logFile))
|
|
23879
24026
|
return;
|
|
23880
24027
|
if (watcher)
|
|
23881
24028
|
return;
|
|
23882
24029
|
let size = 0;
|
|
23883
24030
|
try {
|
|
23884
|
-
size =
|
|
24031
|
+
size = statSync4(config2.logFile).size;
|
|
23885
24032
|
} catch {
|
|
23886
24033
|
return;
|
|
23887
24034
|
}
|
|
@@ -24201,8 +24348,8 @@ function createIpcClient(options) {
|
|
|
24201
24348
|
|
|
24202
24349
|
// bridge/bridge.ts
|
|
24203
24350
|
installPluginLogger();
|
|
24204
|
-
var STATE_DIR = process.env.TELEGRAM_STATE_DIR ??
|
|
24205
|
-
var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ??
|
|
24351
|
+
var STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join4(homedir3(), ".claude", "channels", "telegram");
|
|
24352
|
+
var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ?? join4(STATE_DIR, "gateway.sock");
|
|
24206
24353
|
var TOPIC_ID = process.env.TELEGRAM_TOPIC_ID ? Number(process.env.TELEGRAM_TOPIC_ID) : undefined;
|
|
24207
24354
|
var AGENT_NAME = process.env.SWITCHROOM_AGENT_NAME;
|
|
24208
24355
|
if (!AGENT_NAME) {
|
|
@@ -24684,7 +24831,7 @@ var ptyTailHandle = null;
|
|
|
24684
24831
|
if (ptyTailEnabled) {
|
|
24685
24832
|
try {
|
|
24686
24833
|
const agentDir = process.env.CLAUDE_CONFIG_DIR ? dirname2(process.env.CLAUDE_CONFIG_DIR) : process.cwd();
|
|
24687
|
-
const serviceLogPath = process.env.SWITCHROOM_SERVICE_LOG_PATH ??
|
|
24834
|
+
const serviceLogPath = process.env.SWITCHROOM_SERVICE_LOG_PATH ?? join4(agentDir, "service.log");
|
|
24688
24835
|
ptyTailHandle = startPtyTail({
|
|
24689
24836
|
logFile: serviceLogPath,
|
|
24690
24837
|
log: (msg) => process.stderr.write(`telegram bridge: ${msg}
|
|
@@ -24739,7 +24886,7 @@ async function main() {
|
|
|
24739
24886
|
onStatus,
|
|
24740
24887
|
log: (msg) => process.stderr.write(`telegram bridge: ipc: ${msg}
|
|
24741
24888
|
`),
|
|
24742
|
-
livenessFilePath:
|
|
24889
|
+
livenessFilePath: join4(STATE_DIR, ".bridge-alive")
|
|
24743
24890
|
});
|
|
24744
24891
|
if (ipc.isConnected()) {
|
|
24745
24892
|
process.stderr.write(`telegram bridge: connected to gateway at ${SOCKET_PATH}
|