@tool-bridge/server 0.19.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-23JBIM6X.js → airtable-DMJEEGJP.js} +19 -16
  2. package/dist/{alt_text_generator_ai-ADWBTCIH.js → alt_text_generator_ai-RELFQ5FV.js} +4 -4
  3. package/dist/{amap-CYQCYW2Z.js → amap-YSYEACKQ.js} +4 -4
  4. package/dist/{anthropic-5P62HDNR.js → anthropic-D5X5GSYE.js} +23 -25
  5. package/dist/{apify-54RZUAGW.js → apify-5NVFU3IZ.js} +20 -19
  6. package/dist/{brave_search-AHJ6FTD5.js → brave_search-X557FMGO.js} +16 -14
  7. package/dist/chunk-JEWFX6Z6.js +71 -0
  8. package/dist/{chunk-CLEZ6YQ6.js → chunk-MDY7K5CX.js} +1090 -606
  9. package/dist/{chunk-OKRZPQ3R.js → chunk-MZCIPUNQ.js} +1002 -242
  10. package/dist/{chunk-VLOIDU5U.js → chunk-Q74GLIDK.js} +3 -3
  11. package/dist/{chunk-B4P6YZFS.js → chunk-QR4LK3HF.js} +1 -1
  12. package/dist/{chunk-SWBNHIO4.js → chunk-ZTTN6AJG.js} +1 -1
  13. package/dist/{circleci-UM3NSQJ3.js → circleci-3P3QTUX2.js} +20 -24
  14. package/dist/{clerk-FE5LQ2CZ.js → clerk-GNMZQ2MY.js} +22 -21
  15. package/dist/{cloudflare_dns-KEZABKUT.js → cloudflare_dns-VWZH3ZTR.js} +21 -17
  16. package/dist/{cohere-4IPJADXP.js → cohere-C7QVIIMG.js} +19 -17
  17. package/dist/{confluence-56QEKNQI.js → confluence-52I37IUT.js} +16 -11
  18. package/dist/{convertapi-3QRM5K5T.js → convertapi-3TRJ3WEO.js} +3 -3
  19. package/dist/{currencyapi-L6G4OND5.js → currencyapi-LWEANWVI.js} +23 -26
  20. package/dist/{deepseek-LGC6HBFG.js → deepseek-5U24YG4P.js} +27 -17
  21. package/dist/{docker_hub-XDMK3BIU.js → docker_hub-CMISLRSE.js} +4 -4
  22. package/dist/{dropbox-4QARMFZU.js → dropbox-TW4QN6FT.js} +9 -8
  23. package/dist/{dub-C6JSJKOT.js → dub-EFXGI5UH.js} +22 -19
  24. package/dist/{e2b-6A6TVACJ.js → e2b-PHM63OVF.js} +20 -20
  25. package/dist/{exa-SIWWW6AA.js → exa-DYOQWURR.js} +22 -25
  26. package/dist/{fal_ai-3IJXOKSP.js → fal_ai-VJPMCNRH.js} +18 -17
  27. package/dist/{feishu-L4KDA4DC.js → feishu-TFIZXPIN.js} +2 -2
  28. package/dist/{feishu_custom_bot-SDM75H4P.js → feishu_custom_bot-ADSE23KU.js} +3 -3
  29. package/dist/{figma-6DD436DN.js → figma-4AK47AYY.js} +21 -23
  30. package/dist/{firehydrant-SYSGYB3R.js → firehydrant-RGPTW4EA.js} +15 -15
  31. package/dist/{fixer-FZG7ASTF.js → fixer-OAMF4DKP.js} +4 -4
  32. package/dist/{fly-HMRCZBUC.js → fly-YB4AQD4O.js} +20 -16
  33. package/dist/{front-FAFSD7I3.js → front-6GTVYKUM.js} +20 -23
  34. package/dist/{geocodio-4D3TWENM.js → geocodio-YRT4K25M.js} +4 -4
  35. package/dist/{ghost-OSO2FOZS.js → ghost-JCW6UIP2.js} +4 -4
  36. package/dist/{github-OR4I4RHE.js → github-CEGVRMNX.js} +28 -27
  37. package/dist/{gmail-5AOPJ63E.js → gmail-JCMJD55P.js} +17 -17
  38. package/dist/{googlecalendar-SOJIJUWH.js → googlecalendar-2EAW4MNM.js} +16 -14
  39. package/dist/{googledocs-QSKN5TLN.js → googledocs-YNKKBM6Q.js} +3 -3
  40. package/dist/{grafana-R3AIZM7M.js → grafana-353VSGXN.js} +24 -25
  41. package/dist/{graphhopper-4CR3QOAX.js → graphhopper-H3IVJNDS.js} +4 -4
  42. package/dist/index.d.ts +52 -36
  43. package/dist/index.js +3 -3
  44. package/dist/{ip2proxy-OBCG6X6J.js → ip2proxy-DBGRWH7S.js} +4 -4
  45. package/dist/{ipgeolocation_io-NHH3DTQW.js → ipgeolocation_io-5I2BDVMG.js} +4 -4
  46. package/dist/{ipqualityscore-7POMCBEC.js → ipqualityscore-ILV7TQCV.js} +4 -4
  47. package/dist/{jina_ai-YXVKROV4.js → jina_ai-L5BH455V.js} +20 -21
  48. package/dist/{jira-LADO3VJU.js → jira-IGTILUZA.js} +20 -16
  49. package/dist/{langsmith-XZ6UAQFU.js → langsmith-BYRX4AOF.js} +25 -25
  50. package/dist/{lemlist-P74GLNE7.js → lemlist-ZGNYTIQO.js} +23 -24
  51. package/dist/{linear-CXJ7D37A.js → linear-HLGOWISN.js} +3 -3
  52. package/dist/{logsnag-EVVHWFLK.js → logsnag-5RGTMTU2.js} +20 -22
  53. package/dist/main.js +102 -102
  54. package/dist/{mattermost-WG2MRGBD.js → mattermost-BONGXVC7.js} +21 -17
  55. package/dist/{mem0-HQWUKG6U.js → mem0-RUVNUPTE.js} +15 -15
  56. package/dist/{memos-SQMJIFOE.js → memos-TED4HI54.js} +36 -32
  57. package/dist/{metabase-E27G2DZI.js → metabase-ZHXHRHZK.js} +22 -18
  58. package/dist/{mistral_ai-MIL63NIT.js → mistral_ai-NGP5SHU7.js} +24 -21
  59. package/dist/{mother_duck-AIZVCBNR.js → mother_duck-TKVQM35M.js} +23 -19
  60. package/dist/{ngrok-XS4DVIQS.js → ngrok-BYCUJ7QV.js} +17 -22
  61. package/dist/{notes-JEOUSL2Y.js → notes-KXRNNYDW.js} +1 -1
  62. package/dist/{notion-U4EZVDW2.js → notion-2ILYKJOO.js} +20 -17
  63. package/dist/{open_exchange_rates-AZSQEYEJ.js → open_exchange_rates-JU4DC6HZ.js} +4 -4
  64. package/dist/{openai-HW3SYMTQ.js → openai-6SOT26ZK.js} +22 -16
  65. package/dist/{opengraph_io-QX74MAEL.js → opengraph_io-ZEFHV2OL.js} +4 -4
  66. package/dist/{openrouter-OXSKYL6N.js → openrouter-R4P7JL5L.js} +19 -14
  67. package/dist/{outline-CCQAPDSW.js → outline-VCTQ5V2X.js} +18 -20
  68. package/dist/{paddle-6KQPSSCK.js → paddle-AZOAKBJS.js} +17 -15
  69. package/dist/{perplexity-2TXO7IQE.js → perplexity-OMRLGVAT.js} +19 -23
  70. package/dist/{pinecone-YOO7NULI.js → pinecone-DI62W3ZX.js} +19 -24
  71. package/dist/{pipedrive-Q6RIFIFP.js → pipedrive-CW7HONYW.js} +22 -23
  72. package/dist/{polar-KUMGCES3.js → polar-5DRGTXNR.js} +19 -17
  73. package/dist/{posthog-VXQHBSMB.js → posthog-3DTHFCKE.js} +29 -24
  74. package/dist/{postmark-YLIPF52S.js → postmark-ME2V2XXI.js} +19 -17
  75. package/dist/{prerender-CRY7UJN5.js → prerender-5EAY7GDM.js} +4 -4
  76. package/dist/{pubmed-3Z4T5AM7.js → pubmed-GRQUBGVA.js} +3 -3
  77. package/dist/{railway-BP37IGFL.js → railway-FTM75TMX.js} +3 -3
  78. package/dist/{readwise-HTKICF4K.js → readwise-IJQGV6IQ.js} +16 -15
  79. package/dist/{render-WIVTUXJH.js → render-TMSPHRTY.js} +21 -20
  80. package/dist/{replicate-JJYPA43D.js → replicate-RJCMDB7H.js} +20 -21
  81. package/dist/{resend-TKHZVG7A.js → resend-YYN22NIL.js} +15 -11
  82. package/dist/{rootly-FRSZLG5U.js → rootly-7RXE4K7L.js} +19 -18
  83. package/dist/{scrapfly-M5WXGQWE.js → scrapfly-ZJJ6XM4Q.js} +4 -4
  84. package/dist/{scrapingbee-PMXNLLBK.js → scrapingbee-QNGEOD6D.js} +4 -4
  85. package/dist/{screenshot_fyi-HFW4TAOH.js → screenshot_fyi-SPZAABVD.js} +4 -4
  86. package/dist/{semantic_scholar-KXVH2VZQ.js → semantic_scholar-SDPVGDDI.js} +21 -20
  87. package/dist/{sentry-WWOT2LRX.js → sentry-SJ5NN4C4.js} +22 -19
  88. package/dist/{shodan-FY635H35.js → shodan-YMGOY7KW.js} +4 -4
  89. package/dist/{shopify-HQLBVSA5.js → shopify-SU5ABP54.js} +23 -19
  90. package/dist/{stripe-GJN2GOHB.js → stripe-JAC425KE.js} +3 -3
  91. package/dist/{supabase-BBNZGQU6.js → supabase-GQ2OFVIL.js} +18 -17
  92. package/dist/{tavily-DPENIBOG.js → tavily-Y7MDA5CI.js} +20 -20
  93. package/dist/{telegram-L4NONG6H.js → telegram-OIDT3ZLH.js} +4 -4
  94. package/dist/{telnyx-H67MAEZS.js → telnyx-4JGMC3K7.js} +19 -19
  95. package/dist/{todoist-G2BSP4DX.js → todoist-O7S2OUGX.js} +18 -17
  96. package/dist/{trello-7WMVFDG2.js → trello-3LDE4TAQ.js} +4 -4
  97. package/dist/{turso-ZUAESFC2.js → turso-MUQ44KCA.js} +23 -30
  98. package/dist/{twilio-EYFYIX3B.js → twilio-VYF3HUU6.js} +3 -3
  99. package/dist/{umami-AXAUDUVF.js → umami-SVQIK26J.js} +23 -28
  100. package/dist/{unsplash-UCQAWPLR.js → unsplash-333XYDCJ.js} +19 -18
  101. package/dist/{upstash_redis-ZPZ4ASU6.js → upstash_redis-IUM2HDLU.js} +17 -13
  102. package/dist/{uptimerobot-4QVKKUD5.js → uptimerobot-7ZRU2NJV.js} +3 -3
  103. package/dist/{v2ex-VGEFJTYC.js → v2ex-AVSJCQPS.js} +35 -18
  104. package/dist/{vercel-JME4TSCN.js → vercel-J7RGXNSA.js} +21 -18
  105. package/dist/{wolfram_alpha_api-TRGU2MDG.js → wolfram_alpha_api-6CRVUZOJ.js} +4 -4
  106. package/dist/{wordpress-WRUKLCZR.js → wordpress-THOJLPKA.js} +21 -17
  107. package/dist/{workos-ZDW4EHS4.js → workos-ENTGRWF2.js} +26 -27
  108. package/dist/{zhihu-4VI67CWU.js → zhihu-W2BXICTX.js} +21 -21
  109. package/package.json +3 -3
