@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
@@ -2,14 +2,14 @@ import {
2
2
  createProviderPlugin,
3
3
  requireCredential,
4
4
  upstreamError
5
- } from "./chunk-6ANLYNFB.js";
5
+ } from "./chunk-ATK45BXV.js";
6
6
  import {
7
7
  guardedFetch
8
- } from "./chunk-3WL6EXYX.js";
8
+ } from "./chunk-U7B6DS2O.js";
9
9
  import {
10
10
  TBError,
11
11
  external_exports
12
- } from "./chunk-WIGQCP6O.js";
12
+ } from "./chunk-UZM2RXZH.js";
13
13
  import "./chunk-U67V476Y.js";
14
14
 
15
15
  // ../plugins/src/feishu_custom_bot/api.ts
@@ -1,27 +1,37 @@
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,
7
8
  trimmedText
8
9
  } from "./chunk-JXHMDBAY.js";
9
10
  import {
10
- createProviderPlugin,
11
- requireApiKey,
12
- upstreamError
13
- } from "./chunk-6ANLYNFB.js";
14
- import "./chunk-3WL6EXYX.js";
11
+ createProviderPlugin
12
+ } from "./chunk-ATK45BXV.js";
13
+ import "./chunk-U7B6DS2O.js";
15
14
  import {
16
15
  TBError,
17
16
  external_exports
18
- } from "./chunk-WIGQCP6O.js";
17
+ } from "./chunk-UZM2RXZH.js";
19
18
  import "./chunk-U67V476Y.js";
20
19
 
21
20
  // ../plugins/src/figma/api.ts
22
21
  var SERVICE = "figma";
23
22
  var API_BASE = "https://api.figma.com";
