@tool-bridge/server 0.20.0 → 0.21.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 (109) hide show
  1. package/dist/{airtable-ZNWHIJMO.js → airtable-DMJEEGJP.js} +19 -16
  2. package/dist/{alt_text_generator_ai-X7RMDDM5.js → alt_text_generator_ai-RELFQ5FV.js} +4 -4
  3. package/dist/{amap-3VER75VH.js → amap-YSYEACKQ.js} +4 -4
  4. package/dist/{anthropic-N7NTB3UC.js → anthropic-D5X5GSYE.js} +23 -25
  5. package/dist/{apify-JB5P5AJI.js → apify-5NVFU3IZ.js} +20 -19
  6. package/dist/{brave_search-USL5OOBS.js → brave_search-X557FMGO.js} +16 -14
  7. package/dist/chunk-JEWFX6Z6.js +71 -0
  8. package/dist/{chunk-RVUERWUZ.js → chunk-MDY7K5CX.js} +748 -788
  9. package/dist/{chunk-WIGQCP6O.js → chunk-MZCIPUNQ.js} +141 -176
  10. package/dist/{chunk-6X55ALDX.js → chunk-Q74GLIDK.js} +3 -3
  11. package/dist/{chunk-6ANLYNFB.js → chunk-QR4LK3HF.js} +1 -1
  12. package/dist/{chunk-3WL6EXYX.js → chunk-ZTTN6AJG.js} +1 -1
  13. package/dist/{circleci-LBGB25LP.js → circleci-3P3QTUX2.js} +20 -24
  14. package/dist/{clerk-6RX37CNZ.js → clerk-GNMZQ2MY.js} +22 -21
  15. package/dist/{cloudflare_dns-NQGW7FHV.js → cloudflare_dns-VWZH3ZTR.js} +21 -17
  16. package/dist/{cohere-XPC2NAEW.js → cohere-C7QVIIMG.js} +19 -17
  17. package/dist/{confluence-ZUG2LT5A.js → confluence-52I37IUT.js} +16 -11
  18. package/dist/{convertapi-ZLXKWV3L.js → convertapi-3TRJ3WEO.js} +3 -3
  19. package/dist/{currencyapi-T3A3HSOD.js → currencyapi-LWEANWVI.js} +23 -26
  20. package/dist/{deepseek-NJMOD23E.js → deepseek-5U24YG4P.js} +27 -17
  21. package/dist/{docker_hub-D2MQCSJ7.js → docker_hub-CMISLRSE.js} +4 -4
  22. package/dist/{dropbox-MI6U3SOT.js → dropbox-TW4QN6FT.js} +9 -8
  23. package/dist/{dub-P2BYBYV4.js → dub-EFXGI5UH.js} +22 -19
  24. package/dist/{e2b-BGKIAE54.js → e2b-PHM63OVF.js} +20 -20
  25. package/dist/{exa-EUY7VV4C.js → exa-DYOQWURR.js} +22 -25
  26. package/dist/{fal_ai-AAOG5FYJ.js → fal_ai-VJPMCNRH.js} +18 -17
  27. package/dist/{feishu-AN5IJYOW.js → feishu-TFIZXPIN.js} +2 -2
  28. package/dist/{feishu_custom_bot-BWGMNVXF.js → feishu_custom_bot-ADSE23KU.js} +3 -3
  29. package/dist/{figma-SJSWYCGD.js → figma-4AK47AYY.js} +21 -23
  30. package/dist/{firehydrant-MOXK2PST.js → firehydrant-RGPTW4EA.js} +15 -15
  31. package/dist/{fixer-ISIDUDZU.js → fixer-OAMF4DKP.js} +4 -4
  32. package/dist/{fly-U4KPSGBF.js → fly-YB4AQD4O.js} +20 -16
  33. package/dist/{front-ZHM2YX2E.js → front-6GTVYKUM.js} +20 -23
  34. package/dist/{geocodio-SVCCAXAV.js → geocodio-YRT4K25M.js} +4 -4
  35. package/dist/{ghost-INTR7FIY.js → ghost-JCW6UIP2.js} +4 -4
  36. package/dist/{github-T275VVWR.js → github-CEGVRMNX.js} +28 -27
  37. package/dist/{gmail-KSSPOE67.js → gmail-JCMJD55P.js} +17 -17
  38. package/dist/{googlecalendar-JB5RW27L.js → googlecalendar-2EAW4MNM.js} +16 -14
  39. package/dist/{googledocs-G522PUGW.js → googledocs-YNKKBM6Q.js} +3 -3
  40. package/dist/{grafana-44ZPIV5P.js → grafana-353VSGXN.js} +24 -25
  41. package/dist/{graphhopper-2MORXLOW.js → graphhopper-H3IVJNDS.js} +4 -4
  42. package/dist/index.d.ts +31 -30
  43. package/dist/index.js +3 -3
  44. package/dist/{ip2proxy-R4K4KEMI.js → ip2proxy-DBGRWH7S.js} +4 -4
  45. package/dist/{ipgeolocation_io-H4J55OGI.js → ipgeolocation_io-5I2BDVMG.js} +4 -4
  46. package/dist/{ipqualityscore-XGID4OHA.js → ipqualityscore-ILV7TQCV.js} +4 -4
  47. package/dist/{jina_ai-7ZVDOR3Z.js → jina_ai-L5BH455V.js} +20 -21
  48. package/dist/{jira-CTIYZTT3.js → jira-IGTILUZA.js} +20 -16
  49. package/dist/{langsmith-ISP567FS.js → langsmith-BYRX4AOF.js} +25 -25
  50. package/dist/{lemlist-OGKK272F.js → lemlist-ZGNYTIQO.js} +23 -24
  51. package/dist/{linear-6JX4E3JI.js → linear-HLGOWISN.js} +3 -3
  52. package/dist/{logsnag-BVB36ZCL.js → logsnag-5RGTMTU2.js} +20 -22
  53. package/dist/main.js +102 -102
  54. package/dist/{mattermost-UECVPZGY.js → mattermost-BONGXVC7.js} +21 -17
  55. package/dist/{mem0-EUA7S2OO.js → mem0-RUVNUPTE.js} +15 -15
  56. package/dist/{memos-BYSBJRWZ.js → memos-TED4HI54.js} +36 -32
  57. package/dist/{metabase-4JXZH3YG.js → metabase-ZHXHRHZK.js} +22 -18
  58. package/dist/{mistral_ai-2C5BTBKW.js → mistral_ai-NGP5SHU7.js} +24 -21
  59. package/dist/{mother_duck-ZGNNNR3X.js → mother_duck-TKVQM35M.js} +23 -19
  60. package/dist/{ngrok-NTPGMRXI.js → ngrok-BYCUJ7QV.js} +17 -22
  61. package/dist/{notes-KGYXX6N6.js → notes-KXRNNYDW.js} +1 -1
  62. package/dist/{notion-EX3X2G7G.js → notion-2ILYKJOO.js} +20 -17
  63. package/dist/{open_exchange_rates-2V2LIGPS.js → open_exchange_rates-JU4DC6HZ.js} +4 -4
  64. package/dist/{openai-KQFQPK7Z.js → openai-6SOT26ZK.js} +22 -16
  65. package/dist/{opengraph_io-B63SEYJY.js → opengraph_io-ZEFHV2OL.js} +4 -4
  66. package/dist/{openrouter-62A4H62Q.js → openrouter-R4P7JL5L.js} +19 -14
  67. package/dist/{outline-QC33XLCK.js → outline-VCTQ5V2X.js} +18 -20
  68. package/dist/{paddle-HDZG35Y7.js → paddle-AZOAKBJS.js} +17 -15
  69. package/dist/{perplexity-M7LOMJWA.js → perplexity-OMRLGVAT.js} +19 -23
  70. package/dist/{pinecone-Y7YCJRZM.js → pinecone-DI62W3ZX.js} +19 -24
  71. package/dist/{pipedrive-FLJA62UX.js → pipedrive-CW7HONYW.js} +22 -23
  72. package/dist/{polar-AE55Q425.js → polar-5DRGTXNR.js} +19 -17
  73. package/dist/{posthog-IAY5D3YW.js → posthog-3DTHFCKE.js} +29 -24
  74. package/dist/{postmark-NMKAXDXZ.js → postmark-ME2V2XXI.js} +19 -17
  75. package/dist/{prerender-CDJM7I7N.js → prerender-5EAY7GDM.js} +4 -4
  76. package/dist/{pubmed-N437ZJOR.js → pubmed-GRQUBGVA.js} +3 -3
  77. package/dist/{railway-NBWYXCUM.js → railway-FTM75TMX.js} +3 -3
  78. package/dist/{readwise-QRO3UC3R.js → readwise-IJQGV6IQ.js} +16 -15
  79. package/dist/{render-NEW7SROG.js → render-TMSPHRTY.js} +21 -20
  80. package/dist/{replicate-73YQLRTY.js → replicate-RJCMDB7H.js} +20 -21
  81. package/dist/{resend-R5BAZFHZ.js → resend-YYN22NIL.js} +15 -11
  82. package/dist/{rootly-5BLALPCS.js → rootly-7RXE4K7L.js} +19 -18
  83. package/dist/{scrapfly-EHFLNNUZ.js → scrapfly-ZJJ6XM4Q.js} +4 -4
  84. package/dist/{scrapingbee-UXLYS72S.js → scrapingbee-QNGEOD6D.js} +4 -4
  85. package/dist/{screenshot_fyi-KC3NLTJ6.js → screenshot_fyi-SPZAABVD.js} +4 -4
  86. package/dist/{semantic_scholar-SA5OIUWA.js → semantic_scholar-SDPVGDDI.js} +21 -20
  87. package/dist/{sentry-BAE3XLJN.js → sentry-SJ5NN4C4.js} +22 -19
  88. package/dist/{shodan-FJR6MKKW.js → shodan-YMGOY7KW.js} +4 -4
  89. package/dist/{shopify-7OA6SLN5.js → shopify-SU5ABP54.js} +23 -19
  90. package/dist/{stripe-MUWDZGGF.js → stripe-JAC425KE.js} +3 -3
  91. package/dist/{supabase-SWWGNWYR.js → supabase-GQ2OFVIL.js} +18 -17
  92. package/dist/{tavily-XQNJ5EDI.js → tavily-Y7MDA5CI.js} +20 -20
  93. package/dist/{telegram-RR6JPZOG.js → telegram-OIDT3ZLH.js} +4 -4
  94. package/dist/{telnyx-7PKXOWSO.js → telnyx-4JGMC3K7.js} +19 -19
  95. package/dist/{todoist-63X5IUJE.js → todoist-O7S2OUGX.js} +18 -17
  96. package/dist/{trello-MOG63DAI.js → trello-3LDE4TAQ.js} +4 -4
  97. package/dist/{turso-ENWTSHDL.js → turso-MUQ44KCA.js} +23 -30
  98. package/dist/{twilio-FDXUN7VX.js → twilio-VYF3HUU6.js} +3 -3
  99. package/dist/{umami-TM7PROWF.js → umami-SVQIK26J.js} +23 -28
  100. package/dist/{unsplash-NWXLKSOW.js → unsplash-333XYDCJ.js} +19 -18
  101. package/dist/{upstash_redis-CUTQ5L2N.js → upstash_redis-IUM2HDLU.js} +17 -13
  102. package/dist/{uptimerobot-NNO32M3I.js → uptimerobot-7ZRU2NJV.js} +3 -3
  103. package/dist/{v2ex-24KMSWS7.js → v2ex-AVSJCQPS.js} +35 -18
  104. package/dist/{vercel-B45LPF6I.js → vercel-J7RGXNSA.js} +21 -18
  105. package/dist/{wolfram_alpha_api-DKJWVR6G.js → wolfram_alpha_api-6CRVUZOJ.js} +4 -4
  106. package/dist/{wordpress-XYFSDZXY.js → wordpress-THOJLPKA.js} +21 -17
  107. package/dist/{workos-BEM7EPHM.js → workos-ENTGRWF2.js} +26 -27
  108. package/dist/{zhihu-CFHZ4NC7.js → zhihu-W2BXICTX.js} +21 -21
  109. package/package.json +5 -5
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,20 +9,18 @@ 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-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-MZCIPUNQ.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/mem0/api.ts
22
22
  var SERVICE = "mem0";
