@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,33 @@ 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/turso/api.ts
22
22
  var SERVICE = "turso";
23
23
  var API_BASE = "https://api.turso.tech";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
24
+ var http = createAuthedClient({
25
+ baseUrl: `${API_BASE}/`,
26
+ service: SERVICE,
27
+ auth: { kind: "bearer" },
28
+ headers: { accept: "application/json" },
29
+ errorMessage: {
30
+ // Turso 的错误消息散落在五六个键里,按上游的顺序找。
31
+ keys: ["message", "error", "detail", "title", "error.message", "error.detail"],
32
+ fallback: (status) => `Turso request failed with ${status}`
33
+ },
34
+ mapTransportError: ({ message }) => upstreamError(
35
+ 502,
36
+ message === void 0 ? "Turso request failed" : `Turso request failed: ${message}`
37
+ )
38
+ });
25
39
  function requireText(value, field) {
26
40
  const result = trimmedText(value);
27
41
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required.`);
@@ -68,33 +82,12 @@ function singleResource(payload, keys) {
68
82
  }
69
83
  return normalizeResource(fields);
70
84
  }
71
- function errorMessage(payload, status) {
72
- const direct = trimmedText(payload);
73
- if (direct !== void 0) return direct;
74
- const fields = asJsonObject(payload);
75
- const nested = asJsonObject(fields?.error);
76
- const message = trimmedText(fields?.message) ?? trimmedText(fields?.error) ?? trimmedText(fields?.detail) ?? trimmedText(fields?.title) ?? trimmedText(nested?.message) ?? trimmedText(nested?.detail);
77
- return message ?? `Turso request failed with ${status}`;
78
- }
79
85
  async function request(ctx, input) {
80
- const apiKey = requireApiKey(ctx, SERVICE);
81
- const response = await http.request({
86
+ const response = await http.request(ctx, {
82
87
  method: input.method,
83
88
  path: input.path,
84
- headers: {
85
- accept: "application/json",
86
- authorization: `Bearer ${apiKey}`
87
- },
88
89
  ...input.body === void 0 ? {} : { json: input.body },
89
- invalidJson: "text",
90
- mapError: ({ bodyKind, data, status }) => upstreamError(
91
- status,
92
- errorMessage(bodyKind === "empty" ? {} : bodyKind === "json" ? data : { message: data }, status)
93
- ),
94
- mapTransportError: ({ message }) => upstreamError(
95
- 502,
96
- message === void 0 ? "Turso request failed" : `Turso request failed: ${message}`
97
- )
90
+ invalidJson: "text"
98
91
  });
99
92
  if (response.bodyKind === "empty") return {};
100
93
  return response.bodyKind === "json" ? response.data : { message: response.data };
@@ -7,14 +7,14 @@ import {
7
7
  createProviderPlugin,
8
8
  requireCredential,
9
9
  upstreamError
10
- } from "./chunk-6ANLYNFB.js";
10
+ } from "./chunk-QR4LK3HF.js";
11
11
  import {
12
12
  guardedFetch
13
- } from "./chunk-3WL6EXYX.js";
13
+ } from "./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/twilio/api.ts
@@ -1,55 +1,50 @@
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/umami/api.ts
21
21
  var SERVICE = "umami";
22
22
  var API_BASE = "https://api.umami.is";
23
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
23
+ var http = createAuthedClient({
24
+ baseUrl: `${API_BASE}/`,
25
+ service: SERVICE,
26
+ auth: { kind: "bearer" },
27
+ headers: { accept: "application/json" },
28
+ errorMessage: {
29
+ // 错误消息藏在 `error`(字符串或对象)与 `message` 三处之一,纯文本体则整段拿来用。
30
+ keys: ["error", "error.message", "message"],
31
+ fallback: (status, statusText) => statusText || `umami \u8FD4\u56DE HTTP ${status}`
32
+ },
33
+ mapTransportError: ({ message }) => upstreamError(
34
+ 502,
35
+ message === void 0 ? "umami \u8BF7\u6C42\u5931\u8D25" : `umami \u8BF7\u6C42\u5931\u8D25: ${message}`
36
+ )
37
+ });
24
38
  function requiredText(value, field) {
25
39
  const text = trimmedText(value);
26
40
  if (text === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
27
41
  return text;
28
42
  }
29
- function errorMessage(payload) {
30
- if (typeof payload === "string") return trimmedText(payload);
31
- const body = asJsonObject(payload);
32
- if (body === void 0) return void 0;
33
- return trimmedText(body.error) ?? trimmedText(asJsonObject(body.error)?.message) ?? trimmedText(body.message);
34
- }
35
43
  async function request(ctx, path, query = {}) {
36
- const apiKey = requireApiKey(ctx, SERVICE);
37
- const response = await http.request({
44
+ const response = await http.request(ctx, {
38
45
  path,
39
46
  query: Object.entries(query),
40
- headers: {
41
- accept: "application/json",
42
- authorization: `Bearer ${apiKey}`
43
- },
44
- invalidJson: "text",
45
- mapError: ({ data, status, statusText }) => upstreamError(
46
- status,
47
- errorMessage(data) ?? (statusText || `umami \u8FD4\u56DE HTTP ${status}`)
48
- ),
49
- mapTransportError: ({ message }) => upstreamError(
50
- 502,
51
- message === void 0 ? "umami \u8BF7\u6C42\u5931\u8D25" : `umami \u8BF7\u6C42\u5931\u8D25: ${message}`
52
- )
47
+ invalidJson: "text"
53
48
  });
54
49
  if (response.bodyKind === "invalid-json") throw upstreamError(502, "umami \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
55
50
  return response.bodyKind === "empty" ? null : response.data;
@@ -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
  finiteNumber,
@@ -10,18 +11,17 @@ import {
10
11
  createProviderPlugin,
11
12
  requireApiKey,
12
13
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
- import "./chunk-3WL6EXYX.js";
14
+ } from "./chunk-QR4LK3HF.js";
15
+ import "./chunk-ZTTN6AJG.js";
15
16
  import {
16
17
  TBError,
17
18
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
19
+ } from "./chunk-MZCIPUNQ.js";
19
20
  import "./chunk-U67V476Y.js";
20
21
 
21
22
  // ../plugins/src/unsplash/api.ts
22
23
  var SERVICE = "unsplash";
23
24
  var API_BASE = "https://api.unsplash.com";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
25
  function requireRecord(value, label) {
26
26
  const result = asJsonObject(value);
27
27
  if (result === void 0) {
@@ -56,21 +56,22 @@ function errorMessage(payload) {
56
56
  }
57
57
  return trimmedText(body.error) ?? trimmedText(body.message);
58
58
  }
59
+ var http = createAuthedClient({
60
+ baseUrl: `${API_BASE}/`,
61
+ service: SERVICE,
62
+ // Unsplash 自有的方案名,不是 Bearer。
63
+ auth: { kind: "custom", headers: (ctx) => ({ authorization: `Client-ID ${requireApiKey(ctx, SERVICE)}` }) },
64
+ headers: { "accept": "application/json", "accept-version": "v1" },
65
+ mapError: ({ bodyKind, data, status }) => upstreamError(
66
+ status,
67
+ errorMessage(bodyKind === "json" ? data : null) ?? `Unsplash \u8FD4\u56DE HTTP ${status}`
68
+ )
69
+ });
59
70
  async function request(ctx, path, query = {}) {
60
- const response = await http.request({
71
+ const response = await http.request(ctx, {
61
72
  path,
62
73
  query: Object.entries(query),
63
- headers: {
64
- "accept": "application/json",
65
- // Unsplash 自有的方案名,不是 Bearer。
66
- "authorization": `Client-ID ${requireApiKey(ctx, SERVICE)}`,
67
- "accept-version": "v1"
68
- },
69
- invalidJson: "text",
70
- mapError: ({ bodyKind, data, status }) => upstreamError(
71
- status,
72
- errorMessage(bodyKind === "json" ? data : null) ?? `Unsplash \u8FD4\u56DE HTTP ${status}`
73
- )
74
+ invalidJson: "text"
74
75
  });
75
76
  if (response.bodyKind === "invalid-json") {
76
77
  throw new TBError("unavailable", "Unsplash \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
@@ -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,18 +10,17 @@ import {
9
10
  createProviderPlugin,
10
11
  requireCredential,
11
12
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
13
+ } from "./chunk-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
14
15
  import {
15
16
  TBError,
16
17
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-MZCIPUNQ.js";
18
19
  import "./chunk-U67V476Y.js";
19
20
 
20
21
  // ../plugins/src/upstash_redis/api.ts
21
22
  var SERVICE = "upstash_redis";
22
23
  var HOSTNAME_SUFFIX = ".upstash.io";
23
- var http = createProviderHttpClient({ service: SERVICE });
24
24
  function responseError(message) {
25
25
  return new TBError("unavailable", message, { retryable: true });
26
26
  }
@@ -67,18 +67,22 @@ function unwrap(payload) {
67
67
  if (!Object.hasOwn(body, "result")) throw responseError("Upstash Redis \u54CD\u5E94\u7F3A result");
68
68
  return body.result;
69
69
  }
70
+ var http = createAuthedClient({
71
+ service: SERVICE,
72
+ auth: {
73
+ kind: "custom",
74
+ headers: (ctx) => ({ authorization: `Bearer ${requireCredential(ctx, SERVICE, "restToken")}` })
75
+ },
76
+ headers: { accept: "application/json" },
77
+ mapError: ({ data, rawText, status }) => commandError(status, data, rawText ?? "")
78
+ });
70
79
  async function command(ctx, args) {
71
- const result = await http.request({
80
+ const result = await http.request(ctx, {
72
81
  baseUrl: restUrl(ctx),
73
82
  path: "/",
74
83
  method: "POST",
75
- headers: {
76
- accept: "application/json",
77
- authorization: `Bearer ${requireCredential(ctx, SERVICE, "restToken")}`
78
- },
79
84
  json: args,
80
- invalidJsonMessage: "Upstash Redis \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
81
- mapError: ({ data, rawText, status }) => commandError(status, data, rawText ?? "")
85
+ invalidJsonMessage: "Upstash Redis \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
82
86
  });
83
87
  return unwrap(result.data);
84
88
  }
@@ -5,14 +5,14 @@ import {
5
5
  createProviderPlugin,
6
6
  requireApiKey,
7
7
  upstreamError
8
- } from "./chunk-6ANLYNFB.js";
8
+ } from "./chunk-QR4LK3HF.js";
9
9
  import {
10
10
  guardedFetch
11
- } from "./chunk-3WL6EXYX.js";
11
+ } from "./chunk-ZTTN6AJG.js";
12
12
  import {
13
13
  TBError,
14
14
  external_exports
15
- } from "./chunk-WIGQCP6O.js";
15
+ } from "./chunk-MZCIPUNQ.js";
16
16
  import "./chunk-U67V476Y.js";
17
17
 
18
18
  // ../plugins/src/uptimerobot/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
  trimmedText
@@ -9,12 +10,12 @@ import {
9
10
  createProviderPlugin,
10
11
  requireApiKey,
11
12
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
13
+ } from "./chunk-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
14
15
  import {
15
16
  TBError,
16
17
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-MZCIPUNQ.js";
18
19
  import "./chunk-U67V476Y.js";
19
20
 
20
21
  // ../plugins/src/v2ex/api.ts
@@ -22,8 +23,6 @@ var SERVICE = "v2ex";
22
23
  var API_BASE = "https://www.v2ex.com/api/v2";
23
24
  var LEGACY_API_BASE = "https://www.v2ex.com/api";
24
25
  var REQUEST_TIMEOUT_MS = 3e4;
25
- var v2Http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
26
- var legacyHttp = createProviderHttpClient({ baseUrl: `${LEGACY_API_BASE}/`, service: SERVICE });
27
26
  function invalidResponse(message) {
28
27
  return new TBError("unavailable", message, { retryable: true });
29
28
  }
@@ -49,35 +48,53 @@ function errorMessage(payload) {
49
48
  function envelopeError(payload) {
50
49
  return new TBError("invalid_argument", errorMessage(payload) ?? "V2EX request failed");
51
50
  }
52
- async function send(client, request2, label) {
53
- const response = await client.request({
51
+ var v2Http = createAuthedClient({
52
+ baseUrl: `${API_BASE}/`,
53
+ service: SERVICE,
54
+ auth: { kind: "bearer" },
55
+ headers: { accept: "application/json" },
56
+ mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed")
57
+ });
58
+ var legacyHttp = createAuthedClient({
59
+ baseUrl: `${LEGACY_API_BASE}/`,
60
+ service: SERVICE,
61
+ // legacy API **不带 Authorization** —— 上游这条路径压根不调 `buildV2exHeaders`,加上 Bearer
62
+ // 也没用。但仍然先 `requireApiKey`:上游整个 provider 的 authType 是 `api_key`,没配凭证时
63
+ // 连 context 都建不起来,这两个 action 一样调不通。这里保留那道闸 —— 否则"配了才能用"
64
+ // 会因为迁移悄悄变成"这两个不用配",挂载语义就不一致了。
65
+ auth: {
66
+ kind: "custom",
67
+ headers: (ctx) => {
68
+ requireApiKey(ctx, SERVICE);
69
+ return {};
70
+ }
71
+ },
72
+ headers: { accept: "application/json" },
73
+ mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed")
74
+ });
75
+ async function send(client, ctx, request2, label) {
76
+ const response = await client.request(ctx, {
54
77
  ...request2,
55
78
  timeoutMs: REQUEST_TIMEOUT_MS,
56
79
  invalidJson: "text",
57
- mapError: ({ data, status }) => upstreamError(status, errorMessage(data) ?? "V2EX request failed"),
58
80
  mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `${label} request timed out after ${REQUEST_TIMEOUT_MS / 1e3} seconds`) : upstreamError(502, message === void 0 ? `${label} request failed` : `${label} request failed: ${message}`)
59
81
  });
60
82
  return response.bodyKind === "empty" ? null : response.data;
61
83
  }
62
84
  async function request(ctx, options) {
63
- const headers = {
64
- accept: "application/json",
65
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
66
- };
67
- return send(v2Http, {
85
+ return send(v2Http, ctx, {
68
86
  method: options.method,
69
87
  path: options.path,
70
88
  // 上游连**空串**也当作"没给",不只是 undefined/null。
71
89
  query: Object.entries(options.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
72
- headers,
73
90
  ...options.body === void 0 ? {} : { json: options.body }
74
91
  }, `V2EX ${options.path}`);
75
92
  }
76
93
  async function legacyRequest(ctx, path) {
77
- requireApiKey(ctx, SERVICE);
78
94
  const payload = await send(
79
95
  legacyHttp,
80
- { method: "GET", path, headers: { accept: "application/json" } },
96
+ ctx,
97
+ { method: "GET", path },
81
98
  `V2EX legacy ${path}`
82
99
  );
83
100
  if (!Array.isArray(payload)) {
@@ -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,
@@ -9,21 +10,30 @@ import {
9
10
  trimmedText
10
11
  } from "./chunk-JXHMDBAY.js";
11
12
  import {
12
- createProviderPlugin,
13
- requireApiKey,
14
- upstreamError
15
- } from "./chunk-6ANLYNFB.js";
16
- import "./chunk-3WL6EXYX.js";
13
+ createProviderPlugin
14
+ } from "./chunk-QR4LK3HF.js";
15
+ import "./chunk-ZTTN6AJG.js";
17
16
  import {
18
17
  TBError,
19
18
  external_exports
20
- } from "./chunk-WIGQCP6O.js";
19
+ } from "./chunk-MZCIPUNQ.js";
21
20
  import "./chunk-U67V476Y.js";
22
21
 
23
22
  // ../plugins/src/vercel/api.ts
24
23
  var SERVICE = "vercel";
25
24
  var API_BASE = "https://api.vercel.com";
26
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
25
+ var http = createAuthedClient({
26
+ baseUrl: API_BASE,
27
+ service: SERVICE,
28
+ auth: { kind: "bearer" },
29
+ // 错误体形如 `{ error: { code, message } }`,少数端点直接把 code/message 放在顶层。
30
+ // 两者都拿不到时:JSON 体不回显原文(那是整个错误 body,可能带上游内部细节),
31
+ // 非 JSON 体(HTML 错误页之类)才把原文当消息用 —— 这是上游 readVercelError 的兜底。
32
+ errorMessage: {
33
+ keys: ["error.message", "message"],
34
+ fallback: (status) => `Vercel \u8FD4\u56DE HTTP ${status}`
35
+ }
36
+ });
27
37
  function stringArray(value) {
28
38
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
29
39
  }
@@ -55,20 +65,13 @@ function arrayPayload(payload, key) {
55
65
  }
56
66
  async function request(ctx, input) {
57
67
  const hasBody = input.body !== void 0;
58
- const { data } = await http.request({
68
+ const { data } = await http.request(ctx, {
59
69
  path: input.path,
60
70
  method: input.method ?? "GET",
61
71
  // 上游 `queryParams` 连空串一起跳过。
62
72
  query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
63
- headers: { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` },
64
73
  ...hasBody ? { json: input.body } : {},
