@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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -1
  3. package/dist/agent.d.ts +121 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +105 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/attempt-channel.d.ts +134 -0
  8. package/dist/attempt-channel.d.ts.map +1 -0
  9. package/dist/attempt-channel.js +138 -0
  10. package/dist/attempt-channel.js.map +1 -0
  11. package/dist/index.d.ts +24 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +24 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/instance.d.ts +9 -0
  16. package/dist/instance.d.ts.map +1 -0
  17. package/dist/instance.js +8 -0
  18. package/dist/instance.js.map +1 -0
  19. package/dist/lifecycle/attempt-failure.d.ts +51 -0
  20. package/dist/lifecycle/attempt-failure.d.ts.map +1 -0
  21. package/dist/lifecycle/attempt-failure.js +45 -0
  22. package/dist/lifecycle/attempt-failure.js.map +1 -0
  23. package/dist/lifecycle/attempt.d.ts +61 -0
  24. package/dist/lifecycle/attempt.d.ts.map +1 -0
  25. package/dist/lifecycle/attempt.js +52 -0
  26. package/dist/lifecycle/attempt.js.map +1 -0
  27. package/dist/lifecycle/event.d.ts +30 -0
  28. package/dist/lifecycle/event.d.ts.map +1 -0
  29. package/dist/lifecycle/event.js +26 -0
  30. package/dist/lifecycle/event.js.map +1 -0
  31. package/dist/lifecycle/item.d.ts +11 -0
  32. package/dist/lifecycle/item.d.ts.map +1 -0
  33. package/dist/lifecycle/item.js +9 -0
  34. package/dist/lifecycle/item.js.map +1 -0
  35. package/dist/lifecycle/loop.d.ts +17 -0
  36. package/dist/lifecycle/loop.d.ts.map +1 -0
  37. package/dist/lifecycle/loop.js +15 -0
  38. package/dist/lifecycle/loop.js.map +1 -0
  39. package/dist/lifecycle/run-state.d.ts +133 -0
  40. package/dist/lifecycle/run-state.d.ts.map +1 -0
  41. package/dist/lifecycle/run-state.js +126 -0
  42. package/dist/lifecycle/run-state.js.map +1 -0
  43. package/dist/lifecycle/run.d.ts +22 -0
  44. package/dist/lifecycle/run.d.ts.map +1 -0
  45. package/dist/lifecycle/run.js +22 -0
  46. package/dist/lifecycle/run.js.map +1 -0
  47. package/dist/lifecycle/step.d.ts +23 -0
  48. package/dist/lifecycle/step.d.ts.map +1 -0
  49. package/dist/lifecycle/step.js +21 -0
  50. package/dist/lifecycle/step.js.map +1 -0
  51. package/dist/repository.d.ts +26 -0
  52. package/dist/repository.d.ts.map +1 -0
  53. package/dist/repository.js +32 -0
  54. package/dist/repository.js.map +1 -0
  55. package/dist/step-result.d.ts +35 -0
  56. package/dist/step-result.d.ts.map +1 -0
  57. package/dist/step-result.js +30 -0
  58. package/dist/step-result.js.map +1 -0
  59. package/dist/worker.d.ts +9 -0
  60. package/dist/worker.d.ts.map +1 -0
  61. package/dist/worker.js +9 -0
  62. package/dist/worker.js.map +1 -0
  63. package/package.json +40 -4
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The run state machine (ADR 0002):
3
+ *
4
+ * pending ──────────────► running ──► succeeded
5
+ * │ ▲ │
6
+ * ▼ │ ▼
7
+ * waiting ────────────────┘ failed ──► (retry: attempt N+1) ──► running
8
+ *
9
+ * pending | waiting | running ──► canceled (operator cancel)
10
+ * pending | waiting ──► canceled (supersede, revoke — a started
11
+ * attempt always finishes, ADR 0007)
12
+ *
13
+ * States are value objects (a discriminated union, each state carrying exactly
14
+ * its own data). Transitions are typestate derivers: each function accepts
15
+ * only the states it is legal on, so an illegal transition is a compile
16
+ * error. Construct states through these transitions (or by parsing a stored
17
+ * row via the `RunState` union) — they are the state machine.
18
+ */
19
+ import { Schema } from "effect";
20
+ import { EventId } from "./event.js";
21
+ /** Cancel reason — value object: the operator closed the run by hand. */
22
+ export class OperatorCanceled extends Schema.TaggedClass("CancelReason/OperatorCanceled")("OperatorCanceled", {}) {
23
+ }
24
+ /**
25
+ * Cancel reason — value object: a newer Event for the same Item took the
26
+ * run's place before any attempt started.
27
+ */
28
+ export class Superseded extends Schema.TaggedClass("CancelReason/Superseded")("Superseded", { by: EventId }) {
29
+ }
30
+ /**
31
+ * Cancel reason — value object: the run's Item stopped matching its loop's
32
+ * trigger before any attempt started. Distinct from operator cancel and from
33
+ * supersede.
34
+ */
35
+ export class Revoked extends Schema.TaggedClass("CancelReason/Revoked")("Revoked", {}) {
36
+ }
37
+ export const CancelReason = Schema.Union([OperatorCanceled, Superseded, Revoked]);
38
+ /** Open: just created; no attempt started, no approval gate passed. */
39
+ export class Pending extends Schema.TaggedClass("RunState/Pending")("Pending", {}) {
40
+ }
41
+ /**
42
+ * Open: parked on its loop's approval gate — v1's only waiting reason. The
43
+ * approval it consumes is an Event like every other fact.
44
+ */
45
+ export class Waiting extends Schema.TaggedClass("RunState/Waiting")("Waiting", {}) {
46
+ }
47
+ /** Open: an attempt is executing on a worker. */
48
+ export class Running extends Schema.TaggedClass("RunState/Running")("Running", {}) {
49
+ }
50
+ /** Closed: the step finished and its result is stored. */
51
+ export class Succeeded extends Schema.TaggedClass("RunState/Succeeded")("Succeeded", {}) {
52
+ }
53
+ /**
54
+ * Closed, but reopenable: the last attempt failed and no auto-retry applies.
55
+ * The failure itself lives on the Attempt.
56
+ */
57
+ export class Failed extends Schema.TaggedClass("RunState/Failed")("Failed", {}) {
58
+ }
59
+ /** Closed: canceled, with the reason recorded. */
60
+ export class Canceled extends Schema.TaggedClass("RunState/Canceled")("Canceled", {
61
+ reason: CancelReason,
62
+ }) {
63
+ }
64
+ /**
65
+ * The open half of the machine — the single statement of the open/closed
66
+ * partition; the alias, the guard, and the full union all derive from it.
67
+ */
68
+ export const Open = Schema.Union([Pending, Waiting, Running]);
69
+ export const RunState = Schema.Union([...Open.members, Succeeded, Failed, Canceled]);
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");
88
+ /** pending → waiting: park the run on its loop's approval gate. */
89
+ export const awaitApproval = (_state) => new Waiting();
90
+ /**
91
+ * pending | waiting → running: the first attempt starts. From waiting, the
92
+ * engine consumes the approval Event that opens the gate.
93
+ */
94
+ export const start = (_state) => new Running();
95
+ /** running → succeeded: the attempt finished and the step result is stored. */
96
+ export const succeed = (_state) => new Succeeded();
97
+ /**
98
+ * running → failed: the attempt failed and no auto-retry applies — the engine
99
+ * discharges that precondition with `Attempt.shouldAutoRetry`, the one owner
100
+ * of the auto-retry law.
101
+ */
102
+ export const fail = (_state) => new Failed();
103
+ /**
104
+ * failed → running: operator retry. The next try is a new Attempt (N+1) under
105
+ * the same Step, never a new run.
106
+ */
107
+ export const retry = (_state) => new Running();
108
+ /**
109
+ * open → canceled: the operator's act, reachable from every open state —
110
+ * named by cause like its siblings; supersede and revoke are the other two
111
+ * roads into Canceled.
112
+ */
113
+ export const cancelByOperator = (_state) => new Canceled({ reason: new OperatorCanceled() });
114
+ /**
115
+ * pending | waiting → canceled: a newer Event for the same Item takes this
116
+ * run's place. Only runs with no started attempt can be superseded — a running
117
+ * attempt always finishes, and the newer state is judged again when it ends
118
+ * (ADR 0007).
119
+ */
120
+ export const supersede = (_state, by) => new Canceled({ reason: new Superseded({ by }) });
121
+ /**
122
+ * pending | waiting → canceled: the run's Item stopped matching its loop's
123
+ * trigger. Never touches a running attempt.
124
+ */
125
+ export const revoke = (_state) => new Canceled({ reason: new Revoked() });
126
+ //# sourceMappingURL=run-state.js.map
@@ -0,0 +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,OAA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">;
6
+ export type RunId = typeof RunId.Type;
7
+ declare const Run_base: Schema.Class<Run, Schema.Struct<{
8
+ readonly id: Schema.brand<Schema.NonEmptyString, "RunId">;
9
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
10
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
11
+ readonly state: Schema.Union<readonly [typeof import("./run-state.ts").Pending, typeof import("./run-state.ts").Waiting, typeof import("./run-state.ts").Running, typeof import("./run-state.ts").Succeeded, typeof import("./run-state.ts").Failed, typeof import("./run-state.ts").Canceled]>;
12
+ readonly openedAt: Schema.DateTimeUtc;
13
+ }>, {}>;
14
+ /**
15
+ * Entity — ledger row: the work a loop owes one Event. At most one open run
16
+ * exists per dedup key, ever — the Event owns the key; the engine's ledger
17
+ * enforces the invariant (ADR 0002).
18
+ */
19
+ export declare class Run extends Run_base {
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/lifecycle/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC;;GAEG;AACH,eAAO,MAAM,KAAK,8CAAoD,CAAC;AACvE,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;;;;;;;;AAEtC;;;;GAIG;AACH,qBAAa,GAAI,SAAQ,QAMvB;CAAG"}
@@ -0,0 +1,22 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "./event.js";
3
+ import { LoopName } from "./loop.js";
4
+ import { RunState } from "./run-state.js";
5
+ /**
6
+ * Value object (branded id): identity of one Run.
7
+ */
8
+ export const RunId = Schema.NonEmptyString.pipe(Schema.brand("RunId"));
9
+ /**
10
+ * Entity — ledger row: the work a loop owes one Event. At most one open run
11
+ * exists per dedup key, ever — the Event owns the key; the engine's ledger
12
+ * enforces the invariant (ADR 0002).
13
+ */
14
+ export class Run extends Schema.Class("Run")({
15
+ id: RunId,
16
+ eventId: EventId,
17
+ loop: LoopName,
18
+ state: RunState,
19
+ openedAt: Schema.DateTimeUtc,
20
+ }) {
21
+ }
22
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/lifecycle/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAGvE;;;;GAIG;AACH,MAAM,OAAO,GAAI,SAAQ,MAAM,CAAC,KAAK,CAAM,KAAK,CAAC,CAAC;IAChD,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,MAAM,CAAC,WAAW;CAC7B,CAAC;CAAG"}
@@ -0,0 +1,23 @@
1
+ import { Schema } from "effect";
2
+ import { StepResult } from "../step-result.ts";
3
+ /**
4
+ * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
5
+ * step in the loop file retires it — prior results stay under the old name.
6
+ * There is deliberately no synthetic step id.
7
+ */
8
+ export declare const StepName: Schema.brand<Schema.NonEmptyString, "StepName">;
9
+ export type StepName = typeof StepName.Type;
10
+ declare const Step_base: Schema.Class<Step, Schema.Struct<{
11
+ readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
12
+ readonly name: Schema.brand<Schema.NonEmptyString, "StepName">;
13
+ readonly result: Schema.Option<typeof StepResult>;
14
+ }>, {}>;
15
+ /**
16
+ * Entity — ledger row: a named unit of work inside a run, its stored result addressable by name;
17
+ * exactly one per run in v1 (the agent action). The result is the run host's
18
+ * final message, stored when an attempt succeeds — none until then.
19
+ */
20
+ export declare class Step extends Step_base {
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,21 @@
1
+ import { Schema } from "effect";
2
+ import { StepResult } from "../step-result.js";
3
+ import { RunId } from "./run.js";
4
+ /**
5
+ * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
6
+ * step in the loop file retires it — prior results stay under the old name.
7
+ * There is deliberately no synthetic step id.
8
+ */
9
+ export const StepName = Schema.NonEmptyString.pipe(Schema.brand("StepName"));
10
+ /**
11
+ * Entity — ledger row: a named unit of work inside a run, its stored result addressable by name;
12
+ * exactly one per run in v1 (the agent action). The result is the run host's
13
+ * final message, stored when an attempt succeeds — none until then.
14
+ */
15
+ export class Step extends Schema.Class("Step")({
16
+ runId: RunId,
17
+ name: StepName,
18
+ result: Schema.Option(StepResult),
19
+ }) {
20
+ }
21
+ //# sourceMappingURL=step.js.map
@@ -0,0 +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,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,7 +1,43 @@
1
1
  {
2
2
  "name": "@usine/core",
3
- "version": "0.0.0",
4
- "description": "Name reservation for the usine blocks; real releases start at 0.0.1.",
3
+ "version": "0.1.0",
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
- "repository": { "type": "git", "url": "git+https://github.com/basaltbytes/usine.git" }
7
- }
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/basaltbytes/usine.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "devDependencies": {
26
+ "@effect/vitest": "4.0.0-rc.111",
27
+ "effect": "4.0.0-rc.111",
28
+ "typescript": "7.0.2",
29
+ "vitest": "4.1.11",
30
+ "@usine/tsconfig": "0.0.0"
31
+ },
32
+ "peerDependencies": {
33
+ "effect": "4.0.0-rc.111"
34
+ },
35
+ "engines": {
36
+ "node": ">=22"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -b",
40
+ "check": "tsc -p tsconfig.check.json",
41
+ "test": "vitest run"
42
+ }
43
+ }