@tool-bridge/server 0.23.0 → 0.25.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 (112) hide show
  1. package/dist/admin.js +164 -5
  2. package/dist/{airtable-VMQVXLHK.js → airtable-4HFPBKO2.js} +6 -6
  3. package/dist/{alt_text_generator_ai-FTWY4RU4.js → alt_text_generator_ai-TBGJCAWO.js} +5 -5
  4. package/dist/{amap-OK5VBHYC.js → amap-V2WZ4GP4.js} +5 -5
  5. package/dist/{anthropic-S67AZFZ3.js → anthropic-HVNDGFRH.js} +6 -6
  6. package/dist/{apify-ZE6MYQI3.js → apify-TI5DOAUG.js} +6 -6
  7. package/dist/{brave_search-TG2M2KOD.js → brave_search-7GFBVUIH.js} +6 -6
  8. package/dist/{chunk-BADVCN6K.js → chunk-3VF7MQJX.js} +40 -3
  9. package/dist/{chunk-TDAWLMDE.js → chunk-CXRQCZBS.js} +3 -3
  10. package/dist/{chunk-VWRUGUSU.js → chunk-G6GI7EMV.js} +3 -3
  11. package/dist/{chunk-7CTWGTDU.js → chunk-KVLI7ZFI.js} +2 -2
  12. package/dist/{chunk-2JNAI4OC.js → chunk-N7ZFZWGA.js} +1 -1
  13. package/dist/{chunk-5ICRY3VU.js → chunk-TF2N67HN.js} +1755 -1349
  14. package/dist/{chunk-4XJPN3DY.js → chunk-UKITQ6LN.js} +3792 -2881
  15. package/dist/{chunk-WJHG6OK7.js → chunk-UVG4PNWV.js} +2 -2
  16. package/dist/{circleci-3L3WJVSK.js → circleci-75NMIPKV.js} +6 -6
  17. package/dist/{clerk-EZPF2V7T.js → clerk-PB2SJAMC.js} +6 -6
  18. package/dist/{cohere-U27DPO64.js → cohere-UBIMGBOU.js} +6 -6
  19. package/dist/{confluence-G2KL6ERH.js → confluence-5436ZQBW.js} +6 -6
  20. package/dist/{convertapi-L4CLJ2M3.js → convertapi-CZILNAZL.js} +4 -4
  21. package/dist/{currencyapi-YPYXG7YY.js → currencyapi-IPUUA4ZC.js} +6 -6
  22. package/dist/{deepseek-6HT6WF3M.js → deepseek-F2JV4HEE.js} +6 -6
  23. package/dist/{docker_hub-LPE3PCVB.js → docker_hub-TRH7EULS.js} +5 -5
  24. package/dist/{dropbox-V56ABHTA.js → dropbox-4DCC6FQ7.js} +6 -6
  25. package/dist/{dub-6OKQ7MHT.js → dub-RSI5NDXK.js} +6 -6
  26. package/dist/{e2b-JS2U2QFU.js → e2b-KM4FJOXS.js} +6 -6
  27. package/dist/{exa-DPWVYXSP.js → exa-MF26RJSD.js} +6 -6
  28. package/dist/{fal_ai-DK6Y27ZF.js → fal_ai-4I4QJKBZ.js} +6 -6
  29. package/dist/{feishu-K7EGSRF3.js → feishu-KEBTN5OD.js} +3 -3
  30. package/dist/{feishu_custom_bot-2JUGFYNG.js → feishu_custom_bot-KJTIB3PG.js} +4 -4
  31. package/dist/{figma-FT5I7ITD.js → figma-OFW54Q54.js} +6 -6
  32. package/dist/{firehydrant-EIKLKHX2.js → firehydrant-RU3B7DXC.js} +6 -6
  33. package/dist/{fixer-U5QXIAKD.js → fixer-QZ4WCQN3.js} +5 -5
  34. package/dist/{fly-T3JYFZ2M.js → fly-ZPUXZ5Y7.js} +6 -6
  35. package/dist/{front-D72MGVOR.js → front-SCMVKIEA.js} +6 -6
  36. package/dist/{geocodio-BOTD5TI5.js → geocodio-N3QYPBRC.js} +5 -5
  37. package/dist/{ghost-KYP7SZGB.js → ghost-VMSBR3TP.js} +5 -5
  38. package/dist/{github-AGMZT3VY.js → github-XOML5UVH.js} +6 -6
  39. package/dist/github_events-5FCIB5E3.js +78 -0
  40. package/dist/{gmail-BLJNJOBG.js → gmail-FX3TTLAE.js} +6 -6
  41. package/dist/{googlecalendar-GTHWNCF6.js → googlecalendar-LWMUNEF5.js} +6 -6
  42. package/dist/{googledocs-6EEDMEBQ.js → googledocs-ZGVN66MU.js} +4 -4
  43. package/dist/{grafana-GMW6EKSQ.js → grafana-NKZPJG5L.js} +6 -6
  44. package/dist/{graphhopper-6OLGBDGB.js → graphhopper-XCRPVZNX.js} +5 -5
  45. package/dist/index.d.ts +315 -5
  46. package/dist/index.js +7 -5
  47. package/dist/{ip2proxy-4QN42E6T.js → ip2proxy-RDDJFPLQ.js} +5 -5
  48. package/dist/{ipgeolocation_io-SK4XKDA2.js → ipgeolocation_io-RTUJKI3Z.js} +5 -5
  49. package/dist/{ipqualityscore-6ANBPXKT.js → ipqualityscore-5NG5KR33.js} +5 -5
  50. package/dist/{jina_ai-IHPSVRM5.js → jina_ai-VG5X5JBE.js} +6 -6
  51. package/dist/{jira-46KKM4LC.js → jira-LS6ITOSL.js} +6 -6
  52. package/dist/{langsmith-JZA345I5.js → langsmith-TT26W3A4.js} +6 -6
  53. package/dist/{lemlist-43IV7DK6.js → lemlist-25WLR36L.js} +6 -6
  54. package/dist/{linear-5LFH7XNL.js → linear-JLE2CHI3.js} +4 -4
  55. package/dist/{logsnag-5RMYAHIL.js → logsnag-OI67GLMG.js} +6 -6
  56. package/dist/main.js +6 -5
  57. package/dist/{mattermost-XFL6SHGG.js → mattermost-AYJAUGNG.js} +6 -6
  58. package/dist/{mem0-NYO4DTP6.js → mem0-ZGEAZPCF.js} +6 -6
  59. package/dist/{memos-37MPQOLV.js → memos-PS2QHWZX.js} +6 -6
  60. package/dist/{metabase-KYBKZFMG.js → metabase-6F5P4YNZ.js} +6 -6
  61. package/dist/{mistral_ai-6PL3K4PM.js → mistral_ai-GKF6H3PY.js} +6 -6
  62. package/dist/{mother_duck-2NH7W5M5.js → mother_duck-C7KWG5OB.js} +6 -6
  63. package/dist/{ngrok-UO6CDYCA.js → ngrok-UZQYPMSO.js} +6 -6
  64. package/dist/{notes-I3P32WP4.js → notes-DO7GGFTP.js} +2 -2
  65. package/dist/{notion-BEAJFUOE.js → notion-JSLD5P5J.js} +6 -6
  66. package/dist/{open_exchange_rates-CMF62JB4.js → open_exchange_rates-NZYN73GB.js} +5 -5
  67. package/dist/{openai-IHOMKVND.js → openai-KOXCZZVV.js} +6 -6
  68. package/dist/{opengraph_io-ZQ2FGLHX.js → opengraph_io-DVAV6AK6.js} +5 -5
  69. package/dist/{openrouter-HXLW3NR5.js → openrouter-MPMSFAEY.js} +6 -6
  70. package/dist/{outline-ELCP4NEU.js → outline-E2SNFTFE.js} +6 -6
  71. package/dist/{paddle-O77LALVN.js → paddle-QOZOMZ6T.js} +6 -6
  72. package/dist/{perplexity-JCU654QV.js → perplexity-VRWYDYRW.js} +6 -6
  73. package/dist/{pinecone-W5W4LRKL.js → pinecone-LDU3YSBJ.js} +6 -6
  74. package/dist/{pipedrive-ITMJLLPZ.js → pipedrive-ZN6NDUPL.js} +6 -6
  75. package/dist/{polar-R33XU4L3.js → polar-H5GK75YP.js} +6 -6
  76. package/dist/{posthog-JVNTOLTV.js → posthog-XVJMSCPA.js} +6 -6
  77. package/dist/{postmark-6SBG7HWV.js → postmark-IVXNOXFI.js} +6 -6
  78. package/dist/{prerender-GPNKTNFC.js → prerender-FH4SBVJY.js} +5 -5
  79. package/dist/{pubmed-UP6ZEEIH.js → pubmed-TM7LBALS.js} +4 -4
  80. package/dist/{railway-KWEWXHTY.js → railway-FJ4XQ2NF.js} +4 -4
  81. package/dist/{readwise-BLATSMC3.js → readwise-4VQNTOLQ.js} +6 -6
  82. package/dist/{render-QYRVIXII.js → render-CX7AWO6F.js} +6 -6
  83. package/dist/{replicate-JYTWH4NF.js → replicate-U6T7GYMR.js} +6 -6
  84. package/dist/{resend-L5N75SZM.js → resend-RDQXZGY6.js} +6 -6
  85. package/dist/{rootly-MHCPEQ26.js → rootly-AWTSRSIZ.js} +6 -6
  86. package/dist/{scrapfly-PTPGYSJM.js → scrapfly-UWX6TBH7.js} +5 -5
  87. package/dist/{scrapingbee-JN6UH5PY.js → scrapingbee-BKCOLELF.js} +5 -5
  88. package/dist/{screenshot_fyi-4QRVSV55.js → screenshot_fyi-3OYHV6ZZ.js} +5 -5
  89. package/dist/{semantic_scholar-LRSWA2GE.js → semantic_scholar-EV2HDKRA.js} +6 -6
  90. package/dist/{sentry-2G6PF5W6.js → sentry-BPEKPIFX.js} +6 -6
  91. package/dist/{shodan-WKKPP5C6.js → shodan-RYTNBHVJ.js} +5 -5
  92. package/dist/{shopify-64YDK5T2.js → shopify-JGWZFCNO.js} +6 -6
  93. package/dist/{stripe-QAIGGOTF.js → stripe-RBWCW52X.js} +4 -4
  94. package/dist/{supabase-WHTGR6ND.js → supabase-TX5J2UBD.js} +6 -6
  95. package/dist/{tavily-QIXCDDWO.js → tavily-33ZRT2RT.js} +6 -6
  96. package/dist/{telegram-E6G7CWI6.js → telegram-HX3UKW3Y.js} +5 -5
  97. package/dist/{telnyx-ZDVVS7PK.js → telnyx-5J74OO5R.js} +6 -6
  98. package/dist/{todoist-DMYF3G7J.js → todoist-6CUCDWTH.js} +6 -6
  99. package/dist/{trello-HY2RYIRP.js → trello-FTFDRPZ7.js} +5 -5
  100. package/dist/{turso-HAQWMGRP.js → turso-33T4OAJR.js} +6 -6
  101. package/dist/{twilio-MLXYPHJE.js → twilio-ZBX6EHFG.js} +4 -4
  102. package/dist/{umami-DZHBLPVG.js → umami-QCVTF7WS.js} +6 -6
  103. package/dist/{unsplash-GS2OPXKE.js → unsplash-M6XCQKQE.js} +6 -6
  104. package/dist/{upstash_redis-XMXWTNAJ.js → upstash_redis-57JQ3XMB.js} +6 -6
  105. package/dist/{uptimerobot-TF5WRZ4G.js → uptimerobot-KDS5YBKZ.js} +4 -4
  106. package/dist/{v2ex-2BVXAPDF.js → v2ex-5YPZ6BIT.js} +6 -6
  107. package/dist/{vercel-YMJGQYJE.js → vercel-6VWZHALZ.js} +6 -6
  108. package/dist/{wolfram_alpha_api-I56SXWFZ.js → wolfram_alpha_api-4YNRTVTQ.js} +5 -5
  109. package/dist/{wordpress-R7TDFZ2P.js → wordpress-LKN2EV4B.js} +6 -6
  110. package/dist/{workos-HDNHWVMS.js → workos-DTPEULYR.js} +6 -6
  111. package/dist/{zhihu-LX6AGGDS.js → zhihu-LFQRTQS7.js} +6 -6
  112. package/package.json +5 -5
