@realtimex/sdk 1.7.28 → 2.0.1

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 (66) hide show
  1. package/dist/chunk-ORAAYW4C.mjs +271 -0
  2. package/dist/errors-C98IGxYU.d.mts +168 -0
  3. package/dist/errors-C98IGxYU.d.ts +168 -0
  4. package/dist/index.d.mts +8 -2048
  5. package/dist/index.d.ts +8 -2048
  6. package/dist/index.js +168 -4723
  7. package/dist/index.mjs +7 -3783
  8. package/dist/v1/index.d.mts +3 -56
  9. package/dist/v1/index.d.ts +3 -56
  10. package/dist/v1/index.js +2 -756
  11. package/dist/v1/index.mjs +2 -42
  12. package/package.json +6 -7
  13. package/dist/chunk-Z5GAUBIM.mjs +0 -993
  14. package/dist/errors-NufsyIZ-.d.mts +0 -678
  15. package/dist/errors-NufsyIZ-.d.ts +0 -678
  16. package/skills/realtimex-moderator-sdk/SKILL.md +0 -102
  17. package/skills/realtimex-moderator-sdk/references/activities.md +0 -14
  18. package/skills/realtimex-moderator-sdk/references/agents.md +0 -13
  19. package/skills/realtimex-moderator-sdk/references/api-reference/acpagent.md +0 -105
  20. package/skills/realtimex-moderator-sdk/references/api-reference/activities.md +0 -24
  21. package/skills/realtimex-moderator-sdk/references/api-reference/agent.md +0 -27
  22. package/skills/realtimex-moderator-sdk/references/api-reference/api.md +0 -17
  23. package/skills/realtimex-moderator-sdk/references/api-reference/auth.md +0 -36
  24. package/skills/realtimex-moderator-sdk/references/api-reference/contract.md +0 -27
  25. package/skills/realtimex-moderator-sdk/references/api-reference/core.md +0 -40
  26. package/skills/realtimex-moderator-sdk/references/api-reference/database.md +0 -24
  27. package/skills/realtimex-moderator-sdk/references/api-reference/index.md +0 -43
  28. package/skills/realtimex-moderator-sdk/references/api-reference/llm.md +0 -176
  29. package/skills/realtimex-moderator-sdk/references/api-reference/mcp.md +0 -50
  30. package/skills/realtimex-moderator-sdk/references/api-reference/port.md +0 -21
  31. package/skills/realtimex-moderator-sdk/references/api-reference/stt.md +0 -15
  32. package/skills/realtimex-moderator-sdk/references/api-reference/task.md +0 -62
  33. package/skills/realtimex-moderator-sdk/references/api-reference/tts.md +0 -18
  34. package/skills/realtimex-moderator-sdk/references/api-reference/v1-acpauth.md +0 -21
  35. package/skills/realtimex-moderator-sdk/references/api-reference/v1-acpcommands.md +0 -15
  36. package/skills/realtimex-moderator-sdk/references/api-reference/v1-admin.md +0 -48
  37. package/skills/realtimex-moderator-sdk/references/api-reference/v1-auth.md +0 -18
  38. package/skills/realtimex-moderator-sdk/references/api-reference/v1-channels.md +0 -78
  39. package/skills/realtimex-moderator-sdk/references/api-reference/v1-credentials.md +0 -27
  40. package/skills/realtimex-moderator-sdk/references/api-reference/v1-customthemes.md +0 -24
  41. package/skills/realtimex-moderator-sdk/references/api-reference/v1-desktopbrowser.md +0 -39
  42. package/skills/realtimex-moderator-sdk/references/api-reference/v1-desktopembed.md +0 -24
  43. package/skills/realtimex-moderator-sdk/references/api-reference/v1-desktopruntimesessions.md +0 -33
  44. package/skills/realtimex-moderator-sdk/references/api-reference/v1-document.md +0 -39
  45. package/skills/realtimex-moderator-sdk/references/api-reference/v1-embed.md +0 -27
  46. package/skills/realtimex-moderator-sdk/references/api-reference/v1-openai.md +0 -21
  47. package/skills/realtimex-moderator-sdk/references/api-reference/v1-sttapi.md +0 -12
  48. package/skills/realtimex-moderator-sdk/references/api-reference/v1-system.md +0 -36
  49. package/skills/realtimex-moderator-sdk/references/api-reference/v1-thread.md +0 -26
  50. package/skills/realtimex-moderator-sdk/references/api-reference/v1-users.md +0 -15
  51. package/skills/realtimex-moderator-sdk/references/api-reference/v1-workspace.md +0 -39
  52. package/skills/realtimex-moderator-sdk/references/api-reference/webhook.md +0 -13
  53. package/skills/realtimex-moderator-sdk/references/api-reference.md +0 -1330
  54. package/skills/realtimex-moderator-sdk/references/app-concepts.md +0 -1276
  55. package/skills/realtimex-moderator-sdk/references/browser.md +0 -27
  56. package/skills/realtimex-moderator-sdk/references/channels.md +0 -189
  57. package/skills/realtimex-moderator-sdk/references/credentials.md +0 -111
  58. package/skills/realtimex-moderator-sdk/references/known-issues.md +0 -237
  59. package/skills/realtimex-moderator-sdk/references/llm.md +0 -13
  60. package/skills/realtimex-moderator-sdk/references/mcp.md +0 -13
  61. package/skills/realtimex-moderator-sdk/references/permissions.md +0 -30
  62. package/skills/realtimex-moderator-sdk/references/quickstart.md +0 -16
  63. package/skills/realtimex-moderator-sdk/references/terminal-sessions.md +0 -34
  64. package/skills/realtimex-moderator-sdk/references/workspaces.md +0 -20
  65. package/skills/realtimex-moderator-sdk/scripts/lib/sdk-init.js +0 -171
  66. package/skills/realtimex-moderator-sdk/scripts/rtx.js +0 -1359
package/dist/index.d.ts CHANGED
@@ -1,2069 +1,29 @@
1
- import { V as V1ApiNamespace, a as V1DesktopRuntimeSessionsModule, b as V1DesktopBrowserModule } from './errors-NufsyIZ-.js';
2
- export { A as AuthenticationError, D as DeveloperApiClient, c as DeveloperApiError, N as NotFoundError, S as ServerError, d as ValidationError } from './errors-NufsyIZ-.js';
1
+ import { V as V1ApiNamespace } from './errors-C98IGxYU.js';
2
+ export { A as AuthenticationError, D as DeveloperApiClient, a as DeveloperApiError, N as NotFoundError, S as ServerError, b as ValidationError } from './errors-C98IGxYU.js';
3
3
 