@@ -1,26 +1,25 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.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-B4P6YZFS.js";
13
- import "./chunk-SWBNHIO4.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/polar/api.ts
21
21
  var SERVICE = "polar";
22
22
  var API_BASE = "https://api.polar.sh/v1";
23
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
24
23
  function requireRecord(value, label) {
25
24
  const result = asJsonObject(value);
26
25
  if (result === void 0) throw new TBError("unavailable", `Polar \u7684${label}\u4E0D\u662F\u5BF9\u8C61`, { retryable: true });
@@ -74,20 +73,23 @@ function errorDetail(payload) {
74
73
  }
75
74
  return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.title);
76
75
  }
76
+ var http = createAuthedClient({
77
+ baseUrl: `${API_BASE}/`,
78
+ service: SERVICE,
79
+ auth: { kind: "bearer" },
80
+ headers: { accept: "application/json" },
81
+ // detail 可能是 FastAPI 校验错误数组(取 `detail[0].msg`),标准键序提取表达不了,整段覆写。
82
+ mapError: ({ data: payload, status }) => upstreamError(
83
+ status,
84
+ errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
85
+ )
86
+ });
77
87
  async function request(ctx, path, query) {
78
- const { data } = await http.request({
88
+ const { data } = await http.request(ctx, {
79
89
  path,
80
90
  method: "GET",
81
91
  query,
82
- headers: {
83
- accept: "application/json",
84
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
85
- },
86
- invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
87
- mapError: ({ data: payload, status }) => upstreamError(
88
- status,
89
- errorDetail(payload) ?? `Polar \u8FD4\u56DE HTTP ${status}`
90
- )
92
+ invalidJsonMessage: "Polar \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
91
93
  });
92
94
  return data ?? null;
93
95
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  booleanValue,
6
7
  compactDefined
@@ -9,20 +10,19 @@ import {
9
10
  createProviderPlugin,
10
11
  requireApiKey,
11
12
  upstreamError
12
- } from "./chunk-B4P6YZFS.js";
13
+ } from "./chunk-QR4LK3HF.js";
13
14
  import {
14
15
  assertPublicHttpUrl
15
- } from "./chunk-SWBNHIO4.js";
16
+ } from "./chunk-ZTTN6AJG.js";
16
17
  import {
17
18
  TBError,
18
19
  external_exports
19
- } from "./chunk-OKRZPQ3R.js";
20
+ } from "./chunk-MZCIPUNQ.js";
20
21
  import "./chunk-U67V476Y.js";