@@ -0,0 +1,78 @@
1
+ import {
2
+ createPlugin
3
+ } from "./chunk-3VF7MQJX.js";
4
+ import {
5
+ TBError
6
+ } from "./chunk-TF2N67HN.js";
7
+ import "./chunk-U67V476Y.js";
8
+
9
+ // ../../node_modules/.pnpm/@octokit+webhooks-methods@6.0.0/node_modules/@octokit/webhooks-methods/dist-node/index.js
10
+ import { createHmac } from "crypto";
11
+ import { timingSafeEqual } from "crypto";
12
+ import { Buffer } from "buffer";
13
+ var VERSION = "6.0.0";
14
+ async function sign(secret, payload) {
15
+ if (!secret || !payload) {
16
+ throw new TypeError(
17
+ "[@octokit/webhooks-methods] secret & payload required for sign()"
18
+ );
19
+ }
20
+ if (typeof payload !== "string") {
21
+ throw new TypeError("[@octokit/webhooks-methods] payload must be a string");
22
+ }
23
+ const algorithm = "sha256";
24
+ return `${algorithm}=${createHmac(algorithm, secret).update(payload).digest("hex")}`;
25
+ }
26
+ sign.VERSION = VERSION;
27
+ async function verify(secret, eventPayload, signature) {
28
+ if (!secret || !eventPayload || !signature) {
29
+ throw new TypeError(
30
+ "[@octokit/webhooks-methods] secret, eventPayload & signature required"
31
+ );
32
+ }
33
+ if (typeof eventPayload !== "string") {
34
+ throw new TypeError(
35
+ "[@octokit/webhooks-methods] eventPayload must be a string"
36
+ );
37
+ }
38
+ const signatureBuffer = Buffer.from(signature);
39
+ const verificationBuffer = Buffer.from(await sign(secret, eventPayload));
40
+ if (signatureBuffer.length !== verificationBuffer.length) {
41
+ return false;
42
+ }
43
+ return timingSafeEqual(signatureBuffer, verificationBuffer);
44
+ }
45
+ verify.VERSION = VERSION;
46
+
47
+ // ../plugins/src/github_events/index.ts
48
+ import { z } from "zod/v4";
49
+ var dataSchema = z.object({ repository: z.string(), ref: z.string(), after: z.string() });
50
+ var pushSchema = z.object({
51
+ repository: z.object({ full_name: z.string() }),
52
+ ref: z.string(),
53
+ after: z.string()
54
+ });
55
+ var plugin = createPlugin({ token: (env) => env.PLUGIN_TOKEN });
56
+ plugin.events("pushes", {
57
+ description: "Signed GitHub push events",
58
+ headers: ["x-hub-signature-256"],
59
+ types: { "github.push": { version: 1, schema: dataSchema } },
60
+ async verify({ headers, rawBody }, ctx) {
61
+ const signature = headers["x-hub-signature-256"];
62
+ if (!signature || !ctx.upstreamAuth || !await verify(ctx.upstreamAuth, rawBody, signature)) {
63
+ throw TBError.unauthenticated();
64
+ }
65
+ const body = JSON.parse(rawBody);
66
+ if (z.object({ zen: z.string(), hook_id: z.number() }).safeParse(body).success) return null;
67
+ const result = pushSchema.safeParse(body);
68
+ if (!result.success) throw new TBError("invalid_argument", "expected a GitHub push payload");
69
+ const { repository, ref, after } = result.data;
70
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(rawBody));
71
+ const idempotencyKey = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
72
+ return { type: "github.push", data: { repository: repository.full_name, ref, after }, subject: repository.full_name, idempotencyKey };
73
+ }
74
+ });
75
+ var github_events_default = plugin;
76
+ export {
77
+ github_events_default as default
78
+ };
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  createAuthedClient
3
- } from "./chunk-TDAWLMDE.js";
4
- import "./chunk-VWRUGUSU.js";
3
+ } from "./chunk-CXRQCZBS.js";
4
+ import "./chunk-G6GI7EMV.js";
5
5
  import {
6
6
  asJsonObject
7
7
  } from "./chunk-JXHMDBAY.js";
