@voxagent/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.
Files changed (70) hide show
  1. package/README.md +74 -0
  2. package/dist/audio/source.d.ts +23 -0
  3. package/dist/audio/source.d.ts.map +1 -0
  4. package/dist/audio/source.js +69 -0
  5. package/dist/audio/source.js.map +1 -0
  6. package/dist/cli.d.ts +13 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +171 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/config.d.ts +62 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +102 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/drivers/claude.d.ts +36 -0
  15. package/dist/drivers/claude.d.ts.map +1 -0
  16. package/dist/drivers/claude.js +445 -0
  17. package/dist/drivers/claude.js.map +1 -0
  18. package/dist/drivers/codex.d.ts +56 -0
  19. package/dist/drivers/codex.d.ts.map +1 -0
  20. package/dist/drivers/codex.js +652 -0
  21. package/dist/drivers/codex.js.map +1 -0
  22. package/dist/drivers/index.d.ts +34 -0
  23. package/dist/drivers/index.d.ts.map +1 -0
  24. package/dist/drivers/index.js +18 -0
  25. package/dist/drivers/index.js.map +1 -0
  26. package/dist/drivers/types.d.ts +81 -0
  27. package/dist/drivers/types.d.ts.map +1 -0
  28. package/dist/drivers/types.js +11 -0
  29. package/dist/drivers/types.js.map +1 -0
  30. package/dist/index.d.ts +6 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +5 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/logging.d.ts +15 -0
  35. package/dist/logging.d.ts.map +1 -0
  36. package/dist/logging.js +36 -0
  37. package/dist/logging.js.map +1 -0
  38. package/dist/pair.d.ts +25 -0
  39. package/dist/pair.d.ts.map +1 -0
  40. package/dist/pair.js +41 -0
  41. package/dist/pair.js.map +1 -0
  42. package/dist/permissions.d.ts +67 -0
  43. package/dist/permissions.d.ts.map +1 -0
  44. package/dist/permissions.js +221 -0
  45. package/dist/permissions.js.map +1 -0
  46. package/dist/protocol.d.ts +181 -0
  47. package/dist/protocol.d.ts.map +1 -0
  48. package/dist/protocol.js +63 -0
  49. package/dist/protocol.js.map +1 -0
  50. package/dist/room.d.ts +52 -0
  51. package/dist/room.d.ts.map +1 -0
  52. package/dist/room.js +401 -0
  53. package/dist/room.js.map +1 -0
  54. package/dist/tts/elevenlabs.d.ts +43 -0
  55. package/dist/tts/elevenlabs.d.ts.map +1 -0
  56. package/dist/tts/elevenlabs.js +268 -0
  57. package/dist/tts/elevenlabs.js.map +1 -0
  58. package/dist/tts/index.d.ts +22 -0
  59. package/dist/tts/index.d.ts.map +1 -0
  60. package/dist/tts/index.js +23 -0
  61. package/dist/tts/index.js.map +1 -0
  62. package/dist/tts/openai.d.ts +35 -0
  63. package/dist/tts/openai.d.ts.map +1 -0
  64. package/dist/tts/openai.js +270 -0
  65. package/dist/tts/openai.js.map +1 -0
  66. package/dist/tts/types.d.ts +28 -0
  67. package/dist/tts/types.d.ts.map +1 -0
  68. package/dist/tts/types.js +5 -0
  69. package/dist/tts/types.js.map +1 -0
  70. package/package.json +68 -0
