@usine/core 0.3.0 → 0.5.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 (107) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +43 -18
  3. package/dist/agent/agent.d.ts +12 -8
  4. package/dist/agent/agent.d.ts.map +1 -1
  5. package/dist/agent/agent.js +14 -10
  6. package/dist/agent/agent.js.map +1 -1
  7. package/dist/agent/brain.d.ts +2 -6
  8. package/dist/agent/brain.d.ts.map +1 -1
  9. package/dist/agent/brain.js +3 -7
  10. package/dist/agent/brain.js.map +1 -1
  11. package/dist/agent/capability.d.ts +4 -4
  12. package/dist/agent/capability.d.ts.map +1 -1
  13. package/dist/agent/capability.js +4 -4
  14. package/dist/agent/capability.js.map +1 -1
  15. package/dist/agent/session.d.ts +90 -28
  16. package/dist/agent/session.d.ts.map +1 -1
  17. package/dist/agent/session.js +103 -28
  18. package/dist/agent/session.js.map +1 -1
  19. package/dist/attempt/attempt.d.ts +92 -12
  20. package/dist/attempt/attempt.d.ts.map +1 -1
  21. package/dist/attempt/attempt.js +114 -13
  22. package/dist/attempt/attempt.js.map +1 -1
  23. package/dist/attempt/channel.d.ts +91 -51
  24. package/dist/attempt/channel.d.ts.map +1 -1
  25. package/dist/attempt/channel.js +74 -45
  26. package/dist/attempt/channel.js.map +1 -1
  27. package/dist/attempt/failure.d.ts +27 -14
  28. package/dist/attempt/failure.d.ts.map +1 -1
  29. package/dist/attempt/failure.js +27 -14
  30. package/dist/attempt/failure.js.map +1 -1
  31. package/dist/attempt/outcome.d.ts +3 -5
  32. package/dist/attempt/outcome.d.ts.map +1 -1
  33. package/dist/attempt/outcome.js +2 -4
  34. package/dist/attempt/outcome.js.map +1 -1
  35. package/dist/attempt/salvage.d.ts +77 -0
  36. package/dist/attempt/salvage.d.ts.map +1 -0
  37. package/dist/attempt/salvage.js +49 -0
  38. package/dist/attempt/salvage.js.map +1 -0
  39. package/dist/attempt/start.d.ts +35 -0
  40. package/dist/attempt/start.d.ts.map +1 -0
  41. package/dist/attempt/start.js +30 -0
  42. package/dist/attempt/start.js.map +1 -0
  43. package/dist/closed-struct.d.ts +7 -0
  44. package/dist/closed-struct.d.ts.map +1 -0
  45. package/dist/closed-struct.js +12 -0
  46. package/dist/closed-struct.js.map +1 -0
  47. package/dist/cycle-budget.d.ts +7 -8
  48. package/dist/cycle-budget.d.ts.map +1 -1
  49. package/dist/cycle-budget.js +16 -20
  50. package/dist/cycle-budget.js.map +1 -1
  51. package/dist/event.d.ts +4 -8
  52. package/dist/event.d.ts.map +1 -1
  53. package/dist/event.js +4 -8
  54. package/dist/event.js.map +1 -1
  55. package/dist/instance.d.ts +7 -1
  56. package/dist/instance.d.ts.map +1 -1
  57. package/dist/instance.js +6 -1
  58. package/dist/instance.js.map +1 -1
  59. package/dist/item.d.ts +1 -2
  60. package/dist/item.d.ts.map +1 -1
  61. package/dist/item.js +1 -2
  62. package/dist/item.js.map +1 -1
  63. package/dist/loop.d.ts +10 -2
  64. package/dist/loop.d.ts.map +1 -1
  65. package/dist/loop.js +9 -2
  66. package/dist/loop.js.map +1 -1
  67. package/dist/operator.d.ts +8 -0
  68. package/dist/operator.d.ts.map +1 -0
  69. package/dist/operator.js +9 -0
  70. package/dist/operator.js.map +1 -0
  71. package/dist/repository.d.ts +6 -8
  72. package/dist/repository.d.ts.map +1 -1
  73. package/dist/repository.js +8 -10
  74. package/dist/repository.js.map +1 -1
  75. package/dist/run/again.d.ts +13 -0
  76. package/dist/run/again.d.ts.map +1 -0
  77. package/dist/run/again.js +14 -0
  78. package/dist/run/again.js.map +1 -0
  79. package/dist/run/approval.d.ts +27 -0
  80. package/dist/run/approval.d.ts.map +1 -0
  81. package/dist/run/approval.js +25 -0
  82. package/dist/run/approval.js.map +1 -0
  83. package/dist/run/run.d.ts +2 -2
  84. package/dist/run/run.d.ts.map +1 -1
  85. package/dist/run/run.js +2 -2
  86. package/dist/run/run.js.map +1 -1
  87. package/dist/run/state.d.ts +22 -31
  88. package/dist/run/state.d.ts.map +1 -1
  89. package/dist/run/state.js +23 -36
  90. package/dist/run/state.js.map +1 -1
  91. package/dist/step/harvest.d.ts +44 -0
  92. package/dist/step/harvest.d.ts.map +1 -0
  93. package/dist/step/harvest.js +368 -0
  94. package/dist/step/harvest.js.map +1 -0
  95. package/dist/step/result.d.ts +15 -4
  96. package/dist/step/result.d.ts.map +1 -1
  97. package/dist/step/result.js +14 -4
  98. package/dist/step/result.js.map +1 -1
  99. package/dist/step/step.d.ts +2 -8
  100. package/dist/step/step.d.ts.map +1 -1
  101. package/dist/step/step.js +2 -8
  102. package/dist/step/step.js.map +1 -1
  103. package/dist/worker.d.ts +160 -4
  104. package/dist/worker.d.ts.map +1 -1
  105. package/dist/worker.js +171 -4
  106. package/dist/worker.js.map +1 -1
  107. package/package.json +32 -7
