@tool-bridge/server 0.20.0 → 0.21.1

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.
Files changed (111) hide show
  1. package/dist/{airtable-ZNWHIJMO.js → airtable-LLZDFN7M.js} +19 -16
  2. package/dist/{alt_text_generator_ai-X7RMDDM5.js → alt_text_generator_ai-W7O34SNG.js} +4 -4
  3. package/dist/{amap-3VER75VH.js → amap-VOX4T2AW.js} +4 -4
  4. package/dist/{anthropic-N7NTB3UC.js → anthropic-G23NN3X5.js} +23 -25
  5. package/dist/{apify-JB5P5AJI.js → apify-Y3SS734K.js} +20 -19
  6. package/dist/{brave_search-USL5OOBS.js → brave_search-ZC7OAPSZ.js} +16 -14
  7. package/dist/{chunk-6ANLYNFB.js → chunk-ATK45BXV.js} +1 -1
  8. package/dist/{chunk-6X55ALDX.js → chunk-E6JCVKW6.js} +6 -5
  9. package/dist/{chunk-RVUERWUZ.js → chunk-KMTT3I6D.js} +768 -1048
  10. package/dist/chunk-R6P4XAE5.js +248 -0
  11. package/dist/{chunk-3WL6EXYX.js → chunk-U7B6DS2O.js} +1 -1
  12. package/dist/{chunk-WIGQCP6O.js → chunk-UZM2RXZH.js} +159 -182
  13. package/dist/chunk-XYBU3WZH.js +71 -0
  14. package/dist/{circleci-LBGB25LP.js → circleci-3BAX5FCG.js} +20 -24
  15. package/dist/{clerk-6RX37CNZ.js → clerk-6LEM6TNU.js} +22 -21
  16. package/dist/{cloudflare_dns-NQGW7FHV.js → cloudflare_dns-KINYTJUD.js} +21 -17
  17. package/dist/{cohere-XPC2NAEW.js → cohere-XCJ5AJ6B.js} +19 -17
  18. package/dist/{confluence-ZUG2LT5A.js → confluence-B3EWPZVE.js} +16 -11
  19. package/dist/{convertapi-ZLXKWV3L.js → convertapi-EUWSQYPF.js} +3 -3
  20. package/dist/{currencyapi-T3A3HSOD.js → currencyapi-KVTIK3GL.js} +23 -26
  21. package/dist/{deepseek-NJMOD23E.js → deepseek-PC5YGNC5.js} +27 -17
  22. package/dist/{docker_hub-D2MQCSJ7.js → docker_hub-C3MA5FU6.js} +4 -4
  23. package/dist/{dropbox-MI6U3SOT.js → dropbox-XBV7Z2IR.js} +9 -8
  24. package/dist/{dub-P2BYBYV4.js → dub-LDOFG3HC.js} +22 -19
  25. package/dist/{e2b-BGKIAE54.js → e2b-JMCPSVBW.js} +20 -20
  26. package/dist/{exa-EUY7VV4C.js → exa-RAK7O7RD.js} +22 -25
  27. package/dist/{fal_ai-AAOG5FYJ.js → fal_ai-23E7JPNT.js} +18 -17
  28. package/dist/feishu-7QRIDUV6.js +12019 -0
  29. package/dist/{feishu_custom_bot-BWGMNVXF.js → feishu_custom_bot-TJ4K7QNJ.js} +3 -3
  30. package/dist/{figma-SJSWYCGD.js → figma-E6IX5DTH.js} +21 -23
  31. package/dist/{firehydrant-MOXK2PST.js → firehydrant-ZBLPQREE.js} +15 -15
  32. package/dist/{fixer-ISIDUDZU.js → fixer-BWON27UO.js} +4 -4
  33. package/dist/{fly-U4KPSGBF.js → fly-ZH3HFCZJ.js} +20 -16
  34. package/dist/{front-ZHM2YX2E.js → front-QCGXYEDJ.js} +20 -23
  35. package/dist/{geocodio-SVCCAXAV.js → geocodio-YGNI7DA4.js} +4 -4
  36. package/dist/{ghost-INTR7FIY.js → ghost-EVSGKH2Q.js} +4 -4
  37. package/dist/{github-T275VVWR.js → github-MA2BGRCJ.js} +28 -27
  38. package/dist/{gmail-KSSPOE67.js → gmail-E5E6AADE.js} +17 -17
  39. package/dist/{googlecalendar-JB5RW27L.js → googlecalendar-BTLFPXTD.js} +22 -19
  40. package/dist/{googledocs-G522PUGW.js → googledocs-BUHL4J2H.js} +6 -5
  41. package/dist/{grafana-44ZPIV5P.js → grafana-GLU2DWF2.js} +24 -25
  42. package/dist/{graphhopper-2MORXLOW.js → graphhopper-WSMB3TCD.js} +4 -4
  43. package/dist/index.d.ts +31 -30
  44. package/dist/index.js +4 -3
  45. package/dist/{ip2proxy-R4K4KEMI.js → ip2proxy-EZ64Y4ZH.js} +4 -4
  46. package/dist/{ipgeolocation_io-H4J55OGI.js → ipgeolocation_io-AA7HAS22.js} +4 -4
  47. package/dist/{ipqualityscore-XGID4OHA.js → ipqualityscore-BHJXVTJT.js} +4 -4
  48. package/dist/{jina_ai-7ZVDOR3Z.js → jina_ai-EFBHTBXL.js} +20 -21
  49. package/dist/{jira-CTIYZTT3.js → jira-HQSHAA5K.js} +20 -16
  50. package/dist/{langsmith-ISP567FS.js → langsmith-5W6SCT6F.js} +25 -25
  51. package/dist/{lemlist-OGKK272F.js → lemlist-HJWH6UMK.js} +23 -24
  52. package/dist/{linear-6JX4E3JI.js → linear-K7RYFYAD.js} +6 -5
  53. package/dist/{logsnag-BVB36ZCL.js → logsnag-4KFOHL37.js} +20 -22
  54. package/dist/main.js +103 -102
  55. package/dist/{mattermost-UECVPZGY.js → mattermost-S2BRCWLQ.js} +21 -17
  56. package/dist/{mem0-EUA7S2OO.js → mem0-CAW43CIC.js} +15 -15
  57. package/dist/{memos-BYSBJRWZ.js → memos-TWEGPKFM.js} +39 -34
  58. package/dist/{metabase-4JXZH3YG.js → metabase-MMSEPCOF.js} +22 -18
  59. package/dist/{mistral_ai-2C5BTBKW.js → mistral_ai-64BGZQHP.js} +24 -21
  60. package/dist/{mother_duck-ZGNNNR3X.js → mother_duck-H7PCQNZ2.js} +23 -19
  61. package/dist/{ngrok-NTPGMRXI.js → ngrok-GQCUGZKJ.js} +17 -22
  62. package/dist/{notes-KGYXX6N6.js → notes-PFMKRO33.js} +1 -1
  63. package/dist/{notion-EX3X2G7G.js → notion-DQWZWP4N.js} +20 -17
  64. package/dist/{open_exchange_rates-2V2LIGPS.js → open_exchange_rates-QMMD735E.js} +4 -4
  65. package/dist/{openai-KQFQPK7Z.js → openai-W6PX32NZ.js} +22 -16
  66. package/dist/{opengraph_io-B63SEYJY.js → opengraph_io-HNDBXYNW.js} +4 -4
  67. package/dist/{openrouter-62A4H62Q.js → openrouter-JJYMEAUL.js} +19 -14
  68. package/dist/{outline-QC33XLCK.js → outline-MCBNQZYY.js} +18 -20
  69. package/dist/{paddle-HDZG35Y7.js → paddle-D2SKLUDN.js} +17 -15
  70. package/dist/{perplexity-M7LOMJWA.js → perplexity-XIFMKUAE.js} +19 -23
  71. package/dist/{pinecone-Y7YCJRZM.js → pinecone-HUFTALV2.js} +19 -24
  72. package/dist/{pipedrive-FLJA62UX.js → pipedrive-Y2O7QGFF.js} +22 -23
  73. package/dist/{polar-AE55Q425.js → polar-TYTOMOSR.js} +19 -17
  74. package/dist/{posthog-IAY5D3YW.js → posthog-43JAR3VW.js} +29 -24
  75. package/dist/{postmark-NMKAXDXZ.js → postmark-KL2QJYSG.js} +19 -17
  76. package/dist/{prerender-CDJM7I7N.js → prerender-MENYM2TY.js} +4 -4
  77. package/dist/{pubmed-N437ZJOR.js → pubmed-GOXUVVH5.js} +6 -5
  78. package/dist/{railway-NBWYXCUM.js → railway-V2SID4WV.js} +3 -3
  79. package/dist/{readwise-QRO3UC3R.js → readwise-CI4GIMMJ.js} +16 -15
  80. package/dist/{render-NEW7SROG.js → render-SUBJ6YRZ.js} +21 -20
  81. package/dist/{replicate-73YQLRTY.js → replicate-756MXPYX.js} +20 -21
  82. package/dist/{resend-R5BAZFHZ.js → resend-ZKH3BTBI.js} +15 -11
  83. package/dist/{rootly-5BLALPCS.js → rootly-CD2LJHPI.js} +19 -18
  84. package/dist/{scrapfly-EHFLNNUZ.js → scrapfly-NSRHFDIQ.js} +4 -4
  85. package/dist/{scrapingbee-UXLYS72S.js → scrapingbee-OQHLAVEY.js} +4 -4
  86. package/dist/{screenshot_fyi-KC3NLTJ6.js → screenshot_fyi-DVWG3AXC.js} +4 -4
  87. package/dist/{semantic_scholar-SA5OIUWA.js → semantic_scholar-T4A252KW.js} +21 -20
  88. package/dist/{sentry-BAE3XLJN.js → sentry-546MNDJG.js} +22 -19
  89. package/dist/{shodan-FJR6MKKW.js → shodan-C3OON3Z3.js} +4 -4
  90. package/dist/{shopify-7OA6SLN5.js → shopify-Y2HN2MCQ.js} +23 -19
  91. package/dist/{stripe-MUWDZGGF.js → stripe-VE3CD3AY.js} +3 -3
  92. package/dist/{supabase-SWWGNWYR.js → supabase-U2SL4D63.js} +18 -17
  93. package/dist/{tavily-XQNJ5EDI.js → tavily-KCZHK6HE.js} +20 -20
  94. package/dist/{telegram-RR6JPZOG.js → telegram-3URFBCMY.js} +4 -4
  95. package/dist/{telnyx-7PKXOWSO.js → telnyx-CXQ4EZUX.js} +19 -19
  96. package/dist/{todoist-63X5IUJE.js → todoist-HNPWNYTD.js} +18 -17
  97. package/dist/{trello-MOG63DAI.js → trello-3W2MIXRP.js} +4 -4
  98. package/dist/{turso-ENWTSHDL.js → turso-2EQF7C2Z.js} +23 -30
  99. package/dist/{twilio-FDXUN7VX.js → twilio-4PDBJKWX.js} +6 -5
  100. package/dist/{umami-TM7PROWF.js → umami-5REN7TGP.js} +23 -28
  101. package/dist/{unsplash-NWXLKSOW.js → unsplash-EIXL424F.js} +19 -18
  102. package/dist/{upstash_redis-CUTQ5L2N.js → upstash_redis-G4LQBYHA.js} +17 -13
  103. package/dist/{uptimerobot-NNO32M3I.js → uptimerobot-KNJ3EYLY.js} +3 -3
  104. package/dist/{v2ex-24KMSWS7.js → v2ex-RHJ234PZ.js} +35 -18
  105. package/dist/{vercel-B45LPF6I.js → vercel-AS6NCIC7.js} +21 -18
  106. package/dist/{wolfram_alpha_api-DKJWVR6G.js → wolfram_alpha_api-3G4PUJWB.js} +4 -4
  107. package/dist/{wordpress-XYFSDZXY.js → wordpress-KNDAAUV7.js} +21 -17
  108. package/dist/{workos-BEM7EPHM.js → workos-R6UITSJ7.js} +26 -27
  109. package/dist/{zhihu-CFHZ4NC7.js → zhihu-AGK4HILK.js} +21 -21
  110. package/package.json +5 -5
  111. package/dist/feishu-AN5IJYOW.js +0 -231
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -9,20 +10,18 @@ import {
9
10
  } from "./chunk-JXHMDBAY.js";
