@almadar/integrations 2.0.2 → 2.0.4

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