@rallycry/conveyor-agent 6.0.0 → 6.0.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.
|
@@ -594,6 +594,33 @@ var ProjectConnection = class {
|
|
|
594
594
|
}
|
|
595
595
|
};
|
|
596
596
|
|
|
597
|
+
// src/utils/logger.ts
|
|
598
|
+
import winston from "winston";
|
|
599
|
+
var { combine, timestamp, printf, colorize } = winston.format;
|
|
600
|
+
var customFormat = printf(({ level, message, timestamp: ts, service, ...meta }) => {
|
|
601
|
+
const svc = service ? `[${service}] ` : "";
|
|
602
|
+
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : "";
|
|
603
|
+
return `${ts} [${level}]: ${svc}${message}${metaStr}`;
|
|
604
|
+
});
|
|
605
|
+
var logger = winston.createLogger({
|
|
606
|
+
level: process.env.LOG_LEVEL ?? "info",
|
|
607
|
+
format: combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), combine(colorize(), customFormat)),
|
|
608
|
+
transports: [new winston.transports.Console()]
|
|
609
|
+
});
|
|
610
|
+
function createServiceLogger(serviceName) {
|
|
611
|
+
return logger.child({ service: serviceName });
|
|
612
|
+
}
|
|
613
|
+
function errorMeta(error) {
|
|
614
|
+
if (error instanceof Error) {
|
|
615
|
+
return {
|
|
616
|
+
message: error.message,
|
|
617
|
+
stack: error.stack,
|
|
618
|
+
..."code" in error && typeof error.code === "string" ? { code: error.code } : {}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
return { message: String(error) };
|
|
622
|
+
}
|
|
623
|
+
|
|
597
624
|
// src/runner/worktree.ts
|
|
598
625
|
import { execSync as execSync2 } from "child_process";
|
|
599
626
|
import { existsSync } from "fs";
|
|
@@ -675,33 +702,6 @@ function unshallowRepo(workspaceDir) {
|
|
|
675
702
|
}
|
|
676
703
|
}
|
|
677
704
|
|
|
678
|
-
// src/utils/logger.ts
|
|
679
|
-
import winston from "winston";
|
|
680
|
-
var { combine, timestamp, printf, colorize } = winston.format;
|
|
681
|
-
var customFormat = printf(({ level, message, timestamp: ts, service, ...meta }) => {
|
|
682
|
-
const svc = service ? `[${service}] ` : "";
|
|
683
|
-
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : "";
|
|
684
|
-
return `${ts} [${level}]: ${svc}${message}${metaStr}`;
|
|
685
|
-
});
|
|
686
|
-
var logger = winston.createLogger({
|
|
687
|
-
level: process.env.LOG_LEVEL ?? "info",
|
|
688
|
-
format: combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), combine(colorize(), customFormat)),
|
|
689
|
-
transports: [new winston.transports.Console()]
|
|
690
|
-
});
|
|
691
|
-
function createServiceLogger(serviceName) {
|
|
692
|
-
return logger.child({ service: serviceName });
|
|
693
|
-
}
|
|
694
|
-
function errorMeta(error) {
|
|
695
|
-
if (error instanceof Error) {
|
|
696
|
-
return {
|
|
697
|
-
message: error.message,
|
|
698
|
-
stack: error.stack,
|
|
699
|
-
..."code" in error && typeof error.code === "string" ? { code: error.code } : {}
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
return { message: String(error) };
|
|
703
|
-
}
|
|
704
|
-
|
|
705
705
|
// src/runner/agent-runner.ts
|
|
706
706
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
707
707
|
import { execSync as execSync4 } from "child_process";
|
|
@@ -2750,6 +2750,7 @@ function buildCanUseTool(host) {
|
|
|
2750
2750
|
}
|
|
2751
2751
|
|
|
2752
2752
|
// src/execution/query-executor.ts
|
|
2753
|
+
var logger2 = createServiceLogger("QueryExecutor");
|
|
2753
2754
|
var API_ERROR_PATTERN2 = /API Error: [45]\d\d/;
|
|
2754
2755
|
var IMAGE_ERROR_PATTERN2 = /Could not process image/i;
|
|
2755
2756
|
var RETRY_DELAYS_MS = [6e4, 12e4, 18e4, 3e5];
|
|
@@ -2838,7 +2839,10 @@ function buildQueryOptions(host, context) {
|
|
|
2838
2839
|
betas: settings.betas,
|
|
2839
2840
|
maxBudgetUsd: settings.maxBudgetUsd ?? 50,
|
|
2840
2841
|
disallowedTools: buildDisallowedTools(settings, mode, host.hasExitedPlanMode),
|
|
2841
|
-
enableFileCheckpointing: settings.enableFileCheckpointing
|
|
2842
|
+
enableFileCheckpointing: settings.enableFileCheckpointing,
|
|
2843
|
+
stderr: (data) => {
|
|
2844
|
+
logger2.warn("Claude Code stderr", { data: data.trimEnd() });
|
|
2845
|
+
}
|
|
2842
2846
|
};
|
|
2843
2847
|
if (isCloud && isReadOnly) {
|
|
2844
2848
|
baseOptions.sandbox = buildSandboxConfig(host);
|
|
@@ -3429,7 +3433,7 @@ function buildQueryHost(deps) {
|
|
|
3429
3433
|
}
|
|
3430
3434
|
|
|
3431
3435
|
// src/runner/agent-runner.ts
|
|
3432
|
-
var
|
|
3436
|
+
var logger3 = createServiceLogger("AgentRunner");
|
|
3433
3437
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
|
3434
3438
|
var IDLE_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
3435
3439
|
var AgentRunner = class {
|
|
@@ -3718,7 +3722,7 @@ var AgentRunner = class {
|
|
|
3718
3722
|
const s = this.taskContext.agentSettings ?? this.config.agentSettings ?? {};
|
|
3719
3723
|
const model = this.taskContext.model || this.config.model;
|
|
3720
3724
|
const thinking = formatThinkingSetting(s.thinking);
|
|
3721
|
-
|
|
3725
|
+
logger3.info("Effective agent settings", {
|
|
3722
3726
|
model,
|
|
3723
3727
|
mode: this.config.mode ?? "task",
|
|
3724
3728
|
effort: s.effort ?? "default",
|
|
@@ -3762,7 +3766,7 @@ var AgentRunner = class {
|
|
|
3762
3766
|
this.idleTimer = setTimeout(() => {
|
|
3763
3767
|
this.clearIdleTimers();
|
|
3764
3768
|
this.inputResolver = null;
|
|
3765
|
-
|
|
3769
|
+
logger3.info("Idle timeout reached, shutting down", {
|
|
3766
3770
|
idleMinutes: IDLE_TIMEOUT_MS / 6e4
|
|
3767
3771
|
});
|
|
3768
3772
|
this.connection.postChatMessage(
|
|
@@ -3885,7 +3889,7 @@ import { fileURLToPath } from "url";
|
|
|
3885
3889
|
|
|
3886
3890
|
// src/runner/project-chat-handler.ts
|
|
3887
3891
|
import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
|
|
3888
|
-
var
|
|
3892
|
+
var logger4 = createServiceLogger("ProjectChat");
|
|
3889
3893
|
var FALLBACK_MODEL = "claude-sonnet-4-20250514";
|
|
3890
3894
|
function buildSystemPrompt2(projectDir, agentCtx) {
|
|
3891
3895
|
const parts = [];
|
|
@@ -3938,7 +3942,7 @@ function processContentBlock(block, responseParts, turnToolCalls) {
|
|
|
3938
3942
|
input: inputStr.slice(0, 1e4),
|
|
3939
3943
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3940
3944
|
});
|
|
3941
|
-
|
|
3945
|
+
logger4.debug("Tool use", { tool: block.name });
|
|
3942
3946
|
}
|
|
3943
3947
|
}
|
|
3944
3948
|
async function fetchContext(connection) {
|
|
@@ -3946,13 +3950,13 @@ async function fetchContext(connection) {
|
|
|
3946
3950
|
try {
|
|
3947
3951
|
agentCtx = await connection.fetchAgentContext();
|
|
3948
3952
|
} catch {
|
|
3949
|
-
|
|
3953
|
+
logger4.warn("Could not fetch agent context, using defaults");
|
|
3950
3954
|
}
|
|
3951
3955
|
let chatHistory = [];
|
|
3952
3956
|
try {
|
|
3953
3957
|
chatHistory = await connection.fetchChatHistory(30);
|
|
3954
3958
|
} catch {
|
|
3955
|
-
|
|
3959
|
+
logger4.warn("Could not fetch chat history, proceeding without it");
|
|
3956
3960
|
}
|
|
3957
3961
|
return { agentCtx, chatHistory };
|
|
3958
3962
|
}
|
|
@@ -4026,7 +4030,7 @@ async function handleProjectChatMessage(message, connection, projectDir) {
|
|
|
4026
4030
|
try {
|
|
4027
4031
|
await runChatQuery(message, connection, projectDir);
|
|
4028
4032
|
} catch (error) {
|
|
4029
|
-
|
|
4033
|
+
logger4.error("Failed to handle message", errorMeta(error));
|
|
4030
4034
|
try {
|
|
4031
4035
|
await connection.emitChatMessage(
|
|
4032
4036
|
"I encountered an error processing your message. Please try again."
|
|
@@ -4039,7 +4043,7 @@ async function handleProjectChatMessage(message, connection, projectDir) {
|
|
|
4039
4043
|
}
|
|
4040
4044
|
|
|
4041
4045
|
// src/runner/project-runner.ts
|
|
4042
|
-
var
|
|
4046
|
+
var logger5 = createServiceLogger("ProjectRunner");
|
|
4043
4047
|
var __filename = fileURLToPath(import.meta.url);
|
|
4044
4048
|
var __dirname = path.dirname(__filename);
|
|
4045
4049
|
var HEARTBEAT_INTERVAL_MS2 = 3e4;
|
|
@@ -4063,7 +4067,7 @@ function setupWorkDir(projectDir, assignment) {
|
|
|
4063
4067
|
try {
|
|
4064
4068
|
execSync5(`git checkout -b ${branch}`, { cwd: workDir, stdio: "ignore" });
|
|
4065
4069
|
} catch {
|
|
4066
|
-
|
|
4070
|
+
logger5.warn("Could not checkout branch", { taskId: shortId, branch });
|
|
4067
4071
|
}
|
|
4068
4072
|
}
|
|
4069
4073
|
}
|
|
@@ -4102,13 +4106,13 @@ function spawnChildAgent(assignment, workDir) {
|
|
|
4102
4106
|
child.stdout?.on("data", (data) => {
|
|
4103
4107
|
const lines = data.toString().trimEnd().split("\n");
|
|
4104
4108
|
for (const line of lines) {
|
|
4105
|
-
|
|
4109
|
+
logger5.info(line, { taskId: shortId });
|
|
4106
4110
|
}
|
|
4107
4111
|
});
|
|
4108
4112
|
child.stderr?.on("data", (data) => {
|
|
4109
4113
|
const lines = data.toString().trimEnd().split("\n");
|
|
4110
4114
|
for (const line of lines) {
|
|
4111
|
-
|
|
4115
|
+
logger5.error(line, { taskId: shortId });
|
|
4112
4116
|
}
|
|
4113
4117
|
});
|
|
4114
4118
|
return child;
|
|
@@ -4138,9 +4142,9 @@ var ProjectRunner = class {
|
|
|
4138
4142
|
try {
|
|
4139
4143
|
execSync5(`git fetch origin ${workspaceBranch}`, { cwd: this.projectDir, stdio: "pipe" });
|
|
4140
4144
|
execSync5(`git checkout ${workspaceBranch}`, { cwd: this.projectDir, stdio: "pipe" });
|
|
4141
|
-
|
|
4145
|
+
logger5.info("Checked out workspace branch", { workspaceBranch });
|
|
4142
4146
|
} catch (err) {
|
|
4143
|
-
|
|
4147
|
+
logger5.warn("Failed to checkout workspace branch, continuing on current branch", {
|
|
4144
4148
|
workspaceBranch,
|
|
4145
4149
|
...errorMeta(err)
|
|
4146
4150
|
});
|
|
@@ -4149,15 +4153,15 @@ var ProjectRunner = class {
|
|
|
4149
4153
|
async executeSetupCommand() {
|
|
4150
4154
|
const cmd = process.env.CONVEYOR_SETUP_COMMAND;
|
|
4151
4155
|
if (!cmd) return;
|
|
4152
|
-
|
|
4156
|
+
logger5.info("Running setup command", { command: cmd });
|
|
4153
4157
|
try {
|
|
4154
4158
|
await runSetupCommand(cmd, this.projectDir, (stream, data) => {
|
|
4155
4159
|
this.connection.emitEvent({ type: "setup_output", stream, data });
|
|
4156
4160
|
(stream === "stderr" ? process.stderr : process.stdout).write(data);
|
|
4157
4161
|
});
|
|
4158
|
-
|
|
4162
|
+
logger5.info("Setup command completed");
|
|
4159
4163
|
} catch (error) {
|
|
4160
|
-
|
|
4164
|
+
logger5.error("Setup command failed", errorMeta(error));
|
|
4161
4165
|
this.connection.emitEvent({
|
|
4162
4166
|
type: "setup_error",
|
|
4163
4167
|
message: error instanceof Error ? error.message : "Setup command failed"
|
|
@@ -4168,7 +4172,7 @@ var ProjectRunner = class {
|
|
|
4168
4172
|
executeStartCommand() {
|
|
4169
4173
|
const cmd = process.env.CONVEYOR_START_COMMAND;
|
|
4170
4174
|
if (!cmd) return;
|
|
4171
|
-
|
|
4175
|
+
logger5.info("Running start command", { command: cmd });
|
|
4172
4176
|
const child = runStartCommand(cmd, this.projectDir, (stream, data) => {
|
|
4173
4177
|
this.connection.emitEvent({ type: "start_command_output", stream, data });
|
|
4174
4178
|
(stream === "stderr" ? process.stderr : process.stdout).write(data);
|
|
@@ -4178,7 +4182,7 @@ var ProjectRunner = class {
|
|
|
4178
4182
|
child.on("exit", (code, signal) => {
|
|
4179
4183
|
this.startCommandRunning = false;
|
|
4180
4184
|
this.startCommandChild = null;
|
|
4181
|
-
|
|
4185
|
+
logger5.info("Start command exited", { code, signal });
|
|
4182
4186
|
this.connection.emitEvent({
|
|
4183
4187
|
type: "start_command_exited",
|
|
4184
4188
|
code,
|
|
@@ -4189,13 +4193,13 @@ var ProjectRunner = class {
|
|
|
4189
4193
|
child.on("error", (err) => {
|
|
4190
4194
|
this.startCommandRunning = false;
|
|
4191
4195
|
this.startCommandChild = null;
|
|
4192
|
-
|
|
4196
|
+
logger5.error("Start command error", errorMeta(err));
|
|
4193
4197
|
});
|
|
4194
4198
|
}
|
|
4195
4199
|
async killStartCommand() {
|
|
4196
4200
|
const child = this.startCommandChild;
|
|
4197
4201
|
if (!child || !this.startCommandRunning) return;
|
|
4198
|
-
|
|
4202
|
+
logger5.info("Killing start command");
|
|
4199
4203
|
try {
|
|
4200
4204
|
if (child.pid) process.kill(-child.pid, "SIGTERM");
|
|
4201
4205
|
} catch {
|
|
@@ -4253,7 +4257,7 @@ var ProjectRunner = class {
|
|
|
4253
4257
|
startCommandRunning: this.startCommandRunning
|
|
4254
4258
|
});
|
|
4255
4259
|
} catch (error) {
|
|
4256
|
-
|
|
4260
|
+
logger5.error("Environment setup failed", errorMeta(error));
|
|
4257
4261
|
this.setupComplete = false;
|
|
4258
4262
|
}
|
|
4259
4263
|
this.connection.onTaskAssignment((assignment) => {
|
|
@@ -4263,17 +4267,17 @@ var ProjectRunner = class {
|
|
|
4263
4267
|
this.handleStopTask(data.taskId);
|
|
4264
4268
|
});
|
|
4265
4269
|
this.connection.onShutdown(() => {
|
|
4266
|
-
|
|
4270
|
+
logger5.info("Received shutdown signal from server");
|
|
4267
4271
|
void this.stop();
|
|
4268
4272
|
});
|
|
4269
4273
|
this.connection.onChatMessage((msg) => {
|
|
4270
|
-
|
|
4274
|
+
logger5.debug("Received project chat message");
|
|
4271
4275
|
void handleProjectChatMessage(msg, this.connection, this.projectDir);
|
|
4272
4276
|
});
|
|
4273
4277
|
this.heartbeatTimer = setInterval(() => {
|
|
4274
4278
|
this.connection.sendHeartbeat();
|
|
4275
4279
|
}, HEARTBEAT_INTERVAL_MS2);
|
|
4276
|
-
|
|
4280
|
+
logger5.info("Connected, waiting for task assignments");
|
|
4277
4281
|
await new Promise((resolve2) => {
|
|
4278
4282
|
this.resolveLifecycle = resolve2;
|
|
4279
4283
|
process.on("SIGTERM", () => void this.stop());
|
|
@@ -4284,11 +4288,11 @@ var ProjectRunner = class {
|
|
|
4284
4288
|
const { taskId, mode } = assignment;
|
|
4285
4289
|
const shortId = taskId.slice(0, 8);
|
|
4286
4290
|
if (this.activeAgents.has(taskId)) {
|
|
4287
|
-
|
|
4291
|
+
logger5.info("Task already running, skipping", { taskId: shortId });
|
|
4288
4292
|
return;
|
|
4289
4293
|
}
|
|
4290
4294
|
if (this.activeAgents.size >= MAX_CONCURRENT) {
|
|
4291
|
-
|
|
4295
|
+
logger5.warn("Max concurrent agents reached, rejecting task", {
|
|
4292
4296
|
maxConcurrent: MAX_CONCURRENT,
|
|
4293
4297
|
taskId: shortId
|
|
4294
4298
|
});
|
|
@@ -4299,7 +4303,7 @@ var ProjectRunner = class {
|
|
|
4299
4303
|
try {
|
|
4300
4304
|
execSync5("git fetch origin", { cwd: this.projectDir, stdio: "ignore" });
|
|
4301
4305
|
} catch {
|
|
4302
|
-
|
|
4306
|
+
logger5.warn("Git fetch failed", { taskId: shortId });
|
|
4303
4307
|
}
|
|
4304
4308
|
const { workDir, usesWorktree } = setupWorkDir(this.projectDir, assignment);
|
|
4305
4309
|
const child = spawnChildAgent(assignment, workDir);
|
|
@@ -4310,12 +4314,12 @@ var ProjectRunner = class {
|
|
|
4310
4314
|
usesWorktree
|
|
4311
4315
|
});
|
|
4312
4316
|
this.connection.emitTaskStarted(taskId);
|
|
4313
|
-
|
|
4317
|
+
logger5.info("Started task", { taskId: shortId, mode, workDir });
|
|
4314
4318
|
child.on("exit", (code) => {
|
|
4315
4319
|
this.activeAgents.delete(taskId);
|
|
4316
4320
|
const reason = code === 0 ? "completed" : `exited with code ${code}`;
|
|
4317
4321
|
this.connection.emitTaskStopped(taskId, reason);
|
|
4318
|
-
|
|
4322
|
+
logger5.info("Task exited", { taskId: shortId, reason });
|
|
4319
4323
|
if (code === 0 && usesWorktree) {
|
|
4320
4324
|
try {
|
|
4321
4325
|
removeWorktree(this.projectDir, taskId);
|
|
@@ -4324,7 +4328,7 @@ var ProjectRunner = class {
|
|
|
4324
4328
|
}
|
|
4325
4329
|
});
|
|
4326
4330
|
} catch (error) {
|
|
4327
|
-
|
|
4331
|
+
logger5.error("Failed to start task", {
|
|
4328
4332
|
taskId: shortId,
|
|
4329
4333
|
...errorMeta(error)
|
|
4330
4334
|
});
|
|
@@ -4338,7 +4342,7 @@ var ProjectRunner = class {
|
|
|
4338
4342
|
const agent = this.activeAgents.get(taskId);
|
|
4339
4343
|
if (!agent) return;
|
|
4340
4344
|
const shortId = taskId.slice(0, 8);
|
|
4341
|
-
|
|
4345
|
+
logger5.info("Stopping task", { taskId: shortId });
|
|
4342
4346
|
agent.process.kill("SIGTERM");
|
|
4343
4347
|
const timer = setTimeout(() => {
|
|
4344
4348
|
if (this.activeAgents.has(taskId)) {
|
|
@@ -4358,7 +4362,7 @@ var ProjectRunner = class {
|
|
|
4358
4362
|
async stop() {
|
|
4359
4363
|
if (this.stopping) return;
|
|
4360
4364
|
this.stopping = true;
|
|
4361
|
-
|
|
4365
|
+
logger5.info("Shutting down");
|
|
4362
4366
|
await this.killStartCommand();
|
|
4363
4367
|
if (this.heartbeatTimer) {
|
|
4364
4368
|
clearInterval(this.heartbeatTimer);
|
|
@@ -4384,7 +4388,7 @@ var ProjectRunner = class {
|
|
|
4384
4388
|
})
|
|
4385
4389
|
]);
|
|
4386
4390
|
this.connection.disconnect();
|
|
4387
|
-
|
|
4391
|
+
logger5.info("Shutdown complete");
|
|
4388
4392
|
if (this.resolveLifecycle) {
|
|
4389
4393
|
this.resolveLifecycle();
|
|
4390
4394
|
this.resolveLifecycle = null;
|
|
@@ -4461,13 +4465,13 @@ export {
|
|
|
4461
4465
|
runStartCommand,
|
|
4462
4466
|
ConveyorConnection,
|
|
4463
4467
|
ProjectConnection,
|
|
4468
|
+
createServiceLogger,
|
|
4469
|
+
errorMeta,
|
|
4464
4470
|
ensureWorktree,
|
|
4465
4471
|
removeWorktree,
|
|
4466
4472
|
loadConveyorConfig,
|
|
4467
|
-
createServiceLogger,
|
|
4468
|
-
errorMeta,
|
|
4469
4473
|
AgentRunner,
|
|
4470
4474
|
ProjectRunner,
|
|
4471
4475
|
FileCache
|
|
4472
4476
|
};
|
|
4473
|
-
//# sourceMappingURL=chunk-
|
|
4477
|
+
//# sourceMappingURL=chunk-HYWZJYPW.js.map
|