@usine/core 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 +27 -13
- package/dist/agent/agent.d.ts +27 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +26 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/brain.d.ts +24 -0
- package/dist/agent/brain.d.ts.map +1 -0
- package/dist/agent/brain.js +19 -0
- package/dist/agent/brain.js.map +1 -0
- package/dist/agent/capability.d.ts +23 -0
- package/dist/agent/capability.d.ts.map +1 -0
- package/dist/agent/capability.js +19 -0
- package/dist/agent/capability.js.map +1 -0
- package/dist/agent/session.d.ts +105 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +93 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/attempt/attempt.d.ts +41 -0
- package/dist/attempt/attempt.d.ts.map +1 -0
- package/dist/attempt/attempt.js +36 -0
- package/dist/attempt/attempt.js.map +1 -0
- package/dist/attempt/channel.d.ts +130 -0
- package/dist/attempt/channel.d.ts.map +1 -0
- package/dist/attempt/channel.js +137 -0
- package/dist/attempt/channel.js.map +1 -0
- package/dist/attempt/failure.d.ts +52 -0
- package/dist/attempt/failure.d.ts.map +1 -0
- package/dist/attempt/failure.js +48 -0
- package/dist/attempt/failure.js.map +1 -0
- package/dist/attempt/outcome.d.ts +20 -0
- package/dist/attempt/outcome.d.ts.map +1 -0
- package/dist/attempt/outcome.js +16 -0
- package/dist/attempt/outcome.js.map +1 -0
- package/dist/cycle-budget.d.ts +38 -0
- package/dist/cycle-budget.d.ts.map +1 -0
- package/dist/cycle-budget.js +46 -0
- package/dist/cycle-budget.js.map +1 -0
- package/dist/event.d.ts +25 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +21 -0
- package/dist/event.js.map +1 -0
- package/dist/instance.d.ts +5 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +4 -0
- package/dist/instance.js.map +1 -0
- package/dist/item.d.ts +8 -0
- package/dist/item.d.ts.map +1 -0
- package/dist/item.js +6 -0
- package/dist/item.js.map +1 -0
- package/dist/loop.d.ts +9 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +7 -0
- package/dist/loop.js.map +1 -0
- package/dist/repository.d.ts +21 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +27 -0
- package/dist/repository.js.map +1 -0
- package/dist/run/run.d.ts +16 -0
- package/dist/run/run.d.ts.map +1 -0
- package/dist/run/run.js +16 -0
- package/dist/run/run.js.map +1 -0
- package/dist/run/state.d.ts +114 -0
- package/dist/run/state.d.ts.map +1 -0
- package/dist/run/state.js +102 -0
- package/dist/run/state.js.map +1 -0
- package/dist/step/result.d.ts +33 -0
- package/dist/step/result.d.ts.map +1 -0
- package/dist/step/result.js +28 -0
- package/dist/step/result.js.map +1 -0
- package/dist/step/step.d.ts +21 -0
- package/dist/step/step.d.ts.map +1 -0
- package/dist/step/step.js +19 -0
- package/dist/step/step.js.map +1 -0
- package/dist/worker.d.ts +9 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +9 -0
- package/dist/worker.js.map +1 -0
- package/package.json +76 -4
- package/dist/index.d.ts +0 -19
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -19
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/attempt-failure.d.ts +0 -51
- package/dist/lifecycle/attempt-failure.d.ts.map +0 -1
- package/dist/lifecycle/attempt-failure.js +0 -45
- package/dist/lifecycle/attempt-failure.js.map +0 -1
- package/dist/lifecycle/attempt.d.ts +0 -53
- package/dist/lifecycle/attempt.d.ts.map +0 -1
- package/dist/lifecycle/attempt.js +0 -44
- package/dist/lifecycle/attempt.js.map +0 -1
- package/dist/lifecycle/event.d.ts +0 -30
- package/dist/lifecycle/event.d.ts.map +0 -1
- package/dist/lifecycle/event.js +0 -26
- package/dist/lifecycle/event.js.map +0 -1
- package/dist/lifecycle/loop.d.ts +0 -9
- package/dist/lifecycle/loop.d.ts.map +0 -1
- package/dist/lifecycle/loop.js +0 -8
- package/dist/lifecycle/loop.js.map +0 -1
- package/dist/lifecycle/run-state.d.ts +0 -124
- package/dist/lifecycle/run-state.d.ts.map +0 -1
- package/dist/lifecycle/run-state.js +0 -109
- package/dist/lifecycle/run-state.js.map +0 -1
- package/dist/lifecycle/run.d.ts +0 -22
- package/dist/lifecycle/run.d.ts.map +0 -1
- package/dist/lifecycle/run.js +0 -22
- package/dist/lifecycle/run.js.map +0 -1
- package/dist/lifecycle/step.d.ts +0 -22
- package/dist/lifecycle/step.d.ts.map +0 -1
- package/dist/lifecycle/step.js +0 -20
- package/dist/lifecycle/step.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Result, Schema, type Effect } from "effect";
|
|
2
|
+
import { Agent } from "../agent/agent.ts";
|
|
3
|
+
import { AttemptId } from "./attempt.ts";
|
|
4
|
+
import { StepResult } from "../step/result.ts";
|
|
5
|
+
import { AttemptFailure } from "./failure.ts";
|
|
6
|
+
export declare const PROTOCOL_VERSION: 4;
|
|
7
|
+
/**
|
|
8
|
+
* Per-Attempt, per-direction message sequence, starting at 1. Distinct from the
|
|
9
|
+
* engine's transcript sequence, which orders persisted rows globally.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
12
|
+
export type Sequence = typeof Sequence.Type;
|
|
13
|
+
/**
|
|
14
|
+
* Relative to the run host: `inbound` frames go from the orchestrator to the run
|
|
15
|
+
* host (Start, Steer, Interrupt) and `outbound` frames go the other way.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DIRECTIONS: readonly ["inbound", "outbound"];
|
|
18
|
+
export declare const Direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
19
|
+
export type Direction = typeof Direction.Type;
|
|
20
|
+
declare const RunSpec_base: Schema.Class<RunSpec, Schema.Struct<{
|
|
21
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
22
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
23
|
+
readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
|
|
24
|
+
readonly baseCommit: Schema.brand<Schema.String, "CommitSha">;
|
|
25
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
26
|
+
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
27
|
+
readonly agent: typeof Agent;
|
|
28
|
+
readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
29
|
+
readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
|
|
30
|
+
readonly parentEffort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
31
|
+
}>, {}>;
|
|
32
|
+
/** Launch input for one Attempt. Worker credentials are never part of it. */
|
|
33
|
+
export declare class RunSpec extends RunSpec_base {
|
|
34
|
+
}
|
|
35
|
+
declare const Started_base: Schema.Class<Started, Schema.TaggedStruct<"Started", {
|
|
36
|
+
readonly parentModel: Schema.brand<Schema.String, "ModelId">;
|
|
37
|
+
}>, {}>;
|
|
38
|
+
/**
|
|
39
|
+
* The parent model the SDK selected at launch, which the roster may not declare.
|
|
40
|
+
* Child sessions report their own model in `SessionStarted` events.
|
|
41
|
+
*/
|
|
42
|
+
export declare class Started extends Started_base {
|
|
43
|
+
}
|
|
44
|
+
declare const SessionEvent_base: Schema.Class<SessionEvent, Schema.TaggedStruct<"SessionEvent", {
|
|
45
|
+
readonly event: Schema.Union<readonly [typeof import("../agent/session.ts").SessionStarted, typeof import("../agent/session.ts").TextOutput, typeof import("../agent/session.ts").ToolStarted, typeof import("../agent/session.ts").ToolFinished, typeof import("../agent/session.ts").PoolRateLimitsUpdated, typeof import("../agent/session.ts").SessionFinished]>;
|
|
46
|
+
}>, {}>;
|
|
47
|
+
/** One normalized parent or child session event, persisted in the Attempt transcript. */
|
|
48
|
+
export declare class SessionEvent extends SessionEvent_base {
|
|
49
|
+
}
|
|
50
|
+
declare const Final_base: Schema.Class<Final, Schema.TaggedStruct<"Final", {
|
|
51
|
+
readonly result: typeof StepResult;
|
|
52
|
+
}>, {}>;
|
|
53
|
+
export declare class Final extends Final_base {
|
|
54
|
+
}
|
|
55
|
+
declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
|
|
56
|
+
readonly failure: Schema.Union<readonly [typeof import("./failure.ts").InfraFailure, typeof import("./failure.ts").DefectFailure, typeof import("./failure.ts").AgentFailure, typeof import("./failure.ts").RunawayFailure, typeof import("./failure.ts").ChildSessionBudgetFailure]>;
|
|
57
|
+
}>, {}>;
|
|
58
|
+
export declare class Failed extends Failed_base {
|
|
59
|
+
}
|
|
60
|
+
declare const Interrupted_base: Schema.Class<Interrupted, Schema.TaggedStruct<"Interrupted", {}>, {}>;
|
|
61
|
+
/** The run host stopped on an Interrupt frame. Terminal. */
|
|
62
|
+
export declare class Interrupted extends Interrupted_base {
|
|
63
|
+
}
|
|
64
|
+
export declare const OutboundPayload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted]>;
|
|
65
|
+
export type OutboundPayload = typeof OutboundPayload.Type;
|
|
66
|
+
declare const Steer_base: Schema.Class<Steer, Schema.TaggedStruct<"Steer", {
|
|
67
|
+
readonly message: Schema.NonEmptyString;
|
|
68
|
+
}>, {}>;
|
|
69
|
+
export declare class Steer extends Steer_base {
|
|
70
|
+
}
|
|
71
|
+
declare const Interrupt_base: Schema.Class<Interrupt, Schema.TaggedStruct<"Interrupt", {}>, {}>;
|
|
72
|
+
export declare class Interrupt extends Interrupt_base {
|
|
73
|
+
}
|
|
74
|
+
export declare const InboundPayload: Schema.Union<readonly [typeof Steer, typeof Interrupt]>;
|
|
75
|
+
export type InboundPayload = typeof InboundPayload.Type;
|
|
76
|
+
declare const OutboundEnvelope_base: Schema.Class<OutboundEnvelope, Schema.TaggedStruct<"OutboundEnvelope", {
|
|
77
|
+
readonly version: Schema.Literal<4>;
|
|
78
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
79
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
80
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
81
|
+
readonly payload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted]>;
|
|
82
|
+
}>, {}>;
|
|
83
|
+
export declare class OutboundEnvelope extends OutboundEnvelope_base {
|
|
84
|
+
}
|
|
85
|
+
declare const InboundEnvelope_base: Schema.Class<InboundEnvelope, Schema.TaggedStruct<"InboundEnvelope", {
|
|
86
|
+
readonly version: Schema.Literal<4>;
|
|
87
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
88
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
89
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
90
|
+
readonly payload: Schema.Union<readonly [typeof Steer, typeof Interrupt]>;
|
|
91
|
+
}>, {}>;
|
|
92
|
+
export declare class InboundEnvelope extends InboundEnvelope_base {
|
|
93
|
+
}
|
|
94
|
+
export declare const Envelope: Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>;
|
|
95
|
+
export type Envelope = typeof Envelope.Type;
|
|
96
|
+
declare const Start_base: Schema.Class<Start, Schema.TaggedStruct<"Start", {
|
|
97
|
+
readonly version: Schema.Literal<4>;
|
|
98
|
+
readonly spec: typeof RunSpec;
|
|
99
|
+
}>, {}>;
|
|
100
|
+
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
101
|
+
export declare class Start extends Start_base {
|
|
102
|
+
}
|
|
103
|
+
export declare const InputFrame: Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>;
|
|
104
|
+
export type InputFrame = typeof InputFrame.Type;
|
|
105
|
+
export declare const EnvelopeFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>>;
|
|
106
|
+
export declare const InputFrameFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>>;
|
|
107
|
+
export declare const OutboundEnvelopeFromJson: Schema.fromJsonString<typeof OutboundEnvelope>;
|
|
108
|
+
/** Where a channel consumer persists envelopes. */
|
|
109
|
+
export interface Sink {
|
|
110
|
+
readonly append: (direction: Direction, envelope: Envelope) => Effect.Effect<void, AttemptFailure>;
|
|
111
|
+
}
|
|
112
|
+
/** How far one outbound channel has legally progressed. */
|
|
113
|
+
export interface Progress {
|
|
114
|
+
readonly state: "AwaitingStarted" | "Running" | "Terminal";
|
|
115
|
+
readonly nextSequence: number;
|
|
116
|
+
}
|
|
117
|
+
export declare const initialProgress: Progress;
|
|
118
|
+
/** One protocol violation, described for the infra failure that reports it. */
|
|
119
|
+
export interface Violation {
|
|
120
|
+
readonly message: string;
|
|
121
|
+
readonly detail: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Checks one outbound envelope against the progress so far and returns the next
|
|
125
|
+
* progress, or the violation. Every transport adapter folds the same state
|
|
126
|
+
* machine through it.
|
|
127
|
+
*/
|
|
128
|
+
export declare const admit: (progress: Progress, attemptId: AttemptId, envelope: OutboundEnvelope) => Result.Result<Progress, Violation>;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAA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E;AAC1E,qBAAa,KAAM,SAAQ,UAGzB;CAAG;AAEL,eAAO,MAAM,UAAU,+DAAyC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,eAAO,MAAM,gBAAgB,iGAAkC,CAAC;AAChE,eAAO,MAAM,kBAAkB,sFAAoC,CAAC;AACpE,eAAO,MAAM,wBAAwB,gDAA0C,CAAC;AAEhF,mDAAmD;AACnD,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,MAAM,EAAE,CACf,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,KACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;CAC1C;AAED,2DAA2D;AAC3D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAAC;IAC3D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe,EAAE,QAAwD,CAAC;AAEvF,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAKD;;;;GAIG;AACH,eAAO,MAAM,KAAK,aACN,QAAQ,aACP,SAAS,YACV,gBAAgB,KACzB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAuCnC,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Result, Schema } from "effect";
|
|
2
|
+
import { Agent } from "../agent/agent.js";
|
|
3
|
+
import { Effort, ModelId } from "../agent/brain.js";
|
|
4
|
+
import { AgentSessionEvent, ChildSessionBudget } from "../agent/session.js";
|
|
5
|
+
import { AttemptId, AttemptTask } from "./attempt.js";
|
|
6
|
+
import { RepositoryName, CommitSha, RepositoryRevision } from "../repository.js";
|
|
7
|
+
import { StepResult } from "../step/result.js";
|
|
8
|
+
import { AttemptFailure } from "./failure.js";
|
|
9
|
+
export const PROTOCOL_VERSION = 4;
|
|
10
|
+
/**
|
|
11
|
+
* Per-Attempt, per-direction message sequence, starting at 1. Distinct from the
|
|
12
|
+
* engine's transcript sequence, which orders persisted rows globally.
|
|
13
|
+
*/
|
|
14
|
+
export const Sequence = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("AttemptChannelSequence"));
|
|
15
|
+
/**
|
|
16
|
+
* Relative to the run host: `inbound` frames go from the orchestrator to the run
|
|
17
|
+
* host (Start, Steer, Interrupt) and `outbound` frames go the other way.
|
|
18
|
+
*/
|
|
19
|
+
export const DIRECTIONS = ["inbound", "outbound"];
|
|
20
|
+
export const Direction = Schema.Literals(DIRECTIONS);
|
|
21
|
+
/** Launch input for one Attempt. Worker credentials are never part of it. */
|
|
22
|
+
export class RunSpec extends Schema.Class("AttemptChannel/RunSpec")({
|
|
23
|
+
attemptId: AttemptId,
|
|
24
|
+
repository: RepositoryName,
|
|
25
|
+
revision: RepositoryRevision,
|
|
26
|
+
baseCommit: CommitSha,
|
|
27
|
+
payload: Schema.Json,
|
|
28
|
+
task: AttemptTask,
|
|
29
|
+
agent: Agent,
|
|
30
|
+
parentModel: Schema.OptionFromNullOr(ModelId),
|
|
31
|
+
maxChildren: ChildSessionBudget,
|
|
32
|
+
parentEffort: Effort,
|
|
33
|
+
}) {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The parent model the SDK selected at launch, which the roster may not declare.
|
|
37
|
+
* Child sessions report their own model in `SessionStarted` events.
|
|
38
|
+
*/
|
|
39
|
+
export class Started extends Schema.TaggedClass("AttemptChannel/Started")("Started", {
|
|
40
|
+
parentModel: ModelId,
|
|
41
|
+
}) {
|
|
42
|
+
}
|
|
43
|
+
/** One normalized parent or child session event, persisted in the Attempt transcript. */
|
|
44
|
+
export class SessionEvent extends Schema.TaggedClass("AttemptChannel/SessionEvent")("SessionEvent", { event: AgentSessionEvent }) {
|
|
45
|
+
}
|
|
46
|
+
export class Final extends Schema.TaggedClass("AttemptChannel/Final")("Final", {
|
|
47
|
+
result: StepResult,
|
|
48
|
+
}) {
|
|
49
|
+
}
|
|
50
|
+
export class Failed extends Schema.TaggedClass("AttemptChannel/Failed")("Failed", {
|
|
51
|
+
failure: AttemptFailure,
|
|
52
|
+
}) {
|
|
53
|
+
}
|
|
54
|
+
/** The run host stopped on an Interrupt frame. Terminal. */
|
|
55
|
+
export class Interrupted extends Schema.TaggedClass("AttemptChannel/Interrupted")("Interrupted", {}) {
|
|
56
|
+
}
|
|
57
|
+
export const OutboundPayload = Schema.Union([Started, SessionEvent, Final, Failed, Interrupted]);
|
|
58
|
+
export class Steer extends Schema.TaggedClass("AttemptChannel/Steer")("Steer", {
|
|
59
|
+
message: Schema.NonEmptyString,
|
|
60
|
+
}) {
|
|
61
|
+
}
|
|
62
|
+
export class Interrupt extends Schema.TaggedClass("AttemptChannel/Interrupt")("Interrupt", {}) {
|
|
63
|
+
}
|
|
64
|
+
export const InboundPayload = Schema.Union([Steer, Interrupt]);
|
|
65
|
+
const EnvelopeFields = {
|
|
66
|
+
version: Schema.Literal(PROTOCOL_VERSION),
|
|
67
|
+
attemptId: AttemptId,
|
|
68
|
+
sequence: Sequence,
|
|
69
|
+
sentAt: Schema.DateTimeUtcFromString,
|
|
70
|
+
};
|
|
71
|
+
export class OutboundEnvelope extends Schema.TaggedClass("AttemptChannel/OutboundEnvelope")("OutboundEnvelope", {
|
|
72
|
+
...EnvelopeFields,
|
|
73
|
+
payload: OutboundPayload,
|
|
74
|
+
}) {
|
|
75
|
+
}
|
|
76
|
+
export class InboundEnvelope extends Schema.TaggedClass("AttemptChannel/InboundEnvelope")("InboundEnvelope", {
|
|
77
|
+
...EnvelopeFields,
|
|
78
|
+
payload: InboundPayload,
|
|
79
|
+
}) {
|
|
80
|
+
}
|
|
81
|
+
export const Envelope = Schema.Union([OutboundEnvelope, InboundEnvelope]);
|
|
82
|
+
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
83
|
+
export class Start extends Schema.TaggedClass("AttemptChannel/Start")("Start", {
|
|
84
|
+
version: Schema.Literal(PROTOCOL_VERSION),
|
|
85
|
+
spec: RunSpec,
|
|
86
|
+
}) {
|
|
87
|
+
}
|
|
88
|
+
export const InputFrame = Schema.Union([Start, InboundEnvelope]);
|
|
89
|
+
export const EnvelopeFromJson = Schema.fromJsonString(Envelope);
|
|
90
|
+
export const InputFrameFromJson = Schema.fromJsonString(InputFrame);
|
|
91
|
+
export const OutboundEnvelopeFromJson = Schema.fromJsonString(OutboundEnvelope);
|
|
92
|
+
export const initialProgress = { state: "AwaitingStarted", nextSequence: 1 };
|
|
93
|
+
const isTerminal = (payload) => payload._tag === "Final" || payload._tag === "Failed" || payload._tag === "Interrupted";
|
|
94
|
+
/**
|
|
95
|
+
* Checks one outbound envelope against the progress so far and returns the next
|
|
96
|
+
* progress, or the violation. Every transport adapter folds the same state
|
|
97
|
+
* machine through it.
|
|
98
|
+
*/
|
|
99
|
+
export const admit = (progress, attemptId, envelope) => {
|
|
100
|
+
if (envelope.attemptId !== attemptId) {
|
|
101
|
+
return Result.fail({
|
|
102
|
+
message: "The run host emitted a frame for another Attempt",
|
|
103
|
+
detail: String(envelope.attemptId),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (envelope.sequence !== progress.nextSequence) {
|
|
107
|
+
return Result.fail({
|
|
108
|
+
message: "The run host emitted a non-contiguous sequence",
|
|
109
|
+
detail: `expected ${progress.nextSequence}, received ${envelope.sequence}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (progress.state === "Terminal") {
|
|
113
|
+
return Result.fail({
|
|
114
|
+
message: "The run host emitted an envelope after its terminal envelope",
|
|
115
|
+
detail: envelope.payload._tag,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (progress.state === "AwaitingStarted" &&
|
|
119
|
+
envelope.payload._tag !== "Started" &&
|
|
120
|
+
envelope.payload._tag !== "Failed") {
|
|
121
|
+
return Result.fail({
|
|
122
|
+
message: "The run host did not begin with a Started or Failed envelope",
|
|
123
|
+
detail: envelope.payload._tag,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (progress.state === "Running" && envelope.payload._tag === "Started") {
|
|
127
|
+
return Result.fail({
|
|
128
|
+
message: "The run host emitted more than one Started envelope",
|
|
129
|
+
detail: "duplicate Started envelope",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return Result.succeed({
|
|
133
|
+
state: isTerminal(envelope.payload) ? "Terminal" : "Running",
|
|
134
|
+
nextSequence: progress.nextSequence + 1,
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,C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AQ,CAAC,YAAY,cAAc,QAAQ,CAAC,QAAQ,EAAE;SAC3E,CAAC,CAAC;IACL,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,OAAO,EAAE,8DAA8D;YACvE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;SAC9B,CAAC,CAAC;IACL,CAAC;IACD,IACE,QAAQ,CAAC,KAAK,KAAK,iBAAiB;QACpC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;QACnC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAClC,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,OAAO,EAAE,8DAA8D;YACvE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI;SAC9B,CAAC,CAAC;IACL,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACxE,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,OAAO,EAAE,qDAAqD;YAC9D,MAAM,EAAE,4BAA4B;SACrC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;QAC5D,YAAY,EAAE,QAAQ,CAAC,YAAY,GAAG,CAAC;KACxC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const InfraFailure_base: Schema.Class<InfraFailure, Schema.TaggedStruct<"InfraFailure", {
|
|
3
|
+
readonly message: Schema.String;
|
|
4
|
+
readonly cause: Schema.Defect;
|
|
5
|
+
}>, import("effect/Cause").YieldableError>;
|
|
6
|
+
/**
|
|
7
|
+
* Infrastructure failed around the agent: worker unreachable, checkout failed,
|
|
8
|
+
* run host died. The only class the engine retries on its own, capped.
|
|
9
|
+
*/
|
|
10
|
+
export declare class InfraFailure extends InfraFailure_base {
|
|
11
|
+
}
|
|
12
|
+
declare const DefectFailure_base: Schema.Class<DefectFailure, Schema.TaggedStruct<"DefectFailure", {
|
|
13
|
+
readonly message: Schema.String;
|
|
14
|
+
readonly cause: Schema.Defect;
|
|
15
|
+
}>, import("effect/Cause").YieldableError>;
|
|
16
|
+
/** A programmer defect captured at the durable execution boundary. Retains its cause for diagnosis and requires an operator retry. */
|
|
17
|
+
export declare class DefectFailure extends DefectFailure_base {
|
|
18
|
+
}
|
|
19
|
+
declare const AgentFailure_base: Schema.Class<AgentFailure, Schema.TaggedStruct<"AgentFailure", {
|
|
20
|
+
readonly message: Schema.String;
|
|
21
|
+
}>, import("effect/Cause").YieldableError>;
|
|
22
|
+
/**
|
|
23
|
+
* The agent ran and failed the work itself. Never auto-retried, since the same
|
|
24
|
+
* agent would fail the same way; the operator decides what changes first.
|
|
25
|
+
*/
|
|
26
|
+
export declare class AgentFailure extends AgentFailure_base {
|
|
27
|
+
}
|
|
28
|
+
/** Which per-attempt ceiling the runaway guard tripped. */
|
|
29
|
+
export declare const RunawayCeiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
|
|
30
|
+
export type RunawayCeiling = typeof RunawayCeiling.Type;
|
|
31
|
+
declare const RunawayFailure_base: Schema.Class<RunawayFailure, Schema.TaggedStruct<"RunawayFailure", {
|
|
32
|
+
readonly ceiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
|
|
33
|
+
}>, import("effect/Cause").YieldableError>;
|
|
34
|
+
/** The runaway guard interrupted an attempt that burned without progress. Never auto-retried (ADR 0013). */
|
|
35
|
+
export declare class RunawayFailure extends RunawayFailure_base {
|
|
36
|
+
}
|
|
37
|
+
declare const ChildSessionBudgetFailure_base: Schema.Class<ChildSessionBudgetFailure, Schema.TaggedStruct<"ChildSessionBudgetFailure", {
|
|
38
|
+
readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
|
|
39
|
+
readonly attemptedChildren: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
40
|
+
}>, import("effect/Cause").YieldableError>;
|
|
41
|
+
/**
|
|
42
|
+
* The parent tried to spawn more child sessions than the Attempt allows. Never
|
|
43
|
+
* auto-retried, since the same parent would exhaust the same budget again.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ChildSessionBudgetFailure extends ChildSessionBudgetFailure_base {
|
|
46
|
+
}
|
|
47
|
+
export declare const AttemptFailure: Schema.Union<readonly [typeof InfraFailure, typeof DefectFailure, typeof AgentFailure, typeof RunawayFailure, typeof ChildSessionBudgetFailure]>;
|
|
48
|
+
export type AttemptFailure = typeof AttemptFailure.Type;
|
|
49
|
+
/** The class half of the auto-retry law: only infra failures qualify. `shouldAutoRetry` adds the attempt cap. */
|
|
50
|
+
export declare const isAutoRetryableFailure: <I>(input: I) => input is I & InfraFailure;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../../src/attempt/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAGhC;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAMjC;CAAG;;;;;AAEJ,sIAAsI;AACtI,qBAAa,aAAc,SAAQ,kBAEmC;CAAG;;;;AAEzE;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAKjC;CAAG;AAEJ,2DAA2D;AAC3D,eAAO,MAAM,cAAc,oDAA4C,CAAC;AACxE,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;;;;AAExD,4GAA4G;AAC5G,qBAAa,cAAe,SAAQ,mBAIlC;CAAG;;;;;AAEL;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG;AAEL,eAAO,MAAM,cAAc,kJAMzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,iHAAiH;AACjH,eAAO,MAAM,sBAAsB,4CAA0B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { ChildSessionBudget, ChildSessionCount } from "../agent/session.js";
|
|
3
|
+
/**
|
|
4
|
+
* Infrastructure failed around the agent: worker unreachable, checkout failed,
|
|
5
|
+
* run host died. The only class the engine retries on its own, capped.
|
|
6
|
+
*/
|
|
7
|
+
export class InfraFailure extends Schema.TaggedError("AttemptFailure/InfraFailure")("InfraFailure", {
|
|
8
|
+
message: Schema.String,
|
|
9
|
+
cause: Schema.Defect(),
|
|
10
|
+
}) {
|
|
11
|
+
}
|
|
12
|
+
/** A programmer defect captured at the durable execution boundary. Retains its cause for diagnosis and requires an operator retry. */
|
|
13
|
+
export class DefectFailure extends Schema.TaggedError("AttemptFailure/DefectFailure")("DefectFailure", { message: Schema.String, cause: Schema.Defect() }) {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The agent ran and failed the work itself. Never auto-retried, since the same
|
|
17
|
+
* agent would fail the same way; the operator decides what changes first.
|
|
18
|
+
*/
|
|
19
|
+
export class AgentFailure extends Schema.TaggedError("AttemptFailure/AgentFailure")("AgentFailure", {
|
|
20
|
+
message: Schema.String,
|
|
21
|
+
}) {
|
|
22
|
+
}
|
|
23
|
+
/** Which per-attempt ceiling the runaway guard tripped. */
|
|
24
|
+
export const RunawayCeiling = Schema.Literals(["wall-clock", "tokens"]);
|
|
25
|
+
/** The runaway guard interrupted an attempt that burned without progress. Never auto-retried (ADR 0013). */
|
|
26
|
+
export class RunawayFailure extends Schema.TaggedError("AttemptFailure/RunawayFailure")("RunawayFailure", {
|
|
27
|
+
ceiling: RunawayCeiling,
|
|
28
|
+
}) {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The parent tried to spawn more child sessions than the Attempt allows. Never
|
|
32
|
+
* auto-retried, since the same parent would exhaust the same budget again.
|
|
33
|
+
*/
|
|
34
|
+
export class ChildSessionBudgetFailure extends Schema.TaggedError("AttemptFailure/ChildSessionBudgetFailure")("ChildSessionBudgetFailure", {
|
|
35
|
+
maxChildren: ChildSessionBudget,
|
|
36
|
+
attemptedChildren: ChildSessionCount,
|
|
37
|
+
}) {
|
|
38
|
+
}
|
|
39
|
+
export const AttemptFailure = Schema.Union([
|
|
40
|
+
InfraFailure,
|
|
41
|
+
DefectFailure,
|
|
42
|
+
AgentFailure,
|
|
43
|
+
RunawayFailure,
|
|
44
|
+
ChildSessionBudgetFailure,
|
|
45
|
+
]);
|
|
46
|
+
/** The class half of the auto-retry law: only infra failures qualify. `shouldAutoRetry` adds the attempt cap. */
|
|
47
|
+
export const isAutoRetryableFailure = Schema.is(InfraFailure);
|
|
48
|
+
//# sourceMappingURL=failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failure.js","sourceRoot":"","sources":["../../src/attempt/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,6BAA6B,CAAC,CAC/F,cAAc,EACd;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;CACvB,CACF;CAAG;AAEJ,sIAAsI;AACtI,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,WAAW,CACnD,8BAA8B,CAC/B,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;CAAG;AAEzE;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,6BAA6B,CAAC,CAC/F,cAAc,EACd;IACE,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CACF;CAAG;AAEJ,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGxE,4GAA4G;AAC5G,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,CACpD,+BAA+B,CAChC,CAAC,gBAAgB,EAAE;IAClB,OAAO,EAAE,cAAc;CACxB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,WAAW,CAC/D,0CAA0C,CAC3C,CAAC,2BAA2B,EAAE;IAC7B,WAAW,EAAE,kBAAkB;IAC/B,iBAAiB,EAAE,iBAAiB;CACrC,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;IACzC,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,cAAc;IACd,yBAAyB;CAC1B,CAAC,CAAC;AAGH,iHAAiH;AACjH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const AttemptSucceeded_base: Schema.Class<AttemptSucceeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
|
|
3
|
+
/** The attempt finished; the step result is stored on the Step. */
|
|
4
|
+
export declare class AttemptSucceeded extends AttemptSucceeded_base {
|
|
5
|
+
}
|
|
6
|
+
declare const AttemptFailed_base: Schema.Class<AttemptFailed, Schema.TaggedStruct<"Failed", {
|
|
7
|
+
readonly failure: Schema.Union<readonly [typeof import("./failure.ts").InfraFailure, typeof import("./failure.ts").DefectFailure, typeof import("./failure.ts").AgentFailure, typeof import("./failure.ts").RunawayFailure, typeof import("./failure.ts").ChildSessionBudgetFailure]>;
|
|
8
|
+
}>, {}>;
|
|
9
|
+
/** The attempt failed with the typed failure that closed it. */
|
|
10
|
+
export declare class AttemptFailed extends AttemptFailed_base {
|
|
11
|
+
}
|
|
12
|
+
declare const AttemptCanceled_base: Schema.Class<AttemptCanceled, Schema.TaggedStruct<"Canceled", {}>, {}>;
|
|
13
|
+
/** The operator canceled the Run during this Attempt. */
|
|
14
|
+
export declare class AttemptCanceled extends AttemptCanceled_base {
|
|
15
|
+
}
|
|
16
|
+
/** The recorded end of one try; a failed Attempt may still be followed by a retry of the same Step. */
|
|
17
|
+
export declare const AttemptOutcome: Schema.Union<readonly [typeof AttemptSucceeded, typeof AttemptFailed, typeof AttemptCanceled]>;
|
|
18
|
+
export type AttemptOutcome = typeof AttemptOutcome.Type;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../src/attempt/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAGhC,mEAAmE;AACnE,qBAAa,gBAAiB,SAAQ,qBAEpB;CAAG;;;;AAErB,gEAAgE;AAChE,qBAAa,aAAc,SAAQ,kBAKlC;CAAG;;AAEJ,yDAAyD;AACzD,qBAAa,eAAgB,SAAQ,oBAGpC;CAAG;AAEJ,uGAAuG;AACvG,eAAO,MAAM,cAAc,gGAAmE,CAAC;AAC/F,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { AttemptFailure } from "./failure.js";
|
|
3
|
+
/** The attempt finished; the step result is stored on the Step. */
|
|
4
|
+
export class AttemptSucceeded extends Schema.TaggedClass("AttemptOutcome/Succeeded")("Succeeded", {}) {
|
|
5
|
+
}
|
|
6
|
+
/** The attempt failed with the typed failure that closed it. */
|
|
7
|
+
export class AttemptFailed extends Schema.TaggedClass("AttemptOutcome/Failed")("Failed", {
|
|
8
|
+
failure: AttemptFailure,
|
|
9
|
+
}) {
|
|
10
|
+
}
|
|
11
|
+
/** The operator canceled the Run during this Attempt. */
|
|
12
|
+
export class AttemptCanceled extends Schema.TaggedClass("AttemptOutcome/Canceled")("Canceled", {}) {
|
|
13
|
+
}
|
|
14
|
+
/** The recorded end of one try; a failed Attempt may still be followed by a retry of the same Step. */
|
|
15
|
+
export const AttemptOutcome = Schema.Union([AttemptSucceeded, AttemptFailed, AttemptCanceled]);
|
|
16
|
+
//# sourceMappingURL=outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["../../src/attempt/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,mEAAmE;AACnE,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,CACtD,0BAA0B,CAC3B,CAAC,WAAW,EAAE,EAAE,CAAC;CAAG;AAErB,gEAAgE;AAChE,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,WAAW,CAAgB,uBAAuB,CAAC,CAC3F,QAAQ,EACR;IACE,OAAO,EAAE,cAAc;CACxB,CACF;CAAG;AAEJ,yDAAyD;AACzD,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,CAAkB,yBAAyB,CAAC,CACjG,UAAU,EACV,EAAE,CACH;CAAG;AAEJ,uGAAuG;AACvG,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Maximum Runs one Loop may open for an Item between operator resets. */
|
|
3
|
+
export declare const CycleLimit: Schema.brand<Schema.Int, "CycleLimit">;
|
|
4
|
+
export type CycleLimit = typeof CycleLimit.Type;
|
|
5
|
+
/** Identifies one Item allowance between explicit operator resets. */
|
|
6
|
+
export declare const CycleGeneration: Schema.brand<Schema.Int, "CycleGeneration">;
|
|
7
|
+
export type CycleGeneration = typeof CycleGeneration.Type;
|
|
8
|
+
/** The safe default for unattended rounds on an Item. */
|
|
9
|
+
export declare const DEFAULT_CYCLE_LIMIT: number & import("effect/Brand").Brand<"CycleLimit">;
|
|
10
|
+
/** Number of admitted or completed rounds for one Loop on an Item. */
|
|
11
|
+
export declare const CycleCount: Schema.brand<Schema.Int, "CycleCount">;
|
|
12
|
+
export type CycleCount = typeof CycleCount.Type;
|
|
13
|
+
declare const LoopCycleCount_base: Schema.Class<LoopCycleCount, Schema.Struct<{
|
|
14
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
15
|
+
readonly admitted: Schema.brand<Schema.Int, "CycleCount">;
|
|
16
|
+
readonly completed: Schema.brand<Schema.Int, "CycleCount">;
|
|
17
|
+
}>, {}>;
|
|
18
|
+
/** A Loop's charged Runs and settled Runs in the current cycle budget. */
|
|
19
|
+
export declare class LoopCycleCount extends LoopCycleCount_base {
|
|
20
|
+
}
|
|
21
|
+
/** Identifies the Event and budget generation that first exhausted an Item's allowance. */
|
|
22
|
+
export declare const CycleBudgetAskId: Schema.brand<Schema.brand<Schema.NonEmptyString, "EventId">, "CycleBudgetAskId">;
|
|
23
|
+
export type CycleBudgetAskId = typeof CycleBudgetAskId.Type;
|
|
24
|
+
declare const CycleBudgetAsk_base: Schema.Class<CycleBudgetAsk, Schema.Struct<{
|
|
25
|
+
readonly id: Schema.brand<Schema.brand<Schema.NonEmptyString, "EventId">, "CycleBudgetAskId">;
|
|
26
|
+
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
27
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
28
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
29
|
+
readonly limit: Schema.brand<Schema.Int, "CycleLimit">;
|
|
30
|
+
readonly counts: Schema.NonEmptyArray<typeof LoopCycleCount>;
|
|
31
|
+
}>, {}>;
|
|
32
|
+
/** An Item-level request for an operator reset before further Runs can open. */
|
|
33
|
+
export declare class CycleBudgetAsk extends CycleBudgetAsk_base {
|
|
34
|
+
/** The furthest completed round; each Loop participates at most once per round. */
|
|
35
|
+
get completedCycles(): CycleCount;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=cycle-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycle-budget.d.ts","sourceRoot":"","sources":["../src/cycle-budget.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,0EAA0E;AAC1E,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,sEAAsE;AACtE,eAAO,MAAM,eAAe,6CAE3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,qDAAqB,CAAC;AAEtD,sEAAsE;AACtE,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;;;;;;AAEhD,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,mBAYnC;CAAG;AAEJ,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,kFAAiD,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;;;;;;;;;AAE5D,gFAAgF;AAChF,qBAAa,cAAe,SAAQ,mBAoBnC;IACC,mFAAmF;IACnF,IAAI,eAAe,IAAI,UAAU,CAEhC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EventId } from "./event.js";
|
|
2
|
+
import { ItemKey } from "./item.js";
|
|
3
|
+
import { LoopName } from "./loop.js";
|
|
4
|
+
import { RepositoryName } from "./repository.js";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
/** Maximum Runs one Loop may open for an Item between operator resets. */
|
|
7
|
+
export const CycleLimit = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("CycleLimit"));
|
|
8
|
+
/** Identifies one Item allowance between explicit operator resets. */
|
|
9
|
+
export const CycleGeneration = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("CycleGeneration"));
|
|
10
|
+
/** The safe default for unattended rounds on an Item. */
|
|
11
|
+
export const DEFAULT_CYCLE_LIMIT = CycleLimit.make(3);
|
|
12
|
+
/** Number of admitted or completed rounds for one Loop on an Item. */
|
|
13
|
+
export const CycleCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("CycleCount"));
|
|
14
|
+
/** A Loop's charged Runs and settled Runs in the current cycle budget. */
|
|
15
|
+
export class LoopCycleCount extends Schema.Class("LoopCycleCount")(Schema.Struct({
|
|
16
|
+
loop: LoopName,
|
|
17
|
+
admitted: CycleCount,
|
|
18
|
+
completed: CycleCount,
|
|
19
|
+
})
|
|
20
|
+
.check(Schema.makeFilter(({ admitted, completed }) => completed <= admitted, {
|
|
21
|
+
message: "Completed Runs cannot exceed admitted Runs",
|
|
22
|
+
}))
|
|
23
|
+
.annotate({ parseOptions: { onExcessProperty: "error" } })) {
|
|
24
|
+
}
|
|
25
|
+
/** Identifies the Event and budget generation that first exhausted an Item's allowance. */
|
|
26
|
+
export const CycleBudgetAskId = EventId.pipe(Schema.brand("CycleBudgetAskId"));
|
|
27
|
+
/** An Item-level request for an operator reset before further Runs can open. */
|
|
28
|
+
export class CycleBudgetAsk extends Schema.Class("CycleBudgetAsk")(Schema.Struct({
|
|
29
|
+
id: CycleBudgetAskId,
|
|
30
|
+
itemKey: ItemKey,
|
|
31
|
+
repository: RepositoryName,
|
|
32
|
+
loop: LoopName,
|
|
33
|
+
limit: CycleLimit,
|
|
34
|
+
counts: Schema.NonEmptyArray(LoopCycleCount),
|
|
35
|
+
})
|
|
36
|
+
.check(Schema.makeFilter(({ loop, limit, counts }) => new Set(counts.map((count) => count.loop)).size === counts.length &&
|
|
37
|
+
counts.some((count) => count.loop === loop && count.admitted >= limit), {
|
|
38
|
+
message: "Expected unique participating Loops including the exhausted Loop at its limit",
|
|
39
|
+
}))
|
|
40
|
+
.annotate({ parseOptions: { onExcessProperty: "error" } })) {
|
|
41
|
+
/** The furthest completed round; each Loop participates at most once per round. */
|
|
42
|
+
get completedCycles() {
|
|
43
|
+
return CycleCount.make(Math.max(...this.counts.map(({ completed }) => completed)));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cycle-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycle-budget.js","sourceRoot":"","sources":["../src/cycle-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,KA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CAAC;IACZ,EAAE,EAAE,gBAAgB;IACpB,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,cAAc;IAC1B,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC;CAC7C,CAAC;KACC,KAAK,CACJ,MAAM,CAAC,UAAU,CACf,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAC1B,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM;IACjE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EACxE;IACE,OAAO,EAAE,+EAA+E;CACzF,CACF,CACF;KACA,QAAQ,CAAC,EAAE,YAAY,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7D;IACC,mFAAmF;IACnF,IAAI,eAAe;QACjB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
|
package/dist/event.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Identity of one recorded fact; repeated sightings are matched through its dedup key. */
|
|
3
|
+
export declare const EventId: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
4
|
+
export type EventId = typeof EventId.Type;
|
|
5
|
+
/**
|
|
6
|
+
* Idempotency key the engine derives from watched state, timestamps excluded.
|
|
7
|
+
* The same state is the same Event forever, so a loop file never sets it (ADR 0002).
|
|
8
|
+
*/
|
|
9
|
+
export declare const DedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
|
|
10
|
+
export type DedupKey = typeof DedupKey.Type;
|
|
11
|
+
declare const Event_base: Schema.Class<Event, Schema.Struct<{
|
|
12
|
+
readonly id: Schema.brand<Schema.NonEmptyString, "EventId">;
|
|
13
|
+
readonly dedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
|
|
14
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
15
|
+
readonly receivedAt: Schema.DateTimeUtc;
|
|
16
|
+
}>, {}>;
|
|
17
|
+
/**
|
|
18
|
+
* One deduplicated fact the engine may react to: a trigger match or an operator
|
|
19
|
+
* approval. Trigger payloads retain the snapshot that selection expressions
|
|
20
|
+
* and prompt interpolation use; retries keep that recorded snapshot.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Event extends Event_base {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,2FAA2F;AAC3F,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;;AAE5C;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,UAKzB;CAAG"}
|
package/dist/event.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Identity of one recorded fact; repeated sightings are matched through its dedup key. */
|
|
3
|
+
export const EventId = Schema.NonEmptyString.pipe(Schema.brand("EventId"));
|
|
4
|
+
/**
|
|
5
|
+
* Idempotency key the engine derives from watched state, timestamps excluded.
|
|
6
|
+
* The same state is the same Event forever, so a loop file never sets it (ADR 0002).
|
|
7
|
+
*/
|
|
8
|
+
export const DedupKey = Schema.NonEmptyString.pipe(Schema.brand("DedupKey"));
|
|
9
|
+
/**
|
|
10
|
+
* One deduplicated fact the engine may react to: a trigger match or an operator
|
|
11
|
+
* approval. Trigger payloads retain the snapshot that selection expressions
|
|
12
|
+
* and prompt interpolation use; retries keep that recorded snapshot.
|
|
13
|
+
*/
|
|
14
|
+
export class Event extends Schema.Class("Event")({
|
|
15
|
+
id: EventId,
|
|
16
|
+
dedupKey: DedupKey,
|
|
17
|
+
payload: Schema.Json,
|
|
18
|
+
receivedAt: Schema.DateTimeUtc,
|
|
19
|
+
}) {
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,MAAM,CAAC,KAAK,CAAQ,OAAO,CAAC,CAAC;IACtD,EAAE,EAAE,OAAO;IACX,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,MAAM,CAAC,IAAI;IACpB,UAAU,EAAE,MAAM,CAAC,WAAW;CAC/B,CAAC;CAAG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Root folder containing the factory's `usine.yaml`, Loop files, and Agent roster; the caller resolves its location. */
|
|
3
|
+
export declare const InstanceDirectory: Schema.brand<Schema.NonEmptyString, "InstanceDirectory">;
|
|
4
|
+
export type InstanceDirectory = typeof InstanceDirectory.Type;
|
|
5
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,yHAAyH;AACzH,eAAO,MAAM,iBAAiB,0DAAgE,CAAC;AAC/F,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC"}
|
package/dist/instance.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Root folder containing the factory's `usine.yaml`, Loop files, and Agent roster; the caller resolves its location. */
|
|
3
|
+
export const InstanceDirectory = Schema.NonEmptyString.pipe(Schema.brand("InstanceDirectory"));
|
|
4
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,yHAAyH;AACzH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
|
package/dist/item.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Identity of the issue or pull request a loop acts on. Many content-distinct Events can concern one Item. */
|
|
3
|
+
export declare const ItemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
4
|
+
export type ItemKey = typeof ItemKey.Type;
|
|
5
|
+
/** The issue or pull request number within its repository. */
|
|
6
|
+
export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
|
|
7
|
+
export type ItemNumber = typeof ItemNumber.Type;
|
|
8
|
+
//# sourceMappingURL=item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+GAA+G;AAC/G,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
|