@versot/vaguspi 0.1.4 → 0.1.5
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/bin.js +31 -41
- package/dist/bin.js.map +3 -3
- package/gui/assets/index-DL6d29Yn.js +19 -0
- package/gui/assets/settings-B-1r6vjG.js +60 -0
- package/gui/assets/vendor-D5Ls3_dM.js +41 -0
- package/gui/index.html +3 -3
- package/package.json +1 -1
- package/gui/assets/index-Dl4o9eCz.js +0 -19
- package/gui/assets/settings-V9zrDr2c.js +0 -60
- package/gui/assets/vendor-CkEpMl6t.js +0 -40
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// apps/cli/src/bin.ts
|
|
4
|
-
import { readFileSync as readFileSync7 } from "node:fs";
|
|
4
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
|
|
7
7
|
// apps/cli/src/commands/daemon.ts
|
|
@@ -870,7 +870,7 @@ var ExtensionUiBridge = class {
|
|
|
870
870
|
};
|
|
871
871
|
|
|
872
872
|
// packages/host/engine/dist/vagus-engine.js
|
|
873
|
-
var VagusEngine = class {
|
|
873
|
+
var VagusEngine = class _VagusEngine {
|
|
874
874
|
options;
|
|
875
875
|
sessions = /* @__PURE__ */ new Map();
|
|
876
876
|
/**
|
|
@@ -1698,8 +1698,6 @@ var VagusEngine = class {
|
|
|
1698
1698
|
closeSessionForCwd(cwd) {
|
|
1699
1699
|
for (const [sid, session] of this.sessions) {
|
|
1700
1700
|
if (session.sessionManager?.getCwd() === cwd) {
|
|
1701
|
-
process.stderr.write(`vagus: disposing session ${sid} (cwd=${cwd})
|
|
1702
|
-
`);
|
|
1703
1701
|
try {
|
|
1704
1702
|
session.dispose();
|
|
1705
1703
|
} catch (err) {
|
|
@@ -1769,10 +1767,9 @@ var VagusEngine = class {
|
|
|
1769
1767
|
return void 0;
|
|
1770
1768
|
}
|
|
1771
1769
|
}
|
|
1772
|
-
/** Restores an archived project: moves its session files back under `sessions/`. */
|
|
1773
1770
|
/** Restores an archived project by its encoded dir name (unique identity). */
|
|
1774
1771
|
async unarchiveProjectByDir(dirKey) {
|
|
1775
|
-
if (!
|
|
1772
|
+
if (!_VagusEngine.isSafeDirKey(dirKey))
|
|
1776
1773
|
return;
|
|
1777
1774
|
const agentDir = this.agentDirPath();
|
|
1778
1775
|
const src = join5(agentDir, "archived", dirKey);
|
|
@@ -1824,12 +1821,10 @@ var VagusEngine = class {
|
|
|
1824
1821
|
/** Permanently deletes an archived project dir by its encoded dir name.
|
|
1825
1822
|
* dirKey (not cwd) is the identity — cwds can repeat across archive dirs. */
|
|
1826
1823
|
async deleteArchivedProjectByDir(dirKey) {
|
|
1827
|
-
if (!
|
|
1824
|
+
if (!_VagusEngine.isSafeDirKey(dirKey))
|
|
1828
1825
|
return;
|
|
1829
1826
|
const agentDir = this.agentDirPath();
|
|
1830
1827
|
const dir = join5(agentDir, "archived", dirKey);
|
|
1831
|
-
process.stderr.write(`vagus: deleteArchivedProjectByDir dirKey=${dirKey}
|
|
1832
|
-
`);
|
|
1833
1828
|
const prefix = dir + sep;
|
|
1834
1829
|
for (const [sid, session] of this.sessions) {
|
|
1835
1830
|
const file = session.sessionManager?.getSessionFile();
|
|
@@ -1843,24 +1838,18 @@ var VagusEngine = class {
|
|
|
1843
1838
|
});
|
|
1844
1839
|
}
|
|
1845
1840
|
}
|
|
1846
|
-
process.stderr.write(`vagus: sessions closed, removing dir...
|
|
1847
|
-
`);
|
|
1848
1841
|
this.rmDirSafe(dir);
|
|
1849
|
-
process.stderr.write(`vagus: archived dir removed OK
|
|
1850
|
-
`);
|
|
1851
1842
|
}
|
|
1852
1843
|
/** Permanently deletes an archived project's session dir (JSONL). */
|
|
1853
1844
|
async deleteArchivedProject(cwd) {
|
|
1854
1845
|
const agentDir = this.agentDirPath();
|
|
1855
1846
|
const dir = join5(agentDir, "archived", this.encodeCwd(cwd));
|
|
1856
|
-
process.stderr.write(`vagus: deleteArchivedProject cwd=${cwd} dir=${dir}
|
|
1857
|
-
`);
|
|
1858
1847
|
this.closeSessionForCwd(cwd);
|
|
1859
|
-
process.stderr.write(`vagus: sessions closed, removing dir...
|
|
1860
|
-
`);
|
|
1861
1848
|
this.rmDirSafe(dir);
|
|
1862
|
-
|
|
1863
|
-
|
|
1849
|
+
}
|
|
1850
|
+
/** Safe archive-dir name: a plain single path segment, never traversal. */
|
|
1851
|
+
static isSafeDirKey(dirKey) {
|
|
1852
|
+
return dirKey.length > 0 && dirKey !== "." && dirKey !== ".." && !dirKey.includes("/") && !dirKey.includes("\\") && !dirKey.includes("..");
|
|
1864
1853
|
}
|
|
1865
1854
|
/**
|
|
1866
1855
|
* rmSync(recursive) has crashed the daemon natively (0xC0000409 fastfail)
|
|
@@ -2026,17 +2015,20 @@ var VagusEngine = class {
|
|
|
2026
2015
|
if (!existsSync3(sourceFile))
|
|
2027
2016
|
throw new Error(`source session file not found: ${sourceFile}`);
|
|
2028
2017
|
const raw = readFileSync4(sourceFile, "utf8");
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2018
|
+
const entries = raw.split("\n").filter((l) => l.trim().length > 0).flatMap((l) => {
|
|
2019
|
+
try {
|
|
2020
|
+
return [JSON.parse(l)];
|
|
2021
|
+
} catch {
|
|
2022
|
+
return [];
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2031
2025
|
const header = entries[0];
|
|
2032
2026
|
if (!header || header.type !== "session")
|
|
2033
2027
|
throw new Error("source session has no header");
|
|
2034
2028
|
const targetIdx = entries.findIndex((e) => e.id === entryId);
|
|
2035
2029
|
if (targetIdx < 0)
|
|
2036
2030
|
throw new Error(`entry ${entryId} not found in source session`);
|
|
2037
|
-
|
|
2038
|
-
if (endIdx < 1)
|
|
2039
|
-
endIdx = 1;
|
|
2031
|
+
const endIdx = targetIdx - 1;
|
|
2040
2032
|
const cwd = session.sessionManager.getCwd() || this.options.cwd;
|
|
2041
2033
|
const sessionDir = dirname3(sourceFile);
|
|
2042
2034
|
mkdirSync4(sessionDir, { recursive: true });
|
|
@@ -7092,8 +7084,9 @@ function applyHttpProxy() {
|
|
|
7092
7084
|
const normalized = /^https?:\/\//.test(proxy) ? proxy : `http://${proxy}`;
|
|
7093
7085
|
process.env.HTTPS_PROXY = normalized;
|
|
7094
7086
|
process.env.HTTP_PROXY = normalized;
|
|
7087
|
+
process.env.NO_PROXY ??= "localhost,127.0.0.1";
|
|
7095
7088
|
setGlobalDispatcher(new EnvHttpProxyAgent());
|
|
7096
|
-
process.stderr.write(`vagus: http proxy enabled \u2192 ${normalized}
|
|
7089
|
+
process.stderr.write(`vagus: http proxy enabled \u2192 ${normalized.replace(/\/\/([^@/]*)@/, "//***@")}
|
|
7097
7090
|
`);
|
|
7098
7091
|
}
|
|
7099
7092
|
} catch (err) {
|
|
@@ -7674,10 +7667,10 @@ async function runDaemon() {
|
|
|
7674
7667
|
});
|
|
7675
7668
|
server = new JsonRpcServer({ send: (frame) => transport.send(frame) });
|
|
7676
7669
|
registerMethods(server);
|
|
7677
|
-
const
|
|
7670
|
+
const requestedPort = Number(process.env.VAGUS_WS_PORT ?? "19707");
|
|
7678
7671
|
const wsHost = new WsServerHost();
|
|
7679
|
-
wsHost.listen({
|
|
7680
|
-
port:
|
|
7672
|
+
await wsHost.listen({
|
|
7673
|
+
port: requestedPort,
|
|
7681
7674
|
registerMethods,
|
|
7682
7675
|
staticDir: process.env.VAGUS_GUI_DIR
|
|
7683
7676
|
});
|
|
@@ -7690,7 +7683,6 @@ async function runDaemon() {
|
|
|
7690
7683
|
if (shuttingDown) return;
|
|
7691
7684
|
shuttingDown = true;
|
|
7692
7685
|
process.stderr.write(`vagus: daemon shutting down (${signal})
|
|
7693
|
-
${new Error("shutdown trace").stack}
|
|
7694
7686
|
`);
|
|
7695
7687
|
void (async () => {
|
|
7696
7688
|
try {
|
|
@@ -7704,14 +7696,6 @@ ${new Error("shutdown trace").stack}
|
|
|
7704
7696
|
};
|
|
7705
7697
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
7706
7698
|
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
7707
|
-
process.on("beforeExit", (code) => {
|
|
7708
|
-
process.stderr.write(`vagus: daemon beforeExit (event loop empty), code=${code}
|
|
7709
|
-
`);
|
|
7710
|
-
});
|
|
7711
|
-
process.on("exit", (code) => {
|
|
7712
|
-
process.stderr.write(`vagus: daemon exit, code=${code}
|
|
7713
|
-
`);
|
|
7714
|
-
});
|
|
7715
7699
|
transport.start();
|
|
7716
7700
|
process.stderr.write(`pi-web daemon ready (state: ${stateDir})
|
|
7717
7701
|
`);
|
|
@@ -7734,8 +7718,7 @@ import { join as join9 } from "node:path";
|
|
|
7734
7718
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7735
7719
|
|
|
7736
7720
|
// apps/cli/src/daemon.ts
|
|
7737
|
-
import { spawn } from "node:child_process";
|
|
7738
|
-
import { execSync } from "node:child_process";
|
|
7721
|
+
import { execSync, spawn } from "node:child_process";
|
|
7739
7722
|
import { existsSync as existsSync7 } from "node:fs";
|
|
7740
7723
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7741
7724
|
function detectSystemProxy() {
|
|
@@ -7772,6 +7755,9 @@ function daemonEntryPath() {
|
|
|
7772
7755
|
const source = `${base}.ts`;
|
|
7773
7756
|
return existsSync7(source) ? source : `${base}.js`;
|
|
7774
7757
|
}
|
|
7758
|
+
function defaultWsPort() {
|
|
7759
|
+
return daemonEntryPath().endsWith(".ts") ? 19708 : 19707;
|
|
7760
|
+
}
|
|
7775
7761
|
function spawnDaemon(options = {}) {
|
|
7776
7762
|
const entry = daemonEntryPath();
|
|
7777
7763
|
const args = entry.endsWith(".ts") ? ["--import", "tsx", entry, "daemon"] : [entry, "daemon"];
|
|
@@ -7783,7 +7769,8 @@ function spawnDaemon(options = {}) {
|
|
|
7783
7769
|
injected.HTTPS_PROXY = sysProxy;
|
|
7784
7770
|
injected.HTTP_PROXY = sysProxy;
|
|
7785
7771
|
injected.NO_PROXY = process.env.NO_PROXY ?? "localhost,127.0.0.1";
|
|
7786
|
-
|
|
7772
|
+
const redacted = sysProxy.replace(/\/\/([^@/]*)@/, "//***@");
|
|
7773
|
+
process.stderr.write(`vagus: following system proxy \u2192 ${redacted}
|
|
7787
7774
|
`);
|
|
7788
7775
|
} else {
|
|
7789
7776
|
process.stderr.write(`vagus: no system proxy detected (direct connections)
|
|
@@ -7800,7 +7787,7 @@ function spawnDaemon(options = {}) {
|
|
|
7800
7787
|
}
|
|
7801
7788
|
|
|
7802
7789
|
// apps/cli/src/commands/web.ts
|
|
7803
|
-
var DEFAULT_WS_PORT =
|
|
7790
|
+
var DEFAULT_WS_PORT = defaultWsPort();
|
|
7804
7791
|
function guiDistPath() {
|
|
7805
7792
|
const prod = fileURLToPath3(new URL("../gui", import.meta.url));
|
|
7806
7793
|
if (existsSync8(join9(prod, "index.html"))) return prod;
|
|
@@ -7865,6 +7852,9 @@ async function runWeb() {
|
|
|
7865
7852
|
}
|
|
7866
7853
|
|
|
7867
7854
|
// apps/cli/src/bin.ts
|
|
7855
|
+
if (!process.env.VAGUS_WS_PORT && existsSync9(new URL("./commands/daemon.ts", import.meta.url))) {
|
|
7856
|
+
process.env.VAGUS_WS_PORT = "19708";
|
|
7857
|
+
}
|
|
7868
7858
|
var VERSION = JSON.parse(
|
|
7869
7859
|
readFileSync7(new URL("../package.json", import.meta.url), "utf8")
|
|
7870
7860
|
).version;
|