@usine/orchestrator 0.2.0 → 0.3.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 (173) hide show
  1. package/README.md +151 -50
  2. package/dist/board/items.d.ts +9 -1
  3. package/dist/board/items.d.ts.map +1 -1
  4. package/dist/board/items.js +16 -4
  5. package/dist/board/items.js.map +1 -1
  6. package/dist/board/projection.d.ts +7 -1
  7. package/dist/board/projection.d.ts.map +1 -1
  8. package/dist/board/projection.js +53 -14
  9. package/dist/board/projection.js.map +1 -1
  10. package/dist/board/tasks.d.ts +14 -2
  11. package/dist/board/tasks.d.ts.map +1 -1
  12. package/dist/board/tasks.js +23 -8
  13. package/dist/board/tasks.js.map +1 -1
  14. package/dist/credentials.d.ts +5 -6
  15. package/dist/credentials.d.ts.map +1 -1
  16. package/dist/credentials.js +22 -15
  17. package/dist/credentials.js.map +1 -1
  18. package/dist/current-instance/changes.d.ts +87 -0
  19. package/dist/current-instance/changes.d.ts.map +1 -0
  20. package/dist/current-instance/changes.js +138 -0
  21. package/dist/current-instance/changes.js.map +1 -0
  22. package/dist/current-instance/current-instance.d.ts +89 -0
  23. package/dist/current-instance/current-instance.d.ts.map +1 -0
  24. package/dist/current-instance/current-instance.js +163 -0
  25. package/dist/current-instance/current-instance.js.map +1 -0
  26. package/dist/exe-dev.d.ts +6 -2
  27. package/dist/exe-dev.d.ts.map +1 -1
  28. package/dist/exe-dev.js +7 -8
  29. package/dist/exe-dev.js.map +1 -1
  30. package/dist/idle-triggers.d.ts +1 -1
  31. package/dist/idle-triggers.d.ts.map +1 -1
  32. package/dist/idle-triggers.js +1 -1
  33. package/dist/idle-triggers.js.map +1 -1
  34. package/dist/label-reconciler.d.ts +5 -2
  35. package/dist/label-reconciler.d.ts.map +1 -1
  36. package/dist/label-reconciler.js.map +1 -1
  37. package/dist/local.d.ts +4 -18
  38. package/dist/local.d.ts.map +1 -1
  39. package/dist/local.js +7 -45
  40. package/dist/local.js.map +1 -1
  41. package/dist/loop-matches.d.ts +28 -0
  42. package/dist/loop-matches.d.ts.map +1 -0
  43. package/dist/loop-matches.js +74 -0
  44. package/dist/loop-matches.js.map +1 -0
  45. package/dist/operator/attempt.d.ts +60 -10
  46. package/dist/operator/attempt.d.ts.map +1 -1
  47. package/dist/operator/attempt.js +54 -11
  48. package/dist/operator/attempt.js.map +1 -1
  49. package/dist/operator/board.d.ts +43 -16
  50. package/dist/operator/board.d.ts.map +1 -1
  51. package/dist/operator/board.js +43 -16
  52. package/dist/operator/board.js.map +1 -1
  53. package/dist/operator/configuration.d.ts +258 -0
  54. package/dist/operator/configuration.d.ts.map +1 -0
  55. package/dist/operator/configuration.js +410 -0
  56. package/dist/operator/configuration.js.map +1 -0
  57. package/dist/operator/desk.d.ts +181 -0
  58. package/dist/operator/desk.d.ts.map +1 -0
  59. package/dist/operator/desk.js +463 -0
  60. package/dist/operator/desk.js.map +1 -0
  61. package/dist/operator/github-changes.d.ts +88 -0
  62. package/dist/operator/github-changes.d.ts.map +1 -0
  63. package/dist/operator/github-changes.js +266 -0
  64. package/dist/operator/github-changes.js.map +1 -0
  65. package/dist/operator/http.d.ts +191 -30
  66. package/dist/operator/http.d.ts.map +1 -1
  67. package/dist/operator/http.js +153 -23
  68. package/dist/operator/http.js.map +1 -1
  69. package/dist/operator/need.d.ts +44 -11
  70. package/dist/operator/need.d.ts.map +1 -1
  71. package/dist/operator/need.js +46 -9
  72. package/dist/operator/need.js.map +1 -1
  73. package/dist/operator/operator.d.ts +111 -27
  74. package/dist/operator/operator.d.ts.map +1 -1
  75. package/dist/operator/operator.js +286 -45
  76. package/dist/operator/operator.js.map +1 -1
  77. package/dist/operator/overview.d.ts +7 -7
  78. package/dist/operator/overview.d.ts.map +1 -1
  79. package/dist/operator/overview.js +5 -5
  80. package/dist/operator/overview.js.map +1 -1
  81. package/dist/operator/projection.d.ts +56 -4
  82. package/dist/operator/projection.d.ts.map +1 -1
  83. package/dist/operator/projection.js +125 -15
  84. package/dist/operator/projection.js.map +1 -1
  85. package/dist/operator/run.d.ts +92 -3
  86. package/dist/operator/run.d.ts.map +1 -1
  87. package/dist/operator/run.js +87 -4
  88. package/dist/operator/run.js.map +1 -1
  89. package/dist/operator/task.d.ts +93 -0
  90. package/dist/operator/task.d.ts.map +1 -0
  91. package/dist/operator/task.js +204 -0
  92. package/dist/operator/task.js.map +1 -0
  93. package/dist/operator/transcript.d.ts +14 -12
  94. package/dist/operator/transcript.d.ts.map +1 -1
  95. package/dist/operator/transcript.js +18 -9
  96. package/dist/operator/transcript.js.map +1 -1
  97. package/dist/operator/usage.d.ts +111 -0
  98. package/dist/operator/usage.d.ts.map +1 -0
  99. package/dist/operator/usage.js +219 -0
  100. package/dist/operator/usage.js.map +1 -0
  101. package/dist/orchestrator.d.ts +8 -5
  102. package/dist/orchestrator.d.ts.map +1 -1
  103. package/dist/orchestrator.js +4 -2
  104. package/dist/orchestrator.js.map +1 -1
  105. package/dist/polling/cycle.d.ts +28 -10
  106. package/dist/polling/cycle.d.ts.map +1 -1
  107. package/dist/polling/cycle.js +20 -6
  108. package/dist/polling/cycle.js.map +1 -1
  109. package/dist/polling/evaluation-failures.d.ts +42 -0
  110. package/dist/polling/evaluation-failures.d.ts.map +1 -0
  111. package/dist/polling/evaluation-failures.js +103 -0
  112. package/dist/polling/evaluation-failures.js.map +1 -0
  113. package/dist/polling/hints.d.ts +2 -2
  114. package/dist/polling/hints.d.ts.map +1 -1
  115. package/dist/polling/hints.js +2 -2
  116. package/dist/polling/hints.js.map +1 -1
  117. package/dist/polling/loop-evaluation.d.ts +21 -11
  118. package/dist/polling/loop-evaluation.d.ts.map +1 -1
  119. package/dist/polling/loop-evaluation.js +70 -27
  120. package/dist/polling/loop-evaluation.js.map +1 -1
  121. package/dist/polling/open-issues.d.ts +23 -0
  122. package/dist/polling/open-issues.d.ts.map +1 -0
  123. package/dist/polling/open-issues.js +77 -0
  124. package/dist/polling/open-issues.js.map +1 -0
  125. package/dist/polling/polling.d.ts +20 -11
  126. package/dist/polling/polling.d.ts.map +1 -1
  127. package/dist/polling/polling.js +201 -51
  128. package/dist/polling/polling.js.map +1 -1
  129. package/dist/polling/repository-sync.d.ts +20 -14
  130. package/dist/polling/repository-sync.d.ts.map +1 -1
  131. package/dist/polling/repository-sync.js +34 -27
  132. package/dist/polling/repository-sync.js.map +1 -1
  133. package/dist/polling-triggers.d.ts +1 -1
  134. package/dist/polling-triggers.d.ts.map +1 -1
  135. package/dist/polling-triggers.js +1 -1
  136. package/dist/polling-triggers.js.map +1 -1
  137. package/dist/reloads.d.ts +14 -0
  138. package/dist/reloads.d.ts.map +1 -0
  139. package/dist/reloads.js +7 -0
  140. package/dist/reloads.js.map +1 -0
  141. package/dist/runtime.d.ts +24 -0
  142. package/dist/runtime.d.ts.map +1 -0
  143. package/dist/runtime.js +58 -0
  144. package/dist/runtime.js.map +1 -0
  145. package/dist/schedule-triggers.d.ts +14 -10
  146. package/dist/schedule-triggers.d.ts.map +1 -1
  147. package/dist/schedule-triggers.js +36 -31
  148. package/dist/schedule-triggers.js.map +1 -1
  149. package/dist/scheduler.d.ts +35 -4
  150. package/dist/scheduler.d.ts.map +1 -1
  151. package/dist/scheduler.js +327 -40
  152. package/dist/scheduler.js.map +1 -1
  153. package/dist/ssh.d.ts +39 -0
  154. package/dist/ssh.d.ts.map +1 -0
  155. package/dist/ssh.js +75 -0
  156. package/dist/ssh.js.map +1 -0
  157. package/dist/trigger-condition.d.ts +12 -0
  158. package/dist/trigger-condition.d.ts.map +1 -0
  159. package/dist/trigger-condition.js +88 -0
  160. package/dist/trigger-condition.js.map +1 -0
  161. package/dist/trigger-submission.d.ts +16 -13
  162. package/dist/trigger-submission.d.ts.map +1 -1
  163. package/dist/trigger-submission.js +21 -26
  164. package/dist/trigger-submission.js.map +1 -1
  165. package/dist/worker-engine.d.ts +10 -0
  166. package/dist/worker-engine.d.ts.map +1 -0
  167. package/dist/worker-engine.js +25 -0
  168. package/dist/worker-engine.js.map +1 -0
  169. package/dist/worker-status.d.ts +70 -0
  170. package/dist/worker-status.d.ts.map +1 -0
  171. package/dist/worker-status.js +55 -0
  172. package/dist/worker-status.js.map +1 -0
  173. package/package.json +31 -10
