feat: log warnings and errors

old-agentic-v1^2
Philipp Burckhardt 2023-06-30 14:33:11 -04:00
rodzic c09c24ac66
commit 1273af0b06
2 zmienionych plików z 31 dodań i 15 usunięć

Wyświetl plik

@ -228,7 +228,7 @@ export class TerminalTaskTracker {
case TaskStatus.FAILED: case TaskStatus.FAILED:
return [SYMBOLS.CROSS, red] return [SYMBOLS.CROSS, red]
case TaskStatus.RETRYING: case TaskStatus.RETRYING:
return [SYMBOLS.WARNING, yellow] return [this.getSpinnerSymbol(), yellow]
case TaskStatus.RUNNING: case TaskStatus.RUNNING:
default: default:
return [this.getSpinnerSymbol(), cyan] return [this.getSpinnerSymbol(), cyan]
@ -268,20 +268,24 @@ export class TerminalTaskTracker {
line = indent + gray(SYMBOLS.BAR_END) line = indent + gray(SYMBOLS.BAR_END)
} }
if (output) { const formattedOutput = this.stringify(output || '')
if (status === TaskStatus.COMPLETED) { if (status === TaskStatus.COMPLETED) {
const formattedOutput = this.stringify(output) line +=
line += indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput)
indent + } else if (status === TaskStatus.FAILED) {
' ' + line +=
gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput) indent +
} else if (status === TaskStatus.FAILED) { ' ' +
line += gray(SYMBOLS.RIGHT_ARROW) +
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + red(output)) SPACE +
} else if (status === TaskStatus.RETRYING) { red(formattedOutput)
line += } else if (status === TaskStatus.RETRYING) {
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + yellow(output)) line +=
} indent +
' ' +
yellow(SYMBOLS.WARNING) +
SPACE +
gray(formattedOutput)
} }
lines.push(line) lines.push(line)

Wyświetl plik

@ -360,6 +360,12 @@ export abstract class BaseTask<
ctx.attemptNumber = err.attemptNumber + 1 ctx.attemptNumber = err.attemptNumber + 1
ctx.metadata.error = err ctx.metadata.error = err
this._eventEmitter.emit(TaskStatus.RETRYING, {
taskInputs: input,
taskOutput: err,
...ctx.metadata
})
if (err instanceof errors.ZodOutputValidationError) { if (err instanceof errors.ZodOutputValidationError) {
ctx.retryMessage = err.message ctx.retryMessage = err.message
return return
@ -383,6 +389,12 @@ export abstract class BaseTask<
// task for now. // task for now.
return return
} else { } else {
this._eventEmitter.emit(TaskStatus.FAILED, {
taskInputs: input,
taskOutput: err,
...ctx.metadata
})
throw err throw err
} }
} }