@almadar/integrations 1.0.14 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/integrations",
3
- "version": "1.0.14",
3
+ "version": "2.0.0",
4
4
  "description": "External service integrations for Almadar applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,6 +18,10 @@
18
18
  "./mocks": {
19
19
  "import": "./dist/mocks/index.js",
20
20
  "types": "./dist/mocks/index.d.ts"
21
+ },
22
+ "./github": {
23
+ "import": "./dist/integrations/github/index.js",
24
+ "types": "./dist/integrations/github/index.d.ts"
21
25
  }
22
26
  },
23
27
  "files": [
@@ -28,15 +32,16 @@
28
32
  "access": "public"
29
33
  },
30
34
  "dependencies": {
35
+ "@almadar/core": ">=2.0.0",
36
+ "@almadar/patterns": ">=2.0.0",
37
+ "@almadar/llm": ">=2.0.0",
31
38
  "stripe": "^17.5.0",
32
39
  "twilio": "^5.3.6",
33
40
  "@sendgrid/mail": "^8.1.4",
34
41
  "resend": "^4.0.1",
35
42
  "googleapis": "^144.0.0",
36
43
  "dotenv": "^16.4.0",
37
- "@almadar/core": "1.0.15",
38
- "@almadar/patterns": "1.1.0",
39
- "@almadar/llm": "1.0.15"
44
+ "zod": "^3.23.0"
40
45
  },
