@usine/core 0.0.0 → 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.
- package/LICENSE +21 -0
- package/README.md +29 -1
- package/dist/agent.d.ts +121 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +105 -0
- package/dist/agent.js.map +1 -0
- package/dist/attempt-channel.d.ts +134 -0
- package/dist/attempt-channel.d.ts.map +1 -0
- package/dist/attempt-channel.js +138 -0
- package/dist/attempt-channel.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/instance.d.ts +9 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +8 -0
- package/dist/instance.js.map +1 -0
- package/dist/lifecycle/attempt-failure.d.ts +51 -0
- package/dist/lifecycle/attempt-failure.d.ts.map +1 -0
- package/dist/lifecycle/attempt-failure.js +45 -0
- package/dist/lifecycle/attempt-failure.js.map +1 -0
- package/dist/lifecycle/attempt.d.ts +61 -0
- package/dist/lifecycle/attempt.d.ts.map +1 -0
- package/dist/lifecycle/attempt.js +52 -0
- package/dist/lifecycle/attempt.js.map +1 -0
- package/dist/lifecycle/event.d.ts +30 -0
- package/dist/lifecycle/event.d.ts.map +1 -0
- package/dist/lifecycle/event.js +26 -0
- package/dist/lifecycle/event.js.map +1 -0
- package/dist/lifecycle/item.d.ts +11 -0
- package/dist/lifecycle/item.d.ts.map +1 -0
- package/dist/lifecycle/item.js +9 -0
- package/dist/lifecycle/item.js.map +1 -0
- package/dist/lifecycle/loop.d.ts +17 -0
- package/dist/lifecycle/loop.d.ts.map +1 -0
- package/dist/lifecycle/loop.js +15 -0
- package/dist/lifecycle/loop.js.map +1 -0
- package/dist/lifecycle/run-state.d.ts +133 -0
- package/dist/lifecycle/run-state.d.ts.map +1 -0
- package/dist/lifecycle/run-state.js +126 -0
- package/dist/lifecycle/run-state.js.map +1 -0
- package/dist/lifecycle/run.d.ts +22 -0
- package/dist/lifecycle/run.d.ts.map +1 -0
- package/dist/lifecycle/run.js +22 -0
- package/dist/lifecycle/run.js.map +1 -0
- package/dist/lifecycle/step.d.ts +23 -0
- package/dist/lifecycle/step.d.ts.map +1 -0
- package/dist/lifecycle/step.js +21 -0
- package/dist/lifecycle/step.js.map +1 -0
- package/dist/repository.d.ts +26 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +32 -0
- package/dist/repository.js.map +1 -0
- package/dist/step-result.d.ts +35 -0
- package/dist/step-result.d.ts.map +1 -0
- package/dist/step-result.js +30 -0
- package/dist/step-result.js.map +1 -0
- package/dist/worker.d.ts +9 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +9 -0
- package/dist/worker.js.map +1 -0
- package/package.json +40 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Philippe L'ATTENTION
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# @usine/core
|
|
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, plus shared instance and repository value objects.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
## What each export is
|
|
8
|
+
|
|
9
|
+
| Export | Kind |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `Event`, `Run`, `Step`, `Attempt` | Entities — the four ledger rows, identity plus validated construction |
|
|
12
|
+
| `EventId`, `RunId`, `AttemptId` | Value objects — branded ids; identities that cannot be swapped for each other |
|
|
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 |
|
|
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 |
|
|
22
|
+
| `InfraFailure`, `AgentFailure`, `RunawayFailure` | Typed errors — the attempt-failure taxonomy |
|
|
23
|
+
| `AttemptFailure.isAutoRetryable`, `Attempt.shouldAutoRetry` | Derivers — pure decision functions stating the auto-retry law (class rule; class rule capped by attempt count) |
|
|
24
|
+
|
|
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).
|
|
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
|
+
|
|
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.
|
package/dist/agent.d.ts
ADDED
|
@@ -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,M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;;;;;;AAEL,qBAAa,WAAY,SAAQ,gBAQhC;CAAG;;;;;;;;AAEJ,qBAAa,YAAa,SAAQ,iBASjC;CAAG;;;;AAEJ,qBAAa,eAAgB,SAAQ,oBAGpC;CAAG;AAEJ,gFAAgF;AAChF,eAAO,MAAM,IAAI,oEAAqE,CAAC;AACvF,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;;;;;;AAEpC,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;;;;AAEL,qBAAa,kBAAmB,SAAQ,uBAOtC;CAAG;;;;;;AAEL,2EAA2E;AAC3E,qBAAa,qBAAsB,SAAQ,0BAMzC;CAAG;AAEL,uEAAuE;AACvE,eAAO,MAAM,YAAY,kKAOvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAEpD,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,UACtB,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,c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,WAAW;IACX,YAAY;IACZ,qBAAqB;IACrB,eAAe;CAChB,CAAC,CAAC;AAGH,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAY,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;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C;;;;GAI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AsE;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,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM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}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @usine/core — domain model for usine (ADR 0002, ADR 0013).
|
|
3
|
+
*
|
|
4
|
+
* `lifecycle/` is the run-lifecycle cluster: how one piece of work moves
|
|
5
|
+
* through the engine — a deduplicated Event opens a Run, the Run's named Step
|
|
6
|
+
* is tried as Attempts, and the state machine closes it. Entities are the
|
|
7
|
+
* ledger rows (Event, Run, Step, Attempt); everything else is value objects,
|
|
8
|
+
* typed errors, and pure derivers — each module docblock names its kind.
|
|
9
|
+
*/
|
|
10
|
+
export * as Instance from "./instance.ts";
|
|
11
|
+
export * as Agent from "./agent.ts";
|
|
12
|
+
export * as Repository from "./repository.ts";
|
|
13
|
+
export * as AttemptChannel from "./attempt-channel.ts";
|
|
14
|
+
export * as StepResult from "./step-result.ts";
|
|
15
|
+
export * as Worker from "./worker.ts";
|
|
16
|
+
export * as Attempt from "./lifecycle/attempt.ts";
|
|
17
|
+
export * as AttemptFailure from "./lifecycle/attempt-failure.ts";
|
|
18
|
+
export * as Event from "./lifecycle/event.ts";
|
|
19
|
+
export * as Item from "./lifecycle/item.ts";
|
|
20
|
+
export * as Loop from "./lifecycle/loop.ts";
|
|
21
|
+
export * as Run from "./lifecycle/run.ts";
|
|
22
|
+
export * as RunState from "./lifecycle/run-state.ts";
|
|
23
|
+
export * as Step from "./lifecycle/step.ts";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @usine/core — domain model for usine (ADR 0002, ADR 0013).
|
|
3
|
+
*
|
|
4
|
+
* `lifecycle/` is the run-lifecycle cluster: how one piece of work moves
|
|
5
|
+
* through the engine — a deduplicated Event opens a Run, the Run's named Step
|
|
6
|
+
* is tried as Attempts, and the state machine closes it. Entities are the
|
|
7
|
+
* ledger rows (Event, Run, Step, Attempt); everything else is value objects,
|
|
8
|
+
* typed errors, and pure derivers — each module docblock names its kind.
|
|
9
|
+
*/
|
|
10
|
+
export * as Instance from "./instance.js";
|
|
11
|
+
export * as Agent from "./agent.js";
|
|
12
|
+
export * as Repository from "./repository.js";
|
|
13
|
+
export * as AttemptChannel from "./attempt-channel.js";
|
|
14
|
+
export * as StepResult from "./step-result.js";
|
|
15
|
+
export * as Worker from "./worker.js";
|
|
16
|
+
export * as Attempt from "./lifecycle/attempt.js";
|
|
17
|
+
export * as AttemptFailure from "./lifecycle/attempt-failure.js";
|
|
18
|
+
export * as Event from "./lifecycle/event.js";
|
|
19
|
+
export * as Item from "./lifecycle/item.js";
|
|
20
|
+
export * as Loop from "./lifecycle/loop.js";
|
|
21
|
+
export * as Run from "./lifecycle/run.js";
|
|
22
|
+
export * as RunState from "./lifecycle/run-state.js";
|
|
23
|
+
export * as Step from "./lifecycle/step.js";
|
|
24
|
+
//# sourceMappingURL=index.js.map
|