8
8
  import {
9
9
  createProviderPlugin,
10
10
  upstreamError
11
- } from "./chunk-WJHG6OK7.js";
12
- import "./chunk-2JNAI4OC.js";
13
- import "./chunk-BADVCN6K.js";
11
+ } from "./chunk-UVG4PNWV.js";
12
+ import "./chunk-N7ZFZWGA.js";
13
+ import "./chunk-3VF7MQJX.js";
14
14
  import {
15
15
  TBError
16
- } from "./chunk-5ICRY3VU.js";
16
+ } from "./chunk-TF2N67HN.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/gmail/api/shared.ts
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createAuthedClient
3
- } from "./chunk-TDAWLMDE.js";
4
- import "./chunk-VWRUGUSU.js";
3
+ } from "./chunk-CXRQCZBS.js";
4
+ import "./chunk-G6GI7EMV.js";
5
5
  import {
6
6
  asJsonObject,
7
7
  compactDefined,
@@ -10,13 +10,13 @@ import {
10
10
  import {
11
11
  createProviderPlugin,
12
12
  upstreamError
13
- } from "./chunk-WJHG6OK7.js";
14
- import "./chunk-2JNAI4OC.js";
15
- import "./chunk-BADVCN6K.js";
13
+ } from "./chunk-UVG4PNWV.js";
14
+ import "./chunk-N7ZFZWGA.js";
15
+ import "./chunk-3VF7MQJX.js";
16
16
  import {
17
17
  TBError,
18
18
  isTBError
19
- } from "./chunk-5ICRY3VU.js";
19
+ } from "./chunk-TF2N67HN.js";
20
20
  import "./chunk-U67V476Y.js";
