@usine/core 0.0.1 → 0.1.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 (53) hide show
  1. package/README.md +12 -4
  2. package/dist/agent.d.ts +121 -0
  3. package/dist/agent.d.ts.map +1 -0
  4. package/dist/agent.js +105 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/attempt-channel.d.ts +134 -0
  7. package/dist/attempt-channel.d.ts.map +1 -0
  8. package/dist/attempt-channel.js +138 -0
  9. package/dist/attempt-channel.js.map +1 -0
  10. package/dist/index.d.ts +7 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/instance.d.ts +9 -0
  15. package/dist/instance.d.ts.map +1 -0
  16. package/dist/instance.js +8 -0
  17. package/dist/instance.js.map +1 -0
  18. package/dist/lifecycle/attempt.d.ts +10 -2
  19. package/dist/lifecycle/attempt.d.ts.map +1 -1
  20. package/dist/lifecycle/attempt.js +9 -1
  21. package/dist/lifecycle/attempt.js.map +1 -1
  22. package/dist/lifecycle/event.d.ts +1 -1
  23. package/dist/lifecycle/event.js +1 -1
  24. package/dist/lifecycle/event.js.map +1 -1
  25. package/dist/lifecycle/item.d.ts +11 -0
  26. package/dist/lifecycle/item.d.ts.map +1 -0
  27. package/dist/lifecycle/item.js +9 -0
  28. package/dist/lifecycle/item.js.map +1 -0
  29. package/dist/lifecycle/loop.d.ts +8 -0
  30. package/dist/lifecycle/loop.d.ts.map +1 -1
  31. package/dist/lifecycle/loop.js +7 -0
  32. package/dist/lifecycle/loop.js.map +1 -1
  33. package/dist/lifecycle/run-state.d.ts +9 -0
  34. package/dist/lifecycle/run-state.d.ts.map +1 -1
  35. package/dist/lifecycle/run-state.js +17 -0
  36. package/dist/lifecycle/run-state.js.map +1 -1
  37. package/dist/lifecycle/step.d.ts +2 -1
  38. package/dist/lifecycle/step.d.ts.map +1 -1
  39. package/dist/lifecycle/step.js +2 -1
  40. package/dist/lifecycle/step.js.map +1 -1
  41. package/dist/repository.d.ts +26 -0
  42. package/dist/repository.d.ts.map +1 -0
  43. package/dist/repository.js +32 -0
  44. package/dist/repository.js.map +1 -0
  45. package/dist/step-result.d.ts +35 -0
  46. package/dist/step-result.d.ts.map +1 -0
  47. package/dist/step-result.js +30 -0
  48. package/dist/step-result.js.map +1 -0
  49. package/dist/worker.d.ts +9 -0
  50. package/dist/worker.d.ts.map +1 -0
  51. package/dist/worker.js +9 -0
  52. package/dist/worker.js.map +1 -0
  53. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @usine/core
2
2
 
