@nodes/agent 0.0.3 → 0.0.4
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/cli.js +0 -0
- package/package.json +16 -23
- package/src/cli.ts +0 -120
- package/src/index.ts +0 -3
package/dist/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodes/agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Autonomous AI agent runtime for Nodes",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "
|
|
7
|
-
"types": "
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"nodes": "
|
|
10
|
-
},
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"main": "dist/index.js",
|
|
13
|
-
"types": "dist/index.d.ts",
|
|
14
|
-
"bin": {
|
|
15
|
-
"nodes": "dist/cli.js"
|
|
16
|
-
}
|
|
9
|
+
"nodes": "dist/cli.js"
|
|
17
10
|
},
|
|
18
11
|
"files": [
|
|
19
12
|
"dist"
|
|
20
13
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"dev": "tsx --env-file=.env src/cli.ts",
|
|
24
|
-
"prompt": "tsx --env-file=.env src/cli.ts -p",
|
|
25
|
-
"serve": "tsx --env-file=.env src/cli.ts --serve",
|
|
26
|
-
"test": "vitest run",
|
|
27
|
-
"test:watch": "vitest",
|
|
28
|
-
"test:integration": "vitest run src/tests/run-once.test.ts"
|
|
29
|
-
},
|
|
30
14
|
"dependencies": {
|
|
31
15
|
"@ai-sdk/anthropic": "3.0.47",
|
|
32
16
|
"@ai-sdk/gateway": "3.0.46",
|
|
@@ -34,16 +18,25 @@
|
|
|
34
18
|
"@ai-sdk/openai": "3.0.33",
|
|
35
19
|
"@mariozechner/pi-tui": "^0.55.0",
|
|
36
20
|
"@modelcontextprotocol/sdk": "1.23.0",
|
|
37
|
-
"@nodes/sdk": "workspace:*",
|
|
38
21
|
"ai": "6.0.86",
|
|
39
22
|
"picocolors": "^1.1.1",
|
|
40
23
|
"vercel-minimax-ai-provider": "0.0.2",
|
|
41
|
-
"zod": "3.25.76"
|
|
24
|
+
"zod": "3.25.76",
|
|
25
|
+
"@nodes/sdk": "0.0.1"
|
|
42
26
|
},
|
|
43
27
|
"devDependencies": {
|
|
44
28
|
"@types/node": "^24.0.0",
|
|
45
29
|
"tsx": "^4.19.0",
|
|
46
30
|
"typescript": "^5.6.0",
|
|
47
31
|
"vitest": "^4.0.18"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"dev": "tsx --env-file=.env src/cli.ts",
|
|
36
|
+
"prompt": "tsx --env-file=.env src/cli.ts -p",
|
|
37
|
+
"serve": "tsx --env-file=.env src/cli.ts --serve",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"test:integration": "vitest run src/tests/run-once.test.ts"
|
|
48
41
|
}
|
|
49
|
-
}
|
|
42
|
+
}
|
package/src/cli.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { parseArgs } from 'node:util'
|
|
4
|
-
import { createRequire } from 'module'
|
|
5
|
-
import { NodesClient } from '@nodes/sdk'
|
|
6
|
-
import { runOnce, interactive } from './core/loop.js'
|
|
7
|
-
import { interactiveTUI } from './core/tui-chat.js'
|
|
8
|
-
import { serve } from './core/serve.js'
|
|
9
|
-
|
|
10
|
-
const require = createRequire(import.meta.url)
|
|
11
|
-
const pkg = require('../package.json') as { version: string }
|
|
12
|
-
|
|
13
|
-
const { values } = parseArgs({
|
|
14
|
-
options: {
|
|
15
|
-
prompt: { type: 'string', short: 'p' },
|
|
16
|
-
node: { type: 'string', short: 'n' },
|
|
17
|
-
provider: { type: 'string' },
|
|
18
|
-
serve: { type: 'boolean' },
|
|
19
|
-
simple: { type: 'boolean' },
|
|
20
|
-
help: { type: 'boolean', short: 'h' },
|
|
21
|
-
version: { type: 'boolean', short: 'v' },
|
|
22
|
-
},
|
|
23
|
-
strict: false,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
if (values.help) {
|
|
27
|
-
console.log(`
|
|
28
|
-
nodes — Autonomous AI agent for Nodes
|
|
29
|
-
|
|
30
|
-
Usage:
|
|
31
|
-
nodes Start in interactive mode (new chat)
|
|
32
|
-
nodes -n <nodeId> Resume interactive chat on existing node
|
|
33
|
-
nodes -p "prompt" Run a single prompt and exit
|
|
34
|
-
nodes -p "prompt" -n <id> Run prompt in existing chat and exit
|
|
35
|
-
nodes --provider claude-cli Use local Claude CLI (Max subscription)
|
|
36
|
-
nodes --serve Start MCP server (exposes local tools)
|
|
37
|
-
nodes --simple Use simple readline UI (no TUI)
|
|
38
|
-
nodes --help Show this help
|
|
39
|
-
|
|
40
|
-
Environment:
|
|
41
|
-
NODES_URL Nodes instance URL (default: https://nodes.ws)
|
|
42
|
-
NODES_API_KEY API key for authentication
|
|
43
|
-
NODES_AGENT Agent slug (e.g. "nodes/my-agent") or user ID
|
|
44
|
-
PORT MCP server port (default: 8788, --serve only)
|
|
45
|
-
`)
|
|
46
|
-
process.exit(0)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (values.version) {
|
|
50
|
-
console.log(`nodes ${pkg.version}`)
|
|
51
|
-
process.exit(0)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// --serve doesn't require Nodes credentials (purely local MCP server)
|
|
55
|
-
if (values.serve) {
|
|
56
|
-
serve().catch((err) => {
|
|
57
|
-
console.error(err.message)
|
|
58
|
-
process.exit(1)
|
|
59
|
-
})
|
|
60
|
-
} else {
|
|
61
|
-
// All other modes require Nodes connection
|
|
62
|
-
const url = process.env.NODES_URL || 'https://nodes.ws'
|
|
63
|
-
const apiKey = process.env.NODES_API_KEY || ''
|
|
64
|
-
const agent = process.env.NODES_AGENT || ''
|
|
65
|
-
|
|
66
|
-
if (!apiKey) {
|
|
67
|
-
console.error('Error: NODES_API_KEY is required.')
|
|
68
|
-
process.exit(1)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!agent) {
|
|
72
|
-
console.error('Error: NODES_AGENT is required (agent slug or user ID).')
|
|
73
|
-
process.exit(1)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Extract userId from user-scoped token (nodes_<userId>_<secret>)
|
|
77
|
-
const tokenMatch = apiKey.match(/^nodes_([a-f0-9]{24})_[a-f0-9]{32}$/)
|
|
78
|
-
const userId = tokenMatch?.[1]
|
|
79
|
-
|
|
80
|
-
const prompt = values.prompt as string | undefined
|
|
81
|
-
const nodeId = values.node as string | undefined
|
|
82
|
-
const provider = values.provider as string | undefined
|
|
83
|
-
|
|
84
|
-
const nodes = new NodesClient({ url, apiKey, agent })
|
|
85
|
-
const config = { nodes, agent, userId, prompt, nodeId, provider, nodesUrl: url, nodesApiKey: apiKey }
|
|
86
|
-
|
|
87
|
-
if (prompt) {
|
|
88
|
-
// One-shot mode
|
|
89
|
-
runOnce(config)
|
|
90
|
-
.then((result) => {
|
|
91
|
-
console.log(JSON.stringify(result, null, 2))
|
|
92
|
-
process.exit(0)
|
|
93
|
-
})
|
|
94
|
-
.catch((err) => {
|
|
95
|
-
console.error(err.message)
|
|
96
|
-
process.exit(1)
|
|
97
|
-
})
|
|
98
|
-
.finally(() => nodes.disconnect())
|
|
99
|
-
} else {
|
|
100
|
-
if (values.simple) {
|
|
101
|
-
// Simple readline mode
|
|
102
|
-
process.on('SIGINT', async () => {
|
|
103
|
-
console.log('\nGoodbye.')
|
|
104
|
-
await nodes.disconnect()
|
|
105
|
-
process.exit(0)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
interactive(config).catch((err) => {
|
|
109
|
-
console.error(err.message)
|
|
110
|
-
process.exit(1)
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
// TUI mode (default) — handles its own SIGINT
|
|
114
|
-
interactiveTUI(config).catch((err) => {
|
|
115
|
-
console.error(err.message)
|
|
116
|
-
process.exit(1)
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
package/src/index.ts
DELETED