@almadar/integrations 2.30.0 → 2.32.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.
@@ -161,6 +161,22 @@ var serviceCredentials = {
161
161
  { envVar: "ARXIV_TIMEOUT_MS", required: false, description: "Per-request timeout (ms)" }
162
162
  ]
163
163
  };
164
+ function allCredentialEnvVars() {
165
+ const vars = /* @__PURE__ */ new Set();
166
+ for (const decls of Object.values(serviceCredentials)) {
167
+ for (const { envVar } of decls) vars.add(envVar);
168
+ }
169
+ return vars;
170
+ }
171
+ var STORE_BOOTSTRAP_ENV_VARS = /* @__PURE__ */ new Set([
172
+ "ALMADAR_CREDENTIAL_MASTER_KEY",
173
+ "ALMADAR_CREDENTIAL_MASTER_KEY_PREVIOUS"
174
+ ]);
175
+ function declaredCredentialEnvVars() {
176
+ const vars = allCredentialEnvVars();
177
+ for (const bootstrapVar of STORE_BOOTSTRAP_ENV_VARS) vars.delete(bootstrapVar);
178
+ return vars;
179
+ }
164
180
  var serviceProbes = {
165
181
  calendar: { action: "listEvents", params: { maxResults: 1 } },
166
182
  drive: { action: "listFiles", params: { maxResults: 1 } },
@@ -184,6 +200,14 @@ var ConsoleLogger = class {
184
200
  }
185
201
  };
186
202
  var RESERVED_ENVELOPE_KEYS = /* @__PURE__ */ new Set(["emit", "onSuccess", "onError", "timeout"]);
