( params: ParamsOf<FinishAgentRunFn>, )
| 346 | } |
| 347 | |
| 348 | export async function finishAgentRun( |
| 349 | params: ParamsOf<FinishAgentRunFn>, |
| 350 | ): ReturnType<FinishAgentRunFn> { |
| 351 | const { |
| 352 | apiKey, |
| 353 | runId, |
| 354 | status, |
| 355 | totalSteps, |
| 356 | directCredits, |
| 357 | totalCredits, |
| 358 | logger, |
| 359 | } = params |
| 360 | |
| 361 | const url = new URL(`/api/v1/agent-runs`, WEBSITE_URL) |
| 362 | |
| 363 | try { |
| 364 | const response = await fetchWithRetry( |
| 365 | url, |
| 366 | { |
| 367 | method: 'POST', |
| 368 | headers: { |
| 369 | Authorization: `Bearer ${apiKey}`, |
| 370 | }, |
| 371 | body: JSON.stringify({ |
| 372 | action: 'FINISH', |
| 373 | runId, |
| 374 | status, |
| 375 | totalSteps, |
| 376 | directCredits, |
| 377 | totalCredits, |
| 378 | }), |
| 379 | }, |
| 380 | logger, |
| 381 | ) |
| 382 | |
| 383 | if (!response.ok) { |
| 384 | logger.error({ response }, 'finishAgentRun request failed') |
| 385 | return |
| 386 | } |
| 387 | } catch (error) { |
| 388 | logger.error( |
| 389 | { error: getErrorObject(error), runId, status }, |
| 390 | 'finishAgentRun error', |
| 391 | ) |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | export async function addAgentStep( |
| 396 | params: ParamsOf<AddAgentStepFn>, |
no test coverage detected