@tool-bridge/server 0.15.0 → 0.17.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.
Files changed (115) hide show
  1. package/dist/{airtable-QYTOPRFV.js → airtable-NOSOMOVB.js} +106 -114
  2. package/dist/{alt_text_generator_ai-2CFYNSZV.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
  3. package/dist/{amap-HGOBOHSZ.js → amap-QRLP4TWZ.js} +114 -123
  4. package/dist/{anthropic-3OXOQNSR.js → anthropic-IEOI36EV.js} +34 -56
  5. package/dist/{apify-PUV2QGKL.js → apify-3CCYTQVK.js} +31 -49
  6. package/dist/{brave_search-DG75AVKA.js → brave_search-PZNYDQG7.js} +52 -77
  7. package/dist/chunk-JXHMDBAY.js +45 -0
  8. package/dist/chunk-LMLX3DJF.js +50 -0
  9. package/dist/{chunk-DXXYNIXV.js → chunk-RVWZN3CI.js} +3337 -1440
  10. package/dist/{chunk-NLPTB3IL.js → chunk-TLNUIPFZ.js} +1475 -277
  11. package/dist/chunk-U5UHT7CX.js +977 -0
  12. package/dist/chunk-U67V476Y.js +35 -0
  13. package/dist/chunk-WW2IMPQK.js +283 -0
  14. package/dist/{chunk-NQ67PIIS.js → chunk-YASUMV2K.js} +4 -6
  15. package/dist/{circleci-EFNLX5AW.js → circleci-VSJ4O5FC.js} +36 -55
  16. package/dist/{clerk-UWDLMZVM.js → clerk-CC2JZBZI.js} +60 -80
  17. package/dist/{cloudflare_dns-WQXVDSPU.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
  18. package/dist/{cohere-VPDIKUDP.js → cohere-KBACYSPF.js} +33 -49
  19. package/dist/{confluence-NBOOQNTR.js → confluence-2PX3O7G5.js} +79 -115
  20. package/dist/{convertapi-6Z6OP25T.js → convertapi-BVOTD2PJ.js} +13 -16
  21. package/dist/{currencyapi-CAMUWCTV.js → currencyapi-6ZQ2VNQ7.js} +30 -53
  22. package/dist/{deepseek-GRALXYXR.js → deepseek-MB3WVVTB.js} +30 -38
  23. package/dist/{docker_hub-5AASF3TJ.js → docker_hub-7CLQL2IJ.js} +141 -157
  24. package/dist/{dropbox-HS3VGRD3.js → dropbox-VFYDVUNK.js} +134 -141
  25. package/dist/{dub-KHERUTW6.js → dub-QN3EETJY.js} +61 -93
  26. package/dist/{e2b-4MGHPFXY.js → e2b-NKC3Y776.js} +39 -69
  27. package/dist/{exa-O77PKTBT.js → exa-KKZ6F25K.js} +49 -77
  28. package/dist/{fal_ai-TX2TZFMP.js → fal_ai-25LYJD2O.js} +37 -44
  29. package/dist/{feishu-I7VPWO3C.js → feishu-NRT55B3Q.js} +4 -6
  30. package/dist/{feishu_custom_bot-D4XZDLES.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
  31. package/dist/{figma-SW3HZCZ5.js → figma-4FLP35TC.js} +56 -81
  32. package/dist/{firehydrant-ND5DEW3L.js → firehydrant-BLXPLZ3X.js} +40 -53
  33. package/dist/{fixer-ZTSV7ZK3.js → fixer-4OR62TGE.js} +31 -43
  34. package/dist/{fly-RZ7SZKFT.js → fly-MYCKOZZK.js} +50 -66
  35. package/dist/{front-Q5MZVUGX.js → front-3DFYVMF3.js} +43 -66
  36. package/dist/{geocodio-QPHHODHG.js → geocodio-CXMD6VKA.js} +37 -63
  37. package/dist/{ghost-3Q6O7EWZ.js → ghost-4UUE737W.js} +51 -57
  38. package/dist/{github-LDMGJHXV.js → github-WFS2ON2N.js} +48 -41
  39. package/dist/{gmail-6QBCI3TT.js → gmail-KW7FXA7A.js} +26 -36
  40. package/dist/{googlecalendar-LLSYY4ZJ.js → googlecalendar-AMH5JQMC.js} +57 -78
  41. package/dist/{googledocs-KRGVBGWY.js → googledocs-R5VA6CKD.js} +14 -22
  42. package/dist/{grafana-OHPZMRHT.js → grafana-IT6DWIVB.js} +95 -122
  43. package/dist/{graphhopper-2PBY7OX4.js → graphhopper-TYFDJZWC.js} +32 -46
  44. package/dist/index.d.ts +199 -106
  45. package/dist/index.js +4 -3
  46. package/dist/{ip2proxy-GPBQZKKG.js → ip2proxy-GJ4HXVXO.js} +35 -42
  47. package/dist/{ipgeolocation_io-YNTOLOFH.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
  48. package/dist/{ipqualityscore-CZLQUAQ7.js → ipqualityscore-BCKAMDGL.js} +30 -42
  49. package/dist/{jina_ai-JIFEYH5C.js → jina_ai-N3NXRVIZ.js} +32 -58
  50. package/dist/{jira-2DKTIWHK.js → jira-CHLBKWLO.js} +116 -126
  51. package/dist/{langsmith-UCX7NHKP.js → langsmith-OIKOTPY3.js} +101 -121
  52. package/dist/{lemlist-IS6K2VJG.js → lemlist-VAKYPKS3.js} +57 -68
  53. package/dist/{linear-AK6547ZS.js → linear-Q6QTPJ5R.js} +109 -118
  54. package/dist/{logsnag-EB5LICOH.js → logsnag-SQOQBTES.js} +31 -48
  55. package/dist/main.js +103 -102
  56. package/dist/{mattermost-YOSWUA3R.js → mattermost-G2KBEICM.js} +45 -62
  57. package/dist/{mem0-IICTSHLB.js → mem0-D2FPLYDX.js} +72 -98
  58. package/dist/{memos-DIV6MZPB.js → memos-76PTWV5V.js} +68 -122
  59. package/dist/{metabase-ZGHNTCAT.js → metabase-TWSIDVBM.js} +47 -60
  60. package/dist/{mistral_ai-IAG3WZYO.js → mistral_ai-TP7TQUEJ.js} +35 -40
  61. package/dist/{mother_duck-PYKG4ZHO.js → mother_duck-UXY5THYU.js} +42 -62
  62. package/dist/{ngrok-BXN3DGTK.js → ngrok-RZW2ISJK.js} +42 -58
  63. package/dist/{notes-L2UO36HQ.js → notes-B2I6FWK2.js} +3 -5
  64. package/dist/{notion-PVHVOV4R.js → notion-QOKRUE6M.js} +83 -97
  65. package/dist/{open_exchange_rates-DVMOPFNQ.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
  66. package/dist/{openai-VW6F5YTK.js → openai-ZPBPPPGT.js} +51 -55
  67. package/dist/{opengraph_io-MQUREYWM.js → opengraph_io-EOI5UJKT.js} +61 -79
  68. package/dist/{openrouter-5MI3ODCU.js → openrouter-BUWLF3BG.js} +41 -55
  69. package/dist/{outline-B2U7NIVA.js → outline-NXS3QRXO.js} +89 -104
  70. package/dist/{paddle-LDZTVYQO.js → paddle-T4MSKQ76.js} +34 -49
  71. package/dist/{perplexity-P7BNWFMH.js → perplexity-WW5N2LW7.js} +33 -50
  72. package/dist/{pinecone-3Y67EJYP.js → pinecone-RY5AZPQM.js} +65 -91
  73. package/dist/{pipedrive-4KFLGCJW.js → pipedrive-OHYQNZTU.js} +37 -59
  74. package/dist/{polar-NIULQPUD.js → polar-XZIAHXS5.js} +43 -53
  75. package/dist/{posthog-UXGCIHRP.js → posthog-DTPTWORY.js} +58 -77
  76. package/dist/{postmark-XT77YNQM.js → postmark-F4UCQKC3.js} +52 -71
  77. package/dist/{prerender-37E6ZN6Z.js → prerender-P3Y2MLIC.js} +32 -50
  78. package/dist/{pubmed-BO2W4IR6.js → pubmed-RHU3GXFB.js} +28 -60
  79. package/dist/{railway-5BACZNYC.js → railway-VB6SRLI6.js} +32 -39
  80. package/dist/{readwise-DXABSDKY.js → readwise-DIMSKJZR.js} +62 -78
  81. package/dist/{render-4MCO6RLA.js → render-XCCDCEEK.js} +48 -64
  82. package/dist/{replicate-IVEPY4EP.js → replicate-IUEOQ4JC.js} +41 -58
  83. package/dist/{resend-XJBJO46B.js → resend-N5MJZH5E.js} +27 -37
  84. package/dist/{rootly-R6QDVF3D.js → rootly-25T4NBTU.js} +64 -76
  85. package/dist/{scrapfly-E24XNN32.js → scrapfly-PK4XFXUA.js} +45 -51
  86. package/dist/{scrapingbee-QT3O334C.js → scrapingbee-ITPBMWQU.js} +25 -33
  87. package/dist/{screenshot_fyi-MJNFPUFV.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
  88. package/dist/{semantic_scholar-BVKWS72R.js → semantic_scholar-BJGCI2MU.js} +37 -56
  89. package/dist/{sentry-52T5XARK.js → sentry-63IC263P.js} +66 -85
  90. package/dist/{shodan-RTOTTCX2.js → shodan-2WBIFHFN.js} +42 -53
  91. package/dist/{shopify-3RVWQDZ6.js → shopify-XLLJRAGM.js} +32 -49
  92. package/dist/{stripe-M3T2K3EW.js → stripe-WLVCY3UN.js} +4 -5
  93. package/dist/{supabase-UUUXAEYR.js → supabase-BKNZ35ER.js} +69 -88
  94. package/dist/{tavily-LVOZQQKJ.js → tavily-YFSDEUTL.js} +37 -62
  95. package/dist/{telegram-WJQPCKQT.js → telegram-FC35W74G.js} +168 -177
  96. package/dist/{telnyx-THKSKAI2.js → telnyx-MI32XZUG.js} +30 -50
  97. package/dist/{todoist-YTRGFFRC.js → todoist-4ZFJKZC6.js} +77 -89
  98. package/dist/{trello-QBK6WKN2.js → trello-UOGFNMK4.js} +108 -122
  99. package/dist/{turso-EA44ZKLR.js → turso-YTSTW3ZS.js} +52 -64
  100. package/dist/{twilio-GSW3V55S.js → twilio-XAJDFUQH.js} +48 -55
  101. package/dist/{umami-DVZ7XUYC.js → umami-ZVIUBPAI.js} +49 -69
  102. package/dist/{unsplash-ZWUWQ7OS.js → unsplash-IU3PLDNS.js} +35 -52
  103. package/dist/{upstash_redis-BQIQB5NM.js → upstash_redis-3EYJW7SY.js} +28 -40
  104. package/dist/{uptimerobot-2OJHTUPV.js → uptimerobot-PJG2ASRU.js} +11 -12
  105. package/dist/{v2ex-IZF4BB4O.js → v2ex-KFQWWGFC.js} +36 -61
  106. package/dist/{vercel-PI3BJENX.js → vercel-I2ZDOQRL.js} +124 -150
  107. package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
  108. package/dist/{wolfram_alpha_api-EYQ2QCHH.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
  109. package/dist/{wordpress-ETDA6XLX.js → wordpress-36D7BSMP.js} +87 -104
  110. package/dist/{workos-D7INO4Y4.js → workos-6X4JJRRC.js} +37 -56
  111. package/dist/{zhihu-Q7FNHEDM.js → zhihu-CIXKCHIU.js} +35 -57
  112. package/package.json +5 -5
  113. package/dist/chunk-KH663T3A.js +0 -183
  114. package/dist/chunk-MLKGABMK.js +0 -9
  115. package/dist/chunk-UI4E4T5Q.js +0 -378
@@ -1,25 +1,25 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ asJsonObject
6
+ } from "./chunk-JXHMDBAY.js";
1
7
  import {
2
8
  createProviderPlugin,
3
9
  requireApiKey,
4
10
  upstreamError
5
- } from "./chunk-NQ67PIIS.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-KH663T3A.js";
9
- import "./chunk-UI4E4T5Q.js";
11
+ } from "./chunk-YASUMV2K.js";
12
+ import "./chunk-U5UHT7CX.js";
10
13
  import {
11
- TBError,
12
14
  external_exports
13
- } from "./chunk-DXXYNIXV.js";
14
- import "./chunk-MLKGABMK.js";
15
+ } from "./chunk-RVWZN3CI.js";
16
+ import "./chunk-U67V476Y.js";
15
17
 
16
18
  // ../plugins/src/ipgeolocation_io/api.ts
17
19
  var SERVICE = "ipgeolocation_io";
18
20
  var API_BASE = "https://api.ipgeolocation.io/";
19
21
  var REQUEST_TIMEOUT_MS = 3e4;
20
- function toRecord(value) {
21
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
22
- }
22
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
23
23
  function nullableString(value) {
24
24
  if (typeof value === "string") return value;
25
25
  if (typeof value === "number" || typeof value === "boolean") return String(value);
@@ -39,47 +39,27 @@ function nullableInteger(value) {
39
39
  }
40
40
  function errorMessage(payload, status) {
41
41
  if (typeof payload === "string" && payload.trim() !== "") return payload;
42
- const record = toRecord(payload);
42
+ const record = asJsonObject(payload);
43
43
  const message = record?.message ?? record?.error;
44
44
  if (typeof message === "string" && message.trim() !== "") return message;
45
45
  return `IPGeolocation.io request failed with status ${status}`;
46
46
  }
47
- async function readPayload(response) {
48
- const body = await response.text();
49
- if (body.trim() === "") return null;
50
- try {
51
- return JSON.parse(body);
52
- } catch {
53
- throw upstreamError(502, "IPGeolocation.io returned invalid JSON");
54
- }
55
- }
56
47
  async function request(ctx, path, params) {
57
- const url = new URL(path, API_BASE);
58
- url.searchParams.set("apiKey", requireApiKey(ctx, SERVICE));
59
- for (const [key, value] of Object.entries(params)) {
60
- if (value !== void 0) url.searchParams.set(key, value);
61
- }
62
- let response;
63
- try {
64
- response = await guardedFetch(url.toString(), {
65
- method: "GET",
66
- headers: { accept: "application/json" },
67
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
68
- });
69
- } catch (error) {
70
- if (error instanceof TBError) throw error;
71
- if (error instanceof Error && error.name === "TimeoutError") {
72
- throw upstreamError(504, "IPGeolocation.io request timed out");
73
- }
74
- throw error;
75
- }
76
- const payload = await readPayload(response);
77
- if (!response.ok) {
78
- const status = response.status;
79
- const normalized = status === 429 || status === 401 || status === 403 ? status : status >= 400 && status < 500 ? 400 : status || 500;
80
- throw upstreamError(normalized, errorMessage(payload, status));
81
- }
82
- const record = toRecord(payload);
48
+ const { data: payload } = await http.request({
49
+ path,
50
+ method: "GET",
51
+ query: [["apiKey", requireApiKey(ctx, SERVICE)], ...Object.entries(params)],
52
+ headers: { accept: "application/json" },
53
+ timeoutMs: REQUEST_TIMEOUT_MS,
54
+ invalidJsonMessage: "IPGeolocation.io returned invalid JSON",
55
+ mapError: ({ bodyKind, data, status }) => {
56
+ if (bodyKind === "invalid-json") return upstreamError(502, "IPGeolocation.io returned invalid JSON");
57
+ const normalized = status === 429 || status === 401 || status === 403 ? status : status >= 400 && status < 500 ? 400 : status || 500;
58
+ return upstreamError(normalized, errorMessage(data, status));
59
+ },
60
+ mapTransportError: ({ kind }) => kind === "timeout" ? upstreamError(504, "IPGeolocation.io request timed out") : upstreamError(502, "IPGeolocation.io request failed")
61
+ });
62
+ const record = asJsonObject(payload);
83
63
  if (record === void 0) throw upstreamError(502, "IPGeolocation.io returned an invalid payload");
84
64
  return record;
85
65
  }
@@ -106,7 +86,7 @@ async function lookupIp(input, ctx) {
106
86
  excludes: joinList(input.excludes),
107
87
  include: includes.length > 0 ? includes.join(",") : void 0
108
88
  });
109
- const location = toRecord(payload.location) ?? payload;
89
+ const location = asJsonObject(payload.location) ?? payload;
110
90
  return {
111
91
  geolocation: {
112
92
  ip: nullableString(payload.ip),
@@ -122,17 +102,17 @@ async function lookupIp(input, ctx) {
122
102
  zipcode: nullableString(location.zipcode),
123
103
  latitude: nullableNumber(location.latitude),
124
104
  longitude: nullableNumber(location.longitude),
125
- callingCode: nullableString(toRecord(payload.country_metadata)?.calling_code),
105
+ callingCode: nullableString(asJsonObject(payload.country_metadata)?.calling_code),
126
106
  countryFlag: nullableString(location.country_flag),
127
- countryMetadata: toRecord(payload.country_metadata) ?? null,
128
- network: toRecord(payload.network) ?? null,
129
- asn: toRecord(payload.asn) ?? null,
130
- company: toRecord(payload.company) ?? null,
131
- timeZone: toRecord(payload.time_zone) ?? null,
132
- currency: toRecord(payload.currency) ?? null,
133
- security: toRecord(payload.security) ?? null,
134
- abuse: toRecord(payload.abuse) ?? null,
135
- userAgent: toRecord(payload.user_agent) ?? null,
107
+ countryMetadata: asJsonObject(payload.country_metadata) ?? null,
108
+ network: asJsonObject(payload.network) ?? null,
109
+ asn: asJsonObject(payload.asn) ?? null,
110
+ company: asJsonObject(payload.company) ?? null,
111
+ timeZone: asJsonObject(payload.time_zone) ?? null,
112
+ currency: asJsonObject(payload.currency) ?? null,
113
+ security: asJsonObject(payload.security) ?? null,
114
+ abuse: asJsonObject(payload.abuse) ?? null,
115
+ userAgent: asJsonObject(payload.user_agent) ?? null,
136
116
  raw: payload
137
117
  }
138
118
  };
@@ -163,7 +143,7 @@ async function getTimezone(input, ctx) {
163
143
  yearAbbr: nullableString(payload.year_abbr),
164
144
  isDst: typeof payload.is_dst === "boolean" ? payload.is_dst : null,
165
145
  dstSavings: nullableInteger(payload.dst_savings),
166
- geo: toRecord(payload.geo) ?? null,
146
+ geo: asJsonObject(payload.geo) ?? null,
167
147
  raw: payload
168
148
  }
169
149
  };
@@ -178,7 +158,7 @@ async function getAstronomy(input, ctx) {
178
158
  });
179
159
  return {
180
160
  astronomy: {
181
- location: toRecord(payload.location) ?? null,
161
+ location: asJsonObject(payload.location) ?? null,
182
162
  date: nullableString(payload.date),
183
163
  currentTime: nullableString(payload.current_time),
184
164
  sunrise: nullableString(payload.sunrise),
@@ -1,21 +1,23 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import "./chunk-JXHMDBAY.js";
1
5
  import {
2
6
  createProviderPlugin,
3
7
  requireApiKey,
4
8
  upstreamError
5
- } from "./chunk-NQ67PIIS.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-KH663T3A.js";
9
- import "./chunk-UI4E4T5Q.js";
9
+ } from "./chunk-YASUMV2K.js";
10
+ import "./chunk-U5UHT7CX.js";
10
11
  import {
11
12
  TBError,
12
13
  external_exports
13
- } from "./chunk-DXXYNIXV.js";
14
- import "./chunk-MLKGABMK.js";
14
+ } from "./chunk-RVWZN3CI.js";
15
+ import "./chunk-U67V476Y.js";
15
16
 
16
17
  // ../plugins/src/ipqualityscore/api.ts
17
18
  var SERVICE = "ipqualityscore";
18
19
  var API_BASE = "https://www.ipqualityscore.com";
20
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
19
21
  var IP_LITERAL = external_exports.union([external_exports.ipv4(), external_exports.ipv6()]);
20
22
  function optionalText(value) {
21
23
  return value?.trim() || void 0;
@@ -32,55 +34,41 @@ function messageOf(payload) {
32
34
  const pick = (value) => typeof value === "string" ? optionalText(value) : void 0;
33
35
  return pick(record.message) ?? pick(record.error);
34
36
  }
35
- function ipqsError(response, payload) {
36
- const message = messageOf(payload) ?? optionalText(response.statusText) ?? `IPQualityScore request failed with ${response.status}`;
37
+ function ipqsError(status, statusText, payload) {
38
+ const message = messageOf(payload) ?? optionalText(statusText) ?? `IPQualityScore request failed with ${status}`;
37
39
  const lower = message.toLowerCase();
38
- if (response.status === 429 || response.status === 402 || lower.includes("insufficient credits")) {
40
+ if (status === 429 || status === 402 || lower.includes("insufficient credits")) {
39
41
  return upstreamError(429, message);
40
42
  }
41
- if (lower.includes("invalid api key") || lower.includes("api key") || response.status === 401 || response.status === 403) {
43
+ if (lower.includes("invalid api key") || lower.includes("api key") || status === 401 || status === 403) {
42
44
  return upstreamError(401, message);
43
45
  }
44
- if (response.status === 400 || lower.includes("invalid ip") || lower.includes("invalid email") || lower.includes("invalid phone") || lower.includes("invalid url")) {
46
+ if (status === 400 || lower.includes("invalid ip") || lower.includes("invalid email") || lower.includes("invalid phone") || lower.includes("invalid url")) {
45
47
  return upstreamError(400, message);
46
48
  }
47
- return upstreamError(response.status >= 400 ? response.status : 502, message);
48
- }
49
- async function readPayload(response) {
50
- const body = await response.text();
51
- if (body === "") return null;
52
- try {
53
- return JSON.parse(body);
54
- } catch {
55
- return body;
56
- }
49
+ return upstreamError(status >= 400 ? status : 502, message);
57
50
  }
58
51
  async function request(ctx, family, value, query = []) {
59
- const path = `/api/json/${family}/${encodeURIComponent(requireApiKey(ctx, SERVICE))}/${encodeURIComponent(value)}`;
60
- const url = new URL(path, API_BASE);
61
- for (const [key, queryValue] of query) {
62
- if (queryValue !== void 0) url.searchParams.append(key, queryValue);
63
- }
64
- let response;
65
- let payload;
66
- try {
67
- response = await guardedFetch(url.toString(), {
68
- method: "GET",
69
- headers: { accept: "application/json" }
70
- });
71
- payload = await readPayload(response);
72
- } catch (error) {
73
- throw new TBError(
52
+ const apiKey = requireApiKey(ctx, SERVICE);
53
+ const result = await http.request({
54
+ path: `/api/json/${family}/${encodeURIComponent(apiKey)}/${encodeURIComponent(value)}`,
55
+ method: "GET",
56
+ query,
57
+ headers: { accept: "application/json" },
58
+ invalidJson: "text",
59
+ sensitiveValues: [apiKey],
60
+ mapError: ({ data, status, statusText }) => ipqsError(status, statusText, data),
61
+ mapTransportError: ({ message }) => new TBError(
74
62
  "unavailable",
75
- error instanceof Error ? `IPQualityScore \u8BF7\u6C42\u5931\u8D25: ${error.message}` : "IPQualityScore \u8BF7\u6C42\u5931\u8D25",
63
+ message === void 0 ? "IPQualityScore \u8BF7\u6C42\u5931\u8D25" : `IPQualityScore \u8BF7\u6C42\u5931\u8D25: ${message}`,
76
64
  { retryable: true }
77
- );
78
- }
79
- if (!response.ok) throw ipqsError(response, payload);
65
+ )
66
+ });
67
+ const payload = result.bodyKind === "empty" ? null : result.data;
80
68
  if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
81
69
  throw new TBError("unavailable", `IPQualityScore \u5BF9 ${family} \u7684\u54CD\u5E94\u4E0D\u662F JSON \u5BF9\u8C61`, { retryable: true });
82
70
  }
83
- if (payload.success === false) throw ipqsError(response, payload);
71
+ if (payload.success === false) throw ipqsError(result.status, result.statusText, payload);
84
72
  return payload;
85
73
  }
86
74
  async function checkIpReputation(input, ctx) {
@@ -1,74 +1,48 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-WW2IMPQK.js";
4
+ import {
5
+ messageFrom
6
+ } from "./chunk-JXHMDBAY.js";
1
7
  import {
2
8
  createProviderPlugin,
3
9
  requireApiKey,
4
10
  upstreamError
5
- } from "./chunk-NQ67PIIS.js";
6
- import {
7
- guardedFetch
8
- } from "./chunk-KH663T3A.js";
9
- import "./chunk-UI4E4T5Q.js";
11
+ } from "./chunk-YASUMV2K.js";
12
+ import "./chunk-U5UHT7CX.js";
10
13
  import {
11
- TBError,
12
14
  external_exports
13
- } from "./chunk-DXXYNIXV.js";
14
- import "./chunk-MLKGABMK.js";
15
+ } from "./chunk-RVWZN3CI.js";
16
+ import "./chunk-U67V476Y.js";
15
17
 
16
18
  // ../plugins/src/jina_ai/api.ts
17
19
  var SERVICE = "jina_ai";
18
- var API_BASE = "https://api.jina.ai";
19
20
  var REQUEST_TIMEOUT_MS = 3e4;
20
- function record(value) {
21
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
22
- }
23
- function text(value) {
24
- if (typeof value !== "string") return void 0;
25
- const trimmed = value.trim();
26
- return trimmed === "" ? void 0 : trimmed;
27
- }
28
- function errorMessage(status, body, payload) {
29
- const top = record(payload);
30
- return text(top?.detail) ?? text(top?.message) ?? text(body) ?? `Jina AI request failed with ${status}`;
31
- }
21
+ var http = createProviderHttpClient({ baseUrl: "https://api.jina.ai/", service: SERVICE });
32
22
  async function request(ctx, path, body) {
33
- const apiKey = requireApiKey(ctx, SERVICE);
34
- const timeoutSignal = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
35
- let response;
36
- try {
37
- response = await guardedFetch(`${API_BASE}${path}`, {
38
- method: "POST",
39
- headers: {
40
- "accept": "application/json",
41
- "authorization": `Bearer ${apiKey}`,
42
- "content-type": "application/json"
43
- },
44
- body: JSON.stringify(body),
45
- signal: timeoutSignal
46
- });
47
- } catch (error) {
48
- if (error instanceof TBError) throw error;
49
- if (timeoutSignal.aborted) throw upstreamError(504, `Jina AI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`);
50
- const message = error instanceof Error ? error.message : "unknown network error";
51
- throw upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message}`);
52
- }
53
- const raw = await response.text();
54
- let payload = null;
55
- if (raw !== "") {
56
- try {
57
- payload = JSON.parse(raw);
58
- } catch {
59
- if (response.ok) {
60
- throw new TBError("unavailable", "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
61
- }
62
- }
63
- }
64
- if (!response.ok) throw upstreamError(response.status, errorMessage(response.status, raw, payload));
65
- return payload;
23
+ const { data } = await http.request({
24
+ path,
25
+ method: "POST",
26
+ headers: {
27
+ accept: "application/json",
28
+ authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
29
+ },
30
+ json: body,
31
+ timeoutMs: REQUEST_TIMEOUT_MS,
32
+ invalidJsonMessage: "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
33
+ mapError: ({ data: payload, status }) => upstreamError(
34
+ status,
35
+ messageFrom(payload, ["detail", "message"], `Jina AI request failed with ${status}`)
36
+ ),
37
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Jina AI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message ?? "unknown network error"}`)
38
+ });
39
+ return data ?? null;
66
40
  }
67
- async function createEmbeddings(input, ctx) {
68
- return request(ctx, "/v1/embeddings", input);
41
+ function createEmbeddings(input, ctx) {
42
+ return request(ctx, "v1/embeddings", input);
69
43
  }
70
- async function rerankDocuments(input, ctx) {
71
- return request(ctx, "/v1/rerank", input);
44
+ function rerankDocuments(input, ctx) {
45
+ return request(ctx, "v1/rerank", input);
72
46
  }
73
47
 
74
48
  // ../plugins/src/jina_ai/schema.ts