@almadar/integrations 1.0.15 → 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.15",
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,16 +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
- "zod": "^3.23.0",
38
- "@almadar/core": "1.0.17",
39
- "@almadar/patterns": "1.1.1",
40
- "@almadar/llm": "1.0.16"
44
+ "zod": "^3.23.0"
41
45
  },
42
46
  "devDependencies": {
43
47
  "@types/node": "^20.0.0",
@@ -48,7 +52,7 @@
48
52
  "repository": {
49
53
  "type": "git",
50
54
  "url": "https://github.com/almadar-io/almadar.git",
51
- "directory": "packages/almadar-integrations"
55
+ "directory": "docs/packages/integrations"
52
56
  },
53
57
  "license": "MIT",
54
58
  "keywords": [
@@ -61,6 +65,7 @@
61
65
  "llm",
62
66
  "api"
63
67
  ],
68
+ "homepage": "https://github.com/almadar-io/almadar#readme",
64
69
  "scripts": {
65
70
  "build": "tsup",
66
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,214 +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
- * Provides 4 actions:
106
- * - generate: Generate text content from a prompt
107
- * - classify: Classify text into predefined categories
108
- * - extract: Extract structured data from text using a schema
109
- * - summarize: Summarize long text content
110
- */
111
- declare class LLMIntegration extends BaseIntegration {
112
- private client;
113
- private provider;
114
- constructor(config: IntegrationConfig);
115
- /**
116
- * Lazily create client — avoids throwing on construction if API key is missing.
117
- * The client will throw a clear error when actually used without a key.
118
- */
119
- private getClient;
120
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
121
- private generate;
122
- private classify;
123
- private extract;
124
- private summarize;
125
- }
126
-
127
- /**
128
- * DeepAgent integration for AI code generation
129
- */
130
- declare class DeepAgentIntegration extends BaseIntegration {
131
- private apiUrl;
132
- private apiKey;
133
- constructor(config: IntegrationConfig);
134
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
135
- private sendMessage;
136
- private cancelGeneration;
137
- private validateSchema;
138
- private compileSchema;
139
- private getThreadHistory;
140
- private request;
141
- }
142
-
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
- /**
200
- * CLI integration for Almadar CLI commands.
201
- *
202
- * Wraps `@almadar/cli` commands (validate, compile) as integration actions.
203
- * This runs server-side and executes CLI commands as child processes.
204
- *
205
- * Actions:
206
- * - validate: Validate an orbital schema and return structured results
207
- */
208
- declare class CLIIntegration extends BaseIntegration {
209
- constructor(config: IntegrationConfig);
210
- execute(action: string, params: Record<string, unknown>): Promise<IntegrationResult>;
211
- private validate;
212
- }
213
-
214
- export { BaseIntegration, CLIIntegration, 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 };