@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,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,14 +9,14 @@ import {
9
9
  createProviderPlugin,
10
10
  requireCredential,
11
11
  upstreamError
12
- } from "./chunk-B4P6YZFS.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
13
  import {
14
14
  assertPublicHttpUrl
15
- } from "./chunk-SWBNHIO4.js";
15
+ } from "./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/ghost/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,
@@ -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-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/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-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.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-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/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-VLOIDU5U.js";
2
+ createAuthedClient
3
+ } from "./chunk-JEWFX6Z6.js";
4
+ import "./chunk-Q74GLIDK.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-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/googlecalendar/api/shared.ts
@@ -23,7 +23,6 @@ var SERVICE = "googlecalendar";
23
23
  var API_BASE = "https://www.googleapis.com/calendar/v3";
24
24
  var REQUEST_TIMEOUT_MS = 3e4;
25
25
  var GOOGLE_API_ORIGIN = new URL(API_BASE).origin;
26
- var http = createProviderHttpClient({ baseUrl: `${GOOGLE_API_ORIGIN}/`, service: SERVICE });
27
26
  var MAX_ERROR_MESSAGE_LENGTH = 500;
28
27
  var RATE_LIMIT_REASONS = /* @__PURE__ */ new Set([
29
28
  "rateLimitExceeded",
@@ -102,22 +101,25 @@ function calendarError(context, syncTokenAware) {
102
101
  }
103
102
  return upstreamError(context.status, message);
104
103
  }
104
+ var http = createAuthedClient({
105
+ baseUrl: `${GOOGLE_API_ORIGIN}/`,
106
+ service: SERVICE,
107
+ auth: { kind: "bearer" },
108
+ headers: { accept: "application/json" },
109
+ 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"}`)
110
+ });
105
111
  async function send(ctx, input) {
106
112
  const hasBody = input.body !== void 0;
107
113
  const target = requestTarget(input.url, input.query);
108
- return await http.request({
114
+ return await http.request(ctx, {
109
115
  method: input.method ?? (hasBody ? "POST" : "GET"),
110
116
  path: target.path,
111
117
  query: target.query,
112
- headers: {
113
- accept: "application/json",
114
- authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
115
- },
116
118
  ...hasBody ? { json: input.body } : {},
117
119
  invalidJson: "text",
118
120
  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"}`)
121
+ // 410 syncToken 解读随每次请求走(见文件头第 2 条),故 mapError 只能逐请求给。
122
+ mapError: (context) => calendarError(context, input.syncTokenAware ?? false)
121
123
  });
122
124
  }
123
125
  async function requestJson(ctx, input) {
@@ -9,14 +9,14 @@ import {
9
9
  createProviderPlugin,
10
10
  requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-B4P6YZFS.js";
12
+ } from "./chunk-QR4LK3HF.js";
13
13
  import {
14
14
  guardedFetch
15
- } from "./chunk-SWBNHIO4.js";
15
+ } from "./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/googledocs/api/shared.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
  booleanValue,
@@ -12,14 +13,14 @@ import {
12
13
  createProviderPlugin,
13
14
  requireApiKey,
14
15
  upstreamError
15
- } from "./chunk-B4P6YZFS.js";
16
+ } from "./chunk-QR4LK3HF.js";
16
17
  import {
17
18
  assertPublicHttpUrl
18
- } from "./chunk-SWBNHIO4.js";
19
+ } from "./chunk-ZTTN6AJG.js";
19
20
  import {
20
21
  TBError,
21
22
  external_exports
22
- } from "./chunk-OKRZPQ3R.js";
23
+ } from "./chunk-MZCIPUNQ.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-VLOIDU5U.js";
3
+ } from "./chunk-Q74GLIDK.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-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/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';
@@ -68,6 +67,7 @@ interface Scope {
68
67
  * sys:bootstrapped → true(Admin SK 引导幂等标志)
69
68
  * annotation:<path> → { text, updatedAt, updatedBy }(管理员 Path 补充说明)
70
69
  * feedback:<path> → FeedbackEntry[](Agent 使用反馈,单 key 整存)
70
+ * deviceop:<sha256(deviceId)>:<operationId> → DeviceOperationRecord(revision CAS,密文 payload/result)
71
71
  * store:object:<id> → StoreObject(revision CAS)
72
72
  * store:upload:<id> → UploadSession(revision CAS)
73
73
  * store:call-capability:<id> → CallUploadCapability(token 仅存 hash)
@@ -134,9 +134,14 @@ interface TBErrorBody {
134
134
  * 信任根不自举存储(spec-digest)。主密钥缺失/格式非法时能力禁用:Set 抛 unavailable。
135
135
  *
136
136
  * 纯逻辑,仅依赖 WebCrypto(core 无宿主依赖)。`crypto` / `TextEncoder` / `TextDecoder`
137
- * 在 Workers 与 Node 20+ 均为全局;此处以模块作用域最小声明补齐类型(不改 tsconfig、不污染全局)。
137
+ * 在 Workers 与 Node 20+ 均为全局;类型经 webGlobals.ts 统一承接(不改 tsconfig、不污染全局)。
138
138
  */
139
139
 
140
+ /** system/secret list 的一行(名字与时间戳,永不含值);CLI/Dashboard 经 SDK 消费同一命名。 */
141
+ interface SecretEntrySummary {
142
+ name: string;
143
+ updatedAt: Timestamp;
144
+ }
140
145
  /**
141
146
  * SecretStore 的纯逻辑实现。以注入的 StateStore 为后端。
142
147
  *
@@ -167,10 +172,7 @@ declare class SecretStoreImpl {
167
172
  * 枚举 secret 元数据。**绝不返回明文/密文**——只出 name + updatedAt(只进不出)。
168
173
  * limit 默认 50、上限 200 钳制。
169
174
  */
170
- list(opts?: ListOptions): Promise<Page<{
171
- name: string;
172
- updatedAt: Timestamp;
173
- }>>;
175
+ list(opts?: ListOptions): Promise<Page<SecretEntrySummary>>;
174
176
  /** 删除 secret;不存在 → not_found。 */
175
177
  delete(name: string): Promise<void>;
176
178
  /**
@@ -199,31 +201,26 @@ declare class SecretStoreImpl {
199
201
  * 的落点。
200
202
  */
201
203
 
202
- declare const pluginOAuthSchema: z.ZodObject<{
203
- authorizationUrl: z.ZodString;
204
- tokenUrl: z.ZodString;
205
- refreshUrl: z.ZodOptional<z.ZodString>;
206
- scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
207
- scopeSeparator: z.ZodOptional<z.ZodEnum<{
208
- " ": " ";
209
- ",": ",";
210
- }>>;
211
- clientAuth: z.ZodOptional<z.ZodEnum<{
212
- client_secret_basic: "client_secret_basic";
213
- client_secret_post: "client_secret_post";
214
- none: "none";
215
- }>>;
216
- authorizationParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
217
- responseEnvelope: z.ZodOptional<z.ZodString>;
218
- pkce: z.ZodOptional<z.ZodBoolean>;
219
- }, 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];
220
207
  /**
221
208
  * provider 型 OAuth2 的声明。
222
209
  *
223
210
  * client_id / client_secret **不在这里** —— 它们是每个部署自己的应用凭证,走
224
211
  * `authRef` 指向的 secret(多字段:`clientId` + `clientSecret`),与其他上游凭证同一通道。
225
212
  */
226
- 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
+ }
227
224
 
