Skip to content

Commit cef968c

Browse files
committed
clean logs
1 parent d322cf2 commit cef968c

File tree

16 files changed

+134
-144
lines changed

16 files changed

+134
-144
lines changed

app/api/tasks/[taskId]/files/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
104104
} catch (branchError: unknown) {
105105
if (branchError && typeof branchError === 'object' && 'status' in branchError && branchError.status === 404) {
106106
// Branch doesn't exist yet (task is still processing)
107-
console.log(`Branch ${task.branchName} doesn't exist yet, returning empty file list`)
107+
console.log('Branch does not exist yet, returning empty file list')
108108
return NextResponse.json({
109109
success: true,
110110
files: [],
@@ -144,7 +144,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
144144
masterError.status === 404
145145
) {
146146
// Neither main nor master exists, or head branch doesn't exist
147-
console.log(`Could not compare branches for ${task.branchName}`)
147+
console.log('Could not compare branches')
148148
return NextResponse.json({
149149
success: true,
150150
files: [],
@@ -171,7 +171,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
171171
changes: file.changes || 0,
172172
})) || []
173173

174-
console.log(`Found ${files.length} changed files in branch ${task.branchName}`)
174+
console.log('Found changed files in branch')
175175
} catch (error: unknown) {
176176
console.error('Error fetching file changes from GitHub:', error)
177177

app/api/tasks/[taskId]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
8989
if (killResult.success) {
9090
await logger.success('Sandbox killed successfully')
9191
} else {
92-
await logger.error(`Failed to kill sandbox: ${killResult.error}`)
92+
await logger.error('Failed to kill sandbox')
9393
}
9494
} catch (killError) {
9595
console.error('Failed to kill sandbox during stop:', killError)

app/api/tasks/route.ts

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function POST(request: NextRequest) {
122122
})
123123
.where(eq(tasks.id, taskId))
124124

125-
await logger.success(`Generated AI branch name: ${aiBranchName}`)
125+
await logger.success('Generated AI branch name')
126126
} catch (error) {
127127
console.error('Error generating AI branch name:', error)
128128

@@ -139,7 +139,7 @@ export async function POST(request: NextRequest) {
139139
.where(eq(tasks.id, taskId))
140140

141141
const logger = createTaskLogger(taskId)
142-
await logger.info(`Using fallback branch name: ${fallbackBranchName}`)
142+
await logger.info('Using fallback branch name')
143143
} catch (dbError) {
144144
console.error('Error updating task with fallback branch name:', dbError)
145145
}
@@ -278,7 +278,7 @@ async function processTask(
278278
const taskStartTime = Date.now()
279279

280280
try {
281-
console.log(`[TASK ${taskId}] Starting task processing at ${new Date().toISOString()}`)
281+
console.log('Starting task processing')
282282

283283
// Update task status to processing with real-time logging
284284
await logger.updateStatus('processing', 'Task created, preparing to start...')
@@ -310,13 +310,13 @@ async function processTask(
310310
}
311311

312312
if (aiBranchName) {
313-
await logger.info(`Using AI-generated branch name: ${aiBranchName}`)
313+
await logger.info('Using AI-generated branch name')
314314
} else {
315315
await logger.info('AI branch name not ready, will use fallback during sandbox creation')
316316
}
317317

318-
await logger.updateProgress(15, 'Creating sandbox environment...')
319-
console.log(`[TASK ${taskId}] Creating sandbox at ${new Date().toISOString()}`)
318+
await logger.updateProgress(15, 'Creating sandbox environment')
319+
console.log('Creating sandbox')
320320

321321
// Create sandbox with progress callback and 5-minute timeout
322322
const sandboxResult = await createSandbox(
@@ -371,7 +371,7 @@ async function processTask(
371371

372372
const { sandbox: createdSandbox, domain, branchName } = sandboxResult
373373
sandbox = createdSandbox || null
374-
console.log(`[TASK ${taskId}] Sandbox created successfully at ${new Date().toISOString()}`)
374+
console.log('Sandbox created successfully')
375375

376376
// Update sandbox URL and branch name (only update branch name if not already set by AI)
377377
const updateData: { sandboxUrl?: string; updatedAt: Date; branchName?: string } = {
@@ -393,8 +393,8 @@ async function processTask(
393393
}
394394

395395
// Log agent execution start
396-
await logger.updateProgress(50, `Installing and executing ${selectedAgent} agent...`)
397-
console.log(`[TASK ${taskId}] Starting ${selectedAgent} agent execution at ${new Date().toISOString()}`)
396+
await logger.updateProgress(50, 'Installing and executing agent')
397+
console.log('Starting agent execution')
398398

399399
// Execute selected agent with timeout (different timeouts per agent)
400400
const getAgentTimeout = (agent: string) => {
@@ -447,9 +447,7 @@ async function processTask(
447447
})
448448

449449
if (mcpServers.length > 0) {
450-
await logger.info(
451-
`Found ${mcpServers.length} connected MCP servers: ${mcpServers.map((s) => s.name).join(', ')}`,
452-
)
450+
await logger.info('Found connected MCP servers')
453451

454452
// Store MCP server IDs in the task
455453
await db
@@ -484,15 +482,15 @@ async function processTask(
484482
agentTimeoutPromise,
485483
])
486484

487-
console.log(`[TASK ${taskId}] Agent execution completed at ${new Date().toISOString()}`)
485+
console.log('Agent execution completed')
488486

489487
if (agentResult.success) {
490488
// Log agent completion
491-
await logger.success(`${selectedAgent} agent execution completed`)
492-
await logger.info(agentResult.output || 'Code changes applied successfully')
489+
await logger.success('Agent execution completed')
490+
await logger.info('Code changes applied successfully')
493491

494492
if (agentResult.agentResponse) {
495-
await logger.info(`Agent Response: ${agentResult.agentResponse}`)
493+
await logger.info('Agent response received')
496494
}
497495

498496
// Agent execution logs are already logged in real-time by the agent
@@ -508,7 +506,7 @@ async function processTask(
508506
if (shutdownResult.success) {
509507
await logger.success('Sandbox shutdown completed')
510508
} else {
511-
await logger.error(`Sandbox shutdown failed: ${shutdownResult.error}`)
509+
await logger.error('Sandbox shutdown failed')
512510
}
513511

514512
// Check if push failed and handle accordingly
@@ -521,14 +519,11 @@ async function processTask(
521519
await logger.updateStatus('completed')
522520
await logger.updateProgress(100, 'Task completed successfully')
523521

524-
const totalTaskTime = ((Date.now() - taskStartTime) / 1000).toFixed(2)
525-
console.log(
526-
`[TASK ${taskId}] Task completed successfully at ${new Date().toISOString()} (total time: ${totalTaskTime}s)`,
527-
)
522+
console.log('Task completed successfully')
528523
}
529524
} else {
530525
// Agent failed, but we still want to capture its logs
531-
await logger.error(`${selectedAgent} agent execution failed`)
526+
await logger.error('Agent execution failed')
532527

533528
// Agent execution logs are already logged in real-time by the agent
534529
// No need to log them again here
@@ -546,7 +541,7 @@ async function processTask(
546541
if (shutdownResult.success) {
547542
await logger.info('Sandbox shutdown completed after error')
548543
} else {
549-
await logger.error(`Sandbox shutdown failed: ${shutdownResult.error}`)
544+
await logger.error('Sandbox shutdown failed')
550545
}
551546
} catch (shutdownError) {
552547
console.error('Failed to shutdown sandbox after error:', shutdownError)
@@ -557,7 +552,7 @@ async function processTask(
557552
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'
558553

559554
// Log the error and update task status
560-
await logger.error(`Error: ${errorMessage}`)
555+
await logger.error('Error occurred during task processing')
561556
await logger.updateStatus('error', errorMessage)
562557
}
563558
}

components/task-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export function TaskDetails({ task }: TaskDetailsProps) {
306306
newDiffsCache[filename] = result.data
307307
}
308308
} catch (err) {
309-
console.error(`Error fetching diff for ${filename}:`, err)
309+
console.error('Error fetching diff for file:', err)
310310
}
311311
})
312312

components/task-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export function TaskForm({
239239
setLoadingRepos(false)
240240
return
241241
} catch {
242-
console.warn(`Failed to parse cached repos for ${selectedOwner}, fetching fresh data`)
242+
console.warn('Failed to parse cached repos, fetching fresh data')
243243
sessionStorage.removeItem(cacheKey)
244244
}
245245
}

lib/api-keys/user-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export async function getUserApiKey(provider: Provider): Promise<string | undefi
9797
return decrypt(userKey[0].value)
9898
}
9999
} catch (error) {
100-
console.error(`Error fetching user API key for ${provider}:`, error)
100+
console.error('Error fetching user API key:', error)
101101
}
102102

103103
return systemKeys[provider]

lib/sandbox/agents/claude.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function installClaudeCLI(
8383
// Use selectedModel if provided, otherwise fall back to default
8484

8585
if (mcpServers && mcpServers.length > 0) {
86-
await logger.info(`Adding ${mcpServers.length} MCP servers: ${mcpServers.map((s) => s.name).join(', ')}`)
86+
await logger.info('Adding MCP servers')
8787

8888
for (const server of mcpServers) {
8989
const serverName = server.name.toLowerCase().replace(/[^a-z0-9]/g, '-')
@@ -103,10 +103,10 @@ export async function installClaudeCLI(
103103
const addResult = await runCommandInSandbox(sandbox, 'sh', ['-c', addMcpCmd])
104104

105105
if (addResult.success) {
106-
await logger.info(`Successfully added local MCP server: ${server.name}`)
106+
await logger.info('Successfully added local MCP server')
107107
} else {
108108
const redactedError = redactSensitiveInfo(addResult.error || 'Unknown error')
109-
await logger.info(`Failed to add MCP server ${server.name}: ${redactedError}`)
109+
await logger.info('Failed to add MCP server')
110110
}
111111
} else {
112112
// Remote HTTP/SSE server
@@ -123,10 +123,10 @@ export async function installClaudeCLI(
123123
const addResult = await runCommandInSandbox(sandbox, 'sh', ['-c', addMcpCmd])
124124

125125
if (addResult.success) {
126-
await logger.info(`Successfully added remote MCP server: ${server.name}`)
126+
await logger.info('Successfully added remote MCP server')
127127
} else {
128128
const redactedError = redactSensitiveInfo(addResult.error || 'Unknown error')
129-
await logger.info(`Failed to add MCP server ${server.name}: ${redactedError}`)
129+
await logger.info('Failed to add MCP server')
130130
}
131131
}
132132
}
@@ -235,9 +235,9 @@ export async function executeClaudeInSandbox(
235235

236236
// Check MCP configuration status
237237
const mcpList = await runCommandInSandbox(sandbox, 'sh', ['-c', `${envPrefix} claude mcp list`])
238-
await logger.info(`MCP servers list: ${JSON.stringify(mcpList.output)}`)
238+
await logger.info('MCP servers list retrieved')
239239
if (mcpList.error) {
240-
await logger.info(`MCP list error: ${JSON.stringify(mcpList.error)}`)
240+
await logger.info('MCP list error occurred')
241241
}
242242

243243
// Try multiple command formats to see what works
@@ -274,7 +274,7 @@ export async function executeClaudeInSandbox(
274274

275275
// Log the output
276276
if (result.output && result.output.trim()) {
277-
await logger.info(`everything: ${JSON.stringify(result.output)}`)
277+
await logger.info('Claude CLI execution output available')
278278

279279
const redactedOutput = redactSensitiveInfo(result.output.trim())
280280
await logger.info(redactedOutput)
@@ -295,12 +295,12 @@ export async function executeClaudeInSandbox(
295295

296296
// Log more details for debugging
297297
if (logger) {
298-
await logger.info(`Claude CLI exit code: ${result.exitCode}`)
298+
await logger.info('Claude CLI execution completed')
299299
if (result.output) {
300-
await logger.info(`Claude CLI output length: ${result.output.length} characters`)
300+
await logger.info('Claude CLI output available')
301301
}
302302
if (result.error) {
303-
await logger.error(`Claude CLI error: ${result.error}`)
303+
await logger.error('Claude CLI error occurred')
304304
}
305305
}
306306

lib/sandbox/agents/codex.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function executeCodexInSandbox(
9393

9494
if (logger) {
9595
const keyType = isVercelKey ? 'Vercel AI Gateway' : 'OpenAI'
96-
await logger.info(`Using ${keyType} API key: ${apiKey.substring(0, 10)}...${apiKey.substring(apiKey.length - 4)}`)
96+
await logger.info('Using API key for authentication')
9797
}
9898

9999
// According to the official Codex CLI docs, we should use 'exec' for non-interactive execution
@@ -128,7 +128,7 @@ export async function executeCodexInSandbox(
128128
})
129129

130130
if (logger) {
131-
await logger.info(`Codex CLI version test: ${versionTestResult.exitCode === 0 ? 'SUCCESS' : 'FAILED'}`)
131+
await logger.info('Codex CLI version test completed')
132132
}
133133

134134
// Create configuration file based on API key type
@@ -170,7 +170,7 @@ log_requests = true
170170

171171
// Add MCP servers configuration if provided
172172
if (mcpServers && mcpServers.length > 0) {
173-
await logger.info(`Configuring ${mcpServers.length} MCP servers: ${mcpServers.map((s) => s.name).join(', ')}`)
173+
await logger.info('Configuring MCP servers')
174174

175175
// Check if we need experimental RMCP client (for remote servers)
176176
const hasRemoteServers = mcpServers.some((s) => s.type === 'remote')
@@ -203,7 +203,7 @@ command = "${executable}"
203203
.join(', ')} }\n`
204204
}
205205

206-
await logger.info(`Added local MCP server: ${server.name} (${server.command})`)
206+
await logger.info('Added local MCP server')
207207
} else {
208208
// Remote HTTP/SSE server
209209
configToml += `
@@ -215,7 +215,7 @@ url = "${server.baseUrl}"
215215
configToml += `bearer_token = "${server.oauthClientSecret}"\n`
216216
}
217217

218-
await logger.info(`Added remote MCP server: ${server.name} (${server.baseUrl})`)
218+
await logger.info('Added remote MCP server')
219219
}
220220
}
221221
}
@@ -232,7 +232,7 @@ url = "${server.baseUrl}"
232232
})
233233

234234
if (logger) {
235-
await logger.info(`Codex config setup: ${configSetupResult.exitCode === 0 ? 'SUCCESS' : 'FAILED'}`)
235+
await logger.info('Codex config setup completed')
236236
}
237237

238238
// Debug: Check if the config file was created correctly (without logging sensitive contents)
@@ -250,13 +250,13 @@ url = "${server.baseUrl}"
250250
// Debug: List files in the current directory before running Codex
251251
const lsDebugResult = await runCommandInSandbox(sandbox, 'ls', ['-la'])
252252
if (logger) {
253-
await logger.info(`Current directory contents:\n${lsDebugResult.output || 'No output from ls -la'}`)
253+
await logger.info('Current directory contents retrieved')
254254
}
255255

256256
// Debug: Show current working directory
257257
const pwdResult = await runCommandInSandbox(sandbox, 'pwd', [])
258258
if (logger) {
259-
await logger.info(`Current working directory: ${pwdResult.output || 'Unknown'}`)
259+
await logger.info('Current working directory retrieved')
260260
}
261261

262262
// Use exec command with Vercel AI Gateway configuration

0 commit comments

Comments
 (0)