24
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
23
+ var http = createAuthedClient({
24
+ baseUrl: API_BASE,
25
+ service: SERVICE,
26
+ auth: { kind: "header", name: "x-figma-token" },
27
+ headers: { accept: "application/json" },
28
+ // Figma 的错误消息散在六个位置,按上游的顺序找。payload 是纯文本时它本身就是消息。
29
+ errorMessage: {
30
+ keys: ["message", "err", "error", "status", "error.message", "error.detail"],
31
+ fallback: (status) => `Figma \u8FD4\u56DE HTTP ${status}`
32
+ },
33
+ mapTransportError: () => new TBError("unavailable", "Figma \u8BF7\u6C42\u5931\u8D25", { retryable: true })
34
+ });
25
35
  function requireInput(value, field) {
26
36
  const result = trimmedText(value);
27
37
  if (result === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u662F\u7A7A\u767D`);
@@ -46,27 +56,15 @@ function requireArray(value, label) {
46
56
  if (!Array.isArray(value)) throw new TBError("unavailable", `${label}\u4E0D\u662F\u6570\u7EC4`, { retryable: true });
47
57
  return value;
48
58
  }
49
- function errorMessage(payload, status) {
50
- if (typeof payload === "string") return trimmedText(payload) ?? `Figma \u8FD4\u56DE HTTP ${status}`;
51
- const body = asJsonObject(payload);
52
- const error = asJsonObject(body?.error);
53
- return trimmedText(body?.message) ?? trimmedText(body?.err) ?? trimmedText(body?.error) ?? trimmedText(body?.status) ?? trimmedText(error?.message) ?? trimmedText(error?.detail) ?? `Figma \u8FD4\u56DE HTTP ${status}`;
54
- }
55
59
  async function request(ctx, input) {
56
60
  const hasBody = input.body !== void 0;
57
- const { data } = await http.request({
61
+ const { data } = await http.request(ctx, {
58
62
  path: input.path,
59
63
  method: input.method ?? "GET",
60
64
  query: Object.entries(input.query ?? {}),
61
- headers: {
62
- "accept": "application/json",
63
- "x-figma-token": requireApiKey(ctx, SERVICE)
64
- },
65
65
  ...hasBody ? { json: input.body } : {},
66
66
  // Figma 的错误消息有时是纯文本;成功响应也保留旧实现的原文 payload 语义。
67
- invalidJson: "text",
68
- mapError: ({ data: payload, status }) => upstreamError(status, errorMessage(payload, status)),
69
- mapTransportError: () => new TBError("unavailable", "Figma \u8BF7\u6C42\u5931\u8D25", { retryable: true })
67
+ invalidJson: "text"
70
68
  });
71
69
  return data ?? null;
72
70
  }
@@ -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/firehydrant/api.ts
22
22
  var SERVICE = "firehydrant";
23
23
  var API_BASE = "https://api.firehydrant.io/v1";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  function responseObject(value, what) {
26
25
  const object = asJsonObject(value);
27
26
  if (object === void 0) {
@@ -39,19 +38,20 @@ function errorMessage(payload, status) {
39
38
  }
40
39
  return `FireHydrant request failed with status ${status}`;
41
40
  }
41
+ var http = createAuthedClient({
42
+ baseUrl: `${API_BASE}/`,
43
+ service: SERVICE,
44
+ auth: { kind: "bearer" },
45
+ headers: { "accept": "application/json", "content-type": "application/json" },
46
+ mapError: ({ bodyKind, data: payload, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "FireHydrant \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(payload, status))
47
+ });
42
48
  async function request(ctx, input) {
43
- const { data } = await http.request({
49
+ const { data } = await http.request(ctx, {
44
50
  path: input.path,
45
51
  method: input.method ?? "GET",
46
52
  query: Object.entries(input.query ?? {}),
47
- headers: {
48
- "accept": "application/json",
49
- "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
50
- "content-type": "application/json"
51
- },
52
53
  ...input.body === void 0 ? {} : { json: input.body },
53
- invalidJsonMessage: "FireHydrant \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON",
54
- mapError: ({ bodyKind, data: payload, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "FireHydrant \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(payload, status))
54
+ invalidJsonMessage: "FireHydrant \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
55
55
  });
56
56
  return data ?? {};
57
57
  }
@@ -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
  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-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/fixer/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,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/fly/api.ts
22
22
  var SERVICE = "fly";
23
23
  var API_BASE = "https://api.machines.dev/v1/";
24
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
25
24
  function requireText(value, field) {
26
25
  const result = trimmedText(value);
27
26
  if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
@@ -60,22 +59,27 @@ function errorMessage(payload, status) {
60
59
  }
61
60
  return `Fly.io request failed with status ${status}`;
62
61
  }
62
+ var http = createAuthedClient({
63
+ baseUrl: API_BASE,
64
+ service: SERVICE,
65
+ auth: { kind: "bearer" },
66
+ headers: { accept: "application/json" },
67
+ // 错误消息要先过 flyPayload 二次解析(content-type 不可信),不是标准键序提取。
68
+ mapError: (context) => upstreamError(
69
+ context.status,
70
+ errorMessage(flyPayload(context.data, context.bodyKind, context.headers), context.status)
71
+ ),
72
+ mapTransportError: ({ message }) => upstreamError(502, message ?? "Fly.io request failed")
73
+ });
63
74
  async function request(ctx, input) {
64
- const apiKey = requireApiKey(ctx, SERVICE);
65
- const result = await http.request({
75
+ const result = await http.request(ctx, {
66
76
  path: input.path,
67
77
  method: input.method,
68
78
  // 空串与 undefined 同等对待:Fly 把 `?region=` 当成真的按空 region 过滤。
69
79
  query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
70
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
71
80
  ...input.body === void 0 ? {} : { json: input.body },
72
81
  invalidJson: "text",
73
- responseType: "auto",
74
- mapError: (context) => upstreamError(
75
- context.status,
76
- errorMessage(flyPayload(context.data, context.bodyKind, context.headers), context.status)
77
- ),
78
- mapTransportError: ({ message }) => upstreamError(502, message ?? "Fly.io request failed")
82
+ responseType: "auto"
79
83
  });
80
84
  const payload = flyPayload(result.data, result.bodyKind, result.headers);
81
85
  if (input.expectJson === false) return payload;
@@ -1,53 +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
  external_exports
16
- } from "./chunk-WIGQCP6O.js";
16
+ } from "./chunk-UZM2RXZH.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/front/api.ts
20
20
  var SERVICE = "front";
21
21
  var API_BASE = "https://api2.frontapp.com";
22
22
  var REQUEST_TIMEOUT_MS = 15e3;
23
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
24
- function errorMessage(payload) {
25
- if (typeof payload === "string") return trimmedText(payload);
26
- const body = asJsonObject(payload);
27
- if (body === void 0) return void 0;
28
- const nested = asJsonObject(body.error);
29
- return trimmedText(body.message) ?? trimmedText(body._error) ?? trimmedText(body.error) ?? trimmedText(nested?.message);
30
- }
23
+ var http = createAuthedClient({
24
+ baseUrl: `${API_BASE}/`,
25
+ service: SERVICE,
26
+ auth: { kind: "bearer" },
27
+ headers: { accept: "application/json" },
28
+ // Front 的错误体形状不止一种,四个候选键按上游顺序取第一个有文本的。
29
+ errorMessage: {
30
+ keys: ["message", "_error", "error", "error.message"],
31
+ fallback: (status) => `front \u8FD4\u56DE HTTP ${status}`
32
+ },
33
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, "front \u8BF7\u6C42\u8D85\u65F6") : upstreamError(502, message === void 0 ? "front \u8BF7\u6C42\u5931\u8D25" : `front \u8BF7\u6C42\u5931\u8D25: ${message}`)
34
+ });
31
35
  async function request(ctx, path, input) {
32
- const apiKey = requireApiKey(ctx, SERVICE);
33
36
  const query = [];
34
37
  for (const [key, value] of input.query ?? []) {
35
38
  if (typeof value === "string" && value !== "") query.push([key, value]);
36
39
  else if (typeof value === "number") query.push([key, value]);
37
40
  }
38
- const { data } = await http.request({
41
+ const { data } = await http.request(ctx, {
39
42
  path,
40
43
  method: input.method,
41
44
  query,
42
- headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
43
45
  ...input.body === void 0 ? {} : { json: input.body },
44
46
  timeoutMs: REQUEST_TIMEOUT_MS,
45
- invalidJson: "text",
46
- mapError: ({ data: payload, status }) => upstreamError(
47
- status,
48
- errorMessage(payload) ?? `front \u8FD4\u56DE HTTP ${status}`
49
- ),
50
- mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, "front \u8BF7\u6C42\u8D85\u65F6") : upstreamError(502, message === void 0 ? "front \u8BF7\u6C42\u5931\u8D25" : `front \u8BF7\u6C42\u5931\u8D25: ${message}`)
47
+ invalidJson: "text"
51
48
  });
52
49
  return data ?? {};
53
50
  }
@@ -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
  messageFrom
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-ATK45BXV.js";
12
+ import "./chunk-U7B6DS2O.js";
13
13
  import {
14
14
  TBError,
15
15
  external_exports
16
- } from "./chunk-WIGQCP6O.js";
16
+ } from "./chunk-UZM2RXZH.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/geocodio/api.ts
@@ -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
  trimmedText
@@ -9,14 +9,14 @@ import {
9
9
  createProviderPlugin,
10
10
  requireCredential,
11
11
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
12
+ } from "./chunk-ATK45BXV.js";
13
13
  import {
14
14
  assertPublicHttpUrl
15
- } from "./chunk-3WL6EXYX.js";
15
+ } from "./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/ghost/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,14 +9,13 @@ 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/github/api/shared.ts
@@ -23,7 +23,6 @@ var SERVICE = "github";
23
23
  var API_BASE = "https://api.github.com";
24
24
  var API_VERSION = "2022-11-28";
25
25
  var USER_AGENT = "tool-bridge";
26
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
27
26
  var text = trimmedText;
28
27
  var record = asJsonObject;
29
28
  function objectArray(value) {
@@ -68,14 +67,6 @@ function requireBranchOrTagRef(ref) {
68
67
  }
69
68
  return ref;
70
69
  }
71
- function headers(ctx) {
72
- return {
73
- "accept": "application/vnd.github+json",
74
- "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
75
- "x-github-api-version": API_VERSION,
76
- "user-agent": USER_AGENT
77
- };
78
- }
79
70
  function payloadOf(result) {
80
71
  if (result.bodyKind === "empty") return null;
81
72
  if (result.bodyKind === "json") return result.data;
@@ -108,25 +99,35 @@ function githubError(response, payload) {
108
99
  }
109
100
  return upstreamError(response.status, message);
110
101
  }
102
+ var http = createAuthedClient({
103
+ baseUrl: `${API_BASE}/`,
104
+ service: SERVICE,
105
+ auth: { kind: "bearer" },
106
+ headers: {
107
+ "accept": "application/vnd.github+json",
108
+ "x-github-api-version": API_VERSION,
109
+ "user-agent": USER_AGENT
110
+ },
111
+ // 403 双职分账 + 422 validation 摘要,整段覆写而不用标准键序提取。
112
+ mapError: (context) => githubError(
113
+ {
114
+ headers: context.headers,
115
+ ok: false,
116
+ status: context.status,
117
+ statusText: context.statusText
118
+ },
119
+ payloadOf(context)
120
+ )
121
+ });
111
122
  async function requestRaw(ctx, input) {
112
- const result = await http.request({
123
+ const result = await http.request(ctx, {
113
124
  method: input.method ?? "GET",
114
125
  path: input.path,
115
126
  query: Object.entries(input.query ?? {}),
116
- headers: headers(ctx),
117
127
  ...input.body === void 0 ? {} : { json: input.body },
118
128
  invalidJson: "text",
119
129
  // GitHub 有三个 action 用 404 表达 false;其他调用方仍在下面将它映射为错误。
120
- acceptStatuses: [404],
121
- mapError: (context) => githubError(
122
- {
123
- headers: context.headers,
124
- ok: false,
125
- status: context.status,
126
- statusText: context.statusText
127
- },
128
- payloadOf(context)
129
- )
130
+ acceptStatuses: [404]
130
131
  });
131
132
  return {
132
133
  payload: payloadOf(result),
@@ -1,25 +1,24 @@
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
  } from "./chunk-JXHMDBAY.js";
7
8
  import {
8
9
  createProviderPlugin,
9
- requireApiKey,
10
10
  upstreamError
11
- } from "./chunk-6ANLYNFB.js";
12
- import "./chunk-3WL6EXYX.js";
11
+ } from "./chunk-ATK45BXV.js";
12
+ import "./chunk-U7B6DS2O.js";
13
13
  import {
14
14
  TBError,
15
15
  external_exports
16
- } from "./chunk-WIGQCP6O.js";
16
+ } from "./chunk-UZM2RXZH.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/gmail/api/shared.ts
20
20
  var SERVICE = "gmail";
21
21
  var API_BASE = "https://gmail.googleapis.com/gmail/v1";
22
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
23
22
  var USER_ID = "me";
24
23
  var RATE_LIMIT_REASONS = /* @__PURE__ */ new Set([
25
24
  "dailyLimitExceeded",
@@ -100,22 +99,23 @@ function gmailError(status, payload) {
100
99
  }
101
100
  return upstreamError(status, message);
102
101
  }
102
+ var http = createAuthedClient({
103
+ baseUrl: `${API_BASE}/`,
104
+ service: SERVICE,
105
+ auth: { kind: "bearer" },
106
+ mapError: ({ bodyKind, data, status }) => gmailError(
107
+ status,
108
+ bodyKind === "json" ? data : null
109
+ )
110
+ });
103
111
  async function send(ctx, input) {
104
112
  const hasBody = input.body !== void 0;
105
- const headers = {
106
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
107
- };
108
- const response = await http.request({
113
+ const response = await http.request(ctx, {
109
114
  method: input.method ?? "GET",
110
115
  path: buildPath(input.path),
111
116
  query: Object.entries(input.query ?? {}),
112
- headers,
113
117
  ...hasBody ? { json: input.body } : {},
114
- invalidJson: "text",
115
- mapError: ({ bodyKind, data, status }) => gmailError(
116
- status,
117
- bodyKind === "json" ? data : null
118
- )
118
+ invalidJson: "text"
119
119
  });
120
120
  if (response.bodyKind === "invalid-json") {
121
121
  throw new TBError("unavailable", "Gmail \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
  compactDefined,
@@ -8,14 +9,14 @@ 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
- external_exports
18
- } from "./chunk-WIGQCP6O.js";
17
+ external_exports,
18
+ isTBError
19
+ } from "./chunk-UZM2RXZH.js";
19
20
  import "./chunk-U67V476Y.js";
20
21
 
21
22
  // ../plugins/src/googlecalendar/api/shared.ts
@@ -23,7 +24,6 @@ var SERVICE = "googlecalendar";
23
24
  var API_BASE = "https://www.googleapis.com/calendar/v3";
24
25
  var REQUEST_TIMEOUT_MS = 3e4;
25
26
  var GOOGLE_API_ORIGIN = new URL(API_BASE).origin;
26
- var http = createProviderHttpClient({ baseUrl: `${GOOGLE_API_ORIGIN}/`, service: SERVICE });
27
27
  var MAX_ERROR_MESSAGE_LENGTH = 500;
28
28
  var RATE_LIMIT_REASONS = /* @__PURE__ */ new Set([
29
29
  "rateLimitExceeded",
@@ -102,22 +102,25 @@ function calendarError(context, syncTokenAware) {
102
102
  }
103
103
  return upstreamError(context.status, message);
104
104
  }
105
+ var http = createAuthedClient({
106
+ baseUrl: `${GOOGLE_API_ORIGIN}/`,
107
+ service: SERVICE,
108
+ auth: { kind: "bearer" },
109
+ headers: { accept: "application/json" },
110
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Google Calendar \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`) : upstreamError(502, `Google Calendar \u8BF7\u6C42\u5931\u8D25:${message ?? "unknown network error"}`)
111
+ });
105
112
  async function send(ctx, input) {
106
113
  const hasBody = input.body !== void 0;
107
114
  const target = requestTarget(input.url, input.query);
108
- return await http.request({
115
+ return await http.request(ctx, {
109
116
  method: input.method ?? (hasBody ? "POST" : "GET"),
110
117
  path: target.path,
111
118
  query: target.query,
112
- headers: {
113
- accept: "application/json",
114
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
115
- },
116
119
  ...hasBody ? { json: input.body } : {},
117
120
  invalidJson: "text",
118
121
  timeoutMs: REQUEST_TIMEOUT_MS,
119
- mapError: (context) => calendarError(context, input.syncTokenAware ?? false),
120
- mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Google Calendar \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`) : upstreamError(502, `Google Calendar \u8BF7\u6C42\u5931\u8D25:${message ?? "unknown network error"}`)
122
+ // 410 syncToken 解读随每次请求走(见文件头第 2 条),故 mapError 只能逐请求给。
123
+ mapError: (context) => calendarError(context, input.syncTokenAware ?? false)
121
124
  });
122
125
  }
123
126
  async function requestJson(ctx, input) {
@@ -401,7 +404,7 @@ async function deleteEvent(input, ctx) {
401
404
  method: "DELETE"
402
405
  });
403
406
  } catch (error) {
404
- if (error instanceof TBError && error.code === "not_found") return { success: true };
407
+ if (isTBError(error) && error.code === "not_found") return { success: true };
405
408
  throw error;
406
409
  }
407
410
  return { success: true };
@@ -781,7 +784,7 @@ function buildSummaryItem(event) {
781
784
  });
782
785
  }
783
786
  function mapCalendarError(error) {
784
- if (!(error instanceof TBError)) {
787
+ if (!isTBError(error)) {
785
788
  return { code: "provider_error", message: error instanceof Error ? error.message : String(error) };
786
789
  }
787
790
  if (error.code === "rate_limited") return { code: "rate_limited", message: error.message };
@@ -790,7 +793,7 @@ function mapCalendarError(error) {
790
793
  return { code: "provider_error", message: error.message };
791
794
  }
792
795
  function isUnauthenticated(error) {
793
- return error instanceof TBError && error.code === "permission_denied" && error.httpStatus === 401;
796
+ return isTBError(error) && error.code === "permission_denied" && error.httpStatus === 401;
794
797
  }
795
798
  async function listVisibleCalendars(ctx) {
796
799
  const calendars = [];
@@ -883,7 +886,7 @@ async function listEventsAllCalendars(input, ctx) {
883
886
  if (isUnauthenticated(error)) throw error;
884
887
  const mapped = mapCalendarError(error);
885
888
  errorsByCalendar[calendar.calendarId] = mapped;
886
- firstRecoverableError ??= error instanceof TBError ? error : upstreamError(502, mapped.message);
889
+ firstRecoverableError ??= isTBError(error) ? error : upstreamError(502, mapped.message);
887
890
  }
888
891
  }
889
892
  if (succeeded === 0) {