228
225
  /**
229
226
  * 注册时契约校验(plugin/v2)。
@@ -542,6 +539,8 @@ interface ContextProvider {
542
539
  interface ToolSpec {
543
540
  /** 危险操作二次确认;进 `~help` 的 confirm 行。 */
544
541
  confirm?: boolean;
542
+ /** 仅 device-backed tool 使用;mailbox/both 表示 invoke 可选择持久化交付。 */
543
+ delivery?: 'realtime' | 'mailbox' | 'both';
545
544
  /** 一句话描述;进 `~help` 的 `h` 行。上游可能不带 → 可缺省。 */
546
545
  description?: string;
547
546
  /** 副作用标记(read/write/destructive);进 `~help` 的 effect 行。 */
@@ -631,6 +630,18 @@ type DeviceCallResult = {
631
630
  error: TBErrorBody;
632
631
  ok: false;
633
632
  };
633
+ /**
634
+ * 网关对一次 realtime 尝试的权威认知。
635
+ *
636
+ * - completed:设备明确返回 result(成功或业务错误);
637
+ * - not_dispatched:call 帧确定没有交给设备,可安全改走 Mailbox;
638
+ * - unknown:call 帧已经发送或可能已经发送,但结果未收敛,不能自动重试/入队。
639
+ */
640
+ type DeviceCallDisposition = 'completed' | 'not_dispatched' | 'unknown';
641
+ interface DeviceCallAttempt {
642
+ disposition: DeviceCallDisposition;
643
+ result: DeviceCallResult;
644
+ }
634
645
 
