@agentvault/grok-bridge 0.1.0

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/log.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Prefix every line of `message` with an ISO-8601 UTC timestamp.
3
+ *
4
+ * Per-LINE, not per-call, on purpose: `logLine("[bridge] fatal:", err)` renders a
5
+ * multi-line stack trace, and a first-line-only stamp would leave every frame
6
+ * unanchored — the case where the clock matters most. The acceptance criterion
7
+ * on #790 is "every line in the file", so this reads it literally.
8
+ */
9
+ export declare function stamp(message: string): string;
10
+ /**
11
+ * Write one stamped record to stderr.
12
+ *
13
+ * stderr (not stdout) because the launchd/systemd unit routes both, and the
14
+ * bridge's existing sinks were already `console.error` — keeping the stream the
15
+ * same means this change alters the CONTENT of the logs and nothing else.
16
+ *
17
+ * Multi-arg is supported via `util.format`, which is what `console.error` uses
18
+ * internally, so `logLine("[bridge] fatal:", err)` renders exactly as before —
19
+ * just anchored to a clock.
20
+ */
21
+ export declare function logLine(...args: unknown[]): void;
22
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1,29 @@
1
+ import type { ServiceSpec } from "./spec.js";
2
+ export interface ServiceBackend {
3
+ install(spec: ServiceSpec): void;
4
+ uninstall(label: string): void;
5
+ /** Restart an ALREADY-INSTALLED service without touching its spec (#837).
6
+ * Distinct from install, which re-bakes the plist from the current shell. */
7
+ restart(label: string): void;
8
+ status(label: string): {
9
+ loaded: boolean;
10
+ detail: string;
11
+ };
12
+ }
13
+ export interface BackendDeps {
14
+ home: string;
15
+ uid: number;
16
+ user: string;
17
+ exec: (cmd: string, args: string[]) => {
18
+ code: number;
19
+ stdout: string;
20
+ };
21
+ writeFile: (path: string, data: string) => void;
22
+ mkdir: (path: string) => void;
23
+ chmod: (path: string, mode: number) => void;
24
+ rm: (path: string) => void;
25
+ exists: (path: string) => boolean;
26
+ }
27
+ export declare function defaultDeps(): BackendDeps;
28
+ export declare function selectBackend(platform: NodeJS.Platform, deps?: BackendDeps): ServiceBackend;
29
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/service/backend.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;kFAC8E;IAC9E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACnC;AAED,wBAAgB,WAAW,IAAI,WAAW,CAoBzC;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,cAAc,CAU3F"}
@@ -0,0 +1,21 @@
1
+ import type { ServiceSpec } from "./spec.js";
2
+ import type { BackendDeps, ServiceBackend } from "./backend.js";
3
+ /** Render a launchd LaunchAgent plist for a bridge ServiceSpec. Pure string. */
4
+ export declare function renderLaunchdPlist(spec: ServiceSpec): string;
5
+ export declare class LaunchdBackend implements ServiceBackend {
6
+ private deps;
7
+ constructor(deps: BackendDeps);
8
+ private plistPath;
9
+ private domain;
10
+ install(spec: ServiceSpec): void;
11
+ private waitUntilGone;
12
+ /** #837: restart in place. Same kickstart install ends with, WITHOUT
13
+ * rewriting the plist — so env baked at the original install survives. */
14
+ restart(label: string): void;
15
+ uninstall(label: string): void;
16
+ status(label: string): {
17
+ loaded: boolean;
18
+ detail: string;
19
+ };
20
+ }
21
+ //# sourceMappingURL=launchd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launchd.d.ts","sourceRoot":"","sources":["../../src/service/launchd.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUhE,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAkC5D;AAED,qBAAa,cAAe,YAAW,cAAc;IACvC,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,WAAW;IAErC,OAAO,CAAC,SAAS;IAGjB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IA2BhC,OAAO,CAAC,aAAa;IAOrB;+EAC2E;IAC3E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI5B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM9B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAI3D"}
@@ -0,0 +1,16 @@
1
+ import type { ServiceSpec } from "./spec.js";
2
+ import type { BackendDeps } from "./backend.js";
3
+ export declare const FALLBACK_NODES: string[];
4
+ /** Render the bash launcher the service actually execs. Pure string. It prepends
5
+ * the install-time PATH, then execs the first resolvable node with the bundle
6
+ * entrypoint. If NO node is found it exits 0 (terminal — never a restart-loop,
7
+ * same philosophy as auth-failure) after logging a re-install hint. */
8
+ export declare function renderLauncher(opts: {
9
+ installPath: string;
10
+ entrypoint: string;
11
+ fallbacks?: string[];
12
+ }): string;
13
+ /** Write the launcher executable (0755) into the data-dir before the backend
14
+ * points the service at it. Shared by both platform backends. */
15
+ export declare function writeLauncher(deps: BackendDeps, spec: ServiceSpec): void;
16
+ //# sourceMappingURL=launcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../../src/service/launcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,eAAO,MAAM,cAAc,UAO1B,CAAC;AAcF;;;wEAGwE;AACxE,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,GAAG,MAAM,CAoBT;AAED;kEACkE;AAClE,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAIxE"}
@@ -0,0 +1,20 @@
1
+ import type { BridgeConfig } from "../config.js";
2
+ export interface ServiceSpec {
3
+ label: string;
4
+ programArgs: string[];
5
+ launcherPath: string;
6
+ launcherScript: string;
7
+ env: Record<string, string>;
8
+ workingDir: string;
9
+ logOut: string;
10
+ logErr: string;
11
+ keepAliveUnlessCleanExit: boolean;
12
+ runAtLoad: boolean;
13
+ }
14
+ export interface BuildSpecOptions {
15
+ entrypoint: string;
16
+ home: string;
17
+ path: string;
18
+ }
19
+ export declare function buildServiceSpec(cfg: BridgeConfig, opts: BuildSpecOptions): ServiceSpec;
20
+ //# sourceMappingURL=spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/service/spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,GAAG,WAAW,CAyBvF"}
@@ -0,0 +1,11 @@
1
+ import { type ServiceBackend } from "./backend.js";
2
+ export interface ServiceCmdDeps {
3
+ backend?: ServiceBackend;
4
+ entrypoint?: string;
5
+ log?: (msg: string) => void;
6
+ }
7
+ /** Handle `agentvault-grok-bridge <install|uninstall|status|logs>` before boot.
8
+ * Returns true when handled (caller should exit). Secrets are never placed on
9
+ * the service command line — config flows via the plist env; the token is omitted. */
10
+ export declare function maybeRunServiceSubcommand(argv: string[], env: NodeJS.ProcessEnv, deps?: ServiceCmdDeps): boolean;
11
+ //# sourceMappingURL=subcommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAQD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CA4DT"}
@@ -0,0 +1,22 @@
1
+ import type { ServiceSpec } from "./spec.js";
2
+ import type { BackendDeps, ServiceBackend } from "./backend.js";
3
+ /** Render a systemd --user service unit for a bridge ServiceSpec. Pure string.
4
+ * Restart=on-failure + SuccessExitStatus=0 is the KeepAlive={SuccessfulExit:false}
5
+ * equivalent: a clean exit(0) (revoked device) is treated as success => NOT
6
+ * restarted; a non-zero crash is restarted. WantedBy=default.target is RunAtLoad. */
7
+ export declare function renderSystemdUnit(spec: ServiceSpec): string;
8
+ export declare class SystemdBackend implements ServiceBackend {
9
+ private deps;
10
+ constructor(deps: BackendDeps);
11
+ private unitPath;
12
+ install(spec: ServiceSpec): void;
13
+ /** #837: restart in place, without daemon-reload or rewriting the unit —
14
+ * so env written at the original install survives. */
15
+ restart(label: string): void;
16
+ uninstall(label: string): void;
17
+ status(label: string): {
18
+ loaded: boolean;
19
+ detail: string;
20
+ };
21
+ }
22
+ //# sourceMappingURL=systemd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemd.d.ts","sourceRoot":"","sources":["../../src/service/systemd.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmBhE;;;sFAGsF;AACtF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAsB3D;AAED,qBAAa,cAAe,YAAW,cAAc;IACvC,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,WAAW;IAErC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAoBhC;2DACuD;IACvD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI5B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAU9B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAQ3D"}
@@ -0,0 +1,7 @@
1
+ /** #836: identify the BRIDGE the operator installed, not the plugin it vendors.
2
+ *
3
+ * This lives in its own module on purpose: `index.ts` runs `main()` at module
4
+ * scope, so importing it from a test would spawn the real grok binary and open
5
+ * a SecureChannel during the test run. */
6
+ export declare function buildClientVersion(version: string | undefined): string;
7
+ //# sourceMappingURL=version.d.ts.map
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@agentvault/grok-bridge",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "AgentVault Grok Bridge — daemon bridging a Grok agent into E2E-encrypted AgentVault direct messages and rooms.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": { "agentvault-grok-bridge": "dist/index.js" },
9
+ "engines": { "node": ">=18" },
10
+ "files": ["dist", "README.md", "!dist/*.map"],
11
+ "scripts": {
12
+ "build": "npm --prefix ../plugin run build && tsc --emitDeclarationOnly && node build.mjs",
13
+ "start": "node dist/index.js",
14
+ "test": "vitest run",
15
+ "gate:mac": "RUN_MAC_GATE=1 vitest run src/__tests__/sandbox-gate.mac.test.ts",
16
+ "typecheck": "tsc -p tsconfig.test.json",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "dependencies": { "ws": "^8.16.0", "zod": "^4.3.6" },
20
+ "devDependencies": {
21
+ "@agentvault/agentvault": "file:../plugin",
22
+ "esbuild": "^0.27.3",
23
+ "typescript": "^5.4.0",
24
+ "vitest": "^2.0.0",
25
+ "@types/node": "^20.0.0"
26
+ },
27
+ "publishConfig": { "access": "public" },
28
+ "license": "MIT"
29
+ }