@realtimex/sdk 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/skills/realtimex-moderator-sdk/SKILL.md +93 -0
- package/skills/realtimex-moderator-sdk/references/api-reference.md +662 -0
- package/skills/realtimex-moderator-sdk/references/known-issues.md +237 -0
- package/skills/realtimex-moderator-sdk/scripts/lib/sdk-init.js +119 -0
- package/skills/realtimex-moderator-sdk/scripts/rtx.js +492 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
# RealTimeX SDK — API Reference
|
|
2
|
+
|
|
3
|
+
> Auto-generated from `@realtimex/sdk` source · v**1.4.3** · 2026-03-26
|
|
4
|
+
|
|
5
|
+
**Package:** `@realtimex/sdk` (CJS) · **Server:** `http://localhost:3001`
|
|
6
|
+
**Developer Mode auth:** `Authorization: Bearer <apiKey>`
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Available Permissions
|
|
11
|
+
|
|
12
|
+
| Permission | Grants access to |
|
|
13
|
+
|------------|------------------|
|
|
14
|
+
| `api.agents` | `sdk.api.getAgents()` |
|
|
15
|
+
| `api.workspaces` | `sdk.api.getWorkspaces()` |
|
|
16
|
+
| `api.threads` | `sdk.api.getThreads()` |
|
|
17
|
+
| `api.task` | `sdk.api.getTask()` |
|
|
18
|
+
| `webhook.trigger` | webhook trigger, task events |
|
|
19
|
+
| `activities.read` | `sdk.activities.list/get()` |
|
|
20
|
+
| `activities.write` | `sdk.activities.insert/update/delete()` |
|
|
21
|
+
| `llm.chat` | `sdk.llm.chat/chatStream()` |
|
|
22
|
+
| `llm.embed` | `sdk.llm.embed()` |
|
|
23
|
+
| `llm.providers` | `sdk.llm.chatProviders/embedProviders()` |
|
|
24
|
+
| `vectors.read` | `sdk.llm.vectors.query/listWorkspaces()` |
|
|
25
|
+
| `vectors.write` | `sdk.llm.vectors.upsert/delete()` |
|
|
26
|
+
| `tts.generate` | `sdk.tts.speak/speakStream()` |
|
|
27
|
+
| `mcp.servers` | `sdk.mcp.getServers()` |
|
|
28
|
+
| `mcp.tools` | `sdk.mcp.getTools/executeTool()` |
|
|
29
|
+
| `acp.agent` | `sdk.acpAgent.*` |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Core — RealtimeXSDK
|
|
34
|
+
|
|
35
|
+
### `RealtimeXSDK`
|
|
36
|
+
|
|
37
|
+
**Public properties:**
|
|
38
|
+
- `activities: ActivitiesModule`
|
|
39
|
+
- `webhook: WebhookModule`
|
|
40
|
+
- `api: ApiModule`
|
|
41
|
+
- `task: TaskModule`
|
|
42
|
+
- `port: PortModule`
|
|
43
|
+
- `llm: LLMModule`
|
|
44
|
+
- `tts: TTSModule`
|
|
45
|
+
- `stt: STTModule`
|
|
46
|
+
- `agent: AgentModule`
|
|
47
|
+
- `acpAgent: AcpAgentModule`
|
|
48
|
+
- `mcp: MCPModule`
|
|
49
|
+
- `contract: ContractModule`
|
|
50
|
+
- `contractRuntime: ContractRuntime`
|
|
51
|
+
- `database: DatabaseModule`
|
|
52
|
+
- `auth: AuthModule`
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// Register app with RealtimeX hub and request declared permissions upfront.
|
|
56
|
+
async register(permissions?: string[]): void
|
|
57
|
+
|
|
58
|
+
// Get environment variable (works in Node.js and browser)
|
|
59
|
+
async ping(): Promise<
|
|
60
|
+
|
|
61
|
+
// Get the absolute path to the data directory for this app.
|
|
62
|
+
async getAppDataDir(): Promise<string>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## sdk.api — Agents, Workspaces, Threads, Tasks
|
|
68
|
+
|
|
69
|
+
### `ApiModule`
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
async getAgents(): Promise<Agent[]>
|
|
73
|
+
|
|
74
|
+
async getWorkspaces(): Promise<Workspace[]>
|
|
75
|
+
|
|
76
|
+
async getThreads(workspaceSlug: string): Promise<Thread[]>
|
|
77
|
+
|
|
78
|
+
async getTask(taskUuid: string): Promise<Task>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## sdk.activities — Activities CRUD
|
|
84
|
+
|
|
85
|
+
### `ActivitiesModule`
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// Request a single permission from Electron via internal API
|
|
89
|
+
async insert(rawData: Record<string, unknown>): Promise<Activity>
|
|
90
|
+
|
|
91
|
+
// Update an existing activity
|
|
92
|
+
async update(id: string, updates: Partial<Activity>): Promise<Activity>
|
|
93
|
+
|
|
94
|
+
// Delete an activity
|
|
95
|
+
async delete(id: string): Promise<void>
|
|
96
|
+
|
|
97
|
+
// Get a single activity by ID
|
|
98
|
+
async get(id: string): Promise<Activity | null>
|
|
99
|
+
|
|
100
|
+
// List activities with optional filters
|
|
101
|
+
async list(options?: { status?: string; limit?: number; offset?: number }): Promise<Activity[]>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## sdk.task — Task Lifecycle Reporting
|
|
107
|
+
|
|
108
|
+
### `TaskModule`
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// Configure callback signing behavior.
|
|
112
|
+
configureContract(config: { callbackSecret?: string; signCallbacksByDefault?: boolean }): void
|
|
113
|
+
|
|
114
|
+
// Claim a task before processing.
|
|
115
|
+
async claim(taskUuid: string, options: TaskEventOptions = {}): Promise<TaskStatusResponse>
|
|
116
|
+
|
|
117
|
+
// Alias for claim()
|
|
118
|
+
async claimed(taskUuid: string, options: TaskEventOptions = {}): Promise<TaskStatusResponse>
|
|
119
|
+
|
|
120
|
+
// Mark task as processing.
|
|
121
|
+
async start(taskUuid: string, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>
|
|
122
|
+
|
|
123
|
+
// Report incremental task progress.
|
|
124
|
+
async progress(taskUuid: string, progressData: Record<string, unknown> = {}, options: TaskEventOptions = {}): Promise<TaskStatusResponse>
|
|
125
|
+
|
|
126
|
+
// Mark task as completed with result.
|
|
127
|
+
async complete(taskUuid: string, result: Record<string, unknown> = {}, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>
|
|
128
|
+
|
|
129
|
+
// Mark task as failed with error.
|
|
130
|
+
async fail(taskUuid: string, error: string, machineIdOrOptions?: string | TaskEventOptions): Promise<TaskStatusResponse>
|
|
131
|
+
|
|
132
|
+
// Mark task as canceled.
|
|
133
|
+
async cancel(taskUuid: string, reason?: string, options: TaskEventOptions = {}): Promise<TaskStatusResponse>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `TaskStatusResponse`
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
success: boolean
|
|
140
|
+
task_uuid: string
|
|
141
|
+
status: string
|
|
142
|
+
event_id?: string
|
|
143
|
+
attempt_id?: string
|
|
144
|
+
event_type?: ContractEventType | string
|
|
145
|
+
deduplicated?: boolean
|
|
146
|
+
duplicate?: boolean
|
|
147
|
+
message?: string
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### `TaskEventOptions`
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
machineId?: string
|
|
154
|
+
attemptId?: string | number
|
|
155
|
+
eventId?: string
|
|
156
|
+
timestamp?: string
|
|
157
|
+
callbackUrl?: string
|
|
158
|
+
callbackSecret?: string
|
|
159
|
+
sign?: boolean
|
|
160
|
+
userEmail?: string
|
|
161
|
+
activityId?: string
|
|
162
|
+
tableName?: string
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## sdk.webhook — Webhook Trigger
|
|
168
|
+
|
|
169
|
+
### `WebhookModule`
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
async triggerAgent(payload: TriggerAgentPayload): Promise<TriggerAgentResponse>
|
|
173
|
+
|
|
174
|
+
async ping(): Promise<
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## sdk.llm — LLM Chat, Embed, Vector Search
|
|
180
|
+
|
|
181
|
+
### `LLMModule`
|
|
182
|
+
|
|
183
|
+
**Public properties:**
|
|
184
|
+
- `vectors: VectorStore`
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
// Request a single permission from Electron via internal API
|
|
188
|
+
async chatProviders(): Promise<ProvidersResponse>
|
|
189
|
+
|
|
190
|
+
// Get only configured embedding providers
|
|
191
|
+
async embedProviders(): Promise<ProvidersResponse>
|
|
192
|
+
|
|
193
|
+
// Send a chat completion request (synchronous)
|
|
194
|
+
async chat(messages: ChatMessage[], options: ChatOptions = {}): Promise<ChatResponse>
|
|
195
|
+
|
|
196
|
+
// Send a streaming chat completion request (SSE)
|
|
197
|
+
async *chatStream(messages: ChatMessage[], options: ChatOptions = {}): AsyncGenerator<StreamChunk, void, unknown>
|
|
198
|
+
|
|
199
|
+
// Generate vector embeddings from text
|
|
200
|
+
async embed(input: string | string[], options: EmbedOptions = {}): Promise<EmbedResponse>
|
|
201
|
+
|
|
202
|
+
// Helper: Embed text and store as vectors in one call
|
|
203
|
+
async embedAndStore(params: { texts: string[]; documentId?: string; workspaceId?: string; idPrefix?: string; provider?: string; model?: string; }): Promise<VectorUpsertResponse>
|
|
204
|
+
|
|
205
|
+
// Helper: Search similar documents by text query
|
|
206
|
+
async search(query: string, options: VectorQueryOptions = {}): Promise<VectorQueryResult[]>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### `VectorStore` *(accessed as `sdk.llm.vectors`)*
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
// Request a single permission from Electron via internal API
|
|
213
|
+
async upsert(vectors: VectorRecord[], options: VectorUpsertOptions = {}): Promise<VectorUpsertResponse>
|
|
214
|
+
|
|
215
|
+
// Query similar vectors by embedding
|
|
216
|
+
async query(vector: number[], options: VectorQueryOptions = {}): Promise<VectorQueryResponse>
|
|
217
|
+
|
|
218
|
+
// Delete vectors from storage
|
|
219
|
+
async delete(options: VectorDeleteOptions): Promise<VectorDeleteResponse>
|
|
220
|
+
|
|
221
|
+
// List all available workspaces (namespaces) for this app
|
|
222
|
+
async listWorkspaces(): Promise<VectorListWorkspacesResponse>
|
|
223
|
+
|
|
224
|
+
// Register a custom vector database configuration for this app
|
|
225
|
+
async registerConfig(provider: string, config: Record<string, any>): Promise<VectorRegisterResponse>
|
|
226
|
+
|
|
227
|
+
// List all supported vector database providers and their configuration requirements
|
|
228
|
+
async listProviders(): Promise<VectorProvidersResponse>
|
|
229
|
+
|
|
230
|
+
// Get the current vector database configuration for this app
|
|
231
|
+
async getConfig(): Promise<VectorConfigResponse>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### `ChatOptions`
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
model?: string
|
|
238
|
+
provider?: string
|
|
239
|
+
temperature?: number
|
|
240
|
+
max_tokens?: number
|
|
241
|
+
response_format?: { type: string }
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
#### `ChatResponse`
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
success: boolean
|
|
248
|
+
response?: {
|
|
249
|
+
content: string
|
|
250
|
+
model: string
|
|
251
|
+
provider?: string
|
|
252
|
+
metrics?: {
|
|
253
|
+
prompt_tokens: number
|
|
254
|
+
completion_tokens: number
|
|
255
|
+
total_tokens: number
|
|
256
|
+
duration?: number
|
|
257
|
+
outputTps?: number
|
|
258
|
+
error?: string
|
|
259
|
+
code?: string
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### `StreamChunk`
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
uuid?: string
|
|
266
|
+
type?: string
|
|
267
|
+
textResponse?: string
|
|
268
|
+
close?: boolean
|
|
269
|
+
error?: boolean
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### `EmbedOptions`
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
provider?: string
|
|
276
|
+
model?: string
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### `EmbedResponse`
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
success: boolean
|
|
283
|
+
embeddings?: number[][]
|
|
284
|
+
provider?: string
|
|
285
|
+
model?: string
|
|
286
|
+
dimensions?: number
|
|
287
|
+
error?: string
|
|
288
|
+
code?: string
|
|
289
|
+
errors?: string[]
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### `VectorRecord`
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
id: string
|
|
296
|
+
vector: number[]
|
|
297
|
+
metadata?: {
|
|
298
|
+
text?: string
|
|
299
|
+
documentId?: string
|
|
300
|
+
workspaceId?: string
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### `VectorUpsertOptions`
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
workspaceId?: string
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### `VectorQueryOptions`
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
topK?: number
|
|
313
|
+
filter?: {
|
|
314
|
+
workspaceId?: string
|
|
315
|
+
documentId?: string
|
|
316
|
+
workspaceId?: string
|
|
317
|
+
provider?: string
|
|
318
|
+
model?: string
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### `VectorQueryResult`
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
id: string
|
|
325
|
+
score: number
|
|
326
|
+
metadata?: {
|
|
327
|
+
text?: string
|
|
328
|
+
documentId?: string
|
|
329
|
+
workspaceId?: string
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### `VectorDeleteOptions`
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
workspaceId?: string
|
|
336
|
+
deleteAll: true
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
#### `VectorListWorkspacesResponse`
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
success: boolean
|
|
343
|
+
workspaces?: string[]
|
|
344
|
+
error?: string
|
|
345
|
+
code?: string
|
|
346
|
+
error_message?: string
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## sdk.mcp — MCP Server Tools
|
|
352
|
+
|
|
353
|
+
### `MCPModule` *(extends ApiModule)*
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
super(realtimexUrl, appId, appName, apiKey): void
|
|
357
|
+
|
|
358
|
+
// List configured MCP servers.
|
|
359
|
+
async getServers(provider: 'local' | 'remote' | 'all' = 'all'): Promise<MCPServer[]>
|
|
360
|
+
|
|
361
|
+
// List available tools for a specific MCP server.
|
|
362
|
+
async getTools(serverName: string, provider: 'local' | 'remote' = 'local'): Promise<MCPTool[]>
|
|
363
|
+
|
|
364
|
+
// Execute a tool on an MCP server.
|
|
365
|
+
async executeTool(serverName: string, toolName: string, args: Record<string, any> = {}, provider: 'local' | 'remote' = 'local'): Promise<any>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
#### `MCPServer`
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
name: string
|
|
372
|
+
display_name: string
|
|
373
|
+
description: string | null
|
|
374
|
+
server_type: string
|
|
375
|
+
enabled: boolean
|
|
376
|
+
provider: 'local' | 'remote'
|
|
377
|
+
tags: string[]
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### `MCPTool`
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
name: string
|
|
384
|
+
description: string | null
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
#### `MCPToolResult`
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
success: boolean
|
|
391
|
+
server: string
|
|
392
|
+
tool: string
|
|
393
|
+
provider: string
|
|
394
|
+
result: any
|
|
395
|
+
error?: string
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## sdk.acpAgent — ACP CLI Agent Sessions
|
|
401
|
+
|
|
402
|
+
### `AcpAgentModule`
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
// List available CLI agents. Pass includeModels to get model lists per agent.
|
|
406
|
+
async listAgents(opts?: { includeModels?: boolean; }): Promise<AcpAgentInfo[]>
|
|
407
|
+
|
|
408
|
+
// Create and initialize a new ACP session. Spawns the CLI agent process.
|
|
409
|
+
async createSession(options: AcpSessionOptions): Promise<AcpSession>
|
|
410
|
+
|
|
411
|
+
// Get session status and runtime options.
|
|
412
|
+
async getSession(sessionKey: string): Promise<AcpSessionStatus>
|
|
413
|
+
|
|
414
|
+
// List active ACP sessions owned by this app.
|
|
415
|
+
async listSessions(): Promise<AcpSessionStatus[]>
|
|
416
|
+
|
|
417
|
+
// Update runtime options (applied on next turn).
|
|
418
|
+
async patchSession(sessionKey: string, patch: AcpRuntimeOptionPatch): Promise<void>
|
|
419
|
+
|
|
420
|
+
// Close session and stop the agent process.
|
|
421
|
+
async closeSession(sessionKey: string, reason?: string): Promise<void>
|
|
422
|
+
|
|
423
|
+
// Synchronous turn — waits for completion, returns full response.
|
|
424
|
+
async chat(sessionKey: string, message: string, attachments?: AcpAttachment[]): Promise<AcpChatResponse>
|
|
425
|
+
|
|
426
|
+
// Streaming turn via SSE. Yields events as they arrive.
|
|
427
|
+
async *streamChat(sessionKey: string, message: string, attachments?: AcpAttachment[]): AsyncIterableIterator<AcpStreamEvent>
|
|
428
|
+
|
|
429
|
+
// Cancel the active turn on a session.
|
|
430
|
+
async cancelTurn(sessionKey: string, reason?: string): Promise<void>
|
|
431
|
+
|
|
432
|
+
// Resolve a pending permission request (call while SSE stream is active).
|
|
433
|
+
async resolvePermission(sessionKey: string, decision: AcpPermissionDecision): Promise<
|
|
434
|
+
|
|
435
|
+
// Convenience: create session + first sync chat in one call.
|
|
436
|
+
async startChat(message: string, options: AcpSessionOptions): Promise<
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
#### `AcpSessionOptions`
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
agent_id: string
|
|
443
|
+
cwd?: string
|
|
444
|
+
label?: string
|
|
445
|
+
model?: string
|
|
446
|
+
approvalPolicy?: "approve-all" | "approve-reads" | "deny-all"
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
#### `AcpSession`
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
session_key: string
|
|
453
|
+
agent_id: string
|
|
454
|
+
state: "initializing" | "ready" | "stale" | "closed"
|
|
455
|
+
backend_id: string
|
|
456
|
+
created_at: string
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### `AcpSessionStatus`
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
runtime_options: AcpRuntimeOptionPatch
|
|
463
|
+
last_activity_at: string | null
|
|
464
|
+
last_error?: string
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
#### `AcpRuntimeOptionPatch`
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
model?: string
|
|
471
|
+
cwd?: string
|
|
472
|
+
timeoutSeconds?: number
|
|
473
|
+
runtimeMode?: string
|
|
474
|
+
approvalPolicy?: "approve-all" | "approve-reads" | "deny-all"
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
#### `AcpAttachment`
|
|
478
|
+
|
|
479
|
+
```ts
|
|
480
|
+
contentString: string
|
|
481
|
+
mime: string
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
#### `AcpChatResponse`
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
text: string
|
|
488
|
+
stop_reason?: string
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
#### `AcpStreamEvent`
|
|
492
|
+
|
|
493
|
+
#### `AcpPermissionDecision`
|
|
494
|
+
|
|
495
|
+
```ts
|
|
496
|
+
requestId: string
|
|
497
|
+
optionId: string
|
|
498
|
+
outcome?: string
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## sdk.agent — LLM Agent Sessions (REST/SSE)
|
|
504
|
+
|
|
505
|
+
### `AgentModule`
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
// Create a new agent session
|
|
509
|
+
async createSession(options?: AgentSessionOptions): Promise<AgentSession>
|
|
510
|
+
|
|
511
|
+
// Chat within a session (synchronous)
|
|
512
|
+
async chat(sessionId: string, message: string): Promise<AgentChatResponse>
|
|
513
|
+
|
|
514
|
+
// Stream chat within a session
|
|
515
|
+
async *streamChat(sessionId: string, message: string): AsyncIterableIterator<StreamChunkEvent>
|
|
516
|
+
|
|
517
|
+
// Get session information
|
|
518
|
+
async getSession(sessionId: string): Promise<AgentSessionInfo>
|
|
519
|
+
|
|
520
|
+
// Close and delete a session
|
|
521
|
+
async closeSession(sessionId: string): Promise<void>
|
|
522
|
+
|
|
523
|
+
// Helper: Create session and send first message in one call
|
|
524
|
+
async startChat(message: string, options?: AgentSessionOptions): Promise<
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## sdk.tts — Text-to-Speech
|
|
530
|
+
|
|
531
|
+
### `TTSModule`
|
|
532
|
+
|
|
533
|
+
```ts
|
|
534
|
+
// Request a single permission from Electron via internal API
|
|
535
|
+
async speak(text: string, options: TTSOptions = {}): Promise<ArrayBuffer>
|
|
536
|
+
|
|
537
|
+
// Generate speech from text with streaming (yields decoded audio chunks)
|
|
538
|
+
async *speakStream(text: string, options: TTSOptions = {}): AsyncGenerator<TTSChunk>
|
|
539
|
+
|
|
540
|
+
// List available TTS providers with configuration options
|
|
541
|
+
async listProviders(): Promise<TTSProvider[]>
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## sdk.stt — Speech-to-Text
|
|
547
|
+
|
|
548
|
+
### `STTModule` *(extends ApiModule)*
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
// Get available STT providers and their models.
|
|
552
|
+
async listProviders(): Promise<STTProvider[]>
|
|
553
|
+
|
|
554
|
+
// Listen to microphone and transcribe speech to text.
|
|
555
|
+
async listen(options: STTListenOptions): Promise<STTResponse>
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## sdk.contract — Local App Contract
|
|
561
|
+
|
|
562
|
+
### `ContractModule`
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
async getLocalAppV1(forceRefresh = false): Promise<LocalAppContractDefinition>
|
|
566
|
+
|
|
567
|
+
async listCapabilities(forceRefresh = false): Promise<ContractCapability[]>
|
|
568
|
+
|
|
569
|
+
async searchCapabilities(query: string): Promise<ContractCapability[]>
|
|
570
|
+
|
|
571
|
+
async describeCapability(capabilityId: string): Promise<ContractCapability>
|
|
572
|
+
|
|
573
|
+
async search(query: string): Promise<ContractCapability[]>
|
|
574
|
+
|
|
575
|
+
async describe(capabilityId: string): Promise<ContractCapability>
|
|
576
|
+
|
|
577
|
+
async invoke(payload: ContractInvokePayload): Promise<TriggerAgentResponse>
|
|
578
|
+
|
|
579
|
+
getCachedCatalogHash(): string | null
|
|
580
|
+
|
|
581
|
+
clearCache(): void
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
586
|
+
## sdk.database — Supabase Config
|
|
587
|
+
|
|
588
|
+
### `DatabaseModule`
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
// Get the Supabase database configuration for this app.
|
|
592
|
+
async getConfig(): Promise<DatabaseConfig>
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
#### `DatabaseConfig`
|
|
596
|
+
|
|
597
|
+
> Database Module - Retrieve Supabase config from RealtimeX Main App
|
|
598
|
+
|
|
599
|
+
```ts
|
|
600
|
+
url: string
|
|
601
|
+
anonKey: string
|
|
602
|
+
mode: 'compatible' | 'custom'
|
|
603
|
+
tables: string[]
|
|
604
|
+
max_concurrent_tasks: number
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## sdk.auth — Auth Token
|
|
610
|
+
|
|
611
|
+
### `AuthModule`
|
|
612
|
+
|
|
613
|
+
```ts
|
|
614
|
+
// Push a Supabase access token to the Main App.
|
|
615
|
+
async syncSupabaseToken(token: string): Promise<SyncTokenResponse>
|
|
616
|
+
|
|
617
|
+
// Retrieve the current Keycloak access token from Main App.
|
|
618
|
+
async getAccessToken(): Promise<AuthTokenResponse | null>
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
#### `AuthTokenResponse`
|
|
622
|
+
|
|
623
|
+
> Auth Module - Authentication helpers for RealtimeX SDK
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
token: string
|
|
627
|
+
hasToken: boolean
|
|
628
|
+
syncedAt: string | null
|
|
629
|
+
source: string | null
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
#### `SyncTokenResponse`
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
success: boolean
|
|
636
|
+
message: string
|
|
637
|
+
hasToken: boolean
|
|
638
|
+
syncedAt: string | null
|
|
639
|
+
source: string | null
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
## sdk.port — Port Management
|
|
645
|
+
|
|
646
|
+
### `PortModule`
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
// Get suggested port from environment (RTX_PORT) or default
|
|
650
|
+
getSuggestedPort(): number
|
|
651
|
+
|
|
652
|
+
// Check if a port is available on a specific host
|
|
653
|
+
async isPortAvailable(port: number): Promise<boolean>
|
|
654
|
+
|
|
655
|
+
// Find an available port starting from the suggested port
|
|
656
|
+
async findAvailablePort(startPort?: number, maxAttempts: number = 100): Promise<number>
|
|
657
|
+
|
|
658
|
+
// Get a ready-to-use port
|
|
659
|
+
async getPort(): Promise<number>
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
---
|