@agentmeshhq/agent 0.1.17 → 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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/dist/__tests__/orphan-process.test.d.ts +11 -0
  4. package/dist/__tests__/orphan-process.test.js +286 -0
  5. package/dist/__tests__/orphan-process.test.js.map +1 -0
  6. package/dist/__tests__/runner.test.js +16 -0
  7. package/dist/__tests__/runner.test.js.map +1 -1
  8. package/dist/__tests__/watchdog.test.js +138 -12
  9. package/dist/__tests__/watchdog.test.js.map +1 -1
  10. package/dist/cli/index.js +2 -1
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/start.d.ts +2 -1
  13. package/dist/cli/start.js +6 -3
  14. package/dist/cli/start.js.map +1 -1
  15. package/dist/cli/status.js +11 -0
  16. package/dist/cli/status.js.map +1 -1
  17. package/dist/cli/stop.js +7 -2
  18. package/dist/cli/stop.js.map +1 -1
  19. package/dist/config/schema.d.ts +4 -2
  20. package/dist/core/daemon/assignment-message.d.ts +12 -0
  21. package/dist/core/daemon/assignment-message.js +36 -0
  22. package/dist/core/daemon/assignment-message.js.map +1 -0
  23. package/dist/core/daemon/bootstrap.d.ts +35 -0
  24. package/dist/core/daemon/bootstrap.js +52 -0
  25. package/dist/core/daemon/bootstrap.js.map +1 -0
  26. package/dist/core/daemon/crash-log.d.ts +16 -0
  27. package/dist/core/daemon/crash-log.js +24 -0
  28. package/dist/core/daemon/crash-log.js.map +1 -0
  29. package/dist/core/daemon/health-policy.d.ts +21 -0
  30. package/dist/core/daemon/health-policy.js +32 -0
  31. package/dist/core/daemon/health-policy.js.map +1 -0
  32. package/dist/core/daemon/sandbox-config.d.ts +9 -0
  33. package/dist/core/daemon/sandbox-config.js +17 -0
  34. package/dist/core/daemon/sandbox-config.js.map +1 -0
  35. package/dist/core/daemon/state.d.ts +33 -0
  36. package/dist/core/daemon/state.js +77 -0
  37. package/dist/core/daemon/state.js.map +1 -0
  38. package/dist/core/daemon/tmux-session.d.ts +17 -0
  39. package/dist/core/daemon/tmux-session.js +34 -0
  40. package/dist/core/daemon/tmux-session.js.map +1 -0
  41. package/dist/core/daemon/workspace.d.ts +10 -0
  42. package/dist/core/daemon/workspace.js +51 -0
  43. package/dist/core/daemon/workspace.js.map +1 -0
  44. package/dist/core/daemon.d.ts +4 -7
  45. package/dist/core/daemon.js +143 -259
  46. package/dist/core/daemon.js.map +1 -1
  47. package/dist/core/injector.js +6 -0
  48. package/dist/core/injector.js.map +1 -1
  49. package/dist/core/registry.js +1 -1
  50. package/dist/core/registry.js.map +1 -1
  51. package/dist/core/runner/build.d.ts +9 -0
  52. package/dist/core/runner/build.js +53 -0
  53. package/dist/core/runner/build.js.map +1 -0
  54. package/dist/core/runner/detect.d.ts +5 -0
  55. package/dist/core/runner/detect.js +14 -0
  56. package/dist/core/runner/detect.js.map +1 -0
  57. package/dist/core/runner/index.d.ts +5 -0
  58. package/dist/core/runner/index.js +5 -0
  59. package/dist/core/runner/index.js.map +1 -0
  60. package/dist/core/runner/model.d.ts +5 -0
  61. package/dist/core/runner/model.js +7 -0
  62. package/dist/core/runner/model.js.map +1 -0
  63. package/dist/core/runner/opencode-models.d.ts +15 -0
  64. package/dist/core/runner/opencode-models.js +70 -0
  65. package/dist/core/runner/opencode-models.js.map +1 -0
  66. package/dist/core/runner/types.d.ts +19 -0
  67. package/dist/core/runner/types.js +8 -0
  68. package/dist/core/runner/types.js.map +1 -0
  69. package/dist/core/runner.d.ts +5 -47
  70. package/dist/core/runner.js +5 -167
  71. package/dist/core/runner.js.map +1 -1
  72. package/dist/core/tmux-runtime.d.ts +13 -0
  73. package/dist/core/tmux-runtime.js +72 -0
  74. package/dist/core/tmux-runtime.js.map +1 -0
  75. package/dist/core/tmux.d.ts +7 -1
  76. package/dist/core/tmux.js +75 -45
  77. package/dist/core/tmux.js.map +1 -1
  78. package/dist/core/watchdog.d.ts +18 -1
  79. package/dist/core/watchdog.js +78 -29
  80. package/dist/core/watchdog.js.map +1 -1
  81. package/package.json +30 -11
  82. package/dist/cli/inbox.d.ts +0 -5
  83. package/dist/cli/inbox.js +0 -123
  84. package/dist/cli/inbox.js.map +0 -1
  85. package/dist/cli/issue.d.ts +0 -42
  86. package/dist/cli/issue.js +0 -297
  87. package/dist/cli/issue.js.map +0 -1
  88. package/dist/cli/ready.d.ts +0 -5
  89. package/dist/cli/ready.js +0 -131
  90. package/dist/cli/ready.js.map +0 -1
  91. package/dist/cli/sync.d.ts +0 -8
  92. package/dist/cli/sync.js +0 -154
  93. package/dist/cli/sync.js.map +0 -1
  94. package/dist/core/issue-cache.d.ts +0 -44
  95. package/dist/core/issue-cache.js +0 -75
  96. package/dist/core/issue-cache.js.map +0 -1
  97. package/src/__tests__/context.test.ts +0 -464
  98. package/src/__tests__/injector.test.ts +0 -29
  99. package/src/__tests__/jwt.test.ts +0 -112
  100. package/src/__tests__/loader.test.ts +0 -239
  101. package/src/__tests__/runner.test.ts +0 -104
  102. package/src/__tests__/sandbox.test.ts +0 -435
  103. package/src/__tests__/watchdog.test.ts +0 -368
  104. package/src/cli/attach.ts +0 -22
  105. package/src/cli/build.ts +0 -145
  106. package/src/cli/config.ts +0 -148
  107. package/src/cli/context.ts +0 -231
  108. package/src/cli/deploy.ts +0 -155
  109. package/src/cli/index.ts +0 -375
  110. package/src/cli/init.ts +0 -75
  111. package/src/cli/list.ts +0 -70
  112. package/src/cli/local.ts +0 -183
  113. package/src/cli/logs.ts +0 -64
  114. package/src/cli/migrate.ts +0 -212
  115. package/src/cli/nudge.ts +0 -81
  116. package/src/cli/restart.ts +0 -59
  117. package/src/cli/slack.ts +0 -70
  118. package/src/cli/start.ts +0 -115
  119. package/src/cli/status.ts +0 -91
  120. package/src/cli/stop.ts +0 -48
  121. package/src/cli/test.ts +0 -143
  122. package/src/cli/token.ts +0 -188
  123. package/src/cli/whoami.ts +0 -142
  124. package/src/config/loader.ts +0 -121
  125. package/src/config/schema.ts +0 -68
  126. package/src/context/handoff.ts +0 -122
  127. package/src/context/index.ts +0 -8
  128. package/src/context/schema.ts +0 -111
  129. package/src/context/storage.ts +0 -197
  130. package/src/core/daemon.ts +0 -1308
  131. package/src/core/heartbeat.ts +0 -129
  132. package/src/core/injector.ts +0 -292
  133. package/src/core/registry.ts +0 -159
  134. package/src/core/runner.ts +0 -225
  135. package/src/core/sandbox.ts +0 -547
  136. package/src/core/session-id.ts +0 -111
  137. package/src/core/tmux.ts +0 -405
  138. package/src/core/watchdog.ts +0 -238
  139. package/src/core/websocket.ts +0 -94
  140. package/src/index.ts +0 -10
  141. package/src/utils/jwt.ts +0 -87
  142. package/tsconfig.json +0 -8
  143. package/vitest.config.ts +0 -12