21
22
 
22
23
  // ../plugins/src/posthog/api.ts
23
24
  var SERVICE = "posthog";
24
25
  var CURRENT_USER_PATH = "/api/users/@me/";
25
- var http = createProviderHttpClient({ service: SERVICE });
26
26
  function str(value) {
27
27
  return typeof value === "string" ? value : void 0;
28
28
  }
@@ -111,8 +111,8 @@ function resolveBaseUrl(ctx) {
111
111
  return `${parsed.origin}${path}`;
112
112
  }
113
113
  function resolveAuth(ctx) {
114
- const token = requireApiKey(ctx, SERVICE);
115
- return { baseUrl: resolveBaseUrl(ctx), token };
114
+ requireApiKey(ctx, SERVICE);
115
+ return resolveBaseUrl(ctx);
116
116
  }
117
117
  function posthogError(status, payload, fallback) {
118
118
  const body = nullableRecord(payload);
@@ -123,27 +123,32 @@ function posthogError(status, payload, fallback) {
123
123
  function responsePayload(data, bodyKind) {
124
124
  return bodyKind === "json" ? data : void 0;
125
125
  }
126
+ var http = createAuthedClient({
127
+ service: SERVICE,
128
+ auth: { kind: "bearer" },
129
+ // 迁移前 GET 也带 content-type,保留真实 wire。
130
+ headers: { "content-type": "application/json" },
131
+ // DRF 的 attr 要拼进消息尾巴,标准键序提取表达不了,整段覆写。
132
+ mapError: ({ bodyKind, data, status }) => posthogError(
133
+ status,
134
+ bodyKind === "json" ? data : void 0,
135
+ bodyKind === "empty" ? `${SERVICE} \u8FD4\u56DE HTTP ${status}` : String(data)
136
+ ),
137
+ mapTransportError: ({ message }) => new TBError(
138
+ "unavailable",
139
+ `${SERVICE} \u8BF7\u6C42\u5931\u8D25:${message ?? "undefined"}`,
140
+ { retryable: true }
141
+ )
142
+ });
126
143
  async function request(ctx, options) {
127
- const auth = resolveAuth(ctx);
128
- const result = await http.request({
129
- baseUrl: `${auth.baseUrl}/`,
144
+ const baseUrl = resolveAuth(ctx);
145
+ const result = await http.request(ctx, {
146
+ baseUrl: `${baseUrl}/`,
130
147
  path: options.path,
131
148
  method: options.method ?? "GET",
132
149
  query: Object.entries(options.query ?? {}),
133
- // 迁移前 GET 也带 content-type,保留真实 wire。
134
- headers: { "authorization": `Bearer ${auth.token}`, "content-type": "application/json" },
135
150
  ...options.body === void 0 ? {} : { json: options.body },
136
- invalidJson: "text",
137
- mapError: ({ bodyKind, data, status }) => posthogError(
138
- status,
139
- bodyKind === "json" ? data : void 0,
140
- bodyKind === "empty" ? `${SERVICE} \u8FD4\u56DE HTTP ${status}` : String(data)
141
- ),
142
- mapTransportError: ({ message }) => new TBError(
143
- "unavailable",
144
- `${SERVICE} \u8BF7\u6C42\u5931\u8D25:${message ?? "undefined"}`,
145
- { retryable: true }
146
- )
151
+ invalidJson: "text"
147
152
  });
148
153
  return responsePayload(result.data, result.bodyKind);
149
154
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,20 +9,18 @@ import {
8
9
  } from "./chunk-JXHMDBAY.js";
9
10
  import {
10
11
  createProviderPlugin,
11
- requireApiKey,
12
12
  upstreamError
13
- } from "./chunk-B4P6YZFS.js";
14
- import "./chunk-SWBNHIO4.js";
13
+ } from "./chunk-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-OKRZPQ3R.js";
18
+ } from "./chunk-MZCIPUNQ.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/postmark/api.ts
22
22
  var SERVICE = "postmark";
23
23
  var API_BASE = "https://api.postmarkapp.com";
24
- var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
25
24
  var INVALID_TOKEN_CODE = 10;
26
25
  var NOT_FOUND_CODES = /* @__PURE__ */ new Set([12, 701, 1001, 1101]);
27
26
  var ACCOUNT_BLOCKED_CODES = /* @__PURE__ */ new Set([405, 412, 413]);
@@ -47,21 +46,24 @@ function postmarkError(status, payload) {
47
46
  }
48
47
  return upstreamError(status, message);
49
48
  }
49
+ var http = createAuthedClient({
50
+ baseUrl: API_BASE,
51
+ service: SERVICE,
52
+ auth: { kind: "header", name: "x-postmark-server-token" },
53
+ headers: { accept: "application/json" },
54
+ // ErrorCode 码表比 HTTP 状态准(见文件头),整段覆写而不用标准键序提取。
55
+ mapError: ({ bodyKind, data: payload, status }) => postmarkError(
56
+ status,
57
+ bodyKind === "json" ? asJsonObject(payload) ?? {} : bodyKind === "empty" ? {} : { Message: payload }
58
+ )
59
+ });
50
60
  async function request(ctx, input) {
51
- const { data } = await http.request({
61
+ const { data } = await http.request(ctx, {
52
62
  path: input.path,
53
63
  method: input.method ?? "GET",
54
64
  query: Object.entries(input.query ?? {}),
55
- headers: {
56
- "accept": "application/json",
57
- "x-postmark-server-token": requireApiKey(ctx, SERVICE)
58
- },
59
65
  ...input.body === void 0 ? {} : { json: input.body },
60
- invalidJsonMessage: "Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
61
- mapError: ({ bodyKind, data: payload, status }) => postmarkError(
62
- status,
63
- bodyKind === "json" ? asJsonObject(payload) ?? {} : bodyKind === "empty" ? {} : { Message: payload }
64
- )
66
+ invalidJsonMessage: "Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
65
67
  });
66
68
  if (data === void 0) throw responseError("Postmark \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94");
67
69
  return data;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.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-B4P6YZFS.js";
13
- import "./chunk-SWBNHIO4.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/prerender/api.ts
@@ -8,14 +8,14 @@ import {
8
8
  import {
9
9
  createProviderPlugin,
10
10
  upstreamError
11
- } from "./chunk-B4P6YZFS.js";
11
+ } from "./chunk-QR4LK3HF.js";
12
12
  import {
13
13
  guardedFetch
14
- } from "./chunk-SWBNHIO4.js";
14
+ } from "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  TBError,
17
17
  external_exports
18
- } from "./chunk-OKRZPQ3R.js";
18
+ } from "./chunk-MZCIPUNQ.js";
19
19
  import "./chunk-U67V476Y.js";
20
20
 
21
21
  // ../plugins/src/pubmed/api.ts
@@ -7,14 +7,14 @@ import {
7
7
  createProviderPlugin,
8
8
  requireApiKey,
9
9
  upstreamError
10
- } from "./chunk-B4P6YZFS.js";
10
+ } from "./chunk-QR4LK3HF.js";
11
11
  import {
12
12
  guardedFetch
13
- } from "./chunk-SWBNHIO4.js";
13
+ } from "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/railway/api.ts
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -9,20 +10,18 @@ import {
9
10
  } from "./chunk-JXHMDBAY.js";
