@aarmos/bridge 0.1.10 → 0.1.11
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/bridge.js +7 -129
- package/dist/chunk-GMH5B5YX.js +871 -0
- package/dist/index.js +1500 -219
- package/dist/verify-O6X7MFEE.js +409 -0
- package/package.json +4 -3
- package/dist/bridge.js.map +0 -1
- package/dist/commands/attest.js +0 -62
- package/dist/commands/attest.js.map +0 -1
- package/dist/commands/demo.js +0 -171
- package/dist/commands/demo.js.map +0 -1
- package/dist/commands/dev.js +0 -56
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/pack.js +0 -96
- package/dist/commands/pack.js.map +0 -1
- package/dist/commands/playbook.js +0 -55
- package/dist/commands/playbook.js.map +0 -1
- package/dist/commands/run.js +0 -290
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/simulate.js +0 -180
- package/dist/commands/simulate.js.map +0 -1
- package/dist/commands/verify.js +0 -87
- package/dist/commands/verify.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/attest.js +0 -167
- package/dist/lib/attest.js.map +0 -1
- package/dist/lib/http-broker.js +0 -82
- package/dist/lib/http-broker.js.map +0 -1
- package/dist/lib/llm-test.js +0 -174
- package/dist/lib/llm-test.js.map +0 -1
- package/dist/lib/mcp-broker.js +0 -85
- package/dist/lib/mcp-broker.js.map +0 -1
- package/dist/lib/pack.js +0 -84
- package/dist/lib/pack.js.map +0 -1
- package/dist/lib/playbook.js +0 -237
- package/dist/lib/playbook.js.map +0 -1
- package/dist/lib/scope-templates.js +0 -152
- package/dist/lib/scope-templates.js.map +0 -1
- package/dist/rpc/router.js +0 -349
- package/dist/rpc/router.js.map +0 -1
- package/dist/session.js +0 -100
- package/dist/session.js.map +0 -1
- package/dist/watchers/files.js +0 -31
- package/dist/watchers/files.js.map +0 -1
- package/dist/watchers/git.js +0 -39
- package/dist/watchers/git.js.map +0 -1
package/dist/bridge.js
CHANGED
|
@@ -1,129 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// take the whole bridge down. The dev is likely mid-flow in another tab.
|
|
9
|
-
installProcessGuards();
|
|
10
|
-
const wss = new WebSocketServer({
|
|
11
|
-
host: "127.0.0.1",
|
|
12
|
-
port: opts.port,
|
|
13
|
-
// Origin check — reject anything outside the allow list.
|
|
14
|
-
verifyClient: (info, cb) => {
|
|
15
|
-
const origin = info.origin ?? "";
|
|
16
|
-
if (opts.allowedOrigins.includes(origin))
|
|
17
|
-
return cb(true);
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.warn(`[aarmos] rejected origin: ${origin}`);
|
|
20
|
-
cb(false, 403, "origin not allowed");
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
wss.on("error", (err) => {
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
|
-
console.warn(`[aarmos] server error (continuing): ${err.message}`);
|
|
26
|
-
});
|
|
27
|
-
// Track live connection so we can reject concurrent duplicates while still
|
|
28
|
-
// allowing the developer to close a tab and re-open with the same pairing
|
|
29
|
-
// (e.g. browser crash, laptop lid). Token remains the shared secret; the
|
|
30
|
-
// localhost bind + origin allow-list are the real trust boundary.
|
|
31
|
-
let activeClient = null;
|
|
32
|
-
wss.on("connection", (ws, req) => {
|
|
33
|
-
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
34
|
-
const token = url.searchParams.get("token");
|
|
35
|
-
if (!token || token !== opts.pairingToken) {
|
|
36
|
-
ws.close(4401, "invalid pairing token");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (activeClient && activeClient.readyState === WebSocket.OPEN) {
|
|
40
|
-
ws.close(4409, "another client is already paired");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
activeClient = ws;
|
|
44
|
-
const session = createSession({
|
|
45
|
-
workspace: opts.workspace,
|
|
46
|
-
extraShellAllow: opts.extraShellAllow,
|
|
47
|
-
sqlAllow: opts.sqlAllow,
|
|
48
|
-
readAllow: opts.readAllow,
|
|
49
|
-
});
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.log("◆ PWA paired");
|
|
52
|
-
const send = (msg) => {
|
|
53
|
-
if (ws.readyState === WebSocket.OPEN) {
|
|
54
|
-
try {
|
|
55
|
-
ws.send(JSON.stringify(msg));
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
// eslint-disable-next-line no-console
|
|
59
|
-
console.warn(`[aarmos] send failed (client likely gone): ${err.message}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const stopFiles = startFileWatcher(session, (evt) => send({ type: "event", channel: "fs", event: evt }));
|
|
64
|
-
const stopGit = startGitWatcher(session, (evt) => send({ type: "event", channel: "git", event: evt }));
|
|
65
|
-
ws.on("message", async (raw) => {
|
|
66
|
-
let msg;
|
|
67
|
-
try {
|
|
68
|
-
msg = JSON.parse(String(raw));
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return send({ type: "error", error: "invalid json" });
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const res = await handleRpc(session, msg);
|
|
75
|
-
send(res);
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
// Never let an RPC handler bubble up and kill the process.
|
|
79
|
-
send({ type: "error", error: err.message });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
// Per-socket error handler — closed lids, killed tabs, and network
|
|
83
|
-
// resets all surface here. Log softly, let 'close' run cleanup.
|
|
84
|
-
ws.on("error", (err) => {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
|
-
console.warn(`[aarmos] socket error: ${err.message}`);
|
|
87
|
-
});
|
|
88
|
-
ws.on("close", (code, reason) => {
|
|
89
|
-
stopFiles();
|
|
90
|
-
stopGit();
|
|
91
|
-
if (activeClient === ws)
|
|
92
|
-
activeClient = null;
|
|
93
|
-
const why = reason?.toString() || `code ${code}`;
|
|
94
|
-
// eslint-disable-next-line no-console
|
|
95
|
-
console.log(`◇ Client disconnected (${why}). Standing by on ${opts.port} — rerun pairing from the PWA to reconnect.`);
|
|
96
|
-
});
|
|
97
|
-
send({
|
|
98
|
-
type: "hello",
|
|
99
|
-
workspace: opts.workspace,
|
|
100
|
-
capabilities: session.capabilities,
|
|
101
|
-
dryRun: session.dryRun,
|
|
102
|
-
protocol: "aarmos-bridge/1",
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
await new Promise((resolve) => wss.once("listening", () => resolve()));
|
|
106
|
-
const address = wss.address();
|
|
107
|
-
const boundPort = typeof address === "object" && address ? address.port : opts.port;
|
|
108
|
-
return { port: boundPort, url: `ws://127.0.0.1:${boundPort}` };
|
|
109
|
-
}
|
|
110
|
-
let guardsInstalled = false;
|
|
111
|
-
function installProcessGuards() {
|
|
112
|
-
if (guardsInstalled)
|
|
113
|
-
return;
|
|
114
|
-
guardsInstalled = true;
|
|
115
|
-
process.on("uncaughtException", (err) => {
|
|
116
|
-
// eslint-disable-next-line no-console
|
|
117
|
-
console.warn(`[aarmos] uncaughtException (kept alive): ${err.message}`);
|
|
118
|
-
});
|
|
119
|
-
process.on("unhandledRejection", (reason) => {
|
|
120
|
-
// eslint-disable-next-line no-console
|
|
121
|
-
console.warn(`[aarmos] unhandledRejection (kept alive): ${String(reason)}`);
|
|
122
|
-
});
|
|
123
|
-
process.on("SIGINT", () => {
|
|
124
|
-
// eslint-disable-next-line no-console
|
|
125
|
-
console.log("\n◇ Shutting down aarmos bridge. bye.");
|
|
126
|
-
process.exit(0);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=bridge.js.map
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
startBridge
|
|
4
|
+
} from "./chunk-GMH5B5YX.js";
|
|
5
|
+
export {
|
|
6
|
+
startBridge
|
|
7
|
+
};
|