@mind2flow/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/README.md +20 -0
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.js +154 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +76 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/crews.d.ts +2 -0
- package/dist/commands/crews.js +117 -0
- package/dist/commands/crews.js.map +1 -0
- package/dist/commands/devices.d.ts +2 -0
- package/dist/commands/devices.js +69 -0
- package/dist/commands/devices.js.map +1 -0
- package/dist/commands/mcp.d.ts +10 -0
- package/dist/commands/mcp.js +57 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/tasks.d.ts +2 -0
- package/dist/commands/tasks.js +117 -0
- package/dist/commands/tasks.js.map +1 -0
- package/dist/commands/tools.d.ts +2 -0
- package/dist/commands/tools.js +120 -0
- package/dist/commands/tools.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +47 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +5 -0
- package/dist/output.js +47 -0
- package/dist/output.js.map +1 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @mind2flow/cli
|
|
2
|
+
|
|
3
|
+
`m2f` — the Mind2Flow command-line interface. Build, manage and run AI agents
|
|
4
|
+
from your terminal.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install -g @mind2flow/cli
|
|
8
|
+
|
|
9
|
+
m2f login
|
|
10
|
+
m2f agents list
|
|
11
|
+
m2f agents run <agentId> --input "Hello!"
|
|
12
|
+
m2f tools push ./tool.py --description "What it does"
|
|
13
|
+
m2f tasks create --agent-id <id> --name daily --cron "0 8 * * *" --message "Go!"
|
|
14
|
+
m2f mcp setup --mcp-key mcp_xxx # wire Mind2Flow into Cursor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Configuration lives in `~/.m2f/config.json`; `M2F_API_KEY` / `M2F_BASE_URL`
|
|
18
|
+
environment variables override it.
|
|
19
|
+
|
|
20
|
+
Full docs: https://github.com/pablocruzpineda/m2f-agents-sdk
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerAgentCommands = registerAgentCommands;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const config_1 = require("../config");
|
|
9
|
+
const output_1 = require("../output");
|
|
10
|
+
function registerAgentCommands(program) {
|
|
11
|
+
const agents = program.command('agents').description('Manage and execute AI agents');
|
|
12
|
+
agents
|
|
13
|
+
.command('list')
|
|
14
|
+
.description('List your agents')
|
|
15
|
+
.option('--json', 'Output raw JSON')
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
try {
|
|
18
|
+
const list = await (0, config_1.getClient)().agents.list();
|
|
19
|
+
if (opts.json)
|
|
20
|
+
return (0, output_1.printJson)(list);
|
|
21
|
+
(0, output_1.printTable)(list.map((a) => ({ id: a.id, name: a.name, type: a.type, model: a.modelProvider ?? '' })), ['id', 'name', 'type', 'model']);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
(0, output_1.fail)(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
agents
|
|
28
|
+
.command('get <agentId>')
|
|
29
|
+
.description('Show one agent')
|
|
30
|
+
.action(async (agentId) => {
|
|
31
|
+
try {
|
|
32
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().agents.get(agentId));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
(0, output_1.fail)(error);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
agents
|
|
39
|
+
.command('create')
|
|
40
|
+
.description('Create an agent')
|
|
41
|
+
.requiredOption('--name <name>', 'Agent name')
|
|
42
|
+
.option('--description <text>', 'Description')
|
|
43
|
+
.option('--system-prompt <text>', 'System prompt (or @file.txt to read from a file)')
|
|
44
|
+
.option('--model-provider <provider>', 'LLM provider (e.g. openai, anthropic)')
|
|
45
|
+
.option('--from <file>', 'Create from a JSON file with the full agent definition')
|
|
46
|
+
.action(async (opts) => {
|
|
47
|
+
try {
|
|
48
|
+
let params = {};
|
|
49
|
+
if (opts.from) {
|
|
50
|
+
params = JSON.parse(fs_1.default.readFileSync(opts.from, 'utf-8'));
|
|
51
|
+
}
|
|
52
|
+
let systemPrompt = opts.systemPrompt;
|
|
53
|
+
if (systemPrompt?.startsWith('@')) {
|
|
54
|
+
systemPrompt = fs_1.default.readFileSync(systemPrompt.slice(1), 'utf-8');
|
|
55
|
+
}
|
|
56
|
+
const agent = await (0, config_1.getClient)().agents.create({
|
|
57
|
+
...params,
|
|
58
|
+
name: opts.name,
|
|
59
|
+
description: opts.description ?? params.description,
|
|
60
|
+
systemPrompt: systemPrompt ?? params.systemPrompt,
|
|
61
|
+
modelProvider: opts.modelProvider ?? params.modelProvider,
|
|
62
|
+
});
|
|
63
|
+
console.log(`Agent created: ${agent.id}`);
|
|
64
|
+
(0, output_1.printJson)(agent);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
(0, output_1.fail)(error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
agents
|
|
71
|
+
.command('delete <agentId>')
|
|
72
|
+
.description('Delete an agent')
|
|
73
|
+
.action(async (agentId) => {
|
|
74
|
+
try {
|
|
75
|
+
await (0, config_1.getClient)().agents.delete(agentId);
|
|
76
|
+
console.log(`Agent ${agentId} deleted.`);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
(0, output_1.fail)(error);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
agents
|
|
83
|
+
.command('run <agentId>')
|
|
84
|
+
.description('Execute an agent and print the result')
|
|
85
|
+
.option('--input <text>', 'Input text for the agent')
|
|
86
|
+
.option('--input-file <file>', 'Read input (JSON or text) from a file')
|
|
87
|
+
.option('--timeout <ms>', 'Max wait in milliseconds (default 120000)')
|
|
88
|
+
.action(async (agentId, opts) => {
|
|
89
|
+
try {
|
|
90
|
+
let input = opts.input;
|
|
91
|
+
if (opts.inputFile) {
|
|
92
|
+
const raw = fs_1.default.readFileSync(opts.inputFile, 'utf-8');
|
|
93
|
+
try {
|
|
94
|
+
input = JSON.parse(raw);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
input = raw;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (input === undefined) {
|
|
101
|
+
console.error('Provide --input <text> or --input-file <file>.');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
const timeout = opts.timeout ? parseInt(opts.timeout, 10) : undefined;
|
|
105
|
+
console.error(`Running agent ${agentId}...`);
|
|
106
|
+
const { executionId, result } = await (0, config_1.getClient)().agents.execute(agentId, { input, timeout });
|
|
107
|
+
console.error(`Execution ${executionId} completed.`);
|
|
108
|
+
(0, output_1.printJson)(result);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
(0, output_1.fail)(error);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
agents
|
|
115
|
+
.command('activities <agentId>')
|
|
116
|
+
.description('Show an agent\'s recent activity')
|
|
117
|
+
.option('--limit <n>', 'Max items (default 20)')
|
|
118
|
+
.action(async (agentId, opts) => {
|
|
119
|
+
try {
|
|
120
|
+
const { activities } = await (0, config_1.getClient)().agents.activities(agentId, {
|
|
121
|
+
limit: opts.limit ? parseInt(opts.limit, 10) : 20,
|
|
122
|
+
});
|
|
123
|
+
(0, output_1.printJson)(activities);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
(0, output_1.fail)(error);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
agents
|
|
130
|
+
.command('assign-device <agentId> <deviceId>')
|
|
131
|
+
.description('Assign a device to an agent')
|
|
132
|
+
.action(async (agentId, deviceId) => {
|
|
133
|
+
try {
|
|
134
|
+
await (0, config_1.getClient)().agents.assignDevice(agentId, deviceId);
|
|
135
|
+
console.log(`Device ${deviceId} assigned to agent ${agentId}.`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
(0, output_1.fail)(error);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
agents
|
|
142
|
+
.command('unassign-device <agentId> <deviceId>')
|
|
143
|
+
.description('Unassign a device from an agent')
|
|
144
|
+
.action(async (agentId, deviceId) => {
|
|
145
|
+
try {
|
|
146
|
+
await (0, config_1.getClient)().agents.unassignDevice(agentId, deviceId);
|
|
147
|
+
console.log(`Device ${deviceId} unassigned from agent ${agentId}.`);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
(0, output_1.fail)(error);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":";;;;;AAKA,sDAsJC;AA1JD,4CAAoB;AACpB,sCAAsC;AACtC,sCAAwD;AAExD,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,8BAA8B,CAAC,CAAC;IAErF,MAAM;SACH,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,kBAAkB,CAAC;SAC/B,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;SACnC,MAAM,CAAC,KAAK,EAAE,IAAw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A,kBAAS,GAAE,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,UAAU,QAAQ,sBAAsB,OAAO,GAAG,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,MAAM;SACH,OAAO,CAAC,sCAAsC,CAAC;SAC/C,WAAW,CAAC,iCAAiC,CAAC;SAC9C,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,QAAgB,EAAE,EAAE;QAClD,IAAI,CAAC;YACH,MAAM,IAAA,kBAAS,GAAE,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC3D,OAAO,CAAC,GAAG,CAAC,UAAU,QAAQ,0BAA0B,OAAO,GAAG,CAAC,CAAC;QACtE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAuthCommands = registerAuthCommands;
|
|
4
|
+
const readline_1 = require("readline");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const output_1 = require("../output");
|
|
7
|
+
function prompt(question) {
|
|
8
|
+
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
9
|
+
return new Promise((resolve) => rl.question(question, (answer) => {
|
|
10
|
+
rl.close();
|
|
11
|
+
resolve(answer.trim());
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function registerAuthCommands(program) {
|
|
15
|
+
program
|
|
16
|
+
.command('login')
|
|
17
|
+
.description('Save your API key to ~/.m2f/config.json')
|
|
18
|
+
.option('--api-key <key>', 'REST API key (rest_...); prompts when omitted')
|
|
19
|
+
.option('--base-url <url>', 'API base URL (default: https://api.mind2flow.io/api/v1)')
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
try {
|
|
22
|
+
const apiKey = opts.apiKey || (await prompt('Paste your REST API key (rest_...): '));
|
|
23
|
+
if (!apiKey.startsWith('rest_')) {
|
|
24
|
+
console.error('That does not look like a Mind2Flow REST API key (must start with rest_).');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const config = (0, config_1.loadConfig)();
|
|
28
|
+
config.apiKey = apiKey;
|
|
29
|
+
if (opts.baseUrl)
|
|
30
|
+
config.baseUrl = opts.baseUrl;
|
|
31
|
+
(0, config_1.saveConfig)(config);
|
|
32
|
+
// Verify the key actually works
|
|
33
|
+
const client = (0, config_1.getClient)();
|
|
34
|
+
const me = await client.account.me();
|
|
35
|
+
console.log(`Logged in as ${me.user.email}`);
|
|
36
|
+
console.log(`Scopes: ${(me.auth.scopes ?? []).join(', ')}`);
|
|
37
|
+
console.log(`Config saved to ${(0, config_1.configPath)()}`);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
(0, output_1.fail)(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
program
|
|
44
|
+
.command('logout')
|
|
45
|
+
.description('Remove the stored API key')
|
|
46
|
+
.action(() => {
|
|
47
|
+
const config = (0, config_1.loadConfig)();
|
|
48
|
+
delete config.apiKey;
|
|
49
|
+
(0, config_1.saveConfig)(config);
|
|
50
|
+
console.log('Logged out. API key removed from config.');
|
|
51
|
+
});
|
|
52
|
+
program
|
|
53
|
+
.command('whoami')
|
|
54
|
+
.description('Show the account behind the configured API key')
|
|
55
|
+
.action(async () => {
|
|
56
|
+
try {
|
|
57
|
+
const me = await (0, config_1.getClient)().account.me();
|
|
58
|
+
(0, output_1.printJson)(me);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
(0, output_1.fail)(error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
program
|
|
65
|
+
.command('credits')
|
|
66
|
+
.description('Show your credit balance')
|
|
67
|
+
.action(async () => {
|
|
68
|
+
try {
|
|
69
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().account.credits());
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
(0, output_1.fail)(error);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":";;AAeA,oDA8DC;AA5ED,uCAA2C;AAC3C,sCAA0E;AAC1E,sCAA4C;AAE5C,SAAS,MAAM,CAAC,QAAgB;IAC9B,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;QAC/B,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,iBAAiB,EAAE,+CAA+C,CAAC;SAC1E,MAAM,CAAC,kBAAkB,EAAE,yDAAyD,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,IAA2C,EAAE,EAAE;QAC5D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IA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AM,CAAC,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,MAAM,IAAA,kBAAS,GAAE,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAA,kBAAS,EAAC,EAAE,CAAC,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,0BAA0B,CAAC;SACvC,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,IAAA,kBAAS,EAAC,MAAM,IAAA,kBAAS,GAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerCrewCommands = registerCrewCommands;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const config_1 = require("../config");
|
|
9
|
+
const output_1 = require("../output");
|
|
10
|
+
function registerCrewCommands(program) {
|
|
11
|
+
const crews = program.command('crews').description('Manage and execute multi-agent crews');
|
|
12
|
+
crews
|
|
13
|
+
.command('list')
|
|
14
|
+
.description('List your crews')
|
|
15
|
+
.option('--json', 'Output raw JSON')
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
try {
|
|
18
|
+
const list = await (0, config_1.getClient)().crews.list();
|
|
19
|
+
if (opts.json)
|
|
20
|
+
return (0, output_1.printJson)(list);
|
|
21
|
+
(0, output_1.printTable)(list.map((c) => ({ id: c.id, name: c.name, description: c.description ?? '' })), ['id', 'name', 'description']);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
(0, output_1.fail)(error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
crews
|
|
28
|
+
.command('get <crewId>')
|
|
29
|
+
.description('Show one crew')
|
|
30
|
+
.action(async (crewId) => {
|
|
31
|
+
try {
|
|
32
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().crews.get(crewId));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
(0, output_1.fail)(error);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
crews
|
|
39
|
+
.command('create')
|
|
40
|
+
.description('Create a crew from a JSON definition file')
|
|
41
|
+
.requiredOption('--from <file>', 'JSON file with the crew definition')
|
|
42
|
+
.action(async (opts) => {
|
|
43
|
+
try {
|
|
44
|
+
const params = JSON.parse(fs_1.default.readFileSync(opts.from, 'utf-8'));
|
|
45
|
+
const crew = await (0, config_1.getClient)().crews.create(params);
|
|
46
|
+
console.log(`Crew created: ${crew.id}`);
|
|
47
|
+
(0, output_1.printJson)(crew);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
(0, output_1.fail)(error);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
crews
|
|
54
|
+
.command('delete <crewId>')
|
|
55
|
+
.description('Delete a crew')
|
|
56
|
+
.action(async (crewId) => {
|
|
57
|
+
try {
|
|
58
|
+
await (0, config_1.getClient)().crews.delete(crewId);
|
|
59
|
+
console.log(`Crew ${crewId} deleted.`);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
(0, output_1.fail)(error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
crews
|
|
66
|
+
.command('run <crewId>')
|
|
67
|
+
.description('Execute a crew')
|
|
68
|
+
.option('--input <text>', 'Input text for the crew')
|
|
69
|
+
.option('--input-file <file>', 'Read input (JSON or text) from a file')
|
|
70
|
+
.action(async (crewId, opts) => {
|
|
71
|
+
try {
|
|
72
|
+
let input = opts.input;
|
|
73
|
+
if (opts.inputFile) {
|
|
74
|
+
const raw = fs_1.default.readFileSync(opts.inputFile, 'utf-8');
|
|
75
|
+
try {
|
|
76
|
+
input = JSON.parse(raw);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
input = raw;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
console.error(`Running crew ${crewId}...`);
|
|
83
|
+
const execution = await (0, config_1.getClient)().crews.execute(crewId, input);
|
|
84
|
+
(0, output_1.printJson)(execution);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
(0, output_1.fail)(error);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
crews
|
|
91
|
+
.command('executions <crewId>')
|
|
92
|
+
.description('List a crew\'s executions')
|
|
93
|
+
.option('--limit <n>', 'Max items (default 20)')
|
|
94
|
+
.action(async (crewId, opts) => {
|
|
95
|
+
try {
|
|
96
|
+
const { executions } = await (0, config_1.getClient)().crews.executions(crewId, {
|
|
97
|
+
limit: opts.limit ? parseInt(opts.limit, 10) : 20,
|
|
98
|
+
});
|
|
99
|
+
(0, output_1.printTable)(executions.map((e) => ({ id: e.id, status: e.status, createdAt: e.createdAt ?? '' })), ['id', 'status', 'createdAt']);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
(0, output_1.fail)(error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
crews
|
|
106
|
+
.command('execution <crewId> <executionId>')
|
|
107
|
+
.description('Show one crew execution (poll for status/result)')
|
|
108
|
+
.action(async (crewId, executionId) => {
|
|
109
|
+
try {
|
|
110
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().crews.getExecution(crewId, executionId));
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
(0, output_1.fail)(error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=crews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crews.js","sourceRoot":"","sources":["../../src/commands/crews.ts"],"names":[],"mappings":";;;;;AAKA,oDA8GC;AAlHD,4CAAoB;AACpB,sCAAsC;AACtC,sCAAwD;AAExD,SAAgB,oBAAoB,CAAC,OAAgB;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IAE3F,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,iBAAiB,CAAC;SAC9B,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;SACnC,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,EAAE;QACzC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAA,kBAAS,GAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAA,kBAAS,EAAC,IAAI,CAAC,CAAC;YACtC,IAAA,mBAAU,EACR,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,CAAC,EAC/E,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,CAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,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
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerDeviceCommands = registerDeviceCommands;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const output_1 = require("../output");
|
|
6
|
+
function registerDeviceCommands(program) {
|
|
7
|
+
const devices = program.command('devices').description('Manage devices (WhatsApp, SMS, Email, Web)');
|
|
8
|
+
devices
|
|
9
|
+
.command('list')
|
|
10
|
+
.description('List your devices')
|
|
11
|
+
.option('--json', 'Output raw JSON')
|
|
12
|
+
.option('--available', 'Only devices not assigned to an agent/crew')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
try {
|
|
15
|
+
const client = (0, config_1.getClient)();
|
|
16
|
+
const list = opts.available ? await client.devices.listAvailable() : await client.devices.list();
|
|
17
|
+
if (opts.json)
|
|
18
|
+
return (0, output_1.printJson)(list);
|
|
19
|
+
(0, output_1.printTable)(list.map((d) => ({
|
|
20
|
+
id: d.id,
|
|
21
|
+
name: d.name,
|
|
22
|
+
type: d.type,
|
|
23
|
+
connected: d.isConnected ? 'yes' : 'no',
|
|
24
|
+
})), ['id', 'name', 'type', 'connected']);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
(0, output_1.fail)(error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
devices
|
|
31
|
+
.command('get <deviceId>')
|
|
32
|
+
.description('Show one device')
|
|
33
|
+
.action(async (deviceId) => {
|
|
34
|
+
try {
|
|
35
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().devices.get(deviceId));
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
(0, output_1.fail)(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
devices
|
|
42
|
+
.command('create')
|
|
43
|
+
.description('Create a device')
|
|
44
|
+
.requiredOption('--name <name>', 'Device name')
|
|
45
|
+
.requiredOption('--type <type>', 'Device type: whatsapp | sms | email | web')
|
|
46
|
+
.action(async (opts) => {
|
|
47
|
+
try {
|
|
48
|
+
const device = await (0, config_1.getClient)().devices.create({ name: opts.name, type: opts.type });
|
|
49
|
+
console.log(`Device created: ${device.id}`);
|
|
50
|
+
(0, output_1.printJson)(device);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
(0, output_1.fail)(error);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
devices
|
|
57
|
+
.command('delete <deviceId>')
|
|
58
|
+
.description('Delete a device')
|
|
59
|
+
.action(async (deviceId) => {
|
|
60
|
+
try {
|
|
61
|
+
await (0, config_1.getClient)().devices.delete(deviceId);
|
|
62
|
+
console.log(`Device ${deviceId} deleted.`);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
(0, output_1.fail)(error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../src/commands/devices.ts"],"names":[],"mappings":";;AAIA,wDAgEC;AAnED,sCAAsC;AACtC,sCAAwD;AAExD,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;IAErG,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,mBAAmB,CAAC;SAChC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;SACnC,MAAM,CAAC,aAAa,EAAE,4CAA4C,CAAC;SACnE,MAAM,CAAC,KAAK,EAAE,IAA6C,EAAE,EAAE;QAC9D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,aAAa,E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AAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,GAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACtF,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5C,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC;QACpB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,mBAAmB,CAAC;SAC5B,WAAW,CAAC,iBAAiB,CAAC;SAC9B,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,EAAE;QACjC,IAAI,CAAC;YACH,MAAM,IAAA,kBAAS,GAAE,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,UAAU,QAAQ,WAAW,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Helpers to wire the Mind2Flow MCP server into MCP clients
|
|
4
|
+
* (Cursor, Claude Code, Claude Desktop).
|
|
5
|
+
*
|
|
6
|
+
* The MCP server uses its own key type (mcp_...), created in the dashboard
|
|
7
|
+
* under Developers → MCP Keys — this is separate from the rest_ key the
|
|
8
|
+
* SDK/CLI use.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerMcpCommands(program: Command): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerMcpCommands = registerMcpCommands;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* Helpers to wire the Mind2Flow MCP server into MCP clients
|
|
12
|
+
* (Cursor, Claude Code, Claude Desktop).
|
|
13
|
+
*
|
|
14
|
+
* The MCP server uses its own key type (mcp_...), created in the dashboard
|
|
15
|
+
* under Developers → MCP Keys — this is separate from the rest_ key the
|
|
16
|
+
* SDK/CLI use.
|
|
17
|
+
*/
|
|
18
|
+
function registerMcpCommands(program) {
|
|
19
|
+
const mcp = program.command('mcp').description('Connect the Mind2Flow MCP server to your AI tools');
|
|
20
|
+
mcp
|
|
21
|
+
.command('setup')
|
|
22
|
+
.description('Add the Mind2Flow MCP server to Cursor (~/.cursor/mcp.json)')
|
|
23
|
+
.requiredOption('--mcp-key <key>', 'MCP API key (mcp_...) from the dashboard')
|
|
24
|
+
.option('--url <url>', 'MCP server URL', 'http://localhost:3003/mcp')
|
|
25
|
+
.option('--name <name>', 'Server name in the client config', 'mind2flow')
|
|
26
|
+
.action((opts) => {
|
|
27
|
+
const configFile = path_1.default.join(os_1.default.homedir(), '.cursor', 'mcp.json');
|
|
28
|
+
let config = {};
|
|
29
|
+
try {
|
|
30
|
+
config = JSON.parse(fs_1.default.readFileSync(configFile, 'utf-8'));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// no existing config
|
|
34
|
+
}
|
|
35
|
+
config.mcpServers = {
|
|
36
|
+
...config.mcpServers,
|
|
37
|
+
[opts.name]: {
|
|
38
|
+
url: opts.url,
|
|
39
|
+
headers: { Authorization: `Bearer ${opts.mcpKey}` },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
fs_1.default.mkdirSync(path_1.default.dirname(configFile), { recursive: true });
|
|
43
|
+
fs_1.default.writeFileSync(configFile, JSON.stringify(config, null, 2) + '\n');
|
|
44
|
+
console.log(`Added "${opts.name}" MCP server to ${configFile}`);
|
|
45
|
+
console.log('Restart Cursor to pick up the change.');
|
|
46
|
+
});
|
|
47
|
+
mcp
|
|
48
|
+
.command('claude-command')
|
|
49
|
+
.description('Print the command that adds the MCP server to Claude Code')
|
|
50
|
+
.requiredOption('--mcp-key <key>', 'MCP API key (mcp_...)')
|
|
51
|
+
.option('--url <url>', 'MCP server URL', 'http://localhost:3003/mcp')
|
|
52
|
+
.option('--name <name>', 'Server name', 'mind2flow')
|
|
53
|
+
.action((opts) => {
|
|
54
|
+
console.log(`claude mcp add --transport sse ${opts.name} ${opts.url} --header "Authorization: Bearer ${opts.mcpKey}"`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":";;;;;AAaA,kDA2CC;AAvDD,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AAExB;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,mDAAmD,CAAC,CAAC;IAEpG,GAAG;SACA,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,6DAA6D,CAAC;SAC1E,cAAc,CAAC,iBAAiB,EAAE,0CAA0C,CAAC;SAC7E,MAAM,CAAC,aAAa,EAAE,gBAAgB,EAAE,2BAA2B,CAAC;SACpE,MAAM,CAAC,eAAe,EAAE,kCAAkC,EAAE,WAAW,CAAC;SACxE,MAAM,CAAC,CAAC,IAAmD,EAAE,EAAE;QAC9D,MAAM,UAA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AC,GAAG,CACT,kCAAkC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,oCAAoC,IAAI,CAAC,MAAM,GAAG,CAC1G,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerTaskCommands = registerTaskCommands;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const output_1 = require("../output");
|
|
6
|
+
function registerTaskCommands(program) {
|
|
7
|
+
const tasks = program.command('tasks').description('Manage agent scheduled tasks');
|
|
8
|
+
tasks
|
|
9
|
+
.command('list')
|
|
10
|
+
.description('List scheduled tasks')
|
|
11
|
+
.option('--agent-id <id>', 'Filter by agent')
|
|
12
|
+
.option('--json', 'Output raw JSON')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
try {
|
|
15
|
+
const list = await (0, config_1.getClient)().scheduledTasks.list({ agentId: opts.agentId });
|
|
16
|
+
if (opts.json)
|
|
17
|
+
return (0, output_1.printJson)(list);
|
|
18
|
+
(0, output_1.printTable)(list.map((t) => ({
|
|
19
|
+
id: t.id,
|
|
20
|
+
name: t.name,
|
|
21
|
+
agent: t.agentId,
|
|
22
|
+
type: t.scheduleType,
|
|
23
|
+
schedule: t.cronExpression ?? (t.intervalMs ? `${t.intervalMs}ms` : t.runAt ?? ''),
|
|
24
|
+
enabled: t.enabled ? 'yes' : 'no',
|
|
25
|
+
})), ['id', 'name', 'agent', 'type', 'schedule', 'enabled']);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
(0, output_1.fail)(error);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
tasks
|
|
32
|
+
.command('create')
|
|
33
|
+
.description('Create a scheduled task for an agent')
|
|
34
|
+
.requiredOption('--agent-id <id>', 'Agent to run')
|
|
35
|
+
.requiredOption('--name <name>', 'Task name')
|
|
36
|
+
.requiredOption('--message <text>', 'Message sent to the agent on each run')
|
|
37
|
+
.option('--cron <expression>', 'Cron expression (schedule type: cron)')
|
|
38
|
+
.option('--interval <ms>', 'Interval in milliseconds (schedule type: interval)')
|
|
39
|
+
.option('--at <iso>', 'One-shot run time, ISO 8601 (schedule type: once)')
|
|
40
|
+
.option('--timezone <tz>', 'IANA timezone for cron schedules (default UTC)')
|
|
41
|
+
.action(async (opts) => {
|
|
42
|
+
try {
|
|
43
|
+
const scheduleType = opts.cron ? 'cron' : opts.interval ? 'interval' : opts.at ? 'once' : undefined;
|
|
44
|
+
if (!scheduleType) {
|
|
45
|
+
console.error('Provide one of --cron, --interval or --at.');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
const task = await (0, config_1.getClient)().scheduledTasks.create({
|
|
49
|
+
agentId: opts.agentId,
|
|
50
|
+
name: opts.name,
|
|
51
|
+
message: opts.message,
|
|
52
|
+
scheduleType,
|
|
53
|
+
cronExpression: opts.cron,
|
|
54
|
+
intervalMs: opts.interval ? parseInt(opts.interval, 10) : undefined,
|
|
55
|
+
runAt: opts.at,
|
|
56
|
+
timezone: opts.timezone,
|
|
57
|
+
});
|
|
58
|
+
console.log(`Scheduled task created: ${task.id}`);
|
|
59
|
+
(0, output_1.printJson)(task);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
(0, output_1.fail)(error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
tasks
|
|
66
|
+
.command('toggle <taskId>')
|
|
67
|
+
.description('Enable/disable a task')
|
|
68
|
+
.action(async (taskId) => {
|
|
69
|
+
try {
|
|
70
|
+
const task = await (0, config_1.getClient)().scheduledTasks.toggle(taskId);
|
|
71
|
+
console.log(`Task ${taskId} is now ${task.enabled ? 'enabled' : 'disabled'}.`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
(0, output_1.fail)(error);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
tasks
|
|
78
|
+
.command('run <taskId>')
|
|
79
|
+
.description('Run a task immediately')
|
|
80
|
+
.action(async (taskId) => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await (0, config_1.getClient)().scheduledTasks.run(taskId);
|
|
83
|
+
(0, output_1.printJson)(result);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
(0, output_1.fail)(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
tasks
|
|
90
|
+
.command('delete <taskId>')
|
|
91
|
+
.description('Delete a task')
|
|
92
|
+
.action(async (taskId) => {
|
|
93
|
+
try {
|
|
94
|
+
await (0, config_1.getClient)().scheduledTasks.delete(taskId);
|
|
95
|
+
console.log(`Task ${taskId} deleted.`);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
(0, output_1.fail)(error);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
tasks
|
|
102
|
+
.command('executions <taskId>')
|
|
103
|
+
.description('Show a task\'s execution history')
|
|
104
|
+
.option('--limit <n>', 'Max items (default 20)')
|
|
105
|
+
.action(async (taskId, opts) => {
|
|
106
|
+
try {
|
|
107
|
+
const executions = await (0, config_1.getClient)().scheduledTasks.executions(taskId, {
|
|
108
|
+
limit: opts.limit ? parseInt(opts.limit, 10) : 20,
|
|
109
|
+
});
|
|
110
|
+
(0, output_1.printJson)(executions);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
(0, output_1.fail)(error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/commands/tasks.ts"],"names":[],"mappings":";;AAIA,oDAwHC;AA3HD,sCAAsC;AACtC,sCAAwD;AAExD,SAAgB,oBAAoB,CAAC,OAAgB;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,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e,CAAC;SAC5B,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,IAAA,kBAAS,GAAE,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,QAAQ,MAAM,WAAW,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,KAAK;SACF,OAAO,CAAC,qBAAqB,CAAC;SAC9B,WAAW,CAAC,kCAAkC,CAAC;SAC/C,MAAM,CAAC,aAAa,EAAE,wBAAwB,CAAC;SAC/C,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAwB,EAAE,EAAE;QACzD,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,IAAA,kBAAS,GAAE,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE;gBACrE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;aAClD,CAAC,CAAC;YACH,IAAA,kBAAS,EAAC,UAAU,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerToolCommands = registerToolCommands;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const config_1 = require("../config");
|
|
10
|
+
const output_1 = require("../output");
|
|
11
|
+
function registerToolCommands(program) {
|
|
12
|
+
const tools = program.command('tools').description('Manage custom Python tools');
|
|
13
|
+
tools
|
|
14
|
+
.command('list')
|
|
15
|
+
.description('List your custom tools')
|
|
16
|
+
.option('--json', 'Output raw JSON')
|
|
17
|
+
.option('--public', 'Discover public tools instead')
|
|
18
|
+
.action(async (opts) => {
|
|
19
|
+
try {
|
|
20
|
+
const client = (0, config_1.getClient)();
|
|
21
|
+
const list = opts.public ? await client.tools.listPublic() : await client.tools.list();
|
|
22
|
+
if (opts.json)
|
|
23
|
+
return (0, output_1.printJson)(list);
|
|
24
|
+
(0, output_1.printTable)(list.map((t) => ({
|
|
25
|
+
id: t.id,
|
|
26
|
+
name: t.name,
|
|
27
|
+
category: t.category ?? '',
|
|
28
|
+
public: t.isPublic ? 'yes' : 'no',
|
|
29
|
+
})), ['id', 'name', 'category', 'public']);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
(0, output_1.fail)(error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
tools
|
|
36
|
+
.command('get <toolId>')
|
|
37
|
+
.description('Show one tool (including its code)')
|
|
38
|
+
.action(async (toolId) => {
|
|
39
|
+
try {
|
|
40
|
+
(0, output_1.printJson)(await (0, config_1.getClient)().tools.get(toolId));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
(0, output_1.fail)(error);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
tools
|
|
47
|
+
.command('push <file>')
|
|
48
|
+
.description('Create (or update with --tool-id) a custom tool from a Python file')
|
|
49
|
+
.option('--name <name>', 'Tool name (defaults to the file name)')
|
|
50
|
+
.requiredOption('--description <text>', 'What the tool does — shown to agents')
|
|
51
|
+
.option('--tool-id <id>', 'Update this existing tool instead of creating')
|
|
52
|
+
.option('--category <category>', 'Tool category')
|
|
53
|
+
.option('--public', 'Make the tool publicly discoverable')
|
|
54
|
+
.action(async (file, opts) => {
|
|
55
|
+
try {
|
|
56
|
+
const code = fs_1.default.readFileSync(file, 'utf-8');
|
|
57
|
+
const name = opts.name ?? path_1.default.basename(file, path_1.default.extname(file));
|
|
58
|
+
const client = (0, config_1.getClient)();
|
|
59
|
+
if (opts.toolId) {
|
|
60
|
+
const tool = await client.tools.update(opts.toolId, {
|
|
61
|
+
name,
|
|
62
|
+
description: opts.description,
|
|
63
|
+
code,
|
|
64
|
+
category: opts.category,
|
|
65
|
+
isPublic: opts.public,
|
|
66
|
+
});
|
|
67
|
+
console.log(`Tool updated: ${tool.id}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const tool = await client.tools.create({
|
|
71
|
+
name,
|
|
72
|
+
description: opts.description,
|
|
73
|
+
code,
|
|
74
|
+
category: opts.category,
|
|
75
|
+
isPublic: Boolean(opts.public),
|
|
76
|
+
});
|
|
77
|
+
console.log(`Tool created: ${tool.id}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
(0, output_1.fail)(error);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
tools
|
|
85
|
+
.command('delete <toolId>')
|
|
86
|
+
.description('Delete a custom tool')
|
|
87
|
+
.action(async (toolId) => {
|
|
88
|
+
try {
|
|
89
|
+
await (0, config_1.getClient)().tools.delete(toolId);
|
|
90
|
+
console.log(`Tool ${toolId} deleted.`);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
(0, output_1.fail)(error);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
tools
|
|
97
|
+
.command('exec <file>')
|
|
98
|
+
.description('Run a Python file in the sandbox (requires tools:execute scope)')
|
|
99
|
+
.option('--timeout <seconds>', 'Timeout in seconds (default 60)')
|
|
100
|
+
.action(async (file, opts) => {
|
|
101
|
+
try {
|
|
102
|
+
const code = fs_1.default.readFileSync(file, 'utf-8');
|
|
103
|
+
const result = await (0, config_1.getClient)().tools.executePython({
|
|
104
|
+
code,
|
|
105
|
+
timeout: opts.timeout ? parseInt(opts.timeout, 10) : undefined,
|
|
106
|
+
});
|
|
107
|
+
if (result.stdout)
|
|
108
|
+
process.stdout.write(result.stdout);
|
|
109
|
+
if (result.stderr)
|
|
110
|
+
process.stderr.write(result.stderr);
|
|
111
|
+
console.error(`\n(${result.success ? 'success' : 'failed'} in ${result.executionTime}s)`);
|
|
112
|
+
if (!result.success)
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
(0, output_1.fail)(error);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/commands/tools.ts"],"names":[],"mappings":";;;;;AAMA,oDAgHC;AArHD,4CAAoB;AACpB,gDAAwB;AACxB,sCAAsC;AACtC,sCAAwD;AAExD,SAAgB,oBAAoB,CAAC,OAAgB;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IAEjF,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;SACnC,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,IAA0C,EAAE,EAAE;QAC3D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACvF,I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AC;YAC1F,IAAI,CAAC,MAAM,CAAC,OAAO;gBAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,aAAI,EAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { M2FClient } from '@mind2flow/agents-sdk';
|
|
2
|
+
export interface CliConfig {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function loadConfig(): CliConfig;
|
|
7
|
+
export declare function saveConfig(config: CliConfig): void;
|
|
8
|
+
export declare function configPath(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve credentials (flag > env > config file) and build a client.
|
|
11
|
+
* Exits with a friendly message when no API key is available.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getClient(opts?: {
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
}): M2FClient;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
exports.saveConfig = saveConfig;
|
|
8
|
+
exports.configPath = configPath;
|
|
9
|
+
exports.getClient = getClient;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const os_1 = __importDefault(require("os"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const agents_sdk_1 = require("@mind2flow/agents-sdk");
|
|
14
|
+
const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.m2f');
|
|
15
|
+
const CONFIG_FILE = path_1.default.join(CONFIG_DIR, 'config.json');
|
|
16
|
+
function loadConfig() {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(fs_1.default.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function saveConfig(config) {
|
|
25
|
+
fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
26
|
+
fs_1.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
27
|
+
}
|
|
28
|
+
function configPath() {
|
|
29
|
+
return CONFIG_FILE;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve credentials (flag > env > config file) and build a client.
|
|
33
|
+
* Exits with a friendly message when no API key is available.
|
|
34
|
+
*/
|
|
35
|
+
function getClient(opts = {}) {
|
|
36
|
+
const config = loadConfig();
|
|
37
|
+
const apiKey = opts.apiKey || process.env.M2F_API_KEY || config.apiKey;
|
|
38
|
+
const baseUrl = opts.baseUrl || process.env.M2F_BASE_URL || config.baseUrl || agents_sdk_1.DEFAULT_BASE_URL;
|
|
39
|
+
if (!apiKey) {
|
|
40
|
+
console.error('No API key configured.');
|
|
41
|
+
console.error('Run `m2f login` or set the M2F_API_KEY environment variable.');
|
|
42
|
+
console.error('Create a key in the dashboard: Developers → API → Create REST API Key.');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
return new agents_sdk_1.M2FClient({ apiKey, baseUrl });
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;AAaA,gCAMC;AAED,gCAGC;AAED,gCAEC;AAMD,8BAaC;AA/CD,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,sDA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EAAwE,CAAC,CAAC;QACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,sBAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const auth_1 = require("./commands/auth");
|
|
6
|
+
const agents_1 = require("./commands/agents");
|
|
7
|
+
const crews_1 = require("./commands/crews");
|
|
8
|
+
const devices_1 = require("./commands/devices");
|
|
9
|
+
const tools_1 = require("./commands/tools");
|
|
10
|
+
const tasks_1 = require("./commands/tasks");
|
|
11
|
+
const mcp_1 = require("./commands/mcp");
|
|
12
|
+
const program = new commander_1.Command();
|
|
13
|
+
program
|
|
14
|
+
.name('m2f')
|
|
15
|
+
.description('Mind2Flow CLI — build, manage and run AI agents from your terminal')
|
|
16
|
+
.version('0.1.0');
|
|
17
|
+
(0, auth_1.registerAuthCommands)(program);
|
|
18
|
+
(0, agents_1.registerAgentCommands)(program);
|
|
19
|
+
(0, crews_1.registerCrewCommands)(program);
|
|
20
|
+
(0, devices_1.registerDeviceCommands)(program);
|
|
21
|
+
(0, tools_1.registerToolCommands)(program);
|
|
22
|
+
(0, tasks_1.registerTaskCommands)(program);
|
|
23
|
+
(0, mcp_1.registerMcpCommands)(program);
|
|
24
|
+
program.parseAsync(process.argv);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,0CAAuD;AACvD,8CAA0D;AAC1D,4CAAwD;AACxD,gDAA4D;AAC5D,4CAAwD;AACxD,4CAAwD;AACxD,wCAAqD;AAErD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,oEAAoE,CAAC;KACjF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,IAAA,2BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;AAC/B,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;AAChC,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,yBAAmB,EAAC,OAAO,CAAC,CAAC;AAE7B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Print rows as an aligned plain-text table. */
|
|
2
|
+
export declare function printTable(rows: Array<Record<string, unknown>>, columns: string[]): void;
|
|
3
|
+
export declare function printJson(value: unknown): void;
|
|
4
|
+
/** Uniform error handling for all commands. */
|
|
5
|
+
export declare function fail(error: unknown): never;
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printTable = printTable;
|
|
4
|
+
exports.printJson = printJson;
|
|
5
|
+
exports.fail = fail;
|
|
6
|
+
const agents_sdk_1 = require("@mind2flow/agents-sdk");
|
|
7
|
+
/** Print rows as an aligned plain-text table. */
|
|
8
|
+
function printTable(rows, columns) {
|
|
9
|
+
if (rows.length === 0) {
|
|
10
|
+
console.log('(none)');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const cells = rows.map((row) => columns.map((col) => {
|
|
14
|
+
const value = row[col];
|
|
15
|
+
if (value === null || value === undefined)
|
|
16
|
+
return '';
|
|
17
|
+
if (typeof value === 'object')
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
return String(value);
|
|
20
|
+
}));
|
|
21
|
+
const widths = columns.map((col, i) => Math.max(col.length, ...cells.map((row) => row[i].length)));
|
|
22
|
+
const line = (parts) => parts.map((part, i) => part.padEnd(widths[i])).join(' ');
|
|
23
|
+
console.log(line(columns.map((c) => c.toUpperCase())));
|
|
24
|
+
console.log(line(widths.map((w) => '-'.repeat(w))));
|
|
25
|
+
for (const row of cells)
|
|
26
|
+
console.log(line(row));
|
|
27
|
+
}
|
|
28
|
+
function printJson(value) {
|
|
29
|
+
console.log(JSON.stringify(value, null, 2));
|
|
30
|
+
}
|
|
31
|
+
/** Uniform error handling for all commands. */
|
|
32
|
+
function fail(error) {
|
|
33
|
+
if (error instanceof agents_sdk_1.M2FError) {
|
|
34
|
+
console.error(`Error (HTTP ${error.status}): ${error.message}`);
|
|
35
|
+
if (error.requiredScope) {
|
|
36
|
+
console.error(`Your API key is missing the "${error.requiredScope}" scope.`);
|
|
37
|
+
}
|
|
38
|
+
if (error.isRateLimited) {
|
|
39
|
+
console.error('You are being rate limited — retry in a minute or raise the key\'s limit.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
}
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":";;AAGA,gCAyBC;AAED,8BAEC;AAGD,oBAaC;AAhDD,sDAAiD;AAEjD,iDAAiD;AACjD,SAAgB,UAAU,CAAC,IAAoC,EAAE,OAAiB;IAChF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAA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C,CAAC,CAAC;IACpD,KAAK,MAAM,GAAG,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,+CAA+C;AAC/C,SAAgB,IAAI,CAAC,KAAc;IACjC,IAAI,KAAK,YAAY,qBAAQ,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,eAAe,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,aAAa,UAAU,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mind2flow/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Command-line interface for the Mind2Flow AI agents platform",
|
|
5
|
+
"keywords": ["ai", "agents", "mind2flow", "cli"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/pablocruzpineda/m2f-agents-sdk#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/pablocruzpineda/m2f-agents-sdk.git",
|
|
11
|
+
"directory": "packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/pablocruzpineda/m2f-agents-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"m2f": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": ["dist", "README.md"],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@mind2flow/agents-sdk": "^0.1.0",
|
|
29
|
+
"commander": "^12.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^20.11.0",
|
|
33
|
+
"typescript": "^5.4.0"
|
|
34
|
+
}
|
|
35
|
+
}
|