@mce-bt/microagents-cli 0.1.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/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +93 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/channel.d.ts +8 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +96 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/chat.d.ts +11 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +18 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/dev.d.ts +11 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +103 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +50 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +62 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/templates.d.ts +40 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +315 -0
- package/dist/templates.js.map +1 -0
- package/package.json +57 -0
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { initCommand } from './commands/init.js';
|
|
4
|
+
import { devCommand, devDownCommand } from './commands/dev.js';
|
|
5
|
+
import { registryStartCommand } from './commands/registry.js';
|
|
6
|
+
import { statusCommand } from './commands/status.js';
|
|
7
|
+
import { chatCommand } from './commands/chat.js';
|
|
8
|
+
import { channelStartCommand } from './commands/channel.js';
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name('microagents')
|
|
12
|
+
.description('CLI for scaffolding and managing micro-agent systems')
|
|
13
|
+
.version('0.1.0');
|
|
14
|
+
// microagents init
|
|
15
|
+
program
|
|
16
|
+
.command('init')
|
|
17
|
+
.description('Scaffold a new micro-agent project')
|
|
18
|
+
.action(async () => {
|
|
19
|
+
await initCommand();
|
|
20
|
+
});
|
|
21
|
+
// microagents dev [--detach] [--down]
|
|
22
|
+
const dev = program
|
|
23
|
+
.command('dev')
|
|
24
|
+
.description('Manage Docker Compose infrastructure');
|
|
25
|
+
dev
|
|
26
|
+
.command('up')
|
|
27
|
+
.description('Start Docker Compose services')
|
|
28
|
+
.option('-d, --detach', 'Run containers in background')
|
|
29
|
+
.action(async (opts) => {
|
|
30
|
+
await devCommand({ detach: opts.detach });
|
|
31
|
+
});
|
|
32
|
+
dev
|
|
33
|
+
.command('down')
|
|
34
|
+
.description('Stop Docker Compose services')
|
|
35
|
+
.action(async () => {
|
|
36
|
+
await devDownCommand();
|
|
37
|
+
});
|
|
38
|
+
// microagents registry start
|
|
39
|
+
const registry = program
|
|
40
|
+
.command('registry')
|
|
41
|
+
.description('Manage the agent registry');
|
|
42
|
+
registry
|
|
43
|
+
.command('start')
|
|
44
|
+
.description('Start the registry server')
|
|
45
|
+
.option('-p, --port <port>', 'Port to listen on', '4000')
|
|
46
|
+
.option('-H, --host <host>', 'Host to bind to', '0.0.0.0')
|
|
47
|
+
.action(async (opts) => {
|
|
48
|
+
await registryStartCommand({ port: opts.port, host: opts.host });
|
|
49
|
+
});
|
|
50
|
+
// microagents status
|
|
51
|
+
program
|
|
52
|
+
.command('status')
|
|
53
|
+
.description('Show registered agents and their health')
|
|
54
|
+
.option('-r, --registry-url <url>', 'Registry URL')
|
|
55
|
+
.option('-d, --domain <domain>', 'Filter by domain')
|
|
56
|
+
.action(async (opts) => {
|
|
57
|
+
await statusCommand(opts);
|
|
58
|
+
});
|
|
59
|
+
// microagents chat
|
|
60
|
+
program
|
|
61
|
+
.command('chat')
|
|
62
|
+
.description('Launch terminal chat interface (AG-UI)')
|
|
63
|
+
.option('-u, --agent-url <url>', 'Direct agent URL (skip registry lookup)')
|
|
64
|
+
.option('-n, --agent-name <name>', 'Agent display name')
|
|
65
|
+
.option('-r, --registry-url <url>', 'Registry URL for agent discovery')
|
|
66
|
+
.option('-s, --secret <secret>', 'Shared secret')
|
|
67
|
+
.option('--session <id>', 'Existing session ID')
|
|
68
|
+
.action(async (opts) => {
|
|
69
|
+
await chatCommand({
|
|
70
|
+
agentUrl: opts.agentUrl,
|
|
71
|
+
agentName: opts.agentName,
|
|
72
|
+
registryUrl: opts.registryUrl,
|
|
73
|
+
secret: opts.secret,
|
|
74
|
+
sessionId: opts.session,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
// microagents channel start <type>
|
|
78
|
+
const channel = program
|
|
79
|
+
.command('channel')
|
|
80
|
+
.description('Manage channel integrations');
|
|
81
|
+
channel
|
|
82
|
+
.command('start <type>')
|
|
83
|
+
.description('Start a channel adapter (slack, telegram, webhook)')
|
|
84
|
+
.option('-a, --agent-url <url>', 'Agent URL to forward messages to')
|
|
85
|
+
.option('-p, --port <port>', 'Port for webhook channel')
|
|
86
|
+
.action(async (type, opts) => {
|
|
87
|
+
await channelStartCommand(type, opts);
|
|
88
|
+
});
|
|
89
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
90
|
+
console.error(err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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@@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { SlackChannel, TelegramChannel, WebhookChannel, } from '@mce-bt/microagents-channels';
|
|
3
|
+
/**
|
|
4
|
+
* `microagents channel start <type>` — Start a channel adapter.
|
|
5
|
+
*/
|
|
6
|
+
export async function channelStartCommand(channelType, options) {
|
|
7
|
+
const agentUrl = options.agentUrl ?? process.env.AGENT_URL ?? 'http://localhost:3000';
|
|
8
|
+
const sharedSecret = process.env.SHARED_SECRET;
|
|
9
|
+
console.log(chalk.bold(`\n📡 Starting ${channelType} channel\n`));
|
|
10
|
+
console.log(` Agent URL: ${chalk.cyan(agentUrl)}\n`);
|
|
11
|
+
switch (channelType) {
|
|
12
|
+
case 'slack': {
|
|
13
|
+
const botToken = process.env.SLACK_BOT_TOKEN;
|
|
14
|
+
const appToken = process.env.SLACK_APP_TOKEN;
|
|
15
|
+
const signingSecret = process.env.SLACK_SIGNING_SECRET;
|
|
16
|
+
if (!botToken || !appToken || !signingSecret) {
|
|
17
|
+
console.log(chalk.red(' ✗ Missing Slack environment variables:\n'));
|
|
18
|
+
if (!botToken)
|
|
19
|
+
console.log(chalk.dim(' SLACK_BOT_TOKEN'));
|
|
20
|
+
if (!appToken)
|
|
21
|
+
console.log(chalk.dim(' SLACK_APP_TOKEN'));
|
|
22
|
+
if (!signingSecret)
|
|
23
|
+
console.log(chalk.dim(' SLACK_SIGNING_SECRET'));
|
|
24
|
+
console.log('');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const config = {
|
|
28
|
+
agentUrl,
|
|
29
|
+
sharedSecret,
|
|
30
|
+
botToken,
|
|
31
|
+
appToken,
|
|
32
|
+
signingSecret,
|
|
33
|
+
};
|
|
34
|
+
const channel = new SlackChannel(config);
|
|
35
|
+
await channel.start();
|
|
36
|
+
console.log(chalk.green(' ✓ Slack channel connected (Socket Mode)\n'));
|
|
37
|
+
registerShutdown(() => channel.stop());
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'telegram': {
|
|
41
|
+
const botToken = process.env.TELEGRAM_BOT_TOKEN;
|
|
42
|
+
if (!botToken) {
|
|
43
|
+
console.log(chalk.red(' ✗ Missing TELEGRAM_BOT_TOKEN environment variable\n'));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const allowedChatIds = process.env.TELEGRAM_ALLOWED_CHAT_IDS
|
|
47
|
+
?.split(',')
|
|
48
|
+
.map(Number)
|
|
49
|
+
.filter(n => !isNaN(n));
|
|
50
|
+
const config = {
|
|
51
|
+
agentUrl,
|
|
52
|
+
sharedSecret,
|
|
53
|
+
botToken,
|
|
54
|
+
allowedChatIds,
|
|
55
|
+
};
|
|
56
|
+
const channel = new TelegramChannel(config);
|
|
57
|
+
await channel.start();
|
|
58
|
+
console.log(chalk.green(' ✓ Telegram channel connected (long polling)\n'));
|
|
59
|
+
registerShutdown(() => channel.stop());
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case 'webhook': {
|
|
63
|
+
const port = parseInt(options.port ?? process.env.WEBHOOK_PORT ?? '8080', 10);
|
|
64
|
+
const webhookSecret = process.env.WEBHOOK_SECRET;
|
|
65
|
+
const path = process.env.WEBHOOK_PATH ?? '/webhook';
|
|
66
|
+
const config = {
|
|
67
|
+
agentUrl,
|
|
68
|
+
sharedSecret,
|
|
69
|
+
port,
|
|
70
|
+
webhookSecret,
|
|
71
|
+
path,
|
|
72
|
+
};
|
|
73
|
+
const channel = new WebhookChannel(config);
|
|
74
|
+
await channel.start();
|
|
75
|
+
console.log(chalk.green(` ✓ Webhook channel listening on port ${port}\n`));
|
|
76
|
+
console.log(` Endpoint: ${chalk.cyan(`http://0.0.0.0:${port}${path}`)}`);
|
|
77
|
+
console.log(`\n ${chalk.dim('POST { "message": "hello", "threadId"?: "..." }')}\n`);
|
|
78
|
+
registerShutdown(() => channel.stop());
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
default:
|
|
82
|
+
console.log(chalk.red(` ✗ Unknown channel type: ${channelType}`));
|
|
83
|
+
console.log(chalk.dim('\n Available: slack, telegram, webhook\n'));
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function registerShutdown(cleanup) {
|
|
88
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
89
|
+
process.on(signal, async () => {
|
|
90
|
+
console.log(chalk.dim('\nShutting down channel...'));
|
|
91
|
+
await cleanup();
|
|
92
|
+
process.exit(0);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,eAAe,EACf,cAAc,GAIf,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,OAGC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,uBAAuB,CAAC;IACtF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAE/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,WAAW,YAAY,CAAC,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEtD,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;YAC7C,MAAM,aAAa,G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CAAC,CAAC;YAC5E,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,iDAAiD,CAAC,IAAI,CAAC,CAAC;YACrF,gBAAgB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACvC,MAAM;QACR,CAAC;QAED;YACE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,6BAA6B,WAAW,EAAE,CAAC,CAAC,CAAC;YACnE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC,CAAC;YACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA4B;IACpD,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU,EAAE,CAAC;QACpD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;YACrD,MAAM,OAAO,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `microagents chat` — Launch the terminal chat interface.
|
|
3
|
+
*/
|
|
4
|
+
export declare function chatCommand(options: {
|
|
5
|
+
agentUrl?: string;
|
|
6
|
+
agentName?: string;
|
|
7
|
+
registryUrl?: string;
|
|
8
|
+
secret?: string;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/commands/chat.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAahB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from 'ink';
|
|
3
|
+
import { App } from '@mce-bt/microagents-tui';
|
|
4
|
+
/**
|
|
5
|
+
* `microagents chat` — Launch the terminal chat interface.
|
|
6
|
+
*/
|
|
7
|
+
export async function chatCommand(options) {
|
|
8
|
+
const registryUrl = options.registryUrl ?? process.env.REGISTRY_URL ?? 'http://localhost:4000';
|
|
9
|
+
const sharedSecret = options.secret ?? process.env.SHARED_SECRET;
|
|
10
|
+
render(React.createElement(App, {
|
|
11
|
+
agentUrl: options.agentUrl,
|
|
12
|
+
agentName: options.agentName,
|
|
13
|
+
registryUrl,
|
|
14
|
+
sharedSecret,
|
|
15
|
+
sessionId: options.sessionId,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/commands/chat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAMjC;IACC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,CAAC;IAC/F,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAEjE,MAAM,CACJ,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE;QACvB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW;QACX,YAAY;QACZ,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `microagents dev` — Start local Docker Compose infrastructure.
|
|
3
|
+
*
|
|
4
|
+
* Looks for docker-compose.yml in the current directory or the monorepo root.
|
|
5
|
+
* Starts Redis, RabbitMQ, and PostgreSQL containers.
|
|
6
|
+
*/
|
|
7
|
+
export declare function devCommand(options: {
|
|
8
|
+
detach?: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
export declare function devDownCommand(): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2D7E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAoBpD"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { execSync, spawn } from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
/**
|
|
6
|
+
* `microagents dev` — Start local Docker Compose infrastructure.
|
|
7
|
+
*
|
|
8
|
+
* Looks for docker-compose.yml in the current directory or the monorepo root.
|
|
9
|
+
* Starts Redis, RabbitMQ, and PostgreSQL containers.
|
|
10
|
+
*/
|
|
11
|
+
export async function devCommand(options) {
|
|
12
|
+
const composePath = await findComposeFile();
|
|
13
|
+
if (!composePath) {
|
|
14
|
+
console.log(chalk.red('\n✗ No docker-compose.yml found.\n'));
|
|
15
|
+
console.log(' Create one with the standard infrastructure services:');
|
|
16
|
+
console.log(` ${chalk.cyan('microagents init')} ${chalk.dim('— to scaffold a new project')}\n`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
console.log(chalk.bold('\n🐳 Starting infrastructure...\n'));
|
|
20
|
+
console.log(` Compose file: ${chalk.dim(composePath)}\n`);
|
|
21
|
+
// Check Docker is available
|
|
22
|
+
try {
|
|
23
|
+
execSync('docker info', { stdio: 'ignore' });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
console.log(chalk.red('✗ Docker is not running. Please start Docker and try again.\n'));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
const args = [
|
|
30
|
+
'compose',
|
|
31
|
+
'-f', composePath,
|
|
32
|
+
'up',
|
|
33
|
+
];
|
|
34
|
+
if (options.detach) {
|
|
35
|
+
args.push('-d');
|
|
36
|
+
}
|
|
37
|
+
const proc = spawn('docker', args, {
|
|
38
|
+
stdio: 'inherit',
|
|
39
|
+
cwd: path.dirname(composePath),
|
|
40
|
+
});
|
|
41
|
+
if (options.detach) {
|
|
42
|
+
proc.on('close', (code) => {
|
|
43
|
+
if (code === 0) {
|
|
44
|
+
console.log(chalk.green('\n✓ Infrastructure running in background.\n'));
|
|
45
|
+
console.log(' Services:');
|
|
46
|
+
console.log(` ${chalk.dim('•')} Redis ${chalk.cyan('localhost:6379')}`);
|
|
47
|
+
console.log(` ${chalk.dim('•')} RabbitMQ ${chalk.cyan('localhost:5672')} ${chalk.dim('(mgmt: 15672)')}`);
|
|
48
|
+
console.log(` ${chalk.dim('•')} PostgreSQL ${chalk.cyan('localhost:5432')}`);
|
|
49
|
+
console.log(`\n Stop with: ${chalk.cyan('microagents dev --down')}\n`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
process.exit(code ?? 1);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
proc.on('close', (code) => {
|
|
58
|
+
process.exit(code ?? 0);
|
|
59
|
+
});
|
|
60
|
+
// Forward signals for graceful shutdown
|
|
61
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
62
|
+
process.on(signal, () => proc.kill(signal));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function devDownCommand() {
|
|
67
|
+
const composePath = await findComposeFile();
|
|
68
|
+
if (!composePath) {
|
|
69
|
+
console.log(chalk.red('\n✗ No docker-compose.yml found.\n'));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
console.log(chalk.bold('\n🛑 Stopping infrastructure...\n'));
|
|
73
|
+
const proc = spawn('docker', ['compose', '-f', composePath, 'down'], {
|
|
74
|
+
stdio: 'inherit',
|
|
75
|
+
cwd: path.dirname(composePath),
|
|
76
|
+
});
|
|
77
|
+
proc.on('close', (code) => {
|
|
78
|
+
if (code === 0) {
|
|
79
|
+
console.log(chalk.green('\n✓ Infrastructure stopped.\n'));
|
|
80
|
+
}
|
|
81
|
+
process.exit(code ?? 0);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async function findComposeFile() {
|
|
85
|
+
// Check current directory first, then parent directories up to 5 levels
|
|
86
|
+
let dir = process.cwd();
|
|
87
|
+
for (let i = 0; i < 5; i++) {
|
|
88
|
+
const candidate = path.join(dir, 'docker-compose.yml');
|
|
89
|
+
try {
|
|
90
|
+
await fs.access(candidate);
|
|
91
|
+
return candidate;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Try parent
|
|
95
|
+
const parent = path.dirname(dir);
|
|
96
|
+
if (parent === dir)
|
|
97
|
+
break;
|
|
98
|
+
dir = parent;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAA6B;IAC5D,MAAM,WAAW,GAAG,MAAM,eAAe,EAAE,CAAC;IAE5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;QACjG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE3D,4BAA4B;IAC5B,IAAI,CAAC;QACH,QAAQ,CAAC,aAAa,EAAE,EAAE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H,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,eAAe;IAC5B,wEAAwE;IACxE,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;QACvD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,aAAa;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,MAAM,KAAK,GAAG;gBAAE,MAAM;YAC1B,GAAG,GAAG,MAAM,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAoCA,wBAAsB,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmFnE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { input, select } from '@inquirer/prompts';
|
|
5
|
+
import { agentYaml, agentMd, soulMd, skillsMd, toolsMd, ecosystemMd, indexTs, packageJson, tsConfigJson, dockerfile, envFile, gitignore, processRouteTs, healthRouteTs, exampleToolTs, } from '../templates.js';
|
|
6
|
+
function toClassName(id) {
|
|
7
|
+
return id
|
|
8
|
+
.split(/[-_.]/)
|
|
9
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
10
|
+
.join('') + 'Agent';
|
|
11
|
+
}
|
|
12
|
+
function toId(name) {
|
|
13
|
+
return name
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
16
|
+
.replace(/(^-|-$)/g, '');
|
|
17
|
+
}
|
|
18
|
+
export async function initCommand(targetDir) {
|
|
19
|
+
console.log(chalk.bold('\n🏗 Create a new MicroAgent\n'));
|
|
20
|
+
const name = await input({
|
|
21
|
+
message: 'Agent name:',
|
|
22
|
+
default: 'my-agent',
|
|
23
|
+
validate: (v) => (v.trim().length > 0 ? true : 'Name is required'),
|
|
24
|
+
});
|
|
25
|
+
const domain = await input({
|
|
26
|
+
message: 'Domain (e.g., coding, docs, devops):',
|
|
27
|
+
default: 'general',
|
|
28
|
+
});
|
|
29
|
+
const port = await input({
|
|
30
|
+
message: 'HTTP port:',
|
|
31
|
+
default: '3001',
|
|
32
|
+
validate: (v) => {
|
|
33
|
+
const n = parseInt(v, 10);
|
|
34
|
+
return !isNaN(n) && n > 0 && n < 65536 ? true : 'Must be a valid port number';
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const id = toId(name);
|
|
38
|
+
const className = toClassName(id);
|
|
39
|
+
const dir = path.resolve(targetDir ?? id);
|
|
40
|
+
// Check if directory exists
|
|
41
|
+
try {
|
|
42
|
+
await fs.access(dir);
|
|
43
|
+
console.log(chalk.red(`\n✗ Directory "${dir}" already exists. Choose a different name or location.\n`));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Expected — directory doesn't exist
|
|
48
|
+
}
|
|
49
|
+
console.log(chalk.dim(`\nScaffolding ${chalk.cyan(name)} in ${dir}...\n`));
|
|
50
|
+
// Create directory structure
|
|
51
|
+
await fs.mkdir(path.join(dir, 'config'), { recursive: true });
|
|
52
|
+
await fs.mkdir(path.join(dir, 'src', 'routes'), { recursive: true });
|
|
53
|
+
await fs.mkdir(path.join(dir, 'src', 'events'), { recursive: true });
|
|
54
|
+
await fs.mkdir(path.join(dir, 'src', 'tasks'), { recursive: true });
|
|
55
|
+
await fs.mkdir(path.join(dir, 'src', 'tools'), { recursive: true });
|
|
56
|
+
await fs.mkdir(path.join(dir, 'src', 'skills', 'public'), { recursive: true });
|
|
57
|
+
await fs.mkdir(path.join(dir, 'src', 'skills', 'internal'), { recursive: true });
|
|
58
|
+
// Write files
|
|
59
|
+
const files = [
|
|
60
|
+
['agent.yaml', agentYaml({ id, name, domain, port: parseInt(port, 10) })],
|
|
61
|
+
['config/AGENT.md', agentMd({ name, domain })],
|
|
62
|
+
['config/SOUL.md', soulMd({ name })],
|
|
63
|
+
['config/SKILLS.md', skillsMd()],
|
|
64
|
+
['config/TOOLS.md', toolsMd()],
|
|
65
|
+
['config/ECOSYSTEM.md', ecosystemMd()],
|
|
66
|
+
['src/index.ts', indexTs({ id, name, className })],
|
|
67
|
+
['src/routes/process.ts', processRouteTs({ className })],
|
|
68
|
+
['src/routes/health.ts', healthRouteTs()],
|
|
69
|
+
['src/tools/hello.ts', exampleToolTs()],
|
|
70
|
+
['package.json', packageJson({ id, name })],
|
|
71
|
+
['tsconfig.json', tsConfigJson()],
|
|
72
|
+
['Dockerfile', dockerfile({ id })],
|
|
73
|
+
['.env', envFile()],
|
|
74
|
+
['.gitignore', gitignore()],
|
|
75
|
+
];
|
|
76
|
+
for (const [filePath, content] of files) {
|
|
77
|
+
const fullPath = path.join(dir, filePath);
|
|
78
|
+
await fs.writeFile(fullPath, content, 'utf-8');
|
|
79
|
+
}
|
|
80
|
+
console.log(chalk.green('✓ Project created!\n'));
|
|
81
|
+
console.log(' Files:');
|
|
82
|
+
for (const [filePath] of files) {
|
|
83
|
+
console.log(` ${chalk.dim('•')} ${filePath}`);
|
|
84
|
+
}
|
|
85
|
+
console.log(`\n Next steps:\n`);
|
|
86
|
+
console.log(` ${chalk.cyan('cd')} ${id}`);
|
|
87
|
+
console.log(` ${chalk.cyan('npm install')}`);
|
|
88
|
+
console.log(` ${chalk.cyan('microagents dev')} ${chalk.dim('# Start infrastructure')}`);
|
|
89
|
+
console.log(` ${chalk.cyan('npm run dev')} ${chalk.dim('# Start the agent')}`);
|
|
90
|
+
console.log('');
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,EACZ,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,SAAS,WAAW,CAAC,EAAU;IAC7B,OAAO,EAAE;SACN,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAClD,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,SAAS,IAAI,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AAGA;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CA+ChB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { RegistryServer } from '@mce-bt/microagents-registry';
|
|
3
|
+
/**
|
|
4
|
+
* `microagents registry start` — Start the registry service.
|
|
5
|
+
*/
|
|
6
|
+
export async function registryStartCommand(options) {
|
|
7
|
+
const port = parseInt(options.port ?? process.env.REGISTRY_PORT ?? '4000', 10);
|
|
8
|
+
const host = options.host ?? process.env.REGISTRY_HOST ?? '0.0.0.0';
|
|
9
|
+
const sharedSecret = process.env.SHARED_SECRET ?? 'dev-secret-change-me';
|
|
10
|
+
const databaseUrl = process.env.DATABASE_URL ?? 'postgresql://microagents:microagents@localhost:5432/microagents';
|
|
11
|
+
console.log(chalk.bold('\n📋 Starting Registry Service\n'));
|
|
12
|
+
console.log(` Port: ${chalk.cyan(String(port))}`);
|
|
13
|
+
console.log(` Host: ${chalk.cyan(host)}`);
|
|
14
|
+
console.log(` Database: ${chalk.dim(databaseUrl.replace(/\/\/[^:]+:[^@]+@/, '//***:***@'))}`);
|
|
15
|
+
console.log('');
|
|
16
|
+
const config = {
|
|
17
|
+
port,
|
|
18
|
+
host,
|
|
19
|
+
sharedSecret,
|
|
20
|
+
store: { connectionString: databaseUrl },
|
|
21
|
+
};
|
|
22
|
+
const server = new RegistryServer(config);
|
|
23
|
+
try {
|
|
24
|
+
await server.start();
|
|
25
|
+
console.log(chalk.green(`✓ Registry running at ${chalk.cyan(`http://${host}:${port}`)}\n`));
|
|
26
|
+
console.log(' Endpoints:');
|
|
27
|
+
console.log(` ${chalk.dim('POST')} /api/agents ${chalk.dim('Register agent')}`);
|
|
28
|
+
console.log(` ${chalk.dim('GET')} /api/agents ${chalk.dim('List agents')}`);
|
|
29
|
+
console.log(` ${chalk.dim('GET')} /api/agents/:id ${chalk.dim('Get agent')}`);
|
|
30
|
+
console.log(` ${chalk.dim('DELETE')} /api/agents/:id ${chalk.dim('Deregister agent')}`);
|
|
31
|
+
console.log(` ${chalk.dim('POST')} /api/agents/:id/heartbeat`);
|
|
32
|
+
console.log(` ${chalk.dim('GET')} /health`);
|
|
33
|
+
console.log('');
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.log(chalk.red(`\n✗ Failed to start registry: ${err instanceof Error ? err.message : err}\n`));
|
|
37
|
+
console.log(' Make sure PostgreSQL is running:');
|
|
38
|
+
console.log(` ${chalk.cyan('microagents dev -d')}\n`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
// Graceful shutdown
|
|
42
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
43
|
+
process.on(signal, async () => {
|
|
44
|
+
console.log(chalk.dim('\nShutting down registry...'));
|
|
45
|
+
await server.stop();
|
|
46
|
+
process.exit(0);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/commands/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAA6B,MAAM,8BAA8B,CAAC;AAEzF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAG1C;IACC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,SAAS,CAAC;IACpE,MAAM,YAAY,GAAG,OAAO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AAC,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkFhB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
/**
|
|
3
|
+
* `microagents status` — Show registered agents and their health.
|
|
4
|
+
*/
|
|
5
|
+
export async function statusCommand(options) {
|
|
6
|
+
const registryUrl = options.registryUrl ?? process.env.REGISTRY_URL ?? 'http://localhost:4000';
|
|
7
|
+
const sharedSecret = process.env.SHARED_SECRET ?? 'dev-secret-change-me';
|
|
8
|
+
console.log(chalk.bold('\n📡 Agent Status\n'));
|
|
9
|
+
console.log(` Registry: ${chalk.dim(registryUrl)}\n`);
|
|
10
|
+
// Check registry health
|
|
11
|
+
try {
|
|
12
|
+
const healthRes = await fetch(`${registryUrl}/health`, { signal: AbortSignal.timeout(3000) });
|
|
13
|
+
if (!healthRes.ok)
|
|
14
|
+
throw new Error(`HTTP ${healthRes.status}`);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.log(chalk.red(' ✗ Registry is not reachable.\n'));
|
|
18
|
+
console.log(` Start it with: ${chalk.cyan('microagents registry start')}\n`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
// Fetch agents
|
|
22
|
+
try {
|
|
23
|
+
const url = options.domain
|
|
24
|
+
? `${registryUrl}/api/agents?domain=${encodeURIComponent(options.domain)}`
|
|
25
|
+
: `${registryUrl}/api/agents`;
|
|
26
|
+
const res = await fetch(url, {
|
|
27
|
+
headers: { 'X-Shared-Secret': sharedSecret },
|
|
28
|
+
signal: AbortSignal.timeout(5000),
|
|
29
|
+
});
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
console.log(chalk.red(` ✗ Failed to fetch agents: HTTP ${res.status}\n`));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const agents = (await res.json());
|
|
35
|
+
if (agents.length === 0) {
|
|
36
|
+
console.log(chalk.dim(' No agents registered.\n'));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Table header
|
|
40
|
+
const colId = 20;
|
|
41
|
+
const colDomain = 12;
|
|
42
|
+
const colVersion = 10;
|
|
43
|
+
const colStatus = 10;
|
|
44
|
+
const colUrl = 28;
|
|
45
|
+
console.log(chalk.dim(` ${'ID'.padEnd(colId)} ${'DOMAIN'.padEnd(colDomain)} ${'VERSION'.padEnd(colVersion)} ${'STATUS'.padEnd(colStatus)} ${'URL'.padEnd(colUrl)}`));
|
|
46
|
+
console.log(chalk.dim(` ${'─'.repeat(colId + colDomain + colVersion + colStatus + colUrl + 4)}`));
|
|
47
|
+
for (const agent of agents) {
|
|
48
|
+
const statusColor = agent.status === 'online'
|
|
49
|
+
? chalk.green
|
|
50
|
+
: agent.status === 'unhealthy'
|
|
51
|
+
? chalk.yellow
|
|
52
|
+
: chalk.red;
|
|
53
|
+
console.log(` ${agent.id.padEnd(colId)} ${agent.domain.padEnd(colDomain)} ${agent.version.padEnd(colVersion)} ${statusColor(agent.status.padEnd(colStatus))} ${chalk.dim(agent.baseUrl)}`);
|
|
54
|
+
}
|
|
55
|
+
console.log(`\n ${chalk.dim(`${agents.length} agent${agents.length !== 1 ? 's' : ''} registered`)}\n`);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.log(chalk.red(` ✗ Error: ${err instanceof Error ? err.message : err}\n`));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61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,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { initCommand } from './commands/init.js';
|
|
2
|
+
export { devCommand, devDownCommand } from './commands/dev.js';
|
|
3
|
+
export { registryStartCommand } from './commands/registry.js';
|
|
4
|
+
export { statusCommand } from './commands/status.js';
|
|
5
|
+
export { chatCommand } from './commands/chat.js';
|
|
6
|
+
export { channelStartCommand } from './commands/channel.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { initCommand } from './commands/init.js';
|
|
2
|
+
export { devCommand, devDownCommand } from './commands/dev.js';
|
|
3
|
+
export { registryStartCommand } from './commands/registry.js';
|
|
4
|
+
export { statusCommand } from './commands/status.js';
|
|
5
|
+
export { chatCommand } from './commands/chat.js';
|
|
6
|
+
export { channelStartCommand } from './commands/channel.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates for agent project scaffolding.
|
|
3
|
+
*/
|
|
4
|
+
export declare function agentYaml(opts: {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
domain: string;
|
|
8
|
+
port: number;
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function agentMd(opts: {
|
|
11
|
+
name: string;
|
|
12
|
+
domain: string;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function soulMd(opts: {
|
|
15
|
+
name: string;
|
|
16
|
+
}): string;
|
|
17
|
+
export declare function skillsMd(): string;
|
|
18
|
+
export declare function toolsMd(): string;
|
|
19
|
+
export declare function ecosystemMd(): string;
|
|
20
|
+
export declare function indexTs(opts: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
className: string;
|
|
24
|
+
}): string;
|
|
25
|
+
export declare function packageJson(opts: {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}): string;
|
|
29
|
+
export declare function tsConfigJson(): string;
|
|
30
|
+
export declare function dockerfile(opts: {
|
|
31
|
+
id: string;
|
|
32
|
+
}): string;
|
|
33
|
+
export declare function envFile(): string;
|
|
34
|
+
export declare function gitignore(): string;
|
|
35
|
+
export declare function processRouteTs(opts: {
|
|
36
|
+
className: string;
|
|
37
|
+
}): string;
|
|
38
|
+
export declare function healthRouteTs(): string;
|
|
39
|
+
export declare function exampleToolTs(): string;
|
|
40
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sour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
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates for agent project scaffolding.
|
|
3
|
+
*/
|
|
4
|
+
export function agentYaml(opts) {
|
|
5
|
+
return `id: "${opts.id}"
|
|
6
|
+
name: "${opts.name}"
|
|
7
|
+
domain: "${opts.domain}"
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
description: "A ${opts.domain} agent"
|
|
10
|
+
|
|
11
|
+
completion:
|
|
12
|
+
default:
|
|
13
|
+
provider: openai
|
|
14
|
+
model: gpt-4o-mini
|
|
15
|
+
maxTokens: 2048
|
|
16
|
+
|
|
17
|
+
http:
|
|
18
|
+
port: ${opts.port}
|
|
19
|
+
host: "0.0.0.0"
|
|
20
|
+
|
|
21
|
+
rabbitmq:
|
|
22
|
+
url: \${RABBITMQ_URL:-amqp://microagents:microagents@localhost:5672}
|
|
23
|
+
|
|
24
|
+
redis:
|
|
25
|
+
url: \${REDIS_URL:-redis://localhost:6379}
|
|
26
|
+
|
|
27
|
+
postgres:
|
|
28
|
+
connectionString: \${DATABASE_URL:-postgresql://microagents:microagents@localhost:5432/microagents}
|
|
29
|
+
|
|
30
|
+
registry:
|
|
31
|
+
url: \${REGISTRY_URL:-http://localhost:4000}
|
|
32
|
+
heartbeatIntervalMs: 15000
|
|
33
|
+
|
|
34
|
+
sharedSecret: \${SHARED_SECRET:-dev-secret-change-me}
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
export function agentMd(opts) {
|
|
38
|
+
return `---
|
|
39
|
+
name: ${opts.name}
|
|
40
|
+
domain: ${opts.domain}
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# ${opts.name}
|
|
44
|
+
|
|
45
|
+
You are ${opts.name}, an agent in the ${opts.domain} domain.
|
|
46
|
+
|
|
47
|
+
## Behavior
|
|
48
|
+
|
|
49
|
+
- Respond helpfully and concisely
|
|
50
|
+
- Use available tools when appropriate
|
|
51
|
+
- Follow ecosystem rules
|
|
52
|
+
|
|
53
|
+
## Rules
|
|
54
|
+
|
|
55
|
+
- Be accurate and transparent
|
|
56
|
+
- Ask for clarification when the request is ambiguous
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
export function soulMd(opts) {
|
|
60
|
+
return `---
|
|
61
|
+
name: ${opts.name}
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# Soul
|
|
65
|
+
|
|
66
|
+
## Identity
|
|
67
|
+
|
|
68
|
+
You are ${opts.name}. You are a helpful, reliable, and efficient AI agent.
|
|
69
|
+
|
|
70
|
+
## Communication Style
|
|
71
|
+
|
|
72
|
+
- Be clear and direct
|
|
73
|
+
- Use professional language
|
|
74
|
+
- Adapt tone to context
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
export function skillsMd() {
|
|
78
|
+
return `---
|
|
79
|
+
name: Skills
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
# Skills
|
|
83
|
+
|
|
84
|
+
<!-- Define your agent's skills here -->
|
|
85
|
+
<!-- Skills can be "agentic" (LLM decides flow) or "deterministic" (code-driven) -->
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
export function toolsMd() {
|
|
89
|
+
return `---
|
|
90
|
+
name: Tools
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# Tools
|
|
94
|
+
|
|
95
|
+
<!-- Document your agent's available tools here -->
|
|
96
|
+
<!-- Tools are functions with Zod-validated inputs callable by the LLM -->
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
export function ecosystemMd() {
|
|
100
|
+
return `---
|
|
101
|
+
name: Ecosystem Rules
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
# Ecosystem Rules
|
|
105
|
+
|
|
106
|
+
## Communication Protocol
|
|
107
|
+
|
|
108
|
+
- Use HTTP for synchronous inter-agent calls
|
|
109
|
+
- Use RabbitMQ events for fire-and-forget notifications
|
|
110
|
+
- Use RabbitMQ tasks for async work that needs guaranteed delivery
|
|
111
|
+
|
|
112
|
+
## Session Management
|
|
113
|
+
|
|
114
|
+
- Always propagate session IDs across agent boundaries
|
|
115
|
+
- Log all actions under the originating session ID
|
|
116
|
+
|
|
117
|
+
## Security
|
|
118
|
+
|
|
119
|
+
- All inter-agent HTTP calls must use shared-secret authentication
|
|
120
|
+
- Never expose internal tools via public API without explicit configuration
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
export function indexTs(opts) {
|
|
124
|
+
return `import { createAgent, Agent } from '@mce-bt/microagents-core';
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* ${opts.name}
|
|
128
|
+
*
|
|
129
|
+
* Handlers and tools are auto-discovered from convention directories:
|
|
130
|
+
* src/routes/ → HTTP route handlers
|
|
131
|
+
* src/events/ → RabbitMQ event handlers
|
|
132
|
+
* src/tasks/ → RabbitMQ task handlers
|
|
133
|
+
* src/tools/ → LLM-callable tools
|
|
134
|
+
*
|
|
135
|
+
* Override onInit() only for custom setup beyond auto-discovery.
|
|
136
|
+
*/
|
|
137
|
+
export class ${opts.className} extends Agent {}
|
|
138
|
+
|
|
139
|
+
// ─── Bootstrap ───
|
|
140
|
+
|
|
141
|
+
createAgent(${opts.className}).catch((err) => {
|
|
142
|
+
console.error('Failed to start agent:', err);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
});
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
export function packageJson(opts) {
|
|
148
|
+
return JSON.stringify({
|
|
149
|
+
name: opts.id,
|
|
150
|
+
version: '0.1.0',
|
|
151
|
+
private: true,
|
|
152
|
+
type: 'module',
|
|
153
|
+
scripts: {
|
|
154
|
+
dev: 'tsx watch src/index.ts',
|
|
155
|
+
start: 'node --import tsx src/index.ts',
|
|
156
|
+
build: 'tsc --build',
|
|
157
|
+
},
|
|
158
|
+
dependencies: {
|
|
159
|
+
'@mce-bt/microagents-core': '*',
|
|
160
|
+
'@mce-bt/microagents-communication': '*',
|
|
161
|
+
'@mce-bt/microagents-memory': '*',
|
|
162
|
+
'@mce-bt/microagents-completion': '*',
|
|
163
|
+
'@mce-bt/microagents-observability': '*',
|
|
164
|
+
'@mce-bt/microagents-registry': '*',
|
|
165
|
+
yaml: '^2.7.0',
|
|
166
|
+
zod: '^3.23.0',
|
|
167
|
+
},
|
|
168
|
+
devDependencies: {
|
|
169
|
+
tsx: '^4.19.0',
|
|
170
|
+
typescript: '^6.0.0',
|
|
171
|
+
},
|
|
172
|
+
}, null, 2);
|
|
173
|
+
}
|
|
174
|
+
export function tsConfigJson() {
|
|
175
|
+
return JSON.stringify({
|
|
176
|
+
compilerOptions: {
|
|
177
|
+
target: 'ES2023',
|
|
178
|
+
module: 'NodeNext',
|
|
179
|
+
moduleResolution: 'NodeNext',
|
|
180
|
+
strict: true,
|
|
181
|
+
outDir: 'dist',
|
|
182
|
+
rootDir: 'src',
|
|
183
|
+
declaration: true,
|
|
184
|
+
declarationMap: true,
|
|
185
|
+
sourceMap: true,
|
|
186
|
+
esModuleInterop: true,
|
|
187
|
+
skipLibCheck: true,
|
|
188
|
+
forceConsistentCasingInFileNames: true,
|
|
189
|
+
},
|
|
190
|
+
include: ['src'],
|
|
191
|
+
}, null, 2);
|
|
192
|
+
}
|
|
193
|
+
export function dockerfile(opts) {
|
|
194
|
+
return `FROM node:22-alpine AS base
|
|
195
|
+
WORKDIR /app
|
|
196
|
+
|
|
197
|
+
FROM base AS deps
|
|
198
|
+
COPY package.json ./
|
|
199
|
+
RUN npm install --production
|
|
200
|
+
|
|
201
|
+
FROM base AS runner
|
|
202
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
203
|
+
COPY . .
|
|
204
|
+
|
|
205
|
+
ENV NODE_ENV=production
|
|
206
|
+
EXPOSE 3000
|
|
207
|
+
|
|
208
|
+
CMD ["node", "--import", "tsx", "src/index.ts"]
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
export function envFile() {
|
|
212
|
+
return `# Shared secret for inter-agent authentication
|
|
213
|
+
SHARED_SECRET=change-me-to-a-random-string
|
|
214
|
+
|
|
215
|
+
# Redis
|
|
216
|
+
REDIS_URL=redis://localhost:6379
|
|
217
|
+
|
|
218
|
+
# RabbitMQ
|
|
219
|
+
RABBITMQ_URL=amqp://microagents:microagents@localhost:5672
|
|
220
|
+
|
|
221
|
+
# PostgreSQL
|
|
222
|
+
DATABASE_URL=postgresql://microagents:microagents@localhost:5432/microagents
|
|
223
|
+
|
|
224
|
+
# Registry
|
|
225
|
+
REGISTRY_URL=http://localhost:4000
|
|
226
|
+
|
|
227
|
+
# LLM Provider
|
|
228
|
+
OPENAI_API_KEY=sk-...
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
export function gitignore() {
|
|
232
|
+
return `node_modules/
|
|
233
|
+
dist/
|
|
234
|
+
.env
|
|
235
|
+
*.log
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
// ─── Convention-based file templates ───
|
|
239
|
+
export function processRouteTs(opts) {
|
|
240
|
+
return `import { z } from 'zod';
|
|
241
|
+
import { defineRoute } from '@mce-bt/microagents-core';
|
|
242
|
+
import type { Agent } from '@mce-bt/microagents-core';
|
|
243
|
+
|
|
244
|
+
const ProcessBodySchema = z.object({
|
|
245
|
+
message: z.string(),
|
|
246
|
+
sessionId: z.string().optional(),
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* POST /process — Main entry point for processing messages.
|
|
251
|
+
* Auto-discovered from src/routes/.
|
|
252
|
+
*/
|
|
253
|
+
export default (agent: Agent) => defineRoute({
|
|
254
|
+
url: '/process',
|
|
255
|
+
method: 'post',
|
|
256
|
+
description: 'Process a message through the agent',
|
|
257
|
+
schema: ProcessBodySchema,
|
|
258
|
+
handler: async (req, reply) => {
|
|
259
|
+
const body = ProcessBodySchema.parse(req.body);
|
|
260
|
+
const sessionId = body.sessionId ?? await agent.createSession();
|
|
261
|
+
|
|
262
|
+
const result = await agent.process({
|
|
263
|
+
sessionId,
|
|
264
|
+
message: body.message,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return reply.send({
|
|
268
|
+
sessionId,
|
|
269
|
+
content: result.content,
|
|
270
|
+
toolCalls: result.toolCalls,
|
|
271
|
+
usage: result.usage,
|
|
272
|
+
totalToolRounds: result.totalToolRounds,
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
`;
|
|
277
|
+
}
|
|
278
|
+
export function healthRouteTs() {
|
|
279
|
+
return `import { defineRoute } from '@mce-bt/microagents-core';
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* GET /health — Health check endpoint.
|
|
283
|
+
* Auto-discovered from src/routes/.
|
|
284
|
+
*/
|
|
285
|
+
export default defineRoute({
|
|
286
|
+
url: '/health',
|
|
287
|
+
method: 'get',
|
|
288
|
+
description: 'Health check',
|
|
289
|
+
handler: async (_req, reply) => reply.send({ status: 'ok' }),
|
|
290
|
+
});
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
export function exampleToolTs() {
|
|
294
|
+
return `import { z } from 'zod';
|
|
295
|
+
import { defineTool } from '@mce-bt/microagents-core';
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Example tool — auto-discovered from src/tools/.
|
|
299
|
+
* Replace with your own domain-specific tools.
|
|
300
|
+
*/
|
|
301
|
+
export default defineTool({
|
|
302
|
+
name: 'hello',
|
|
303
|
+
description: 'Greet someone by name',
|
|
304
|
+
parameters: z.object({
|
|
305
|
+
name: z.string().describe('The name to greet'),
|
|
306
|
+
}),
|
|
307
|
+
visibility: 'public',
|
|
308
|
+
handler: async (params) => {
|
|
309
|
+
const { name } = params as { name: string };
|
|
310
|
+
return \`Hello, \${name}!\`;
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA;;GAEG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C;AACF,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO;;;;;;;;;;;;;;;;;;;CAmBR,CAAC;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mce-bt/microagents-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for scaffolding and managing micro agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"microagents": "dist/bin.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc --build",
|
|
13
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
14
|
+
"test": "vitest run"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@mce-bt/microagents-registry": "^0.1.0",
|
|
18
|
+
"@mce-bt/microagents-channels": "^0.1.0",
|
|
19
|
+
"commander": "^13.1.0",
|
|
20
|
+
"chalk": "^5.4.1",
|
|
21
|
+
"ora": "^8.2.0",
|
|
22
|
+
"inquirer": "^12.6.0",
|
|
23
|
+
"ink": "^5.1.0",
|
|
24
|
+
"react": "^18.3.1",
|
|
25
|
+
"@mce-bt/microagents-tui": "^0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@mce-bt/microagents-core": "^0.1.0",
|
|
29
|
+
"@types/react": "^18.3.20",
|
|
30
|
+
"yaml": "^2.7.0"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/cavillo/microagents.git",
|
|
42
|
+
"directory": "packages/cli"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/cavillo/microagents#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/cavillo/microagents/issues"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20.0.0"
|
|
50
|
+
},
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"import": "./dist/index.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|