635
646
  interface RuntimeRemoteSettings {
636
647
  allowInsecure: boolean;
@@ -648,7 +659,12 @@ interface RuntimeRemoteSettings {
648
659
  maxHops: number;
649
660
  }
650
661
 
651
- 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';
652
668
  /** 全局工具搜索的完整结果;只在权限和可见性候选筛选后 hydrate。 */
653
669
  interface ToolSearchHit {
654
670
  path: TreePath;
@@ -676,7 +692,7 @@ interface ToolSearchOptions {
676
692
  limit?: number;
677
693
  matching?: ToolSearchMatching;
678
694
  minCoverage?: number;
679
- mode?: 'keyword' | 'semantic';
695
+ mode?: 'keyword';
680
696
  pathPrefix?: TreePath;
681
697
  }
682
698
  /** 会改变候选集合或分页档位的规范化约束;cursor 必须绑定其完整指纹。 */
@@ -689,7 +705,7 @@ interface NormalizedToolSearchOptions {
689
705
  /** 宿主提供的全局工具索引;权限和虚拟化仍由 gateway 处理。 */
690
706
  interface SearchIndex {
691
707
  readonly capabilities: readonly SearchCapability[];
692
- cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword' | 'semantic'): Promise<string>;
708
+ cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword'): Promise<string>;
693
709
  /** 联邦 continuation 的 topology binding;不实现的自定义 adapter 只能提供 local search。 */
694
710
  revision?(): Promise<number | string>;
695
711
  search(query: string, opts?: ToolSearchOptions): Promise<Page<ToolSearchCandidate>>;
@@ -815,9 +831,9 @@ interface SqlSearchDriver {
815
831
  write: (statements: readonly SqlSearchStatement[]) => Promise<void>;
816
832
  }
817
833
  declare class SqlSearchIndex implements MutableSearchIndex {
818
- protected readonly driver: SqlSearchDriver;
819
834
  readonly capabilities: readonly SearchCapability[];
820
835
  protected readonly dialect: SqlSearchDialect;
836
+ protected readonly driver: SqlSearchDriver;
821
837
  constructor(driver: SqlSearchDriver, dialect?: SqlSearchDialect);
822
838
  /** 容量 trigger 的 ABORT 在各驱动里错误形状不同,统一按标记串归一。 */
823
839
  private writeOrCapacity;
@@ -832,7 +848,7 @@ declare class SqlSearchIndex implements MutableSearchIndex {
832
848
  removePrefix(path: TreePath): Promise<void>;
833
849
  rebuild(documents: readonly ToolSearchDocument[]): Promise<void>;
834
850
  search(query: string, opts?: ToolSearchOptions): Promise<Page<ToolSearchCandidate>>;
835
- cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword' | 'semantic'): Promise<string>;
851
+ cursorFor(query: string, candidate: ToolSearchCandidate, mode?: 'keyword'): Promise<string>;
836
852
  }
837
853
 
838
854
  /**
@@ -927,8 +943,8 @@ interface DeviceInvokeRequest {
927
943
  }
928
944
  /** 设备通道宿主(CF = DeviceSession DO / Docker = ws)。 */
929
945
  interface DeviceChannel {
930
- /** HTTP→WS 调用转发:结果为 DeviceCallResult 形状(设备侧 result 帧)。 */
931
- invoke(deviceId: string, req: DeviceInvokeRequest): Promise<unknown>;
946
+ /** HTTP→WS 调用转发,并显式报告是否已 dispatch,供安全 Mailbox fallback 判定。 */
947
+ invoke(deviceId: string, req: DeviceInvokeRequest): Promise<DeviceCallAttempt>;
932
948
  /** WS 升级请求转交(/system/device/ws)。 */
933
949
  ws(deviceId: string, request: Request): Promise<Response>;
934
950
  }
@@ -1225,7 +1241,7 @@ declare class DeviceRouter {
1225
1241
  constructor(replicaId: string, backend: DeviceRouterBackend, opts: {
1226
1242
  forwardTimeoutMs?: number;
1227
1243
  /** 收到转发来的调用时,在本副本执行(本地无该连接则返回 offline)。 */
1228
- onLocalCall: (deviceId: string, req: DeviceInvokeRequest) => Promise<DeviceCallResult>;
1244
+ onLocalCall: (deviceId: string, req: DeviceInvokeRequest) => Promise<DeviceCallAttempt>;
1229
1245
  ttlSec?: number;
1230
1246
  });
1231
1247
  private get ttlSec();
@@ -1241,7 +1257,7 @@ declare class DeviceRouter {
1241
1257
  * 把调用转发给持有该设备的副本并等结果。
1242
1258
  * 无人持有 → null(调用方按 deviceOffline 处理)。
1243
1259
  */
1244
- forward(deviceId: string, req: DeviceInvokeRequest): Promise<DeviceCallResult | null>;
1260
+ forward(deviceId: string, req: DeviceInvokeRequest): Promise<DeviceCallAttempt | null>;
1245
1261
  close(): Promise<void>;
1246
1262
  /** correlationId 的进程内序号(与 replicaId 组合后全局唯一)。 */
1247
1263
  private static seq;
@@ -1269,7 +1285,7 @@ declare class DeviceRouter {
1269
1285
  */
1270
1286
 
1271
1287
  /** router 回调本副本执行设备调用的签名。 */
1272
- type DeviceLocalCall = (deviceId: string, req: DeviceInvokeRequest) => Promise<DeviceCallResult>;
1288
+ type DeviceLocalCall = (deviceId: string, req: DeviceInvokeRequest) => Promise<DeviceCallAttempt>;
1273
1289
  declare const DEVICE_WS_PATH = "/system/device/ws";
1274
1290
  declare class DeviceHub {
1275
1291
  private readonly store;
@@ -1304,7 +1320,7 @@ declare class DeviceHub {
1304
1320
  * 本地没有但配了 router → 问路由表并转发给持有者副本(socket 不可序列化,
1305
1321
  * 只能把调用送到 socket 所在进程)。都没有 → deviceOffline。
1306
1322
  */
1307
- invoke(deviceId: string, req: DeviceInvokeRequest): Promise<unknown>;
1323
+ invoke(deviceId: string, req: DeviceInvokeRequest): Promise<DeviceCallAttempt>;
1308
1324
  /**
1309
1325
  * 只走本副本 socket 的调用执行。
1310
1326
  *
package/dist/index.js CHANGED
@@ -12,9 +12,9 @@ import {
12
12
  configFromEnv,
13
13
  createDataObjectStore,
14
14
  createTbServer
15
- } from "./chunk-CLEZ6YQ6.js";
16
- import "./chunk-SWBNHIO4.js";
17
- import "./chunk-OKRZPQ3R.js";
15
+ } from "./chunk-MDY7K5CX.js";
16
+ import "./chunk-ZTTN6AJG.js";
17
+ import "./chunk-MZCIPUNQ.js";
18
18
  import "./chunk-U67V476Y.js";
19
19
  export {
20
20
  DEVICE_FORWARD_TIMEOUT_MS,
@@ -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/ip2proxy/schema.ts
@@ -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
  } from "./chunk-JXHMDBAY.js";
@@ -8,11 +8,11 @@ import {
8
8
  createProviderPlugin,
9
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
  external_exports
15
- } from "./chunk-OKRZPQ3R.js";
15
+ } from "./chunk-MZCIPUNQ.js";
16
16
  import "./chunk-U67V476Y.js";
17
17
 
18
18
  // ../plugins/src/ipgeolocation_io/api.ts