@tool-bridge/server 0.3.0 → 0.5.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 (108) hide show
  1. package/dist/{airtable-V6446SVY.js → airtable-7TFNLFIF.js} +6 -4
  2. package/dist/{alt_text_generator_ai-HV7JZPDT.js → alt_text_generator_ai-VJSAHBJM.js} +6 -4
  3. package/dist/{amap-TTTVB6WS.js → amap-KZMUDGK6.js} +6 -4
  4. package/dist/{anthropic-JH3RA363.js → anthropic-C6FCUSY7.js} +6 -4
  5. package/dist/{apify-ETNN7ITU.js → apify-MUCWNIWU.js} +6 -4
  6. package/dist/{brave_search-3DDR2MMB.js → brave_search-NRVZ4ZNY.js} +6 -4
  7. package/dist/{chunk-KGYJEEBI.js → chunk-3C3J36GT.js} +106 -61
  8. package/dist/{chunk-CSJEZHQO.js → chunk-7GP7DRES.js} +13 -82
  9. package/dist/{chunk-JLTYA2B3.js → chunk-7PM4FD5K.js} +100 -71
  10. package/dist/{chunk-K7FVSFUX.js → chunk-B4ZA7EGO.js} +47 -3
  11. package/dist/chunk-FHYFPPBZ.js +90 -0
  12. package/dist/{circleci-MX3TX3HC.js → circleci-QY36SZIM.js} +6 -4
  13. package/dist/{clerk-MRPORVF4.js → clerk-ECH23XL5.js} +6 -4
  14. package/dist/{cloudflare_dns-OWP7DD7L.js → cloudflare_dns-F6DN2F3X.js} +6 -4
  15. package/dist/{cohere-GPECP66S.js → cohere-HD4XZOPJ.js} +6 -4
  16. package/dist/{confluence-BN7LZ6BC.js → confluence-J4AZ2KYL.js} +6 -4
  17. package/dist/{convertapi-SBEOFOFQ.js → convertapi-BXBII5Z6.js} +7 -5
  18. package/dist/{currencyapi-P2YY7Y7P.js → currencyapi-HEEQ7EQJ.js} +6 -4
  19. package/dist/{deepseek-MWB3NYIN.js → deepseek-RKRGIFPM.js} +6 -4
  20. package/dist/{docker_hub-3JSCIGQ3.js → docker_hub-YFSTEZVP.js} +6 -4
  21. package/dist/{dropbox-RFIBDAXO.js → dropbox-VGK634PO.js} +6 -4
  22. package/dist/{dub-YVP57ELQ.js → dub-GEXD3XK6.js} +6 -4
  23. package/dist/{e2b-NFSUHTZR.js → e2b-LPTZQEDV.js} +6 -4
  24. package/dist/{exa-KTDY6IV3.js → exa-VJENLTKN.js} +6 -4
  25. package/dist/{fal_ai-OCUENLNQ.js → fal_ai-75O63LLP.js} +6 -4
  26. package/dist/{feishu-5CWBQ7E5.js → feishu-FATBHGEJ.js} +12 -4
  27. package/dist/{feishu_custom_bot-ZJR22OK6.js → feishu_custom_bot-QFSYPOLI.js} +6 -4
  28. package/dist/{figma-YULGANSA.js → figma-JED3Q56H.js} +6 -4
  29. package/dist/{firehydrant-2V6YSYAP.js → firehydrant-7JDKFJTB.js} +6 -4
  30. package/dist/{fixer-LTCDB3CJ.js → fixer-ZI2JS5GU.js} +6 -4
  31. package/dist/{fly-IXPKMAML.js → fly-3RA7ETFP.js} +6 -4
  32. package/dist/{front-KRFB4M5X.js → front-X2CJXBYS.js} +6 -4
  33. package/dist/{geocodio-VVURKYHQ.js → geocodio-C6NHG5UJ.js} +6 -4
  34. package/dist/{ghost-6J2RIOUB.js → ghost-ZBFOMWQF.js} +7 -5
  35. package/dist/{github-5Z6KQRYH.js → github-6QM2NIP4.js} +6 -4
  36. package/dist/{gmail-KU4NZ7VA.js → gmail-ST3MS32S.js} +6 -4
  37. package/dist/{googlecalendar-X44DFFXG.js → googlecalendar-SAUTUJ3Q.js} +6 -4
  38. package/dist/{googledocs-WSGLPKSF.js → googledocs-2SJKS2SC.js} +6 -4
  39. package/dist/{grafana-4PKSSDXY.js → grafana-RP7DOS3A.js} +13 -5
  40. package/dist/{graphhopper-DF65ZNGK.js → graphhopper-XSDTLJTE.js} +6 -4
  41. package/dist/index.d.ts +43 -10
  42. package/dist/index.js +2 -2
  43. package/dist/{ip2proxy-UCAQ5P2J.js → ip2proxy-IKV5IWUI.js} +6 -4
  44. package/dist/{ipgeolocation_io-UX6FCA2S.js → ipgeolocation_io-NSUWUF5X.js} +6 -4
  45. package/dist/{ipqualityscore-MKTRXIZJ.js → ipqualityscore-ZQKL3WLC.js} +6 -4
  46. package/dist/{jina_ai-MRHPCSV5.js → jina_ai-F4Y7V5AS.js} +6 -4
  47. package/dist/{jira-EG7ZPOIW.js → jira-CYDY44ZO.js} +7 -5
  48. package/dist/{langsmith-FNO3RCOZ.js → langsmith-74JSSJNY.js} +19 -4
  49. package/dist/{lemlist-SN6BJHSG.js → lemlist-C3LKIPVN.js} +6 -4
  50. package/dist/{linear-H3VU4PSD.js → linear-YYGRHKJC.js} +6 -4
  51. package/dist/{logsnag-OY2JJT2H.js → logsnag-YBMDJ6DO.js} +6 -4
  52. package/dist/main.js +184 -184
  53. package/dist/{mattermost-C5SQ7PGD.js → mattermost-NDID4TAL.js} +7 -5
  54. package/dist/{mem0-LMLE5BFC.js → mem0-ASBAEBWR.js} +6 -4
  55. package/dist/{memos-UWFAMBZC.js → memos-76I27HCW.js} +13 -5
  56. package/dist/{metabase-SRYDSDJ6.js → metabase-LCPIP2DL.js} +13 -5
  57. package/dist/{mistral_ai-YNIJ7VDM.js → mistral_ai-YVBQ6QKO.js} +7 -5
  58. package/dist/{mother_duck-CPGOFEXE.js → mother_duck-J2MPBIFO.js} +6 -4
  59. package/dist/{ngrok-CDJFBSOM.js → ngrok-UJC2ORDH.js} +6 -4
  60. package/dist/{notes-DIVFH3P3.js → notes-6VWWD6RW.js} +10 -3
  61. package/dist/{notion-HGDKS4HK.js → notion-6LBO2KHR.js} +6 -4
  62. package/dist/{open_exchange_rates-COHHYJDD.js → open_exchange_rates-OGDH4ZBX.js} +6 -4
  63. package/dist/{openai-4TRT66GW.js → openai-IKGD5M66.js} +7 -5
  64. package/dist/{opengraph_io-YKVW4PXI.js → opengraph_io-CIILQ7VK.js} +7 -5
  65. package/dist/{openrouter-6CV7B7V5.js → openrouter-IYG5CPG5.js} +6 -4
  66. package/dist/{outline-YWDUK5F7.js → outline-R2UMBY4M.js} +13 -5
  67. package/dist/{paddle-MEU7HWDZ.js → paddle-IYWA7DOV.js} +6 -4
  68. package/dist/{perplexity-MRQUDBIC.js → perplexity-3TGYQWHT.js} +6 -4
  69. package/dist/{pinecone-JI7X2TAF.js → pinecone-TEBOW4LJ.js} +6 -4
  70. package/dist/{pipedrive-6JQPAW23.js → pipedrive-ZXDY753U.js} +6 -4
  71. package/dist/{polar-7BF56CMC.js → polar-BVZV5A4O.js} +6 -4
  72. package/dist/{posthog-YPU5ADEN.js → posthog-DXKAS4PJ.js} +20 -5
  73. package/dist/{postmark-BEU5OFKU.js → postmark-6RWFC3TD.js} +6 -4
  74. package/dist/{prerender-UT5GOOZH.js → prerender-YIXOTM3K.js} +6 -4
  75. package/dist/{pubmed-3SGOE24Q.js → pubmed-2RHSZB4E.js} +6 -4
  76. package/dist/{railway-CEK4GLRQ.js → railway-IF64BUE2.js} +12 -4
  77. package/dist/{readwise-DXQUQU67.js → readwise-5XKQZNOM.js} +6 -4
  78. package/dist/{render-7TGAU5AW.js → render-Q2Z66LTA.js} +6 -4
  79. package/dist/{replicate-VICFSQ5A.js → replicate-SOI65IJO.js} +6 -4
  80. package/dist/{resend-3E76WK3O.js → resend-O2BGONOO.js} +6 -4
  81. package/dist/{rootly-36GY46BY.js → rootly-WPQKTVU3.js} +6 -4
  82. package/dist/{scrapfly-VDVUYAHX.js → scrapfly-GLMBVNPG.js} +6 -4
  83. package/dist/{scrapingbee-3KTPMAVY.js → scrapingbee-TUER54CY.js} +6 -4
  84. package/dist/{screenshot_fyi-LKG62C3J.js → screenshot_fyi-4J4W5EKY.js} +6 -4
  85. package/dist/{semantic_scholar-4WREECYO.js → semantic_scholar-4PITOANV.js} +6 -4
  86. package/dist/{sentry-HUQTGXOV.js → sentry-4WURPLIE.js} +6 -4
  87. package/dist/{shodan-SGRKU4KS.js → shodan-G3M3LFEW.js} +6 -4
  88. package/dist/{shopify-YCZ4L5HT.js → shopify-72AIELMS.js} +6 -4
  89. package/dist/{stripe-OEBKMELB.js → stripe-7C7XVPMU.js} +6 -4
  90. package/dist/{supabase-I3DBY7L4.js → supabase-N4Y3YC23.js} +6 -4
  91. package/dist/{tavily-B2YHCNRD.js → tavily-GGLSWERP.js} +6 -4
  92. package/dist/{telegram-2VYJELZX.js → telegram-4RH36WYP.js} +7 -5
  93. package/dist/{telnyx-HHXD3CXL.js → telnyx-I2KUITFV.js} +6 -4
  94. package/dist/{todoist-PHFDEEIS.js → todoist-A3NX6X2Y.js} +6 -4
  95. package/dist/{trello-WUSAK6YN.js → trello-2GJYN7GR.js} +6 -4
  96. package/dist/{turso-FW56U2B3.js → turso-WKUXMTZ5.js} +6 -4
  97. package/dist/{twilio-M5JI7XHA.js → twilio-SSXDBOK4.js} +6 -4
  98. package/dist/{umami-HAYODRC4.js → umami-SBDB4GXK.js} +6 -4
  99. package/dist/{unsplash-EDPTNEHJ.js → unsplash-4AVC4ZGP.js} +6 -4
  100. package/dist/{upstash_redis-GC2CLIWD.js → upstash_redis-7XY3UHBO.js} +6 -4
  101. package/dist/{uptimerobot-XMSNYLIT.js → uptimerobot-QVQP3QYG.js} +6 -4
  102. package/dist/{v2ex-KU4ECD65.js → v2ex-ASVTIKO7.js} +6 -4
  103. package/dist/{vercel-THPCEFHW.js → vercel-ZQXZCGWY.js} +6 -4
  104. package/dist/{wolfram_alpha_api-WHHTH4GU.js → wolfram_alpha_api-RVBWQSEF.js} +6 -4
  105. package/dist/{wordpress-O6TQEQNF.js → wordpress-SOWKVNCX.js} +7 -5
  106. package/dist/{workos-A3VHHWI3.js → workos-F45INANB.js} +6 -4
  107. package/dist/{zhihu-BJAI64YJ.js → zhihu-5VODAGAP.js} +6 -4
  108. package/package.json +5 -5
