@usine/core 0.1.0 → 0.2.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 (120) hide show
  1. package/README.md +28 -22
  2. package/dist/agent/agent.d.ts +27 -0
  3. package/dist/agent/agent.d.ts.map +1 -0
  4. package/dist/agent/agent.js +26 -0
  5. package/dist/agent/agent.js.map +1 -0
  6. package/dist/agent/brain.d.ts +24 -0
  7. package/dist/agent/brain.d.ts.map +1 -0
  8. package/dist/agent/brain.js +19 -0
  9. package/dist/agent/brain.js.map +1 -0
  10. package/dist/agent/capability.d.ts +23 -0
  11. package/dist/agent/capability.d.ts.map +1 -0
  12. package/dist/agent/capability.js +19 -0
  13. package/dist/agent/capability.js.map +1 -0
  14. package/dist/{agent.d.ts → agent/session.d.ts} +34 -50
  15. package/dist/agent/session.d.ts.map +1 -0
  16. package/dist/agent/session.js +93 -0
  17. package/dist/agent/session.js.map +1 -0
  18. package/dist/attempt/attempt.d.ts +41 -0
  19. package/dist/attempt/attempt.d.ts.map +1 -0
  20. package/dist/attempt/attempt.js +36 -0
  21. package/dist/attempt/attempt.js.map +1 -0
  22. package/dist/{attempt-channel.d.ts → attempt/channel.d.ts} +28 -32
  23. package/dist/attempt/channel.d.ts.map +1 -0
  24. package/dist/{attempt-channel.js → attempt/channel.js} +25 -26
  25. package/dist/attempt/channel.js.map +1 -0
  26. package/dist/attempt/failure.d.ts +52 -0
  27. package/dist/attempt/failure.d.ts.map +1 -0
  28. package/dist/attempt/failure.js +48 -0
  29. package/dist/attempt/failure.js.map +1 -0
  30. package/dist/attempt/outcome.d.ts +20 -0
  31. package/dist/attempt/outcome.d.ts.map +1 -0
  32. package/dist/attempt/outcome.js +16 -0
  33. package/dist/attempt/outcome.js.map +1 -0
  34. package/dist/cycle-budget.d.ts +38 -0
  35. package/dist/cycle-budget.d.ts.map +1 -0
  36. package/dist/cycle-budget.js +46 -0
  37. package/dist/cycle-budget.js.map +1 -0
  38. package/dist/{lifecycle/event.d.ts → event.d.ts} +6 -11
  39. package/dist/event.d.ts.map +1 -0
  40. package/dist/event.js +21 -0
  41. package/dist/event.js.map +1 -0
  42. package/dist/instance.d.ts +3 -7
  43. package/dist/instance.d.ts.map +1 -1
  44. package/dist/instance.js +2 -6
  45. package/dist/instance.js.map +1 -1
  46. package/dist/item.d.ts +8 -0
  47. package/dist/item.d.ts.map +1 -0
  48. package/dist/item.js +6 -0
  49. package/dist/item.js.map +1 -0
  50. package/dist/loop.d.ts +9 -0
  51. package/dist/loop.d.ts.map +1 -0
  52. package/dist/loop.js +7 -0
  53. package/dist/loop.js.map +1 -0
  54. package/dist/repository.d.ts +12 -17
  55. package/dist/repository.d.ts.map +1 -1
  56. package/dist/repository.js +11 -16
  57. package/dist/repository.js.map +1 -1
  58. package/dist/run/run.d.ts +16 -0
  59. package/dist/run/run.d.ts.map +1 -0
  60. package/dist/run/run.js +16 -0
  61. package/dist/run/run.js.map +1 -0
  62. package/dist/run/state.d.ts +114 -0
  63. package/dist/run/state.d.ts.map +1 -0
  64. package/dist/run/state.js +102 -0
  65. package/dist/run/state.js.map +1 -0
  66. package/dist/{step-result.d.ts → step/result.d.ts} +7 -9
  67. package/dist/step/result.d.ts.map +1 -0
  68. package/dist/{step-result.js → step/result.js} +8 -10
  69. package/dist/step/result.js.map +1 -0
  70. package/dist/step/step.d.ts +21 -0
  71. package/dist/step/step.d.ts.map +1 -0
  72. package/dist/step/step.js +19 -0
  73. package/dist/step/step.js.map +1 -0
  74. package/dist/worker.d.ts +7 -7
  75. package/dist/worker.d.ts.map +1 -1
  76. package/dist/worker.js +5 -5
  77. package/dist/worker.js.map +1 -1
  78. package/package.json +76 -4
  79. package/dist/agent.d.ts.map +0 -1
  80. package/dist/agent.js +0 -105
  81. package/dist/agent.js.map +0 -1
  82. package/dist/attempt-channel.d.ts.map +0 -1
  83. package/dist/attempt-channel.js.map +0 -1
  84. package/dist/index.d.ts +0 -24
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.js +0 -24
  87. package/dist/index.js.map +0 -1
  88. package/dist/lifecycle/attempt-failure.d.ts +0 -51
  89. package/dist/lifecycle/attempt-failure.d.ts.map +0 -1
  90. package/dist/lifecycle/attempt-failure.js +0 -45
  91. package/dist/lifecycle/attempt-failure.js.map +0 -1
  92. package/dist/lifecycle/attempt.d.ts +0 -61
  93. package/dist/lifecycle/attempt.d.ts.map +0 -1
  94. package/dist/lifecycle/attempt.js +0 -52
  95. package/dist/lifecycle/attempt.js.map +0 -1
  96. package/dist/lifecycle/event.d.ts.map +0 -1
  97. package/dist/lifecycle/event.js +0 -26
  98. package/dist/lifecycle/event.js.map +0 -1
  99. package/dist/lifecycle/item.d.ts +0 -11
  100. package/dist/lifecycle/item.d.ts.map +0 -1
  101. package/dist/lifecycle/item.js +0 -9
  102. package/dist/lifecycle/item.js.map +0 -1
  103. package/dist/lifecycle/loop.d.ts +0 -17
  104. package/dist/lifecycle/loop.d.ts.map +0 -1
  105. package/dist/lifecycle/loop.js +0 -15
  106. package/dist/lifecycle/loop.js.map +0 -1
  107. package/dist/lifecycle/run-state.d.ts +0 -133
  108. package/dist/lifecycle/run-state.d.ts.map +0 -1
  109. package/dist/lifecycle/run-state.js +0 -126
  110. package/dist/lifecycle/run-state.js.map +0 -1
  111. package/dist/lifecycle/run.d.ts +0 -22
  112. package/dist/lifecycle/run.d.ts.map +0 -1
  113. package/dist/lifecycle/run.js +0 -22
  114. package/dist/lifecycle/run.js.map +0 -1
  115. package/dist/lifecycle/step.d.ts +0 -23
  116. package/dist/lifecycle/step.d.ts.map +0 -1
  117. package/dist/lifecycle/step.js +0 -21
  118. package/dist/lifecycle/step.js.map +0 -1
  119. package/dist/step-result.d.ts.map +0 -1
  120. package/dist/step-result.js.map +0 -1