10
11
  import {
11
12
  createProviderPlugin,
12
- requireApiKey,
13
13
  upstreamError
14
- } from "./chunk-B4P6YZFS.js";
15
- import "./chunk-SWBNHIO4.js";
14
+ } from "./chunk-QR4LK3HF.js";
15
+ import "./chunk-ZTTN6AJG.js";
16
16
  import {
17
17
  TBError,
18
18
  external_exports
19
- } from "./chunk-OKRZPQ3R.js";
19
+ } from "./chunk-MZCIPUNQ.js";
20
20
  import "./chunk-U67V476Y.js";
21
21
 
22
22
  // ../plugins/src/readwise/api.ts
23
23
  var SERVICE = "readwise";
24
24
  var API_BASE = "https://readwise.io/api";
25
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
26
25
  function readArray(value) {
27
26
  return Array.isArray(value) ? value : [];
28
27
  }
@@ -40,19 +39,21 @@ function errorMessage(payload, status) {
40
39
  }
41
40
  return `Readwise request failed with status ${status}`;
42
41
  }
42
+ var http = createAuthedClient({
43
+ baseUrl: `${API_BASE}/`,
44
+ service: SERVICE,
45
+ // Readwise 用的是 `Token <key>`,不是 Bearer —— 写成 Bearer 会一直 401。
46
+ auth: { kind: "token" },
47
+ headers: { accept: "application/json" },
48
+ mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(data, status))
49
+ });
43
50
  async function request(ctx, input) {
44
- const response = await http.request({
51
+ const response = await http.request(ctx, {
45
52
  method: input.method ?? "GET",
46
53
  path: input.path,
47
54
  query: Object.entries(input.query ?? {}),
48
- headers: {
49
- accept: "application/json",
50
- // Readwise 用的是 `Token <key>`,不是 Bearer —— 写成 Bearer 会一直 401。
51
- authorization: `Token ${requireApiKey(ctx, SERVICE)}`
52
- },
53
55
  ...input.body === void 0 ? {} : { json: input.body },
54
- invalidJsonMessage: "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON",
55
- mapError: ({ bodyKind, data, status }) => bodyKind === "invalid-json" ? new TBError("unavailable", "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON", { retryable: true }) : upstreamError(status, errorMessage(data, status))
56
+ invalidJsonMessage: "Readwise \u8FD4\u56DE\u4E86\u975E\u6CD5 JSON"
56
57
  });
57
58
  return response.bodyKind === "empty" ? {} : response.data;
58
59
  }
@@ -1,25 +1,24 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  trimmedText
6
7
  } from "./chunk-JXHMDBAY.js";
7
8
  import {
8
9
  createProviderPlugin,
9
- requireApiKey,
10
10
  upstreamError
11
- } from "./chunk-B4P6YZFS.js";
12
- import "./chunk-SWBNHIO4.js";
11
+ } from "./chunk-QR4LK3HF.js";
12
+ import "./chunk-ZTTN6AJG.js";
13
13
  import {
14
14
  TBError,
15
15
  external_exports
16
- } from "./chunk-OKRZPQ3R.js";
16
+ } from "./chunk-MZCIPUNQ.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/render/api.ts
20
20
  var SERVICE = "render";