3
- Domain model for [usine](https://github.com/basaltbytes/usine), an agent-agnostic software factory: the Event → Run → Step → Attempt vocabulary every other block types against.
3
+ Domain model for [usine](https://github.com/basaltbytes/usine), an agent-agnostic software factory: the Event → Run → Step → Attempt vocabulary every other block types against, plus shared instance and repository value objects.
4
4
 
5
- Everything lives in the `lifecycle` cluster — how one piece of work moves through the engine: a deduplicated Event opens a Run, the Run's named Step is tried as Attempts, and the state machine closes it. The attempt-channel envelope schema arrives later as a sibling cluster.
5
+ Everything lives in the `lifecycle` cluster: a deduplicated Event opens a Run, the Run's named Step is tried as Attempts, and the state machine closes it.
6
6
 
7
7
  ## What each export is
8
8
 
@@ -10,12 +10,20 @@ Everything lives in the `lifecycle` cluster — how one piece of work moves thro
10
10
  | --- | --- |
11
11
  | `Event`, `Run`, `Step`, `Attempt` | Entities — the four ledger rows, identity plus validated construction |
12
12
  | `EventId`, `RunId`, `AttemptId` | Value objects — branded ids; identities that cannot be swapped for each other |
13
- | `DedupKey`, `LoopName`, `StepName`, `AttemptNumber` | Value objects — branded primitives carrying a domain constraint |
14
- | `RunState.*`, `CancelReason`, `Attempt.Outcome` | State value objects — discriminated unions, each state carrying exactly its own data |
13
+ | `DedupKey`, `ItemKey`, `Item.Number`, `LoopName`, `StepName`, `AttemptNumber` | Value objects — branded primitives carrying a domain constraint; Item numbers are positive integers |
14
+ | `Instance.Directory`, `Repository.Name`, `Repository.Revision`, `Repository.CommitSha` | Shared value objects — paths and validated Git identities |
15
+ | `Worker.Name`, `Worker.Kind` | Value objects — a Worker identity and its local or exe.dev adapter kind |
16
+ | `Agent.Agent`, `Agent.BrainSpec` | Agent values — a named persona, its child brain, and optional Pi parent-model override |
17
+ | `Agent.SessionEvent` | Session events — typed parent or first-level child lifecycle, text, and tool events |
18
+ | `AttemptChannel.*` | Protocol values: the secret-free run spec, framed input, and protocol-v3 Attempt envelopes (`Started` carries the effective parent model) |
19
+ | `StepResult.*` | Result values — the final agent message plus commit, pull-request, and comment facts |
20
+ | `RunState.*`, `CancelReason`, `Attempt.Outcome` | State value objects — discriminated unions, including a distinct canceled Attempt outcome |
15
21
  | `RunState.awaitApproval/start/succeed/fail/retry/cancelByOperator/supersede/revoke` | Typestate transitions — each accepts only the states it is legal on, so an illegal transition is a compile error |
16
22
  | `InfraFailure`, `AgentFailure`, `RunawayFailure` | Typed errors — the attempt-failure taxonomy |
17
23
  | `AttemptFailure.isAutoRetryable`, `Attempt.shouldAutoRetry` | Derivers — pure decision functions stating the auto-retry law (class rule; class rule capped by attempt count) |
18
24
 
19
25
  The run state machine is `pending → waiting → running → succeeded / failed / canceled`, with `failed → running` on operator retry. The failure taxonomy separates infra failures (the only auto-retryable class, capped), agent failures (always wait for the operator), and the runaway guard tripping (never auto-retried).
20
26
 
27
+ Each Attempt records the child `BrainSpec` and effective Pi parent model used for that try. The attempt channel carries immutable repository, payload, task, and agent context in its `Start` frame; outbound `SessionEvent` envelopes retain parent and first-level child session identity.
28
+
21
29
  Everything is 0.x: APIs change without notice while the engine grows. `effect` is a peer dependency — supply it yourself at the pinned version.
@@ -0,0 +1,121 @@
1
+ import { Option, Schema } from "effect";
2
+ /** Value object: the filename-keyed identity of one rostered Agent. */
3
+ export declare const Name: Schema.brand<Schema.String, "AgentName">;
4
+ export type Name = typeof Name.Type;
5
+ /** Value object: an opaque vendor model identifier. */
6
+ export declare const ModelId: Schema.brand<Schema.String, "ModelId">;
7
+ export type ModelId = typeof ModelId.Type;
8
+ /** Value object: standing Markdown instructions for one Agent. */
9
+ export declare const Persona: Schema.brand<Schema.String, "AgentPersona">;
10
+ export type Persona = typeof Persona.Type;
11
+ export declare const HARNESSES: readonly ["claude", "codex", "pi"];
12
+ export declare const Harness: Schema.Literals<readonly ["claude", "codex", "pi"]>;
13
+ export type Harness = typeof Harness.Type;
14
+ export declare const EFFORTS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
15
+ export declare const Effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
16
+ export type Effort = typeof Effort.Type;
17
+ declare const BrainSpec_base: Schema.Class<BrainSpec, Schema.Struct<{
18
+ readonly harness: Schema.Literals<readonly ["claude", "codex", "pi"]>;
19
+ readonly model: Schema.brand<Schema.String, "ModelId">;
20
+ readonly effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
21
+ }>, {}>;
22
+ /** Value object: the harness child that a run is declared to spawn. */
23
+ export declare class BrainSpec extends BrainSpec_base {
24
+ }
25
+ declare const Agent_base: Schema.Class<Agent, Schema.Struct<{
26
+ readonly name: Schema.brand<Schema.String, "AgentName">;
27
+ readonly brain: typeof BrainSpec;
28
+ readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
29
+ readonly persona: Schema.brand<Schema.String, "AgentPersona">;
30
+ }>, {}>;
31
+ /** Entity: one named member of the instance's authored team roster. */
32
+ export declare class Agent extends Agent_base {
33
+ }
34
+ /** Value object: SDK-local identity of one parent or child agent session. */
35
+ export declare const SessionId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
36
+ export type SessionId = typeof SessionId.Type;
37
+ declare const ParentSession_base: Schema.Class<ParentSession, Schema.TaggedStruct<"ParentSession", {
38
+ readonly id: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
39
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
40
+ readonly brain: typeof BrainSpec;
41
+ }>, {}>;
42
+ /** Parent session descriptor. It cannot name a parent, so recursive nesting is unrepresentable. */
43
+ export declare class ParentSession extends ParentSession_base {
44
+ }
45
+ declare const ChildSession_base: Schema.Class<ChildSession, Schema.TaggedStruct<"ChildSession", {
46
+ readonly id: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
47
+ readonly parentId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
48
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
49
+ readonly brain: typeof BrainSpec;
50
+ }>, {}>;
51
+ /** Child session descriptor. Exactly one parent id keeps session nesting one level deep. */
52
+ export declare class ChildSession extends ChildSession_base {
53
+ }
54
+ export declare const Session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
55
+ export type Session = typeof Session.Type;
56
+ declare const SessionStarted_base: Schema.Class<SessionStarted, Schema.TaggedStruct<"SessionStarted", {
57
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
58
+ }>, {}>;
59
+ export declare class SessionStarted extends SessionStarted_base {
60
+ }
61
+ declare const TextOutput_base: Schema.Class<TextOutput, Schema.TaggedStruct<"TextOutput", {
62
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
63
+ readonly text: Schema.NonEmptyString;
64
+ }>, {}>;
65
+ export declare class TextOutput extends TextOutput_base {
66
+ }
67
+ declare const ToolStarted_base: Schema.Class<ToolStarted, Schema.TaggedStruct<"ToolStarted", {
68
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
69
+ readonly callId: Schema.NonEmptyString;
70
+ readonly tool: Schema.NonEmptyString;
71
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
72
+ }>, {}>;
73
+ export declare class ToolStarted extends ToolStarted_base {
74
+ }
75
+ declare const ToolFinished_base: Schema.Class<ToolFinished, Schema.TaggedStruct<"ToolFinished", {
76
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
77
+ readonly callId: Schema.NonEmptyString;
78
+ readonly tool: Schema.NonEmptyString;
79
+ readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
80
+ readonly isError: Schema.Boolean;
81
+ }>, {}>;
82
+ export declare class ToolFinished extends ToolFinished_base {
83
+ }
84
+ declare const SessionFinished_base: Schema.Class<SessionFinished, Schema.TaggedStruct<"SessionFinished", {
85
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
86
+ }>, {}>;
87
+ export declare class SessionFinished extends SessionFinished_base {
88
+ }
89
+ /** Billing source whose native meter produced a usage or health observation. */
90
+ export declare const Pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
91
+ export type Pool = typeof Pool.Type;
92
+ declare const RateLimitWindow_base: Schema.Class<RateLimitWindow, Schema.Struct<{
93
+ readonly usedPercent: Schema.Number;
94
+ readonly windowDurationMinutes: Schema.OptionFromNullOr<Schema.Number>;
95
+ readonly resetsAt: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
96
+ }>, {}>;
97
+ export declare class RateLimitWindow extends RateLimitWindow_base {
98
+ }
99
+ declare const RateLimitsSnapshot_base: Schema.Class<RateLimitsSnapshot, Schema.Struct<{
100
+ readonly limitId: Schema.OptionFromNullOr<Schema.String>;
101
+ readonly limitName: Schema.OptionFromNullOr<Schema.String>;
102
+ readonly primary: Schema.OptionFromNullOr<typeof RateLimitWindow>;
103
+ readonly secondary: Schema.OptionFromNullOr<typeof RateLimitWindow>;
104
+ }>, {}>;
105
+ export declare class RateLimitsSnapshot extends RateLimitsSnapshot_base {
106
+ }
107
+ declare const PoolRateLimitsUpdated_base: Schema.Class<PoolRateLimitsUpdated, Schema.TaggedStruct<"PoolRateLimitsUpdated", {
108
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
109
+ readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
110
+ readonly rateLimits: typeof RateLimitsSnapshot;
111
+ }>, {}>;
112
+ /** Latest native billing-pool rate windows observed during one session. */
113
+ export declare class PoolRateLimitsUpdated extends PoolRateLimitsUpdated_base {
114
+ }
115
+ /** Normalized events emitted by every parent and child SDK backend. */
116
+ export declare const SessionEvent: Schema.Union<readonly [typeof SessionStarted, typeof TextOutput, typeof ToolStarted, typeof ToolFinished, typeof PoolRateLimitsUpdated, typeof SessionFinished]>;
117
+ export type SessionEvent = typeof SessionEvent.Type;
118
+ /** Pure deriver: a per-Agent parent override wins over the instance default. */
119
+ export declare const resolveParentModel: (agent: Agent, instanceDefault: Option.Option<ModelId>) => Option.Option<ModelId>;
120
+ export {};
121
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKxC,uEAAuE;AACvE,eAAO,MAAM,IAAI,0CAIgB,CAAC;AAClC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAEpC,uDAAuD;AACvD,eAAO,MAAM,OAAO,wCAEnB,CAAC;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,kEAAkE;AAClE,eAAO,MAAM,OAAO,6CAEnB,CAAC;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,eAAO,MAAM,SAAS,YAAI,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AAC5D,eAAO,MAAM,OAAO,qDAA6B,CAAC;AAClD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,eAAO,MAAM,OAAO,YAAI,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AA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tB,KAAK,mBACK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAA6D,CAAC"}
package/dist/agent.js ADDED
@@ -0,0 +1,105 @@
1
+ import { Option, Schema } from "effect";
2
+ const nonBlankString = (message) => Schema.String.check(Schema.isPattern(/\S/u, { message }));
3
+ /** Value object: the filename-keyed identity of one rostered Agent. */
4
+ export const Name = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, {
5
+ message: "Expected a kebab-case Agent name",
6
+ })).pipe(Schema.brand("AgentName"));
7
+ /** Value object: an opaque vendor model identifier. */
8
+ export const ModelId = nonBlankString("Expected a non-blank model id").pipe(Schema.brand("ModelId"));
9
+ /** Value object: standing Markdown instructions for one Agent. */
10
+ export const Persona = nonBlankString("Expected a non-blank Agent persona").pipe(Schema.brand("AgentPersona"));
11
+ export const HARNESSES = ["claude", "codex", "pi"];
12
+ export const Harness = Schema.Literals(HARNESSES);
13
+ export const EFFORTS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
14
+ export const Effort = Schema.Literals(EFFORTS);
15
+ /** Value object: the harness child that a run is declared to spawn. */
16
+ export class BrainSpec extends Schema.Class("Agent/BrainSpec")({
17
+ harness: Harness,
18
+ model: ModelId,
19
+ effort: Effort,
20
+ }) {
21
+ }
22
+ /** Entity: one named member of the instance's authored team roster. */
23
+ export class Agent extends Schema.Class("Agent")({
24
+ name: Name,
25
+ brain: BrainSpec,
26
+ parentModel: Schema.OptionFromNullOr(ModelId),
27
+ persona: Persona,
28
+ }) {
29
+ }
30
+ /** Value object: SDK-local identity of one parent or child agent session. */
31
+ export const SessionId = Schema.NonEmptyString.pipe(Schema.brand("AgentSessionId"));
32
+ /** Parent session descriptor. It cannot name a parent, so recursive nesting is unrepresentable. */
33
+ export class ParentSession extends Schema.TaggedClass("Agent/ParentSession")("ParentSession", {
34
+ id: SessionId,
35
+ agent: Name,
36
+ brain: BrainSpec,
37
+ }) {
38
+ }
39
+ /** Child session descriptor. Exactly one parent id keeps session nesting one level deep. */
40
+ export class ChildSession extends Schema.TaggedClass("Agent/ChildSession")("ChildSession", {
41
+ id: SessionId,
42
+ parentId: SessionId,
43
+ agent: Name,
44
+ brain: BrainSpec,
45
+ }) {
46
+ }
47
+ export const Session = Schema.Union([ParentSession, ChildSession]);
48
+ export class SessionStarted extends Schema.TaggedClass("Agent/SessionStarted")("SessionStarted", { session: Session }) {
49
+ }
50
+ export class TextOutput extends Schema.TaggedClass("Agent/TextOutput")("TextOutput", {
51
+ session: Session,
52
+ text: Schema.NonEmptyString,
53
+ }) {
54
+ }
55
+ export class ToolStarted extends Schema.TaggedClass("Agent/ToolStarted")("ToolStarted", {
56
+ session: Session,
57
+ callId: Schema.NonEmptyString,
58
+ tool: Schema.NonEmptyString,
59
+ input: Schema.Json,
60
+ }) {
61
+ }
62
+ export class ToolFinished extends Schema.TaggedClass("Agent/ToolFinished")("ToolFinished", {
63
+ session: Session,
64
+ callId: Schema.NonEmptyString,
65
+ tool: Schema.NonEmptyString,
66
+ output: Schema.Json,
67
+ isError: Schema.Boolean,
68
+ }) {
69
+ }
70
+ export class SessionFinished extends Schema.TaggedClass("Agent/SessionFinished")("SessionFinished", { session: Session }) {
71
+ }
72
+ /** Billing source whose native meter produced a usage or health observation. */
73
+ export const Pool = Schema.Literals(["apiKeys", "claudePlan", "chatgptPlan"]);
74
+ export class RateLimitWindow extends Schema.Class("Agent/RateLimitWindow")({
75
+ usedPercent: Schema.Number,
76
+ windowDurationMinutes: Schema.OptionFromNullOr(Schema.Number),
77
+ resetsAt: Schema.OptionFromNullOr(Schema.DateTimeUtcFromString),
78
+ }) {
79
+ }
80
+ export class RateLimitsSnapshot extends Schema.Class("Agent/RateLimitsSnapshot")({
81
+ limitId: Schema.OptionFromNullOr(Schema.String),
82
+ limitName: Schema.OptionFromNullOr(Schema.String),
83
+ primary: Schema.OptionFromNullOr(RateLimitWindow),
84
+ secondary: Schema.OptionFromNullOr(RateLimitWindow),
85
+ }) {
86
+ }
87
+ /** Latest native billing-pool rate windows observed during one session. */
88
+ export class PoolRateLimitsUpdated extends Schema.TaggedClass("Agent/PoolRateLimitsUpdated")("PoolRateLimitsUpdated", {
89
+ session: Session,
90
+ pool: Pool,
91
+ rateLimits: RateLimitsSnapshot,
92
+ }) {
93
+ }
94
+ /** Normalized events emitted by every parent and child SDK backend. */
95
+ export const SessionEvent = Schema.Union([
96
+ SessionStarted,
97
+ TextOutput,
98
+ ToolStarted,
99
+ ToolFinished,
100
+ PoolRateLimitsUpdated,
101
+ SessionFinished,
102
+ ]);
103
+ /** Pure deriver: a per-Agent parent override wins over the instance default. */
104
+ export const resolveParentModel = (agent, instanceDefault) => Option.firstSomeOf([agent.parentModel, instanceDefault]);
105
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,EAAE,CACzC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAE5D,uEAAuE;AACvE,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACrC,MAAM,CAAC,SAAS,CAAC,6BAA6B,EAAE;IAC9C,OAAO,EAAE,kCAAkC;CAC5C,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAGlC,uDAAuD;AACvD,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC,+BAA+B,CAAC,CAAC,IAAI,CACzE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CACxB,CAAC;AAGF,kEAAkE;AAClE,MAAM,CAAC,MA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,EACZ,eAAuC,EACf,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC"}
@@ -0,0 +1,134 @@
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
@@ -0,0 +1 @@
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;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AAO,MAAM,QAAQ,0EAAoD,CAAC;AAC1E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;AAE5C,sEAAsE;AACtE,qBAAa,KAAM,SAAQ,UAGzB;CAAG;AAEL,eAAO,MAAM,UAAU,+DAAyC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,eAAO,MAAM,gBAAgB,iGAAkC,CAAC;AAChE,eAAO,MAAM,kBAAkB,sFAAoC,CAAC;AACpE,eAAO,MAAM,wBAAwB,gDAA0C,CAAC;AAEhF,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"}
@@ -0,0 +1,138 @@
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
@@ -0,0 +1 @@
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,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AAC,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 CHANGED
@@ -6,12 +6,17 @@
6
6
  * is tried as Attempts, and the state machine closes it. Entities are the