@@ -1 +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
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,yHAAyH;AACzH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
package/dist/item.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the issue or pull request a loop acts on. Many content-distinct Events can concern one Item. */
3
+ export declare const ItemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
4
+ export type ItemKey = typeof ItemKey.Type;
5
+ /** The issue or pull request number within its repository. */
6
+ export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
7
+ export type ItemNumber = typeof ItemNumber.Type;
8
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+GAA+G;AAC/G,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
package/dist/item.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the issue or pull request a loop acts on. Many content-distinct Events can concern one Item. */
3
+ export const ItemKey = Schema.NonEmptyString.pipe(Schema.brand("ItemKey"));
4
+ /** The issue or pull request number within its repository. */
5
+ export const ItemNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("ItemNumber"));
6
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+GAA+G;AAC/G,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAC3B,CAAC"}
package/dist/loop.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
3
+ export declare const LoopName: Schema.brand<Schema.NonEmptyString, "LoopName">;
4
+ export type LoopName = typeof LoopName.Type;
5
+ /** Whether a loop parks new runs until an approval Event arrives. The default is `none`. */
6
+ export declare const APPROVAL_REQUIREMENTS: readonly ["none", "required"];
7
+ export declare const ApprovalRequirement: Schema.Literals<readonly ["none", "required"]>;
8
+ export type ApprovalRequirement = typeof ApprovalRequirement.Type;
9
+ //# sourceMappingURL=loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,4FAA4F;AAC5F,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"}
package/dist/loop.js ADDED
@@ -0,0 +1,7 @@
1
+ import { Schema } from "effect";
2
+ /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
3
+ export const LoopName = Schema.NonEmptyString.pipe(Schema.brand("LoopName"));
4
+ /** Whether a loop parks new runs until an approval Event arrives. The default is `none`. */
5
+ export const APPROVAL_REQUIREMENTS = ["none", "required"];
6
+ export const ApprovalRequirement = Schema.Literals(APPROVAL_REQUIREMENTS);
7
+ //# sourceMappingURL=loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E,4FAA4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC"}
@@ -1,26 +1,21 @@
1
1
  import { Schema } from "effect";
