@tool-bridge/server 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{airtable-ZNWHIJMO.js → airtable-LLZDFN7M.js} +19 -16
  2. package/dist/{alt_text_generator_ai-X7RMDDM5.js → alt_text_generator_ai-W7O34SNG.js} +4 -4
  3. package/dist/{amap-3VER75VH.js → amap-VOX4T2AW.js} +4 -4
  4. package/dist/{anthropic-N7NTB3UC.js → anthropic-G23NN3X5.js} +23 -25
  5. package/dist/{apify-JB5P5AJI.js → apify-Y3SS734K.js} +20 -19
  6. package/dist/{brave_search-USL5OOBS.js → brave_search-ZC7OAPSZ.js} +16 -14
  7. package/dist/{chunk-6ANLYNFB.js → chunk-ATK45BXV.js} +1 -1
  8. package/dist/{chunk-6X55ALDX.js → chunk-E6JCVKW6.js} +6 -5
  9. package/dist/{chunk-RVUERWUZ.js → chunk-KMTT3I6D.js} +768 -1048
  10. package/dist/chunk-R6P4XAE5.js +248 -0
  11. package/dist/{chunk-3WL6EXYX.js → chunk-U7B6DS2O.js} +1 -1
  12. package/dist/{chunk-WIGQCP6O.js → chunk-UZM2RXZH.js} +159 -182
  13. package/dist/chunk-XYBU3WZH.js +71 -0
  14. package/dist/{circleci-LBGB25LP.js → circleci-3BAX5FCG.js} +20 -24
  15. package/dist/{clerk-6RX37CNZ.js → clerk-6LEM6TNU.js} +22 -21
  16. package/dist/{cloudflare_dns-NQGW7FHV.js → cloudflare_dns-KINYTJUD.js} +21 -17
  17. package/dist/{cohere-XPC2NAEW.js → cohere-XCJ5AJ6B.js} +19 -17
  18. package/dist/{confluence-ZUG2LT5A.js → confluence-B3EWPZVE.js} +16 -11
  19. package/dist/{convertapi-ZLXKWV3L.js → convertapi-EUWSQYPF.js} +3 -3
  20. package/dist/{currencyapi-T3A3HSOD.js → currencyapi-KVTIK3GL.js} +23 -26
  21. package/dist/{deepseek-NJMOD23E.js → deepseek-PC5YGNC5.js} +27 -17
  22. package/dist/{docker_hub-D2MQCSJ7.js → docker_hub-C3MA5FU6.js} +4 -4
  23. package/dist/{dropbox-MI6U3SOT.js → dropbox-XBV7Z2IR.js} +9 -8
  24. package/dist/{dub-P2BYBYV4.js → dub-LDOFG3HC.js} +22 -19
  25. package/dist/{e2b-BGKIAE54.js → e2b-JMCPSVBW.js} +20 -20
  26. package/dist/{exa-EUY7VV4C.js → exa-RAK7O7RD.js} +22 -25
  27. package/dist/{fal_ai-AAOG5FYJ.js → fal_ai-23E7JPNT.js} +18 -17
  28. package/dist/feishu-7QRIDUV6.js +12019 -0
  29. package/dist/{feishu_custom_bot-BWGMNVXF.js → feishu_custom_bot-TJ4K7QNJ.js} +3 -3
  30. package/dist/{figma-SJSWYCGD.js → figma-E6IX5DTH.js} +21 -23
  31. package/dist/{firehydrant-MOXK2PST.js → firehydrant-ZBLPQREE.js} +15 -15
  32. package/dist/{fixer-ISIDUDZU.js → fixer-BWON27UO.js} +4 -4
  33. package/dist/{fly-U4KPSGBF.js → fly-ZH3HFCZJ.js} +20 -16
  34. package/dist/{front-ZHM2YX2E.js → front-QCGXYEDJ.js} +20 -23
  35. package/dist/{geocodio-SVCCAXAV.js → geocodio-YGNI7DA4.js} +4 -4
  36. package/dist/{ghost-INTR7FIY.js → ghost-EVSGKH2Q.js} +4 -4
  37. package/dist/{github-T275VVWR.js → github-MA2BGRCJ.js} +28 -27
  38. package/dist/{gmail-KSSPOE67.js → gmail-E5E6AADE.js} +17 -17
  39. package/dist/{googlecalendar-JB5RW27L.js → googlecalendar-BTLFPXTD.js} +22 -19
  40. package/dist/{googledocs-G522PUGW.js → googledocs-BUHL4J2H.js} +6 -5
  41. package/dist/{grafana-44ZPIV5P.js → grafana-GLU2DWF2.js} +24 -25
  42. package/dist/{graphhopper-2MORXLOW.js → graphhopper-WSMB3TCD.js} +4 -4
  43. package/dist/index.d.ts +31 -30
  44. package/dist/index.js +4 -3
  45. package/dist/{ip2proxy-R4K4KEMI.js → ip2proxy-EZ64Y4ZH.js} +4 -4
  46. package/dist/{ipgeolocation_io-H4J55OGI.js → ipgeolocation_io-AA7HAS22.js} +4 -4
  47. package/dist/{ipqualityscore-XGID4OHA.js → ipqualityscore-BHJXVTJT.js} +4 -4
  48. package/dist/{jina_ai-7ZVDOR3Z.js → jina_ai-EFBHTBXL.js} +20 -21
  49. package/dist/{jira-CTIYZTT3.js → jira-HQSHAA5K.js} +20 -16
  50. package/dist/{langsmith-ISP567FS.js → langsmith-5W6SCT6F.js} +25 -25
  51. package/dist/{lemlist-OGKK272F.js → lemlist-HJWH6UMK.js} +23 -24
  52. package/dist/{linear-6JX4E3JI.js → linear-K7RYFYAD.js} +6 -5
  53. package/dist/{logsnag-BVB36ZCL.js → logsnag-4KFOHL37.js} +20 -22
  54. package/dist/main.js +103 -102
  55. package/dist/{mattermost-UECVPZGY.js → mattermost-S2BRCWLQ.js} +21 -17
  56. package/dist/{mem0-EUA7S2OO.js → mem0-CAW43CIC.js} +15 -15
  57. package/dist/{memos-BYSBJRWZ.js → memos-TWEGPKFM.js} +39 -34
  58. package/dist/{metabase-4JXZH3YG.js → metabase-MMSEPCOF.js} +22 -18
  59. package/dist/{mistral_ai-2C5BTBKW.js → mistral_ai-64BGZQHP.js} +24 -21
  60. package/dist/{mother_duck-ZGNNNR3X.js → mother_duck-H7PCQNZ2.js} +23 -19
  61. package/dist/{ngrok-NTPGMRXI.js → ngrok-GQCUGZKJ.js} +17 -22
  62. package/dist/{notes-KGYXX6N6.js → notes-PFMKRO33.js} +1 -1
  63. package/dist/{notion-EX3X2G7G.js → notion-DQWZWP4N.js} +20 -17
  64. package/dist/{open_exchange_rates-2V2LIGPS.js → open_exchange_rates-QMMD735E.js} +4 -4
  65. package/dist/{openai-KQFQPK7Z.js → openai-W6PX32NZ.js} +22 -16
  66. package/dist/{opengraph_io-B63SEYJY.js → opengraph_io-HNDBXYNW.js} +4 -4
  67. package/dist/{openrouter-62A4H62Q.js → openrouter-JJYMEAUL.js} +19 -14
  68. package/dist/{outline-QC33XLCK.js → outline-MCBNQZYY.js} +18 -20
  69. package/dist/{paddle-HDZG35Y7.js → paddle-D2SKLUDN.js} +17 -15
  70. package/dist/{perplexity-M7LOMJWA.js → perplexity-XIFMKUAE.js} +19 -23
  71. package/dist/{pinecone-Y7YCJRZM.js → pinecone-HUFTALV2.js} +19 -24
  72. package/dist/{pipedrive-FLJA62UX.js → pipedrive-Y2O7QGFF.js} +22 -23
  73. package/dist/{polar-AE55Q425.js → polar-TYTOMOSR.js} +19 -17
  74. package/dist/{posthog-IAY5D3YW.js → posthog-43JAR3VW.js} +29 -24
  75. package/dist/{postmark-NMKAXDXZ.js → postmark-KL2QJYSG.js} +19 -17
  76. package/dist/{prerender-CDJM7I7N.js → prerender-MENYM2TY.js} +4 -4
  77. package/dist/{pubmed-N437ZJOR.js → pubmed-GOXUVVH5.js} +6 -5
  78. package/dist/{railway-NBWYXCUM.js → railway-V2SID4WV.js} +3 -3
  79. package/dist/{readwise-QRO3UC3R.js → readwise-CI4GIMMJ.js} +16 -15
  80. package/dist/{render-NEW7SROG.js → render-SUBJ6YRZ.js} +21 -20
  81. package/dist/{replicate-73YQLRTY.js → replicate-756MXPYX.js} +20 -21
  82. package/dist/{resend-R5BAZFHZ.js → resend-ZKH3BTBI.js} +15 -11
  83. package/dist/{rootly-5BLALPCS.js → rootly-CD2LJHPI.js} +19 -18
  84. package/dist/{scrapfly-EHFLNNUZ.js → scrapfly-NSRHFDIQ.js} +4 -4
  85. package/dist/{scrapingbee-UXLYS72S.js → scrapingbee-OQHLAVEY.js} +4 -4
  86. package/dist/{screenshot_fyi-KC3NLTJ6.js → screenshot_fyi-DVWG3AXC.js} +4 -4
  87. package/dist/{semantic_scholar-SA5OIUWA.js → semantic_scholar-T4A252KW.js} +21 -20
  88. package/dist/{sentry-BAE3XLJN.js → sentry-546MNDJG.js} +22 -19
  89. package/dist/{shodan-FJR6MKKW.js → shodan-C3OON3Z3.js} +4 -4
  90. package/dist/{shopify-7OA6SLN5.js → shopify-Y2HN2MCQ.js} +23 -19
  91. package/dist/{stripe-MUWDZGGF.js → stripe-VE3CD3AY.js} +3 -3
  92. package/dist/{supabase-SWWGNWYR.js → supabase-U2SL4D63.js} +18 -17
  93. package/dist/{tavily-XQNJ5EDI.js → tavily-KCZHK6HE.js} +20 -20
  94. package/dist/{telegram-RR6JPZOG.js → telegram-3URFBCMY.js} +4 -4
  95. package/dist/{telnyx-7PKXOWSO.js → telnyx-CXQ4EZUX.js} +19 -19
  96. package/dist/{todoist-63X5IUJE.js → todoist-HNPWNYTD.js} +18 -17
  97. package/dist/{trello-MOG63DAI.js → trello-3W2MIXRP.js} +4 -4
  98. package/dist/{turso-ENWTSHDL.js → turso-2EQF7C2Z.js} +23 -30
  99. package/dist/{twilio-FDXUN7VX.js → twilio-4PDBJKWX.js} +6 -5
  100. package/dist/{umami-TM7PROWF.js → umami-5REN7TGP.js} +23 -28
  101. package/dist/{unsplash-NWXLKSOW.js → unsplash-EIXL424F.js} +19 -18
  102. package/dist/{upstash_redis-CUTQ5L2N.js → upstash_redis-G4LQBYHA.js} +17 -13
  103. package/dist/{uptimerobot-NNO32M3I.js → uptimerobot-KNJ3EYLY.js} +3 -3
  104. package/dist/{v2ex-24KMSWS7.js → v2ex-RHJ234PZ.js} +35 -18
  105. package/dist/{vercel-B45LPF6I.js → vercel-AS6NCIC7.js} +21 -18
  106. package/dist/{wolfram_alpha_api-DKJWVR6G.js → wolfram_alpha_api-3G4PUJWB.js} +4 -4
  107. package/dist/{wordpress-XYFSDZXY.js → wordpress-KNDAAUV7.js} +21 -17
  108. package/dist/{workos-BEM7EPHM.js → workos-R6UITSJ7.js} +26 -27
  109. package/dist/{zhihu-CFHZ4NC7.js → zhihu-AGK4HILK.js} +21 -21
  110. package/package.json +5 -5
  111. package/dist/feishu-AN5IJYOW.js +0 -231
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -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-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/supabase/api.ts
22
22
  var SERVICE = "supabase";