23
23
  var API_BASE = "https://api.mem0.ai";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  function requireText(value, field) {
26
25
  const result = trimmedText(value);
27
26
  if (result === void 0) throw new TBError("invalid_argument", `${field} \u662F\u5FC5\u586B\u7684`);
@@ -41,19 +40,20 @@ function errorMessage(value, status) {
41
40
  if (typeof payload.error === "string" && payload.error !== "") return payload.error;
42
41
  return `Mem0 \u8FD4\u56DE HTTP ${status}`;
43
42
  }
43
+ var http = createAuthedClient({
44
+ baseUrl: `${API_BASE}/`,
45
+ service: SERVICE,
46
+ auth: { kind: "token" },
47
+ headers: { accept: "application/json" },
48
+ mapError: ({ data, status }) => upstreamError(status, errorMessage(data, status))
49
+ });
44
50
  function execute(ctx, input) {
45
- return http.request({
51
+ return http.request(ctx, {
46
52
  path: input.path,
47
53
  method: input.method ?? "GET",
48
54
  query: Object.entries(input.query ?? {}),
49
- headers: {
50
- accept: "application/json",
51
- // Token 而非 Bearer —— Mem0 用的是 DRF 的 TokenAuthentication。
52
- authorization: `Token ${requireApiKey(ctx, SERVICE)}`
53
- },
54
55
  ...input.body === void 0 ? {} : { json: input.body },
55
- invalidJson: "text",
56
- mapError: ({ data, status }) => upstreamError(status, errorMessage(data, status))
56
+ invalidJson: "text"
57
57
  });
58
58
  }
59
59
  async function request(ctx, input) {
@@ -3,8 +3,9 @@ import {
3
3
  readBoundedResponseBytes
4
4
  } from "./chunk-LMLX3DJF.js";
5
5
  import {
6
- createProviderHttpClient
7
- } from "./chunk-6X55ALDX.js";
6
+ createAuthedClient
7
+ } from "./chunk-JEWFX6Z6.js";
8
+ import "./chunk-Q74GLIDK.js";
8
9
  import {
9
10
  asJsonObject,
10
11
  compactDefined,
@@ -14,22 +15,31 @@ import {
14
15
  createProviderPlugin,
15
16
  requireApiKey,
16
17
  upstreamError
17
- } from "./chunk-6ANLYNFB.js";
18
+ } from "./chunk-QR4LK3HF.js";
18
19
  import {
19
20
  assertPublicHttpUrl,
20
21
  guardedFetch
21
- } from "./chunk-3WL6EXYX.js";
22
+ } from "./chunk-ZTTN6AJG.js";
22
23
  import {
23
24
  TBError,
24
25
  external_exports
25
- } from "./chunk-WIGQCP6O.js";
26
+ } from "./chunk-MZCIPUNQ.js";
26
27
  import "./chunk-U67V476Y.js";
27
28
 
28
29
  // ../plugins/src/memos/api.ts
29
30
  var SERVICE = "memos";
30
31
  var API_SUFFIX = "/api/v1";
31
32
  var ATTACHMENT_MAX_BYTES = 20 * 1024 * 1024;
32
- var http = createProviderHttpClient({ service: SERVICE });
33
+ var http = createAuthedClient({
34
+ service: SERVICE,
35
+ auth: { kind: "bearer" },
36
+ headers: { accept: "application/json" },
37
+ // Memos 的错误消息就一个 `message` 键(gRPC-gateway 的形状);非 JSON 体则是整段文本。
38
+ errorMessage: {
39
+ keys: ["message"],
40
+ fallback: () => "Memos request failed"
41
+ }
42
+ });
33
43
  var UPDATE_MASKS = [
34
44
  ["content", "content"],
35
45
  ["visibility", "visibility"],
@@ -84,7 +94,8 @@ function resolveBaseUrl(ctx) {
84
94
  return normalized.endsWith(API_SUFFIX) ? normalized : `${normalized}${API_SUFFIX}`;
85
95
  }
86
96
  function resolveTarget(ctx) {
87
- return { apiKey: requireApiKey(ctx, SERVICE), baseUrl: resolveBaseUrl(ctx) };
97
+ requireApiKey(ctx, SERVICE);
98
+ return resolveBaseUrl(ctx);
88
99
  }
89
100
  function resourcePath(name, collection) {
90
101
  const segments = name.split("/");
@@ -94,21 +105,14 @@ function resourcePath(name, collection) {
94
105
  }
95
106
  return `/${collection}/${encodeURIComponent(id)}`;
96
107
  }
97
- function errorMessage(payload) {
98
- const direct = trimmedText(payload);
99
- if (direct !== void 0) return direct;
100
- return trimmedText(asJsonObject(payload)?.message) ?? "Memos request failed";
101
- }
102
- async function request(target, input) {
103
- const result = await http.request({
104
- baseUrl: `${target.baseUrl}/`,
108
+ async function request(ctx, input) {
109
+ const result = await http.request(ctx, {
110
+ baseUrl: `${resolveTarget(ctx)}/`,
105
111
  path: input.path,
106
112
  method: input.method ?? "GET",
107
113
  query: Object.entries(input.query ?? {}),
108
- headers: { accept: "application/json", authorization: `Bearer ${target.apiKey}` },
109
114
  ...input.body === void 0 ? {} : { json: input.body },
110
115
  invalidJsonMessage: "Memos returned invalid JSON",
111
- mapError: ({ data, status }) => upstreamError(status, errorMessage(data)),
112
116
  mapTransportError: ({ message }) => upstreamError(
113
117
  502,
114
118
  `Memos ${input.path} request failed: ${message ?? "unknown network error"}`
@@ -138,7 +142,7 @@ async function downloadAttachment(fileUrl, declaredType) {
138
142
  return { bytes, mimeType: declaredType ?? responseType ?? "application/octet-stream" };
139
143
  }
140
144
  async function createMemo(input, ctx) {
141
- const payload = await request(resolveTarget(ctx), {
145
+ const payload = await request(ctx, {
142
146
  method: "POST",
143
147
  path: "/memos",
144
148
  // memoId 是**query** 参数而不是 body 字段(Memos 的 AIP 风格:资源 id 走 query)。
@@ -154,7 +158,7 @@ async function createMemo(input, ctx) {
154
158
  return { memo: requireResponseObject(payload, "create memo") };
155
159
  }
156
160
  async function listMemos(input, ctx) {
157
- const payload = requireResponseObject(await request(resolveTarget(ctx), {
161
+ const payload = requireResponseObject(await request(ctx, {
158
162
  path: "/memos",
159
163
  query: compactDefined({
160
164
  pageSize: input.pageSize,
@@ -173,7 +177,7 @@ async function listMemos(input, ctx) {
173
177
  }
174
178
  async function getMemo(input, ctx) {
175
179
  const path = resourcePath(requireText(input.name, "name"), "memos");
176
- const payload = await request(resolveTarget(ctx), { path });
180
+ const payload = await request(ctx, { path });
177
181
  return { memo: requireResponseObject(payload, "get memo") };
178
182
  }
179
183
  async function updateMemo(input, ctx) {
@@ -182,7 +186,7 @@ async function updateMemo(input, ctx) {
182
186
  if (updateMask.length === 0) {
183
187
  throw new TBError("invalid_argument", "Provide at least one memo field to update.");
184
188
  }
185
- const payload = await request(resolveTarget(ctx), {
189
+ const payload = await request(ctx, {
186
190
  method: "PATCH",
187
191
  path: resourcePath(name, "memos"),
188
192
  query: { updateMask: updateMask.join(",") },
@@ -200,7 +204,7 @@ async function updateMemo(input, ctx) {
200
204
  }
201
205
  async function deleteMemo(input, ctx) {
202
206
  const name = requireText(input.name, "name");
203
- await request(resolveTarget(ctx), {
207
+ await request(ctx, {
204
208
  method: "DELETE",
205
209
  path: resourcePath(name, "memos"),
206
210
  query: compactDefined({ force: input.force })
@@ -208,9 +212,9 @@ async function deleteMemo(input, ctx) {
208
212
  return { deleted: true, name };
209
213
  }
210
214
  async function uploadAttachment(input, ctx) {
211
- const target = resolveTarget(ctx);
215
+ resolveTarget(ctx);
212
216
  const source = await downloadAttachment(requireText(input.fileUrl, "fileUrl"), trimmedText(input.type));
213
- const payload = await request(target, {
217
+ const payload = await request(ctx, {
214
218
  method: "POST",
215
219
  path: "/attachments",
216
220
  query: compactDefined({ attachmentId: trimmedText(input.attachmentId) }),
@@ -224,7 +228,7 @@ async function uploadAttachment(input, ctx) {
224
228
  return { attachment: requireResponseObject(payload, "upload attachment") };
225
229
  }
226
230
  async function listAttachments(input, ctx) {
227
- const payload = requireResponseObject(await request(resolveTarget(ctx), {
231
+ const payload = requireResponseObject(await request(ctx, {
228
232
  path: "/attachments",
229
233
  query: compactDefined({
230
234
  pageSize: input.pageSize,
@@ -240,17 +244,17 @@ async function listAttachments(input, ctx) {
240
244
  }
241
245
  async function getAttachment(input, ctx) {
242
246
  const path = resourcePath(requireText(input.name, "name"), "attachments");
243
- const payload = await request(resolveTarget(ctx), { path });
247
+ const payload = await request(ctx, { path });
244
248
  return { attachment: requireResponseObject(payload, "get attachment") };
245
249
  }
246
250
  async function deleteAttachment(input, ctx) {
247
251
  const name = requireText(input.name, "name");
248
- await request(resolveTarget(ctx), { method: "DELETE", path: resourcePath(name, "attachments") });
252
+ await request(ctx, { method: "DELETE", path: resourcePath(name, "attachments") });
249
253
  return { deleted: true, name };
250
254
  }
251
255
  async function listMemoAttachments(input, ctx) {
252
256
  const name = requireText(input.name, "name");
253
- const payload = requireResponseObject(await request(resolveTarget(ctx), {
257
+ const payload = requireResponseObject(await request(ctx, {
254
258
  path: `${resourcePath(name, "memos")}/attachments`,
255
259
  query: compactDefined({ pageSize: input.pageSize, pageToken: trimmedText(input.pageToken) })
256
260
  }), "list memo attachments");
@@ -263,7 +267,7 @@ async function setMemoAttachments(input, ctx) {
263
267
  const name = requireText(input.name, "name");
264
268
  const attachmentNames = input.attachmentNames.map((item) => requireText(item, "attachmentNames"));
265
269
  for (const attachmentName of attachmentNames) resourcePath(attachmentName, "attachments");
266
- await request(resolveTarget(ctx), {
270
+ await request(ctx, {
267
271
  method: "PATCH",
268
272
  path: `${resourcePath(name, "memos")}/attachments`,
269
273
  body: { name, attachments: attachmentNames.map((attachmentName) => ({ name: attachmentName })) }
@@ -271,11 +275,11 @@ async function setMemoAttachments(input, ctx) {
271
275
  return { updated: true, name, attachmentNames };
272
276
  }
273
277
  async function getCurrentUser(_input, ctx) {
274
- const payload = requireResponseObject(await request(resolveTarget(ctx), { path: "/auth/me" }), "get current user");
278
+ const payload = requireResponseObject(await request(ctx, { path: "/auth/me" }), "get current user");
275
279
  return { user: requireResponseObject(payload.user, "get current user") };
276
280
  }
277
281
  async function listUsers(input, ctx) {
278
- const payload = requireResponseObject(await request(resolveTarget(ctx), {
282
+ const payload = requireResponseObject(await request(ctx, {
279
283
  path: "/users",
280
284
  query: compactDefined({
281
285
  pageSize: input.pageSize,
@@ -291,7 +295,7 @@ async function listUsers(input, ctx) {
291
295
  }
292
296
  async function getUser(input, ctx) {
293
297
  const path = resourcePath(requireText(input.name, "name"), "users");
294
- const payload = await request(resolveTarget(ctx), {
298
+ const payload = await request(ctx, {
295
299
  path,
296
300
  query: compactDefined({ readMask: trimmedText(input.readMask) })
297
301
  });
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  trimmedText
@@ -9,21 +10,20 @@ import {
9
10
  createProviderPlugin,
10
11
  requireApiKey,
11
12
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
+ } from "./chunk-QR4LK3HF.js";
13
14
  import {
14
15
  assertPublicHttpUrl
15
- } from "./chunk-3WL6EXYX.js";
16
+ } from "./chunk-ZTTN6AJG.js";
16
17
  import {
17
18
  TBError,
18
19
  external_exports
19
- } from "./chunk-WIGQCP6O.js";
20
+ } from "./chunk-MZCIPUNQ.js";
20
21
  import "./chunk-U67V476Y.js";
21
22
 
22
23
  // ../plugins/src/metabase/api.ts
23
24
  var SERVICE = "metabase";
24
25
  var API_PATH_PREFIX = "/api";
25
26
  var CURRENT_USER_PATH = "/user/current";
26
- var http = createProviderHttpClient({ service: SERVICE });
27
27
  function configError(message) {
28
28
  return new TBError("invalid_argument", `${SERVICE} \u7684 ${message}`);
29
29
  }
@@ -65,23 +65,27 @@ function errorMessage(payload, status) {
65
65
  function errorPayload(data, bodyKind) {
66
66
  return bodyKind === "invalid-json" ? { message: data } : data;
67
67
  }
68
+ var http = createAuthedClient({
69
+ service: SERVICE,
70
+ auth: { kind: "header", name: "x-api-key" },
71
+ headers: { accept: "application/json" },
72
+ mapError: ({ bodyKind, data, status }) => upstreamError(
73
+ status,
74
+ errorMessage(errorPayload(data, bodyKind), status)
75
+ ),
76
+ mapTransportError: ({ message }) => upstreamError(
77
+ 502,
78
+ `Metabase \u8BF7\u6C42\u5931\u8D25:${message ?? "\u672A\u77E5\u9519\u8BEF"}`
79
+ )
80
+ });
68
81
  async function request(ctx, path, query) {
69
- const apiKey = requireApiKey(ctx, SERVICE);
70
- const result = await http.request({
82
+ requireApiKey(ctx, SERVICE);
83
+ const result = await http.request(ctx, {
71
84
  baseUrl: `${resolveApiBase(ctx)}/`,
72
85
  path,
73
86
  // `models` 是多选,数组由薄层展开成重复同名参数。
74
87
  query: Object.entries(query ?? {}),
75
- headers: { "accept": "application/json", "x-api-key": apiKey },
76
- invalidJsonMessage: "Metabase \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
77
- mapError: ({ bodyKind, data, status }) => upstreamError(
78
- status,
79
- errorMessage(errorPayload(data, bodyKind), status)
80
- ),
81
- mapTransportError: ({ message }) => upstreamError(
82
- 502,
83
- `Metabase \u8BF7\u6C42\u5931\u8D25:${message ?? "\u672A\u77E5\u9519\u8BEF"}`
84
- )
88
+ invalidJsonMessage: "Metabase \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
85
89
  });
86
90
  return result.data === void 0 ? null : result.data;
87
91
  }
@@ -2,8 +2,9 @@ import {
2
2
  readBoundedResponseBytes
3
3
  } from "./chunk-LMLX3DJF.js";
4
4
  import {
5
- createProviderHttpClient
6
- } from "./chunk-6X55ALDX.js";
5
+ createAuthedClient
6
+ } from "./chunk-JEWFX6Z6.js";
7
+ import "./chunk-Q74GLIDK.js";
7
8
  import {
8
9
  asJsonObject
9
10
  } from "./chunk-JXHMDBAY.js";
@@ -11,15 +12,15 @@ import {
11
12
  createProviderPlugin,
12
13
  requireApiKey,
13
14
  upstreamError
14
- } from "./chunk-6ANLYNFB.js";
15
+ } from "./chunk-QR4LK3HF.js";
15
16
  import {
16
17
  assertPublicHttpUrl,
17
18
  guardedFetch
18
- } from "./chunk-3WL6EXYX.js";
19
+ } from "./chunk-ZTTN6AJG.js";
19
20
  import {
20
21
  TBError,
21
22
  external_exports
22
- } from "./chunk-WIGQCP6O.js";
23
+ } from "./chunk-MZCIPUNQ.js";
23
24
  import "./chunk-U67V476Y.js";
24
25
 
25
26
  // ../plugins/src/mistral_ai/schema.ts
@@ -814,7 +815,6 @@ var mistralAiActions = {
814
815
  var SERVICE = "mistral_ai";
815
816
  var API_BASE = "https://api.mistral.ai";
816
817
  var MAX_REMOTE_UPLOAD_BYTES = 100 * 1024 * 1024;
817
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
818
818
  var SPECS = {
819
819
  list_models: { method: "GET", path: "/v1/models" },
820
820
  get_model: { method: "GET", path: "/v1/models/{model_id}", pathKeys: ["model_id"] },
@@ -946,6 +946,18 @@ var SPECS = {
946
946
  function text(value) {
947
947
  return typeof value === "string" && value !== "" ? value : void 0;
948
948
  }
949
+ var http = createAuthedClient({
950
+ baseUrl: API_BASE,
951
+ service: SERVICE,
952
+ auth: { kind: "bearer" },
953
+ headers: { "content-type": "application/json" },
954
+ mapError: ({ data, rawText, status }) => {
955
+ const payload = asJsonObject(data);
956
+ const fallback = `mistral_ai request failed with ${status}`;
957
+ const message = text(payload?.detail) ?? text(payload?.message) ?? text(payload?.error) ?? text(rawText) ?? fallback;
958
+ return upstreamError(status === 422 ? 400 : status || 502, message);
959
+ }
960
+ });
949
961
  function compactJson(value) {
950
962
  if (Array.isArray(value)) return value.map((item) => compactJson(item));
951
963
  if (value === null || typeof value !== "object") return value;
@@ -1075,27 +1087,18 @@ async function resolveUpload(remaining) {
1075
1087
  mimeType: mimeType ?? response.headers.get("content-type") ?? "application/octet-stream"
1076
1088
  };
1077
1089
  }
1078
- function authHeaders(ctx, json) {
1079
- const headers = { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` };
1080
- if (json) headers["content-type"] = "application/json";
1081
- return headers;
1090
+ function authHeaders(ctx) {
1091
+ return { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` };
1082
1092
  }
1083
1093
  async function executeJson(spec, input, ctx) {
1084
1094
  const { url, remaining } = buildUrl(spec, input);
1085
1095
  const sendsBody = spec.method === "POST" || spec.method === "PUT" || spec.method === "PATCH" || spec.method === "DELETE" && spec.bodyOnDelete === true;
1086
- const result = await http.request({
1096
+ const result = await http.request(ctx, {
1087
1097
  path: url,
1088
1098
  method: spec.method,
1089
- headers: authHeaders(ctx, true),
1090
1099
  ...sendsBody ? { json: compactJson(remaining) } : {},
1091
1100
  responseType: "auto",
1092
- invalidJsonMessage: "mistral_ai returned malformed JSON",
1093
- mapError: ({ data, rawText, status }) => {
1094
- const payload = asJsonObject(data);
1095
- const fallback = `mistral_ai request failed with ${status}`;
1096
- const message = text(payload?.detail) ?? text(payload?.message) ?? text(payload?.error) ?? text(rawText) ?? fallback;
1097
- return upstreamError(status === 422 ? 400 : status || 502, message);
1098
- }
1101
+ invalidJsonMessage: "mistral_ai returned malformed JSON"
1099
1102
  });
1100
1103
  if (result.status === 204) return { deleted: true };
1101
1104
  return result.bodyKind === "empty" ? "" : result.data;
@@ -1110,7 +1113,7 @@ async function executeMultipart(spec, input, ctx) {
1110
1113
  }
1111
1114
  const response = await guardedFetch(url, {
1112
1115
  method: spec.method,
1113
- headers: authHeaders(ctx, false),
1116
+ headers: authHeaders(ctx),
1114
1117
  body: form
1115
1118
  });
1116
1119
  await assertOk(response);
@@ -1148,7 +1151,7 @@ async function executeAudioTranscription(spec, input, ctx) {
1148
1151
  }
1149
1152
  const response = await guardedFetch(url, {
1150
1153
  method: spec.method,
1151
- headers: authHeaders(ctx, false),
1154
+ headers: authHeaders(ctx),
1152
1155
  body: form
1153
1156
  });
1154
1157
  await assertOk(response);
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,45 +9,48 @@ 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-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-MZCIPUNQ.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/mother_duck/api.ts
22
22
  var SERVICE = "mother_duck";
23
23
  var API_BASE = "https://api.motherduck.com";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  function errorMessage(payload) {
26
25
  const body = asJsonObject(payload);
27
26
  if (body === void 0) return void 0;
28
27
  return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.code);
29
28
  }
29
+ var http = createAuthedClient({
30
+ baseUrl: `${API_BASE}/`,
31
+ service: SERVICE,
32
+ auth: { kind: "bearer" },
33
+ headers: { accept: "application/json" },
34
+ // invalid-json 错误体按**原文不 trim**透出 —— 标准 errorMessage 的 trim 语义接不住,整段覆写。
35
+ mapError: ({ bodyKind, data, status }) => upstreamError(
36
+ status,
37
+ bodyKind === "invalid-json" && typeof data === "string" ? data : errorMessage(data) ?? `MotherDuck \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
38
+ ),
39
+ mapTransportError: ({ message }) => upstreamError(
40
+ 502,
41
+ message === void 0 ? "MotherDuck \u8BF7\u6C42\u5931\u8D25" : `MotherDuck \u8BF7\u6C42\u5931\u8D25: ${message}`
42
+ )
43
+ });
30
44
  function isEmpty(payload) {
31
45
  const object = asJsonObject(payload);
32
46
  return object !== void 0 && Object.keys(object).length === 0;
33
47
  }
34
48
  async function request(ctx, path, input = {}) {
35
- const apiKey = requireApiKey(ctx, SERVICE);
36
- const result = await http.request({
49
+ const result = await http.request(ctx, {
37
50
  path,
38
51
  method: input.method ?? "GET",
39
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
40
52
  ...input.body === void 0 ? {} : { json: input.body },
41
- invalidJson: "text",
42
- mapError: ({ bodyKind, data, status }) => upstreamError(
43
- status,
44
- bodyKind === "invalid-json" && typeof data === "string" ? data : errorMessage(data) ?? `MotherDuck \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
45
- ),
46
- mapTransportError: ({ message }) => upstreamError(
47
- 502,
48
- message === void 0 ? "MotherDuck \u8BF7\u6C42\u5931\u8D25" : `MotherDuck \u8BF7\u6C42\u5931\u8D25: ${message}`
49
- )
53
+ invalidJson: "text"
50
54
  });
51
55
  const payload = result.bodyKind === "empty" ? {} : result.bodyKind === "invalid-json" && typeof result.data === "string" ? { message: result.data } : result.data;
52
56
  if (input.allowEmpty === true && isEmpty(payload)) return {};
@@ -1,40 +1,35 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
- messageFrom,
7
7
  trimmedText
8
8
  } from "./chunk-JXHMDBAY.js";
9
9
  import {
10
10
  createProviderPlugin,
11
- requireApiKey,
12
11
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
- import "./chunk-3WL6EXYX.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
15
14
  import {
16
15
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
16
+ } from "./chunk-MZCIPUNQ.js";
18
17
  import "./chunk-U67V476Y.js";
19
18
 
20
19
  // ../plugins/src/ngrok/api.ts
21
20
  var SERVICE = "ngrok";
22
- var http = createProviderHttpClient({ baseUrl: "https://api.ngrok.com/", service: SERVICE });
21
+ var http = createAuthedClient({
22
+ baseUrl: "https://api.ngrok.com/",
23
+ service: SERVICE,
24
+ auth: { kind: "bearer" },
25
+ headers: { "accept": "application/json", "ngrok-version": "2" },
26
+ errorMessage: {
27
+ keys: ["msg", "message", "error"],
28
+ fallback: (status) => `ngrok request failed with ${status}`
29
+ }
30
+ });
23
31
  async function request(ctx, path, query) {
24
- const { data } = await http.request({
25
- path,
26
- query,
27
- headers: {
28
- "accept": "application/json",
29
- "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
30
- "ngrok-version": "2"
31
- },
32
- invalidJson: "text",
33
- mapError: ({ data: payload, status }) => upstreamError(
34
- status,
35
- messageFrom(payload, ["msg", "message", "error"], `ngrok request failed with ${status}`)
36
- )
37
- });
32
+ const { data } = await http.request(ctx, { path, query, invalidJson: "text" });
38
33
  const result = asJsonObject(data);
39
34
  if (result === void 0) throw upstreamError(502, "ngrok response was not a JSON object");
40
35
  return result;
@@ -2,7 +2,7 @@ import {
2
2
  TBError,
3
3
  createPlugin,
4
4
  external_exports
5
- } from "./chunk-WIGQCP6O.js";
5
+ } from "./chunk-MZCIPUNQ.js";
6
6
  import "./chunk-U67V476Y.js";
7
7
 
8
8
  // ../plugins/src/notes/index.ts
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  booleanValue,
@@ -8,21 +9,19 @@ 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-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-MZCIPUNQ.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/notion/api.ts
22
22
  var SERVICE = "notion";
23
23
  var API_BASE = "https://api.notion.com/v1";
24
24
  var NOTION_VERSION = "2026-03-11";
25
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
26
25
  function nonEmpty(value) {
27
26
  return typeof value === "string" && value.length > 0 ? value : void 0;
28
27
  }
@@ -40,23 +39,27 @@ function errorMessage(status, payload, bodyKind) {
40
39
  const parsed = asJsonObject(payload);
41
40
  return nonEmpty(parsed?.message) ?? nonEmpty(parsed?.error) ?? JSON.stringify(payload) ?? `notion request failed with ${status}`;
42
41
  }
42
+ var http = createAuthedClient({
43
+ baseUrl: `${API_BASE}/`,
44
+ service: SERVICE,
45
+ auth: { kind: "bearer" },
46
+ headers: { "notion-version": NOTION_VERSION },
47
+ // 提取**不 trim**(nonEmpty)且兜底走 JSON.stringify —— 与标准 errorMessage 的 trim 语义
48
+ // 不同,整段覆写。
49
+ mapError: ({ bodyKind, data: payload, status }) => upstreamError(
50
+ status,
51
+ errorMessage(status, payload, bodyKind)
52
+ )
53
+ });
43
54
  async function request(ctx, input) {
44
55
  const hasBody = input.body !== void 0;
45
- const { data } = await http.request({
56
+ const { data } = await http.request(ctx, {
46
57
  path: input.path,
47
58
  method: input.method ?? "GET",
48
59
  // filter_properties[] 靠**重复同名参数**表达;空数组在调用处就丢掉了。
49
60
  query: Object.entries(input.query ?? {}),
50
- headers: {
51
- "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
52
- "notion-version": NOTION_VERSION
53
- },
54
61
  ...hasBody ? { json: input.body } : {},
55
- invalidJsonMessage: "Notion \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
56
- mapError: ({ bodyKind, data: payload, status }) => upstreamError(
57
- status,
58
- errorMessage(status, payload, bodyKind)
59
- )
62
+ invalidJsonMessage: "Notion \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
60
63
  });
61
64
  if (data === void 0) return {};
62
65
  const result = asJsonObject(data);