65
- invalidJsonMessage: "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
66
- mapError: ({ bodyKind, data: payload, status }) => {
67
- const body = asJsonObject(payload) ?? {};
68
- const error = asJsonObject(body.error) ?? {};
69
- const message = trimmedText(error.message) ?? trimmedText(body.message) ?? (bodyKind === "invalid-json" || bodyKind === "text" ? trimmedText(payload) : void 0) ?? `Vercel \u8FD4\u56DE HTTP ${status}`;
70
- return upstreamError(status, message);
71
- }
74
+ invalidJsonMessage: "Vercel \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
72
75
  });
73
76
  return data ?? {};
74
77
  }
@@ -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
  trimmedText
@@ -9,12 +9,12 @@ import {
9
9
  createProviderPlugin,
10
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/wolfram_alpha_api/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,
@@ -10,14 +11,14 @@ import {
10
11
  createProviderPlugin,
11
12
  requireCredential,
12
13
  upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
+ } from "./chunk-QR4LK3HF.js";
14
15
  import {
15
16
  assertPublicHttpUrl
16
- } from "./chunk-3WL6EXYX.js";
17
+ } from "./chunk-ZTTN6AJG.js";
17
18
  import {
18
19
  TBError,
19
20
  external_exports
20
- } from "./chunk-WIGQCP6O.js";
21
+ } from "./chunk-MZCIPUNQ.js";
21
22
  import "./chunk-U67V476Y.js";
