@usine/engine 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/README.md +109 -38
  2. package/dist/board-moves/board-moves.d.ts +20 -0
  3. package/dist/board-moves/board-moves.d.ts.map +1 -0
  4. package/dist/board-moves/board-moves.js +74 -0
  5. package/dist/board-moves/board-moves.js.map +1 -0
  6. package/dist/board-moves/model.d.ts +21 -0
  7. package/dist/board-moves/model.d.ts.map +1 -0
  8. package/dist/board-moves/model.js +22 -0
  9. package/dist/board-moves/model.js.map +1 -0
  10. package/dist/cursor/cursor.d.ts +2 -6
  11. package/dist/cursor/cursor.d.ts.map +1 -1
  12. package/dist/cursor/cursor.js +2 -6
  13. package/dist/cursor/cursor.js.map +1 -1
  14. package/dist/cycle-budget/cycle-budget.d.ts +6 -6
  15. package/dist/cycle-budget/cycle-budget.d.ts.map +1 -1
  16. package/dist/cycle-budget/cycle-budget.js +5 -5
  17. package/dist/cycle-budget/cycle-budget.js.map +1 -1
  18. package/dist/cycle-budget/model.d.ts +2 -2
  19. package/dist/cycle-budget/model.d.ts.map +1 -1
  20. package/dist/cycle-budget/model.js +2 -2
  21. package/dist/cycle-budget/model.js.map +1 -1
  22. package/dist/cycle-budget/queries.d.ts +1 -1
  23. package/dist/cycle-budget/queries.d.ts.map +1 -1
  24. package/dist/cycle-budget/queries.js +3 -3
  25. package/dist/cycle-budget/queries.js.map +1 -1
  26. package/dist/database/database.d.ts +1 -1
  27. package/dist/database/database.d.ts.map +1 -1
  28. package/dist/database/local-sqlite.d.ts +10 -8
  29. package/dist/database/local-sqlite.d.ts.map +1 -1
  30. package/dist/database/local-sqlite.js +11 -10
  31. package/dist/database/local-sqlite.js.map +1 -1
  32. package/dist/database/schema.d.ts +533 -22
  33. package/dist/database/schema.d.ts.map +1 -1
  34. package/dist/database/schema.js +100 -23
  35. package/dist/database/schema.js.map +1 -1
  36. package/dist/{workflow → engine}/admission.d.ts +2 -2
  37. package/dist/engine/admission.d.ts.map +1 -0
  38. package/dist/{workflow → engine}/admission.js +4 -4
  39. package/dist/engine/admission.js.map +1 -0
  40. package/dist/engine/checkout-recovery.d.ts +69 -0
  41. package/dist/engine/checkout-recovery.d.ts.map +1 -0
  42. package/dist/engine/checkout-recovery.js +181 -0
  43. package/dist/engine/checkout-recovery.js.map +1 -0
  44. package/dist/engine/engine.d.ts +55 -26
  45. package/dist/engine/engine.d.ts.map +1 -1
  46. package/dist/engine/engine.js +118 -128
  47. package/dist/engine/engine.js.map +1 -1
  48. package/dist/engine/error.d.ts +29 -10
  49. package/dist/engine/error.d.ts.map +1 -1
  50. package/dist/engine/error.js +28 -8
  51. package/dist/engine/error.js.map +1 -1
  52. package/dist/engine/lifecycle.d.ts +81 -28
  53. package/dist/engine/lifecycle.d.ts.map +1 -1
  54. package/dist/engine/lifecycle.js +83 -44
  55. package/dist/engine/lifecycle.js.map +1 -1
  56. package/dist/engine/retry.d.ts +16 -0
  57. package/dist/engine/retry.d.ts.map +1 -0
  58. package/dist/engine/retry.js +18 -0
  59. package/dist/engine/retry.js.map +1 -0
  60. package/dist/engine/run-again.d.ts +45 -0
  61. package/dist/engine/run-again.d.ts.map +1 -0
  62. package/dist/engine/run-again.js +56 -0
  63. package/dist/engine/run-again.js.map +1 -0
  64. package/dist/engine/run-driver.d.ts +54 -0
  65. package/dist/engine/run-driver.d.ts.map +1 -0
  66. package/dist/engine/run-driver.js +362 -0
  67. package/dist/engine/run-driver.js.map +1 -0
  68. package/dist/engine/shutdown.d.ts +3 -4
  69. package/dist/engine/shutdown.d.ts.map +1 -1
  70. package/dist/engine/shutdown.js +3 -4
  71. package/dist/engine/shutdown.js.map +1 -1
  72. package/dist/engine/submission.d.ts +31 -11
  73. package/dist/engine/submission.d.ts.map +1 -1
  74. package/dist/engine/submission.js +42 -12
  75. package/dist/engine/submission.js.map +1 -1
  76. package/dist/item-projection/item-projection.d.ts +12 -4
  77. package/dist/item-projection/item-projection.d.ts.map +1 -1
  78. package/dist/item-projection/item-projection.js +41 -6
  79. package/dist/item-projection/item-projection.js.map +1 -1
  80. package/dist/item-projection/model.d.ts +5 -1
  81. package/dist/item-projection/model.d.ts.map +1 -1
  82. package/dist/item-projection/model.js +6 -2
  83. package/dist/item-projection/model.js.map +1 -1
  84. package/dist/loop-control/loop-control.d.ts +5 -5
  85. package/dist/loop-control/loop-control.d.ts.map +1 -1
  86. package/dist/loop-control/loop-control.js +4 -4
  87. package/dist/loop-control/loop-control.js.map +1 -1
  88. package/dist/loop-control/model.d.ts +1 -1
  89. package/dist/loop-control/model.d.ts.map +1 -1
  90. package/dist/loop-control/model.js +1 -1
  91. package/dist/loop-control/model.js.map +1 -1
  92. package/dist/repository-label-projection/model.d.ts +2 -2
  93. package/dist/repository-label-projection/model.d.ts.map +1 -1
  94. package/dist/repository-label-projection/model.js +2 -2
  95. package/dist/repository-label-projection/model.js.map +1 -1
  96. package/dist/repository-label-projection/repository-label-projection.d.ts +1 -1
  97. package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -1
  98. package/dist/repository-label-projection/repository-label-projection.js +1 -1
  99. package/dist/repository-label-projection/repository-label-projection.js.map +1 -1
  100. package/dist/run-reader/model.d.ts +62 -4
  101. package/dist/run-reader/model.d.ts.map +1 -1
  102. package/dist/run-reader/model.js +66 -7
  103. package/dist/run-reader/model.js.map +1 -1
  104. package/dist/run-reader/run-reader.d.ts +19 -9
  105. package/dist/run-reader/run-reader.d.ts.map +1 -1
  106. package/dist/run-reader/run-reader.js +23 -7
  107. package/dist/run-reader/run-reader.js.map +1 -1
  108. package/dist/step-executor.d.ts +64 -10
  109. package/dist/step-executor.d.ts.map +1 -1
  110. package/dist/step-executor.js +10 -2
  111. package/dist/step-executor.js.map +1 -1
  112. package/dist/store/attempt-windows.d.ts +8 -0
  113. package/dist/store/attempt-windows.d.ts.map +1 -0
  114. package/dist/store/attempt-windows.js +53 -0
  115. package/dist/store/attempt-windows.js.map +1 -0
  116. package/dist/store/codec.d.ts +207 -42
  117. package/dist/store/codec.d.ts.map +1 -1
  118. package/dist/store/codec.js +52 -14
  119. package/dist/store/codec.js.map +1 -1
  120. package/dist/store/leftovers.d.ts +10 -0
  121. package/dist/store/leftovers.d.ts.map +1 -0
  122. package/dist/store/leftovers.js +43 -0
  123. package/dist/store/leftovers.js.map +1 -0
  124. package/dist/store/loop-items.d.ts +16 -0
  125. package/dist/store/loop-items.d.ts.map +1 -0
  126. package/dist/store/loop-items.js +185 -0
  127. package/dist/store/loop-items.js.map +1 -0
  128. package/dist/store/queries.d.ts +342 -35
  129. package/dist/store/queries.d.ts.map +1 -1
  130. package/dist/store/queries.js +302 -107
  131. package/dist/store/queries.js.map +1 -1
  132. package/dist/store/store.d.ts +91 -54
  133. package/dist/store/store.d.ts.map +1 -1
  134. package/dist/store/store.js +468 -190
  135. package/dist/store/store.js.map +1 -1
  136. package/dist/store/transcript.d.ts +3 -3
  137. package/dist/store/transcript.d.ts.map +1 -1
  138. package/dist/store/transcript.js +25 -6
  139. package/dist/store/transcript.js.map +1 -1
  140. package/dist/transcript.d.ts +19 -20
  141. package/dist/transcript.d.ts.map +1 -1
  142. package/dist/transcript.js +23 -21
  143. package/dist/transcript.js.map +1 -1
  144. package/dist/trigger-condition.d.ts +23 -0
  145. package/dist/trigger-condition.d.ts.map +1 -0
  146. package/dist/trigger-condition.js +8 -0
  147. package/dist/trigger-condition.js.map +1 -0
  148. package/drizzle/20260917071139_resolve_run_failure/migration.sql +1 -0
  149. package/drizzle/20260917071139_resolve_run_failure/snapshot.json +1471 -0
  150. package/drizzle/20260918032643_attempt_salvage/migration.sql +1 -0
  151. package/drizzle/20260918032643_attempt_salvage/snapshot.json +1481 -0
  152. package/drizzle/20261011153856_drop_workflow_tables/migration.sql +4 -0
  153. package/drizzle/20261011153856_drop_workflow_tables/snapshot.json +1433 -0
  154. package/drizzle/20261017155043_attempt_salvage_check/migration.sql +41 -0
  155. package/drizzle/20261017155043_attempt_salvage_check/snapshot.json +1421 -0
  156. package/drizzle/20261018162700_discard_attempt_leftovers/migration.sql +1 -0
  157. package/drizzle/20261018162700_discard_attempt_leftovers/snapshot.json +1431 -0
  158. package/drizzle/20261018172605_loop_items_and_reopenings/migration.sql +15 -0
  159. package/drizzle/20261018172605_loop_items_and_reopenings/snapshot.json +1574 -0
  160. package/drizzle/20261018180339_attempt_ended_at/migration.sql +1 -0
  161. package/drizzle/20261018180339_attempt_ended_at/snapshot.json +1584 -0
  162. package/drizzle/20261019104043_run_approval_source/migration.sql +15 -0
  163. package/drizzle/20261019104043_run_approval_source/snapshot.json +1610 -0
  164. package/drizzle/20261019133538_board_moves/migration.sql +14 -0
  165. package/drizzle/20261019133538_board_moves/snapshot.json +1731 -0
  166. package/drizzle/20261019170538_item_projection_gone/migration.sql +1 -0
  167. package/drizzle/20261019170538_item_projection_gone/snapshot.json +1741 -0
  168. package/drizzle/20261019180649_run_again_events/migration.sql +7 -0
  169. package/drizzle/20261019180649_run_again_events/snapshot.json +1804 -0
  170. package/drizzle/20261019185008_trigger_event_permissions/migration.sql +1 -0
  171. package/drizzle/20261019185008_trigger_event_permissions/snapshot.json +1814 -0
  172. package/drizzle/20261020103746_attempt_start/migration.sql +5 -0
  173. package/drizzle/20261020103746_attempt_start/snapshot.json +1844 -0
  174. package/drizzle/20261020125211_attempt_comments/migration.sql +1 -0
  175. package/drizzle/20261020125211_attempt_comments/snapshot.json +1854 -0
  176. package/drizzle/20261020191320_run_closed_at/migration.sql +6 -0
  177. package/drizzle/20261020191320_run_closed_at/snapshot.json +1864 -0
  178. package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/migration.sql +2 -0
  179. package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/snapshot.json +1867 -0
  180. package/package.json +15 -5
  181. package/dist/workflow/admission.d.ts.map +0 -1
  182. package/dist/workflow/admission.js.map +0 -1
  183. package/dist/workflow/command.d.ts +0 -13
  184. package/dist/workflow/command.d.ts.map +0 -1
  185. package/dist/workflow/command.js +0 -17
  186. package/dist/workflow/command.js.map +0 -1
  187. package/dist/workflow/workflow.d.ts +0 -18
  188. package/dist/workflow/workflow.d.ts.map +0 -1
  189. package/dist/workflow/workflow.js +0 -108
  190. package/dist/workflow/workflow.js.map +0 -1
