@tenux/cli 0.0.1 → 0.0.2
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/{chunk-P2FMWWKI.js → chunk-YSWQKJBF.js} +14 -2
- package/dist/cli.js +7 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -506,7 +506,8 @@ async function handleClaudeQuery(command, supabase) {
|
|
|
506
506
|
const {
|
|
507
507
|
prompt,
|
|
508
508
|
project_path,
|
|
509
|
-
model
|
|
509
|
+
model,
|
|
510
|
+
session_id
|
|
510
511
|
} = command.payload;
|
|
511
512
|
if (!prompt) throw new Error("prompt is required");
|
|
512
513
|
const config = loadConfig();
|
|
@@ -519,6 +520,7 @@ async function handleClaudeQuery(command, supabase) {
|
|
|
519
520
|
// structured streaming output
|
|
520
521
|
];
|
|
521
522
|
if (model) args.push("--model", model);
|
|
523
|
+
if (session_id) args.push("--resume", session_id);
|
|
522
524
|
args.push("-p", prompt);
|
|
523
525
|
const proc = spawn3("claude", args, {
|
|
524
526
|
cwd,
|
|
@@ -528,6 +530,7 @@ async function handleClaudeQuery(command, supabase) {
|
|
|
528
530
|
stdio: ["pipe", "pipe", "pipe"]
|
|
529
531
|
});
|
|
530
532
|
let seq = 0;
|
|
533
|
+
let capturedSessionId = null;
|
|
531
534
|
let batch = [];
|
|
532
535
|
const batchInterval = 100;
|
|
533
536
|
const flushBatch = async () => {
|
|
@@ -546,6 +549,12 @@ async function handleClaudeQuery(command, supabase) {
|
|
|
546
549
|
if (!line.trim()) continue;
|
|
547
550
|
try {
|
|
548
551
|
const event = JSON.parse(line);
|
|
552
|
+
if (event.type === "system" && event.subtype === "init" && event.session_id) {
|
|
553
|
+
capturedSessionId = event.session_id;
|
|
554
|
+
}
|
|
555
|
+
if (event.type === "result" && event.session_id) {
|
|
556
|
+
capturedSessionId = event.session_id;
|
|
557
|
+
}
|
|
549
558
|
batch.push({
|
|
550
559
|
command_id: command.id,
|
|
551
560
|
seq: seq++,
|
|
@@ -590,7 +599,10 @@ async function handleClaudeQuery(command, supabase) {
|
|
|
590
599
|
await flushBatch();
|
|
591
600
|
await supabase.from("commands").update({
|
|
592
601
|
status: exitCode === 0 ? "done" : "error",
|
|
593
|
-
result: {
|
|
602
|
+
result: {
|
|
603
|
+
exit_code: exitCode,
|
|
604
|
+
...capturedSessionId ? { session_id: capturedSessionId } : {}
|
|
605
|
+
},
|
|
594
606
|
completed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
595
607
|
}).eq("id", command.id);
|
|
596
608
|
promiseResolve();
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
loadConfig,
|
|
18
18
|
saveConfig,
|
|
19
19
|
updateConfig
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YSWQKJBF.js";
|
|
21
21
|
|
|
22
22
|
// src/cli.ts
|
|
23
23
|
import { Command } from "commander";
|
|
@@ -245,9 +245,6 @@ program.command("start").description("Start the agent and listen for commands").
|
|
|
245
245
|
await supabase.from("devices").update({ last_seen_at: (/* @__PURE__ */ new Date()).toISOString(), is_online: true }).eq("id", config.deviceId);
|
|
246
246
|
}, 3e4);
|
|
247
247
|
const relay = new Relay(supabase);
|
|
248
|
-
relay.on("git.clone", handleGitClone).on("git.status", handleGitStatus).on("git.pull", handleGitPull).on("fs.read", handleFsRead).on("fs.write", handleFsWrite).on("fs.list", handleFsList).on("fs.delete", handleFsDelete).on("terminal.exec", handleTerminalExec).on("terminal.kill", handleTerminalKill).on("claude.query", handleClaudeQuery);
|
|
249
|
-
await relay.start();
|
|
250
|
-
console.log(chalk.green(" \u2713"), "Agent running. Press Ctrl+C to stop.\n");
|
|
251
248
|
const shutdown = async () => {
|
|
252
249
|
console.log(chalk.dim("\n Shutting down..."));
|
|
253
250
|
clearInterval(heartbeat);
|
|
@@ -255,6 +252,12 @@ program.command("start").description("Start the agent and listen for commands").
|
|
|
255
252
|
await supabase.from("devices").update({ is_online: false }).eq("id", config.deviceId);
|
|
256
253
|
process.exit(0);
|
|
257
254
|
};
|
|
255
|
+
relay.on("git.clone", handleGitClone).on("git.status", handleGitStatus).on("git.pull", handleGitPull).on("fs.read", handleFsRead).on("fs.write", handleFsWrite).on("fs.list", handleFsList).on("fs.delete", handleFsDelete).on("terminal.exec", handleTerminalExec).on("terminal.kill", handleTerminalKill).on("claude.query", handleClaudeQuery).on("agent.shutdown", async () => {
|
|
256
|
+
console.log(chalk.yellow("\n \u26A1 Remote shutdown requested"));
|
|
257
|
+
await shutdown();
|
|
258
|
+
});
|
|
259
|
+
await relay.start();
|
|
260
|
+
console.log(chalk.green(" \u2713"), "Agent running. Press Ctrl+C to stop.\n");
|
|
258
261
|
process.on("SIGINT", shutdown);
|
|
259
262
|
process.on("SIGTERM", shutdown);
|
|
260
263
|
});
|
package/dist/index.js
CHANGED