7
7
  * ledger rows (Event, Run, Step, Attempt); everything else is value objects,
8
8
  * typed errors, and pure derivers — each module docblock names its kind.
9
- * The attempt-channel envelope schema (ADR 0012) will arrive as a sibling
10
- * cluster.
11
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";
12
16
  export * as Attempt from "./lifecycle/attempt.ts";
13
17
  export * as AttemptFailure from "./lifecycle/attempt-failure.ts";
14
18
  export * as Event from "./lifecycle/event.ts";
19
+ export * as Item from "./lifecycle/item.ts";
15
20
  export * as Loop from "./lifecycle/loop.ts";
16
21
  export * as Run from "./lifecycle/run.ts";
17
22
  export * as RunState from "./lifecycle/run-state.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,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,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC"}
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 CHANGED
@@ -6,12 +6,17 @@
6
6
  * is tried as Attempts, and the state machine closes it. Entities are the
7
7
  * ledger rows (Event, Run, Step, Attempt); everything else is value objects,
8
8
  * typed errors, and pure derivers — each module docblock names its kind.
9
- * The attempt-channel envelope schema (ADR 0012) will arrive as a sibling
10
- * cluster.
11
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";
12
16
  export * as Attempt from "./lifecycle/attempt.js";
13
17
  export * as AttemptFailure from "./lifecycle/attempt-failure.js";
