@techdigger/humanode-agentlink-cli 0.2.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/README.md +93 -0
- package/REGISTRATION.md +302 -0
- package/dist/commands/authorize-link.d.ts +19 -0
- package/dist/commands/authorize-link.js +30 -0
- package/dist/commands/init.d.ts +33 -0
- package/dist/commands/init.js +127 -0
- package/dist/commands/link.d.ts +38 -0
- package/dist/commands/link.js +82 -0
- package/dist/commands/status.d.ts +30 -0
- package/dist/commands/status.js +68 -0
- package/dist/help.d.ts +5 -0
- package/dist/help.js +103 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +185 -0
- package/dist/lib/core.d.ts +92 -0
- package/dist/lib/core.js +435 -0
- package/dist/lib/telemetry.d.ts +13 -0
- package/dist/lib/telemetry.js +123 -0
- package/dist/templates.d.ts +12 -0
- package/dist/templates.js +281 -0
- package/package.json +42 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { getPackageManagerInstallCommand, getPackageManagerRunCommand } from './lib/core.js';
|
|
2
|
+
const LANGCHAIN_VERSION = '^1.2.37';
|
|
3
|
+
const LANGCHAIN_OPENAI_VERSION = '^1.3.1';
|
|
4
|
+
const AI_SDK_VERSION = '^6.0.138';
|
|
5
|
+
const AI_SDK_OPENAI_VERSION = '^3.0.48';
|
|
6
|
+
const MCP_SDK_VERSION = '^1.12.1';
|
|
7
|
+
const DOTENV_VERSION = '^17.3.1';
|
|
8
|
+
const TSX_VERSION = '^4.19.4';
|
|
9
|
+
const TYPESCRIPT_VERSION = '^5.8.3';
|
|
10
|
+
function buildCommonEnv(input, includeOpenAI) {
|
|
11
|
+
const lines = [
|
|
12
|
+
`AGENT_PRIVATE_KEY=0xyouragentprivatekey`,
|
|
13
|
+
`BIOMAPPER_NETWORK=${input.network}`,
|
|
14
|
+
`BIOMAPPER_REGISTRY=${input.registry}`,
|
|
15
|
+
`BIOMAPPER_LINKER_URL=http://localhost:5173/`,
|
|
16
|
+
];
|
|
17
|
+
if (includeOpenAI) {
|
|
18
|
+
lines.unshift('OPENAI_API_KEY=your-openai-api-key', 'OPENAI_MODEL=gpt-4.1-mini');
|
|
19
|
+
}
|
|
20
|
+
return `${lines.join('\n')}\n`;
|
|
21
|
+
}
|
|
22
|
+
function buildGitIgnore() {
|
|
23
|
+
return `node_modules
|
|
24
|
+
.env
|
|
25
|
+
.env.local
|
|
26
|
+
dist
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
function buildTsconfig() {
|
|
30
|
+
return `{
|
|
31
|
+
"compilerOptions": {
|
|
32
|
+
"target": "ES2022",
|
|
33
|
+
"module": "NodeNext",
|
|
34
|
+
"moduleResolution": "NodeNext",
|
|
35
|
+
"types": ["node"],
|
|
36
|
+
"strict": true,
|
|
37
|
+
"esModuleInterop": true,
|
|
38
|
+
"skipLibCheck": true
|
|
39
|
+
},
|
|
40
|
+
"include": ["src"]
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
function buildPackageJson(input) {
|
|
45
|
+
const base = {
|
|
46
|
+
name: input.packageName,
|
|
47
|
+
private: true,
|
|
48
|
+
type: 'module',
|
|
49
|
+
scripts: {
|
|
50
|
+
dev: 'tsx src/index.ts',
|
|
51
|
+
link: 'agentlink link',
|
|
52
|
+
status: 'agentlink status',
|
|
53
|
+
'authorize-link': 'agentlink authorize-link',
|
|
54
|
+
},
|
|
55
|
+
devDependencies: {
|
|
56
|
+
'@techdigger/humanode-agentlink-cli': input.humanodePackages.cli,
|
|
57
|
+
tsx: TSX_VERSION,
|
|
58
|
+
typescript: TYPESCRIPT_VERSION,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
switch (input.template) {
|
|
62
|
+
case 'langchain':
|
|
63
|
+
return JSON.stringify({
|
|
64
|
+
...base,
|
|
65
|
+
dependencies: {
|
|
66
|
+
'@techdigger/humanode-agentlink-langchain': input.humanodePackages.langchain,
|
|
67
|
+
'@langchain/openai': LANGCHAIN_OPENAI_VERSION,
|
|
68
|
+
dotenv: DOTENV_VERSION,
|
|
69
|
+
langchain: LANGCHAIN_VERSION,
|
|
70
|
+
},
|
|
71
|
+
}, null, 2);
|
|
72
|
+
case 'vercel-ai-sdk':
|
|
73
|
+
return JSON.stringify({
|
|
74
|
+
...base,
|
|
75
|
+
dependencies: {
|
|
76
|
+
'@ai-sdk/openai': AI_SDK_OPENAI_VERSION,
|
|
77
|
+
'@techdigger/humanode-agentlink-ai-sdk': input.humanodePackages.aiSdk,
|
|
78
|
+
ai: AI_SDK_VERSION,
|
|
79
|
+
dotenv: DOTENV_VERSION,
|
|
80
|
+
},
|
|
81
|
+
}, null, 2);
|
|
82
|
+
case 'mcp':
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
...base,
|
|
85
|
+
dependencies: {
|
|
86
|
+
'@techdigger/humanode-agentlink-mcp': input.humanodePackages.mcp,
|
|
87
|
+
'@modelcontextprotocol/sdk': MCP_SDK_VERSION,
|
|
88
|
+
dotenv: DOTENV_VERSION,
|
|
89
|
+
},
|
|
90
|
+
}, null, 2);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function buildEnvLoader() {
|
|
94
|
+
return `import { config as loadEnv } from 'dotenv'
|
|
95
|
+
|
|
96
|
+
loadEnv({ path: '.env' })
|
|
97
|
+
loadEnv({ path: '.env.local', override: true })
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
function buildLangChainSource() {
|
|
101
|
+
return `${buildEnvLoader()}
|
|
102
|
+
import { ChatOpenAI } from '@langchain/openai'
|
|
103
|
+
import { createAgent } from 'langchain'
|
|
104
|
+
import { createBiomapperLangChainTools } from '@techdigger/humanode-agentlink-langchain'
|
|
105
|
+
|
|
106
|
+
async function main() {
|
|
107
|
+
const prompt =
|
|
108
|
+
process.argv.slice(2).join(' ') ||
|
|
109
|
+
'Check the configured Biomapper registry and explain what an agent developer should do next.'
|
|
110
|
+
const network = (process.env.BIOMAPPER_NETWORK ?? 'base-sepolia') as 'base' | 'base-sepolia'
|
|
111
|
+
const registryAddress = process.env.BIOMAPPER_REGISTRY as \`0x\${string}\`
|
|
112
|
+
|
|
113
|
+
const model = new ChatOpenAI({
|
|
114
|
+
model: process.env.OPENAI_MODEL ?? 'gpt-4.1-mini',
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const agent = createAgent({
|
|
118
|
+
model,
|
|
119
|
+
tools: createBiomapperLangChainTools({
|
|
120
|
+
network,
|
|
121
|
+
registryAddress,
|
|
122
|
+
}),
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const result = await agent.invoke({
|
|
126
|
+
messages: [{ role: 'user', content: prompt }],
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
console.log(JSON.stringify(result, null, 2))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
main().catch(error => {
|
|
133
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
134
|
+
process.exit(1)
|
|
135
|
+
})
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
function buildAISource() {
|
|
139
|
+
return `${buildEnvLoader()}
|
|
140
|
+
import { openai } from '@ai-sdk/openai'
|
|
141
|
+
import { generateText } from 'ai'
|
|
142
|
+
import { createBiomapperAISDKTools } from '@techdigger/humanode-agentlink-ai-sdk'
|
|
143
|
+
|
|
144
|
+
async function main() {
|
|
145
|
+
const prompt =
|
|
146
|
+
process.argv.slice(2).join(' ') ||
|
|
147
|
+
'Check the configured Biomapper registry and explain what an agent developer should do next.'
|
|
148
|
+
const network = (process.env.BIOMAPPER_NETWORK ?? 'base-sepolia') as 'base' | 'base-sepolia'
|
|
149
|
+
const registryAddress = process.env.BIOMAPPER_REGISTRY as \`0x\${string}\`
|
|
150
|
+
|
|
151
|
+
const result = await generateText({
|
|
152
|
+
model: openai(process.env.OPENAI_MODEL ?? 'gpt-4.1-mini'),
|
|
153
|
+
prompt,
|
|
154
|
+
tools: createBiomapperAISDKTools({
|
|
155
|
+
network,
|
|
156
|
+
registryAddress,
|
|
157
|
+
}),
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
console.log(result.text)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
main().catch(error => {
|
|
164
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
165
|
+
process.exit(1)
|
|
166
|
+
})
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
function buildMcpSource() {
|
|
170
|
+
return `${buildEnvLoader()}
|
|
171
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
172
|
+
import { createBiomapperMcpServer } from '@techdigger/humanode-agentlink-mcp'
|
|
173
|
+
|
|
174
|
+
async function main() {
|
|
175
|
+
const server = createBiomapperMcpServer()
|
|
176
|
+
await server.connect(new StdioServerTransport())
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
main().catch(error => {
|
|
180
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
181
|
+
process.exit(1)
|
|
182
|
+
})
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
function buildLocalSourceNote(input) {
|
|
186
|
+
if (input.packageSource !== 'local') {
|
|
187
|
+
return '';
|
|
188
|
+
}
|
|
189
|
+
return 'This starter uses local `file:` dependencies that point at the checked-out Biomapper workspace.\n\n';
|
|
190
|
+
}
|
|
191
|
+
function buildReadme(input, opts) {
|
|
192
|
+
return `# ${input.projectName}
|
|
193
|
+
|
|
194
|
+
Biomapper-ready ${opts.subtitle} starter.
|
|
195
|
+
|
|
196
|
+
## Setup
|
|
197
|
+
|
|
198
|
+
1. Fill in \`.env.local\` with your ${opts.envNote}.
|
|
199
|
+
2. Install dependencies:
|
|
200
|
+
|
|
201
|
+
\`\`\`bash
|
|
202
|
+
${getPackageManagerInstallCommand(input.packageManager)}
|
|
203
|
+
\`\`\`
|
|
204
|
+
|
|
205
|
+
3. ${opts.runCmd}
|
|
206
|
+
${opts.extraSetupStep ? `\n4. ${opts.extraSetupStep}\n` : ''}
|
|
207
|
+
${buildLocalSourceNote(input)}## Link Your Agent
|
|
208
|
+
|
|
209
|
+
\`\`\`bash
|
|
210
|
+
${getPackageManagerRunCommand(input.packageManager, 'link')} -- --owner 0xOwner --open
|
|
211
|
+
\`\`\`
|
|
212
|
+
|
|
213
|
+
## Check Status
|
|
214
|
+
|
|
215
|
+
\`\`\`bash
|
|
216
|
+
${getPackageManagerRunCommand(input.packageManager, 'status')}
|
|
217
|
+
\`\`\`
|
|
218
|
+
`;
|
|
219
|
+
}
|
|
220
|
+
function buildLangChainReadme(input) {
|
|
221
|
+
return buildReadme(input, {
|
|
222
|
+
subtitle: 'LangChain',
|
|
223
|
+
envNote: 'OpenAI key, agent private key, and Biomapper registry values',
|
|
224
|
+
runCmd: `Run the starter:\n\n\`\`\`bash\n${getPackageManagerRunCommand(input.packageManager, 'dev')} -- "Check whether my configured agent is linked"\n\`\`\``,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function buildAISDKReadme(input) {
|
|
228
|
+
return buildReadme(input, {
|
|
229
|
+
subtitle: 'Vercel AI SDK',
|
|
230
|
+
envNote: 'OpenAI key, agent private key, and Biomapper registry values',
|
|
231
|
+
runCmd: `Run the starter:\n\n\`\`\`bash\n${getPackageManagerRunCommand(input.packageManager, 'dev')} -- "Check whether my configured agent is linked"\n\`\`\``,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function buildMcpReadme(input) {
|
|
235
|
+
return buildReadme(input, {
|
|
236
|
+
subtitle: 'MCP',
|
|
237
|
+
envNote: 'agent private key and Biomapper registry values',
|
|
238
|
+
runCmd: `Run the MCP server:\n\n\`\`\`bash\n${getPackageManagerRunCommand(input.packageManager, 'dev')}\n\`\`\``,
|
|
239
|
+
extraSetupStep: 'Point your MCP-compatible host at `./mcp.config.json`.',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
const MCP_CONFIG_COMMANDS = {
|
|
243
|
+
pnpm: { command: 'pnpm', args: ['run', 'dev'] },
|
|
244
|
+
yarn: { command: 'yarn', args: ['run', 'dev'] },
|
|
245
|
+
bun: { command: 'bun', args: ['run', 'dev'] },
|
|
246
|
+
npm: { command: 'npm', args: ['run', 'dev'] },
|
|
247
|
+
};
|
|
248
|
+
function buildMcpConfig(packageManager) {
|
|
249
|
+
return `${JSON.stringify({ mcpServers: { biomapper: MCP_CONFIG_COMMANDS[packageManager] } }, null, 2)}\n`;
|
|
250
|
+
}
|
|
251
|
+
export function buildTemplateFiles(input) {
|
|
252
|
+
const commonFiles = [
|
|
253
|
+
{ path: '.gitignore', content: buildGitIgnore() },
|
|
254
|
+
{ path: 'package.json', content: `${buildPackageJson(input)}\n` },
|
|
255
|
+
{ path: 'tsconfig.json', content: buildTsconfig() },
|
|
256
|
+
];
|
|
257
|
+
switch (input.template) {
|
|
258
|
+
case 'langchain':
|
|
259
|
+
return [
|
|
260
|
+
...commonFiles,
|
|
261
|
+
{ path: '.env.local', content: buildCommonEnv(input, true) },
|
|
262
|
+
{ path: 'README.md', content: buildLangChainReadme(input) },
|
|
263
|
+
{ path: 'src/index.ts', content: buildLangChainSource() },
|
|
264
|
+
];
|
|
265
|
+
case 'vercel-ai-sdk':
|
|
266
|
+
return [
|
|
267
|
+
...commonFiles,
|
|
268
|
+
{ path: '.env.local', content: buildCommonEnv(input, true) },
|
|
269
|
+
{ path: 'README.md', content: buildAISDKReadme(input) },
|
|
270
|
+
{ path: 'src/index.ts', content: buildAISource() },
|
|
271
|
+
];
|
|
272
|
+
case 'mcp':
|
|
273
|
+
return [
|
|
274
|
+
...commonFiles,
|
|
275
|
+
{ path: '.env.local', content: buildCommonEnv(input, false) },
|
|
276
|
+
{ path: 'README.md', content: buildMcpReadme(input) },
|
|
277
|
+
{ path: 'mcp.config.json', content: buildMcpConfig(input.packageManager) },
|
|
278
|
+
{ path: 'src/index.ts', content: buildMcpSource() },
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@techdigger/humanode-agentlink-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Scaffold, link, and inspect Biomapper-ready agent projects.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agentlink": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"REGISTRATION.md"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"test": "bun test tests/*.test.ts",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"publish:npm": "npm publish",
|
|
23
|
+
"cli": "tsx src/index.ts"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@techdigger/humanode-agentlink": "^0.2.0",
|
|
27
|
+
"posthog-node": "^5.21.2",
|
|
28
|
+
"viem": "^2.46.2"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"biomapper",
|
|
32
|
+
"agentlink",
|
|
33
|
+
"cli",
|
|
34
|
+
"x402",
|
|
35
|
+
"mcp"
|
|
36
|
+
],
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^24.3.2",
|
|
39
|
+
"tsx": "^4.19.4",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
}
|
|
42
|
+
}
|