@@ -0,0 +1,410 @@
1
+ import { AgentPersona, AgentName, resolveParentEffort, resolveParentModel, } from "@usine/core/agent";
2
+ import { Effort, Harness, ModelId } from "@usine/core/agent/brain";
3
+ import { CycleLimit } from "@usine/core/cycle-budget";
4
+ import { ApprovalRequirement, LoopName, LoopPermissions } from "@usine/core/loop";
5
+ import { OperatorLogin } from "@usine/core/operator";
6
+ import { RepositoryName } from "@usine/core/repository";
7
+ import { StepName } from "@usine/core/step";
8
+ import { GatewayAdminPort, GatewayDomain, GatewayLlmProvider, SshDestination, SshIdentityFile, SshPort, WorkerKind, WorkerName, WorkerRoot, } from "@usine/core/worker";
9
+ import { LaneItemState, LaneName } from "@usine/config/board";
10
+ import { RegistryTag } from "@usine/config/factory";
11
+ import { ConfigFileError, InstancePath } from "@usine/config/file";
12
+ import { canonicalLabelName, GitHubLabelName } from "@usine/config/label";
13
+ import { PromptTemplate } from "@usine/config/loop";
14
+ import { matchesSelector } from "@usine/config/selector";
15
+ import { Cron, TimeZone } from "@usine/config/trigger";
16
+ import { LoopControl } from "@usine/engine/loop-control";
17
+ import { RepositoryLabelProjectionReader } from "@usine/engine/repository-label-projection";
18
+ import { WorkerCapability } from "@usine/executor";
19
+ import { Source } from "@usine/expression/expression-engine";
20
+ import { Context, DateTime, Effect, Layer, Match, Option, Schema } from "effect";
21
+ import { LabelPreflightFinding } from "../label-reconciler.js";
22
+ import { PollingTriggers } from "../polling-triggers.js";
23
+ import { WorkerStatus } from "../worker-status.js";
24
+ /** A Loop's selector as written: the repositories and registry tags. */
25
+ export class LoopSelectorView extends Schema.Class("@usine/orchestrator/LoopSelectorView")({
26
+ repos: Schema.NullOr(Schema.Array(RepositoryName)),
27
+ tags: Schema.NullOr(Schema.Array(RegistryTag)),
28
+ }) {
29
+ }
30
+ /** A parsed Loop file with its runtime pause state. */
31
+ export class LoopFileView extends Schema.Class("@usine/orchestrator/LoopFileView")({
32
+ name: LoopName,
33
+ file: InstancePath,
34
+ /** The trigger's `on:` stream. */
35
+ stream: Schema.Literals(["issue", "pr", "schedule"]),
36
+ /** The trigger's `if:` expression as written. */
37
+ condition: Source,
38
+ /** A schedule trigger's cron and time zone, or null for the other streams. */
39
+ cron: Schema.NullOr(Cron),
40
+ timeZone: Schema.NullOr(TimeZone),
41
+ /** Null if the file has no selector, so the Loop applies to every registered repository. */
42
+ selector: Schema.NullOr(LoopSelectorView),
43
+ /** The registered repositories the selector selects, in `usine.yaml` order. */
44
+ repositories: Schema.Array(RepositoryName),
45
+ approval: ApprovalRequirement,
46
+ maxCycles: CycleLimit,
47
+ permissions: LoopPermissions,
48
+ step: StepName,
49
+ agent: AgentName,
50
+ /** The Markdown prompt template, with its `{{ }}` expressions as written. */
51
+ prompt: PromptTemplate,
52
+ paused: Schema.Boolean,
53
+ /** Labels the trigger compares against that `usine.yaml` doesn't declare in `labels`. */
54
+ undeclaredLabels: Schema.Array(GitHubLabelName),
55
+ }) {
56
+ }
57
+ /** A Loop file that failed to load and opens no Runs, with the failed stage and reason. */
58
+ export class QuarantinedLoopView extends Schema.Class("@usine/orchestrator/QuarantinedLoopView")({
59
+ /** The file name without its folder and `.md` extension. */
60
+ name: Schema.NonEmptyString,
61
+ file: InstancePath,
62
+ error: ConfigFileError,
63
+ }) {
64
+ }
65
+ /** A parsed rostered Agent file with the Loops that use it. */
66
+ export class AgentFileView extends Schema.Class("@usine/orchestrator/AgentFileView")({
67
+ name: AgentName,
68
+ file: InstancePath,
69
+ harness: Harness,
70
+ model: ModelId,
71
+ effort: Effort,
72
+ /** The file's own parent model and effort, or null if it sets none. */
73
+ parentModel: Schema.NullOr(ModelId),
74
+ parentEffort: Schema.NullOr(Effort),
75
+ /** The file's parent model, else `settings.parent_model`. If null, Pi chooses. */
76
+ resolvedParentModel: Schema.NullOr(ModelId),
77
+ /** The file's parent effort, else `settings.parent_effort`, else `effort`. */
78
+ resolvedParentEffort: Effort,
79
+ persona: AgentPersona,
80
+ /** The loaded Loops that use this Agent. */
81
+ loops: Schema.Array(LoopName),
82
+ }) {
83
+ }
84
+ /**
85
+ * An Agent file that failed to load and is left out of the roster, with the failed stage and
86
+ * reason.
87
+ */
88
+ export class InvalidAgentView extends Schema.Class("@usine/orchestrator/InvalidAgentView")({
89
+ /** The file name without its folder and `.md` extension. */
90
+ name: Schema.NonEmptyString,
91
+ file: InstancePath,
92
+ error: ConfigFileError,
93
+ }) {
94
+ }
95
+ /**
96
+ * The Gateway in front of an SSH Worker. Includes only the name of the environment variable with
97
+ * its admin token.
98
+ */
99
+ export class GatewayView extends Schema.Class("@usine/orchestrator/GatewayView")({
100
+ domain: GatewayDomain,
101
+ destination: SshDestination,
102
+ adminPort: GatewayAdminPort,
103
+ adminTokenEnv: Schema.NonEmptyString,
104
+ llmProviders: Schema.Array(GatewayLlmProvider),
105
+ }) {
106
+ }
107
+ /** The current slot usage of a Worker. */
108
+ export class WorkerSlotsView extends Schema.Class("@usine/orchestrator/WorkerSlotsView")({
109
+ /** The number of slots for Attempts: `max_concurrent_attempts` once a reload applied it. */
110
+ capacity: Schema.Int,
111
+ leased: Schema.Int,
112
+ }) {
113
+ }
114
+ /** A passed preflight check, at an ISO instant. */
115
+ export class PassedCheckView extends Schema.TaggedClass("@usine/orchestrator/PassedCheckView")("Passed", { checkedAt: Schema.String }) {
116
+ }
117
+ /** A preflight check that found a missing prerequisite or couldn't run, at an ISO instant. */
118
+ export class FailedCheckView extends Schema.TaggedClass("@usine/orchestrator/FailedCheckView")("Failed", {
119
+ checkedAt: Schema.String,
120
+ /** Null when the check itself failed, such as a timed-out probe. */
121
+ capability: Schema.NullOr(WorkerCapability),
122
+ message: Schema.String,
123
+ }) {
124
+ }
125
+ export const PreflightCheckView = Schema.Union([PassedCheckView, FailedCheckView]);
126
+ /** The last preflight of one harness on a Worker. */
127
+ export class HarnessPreflightView extends Schema.Class("@usine/orchestrator/HarnessPreflightView")({
128
+ harness: Harness,
129
+ check: PreflightCheckView,
130
+ }) {
131
+ }
132
+ /** A Worker as declared in `usine.yaml`, with its slot usage and last preflight. */
133
+ export class WorkerConfigurationView extends Schema.Class("@usine/orchestrator/WorkerConfigurationView")({
134
+ name: WorkerName,
135
+ kind: WorkerKind,
136
+ maxConcurrentAttempts: Schema.Int,
137
+ /** An SSH Worker's connection and root, or null for the other kinds. */
138
+ destination: Schema.NullOr(SshDestination),
139
+ port: Schema.NullOr(SshPort),
140
+ identityFile: Schema.NullOr(SshIdentityFile),
141
+ root: Schema.NullOr(WorkerRoot),
142
+ gateway: Schema.NullOr(GatewayView),
143
+ /** Null while the scheduler runs no Attempts, as in setup mode. */
144
+ slots: Schema.NullOr(WorkerSlotsView),
145
+ /**
146
+ * The Worker's own prerequisites: machine, Git, memory, Gateway, and credentials. Null before any
147
+ * preflight.
148
+ */
149
+ prerequisites: Schema.NullOr(PreflightCheckView),
150
+ /** In harness name order; empty before any harness check. */
151
+ harnesses: Schema.Array(HarnessPreflightView),
152
+ }) {
153
+ }
154
+ /** A Worker removed by a reload that still runs Attempts. It's removed when the last one ends. */
155
+ export class RemovedWorkerView extends Schema.Class("@usine/orchestrator/RemovedWorkerView")({
156
+ name: WorkerName,
157
+ running: Schema.Int,
158
+ }) {
159
+ }
160
+ /** A GitHub label in one repository, as of the last label poll. */
161
+ export class LabelStateView extends Schema.Class("@usine/orchestrator/LabelStateView")({
162
+ name: GitHubLabelName,
163
+ /** Null until polling has read the repository's labels. */
164
+ onGitHub: Schema.NullOr(Schema.Boolean),
165
+ /** The repository's label color, else the color declared in `labels`, as six hex digits. */
166
+ color: Schema.NullOr(Schema.String),
167
+ description: Schema.NullOr(Schema.String),
168
+ /** Whether `labels` in `usine.yaml` declares the label, so usine creates it if missing. */
169
+ declared: Schema.Boolean,
170
+ /** The reason usine couldn't create or confirm the label at the last poll. */
171
+ failure: Schema.NullOr(LabelPreflightFinding),
172
+ }) {
173
+ }
174
+ /** A lane source that routes Items by label. */
175
+ export class LabelLaneSourceView extends Schema.TaggedClass("@usine/orchestrator/LabelLaneSourceView")("Label", { label: LabelStateView }) {
176
+ }
177
+ /** A lane source that routes Items by issue or pull request state. */
178
+ export class StateLaneSourceView extends Schema.TaggedClass("@usine/orchestrator/StateLaneSourceView")("State", { state: LaneItemState }) {
179
+ }
180
+ export const LaneSourceView = Schema.Union([LabelLaneSourceView, StateLaneSourceView]);
181
+ /** One lane declared in `repos[].lanes`, with its sources in file order. */
182
+ export class LaneConfigurationView extends Schema.Class("@usine/orchestrator/LaneConfigurationView")({
183
+ name: LaneName,
184
+ sources: Schema.Array(LaneSourceView),
185
+ }) {
186
+ }
187
+ /** A registered repository with its lanes in Board order, declared labels, and Loops. */
188
+ export class RepositoryConfigurationView extends Schema.Class("@usine/orchestrator/RepositoryConfigurationView")({
189
+ name: RepositoryName,
190
+ tags: Schema.Array(RegistryTag),
191
+ /** Empty if `usine.yaml` declares no lanes, so the Board proposes lanes from the labels. */
192
+ lanes: Schema.Array(LaneConfigurationView),
193
+ /** The labels declared in `usine.yaml`, as this repository has them. */
194
+ declaredLabels: Schema.Array(LabelStateView),
195
+ /** The loaded Loops whose selector selects this repository. */
196
+ loops: Schema.Array(LoopName),
197
+ }) {
198
+ }
199
+ /** The `settings`, `operator`, and webhooks mode of `usine.yaml`, with defaults applied. */
200
+ export class SettingsView extends Schema.Class("@usine/orchestrator/SettingsView")({
201
+ pollInterval: Schema.Int,
202
+ maxChildren: Schema.Int,
203
+ maxAttemptMinutes: Schema.NullOr(Schema.Int),
204
+ maxAttemptTokens: Schema.NullOr(Schema.Int),
205
+ parentModel: Schema.NullOr(ModelId),
206
+ parentEffort: Schema.NullOr(Effort),
207
+ operator: Schema.NullOr(OperatorLogin),
208
+ webhooks: Schema.Literals(["off", "deliveries", "endpoint"]),
209
+ /** The public URL for `endpoint` webhooks, or null for the other modes. */
210
+ webhooksPublicUrl: Schema.NullOr(Schema.String),
211
+ }) {
212
+ }
213
+ /**
214
+ * The parsed instance folder (Loops, Agents, Workers, repositories, and settings), the files that
215
+ * failed to load, and the runtime state of each.
216
+ */
217
+ export class ConfigurationView extends Schema.Class("@usine/orchestrator/ConfigurationView")({
218
+ loops: Schema.Array(LoopFileView),
219
+ quarantinedLoops: Schema.Array(QuarantinedLoopView),
220
+ agents: Schema.Array(AgentFileView),
221
+ invalidAgents: Schema.Array(InvalidAgentView),
222
+ workers: Schema.Array(WorkerConfigurationView),
223
+ removedWorkers: Schema.Array(RemovedWorkerView),
224
+ repositories: Schema.Array(RepositoryConfigurationView),
225
+ settings: SettingsView,
226
+ }) {
227
+ }
228
+ const fileStem = (file) => {
229
+ const name = file.slice(file.lastIndexOf("/") + 1).replace(/\.md$/u, "");
230
+ return name === "" ? file : name;
231
+ };
232
+ /** Returns the operator API view of a preflight check. */
233
+ export const checkView = (check) => Match.valueTags(check, {
234
+ Passed: ({ checkedAt }) => new PassedCheckView({ checkedAt: DateTime.formatIso(checkedAt) }),
235
+ Failed: ({ checkedAt, capability, message }) => new FailedCheckView({
236
+ checkedAt: DateTime.formatIso(checkedAt),
237
+ capability: Option.getOrNull(capability),
238
+ message,
239
+ }),
240
+ });
241
+ const workerConnection = (worker) => worker.kind === "ssh"
242
+ ? {
243
+ destination: worker.destination,
244
+ port: Option.getOrNull(worker.port),
245
+ identityFile: Option.getOrNull(worker.identityFile),
246
+ root: worker.root,
247
+ gateway: Option.match(worker.gateway, {
248
+ onNone: () => null,
249
+ onSome: (gateway) => new GatewayView({
250
+ domain: gateway.domain,
251
+ destination: gateway.destination,
252
+ adminPort: gateway.adminPort,
253
+ adminTokenEnv: gateway.adminTokenEnv,
254
+ llmProviders: gateway.llmProviders,
255
+ }),
256
+ }),
257
+ }
258
+ : { destination: null, port: null, identityFile: null, root: null, gateway: null };
259
+ const makeOperatorConfiguration = Effect.gen(function* () {
260
+ const controls = yield* LoopControl;
261
+ const repositoryLabels = yield* RepositoryLabelProjectionReader;
262
+ const polling = yield* PollingTriggers;
263
+ const workerStatus = yield* WorkerStatus;
264
+ const repositoryView = Effect.fn("OperatorConfiguration.repository")(function* (instance, repository, findings) {
265
+ const projection = yield* repositoryLabels.get(repository.name);
266
+ const catalog = Option.map(projection, ({ labels }) => new Map(labels.map((label) => [canonicalLabelName(label.name), label])));
267
+ const declared = new Map(instance.config.labels.map((label) => [canonicalLabelName(label.name), label]));
268
+ const labelState = (name) => {
269
+ const key = canonicalLabelName(name);
270
+ const found = Option.flatMap(catalog, (labels) => Option.fromNullishOr(labels.get(key)));
271
+ const authored = declared.get(key);
272
+ return new LabelStateView({
273
+ name,
274
+ onGitHub: Option.match(catalog, { onNone: () => null, onSome: () => Option.isSome(found) }),
275
+ color: Option.getOrNull(Option.orElse(Option.flatMap(found, ({ color }) => color), () => Option.flatMap(Option.fromNullishOr(authored), ({ color }) => color))),
276
+ description: Option.getOrNull(Option.orElse(Option.flatMap(found, ({ description }) => description), () => Option.flatMap(Option.fromNullishOr(authored), ({ description }) => description))),
277
+ declared: authored !== undefined,
278
+ failure: findings.find((finding) => finding.repository === repository.name && canonicalLabelName(finding.label) === key) ?? null,
279
+ });
280
+ };
281
+ return new RepositoryConfigurationView({
282
+ name: repository.name,
283
+ tags: repository.tags,
284
+ lanes: repository.lanes.map((lane) => new LaneConfigurationView({
285
+ name: lane.name,
286
+ sources: lane.sources.map((source) => "label" in source
287
+ ? new LabelLaneSourceView({ label: labelState(source.label) })
288
+ : new StateLaneSourceView({ state: source.state })),
289
+ })),
290
+ declaredLabels: instance.config.labels.map(({ name }) => labelState(name)),
291
+ loops: instance.loops
292
+ .filter((loop) => matchesSelector(loop.selector, repository))
293
+ .map(({ name }) => name),
294
+ });
295
+ });
296
+ const view = Effect.fn("OperatorConfiguration.view")(function* (instance) {
297
+ const { config } = instance;
298
+ const [states, latestPoll, slots, preflights] = yield* Effect.all([controls.states, polling.latest, workerStatus.slots, workerStatus.preflights], { concurrency: "unbounded" });
299
+ const paused = new Set(states.filter((state) => state.paused).map((state) => state.loop));
300
+ const findings = Option.match(latestPoll, {
301
+ onNone: () => [],
302
+ onSome: ({ preflightFindings }) => preflightFindings,
303
+ });
304
+ const repositories = yield* Effect.forEach(config.repos, (repository) => repositoryView(instance, repository, findings), { concurrency: 4 });
305
+ const undeclared = (loop) => instance.warnings.flatMap((warning) => warning._tag === "UndeclaredTriggerLabelWarning" && warning.loop === loop
306
+ ? [warning.label]
307
+ : []);
308
+ const loops = instance.loops.map((loop) => new LoopFileView({
309
+ name: loop.name,
310
+ file: InstancePath.make(`loops/${loop.name}.md`),
311
+ stream: loop.trigger.on,
312
+ condition: loop.trigger.if,
313
+ cron: loop.trigger.on === "schedule" ? loop.trigger.cron : null,
314
+ timeZone: loop.trigger.on === "schedule" ? loop.trigger.tz : null,
315
+ selector: Option.match(loop.selector, {
316
+ onNone: () => null,
317
+ onSome: ({ repos, tags }) => new LoopSelectorView({
318
+ repos: Option.getOrNull(repos),
319
+ tags: Option.getOrNull(tags),
320
+ }),
321
+ }),
322
+ repositories: config.repos
323
+ .filter((repository) => matchesSelector(loop.selector, repository))
324
+ .map(({ name }) => name),
325
+ approval: loop.approval,
326
+ maxCycles: loop.maxCycles,
327
+ permissions: loop.permissions,
328
+ step: loop.step,
329
+ agent: loop.agent,
330
+ prompt: loop.body,
331
+ paused: paused.has(loop.name),
332
+ undeclaredLabels: undeclared(loop.name),
333
+ }));
334
+ const agents = instance.agents.map((file) => new AgentFileView({
335
+ name: file.name,
336
+ file: InstancePath.make(`agents/${file.name}.md`),
337
+ harness: file.harness,
338
+ model: file.model,
339
+ effort: file.effort,
340
+ parentModel: Option.getOrNull(file.parentModel),
341
+ parentEffort: Option.getOrNull(file.parentEffort),
342
+ resolvedParentModel: Option.getOrNull(resolveParentModel(file.agent, config.settings.parentModel)),
343
+ resolvedParentEffort: resolveParentEffort(file.agent, config.settings.parentEffort),
344
+ persona: file.persona,
345
+ loops: instance.loops.filter(({ agent }) => agent === file.name).map(({ name }) => name),
346
+ }));
347
+ const slotsBy = new Map(slots.map((slot) => [slot.worker, slot]));
348
+ const preflightBy = new Map(preflights.map((preflight) => [preflight.worker, preflight]));
349
+ const declaredWorkers = new Set(config.workers.map(({ name }) => name));
350
+ const workers = config.workers.map((worker) => {
351
+ const slot = slotsBy.get(worker.name);
352
+ const preflight = preflightBy.get(worker.name);
353
+ return new WorkerConfigurationView({
354
+ name: worker.name,
355
+ kind: worker.kind,
356
+ maxConcurrentAttempts: worker.maxConcurrentAttempts,
357
+ ...workerConnection(worker),
358
+ slots: slot === undefined
359
+ ? null
360
+ : new WorkerSlotsView({ capacity: slot.capacity, leased: slot.leased }),
361
+ prerequisites: preflight === undefined
362
+ ? null
363
+ : Option.getOrNull(Option.map(preflight.prerequisites, checkView)),
364
+ harnesses: (preflight?.harnesses ?? []).map(({ harness, check }) => new HarnessPreflightView({ harness, check: checkView(check) })),
365
+ });
366
+ });
367
+ const { settings, webhooks } = config;
368
+ const configuration = new ConfigurationView({
369
+ loops,
370
+ quarantinedLoops: instance.quarantinedLoops.map(({ file, error }) => new QuarantinedLoopView({ name: fileStem(file), file, error })),
371
+ agents,
372
+ invalidAgents: instance.invalidAgents.map(({ file, error }) => new InvalidAgentView({ name: fileStem(file), file, error })),
373
+ workers,
374
+ removedWorkers: slots
375
+ .filter(({ worker, leased }) => !declaredWorkers.has(worker) && leased > 0)
376
+ .map(({ worker, leased }) => new RemovedWorkerView({ name: worker, running: leased })),
377
+ repositories,
378
+ settings: new SettingsView({
379
+ pollInterval: settings.pollInterval,
380
+ maxChildren: settings.maxChildren,
381
+ maxAttemptMinutes: Option.getOrNull(settings.maxAttemptMinutes),
382
+ maxAttemptTokens: Option.getOrNull(settings.maxAttemptTokens),
383
+ parentModel: Option.getOrNull(settings.parentModel),
384
+ parentEffort: Option.getOrNull(settings.parentEffort),
385
+ operator: Option.getOrNull(config.operator),
386
+ webhooks: webhooks.mode,
387
+ webhooksPublicUrl: webhooks.mode === "endpoint" ? webhooks.publicUrl.href : null,
388
+ }),
389
+ });
390
+ yield* Effect.logDebug("Read the configuration view", {
391
+ loops: loops.length,
392
+ quarantinedLoops: configuration.quarantinedLoops.length,
393
+ agents: agents.length,
394
+ invalidAgents: configuration.invalidAgents.length,
395
+ workers: workers.length,
396
+ runningWorkers: slots.length,
397
+ repositories: repositories.length,
398
+ });
399
+ return configuration;
400
+ });
401
+ return { view };
402
+ });
403
+ /**
404
+ * The operator's view of the parsed instance folder and its runtime state. Reads only memory and
405
+ * the runtime store, never the files.
406
+ */
407
+ export class OperatorConfiguration extends Context.Service()("@usine/orchestrator/OperatorConfiguration") {
408
+ static layer = Layer.effect(OperatorConfiguration, makeOperatorConfiguration);
409
+ }
410
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/operator/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EA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AC,MAAM;YACvD,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM;YACjD,OAAO,EAAE,OAAO,CAAC,MAAM;YACvB,cAAc,EAAE,KAAK,CAAC,MAAM;YAC5B,YAAY,EAAE,YAAY,CAAC,MAAM;SAClC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAW,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,OAAO,CAAC,OAAO,EAWvD,CAAC,2CAA2C,CAAC;IAC9C,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;CACxF"}
@@ -0,0 +1,181 @@
1
+ import type { LoadedInstance } from "@usine/config/instance";
2
+ import { CycleBudgetAsk } from "@usine/core/cycle-budget";
3
+ import { CycleBudgets } from "@usine/engine/cycle-budget";
4
+ import { ItemProjectionReader } from "@usine/engine/item-projection";
5
+ import { LoopControl } from "@usine/engine/loop-control";
6
+ import type { RunStoreError } from "@usine/engine/engine";
7
+ import { RunReader } from "@usine/engine/run-reader";
8
+ import { Context, Effect, Layer, Schema } from "effect";
9
+ import { PollingTriggers } from "../polling-triggers.ts";
10
+ import { WorkerStatus } from "../worker-status.ts";
11
+ import { AttemptView } from "./attempt.ts";
12
+ import { BoardItemLink } from "./board.ts";
13
+ import { WorkerSlotsView } from "./configuration.ts";
14
+ import { RunView } from "./run.ts";
15
+ declare const WorkerSilentView_base: Schema.Class<WorkerSilentView, Schema.TaggedStruct<"WorkerSilent", {
16
+ readonly worker: Schema.brand<Schema.String, "WorkerName">;
17
+ readonly lastAnsweredAt: Schema.String;
18
+ }>, {}>;
19
+ /** The Attempt's Worker hasn't answered the executor's probe since `lastAnsweredAt`. */
20
+ export declare class WorkerSilentView extends WorkerSilentView_base {
21
+ }
22
+ declare const ProviderRetryingView_base: Schema.Class<ProviderRetryingView, Schema.TaggedStruct<"ProviderRetrying", {
23
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
24
+ readonly message: Schema.NonEmptyString;
25
+ readonly retries: Schema.brand<Schema.Int, "ProviderRetries">;
26
+ readonly since: Schema.String;
27
+ }>, {}>;
28
+ /**
29
+ * A session's harness is retrying its model provider: the retries in this turn, the latest report,
30
+ * and when the first unanswered retry was recorded.
31
+ */
32
+ export declare class ProviderRetryingView extends ProviderRetryingView_base {
33
+ }
34
+ /**
35
+ * An open connectivity problem in an Attempt's transcript. It's a warning and never stops the
36
+ * Attempt (ADR 0013).
37
+ */
38
+ export declare const ConnectivityWarningView: Schema.Union<readonly [typeof WorkerSilentView, typeof ProviderRetryingView]>;
39
+ export type ConnectivityWarningView = typeof ConnectivityWarningView.Type;
40
+ declare const RunningAttemptView_base: Schema.Class<RunningAttemptView, Schema.Struct<{
41
+ readonly run: typeof RunView;
42
+ readonly attempt: typeof AttemptView;
43
+ /**
44
+ * The Run's Item as its Board card links it, or null for a schedule Run or an Item the desk
45
+ * didn't read.
46
+ */
47
+ readonly item: Schema.NullOr<typeof BoardItemLink>;
48
+ /**
49
+ * When the Attempt's sessions last showed work, excluding Worker notices, pool meters, and
50
+ * provider retries. Null if the newest rows show none.
51
+ */
52
+ readonly lastActivityAt: Schema.NullOr<Schema.String>;
53
+ /** The connectivity problems still open after the newest rows. */
54
+ readonly warnings: Schema.$Array<Schema.Union<readonly [typeof WorkerSilentView, typeof ProviderRetryingView]>>;
55
+ }>, {}>;
56
+ /** A running Attempt with its Run, Item, and recent transcript activity. */
57
+ export declare class RunningAttemptView extends RunningAttemptView_base {
58
+ }
59
+ declare const SuppressedForOperatorView_base: Schema.Class<SuppressedForOperatorView, Schema.TaggedStruct<"SuppressedForOperator", {
60
+ readonly run: typeof RunView;
61
+ }>, {}>;
62
+ /**
63
+ * An Agent's question or blocker that suppresses the Item for the Loop until the operator answers
64
+ * or resolves `run`, or the Item changes (ADR 0017).
65
+ */
66
+ export declare class SuppressedForOperatorView extends SuppressedForOperatorView_base {
67
+ }
68
+ declare const ClosedUnchangedView_base: Schema.Class<ClosedUnchangedView, Schema.TaggedStruct<"ClosedUnchanged", {
69
+ readonly run: typeof RunView;
70
+ }>, {}>;
71
+ /**
72
+ * `run` succeeded or was canceled on the Item's current state, so the Loop opens no other Run until
73
+ * the state changes (ADR 0007).
74
+ */
75
+ export declare class ClosedUnchangedView extends ClosedUnchangedView_base {
76
+ }
77
+ declare const RunFailedView_base: Schema.Class<RunFailedView, Schema.TaggedStruct<"RunFailed", {
78
+ readonly run: typeof RunView;
79
+ }>, {}>;
80
+ /** `run` failed on the Item's current state and waits for the operator to retry it. */
81
+ export declare class RunFailedView extends RunFailedView_base {
82
+ }
83
+ declare const LoopPausedView_base: Schema.Class<LoopPausedView, Schema.TaggedStruct<"LoopPaused", {}>, {}>;
84
+ /** The Loop is paused, so its trigger opens no Run. */
85
+ export declare class LoopPausedView extends LoopPausedView_base {
86
+ }
87
+ declare const CycleBudgetUsedUpView_base: Schema.Class<CycleBudgetUsedUpView, Schema.TaggedStruct<"CycleBudgetUsedUp", {
88
+ readonly ask: typeof CycleBudgetAsk;
89
+ }>, {}>;
90
+ /** The Item used up its cycle budget; `ask` waits for the operator to reset it. */
91
+ export declare class CycleBudgetUsedUpView extends CycleBudgetUsedUpView_base {
92
+ }
93
+ declare const AwaitingApprovalView_base: Schema.Class<AwaitingApprovalView, Schema.TaggedStruct<"AwaitingApproval", {
94
+ readonly run: typeof RunView;
95
+ }>, {}>;
96
+ /** `run` waits for the operator's approval. */
97
+ export declare class AwaitingApprovalView extends AwaitingApprovalView_base {
98
+ }
99
+ declare const QueuedForWorkerView_base: Schema.Class<QueuedForWorkerView, Schema.TaggedStruct<"QueuedForWorker", {
100
+ readonly run: typeof RunView;
101
+ }>, {}>;
102
+ /** `run` waits for a free Worker slot. */
103
+ export declare class QueuedForWorkerView extends QueuedForWorkerView_base {
104
+ }
105
+ declare const AwaitingPollView_base: Schema.Class<AwaitingPollView, Schema.TaggedStruct<"AwaitingPoll", {}>, {}>;
106
+ /** No Event of the Loop has a Run for the Item's current state yet. The next poll acts on it. */
107
+ export declare class AwaitingPollView extends AwaitingPollView_base {
108
+ }
109
+ /** The reason a matched Item has no running Attempt. */
110
+ export declare const StallReasonView: Schema.Union<readonly [typeof AwaitingApprovalView, typeof SuppressedForOperatorView, typeof CycleBudgetUsedUpView, typeof RunFailedView, typeof ClosedUnchangedView, typeof LoopPausedView, typeof QueuedForWorkerView, typeof AwaitingPollView]>;
111
+ export type StallReasonView = typeof StallReasonView.Type;
112
+ declare const StalledItemView_base: Schema.Class<StalledItemView, Schema.Struct<{
113
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
114
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
115
+ readonly item: typeof BoardItemLink;
116
+ readonly reason: Schema.Union<readonly [typeof AwaitingApprovalView, typeof SuppressedForOperatorView, typeof CycleBudgetUsedUpView, typeof RunFailedView, typeof ClosedUnchangedView, typeof LoopPausedView, typeof QueuedForWorkerView, typeof AwaitingPollView]>;
117
+ }>, {}>;
118
+ /** An Item that a Loop's trigger matches with no running Attempt, and the reason. */
119
+ export declare class StalledItemView extends StalledItemView_base {
120
+ }
121
+ declare const ClosedRunView_base: Schema.Class<ClosedRunView, Schema.Struct<{
122
+ readonly run: typeof RunView;
123
+ /**
124
+ * The Run's Item as its Board card links it, or null for a schedule Run or an Item the desk
125
+ * didn't read.
126
+ */
127
+ readonly item: Schema.NullOr<typeof BoardItemLink>;
128
+ /** The Run's `closedAt`, set even for a Run canceled before any Attempt. */
129
+ readonly closedAt: Schema.String;
130
+ }>, {}>;
131
+ /** A closed Run with its Item and close time. */
132
+ export declare class ClosedRunView extends ClosedRunView_base {
133
+ }
134
+ declare const WorkerView_base: Schema.Class<WorkerView, Schema.Struct<{
135
+ readonly name: Schema.brand<Schema.String, "WorkerName">;
136
+ /**
137
+ * The slots as the scheduler leases them. If the scheduler runs no Attempts (as in setup mode),
138
+ * the declared `max_concurrent_attempts` with none leased.
139
+ */
140
+ readonly slots: typeof WorkerSlotsView;
141
+ /**
142
+ * The newest failed check among the Worker's prerequisites and harnesses, or else the newest
143
+ * passed check. Null before the first preflight.
144
+ */
145
+ readonly preflight: Schema.NullOr<Schema.Union<readonly [typeof import("./configuration.ts").PassedCheckView, typeof import("./configuration.ts").FailedCheckView]>>;
146
+ }>, {}>;
147
+ /** One Worker on the desk's Workers line, with its slots and last preflight. */
148
+ export declare class WorkerView extends WorkerView_base {
149
+ }
150
+ declare const RepositoryPollView_base: Schema.Class<RepositoryPollView, Schema.Struct<{
151
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
152
+ readonly polledAt: Schema.NullOr<Schema.String>;
153
+ }>, {}>;
154
+ /**
155
+ * When the factory last finished polling a managed repository, or null before the first poll ends.
156
+ */
157
+ export declare class RepositoryPollView extends RepositoryPollView_base {
158
+ }
159
+ declare const DeskView_base: Schema.Class<DeskView, Schema.Struct<{
160
+ readonly running: Schema.$Array<typeof RunningAttemptView>;
161
+ readonly notMoving: Schema.$Array<typeof StalledItemView>;
162
+ readonly lastOutcomes: Schema.$Array<typeof ClosedRunView>;
163
+ readonly workers: Schema.$Array<typeof WorkerView>;
164
+ readonly polls: Schema.$Array<typeof RepositoryPollView>;
165
+ }>, {}>;
166
+ /**
167
+ * The operator's desk: running Attempts, stalled matched Items, recently closed Runs, Worker slots,
168
+ * and poll times. Needs you comes from the overview.
169
+ */
170
+ export declare class DeskView extends DeskView_base {
171
+ }
172
+ declare const OperatorDesk_base: Context.ServiceClass<OperatorDesk, "@usine/orchestrator/OperatorDesk", {
173
+ /** Returns the instance's desk, as described in `OperatorObservation.desk`. */
174
+ readonly desk: (instance: LoadedInstance) => Effect.Effect<DeskView, RunStoreError>;
175
+ }>;
176
+ /** Builds the operator's desk from the engine's stores, the Loop matches, and the scheduler's slots. */
177
+ export declare class OperatorDesk extends OperatorDesk_base {
178
+ static readonly layer: Layer.Layer<OperatorDesk, never, CycleBudgets | import("@usine/expression/expression-engine").ExpressionEngine | ItemProjectionReader | LoopControl | PollingTriggers | RunReader | WorkerStatus>;
179
+ }
180
+ export {};
181
+ //# sourceMappingURL=desk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desk.d.ts","sourceRoot":"","sources":["../../src/operator/desk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAqB,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AAEzF,OAAO,EAAE,OAAO,EAAY,MAAM,EAAE,KAAK,EAAgC,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAA6C,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAiC,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;;;;;AAiBnC,wFAAwF;AACxF,qBAAa,gBAAiB,SAAQ,qBAEkC;CAAG;;;;;;;AAE3E;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,yBAOxC;CAAG;AAEL;;;GAGG;AACH,eAAO,MAAM,uBAAuB,+EAAyD,CAAC;AAC9F,MAAM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