@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.
Files changed (123) hide show
  1. package/README.md +32 -22
  2. package/dist/agent/agent.d.ts +27 -0
  3. package/dist/agent/agent.d.ts.map +1 -0
  4. package/dist/agent/agent.js +26 -0
  5. package/dist/agent/agent.js.map +1 -0
  6. package/dist/agent/brain.d.ts +24 -0
  7. package/dist/agent/brain.d.ts.map +1 -0
  8. package/dist/agent/brain.js +19 -0
  9. package/dist/agent/brain.js.map +1 -0
  10. package/dist/agent/capability.d.ts +23 -0
  11. package/dist/agent/capability.d.ts.map +1 -0
  12. package/dist/agent/capability.js +19 -0
  13. package/dist/agent/capability.js.map +1 -0
  14. package/dist/agent/session.d.ts +139 -0
  15. package/dist/agent/session.d.ts.map +1 -0
  16. package/dist/agent/session.js +119 -0
  17. package/dist/agent/session.js.map +1 -0
  18. package/dist/attempt/attempt.d.ts +53 -0
  19. package/dist/attempt/attempt.d.ts.map +1 -0
  20. package/dist/attempt/attempt.js +47 -0
  21. package/dist/attempt/attempt.js.map +1 -0
  22. package/dist/attempt/channel.d.ts +194 -0
  23. package/dist/attempt/channel.d.ts.map +1 -0
  24. package/dist/attempt/channel.js +196 -0
  25. package/dist/attempt/channel.js.map +1 -0
  26. package/dist/attempt/failure.d.ts +52 -0
  27. package/dist/attempt/failure.d.ts.map +1 -0
  28. package/dist/attempt/failure.js +48 -0
  29. package/dist/attempt/failure.js.map +1 -0
  30. package/dist/attempt/outcome.d.ts +20 -0
  31. package/dist/attempt/outcome.d.ts.map +1 -0
  32. package/dist/attempt/outcome.js +16 -0
  33. package/dist/attempt/outcome.js.map +1 -0
  34. package/dist/cycle-budget.d.ts +38 -0
  35. package/dist/cycle-budget.d.ts.map +1 -0
  36. package/dist/cycle-budget.js +46 -0
  37. package/dist/cycle-budget.js.map +1 -0
  38. package/dist/{lifecycle/event.d.ts → event.d.ts} +6 -11
  39. package/dist/event.d.ts.map +1 -0
  40. package/dist/event.js +21 -0
  41. package/dist/event.js.map +1 -0
  42. package/dist/instance.d.ts +3 -7
  43. package/dist/instance.d.ts.map +1 -1
  44. package/dist/instance.js +2 -6
  45. package/dist/instance.js.map +1 -1
  46. package/dist/item.d.ts +8 -0
  47. package/dist/item.d.ts.map +1 -0
  48. package/dist/item.js +6 -0
  49. package/dist/item.js.map +1 -0
  50. package/dist/loop.d.ts +9 -0
  51. package/dist/loop.d.ts.map +1 -0
  52. package/dist/loop.js +7 -0
  53. package/dist/loop.js.map +1 -0
  54. package/dist/repository.d.ts +12 -17
  55. package/dist/repository.d.ts.map +1 -1
  56. package/dist/repository.js +11 -16
  57. package/dist/repository.js.map +1 -1
  58. package/dist/run/run.d.ts +16 -0
  59. package/dist/run/run.d.ts.map +1 -0
  60. package/dist/run/run.js +16 -0
  61. package/dist/run/run.js.map +1 -0
  62. package/dist/run/state.d.ts +114 -0
  63. package/dist/run/state.d.ts.map +1 -0
  64. package/dist/run/state.js +102 -0
  65. package/dist/run/state.js.map +1 -0
  66. package/dist/{step-result.d.ts → step/result.d.ts} +7 -9
  67. package/dist/step/result.d.ts.map +1 -0
  68. package/dist/{step-result.js → step/result.js} +8 -10
  69. package/dist/step/result.js.map +1 -0
  70. package/dist/step/step.d.ts +21 -0
  71. package/dist/step/step.d.ts.map +1 -0
  72. package/dist/step/step.js +19 -0
  73. package/dist/step/step.js.map +1 -0
  74. package/dist/worker.d.ts +7 -7
  75. package/dist/worker.d.ts.map +1 -1
  76. package/dist/worker.js +5 -5
  77. package/dist/worker.js.map +1 -1
  78. package/package.json +76 -4
  79. package/dist/agent.d.ts +0 -121
  80. package/dist/agent.d.ts.map +0 -1
  81. package/dist/agent.js +0 -105
  82. package/dist/agent.js.map +0 -1
  83. package/dist/attempt-channel.d.ts +0 -134
  84. package/dist/attempt-channel.d.ts.map +0 -1
  85. package/dist/attempt-channel.js +0 -138
  86. package/dist/attempt-channel.js.map +0 -1
  87. package/dist/index.d.ts +0 -24
  88. package/dist/index.d.ts.map +0 -1
  89. package/dist/index.js +0 -24
  90. package/dist/index.js.map +0 -1
  91. package/dist/lifecycle/attempt-failure.d.ts +0 -51
  92. package/dist/lifecycle/attempt-failure.d.ts.map +0 -1
  93. package/dist/lifecycle/attempt-failure.js +0 -45
  94. package/dist/lifecycle/attempt-failure.js.map +0 -1
  95. package/dist/lifecycle/attempt.d.ts +0 -61
  96. package/dist/lifecycle/attempt.d.ts.map +0 -1
  97. package/dist/lifecycle/attempt.js +0 -52
  98. package/dist/lifecycle/attempt.js.map +0 -1
  99. package/dist/lifecycle/event.d.ts.map +0 -1
  100. package/dist/lifecycle/event.js +0 -26
  101. package/dist/lifecycle/event.js.map +0 -1
  102. package/dist/lifecycle/item.d.ts +0 -11
  103. package/dist/lifecycle/item.d.ts.map +0 -1
  104. package/dist/lifecycle/item.js +0 -9
  105. package/dist/lifecycle/item.js.map +0 -1
  106. package/dist/lifecycle/loop.d.ts +0 -17
  107. package/dist/lifecycle/loop.d.ts.map +0 -1
  108. package/dist/lifecycle/loop.js +0 -15
  109. package/dist/lifecycle/loop.js.map +0 -1
  110. package/dist/lifecycle/run-state.d.ts +0 -133
  111. package/dist/lifecycle/run-state.d.ts.map +0 -1
  112. package/dist/lifecycle/run-state.js +0 -126
  113. package/dist/lifecycle/run-state.js.map +0 -1
  114. package/dist/lifecycle/run.d.ts +0 -22
  115. package/dist/lifecycle/run.d.ts.map +0 -1
  116. package/dist/lifecycle/run.js +0 -22
  117. package/dist/lifecycle/run.js.map +0 -1
  118. package/dist/lifecycle/step.d.ts +0 -23
  119. package/dist/lifecycle/step.d.ts.map +0 -1
  120. package/dist/lifecycle/step.js +0 -21
  121. package/dist/lifecycle/step.js.map +0 -1
  122. package/dist/step-result.d.ts.map +0 -1
  123. package/dist/step-result.js.map +0 -1