14
18
  export * as Event from "./lifecycle/event.js";
19
+ export * as Item from "./lifecycle/item.js";
15
20
  export * as Loop from "./lifecycle/loop.js";
16
21
  export * as Run from "./lifecycle/run.js";
17
22
  export * as RunState from "./lifecycle/run-state.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,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,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC"}
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"}
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Value object (branded path): absolute or caller-resolved path to the
4
+ * instance folder (ADR 0001). Shared by every package that anchors itself to
5
+ * the instance repo — the engine's database adapters and the config loader.
6
+ */
7
+ export declare const Directory: Schema.brand<Schema.NonEmptyString, "InstanceDirectory">;
8
+ export type Directory = typeof Directory.Type;
9
+ //# sourceMappingURL=instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,SAAS,0DAAgE,CAAC;AACvF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Value object (branded path): absolute or caller-resolved path to the
4
+ * instance folder (ADR 0001). Shared by every package that anchors itself to
5
+ * the instance repo — the engine's database adapters and the config loader.
6
+ */
7
+ export const Directory = Schema.NonEmptyString.pipe(Schema.brand("InstanceDirectory"));
8
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { AttemptFailure } from "./attempt-failure.ts";
3
+ import { BrainSpec } from "../agent.ts";
3
4
  /**
4
5
  * Value object (branded id): identity of one Attempt.
5
6
  */
