@usine/orchestrator 0.3.0 → 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 +32 -9
- package/dist/board/items.d.ts +14 -3
- package/dist/board/items.d.ts.map +1 -1
- package/dist/board/items.js +29 -1
- package/dist/board/items.js.map +1 -1
- package/dist/board/projection.d.ts +2 -1
- package/dist/board/projection.d.ts.map +1 -1
- package/dist/board/projection.js +20 -10
- package/dist/board/projection.js.map +1 -1
- package/dist/board/tasks.d.ts +1 -1
- package/dist/board/tasks.d.ts.map +1 -1
- package/dist/board/tasks.js +7 -3
- 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/current-instance/changes.d.ts +3 -3
- package/dist/current-instance/changes.d.ts.map +1 -1
- package/dist/current-instance/changes.js +6 -3
- package/dist/current-instance/changes.js.map +1 -1
- package/dist/current-instance/current-instance.d.ts +3 -3
- package/dist/exe-dev.d.ts +1 -1
- package/dist/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev.js +3 -1
- 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/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 +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +3 -1
- package/dist/local.js.map +1 -1
- package/dist/operator/attempt.d.ts +22 -3
- package/dist/operator/attempt.d.ts.map +1 -1
- package/dist/operator/attempt.js +22 -3
- package/dist/operator/attempt.js.map +1 -1
- package/dist/operator/board.d.ts +8 -3
- package/dist/operator/board.d.ts.map +1 -1
- package/dist/operator/board.js +8 -4
- package/dist/operator/board.js.map +1 -1
- package/dist/operator/configuration.d.ts +65 -9
- package/dist/operator/configuration.d.ts.map +1 -1
- package/dist/operator/configuration.js +90 -10
- package/dist/operator/configuration.js.map +1 -1
- package/dist/operator/desk.d.ts +33 -8
- package/dist/operator/desk.d.ts.map +1 -1
- package/dist/operator/desk.js +73 -11
- package/dist/operator/desk.js.map +1 -1
- package/dist/operator/http.d.ts +14 -79
- package/dist/operator/http.d.ts.map +1 -1
- package/dist/operator/http.js +20 -14
- 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 +15 -1
- package/dist/operator/need.d.ts.map +1 -1
- package/dist/operator/need.js +15 -0
- package/dist/operator/need.js.map +1 -1
- package/dist/operator/operator.d.ts +36 -10
- package/dist/operator/operator.d.ts.map +1 -1
- package/dist/operator/operator.js +136 -31
- package/dist/operator/operator.js.map +1 -1
- package/dist/operator/overview.d.ts +2 -2
- package/dist/operator/projection.d.ts +2 -0
- package/dist/operator/projection.d.ts.map +1 -1
- package/dist/operator/projection.js +12 -4
- package/dist/operator/projection.js.map +1 -1
- package/dist/operator/run.d.ts +30 -0
- package/dist/operator/run.d.ts.map +1 -1
- package/dist/operator/run.js +31 -1
- 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 +2 -1
- package/dist/operator/task.d.ts.map +1 -1
- package/dist/operator/task.js +3 -3
- package/dist/operator/task.js.map +1 -1
- package/dist/operator/usage.d.ts +10 -18
- package/dist/operator/usage.d.ts.map +1 -1
- package/dist/operator/usage.js +57 -42
- package/dist/operator/usage.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/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.map +1 -1
- package/dist/polling/polling.js +31 -18
- package/dist/polling/polling.js.map +1 -1
- package/dist/polling/repository-sync.d.ts +1 -0
- package/dist/polling/repository-sync.d.ts.map +1 -1
- package/dist/polling/repository-sync.js +1 -1
- package/dist/polling/repository-sync.js.map +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +10 -10
- package/dist/runtime.js.map +1 -1
- package/dist/scheduler.d.ts +13 -4
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +312 -55
- package/dist/scheduler.js.map +1 -1
- package/dist/ssh.d.ts +71 -7
- package/dist/ssh.d.ts.map +1 -1
- package/dist/ssh.js +84 -15
- package/dist/ssh.js.map +1 -1
- package/dist/worker-engine.d.ts +7 -4
- package/dist/worker-engine.d.ts.map +1 -1
- package/dist/worker-engine.js +36 -5
- package/dist/worker-engine.js.map +1 -1
- package/dist/worker-status.d.ts +80 -10
- package/dist/worker-status.d.ts.map +1 -1
- package/dist/worker-status.js +31 -10
- package/dist/worker-status.js.map +1 -1
- package/package.json +29 -25
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { BrainSpec } from "@usine/core/agent/brain";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/** The span the statistics cover: today and the 6 or 29 UTC days before it, or every stored Run. */
|
|
4
|
+
export declare const StatisticsWindow: Schema.Literals<readonly ["7d", "30d", "all"]>;
|
|
5
|
+
export type StatisticsWindow = typeof StatisticsWindow.Type;
|
|
6
|
+
/** The length of the periods in a time series: a UTC day, or a UTC week from Monday. */
|
|
7
|
+
export declare const StatisticsBucket: Schema.Literals<readonly ["day", "week"]>;
|
|
8
|
+
export type StatisticsBucket = typeof StatisticsBucket.Type;
|
|
9
|
+
declare const TaskDoneView_base: Schema.Class<TaskDoneView, Schema.Struct<{
|
|
10
|
+
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
11
|
+
/** The task's first issue, or its first pull request if it has no issue. */
|
|
12
|
+
readonly number: Schema.brand<Schema.Int, "ItemNumber">;
|
|
13
|
+
readonly mergedAt: Schema.String;
|
|
14
|
+
readonly durationMillis: Schema.Int;
|
|
15
|
+
}>, {}>;
|
|
16
|
+
/**
|
|
17
|
+
* A task whose pull request merged in the window. `durationMillis` runs from the opening of the
|
|
18
|
+
* task's first Run to the close of its last Run, or to the merge if a Run was open at the merge or
|
|
19
|
+
* closed after it. The wait between the last Run and the merge is left out.
|
|
20
|
+
*/
|
|
21
|
+
export declare class TaskDoneView extends TaskDoneView_base {
|
|
22
|
+
}
|
|
23
|
+
declare const TaskPeriodView_base: Schema.Class<TaskPeriodView, Schema.Struct<{
|
|
24
|
+
readonly start: Schema.String;
|
|
25
|
+
readonly tasks: Schema.Int;
|
|
26
|
+
readonly medianMillis: Schema.NullOr<Schema.Int>;
|
|
27
|
+
readonly firstTimeRight: Schema.Int;
|
|
28
|
+
readonly operatorActions: Schema.Int;
|
|
29
|
+
}>, {}>;
|
|
30
|
+
/** The tasks done in one period. `medianMillis` is null if there are none. */
|
|
31
|
+
export declare class TaskPeriodView extends TaskPeriodView_base {
|
|
32
|
+
}
|
|
33
|
+
declare const LoopShareView_base: Schema.Class<LoopShareView, Schema.Struct<{
|
|
34
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
35
|
+
readonly share: Schema.Finite;
|
|
36
|
+
}>, {}>;
|
|
37
|
+
/** A Loop's share of the measured tasks' time or tokens, averaged over the tasks. */
|
|
38
|
+
export declare class LoopShareView extends LoopShareView_base {
|
|
39
|
+
}
|
|
40
|
+
declare const LoopRunTimeView_base: Schema.Class<LoopRunTimeView, Schema.Struct<{
|
|
41
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
42
|
+
readonly runs: Schema.Int;
|
|
43
|
+
readonly medianMillis: Schema.Int;
|
|
44
|
+
}>, {}>;
|
|
45
|
+
/** The median wall time of a Loop's closed Runs on the measured tasks, summed over Attempts. */
|
|
46
|
+
export declare class LoopRunTimeView extends LoopRunTimeView_base {
|
|
47
|
+
}
|
|
48
|
+
declare const TaskTimeView_base: Schema.Class<TaskTimeView, Schema.Struct<{
|
|
49
|
+
readonly tasks: Schema.Int;
|
|
50
|
+
readonly loops: Schema.$Array<typeof LoopShareView>;
|
|
51
|
+
readonly waiting: Schema.Finite;
|
|
52
|
+
readonly runs: Schema.$Array<typeof LoopRunTimeView>;
|
|
53
|
+
}>, {}>;
|
|
54
|
+
/**
|
|
55
|
+
* The time of the tasks done whose Attempts all have a recorded end. Each share is the part of a
|
|
56
|
+
* task's duration that the Loop's Attempts ran, or that no Attempt ran (`waiting`: approval, queue,
|
|
57
|
+
* and the time between Runs), averaged over the tasks.
|
|
58
|
+
*/
|
|
59
|
+
export declare class TaskTimeView extends TaskTimeView_base {
|
|
60
|
+
}
|
|
61
|
+
declare const TaskCostView_base: Schema.Class<TaskCostView, Schema.Struct<{
|
|
62
|
+
readonly tasks: Schema.Int;
|
|
63
|
+
readonly medianUsd: Schema.brand<Schema.Finite, "UsdAmount">;
|
|
64
|
+
readonly estimate: Schema.Boolean;
|
|
65
|
+
}>, {}>;
|
|
66
|
+
/**
|
|
67
|
+
* The median cost of the priced tasks: those whose sessions all have a price. `estimate` is true if
|
|
68
|
+
* a session of a priced task is in the Claude or ChatGPT plan.
|
|
69
|
+
*/
|
|
70
|
+
export declare class TaskCostView extends TaskCostView_base {
|
|
71
|
+
}
|
|
72
|
+
declare const TaskTokensView_base: Schema.Class<TaskTokensView, Schema.Struct<{
|
|
73
|
+
readonly tasks: Schema.Int;
|
|
74
|
+
readonly medianTokens: Schema.brand<Schema.Int, "TokenCount">;
|
|
75
|
+
readonly loops: Schema.$Array<typeof LoopShareView>;
|
|
76
|
+
readonly cost: Schema.NullOr<typeof TaskCostView>;
|
|
77
|
+
}>, {}>;
|
|
78
|
+
/**
|
|
79
|
+
* The tokens of the tasks done whose Runs with an Attempt all reported tokens, with each Loop's
|
|
80
|
+
* share. `cost` is null if no such task is priced.
|
|
81
|
+
*/
|
|
82
|
+
export declare class TaskTokensView extends TaskTokensView_base {
|
|
83
|
+
}
|
|
84
|
+
declare const UntimedTasksView_base: Schema.Class<UntimedTasksView, Schema.Struct<{
|
|
85
|
+
readonly tasks: Schema.Int;
|
|
86
|
+
readonly before: Schema.String;
|
|
87
|
+
}>, {}>;
|
|
88
|
+
/**
|
|
89
|
+
* The tasks done with an Attempt that ended before usine recorded end times, left out of `time`.
|
|
90
|
+
* Each such Attempt started before `before`.
|
|
91
|
+
*/
|
|
92
|
+
export declare class UntimedTasksView extends UntimedTasksView_base {
|
|
93
|
+
}
|
|
94
|
+
declare const StatisticsView_base: Schema.Class<StatisticsView, Schema.Struct<{
|
|
95
|
+
readonly window: Schema.Literals<readonly ["7d", "30d", "all"]>;
|
|
96
|
+
/** The window's start: midnight UTC of its first day. */
|
|
97
|
+
readonly from: Schema.String;
|
|
98
|
+
/** The time the statistics were computed. */
|
|
99
|
+
readonly to: Schema.String;
|
|
100
|
+
readonly bucket: Schema.Literals<readonly ["day", "week"]>;
|
|
101
|
+
/**
|
|
102
|
+
* The Loops of the window's tasks in the order they first run in a task: by mean rank, from 0
|
|
103
|
+
* for a task's first Loop to 1 for its last, then by name. `time` and `tokens` follow it.
|
|
104
|
+
*/
|
|
105
|
+
readonly loops: Schema.$Array<Schema.brand<Schema.NonEmptyString, "LoopName">>;
|
|
106
|
+
/** By merge time, oldest first. */
|
|
107
|
+
readonly tasks: Schema.$Array<typeof TaskDoneView>;
|
|
108
|
+
/** The median of the tasks' `durationMillis`, or null without a task. */
|
|
109
|
+
readonly medianMillis: Schema.NullOr<Schema.Int>;
|
|
110
|
+
/** One period per bucket from `from` to `to`, oldest first. */
|
|
111
|
+
readonly periods: Schema.$Array<typeof TaskPeriodView>;
|
|
112
|
+
/** The tasks with no Loop that succeeded twice on one of their Items. */
|
|
113
|
+
readonly firstTimeRight: Schema.Int;
|
|
114
|
+
/**
|
|
115
|
+
* The approvals, operator retries, failures marked resolved, and cycle-budget resets on the
|
|
116
|
+
* tasks' Runs and Items.
|
|
117
|
+
*/
|
|
118
|
+
readonly operatorActions: Schema.Int;
|
|
119
|
+
readonly time: Schema.NullOr<typeof TaskTimeView>;
|
|
120
|
+
readonly tokens: Schema.NullOr<typeof TaskTokensView>;
|
|
121
|
+
readonly untimed: Schema.NullOr<typeof UntimedTasksView>;
|
|
122
|
+
/** The tasks with a Run that has an Attempt but no token report, left out of `tokens`. */
|
|
123
|
+
readonly unmetered: Schema.Int;
|
|
124
|
+
}>, {}>;
|
|
125
|
+
/**
|
|
126
|
+
* The tasks done in `window`: a task is done when its pull request merges, and counts if it has a
|
|
127
|
+
* Run. Runs that a newer Event or an Item change canceled before an Attempt are left out.
|
|
128
|
+
*/
|
|
129
|
+
export declare class StatisticsView extends StatisticsView_base {
|
|
130
|
+
}
|
|
131
|
+
declare const DurationSummaryView_base: Schema.Class<DurationSummaryView, Schema.Struct<{
|
|
132
|
+
readonly count: Schema.Int;
|
|
133
|
+
readonly medianMillis: Schema.Int;
|
|
134
|
+
}>, {}>;
|
|
135
|
+
/** The median of at least one duration. */
|
|
136
|
+
export declare class DurationSummaryView extends DurationSummaryView_base {
|
|
137
|
+
}
|
|
138
|
+
declare const OutcomeCountsView_base: Schema.Class<OutcomeCountsView, Schema.Struct<{
|
|
139
|
+
readonly succeeded: Schema.Int;
|
|
140
|
+
readonly failed: Schema.Int;
|
|
141
|
+
readonly canceled: Schema.Int;
|
|
142
|
+
}>, {}>;
|
|
143
|
+
/** Closed Runs or ended Attempts counted by outcome. */
|
|
144
|
+
export declare class OutcomeCountsView extends OutcomeCountsView_base {
|
|
145
|
+
}
|
|
146
|
+
declare const PoolTokensView_base: Schema.Class<PoolTokensView, Schema.Struct<{
|
|
147
|
+
readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
|
|
148
|
+
readonly tokens: Schema.brand<Schema.Int, "TokenCount">;
|
|
149
|
+
}>, {}>;
|
|
150
|
+
/** The tokens used in one billing pool. */
|
|
151
|
+
export declare class PoolTokensView extends PoolTokensView_base {
|
|
152
|
+
}
|
|
153
|
+
declare const CostSummaryView_base: Schema.Class<CostSummaryView, Schema.Struct<{
|
|
154
|
+
readonly usd: Schema.brand<Schema.Finite, "UsdAmount">;
|
|
155
|
+
readonly meanUsd: Schema.brand<Schema.Finite, "UsdAmount">;
|
|
156
|
+
readonly estimate: Schema.Boolean;
|
|
157
|
+
readonly priced: Schema.Int;
|
|
158
|
+
}>, {}>;
|
|
159
|
+
/**
|
|
160
|
+
* The cost of the priced Runs or Attempts: those with a price for each session. `estimate` is true
|
|
161
|
+
* if a priced session is in the Claude or ChatGPT plan.
|
|
162
|
+
*/
|
|
163
|
+
export declare class CostSummaryView extends CostSummaryView_base {
|
|
164
|
+
}
|
|
165
|
+
declare const UsageSummaryView_base: Schema.Class<UsageSummaryView, Schema.Struct<{
|
|
166
|
+
readonly measured: Schema.Int;
|
|
167
|
+
readonly tokens: Schema.brand<Schema.Int, "TokenCount">;
|
|
168
|
+
readonly meanTokens: Schema.NullOr<Schema.brand<Schema.Int, "TokenCount">>;
|
|
169
|
+
/** In the order API keys, Claude plan, ChatGPT plan; unused pools are absent. */
|
|
170
|
+
readonly pools: Schema.$Array<typeof PoolTokensView>;
|
|
171
|
+
readonly cost: Schema.NullOr<typeof CostSummaryView>;
|
|
172
|
+
}>, {}>;
|
|
173
|
+
/**
|
|
174
|
+
* The tokens and cost of the Runs or Attempts with at least one Attempt. `meanTokens` is null if
|
|
175
|
+
* none has one, and `cost` is null if none is priced.
|
|
176
|
+
*/
|
|
177
|
+
export declare class UsageSummaryView extends UsageSummaryView_base {
|
|
178
|
+
}
|
|
179
|
+
declare const LoopStatisticsView_base: Schema.Class<LoopStatisticsView, Schema.Struct<{
|
|
180
|
+
readonly outcomes: typeof OutcomeCountsView;
|
|
181
|
+
readonly time: Schema.NullOr<typeof DurationSummaryView>;
|
|
182
|
+
readonly usage: typeof UsageSummaryView;
|
|
183
|
+
readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
|
|
184
|
+
}>, {}>;
|
|
185
|
+
/** The closed Runs of one Loop. */
|
|
186
|
+
export declare class LoopStatisticsView extends LoopStatisticsView_base {
|
|
187
|
+
}
|
|
188
|
+
declare const AgentStatisticsView_base: Schema.Class<AgentStatisticsView, Schema.Struct<{
|
|
189
|
+
readonly outcomes: typeof OutcomeCountsView;
|
|
190
|
+
readonly time: Schema.NullOr<typeof DurationSummaryView>;
|
|
191
|
+
readonly usage: typeof UsageSummaryView;
|
|
192
|
+
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
193
|
+
}>, {}>;
|
|
194
|
+
/** The closed Runs whose effective Agent is `agent`. */
|
|
195
|
+
export declare class AgentStatisticsView extends AgentStatisticsView_base {
|
|
196
|
+
}
|
|
197
|
+
declare const BrainStatisticsView_base: Schema.Class<BrainStatisticsView, Schema.Struct<{
|
|
198
|
+
readonly outcomes: typeof OutcomeCountsView;
|
|
199
|
+
readonly time: Schema.NullOr<typeof DurationSummaryView>;
|
|
200
|
+
readonly usage: typeof UsageSummaryView;
|
|
201
|
+
readonly brain: typeof BrainSpec;
|
|
202
|
+
}>, {}>;
|
|
203
|
+
/** The ended Attempts of closed Runs that ran with one harness, model, and effort. */
|
|
204
|
+
export declare class BrainStatisticsView extends BrainStatisticsView_base {
|
|
205
|
+
}
|
|
206
|
+
declare const ThroughputPeriodView_base: Schema.Class<ThroughputPeriodView, Schema.Struct<{
|
|
207
|
+
readonly succeeded: Schema.Int;
|
|
208
|
+
readonly failed: Schema.Int;
|
|
209
|
+
readonly canceled: Schema.Int;
|
|
210
|
+
readonly start: Schema.String;
|
|
211
|
+
}>, {}>;
|
|
212
|
+
/** The Runs that closed in one period, by outcome. */
|
|
213
|
+
export declare class ThroughputPeriodView extends ThroughputPeriodView_base {
|
|
214
|
+
}
|
|
215
|
+
declare const WorkerQueueWaitView_base: Schema.Class<WorkerQueueWaitView, Schema.Struct<{
|
|
216
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
217
|
+
readonly wait: typeof DurationSummaryView;
|
|
218
|
+
}>, {}>;
|
|
219
|
+
/** The time from a Run's opening, or its approval, to its first Attempt's start on `worker`. */
|
|
220
|
+
export declare class WorkerQueueWaitView extends WorkerQueueWaitView_base {
|
|
221
|
+
}
|
|
222
|
+
declare const AttemptCountView_base: Schema.Class<AttemptCountView, Schema.Struct<{
|
|
223
|
+
readonly attempts: Schema.Int;
|
|
224
|
+
readonly runs: Schema.Int;
|
|
225
|
+
}>, {}>;
|
|
226
|
+
/** The number of closed Runs that took `attempts` Attempts. */
|
|
227
|
+
export declare class AttemptCountView extends AttemptCountView_base {
|
|
228
|
+
}
|
|
229
|
+
declare const WorkerUtilizationView_base: Schema.Class<WorkerUtilizationView, Schema.Struct<{
|
|
230
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
231
|
+
readonly slots: Schema.Int;
|
|
232
|
+
readonly occupiedMillis: Schema.Int;
|
|
233
|
+
readonly share: Schema.Finite;
|
|
234
|
+
}>, {}>;
|
|
235
|
+
/**
|
|
236
|
+
* The time a declared Worker's slots held Attempts in the window, as a share of `slots` times the
|
|
237
|
+
* window's length.
|
|
238
|
+
*/
|
|
239
|
+
export declare class WorkerUtilizationView extends WorkerUtilizationView_base {
|
|
240
|
+
}
|
|
241
|
+
declare const NeedsAttentionPeriodView_base: Schema.Class<NeedsAttentionPeriodView, Schema.Struct<{
|
|
242
|
+
readonly start: Schema.String;
|
|
243
|
+
readonly approvals: Schema.Int;
|
|
244
|
+
readonly failures: Schema.Int;
|
|
245
|
+
}>, {}>;
|
|
246
|
+
/** The Needs attention entries raised in one period. */
|
|
247
|
+
export declare class NeedsAttentionPeriodView extends NeedsAttentionPeriodView_base {
|
|
248
|
+
}
|
|
249
|
+
declare const NeedsAttentionView_base: Schema.Class<NeedsAttentionView, Schema.Struct<{
|
|
250
|
+
readonly approvals: Schema.Int;
|
|
251
|
+
readonly failures: Schema.Int;
|
|
252
|
+
readonly periods: Schema.$Array<typeof NeedsAttentionPeriodView>;
|
|
253
|
+
readonly approvalWait: Schema.NullOr<typeof DurationSummaryView>;
|
|
254
|
+
readonly retryWait: Schema.NullOr<typeof DurationSummaryView>;
|
|
255
|
+
readonly resolutionWait: Schema.NullOr<typeof DurationSummaryView>;
|
|
256
|
+
readonly failureWait: Schema.NullOr<typeof DurationSummaryView>;
|
|
257
|
+
}>, {}>;
|
|
258
|
+
/**
|
|
259
|
+
* The approvals asked for and the failed Attempts that no automatic retry followed, with their
|
|
260
|
+
* waits: from a run's opening to its approval, and from a failure to its first recorded operator
|
|
261
|
+
* answer (retry or resolution). Each answered failure contributes once to `failureWait` and to
|
|
262
|
+
* either `retryWait` or `resolutionWait`. Older resolutions without a timestamp are excluded.
|
|
263
|
+
*/
|
|
264
|
+
export declare class NeedsAttentionView extends NeedsAttentionView_base {
|
|
265
|
+
}
|
|
266
|
+
declare const RunStatisticsView_base: Schema.Class<RunStatisticsView, Schema.Struct<{
|
|
267
|
+
readonly window: Schema.Literals<readonly ["7d", "30d", "all"]>;
|
|
268
|
+
/** The window's start: midnight UTC of its first day. */
|
|
269
|
+
readonly from: Schema.String;
|
|
270
|
+
/** The time the statistics were computed. */
|
|
271
|
+
readonly to: Schema.String;
|
|
272
|
+
readonly bucket: Schema.Literals<readonly ["day", "week"]>;
|
|
273
|
+
readonly runs: typeof OutcomeCountsView;
|
|
274
|
+
/** From each closed Run's opening to its close. */
|
|
275
|
+
readonly runTime: Schema.NullOr<typeof DurationSummaryView>;
|
|
276
|
+
/** From each ended Attempt's start to its recorded end. */
|
|
277
|
+
readonly attemptTime: Schema.NullOr<typeof DurationSummaryView>;
|
|
278
|
+
/** The ended Attempts closed before end times were recorded, left out of `attemptTime`. */
|
|
279
|
+
readonly unmeasuredAttempts: Schema.Int;
|
|
280
|
+
/** One period per bucket from `from` to `to`, oldest first. */
|
|
281
|
+
readonly throughput: Schema.$Array<typeof ThroughputPeriodView>;
|
|
282
|
+
/** By closed Run count, highest first. */
|
|
283
|
+
readonly loops: Schema.$Array<typeof LoopStatisticsView>;
|
|
284
|
+
readonly agents: Schema.$Array<typeof AgentStatisticsView>;
|
|
285
|
+
readonly brains: Schema.$Array<typeof BrainStatisticsView>;
|
|
286
|
+
/** For Runs whose first Attempt started in the window, by Worker name. */
|
|
287
|
+
readonly queueWait: Schema.$Array<typeof WorkerQueueWaitView>;
|
|
288
|
+
/** From one Attempt to the most any closed Run took, each count present. */
|
|
289
|
+
readonly attemptsPerRun: Schema.$Array<typeof AttemptCountView>;
|
|
290
|
+
/** For the Workers that `usine.yaml` declares, in declaration order. */
|
|
291
|
+
readonly utilization: Schema.$Array<typeof WorkerUtilizationView>;
|
|
292
|
+
readonly needsAttention: typeof NeedsAttentionView;
|
|
293
|
+
}>, {}>;
|
|
294
|
+
/**
|
|
295
|
+
* How the Runs went in `window`: closed Runs by outcome, Loop, Agent, and brain, with their time,
|
|
296
|
+
* tokens, and cost, and the Worker, retry, and Needs attention measures. Runs that a newer Event or
|
|
297
|
+
* an Item change canceled before an Attempt are left out.
|
|
298
|
+
*/
|
|
299
|
+
export declare class RunStatisticsView extends RunStatisticsView_base {
|
|
300
|
+
}
|
|
301
|
+
export {};
|
|
302
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/operator/statistics/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAWhC,oGAAoG;AACpG,eAAO,MAAM,gBAAgB,gDAAwC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AAE5D,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,2CAAmC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;;;IAS1D,4EAA4E;;;;;AAP9E;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,iBAMhC;CAAG;;;;;;;;AAEL,8EAA8E;AAC9E,qBAAa,cAAe,SAAQ,mBAQlC;CAAG;;;;;AAEL,qFAAqF;AACrF,qBAAa,aAAc,SAAQ,kBAElC;CAAG;;;;;;AAEJ,gGAAgG;AAChG,qBAAa,eAAgB,SAAQ,oBAEiC;CAAG;;;;;;;AAEzE;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,iBAKhC;CAAG;;;;;;AAEL;;;GAGG;A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D;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,uBAUtC;CAAG;;;IAWH,yDAAyD;;IAEzD,6CAA6C;;;;IAI7C,mDAAmD;;IAEnD,2DAA2D;;IAE3D,2FAA2F;;IAE3F,+DAA+D;;IAE/D,0CAA0C;;;;IAI1C,0EAA0E;;IAE1E,4EAA4E;;IAE5E,wEAAwE;;;;AA/B1E;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,sBA6BrC;CAAG"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { AgentName } from "@usine/core/agent";
|
|
2
|
+
import { BrainSpec } from "@usine/core/agent/brain";
|
|
3
|
+
import { BillingPool, TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
4
|
+
import { ItemNumber } from "@usine/core/item";
|
|
5
|
+
import { LoopName } from "@usine/core/loop";
|
|
6
|
+
import { RepositoryName } from "@usine/core/repository";
|
|
7
|
+
import { WorkerName } from "@usine/core/worker";
|
|
8
|
+
import { Schema } from "effect";
|
|
9
|
+
const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
10
|
+
const PositiveCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
11
|
+
const Milliseconds = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
12
|
+
const Share = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));
|
|
13
|
+
/** A UTC calendar day, such as `2026-10-25`. */
|
|
14
|
+
const UtcDay = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}$/u, { message: "Expected a UTC day as YYYY-MM-DD" }));
|
|
15
|
+
/** The span the statistics cover: today and the 6 or 29 UTC days before it, or every stored Run. */
|
|
16
|
+
export const StatisticsWindow = Schema.Literals(["7d", "30d", "all"]);
|
|
17
|
+
/** The length of the periods in a time series: a UTC day, or a UTC week from Monday. */
|
|
18
|
+
export const StatisticsBucket = Schema.Literals(["day", "week"]);
|
|
19
|
+
/**
|
|
20
|
+
* A task whose pull request merged in the window. `durationMillis` runs from the opening of the
|
|
21
|
+
* task's first Run to the close of its last Run, or to the merge if a Run was open at the merge or
|
|
22
|
+
* closed after it. The wait between the last Run and the merge is left out.
|
|
23
|
+
*/
|
|
24
|
+
export class TaskDoneView extends Schema.Class("@usine/orchestrator/TaskDoneView")({
|
|
25
|
+
repository: RepositoryName,
|
|
26
|
+
/** The task's first issue, or its first pull request if it has no issue. */
|
|
27
|
+
number: ItemNumber,
|
|
28
|
+
mergedAt: Schema.String,
|
|
29
|
+
durationMillis: Milliseconds,
|
|
30
|
+
}) {
|
|
31
|
+
}
|
|
32
|
+
/** The tasks done in one period. `medianMillis` is null if there are none. */
|
|
33
|
+
export class TaskPeriodView extends Schema.Class("@usine/orchestrator/TaskPeriodView")({
|
|
34
|
+
start: UtcDay,
|
|
35
|
+
tasks: Count,
|
|
36
|
+
medianMillis: Schema.NullOr(Milliseconds),
|
|
37
|
+
firstTimeRight: Count,
|
|
38
|
+
operatorActions: Count,
|
|
39
|
+
}) {
|
|
40
|
+
}
|
|
41
|
+
/** A Loop's share of the measured tasks' time or tokens, averaged over the tasks. */
|
|
42
|
+
export class LoopShareView extends Schema.Class("@usine/orchestrator/LoopShareView")({ loop: LoopName, share: Share }) {
|
|
43
|
+
}
|
|
44
|
+
/** The median wall time of a Loop's closed Runs on the measured tasks, summed over Attempts. */
|
|
45
|
+
export class LoopRunTimeView extends Schema.Class("@usine/orchestrator/LoopRunTimeView")({ loop: LoopName, runs: PositiveCount, medianMillis: Milliseconds }) {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The time of the tasks done whose Attempts all have a recorded end. Each share is the part of a
|
|
49
|
+
* task's duration that the Loop's Attempts ran, or that no Attempt ran (`waiting`: approval, queue,
|
|
50
|
+
* and the time between Runs), averaged over the tasks.
|
|
51
|
+
*/
|
|
52
|
+
export class TaskTimeView extends Schema.Class("@usine/orchestrator/TaskTimeView")({
|
|
53
|
+
tasks: PositiveCount,
|
|
54
|
+
loops: Schema.Array(LoopShareView),
|
|
55
|
+
waiting: Share,
|
|
56
|
+
runs: Schema.Array(LoopRunTimeView),
|
|
57
|
+
}) {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The median cost of the priced tasks: those whose sessions all have a price. `estimate` is true if
|
|
61
|
+
* a session of a priced task is in the Claude or ChatGPT plan.
|
|
62
|
+
*/
|
|
63
|
+
export class TaskCostView extends Schema.Class("@usine/orchestrator/TaskCostView")({
|
|
64
|
+
tasks: PositiveCount,
|
|
65
|
+
medianUsd: UsdAmount,
|
|
66
|
+
estimate: Schema.Boolean,
|
|
67
|
+
}) {
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The tokens of the tasks done whose Runs with an Attempt all reported tokens, with each Loop's
|
|
71
|
+
* share. `cost` is null if no such task is priced.
|
|
72
|
+
*/
|
|
73
|
+
export class TaskTokensView extends Schema.Class("@usine/orchestrator/TaskTokensView")({
|
|
74
|
+
tasks: PositiveCount,
|
|
75
|
+
medianTokens: TokenCount,
|
|
76
|
+
loops: Schema.Array(LoopShareView),
|
|
77
|
+
cost: Schema.NullOr(TaskCostView),
|
|
78
|
+
}) {
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The tasks done with an Attempt that ended before usine recorded end times, left out of `time`.
|
|
82
|
+
* Each such Attempt started before `before`.
|
|
83
|
+
*/
|
|
84
|
+
export class UntimedTasksView extends Schema.Class("@usine/orchestrator/UntimedTasksView")({ tasks: PositiveCount, before: UtcDay }) {
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The tasks done in `window`: a task is done when its pull request merges, and counts if it has a
|
|
88
|
+
* Run. Runs that a newer Event or an Item change canceled before an Attempt are left out.
|
|
89
|
+
*/
|
|
90
|
+
export class StatisticsView extends Schema.Class("@usine/orchestrator/StatisticsView")({
|
|
91
|
+
window: StatisticsWindow,
|
|
92
|
+
/** The window's start: midnight UTC of its first day. */
|
|
93
|
+
from: Schema.String,
|
|
94
|
+
/** The time the statistics were computed. */
|
|
95
|
+
to: Schema.String,
|
|
96
|
+
bucket: StatisticsBucket,
|
|
97
|
+
/**
|
|
98
|
+
* The Loops of the window's tasks in the order they first run in a task: by mean rank, from 0
|
|
99
|
+
* for a task's first Loop to 1 for its last, then by name. `time` and `tokens` follow it.
|
|
100
|
+
*/
|
|
101
|
+
loops: Schema.Array(LoopName),
|
|
102
|
+
/** By merge time, oldest first. */
|
|
103
|
+
tasks: Schema.Array(TaskDoneView),
|
|
104
|
+
/** The median of the tasks' `durationMillis`, or null without a task. */
|
|
105
|
+
medianMillis: Schema.NullOr(Milliseconds),
|
|
106
|
+
/** One period per bucket from `from` to `to`, oldest first. */
|
|
107
|
+
periods: Schema.Array(TaskPeriodView),
|
|
108
|
+
/** The tasks with no Loop that succeeded twice on one of their Items. */
|
|
109
|
+
firstTimeRight: Count,
|
|
110
|
+
/**
|
|
111
|
+
* The approvals, operator retries, failures marked resolved, and cycle-budget resets on the
|
|
112
|
+
* tasks' Runs and Items.
|
|
113
|
+
*/
|
|
114
|
+
operatorActions: Count,
|
|
115
|
+
time: Schema.NullOr(TaskTimeView),
|
|
116
|
+
tokens: Schema.NullOr(TaskTokensView),
|
|
117
|
+
untimed: Schema.NullOr(UntimedTasksView),
|
|
118
|
+
/** The tasks with a Run that has an Attempt but no token report, left out of `tokens`. */
|
|
119
|
+
unmetered: Count,
|
|
120
|
+
}) {
|
|
121
|
+
}
|
|
122
|
+
/** The median of at least one duration. */
|
|
123
|
+
export class DurationSummaryView extends Schema.Class("@usine/orchestrator/DurationSummaryView")({ count: PositiveCount, medianMillis: Milliseconds }) {
|
|
124
|
+
}
|
|
125
|
+
/** Closed Runs or ended Attempts counted by outcome. */
|
|
126
|
+
export class OutcomeCountsView extends Schema.Class("@usine/orchestrator/OutcomeCountsView")({ succeeded: Count, failed: Count, canceled: Count }) {
|
|
127
|
+
}
|
|
128
|
+
/** The tokens used in one billing pool. */
|
|
129
|
+
export class PoolTokensView extends Schema.Class("@usine/orchestrator/PoolTokensView")({ pool: BillingPool, tokens: TokenCount }) {
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The cost of the priced Runs or Attempts: those with a price for each session. `estimate` is true
|
|
133
|
+
* if a priced session is in the Claude or ChatGPT plan.
|
|
134
|
+
*/
|
|
135
|
+
export class CostSummaryView extends Schema.Class("@usine/orchestrator/CostSummaryView")({
|
|
136
|
+
usd: UsdAmount,
|
|
137
|
+
meanUsd: UsdAmount,
|
|
138
|
+
estimate: Schema.Boolean,
|
|
139
|
+
priced: PositiveCount,
|
|
140
|
+
}) {
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The tokens and cost of the Runs or Attempts with at least one Attempt. `meanTokens` is null if
|
|
144
|
+
* none has one, and `cost` is null if none is priced.
|
|
145
|
+
*/
|
|
146
|
+
export class UsageSummaryView extends Schema.Class("@usine/orchestrator/UsageSummaryView")({
|
|
147
|
+
measured: Count,
|
|
148
|
+
tokens: TokenCount,
|
|
149
|
+
meanTokens: Schema.NullOr(TokenCount),
|
|
150
|
+
/** In the order API keys, Claude plan, ChatGPT plan; unused pools are absent. */
|
|
151
|
+
pools: Schema.Array(PoolTokensView),
|
|
152
|
+
cost: Schema.NullOr(CostSummaryView),
|
|
153
|
+
}) {
|
|
154
|
+
}
|
|
155
|
+
const groupFields = {
|
|
156
|
+
outcomes: OutcomeCountsView,
|
|
157
|
+
/** Run time for a Loop or Agent, Attempt time for a brain; null without a measured one. */
|
|
158
|
+
time: Schema.NullOr(DurationSummaryView),
|
|
159
|
+
usage: UsageSummaryView,
|
|
160
|
+
};
|
|
161
|
+
/** The closed Runs of one Loop. */
|
|
162
|
+
export class LoopStatisticsView extends Schema.Class("@usine/orchestrator/LoopStatisticsView")({ loop: LoopName, ...groupFields }) {
|
|
163
|
+
}
|
|
164
|
+
/** The closed Runs whose effective Agent is `agent`. */
|
|
165
|
+
export class AgentStatisticsView extends Schema.Class("@usine/orchestrator/AgentStatisticsView")({ agent: AgentName, ...groupFields }) {
|
|
166
|
+
}
|
|
167
|
+
/** The ended Attempts of closed Runs that ran with one harness, model, and effort. */
|
|
168
|
+
export class BrainStatisticsView extends Schema.Class("@usine/orchestrator/BrainStatisticsView")({ brain: BrainSpec, ...groupFields }) {
|
|
169
|
+
}
|
|
170
|
+
/** The Runs that closed in one period, by outcome. */
|
|
171
|
+
export class ThroughputPeriodView extends Schema.Class("@usine/orchestrator/ThroughputPeriodView")({ start: UtcDay, ...OutcomeCountsView.fields }) {
|
|
172
|
+
}
|
|
173
|
+
/** The time from a Run's opening, or its approval, to its first Attempt's start on `worker`. */
|
|
174
|
+
export class WorkerQueueWaitView extends Schema.Class("@usine/orchestrator/WorkerQueueWaitView")({ worker: WorkerName, wait: DurationSummaryView }) {
|
|
175
|
+
}
|
|
176
|
+
/** The number of closed Runs that took `attempts` Attempts. */
|
|
177
|
+
export class AttemptCountView extends Schema.Class("@usine/orchestrator/AttemptCountView")({ attempts: PositiveCount, runs: Count }) {
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The time a declared Worker's slots held Attempts in the window, as a share of `slots` times the
|
|
181
|
+
* window's length.
|
|
182
|
+
*/
|
|
183
|
+
export class WorkerUtilizationView extends Schema.Class("@usine/orchestrator/WorkerUtilizationView")({
|
|
184
|
+
worker: WorkerName,
|
|
185
|
+
slots: PositiveCount,
|
|
186
|
+
occupiedMillis: Milliseconds,
|
|
187
|
+
share: Share,
|
|
188
|
+
}) {
|
|
189
|
+
}
|
|
190
|
+
/** The Needs attention entries raised in one period. */
|
|
191
|
+
export class NeedsAttentionPeriodView extends Schema.Class("@usine/orchestrator/NeedsAttentionPeriodView")({ start: UtcDay, approvals: Count, failures: Count }) {
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The approvals asked for and the failed Attempts that no automatic retry followed, with their
|
|
195
|
+
* waits: from a run's opening to its approval, and from a failure to its first recorded operator
|
|
196
|
+
* answer (retry or resolution). Each answered failure contributes once to `failureWait` and to
|
|
197
|
+
* either `retryWait` or `resolutionWait`. Older resolutions without a timestamp are excluded.
|
|
198
|
+
*/
|
|
199
|
+
export class NeedsAttentionView extends Schema.Class("@usine/orchestrator/NeedsAttentionView")({
|
|
200
|
+
approvals: Count,
|
|
201
|
+
failures: Count,
|
|
202
|
+
periods: Schema.Array(NeedsAttentionPeriodView),
|
|
203
|
+
approvalWait: Schema.NullOr(DurationSummaryView),
|
|
204
|
+
retryWait: Schema.NullOr(DurationSummaryView),
|
|
205
|
+
resolutionWait: Schema.NullOr(DurationSummaryView),
|
|
206
|
+
failureWait: Schema.NullOr(DurationSummaryView),
|
|
207
|
+
}) {
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* How the Runs went in `window`: closed Runs by outcome, Loop, Agent, and brain, with their time,
|
|
211
|
+
* tokens, and cost, and the Worker, retry, and Needs attention measures. Runs that a newer Event or
|
|
212
|
+
* an Item change canceled before an Attempt are left out.
|
|
213
|
+
*/
|
|
214
|
+
export class RunStatisticsView extends Schema.Class("@usine/orchestrator/RunStatisticsView")({
|
|
215
|
+
window: StatisticsWindow,
|
|
216
|
+
/** The window's start: midnight UTC of its first day. */
|
|
217
|
+
from: Schema.String,
|
|
218
|
+
/** The time the statistics were computed. */
|
|
219
|
+
to: Schema.String,
|
|
220
|
+
bucket: StatisticsBucket,
|
|
221
|
+
runs: OutcomeCountsView,
|
|
222
|
+
/** From each closed Run's opening to its close. */
|
|
223
|
+
runTime: Schema.NullOr(DurationSummaryView),
|
|
224
|
+
/** From each ended Attempt's start to its recorded end. */
|
|
225
|
+
attemptTime: Schema.NullOr(DurationSummaryView),
|
|
226
|
+
/** The ended Attempts closed before end times were recorded, left out of `attemptTime`. */
|
|
227
|
+
unmeasuredAttempts: Count,
|
|
228
|
+
/** One period per bucket from `from` to `to`, oldest first. */
|
|
229
|
+
throughput: Schema.Array(ThroughputPeriodView),
|
|
230
|
+
/** By closed Run count, highest first. */
|
|
231
|
+
loops: Schema.Array(LoopStatisticsView),
|
|
232
|
+
agents: Schema.Array(AgentStatisticsView),
|
|
233
|
+
brains: Schema.Array(BrainStatisticsView),
|
|
234
|
+
/** For Runs whose first Attempt started in the window, by Worker name. */
|
|
235
|
+
queueWait: Schema.Array(WorkerQueueWaitView),
|
|
236
|
+
/** From one Attempt to the most any closed Run took, each count present. */
|
|
237
|
+
attemptsPerRun: Schema.Array(AttemptCountView),
|
|
238
|
+
/** For the Workers that `usine.yaml` declares, in declaration order. */
|
|
239
|
+
utilization: Schema.Array(WorkerUtilizationView),
|
|
240
|
+
needsAttention: NeedsAttentionView,
|
|
241
|
+
}) {
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/operator/statistics/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,MAAM,YAAY,GAAG,MAAM,CAAC,GA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C,MAAM,CAAC,mBAAmB,CAAC;CAChD,CAAC;CAAG;AAEL;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,KAAK,CACjD,uCAAuC,CACxC,CAAC;IACA,MAAM,EAAE,gBAAgB;IACxB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,MAAM,EAAE,gBAAgB;IACxB,IAAI,EAAE,iBAAiB;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC3C,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAC/C,2FAA2F;IAC3F,kBAAkB,EAAE,KAAK;IACzB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAC9C,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC;IACzC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC;IAC5C,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;IAC9C,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC;IAChD,cAAc,EAAE,kBAAkB;CACnC,CAAC;CAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RunSummary } from "@usine/engine/run-reader";
|
|
2
|
+
import { DateTime, Option } from "effect";
|
|
3
|
+
import type { StatisticsBucket, StatisticsWindow } from "./view.ts";
|
|
4
|
+
export declare const DAY = 86400000;
|
|
5
|
+
export declare const epoch: (self: DateTime.DateTime) => number;
|
|
6
|
+
export declare const startOfUtcDay: (epochMillis: number) => number;
|
|
7
|
+
/** Returns the start of `window`, or `None` for `all`, whose start depends on the stored Runs. */
|
|
8
|
+
export declare const windowStart: (window: StatisticsWindow, now: DateTime.Utc) => Option.Option<DateTime.Utc>;
|
|
9
|
+
/** Returns the period length for a span: days up to 62 days, else weeks. */
|
|
10
|
+
export declare const spanBucket: (from: number, to: number) => StatisticsBucket;
|
|
11
|
+
export declare const utcDay: (epochMillis: number) => string;
|
|
12
|
+
/** Returns the start of the period that holds `epochMillis`. Weeks start on Monday. */
|
|
13
|
+
export declare const periodStart: (bucket: StatisticsBucket, epochMillis: number) => number;
|
|
14
|
+
/** Returns the start of each period from `from` to `to`, oldest first. */
|
|
15
|
+
export declare const periodStarts: (bucket: StatisticsBucket, from: number, to: number) => ReadonlyArray<number>;
|
|
16
|
+
export declare const sum: (values: ReadonlyArray<number>) => number;
|
|
17
|
+
/** Returns the median of `values`, the mean of the two middle values for an even count. */
|
|
18
|
+
export declare const median: (values: ReadonlyArray<number>) => Option.Option<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the engine canceled the Run before any Attempt because a newer Event or an Item change
|
|
21
|
+
* replaced it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const replacedBeforeStart: ({ run, attempts }: RunSummary) => boolean;
|
|
24
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../src/operator/statistics/window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAwB,QAAQ,EAAE,MAAM,EAAS,MAAM,QAAQ,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEpE,eAAO,MAAM,GAAG,WAAa,CAAC;AAM9B,eAAO,MAAM,KAAK,qCAAyB,CAAC;AAE5C,eAAO,MAAM,aAAa,gBAAiB,MAAM,KAAG,MAA2C,CAAC;AAEhG,kGAAkG;AAClG,eAAO,MAAM,WAAW,WACd,gBAAgB,OACnB,QAAQ,CAAC,GAAG,KAChB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAOtB,CAAC;AAER,4EAA4E;AAC5E,eAAO,MAAM,UAAU,SAAU,MAAM,MAAM,MAAM,KAAG,gBACoB,CAAC;AAE3E,eAAO,MAAM,MAAM,gBAAiB,MAAM,KAAG,MACK,CAAC;AAEnD,uFAAuF;AACvF,eAAO,MAAM,WAAW,WAAY,gBAAgB,eAAe,MAAM,KAAG,MAG3E,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,YAAY,WACf,gBAAgB,QAClB,MAAM,MACR,MAAM,KACT,aAAa,CAAC,MAAM,CAKtB,CAAC;AAEF,eAAO,MAAM,GAAG,WAAY,aAAa,CAAC,MAAM,CAAC,KAAG,MACD,CAAC;AAEpD,2FAA2F;AAC3F,eAAO,MAAM,MAAM,WAAY,aAAa,CAAC,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAO1E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,sBAAuB,UAAU,KAAG,OAGtB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Array as EffectArray, DateTime, Option, Order } from "effect";
|
|
2
|
+
export const DAY = 86_400_000;
|
|
3
|
+
const WEEK = 7 * DAY;
|
|
4
|
+
/** The longest span, in days, that the time series still split into days. */
|
|
5
|
+
const DAILY_SPAN_DAYS = 62;
|
|
6
|
+
const WINDOW_DAYS = { "7d": 7, "30d": 30 };
|
|
7
|
+
export const epoch = DateTime.toEpochMillis;
|
|
8
|
+
export const startOfUtcDay = (epochMillis) => epochMillis - (epochMillis % DAY);
|
|
9
|
+
/** Returns the start of `window`, or `None` for `all`, whose start depends on the stored Runs. */
|
|
10
|
+
export const windowStart = (window, now) => window === "all"
|
|
11
|
+
? Option.none()
|
|
12
|
+
: Option.some(DateTime.makeUnsafe(startOfUtcDay(DateTime.toEpochMillis(now)) - (WINDOW_DAYS[window] - 1) * DAY));
|
|
13
|
+
/** Returns the period length for a span: days up to 62 days, else weeks. */
|
|
14
|
+
export const spanBucket = (from, to) => (startOfUtcDay(to) - from) / DAY + 1 <= DAILY_SPAN_DAYS ? "day" : "week";
|
|
15
|
+
export const utcDay = (epochMillis) => new Date(epochMillis).toISOString().slice(0, 10);
|
|
16
|
+
/** Returns the start of the period that holds `epochMillis`. Weeks start on Monday. */
|
|
17
|
+
export const periodStart = (bucket, epochMillis) => {
|
|
18
|
+
const day = startOfUtcDay(epochMillis);
|
|
19
|
+
return bucket === "day" ? day : day - ((new Date(day).getUTCDay() + 6) % 7) * DAY;
|
|
20
|
+
};
|
|
21
|
+
/** Returns the start of each period from `from` to `to`, oldest first. */
|
|
22
|
+
export const periodStarts = (bucket, from, to) => {
|
|
23
|
+
const step = bucket === "day" ? DAY : WEEK;
|
|
24
|
+
const starts = [];
|
|
25
|
+
for (let start = periodStart(bucket, from); start <= to; start += step)
|
|
26
|
+
starts.push(start);
|
|
27
|
+
return starts;
|
|
28
|
+
};
|
|
29
|
+
export const sum = (values) => values.reduce((total, value) => total + value, 0);
|
|
30
|
+
/** Returns the median of `values`, the mean of the two middle values for an even count. */
|
|
31
|
+
export const median = (values) => {
|
|
32
|
+
if (!EffectArray.isReadonlyArrayNonEmpty(values))
|
|
33
|
+
return Option.none();
|
|
34
|
+
const sorted = EffectArray.sort(values, Order.Number);
|
|
35
|
+
const middle = (sorted.length - 1) / 2;
|
|
36
|
+
const lower = sorted[Math.floor(middle)] ?? sorted[0];
|
|
37
|
+
const upper = sorted[Math.ceil(middle)] ?? lower;
|
|
38
|
+
return Option.some((lower + upper) / 2);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Whether the engine canceled the Run before any Attempt because a newer Event or an Item change
|
|
42
|
+
* replaced it.
|
|
43
|
+
*/
|
|
44
|
+
export const replacedBeforeStart = ({ run, attempts }) => attempts.length === 0 &&
|
|
45
|
+
run.state._tag === "Canceled" &&
|
|
46
|
+
run.state.reason._tag !== "OperatorCanceled";
|
|
47
|
+
//# sourceMappingURL=window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../src/operator/statistics/window.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGvE,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAAC;AAC9B,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC;AACrB,6EAA6E;AAC7E,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAW,CAAC;AAEpD,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAU,EAAE,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;AAEhG,kGAAkG;AAClG,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,MAAwB,EACxB,GAAiB,EACY,EAAE,CAC/B,MAAM,KAAK,KAAK;IACd,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;IACf,CAAC,CAAC,MAAM,CAAC,IAAI,CACT,QAAQ,CAAC,UAAU,CACjB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAC7E,CACF,CAAC;AAER,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAU,EA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