@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
package/dist/worker-status.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { BrainSpec, Harness } from "@usine/core/agent/brain";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
2
|
+
import type { ItemKey } from "@usine/core/item";
|
|
3
|
+
import type { LoopName } from "@usine/core/loop";
|
|
4
|
+
import type { RunId } from "@usine/core/run";
|
|
5
|
+
import type { ContainerLimits, WorkerName } from "@usine/core/worker";
|
|
6
|
+
import type { ExecutorError, MachineStatus, MachineUnavailableReason, PreflightReport, WorkerCapability } from "@usine/executor";
|
|
7
|
+
import { Context, type DateTime, Effect, Layer, Option, Result } from "effect";
|
|
8
|
+
import type { PipelinePosition } from "./lease-order.ts";
|
|
5
9
|
/** A Worker's current slot usage in the scheduler. */
|
|
6
10
|
export interface WorkerSlots {
|
|
7
11
|
readonly worker: WorkerName;
|
|
@@ -10,11 +14,44 @@ export interface WorkerSlots {
|
|
|
10
14
|
/** The number of Attempts with a slot, which can exceed `capacity` after a reload lowered it. */
|
|
11
15
|
readonly leased: number;
|
|
12
16
|
}
|
|
17
|
+
/** A Run that waits for a Worker slot. */
|
|
18
|
+
export interface QueuedRun {
|
|
19
|
+
readonly runId: RunId;
|
|
20
|
+
readonly loop: LoopName;
|
|
21
|
+
readonly itemKey: ItemKey;
|
|
22
|
+
readonly position: PipelinePosition;
|
|
23
|
+
/**
|
|
24
|
+
* The fewest queued Runs that take a Worker slot before this one. Of the Runs that wait for their
|
|
25
|
+
* reattached Attempt's Worker, a Run that can take any Worker's slot counts only those of the
|
|
26
|
+
* Worker with the fewest, among the Workers that take new Attempts.
|
|
27
|
+
*/
|
|
28
|
+
readonly ahead: number;
|
|
29
|
+
}
|
|
13
30
|
/** A passed preflight check. */
|
|
14
31
|
export interface PreflightPassed {
|
|
15
32
|
readonly _tag: "Passed";
|
|
16
33
|
readonly checkedAt: DateTime.Utc;
|
|
17
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A passed check of a Worker's own prerequisites that found it running Attempts without a
|
|
37
|
+
* capability that keeps them apart, such as an SSH Worker without Docker.
|
|
38
|
+
*/
|
|
39
|
+
export interface PreflightDegraded {
|
|
40
|
+
readonly _tag: "Degraded";
|
|
41
|
+
readonly checkedAt: DateTime.Utc;
|
|
42
|
+
/** The executor's summary for operators. */
|
|
43
|
+
readonly message: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A check that the preflight left for later, such as a provisioned Worker's harness checks,
|
|
47
|
+
* which run on its first machine each day.
|
|
48
|
+
*/
|
|
49
|
+
export interface PreflightDeferred {
|
|
50
|
+
readonly _tag: "Deferred";
|
|
51
|
+
readonly checkedAt: DateTime.Utc;
|
|
52
|
+
/** When the check runs instead, for operators. */
|
|
53
|
+
readonly message: string;
|
|
54
|
+
}
|
|
18
55
|
/** A preflight check that found a missing prerequisite or couldn't run. */
|
|
19
56
|
export interface PreflightFailed {
|
|
20
57
|
readonly _tag: "Failed";
|
|
@@ -25,7 +62,23 @@ export interface PreflightFailed {
|
|
|
25
62
|
readonly message: string;
|
|
26
63
|
}
|
|
27
64
|
/** The last outcome of one preflight check and when it ended. */
|
|
28
|
-
export type PreflightCheck = PreflightPassed | PreflightFailed;
|
|
65
|
+
export type PreflightCheck = PreflightPassed | PreflightDegraded | PreflightDeferred | PreflightFailed;
|
|
66
|
+
/**
|
|
67
|
+
* A provisioned Worker that couldn't create a machine, and when it tries again. The Runs it
|
|
68
|
+
* would serve keep waiting.
|
|
69
|
+
*/
|
|
70
|
+
export interface ProvisioningPause {
|
|
71
|
+
readonly worker: WorkerName;
|
|
72
|
+
/** Why the creation failed, or `check` if the first machine of the day failed its preflight. */
|
|
73
|
+
readonly reason: MachineUnavailableReason | "check";
|
|
74
|
+
readonly message: string;
|
|
75
|
+
/** The number of failed creations in a row. */
|
|
76
|
+
readonly failures: number;
|
|
77
|
+
readonly failedAt: DateTime.Utc;
|
|
78
|
+
readonly retryAt: DateTime.Utc;
|
|
79
|
+
/** Whether the Worker still waits for `retryAt` before it creates a machine. */
|
|
80
|
+
readonly blocked: boolean;
|
|
81
|
+
}
|
|
29
82
|
/** The last preflight of one harness on a Worker. */
|
|
30
83
|
export interface HarnessPreflight {
|
|
31
84
|
readonly harness: Harness;
|
|
@@ -33,7 +86,7 @@ export interface HarnessPreflight {
|
|
|
33
86
|
}
|
|
34
87
|
/**
|
|
35
88
|
* The last preflight of a Worker: its own prerequisites (machine, Git, memory, Gateway, and
|
|
36
|
-
* credentials)
|
|
89
|
+
* credentials), each checked harness, and the limits of its Attempt containers.
|
|
37
90
|
*/
|
|
38
91
|
export interface WorkerPreflight {
|
|
39
92
|
readonly worker: WorkerName;
|
|
@@ -41,12 +94,20 @@ export interface WorkerPreflight {
|
|
|
41
94
|
readonly prerequisites: Option.Option<PreflightCheck>;
|
|
42
95
|
/** In harness name order. */
|
|
43
96
|
readonly harnesses: ReadonlyArray<HarnessPreflight>;
|
|
97
|
+
/**
|
|
98
|
+
* The limits of each Attempt container from the last passed preflight that checked the
|
|
99
|
+
* Worker's machine. `None` before one, or if that machine had no Docker.
|
|
100
|
+
*/
|
|
101
|
+
readonly containerLimits: Option.Option<ContainerLimits>;
|
|
44
102
|
}
|
|
45
103
|
/**
|
|
46
|
-
* Returns `previous` updated with one preflight of `brains`.
|
|
47
|
-
* harness and
|
|
104
|
+
* Returns `previous` updated with one preflight of `brains`. A degraded report passes every
|
|
105
|
+
* harness and records the prerequisites as degraded, and a deferred report records every
|
|
106
|
+
* harness as deferred and keeps the container limits, since it checked no machine. An
|
|
107
|
+
* unavailable harness fails that harness and passes the ones checked before it; any other
|
|
108
|
+
* failure fails only the prerequisites.
|
|
48
109
|
*/
|
|
49
|
-
export declare const recordPreflight: (previous: WorkerPreflight, brains: ReadonlyArray<BrainSpec>, checkedAt: DateTime.Utc,
|
|
110
|
+
export declare const recordPreflight: (previous: WorkerPreflight, brains: ReadonlyArray<BrainSpec>, checkedAt: DateTime.Utc, outcome: Result.Result<PreflightReport, ExecutorError>) => WorkerPreflight;
|
|
50
111
|
/** Returns the preflight record of a Worker that no preflight has checked. */
|
|
51
112
|
export declare const unchecked: (worker: WorkerName) => WorkerPreflight;
|
|
52
113
|
declare const WorkerStatus_base: Context.ServiceClass<WorkerStatus, "@usine/orchestrator/WorkerStatus", {
|
|
@@ -55,15 +116,24 @@ declare const WorkerStatus_base: Context.ServiceClass<WorkerStatus, "@usine/orch
|
|
|
55
116
|
* Attempt ends.
|
|
56
117
|
*/
|
|
57
118
|
readonly slots: Effect.Effect<ReadonlyArray<WorkerSlots>>;
|
|
119
|
+
/** The Runs that wait for a Worker slot, in the order they take one (`leaseOrder`). */
|
|
120
|
+
readonly queue: Effect.Effect<ReadonlyArray<QueuedRun>>;
|
|
58
121
|
/**
|
|
59
122
|
* The last preflight of each Worker checked since startup, including a refused reload's
|
|
60
123
|
* preflight.
|
|
61
124
|
*/
|
|
62
125
|
readonly preflights: Effect.Effect<ReadonlyArray<WorkerPreflight>>;
|
|
126
|
+
/** The machines of the provisioned Workers in flight, oldest first. */
|
|
127
|
+
readonly machines: Effect.Effect<ReadonlyArray<MachineStatus>>;
|
|
128
|
+
/** The provisioned Workers whose last machine creation failed. */
|
|
129
|
+
readonly provisioning: Effect.Effect<ReadonlyArray<ProvisioningPause>>;
|
|
63
130
|
}>;
|
|
64
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* The scheduler's current slot usage, queued Runs, last preflight of each Worker, and the
|
|
133
|
+
* provisioned Workers' machines and pauses.
|
|
134
|
+
*/
|
|
65
135
|
export declare class WorkerStatus extends WorkerStatus_base {
|
|
66
|
-
/** A status with no Workers and no preflights, as in setup mode. */
|
|
136
|
+
/** A status with no Workers, no queued Runs, and no preflights, as in setup mode. */
|
|
67
137
|
static readonly idle: Layer.Layer<WorkerStatus, never, never>;
|
|
68
138
|
}
|
|
69
139
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-status.d.ts","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-status.d.ts","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,OAAO,EACP,KAAK,QAAQ,EACb,MAAM,EACN,KAAK,EACL,MAAM,EAEN,MAAM,EAEP,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,kFAAkF;IACl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,MAAM,SAAS,WAAY,UAAU,KAAG,eAK7C,CAAC;;IASC;;;OAGG;oBACa,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACzD,uFAAuF;oBACvE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD;;;OAGG;yBACkB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IAClE,uEAAuE;uBACpD,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC9D,kEAAkE;2BAC3C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;;AAtB1E;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAoBK;IACrC,qFAAqF;IACrF,MAAM,CAAC,QAAQ,CAAC,IAAI,0CAMjB;CACJ"}
|
package/dist/worker-status.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
-
import { Array as Arr, Context, Effect, Layer, Option, Order, Schema } from "effect";
|
|
2
|
+
import { Array as Arr, Context, Effect, Layer, Option, Order, Result, Schema, } from "effect";
|
|
3
3
|
const isHarnessUnavailable = Schema.is(HarnessUnavailableError);
|
|
4
4
|
const byHarness = Order.mapInput(Order.String, ({ harness }) => harness);
|
|
5
5
|
const withHarnesses = (harnesses, checked, check) => Arr.sort([
|
|
@@ -7,20 +7,32 @@ const withHarnesses = (harnesses, checked, check) => Arr.sort([
|
|
|
7
7
|
...checked.map((harness) => ({ harness, check })),
|
|
8
8
|
], byHarness);
|
|
9
9
|
/**
|
|
10
|
-
* Returns `previous` updated with one preflight of `brains`.
|
|
11
|
-
* harness and
|
|
10
|
+
* Returns `previous` updated with one preflight of `brains`. A degraded report passes every
|
|
11
|
+
* harness and records the prerequisites as degraded, and a deferred report records every
|
|
12
|
+
* harness as deferred and keeps the container limits, since it checked no machine. An
|
|
13
|
+
* unavailable harness fails that harness and passes the ones checked before it; any other
|
|
14
|
+
* failure fails only the prerequisites.
|
|
12
15
|
*/
|
|
13
|
-
export const recordPreflight = (previous, brains, checkedAt,
|
|
16
|
+
export const recordPreflight = (previous, brains, checkedAt, outcome) => {
|
|
14
17
|
const harnesses = Arr.dedupe(brains.map(({ harness }) => harness));
|
|
15
|
-
if (
|
|
18
|
+
if (Result.isSuccess(outcome)) {
|
|
16
19
|
const passed = { _tag: "Passed", checkedAt };
|
|
17
20
|
return {
|
|
18
21
|
worker: previous.worker,
|
|
19
|
-
prerequisites: Option.some(
|
|
20
|
-
|
|
22
|
+
prerequisites: Option.some(Option.match(outcome.success.degraded, {
|
|
23
|
+
onNone: () => passed,
|
|
24
|
+
onSome: (message) => ({ _tag: "Degraded", checkedAt, message }),
|
|
25
|
+
})),
|
|
26
|
+
harnesses: withHarnesses(previous.harnesses, harnesses, Option.match(outcome.success.deferred, {
|
|
27
|
+
onNone: () => passed,
|
|
28
|
+
onSome: (message) => ({ _tag: "Deferred", checkedAt, message }),
|
|
29
|
+
})),
|
|
30
|
+
containerLimits: Option.isSome(outcome.success.deferred)
|
|
31
|
+
? previous.containerLimits
|
|
32
|
+
: outcome.success.containerLimits,
|
|
21
33
|
};
|
|
22
34
|
}
|
|
23
|
-
const error = failure
|
|
35
|
+
const error = outcome.failure;
|
|
24
36
|
const capability = error._tag === "WorkerCapabilityError" ? Option.some(error.capability) : Option.none();
|
|
25
37
|
const failed = { _tag: "Failed", checkedAt, capability, message: error.message };
|
|
26
38
|
if (error._tag === "WorkerCapabilityError" && isHarnessUnavailable(error.cause)) {
|
|
@@ -30,12 +42,14 @@ export const recordPreflight = (previous, brains, checkedAt, failure) => {
|
|
|
30
42
|
worker: previous.worker,
|
|
31
43
|
prerequisites: previous.prerequisites,
|
|
32
44
|
harnesses: withHarnesses(withHarnesses(previous.harnesses, before, { _tag: "Passed", checkedAt }), [unavailable], failed),
|
|
45
|
+
containerLimits: previous.containerLimits,
|
|
33
46
|
};
|
|
34
47
|
}
|
|
35
48
|
return {
|
|
36
49
|
worker: previous.worker,
|
|
37
50
|
prerequisites: Option.some(failed),
|
|
38
51
|
harnesses: previous.harnesses,
|
|
52
|
+
containerLimits: previous.containerLimits,
|
|
39
53
|
};
|
|
40
54
|
};
|
|
41
55
|
/** Returns the preflight record of a Worker that no preflight has checked. */
|
|
@@ -43,13 +57,20 @@ export const unchecked = (worker) => ({
|
|
|
43
57
|
worker,
|
|
44
58
|
prerequisites: Option.none(),
|
|
45
59
|
harnesses: [],
|
|
60
|
+
containerLimits: Option.none(),
|
|
46
61
|
});
|
|
47
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* The scheduler's current slot usage, queued Runs, last preflight of each Worker, and the
|
|
64
|
+
* provisioned Workers' machines and pauses.
|
|
65
|
+
*/
|
|
48
66
|
export class WorkerStatus extends Context.Service()("@usine/orchestrator/WorkerStatus") {
|
|
49
|
-
/** A status with no Workers and no preflights, as in setup mode. */
|
|
67
|
+
/** A status with no Workers, no queued Runs, and no preflights, as in setup mode. */
|
|
50
68
|
static idle = Layer.succeed(WorkerStatus)({
|
|
51
69
|
slots: Effect.succeed([]),
|
|
70
|
+
queue: Effect.succeed([]),
|
|
52
71
|
preflights: Effect.succeed([]),
|
|
72
|
+
machines: Effect.succeed([]),
|
|
73
|
+
provisioning: Effect.succeed([]),
|
|
53
74
|
});
|
|
54
75
|
}
|
|
55
76
|
//# sourceMappingURL=worker-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-status.js","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-status.js","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAYvE,OAAO,EACL,KAAK,IAAI,GAAG,EACZ,OAA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AAC,OAAO,CAAC,EAAE,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;KACjC,CAAC,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/orchestrator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The embeddable usine composition: the full engine as an Effect layer, startable in-process.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/basaltbytes/usine.git",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./dist/board/projection.d.ts",
|
|
20
20
|
"default": "./dist/board/projection.js"
|
|
21
21
|
},
|
|
22
|
+
"./cloudflare": {
|
|
23
|
+
"types": "./dist/cloudflare.d.ts",
|
|
24
|
+
"default": "./dist/cloudflare.js"
|
|
25
|
+
},
|
|
22
26
|
"./credentials": {
|
|
23
27
|
"types": "./dist/credentials.d.ts",
|
|
24
28
|
"default": "./dist/credentials.js"
|
|
@@ -43,6 +47,14 @@
|
|
|
43
47
|
"types": "./dist/local.d.ts",
|
|
44
48
|
"default": "./dist/local.js"
|
|
45
49
|
},
|
|
50
|
+
"./operator": {
|
|
51
|
+
"types": "./dist/operator/operator.d.ts",
|
|
52
|
+
"default": "./dist/operator/operator.js"
|
|
53
|
+
},
|
|
54
|
+
"./operator/http": {
|
|
55
|
+
"types": "./dist/operator/http.d.ts",
|
|
56
|
+
"default": "./dist/operator/http.js"
|
|
57
|
+
},
|
|
46
58
|
"./orchestrator": {
|
|
47
59
|
"types": "./dist/orchestrator.d.ts",
|
|
48
60
|
"default": "./dist/orchestrator.js"
|
|
@@ -70,41 +82,33 @@
|
|
|
70
82
|
"./worker-status": {
|
|
71
83
|
"types": "./dist/worker-status.d.ts",
|
|
72
84
|
"default": "./dist/worker-status.js"
|
|
73
|
-
},
|
|
74
|
-
"./operator": {
|
|
75
|
-
"types": "./dist/operator/operator.d.ts",
|
|
76
|
-
"default": "./dist/operator/operator.js"
|
|
77
|
-
},
|
|
78
|
-
"./operator/http": {
|
|
79
|
-
"types": "./dist/operator/http.d.ts",
|
|
80
|
-
"default": "./dist/operator/http.js"
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
87
|
"publishConfig": {
|
|
84
88
|
"access": "public"
|
|
85
89
|
},
|
|
86
90
|
"dependencies": {
|
|
87
|
-
"@effect/platform-node": "4.0.
|
|
88
|
-
"@effect/platform-node-shared": "4.0.
|
|
89
|
-
"@usine/
|
|
90
|
-
"@usine/
|
|
91
|
-
"@usine/
|
|
92
|
-
"@usine/
|
|
93
|
-
"@usine/engine": "0.
|
|
94
|
-
"@usine/
|
|
95
|
-
"@usine/
|
|
91
|
+
"@effect/platform-node": "4.0.6",
|
|
92
|
+
"@effect/platform-node-shared": "4.0.6",
|
|
93
|
+
"@usine/agents": "0.5.0",
|
|
94
|
+
"@usine/core": "0.5.0",
|
|
95
|
+
"@usine/config": "0.4.0",
|
|
96
|
+
"@usine/durable": "0.2.0",
|
|
97
|
+
"@usine/engine": "0.5.0",
|
|
98
|
+
"@usine/github": "0.3.0",
|
|
99
|
+
"@usine/executor": "0.4.0",
|
|
100
|
+
"@usine/expression": "0.4.0"
|
|
96
101
|
},
|
|
97
102
|
"devDependencies": {
|
|
98
|
-
"@effect/vitest": "4.0.
|
|
99
|
-
"effect": "4.0.
|
|
103
|
+
"@effect/vitest": "4.0.6",
|
|
104
|
+
"effect": "4.0.6",
|
|
100
105
|
"typescript": "7.0.2",
|
|
101
|
-
"vitest": "
|
|
102
|
-
"@usine/
|
|
103
|
-
"@usine/gateway": "0.1.0",
|
|
106
|
+
"vitest": "5.0.5",
|
|
107
|
+
"@usine/gateway": "0.2.0",
|
|
104
108
|
"@usine/tsconfig": "0.0.0"
|
|
105
109
|
},
|
|
106
110
|
"peerDependencies": {
|
|
107
|
-
"effect": "4.0.
|
|
111
|
+
"effect": "4.0.6"
|
|
108
112
|
},
|
|
109
113
|
"engines": {
|
|
110
114
|
"node": ">=22"
|