@realtimex/sdk 1.1.1 → 1.1.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/README.md CHANGED
@@ -25,6 +25,9 @@ Before using this SDK, ensure your Supabase database is set up:
25
25
  import { RealtimeXSDK } from '@realtimex/sdk';
26
26
 
27
27
  const sdk = new RealtimeXSDK({
28
+ // Development Mode: Use API key for full access
29
+ realtimex: { apiKey: 'sk-abc123...' },
30
+ // OR Production Mode: Declare permissions
28
31
  permissions: ['activities.read', 'activities.write', 'webhook.trigger']
29
32
  });
30
33
 
@@ -59,8 +62,9 @@ When you start your Local App from the RealtimeX Main App:
59
62
  const sdk = new RealtimeXSDK({
60
63
  realtimex: {
61
64
  url: 'http://custom-host:3001', // Default: localhost:3001
62
- appId: 'custom-id', // Override auto-detected
63
- appName: 'My App', // Override auto-detected
65
+ apiKey: 'sk-abc123...', // Development mode
66
+ appId: 'custom-id', // Production mode (override)
67
+ appName: 'My App', // Optional
64
68
  }
65
69
  });
66
70
  ```
@@ -133,11 +137,18 @@ const sdk = new RealtimeXSDK({
133
137
  #### List Providers & Models
134
138
 
135
139
  ```typescript
136
- const { llm, embedding } = await sdk.llm.getProviders();
137
- // llm[]: Array of LLM providers with models
138
- // embedding[]: Array of embedding providers with models
140
+
141
+
142
+ // Get only configured Chat providers (recommended)
143
+ const chatRes = await sdk.llm.chatProviders();
144
+ // chatRes.providers: Array of chat providers with models
145
+
146
+ // Get only configured Embedding providers (recommended)
147
+ const embedRes = await sdk.llm.embedProviders();
148
+ // embedRes.providers: Array of embedding providers with models
139
149
  ```
140
150
 
151
+
141
152
  #### Chat Completion
142
153
 
143
154
  ```typescript
package/dist/index.d.mts CHANGED
@@ -6,6 +6,7 @@ interface SDKConfig {
6
6
  url?: string;
7
7
  appId?: string;
8
8
  appName?: string;
9
+ apiKey?: string;
9
10
  };
10
11
  defaultPort?: number;
11
12
  permissions?: string[];
