@rubytech/create-realagent 1.0.630 → 1.0.632
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/index.js +17 -4
- package/package.json +1 -1
- package/payload/platform/plugins/cloudflare/references/manual-setup.md +12 -1
- package/payload/platform/plugins/cloudflare/scripts/setup-tunnel.sh +66 -39
- package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +1 -1
- package/payload/server/public/assets/{admin-DirN63aF.js → admin-BntwbBs-.js} +60 -60
- package/payload/server/public/index.html +1 -1
- package/payload/server/server.js +100 -25
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Real Agent</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-BntwbBs-.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-Be6NvmcD.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-rov5CBGT.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-tbj4tUsl.js">
|
package/payload/server/server.js
CHANGED
|
@@ -4359,7 +4359,7 @@ import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
|
|
|
4359
4359
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
4360
4360
|
import { resolve as resolve6, join as join4 } from "path";
|
|
4361
4361
|
import { platform as osPlatform } from "os";
|
|
4362
|
-
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, readdirSync as readdirSync2, existsSync as existsSync6, mkdirSync as mkdirSync4, createWriteStream, statSync as statSync3, unlinkSync as unlinkSync2, cpSync, rmSync } from "fs";
|
|
4362
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, readdirSync as readdirSync2, existsSync as existsSync6, mkdirSync as mkdirSync4, createWriteStream, statSync as statSync3, unlinkSync as unlinkSync2, cpSync, rmSync, appendFileSync as appendFileSync2 } from "fs";
|
|
4363
4363
|
import { lookup as dnsLookup } from "dns/promises";
|
|
4364
4364
|
import { createConnection as netConnect } from "net";
|
|
4365
4365
|
import { StringDecoder } from "string_decoder";
|
|
@@ -6373,14 +6373,41 @@ function agentLogStream(name, accountDir, conversationId) {
|
|
|
6373
6373
|
const logDir = resolve6(accountDir, "logs");
|
|
6374
6374
|
mkdirSync4(logDir, { recursive: true });
|
|
6375
6375
|
purgeOldLogs(logDir, `${name}-`);
|
|
6376
|
-
|
|
6376
|
+
const logPath2 = resolve6(logDir, `${name}-${conversationId}.log`);
|
|
6377
|
+
const stream = createWriteStream(logPath2, { flags: "a" });
|
|
6378
|
+
registerStreamLog(stream, { path: logPath2, conversationId, name });
|
|
6379
|
+
return stream;
|
|
6377
6380
|
}
|
|
6378
6381
|
function preConversationLogStream(name, accountDir) {
|
|
6379
6382
|
const logDir = resolve6(accountDir, "logs");
|
|
6380
6383
|
mkdirSync4(logDir, { recursive: true });
|
|
6381
6384
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
6382
6385
|
purgeOldLogs(logDir, `preconversation-${name}-`);
|
|
6383
|
-
|
|
6386
|
+
const logPath2 = resolve6(logDir, `preconversation-${name}-${date5}.log`);
|
|
6387
|
+
const stream = createWriteStream(logPath2, { flags: "a" });
|
|
6388
|
+
registerStreamLog(stream, { path: logPath2, conversationId: null, name: `preconversation-${name}` });
|
|
6389
|
+
return stream;
|
|
6390
|
+
}
|
|
6391
|
+
var openStreamLogs = /* @__PURE__ */ new Map();
|
|
6392
|
+
function registerStreamLog(stream, entry) {
|
|
6393
|
+
openStreamLogs.set(stream, entry);
|
|
6394
|
+
stream.once("close", () => {
|
|
6395
|
+
openStreamLogs.delete(stream);
|
|
6396
|
+
});
|
|
6397
|
+
}
|
|
6398
|
+
function sigtermFlushStreamLogs(reason, source) {
|
|
6399
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
6400
|
+
for (const entry of openStreamLogs.values()) {
|
|
6401
|
+
const convPart = entry.conversationId ? ` conversationId=${entry.conversationId}` : "";
|
|
6402
|
+
const line = `[${ts}] [server-sigterm] reason=${reason}${convPart} name=${entry.name} source=${source}
|
|
6403
|
+
`;
|
|
6404
|
+
try {
|
|
6405
|
+
appendFileSync2(entry.path, line);
|
|
6406
|
+
} catch (err) {
|
|
6407
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
6408
|
+
console.error(`[server-sigterm-flush-err] path=${entry.path} reason=${msg}`);
|
|
6409
|
+
}
|
|
6410
|
+
}
|
|
6384
6411
|
}
|
|
6385
6412
|
function purgeOldLogs(logDir, prefix) {
|
|
6386
6413
|
const cutoff = Date.now() - LOG_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
@@ -11341,7 +11368,7 @@ function sourceKey(file2) {
|
|
|
11341
11368
|
}
|
|
11342
11369
|
|
|
11343
11370
|
// app/lib/review-detector/writer.ts
|
|
11344
|
-
import { appendFileSync as
|
|
11371
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync8, renameSync as renameSync3, statSync as statSync6 } from "fs";
|
|
11345
11372
|
import { resolve as resolve9, dirname as dirname4 } from "path";
|
|
11346
11373
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
11347
11374
|
function reviewLogPath(configDir2) {
|
|
@@ -11358,7 +11385,7 @@ function reviewLog(configDir2, event) {
|
|
|
11358
11385
|
typeof event.ts === "number" ? event.ts : Date.now()
|
|
11359
11386
|
).toISOString()} [review] ${JSON.stringify(event)}
|
|
11360
11387
|
`;
|
|
11361
|
-
|
|
11388
|
+
appendFileSync3(path2, line, "utf-8");
|
|
11362
11389
|
} catch (err) {
|
|
11363
11390
|
console.error(`[review] failed to write review log at ${path2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
11364
11391
|
}
|
|
@@ -11472,7 +11499,7 @@ function queueAlert(configDir2, accountId, match2) {
|
|
|
11472
11499
|
try {
|
|
11473
11500
|
mkdirSync7(dirname4(path2), { recursive: true });
|
|
11474
11501
|
const line = JSON.stringify({ accountId, match: match2 }) + "\n";
|
|
11475
|
-
|
|
11502
|
+
appendFileSync3(path2, line, "utf-8");
|
|
11476
11503
|
} catch (err) {
|
|
11477
11504
|
console.error(`[review] failed to queue alert at ${path2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
11478
11505
|
}
|
|
@@ -31543,6 +31570,40 @@ function startScriptStreamTailer(opts) {
|
|
|
31543
31570
|
};
|
|
31544
31571
|
}
|
|
31545
31572
|
|
|
31573
|
+
// app/lib/admin-sse-registry.ts
|
|
31574
|
+
var activeAdminSSEControllers = /* @__PURE__ */ new Set();
|
|
31575
|
+
function registerAdminSSE(entry) {
|
|
31576
|
+
activeAdminSSEControllers.add(entry);
|
|
31577
|
+
}
|
|
31578
|
+
function unregisterAdminSSE(entry) {
|
|
31579
|
+
activeAdminSSEControllers.delete(entry);
|
|
31580
|
+
}
|
|
31581
|
+
function broadcastAdminShutdown(reason) {
|
|
31582
|
+
const encoder = new TextEncoder();
|
|
31583
|
+
const payload = JSON.stringify({ type: "server_shutdown", reason });
|
|
31584
|
+
const frame = encoder.encode(`data: ${payload}
|
|
31585
|
+
|
|
31586
|
+
`);
|
|
31587
|
+
const done = encoder.encode(`data: [DONE]
|
|
31588
|
+
|
|
31589
|
+
`);
|
|
31590
|
+
for (const entry of activeAdminSSEControllers) {
|
|
31591
|
+
try {
|
|
31592
|
+
entry.controller.enqueue(frame);
|
|
31593
|
+
} catch {
|
|
31594
|
+
}
|
|
31595
|
+
try {
|
|
31596
|
+
entry.controller.enqueue(done);
|
|
31597
|
+
} catch {
|
|
31598
|
+
}
|
|
31599
|
+
try {
|
|
31600
|
+
entry.controller.close();
|
|
31601
|
+
} catch {
|
|
31602
|
+
}
|
|
31603
|
+
}
|
|
31604
|
+
activeAdminSSEControllers.clear();
|
|
31605
|
+
}
|
|
31606
|
+
|
|
31546
31607
|
// app/api/admin/chat/route.ts
|
|
31547
31608
|
function isComponentDone(parsed) {
|
|
31548
31609
|
return typeof parsed === "object" && parsed !== null && parsed._componentDone === true && typeof parsed.component === "string" && typeof parsed.payload === "string";
|
|
@@ -31738,29 +31799,31 @@ async function POST21(req) {
|
|
|
31738
31799
|
const readable = new ReadableStream({
|
|
31739
31800
|
async start(controller) {
|
|
31740
31801
|
let controllerOpen = true;
|
|
31741
|
-
|
|
31742
|
-
|
|
31743
|
-
|
|
31744
|
-
|
|
31745
|
-
|
|
31746
|
-
|
|
31747
|
-
|
|
31748
|
-
|
|
31802
|
+
const sseEntry = { controller, conversationId: sseConvId ?? null, sessionKey: session_key };
|
|
31803
|
+
try {
|
|
31804
|
+
registerAdminSSE(sseEntry);
|
|
31805
|
+
if (sseConvId) {
|
|
31806
|
+
const streamLogPath = resolve19(account.accountDir, "logs", `claude-agent-stream-${sseConvId}.log`);
|
|
31807
|
+
tailer = startScriptStreamTailer({
|
|
31808
|
+
path: streamLogPath,
|
|
31809
|
+
onEvent: (event) => {
|
|
31810
|
+
if (!controllerOpen) return;
|
|
31811
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
31812
|
+
sseLog.write(`[${ts}] [${sk}] admin: ${JSON.stringify(event)}
|
|
31749
31813
|
`);
|
|
31750
|
-
|
|
31751
|
-
|
|
31814
|
+
try {
|
|
31815
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}
|
|
31752
31816
|
|
|
31753
31817
|
`));
|
|
31754
|
-
|
|
31755
|
-
|
|
31818
|
+
} catch {
|
|
31819
|
+
controllerOpen = false;
|
|
31820
|
+
}
|
|
31821
|
+
},
|
|
31822
|
+
onError: (err) => {
|
|
31823
|
+
console.error(`[script-stream-tailer] ${streamLogPath}: ${err.message}`);
|
|
31756
31824
|
}
|
|
31757
|
-
}
|
|
31758
|
-
|
|
31759
|
-
console.error(`[script-stream-tailer] ${streamLogPath}: ${err.message}`);
|
|
31760
|
-
}
|
|
31761
|
-
});
|
|
31762
|
-
}
|
|
31763
|
-
try {
|
|
31825
|
+
});
|
|
31826
|
+
}
|
|
31764
31827
|
for await (const event of invokeAgent(
|
|
31765
31828
|
{ type: "admin", skipTopicCheck },
|
|
31766
31829
|
message,
|
|
@@ -31819,6 +31882,7 @@ async function POST21(req) {
|
|
|
31819
31882
|
controller.close();
|
|
31820
31883
|
} catch {
|
|
31821
31884
|
}
|
|
31885
|
+
unregisterAdminSSE(sseEntry);
|
|
31822
31886
|
}
|
|
31823
31887
|
}
|
|
31824
31888
|
});
|
|
@@ -33598,6 +33662,17 @@ process.on("SIGTERM", async () => {
|
|
|
33598
33662
|
}
|
|
33599
33663
|
shuttingDown = true;
|
|
33600
33664
|
console.error("[server] SIGTERM received \u2014 starting graceful shutdown");
|
|
33665
|
+
try {
|
|
33666
|
+
sigtermFlushStreamLogs("systemd-stop", "server-index");
|
|
33667
|
+
} catch (err) {
|
|
33668
|
+
console.error(`[server] sigterm flush error: ${String(err)}`);
|
|
33669
|
+
}
|
|
33670
|
+
try {
|
|
33671
|
+
broadcastAdminShutdown("systemd-stop");
|
|
33672
|
+
} catch (err) {
|
|
33673
|
+
console.error(`[server] sigterm broadcast error: ${String(err)}`);
|
|
33674
|
+
}
|
|
33675
|
+
await new Promise((res) => setImmediate(res));
|
|
33601
33676
|
try {
|
|
33602
33677
|
await shutdown();
|
|
33603
33678
|
} catch (err) {
|