@tool-bridge/server 0.16.0 → 0.17.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.
- package/dist/{airtable-S3T4TAN7.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-4DIRIDKL.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-LGVGNPML.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-27RFZO35.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-6WLYAIAS.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-K2SVJ66F.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-YB2FLNWI.js → chunk-RVWZN3CI.js} +2103 -1775
- package/dist/{chunk-BB6ZLMTU.js → chunk-TLNUIPFZ.js} +492 -300
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-VK3V2WTY.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-WV3ITU7Q.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-NFQEFKS4.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-2RK5ASBJ.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-5KEW7LWT.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-SZE63S46.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-QPG2JC5K.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-UO2APQRY.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-LJELIMM3.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-2MFXSBOF.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-GQYNTTVA.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KI2LHXST.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-WO6ISY3C.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-IZ7B3BPT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-LTMF36GJ.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-WM7SLSFD.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-66W3MXH2.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-2Z274VQZ.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-IFI4R65V.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-BCCZEB3D.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-755FXYB5.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-4FZKKXXK.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-WYKDJ3DP.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-5BNQTCOH.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-ULELF5VX.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-G34WT64J.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-BQU255SC.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-HPCNQXYJ.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-VOV24FIC.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-D5RXW6AP.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +57 -50
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-DAYO7EKZ.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-XD4PSLII.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-K27QEAWK.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-E6UXFV2P.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-ZDSXGQ6W.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-TIFJRREW.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-DASEMJMA.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-KE6UP4SP.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-IMNDN4R5.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-HHHMUXQA.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-D2FGGOIY.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-4OVIGFPH.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-33WCX5YD.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-QIMZ2JYL.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-M6VWS2VH.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-Z2PKQBHH.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-SS4RPC4K.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-FJCNQ6I7.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-WU57WTT5.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-JODZ4GKT.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-SQRAUSV5.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-Q5XXEJZ7.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-RT2EHJ2X.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-OF2V7GAC.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-LNZEWLHG.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-JSJIXZYN.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-D4CKVUXR.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-M7ZYP6UR.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-YV7CZOH4.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-KYHLECRG.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-HCMHBKV2.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-WYVLCCN3.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-TWIRD5KR.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-UZ467IQ7.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-MECUC5CC.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-A5MEK3SW.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-BC6EAWJQ.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-ZM3QDUIS.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-WAML42QJ.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-DG7PET3V.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-HY6WTHIO.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-C5IZA7IP.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-OKBPSTDM.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-PPC6DYU4.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-EWGUHBXO.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-6RPDPC5W.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-SK7DQ42N.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-YCG5VQMH.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-2OES5FYB.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-POOSBBR4.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-M7YD6YSS.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-IS6V5W3E.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-RCFHUFVH.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-OS2RXFGO.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-PQ2SJ2LN.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-C6BPZO4E.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-WH6UER7H.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-M3YZGS6Z.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-R4JWTEHN.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-FZVYUOQD.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-2KOLO5DC.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-XRWGO6LG.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-WR4NKOYL.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-BKZIB3WA.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-2O27H4Y2.js +0 -183
- package/dist/chunk-GKX72JMJ.js +0 -378
- package/dist/chunk-MLKGABMK.js +0 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from './v4/classic/external.cjs';
|
|
2
2
|
import * as http from 'node:http';
|
|
3
3
|
import { Sql } from 'postgres';
|
|
4
4
|
import { Hono } from 'hono';
|
|
@@ -530,6 +530,50 @@ interface ContextProvider {
|
|
|
530
530
|
write?(path: string, entry: ContextEntryInput): Promise<ContextEntryMeta>;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Tool Layer 的中立类型。
|
|
535
|
+
*
|
|
536
|
+
* `ToolSpec` 是**上游工具的中立形状**:mcp(`tools/list` 的 `Tool`)与 http
|
|
537
|
+
* (`HttpToolDef`)都归一到它,虚拟化(virtualize.ts)与 `~help` 派生(mcpSchema.ts)
|
|
538
|
+
* 只认 `ToolSpec`,不感知上游是 mcp 还是 http。它把 `ToolMeta`+`ToolDef`
|
|
539
|
+
* 合并为一个形状:`description` 可缺省(上游可能不带),另携 `confirm`(危险工具二次确认)。
|
|
540
|
+
*/
|
|
541
|
+
/** 上游工具的中立形状(mcp/http 归一目标)。 */
|
|
542
|
+
interface ToolSpec {
|
|
543
|
+
/** 危险操作二次确认;进 `~help` 的 confirm 行。 */
|
|
544
|
+
confirm?: boolean;
|
|
545
|
+
/** 一句话描述;进 `~help` 的 `h` 行。上游可能不带 → 可缺省。 */
|
|
546
|
+
description?: string;
|
|
547
|
+
/** 副作用标记(read/write/destructive);进 `~help` 的 effect 行。 */
|
|
548
|
+
effect?: string;
|
|
549
|
+
/** JSON Schema;`~help` 的 body 数据源。 */
|
|
550
|
+
inputSchema?: unknown;
|
|
551
|
+
/** 工具名(虚拟化前为上游原名,虚拟化后为对外虚拟名)。 */
|
|
552
|
+
name: string;
|
|
553
|
+
/**
|
|
554
|
+
* 返回值的 JSON Schema(可选)。与 `inputSchema` 对称,同为裸 JSON Schema。
|
|
555
|
+
*
|
|
556
|
+
* 来源:MCP 上游的 `Tool.outputSchema`、plugin 作者在 `OperationSpec.outputSchema` 里的声明。
|
|
557
|
+
* 去处:工具级全量 `~help`(JSON 的 `outputSchema` / DSL 的 `result` 行)与 MCP consumer 端点。
|
|
558
|
+
* 索引形态的 `~help` 不含它(同 inputSchema,两级披露)。
|
|
559
|
+
*/
|
|
560
|
+
outputSchema?: unknown;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* 工具调用结果。`isError:true` 是**工具业务级错误**(上游 HTTP 200
|
|
564
|
+
* 正常返回、内容为错),按内容协商渲染——**不是** TBError(传输/协议错误才归一为
|
|
565
|
+
* TBError,见 upstreamError.ts)。
|
|
566
|
+
*/
|
|
567
|
+
interface ToolResult {
|
|
568
|
+
/** markdown 文本或结构化 JSON(按内容协商输出)。 */
|
|
569
|
+
content: string | unknown;
|
|
570
|
+
/** MCP 等上游的原生多模态 content blocks;HTBP 渲染仍使用归一后的 content。 */
|
|
571
|
+
contentBlocks?: unknown[];
|
|
572
|
+
isError?: boolean;
|
|
573
|
+
/** MCP 上游返回的结构化结果;consumer endpoint 转发时保留。 */
|
|
574
|
+
structuredContent?: Record<string, unknown>;
|
|
575
|
+
}
|
|
576
|
+
|
|
533
577
|
/**
|
|
534
578
|
* DeviceFrame:设备 WS 帧协议的类型与编解码。
|
|
535
579
|
*
|
|
@@ -588,50 +632,6 @@ type DeviceCallResult = {
|
|
|
588
632
|
ok: false;
|
|
589
633
|
};
|
|
590
634
|
|
|
591
|
-
/**
|
|
592
|
-
* Tool Layer 的中立类型。
|
|
593
|
-
*
|
|
594
|
-
* `ToolSpec` 是**上游工具的中立形状**:mcp(`tools/list` 的 `Tool`)与 http
|
|
595
|
-
* (`HttpToolDef`)都归一到它,虚拟化(virtualize.ts)与 `~help` 派生(mcpSchema.ts)
|
|
596
|
-
* 只认 `ToolSpec`,不感知上游是 mcp 还是 http。它把 `ToolMeta`+`ToolDef`
|
|
597
|
-
* 合并为一个形状:`description` 可缺省(上游可能不带),另携 `confirm`(危险工具二次确认)。
|
|
598
|
-
*/
|
|
599
|
-
/** 上游工具的中立形状(mcp/http 归一目标)。 */
|
|
600
|
-
interface ToolSpec {
|
|
601
|
-
/** 危险操作二次确认;进 `~help` 的 confirm 行。 */
|
|
602
|
-
confirm?: boolean;
|
|
603
|
-
/** 一句话描述;进 `~help` 的 `h` 行。上游可能不带 → 可缺省。 */
|
|
604
|
-
description?: string;
|
|
605
|
-
/** 副作用标记(read/write/destructive);进 `~help` 的 effect 行。 */
|
|
606
|
-
effect?: string;
|
|
607
|
-
/** JSON Schema;`~help` 的 body 数据源。 */
|
|
608
|
-
inputSchema?: unknown;
|
|
609
|
-
/** 工具名(虚拟化前为上游原名,虚拟化后为对外虚拟名)。 */
|
|
610
|
-
name: string;
|
|
611
|
-
/**
|
|
612
|
-
* 返回值的 JSON Schema(可选)。与 `inputSchema` 对称,同为裸 JSON Schema。
|
|
613
|
-
*
|
|
614
|
-
* 来源:MCP 上游的 `Tool.outputSchema`、plugin 作者在 `OperationSpec.outputSchema` 里的声明。
|
|
615
|
-
* 去处:工具级全量 `~help`(JSON 的 `outputSchema` / DSL 的 `result` 行)与 MCP consumer 端点。
|
|
616
|
-
* 索引形态的 `~help` 不含它(同 inputSchema,两级披露)。
|
|
617
|
-
*/
|
|
618
|
-
outputSchema?: unknown;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* 工具调用结果。`isError:true` 是**工具业务级错误**(上游 HTTP 200
|
|
622
|
-
* 正常返回、内容为错),按内容协商渲染——**不是** TBError(传输/协议错误才归一为
|
|
623
|
-
* TBError,见 upstreamError.ts)。
|
|
624
|
-
*/
|
|
625
|
-
interface ToolResult {
|
|
626
|
-
/** markdown 文本或结构化 JSON(按内容协商输出)。 */
|
|
627
|
-
content: string | unknown;
|
|
628
|
-
/** MCP 等上游的原生多模态 content blocks;HTBP 渲染仍使用归一后的 content。 */
|
|
629
|
-
contentBlocks?: unknown[];
|
|
630
|
-
isError?: boolean;
|
|
631
|
-
/** MCP 上游返回的结构化结果;consumer endpoint 转发时保留。 */
|
|
632
|
-
structuredContent?: Record<string, unknown>;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
635
|
type SearchCapability = 'search' | 'search:semantic';
|
|
636
636
|
/** 全局工具搜索的完整结果;只在权限和可见性候选筛选后 hydrate。 */
|
|
637
637
|
interface ToolSearchHit {
|
|
@@ -860,9 +860,10 @@ interface RemoteSettings {
|
|
|
860
860
|
/**
|
|
861
861
|
* 宿主注入面与请求期公共类型。
|
|
862
862
|
*
|
|
863
|
-
*
|
|
864
|
-
* Provider
|
|
865
|
-
* toolNodes/contextNodes/helpModel 与 routes
|
|
863
|
+
* 这里只放形状:五个数据/设备注入点(state / objects / secrets / device / search)、
|
|
864
|
+
* Provider OAuth 安全出站通道、进程内 Provider 钩子与解析后的部署配置。行为实现
|
|
865
|
+
* 分散在 paths/federation/deviceNodes/toolNodes/contextNodes/helpModel 与 routes/*,
|
|
866
|
+
* 装配在 tbApp.ts。
|
|
866
867
|
*/
|
|
867
868
|
|
|
868
869
|
/** 帧协议 call 转发的入参(id 由调用点生成,幂等键)。 */
|
|
@@ -901,7 +902,7 @@ interface ReadinessReport {
|
|
|
901
902
|
ready: boolean;
|
|
902
903
|
}
|
|
903
904
|
/**
|
|
904
|
-
* tb app 的宿主注入面(
|
|
905
|
+
* tb app 的宿主注入面(数据/设备五注入点 + 安全出站通道 + 解析后的部署配置)。
|
|
905
906
|
* 核心业务逻辑零分叉:Workers 适配层(app.ts)与 SDK(packages/sdk)都注入此形状。
|
|
906
907
|
*/
|
|
907
908
|
interface TbAppDeps {
|
|
@@ -941,6 +942,12 @@ interface TbAppDeps {
|
|
|
941
942
|
* 那个插件解析不出 export;反之则解析得出但调不动(unavailable)。宿主该两者同源装配。
|
|
942
943
|
*/
|
|
943
944
|
pluginCatalog?: BuiltinCatalog;
|
|
945
|
+
/**
|
|
946
|
+
* Provider OAuth 令牌端点的宿主出站通道。必须由宿主显式注入;缺省时 OAuth
|
|
947
|
+
* 发起、回调兑换与 access-token 解析全部 fail closed,绝不回退到全局 fetch。
|
|
948
|
+
* 标准宿主注入逐跳校验且拒绝跨源 body 重定向的 guarded fetch。
|
|
949
|
+
*/
|
|
950
|
+
providerOAuthFetch?: typeof fetch;
|
|
944
951
|
/**
|
|
945
952
|
* 后端连通性探测(GET /readyz;k8s readiness)。宿主注入闭包,自行探测其长连接
|
|
946
953
|
* 后端(PG 池 / Redis)并叠加 draining 状态。缺省 → /readyz 恒 200:请求期绑定
|
|
@@ -1003,7 +1010,7 @@ declare function createTbApp(deps: TbAppDeps): Hono<{
|
|
|
1003
1010
|
* Node 宿主的 env 配置面。变量名与语义对齐 CF 宿主(gateway/src/app.ts 的 Env),
|
|
1004
1011
|
* 仅新增宿主形态相关的 TB_PORT / TB_HOST / TB_DATA_DIR / TB_UI_DIR / TB_DATABASE_URL。
|
|
1005
1012
|
* 端口额外兜底平台注入的 PORT(PaaS 通行约定)。
|
|
1006
|
-
*
|
|
1013
|
+
* Node/Workers 共用字段由 core runtimeEnv Zod schema 解析,本文件只保留 Node 宿主字段。
|
|
1007
1014
|
*/
|
|
1008
1015
|
|
|
1009
1016
|
interface ServerConfig {
|
package/dist/index.js
CHANGED
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
configFromEnv,
|
|
13
13
|
createDataObjectStore,
|
|
14
14
|
createTbServer
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-TLNUIPFZ.js";
|
|
16
|
+
import "./chunk-U5UHT7CX.js";
|
|
17
|
+
import "./chunk-RVWZN3CI.js";
|
|
18
|
+
import "./chunk-U67V476Y.js";
|
|
18
19
|
export {
|
|
19
20
|
DEVICE_FORWARD_TIMEOUT_MS,
|
|
20
21
|
DEVICE_ROUTE_TTL_SEC,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import "./chunk-JXHMDBAY.js";
|
|
1
5
|
import {
|
|
2
6
|
createProviderPlugin,
|
|
3
7
|
requireApiKey,
|
|
4
8
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
9
|
+
} from "./chunk-YASUMV2K.js";
|
|
10
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
11
|
import {
|
|
11
12
|
TBError,
|
|
12
13
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-RVWZN3CI.js";
|
|
15
|
+
import "./chunk-U67V476Y.js";
|
|
15
16
|
|
|
16
17
|
// ../plugins/src/ip2proxy/schema.ts
|
|
17
18
|
var lookupIpInput = external_exports.strictObject({
|
|
@@ -48,55 +49,47 @@ var ip2proxyActions = {
|
|
|
48
49
|
// ../plugins/src/ip2proxy/api.ts
|
|
49
50
|
var SERVICE = "ip2proxy";
|
|
50
51
|
var API_BASE = "https://api.ip2proxy.com";
|
|
52
|
+
var http = createProviderHttpClient({ baseUrl: `${API_BASE}/`, service: SERVICE });
|
|
51
53
|
var DEFAULT_PACKAGE = "PX1";
|
|
52
|
-
async function readPayload(response) {
|
|
53
|
-
const body = await response.text();
|
|
54
|
-
if (body === "") return null;
|
|
55
|
-
try {
|
|
56
|
-
return JSON.parse(body);
|
|
57
|
-
} catch {
|
|
58
|
-
return body;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
54
|
function payloadError(payload) {
|
|
62
55
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) return void 0;
|
|
63
56
|
const message = payload.response;
|
|
64
57
|
if (typeof message !== "string" || message === "" || message === "OK") return void 0;
|
|
65
58
|
return message;
|
|
66
59
|
}
|
|
60
|
+
function classifiedPayloadError(message) {
|
|
61
|
+
const lower = message.toLowerCase();
|
|
62
|
+
return upstreamError(lower.includes("api key") || lower.includes("credit") ? 401 : 502, message);
|
|
63
|
+
}
|
|
67
64
|
async function lookupIp(input, ctx) {
|
|
68
65
|
if (input.ip === void 0 || input.ip === "") {
|
|
69
66
|
throw new TBError("invalid_argument", "ip \u4E0D\u80FD\u4E3A\u7A7A");
|
|
70
67
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
const result = await http.request({
|
|
69
|
+
path: "/",
|
|
70
|
+
method: "GET",
|
|
71
|
+
query: [
|
|
72
|
+
["key", requireApiKey(ctx, SERVICE)],
|
|
73
|
+
["format", "json"],
|
|
74
|
+
["ip", input.ip],
|
|
75
|
+
["package", input.package ?? DEFAULT_PACKAGE]
|
|
76
|
+
],
|
|
77
|
+
headers: { accept: "application/json" },
|
|
78
|
+
invalidJson: "text",
|
|
79
|
+
mapError: ({ data: payload2, status, statusText }) => {
|
|
80
|
+
const failure2 = payloadError(payload2);
|
|
81
|
+
if (failure2 !== void 0) return classifiedPayloadError(failure2);
|
|
82
|
+
return upstreamError(status || 500, statusText || "IP2Proxy request failed");
|
|
83
|
+
},
|
|
84
|
+
mapTransportError: ({ message }) => new TBError(
|
|
86
85
|
"unavailable",
|
|
87
|
-
|
|
86
|
+
message === void 0 ? "IP2Proxy \u8BF7\u6C42\u5931\u8D25" : `IP2Proxy \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
88
87
|
{ retryable: true }
|
|
89
|
-
)
|
|
90
|
-
}
|
|
88
|
+
)
|
|
89
|
+
});
|
|
90
|
+
const payload = result.bodyKind === "empty" ? null : result.data;
|
|
91
91
|
const failure = payloadError(payload);
|
|
92
|
-
if (failure !== void 0)
|
|
93
|
-
const lower = failure.toLowerCase();
|
|
94
|
-
const credentialIssue = lower.includes("api key") || lower.includes("credit");
|
|
95
|
-
throw upstreamError(credentialIssue ? 401 : 502, failure);
|
|
96
|
-
}
|
|
97
|
-
if (!response.ok) {
|
|
98
|
-
throw upstreamError(response.status || 500, response.statusText || "IP2Proxy request failed");
|
|
99
|
-
}
|
|
92
|
+
if (failure !== void 0) throw classifiedPayloadError(failure);
|
|
100
93
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
101
94
|
throw new TBError("unavailable", "IP2Proxy \u8FD4\u56DE\u7684\u4E0D\u662F JSON \u5BF9\u8C61", { retryable: true });
|
|
102
95
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject
|
|
6
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
7
|
import {
|
|
2
8
|
createProviderPlugin,
|
|
3
9
|
requireApiKey,
|
|
4
10
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
11
|
+
} from "./chunk-YASUMV2K.js";
|
|
12
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
13
|
import {
|
|
11
|
-
TBError,
|
|
12
14
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-RVWZN3CI.js";
|
|
16
|
+
import "./chunk-U67V476Y.js";
|
|
15
17
|
|
|
16
18
|
// ../plugins/src/ipgeolocation_io/api.ts
|
|
17
19
|
var SERVICE = "ipgeolocation_io";
|
|
18
20
|
var API_BASE = "https://api.ipgeolocation.io/";
|
|
19
21
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
20
|
-
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22
|
-
}
|
|
22
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
23
23
|
function nullableString(value) {
|
|
24
24
|
if (typeof value === "string") return value;
|
|
25
25
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
@@ -39,47 +39,27 @@ function nullableInteger(value) {
|
|
|
39
39
|
}
|
|
40
40
|
function errorMessage(payload, status) {
|
|
41
41
|
if (typeof payload === "string" && payload.trim() !== "") return payload;
|
|
42
|
-
const record =
|
|
42
|
+
const record = asJsonObject(payload);
|
|
43
43
|
const message = record?.message ?? record?.error;
|
|
44
44
|
if (typeof message === "string" && message.trim() !== "") return message;
|
|
45
45
|
return `IPGeolocation.io request failed with status ${status}`;
|
|
46
46
|
}
|
|
47
|
-
async function readPayload(response) {
|
|
48
|
-
const body = await response.text();
|
|
49
|
-
if (body.trim() === "") return null;
|
|
50
|
-
try {
|
|
51
|
-
return JSON.parse(body);
|
|
52
|
-
} catch {
|
|
53
|
-
throw upstreamError(502, "IPGeolocation.io returned invalid JSON");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
47
|
async function request(ctx, path, params) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
throw upstreamError(504, "IPGeolocation.io request timed out");
|
|
73
|
-
}
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
const payload = await readPayload(response);
|
|
77
|
-
if (!response.ok) {
|
|
78
|
-
const status = response.status;
|
|
79
|
-
const normalized = status === 429 || status === 401 || status === 403 ? status : status >= 400 && status < 500 ? 400 : status || 500;
|
|
80
|
-
throw upstreamError(normalized, errorMessage(payload, status));
|
|
81
|
-
}
|
|
82
|
-
const record = toRecord(payload);
|
|
48
|
+
const { data: payload } = await http.request({
|
|
49
|
+
path,
|
|
50
|
+
method: "GET",
|
|
51
|
+
query: [["apiKey", requireApiKey(ctx, SERVICE)], ...Object.entries(params)],
|
|
52
|
+
headers: { accept: "application/json" },
|
|
53
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
54
|
+
invalidJsonMessage: "IPGeolocation.io returned invalid JSON",
|
|
55
|
+
mapError: ({ bodyKind, data, status }) => {
|
|
56
|
+
if (bodyKind === "invalid-json") return upstreamError(502, "IPGeolocation.io returned invalid JSON");
|
|
57
|
+
const normalized = status === 429 || status === 401 || status === 403 ? status : status >= 400 && status < 500 ? 400 : status || 500;
|
|
58
|
+
return upstreamError(normalized, errorMessage(data, status));
|
|
59
|
+
},
|
|
60
|
+
mapTransportError: ({ kind }) => kind === "timeout" ? upstreamError(504, "IPGeolocation.io request timed out") : upstreamError(502, "IPGeolocation.io request failed")
|
|
61
|
+
});
|
|
62
|
+
const record = asJsonObject(payload);
|
|
83
63
|
if (record === void 0) throw upstreamError(502, "IPGeolocation.io returned an invalid payload");
|
|
84
64
|
return record;
|
|
85
65
|
}
|
|
@@ -106,7 +86,7 @@ async function lookupIp(input, ctx) {
|
|
|
106
86
|
excludes: joinList(input.excludes),
|
|
107
87
|
include: includes.length > 0 ? includes.join(",") : void 0
|
|
108
88
|
});
|
|
109
|
-
const location =
|
|
89
|
+
const location = asJsonObject(payload.location) ?? payload;
|
|
110
90
|
return {
|
|
111
91
|
geolocation: {
|
|
112
92
|
ip: nullableString(payload.ip),
|
|
@@ -122,17 +102,17 @@ async function lookupIp(input, ctx) {
|
|
|
122
102
|
zipcode: nullableString(location.zipcode),
|
|
123
103
|
latitude: nullableNumber(location.latitude),
|
|
124
104
|
longitude: nullableNumber(location.longitude),
|
|
125
|
-
callingCode: nullableString(
|
|
105
|
+
callingCode: nullableString(asJsonObject(payload.country_metadata)?.calling_code),
|
|
126
106
|
countryFlag: nullableString(location.country_flag),
|
|
127
|
-
countryMetadata:
|
|
128
|
-
network:
|
|
129
|
-
asn:
|
|
130
|
-
company:
|
|
131
|
-
timeZone:
|
|
132
|
-
currency:
|
|
133
|
-
security:
|
|
134
|
-
abuse:
|
|
135
|
-
userAgent:
|
|
107
|
+
countryMetadata: asJsonObject(payload.country_metadata) ?? null,
|
|
108
|
+
network: asJsonObject(payload.network) ?? null,
|
|
109
|
+
asn: asJsonObject(payload.asn) ?? null,
|
|
110
|
+
company: asJsonObject(payload.company) ?? null,
|
|
111
|
+
timeZone: asJsonObject(payload.time_zone) ?? null,
|
|
112
|
+
currency: asJsonObject(payload.currency) ?? null,
|
|
113
|
+
security: asJsonObject(payload.security) ?? null,
|
|
114
|
+
abuse: asJsonObject(payload.abuse) ?? null,
|
|
115
|
+
userAgent: asJsonObject(payload.user_agent) ?? null,
|
|
136
116
|
raw: payload
|
|
137
117
|
}
|
|
138
118
|
};
|
|
@@ -163,7 +143,7 @@ async function getTimezone(input, ctx) {
|
|
|
163
143
|
yearAbbr: nullableString(payload.year_abbr),
|
|
164
144
|
isDst: typeof payload.is_dst === "boolean" ? payload.is_dst : null,
|
|
165
145
|
dstSavings: nullableInteger(payload.dst_savings),
|
|
166
|
-
geo:
|
|
146
|
+
geo: asJsonObject(payload.geo) ?? null,
|
|
167
147
|
raw: payload
|
|
168
148
|
}
|
|
169
149
|
};
|
|
@@ -178,7 +158,7 @@ async function getAstronomy(input, ctx) {
|
|
|
178
158
|
});
|
|
179
159
|
return {
|
|
180
160
|
astronomy: {
|
|
181
|
-
location:
|
|
161
|
+
location: asJsonObject(payload.location) ?? null,
|
|
182
162
|
date: nullableString(payload.date),
|
|
183
163
|
currentTime: nullableString(payload.current_time),
|
|
184
164
|
sunrise: nullableString(payload.sunrise),
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import "./chunk-JXHMDBAY.js";
|
|
1
5
|
import {
|
|
2
6
|
createProviderPlugin,
|
|
3
7
|
requireApiKey,
|
|
4
8
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
9
|
+
} from "./chunk-YASUMV2K.js";
|
|
10
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
11
|
import {
|
|
11
12
|
TBError,
|
|
12
13
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-RVWZN3CI.js";
|
|
15
|
+
import "./chunk-U67V476Y.js";
|
|
15
16
|
|
|
16
17
|
// ../plugins/src/ipqualityscore/api.ts
|
|
17
18
|
var SERVICE = "ipqualityscore";
|
|
18
19
|
var API_BASE = "https://www.ipqualityscore.com";
|
|
20
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
19
21
|
var IP_LITERAL = external_exports.union([external_exports.ipv4(), external_exports.ipv6()]);
|
|
20
22
|
function optionalText(value) {
|
|
21
23
|
return value?.trim() || void 0;
|
|
@@ -32,55 +34,41 @@ function messageOf(payload) {
|
|
|
32
34
|
const pick = (value) => typeof value === "string" ? optionalText(value) : void 0;
|
|
33
35
|
return pick(record.message) ?? pick(record.error);
|
|
34
36
|
}
|
|
35
|
-
function ipqsError(
|
|
36
|
-
const message = messageOf(payload) ?? optionalText(
|
|
37
|
+
function ipqsError(status, statusText, payload) {
|
|
38
|
+
const message = messageOf(payload) ?? optionalText(statusText) ?? `IPQualityScore request failed with ${status}`;
|
|
37
39
|
const lower = message.toLowerCase();
|
|
38
|
-
if (
|
|
40
|
+
if (status === 429 || status === 402 || lower.includes("insufficient credits")) {
|
|
39
41
|
return upstreamError(429, message);
|
|
40
42
|
}
|
|
41
|
-
if (lower.includes("invalid api key") || lower.includes("api key") ||
|
|
43
|
+
if (lower.includes("invalid api key") || lower.includes("api key") || status === 401 || status === 403) {
|
|
42
44
|
return upstreamError(401, message);
|
|
43
45
|
}
|
|
44
|
-
if (
|
|
46
|
+
if (status === 400 || lower.includes("invalid ip") || lower.includes("invalid email") || lower.includes("invalid phone") || lower.includes("invalid url")) {
|
|
45
47
|
return upstreamError(400, message);
|
|
46
48
|
}
|
|
47
|
-
return upstreamError(
|
|
48
|
-
}
|
|
49
|
-
async function readPayload(response) {
|
|
50
|
-
const body = await response.text();
|
|
51
|
-
if (body === "") return null;
|
|
52
|
-
try {
|
|
53
|
-
return JSON.parse(body);
|
|
54
|
-
} catch {
|
|
55
|
-
return body;
|
|
56
|
-
}
|
|
49
|
+
return upstreamError(status >= 400 ? status : 502, message);
|
|
57
50
|
}
|
|
58
51
|
async function request(ctx, family, value, query = []) {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
headers: { accept: "application/json" }
|
|
70
|
-
});
|
|
71
|
-
payload = await readPayload(response);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
throw new TBError(
|
|
52
|
+
const apiKey = requireApiKey(ctx, SERVICE);
|
|
53
|
+
const result = await http.request({
|
|
54
|
+
path: `/api/json/${family}/${encodeURIComponent(apiKey)}/${encodeURIComponent(value)}`,
|
|
55
|
+
method: "GET",
|
|
56
|
+
query,
|
|
57
|
+
headers: { accept: "application/json" },
|
|
58
|
+
invalidJson: "text",
|
|
59
|
+
sensitiveValues: [apiKey],
|
|
60
|
+
mapError: ({ data, status, statusText }) => ipqsError(status, statusText, data),
|
|
61
|
+
mapTransportError: ({ message }) => new TBError(
|
|
74
62
|
"unavailable",
|
|
75
|
-
|
|
63
|
+
message === void 0 ? "IPQualityScore \u8BF7\u6C42\u5931\u8D25" : `IPQualityScore \u8BF7\u6C42\u5931\u8D25: ${message}`,
|
|
76
64
|
{ retryable: true }
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
65
|
+
)
|
|
66
|
+
});
|
|
67
|
+
const payload = result.bodyKind === "empty" ? null : result.data;
|
|
80
68
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
81
69
|
throw new TBError("unavailable", `IPQualityScore \u5BF9 ${family} \u7684\u54CD\u5E94\u4E0D\u662F JSON \u5BF9\u8C61`, { retryable: true });
|
|
82
70
|
}
|
|
83
|
-
if (payload.success === false) throw ipqsError(
|
|
71
|
+
if (payload.success === false) throw ipqsError(result.status, result.statusText, payload);
|
|
84
72
|
return payload;
|
|
85
73
|
}
|
|
86
74
|
async function checkIpReputation(input, ctx) {
|
|
@@ -1,74 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
messageFrom
|
|
6
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
7
|
import {
|
|
2
8
|
createProviderPlugin,
|
|
3
9
|
requireApiKey,
|
|
4
10
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-2O27H4Y2.js";
|
|
9
|
-
import "./chunk-GKX72JMJ.js";
|
|
11
|
+
} from "./chunk-YASUMV2K.js";
|
|
12
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
13
|
import {
|
|
11
|
-
TBError,
|
|
12
14
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-RVWZN3CI.js";
|
|
16
|
+
import "./chunk-U67V476Y.js";
|
|
15
17
|
|
|
16
18
|
// ../plugins/src/jina_ai/api.ts
|
|
17
19
|
var SERVICE = "jina_ai";
|
|
18
|
-
var API_BASE = "https://api.jina.ai";
|
|
19
20
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
20
|
-
|
|
21
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
22
|
-
}
|
|
23
|
-
function text(value) {
|
|
24
|
-
if (typeof value !== "string") return void 0;
|
|
25
|
-
const trimmed = value.trim();
|
|
26
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
27
|
-
}
|
|
28
|
-
function errorMessage(status, body, payload) {
|
|
29
|
-
const top = record(payload);
|
|
30
|
-
return text(top?.detail) ?? text(top?.message) ?? text(body) ?? `Jina AI request failed with ${status}`;
|
|
31
|
-
}
|
|
21
|
+
var http = createProviderHttpClient({ baseUrl: "https://api.jina.ai/", service: SERVICE });
|
|
32
22
|
async function request(ctx, path, body) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const message = error instanceof Error ? error.message : "unknown network error";
|
|
51
|
-
throw upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message}`);
|
|
52
|
-
}
|
|
53
|
-
const raw = await response.text();
|
|
54
|
-
let payload = null;
|
|
55
|
-
if (raw !== "") {
|
|
56
|
-
try {
|
|
57
|
-
payload = JSON.parse(raw);
|
|
58
|
-
} catch {
|
|
59
|
-
if (response.ok) {
|
|
60
|
-
throw new TBError("unavailable", "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94", { retryable: true });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!response.ok) throw upstreamError(response.status, errorMessage(response.status, raw, payload));
|
|
65
|
-
return payload;
|
|
23
|
+
const { data } = await http.request({
|
|
24
|
+
path,
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
accept: "application/json",
|
|
28
|
+
authorization: `Bearer ${requireApiKey(ctx, SERVICE)}`
|
|
29
|
+
},
|
|
30
|
+
json: body,
|
|
31
|
+
timeoutMs: REQUEST_TIMEOUT_MS,
|
|
32
|
+
invalidJsonMessage: "Jina AI \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
33
|
+
mapError: ({ data: payload, status }) => upstreamError(
|
|
34
|
+
status,
|
|
35
|
+
messageFrom(payload, ["detail", "message"], `Jina AI request failed with ${status}`)
|
|
36
|
+
),
|
|
37
|
+
mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `Jina AI ${REQUEST_TIMEOUT_MS / 1e3}s \u5185\u6CA1\u6709\u8FD4\u56DE`) : upstreamError(502, `Jina AI \u8BF7\u6C42\u5931\u8D25: ${message ?? "unknown network error"}`)
|
|
38
|
+
});
|
|
39
|
+
return data ?? null;
|
|
66
40
|
}
|
|
67
|
-
|
|
68
|
-
return request(ctx, "
|
|
41
|
+
function createEmbeddings(input, ctx) {
|
|
42
|
+
return request(ctx, "v1/embeddings", input);
|
|
69
43
|
}
|
|
70
|
-
|
|
71
|
-
return request(ctx, "
|
|
44
|
+
function rerankDocuments(input, ctx) {
|
|
45
|
+
return request(ctx, "v1/rerank", input);
|
|
72
46
|
}
|
|
73
47
|
|
|
74
48
|
// ../plugins/src/jina_ai/schema.ts
|