@@ -22,15 +23,22 @@ declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
22
23
  /** Outcome — value object: the attempt failed, with the typed failure that closed it. */
23
24
  export declare class Failed extends Failed_base {
24
25
  }
25
- export declare const Outcome: Schema.Union<readonly [typeof Succeeded, typeof Failed]>;
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]>;
26
31
  export type Outcome = typeof Outcome.Type;
27
32
  declare const Attempt_base: Schema.Class<Attempt, Schema.Struct<{
28
33
  readonly id: Schema.brand<Schema.NonEmptyString, "AttemptId">;
29
34
  readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
30
35
  readonly stepName: Schema.brand<Schema.NonEmptyString, "StepName">;
36
+ readonly worker: Schema.brand<Schema.String, "WorkerName">;
31
37
  readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
38
+ readonly brain: typeof BrainSpec;
39
+ readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
32
40
  readonly startedAt: Schema.DateTimeUtc;
33
- readonly outcome: Schema.Option<Schema.Union<readonly [typeof Succeeded, typeof Failed]>>;
41
+ readonly outcome: Schema.Option<Schema.Union<readonly [typeof Succeeded, typeof Failed, typeof Canceled]>>;
34
42
  }>, {}>;
35
43
  /**
36
44
  * Entity — ledger row: one try of a step on a worker. `outcome` is none while
@@ -1 +1 @@
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;AAIvE;;GAEG;AACH,eAAO,M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AO,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"}
@@ -2,6 +2,8 @@ import { Schema } from "effect";
2
2
  import { AttemptFailure, isAutoRetryable } from "./attempt-failure.js";
3
3
  import { RunId } from "./run.js";
4
4
  import { StepName } from "./step.js";
5
+ import { BrainSpec, ModelId } from "../agent.js";
6
+ import { Name as WorkerName } from "../worker.js";
5
7
  /**
6
8
  * Value object (branded id): identity of one Attempt.
7
9
  */
@@ -20,7 +22,10 @@ export class Failed extends Schema.TaggedClass("AttemptOutcome/Failed")("Failed"
20
22
  failure: AttemptFailure,
21
23
  }) {
22
24
  }
23
- export const Outcome = Schema.Union([Succeeded, Failed]);
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]);
24
29
  /**
25
30
  * Entity — ledger row: one try of a step on a worker. `outcome` is none while
26
31
  * the attempt is in flight.
@@ -29,7 +34,10 @@ export class Attempt extends Schema.Class("Attempt")({
29
34
  id: AttemptId,
30
35
  runId: RunId,
31
36
  stepName: StepName,
37
+ worker: WorkerName,
32
38
  number: AttemptNumber,
39
+ brain: BrainSpec,
40
+ parentModel: Schema.OptionFromNullOr(ModelId),
33
41
  startedA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AC,CAAC,QAAQ,EAAE;IACxF,OAAO,EAAE,cAAc;CACxB,CAAC;CAAG;AAEL,iFAAiF;AACjF,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,WAAW,CAAW,yBAAyB,CAAC,CACnF,UAAU,EACV,EAAE,CACH;CAAG;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;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"}
@@ -14,7 +14,7 @@ export type DedupKey = typeof DedupKey.Type;
14
14
  declare const Event_base: Schema.Class<Event, Schema.Struct<{
15
15
  readonly id: Schema.brand<Schema.NonEmptyString, "EventId">;
16
16
  readonly dedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
17
- readonly payload: Schema.Unknown;
17
+ readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
18
18
  readonly receivedAt: Schema.DateTimeUtc;
19
19
  }>, {}>;
20
20
  /**
@@ -19,7 +19,7 @@ export const DedupKey = Schema.NonEmptyString.pipe(Schema.brand("DedupKey"));
19
19
  export class Event extends Schema.Class("Event")({
20
20
  id: EventId,
21
21
  dedupKey: DedupKey,
22
- payload: Schema.Unknown,
22
+ payload: Schema.Json,
23
23
  receivedAt: Schema.DateTimeUtc,
24
24
  }) {
25
25
  }
@@ -1 +1 @@
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,OAAO;IACvB,UAAU,EAAE,MAAM,CAAC,WAAW;CAC/B,CAAC;CAAG"}
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"}
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,9 @@
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 const ItemKey = Schema.NonEmptyString.pipe(Schema.brand("ItemKey"));
7
+ /** Positive repository-local number for an issue-like Item. */
8
+ export const Number = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("ItemNumber"));
9
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../../src/lifecycle/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAG3E,+DAA+D;AAC/D,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC3E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAC3B,CAAC"}
@@ -6,4 +6,12 @@ import { Schema } from "effect";
6
6
  */
7
7
  export declare const LoopName: Schema.brand<Schema.NonEmptyString, "LoopName">;
8
8
  export type LoopName = typeof LoopName.Type;