2
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.
3
+ * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
+ * Compare through `canonicalRepositoryName`, since GitHub ignores case.
6
5
  */
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. */
6
+ export declare const RepositoryName: Schema.brand<Schema.String, "RepositoryName">;
7
+ export type RepositoryName = typeof RepositoryName.Type;
8
+ /** The branch, tag, commit, or `HEAD` a Worker fetches when preparing an Attempt; named refs resolve at preparation time. */
9
+ export declare const RepositoryRevision: Schema.brand<Schema.String, "RepositoryRevision">;
10
+ export type RepositoryRevision = typeof RepositoryRevision.Type;
11
+ /** An exact Git commit recorded for a checkout or produced by an Attempt, unchanged when branch names move. */
17
12
  export declare const CommitSha: Schema.brand<Schema.String, "CommitSha">;
18
13
  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) => {
14
+ /** Splits a repository name into its `owner` and `name`. */
15
+ export declare const splitRepositoryName: (repository: RepositoryName) => {
21
16
  readonly owner: string;
22
17
  readonly name: string;
23
18
  };
24
- /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
25
- export declare const canonical: (repository: Name) => string;
19
+ /** Lowercases a repository name for comparison, since GitHub ignores case. */
20
+ export declare const canonicalRepositoryName: (repository: RepositoryName) => string;
26
21
  //# sourceMappingURL=repository.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,cAAc,+CAIW,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,6HAA6H;AAC7H,eAAO,MAAM,kBAAkB,mDAIW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,+GAA+G;AAC/G,eAAO,MAAM,SAAS,0CAIW,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,eAAgB,cAAc;aAG1D,KAAK;aACL,IAAI;CAEP,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,eAAgB,cAAc,KAAG,MAC3C,CAAC"}
@@ -1,32 +1,27 @@
1
1
  import { Schema } from "effect";
2
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.
3
+ * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
+ * Compare through `canonicalRepositoryName`, since GitHub ignores case.
6
5
  */
7
- export const Name = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
6
+ export const RepositoryName = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
8
7
  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, {
8
+ })).pipe(Schema.brand("RepositoryName"));
9
+ /** The branch, tag, commit, or `HEAD` a Worker fetches when preparing an Attempt; named refs resolve at preparation time. */
10
+ export const RepositoryRevision = Schema.String.check(Schema.isPattern(/^[^\s-]\S*$/u, {
16
11
  message: "Expected a git revision without whitespace or a leading dash",
17
12
  })).pipe(Schema.brand("RepositoryRevision"));
