mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-09 21:58:28 +00:00
fix(core): align terminal failures with current runner
This commit is contained in:
parent
cfab7a2d79
commit
aeaabc3928
3 changed files with 10 additions and 5 deletions
|
|
@ -124,7 +124,7 @@ export namespace Run {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
reason: Schema.Literals(["execution-failed", "step-limit-exceeded", "unknown"]),
|
||||
reason: Schema.Literals(["execution-failed", "unknown"]),
|
||||
input: Schema.Struct({
|
||||
messageID: SessionMessageID.ID,
|
||||
admittedSeq: NonNegativeInt,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export const layer = Layer.effect(
|
|||
yield* events.publish(SessionEvent.Run.Failed, {
|
||||
sessionID,
|
||||
timestamp: yield* DateTime.now,
|
||||
reason: error instanceof SessionRunner.StepLimitExceededError ? "step-limit-exceeded" : "execution-failed",
|
||||
reason: error === undefined ? "unknown" : "execution-failed",
|
||||
...(input === undefined
|
||||
? {}
|
||||
: {
|
||||
|
|
|
|||
|
|
@ -915,19 +915,24 @@ describe("SessionRunCoordinator", () => {
|
|||
Effect.gen(function* () {
|
||||
const failure = new Error("wake failed")
|
||||
const reported: Cause.Cause<Error>[] = []
|
||||
const contexts: Array<{ readonly mode: "wake"; readonly seq?: number }> = []
|
||||
const reportedOnce = yield* Deferred.make<void>()
|
||||
const coordinator = yield* SessionRunCoordinator.make<string, void, Error>({
|
||||
drain: () => Effect.fail(failure),
|
||||
onFailure: (_key, cause) =>
|
||||
Effect.sync(() => reported.push(cause)).pipe(Effect.andThen(Deferred.succeed(reportedOnce, undefined))),
|
||||
onFailure: (_key, cause, context) =>
|
||||
Effect.sync(() => {
|
||||
reported.push(cause)
|
||||
contexts.push(context)
|
||||
}).pipe(Effect.andThen(Deferred.succeed(reportedOnce, undefined))),
|
||||
})
|
||||
|
||||
yield* coordinator.wake("session")
|
||||
yield* coordinator.wake("session", 7)
|
||||
yield* Deferred.await(reportedOnce)
|
||||
yield* Effect.yieldNow
|
||||
|
||||
expect(reported).toHaveLength(1)
|
||||
expect(Cause.squash(reported[0]!)).toBe(failure)
|
||||
expect(contexts).toEqual([{ mode: "wake", seq: 7 }])
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue