@bondsmith/bondsmithd 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/index.js +15 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -951,7 +951,7 @@ import { sign } from "crypto";
|
|
|
951
951
|
import WebSocket from "ws";
|
|
952
952
|
|
|
953
953
|
// src/version.ts
|
|
954
|
-
var DAEMON_VERSION = true ? "0.1.
|
|
954
|
+
var DAEMON_VERSION = true ? "0.1.5" : "dev";
|
|
955
955
|
var VERSION_FLAGS = ["--version", "-v"];
|
|
956
956
|
function versionLine() {
|
|
957
957
|
return `bondsmithd ${DAEMON_VERSION} (protocol ${PROTOCOL_VERSION})`;
|
|
@@ -1378,9 +1378,12 @@ function error(message, requestId) {
|
|
|
1378
1378
|
function errorMessageOf(err, fallback) {
|
|
1379
1379
|
return err instanceof Error ? err.message : fallback;
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1381
|
+
function requestIdOf(message) {
|
|
1382
|
+
return "requestId" in message ? message.requestId : void 0;
|
|
1383
|
+
}
|
|
1384
|
+
function getSessionOrError(sessionManager, conn, sessionId, requestId) {
|
|
1382
1385
|
const session = sessionManager.get(sessionId);
|
|
1383
|
-
if (!session) conn.send(error("unknown session"));
|
|
1386
|
+
if (!session) conn.send(error("unknown session", requestId));
|
|
1384
1387
|
return session;
|
|
1385
1388
|
}
|
|
1386
1389
|
async function handleBrowserMessage(conn, raw, deps) {
|
|
@@ -1400,11 +1403,11 @@ async function handleBrowserMessage(conn, raw, deps) {
|
|
|
1400
1403
|
deps.trustedControllersPath
|
|
1401
1404
|
);
|
|
1402
1405
|
if (!verdict.ok) {
|
|
1403
|
-
conn.send(error(verifyRejectionMessage(verdict.reason)));
|
|
1406
|
+
conn.send(error(verifyRejectionMessage(verdict.reason), requestIdOf(innerMessage.data)));
|
|
1404
1407
|
return false;
|
|
1405
1408
|
}
|
|
1406
1409
|
if (conn.connectionAuth.isRevoked()) {
|
|
1407
|
-
conn.send(error(REVOKED_REJECTION_MESSAGE));
|
|
1410
|
+
conn.send(error(REVOKED_REJECTION_MESSAGE, requestIdOf(innerMessage.data)));
|
|
1408
1411
|
return false;
|
|
1409
1412
|
}
|
|
1410
1413
|
return true;
|
|
@@ -1432,7 +1435,7 @@ async function handleBrowserMessage(conn, raw, deps) {
|
|
|
1432
1435
|
return;
|
|
1433
1436
|
}
|
|
1434
1437
|
if (isSignableAction(parsed.data.type)) {
|
|
1435
|
-
conn.send(error("signature required for this command"));
|
|
1438
|
+
conn.send(error("signature required for this command", requestIdOf(parsed.data)));
|
|
1436
1439
|
return;
|
|
1437
1440
|
}
|
|
1438
1441
|
await dispatch(conn, parsed.data, deps);
|
|
@@ -1571,7 +1574,7 @@ async function dispatch(conn, message, {
|
|
|
1571
1574
|
return;
|
|
1572
1575
|
}
|
|
1573
1576
|
case "workspace.getStatus": {
|
|
1574
|
-
const session = getSessionOrError(sessionManager, conn, message.sessionId);
|
|
1577
|
+
const session = getSessionOrError(sessionManager, conn, message.sessionId, message.requestId);
|
|
1575
1578
|
if (!session) return;
|
|
1576
1579
|
try {
|
|
1577
1580
|
const status = await getWorkspaceStatus2(session.cwd);
|
|
@@ -1582,12 +1585,12 @@ async function dispatch(conn, message, {
|
|
|
1582
1585
|
status
|
|
1583
1586
|
});
|
|
1584
1587
|
} catch (err) {
|
|
1585
|
-
conn.send(error(errorMessageOf(err, "failed to read workspace status")));
|
|
1588
|
+
conn.send(error(errorMessageOf(err, "failed to read workspace status"), message.requestId));
|
|
1586
1589
|
}
|
|
1587
1590
|
return;
|
|
1588
1591
|
}
|
|
1589
1592
|
case "workspace.getDiff": {
|
|
1590
|
-
const session = getSessionOrError(sessionManager, conn, message.sessionId);
|
|
1593
|
+
const session = getSessionOrError(sessionManager, conn, message.sessionId, message.requestId);
|
|
1591
1594
|
if (!session) return;
|
|
1592
1595
|
try {
|
|
1593
1596
|
const diff = await getWorkspaceDiff2(session.cwd, message.path, message.staged);
|
|
@@ -1598,7 +1601,7 @@ async function dispatch(conn, message, {
|
|
|
1598
1601
|
diff
|
|
1599
1602
|
});
|
|
1600
1603
|
} catch (err) {
|
|
1601
|
-
conn.send(error(errorMessageOf(err, "failed to read workspace diff")));
|
|
1604
|
+
conn.send(error(errorMessageOf(err, "failed to read workspace diff"), message.requestId));
|
|
1602
1605
|
}
|
|
1603
1606
|
return;
|
|
1604
1607
|
}
|
|
@@ -2814,7 +2817,7 @@ ${new TmuxNotFoundError().message}
|
|
|
2814
2817
|
}
|
|
2815
2818
|
return false;
|
|
2816
2819
|
}
|
|
2817
|
-
const created = { process: ptyProcess,
|
|
2820
|
+
const created = { process: ptyProcess, dataListeners: /* @__PURE__ */ new Set([onData]) };
|
|
2818
2821
|
this.handles.set(sessionId, created);
|
|
2819
2822
|
ptyProcess.onData((data) => {
|
|
2820
2823
|
for (const listener of created.dataListeners) listener(data);
|
|
@@ -2822,12 +2825,9 @@ ${new TmuxNotFoundError().message}
|
|
|
2822
2825
|
ptyProcess.onExit(() => {
|
|
2823
2826
|
if (this.handles.get(sessionId) === created) this.handles.delete(sessionId);
|
|
2824
2827
|
});
|
|
2825
|
-
created.refCount += 1;
|
|
2826
|
-
created.dataListeners.add(onData);
|
|
2827
2828
|
return true;
|
|
2828
2829
|
}
|
|
2829
2830
|
await this.sendPaneSnapshot(tmuxSessionName, onData);
|
|
2830
|
-
handle.refCount += 1;
|
|
2831
2831
|
handle.dataListeners.add(onData);
|
|
2832
2832
|
return true;
|
|
2833
2833
|
}
|
|
@@ -2854,8 +2854,7 @@ ${new TmuxNotFoundError().message}
|
|
|
2854
2854
|
release(sessionId, onData) {
|
|
2855
2855
|
const handle = this.handles.get(sessionId);
|
|
2856
2856
|
if (!handle?.dataListeners.delete(onData)) return;
|
|
2857
|
-
handle.
|
|
2858
|
-
if (handle.refCount <= 0) {
|
|
2857
|
+
if (handle.dataListeners.size === 0) {
|
|
2859
2858
|
handle.process.kill();
|
|
2860
2859
|
this.handles.delete(sessionId);
|
|
2861
2860
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bondsmith/bondsmithd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Local daemon for Bondsmith agent sessions — runs on the user's own machine, pairs with a Bondsmith account, and exposes tmux-backed terminal sessions to the Bondsmith web app over a signed WebSocket protocol.",
|
|
6
6
|
"homepage": "https://bondsmith.dev",
|