@fosenai/cord 0.1.0-alpha.16 → 0.1.0-alpha.17

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 ADDED
@@ -0,0 +1,44 @@
1
+ # @fosenai/cord
2
+
3
+ Cord Rust CLI — install via npm,跑的是 native binary。
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @fosenai/cord
9
+ ```
10
+
11
+ npm 会按你机器的 OS / arch 自动拉对应平台的 binary(`@fosenai/cord-darwin-arm64` /
12
+ `-darwin-x64` / `-linux-x64` / `-linux-arm64`)。
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ cord whoami # 临时 keypair → peerId
18
+ cord serve --port 0 # 起节点 + 注册 echo cap
19
+ --api-port 7878 # + HTTP 管理面(GET /info /capabilities, POST /call)
20
+ --bridge codex=codex # + 把 codex CLI 包成一个 P2P cap
21
+ --bridge-mode prompt-arg
22
+ --mdns # + 局域网 mDNS 发现
23
+ cord call --peer <multiaddr> # dial peer 调它的 cap
24
+ --cap echo --input '{"x":1}'
25
+ cord info --api http://... # 查正在跑的 daemon 状态
26
+ ```
27
+
28
+ ## Build from source
29
+
30
+ 不想用 prebuilt binary:
31
+
32
+ ```bash
33
+ git clone https://github.com/your-org/cord.git
34
+ cd cord/rust
35
+ cargo install --path crates/cord-cli
36
+ ```
37
+
38
+ 带 ONNX bge-m3 模型支持(embed-server):
39
+
40
+ ```bash
41
+ cargo install --path crates/cord-embed-server --features embed-onnx
42
+ ```
43
+
44
+ 详见 https://github.com/your-org/cord/tree/rust
package/bin/cord.js CHANGED
@@ -1,34 +1,53 @@
1
1
  #!/usr/bin/env node
2
- // Cord CLI shim — resolves the platform-specific native binary and execs it.
2
+ // cord —— shim:找当前平台的 native binary 然后透传 argv
3
+ // optionalDependencies 装了 @fosenai/cord-<os>-<arch>,binary 在它的包里
4
+
3
5
  const { spawnSync } = require('node:child_process')
6
+ const { existsSync } = require('node:fs')
4
7
  const path = require('node:path')
5
8
 
