@tool-bridge/server 0.15.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-QYTOPRFV.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-2CFYNSZV.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-HGOBOHSZ.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-3OXOQNSR.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-PUV2QGKL.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-DG75AVKA.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-DXXYNIXV.js → chunk-RVWZN3CI.js} +3337 -1440
- package/dist/{chunk-NLPTB3IL.js → chunk-TLNUIPFZ.js} +1475 -277
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-NQ67PIIS.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-EFNLX5AW.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-UWDLMZVM.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-WQXVDSPU.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-VPDIKUDP.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-NBOOQNTR.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-6Z6OP25T.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-CAMUWCTV.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-GRALXYXR.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-5AASF3TJ.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-HS3VGRD3.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KHERUTW6.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-4MGHPFXY.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-O77PKTBT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-TX2TZFMP.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-I7VPWO3C.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-D4XZDLES.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-SW3HZCZ5.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-ND5DEW3L.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-ZTSV7ZK3.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-RZ7SZKFT.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-Q5MZVUGX.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-QPHHODHG.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-3Q6O7EWZ.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-LDMGJHXV.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-6QBCI3TT.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-LLSYY4ZJ.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-KRGVBGWY.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-OHPZMRHT.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-2PBY7OX4.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +199 -106
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-GPBQZKKG.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-YNTOLOFH.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-CZLQUAQ7.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-JIFEYH5C.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-2DKTIWHK.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-UCX7NHKP.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-IS6K2VJG.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-AK6547ZS.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-EB5LICOH.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-YOSWUA3R.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-IICTSHLB.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-DIV6MZPB.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-ZGHNTCAT.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-IAG3WZYO.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-PYKG4ZHO.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-BXN3DGTK.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-L2UO36HQ.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-PVHVOV4R.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-DVMOPFNQ.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-VW6F5YTK.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-MQUREYWM.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-5MI3ODCU.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-B2U7NIVA.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-LDZTVYQO.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-P7BNWFMH.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-3Y67EJYP.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-4KFLGCJW.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-NIULQPUD.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-UXGCIHRP.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-XT77YNQM.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-37E6ZN6Z.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-BO2W4IR6.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-5BACZNYC.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-DXABSDKY.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-4MCO6RLA.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-IVEPY4EP.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-XJBJO46B.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-R6QDVF3D.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-E24XNN32.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-QT3O334C.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-MJNFPUFV.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-BVKWS72R.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-52T5XARK.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-RTOTTCX2.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-3RVWQDZ6.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-M3T2K3EW.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-UUUXAEYR.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-LVOZQQKJ.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-WJQPCKQT.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-THKSKAI2.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-YTRGFFRC.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-QBK6WKN2.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-EA44ZKLR.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-GSW3V55S.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-DVZ7XUYC.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-ZWUWQ7OS.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-BQIQB5NM.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-2OJHTUPV.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-IZF4BB4O.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-PI3BJENX.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-EYQ2QCHH.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-ETDA6XLX.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-D7INO4Y4.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-Q7FNHEDM.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-KH663T3A.js +0 -183
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-UI4E4T5Q.js +0 -378
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';
|
|
@@ -68,8 +68,24 @@ interface Scope {
|
|
|
68
68
|
* sys:bootstrapped → true(Admin SK 引导幂等标志)
|
|
69
69
|
* annotation:<path> → { text, updatedAt, updatedBy }(管理员 Path 补充说明)
|
|
70
70
|
* feedback:<path> → FeedbackEntry[](Agent 使用反馈,单 key 整存)
|
|
71
|
+
* store:object:<id> → StoreObject(revision CAS)
|
|
72
|
+
* store:upload:<id> → UploadSession(revision CAS)
|
|
73
|
+
* store:call-capability:<id> → CallUploadCapability(token 仅存 hash)
|
|
74
|
+
* store:share:<id> → ShareGrant(token 仅存 hash)
|
|
71
75
|
*/
|
|
72
76
|
interface StateStore {
|
|
77
|
+
/**
|
|
78
|
+
* 可选原子 compare-and-swap 原语,供带 `revision` 的权威记录做跨副本状态转换。
|
|
79
|
+
*
|
|
80
|
+
* - `expectedRevision === null`:仅当 key 不存在时写入;
|
|
81
|
+
* - 数字:仅当现存值是对象且其 `revision` 严格等于该值时替换或删除;
|
|
82
|
+
* - `value === null`:命中后删除,否则替换为 value。
|
|
83
|
+
*
|
|
84
|
+
* 调用方负责让新值的 revision 从 expectedRevision 单调加一。实现必须把比较与
|
|
85
|
+
* 写入/删除放在同一条原子存储操作中,不能用 get→put 或进程内锁模拟。
|
|
86
|
+
* StoreService 等依赖并发状态机的能力会在缺少此原语时 fail closed。
|
|
87
|
+
*/
|
|
88
|
+
compareAndSwap?(key: string, expectedRevision: number | null, value: unknown | null): Promise<boolean>;
|
|
73
89
|
delete(key: string): Promise<void>;
|
|
74
90
|
get(key: string): Promise<unknown | null>;
|
|
75
91
|
/** 批量读取,返回值只包含当前存在的 key;单次最多 100 keys。 */
|
|
@@ -358,66 +374,6 @@ interface BuiltinCatalogEntry {
|
|
|
358
374
|
/** binding 名 → 目录项。 */
|
|
359
375
|
type BuiltinCatalog = Record<string, BuiltinCatalogEntry>;
|
|
360
376
|
|
|
361
|
-
/**
|
|
362
|
-
* Context Layer 类型(原样转写;方法签名异步化以兼容对象存储后端)。
|
|
363
|
-
*
|
|
364
|
-
* 全部动词可选:能力由 handler 存在性推导(见 context/capabilities.ts)。
|
|
365
|
-
* 可选能力(Search/Delete)另在 ~describe 的 capabilities 中声明,调用方先探测再用。
|
|
366
|
-
*/
|
|
367
|
-
|
|
368
|
-
interface ContextEntryMeta {
|
|
369
|
-
/** "text/markdown" | "application/json" | ... */
|
|
370
|
-
contentType: string;
|
|
371
|
-
metadata: Record<string, string>;
|
|
372
|
-
size?: number;
|
|
373
|
-
updatedAt: Timestamp;
|
|
374
|
-
/** node://<namespace-path>/<entry-path>;目录条目以尾 '/' 表示。 */
|
|
375
|
-
uri: URI;
|
|
376
|
-
/** 乐观并发:Update/Write 可携带 ifVersion;对象存储后端 = etag。 */
|
|
377
|
-
version: string;
|
|
378
|
-
}
|
|
379
|
-
interface ContextEntry extends ContextEntryMeta {
|
|
380
|
-
/** 文本或 JSON;大对象返回 { $ref: <预签名或中转 URL> }。 */
|
|
381
|
-
content: string | unknown;
|
|
382
|
-
}
|
|
383
|
-
interface ContextEntryInput {
|
|
384
|
-
content: string | unknown;
|
|
385
|
-
/** 字符串 content 必填(缺失 → invalid_argument);非字符串 content 缺省 application/json。 */
|
|
386
|
-
contentType?: string;
|
|
387
|
-
/** 不匹配 → conflict。 */
|
|
388
|
-
ifVersion?: string;
|
|
389
|
-
metadata?: Record<string, string>;
|
|
390
|
-
}
|
|
391
|
-
interface ContextPatch {
|
|
392
|
-
content?: string | unknown;
|
|
393
|
-
ifVersion?: string;
|
|
394
|
-
/** 浅合并。 */
|
|
395
|
-
metadata?: Record<string, string>;
|
|
396
|
-
}
|
|
397
|
-
interface SearchOptions extends ListOptions {
|
|
398
|
-
/** 缺省 keyword;semantic 需 capabilities 声明 "search:semantic",未声明 → invalid_argument。 */
|
|
399
|
-
mode?: 'keyword' | 'semantic';
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Context provider。**全部动词可选**:能力由 handler 存在性推导(context/capabilities.ts),
|
|
403
|
-
* `~help` 只列真实存在的操作,没有任何写动词即自动只读。
|
|
404
|
-
*
|
|
405
|
-
* 这样只读资源、纯搜索服务、append-only 存储都能如实表达自己,不必为满足接口而伪造
|
|
406
|
-
* 方法或抛 unimplemented。未实现的动词在数据面按 unknown cmd 拒绝(invalid_argument)。
|
|
407
|
-
*/
|
|
408
|
-
interface ContextProvider {
|
|
409
|
-
delete?(path: string): Promise<void>;
|
|
410
|
-
/** 读取单个条目(含内容);不存在 → not_found。 */
|
|
411
|
-
get?(path: string): Promise<ContextEntry>;
|
|
412
|
-
/** 枚举条目(浅层列表 + 分页);path 为 namespace 内相对路径前缀。 */
|
|
413
|
-
list?(path: string, opts?: ListOptions): Promise<Page<ContextEntryMeta>>;
|
|
414
|
-
search?(query: string, opts?: SearchOptions): Promise<Page<ContextEntryMeta>>;
|
|
415
|
-
/** 部分更新已存在条目的内容或 metadata;不存在 → not_found。 */
|
|
416
|
-
update?(path: string, patch: ContextPatch): Promise<ContextEntryMeta>;
|
|
417
|
-
/** 创建或整体替换条目(幂等 upsert)。 */
|
|
418
|
-
write?(path: string, entry: ContextEntryInput): Promise<ContextEntryMeta>;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
377
|
/**
|
|
422
378
|
* ObjectStore:对象存储抽象。
|
|
423
379
|
*
|
|
@@ -456,6 +412,8 @@ interface ObjectPutOptions {
|
|
|
456
412
|
contentType?: string;
|
|
457
413
|
/** 与现存对象 etag 不符(含对象不存在)→ TBError conflict。 */
|
|
458
414
|
ifMatchEtag?: string;
|
|
415
|
+
/** `*` 表示仅当对象不存在时创建;命中现存对象 → TBError conflict。 */
|
|
416
|
+
ifNoneMatch?: '*';
|
|
459
417
|
metadata?: Record<string, string>;
|
|
460
418
|
}
|
|
461
419
|
interface ObjectListOptions {
|
|
@@ -482,7 +440,19 @@ interface ObjectPresignPutOptions {
|
|
|
482
440
|
/** `*` 表示仅当对象不存在时写入;必须随 PUT 一同签名并发送。 */
|
|
483
441
|
ifNoneMatch?: '*';
|
|
484
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* 定长直传契约:实现必须把 Content-Length 纳入签名,让存储端拒绝
|
|
445
|
+
* 任何与声明字节数不同的请求。普通 `presignPut` 没有这个安全保证。
|
|
446
|
+
*/
|
|
447
|
+
interface ObjectPresignPutExactOptions extends ObjectPresignPutOptions {
|
|
448
|
+
contentLength: number;
|
|
449
|
+
}
|
|
485
450
|
interface ObjectStore {
|
|
451
|
+
/**
|
|
452
|
+
* 可选宿主钩子:清理 prefix 下早于 olderThan 的未落位 staging 临时文件。
|
|
453
|
+
* staging 不进入 list,且命名/mtime 属于 driver 私有实现;返回实际删除数量。
|
|
454
|
+
*/
|
|
455
|
+
cleanupStaging?(prefix: string, olderThan: string): Promise<number>;
|
|
486
456
|
/** 幂等:不存在静默。 */
|
|
487
457
|
delete(key: string): Promise<void>;
|
|
488
458
|
get(key: string): Promise<{
|
|
@@ -495,56 +465,70 @@ interface ObjectStore {
|
|
|
495
465
|
presign?(key: string, ttlSec: number): Promise<string>;
|
|
496
466
|
/** 生成限时、定路径的直传 PUT 请求;后端或凭证不支持时缺省。 */
|
|
497
467
|
presignPut?(key: string, ttlSec: number, opts: ObjectPresignPutOptions): Promise<ObjectPresignedPut>;
|
|
468
|
+
/** 仅当 backend 能在签名中强制精确 Content-Length 时提供。 */
|
|
469
|
+
presignPutExact?(key: string, ttlSec: number, opts: ObjectPresignPutExactOptions): Promise<ObjectPresignedPut>;
|
|
498
470
|
put(key: string, body: ObjectBody, opts?: ObjectPutOptions): Promise<ObjectMeta>;
|
|
499
471
|
}
|
|
500
472
|
|
|
501
473
|
/**
|
|
502
|
-
*
|
|
474
|
+
* Context Layer 类型(原样转写;方法签名异步化以兼容对象存储后端)。
|
|
503
475
|
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* DO 的 setWebSocketAutoResponse 按字符串精确匹配,设备侧心跳帧不得有其他序列化形态。
|
|
476
|
+
* 全部动词可选:能力由 handler 存在性推导(见 context/capabilities.ts)。
|
|
477
|
+
* 可选能力(Search/Delete)另在 ~describe 的 capabilities 中声明,调用方先探测再用。
|
|
507
478
|
*/
|
|
508
479
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
480
|
+
interface ContextEntryMeta {
|
|
481
|
+
/** "text/markdown" | "application/json" | ... */
|
|
482
|
+
contentType: string;
|
|
483
|
+
metadata: Record<string, string>;
|
|
484
|
+
size?: number;
|
|
485
|
+
updatedAt: Timestamp;
|
|
486
|
+
/** node://<namespace-path>/<entry-path>;目录条目以尾 '/' 表示。 */
|
|
487
|
+
uri: URI;
|
|
488
|
+
/** 乐观并发:Update/Write 可携带 ifVersion;对象存储后端 = etag。 */
|
|
489
|
+
version: string;
|
|
490
|
+
}
|
|
491
|
+
interface ContextEntry extends ContextEntryMeta {
|
|
492
|
+
/** 文本或 JSON;大对象返回 { $ref: <预签名或中转 URL> }。 */
|
|
493
|
+
content: string | unknown;
|
|
494
|
+
}
|
|
495
|
+
interface ContextEntryInput {
|
|
496
|
+
content: string | unknown;
|
|
497
|
+
/** 字符串 content 必填(缺失 → invalid_argument);非字符串 content 缺省 application/json。 */
|
|
498
|
+
contentType?: string;
|
|
499
|
+
/** 不匹配 → conflict。 */
|
|
500
|
+
ifVersion?: string;
|
|
501
|
+
metadata?: Record<string, string>;
|
|
502
|
+
}
|
|
503
|
+
interface ContextPatch {
|
|
504
|
+
content?: string | unknown;
|
|
505
|
+
ifVersion?: string;
|
|
506
|
+
/** 浅合并。 */
|
|
507
|
+
metadata?: Record<string, string>;
|
|
508
|
+
}
|
|
509
|
+
interface SearchOptions extends ListOptions {
|
|
510
|
+
/** 缺省 keyword;semantic 需 capabilities 声明 "search:semantic",未声明 → invalid_argument。 */
|
|
511
|
+
mode?: 'keyword' | 'semantic';
|
|
527
512
|
}
|
|
528
|
-
|
|
529
513
|
/**
|
|
530
|
-
*
|
|
514
|
+
* Context provider。**全部动词可选**:能力由 handler 存在性推导(context/capabilities.ts),
|
|
515
|
+
* `~help` 只列真实存在的操作,没有任何写动词即自动只读。
|
|
531
516
|
*
|
|
532
|
-
* -
|
|
533
|
-
*
|
|
534
|
-
* - 未 hello 先发非 hello 帧 / hello 重复 / 设备发出网关方向帧 → 拒绝帧 + 关闭。
|
|
535
|
-
* - call:requestId 幂等表——已有结果的重复 id 立即以首次结果应答;结果未到的重复 id
|
|
536
|
-
* 挂到同一待决项,不重复下发 call 帧。
|
|
537
|
-
* - 超时(DEVICE_CALL_TIMEOUT_MS):给调用方 unavailable(retryable:true),给设备 cancel 帧;
|
|
538
|
-
* 迟到的 result 仅入幂等表(后续重复 id 以它应答)。
|
|
517
|
+
* 这样只读资源、纯搜索服务、append-only 存储都能如实表达自己,不必为满足接口而伪造
|
|
518
|
+
* 方法或抛 unimplemented。未实现的动词在数据面按 unknown cmd 拒绝(invalid_argument)。
|
|
539
519
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
520
|
+
interface ContextProvider {
|
|
521
|
+
delete?(path: string): Promise<void>;
|
|
522
|
+
/** 读取单个条目(含内容);不存在 → not_found。 */
|
|
523
|
+
get?(path: string): Promise<ContextEntry>;
|
|
524
|
+
/** 枚举条目(浅层列表 + 分页);path 为 namespace 内相对路径前缀。 */
|
|
525
|
+
list?(path: string, opts?: ListOptions): Promise<Page<ContextEntryMeta>>;
|
|
526
|
+
search?(query: string, opts?: SearchOptions): Promise<Page<ContextEntryMeta>>;
|
|
527
|
+
/** 部分更新已存在条目的内容或 metadata;不存在 → not_found。 */
|
|
528
|
+
update?(path: string, patch: ContextPatch): Promise<ContextEntryMeta>;
|
|
529
|
+
/** 创建或整体替换条目(幂等 upsert)。 */
|
|
530
|
+
write?(path: string, entry: ContextEntryInput): Promise<ContextEntryMeta>;
|
|
531
|
+
}
|
|
548
532
|
|
|
549
533
|
/**
|
|
550
534
|
* Tool Layer 的中立类型。
|
|
@@ -590,6 +574,64 @@ interface ToolResult {
|
|
|
590
574
|
structuredContent?: Record<string, unknown>;
|
|
591
575
|
}
|
|
592
576
|
|
|
577
|
+
/**
|
|
578
|
+
* DeviceFrame:设备 WS 帧协议的类型与编解码。
|
|
579
|
+
*
|
|
580
|
+
* JSON 文本帧、`type` 区分;decode 拒绝非 JSON / 未知 type / 缺字段(invalid_argument),
|
|
581
|
+
* encode 产出紧凑 JSON。ping/pong 序列化为稳定字面量(PING_FRAME_JSON/PONG_FRAME_JSON)——
|
|
582
|
+
* DO 的 setWebSocketAutoResponse 按字符串精确匹配,设备侧心跳帧不得有其他序列化形态。
|
|
583
|
+
*/
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* 网关鉴权后为本次 call 生成的调用方来源与权威期限。
|
|
587
|
+
* 全部由网关签发,不接受来自调用 arguments;设备只消费不自造,且不做授权裁决
|
|
588
|
+
* (scope 判定在网关侧已完成)。故意不含 scopes / SK / 敏感参数。
|
|
589
|
+
*/
|
|
590
|
+
interface DeviceCallContext {
|
|
591
|
+
caller: {
|
|
592
|
+
displayName?: string;
|
|
593
|
+
/** 本次调用使用的 SK id(非明文,审计用)。 */
|
|
594
|
+
keyId: string;
|
|
595
|
+
owner: OwnerRef;
|
|
596
|
+
};
|
|
597
|
+
/** 网关签发时刻(网关时钟,非设备本地时钟)。 */
|
|
598
|
+
createdAt: Timestamp;
|
|
599
|
+
/** 本次调用的权威失效时刻;设备复检一律以此比对,不信任设备本地时钟。 */
|
|
600
|
+
expiresAt: Timestamp;
|
|
601
|
+
/** 全链路观测,与 call id 同源。 */
|
|
602
|
+
traceId: string;
|
|
603
|
+
/**
|
|
604
|
+
* 本次 call 独享的 Store 上传能力。token 是短期 bearer,只由 SDK 消费并放入
|
|
605
|
+
* capability-only 请求 header,设备 handler 不应把它写入结果或日志。
|
|
606
|
+
*/
|
|
607
|
+
upload?: {
|
|
608
|
+
expiresAt: Timestamp;
|
|
609
|
+
maxBytes: number;
|
|
610
|
+
maxObjects: number;
|
|
611
|
+
token: string;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* 网关侧设备会话状态机(纯逻辑,I/O 与时间注入,DO 只做胶水)。
|
|
617
|
+
*
|
|
618
|
+
* - awaiting-hello → ready:hello 经 io.onHello 交胶水层做 Check(register),
|
|
619
|
+
* 通过则 accept(mountPath)(回 ready 帧),否则 reject(error)(拒绝帧 + close(1008))。
|
|
620
|
+
* - 未 hello 先发非 hello 帧 / hello 重复 / 设备发出网关方向帧 → 拒绝帧 + 关闭。
|
|
621
|
+
* - call:requestId 幂等表——已有结果的重复 id 立即以首次结果应答;结果未到的重复 id
|
|
622
|
+
* 挂到同一待决项,不重复下发 call 帧。
|
|
623
|
+
* - 超时(DEVICE_CALL_TIMEOUT_MS):给调用方 unavailable(retryable:true),给设备 cancel 帧;
|
|
624
|
+
* 迟到的 result 仅入幂等表(后续重复 id 以它应答)。
|
|
625
|
+
*/
|
|
626
|
+
|
|
627
|
+
type DeviceCallResult = {
|
|
628
|
+
ok: true;
|
|
629
|
+
value: unknown;
|
|
630
|
+
} | {
|
|
631
|
+
error: TBErrorBody;
|
|
632
|
+
ok: false;
|
|
633
|
+
};
|
|
634
|
+
|
|
593
635
|
type SearchCapability = 'search' | 'search:semantic';
|
|
594
636
|
/** 全局工具搜索的完整结果;只在权限和可见性候选筛选后 hydrate。 */
|
|
595
637
|
interface ToolSearchHit {
|
|
@@ -818,9 +860,10 @@ interface RemoteSettings {
|
|
|
818
860
|
/**
|
|
819
861
|
* 宿主注入面与请求期公共类型。
|
|
820
862
|
*
|
|
821
|
-
*
|
|
822
|
-
* Provider
|
|
823
|
-
* 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。
|
|
824
867
|
*/
|
|
825
868
|
|
|
826
869
|
/** 帧协议 call 转发的入参(id 由调用点生成,幂等键)。 */
|
|
@@ -859,7 +902,7 @@ interface ReadinessReport {
|
|
|
859
902
|
ready: boolean;
|
|
860
903
|
}
|
|
861
904
|
/**
|
|
862
|
-
* tb app 的宿主注入面(
|
|
905
|
+
* tb app 的宿主注入面(数据/设备五注入点 + 安全出站通道 + 解析后的部署配置)。
|
|
863
906
|
* 核心业务逻辑零分叉:Workers 适配层(app.ts)与 SDK(packages/sdk)都注入此形状。
|
|
864
907
|
*/
|
|
865
908
|
interface TbAppDeps {
|
|
@@ -899,6 +942,12 @@ interface TbAppDeps {
|
|
|
899
942
|
* 那个插件解析不出 export;反之则解析得出但调不动(unavailable)。宿主该两者同源装配。
|
|
900
943
|
*/
|
|
901
944
|
pluginCatalog?: BuiltinCatalog;
|
|
945
|
+
/**
|
|
946
|
+
* Provider OAuth 令牌端点的宿主出站通道。必须由宿主显式注入;缺省时 OAuth
|
|
947
|
+
* 发起、回调兑换与 access-token 解析全部 fail closed,绝不回退到全局 fetch。
|
|
948
|
+
* 标准宿主注入逐跳校验且拒绝跨源 body 重定向的 guarded fetch。
|
|
949
|
+
*/
|
|
950
|
+
providerOAuthFetch?: typeof fetch;
|
|
902
951
|
/**
|
|
903
952
|
* 后端连通性探测(GET /readyz;k8s readiness)。宿主注入闭包,自行探测其长连接
|
|
904
953
|
* 后端(PG 池 / Redis)并叠加 draining 状态。缺省 → /readyz 恒 200:请求期绑定
|
|
@@ -917,6 +966,26 @@ interface TbAppDeps {
|
|
|
917
966
|
search?: SearchIndex;
|
|
918
967
|
secrets: SecretStoreImpl;
|
|
919
968
|
state: StateStore;
|
|
969
|
+
/** call capability 允许的 MIME pattern;缺省 `*\/*`。 */
|
|
970
|
+
storeCallAllowedContentTypes?: string[];
|
|
971
|
+
/** 单次 device call 的聚合上传字节预算。 */
|
|
972
|
+
storeCallMaxBytes?: number;
|
|
973
|
+
/** 单次 device call 的单对象字节预算。 */
|
|
974
|
+
storeCallMaxObjectBytes?: number;
|
|
975
|
+
/** 单次 device call 最多创建的 Store 对象数。 */
|
|
976
|
+
storeCallMaxObjects?: number;
|
|
977
|
+
/** default Store 的单对象部署级上限。 */
|
|
978
|
+
storeMaxObjectBytes?: number;
|
|
979
|
+
/** owner read `$ref` 有效期秒;缺省 refTtlSec 或 900。 */
|
|
980
|
+
storeReadTtlSec?: number;
|
|
981
|
+
/** relay transport 的有效 request-body 上限;direct 不受此值收紧。 */
|
|
982
|
+
storeRelayMaxBytes?: number;
|
|
983
|
+
/** 短期 share 的缺省有效期秒。 */
|
|
984
|
+
storeShareTtlSec?: number;
|
|
985
|
+
/** Store capability HMAC secret;缺省由 StateStore 原子生成并持久化。 */
|
|
986
|
+
storeTokenSecret?: string;
|
|
987
|
+
/** Store upload session 有效期秒。 */
|
|
988
|
+
storeUploadTtlSec?: number;
|
|
920
989
|
/** mcp/tool 工具缓存 TTL 秒(缺省 300)。 */
|
|
921
990
|
toolCacheTtlSec?: number;
|
|
922
991
|
/** create_upload 写入 grant 有效期秒;缺省 min(refTtlSec, 900)。 */
|
|
@@ -941,7 +1010,7 @@ declare function createTbApp(deps: TbAppDeps): Hono<{
|
|
|
941
1010
|
* Node 宿主的 env 配置面。变量名与语义对齐 CF 宿主(gateway/src/app.ts 的 Env),
|
|
942
1011
|
* 仅新增宿主形态相关的 TB_PORT / TB_HOST / TB_DATA_DIR / TB_UI_DIR / TB_DATABASE_URL。
|
|
943
1012
|
* 端口额外兜底平台注入的 PORT(PaaS 通行约定)。
|
|
944
|
-
*
|
|
1013
|
+
* Node/Workers 共用字段由 core runtimeEnv Zod schema 解析,本文件只保留 Node 宿主字段。
|
|
945
1014
|
*/
|
|
946
1015
|
|
|
947
1016
|
interface ServerConfig {
|
|
@@ -972,7 +1041,7 @@ interface ServerConfig {
|
|
|
972
1041
|
encryptionKey?: string;
|
|
973
1042
|
host: string;
|
|
974
1043
|
/**
|
|
975
|
-
* 平台对象存储(context `$ref` 大对象落点)。给出则用 S3/R2 兼容端点,
|
|
1044
|
+
* 平台对象存储(default Store + context `$ref` 大对象落点)。给出则用 S3/R2 兼容端点,
|
|
976
1045
|
* 缺省回退 dataDir 下的本地 FS。配 S3 后容器可无状态横向扩容 —— FS 落点
|
|
977
1046
|
* 在多副本间互不可见、容器重建即丢。
|
|
978
1047
|
*/
|
|
@@ -1021,6 +1090,28 @@ interface ServerConfig {
|
|
|
1021
1090
|
* 请求吃闭门羹;单机/本地开发保持 0,关停立即进行。
|
|
1022
1091
|
*/
|
|
1023
1092
|
shutdownDrainSec?: number;
|
|
1093
|
+
/** 设备调用允许上传的 MIME pattern;缺省由应用使用安全默认值。 */
|
|
1094
|
+
storeCallAllowedContentTypes?: string[];
|
|
1095
|
+
/** 设备调用所签发 Store capability 的总字节上限。 */
|
|
1096
|
+
storeCallMaxBytes?: number;
|
|
1097
|
+
/** 设备调用单个 Store 对象的字节上限。 */
|
|
1098
|
+
storeCallMaxObjectBytes?: number;
|
|
1099
|
+
/** 设备调用最多可创建的 Store 对象数。 */
|
|
1100
|
+
storeCallMaxObjects?: number;
|
|
1101
|
+
/** Store 孤儿字节、过期 session/share/call capability 的周期清理间隔。 */
|
|
1102
|
+
storeCleanupIntervalSec: number;
|
|
1103
|
+
/** Store 对象统一上限;direct upload 可使用完整值。 */
|
|
1104
|
+
storeMaxObjectBytes?: number;
|
|
1105
|
+
/** Store owner read ref 的有效期。 */
|
|
1106
|
+
storeReadTtlSec?: number;
|
|
1107
|
+
/** relay upload 的宿主有效上限;缺省等于对象统一上限。 */
|
|
1108
|
+
storeRelayMaxBytes?: number;
|
|
1109
|
+
/** Store 匿名可撤销 share 的有效期。 */
|
|
1110
|
+
storeShareTtlSec?: number;
|
|
1111
|
+
/** 显式 Store token 根密钥;缺省由应用在 StateStore 原子生成并持久化。 */
|
|
1112
|
+
storeTokenSecret?: string;
|
|
1113
|
+
/** Store upload session 的有效期。 */
|
|
1114
|
+
storeUploadTtlSec?: number;
|
|
1024
1115
|
toolCacheTtlSec?: number;
|
|
1025
1116
|
/** Dashboard 静态资源目录覆盖(缺省经 @tool-bridge/dashboard 包解析)。 */
|
|
1026
1117
|
uiDir?: string;
|
|
@@ -1247,6 +1338,7 @@ declare class PgStateStore implements StateStore {
|
|
|
1247
1338
|
get(key: string): Promise<unknown | null>;
|
|
1248
1339
|
getMany(keys: readonly string[]): Promise<Map<string, unknown>>;
|
|
1249
1340
|
put(key: string, value: unknown): Promise<void>;
|
|
1341
|
+
compareAndSwap(key: string, expectedRevision: number | null, value: unknown | null): Promise<boolean>;
|
|
1250
1342
|
putIfAbsent(key: string, value: unknown): Promise<boolean>;
|
|
1251
1343
|
delete(key: string): Promise<void>;
|
|
1252
1344
|
list(prefix: string, opts?: {
|
|
@@ -1349,6 +1441,7 @@ declare class SqliteStateStore implements StateStore {
|
|
|
1349
1441
|
get(key: string): Promise<unknown | null>;
|
|
1350
1442
|
getMany(keys: readonly string[]): Promise<Map<string, unknown>>;
|
|
1351
1443
|
put(key: string, value: unknown): Promise<void>;
|
|
1444
|
+
compareAndSwap(key: string, expectedRevision: number | null, value: unknown | null): Promise<boolean>;
|
|
1352
1445
|
putIfAbsent(key: string, value: unknown): Promise<boolean>;
|
|
1353
1446
|
delete(key: string): Promise<void>;
|
|
1354
1447
|
list(prefix: string, opts?: {
|
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-KH663T3A.js";
|
|
9
|
-
import "./chunk-UI4E4T5Q.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
|
}
|