@twinsearth/agent-universe 3.5.0 → 3.6.1

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/README.md CHANGED
@@ -5,11 +5,28 @@
5
5
  > **一句话简介:群众化的 AGI 路线,去中心化的智能体共享 & 开源网络。**
6
6
 
7
7
  [![CI](https://github.com/TwinsEarth/agent-universe/actions/workflows/ci.yml/badge.svg)](https://github.com/TwinsEarth/agent-universe/actions/workflows/ci.yml)
8
+ [![Client Build](https://img.shields.io/github/actions/workflow/status/TwinsEarth/agent-universe/client-build.yml?label=client%20build)](https://github.com/TwinsEarth/agent-universe/actions/workflows/client-build.yml)
9
+ [![Release Pipeline](https://img.shields.io/github/actions/workflow/status/TwinsEarth/agent-universe/release.yml?label=release%20pipeline)](https://github.com/TwinsEarth/agent-universe/actions/workflows/release.yml)
10
+ [![Publish Pipeline](https://img.shields.io/github/actions/workflow/status/TwinsEarth/agent-universe/publish.yml?label=publish%20pipeline)](https://github.com/TwinsEarth/agent-universe/actions/workflows/publish.yml)
11
+
8
12
  [![Release](https://img.shields.io/github/v/release/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/releases)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
13
+ [![Release Date](https://img.shields.io/github/release-date/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/releases)
14
+ [![npm](https://img.shields.io/npm/v/@twinsearth/agent-universe?color=red)](https://www.npmjs.com/package/@twinsearth/agent-universe)
15
+ [![npm downloads](https://img.shields.io/npm/dm/@twinsearth/agent-universe?color=red)](https://www.npmjs.com/package/@twinsearth/agent-universe)
16
+
17
+ [![Platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-lightgrey)](https://github.com/TwinsEarth/agent-universe/actions/workflows/ci.yml)
10
18
  [![Rust](https://img.shields.io/badge/rust-2021%20edition-orange.svg)](https://www.rust-lang.org/)
19
+ [![MSRV](https://img.shields.io/badge/MSRV-1.88%2B-orange)](https://github.com/TwinsEarth/agent-universe/actions/workflows/ci.yml)
11
20
  [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
12
- [![npm](https://img.shields.io/badge/npm-%40twinsearth%2Fagent--universe-red.svg)](https://github.com/TwinsEarth/agent-universe/packages)
21
+ [![Node](https://img.shields.io/badge/node-18%2B-green.svg)](https://nodejs.org/)
22
+
23
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
24
+ [![Safety Gates](https://img.shields.io/badge/safety-no%20panic%20%E2%80%A2%20unsafe%20contained-success)](https://github.com/TwinsEarth/agent-universe/actions/workflows/ci.yml)
25
+ [![Stars](https://img.shields.io/github/stars/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/stargazers)
26
+ [![Forks](https://img.shields.io/github/forks/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/network/members)
27
+ [![Contributors](https://img.shields.io/github/contributors/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/graphs/contributors)
28
+ [![Issues](https://img.shields.io/github/issues/TwinsEarth/agent-universe)](https://github.com/TwinsEarth/agent-universe/issues)
29
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
13
30
 
14
31
  ## 核心理念
15
32
 
@@ -87,6 +104,15 @@
87
104
  | `marketplace/` | **智能体市场 Agent Market**(v2.3.4):注册/发现/匹配/BFT验证/结算/信誉 |
88
105
  | `bin/` | **gsn-daemon** 守护进程 |
89
106
 
107
+ > **库面模块与运行面的区分(v3.5.9,DOC-05 / 自审 F-4)**:上表是 **gsn-core 代码库的
108
+ > 模块清单**,不等于「守护进程实际构造运行的能力」。其中 `topology/`、`scheduler/`、
109
+ > `memory/`、`swarm/`、`mesh/`、`nat/` 目前是 **library-only / 实验性模块**:它们的类型
110
+ > 被 `lib.rs` re-export、有单元测试,但**不在 `gsn-daemon` 的启动运行图中构造**;节点实际的
111
+ > 网络发现/广播/打洞走 **libp2p**(`net/` 的 Kademlia、GossipSub、AutoNAT、DCUtR、Relay),
112
+ > 调度与群体涌现的运行能力由官方插件以各自实现提供。各模块头注释有逐条标注,「接线启用
113
+ > 还是收敛删除」的待决记录与能力边界现状见
114
+ > [`docs/CAPABILITY-STATUS.md`](docs/CAPABILITY-STATUS.md)。
115
+
90
116
  ### Python SDK(aip-sdk-py)
91
117
 
92
118
  - Agent Interop Protocol 客户端
@@ -167,7 +193,32 @@ cargo run --release --bin gsn-daemon -- \
167
193
  | `GET /tasks` | 任务列表 |
168
194
  | `POST /agents` | 注册 AgentCard(同时落 SQLite 与 DHT) |
169
195
 
170
- > **当前实现状态**:gsn-daemon 已是**真实网络节点**——libp2p(Noise 加密 + Kademlia DHT + GossipSub)真实 bind P2P 端口,HTTP API 真实 bind API 端口,agents/tasks 通过 SQLite 真实落盘并在重启后恢复。已真机验证:两端口 `LISTEN`、各 API 端点返回正确、POST 注册可查、404 路径正确转义、kill 重启后数据仍在。核心业务逻辑(Agent Market 结算守恒、BFT-lite 验证、信誉)由 155 个 Rust 测试 + 17 个 Python 测试 + 12 个 JS 测试守护,跨语言签名测试保证三端身份/签名互验。链上结算与跨主机多节点 DHT 联调为下一步目标。
196
+ > **当前实现状态**:gsn-daemon 已是**真实网络节点**——libp2p(Noise 加密 + Kademlia DHT + GossipSub)真实 bind P2P 端口,HTTP API 真实 bind API 端口,agents/tasks 通过 SQLite 真实落盘并在重启后恢复。已真机验证:两端口 `LISTEN`、各 API 端点返回正确、POST 注册可查、404 路径正确转义、kill 重启后数据仍在。核心业务逻辑(Agent Market 结算守恒、BFT-lite 验证、信誉)由 618 个 Rust 测试 + 19 个 Python 测试 + 22 个 JS 测试守护(随版本增长,以发布时 cargo test / pytest / node 实测为准),跨语言签名测试保证三端身份/签名互验。链上结算与跨主机多节点 DHT 联调为下一步目标。
197
+
198
+ ### 自动更新(v3.6.1)
199
+
200
+ daemon 每次启动会在**后台**联网到 npm registry(`@twinsearth/agent-universe` 的完整版本表)
201
+ 检查是否最新,检查失败只告警、不影响启动。更新对象同时包含 **daemon 二进制**与 **npm 包**。
202
+
203
+ - **默认 Minor 通道**:只自动跟进同一大版本最新「中版本基线」`x.Y.0`,不追补丁,**绝不跨大版本**。
204
+ - **Patch 通道(先锋队员/贡献者白名单)**:自动跟进最新「小版本」`x.Y.Z`。名单为仓库内置、
205
+ 编译期嵌入的 [`config/pioneers.txt`](config/pioneers.txt),可用 `GSN_PIONEERS_FILE` 追加。
206
+ - **手动更新任意版本(含跨大版本)**:
207
+
208
+ ```bash
209
+ gsn update # 按本机通道自动更新 daemon + npm
210
+ gsn update --check # 只检查,不安装
211
+ gsn update 3.6.1 # 手动更新到指定版本(可跨大版本/降级)
212
+ gsn update --track patch # 本次按 patch 通道
213
+ gsn version --check # 只查询通道内目标与新大版本提示
214
+ ```
215
+
216
+ 环境变量:`GSN_AUTO_UPDATE=0`(只检查不自动安装)、`GSN_NO_UPDATE_CHECK=1`(关闭联网检查)、
217
+ `GSN_UPDATE_TRACK=minor|patch`、`GSN_UPDATE_NPM=0`(不更新 npm 包)。
218
+
219
+ 安全:daemon 二进制安装前强制校验随 Release 发布的 `.sha256`(不符即拒绝),同目录原子替换;
220
+ 安装后**下次启动生效**,不强制重启。平台支持矩阵与诚实边界(如 macOS 仅 aarch64 有资产、
221
+ Windows exe 占用需先停节点)见 [`releases/v3.6.1.md`](releases/v3.6.1.md)。
171
222
 
172
223
  ### 三大连接层:CLI · API · MCP(v2.3.5 引入,v2.3.6 深化)
173
224
 
@@ -219,14 +270,14 @@ gsn market stats # 市场统计
219
270
 
220
271
  业务错误返回 `422`,资源不存在返回 `404`,注册类成功返回 `201`,`OPTIONS` 返回 `204`。
221
272
 
222
- **③ MCP(18 个市场工具,支持 stdio 与 HTTP/SSE 两种传输)**
273
+ **③ MCP(20 个市场工具,支持 stdio 与 HTTP/SSE 两种传输)**
223
274
 
224
275
  - stdio:`gsn mcp`,逐行读写 JSON-RPC(日志走 stderr),可直接接入 Claude Desktop / Cursor 等;
225
276
  - HTTP:`POST /api/v1/mcp` 无状态 JSON-RPC,`GET /api/v1/mcp` 返回 `text/event-stream` 初始化帧。
226
277
 
227
- 工具命名 `market_*`,覆盖:`market_register_agent`、`market_discover_agents`、`market_publish_task`、`market_submit_bid`、`market_match_task`、`market_submit_result`、`market_verify_result`、`market_settle_task`、`market_open_dispute`、`market_arbitrate`、`market_deposit`、`market_balance`、`market_conservation`、`market_leaderboard`、`market_stats` 等共 18 个。`tools/call` 全部路由到市场 actor **真实执行**(非占位)。
278
+ 工具命名 `market_*`,覆盖:`market_register_agent`、`market_discover_agents`、`market_publish_task`、`market_submit_bid`、`market_match_task`、`market_submit_result`、`market_verify_result`、`market_settle_task`、`market_open_dispute`、`market_arbitrate`、`market_deposit`、`market_balance`、`market_conservation`、`market_leaderboard`、`market_stats` 等共 20 个。`tools/call` 全部路由到市场 actor **真实执行**(非占位)。
228
279
 
229
- > 三层均已真机验证:daemon 真实 bind P2P/API 端口,curl 走通「充值→注册→发布→投标→匹配→结果→验证→结算→守恒」完整闭环;MCP stdio 完成 `initialize` / `tools/list`(18 工具)/ `tools/call`;CLI 各子命令连接节点返回真实数据。由 155 个 Rust 测试守护,跨语言签名测试保证 Rust/Python/JS 三端身份、规范载荷与签名逐字节一致、可互验。
280
+ > 三层均已真机验证:daemon 真实 bind P2P/API 端口,curl 走通「充值→注册→发布→投标→匹配→结果→验证→结算→守恒」完整闭环;MCP stdio 完成 `initialize` / `tools/list`(20 工具)/ `tools/call`;CLI 各子命令连接节点返回真实数据。由 618 个 Rust 测试守护,跨语言签名测试保证 Rust/Python/JS 三端身份、规范载荷与签名逐字节一致、可互验。
230
281
 
231
282
  ### Python SDK 使用
232
283
 
@@ -273,7 +324,7 @@ npm config set @twinsearth:registry https://npm.pkg.github.com
273
324
  npm install @twinsearth/agent-universe
274
325
  ```
275
326
 
276
- 已发布版本:1.0.0 / 2.0.0 / 2.2.0 / 2.3.0 / 2.3.1 / 2.3.4 / 2.3.5 / 2.3.6 / 2.4.0 ~ 2.9.2(v2.8.8 跳过)/ 3.0.0,详见 [Releases](https://github.com/TwinsEarth/agent-universe/releases)。
327
+ 已发布版本:1.0.0 / 2.0.0 / 2.2.0 / 2.3.0 / 2.3.1 / 2.3.4 / 2.3.5 / 2.3.6 / 2.4.0 ~ 2.9.2(v2.8.8 跳过)/ 3.0.0 / 3.1.0 ~ 3.6.1,详见 [Releases](https://github.com/TwinsEarth/agent-universe/releases)。
277
328
 
278
329
  ## 版本谱系
279
330
 
@@ -343,6 +394,24 @@ npm install @twinsearth/agent-universe
343
394
  | v2.9.1 | **Sandbox Capability** | **沙箱能力声明闸门:边界要么强制执行、要么显式 waiver(带理由),否则拒绝;默认不执行(NullExecutor/后端禁用);`trusted_local` 平台感知 waiver(Linux 网络/FS/磁盘,macOS 额外内存);内存/CPU 跨平台(Linux ulimit -v、macOS 无 RLIMIT_AS 诚实标 unenforced、Node --max-old-space-size 全平台);生产代码 panic 归零(静态关卡验证,v2.9.2 接入 CI);快照持久化错误改为告警;cargo fmt 关卡** |
344
395
  | v2.9.2 | **CI Engineering** | **rust-test 矩阵接入 Windows(fmt/build/test/clippy,winjob 等专属代码首次有 CI);新增 static-gates job:check-no-panics(生产 panic 站点必为 0)+ check-unsafe-containment(每个 unsafe 有 SAFETY 理由);两个静态检查脚本正式入库** |
345
396
  | v3.0.0 | **Plugin Kernel(大版本)** | **一切插件化架构重构:插件内核(注册中心/插件总线 PMB/权限仲裁/生命周期/能力模型/黑名单)、热更新·热插拔·热兼容(原子切换+失败回滚+ABI 协商)、五级插件体系(系统/官方/认证/第三方/黑名单)、T1/T2/T3 独立进程隔离 + 能力闸门、T0 系统插件真实运行、`/api/v1/plugins` REST API;crate 版本映射规则升级(0.X.YZ,3.0.0→0.3.0);WASM 为可选 feature(当前类型化拒绝)。详见 [PLUGIN_GUIDE.md](docs/PLUGIN_GUIDE.md)** |
397
+ | v3.1.0 | **Business Plugins** | **业务插件化:官方插件真正承载业务逻辑(entry 模块 + 随内核自动装配)** |
398
+ | v3.2.0 | **More Business Plugins** | **业务插件化深化:再 3 个核心官方插件(shard/bridge/crdt 等)承载真实业务 entry** |
399
+ | v3.2.1 | **PMB Security** | **PMB 安全通信:消息 HMAC 签名 + nonce 防重放 + 总线端到端接线** |
400
+ | v3.2.2 | **Swarm Detect** | **业务化 swarm-emergence:群体智能涌现检测(detect)** |
401
+ | v3.2.3 | **Skill Discover** | **业务化 agent-skill:按技能发现智能体(discover)** |
402
+ | v3.3.0 | **Chain Anchor** | **业务化 chain-anchor:离线锚定构造与双校验(anchor/verify)** |
403
+ | v3.4.0 | **Chain Bridge** | **业务化 chain-bridge:跨链信誉桥接与中位数共识(9/9 官方插件全业务化)** |
404
+ | v3.4.2 | **Plugin Audit** | **全局审核版本:补齐插件生命周期/信任/黑名单接线 + 架构合规关卡** |
405
+ | v3.4.5 | **Grounding** | **A 类接地修复 + B1 主数据面编排接管 + B3 系统插件接线** |
406
+ | v3.5.0 | **Plugin Outbox** | **B2:进程插件 outbox 主动通信(新能力);Mac/Windows 实机部署与跨平台验证** |
407
+ | v3.5.4 | **Persist Fidelity** | **重启持久化全字段保真(W-04 任务规格 / W-05 智能体卡片)** |
408
+ | v3.5.5 | **CLI Hardening** | **gsn CLI 鉴权/金额/仲裁契约加固(W-03)与 daemon 版本开关(W-02)** |
409
+ | v3.5.6 | **Audit Persist** | **中继池遥测落盘失败显式化 + 市场层结算独立审计/防重复结算回归(#74)** |
410
+ | v3.5.7 | **MSRV Honesty** | **MSRV 诚实化:显式声明并实测最低工具链 1.88.0(#75 / W-01)** |
411
+ | v3.5.8 | **Real Benchmark** | **守护进程真实端到端吞吐/延迟基准 + 历史无测量性能小节诚实化(#76 / DOC-07)** |
412
+ | v3.5.9 | **Capability Status** | **能力边界状态登记 + 库面模块诚实标注 + 历史条目勘误指针(#77 / DEV-01~05、DOC-05/F-4、DOC-08)** |
413
+ | v3.6.0 | **Ops CLI** | **新增运维只读 CLI:`gsn ledger verify`(账本哈希链/坏行/重放守恒离线核验)与 `gsn doctor`(一键诊断)** |
414
+ | v3.6.1 | **Auto Update** | **daemon 自动更新:npm registry 权威源(不盲信 dist-tags)+ 默认 minor/白名单 patch 双通道 + 手动可跨大版本;daemon 二进制 sha256 fail-closed 原子替换 + npm 包同步;release.yml 三平台增原始二进制+.sha256 资产** |
346
415
 
347
416
  详见 [RELEASES.md](RELEASES.md) 和 [releases/](releases/) 目录。
348
417
 
@@ -445,7 +514,7 @@ AipIdentity.verifyObject(manifest, id.publicKey); // true
445
514
  const { McpHttpClient } = require('@twinsearth/agent-universe');
446
515
  const mcp = new McpHttpClient('http://127.0.0.1:4002');
447
516
  await mcp.initialize();
448
- const tools = await mcp.listTools(); // 18 个工具,字段为规范 inputSchema
517
+ const tools = await mcp.listTools(); // 20 个工具,字段为规范 inputSchema
449
518
  await mcp.callTool('market_stats', {}); // 经 daemon 真实路由执行
450
519
  ```
451
520
 
package/js/index.js CHANGED
@@ -9,7 +9,7 @@ const { AgentMarket, Bid, Reputation, MIN_STAKE } = require('./lib/market');
9
9
  const { McpHttpClient, McpError, MCP_PROTOCOL_VERSION } = require('./lib/mcp');
10
10
  const aca = require('./lib/aca');
11
11
 
12
- const version = '3.5.0';
12
+ const version = '3.6.1';
13
13
 
14
14
  /**
15
15
  * AgentUniverse 门面:聚合身份、网络、市场能力
package/js/lib/aca.js CHANGED
@@ -158,7 +158,7 @@ function buildManifest(identity, name, capabilities, opts = {}) {
158
158
  const manifest = {
159
159
  did: identity.did,
160
160
  name,
161
- version: opts.version || '3.5.0',
161
+ version: opts.version || '3.6.1',
162
162
  capabilities: [...capabilities],
163
163
  endpoints: opts.endpoints || [],
164
164
  hardware: {
package/js/lib/mcp.js CHANGED
@@ -18,12 +18,25 @@ class McpHttpClient {
18
18
  constructor(
19
19
  baseUrl = 'http://127.0.0.1:4002',
20
20
  path = '/api/v1/mcp',
21
- timeout = 10000
21
+ timeout = 10000,
22
+ authToken = null
22
23
  ) {
23
24
  this.endpoint = baseUrl.replace(/\/$/, '') + path;
24
25
  this.timeout = timeout;
25
26
  this._id = 0;
26
27
  this.initialized = false;
28
+ // v3.5.3(AU-15):可选 Bearer token。设置后所有 MCP 请求带
29
+ // `Authorization: Bearer <token>`;不设置则不发送该头(保持现状)。
30
+ this.authToken = authToken || null;
31
+ }
32
+
33
+ _headers() {
34
+ const h = {
35
+ 'Content-Type': 'application/json',
36
+ Accept: 'application/json',
37
+ };
38
+ if (this.authToken) h['Authorization'] = `Bearer ${this.authToken}`;
39
+ return h;
27
40
  }
28
41
 
29
42
  async _post(payload, awaitResponse = true) {
@@ -33,10 +46,7 @@ class McpHttpClient {
33
46
  try {
34
47
  res = await fetch(this.endpoint, {
35
48
  method: 'POST',
36
- headers: {
37
- 'Content-Type': 'application/json',
38
- Accept: 'application/json',
39
- },
49
+ headers: this._headers(),
40
50
  body: JSON.stringify(payload),
41
51
  signal: ctrl.signal,
42
52
  });
@@ -60,7 +70,7 @@ class McpHttpClient {
60
70
  method: 'initialize',
61
71
  params: {
62
72
  protocolVersion: MCP_PROTOCOL_VERSION,
63
- clientInfo: { name: 'agent-universe-js', version: '3.5.0' },
73
+ clientInfo: { name: 'agent-universe-js', version: '3.6.1' },
64
74
  capabilities: {},
65
75
  },
66
76
  });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@twinsearth/agent-universe",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@twinsearth/agent-universe",
9
- "version": "3.5.0",
9
+ "version": "3.6.1",
10
10
  "license": "MIT",
11
11
  "engines": {
12
12
  "node": ">=18"
package/js/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/agent-universe",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "Agent Universe - 群众化的 AGI 路线,去中心化的智能体共享 & 开源网络。使命:让科技造福全人类!",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/js/test/test.js CHANGED
@@ -25,6 +25,7 @@ const {
25
25
  verifyMessage,
26
26
  verifyReceipt,
27
27
  verifyReceiptResult,
28
+ McpHttpClient,
28
29
  } = require('../index');
29
30
 
30
31
  let passed = 0;
@@ -43,8 +44,8 @@ function test(name, fn) {
43
44
  console.log('Agent Universe JS SDK 测试\n');
44
45
 
45
46
  // 1. 版本号
46
- test('版本号为 3.5.0', () => {
47
- assert.strictEqual(version, '3.5.0');
47
+ test('版本号为 3.6.1', () => {
48
+ assert.strictEqual(version, '3.6.1');
48
49
  });
49
50
 
50
51
  // 2. 密钥对 + DID + 签名验证
@@ -101,7 +102,11 @@ test('ShardedIndex 分片落盘且分片号合法', () => {
101
102
  assert.ok(s >= 0 && s < 16);
102
103
  }
103
104
  assert.strictEqual(idx.size, 100);
104
- assert.strictEqual(shardOf('key-0', 16), shardOf('key-0', 16));
105
+ // v3.5.3(AU-39):旧断言 shardOf('key-0',16) === shardOf('key-0',16) 恒真(自身比自身)。
106
+ // 改为有意义的不变量:①同一 key 分片结果确定(两次调用一致);②结果落在合法区间 [0,16)。
107
+ const shard = shardOf('key-0', 16);
108
+ assert.strictEqual(shardOf('key-0', 16), shard);
109
+ assert.ok(Number.isInteger(shard) && shard >= 0 && shard < 16, `分片号合法: ${shard}`);
105
110
  // 分布:100 key 到 16 片,不应有大片为空(概率性,至少覆盖 8 片)
106
111
  const nonEmpty = idx.distribution().filter((n) => n > 0).length;
107
112
  assert.ok(nonEmpty >= 8, `非空分片 ${nonEmpty} >= 8`);
@@ -447,6 +452,17 @@ test('v2.7.1 stableStringify:undefined 键省略、BigInt/Date 显式拒绝、
447
452
  assert.strictEqual(stableStringify({ b: 1, a: 2 }), '{"a":2,"b":1}');
448
453
  });
449
454
 
455
+ // 18. MCP Bearer 注入(v3.5.3,AU-15)
456
+ test('McpHttpClient:带 token 发 Bearer 头、不带则不发', () => {
457
+ // 不设置 token → 不出现 Authorization 头。
458
+ const noAuth = new McpHttpClient();
459
+ assert.strictEqual(noAuth._headers().Authorization, undefined);
460
+ assert.strictEqual(noAuth._headers()['Content-Type'], 'application/json');
461
+ // 设置 token → 带正确的 Bearer 头。
462
+ const withAuth = new McpHttpClient('http://127.0.0.1:4002', '/api/v1/mcp', 10000, 'secret-xyz');
463
+ assert.strictEqual(withAuth._headers().Authorization, 'Bearer secret-xyz');
464
+ });
465
+
450
466
  console.log(`\n${passed} 项测试通过`);
451
467
  if (process.exitCode === 1) {
452
468
  console.error('存在失败测试');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/agent-universe",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "Agent Universe - 群众化的 AGI 路线,去中心化的智能体共享 & 开源网络。使命:让科技造福全人类!",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",