@@ -0,0 +1,221 @@
1
+ /**
2
+ * @file In-meeting permission broker.
3
+ *
4
+ * The Claude driver hands off to this broker via a callback whenever a tool
5
+ * call needs human approval. The broker:
6
+ * 1. Picks an auto-decision when the workspace policy can answer locally
7
+ * (reads = allow, writes/edits inside cwd = allow, etc.).
8
+ * 2. Otherwise emits a `agent.permission_request` event into the room and
9
+ * blocks until the corresponding `permission.response` arrives — or
10
+ * until the request times out / the run is aborted.
11
+ *
12
+ * The broker has no LiveKit awareness; it takes a pair of callbacks (publish,
13
+ * resolve) so it can be unit-tested in isolation and the room runtime owns
14
+ * the actual data-channel plumbing.
15
+ */
16
+ import { randomUUID } from 'node:crypto';
17
+ import { sep } from 'node:path';
18
+ import { log } from './logging.js';
19
+ const READ_ONLY_TOOLS = new Set(['Read', 'Glob', 'Grep', 'WebFetch', 'WebSearch']);
20
+ const SAFE_RECURSIVE_TOOLS = new Set(['Task']);
21
+ const FILE_WRITE_TOOLS = new Set(['Edit', 'MultiEdit', 'Write', 'NotebookEdit']);
22
+ const DEFAULT_TIMEOUT_MS = 90_000;
23
+ export class PermissionBroker {
24
+ policy;
25
+ pending = new Map();
26
+ timeoutMs;
27
+ publisher = null;
28
+ queuedRequests = [];
29
+ constructor(policy, deps = {}) {
30
+ this.policy = policy;
31
+ this.timeoutMs = deps.timeoutMs ?? DEFAULT_TIMEOUT_MS;
32
+ }
33
+ /**
34
+ * Wires the broker to a transport. Called by the room runtime once it has
35
+ * a connected LiveKit data channel. Any requests that arrived earlier are
36
+ * flushed in order.
37
+ */
38
+ attachPublisher(publish) {
39
+ this.publisher = publish;
40
+ const queued = this.queuedRequests;
41
+ this.queuedRequests = [];
42
+ for (const event of queued) {
43
+ try {
44
+ publish(event);
45
+ }
46
+ catch (error) {
47
+ log.warn('permission_publish_flush_failed', {
48
+ requestId: event.requestId,
49
+ message: error instanceof Error ? error.message : String(error),
50
+ });
51
+ }
52
+ }
53
+ }
54
+ detachPublisher() {
55
+ this.publisher = null;
56
+ }
57
+ /**
58
+ * Decides whether a tool call can proceed. Synchronously resolves for
59
+ * trivially-safe tools; otherwise asks the room and awaits a response.
60
+ */
61
+ async decide(args) {
62
+ if (this.policy.fullAccess) {
63
+ return { decision: 'allow' };
64
+ }
65
+ if (READ_ONLY_TOOLS.has(args.toolName) || SAFE_RECURSIVE_TOOLS.has(args.toolName)) {
66
+ return { decision: 'allow' };
67
+ }
68
+ const inWorkspace = this.fileToolStaysInWorkspace(args.toolName, args.toolInput);
69
+ if (inWorkspace === true)
70
+ return { decision: 'allow' };
71
+ const requestId = randomUUID();
72
+ const summary = summarizeToolCall(args.toolName, args.toolInput);
73
+ const reason = summarizeReason(args.toolName, args.toolInput, inWorkspace, this.policy.workspaceCwd);
74
+ const riskLevel = computeRisk(args.toolName, args.toolInput);
75
+ const event = {
76
+ type: 'agent.permission_request',
77
+ requestId,
78
+ runId: args.runId,
79
+ toolName: args.toolName,
80
+ toolInput: args.toolInput,
81
+ summary,
82
+ reason,
83
+ riskLevel,
84
+ };
85
+ log.info('permission_request_dispatched', {
86
+ requestId,
87
+ toolName: args.toolName,
88
+ summary,
89
+ riskLevel,
90
+ });
91
+ return new Promise((resolve) => {
92
+ const timer = setTimeout(() => {
93
+ if (!this.pending.has(requestId))
94
+ return;
95
+ this.pending.delete(requestId);
96
+ log.warn('permission_request_timeout', { requestId, toolName: args.toolName });
97
+ resolve({
98
+ decision: 'deny',
99
+ message: 'Permission request timed out without a response from the room.',
100
+ });
101
+ }, this.timeoutMs);
102
+ this.pending.set(requestId, {
103
+ resolve: (decision) => {
104
+ resolve({
105
+ decision,
106
+ ...(decision === 'deny' ? { message: 'Denied by host.' } : {}),
107
+ });
108
+ },
109
+ timer,
110
+ });
111
+ if (this.publisher) {
112
+ try {
113
+ this.publisher(event);
114
+ }
115
+ catch (publishError) {
116
+ clearTimeout(timer);
117
+ this.pending.delete(requestId);
118
+ log.error('permission_publish_failed', {
119
+ requestId,
120
+ message: publishError instanceof Error ? publishError.message : String(publishError),
121
+ });
122
+ resolve({
123
+ decision: 'deny',
124
+ message: 'Could not deliver permission request to the room.',
125
+ });
126
+ }
127
+ }
128
+ else {
129
+ // No transport yet — buffer until attachPublisher() flushes us.
130
+ this.queuedRequests.push(event);
131
+ }
132
+ });
133
+ }
134
+ /** Called by the room runtime when a `permission.response` event arrives. */
135
+ resolve(requestId, decision) {
136
+ const entry = this.pending.get(requestId);
137
+ if (!entry)
138
+ return false;
139
+ this.pending.delete(requestId);
140
+ clearTimeout(entry.timer);
141
+ entry.resolve(decision);
142
+ return true;
143
+ }
144
+ /** Cancel every outstanding request (e.g. on shutdown / run abort). */
145
+ cancelAll(reason = 'deny') {
146
+ for (const [, entry] of this.pending) {
147
+ clearTimeout(entry.timer);
148
+ entry.resolve(reason);
149
+ }
150
+ this.pending.clear();
151
+ }
152
+ /**
153
+ * Returns `true` when the file path is safely inside the workspace, `false`
154
+ * when it points outside, and `null` when the tool isn't a file-write tool
155
+ * (caller falls through to the room).
156
+ */
157
+ fileToolStaysInWorkspace(toolName, toolInput) {
158
+ if (!FILE_WRITE_TOOLS.has(toolName))
159
+ return null;
160
+ const filePath = extractFilePath(toolInput);
161
+ if (!filePath)
162
+ return false;
163
+ return isPathInsideWorkspace(filePath, this.policy.workspaceCwd);
164
+ }
165
+ }
166
+ function extractFilePath(input) {
167
+ if (!input || typeof input !== 'object')
168
+ return null;
169
+ const obj = input;
170
+ const candidate = obj.file_path ?? obj.path ?? obj.notebook_path;
171
+ return typeof candidate === 'string' && candidate.length > 0 ? candidate : null;
172
+ }
173
+ function isPathInsideWorkspace(filePath, workspaceCwd) {
174
+ const cwdNorm = workspaceCwd.replace(/[/\\]+$/, '') + sep;
175
+ const fileNorm = filePath.endsWith(sep) ? filePath : filePath + (filePath.includes(sep) ? '' : sep);
176
+ if (filePath === workspaceCwd)
177
+ return true;
178
+ return filePath.startsWith(cwdNorm) || fileNorm.startsWith(cwdNorm);
179
+ }
180
+ function summarizeToolCall(toolName, toolInput) {
181
+ if (!toolInput || typeof toolInput !== 'object')
182
+ return toolName;
183
+ const obj = toolInput;
184
+ if (toolName === 'Bash' && typeof obj.command === 'string') {
185
+ const cmd = obj.command.trim();
186
+ return `Bash: ${cmd.length > 120 ? `${cmd.slice(0, 117)}…` : cmd}`;
187
+ }
188
+ const path = extractFilePath(toolInput);
189
+ if (path)
190
+ return `${toolName}: ${path}`;
191
+ return toolName;
192
+ }
193
+ function summarizeReason(toolName, toolInput, workspaceFlag, workspaceCwd) {
194
+ if (toolName === 'Bash') {
195
+ const cmd = typeof toolInput?.command === 'string'
196
+ ? toolInput.command
197
+ : '';
198
+ if (/\b(rm|sudo|chmod|chown|mv\s+\/|curl\s+.*\|\s*sh|wget\s+.*\|\s*sh)\b/.test(cmd)) {
199
+ return 'Shell command flagged as potentially destructive.';
200
+ }
201
+ return 'Shell commands always require approval outside full-access mode.';
202
+ }
203
+ if (workspaceFlag === false) {
204
+ return `Path is outside the workspace (${workspaceCwd}).`;
205
+ }
206
+ return 'Tool not on the auto-approve list — approval required.';
207
+ }
208
+ function computeRisk(toolName, toolInput) {
209
+ if (toolName === 'Bash') {
210
+ const cmd = typeof toolInput?.command === 'string'
211
+ ? toolInput.command
212
+ : '';
213
+ if (/\b(rm\s+-rf|sudo|curl\s+.*\|\s*sh|wget\s+.*\|\s*sh)\b/.test(cmd))
214
+ return 'high';
215
+ return 'medium';
216
+ }
217
+ if (FILE_WRITE_TOOLS.has(toolName))
218
+ return 'medium';
219
+ return 'low';
220
+ }
221
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AA+BnC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AACnF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AAEjF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,MAAM,OAAO,gBAAgB;IAOR;IANX,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IACnC,SAAS,CAAS;IAC3B,SAAS,GAA0D,IAAI,CAAC;IACxE,cAAc,GAAkC,EAAE,CAAC;IAE3D,YACmB,MAAwB,EACz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AA6B,EAC7B,YAAoB;IAEpB,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,GAAG,GACP,OAAQ,SAAmC,EAAE,OAAO,KAAK,QAAQ;YAC/D,CAAC,CAAE,SAAiC,CAAC,OAAO;YAC5C,CAAC,CAAC,EAAE,CAAC;QACT,IAAI,qEAAqE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACpF,OAAO,mDAAmD,CAAC;QAC7D,CAAC;QACD,OAAO,kEAAkE,CAAC;IAC5E,CAAC;IACD,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,kCAAkC,YAAY,IAAI,CAAC;IAC5D,CAAC;IACD,OAAO,wDAAwD,CAAC;AAClE,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB,EAAE,SAAkB;IACvD,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,GAAG,GACP,OAAQ,SAAmC,EAAE,OAAO,KAAK,QAAQ;YAC/D,CAAC,CAAE,SAAiC,CAAC,OAAO;YAC5C,CAAC,CAAC,EAAE,CAAC;QACT,IAAI,uDAAuD,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC;QACrF,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * @file Wire protocol shared between the bridge process and the web client.
3
+ *
4
+ * Both packages import these types so adding/changing an event type fails the
5
+ * type checker on both ends. Runtime exports are intentionally minimal — the
6
+ * web side only uses the type aliases.
7
+ */
8
+ export declare const PROTOCOL_VERSION: 1;
9
+ /**
10
+ * LiveKit data channel topic used for all bridge ↔ room control messages.
11
+ *
12
+ * Keeps event traffic isolated from any other future data-channel usage.
13
+ */
14
+ export declare const BRIDGE_TOPIC: "voxagent.bridge";
15
+ /**
16
+ * Identity prefix reserved for the bridge participant.
17
+ *
18
+ * The web token route refuses to mint identities matching this prefix to
19
+ * prevent browser participants from impersonating the agent.
20
+ */
21
+ export declare const AGENT_IDENTITY_PREFIX: "agent:";
22
+ /**
23
+ * Builds the canonical agent identity for one room.
24
+ *
25
+ * @param roomId - Room identifier the bridge will pair with.
26
+ * @returns LiveKit participant identity string.
27
+ */
28
+ export declare function buildAgentIdentity(roomId: string): string;
29
+ /**
30
+ * Returns true when an identity string matches the reserved agent prefix.
31
+ */
32
+ export declare function isAgentIdentity(identity: string): boolean;
33
+ export type AgentBackend = 'claude' | 'codex';
34
+ export interface CapabilitiesInfo {
35
+ backend: AgentBackend;
36
+ /** Skill names discovered on the host. */
37
+ skills: string[];
38
+ /** Plugin names discovered on the host. */
39
+ plugins: string[];
40
+ /** MCP server identifiers (configured names) discovered on the host. */
41
+ mcpServers: string[];
42
+ /** Working directory the bridge will run the agent in. */
43
+ cwd: string;
44
+ /** Bridge package version. */
45
+ bridgeVersion: string;
46
+ }
47
+ export interface BridgeHelloEvent {
48
+ type: 'bridge.hello';
49
+ protocolVersion: typeof PROTOCOL_VERSION;
50
+ capabilities: CapabilitiesInfo;
51
+ }
52
+ export interface BridgeByeEvent {
53
+ type: 'bridge.bye';
54
+ reason: 'shutdown' | 'error' | 'unpaired';
55
+ message?: string;
56
+ }
57
+ export interface AgentRunStartEvent {
58
+ type: 'agent.run_start';
59
+ runId: string;
60
+ promptId: string;
61
+ startedAtMs: number;
62
+ }
63
+ export interface AgentTextDeltaEvent {
64
+ type: 'agent.text_delta';
65
+ runId: string;
66
+ delta: string;
67
+ /** Monotonic sequence within the run for ordering. */
68
+ seq: number;
69
+ }
70
+ export interface AgentTextDoneEvent {
71
+ type: 'agent.text_done';
72
+ runId: string;
73
+ text: string;
74
+ }
75
+ export interface AgentToolUseStartEvent {
76
+ type: 'agent.tool_use_start';
77
+ runId: string;
78
+ toolUseId: string;
79
+ /** Tool name (e.g. "Bash", "Edit", "Read", or any MCP tool). */
80
+ name: string;
81
+ /** Best-effort input snapshot (may be partial during streaming). */
82
+ input: unknown;
83
+ }
84
+ export interface AgentToolUseProgressEvent {
85
+ type: 'agent.tool_use_progress';
86
+ runId: string;
87
+ toolUseId: string;
88
+ /** Plain-text progress chunk (e.g. streaming Bash stdout). */
89
+ chunk: string;
90
+ }
91
+ export interface AgentToolUseEndEvent {
92
+ type: 'agent.tool_use_end';
93
+ runId: string;
94
+ toolUseId: string;
95
+ status: 'success' | 'error';
96
+ output: unknown;
97
+ latencyMs?: number;
98
+ }
99
+ export interface AgentThinkingDeltaEvent {
100
+ type: 'agent.thinking_delta';
101
+ runId: string;
102
+ delta: string;
103
+ }
104
+ export interface AgentRunEndEvent {
105
+ type: 'agent.run_end';
106
+ runId: string;
107
+ reason: 'completed' | 'interrupted' | 'error';
108
+ message?: string;
109
+ totalLatencyMs?: number;
110
+ }
111
+ export type PermissionRiskLevel = 'low' | 'medium' | 'high';
112
+ export interface AgentPermissionRequestEvent {
113
+ type: 'agent.permission_request';
114
+ requestId: string;
115
+ runId: string;
116
+ toolName: string;
117
+ toolInput: unknown;
118
+ /** One-line human-readable summary used as the modal title. */
119
+ summary: string;
120
+ /** Why approval is being asked — e.g. "outside workspace", "shell command". */
121
+ reason: string;
122
+ riskLevel: PermissionRiskLevel;
123
+ }
124
+ export interface AgentPermissionResolvedEvent {
125
+ type: 'agent.permission_resolved';
126
+ requestId: string;
127
+ decision: 'allow' | 'deny' | 'expired';
128
+ }
129
+ export type BridgeOutboundEvent = BridgeHelloEvent | BridgeByeEvent | AgentRunStartEvent | AgentTextDeltaEvent | AgentTextDoneEvent | AgentToolUseStartEvent | AgentToolUseProgressEvent | AgentToolUseEndEvent | AgentThinkingDeltaEvent | AgentRunEndEvent | AgentPermissionRequestEvent | AgentPermissionResolvedEvent;
130
+ export interface PromptUserTurnEvent {
131
+ type: 'prompt.user_turn';
132
+ promptId: string;
133
+ /** Display name of the speaker who triggered this prompt. */
134
+ speaker: string;
135
+ /** Stable speaker identity (LiveKit participant identity). */
136
+ speakerIdentity: string;
137
+ /** Latest line that addressed the agent. */
138
+ text: string;
139
+ /** Sliding transcript window for context. */
140
+ transcriptWindow: TranscriptWindowEntry[];
141
+ /** Active room metadata used for prompt grounding. */
142
+ room: {
143
+ id: string;
144
+ name: string;
145
+ participants: string[];
146
+ };
147
+ }
148
+ export interface TranscriptWindowEntry {
149
+ speaker: string;
150
+ text: string;
151
+ timestampMs: number;
152
+ }
153
+ export interface PromptInterruptEvent {
154
+ type: 'prompt.interrupt';
155
+ /** Optional run ID — when omitted, interrupts whatever is active. */
156
+ runId?: string;
157
+ }
158
+ export interface PromptCancelPendingEvent {
159
+ type: 'prompt.cancel_pending';
160
+ }
161
+ export interface PermissionResponseEvent {
162
+ type: 'permission.response';
163
+ requestId: string;
164
+ decision: 'allow' | 'deny';
165
+ }
166
+ export type BridgeInboundEvent = PromptUserTurnEvent | PromptInterruptEvent | PromptCancelPendingEvent | PermissionResponseEvent;
167
+ export type BridgeEvent = BridgeOutboundEvent | BridgeInboundEvent;
168
+ /**
169
+ * Encodes an event for transmission over the LiveKit data channel.
170
+ *
171
+ * @param event - Bridge event to serialize.
172
+ * @returns UTF-8 encoded JSON byte payload.
173
+ */
174
+ export declare function encodeBridgeEvent(event: BridgeEvent): Uint8Array;
175
+ /**
176
+ * Decodes a LiveKit data-channel payload back into a bridge event.
177
+ *
178
+ * Returns `null` when the payload is not valid JSON or not a known event.
179
+ */
180
+ export declare function decodeBridgeEvent(payload: Uint8Array): BridgeEvent | null;
181
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAG,iBAA0B,CAAC;AAEvD;;;;;GAKG;AACH,e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AC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,oBAAoB,GACpB,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAEnE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CASzE"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @file Wire protocol shared between the bridge process and the web client.
3
+ *
4
+ * Both packages import these types so adding/changing an event type fails the
5
+ * type checker on both ends. Runtime exports are intentionally minimal — the
6
+ * web side only uses the type aliases.
7
+ */
8
+ export const PROTOCOL_VERSION = 1;
9
+ /**
10
+ * LiveKit data channel topic used for all bridge ↔ room control messages.
11
+ *
12
+ * Keeps event traffic isolated from any other future data-channel usage.
13
+ */
14
+ export const BRIDGE_TOPIC = 'voxagent.bridge';
15
+ /**
16
+ * Identity prefix reserved for the bridge participant.
17
+ *
18
+ * The web token route refuses to mint identities matching this prefix to
19
+ * prevent browser participants from impersonating the agent.
20
+ */
21
+ export const AGENT_IDENTITY_PREFIX = 'agent:';
22
+ /**
23
+ * Builds the canonical agent identity for one room.
24
+ *
25
+ * @param roomId - Room identifier the bridge will pair with.
26
+ * @returns LiveKit participant identity string.
27
+ */
28
+ export function buildAgentIdentity(roomId) {
29
+ return `${AGENT_IDENTITY_PREFIX}${roomId}`;
30
+ }
31
+ /**
32
+ * Returns true when an identity string matches the reserved agent prefix.
33
+ */
34
+ export function isAgentIdentity(identity) {
35
+ return identity.startsWith(AGENT_IDENTITY_PREFIX);
36
+ }
37
+ /**
38
+ * Encodes an event for transmission over the LiveKit data channel.
39
+ *
40
+ * @param event - Bridge event to serialize.
41
+ * @returns UTF-8 encoded JSON byte payload.
42
+ */
43
+ export function encodeBridgeEvent(event) {
44
+ return new TextEncoder().encode(JSON.stringify(event));
45
+ }
46
+ /**
47
+ * Decodes a LiveKit data-channel payload back into a bridge event.
48
+ *
49
+ * Returns `null` when the payload is not valid JSON or not a known event.
50
+ */
51
+ export function decodeBridgeEvent(payload) {
52
+ try {
53
+ const text = new TextDecoder().decode(payload);
54
+ const parsed = JSON.parse(text);
55
+ if (typeof parsed.type !== 'string')
56
+ return null;
57
+ return parsed;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,iBAA0B,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAiB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,GAAG,qBAAqB,GAAG,MAAM,EAAE,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AACpD,CAAC;AAgLD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IAClD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmB;IACnD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAuB,CAAC;QACtD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACjD,OAAO,MAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/room.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @file Room runtime — joins LiveKit, publishes agent voice, drives the agent.
3
+ *
4
+ * Lifecycle:
5
+ * 1. Connect to LiveKit with the bridge JWT.
6
+ * 2. Publish the agent audio track so other participants subscribe to it.
7
+ * 3. Send `bridge.hello` over the data channel so the UI knows we're paired.
8
+ * 4. Listen for `prompt.user_turn` from any participant.
9
+ * 5. For each prompt, run the driver; fan events into:
10
+ * - data channel (text deltas, tool events) for UI
11
+ * - TTS engine (text deltas) → AudioSource (PCM frames) for voice
12
+ * - cloud action ingest (tool start/end) for the persisted timeline
13
+ */
14
+ import type { BridgeConfig } from './config.js';
15
+ import type { AgentDriver } from './drivers/index.js';
16
+ import type { PairResult } from './pair.js';
17
+ import { PermissionBroker } from './permissions.js';
18
+ import { type CapabilitiesInfo } from './protocol.js';
19
+ interface RoomRuntimeOptions {
20
+ config: BridgeConfig;
21
+ pair: PairResult;
22
+ driver: AgentDriver;
23
+ capabilities: CapabilitiesInfo;
24
+ permissionBroker: PermissionBroker;
25
+ }
26
+ export declare class BridgeRoomRuntime {
27
+ private readonly options;
28
+ private room;
29
+ private audio;
30
+ private tts;
31
+ private activeRun;
32
+ private deltaSeq;
33
+ private shuttingDown;
34
+ private pendingPrompts;
35
+ constructor(options: RoomRuntimeOptions);
36
+ start(): Promise<void>;
37
+ shutdown(reason?: 'shutdown' | 'error'): Promise<void>;
38
+ private handleDisconnect;
39
+ private handleDataReceived;
40
+ private enqueuePrompt;
41
+ private drainPrompts;
42
+ private interruptActiveRun;
43
+ private runPrompt;
44
+ private pumpAudio;
45
+ private handleDriverEvent;
46
+ private publishEvent;
47
+ private ingestActionStart;
48
+ private ingestActionEnd;
49
+ private callIngest;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=room.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room.d.ts","sourceRoot":"","sources":["../src/room.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAML,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;AAGvB,UAAU,kBAAkB;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AASD,qBAAa,iBAAiB;IAShB,OAAO,CAAC,QAAQ,CAAC,OAAO;IARpC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,cAAc,CAA6B;gBAEtB,OAAO,EAAE,kBAAkB;IAIlD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA6DtB,QAAQ,CAAC,MAAM,GAAE,UAAU,GAAG,OAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCxE,OAA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