@usine/orchestrator 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/README.md +174 -52
- package/dist/board/items.d.ts +22 -3
- package/dist/board/items.d.ts.map +1 -1
- package/dist/board/items.js +44 -4
- package/dist/board/items.js.map +1 -1
- package/dist/board/projection.d.ts +8 -1
- package/dist/board/projection.d.ts.map +1 -1
- package/dist/board/projection.js +63 -14
- package/dist/board/projection.js.map +1 -1
- package/dist/board/tasks.d.ts +15 -3
- package/dist/board/tasks.d.ts.map +1 -1
- package/dist/board/tasks.js +28 -9
- package/dist/board/tasks.js.map +1 -1
- package/dist/cloudflare.d.ts +32 -0
- package/dist/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare.js +68 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/credentials.d.ts +5 -6
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +22 -15
- package/dist/credentials.js.map +1 -1
- package/dist/current-instance/changes.d.ts +87 -0
- package/dist/current-instance/changes.d.ts.map +1 -0
- package/dist/current-instance/changes.js +141 -0
- package/dist/current-instance/changes.js.map +1 -0
- package/dist/current-instance/current-instance.d.ts +89 -0
- package/dist/current-instance/current-instance.d.ts.map +1 -0
- package/dist/current-instance/current-instance.js +163 -0
- package/dist/current-instance/current-instance.js.map +1 -0
- package/dist/exe-dev.d.ts +6 -2
- package/dist/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev.js +10 -9
- package/dist/exe-dev.js.map +1 -1
- package/dist/http-client.d.ts +8 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +8 -0
- package/dist/http-client.js.map +1 -0
- package/dist/idle-triggers.d.ts +1 -1
- package/dist/idle-triggers.d.ts.map +1 -1
- package/dist/idle-triggers.js +1 -1
- package/dist/idle-triggers.js.map +1 -1
- package/dist/label-reconciler.d.ts +5 -2
- package/dist/label-reconciler.d.ts.map +1 -1
- package/dist/label-reconciler.js.map +1 -1
- package/dist/lease-order.d.ts +60 -0
- package/dist/lease-order.d.ts.map +1 -0
- package/dist/lease-order.js +76 -0
- package/dist/lease-order.js.map +1 -0
- package/dist/local.d.ts +4 -18
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +9 -45
- package/dist/local.js.map +1 -1
- package/dist/loop-matches.d.ts +28 -0
- package/dist/loop-matches.d.ts.map +1 -0
- package/dist/loop-matches.js +74 -0
- package/dist/loop-matches.js.map +1 -0
- package/dist/operator/attempt.d.ts +76 -10
- package/dist/operator/attempt.d.ts.map +1 -1
- package/dist/operator/attempt.js +69 -11
- package/dist/operator/attempt.js.map +1 -1
- package/dist/operator/board.d.ts +48 -16
- package/dist/operator/board.d.ts.map +1 -1
- package/dist/operator/board.js +48 -17
- package/dist/operator/board.js.map +1 -1
- package/dist/operator/configuration.d.ts +314 -0
- package/dist/operator/configuration.d.ts.map +1 -0
- package/dist/operator/configuration.js +490 -0
- package/dist/operator/configuration.js.map +1 -0
- package/dist/operator/desk.d.ts +206 -0
- package/dist/operator/desk.d.ts.map +1 -0
- package/dist/operator/desk.js +525 -0
- package/dist/operator/desk.js.map +1 -0
- package/dist/operator/github-changes.d.ts +88 -0
- package/dist/operator/github-changes.d.ts.map +1 -0
- package/dist/operator/github-changes.js +266 -0
- package/dist/operator/github-changes.js.map +1 -0
- package/dist/operator/http.d.ts +135 -105
- package/dist/operator/http.d.ts.map +1 -1
- package/dist/operator/http.js +155 -30
- package/dist/operator/http.js.map +1 -1
- package/dist/operator/machines.d.ts +71 -0
- package/dist/operator/machines.d.ts.map +1 -0
- package/dist/operator/machines.js +103 -0
- package/dist/operator/machines.js.map +1 -0
- package/dist/operator/need.d.ts +58 -11
- package/dist/operator/need.d.ts.map +1 -1
- package/dist/operator/need.js +61 -9
- package/dist/operator/need.js.map +1 -1
- package/dist/operator/operator.d.ts +135 -29
- package/dist/operator/operator.d.ts.map +1 -1
- package/dist/operator/operator.js +370 -63
- package/dist/operator/operator.js.map +1 -1
- package/dist/operator/overview.d.ts +7 -7
- package/dist/operator/overview.d.ts.map +1 -1
- package/dist/operator/overview.js +5 -5
- package/dist/operator/overview.js.map +1 -1
- package/dist/operator/projection.d.ts +56 -5
- package/dist/operator/projection.d.ts.map +1 -1
- package/dist/operator/projection.js +108 -9
- package/dist/operator/projection.js.map +1 -1
- package/dist/operator/run.d.ts +101 -6
- package/dist/operator/run.d.ts.map +1 -1
- package/dist/operator/run.js +100 -7
- package/dist/operator/run.js.map +1 -1
- package/dist/operator/statistics/cache.d.ts +7 -0
- package/dist/operator/statistics/cache.d.ts.map +1 -0
- package/dist/operator/statistics/cache.js +40 -0
- package/dist/operator/statistics/cache.js.map +1 -0
- package/dist/operator/statistics/runs.d.ts +36 -0
- package/dist/operator/statistics/runs.d.ts.map +1 -0
- package/dist/operator/statistics/runs.js +284 -0
- package/dist/operator/statistics/runs.js.map +1 -0
- package/dist/operator/statistics/statistics.d.ts +20 -0
- package/dist/operator/statistics/statistics.d.ts.map +1 -0
- package/dist/operator/statistics/statistics.js +138 -0
- package/dist/operator/statistics/statistics.js.map +1 -0
- package/dist/operator/statistics/tasks.d.ts +30 -0
- package/dist/operator/statistics/tasks.d.ts.map +1 -0
- package/dist/operator/statistics/tasks.js +244 -0
- package/dist/operator/statistics/tasks.js.map +1 -0
- package/dist/operator/statistics/view.d.ts +302 -0
- package/dist/operator/statistics/view.d.ts.map +1 -0
- package/dist/operator/statistics/view.js +243 -0
- package/dist/operator/statistics/view.js.map +1 -0
- package/dist/operator/statistics/window.d.ts +24 -0
- package/dist/operator/statistics/window.d.ts.map +1 -0
- package/dist/operator/statistics/window.js +47 -0
- package/dist/operator/statistics/window.js.map +1 -0
- package/dist/operator/task.d.ts +94 -0
- package/dist/operator/task.d.ts.map +1 -0
- package/dist/operator/task.js +204 -0
- package/dist/operator/task.js.map +1 -0
- package/dist/operator/transcript.d.ts +12 -12
- package/dist/operator/transcript.d.ts.map +1 -1
- package/dist/operator/transcript.js +11 -9
- package/dist/operator/transcript.js.map +1 -1
- package/dist/operator/usage.d.ts +103 -0
- package/dist/operator/usage.d.ts.map +1 -0
- package/dist/operator/usage.js +234 -0
- package/dist/operator/usage.js.map +1 -0
- package/dist/orchestrator.d.ts +8 -5
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +4 -2
- package/dist/orchestrator.js.map +1 -1
- package/dist/polling/closed-item-asks.d.ts +8 -0
- package/dist/polling/closed-item-asks.d.ts.map +1 -0
- package/dist/polling/closed-item-asks.js +28 -0
- package/dist/polling/closed-item-asks.js.map +1 -0
- package/dist/polling/cycle.d.ts +28 -10
- package/dist/polling/cycle.d.ts.map +1 -1
- package/dist/polling/cycle.js +20 -6
- package/dist/polling/cycle.js.map +1 -1
- package/dist/polling/evaluation-failures.d.ts +42 -0
- package/dist/polling/evaluation-failures.d.ts.map +1 -0
- package/dist/polling/evaluation-failures.js +103 -0
- package/dist/polling/evaluation-failures.js.map +1 -0
- package/dist/polling/hints.d.ts +2 -2
- package/dist/polling/hints.d.ts.map +1 -1
- package/dist/polling/hints.js +2 -2
- package/dist/polling/hints.js.map +1 -1
- package/dist/polling/loop-evaluation.d.ts +21 -11
- package/dist/polling/loop-evaluation.d.ts.map +1 -1
- package/dist/polling/loop-evaluation.js +70 -27
- package/dist/polling/loop-evaluation.js.map +1 -1
- package/dist/polling/open-issues.d.ts +23 -0
- package/dist/polling/open-issues.d.ts.map +1 -0
- package/dist/polling/open-issues.js +77 -0
- package/dist/polling/open-issues.js.map +1 -0
- package/dist/polling/open-pull-requests.d.ts +28 -0
- package/dist/polling/open-pull-requests.d.ts.map +1 -0
- package/dist/polling/open-pull-requests.js +131 -0
- package/dist/polling/open-pull-requests.js.map +1 -0
- package/dist/polling/polling.d.ts +20 -11
- package/dist/polling/polling.d.ts.map +1 -1
- package/dist/polling/polling.js +215 -52
- package/dist/polling/polling.js.map +1 -1
- package/dist/polling/repository-sync.d.ts +21 -14
- package/dist/polling/repository-sync.d.ts.map +1 -1
- package/dist/polling/repository-sync.js +35 -28
- package/dist/polling/repository-sync.js.map +1 -1
- package/dist/polling-triggers.d.ts +1 -1
- package/dist/polling-triggers.d.ts.map +1 -1
- package/dist/polling-triggers.js +1 -1
- package/dist/polling-triggers.js.map +1 -1
- package/dist/reloads.d.ts +14 -0
- package/dist/reloads.d.ts.map +1 -0
- package/dist/reloads.js +7 -0
- package/dist/reloads.js.map +1 -0
- package/dist/runtime.d.ts +24 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +58 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schedule-triggers.d.ts +14 -10
- package/dist/schedule-triggers.d.ts.map +1 -1
- package/dist/schedule-triggers.js +36 -31
- package/dist/schedule-triggers.js.map +1 -1
- package/dist/scheduler.d.ts +45 -5
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +587 -44
- package/dist/scheduler.js.map +1 -1
- package/dist/ssh.d.ts +103 -0
- package/dist/ssh.d.ts.map +1 -0
- package/dist/ssh.js +144 -0
- package/dist/ssh.js.map +1 -0
- package/dist/trigger-condition.d.ts +12 -0
- package/dist/trigger-condition.d.ts.map +1 -0
- package/dist/trigger-condition.js +88 -0
- package/dist/trigger-condition.js.map +1 -0
- package/dist/trigger-submission.d.ts +16 -13
- package/dist/trigger-submission.d.ts.map +1 -1
- package/dist/trigger-submission.js +19 -14
- package/dist/trigger-submission.js.map +1 -1
- package/dist/worker-engine.d.ts +13 -0
- package/dist/worker-engine.d.ts.map +1 -0
- package/dist/worker-engine.js +56 -0
- package/dist/worker-engine.js.map +1 -0
- package/dist/worker-status.d.ts +140 -0
- package/dist/worker-status.d.ts.map +1 -0
- package/dist/worker-status.js +76 -0
- package/dist/worker-status.js.map +1 -0
- package/package.json +47 -22
package/dist/operator/run.d.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import { BrainSpec } from "@usine/core/agent/brain";
|
|
2
|
+
import { RunAgain } from "@usine/core/run/again";
|
|
3
|
+
import { ApprovalSource } from "@usine/core/run/approval";
|
|
1
4
|
import { Schema } from "effect";
|
|
2
5
|
import { AttemptView } from "./attempt.ts";
|
|
6
|
+
import { MachineView } from "./machines.ts";
|
|
3
7
|
import { TranscriptEventView, TranscriptPageCursor } from "./transcript.ts";
|
|
4
|
-
|
|
8
|
+
import { RunUsageView } from "./usage.ts";
|
|
9
|
+
/** The stored Run lifecycle state as shown in operator views. */
|
|
5
10
|
export declare const RunStateTag: Schema.Literals<readonly ["Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled"]>;
|
|
6
11
|
export type RunStateTag = typeof RunStateTag.Type;
|
|
7
12
|
declare const EditAndRetry_base: Schema.Class<EditAndRetry, Schema.Struct<{
|
|
8
13
|
readonly task: Schema.brand<Schema.String, "AttemptTask">;
|
|
9
14
|
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
10
15
|
}>, {}>;
|
|
11
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The operator's replacement task and roster Agent. The server derives the Agent's persona and
|
|
18
|
+
* brain.
|
|
19
|
+
*/
|
|
12
20
|
export declare class EditAndRetry extends EditAndRetry_base {
|
|
13
21
|
}
|
|
14
22
|
declare const SessionIntervention_base: Schema.Class<SessionIntervention, Schema.Struct<{
|
|
@@ -23,39 +31,126 @@ declare const RosterAgentNotFoundError_base: Schema.Class<RosterAgentNotFoundErr
|
|
|
23
31
|
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
24
32
|
readonly message: Schema.String;
|
|
25
33
|
}>, import("effect/Cause").YieldableError>;
|
|
26
|
-
/** The requested Agent
|
|
34
|
+
/** The requested Agent isn't in the loaded roster. */
|
|
27
35
|
export declare class RosterAgentNotFoundError extends RosterAgentNotFoundError_base {
|
|
28
36
|
}
|
|
37
|
+
declare const LoopNotFoundError_base: Schema.Class<LoopNotFoundError, Schema.TaggedStruct<"LoopNotFoundError", {
|
|
38
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
39
|
+
readonly message: Schema.String;
|
|
40
|
+
}>, import("effect/Cause").YieldableError>;
|
|
41
|
+
/** The Run's Loop isn't in the loaded instance, so a new Run of it can't be opened. */
|
|
42
|
+
export declare class LoopNotFoundError extends LoopNotFoundError_base {
|
|
43
|
+
}
|
|
44
|
+
declare const ApprovalView_base: Schema.Class<ApprovalView, Schema.Struct<{
|
|
45
|
+
readonly approvedAt: Schema.String;
|
|
46
|
+
/** Null for approvals given before the approver was recorded. */
|
|
47
|
+
readonly source: Schema.NullOr<typeof ApprovalSource>;
|
|
48
|
+
}>, {}>;
|
|
49
|
+
/** A Run's approval: when it was given and, if recorded, who gave it and through which channel. */
|
|
50
|
+
export declare class ApprovalView extends ApprovalView_base {
|
|
51
|
+
}
|
|
29
52
|
declare const RunView_base: Schema.Class<RunView, Schema.Struct<{
|
|
30
53
|
readonly id: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
31
54
|
readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
|
|
32
55
|
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
33
56
|
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
34
57
|
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
58
|
+
/** The saved agent definition's brain, including any edit-and-retry amendment. */
|
|
59
|
+
readonly agentBrain: typeof BrainSpec;
|
|
35
60
|
readonly state: Schema.Literals<readonly ["Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled"]>;
|
|
36
61
|
readonly loopPaused: Schema.Boolean;
|
|
37
62
|
readonly openedAt: Schema.String;
|
|
63
|
+
/**
|
|
64
|
+
* When the Run last succeeded, failed, or was canceled, even before any Attempt. Null while open;
|
|
65
|
+
* a retry reopens a failed Run and clears it.
|
|
66
|
+
*/
|
|
67
|
+
readonly closedAt: Schema.NullOr<Schema.String>;
|
|
38
68
|
readonly task: Schema.String;
|
|
39
69
|
readonly attempts: Schema.$Array<typeof AttemptView>;
|
|
70
|
+
/**
|
|
71
|
+
* The approval the Run consumed, or null until one arrives. Always null for a Loop with
|
|
72
|
+
* `approval: none`.
|
|
73
|
+
*/
|
|
74
|
+
readonly approval: Schema.NullOr<typeof ApprovalView>;
|
|
75
|
+
/**
|
|
76
|
+
* The closed Run that the operator ran again to open this one, and who asked, or null for a
|
|
77
|
+
* trigger-opened Run. Its time is `openedAt`.
|
|
78
|
+
*/
|
|
79
|
+
readonly runAgain: Schema.NullOr<typeof RunAgain>;
|
|
40
80
|
readonly resultMessage: Schema.NullOr<Schema.String>;
|
|
41
81
|
readonly pullRequestUrl: Schema.NullOr<Schema.String>;
|
|
42
82
|
readonly canApprove: Schema.Boolean;
|
|
43
83
|
readonly canRetry: Schema.Boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the latest failed Attempt still requests attention, independent of retry availability.
|
|
86
|
+
*/
|
|
87
|
+
readonly canResolveFailure: Schema.Boolean;
|
|
44
88
|
readonly canCancel: Schema.Boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the Run succeeded or was canceled, so the operator can open a new Run for its Item
|
|
91
|
+
* state.
|
|
92
|
+
*/
|
|
93
|
+
readonly canRunAgain: Schema.Boolean;
|
|
45
94
|
}>, {}>;
|
|
46
|
-
/** A Run
|
|
95
|
+
/** A Run with its Attempts, result links, and available operator actions. */
|
|
47
96
|
export declare class RunView extends RunView_base {
|
|
48
97
|
}
|
|
98
|
+
declare const RunDurationView_base: Schema.Class<RunDurationView, Schema.Struct<{
|
|
99
|
+
/** The ended Attempts' time, each from start to recorded end. */
|
|
100
|
+
readonly endedMillis: Schema.Int;
|
|
101
|
+
/** The start of the running Attempt, or null if none runs. */
|
|
102
|
+
readonly runningSince: Schema.NullOr<Schema.String>;
|
|
103
|
+
/**
|
|
104
|
+
* The number of ended Attempts closed before end times were recorded, excluded from the total.
|
|
105
|
+
*/
|
|
106
|
+
readonly unmeasured: Schema.Int;
|
|
107
|
+
}>, {}>;
|
|
108
|
+
/** The time a Run's Attempts worked, summed per Attempt. */
|
|
109
|
+
export declare class RunDurationView extends RunDurationView_base {
|
|
110
|
+
}
|
|
111
|
+
declare const UnconfirmedStopView_base: Schema.Class<UnconfirmedStopView, Schema.Struct<{
|
|
112
|
+
/** The Run of the Attempt: this Run, or an earlier Run of the Loop on the Item. */
|
|
113
|
+
readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
114
|
+
readonly attemptNumber: Schema.brand<Schema.Int, "AttemptNumber">;
|
|
115
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
116
|
+
}>, {}>;
|
|
117
|
+
/**
|
|
118
|
+
* An Attempt on the Run's Loop and Item whose parent task isn't confirmed stopped. The open Run
|
|
119
|
+
* starts no Attempt until a reconcile confirms the stop (#523).
|
|
120
|
+
*/
|
|
121
|
+
export declare class UnconfirmedStopView extends UnconfirmedStopView_base {
|
|
122
|
+
}
|
|
49
123
|
declare const RunDetailView_base: Schema.Class<RunDetailView, Schema.Struct<{
|
|
50
124
|
readonly run: typeof RunView;
|
|
125
|
+
/** Whether the loaded agent differs from the saved definition; false if no longer loaded. */
|
|
126
|
+
readonly agentDefinitionChanged: Schema.Boolean;
|
|
51
127
|
readonly eventDedupKey: Schema.String;
|
|
52
128
|
readonly eventPayload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
53
129
|
readonly transcript: Schema.$Array<typeof TranscriptEventView>;
|
|
54
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* The current session controls, included even when their last activity is before the transcript
|
|
132
|
+
* page.
|
|
133
|
+
*/
|
|
55
134
|
readonly sessionState: Schema.$Array<typeof TranscriptEventView>;
|
|
56
135
|
readonly earlierTranscript: Schema.$Array<typeof TranscriptPageCursor>;
|
|
136
|
+
/** The Worker of the newest Attempt, or null before the first Attempt. */
|
|
137
|
+
readonly worker: Schema.withConstructorDefault<Schema.NullOr<Schema.brand<Schema.String, "WorkerName">>>;
|
|
138
|
+
/**
|
|
139
|
+
* The state of the Run's Item from the newest poll if the Item is closed, merged, or gone, else
|
|
140
|
+
* null. Needs attention leaves out a failed Run on such an Item.
|
|
141
|
+
*/
|
|
142
|
+
readonly settledItemState: Schema.withConstructorDefault<Schema.NullOr<Schema.Literals<readonly ["issue-closed", "pr-closed", "pr-merged"]>>>;
|
|
143
|
+
readonly duration: Schema.withConstructorDefault<typeof RunDurationView>;
|
|
144
|
+
readonly usage: Schema.withConstructorDefault<typeof RunUsageView>;
|
|
145
|
+
/** The unconfirmed stop that keeps the open Run from starting an Attempt, or null. */
|
|
146
|
+
readonly unconfirmedStop: Schema.withConstructorDefault<Schema.NullOr<typeof UnconfirmedStopView>>;
|
|
147
|
+
/**
|
|
148
|
+
* The machine a provisioned Worker creates or holds for the Run's next or running Attempt, or
|
|
149
|
+
* null.
|
|
150
|
+
*/
|
|
151
|
+
readonly machine: Schema.withConstructorDefault<Schema.NullOr<typeof MachineView>>;
|
|
57
152
|
}>, {}>;
|
|
58
|
-
/** A Run
|
|
153
|
+
/** A Run with its triggering Event payload, a page of its transcript, and its usage. */
|
|
59
154
|
export declare class RunDetailView extends RunDetailView_base {
|
|
60
155
|
}
|
|
61
156
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/operator/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/operator/run.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQpD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,iEAAiE;AACjE,eAAO,MAAM,WAAW,0GAAuC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;;;;;AAIlD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAGhC;CAAG;;;;;;AAEL,wGAAwG;AACxG,qBAAa,mBAAoB,SAAQ,wBAMvC;CAAG;;;;;AAEL,sDAAsD;AACtD,qBAAa,wBAAyB,SAAQ,6BAE6B;CAAG;;;;;AAE9E,uFAAuF;AACvF,qBAAa,iBAAkB,SAAQ,sBAE2B;CAAG;;;IAKnE,iEAAiE;;;AAHnE,mGAAmG;AACnG,qBAAa,YAAa,SAAQ,iBAIhC;CAAG;;;;;;;IASH,kFAAkF;;;;;IAKlF;;;OAGG;;;;IAIH;;;OAGG;;IAEH;;;OAGG;;;;;;IAMH;;OAEG;;;IAGH;;;OAGG;;;AAzCL,6EAA6E;AAC7E,qBAAa,OAAQ,SAAQ,YA0C3B;CAAG;;IASH,iEAAiE;;IAEjE,8DAA8D;;IAE9D;;OAEG;;;AAVL,4DAA4D;AAC5D,qBAAa,eAAgB,SAAQ,oBAWnC;CAAG;;IASH,mFAAmF;;;;;AAPrF;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,wBAOvC;CAAG;;;IAMD,6FAA6F;;;;;IAK7F;;;OAGG;;;IAGH,0EAA0E;;IAE1E;;;OAGG;;;;IAcH,sFAAsF;;IAItF;;;OAGG;;;AAzCP,wFAAwF;AACxF,qBAAa,aAAc,SAAQ,kBA2ClC;CAAG"}
|
package/dist/operator/run.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
import { SettledItemState } from "@usine/config/board";
|
|
1
2
|
import { AgentName } from "@usine/core/agent";
|
|
2
|
-
import {
|
|
3
|
+
import { BrainSpec } from "@usine/core/agent/brain";
|
|
4
|
+
import { TokenCount } from "@usine/core/agent/session";
|
|
5
|
+
import { AttemptId, AttemptNumber, AttemptTask } from "@usine/core/attempt";
|
|
3
6
|
import { OperatorAction, SessionTarget } from "@usine/core/attempt/channel";
|
|
4
7
|
import { ItemKey } from "@usine/core/item";
|
|
5
8
|
import { LoopName } from "@usine/core/loop";
|
|
6
9
|
import { RepositoryName } from "@usine/core/repository";
|
|
7
10
|
import { RunId } from "@usine/core/run";
|
|
11
|
+
import { RunAgain } from "@usine/core/run/again";
|
|
12
|
+
import { ApprovalSource } from "@usine/core/run/approval";
|
|
8
13
|
import * as RunState from "@usine/core/run/state";
|
|
14
|
+
import { WorkerName } from "@usine/core/worker";
|
|
9
15
|
import { Effect, Schema } from "effect";
|
|
10
16
|
import { AttemptView } from "./attempt.js";
|
|
17
|
+
import { MachineView } from "./machines.js";
|
|
11
18
|
import { TranscriptEventView, TranscriptPageCursor } from "./transcript.js";
|
|
12
|
-
|
|
19
|
+
import { RunUsageView } from "./usage.js";
|
|
20
|
+
/** The stored Run lifecycle state as shown in operator views. */
|
|
13
21
|
export const RunStateTag = Schema.Literals(RunState.STATE_TAGS);
|
|
14
22
|
const NullableString = Schema.NullOr(Schema.String);
|
|
15
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The operator's replacement task and roster Agent. The server derives the Agent's persona and
|
|
25
|
+
* brain.
|
|
26
|
+
*/
|
|
16
27
|
export class EditAndRetry extends Schema.Class("@usine/orchestrator/EditAndRetry")({
|
|
17
28
|
task: AttemptTask,
|
|
18
29
|
agent: AgentName,
|
|
@@ -25,37 +36,119 @@ export class SessionIntervention extends Schema.Class("@usine/orchestrator/Sessi
|
|
|
25
36
|
action: OperatorAction,
|
|
26
37
|
}) {
|
|
27
38
|
}
|
|
28
|
-
/** The requested Agent
|
|
39
|
+
/** The requested Agent isn't in the loaded roster. */
|
|
29
40
|
export class RosterAgentNotFoundError extends Schema.TaggedError("@usine/orchestrator/RosterAgentNotFoundError")("RosterAgentNotFoundError", { agent: AgentName, message: Schema.String }) {
|
|
30
41
|
}
|
|
31
|
-
/**
|
|
42
|
+
/** The Run's Loop isn't in the loaded instance, so a new Run of it can't be opened. */
|
|
43
|
+
export class LoopNotFoundError extends Schema.TaggedError("@usine/orchestrator/LoopNotFoundError")("LoopNotFoundError", { loop: LoopName, message: Schema.String }) {
|
|
44
|
+
}
|
|
45
|
+
/** A Run's approval: when it was given and, if recorded, who gave it and through which channel. */
|
|
46
|
+
export class ApprovalView extends Schema.Class("@usine/orchestrator/ApprovalView")({
|
|
47
|
+
approvedAt: Schema.String,
|
|
48
|
+
/** Null for approvals given before the approver was recorded. */
|
|
49
|
+
source: Schema.NullOr(ApprovalSource),
|
|
50
|
+
}) {
|
|
51
|
+
}
|
|
52
|
+
/** A Run with its Attempts, result links, and available operator actions. */
|
|
32
53
|
export class RunView extends Schema.Class("@usine/orchestrator/RunView")({
|
|
33
54
|
id: RunId,
|
|
34
55
|
itemKey: ItemKey,
|
|
35
56
|
loop: LoopName,
|
|
36
57
|
repository: RepositoryName,
|
|
37
58
|
agent: AgentName,
|
|
59
|
+
/** The saved agent definition's brain, including any edit-and-retry amendment. */
|
|
60
|
+
agentBrain: BrainSpec,
|
|
38
61
|
state: RunStateTag,
|
|
39
62
|
loopPaused: Schema.Boolean,
|
|
40
63
|
openedAt: Schema.String,
|
|
64
|
+
/**
|
|
65
|
+
* When the Run last succeeded, failed, or was canceled, even before any Attempt. Null while open;
|
|
66
|
+
* a retry reopens a failed Run and clears it.
|
|
67
|
+
*/
|
|
68
|
+
closedAt: Schema.NullOr(Schema.String),
|
|
41
69
|
task: Schema.String,
|
|
42
70
|
attempts: Schema.Array(AttemptView),
|
|
71
|
+
/**
|
|
72
|
+
* The approval the Run consumed, or null until one arrives. Always null for a Loop with
|
|
73
|
+
* `approval: none`.
|
|
74
|
+
*/
|
|
75
|
+
approval: Schema.NullOr(ApprovalView),
|
|
76
|
+
/**
|
|
77
|
+
* The closed Run that the operator ran again to open this one, and who asked, or null for a
|
|
78
|
+
* trigger-opened Run. Its time is `openedAt`.
|
|
79
|
+
*/
|
|
80
|
+
runAgain: Schema.NullOr(RunAgain),
|
|
43
81
|
resultMessage: NullableString,
|
|
44
82
|
pullRequestUrl: NullableString,
|
|
45
83
|
canApprove: Schema.Boolean,
|
|
46
84
|
canRetry: Schema.Boolean,
|
|
85
|
+
/**
|
|
86
|
+
* Whether the latest failed Attempt still requests attention, independent of retry availability.
|
|
87
|
+
*/
|
|
88
|
+
canResolveFailure: Schema.Boolean,
|
|
47
89
|
canCancel: Schema.Boolean,
|
|
90
|
+
/**
|
|
91
|
+
* Whether the Run succeeded or was canceled, so the operator can open a new Run for its Item
|
|
92
|
+
* state.
|
|
93
|
+
*/
|
|
94
|
+
canRunAgain: Schema.Boolean,
|
|
95
|
+
}) {
|
|
96
|
+
}
|
|
97
|
+
const Milliseconds = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
98
|
+
const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
99
|
+
/** The time a Run's Attempts worked, summed per Attempt. */
|
|
100
|
+
export class RunDurationView extends Schema.Class("@usine/orchestrator/RunDurationView")({
|
|
101
|
+
/** The ended Attempts' time, each from start to recorded end. */
|
|
102
|
+
endedMillis: Milliseconds,
|
|
103
|
+
/** The start of the running Attempt, or null if none runs. */
|
|
104
|
+
runningSince: Schema.NullOr(Schema.String),
|
|
105
|
+
/**
|
|
106
|
+
* The number of ended Attempts closed before end times were recorded, excluded from the total.
|
|
107
|
+
*/
|
|
108
|
+
unmeasured: Count,
|
|
109
|
+
}) {
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* An Attempt on the Run's Loop and Item whose parent task isn't confirmed stopped. The open Run
|
|
113
|
+
* starts no Attempt until a reconcile confirms the stop (#523).
|
|
114
|
+
*/
|
|
115
|
+
export class UnconfirmedStopView extends Schema.Class("@usine/orchestrator/UnconfirmedStopView")({
|
|
116
|
+
/** The Run of the Attempt: this Run, or an earlier Run of the Loop on the Item. */
|
|
117
|
+
runId: RunId,
|
|
118
|
+
attemptNumber: AttemptNumber,
|
|
119
|
+
worker: WorkerName,
|
|
48
120
|
}) {
|
|
49
121
|
}
|
|
50
|
-
/** A Run
|
|
122
|
+
/** A Run with its triggering Event payload, a page of its transcript, and its usage. */
|
|
51
123
|
export class RunDetailView extends Schema.Class("@usine/orchestrator/RunDetailView")({
|
|
52
124
|
run: RunView,
|
|
125
|
+
/** Whether the loaded agent differs from the saved definition; false if no longer loaded. */
|
|
126
|
+
agentDefinitionChanged: Schema.Boolean,
|
|
53
127
|
eventDedupKey: Schema.String,
|
|
54
128
|
eventPayload: Schema.Json,
|
|
55
129
|
transcript: Schema.Array(TranscriptEventView),
|
|
56
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* The current session controls, included even when their last activity is before the transcript
|
|
132
|
+
* page.
|
|
133
|
+
*/
|
|
57
134
|
sessionState: Schema.Array(TranscriptEventView),
|
|
58
135
|
earlierTranscript: Schema.Array(TranscriptPageCursor),
|
|
136
|
+
/** The Worker of the newest Attempt, or null before the first Attempt. */
|
|
137
|
+
worker: Schema.NullOr(WorkerName).pipe(Schema.withConstructorDefault(Effect.succeed(null))),
|
|
138
|
+
/**
|
|
139
|
+
* The state of the Run's Item from the newest poll if the Item is closed, merged, or gone, else
|
|
140
|
+
* null. Needs attention leaves out a failed Run on such an Item.
|
|
141
|
+
*/
|
|
142
|
+
settledItemState: Schema.NullOr(SettledItemState).pipe(Schema.withConstructorDefault(Effect.succeed(null))),
|
|
143
|
+
duration: RunDurationView.pipe(Schema.withConstructorDefault(Effect.succeed(new RunDurationView({ endedMillis: 0, runningSince: null, unmeasured: 0 })))),
|
|
144
|
+
usage: RunUsageView.pipe(Schema.withConstructorDefault(Effect.succeed(new RunUsageView({ tokens: TokenCount.make(0), pools: [], sessions: [] })))),
|
|
145
|
+
/** The unconfirmed stop that keeps the open Run from starting an Attempt, or null. */
|
|
146
|
+
unconfirmedStop: Schema.NullOr(UnconfirmedStopView).pipe(Schema.withConstructorDefault(Effect.succeed(null))),
|
|
147
|
+
/**
|
|
148
|
+
* The machine a provisioned Worker creates or holds for the Run's next or running Attempt, or
|
|
149
|
+
* null.
|
|
150
|
+
*/
|
|
151
|
+
machine: Schema.NullOr(MachineView).pipe(Schema.withConstructorDefault(Effect.succeed(null))),
|
|
59
152
|
}) {
|
|
60
153
|
}
|
|
61
154
|
//# sourceMappingURL=run.js.map
|
package/dist/operator/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/operator/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/operator/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B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RunReader } from "@usine/engine/run-reader";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import type { StatisticsWindow } from "./view.ts";
|
|
6
|
+
export declare const cacheStatistics: <View>(revision: RunReader["Service"]["revision"], compute: (instance: LoadedInstance, window: StatisticsWindow) => Effect.Effect<View, RunStoreError>) => (instance: LoadedInstance, window: "30d" | "7d" | "all") => Effect.Effect<View, import("@usine/engine/engine").EnginePersistenceError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("@usine/engine/engine").RunRetryBlockedError, never>;
|
|
7
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/operator/statistics/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAsB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAS,MAAM,EAA2B,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAWlD,eAAO,MAAM,eAAe,GAAI,IAAI,YACxB,SAAS,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,WACjC,CACP,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,gBAAgB,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,qTAmDxC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Clock, Effect, Option, SynchronizedRef } from "effect";
|
|
2
|
+
const MAX_AGE_MILLIS = 5 * 60 * 1_000;
|
|
3
|
+
export const cacheStatistics = (revision, compute) => {
|
|
4
|
+
const windows = new Map();
|
|
5
|
+
return Effect.fn("Operator.statistics.cached")(function* (instance, window) {
|
|
6
|
+
yield* Effect.annotateCurrentSpan({ window });
|
|
7
|
+
let cache = windows.get(window);
|
|
8
|
+
if (cache === undefined) {
|
|
9
|
+
cache = SynchronizedRef.makeUnsafe(Option.none());
|
|
10
|
+
windows.set(window, cache);
|
|
11
|
+
}
|
|
12
|
+
return yield* SynchronizedRef.modifyEffect(cache, (cached) => Effect.gen(function* () {
|
|
13
|
+
const current = yield* revision();
|
|
14
|
+
const now = yield* Clock.currentTimeMillis;
|
|
15
|
+
if (Option.isSome(current) &&
|
|
16
|
+
Option.isSome(cached) &&
|
|
17
|
+
cached.value.revision === current.value &&
|
|
18
|
+
cached.value.instance === instance &&
|
|
19
|
+
now < cached.value.expiresAt) {
|
|
20
|
+
yield* Effect.logDebug("Statistics cache hit", { window, revision: current.value });
|
|
21
|
+
return [cached.value.view, cached];
|
|
22
|
+
}
|
|
23
|
+
yield* Effect.logDebug("Statistics cache miss", { window, revision: current });
|
|
24
|
+
if (Option.isNone(current)) {
|
|
25
|
+
yield* Effect.logWarning("Projection revision singleton is missing; the statistics cache is bypassed", { window });
|
|
26
|
+
}
|
|
27
|
+
const view = yield* compute(instance, window);
|
|
28
|
+
return [
|
|
29
|
+
view,
|
|
30
|
+
Option.map(current, (revision) => ({
|
|
31
|
+
instance,
|
|
32
|
+
revision,
|
|
33
|
+
expiresAt: now + MAX_AGE_MILLIS,
|
|
34
|
+
view,
|
|
35
|
+
})),
|
|
36
|
+
];
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/operator/statistics/cache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGhE,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AAStC,MAAM,CAAC,MA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,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAU,CAAC;YAC9C,CAAC;YACD,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAC/E,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CACtB,4EAA4E,EAC5E,EAAE,MAAM,EAAE,CACX,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO;gBACL,IAAI;gBACJ,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBACjC,QAAQ;oBACR,QAAQ;oBACR,SAAS,EAAE,GAAG,GAAG,cAAc;oBAC/B,IAAI;iBACL,CAAC,CAAC;aACK,CAAC;QACb,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Attempt } from "@usine/core/attempt";
|
|
2
|
+
import type { RunId } from "@usine/core/run";
|
|
3
|
+
import type { WorkerName } from "@usine/core/worker";
|
|
4
|
+
import type { RunSummary } from "@usine/engine/run-reader";
|
|
5
|
+
import { DateTime, Option } from "effect";
|
|
6
|
+
import type { RunUsageView } from "../usage.ts";
|
|
7
|
+
import { DurationSummaryView, RunStatisticsView, type StatisticsWindow } from "./view.ts";
|
|
8
|
+
/** A Worker that `usine.yaml` declares, with its `max_concurrent_attempts`. */
|
|
9
|
+
interface DeclaredWorker {
|
|
10
|
+
readonly name: WorkerName;
|
|
11
|
+
readonly slots: number;
|
|
12
|
+
}
|
|
13
|
+
/** The stored facts that `runStatisticsView` reduces. */
|
|
14
|
+
export interface RunStatisticsFacts {
|
|
15
|
+
readonly window: StatisticsWindow;
|
|
16
|
+
readonly now: DateTime.Utc;
|
|
17
|
+
/** The Runs that closed in the window and the open Runs. */
|
|
18
|
+
readonly runs: ReadonlyArray<RunSummary>;
|
|
19
|
+
/** The usage of each closed Run in `runs`. */
|
|
20
|
+
readonly usage: ReadonlyMap<RunId, RunUsageView>;
|
|
21
|
+
readonly workers: ReadonlyArray<DeclaredWorker>;
|
|
22
|
+
}
|
|
23
|
+
/** Returns the median of `durations`, or null if there are none. */
|
|
24
|
+
export declare const durationSummary: (durations: ReadonlyArray<number>) => DurationSummaryView | null;
|
|
25
|
+
/** Returns the Attempt's wall time, or `None` while it runs or if its end wasn't recorded. */
|
|
26
|
+
export declare const attemptMillis: (attempt: Attempt) => Option.Option<number>;
|
|
27
|
+
/** Whether the operator started the Attempt by retrying the failed Run, with or without an edit. */
|
|
28
|
+
export declare const operatorRetry: (attempt: Attempt | undefined) => attempt is Attempt;
|
|
29
|
+
/**
|
|
30
|
+
* Reduces the stored facts to the Run statistics of `window`. Run measures cover the Runs that
|
|
31
|
+
* closed in the window; queue wait, Worker utilization, and Needs attention also cover the open
|
|
32
|
+
* Runs.
|
|
33
|
+
*/
|
|
34
|
+
export declare const runStatisticsView: ({ window, now, runs: stored, usage, workers, }: RunStatisticsFacts) => RunStatisticsView;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../../src/operator/statistics/runs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAwB,Q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