@standardagents/code 0.11.7 → 0.11.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/dist/index.js +72 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import os8, { homedir } from 'os';
|
|
3
3
|
import path4 from 'path';
|
|
4
|
-
import
|
|
4
|
+
import readline3 from 'readline/promises';
|
|
5
5
|
import { stdout, stdin } from 'process';
|
|
6
6
|
import net from 'net';
|
|
7
7
|
import fs5 from 'fs';
|
|
@@ -938,6 +938,7 @@ var TunnelManager = class {
|
|
|
938
938
|
let opened = false;
|
|
939
939
|
const socket = net.connect({ host, port });
|
|
940
940
|
socket.setNoDelay(true);
|
|
941
|
+
socket.setKeepAlive(true, 15e3);
|
|
941
942
|
this.tunnels.set(id, { socket });
|
|
942
943
|
socket.on("connect", () => {
|
|
943
944
|
opened = true;
|
|
@@ -6490,7 +6491,7 @@ function readVersion() {
|
|
|
6490
6491
|
if (typeof pkg.version === "string" && pkg.version) return pkg.version;
|
|
6491
6492
|
} catch {
|
|
6492
6493
|
}
|
|
6493
|
-
return "0.11.
|
|
6494
|
+
return "0.11.8" ;
|
|
6494
6495
|
}
|
|
6495
6496
|
function isLocalHost(host) {
|
|
6496
6497
|
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host.endsWith(".local") || host.endsWith(".localhost") || /^10\./.test(host) || /^192\.168\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host);
|
|
@@ -6879,16 +6880,16 @@ async function clearMachineCommands(api, machineId, appliedIds) {
|
|
|
6879
6880
|
async function applyMachineCommand(api, identity, cmd) {
|
|
6880
6881
|
switch (cmd.kind) {
|
|
6881
6882
|
case "add_project": {
|
|
6882
|
-
const
|
|
6883
|
-
if (!
|
|
6884
|
-
await registerProject(api, identity,
|
|
6885
|
-
return `added project ${
|
|
6883
|
+
const path16 = typeof cmd.args?.path === "string" ? cmd.args.path : "";
|
|
6884
|
+
if (!path16) return "add_project: ignored (no path)";
|
|
6885
|
+
await registerProject(api, identity, path16);
|
|
6886
|
+
return `added project ${path16}`;
|
|
6886
6887
|
}
|
|
6887
6888
|
case "remove_project": {
|
|
6888
|
-
const
|
|
6889
|
-
if (!
|
|
6890
|
-
await unregisterProject(api, identity,
|
|
6891
|
-
return `removed project ${
|
|
6889
|
+
const path16 = typeof cmd.args?.path === "string" ? cmd.args.path : "";
|
|
6890
|
+
if (!path16) return "remove_project: ignored (no path)";
|
|
6891
|
+
await unregisterProject(api, identity, path16);
|
|
6892
|
+
return `removed project ${path16}`;
|
|
6892
6893
|
}
|
|
6893
6894
|
case "update":
|
|
6894
6895
|
return "update requested";
|
|
@@ -8181,7 +8182,7 @@ async function installCommand(endpointFlag) {
|
|
|
8181
8182
|
const identity = loadMachineIdentity();
|
|
8182
8183
|
const existing = await loadMachine(api, identity.machine_id).catch(() => null);
|
|
8183
8184
|
const suggested = machineDisplayName(existing ?? { hostname: os8.hostname(), id: identity.machine_id });
|
|
8184
|
-
const rl =
|
|
8185
|
+
const rl = readline3.createInterface({ input: stdin, output: stdout });
|
|
8185
8186
|
const answer = (await rl.question(
|
|
8186
8187
|
`${c3.bold}Machine name${c3.reset} ${c3.dim}(shown in the session picker)${c3.reset} [${suggested}]: `
|
|
8187
8188
|
)).trim();
|
|
@@ -8339,6 +8340,29 @@ async function runDaemonCommand(argv) {
|
|
|
8339
8340
|
}
|
|
8340
8341
|
}
|
|
8341
8342
|
}
|
|
8343
|
+
var DIR2 = path4.join(os8.homedir(), ".standardagents");
|
|
8344
|
+
var FILE2 = path4.join(DIR2, "prefs.json");
|
|
8345
|
+
function loadPrefs(file2 = FILE2) {
|
|
8346
|
+
try {
|
|
8347
|
+
return JSON.parse(fs5.readFileSync(file2, "utf8"));
|
|
8348
|
+
} catch {
|
|
8349
|
+
return {};
|
|
8350
|
+
}
|
|
8351
|
+
}
|
|
8352
|
+
function savePrefs(update, file2 = FILE2) {
|
|
8353
|
+
const merged = { ...loadPrefs(file2), ...update };
|
|
8354
|
+
fs5.mkdirSync(path4.dirname(file2), { recursive: true });
|
|
8355
|
+
fs5.writeFileSync(file2, JSON.stringify(merged, null, 2));
|
|
8356
|
+
}
|
|
8357
|
+
function shouldOfferDaemonInstall(facts) {
|
|
8358
|
+
if (facts.optedOutEnv) return false;
|
|
8359
|
+
if (!facts.interactive) return false;
|
|
8360
|
+
if (facts.platform === "win32") return false;
|
|
8361
|
+
if (facts.serviceInstalled) return false;
|
|
8362
|
+
if (facts.daemonOnline) return false;
|
|
8363
|
+
if (facts.declinedAt !== void 0) return false;
|
|
8364
|
+
return true;
|
|
8365
|
+
}
|
|
8342
8366
|
|
|
8343
8367
|
// src/auth-cli.ts
|
|
8344
8368
|
var c4 = {
|
|
@@ -8729,7 +8753,7 @@ ${c5.dim}Press Control-C again to exit${c5.reset}
|
|
|
8729
8753
|
};
|
|
8730
8754
|
const ask = async (question) => {
|
|
8731
8755
|
if (!reader.rl) {
|
|
8732
|
-
reader.rl =
|
|
8756
|
+
reader.rl = readline3.createInterface({ input: stdin, output: stdout });
|
|
8733
8757
|
reader.rl.on("SIGINT", onPreflightSigint);
|
|
8734
8758
|
reader.rl.on("close", () => {
|
|
8735
8759
|
if (handoffClosing) return;
|
|
@@ -8912,6 +8936,42 @@ ${c5.dim}Press Control-C again to exit${c5.reset}
|
|
|
8912
8936
|
session.suggestDaemonInstall = machines.every((m) => !m.daemon);
|
|
8913
8937
|
const remoteTargets = machines.filter((m) => m.id !== identity.machine_id && daemonOnline(m));
|
|
8914
8938
|
const self = machines.find((m) => m.id === identity.machine_id);
|
|
8939
|
+
if (shouldOfferDaemonInstall({
|
|
8940
|
+
platform: process.platform,
|
|
8941
|
+
interactive: Boolean(stdin.isTTY && stdout.isTTY),
|
|
8942
|
+
serviceInstalled: serviceStatus().installed,
|
|
8943
|
+
daemonOnline: Boolean(self && daemonOnline(self)),
|
|
8944
|
+
declinedAt: loadPrefs().daemon_install_declined_at,
|
|
8945
|
+
optedOutEnv: Boolean(process.env.STANDARD_CODE_NO_DAEMON_PROMPT)
|
|
8946
|
+
})) {
|
|
8947
|
+
stdout.write(
|
|
8948
|
+
`
|
|
8949
|
+
${c5.bold}This machine has no always-on daemon${c5.reset} ${c5.dim}\u2014 sessions stop when this terminal closes.${c5.reset}
|
|
8950
|
+
`
|
|
8951
|
+
);
|
|
8952
|
+
const promptRl = readline3.createInterface({ input: stdin, output: stdout });
|
|
8953
|
+
let answer = "";
|
|
8954
|
+
try {
|
|
8955
|
+
answer = (await promptRl.question(
|
|
8956
|
+
`${c5.white}Install it now so sessions keep running and start from anywhere?${c5.reset} ${c5.dim}[Y/n]${c5.reset} `
|
|
8957
|
+
)).trim().toLowerCase();
|
|
8958
|
+
} catch {
|
|
8959
|
+
answer = "n";
|
|
8960
|
+
} finally {
|
|
8961
|
+
promptRl.close();
|
|
8962
|
+
}
|
|
8963
|
+
if (answer === "" || answer === "y" || answer === "yes") {
|
|
8964
|
+
await runDaemonCommand(endpointOverride ? ["install", "--endpoint", endpoint] : ["install"]);
|
|
8965
|
+
stdout.write("\n");
|
|
8966
|
+
} else {
|
|
8967
|
+
savePrefs({ daemon_install_declined_at: Date.now() });
|
|
8968
|
+
stdout.write(
|
|
8969
|
+
`${c5.dim}Okay \u2014 \`standardcode daemon install\` sets it up any time.${c5.reset}
|
|
8970
|
+
|
|
8971
|
+
`
|
|
8972
|
+
);
|
|
8973
|
+
}
|
|
8974
|
+
}
|
|
8915
8975
|
const launchDir = projectDir;
|
|
8916
8976
|
let tags = [];
|
|
8917
8977
|
let resumeTags = [];
|