@@ -0,0 +1,53 @@
1
+ import { AttemptWindows, windowOf, windowsOverlap } from "@usine/core/attempt";
2
+ import { and, eq, inArray, ne } from "drizzle-orm";
3
+ import { Effect, Option } from "effect";
4
+ import { attempts, runs, triggerEvents } from "../database/schema.js";
5
+ import { attemptFromRow, decodeAttemptRows } from "./codec.js";
6
+ import { attemptSelection } from "./queries.js";
7
+ /** Returns the Attempt window queries that run on the caller's transaction. */
8
+ export const attemptWindowQueries = (database) => {
9
+ /**
10
+ * Returns the window of `attemptId` and the overlapping windows of the same Agent's other
11
+ * Attempts on the Item. An Attempt that ended before end times were recorded has no window: for
12
+ * `attemptId` the result is empty, and other such Attempts are left out. Dies if `attemptId`
13
+ * isn't recorded.
14
+ */
15
+ const attemptWindows = Effect.fn("RunStoreQueries.attemptWindows")(function* (attemptId) {
16
+ yield* Effect.annotateCurrentSpan({ attemptId });
17
+ const [own] = yield* database
18
+ .select(attemptSelection)
19
+ .from(attempts)
20
+ .where(eq(attempts.attemptId, attemptId))
21
+ .execute()
22
+ .pipe(Effect.flatMap(decodeAttemptRows));
23
+ if (own === undefined)
24
+ return yield* Effect.die(new Error(`No attempt ${attemptId} recorded`));
25
+ const ownWindow = windowOf(attemptFromRow(own));
26
+ if (Option.isNone(ownWindow)) {
27
+ yield* Effect.logDebug("The Attempt ended before end times were recorded, so it has no window and none overlaps it", { attemptId });
28
+ return new AttemptWindows({ own: ownWindow, overlapping: [] });
29
+ }
30
+ const item = database
31
+ .select({ itemKey: triggerEvents.itemKey })
32
+ .from(runs)
33
+ .innerJoin(triggerEvents, eq(triggerEvents.eventId, runs.eventId))
34
+ .where(eq(runs.runId, own.runId));
35
+ const others = yield* database
36
+ .select(attemptSelection)
37
+ .from(attempts)
38
+ .innerJoin(runs, eq(runs.runId, attempts.runId))
39
+ .innerJoin(triggerEvents, eq(triggerEvents.eventId, runs.eventId))
40
+ .where(and(inArray(triggerEvents.itemKey, item), eq(attempts.agent, own.agent), ne(attempts.attemptId, attemptId)))
41
+ .orderBy(attempts.startedAt)
42
+ .execute()
43
+ .pipe(Effect.flatMap(decodeAttemptRows));
44
+ return new AttemptWindows({
45
+ own: ownWindow,
46
+ overlapping: others
47
+ .flatMap((row) => Option.toArray(windowOf(attemptFromRow(row))))
48
+ .filter((window) => windowsOverlap(ownWindow.value, window)),
49
+ });
50
+ });
51
+ return { attemptWindows };
52
+ };
53
+ //# sourceMappingURL=attempt-windows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempt-windows.js","sourceRoot":"","sources":["../../src/store/attempt-windows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAA2B,EAAE,EAAE;IAClE;;;;;OAKG;IACH,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC,QAAQ,CAAC,EAC1E,SAAoB;QAEpB,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACjD,MAAM,CAAC,GAA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AAQ,CAAC,KAAK,CAAC,CAAC;aAC/C,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;aACjE,KAAK,CACJ,GAAG,CACD,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,EACpC,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,EAC7B,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAClC,CACF;aACA,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;aAC3B,OAAO,EAAE;aACT,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,cAAc,CAAC;YACxB,GAAG,EAAE,SAAS;YACd,WAAW,EAAE,MAAM;iBAChB,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBAC/D,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;SAC/D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,cAAc,EAAW,CAAC;AACrC,CAAC,CAAC"}
@@ -4,13 +4,15 @@ import { Attempt } from "@usine/core/attempt";
4
4
  import * as AttemptChannel from "@usine/core/attempt/channel";
