@realtimex/sdk 2.0.18 → 2.0.20

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