@almadar/integrations 2.36.0 → 2.38.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/dist/index.js CHANGED
@@ -54,8 +54,8 @@ var serviceCredentials = {
54
54
  { envVar: "TWILIO_PHONE_NUMBER", required: false, description: "Default sender phone number" }
55
55
  ],
56
56
  email: [
57
- { envVar: "SENDGRID_API_KEY", required: false, description: "SendGrid API key (use this OR RESEND_API_KEY)" },
58
- { envVar: "RESEND_API_KEY", required: false, description: "Resend API key (use this OR SENDGRID_API_KEY)" },
57
+ { envVar: "SENDGRID_API_KEY", required: false, oneOf: "provider", description: "SendGrid API key (use this OR RESEND_API_KEY)" },
58
+ { envVar: "RESEND_API_KEY", required: false, oneOf: "provider", description: "Resend API key (use this OR SENDGRID_API_KEY)" },
59
59
  { envVar: "FROM_EMAIL", required: false, description: "Default sender email address" }
60
60
  ],
61
61
  webhook: [
@@ -74,9 +74,9 @@ var serviceCredentials = {
74
74
  { envVar: "GOOGLE_CALENDAR_CHANNEL_TOKEN", required: false, description: "Watch-channel verification token \u2014 required to receive inbound calendar hooks (two-way sync)" }
75
75
  ],
76
76
  drive: [
77
- { envVar: "GOOGLE_DRIVE_SA_KEY", required: false, description: "Google service-account key JSON (raw or base64) with drive scope \u2014 serves reads; store in Secret Manager, bind as env" },
77
+ { envVar: "GOOGLE_DRIVE_SA_KEY", required: false, oneOf: "auth", description: "Google service-account key JSON (raw or base64) with drive scope \u2014 serves reads; store in Secret Manager, bind as env" },
78
78
  { envVar: "GOOGLE_DRIVE_SUBJECT", required: false, description: "Workspace user to impersonate (domain-wide delegation); empty = act as the service account" },
79
- { envVar: "GOOGLE_DRIVE_REFRESH_TOKEN", required: false, description: "User OAuth refresh token (drive-consent.mjs) \u2014 serves writes; SA uploads are impossible on personal accounts (no SA storage quota)" },
79
+ { envVar: "GOOGLE_DRIVE_REFRESH_TOKEN", required: false, oneOf: "auth", description: "User OAuth refresh token (drive-consent.mjs) \u2014 serves writes; SA uploads are impossible on personal accounts (no SA storage quota)" },
80
80
  { envVar: "GOOGLE_DRIVE_FOLDER_ID", required: false, description: "Default parent folder for uploads/new folders when the call names none" }
81
81
  ],
82
82
  metaAds: [
@@ -93,12 +93,13 @@ var serviceCredentials = {
93
93
  { envVar: "DOCUSIGN_ACCESS_TOKEN", required: true, description: "DocuSign OAuth access token (JWT grant rotation is the deployment concern)" }
94
94
  ],
95
95
  llm: [
96
- { envVar: "ANTHROPIC_API_KEY", required: false, description: "Anthropic API key (use this OR OPENAI_API_KEY)" },
97
- { envVar: "OPENAI_API_KEY", required: false, description: "OpenAI API key (use this OR ANTHROPIC_API_KEY)" }
96
+ { envVar: "ANTHROPIC_API_KEY", required: false, oneOf: "provider", description: "Anthropic API key (use this OR OPENAI_API_KEY)" },
97
+ { envVar: "OPENAI_API_KEY", required: false, oneOf: "provider", description: "OpenAI API key (use this OR ANTHROPIC_API_KEY)" },
98
+ { envVar: "LLM_PROVIDER", required: false, description: "Chat provider when several keys are set: anthropic | openai | deepseek | kimi | openrouter (default: the first key found)" }
98
99
  ],
99
100
  "llm-integration": [
100
- { envVar: "ANTHROPIC_API_KEY", required: false, description: "Anthropic API key" },
101
- { envVar: "OPENAI_API_KEY", required: false, description: "OpenAI API key" }
101
+ { envVar: "ANTHROPIC_API_KEY", required: false, oneOf: "provider", description: "Anthropic API key" },
102
+ { envVar: "OPENAI_API_KEY", required: false, oneOf: "provider", description: "OpenAI API key" }
102
103
  ],
103
104
  ml: [
104
105
  { envVar: "MASAR_URL", required: true, description: "Base URL of the deployed model-serving orbital" },
@@ -255,13 +256,14 @@ function validateParams(integration, action, params) {
255
256
  }
256
257
  }
257
258
  for (const paramDef of actionDef.params) {
258
- if (paramDef.required && !(paramDef.name in params)) {
259
+ const provided = params[paramDef.name] !== void 0;
260
+ if (paramDef.required && !provided) {
259
261
  errors.push({
260
262
  param: paramDef.name,
261
263
  message: `Missing required parameter: ${paramDef.name}`
262
264
  });
263
265
  }
264
- if (paramDef.name in params) {
266
+ if (provided) {
265
267
  const value = params[paramDef.name];
266
268
  const expectedType = paramDef.type;
267
269
  const actualType = typeof value;
@@ -342,6 +344,14 @@ var BaseIntegration = class {
342
344
  validateParams(action, params) {
343
345
  return validateParams(this.config.name, action, params);
344
346
  }
347
+ /** A rejected call: a real IntegrationError naming every failing param (kept in `details`). */
348
+ validationFailure(action, errors) {
349
+ const reasons = errors.map((e) => `${e.param}: ${e.message}`).join("; ");
350
+ const error = new IntegrationError(`Validation failed for ${this.config.name}.${action}: ${reasons}`, "VALIDATION_ERROR", errors);
351
+ error.integration = this.config.name;
352
+ error.action = action;
353
+ return { success: false, error, metadata: this.createMetadata(action, 0) };
354
+ }
345
355
  /**
346
356
  * Handle errors uniformly
347
357
  */
@@ -432,13 +442,13 @@ var IntegrationFactory = class {
432
442
  }
433
443
  const Constructor = getIntegration(name);
434
444
  if (!Constructor) {
435
- throw new Error(`Unknown integration: ${name}. Make sure it's imported.`);
445
+ throw new IntegrationError(`Unknown integration: ${name}. Make sure it's imported.`, "UNKNOWN_INTEGRATION");
436
446
  }
437
447
  const config = this.configs.get(key) ?? this.configs.get(name);
438
448
  if (!config) {
439
- throw new Error(
440
- `Integration not configured: ${name}. Call configure() first.`
441
- );
449
+ const envVars = (serviceCredentials[name] ?? []).map((c) => c.envVar);
450
+ const needs = envVars.length > 0 ? ` Set ${envVars.join(" / ")}.` : "";
451
+ throw new IntegrationError(`Integration not configured: ${name}.${needs}`, "NOT_CONFIGURED");
442
452
  }
443
453
  const instance = new Constructor(config);
444
454
  this.instances.set(key, instance);
@@ -995,18 +1005,7 @@ var StripeIntegration = class extends BaseIntegration {
995
1005
  }
996
1006
  async execute(action, params) {
997
1007
  const validation = this.validateParams(action, params);
998
- if (!validation.valid) {
999
- return {
1000
- success: false,
1001
- error: {
1002
- name: "IntegrationError",
1003
- message: "Validation failed",
1004
- code: "VALIDATION_ERROR",
1005
- details: validation.errors
1006
- },
1007
- metadata: this.createMetadata(action, 0)
1008
- };
1009
- }
1008
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1010
1009
  const startTime = Date.now();
1011
1010
  const retries = 0;
1012
1011
  try {
@@ -1224,18 +1223,7 @@ var YouTubeIntegration = class extends BaseIntegration {
1224
1223
  }
1225
1224
  async execute(action, params) {
1226
1225
  const validation = this.validateParams(action, params);
1227
- if (!validation.valid) {
1228
- return {
1229
- success: false,
1230
- error: {
1231
- name: "IntegrationError",
1232
- message: "Validation failed",
1233
- code: "VALIDATION_ERROR",
1234
- details: validation.errors
1235
- },
1236
- metadata: this.createMetadata(action, 0)
1237
- };
1238
- }
1226
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1239
1227
  const startTime = Date.now();
1240
1228
  let retries = 0;
1241
1229
  try {
@@ -1329,18 +1317,7 @@ var TwilioIntegration = class extends BaseIntegration {
1329
1317
  }
1330
1318
  async execute(action, params) {
1331
1319
  const validation = this.validateParams(action, params);
1332
- if (!validation.valid) {
1333
- return {
1334
- success: false,
1335
- error: {
1336
- name: "IntegrationError",
1337
- message: "Validation failed",
1338
- code: "VALIDATION_ERROR",
1339
- details: validation.errors
1340
- },
1341
- metadata: this.createMetadata(action, 0)
1342
- };
1343
- }
1320
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1344
1321
  const startTime = Date.now();
1345
1322
  let retries = 0;
1346
1323
  try {
@@ -1414,18 +1391,7 @@ var EmailIntegration = class extends BaseIntegration {
1414
1391
  }
1415
1392
  async execute(action, params) {
1416
1393
  const validation = this.validateParams(action, params);
1417
- if (!validation.valid) {
1418
- return {
1419
- success: false,
1420
- error: {
1421
- name: "IntegrationError",
1422
- message: "Validation failed",
1423
- code: "VALIDATION_ERROR",
1424
- details: validation.errors
1425
- },
1426
- metadata: this.createMetadata(action, 0)
1427
- };
1428
- }
1394
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1429
1395
  const startTime = Date.now();
1430
1396
  let retries = 0;
1431
1397
  try {
@@ -1498,8 +1464,11 @@ var EmailIntegration = class extends BaseIntegration {
1498
1464
  ...message.htmlBody ? { text: message.body } : {},
1499
1465
  ...message.replyTo ? { replyTo: message.replyTo } : {}
1500
1466
  });
1467
+ if (response.error || !response.data) {
1468
+ throw new Error(`Resend rejected the email: ${response.error?.message ?? "no message id returned"}`);
1469
+ }
1501
1470
  return {
1502
- id: response.data?.id,
1471
+ id: response.data.id,
1503
1472
  status: "sent"
1504
1473
  };
1505
1474
  }
@@ -1514,18 +1483,7 @@ var WebhookIntegration = class extends BaseIntegration {
1514
1483
  }
1515
1484
  async execute(action, params) {
1516
1485
  const validation = this.validateParams(action, params);
1517
- if (!validation.valid) {
1518
- return {
1519
- success: false,
1520
- error: {
1521
- name: "IntegrationError",
1522
- message: "Validation failed",
1523
- code: "VALIDATION_ERROR",
1524
- details: validation.errors
1525
- },
1526
- metadata: this.createMetadata(action, 0)
1527
- };
1528
- }
1486
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1529
1487
  const startTime = Date.now();
1530
1488
  let retries = 0;
1531
1489
  try {
@@ -1605,18 +1563,7 @@ var PushIntegration = class extends BaseIntegration {
1605
1563
  }
1606
1564
  async execute(action, params) {
1607
1565
  const validation = this.validateParams(action, params);
1608
- if (!validation.valid) {
1609
- return {
1610
- success: false,
1611
- error: {
1612
- name: "IntegrationError",
1613
- message: "Validation failed",
1614
- code: "VALIDATION_ERROR",
1615
- details: validation.errors
1616
- },
1617
- metadata: this.createMetadata(action, 0)
1618
- };
1619
- }
1566
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1620
1567
  const startTime = Date.now();
1621
1568
  let retries = 0;
1622
1569
  try {
@@ -1737,18 +1684,7 @@ var CalendarIntegration = class extends BaseIntegration {
1737
1684
  }
1738
1685
  async execute(action, params) {
1739
1686
  const validation = this.validateParams(action, params);
1740
- if (!validation.valid) {
1741
- return {
1742
- success: false,
1743
- error: {
1744
- name: "IntegrationError",
1745
- message: "Validation failed",
1746
- code: "VALIDATION_ERROR",
1747
- details: validation.errors
1748
- },
1749
- metadata: this.createMetadata(action, 0)
1750
- };
1751
- }
1687
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
1752
1688
  const startTime = Date.now();
1753
1689
  let retries = 0;
1754
1690
  try {
@@ -2010,18 +1946,7 @@ var DriveIntegration = class extends BaseIntegration {
2010
1946
  }
2011
1947
  async execute(action, params) {
2012
1948
  const validation = this.validateParams(action, params);
2013
- if (!validation.valid) {
2014
- return {
2015
- success: false,
2016
- error: {
2017
- name: "IntegrationError",
2018
- message: "Validation failed",
2019
- code: "VALIDATION_ERROR",
2020
- details: validation.errors
2021
- },
2022
- metadata: this.createMetadata(action, 0)
2023
- };
2024
- }
1949
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2025
1950
  const startTime = Date.now();
2026
1951
  try {
2027
1952
  let data;
@@ -2157,18 +2082,7 @@ var MetaAdsIntegration = class extends BaseIntegration {
2157
2082
  }
2158
2083
  async execute(action, params) {
2159
2084
  const validation = this.validateParams(action, params);
2160
- if (!validation.valid) {
2161
- return {
2162
- success: false,
2163
- error: {
2164
- name: "IntegrationError",
2165
- message: "Validation failed",
2166
- code: "VALIDATION_ERROR",
2167
- details: validation.errors
2168
- },
2169
- metadata: this.createMetadata(action, 0)
2170
- };
2171
- }
2085
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2172
2086
  const startTime = Date.now();
2173
2087
  try {
2174
2088
  let data;
@@ -2256,18 +2170,7 @@ var AccountingIntegration = class extends BaseIntegration {
2256
2170
  }
2257
2171
  async execute(action, params) {
2258
2172
  const validation = this.validateParams(action, params);
2259
- if (!validation.valid) {
2260
- return {
2261
- success: false,
2262
- error: {
2263
- name: "IntegrationError",
2264
- message: "Validation failed",
2265
- code: "VALIDATION_ERROR",
2266
- details: validation.errors
2267
- },
2268
- metadata: this.createMetadata(action, 0)
2269
- };
2270
- }
2173
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2271
2174
  const startTime = Date.now();
2272
2175
  try {
2273
2176
  let data;
@@ -2335,18 +2238,7 @@ var BankingIntegration = class extends BaseIntegration {
2335
2238
  }
2336
2239
  async execute(action, params) {
2337
2240
  const validation = this.validateParams(action, params);
2338
- if (!validation.valid) {
2339
- return {
2340
- success: false,
2341
- error: {
2342
- name: "IntegrationError",
2343
- message: "Validation failed",
2344
- code: "VALIDATION_ERROR",
2345
- details: validation.errors
2346
- },
2347
- metadata: this.createMetadata(action, 0)
2348
- };
2349
- }
2241
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2350
2242
  const startTime = Date.now();
2351
2243
  try {
2352
2244
  let data;
@@ -2459,18 +2351,7 @@ var EsignIntegration = class extends BaseIntegration {
2459
2351
  }
2460
2352
  async execute(action, params) {
2461
2353
  const validation = this.validateParams(action, params);
2462
- if (!validation.valid) {
2463
- return {
2464
- success: false,
2465
- error: {
2466
- name: "IntegrationError",
2467
- message: "Validation failed",
2468
- code: "VALIDATION_ERROR",
2469
- details: validation.errors
2470
- },
2471
- metadata: this.createMetadata(action, 0)
2472
- };
2473
- }
2354
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2474
2355
  const startTime = Date.now();
2475
2356
  try {
2476
2357
  let data;
@@ -2607,18 +2488,7 @@ var LLMIntegration = class extends BaseIntegration {
2607
2488
  }
2608
2489
  async execute(action, params) {
2609
2490
  const validation = this.validateParams(action, params);
2610
- if (!validation.valid) {
2611
- return {
2612
- success: false,
2613
- error: {
2614
- name: "IntegrationError",
2615
- message: "Validation failed",
2616
- code: "VALIDATION_ERROR",
2617
- details: validation.errors
2618
- },
2619
- metadata: this.createMetadata(action, 0)
2620
- };
2621
- }
2491
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2622
2492
  const startTime = Date.now();
2623
2493
  try {
2624
2494
  let data;
@@ -2659,16 +2529,14 @@ var LLMIntegration = class extends BaseIntegration {
2659
2529
  maxTokens
2660
2530
  } = params;
2661
2531
  this.logger.debug("Generating content", { model, temperature });
2662
- const client = model ? new LLMClient({ provider: this.provider, model, temperature: temperature ?? 0.7 }) : this.getClient();
2663
- const response = await client.callWithMetadata({
2532
+ const client = model !== void 0 || temperature !== void 0 ? new LLMClient({ provider: this.provider, model, temperature: temperature ?? 0.7 }) : this.getClient();
2533
+ const response = await client.callRawWithMetadata({
2664
2534
  systemPrompt: systemPrompt || "You are a helpful assistant.",
2665
2535
  userPrompt,
2666
- maxTokens: maxTokens ?? 1024,
2667
- temperature,
2668
- skipSchemaValidation: true
2536
+ maxTokens: maxTokens ?? 1024
2669
2537
  });
2670
2538
  return {
2671
- content: response.data,
2539
+ content: response.raw,
2672
2540
  usage: response.usage ? {
2673
2541
  promptTokens: response.usage.promptTokens,
2674
2542
  completionTokens: response.usage.completionTokens,
@@ -2785,18 +2653,7 @@ var MLIntegration = class extends BaseIntegration {
2785
2653
  }
2786
2654
  async execute(action, params) {
2787
2655
  const validation = this.validateParams(action, params);
2788
- if (!validation.valid) {
2789
- return {
2790
- success: false,
2791
- error: {
2792
- name: "IntegrationError",
2793
- message: "Validation failed",
2794
- code: "VALIDATION_ERROR",
2795
- details: validation.errors
2796
- },
2797
- metadata: this.createMetadata(action, 0)
2798
- };
2799
- }
2656
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2800
2657
  const startTime = Date.now();
2801
2658
  try {
2802
2659
  let data;
@@ -2905,18 +2762,7 @@ var DeepAgentIntegration = class extends BaseIntegration {
2905
2762
  }
2906
2763
  async execute(action, params) {
2907
2764
  const validation = this.validateParams(action, params);
2908
- if (!validation.valid) {
2909
- return {
2910
- success: false,
2911
- error: {
2912
- name: "IntegrationError",
2913
- message: "Validation failed",
2914
- code: "VALIDATION_ERROR",
2915
- details: validation.errors
2916
- },
2917
- metadata: this.createMetadata(action, 0)
2918
- };
2919
- }
2765
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
2920
2766
  const startTime = Date.now();
2921
2767
  let retries = 0;
2922
2768
  try {
@@ -3350,18 +3196,7 @@ var GitHubIntegration = class extends BaseIntegration {
3350
3196
  */
3351
3197
  async execute(action, params) {
3352
3198
  const validation = this.validateParams(action, params);
3353
- if (!validation.valid) {
3354
- return {
3355
- success: false,
3356
- error: {
3357
- name: "IntegrationError",
3358
- message: "Validation failed",
3359
- code: "VALIDATION_ERROR",
3360
- details: validation.errors
3361
- },
3362
- metadata: this.createMetadata(action, 0)
3363
- };
3364
- }
3199
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
3365
3200
  const startTime = Date.now();
3366
3201
  let retries = 0;
3367
3202
  try {
@@ -3652,18 +3487,7 @@ var RedisIntegration = class extends BaseIntegration {
3652
3487
  }
3653
3488
  async execute(action, params) {
3654
3489
  const validation = this.validateParams(action, params);
3655
- if (!validation.valid) {
3656
- return {
3657
- success: false,
3658
- error: {
3659
- name: "IntegrationError",
3660
- message: "Validation failed",
3661
- code: "VALIDATION_ERROR",
3662
- details: validation.errors
3663
- },
3664
- metadata: this.createMetadata(action, 0)
3665
- };
3666
- }
3490
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
3667
3491
  const startTime = Date.now();
3668
3492
  try {
3669
3493
  let data;
@@ -3866,18 +3690,7 @@ var QueueIntegration = class extends BaseIntegration {
3866
3690
  }
3867
3691
  async execute(action, params) {
3868
3692
  const validation = this.validateParams(action, params);
3869
- if (!validation.valid) {
3870
- return {
3871
- success: false,
3872
- error: {
3873
- name: "IntegrationError",
3874
- message: "Validation failed",
3875
- code: "VALIDATION_ERROR",
3876
- details: validation.errors
3877
- },
3878
- metadata: this.createMetadata(action, 0)
3879
- };
3880
- }
3693
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
3881
3694
  const startTime = Date.now();
3882
3695
  try {
3883
3696
  let data;
@@ -4076,18 +3889,7 @@ var OtelIntegration = class extends BaseIntegration {
4076
3889
  }
4077
3890
  async execute(action, params) {
4078
3891
  const validation = this.validateParams(action, params);
4079
- if (!validation.valid) {
4080
- return {
4081
- success: false,
4082
- error: {
4083
- name: "IntegrationError",
4084
- message: "Validation failed",
4085
- code: "VALIDATION_ERROR",
4086
- details: validation.errors
4087
- },
4088
- metadata: this.createMetadata(action, 0)
4089
- };
4090
- }
3892
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
4091
3893
  const startTime = Date.now();
4092
3894
  try {
4093
3895
  let data;
@@ -4279,18 +4081,7 @@ var OAuthIntegration = class extends BaseIntegration {
4279
4081
  }
4280
4082
  async execute(action, params) {
4281
4083
  const validation = this.validateParams(action, params);
4282
- if (!validation.valid) {
4283
- return {
4284
- success: false,
4285
- error: {
4286
- name: "IntegrationError",
4287
- message: "Validation failed",
4288
- code: "VALIDATION_ERROR",
4289
- details: validation.errors
4290
- },
4291
- metadata: this.createMetadata(action, 0)
4292
- };
4293
- }
4084
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
4294
4085
  const startTime = Date.now();
4295
4086
  try {
4296
4087
  let data;
@@ -4592,18 +4383,7 @@ var CredentialsIntegration = class extends BaseIntegration {
4592
4383
  }
4593
4384
  }
4594
4385
  const validation = this.validateParams(action, params);
4595
- if (!validation.valid) {
4596
- return {
4597
- success: false,
4598
- error: {
4599
- name: "IntegrationError",
4600
- message: "Validation failed",
4601
- code: "VALIDATION_ERROR",
4602
- details: validation.errors
4603
- },
4604
- metadata: this.createMetadata(action, 0)
4605
- };
4606
- }
4386
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
4607
4387
  const startTime = Date.now();
4608
4388
  try {
4609
4389
  let data;
@@ -4804,18 +4584,7 @@ var StorageIntegration = class extends BaseIntegration {
4804
4584
  }
4805
4585
  async execute(action, params) {
4806
4586
  const validation = this.validateParams(action, params);
4807
- if (!validation.valid) {
4808
- return {
4809
- success: false,
4810
- error: {
4811
- name: "IntegrationError",
4812
- message: "Validation failed",
4813
- code: "VALIDATION_ERROR",
4814
- details: validation.errors
4815
- },
4816
- metadata: this.createMetadata(action, 0)
4817
- };
4818
- }
4587
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
4819
4588
  const startTime = Date.now();
4820
4589
  try {
4821
4590
  let data;
@@ -5094,18 +4863,7 @@ var DockerIntegration = class extends BaseIntegration {
5094
4863
  }
5095
4864
  async execute(action, params) {
5096
4865
  const validation = this.validateParams(action, params);
5097
- if (!validation.valid) {
5098
- return {
5099
- success: false,
5100
- error: {
5101
- name: "IntegrationError",
5102
- message: "Validation failed",
5103
- code: "VALIDATION_ERROR",
5104
- details: validation.errors
5105
- },
5106
- metadata: this.createMetadata(action, 0)
5107
- };
5108
- }
4866
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5109
4867
  const startTime = Date.now();
5110
4868
  try {
5111
4869
  let data;
@@ -5530,18 +5288,7 @@ var DatabaseIntegration = class extends BaseIntegration {
5530
5288
  }
5531
5289
  async execute(action, params) {
5532
5290
  const validation = this.validateParams(action, params);
5533
- if (!validation.valid) {
5534
- return {
5535
- success: false,
5536
- error: {
5537
- name: "IntegrationError",
5538
- message: "Validation failed",
5539
- code: "VALIDATION_ERROR",
5540
- details: validation.errors
5541
- },
5542
- metadata: this.createMetadata(action, 0)
5543
- };
5544
- }
5291
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5545
5292
  const startTime = Date.now();
5546
5293
  try {
5547
5294
  let data;
@@ -5609,18 +5356,7 @@ var WikimediaIntegration = class extends BaseIntegration {
5609
5356
  }
5610
5357
  async execute(action, params) {
5611
5358
  const validation = this.validateParams(action, params);
5612
- if (!validation.valid) {
5613
- return {
5614
- success: false,
5615
- error: {
5616
- name: "IntegrationError",
5617
- message: "Validation failed",
5618
- code: "VALIDATION_ERROR",
5619
- details: validation.errors
5620
- },
5621
- metadata: this.createMetadata(action, 0)
5622
- };
5623
- }
5359
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5624
5360
  const startTime = Date.now();
5625
5361
  try {
5626
5362
  let data;
@@ -5678,18 +5414,7 @@ var IconifyIntegration = class extends BaseIntegration {
5678
5414
  }
5679
5415
  async execute(action, params) {
5680
5416
  const validation = this.validateParams(action, params);
5681
- if (!validation.valid) {
5682
- return {
5683
- success: false,
5684
- error: {
5685
- name: "IntegrationError",
5686
- message: "Validation failed",
5687
- code: "VALIDATION_ERROR",
5688
- details: validation.errors
5689
- },
5690
- metadata: this.createMetadata(action, 0)
5691
- };
5692
- }
5417
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5693
5418
  const startTime = Date.now();
5694
5419
  try {
5695
5420
  let data;
@@ -5788,18 +5513,7 @@ var ArxivIntegration = class extends BaseIntegration {
5788
5513
  }
5789
5514
  async execute(action, params) {
5790
5515
  const validation = this.validateParams(action, params);
5791
- if (!validation.valid) {
5792
- return {
5793
- success: false,
5794
- error: {
5795
- name: "IntegrationError",
5796
- message: "Validation failed",
5797
- code: "VALIDATION_ERROR",
5798
- details: validation.errors
5799
- },
5800
- metadata: this.createMetadata(action, 0)
5801
- };
5802
- }
5516
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5803
5517
  const startTime = Date.now();
5804
5518
  try {
5805
5519
  let data;
@@ -5871,32 +5585,10 @@ var RiggerIntegration = class extends BaseIntegration {
5871
5585
  }
5872
5586
  async execute(action, params) {
5873
5587
  const validation = this.validateParams(action, params);
5874
- if (!validation.valid) {
5875
- return {
5876
- success: false,
5877
- error: {
5878
- name: "IntegrationError",
5879
- message: "Validation failed",
5880
- code: "VALIDATION_ERROR",
5881
- details: validation.errors
5882
- },
5883
- metadata: this.createMetadata(action, 0)
5884
- };
5885
- }
5588
+ if (!validation.valid) return this.validationFailure(action, validation.errors);
5886
5589
  if (action === "generate") {
5887
5590
  const invalid = generateParamErrors(params);
5888
- if (invalid.length > 0) {
5889
- return {
5890
- success: false,
5891
- error: {
5892
- name: "IntegrationError",
5893
- message: "Validation failed",
5894
- code: "VALIDATION_ERROR",
5895
- details: invalid
5896
- },
5897
- metadata: this.createMetadata(action, 0)
5898
- };
5899
- }
5591
+ if (invalid.length > 0) return this.validationFailure(action, invalid.map((message) => ({ param: "params", message })));
5900
5592
  }
5901
5593
  const startTime = Date.now();
5902
5594
  try {