4
- /**
5
- * RealtimeX Local App SDK - Types
6
- */
7
4
  interface SDKConfig {
8
5
  realtimex?: {
9
6
  url?: string;
10
7
  appId?: string;
11
- appName?: string;
12
8
  apiKey?: string;
13
9
  };
14
- defaultPort?: number;
15
- permissions?: string[];
16
- contract?: {
17
- callbackSecret?: string;
18
- signCallbacksByDefault?: boolean;
19
- };
20
- }
21
- interface Activity {
22
- id: string;
23
- raw_data: Record<string, unknown>;
24
- old_data?: Record<string, unknown>;
25
- status: 'pending' | 'claimed' | 'completed' | 'failed';
26
- locked_by?: string;
27
- locked_at?: string;
28
- completed_at?: string;
29
- error_message?: string;
30
- result?: Record<string, unknown>;
31
- created_at: string;
32
- }
33
- interface TriggerAgentPayload {
34
- raw_data: Record<string, unknown>;
35
- auto_run?: boolean;
36
- agent_name?: string;
37
- workspace_slug?: string;
38
- thread_slug?: string;
39
- prompt?: string;
40
- event_id?: string;
41
- attempt_id?: string | number;
42
- }
43
- interface TriggerAgentResponse {
44
- success: boolean;
45
- task_uuid?: string;
46
- task_id?: string;
47
- capability_id?: string;
48
- event_id?: string;
49
- attempt_id?: string;
50
- event_type?: ContractEventType | string;
51
- contract_version?: string;
52
- calendar_event_uuid?: string;
53
- auto_run?: boolean;
54
- message?: string;
55
- error?: string;
56
- }
57
- type ContractEventType = 'task.trigger' | 'system.ping' | 'task.claimed' | 'task.started' | 'task.progress' | 'task.completed' | 'task.failed' | 'task.canceled';
58
- interface ContractCallbackMetadata {
59
- event_id_header?: string;
60
- signature_header?: string;
61
- signature_algorithm?: string;
62
- signature_message?: string;
63
- attempt_id_format?: string;
64
- idempotency?: string;
65
- }
66
- interface ContractCapabilityTrigger$1 {
67
- event: string;
68
- route?: string;
69
- payload_template?: Record<string, unknown>;
70
- }
71
- interface ContractCapability$1 {
72
- capability_id: string;
73
- name: string;
74
- description?: string;
75
- input_schema: Record<string, unknown>;
76
- output_schema?: Record<string, unknown>;
77
- permission?: string;
78
- trigger?: ContractCapabilityTrigger$1;
79
- tags?: string[];
80
- examples?: string[];
81
- risk_level?: 'low' | 'medium' | 'high' | null;
82
- enabled?: boolean;
83
- }
84
- interface LocalAppContractDefinition {
85
- id: string;
86
- version: string;
87
- strictness?: 'compatible' | 'strict';
88
- events: Record<string, ContractEventType>;
89
- supported_events: ContractEventType[];
90
- supported_legacy_events: string[];
91
- aliases: Record<string, ContractEventType>;
92
- status_map: Record<string, string>;
93
- legacy_action_map: Record<ContractEventType, string>;
94
- catalog_hash?: string;
95
- capability_count?: number;
96
- capabilities?: ContractCapability$1[];
97
- callback?: ContractCallbackMetadata;
98
- }
99
- interface LocalAppContractResponse {
100
- success: boolean;
101
- contract: LocalAppContractDefinition;
102
- }
103
- interface LocalAppCapabilitiesResponse {
104
- success: boolean;
105
- contract_version: string;
106
- strictness?: 'compatible' | 'strict';
107
- catalog_hash?: string;
108
- count: number;
109
- capabilities: ContractCapability$1[];
110
- }
111
- interface LocalAppCapabilitySearchResponse extends LocalAppCapabilitiesResponse {
112
- query: string;
113
- }
114
- interface LocalAppCapabilityDetailResponse {
115
- success: boolean;
116
- contract_version: string;
117
- strictness?: 'compatible' | 'strict';
118
- catalog_hash?: string;
119
- capability: ContractCapability$1;
120
- }
121
- interface ContractInvokePayload {
122
- capability_id: string;
123
- args?: Record<string, unknown>;
124
- auto_run?: boolean;
125
- agent_name?: string;
126
- workspace_slug?: string;
127
- thread_slug?: string;
128
- prompt?: string;
129
- event_id?: string;
130
- attempt_id?: string | number;
131
- }
132
- interface Agent {
133
- slug: string;
134
- name: string;
135
- description?: string;
136
- hub_id?: string;
137
- }
138
- interface Workspace {
139
- id: number;
140
- slug: string;
141
- name: string;
142
- type: string;
143
- created_at: string;
144
- }
145
- interface Thread {
146
- id: number;
147
- slug: string;
148
- name: string;
149
- created_at: string;
150
- }
151
- interface TaskRun {
152
- id: number;
153
- attempt_id?: string;
154
- agent_name: string;
155
- workspace_slug: string;
156
- thread_slug?: string;
157
- status: string;
158
- started_at?: string;
159
- completed_at?: string;
160
- error?: string;
161
- }
162
- interface Task {
163
- uuid: string;
164
- title: string;
165
- status: string;
166
- action_type: string;
167
- source_app: string;
168
- error?: string;
169
- created_at: string;
170
- updated_at: string;
171
- runs: TaskRun[];
172
- }
173
- interface TTSOptions {
174
- /** Voice ID (provider-specific) */
175
- voice?: string;
176
- /** Model ID (provider-specific) */
177
- model?: string;
178
- /** Speech speed (0.5-2.0) */
179
- speed?: number;
180
- /** TTS provider ID */
181
- provider?: string;
182
- /** Language code (e.g., 'en', 'es', 'fr') - for Supertonic */
183
- language?: string;
184
- /** Quality level (1-20) - for Supertonic num_inference_steps */
185
- num_inference_steps?: number;
186
- }
187
- interface TTSProviderConfig {
188
- /** Available voice/speaker IDs */
189
- voices: string[];
190
- /** Supported languages (for multilingual providers) */
191
- languages?: string[];
192
- /** Speed range */
193
- speed?: {
194
- min: number;
195
- max: number;
196
- default: number;
197
- };
198
- /** Quality range (for providers that support it) */
199
- quality?: {
200
- min: number;
201
- max: number;
202
- default: number;
203
- description?: string;
204
- };
205
- }
206
- interface TTSProvider {
207
- /** Provider ID (e.g., 'elevenlabs', 'supertonic_local') */
208
- id: string;
209
- /** Display name */
210
- name: string;
211
- /** Provider type: 'server' (remote API) or 'client' (local) */
212
- type: 'server' | 'client';
213
- /** Whether provider is configured and ready */
214
- configured: boolean;
215
- /** Whether streaming is supported */
216
- supportsStreaming: boolean;
217
- /** Optional note about provider requirements */
218
- note?: string;
219
- /** Configuration options */
220
- config?: TTSProviderConfig;
221
- }
222
- interface TTSProvidersResponse {
223
- success: boolean;
224
- providers: TTSProvider[];
225
- default: string;
226
- error?: string;
227
- }
228
- interface TTSChunk {
229
- /** Chunk index (0-based) */
230
- index: number;
231
- /** Total number of chunks */
232
- total: number;
233
- /** Decoded audio data (ArrayBuffer) - ready for playback */
234
- audio: ArrayBuffer;
235
- /** Audio MIME type */
236
- mimeType: string;
237
- }
238
- interface TTSChunkEvent {
239
- type: 'info' | 'chunk' | 'error' | 'done';
240
- data: TTSChunk | {
241
- totalChunks: number;
242
- } | {
243
- error: string;
244
- };
245
- }
246
- interface STTListenOptions {
247
- /** STT provider (e.g., 'native', 'whisper', 'groq') */
248
- provider?: string;
249
- /** Language code (e.g., 'en-US') */
250
- language?: string;
251
- /** Specific model ID (e.g., 'onnx-community/whisper-tiny.en') */
252
- model: string;
253
- /** Timeout in milliseconds (default: 60000) */
254
- timeout?: number;
255
- }
256
- interface STTModel {
257
- id: string;
258
- name: string;
259
- provider?: string;
260
- description?: string;
261
- language?: string;
262
- size?: string;
263
- recommended?: boolean;
264
- }
265
- interface STTProvider {
266
- id: string;
267
- name: string;
268
- description?: string;
269
- models: STTModel[];
270
- }
271
- interface STTProvidersResponse {
272
- success: boolean;
273
- providers: STTProvider[];
274
- error?: string;
275
- }
276
- interface STTModelsResponse {
277
- success: boolean;
278
- models: STTModel[];
279
- error?: string;
280
- }
281
- interface STTResponse {
282
- success: boolean;
283
- /** Transcribed text */
284
- text: string;
285
- error?: string;
286
- }
287
-
288
- /**
289
- * Activities Module - HTTP Proxy to RealtimeX Main App
290
- * No direct Supabase access - all operations go through Main App
291
- */
292
-
293
- declare class ActivitiesModule {
294
- private baseUrl;
295
- private appId;
296
- private appName;
297
- private apiKey?;
298
- constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
299
- /**
300
- * Request a single permission from Electron via internal API
301
- */
302
- private requestPermission;
303
- private request;
304
- /**
305
- * Insert a new activity
306
- */
307
- insert(rawData: Record<string, unknown>): Promise<Activity>;
308
- /**
309
- * Update an existing activity
310
- */
311
- update(id: string, updates: Partial<Activity>): Promise<Activity>;
312
- /**
313
- * Delete an activity
314
- */
315
- delete(id: string): Promise<void>;
316
- /**
317
- * Get a single activity by ID
318
- */
319
- get(id: string): Promise<Activity | null>;
320
- /**
321
- * List activities with optional filters
322
- */
323
- list(options?: {
324
- status?: string;
325
- limit?: number;
326
- offset?: number;
327
- }): Promise<Activity[]>;
328
- }
329
-
330
- declare class WebhookModule {
331
- private realtimexUrl;
332
- private appName?;
333
- private appId?;
334
- private apiKey?;
335
- constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
336
- /**
337
- * Request a single permission from Electron via internal API
338
- */
339
- private requestPermission;
340
- private request;
341
- triggerAgent(payload: TriggerAgentPayload): Promise<TriggerAgentResponse>;
342
- ping(): Promise<{
343
- success: boolean;
344
- app_name: string;
345
- message: string;
346
- }>;
347
- }
348
-
349
- /**
350
- * API Module - Call RealtimeX public APIs
351
- */
352
-
353
- /**
354
- * Error thrown when a permission is permanently denied
355
- */
356
- declare class PermissionDeniedError extends Error {
357
- readonly permission: string;
358
- readonly code: string;
359
- constructor(permission: string, message?: string, code?: string);
360
- }
361
- /**
362
- * Error thrown when a permission needs to be granted
363
- */
364
- declare class PermissionRequiredError extends Error {
365
- readonly permission: string;
366
- readonly code: string;
367
- constructor(permission: string, message?: string, code?: string);
368
- }
369
- declare class ApiModule {
370
- private realtimexUrl;
371
- private appId;
372
- private appName;
373
- private apiKey?;
374
- constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
375
- private getHeaders;
376
- /**
377
- * Request a single permission from Electron via internal API
378
- */
379
- private requestPermission;
380
- /**
381
- * Make an API call with automatic permission handling
382
- */
383
- protected apiCall<T>(method: string, endpoint: string, options?: RequestInit): Promise<T>;
384
- getAgents(): Promise<Agent[]>;
385
- getWorkspaces(): Promise<Workspace[]>;
386
- getThreads(workspaceSlug: string): Promise<Thread[]>;
387
- getTask(taskUuid: string): Promise<Task>;
388
- }
389
-
390
- /**
391
- * Task Module - Report task status to RealtimeX
392
- * Used by external agents/processors to update task status
393
- */
394
-
395
- interface TaskStatusResponse {
396
- success: boolean;
397
- task_uuid: string;
398
- status: string;
399
- event_id?: string;
400
- attempt_id?: string;
401
- event_type?: ContractEventType | string;
402
- deduplicated?: boolean;
403
- duplicate?: boolean;
404
- message?: string;
405
- }
406
- interface TaskEventOptions {
407
- machineId?: string;
408
- attemptId?: string | number;
409
- eventId?: string;
410
- timestamp?: string;
411
- callbackUrl?: string;
412
- callbackSecret?: string;
413
- sign?: boolean;
414
- userEmail?: string;
415
- activityId?: string;
416
- tableName?: string;
417
- }
418
- declare class TaskModule {
419
- private realtimexUrl;
420
- private appName?;
421
- private appId?;
422
- private apiKey?;
423
- private callbackSecret?;
424
- private signCallbacksByDefault;
425
- constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
426
- /**
427
- * Configure callback signing behavior.
428
- */
429
- configureContract(config: {
430
- callbackSecret?: string;
431
- signCallbacksByDefault?: boolean;
432
- }): void;
433
- /**
434
- * Claim a task before processing.
435
- */
436
- claim(taskUuid: string, options?: TaskEventOptions): Promise<TaskStatusResponse>;
437
- /**
438
- * Alias for claim()
439
- */
440
- claimed(taskUuid: string, options?: TaskEventOptions): Promise<TaskStatusResponse>;
441
- /**
442
- * Mark task as processing.
443
- * Backward compatible signature: start(taskUuid, machineId?)
444
- */
445
- start(taskUuid: string, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>;
446
- /**
447
- * Report incremental task progress.
448
- */
449
- progress(taskUuid: string, progressData?: Record<string, unknown>, options?: TaskEventOptions): Promise<TaskStatusResponse>;
450
- /**
451
- * Mark task as completed with result.
452
- * Backward compatible signature: complete(taskUuid, result?, machineId?)
453
- */
454
- complete(taskUuid: string, result?: Record<string, unknown>, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>;
455
- /**
456
- * Mark task as failed with error.
457
- * Backward compatible signature: fail(taskUuid, error, machineId?)
458
- */
459
- fail(taskUuid: string, error: string, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>;
460
- /**
461
- * Mark task as canceled.
462
- */
463
- cancel(taskUuid: string, reason?: string, options?: TaskEventOptions): Promise<TaskStatusResponse>;
464
- private _normalizeOptions;
465
- private _sendEvent;
466
- }
467
-
468
- /**
469
- * Port utilities for Local Apps
470
- * Helps find available ports to avoid conflicts when multiple apps run simultaneously
471
- */
472
- declare class PortModule {
473
- private defaultPort;
474
- constructor(defaultPort?: number);
475
- /**
476
- * Get suggested port from environment (RTX_PORT) or default
477
- */
478
- getSuggestedPort(): number;
479
- /**
480
- * Check if a port is available on a specific host
481
- */
482
- private isPortAvailableOn;
483
- /**
484
- * Check if a port is available (checks both IPv4 and IPv6)
485
- * @param port - Port number to check
486
- * @returns Promise resolving to true if port is available on ALL interfaces
487
- */
488
- isPortAvailable(port: number): Promise<boolean>;
489
- /**
490
- * Find an available port starting from the suggested port
491
- * @param startPort - Starting port number (default: RTX_PORT or defaultPort)
492
- * @param maxAttempts - Maximum ports to try (default: 100)
493
- * @returns Promise resolving to an available port number
494
- * @throws Error if no available port found in range
495
- */
496
- findAvailablePort(startPort?: number, maxAttempts?: number): Promise<number>;
497
- /**
498
- * Get a ready-to-use port
499
- * Returns the suggested port if available, otherwise finds the next available port
500
- *
501
- * @example
502
- * ```typescript
503
- * const sdk = new RealtimeXSDK();
504
- * const port = await sdk.port.getPort();
505
- * app.listen(port);
506
- * ```
507
- */
508
- getPort(): Promise<number>;
509
- }
510
-
511
- /**
512
- * LLM Module for RealtimeX SDK
513
- *
514
- * Provides access to LLM capabilities:
515
- * - Chat completion (sync and streaming)
516
- * - Embedding generation
517
- * - Provider/model listing
518
- * - Vector storage (upsert, query, delete)
519
- */
520
-
521
- interface ChatTextBlock {
522
- type: 'text' | 'input_text';
523
- text: string;
524
- [key: string]: unknown;
525
- }
526
- interface ChatImageUrlBlock {
527
- type: 'image_url' | 'input_image';
528
- image_url: string | {
529
- url: string;
530
- detail?: 'auto' | 'low' | 'high';
531
- [key: string]: unknown;
532
- };
533
- [key: string]: unknown;
534
- }
535
- interface ChatFileBlock {
536
- type: 'input_file' | 'file';
537
- file_url?: string;
538
- file_id?: string;
539
- filename?: string;
540
- [key: string]: unknown;
541
- }
542
- interface ChatCustomBlock {
543
- type: string;
544
- [key: string]: unknown;
545
- }
546
- type ChatContentBlock = ChatTextBlock | ChatImageUrlBlock | ChatFileBlock | ChatCustomBlock;
547
- type ChatMessageContent = string | ChatContentBlock[];
548
- interface ChatMessage {
549
- role: 'system' | 'user' | 'assistant';
550
- content: ChatMessageContent;
551
- }
552
- interface ChatOptions {
553
- model?: string;
554
- provider?: string;
555
- temperature?: number;
556
- max_tokens?: number;
557
- response_format?: {
558
- type: string;
559
- };
560
- }
561
- interface ChatResponse {
562
- success: boolean;
563
- response?: {
564
- content: string;
565
- model: string;
566
- provider?: string;
567
- metrics?: {
568
- prompt_tokens: number;
569
- completion_tokens: number;
570
- total_tokens: number;
571
- duration?: number;
572
- outputTps?: number;
573
- };
574
- };
575
- error?: string;
576
- code?: string;
577
- }
578
- interface StreamChunk {
579
- uuid?: string;
580
- type?: string;
581
- textResponse?: string;
582
- close?: boolean;
583
- error?: boolean;
584
- }
585
- interface EmbedOptions {
586
- provider?: string;
587
- model?: string;
588
- }
589
- interface EmbedResponse {
590
- success: boolean;
591
- embeddings?: number[][];
592
- provider?: string;
593
- model?: string;
594
- dimensions?: number;
595
- error?: string;
596
- code?: string;
597
- errors?: string[];
598
- }
599
- interface Provider {
600
- provider: string;
601
- models: Array<{
602
- id: string;
603
- name: string;
604
- }>;
605
- }
606
- interface ProvidersResponse {
607
- success: boolean;
608
- llm?: Provider[];
609
- embedding?: Provider[];
610
- providers?: Provider[];
611
- error?: string;
612
- code?: string;
613
- }
614
- interface VectorRecord {
615
- id: string;
616
- vector: number[];
617
- metadata?: {
618
- text?: string;
619
- documentId?: string;
620
- workspaceId?: string;
621
- [key: string]: unknown;
622
- };
623
- }
624
- interface VectorUpsertOptions {
625
- workspaceId?: string;
626
- }
627
- interface VectorUpsertResponse {
628
- success: boolean;
629
- upserted?: number;
630
- namespace?: string;
631
- error?: string;
632
- code?: string;
633
- errors?: string[];
634
- }
635
- interface VectorQueryOptions {
636
- topK?: number;
637
- filter?: {
638
- workspaceId?: string;
639
- documentId?: string;
640
- };
641
- workspaceId?: string;
642
- provider?: string;
643
- model?: string;
644
- }
645
- interface VectorQueryResult {
646
- id: string;
647
- score: number;
648
- metadata?: {
649
- text?: string;
650
- documentId?: string;
651
- workspaceId?: string;
652
- [key: string]: unknown;
653
- };
654
- }
655
- interface VectorQueryResponse {
656
- success: boolean;
657
- results?: VectorQueryResult[];
658
- error?: string;
659
- code?: string;
660
- }
661
- interface VectorDeleteOptions {
662
- workspaceId?: string;
663
- deleteAll: true;
664
- }
665
- interface VectorDeleteResponse {
666
- success: boolean;
667
- deleted?: number;
668
- message?: string;
669
- error?: string;
670
- code?: string;
671
- errors?: string[];
672
- }
673
- interface VectorListWorkspacesResponse {
674
- success: boolean;
675
- workspaces?: string[];
676
- error?: string;
677
- code?: string;
678
- error_message?: string;
679
- }
680
- interface VectorRegisterResponse {
681
- success: boolean;
682
- message?: string;
683
- error?: string;
684
- code?: string;
685
- }
686
- interface VectorConfigResponse {
687
- success: boolean;
688
- provider?: string;
689
- config?: Record<string, any>;
690
- error?: string;
691
- code?: string;
692
- }
693
- interface VectorProviderField {
694
- name: string;
695
- label: string;
696
- type: 'string' | 'password';
697
- placeholder?: string;
698
- }
699
- interface VectorProviderMetadata {
700
- name: string;
701
- label: string;
702
- description?: string;
703
- fields: VectorProviderField[];
704
- }
705
- interface VectorProvidersResponse {
706
- success: boolean;
707
- providers: VectorProviderMetadata[];
708
- }
709
- /**
710
- * @deprecated Use PermissionRequiredError from api module instead
711
- */
712
- declare class LLMPermissionError extends PermissionRequiredError {
713
- constructor(permission: string, code?: string);
714
- }
715
- declare class LLMProviderError extends Error {
716
- code: string;
717
- constructor(message: string, code?: string);
718
- }
719
- declare class VectorStore {
720
- private baseUrl;
721
- private appId;
722
- private appName;
723
- private apiKey?;
724
- constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
725
- private get headers();
726
- /**
727
- * Request a single permission from Electron via internal API
728
- */
729
- private requestPermission;
730
- /**
731
- * Internal request wrapper that handles automatic permission prompts
732
- */
733
- private request;
734
- /**
735
- * Upsert (insert or update) vectors into storage
736
- *
737
- * @example
738
- * ```ts
739
- * await sdk.llm.vectors.upsert([
740
- * { id: 'chunk-1', vector: embeddings[0], metadata: { text: 'Hello', documentId: 'doc-1' } }
741
- * ], { workspaceId: 'ws-123' });
742
- * ```
743
- */
744
- upsert(vectors: VectorRecord[], options?: VectorUpsertOptions): Promise<VectorUpsertResponse>;
745
- /**
746
- * Query similar vectors by embedding
747
- *
748
- * @example
749
- * ```ts
750
- * const results = await sdk.llm.vectors.query(queryVector, {
751
- * topK: 5,
752
- * filter: { documentId: 'doc-1' },
753
- * workspaceId: 'ws-123'
754
- * });
755
- * ```
756
- */
757
- query(vector: number[], options?: VectorQueryOptions): Promise<VectorQueryResponse>;
758
- /**
759
- * Delete vectors from storage
760
- *
761
- * Note: Currently only supports deleteAll: true
762
- * Use workspaceId to scope deletion to a specific workspace
763
- *
764
- * @example
765
- * ```ts
766
- * await sdk.llm.vectors.delete({ deleteAll: true, workspaceId: 'ws-123' });
767
- * ```
768
- */
769
- delete(options: VectorDeleteOptions): Promise<VectorDeleteResponse>;
770
- /**
771
- * List all available workspaces (namespaces) for this app
772
- *
773
- * @example
774
- * ```ts
775
- * const { workspaces } = await sdk.llm.vectors.listWorkspaces();
776
- * console.log('Workspaces:', workspaces);
777
- * ```
778
- */
779
- listWorkspaces(): Promise<VectorListWorkspacesResponse>;
780
- /**
781
- * Register a custom vector database configuration for this app
782
- *
783
- * @example
784
- * ```ts
785
- * await sdk.llm.vectors.registerConfig('lancedb', { });
786
- * ```
787
- */
788
- registerConfig(provider: string, config: Record<string, any>): Promise<VectorRegisterResponse>;
789
- /**
790
- * List all supported vector database providers and their configuration requirements
791
- */
792
- listProviders(): Promise<VectorProvidersResponse>;
793
- /**
794
- * Get the current vector database configuration for this app
795
- *
796
- * @example
797
- * ```ts
798
- * const { provider, config } = await sdk.llm.vectors.getConfig();
799
- * console.log(`App is using ${provider}`);
800
- * ```
801
- */
802
- getConfig(): Promise<VectorConfigResponse>;
803
- }
804
- declare class LLMModule {
805
- private baseUrl;
806
- private appId;
807
- private appName;
808
- private apiKey?;
809
- vectors: VectorStore;
810
- constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
811
- private get headers();
812
- /**
813
- * Request a single permission from Electron via internal API
814
- */
815
- private requestPermission;
816
- /**
817
- * Internal request wrapper that handles automatic permission prompts
818
- */
819
- private request;
820
- /**
821
- * Get only configured chat (LLM) providers
822
- *
823
- * @example
824
- * ```ts
825
- * const { providers } = await sdk.llm.chatProviders();
826
- * console.log('Available chat models:', providers[0].models);
827
- * ```
828
- */
829
- chatProviders(): Promise<ProvidersResponse>;
830
- /**
831
- * Get only configured embedding providers
832
- *
833
- * @example
834
- * ```ts
835
- * const { providers } = await sdk.llm.embedProviders();
836
- * console.log('Available embedding models:', providers[0].models);
837
- * ```
838
- */
839
- embedProviders(): Promise<ProvidersResponse>;
840
- /**
841
- * Send a chat completion request (synchronous)
842
- *
843
- * @example
844
- * ```ts
845
- * const response = await sdk.llm.chat([
846
- * { role: 'system', content: 'You are a helpful assistant.' },
847
- * { role: 'user', content: 'Hello!' }
848
- * ], { model: 'gpt-4o', temperature: 0.7 });
849
- *
850
- * console.log(response.response?.content);
851
- * ```
852
- */
853
- chat(messages: ChatMessage[], options?: ChatOptions): Promise<ChatResponse>;
854
- /**
855
- * Send a streaming chat completion request (SSE)
856
- *
857
- * @example
858
- * ```ts
859
- * for await (const chunk of sdk.llm.chatStream([
860
- * { role: 'user', content: 'Tell me a story' }
861
- * ])) {
862
- * process.stdout.write(chunk.textResponse || '');
863
- * }
864
- * ```
865
- */
866
- chatStream(messages: ChatMessage[], options?: ChatOptions): AsyncGenerator<StreamChunk, void, unknown>;
867
- /**
868
- * Generate vector embeddings from text
869
- *
870
- * @example
871
- * ```ts
872
- * // Single text
873
- * const { embeddings } = await sdk.llm.embed('Hello world');
874
- *
875
- * // Multiple texts
876
- * const { embeddings } = await sdk.llm.embed(['Hello', 'World']);
877
- * ```
878
- */
879
- embed(input: string | string[], options?: EmbedOptions): Promise<EmbedResponse>;
880
- /**
881
- * Helper: Embed text and store as vectors in one call
882
- *
883
- * @example
884
- * ```ts
885
- * await sdk.llm.embedAndStore({
886
- * texts: ['Hello world', 'Goodbye world'],
887
- * documentId: 'doc-123',
888
- * workspaceId: 'ws-456'
889
- * });
890
- * ```
891
- */
892
- embedAndStore(params: {
893
- texts: string[];
894
- documentId?: string;
895
- workspaceId?: string;
896
- idPrefix?: string;
897
- provider?: string;
898
- model?: string;
899
- }): Promise<VectorUpsertResponse>;
900
- /**
901
- * Helper: Search similar documents by text query
902
- *
903
- * @example
904
- * ```ts
905
- * const results = await sdk.llm.search('What is RealtimeX?', {
906
- * topK: 5,
907
- * workspaceId: 'ws-123'
908
- * });
909
- *
910
- * for (const result of results) {
911
- * console.log(result.metadata?.text, result.score);
912
- * }
913
- * ```
914
- */
915
- search(query: string, options?: VectorQueryOptions): Promise<VectorQueryResult[]>;
916
- }
917
-
918
- declare class TTSModule {
919
- private baseUrl;
920
- private appId;
921
- private appName;
922
- private apiKey?;
923
- constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
924
- private get headers();
925
- /**
926
- * Request a single permission from Electron via internal API
927
- */
928
- private requestPermission;
929
- /**
930
- * Internal request wrapper that handles automatic permission prompts
931
- */
932
- private request;
933
- /**
934
- * Generate speech from text (returns full buffer)
935
- *
936
- * @example
937
- * ```ts
938
- * const buffer = await sdk.tts.speak("Hello world");
939
- * // Play buffer...
940
- * ```
941
- */
942
- speak(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
943
- /**
944
- * Generate speech from text with streaming (yields decoded audio chunks)
945
- * Uses SSE internally but returns decoded ArrayBuffer chunks for easy playback.
946
- *
947
- * @example
948
- * ```ts
949
- * for await (const chunk of sdk.tts.speakStream("Hello world")) {
950
- * // chunk.audio is ArrayBuffer (already decoded!)
951
- * const blob = new Blob([chunk.audio], { type: chunk.mimeType });
952
- * const audio = new Audio(URL.createObjectURL(blob));
953
- * await audio.play();
954
- * }
955
- * ```
956
- */
957
- speakStream(text: string, options?: TTSOptions): AsyncGenerator<TTSChunk>;
958
- /**
959
- * List available TTS providers with configuration options
960
- */
961
- listProviders(): Promise<TTSProvider[]>;
962
- }
963
-
964
- declare class STTModule extends ApiModule {
965
- /**
966
- * Get available STT providers and their models.
967
- * @returns Promise resolving to list of providers
968
- */
969
- listProviders(): Promise<STTProvider[]>;
970
- /**
971
- * Listen to microphone and transcribe speech to text.
972
- * Performed on the client device (Electron) via the RealtimeX Hub.
973
- *
974
- * @param options Configuration options for listening
975
- * @returns Promise resolving to the transcribed text
976
- */
977
- listen(options: STTListenOptions): Promise<STTResponse>;
978
- }
979
-
980
- /**
981
- * HTTP Client Module - Smart Client with Auth Handling
982
- */
983
- declare class HttpClient {
984
- private baseUrl;
985
- private appId;
986
- private apiKey?;
987
- private accessToken?;
988
- constructor(baseUrl: string, appId: string, apiKey?: string);
989
- private getAppHeaders;
990
- private getAccessToken;
991
- fetch(endpoint: string, options?: RequestInit): Promise<Response>;
992
- }
993
-
994
- /**
995
- * Agent Module - Simple session-based agent chat
996
- *
997
- * This module provides the simplest way to chat with AI agents:
998
- * 1. Create a session (optional - can just chat directly)
999
- * 2. Send messages (context is automatically maintained)
1000
- * 3. Close session when done (optional - auto-expires)
1001
- */
1002
-
1003
- interface AgentSessionOptions {
1004
- workspace_slug?: string;
1005
- thread_slug?: string;
1006
- agent_name?: string;
1007
- }
1008
- interface AgentSession {
1009
- session_id: string;
1010
- workspace: {
1011
- slug: string;
1012
- name: string;
1013
- };
1014
- thread?: {
1015
- slug: string;
1016
- name: string;
1017
- } | null;
1018
- agent: {
1019
- name: string;
1020
- provider: string;
1021
- model: string | null;
1022
- };
1023
- created_at: string;
1024
- }
1025
- interface AgentChatOptions {
1026
- message: string;
1027
- }
1028
- interface AgentChatResponse {
1029
- id: string;
1030
- session_id: string;
1031
- text: string;
1032
- thoughts: string[];
1033
- message_count: number;
1034
- }
1035
- interface AgentSessionInfo extends AgentSession {
1036
- message_count: number;
1037
- last_message_at: string | null;
1038
- }
1039
- interface StreamChunkEvent {
1040
- type: 'agentThought' | 'textResponse' | 'close' | 'error';
1041
- data: any;
1042
- }
1043
- declare class AgentModule {
1044
- private httpClient;
1045
- constructor(httpClient: HttpClient);
1046
- /**
1047
- * Create a new agent session
1048
- *
1049
- * @example
1050
- * ```typescript
1051
- * const session = await sdk.agent.createSession({
1052
- * workspace_slug: 'my-workspace',
1053
- * agent_name: '@agent'
1054
- * });
1055
- * ```
1056
- */
1057
- createSession(options?: AgentSessionOptions): Promise<AgentSession>;
1058
- /**
1059
- * Chat within a session (synchronous)
1060
- *
1061
- * @example
1062
- * ```typescript
1063
- * const response = await sdk.agent.chat(sessionId, 'Hello agent!');
1064
- * console.log(response.text);
1065
- * ```
1066
- */
1067
- chat(sessionId: string, message: string): Promise<AgentChatResponse>;
1068
- /**
1069
- * Stream chat within a session
1070
- * Returns an async iterator for SSE events
1071
- *
1072
- * @example
1073
- * ```typescript
1074
- * for await (const event of sdk.agent.streamChat(sessionId, 'Tell me a story')) {
1075
- * if (event.type === 'agentThought') {
1076
- * console.log('Thinking:', event.data.thought);
1077
- * } else if (event.type === 'textResponse') {
1078
- * console.log('Response:', event.data.textResponse);
1079
- * }
1080
- * }
1081
- * ```
1082
- */
1083
- streamChat(sessionId: string, message: string): AsyncIterableIterator<StreamChunkEvent>;
1084
- /**
1085
- * Get session information
1086
- *
1087
- * @example
1088
- * ```typescript
1089
- * const info = await sdk.agent.getSession(sessionId);
1090
- * console.log(`Messages sent: ${info.message_count}`);
1091
- * ```
1092
- */
1093
- getSession(sessionId: string): Promise<AgentSessionInfo>;
1094
- /**
1095
- * Close and delete a session
1096
- * Sessions auto-expire after 1 hour, but you can close them manually
1097
- *
1098
- * @example
1099
- * ```typescript
1100
- * await sdk.agent.closeSession(sessionId);
1101
- * ```
1102
- */
1103
- closeSession(sessionId: string): Promise<void>;
1104
- /**
1105
- * Helper: Create session and send first message in one call
1106
- * This is the simplest way to start chatting with an agent
1107
- *
1108
- * @example
1109
- * ```typescript
1110
- * const { session, response } = await sdk.agent.startChat('Hello agent!');
1111
- * console.log(response.text);
1112
- *
1113
- * // Continue chatting in the same session
1114
- * const reply = await sdk.agent.chat(session.session_id, 'Tell me more');
1115
- * ```
1116
- */
1117
- startChat(message: string, options?: AgentSessionOptions): Promise<{
1118
- session: AgentSession;
1119
- response: AgentChatResponse;
1120
- }>;
1121
- }
1122
-
1123
- /**
1124
- * ACP Agent Module — CLI-based agent sessions via ACP bridge
1125
- *
1126
- * Provides session lifecycle, sync/streaming chat, permission resolution,
1127
- * and turn control for CLI agents (Claude, Gemini, Codex, etc.).
1128
- *
1129
- * Unlike AgentModule (LLM API-based), ACP agents spawn CLI processes
1130
- * and can execute commands, read/write files, and interact with tools.
1131
- */
1132
-
1133
- interface AcpAgentInfo {
1134
- id: string;
1135
- label: string;
1136
- handles: string[];
1137
- installed: boolean;
1138
- authReady: boolean;
1139
- version?: string | null;
1140
- status: "installed" | "not_installed";
1141
- /** Present when listAgents({ includeModels: true }). */
1142
- models?: Array<{
1143
- id: string;
1144
- name?: string;
1145
- }>;
1146
- /** "provider_api" | "fallback" — how models were resolved. */
1147
- source?: string | null;
1148
- /** Non-null if model fetch failed and fell back. */
1149
- error?: string | null;
1150
- /** Whether this agent supports using credentials from another provider. */
1151
- supportsProviderForwarding?: boolean;
1152
- /** Provider IDs that can be forwarded (e.g. ["openai", "anthropic"]). */
1153
- forwardableProviders?: string[];
1154
- }
1155
- interface AcpSessionOptions {
1156
- agent_id: string;
1157
- cwd?: string;
1158
- label?: string;
1159
- model?: string;
1160
- approvalPolicy?: "approve-all" | "approve-reads" | "deny-all";
1161
- /** Use another provider's credentials (e.g. "openai"). Agent must support forwarding. */
1162
- forwardedProvider?: string;
1163
- }
1164
- interface AcpSession {
1165
- session_key: string;
1166
- agent_id: string;
1167
- state: "initializing" | "ready" | "stale" | "closed";
1168
- backend_id: string;
1169
- created_at: string;
1170
- }
1171
- interface AcpSessionStatus extends AcpSession {
1172
- runtime_options: AcpRuntimeOptionPatch;
1173
- last_activity_at: string | null;
1174
- last_error?: string;
1175
- }
1176
- interface AcpRuntimeOptionPatch {
1177
- model?: string;
1178
- cwd?: string;
1179
- timeoutSeconds?: number;
1180
- runtimeMode?: string;
1181
- approvalPolicy?: "approve-all" | "approve-reads" | "deny-all";
1182
- extras?: Record<string, string>;
1183
- }
1184
- interface AcpAttachment {
1185
- contentString: string;
1186
- mime: string;
1187
- }
1188
- interface AcpChatResponse {
1189
- text: string;
1190
- stop_reason?: string;
1191
- }
1192
- interface AcpStreamEvent {
1193
- type: "text_delta" | "status" | "tool_call" | "permission_request" | "done" | "error" | "close";
1194
- data: Record<string, unknown>;
1195
- }
1196
- interface AcpPermissionDecision {
1197
- requestId: string;
1198
- optionId: string;
1199
- outcome?: string;
1200
- }
1201
- declare class AcpAgentModule {
1202
- private httpClient;
1203
- constructor(httpClient: HttpClient);
1204
- /** List available CLI agents. Pass includeModels to get model lists per agent. */
1205
- listAgents(opts?: {
1206
- includeModels?: boolean;
1207
- }): Promise<AcpAgentInfo[]>;
1208
- /** Create and initialize a new ACP session. Spawns the CLI agent process. */
1209
- createSession(options: AcpSessionOptions): Promise<AcpSession>;
1210
- /** Get session status and runtime options. */
1211
- getSession(sessionKey: string): Promise<AcpSessionStatus>;
1212
- /** List active ACP sessions owned by this app. */
1213
- listSessions(): Promise<AcpSessionStatus[]>;
1214
- /** Update runtime options (applied on next turn). */
1215
- patchSession(sessionKey: string, patch: AcpRuntimeOptionPatch): Promise<void>;
1216
- /** Close session and stop the agent process. */
1217
- closeSession(sessionKey: string, reason?: string): Promise<void>;
1218
- /**
1219
- * Synchronous turn — waits for completion, returns full response.
1220
- * Requires approvalPolicy set on the session (via create or patchSession).
1221
- */
1222
- chat(sessionKey: string, message: string, attachments?: AcpAttachment[]): Promise<AcpChatResponse>;
1223
- /**
1224
- * Streaming turn via SSE. Yields events as they arrive.
1225
- *
1226
- * Uses named SSE events (event: + data: lines). The event type comes
1227
- * from the `event:` line, not from inside the JSON payload.
1228
- *
1229
- * @example
1230
- * ```typescript
1231
- * for await (const event of sdk.acpAgent.streamChat(key, 'Explain this')) {
1232
- * if (event.type === 'text_delta') console.log(event.data.text);
1233
- * if (event.type === 'permission_request') {
1234
- * await sdk.acpAgent.resolvePermission(key, {
1235
- * requestId: event.data.requestId as string,
1236
- * optionId: 'allow_once',
1237
- * });
1238
- * }
1239
- * }
1240
- * ```
1241
- */
1242
- streamChat(sessionKey: string, message: string, attachments?: AcpAttachment[]): AsyncIterableIterator<AcpStreamEvent>;
1243
- /** Cancel the active turn on a session. */
1244
- cancelTurn(sessionKey: string, reason?: string): Promise<void>;
1245
- /** Resolve a pending permission request (call while SSE stream is active). */
1246
- resolvePermission(sessionKey: string, decision: AcpPermissionDecision): Promise<{
1247
- resolved: boolean;
1248
- reason?: string;
1249
- }>;
1250
- /** Convenience: create session + first sync chat in one call. */
1251
- startChat(message: string, options: AcpSessionOptions): Promise<{
1252
- session: AcpSession;
1253
- response: AcpChatResponse;
1254
- }>;
1255
- }
1256
-
1257
- /**
1258
- * MCP Module - Interact with MCP servers via RealtimeX SDK
1259
- */
1260
-
1261
- interface MCPServer {
1262
- /** Unique server name (slug) */
1263
- name: string;
1264
- /** User-friendly display name */
1265
- display_name: string;
1266
- /** Server description */
1267
- description: string | null;
1268
- /** Server type: 'stdio', 'http', 'sse', or 'remote' */
1269
- server_type: string;
1270
- /** Whether the server is enabled */
1271
- enabled: boolean;
1272
- /** Provider: 'local' or 'remote' */
1273
- provider: 'local' | 'remote';
1274
- /** Tags / categories */
1275
- tags: string[];
1276
- }
1277
- interface MCPTool {
1278
- /** Tool name */
1279
- name: string;
1280
- /** Tool description */
1281
- description: string | null;
1282
- /** JSON Schema describing the tool's input parameters */
1283
- input_schema: Record<string, any>;
1284
- }
1285
- interface MCPToolResult {
1286
- /** Whether the execution was successful */
1287
- success: boolean;
1288
- /** Server that executed the tool */
1289
- server: string;
1290
- /** Tool that was executed */
1291
- tool: string;
1292
- /** Provider used */
1293
- provider: string;
1294
- /** Execution result data */
1295
- result: any;
1296
- /** Error message if failed */
1297
- error?: string;
1298
- }
1299
- declare class MCPModule extends ApiModule {
1300
- constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
1301
- /**
1302
- * List configured MCP servers.
1303
- * @param provider - Filter by provider: 'local', 'remote', or 'all' (default: 'all')
1304
- * @returns Array of MCP server objects
1305
- */
1306
- getServers(provider?: 'local' | 'remote' | 'all'): Promise<MCPServer[]>;
1307
- /**
1308
- * List available tools for a specific MCP server.
1309
- * @param serverName - The server name (slug)
1310
- * @param provider - Provider: 'local' or 'remote' (default: 'local')
1311
- * @returns Array of tool objects with name, description, and input schema
1312
- */
1313
- getTools(serverName: string, provider?: 'local' | 'remote'): Promise<MCPTool[]>;
1314
- /**
1315
- * Execute a tool on an MCP server.
1316
- * @param serverName - The server name (slug)
1317
- * @param toolName - The tool name to execute
1318
- * @param args - Arguments to pass to the tool (matches tool's input_schema)
1319
- * @param provider - Provider: 'local' or 'remote' (default: 'local')
1320
- * @returns Tool execution result
1321
- */
1322
- executeTool(serverName: string, toolName: string, args?: Record<string, any>, provider?: 'local' | 'remote'): Promise<any>;
1323
- }
1324
-
1325
- declare const LOCAL_APP_CONTRACT_VERSION = "local-app-contract/v1";
1326
- declare const CONTRACT_SIGNATURE_HEADER = "x-rtx-contract-signature";
1327
- declare const CONTRACT_EVENT_ID_HEADER = "x-rtx-event-id";
1328
- declare const CONTRACT_SIGNATURE_ALGORITHM = "sha256";
1329
- declare const CONTRACT_ATTEMPT_PREFIX = "run-";
1330
- interface ContractSignInput {
1331
- secret: string;
1332
- eventId?: string;
1333
- eventType: ContractEventType | string;
1334
- taskId: string;
1335
- attemptId?: string | number | null;
1336
- timestamp?: string | null;
1337
- payload?: unknown;
1338
- }
1339
- declare function normalizeContractEvent(eventLike?: string | null): ContractEventType | null;
1340
- declare function normalizeAttemptId(attemptLike?: string | number | null): string | undefined;
1341
- declare function parseAttemptRunId(attemptLike?: string | number | null): number | null;
1342
- declare function hashContractPayload(payload: unknown): string;
1343
- declare function createContractEventId(): string;
1344
- declare function buildContractSignatureMessage({ eventId, eventType, taskId, attemptId, timestamp, payload, }: Omit<ContractSignInput, 'secret'>): string;
1345
- declare function signContractEvent(input: ContractSignInput): string;
1346
- declare function canonicalEventToLegacyAction(eventLike: string): string | null;
1347
- declare function buildContractIdempotencyKey({ taskId, eventType, eventId, attemptId, machineId, timestamp, payload, }: {
1348
- taskId: string;
1349
- eventType: string;
1350
- eventId?: string | null;
1351
- attemptId?: string | number | null;
1352
- machineId?: string | null;
1353
- timestamp?: string | null;
1354
- payload?: unknown;
1355
- }): string;
1356
- declare class ContractModule {
1357
- private readonly realtimexUrl;
1358
- private readonly appName?;
1359
- private readonly appId?;
1360
- private readonly apiKey?;
1361
- private cachedContract;
1362
- private cachedCapabilities;
1363
- private cachedCapabilityCatalogHash;
1364
- constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
1365
- private requestPermission;
1366
- private request;
1367
- getLocalAppV1(forceRefresh?: boolean): Promise<LocalAppContractDefinition>;
1368
- listCapabilities(forceRefresh?: boolean): Promise<ContractCapability$1[]>;
1369
- searchCapabilities(query: string): Promise<ContractCapability$1[]>;
1370
- describeCapability(capabilityId: string): Promise<ContractCapability$1>;
1371
- search(query: string): Promise<ContractCapability$1[]>;
1372
- describe(capabilityId: string): Promise<ContractCapability$1>;
1373
- invoke(payload: ContractInvokePayload): Promise<TriggerAgentResponse>;
1374
- getCachedCatalogHash(): string | null;
1375
- clearCache(): void;
1376
- }
1377
-
1378
- type ProviderKind = 'gemini' | 'claude' | 'codex';
1379
- type ContractStrictness = 'compatible' | 'strict';
1380
- interface ContractCallbackRules {
1381
- event_id_header?: string;
1382
- signature_header?: string;
1383
- signature_algorithm?: string;
1384
- signature_message?: string;
1385
- attempt_id_format?: string;
1386
- idempotency?: string;
1387
- }
1388
- interface ContractCapabilityTrigger {
1389
- event: 'task.trigger';
1390
- route?: string;
1391
- payload_template?: Record<string, unknown>;
1392
- }
1393
- interface ContractCapability {
1394
- capability_id: string;
1395
- name: string;
1396
- description: string;
1397
- input_schema: Record<string, unknown>;
1398
- output_schema?: Record<string, unknown>;
1399
- permission: string;
1400
- trigger: ContractCapabilityTrigger;
1401
- }
1402
- interface LocalAppContractV1 {
1403
- contract_version: 'local-app-contract/v1';
1404
- strictness: ContractStrictness;
1405
- supported_contract_events: string[];
1406
- supported_legacy_events?: string[];
1407
- aliases?: Record<string, string>;
1408
- status_map?: Record<string, string>;
1409
- legacy_action_map?: Record<string, string>;
1410
- callback?: ContractCallbackRules;
1411
- capabilities?: ContractCapability[];
1412
- }
1413
- interface LegacyLocalAppContractShape {
1414
- id?: string;
1415
- version?: string;
1416
- strictness?: ContractStrictness;
1417
- supported_events?: string[];
1418
- supported_contract_events?: string[];
1419
- supported_legacy_events?: string[];
1420
- aliases?: Record<string, string>;
1421
- status_map?: Record<string, string>;
1422
- legacy_action_map?: Record<string, string>;
1423
- callback?: ContractCallbackRules;
1424
- capabilities?: ContractCapability[];
1425
- }
1426
- interface ContractDiscoveryResponse {
1427
- success: boolean;
1428
- contract: LocalAppContractV1 | LegacyLocalAppContractShape;
1429
- }
1430
-
1431
- interface ProjectToolsInput {
1432
- contract: LocalAppContractV1;
1433
- provider: ProviderKind;
1434
- appId: string;
1435
- namespace?: string;
1436
- }
1437
- interface CanonicalToolDefinition {
1438
- tool_name: string;
1439
- title: string;
1440
- description: string;
1441
- input_schema: Record<string, unknown>;
1442
- output_schema?: Record<string, unknown>;
1443
- permission: string;
1444
- capability_id: string;
1445
- trigger: ContractCapability['trigger'];
1446
- }
1447
- interface HostToolAdapter<TProviderTool, TProviderToolCall, TProviderResult> {
1448
- toProviderTools(tools: CanonicalToolDefinition[]): TProviderTool[];
1449
- fromProviderToolCall(call: TProviderToolCall): {
1450
- tool_call_id: string;
1451
- tool_name: string;
1452
- args: Record<string, unknown>;
1453
- };
1454
- toProviderResult(result: {
1455
- status: 'completed' | 'failed' | 'queued';
1456
- tool_call_id?: string;
1457
- task_id?: string;
1458
- attempt_id?: string;
1459
- output?: Record<string, unknown>;
1460
- error?: {
1461
- code: string;
1462
- message: string;
1463
- retryable: boolean;
1464
- };
1465
- }): TProviderResult;
1466
- }
1467
-
1468
- interface ToolCall {
1469
- tool_call_id: string;
1470
- tool_name: string;
1471
- args: Record<string, unknown>;
1472
- }
1473
- interface ExecutionContext {
1474
- appId: string;
1475
- userId: string;
1476
- workspaceId?: string;
1477
- requestId?: string;
1478
- idempotencyKey?: string;
1479
- provider?: ProviderKind;
1480
- namespace?: string;
1481
- metadata?: Record<string, unknown>;
1482
- }
1483
- interface ExecutionResult {
1484
- status: 'completed' | 'failed' | 'queued';
1485
- tool_call_id?: string;
1486
- task_id?: string;
1487
- attempt_id?: string;
1488
- output?: Record<string, unknown>;
1489
- error?: {
1490
- code: string;
1491
- message: string;
1492
- retryable: boolean;
1493
- };
1494
- }
1495
- type LifecycleEventType = 'task.claimed' | 'task.started' | 'task.progress' | 'task.completed' | 'task.failed' | 'task.canceled';
1496
- interface RuntimeExecutionEvent {
1497
- tool_call_id: string;
1498
- task_id: string;
1499
- attempt_id?: string;
1500
- event_type: LifecycleEventType;
1501
- event_id: string;
1502
- timestamp: string;
1503
- payload?: Record<string, unknown>;
1504
- }
1505
- interface GetToolsInput {
1506
- appId: string;
1507
- provider: ProviderKind;
1508
- namespace?: string;
1509
- }
1510
- interface IngestExecutionEventInput {
1511
- event?: string;
1512
- event_type?: string;
1513
- event_id?: string;
1514
- task_id?: string;
1515
- task_uuid?: string;
1516
- attempt_id?: string | number | null;
1517
- tool_call_id?: string;
1518
- timestamp?: string;
1519
- payload?: Record<string, unknown>;
1520
- data?: Record<string, unknown>;
1521
- [key: string]: unknown;
1522
- }
1523
- interface ContractRuntimeInterface {
1524
- getContract(appId: string): Promise<LocalAppContractV1>;
1525
- getTools(input: GetToolsInput): Promise<CanonicalToolDefinition[]>;
1526
- executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
1527
- onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
1528
- }
1529
-
1530
- interface RetryPolicyOptions {
1531
- maxAttempts?: number;
1532
- baseDelayMs?: number;
1533
- maxDelayMs?: number;
1534
- shouldRetry?: (error: unknown, attempt: number) => boolean;
1535
- }
1536
- declare class RetryPolicy {
1537
- private readonly maxAttempts;
1538
- private readonly baseDelayMs;
1539
- private readonly maxDelayMs;
1540
- private readonly shouldRetry;
1541
- constructor(options?: RetryPolicyOptions);
1542
- execute<T>(operation: (attempt: number) => Promise<T>): Promise<T>;
1543
- }
1544
-
1545
- interface ContractRuntimeOptions {
1546
- baseUrl: string;
1547
- appId?: string;
1548
- appName?: string;
1549
- apiKey?: string;
1550
- permissions?: string[];
1551
- namespace?: string;
1552
- fetchImpl?: typeof fetch;
1553
- cacheTtlMs?: number;
1554
- retry?: RetryPolicyOptions;
1555
- }
1556
- declare class ContractRuntime implements ContractRuntimeInterface {
1557
- private readonly appId?;
1558
- private readonly appName?;
1559
- private readonly defaultNamespace?;
1560
- private readonly contractClient;
1561
- private readonly toolProjector;
1562
- private readonly executionStore;
1563
- private readonly lifecycleReporter;
1564
- private readonly scopeGuard;
1565
- private readonly retryPolicy;
1566
- private readonly httpClient;
1567
- constructor(options: ContractRuntimeOptions);
1568
- getContract(appId: string): Promise<LocalAppContractV1>;
1569
- getTools(input: GetToolsInput): Promise<CanonicalToolDefinition[]>;
1570
- executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
1571
- onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
1572
- ingestExecutionEvent(input: IngestExecutionEventInput): RuntimeExecutionEvent | null;
1573
- clearCache(): void;
1574
- private assertAppContext;
1575
- private buildRegistryKey;
1576
- private resolveTaskId;
1577
- private buildTriggerRequestBody;
1578
- private validateToolArgs;
1579
- private matchesType;
1580
- private tryEmitLifecycleEvent;
1581
- private toFailedResult;
1582
- }
1583
-
1584
- /**
1585
- * Database Module - Retrieve Supabase config from RealtimeX Main App
1586
- *
1587
- * Allows Local Apps to fetch their database configuration (URL, anonKey, mode)
1588
- * without hardcoding them.
1589
- */
1590
- interface DatabaseConfig {
1591
- url: string;
1592
- anonKey: string;
1593
- mode: 'compatible' | 'custom';
1594
- tables: string[];
1595
- max_concurrent_tasks: number;
1596
- }
1597
- declare class DatabaseModule {
1598
- private baseUrl;
1599
- private appId;
1600
- private apiKey?;
1601
- constructor(realtimexUrl: string, appId: string, apiKey?: string);
1602
- private getHeaders;
1603
- /**
1604
- * Get the Supabase database configuration for this app.
1605
- * Returns URL, anonKey, mode, and tables.
1606
- *
1607
- * @example
1608
- * ```ts
1609
- * const config = await sdk.database.getConfig();
1610
- * const supabase = createClient(config.url, config.anonKey);
1611
- * ```
1612
- */
1613
- getConfig(): Promise<DatabaseConfig>;
1614
10
  }
1615
11
 
1616
12
  /**
1617
- * Auth Module - Authentication helpers for RealtimeX SDK
13
+ * RealtimeX SDK
1618
14
  *
1619
- * Provides:
1620
- * - syncSupabaseToken(): Push Supabase JWT to Main App for RLS-aware operations
1621
- * - getAccessToken(): Retrieve the Keycloak access token from Main App (existing endpoint)
1622
- */
1623
- interface AuthTokenResponse {
1624
- token: string;
1625
- hasToken: boolean;
1626
- syncedAt: string | null;
1627
- source: string | null;
1628
- }
1629
- interface SyncTokenResponse {
1630
- success: boolean;
1631
- message: string;
1632
- hasToken: boolean;
1633
- syncedAt: string | null;
1634
- source: string | null;
1635
- }
1636
- declare class AuthModule {
1637
- private baseUrl;
1638
- private appId;
1639
- private apiKey?;
1640
- constructor(realtimexUrl: string, appId: string, apiKey?: string);
1641
- private getHeaders;
1642
- /**
1643
- * Push a Supabase access token to the Main App.
1644
- * This enables Main App to use the token for:
1645
- * - Realtime subscriptions (bypass RLS)
1646
- * - CRUD operations on rtx_activities (bypass RLS)
1647
- *
1648
- * @param token - Supabase JWT from supabase.auth.signIn()
1649
- *
1650
- * @example
1651
- * ```ts
1652
- * const { data } = await supabase.auth.signInWithPassword({ email, password });
1653
- * await sdk.auth.syncSupabaseToken(data.session.access_token);
1654
- * ```
1655
- */
1656
- syncSupabaseToken(token: string): Promise<SyncTokenResponse>;
1657
- /**
1658
- * Retrieve the current Keycloak access token from Main App.
1659
- * This is the existing Token Vending Machine endpoint.
1660
- *
1661
- * @returns The access token info, or null if no token is available.
1662
- */
1663
- getAccessToken(): Promise<AuthTokenResponse | null>;
1664
- }
1665
-
1666
- /**
1667
- * Credentials Module — read-only access to user-managed credentials
1668
- *
1669
- * Credential values are encrypted at rest and decrypted only on get().
1670
- * Values should NEVER be printed to stdout or included in agent responses.
1671
- */
1672
-
1673
- interface CredentialInfo {
1674
- name: string;
1675
- type: "http_header" | "query_auth" | "basic_auth" | "env_var";
1676
- metadata: Record<string, any> | null;
1677
- }
1678
- interface CredentialPayload {
1679
- name: string;
1680
- type: string;
1681
- payload: Record<string, string>;
1682
- }
1683
- declare class CredentialsModule {
1684
- private httpClient;
1685
- constructor(httpClient: HttpClient);
1686
- /** List available credentials (names and types, no values). */
1687
- list(): Promise<CredentialInfo[]>;
1688
- /** Get a credential's decrypted payload by name. */
1689
- get(name: string): Promise<CredentialPayload>;
1690
- }
1691
-
1692
- interface ContractHttpClientConfig {
1693
- baseUrl: string;
1694
- appId?: string;
1695
- appName?: string;
1696
- apiKey?: string;
1697
- fetchImpl?: typeof fetch;
1698
- }
1699
- declare class ContractHttpClient {
1700
- private readonly baseUrl;
1701
- private readonly appId?;
1702
- private readonly appName?;
1703
- private readonly apiKey?;
1704
- private readonly fetchImpl;
1705
- constructor(config: ContractHttpClientConfig);
1706
- get<T>(path: string, headers?: HeadersInit): Promise<T>;
1707
- post<T>(path: string, body: unknown, headers?: HeadersInit): Promise<T>;
1708
- request<T>(path: string, options?: RequestInit): Promise<T>;
1709
- private buildHeaders;
1710
- private parseResponse;
1711
- }
1712
-
1713
- declare class ContractCache {
1714
- private readonly ttlMs;
1715
- private readonly entries;
1716
- constructor(ttlMs?: number);
1717
- get(key: string): LocalAppContractV1 | null;
1718
- set(key: string, value: LocalAppContractV1): void;
1719
- clear(key?: string): void;
1720
- }
1721
-
1722
- interface ContractClientOptions {
1723
- cache?: ContractCache;
1724
- cacheKey?: string;
1725
- }
1726
- declare class ContractClient {
1727
- private readonly httpClient;
1728
- private readonly cache;
1729
- private readonly cacheKey;
1730
- constructor(httpClient: ContractHttpClient, options?: ContractClientOptions);
1731
- getLocalAppV1(forceRefresh?: boolean): Promise<LocalAppContractV1>;
1732
- clearCache(): void;
1733
- }
1734
-
1735
- declare function normalizeLocalAppContractV1(payload: unknown): LocalAppContractV1;
1736
-
1737
- declare class ToolProjector {
1738
- project(input: ProjectToolsInput): CanonicalToolDefinition[];
1739
- private ensureUniqueToolName;
1740
- }
1741
-
1742
- declare function normalizeSchema(schema?: Record<string, unknown>): Record<string, unknown>;
1743
-
1744
- declare function toStableToolName(capabilityId: string, namespace?: string): string;
1745
-
1746
- declare class ScopeGuard {
1747
- private readonly scopes;
1748
- constructor(scopes?: string[]);
1749
- can(permission?: string): boolean;
1750
- assert(permission?: string): void;
1751
- }
1752
-
1753
- interface AuthProvider {
1754
- buildHeaders(baseHeaders?: Record<string, string>): Record<string, string>;
1755
- }
1756
- interface StaticAuthProviderOptions {
1757
- appId?: string;
1758
- appName?: string;
1759
- apiKey?: string;
1760
- }
1761
- declare class StaticAuthProvider implements AuthProvider {
1762
- private readonly appId?;
1763
- private readonly appName?;
1764
- private readonly apiKey?;
1765
- constructor(options?: StaticAuthProviderOptions);
1766
- buildHeaders(baseHeaders?: Record<string, string>): Record<string, string>;
1767
- }
1768
-
1769
- declare class ContractError extends Error {
1770
- readonly code: string;
1771
- readonly details?: unknown;
1772
- constructor(code: string, message: string, details?: unknown);
1773
- }
1774
- declare class ContractValidationError extends ContractError {
1775
- constructor(message: string, details?: unknown);
1776
- }
1777
- declare class ToolValidationError extends ContractError {
1778
- constructor(message: string, details?: unknown);
1779
- }
1780
- declare class ToolNotFoundError extends ContractError {
1781
- constructor(toolName: string, details?: unknown);
1782
- }
1783
- declare class ScopeDeniedError extends ContractError {
1784
- constructor(permission: string, details?: unknown);
1785
- }
1786
- declare class RuntimeTransportError extends ContractError {
1787
- readonly statusCode?: number;
1788
- constructor(message: string, statusCode?: number, details?: unknown);
1789
- }
1790
-
1791
- interface GeminiFunctionDeclaration {
1792
- name: string;
1793
- description?: string;
1794
- parameters?: Record<string, unknown>;
1795
- }
1796
- interface GeminiToolCall {
1797
- id: string;
1798
- name: string;
1799
- args?: Record<string, unknown> | string;
1800
- }
1801
- interface GeminiToolResult {
1802
- tool_call_id: string;
1803
- status: ExecutionResult['status'];
1804
- payload: Record<string, unknown>;
1805
- }
1806
- declare class GeminiToolAdapter implements HostToolAdapter<GeminiFunctionDeclaration, GeminiToolCall, GeminiToolResult> {
1807
- toProviderTools(tools: CanonicalToolDefinition[]): GeminiFunctionDeclaration[];
1808
- fromProviderToolCall(call: GeminiToolCall): ToolCall;
1809
- toProviderResult(result: ExecutionResult): GeminiToolResult;
1810
- }
1811
-
1812
- interface ClaudeToolDefinition {
1813
- name: string;
1814
- description: string;
1815
- input_schema: Record<string, unknown>;
1816
- }
1817
- interface ClaudeToolCall {
1818
- id: string;
1819
- name: string;
1820
- input?: Record<string, unknown>;
1821
- }
1822
- interface ClaudeToolResult {
1823
- type: 'tool_result';
1824
- tool_use_id: string;
1825
- content: string;
1826
- is_error?: boolean;
1827
- }
1828
- declare class ClaudeToolAdapter implements HostToolAdapter<ClaudeToolDefinition, ClaudeToolCall, ClaudeToolResult> {
1829
- toProviderTools(tools: CanonicalToolDefinition[]): ClaudeToolDefinition[];
1830
- fromProviderToolCall(call: ClaudeToolCall): ToolCall;
1831
- toProviderResult(result: ExecutionResult): ClaudeToolResult;
1832
- }
1833
-
1834
- interface CodexToolDefinition {
1835
- type: 'function';
1836
- function: {
1837
- name: string;
1838
- description: string;
1839
- parameters: Record<string, unknown>;
1840
- };
1841
- }
1842
- interface CodexToolCall {
1843
- id: string;
1844
- function: {
1845
- name: string;
1846
- arguments?: string | Record<string, unknown>;
1847
- };
1848
- }
1849
- interface CodexToolResult {
1850
- tool_call_id: string;
1851
- output: string;
1852
- is_error?: boolean;
1853
- }
1854
- declare class CodexToolAdapter implements HostToolAdapter<CodexToolDefinition, CodexToolCall, CodexToolResult> {
1855
- toProviderTools(tools: CanonicalToolDefinition[]): CodexToolDefinition[];
1856
- fromProviderToolCall(call: CodexToolCall): ToolCall;
1857
- toProviderResult(result: ExecutionResult): CodexToolResult;
1858
- }
1859
-
1860
- type ACPToolKind = 'read' | 'edit' | 'delete' | 'move' | 'search' | 'execute' | 'think' | 'fetch' | 'other';
1861
- type ACPToolStatus = 'pending' | 'in_progress' | 'completed' | 'failed';
1862
- interface ACPTextContent {
1863
- type: 'text';
1864
- text: string;
1865
- }
1866
- interface ACPSessionToolUpdate {
1867
- type: 'tool_call' | 'tool_call_update';
1868
- toolCallId: string;
1869
- title?: string;
1870
- kind?: ACPToolKind;
1871
- status: ACPToolStatus;
1872
- content?: ACPTextContent[];
1873
- rawInput?: Record<string, unknown>;
1874
- rawOutput?: Record<string, unknown>;
1875
- _meta?: Record<string, unknown>;
1876
- }
1877
- interface ACPSessionUpdateParams {
1878
- sessionId: string;
1879
- update: ACPSessionToolUpdate;
1880
- }
1881
- interface ACPNotifier {
1882
- notify(method: 'session/update', params: ACPSessionUpdateParams): Promise<void>;
1883
- request?<T = unknown>(method: string, params: Record<string, unknown>): Promise<T>;
1884
- }
1885
- interface ACPAdapterContext {
1886
- sessionId: string;
1887
- appId: string;
1888
- userId: string;
1889
- workspaceId?: string;
1890
- provider?: 'gemini' | 'claude' | 'codex';
1891
- namespace?: string;
1892
- }
1893
- interface ACPToolInvocation {
1894
- toolCallId: string;
1895
- toolName: string;
1896
- args: Record<string, unknown>;
1897
- title?: string;
1898
- kind?: ACPToolKind;
1899
- }
1900
- interface ACPExecutionReference {
1901
- sessionId: string;
1902
- toolCallId: string;
1903
- appId: string;
1904
- userId: string;
1905
- workspaceId?: string;
1906
- provider?: 'gemini' | 'claude' | 'codex';
1907
- namespace?: string;
1908
- title?: string;
1909
- kind?: ACPToolKind;
1910
- }
1911
- interface PermissionOption {
1912
- id: string;
1913
- label: string;
1914
- kind?: 'allow_once' | 'allow_always' | 'deny_once' | 'deny_always';
1915
- }
1916
- interface ACPContractRuntime {
1917
- executeToolCall(call: ToolCall, context: ExecutionContext): Promise<ExecutionResult>;
1918
- onExecutionEvent(handler: (event: RuntimeExecutionEvent) => void): () => void;
1919
- ingestExecutionEvent(input: IngestExecutionEventInput): RuntimeExecutionEvent | null;
1920
- }
1921
- interface ACPContractAdapterOptions {
1922
- runtime: ACPContractRuntime;
1923
- notifier: ACPNotifier;
1924
- requestPermission?: boolean;
1925
- buildPermissionOptions?: (input: ACPToolInvocation) => PermissionOption[];
1926
- telemetry?: ACPAdapterTelemetrySink;
1927
- }
1928
- interface ACPAdapterTelemetryEvent {
1929
- phase: 'execute' | 'notify' | 'permission' | 'runtime_event' | 'ingest';
1930
- result: 'ok' | 'failed' | 'skipped';
1931
- sessionId?: string;
1932
- toolCallId?: string;
1933
- toolName?: string;
1934
- taskId?: string;
1935
- attemptId?: string;
1936
- eventId?: string;
1937
- eventType?: string;
1938
- status?: ACPToolStatus;
1939
- error?: string;
1940
- metadata?: Record<string, unknown>;
1941
- }
1942
- interface ACPAdapterTelemetrySink {
1943
- emit(event: ACPAdapterTelemetryEvent): void | Promise<void>;
1944
- }
1945
-
1946
- declare class ACPContractAdapter {
1947
- private readonly runtime;
1948
- private readonly notifier;
1949
- private readonly mapper;
1950
- private readonly permissionBridge;
1951
- private readonly telemetry;
1952
- private readonly taskReferences;
1953
- private readonly toolCallReferences;
1954
- private readonly runtimeUnsubscribe;
1955
- constructor(options: ACPContractAdapterOptions);
1956
- dispose(): void;
1957
- executeTool(invocation: ACPToolInvocation, context: ACPAdapterContext): Promise<ExecutionResult>;
1958
- ingestContractCallback(payload: Record<string, unknown>, context: Pick<ACPAdapterContext, 'sessionId'>): RuntimeExecutionEvent | null;
1959
- private handleRuntimeEvent;
1960
- private resolveReferenceForEvent;
1961
- private rememberReference;
1962
- private cleanupReference;
1963
- private notify;
1964
- }
1965
-
1966
- declare class ACPEventMapper {
1967
- createReference(invocation: ACPToolInvocation, context: ACPAdapterContext): ACPExecutionReference;
1968
- buildPendingUpdate(invocation: ACPToolInvocation, reference: ACPExecutionReference): ACPSessionUpdateParams;
1969
- buildResultUpdate(result: ExecutionResult, reference: ACPExecutionReference): ACPSessionUpdateParams;
1970
- buildLifecycleUpdate(event: RuntimeExecutionEvent, reference: ACPExecutionReference): ACPSessionUpdateParams | null;
1971
- buildNotifyFailureUpdate(reference: ACPExecutionReference, error: unknown): ACPSessionUpdateParams;
1972
- mapContractEventStatus(eventType: string): ACPToolStatus | null;
1973
- private mapExecutionResultStatus;
1974
- private resolveEventText;
1975
- }
1976
-
1977
- interface ACPPermissionBridgeOptions {
1978
- notifier: ACPNotifier;
1979
- enabled: boolean;
1980
- buildPermissionOptions?: (input: ACPToolInvocation) => PermissionOption[];
1981
- }
1982
- declare class ACPPermissionBridge {
1983
- private readonly notifier;
1984
- private readonly enabled;
1985
- private readonly buildPermissionOptions?;
1986
- constructor(options: ACPPermissionBridgeOptions);
1987
- requestToolPermission(invocation: ACPToolInvocation, context: ACPAdapterContext): Promise<boolean>;
1988
- }
1989
-
1990
- declare class ACPTelemetry {
1991
- private readonly sink?;
1992
- constructor(sink?: ACPAdapterTelemetrySink);
1993
- emit(event: ACPAdapterTelemetryEvent): void;
1994
- }
1995
-
1996
- /**
1997
- * RealtimeX Local App SDK
1998
- *
1999
- * SDK for building Local Apps that integrate with RealtimeX
2000
- * All operations go through RealtimeX Main App proxy
15
+ * Milestone 1 SDK surface: generated Developer API v1 modules for workspace,
16
+ * thread, and chat.
2001
17
  */
2002
18
 
2003
19
  declare class RealtimeXSDK {
2004
- activities: ActivitiesModule;
2005
- webhook: WebhookModule;
2006
- api: ApiModule;
2007
- task: TaskModule;
2008
- port: PortModule;
2009
- llm: LLMModule;
2010
- tts: TTSModule;
2011
- stt: STTModule;
2012
- agent: AgentModule;
2013
- acpAgent: AcpAgentModule;
2014
- mcp: MCPModule;
2015
- contract: ContractModule;
2016
- contractRuntime: ContractRuntime;
2017
- database: DatabaseModule;
2018
- auth: AuthModule;
2019
- credentials: CredentialsModule;
2020
- /**
2021
- * Developer API (v1) — requires apiKey to be set in config.
2022
- * Provides access to workspace management, admin, documents, system settings, and more.
2023
- */
2024
- v1: V1ApiNamespace | undefined;
2025
- /**
2026
- * Desktop terminal sessions — top-level alias for the desktop runtime session APIs.
2027
- * Backed by `sdk.v1.desktopRuntimeSessions` for compatibility with generated v1 modules.
2028
- */
2029
- desktopRuntimeSessions: V1DesktopRuntimeSessionsModule | undefined;
2030
- /**
2031
- * Desktop browser control — top-level alias for the RealTimeX Browser session and tab APIs.
2032
- * Backed by `sdk.v1.desktopBrowser` for compatibility with generated v1 modules.
2033
- */
2034
- desktopBrowser: V1DesktopBrowserModule | undefined;
2035
20
  readonly appId: string;
2036
- readonly appName: string | undefined;
2037
21
  readonly apiKey: string | undefined;
2038
- private readonly realtimexUrl;
2039
- private readonly permissions;
2040
- private httpClient;
22
+ readonly realtimexUrl: string;
23
+ readonly v1: V1ApiNamespace;
2041
24
  private static DEFAULT_REALTIMEX_URL;
2042
25
  constructor(config?: SDKConfig);
2043
- /**
2044
- * Register app with RealtimeX hub and request declared permissions upfront.
2045
- * This is called automatically if permissions are provided in constructor.
2046
- */
2047
- register(permissions?: string[]): Promise<void>;
2048
- /**
2049
- * Get environment variable (works in Node.js and browser)
2050
- */
2051
26
  private getEnvVar;
2052
- /**
2053
- * Ping RealtimeX server to verify connection and authentication.
2054
- * Works in both development (API Key) and production (App ID) modes.
2055
- */
2056
- ping(): Promise<{
2057
- success: boolean;
2058
- mode: 'development' | 'production';
2059
- appId?: string;
2060
- timestamp: string;
2061
- }>;
2062
- /**
2063
- * Get the absolute path to the data directory for this app.
2064
- * Path: ~/.realtimex.ai/Resources/local-apps/{appId}
2065
- */
2066
- getAppDataDir(): Promise<string>;
2067
27
  }
2068
28
 
2069
- export { type ACPAdapterContext, type ACPAdapterTelemetryEvent, type ACPAdapterTelemetrySink, ACPContractAdapter, type ACPContractAdapterOptions, type ACPContractRuntime, ACPEventMapper, type ACPExecutionReference, type ACPNotifier, ACPPermissionBridge, type ACPSessionToolUpdate, type ACPSessionUpdateParams, ACPTelemetry, type ACPTextContent, type ACPToolInvocation, type ACPToolKind, type ACPToolStatus, type AcpAgentInfo, AcpAgentModule, type AcpAttachment, type AcpChatResponse, type AcpPermissionDecision, type AcpRuntimeOptionPatch, type AcpSession, type AcpSessionOptions, type AcpSessionStatus, type AcpStreamEvent, ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, AuthModule, type AuthProvider, type AuthTokenResponse, CONTRACT_ATTEMPT_PREFIX, CONTRACT_EVENT_ID_HEADER, CONTRACT_SIGNATURE_ALGORITHM, CONTRACT_SIGNATURE_HEADER, type CanonicalToolDefinition, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, ClaudeToolAdapter, type ClaudeToolCall, type ClaudeToolDefinition, type ClaudeToolResult, CodexToolAdapter, type CodexToolCall, type CodexToolDefinition, type CodexToolResult, ContractCache, type ContractCallbackMetadata, type ContractCallbackRules, type ContractCapability, type ContractCapabilityTrigger, ContractClient, type ContractClientOptions, type ContractDiscoveryResponse, ContractError, type ContractEventType, ContractHttpClient, type ContractHttpClientConfig, type ContractInvokePayload, ContractModule, ContractRuntime, type ContractRuntimeInterface, type ContractRuntimeOptions, type ContractSignInput, type ContractStrictness, ContractValidationError, type DatabaseConfig, DatabaseModule, type EmbedOptions, type EmbedResponse, type ExecutionContext, type ExecutionResult, type GeminiFunctionDeclaration, GeminiToolAdapter, type GeminiToolCall, type GeminiToolResult, type GetToolsInput, type HostToolAdapter, type IngestExecutionEventInput, LLMModule, LLMPermissionError, LLMProviderError, LOCAL_APP_CONTRACT_VERSION, type LegacyLocalAppContractShape, type LifecycleEventType, type LocalAppCapabilitiesResponse, type LocalAppCapabilityDetailResponse, type LocalAppCapabilitySearchResponse, type LocalAppContractDefinition, type LocalAppContractResponse, type LocalAppContractV1, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, type PermissionOption, PermissionRequiredError, PortModule, type ProjectToolsInput, type Provider, type ProviderKind, type ProvidersResponse, RealtimeXSDK, RetryPolicy, type RetryPolicyOptions, type RuntimeExecutionEvent, RuntimeTransportError, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, ScopeDeniedError, ScopeGuard, StaticAuthProvider, type StaticAuthProviderOptions, type StreamChunk, type StreamChunkEvent, type SyncTokenResponse, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type ToolCall, ToolNotFoundError, ToolProjector, ToolValidationError, type TriggerAgentPayload, type TriggerAgentResponse, V1ApiNamespace, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace, buildContractIdempotencyKey, buildContractSignatureMessage, canonicalEventToLegacyAction, createContractEventId, hashContractPayload, normalizeAttemptId, normalizeContractEvent, normalizeLocalAppContractV1, normalizeSchema, parseAttemptRunId, signContractEvent, toStableToolName };
29
+ export { RealtimeXSDK, type SDKConfig, V1ApiNamespace };