@agentvault/muse-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/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @agentvault/muse-bridge
2
+
3
+ Bridges a [Muse](https://dev.meta.ai/) agent into E2E-encrypted AgentVault
4
+ direct messages and rooms.
5
+
6
+ **This package is a separate entity from `@agentvault/claude-bridge` and
7
+ `@agentvault/grok-bridge`.** They share no runtime code. The child is
8
+ `muse exec --json` (JSONL), not ACP.
9
+
10
+ ## Prerequisite
11
+
12
+ Install Muse Code and run `muse login` (or set `META_API_KEY`). The bridge
13
+ copies host `~/.config/muse/auth.json` into its fence once, at first run, and
14
+ never overwrites it.
15
+
16
+ ## First enroll
17
+
18
+ ```sh
19
+ AV_AGENT_NAME=<agent> AV_DATA_DIR="$HOME/.agentvault/muse-room-bridge/<slug>" \
20
+ AV_INVITE_TOKEN=<token> npx @agentvault/muse-bridge
21
+ ```
22
+
23
+ There is **no** `--install` flag. That race left other bridges mute; Muse never
24
+ grew it.
25
+
26
+ ## Supervised service (after enroll)
27
+
28
+ Credentials must already persist (`agentvault.json`). Then:
29
+
30
+ ```sh
31
+ npm i -g @agentvault/muse-bridge
32
+ AV_AGENT_NAME=<agent> agentvault-muse-bridge install
33
+ ```
34
+
35
+ `install` refuses an ephemeral `npx`/`dlx` entrypoint so launchd cannot bake a
36
+ pruned cache path.
37
+
38
+ ## Owner power
39
+
40
+ `--yolo` only when both Access grants are on (`workAllowed` and `gatesRemoved`).
41
+ Otherwise `--disable-shell` and `--disable-write` (no terminal, no file-tool
42
+ writes).
@@ -0,0 +1,83 @@
1
+ /** Muse-owned room/DM wiring. Owner power is two raw booleans from
2
+ * `arming_snapshot` (`=== true` only). Do not copy grok grant-trim.
3
+ * Do not call decideArming, host-trust, or osIsolated. */
4
+ import type { RoomSession } from "./muse-session.js";
5
+ export declare function workAllowed(): boolean;
6
+ export declare function gatesRemoved(): boolean;
7
+ export declare function resetOwnerPower(): void;
8
+ export interface RoomMessage {
9
+ roomId: string;
10
+ senderName: string;
11
+ plaintext: string;
12
+ senderIsAgent?: boolean;
13
+ }
14
+ export interface MessageMeta {
15
+ roomId?: string;
16
+ ownerDm1to1?: boolean;
17
+ }
18
+ export interface RoomHushed {
19
+ roomId: string;
20
+ hushedUntil: string | null;
21
+ }
22
+ export interface ArmingSnapshot {
23
+ workAllowed?: unknown;
24
+ gatesRemoved?: unknown;
25
+ }
26
+ export interface RoomChannel {
27
+ on(ev: "room_message", cb: (e: RoomMessage) => void): unknown;
28
+ on(ev: "room_joined", cb: (e: {
29
+ roomId: string;
30
+ name?: string;
31
+ }) => void): unknown;
32
+ on(ev: "message", cb: (text: string, metadata: MessageMeta) => void): unknown;
33
+ on(ev: "room_hushed", cb: (e: RoomHushed) => void): unknown;
34
+ on(ev: "arming_snapshot", cb: (e: ArmingSnapshot) => void): unknown;
35
+ on(ev: "error", cb: (err: unknown) => void): unknown;
36
+ on(ev: "ready", cb: () => void): unknown;
37
+ on(ev: "state", cb: (s: string) => void): unknown;
38
+ sendToRoom(roomId: string, text: string): Promise<void>;
39
+ send(text: string): Promise<void>;
40
+ }
41
+ export declare class RoomHushState {
42
+ private until;
43
+ set(roomId: string, hushedUntilIso: string | null): void;
44
+ isHushed(roomId: string, now?: number): boolean;
45
+ }
46
+ export type BridgeTarget = {
47
+ kind: "room";
48
+ roomId: string;
49
+ } | {
50
+ kind: "dm";
51
+ };
52
+ export interface ReplyChannel {
53
+ sendToRoom(roomId: string, text: string): Promise<void>;
54
+ send(text: string): Promise<void>;
55
+ }
56
+ export declare class ActiveTarget {
57
+ private target;
58
+ setRoom(roomId: string): void;
59
+ setDm(): void;
60
+ get current(): BridgeTarget | null;
61
+ snapshotReply(channel: ReplyChannel, log?: (msg: string) => void): (text: string) => Promise<void>;
62
+ }
63
+ export interface LifecycleChannel {
64
+ on(ev: "auth_failed", cb: (e: {
65
+ reason: string;
66
+ }) => void): unknown;
67
+ on(ev: "session_replaced", cb: (e: {
68
+ code?: number;
69
+ }) => void): unknown;
70
+ on(ev: "error", cb: (err: unknown) => void): unknown;
71
+ }
72
+ export declare function attachLifecycle(channel: LifecycleChannel, opts?: {
73
+ log?: (msg: string) => void;
74
+ onTerminal?: (reason: string, o: {
75
+ restart: boolean;
76
+ }) => void;
77
+ }): void;
78
+ export declare function roomTurnPrefix(roomId: string, senderName: string, roomName?: string): string;
79
+ export declare function wireBridge(channel: RoomChannel, session: RoomSession, target: ActiveTarget, opts?: {
80
+ roomFilter?: string;
81
+ log?: (msg: string) => void;
82
+ }): void;
83
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1,36 @@
1
+ export declare function hasPersistedCreds(dataDir: string): boolean;
2
+ export declare function slugify(name: string): string;
3
+ export interface BridgeConfig {
4
+ inviteToken: string;
5
+ dataDir: string;
6
+ agentName: string;
7
+ /** Per-agent filesystem sandbox. Sibling of dataDir unless AV_WORKSPACE_DIR. */
8
+ workspaceDir: string;
9
+ /** Absolute path to the muse binary, or the PATH name "muse". */
10
+ musePath: string;
11
+ /** The agent's fenced HOME. Defaults to <dataDir>/fence. This is Muse HOME. */
12
+ fenceHome: string;
13
+ /** Meta key forwarded to the muse child as META_API_KEY. Never logged. */
14
+ apiKey?: string;
15
+ /** process HOME — seed source for fence auth.json only, never Muse HOME. */
16
+ hostHome: string;
17
+ /** Backend API. Same default as grok-bridge. */
18
+ apiUrl: string;
19
+ }
20
+ export declare const VERSION_FLAGS: readonly ["--version", "-v"];
21
+ export declare const HELP_FLAGS: readonly ["--help", "-h"];
22
+ /** Pure argv read. Independent of loadConfig so `--version` needs no token. */
23
+ export declare function parseInfoFlags(argv: string[]): {
24
+ showVersion: boolean;
25
+ showHelp: boolean;
26
+ };
27
+ /**
28
+ * Package-manager scratch caches. `service/subcommand.ts` bakes `process.argv[1]`
29
+ * into the launcher, so a service installed from one of these dies when the
30
+ * cache is pruned.
31
+ */
32
+ export declare function isEphemeralEntrypoint(entrypoint: string): boolean;
33
+ /** Throw unless `entrypoint` is durable enough to bake into a supervised service. */
34
+ export declare function assertInstallableEntrypoint(entrypoint: string): void;
35
+ export declare function loadConfig(env: NodeJS.ProcessEnv, argv?: string[]): BridgeConfig;
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,14 @@
1
+ export type SeedResult = "seeded" | "already-present" | "no-host-credential";
2
+ /**
3
+ * Copy the host's Muse credential into the agent's fence, ONCE.
4
+ *
5
+ * Copies auth.json alone — never host settings.json, skills, or trust.json.
6
+ * Never overwrite an existing fence credential (a fenced child refreshes its
7
+ * own token in place). Never log file contents.
8
+ */
9
+ export declare function seedFenceCredential(opts: {
10
+ fenceHome: string;
11
+ hostHome: string;
12
+ log?: (m: string) => void;
13
+ }): SeedResult;
14
+ //# sourceMappingURL=fence-auth.d.ts.map
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { type BridgeConfig } from "./config.js";
3
+ import { MuseSession } from "./muse-session.js";
4
+ import { MuseDriver, type MuseSpawnFn } from "./muse-driver.js";
5
+ import { type RoomMcpServer } from "./muse-room-http.js";
6
+ import { type LifecycleChannel, type RoomChannel } from "./bridge.js";
7
+ import type { ServiceBackend } from "./service/backend.js";
8
+ export type BootChannel = RoomChannel & LifecycleChannel & {
9
+ start(): Promise<void>;
10
+ stop(): Promise<void>;
11
+ };
12
+ export interface MainOpts {
13
+ env?: NodeJS.ProcessEnv;
14
+ argv?: string[];
15
+ spawnFn?: MuseSpawnFn;
16
+ path?: string;
17
+ createChannel?: (opts: {
18
+ inviteToken: string;
19
+ dataDir: string;
20
+ apiUrl: string;
21
+ agentName: string;
22
+ platform: string;
23
+ clientVersion: string;
24
+ }) => BootChannel;
25
+ exit?: (code: number) => void;
26
+ backend?: ServiceBackend;
27
+ entrypoint?: string;
28
+ }
29
+ export interface MainHandle {
30
+ driver: MuseDriver;
31
+ session: MuseSession;
32
+ mcp: RoomMcpServer;
33
+ cfg: BridgeConfig;
34
+ shutdown: (code?: number) => Promise<void>;
35
+ shuttingDown: () => boolean;
36
+ }
37
+ export declare function main(opts?: MainOpts): Promise<MainHandle | undefined>;
38
+ //# sourceMappingURL=index.d.ts.map