@usine/engine 0.0.1 → 0.2.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.
- package/README.md +91 -2
- package/dist/cursor/cursor.d.ts +20 -0
- package/dist/cursor/cursor.d.ts.map +1 -0
- package/dist/cursor/cursor.js +55 -0
- package/dist/cursor/cursor.js.map +1 -0
- package/dist/cycle-budget/cycle-budget.d.ts +25 -0
- package/dist/cycle-budget/cycle-budget.d.ts.map +1 -0
- package/dist/cycle-budget/cycle-budget.js +117 -0
- package/dist/cycle-budget/cycle-budget.js.map +1 -0
- package/dist/cycle-budget/model.d.ts +26 -0
- package/dist/cycle-budget/model.d.ts.map +1 -0
- package/dist/cycle-budget/model.js +20 -0
- package/dist/cycle-budget/model.js.map +1 -0
- package/dist/cycle-budget/queries.d.ts +27 -0
- package/dist/cycle-budget/queries.d.ts.map +1 -0
- package/dist/cycle-budget/queries.js +175 -0
- package/dist/cycle-budget/queries.js.map +1 -0
- package/dist/database/database.d.ts +15 -0
- package/dist/database/database.d.ts.map +1 -0
- package/dist/database/database.js +5 -0
- package/dist/database/database.js.map +1 -0
- package/dist/database/local-sqlite.d.ts +37 -0
- package/dist/database/local-sqlite.d.ts.map +1 -0
- package/dist/database/local-sqlite.js +144 -0
- package/dist/database/local-sqlite.js.map +1 -0
- package/dist/database/schema.d.ts +1341 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +224 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/engine/engine.d.ts +55 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/engine.js +193 -0
- package/dist/engine/engine.js.map +1 -0
- package/dist/engine/error.d.ts +37 -0
- package/dist/engine/error.d.ts.map +1 -0
- package/dist/engine/error.js +41 -0
- package/dist/engine/error.js.map +1 -0
- package/dist/engine/lifecycle.d.ts +112 -0
- package/dist/engine/lifecycle.d.ts.map +1 -0
- package/dist/engine/lifecycle.js +132 -0
- package/dist/engine/lifecycle.js.map +1 -0
- package/dist/engine/shutdown.d.ts +12 -0
- package/dist/engine/shutdown.d.ts.map +1 -0
- package/dist/engine/shutdown.js +10 -0
- package/dist/engine/shutdown.js.map +1 -0
- package/dist/engine/submission.d.ts +58 -0
- package/dist/engine/submission.d.ts.map +1 -0
- package/dist/engine/submission.js +54 -0
- package/dist/engine/submission.js.map +1 -0
- package/dist/item-projection/item-projection.d.ts +25 -0
- package/dist/item-projection/item-projection.d.ts.map +1 -0
- package/dist/item-projection/item-projection.js +100 -0
- package/dist/item-projection/item-projection.js.map +1 -0
- package/dist/item-projection/model.d.ts +18 -0
- package/dist/item-projection/model.d.ts.map +1 -0
- package/dist/item-projection/model.js +16 -0
- package/dist/item-projection/model.js.map +1 -0
- package/dist/loop-control/loop-control.d.ts +21 -0
- package/dist/loop-control/loop-control.d.ts.map +1 -0
- package/dist/loop-control/loop-control.js +71 -0
- package/dist/loop-control/loop-control.js.map +1 -0
- package/dist/loop-control/model.d.ts +10 -0
- package/dist/loop-control/model.d.ts.map +1 -0
- package/dist/loop-control/model.js +9 -0
- package/dist/loop-control/model.js.map +1 -0
- package/dist/repository-label-projection/model.d.ts +19 -0
- package/dist/repository-label-projection/model.d.ts.map +1 -0
- package/dist/repository-label-projection/model.js +20 -0
- package/dist/repository-label-projection/model.js.map +1 -0
- package/dist/repository-label-projection/repository-label-projection.d.ts +20 -0
- package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -0
- package/dist/repository-label-projection/repository-label-projection.js +83 -0
- package/dist/repository-label-projection/repository-label-projection.js.map +1 -0
- package/dist/run-reader/model.d.ts +46 -0
- package/dist/run-reader/model.d.ts.map +1 -0
- package/dist/run-reader/model.js +44 -0
- package/dist/run-reader/model.js.map +1 -0
- package/dist/run-reader/run-reader.d.ts +29 -0
- package/dist/run-reader/run-reader.d.ts.map +1 -0
- package/dist/run-reader/run-reader.js +44 -0
- package/dist/run-reader/run-reader.js.map +1 -0
- package/dist/step-executor.d.ts +43 -0
- package/dist/step-executor.d.ts.map +1 -0
- package/dist/step-executor.js +25 -0
- package/dist/step-executor.js.map +1 -0
- package/dist/store/codec.d.ts +495 -0
- package/dist/store/codec.d.ts.map +1 -0
- package/dist/store/codec.js +162 -0
- package/dist/store/codec.js.map +1 -0
- package/dist/store/queries.d.ts +107 -0
- package/dist/store/queries.d.ts.map +1 -0
- package/dist/store/queries.js +543 -0
- package/dist/store/queries.js.map +1 -0
- package/dist/store/store.d.ts +101 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +432 -0
- package/dist/store/store.js.map +1 -0
- package/dist/transcript.d.ts +64 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/transcript.js +59 -0
- package/dist/transcript.js.map +1 -0
- package/dist/workflow/admission.d.ts +13 -0
- package/dist/workflow/admission.d.ts.map +1 -0
- package/dist/workflow/admission.js +55 -0
- package/dist/workflow/admission.js.map +1 -0
- package/dist/workflow/command.d.ts +13 -0
- package/dist/workflow/command.d.ts.map +1 -0
- package/dist/workflow/command.js +17 -0
- package/dist/workflow/command.js.map +1 -0
- package/dist/workflow/workflow.d.ts +18 -0
- package/dist/workflow/workflow.d.ts.map +1 -0
- package/dist/workflow/workflow.js +108 -0
- package/dist/workflow/workflow.js.map +1 -0
- package/drizzle/20260825055549_initial_runtime/migration.sql +73 -0
- package/drizzle/20260825055549_initial_runtime/snapshot.json +592 -0
- package/drizzle/20260830191125_polling_cursors/migration.sql +5 -0
- package/drizzle/20260830191125_polling_cursors/snapshot.json +629 -0
- package/drizzle/20260831073158_attempt_channel/migration.sql +36 -0
- package/drizzle/20260831073158_attempt_channel/snapshot.json +845 -0
- package/drizzle/20260831133534_agent_context/migration.sql +49 -0
- package/drizzle/20260831133534_agent_context/snapshot.json +897 -0
- package/drizzle/20260831134612_attempt_brain/migration.sql +26 -0
- package/drizzle/20260831134612_attempt_brain/snapshot.json +923 -0
- package/drizzle/20260831194605_loop_runtime/migration.sql +4 -0
- package/drizzle/20260831194605_loop_runtime/snapshot.json +954 -0
- package/drizzle/20260901073233_projection_revision/migration.sql +55 -0
- package/drizzle/20260901073233_projection_revision/snapshot.json +991 -0
- package/drizzle/20260901180433_item_projections/migration.sql +22 -0
- package/drizzle/20260901180433_item_projections/snapshot.json +1110 -0
- package/drizzle/20260901185146_repository_label_projections/migration.sql +17 -0
- package/drizzle/20260901185146_repository_label_projections/snapshot.json +1147 -0
- package/drizzle/20260903091940_queued_approved_runs/migration.sql +3 -0
- package/drizzle/20260903091940_queued_approved_runs/snapshot.json +1147 -0
- package/drizzle/20260905150403_item_cycle_budgets/migration.sql +58 -0
- package/drizzle/20260905150403_item_cycle_budgets/snapshot.json +1417 -0
- package/drizzle/20260905174009_item_run_history/migration.sql +1 -0
- package/drizzle/20260905174009_item_run_history/snapshot.json +1431 -0
- package/package.json +60 -6
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { Agent } from "@usine/core/agent";
|
|
2
|
+
import { BrainSpec } from "@usine/core/agent/brain";
|
|
3
|
+
import { Attempt } from "@usine/core/attempt";
|
|
4
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
5
|
+
import { Event } from "@usine/core/event";
|
|
6
|
+
import { Run } from "@usine/core/run";
|
|
7
|
+
import { Step } from "@usine/core/step";
|
|
8
|
+
import * as RunState from "@usine/core/run/state";
|
|
9
|
+
import { StepResult } from "@usine/core/step/result";
|
|
10
|
+
import { Effect, Schema } from "effect";
|
|
11
|
+
import { RunStoreError } from "../engine/error.ts";
|
|
12
|
+
import { Submission } from "../engine/submission.ts";
|
|
13
|
+
import { RunSummary } from "../run-reader/model.ts";
|
|
14
|
+
import { TranscriptEntry } from "../transcript.ts";
|
|
15
|
+
export declare const EventRouteRow: Schema.Struct<{
|
|
16
|
+
readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
17
|
+
readonly dedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
|
|
18
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
19
|
+
readonly receivedAt: Schema.DateTimeUtcFromString;
|
|
20
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
21
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
22
|
+
readonly step: Schema.brand<Schema.NonEmptyString, "StepName">;
|
|
23
|
+
readonly approval: Schema.Literals<readonly ["none", "required"]>;
|
|
24
|
+
readonly cycleLimit: Schema.NullOr<Schema.brand<Schema.Int, "CycleLimit">>;
|
|
25
|
+
readonly cycleGeneration: Schema.brand<Schema.Int, "CycleGeneration">;
|
|
26
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
27
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
28
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
29
|
+
readonly agent: typeof Agent;
|
|
30
|
+
readonly parentModel: Schema.NullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
31
|
+
}>;
|
|
32
|
+
export type EventRouteRow = typeof EventRouteRow.Type;
|
|
33
|
+
export declare const RunRow: Schema.Struct<{
|
|
34
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
35
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
36
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
37
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
38
|
+
readonly agent: typeof Agent;
|
|
39
|
+
readonly parentModel: Schema.NullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
40
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
41
|
+
readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
42
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
43
|
+
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]>;
|
|
44
|
+
readonly openedAt: Schema.DateTimeUtcFromString;
|
|
45
|
+
readonly stepName: Schema.brand<Schema.NonEmptyString, "StepName">;
|
|
46
|
+
readonly result: Schema.NullOr<typeof StepResult>;
|
|
47
|
+
}>;
|
|
48
|
+
export type RunRow = typeof RunRow.Type;
|
|
49
|
+
export declare const AttemptRow: Schema.Struct<{
|
|
50
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
51
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
52
|
+
readonly stepName: Schema.brand<Schema.NonEmptyString, "StepName">;
|
|
53
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
54
|
+
readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
|
|
55
|
+
readonly brain: typeof BrainSpec;
|
|
56
|
+
readonly parentModel: Schema.NullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
57
|
+
readonly startedAt: Schema.DateTimeUtcFromString;
|
|
58
|
+
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]>>;
|
|
59
|
+
}>;
|
|
60
|
+
export type AttemptRow = typeof AttemptRow.Type;
|
|
61
|
+
export declare const TranscriptRow: Schema.Struct<{
|
|
62
|
+
readonly sequence: Schema.brand<Schema.Int, "TranscriptSequence">;
|
|
63
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
64
|
+
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
65
|
+
readonly envelope: Schema.Union<readonly [Schema.Union<readonly [typeof AttemptChannel.OutboundEnvelope, typeof AttemptChannel.InboundEnvelope]>, Schema.Union<readonly [Schema.Struct<{
|
|
66
|
+
readonly _tag: Schema.tag<"OutboundEnvelope">;
|
|
67
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
68
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
69
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
70
|
+
readonly payload: Schema.Union<readonly [typeof AttemptChannel.Started, typeof AttemptChannel.SessionEvent, typeof AttemptChannel.Final, typeof AttemptChannel.Failed, typeof AttemptChannel.Interrupted]>;
|
|
71
|
+
readonly version: Schema.Literal<3>;
|
|
72
|
+
}>, Schema.Struct<{
|
|
73
|
+
readonly _tag: Schema.tag<"InboundEnvelope">;
|
|
74
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
75
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
76
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
77
|
+
readonly payload: Schema.Union<readonly [typeof AttemptChannel.Steer, typeof AttemptChannel.Interrupt]>;
|
|
78
|
+
readonly version: Schema.Literal<3>;
|
|
79
|
+
}>]>]>;
|
|
80
|
+
readonly receivedAt: Schema.DateTimeUtcFromString;
|
|
81
|
+
}>;
|
|
82
|
+
export type TranscriptRow = typeof TranscriptRow.Type;
|
|
83
|
+
export declare const WorkflowCommandRow: Schema.Struct<{
|
|
84
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
85
|
+
readonly command: Schema.Literals<readonly ["Approve", "Continue", "Interrupt", "Resume"]>;
|
|
86
|
+
}>;
|
|
87
|
+
export type WorkflowCommandRow = typeof WorkflowCommandRow.Type;
|
|
88
|
+
export declare const decodeEventRoutes: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
89
|
+
readonly eventId: string & import("effect/Brand").Brand<"EventId">;
|
|
90
|
+
readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
|
|
91
|
+
readonly payload: Schema.Json;
|
|
92
|
+
readonly receivedAt: import("effect/DateTime").Utc;
|
|
93
|
+
readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
|
|
94
|
+
readonly loop: string & import("effect/Brand").Brand<"LoopName">;
|
|
95
|
+
readonly step: string & import("effect/Brand").Brand<"StepName">;
|
|
96
|
+
readonly approval: "none" | "required";
|
|
97
|
+
readonly cycleLimit: (number & import("effect/Brand").Brand<"CycleLimit">) | null;
|
|
98
|
+
readonly cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
|
|
99
|
+
readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
100
|
+
readonly revision: string & import("effect/Brand").Brand<"RepositoryRevision">;
|
|
101
|
+
readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
|
|
102
|
+
readonly agent: Agent;
|
|
103
|
+
readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
|
|
104
|
+
}[], Schema.SchemaError, never>;
|
|
105
|
+
export declare const decodeRunRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
106
|
+
readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
|
|
107
|
+
readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
108
|
+
readonly revision: string & import("effect/Brand").Brand<"RepositoryRevision">;
|
|
109
|
+
readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
|
|
110
|
+
readonly agent: Agent;
|
|
111
|
+
readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
|
|
112
|
+
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
113
|
+
readonly eventId: string & import("effect/Brand").Brand<"EventId">;
|
|
114
|
+
readonly loop: string & import("effect/Brand").Brand<"LoopName">;
|
|
115
|
+
readonly state: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting;
|
|
116
|
+
readonly openedAt: import("effect/DateTime").Utc;
|
|
117
|
+
readonly stepName: string & import("effect/Brand").Brand<"StepName">;
|
|
118
|
+
readonly result: StepResult | null;
|
|
119
|
+
}[], Schema.SchemaError, never>;
|
|
120
|
+
export declare const decodeAttemptRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
121
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
122
|
+
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
123
|
+
readonly stepName: string & import("effect/Brand").Brand<"StepName">;
|
|
124
|
+
readonly worker: string & import("effect/Brand").Brand<"WorkerName">;
|
|
125
|
+
readonly number: number & import("effect/Brand").Brand<"AttemptNumber">;
|
|
126
|
+
readonly brain: BrainSpec;
|
|
127
|
+
readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
|
|
128
|
+
readonly startedAt: import("effect/DateTime").Utc;
|
|
129
|
+
readonly outcome: import("@usine/core/attempt/outcome").AttemptCanceled | import("@usine/core/attempt/outcome").AttemptFailed | import("@usine/core/attempt/outcome").AttemptSucceeded | null;
|
|
130
|
+
}[], Schema.SchemaError, never>;
|
|
131
|
+
export declare const decodeRecoverableRuns: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
132
|
+
readonly eventId: string & import("effect/Brand").Brand<"EventId">;
|
|
133
|
+
readonly dedupKey: string & import("effect/Brand").Brand<"DedupKey">;
|
|
134
|
+
readonly payload: Schema.Json;
|
|
135
|
+
readonly receivedAt: import("effect/DateTime").Utc;
|
|
136
|
+
readonly itemKey: string & import("effect/Brand").Brand<"ItemKey">;
|
|
137
|
+
readonly loop: string & import("effect/Brand").Brand<"LoopName">;
|
|
138
|
+
readonly step: string & import("effect/Brand").Brand<"StepName">;
|
|
139
|
+
readonly approval: "none" | "required";
|
|
140
|
+
readonly cycleLimit: (number & import("effect/Brand").Brand<"CycleLimit">) | null;
|
|
141
|
+
readonly cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
|
|
142
|
+
readonly repository: string & import("effect/Brand").Brand<"RepositoryName">;
|
|
143
|
+
readonly revision: string & import("effect/Brand").Brand<"RepositoryRevision">;
|
|
144
|
+
readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
|
|
145
|
+
readonly agent: Agent;
|
|
146
|
+
readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
|
|
147
|
+
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
148
|
+
readonly state: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting;
|
|
149
|
+
}[], Schema.SchemaError, never>;
|
|
150
|
+
export declare const decodeRunIds: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
151
|
+
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
152
|
+
}[], Schema.SchemaError, never>;
|
|
153
|
+
export declare const decodeDiscards: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
154
|
+
readonly reason: "revoked" | "superseded";
|
|
155
|
+
}[], Schema.SchemaError, never>;
|
|
156
|
+
export declare const decodeWorkflowCommands: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
157
|
+
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
158
|
+
readonly command: "Approve" | "Continue" | "Interrupt" | "Resume";
|
|
159
|
+
}[], Schema.SchemaError, never>;
|
|
160
|
+
export declare const decodeProjectionRevision: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
161
|
+
readonly revision: number & import("effect/Brand").Brand<"ProjectionRevision">;
|
|
162
|
+
}[], Schema.SchemaError, never>;
|
|
163
|
+
export declare const decodeTranscriptRows: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Effect.Effect<readonly {
|
|
164
|
+
readonly sequence: number & import("effect/Brand").Brand<"TranscriptSequence">;
|
|
165
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
166
|
+
readonly direction: "inbound" | "outbound";
|
|
167
|
+
readonly envelope: AttemptChannel.InboundEnvelope | AttemptChannel.OutboundEnvelope | {
|
|
168
|
+
readonly _tag: "OutboundEnvelope";
|
|
169
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
170
|
+
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
171
|
+
readonly sentAt: import("effect/DateTime").Utc;
|
|
172
|
+
readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.SessionEvent | AttemptChannel.Started;
|
|
173
|
+
readonly version: 3;
|
|
174
|
+
} | {
|
|
175
|
+
readonly _tag: "InboundEnvelope";
|
|
176
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
177
|
+
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
178
|
+
readonly sentAt: import("effect/DateTime").Utc;
|
|
179
|
+
readonly payload: AttemptChannel.Interrupt | AttemptChannel.Steer;
|
|
180
|
+
readonly version: 3;
|
|
181
|
+
};
|
|
182
|
+
readonly receivedAt: import("effect/DateTime").Utc;
|
|
183
|
+
}[], Schema.SchemaError, never>;
|
|
184
|
+
export declare const encodePayload: (input: Schema.Json, options?: import("effect/SchemaAST").ParseOptions) => Schema.Json;
|
|
185
|
+
export declare const encodeDateTime: (input: import("effect/DateTime").Utc, options?: import("effect/SchemaAST").ParseOptions) => string;
|
|
186
|
+
export declare const encodeRunState: (input: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
187
|
+
readonly _tag: "Succeeded";
|
|
188
|
+
} | {
|
|
189
|
+
readonly _tag: "Pending";
|
|
190
|
+
} | {
|
|
191
|
+
readonly _tag: "Waiting";
|
|
192
|
+
} | {
|
|
193
|
+
readonly _tag: "Queued";
|
|
194
|
+
} | {
|
|
195
|
+
readonly _tag: "Running";
|
|
196
|
+
} | {
|
|
197
|
+
readonly _tag: "Failed";
|
|
198
|
+
} | {
|
|
199
|
+
readonly _tag: "Canceled";
|
|
200
|
+
readonly reason: {
|
|
201
|
+
readonly _tag: "OperatorCanceled";
|
|
202
|
+
} | {
|
|
203
|
+
readonly _tag: "Superseded";
|
|
204
|
+
readonly by: string;
|
|
205
|
+
} | {
|
|
206
|
+
readonly _tag: "Revoked";
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
export declare const encodeOutcome: (input: import("@usine/core/attempt/outcome").AttemptCanceled | import("@usine/core/attempt/outcome").AttemptFailed | import("@usine/core/attempt/outcome").AttemptSucceeded, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
210
|
+
readonly _tag: "Succeeded";
|
|
211
|
+
} | {
|
|
212
|
+
readonly _tag: "Failed";
|
|
213
|
+
readonly failure: {
|
|
214
|
+
readonly _tag: "InfraFailure";
|
|
215
|
+
readonly message: string;
|
|
216
|
+
readonly cause: Schema.Json;
|
|
217
|
+
} | {
|
|
218
|
+
readonly _tag: "DefectFailure";
|
|
219
|
+
readonly message: string;
|
|
220
|
+
readonly cause: Schema.Json;
|
|
221
|
+
} | {
|
|
222
|
+
readonly _tag: "AgentFailure";
|
|
223
|
+
readonly message: string;
|
|
224
|
+
} | {
|
|
225
|
+
readonly _tag: "RunawayFailure";
|
|
226
|
+
readonly ceiling: "tokens" | "wall-clock";
|
|
227
|
+
} | {
|
|
228
|
+
readonly _tag: "ChildSessionBudgetFailure";
|
|
229
|
+
readonly maxChildren: number;
|
|
230
|
+
readonly attemptedChildren: number;
|
|
231
|
+
};
|
|
232
|
+
} | {
|
|
233
|
+
readonly _tag: "Canceled";
|
|
234
|
+
};
|
|
235
|
+
export declare const encodeStepResult: (input: StepResult, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
236
|
+
readonly message: string;
|
|
237
|
+
readonly facts: readonly ({
|
|
238
|
+
readonly _tag: "Commit";
|
|
239
|
+
readonly sha: string;
|
|
240
|
+
readonly summary: string;
|
|
241
|
+
} | {
|
|
242
|
+
readonly _tag: "PullRequest";
|
|
243
|
+
readonly number: number;
|
|
244
|
+
readonly url: string;
|
|
245
|
+
} | {
|
|
246
|
+
readonly _tag: "Comment";
|
|
247
|
+
readonly url: string;
|
|
248
|
+
})[];
|
|
249
|
+
};
|
|
250
|
+
export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | AttemptChannel.OutboundEnvelope, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
251
|
+
readonly _tag: "OutboundEnvelope";
|
|
252
|
+
readonly version: 4;
|
|
253
|
+
readonly attemptId: string;
|
|
254
|
+
readonly sequence: number;
|
|
255
|
+
readonly sentAt: string;
|
|
256
|
+
readonly payload: {
|
|
257
|
+
readonly _tag: "Started";
|
|
258
|
+
readonly parentModel: string;
|
|
259
|
+
} | {
|
|
260
|
+
readonly _tag: "SessionEvent";
|
|
261
|
+
readonly event: {
|
|
262
|
+
readonly _tag: "SessionStarted";
|
|
263
|
+
readonly session: {
|
|
264
|
+
readonly _tag: "ParentSession";
|
|
265
|
+
readonly id: string;
|
|
266
|
+
readonly agent: string;
|
|
267
|
+
readonly brain: {
|
|
268
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
269
|
+
readonly model: string;
|
|
270
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
271
|
+
};
|
|
272
|
+
} | {
|
|
273
|
+
readonly _tag: "ChildSession";
|
|
274
|
+
readonly id: string;
|
|
275
|
+
readonly parentId: string;
|
|
276
|
+
readonly agent: string;
|
|
277
|
+
readonly brain: {
|
|
278
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
279
|
+
readonly model: string;
|
|
280
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
} | {
|
|
284
|
+
readonly _tag: "TextOutput";
|
|
285
|
+
readonly session: {
|
|
286
|
+
readonly _tag: "ParentSession";
|
|
287
|
+
readonly id: string;
|
|
288
|
+
readonly agent: string;
|
|
289
|
+
readonly brain: {
|
|
290
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
291
|
+
readonly model: string;
|
|
292
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
293
|
+
};
|
|
294
|
+
} | {
|
|
295
|
+
readonly _tag: "ChildSession";
|
|
296
|
+
readonly id: string;
|
|
297
|
+
readonly parentId: string;
|
|
298
|
+
readonly agent: string;
|
|
299
|
+
readonly brain: {
|
|
300
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
301
|
+
readonly model: string;
|
|
302
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
readonly text: string;
|
|
306
|
+
} | {
|
|
307
|
+
readonly _tag: "ToolStarted";
|
|
308
|
+
readonly session: {
|
|
309
|
+
readonly _tag: "ParentSession";
|
|
310
|
+
readonly id: string;
|
|
311
|
+
readonly agent: string;
|
|
312
|
+
readonly brain: {
|
|
313
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
314
|
+
readonly model: string;
|
|
315
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
316
|
+
};
|
|
317
|
+
} | {
|
|
318
|
+
readonly _tag: "ChildSession";
|
|
319
|
+
readonly id: string;
|
|
320
|
+
readonly parentId: string;
|
|
321
|
+
readonly agent: string;
|
|
322
|
+
readonly brain: {
|
|
323
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
324
|
+
readonly model: string;
|
|
325
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
readonly callId: string;
|
|
329
|
+
readonly tool: string;
|
|
330
|
+
readonly input: Schema.Json;
|
|
331
|
+
} | {
|
|
332
|
+
readonly _tag: "ToolFinished";
|
|
333
|
+
readonly session: {
|
|
334
|
+
readonly _tag: "ParentSession";
|
|
335
|
+
readonly id: string;
|
|
336
|
+
readonly agent: string;
|
|
337
|
+
readonly brain: {
|
|
338
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
339
|
+
readonly model: string;
|
|
340
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
341
|
+
};
|
|
342
|
+
} | {
|
|
343
|
+
readonly _tag: "ChildSession";
|
|
344
|
+
readonly id: string;
|
|
345
|
+
readonly parentId: string;
|
|
346
|
+
readonly agent: string;
|
|
347
|
+
readonly brain: {
|
|
348
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
349
|
+
readonly model: string;
|
|
350
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
readonly callId: string;
|
|
354
|
+
readonly tool: string;
|
|
355
|
+
readonly output: Schema.Json;
|
|
356
|
+
readonly isError: boolean;
|
|
357
|
+
} | {
|
|
358
|
+
readonly _tag: "PoolRateLimitsUpdated";
|
|
359
|
+
readonly session: {
|
|
360
|
+
readonly _tag: "ParentSession";
|
|
361
|
+
readonly id: string;
|
|
362
|
+
readonly agent: string;
|
|
363
|
+
readonly brain: {
|
|
364
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
365
|
+
readonly model: string;
|
|
366
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
367
|
+
};
|
|
368
|
+
} | {
|
|
369
|
+
readonly _tag: "ChildSession";
|
|
370
|
+
readonly id: string;
|
|
371
|
+
readonly parentId: string;
|
|
372
|
+
readonly agent: string;
|
|
373
|
+
readonly brain: {
|
|
374
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
375
|
+
readonly model: string;
|
|
376
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
readonly pool: "apiKeys" | "chatgptPlan" | "claudePlan";
|
|
380
|
+
readonly rateLimits: {
|
|
381
|
+
readonly limitId: string | null;
|
|
382
|
+
readonly limitName: string | null;
|
|
383
|
+
readonly primary: {
|
|
384
|
+
readonly usedPercent: number;
|
|
385
|
+
readonly windowDurationMinutes: number | null;
|
|
386
|
+
readonly resetsAt: string | null;
|
|
387
|
+
} | null;
|
|
388
|
+
readonly secondary: {
|
|
389
|
+
readonly usedPercent: number;
|
|
390
|
+
readonly windowDurationMinutes: number | null;
|
|
391
|
+
readonly resetsAt: string | null;
|
|
392
|
+
} | null;
|
|
393
|
+
};
|
|
394
|
+
} | {
|
|
395
|
+
readonly _tag: "SessionFinished";
|
|
396
|
+
readonly session: {
|
|
397
|
+
readonly _tag: "ParentSession";
|
|
398
|
+
readonly id: string;
|
|
399
|
+
readonly agent: string;
|
|
400
|
+
readonly brain: {
|
|
401
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
402
|
+
readonly model: string;
|
|
403
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
404
|
+
};
|
|
405
|
+
} | {
|
|
406
|
+
readonly _tag: "ChildSession";
|
|
407
|
+
readonly id: string;
|
|
408
|
+
readonly parentId: string;
|
|
409
|
+
readonly agent: string;
|
|
410
|
+
readonly brain: {
|
|
411
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
412
|
+
readonly model: string;
|
|
413
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
} | {
|
|
418
|
+
readonly _tag: "Final";
|
|
419
|
+
readonly result: {
|
|
420
|
+
readonly message: string;
|
|
421
|
+
readonly facts: readonly ({
|
|
422
|
+
readonly _tag: "Commit";
|
|
423
|
+
readonly sha: string;
|
|
424
|
+
readonly summary: string;
|
|
425
|
+
} | {
|
|
426
|
+
readonly _tag: "PullRequest";
|
|
427
|
+
readonly number: number;
|
|
428
|
+
readonly url: string;
|
|
429
|
+
} | {
|
|
430
|
+
readonly _tag: "Comment";
|
|
431
|
+
readonly url: string;
|
|
432
|
+
})[];
|
|
433
|
+
};
|
|
434
|
+
} | {
|
|
435
|
+
readonly _tag: "Failed";
|
|
436
|
+
readonly failure: {
|
|
437
|
+
readonly _tag: "InfraFailure";
|
|
438
|
+
readonly message: string;
|
|
439
|
+
readonly cause: Schema.Json;
|
|
440
|
+
} | {
|
|
441
|
+
readonly _tag: "DefectFailure";
|
|
442
|
+
readonly message: string;
|
|
443
|
+
readonly cause: Schema.Json;
|
|
444
|
+
} | {
|
|
445
|
+
readonly _tag: "AgentFailure";
|
|
446
|
+
readonly message: string;
|
|
447
|
+
} | {
|
|
448
|
+
readonly _tag: "RunawayFailure";
|
|
449
|
+
readonly ceiling: "tokens" | "wall-clock";
|
|
450
|
+
} | {
|
|
451
|
+
readonly _tag: "ChildSessionBudgetFailure";
|
|
452
|
+
readonly maxChildren: number;
|
|
453
|
+
readonly attemptedChildren: number;
|
|
454
|
+
};
|
|
455
|
+
} | {
|
|
456
|
+
readonly _tag: "Interrupted";
|
|
457
|
+
};
|
|
458
|
+
} | {
|
|
459
|
+
readonly _tag: "InboundEnvelope";
|
|
460
|
+
readonly version: 4;
|
|
461
|
+
readonly attemptId: string;
|
|
462
|
+
readonly sequence: number;
|
|
463
|
+
readonly sentAt: string;
|
|
464
|
+
readonly payload: {
|
|
465
|
+
readonly _tag: "Steer";
|
|
466
|
+
readonly message: string;
|
|
467
|
+
} | {
|
|
468
|
+
readonly _tag: "Interrupt";
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
export declare const encodeAgent: (input: Agent, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
472
|
+
readonly name: string;
|
|
473
|
+
readonly brain: {
|
|
474
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
475
|
+
readonly model: string;
|
|
476
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
477
|
+
};
|
|
478
|
+
readonly parentModel: string | null;
|
|
479
|
+
readonly parentEffort?: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
480
|
+
readonly persona: string;
|
|
481
|
+
};
|
|
482
|
+
export declare const encodeBrainSpec: (input: BrainSpec, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
483
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
484
|
+
readonly model: string;
|
|
485
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
486
|
+
};
|
|
487
|
+
export declare const persistence: (operation: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, RunStoreError, R>;
|
|
488
|
+
export declare const eventFromRow: (row: EventRouteRow) => Event;
|
|
489
|
+
export declare const submissionFromRow: (row: EventRouteRow) => Submission;
|
|
490
|
+
export declare const runFromRow: (row: RunRow) => Run;
|
|
491
|
+
export declare const stepFromRow: (row: RunRow) => Step;
|
|
492
|
+
export declare const attemptFromRow: (row: AttemptRow) => Attempt;
|
|
493
|
+
export declare const runSummaryFromRow: (row: RunRow, storedAttempts: ReadonlyArray<AttemptRow>) => RunSummary;
|
|
494
|
+
export declare const transcriptEntryFromRow: (row: TranscriptRow) => TranscriptEntry;
|
|
495
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/store/codec.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Agent } from "@usine/core/agent";
|
|
2
|
+
import { CycleGeneration, CycleLimit } from "@usine/core/cycle-budget";
|
|
3
|
+
import { BrainSpec, ModelId } from "@usine/core/agent/brain";
|
|
4
|
+
import { Attempt, AttemptNumber, AttemptTask, AttemptId } from "@usine/core/attempt";
|
|
5
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
6
|
+
import { AttemptOutcome } from "@usine/core/attempt/outcome";
|
|
7
|
+
import { Event, DedupKey, EventId } from "@usine/core/event";
|
|
8
|
+
import { ApprovalRequirement, LoopName } from "@usine/core/loop";
|
|
9
|
+
import { ItemKey } from "@usine/core/item";
|
|
10
|
+
import { RepositoryName, RepositoryRevision } from "@usine/core/repository";
|
|
11
|
+
import { RunId, Run } from "@usine/core/run";
|
|
12
|
+
import { StepName, Step } from "@usine/core/step";
|
|
13
|
+
import { WorkerName } from "@usine/core/worker";
|
|
14
|
+
import * as RunState from "@usine/core/run/state";
|
|
15
|
+
import { StepResult } from "@usine/core/step/result";
|
|
16
|
+
import { Effect, Option, Schema } from "effect";
|
|
17
|
+
import { EnginePersistenceError, RunStoreError } from "../engine/error.js";
|
|
18
|
+
import { IgnoreReason, Submission } from "../engine/submission.js";
|
|
19
|
+
import { ProjectionRevision, RunSummary } from "../run-reader/model.js";
|
|
20
|
+
import { TranscriptEntry, TranscriptSequence } from "../transcript.js";
|
|
21
|
+
import { WorkflowCommand } from "../workflow/command.js";
|
|
22
|
+
export const EventRouteRow = Schema.Struct({
|
|
23
|
+
eventId: EventId,
|
|
24
|
+
dedupKey: DedupKey,
|
|
25
|
+
payload: Schema.Json,
|
|
26
|
+
receivedAt: Schema.DateTimeUtcFromString,
|
|
27
|
+
itemKey: ItemKey,
|
|
28
|
+
loop: LoopName,
|
|
29
|
+
step: StepName,
|
|
30
|
+
approval: ApprovalRequirement,
|
|
31
|
+
cycleLimit: Schema.NullOr(CycleLimit),
|
|
32
|
+
cycleGeneration: CycleGeneration,
|
|
33
|
+
repository: RepositoryName,
|
|
34
|
+
revision: RepositoryRevision,
|
|
35
|
+
task: AttemptTask,
|
|
36
|
+
agent: Agent,
|
|
37
|
+
parentModel: Schema.NullOr(ModelId),
|
|
38
|
+
});
|
|
39
|
+
export const RunRow = Schema.Struct({
|
|
40
|
+
itemKey: ItemKey,
|
|
41
|
+
repository: RepositoryName,
|
|
42
|
+
revision: RepositoryRevision,
|
|
43
|
+
task: AttemptTask,
|
|
44
|
+
agent: Agent,
|
|
45
|
+
parentModel: Schema.NullOr(ModelId),
|
|
46
|
+
runId: RunId,
|
|
47
|
+
eventId: EventId,
|
|
48
|
+
loop: LoopName,
|
|
49
|
+
state: RunState.RunState,
|
|
50
|
+
openedAt: Schema.DateTimeUtcFromString,
|
|
51
|
+
stepName: StepName,
|
|
52
|
+
result: Schema.NullOr(StepResult),
|
|
53
|
+
});
|
|
54
|
+
export const AttemptRow = Schema.Struct({
|
|
55
|
+
attemptId: AttemptId,
|
|
56
|
+
runId: RunId,
|
|
57
|
+
stepName: StepName,
|
|
58
|
+
worker: WorkerName,
|
|
59
|
+
number: AttemptNumber,
|
|
60
|
+
brain: BrainSpec,
|
|
61
|
+
parentModel: Schema.NullOr(ModelId),
|
|
62
|
+
startedAt: Schema.DateTimeUtcFromString,
|
|
63
|
+
outcome: Schema.NullOr(AttemptOutcome),
|
|
64
|
+
});
|
|
65
|
+
export const TranscriptRow = Schema.Struct({
|
|
66
|
+
sequence: TranscriptSequence,
|
|
67
|
+
attemptId: AttemptId,
|
|
68
|
+
direction: AttemptChannel.Direction,
|
|
69
|
+
envelope: TranscriptEntry.fields.envelope,
|
|
70
|
+
receivedAt: Schema.DateTimeUtcFromString,
|
|
71
|
+
});
|
|
72
|
+
const RecoverableRunRow = Schema.Struct({
|
|
73
|
+
...EventRouteRow.fields,
|
|
74
|
+
runId: RunId,
|
|
75
|
+
state: RunState.RunState,
|
|
76
|
+
});
|
|
77
|
+
const RunIdRow = Schema.Struct({ runId: RunId });
|
|
78
|
+
const DiscardRow = Schema.Struct({ reason: IgnoreReason });
|
|
79
|
+
export const WorkflowCommandRow = Schema.Struct({
|
|
80
|
+
runId: RunId,
|
|
81
|
+
command: WorkflowCommand,
|
|
82
|
+
});
|
|
83
|
+
const ProjectionRevisionRow = Schema.Struct({ revision: ProjectionRevision });
|
|
84
|
+
export const decodeEventRoutes = Schema.decodeUnknownEffect(Schema.Array(EventRouteRow));
|
|
85
|
+
export const decodeRunRows = Schema.decodeUnknownEffect(Schema.Array(RunRow));
|
|
86
|
+
export const decodeAttemptRows = Schema.decodeUnknownEffect(Schema.Array(AttemptRow));
|
|
87
|
+
export const decodeRecoverableRuns = Schema.decodeUnknownEffect(Schema.Array(RecoverableRunRow));
|
|
88
|
+
export const decodeRunIds = Schema.decodeUnknownEffect(Schema.Array(RunIdRow));
|
|
89
|
+
export const decodeDiscards = Schema.decodeUnknownEffect(Schema.Array(DiscardRow));
|
|
90
|
+
export const decodeWorkflowCommands = Schema.decodeUnknownEffect(Schema.Array(WorkflowCommandRow));
|
|
91
|
+
export const decodeProjectionRevision = Schema.decodeUnknownEffect(Schema.Array(ProjectionRevisionRow));
|
|
92
|
+
export const decodeTranscriptRows = Schema.decodeUnknownEffect(Schema.Array(TranscriptRow));
|
|
93
|
+
export const encodePayload = Schema.encodeSync(Schema.Json);
|
|
94
|
+
export const encodeDateTime = Schema.encodeSync(Schema.DateTimeUtcFromString);
|
|
95
|
+
export const encodeRunState = Schema.encodeSync(RunState.RunState);
|
|
96
|
+
export const encodeOutcome = Schema.encodeSync(AttemptOutcome);
|
|
97
|
+
export const encodeStepResult = Schema.encodeSync(StepResult);
|
|
98
|
+
export const encodeEnvelope = Schema.encodeSync(AttemptChannel.Envelope);
|
|
99
|
+
export const encodeAgent = Schema.encodeSync(Agent);
|
|
100
|
+
export const encodeBrainSpec = Schema.encodeSync(BrainSpec);
|
|
101
|
+
const isRunStoreError = Schema.is(RunStoreError);
|
|
102
|
+
export const persistence = (operation) => (effect) => Effect.mapError(effect, (error) => isRunStoreError(error) ? error : new EnginePersistenceError({ operation, cause: error }));
|
|
103
|
+
export const eventFromRow = (row) => new Event({
|
|
104
|
+
id: row.eventId,
|
|
105
|
+
dedupKey: row.dedupKey,
|
|
106
|
+
payload: row.payload,
|
|
107
|
+
receivedAt: row.receivedAt,
|
|
108
|
+
});
|
|
109
|
+
export const submissionFromRow = (row) => new Submission({
|
|
110
|
+
event: eventFromRow(row),
|
|
111
|
+
itemKey: row.itemKey,
|
|
112
|
+
loop: row.loop,
|
|
113
|
+
step: row.step,
|
|
114
|
+
approval: row.approval,
|
|
115
|
+
cycleLimit: Option.fromNullishOr(row.cycleLimit),
|
|
116
|
+
cycleGeneration: row.cycleGeneration,
|
|
117
|
+
repository: row.repository,
|
|
118
|
+
revision: row.revision,
|
|
119
|
+
task: row.task,
|
|
120
|
+
agent: row.agent,
|
|
121
|
+
parentModel: Option.fromNullishOr(row.parentModel),
|
|
122
|
+
});
|
|
123
|
+
export const runFromRow = (row) => new Run({
|
|
124
|
+
id: row.runId,
|
|
125
|
+
eventId: row.eventId,
|
|
126
|
+
loop: row.loop,
|
|
127
|
+
state: row.state,
|
|
128
|
+
openedAt: row.openedAt,
|
|
129
|
+
});
|
|
130
|
+
export const stepFromRow = (row) => new Step({
|
|
131
|
+
runId: row.runId,
|
|
132
|
+
name: row.stepName,
|
|
133
|
+
result: Option.fromNullishOr(row.result),
|
|
134
|
+
});
|
|
135
|
+
export const attemptFromRow = (row) => new Attempt({
|
|
136
|
+
id: row.attemptId,
|
|
137
|
+
runId: row.runId,
|
|
138
|
+
stepName: row.stepName,
|
|
139
|
+
worker: row.worker,
|
|
140
|
+
number: row.number,
|
|
141
|
+
brain: row.brain,
|
|
142
|
+
parentModel: Option.fromNullishOr(row.parentModel),
|
|
143
|
+
startedAt: row.startedAt,
|
|
144
|
+
outcome: Option.fromNullishOr(row.outcome),
|
|
145
|
+
});
|
|
146
|
+
export const runSummaryFromRow = (row, storedAttempts) => new RunSummary({
|
|
147
|
+
itemKey: row.itemKey,
|
|
148
|
+
run: runFromRow(row),
|
|
149
|
+
step: stepFromRow(row),
|
|
150
|
+
attempts: storedAttempts.map(attemptFromRow),
|
|
151
|
+
repository: row.repository,
|
|
152
|
+
task: row.task,
|
|
153
|
+
agent: row.agent,
|
|
154
|
+
});
|
|
155
|
+
export const transcriptEntryFromRow = (row) => new TranscriptEntry({
|
|
156
|
+
sequence: row.sequence,
|
|
157
|
+
attemptId: row.attemptId,
|
|
158
|
+
direction: row.direction,
|
|
159
|
+
envelope: row.envelope,
|
|
160
|
+
receivedAt: row.receivedAt,
|
|
161
|
+
});
|
|
162
|
+
//# sourceMappingURL=codec.js.map
|