@@ -15083,23 +15083,50 @@ var NODE_KIND_BY_PROFILE = {
15083
15083
  "tools/v1": "tool",
15084
15084
  "context/v1": "context"
15085
15085
  };
15086
+ function projectExportAuth(exported) {
15087
+ if (exported.oauth !== void 0) return { kind: "oauth" };
15088
+ if (exported.credentialFields !== void 0) {
15089
+ return { kind: "fields", fields: exported.credentialFields };
15090
+ }
15091
+ if (exported.auth?.kind === "none") return { kind: "none" };
15092
+ if (exported.auth?.kind !== "single") {
15093
+ throw new TBError(
15094
+ "invalid_argument",
15095
+ `catalog export '${exported.id}' \u5FC5\u987B\u663E\u5F0F\u58F0\u660E auth\u3001oauth \u6216 credentialFields`
15096
+ );
15097
+ }
15098
+ return {
15099
+ kind: "single",
15100
+ required: exported.auth.required ?? false,
15101
+ ...exported.auth.label !== void 0 ? { label: exported.auth.label } : {},
15102
+ ...exported.auth.description !== void 0 ? { description: exported.auth.description } : {}
15103
+ };
15104
+ }
15086
15105
  function projectListItem(entry) {
15087
15106
  const exports = entry.describe.exports;
15088
15107
  const kinds = /* @__PURE__ */ new Set();
15108
+ const exportDetails = {};
15089
15109
  for (const e of exports) {
15090
15110
  const kind = NODE_KIND_BY_PROFILE[e.profile];
15091
- if (kind !== void 0) kinds.add(kind);
15111
+ if (kind !== void 0) {
15112
+ kinds.add(kind);
15113
+ exportDetails[e.id] = {
15114
+ id: e.id,
15115
+ kind,
15116
+ auth: projectExportAuth(e),
15117
+ ...e.description !== void 0 ? { description: e.description } : {},
15118
+ ...e.mountConfigFields !== void 0 ? { mountConfigFields: e.mountConfigFields } : {}
15119
+ };
15120
+ }
15092
15121
  }
15093
- const withFields = exports.find((e) => e.credentialFields !== void 0);
15094
15122
  const description = exports.find((e) => e.description !== void 0)?.description;
15095
15123
  return {
15096
15124
  id: entry.id,
15097
15125
  digest: entry.digest,
15098
15126
  exports: exports.map((e) => e.id),
15127
+ exportDetails,
15099
15128
  nodeKinds: [...kinds].sort(),
15100
- needsOAuth: exports.some((e) => e.oauth !== void 0),
15101
- ...description !== void 0 ? { description } : {},
15102
- ...withFields?.credentialFields !== void 0 ? { credentialFields: withFields.credentialFields } : {}
15129
+ ...description !== void 0 ? { description } : {}
15103
15130
  };
15104
15131
  }