18
- /** Value object: a git object id harvested from an Attempt workspace. */
13
+ /** An exact Git commit recorded for a checkout or produced by an Attempt, unchanged when branch names move. */
19
14
  export const CommitSha = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u, {
20
15
  message: "Expected a 40- or 64-character lowercase git object id",
21
16
  })).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) => {
17
+ /** Splits a repository name into its `owner` and `name`. */
18
+ export const splitRepositoryName = (repository) => {
24
19
  const separator = repository.indexOf("/");
25
20
  return {
26
21
  owner: repository.slice(0, separator),
27
22
  name: repository.slice(separator + 1),
28
23
  };
29
24
  };
30
- /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
31
- export const canonical = (repository) => repository.toLowerCase();
25
+ /** Lowercases a repository name for comparison, since GitHub ignores case. */
26
+ export const canonicalRepositoryName = (repository) => repository.toLowerCase();
32
27
  //# sourceMappingURL=repository.js.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BAAuB,GAAG,CAAC,UAA0B,EAAU,EAAE,CAC5E,UAAU,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the work owed to one Event, retained across retries of its Step. */
3
+ export declare const RunId: Schema.brand<Schema.NonEmptyString, "RunId">;
4
+ export type RunId = typeof RunId.Type;
5
+ declare const Run_base: Schema.Class<Run, Schema.Struct<{
6
+ readonly id: Schema.brand<Schema.NonEmptyString, "RunId">;
7
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
8
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
9
+ readonly state: Schema.Union<readonly [typeof import("./state.ts").Pending, typeof import("./state.ts").Waiting, typeof import("./state.ts").Queued, typeof import("./state.ts").Running, typeof import("./state.ts").Succeeded, typeof import("./state.ts").Failed, typeof import("./state.ts").Canceled]>;
10
+ readonly openedAt: Schema.DateTimeUtc;
11
+ }>, {}>;
12
+ /** The work a loop owes one Event. At most one open Run exists per dedup key; the engine's ledger enforces it (ADR 0002). */
13
+ export declare class Run extends Run_base {
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,mFAAmF;AACnF,eAAO,MAAM,KAAK,8CAAoD,CAAC;AAEvE,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;;;;;;;;AAEtC,6HAA6H;AAC7H,qBAAa,GAAI,SAAQ,QAMvB;CAAG"}
@@ -0,0 +1,16 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "../event.js";
3
+ import { LoopName } from "../loop.js";
4
+ import { RunState } from "./state.js";
5
+ /** Identity of the work owed to one Event, retained across retries of its Step. */
6
+ export const RunId = Schema.NonEmptyString.pipe(Schema.brand("RunId"));
7
+ /** The work a loop owes one Event. At most one open Run exists per dedup key; the engine's ledger enforces it (ADR 0002). */
8
+ export class Run extends Schema.Class("Run")({
9
+ id: RunId,
10
+ eventId: EventId,
11
+ loop: LoopName,
12
+ state: RunState,
13
+ openedAt: Schema.DateTimeUtc,
14
+ }) {
15
+ }
16
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAIvE,6HAA6H;AAC7H,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,114 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "../event.ts";
3
+ declare const OperatorCanceled_base: Schema.Class<OperatorCanceled, Schema.TaggedStruct<"OperatorCanceled", {}>, {}>;
4
+ /**
5
+ * The run state machine (ADR 0002):
6
+ *
7
+ * pending ─────────────────────────► running ──► succeeded
8
+ * │ ▲ │
9
+ * ▼ │ ▼
10
+ * waiting ──(approval)──► queued ────┘ failed ──► (retry: attempt N+1) ──► running
11
+ *
12
+ * pending | waiting | queued | running ──► canceled (operator cancel)
13
+ * pending | waiting | queued ──► canceled (supersede, revoke: a started
14
+ * attempt always finishes, ADR 0007)
15
+ *
16
+ * Each transition accepts only the states it is legal on, so an illegal
17
+ * transition fails to compile. Construct states through the transitions or by
18
+ * decoding a stored row with `RunState`.
19
+ */
20
+ /** The operator closed the run by hand. */
21
+ export declare class OperatorCanceled extends OperatorCanceled_base {
22
+ }
23
+ declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
24
+ readonly by: Schema.brand<Schema.NonEmptyString, "EventId">;
25
+ }>, {}>;
26
+ /** A newer Event for the same Item took the run's place before any attempt started. */
27
+ export declare class Superseded extends Superseded_base {
28
+ }
29
+ declare const Revoked_base: Schema.Class<Revoked, Schema.TaggedStruct<"Revoked", {}>, {}>;
30
+ /** The run's Item stopped matching its loop's trigger before any attempt started. */
31
+ export declare class Revoked extends Revoked_base {
32
+ }
33
+ export declare const CancelReason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
34
+ export type CancelReason = typeof CancelReason.Type;
35
+ declare const Pending_base: Schema.Class<Pending, Schema.TaggedStruct<"Pending", {}>, {}>;
36
+ /** Just created: no attempt started and no approval gate passed. */
37
+ export declare class Pending extends Pending_base {
38
+ }
39
+ declare const Waiting_base: Schema.Class<Waiting, Schema.TaggedStruct<"Waiting", {}>, {}>;
40
+ /** Parked on the loop's approval gate. The approval it waits for is an Event like any other fact. */
41
+ export declare class Waiting extends Waiting_base {
42
+ }
43
+ declare const Queued_base: Schema.Class<Queued, Schema.TaggedStruct<"Queued", {}>, {}>;
44
+ /** Approved and waiting for a worker slot. */
45
+ export declare class Queued extends Queued_base {
46
+ }
47
+ declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running", {}>, {}>;
48
+ /** An attempt is executing on a worker. */
49
+ export declare class Running extends Running_base {
50
+ }
51
+ declare const Succeeded_base: Schema.Class<Succeeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
52
+ /** The step finished and its result is stored. */
53
+ export declare class Succeeded extends Succeeded_base {
54
+ }
55
+ declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {}>, {}>;
56
+ /** The last attempt failed and no auto-retry applies. The failure is on the Attempt, and `retry` reopens the run. */
57
+ export declare class Failed extends Failed_base {
58
+ }
59
+ declare const Canceled_base: Schema.Class<Canceled, Schema.TaggedStruct<"Canceled", {
60
+ readonly reason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
61
+ }>, {}>;
62
+ /** Canceled, with the reason recorded. */
63
+ export declare class Canceled extends Canceled_base {
64
+ }
65
+ /** Runs that still owe work, including those waiting for approval or a Worker. */
66
+ export declare const Open: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running]>;
67
+ export type Open = typeof Open.Type;
68
+ /** A Run's progress from creation through approval and execution to a recorded outcome. */
69
+ export declare const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>;
70
+ export type RunState = typeof RunState.Type;
71
+ /** The states with no attempt started: what `supersede` and `revoke` accept. */
72
+ export declare const Unstarted: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued]>;
73
+ export type Unstarted = typeof Unstarted.Type;
74
+ /** The states an attempt can start from: the gate is passed or absent. */
75
+ export declare const Startable: Schema.Union<readonly [typeof Pending, typeof Queued]>;
76
+ export type Startable = typeof Startable.Type;
77
+ export declare const isOpen: <I>(input: I) => input is I & (Pending | Queued | Running | Waiting);
78
+ export declare const isUnstarted: <I>(input: I) => input is I & (Pending | Queued | Waiting);
79
+ export declare const isStartable: <I>(input: I) => input is I & (Pending | Queued);
80
+ /** The operator actions permitted by a Run's lifecycle state. Command handlers still apply the typed transitions. */
81
+ export declare const operatorActions: (state: RunState) => {
82
+ canApprove: boolean;
83
+ canRetry: boolean;
84
+ canCancel: boolean;
85
+ };
86
+ /** The open states as `_tag` literals, for queries that filter stored rows. */
87
+ export declare const OPEN_STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running"];
88
+ /** Every state as a `_tag` literal, for read models that project stored rows. */
89
+ export declare const STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled"];
90
+ /** The unstarted states as `_tag` literals, for queries that filter stored rows. */
91
+ export declare const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting", "Queued"];
92
+ /** Parks a pending run on its loop's approval gate. */
93
+ export declare const awaitApproval: (_state: Pending) => Waiting;
94
+ /** Returns the approved state; the Run still waits for a Worker slot before execution. */
95
+ export declare const approve: (_state: Waiting) => Queued;
96
+ /** Returns the running state for a first Attempt after any required approval has been granted. */
97
+ export declare const start: (_state: Startable) => Running;
98
+ /** Closes the run after a successful attempt. */
99
+ export declare const succeed: (_state: Running) => Succeeded;
100
+ /** Closes the run after a failed attempt when no auto-retry applies; `shouldAutoRetry` decides that. */
101
+ export declare const fail: (_state: Running) => Failed;
102
+ /** Returns the reopened state for operator retry; attempt N+1 belongs to the same Run and Step. */
103
+ export declare const retry: (_state: Failed) => Running;
104
+ /** Cancels from any open state. */
105
+ export declare const cancelByOperator: (_state: Open) => Canceled;
106
+ /**
107
+ * Cancels an unstarted run because a newer Event for the same Item replaced it.
108
+ * A running attempt always finishes and the newer state is judged when it ends (ADR 0007).
109
+ */
110
+ export declare const supersede: (_state: Unstarted, by: EventId) => Canceled;
111
+ /** Cancels an unstarted run because its Item stopped matching the loop's trigger. */
112
+ export declare const revoke: (_state: Unstarted) => Canceled;
113
+ export {};
114
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/run/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;;AAEtC;;;;;;;;;;;;;;;GAeG;AAEH,2CAA2C;AAC3C,qBAAa,gBAAiB,SAAQ,qBAEb;CA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AAM,eAAe,UAAW,QAAQ;IAC7C,UAAU;IACV,QAAQ;IACR,SAAS;CACT,CAAC;AAcH,+EAA+E;AAC/E,eAAO,MAAM,eAAe,sDAA4D,CAAC;AAEzF,iFAAiF;AACjF,eAAO,MAAM,UAAU,yFAQtB,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,2CAAsD,CAAC;AAExF,uDAAuD;AACvD,eAAO,MAAM,aAAa,WAAY,OAAO,KAAG,OAAwB,CAAC;AAEzE,0FAA0F;AAC1F,eAAO,MAAM,OAAO,WAAY,OAAO,KAAG,MAAsB,CAAC;AAEjE,kGAAkG;AAClG,eAAO,MAAM,KAAK,WAAY,SAAS,KAAG,OAAwB,CAAC;AAEnE,iDAAiD;AACjD,eAAO,MAAM,OAAO,WAAY,OAAO,KAAG,SAA4B,CAAC;AAEvE,wGAAwG;AACxG,eAAO,MAAM,IAAI,WAAY,OAAO,KAAG,MAAsB,CAAC;AAE9D,mGAAmG;AACnG,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,OAAwB,CAAC;AAEhE,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,WAAY,IAAI,KAAG,QACE,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,SAAS,WAAY,SAAS,MAAM,OAAO,KAAG,QACT,CAAC;AAEnD,qFAAqF;AACrF,eAAO,MAAM,MAAM,WAAY,SAAS,KAAG,QAAmD,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "../event.js";
3
+ /**
4
+ * The run state machine (ADR 0002):
5
+ *
6
+ * pending ─────────────────────────► running ──► succeeded
7
+ * │ ▲ │
8
+ * ▼ │ ▼
9
+ * waiting ──(approval)──► queued ────┘ failed ──► (retry: attempt N+1) ──► running
10
+ *
11
+ * pending | waiting | queued | running ──► canceled (operator cancel)
12
+ * pending | waiting | queued ──► canceled (supersede, revoke: a started
13
+ * attempt always finishes, ADR 0007)
14
+ *
15
+ * Each transition accepts only the states it is legal on, so an illegal
16
+ * transition fails to compile. Construct states through the transitions or by
17
+ * decoding a stored row with `RunState`.
18
+ */
19
+ /** The operator closed the run by hand. */
20
+ export class OperatorCanceled extends Schema.TaggedClass("CancelReason/OperatorCanceled")("OperatorCanceled", {}) {
21
+ }
22
+ /** A newer Event for the same Item took the run's place before any attempt started. */
23
+ export class Superseded extends Schema.TaggedClass("CancelReason/Superseded")("Superseded", { by: EventId }) {
24
+ }
25
+ /** The run's Item stopped matching its loop's trigger before any attempt started. */
26
+ export class Revoked extends Schema.TaggedClass("CancelReason/Revoked")("Revoked", {}) {
27
+ }
28
+ export const CancelReason = Schema.Union([OperatorCanceled, Superseded, Revoked]);
29
+ /** Just created: no attempt started and no approval gate passed. */
30
+ export class Pending extends Schema.TaggedClass("RunState/Pending")("Pending", {}) {
31
+ }
32
+ /** Parked on the loop's approval gate. The approval it waits for is an Event like any other fact. */
33
+ export class Waiting extends Schema.TaggedClass("RunState/Waiting")("Waiting", {}) {
34
+ }
35
+ /** Approved and waiting for a worker slot. */
36
+ export class Queued extends Schema.TaggedClass("RunState/Queued")("Queued", {}) {
37
+ }
38
+ /** An attempt is executing on a worker. */
39
+ export class Running extends Schema.TaggedClass("RunState/Running")("Running", {}) {
40
+ }
41
+ /** The step finished and its result is stored. */
42
+ export class Succeeded extends Schema.TaggedClass("RunState/Succeeded")("Succeeded", {}) {
43
+ }
44
+ /** The last attempt failed and no auto-retry applies. The failure is on the Attempt, and `retry` reopens the run. */
45
+ export class Failed extends Schema.TaggedClass("RunState/Failed")("Failed", {}) {
46
+ }
47
+ /** Canceled, with the reason recorded. */
48
+ export class Canceled extends Schema.TaggedClass("RunState/Canceled")("Canceled", {
49
+ reason: CancelReason,
50
+ }) {
51
+ }
52
+ /** Runs that still owe work, including those waiting for approval or a Worker. */
53
+ export const Open = Schema.Union([Pending, Waiting, Queued, Running]);
54
+ /** A Run's progress from creation through approval and execution to a recorded outcome. */
55
+ export const RunState = Schema.Union([...Open.members, Succeeded, Failed, Canceled]);
56
+ /** The states with no attempt started: what `supersede` and `revoke` accept. */
57
+ export const Unstarted = Schema.Union([Pending, Waiting, Queued]);
58
+ /** The states an attempt can start from: the gate is passed or absent. */
59
+ export const Startable = Schema.Union([Pending, Queued]);
60
+ export const isOpen = Schema.is(Open);
61
+ export const isUnstarted = Schema.is(Unstarted);
62
+ export const isStartable = Schema.is(Startable);
63
+ /** The operator actions permitted by a Run's lifecycle state. Command handlers still apply the typed transitions. */
64
+ export const operatorActions = (state) => ({
65
+ canApprove: state._tag === "Waiting",
66
+ canRetry: state._tag === "Failed",
67
+ canCancel: isOpen(state),
68
+ });
69
+ /**
70
+ * Builds a tag tuple that must name every `_tag` of `State` and nothing else,
71
+ * so the SQL-side lists below cannot drift from the unions above. A foreign tag
72
+ * fails the `Tags` constraint; a missing tag collapses the parameters to `[never]`.
73
+ */
74
+ const tagsOf = () => (...tags) => tags;
75
+ /** The open states as `_tag` literals, for queries that filter stored rows. */
76
+ export const OPEN_STATE_TAGS = tagsOf()("Pending", "Waiting", "Queued", "Running");
77
+ /** Every state as a `_tag` literal, for read models that project stored rows. */
78
+ export const STATE_TAGS = tagsOf()("Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled");
79
+ /** The unstarted states as `_tag` literals, for queries that filter stored rows. */
80
+ export const UNSTARTED_STATE_TAGS = tagsOf()("Pending", "Waiting", "Queued");
81
+ /** Parks a pending run on its loop's approval gate. */
82
+ export const awaitApproval = (_state) => new Waiting();
83
+ /** Returns the approved state; the Run still waits for a Worker slot before execution. */
84
+ export const approve = (_state) => new Queued();
85
+ /** Returns the running state for a first Attempt after any required approval has been granted. */
86
+ export const start = (_state) => new Running();
87
+ /** Closes the run after a successful attempt. */
88
+ export const succeed = (_state) => new Succeeded();
89
+ /** Closes the run after a failed attempt when no auto-retry applies; `shouldAutoRetry` decides that. */
90
+ export const fail = (_state) => new Failed();
91
+ /** Returns the reopened state for operator retry; attempt N+1 belongs to the same Run and Step. */
92
+ export const retry = (_state) => new Running();
93
+ /** Cancels from any open state. */
94
+ export const cancelByOperator = (_state) => new Canceled({ reason: new OperatorCanceled() });
95
+ /**
96
+ * Cancels an unstarted run because a newer Event for the same Item replaced it.
97
+ * A running attempt always finishes and the newer state is judged when it ends (ADR 0007).
98
+ */
99
+ export const supersede = (_state, by) => new Canceled({ reason: new Superseded({ by }) });
100
+ /** Cancels an unstarted run because its Item stopped matching the loop's trigger. */
101
+ export const revoke = (_state) => new Canceled({ reason: new Revoked() });
102
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/run/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AAEH,2CAA2C;AAC3C,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,CACtD,+BAA+B,CAChC,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAAG;AAE5B,uFAAuF;AACvF,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,CAAa,yBAAyB,CAAC,CACvF,YAAY,EACZ,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;CAAG;AAEJ,qFAAqF;AACrF,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,oEAAoE;AACpE,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,kBAAkB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;CAAG;AAE9F,qGAAqG;AACrG,MAAM,OAAO,OAAQ,SAAQ,MAAM,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AkG;AAClG,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAiB,EAAW,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;AAEnE,iDAAiD;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAe,EAAa,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;AAEvE,wGAAwG;AACxG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAe,EAAU,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;AAE9D,mGAAmG;AACnG,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;AAEhE,mCAAmC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAY,EAAY,EAAE,CACzD,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAiB,EAAE,EAAW,EAAY,EAAE,CACpE,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnD,qFAAqF;AACrF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAiB,EAAY,EAAE,CAAC,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC"}
@@ -8,28 +8,26 @@ export declare class Commit extends Commit_base {
8
8
  }