22
23
 
23
24
  // ../plugins/src/wordpress/api.ts
@@ -25,7 +26,6 @@ var SERVICE = "wordpress";
25
26
  var API_PATH = "wp-json/wp/v2";
26
27
  var REST_ROOT_SUFFIXES = ["/wp-json/wp/v2", "/wp-json"];
27
28
  var CURRENT_USER_PATH = "/users/me";
28
- var http = createProviderHttpClient({ service: SERVICE });
29
29
  function requireRecord(value, message) {
30
30
  const result = asJsonObject(value);
31
31
  if (result === void 0) throw upstreamError(502, message);
@@ -90,24 +90,28 @@ function errorMessage(payload, context) {
90
90
  function jsonPayload(data, bodyKind) {
91
91
  return bodyKind === "json" ? data : null;
92
92
  }
93
+ var http = createAuthedClient({
94
+ service: SERVICE,
95
+ auth: { kind: "custom", headers: (ctx) => ({ authorization: basicAuthHeader(ctx) }) },
96
+ headers: { accept: "application/json" },
97
+ mapError: (context) => upstreamError(
98
+ context.status || 502,
99
+ errorMessage(jsonPayload(context.data, context.bodyKind), context)
100
+ ),
101
+ mapTransportError: ({ message }) => upstreamError(
102
+ 502,
103
+ message === void 0 ? "WordPress request failed" : `WordPress request failed: ${message}`
104
+ )
105
+ });
93
106
  async function requestResponse(ctx, options) {
94
- return http.request({
107
+ return http.request(ctx, {
95
108
  baseUrl: `${apiBaseUrl(ctx)}/`,
96
109
  path: options.path,
97
110
  method: options.method ?? "GET",
98
111
  query: queryPairs(options.query),
99
- headers: { accept: "application/json", authorization: basicAuthHeader(ctx) },
100
112
  ...options.body === void 0 ? {} : { json: options.body },
101
113
  // 上游 response.json().catch(() => null):成功或错误上的非 JSON 都按 null。
102
- invalidJson: "text",
103
- mapError: (context) => upstreamError(
104
- context.status || 502,
105
- errorMessage(jsonPayload(context.data, context.bodyKind), context)
106
- ),
107
- mapTransportError: ({ message }) => upstreamError(
108
- 502,
109
- message === void 0 ? "WordPress request failed" : `WordPress request failed: ${message}`
110
- )
114
+ invalidJson: "text"
111
115
  });
112
116
  }
113
117
  async function requestObject(ctx, options) {