@agentmeshhq/agent 0.2.0 → 0.2.1
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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/__tests__/orphan-process.test.d.ts +11 -0
- package/dist/__tests__/orphan-process.test.js +286 -0
- package/dist/__tests__/orphan-process.test.js.map +1 -0
- package/dist/__tests__/runner.test.js +16 -0
- package/dist/__tests__/runner.test.js.map +1 -1
- package/dist/__tests__/watchdog.test.js +138 -12
- package/dist/__tests__/watchdog.test.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/cli/status.js +11 -0
- package/dist/cli/status.js.map +1 -1
- package/dist/cli/stop.js +7 -2
- package/dist/cli/stop.js.map +1 -1
- package/dist/config/schema.d.ts +4 -2
- package/dist/core/daemon/assignment-message.d.ts +12 -0
- package/dist/core/daemon/assignment-message.js +36 -0
- package/dist/core/daemon/assignment-message.js.map +1 -0
- package/dist/core/daemon/bootstrap.d.ts +35 -0
- package/dist/core/daemon/bootstrap.js +52 -0
- package/dist/core/daemon/bootstrap.js.map +1 -0
- package/dist/core/daemon/crash-log.d.ts +16 -0
- package/dist/core/daemon/crash-log.js +24 -0
- package/dist/core/daemon/crash-log.js.map +1 -0
- package/dist/core/daemon/health-policy.d.ts +21 -0
- package/dist/core/daemon/health-policy.js +32 -0
- package/dist/core/daemon/health-policy.js.map +1 -0
- package/dist/core/daemon/sandbox-config.d.ts +9 -0
- package/dist/core/daemon/sandbox-config.js +17 -0
- package/dist/core/daemon/sandbox-config.js.map +1 -0
- package/dist/core/daemon/state.d.ts +33 -0
- package/dist/core/daemon/state.js +77 -0
- package/dist/core/daemon/state.js.map +1 -0
- package/dist/core/daemon/tmux-session.d.ts +17 -0
- package/dist/core/daemon/tmux-session.js +34 -0
- package/dist/core/daemon/tmux-session.js.map +1 -0
- package/dist/core/daemon/workspace.d.ts +10 -0
- package/dist/core/daemon/workspace.js +51 -0
- package/dist/core/daemon/workspace.js.map +1 -0
- package/dist/core/daemon.d.ts +0 -6
- package/dist/core/daemon.js +123 -244
- package/dist/core/daemon.js.map +1 -1
- package/dist/core/injector.js +6 -0
- package/dist/core/injector.js.map +1 -1
- package/dist/core/runner/build.d.ts +9 -0
- package/dist/core/runner/build.js +53 -0
- package/dist/core/runner/build.js.map +1 -0
- package/dist/core/runner/detect.d.ts +5 -0
- package/dist/core/runner/detect.js +14 -0
- package/dist/core/runner/detect.js.map +1 -0
- package/dist/core/runner/index.d.ts +5 -0
- package/dist/core/runner/index.js +5 -0
- package/dist/core/runner/index.js.map +1 -0
- package/dist/core/runner/model.d.ts +5 -0
- package/dist/core/runner/model.js +7 -0
- package/dist/core/runner/model.js.map +1 -0
- package/dist/core/runner/opencode-models.d.ts +15 -0
- package/dist/core/runner/opencode-models.js +70 -0
- package/dist/core/runner/opencode-models.js.map +1 -0
- package/dist/core/runner/types.d.ts +19 -0
- package/dist/core/runner/types.js +8 -0
- package/dist/core/runner/types.js.map +1 -0
- package/dist/core/runner.d.ts +5 -47
- package/dist/core/runner.js +5 -167
- package/dist/core/runner.js.map +1 -1
- package/dist/core/tmux-runtime.d.ts +13 -0
- package/dist/core/tmux-runtime.js +72 -0
- package/dist/core/tmux-runtime.js.map +1 -0
- package/dist/core/tmux.d.ts +7 -1
- package/dist/core/tmux.js +75 -45
- package/dist/core/tmux.js.map +1 -1
- package/dist/core/watchdog.d.ts +18 -1
- package/dist/core/watchdog.js +78 -29
- package/dist/core/watchdog.js.map +1 -1
- package/package.json +30 -11
- package/dist/cli/inbox.d.ts +0 -5
- package/dist/cli/inbox.js +0 -123
- package/dist/cli/inbox.js.map +0 -1
- package/dist/cli/issue.d.ts +0 -42
- package/dist/cli/issue.js +0 -297
- package/dist/cli/issue.js.map +0 -1
- package/dist/cli/ready.d.ts +0 -5
- package/dist/cli/ready.js +0 -131
- package/dist/cli/ready.js.map +0 -1
- package/dist/cli/sync.d.ts +0 -8
- package/dist/cli/sync.js +0 -154
- package/dist/cli/sync.js.map +0 -1
- package/dist/core/issue-cache.d.ts +0 -44
- package/dist/core/issue-cache.js +0 -75
- package/dist/core/issue-cache.js.map +0 -1
- package/src/__tests__/context.test.ts +0 -464
- package/src/__tests__/injector.test.ts +0 -29
- package/src/__tests__/jwt.test.ts +0 -112
- package/src/__tests__/loader.test.ts +0 -239
- package/src/__tests__/runner.test.ts +0 -104
- package/src/__tests__/sandbox.test.ts +0 -435
- package/src/__tests__/watchdog.test.ts +0 -368
- package/src/cli/attach.ts +0 -22
- package/src/cli/build.ts +0 -145
- package/src/cli/config.ts +0 -148
- package/src/cli/context.ts +0 -231
- package/src/cli/deploy.ts +0 -155
- package/src/cli/index.ts +0 -376
- package/src/cli/init.ts +0 -75
- package/src/cli/list.ts +0 -70
- package/src/cli/local.ts +0 -183
- package/src/cli/logs.ts +0 -64
- package/src/cli/migrate.ts +0 -212
- package/src/cli/nudge.ts +0 -81
- package/src/cli/restart.ts +0 -59
- package/src/cli/slack.ts +0 -70
- package/src/cli/start.ts +0 -118
- package/src/cli/status.ts +0 -91
- package/src/cli/stop.ts +0 -48
- package/src/cli/test.ts +0 -143
- package/src/cli/token.ts +0 -188
- package/src/cli/whoami.ts +0 -142
- package/src/config/loader.ts +0 -121
- package/src/config/schema.ts +0 -68
- package/src/context/handoff.ts +0 -122
- package/src/context/index.ts +0 -8
- package/src/context/schema.ts +0 -111
- package/src/context/storage.ts +0 -197
- package/src/core/daemon.ts +0 -1317
- package/src/core/heartbeat.ts +0 -129
- package/src/core/injector.ts +0 -292
- package/src/core/registry.ts +0 -159
- package/src/core/runner.ts +0 -225
- package/src/core/sandbox.ts +0 -547
- package/src/core/session-id.ts +0 -111
- package/src/core/tmux.ts +0 -405
- package/src/core/watchdog.ts +0 -238
- package/src/core/websocket.ts +0 -94
- package/src/index.ts +0 -10
- package/src/utils/jwt.ts +0 -87
- package/tsconfig.json +0 -8
- package/vitest.config.ts +0 -12
package/src/cli/index.ts
DELETED
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { Command } from "commander";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import { attach } from "./attach.js";
|
|
7
|
-
import { build } from "./build.js";
|
|
8
|
-
import { configCmd } from "./config.js";
|
|
9
|
-
import { contextCmd } from "./context.js";
|
|
10
|
-
import { deploy } from "./deploy.js";
|
|
11
|
-
import { init } from "./init.js";
|
|
12
|
-
import { list } from "./list.js";
|
|
13
|
-
import { localDown, localLogs, localStatus, localUp } from "./local.js";
|
|
14
|
-
import { logs } from "./logs.js";
|
|
15
|
-
import { migrate } from "./migrate.js";
|
|
16
|
-
import { nudge } from "./nudge.js";
|
|
17
|
-
import { restart } from "./restart.js";
|
|
18
|
-
import { slack } from "./slack.js";
|
|
19
|
-
import { start } from "./start.js";
|
|
20
|
-
import { status } from "./status.js";
|
|
21
|
-
import { stop } from "./stop.js";
|
|
22
|
-
import { test } from "./test.js";
|
|
23
|
-
import { token } from "./token.js";
|
|
24
|
-
import { whoami } from "./whoami.js";
|
|
25
|
-
|
|
26
|
-
const require = createRequire(import.meta.url);
|
|
27
|
-
const pkg = require("../../package.json") as { version: string };
|
|
28
|
-
|
|
29
|
-
const program = new Command();
|
|
30
|
-
|
|
31
|
-
program
|
|
32
|
-
.name("agentmesh")
|
|
33
|
-
.description("AgentMesh Agent Wrapper - Turn any AI assistant into a dispatchable agent")
|
|
34
|
-
.version(pkg.version);
|
|
35
|
-
|
|
36
|
-
program
|
|
37
|
-
.command("init")
|
|
38
|
-
.description("Initialize AgentMesh configuration")
|
|
39
|
-
.action(async () => {
|
|
40
|
-
try {
|
|
41
|
-
await init();
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error(pc.red((error as Error).message));
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
program
|
|
49
|
-
.command("start")
|
|
50
|
-
.description("Start an agent (runs in background by default)")
|
|
51
|
-
.requiredOption("-n, --name <name>", "Agent name")
|
|
52
|
-
.option("-c, --command <command>", "Command to run (default: opencode)")
|
|
53
|
-
.option("-w, --workdir <path>", "Working directory")
|
|
54
|
-
.option("-m, --model <model>", "Model identifier")
|
|
55
|
-
.option("-f, --foreground", "Run in foreground (blocking)")
|
|
56
|
-
.option("--restore-context", "Restore context from previous session (default: disabled)")
|
|
57
|
-
.option("--worker", "Enable auto-nudge and restart for worker agents (default: disabled)")
|
|
58
|
-
.option("--auto-setup", "Auto-clone repository for project assignments")
|
|
59
|
-
.option("--serve", "Run opencode serve instead of tmux TUI (for Integration Service)")
|
|
60
|
-
.option("--serve-port <port>", "Port for opencode serve (default: 3001)", "3001")
|
|
61
|
-
.option("--sandbox", "Run agent in Docker sandbox container with filesystem isolation")
|
|
62
|
-
.option(
|
|
63
|
-
"--sandbox-image <image>",
|
|
64
|
-
"Docker image for sandbox (default: agentmesh/agent-sandbox:latest)",
|
|
65
|
-
)
|
|
66
|
-
.option("--sandbox-cpu <limit>", "CPU limit for sandbox (default: 1)")
|
|
67
|
-
.option("--sandbox-memory <limit>", "Memory limit for sandbox (default: 2g)")
|
|
68
|
-
.action(async (options) => {
|
|
69
|
-
try {
|
|
70
|
-
// Parse serve port as number
|
|
71
|
-
if (options.servePort) {
|
|
72
|
-
options.servePort = parseInt(options.servePort, 10);
|
|
73
|
-
}
|
|
74
|
-
await start(options);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error(pc.red((error as Error).message));
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
program
|
|
82
|
-
.command("stop")
|
|
83
|
-
.description("Stop an agent")
|
|
84
|
-
.argument("<name>", "Agent name")
|
|
85
|
-
.action(async (name) => {
|
|
86
|
-
try {
|
|
87
|
-
await stop(name);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error(pc.red((error as Error).message));
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
program
|
|
95
|
-
.command("list")
|
|
96
|
-
.alias("ls")
|
|
97
|
-
.description("List running agents")
|
|
98
|
-
.action(async () => {
|
|
99
|
-
try {
|
|
100
|
-
await list();
|
|
101
|
-
} catch (error) {
|
|
102
|
-
console.error(pc.red((error as Error).message));
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
program
|
|
108
|
-
.command("attach")
|
|
109
|
-
.description("Attach to an agent's tmux session")
|
|
110
|
-
.argument("<name>", "Agent name")
|
|
111
|
-
.action((name) => {
|
|
112
|
-
try {
|
|
113
|
-
attach(name);
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error(pc.red((error as Error).message));
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
program
|
|
121
|
-
.command("nudge")
|
|
122
|
-
.description("Send a nudge to an agent")
|
|
123
|
-
.argument("<name>", "Agent name")
|
|
124
|
-
.argument("<message>", "Message to send")
|
|
125
|
-
.action(async (name, message) => {
|
|
126
|
-
try {
|
|
127
|
-
await nudge(name, message);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.error(pc.red((error as Error).message));
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
program
|
|
135
|
-
.command("whoami")
|
|
136
|
-
.description("Show current agent identity and status")
|
|
137
|
-
.argument("[name]", "Agent name (optional)")
|
|
138
|
-
.action(async (name) => {
|
|
139
|
-
try {
|
|
140
|
-
await whoami(name);
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.error(pc.red((error as Error).message));
|
|
143
|
-
process.exit(1);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
program
|
|
148
|
-
.command("token")
|
|
149
|
-
.description("Manage agent tokens")
|
|
150
|
-
.argument("[action]", "Action: show (default), refresh, info")
|
|
151
|
-
.option("-n, --name <name>", "Agent name")
|
|
152
|
-
.action(async (action, options) => {
|
|
153
|
-
try {
|
|
154
|
-
await token(action || "show", options.name);
|
|
155
|
-
} catch (error) {
|
|
156
|
-
console.error(pc.red((error as Error).message));
|
|
157
|
-
process.exit(1);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
program
|
|
162
|
-
.command("status")
|
|
163
|
-
.description("Show AgentMesh status and health")
|
|
164
|
-
.action(async () => {
|
|
165
|
-
try {
|
|
166
|
-
await status();
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.error(pc.red((error as Error).message));
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
program
|
|
174
|
-
.command("logs")
|
|
175
|
-
.description("View agent session logs")
|
|
176
|
-
.argument("<name>", "Agent name")
|
|
177
|
-
.option("-f, --follow", "Follow log output (attach read-only)")
|
|
178
|
-
.option("-n, --lines <number>", "Number of lines to show", "50")
|
|
179
|
-
.action(async (name, options) => {
|
|
180
|
-
try {
|
|
181
|
-
await logs(name, { follow: options.follow, lines: parseInt(options.lines, 10) });
|
|
182
|
-
} catch (error) {
|
|
183
|
-
console.error(pc.red((error as Error).message));
|
|
184
|
-
process.exit(1);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
program
|
|
189
|
-
.command("restart")
|
|
190
|
-
.description("Restart an agent (preserves agent ID and runtime model)")
|
|
191
|
-
.argument("<name>", "Agent name")
|
|
192
|
-
.option("-m, --model <model>", "Override the runtime model")
|
|
193
|
-
.action(async (name, options) => {
|
|
194
|
-
try {
|
|
195
|
-
await restart(name, { model: options.model });
|
|
196
|
-
} catch (error) {
|
|
197
|
-
console.error(pc.red((error as Error).message));
|
|
198
|
-
process.exit(1);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
program
|
|
203
|
-
.command("config")
|
|
204
|
-
.description("View or edit configuration")
|
|
205
|
-
.argument("[action]", "Action: show (default), get, set, edit, path")
|
|
206
|
-
.argument("[key]", "Config key (for get/set)")
|
|
207
|
-
.argument("[value]", "Config value (for set)")
|
|
208
|
-
.action(async (action, key, value) => {
|
|
209
|
-
try {
|
|
210
|
-
await configCmd(action || "show", key, value);
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error(pc.red((error as Error).message));
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
program
|
|
218
|
-
.command("context")
|
|
219
|
-
.description("Manage agent context persistence")
|
|
220
|
-
.argument("[action]", "Action: show (default), clear, export, import, list, path")
|
|
221
|
-
.argument("[name]", "Agent name or file path (for import)")
|
|
222
|
-
.option("-o, --output <path>", "Output file path (for export)")
|
|
223
|
-
.action(async (action, name, options) => {
|
|
224
|
-
try {
|
|
225
|
-
await contextCmd(action || "show", name, options);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
console.error(pc.red((error as Error).message));
|
|
228
|
-
process.exit(1);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
program
|
|
233
|
-
.command("slack")
|
|
234
|
-
.description("Interact with Slack")
|
|
235
|
-
.argument("[action]", "Action: respond")
|
|
236
|
-
.argument("[channel]", "Slack channel ID")
|
|
237
|
-
.argument("[message]", "Message to send")
|
|
238
|
-
.option("-n, --name <name>", "Agent name (default: concierge)")
|
|
239
|
-
.action(async (action, channel, message, options) => {
|
|
240
|
-
try {
|
|
241
|
-
await slack(action || "help", channel, message, options);
|
|
242
|
-
} catch (error) {
|
|
243
|
-
console.error(pc.red((error as Error).message));
|
|
244
|
-
process.exit(1);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// Local development stack commands
|
|
249
|
-
const localCmd = program
|
|
250
|
-
.command("local")
|
|
251
|
-
.description("Manage local development stack (Postgres, Valkey, Hub)");
|
|
252
|
-
|
|
253
|
-
localCmd
|
|
254
|
-
.command("up")
|
|
255
|
-
.description("Start local development stack")
|
|
256
|
-
.option("--no-detach", "Run in foreground")
|
|
257
|
-
.action(async (options) => {
|
|
258
|
-
try {
|
|
259
|
-
await localUp({ detach: options.detach });
|
|
260
|
-
} catch (error) {
|
|
261
|
-
console.error(pc.red((error as Error).message));
|
|
262
|
-
process.exit(1);
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
localCmd
|
|
267
|
-
.command("down")
|
|
268
|
-
.description("Stop local development stack")
|
|
269
|
-
.action(async () => {
|
|
270
|
-
try {
|
|
271
|
-
await localDown();
|
|
272
|
-
} catch (error) {
|
|
273
|
-
console.error(pc.red((error as Error).message));
|
|
274
|
-
process.exit(1);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
localCmd
|
|
279
|
-
.command("status")
|
|
280
|
-
.description("Show local stack status and ports")
|
|
281
|
-
.action(async () => {
|
|
282
|
-
try {
|
|
283
|
-
await localStatus();
|
|
284
|
-
} catch (error) {
|
|
285
|
-
console.error(pc.red((error as Error).message));
|
|
286
|
-
process.exit(1);
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
localCmd
|
|
291
|
-
.command("logs")
|
|
292
|
-
.description("View local stack logs")
|
|
293
|
-
.option("-f, --follow", "Follow log output")
|
|
294
|
-
.option("-s, --service <name>", "Specific service to show logs for")
|
|
295
|
-
.action(async (options) => {
|
|
296
|
-
try {
|
|
297
|
-
await localLogs({ follow: options.follow, service: options.service });
|
|
298
|
-
} catch (error) {
|
|
299
|
-
console.error(pc.red((error as Error).message));
|
|
300
|
-
process.exit(1);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// Build commands
|
|
305
|
-
program
|
|
306
|
-
.command("build")
|
|
307
|
-
.description("Build packages or Docker images")
|
|
308
|
-
.option("--docker", "Build Docker images instead of packages")
|
|
309
|
-
.option("-p, --package <name>", "Build specific package")
|
|
310
|
-
.option("--clean", "Clean build artifacts before building")
|
|
311
|
-
.action(async (options) => {
|
|
312
|
-
try {
|
|
313
|
-
await build(options);
|
|
314
|
-
} catch (error) {
|
|
315
|
-
console.error(pc.red((error as Error).message));
|
|
316
|
-
process.exit(1);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// Test commands
|
|
321
|
-
program
|
|
322
|
-
.command("test")
|
|
323
|
-
.description("Run tests")
|
|
324
|
-
.option("-p, --package <name>", "Test specific package")
|
|
325
|
-
.option("--e2e", "Run E2E tests")
|
|
326
|
-
.option("-w, --watch", "Watch mode")
|
|
327
|
-
.option("--coverage", "Generate coverage report")
|
|
328
|
-
.option("-u, --update-snapshots", "Update test snapshots")
|
|
329
|
-
.action(async (options) => {
|
|
330
|
-
try {
|
|
331
|
-
await test(options);
|
|
332
|
-
} catch (error) {
|
|
333
|
-
console.error(pc.red((error as Error).message));
|
|
334
|
-
process.exit(1);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
// Migration commands
|
|
339
|
-
program
|
|
340
|
-
.command("migrate")
|
|
341
|
-
.description("Run database migrations")
|
|
342
|
-
.option("--dev", "Run against agentmeshhq.dev")
|
|
343
|
-
.option("--staging", "Run against staging")
|
|
344
|
-
.option("--generate", "Generate migration from schema changes")
|
|
345
|
-
.option("--status", "Show migration status")
|
|
346
|
-
.action(async (options) => {
|
|
347
|
-
try {
|
|
348
|
-
await migrate(options);
|
|
349
|
-
} catch (error) {
|
|
350
|
-
console.error(pc.red((error as Error).message));
|
|
351
|
-
process.exit(1);
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// Deploy commands
|
|
356
|
-
program
|
|
357
|
-
.command("deploy")
|
|
358
|
-
.description("Deploy to environment")
|
|
359
|
-
.argument("<environment>", "Target environment: dev, staging, prod")
|
|
360
|
-
.option("--skip-build", "Skip build step")
|
|
361
|
-
.option("--skip-push", "Skip push to registry")
|
|
362
|
-
.option("--dry-run", "Show what would be done without executing")
|
|
363
|
-
.action(async (environment, options) => {
|
|
364
|
-
try {
|
|
365
|
-
if (!["dev", "staging", "prod"].includes(environment)) {
|
|
366
|
-
console.error(pc.red(`Invalid environment: ${environment}. Use: dev, staging, or prod`));
|
|
367
|
-
process.exit(1);
|
|
368
|
-
}
|
|
369
|
-
await deploy({ environment, ...options });
|
|
370
|
-
} catch (error) {
|
|
371
|
-
console.error(pc.red((error as Error).message));
|
|
372
|
-
process.exit(1);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
program.parse();
|
package/src/cli/init.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import * as readline from "node:readline";
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
import { createDefaultConfig, loadConfig, saveConfig } from "../config/loader.js";
|
|
4
|
-
import type { Config } from "../config/schema.js";
|
|
5
|
-
|
|
6
|
-
function question(rl: readline.Interface, prompt: string): Promise<string> {
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
rl.question(prompt, resolve);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function init(): Promise<void> {
|
|
13
|
-
const existingConfig = loadConfig();
|
|
14
|
-
|
|
15
|
-
if (existingConfig) {
|
|
16
|
-
console.log(pc.yellow("Config already exists at ~/.agentmesh/config.json"));
|
|
17
|
-
console.log("Current workspace:", pc.cyan(existingConfig.workspace));
|
|
18
|
-
|
|
19
|
-
const rl = readline.createInterface({
|
|
20
|
-
input: process.stdin,
|
|
21
|
-
output: process.stdout,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const overwrite = await question(rl, "Overwrite? (y/N): ");
|
|
25
|
-
rl.close();
|
|
26
|
-
|
|
27
|
-
if (overwrite.toLowerCase() !== "y") {
|
|
28
|
-
console.log("Aborted.");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
console.log(pc.bold("\nAgentMesh Agent Setup\n"));
|
|
34
|
-
|
|
35
|
-
const rl = readline.createInterface({
|
|
36
|
-
input: process.stdin,
|
|
37
|
-
output: process.stdout,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const apiKey = await question(
|
|
42
|
-
rl,
|
|
43
|
-
`API Key ${pc.dim("(from agentmeshhq.dev/settings/api-keys)")}: `,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (!apiKey) {
|
|
47
|
-
console.log(pc.red("API Key is required."));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const workspace = await question(rl, `Workspace ${pc.dim("(default: agentmesh)")}: `);
|
|
52
|
-
|
|
53
|
-
const command = await question(rl, `Default command ${pc.dim("(default: opencode)")}: `);
|
|
54
|
-
|
|
55
|
-
const model = await question(rl, `Default model ${pc.dim("(default: claude-sonnet-4)")}: `);
|
|
56
|
-
|
|
57
|
-
const config: Config = createDefaultConfig(apiKey.trim(), workspace.trim() || "agentmesh");
|
|
58
|
-
|
|
59
|
-
if (command.trim()) {
|
|
60
|
-
config.defaults.command = command.trim();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (model.trim()) {
|
|
64
|
-
config.defaults.model = model.trim();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
saveConfig(config);
|
|
68
|
-
|
|
69
|
-
console.log(pc.green("\nConfig saved to ~/.agentmesh/config.json"));
|
|
70
|
-
console.log("\nNext steps:");
|
|
71
|
-
console.log(` ${pc.cyan("agentmesh start --name my-agent")}`);
|
|
72
|
-
} finally {
|
|
73
|
-
rl.close();
|
|
74
|
-
}
|
|
75
|
-
}
|
package/src/cli/list.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import pc from "picocolors";
|
|
2
|
-
import { loadConfig, loadState } from "../config/loader.js";
|
|
3
|
-
import { checkInbox, fetchAssignments } from "../core/registry.js";
|
|
4
|
-
import { getSessionInfo, getSessionName, sessionExists } from "../core/tmux.js";
|
|
5
|
-
|
|
6
|
-
export async function list(): Promise<void> {
|
|
7
|
-
const state = loadState();
|
|
8
|
-
const config = loadConfig();
|
|
9
|
-
|
|
10
|
-
if (state.agents.length === 0) {
|
|
11
|
-
console.log(pc.dim("No agents running."));
|
|
12
|
-
console.log(`Start one with: ${pc.cyan("agentmesh start --name <name>")}`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
console.log(pc.bold("Running Agents:\n"));
|
|
17
|
-
console.log(
|
|
18
|
-
`${"NAME".padEnd(20)} ${"STATUS".padEnd(10)} ${"SESSION".padEnd(25)} ${"PENDING ID".padEnd(18)} ${"WORKDIR".padEnd(38)} ${"PROJECT"}`,
|
|
19
|
-
);
|
|
20
|
-
console.log("-".repeat(140));
|
|
21
|
-
|
|
22
|
-
for (const agent of state.agents) {
|
|
23
|
-
const sessionName = getSessionName(agent.name);
|
|
24
|
-
const exists = sessionExists(sessionName);
|
|
25
|
-
const info = getSessionInfo(agent.name);
|
|
26
|
-
|
|
27
|
-
let status = pc.green("online");
|
|
28
|
-
if (!exists) {
|
|
29
|
-
status = pc.red("offline");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let pendingId = pc.dim("-");
|
|
33
|
-
let assignedProject = agent.assignedProject || "-";
|
|
34
|
-
|
|
35
|
-
// Try to check inbox if we have a token
|
|
36
|
-
if (config && agent.token) {
|
|
37
|
-
try {
|
|
38
|
-
const items = await checkInbox(config.hubUrl, config.workspace, agent.token);
|
|
39
|
-
if (items.length > 0) {
|
|
40
|
-
const firstId = items[0]?.id || "-";
|
|
41
|
-
pendingId = pc.yellow(items.length === 1 ? firstId : `${firstId} (+${items.length - 1})`);
|
|
42
|
-
}
|
|
43
|
-
} catch {
|
|
44
|
-
// Ignore errors
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const assignments = await fetchAssignments(config.hubUrl, agent.token);
|
|
49
|
-
if (assignments.length > 0) {
|
|
50
|
-
assignedProject = assignments.map((a) => a.project.name).join(", ");
|
|
51
|
-
}
|
|
52
|
-
} catch {
|
|
53
|
-
// Ignore errors
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const command = info.command ? pc.dim(`(${info.command})`) : "";
|
|
58
|
-
const workdir = agent.workdir || "-";
|
|
59
|
-
|
|
60
|
-
console.log(
|
|
61
|
-
`${agent.name.padEnd(20)} ${status.padEnd(19)} ${sessionName.padEnd(25)} ${pendingId.padEnd(18)} ${workdir.padEnd(38)} ${assignedProject}`,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (command) {
|
|
65
|
-
console.log(`${"".padEnd(20)} ${command}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
console.log("");
|
|
70
|
-
}
|
package/src/cli/local.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { execSync, spawn, spawnSync } from "node:child_process";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
|
|
5
|
-
const COMPOSE_FILE = "docker/docker-compose.local.yml";
|
|
6
|
-
|
|
7
|
-
interface LocalStackPorts {
|
|
8
|
-
postgres: number;
|
|
9
|
-
valkey: number;
|
|
10
|
-
hub: number;
|
|
11
|
-
admin: number;
|
|
12
|
-
nginx: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function findProjectRoot(): string {
|
|
16
|
-
// Try to find the project root by looking for docker-compose files
|
|
17
|
-
let dir = process.cwd();
|
|
18
|
-
for (let i = 0; i < 10; i++) {
|
|
19
|
-
const composePath = path.join(dir, COMPOSE_FILE);
|
|
20
|
-
try {
|
|
21
|
-
execSync(`test -f "${composePath}"`, { stdio: "ignore" });
|
|
22
|
-
return dir;
|
|
23
|
-
} catch {
|
|
24
|
-
dir = path.dirname(dir);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
throw new Error(
|
|
28
|
-
"Could not find AgentMesh project root. Make sure you're in the agentmesh repository.",
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getContainerStatus(containerName: string): {
|
|
33
|
-
running: boolean;
|
|
34
|
-
healthy: boolean;
|
|
35
|
-
port?: string;
|
|
36
|
-
} {
|
|
37
|
-
try {
|
|
38
|
-
const result = execSync(
|
|
39
|
-
`docker inspect --format='{{.State.Running}}:{{.State.Health.Status}}' ${containerName} 2>/dev/null`,
|
|
40
|
-
{ encoding: "utf-8" },
|
|
41
|
-
).trim();
|
|
42
|
-
const [running, health] = result.split(":");
|
|
43
|
-
return {
|
|
44
|
-
running: running === "true",
|
|
45
|
-
healthy: health === "healthy",
|
|
46
|
-
};
|
|
47
|
-
} catch {
|
|
48
|
-
return { running: false, healthy: false };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getContainerPort(containerName: string, internalPort: number): string | null {
|
|
53
|
-
try {
|
|
54
|
-
const result = execSync(`docker port ${containerName} ${internalPort} 2>/dev/null | head -1`, {
|
|
55
|
-
encoding: "utf-8",
|
|
56
|
-
}).trim();
|
|
57
|
-
// Format: 0.0.0.0:5432 -> 5432
|
|
58
|
-
const match = result.match(/:(\d+)$/);
|
|
59
|
-
return match ? match[1] : null;
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function localUp(options: { detach?: boolean } = {}): Promise<void> {
|
|
66
|
-
const projectRoot = findProjectRoot();
|
|
67
|
-
const composePath = path.join(projectRoot, COMPOSE_FILE);
|
|
68
|
-
|
|
69
|
-
console.log(pc.cyan("Starting AgentMesh local development stack..."));
|
|
70
|
-
console.log();
|
|
71
|
-
|
|
72
|
-
const args = ["compose", "-f", composePath, "up"];
|
|
73
|
-
if (options.detach !== false) {
|
|
74
|
-
args.push("-d");
|
|
75
|
-
}
|
|
76
|
-
args.push("--build");
|
|
77
|
-
|
|
78
|
-
const result = spawnSync("docker", args, {
|
|
79
|
-
cwd: projectRoot,
|
|
80
|
-
stdio: "inherit",
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (result.status !== 0) {
|
|
84
|
-
console.error(pc.red("Failed to start local stack"));
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (options.detach !== false) {
|
|
89
|
-
console.log();
|
|
90
|
-
console.log(pc.green("Local stack started successfully!"));
|
|
91
|
-
console.log();
|
|
92
|
-
await localStatus();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function localDown(): Promise<void> {
|
|
97
|
-
const projectRoot = findProjectRoot();
|
|
98
|
-
const composePath = path.join(projectRoot, COMPOSE_FILE);
|
|
99
|
-
|
|
100
|
-
console.log(pc.cyan("Stopping AgentMesh local development stack..."));
|
|
101
|
-
|
|
102
|
-
const result = spawnSync("docker", ["compose", "-f", composePath, "down"], {
|
|
103
|
-
cwd: projectRoot,
|
|
104
|
-
stdio: "inherit",
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (result.status !== 0) {
|
|
108
|
-
console.error(pc.red("Failed to stop local stack"));
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
console.log(pc.green("Local stack stopped."));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export async function localStatus(): Promise<void> {
|
|
116
|
-
const services = [
|
|
117
|
-
{ name: "postgres", container: "agentmesh_postgres", port: 5432 },
|
|
118
|
-
{ name: "valkey", container: "agentmesh_valkey", port: 6379 },
|
|
119
|
-
{ name: "hub-api", container: "agentmesh_hub_api", port: 3777 },
|
|
120
|
-
{ name: "hub-worker", container: "agentmesh_hub_worker", port: null },
|
|
121
|
-
{ name: "admin", container: "agentmesh_admin", port: 3778 },
|
|
122
|
-
{ name: "nginx", container: "agentmesh_nginx", port: 80 },
|
|
123
|
-
];
|
|
124
|
-
|
|
125
|
-
console.log(pc.bold("AgentMesh Local Stack Status"));
|
|
126
|
-
console.log();
|
|
127
|
-
console.log(pc.dim(`${"Service".padEnd(15) + "Status".padEnd(12) + "Health".padEnd(10)}Port`));
|
|
128
|
-
console.log(pc.dim("-".repeat(50)));
|
|
129
|
-
|
|
130
|
-
let anyRunning = false;
|
|
131
|
-
|
|
132
|
-
for (const service of services) {
|
|
133
|
-
const status = getContainerStatus(service.container);
|
|
134
|
-
const port = service.port ? getContainerPort(service.container, service.port) : null;
|
|
135
|
-
|
|
136
|
-
const statusText = status.running ? pc.green("running") : pc.dim("stopped");
|
|
137
|
-
const healthText = status.running
|
|
138
|
-
? status.healthy
|
|
139
|
-
? pc.green("healthy")
|
|
140
|
-
: pc.yellow("starting")
|
|
141
|
-
: pc.dim("-");
|
|
142
|
-
const portText = port ? pc.cyan(port) : pc.dim("-");
|
|
143
|
-
|
|
144
|
-
console.log(
|
|
145
|
-
`${service.name.padEnd(15)}${statusText.padEnd(20)}${healthText.padEnd(18)}${portText}`,
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
if (status.running) anyRunning = true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
console.log();
|
|
152
|
-
|
|
153
|
-
if (anyRunning) {
|
|
154
|
-
const nginxPort = getContainerPort("agentmesh_nginx", 80) || "3000";
|
|
155
|
-
console.log(pc.bold("Access:"));
|
|
156
|
-
console.log(` Admin UI: ${pc.cyan(`http://localhost:${nginxPort}/admin`)}`);
|
|
157
|
-
console.log(` API: ${pc.cyan(`http://localhost:${nginxPort}/api`)}`);
|
|
158
|
-
console.log();
|
|
159
|
-
console.log(pc.bold("Commands:"));
|
|
160
|
-
console.log(` Stop: ${pc.cyan("agentmesh local down")}`);
|
|
161
|
-
console.log(
|
|
162
|
-
` Logs: ${pc.cyan("docker compose -f docker/docker-compose.local.yml logs -f")}`,
|
|
163
|
-
);
|
|
164
|
-
} else {
|
|
165
|
-
console.log(pc.dim("No services running. Start with: agentmesh local up"));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export async function localLogs(
|
|
170
|
-
options: { follow?: boolean; service?: string } = {},
|
|
171
|
-
): Promise<void> {
|
|
172
|
-
const projectRoot = findProjectRoot();
|
|
173
|
-
const composePath = path.join(projectRoot, COMPOSE_FILE);
|
|
174
|
-
|
|
175
|
-
const args = ["compose", "-f", composePath, "logs"];
|
|
176
|
-
if (options.follow) args.push("-f");
|
|
177
|
-
if (options.service) args.push(options.service);
|
|
178
|
-
|
|
179
|
-
spawn("docker", args, {
|
|
180
|
-
cwd: projectRoot,
|
|
181
|
-
stdio: "inherit",
|
|
182
|
-
});
|
|
183
|
-
}
|