@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,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-Q74GLIDK.js";
4
4
  import {
5
5
  asJsonObject
6
6
  } from "./chunk-JXHMDBAY.js";
@@ -8,12 +8,12 @@ import {
8
8
  createProviderPlugin,
9
9
  requireApiKey,
10
10
  upstreamError
11
- } from "./chunk-6ANLYNFB.js";
12
- import "./chunk-3WL6EXYX.js";
11
+ } from "./chunk-QR4LK3HF.js";
12
+ import "./chunk-ZTTN6AJG.js";
13
13
  import {
14
14
  TBError,
15
15
  external_exports
16
- } from "./chunk-WIGQCP6O.js";
16
+ } from "./chunk-MZCIPUNQ.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/open_exchange_rates/api.ts
@@ -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
  trimmedText
10
11
  } from "./chunk-JXHMDBAY.js";
@@ -12,15 +13,15 @@ import {
12
13
  createProviderPlugin,
13
14
  requireApiKey,
14
15
  upstreamError
15
- } from "./chunk-6ANLYNFB.js";
16
+ } from "./chunk-QR4LK3HF.js";
16
17
  import {
17
18
  assertPublicHttpUrl,
18
19
  guardedFetch
19
- } from "./chunk-3WL6EXYX.js";
20
+ } from "./chunk-ZTTN6AJG.js";
20
21
  import {
21
22
  TBError,
22
23
  external_exports
23
- } from "./chunk-WIGQCP6O.js";
24
+ } from "./chunk-MZCIPUNQ.js";
24
25
  import "./chunk-U67V476Y.js";
25
26
 
26
27
  // ../plugins/src/openai/api.ts
@@ -28,7 +29,6 @@ var SERVICE = "openai";
28
29
  var API_BASE = "https://api.openai.com/v1";
29
30
  var AUDIO_SOURCE_MAX_BYTES = 25 * 1024 * 1024;
30
31
  var AUDIO_SOURCE_FETCH_TIMEOUT_MS = 3e4;