10
11
  import {
11
12
  createProviderPlugin,
12
- requireApiKey,
13
13
  upstreamError
14
- } from "./chunk-6ANLYNFB.js";
15
- import "./chunk-3WL6EXYX.js";
14
+ } from "./chunk-ATK45BXV.js";
15
+ import "./chunk-U7B6DS2O.js";
16
16
  import {
17
17
  TBError,
18
18
  external_exports
19
- } from "./chunk-WIGQCP6O.js";
19
+ } from "./chunk-UZM2RXZH.js";
20
20
  import "./chunk-U67V476Y.js";
21
21
 
22
22
  // ../plugins/src/dub/api.ts
23
23
  var SERVICE = "dub";
24
24
  var API_BASE = "https://api.dub.co";
25
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
26
25
  var LINKS_PATH = "/links";
27
26
  var LINKS_INFO_PATH = "/links/info";
28
27
  var LINKS_COUNT_PATH = "/links/count";
@@ -41,23 +40,27 @@ function errorMessage(payload) {
41
40
  if (object === void 0) return void 0;
42
41
  return trimmedText(asJsonObject(object.error)?.message) ?? trimmedText(object.message) ?? trimmedText(object.error);
43
42
  }
43
+ var http = createAuthedClient({
44
+ baseUrl: API_BASE,
45
+ service: SERVICE,
46
+ auth: { kind: "bearer" },
47
+ headers: { accept: "application/json" },
48
+ mapError: ({ data: payload, status, statusText }) => upstreamError(
49
+ status,
50
+ errorMessage(payload) ?? (statusText || `dub \u8FD4\u56DE HTTP ${status}`)
51
+ ),
52
+ mapTransportError: ({ message }) => upstreamError(
53
+ 502,
54
+ message === void 0 ? "dub \u8BF7\u6C42\u5931\u8D25" : `dub \u8BF7\u6C42\u5931\u8D25: ${message}`
55
+ )
56
+ });
44
57
  async function request(ctx, path, input) {
45
- const apiKey = requireApiKey(ctx, SERVICE);
46
- const { bodyKind, data } = await http.request({
58
+ const { bodyKind, data } = await http.request(ctx, {
47
59
  path,
48
60
  method: input.method,
49
61
  query: providerQuery(input.query ?? {}),
50
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
51
62
  ...input.body === void 0 ? {} : { json: input.body },
52
- invalidJson: "text",
53
- mapError: ({ data: payload, status, statusText }) => upstreamError(
54
- status,
55
- errorMessage(payload) ?? (statusText || `dub \u8FD4\u56DE HTTP ${status}`)
56
- ),
57
- mapTransportError: ({ message }) => upstreamError(
58
- 502,
59
- message === void 0 ? "dub \u8BF7\u6C42\u5931\u8D25" : `dub \u8BF7\u6C42\u5931\u8D25: ${message}`
60
- )
63
+ invalidJson: "text"
61
64
  });
62
65
  return bodyKind === "empty" ? null : data;
63
66
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,21 +9,31 @@ import {
8
9
  } from "./chunk-JXHMDBAY.js";
9
10
  import {
10
11
  createProviderPlugin,
11
- requireApiKey,
12
12
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
- import "./chunk-3WL6EXYX.js";
13
+ } from "./chunk-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/e2b/api.ts
22
22
  var SERVICE = "e2b";
23
23
  var API_BASE = "https://api.e2b.app";
24
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
25
24
  var REQUEST_TIMEOUT_MS = 3e4;
25
+ var http = createAuthedClient({
26
+ baseUrl: API_BASE,
27
+ service: SERVICE,
28
+ auth: { kind: "header", name: "x-api-key" },
29
+ headers: { accept: "application/json" },
30
+ // E2B 的错误文案:纯文本 body 直接用,JSON 则依次看 message / error / detail。
31
+ errorMessage: {
32
+ keys: ["message", "error", "detail"],
33
+ fallback: (status) => `E2B request failed with status ${status}`
34
+ },
35
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `E2B ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, message === void 0 ? "E2B request failed" : `E2B request failed: ${message}`)
36
+ });
26
37
  function requireText(value, field) {
27
38
  const result = trimmedText(value);
28
39
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
@@ -38,30 +49,19 @@ function stringArray(value) {
38
49
  const items = value.filter((item) => typeof item === "string" && item !== "");
39
50
  return items.length > 0 ? items : void 0;
40
51
  }
41
- function errorMessage(payload, status) {
42
- if (typeof payload === "string") {
43
- const trimmed = payload.trim();
44
- if (trimmed !== "") return trimmed;
45
- }
46
- const body = asJsonObject(payload);
47
- return trimmedText(body?.message) ?? trimmedText(body?.error) ?? trimmedText(body?.detail) ?? `E2B request failed with status ${status}`;
48
- }
49
52
  async function request(ctx, options) {
50
53
  const query = Object.entries(options.query ?? {}).map(([key, value]) => [
51
54
  key,
52
55
  // 数组 query 拼成一个逗号串:E2B 不认重复的同名参数。
53
56
  Array.isArray(value) ? value.join(",") : value
54
57
  ]);
55
- const { data } = await http.request({
58
+ const { data } = await http.request(ctx, {
56
59
  path: options.path,
57
60
  method: options.method ?? "GET",
58
61
  query,
59
- headers: { "accept": "application/json", "x-api-key": requireApiKey(ctx, SERVICE) },
60
62
  ...options.body === void 0 ? {} : { json: options.body },
61
63
  timeoutMs: REQUEST_TIMEOUT_MS,
62
- invalidJsonMessage: "E2B returned invalid JSON",
63
- mapError: ({ data: payload, status }) => upstreamError(status, errorMessage(payload, status)),
64
- mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `E2B ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, message === void 0 ? "E2B request failed" : `E2B request failed: ${message}`)
64
+ invalidJsonMessage: "E2B returned invalid JSON"
65
65
  });
66
66
  return data === void 0 ? options.emptySuccess ?? null : data;
67
67
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,46 +9,42 @@ import {
8
9
  } from "./chunk-JXHMDBAY.js";
9
10
  import {
10
11
  createProviderPlugin,
11
- requireApiKey,
12
12
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
- import "./chunk-3WL6EXYX.js";
13
+ } from "./chunk-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/exa/api.ts
22
22
  var SERVICE = "exa";
23
23
  var API_BASE = "https://api.exa.ai";
24
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
24
+ var http = createAuthedClient({
25
+ baseUrl: API_BASE,
26
+ service: SERVICE,
27
+ auth: { kind: "header", name: "x-api-key" },
28
+ headers: { accept: "application/json" },
29
+ errorMessage: {
30
+ keys: ["error", "message", "detail"],
31
+ fallback: (status, statusText) => statusText || `exa \u8FD4\u56DE HTTP ${status}`
32
+ },
33
+ mapTransportError: ({ message }) => upstreamError(
34
+ 502,
35
+ message === void 0 ? "exa \u8BF7\u6C42\u5931\u8D25" : `exa \u8BF7\u6C42\u5931\u8D25: ${message}`
36
+ )
37
+ });
25
38
  var SEARCH_PATH = "/search";
26
39
  var CONTENTS_PATH = "/contents";
27
40
  var ANSWER_PATH = "/answer";
28
41
  var FIND_SIMILAR_PATH = "/findSimilar";
29
- function errorMessage(payload) {
30
- if (typeof payload === "string") return trimmedText(payload);
31
- const object = asJsonObject(payload);
32
- if (object === void 0) return void 0;
33
- return trimmedText(object.error) ?? trimmedText(object.message) ?? trimmedText(object.detail);
34
- }
35
42
  async function request(ctx, path, body) {
36
- const apiKey = requireApiKey(ctx, SERVICE);
37
- const { bodyKind, data } = await http.request({
43
+ const { bodyKind, data } = await http.request(ctx, {
38
44
  path,
39
45
  method: "POST",
40
- headers: { "accept": "application/json", "x-api-key": apiKey },
41
46
  json: body,
42
- invalidJson: "text",
43
- mapError: ({ data: payload, status, statusText }) => upstreamError(
44
- status,
45
- errorMessage(payload) ?? (statusText || `exa \u8FD4\u56DE HTTP ${status}`)
46
- ),
47
- mapTransportError: ({ message }) => upstreamError(
48
- 502,
49
- message === void 0 ? "exa \u8BF7\u6C42\u5931\u8D25" : `exa \u8BF7\u6C42\u5931\u8D25: ${message}`
50
- )
47
+ invalidJson: "text"
51
48
  });
52
49
  if (bodyKind === "empty") return {};
53
50
  if (bodyKind === "invalid-json") throw upstreamError(502, "exa \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -10,21 +11,20 @@ import {
10
11
  createProviderPlugin,
11
12
  requireApiKey,
12
13
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
+ } from "./chunk-ATK45BXV.js";
14
15
  import {
15
16
  guardedFetch
16
- } from "./chunk-3WL6EXYX.js";
17
+ } from "./chunk-U7B6DS2O.js";
17
18
  import {
18
19
  TBError,
19
20
  external_exports
20
- } from "./chunk-WIGQCP6O.js";
21
+ } from "./chunk-UZM2RXZH.js";
21
22
  import "./chunk-U67V476Y.js";
22
23
 
23
24
  // ../plugins/src/fal_ai/api.ts
24
25
  var SERVICE = "fal_ai";
25
26
  var PLATFORM_BASE = "https://api.fal.ai";
26
27
  var QUEUE_BASE = "https://queue.fal.run";
27
- var http = createProviderHttpClient({ service: SERVICE });
28
28
  function str(value) {
29
29
  return typeof value === "string" ? value : void 0;
30
30
  }
@@ -62,23 +62,24 @@ function errorMessage(payload, status) {
62
62
  }
63
63
  return `fal.ai \u8FD4\u56DE HTTP ${status}`;
64
64
  }
65
+ var http = createAuthedClient({
66
+ service: SERVICE,
67
+ auth: { kind: "custom", headers: (ctx) => ({ authorization: `Key ${requireApiKey(ctx, SERVICE)}` }) },
68
+ headers: { "content-type": "application/json" },
69
+ mapError: ({ bodyKind, data, status }) => upstreamError(
70
+ status,
71
+ errorMessage(bodyKind === "json" ? data : null, status)
72
+ )
73
+ });
65
74
  async function request(ctx, input) {
66
- const result = await http.request({
75
+ const result = await http.request(ctx, {
67
76
  baseUrl: input.base,
68
77
  path: input.path,
69
78
  method: input.method ?? (input.body === void 0 ? "GET" : "POST"),
70
79
  query: Object.entries(input.query ?? {}),
71
- headers: {
72
- "authorization": `Key ${requireApiKey(ctx, SERVICE)}`,
73
- "content-type": "application/json",
74
- ...input.headers
75
- },
80
+ ...input.headers === void 0 ? {} : { headers: input.headers },
76
81
  ...input.body === void 0 ? {} : { json: input.body },
77
- invalidJsonMessage: "fal.ai \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
78
- mapError: ({ bodyKind, data, status }) => upstreamError(
79
- status,
80
- errorMessage(bodyKind === "json" ? data : null, status)
81
- )
82
+ invalidJsonMessage: "fal.ai \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
82
83
  });
83
84
  return result.data === void 0 ? null : result.data;
84
85
  }