@@ -1,54 +1,64 @@
1
- import { Effect, Option, Schema } from "effect";
1
+ import { Effect, Match, Option, Schema } from "effect";
2
+ import { GatewayCredentialKind } from "../worker.js";
2
3
  import { AgentName } from "./agent.js";
3
4
  import { BrainSpec } from "./brain.js";
4
- /** Identity usine assigns to a parent or child session within an Attempt. */
5
+ /** The usine ID of a parent or child session, distinct from `HarnessSessionId`. */
5
6
  export const AgentSessionId = Schema.NonEmptyString.pipe(Schema.brand("AgentSessionId"));
6
- /** A provider-reported count of input, output, and cached tokens. */
7
+ /** The sum of output tokens and uncached input tokens (new prompt text and cache writes), excluding cache reads. */
7
8
  export const TokenCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("TokenCount"));
8
9
  const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
9
- /** Maximum child sessions one Attempt may spawn over its lifetime, including sequential spawns. */
10
+ /** The maximum number of child sessions per Attempt, counting sequential spawns. */
10
11
  export const ChildSessionBudget = PositiveInt.pipe(Schema.brand("ChildSessionBudget"));
11
- /** The 1-based child spawn request number within an Attempt, including requests rejected by the budget. */
12
+ /** The 1-based number of a child spawn request in an Attempt, counting requests the budget rejected. */
12
13
  export const ChildSessionCount = PositiveInt.pipe(Schema.brand("ChildSessionCount"));
13
- /** The session coordinating an Attempt and delegating work to its coding children. */
14
14
  export class ParentSession extends Schema.TaggedClass("Agent/ParentSession")("ParentSession", {
15
15
  id: AgentSessionId,
16
16
  agent: AgentName,
17
17
  brain: BrainSpec,
18
18
  }) {
19
19
  }
20
- /** A coding session delegated by the Attempt's parent; children cannot delegate to further children. */
20
+ /** A session spawned by the parent session; a child can't spawn children. */
21
21
  export class ChildSession extends Schema.TaggedClass("Agent/ChildSession")("ChildSession", {
22
22
  id: AgentSessionId,
23
23
  parentId: AgentSessionId,
24
24
  agent: AgentName,
25
25
  brain: BrainSpec,
26
+ /**
27
+ * The credential kind the Gateway (ADR 0027) or a Cloudflare Worker's outbound handler used
28
+ * for the child's model requests, or `None` if the child used its harness's own login or the
29
+ * record is older.
30
+ */
31
+ gatewayCredential: Schema.OptionFromOptionalKey(GatewayCredentialKind).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
26
32
  }) {
27
33
  }
28
- /** A participant in an Attempt, with its role, Agent, and effective brain recorded. */
29
34
  export const AgentSession = Schema.Union([ParentSession, ChildSession]);
30
- /** The identity assigned by a harness to its saved conversation, distinct from usine's session id. */
35
+ /** The harness's ID for its saved conversation, distinct from `AgentSessionId`. */
31
36
  export const HarnessSessionId = Schema.NonEmptyString.pipe(Schema.brand("HarnessSessionId"));
32
- /** A saved harness conversation and the worker checkout from which it can be resumed. */
37
+ /** A saved harness conversation; `cwd` is the Worker checkout to resume it from. */
33
38
  export class HarnessSession extends Schema.Class("Agent/HarnessSession")({
34
39
  id: HarnessSessionId,
35
40
  cwd: Schema.NonEmptyString,
41
+ /**
42
+ * The directory the harness saved the conversation in, if the Attempt set one in place of the
43
+ * harness's default: Codex's `CODEX_HOME`. `None` for the default or an older record.
44
+ */
45
+ home: Schema.OptionFromOptionalKey(Schema.NonEmptyString).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
36
46
  }) {
37
47
  }