23
23
  var API_BASE = "https://api.supabase.com/v1";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  var PROJECT_STATUSES = /* @__PURE__ */ new Set([
26
25
  "ACTIVE_HEALTHY",
27
26
  "ACTIVE_UNHEALTHY",
@@ -84,23 +83,25 @@ function errorMessage(status, payload) {
84
83
  if (code === "invalid_grant") return "supabase grant is invalid or expired";
85
84
  return trimmedText(detail.message) ?? trimmedText(detail.msg) ?? trimmedText(detail.error_description) ?? `supabase request failed with ${status}`;
86
85
  }
86
+ var http = createAuthedClient({
87
+ baseUrl: `${API_BASE}/`,
88
+ service: SERVICE,
89
+ auth: { kind: "bearer" },
90
+ headers: { accept: "application/json" },
91
+ mapError: ({ data: payload, status }) => upstreamError(
92
+ status,
93
+ errorMessage(status, typeof payload === "string" ? { message: payload } : payload)
94
+ )
95
+ });
87
96
  async function request(ctx, input) {
88
97
  const hasBody = input.body !== void 0;
89
- const { data } = await http.request({
98
+ const { data } = await http.request(ctx, {
90
99
  path: input.path,
91
100
  method: input.method ?? "GET",
92
101
  // health 的 services 靠**重复同名参数**表达;statuses 那种逗号串在调用处就拼好了。
93
102
  query: Object.entries(input.query ?? {}),
94
- headers: {
95
- accept: "application/json",
96
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
97
- },
98
103
  ...hasBody ? { json: input.body } : {},
99
- invalidJsonMessage: "malformed supabase response: malformed supabase json response",
100
- mapError: ({ data: payload2, status }) => upstreamError(
101
- status,
102
- errorMessage(status, typeof payload2 === "string" ? { message: payload2 } : payload2)
103
- )
104
+ invalidJsonMessage: "malformed supabase response: malformed supabase json response"
104
105
  });
105
106
  const payload = data ?? null;
106
107
  if (payload === null && input.allowEmpty !== true) throw malformed("empty body");
@@ -1,41 +1,41 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
- asJsonObject,
6
- messageFrom
6
+ asJsonObject
7
7
  } from "./chunk-JXHMDBAY.js";
8
8
  import {
9
9
  createProviderPlugin,
10
- requireApiKey,
11
10
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
13
- import "./chunk-3WL6EXYX.js";
11
+ } from "./chunk-ATK45BXV.js";
12
+ import "./chunk-U7B6DS2O.js";
14
13
  import {
15
14
  external_exports
16
- } from "./chunk-WIGQCP6O.js";
15
+ } from "./chunk-UZM2RXZH.js";
17
16
  import "./chunk-U67V476Y.js";
18
17
 
19
18
  // ../plugins/src/tavily/api.ts
20
19
  var SERVICE = "tavily";
21
20
  var REQUEST_TIMEOUT_MS = 3e4;
22
- var http = createProviderHttpClient({ baseUrl: "https://api.tavily.com/", service: SERVICE });
21
+ var http = createAuthedClient({
22
+ baseUrl: "https://api.tavily.com/",
23
+ service: SERVICE,
24
+ auth: { kind: "bearer" },
25
+ headers: { accept: "application/json" },
26
+ errorMessage: {
27
+ keys: ["detail", "error", "message"],
28
+ fallback: (status) => `Tavily \u8FD4\u56DE HTTP ${status}`
29
+ },
30
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Tavily ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, message === void 0 ? "Tavily \u8BF7\u6C42\u5931\u8D25" : `Tavily \u8BF7\u6C42\u5931\u8D25:${message}`)
31
+ });
23
32
  async function request(ctx, options) {
24
- const { data } = await http.request({
33
+ const { data } = await http.request(ctx, {
25
34
  path: options.path,
26
35
  method: options.method,
27
- headers: {
28
- accept: "application/json",
29
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
30
- },
31
36
  ...options.body === void 0 ? {} : { json: options.body },
32
37
  timeoutMs: REQUEST_TIMEOUT_MS,
33
- invalidJsonMessage: "Tavily \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
34
- mapError: ({ data: payload, status }) => upstreamError(
35
- status,
36
- messageFrom(payload, ["detail", "error", "message"], `Tavily \u8FD4\u56DE HTTP ${status}`)
37
- ),
38
- mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Tavily ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, message === void 0 ? "Tavily \u8BF7\u6C42\u5931\u8D25" : `Tavily \u8BF7\u6C42\u5931\u8D25:${message}`)
38
+ invalidJsonMessage: "Tavily \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
39
39
  });
40
40
  if (data === void 0) return {};
41
41
  const result = asJsonObject(data);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-E6JCVKW6.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-ATK45BXV.js";
16
16
  import {
17
17
  assertPublicHttpUrl
18
- } from "./chunk-3WL6EXYX.js";
18
+ } from "./chunk-U7B6DS2O.js";
19
19
  import {
20
20
  TBError,
21
21
  external_exports
22
- } from "./chunk-WIGQCP6O.js";
22
+ } from "./chunk-UZM2RXZH.js";
23
23
  import "./chunk-U67V476Y.js";
24
24
 
25
25
  // ../plugins/src/telegram/api.ts
@@ -1,26 +1,25 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  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-ATK45BXV.js";
13
+ import "./chunk-U7B6DS2O.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-UZM2RXZH.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/telnyx/api.ts
21
21
  var SERVICE = "telnyx";
22
22
  var API_BASE = "https://api.telnyx.com/v2";
23
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
24
23
  function errorMessage(payload, status, statusText) {
25
24
  if (typeof payload === "string" && payload.trim() !== "") return payload;
26
25
  const record = asJsonObject(payload);
@@ -29,27 +28,28 @@ function errorMessage(payload, status, statusText) {
29
28
  const message = first === void 0 ? trimmedText(record?.detail) ?? trimmedText(record?.message) ?? trimmedText(record?.error) ?? trimmedText(record?.title) : trimmedText(first.detail) ?? trimmedText(first.title) ?? trimmedText(first.code);
30
29
  return message ?? (statusText || `Telnyx \u8FD4\u56DE HTTP ${status}`);
31
30
  }
31
+ var http = createAuthedClient({
32
+ baseUrl: `${API_BASE}/`,
33
+ service: SERVICE,
34
+ auth: { kind: "bearer" },
35
+ headers: { accept: "application/json" },
36
+ mapError: ({ bodyKind, data, status, statusText }) => bodyKind === "invalid-json" ? upstreamError(status === 429 ? 429 : 502, "Telnyx \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94") : upstreamError(status, errorMessage(bodyKind === "empty" ? null : data, status, statusText)),
37
+ mapTransportError: ({ message }) => upstreamError(
38
+ 502,
39
+ message === void 0 ? "telnyx request failed" : `telnyx request failed: ${message}`
40
+ )
41
+ });
32
42
  async function request(ctx, path, input = {}) {
33
- const headers = {
34
- accept: "application/json",
35
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
36
- };
37
- const response = await http.request({
43
+ const response = await http.request(ctx, {
38
44
  method: input.method ?? "GET",
39
45
  path,
40
46
  // 空串不进 query:Telnyx 会把 `filter[name]=` 读成"匹配空名字",而调用方省略一个
41
47
  // 可选筛选时想要的是"不筛选"。
42
48
  query: (input.query ?? []).filter(([, value]) => value !== void 0 && value !== null && value !== ""),
43
- headers,
44
49
  // JSON.stringify 自己会丢掉值为 undefined 的键,故不必复制上游的 removeUndefined;
45
50
  // 但 null 必须留住 —— schema 允许 sendAt 显式传 null,那是要发给 Telnyx 的值。
46
51
  ...input.body === void 0 ? {} : { json: input.body },
47
- invalidJsonMessage: "Telnyx \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
48
- mapError: ({ bodyKind, data, status, statusText }) => bodyKind === "invalid-json" ? upstreamError(status === 429 ? 429 : 502, "Telnyx \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94") : upstreamError(status, errorMessage(bodyKind === "empty" ? null : data, status, statusText)),
49
- mapTransportError: ({ message }) => upstreamError(
50
- 502,
51
- message === void 0 ? "telnyx request failed" : `telnyx request failed: ${message}`
52
- )
52
+ invalidJsonMessage: "Telnyx \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
53
53
  });
54
54
  const record = asJsonObject(response.bodyKind === "empty" ? null : response.data);
55
55
  if (record === void 0) {
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,21 +9,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-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/todoist/api.ts
22
22
  var SERVICE = "todoist";
23
23
  var API_BASE = "https://api.todoist.com/api/v1";
24
24
  var USER_PATH = "/user";
25
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, 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.`);
@@ -48,6 +47,16 @@ function errorMessage(status, payload) {
48
47
  }
49
48
  return `todoist request failed with ${status}`;
50
49
  }
50
+ var http = createAuthedClient({
51
+ baseUrl: `${API_BASE}/`,
52
+ service: SERVICE,
53
+ auth: { kind: "bearer" },
54
+ headers: { accept: "application/json" },
55
+ mapError: ({ data, status }) => upstreamError(
56
+ status,
57
+ errorMessage(status, typeof data === "string" ? { message: data } : data)
58
+ )
59
+ });
51
60
  async function request(ctx, input) {
52
61
  const hasBody = input.body !== void 0;
53
62
  const query = Object.entries(input.query ?? {}).map(([key, value]) => [
@@ -55,20 +64,12 @@ async function request(ctx, input) {
55
64
  // 多值参数(list_tasks 的 ids)是**逗号串**,不是重复的同名参数。
56
65
  Array.isArray(value) ? value.join(",") : value
57
66
  ]);
58
- const { data } = await http.request({
67
+ const { data } = await http.request(ctx, {
59
68
  path: input.path,
60
69
  method: input.method ?? "GET",
61
70
  query,
62
- headers: {
63
- accept: "application/json",
64
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
65
- },
66
71
  ...hasBody ? { json: input.body } : {},
67
- invalidJsonMessage: "Todoist \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
68
- mapError: ({ data: data2, status }) => upstreamError(
69
- status,
70
- errorMessage(status, typeof data2 === "string" ? { message: data2 } : data2)
71
- )
72
+ invalidJsonMessage: "Todoist \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
72
73
  });
73
74
  return data ?? {};
74
75
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-E6JCVKW6.js";
4
4
  import {
5
5
  asJsonObject,
6
6
  booleanValue,
@@ -11,12 +11,12 @@ import {
11
11
  createProviderPlugin,
12
12
  requireCredential,
13
13
  upstreamError
14
- } from "./chunk-6ANLYNFB.js";
15
- import "./chunk-3WL6EXYX.js";
14
+ } from "./chunk-ATK45BXV.js";
15
+ import "./chunk-U7B6DS2O.js";
16
16
  import {
17
17
  TBError,
18
18
  external_exports
19
- } from "./chunk-WIGQCP6O.js";
19
+ } from "./chunk-UZM2RXZH.js";
20
20
  import "./chunk-U67V476Y.js";
21
21
 
22
22
  // ../plugins/src/trello/api.ts
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,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-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/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,15 @@ import {
7
7
  createProviderPlugin,
8
8
  requireCredential,
9
9
  upstreamError
10
- } from "./chunk-6ANLYNFB.js";
10
+ } from "./chunk-ATK45BXV.js";
11
11
  import {
12
12
  guardedFetch
13
- } from "./chunk-3WL6EXYX.js";
13
+ } from "./chunk-U7B6DS2O.js";
14
14
  import {
15
15
  TBError,
16
- external_exports
17
- } from "./chunk-WIGQCP6O.js";
16
+ external_exports,
17
+ isTBError
18
+ } from "./chunk-UZM2RXZH.js";
18
19
  import "./chunk-U67V476Y.js";
19
20
 
20
21
  // ../plugins/src/twilio/api.ts
@@ -61,7 +62,7 @@ async function request(ctx, options) {
61
62
  ...options.form === void 0 ? {} : { body: options.form.toString() }
62
63
  });
63
64
  } catch (error) {
64
- if (error instanceof TBError) throw error;
65
+ if (isTBError(error)) throw error;
65
66
  throw upstreamError(
66
67
  502,
67
68
  error instanceof Error ? `Twilio request failed: ${error.message}` : "Twilio request failed"
@@ -1,55 +1,50 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  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-ATK45BXV.js";
13
+ import "./chunk-U7B6DS2O.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-UZM2RXZH.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-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.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-ATK45BXV.js";
15
+ import "./chunk-U7B6DS2O.js";
15
16
  import {
16
17
  TBError,
17
18
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
19
+ } from "./chunk-UZM2RXZH.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-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.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-ATK45BXV.js";
14
+ import "./chunk-U7B6DS2O.js";
14
15
  import {
15
16
  TBError,
16
17
  external_exports
17
- } from "./chunk-WIGQCP6O.js";
18
+ } from "./chunk-UZM2RXZH.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-ATK45BXV.js";
9
9
  import {
10
10
  guardedFetch
11
- } from "./chunk-3WL6EXYX.js";
11
+ } from "./chunk-U7B6DS2O.js";
12
12
  import {
13
13
  TBError,
14
14
  external_exports
15
- } from "./chunk-WIGQCP6O.js";
15
+ } from "./chunk-UZM2RXZH.js";
16
16
  import "./chunk-U67V476Y.js";
17
17
 
18
18
  // ../plugins/src/uptimerobot/api.ts