package/src/cli/index.ts DELETED
@@ -1,375 +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("--no-context", "Start fresh without restoring previous context")
57
- .option("--auto-setup", "Auto-clone repository for project assignments")
58
- .option("--serve", "Run opencode serve instead of tmux TUI (for Integration Service)")
59
- .option("--serve-port <port>", "Port for opencode serve (default: 3001)", "3001")
60
- .option("--sandbox", "Run agent in Docker sandbox container with filesystem isolation")
61
- .option(
62
- "--sandbox-image <image>",
63
- "Docker image for sandbox (default: agentmesh/agent-sandbox:latest)",
64
- )
65
- .option("--sandbox-cpu <limit>", "CPU limit for sandbox (default: 1)")
66
- .option("--sandbox-memory <limit>", "Memory limit for sandbox (default: 2g)")
67
- .action(async (options) => {
68
- try {
69
- // Parse serve port as number
70
- if (options.servePort) {
71
- options.servePort = parseInt(options.servePort, 10);
72
- }
73
- await start(options);
74
- } catch (error) {
75
- console.error(pc.red((error as Error).message));
76
- process.exit(1);
77
- }
78
- });
79
-
80
- program
81
- .command("stop")
82
- .description("Stop an agent")
83
- .argument("<name>", "Agent name")
84
- .action(async (name) => {
85
- try {
86
- await stop(name);
87
- } catch (error) {
88
- console.error(pc.red((error as Error).message));
89
- process.exit(1);
90
- }
91
- });
92
-
93
- program
94
- .command("list")
95
- .alias("ls")
96
- .description("List running agents")
97
- .action(async () => {
98
- try {
99
- await list();
100
- } catch (error) {
101
- console.error(pc.red((error as Error).message));
102
- process.exit(1);
103
- }
104
- });
105
-
106
- program
107
- .command("attach")
108
- .description("Attach to an agent's tmux session")
109
- .argument("<name>", "Agent name")
110
- .action((name) => {
111
- try {
112
- attach(name);
113
- } catch (error) {
114
- console.error(pc.red((error as Error).message));
115
- process.exit(1);
116
- }
117
- });
118
-
119
- program
120
- .command("nudge")
121
- .description("Send a nudge to an agent")
122
- .argument("<name>", "Agent name")
123
- .argument("<message>", "Message to send")
124
- .action(async (name, message) => {
125
- try {
126
- await nudge(name, message);
127
- } catch (error) {
128
- console.error(pc.red((error as Error).message));
129
- process.exit(1);
130
- }
131
- });
132
-
133
- program
134
- .command("whoami")
135
- .description("Show current agent identity and status")
136
- .argument("[name]", "Agent name (optional)")
137
- .action(async (name) => {
138
- try {
139
- await whoami(name);
140
- } catch (error) {
141
- console.error(pc.red((error as Error).message));
142
- process.exit(1);
143
- }
144
- });
145
-
146
- program
147
- .command("token")
148
- .description("Manage agent tokens")
149
- .argument("[action]", "Action: show (default), refresh, info")
150
- .option("-n, --name <name>", "Agent name")
151
- .action(async (action, options) => {
152
- try {
153
- await token(action || "show", options.name);
154
- } catch (error) {
155
- console.error(pc.red((error as Error).message));
156
- process.exit(1);
157
- }
158
- });
159
-
160
- program
161
- .command("status")
162
- .description("Show AgentMesh status and health")
163
- .action(async () => {
164
- try {
165
- await status();
166
- } catch (error) {
167
- console.error(pc.red((error as Error).message));
168
- process.exit(1);
169
- }
170
- });
171
-
172
- program
173
- .command("logs")
174
- .description("View agent session logs")
175
- .argument("<name>", "Agent name")
176
- .option("-f, --follow", "Follow log output (attach read-only)")
177
- .option("-n, --lines <number>", "Number of lines to show", "50")
178
- .action(async (name, options) => {
179
- try {
180
- await logs(name, { follow: options.follow, lines: parseInt(options.lines, 10) });
181
- } catch (error) {
182
- console.error(pc.red((error as Error).message));
183
- process.exit(1);
184
- }
185
- });
186
-
187
- program
188
- .command("restart")
189
- .description("Restart an agent (preserves agent ID and runtime model)")
190
- .argument("<name>", "Agent name")
191
- .option("-m, --model <model>", "Override the runtime model")
192
- .action(async (name, options) => {
193
- try {
194
- await restart(name, { model: options.model });
195
- } catch (error) {
196
- console.error(pc.red((error as Error).message));
197
- process.exit(1);
198
- }
199
- });
200
-
201
- program
202
- .command("config")
203
- .description("View or edit configuration")
204
- .argument("[action]", "Action: show (default), get, set, edit, path")
205
- .argument("[key]", "Config key (for get/set)")
206
- .argument("[value]", "Config value (for set)")
207
- .action(async (action, key, value) => {
208
- try {
209
- await configCmd(action || "show", key, value);
210
- } catch (error) {
211
- console.error(pc.red((error as Error).message));
212
- process.exit(1);
213
- }
214
- });
215
-
216
- program
217
- .command("context")
218
- .description("Manage agent context persistence")
219
- .argument("[action]", "Action: show (default), clear, export, import, list, path")
220
- .argument("[name]", "Agent name or file path (for import)")
221
- .option("-o, --output <path>", "Output file path (for export)")
222
- .action(async (action, name, options) => {
223
- try {
224
- await contextCmd(action || "show", name, options);
225
- } catch (error) {
226
- console.error(pc.red((error as Error).message));
227
- process.exit(1);
228
- }
229
- });
230
-
231
- program
232
- .command("slack")
233
- .description("Interact with Slack")
234
- .argument("[action]", "Action: respond")
235
- .argument("[channel]", "Slack channel ID")
236
- .argument("[message]", "Message to send")
237
- .option("-n, --name <name>", "Agent name (default: concierge)")
238
- .action(async (action, channel, message, options) => {
239
- try {
240
- await slack(action || "help", channel, message, options);
241
- } catch (error) {
242
- console.error(pc.red((error as Error).message));
243
- process.exit(1);
244
- }
245
- });
246
-
247
- // Local development stack commands
248
- const localCmd = program
249
- .command("local")
250
- .description("Manage local development stack (Postgres, Valkey, Hub)");
251
-
252
- localCmd
253
- .command("up")
254
- .description("Start local development stack")
255
- .option("--no-detach", "Run in foreground")
256
- .action(async (options) => {
257
- try {
258
- await localUp({ detach: options.detach });
259
- } catch (error) {
260
- console.error(pc.red((error as Error).message));
261
- process.exit(1);
262
- }
263
- });
264
-
265
- localCmd
266
- .command("down")
267
- .description("Stop local development stack")
268
- .action(async () => {
269
- try {
270
- await localDown();
271
- } catch (error) {
272
- console.error(pc.red((error as Error).message));
273
- process.exit(1);
274
- }
275
- });
276
-
277
- localCmd
278
- .command("status")
279
- .description("Show local stack status and ports")
280
- .action(async () => {
281
- try {
282
- await localStatus();
283
- } catch (error) {
284
- console.error(pc.red((error as Error).message));
285
- process.exit(1);
286
- }
287
- });
288
-
289
- localCmd
290
- .command("logs")
291
- .description("View local stack logs")
292
- .option("-f, --follow", "Follow log output")
293
- .option("-s, --service <name>", "Specific service to show logs for")
294
- .action(async (options) => {
295
- try {
296
- await localLogs({ follow: options.follow, service: options.service });
297
- } catch (error) {
298
- console.error(pc.red((error as Error).message));
299
- process.exit(1);
300
- }
301
- });
302
-
303
- // Build commands
304
- program
305
- .command("build")
306
- .description("Build packages or Docker images")
307
- .option("--docker", "Build Docker images instead of packages")
308
- .option("-p, --package <name>", "Build specific package")
309
- .option("--clean", "Clean build artifacts before building")
310
- .action(async (options) => {
311
- try {
312
- await build(options);
313
- } catch (error) {
314
- console.error(pc.red((error as Error).message));
315
- process.exit(1);
316
- }
317
- });
318
-
319
- // Test commands
320
- program
321
- .command("test")
322
- .description("Run tests")
323
- .option("-p, --package <name>", "Test specific package")
324
- .option("--e2e", "Run E2E tests")
325
- .option("-w, --watch", "Watch mode")
326
- .option("--coverage", "Generate coverage report")
327
- .option("-u, --update-snapshots", "Update test snapshots")
328
- .action(async (options) => {
329
- try {
330
- await test(options);
331
- } catch (error) {
332
- console.error(pc.red((error as Error).message));
333
- process.exit(1);
334
- }
335
- });
336
-
337
- // Migration commands
338
- program
339
- .command("migrate")
340
- .description("Run database migrations")
341
- .option("--dev", "Run against agentmeshhq.dev")
342
- .option("--staging", "Run against staging")
343
- .option("--generate", "Generate migration from schema changes")
344
- .option("--status", "Show migration status")
345
- .action(async (options) => {
346
- try {
347
- await migrate(options);
348
- } catch (error) {
349
- console.error(pc.red((error as Error).message));
350
- process.exit(1);
351
- }
352
- });
353
-
354
- // Deploy commands
355
- program
356
- .command("deploy")
357
- .description("Deploy to environment")
358
- .argument("<environment>", "Target environment: dev, staging, prod")
359
- .option("--skip-build", "Skip build step")
360
- .option("--skip-push", "Skip push to registry")
361
- .option("--dry-run", "Show what would be done without executing")
362
- .action(async (environment, options) => {
363
- try {
364
- if (!["dev", "staging", "prod"].includes(environment)) {
365
- console.error(pc.red(`Invalid environment: ${environment}. Use: dev, staging, or prod`));
366
- process.exit(1);
367
- }
368
- await deploy({ environment, ...options });
369
- } catch (error) {
370
- console.error(pc.red((error as Error).message));
371
- process.exit(1);
372
- }
373
- });
374
-
375
- 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
- }