21
21
  var API_BASE = "https://api.render.com/v1";
22
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
23
22
  function pathSegment(value, field) {
24
23
  const parsed = trimmedText(value);
25
24
  if (parsed === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
@@ -51,28 +50,30 @@ function errorMessage(context) {
51
50
  }
52
51
  return `Render \u8FD4\u56DE HTTP ${context.status}`;
53
52
  }
53
+ var http = createAuthedClient({
54
+ baseUrl: `${API_BASE}/`,
55
+ service: SERVICE,
56
+ auth: { kind: "bearer" },
57
+ headers: { accept: "application/json" },
58
+ // errors 数组与 bodyKind 分叉(非 JSON 原文 String 化不 trim),标准键序提取表达不了,整段覆写。
59
+ mapError: (context) => upstreamError(context.status, errorMessage(context)),
60
+ mapTransportError: ({ message }) => new TBError(
61
+ "unavailable",
62
+ message === void 0 ? "Render \u8BF7\u6C42\u5931\u8D25" : `Render \u8BF7\u6C42\u5931\u8D25: ${message}`,
63
+ { retryable: true }
64
+ )
65
+ });
54
66
  async function send(ctx, input) {
55
- const apiKey = requireApiKey(ctx, SERVICE);
56
67
  const query = Object.entries(input.query ?? {}).flatMap(([key, value]) => {
57
68
  if (Array.isArray(value)) return value.length === 0 ? [] : [[key, value.join(",")]];
58
69
  return [[key, value]];
59
70
  });
60
- return await http.request({
71
+ return await http.request(ctx, {
61
72
  method: input.method ?? "GET",
62
73
  path: input.path,
63
74
  query,
64
- headers: {
65
- accept: "application/json",
66
- authorization: `Bearer ${apiKey}`
67
- },
68
75
  ...input.body === void 0 ? {} : { json: input.body },
69
- invalidJson: "text",
70
- mapError: (context) => upstreamError(context.status, errorMessage(context)),
71
- mapTransportError: ({ message }) => new TBError(
72
- "unavailable",
73
- message === void 0 ? "Render \u8BF7\u6C42\u5931\u8D25" : `Render \u8BF7\u6C42\u5931\u8D25: ${message}`,
74
- { retryable: true }
75
- )
76
+ invalidJson: "text"
76
77
  });
77
78
  }
78
79
  async function requestJson(ctx, input) {
@@ -1,28 +1,36 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.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-B4P6YZFS.js";
14
- import "./chunk-SWBNHIO4.js";
11
+ createProviderPlugin
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
15
14
  import {
16
15
  TBError,
17
16
  external_exports
18
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
19
18
  import "./chunk-U67V476Y.js";
20
19
 
21
20
  // ../plugins/src/replicate/api.ts
22
21
  var SERVICE = "replicate";
23
22
  var API_BASE = "https://api.replicate.com";
24
23
  var ACCOUNT_PATH = "/v1/account";
25
- 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
+ keys: ["detail", "title"],
31
+ fallback: (status) => `Replicate \u8FD4\u56DE HTTP ${status}`
32
+ }
33
+ });
26
34
  function required(value, field) {
27
35
  const trimmed = trimmedText(value);
28
36
  if (trimmed === void 0) throw new TBError("invalid_argument", `${field} \u4E0D\u80FD\u4E3A\u7A7A`);
@@ -32,23 +40,14 @@ function segment(value, field) {
32
40
  return encodeURIComponent(required(value, field));
33
41
  }
34
42
  async function request(ctx, input) {
35
- const headers = {
36
- accept: "application/json",
37
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`,
38
- ...input.headers
39
- };
40
- const response = await http.request({
43
+ const response = await http.request(ctx, {
41
44
  method: input.method ?? "GET",
42
45
  path: input.path,
43
46
  // 上游这里连空串一起跳过(空的 created_after 打出去会被上游当成非法时间戳)。
44
47
  query: Object.entries(input.query ?? {}).filter(([, value]) => value !== void 0 && value !== ""),
45
- headers,
48
+ headers: input.headers,
46
49
  ...input.body === void 0 ? {} : { json: input.body },
47
- invalidJson: "text",
48
- mapError: ({ bodyKind, data, status }) => {
49
- const body = bodyKind === "json" ? asJsonObject(data) ?? {} : { detail: data };
50
- return upstreamError(status, trimmedText(body.detail) ?? trimmedText(body.title) ?? `Replicate \u8FD4\u56DE HTTP ${status}`);
51
- }
50
+ invalidJson: "text"
52
51
  });
53
52
  if (response.bodyKind === "empty") return {};
54
53
  if (response.bodyKind !== "json") {
@@ -1,20 +1,20 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.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-B4P6YZFS.js";
13
- import "./chunk-SWBNHIO4.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
+ import "./chunk-ZTTN6AJG.js";
14
14
  import {
15
15
  TBError,
16
16
  external_exports
17
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/resend/schema.handwritten.ts
@@ -45,7 +45,6 @@ var resendActions = {
45
45
  // ../plugins/src/resend/api.ts
46
46
  var SERVICE = "resend";
47
47
  var AUTH_ERROR_NAMES = /* @__PURE__ */ new Set(["invalid_api_key", "missing_api_key"]);
48
- var http = createProviderHttpClient({ baseUrl: "https://api.resend.com/", service: SERVICE });
49
48
  function payloadOf(data) {
50
49
  return asJsonObject(data) ?? (typeof data === "string" ? { message: data } : {});
51
50
  }
@@ -55,11 +54,17 @@ function resendError(status, data) {
55
54
  const message = trimmedText(payload.message) ?? trimmedText(payload.error_description) ?? `Resend \u8FD4\u56DE HTTP ${status}`;
56
55
  return AUTH_ERROR_NAMES.has(name) ? new TBError("permission_denied", message, { httpStatus: 401 }) : upstreamError(status, message);
57
56
  }
57
+ var http = createAuthedClient({
58
+ baseUrl: "https://api.resend.com/",
59
+ service: SERVICE,
60
+ auth: { kind: "bearer" },
61
+ // 错误码表(invalid_api_key 等改判 permission_denied),整段覆写而不用标准键序提取。
62
+ mapError: ({ data: payload, status }) => resendError(status, payload)
63
+ });
58
64
  async function sendEmail(input, ctx) {
59
- const { data } = await http.request({
65
+ const { data } = await http.request(ctx, {
60
66
  path: "emails",
61
67
  method: "POST",
62
- headers: { authorization: `Bearer ${requireApiKey(ctx, SERVICE)}` },
63
68
  json: {
64
69
  from: input.from,
65
70
  to: input.to,
@@ -67,8 +72,7 @@ async function sendEmail(input, ctx) {
67
72
  ...input.html === void 0 ? {} : { html: input.html },
68
73
  ...input.text === void 0 ? {} : { text: input.text }
69
74
  },
70
- invalidJson: "text",
71
- mapError: ({ data: payload, status }) => resendError(status, payload)
75
+ invalidJson: "text"
72
76
  });
73
77
  const emailId = trimmedText(payloadOf(data).id);
74
78
  if (emailId === void 0) {
@@ -1,6 +1,7 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.js";
4
5
  import {
5
6
  asJsonObject,
6
7
  compactDefined,
@@ -8,20 +9,18 @@ import {
8
9
  } from "./chunk-JXHMDBAY.js";
9
10
  import {
10
11
  createProviderPlugin,
11
- requireApiKey,
12
12
  upstreamError
13
- } from "./chunk-B4P6YZFS.js";
14
- import "./chunk-SWBNHIO4.js";
13
+ } from "./chunk-QR4LK3HF.js";
14
+ import "./chunk-ZTTN6AJG.js";
15
15
  import {
16
16
  external_exports
17
- } from "./chunk-OKRZPQ3R.js";
17
+ } from "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
 
20
20
  // ../plugins/src/rootly/api.ts
21
21
  var SERVICE = "rootly";
22
22
  var API_BASE = "https://api.rootly.com/v1";
23
23
  var JSON_API_CONTENT_TYPE = "application/vnd.api+json";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
24
  function requireRecord(value, label) {
26
25
  const record = asJsonObject(value);
27
26
  if (record === void 0) throw upstreamError(502, `${label} was not an object`);
@@ -33,20 +32,22 @@ function errorMessage(payload, status) {
33
32
  const first = asJsonObject(errors[0]);
34
33
  return trimmedText(first?.detail) ?? trimmedText(first?.title) ?? `Rootly request failed with ${status}`;
35
34
  }
35
+ var http = createAuthedClient({
36
+ baseUrl: `${API_BASE}/`,
37
+ service: SERVICE,
38
+ auth: { kind: "bearer" },
39
+ headers: { "accept": JSON_API_CONTENT_TYPE, "content-type": JSON_API_CONTENT_TYPE },
40
+ // JSON:API 的消息在 `errors[0].detail/title`,非 JSON 体还要包成同形再提取,整段覆写。
41
+ mapError: ({ bodyKind, data, status }) => upstreamError(
42
+ status,
43
+ errorMessage(bodyKind === "json" ? data : { errors: [{ detail: data }] }, status)
44
+ )
45
+ });
36
46
  async function requestJson(ctx, path, query) {
37
- const response = await http.request({
47
+ const response = await http.request(ctx, {
38
48
  path,
39
49
  query: Object.entries(query),
40
- headers: {
41
- "accept": JSON_API_CONTENT_TYPE,
42
- "authorization": `Bearer ${requireApiKey(ctx, SERVICE)}`,
43
- "content-type": JSON_API_CONTENT_TYPE
44
- },
45
- invalidJson: "text",
46
- mapError: ({ bodyKind, data, status }) => upstreamError(
47
- status,
48
- errorMessage(bodyKind === "json" ? data : { errors: [{ detail: data }] }, status)
49
- )
50
+ invalidJson: "text"
50
51
  });
51
52
  if (response.bodyKind === "empty") return {};
52
53
  if (response.bodyKind !== "json") throw upstreamError(502, "Rootly returned invalid JSON");
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-VLOIDU5U.js";
3
+ } from "./chunk-Q74GLIDK.js";
4
4
  import "./chunk-JXHMDBAY.js";
5
5
  import {
6
6
  createProviderPlugin,
7
7
  requireApiKey,
8
8
  upstreamError
9
- } from "./chunk-B4P6YZFS.js";
10
- import "./chunk-SWBNHIO4.js";
9
+ } from "./chunk-QR4LK3HF.js";
10
+ import "./chunk-ZTTN6AJG.js";
11
11
  import {
12
12
  TBError,
13
13
  external_exports
14
- } from "./chunk-OKRZPQ3R.js";
14
+ } from "./chunk-MZCIPUNQ.js";
15
15
  import "./chunk-U67V476Y.js";
16
16
 
17
17
  // ../plugins/src/scrapfly/api.ts