@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
@@ -9,14 +9,15 @@ import {
9
9
  createProviderPlugin,
10
10
  requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-6ANLYNFB.js";
12
+ } from "./chunk-ATK45BXV.js";
13
13
  import {
14
14
  guardedFetch
15
- } from "./chunk-3WL6EXYX.js";
15
+ } from "./chunk-U7B6DS2O.js";
16
16
  import {
17
17
  TBError,
18
- external_exports
19
- } from "./chunk-WIGQCP6O.js";
18
+ external_exports,
19
+ isTBError
20
+ } from "./chunk-UZM2RXZH.js";
20
21
  import "./chunk-U67V476Y.js";
21
22
 
22
23
  // ../plugins/src/googledocs/api/shared.ts
@@ -157,7 +158,7 @@ async function send(ctx, input) {
157
158
  signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
158
159
  });
159
160
  } catch (error) {
160
- if (error instanceof TBError) throw error;
161
+ if (isTBError(error)) throw error;
161
162
  if (error instanceof Error && error.name === "TimeoutError") {
162
163
  throw upstreamError(504, `Google Docs \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`);
163
164
  }
@@ -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
  booleanValue,
@@ -12,14 +13,14 @@ import {
12
13
  createProviderPlugin,
13
14
  requireApiKey,
14
15
  upstreamError
15
- } from "./chunk-6ANLYNFB.js";
16
+ } from "./chunk-ATK45BXV.js";
16
17
  import {
17
18
  assertPublicHttpUrl
18
- } from "./chunk-3WL6EXYX.js";
19
+ } from "./chunk-U7B6DS2O.js";
19
20
  import {
20
21
  TBError,
21
22
  external_exports
22
- } from "./chunk-WIGQCP6O.js";
23
+ } from "./chunk-UZM2RXZH.js";
23
24
  import "./chunk-U67V476Y.js";
24
25
 
25
26
  // ../plugins/src/grafana/api.ts
@@ -33,7 +34,20 @@ var API_GROUPS = {
33
34
  folders: "folder.grafana.app"
34
35
  };
35
36
  var API_VERSION_CACHE_MAX = 256;
36
- var http = createProviderHttpClient({ service: SERVICE });
37
+ var http = createAuthedClient({
38
+ service: SERVICE,
39
+ auth: { kind: "bearer" },
40
+ headers: { accept: "application/json" },
41
+ // Grafana 的错误消息在 `message` / `error` / `detail` / `title` 之一,或整个体就是一段文本。
42
+ errorMessage: {
43
+ keys: ["message", "error", "detail", "title"],
44
+ fallback: (status, statusText) => trimmedText(statusText) ?? `Grafana request failed with ${status}`
45
+ },
46
+ mapTransportError: ({ message }) => upstreamError(
47
+ 502,
48
+ `Grafana request failed: ${message ?? "unknown network error"}`
49
+ )
50
+ });
37
51
  var apiVersionCache = /* @__PURE__ */ new Map();