38
- /** Records the session identity and brain actually selected at launch. */
48
+ /** The session identity and the brain selected at launch. */
39
49
  export class SessionStarted extends Schema.TaggedClass("Agent/SessionStarted")("SessionStarted", {
40
50
  session: AgentSession,
41
- /** Absent for older transcripts and harnesses without a saved conversation. */
51
+ /** `None` for older transcripts and for harnesses without a saved conversation. */
42
52
  harnessSession: Schema.OptionFromOptionalKey(HarnessSession).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
43
53
  }) {
44
54
  }
45
- /** Completed assistant text emitted during the session, which may precede its final result. */
55
+ /** Completed assistant text, which can come before the final result. */
46
56
  export class TextOutput extends Schema.TaggedClass("Agent/TextOutput")("TextOutput", {
47
57
  session: AgentSession,
48
58
  text: Schema.NonEmptyString,
49
59
  }) {
50
60
  }
51
- /** A session began a tool call; `callId` pairs it with the corresponding result. */
61
+ /** The start of a tool call; `callId` matches the corresponding `ToolFinished`. */
52
62
  export class ToolStarted extends Schema.TaggedClass("Agent/ToolStarted")("ToolStarted", {
53
63
  session: AgentSession,
54
64
  callId: Schema.NonEmptyString,
@@ -56,7 +66,7 @@ export class ToolStarted extends Schema.TaggedClass("Agent/ToolStarted")("ToolSt
56
66
  input: Schema.Json,
57
67
  }) {
58
68
  }
59
- /** A tool call returned its output; a tool error does not by itself close the session. */
69
+ /** The result of a tool call; `isError` doesn't end the session. */
60
70
  export class ToolFinished extends Schema.TaggedClass("Agent/ToolFinished")("ToolFinished", {
61
71
  session: AgentSession,
62
72
  callId: Schema.NonEmptyString,
@@ -65,31 +75,74 @@ export class ToolFinished extends Schema.TaggedClass("Agent/ToolFinished")("Tool
65
75
  isError: Schema.Boolean,
66
76
  }) {
67
77
  }
68
- /** Marks the end of a session's activity in the transcript; the Attempt's outcome is recorded separately. */
78
+ /** The end of a session's activity; the Attempt's outcome is recorded separately. */
69
79
  export class SessionFinished extends Schema.TaggedClass("Agent/SessionFinished")("SessionFinished", { session: AgentSession }) {
70
80
  }
71
- /** A supervised session finished a turn and remains available for further operator messages. */
81
+ /** A supervised session that finished a turn and accepts more operator messages. */
72
82
  export class SessionIdle extends Schema.TaggedClass("Agent/SessionIdle")("SessionIdle", { session: AgentSession }) {
73
83
  }
74
- /** A live session is processing another user turn in the same conversation. */
84
+ /** A live session that started another user turn in the same conversation. */
75
85
  export class SessionResumed extends Schema.TaggedClass("Agent/SessionResumed")("SessionResumed", { session: AgentSession }) {
76
86
  }
77
- /** Cumulative tokens consumed by this session, including its later operator turns. */
78
- export class SessionTokensUpdated extends Schema.TaggedClass("Agent/SessionTokensUpdated")("SessionTokensUpdated", { session: AgentSession, totalTokens: TokenCount }) {
87
+ /** An estimated amount in US dollars from a rate table, not a bill (ADR 0013). */
88
+ export const UsdAmount = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("UsdAmount"));
89
+ const TokenTally = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
90
+ /** A session's cumulative tokens per billing rate; each token counts in one field only. */
91
+ export class TokenBreakdown extends Schema.Class("Agent/TokenBreakdown")({
92
+ /** Input tokens that are neither read from nor written to the prompt cache. */
93
+ input: TokenTally,
94
+ /** Input tokens read from the prompt cache. */
95
+ cachedInput: TokenTally,
96
+ /** Input tokens written to the prompt cache. */
97
+ cacheWrite: TokenTally,
98
+ /** Output tokens, including reasoning tokens. */
99
+ output: TokenTally,
100
+ }) {
101
+ }
102
+ /**
103
+ * The session's cumulative token count and price, including later operator turns. `costUsd` is
104
+ * `None` for harnesses that don't price usage, such as Codex, and for older transcripts.
105
+ * `breakdown` is `None` for harnesses other than Codex and for older transcripts.
106
+ */
107
+ export class SessionTokensUpdated extends Schema.TaggedClass("Agent/SessionTokensUpdated")("SessionTokensUpdated", {
108
+ session: AgentSession,
109
+ totalTokens: TokenCount,
110
+ costUsd: Schema.OptionFromOptionalKey(UsdAmount).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
111
+ breakdown: Schema.OptionFromOptionalKey(TokenBreakdown).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
112
+ }) {
79
113
  }
80
- /** The billing source whose meter produced a usage or rate-limit observation. */
81
114
  export const BillingPool = Schema.Literals(["apiKeys", "claudePlan", "chatgptPlan"]);
82
- /** A billing pool's observed usage for one allowance window. */
115
+ /**
116
+ * Returns the billing pool of a session with `brain` and the kind of the credential that a
117
+ * Gateway or a Cloudflare Worker's outbound handler injects, if any.
118
+ *
119
+ * - Claude Code: `apiKeys` if an API key is injected, otherwise `claudePlan` (ADR 0013).
120
+ * - Codex: `apiKeys` if an API key is injected, otherwise `chatgptPlan`.
121
+ * - Pi: `chatgptPlan` for `openai-codex/` models, otherwise `apiKeys` (ADR 0021).
122
+ */
123
+ export const brainPool = (brain, gatewayCredential) => {
124
+ switch (brain.harness) {
125
+ case "claude":
126
+ return Option.contains(gatewayCredential, "api-key") ? "apiKeys" : "claudePlan";
127
+ case "codex":
128
+ return Option.contains(gatewayCredential, "api-key") ? "apiKeys" : "chatgptPlan";
129
+ case "pi":
130
+ return brain.model.startsWith("openai-codex/") ? "chatgptPlan" : "apiKeys";
131
+ }
132
+ };
133
+ /** Returns the billing pool of a recorded session; the parent never uses a Gateway credential. */
134
+ export const sessionPool = (session) => Match.valueTags(session, {
135
+ ParentSession: ({ brain }) => brainPool(brain, Option.none()),
136
+ ChildSession: ({ brain, gatewayCredential }) => brainPool(brain, gatewayCredential),
137
+ });
83
138
  export class RateLimitWindow extends Schema.Class("Agent/RateLimitWindow")({
84
- /** Percentage of the allowance already consumed, including usage outside this Attempt. */
139
+ /** The percentage of the allowance used, including usage outside this Attempt. */
85
140
  usedPercent: Schema.Number,
86
- /** Length of the allowance window; absent when the provider omits it. */
87
141
  windowDurationMinutes: Schema.OptionFromNullOr(Schema.Number),
88
- /** When the allowance resets; absent when the provider omits it. */
89
142
  resetsAt: Schema.OptionFromNullOr(Schema.DateTimeUtcFromString),
90
143
  }) {
91
144
  }
92
- /** The allowance windows reported together by a provider; omitted windows remain unknown. */
145
+ /** The rate-limit windows from one provider report; a window is `None` if not reported. */
93
146
  export class RateLimitsSnapshot extends Schema.Class("Agent/RateLimitsSnapshot")({
94
147
  limitId: Schema.OptionFromNullOr(Schema.String),
95
148
  limitName: Schema.OptionFromNullOr(Schema.String),
@@ -97,14 +150,34 @@ export class RateLimitsSnapshot extends Schema.Class("Agent/RateLimitsSnapshot")
97
150
  secondary: Schema.OptionFromNullOr(RateLimitWindow),
98
151
  }) {
99
152
  }
100
- /** The latest rate windows observed for a billing pool during one session. */
153
+ /** The latest rate-limit windows observed for `pool` during the session. */
101
154
  export class PoolRateLimitsUpdated extends Schema.TaggedClass("Agent/PoolRateLimitsUpdated")("PoolRateLimitsUpdated", {
102
155
  session: AgentSession,
103
156
  pool: BillingPool,
104
157
  rateLimits: RateLimitsSnapshot,
105
158
  }) {
106
159
  }
107
- /** Session activity and billing observations recorded in an Attempt's transcript. */
160
+ /** The number of model provider retries in the current turn, starting at 1. */
161
+ export const ProviderRetries = PositiveInt.pipe(Schema.brand("ProviderRetries"));
162
+ /**
163
+ * A harness report of a failed model provider request that it retries, such as Codex's
164
+ * `Reconnecting...`. The session isn't stopped or failed (ADR 0013).
165
+ */
166
+ export class ProviderRetrying extends Schema.TaggedClass("Agent/ProviderRetrying")("ProviderRetrying", {
167
+ session: AgentSession,
168
+ /** The harness's failure message, verbatim if it provides one. */
169
+ message: Schema.NonEmptyString,
170
+ /** The retries reported in the current turn, including this one. */
171
+ retries: ProviderRetries,
172
+ }) {
173
+ }
174
+ /** A model provider response after a `ProviderRetrying` in the same turn. */
175
+ export class ProviderRecovered extends Schema.TaggedClass("Agent/ProviderRecovered")("ProviderRecovered", {
176
+ session: AgentSession,
177
+ /** The retries in the turn before the response. */
178
+ retries: ProviderRetries,
179
+ }) {
180
+ }
108
181
  export const AgentSessionEvent = Schema.Union([
109
182
  SessionStarted,
110
183
  TextOutput,
@@ -115,5 +188,7 @@ export const AgentSessionEvent = Schema.Union([
115
188
  SessionIdle,
116
189
  SessionResumed,
117
190
  SessionTokensUpdated,
191
+ ProviderRetrying,
192
+ ProviderRecovered,
118
193
  ]);
119
194
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAGzF,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAC3B,CAAC;AAGF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvE,mGAAmG;AACnG,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAGvF,2GAA2G;AAC3G,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAGrF,sFAAsF;AACtF,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,WAAW,CAAgB,qBAAqB,CAAC,CACzF,eAAe,EACf;IACE,EAAE,EAAE,cAAc;IAClB,KAAK,EAAE,SAAS;IAChB,K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C"}
@@ -1,27 +1,61 @@
1
- import { Schema } from "effect";
1
+ import { Array as EffectArray, DateTime, Option, Schema } from "effect";
2
2
  import { Agent } from "../agent/agent.ts";
3
3
  import { BrainSpec } from "../agent/brain.ts";
4
+ import { Comment } from "../step/result.ts";
4
5
  import { AttemptFailure } from "./failure.ts";
5
- /** Identity of one execution try; each retry receives a new identity under the same Run and Step. */
6
+ /** The ID of an Attempt; each retry gets a new ID under the same Run and Step. */
6
7
  export declare const AttemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
7
8
  export type AttemptId = typeof AttemptId.Type;
8
- /**
9
- * 1-based position of a try under its step. Retries are attempt N+1 under the
10
- * same step, and the auto-retry cap counts total attempts.
11
- */
9
+ /** The 1-based position of the Attempt in its Step. */
12
10
  export declare const AttemptNumber: Schema.brand<Schema.Int, "AttemptNumber">;
13
11
  export type AttemptNumber = typeof AttemptNumber.Type;
14
- /** Task text given to the agent after loop interpolation or an operator's edit-and-retry amendment. */
12
+ /** The task text for the agent: the interpolated loop prompt or the operator's edit-and-retry text. */
15
13
  export declare const AttemptTask: Schema.brand<Schema.String, "AttemptTask">;
16
14
  export type AttemptTask = typeof AttemptTask.Type;
15
+ /**
16
+ * Why the engine stops an Attempt's parent task: the operator canceled the Attempt (`cancel`), the
17
+ * Attempt failed (`failed`), or startup found the Attempt closed or not reattached (`startup`).
18
+ */
19
+ export declare const StopReason: Schema.Literals<readonly ["cancel", "failed", "startup"]>;
20
+ export type StopReason = typeof StopReason.Type;
17
21
  declare const AttemptContext_base: Schema.Class<AttemptContext, Schema.Struct<{
18
22
  readonly task: Schema.brand<Schema.String, "AttemptTask">;
19
23
  readonly agent: typeof Agent;
20
24
  readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
21
25
  }>, {}>;
22
- /** The effective task and roster Agent an operator assigns to a Run's later Attempts. */
26
+ /** The task and Agent that an operator sets for a Run's later Attempts. */
23
27
  export declare class AttemptContext extends AttemptContext_base {
24
28
  }
29
+ declare const FailureResolution_base: Schema.Class<FailureResolution, Schema.Struct<{
30
+ readonly resolvedAt: Schema.DateTimeUtcFromString;
31
+ readonly operator: Schema.OptionFromNullOr<Schema.brand<Schema.String, "OperatorLogin">>;
32
+ }>, {}>;
33
+ /** An operator's resolution of a failed attempt; the login is absent if none is configured. */
34
+ export declare class FailureResolution extends FailureResolution_base {
35
+ }
36
+ declare const OutOfMemoryKills_base: Schema.Class<OutOfMemoryKills, Schema.Struct<{
37
+ readonly kills: Schema.Int;
38
+ readonly memoryMib: Schema.brand<Schema.Int, "ContainerMemoryMib">;
39
+ }>, {}>;
40
+ /**
41
+ * The processes that the kernel killed in an Attempt's containers because a container reached
42
+ * its memory limit, `memoryMib`: the limit of the last container that recorded kills.
43
+ */
44
+ export declare class OutOfMemoryKills extends OutOfMemoryKills_base {
45
+ }
46
+ declare const ContainerOutOfMemoryKills_base: Schema.Class<ContainerOutOfMemoryKills, Schema.Struct<{
47
+ readonly container: Schema.brand<Schema.String, "ContainerId">;
48
+ readonly kills: Schema.Int;
49
+ readonly memoryMib: Schema.brand<Schema.Int, "ContainerMemoryMib">;
50
+ }>, {}>;
51
+ /**
52
+ * The processes that the kernel killed in one of an Attempt's containers, `container`, because it
53
+ * reached its memory limit, `memoryMib`. A reattachment runs the Attempt in a new container.
54
+ */
55
+ export declare class ContainerOutOfMemoryKills extends ContainerOutOfMemoryKills_base {
56
+ }
57
+ /** Returns the kills in `containers` together, with the memory limit of the last one. */
58
+ export declare const totalOutOfMemoryKills: (containers: EffectArray.NonEmptyReadonlyArray<ContainerOutOfMemoryKills>) => OutOfMemoryKills;
25
59
  declare const Attempt_base: Schema.Class<Attempt, Schema.Struct<{
26
60
  readonly id: Schema.brand<Schema.NonEmptyString, "AttemptId">;
27
61
  readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
@@ -35,14 +69,60 @@ declare const Attempt_base: Schema.Class<Attempt, Schema.Struct<{
35
69
  readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
36
70
  readonly startedAt: Schema.DateTimeUtc;
37
71
  readonly outcome: Schema.Option<Schema.Union<readonly [typeof import("./outcome.ts").AttemptSucceeded, typeof import("./outcome.ts").AttemptFailed, typeof import("./outcome.ts").AttemptCanceled]>>;
72
+ readonly endedAt: Schema.Option<Schema.DateTimeUtc>;
73
+ readonly salvage: Schema.Option<Schema.Union<readonly [typeof import("./salvage.ts").SalvagePushed, typeof import("./salvage.ts").SalvagePartlyPushed, typeof import("./salvage.ts").SalvageRetained, typeof import("./salvage.ts").SalvageRejected]>>;
74
+ readonly failureResolution: Schema.withConstructorDefault<Schema.Option<typeof FailureResolution>>;
75
+ readonly start: Schema.withConstructorDefault<Schema.Option<Schema.Union<readonly [typeof import("./start.ts").StartedByEvent, typeof import("./start.ts").StartedByRetry, typeof import("./start.ts").StartedByEditAndRetry, typeof import("./start.ts").StartedByInfraRetry, typeof import("./start.ts").StartedAfterRestart]>>>;
76
+ readonly reattachedAt: Schema.withConstructorDefault<Schema.Option<Schema.DateTimeUtc>>;
77
+ readonly comments: Schema.withConstructorDefault<Schema.$Array<typeof Comment>>;
78
+ readonly outOfMemory: Schema.withConstructorDefault<Schema.Option<typeof OutOfMemoryKills>>;
38
79
  }>, {}>;
39
- /** One try of a step on a worker. `outcome` is none while the attempt is in flight. */
80
+ /**
81
+ * One try of a Step on a Worker.
82
+ *
83
+ * - `outcome`: `None` while the Attempt runs.
84
+ * - `endedAt`: the time the outcome was recorded; `None` while running and for older records.
85
+ * - `salvage`: what the executor kept of the workspace after an unsuccessful end.
86
+ * - `start`: the reason the Attempt started; `None` for older records.
87
+ * - `reattachedAt`: the last time an orchestrator restart reattached the Attempt.
88
+ * - `comments`: the comments and reviews posted by an unsuccessful Attempt; a successful
89
+ * Attempt's are in the Step result.
90
+ * - `outOfMemory`: the processes the kernel killed in the Attempt's containers for memory, in all
91
+ * of them together; `None` if it killed none or the Attempt ran without a container.
92
+ */
40
93
  export declare class Attempt extends Attempt_base {
41
94
  }
95
+ declare const AttemptWindow_base: Schema.Class<AttemptWindow, Schema.Struct<{
96
+ readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
97
+ readonly startedAt: Schema.DateTimeUtc;
98
+ readonly endedAt: Schema.Option<Schema.DateTimeUtc>;
99
+ }>, {}>;
100
+ /**
101
+ * The time span of an Attempt, open while `endedAt` is `None`, used to attribute GitHub writes
102
+ * by Attempts that share one App login.
103
+ */
104
+ export declare class AttemptWindow extends AttemptWindow_base {
105
+ }
106
+ /** Returns the Attempt's window, or `None` if it ended before end times were recorded. */
107
+ export declare const windowOf: (attempt: Attempt) => Option.Option<AttemptWindow>;
108
+ /** Returns whether the GitHub timestamp `at` is inside `window`. */
109
+ export declare const windowHolds: (window: AttemptWindow, at: DateTime.Utc) => boolean;
110
+ /** Returns whether a GitHub timestamp can be inside both windows. */
111
+ export declare const windowsOverlap: (left: AttemptWindow, right: AttemptWindow) => boolean;
112
+ declare const AttemptWindows_base: Schema.Class<AttemptWindows, Schema.Struct<{
113
+ readonly own: Schema.Option<typeof AttemptWindow>;
114
+ readonly overlapping: Schema.$Array<typeof AttemptWindow>;
115
+ }>, {}>;
116
+ /**
117
+ * The windows used to attribute writes on a Run's Item to one Attempt. A write belongs to the
118
+ * Attempt only if its time is inside `own` and outside every `overlapping` window, which are the
119
+ * same Agent's other Attempts on the Item.
120
+ */
121
+ export declare class AttemptWindows extends AttemptWindows_base {
122
+ }
42
123
  /**
43
- * The auto-retry law: only an infra failure retries, and only while the attempt
44
- * number is below `maxAutoAttempts` (ADR 0002).
45
- * `number` is the failed try's position; `maxAutoAttempts` includes the first try.
124
+ * Returns whether `failure` is retryable and the failed Attempt's `number` is below
125
+ * `maxAutoAttempts`, which counts the first try (ADR 0002).
46
126
  */
47
127
  export declare const shouldAutoRetry: (options: {
48
128
  readonly failure: AttemptFailure;
@@ -1 +1 @@
1
- {"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/attempt/attempt.ts"],"names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Ac,SAAU,aAAa,SAAS,aAAa,KAAG,OACX,CAAC;;;;;AAEjE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;AAEL;;;GAGG;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,OAA8F,CAAC"}
@@ -1,28 +1,78 @@
1
- import { Schema } from "effect";
1
+ import { Array as EffectArray, DateTime, Effect, Option, Schema } from "effect";
2
2
  import { Agent, AgentName } from "../agent/agent.js";
3
3
  import { BrainSpec, ModelId } from "../agent/brain.js";
4
+ import { closedStruct } from "../closed-struct.js";
5
+ import { OperatorLogin } from "../operator.js";
4
6
  import { RunId } from "../run/run.js";
7
+ import { Comment } from "../step/result.js";
5
8
  import { StepName } from "../step/step.js";
6
- import { WorkerName } from "../worker.js";
9
+ import { ContainerId, ContainerMemoryMib, WorkerName } from "../worker.js";
7
10
  import { AttemptFailure, isAutoRetryableFailure } from "./failure.js";
8
11
  import { AttemptOutcome } from "./outcome.js";
9
- /** Identity of one execution try; each retry receives a new identity under the same Run and Step. */
12
+ import { AttemptSalvage } from "./salvage.js";
13
+ import { AttemptStart } from "./start.js";
14
+ /** The ID of an Attempt; each retry gets a new ID under the same Run and Step. */
10
15
  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
- */
16
+ /** The 1-based position of the Attempt in its Step. */
15
17
  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. */
18
+ /** The task text for the agent: the interpolated loop prompt or the operator's edit-and-retry text. */
17
19
  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. */
20
+ /**
21
+ * Why the engine stops an Attempt's parent task: the operator canceled the Attempt (`cancel`), the
22
+ * Attempt failed (`failed`), or startup found the Attempt closed or not reattached (`startup`).
23
+ */
24
+ export const StopReason = Schema.Literals(["cancel", "failed", "startup"]);
25
+ /** The task and Agent that an operator sets for a Run's later Attempts. */
19
26
  export class AttemptContext extends Schema.Class("AttemptContext")({
20
27
  task: AttemptTask,
21
28
  agent: Agent,
22
29
  parentModel: Schema.OptionFromNullOr(ModelId),
23
30
  }) {
24
31
  }
25
- /** One try of a step on a worker. `outcome` is none while the attempt is in flight. */
32
+ /** An operator's resolution of a failed attempt; the login is absent if none is configured. */
33
+ export class FailureResolution extends Schema.Class("FailureResolution")(closedStruct({
34
+ resolvedAt: Schema.DateTimeUtcFromString,
35
+ operator: Schema.OptionFromNullOr(OperatorLogin),
36
+ })) {
37
+ }
38
+ const Kills = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
39
+ /**
40
+ * The processes that the kernel killed in an Attempt's containers because a container reached
41
+ * its memory limit, `memoryMib`: the limit of the last container that recorded kills.
42
+ */
43
+ export class OutOfMemoryKills extends Schema.Class("OutOfMemoryKills")({
44
+ kills: Kills,
45
+ memoryMib: ContainerMemoryMib,
46
+ }) {
47
+ }
48
+ /**
49
+ * The processes that the kernel killed in one of an Attempt's containers, `container`, because it
50
+ * reached its memory limit, `memoryMib`. A reattachment runs the Attempt in a new container.
51
+ */
52
+ export class ContainerOutOfMemoryKills extends Schema.Class("ContainerOutOfMemoryKills")({
53
+ container: ContainerId,
54
+ kills: Kills,
55
+ memoryMib: ContainerMemoryMib,
56
+ }) {
57
+ }
58
+ /** Returns the kills in `containers` together, with the memory limit of the last one. */
59
+ export const totalOutOfMemoryKills = (containers) => new OutOfMemoryKills({
60
+ kills: containers.reduce((total, { kills }) => total + kills, 0),
61
+ memoryMib: EffectArray.lastNonEmpty(containers).memoryMib,
62
+ });
63
+ /**
64
+ * One try of a Step on a Worker.
65
+ *
66
+ * - `outcome`: `None` while the Attempt runs.
67
+ * - `endedAt`: the time the outcome was recorded; `None` while running and for older records.
68
+ * - `salvage`: what the executor kept of the workspace after an unsuccessful end.
69
+ * - `start`: the reason the Attempt started; `None` for older records.
70
+ * - `reattachedAt`: the last time an orchestrator restart reattached the Attempt.
71
+ * - `comments`: the comments and reviews posted by an unsuccessful Attempt; a successful
72
+ * Attempt's are in the Step result.
73
+ * - `outOfMemory`: the processes the kernel killed in the Attempt's containers for memory, in all
74
+ * of them together; `None` if it killed none or the Attempt ran without a container.
75
+ */
26
76
  export class Attempt extends Schema.Class("Attempt")({
27
77
  id: AttemptId,
28
78
  runId: RunId,
@@ -36,12 +86,63 @@ export class Attempt extends Schema.Class("Attempt")({
36
86
  parentModel: Schema.OptionFromNullOr(ModelId),
37
87
  startedAt: Schema.DateTimeUtc,
38
88
  outcome: Schema.Option(AttemptOutcome),
89
+ endedAt: Schema.Option(Schema.DateTimeUtc),
90
+ salvage: Schema.Option(AttemptSalvage),
91
+ failureResolution: Schema.Option(FailureResolution).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
92
+ start: Schema.Option(AttemptStart).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
93
+ reattachedAt: Schema.Option(Schema.DateTimeUtc).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
94
+ comments: Schema.Array(Comment).pipe(Schema.withConstructorDefault(Effect.succeed([]))),
95
+ outOfMemory: Schema.Option(OutOfMemoryKills).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
96
+ }) {
97
+ }
98
+ /**
99
+ * The time span of an Attempt, open while `endedAt` is `None`, used to attribute GitHub writes
100
+ * by Attempts that share one App login.
101
+ */
102
+ export class AttemptWindow extends Schema.Class("AttemptWindow")({
103
+ attemptId: AttemptId,
104
+ startedAt: Schema.DateTimeUtc,
105
+ endedAt: Schema.Option(Schema.DateTimeUtc),
106
+ }) {
107
+ }
108
+ /** Returns the Attempt's window, or `None` if it ended before end times were recorded. */
109
+ export const windowOf = (attempt) => Option.isSome(attempt.outcome) && Option.isNone(attempt.endedAt)
110
+ ? Option.none()
111
+ : Option.some(new AttemptWindow({
112
+ attemptId: attempt.id,
113
+ startedAt: attempt.startedAt,
114
+ endedAt: attempt.endedAt,
115
+ }));
116
+ /** Returns the window start truncated to the second, the precision of GitHub timestamps. */
117
+ const opening = (window) => {
118
+ const start = DateTime.toEpochMillis(window.startedAt);
119
+ return start - (start % 1_000);
120
+ };
121
+ /** Returns whether `window` is open or ended at or after `millis`. */
122
+ const reaches = (window, millis) => Option.match(window.endedAt, {
123
+ onNone: () => true,
124
+ onSome: (end) => millis <= DateTime.toEpochMillis(end),
125
+ });
126
+ /** Returns whether the GitHub timestamp `at` is inside `window`. */
127
+ export const windowHolds = (window, at) => {
128
+ const time = DateTime.toEpochMillis(at);
129
+ return opening(window) <= time && reaches(window, time);
130
+ };
131
+ /** Returns whether a GitHub timestamp can be inside both windows. */
132
+ export const windowsOverlap = (left, right) => reaches(left, opening(right)) && reaches(right, opening(left));
133
+ /**
134
+ * The windows used to attribute writes on a Run's Item to one Attempt. A write belongs to the
135
+ * Attempt only if its time is inside `own` and outside every `overlapping` window, which are the
136
+ * same Agent's other Attempts on the Item.
137
+ */
138
+ export class AttemptWindows extends Schema.Class("AttemptWindows")({
139
+ own: Schema.Option(AttemptWindow),
140
+ overlapping: Schema.Array(AttemptWindow),
39
141
  }) {
40
142
  }
41
143
  /**
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.
144
+ * Returns whether `failure` is retryable and the failed Attempt's `number` is below
145
+ * `maxAutoAttempts`, which counts the first try (ADR 0002).
45
146
  */
46
147
  export const shouldAutoRetry = (options) => isAutoRetryableFailure(options.failure) && options.number < options.maxAutoAttempts;
47
148
  //# sourceMappingURL=attempt.js.map
@@ -1 +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;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