@securecoms/agent-bridge 0.3.1 → 0.3.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/bin.js +65 -57
- package/dist/bridge-agent.d.ts +1 -1
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -3395,8 +3395,59 @@ var SqliteMlsStateStore = class {
|
|
|
3395
3395
|
|
|
3396
3396
|
// src/bridge-agent.ts
|
|
3397
3397
|
import { decryptFile, encryptFile, computeFileDigest, base64ToBytes as base64ToBytes2, bytesToBase64 as bytesToBase642 } from "@agentvault/crypto";
|
|
3398
|
-
|
|
3398
|
+
|
|
3399
|
+
// src/service/resolve-bin.ts
|
|
3399
3400
|
import { join as join2, dirname as dirname2 } from "node:path";
|
|
3401
|
+
import { createRequire } from "node:module";
|
|
3402
|
+
var GlobalInstallPermissionError = class extends Error {
|
|
3403
|
+
constructor(message) {
|
|
3404
|
+
super(message);
|
|
3405
|
+
this.name = "GlobalInstallPermissionError";
|
|
3406
|
+
}
|
|
3407
|
+
};
|
|
3408
|
+
function isEphemeralPath(p) {
|
|
3409
|
+
return /[\\/]_npx[\\/]/.test(p);
|
|
3410
|
+
}
|
|
3411
|
+
function refersToSameFile(a, b, realpath) {
|
|
3412
|
+
if (a === b) return true;
|
|
3413
|
+
try {
|
|
3414
|
+
return realpath(a) === realpath(b);
|
|
3415
|
+
} catch {
|
|
3416
|
+
return false;
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
function resolveStableBinScript(input, deps) {
|
|
3420
|
+
const ephemeral = isEphemeralPath(input.binScript);
|
|
3421
|
+
if (!ephemeral) {
|
|
3422
|
+
if (deps.fileExists(input.binScript)) return input.binScript;
|
|
3423
|
+
throw new Error(`bin path does not exist and is not an npx cache path: ${input.binScript}`);
|
|
3424
|
+
}
|
|
3425
|
+
const pkgRoot = dirname2(dirname2(input.binScript));
|
|
3426
|
+
const inst = deps.run("npm", ["i", "-g", pkgRoot, "--install-links"]);
|
|
3427
|
+
if (inst.status !== 0) {
|
|
3428
|
+
if (/EACCES|permission denied/i.test(inst.stderr)) {
|
|
3429
|
+
throw new GlobalInstallPermissionError(
|
|
3430
|
+
`Can't write the global npm prefix. Run this once, then re-run install:
|
|
3431
|
+
npm i -g ${input.packageName}`
|
|
3432
|
+
);
|
|
3433
|
+
}
|
|
3434
|
+
throw new Error(`npm i -g ${pkgRoot} failed (exit ${inst.status})${inst.stderr ? `: ${inst.stderr.trim()}` : ""}`);
|
|
3435
|
+
}
|
|
3436
|
+
const root = deps.run("npm", ["root", "-g"]);
|
|
3437
|
+
if (root.status !== 0) throw new Error(`npm root -g failed (exit ${root.status})`);
|
|
3438
|
+
const stable = join2(root.stdout.trim(), input.packageName, "dist", "bin.js");
|
|
3439
|
+
if (!deps.fileExists(stable)) throw new Error(`global install did not produce ${stable}`);
|
|
3440
|
+
return stable;
|
|
3441
|
+
}
|
|
3442
|
+
function loadPackageMeta(importMetaUrl) {
|
|
3443
|
+
const require2 = createRequire(importMetaUrl);
|
|
3444
|
+
const pkg = require2("../package.json");
|
|
3445
|
+
return { name: pkg.name, version: pkg.version };
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
// src/bridge-agent.ts
|
|
3449
|
+
import { promises as fsp } from "node:fs";
|
|
3450
|
+
import { join as join3, dirname as dirname3 } from "node:path";
|
|
3400
3451
|
|
|
3401
3452
|
// src/latency.ts
|
|
3402
3453
|
var DEFAULT_CAPACITY = 1024;
|
|
@@ -3729,7 +3780,13 @@ var UnknownActionRunError = class extends Error {
|
|
|
3729
3780
|
this.name = "UnknownActionRunError";
|
|
3730
3781
|
}
|
|
3731
3782
|
};
|
|
3732
|
-
var BRIDGE_VERSION =
|
|
3783
|
+
var BRIDGE_VERSION = (() => {
|
|
3784
|
+
try {
|
|
3785
|
+
return loadPackageMeta(import.meta.url).version;
|
|
3786
|
+
} catch {
|
|
3787
|
+
return "0.0.0";
|
|
3788
|
+
}
|
|
3789
|
+
})();
|
|
3733
3790
|
function hexToBytes4(h) {
|
|
3734
3791
|
return new Uint8Array(Buffer.from(h, "hex"));
|
|
3735
3792
|
}
|
|
@@ -3834,7 +3891,7 @@ var BridgeAgent = class _BridgeAgent {
|
|
|
3834
3891
|
const j = await res.json();
|
|
3835
3892
|
return String(j.attachment_id);
|
|
3836
3893
|
};
|
|
3837
|
-
this.attachmentsDirImpl = deps.attachmentsDir ??
|
|
3894
|
+
this.attachmentsDirImpl = deps.attachmentsDir ?? join3(dirname3(cfg.storePath), "attachments");
|
|
3838
3895
|
this.action = {
|
|
3839
3896
|
begin: (channelId) => this.actionBegin(channelId),
|
|
3840
3897
|
start: (opts) => this.actionStart(opts),
|
|
@@ -5579,7 +5636,7 @@ import { homedir, userInfo } from "node:os";
|
|
|
5579
5636
|
import { spawnSync } from "node:child_process";
|
|
5580
5637
|
|
|
5581
5638
|
// src/service/install.ts
|
|
5582
|
-
import { dirname as
|
|
5639
|
+
import { dirname as dirname4 } from "node:path";
|
|
5583
5640
|
|
|
5584
5641
|
// src/service/config.ts
|
|
5585
5642
|
import { basename as basename2, extname, isAbsolute, resolve } from "node:path";
|
|
@@ -5663,7 +5720,7 @@ WantedBy=default.target
|
|
|
5663
5720
|
var ServiceUnsupportedError = class extends Error {
|
|
5664
5721
|
};
|
|
5665
5722
|
function tokenHint(input) {
|
|
5666
|
-
return `${
|
|
5723
|
+
return `${dirname4(input.credentialPath)}/bridge-token`;
|
|
5667
5724
|
}
|
|
5668
5725
|
function requireOk(r, what) {
|
|
5669
5726
|
if (r.status !== 0) throw new Error(`${what} failed (exit ${r.status})${r.stderr ? `: ${r.stderr.trim()}` : ""}`);
|
|
@@ -5671,8 +5728,8 @@ function requireOk(r, what) {
|
|
|
5671
5728
|
function installService(input, deps) {
|
|
5672
5729
|
const cfg = deriveServiceConfig(input);
|
|
5673
5730
|
if (deps.platform === "darwin") {
|
|
5674
|
-
deps.mkdirp(
|
|
5675
|
-
deps.mkdirp(
|
|
5731
|
+
deps.mkdirp(dirname4(cfg.plistPath));
|
|
5732
|
+
deps.mkdirp(dirname4(cfg.logPath));
|
|
5676
5733
|
deps.writeFile(cfg.plistPath, renderLaunchdPlist(cfg));
|
|
5677
5734
|
deps.run("launchctl", ["bootout", `gui/${cfg.uid}/${cfg.label}`]);
|
|
5678
5735
|
requireOk(deps.run("launchctl", ["bootstrap", `gui/${cfg.uid}`, cfg.plistPath]), "launchctl bootstrap");
|
|
@@ -5681,7 +5738,7 @@ function installService(input, deps) {
|
|
|
5681
5738
|
return { label: cfg.label, filePath: cfg.plistPath, logHint: cfg.logPath, tokenHint: tokenHint(input) };
|
|
5682
5739
|
}
|
|
5683
5740
|
if (deps.platform === "linux") {
|
|
5684
|
-
deps.mkdirp(
|
|
5741
|
+
deps.mkdirp(dirname4(cfg.unitPath));
|
|
5685
5742
|
deps.writeFile(cfg.unitPath, renderSystemdUnit(cfg));
|
|
5686
5743
|
deps.run("systemctl", ["--user", "daemon-reload"]);
|
|
5687
5744
|
deps.run("loginctl", ["enable-linger", deps.user]);
|
|
@@ -5708,55 +5765,6 @@ function uninstallService(input, deps) {
|
|
|
5708
5765
|
throw new ServiceUnsupportedError(`Service uninstall isn't supported on ${deps.platform} yet.`);
|
|
5709
5766
|
}
|
|
5710
5767
|
|
|
5711
|
-
// src/service/resolve-bin.ts
|
|
5712
|
-
import { join as join3, dirname as dirname4 } from "node:path";
|
|
5713
|
-
import { createRequire } from "node:module";
|
|
5714
|
-
var GlobalInstallPermissionError = class extends Error {
|
|
5715
|
-
constructor(message) {
|
|
5716
|
-
super(message);
|
|
5717
|
-
this.name = "GlobalInstallPermissionError";
|
|
5718
|
-
}
|
|
5719
|
-
};
|
|
5720
|
-
function isEphemeralPath(p) {
|
|
5721
|
-
return /[\\/]_npx[\\/]/.test(p);
|
|
5722
|
-
}
|
|
5723
|
-
function refersToSameFile(a, b, realpath) {
|
|
5724
|
-
if (a === b) return true;
|
|
5725
|
-
try {
|
|
5726
|
-
return realpath(a) === realpath(b);
|
|
5727
|
-
} catch {
|
|
5728
|
-
return false;
|
|
5729
|
-
}
|
|
5730
|
-
}
|
|
5731
|
-
function resolveStableBinScript(input, deps) {
|
|
5732
|
-
const ephemeral = isEphemeralPath(input.binScript);
|
|
5733
|
-
if (!ephemeral) {
|
|
5734
|
-
if (deps.fileExists(input.binScript)) return input.binScript;
|
|
5735
|
-
throw new Error(`bin path does not exist and is not an npx cache path: ${input.binScript}`);
|
|
5736
|
-
}
|
|
5737
|
-
const pkgRoot = dirname4(dirname4(input.binScript));
|
|
5738
|
-
const inst = deps.run("npm", ["i", "-g", pkgRoot, "--install-links"]);
|
|
5739
|
-
if (inst.status !== 0) {
|
|
5740
|
-
if (/EACCES|permission denied/i.test(inst.stderr)) {
|
|
5741
|
-
throw new GlobalInstallPermissionError(
|
|
5742
|
-
`Can't write the global npm prefix. Run this once, then re-run install:
|
|
5743
|
-
npm i -g ${input.packageName}`
|
|
5744
|
-
);
|
|
5745
|
-
}
|
|
5746
|
-
throw new Error(`npm i -g ${pkgRoot} failed (exit ${inst.status})${inst.stderr ? `: ${inst.stderr.trim()}` : ""}`);
|
|
5747
|
-
}
|
|
5748
|
-
const root = deps.run("npm", ["root", "-g"]);
|
|
5749
|
-
if (root.status !== 0) throw new Error(`npm root -g failed (exit ${root.status})`);
|
|
5750
|
-
const stable = join3(root.stdout.trim(), input.packageName, "dist", "bin.js");
|
|
5751
|
-
if (!deps.fileExists(stable)) throw new Error(`global install did not produce ${stable}`);
|
|
5752
|
-
return stable;
|
|
5753
|
-
}
|
|
5754
|
-
function loadPackageMeta(importMetaUrl) {
|
|
5755
|
-
const require2 = createRequire(importMetaUrl);
|
|
5756
|
-
const pkg = require2("../package.json");
|
|
5757
|
-
return { name: pkg.name, version: pkg.version };
|
|
5758
|
-
}
|
|
5759
|
-
|
|
5760
5768
|
// src/bin.ts
|
|
5761
5769
|
function nodeMajorOk(version) {
|
|
5762
5770
|
return Number(version.split(".")[0]) >= 24;
|
package/dist/bridge-agent.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export interface AgentActionAPI {
|
|
|
170
170
|
/** Auto-capture helper: start a node, run `fn`, finish it done/error from the outcome. */
|
|
171
171
|
wrap<T>(runId: string, fn: () => T | Promise<T>, opts: AgentActionWrapOpts): Promise<T>;
|
|
172
172
|
}
|
|
173
|
-
export declare const BRIDGE_VERSION
|
|
173
|
+
export declare const BRIDGE_VERSION: string;
|
|
174
174
|
export declare class BridgeAgent {
|
|
175
175
|
private readonly cfg;
|
|
176
176
|
private readonly transport;
|
package/dist/index.js
CHANGED
|
@@ -3323,6 +3323,16 @@ var SqliteMlsStateStore = class {
|
|
|
3323
3323
|
|
|
3324
3324
|
// src/bridge-agent.ts
|
|
3325
3325
|
import { decryptFile, encryptFile, computeFileDigest, base64ToBytes as base64ToBytes2, bytesToBase64 as bytesToBase642 } from "@agentvault/crypto";
|
|
3326
|
+
|
|
3327
|
+
// src/service/resolve-bin.ts
|
|
3328
|
+
import { createRequire } from "node:module";
|
|
3329
|
+
function loadPackageMeta(importMetaUrl) {
|
|
3330
|
+
const require2 = createRequire(importMetaUrl);
|
|
3331
|
+
const pkg = require2("../package.json");
|
|
3332
|
+
return { name: pkg.name, version: pkg.version };
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
// src/bridge-agent.ts
|
|
3326
3336
|
import { promises as fsp } from "node:fs";
|
|
3327
3337
|
import { join, dirname } from "node:path";
|
|
3328
3338
|
|
|
@@ -3657,7 +3667,13 @@ var UnknownActionRunError = class extends Error {
|
|
|
3657
3667
|
this.name = "UnknownActionRunError";
|
|
3658
3668
|
}
|
|
3659
3669
|
};
|
|
3660
|
-
var BRIDGE_VERSION =
|
|
3670
|
+
var BRIDGE_VERSION = (() => {
|
|
3671
|
+
try {
|
|
3672
|
+
return loadPackageMeta(import.meta.url).version;
|
|
3673
|
+
} catch {
|
|
3674
|
+
return "0.0.0";
|
|
3675
|
+
}
|
|
3676
|
+
})();
|
|
3661
3677
|
function hexToBytes4(h) {
|
|
3662
3678
|
return new Uint8Array(Buffer.from(h, "hex"));
|
|
3663
3679
|
}
|