38
52
  function requireText(value, field) {
39
53
  const result = trimmedText(value);
@@ -86,37 +100,22 @@ function resolveBaseUrl(ctx) {
86
100
  return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
87
101
  }
88
102
  function resolveTarget(ctx) {
89
- return { apiKey: requireApiKey(ctx, SERVICE), baseUrl: resolveBaseUrl(ctx) };
90
- }
91
- function errorMessage(payload, status, statusText) {
92
- const direct = trimmedText(payload);
93
- if (direct !== void 0) return direct;
94
- const fields = asJsonObject(payload);
95
- const message = trimmedText(fields?.message) ?? trimmedText(fields?.error) ?? trimmedText(fields?.detail) ?? trimmedText(fields?.title);
96
- return message ?? trimmedText(statusText) ?? `Grafana request failed with ${status}`;
103
+ requireApiKey(ctx, SERVICE);
104
+ return { baseUrl: resolveBaseUrl(ctx), ctx };
97
105
  }
98
106
  async function request(target, input) {
99
107
  const query = [
100
108
  ...Object.entries(input.query ?? {}),
101
109
  ...Object.entries(input.multiValueQuery ?? {})
102
110
  ];
103
- const result = await http.request({
111
+ const result = await http.request(target.ctx, {
104
112
  // 尾斜杠保住实例部署上下文路径(`/grafana`);薄层再强制 path 不得换 origin。
105
113
  baseUrl: `${target.baseUrl}/`,
106
114
  path: input.path,
107
115
  method: input.method,
108
116
  query,
109
- headers: { accept: "application/json", authorization: `Bearer ${target.apiKey}` },
110
117
  ...input.body === void 0 ? {} : { json: input.body },
111
- invalidJson: "text",
112
- mapError: ({ data, status, statusText }) => upstreamError(
113
- status,
114
- errorMessage(data, status, statusText)
115
- ),
116
- mapTransportError: ({ message }) => upstreamError(
117
- 502,
118
- `Grafana request failed: ${message ?? "unknown network error"}`
119
- )
118
+ invalidJson: "text"
120
119
  });
121
120
  return result.data === void 0 ? null : result.data;
122
121
  }
@@ -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
  } 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/graphhopper/api.ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as z from './v4/classic/external.cjs';
2
1
  import * as http from 'node:http';
3
2
  import { Sql } from 'postgres';
4
3
  import { Hono } from 'hono';
@@ -135,9 +134,14 @@ interface TBErrorBody {
135
134
  * 信任根不自举存储(spec-digest)。主密钥缺失/格式非法时能力禁用:Set 抛 unavailable。
136
135
  *
137
136
  * 纯逻辑,仅依赖 WebCrypto(core 无宿主依赖)。`crypto` / `TextEncoder` / `TextDecoder`
138
- * 在 Workers 与 Node 20+ 均为全局;此处以模块作用域最小声明补齐类型(不改 tsconfig、不污染全局)。
137
+ * 在 Workers 与 Node 20+ 均为全局;类型经 webGlobals.ts 统一承接(不改 tsconfig、不污染全局)。
139
138
  */
140
139
 
140
+ /** system/secret list 的一行(名字与时间戳,永不含值);CLI/Dashboard 经 SDK 消费同一命名。 */
141
+ interface SecretEntrySummary {
142
+ name: string;
143
+ updatedAt: Timestamp;
144
+ }
141
145
  /**
142
146
  * SecretStore 的纯逻辑实现。以注入的 StateStore 为后端。
143
147
  *
@@ -168,10 +172,7 @@ declare class SecretStoreImpl {
168
172
  * 枚举 secret 元数据。**绝不返回明文/密文**——只出 name + updatedAt(只进不出)。
169
173
  * limit 默认 50、上限 200 钳制。
170
174
  */
171
- list(opts?: ListOptions): Promise<Page<{
172
- name: string;
173
- updatedAt: Timestamp;
174
- }>>;
175
+ list(opts?: ListOptions): Promise<Page<SecretEntrySummary>>;
175
176
  /** 删除 secret;不存在 → not_found。 */
176
177
  delete(name: string): Promise<void>;
177
178
  /**
@@ -200,31 +201,26 @@ declare class SecretStoreImpl {
200
201
  * 的落点。
201
202
  */
202
203
 
203
- declare const pluginOAuthSchema: z.ZodObject<{
204
- authorizationUrl: z.ZodString;
205
- tokenUrl: z.ZodString;
206
- refreshUrl: z.ZodOptional<z.ZodString>;
207
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
208
- scopeSeparator: z.ZodOptional<z.ZodEnum<{
209
- " ": " ";
210
- ",": ",";
211
- }>>;
212
- clientAuth: z.ZodOptional<z.ZodEnum<{
213
- client_secret_basic: "client_secret_basic";
214
- client_secret_post: "client_secret_post";
215
- none: "none";
216
- }>>;
217
- authorizationParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
218
- responseEnvelope: z.ZodOptional<z.ZodString>;
219
- pkce: z.ZodOptional<z.ZodBoolean>;
220
- }, z.core.$strip>;
204
+ /** 令牌端点的客户端认证方式。 */
205
+ declare const OAUTH_CLIENT_AUTH_METHODS: readonly ["client_secret_basic", "client_secret_post", "none"];
206
+ type OAuthClientAuthMethod = (typeof OAUTH_CLIENT_AUTH_METHODS)[number];
221
207
  /**
222
208
  * provider 型 OAuth2 的声明。
223
209
  *
224
210
  * client_id / client_secret **不在这里** —— 它们是每个部署自己的应用凭证,走
225
211
  * `authRef` 指向的 secret(多字段:`clientId` + `clientSecret`),与其他上游凭证同一通道。
226
212
  */
227
- type PluginOAuth = z.infer<typeof pluginOAuthSchema>;
213
+ interface PluginOAuth {
214
+ authorizationParams?: Record<string, string>;
215
+ authorizationUrl: string;
216
+ clientAuth?: OAuthClientAuthMethod;
217
+ pkce?: boolean;
218
+ refreshUrl?: string;
219
+ responseEnvelope?: string;
220
+ scopes?: string[];
221
+ scopeSeparator?: ' ' | ',';
222
+ tokenUrl: string;
223
+ }
228
224
 
229
225
  /**
230
226
  * 注册时契约校验(plugin/v2)。
@@ -663,7 +659,12 @@ interface RuntimeRemoteSettings {
663
659
  maxHops: number;
664
660
  }
665
661
 
666
- type SearchCapability = 'search' | 'search:federated' | 'search:semantic';
662
+ /**
663
+ * pre-launch 收口:曾预留 'search:semantic' 全链路(wire/cursor/CLI/Dashboard 穿透)
664
+ * 但仓内从无任何 SearchIndex 声明或实现,唯一作用是被拒绝——已整链删除。
665
+ * 语义检索将来作为新 capability + 新 mode 一并落地,不留空档字段。
666
+ */
667
+ type SearchCapability = 'search' | 'search:federated';
667
668
  /** 全局工具搜索的完整结果;只在权限和可见性候选筛选后 hydrate。 */
668
669
  interface ToolSearchHit {
669
670
  path: TreePath;
@@ -691,7 +692,7 @@ interface ToolSearchOptions {
691
692
  limit?: number;
692
693
  matching?: ToolSearchMatching;
693
694
  minCoverage?: number;
694
- mode?: 'keyword' | 'semantic';
695
+ mode?: 'keyword';
695
696
  pathPrefix?: TreePath;
696
697
  }
697
698
  /** 会改变候选集合或分页档位的规范化约束;cursor 必须绑定其完整指纹。 */
@@ -704,7 +705,7 @@ interface NormalizedToolSearchOptions {
704
705
  /** 宿主提供的全局工具索引;权限和虚拟化仍由 gateway 处理。 */
705
706
  interface SearchIndex {
706
707
  readonly capabilities: readonly SearchCapability[];
707
- cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword' | 'semantic'): Promise<string>;
708
+ cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword'): Promise<string>;
708
709
  /** 联邦 continuation 的 topology binding;不实现的自定义 adapter 只能提供 local search。 */
709
710
  revision?(): Promise<number | string>;
710
711
  search(query: string, opts?: ToolSearchOptions): Promise<Page<ToolSearchCandidate>>;
@@ -830,9 +831,9 @@ interface SqlSearchDriver {
830
831
  write: (statements: readonly SqlSearchStatement[]) => Promise<void>;
831
832
  }
832
833
  declare class SqlSearchIndex implements MutableSearchIndex {
833
- protected readonly driver: SqlSearchDriver;
834
834
  readonly capabilities: readonly SearchCapability[];
835
835
  protected readonly dialect: SqlSearchDialect;
836
+ protected readonly driver: SqlSearchDriver;
836
837
  constructor(driver: SqlSearchDriver, dialect?: SqlSearchDialect);
837
838
  /** 容量 trigger 的 ABORT 在各驱动里错误形状不同,统一按标记串归一。 */
838
839
  private writeOrCapacity;
@@ -847,7 +848,7 @@ declare class SqlSearchIndex implements MutableSearchIndex {
847
848
  removePrefix(path: TreePath): Promise<void>;
848
849
  rebuild(documents: readonly ToolSearchDocument[]): Promise<void>;
849
850
  search(query: string, opts?: ToolSearchOptions): Promise<Page<ToolSearchCandidate>>;
850
- cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword' | 'semantic'): Promise<string>;
851
+ cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword'): Promise<string>;
851
852
  }
852
853
 
853
854
  /**
package/dist/index.js CHANGED
@@ -12,9 +12,10 @@ import {
12
12
  configFromEnv,
13
13
  createDataObjectStore,
14
14
  createTbServer
15
- } from "./chunk-RVUERWUZ.js";
16
- import "./chunk-3WL6EXYX.js";
17
- import "./chunk-WIGQCP6O.js";
15
+ } from "./chunk-KMTT3I6D.js";
16
+ import "./chunk-R6P4XAE5.js";
17
+ import "./chunk-U7B6DS2O.js";
18
+ import "./chunk-UZM2RXZH.js";
18
19
  import "./chunk-U67V476Y.js";
19
20
  export {
20
21
  DEVICE_FORWARD_TIMEOUT_MS,
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-E6JCVKW6.js";
4
4
  import "./chunk-JXHMDBAY.js";
5
5
  import {
6
6
  createProviderPlugin,
7
7
  requireApiKey,
8
8
  upstreamError
9
- } from "./chunk-6ANLYNFB.js";
10
- import "./chunk-3WL6EXYX.js";
9
+ } from "./chunk-ATK45BXV.js";
10
+ import "./chunk-U7B6DS2O.js";
11
11
  import {
12
12
  TBError,
13
13
  external_exports
14
- } from "./chunk-WIGQCP6O.js";
14
+ } from "./chunk-UZM2RXZH.js";
15
15
  import "./chunk-U67V476Y.js";
16
16
 
17
17
  // ../plugins/src/ip2proxy/schema.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
  } from "./chunk-JXHMDBAY.js";
@@ -8,11 +8,11 @@ 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
  external_exports
15
- } from "./chunk-WIGQCP6O.js";
15
+ } from "./chunk-UZM2RXZH.js";
16
16
  import "./chunk-U67V476Y.js";
17
17
 
18
18
  // ../plugins/src/ipgeolocation_io/api.ts
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
3
+ } from "./chunk-E6JCVKW6.js";
4
4
  import "./chunk-JXHMDBAY.js";
5
5
  import {
6
6
  createProviderPlugin,
7
7
  requireApiKey,
8
8
  upstreamError
9
- } from "./chunk-6ANLYNFB.js";
10
- import "./chunk-3WL6EXYX.js";
9
+ } from "./chunk-ATK45BXV.js";
10
+ import "./chunk-U7B6DS2O.js";
11
11
  import {
12
12
  TBError,
13
13
  external_exports
14
- } from "./chunk-WIGQCP6O.js";
14
+ } from "./chunk-UZM2RXZH.js";
15
15
  import "./chunk-U67V476Y.js";
16
16
 
17
17
  // ../plugins/src/ipqualityscore/api.ts
@@ -1,40 +1,39 @@
1
1
  import {
2
- createProviderHttpClient
3
- } from "./chunk-6X55ALDX.js";
4
- import {
5
- messageFrom
6
- } from "./chunk-JXHMDBAY.js";
2
+ createAuthedClient
3
+ } from "./chunk-XYBU3WZH.js";
4
+ import "./chunk-E6JCVKW6.js";
5
+ import "./chunk-JXHMDBAY.js";
7
6
  import {
8
7
  createProviderPlugin,
9
- requireApiKey,
10
8
  upstreamError
11
- } from "./chunk-6ANLYNFB.js";
12
- import "./chunk-3WL6EXYX.js";
9
+ } from "./chunk-ATK45BXV.js";
10
+ import "./chunk-U7B6DS2O.js";
13
11
  import {
14
12
  external_exports
15
- } from "./chunk-WIGQCP6O.js";
13
+ } from "./chunk-UZM2RXZH.js";
16
14
  import "./chunk-U67V476Y.js";
17
15
 
18
16
  // ../plugins/src/jina_ai/api.ts
19
17
  var SERVICE = "jina_ai";
20
18
  var REQUEST_TIMEOUT_MS = 3e4;
21
- var http = createProviderHttpClient({ baseUrl: "https://api.jina.ai/", service: SERVICE });
19
+ var http = createAuthedClient({
20
+ baseUrl: "https://api.jina.ai/",
21
+ service: SERVICE,
22
+ auth: { kind: "bearer" },
23
+ headers: { accept: "application/json" },
24
+ errorMessage: {
25
+ keys: ["detail", "message"],
26
+ fallback: (status) => `Jina AI request failed with ${status}`
27
+ },
28
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Jina AI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message ?? "unknown network error"}`)
29
+ });
22
30
  async function request(ctx, path, body) {
23
- const { data } = await http.request({
31
+ const { data } = await http.request(ctx, {
24
32
  path,
25
33
  method: "POST",
26
- headers: {
27
- accept: "application/json",
28
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
29
- },
30
34
  json: body,
31
35
  timeoutMs: REQUEST_TIMEOUT_MS,
32
- invalidJsonMessage: "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
33
- mapError: ({ data: payload, status }) => upstreamError(
34
- status,
35
- messageFrom(payload, ["detail", "message"], `Jina AI request failed with ${status}`)
36
- ),
37
- mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Jina AI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message ?? "unknown network error"}`)
36
+ invalidJsonMessage: "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94"
38
37
  });
39
38
  return data ?? null;
40
39
  }
@@ -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
  booleanValue,
@@ -12,20 +13,19 @@ import {
12
13
  createProviderPlugin,
13
14
  requireCredential,
14
15
  upstreamError
15
- } from "./chunk-6ANLYNFB.js";
16
+ } from "./chunk-ATK45BXV.js";
16
17
  import {
17
18
  assertPublicHttpUrl
18
- } from "./chunk-3WL6EXYX.js";
19
+ } from "./chunk-U7B6DS2O.js";
19
20
  import {
20
21
  TBError,
21
22
  external_exports
22
- } from "./chunk-WIGQCP6O.js";
23
+ } from "./chunk-UZM2RXZH.js";
23
24
  import "./chunk-U67V476Y.js";
24
25
 
25
26
  // ../plugins/src/jira/api.ts
26
27
  var SERVICE = "jira";
27
28
  var DEFAULT_LIMIT = 50;
28
- var http = createProviderHttpClient({ service: SERVICE });
29
29
  var DEFAULT_ISSUE_FIELD_IDS = [
30
30
  "summary",
31
31
  "description",
@@ -116,23 +116,27 @@ function responsePayload(data, bodyKind) {
116
116
  if (bodyKind === "empty") return {};
117
117
  return bodyKind === "invalid-json" ? { message: data } : data;
118
118
  }
119
+ var http = createAuthedClient({
120
+ service: SERVICE,
121
+ auth: {
122
+ kind: "custom",
123
+ headers: (ctx) => ({ authorization: `Bearer ${requireCredential(ctx, SERVICE, "personalAccessToken")}` })
124
+ },
125
+ headers: { accept: "application/json" },
126
+ mapError: ({ bodyKind, data, status }) => upstreamError(
127
+ status,
128
+ errorMessage(responsePayload(data, bodyKind))
129
+ )
130
+ });
119
131
  async function requestValue(ctx, options) {
120
132
  const baseUrl = apiBaseUrl(ctx);
121
- const result = await http.request({
133
+ const result = await http.request(ctx, {
122
134
  baseUrl,
123
135
  // create_issue 会跟随 Jira 返回的 self;buildUrl 先锁定 origin 与 REST API path 前缀。
124
136
  path: buildUrl(baseUrl, options.path, options.query),
125
137
  method: options.method ?? (options.body === void 0 ? "GET" : "POST"),
126
- headers: {
127
- accept: "application/json",
128
- authorization: `Bearer ${requireCredential(ctx, SERVICE, "personalAccessToken")}`
129
- },
130
138
  ...options.body === void 0 ? {} : { json: options.body },
131
- invalidJson: "text",
132
- mapError: ({ bodyKind, data, status }) => upstreamError(
133
- status,
134
- errorMessage(responsePayload(data, bodyKind))
135
- )
139
+ invalidJson: "text"
136
140
  });
137
141
  return responsePayload(result.data, result.bodyKind);
138
142
  }
@@ -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,
@@ -12,19 +13,32 @@ import {
12
13
  createProviderPlugin,
13
14
  requireApiKey,
14
15
  upstreamError
15
- } from "./chunk-6ANLYNFB.js";
16
- import "./chunk-3WL6EXYX.js";
16
+ } from "./chunk-ATK45BXV.js";
17
+ import "./chunk-U7B6DS2O.js";
17
18
  import {
18
19
  TBError,
19
20
  external_exports
20
- } from "./chunk-WIGQCP6O.js";
21
+ } from "./chunk-UZM2RXZH.js";
21
22
  import "./chunk-U67V476Y.js";
22
23
 
23
24
  // ../plugins/src/langsmith/api.ts
24
25
  var SERVICE = "langsmith";
25
26
  var WORKSPACES_PATH = "/api/v1/workspaces";
26
27
  var DEFAULT_REGION = "us";
27
- var http = createProviderHttpClient({ service: SERVICE });
28
+ var http = createAuthedClient({
29
+ service: SERVICE,
30
+ auth: { kind: "header", name: "X-Api-Key" },
31
+ headers: { accept: "application/json" },
32
+ // 错误消息四处之一;拿不到就退回状态行。
33
+ errorMessage: {
34
+ keys: ["detail", "message", "error", "title"],
35
+ fallback: (status, statusText) => trimmedText(statusText) ?? `langsmith \u8FD4\u56DE HTTP ${status}`
36
+ },
37
+ mapTransportError: ({ message }) => upstreamError(
38
+ 502,
39
+ `langsmith \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`
40
+ )
41
+ });
28
42
  var REGION_BASE_URLS = {
29
43
  us: "https://api.smith.langchain.com",
30
44
  eu: "https://eu.api.smith.langchain.com",
@@ -48,12 +62,6 @@ function resolveWorkspaceId(ctx) {
48
62
  if (configured !== void 0 && typeof configured !== "string") throw configError("workspaceId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
49
63
  return trimmedText(configured);
50
64
  }
51
- function errorMessage(context) {
52
- const payload = context.data;
53
- const fromText = typeof payload === "string" ? trimmedText(payload) : void 0;
54
- const body = asJsonObject(payload);
55
- return fromText ?? trimmedText(body?.detail) ?? trimmedText(body?.message) ?? trimmedText(body?.error) ?? trimmedText(body?.title) ?? trimmedText(context.statusText) ?? `langsmith \u8FD4\u56DE HTTP ${context.status}`;
56
- }
57
65
  function queryPairs(query) {
58
66
  return Object.entries(query ?? {}).flatMap(([key, value]) => {
59
67
  if (value === void 0 || value === null) return [];
@@ -61,25 +69,17 @@ function queryPairs(query) {
61
69
  });
62
70
  }
63
71
  async function request(ctx, input) {
64
- const apiKey = requireApiKey(ctx, SERVICE);
72
+ requireApiKey(ctx, SERVICE);
65
73
  const workspaceId = resolveWorkspaceId(ctx);
66
- const result = await http.request({
74
+ const result = await http.request(ctx, {
67
75
  baseUrl: resolveApiBase(ctx),
68
76
  path: input.path,
69
77
  method: input.method ?? "GET",
70
78
  query: queryPairs(input.query),
71
- headers: {
72
- "accept": "application/json",
73
- "X-Api-Key": apiKey,
74
- ...workspaceId === void 0 ? {} : { "X-Tenant-Id": workspaceId }
75
- },
79
+ // 一个 API key 能看到多个 workspace 时,靠 `X-Tenant-Id` 指定用哪个。
80
+ ...workspaceId === void 0 ? {} : { headers: { "X-Tenant-Id": workspaceId } },
76
81
  ...input.body === void 0 ? {} : { json: input.body },
77
- invalidJson: "text",
78
- mapError: (context) => upstreamError(context.status, errorMessage(context)),
79
- mapTransportError: ({ message }) => upstreamError(
80
- 502,
81
- `langsmith \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`
82
- )
82
+ invalidJson: "text"
83
83
  });
84
84
  return result.data === void 0 ? null : result.data;
85
85
  }
@@ -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,
@@ -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/lemlist/api.ts
22
23
  var SERVICE = "lemlist";
23
24
  var API_BASE = "https://api.lemlist.com/api";
24
- var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
25
25
  function stringArray(value) {
26
26
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
27
27
  }
@@ -35,33 +35,32 @@ function basicAuthHeader(apiKey) {
35
35
  for (const byte of bytes) binary += String.fromCharCode(byte);
36
36
  return `Basic ${btoa(binary)}`;
37
37
  }
38
- function errorMessage(payload) {
39
- if (typeof payload === "string") return trimmedText(payload);
40
- const body = asJsonObject(payload);
41
- if (body === void 0) return void 0;
42
- return trimmedText(body.message) ?? trimmedText(body.error) ?? trimmedText(body.reason);
43
- }
38
+ var http = createAuthedClient({
39
+ baseUrl: `${API_BASE}/`,
40
+ service: SERVICE,
41
+ // Basic(用户名留空、key 当密码)不在 helper 的三种头型里,自己拼。
42
+ auth: { kind: "custom", headers: (ctx) => ({ authorization: basicAuthHeader(requireApiKey(ctx, SERVICE)) }) },
43
+ headers: { accept: "application/json" },
44
+ errorMessage: {
45
+ keys: ["message", "error", "reason"],
46
+ fallback: (status) => `lemlist \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
47
+ },
48
+ mapTransportError: ({ message }) => upstreamError(
49
+ 502,
50
+ message === void 0 ? "lemlist \u8BF7\u6C42\u5931\u8D25" : `lemlist \u8BF7\u6C42\u5931\u8D25: ${message}`
51
+ )
52
+ });
44
53
  async function request(ctx, path, query = {}) {
45
- const apiKey = requireApiKey(ctx, SERVICE);
46
54
  const pairs = [];
47
55
  for (const [key, value] of Object.entries(query)) {
48
56
  if (typeof value === "number" || typeof value === "string" && value !== "") {
49
57
  pairs.push([key, value]);
50
58
  }
51
59
  }
52
- const { data } = await http.request({
60
+ const { data } = await http.request(ctx, {
53
61
  path,
54
62
  query: pairs,
55
- headers: { accept: "application/json", authorization: basicAuthHeader(apiKey) },
56
- invalidJson: "text",
57
- mapError: ({ data: payload, status }) => upstreamError(
58
- status,
59
- errorMessage(payload) ?? `lemlist \u8BF7\u6C42\u5931\u8D25,HTTP ${status}`
60
- ),
61
- mapTransportError: ({ message }) => upstreamError(
62
- 502,
63
- message === void 0 ? "lemlist \u8BF7\u6C42\u5931\u8D25" : `lemlist \u8BF7\u6C42\u5931\u8D25: ${message}`
64
- )
63
+ invalidJson: "text"
65
64
  });
66
65
  return data ?? null;
67
66
  }