@rallycry/conveyor-agent 5.9.1 → 5.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X2QE27GN.js → chunk-MTIMRYLD.js} +99 -95
- package/dist/chunk-MTIMRYLD.js.map +1 -0
- package/dist/cli.js +2 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-X2QE27GN.js.map +0 -1
|
@@ -1,3 +1,62 @@
|
|
|
1
|
+
// src/setup/commands.ts
|
|
2
|
+
import { spawn, execSync } from "child_process";
|
|
3
|
+
function runSetupCommand(cmd, cwd, onOutput) {
|
|
4
|
+
return new Promise((resolve2, reject) => {
|
|
5
|
+
const child = spawn("sh", ["-c", cmd], {
|
|
6
|
+
cwd,
|
|
7
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
8
|
+
env: { ...process.env }
|
|
9
|
+
});
|
|
10
|
+
child.stdout.on("data", (chunk) => {
|
|
11
|
+
onOutput("stdout", chunk.toString());
|
|
12
|
+
});
|
|
13
|
+
child.stderr.on("data", (chunk) => {
|
|
14
|
+
onOutput("stderr", chunk.toString());
|
|
15
|
+
});
|
|
16
|
+
child.on("close", (code) => {
|
|
17
|
+
if (code === 0) {
|
|
18
|
+
resolve2();
|
|
19
|
+
} else {
|
|
20
|
+
reject(new Error(`Setup command exited with code ${code}`));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
child.on("error", (err) => {
|
|
24
|
+
reject(err);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
var AUTH_TOKEN_TIMEOUT_MS = 3e4;
|
|
29
|
+
function runAuthTokenCommand(cmd, userEmail, cwd) {
|
|
30
|
+
try {
|
|
31
|
+
const output = execSync(`${cmd} ${JSON.stringify(userEmail)}`, {
|
|
32
|
+
cwd,
|
|
33
|
+
timeout: AUTH_TOKEN_TIMEOUT_MS,
|
|
34
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
35
|
+
env: { ...process.env }
|
|
36
|
+
});
|
|
37
|
+
const token = output.toString().trim();
|
|
38
|
+
return token || null;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function runStartCommand(cmd, cwd, onOutput) {
|
|
44
|
+
const child = spawn("sh", ["-c", cmd], {
|
|
45
|
+
cwd,
|
|
46
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
47
|
+
detached: true,
|
|
48
|
+
env: { ...process.env }
|
|
49
|
+
});
|
|
50
|
+
child.stdout.on("data", (chunk) => {
|
|
51
|
+
onOutput("stdout", chunk.toString());
|
|
52
|
+
});
|
|
53
|
+
child.stderr.on("data", (chunk) => {
|
|
54
|
+
onOutput("stderr", chunk.toString());
|
|
55
|
+
});
|
|
56
|
+
child.unref();
|
|
57
|
+
return child;
|
|
58
|
+
}
|
|
59
|
+
|
|
1
60
|
// src/connection/task-connection.ts
|
|
2
61
|
import { io } from "socket.io-client";
|
|
3
62
|
|
|
@@ -161,6 +220,10 @@ var ConveyorConnection = class _ConveyorConnection {
|
|
|
161
220
|
this.socket.on("agentRunner:runStartCommand", () => {
|
|
162
221
|
if (this.runStartCommandCallback) this.runStartCommandCallback();
|
|
163
222
|
});
|
|
223
|
+
this.socket.on(
|
|
224
|
+
"agentRunner:runAuthTokenCommand",
|
|
225
|
+
(data, cb) => this.handleRunAuthTokenCommand(data.userEmail, cb)
|
|
226
|
+
);
|
|
164
227
|
this.socket.on("connect", () => {
|
|
165
228
|
if (!settled) {
|
|
166
229
|
settled = true;
|
|
@@ -260,6 +323,33 @@ var ConveyorConnection = class _ConveyorConnection {
|
|
|
260
323
|
onRunStartCommand(callback) {
|
|
261
324
|
this.runStartCommandCallback = callback;
|
|
262
325
|
}
|
|
326
|
+
handleRunAuthTokenCommand(userEmail, cb) {
|
|
327
|
+
try {
|
|
328
|
+
if (process.env.CODESPACES !== "true") {
|
|
329
|
+
cb({ ok: false, error: "Auth token command only available in codespace environments" });
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const authCmd = process.env.CONVEYOR_AUTH_TOKEN_COMMAND;
|
|
333
|
+
if (!authCmd) {
|
|
334
|
+
cb({ ok: false, error: "CONVEYOR_AUTH_TOKEN_COMMAND not configured" });
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const token = runAuthTokenCommand(authCmd, userEmail, this.config.workspaceDir);
|
|
338
|
+
if (!token) {
|
|
339
|
+
cb({
|
|
340
|
+
ok: false,
|
|
341
|
+
error: `Auth token command returned empty output. Command: ${authCmd}, Working Dir: ${this.config.workspaceDir}`
|
|
342
|
+
});
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
cb({ ok: true, token });
|
|
346
|
+
} catch (error) {
|
|
347
|
+
cb({
|
|
348
|
+
ok: false,
|
|
349
|
+
error: error instanceof Error ? error.message : "Auth token command failed"
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
263
353
|
emitModeChanged(agentMode) {
|
|
264
354
|
if (!this.socket) return;
|
|
265
355
|
this.socket.emit("agentRunner:modeChanged", { agentMode });
|
|
@@ -272,10 +362,6 @@ var ConveyorConnection = class _ConveyorConnection {
|
|
|
272
362
|
if (!this.socket) return;
|
|
273
363
|
this.socket.emit("agentRunner:statusUpdate", { status });
|
|
274
364
|
}
|
|
275
|
-
emitAuthToken(token) {
|
|
276
|
-
if (!this.socket) return;
|
|
277
|
-
this.socket.emit("agentRunner:authToken", { token });
|
|
278
|
-
}
|
|
279
365
|
emitRateLimitPause(resetsAt) {
|
|
280
366
|
if (!this.socket) return;
|
|
281
367
|
this.socket.emit("agentRunner:rateLimitPause", { resetsAt });
|
|
@@ -509,7 +595,7 @@ var ProjectConnection = class {
|
|
|
509
595
|
};
|
|
510
596
|
|
|
511
597
|
// src/runner/worktree.ts
|
|
512
|
-
import { execSync } from "child_process";
|
|
598
|
+
import { execSync as execSync2 } from "child_process";
|
|
513
599
|
import { existsSync } from "fs";
|
|
514
600
|
import { join } from "path";
|
|
515
601
|
var WORKTREE_DIR = ".worktrees";
|
|
@@ -521,7 +607,7 @@ function ensureWorktree(projectDir, taskId, branch) {
|
|
|
521
607
|
if (existsSync(worktreePath)) {
|
|
522
608
|
if (branch) {
|
|
523
609
|
try {
|
|
524
|
-
|
|
610
|
+
execSync2(`git checkout --detach origin/${branch}`, {
|
|
525
611
|
cwd: worktreePath,
|
|
526
612
|
stdio: "ignore"
|
|
527
613
|
});
|
|
@@ -531,7 +617,7 @@ function ensureWorktree(projectDir, taskId, branch) {
|
|
|
531
617
|
return worktreePath;
|
|
532
618
|
}
|
|
533
619
|
const ref = branch ? `origin/${branch}` : "HEAD";
|
|
534
|
-
|
|
620
|
+
execSync2(`git worktree add --detach "${worktreePath}" ${ref}`, {
|
|
535
621
|
cwd: projectDir,
|
|
536
622
|
stdio: "ignore"
|
|
537
623
|
});
|
|
@@ -541,7 +627,7 @@ function removeWorktree(projectDir, taskId) {
|
|
|
541
627
|
const worktreePath = join(projectDir, WORKTREE_DIR, taskId);
|
|
542
628
|
if (!existsSync(worktreePath)) return;
|
|
543
629
|
try {
|
|
544
|
-
|
|
630
|
+
execSync2(`git worktree remove "${worktreePath}" --force`, {
|
|
545
631
|
cwd: projectDir,
|
|
546
632
|
stdio: "ignore"
|
|
547
633
|
});
|
|
@@ -552,7 +638,6 @@ function removeWorktree(projectDir, taskId) {
|
|
|
552
638
|
// src/setup/config.ts
|
|
553
639
|
import { readFile } from "fs/promises";
|
|
554
640
|
import { join as join2 } from "path";
|
|
555
|
-
var CONVEYOR_CONFIG_PATH = ".conveyor/config.json";
|
|
556
641
|
var DEVCONTAINER_PATH = ".devcontainer/conveyor/devcontainer.json";
|
|
557
642
|
async function loadForwardPorts(workspaceDir) {
|
|
558
643
|
try {
|
|
@@ -563,87 +648,20 @@ async function loadForwardPorts(workspaceDir) {
|
|
|
563
648
|
return [];
|
|
564
649
|
}
|
|
565
650
|
}
|
|
566
|
-
|
|
651
|
+
function loadConveyorConfig(_workspaceDir) {
|
|
567
652
|
const envSetup = process.env.CONVEYOR_SETUP_COMMAND;
|
|
568
653
|
const envStart = process.env.CONVEYOR_START_COMMAND;
|
|
569
654
|
const envPort = process.env.CONVEYOR_PREVIEW_PORT;
|
|
570
|
-
const envAuth = process.env.CONVEYOR_AUTH_TOKEN_COMMAND;
|
|
571
655
|
if (envSetup || envStart) {
|
|
572
656
|
return {
|
|
573
657
|
setupCommand: envSetup,
|
|
574
658
|
startCommand: envStart,
|
|
575
|
-
previewPort: envPort ? Number(envPort) : void 0
|
|
576
|
-
authTokenCommand: envAuth
|
|
659
|
+
previewPort: envPort ? Number(envPort) : void 0
|
|
577
660
|
};
|
|
578
661
|
}
|
|
579
|
-
try {
|
|
580
|
-
const raw = await readFile(join2(workspaceDir, CONVEYOR_CONFIG_PATH), "utf-8");
|
|
581
|
-
const parsed = JSON.parse(raw);
|
|
582
|
-
if (parsed.setupCommand || parsed.startCommand) return parsed;
|
|
583
|
-
} catch {
|
|
584
|
-
}
|
|
585
662
|
return null;
|
|
586
663
|
}
|
|
587
664
|
|
|
588
|
-
// src/setup/commands.ts
|
|
589
|
-
import { spawn, execSync as execSync2 } from "child_process";
|
|
590
|
-
function runSetupCommand(cmd, cwd, onOutput) {
|
|
591
|
-
return new Promise((resolve2, reject) => {
|
|
592
|
-
const child = spawn("sh", ["-c", cmd], {
|
|
593
|
-
cwd,
|
|
594
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
595
|
-
env: { ...process.env }
|
|
596
|
-
});
|
|
597
|
-
child.stdout.on("data", (chunk) => {
|
|
598
|
-
onOutput("stdout", chunk.toString());
|
|
599
|
-
});
|
|
600
|
-
child.stderr.on("data", (chunk) => {
|
|
601
|
-
onOutput("stderr", chunk.toString());
|
|
602
|
-
});
|
|
603
|
-
child.on("close", (code) => {
|
|
604
|
-
if (code === 0) {
|
|
605
|
-
resolve2();
|
|
606
|
-
} else {
|
|
607
|
-
reject(new Error(`Setup command exited with code ${code}`));
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
child.on("error", (err) => {
|
|
611
|
-
reject(err);
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
var AUTH_TOKEN_TIMEOUT_MS = 3e4;
|
|
616
|
-
function runAuthTokenCommand(cmd, userEmail, cwd) {
|
|
617
|
-
try {
|
|
618
|
-
const output = execSync2(`${cmd} ${JSON.stringify(userEmail)}`, {
|
|
619
|
-
cwd,
|
|
620
|
-
timeout: AUTH_TOKEN_TIMEOUT_MS,
|
|
621
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
622
|
-
env: { ...process.env }
|
|
623
|
-
});
|
|
624
|
-
const token = output.toString().trim();
|
|
625
|
-
return token || null;
|
|
626
|
-
} catch {
|
|
627
|
-
return null;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function runStartCommand(cmd, cwd, onOutput) {
|
|
631
|
-
const child = spawn("sh", ["-c", cmd], {
|
|
632
|
-
cwd,
|
|
633
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
634
|
-
detached: true,
|
|
635
|
-
env: { ...process.env }
|
|
636
|
-
});
|
|
637
|
-
child.stdout.on("data", (chunk) => {
|
|
638
|
-
onOutput("stdout", chunk.toString());
|
|
639
|
-
});
|
|
640
|
-
child.stderr.on("data", (chunk) => {
|
|
641
|
-
onOutput("stderr", chunk.toString());
|
|
642
|
-
});
|
|
643
|
-
child.unref();
|
|
644
|
-
return child;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
665
|
// src/setup/codespace.ts
|
|
648
666
|
import { execSync as execSync3 } from "child_process";
|
|
649
667
|
function unshallowRepo(workspaceDir) {
|
|
@@ -3048,17 +3066,6 @@ The agent cannot start until this is resolved.`
|
|
|
3048
3066
|
return { ok: false, conveyorConfig: null };
|
|
3049
3067
|
}
|
|
3050
3068
|
}
|
|
3051
|
-
function runAuthTokenSafe(config, connection, taskContext) {
|
|
3052
|
-
const authCmd = process.env.CONVEYOR_AUTH_TOKEN_COMMAND;
|
|
3053
|
-
if (!authCmd || !taskContext.userEmail) return;
|
|
3054
|
-
try {
|
|
3055
|
-
const token = runAuthTokenCommand(authCmd, taskContext.userEmail, config.workspaceDir);
|
|
3056
|
-
if (token) {
|
|
3057
|
-
connection.emitAuthToken(token);
|
|
3058
|
-
}
|
|
3059
|
-
} catch {
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
3069
|
function rerunStartCommand(conveyorConfig, runnerConfig, connection, setupLog) {
|
|
3063
3070
|
if (!conveyorConfig.startCommand) return;
|
|
3064
3071
|
pushSetupLog(setupLog, `$ ${conveyorConfig.startCommand} & (background, re-trigger)`);
|
|
@@ -3288,9 +3295,6 @@ var AgentRunner = class {
|
|
|
3288
3295
|
}
|
|
3289
3296
|
this.tryInitWorktree();
|
|
3290
3297
|
if (!await this.fetchAndInitContext()) return;
|
|
3291
|
-
if (process.env.CODESPACES === "true" && this.taskContext) {
|
|
3292
|
-
runAuthTokenSafe(this.config, this.connection, this.taskContext);
|
|
3293
|
-
}
|
|
3294
3298
|
this.tryPostContextWorktree();
|
|
3295
3299
|
this.checkoutWorktreeBranch();
|
|
3296
3300
|
await this.executeInitialMode();
|
|
@@ -4102,17 +4106,17 @@ var FileCache = class {
|
|
|
4102
4106
|
};
|
|
4103
4107
|
|
|
4104
4108
|
export {
|
|
4109
|
+
runSetupCommand,
|
|
4110
|
+
runStartCommand,
|
|
4105
4111
|
ConveyorConnection,
|
|
4106
4112
|
ProjectConnection,
|
|
4107
4113
|
ensureWorktree,
|
|
4108
4114
|
removeWorktree,
|
|
4109
4115
|
loadConveyorConfig,
|
|
4110
|
-
runSetupCommand,
|
|
4111
|
-
runStartCommand,
|
|
4112
4116
|
createServiceLogger,
|
|
4113
4117
|
errorMeta,
|
|
4114
4118
|
AgentRunner,
|
|
4115
4119
|
ProjectRunner,
|
|
4116
4120
|
FileCache
|
|
4117
4121
|
};
|
|
4118
|
-
//# sourceMappingURL=chunk-
|
|
4122
|
+
//# sourceMappingURL=chunk-MTIMRYLD.js.map
|