@@ -1,134 +0,0 @@
1
- import { Result, Schema, type Effect } from "effect";
2
- import { Agent } from "./agent.ts";
3
- import { AttemptId } from "./lifecycle/attempt.ts";
4
- import { AttemptFailure } from "./lifecycle/attempt-failure.ts";
5
- import { StepResult } from "./step-result.ts";
6
- export declare const PROTOCOL_VERSION: 3;
7
- /**
8
- * Value object: monotonically increasing per-Attempt, per-direction message
9
- * sequence. Distinct from the engine's transcript sequence, which is the
10
- * global append order of the persisted transcript rows.
11
- */
12
- export declare const Sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
13
- export type Sequence = typeof Sequence.Type;
14
- /**
15
- * Run-host-relative: `inbound` frames travel orchestrator → run host (Start,
16
- * Steer, Interrupt); `outbound` frames travel run host → orchestrator.
17
- */
18
- export declare const DIRECTIONS: readonly ["inbound", "outbound"];
19
- export declare const Direction: Schema.Literals<readonly ["inbound", "outbound"]>;
20
- export type Direction = typeof Direction.Type;
21
- /** Value object: the rendered task text the run host gives the agent. */
22
- export declare const Task: Schema.brand<Schema.String, "AttemptTask">;
23
- export type Task = typeof Task.Type;
24
- declare const RunSpec_base: Schema.Class<RunSpec, Schema.Struct<{
25
- readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
26
- readonly repository: Schema.brand<Schema.String, "RepoName">;
27
- readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
28
- readonly baseCommit: Schema.brand<Schema.String, "CommitSha">;
29
- readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
30
- readonly task: Schema.brand<Schema.String, "AttemptTask">;
31
- readonly agent: typeof Agent;
32
- readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
33
- }>, {}>;
34
- /** Secret-free launch input. Worker credentials are deliberately absent. */
35
- export declare class RunSpec extends RunSpec_base {
36
- }
37
- declare const Started_base: Schema.Class<Started, Schema.TaggedStruct<"Started", {
38
- readonly parentModel: Schema.brand<Schema.String, "ModelId">;
39
- }>, {}>;
40
- /**
41
- * The parent model the SDK actually selected at launch — the one effective
42
- * value the run host knows that the roster may not declare. Child sessions
43
- * spawn later; their effective brains ride the transcript's `SessionStarted`
44
- * events (declare by roster, observe by record).
45
- */
46
- export declare class Started extends Started_base {
47
- }
48
- declare const SessionEvent_base: Schema.Class<SessionEvent, Schema.TaggedStruct<"SessionEvent", {
49
- readonly event: Schema.Union<readonly [typeof import("./agent.ts").SessionStarted, typeof import("./agent.ts").TextOutput, typeof import("./agent.ts").ToolStarted, typeof import("./agent.ts").ToolFinished, typeof import("./agent.ts").PoolRateLimitsUpdated, typeof import("./agent.ts").SessionFinished]>;
50
- }>, {}>;
51
- /** One normalized parent or child session event, persisted in the Attempt transcript. */
52
- export declare class SessionEvent extends SessionEvent_base {
53
- }
54
- declare const Final_base: Schema.Class<Final, Schema.TaggedStruct<"Final", {
55
- readonly result: typeof StepResult;
56
- }>, {}>;
57
- export declare class Final extends Final_base {
58
- }
59
- declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
60
- readonly failure: Schema.Union<readonly [typeof import("./lifecycle/attempt-failure.ts").InfraFailure, typeof import("./lifecycle/attempt-failure.ts").AgentFailure, typeof import("./lifecycle/attempt-failure.ts").RunawayFailure]>;
61
- }>, {}>;
62
- export declare class Failed extends Failed_base {
63
- }
64
- declare const Interrupted_base: Schema.Class<Interrupted, Schema.TaggedStruct<"Interrupted", {}>, {}>;
65
- /** Terminal acknowledgement that the run host stopped on an Interrupt frame. */
66
- export declare class Interrupted extends Interrupted_base {
67
- }
68
- export declare const OutboundPayload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted]>;
69
- export type OutboundPayload = typeof OutboundPayload.Type;
70
- declare const Steer_base: Schema.Class<Steer, Schema.TaggedStruct<"Steer", {
71
- readonly message: Schema.NonEmptyString;
72
- }>, {}>;
73
- export declare class Steer extends Steer_base {
74
- }
75
- declare const Interrupt_base: Schema.Class<Interrupt, Schema.TaggedStruct<"Interrupt", {}>, {}>;
76
- export declare class Interrupt extends Interrupt_base {
77
- }
78
- export declare const InboundPayload: Schema.Union<readonly [typeof Steer, typeof Interrupt]>;
79
- export type InboundPayload = typeof InboundPayload.Type;
80
- declare const OutboundEnvelope_base: Schema.Class<OutboundEnvelope, Schema.TaggedStruct<"OutboundEnvelope", {
81
- readonly version: Schema.Literal<3>;
82
- readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
83
- readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
84
- readonly sentAt: Schema.DateTimeUtcFromString;
85
- readonly payload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted]>;
86
- }>, {}>;
87
- export declare class OutboundEnvelope extends OutboundEnvelope_base {
88
- }
89
- declare const InboundEnvelope_base: Schema.Class<InboundEnvelope, Schema.TaggedStruct<"InboundEnvelope", {
90
- readonly version: Schema.Literal<3>;
91
- readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
92
- readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
93
- readonly sentAt: Schema.DateTimeUtcFromString;
94
- readonly payload: Schema.Union<readonly [typeof Steer, typeof Interrupt]>;
95
- }>, {}>;
96
- export declare class InboundEnvelope extends InboundEnvelope_base {
97
- }
98
- export declare const Envelope: Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>;
99
- export type Envelope = typeof Envelope.Type;
100
- declare const Start_base: Schema.Class<Start, Schema.TaggedStruct<"Start", {
101
- readonly version: Schema.Literal<3>;
102
- readonly spec: typeof RunSpec;
103
- }>, {}>;
104
- /** First framed stdin message; later frames are inbound envelopes. */
105
- export declare class Start extends Start_base {
106
- }
107
- export declare const InputFrame: Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>;
108
- export type InputFrame = typeof InputFrame.Type;
109
- export declare const EnvelopeFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>>;
110
- export declare const InputFrameFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>>;
111
- export declare const OutboundEnvelopeFromJson: Schema.fromJsonString<typeof OutboundEnvelope>;
112
- /** The transcript append seam a channel consumer persists envelopes through. */
113
- export interface Sink {
114
- readonly append: (direction: Direction, envelope: Envelope) => Effect.Effect<void, AttemptFailure>;
115
- }
116
- /** How far one outbound channel has legally progressed. */
117
- export interface Progress {
118
- readonly state: "AwaitingStarted" | "Running" | "Terminal";
119
- readonly nextSequence: number;
120
- }
121
- export declare const initialProgress: Progress;
122
- /** One protocol violation, described for the infra-failure that reports it. */
123
- export interface Violation {
124
- readonly message: string;
125
- readonly detail: string;
126
- }
127
- /**
128
- * Pure outbound protocol reducer: admits one envelope
129
- * against the progress so far, or names the violation. Owning it here keeps
130
- * every transport adapter folding the same state machine.
131
- */
132
- export declare const admit: (progress: Progress, attemptId: AttemptId, envelope: OutboundEnvelope) => Result.Result<Progress, Violation>;
133
- export {};
134
- //# sourceMappingURL=attempt-channel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt-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,EAAqC,KAAK,EAAW,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C;;;;GAIG;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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0C,CAAC;AAEhF,gFAAgF;AAChF,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"}
@@ -1,138 +0,0 @@
1
- import { Result, Schema } from "effect";
2
- import { SessionEvent as AgentSessionEvent, Agent, ModelId } from "./agent.js";
3
- import { AttemptId } from "./lifecycle/attempt.js";
4
- import { AttemptFailure } from "./lifecycle/attempt-failure.js";
5
- import { CommitSha, Name as RepositoryName, Revision } from "./repository.js";
6
- import { StepResult } from "./step-result.js";
7
- export const PROTOCOL_VERSION = 3;
8
- /**
9
- * Value object: monotonically increasing per-Attempt, per-direction message
10
- * sequence. Distinct from the engine's transcript sequence, which is the
11
- * global append order of the persisted transcript rows.
12
- */
13
- export const Sequence = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("AttemptChannelSequence"));
14
- /**
15
- * Run-host-relative: `inbound` frames travel orchestrator → run host (Start,
16
- * Steer, Interrupt); `outbound` frames travel run host → orchestrator.
17
- */
18
- export const DIRECTIONS = ["inbound", "outbound"];
19
- export const Direction = Schema.Literals(DIRECTIONS);
20
- /** Value object: the rendered task text the run host gives the agent. */
21
- export const Task = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected non-blank task text" })).pipe(Schema.brand("AttemptTask"));
22
- /** Secret-free launch input. Worker credentials are deliberately absent. */
23
- export class RunSpec extends Schema.Class("AttemptChannel/RunSpec")({
24
- attemptId: AttemptId,
25
- repository: RepositoryName,
26
- revision: Revision,
27
- baseCommit: CommitSha,
28
- payload: Schema.Json,
29
- task: Task,
30
- agent: Agent,
31
- parentModel: Schema.OptionFromNullOr(ModelId),
32
- }) {
33
- }
34
- /**
35
- * The parent model the SDK actually selected at launch — the one effective
36
- * value the run host knows that the roster may not declare. Child sessions
37
- * spawn later; their effective brains ride the transcript's `SessionStarted`
38
- * events (declare by roster, observe by record).
39
- */
40
- export class Started extends Schema.TaggedClass("AttemptChannel/Started")("Started", {
41
- parentModel: ModelId,
42
- }) {
43
- }
44
- /** One normalized parent or child session event, persisted in the Attempt transcript. */
45
- export class SessionEvent extends Schema.TaggedClass("AttemptChannel/SessionEvent")("SessionEvent", { event: AgentSessionEvent }) {
46
- }
47
- export class Final extends Schema.TaggedClass("AttemptChannel/Final")("Final", {
48
- result: StepResult,
49
- }) {
50
- }
51
- export class Failed extends Schema.TaggedClass("AttemptChannel/Failed")("Failed", {
52
- failure: AttemptFailure,
53
- }) {
54
- }
55
- /** Terminal acknowledgement that the run host stopped on an Interrupt frame. */
56
- export class Interrupted extends Schema.TaggedClass("AttemptChannel/Interrupted")("Interrupted", {}) {
57
- }
58
- export const OutboundPayload = Schema.Union([Started, SessionEvent, Final, Failed, Interrupted]);
59
- export class Steer extends Schema.TaggedClass("AttemptChannel/Steer")("Steer", {
60
- message: Schema.NonEmptyString,
61
- }) {
62
- }
63
- export class Interrupt extends Schema.TaggedClass("AttemptChannel/Interrupt")("Interrupt", {}) {
64
- }
65
- export const InboundPayload = Schema.Union([Steer, Interrupt]);
66
- const EnvelopeFields = {
67
- version: Schema.Literal(PROTOCOL_VERSION),
68
- attemptId: AttemptId,
69
- sequence: Sequence,
70
- sentAt: Schema.DateTimeUtcFromString,
71
- };
72
- export class OutboundEnvelope extends Schema.TaggedClass("AttemptChannel/OutboundEnvelope")("OutboundEnvelope", {
73
- ...EnvelopeFields,
74
- payload: OutboundPayload,
75
- }) {
76
- }
77
- export class InboundEnvelope extends Schema.TaggedClass("AttemptChannel/InboundEnvelope")("InboundEnvelope", {
78
- ...EnvelopeFields,
79
- payload: InboundPayload,
80
- }) {
81
- }
82
- export const Envelope = Schema.Union([OutboundEnvelope, InboundEnvelope]);
83
- /** First framed stdin message; later frames are inbound envelopes. */
84
- export class Start extends Schema.TaggedClass("AttemptChannel/Start")("Start", {
85
- version: Schema.Literal(PROTOCOL_VERSION),
86
- spec: RunSpec,
87
- }) {
88
- }
89
- export const InputFrame = Schema.Union([Start, InboundEnvelope]);
90
- export const EnvelopeFromJson = Schema.fromJsonString(Envelope);
91
- export const InputFrameFromJson = Schema.fromJsonString(InputFrame);
92
- export const OutboundEnvelopeFromJson = Schema.fromJsonString(OutboundEnvelope);
93
- export const initialProgress = { state: "AwaitingStarted", nextSequence: 1 };
94
- const isTerminal = (payload) => payload._tag === "Final" || payload._tag === "Failed" || payload._tag === "Interrupted";
95
- /**
96
- * Pure outbound protocol reducer: admits one envelope
97
- * against the progress so far, or names the violation. Owning it here keeps
98
- * every transport adapter folding the same state machine.
99
- */
100
- export const admit = (progress, attemptId, envelope) => {
101
- if (envelope.attemptId !== attemptId) {
102
- return Result.fail({
103
- message: "The run host emitted a frame for another Attempt",
104
- detail: String(envelope.attemptId),
105
- });
106
- }
107
- if (envelope.sequence !== progress.nextSequence) {
108
- return Result.fail({
109
- message: "The run host emitted a non-contiguous sequence",
110
- detail: `expected ${progress.nextSequence}, received ${envelope.sequence}`,
111
- });
112
- }
113
- if (progress.state === "Terminal") {
114
- return Result.fail({
115
- message: "The run host emitted an envelope after its terminal envelope",
116
- detail: envelope.payload._tag,
117
- });
118
- }
119
- if (progress.state === "AwaitingStarted" &&
120
- envelope.payload._tag !== "Started" &&
121
- envelope.payload._tag !== "Failed") {
122
- return Result.fail({
123
- message: "The run host did not begin with a Started or Failed envelope",
124
- detail: envelope.payload._tag,
125
- });
126
- }
127
- if (progress.state === "Running" && envelope.payload._tag === "Started") {
128
- return Result.fail({
129
- message: "The run host emitted more than one Started envelope",
130
- detail: "duplicate Started envelope",
131
- });
132
- }
133
- return Result.succeed({
134
- state: isTerminal(envelope.payload) ? "Terminal" : "Running",
135
- nextSequence: progress.nextSequence + 1,
136
- });
137
- };
138
- //# sourceMappingURL=attempt-channel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt-channel.js","sourceRoot":"","sources":["../src/attempt-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC7E,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CACvC,CAAC;AAGF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,UAAU,CAAU,CAAC;AAC3D,MAAM,CAAC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AAQ,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"}
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * @usine/core — domain model for usine (ADR 0002, ADR 0013).
3
- *
4
- * `lifecycle/` is the run-lifecycle cluster: how one piece of work moves
5
- * through the engine — a deduplicated Event opens a Run, the Run's named Step
6
- * is tried as Attempts, and the state machine closes it. Entities are the
7
- * ledger rows (Event, Run, Step, Attempt); everything else is value objects,
8
- * typed errors, and pure derivers — each module docblock names its kind.
9
- */
10
- export * as Instance from "./instance.ts";
11
- export * as Agent from "./agent.ts";
12
- export * as Repository from "./repository.ts";
13
- export * as AttemptChannel from "./attempt-channel.ts";
14
- export * as StepResult from "./step-result.ts";
15
- export * as Worker from "./worker.ts";
16
- export * as Attempt from "./lifecycle/attempt.ts";
17
- export * as AttemptFailure from "./lifecycle/attempt-failure.ts";
18
- export * as Event from "./lifecycle/event.ts";
19
- export * as Item from "./lifecycle/item.ts";
20
- export * as Loop from "./lifecycle/loop.ts";
21
- export * as Run from "./lifecycle/run.ts";
22
- export * as RunState from "./lifecycle/run-state.ts";
23
- export * as Step from "./lifecycle/step.ts";
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC"}
package/dist/index.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * @usine/core — domain model for usine (ADR 0002, ADR 0013).
3
- *
4
- * `lifecycle/` is the run-lifecycle cluster: how one piece of work moves
5
- * through the engine — a deduplicated Event opens a Run, the Run's named Step
6
- * is tried as Attempts, and the state machine closes it. Entities are the
7
- * ledger rows (Event, Run, Step, Attempt); everything else is value objects,
8
- * typed errors, and pure derivers — each module docblock names its kind.
9
- */
10
- export * as Instance from "./instance.js";
11
- export * as Agent from "./agent.js";
12
- export * as Repository from "./repository.js";
13
- export * as AttemptChannel from "./attempt-channel.js";
14
- export * as StepResult from "./step-result.js";
15
- export * as Worker from "./worker.js";
16
- export * as Attempt from "./lifecycle/attempt.js";
17
- export * as AttemptFailure from "./lifecycle/attempt-failure.js";
18
- export * as Event from "./lifecycle/event.js";
19
- export * as Item from "./lifecycle/item.js";
20
- export * as Loop from "./lifecycle/loop.js";
21
- export * as Run from "./lifecycle/run.js";
22
- export * as RunState from "./lifecycle/run-state.js";
23
- export * as Step from "./lifecycle/step.js";
24
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC"}
@@ -1,51 +0,0 @@
1
- /**
2
- * Why an attempt failed — the typed taxonomy the retry law dispatches on
3
- * (ADR 0002, ADR 0013). Typed errors; three classes, deliberately distinct:
4
- *
5
- * - `InfraFailure` — the only class the engine may retry on its own, capped.
6
- * - `AgentFailure` — always waits for the operator.
7
- * - `RunawayFailure` — never auto-retried; only the operator restarts it.
8
- */
9
- import { Schema } from "effect";
10
- declare const InfraFailure_base: Schema.Class<InfraFailure, Schema.TaggedStruct<"InfraFailure", {
11
- readonly message: Schema.String;
12
- readonly cause: Schema.Defect;
13
- }>, import("effect/Cause").YieldableError>;
14
- /**
15
- * Typed error: infrastructure failed around the agent — worker unreachable,
16
- * checkout failed, run host died. Auto-retryable, capped.
17
- */
18
- export declare class InfraFailure extends InfraFailure_base {
19
- }
20
- declare const AgentFailure_base: Schema.Class<AgentFailure, Schema.TaggedStruct<"AgentFailure", {
21
- readonly message: Schema.String;
22
- }>, import("effect/Cause").YieldableError>;
23
- /**
24
- * Typed error: the agent ran and failed the work itself. Never auto-retried —
25
- * an agent that failed once would fail the same way again; the operator
26
- * decides what changes before the next attempt.
27
- */
28
- export declare class AgentFailure extends AgentFailure_base {
29
- }
30
- /** Which per-attempt ceiling the runaway guard tripped. */
31
- export declare const RunawayCeiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
32
- export type RunawayCeiling = typeof RunawayCeiling.Type;
33
- declare const RunawayFailure_base: Schema.Class<RunawayFailure, Schema.TaggedStruct<"RunawayFailure", {
34
- readonly ceiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
35
- }>, import("effect/Cause").YieldableError>;
36
- /**
37
- * Typed error: the runaway guard interrupted an attempt burning without
38
- * progress. Its own class so auto-retry can never touch it (ADR 0013).
39
- */
40
- export declare class RunawayFailure extends RunawayFailure_base {
41
- }
42
- export declare const AttemptFailure: Schema.Union<readonly [typeof InfraFailure, typeof AgentFailure, typeof RunawayFailure]>;
43
- export type AttemptFailure = typeof AttemptFailure.Type;
44
- /**
45
- * The class half of the auto-retry law (ADR 0002): only infra failures are
46
- * ever auto-retried. This deliberately ignores the attempt cap — the full
47
- * capped decision is `Attempt.shouldAutoRetry`.
48
- */
49
- export declare const isAutoRetryable: <I>(input: I) => input is I & InfraFailure;
50
- export {};
51
- //# sourceMappingURL=attempt-failure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt-failure.d.ts","sourceRoot":"","sources":["../../src/lifecycle/attempt-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAEhC;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAMjC;CAAG;;;;AAEJ;;;;GAIG;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;;;GAGG;AACH,qBAAa,cAAe,SAAQ,mBAIlC;CAAG;AAEL,eAAO,MAAM,cAAc,0FAA6D,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,4CAA0B,CAAC"}
@@ -1,45 +0,0 @@
1
- /**
2
- * Why an attempt failed — the typed taxonomy the retry law dispatches on
3
- * (ADR 0002, ADR 0013). Typed errors; three classes, deliberately distinct:
4
- *
5
- * - `InfraFailure` — the only class the engine may retry on its own, capped.
6
- * - `AgentFailure` — always waits for the operator.
7
- * - `RunawayFailure` — never auto-retried; only the operator restarts it.
8
- */
9
- import { Schema } from "effect";
10
- /**
11
- * Typed error: infrastructure failed around the agent — worker unreachable,
12
- * checkout failed, run host died. Auto-retryable, capped.
13
- */
14
- export class InfraFailure extends Schema.TaggedError("AttemptFailure/InfraFailure")("InfraFailure", {
15
- message: Schema.String,
16
- cause: Schema.Defect(),
17
- }) {
18
- }
19
- /**
20
- * Typed error: the agent ran and failed the work itself. Never auto-retried —
21
- * an agent that failed once would fail the same way again; the operator
22
- * decides what changes before the next attempt.
23
- */
24
- export class AgentFailure extends Schema.TaggedError("AttemptFailure/AgentFailure")("AgentFailure", {
25
- message: Schema.String,
26
- }) {
27
- }
28
- /** Which per-attempt ceiling the runaway guard tripped. */
29
- export const RunawayCeiling = Schema.Literals(["wall-clock", "tokens"]);
30
- /**
31
- * Typed error: the runaway guard interrupted an attempt burning without
32
- * progress. Its own class so auto-retry can never touch it (ADR 0013).
33
- */
34
- export class RunawayFailure extends Schema.TaggedError("AttemptFailure/RunawayFailure")("RunawayFailure", {
35
- ceiling: RunawayCeiling,
36
- }) {
37
- }
38
- export const AttemptFailure = Schema.Union([InfraFailure, AgentFailure, RunawayFailure]);
39
- /**
40
- * The class half of the auto-retry law (ADR 0002): only infra failures are
41
- * ever auto-retried. This deliberately ignores the attempt cap — the full
42
- * capped decision is `Attempt.shouldAutoRetry`.
43
- */
44
- export const isAutoRetryable = Schema.is(InfraFailure);
45
- //# sourceMappingURL=attempt-failure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt-failure.js","sourceRoot":"","sources":["../../src/lifecycle/attempt-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;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;;;;GAIG;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;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,CACpD,+BAA+B,CAChC,CAAC,gBAAgB,EAAE;IAClB,OAAO,EAAE,cAAc;CACxB,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AAGzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC"}
@@ -1,61 +0,0 @@
1
- import { Schema } from "effect";
2
- import { AttemptFailure } from "./attempt-failure.ts";
3
- import { BrainSpec } from "../agent.ts";
4
- /**
5
- * Value object (branded id): identity of one Attempt.
6
- */
7
- export declare const AttemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
8
- export type AttemptId = typeof AttemptId.Type;
9
- /**
10
- * Value object: 1-based position of a try under its step — retries are
11
- * attempt N+1 under the same step, never new runs. Also the unit of the
12
- * auto-retry cap: a cap of 3 means at most three attempts in total.
13
- */
14
- export declare const AttemptNumber: Schema.brand<Schema.Int, "AttemptNumber">;
15
- export type AttemptNumber = typeof AttemptNumber.Type;
16
- declare const Succeeded_base: Schema.Class<Succeeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
17
- /** Outcome — value object: the attempt finished; the step result is stored on the Step. */
18
- export declare class Succeeded extends Succeeded_base {
19
- }
20
- declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
21
- readonly failure: Schema.Union<readonly [typeof import("./attempt-failure.ts").InfraFailure, typeof import("./attempt-failure.ts").AgentFailure, typeof import("./attempt-failure.ts").RunawayFailure]>;
22
- }>, {}>;
23
- /** Outcome — value object: the attempt failed, with the typed failure that closed it. */
24
- export declare class Failed extends Failed_base {
25
- }
26
- declare const Canceled_base: Schema.Class<Canceled, Schema.TaggedStruct<"Canceled", {}>, {}>;
27
- /** Outcome — value object: the operator canceled the Run during this Attempt. */
28
- export declare class Canceled extends Canceled_base {
29
- }
30
- export declare const Outcome: Schema.Union<readonly [typeof Succeeded, typeof Failed, typeof Canceled]>;
31
- export type Outcome = typeof Outcome.Type;
32
- declare const Attempt_base: Schema.Class<Attempt, Schema.Struct<{
33
- readonly id: Schema.brand<Schema.NonEmptyString, "AttemptId">;
34
- readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
35
- readonly stepName: Schema.brand<Schema.NonEmptyString, "StepName">;
36
- readonly worker: Schema.brand<Schema.String, "WorkerName">;
37
- readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
38
- readonly brain: typeof BrainSpec;
39
- readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
40
- readonly startedAt: Schema.DateTimeUtc;
41
- readonly outcome: Schema.Option<Schema.Union<readonly [typeof Succeeded, typeof Failed, typeof Canceled]>>;
42
- }>, {}>;
43
- /**
44
- * Entity — ledger row: one try of a step on a worker. `outcome` is none while
45
- * the attempt is in flight.
46
- */
47
- export declare class Attempt extends Attempt_base {
48
- }
49
- /**
50
- * Deriver — the full auto-retry law over one failed attempt (ADR 0002,
51
- * ADR 0013): the class rule (`AttemptFailure.isAutoRetryable` — infra only)
52
- * capped by the attempt count. `maxAutoAttempts` counts total attempts:
53
- * attempt N may auto-retry into attempt N+1 only while N < maxAutoAttempts.
54
- */
55
- export declare const shouldAutoRetry: (options: {
56
- readonly failure: AttemptFailure;
57
- readonly number: AttemptNumber;
58
- readonly maxAutoAttempts: AttemptNumber;
59
- }) => boolean;
60
- export {};
61
- //# sourceMappingURL=attempt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/lifecycle/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAmB,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,SAAS,EAAW,MAAM,aAAa,CAAC;AAGjD;;GAEG;AACH,eAAO,MAAM,SAAS,kDAAwD,CAAC;AAC/E,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,2CAEzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;;AAEtD,2FAA2F;AAC3F,qBAAa,SAAU,SAAQ,cAG9B;CAAG;;;;AAEJ,yFAAyF;AACzF,qBAAa,MAAO,SAAQ,WAE1B;CAAG;;AAEL,iFAAiF;AACjF,qBAAa,QAAS,SAAQ,aAG7B;CAAG;AAEJ,eAAO,MAAM,OAAO,2EAA8C,CAAC;AACnE,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;AAE1C;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,YAU3B;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,eAAe,YAAa;IACvC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;CACzC,KAAG,OAAuF,CAAC"}
@@ -1,52 +0,0 @@
1
- import { Schema } from "effect";
2
- import { AttemptFailure, isAutoRetryable } from "./attempt-failure.js";
3
- import { RunId } from "./run.js";
4
- import { StepName } from "./step.js";
5
- import { BrainSpec, ModelId } from "../agent.js";
6
- import { Name as WorkerName } from "../worker.js";
7
- /**
8
- * Value object (branded id): identity of one Attempt.
9
- */
10
- export const AttemptId = Schema.NonEmptyString.pipe(Schema.brand("AttemptId"));
11
- /**
12
- * Value object: 1-based position of a try under its step — retries are
13
- * attempt N+1 under the same step, never new runs. Also the unit of the
14
- * auto-retry cap: a cap of 3 means at most three attempts in total.
15
- */
16
- export const AttemptNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("AttemptNumber"));
17
- /** Outcome — value object: the attempt finished; the step result is stored on the Step. */
18
- export class Succeeded extends Schema.TaggedClass("AttemptOutcome/Succeeded")("Succeeded", {}) {
19
- }
20
- /** Outcome — value object: the attempt failed, with the typed failure that closed it. */
21
- export class Failed extends Schema.TaggedClass("AttemptOutcome/Failed")("Failed", {
22
- failure: AttemptFailure,
23
- }) {
24
- }
25
- /** Outcome — value object: the operator canceled the Run during this Attempt. */
26
- export class Canceled extends Schema.TaggedClass("AttemptOutcome/Canceled")("Canceled", {}) {
27
- }
28
- export const Outcome = Schema.Union([Succeeded, Failed, Canceled]);
29
- /**
30
- * Entity — ledger row: one try of a step on a worker. `outcome` is none while
31
- * the attempt is in flight.
32
- */
33
- export class Attempt extends Schema.Class("Attempt")({
34
- id: AttemptId,
35
- runId: RunId,
36
- stepName: StepName,
37
- worker: WorkerName,
38
- number: AttemptNumber,
39
- brain: BrainSpec,
40
- parentModel: Schema.OptionFromNullOr(ModelId),
41
- startedAt: Schema.DateTimeUtc,
42
- outcome: Schema.Option(Outcome),
43
- }) {
44
- }
45
- /**
46
- * Deriver — the full auto-retry law over one failed attempt (ADR 0002,
47
- * ADR 0013): the class rule (`AttemptFailure.isAutoRetryable` — infra only)
48
- * capped by the attempt count. `maxAutoAttempts` counts total attempts:
49
- * attempt N may auto-retry into attempt N+1 only while N < maxAutoAttempts.
50
- */
51
- export const shouldAutoRetry = (options) => isAutoRetryable(options.failure) && options.number < options.maxAutoAttempts;
52
- //# sourceMappingURL=attempt.js.map
@@ -1 +0,0 @@
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AC;AAGnE;;;GAGG;AACH,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,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC,WAAW;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;CAChC,CAAC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAI/B,EAAW,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/lifecycle/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAC3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;;AAE5C;;;;;;GAMG;AACH,qBAAa,KAAM,SAAQ,UAKzB;CAAG"}
@@ -1,26 +0,0 @@
1
- import { Schema } from "effect";
2
- /**
3
- * Value object (branded id): identity of one Event in the ledger.
4
- */
5
- export const EventId = Schema.NonEmptyString.pipe(Schema.brand("EventId"));
6
- /**
7
- * Value object: the engine-derived, never-expiring idempotency key — timestamps aside, the
8
- * same watched state is the same Event, forever. Derived per trigger type,
9
- * never authored in a loop file (ADR 0002).
10
- */
11
- export const DedupKey = Schema.NonEmptyString.pipe(Schema.brand("DedupKey"));
12
- /**
13
- * Entity — ledger row: one deduplicated fact the engine may react to — a trigger matching watched
14
- * state, or an operator approval. An Event owns at most one open Run, ever.
15
- *
16
- * The payload is the stream's payload slice — GitHub's own shapes, kept opaque
17
- * here; the expression and loop-file blocks range over it.
18
- */
19
- export class Event extends Schema.Class("Event")({
20
- id: EventId,
21
- dedupKey: DedupKey,
22
- payload: Schema.Json,
23
- receivedAt: Schema.DateTimeUtc,
24
- }) {
25
- }
26
- //# sourceMappingURL=event.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/lifecycle/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAG3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;;;GAMG;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"}
@@ -1,11 +0,0 @@
1
- import { Schema } from "effect";
2
- /**
3
- * Value object: stable identity of one piece of software-work state inside a
4
- * loop. Several content-distinct Events may concern the same Item.
5
- */
6
- export declare const ItemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
7
- export type ItemKey = typeof ItemKey.Type;
8
- /** Positive repository-local number for an issue-like Item. */
9
- export declare const Number: Schema.brand<Schema.Int, "ItemNumber">;
10
- export type Number = typeof Number.Type;
11
- //# sourceMappingURL=item.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/lifecycle/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAC3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,+DAA+D;AAC/D,eAAO,MAAM,MAAM,wCAElB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC"}