@usine/core 0.1.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 +32 -22
- 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 +139 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +119 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/attempt/attempt.d.ts +53 -0
- package/dist/attempt/attempt.d.ts.map +1 -0
- package/dist/attempt/attempt.js +47 -0
- package/dist/attempt/attempt.js.map +1 -0
- package/dist/attempt/channel.d.ts +194 -0
- package/dist/attempt/channel.d.ts.map +1 -0
- package/dist/attempt/channel.js +196 -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/{lifecycle/event.d.ts → event.d.ts} +6 -11
- 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 +3 -7
- package/dist/instance.d.ts.map +1 -1
- package/dist/instance.js +2 -6
- package/dist/instance.js.map +1 -1
- 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 +12 -17
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +11 -16
- package/dist/repository.js.map +1 -1
- 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 → step/result.d.ts} +7 -9
- package/dist/step/result.d.ts.map +1 -0
- package/dist/{step-result.js → step/result.js} +8 -10
- 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 +7 -7
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +5 -5
- package/dist/worker.js.map +1 -1
- package/package.json +76 -4
- package/dist/agent.d.ts +0 -121
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -105
- package/dist/agent.js.map +0 -1
- package/dist/attempt-channel.d.ts +0 -134
- package/dist/attempt-channel.d.ts.map +0 -1
- package/dist/attempt-channel.js +0 -138
- package/dist/attempt-channel.js.map +0 -1
- package/dist/index.d.ts +0 -24
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -24
- 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 -61
- package/dist/lifecycle/attempt.d.ts.map +0 -1
- package/dist/lifecycle/attempt.js +0 -52
- package/dist/lifecycle/attempt.js.map +0 -1
- 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/item.d.ts +0 -11
- package/dist/lifecycle/item.d.ts.map +0 -1
- package/dist/lifecycle/item.js +0 -9
- package/dist/lifecycle/item.js.map +0 -1
- package/dist/lifecycle/loop.d.ts +0 -17
- package/dist/lifecycle/loop.d.ts.map +0 -1
- package/dist/lifecycle/loop.js +0 -15
- package/dist/lifecycle/loop.js.map +0 -1
- package/dist/lifecycle/run-state.d.ts +0 -133
- package/dist/lifecycle/run-state.d.ts.map +0 -1
- package/dist/lifecycle/run-state.js +0 -126
- 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 -23
- package/dist/lifecycle/step.d.ts.map +0 -1
- package/dist/lifecycle/step.js +0 -21
- package/dist/lifecycle/step.js.map +0 -1
- package/dist/step-result.d.ts.map +0 -1
- package/dist/step-result.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Agent, AgentName } from "../agent/agent.js";
|
|
3
|
+
import { BrainSpec, ModelId } from "../agent/brain.js";
|
|
4
|
+
import { RunId } from "../run/run.js";
|
|
5
|
+
import { StepName } from "../step/step.js";
|
|
6
|
+
import { WorkerName } from "../worker.js";
|
|
7
|
+
import { AttemptFailure, isAutoRetryableFailure } from "./failure.js";
|
|
8
|
+
import { AttemptOutcome } from "./outcome.js";
|
|
9
|
+
/** Identity of one execution try; each retry receives a new identity under the same Run and Step. */
|
|
10
|
+
export const AttemptId = Schema.NonEmptyString.pipe(Schema.brand("AttemptId"));
|
|
11
|
+
/**
|
|
12
|
+
* 1-based position of a try under its step. Retries are attempt N+1 under the
|
|
13
|
+
* same step, and the auto-retry cap counts total attempts.
|
|
14
|
+
*/
|
|
15
|
+
export const AttemptNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("AttemptNumber"));
|
|
16
|
+
/** Task text given to the agent after loop interpolation or an operator's edit-and-retry amendment. */
|
|
17
|
+
export const AttemptTask = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected non-blank task text" })).pipe(Schema.brand("AttemptTask"));
|
|
18
|
+
/** The effective task and roster Agent an operator assigns to a Run's later Attempts. */
|
|
19
|
+
export class AttemptContext extends Schema.Class("AttemptContext")({
|
|
20
|
+
task: AttemptTask,
|
|
21
|
+
agent: Agent,
|
|
22
|
+
parentModel: Schema.OptionFromNullOr(ModelId),
|
|
23
|
+
}) {
|
|
24
|
+
}
|
|
25
|
+
/** One try of a step on a worker. `outcome` is none while the attempt is in flight. */
|
|
26
|
+
export class Attempt extends Schema.Class("Attempt")({
|
|
27
|
+
id: AttemptId,
|
|
28
|
+
runId: RunId,
|
|
29
|
+
stepName: StepName,
|
|
30
|
+
worker: WorkerName,
|
|
31
|
+
number: AttemptNumber,
|
|
32
|
+
brain: BrainSpec,
|
|
33
|
+
task: AttemptTask,
|
|
34
|
+
agent: AgentName,
|
|
35
|
+
operatorIntervened: Schema.Boolean,
|
|
36
|
+
parentModel: Schema.OptionFromNullOr(ModelId),
|
|
37
|
+
startedAt: Schema.DateTimeUtc,
|
|
38
|
+
outcome: Schema.Option(AttemptOutcome),
|
|
39
|
+
}) {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The auto-retry law: only an infra failure retries, and only while the attempt
|
|
43
|
+
* number is below `maxAutoAttempts` (ADR 0002).
|
|
44
|
+
* `number` is the failed try's position; `maxAutoAttempts` includes the first try.
|
|
45
|
+
*/
|
|
46
|
+
export const shouldAutoRetry = (options) => isAutoRetryableFailure(options.failure) && options.number < options.maxAutoAttempts;
|
|
47
|
+
//# sourceMappingURL=attempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attempt.js","sourceRoot":"","sources":["../../src/attempt/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qGAAqG;AACrG,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAI/E;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAClF,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAC9B,CAAC;AAGF,uGAAuG;AACvG,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC5C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CACrE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AAGpC,yFAAyF;AACzF,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAAiB,gBAAgB,CAAC,CAAC;IACjF,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;CAC9C,CAAC;CAAG;AAEL,uFAAuF;AACvF,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,KAAK,CAAU,SAAS,CAAC,CAAC;IAC5D,EAAE,EAAE,SAAS;IACb,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,SAAS;IAChB,kBAAkB,EAAE,MAAM,CAAC,OAAO;IAClC,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC,WAAW;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;CACvC,CAAC;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAI/B,EAAW,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Effect, Result, Schema } 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: 6;
|
|
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, operator input, Cancel) 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, typeof import("../agent/session.ts").SessionIdle, typeof import("../agent/session.ts").SessionResumed, typeof import("../agent/session.ts").SessionTokensUpdated]>;
|
|
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 acknowledged Attempt cancellation. Terminal. */
|
|
62
|
+
export declare class Interrupted extends Interrupted_base {
|
|
63
|
+
}
|
|
64
|
+
declare const Steer_base: Schema.Class<Steer, Schema.TaggedStruct<"Steer", {
|
|
65
|
+
readonly message: Schema.NonEmptyString;
|
|
66
|
+
}>, {}>;
|
|
67
|
+
export declare class Steer extends Steer_base {
|
|
68
|
+
}
|
|
69
|
+
declare const Interrupt_base: Schema.Class<Interrupt, Schema.TaggedStruct<"Interrupt", {}>, {}>;
|
|
70
|
+
export declare class Interrupt extends Interrupt_base {
|
|
71
|
+
}
|
|
72
|
+
declare const Cancel_base: Schema.Class<Cancel, Schema.TaggedStruct<"Cancel", {}>, {}>;
|
|
73
|
+
/** Stops the entire Attempt, including every held or paused session. Used by cancellation and guardrails. */
|
|
74
|
+
export declare class Cancel extends Cancel_base {
|
|
75
|
+
}
|
|
76
|
+
declare const OperatorMessage_base: Schema.Class<OperatorMessage, Schema.TaggedStruct<"OperatorMessage", {
|
|
77
|
+
readonly message: Schema.NonEmptyString;
|
|
78
|
+
}>, {}>;
|
|
79
|
+
/** An operator turn joined to the target session, distinct from a Steer so a takeover can record and hold it (ADR 0018). */
|
|
80
|
+
export declare class OperatorMessage extends OperatorMessage_base {
|
|
81
|
+
}
|
|
82
|
+
declare const Release_base: Schema.Class<Release, Schema.TaggedStruct<"Release", {}>, {}>;
|
|
83
|
+
/** Ends a held child's takeover, letting its idle result return to the awaiting parent (ADR 0018). */
|
|
84
|
+
export declare class Release extends Release_base {
|
|
85
|
+
}
|
|
86
|
+
/** Nonterminal operator controls; cancellation is an Attempt operation. */
|
|
87
|
+
export declare const OperatorAction: Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>;
|
|
88
|
+
export type OperatorAction = typeof OperatorAction.Type;
|
|
89
|
+
export declare const InboundPayload: Schema.Union<readonly [Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>, typeof Cancel]>;
|
|
90
|
+
export type InboundPayload = typeof InboundPayload.Type;
|
|
91
|
+
declare const ParentTarget_base: Schema.Class<ParentTarget, Schema.TaggedStruct<"Parent", {}>, {}>;
|
|
92
|
+
/** The Pi parent, the default recipient of operator input for an Attempt. */
|
|
93
|
+
export declare class ParentTarget extends ParentTarget_base {
|
|
94
|
+
}
|
|
95
|
+
declare const ChildTarget_base: Schema.Class<ChildTarget, Schema.TaggedStruct<"Child", {
|
|
96
|
+
readonly sessionId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
|
|
97
|
+
}>, {}>;
|
|
98
|
+
/** A harness child of the Attempt's parent, addressed by the id it reports in the normalized event stream. */
|
|
99
|
+
export declare class ChildTarget extends ChildTarget_base {
|
|
100
|
+
}
|
|
101
|
+
/** Which session inside an Attempt an inbound frame addresses: the Pi parent, or one of its children. */
|
|
102
|
+
export declare const SessionTarget: Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>;
|
|
103
|
+
export type SessionTarget = typeof SessionTarget.Type;
|
|
104
|
+
declare const Intervention_base: Schema.Class<Intervention, Schema.Struct<{
|
|
105
|
+
readonly operator: Schema.NonEmptyString;
|
|
106
|
+
readonly target: Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>;
|
|
107
|
+
readonly action: Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>;
|
|
108
|
+
}>, {}>;
|
|
109
|
+
/** Attributed operator input addressed to one live session, never an Event. */
|
|
110
|
+
export declare class Intervention extends Intervention_base {
|
|
111
|
+
}
|
|
112
|
+
declare const InterventionState_base: Schema.Class<InterventionState, Schema.Struct<{
|
|
113
|
+
readonly held: Schema.Boolean;
|
|
114
|
+
readonly paused: Schema.Boolean;
|
|
115
|
+
}>, {}>;
|
|
116
|
+
/** The session's supervision state after an accepted operator action. */
|
|
117
|
+
export declare class InterventionState extends InterventionState_base {
|
|
118
|
+
}
|
|
119
|
+
declare const InterventionApplied_base: Schema.Class<InterventionApplied, Schema.TaggedStruct<"InterventionApplied", {
|
|
120
|
+
readonly inputSequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
121
|
+
readonly intervention: typeof Intervention;
|
|
122
|
+
readonly state: typeof InterventionState;
|
|
123
|
+
}>, {}>;
|
|
124
|
+
/** Acknowledges delivery and records the resulting Hold or pause in the transcript. */
|
|
125
|
+
export declare class InterventionApplied extends InterventionApplied_base {
|
|
126
|
+
}
|
|
127
|
+
declare const InterventionRejected_base: Schema.Class<InterventionRejected, Schema.TaggedStruct<"InterventionRejected", {
|
|
128
|
+
readonly inputSequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
129
|
+
readonly intervention: typeof Intervention;
|
|
130
|
+
readonly message: Schema.NonEmptyString;
|
|
131
|
+
}>, {}>;
|
|
132
|
+
/** A session closed or refused an operator action; the Attempt itself continues. */
|
|
133
|
+
export declare class InterventionRejected extends InterventionRejected_base {
|
|
134
|
+
}
|
|
135
|
+
export declare const OutboundPayload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected]>;
|
|
136
|
+
export type OutboundPayload = typeof OutboundPayload.Type;
|
|
137
|
+
declare const OutboundEnvelope_base: Schema.Class<OutboundEnvelope, Schema.TaggedStruct<"OutboundEnvelope", {
|
|
138
|
+
readonly version: Schema.Literal<6>;
|
|
139
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
140
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
141
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
142
|
+
readonly payload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected]>;
|
|
143
|
+
}>, {}>;
|
|
144
|
+
export declare class OutboundEnvelope extends OutboundEnvelope_base {
|
|
145
|
+
}
|
|
146
|
+
declare const InboundEnvelope_base: Schema.Class<InboundEnvelope, Schema.TaggedStruct<"InboundEnvelope", {
|
|
147
|
+
readonly version: Schema.Literal<6>;
|
|
148
|
+
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
149
|
+
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
150
|
+
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
151
|
+
/** The session this frame addresses; the Pi parent unless a child is named. */
|
|
152
|
+
readonly target: Schema.withDecodingDefaultKey<Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>, never>;
|
|
153
|
+
readonly operator: Schema.NonEmptyString;
|
|
154
|
+
readonly payload: Schema.Union<readonly [Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>, typeof Cancel]>;
|
|
155
|
+
}>, {}>;
|
|
156
|
+
export declare class InboundEnvelope extends InboundEnvelope_base {
|
|
157
|
+
}
|
|
158
|
+
export declare const Envelope: Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>;
|
|
159
|
+
export type Envelope = typeof Envelope.Type;
|
|
160
|
+
declare const Start_base: Schema.Class<Start, Schema.TaggedStruct<"Start", {
|
|
161
|
+
readonly version: Schema.Literal<6>;
|
|
162
|
+
readonly spec: typeof RunSpec;
|
|
163
|
+
}>, {}>;
|
|
164
|
+
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
165
|
+
export declare class Start extends Start_base {
|
|
166
|
+
}
|
|
167
|
+
export declare const InputFrame: Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>;
|
|
168
|
+
export type InputFrame = typeof InputFrame.Type;
|
|
169
|
+
export declare const EnvelopeFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>>;
|
|
170
|
+
export declare const InputFrameFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>>;
|
|
171
|
+
export declare const OutboundEnvelopeFromJson: Schema.fromJsonString<typeof OutboundEnvelope>;
|
|
172
|
+
/** Where a channel consumer persists envelopes. */
|
|
173
|
+
export interface Sink {
|
|
174
|
+
readonly append: (direction: Direction, envelope: Envelope) => Effect.Effect<void, AttemptFailure>;
|
|
175
|
+
}
|
|
176
|
+
/** How far one outbound channel has legally progressed. */
|
|
177
|
+
export interface Progress {
|
|
178
|
+
readonly state: "AwaitingStarted" | "Running" | "Terminal";
|
|
179
|
+
readonly nextSequence: number;
|
|
180
|
+
}
|
|
181
|
+
export declare const initialProgress: Progress;
|
|
182
|
+
/** One protocol violation, described for the infra failure that reports it. */
|
|
183
|
+
export interface Violation {
|
|
184
|
+
readonly message: string;
|
|
185
|
+
readonly detail: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Checks one outbound envelope against the progress so far and returns the next
|
|
189
|
+
* progress, or the violation. Every transport adapter folds the same state
|
|
190
|
+
* machine through it.
|
|
191
|
+
*/
|
|
192
|
+
export declare const admit: (progress: Progress, attemptId: AttemptId, envelope: OutboundEnvelope) => Result.Result<Progress, Violation>;
|
|
193
|
+
export {};
|
|
194
|
+
//# 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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,QAAQ,oDAEpB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,UAAU,YAAI,SAAS,EAAE,UAAU,CAAU,CAAC;AAC3D,eAAO,MAAM,SAAS,mDAA8B,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;;;;;;;;;;;;;AAE9C,6E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YACV,gBAAgB,KACzB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAuCnC,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Effect, Result, Schema } from "effect";
|
|
2
|
+
import { Agent } from "../agent/agent.js";
|
|
3
|
+
import { Effort, ModelId } from "../agent/brain.js";
|
|
4
|
+
import { AgentSessionEvent, AgentSessionId, 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 = 6;
|
|
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, operator input, Cancel) 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 acknowledged Attempt cancellation. Terminal. */
|
|
55
|
+
export class Interrupted extends Schema.TaggedClass("AttemptChannel/Interrupted")("Interrupted", {}) {
|
|
56
|
+
}
|
|
57
|
+
export class Steer extends Schema.TaggedClass("AttemptChannel/Steer")("Steer", {
|
|
58
|
+
message: Schema.NonEmptyString,
|
|
59
|
+
}) {
|
|
60
|
+
}
|
|
61
|
+
export class Interrupt extends Schema.TaggedClass("AttemptChannel/Interrupt")("Interrupt", {}) {
|
|
62
|
+
}
|
|
63
|
+
/** Stops the entire Attempt, including every held or paused session. Used by cancellation and guardrails. */
|
|
64
|
+
export class Cancel extends Schema.TaggedClass("AttemptChannel/Cancel")("Cancel", {}) {
|
|
65
|
+
}
|
|
66
|
+
/** An operator turn joined to the target session, distinct from a Steer so a takeover can record and hold it (ADR 0018). */
|
|
67
|
+
export class OperatorMessage extends Schema.TaggedClass("AttemptChannel/OperatorMessage")("OperatorMessage", {
|
|
68
|
+
message: Schema.NonEmptyString,
|
|
69
|
+
}) {
|
|
70
|
+
}
|
|
71
|
+
/** Ends a held child's takeover, letting its idle result return to the awaiting parent (ADR 0018). */
|
|
72
|
+
export class Release extends Schema.TaggedClass("AttemptChannel/Release")("Release", {}) {
|
|
73
|
+
}
|
|
74
|
+
/** Nonterminal operator controls; cancellation is an Attempt operation. */
|
|
75
|
+
export const OperatorAction = Schema.Union([Steer, Interrupt, OperatorMessage, Release]);
|
|
76
|
+
export const InboundPayload = Schema.Union([OperatorAction, Cancel]);
|
|
77
|
+
/** The Pi parent, the default recipient of operator input for an Attempt. */
|
|
78
|
+
export class ParentTarget extends Schema.TaggedClass("AttemptChannel/ParentTarget")("Parent", {}) {
|
|
79
|
+
}
|
|
80
|
+
/** A harness child of the Attempt's parent, addressed by the id it reports in the normalized event stream. */
|
|
81
|
+
export class ChildTarget extends Schema.TaggedClass("AttemptChannel/ChildTarget")("Child", { sessionId: AgentSessionId }) {
|
|
82
|
+
}
|
|
83
|
+
/** Which session inside an Attempt an inbound frame addresses: the Pi parent, or one of its children. */
|
|
84
|
+
export const SessionTarget = Schema.Union([ParentTarget, ChildTarget]);
|
|
85
|
+
/** Attributed operator input addressed to one live session, never an Event. */
|
|
86
|
+
export class Intervention extends Schema.Class("AttemptChannel/Intervention")({
|
|
87
|
+
operator: Schema.NonEmptyString,
|
|
88
|
+
target: SessionTarget,
|
|
89
|
+
action: OperatorAction,
|
|
90
|
+
}) {
|
|
91
|
+
}
|
|
92
|
+
/** The session's supervision state after an accepted operator action. */
|
|
93
|
+
export class InterventionState extends Schema.Class("AttemptChannel/InterventionState")({
|
|
94
|
+
held: Schema.Boolean,
|
|
95
|
+
paused: Schema.Boolean,
|
|
96
|
+
}) {
|
|
97
|
+
}
|
|
98
|
+
/** Acknowledges delivery and records the resulting Hold or pause in the transcript. */
|
|
99
|
+
export class InterventionApplied extends Schema.TaggedClass("AttemptChannel/InterventionApplied")("InterventionApplied", {
|
|
100
|
+
inputSequence: Sequence,
|
|
101
|
+
intervention: Intervention,
|
|
102
|
+
state: InterventionState,
|
|
103
|
+
}) {
|
|
104
|
+
}
|
|
105
|
+
/** A session closed or refused an operator action; the Attempt itself continues. */
|
|
106
|
+
export class InterventionRejected extends Schema.TaggedClass("AttemptChannel/InterventionRejected")("InterventionRejected", {
|
|
107
|
+
inputSequence: Sequence,
|
|
108
|
+
intervention: Intervention,
|
|
109
|
+
message: Schema.NonEmptyString,
|
|
110
|
+
}) {
|
|
111
|
+
}
|
|
112
|
+
export const OutboundPayload = Schema.Union([
|
|
113
|
+
Started,
|
|
114
|
+
SessionEvent,
|
|
115
|
+
Final,
|
|
116
|
+
Failed,
|
|
117
|
+
Interrupted,
|
|
118
|
+
InterventionApplied,
|
|
119
|
+
InterventionRejected,
|
|
120
|
+
]);
|
|
121
|
+
const EnvelopeFields = {
|
|
122
|
+
version: Schema.Literal(PROTOCOL_VERSION),
|
|
123
|
+
attemptId: AttemptId,
|
|
124
|
+
sequence: Sequence,
|
|
125
|
+
sentAt: Schema.DateTimeUtcFromString,
|
|
126
|
+
};
|
|
127
|
+
export class OutboundEnvelope extends Schema.TaggedClass("AttemptChannel/OutboundEnvelope")("OutboundEnvelope", {
|
|
128
|
+
...EnvelopeFields,
|
|
129
|
+
payload: OutboundPayload,
|
|
130
|
+
}) {
|
|
131
|
+
}
|
|
132
|
+
export class InboundEnvelope extends Schema.TaggedClass("AttemptChannel/InboundEnvelope")("InboundEnvelope", {
|
|
133
|
+
...EnvelopeFields,
|
|
134
|
+
/** The session this frame addresses; the Pi parent unless a child is named. */
|
|
135
|
+
target: SessionTarget.pipe(Schema.withDecodingDefaultKey(Effect.succeed({ _tag: "Parent" }))),
|
|
136
|
+
operator: Schema.NonEmptyString,
|
|
137
|
+
payload: InboundPayload,
|
|
138
|
+
}) {
|
|
139
|
+
}
|
|
140
|
+
export const Envelope = Schema.Union([OutboundEnvelope, InboundEnvelope]);
|
|
141
|
+
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
142
|
+
export class Start extends Schema.TaggedClass("AttemptChannel/Start")("Start", {
|
|
143
|
+
version: Schema.Literal(PROTOCOL_VERSION),
|
|
144
|
+
spec: RunSpec,
|
|
145
|
+
}) {
|
|
146
|
+
}
|
|
147
|
+
export const InputFrame = Schema.Union([Start, InboundEnvelope]);
|
|
148
|
+
export const EnvelopeFromJson = Schema.fromJsonString(Envelope);
|
|
149
|
+
export const InputFrameFromJson = Schema.fromJsonString(InputFrame);
|
|
150
|
+
export const OutboundEnvelopeFromJson = Schema.fromJsonString(OutboundEnvelope);
|
|
151
|
+
export const initialProgress = { state: "AwaitingStarted", nextSequence: 1 };
|
|
152
|
+
const isTerminal = (payload) => payload._tag === "Final" || payload._tag === "Failed" || payload._tag === "Interrupted";
|
|
153
|
+
/**
|
|
154
|
+
* Checks one outbound envelope against the progress so far and returns the next
|
|
155
|
+
* progress, or the violation. Every transport adapter folds the same state
|
|
156
|
+
* machine through it.
|
|
157
|
+
*/
|
|
158
|
+
export const admit = (progress, attemptId, envelope) => {
|
|
159
|
+
if (envelope.attemptId !== attemptId) {
|
|
160
|
+
return Result.fail({
|
|
161
|
+
message: "The run host emitted a frame for another Attempt",
|
|
162
|
+
detail: String(envelope.attemptId),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (envelope.sequence !== progress.nextSequence) {
|
|
166
|
+
return Result.fail({
|
|
167
|
+
message: "The run host emitted a non-contiguous sequence",
|
|
168
|
+
detail: `expected ${progress.nextSequence}, received ${envelope.sequence}`,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (progress.state === "Terminal") {
|
|
172
|
+
return Result.fail({
|
|
173
|
+
message: "The run host emitted an envelope after its terminal envelope",
|
|
174
|
+
detail: envelope.payload._tag,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (progress.state === "AwaitingStarted" &&
|
|
178
|
+
envelope.payload._tag !== "Started" &&
|
|
179
|
+
envelope.payload._tag !== "Failed") {
|
|
180
|
+
return Result.fail({
|
|
181
|
+
message: "The run host did not begin with a Started or Failed envelope",
|
|
182
|
+
detail: envelope.payload._tag,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (progress.state === "Running" && envelope.payload._tag === "Started") {
|
|
186
|
+
return Result.fail({
|
|
187
|
+
message: "The run host emitted more than one Started envelope",
|
|
188
|
+
detail: "duplicate Started envelope",
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return Result.succeed({
|
|
192
|
+
state: isTerminal(envelope.payload) ? "Terminal" : "Running",
|
|
193
|
+
nextSequence: progress.nextSequence + 1,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
//# 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,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,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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AAE,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"}
|