9
+ /**
10
+ * Value object: whether a loop parks new runs until an approval Event arrives
11
+ * (ADR 0004's `approval:` field, default none). One owner for the literal set
12
+ * the config parser accepts and the engine routes on.
13
+ */
14
+ export declare const APPROVAL_REQUIREMENTS: readonly ["none", "required"];
15
+ export declare const ApprovalRequirement: Schema.Literals<readonly ["none", "required"]>;
16
+ export type ApprovalRequirement = typeof ApprovalRequirement.Type;
9
17
  //# sourceMappingURL=loop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC"}
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YAAI,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,eAAO,MAAM,mBAAmB,gDAAyC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAC"}
@@ -5,4 +5,11 @@ import { Schema } from "effect";
5
5
  * (ADR 0001).
6
6
  */
7
7
  export const LoopName = Schema.NonEmptyString.pipe(Schema.brand("LoopName"));
8
+ /**
9
+ * Value object: whether a loop parks new runs until an approval Event arrives
10
+ * (ADR 0004's `approval:` field, default none). One owner for the literal set
11
+ * the config parser accepts and the engine routes on.
12
+ */
13
+ export const APPROVAL_REQUIREMENTS = ["none", "required"];
14
+ export const ApprovalRequirement = Schema.Literals(APPROVAL_REQUIREMENTS);
8
15
  //# sourceMappingURL=loop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC"}
@@ -82,6 +82,15 @@ export type Open = typeof Open.Type;
82
82
  export declare const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>;
83
83
  export type RunState = typeof RunState.Type;
84
84
  export declare const isOpen: <I>(input: I) => input is I & (Pending | Running | Waiting);
85
+ /** The open partition as `_tag` literals, for queries that filter stored rows by state. */
86
+ export declare const OPEN_STATE_TAGS: readonly ["Pending", "Waiting", "Running"];
87
+ /** Every state as `_tag` literals, for read models that project stored rows by state. */
88
+ export declare const STATE_TAGS: readonly ["Pending", "Waiting", "Running", "Succeeded", "Failed", "Canceled"];
89
+ /**
90
+ * The states with no started attempt, as `_tag` literals — the precondition
91
+ * of `supersede` and `revoke`, for queries that filter stored rows by state.
92
+ */
93
+ export declare const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting"];
85
94
  /** pending → waiting: park the run on its loop's approval gate. */
86
95
  export declare const awaitApproval: (_state: Pending) => Waiting;
