@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/context.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import pc from "picocolors";
|
|
2
|
-
import { getAgentState, loadState } from "../config/loader.js";
|
|
3
|
-
import {
|
|
4
|
-
CONTEXT_DIR,
|
|
5
|
-
deleteContext,
|
|
6
|
-
exportContext,
|
|
7
|
-
importContext,
|
|
8
|
-
listContexts,
|
|
9
|
-
loadContext,
|
|
10
|
-
} from "../context/index.js";
|
|
11
|
-
|
|
12
|
-
export interface ContextOptions {
|
|
13
|
-
output?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function contextCmd(
|
|
17
|
-
action: string,
|
|
18
|
-
nameOrPath?: string,
|
|
19
|
-
options?: ContextOptions,
|
|
20
|
-
): Promise<void> {
|
|
21
|
-
switch (action) {
|
|
22
|
-
case "show":
|
|
23
|
-
await showContext(nameOrPath);
|
|
24
|
-
break;
|
|
25
|
-
case "clear":
|
|
26
|
-
await clearContext(nameOrPath);
|
|
27
|
-
break;
|
|
28
|
-
case "export":
|
|
29
|
-
await exportContextCmd(nameOrPath, options?.output);
|
|
30
|
-
break;
|
|
31
|
-
case "import":
|
|
32
|
-
await importContextCmd(nameOrPath);
|
|
33
|
-
break;
|
|
34
|
-
case "list":
|
|
35
|
-
case "ls":
|
|
36
|
-
await listContextsCmd();
|
|
37
|
-
break;
|
|
38
|
-
case "path":
|
|
39
|
-
console.log(CONTEXT_DIR);
|
|
40
|
-
break;
|
|
41
|
-
default:
|
|
42
|
-
console.log(pc.red(`Unknown action: ${action}`));
|
|
43
|
-
console.log("Available actions: show, clear, export, import, list, path");
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function showContext(name?: string): Promise<void> {
|
|
49
|
-
const agentId = await resolveAgentId(name);
|
|
50
|
-
if (!agentId) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const context = loadContext(agentId);
|
|
55
|
-
if (!context) {
|
|
56
|
-
console.log(pc.yellow(`No saved context found for agent.`));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log(pc.bold(`Context for ${context.agentName} (${context.agentId}):`));
|
|
61
|
-
console.log(pc.dim(`Saved at: ${new Date(context.savedAt).toLocaleString()}`));
|
|
62
|
-
console.log();
|
|
63
|
-
|
|
64
|
-
// Working state
|
|
65
|
-
console.log(pc.bold("Working State:"));
|
|
66
|
-
console.log(` Directory: ${context.workingState.workdir}`);
|
|
67
|
-
if (context.workingState.gitBranch) {
|
|
68
|
-
console.log(` Git branch: ${context.workingState.gitBranch}`);
|
|
69
|
-
}
|
|
70
|
-
if (context.workingState.recentFiles.length > 0) {
|
|
71
|
-
console.log(` Recent files: ${context.workingState.recentFiles.slice(0, 5).join(", ")}`);
|
|
72
|
-
}
|
|
73
|
-
console.log();
|
|
74
|
-
|
|
75
|
-
// Tasks
|
|
76
|
-
const activeTasks = context.tasks.tasks.filter(
|
|
77
|
-
(t) => t.status === "in_progress" || t.status === "pending",
|
|
78
|
-
);
|
|
79
|
-
if (activeTasks.length > 0 || context.tasks.currentGoal) {
|
|
80
|
-
console.log(pc.bold("Tasks:"));
|
|
81
|
-
if (context.tasks.currentGoal) {
|
|
82
|
-
console.log(` Goal: ${context.tasks.currentGoal}`);
|
|
83
|
-
}
|
|
84
|
-
for (const task of activeTasks) {
|
|
85
|
-
const icon = task.status === "in_progress" ? pc.yellow(">") : pc.dim("-");
|
|
86
|
-
const priority =
|
|
87
|
-
task.priority === "high" ? pc.red(`[${task.priority}]`) : pc.dim(`[${task.priority}]`);
|
|
88
|
-
console.log(` ${icon} ${task.content} ${priority}`);
|
|
89
|
-
}
|
|
90
|
-
console.log();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Conversation
|
|
94
|
-
if (context.conversation.topics.length > 0 || context.conversation.accomplishments.length > 0) {
|
|
95
|
-
console.log(pc.bold("Conversation:"));
|
|
96
|
-
if (context.conversation.topics.length > 0) {
|
|
97
|
-
console.log(` Topics: ${context.conversation.topics.join(", ")}`);
|
|
98
|
-
}
|
|
99
|
-
if (context.conversation.accomplishments.length > 0) {
|
|
100
|
-
console.log(" Accomplishments:");
|
|
101
|
-
for (const acc of context.conversation.accomplishments.slice(0, 5)) {
|
|
102
|
-
console.log(` - ${acc}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
console.log();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Custom context
|
|
109
|
-
if (Object.keys(context.custom).length > 0) {
|
|
110
|
-
console.log(pc.bold("Custom Context:"));
|
|
111
|
-
console.log(JSON.stringify(context.custom, null, 2));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function clearContext(name?: string): Promise<void> {
|
|
116
|
-
const agentId = await resolveAgentId(name);
|
|
117
|
-
if (!agentId) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const deleted = deleteContext(agentId);
|
|
122
|
-
if (deleted) {
|
|
123
|
-
console.log(pc.green(`Context cleared for agent.`));
|
|
124
|
-
} else {
|
|
125
|
-
console.log(pc.yellow(`No context found to clear.`));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
async function exportContextCmd(name?: string, outputPath?: string): Promise<void> {
|
|
130
|
-
const agentId = await resolveAgentId(name);
|
|
131
|
-
if (!agentId) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const context = loadContext(agentId);
|
|
136
|
-
if (!context) {
|
|
137
|
-
console.log(pc.yellow(`No saved context found for agent.`));
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const output = outputPath || `${context.agentName}-context.json`;
|
|
142
|
-
const success = exportContext(agentId, output);
|
|
143
|
-
|
|
144
|
-
if (success) {
|
|
145
|
-
console.log(pc.green(`Context exported to: ${output}`));
|
|
146
|
-
} else {
|
|
147
|
-
console.log(pc.red(`Failed to export context.`));
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async function importContextCmd(inputPath?: string): Promise<void> {
|
|
153
|
-
if (!inputPath) {
|
|
154
|
-
console.log(pc.red("Please specify a file path to import."));
|
|
155
|
-
console.log("Usage: agentmesh context import <file>");
|
|
156
|
-
process.exit(1);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const context = importContext(inputPath);
|
|
160
|
-
if (context) {
|
|
161
|
-
console.log(pc.green(`Context imported for agent: ${context.agentName} (${context.agentId})`));
|
|
162
|
-
} else {
|
|
163
|
-
console.log(pc.red(`Failed to import context from: ${inputPath}`));
|
|
164
|
-
process.exit(1);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function listContextsCmd(): Promise<void> {
|
|
169
|
-
const contexts = listContexts();
|
|
170
|
-
|
|
171
|
-
if (contexts.length === 0) {
|
|
172
|
-
console.log(pc.yellow("No saved contexts found."));
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
console.log(pc.bold("Saved Contexts:"));
|
|
177
|
-
console.log();
|
|
178
|
-
|
|
179
|
-
for (const ctx of contexts) {
|
|
180
|
-
const context = loadContext(ctx.agentId);
|
|
181
|
-
if (!context) continue;
|
|
182
|
-
|
|
183
|
-
console.log(` ${pc.cyan(context.agentName)} (${pc.dim(ctx.agentId.slice(0, 8))}...)`);
|
|
184
|
-
console.log(` Saved: ${new Date(ctx.savedAt).toLocaleString()}`);
|
|
185
|
-
if (context.tasks.currentGoal) {
|
|
186
|
-
console.log(` Goal: ${context.tasks.currentGoal}`);
|
|
187
|
-
}
|
|
188
|
-
console.log();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async function resolveAgentId(name?: string): Promise<string | null> {
|
|
193
|
-
// If no name provided, try to get from environment
|
|
194
|
-
if (!name) {
|
|
195
|
-
const envAgentId = process.env.AGENTMESH_AGENT_ID;
|
|
196
|
-
if (envAgentId) {
|
|
197
|
-
return envAgentId;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Try to find single running agent
|
|
201
|
-
const state = loadState();
|
|
202
|
-
if (state.agents.length === 1) {
|
|
203
|
-
return state.agents[0].agentId;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (state.agents.length === 0) {
|
|
207
|
-
console.log(pc.yellow("No running agents found."));
|
|
208
|
-
console.log("Usage: agentmesh context show <name>");
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
console.log(pc.yellow("Multiple agents running. Please specify a name."));
|
|
213
|
-
console.log("Usage: agentmesh context show <name>");
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Try to find by name
|
|
218
|
-
const agentState = getAgentState(name);
|
|
219
|
-
if (agentState) {
|
|
220
|
-
return agentState.agentId;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Maybe it's already an agent ID
|
|
224
|
-
const context = loadContext(name);
|
|
225
|
-
if (context) {
|
|
226
|
-
return name;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
console.log(pc.red(`Agent not found: ${name}`));
|
|
230
|
-
return null;
|
|
231
|
-
}
|
package/src/cli/deploy.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { execSync, spawnSync } from "node:child_process";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
|
|
5
|
-
function findProjectRoot(): string {
|
|
6
|
-
let dir = process.cwd();
|
|
7
|
-
for (let i = 0; i < 10; i++) {
|
|
8
|
-
const scriptsDir = path.join(dir, "scripts");
|
|
9
|
-
const buildScript = path.join(scriptsDir, "build.sh");
|
|
10
|
-
try {
|
|
11
|
-
execSync(`test -f "${buildScript}"`, { stdio: "ignore" });
|
|
12
|
-
return dir;
|
|
13
|
-
} catch {
|
|
14
|
-
dir = path.dirname(dir);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
throw new Error(
|
|
18
|
-
"Could not find AgentMesh project root. Make sure you're in the agentmesh repository.",
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type DeployEnvironment = "dev" | "staging" | "prod";
|
|
23
|
-
|
|
24
|
-
export interface DeployOptions {
|
|
25
|
-
environment: DeployEnvironment;
|
|
26
|
-
skipBuild?: boolean;
|
|
27
|
-
skipPush?: boolean;
|
|
28
|
-
skipTests?: boolean;
|
|
29
|
-
dryRun?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function deploy(options: DeployOptions): Promise<void> {
|
|
33
|
-
const projectRoot = findProjectRoot();
|
|
34
|
-
|
|
35
|
-
console.log(pc.cyan(`Deploying to ${options.environment}...`));
|
|
36
|
-
console.log();
|
|
37
|
-
|
|
38
|
-
// Safety checks
|
|
39
|
-
if (options.environment === "prod") {
|
|
40
|
-
console.log(pc.red("WARNING: You are about to deploy to PRODUCTION"));
|
|
41
|
-
console.log(pc.yellow("Make sure all tests pass and staging deployment is verified."));
|
|
42
|
-
console.log();
|
|
43
|
-
console.log(pc.dim("Press Ctrl+C to cancel, or wait 10 seconds to continue..."));
|
|
44
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
45
|
-
console.log();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (options.dryRun) {
|
|
49
|
-
console.log(pc.yellow("[DRY RUN] No actual deployment will be performed"));
|
|
50
|
-
console.log();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Step 1: Build
|
|
54
|
-
if (!options.skipBuild) {
|
|
55
|
-
console.log(pc.bold("Step 1: Building..."));
|
|
56
|
-
|
|
57
|
-
const buildScript = path.join(projectRoot, "scripts", "build.sh");
|
|
58
|
-
const buildArgs = [buildScript, options.environment];
|
|
59
|
-
|
|
60
|
-
if (options.dryRun) {
|
|
61
|
-
console.log(pc.dim(`Would run: ${buildArgs.join(" ")}`));
|
|
62
|
-
} else {
|
|
63
|
-
const result = spawnSync("bash", buildArgs, {
|
|
64
|
-
cwd: projectRoot,
|
|
65
|
-
stdio: "inherit",
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (result.status !== 0) {
|
|
69
|
-
console.error(pc.red("Build failed. Aborting deployment."));
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
console.log();
|
|
74
|
-
} else {
|
|
75
|
-
console.log(pc.dim("Skipping build (--skip-build)"));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Step 2: Push to registry
|
|
79
|
-
if (!options.skipPush) {
|
|
80
|
-
console.log(pc.bold("Step 2: Pushing to registry..."));
|
|
81
|
-
|
|
82
|
-
// Get the image tag from git commit
|
|
83
|
-
let tag: string;
|
|
84
|
-
try {
|
|
85
|
-
const commit = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
|
|
86
|
-
tag = `${options.environment}-${commit}`;
|
|
87
|
-
} catch {
|
|
88
|
-
console.error(pc.red("Failed to get git commit. Are you in a git repository?"));
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const pushScript = path.join(projectRoot, "scripts", "push.sh");
|
|
93
|
-
const pushArgs = [pushScript, tag];
|
|
94
|
-
|
|
95
|
-
if (options.dryRun) {
|
|
96
|
-
console.log(pc.dim(`Would run: ${pushArgs.join(" ")}`));
|
|
97
|
-
} else {
|
|
98
|
-
const result = spawnSync("bash", pushArgs, {
|
|
99
|
-
cwd: projectRoot,
|
|
100
|
-
stdio: "inherit",
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
if (result.status !== 0) {
|
|
104
|
-
console.error(pc.red("Push failed. Aborting deployment."));
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
console.log();
|
|
109
|
-
} else {
|
|
110
|
-
console.log(pc.dim("Skipping push (--skip-push)"));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Step 3: Deploy to server
|
|
114
|
-
console.log(pc.bold("Step 3: Deploying to server..."));
|
|
115
|
-
|
|
116
|
-
let tag: string;
|
|
117
|
-
try {
|
|
118
|
-
const commit = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
|
|
119
|
-
tag = `${options.environment}-${commit}`;
|
|
120
|
-
} catch {
|
|
121
|
-
console.error(pc.red("Failed to get git commit."));
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const deployScript = path.join(projectRoot, "scripts", "deploy.sh");
|
|
126
|
-
const deployArgs = [deployScript, options.environment, tag];
|
|
127
|
-
|
|
128
|
-
if (options.dryRun) {
|
|
129
|
-
console.log(pc.dim(`Would run: ${deployArgs.join(" ")}`));
|
|
130
|
-
} else {
|
|
131
|
-
const result = spawnSync("bash", deployArgs, {
|
|
132
|
-
cwd: projectRoot,
|
|
133
|
-
stdio: "inherit",
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
if (result.status !== 0) {
|
|
137
|
-
console.error(pc.red("Deployment failed."));
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
console.log();
|
|
143
|
-
console.log(pc.green(`Successfully deployed to ${options.environment}!`));
|
|
144
|
-
|
|
145
|
-
// Show access info
|
|
146
|
-
const urls: Record<DeployEnvironment, string> = {
|
|
147
|
-
dev: "https://agentmeshhq.dev",
|
|
148
|
-
staging: "https://staging.agentmesh.ai",
|
|
149
|
-
prod: "https://agentmesh.ai",
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
console.log();
|
|
153
|
-
console.log(pc.bold("Access:"));
|
|
154
|
-
console.log(` URL: ${pc.cyan(urls[options.environment])}`);
|
|
155
|
-
}
|