41
46
  "devDependencies": {
42
47
  "@types/node": "^20.0.0",
@@ -47,7 +52,7 @@
47
52
  "repository": {
48
53
  "type": "git",
49
54
  "url": "https://github.com/almadar-io/almadar.git",
50
- "directory": "packages/almadar-integrations"
55
+ "directory": "docs/packages/integrations"
51
56
  },
52
57
  "license": "MIT",
53
58
  "keywords": [
@@ -60,6 +65,7 @@
60
65
  "llm",
61
66
  "api"
62
67
  ],
68
+ "homepage": "https://github.com/almadar-io/almadar#readme",
63
69
  "scripts": {
64
70
  "build": "tsup",
65
71
  "build:watch": "tsup --watch",
@@ -1,159 +0,0 @@
1
- /**
2
- * Core types for Almadar integrations
3
- */
4
- /**
5
- * Configuration for an integration instance
6
- */
7
- interface IntegrationConfig {
8
- /** Integration name (matches registry) */
9
- name: string;
10
- /** Environment variables (API keys, secrets) */
11
- env: Record<string, string>;
12
- /** Optional logger */
13
- logger?: IntegrationLogger;
14
- /** Optional rate limiting config */
15
- rateLimit?: {
16
- requestsPerSecond: number;
17
- burstSize: number;
18
- };
19
- /** Optional timeout (ms) */
20
- timeout?: number;
21
- /** Optional retry config */
22
- retry?: {
23
- maxAttempts: number;
24
- backoffMs: number;
25
- maxBackoffMs?: number;
26
- };
27
- }
28
- /**
29
- * Result of an integration action call
30
- */
31
- interface IntegrationResult<T = unknown> {
32
- /** Success flag */
33
- success: boolean;
34
- /** Response data (on success) */
35
- data?: T;
36
- /** Error (on failure) */
37
- error?: IntegrationError;
38
- /** Metadata (timing, retries, etc.) */
39
- metadata: {
40
- integration: string;
41
- action: string;
42
- duration: number;
43
- retries: number;
44
- timestamp: number;
45
- };
46
- }
47
- /**
48
- * Integration error codes
49
- */
50
- type IntegrationErrorCode = 'VALIDATION_ERROR' | 'AUTH_ERROR' | 'RATE_LIMIT_ERROR' | 'TIMEOUT_ERROR' | 'NETWORK_ERROR' | 'SERVICE_ERROR' | 'UNKNOWN_ERROR';
51
- /**
52
- * Integration error
53
- */
54
- declare class IntegrationError extends Error {
55
- code: IntegrationErrorCode;
56
- integration?: string;
57
- action?: string;
58
- details?: unknown;
59
- constructor(message: string, code?: IntegrationErrorCode, details?: unknown);
60
- toJSON(): {
61
- name: string;
62
- message: string;
63
- code: IntegrationErrorCode;
64
- integration: string | undefined;
65
- action: string | undefined;
66
- details: unknown;
67
- };
68
- }
69
- /**
70
- * Logger interface
71
- */
72
- interface IntegrationLogger {
73
- debug(message: string, meta?: Record<string, unknown>): void;
74
- info(message: string, meta?: Record<string, unknown>): void;
75
- warn(message: string, meta?: Record<string, unknown>): void;
76
- error(message: string, meta?: Record<string, unknown>): void;
77
- }
78
- /**
79
- * Validation result
80
- */
81
- interface ValidationResult {
82
- valid: boolean;
83
- errors: ValidationError[];
84
- }
85
- /**
86
- * Validation error
87
- */
88
- interface ValidationError {
89
- param: string;
90
- message: string;
91
- }
92
-
93
- /**
94
- * Validate action params against registry schema
95
- */
96
- declare function validateParams(integration: string, action: string, params: Record<string, unknown>): ValidationResult;
97
-
98
- /**
99
- * Base class for all integrations
100
- */
101
- declare abstract class BaseIntegration {
102
- protected config: IntegrationConfig;
103
- protected logger: IntegrationLogger;
104
- constructor(config: IntegrationConfig);
105
- /**
106
- * Execute an action
107
- */
108
- abstract execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
109
- /**
110
- * Validate action params against registry
111
- */
112
- protected validateParams(action: string, params: Record<string, unknown>): ReturnType<typeof validateParams>;
113
- /**
114
- * Handle errors uniformly
115
- */
116
- protected handleError(action: string, error: unknown): IntegrationResult;
117
- /**
118
- * Create metadata for result
119
- */
120
- protected createMetadata(action: string, duration: number, retries?: number): IntegrationResult['metadata'];
121
- /**
122
- * Execute with retry logic
123
- */
124
- protected executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
125
- }
126
-
127
- /**
128
- * Factory for creating and managing integration instances
129
- */
130
- declare class IntegrationFactory {
131
- private instances;
132
- private configs;
133
- /**
134
- * Configure an integration (doesn't instantiate yet)
135
- */
136
- configure(name: string, config: Omit<IntegrationConfig, 'name'>): void;
137
- /**
138
- * Get or create an integration instance
139
- */
140
- get(name: string): BaseIntegration;
141
- /**
142
- * Execute an action on an integration
143
- */
144
- execute(integration: string, action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
145
- /**
146
- * Check if integration is configured
147
- */
148
- isConfigured(name: string): boolean;
149
- /**
150
- * Clear all instances (useful for testing)
151
- */
152
- clear(): void;
153
- /**
154
- * Clear all instances and configs
155
- */
156
- reset(): void;
157
- }
158
-
159
- export { BaseIntegration as B, type IntegrationLogger as I, type ValidationError as V, type IntegrationErrorCode as a, type IntegrationConfig as b, type IntegrationResult as c, IntegrationError as d, IntegrationFactory as e, type ValidationResult as f, validateParams as v };
package/dist/index.d.ts DELETED
@@ -1,189 +0,0 @@
1
- import { I as IntegrationLogger, a as IntegrationErrorCode, b as IntegrationConfig, B as BaseIntegration, c as IntegrationResult } from './factory-rMujCO3M.js';
2
- export { d as IntegrationError, e as IntegrationFactory, V as ValidationError, f as ValidationResult, v as validateParams } from './factory-rMujCO3M.js';
3
-
4
- /**
5
- * Console-based logger implementation
6
- */
7
- declare class ConsoleLogger implements IntegrationLogger {
8
- private level;
9
- constructor(level?: 'debug' | 'info' | 'warn' | 'error');
10
- debug(message: string, meta?: Record<string, unknown>): void;
11
- info(message: string, meta?: Record<string, unknown>): void;
12
- warn(message: string, meta?: Record<string, unknown>): void;
13
- error(message: string, meta?: Record<string, unknown>): void;
14
- private shouldLog;
15
- }
16
-
17
- /**
18
- * Retry configuration
19
- */
20
- interface RetryConfig {
21
- maxAttempts: number;
22
- backoffMs: number;
23
- maxBackoffMs?: number;
24
- retryableErrors?: IntegrationErrorCode[];
25
- }
26
- /**
27
- * Execute a function with retry logic
28
- */
29
- declare function withRetry<T>(fn: () => Promise<T>, config: RetryConfig): Promise<T>;
30
-
31
- /**
32
- * Integration constructor type
33
- */
34
- type IntegrationConstructor = new (config: IntegrationConfig) => BaseIntegration;
35
- /**
36
- * Register an integration
37
- */
38
- declare function registerIntegration(name: string, constructor: IntegrationConstructor): void;
39
- /**
40
- * Get integration constructor by name
41
- */
42
- declare function getIntegration(name: string): IntegrationConstructor | undefined;
43
- /**
44
- * Check if integration is known
45
- */
46
- declare function isKnownIntegration(name: string): boolean;
47
- /**
48
- * Get all registered integration names
49
- */
50
- declare function getRegisteredIntegrations(): string[];
51
-
52
- /**
53
- * Stripe integration for payment processing
54
- */
55
- declare class StripeIntegration extends BaseIntegration {
56
- private client;
57
- constructor(config: IntegrationConfig);
58
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
59
- private createPaymentIntent;
60
- private confirmPayment;
61
- private refund;
62
- }
63
-
64
- /**
65
- * YouTube Data API integration
66
- */
67
- declare class YouTubeIntegration extends BaseIntegration {
68
- private client;
69
- constructor(config: IntegrationConfig);
70
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
71
- private search;
72
- private getVideo;
73
- private getChannel;
74
- }
75
-
76
- /**
77
- * Twilio messaging integration
78
- */
79
- declare class TwilioIntegration extends BaseIntegration {
80
- private client;
81
- private phoneNumber;
82
- constructor(config: IntegrationConfig);
83
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
84
- private sendSMS;
85
- private sendWhatsApp;
86
- }
87
-
88
- /**
89
- * Email integration (SendGrid/Resend)
90
- */
91
- declare class EmailIntegration extends BaseIntegration {
92
- private provider;
93
- private fromEmail;
94
- private resendClient?;
95
- constructor(config: IntegrationConfig);
96
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
97
- private send;
98
- private sendViaSendGrid;
99
- private sendViaResend;
100
- }
101
-
102
- /**
103
- * LLM integration using @almadar/llm
104
- */
105
- declare class LLMIntegration extends BaseIntegration {
106
- private client;
107
- private provider;
108
- constructor(config: IntegrationConfig);
109
- private createLLMClient;
110
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
111
- private generate;
112
- private classify;
113
- private extract;
114
- private summarize;
115
- }
116
-
117
- /**
118
- * DeepAgent integration for AI code generation
119
- */
120
- declare class DeepAgentIntegration extends BaseIntegration {
121
- private apiUrl;
122
- private apiKey;
123
- constructor(config: IntegrationConfig);
124
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
125
- private sendMessage;
126
- private cancelGeneration;
127
- private validateSchema;
128
- private compileSchema;
129
- private getThreadHistory;
130
- private request;
131
- }
132
-
133
- /**
134
- * GitHub Integration for Almadar
135
- * Provides git operations and GitHub API access for the agent
136
- */
137
-
138
- /**
139
- * GitHub integration class
140
- */
141
- declare class GitHubIntegration extends BaseIntegration {
142
- private token;
143
- private owner;
144
- private repo;
145
- private workDir;
146
- constructor(config: IntegrationConfig);
147
- /**
148
- * Execute a GitHub action
149
- */
150
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
151
- /**
152
- * Clone a repository
153
- */
154
- private cloneRepo;
155
- /**
156
- * Create a branch
157
- */
158
- private createBranch;
159
- /**
160
- * Commit changes
161
- */
162
- private commit;
163
- /**
164
- * Push branch
165
- */
166
- private push;
167
- /**
168
- * Create a pull request
169
- */
170
- private createPR;
171
- /**
172
- * Get PR comments
173
- */
174
- private getPRComments;
175
- /**
176
- * List issues
177
- */
178
- private listIssues;
179
- /**
180
- * Get issue details
181
- */
182
- private getIssue;
183
- /**
184
- * Get API config for GitHub API calls
185
- */
186
- private getAPIConfig;
187
- }
188
-
189
- export { BaseIntegration, ConsoleLogger, DeepAgentIntegration, EmailIntegration, GitHubIntegration, IntegrationConfig, type IntegrationConstructor, IntegrationErrorCode, IntegrationLogger, IntegrationResult, LLMIntegration, type RetryConfig, StripeIntegration, TwilioIntegration, YouTubeIntegration, getIntegration, getRegisteredIntegrations, isKnownIntegration, registerIntegration, withRetry };
@@ -1,50 +0,0 @@
1
- import { B as BaseIntegration, b as IntegrationConfig, c as IntegrationResult, e as IntegrationFactory } from '../factory-rMujCO3M.js';
2
-
3
- /**
4
- * Mock integration for testing
5
- */
6
- declare class MockIntegration extends BaseIntegration {
7
- private responses;
8
- private calls;
9
- constructor(config: IntegrationConfig);
10
- /**
11
- * Set mock response for an action
12
- */
13
- setResponse(action: string, data: unknown): void;
14
- /**
15
- * Get all calls made to this integration
16
- */
17
- getCalls(): Array<{
18
- action: string;
19
- params: Record<string, unknown>;
20
- }>;
21
- /**
22
- * Clear all calls
23
- */
24
- clearCalls(): void;
25
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
26
- }
27
-
28
- /**
29
- * Mock integration factory for testing
30
- */
31
- declare class MockIntegrationFactory extends IntegrationFactory {
32
- constructor();
33
- /**
34
- * Set mock response for an integration action
35
- */
36
- setMockResponse(integration: string, action: string, data: unknown): void;
37
- /**
38
- * Get calls made to an integration
39
- */
40
- getMockCalls(integration: string): Array<{
41
- action: string;
42
- params: Record<string, unknown>;
43
- }>;
44
- /**
45
- * Clear calls for an integration
46
- */
47
- clearMockCalls(integration: string): void;
48
- }
49
-
50
- export { MockIntegration, MockIntegrationFactory };
@@ -1,29 +0,0 @@
1
- import { e as IntegrationFactory } from '../factory-rMujCO3M.js';
2
-
3
- /**
4
- * Runtime integration manager
5
- * Auto-configures integrations from environment variables
6
- */
7
- declare class RuntimeIntegrationManager {
8
- private factory;
9
- constructor();
10
- /**
11
- * Configure from environment variables
12
- */
13
- configureFromEnv(): void;
14
- /**
15
- * Get effect handler for runtime
16
- */
17
- getCallServiceHandler(): (service: string, action: string, params: Record<string, unknown> | undefined) => Promise<unknown>;
18
- /**
19
- * Get factory (for advanced usage)
20
- */
21
- getFactory(): IntegrationFactory;
22
- }
23
-
24
- /**
25
- * Create a callService effect handler for @almadar/runtime
26
- */
27
- declare function createCallServiceHandler(factory: IntegrationFactory): (service: string, action: string, params: Record<string, unknown> | undefined) => Promise<unknown>;
28
-
29
- export { RuntimeIntegrationManager, createCallServiceHandler };