@@ -88,7 +89,8 @@ declare class ActivitiesModule {
88
89
  private baseUrl;
89
90
  private appId;
90
91
  private appName;
91
- constructor(realtimexUrl: string, appId: string, appName?: string);
92
+ private apiKey?;
93
+ constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
92
94
  /**
93
95
  * Request a single permission from Electron via internal API
94
96
  */
@@ -124,7 +126,8 @@ declare class WebhookModule {
124
126
  private realtimexUrl;
125
127
  private appName?;
126
128
  private appId?;
127
- constructor(realtimexUrl: string, appName?: string, appId?: string);
129
+ private apiKey?;
130
+ constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
128
131
  /**
129
132
  * Request a single permission from Electron via internal API
130
133
  */
@@ -147,20 +150,23 @@ declare class WebhookModule {
147
150
  */
148
151
  declare class PermissionDeniedError extends Error {
149
152
  readonly permission: string;
150
- constructor(permission: string, message?: string);
153
+ readonly code: string;
154
+ constructor(permission: string, message?: string, code?: string);
151
155
  }
152
156
  /**
153
157
  * Error thrown when a permission needs to be granted
154
158
  */
155
159
  declare class PermissionRequiredError extends Error {
156
160
  readonly permission: string;
157
- constructor(permission: string, message?: string);
161
+ readonly code: string;
162
+ constructor(permission: string, message?: string, code?: string);
158
163
  }
159
164
  declare class ApiModule {
160
165
  private realtimexUrl;
161
166
  private appId;
162
167
  private appName;
163
- constructor(realtimexUrl: string, appId: string, appName?: string);
168
+ private apiKey?;
169
+ constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
164
170
  private getHeaders;
165
171
  /**
166
172
  * Request a single permission from Electron via internal API
@@ -190,7 +196,8 @@ declare class TaskModule {
190
196
  private realtimexUrl;
191
197
  private appName?;
192
198
  private appId?;
193
- constructor(realtimexUrl: string, appName?: string, appId?: string);
199
+ private apiKey?;
200
+ constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
194
201
  /**
195
202
  * Mark task as processing
196
203
  */
@@ -258,6 +265,7 @@ declare class PortModule {
258
265
  * - Provider/model listing
259
266
  * - Vector storage (upsert, query, delete)
260
267
  */
268
+
261
269
  interface ChatMessage {
262
270
  role: 'system' | 'user' | 'assistant';
263
271
  content: string;
@@ -267,6 +275,9 @@ interface ChatOptions {
267
275
  provider?: string;
268
276
  temperature?: number;
269
277
  max_tokens?: number;
278
+ response_format?: {
279
+ type: string;
280
+ };
270
281
  }
271
282
  interface ChatResponse {
272
283
  success: boolean;
@@ -317,6 +328,7 @@ interface ProvidersResponse {
317
328
  success: boolean;
318
329
  llm?: Provider[];
319
330
  embedding?: Provider[];
331
+ providers?: Provider[];
320
332
  error?: string;
321
333
  code?: string;
322
334
  }
@@ -385,9 +397,10 @@ interface VectorListWorkspacesResponse {
385
397
  error?: string;
386
398
  code?: string;
387
399
  }
388
- declare class LLMPermissionError extends Error {
389
- permission: string;
390
- code: string;
400
+ /**
401
+ * @deprecated Use PermissionRequiredError from api module instead
402
+ */
403
+ declare class LLMPermissionError extends PermissionRequiredError {
391
404
  constructor(permission: string, code?: string);
392
405
  }
393
406
  declare class LLMProviderError extends Error {
@@ -397,8 +410,18 @@ declare class LLMProviderError extends Error {
397
410
  declare class VectorStore {
398
411
  private baseUrl;
399
412
  private appId;
400
- constructor(baseUrl: string, appId: string);
413
+ private appName;
414
+ private apiKey?;
415
+ constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
401
416
  private get headers();
417
+ /**
418
+ * Request a single permission from Electron via internal API
419
+ */
420
+ private requestPermission;
421
+ /**
422
+ * Internal request wrapper that handles automatic permission prompts
423
+ */
424
+ private request;
402
425
  /**
403
426
  * Upsert (insert or update) vectors into storage
404
427
  *
@@ -449,19 +472,39 @@ declare class VectorStore {
449
472
  declare class LLMModule {
450
473
  private baseUrl;
451
474
  private appId;
475
+ private appName;
476
+ private apiKey?;
452
477
  vectors: VectorStore;
453
- constructor(baseUrl: string, appId: string);
478
+ constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
454
479
  private get headers();
455
480
  /**
456
- * Get available LLM and embedding providers/models
481
+ * Request a single permission from Electron via internal API
482
+ */
483
+ private requestPermission;
484
+ /**
485
+ * Internal request wrapper that handles automatic permission prompts
486
+ */
487
+ private request;
488
+ /**
489
+ * Get only configured chat (LLM) providers
490
+ *
491
+ * @example
492
+ * ```ts
493
+ * const { providers } = await sdk.llm.chatProviders();
494
+ * console.log('Available chat models:', providers[0].models);
495
+ * ```
496
+ */
497
+ chatProviders(): Promise<ProvidersResponse>;
498
+ /**
499
+ * Get only configured embedding providers
457
500
  *
458
501
  * @example
459
502
  * ```ts
460
- * const { llm, embedding } = await sdk.llm.getProviders();
461
- * console.log('Available LLM models:', llm[0].models);
503
+ * const { providers } = await sdk.llm.embedProviders();
504
+ * console.log('Available embedding models:', providers[0].models);
462
505
  * ```
463
506
  */
464
- getProviders(): Promise<ProvidersResponse>;
507
+ embedProviders(): Promise<ProvidersResponse>;
465
508
  /**
466
509
  * Send a chat completion request (synchronous)
467
510
  *
@@ -556,6 +599,7 @@ declare class RealtimeXSDK {
556
599
  llm: LLMModule;
557
600
  readonly appId: string;
558
601
  readonly appName: string | undefined;
602
+ readonly apiKey: string | undefined;
559
603
  private readonly realtimexUrl;
560
604
  private readonly permissions;
561
605
  private static DEFAULT_REALTIMEX_URL;
@@ -569,6 +613,16 @@ declare class RealtimeXSDK {
569
613
  * Get environment variable (works in Node.js and browser)
570
614
  */
571
615
  private getEnvVar;
616
+ /**
617
+ * Ping RealtimeX server to verify connection and authentication.
618
+ * Works in both development (API Key) and production (App ID) modes.
619
+ */
620
+ ping(): Promise<{
621
+ success: boolean;
622
+ mode: 'development' | 'production';
623
+ appId?: string;
624
+ timestamp: string;
625
+ }>;
572
626
  }
573
627
 
574
628
  export { ActivitiesModule, type Activity, type Agent, ApiModule, type ChatMessage, type ChatOptions, type ChatResponse, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type StreamChunk, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ interface SDKConfig {
6
6
  url?: string;
7
7
  appId?: string;
8
8
  appName?: string;
9
+ apiKey?: string;
9
10
  };
10
11
  defaultPort?: number;
11
12
  permissions?: string[];
@@ -88,7 +89,8 @@ declare class ActivitiesModule {
88
89
  private baseUrl;
89
90
  private appId;
90
91
  private appName;
91
- constructor(realtimexUrl: string, appId: string, appName?: string);
92
+ private apiKey?;
93
+ constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
92
94
  /**
93
95
  * Request a single permission from Electron via internal API
94
96
  */
@@ -124,7 +126,8 @@ declare class WebhookModule {
124
126
  private realtimexUrl;
125
127
  private appName?;
126
128
  private appId?;
127
- constructor(realtimexUrl: string, appName?: string, appId?: string);
129
+ private apiKey?;
130
+ constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
128
131
  /**
129
132
  * Request a single permission from Electron via internal API
130
133
  */
@@ -147,20 +150,23 @@ declare class WebhookModule {
147
150
  */
148
151
  declare class PermissionDeniedError extends Error {
149
152
  readonly permission: string;
150
- constructor(permission: string, message?: string);
153
+ readonly code: string;
154
+ constructor(permission: string, message?: string, code?: string);
151
155
  }
152
156
  /**
153
157
  * Error thrown when a permission needs to be granted
154
158
  */
155
159
  declare class PermissionRequiredError extends Error {
156
160
  readonly permission: string;
157
- constructor(permission: string, message?: string);
161
+ readonly code: string;
162
+ constructor(permission: string, message?: string, code?: string);
158
163
  }
159
164
  declare class ApiModule {
160
165
  private realtimexUrl;
161
166
  private appId;
162
167
  private appName;
163
- constructor(realtimexUrl: string, appId: string, appName?: string);
168
+ private apiKey?;
169
+ constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
164
170
  private getHeaders;
165
171
  /**
166
172
  * Request a single permission from Electron via internal API
@@ -190,7 +196,8 @@ declare class TaskModule {
190
196
  private realtimexUrl;
191
197
  private appName?;
192
198
  private appId?;
193
- constructor(realtimexUrl: string, appName?: string, appId?: string);
199
+ private apiKey?;
200
+ constructor(realtimexUrl: string, appName?: string, appId?: string, apiKey?: string);
194
201
  /**
195
202
  * Mark task as processing
196
203
  */
@@ -258,6 +265,7 @@ declare class PortModule {
258
265
  * - Provider/model listing
259
266
  * - Vector storage (upsert, query, delete)
260
267
  */
268
+
261
269
  interface ChatMessage {
262
270
  role: 'system' | 'user' | 'assistant';
263
271
  content: string;
@@ -267,6 +275,9 @@ interface ChatOptions {
267
275
  provider?: string;
268
276
  temperature?: number;
269
277
  max_tokens?: number;
278
+ response_format?: {
279
+ type: string;
280
+ };
270
281
  }
271
282
  interface ChatResponse {
272
283
  success: boolean;
@@ -317,6 +328,7 @@ interface ProvidersResponse {
317
328
  success: boolean;
318
329
  llm?: Provider[];
319
330
  embedding?: Provider[];
331
+ providers?: Provider[];
320
332
  error?: string;
321
333
  code?: string;
322
334
  }
@@ -385,9 +397,10 @@ interface VectorListWorkspacesResponse {
385
397
  error?: string;
386
398
  code?: string;
387
399
  }
388
- declare class LLMPermissionError extends Error {
389
- permission: string;
390
- code: string;
400
+ /**
401
+ * @deprecated Use PermissionRequiredError from api module instead
402
+ */
403
+ declare class LLMPermissionError extends PermissionRequiredError {
391
404
  constructor(permission: string, code?: string);
392
405
  }
393
406
  declare class LLMProviderError extends Error {
@@ -397,8 +410,18 @@ declare class LLMProviderError extends Error {
397
410
  declare class VectorStore {
398
411
  private baseUrl;
399
412
  private appId;
400
- constructor(baseUrl: string, appId: string);
413
+ private appName;
414
+ private apiKey?;
415
+ constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
401
416
  private get headers();
417
+ /**
418
+ * Request a single permission from Electron via internal API
419
+ */
420
+ private requestPermission;
421
+ /**
422
+ * Internal request wrapper that handles automatic permission prompts
423
+ */
424
+ private request;
402
425
  /**
403
426
  * Upsert (insert or update) vectors into storage
404
427
  *
@@ -449,19 +472,39 @@ declare class VectorStore {
449
472
  declare class LLMModule {
450
473
  private baseUrl;
451
474
  private appId;
475
+ private appName;
476
+ private apiKey?;
452
477
  vectors: VectorStore;
453
- constructor(baseUrl: string, appId: string);
478
+ constructor(baseUrl: string, appId: string, appName?: string, apiKey?: string | undefined);
454
479
  private get headers();
455
480
  /**
456
- * Get available LLM and embedding providers/models
481
+ * Request a single permission from Electron via internal API
482
+ */
483
+ private requestPermission;
484
+ /**
485
+ * Internal request wrapper that handles automatic permission prompts
486
+ */
487
+ private request;
488
+ /**
489
+ * Get only configured chat (LLM) providers
490
+ *
491
+ * @example
492
+ * ```ts
493
+ * const { providers } = await sdk.llm.chatProviders();
494
+ * console.log('Available chat models:', providers[0].models);
495
+ * ```
496
+ */
497
+ chatProviders(): Promise<ProvidersResponse>;
498
+ /**
499
+ * Get only configured embedding providers
457
500
  *
458
501
  * @example
459
502
  * ```ts
460
- * const { llm, embedding } = await sdk.llm.getProviders();
461
- * console.log('Available LLM models:', llm[0].models);
503
+ * const { providers } = await sdk.llm.embedProviders();
504
+ * console.log('Available embedding models:', providers[0].models);
462
505
  * ```
463
506
  */
464
- getProviders(): Promise<ProvidersResponse>;
507
+ embedProviders(): Promise<ProvidersResponse>;
465
508
  /**
466
509
  * Send a chat completion request (synchronous)
467
510
  *
@@ -556,6 +599,7 @@ declare class RealtimeXSDK {
556
599
  llm: LLMModule;
557
600
  readonly appId: string;
558
601
  readonly appName: string | undefined;
602
+ readonly apiKey: string | undefined;
559
603
  private readonly realtimexUrl;
560
604
  private readonly permissions;
561
605
  private static DEFAULT_REALTIMEX_URL;
@@ -569,6 +613,16 @@ declare class RealtimeXSDK {
569
613
  * Get environment variable (works in Node.js and browser)
570
614
  */
571
615
  private getEnvVar;
616
+ /**
617
+ * Ping RealtimeX server to verify connection and authentication.
618
+ * Works in both development (API Key) and production (App ID) modes.
619
+ */
620
+ ping(): Promise<{
621
+ success: boolean;
622
+ mode: 'development' | 'production';
623
+ appId?: string;
624
+ timestamp: string;
625
+ }>;
572
626
  }
573
627
 
574
628
  export { ActivitiesModule, type Activity, type Agent, ApiModule, type ChatMessage, type ChatOptions, type ChatResponse, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type StreamChunk, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };