( params: Record<string, unknown>, context: ExecutionContext )
| 353 | } |
| 354 | |
| 355 | export async function executeCompleteJob( |
| 356 | params: Record<string, unknown>, |
| 357 | context: ExecutionContext |
| 358 | ): Promise<ToolCallResult> { |
| 359 | const { jobId } = params as { jobId?: string } |
| 360 | |
| 361 | if (!jobId) { |
| 362 | return { success: false, error: 'jobId is required' } |
| 363 | } |
| 364 | |
| 365 | try { |
| 366 | if (!context.workspaceId) { |
| 367 | return { success: false, error: 'Missing workspace context' } |
| 368 | } |
| 369 | |
| 370 | const result = await performCompleteJob({ |
| 371 | jobId, |
| 372 | workspaceId: context.workspaceId, |
| 373 | userId: context.userId, |
| 374 | }) |
| 375 | if (!result.success) { |
| 376 | return { success: false, error: result.error || 'Failed to complete job' } |
| 377 | } |
| 378 | if (result.alreadyCompleted) { |
| 379 | return { |
| 380 | success: true, |
| 381 | output: { jobId, message: 'Job is already completed' }, |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | return { |
| 386 | success: true, |
| 387 | output: { jobId, message: 'Job marked as completed. No further executions will occur.' }, |
| 388 | } |
| 389 | } catch (err) { |
| 390 | logger.error('Failed to complete job', { |
| 391 | error: toError(err).message, |
| 392 | }) |
| 393 | return { success: false, error: 'Failed to complete job' } |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | export async function executeUpdateJobHistory( |
| 398 | params: Record<string, unknown>, |
nothing calls this directly
no test coverage detected