@usine/engine 0.2.0 → 0.3.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 +2 -0
- package/dist/database/local-sqlite.d.ts.map +1 -1
- package/dist/database/local-sqlite.js +8 -2
- package/dist/database/local-sqlite.js.map +1 -1
- package/dist/database/schema.d.ts +48 -0
- package/dist/database/schema.d.ts.map +1 -1
- package/dist/database/schema.js +4 -0
- package/dist/database/schema.js.map +1 -1
- package/dist/engine/engine.d.ts +7 -3
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/engine.js +38 -4
- package/dist/engine/engine.js.map +1 -1
- package/dist/engine/error.d.ts +9 -1
- package/dist/engine/error.d.ts.map +1 -1
- package/dist/engine/error.js +8 -0
- package/dist/engine/error.js.map +1 -1
- package/dist/step-executor.d.ts +2 -0
- package/dist/step-executor.d.ts.map +1 -1
- package/dist/step-executor.js.map +1 -1
- package/dist/store/codec.d.ts +184 -10
- package/dist/store/codec.d.ts.map +1 -1
- package/dist/store/codec.js +7 -1
- package/dist/store/codec.js.map +1 -1
- package/dist/store/queries.d.ts +5 -4
- package/dist/store/queries.d.ts.map +1 -1
- package/dist/store/queries.js +35 -57
- package/dist/store/queries.js.map +1 -1
- package/dist/store/store.d.ts +2 -2
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +16 -3
- package/dist/store/store.js.map +1 -1
- package/dist/store/transcript.d.ts +9 -0
- package/dist/store/transcript.d.ts.map +1 -0
- package/dist/store/transcript.js +71 -0
- package/dist/store/transcript.js.map +1 -0
- package/dist/transcript.d.ts +28 -6
- package/dist/transcript.d.ts.map +1 -1
- package/dist/transcript.js +30 -12
- package/dist/transcript.js.map +1 -1
- package/drizzle/20260912111855_operator_intervention/migration.sql +42 -0
- package/drizzle/20260912111855_operator_intervention/snapshot.json +1461 -0
- package/package.json +2 -2
package/dist/store/codec.d.ts
CHANGED
|
@@ -53,6 +53,9 @@ export declare const AttemptRow: Schema.Struct<{
|
|
|
53
53
|
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
54
54
|
readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
|
|
55
55
|
readonly brain: typeof BrainSpec;
|
|
56
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
57
|
+
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
58
|
+
readonly operatorIntervened: Schema.Boolean;
|
|
56
59
|
readonly parentModel: Schema.NullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
57
60
|
readonly startedAt: Schema.DateTimeUtcFromString;
|
|
58
61
|
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]>>;
|
|
@@ -62,21 +65,37 @@ export declare const TranscriptRow: Schema.Struct<{
|
|
|
62
65
|
readonly sequence: Schema.brand<Schema.Int, "TranscriptSequence">;
|
|
63
66
|
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
64
67
|
readonly direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
65
|
-
readonly envelope: Schema.Union<readonly [Schema.Union<readonly [typeof AttemptChannel.OutboundEnvelope, typeof AttemptChannel.InboundEnvelope]>, Schema.
|
|
68
|
+
readonly envelope: Schema.Union<readonly [Schema.Union<readonly [typeof AttemptChannel.OutboundEnvelope, typeof AttemptChannel.InboundEnvelope]>, Schema.Struct<{
|
|
66
69
|
readonly _tag: Schema.tag<"OutboundEnvelope">;
|
|
67
70
|
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
68
71
|
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
69
72
|
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<
|
|
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>;
|
|
72
75
|
}>, Schema.Struct<{
|
|
73
76
|
readonly _tag: Schema.tag<"InboundEnvelope">;
|
|
74
77
|
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
75
78
|
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
76
79
|
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
80
|
+
readonly target: Schema.withDecodingDefaultKey<Schema.Union<readonly [typeof AttemptChannel.ParentTarget, typeof AttemptChannel.ChildTarget]>, never>;
|
|
81
|
+
readonly operator: Schema.NonEmptyString;
|
|
82
|
+
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>;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly _tag: Schema.tag<"OutboundEnvelope">;
|
|
86
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
87
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
88
|
+
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]>;
|
|
90
|
+
readonly version: Schema.Literals<readonly [3, 4]>;
|
|
91
|
+
}>, Schema.Struct<{
|
|
92
|
+
readonly _tag: Schema.Literal<"InboundEnvelope">;
|
|
93
|
+
readonly version: Schema.Literals<readonly [3, 4]>;
|
|
94
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
95
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
96
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
77
97
|
readonly payload: Schema.Union<readonly [typeof AttemptChannel.Steer, typeof AttemptChannel.Interrupt]>;
|
|
78
|
-
|
|
79
|
-
}>]>]>;
|
|
98
|
+
}>]>;
|
|
80
99
|
readonly receivedAt: Schema.DateTimeUtcFromString;
|
|
81
100
|
}>;
|
|
82
101
|
export type TranscriptRow = typeof TranscriptRow.Type;
|
|
@@ -124,6 +143,9 @@ export declare const decodeAttemptRows: (input: unknown, options?: import("effec
|
|
|
124
143
|
readonly worker: string & import("effect/Brand").Brand<"WorkerName">;
|
|
125
144
|
readonly number: number & import("effect/Brand").Brand<"AttemptNumber">;
|
|
126
145
|
readonly brain: BrainSpec;
|
|
146
|
+
readonly task: string & import("effect/Brand").Brand<"AttemptTask">;
|
|
147
|
+
readonly agent: string & import("effect/Brand").Brand<"AgentName">;
|
|
148
|
+
readonly operatorIntervened: boolean;
|
|
127
149
|
readonly parentModel: (string & import("effect/Brand").Brand<"ModelId">) | null;
|
|
128
150
|
readonly startedAt: import("effect/DateTime").Utc;
|
|
129
151
|
readonly outcome: import("@usine/core/attempt/outcome").AttemptCanceled | import("@usine/core/attempt/outcome").AttemptFailed | import("@usine/core/attempt/outcome").AttemptSucceeded | null;
|
|
@@ -169,15 +191,31 @@ export declare const decodeTranscriptRows: (input: unknown, options?: import("ef
|
|
|
169
191
|
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
170
192
|
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
171
193
|
readonly sentAt: import("effect/DateTime").Utc;
|
|
172
|
-
readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.SessionEvent | AttemptChannel.Started;
|
|
173
|
-
readonly version:
|
|
194
|
+
readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started;
|
|
195
|
+
readonly version: 5;
|
|
196
|
+
} | {
|
|
197
|
+
readonly _tag: "InboundEnvelope";
|
|
198
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
199
|
+
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
200
|
+
readonly sentAt: import("effect/DateTime").Utc;
|
|
201
|
+
readonly target: AttemptChannel.ChildTarget | AttemptChannel.ParentTarget;
|
|
202
|
+
readonly operator: string;
|
|
203
|
+
readonly payload: AttemptChannel.Cancel | AttemptChannel.Interrupt | AttemptChannel.OperatorMessage | AttemptChannel.Release | AttemptChannel.Steer;
|
|
204
|
+
readonly version: 5;
|
|
205
|
+
} | {
|
|
206
|
+
readonly _tag: "OutboundEnvelope";
|
|
207
|
+
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
208
|
+
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
209
|
+
readonly sentAt: import("effect/DateTime").Utc;
|
|
210
|
+
readonly payload: AttemptChannel.Failed | AttemptChannel.Final | AttemptChannel.Interrupted | AttemptChannel.InterventionApplied | AttemptChannel.InterventionRejected | AttemptChannel.SessionEvent | AttemptChannel.Started;
|
|
211
|
+
readonly version: 3 | 4;
|
|
174
212
|
} | {
|
|
175
213
|
readonly _tag: "InboundEnvelope";
|
|
214
|
+
readonly version: 3 | 4;
|
|
176
215
|
readonly attemptId: string & import("effect/Brand").Brand<"AttemptId">;
|
|
177
216
|
readonly sequence: number & import("effect/Brand").Brand<"AttemptChannelSequence">;
|
|
178
217
|
readonly sentAt: import("effect/DateTime").Utc;
|
|
179
218
|
readonly payload: AttemptChannel.Interrupt | AttemptChannel.Steer;
|
|
180
|
-
readonly version: 3;
|
|
181
219
|
};
|
|
182
220
|
readonly receivedAt: import("effect/DateTime").Utc;
|
|
183
221
|
}[], Schema.SchemaError, never>;
|
|
@@ -249,7 +287,7 @@ export declare const encodeStepResult: (input: StepResult, options?: import("eff
|
|
|
249
287
|
};
|
|
250
288
|
export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | AttemptChannel.OutboundEnvelope, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
251
289
|
readonly _tag: "OutboundEnvelope";
|
|
252
|
-
readonly version:
|
|
290
|
+
readonly version: 6;
|
|
253
291
|
readonly attemptId: string;
|
|
254
292
|
readonly sequence: number;
|
|
255
293
|
readonly sentAt: string;
|
|
@@ -280,6 +318,10 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
|
|
|
280
318
|
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
281
319
|
};
|
|
282
320
|
};
|
|
321
|
+
readonly harnessSession?: {
|
|
322
|
+
readonly id: string;
|
|
323
|
+
readonly cwd: string;
|
|
324
|
+
};
|
|
283
325
|
} | {
|
|
284
326
|
readonly _tag: "TextOutput";
|
|
285
327
|
readonly session: {
|
|
@@ -413,6 +455,73 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
|
|
|
413
455
|
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
414
456
|
};
|
|
415
457
|
};
|
|
458
|
+
} | {
|
|
459
|
+
readonly _tag: "SessionIdle";
|
|
460
|
+
readonly session: {
|
|
461
|
+
readonly _tag: "ParentSession";
|
|
462
|
+
readonly id: string;
|
|
463
|
+
readonly agent: string;
|
|
464
|
+
readonly brain: {
|
|
465
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
466
|
+
readonly model: string;
|
|
467
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
468
|
+
};
|
|
469
|
+
} | {
|
|
470
|
+
readonly _tag: "ChildSession";
|
|
471
|
+
readonly id: string;
|
|
472
|
+
readonly parentId: string;
|
|
473
|
+
readonly agent: string;
|
|
474
|
+
readonly brain: {
|
|
475
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
476
|
+
readonly model: string;
|
|
477
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
} | {
|
|
481
|
+
readonly _tag: "SessionResumed";
|
|
482
|
+
readonly session: {
|
|
483
|
+
readonly _tag: "ParentSession";
|
|
484
|
+
readonly id: string;
|
|
485
|
+
readonly agent: string;
|
|
486
|
+
readonly brain: {
|
|
487
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
488
|
+
readonly model: string;
|
|
489
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
490
|
+
};
|
|
491
|
+
} | {
|
|
492
|
+
readonly _tag: "ChildSession";
|
|
493
|
+
readonly id: string;
|
|
494
|
+
readonly parentId: string;
|
|
495
|
+
readonly agent: string;
|
|
496
|
+
readonly brain: {
|
|
497
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
498
|
+
readonly model: string;
|
|
499
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
} | {
|
|
503
|
+
readonly _tag: "SessionTokensUpdated";
|
|
504
|
+
readonly session: {
|
|
505
|
+
readonly _tag: "ParentSession";
|
|
506
|
+
readonly id: string;
|
|
507
|
+
readonly agent: string;
|
|
508
|
+
readonly brain: {
|
|
509
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
510
|
+
readonly model: string;
|
|
511
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
512
|
+
};
|
|
513
|
+
} | {
|
|
514
|
+
readonly _tag: "ChildSession";
|
|
515
|
+
readonly id: string;
|
|
516
|
+
readonly parentId: string;
|
|
517
|
+
readonly agent: string;
|
|
518
|
+
readonly brain: {
|
|
519
|
+
readonly harness: "claude" | "codex" | "pi";
|
|
520
|
+
readonly model: string;
|
|
521
|
+
readonly effort: "high" | "low" | "max" | "medium" | "minimal" | "off" | "xhigh";
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
readonly totalTokens: number;
|
|
416
525
|
};
|
|
417
526
|
} | {
|
|
418
527
|
readonly _tag: "Final";
|
|
@@ -454,18 +563,83 @@ export declare const encodeEnvelope: (input: AttemptChannel.InboundEnvelope | At
|
|
|
454
563
|
};
|
|
455
564
|
} | {
|
|
456
565
|
readonly _tag: "Interrupted";
|
|
566
|
+
} | {
|
|
567
|
+
readonly _tag: "InterventionApplied";
|
|
568
|
+
readonly inputSequence: number;
|
|
569
|
+
readonly intervention: {
|
|
570
|
+
readonly operator: string;
|
|
571
|
+
readonly target: {
|
|
572
|
+
readonly _tag: "Parent";
|
|
573
|
+
} | {
|
|
574
|
+
readonly _tag: "Child";
|
|
575
|
+
readonly sessionId: string;
|
|
576
|
+
};
|
|
577
|
+
readonly action: {
|
|
578
|
+
readonly _tag: "Steer";
|
|
579
|
+
readonly message: string;
|
|
580
|
+
} | {
|
|
581
|
+
readonly _tag: "Interrupt";
|
|
582
|
+
} | {
|
|
583
|
+
readonly _tag: "OperatorMessage";
|
|
584
|
+
readonly message: string;
|
|
585
|
+
} | {
|
|
586
|
+
readonly _tag: "Release";
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
readonly state: {
|
|
590
|
+
readonly held: boolean;
|
|
591
|
+
readonly paused: boolean;
|
|
592
|
+
};
|
|
593
|
+
} | {
|
|
594
|
+
readonly _tag: "InterventionRejected";
|
|
595
|
+
readonly inputSequence: number;
|
|
596
|
+
readonly intervention: {
|
|
597
|
+
readonly operator: string;
|
|
598
|
+
readonly target: {
|
|
599
|
+
readonly _tag: "Parent";
|
|
600
|
+
} | {
|
|
601
|
+
readonly _tag: "Child";
|
|
602
|
+
readonly sessionId: string;
|
|
603
|
+
};
|
|
604
|
+
readonly action: {
|
|
605
|
+
readonly _tag: "Steer";
|
|
606
|
+
readonly message: string;
|
|
607
|
+
} | {
|
|
608
|
+
readonly _tag: "Interrupt";
|
|
609
|
+
} | {
|
|
610
|
+
readonly _tag: "OperatorMessage";
|
|
611
|
+
readonly message: string;
|
|
612
|
+
} | {
|
|
613
|
+
readonly _tag: "Release";
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
readonly message: string;
|
|
457
617
|
};
|
|
458
618
|
} | {
|
|
459
619
|
readonly _tag: "InboundEnvelope";
|
|
460
|
-
readonly version:
|
|
620
|
+
readonly version: 6;
|
|
461
621
|
readonly attemptId: string;
|
|
462
622
|
readonly sequence: number;
|
|
463
623
|
readonly sentAt: string;
|
|
624
|
+
readonly target?: {
|
|
625
|
+
readonly _tag: "Parent";
|
|
626
|
+
} | {
|
|
627
|
+
readonly _tag: "Child";
|
|
628
|
+
readonly sessionId: string;
|
|
629
|
+
};
|
|
630
|
+
readonly operator: string;
|
|
464
631
|
readonly payload: {
|
|
465
632
|
readonly _tag: "Steer";
|
|
466
633
|
readonly message: string;
|
|
467
634
|
} | {
|
|
468
635
|
readonly _tag: "Interrupt";
|
|
636
|
+
} | {
|
|
637
|
+
readonly _tag: "OperatorMessage";
|
|
638
|
+
readonly message: string;
|
|
639
|
+
} | {
|
|
640
|
+
readonly _tag: "Release";
|
|
641
|
+
} | {
|
|
642
|
+
readonly _tag: "Cancel";
|
|
469
643
|
};
|
|
470
644
|
};
|
|
471
645
|
export declare const encodeAgent: (input: Agent, options?: import("effect/SchemaAST").ParseOptions) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/store/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA6C,CAAC;AACzE,eAAO,MAAM,WAAW;;;;;;;;;;CAA2B,CAAC;AACpD,eAAO,MAAM,eAAe;;;;CAA+B,CAAC;AAI5D,eAAO,MAAM,WAAW,cACV,MAAM,MACjB,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAGzE,CAAC;AAEN,eAAO,MAAM,YAAY,QAAS,aAAa,KAAG,KAM9C,CAAC;AAEL,eAAO,MAAM,iBAAiB,QAAS,aAAa,KAAG,UAcnD,CAAC;AAEL,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,GAOrC,CAAC;AAEL,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,IAKtC,CAAC;AAEL,eAAO,MAAM,cAAc,QAAS,UAAU,KAAG,OAc7C,CAAC;AAEL,eAAO,MAAM,iBAAiB,QACvB,MAAM,kBACK,aAAa,CAAC,UAAU,CAAC,KACxC,UASC,CAAC;AAEL,eAAO,MAAM,sBAAsB,QAAS,aAAa,KAAG,eAOxD,CAAC"}
|
package/dist/store/codec.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent } from "@usine/core/agent";
|
|
1
|
+
import { Agent, AgentName } from "@usine/core/agent";
|
|
2
2
|
import { CycleGeneration, CycleLimit } from "@usine/core/cycle-budget";
|
|
3
3
|
import { BrainSpec, ModelId } from "@usine/core/agent/brain";
|
|
4
4
|
import { Attempt, AttemptNumber, AttemptTask, AttemptId } from "@usine/core/attempt";
|
|
@@ -58,6 +58,9 @@ export const AttemptRow = Schema.Struct({
|
|
|
58
58
|
worker: WorkerName,
|
|
59
59
|
number: AttemptNumber,
|
|
60
60
|
brain: BrainSpec,
|
|
61
|
+
task: AttemptTask,
|
|
62
|
+
agent: AgentName,
|
|
63
|
+
operatorIntervened: Schema.Boolean,
|
|
61
64
|
parentModel: Schema.NullOr(ModelId),
|
|
62
65
|
startedAt: Schema.DateTimeUtcFromString,
|
|
63
66
|
outcome: Schema.NullOr(AttemptOutcome),
|
|
@@ -139,6 +142,9 @@ export const attemptFromRow = (row) => new Attempt({
|
|
|
139
142
|
worker: row.worker,
|
|
140
143
|
number: row.number,
|
|
141
144
|
brain: row.brain,
|
|
145
|
+
task: row.task,
|
|
146
|
+
agent: row.agent,
|
|
147
|
+
operatorIntervened: row.operatorIntervened,
|
|
142
148
|
parentModel: Option.fromNullishOr(row.parentModel),
|
|
143
149
|
startedAt: row.startedAt,
|
|
144
150
|
outcome: Option.fromNullishOr(row.outcome),
|
package/dist/store/codec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/store/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/store/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;A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CAAC,GAAG,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC;IACtB,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5C,UAAU,EAAE,GAAG,CAAC,UAAU;IAC1B,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,KAAK,EAAE,GAAG,CAAC,KAAK;CACjB,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAkB,EAAmB,EAAE,CAC5E,IAAI,eAAe,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;IACtB,SAAS,EAAE,GAAG,CAAC,SAAS;IACxB,SAAS,EAAE,GAAG,CAAC,SAAS;IACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;IACtB,UAAU,EAAE,GAAG,CAAC,UAAU;CAC3B,CAAC,CAAC"}
|
package/dist/store/queries.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Agent } from "@usine/core/agent";
|
|
2
|
-
import { Attempt } from "@usine/core/attempt";
|
|
3
|
-
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
+
import { Attempt, AttemptContext } from "@usine/core/attempt";
|
|
4
3
|
import { Event } from "@usine/core/event";
|
|
5
4
|
import * as RunState from "@usine/core/run/state";
|
|
6
5
|
import { StepResult } from "@usine/core/step/result";
|
|
@@ -10,6 +9,8 @@ import { RunNotFoundError } from "../engine/error.ts";
|
|
|
10
9
|
import { RunSnapshot, RunSummary } from "../run-reader/model.ts";
|
|
11
10
|
import { Submission } from "../engine/submission.ts";
|
|
12
11
|
export declare const queriesFor: (database: RunDatabaseClient) => {
|
|
12
|
+
readonly appendTranscript: (direction: "inbound" | "outbound", envelope: import("@usine/core/attempt/channel").InboundEnvelope | import("@usine/core/attempt/channel").OutboundEnvelope, receivedAt: DateTime.Utc) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
13
|
+
readonly transcript: (query: import("../transcript.ts").TranscriptAllQuery | import("../transcript.ts").TranscriptPageQuery | import("../transcript.ts").TranscriptSessionsQuery | import("../transcript.ts").TranscriptTailQuery) => Effect.Effect<import("../transcript.ts").TranscriptEntry[], import("drizzle-orm/effect-core").EffectDrizzleQueryError | Schema.SchemaError, never>;
|
|
13
14
|
readonly cycles: {
|
|
14
15
|
admit: (submission: Submission) => Effect.Effect<Option.Option<import("@usine/core/cycle-budget").CycleBudgetAsk>, import("drizzle-orm/effect-core").EffectDrizzleQueryError | Schema.SchemaError, never>;
|
|
15
16
|
reserve: (submission: Submission, runId: string & import("effect/Brand").Brand<"RunId">) => Effect.Effect<undefined, import("drizzle-orm/effect-core").EffectDrizzleQueryError | Schema.SchemaError, never>;
|
|
@@ -32,7 +33,8 @@ export declare const queriesFor: (database: RunDatabaseClient) => {
|
|
|
32
33
|
currentEvent: import("drizzle-orm").SQL<unknown>;
|
|
33
34
|
};
|
|
34
35
|
readonly addAttempt: (attempt: Attempt) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
35
|
-
readonly
|
|
36
|
+
readonly amend: (runId: string & import("effect/Brand").Brand<"RunId">, context: AttemptContext) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
37
|
+
readonly markIntervened: (attemptId: string & import("effect/Brand").Brand<"AttemptId">) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
36
38
|
readonly approvalExists: (runId: string & import("effect/Brand").Brand<"RunId">) => Effect.Effect<boolean, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
37
39
|
readonly blockingRun: (loop: string & import("effect/Brand").Brand<"LoopName">, itemKey: string & import("effect/Brand").Brand<"ItemKey">) => Effect.Effect<readonly {
|
|
38
40
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
@@ -99,7 +101,6 @@ export declare const queriesFor: (database: RunDatabaseClient) => {
|
|
|
99
101
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
100
102
|
}[], import("drizzle-orm/effect-core").EffectDrizzleQueryError | Schema.SchemaError, never>;
|
|
101
103
|
readonly snapshot: (runId: string & import("effect/Brand").Brand<"RunId">) => Effect.Effect<RunSnapshot, import("drizzle-orm/effect-core").EffectDrizzleQueryError | RunNotFoundError | Schema.SchemaError, never>;
|
|
102
|
-
readonly transcript: (query: import("../transcript.ts").TranscriptAllQuery | import("../transcript.ts").TranscriptPageQuery | import("../transcript.ts").TranscriptTailQuery) => Effect.Effect<import("../transcript.ts").TranscriptEntry[], import("drizzle-orm/effect-core").EffectDrizzleQueryError | Schema.SchemaError, never>;
|
|
103
104
|
readonly updateStepResult: (runId: string & import("effect/Brand").Brand<"RunId">, stepName: string & import("effect/Brand").Brand<"StepName">, result: StepResult) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
104
105
|
readonly updateAttemptParentModel: (attemptId: string & import("effect/Brand").Brand<"AttemptId">, parentModel: string & import("effect/Brand").Brand<"ModelId">) => Effect.Effect<void, import("drizzle-orm/effect-core").EffectDrizzleQueryError, never>;
|
|
105
106
|
readonly updateState: (runId: string & import("effect/Brand").Brand<"RunId">, state: RunState.Canceled | RunState.Failed | RunState.Pending | RunState.Queued | RunState.Running | RunState.Succeeded | RunState.Waiting) => Effect.Effect<undefined, import("drizzle-orm/effect-core").EffectDrizzleQueryError | RunNotFoundError, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/store/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAa,
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/store/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAa,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EAAE,KAAK,EAAqB,MAAM,mBAAmB,CAAC;AAK7D,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAwB,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAYjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA6FrD,eAAO,MAAM,UAAU,aAAc,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+jBrD,CAAC"}
|
package/dist/store/queries.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Attempt, AttemptId } from "@usine/core/attempt";
|
|
2
|
-
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
1
|
+
import { Attempt, AttemptId, AttemptContext } from "@usine/core/attempt";
|
|
3
2
|
import { AttemptOutcome } from "@usine/core/attempt/outcome";
|
|
4
3
|
import { Event, DedupKey, EventId } from "@usine/core/event";
|
|
5
4
|
import { ItemKey } from "@usine/core/item";
|
|
@@ -8,17 +7,17 @@ import { RunId } from "@usine/core/run";
|
|
|
8
7
|
import { StepName } from "@usine/core/step";
|
|
9
8
|
import * as RunState from "@usine/core/run/state";
|
|
10
9
|
import { StepResult } from "@usine/core/step/result";
|
|
11
|
-
import { and, asc, desc, eq,
|
|
10
|
+
import { and, asc, desc, eq, inArray, isNull, ne, notInArray, sql } from "drizzle-orm";
|
|
12
11
|
import { alias } from "drizzle-orm/sqlite-core";
|
|
13
|
-
import { Array as EffectArray, DateTime, Effect,
|
|
14
|
-
import { approvals,
|
|
12
|
+
import { Array as EffectArray, DateTime, Effect, Option, Schema } from "effect";
|
|
13
|
+
import { approvals, attempts, events, ignoredEvents, projectionRevision, runs, steps, triggerEvents, workflowCommands, } from "../database/schema.js";
|
|
15
14
|
import { RunNotFoundError } from "../engine/error.js";
|
|
16
15
|
import { RunSnapshot, RunSummary } from "../run-reader/model.js";
|
|
17
16
|
import { Submission } from "../engine/submission.js";
|
|
18
|
-
import { TranscriptQuery } from "../transcript.js";
|
|
19
17
|
import { WORKFLOW_COMMAND_PRIORITY } from "../workflow/command.js";
|
|
20
18
|
import { cycleQueries } from "../cycle-budget/queries.js";
|
|
21
|
-
import { attemptFromRow, decodeAttemptRows, decodeDiscards, decodeEventRoutes, decodeRecoverableRuns, decodeProjectionRevision, decodeRunIds, decodeRunRows, decodeWorkflowCommands,
|
|
19
|
+
import { attemptFromRow, decodeAttemptRows, decodeDiscards, decodeEventRoutes, decodeRecoverableRuns, decodeProjectionRevision, decodeRunIds, decodeRunRows, decodeWorkflowCommands, encodeAgent, encodeBrainSpec, encodeDateTime, encodeOutcome, encodePayload, encodeRunState, encodeStepResult, eventFromRow, runFromRow, runSummaryFromRow, stepFromRow, submissionFromRow, } from "./codec.js";
|
|
20
|
+
import { transcriptQueries } from "./transcript.js";
|
|
22
21
|
const newestRunFirst = (left, right) => DateTime.toEpochMillis(right.openedAt) - DateTime.toEpochMillis(left.openedAt) ||
|
|
23
22
|
right.runId.localeCompare(left.runId);
|
|
24
23
|
const eventRouteSelection = {
|
|
@@ -60,6 +59,9 @@ const attemptSelection = {
|
|
|
60
59
|
worker: attempts.workerName,
|
|
61
60
|
number: attempts.attemptNumber,
|
|
62
61
|
brain: attempts.brainJson,
|
|
62
|
+
task: attempts.task,
|
|
63
|
+
agent: attempts.agent,
|
|
64
|
+
operatorIntervened: attempts.operatorIntervened,
|
|
63
65
|
parentModel: attempts.parentModel,
|
|
64
66
|
startedAt: attempts.startedAt,
|
|
65
67
|
outcome: attempts.outcomeJson,
|
|
@@ -222,6 +224,9 @@ export const queriesFor = (database) => {
|
|
|
222
224
|
workerName: attempt.worker,
|
|
223
225
|
attemptNumber: attempt.number,
|
|
224
226
|
brainJson: encodeBrainSpec(attempt.brain),
|
|
227
|
+
task: attempt.task,
|
|
228
|
+
agent: attempt.agent,
|
|
229
|
+
operatorIntervened: attempt.operatorIntervened,
|
|
225
230
|
parentModel: Option.getOrNull(attempt.parentModel),
|
|
226
231
|
startedAt: encodeDateTime(attempt.startedAt),
|
|
227
232
|
outcomeJson: null,
|
|
@@ -235,6 +240,26 @@ export const queriesFor = (database) => {
|
|
|
235
240
|
.where(and(eq(attempts.attemptId, attemptId), isNull(attempts.outcomeJson)))
|
|
236
241
|
.execute();
|
|
237
242
|
});
|
|
243
|
+
const amend = Effect.fn("RunStoreQueries.amend")(function* (runId, context) {
|
|
244
|
+
yield* Effect.annotateCurrentSpan({ runId, agent: context.agent.name });
|
|
245
|
+
yield* database
|
|
246
|
+
.update(runs)
|
|
247
|
+
.set({
|
|
248
|
+
task: context.task,
|
|
249
|
+
agentJson: storedAgent(context.agent),
|
|
250
|
+
parentModel: Option.getOrNull(context.parentModel),
|
|
251
|
+
})
|
|
252
|
+
.where(eq(runs.runId, runId))
|
|
253
|
+
.execute();
|
|
254
|
+
});
|
|
255
|
+
const markIntervened = Effect.fn("RunStoreQueries.markIntervened")(function* (attemptId) {
|
|
256
|
+
yield* Effect.annotateCurrentSpan({ attemptId });
|
|
257
|
+
yield* database
|
|
258
|
+
.update(attempts)
|
|
259
|
+
.set({ operatorIntervened: true })
|
|
260
|
+
.where(eq(attempts.attemptId, attemptId))
|
|
261
|
+
.execute();
|
|
262
|
+
});
|
|
238
263
|
const updateAttemptParentModel = Effect.fn("RunStoreQueries.updateAttemptParentModel")(function* (attemptId, parentModel) {
|
|
239
264
|
yield* database
|
|
240
265
|
.update(attempts)
|
|
@@ -404,54 +429,6 @@ export const queriesFor = (database) => {
|
|
|
404
429
|
const queued = yield* decodeEventRoutes(queuedRows);
|
|
405
430
|
return Option.fromNullishOr(queued[0]).pipe(Option.map(submissionFromRow));
|
|
406
431
|
});
|
|
407
|
-
const appendTranscript = Effect.fn("RunStoreQueries.appendTranscript")(function* (direction, envelope, receivedAt) {
|
|
408
|
-
yield* database
|
|
409
|
-
.insert(attemptTranscripts)
|
|
410
|
-
.values({
|
|
411
|
-
attemptId: envelope.attemptId,
|
|
412
|
-
direction,
|
|
413
|
-
channelSequence: envelope.sequence,
|
|
414
|
-
envelope: encodeEnvelope(envelope),
|
|
415
|
-
receivedAt: encodeDateTime(receivedAt),
|
|
416
|
-
})
|
|
417
|
-
.onConflictDoNothing()
|
|
418
|
-
.execute();
|
|
419
|
-
});
|
|
420
|
-
const transcript = Effect.fn("RunStoreQueries.transcript")(function* (query) {
|
|
421
|
-
yield* Effect.annotateCurrentSpan({
|
|
422
|
-
attemptId: query.attemptId,
|
|
423
|
-
query: query._tag,
|
|
424
|
-
});
|
|
425
|
-
const cursor = Match.valueTags(query, {
|
|
426
|
-
TranscriptAllQuery: ({ attemptId }) => eq(attemptTranscripts.attemptId, attemptId),
|
|
427
|
-
TranscriptTailQuery: ({ attemptId, after }) => and(eq(attemptTranscripts.attemptId, attemptId), gt(attemptTranscripts.sequence, after)),
|
|
428
|
-
TranscriptPageQuery: ({ attemptId, before }) => Option.match(before, {
|
|
429
|
-
onNone: () => eq(attemptTranscripts.attemptId, attemptId),
|
|
430
|
-
onSome: (sequence) => and(eq(attemptTranscripts.attemptId, attemptId), lt(attemptTranscripts.sequence, sequence)),
|
|
431
|
-
}),
|
|
432
|
-
});
|
|
433
|
-
const selection = database
|
|
434
|
-
.select({
|
|
435
|
-
sequence: attemptTranscripts.sequence,
|
|
436
|
-
attemptId: attemptTranscripts.attemptId,
|
|
437
|
-
direction: attemptTranscripts.direction,
|
|
438
|
-
envelope: attemptTranscripts.envelope,
|
|
439
|
-
receivedAt: attemptTranscripts.receivedAt,
|
|
440
|
-
})
|
|
441
|
-
.from(attemptTranscripts)
|
|
442
|
-
.where(cursor);
|
|
443
|
-
// A limited read walks the tail index backwards for the newest N rows and
|
|
444
|
-
// re-sorts ascending, so callers always receive append order.
|
|
445
|
-
const rows = yield* Match.valueTags(query, {
|
|
446
|
-
TranscriptAllQuery: () => selection.orderBy(asc(attemptTranscripts.sequence)).execute(),
|
|
447
|
-
TranscriptTailQuery: ({ limit }) => selection.orderBy(asc(attemptTranscripts.sequence)).limit(limit).execute(),
|
|
448
|
-
TranscriptPageQuery: ({ limit }) => selection.orderBy(desc(attemptTranscripts.sequence)).limit(limit).execute(),
|
|
449
|
-
});
|
|
450
|
-
// Transcript rows are usine-owned, so an unknown key is corruption.
|
|
451
|
-
return (yield* decodeTranscriptRows(rows, { onExcessProperty: "error" }))
|
|
452
|
-
.map(transcriptEntryFromRow)
|
|
453
|
-
.sort((left, right) => left.sequence - right.sequence);
|
|
454
|
-
});
|
|
455
432
|
const recoverable = Effect.fn("RunStoreQueries.recoverable")(function* () {
|
|
456
433
|
const rows = yield* database
|
|
457
434
|
.select({
|
|
@@ -511,8 +488,10 @@ export const queriesFor = (database) => {
|
|
|
511
488
|
});
|
|
512
489
|
return {
|
|
513
490
|
cycles: cycleQueries(database),
|
|
491
|
+
...transcriptQueries(database),
|
|
514
492
|
addAttempt,
|
|
515
|
-
|
|
493
|
+
amend,
|
|
494
|
+
markIntervened,
|
|
516
495
|
approvalExists,
|
|
517
496
|
blockingRun,
|
|
518
497
|
closeAttempt,
|
|
@@ -534,7 +513,6 @@ export const queriesFor = (database) => {
|
|
|
534
513
|
itemRunSummaries,
|
|
535
514
|
runForEvent,
|
|
536
515
|
snapshot,
|
|
537
|
-
transcript,
|
|
538
516
|
updateStepResult,
|
|
539
517
|
updateAttemptParentModel,
|
|
540
518
|
updateState,
|