21
21
 
22
22
  // ../plugins/src/googlecalendar/api/shared.ts
@@ -9,15 +9,15 @@ import {
9
9
  createProviderPlugin,
10
10
  requireApiKey,
11
11
  upstreamError
12
- } from "./chunk-WJHG6OK7.js";
12
+ } from "./chunk-UVG4PNWV.js";
13
13
  import {
14
14
  guardedFetch
15
- } from "./chunk-2JNAI4OC.js";
16
- import "./chunk-BADVCN6K.js";
15
+ } from "./chunk-N7ZFZWGA.js";
16
+ import "./chunk-3VF7MQJX.js";
17
17
  import {
18
18
  TBError,
19
19
  isTBError
20
- } from "./chunk-5ICRY3VU.js";
20
+ } from "./chunk-TF2N67HN.js";
21
21
  import "./chunk-U67V476Y.js";
22
22
 
23
23
  // ../plugins/src/googledocs/api/shared.ts
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createAuthedClient
3
- } from "./chunk-TDAWLMDE.js";
4
- import "./chunk-VWRUGUSU.js";
3
+ } from "./chunk-CXRQCZBS.js";
4
+ import "./chunk-G6GI7EMV.js";
5
5
  import {
6
6
  asJsonObject,
7
7
  booleanValue,
@@ -13,14 +13,14 @@ import {
13
13
  createProviderPlugin,
14
14
  requireApiKey,
15
15
  upstreamError
16
- } from "./chunk-WJHG6OK7.js";
16
+ } from "./chunk-UVG4PNWV.js";
17
17
  import {
18
18
  assertPublicHttpUrl
19
- } from "./chunk-2JNAI4OC.js";
20
- import "./chunk-BADVCN6K.js";
19
+ } from "./chunk-N7ZFZWGA.js";
20
+ import "./chunk-3VF7MQJX.js";
21
21
  import {
22
22
  TBError
23
- } from "./chunk-5ICRY3VU.js";
23
+ } from "./chunk-TF2N67HN.js";
24
24
  import "./chunk-U67V476Y.js";
25
25
 
26
26
  // ../plugins/src/grafana/api.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderHttpClient
3
- } from "./chunk-VWRUGUSU.js";
3
+ } from "./chunk-G6GI7EMV.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-WJHG6OK7.js";
12
- import "./chunk-2JNAI4OC.js";
13
- import "./chunk-BADVCN6K.js";
11
+ } from "./chunk-UVG4PNWV.js";
12
+ import "./chunk-N7ZFZWGA.js";
13
+ import "./chunk-3VF7MQJX.js";
14
14
  import {
15
15
  TBError
16
- } from "./chunk-5ICRY3VU.js";
16
+ } from "./chunk-TF2N67HN.js";
17
17
  import "./chunk-U67V476Y.js";
18
18
 
19
19
  // ../plugins/src/graphhopper/api.ts
package/dist/index.d.ts CHANGED
@@ -29,6 +29,199 @@ interface ListOptions {
29
29
  }
30
30
  /** "user:alice" | "agent:researcher" | "device:build-01"。 */
31
31
  type OwnerRef = string;
