@twinsearth/agent-universe 2.5.6 → 2.5.7

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
@@ -273,7 +273,7 @@ npm config set @twinsearth:registry https://npm.pkg.github.com
273
273
  npm install @twinsearth/agent-universe
274
274
  ```
275
275
 
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.5.6,详见 [Releases](https://github.com/TwinsEarth/agent-universe/releases)。
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.5.7,详见 [Releases](https://github.com/TwinsEarth/agent-universe/releases)。
277
277
 
278
278
  ## 版本谱系
279
279
 
@@ -307,6 +307,7 @@ npm install @twinsearth/agent-universe
307
307
  | v2.5.4 | **Traversal** | **NAT 穿透:Circuit Relay v2 + AutoNAT + DCUtR + Ping,跨网中继** |
308
308
  | v2.5.5 | **Relay Pool** | **Relay 节点池管理 + 多通道智能切换(默认 3 条,掉线自动补)** |
309
309
  | v2.5.6 | **Regression** | **历史 Bug 回归套件:test/ 14 条 + Rust 网络回归,CI 强制全量回归,修新 bug 先加用例** |
310
+ | v2.5.7 | **Identity** | **跨实现身份一致性:统一 DID 派生口径 + conformance 签名向量逐字节命中上游 + 客户端构建链路根治(file: 依赖)** |
310
311
 
311
312
  详见 [RELEASES.md](RELEASES.md) 和 [releases/](releases/) 目录。
312
313
 
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 = '2.5.6';
12
+ const version = '2.5.7';
13
13
 
14
14
  /**
15
15
  * AgentUniverse 门面:聚合身份、网络、市场能力
package/js/lib/aca.js CHANGED
@@ -129,7 +129,7 @@ function buildManifest(identity, name, capabilities, opts = {}) {
129
129
  const manifest = {
130
130
  did: identity.did,
131
131
  name,
132
- version: opts.version || '2.5.6',
132
+ version: opts.version || '2.5.7',
133
133
  capabilities: [...capabilities],
134
134
  endpoints: opts.endpoints || [],
135
135
  hardware: {
@@ -1,29 +1,51 @@
1
1
  // lib/keychain.js
2
2
  // Ed25519 密钥对 + DID 身份(零依赖,使用 node:crypto)
3
+ //
4
+ // v2.5.7:身份派生口径与 Rust / Python 统一 ——
5
+ // fingerprint = hex(SHA-256(原始 32 字节公钥)[..8])
6
+ // 本项目新铸造身份使用 did:nau: 前缀;parseDid 仍接受上游 did:aip:。
3
7
 
4
8
  const crypto = require('node:crypto');
5
9
 
10
+ // Ed25519 SubjectPublicKeyInfo DER 固定前缀(其后紧跟 32 字节原始公钥)
11
+ const SPKI_PREFIX = Buffer.from('302a300506032b6570032100', 'hex');
12
+
6
13
  /**
7
14
  * 密钥对与去中心化身份
8
15
  */
9
16
  class Keypair {
10
17
  constructor(publicKey, privateKey, did) {
11
- this.publicKey = publicKey; // hex
12
- this.privateKey = privateKey; // hex(node KeyObject 可导出的形式)
13
- this.did = did; // did:au:<hash>
18
+ this.publicKey = publicKey; // SPKI DER hex
19
+ this.privateKey = privateKey; // PKCS8 DER hex
20
+ this.did = did; // did:nau:<fingerprint>
21
+ }
22
+
23
+ /** 从原始 32 字节公钥计算 fingerprint(与 Rust/Python 一致) */
24
+ static fingerprint(rawPubkey) {
25
+ return crypto.createHash('sha256')
26
+ .update(rawPubkey)
27
+ .digest('hex')
28
+ .slice(0, 16); // 前 8 字节 = 16 hex 字符
29
+ }
30
+
31
+ /** 解析 DID,接受上游 did:aip: 与本项目 did:nau:;返回 {method, identifier} */
32
+ static parseDid(s) {
33
+ const m = /^did:(aip|nau):([0-9a-f]+)$/.exec(s);
34
+ if (!m) {
35
+ throw new Error(`不支持的 DID(格式应为 did:<aip|nau>:<id>): ${s}`);
36
+ }
37
+ return { method: m[1], identifier: m[2] };
14
38
  }
15
39
 
16
- /** 生成新的 Ed25519 密钥对与 DID */
40
+ /** 生成新的 Ed25519 密钥对与 DID(新身份使用 did:nau:) */
17
41
  static generate() {
18
42
  const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
19
- const pubHex = publicKey.export({ format: 'der', type: 'spki' })
20
- .toString('hex');
21
- // DID 由公钥的 SHA-256 哈希(取前 32 字符)派生
22
- const didHash = crypto.createHash('sha256')
23
- .update(publicKey.export({ format: 'der', type: 'spki' }))
24
- .digest('hex')
25
- .slice(0, 32);
26
- const did = `did:au:${didHash}`;
43
+ const spkiDer = publicKey.export({ format: 'der', type: 'spki' });
44
+ const pubHex = spkiDer.toString('hex');
45
+
46
+ // 去掉 SPKI 固定前缀,得到 32 字节原始公钥
47
+ const rawPub = spkiDer.subarray(SPKI_PREFIX.length);
48
+ const did = `did:nau:${Keypair.fingerprint(rawPub)}`;
27
49
 
28
50
  // 私钥以 PKCS8 DER hex 保存,便于重建 KeyObject
29
51
  const privHex = privateKey.export({ format: 'der', type: 'pkcs8' })
@@ -57,6 +79,12 @@ class Keypair {
57
79
  return this._pubKeyObj;
58
80
  }
59
81
 
82
+ /** 返回 32 字节原始公钥 */
83
+ rawPublicKey() {
84
+ const spkiDer = this._publicKeyObject().export({ format: 'der', type: 'spki' });
85
+ return spkiDer.subarray(SPKI_PREFIX.length);
86
+ }
87
+
60
88
  /** 对消息签名,返回 hex */
61
89
  sign(message) {
62
90
  const data = Buffer.isBuffer(message) ? message : Buffer.from(message);
package/js/lib/mcp.js CHANGED
@@ -60,7 +60,7 @@ class McpHttpClient {
60
60
  method: 'initialize',
61
61
  params: {
62
62
  protocolVersion: MCP_PROTOCOL_VERSION,
63
- clientInfo: { name: 'agent-universe-js', version: '2.5.6' },
63
+ clientInfo: { name: 'agent-universe-js', version: '2.5.7' },
64
64
  capabilities: {},
65
65
  },
66
66
  });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@twinsearth/agent-universe",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@twinsearth/agent-universe",
9
- "version": "2.5.6",
9
+ "version": "2.5.7",
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": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "Agent Universe - 群众化的 AGI 路线,去中心化的智能体共享 & 开源网络。使命:让科技造福全人类!",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/js/test/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // test/test.js
2
- // Agent Universe JS SDK 测试(8 项)
2
+ // Agent Universe JS SDK 测试(12 项)
3
3
 
4
4
  const assert = require('node:assert');
5
5
  const {
@@ -41,15 +41,15 @@ function test(name, fn) {
41
41
  console.log('Agent Universe JS SDK 测试\n');
42
42
 
43
43
  // 1. 版本号
44
- test('版本号为 2.5.6', () => {
45
- assert.strictEqual(version, '2.5.6');
44
+ test('版本号为 2.5.7', () => {
45
+ assert.strictEqual(version, '2.5.7');
46
46
  });
47
47
 
48
48
  // 2. 密钥对 + DID + 签名验证
49
49
  test('Keypair 生成 DID 且签名可验证', () => {
50
50
  const kp = Keypair.generate();
51
- assert.ok(kp.did.startsWith('did:au:'), 'DID 前缀');
52
- assert.strictEqual(kp.did.length, 'did:au:'.length + 32);
51
+ assert.ok(kp.did.startsWith('did:nau:'), 'DID 前缀');
52
+ assert.strictEqual(kp.did.length, 'did:nau:'.length + 16);
53
53
  const msg = 'hello agent universe';
54
54
  const sig = kp.sign(msg);
55
55
  assert.ok(kp.verify(msg, sig), '签名验证通过');
package/lib/aca.js ADDED
@@ -0,0 +1,3 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/aca.js 子路径,供浏览器端按需引入(与 js 子包发布结构对齐)。
3
+ module.exports = require('../js/lib/aca.js');
package/lib/dht.js ADDED
@@ -0,0 +1,3 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/dht.js 子路径(与 js 子包发布结构对齐)。
3
+ module.exports = require('../js/lib/dht.js');
@@ -0,0 +1,3 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/keychain.js 子路径(依赖 node:crypto,浏览器端勿直接引)。
3
+ module.exports = require('../js/lib/keychain.js');
package/lib/market.js ADDED
@@ -0,0 +1,4 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/market.js 子路径。market.js 为纯逻辑(仅依赖 models,不引 node:crypto),
3
+ // 浏览器 / WKWebView 端只引此模块即可运行市场演示,避开密钥模块。
4
+ module.exports = require('../js/lib/market.js');
package/lib/mcp.js ADDED
@@ -0,0 +1,3 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/mcp.js 子路径(与 js 子包发布结构对齐)。
3
+ module.exports = require('../js/lib/mcp.js');
package/lib/models.js ADDED
@@ -0,0 +1,3 @@
1
+ // 根包 /lib 子路径入口(v2.5.7 补):re-export js/lib,
2
+ // 使根发布包暴露 /lib/models.js 子路径(与 js 子包发布结构对齐)。
3
+ module.exports = require('../js/lib/models.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/agent-universe",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "Agent Universe - 群众化的 AGI 路线,去中心化的智能体共享 & 开源网络。使命:让科技造福全人类!",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -41,6 +41,7 @@
41
41
  "files": [
42
42
  "index.js",
43
43
  "index.d.ts",
44
- "js"
44
+ "js",
45
+ "lib"
45
46
  ]
46
47
  }