9
9
  declare const PullRequest_base: Schema.Class<PullRequest, Schema.TaggedStruct<"PullRequest", {
10
10
  readonly number: Schema.Int;
11
- readonly url: Schema.URL;
11
+ readonly url: Schema.URLFromString;
12
12
  }>, {}>;
13
13
  /** A pull request the agent created or updated during the Attempt. */
14
14
  export declare class PullRequest extends PullRequest_base {
15
15
  }
16
16
  declare const Comment_base: Schema.Class<Comment, Schema.TaggedStruct<"Comment", {
17
- readonly url: Schema.URL;
17
+ readonly url: Schema.URLFromString;
18
18
  }>, {}>;
19
19
  /** A GitHub comment the agent created or updated during the Attempt. */
20
20
  export declare class Comment extends Comment_base {
21
21
  }
22
- export declare const Fact: Schema.Union<readonly [typeof Commit, typeof PullRequest, typeof Comment]>;
23
- export type Fact = typeof Fact.Type;
22
+ /** A commit or GitHub artifact recorded as an outcome of the Agent's work. */
23
+ export declare const StepResultFact: Schema.Union<readonly [typeof Commit, typeof PullRequest, typeof Comment]>;
24
+ export type StepResultFact = typeof StepResultFact.Type;
24
25
  declare const StepResult_base: Schema.Class<StepResult, Schema.Struct<{
25
26
  readonly message: Schema.NonEmptyString;
26
27
  readonly facts: Schema.$Array<Schema.Union<readonly [typeof Commit, typeof PullRequest, typeof Comment]>>;
27
28
  }>, {}>;
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
- */
29
+ /** The agent's final message plus the facts that survive workspace cleanup. */
32
30
  export declare class StepResult extends StepResult_base {
33
31
  }