6
- const map = {
7
- 'darwin-arm64': '@fosenai/cord-darwin-arm64',
8
- 'darwin-x64': '@fosenai/cord-darwin-x64',
9
- 'linux-x64': '@fosenai/cord-linux-x64',
10
- 'linux-arm64': '@fosenai/cord-linux-arm64',
11
- 'win32-x64': '@fosenai/cord-windows-x64',
9
+ function platformPkg() {
10
+ const os = process.platform // 'darwin' | 'linux' | 'win32'
11
+ const arch = process.arch // 'arm64' | 'x64'
12
+ const map = {
13
+ 'darwin-arm64': '@fosenai/cord-darwin-arm64',
14
+ 'darwin-x64': '@fosenai/cord-darwin-x64',
15
+ 'linux-x64': '@fosenai/cord-linux-x64',
16
+ 'linux-arm64': '@fosenai/cord-linux-arm64',
17
+ }
18
+ const key = `${os}-${arch}`
19
+ return map[key]
12
20
  }
13
21
 
14
- const key = `${process.platform}-${process.arch}`
15
- const pkg = map[key]
16
- if (!pkg) {
17
- console.error(`cord: no prebuilt binary for ${key}`)
18
- console.error(`cord: supported platforms: ${Object.keys(map).join(', ')}`)
19
- process.exit(1)
22
+ function findBinary() {
23
+ const pkg = platformPkg()
24
+ if (!pkg) {
25
+ console.error(`[cord] no prebuilt binary for ${process.platform}-${process.arch}`)
26
+ console.error(`[cord] supported: darwin-arm64 / darwin-x64 / linux-x64 / linux-arm64`)
27
+ console.error(`[cord] build from source: cargo install --git https://github.com/your-org/cord cord-cli`)
28
+ process.exit(1)
29
+ }
30
+ let pkgRoot
31
+ try {
32
+ pkgRoot = path.dirname(require.resolve(`${pkg}/package.json`))
33
+ } catch (e) {
34
+ console.error(`[cord] platform package ${pkg} not installed`)
35
+ console.error(`[cord] try: npm install ${pkg}`)
36
+ process.exit(1)
37
+ }
38
+ const ext = process.platform === 'win32' ? '.exe' : ''
39
+ const bin = path.join(pkgRoot, `cord${ext}`)
40
+ if (!existsSync(bin)) {
41
+ console.error(`[cord] binary not found at ${bin}`)
42
+ process.exit(1)
43
+ }
44
+ return bin
20
45
  }
21
46
 
22
- let binPath
23
- try {
24
- const root = path.dirname(require.resolve(`${pkg}/package.json`))
25
- const ext = process.platform === 'win32' ? '.exe' : ''
26
- binPath = path.join(root, `cord${ext}`)
27
- } catch {
28
- console.error(`cord: platform package ${pkg} not installed`)
29
- console.error(`cord: try: npm install ${pkg}`)
47
+ const bin = findBinary()
48
+ const r = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' })
49
+ if (r.error) {
50
+ console.error(`[cord] failed to spawn: ${r.error.message}`)
30
51
  process.exit(1)
31
52
  }
32
-
33
- const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' })
34
- process.exit(result.status ?? 1)
53
+ process.exit(r.status ?? 0)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@fosenai/cord",
3
- "version": "0.1.0-alpha.16",
4
- "description": "Cord distributed agent fabric for LLMs, MCP servers and AI agents. Wrap any LLM CLI / HTTP backend / MCP server into a network-discoverable capability and find it across machines via natural-language semantic search.",
5
- "license": "Apache-2.0",
3
+ "version": "0.1.0-alpha.17",
4
+ "description": "Cord Rust CLI install via npm, runs as native binary",
5
+ "license": "BUSL-1.1",
6
6
  "bin": {
7
7
  "cord": "bin/cord.js"
8
8
  },
@@ -15,52 +15,22 @@
15
15
  "postinstall": "node scripts/install.js"
16
16
  },
17
17
  "optionalDependencies": {
18
- "@fosenai/cord-darwin-arm64": "0.1.0-alpha.16",
19
- "@fosenai/cord-darwin-x64": "0.1.0-alpha.16",
20
- "@fosenai/cord-linux-x64": "0.1.0-alpha.16",
21
- "@fosenai/cord-linux-arm64": "0.1.0-alpha.16",
22
- "@fosenai/cord-windows-x64": "0.1.0-alpha.16"
18
+ "@fosenai/cord-darwin-arm64": "0.1.0-alpha.17",
19
+ "@fosenai/cord-darwin-x64": "0.1.0-alpha.17",
20
+ "@fosenai/cord-linux-x64": "0.1.0-alpha.17",
21
+ "@fosenai/cord-linux-arm64": "0.1.0-alpha.17"
23
22
  },
24
23
  "engines": {
25
24
  "node": ">=18"
26
25
  },
27
26
  "repository": {
28
27
  "type": "git",
29
- "url": "git+https://github.com/fosenai/cord.git"
30
- },
31
- "homepage": "https://github.com/fosenai/cord",
32
- "bugs": {
33
- "url": "https://github.com/fosenai/cord/issues"
28
+ "url": "git+https://github.com/your-org/cord.git"
34
29
  },
35
30
  "keywords": [
36
- "cord",
31
+ "p2p",
37
32
  "agent",
38
- "ai-agent",
39
- "ai-agents",
40
- "multi-agent",
41
- "multi-agent-systems",
42
- "multi-agent-collaboration",
43
- "autonomous-agents",
44
- "agent-network",
45
- "agent-mesh",
46
- "agent-discovery",
47
- "agent-orchestration",
48
- "decentralized",
49
- "distributed",
50
- "mcp",
51
- "mcp-server",
52
- "mcp-client",
53
- "model-context-protocol",
54
- "llm",
55
- "llm-agent",
56
- "llm-cli",
57
- "claude",
58
- "claude-code",
59
- "codex",
60
- "ollama",
61
- "anthropic",
62
- "openai",
63
- "cli",
33
+ "libp2p",
64
34
  "rust"
65
35
  ]
66
36
  }
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- // postinstall: verify the platform binary made it through optionalDependencies.
2
+ // 装完 @fosenai/cord 后跑这个脚本检查平台 binary 是否拿到。
3
+ // optionalDependencies 不会因为某个平台拉失败而 break 整个 install。
4
+
3
5
  const { existsSync } = require('node:fs')
4
6
  const path = require('node:path')
5
7
 
@@ -8,14 +10,14 @@ const map = {
8
10
  'darwin-x64': '@fosenai/cord-darwin-x64',
9
11
  'linux-x64': '@fosenai/cord-linux-x64',
10
12
  'linux-arm64': '@fosenai/cord-linux-arm64',
11
- 'win32-x64': '@fosenai/cord-windows-x64',
12
13
  }
13
14
 
14
15
  const key = `${process.platform}-${process.arch}`
15
16
  const pkg = map[key]
16
17
  if (!pkg) {
17
- console.warn(`[cord] no prebuilt binary for ${key}; please file an issue at`)
18
- console.warn(`[cord] https://github.com/fosenai/cord/issues`)
18
+ console.warn(`[cord postinstall] no prebuilt binary for ${key}`)
19
+ console.warn(`[cord postinstall] you can build from source:`)
20
+ console.warn(`[cord postinstall] cargo install --git https://github.com/your-org/cord cord-cli`)
19
21
  process.exit(0)
20
22
  }
21
23
 
@@ -24,11 +26,11 @@ try {
24
26
  const ext = process.platform === 'win32' ? '.exe' : ''
25
27
  const bin = path.join(root, `cord${ext}`)
26
28
  if (existsSync(bin)) {
27
- console.log(`[cord] ok: ${pkg}`)
29
+ console.log(`[cord postinstall] ok: ${pkg} (${bin})`)
28
30
  } else {
29
- console.warn(`[cord] ${pkg} installed but binary missing at ${bin}`)
31
+ console.warn(`[cord postinstall] ${pkg} installed but binary missing at ${bin}`)
30
32
  }
31
33
  } catch {
32
- console.warn(`[cord] platform package ${pkg} not installed (optional deps may be filtered)`)
33
- console.warn(`[cord] try: npm install ${pkg}`)
34
+ console.warn(`[cord postinstall] platform package ${pkg} not installed`)
35
+ console.warn(`[cord postinstall] try manually: npm install ${pkg}`)
34
36
  }