32
+ interface CallContext {
33
+ /** 平台→Plugin envelope 专用:本次调用命中该 plugin 的哪个 export(v2 多 export 路由)。 */
34
+ exportId?: string;
35
+ /** 本次调用使用的 SK 的 id(非明文)。 */
36
+ keyId: string;
37
+ /** 平台→Plugin envelope 专用:挂载节点 config.providerConfig 透传(每挂载非敏感配置)。 */
38
+ mountConfig?: Record<string, unknown>;
39
+ /** 平台→Plugin envelope 专用:本次调用来自哪个挂载节点(同一 plugin 可多路径挂载)。 */
40
+ mountPath?: TreePath;
41
+ owner: OwnerRef;
42
+ /** 反向注册路径收紧规则;缺省按非保留根放行。 */
43
+ registerPaths?: TreePath[];
44
+ scopes: Scope[];
45
+ /** 全链路观测。 */
46
+ traceId: string;
47
+ }
48
+ type Action = 'read' | 'write' | 'call' | 'register' | 'admin';
49
+ interface Scope {
50
+ actions: Action[];
51
+ /** 默认 allow;deny 优先于一切 allow。 */
52
+ effect?: 'allow' | 'deny';
53
+ /** 树路径 glob:"**" | "docs/**" | "device/build-01/**"。 */
54
+ pattern: string;
55
+ }
56
+ type NodeKind = 'topic' | 'directory' | 'mcp' | 'http' | 'builtin' | 'context' | 'device' | 'remote' | 'tool' | 'skillhub';
57
+ interface TreeNode {
58
+ /** 按 kind 区分。 */
59
+ config?: NodeConfig;
60
+ createdAt: Timestamp;
61
+ /** 一句话;上级 ~help 列子节点时展示。 */
62
+ description: string;
63
+ /** 设备最后一次 hello 的环境快照;仅网关写入,不作为权限依据。 */
64
+ deviceEnvironment?: DeviceEnvironment;
65
+ /** 仅设备挂载根:hello 中声明的稳定设备身份。由设备注册流程写入,不接受普通 NodeInput。 */
66
+ deviceId?: string;
67
+ deviceReportedAt?: Timestamp;
68
+ kind: NodeKind;
69
+ /** 仅 device:最近一次观察到设备存活(hello / 心跳 / 成功调用)的时刻。缺省表示从未观察或旧数据;
70
+ * freshness 判定见 device/presence.ts。写路径专用,不经普通注册面。 */
71
+ lastSeenAt?: Timestamp;
72
+ /** 仅 device:连接是否已建立(hello 落库 true,连接拆除 false)。是否"可立即路由"还须看
73
+ * `lastSeenAt` 的新鲜度——投影时由 derivePresence 综合成三态 presence,不要直接把它当在线。 */
74
+ online?: boolean;
75
+ /** 唯一键。 */
76
+ path: TreePath;
77
+ /** keyId;device 节点由 Gateway 代写;自动物化 directory 为 'system:auto'。 */
78
+ registeredBy: string;
79
+ updatedAt: Timestamp;
80
+ /** 工具虚拟化(mcp/http 适用)。 */
81
+ virtualize?: Virtualize;
82
+ }
83
+ interface Virtualize {
84
+ /** description override。 */
85
+ describe?: Record<string, string>;
86
+ /** 隐藏的工具名。 */
87
+ hide?: string[];
88
+ /** 工具名统一加前缀。 */
89
+ prefix?: string;
90
+ /** 原名 → 虚拟名。 */
91
+ rename?: Record<string, string>;
92
+ }
93
+ interface HttpToolDef {
94
+ description: string;
95
+ /** 工具副作用词汇;缺省由 Provider 按 method/schema 派生。 */
96
+ effect?: 'read' | 'write' | 'destructive';
97
+ /** JSON Schema;~help 的数据源。 */
98
+ inputSchema?: unknown;
99
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
100
+ name: string;
101
+ /** 相对 endpoint;支持 {param} 占位。 */
102
+ pathTemplate: string;
103
+ }
104
+ /**
105
+ * MCP 托管 OAuth 的预注册客户端。clientId 是可回显标识;机密只允许通过
106
+ * clientSecretRef 指向 SecretStore,不能直接进入节点 config。
107
+ */
108
+ interface McpOAuthClientConfig {
109
+ clientId: string;
110
+ clientSecretRef?: string;
111
+ }
112
+ /** 有界的设备自报环境;禁止自动携带路径、环境变量或凭据。 */
113
+ interface DeviceEnvironment {
114
+ arch?: string;
115
+ platform: 'darwin' | 'linux' | 'win32' | 'android' | 'ios' | 'other';
116
+ runtime?: 'node' | 'bun' | 'react-native' | 'other';
117
+ runtimeId?: string;
118
+ runtimeVersion?: string;
119
+ }
120
+ interface DeviceExpose {
121
+ /** 宿主显式提供,neutral SDK 不采集本机信息。 */
122
+ environment?: DeviceEnvironment;
123
+ /** 挂 `<mountPath>/fs` context 节点(file provider);支持多根。 */
124
+ fs?: {
125
+ readOnly?: boolean;
126
+ roots: string[];
127
+ };
128
+ /** SDK 自定义节点(路径相对 mountPath)。 */
129
+ nodes?: DeviceNodeInput[];
130
+ /** 挂 `<mountPath>/shell` 工具节点;allow 白名单语义:缺省 [] = 全拒。 */
131
+ shell?: {
132
+ allow?: string[];
133
+ description?: string;
134
+ };
135
+ }
136
+ /** 设备命令的投递声明;缺省等价 realtime,mailbox/both 才允许显式 enqueue。 */
137
+ type DeviceCommandDelivery = 'realtime' | 'mailbox' | 'both';
138
+ /**
139
+ * expose.nodes 元素:NodeInput + 可选工具表 `cmds`(ToolSpec 形状,
140
+ * SDK 随注册上送;网关存入代写节点的 providerConfig 作 `~help` 数据源,不新增帧类型)。
141
+ */
142
+ type DeviceNodeInput = NodeInput & {
143
+ cmds?: DeviceNodeCmd[];
144
+ };
145
+ /** 设备自定义节点随注册上送的单条工具元数据(与 tool/types.ts 的 ToolSpec 同形)。 */
146
+ interface DeviceNodeCmd {
147
+ confirm?: boolean;
148
+ delivery?: DeviceCommandDelivery;
149
+ description?: string;
150
+ effect?: string;
151
+ inputSchema?: unknown;
152
+ name: string;
153
+ outputSchema?: unknown;
154
+ }
155
+ type NodeConfig = {
156
+ auth?: 'oauth';
157
+ /** authRef 凭证注入的头名(默认 Authorization)。 */
158
+ authHeader?: string;
159
+ authRef?: string;
160
+ /** 凭证前缀;空串 = 原样注入(默认 Bearer)。 */
161
+ authScheme?: string;
162
+ /** 静态明文请求头(非机密,如上游要求的工具白名单头);authRef 头优先。 */
163
+ headers?: Record<string, string>;
164
+ kind: 'mcp';
165
+ /** 缺省走 DCR;配置后使用预注册 public/confidential client,不尝试 DCR。 */
166
+ oauthClient?: McpOAuthClientConfig;
167
+ url: string;
168
+ } | {
169
+ authHeader?: string;
170
+ authRef?: string;
171
+ authScheme?: string;
172
+ endpoint: string;
173
+ kind: 'http';
174
+ tools: HttpToolDef[];
175
+ } | {
176
+ authRef: string;
177
+ export: string;
178
+ kind: 'topic';
179
+ provider: string;
180
+ } | {
181
+ kind: 'builtin';
182
+ module: string;
183
+ } | {
184
+ authRef?: string;
185
+ /** 多 export plugin:挂载的 export id;单 export 可省。 */
186
+ export?: string;
187
+ kind: 'context';
188
+ provider: string;
189
+ providerConfig?: Record<string, unknown>;
190
+ readOnly?: boolean;
191
+ /** ttl 秒:到期整节点回收(临时 namespace)。 */
192
+ ttl?: number;
193
+ } | {
194
+ deviceId: string;
195
+ expose: DeviceExpose;
196
+ kind: 'device';
197
+ } | {
198
+ baseUrl: string;
199
+ kind: 'remote';
200
+ skRef?: string;
201
+ }
202
+ /** tool-provider 挂载:provider = plugin id 或 SDK 内部保留 id(如 '@local')。
203
+ * providerConfig:设备自定义节点的转发标记(deviceId+mountPath+cmds,网关代写)。
204
+ * authRef:上游凭证引用,调用时平台 resolve 后经 X-TB-Upstream-Auth 注入 plugin。 */
205
+ | {
206
+ authRef?: string;
207
+ /** 多 export plugin:挂载的 export id;单 export 可省(见 plugin/contract resolvePluginExport)。 */
208
+ export?: string;
209
+ kind: 'tool';
210
+ provider: string;
211
+ providerConfig?: Record<string, unknown>;
212
+ }
213
+ /** skillhub:与 context 同形的内容型 kind,存 Agent Skill(每 skill = <id>/SKILL.md + 若干文本文件)。
214
+ * 底层复用 context 的对象存储(provider storage 用平台自带桶,无需外部凭证;s3 需 authRef)。 */
215
+ | {
216
+ authRef?: string;
217
+ kind: 'skillhub';
218
+ provider: string;
219
+ providerConfig?: Record<string, unknown>;
220
+ readOnly?: boolean;
221
+ /** ttl 秒:到期整节点回收(临时 hub)。 */
222
+ ttl?: number;
223
+ };
224
+ type NodeInput = Omit<TreeNode, 'registeredBy' | 'online' | 'lastSeenAt' | 'deviceId' | 'deviceEnvironment' | 'deviceReportedAt' | 'createdAt' | 'updatedAt'>;
32
225
 