15105
15132
  function matches2(item, query) {
@@ -15115,7 +15142,7 @@ function catalogCmds(nodePath) {
15115
15142
  path,
15116
15143
  h: "list built-in integrations available on this host (no credentials, read scope)",
15117
15144
  inputSchema: { type: "object", properties: { opts: LIST_OPTS_SCHEMA } },
15118
- returns: "Page<CatalogListItem> \u2014 id, exports, nodeKinds, credential field names",
15145
+ returns: "Page<CatalogListItem> \u2014 id, exports, nodeKinds, exportDetails",
15119
15146
  scope: "read"
15120
15147
  },
15121
15148
  {
@@ -15396,6 +15423,15 @@ function optionalMethodsForCapabilities(capabilities) {
15396
15423
  return methods;
15397
15424
  }
15398
15425
  var EXPORT_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
15426
+ var exportAuthSchema = external_exports.discriminatedUnion("kind", [
15427
+ external_exports.object({ kind: external_exports.literal("none") }),
15428
+ external_exports.object({
15429
+ kind: external_exports.literal("single"),
15430
+ description: external_exports.string().optional(),
15431
+ label: external_exports.string().optional(),
15432
+ required: external_exports.boolean().optional()
15433
+ })
15434
+ ]);
15399
15435
  var exportSchema = external_exports.object({
15400
15436
  id: external_exports.string().regex(EXPORT_ID_RE, "export id \u987B\u4E3A [A-Za-z0-9._-] \u4E14\u4E0D\u4EE5\u6807\u70B9\u5F00\u5934"),
15401
15437
  profile: external_exports.enum(PLUGIN_PROFILES),
@@ -15403,17 +15439,19 @@ var exportSchema = external_exports.object({
15403
15439
  /** context/v1:实际提供的动词;tools/v1 由运行时 List 发现,可省。 */
15404
15440
  methods: external_exports.array(external_exports.string()).optional(),
15405
15441
  capabilities: external_exports.array(external_exports.string()).optional(),
15442
+ /** export 的单值/无凭证声明;多字段与 OAuth 继续由各自字段表达。 */
15443
+ auth: exportAuthSchema.optional(),
15406
15444
  /**
15407
15445
  * tools/v1 可选:一个**只读、零副作用、无必填入参**的工具名,平台在挂载时拿它做一次
15408
15446
  * 真实调用来验证 `authRef` 指向的凭证可用(见 `credentialProbe` 的类型注释)。
15409
15447
  */
15410
15448
  credentialProbe: external_exports.string().optional(),
15411
15449
  /**
15412
- * 多字段凭证的字段声明(tools/v1)。声明了它,平台就知道该 secret 存的是一个 JSON
15450
+ * 多字段凭证的字段声明(tools/v1)。声明了它,平台就知道该 secret 存的是一个 JSON
15413
15451
  * 对象而非单值,并在挂载时校验字段齐全 —— 见 `credentialFields` 的类型注释。
15414
15452
  */
15415
15453
  /**
15416
- * provider 型 OAuth2 的声明(tools/v1)。声明了它,平台就托管授权码流程:
15454
+ * provider 型 OAuth2 的声明(tools/v1)。声明了它,平台就托管授权码流程:
15417
15455
  * `POST /<path>/~authorize` 发起、回调兑换、调用时自动刷新,插件只拿到 access token。
15418
15456
  */
15419
15457
  oauth: pluginOAuthSchema.optional(),
@@ -15424,6 +15462,17 @@ var exportSchema = external_exports.object({
15424
15462
  required: external_exports.boolean().optional(),
15425
15463
  /** 敏感字段:管理面不回显、日志不打印。缺省按敏感处理(fail safe)。 */
15426
15464
  secret: external_exports.boolean().optional()
15465
+ })).min(1).optional(),
15466
+ /**
15467
+ * 非凭证的挂载配置字段(如 baseUrl / instanceUrl / region)。声明了它,平台就知道
15468
+ * 该 export 挂载时还需要哪些 `providerConfig`,管理面据此渲染带标签的输入框而不是让
15469
+ * 用户对着一个自由 k=v 框猜 —— 见 `mountConfigFields` 的类型注释。
15470
+ */
15471
+ mountConfigFields: external_exports.array(external_exports.object({
15472
+ key: external_exports.string().regex(/^[A-Za-z_][\w]*$/, "\u5B57\u6BB5\u540D\u987B\u4E3A\u5408\u6CD5\u6807\u8BC6\u7B26"),
15473
+ label: external_exports.string().optional(),
15474
+ description: external_exports.string().optional(),
15475
+ required: external_exports.boolean().optional()
15427
15476
  })).min(1).optional()
15428
15477
  });
15429
15478
  var describeSchema = external_exports.object({
@@ -15453,6 +15502,26 @@ function validatePluginContract(input) {
15453
15502
  throw new TBError("invalid_argument", `plugin '${manifest.id}' \u7684 export id \u91CD\u590D:'${exported.id}'`);
15454
15503
  }
15455
15504
  seen.add(exported.id);
15505
+ if (exported.auth === void 0 && exported.oauth === void 0 && exported.credentialFields === void 0) {
15506
+ throw new TBError(
15507
+ "invalid_argument",
15508
+ `plugin '${manifest.id}' export '${exported.id}' \u5FC5\u987B\u663E\u5F0F\u58F0\u660E auth\u3001oauth \u6216 credentialFields`
15509
+ );
15510
+ }
15511
+ if (exported.auth !== void 0) {
15512
+ if (exported.oauth !== void 0 || exported.credentialFields !== void 0) {
15513
+ throw new TBError(
15514
+ "invalid_argument",
15515
+ `plugin '${manifest.id}' export '${exported.id}' \u7684 auth \u4E0D\u80FD\u4E0E oauth/credentialFields \u540C\u65F6\u58F0\u660E`
15516
+ );
15517
+ }
15518
+ if (exported.auth.kind === "none" && exported.credentialProbe !== void 0) {
15519
+ throw new TBError(
15520
+ "invalid_argument",
15521
+ `plugin '${manifest.id}' export '${exported.id}' \u58F0\u660E auth:none,\u4E0D\u80FD\u518D\u58F0\u660E credentialProbe`
15522
+ );
15523
+ }
15524
+ }
15456
15525
  if (exported.credentialProbe !== void 0 && exported.profile !== "tools/v1") {
15457
15526
  throw new TBError(
15458
15527
  "invalid_argument",
@@ -15497,6 +15566,18 @@ function validatePluginContract(input) {
15497
15566
  keys.add(field.key);
15498
15567
  }
15499
15568
  }
15569
+ if (exported.mountConfigFields !== void 0) {
15570
+ const keys = /* @__PURE__ */ new Set();
15571
+ for (const field of exported.mountConfigFields) {
15572
+ if (keys.has(field.key)) {
15573
+ throw new TBError(
15574
+ "invalid_argument",
15575
+ `plugin '${manifest.id}' export '${exported.id}' \u7684 mountConfigFields \u6709\u91CD\u590D\u5B57\u6BB5 '${field.key}'`
15576
+ );
15577
+ }
15578
+ keys.add(field.key);
15579
+ }
15580
+ }
15500
15581
  if (exported.profile === "context/v1") {
15501
15582
  const known = new Set(CONTEXT_METHODS);
15502
15583
  const unknown2 = (exported.methods ?? []).filter((m) => !known.has(m));
@@ -15593,14 +15674,14 @@ var authSchema = external_exports.discriminatedUnion("kind", [
15593
15674
  ]);
15594
15675
  var manifestSchema = external_exports.object({
15595
15676
  id: external_exports.string().regex(ID_RE, "id \u987B\u4E3A path-segment \u5B89\u5168\u5B57\u7B26([A-Za-z0-9._-],\u4E0D\u4EE5\u6807\u70B9\u5F00\u5934)"),
15596
- protocolVersion: external_exports.string().default(PLUGIN_PROTOCOL_VERSION).refine((v) => v === PLUGIN_PROTOCOL_VERSION, {
15677
+ protocolVersion: external_exports.string().refine((v) => v === PLUGIN_PROTOCOL_VERSION, {
15597
15678
  error: `protocolVersion \u987B\u4E3A '${PLUGIN_PROTOCOL_VERSION}'`
15598
15679
  }),
15599
15680
  endpoint: external_exports.string().min(1),
15600
15681
  auth: authSchema,
15601
15682
  healthPath: external_exports.string().regex(/^\//, "healthPath \u987B\u4EE5 '/' \u5F00\u5934"),
15602
15683
  enabled: external_exports.boolean()
15603
- });
15684
+ }).strict();
15604
15685
  function parsePluginManifest(value, opts = {}) {
15605
15686
  const parsed = manifestSchema.safeParse(value);
15606
15687
  if (!parsed.success) {
@@ -15718,15 +15799,6 @@ function pluginCmds(nodePath) {
15718
15799
  inputSchema: idSchema2,
15719
15800
  returns: "{ id, healthy, checkedAt }",
15720
15801
  scope: "admin"
15721
- },
15722
- {
15723
- name: "catalog",
15724
- method: "POST",
15725
- path,
15726
- h: "list in-process plugins assembled by this host (available, not yet activated); register one via write with its endpoint value",
15727
- inputSchema: { type: "object", properties: {} },
15728
- returns: "{ items: Array<{ name, endpoint, registered, pluginId? }> }",
15729
- scope: "admin"
15730
15802
  }
15731
15803
  ];
15732
15804
  }
@@ -15746,10 +15818,14 @@ function createPluginModule(deps) {
15746
15818
  }
15747
15819
  async function view(record2) {
15748
15820
  const describe3 = await store.get(KEY_PLUGIN_META + record2.id);
15749
- return {
15750
- ...projectManifest(record2),
15751
- ...describe3?.exports !== void 0 ? { exports: describe3.exports } : {}
15752
- };
15821
+ if (describe3 === null) {
15822
+ throw new TBError(
15823
+ "unavailable",
15824
+ `plugin '${record2.id}' \u7F3A\u5C11 ~describe \u7F13\u5B58,\u8BF7\u91CD\u65B0\u6CE8\u518C`,
15825
+ { retryable: false }
15826
+ );
15827
+ }
15828
+ return { ...projectManifest(record2), exports: describe3.exports };
15753
15829
  }
15754
15830
  async function revokeToken(record2) {
15755
15831
  if (record2.tokenSkId !== void 0) await sk.delete(record2.tokenSkId);
@@ -15913,33 +15989,6 @@ function createPluginModule(deps) {
15913
15989
  const record2 = await probeAndRecord(manifest);
15914
15990
  return { id, healthy: record2.healthy, checkedAt: record2.checkedAt };
15915
15991
  }
15916
- case "catalog": {
15917
- const names = deps.bindings?.() ?? [];
15918
- const byEndpoint = /* @__PURE__ */ new Map();
15919
- let cursor;
15920
- do {
15921
- const page = await store.list(KEY_PLUGIN, {
15922
- limit: LIST_LIMIT_MAX,
15923
- ...cursor !== void 0 ? { cursor } : {}
15924
- });
15925
- for (const { value } of page.items) {
15926
- const record2 = value;
15927
- byEndpoint.set(record2.endpoint, record2.id);
15928
- }
15929
- cursor = page.cursor;
15930
- } while (cursor !== void 0);
15931
- const items = [...names].sort().map((name) => {
15932
- const endpoint = `binding:${name}`;
15933
- const pluginId = byEndpoint.get(endpoint);
15934
- return {
15935
- name,
15936
- endpoint,
15937
- registered: pluginId !== void 0,
15938
- ...pluginId !== void 0 ? { pluginId } : {}
15939
- };
15940
- });
15941
- return { items };
15942
- }
15943
15992
  default:
15944
15993
  throw new TBError("invalid_argument", `unknown cmd '${cmd}' on system/plugin`);
15945
15994
  }
@@ -18169,8 +18218,7 @@ async function resolveExternalExport(store, id, nodeKind, what, exportId) {
18169
18218
  }
18170
18219
  async function resolveIntegration(store, catalog, id, nodeKind, what, exportId) {
18171
18220
  const manifest = await store.get(KEY_PLUGIN + id);
18172
- const isBinding = manifest?.endpoint.startsWith("binding:") === true;
18173
- if (manifest !== null && !(isBinding && catalog[id] !== void 0)) {
18221
+ if (manifest !== null) {
18174
18222
  return await resolveExternalExport(store, id, nodeKind, what, exportId);
18175
18223
  }
18176
18224
  return resolveBuiltinExport(catalog, id, nodeKind, what, exportId);
@@ -18346,25 +18394,6 @@ function decodePluginCall(body) {
18346
18394
  return parsed.data;
18347
18395
  }
18348
18396
 
18349
- // ../core/src/plugin/package.ts
18350
- var PLUGIN_BUNDLE_MAX_BYTES = 5 * 1024 * 1024;
18351
- var NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
18352
- var SHA256_HEX_RE = /^[0-9a-f]{64}$/;
18353
- var VERSION_RE = /^\d+\.\d+\.\d+(?:[-+.][A-Za-z0-9.-]+)?$/;
18354
- var packageSchema = external_exports.object({
18355
- name: external_exports.string().regex(NAME_RE, "name \u987B\u4E3A path-segment \u5B89\u5168\u5B57\u7B26([A-Za-z0-9._-],\u4E0D\u4EE5\u6807\u70B9\u5F00\u5934)"),
18356
- version: external_exports.string().regex(VERSION_RE, "version \u987B\u4E3A semver(\u5982 1.2.3)"),
18357
- bundleUrl: external_exports.string().min(1),
18358
- sha256: external_exports.string().regex(SHA256_HEX_RE, "sha256 \u987B\u4E3A 64 \u4F4D hex \u5C0F\u5199"),
18359
- protocolVersion: external_exports.string().default(PLUGIN_PROTOCOL_VERSION).refine((v) => v === PLUGIN_PROTOCOL_VERSION, {
18360
- error: `protocolVersion \u987B\u4E3A '${PLUGIN_PROTOCOL_VERSION}'`
18361
- }),
18362
- healthPath: external_exports.string().regex(/^\//, "healthPath \u987B\u4EE5 '/' \u5F00\u5934"),
18363
- description: external_exports.string().optional(),
18364
- configSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
18365
- mountConfigSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
18366
- });
18367
-
18368
18397
  // ../core/src/search/shortTermSql.ts
18369
18398
  function shortTermsSql(patterns) {
18370
18399
  return `short_terms(pattern) AS (VALUES ${patterns.map(() => "(?)").join(", ")})`;
@@ -10,7 +10,7 @@ import {
10
10
  isTBError,
11
11
  parseCredentialValues,
12
12
  toToolResult
13
- } from "./chunk-JLTYA2B3.js";
13
+ } from "./chunk-7PM4FD5K.js";
14
14
 
15
15
  // ../plugin-sdk/src/index.ts
16
16
  var CONTEXT_VERB_BY_HANDLER = {
@@ -64,8 +64,10 @@ function createPlugin(opts = {}) {
64
64
  id: state.id,
65
65
  profile: "tools/v1",
66
66
  ...state.description !== void 0 ? { description: state.description } : {},
67
+ ...state.auth !== void 0 ? { auth: state.auth } : {},
67
68
  ...state.kind === "tools" && state.credentialProbe !== void 0 ? { credentialProbe: state.credentialProbe } : {},
68
69
  ...state.credentialFields !== void 0 ? { credentialFields: state.credentialFields } : {},
70
+ ...state.kind === "tools" && state.mountConfigFields !== void 0 ? { mountConfigFields: state.mountConfigFields } : {},
69
71
  ...state.kind === "tools" && state.oauth !== void 0 ? { oauth: state.oauth } : {}
70
72
  };
71
73
  }
@@ -75,8 +77,10 @@ function createPlugin(opts = {}) {
75
77
  id: state.id,
76
78
  profile: "context/v1",
77
79
  ...state.description !== void 0 ? { description: state.description } : {},
80
+ ...state.auth !== void 0 ? { auth: state.auth } : {},
78
81
  methods,
79
- ...capabilities.length > 0 ? { capabilities } : {}
82
+ ...capabilities.length > 0 ? { capabilities } : {},
83
+ ...state.mountConfigFields !== void 0 ? { mountConfigFields: state.mountConfigFields } : {}
80
84
  };
81
85
  })
82
86
  };
@@ -226,16 +230,34 @@ function createPlugin(opts = {}) {
226
230
  tools(id, meta) {
227
231
  assertFreshId(id);
228
232
  const state = {
233
+ auth: void 0,
229
234
  kind: "tools",
230
235
  id,
231
236
  description: meta?.description,
232
237
  credentialProbe: void 0,
233
238
  credentialFields: void 0,
239
+ mountConfigFields: void 0,
234
240
  oauth: void 0,
235
241
  registry: new OperationRegistry()
236
242
  };
237
243
  exports.set(id, state);
238
244
  const surface = {
245
+ auth(config) {
246
+ if (state.oauth !== void 0 || state.credentialFields !== void 0) {
247
+ throw new TBError(
248
+ "invalid_argument",
249
+ `export '${id}' \u5DF2\u58F0\u660E oauth/credentials(),\u4E0D\u80FD\u518D\u58F0\u660E auth`
250
+ );
251
+ }
252
+ if (config.kind === "none" && state.credentialProbe !== void 0) {
253
+ throw new TBError(
254
+ "invalid_argument",
255
+ `export '${id}' \u5DF2\u58F0\u660E credentialProbe,\u4E0D\u80FD\u518D\u58F0\u660E auth:none`
256
+ );
257
+ }
258
+ state.auth = config;
259
+ return surface;
260
+ },
239
261
  register(name, spec, handler) {
240
262
  state.registry.register(name, spec, handler);
241
263
  return surface;
@@ -250,9 +272,19 @@ function createPlugin(opts = {}) {
250
272
  `export '${id}' \u5DF2\u58F0\u660E oauth,\u4E0D\u80FD\u518D\u58F0\u660E credentials()(oauth \u6A21\u5F0F\u4E0B authRef \u6307\u5411\u7684 secret \u56FA\u5B9A\u5B58 clientId/clientSecret)`
251
273
  );
252
274
  }
275
+ if (state.auth !== void 0) {
276
+ throw new TBError("invalid_argument", `export '${id}' \u5DF2\u58F0\u660E auth,\u4E0D\u80FD\u518D\u58F0\u660E credentials()`);
277
+ }
253
278
  state.credentialFields = fields;
254
279
  return surface;
255
280
  },
281
+ mountConfig(fields) {
282
+ if (fields.length === 0) {
283
+ throw new TBError("invalid_argument", "mountConfig() \u81F3\u5C11\u8981\u58F0\u660E\u4E00\u4E2A\u5B57\u6BB5");
284
+ }
285
+ state.mountConfigFields = fields;
286
+ return surface;
287
+ },
256
288
  oauth(config) {
257
289
  if (state.credentialFields !== void 0) {
258
290
  throw new TBError(
@@ -260,6 +292,9 @@ function createPlugin(opts = {}) {
260
292
  `export '${id}' \u5DF2\u58F0\u660E credentials(),\u4E0D\u80FD\u518D\u58F0\u660E oauth(oauth \u6A21\u5F0F\u4E0B authRef \u6307\u5411\u7684 secret \u56FA\u5B9A\u5B58 clientId/clientSecret)`
261
293
  );
262
294
  }
295
+ if (state.auth !== void 0) {
296
+ throw new TBError("invalid_argument", `export '${id}' \u5DF2\u58F0\u660E auth,\u4E0D\u80FD\u518D\u58F0\u660E oauth`);
297
+ }
263
298
  if (state.credentialProbe !== void 0) {
264
299
  throw new TBError(
265
300
  "invalid_argument",
@@ -282,6 +317,9 @@ function createPlugin(opts = {}) {
282
317
  `export '${id}' \u5DF2\u58F0\u660E oauth,\u4E0D\u80FD\u518D\u58F0\u660E credentialProbe(\u51ED\u8BC1\u53EF\u7528\u6027\u7531\u6388\u6743\u6D41\u7A0B\u672C\u8EAB\u8BC1\u660E;\u62FF client \u51ED\u8BC1\u53BB\u8C03\u63A2\u9488\u65E2\u8BC1\u660E\u4E0D\u4E86\u4EC0\u4E48,\u53C8\u4F1A\u628A clientSecret \u9001\u8FDB\u63D2\u4EF6)`
283
318
  );
284
319
  }
320
+ if (state.auth?.kind === "none") {
321
+ throw new TBError("invalid_argument", `export '${id}' \u58F0\u660E auth:none,\u4E0D\u80FD\u518D\u58F0\u660E credentialProbe`);
322
+ }
285
323
  state.credentialProbe = name;
286
324
  return surface;
287
325
  }
@@ -290,7 +328,11 @@ function createPlugin(opts = {}) {
290
328
  },
291
329
  proxyTools(id, handlers) {
292
330
  assertFreshId(id);
331
+ if (handlers.auth !== void 0 && handlers.credentialFields !== void 0) {
332
+ throw new TBError("invalid_argument", `export '${id}' \u7684 auth \u4E0D\u80FD\u4E0E credentialFields \u540C\u65F6\u58F0\u660E`);
333
+ }
293
334
  exports.set(id, {
335
+ auth: handlers.auth,
294
336
  kind: "proxyTools",
295
337
  id,
296
338
  description: handlers.description,
@@ -302,10 +344,12 @@ function createPlugin(opts = {}) {
302
344
  context(id, handlers) {
303
345
  assertFreshId(id);
304
346
  exports.set(id, {
347
+ auth: handlers.auth,
305
348
  kind: "context",
306
349
  id,
307
350
  description: handlers.description,
308
- handlers
351
+ handlers,
352
+ mountConfigFields: handlers.mountConfigFields
309
353
  });
310
354
  return plugin;
311
355
  },
@@ -0,0 +1,90 @@
1
+ import {
2
+ createPlugin
3
+ } from "./chunk-B4ZA7EGO.js";
4
+ import {
5
+ TBError
6
+ } from "./chunk-7PM4FD5K.js";
7
+
8
+ // ../plugins/src/_runtime/plugin.ts
9
+ function requireApiKey(ctx, service) {
10
+ const key = ctx.upstreamAuth;
11
+ if (key === void 0 || key === "") {
12
+ throw new TBError(
13
+ "unavailable",
14
+ `${service} \u9700\u8981 API key:\u7ED9\u6302\u8F7D\u8282\u70B9\u914D config.authRef \u6307\u5411\u5DF2\u5B58\u5165 system/secret \u7684\u51ED\u8BC1`
15
+ );
16
+ }
17
+ return key;
18
+ }
19
+ function requireCredential(ctx, service, field) {
20
+ const values = ctx.credentials;
21
+ if (values === void 0) {
22
+ throw new TBError(
23
+ "unavailable",
24
+ `${service} \u9700\u8981\u591A\u5B57\u6BB5\u51ED\u8BC1:\u7ED9\u6302\u8F7D\u8282\u70B9\u914D config.authRef \u6307\u5411\u5DF2\u5B58\u5165 system/secret \u7684\u51ED\u8BC1(\u7528 \`tb secret set <name> --field ...\` \u5199\u5165)`
25
+ );
26
+ }
27
+ const value = values[field];
28
+ if (value === void 0 || value === "") {
29
+ throw new TBError("internal", `${service} \u7684\u51ED\u8BC1\u5B57\u6BB5 '${field}' \u672A\u5728 credentialFields \u91CC\u58F0\u660E`);
30
+ }
31
+ return value;
32
+ }
33
+ function createProviderPlugin(input) {
34
+ const names = Object.keys(input.actions);
35
+ const handlerNames = Object.keys(input.handlers);
36
+ const missing = names.filter((name) => !handlerNames.includes(name));
37
+ const extra = handlerNames.filter((name) => !names.includes(name));
38
+ if (missing.length > 0 || extra.length > 0) {
39
+ throw new Error(
40
+ `action \u8868\u4E0E handler \u8868\u4E0D\u543B\u5408:\u7F3A handler [${missing.join(", ")}];\u591A\u4F59 handler [${extra.join(", ")}]`
41
+ );
42
+ }
43
+ const plugin = createPlugin({ token: (env) => env.PLUGIN_TOKEN });
44
+ const tools = plugin.tools(input.exportId ?? "actions", { description: input.description });
45
+ if (input.auth !== void 0) {
46
+ tools.auth(input.auth);
47
+ } else if (input.oauth === void 0 && input.credentialFields === void 0) {
48
+ tools.auth({ kind: "single", required: true });
49
+ }
50
+ if (input.oauth !== void 0) tools.oauth(input.oauth);
51
+ if (input.credentialFields !== void 0) tools.credentials(input.credentialFields);
52
+ if (input.mountConfigFields !== void 0) tools.mountConfig(input.mountConfigFields);
53
+ for (const name of names) {
54
+ tools.register(name, input.actions[name], (args, ctx) => input.handlers[name](args, {
55
+ upstreamAuth: ctx.upstreamAuth,
56
+ credentials: ctx.credentials,
57
+ config: ctx.mountConfig
58
+ }));
59
+ }
60
+ if (input.credentialProbe !== void 0) {
61
+ const effect = input.actions[input.credentialProbe]?.effect;
62
+ if (effect !== "read") {
63
+ throw new Error(
64
+ `credentialProbe '${input.credentialProbe}' \u7684 effect \u662F '${effect ?? "\u672A\u58F0\u660E"}', \u63A2\u9488\u5FC5\u987B\u662F read \u2014\u2014 \u6302\u8F7D\u65F6\u4F1A\u771F\u5B9E\u8C03\u7528\u5B83`
65
+ );
66
+ }
67
+ tools.probeCredentialWith(input.credentialProbe);
68
+ }
69
+ return plugin;
70
+ }
71
+
72
+ // ../plugins/src/_runtime/upstreamError.ts
73
+ function upstreamError(status, message) {
74
+ if (status === 401) {
75
+ return new TBError("permission_denied", message, { httpStatus: 401 });
76
+ }
77
+ if (status === 403) return new TBError("permission_denied", message);
78
+ if (status === 404) return new TBError("not_found", message);
79
+ if (status === 409) return new TBError("conflict", message);
80
+ if (status === 429) return new TBError("rate_limited", message, { retryable: true });
81
+ if (status >= 500) return new TBError("unavailable", message, { retryable: true });
82
+ return new TBError("invalid_argument", message);
83
+ }
84
+
85
+ export {
86
+ requireApiKey,
87
+ requireCredential,
88
+ createProviderPlugin,
89
+ upstreamError
90
+ };
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireApiKey,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  TBError,
10
12
  external_exports
11
- } from "./chunk-JLTYA2B3.js";
13
+ } from "./chunk-7PM4FD5K.js";
12
14
  import "./chunk-MLKGABMK.js";
13
15
 
14
16
  // ../plugins/src/circleci/api.ts
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireApiKey,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  external_exports
10
- } from "./chunk-JLTYA2B3.js";
12
+ } from "./chunk-7PM4FD5K.js";
11
13
  import "./chunk-MLKGABMK.js";
12
14
 
13
15
  // ../plugins/src/clerk/api.ts
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireApiKey,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  TBError,
10
12
  external_exports
11
- } from "./chunk-JLTYA2B3.js";
13
+ } from "./chunk-7PM4FD5K.js";
12
14
  import "./chunk-MLKGABMK.js";
13
15
 
14
16
  // ../plugins/src/cloudflare_dns/api.ts
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireApiKey,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  external_exports
10
- } from "./chunk-JLTYA2B3.js";
12
+ } from "./chunk-7PM4FD5K.js";
11
13
  import "./chunk-MLKGABMK.js";
12
14
 
13
15
  // ../plugins/src/cohere/api.ts
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireCredential,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  TBError,
10
12
  external_exports
11
- } from "./chunk-JLTYA2B3.js";
13
+ } from "./chunk-7PM4FD5K.js";
12
14
  import "./chunk-MLKGABMK.js";
13
15
 
14
16
  // ../plugins/src/confluence/api.ts
@@ -1,15 +1,17 @@
1
1
  import {
2
- assertPublicHttpUrl,
3
2
  createProviderPlugin,
4
- guardedFetch,
5
3
  requireApiKey,
6
4
  upstreamError
7
- } from "./chunk-CSJEZHQO.js";
8
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ assertPublicHttpUrl,
8
+ guardedFetch
9
+ } from "./chunk-7GP7DRES.js";
10
+ import "./chunk-B4ZA7EGO.js";
9
11
  import {
10
12
  TBError,
11
13
  external_exports
12
- } from "./chunk-JLTYA2B3.js";
14
+ } from "./chunk-7PM4FD5K.js";
13
15
  import "./chunk-MLKGABMK.js";
14
16
 
15
17
  // ../plugins/src/convertapi/schema.ts
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  createProviderPlugin,
3
- guardedFetch,
4
3
  requireApiKey,
5
4
  upstreamError
6
- } from "./chunk-CSJEZHQO.js";
7
- import "./chunk-K7FVSFUX.js";
5
+ } from "./chunk-FHYFPPBZ.js";
6
+ import {
7
+ guardedFetch
8
+ } from "./chunk-7GP7DRES.js";
9
+ import "./chunk-B4ZA7EGO.js";
8
10
  import {
9
11
  external_exports
10
- } from "./chunk-JLTYA2B3.js";
12
+ } from "./chunk-7PM4FD5K.js";
11
13
  import "./chunk-MLKGABMK.js";
12
14
 
13
15
  // ../plugins/src/currencyapi/api.ts