87
96
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"run-state.d.ts","sourceRoot":"","sources":["../../src/lifecycle/run-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;;AAErC,yEAAyE;AACzE,qBAAa,gBAAiB,SAAQ,qBAEb;CAAG;;;;AAE5B;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAG/B;CAAG;;AAEJ;;;;GAIG;AACH,qBAAa,OAAQ,SAAQ,YAAkE;CAAG;AAElG,eAAO,MAAM,YAAY,qFAAwD,CAAC;AAClF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;;AAEpD,uEAA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E,eAAO,MAAM,aAAa,WAAY,OAAO,KAAG,OAAwB,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,KAAK,WAAY,OAAO,GAAG,OAAO,KAAG,OAAwB,CAAC;AAE3E,+EAA+E;AAC/E,eAAO,MAAM,OAAO,WAAY,OAAO,KAAG,SAA4B,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,IAAI,WAAY,OAAO,KAAG,MAAsB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,OAAwB,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,IAAI,KAAG,QACE,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,WAAY,OAAO,GAAG,OAAO,MAAM,OAAO,KAAG,QACjB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,MAAM,WAAY,OAAO,GAAG,OAAO,KAAG,QACV,CAAC"}
@@ -68,6 +68,23 @@ export class Canceled extends Schema.TaggedClass("RunState/Canceled")("Canceled"
68
68
  export const Open = Schema.Union([Pending, Waiting, Running]);
69
69
  export const RunState = Schema.Union([...Open.members, Succeeded, Failed, Canceled]);
70
70
  export const isOpen = Schema.is(Open);
71
+ /**
72
+ * Compile-checked tag tuple over a state partition: the argument list must
73
+ * name every `_tag` of `State` and nothing else. A foreign tag fails the
74
+ * `Tags` constraint; a missing tag collapses the parameters to `[never]`, so
75
+ * the call stops compiling. This keeps the unions above the single owner of
76
+ * each partition while read-side SQL gets a value-level tag list.
77
+ */
78
+ const tagsOf = () => (...tags) => tags;
79
+ /** The open partition as `_tag` literals, for queries that filter stored rows by state. */
80
+ export const OPEN_STATE_TAGS = tagsOf()("Pending", "Waiting", "Running");
81
+ /** Every state as `_tag` literals, for read models that project stored rows by state. */
82
+ export const STATE_TAGS = tagsOf()("Pending", "Waiting", "Running", "Succeeded", "Failed", "Canceled");
83
+ /**
84
+ * The states with no started attempt, as `_tag` literals — the precondition
85
+ * of `supersede` and `revoke`, for queries that filter stored rows by state.
86
+ */
87
+ export const UNSTARTED_STATE_TAGS = tagsOf()("Pending", "Waiting");
71
88
  /** pending → waiting: park the run on its loop's approval gate. */
72
89
  export const awaitApproval = (_state) => new Waiting();
73
90
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../src/lifecycle/run-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,yEAAyE;AACzE,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,CACtD,+BAA+B,CAChC,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAAG;AAE5B;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAa,yBAAyB,CAAC,CACvF,YAAY,EACZ,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;CAAG;AAEJ;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,sBAAsB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAElG,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAGlF,uEAAuE;AACvE,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,kBAAkB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAE9F;;;GAGG;AACH,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,kBAAkB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAE9F,iDAAiD;AACjD,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,kBAAkB,CAAC,CAAC,SA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AI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAyB,EAAY,EAAE,CAC5D,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import { StepResult } from "../step-result.ts";
2
3
  /**
3
4
  * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
4
5
  * step in the loop file retires it — prior results stay under the old name.
@@ -9,7 +10,7 @@ export type StepName = typeof StepName.Type;
9
10
  declare const Step_base: Schema.Class<Step, Schema.Struct<{
10
11
  readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
11
12
  readonly name: Schema.brand<Schema.NonEmptyString, "StepName">;
12
- readonly result: Schema.Option<Schema.String>;
13
+ readonly result: Schema.Option<typeof StepResult>;
13
14
  }>, {}>;
14
15
  /**
15
16
  * Entity — ledger row: a named unit of work inside a run, its stored result addressable by name;
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;AAE5C;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,SAIxB;CAAG"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;AAE5C;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,SAIxB;CAAG"}
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import { StepResult } from "../step-result.js";
2
3
  import { RunId } from "./run.js";
3
4
  /**
4
5
  * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
@@ -14,7 +15,7 @@ export const StepName = Schema.NonEmptyString.pipe(Schema.brand("StepName"));
14
15
  export class Step extends Schema.Class("Step")({
15
16
  runId: RunId,
16
17
  name: StepName,
17
- result: Schema.Option(Schema.String),
18
+ result: Schema.Option(StepResult),
18
19
  }) {
19
20
  }
20
21
  //# sourceMappingURL=step.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,OAAO,IAAK,SAAQ,MAAM,CAAC,KAAK,CAAO,MAAM,CAAC,CAAC;IACnD,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;CACrC,CAAC;CAAG"}
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,OAAO,IAAK,SAAQ,MAAM,CAAC,KAAK,CAAO,MAAM,CAAC,CAAC;IACnD,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;CAClC,CAAC;CAAG"}
@@ -0,0 +1,26 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Value object: the stable `owner/name` identity shared by the registry and
4
+ * every GitHub-facing block. The original casing is significant to display;
5
+ * GitHub comparisons are handled separately at the adapter boundary.
6
+ */
7
+ export declare const Name: Schema.brand<Schema.String, "RepoName">;
8
+ export type Name = typeof Name.Type;
9
+ /**
10
+ * Value object: a git revision resolved when an Attempt workspace is created.
11
+ * Revisions reach `git fetch` as bare arguments, so a leading `-` (which git
12
+ * would parse as an option) and whitespace are unrepresentable by the brand.
13
+ */
14
+ export declare const Revision: Schema.brand<Schema.String, "RepositoryRevision">;
15
+ export type Revision = typeof Revision.Type;
16
+ /** Value object: a git object id harvested from an Attempt workspace. */
17
+ export declare const CommitSha: Schema.brand<Schema.String, "CommitSha">;
18
+ export type CommitSha = typeof CommitSha.Type;
19
+ /** The `owner` and `name` halves of a full repo name; the brand proves the separator exists. */
20
+ export declare const parts: (repository: Name) => {
21
+ readonly owner: string;
22
+ readonly name: string;
23
+ };
24
+ /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
25
+ export declare const canonical: (repository: Name) => string;
26
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,IAAI,yCAIe,CAAC;AACjC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,mDAIqB,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,SAAS,0CAIW,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,gGAAgG;AAChG,eAAO,MAAM,KAAK,eAAgB,IAAI;aAGlC,KAAK;aACL,IAAI;CAEP,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,SAAS,eAAgB,IAAI,KAAG,MAAkC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Value object: the stable `owner/name` identity shared by the registry and
4
+ * every GitHub-facing block. The original casing is significant to display;
5
+ * GitHub comparisons are handled separately at the adapter boundary.
6
+ */
7
+ export const Name = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
8
+ message: "Expected a full GitHub repo name (owner/name)",
9
+ })).pipe(Schema.brand("RepoName"));
10
+ /**
11
+ * Value object: a git revision resolved when an Attempt workspace is created.
12
+ * Revisions reach `git fetch` as bare arguments, so a leading `-` (which git
13
+ * would parse as an option) and whitespace are unrepresentable by the brand.
14
+ */
15
+ export const Revision = Schema.String.check(Schema.isPattern(/^[^\s-]\S*$/u, {
16
+ message: "Expected a git revision without whitespace or a leading dash",
17
+ })).pipe(Schema.brand("RepositoryRevision"));
18
+ /** Value object: a git object id harvested from an Attempt workspace. */
19
+ export const CommitSha = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u, {
20
+ message: "Expected a 40- or 64-character lowercase git object id",
21
+ })).pipe(Schema.brand("CommitSha"));
22
+ /** The `owner` and `name` halves of a full repo name; the brand proves the separator exists. */
23
+ export const parts = (repository) => {
24
+ const separator = repository.indexOf("/");
25
+ return {
26
+ owner: repository.slice(0, separator),
27
+ name: repository.slice(separator + 1),
28
+ };
29
+ };
30
+ /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
31
+ export const canonical = (repository) => repository.toLowerCase();
32
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACrC,MAAM,CAAC,SAAS,CAAC,qCAAqC,EAAE;IACtD,OAAO,EAAE,+CAA+C;CACzD,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAGjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACzC,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE;IAC/B,OAAO,EAAE,8DAA8D;CACxE,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAG3C,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC1C,MAAM,CAAC,SAAS,CAAC,kCAAkC,EAAE;IACnD,OAAO,EAAE,wDAAwD;CAClE,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAGlC,gGAAgG;AAChG,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,UAAgB,EAAE,EAAE;IACxC,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;QACrC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;KAC7B,CAAC;AACb,CAAC,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAgB,EAAU,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { Schema } from "effect";
2
+ declare const Commit_base: Schema.Class<Commit, Schema.TaggedStruct<"Commit", {
3
+ readonly sha: Schema.brand<Schema.String, "CommitSha">;
4
+ readonly summary: Schema.NonEmptyString;
5
+ }>, {}>;
6
+ /** A commit the run host found between the workspace base and final HEAD. */
7
+ export declare class Commit extends Commit_base {
8
+ }
9
+ declare const PullRequest_base: Schema.Class<PullRequest, Schema.TaggedStruct<"PullRequest", {
10
+ readonly number: Schema.Int;
11
+ readonly url: Schema.URL;
12
+ }>, {}>;
13
+ /** A pull request the agent created or updated during the Attempt. */
14
+ export declare class PullRequest extends PullRequest_base {
15
+ }
16
+ declare const Comment_base: Schema.Class<Comment, Schema.TaggedStruct<"Comment", {
17
+ readonly url: Schema.URL;
18
+ }>, {}>;
19
+ /** A GitHub comment the agent created or updated during the Attempt. */
20
+ export declare class Comment extends Comment_base {
21
+ }
22
+ export declare const Fact: Schema.Union<readonly [typeof Commit, typeof PullRequest, typeof Comment]>;
23
+ export type Fact = typeof Fact.Type;
24
+ declare const StepResult_base: Schema.Class<StepResult, Schema.Struct<{
25
+ readonly message: Schema.NonEmptyString;
26
+ readonly facts: Schema.$Array<Schema.Union<readonly [typeof Commit, typeof PullRequest, typeof Comment]>>;
27
+ }>, {}>;
28
+ /**
29
+ * The Step result carried by the run host's final envelope: the agent's final
30
+ * message plus durable facts that survive workspace cleanup.
31
+ */
32
+ export declare class StepResult extends StepResult_base {
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=step-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-result.d.ts","sourceRoot":"","sources":["../src/step-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAGhC,6EAA6E;AAC7E,qBAAa,MAAO,SAAQ,WAG1B;CAAG;;;;;AAEL,sEAAsE;AACtE,qBAAa,WAAY,SAAQ,gBAMhC;CAAG;;;;AAEJ,wEAAwE;AACxE,qBAAa,OAAQ,SAAQ,YAE3B;CAAG;AAEL,eAAO,MAAM,IAAI,4EAA+C,CAAC;AACjE,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;;;;;AAEpC;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAG9B;CAAG"}
@@ -0,0 +1,30 @@
1
+ import { Schema } from "effect";
2
+ import { CommitSha } from "./repository.js";
3
+ /** A commit the run host found between the workspace base and final HEAD. */
4
+ export class Commit extends Schema.TaggedClass("StepResult/Commit")("Commit", {
5
+ sha: CommitSha,
6
+ summary: Schema.NonEmptyString,
7
+ }) {
8
+ }
9
+ /** A pull request the agent created or updated during the Attempt. */
10
+ export class PullRequest extends Schema.TaggedClass("StepResult/PullRequest")("PullRequest", {
11
+ number: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
12
+ url: Schema.URL,
13
+ }) {
14
+ }
15
+ /** A GitHub comment the agent created or updated during the Attempt. */
16
+ export class Comment extends Schema.TaggedClass("StepResult/Comment")("Comment", {
17
+ url: Schema.URL,
18
+ }) {
19
+ }
20
+ export const Fact = Schema.Union([Commit, PullRequest, Comment]);
21
+ /**
22
+ * The Step result carried by the run host's final envelope: the agent's final
23
+ * message plus durable facts that survive workspace cleanup.
24
+ */
25
+ export class StepResult extends Schema.Class("StepResult")({
26
+ message: Schema.NonEmptyString,
27
+ facts: Schema.Array(Fact),
28
+ }) {
29
+ }
30
+ //# sourceMappingURL=step-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-result.js","sourceRoot":"","sources":["../src/step-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,OAAO,MAAO,SAAQ,MAAM,CAAC,WAAW,CAAS,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IACpF,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC;CAAG;AAEL,sEAAsE;AACtE,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,CAAc,wBAAwB,CAAC,CACxF,aAAa,EACb;IACE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAC1D,GAAG,EAAE,MAAM,CAAC,GAAG;CAChB,CACF;CAAG;AAEJ,wEAAwE;AACxE,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,oBAAoB,CAAC,CAAC,SAAS,EAAE;IACxF,GAAG,EAAE,MAAM,CAAC,GAAG;CAChB,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAGjE;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,KAAK,CAAa,YAAY,CAAC,CAAC;IACrE,OAAO,EAAE,MAAM,CAAC,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;CAC1B,CAAC;CAAG"}
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /** The engine-owned Worker adapters available to an instance. */
3
+ export declare const KINDS: readonly ["local", "exe.dev"];
4
+ export declare const Kind: Schema.Literals<readonly ["local", "exe.dev"]>;
5
+ export type Kind = typeof Kind.Type;
6
+ /** Value object: the name-keyed identity of a configured Worker. */
7
+ export declare const Name: Schema.brand<Schema.String, "WorkerName">;
8
+ export type Name = typeof Name.Type;
9
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,iEAAiE;AACjE,eAAO,MAAM,KAAK,YAAI,OAAO,EAAE,SAAS,CAAU,CAAC;AACnD,eAAO,MAAM,IAAI,gDAAyB,CAAC;AAC3C,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAEpC,oEAAoE;AACpE,eAAO,MAAM,IAAI,2CAIiB,CAAC;AACnC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC"}
package/dist/worker.js ADDED
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /** The engine-owned Worker adapters available to an instance. */
3
+ export const KINDS = ["local", "exe.dev"];
4
+ export const Kind = Schema.Literals(KINDS);
5
+ /** Value object: the name-keyed identity of a configured Worker. */
6
+ export const Name = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, {
7
+ message: "Expected a kebab-case Worker name",
8
+ })).pipe(Schema.brand("WorkerName"));
9
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,iEAAiE;AACjE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AACnD,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAG3C,oEAAoE;AACpE,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACrC,MAAM,CAAC,SAAS,CAAC,6BAA6B,EAAE;IAC9C,OAAO,EAAE,mCAAmC;CAC7C,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usine/core",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Domain model for usine: Event → Run → Step → Attempt, branded ids, the run state machine, and the typed attempt-failure taxonomy.",
5
5
  "license": "MIT",
6
6
  "repository": {