5
5
  import { Event } from "@usine/core/event";
6
6
  import { Run } from "@usine/core/run";
7
+ import { RunAgain } from "@usine/core/run/again";
8
+ import { RunApproval } from "@usine/core/run/approval";
7
9
  import { Step } from "@usine/core/step";
8
10
  import * as RunState from "@usine/core/run/state";
9
- import { StepResult } from "@usine/core/step/result";
10
- import { Effect, Schema } from "effect";
11
+ import { Comment, StepResult } from "@usine/core/step/result";
12
+ import { Effect, Option, Schema } from "effect";
11
13
  import { RunStoreError } from "../engine/error.ts";
12
14
  import { Submission } from "../engine/submission.ts";
13
- import { RunSummary } from "../run-reader/model.ts";
15
+ import { RunEvent, RunSummary } from "../run-reader/model.ts";
14
16
  import { TranscriptEntry } from "../transcript.ts";
15
17
  export declare const EventRouteRow: Schema.Struct<{
16
18
  readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
@@ -21,6 +23,7 @@ export declare const EventRouteRow: Schema.Struct<{
21
23
  readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
22
24
  readonly step: Schema.brand<Schema.NonEmptyString, "StepName">;
23
25
  readonly approval: Schema.Literals<readonly ["none", "required"]>;
26
+ readonly permissions: Schema.Literals<readonly ["write", "read"]>;
24
27
  readonly cycleLimit: Schema.NullOr<Schema.brand<Schema.Int, "CycleLimit">>;
25
28
  readonly cycleGeneration: Schema.brand<Schema.Int, "CycleGeneration">;
26
29
  readonly repository: Schema.brand<Schema.String, "RepositoryName">;
@@ -41,9 +44,16 @@ export declare const RunRow: Schema.Struct<{
41
44
  readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
42
45
  readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
43
46
  readonly state: Schema.Union<readonly [typeof RunState.Pending, typeof RunState.Waiting, typeof RunState.Queued, typeof RunState.Running, typeof RunState.Succeeded, typeof RunState.Failed, typeof RunState.Canceled]>;
47
+ readonly resolvedFailureAttemptId: Schema.NullOr<Schema.brand<Schema.NonEmptyString, "AttemptId">>;
44
48
  readonly openedAt: Schema.DateTimeUtcFromString;
49
+ readonly closedAt: Schema.NullOr<Schema.DateTimeUtcFromString>;
45
50
  readonly stepName: Schema.brand<Schema.NonEmptyString, "StepName">;
46
51
  readonly result: Schema.NullOr<typeof StepResult>;
52
+ readonly approvedAt: Schema.NullOr<Schema.DateTimeUtcFromString>;
53
+ readonly approvalChannel: Schema.NullOr<Schema.Literals<readonly ["ui", "github-ask"]>>;
54
+ readonly approver: Schema.NullOr<Schema.brand<Schema.String, "OperatorLogin">>;
55
+ readonly againFrom: Schema.NullOr<Schema.brand<Schema.NonEmptyString, "RunId">>;
56
+ readonly againRequestedBy: Schema.NullOr<Schema.brand<Schema.String, "OperatorLogin">>;
47
57
  }>;
48
58
  export type RunRow = typeof RunRow.Type;
49
59
  export declare const AttemptRow: Schema.Struct<{
@@ -59,6 +69,11 @@ export declare const AttemptRow: Schema.Struct<{
59
69
  readonly parentModel: Schema.NullOr<Schema.brand<Schema.String, "ModelId">>;
60
70
  readonly startedAt: Schema.DateTimeUtcFromString;
61
71
  readonly outcome: Schema.NullOr<Schema.Union<readonly [typeof import("@usine/core/attempt/outcome").AttemptSucceeded, typeof import("@usine/core/attempt/outcome").AttemptFailed, typeof import("@usine/core/attempt/outcome").AttemptCanceled]>>;
72
+ readonly endedAt: Schema.NullOr<Schema.DateTimeUtcFromString>;
73
+ readonly salvage: Schema.NullOr<Schema.Union<readonly [typeof import("@usine/core/attempt/salvage").SalvagePushed, typeof import("@usine/core/attempt/salvage").SalvageRetained]>>;
74
+ readonly start: Schema.NullOr<Schema.Union<readonly [typeof import("@usine/core/attempt/start").StartedByEvent, typeof import("@usine/core/attempt/start").StartedByRetry, typeof import("@usine/core/attempt/start").StartedByEditAndRetry, typeof import("@usine/core/attempt/start").StartedByInfraRetry, typeof import("@usine/core/attempt/start").StartedAfterRestart]>>;
75
+ readonly reattachedAt: Schema.NullOr<Schema.DateTimeUtcFromString>;
76
+ readonly comments: Schema.NullOr<Schema.$Array<typeof Comment>>;
62
77
  }>;
63
78
  export type AttemptRow = typeof AttemptRow.Type;
64
79
  export declare const TranscriptRow: Schema.Struct<{
@@ -70,8 +85,8 @@ export declare const TranscriptRow: Schema.Struct<{
70
85
  readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
71
86
  readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
72
87
  readonly sentAt: Schema.DateTimeUtcFromString;
73
- readonly payload: Schema.Union<readonly [typeof AttemptChannel.Started, typeof AttemptChannel.SessionEvent, typeof AttemptChannel.Final, typeof AttemptChannel.Failed, typeof AttemptChannel.Interrupted, typeof AttemptChannel.InterventionApplied, typeof AttemptChannel.InterventionRejected]>;
74
- readonly version: Schema.Literal<5>;
88
+ readonly payload: Schema.Union<readonly [typeof AttemptChannel.Started, typeof AttemptChannel.SessionEvent, typeof AttemptChannel.Final, typeof AttemptChannel.Failed, typeof AttemptChannel.Interrupted, typeof AttemptChannel.InterventionApplied, typeof AttemptChannel.InterventionRejected, typeof AttemptChannel.WorkerUnresponsive, typeof AttemptChannel.WorkerResponsive]>;
89
+ readonly version: Schema.Literals<readonly [5, 6]>;
75
90
  }>, Schema.Struct<{
76
91
  readonly _tag: Schema.tag<"InboundEnvelope">;
77
92
  readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
@@ -80,13 +95,13 @@ export declare const TranscriptRow: Schema.Struct<{
80
95
  readonly target: Schema.withDecodingDefaultKey<Schema.Union<readonly [typeof AttemptChannel.ParentTarget, typeof AttemptChannel.ChildTarget]>, never>;
81
96
  readonly operator: Schema.NonEmptyString;
82
97
  readonly payload: Schema.Union<readonly [Schema.Union<readonly [typeof AttemptChannel.Steer, typeof AttemptChannel.Interrupt, typeof AttemptChannel.OperatorMessage, typeof AttemptChannel.Release]>, typeof AttemptChannel.Cancel]>;
83
- readonly version: Schema.Literal<5>;
98
+ readonly version: Schema.Literals<readonly [5, 6]>;
84
99
  }>, Schema.Struct<{
85
100
  readonly _tag: Schema.tag<"OutboundEnvelope">;
86
101
  readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
87
102
  readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
88
103
  readonly sentAt: Schema.DateTimeUtcFromString;
89
- readonly payload: Schema.Union<readonly [typeof AttemptChannel.Started, typeof AttemptChannel.SessionEvent, typeof AttemptChannel.Final, typeof AttemptChannel.Failed, typeof AttemptChannel.Interrupted, typeof AttemptChannel.InterventionApplied, typeof AttemptChannel.InterventionRejected]>;
104
+ readonly payload: Schema.Union<readonly [typeof AttemptChannel.Started, typeof AttemptChannel.SessionEvent, typeof AttemptChannel.Final, typeof AttemptChannel.Failed, typeof AttemptChannel.Interrupted, typeof AttemptChannel.InterventionApplied, typeof AttemptChannel.InterventionRejected, typeof AttemptChannel.WorkerUnresponsive, typeof AttemptChannel.WorkerResponsive]>;
90
105
  readonly version: Schema.Literals<readonly [3, 4]>;
91
106
  }>, Schema.Struct<{
92
107
  readonly _tag: Schema.Literal<"InboundEnvelope">;
@@ -99,11 +114,13 @@ export declare const TranscriptRow: Schema.Struct<{
99
114
  readonly receivedAt: Schema.DateTimeUtcFromString;
100
115
  }>;
101
116
  export type TranscriptRow = typeof TranscriptRow.Type;
102
- export declare const WorkflowCommandRow: Schema.Struct<{
117
+ declare const RunEventRow: Schema.Struct<{
103
118
  readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
104
- readonly command: Schema.Literals<readonly ["Approve", "Continue", "Interrupt", "Resume"]>;
119
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
120
+ readonly dedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
121
+ readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
122
+ readonly receivedAt: Schema.DateTimeUtcFromString;
105
123
  }>;
106
- export type WorkflowCommandRow = typeof WorkflowCommandRow.Type;
107
124
  export declare const decodeEventRoutes: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
108
125
  readonly eventId: string & import("effect/Brand").Brand<"EventId">;
109
126
  readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
@@ -113,6 +130,7 @@ export declare const decodeEventRoutes: (input: unknown, options?: import("effec
113
130
  readonly loop: string & import("effect/Brand").Brand<"LoopName">;
114
131
  readonly step: string & import("effect/Brand").Brand<"StepName">;
115
132
  readonly approval: "none" | "required";
133
+ readonly permissions: "read" | "write";
116
134
  readonly cycleLimit: (number & import("effect/Brand").Brand<"CycleLimit">) | null;
117
135
  readonly cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
118
136
  readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
@@ -121,6 +139,29 @@ export declare const decodeEventRoutes: (input: unknown, options?: import("effec
121
139
  readonly agent: Agent;
122
140
  readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
123
141
  }[], Schema.SchemaError, never>;
142
+ export declare const decodeReopenings: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
143
+ readonly eventId: string & import("effect/Brand").Brand<"EventId">;
144
+ readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
145
+ readonly payload: Schema.Json;
146
+ readonly receivedAt: import("effect/DateTime").Utc;
147
+ readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
148
+ readonly loop: string & import("effect/Brand").Brand<"LoopName">;
149
+ readonly step: string & import("effect/Brand").Brand<"StepName">;
150
+ readonly approval: "none" | "required";
151
+ readonly permissions: "read" | "write";
152
+ readonly cycleLimit: (number & import("effect/Brand").Brand<"CycleLimit">) | null;
153
+ readonly cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
154
+ readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
155
+ readonly revision: string & import("effect/Brand").Brand<"RepositoryRevision">;
156
+ readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
157
+ readonly agent: Agent;
158
+ readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
159
+ readonly reopening: number;
160
+ }[], Schema.SchemaError, never>;
161
+ export declare const decodeReopenedEvents: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
162
+ readonly eventId: string & import("effect/Brand").Brand<"EventId">;
163
+ readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
164
+ }[], Schema.SchemaError, never>;
124
165
  export declare const decodeRunRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
125
166
  readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
126
167
  readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
@@ -132,9 +173,23 @@ export declare const decodeRunRows: (input: unknown, options?: import("effect/Sc
132
173
  readonly eventId: string & import("effect/Brand").Brand<"EventId">;
133
174
  readonly loop: string & import("effect/Brand").Brand<"LoopName">;
134
175
  readonly state: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting;
176
+ readonly resolvedFailureAttemptId: (string & import("effect/Brand").Brand<"AttemptId">) | null;
135
177
  readonly openedAt: import("effect/DateTime").Utc;
178
+ readonly closedAt: import("effect/DateTime").Utc | null;
136
179
  readonly stepName: string & import("effect/Brand").Brand<"StepName">;
137
180
  readonly result: StepResult | null;
181
+ readonly approvedAt: import("effect/DateTime").Utc | null;
182
+ readonly approvalChannel: "github-ask" | "ui" | null;
183
+ readonly approver: (string & import("effect/Brand").Brand<"OperatorLogin">) | null;
184
+ readonly againFrom: (string & import("effect/Brand").Brand<"RunId">) | null;
185
+ readonly againRequestedBy: (string & import("effect/Brand").Brand<"OperatorLogin">) | null;
186
+ }[], Schema.SchemaError, never>;
187
+ export declare const decodeRunEventRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
188
+ readonly runId: string & import("effect/Brand").Brand<"RunId">;
189
+ readonly eventId: string & import("effect/Brand").Brand<"EventId">;
190
+ readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
191
+ readonly payload: Schema.Json;
192
+ readonly receivedAt: import("effect/DateTime").Utc;
138
193
  }[], Schema.SchemaError, never>;
139
194
  export declare const decodeAttemptRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
140
195
  readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
@@ -149,25 +204,11 @@ export declare const decodeAttemptRows: (input: unknown, options?: import("effec
149
204
  readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
150
205
  readonly startedAt: import("effect/DateTime").Utc;
151
206
  readonly outcome: import("@usine/core/attempt/outcome").AttemptCanceled | import("@usine/core/attempt/outcome").AttemptFailed | import("@usine/core/attempt/outcome").AttemptSucceeded | null;
152
- }[], Schema.SchemaError, never>;
153
- export declare const decodeRecoverableRuns: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
154
- readonly eventId: string & import("effect/Brand").Brand<"EventId">;
155
- readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
156
- readonly payload: Schema.Json;
157
- readonly receivedAt: import("effect/DateTime").Utc;
158
- readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
159
- readonly loop: string & import("effect/Brand").Brand<"LoopName">;
160
- readonly step: string & import("effect/Brand").Brand<"StepName">;
161
- readonly approval: "none" | "required";
162
- readonly cycleLimit: (number & import("effect/Brand").Brand<"CycleLimit">) | null;
163
- readonly cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
164
- readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
165
- readonly revision: string & import("effect/Brand").Brand<"RepositoryRevision">;
166
- readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
167
- readonly agent: Agent;
168
- readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
169
- readonly runId: string & import("effect/Brand").Brand<"RunId">;
170
- readonly state: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting;
207
+ readonly endedAt: import("effect/DateTime").Utc | null;
208
+ readonly salvage: import("@usine/core/attempt/salvage").SalvagePushed | import("@usine/core/attempt/salvage").SalvageRetained | null;
209
+ readonly start: import("@usine/core/attempt/start").StartedAfterRestart | import("@usine/core/attempt/start").StartedByEditAndRetry | import("@usine/core/attempt/start").StartedByEvent | import("@usine/core/attempt/start").StartedByInfraRetry | import("@usine/core/attempt/start").StartedByRetry | null;
210
+ readonly reattachedAt: import("effect/DateTime").Utc | null;
211
+ readonly comments: readonly Comment[] | null;
171
212
  }[], Schema.SchemaError, never>;
172
213
  export declare const decodeRunIds: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
173
214
  readonly runId: string & import("effect/Brand").Brand<"RunId">;
@@ -175,10 +216,6 @@ export declare const decodeRunIds: (input: unknown, options?: import("effect/Sch
175
216
  export declare const decodeDiscards: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
176
217
  readonly reason: "revoked" | "superseded";
177
218
  }[], Schema.SchemaError, never>;
178
- export declare const decodeWorkflowCommands: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
179
- readonly runId: string & import("effect/Brand").Brand<"RunId">;
180
- readonly command: "Approve" | "Continue" | "Interrupt" | "Resume";
181
- }[], Schema.SchemaError, never>;
182
219
  export declare const decodeProjectionRevision: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
183
220
  readonly revision: number & import("effect/Brand").Brand<"ProjectionRevision">;
184
221
  }[], Schema.SchemaError, never>;
@@ -191,8 +228,8 @@ export declare const decodeTranscriptRows: (input: unknown, options?: import("ef
191
228
  readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
192
229
  readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
193
230
  readonly sentAt: import("effect/DateTime").Utc;
194
- readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started;
195
- readonly version: 5;
231
+ readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started | AttemptChannel.WorkerResponsive | AttemptChannel.WorkerUnresponsive;
232
+ readonly version: 5 | 6;
196
233
  } | {
197
234
  readonly _tag: "InboundEnvelope";
198
235
  readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
@@ -201,13 +238,13 @@ export declare const decodeTranscriptRows: (input: unknown, options?: import("ef
201
238
  readonly target: AttemptChannel.ChildTarget | AttemptChannel.ParentTarget;
202
239
  readonly operator: string;
203
240
  readonly payload: AttemptChannel.Cancel | AttemptChannel.Interrupt | AttemptChannel.OperatorMessage | AttemptChannel.Release | AttemptChannel.Steer;
204
- readonly version: 5;
241
+ readonly version: 5 | 6;
205
242
  } | {
206
243
  readonly _tag: "OutboundEnvelope";
207
244
  readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
208
245
  readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
209
246
  readonly sentAt: import("effect/DateTime").Utc;
210
- readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started;
247
+ readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started | AttemptChannel.WorkerResponsive | AttemptChannel.WorkerUnresponsive;
211
248
  readonly version: 3 | 4;
212
249
  } | {
213
250
  readonly _tag: "InboundEnvelope";
@@ -222,8 +259,6 @@ export declare const decodeTranscriptRows: (input: unknown, options?: import("ef
222
259
  export declare const encodePayload: (input: Schema.Json, options?: import("effect/SchemaAST").ParseOptions) => Schema.Json;
223
260
  export declare const encodeDateTime: (input: import("effect/DateTime").Utc, options?: import("effect/SchemaAST").ParseOptions) => string;
224
261
  export declare const encodeRunState: (input: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting, options?: import("effect/SchemaAST").ParseOptions) => {
225
- readonly _tag: "Succeeded";
226
- } | {
227
262
  readonly _tag: "Pending";
228
263
  } | {
229
264
  readonly _tag: "Waiting";
@@ -231,6 +266,8 @@ export declare const encodeRunState: (input: RunState.Canceled | RunState.Failed
231
266
  readonly _tag: "Queued";
232
267
  } | {
233
268
  readonly _tag: "Running";
269
+ } | {
270
+ readonly _tag: "Succeeded";
234
271
  } | {
235
272
  readonly _tag: "Failed";
236
273
  } | {
@@ -259,6 +296,12 @@ export declare const encodeOutcome: (input: import("@usine/core/attempt/outcome"
259
296
  } | {
260
297
  readonly _tag: "AgentFailure";
261
298
  readonly message: string;
299
+ } | {
300
+ readonly _tag: "BlockedFailure";
301
+ readonly message: string;
302
+ } | {
303
+ readonly _tag: "QuestionFailure";
304
+ readonly question: string;
262
305
  } | {
263
306
  readonly _tag: "RunawayFailure";
264
307
  readonly ceiling: "tokens" | "wall-clock";
@@ -270,6 +313,38 @@ export declare const encodeOutcome: (input: import("@usine/core/attempt/outcome"
270
313
  } | {
271
314
  readonly _tag: "Canceled";
272
315
  };
316
+ export declare const encodeSalvage: (input: import("@usine/core/attempt/salvage").SalvagePushed | import("@usine/core/attempt/salvage").SalvageRetained, options?: import("effect/SchemaAST").ParseOptions) => {
317
+ readonly _tag: "Pushed";
318
+ readonly ref: string;
319
+ readonly commit: string;
320
+ } | {
321
+ readonly _tag: "Retained";
322
+ readonly path: string;
323
+ readonly commit: string | null;
324
+ readonly message: string;
325
+ };
326
+ export declare const encodeComments: (input: readonly Comment[], options?: import("effect/SchemaAST").ParseOptions) => readonly {
327
+ readonly _tag: "Comment";
328
+ readonly url: string;
329
+ readonly kind: "issue-comment" | "review" | "review-comment";
330
+ readonly at?: string;
331
+ }[];
332
+ export declare const encodeAttemptStart: (input: import("@usine/core/attempt/start").StartedAfterRestart | import("@usine/core/attempt/start").StartedByEditAndRetry | import("@usine/core/attempt/start").StartedByEvent | import("@usine/core/attempt/start").StartedByInfraRetry | import("@usine/core/attempt/start").StartedByRetry, options?: import("effect/SchemaAST").ParseOptions) => {
333
+ readonly _tag: "Event";
334
+ } | {
335
+ readonly _tag: "OperatorRetry";
336
+ readonly operator: string | null;
337
+ } | {
338
+ readonly _tag: "EditAndRetry";
339
+ readonly operator: string | null;
340
+ } | {
341
+ readonly _tag: "InfraRetry";
342
+ } | {
343
+ readonly _tag: "AfterRestart";
344
+ };
345
+ export declare const decodeNextStarts: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
346
+ readonly nextStart: import("@usine/core/attempt/start").StartedByEditAndRetry | import("@usine/core/attempt/start").StartedByRetry | null;
347
+ }[], Schema.SchemaError, never>;
273
348
  export declare const encodeStepResult: (input: StepResult, options?: import("effect/SchemaAST").ParseOptions) => {
274
349
  readonly message: string;
275
350
  readonly facts: readonly ({
@@ -283,17 +358,24 @@ export declare const encodeStepResult: (input: StepResult, options?: import("eff
283
358
  } | {
284
359
  readonly _tag: "Comment";
285
360
  readonly url: string;
361
+ readonly kind: "issue-comment" | "review" | "review-comment";
362
+ readonly at?: string;
286
363
  })[];
287
364
  };
288
365
  export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | AttemptChannel.OutboundEnvelope, options?: import("effect/SchemaAST").ParseOptions) => {
289
366
  readonly _tag: "OutboundEnvelope";
290
- readonly version: 6;
367
+ readonly version: 7;
291
368
  readonly attemptId: string;
292
369
  readonly sequence: number;
293
370
  readonly sentAt: string;
294
371
  readonly payload: {
295
372
  readonly _tag: "Started";
296
373
  readonly parentModel: string;
374
+ readonly conflictingSalvage?: {
375
+ readonly _tag: "Pushed";
376
+ readonly ref: string;
377
+ readonly commit: string;
378
+ } | null;
297
379
  } | {
298
380
  readonly _tag: "SessionEvent";
299
381
  readonly event: {
@@ -317,6 +399,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
317
399
  readonly model: string;
318
400
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
319
401
  };
402
+ readonly gatewayCredential?: "api-key" | "subscription";
320
403
  };
321
404
  readonly harnessSession?: {
322
405
  readonly id: string;
@@ -343,6 +426,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
343
426
  readonly model: string;
344
427
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
345
428
  };
429
+ readonly gatewayCredential?: "api-key" | "subscription";
346
430
  };
347
431
  readonly text: string;
348
432
  } | {
@@ -366,6 +450,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
366
450
  readonly model: string;
367
451
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
368
452
  };
453
+ readonly gatewayCredential?: "api-key" | "subscription";
369
454
  };
370
455
  readonly callId: string;
371
456
  readonly tool: string;
@@ -391,6 +476,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
391
476
  readonly model: string;
392
477
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
393
478
  };
479
+ readonly gatewayCredential?: "api-key" | "subscription";
394
480
  };
395
481
  readonly callId: string;
396
482
  readonly tool: string;
@@ -417,6 +503,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
417
503
  readonly model: string;
418
504
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
419
505
  };
506
+ readonly gatewayCredential?: "api-key" | "subscription";
420
507
  };
421
508
  readonly pool: "apiKeys" | "chatgptPlan" | "claudePlan";
422
509
  readonly rateLimits: {
@@ -454,6 +541,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
454
541
  readonly model: string;
455
542
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
456
543
  };
544
+ readonly gatewayCredential?: "api-key" | "subscription";
457
545
  };
458
546
  } | {
459
547
  readonly _tag: "SessionIdle";
@@ -476,6 +564,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
476
564
  readonly model: string;
477
565
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
478
566
  };
567
+ readonly gatewayCredential?: "api-key" | "subscription";
479
568
  };
480
569
  } | {
481
570
  readonly _tag: "SessionResumed";
@@ -498,6 +587,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
498
587
  readonly model: string;
499
588
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
500
589
  };
590
+ readonly gatewayCredential?: "api-key" | "subscription";
501
591
  };
502
592
  } | {
503
593
  readonly _tag: "SessionTokensUpdated";
@@ -520,8 +610,59 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
520
610
  readonly model: string;
521
611
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
522
612
  };
613
+ readonly gatewayCredential?: "api-key" | "subscription";
523
614
  };
524
615
  readonly totalTokens: number;
616
+ readonly costUsd?: number;
617
+ } | {
618
+ readonly _tag: "ProviderRetrying";
619
+ readonly session: {
620
+ readonly _tag: "ParentSession";
621
+ readonly id: string;
622
+ readonly agent: string;
623
+ readonly brain: {
624
+ readonly harness: "claude" | "codex" | "pi";
625
+ readonly model: string;
626
+ readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
627
+ };
628
+ } | {
629
+ readonly _tag: "ChildSession";
630
+ readonly id: string;
631
+ readonly parentId: string;
632
+ readonly agent: string;
633
+ readonly brain: {
634
+ readonly harness: "claude" | "codex" | "pi";
635
+ readonly model: string;
636
+ readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
637
+ };
638
+ readonly gatewayCredential?: "api-key" | "subscription";
639
+ };
640
+ readonly message: string;
641
+ readonly retries: number;
642
+ } | {
643
+ readonly _tag: "ProviderRecovered";
644
+ readonly session: {
645
+ readonly _tag: "ParentSession";
646
+ readonly id: string;
647
+ readonly agent: string;
648
+ readonly brain: {
649
+ readonly harness: "claude" | "codex" | "pi";
650
+ readonly model: string;
651
+ readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
652
+ };
653
+ } | {
654
+ readonly _tag: "ChildSession";
655
+ readonly id: string;
656
+ readonly parentId: string;
657
+ readonly agent: string;
658
+ readonly brain: {
659
+ readonly harness: "claude" | "codex" | "pi";
660
+ readonly model: string;
661
+ readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
662
+ };
663
+ readonly gatewayCredential?: "api-key" | "subscription";
664
+ };
665
+ readonly retries: number;
525
666
  };
526
667
  } | {
527
668
  readonly _tag: "Final";
@@ -538,6 +679,8 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
538
679
  } | {
539
680
  readonly _tag: "Comment";
540
681
  readonly url: string;
682
+ readonly kind: "issue-comment" | "review" | "review-comment";
683
+ readonly at?: string;
541
684
  })[];
542
685
  };
543
686
  } | {
@@ -553,6 +696,12 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
553
696
  } | {
554
697
  readonly _tag: "AgentFailure";
555
698
  readonly message: string;
699
+ } | {
700
+ readonly _tag: "BlockedFailure";
701
+ readonly message: string;
702
+ } | {
703
+ readonly _tag: "QuestionFailure";
704
+ readonly question: string;
556
705
  } | {
557
706
  readonly _tag: "RunawayFailure";
558
707
  readonly ceiling: "tokens" | "wall-clock";
@@ -589,6 +738,7 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
589
738
  readonly state: {
590
739
  readonly held: boolean;
591
740
  readonly paused: boolean;
741
+ readonly queued?: boolean;
592
742
  };
593
743
  } | {
594
744
  readonly _tag: "InterventionRejected";
@@ -614,10 +764,19 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
614
764
  };
