@realtimex/sdk 2.0.18 → 2.0.19

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/index.js ADDED
@@ -0,0 +1,1309 @@
1
+ 'use strict';
2
+
3
+ const operations = {
4
+ "approveChannelPairingCode": {
5
+ "method": "POST",
6
+ "path": "/approve-channel-pairing-code/{code}",
7
+ "pathParams": [
8
+ "code"
9
+ ],
10
+ "queryParams": [],
11
+ "headerParams": [
12
+ "x-app-id"
13
+ ],
14
+ "hasBody": false
15
+ },
16
+ "clearWorkspaceDefaultAgent": {
17
+ "method": "DELETE",
18
+ "path": "/clear-workspace-default-agent/{workspaceSlug}",
19
+ "pathParams": [
20
+ "workspaceSlug"
21
+ ],
22
+ "queryParams": [],
23
+ "headerParams": [
24
+ "authorization",
25
+ "x-app-id"
26
+ ],
27
+ "hasBody": false
28
+ },
29
+ "createChannel": {
30
+ "method": "POST",
31
+ "path": "/create-channel/{workspaceSlug}",
32
+ "pathParams": [
33
+ "workspaceSlug"
34
+ ],
35
+ "queryParams": [],
36
+ "headerParams": [
37
+ "x-app-id"
38
+ ],
39
+ "hasBody": true
40
+ },
41
+ "createThread": {
42
+ "method": "POST",
43
+ "path": "/create-thread/{workspaceSlug}",
44
+ "pathParams": [
45
+ "workspaceSlug"
46
+ ],
47
+ "queryParams": [],
48
+ "headerParams": [
49
+ "x-app-id"
50
+ ],
51
+ "hasBody": true
52
+ },
53
+ "createWorkspace": {
54
+ "method": "POST",
55
+ "path": "/create-workspace",
56
+ "pathParams": [],
57
+ "queryParams": [],
58
+ "headerParams": [
59
+ "authorization",
60
+ "x-app-id"
61
+ ],
62
+ "hasBody": true
63
+ },
64
+ "deleteChannel": {
65
+ "method": "DELETE",
66
+ "path": "/delete-channel/{channelId}",
67
+ "pathParams": [
68
+ "channelId"
69
+ ],
70
+ "queryParams": [],
71
+ "headerParams": [
72
+ "x-app-id"
73
+ ],
74
+ "hasBody": false
75
+ },
76
+ "deleteThread": {
77
+ "method": "DELETE",
78
+ "path": "/delete-thread/{workspaceSlug}/{threadSlug}",
79
+ "pathParams": [
80
+ "workspaceSlug",
81
+ "threadSlug"
82
+ ],
83
+ "queryParams": [],
84
+ "headerParams": [
85
+ "x-app-id"
86
+ ],
87
+ "hasBody": false
88
+ },
89
+ "deleteWorkspace": {
90
+ "method": "DELETE",
91
+ "path": "/delete-workspace/{workspaceSlug}",
92
+ "pathParams": [
93
+ "workspaceSlug"
94
+ ],
95
+ "queryParams": [],
96
+ "headerParams": [
97
+ "x-app-id"
98
+ ],
99
+ "hasBody": false
100
+ },
101
+ "disablePlugin": {
102
+ "method": "POST",
103
+ "path": "/disable-plugin/{pluginId}",
104
+ "pathParams": [
105
+ "pluginId"
106
+ ],
107
+ "queryParams": [],
108
+ "headerParams": [
109
+ "x-app-id"
110
+ ],
111
+ "hasBody": false
112
+ },
113
+ "disableWorkspaceAgentSkill": {
114
+ "method": "POST",
115
+ "path": "/disable-workspace-agent-skill/{workspaceSlug}/{skillId}",
116
+ "pathParams": [
117
+ "workspaceSlug",
118
+ "skillId"
119
+ ],
120
+ "queryParams": [],
121
+ "headerParams": [
122
+ "authorization",
123
+ "x-app-id"
124
+ ],
125
+ "hasBody": false
126
+ },
127
+ "enablePlugin": {
128
+ "method": "POST",
129
+ "path": "/enable-plugin/{pluginId}",
130
+ "pathParams": [
131
+ "pluginId"
132
+ ],
133
+ "queryParams": [],
134
+ "headerParams": [
135
+ "x-app-id"
136
+ ],
137
+ "hasBody": false
138
+ },
139
+ "enableWorkspaceAgentSkill": {
140
+ "method": "POST",
141
+ "path": "/enable-workspace-agent-skill/{workspaceSlug}/{skillId}",
142
+ "pathParams": [
143
+ "workspaceSlug",
144
+ "skillId"
145
+ ],
146
+ "queryParams": [],
147
+ "headerParams": [
148
+ "authorization",
149
+ "x-app-id"
150
+ ],
151
+ "hasBody": false
152
+ },
153
+ "getArtifact": {
154
+ "method": "GET",
155
+ "path": "/get-artifact/{artifactId}",
156
+ "pathParams": [
157
+ "artifactId"
158
+ ],
159
+ "queryParams": [],
160
+ "headerParams": [
161
+ "x-app-id"
162
+ ],
163
+ "hasBody": false
164
+ },
165
+ "getThread": {
166
+ "method": "GET",
167
+ "path": "/get-thread/{workspaceSlug}/{threadSlug}",
168
+ "pathParams": [
169
+ "workspaceSlug",
170
+ "threadSlug"
171
+ ],
172
+ "queryParams": [],
173
+ "headerParams": [
174
+ "x-app-id"
175
+ ],
176
+ "hasBody": false
177
+ },
178
+ "getWorkspace": {
179
+ "method": "GET",
180
+ "path": "/get-workspace/{workspaceSlug}",
181
+ "pathParams": [
182
+ "workspaceSlug"
183
+ ],
184
+ "queryParams": [],
185
+ "headerParams": [
186
+ "x-app-id"
187
+ ],
188
+ "hasBody": false
189
+ },
190
+ "listAgentSkills": {
191
+ "method": "GET",
192
+ "path": "/list-agent-skills",
193
+ "pathParams": [],
194
+ "queryParams": [],
195
+ "headerParams": [
196
+ "x-app-id"
197
+ ],
198
+ "hasBody": false
199
+ },
200
+ "listArtifacts": {
201
+ "method": "GET",
202
+ "path": "/list-artifacts/{workspaceSlug}",
203
+ "pathParams": [
204
+ "workspaceSlug"
205
+ ],
206
+ "queryParams": [],
207
+ "headerParams": [
208
+ "x-app-id"
209
+ ],
210
+ "hasBody": false
211
+ },
212
+ "listChannels": {
213
+ "method": "GET",
214
+ "path": "/list-channels",
215
+ "pathParams": [],
216
+ "queryParams": [],
217
+ "headerParams": [
218
+ "x-app-id"
219
+ ],
220
+ "hasBody": false
221
+ },
222
+ "listLlmModels": {
223
+ "method": "GET",
224
+ "path": "/list-llm-models/{provider}",
225
+ "pathParams": [
226
+ "provider"
227
+ ],
228
+ "queryParams": [],
229
+ "headerParams": [
230
+ "x-app-id"
231
+ ],
232
+ "hasBody": false
233
+ },
234
+ "listLlmProviders": {
235
+ "method": "GET",
236
+ "path": "/list-llm-providers",
237
+ "pathParams": [],
238
+ "queryParams": [],
239
+ "headerParams": [
240
+ "x-app-id"
241
+ ],
242
+ "hasBody": false
243
+ },
244
+ "listPlugins": {
245
+ "method": "GET",
246
+ "path": "/list-plugins",
247
+ "pathParams": [],
248
+ "queryParams": [],
249
+ "headerParams": [
250
+ "x-app-id"
251
+ ],
252
+ "hasBody": false
253
+ },
254
+ "listTerminalAgents": {
255
+ "method": "GET",
256
+ "path": "/list-terminal-agents",
257
+ "pathParams": [],
258
+ "queryParams": [],
259
+ "headerParams": [
260
+ "x-app-id"
261
+ ],
262
+ "hasBody": false
263
+ },
264
+ "listTerminalSessions": {
265
+ "method": "GET",
266
+ "path": "/list-terminal-sessions",
267
+ "pathParams": [],
268
+ "queryParams": [
269
+ "workspaceSlug",
270
+ "threadSlug",
271
+ "includeClosed",
272
+ "limit"
273
+ ],
274
+ "headerParams": [
275
+ "x-app-id"
276
+ ],
277
+ "hasBody": false
278
+ },
279
+ "listThreads": {
280
+ "method": "GET",
281
+ "path": "/list-threads/{workspaceSlug}",
282
+ "pathParams": [
283
+ "workspaceSlug"
284
+ ],
285
+ "queryParams": [],
286
+ "headerParams": [
287
+ "x-app-id"
288
+ ],
289
+ "hasBody": false
290
+ },
291
+ "listWorkspaceAgentSkills": {
292
+ "method": "GET",
293
+ "path": "/list-workspace-agent-skills/{workspaceSlug}",
294
+ "pathParams": [
295
+ "workspaceSlug"
296
+ ],
297
+ "queryParams": [],
298
+ "headerParams": [
299
+ "authorization",
300
+ "x-app-id"
301
+ ],
302
+ "hasBody": false
303
+ },
304
+ "listWorkspaces": {
305
+ "method": "GET",
306
+ "path": "/list-workspaces",
307
+ "pathParams": [],
308
+ "queryParams": [],
309
+ "headerParams": [
310
+ "x-app-id"
311
+ ],
312
+ "hasBody": false
313
+ },
314
+ "openTerminalSession": {
315
+ "method": "POST",
316
+ "path": "/open-terminal-session",
317
+ "pathParams": [],
318
+ "queryParams": [],
319
+ "headerParams": [
320
+ "x-app-id"
321
+ ],
322
+ "hasBody": true
323
+ },
324
+ "pauseArtifact": {
325
+ "method": "POST",
326
+ "path": "/pause-artifact/{artifactId}",
327
+ "pathParams": [
328
+ "artifactId"
329
+ ],
330
+ "queryParams": [],
331
+ "headerParams": [
332
+ "x-app-id"
333
+ ],
334
+ "hasBody": false
335
+ },
336
+ "prepare": {
337
+ "method": "GET",
338
+ "path": "/prepare",
339
+ "pathParams": [],
340
+ "queryParams": [
341
+ "workspaceSlug",
342
+ "threadSlug"
343
+ ],
344
+ "headerParams": [
345
+ "x-app-id"
346
+ ],
347
+ "hasBody": false
348
+ },
349
+ "publishArtifact": {
350
+ "method": "POST",
351
+ "path": "/publish-artifact/{workspaceSlug}",
352
+ "pathParams": [
353
+ "workspaceSlug"
354
+ ],
355
+ "queryParams": [],
356
+ "headerParams": [
357
+ "x-app-id"
358
+ ],
359
+ "hasBody": true
360
+ },
361
+ "reloadAgentSkills": {
362
+ "method": "POST",
363
+ "path": "/reload-agent-skills",
364
+ "pathParams": [],
365
+ "queryParams": [],
366
+ "headerParams": [
367
+ "x-app-id"
368
+ ],
369
+ "hasBody": true
370
+ },
371
+ "reloadPlugin": {
372
+ "method": "POST",
373
+ "path": "/reload-plugin/{pluginId}",
374
+ "pathParams": [
375
+ "pluginId"
376
+ ],
377
+ "queryParams": [],
378
+ "headerParams": [
379
+ "x-app-id"
380
+ ],
381
+ "hasBody": false
382
+ },
383
+ "renameThread": {
384
+ "method": "POST",
385
+ "path": "/rename-thread/{workspaceSlug}/{threadSlug}",
386
+ "pathParams": [
387
+ "workspaceSlug",
388
+ "threadSlug"
389
+ ],
390
+ "queryParams": [],
391
+ "headerParams": [
392
+ "x-app-id"
393
+ ],
394
+ "hasBody": true
395
+ },
396
+ "renameWorkspace": {
397
+ "method": "POST",
398
+ "path": "/rename-workspace/{workspaceSlug}",
399
+ "pathParams": [
400
+ "workspaceSlug"
401
+ ],
402
+ "queryParams": [],
403
+ "headerParams": [
404
+ "x-app-id"
405
+ ],
406
+ "hasBody": true
407
+ },
408
+ "resumeArtifact": {
409
+ "method": "POST",
410
+ "path": "/resume-artifact/{artifactId}",
411
+ "pathParams": [
412
+ "artifactId"
413
+ ],
414
+ "queryParams": [],
415
+ "headerParams": [
416
+ "x-app-id"
417
+ ],
418
+ "hasBody": false
419
+ },
420
+ "resumeLatestTerminalSession": {
421
+ "method": "POST",
422
+ "path": "/resume-latest-terminal-session",
423
+ "pathParams": [],
424
+ "queryParams": [],
425
+ "headerParams": [
426
+ "x-app-id"
427
+ ],
428
+ "hasBody": true
429
+ },
430
+ "resumeTerminalSession": {
431
+ "method": "POST",
432
+ "path": "/resume-terminal-session/{sessionId}",
433
+ "pathParams": [
434
+ "sessionId"
435
+ ],
436
+ "queryParams": [],
437
+ "headerParams": [
438
+ "x-app-id"
439
+ ],
440
+ "hasBody": true
441
+ },
442
+ "revokeArtifact": {
443
+ "method": "POST",
444
+ "path": "/revoke-artifact/{artifactId}",
445
+ "pathParams": [
446
+ "artifactId"
447
+ ],
448
+ "queryParams": [],
449
+ "headerParams": [
450
+ "x-app-id"
451
+ ],
452
+ "hasBody": false
453
+ },
454
+ "runAutomationFlow": {
455
+ "method": "POST",
456
+ "path": "/{command}",
457
+ "pathParams": [
458
+ "command"
459
+ ],
460
+ "queryParams": [],
461
+ "headerParams": [
462
+ "x-app-id"
463
+ ],
464
+ "hasBody": true
465
+ },
466
+ "runAutomationWorkflow": {
467
+ "method": "POST",
468
+ "path": "/run-automation-workflow",
469
+ "pathParams": [],
470
+ "queryParams": [],
471
+ "headerParams": [
472
+ "x-app-id"
473
+ ],
474
+ "hasBody": true
475
+ },
476
+ "sendChannelFile": {
477
+ "method": "POST",
478
+ "path": "/send-channel-file",
479
+ "pathParams": [],
480
+ "queryParams": [],
481
+ "headerParams": [
482
+ "x-app-id"
483
+ ],
484
+ "hasBody": true
485
+ },
486
+ "sendMessage": {
487
+ "method": "POST",
488
+ "path": "/send-message/{workspaceSlug}/{threadSlug}",
489
+ "pathParams": [
490
+ "workspaceSlug",
491
+ "threadSlug"
492
+ ],
493
+ "queryParams": [],
494
+ "headerParams": [
495
+ "x-app-id"
496
+ ],
497
+ "hasBody": true
498
+ },
499
+ "setHeartbeatActiveHours": {
500
+ "method": "POST",
501
+ "path": "/set-heartbeat-active-hours",
502
+ "pathParams": [],
503
+ "queryParams": [],
504
+ "headerParams": [
505
+ "x-app-id"
506
+ ],
507
+ "hasBody": true
508
+ },
509
+ "setHeartbeatAutoPilot": {
510
+ "method": "POST",
511
+ "path": "/set-heartbeat-auto-pilot",
512
+ "pathParams": [],
513
+ "queryParams": [],
514
+ "headerParams": [
515
+ "x-app-id"
516
+ ],
517
+ "hasBody": true
518
+ },
519
+ "setHeartbeatDefaultAgent": {
520
+ "method": "POST",
521
+ "path": "/set-heartbeat-default-agent",
522
+ "pathParams": [],
523
+ "queryParams": [],
524
+ "headerParams": [
525
+ "x-app-id"
526
+ ],
527
+ "hasBody": true
528
+ },
529
+ "setHeartbeatEnabled": {
530
+ "method": "POST",
531
+ "path": "/set-heartbeat-enabled",
532
+ "pathParams": [],
533
+ "queryParams": [],
534
+ "headerParams": [
535
+ "x-app-id"
536
+ ],
537
+ "hasBody": true
538
+ },
539
+ "setHeartbeatInterval": {
540
+ "method": "POST",
541
+ "path": "/set-heartbeat-interval",
542
+ "pathParams": [],
543
+ "queryParams": [],
544
+ "headerParams": [
545
+ "x-app-id"
546
+ ],
547
+ "hasBody": true
548
+ },
549
+ "setHeartbeatTimezone": {
550
+ "method": "POST",
551
+ "path": "/set-heartbeat-timezone",
552
+ "pathParams": [],
553
+ "queryParams": [],
554
+ "headerParams": [
555
+ "x-app-id"
556
+ ],
557
+ "hasBody": true
558
+ },
559
+ "setupHeartbeatTasks": {
560
+ "method": "GET",
561
+ "path": "/setup-heartbeat-tasks",
562
+ "pathParams": [],
563
+ "queryParams": [
564
+ "workspaceSlug",
565
+ "scope"
566
+ ],
567
+ "headerParams": [
568
+ "x-app-id"
569
+ ],
570
+ "hasBody": false
571
+ },
572
+ "setupPersonality": {
573
+ "method": "GET",
574
+ "path": "/setup-personality",
575
+ "pathParams": [],
576
+ "queryParams": [
577
+ "workspaceSlug",
578
+ "scope"
579
+ ],
580
+ "headerParams": [
581
+ "x-app-id"
582
+ ],
583
+ "hasBody": false
584
+ },
585
+ "setupWorkingDir": {
586
+ "method": "POST",
587
+ "path": "/setup-working-dir",
588
+ "pathParams": [],
589
+ "queryParams": [],
590
+ "headerParams": [],
591
+ "hasBody": true
592
+ },
593
+ "setWorkspaceDefaultAgent": {
594
+ "method": "POST",
595
+ "path": "/set-workspace-default-agent/{workspaceSlug}",
596
+ "pathParams": [
597
+ "workspaceSlug"
598
+ ],
599
+ "queryParams": [],
600
+ "headerParams": [
601
+ "authorization",
602
+ "x-app-id"
603
+ ],
604
+ "hasBody": true
605
+ },
606
+ "startChannel": {
607
+ "method": "POST",
608
+ "path": "/start-channel/{channelId}",
609
+ "pathParams": [
610
+ "channelId"
611
+ ],
612
+ "queryParams": [],
613
+ "headerParams": [
614
+ "x-app-id"
615
+ ],
616
+ "hasBody": false
617
+ },
618
+ "stopChannel": {
619
+ "method": "POST",
620
+ "path": "/stop-channel/{channelId}",
621
+ "pathParams": [
622
+ "channelId"
623
+ ],
624
+ "queryParams": [],
625
+ "headerParams": [
626
+ "x-app-id"
627
+ ],
628
+ "hasBody": false
629
+ },
630
+ "stopThreadTerminalSession": {
631
+ "method": "POST",
632
+ "path": "/stop-thread-terminal-session",
633
+ "pathParams": [],
634
+ "queryParams": [],
635
+ "headerParams": [
636
+ "x-app-id"
637
+ ],
638
+ "hasBody": false
639
+ },
640
+ "terminateTerminalSession": {
641
+ "method": "POST",
642
+ "path": "/terminate-terminal-session/{sessionId}",
643
+ "pathParams": [
644
+ "sessionId"
645
+ ],
646
+ "queryParams": [],
647
+ "headerParams": [
648
+ "x-app-id"
649
+ ],
650
+ "hasBody": false
651
+ },
652
+ "triggerWorkspaceHeartbeat": {
653
+ "method": "POST",
654
+ "path": "/trigger-workspace-heartbeat/{workspaceSlug}",
655
+ "pathParams": [
656
+ "workspaceSlug"
657
+ ],
658
+ "queryParams": [],
659
+ "headerParams": [
660
+ "x-app-id"
661
+ ],
662
+ "hasBody": true
663
+ },
664
+ "triggerWorkspaceHeartbeatTasks": {
665
+ "method": "POST",
666
+ "path": "/trigger-workspace-heartbeat-tasks/{workspaceSlug}",
667
+ "pathParams": [
668
+ "workspaceSlug"
669
+ ],
670
+ "queryParams": [],
671
+ "headerParams": [
672
+ "x-app-id"
673
+ ],
674
+ "hasBody": true
675
+ },
676
+ "updateChannel": {
677
+ "method": "POST",
678
+ "path": "/update-channel/{channelId}",
679
+ "pathParams": [
680
+ "channelId"
681
+ ],
682
+ "queryParams": [],
683
+ "headerParams": [
684
+ "x-app-id"
685
+ ],
686
+ "hasBody": true
687
+ }
688
+ };
689
+
690
+ class RealtimeXApiError extends Error {
691
+ constructor(message, response, body) {
692
+ super(message);
693
+ this.name = 'RealtimeXApiError';
694
+ this.status = response && response.status;
695
+ this.statusText = response && response.statusText;
696
+ this.body = body;
697
+ this.response = response;
698
+ }
699
+ }
700
+
701
+ function joinUrl(baseUrl, pathname) {
702
+ const base = String(baseUrl || '').replace(/\/+$/g, '');
703
+ const path = String(pathname || '').replace(/^\/+/, '');
704
+ return base + '/' + path;
705
+ }
706
+
707
+ function encodePath(pathname, params) {
708
+ let encoded = pathname;
709
+ for (const [key, value] of Object.entries(params || {})) {
710
+ if (value == null) continue;
711
+ encoded = encoded.replace(
712
+ new RegExp('\\{' + key + '\\}', 'g'),
713
+ encodeURIComponent(String(value))
714
+ );
715
+ }
716
+ return encoded;
717
+ }
718
+
719
+ function appendQuery(url, query) {
720
+ const entries = Object.entries(query || {}).filter(([, value]) => value != null);
721
+ if (entries.length === 0) return url;
722
+ const parsed = new URL(url);
723
+ for (const [key, value] of entries) {
724
+ if (Array.isArray(value)) {
725
+ for (const item of value) parsed.searchParams.append(key, String(item));
726
+ } else {
727
+ parsed.searchParams.set(key, String(value));
728
+ }
729
+ }
730
+ return parsed.toString();
731
+ }
732
+
733
+ async function parseResponseBody(response) {
734
+ const text = await response.text();
735
+ if (!text) return null;
736
+ const contentType =
737
+ response.headers && response.headers.get
738
+ ? response.headers.get('content-type') || ''
739
+ : '';
740
+ if (contentType.includes('application/json')) {
741
+ try {
742
+ return JSON.parse(text);
743
+ } catch {
744
+ return text;
745
+ }
746
+ }
747
+ try {
748
+ return JSON.parse(text);
749
+ } catch {
750
+ return text;
751
+ }
752
+ }
753
+
754
+ function isPlainObject(value) {
755
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
756
+ }
757
+
758
+ function isLowLevelRequestOptions(value) {
759
+ return isPlainObject(value) && (
760
+ Object.prototype.hasOwnProperty.call(value, 'params') ||
761
+ Object.prototype.hasOwnProperty.call(value, 'query') ||
762
+ Object.prototype.hasOwnProperty.call(value, 'headers') ||
763
+ Object.prototype.hasOwnProperty.call(value, 'body') ||
764
+ Object.prototype.hasOwnProperty.call(value, 'signal')
765
+ );
766
+ }
767
+
768
+ function mergeRequestOptions(base, overrides) {
769
+ if (!overrides) return base;
770
+ return {
771
+ ...base,
772
+ ...overrides,
773
+ params: { ...(base.params || {}), ...(overrides.params || {}) },
774
+ query: { ...(base.query || {}), ...(overrides.query || {}) },
775
+ headers: { ...(base.headers || {}), ...(overrides.headers || {}) },
776
+ };
777
+ }
778
+
779
+ function normalizeOperationOptions(operation, args) {
780
+ if (!args || args.length === 0) return {};
781
+
782
+ const [first, second, third] = args;
783
+ if (isLowLevelRequestOptions(first)) {
784
+ return mergeRequestOptions(first, second);
785
+ }
786
+
787
+ const options = {};
788
+
789
+ if (operation.hasBody) {
790
+ if (operation.pathParams.length === 1 && args.length >= 2 && !isPlainObject(first)) {
791
+ options.params = { [operation.pathParams[0]]: first };
792
+ options.body = second;
793
+ return mergeRequestOptions(options, third);
794
+ }
795
+ if (operation.pathParams.length > 0 && args.length >= 2) {
796
+ options.params = first || {};
797
+ options.body = second;
798
+ return mergeRequestOptions(options, third);
799
+ }
800
+ options.body = first;
801
+ } else if (operation.pathParams.length === 1 && !isPlainObject(first)) {
802
+ options.params = { [operation.pathParams[0]]: first };
803
+ } else if (operation.pathParams.length > 0) {
804
+ options.params = first || {};
805
+ } else if (operation.queryParams.length > 0) {
806
+ options.query = first || {};
807
+ } else if (isPlainObject(first)) {
808
+ options.query = first;
809
+ }
810
+
811
+ return mergeRequestOptions(options, second);
812
+ }
813
+
814
+ class RealtimeXClient {
815
+ constructor(options = {}) {
816
+ const env = typeof process !== 'undefined' ? process.env || {} : {};
817
+ this.baseUrl =
818
+ options.baseUrl || env.REALTIMEX_BASE_URL || 'http://localhost:3101/cli';
819
+ this.fetch = options.fetch || globalThis.fetch;
820
+ if (typeof this.fetch !== 'function') {
821
+ throw new Error('A fetch implementation is required. Use Node 18+ or pass { fetch }.');
822
+ }
823
+
824
+ this.defaultHeaders = { ...(options.headers || {}) };
825
+ const appId = options.appId || options.appIdAuth || env.REALTIMEX_APP_ID_AUTH;
826
+ const apiKey = options.apiKey || env.REALTIMEX_API_KEY;
827
+ const token = options.token || env.REALTIMEX_AUTH_TOKEN;
828
+ if (appId) this.defaultHeaders['x-app-id'] = appId;
829
+ if (apiKey) this.defaultHeaders['x-api-key'] = apiKey;
830
+ if (token) {
831
+ this.defaultHeaders.Authorization = String(token).startsWith('Bearer ')
832
+ ? token
833
+ : 'Bearer ' + token;
834
+ }
835
+ }
836
+
837
+ async request(operationName, options = {}) {
838
+ const operation = operations[operationName];
839
+ if (!operation) {
840
+ throw new Error('Unknown RealtimeX SDK operation: ' + operationName);
841
+ }
842
+
843
+ const params = options.params || {};
844
+ const query = { ...(options.query || {}) };
845
+ for (const name of operation.queryParams) {
846
+ if (params[name] !== undefined && query[name] === undefined) {
847
+ query[name] = params[name];
848
+ }
849
+ }
850
+
851
+ const headers = { ...this.defaultHeaders, ...(options.headers || {}) };
852
+ for (const name of operation.headerParams) {
853
+ if (params[name] !== undefined && headers[name] === undefined) {
854
+ headers[name] = params[name];
855
+ }
856
+ }
857
+
858
+ let url = joinUrl(this.baseUrl, encodePath(operation.path, params));
859
+ url = appendQuery(url, query);
860
+
861
+ const init = { method: operation.method, headers };
862
+ if (options.signal) init.signal = options.signal;
863
+ if (operation.hasBody || options.body !== undefined) {
864
+ if (options.body !== undefined) {
865
+ headers['content-type'] =
866
+ headers['content-type'] || headers['Content-Type'] || 'application/json';
867
+ init.body =
868
+ typeof options.body === 'string' ? options.body : JSON.stringify(options.body);
869
+ }
870
+ }
871
+
872
+ const response = await this.fetch(url, init);
873
+ const body = await parseResponseBody(response);
874
+ if (!response.ok) {
875
+ throw new RealtimeXApiError(
876
+ 'RealtimeX API request failed: ' + response.status + ' ' + response.statusText,
877
+ response,
878
+ body
879
+ );
880
+ }
881
+ return body;
882
+ }
883
+
884
+ approveChannelPairingCode(...args) {
885
+ return this.request(
886
+ "approveChannelPairingCode",
887
+ normalizeOperationOptions(operations["approveChannelPairingCode"], args)
888
+ );
889
+ }
890
+
891
+ clearWorkspaceDefaultAgent(...args) {
892
+ return this.request(
893
+ "clearWorkspaceDefaultAgent",
894
+ normalizeOperationOptions(operations["clearWorkspaceDefaultAgent"], args)
895
+ );
896
+ }
897
+
898
+ createChannel(...args) {
899
+ return this.request(
900
+ "createChannel",
901
+ normalizeOperationOptions(operations["createChannel"], args)
902
+ );
903
+ }
904
+
905
+ createThread(...args) {
906
+ return this.request(
907
+ "createThread",
908
+ normalizeOperationOptions(operations["createThread"], args)
909
+ );
910
+ }
911
+
912
+ createWorkspace(...args) {
913
+ return this.request(
914
+ "createWorkspace",
915
+ normalizeOperationOptions(operations["createWorkspace"], args)
916
+ );
917
+ }
918
+
919
+ deleteChannel(...args) {
920
+ return this.request(
921
+ "deleteChannel",
922
+ normalizeOperationOptions(operations["deleteChannel"], args)
923
+ );
924
+ }
925
+
926
+ deleteThread(...args) {
927
+ return this.request(
928
+ "deleteThread",
929
+ normalizeOperationOptions(operations["deleteThread"], args)
930
+ );
931
+ }
932
+
933
+ deleteWorkspace(...args) {
934
+ return this.request(
935
+ "deleteWorkspace",
936
+ normalizeOperationOptions(operations["deleteWorkspace"], args)
937
+ );
938
+ }
939
+
940
+ disablePlugin(...args) {
941
+ return this.request(
942
+ "disablePlugin",
943
+ normalizeOperationOptions(operations["disablePlugin"], args)
944
+ );
945
+ }
946
+
947
+ disableWorkspaceAgentSkill(...args) {
948
+ return this.request(
949
+ "disableWorkspaceAgentSkill",
950
+ normalizeOperationOptions(operations["disableWorkspaceAgentSkill"], args)
951
+ );
952
+ }
953
+
954
+ enablePlugin(...args) {
955
+ return this.request(
956
+ "enablePlugin",
957
+ normalizeOperationOptions(operations["enablePlugin"], args)
958
+ );
959
+ }
960
+
961
+ enableWorkspaceAgentSkill(...args) {
962
+ return this.request(
963
+ "enableWorkspaceAgentSkill",
964
+ normalizeOperationOptions(operations["enableWorkspaceAgentSkill"], args)
965
+ );
966
+ }
967
+
968
+ getArtifact(...args) {
969
+ return this.request(
970
+ "getArtifact",
971
+ normalizeOperationOptions(operations["getArtifact"], args)
972
+ );
973
+ }
974
+
975
+ getThread(...args) {
976
+ return this.request(
977
+ "getThread",
978
+ normalizeOperationOptions(operations["getThread"], args)
979
+ );
980
+ }
981
+
982
+ getWorkspace(...args) {
983
+ return this.request(
984
+ "getWorkspace",
985
+ normalizeOperationOptions(operations["getWorkspace"], args)
986
+ );
987
+ }
988
+
989
+ listAgentSkills(...args) {
990
+ return this.request(
991
+ "listAgentSkills",
992
+ normalizeOperationOptions(operations["listAgentSkills"], args)
993
+ );
994
+ }
995
+
996
+ listArtifacts(...args) {
997
+ return this.request(
998
+ "listArtifacts",
999
+ normalizeOperationOptions(operations["listArtifacts"], args)
1000
+ );
1001
+ }
1002
+
1003
+ listChannels(...args) {
1004
+ return this.request(
1005
+ "listChannels",
1006
+ normalizeOperationOptions(operations["listChannels"], args)
1007
+ );
1008
+ }
1009
+
1010
+ listLlmModels(...args) {
1011
+ return this.request(
1012
+ "listLlmModels",
1013
+ normalizeOperationOptions(operations["listLlmModels"], args)
1014
+ );
1015
+ }
1016
+
1017
+ listLlmProviders(...args) {
1018
+ return this.request(
1019
+ "listLlmProviders",
1020
+ normalizeOperationOptions(operations["listLlmProviders"], args)
1021
+ );
1022
+ }
1023
+
1024
+ listPlugins(...args) {
1025
+ return this.request(
1026
+ "listPlugins",
1027
+ normalizeOperationOptions(operations["listPlugins"], args)
1028
+ );
1029
+ }
1030
+
1031
+ listTerminalAgents(...args) {
1032
+ return this.request(
1033
+ "listTerminalAgents",
1034
+ normalizeOperationOptions(operations["listTerminalAgents"], args)
1035
+ );
1036
+ }
1037
+
1038
+ listTerminalSessions(...args) {
1039
+ return this.request(
1040
+ "listTerminalSessions",
1041
+ normalizeOperationOptions(operations["listTerminalSessions"], args)
1042
+ );
1043
+ }
1044
+
1045
+ listThreads(...args) {
1046
+ return this.request(
1047
+ "listThreads",
1048
+ normalizeOperationOptions(operations["listThreads"], args)
1049
+ );
1050
+ }
1051
+
1052
+ listWorkspaceAgentSkills(...args) {
1053
+ return this.request(
1054
+ "listWorkspaceAgentSkills",
1055
+ normalizeOperationOptions(operations["listWorkspaceAgentSkills"], args)
1056
+ );
1057
+ }
1058
+
1059
+ listWorkspaces(...args) {
1060
+ return this.request(
1061
+ "listWorkspaces",
1062
+ normalizeOperationOptions(operations["listWorkspaces"], args)
1063
+ );
1064
+ }
1065
+
1066
+ openTerminalSession(...args) {
1067
+ return this.request(
1068
+ "openTerminalSession",
1069
+ normalizeOperationOptions(operations["openTerminalSession"], args)
1070
+ );
1071
+ }
1072
+
1073
+ pauseArtifact(...args) {
1074
+ return this.request(
1075
+ "pauseArtifact",
1076
+ normalizeOperationOptions(operations["pauseArtifact"], args)
1077
+ );
1078
+ }
1079
+
1080
+ prepare(...args) {
1081
+ return this.request(
1082
+ "prepare",
1083
+ normalizeOperationOptions(operations["prepare"], args)
1084
+ );
1085
+ }
1086
+
1087
+ publishArtifact(...args) {
1088
+ return this.request(
1089
+ "publishArtifact",
1090
+ normalizeOperationOptions(operations["publishArtifact"], args)
1091
+ );
1092
+ }
1093
+
1094
+ reloadAgentSkills(...args) {
1095
+ return this.request(
1096
+ "reloadAgentSkills",
1097
+ normalizeOperationOptions(operations["reloadAgentSkills"], args)
1098
+ );
1099
+ }
1100
+
1101
+ reloadPlugin(...args) {
1102
+ return this.request(
1103
+ "reloadPlugin",
1104
+ normalizeOperationOptions(operations["reloadPlugin"], args)
1105
+ );
1106
+ }
1107
+
1108
+ renameThread(...args) {
1109
+ return this.request(
1110
+ "renameThread",
1111
+ normalizeOperationOptions(operations["renameThread"], args)
1112
+ );
1113
+ }
1114
+
1115
+ renameWorkspace(...args) {
1116
+ return this.request(
1117
+ "renameWorkspace",
1118
+ normalizeOperationOptions(operations["renameWorkspace"], args)
1119
+ );
1120
+ }
1121
+
1122
+ resumeArtifact(...args) {
1123
+ return this.request(
1124
+ "resumeArtifact",
1125
+ normalizeOperationOptions(operations["resumeArtifact"], args)
1126
+ );
1127
+ }
1128
+
1129
+ resumeLatestTerminalSession(...args) {
1130
+ return this.request(
1131
+ "resumeLatestTerminalSession",
1132
+ normalizeOperationOptions(operations["resumeLatestTerminalSession"], args)
1133
+ );
1134
+ }
1135
+
1136
+ resumeTerminalSession(...args) {
1137
+ return this.request(
1138
+ "resumeTerminalSession",
1139
+ normalizeOperationOptions(operations["resumeTerminalSession"], args)
1140
+ );
1141
+ }
1142
+
1143
+ revokeArtifact(...args) {
1144
+ return this.request(
1145
+ "revokeArtifact",
1146
+ normalizeOperationOptions(operations["revokeArtifact"], args)
1147
+ );
1148
+ }
1149
+
1150
+ runAutomationFlow(...args) {
1151
+ return this.request(
1152
+ "runAutomationFlow",
1153
+ normalizeOperationOptions(operations["runAutomationFlow"], args)
1154
+ );
1155
+ }
1156
+
1157
+ runAutomationWorkflow(...args) {
1158
+ return this.request(
1159
+ "runAutomationWorkflow",
1160
+ normalizeOperationOptions(operations["runAutomationWorkflow"], args)
1161
+ );
1162
+ }
1163
+
1164
+ sendChannelFile(...args) {
1165
+ return this.request(
1166
+ "sendChannelFile",
1167
+ normalizeOperationOptions(operations["sendChannelFile"], args)
1168
+ );
1169
+ }
1170
+
1171
+ sendMessage(...args) {
1172
+ return this.request(
1173
+ "sendMessage",
1174
+ normalizeOperationOptions(operations["sendMessage"], args)
1175
+ );
1176
+ }
1177
+
1178
+ setHeartbeatActiveHours(...args) {
1179
+ return this.request(
1180
+ "setHeartbeatActiveHours",
1181
+ normalizeOperationOptions(operations["setHeartbeatActiveHours"], args)
1182
+ );
1183
+ }
1184
+
1185
+ setHeartbeatAutoPilot(...args) {
1186
+ return this.request(
1187
+ "setHeartbeatAutoPilot",
1188
+ normalizeOperationOptions(operations["setHeartbeatAutoPilot"], args)
1189
+ );
1190
+ }
1191
+
1192
+ setHeartbeatDefaultAgent(...args) {
1193
+ return this.request(
1194
+ "setHeartbeatDefaultAgent",
1195
+ normalizeOperationOptions(operations["setHeartbeatDefaultAgent"], args)
1196
+ );
1197
+ }
1198
+
1199
+ setHeartbeatEnabled(...args) {
1200
+ return this.request(
1201
+ "setHeartbeatEnabled",
1202
+ normalizeOperationOptions(operations["setHeartbeatEnabled"], args)
1203
+ );
1204
+ }
1205
+
1206
+ setHeartbeatInterval(...args) {
1207
+ return this.request(
1208
+ "setHeartbeatInterval",
1209
+ normalizeOperationOptions(operations["setHeartbeatInterval"], args)
1210
+ );
1211
+ }
1212
+
1213
+ setHeartbeatTimezone(...args) {
1214
+ return this.request(
1215
+ "setHeartbeatTimezone",
1216
+ normalizeOperationOptions(operations["setHeartbeatTimezone"], args)
1217
+ );
1218
+ }
1219
+
1220
+ setupHeartbeatTasks(...args) {
1221
+ return this.request(
1222
+ "setupHeartbeatTasks",
1223
+ normalizeOperationOptions(operations["setupHeartbeatTasks"], args)
1224
+ );
1225
+ }
1226
+
1227
+ setupPersonality(...args) {
1228
+ return this.request(
1229
+ "setupPersonality",
1230
+ normalizeOperationOptions(operations["setupPersonality"], args)
1231
+ );
1232
+ }
1233
+
1234
+ setupWorkingDir(...args) {
1235
+ return this.request(
1236
+ "setupWorkingDir",
1237
+ normalizeOperationOptions(operations["setupWorkingDir"], args)
1238
+ );
1239
+ }
1240
+
1241
+ setWorkspaceDefaultAgent(...args) {
1242
+ return this.request(
1243
+ "setWorkspaceDefaultAgent",
1244
+ normalizeOperationOptions(operations["setWorkspaceDefaultAgent"], args)
1245
+ );
1246
+ }
1247
+
1248
+ startChannel(...args) {
1249
+ return this.request(
1250
+ "startChannel",
1251
+ normalizeOperationOptions(operations["startChannel"], args)
1252
+ );
1253
+ }
1254
+
1255
+ stopChannel(...args) {
1256
+ return this.request(
1257
+ "stopChannel",
1258
+ normalizeOperationOptions(operations["stopChannel"], args)
1259
+ );
1260
+ }
1261
+
1262
+ stopThreadTerminalSession(...args) {
1263
+ return this.request(
1264
+ "stopThreadTerminalSession",
1265
+ normalizeOperationOptions(operations["stopThreadTerminalSession"], args)
1266
+ );
1267
+ }
1268
+
1269
+ terminateTerminalSession(...args) {
1270
+ return this.request(
1271
+ "terminateTerminalSession",
1272
+ normalizeOperationOptions(operations["terminateTerminalSession"], args)
1273
+ );
1274
+ }
1275
+
1276
+ triggerWorkspaceHeartbeat(...args) {
1277
+ return this.request(
1278
+ "triggerWorkspaceHeartbeat",
1279
+ normalizeOperationOptions(operations["triggerWorkspaceHeartbeat"], args)
1280
+ );
1281
+ }
1282
+
1283
+ triggerWorkspaceHeartbeatTasks(...args) {
1284
+ return this.request(
1285
+ "triggerWorkspaceHeartbeatTasks",
1286
+ normalizeOperationOptions(operations["triggerWorkspaceHeartbeatTasks"], args)
1287
+ );
1288
+ }
1289
+
1290
+ updateChannel(...args) {
1291
+ return this.request(
1292
+ "updateChannel",
1293
+ normalizeOperationOptions(operations["updateChannel"], args)
1294
+ );
1295
+ }
1296
+ }
1297
+
1298
+ function createRealtimeXClient(options = {}) {
1299
+ return new RealtimeXClient(options);
1300
+ }
1301
+
1302
+ module.exports = {
1303
+ RealtimeXApiError,
1304
+ RealtimeXClient,
1305
+ createClient: createRealtimeXClient,
1306
+ createRealtimeXClient,
1307
+ operations,
1308
+ version: "2.0.19",
1309
+ };