34
32
  export {};
35
- //# sourceMappingURL=step-result.d.ts.map
33
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,8EAA8E;AAC9E,eAAO,MAAM,cAAc,4EAA+C,CAAC;AAC3E,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;;;;;AAExD,+EAA+E;AAC/E,qBAAa,UAAW,SAAQ,eAG9B;CAAG"}
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { CommitSha } from "./repository.js";
2
+ import { CommitSha } from "../repository.js";
3
3
  /** A commit the run host found between the workspace base and final HEAD. */
4
4
  export class Commit extends Schema.TaggedClass("StepResult/Commit")("Commit", {
5
5
  sha: CommitSha,
@@ -9,22 +9,20 @@ export class Commit extends Schema.TaggedClass("StepResult/Commit")("Commit", {
9
9
  /** A pull request the agent created or updated during the Attempt. */
10
10
  export class PullRequest extends Schema.TaggedClass("StepResult/PullRequest")("PullRequest", {
11
11
  number: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
12
- url: Schema.URL,
12
+ url: Schema.URLFromString,
13
13
  }) {
14
14
  }
15
15
  /** A GitHub comment the agent created or updated during the Attempt. */
16
16
  export class Comment extends Schema.TaggedClass("StepResult/Comment")("Comment", {
17
- url: Schema.URL,
17
+ url: Schema.URLFromString,
18
18
  }) {
19
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
- */
20
+ /** A commit or GitHub artifact recorded as an outcome of the Agent's work. */
21
+ export const StepResultFact = Schema.Union([Commit, PullRequest, Comment]);
22
+ /** The agent's final message plus the facts that survive workspace cleanup. */
25
23
  export class StepResult extends Schema.Class("StepResult")({
26
24
  message: Schema.NonEmptyString,
27
- facts: Schema.Array(Fact),
25
+ facts: Schema.Array(StepResultFact),
28
26
  }) {
29
27
  }
30
- //# sourceMappingURL=step-result.js.map
28
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/step/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,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,aAAa;CAC1B,CACF;CAAG;AAEJ,wEAAwE;AACxE,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,oBAAoB,CAAC,CAAC,SAAS,EAAE;IACxF,GAAG,EAAE,MAAM,CAAC,aAAa;CAC1B,CAAC;CAAG;AAEL,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAG3E,+EAA+E;AAC/E,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,KAAK,CAAa,YAAY,CAAC,CAAC;IACrE,OAAO,EAAE,MAAM,CAAC,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;CACpC,CAAC;CAAG"}
@@ -0,0 +1,21 @@
1
+ import { Schema } from "effect";
2
+ import { StepResult } from "./result.ts";
3
+ /**
4
+ * The loop-authored step name. Renaming a step in the loop file retires it and
5
+ * its stored results stay under the old name (ADR 0002).
6
+ */
7
+ export declare const StepName: Schema.brand<Schema.NonEmptyString, "StepName">;
8
+ export type StepName = typeof StepName.Type;
9
+ declare const Step_base: Schema.Class<Step, Schema.Struct<{
10
+ readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
11
+ readonly name: Schema.brand<Schema.NonEmptyString, "StepName">;
12
+ readonly result: Schema.Option<typeof StepResult>;
13
+ }>, {}>;
14
+ /**
15
+ * A named unit of work inside a run, exactly one per run in v1. The result is
16
+ * stored when an attempt succeeds and is none until then.
17
+ */
18
+ export declare class Step extends Step_base {
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/step/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;AAE5C;;;GAGG;AACH,qBAAa,IAAK,SAAQ,SAIxB;CAAG"}
@@ -0,0 +1,19 @@
1
+ import { Schema } from "effect";
2
+ import { RunId } from "../run/run.js";
3
+ import { StepResult } from "./result.js";
4
+ /**
5
+ * The loop-authored step name. Renaming a step in the loop file retires it and
6
+ * its stored results stay under the old name (ADR 0002).
7
+ */
8
+ export const StepName = Schema.NonEmptyString.pipe(Schema.brand("StepName"));
9
+ /**
10
+ * A named unit of work inside a run, exactly one per run in v1. The result is
11
+ * stored when an attempt succeeds and is none until then.
12
+ */
13
+ export class Step extends Schema.Class("Step")({
14
+ runId: RunId,
15
+ name: StepName,
16
+ result: Schema.Option(StepResult),
17
+ }) {
18
+ }
19
+ //# sourceMappingURL=step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/step/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E;;;GAGG;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"}
package/dist/worker.d.ts CHANGED
@@ -1,9 +1,9 @@
1
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;
2
+ /** Kebab-case name of a configured Worker. */
3
+ export declare const WorkerName: Schema.brand<Schema.String, "WorkerName">;
4
+ export type WorkerName = typeof WorkerName.Type;
5
+ /** The Worker adapters the engine ships. */
6
+ export declare const WORKER_KINDS: readonly ["local", "exe.dev"];
7
+ export declare const WorkerKind: Schema.Literals<readonly ["local", "exe.dev"]>;
8
+ export type WorkerKind = typeof WorkerKind.Type;
9
9
  //# sourceMappingURL=worker.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,8CAA8C;AAC9C,eAAO,MAAM,UAAU,2CAIW,CAAC;AAEnC,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,4CAA4C;AAC5C,eAAO,MAAM,YAAY,YAAI,OAAO,EAAE,SAAS,CAAU,CAAC;AAC1D,eAAO,MAAM,UAAU,gDAAgC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}