615
765
  };
616
766
  readonly message: string;
767
+ } | {
768
+ readonly _tag: "WorkerUnresponsive";
769
+ readonly worker: string;
770
+ readonly lastAnsweredAt: string;
771
+ readonly reason: string;
772
+ } | {
773
+ readonly _tag: "WorkerResponsive";
774
+ readonly worker: string;
775
+ readonly lastAnsweredAt: string;
617
776
  };
618
777
  } | {
619
778
  readonly _tag: "InboundEnvelope";
620
- readonly version: 6;
779
+ readonly version: 7;
621
780
  readonly attemptId: string;
622
781
  readonly sequence: number;
623
782
  readonly sentAt: string;
@@ -659,11 +818,17 @@ export declare const encodeBrainSpec: (input: BrainSpec, options?: import("effec
659
818
  readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
660
819
  };
661
820
  export declare const persistence: (operation: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, RunStoreError, R>;
662
- export declare const eventFromRow: (row: EventRouteRow) => Event;
821
+ /** The Event columns shared by route rows and Run Event rows. */
822
+ type EventColumns = Pick<EventRouteRow, "eventId" | "dedupKey" | "payload" | "receivedAt">;
823
+ export declare const eventFromRow: (row: EventColumns) => Event;
824
+ export declare const runEventFromRow: (row: typeof RunEventRow.Type) => RunEvent;
663
825
  export declare const submissionFromRow: (row: EventRouteRow) => Submission;
664
826
  export declare const runFromRow: (row: RunRow) => Run;
827
+ export declare const approvalFromRow: (row: RunRow) => Option.Option<RunApproval>;
828
+ export declare const runAgainFromRow: (row: RunRow) => Option.Option<RunAgain>;
665
829
  export declare const stepFromRow: (row: RunRow) => Step;
666
830
  export declare const attemptFromRow: (row: AttemptRow) => Attempt;
667
831
  export declare const runSummaryFromRow: (row: RunRow, storedAttempts: ReadonlyArray<AttemptRow>) => RunSummary;
668
832
  export declare const transcriptEntryFromRow: (row: TranscriptRow) => TranscriptEntry;
833
+ export {};
669
834
  //# sourceMappingURL=codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/store/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAW,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAyC,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AA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