33
226
  /**
34
227
  * StateStore:宿主注入的状态存储接口。
@@ -51,6 +244,9 @@ type OwnerRef = string;
51
244
  * store:call-capability:<id> → CallUploadCapability(token 仅存 hash)
52
245
  * store:share:<id> → ShareGrant(token 仅存 hash)
53
246
  */
247
+
248
+ /** A synchronous node edit. Storage holds the row stable until the edit commits. */
249
+ type NodeEdit = (current: TreeNode) => TreeNode;
54
250
  interface StateStore {
55
251
  /**
56
252
  * 可选原子 compare-and-swap 原语,供带 `revision` 的权威记录做跨副本状态转换。
@@ -87,6 +283,7 @@ interface StateStore {
87
283
  * 可选而非必选:必选会破坏 SDK 消费者已实现的自定义 StateStore。
88
284
  */
89
285
  putIfAbsent?(key: string, value: unknown): Promise<boolean>;
286
+ updateNode?(key: string, edit: NodeEdit): Promise<TreeNode | null>;
90
287
  }
91
288
 
92
289
  /**
@@ -179,6 +376,16 @@ declare class SecretStoreImpl {
179
376
  }>;
180
377
  }
181
378
 
379
+ /** Portable event source metadata shared by plugin and catalog views. */
380
+ interface PluginEventSource {
381
+ headers: string[];
382
+ types: Array<{
383
+ dataSchema: Record<string, unknown>;
384
+ type: string;
385
+ version: number;
386
+ }>;
387
+ }
388
+
182
389
  /**
183
390
  * Provider 型 OAuth2 的声明契约(与 mcp 上游的托管 OAuth 是**两套机制**)。
184
391
  *
@@ -236,7 +443,7 @@ interface PluginOAuth {
236
443
  */
237
444
 
238
445
  /** export 的语义档位。 */
239
- type PluginProfile = 'tools/v1' | 'context/v1';
446
+ type PluginProfile = 'tools/v1' | 'context/v1' | 'events/v1';
240
447
  /** 单个 export 的声明。 */
