@almadar/integrations 2.12.0 → 2.13.0

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.
@@ -0,0 +1,880 @@
1
+ import { ServiceParams } from '@almadar/core';
2
+ import { d as IntegrationParams } from './BaseIntegration-B9lSTRQm.js';
3
+
4
+ /**
5
+ * ServiceContract type definitions for all @almadar/integrations.
6
+ *
7
+ * Each integration defines its own action map as a Record<string, ServiceAction>,
8
+ * suitable for use with ServiceContract<T> from @almadar/core.
9
+ *
10
+ * Types are simplified representations of the actual params/results. They capture
11
+ * the contract shape without pulling in third-party SDK types (Stripe, Twilio, etc.).
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+
16
+ type GitHubActions = {
17
+ cloneRepo: {
18
+ params: {
19
+ repoUrl: string;
20
+ targetDir: string;
21
+ branch?: string;
22
+ };
23
+ result: {
24
+ message: string;
25
+ };
26
+ };
27
+ createBranch: {
28
+ params: {
29
+ branchName: string;
30
+ baseBranch?: string;
31
+ };
32
+ result: {
33
+ message: string;
34
+ };
35
+ };
36
+ commit: {
37
+ params: {
38
+ message: string;
39
+ files?: string[];
40
+ };
41
+ result: {
42
+ message: string;
43
+ };
44
+ };
45
+ push: {
46
+ params: {
47
+ branchName: string;
48
+ force?: boolean;
49
+ };
50
+ result: {
51
+ message: string;
52
+ };
53
+ };
54
+ createPR: {
55
+ params: {
56
+ title: string;
57
+ body: string;
58
+ head: string;
59
+ base: string;
60
+ };
61
+ result: {
62
+ number: number;
63
+ url: string;
64
+ title: string;
65
+ };
66
+ };
67
+ getPRComments: {
68
+ params: {
69
+ prNumber: number;
70
+ };
71
+ result: {
72
+ comments: Array<{
73
+ id: number;
74
+ body: string;
75
+ user: string;
76
+ }>;
77
+ };
78
+ };
79
+ listIssues: {
80
+ params: {
81
+ state?: string;
82
+ labels?: string[];
83
+ per_page?: number;
84
+ };
85
+ result: {
86
+ issues: Array<{
87
+ number: number;
88
+ title: string;
89
+ state: string;
90
+ }>;
91
+ };
92
+ };
93
+ getIssue: {
94
+ params: {
95
+ issueNumber: number;
96
+ };
97
+ result: {
98
+ number: number;
99
+ title: string;
100
+ body: string;
101
+ state: string;
102
+ };
103
+ };
104
+ getFile: {
105
+ params: {
106
+ owner: string;
107
+ repo: string;
108
+ path: string;
109
+ ref?: string;
110
+ };
111
+ result: {
112
+ path: string;
113
+ content: string;
114
+ sha: string;
115
+ size: number;
116
+ };
117
+ };
118
+ listCommits: {
119
+ params: {
120
+ owner: string;
121
+ repo: string;
122
+ path?: string;
123
+ ref?: string;
124
+ per_page?: number;
125
+ };
126
+ result: {
127
+ commits: Array<{
128
+ sha: string;
129
+ message: string;
130
+ author: string;
131
+ date: string;
132
+ }>;
133
+ };
134
+ };
135
+ createIssue: {
136
+ params: {
137
+ owner: string;
138
+ repo: string;
139
+ title: string;
140
+ body?: string;
141
+ labels?: string[];
142
+ };
143
+ result: {
144
+ number: number;
145
+ title: string;
146
+ url: string;
147
+ };
148
+ };
149
+ };
150
+ type StripeActions = {
151
+ createPaymentIntent: {
152
+ params: {
153
+ amount: number;
154
+ currency: string;
155
+ metadata?: Record<string, string>;
156
+ };
157
+ result: {
158
+ id: string;
159
+ clientSecret: string;
160
+ status: string;
161
+ amount: number;
162
+ currency: string;
163
+ };
164
+ };
165
+ confirmPayment: {
166
+ params: {
167
+ paymentIntentId: string;
168
+ };
169
+ result: {
170
+ id: string;
171
+ status: string;
172
+ };
173
+ };
174
+ refund: {
175
+ params: {
176
+ paymentIntentId: string;
177
+ amount?: number;
178
+ };
179
+ result: {
180
+ id: string;
181
+ status: string;
182
+ amount: number;
183
+ };
184
+ };
185
+ };
186
+ type LLMIntegrationActions = {
187
+ generate: {
188
+ params: {
189
+ userPrompt: string;
190
+ systemPrompt?: string;
191
+ model?: string;
192
+ temperature?: number;
193
+ maxTokens?: number;
194
+ };
195
+ result: {
196
+ content: string;
197
+ usage: {
198
+ promptTokens?: number;
199
+ completionTokens?: number;
200
+ totalTokens?: number;
201
+ tokens?: number;
202
+ };
203
+ };
204
+ };
205
+ classify: {
206
+ params: {
207
+ text: string;
208
+ categories: string[];
209
+ model?: string;
210
+ };
211
+ result: {
212
+ category: string;
213
+ confidence: number;
214
+ reasoning: string;
215
+ };
216
+ };
217
+ extract: {
218
+ params: {
219
+ text: string;
220
+ schema: IntegrationParams;
221
+ model?: string;
222
+ };
223
+ result: IntegrationParams;
224
+ };
225
+ summarize: {
226
+ params: {
227
+ text: string;
228
+ maxLength?: number;
229
+ style?: string;
230
+ model?: string;
231
+ };
232
+ result: {
233
+ summary: string;
234
+ keyPoints: string[];
235
+ };
236
+ };
237
+ };
238
+ type YouTubeActions = {
239
+ search: {
240
+ params: {
241
+ query: string;
242
+ maxResults?: number;
243
+ type?: string;
244
+ };
245
+ result: Array<{
246
+ videoId: string;
247
+ title: string;
248
+ thumbnail: string;
249
+ description: string;
250
+ }>;
251
+ };
252
+ getVideo: {
253
+ params: {
254
+ videoId: string;
255
+ };
256
+ result: {
257
+ title: string;
258
+ description: string;
259
+ viewCount: string;
260
+ likeCount: string;
261
+ };
262
+ };
263
+ getChannel: {
264
+ params: {
265
+ channelId: string;
266
+ };
267
+ result: {
268
+ name: string;
269
+ description: string;
270
+ subscriberCount: string;
271
+ };
272
+ };
273
+ };
274
+ type TwilioActions = {
275
+ sendSMS: {
276
+ params: {
277
+ to: string;
278
+ body: string;
279
+ };
280
+ result: {
281
+ sid: string;
282
+ status: string;
283
+ };
284
+ };
285
+ sendWhatsApp: {
286
+ params: {
287
+ to: string;
288
+ body: string;
289
+ };
290
+ result: {
291
+ sid: string;
292
+ status: string;
293
+ };
294
+ };
295
+ };
296
+ type EmailActions = {
297
+ send: {
298
+ params: {
299
+ to: string;
300
+ subject: string;
301
+ body: string;
302
+ from?: string;
303
+ };
304
+ result: {
305
+ id: string;
306
+ status: string;
307
+ };
308
+ };
309
+ };
310
+ type DockerActions = {
311
+ build: {
312
+ params: {
313
+ tag: string;
314
+ dockerfile?: string;
315
+ context?: string;
316
+ buildArgs?: Record<string, string>;
317
+ };
318
+ result: {
319
+ imageId: string;
320
+ tag: string;
321
+ size: number;
322
+ buildTime: number;
323
+ };
324
+ };
325
+ run: {
326
+ params: {
327
+ image: string;
328
+ name?: string;
329
+ ports?: Array<{
330
+ host: number;
331
+ container: number;
332
+ protocol?: string;
333
+ }>;
334
+ env?: Record<string, string>;
335
+ volumes?: Array<{
336
+ host: string;
337
+ container: string;
338
+ }>;
339
+ command?: string;
340
+ };
341
+ result: {
342
+ containerId: string;
343
+ name: string;
344
+ status: string;
345
+ ports: Array<{
346
+ host: number;
347
+ container: number;
348
+ protocol: string;
349
+ }>;
350
+ };
351
+ };
352
+ stop: {
353
+ params: {
354
+ containerId: string;
355
+ };
356
+ result: {
357
+ containerId: string;
358
+ status: string;
359
+ stoppedAt: number;
360
+ };
361
+ };
362
+ remove: {
363
+ params: {
364
+ containerId: string;
365
+ force?: boolean;
366
+ };
367
+ result: {
368
+ containerId: string;
369
+ removed: boolean;
370
+ };
371
+ };
372
+ logs: {
373
+ params: {
374
+ containerId: string;
375
+ tail?: number;
376
+ since?: string;
377
+ };
378
+ result: {
379
+ containerId: string;
380
+ logs: string[];
381
+ lineCount: number;
382
+ };
383
+ };
384
+ status: {
385
+ params: {
386
+ containerId: string;
387
+ };
388
+ result: {
389
+ containerId: string;
390
+ name: string;
391
+ image: string;
392
+ status: string;
393
+ ports: Array<{
394
+ host: number;
395
+ container: number;
396
+ protocol: string;
397
+ }>;
398
+ createdAt: number;
399
+ startedAt: number | null;
400
+ stoppedAt: number | null;
401
+ };
402
+ };
403
+ list: {
404
+ params: {
405
+ all?: boolean;
406
+ filterByLabel?: string;
407
+ };
408
+ result: {
409
+ containers: Array<{
410
+ id: string;
411
+ name: string;
412
+ image: string;
413
+ status: string;
414
+ ports: Array<{
415
+ host: number;
416
+ container: number;
417
+ protocol: string;
418
+ }>;
419
+ createdAt: number;
420
+ }>;
421
+ total: number;
422
+ };
423
+ };
424
+ };
425
+ type StorageActions = {
426
+ upload: {
427
+ params: {
428
+ bucket: string;
429
+ key?: string;
430
+ content?: string;
431
+ contentType?: string;
432
+ file?: IntegrationParams;
433
+ acl?: 'public' | 'private';
434
+ maxSize?: number;
435
+ metadata?: IntegrationParams;
436
+ };
437
+ result: {
438
+ key: string;
439
+ bucket: string;
440
+ size: number;
441
+ etag: string;
442
+ };
443
+ };
444
+ download: {
445
+ params: {
446
+ bucket: string;
447
+ key: string;
448
+ };
449
+ result: {
450
+ content: string;
451
+ contentType: string;
452
+ size: number;
453
+ metadata: IntegrationParams;
454
+ };
455
+ };
456
+ list: {
457
+ params: {
458
+ bucket: string;
459
+ prefix?: string;
460
+ maxKeys?: number;
461
+ };
462
+ result: {
463
+ keys: Array<{
464
+ key: string;
465
+ size: number;
466
+ lastModified: number;
467
+ }>;
468
+ truncated: boolean;
469
+ };
470
+ };
471
+ delete: {
472
+ params: {
473
+ bucket: string;
474
+ key: string;
475
+ };
476
+ result: {
477
+ deleted: boolean;
478
+ };
479
+ };
480
+ getSignedUrl: {
481
+ params: {
482
+ bucket: string;
483
+ key: string;
484
+ expiresIn?: number;
485
+ operation?: 'get' | 'put';
486
+ };
487
+ result: {
488
+ url: string;
489
+ expiresAt: number;
490
+ };
491
+ };
492
+ };
493
+ type QueueActions = {
494
+ enqueue: {
495
+ params: {
496
+ queue: string;
497
+ payload: ServiceParams;
498
+ delay?: number;
499
+ priority?: number;
500
+ };
501
+ result: {
502
+ jobId: string;
503
+ position: number;
504
+ };
505
+ };
506
+ dequeue: {
507
+ params: {
508
+ queue: string;
509
+ };
510
+ result: {
511
+ job: {
512
+ id: string;
513
+ payload: ServiceParams;
514
+ enqueuedAt: number;
515
+ priority: number;
516
+ } | null;
517
+ };
518
+ };
519
+ status: {
520
+ params: {
521
+ jobId: string;
522
+ };
523
+ result: {
524
+ status: 'pending' | 'processing' | 'completed' | 'failed';
525
+ job: {
526
+ id: string;
527
+ payload: ServiceParams;
528
+ enqueuedAt: number;
529
+ priority: number;
530
+ } | null;
531
+ };
532
+ };
533
+ complete: {
534
+ params: {
535
+ jobId: string;
536
+ result?: ServiceParams;
537
+ };
538
+ result: {
539
+ completed: boolean;
540
+ };
541
+ };
542
+ fail: {
543
+ params: {
544
+ jobId: string;
545
+ error?: string;
546
+ };
547
+ result: {
548
+ failed: boolean;
549
+ };
550
+ };
551
+ cancel: {
552
+ params: {
553
+ jobId: string;
554
+ };
555
+ result: {
556
+ cancelled: boolean;
557
+ };
558
+ };
559
+ size: {
560
+ params: {
561
+ queue: string;
562
+ };
563
+ result: {
564
+ size: number;
565
+ pending: number;
566
+ processing: number;
567
+ };
568
+ };
569
+ };
570
+ type RedisActions = {
571
+ get: {
572
+ params: {
573
+ key: string;
574
+ };
575
+ result: {
576
+ value: ServiceParams;
577
+ };
578
+ };
579
+ set: {
580
+ params: {
581
+ key: string;
582
+ value: ServiceParams;
583
+ ttl?: number;
584
+ };
585
+ result: {
586
+ ok: boolean;
587
+ };
588
+ };
589
+ delete: {
590
+ params: {
591
+ key: string;
592
+ };
593
+ result: {
594
+ deleted: boolean;
595
+ };
596
+ };
597
+ lock: {
598
+ params: {
599
+ key: string;
600
+ ttl?: number;
601
+ };
602
+ result: {
603
+ acquired: boolean;
604
+ lockId: string;
605
+ };
606
+ };
607
+ unlock: {
608
+ params: {
609
+ key: string;
610
+ lockId: string;
611
+ };
612
+ result: {
613
+ released: boolean;
614
+ };
615
+ };
616
+ increment: {
617
+ params: {
618
+ key: string;
619
+ by?: number;
620
+ };
621
+ result: {
622
+ value: number;
623
+ };
624
+ };
625
+ expire: {
626
+ params: {
627
+ key: string;
628
+ ttl: number;
629
+ };
630
+ result: {
631
+ set: boolean;
632
+ };
633
+ };
634
+ publish: {
635
+ params: {
636
+ channel: string;
637
+ message: ServiceParams;
638
+ };
639
+ result: {
640
+ receivers: number;
641
+ };
642
+ };
643
+ subscribe: {
644
+ params: {
645
+ channel: string;
646
+ };
647
+ result: {
648
+ subscribed: boolean;
649
+ };
650
+ };
651
+ };
652
+ type OAuthActions = {
653
+ authorize: {
654
+ params: {
655
+ provider: 'google' | 'github' | 'auth0';
656
+ scopes: string[];
657
+ redirectUri: string;
658
+ };
659
+ result: {
660
+ authUrl: string;
661
+ state: string;
662
+ };
663
+ };
664
+ token: {
665
+ params: {
666
+ code: string;
667
+ state: string;
668
+ };
669
+ result: {
670
+ accessToken: string;
671
+ refreshToken: string;
672
+ expiresIn: number;
673
+ tokenType: 'bearer';
674
+ };
675
+ };
676
+ refresh: {
677
+ params: {
678
+ refreshToken: string;
679
+ };
680
+ result: {
681
+ accessToken: string;
682
+ expiresIn: number;
683
+ };
684
+ };
685
+ revoke: {
686
+ params: {
687
+ token: string;
688
+ };
689
+ result: {
690
+ revoked: boolean;
691
+ };
692
+ };
693
+ userinfo: {
694
+ params: {
695
+ accessToken: string;
696
+ };
697
+ result: {
698
+ sub: string;
699
+ email: string;
700
+ name: string;
701
+ picture: string;
702
+ };
703
+ };
704
+ };
705
+ type OtelActions = {
706
+ startSpan: {
707
+ params: {
708
+ name: string;
709
+ attributes?: IntegrationParams;
710
+ traceId?: string;
711
+ };
712
+ result: {
713
+ spanId: string;
714
+ traceId: string;
715
+ };
716
+ };
717
+ endSpan: {
718
+ params: {
719
+ spanId: string;
720
+ status?: 'ok' | 'error';
721
+ };
722
+ result: {
723
+ ended: boolean;
724
+ };
725
+ };
726
+ addEvent: {
727
+ params: {
728
+ spanId: string;
729
+ name: string;
730
+ attributes?: IntegrationParams;
731
+ };
732
+ result: {
733
+ added: boolean;
734
+ };
735
+ };
736
+ recordMetric: {
737
+ params: {
738
+ name: string;
739
+ value: number;
740
+ type?: 'counter' | 'gauge' | 'histogram';
741
+ labels?: IntegrationParams;
742
+ };
743
+ result: {
744
+ recorded: boolean;
745
+ };
746
+ };
747
+ getSpan: {
748
+ params: {
749
+ spanId: string;
750
+ };
751
+ result: {
752
+ spanId: string;
753
+ traceId: string;
754
+ name: string;
755
+ startTime: number;
756
+ endTime?: number;
757
+ status?: 'ok' | 'error';
758
+ attributes: IntegrationParams;
759
+ } | null;
760
+ };
761
+ getMetrics: {
762
+ params: Record<string, never>;
763
+ result: Record<string, {
764
+ name: string;
765
+ type: string;
766
+ value: number;
767
+ values: number[];
768
+ labels: IntegrationParams;
769
+ }>;
770
+ };
771
+ };
772
+ type CLIActions = {
773
+ validate: {
774
+ params: {
775
+ schema: string;
776
+ };
777
+ result: {
778
+ valid: boolean;
779
+ errors: string[];
780
+ warnings: string[];
781
+ summary: string;
782
+ };
783
+ };
784
+ };
785
+ type DeepAgentActions = {
786
+ sendMessage: {
787
+ params: {
788
+ message: string;
789
+ threadId?: string;
790
+ skill?: string;
791
+ context?: IntegrationParams;
792
+ };
793
+ result: {
794
+ response: string;
795
+ threadId: string;
796
+ };
797
+ };
798
+ cancelGeneration: {
799
+ params: {
800
+ threadId: string;
801
+ };
802
+ result: {
803
+ cancelled: boolean;
804
+ };
805
+ };
806
+ validateSchema: {
807
+ params: {
808
+ schema: string;
809
+ };
810
+ result: {
811
+ valid: boolean;
812
+ errors: string[];
813
+ };
814
+ };
815
+ compileSchema: {
816
+ params: {
817
+ schema: string;
818
+ shell?: string;
819
+ };
820
+ result: {
821
+ output: string;
822
+ files: string[];
823
+ };
824
+ };
825
+ getThreadHistory: {
826
+ params: {
827
+ threadId: string;
828
+ };
829
+ result: {
830
+ messages: Array<{
831
+ role: string;
832
+ content: string;
833
+ timestamp: number;
834
+ }>;
835
+ };
836
+ };
837
+ };
838
+ /**
839
+ * Maps each integration name (as used in `registerIntegration`) to its action
840
+ * map type. Use with `ServiceContract<IntegrationContracts[K]>` to get a fully
841
+ * typed service interface for a specific integration.
842
+ *
843
+ * @example
844
+ * ```typescript
845
+ * import type { ServiceContract } from '@almadar/core';
846
+ * import type { IntegrationContracts } from '@almadar/integrations';
847
+ *
848
+ * type TypedStripe = ServiceContract<IntegrationContracts['stripe']>;
849
+ * ```
850
+ */
851
+ type IntegrationContracts = {
852
+ github: GitHubActions;
853
+ stripe: StripeActions;
854
+ llm: LLMIntegrationActions;
855
+ youtube: YouTubeActions;
856
+ twilio: TwilioActions;
857
+ email: EmailActions;
858
+ docker: DockerActions;
859
+ storage: StorageActions;
860
+ queue: QueueActions;
861
+ redis: RedisActions;
862
+ oauth: OAuthActions;
863
+ otel: OtelActions;
864
+ cli: CLIActions;
865
+ deepagent: DeepAgentActions;
866
+ };
867
+ /** Integration name literal union. */
868
+ type IntegrationName = keyof IntegrationContracts;
869
+ /**
870
+ * Helper: extract the action names for a given integration.
871
+ *
872
+ * @example
873
+ * ```typescript
874
+ * type StripeAction = IntegrationActionName<'stripe'>;
875
+ * // => 'createPaymentIntent' | 'confirmPayment' | 'refund'
876
+ * ```
877
+ */
878
+ type IntegrationActionName<K extends IntegrationName> = keyof IntegrationContracts[K] & string;
879
+
880
+ export type { CLIActions as C, DeepAgentActions as D, EmailActions as E, GitHubActions as G, IntegrationActionName as I, LLMIntegrationActions as L, OAuthActions as O, QueueActions as Q, RedisActions as R, StorageActions as S, TwilioActions as T, YouTubeActions as Y, DockerActions as a, IntegrationContracts as b, IntegrationName as c, OtelActions as d, StripeActions as e };