203
+ var UnknownActionError = class extends Error {
204
+ constructor(integration, action) {
205
+ super(`Unknown ${integration} action: ${action}`);
206
+ this.name = "UnknownActionError";
207
+ this.integration = integration;
208
+ this.action = action;
209
+ }
210
+ };
187
211
  function validateParams(integration, action, params) {
188
212
  const typedRegistry = integratorsRegistry;
189
213
  const registry = typedRegistry.integrators[integration];
@@ -572,7 +596,7 @@ var StripeIntegration = class extends BaseIntegration {
572
596
  data = await this.executeWithRetry(() => this.refund(params));
573
597
  break;
574
598
  default:
575
- throw new Error(`Unknown action: ${action}`);
599
+ throw new UnknownActionError(this.config.name, action);
576
600
  }
577
601
  return {
578
602
  success: true,
@@ -799,7 +823,7 @@ var YouTubeIntegration = class extends BaseIntegration {
799
823
  data = await this.executeWithRetry(() => this.getChannel(params));
800
824
  break;
801
825
  default:
802
- throw new Error(`Unknown action: ${action}`);
826
+ throw new UnknownActionError(this.config.name, action);
803
827
  }
804
828
  return {
805
829
  success: true,
@@ -901,7 +925,7 @@ var TwilioIntegration = class extends BaseIntegration {
901
925
  data = await this.executeWithRetry(() => this.sendWhatsApp(params));
902
926
  break;
903
927
  default:
904
- throw new Error(`Unknown action: ${action}`);
928
+ throw new UnknownActionError(this.config.name, action);
905
929
  }
906
930
  return {
907
931
  success: true,
@@ -983,7 +1007,7 @@ var EmailIntegration = class extends BaseIntegration {
983
1007
  data = await this.executeWithRetry(() => this.send(params));
984
1008
  break;
985
1009
  default:
986
- throw new Error(`Unknown action: ${action}`);
1010
+ throw new UnknownActionError(this.config.name, action);
987
1011
  }
988
1012
  return {
989
1013
  success: true,
@@ -1083,7 +1107,7 @@ var WebhookIntegration = class extends BaseIntegration {
1083
1107
  data = await this.executeWithRetry(() => this.send(params));
1084
1108
  break;
1085
1109
  default:
1086
- throw new Error(`Unknown action: ${action}`);
1110
+ throw new UnknownActionError(this.config.name, action);
1087
1111
  }
1088
1112
  return {
1089
1113
  success: true,
@@ -1174,7 +1198,7 @@ var PushIntegration = class extends BaseIntegration {
1174
1198
  data = await this.executeWithRetry(() => this.send(params));
1175
1199
  break;
1176
1200
  default:
1177
- throw new Error(`Unknown action: ${action}`);
1201
+ throw new UnknownActionError(this.config.name, action);
1178
1202
  }
1179
1203
  return {
1180
1204
  success: true,
@@ -1283,7 +1307,7 @@ var CalendarIntegration = class extends BaseIntegration {
1283
1307
  data = await this.executeWithRetry(() => this.stopWatch(params));
1284
1308
  break;
1285
1309
  default:
1286
- throw new Error(`Unknown action: ${action}`);
1310
+ throw new UnknownActionError(this.config.name, action);
1287
1311
  }
1288
1312
  return {
1289
1313
  success: true,
@@ -1528,7 +1552,7 @@ var DriveIntegration = class extends BaseIntegration {
1528
1552
  data = await this.executeWithRetry(() => this.shareFile(params));
1529
1553
  break;
1530
1554
  default:
1531
- throw new Error(`Unknown action: ${action}`);
1555
+ throw new UnknownActionError(this.config.name, action);
1532
1556
  }
1533
1557
  return {
1534
1558
  success: true,
@@ -1666,7 +1690,7 @@ var MetaAdsIntegration = class extends BaseIntegration {
1666
1690
  data = await this.executeWithRetry(() => this.listCampaigns(params));
1667
1691
  break;
1668
1692
  default:
1669
- throw new Error(`Unknown action: ${action}`);
1693
+ throw new UnknownActionError(this.config.name, action);
1670
1694
  }
1671
1695
  return {
1672
1696
  success: true,
@@ -1765,7 +1789,7 @@ var AccountingIntegration = class extends BaseIntegration {
1765
1789
  data = this.exportRows(params.entries, JOURNAL_COLUMNS, "journal");
1766
1790
  break;
1767
1791
  default:
1768
- throw new Error(`Unknown action: ${action}`);
1792
+ throw new UnknownActionError(this.config.name, action);
1769
1793
  }
1770
1794
  return {
1771
1795
  success: true,
@@ -1847,7 +1871,7 @@ var BankingIntegration = class extends BaseIntegration {
1847
1871
  data = await this.executeWithRetry(() => this.listTransactions(params));
1848
1872
  break;
1849
1873
  default:
1850
- throw new Error(`Unknown action: ${action}`);
1874
+ throw new UnknownActionError(this.config.name, action);
1851
1875
  }
1852
1876
  return {
1853
1877
  success: true,
@@ -1971,7 +1995,7 @@ var EsignIntegration = class extends BaseIntegration {
1971
1995
  data = await this.executeWithRetry(() => this.downloadDocument(params));
1972
1996
  break;
1973
1997
  default:
1974
- throw new Error(`Unknown action: ${action}`);
1998
+ throw new UnknownActionError(this.config.name, action);
1975
1999
  }
1976
2000
  return {
1977
2001
  success: true,
@@ -2125,7 +2149,7 @@ var LLMIntegration = class extends BaseIntegration {
2125
2149
  data = await this.executeWithRetry(() => this.embed(params));
2126
2150
  break;
2127
2151
  default:
2128
- throw new Error(`Unknown action: ${action}`);
2152
+ throw new UnknownActionError(this.config.name, action);
2129
2153
  }
2130
2154
  return {
2131
2155
  success: true,
@@ -2291,7 +2315,7 @@ var MLIntegration = class extends BaseIntegration {
2291
2315
  data = await this.executeWithRetry(() => this.infer(params));
2292
2316
  break;
2293
2317
  default:
2294
- throw new Error(`Unknown action: ${action}`);
2318
+ throw new UnknownActionError(this.config.name, action);
2295
2319
  }
2296
2320
  return {
2297
2321
  success: true,
@@ -2428,7 +2452,7 @@ var DeepAgentIntegration = class extends BaseIntegration {
2428
2452
  );
2429
2453
  break;
2430
2454
  default:
2431
- throw new Error(`Unknown action: ${action}`);
2455
+ throw new UnknownActionError(this.config.name, action);
2432
2456
  }
2433
2457
  return {
2434
2458
  success: true,
@@ -2730,10 +2754,10 @@ async function getPRComments(params, config) {
2730
2754
  return data;
2731
2755
  }
2732
2756
  async function listIssues(params, config) {
2733
- const { state = "open", labels = [], limit = 30 } = params;
2757
+ const { state = "open", labels = [], per_page = 30 } = params;
2734
2758
  const queryParams = new URLSearchParams({
2735
2759
  state,
2736
- per_page: Math.min(limit, 100).toString()
2760
+ per_page: Math.min(per_page, 100).toString()
2737
2761
  });
2738
2762
  if (labels.length > 0) {
2739
2763
  queryParams.append("labels", labels.join(","));
@@ -2750,6 +2774,52 @@ async function getIssue(params, config) {
2750
2774
  const { data: comments } = await githubFetch(commentsEndpoint, config);
2751
2775
  return { issue, comments };
2752
2776
  }
2777
+ async function listCommits(config, options) {
2778
+ const params = new URLSearchParams();
2779
+ if (options?.path) params.set("path", options.path);
2780
+ if (options?.ref) params.set("sha", options.ref);
2781
+ if (options?.perPage) params.set("per_page", options.perPage.toString());
2782
+ if (options?.page) params.set("page", options.page.toString());
2783
+ const queryStr = params.toString();
2784
+ const endpoint = `/repos/${config.owner}/${config.repo}/commits${queryStr ? `?${queryStr}` : ""}`;
2785
+ const { data } = await githubFetch(endpoint, config);
2786
+ return data.map((item) => ({
2787
+ sha: item.sha,
2788
+ message: item.commit.message,
2789
+ author: item.commit.author,
2790
+ stats: item.stats
2791
+ }));
2792
+ }
2793
+ async function getFile(params, token) {
2794
+ const { owner, repo, path, ref } = params;
2795
+ const config = { token};
2796
+ const query = ref ? `?ref=${encodeURIComponent(ref)}` : "";
2797
+ const endpoint = `/repos/${owner}/${repo}/contents/${path}${query}`;
2798
+ const { data } = await githubFetch(endpoint, config);
2799
+ const content = data.encoding === "base64" ? Buffer.from(data.content, "base64").toString("utf-8") : data.content;
2800
+ return { path: data.path, content, sha: data.sha, size: data.size };
2801
+ }
2802
+ async function listCommitsSummary(params, token) {
2803
+ const { owner, repo, path, ref, per_page } = params;
2804
+ const config = { token, owner, repo };
2805
+ const commits = await listCommits(config, { path, ref, perPage: per_page });
2806
+ return commits.map((commit2) => ({
2807
+ sha: commit2.sha,
2808
+ message: commit2.message,
2809
+ author: commit2.author.name,
2810
+ date: commit2.author.date
2811
+ }));
2812
+ }
2813
+ async function createIssue(params, token) {
2814
+ const { owner, repo, title, body, labels } = params;
2815
+ const config = { token};
2816
+ const endpoint = `/repos/${owner}/${repo}/issues`;
2817
+ const { data } = await githubFetch(endpoint, config, {
2818
+ method: "POST",
2819
+ body: JSON.stringify({ title, body, labels })
2820
+ });
2821
+ return { number: data.number, title: data.title, url: data.url };
2822
+ }
2753
2823
  function parseRepoUrl(repoUrl) {
2754
2824
  try {
2755
2825
  const url = new URL(repoUrl);
@@ -2847,8 +2917,23 @@ var GitHubIntegration = class extends BaseIntegration {
2847
2917
  () => this.getIssue(params)
2848
2918
  );
2849
2919
  break;
2920
+ case "getFile":
2921
+ data = await this.executeWithRetry(
2922
+ () => this.getFile(params)
2923
+ );
2924
+ break;
2925
+ case "listCommits":
2926
+ data = await this.executeWithRetry(
2927
+ () => this.listCommits(params)
2928
+ );
2929
+ break;
2930
+ case "createIssue":
2931
+ data = await this.executeWithRetry(
2932
+ () => this.createIssue(params)
2933
+ );
2934
+ break;
2850
2935
  default:
2851
- throw new Error(`Unknown GitHub action: ${action}`);
2936
+ throw new UnknownActionError(this.config.name, action);
2852
2937
  }
2853
2938
  return {
2854
2939
  success: true,
@@ -2927,7 +3012,7 @@ var GitHubIntegration = class extends BaseIntegration {
2927
3012
  * List issues
2928
3013
  */
2929
3014
  async listIssues(params) {
2930
- this.logger.debug("Listing issues", { state: params.state, labels: params.labels?.join(", "), limit: params.limit });
3015
+ this.logger.debug("Listing issues", { state: params.state, labels: params.labels?.join(", "), per_page: params.per_page });
2931
3016
  const apiConfig = this.getAPIConfig();
2932
3017
  const issues = await listIssues(params, apiConfig);
2933
3018
  return { issues };
@@ -2941,6 +3026,29 @@ var GitHubIntegration = class extends BaseIntegration {
2941
3026
  const result = await getIssue(params, apiConfig);
2942
3027
  return result;
2943
3028
  }
3029
+ /**
3030
+ * Get a file's content plus metadata (owner/repo are per-call, not the
3031
+ * configured default repo)
3032
+ */
3033
+ async getFile(params) {
3034
+ this.logger.debug("Getting file", { owner: params.owner, repo: params.repo, path: params.path });
3035
+ return getFile(params, this.token);
3036
+ }
3037
+ /**
3038
+ * List commits (owner/repo are per-call, not the configured default repo)
3039
+ */
3040
+ async listCommits(params) {
3041
+ this.logger.debug("Listing commits", { owner: params.owner, repo: params.repo, path: params.path });
3042
+ const commits = await listCommitsSummary(params, this.token);
3043
+ return { commits };
3044
+ }
3045
+ /**
3046
+ * Create an issue (owner/repo are per-call, not the configured default repo)
3047
+ */
3048
+ async createIssue(params) {
3049
+ this.logger.debug("Creating issue", { owner: params.owner, repo: params.repo, title: params.title });
3050
+ return createIssue(params, this.token);
3051
+ }
2944
3052
  /**
2945
3053
  * Get API config for GitHub API calls
2946
3054
  */
@@ -2972,7 +3080,7 @@ var CLIIntegration = class extends BaseIntegration {
2972
3080
  data = await this.validate(params);
2973
3081
  break;
2974
3082
  default:
2975
- throw new Error(`Unknown CLI action: ${action}`);
3083
+ throw new UnknownActionError(this.config.name, action);
2976
3084
  }
2977
3085
  return {
2978
3086
  success: true,
@@ -3100,7 +3208,7 @@ var RedisIntegration = class extends BaseIntegration {
3100
3208
  );
3101
3209
  break;
3102
3210
  default:
3103
- throw new Error(`Unknown action: ${action}`);
3211
+ throw new UnknownActionError(this.config.name, action);
3104
3212
  }
3105
3213
  return {
3106
3214
  success: true,
@@ -3306,7 +3414,7 @@ var QueueIntegration = class extends BaseIntegration {
3306
3414
  data = await this.executeWithRetry(() => this.size(params));
3307
3415
  break;
3308
3416
  default:
3309
- throw new Error(`Unknown action: ${action}`);
3417
+ throw new UnknownActionError(this.config.name, action);
3310
3418
  }
3311
3419
  return {
3312
3420
  success: true,
@@ -3513,7 +3621,7 @@ var OtelIntegration = class extends BaseIntegration {
3513
3621
  data = await this.executeWithRetry(() => this.getAllMetrics());
3514
3622
  break;
3515
3623
  default:
3516
- throw new Error(`Unknown action: ${action}`);
3624
+ throw new UnknownActionError(this.config.name, action);
3517
3625
  }
3518
3626
  return {
3519
3627
  success: true,
@@ -3709,7 +3817,7 @@ var OAuthIntegration = class extends BaseIntegration {
3709
3817
  data = await this.executeWithRetry(() => this.real ? this.oidcUserinfo(params) : this.userinfo(params));
3710
3818
  break;
3711
3819
  default:
3712
- throw new Error(`Unknown action: ${action}`);
3820
+ throw new UnknownActionError(this.config.name, action);
3713
3821
  }
3714
3822
  return {
3715
3823
  success: true,
@@ -4027,7 +4135,7 @@ var CredentialsIntegration = class extends BaseIntegration {
4027
4135
  break;
4028
4136
  }
4029
4137
  default:
4030
- throw new Error(`Unknown action: ${action}`);
4138
+ throw new UnknownActionError(this.config.name, action);
4031
4139
  }
4032
4140
  return {
4033
4141
  success: true,
@@ -4237,7 +4345,7 @@ var StorageIntegration = class extends BaseIntegration {
4237
4345
  data = await this.executeWithRetry(() => this.getSignedUrl(params));
4238
4346
  break;
4239
4347
  default:
4240
- throw new Error(`Unknown action: ${action}`);
4348
+ throw new UnknownActionError(this.config.name, action);
4241
4349
  }
4242
4350
  return {
4243
4351
  success: true,
@@ -4530,7 +4638,7 @@ var DockerIntegration = class extends BaseIntegration {
4530
4638
  data = await this.executeWithRetry(() => this.list(params));
4531
4639
  break;
4532
4640
  default:
4533
- throw new Error(`Unknown action: ${action}`);
4641
+ throw new UnknownActionError(this.config.name, action);
4534
4642
  }
4535
4643
  return {
4536
4644
  success: true,
@@ -4948,7 +5056,7 @@ var DatabaseIntegration = class extends BaseIntegration {
4948
5056
  data = await this.executeWithRetry(() => this.runQuery(params));
4949
5057
  break;
4950
5058
  default:
4951
- throw new Error(`Unknown action: ${action}`);
5059
+ throw new UnknownActionError(this.config.name, action);
4952
5060
  }
4953
5061
  return {
4954
5062
  success: true,
@@ -5027,7 +5135,7 @@ var WikimediaIntegration = class extends BaseIntegration {
5027
5135
  data = await this.executeWithRetry(() => this.getPage(params));
5028
5136
  break;
5029
5137
  default:
5030
- throw new Error(`Unknown action: ${action}`);
5138
+ throw new UnknownActionError(this.config.name, action);
5031
5139
  }
5032
5140
  return { success: true, data, metadata: this.createMetadata(action, Date.now() - startTime) };
5033
5141
  } catch (error) {
@@ -5102,7 +5210,7 @@ var IconifyIntegration = class extends BaseIntegration {
5102
5210
  data = await this.executeWithRetry(() => this.getIconBody(params));
5103
5211
  break;
5104
5212
  default:
5105
- throw new Error(`Unknown action: ${action}`);
5213
+ throw new UnknownActionError(this.config.name, action);
5106
5214
  }
5107
5215
  return { success: true, data, metadata: this.createMetadata(action, Date.now() - startTime) };
5108
5216
  } catch (error) {
@@ -5206,7 +5314,7 @@ var ArxivIntegration = class extends BaseIntegration {
5206
5314
  data = await this.executeWithRetry(() => this.search(params));
5207
5315
  break;
5208
5316
  default:
5209
- throw new Error(`Unknown action: ${action}`);
5317
+ throw new UnknownActionError(this.config.name, action);
5210
5318
  }
5211
5319
  return { success: true, data, metadata: this.createMetadata(action, Date.now() - startTime) };
5212
5320
  } catch (error) {
@@ -5291,19 +5399,6 @@ function createCallServiceHandler(factory) {
5291
5399
  }
5292
5400
 
5293
5401
  // src/runtime/RuntimeIntegrationManager.ts
5294
- var STORE_BOOTSTRAP_ENV_VARS = /* @__PURE__ */ new Set([
5295
- "ALMADAR_CREDENTIAL_MASTER_KEY",
5296
- "ALMADAR_CREDENTIAL_MASTER_KEY_PREVIOUS"
5297
- ]);
5298
- function declaredCredentialEnvVars() {
5299
- const vars = /* @__PURE__ */ new Set();
5300
- for (const decls of Object.values(serviceCredentials)) {
5301
- for (const { envVar } of decls) {
5302
- if (!STORE_BOOTSTRAP_ENV_VARS.has(envVar)) vars.add(envVar);
5303
- }
5304
- }
5305
- return vars;
5306
- }
5307
5402
  function generateMockFromShape(shape) {
5308
5403
  const data = {};
5309
5404
  for (const [key, type] of Object.entries(shape)) {