241
448
  interface PluginExport {
242
449
  /** 明确声明无需凭证,或声明单值凭证的展示/必填语义;与 oauth/credentialFields 三选一。 */
@@ -269,6 +476,7 @@ interface PluginExport {
269
476
  */
270
477
  credentialProbe?: string;
271
478
  description?: string;
479
+ eventSource?: PluginEventSource;
272
480
  id: string;
273
481
  methods?: string[];
274
482
  /**
@@ -362,6 +570,8 @@ interface BuiltinCatalogEntry {
362
570
  /** binding 名 → 目录项。 */
363
571
  type BuiltinCatalog = Record<string, BuiltinCatalogEntry>;
364
572
 
573
+ type PreparePluginImage = (id: string, image: string) => Promise<string>;
574
+
365
575
  /**
366
576
  * ObjectStore:对象存储抽象。
367
577
  *
@@ -1323,6 +1533,61 @@ interface DeviceCallAttempt {
1323
1533
  result: DeviceCallResult;
1324
1534
  }
1325
1535
 
1536
+ /** Portable public types; SDK declaration consumers do not need the validator package. */
1537
+ type EventData = string | number | boolean | null | EventData[] | {
1538
+ [key: string]: EventData;
1539
+ };
1540
+ interface EventPublishInput {
1541
+ data: EventData;
1542
+ idempotencyKey?: string;
1543
+ schemaVersion?: number;
1544
+ subject?: string;
1545
+ type: string;
1546
+ }
1547
+ interface EventReadInput {
1548
+ after?: string;
1549
+ limit?: number;
1550
+ type?: string;
1551
+ waitMs?: number;
1552
+ }
1553
+ interface EventReceipt {
1554
+ cursor: string;
1555
+ id: string;
1556
+ }
1557
+ interface EventEnvelope extends EventReceipt {
1558
+ data: EventData;
1559
+ recordedAt: string;
1560
+ schemaVersion: number;
1561
+ source: string;
1562
+ subject?: string;
1563
+ type: string;
1564
+ }
1565
+ interface EventReadResult {
1566
+ events: EventEnvelope[];
1567
+ gap?: {
1568
+ earliestCursor: string;
1569
+ reason: 'generation' | 'retention';
1570
+ };
1571
+ nextCursor: string;
1572
+ timedOut: boolean;
1573
+ }
1574
+
1575
+ interface EventTopicBinding {
1576
+ authRef: string;
1577
+ export: string;
1578
+ generation: string;
1579
+ provider: string;
1580
+ }
1581
+ interface EventRepository {
1582
+ acquireWait(keyId: string): Promise<() => Promise<void>>;
1583
+ /** One snapshot of the authenticated ingress binding. Null for absent or user topics. */
1584
+ binding(path: string): Promise<EventTopicBinding | null>;
1585
+ publish(path: string, actor: Pick<CallContext, 'keyId' | 'owner'>, input: EventPublishInput, expectedBinding?: EventTopicBinding): Promise<EventReceipt>;
1586
+ read(path: string, input: EventReadInput): Promise<EventReadResult>;
1587
+ /** A wake is only a hint. Each reader independently queries its durable position. */
1588
+ watch(path: string, wake: () => void): () => void;
1589
+ }
1590
+
1326
1591
  interface RuntimeRemoteSettings {
1327
1592
  allowInsecure: boolean;
1328
1593
  allowlist: string[];
@@ -1400,7 +1665,14 @@ interface ToolSearchDocument extends ToolSearchHit {
1400
1665
  * 可变索引的宿主契约。写入单位是节点快照,避免逐条 upsert 遗留已删除工具;
1401
1666
  * rebuild 用于首次 seed 与运维修复,removePrefix 用于设备子树回收。
1402
1667
  */
1668
+ interface SearchRegistrySnapshot {
1669
+ items: TreeNode[];
1670
+ truncated: boolean;
1671
+ }
1672
+ type BuildSearchDocuments = (nodes: readonly TreeNode[], getMany: (keys: readonly string[]) => Promise<Map<string, unknown>>) => Promise<ToolSearchDocument[]>;
1403
1673
  interface MutableSearchIndex extends SearchIndex {
1674
+ /** Optional for hosts sharing a transaction between canonical state and the index. */
1675
+ auditCanonical?(build: BuildSearchDocuments): Promise<SearchRegistrySnapshot>;
1404
1676
  initialized(): Promise<boolean>;
1405
1677
  rebuild(documents: readonly ToolSearchDocument[]): Promise<void>;
1406
1678
  remove(path: TreePath): Promise<void>;
@@ -1663,6 +1935,8 @@ interface TbAppDeps {
1663
1935
  encryptionKeyring?: EncryptionKeyring;
1664
1936
  /** 认证前的实例就绪钩子(引导/延迟注册 flush);每请求调用,幂等由宿主保证。 */
1665
1937
  ensureReady?: () => Promise<void>;
1938
+ eventRepository?: EventRepository;
1939
+ eventStreamShutdown?: AbortSignal;
1666
1940
  keyManagement?: KeyManagement;
1667
1941
  /** SDK 进程内 Provider 表(缺省无)。 */
1668
1942
  locals?: LocalProviderHooks;
@@ -1687,6 +1961,7 @@ interface TbAppDeps {
1687
1961
  * 那个插件解析不出 export;反之则解析得出但调不动(unavailable)。宿主该两者同源装配。
1688
1962
  */
1689
1963
  pluginCatalog?: BuiltinCatalog;
1964
+ preparePluginImage?: PreparePluginImage;
1690
1965
  /**
1691
1966
  * Provider OAuth 令牌端点的宿主出站通道。必须由宿主显式注入;缺省时 OAuth
1692
1967
  * 发起、回调兑换与 access-token 解析全部 fail closed,绝不回退到全局 fetch。
@@ -1765,6 +2040,7 @@ interface ServerConfig extends Partial<RuntimeConfig> {
1765
2040
  objectStore?: S3StoreConfig;
1766
2041
  pluginBindings?: PluginBindings;
1767
2042
  pluginCatalog?: BuiltinCatalog;
2043
+ pluginRunnerSocket?: string;
1768
2044
  port: number;
1769
2045
  redisUrl?: string;
1770
2046
  remote: RuntimeRemoteSettings;
@@ -1887,6 +2163,8 @@ declare class DeviceHub {
1887
2163
  private readonly upgradeHandler;
1888
2164
  private readonly store;
1889
2165
  private readonly search;
2166
+ private readonly publishedReclaimSec?;
2167
+ private resweepRequired;
1890
2168
  private reclaimSec;
1891
2169
  private readonly wss;
1892
2170
  private readonly activeByDevice;
@@ -1897,6 +2175,7 @@ declare class DeviceHub {
1897
2175
  private router;
1898
2176
  constructor(opts: {
1899
2177
  heartbeatMs?: number;
2178
+ publishedReclaimSec?: () => Promise<number>;
1900
2179
  reclaimSec: number;
1901
2180
  /** 多副本部署的调用路由工厂;拿到 onLocalCall 回调后构造(避免循环依赖)。 */
1902
2181
  router?: (onLocalCall: DeviceLocalCall) => DeviceRouter;
@@ -2034,6 +2313,7 @@ declare class MaintenanceManager implements MaintenanceManagement {
2034
2313
  interface ManagedServerOptions {
2035
2314
  directory: string;
2036
2315
  host?: string;
2316
+ pluginRunnerSocket?: string;
2037
2317
  port?: number;
2038
2318
  uiDir?: string;
2039
2319
  }
@@ -2049,6 +2329,25 @@ declare function createManagedServer(options: ManagedServerOptions): Promise<{
2049
2329
  shutdown(): Promise<void>;
2050
2330
  }>;
2051
2331
 
2332
+ /** Registry mutations and topic generations change in the same database transaction. */
2333
+ declare class PgEventRepository implements EventRepository {
2334
+ private readonly sql;
2335
+ private readonly watchers;
2336
+ private listener?;
2337
+ constructor(sql: Sql);
2338
+ ensureSchema(): Promise<void>;
2339
+ watch(path: string, wake: () => void): () => void;
2340
+ close(): Promise<void>;
2341
+ cleanup(): Promise<void>;
2342
+ acquireWait(keyId: string): Promise<() => Promise<void>>;
2343
+ binding(path: string): Promise<EventTopicBinding | null>;
2344
+ publish(path: string, actor: {
2345
+ keyId: string;
2346
+ owner: string;
2347
+ }, input: EventPublishInput, expectedBinding?: EventTopicBinding): Promise<EventReceipt>;
2348
+ read(path: string, input: EventReadInput): Promise<EventReadResult>;
2349
+ }
2350
+
2052
2351
  interface KeyRotationJob {
2053
2352
  changed: number;
2054
2353
  cursor: string | null;
@@ -2096,11 +2395,16 @@ declare class PgMailboxRepository implements MailboxRepository {
2096
2395
  private writeUnderLease;
2097
2396
  }
2098
2397
 
2099
- /** PostgreSQL driver: transactions and bounded VALUES batches; search SQL is owned by core/pgSearchSql. */
2100
-
2101
2398
  /** Node 自托管宿主的 postgres.js SearchIndex。 */
2102
2399
  declare class PgSearchIndex extends SqlSearchIndex {
2400
+ private readonly sql;
2401
+ private snapshot?;
2402
+ private auditing?;
2403
+ auditCanonical?: (build: BuildSearchDocuments) => Promise<SearchRegistrySnapshot>;
2103
2404
  constructor(sql: Sql);
2405
+ /** Install only when the standard host owns both tb_kv and this index. */
2406
+ enableCanonicalAudit(): Promise<void>;
2407
+ private audit;
2104
2408
  }
2105
2409
 
2106
2410
  /**
@@ -2126,7 +2430,10 @@ declare class PgStateStore implements StateStore {
2126
2430
  ensureContextReferencesSchema(): Promise<void>;
2127
2431
  get(key: string): Promise<unknown | null>;
2128
2432
  getMany(keys: readonly string[]): Promise<Map<string, unknown>>;
2433
+ private upsert;
2129
2434
  put(key: string, value: unknown): Promise<void>;
2435
+ private syncContextReference;
2436
+ updateNode(key: string, edit: (current: TreeNode) => TreeNode): Promise<TreeNode | null>;
2130
2437
  compareAndSwap(key: string, expectedRevision: number | null, value: unknown | null): Promise<boolean>;
2131
2438
  putIfAbsent(key: string, value: unknown): Promise<boolean>;
2132
2439
  delete(key: string): Promise<void>;
@@ -2251,11 +2558,14 @@ declare class StorageManager implements StorageManagement, StoreBackendResolver
2251
2558
  declare class ConfigManager implements ConfigManagement {
2252
2559
  private readonly sql;
2253
2560
  private readonly onApply;
2561
+ private readonly onPublished?;
2254
2562
  private localRevision;
2255
2563
  private localEffective;
2256
2564
  private localError;
2565
+ private committedRevision;
2257
2566
  private serial;
2258
- constructor(sql: Sql, onApply: (settings: RuntimeConfig) => Promise<void>);
2567
+ constructor(sql: Sql, onApply: (settings: RuntimeConfig) => Promise<void>, onPublished?: ((settings: RuntimeConfig) => Promise<void>) | undefined);
2568
+ private activatePublished;
2259
2569
  ensureSchema(defaults?: {
2260
2570
  canonicalOrigin: string;
2261
2571
  remoteAllowlist: string[];
@@ -2318,4 +2628,4 @@ interface TbServer {
2318
2628
  }
2319
2629
  declare function createTbServer(config: ServerConfig): TbServer;
2320
2630
 
2321
- export { BootstrapStateStore, DEVICE_FORWARD_TIMEOUT_MS, DEVICE_ROUTE_TTL_SEC, DEVICE_WS_PATH, DeviceHub, type DeviceLocalCall, DeviceRouter, type DeviceRouterBackend, type KeyManagementHooks, KeyManager, type MaintenanceHooks, MaintenanceManager, type ManagedServerOptions, PgKeyRotation, PgMailboxRepository, PgSearchIndex, PgStateStore, PgStoreRepository, RedisDeviceRouterBackend, type S3ObjectStore, type S3ObjectStoreOptions, type S3ProbeResult, type ServerConfig, StorageManager, type TbServer, createManagedServer, createS3ObjectStore, createTbServer, probeS3ObjectStore, runtimeAppSettings };
2631
+ export { BootstrapStateStore, DEVICE_FORWARD_TIMEOUT_MS, DEVICE_ROUTE_TTL_SEC, DEVICE_WS_PATH, DeviceHub, type DeviceLocalCall, DeviceRouter, type DeviceRouterBackend, type KeyManagementHooks, KeyManager, type MaintenanceHooks, MaintenanceManager, type ManagedServerOptions, PgEventRepository, PgKeyRotation, PgMailboxRepository, PgSearchIndex, PgStateStore, PgStoreRepository, RedisDeviceRouterBackend, type S3ObjectStore, type S3ObjectStoreOptions, type S3ProbeResult, type ServerConfig, StorageManager, type TbServer, createManagedServer, createS3ObjectStore, createTbServer, probeS3ObjectStore, runtimeAppSettings };