31
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
32
32
  function normalizedContentType(value, fallback) {
33
33
  if (value === null || value === "") return fallback;
34
34
  return value.split(";", 1)[0]?.trim() || fallback;
@@ -103,22 +103,28 @@ function errorMessageFromContext(context) {
103
103
  if (typeof message === "string" && message !== "") return message;
104
104
  return context.rawText?.trim() || fallback;
105
105
  }
106
+ var http = createAuthedClient({
107
+ baseUrl: `${API_BASE}/`,
108
+ service: SERVICE,
109
+ auth: { kind: "bearer" },
110
+ headers: { accept: "application/json" },
111
+ // 提取不 trim 且兜底回显 rawText 原文,标准键序提取表达不了,整段覆写。
112
+ mapError: (context) => upstreamError(context.status, errorMessageFromContext(context)),
113
+ mapTransportError: ({ message }) => upstreamError(
114
+ 502,
115
+ `openai request failed before receiving response: ${message ?? "unknown network error"}`
116
+ )
117
+ });
106
118
  async function jsonRequest(ctx, input) {
107
119
  if (input.body instanceof FormData) {
108
120
  throw new TBError("internal", "openai jsonRequest cannot send multipart data");
109
121
  }
110
- const method = input.method ?? "GET";
111
- const result = await http.request({
122
+ const result = await http.request(ctx, {
112
123
  path: input.path,
113
- method,
114
- headers: input.headers ?? baseHeaders(requireApiKey(ctx, SERVICE)),
124
+ method: input.method ?? "GET",
125
+ headers: input.headers,
115
126
  ...input.body === void 0 ? {} : { json: input.body },
116
- invalidJsonMessage: "OpenAI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
117
- mapError: (context) => upstreamError(context.status, errorMessageFromContext(context)),
118
- mapTransportError: ({ message }) => upstreamError(
119
- 502,
120
- `openai request failed before receiving response: ${message ?? "unknown network error"}`
121
- )
127
+ invalidJsonMessage: "OpenAI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
122
128
  });
123
129
  return result.data;
124
130
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-Q74GLIDK.js";
4
4
  import {
5
5
  asJsonObject,
6
6
  booleanValue,
@@ -12,14 +12,14 @@ import {
12
12
  createProviderPlugin,
13
13
  requireApiKey,
14
14
  upstreamError
15
- } from "./chunk-6ANLYNFB.js";
15
+ } from "./chunk-QR4LK3HF.js";
16
16
  import {
17
17
  assertPublicHttpUrl
18
- } from "./chunk-3WL6EXYX.js";
18
+ } from "./chunk-ZTTN6AJG.js";
19
19
  import {
20
20
  TBError,
21
21
  external_exports
22
- } from "./chunk-WIGQCP6O.js";
22
+ } from "./chunk-MZCIPUNQ.js";
23
23
  import "./chunk-U67V476Y.js";
24
24
 
25
25
  // ../plugins/src/opengraph_io/api.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
  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/openrouter/api.ts
22
22
  var SERVICE = "openrouter";
23
23
  var API_BASE = "https://openrouter.ai/api/v1";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  var HEADER_INPUT_KEYS = ["httpReferer", "xTitle"];
26
25
  function requireRecord(value, label) {
27
26
  const result = asJsonObject(value);
@@ -55,25 +54,31 @@ function errorMessage(payload) {
55
54
  if (body === void 0) return void 0;
56
55
  return trimmedText(asJsonObject(body.error)?.message) ?? trimmedText(body.message);
57
56
  }
57
+ var http = createAuthedClient({
58
+ baseUrl: `${API_BASE}/`,
59
+ service: SERVICE,
60
+ auth: { kind: "bearer" },
61
+ // 非 JSON 错误体**不回显原文**(bodyKind 门控),与标准提取的 string 取文语义不同,整段覆写。
62
+ mapError: ({ bodyKind, data, status }) => upstreamError(
63
+ status,
64
+ bodyKind === "json" ? errorMessage(data) ?? `OpenRouter \u8FD4\u56DE HTTP ${status}` : `OpenRouter \u8FD4\u56DE HTTP ${status}`
65
+ )
66
+ });
58
67
  async function request(ctx, input) {
59
68
  const hasBody = input.body !== void 0;
60
- const headers = new Headers({ authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` });
69
+ const headers = new Headers();
61
70
  const referer = trimmedText(input.headerSource?.httpReferer);
62
71
  const title = trimmedText(input.headerSource?.xTitle);
63
72
  if (referer !== void 0) headers.set("HTTP-Referer", referer);
64
73
  if (title !== void 0) headers.set("X-Title", title);
65
- const response = await http.request({
74
+ const response = await http.request(ctx, {
66
75
  method: input.method ?? "GET",
67
76
  path: input.path,
68
77
  query: Object.entries(input.query ?? {}),
69
78
  headers,
70
79
  ...hasBody ? { json: compactDefined(input.body ?? {}) } : {},
71
80
  responseType: "json",
72
- invalidJson: "text",
73
- mapError: ({ bodyKind, data, status }) => upstreamError(
74
- status,
75
- bodyKind === "json" ? errorMessage(data) ?? `OpenRouter \u8FD4\u56DE HTTP ${status}` : `OpenRouter \u8FD4\u56DE HTTP ${status}`
76
- )
81
+ invalidJson: "text"
77
82
  });
78
83
  const contentType = response.headers.get("content-type") ?? "";
79
84
  const isText = contentType.includes("xml") || contentType.includes("rss") || contentType.startsWith("text/");
@@ -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,
@@ -11,20 +12,29 @@ 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
- } from "./chunk-3WL6EXYX.js";
18
+ } from "./chunk-ZTTN6AJG.js";
18
19
  import {
19
20
  TBError,
20
21
  external_exports
21
- } from "./chunk-WIGQCP6O.js";
22
+ } from "./chunk-MZCIPUNQ.js";
22
23
  import "./chunk-U67V476Y.js";
23
24
 
24
25
  // ../plugins/src/outline/api.ts
25
26
  var SERVICE = "outline";
26
27
  var CLOUD_API_BASE = "https://app.getoutline.com/api";
27
- var http = createProviderHttpClient({ service: SERVICE });
28
+ var http = createAuthedClient({
29
+ service: SERVICE,
30
+ auth: { kind: "bearer" },
31
+ headers: { accept: "application/json" },
32
+ errorMessage: {
33
+ // Outline 的错误消息在 `message` / `error` / `status` 三处之一。
34
+ keys: ["message", "error", "status"],
35
+ fallback: (status) => `outline request failed with status ${status}`
36
+ }
37
+ });
28
38
  function nullableText(value) {
29
39
  return value === null ? null : trimmedText(value);
30
40
  }
@@ -60,26 +70,14 @@ function resolveApiBase(ctx) {
60
70
  const normalized = `${url.origin}${path}`;
61
71
  return normalized.endsWith("/api") ? normalized : `${normalized}/api`;
62
72
  }
63
- function errorMessage(status, payload) {
64
- const body = asJsonObject(payload);
65
- return trimmedText(body?.message) ?? trimmedText(body?.error) ?? trimmedText(body?.status) ?? `outline request failed with status ${status}`;
66
- }
67
- function errorPayload(data, bodyKind) {
68
- return bodyKind === "invalid-json" && typeof data === "string" ? { message: data.trim() } : data;
69
- }
70
73
  async function request(ctx, path, body = {}) {
71
- const apiKey = requireApiKey(ctx, SERVICE);
72
- const result = await http.request({
74
+ requireApiKey(ctx, SERVICE);
75
+ const result = await http.request(ctx, {
73
76
  baseUrl: `${resolveApiBase(ctx)}/`,
74
77
  path,
75
78
  method: "POST",
76
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
77
79
  json: body,
78
80
  invalidJsonMessage: "outline \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
79
- mapError: ({ bodyKind, data, status }) => upstreamError(
80
- status,
81
- errorMessage(status, errorPayload(data, bodyKind))
82
- ),
83
81
  mapTransportError: ({ message }) => upstreamError(
84
82
  502,
85
83
  `outline ${path} failed before receiving response: ${message ?? "unknown network error"}`
@@ -1,26 +1,25 @@
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
7
8
  } from "./chunk-JXHMDBAY.js";
8
9
  import {
9
10
  createProviderPlugin,
10
- requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/paddle/api.ts
21
21
  var SERVICE = "paddle";
22
22
  var API_BASE = "https://api.paddle.com";
23
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
24
23
  function pathSegment(value, field) {
25
24
  if (value === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
26
25
  return encodeURIComponent(value);
@@ -42,19 +41,22 @@ function errorMessage(payload, context) {
42
41
  const message = trimmedText(error?.detail) ?? trimmedText(error?.message) ?? trimmedText(data.message) ?? trimmedText(data.error);
43
42
  return message ?? (context.statusText || `Paddle \u8FD4\u56DE HTTP ${context.status}`);
44
43
  }
44
+ var http = createAuthedClient({
45
+ baseUrl: API_BASE,
46
+ service: SERVICE,
47
+ auth: { kind: "bearer" },
48
+ headers: { accept: "application/json" },
49
+ // string 错误体原样透出且**不 trim** —— 与标准提取的 trim 语义不同,整段覆写。
50
+ mapError: (context) => upstreamError(context.status, errorMessage(context.data, context))
51
+ });
45
52
  async function request(ctx, input) {
46
- const result = await http.request({
53
+ const result = await http.request(ctx, {
47
54
  path: input.path,
48
55
  method: input.method,
49
56
  query: [...input.searchParams ?? []],
50
- headers: {
51
- accept: "application/json",
52
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`,
53
- ...input.skipCount === true ? { "skip-count": "true" } : {}
54
- },
57
+ ...input.skipCount === true ? { headers: { "skip-count": "true" } } : {},
55
58
  ...input.body === void 0 ? {} : { json: input.body },
56
- invalidJsonMessage: "Paddle returned malformed JSON",
57
- mapError: (context) => upstreamError(context.status, errorMessage(context.data, context))
59
+ invalidJsonMessage: "Paddle returned malformed JSON"
58
60
  });
59
61
  return result.data === void 0 ? null : result.data;
60
62
  }
@@ -1,47 +1,43 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
4
- import {
5
- asJsonObject,
6
- trimmedText
7
- } from "./chunk-JXHMDBAY.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
5
+ import "./chunk-JXHMDBAY.js";
8
6
  import {
9
7
  createProviderPlugin,
10
- requireApiKey,
11
8
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
9
+ } from "./chunk-QR4LK3HF.js";
10
+ import "./chunk-ZTTN6AJG.js";
14
11
  import {
15
12
  TBError,
16
13
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
14
+ } from "./chunk-MZCIPUNQ.js";
18
15
  import "./chunk-U67V476Y.js";
19
16
 
20
17
  // ../plugins/src/perplexity/api.ts
21
18
  var SERVICE = "perplexity";
22
19
  var API_BASE = "https://api.perplexity.ai";
23
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
20
+ var http = createAuthedClient({
21
+ baseUrl: API_BASE,
22
+ service: SERVICE,
23
+ auth: { kind: "bearer" },
24
+ headers: { accept: "application/json" },
25
+ errorMessage: {
26
+ keys: ["error.message", "error.detail", "message", "detail"],
27
+ fallback: (status) => `perplexity request failed with ${status}`
28
+ }
29
+ });
24
30
  var EMBEDDING_MIN_DIMENSIONS = 128;
25
31
  var EMBEDDING_MAX_DIMENSIONS = { "pplx-embed-v1-0.6b": 1024 };
26
32
  var EMBEDDING_MAX_DIMENSIONS_FALLBACK = 2560;
27
- function errorMessage(status, payload, bodyKind) {
28
- const top = asJsonObject(payload);
29
- const nested = asJsonObject(top?.error);
30
- return trimmedText(nested?.message) ?? trimmedText(nested?.detail) ?? trimmedText(top?.message) ?? trimmedText(top?.detail) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? `perplexity request failed with ${status}`;
31
- }
32
33
  async function request(ctx, method, path, body) {
33
- const apiKey = requireApiKey(ctx, SERVICE);
34
- const { data } = await http.request({
34
+ const { data } = await http.request(ctx, {
35
35
  path,
36
36
  method,
37
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
38
37
  // 上游先过一道 `compactObject`;JSON.stringify 本来就丢 undefined 值,故不再重复一遍。
39
38
  ...method === "POST" ? { json: body ?? {} } : {},
40
39
  invalidJsonMessage: "Perplexity \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
41
- mapError: ({ bodyKind, data: payload, status }) => upstreamError(
42
- status,
43
- errorMessage(status, payload, bodyKind)
44
- ),
40
+ // 消息里带着本次的 method/path,只能逐请求给,不能挪到 client 级。
45
41
  mapTransportError: ({ message }) => upstreamError(
46
42
  502,
47
43
  `perplexity ${method} ${path} failed before receiving response: ${message ?? "unknown network error"}`
@@ -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,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/pinecone/api.ts
22
22
  var SERVICE = "pinecone";
23
23
  var CONTROL_API_BASE = "https://api.pinecone.io";
24
24
  var API_VERSION = "2026-04";
25
- var http = createProviderHttpClient({ service: SERVICE });
26
25
  function requireText(value, field) {
27
26
  const result = trimmedText(value);
28
27
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
@@ -52,14 +51,6 @@ function requireIndexHost(value) {
52
51
  parsed.hash = "";
53
52
  return parsed.origin;
54
53
  }
55
- function headers(apiKey, hasBody) {
56
- return {
57
- "accept": "application/json",
58
- "api-key": apiKey,
59
- "x-pinecone-api-version": API_VERSION,
60
- ...hasBody ? { "content-type": "application/json" } : {}
61
- };
62
- }
63
54
  function errorMessage(payload, status) {
64
55
  if (typeof payload === "string") {
65
56
  const message2 = trimmedText(payload);
@@ -69,21 +60,25 @@ function errorMessage(payload, status) {
69
60
  const message = trimmedText(fields?.message) ?? trimmedText(asJsonObject(fields?.error)?.message);
70
61
  return message ?? `Pinecone request failed with status ${status}`;
71
62
  }
63
+ var http = createAuthedClient({
64
+ service: SERVICE,
65
+ auth: { kind: "header", name: "api-key" },
66
+ // 每个请求都带 `x-pinecone-api-version`,它决定响应形状,不是可选优化项。
67
+ headers: { "accept": "application/json", "x-pinecone-api-version": API_VERSION },
68
+ mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "Pinecone returned invalid JSON") : upstreamError(status, errorMessage(data, status)),
69
+ mapTransportError: ({ message }) => upstreamError(
70
+ 502,
71
+ message === void 0 ? "Pinecone request failed" : `Pinecone request failed: ${message}`
72
+ )
73
+ });
72
74
  async function request(ctx, input) {
73
- const apiKey = requireApiKey(ctx, SERVICE);
74
- const result = await http.request({
75
+ const result = await http.request(ctx, {
75
76
  baseUrl: `${(input.baseUrl ?? CONTROL_API_BASE).replace(/\/+$/, "")}/`,
76
77
  path: input.path,
77
78
  method: input.method,
78
79
  query: Object.entries(input.query ?? {}),
79
- headers: headers(apiKey, input.body !== void 0),
80
80
  ...input.body === void 0 ? {} : { json: compactDeep(input.body) },
81
- invalidJsonMessage: "Pinecone returned invalid JSON",
82
- mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? upstreamError(502, "Pinecone returned invalid JSON") : upstreamError(status, errorMessage(data, status)),
83
- mapTransportError: ({ message }) => upstreamError(
84
- 502,
85
- message === void 0 ? "Pinecone request failed" : `Pinecone request failed: ${message}`
86
- )
81
+ invalidJsonMessage: "Pinecone returned invalid JSON"
87
82
  });
88
83
  return result.data === void 0 ? {} : result.data;
89
84
  }
@@ -1,20 +1,20 @@
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
7
8
  } from "./chunk-JXHMDBAY.js";
8
9
  import {
9
10
  createProviderPlugin,
10
- requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/pipedrive/schema.ts
@@ -260,7 +260,20 @@ var pipedriveActions = {
260
260
  // ../plugins/src/pipedrive/api.ts
261
261
  var SERVICE = "pipedrive";
262
262
  var API_BASE = "https://api.pipedrive.com";
263
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
263
+ var http = createAuthedClient({
264
+ baseUrl: `${API_BASE}/`,
265
+ service: SERVICE,
266
+ auth: { kind: "header", name: "x-api-token" },
267
+ headers: { accept: "application/json" },
268
+ errorMessage: {
269
+ keys: ["error", "error_info", "message", "statusText"],
270
+ fallback: (status, statusText) => statusText || `pipedrive \u8FD4\u56DE HTTP ${status}`
271
+ },
272
+ mapTransportError: ({ message }) => upstreamError(
273
+ 502,
274
+ message === void 0 ? "pipedrive \u8BF7\u6C42\u5931\u8D25" : `pipedrive \u8BF7\u6C42\u5931\u8D25: ${message}`
275
+ )
276
+ });
264
277
  var OPERATIONS = {
265
278
  list_persons: { method: "GET", path: "/api/v2/persons", listKey: "persons" },
266
279
  get_person: { method: "GET", path: "/api/v2/persons/{id}", idField: "personId", itemKey: "person" },
@@ -348,27 +361,13 @@ function errorMessage(payload) {
348
361
  return trimmedText(record.error) ?? trimmedText(record.error_info) ?? trimmedText(record.message) ?? trimmedText(record.statusText);
349
362
  }
350
363
  async function request(ctx, operation, input) {
351
- const apiKey = requireApiKey(ctx, SERVICE);
352
364
  const hasBody = operation.method === "POST" || operation.method === "PATCH";
353
- const headers = {
354
- "accept": "application/json",
355
- "x-api-token": apiKey
356
- };
357
- const response = await http.request({
365
+ const response = await http.request(ctx, {
358
366
  method: operation.method,
359
367
  path: buildPath(operation, input),
360
- headers,
361
368
  ...operation.method === "GET" ? { query: Object.entries(buildQuery(operation, input)) } : {},
362
369
  ...hasBody ? { json: buildBody(operation, input) } : {},
363
- invalidJson: "text",
364
- mapError: ({ data, status, statusText }) => upstreamError(
365
- status,
366
- errorMessage(data) ?? (statusText || `pipedrive \u8FD4\u56DE HTTP ${status}`)
367
- ),
368
- mapTransportError: ({ message }) => upstreamError(
369
- 502,
370
- message === void 0 ? "pipedrive \u8BF7\u6C42\u5931\u8D25" : `pipedrive \u8BF7\u6C42\u5931\u8D25: ${message}`
371
- )
370
+ invalidJson: "text"
372
371
  });
373
372
  const record = response.bodyKind === "empty" ? {} : asJsonObject(response.data);
374
373
  if (record === void 0) throw upstreamError(502, "pipedrive \u8FD4\u56DE\u7684\u54CD\u5E94\u4E0D\u662F JSON \u5BF9\u8C61");
@@ -1,26 +1,25 @@
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
7
8
  } from "./chunk-JXHMDBAY.js";
8
9
  import {
9
10
  createProviderPlugin,
10
- requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/polar/api.ts
21
21
  var SERVICE = "polar";
22
22
  var API_BASE = "https://api.polar.sh/v1";
23
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
24
23
  function requireRecord(value, label) {
25
24
  const result = asJsonObject(value);
26
25
  if (result === void 0) throw new TBError("unavailable", `Polar \u7684${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
@@ -74,20 +73,23 @@ function errorDetail(payload) {
74
73
  }
75
74
  return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.title);
76
75
  }
76
+ var http = createAuthedClient({
77
+ baseUrl: `${API_BASE}/`,
78
+ service: SERVICE,
79
+ auth: { kind: "bearer" },
80
+ headers: { accept: "application/json" },
81
+ // detail 可能是 FastAPI 校验错误数组(取 `detail[0].msg`),标准键序提取表达不了,整段覆写。
82
+ mapError: ({ data: payload, status }) => upstreamError(
83
+ status,
84
+ errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
85
+ )
86
+ });
77
87
  async function request(ctx, path, query) {
78
- const { data } = await http.request({
88
+ const { data } = await http.request(ctx, {
79
89
  path,
80
90
  method: "GET",
81
91
  query,
82
- headers: {
83
- accept: "application/json",
84
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
85
- },
86
- invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
87
- mapError: ({ data: payload, status }) => upstreamError(
88
- status,
89
- errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
90
- )
92
+ invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
91
93
  });
92
94
  return data ?? null;
93
95
  }