@usine/orchestrator 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -52
- package/dist/board/items.d.ts +9 -1
- package/dist/board/items.d.ts.map +1 -1
- package/dist/board/items.js +16 -4
- package/dist/board/items.js.map +1 -1
- package/dist/board/projection.d.ts +7 -1
- package/dist/board/projection.d.ts.map +1 -1
- package/dist/board/projection.js +53 -14
- package/dist/board/projection.js.map +1 -1
- package/dist/board/tasks.d.ts +14 -2
- package/dist/board/tasks.d.ts.map +1 -1
- package/dist/board/tasks.js +23 -8
- package/dist/board/tasks.js.map +1 -1
- 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 +138 -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 +7 -8
- package/dist/exe-dev.js.map +1 -1
- 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/local.d.ts +4 -18
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +7 -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 +57 -10
- package/dist/operator/attempt.d.ts.map +1 -1
- package/dist/operator/attempt.js +49 -10
- package/dist/operator/attempt.js.map +1 -1
- package/dist/operator/board.d.ts +43 -16
- package/dist/operator/board.d.ts.map +1 -1
- package/dist/operator/board.js +43 -16
- package/dist/operator/board.js.map +1 -1
- package/dist/operator/configuration.d.ts +258 -0
- package/dist/operator/configuration.d.ts.map +1 -0
- package/dist/operator/configuration.js +410 -0
- package/dist/operator/configuration.js.map +1 -0
- package/dist/operator/desk.d.ts +181 -0
- package/dist/operator/desk.d.ts.map +1 -0
- package/dist/operator/desk.js +463 -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 +152 -57
- package/dist/operator/http.d.ts.map +1 -1
- package/dist/operator/http.js +140 -21
- package/dist/operator/http.js.map +1 -1
- package/dist/operator/need.d.ts +44 -11
- package/dist/operator/need.d.ts.map +1 -1
- package/dist/operator/need.js +46 -9
- package/dist/operator/need.js.map +1 -1
- package/dist/operator/operator.d.ts +109 -29
- package/dist/operator/operator.d.ts.map +1 -1
- package/dist/operator/operator.js +254 -52
- 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 +54 -5
- package/dist/operator/projection.d.ts.map +1 -1
- package/dist/operator/projection.js +100 -9
- package/dist/operator/projection.js.map +1 -1
- package/dist/operator/run.d.ts +71 -6
- package/dist/operator/run.d.ts.map +1 -1
- package/dist/operator/run.js +69 -6
- package/dist/operator/run.js.map +1 -1
- package/dist/operator/task.d.ts +93 -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 +111 -0
- package/dist/operator/usage.d.ts.map +1 -0
- package/dist/operator/usage.js +219 -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/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/polling.d.ts +20 -11
- package/dist/polling/polling.d.ts.map +1 -1
- package/dist/polling/polling.js +201 -51
- package/dist/polling/polling.js.map +1 -1
- package/dist/polling/repository-sync.d.ts +20 -14
- package/dist/polling/repository-sync.d.ts.map +1 -1
- package/dist/polling/repository-sync.js +34 -27
- 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 +35 -4
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +327 -41
- package/dist/scheduler.js.map +1 -1
- package/dist/ssh.d.ts +39 -0
- package/dist/ssh.d.ts.map +1 -0
- package/dist/ssh.js +75 -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 +10 -0
- package/dist/worker-engine.d.ts.map +1 -0
- package/dist/worker-engine.js +25 -0
- package/dist/worker-engine.js.map +1 -0
- package/dist/worker-status.d.ts +70 -0
- package/dist/worker-status.d.ts.map +1 -0
- package/dist/worker-status.js +55 -0
- package/dist/worker-status.js.map +1 -0
- package/package.json +31 -10
package/dist/ssh.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../src/ssh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,K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
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TriggerCondition } from "@usine/engine/trigger-condition";
|
|
2
|
+
import { ExpressionEngine } from "@usine/expression/expression-engine";
|
|
3
|
+
import { GitHubPolling } from "@usine/github/polling";
|
|
4
|
+
import { Layer } from "effect";
|
|
5
|
+
import { CurrentInstance } from "./current-instance/current-instance.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Re-evaluates a queued Event's trigger against a fresh GitHub snapshot of its Item. Returns
|
|
8
|
+
* `item-gone` if the Item no longer exists, and `matches` on any other failure or after five
|
|
9
|
+
* seconds.
|
|
10
|
+
*/
|
|
11
|
+
export declare const triggerConditionLayer: Layer.Layer<TriggerCondition, never, CurrentInstance | ExpressionEngine | GitHubPolling>;
|
|
12
|
+
//# sourceMappingURL=trigger-condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-condition.d.ts","sourceRoot":"","sources":["../src/trigger-condition.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAoC,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAU,KAAK,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAMzE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,KAAK,CAC7C,gBAAgB,EAChB,KAAK,EACL,eAAe,GAAG,gBAAgB,GAAG,aAAa,CAkGnD,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { environmentFor, repositoryContext } from "@usine/config/payload-slices";
|
|
2
|
+
import { matchesSelector } from "@usine/config/selector";
|
|
3
|
+
import { canonicalRepositoryName } from "@usine/core/repository";
|
|
4
|
+
import { TriggerCondition } from "@usine/engine/trigger-condition";
|
|
5
|
+
import { ExpressionEngine } from "@usine/expression/expression-engine";
|
|
6
|
+
import { ChangedIssue, ChangedPullRequest, GitHubPolling } from "@usine/github/polling";
|
|
7
|
+
import { Effect, Layer, Option, Schema } from "effect";
|
|
8
|
+
import { CurrentInstance } from "./current-instance/current-instance.js";
|
|
9
|
+
import { repositoryFailureLogFields } from "./polling/cycle.js";
|
|
10
|
+
import { GitHubItemKey } from "./polling/repository-sync.js";
|
|
11
|
+
const decodeItemKey = Schema.decodeUnknownOption(GitHubItemKey);
|
|
12
|
+
/**
|
|
13
|
+
* Re-evaluates a queued Event's trigger against a fresh GitHub snapshot of its Item. Returns
|
|
14
|
+
* `item-gone` if the Item no longer exists, and `matches` on any other failure or after five
|
|
15
|
+
* seconds.
|
|
16
|
+
*/
|
|
17
|
+
export const triggerConditionLayer = Layer.effect(TriggerCondition, Effect.gen(function* () {
|
|
18
|
+
const github = yield* GitHubPolling;
|
|
19
|
+
const expressions = yield* ExpressionEngine;
|
|
20
|
+
const instances = yield* CurrentInstance;
|
|
21
|
+
const evaluate = Effect.fn("TriggerCondition.evaluate")(function* (submission) {
|
|
22
|
+
const fields = {
|
|
23
|
+
loop: submission.loop,
|
|
24
|
+
repository: submission.repository,
|
|
25
|
+
itemKey: submission.itemKey,
|
|
26
|
+
};
|
|
27
|
+
const instance = yield* instances.get;
|
|
28
|
+
const loop = instance.loops.find(({ name }) => name === submission.loop);
|
|
29
|
+
if (loop === undefined) {
|
|
30
|
+
yield* Effect.logInfo("Queued Event belongs to a Loop that is no longer loaded", fields);
|
|
31
|
+
return "no-longer-matches";
|
|
32
|
+
}
|
|
33
|
+
if (loop.trigger.on === "schedule")
|
|
34
|
+
return "matches";
|
|
35
|
+
const repository = instance.config.repos.find(({ name }) => canonicalRepositoryName(name) === canonicalRepositoryName(submission.repository));
|
|
36
|
+
if (repository === undefined || !matchesSelector(loop.selector, repository)) {
|
|
37
|
+
yield* Effect.logInfo("Queued Event's repository is no longer watched by its Loop", {
|
|
38
|
+
...fields,
|
|
39
|
+
managed: repository !== undefined,
|
|
40
|
+
});
|
|
41
|
+
return "no-longer-matches";
|
|
42
|
+
}
|
|
43
|
+
const item = decodeItemKey(submission.itemKey);
|
|
44
|
+
if (Option.isNone(item)) {
|
|
45
|
+
yield* Effect.logWarning("Queued Event's Item key is not a GitHub Item; opening as before", fields);
|
|
46
|
+
return "matches";
|
|
47
|
+
}
|
|
48
|
+
const [, , number] = item.value;
|
|
49
|
+
const changed = loop.trigger.on === "pr"
|
|
50
|
+
? new ChangedPullRequest({ number, updatedAt: submission.event.receivedAt })
|
|
51
|
+
: new ChangedIssue({ number, updatedAt: submission.event.receivedAt });
|
|
52
|
+
const snapshot = yield* github.snapshot(repository.name, changed);
|
|
53
|
+
const holds = yield* expressions.evaluateBoolean(loop.trigger.if, environmentFor(loop.trigger.on), { repo: repositoryContext(repository), item: snapshot.payload });
|
|
54
|
+
yield* Effect.logInfo("Queued Event re-evaluated against the Item's current state", {
|
|
55
|
+
...fields,
|
|
56
|
+
item: number,
|
|
57
|
+
contentHash: snapshot.contentHash,
|
|
58
|
+
holds,
|
|
59
|
+
});
|
|
60
|
+
return holds ? "matches" : "no-longer-matches";
|
|
61
|
+
});
|
|
62
|
+
const recheck = Effect.fn("TriggerCondition.recheck")(function* (submission) {
|
|
63
|
+
yield* Effect.annotateCurrentSpan({
|
|
64
|
+
loop: submission.loop,
|
|
65
|
+
repository: submission.repository,
|
|
66
|
+
itemKey: submission.itemKey,
|
|
67
|
+
});
|
|
68
|
+
// Bound the whole re-check so a stalled read cannot retain the closed
|
|
69
|
+
// Run's continuation and block the Item or an operator retry.
|
|
70
|
+
return yield* evaluate(submission).pipe(Effect.timeout("5 seconds"));
|
|
71
|
+
}, (effect, submission) => effect.pipe(Effect.catchTag("GitHubItemNotFoundError", (error) => Effect.logInfo("Queued Event's Item is gone from GitHub; its Events are revoked", {
|
|
72
|
+
loop: submission.loop,
|
|
73
|
+
repository: submission.repository,
|
|
74
|
+
itemKey: submission.itemKey,
|
|
75
|
+
item: error.item,
|
|
76
|
+
errorTag: error._tag,
|
|
77
|
+
message: error.message,
|
|
78
|
+
}).pipe(Effect.as("item-gone"))), Effect.catch((error) => Effect.logWarning("Trigger re-check failed; opening the queued Event as before", {
|
|
79
|
+
loop: submission.loop,
|
|
80
|
+
repository: submission.repository,
|
|
81
|
+
itemKey: submission.itemKey,
|
|
82
|
+
...(error._tag === "TimeoutError"
|
|
83
|
+
? { errorTag: error._tag, message: "Trigger re-check exceeded five seconds" }
|
|
84
|
+
: repositoryFailureLogFields(error)),
|
|
85
|
+
}).pipe(Effect.as("matches")))));
|
|
86
|
+
return { recheck };
|
|
87
|
+
}));
|
|
88
|
+
//# sourceMappingURL=trigger-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-condition.js","sourceRoot":"","sources":["../src/trigger-condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;AAEhE;;;;GA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A6D,EAAE;QAC/E,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc;YAC/B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,wCAAwC,EAAE;YAC7E,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;KACvC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAkB,CAAC,CAAC,CACvC,CACF,CACJ,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -6,12 +6,15 @@ import { Agent } from "@usine/core/agent";
|
|
|
6
6
|
import { ModelId } from "@usine/core/agent/brain";
|
|
7
7
|
import { AttemptTask } from "@usine/core/attempt";
|
|
8
8
|
import { DedupKey } from "@usine/core/event";
|
|
9
|
-
import { CycleGeneration } from "@usine/core/cycle-budget";
|
|
9
|
+
import { CycleGeneration, type CycleLimit } from "@usine/core/cycle-budget";
|
|
10
10
|
import { ItemKey } from "@usine/core/item";
|
|
11
11
|
import { RepositoryRevision } from "@usine/core/repository";
|
|
12
12
|
import { Submission, type SubmissionResult } from "@usine/engine/engine";
|
|
13
13
|
import { type DateTime, Effect, Option, Schema } from "effect";
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The revision for issue and schedule Attempts, which resolve the remote's default branch at
|
|
16
|
+
* prepare time.
|
|
17
|
+
*/
|
|
15
18
|
export declare const DEFAULT_BRANCH_REVISION: string & import("effect/Brand").Brand<"RepositoryRevision">;
|
|
16
19
|
export interface ResolvedLoop {
|
|
17
20
|
readonly agent: Agent;
|
|
@@ -23,21 +26,16 @@ declare const LoopAgentResolutionError_base: Schema.Class<LoopAgentResolutionErr
|
|
|
23
26
|
readonly agent: Schema.brand<Schema.String, "AgentName">;
|
|
24
27
|
readonly message: Schema.NonEmptyString;
|
|
25
28
|
}>, import("effect/Cause").YieldableError>;
|
|
26
|
-
/** The
|
|
29
|
+
/** The Agent of a loaded Loop is no longer in the roster. */
|
|
27
30
|
export declare class LoopAgentResolutionError extends LoopAgentResolutionError_base {
|
|
28
31
|
}
|
|
29
|
-
/** Resolves one
|
|
32
|
+
/** Resolves one Loop's roster Agent and effective parent model. */
|
|
30
33
|
export declare const resolveTriggerLoop: (instance: LoadedInstance, loop: LoopFile) => Effect.Effect<{
|
|
31
34
|
agent: Agent;
|
|
32
35
|
loop: LoopFile;
|
|
33
36
|
parentModel: Option.Option<string & import("effect/Brand").Brand<"ModelId">>;
|
|
34
37
|
}, LoopAgentResolutionError, never>;
|
|
35
|
-
/**
|
|
36
|
-
* Resolves every loaded loop's agent. `InstanceFolder.load` already quarantines
|
|
37
|
-
* loops that name unknown agents, so a miss here means a hand-assembled
|
|
38
|
-
* instance drifted: the loop is skipped with a log each cycle and its siblings
|
|
39
|
-
* keep running.
|
|
40
|
-
*/
|
|
38
|
+
/** Resolves every loaded Loop's Agent, skipping and logging each Loop whose Agent is missing. */
|
|
41
39
|
export declare const resolveTriggerLoops: (instance: LoadedInstance) => Effect.Effect<ResolvedLoop[], never, never>;
|
|
42
40
|
interface TriggerSubmissionOptions {
|
|
43
41
|
readonly agent: Agent;
|
|
@@ -52,11 +50,16 @@ interface TriggerSubmissionOptions {
|
|
|
52
50
|
readonly task: AttemptTask;
|
|
53
51
|
readonly parentModel: Option.Option<ModelId>;
|
|
54
52
|
}
|
|
55
|
-
/**
|
|
53
|
+
/** Returns the Loop's `max_cycles`, or `None` for a schedule Loop, whose Runs no budget counts. */
|
|
54
|
+
export declare const cycleLimitOf: (loop: LoopFile) => Option.Option<CycleLimit>;
|
|
55
|
+
/** Builds the Submission that every trigger stream sends to the engine. */
|
|
56
56
|
export declare const triggerSubmission: (options: TriggerSubmissionOptions) => Submission;
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Returns the log fields for a submission outcome: the Run ID for a claim or suppression, the
|
|
59
|
+
* reason for an ignore.
|
|
60
|
+
*/
|
|
58
61
|
export declare const submissionLogFields: (submission: SubmissionResult) => Record<string, string>;
|
|
59
|
-
/**
|
|
62
|
+
/** Returns the log fields for a config failure during triggering. */
|
|
60
63
|
export declare const configFileErrorLogFields: (error: ConfigFileError) => {
|
|
61
64
|
configFile: string & import("effect/Brand").Brand<"InstancePath">;
|
|
62
65
|
configStage: "expression" | "frontmatter" | "read" | "reference" | "schema" | "yaml";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-submission.d.ts","sourceRoot":"","sources":["../src/trigger-submission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAiC,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAS,QAAQ,EAAW,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"trigger-submission.d.ts","sourceRoot":"","sources":["../src/trigger-submission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,W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EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAC9C;AAED,mGAAmG;AACnG,eAAO,MAAM,YAAY,SAAU,QAAQ,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CACQ,CAAC;AAE/E,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,YAAa,wBAAwB,KAAG,UAoBlE,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,mBAAmB,eAAgB,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAOpF,CAAC;AAEL,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,UAAW,eAAe;;;;;;;CAQ3D,CAAC"}
|
|
@@ -8,16 +8,19 @@ import { LoopName } from "@usine/core/loop";
|
|
|
8
8
|
import { RepositoryRevision } from "@usine/core/repository";
|
|
9
9
|
import { Submission } from "@usine/engine/engine";
|
|
10
10
|
import { Effect, Match, Option, Result, Schema } from "effect";
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* The revision for issue and schedule Attempts, which resolve the remote's default branch at
|
|
13
|
+
* prepare time.
|
|
14
|
+
*/
|
|
12
15
|
export const DEFAULT_BRANCH_REVISION = RepositoryRevision.make("HEAD");
|
|
13
|
-
/** The
|
|
16
|
+
/** The Agent of a loaded Loop is no longer in the roster. */
|
|
14
17
|
export class LoopAgentResolutionError extends Schema.TaggedError("@usine/orchestrator/LoopAgentResolutionError")("LoopAgentResolutionError", {
|
|
15
18
|
loop: LoopName,
|
|
16
19
|
agent: AgentName,
|
|
17
20
|
message: Schema.NonEmptyString,
|
|
18
21
|
}) {
|
|
19
22
|
}
|
|
20
|
-
/** Resolves one
|
|
23
|
+
/** Resolves one Loop's roster Agent and effective parent model. */
|
|
21
24
|
export const resolveTriggerLoop = Effect.fn("TriggerRouting.resolveLoop")(function* (instance, loop) {
|
|
22
25
|
yield* Effect.annotateCurrentSpan({ loop: loop.name, agent: loop.agent });
|
|
23
26
|
const roster = new Map(instance.agents.map((agent) => [agent.name, agent]));
|
|
@@ -26,7 +29,7 @@ export const resolveTriggerLoop = Effect.fn("TriggerRouting.resolveLoop")(functi
|
|
|
26
29
|
return yield* new LoopAgentResolutionError({
|
|
27
30
|
loop: loop.name,
|
|
28
31
|
agent: loop.agent,
|
|
29
|
-
message: `Loop ${loop.name} references
|
|
32
|
+
message: `Loop "${loop.name}" references agent "${loop.agent}", which is not in the roster`,
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
35
|
const agent = loaded.agent;
|
|
@@ -36,12 +39,7 @@ export const resolveTriggerLoop = Effect.fn("TriggerRouting.resolveLoop")(functi
|
|
|
36
39
|
parentModel: resolveParentModel(agent, instance.config.settings.parentModel),
|
|
37
40
|
};
|
|
38
41
|
});
|
|
39
|
-
/**
|
|
40
|
-
* Resolves every loaded loop's agent. `InstanceFolder.load` already quarantines
|
|
41
|
-
* loops that name unknown agents, so a miss here means a hand-assembled
|
|
42
|
-
* instance drifted: the loop is skipped with a log each cycle and its siblings
|
|
43
|
-
* keep running.
|
|
44
|
-
*/
|
|
42
|
+
/** Resolves every loaded Loop's Agent, skipping and logging each Loop whose Agent is missing. */
|
|
45
43
|
export const resolveTriggerLoops = Effect.fn("TriggerRouting.resolveLoops")(function* (instance) {
|
|
46
44
|
const resolved = [];
|
|
47
45
|
for (const loop of instance.loops) {
|
|
@@ -59,7 +57,9 @@ export const resolveTriggerLoops = Effect.fn("TriggerRouting.resolveLoops")(func
|
|
|
59
57
|
}
|
|
60
58
|
return resolved;
|
|
61
59
|
});
|
|
62
|
-
/**
|
|
60
|
+
/** Returns the Loop's `max_cycles`, or `None` for a schedule Loop, whose Runs no budget counts. */
|
|
61
|
+
export const cycleLimitOf = (loop) => loop.trigger.on === "schedule" ? Option.none() : Option.some(loop.maxCycles);
|
|
62
|
+
/** Builds the Submission that every trigger stream sends to the engine. */
|
|
63
63
|
export const triggerSubmission = (options) => new Submission({
|
|
64
64
|
event: new Event({
|
|
65
65
|
id: EventId.make(options.dedupKey),
|
|
@@ -72,21 +72,26 @@ export const triggerSubmission = (options) => new Submission({
|
|
|
72
72
|
loop: options.loop.name,
|
|
73
73
|
step: options.loop.step,
|
|
74
74
|
approval: options.loop.approval,
|
|
75
|
-
|
|
75
|
+
permissions: options.loop.permissions,
|
|
76
|
+
cycleLimit: cycleLimitOf(options.loop),
|
|
76
77
|
repository: options.repository.name,
|
|
77
78
|
revision: options.revision,
|
|
78
79
|
task: options.task,
|
|
79
80
|
agent: options.agent,
|
|
80
81
|
parentModel: options.parentModel,
|
|
81
82
|
});
|
|
82
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Returns the log fields for a submission outcome: the Run ID for a claim or suppression, the
|
|
85
|
+
* reason for an ignore.
|
|
86
|
+
*/
|
|
83
87
|
export const submissionLogFields = (submission) => Match.valueTags(submission, {
|
|
84
88
|
Claimed: ({ runId }) => ({ runId }),
|
|
85
89
|
Queued: () => ({}),
|
|
90
|
+
Suppressed: ({ runId }) => ({ suppressedBy: runId }),
|
|
86
91
|
Ignored: ({ reason }) => ({ reason }),
|
|
87
92
|
CycleBlocked: ({ ask }) => ({ askId: ask.id, reason: "cycle-budget-exhausted" }),
|
|
88
93
|
});
|
|
89
|
-
/**
|
|
94
|
+
/** Returns the log fields for a config failure during triggering. */
|
|
90
95
|
export const configFileErrorLogFields = (error) => Option.match(error.expression, {
|
|
91
96
|
onNone: () => ({ configFile: error.file, configStage: error.stage }),
|
|
92
97
|
onSome: (expression) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-submission.js","sourceRoot":"","sources":["../src/trigger-submission.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"trigger-submission.js","sourceRoot":"","sources":["../src/trigger-submission.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAmB,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAyB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAiB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAQvE,6DAA6D;AAC7D,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,CAC9D,8CAA8C,CAC/C,CA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E;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAsB,EAAE,EAAE,CACjE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE;IAC7B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACpE,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvB,UAAU,EAAE,KAAK,CAAC,IAAI;QACtB,WAAW,EAAE,KAAK,CAAC,KAAK;QACxB,UAAU;KACX,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UsineConfig } from "@usine/config/factory";
|
|
2
|
+
import type { BrainSpec } from "@usine/core/agent/brain";
|
|
3
|
+
import type { InstanceDirectory } from "@usine/core/instance";
|
|
4
|
+
import { Layer } from "effect";
|
|
5
|
+
/**
|
|
6
|
+
* Provides the engine for the Workers in `config`: the SSH executor if every Worker is `ssh`,
|
|
7
|
+
* otherwise the local one. Fails at startup with `UnsupportedWorkerError` on any other mix.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workerEngineLayer: (instanceDirectory: InstanceDirectory, config: UsineConfig, brains: ReadonlyArray<BrainSpec>) => Layer.Layer<import("@usine/engine/board-moves").BoardMoves | import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | import("@usine/engine/loop-control").LoopControl | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader | import("@usine/engine/step-executor").StepExecutor | import("./worker-status.ts").WorkerStatus, import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("@usine/engine/engine").RunRetryBlockedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/durable/attempt-runtime").AttemptRuntime | import("@usine/agents/runtime").ClaudeLoginLock | import("@usine/executor").CredentialProvider | import("./current-instance/current-instance.ts").CurrentInstance | import("@usine/github/github-app").GitHubApp | import("@usine/engine/trigger-condition").TriggerCondition>;
|
|
10
|
+
//# sourceMappingURL=worker-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-engine.d.ts","sourceRoot":"","sources":["../src/worker-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;AAI/C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,sBACT,iBAAiB,UAC5B,WAAW,UACX,aAAa,CAAC,SAAS,CAAC,kiDAoB/B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Effect, Layer, Option } from "effect";
|
|
2
|
+
import { layer as localLayer } from "./local.js";
|
|
3
|
+
import { layer as sshLayer, sshWorkerAddressesOf, sshWorkersOf } from "./ssh.js";
|
|
4
|
+
/**
|
|
5
|
+
* Provides the engine for the Workers in `config`: the SSH executor if every Worker is `ssh`,
|
|
6
|
+
* otherwise the local one. Fails at startup with `UnsupportedWorkerError` on any other mix.
|
|
7
|
+
*/
|
|
8
|
+
export const workerEngineLayer = (instanceDirectory, config, brains) => Layer.unwrap(Effect.gen(function* () {
|
|
9
|
+
const ssh = sshWorkersOf(config);
|
|
10
|
+
const workers = config.workers.map(({ name }) => name).join(",");
|
|
11
|
+
if (ssh.length === config.workers.length) {
|
|
12
|
+
const addresses = yield* sshWorkerAddressesOf(config);
|
|
13
|
+
yield* Effect.logInfo("Running Attempts on SSH Workers", {
|
|
14
|
+
workers,
|
|
15
|
+
behindGateway: addresses
|
|
16
|
+
.filter(({ gateway }) => Option.isSome(gateway))
|
|
17
|
+
.map(({ name }) => name)
|
|
18
|
+
.join(","),
|
|
19
|
+
});
|
|
20
|
+
return sshLayer(instanceDirectory, config, brains, { workers: addresses });
|
|
21
|
+
}
|
|
22
|
+
yield* Effect.logInfo("Running Attempts with the local executor", { workers });
|
|
23
|
+
return localLayer(instanceDirectory, config, brains, {});
|
|
24
|
+
}));
|
|
25
|
+
//# sourceMappingURL=worker-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-engine.js","sourceRoot":"","sources":["../src/worker-engine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEjF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,iBAAoC,EACpC,MAAmB,EACnB,MAAgC,EAChC,EAAE,CACF,KAAK,CAAC,MAAM,CACV,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACtD,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iCAAiC,EAAE;YACvD,OAAO;YACP,aAAa,EAAE,SAAS;iBACrB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;iBAC/C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,GAAG,CAAC;SACb,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,0CAA0C,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,OAAO,UAAU,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { BrainSpec, Harness } from "@usine/core/agent/brain";
|
|
2
|
+
import type { WorkerName } from "@usine/core/worker";
|
|
3
|
+
import type { ExecutorError, WorkerCapability } from "@usine/executor";
|
|
4
|
+
import { Context, type DateTime, Effect, Layer, Option } from "effect";
|
|
5
|
+
/** A Worker's current slot usage in the scheduler. */
|
|
6
|
+
export interface WorkerSlots {
|
|
7
|
+
readonly worker: WorkerName;
|
|
8
|
+
/** The maximum concurrent Attempts, or zero after a reload removed the Worker. */
|
|
9
|
+
readonly capacity: number;
|
|
10
|
+
/** The number of Attempts with a slot, which can exceed `capacity` after a reload lowered it. */
|
|
11
|
+
readonly leased: number;
|
|
12
|
+
}
|
|
13
|
+
/** A passed preflight check. */
|
|
14
|
+
export interface PreflightPassed {
|
|
15
|
+
readonly _tag: "Passed";
|
|
16
|
+
readonly checkedAt: DateTime.Utc;
|
|
17
|
+
}
|
|
18
|
+
/** A preflight check that found a missing prerequisite or couldn't run. */
|
|
19
|
+
export interface PreflightFailed {
|
|
20
|
+
readonly _tag: "Failed";
|
|
21
|
+
readonly checkedAt: DateTime.Utc;
|
|
22
|
+
/** The missing prerequisite, or `None` if the check itself failed, such as a timed-out probe. */
|
|
23
|
+
readonly capability: Option.Option<WorkerCapability>;
|
|
24
|
+
/** The executor's summary for operators. */
|
|
25
|
+
readonly message: string;
|
|
26
|
+
}
|
|
27
|
+
/** The last outcome of one preflight check and when it ended. */
|
|
28
|
+
export type PreflightCheck = PreflightPassed | PreflightFailed;
|
|
29
|
+
/** The last preflight of one harness on a Worker. */
|
|
30
|
+
export interface HarnessPreflight {
|
|
31
|
+
readonly harness: Harness;
|
|
32
|
+
readonly check: PreflightCheck;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The last preflight of a Worker: its own prerequisites (machine, Git, memory, Gateway, and
|
|
36
|
+
* credentials) and each checked harness.
|
|
37
|
+
*/
|
|
38
|
+
export interface WorkerPreflight {
|
|
39
|
+
readonly worker: WorkerName;
|
|
40
|
+
/** `None` until a preflight checked the Worker's own prerequisites. */
|
|
41
|
+
readonly prerequisites: Option.Option<PreflightCheck>;
|
|
42
|
+
/** In harness name order. */
|
|
43
|
+
readonly harnesses: ReadonlyArray<HarnessPreflight>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns `previous` updated with one preflight of `brains`. An unavailable harness fails that
|
|
47
|
+
* harness and passes the ones checked before it; any other `failure` fails only the prerequisites.
|
|
48
|
+
*/
|
|
49
|
+
export declare const recordPreflight: (previous: WorkerPreflight, brains: ReadonlyArray<BrainSpec>, checkedAt: DateTime.Utc, failure: Option.Option<ExecutorError>) => WorkerPreflight;
|
|
50
|
+
/** Returns the preflight record of a Worker that no preflight has checked. */
|
|
51
|
+
export declare const unchecked: (worker: WorkerName) => WorkerPreflight;
|
|
52
|
+
declare const WorkerStatus_base: Context.ServiceClass<WorkerStatus, "@usine/orchestrator/WorkerStatus", {
|
|
53
|
+
/**
|
|
54
|
+
* The slots of each Worker in `usine.yaml` order, then of each removed Worker until its last
|
|
55
|
+
* Attempt ends.
|
|
56
|
+
*/
|
|
57
|
+
readonly slots: Effect.Effect<ReadonlyArray<WorkerSlots>>;
|
|
58
|
+
/**
|
|
59
|
+
* The last preflight of each Worker checked since startup, including a refused reload's
|
|
60
|
+
* preflight.
|
|
61
|
+
*/
|
|
62
|
+
readonly preflights: Effect.Effect<ReadonlyArray<WorkerPreflight>>;
|
|
63
|
+
}>;
|
|
64
|
+
/** The scheduler's current slot usage and last preflight of each Worker. */
|
|
65
|
+
export declare class WorkerStatus extends WorkerStatus_base {
|
|
66
|
+
/** A status with no Workers and no preflights, as in setup mode. */
|
|
67
|
+
static readonly idle: Layer.Layer<WorkerStatus, never, never>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=worker-status.d.ts.map
|
|
@@ -0,0 +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;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAgB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAEpG,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,kFAAkF;I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G,eAI7C,CAAC;;IAMC;;;OAGG;oBACa,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACzD;;;OAGG;yBACkB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;;AAbtE,4EAA4E;AAC5E,qBAAa,YAAa,SAAQ,iBAcK;IACrC,oEAAoE;IACpE,MAAM,CAAC,QAAQ,CAAC,IAAI,0CAGjB;CACJ"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
+
import { Array as Arr, Context, Effect, Layer, Option, Order, Schema } from "effect";
|
|
3
|
+
const isHarnessUnavailable = Schema.is(HarnessUnavailableError);
|
|
4
|
+
const byHarness = Order.mapInput(Order.String, ({ harness }) => harness);
|
|
5
|
+
const withHarnesses = (harnesses, checked, check) => Arr.sort([
|
|
6
|
+
...harnesses.filter(({ harness }) => !checked.includes(harness)),
|
|
7
|
+
...checked.map((harness) => ({ harness, check })),
|
|
8
|
+
], byHarness);
|
|
9
|
+
/**
|
|
10
|
+
* Returns `previous` updated with one preflight of `brains`. An unavailable harness fails that
|
|
11
|
+
* harness and passes the ones checked before it; any other `failure` fails only the prerequisites.
|
|
12
|
+
*/
|
|
13
|
+
export const recordPreflight = (previous, brains, checkedAt, failure) => {
|
|
14
|
+
const harnesses = Arr.dedupe(brains.map(({ harness }) => harness));
|
|
15
|
+
if (Option.isNone(failure)) {
|
|
16
|
+
const passed = { _tag: "Passed", checkedAt };
|
|
17
|
+
return {
|
|
18
|
+
worker: previous.worker,
|
|
19
|
+
prerequisites: Option.some(passed),
|
|
20
|
+
harnesses: withHarnesses(previous.harnesses, harnesses, passed),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const error = failure.value;
|
|
24
|
+
const capability = error._tag === "WorkerCapabilityError" ? Option.some(error.capability) : Option.none();
|
|
25
|
+
const failed = { _tag: "Failed", checkedAt, capability, message: error.message };
|
|
26
|
+
if (error._tag === "WorkerCapabilityError" && isHarnessUnavailable(error.cause)) {
|
|
27
|
+
const unavailable = error.cause.harness;
|
|
28
|
+
const before = Arr.dedupe(Arr.takeWhile(brains, ({ harness }) => harness !== unavailable).map(({ harness }) => harness));
|
|
29
|
+
return {
|
|
30
|
+
worker: previous.worker,
|
|
31
|
+
prerequisites: previous.prerequisites,
|
|
32
|
+
harnesses: withHarnesses(withHarnesses(previous.harnesses, before, { _tag: "Passed", checkedAt }), [unavailable], failed),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
worker: previous.worker,
|
|
37
|
+
prerequisites: Option.some(failed),
|
|
38
|
+
harnesses: previous.harnesses,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/** Returns the preflight record of a Worker that no preflight has checked. */
|
|
42
|
+
export const unchecked = (worker) => ({
|
|
43
|
+
worker,
|
|
44
|
+
prerequisites: Option.none(),
|
|
45
|
+
harnesses: [],
|
|
46
|
+
});
|
|
47
|
+
/** The scheduler's current slot usage and last preflight of each Worker. */
|
|
48
|
+
export class WorkerStatus extends Context.Service()("@usine/orchestrator/WorkerStatus") {
|
|
49
|
+
/** A status with no Workers and no preflights, as in setup mode. */
|
|
50
|
+
static idle = Layer.succeed(WorkerStatus)({
|
|
51
|
+
slots: Effect.succeed([]),
|
|
52
|
+
preflights: Effect.succeed([]),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=worker-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-status.js","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,OAAO,EAAiB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgDpG,MAAM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,EAAE,MAAM,CAAC,IAAI,EAAE;IAC5B,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAc9C,CAAC,kCAAkC,CAAC;IACrC,oEAAoE;IACpE,MAAM,CAAU,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjD,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;KAC/B,CAAC,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/orchestrator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The embeddable usine composition: the full engine as an Effect layer, startable in-process.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"directory": "packages/orchestrator"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
@@ -22,6 +23,10 @@
|
|
|
22
23
|
"types": "./dist/credentials.d.ts",
|
|
23
24
|
"default": "./dist/credentials.js"
|
|
24
25
|
},
|
|
26
|
+
"./current-instance": {
|
|
27
|
+
"types": "./dist/current-instance/current-instance.d.ts",
|
|
28
|
+
"default": "./dist/current-instance/current-instance.js"
|
|
29
|
+
},
|
|
25
30
|
"./exe-dev": {
|
|
26
31
|
"types": "./dist/exe-dev.d.ts",
|
|
27
32
|
"default": "./dist/exe-dev.js"
|
|
@@ -46,6 +51,10 @@
|
|
|
46
51
|
"types": "./dist/polling-triggers.d.ts",
|
|
47
52
|
"default": "./dist/polling-triggers.js"
|
|
48
53
|
},
|
|
54
|
+
"./runtime": {
|
|
55
|
+
"types": "./dist/runtime.d.ts",
|
|
56
|
+
"default": "./dist/runtime.js"
|
|
57
|
+
},
|
|
49
58
|
"./schedule-triggers": {
|
|
50
59
|
"types": "./dist/schedule-triggers.d.ts",
|
|
51
60
|
"default": "./dist/schedule-triggers.js"
|
|
@@ -54,6 +63,14 @@
|
|
|
54
63
|
"types": "./dist/scheduler.d.ts",
|
|
55
64
|
"default": "./dist/scheduler.js"
|
|
56
65
|
},
|
|
66
|
+
"./ssh": {
|
|
67
|
+
"types": "./dist/ssh.d.ts",
|
|
68
|
+
"default": "./dist/ssh.js"
|
|
69
|
+
},
|
|
70
|
+
"./worker-status": {
|
|
71
|
+
"types": "./dist/worker-status.d.ts",
|
|
72
|
+
"default": "./dist/worker-status.js"
|
|
73
|
+
},
|
|
57
74
|
"./operator": {
|
|
58
75
|
"types": "./dist/operator/operator.d.ts",
|
|
59
76
|
"default": "./dist/operator/operator.js"
|
|
@@ -68,19 +85,22 @@
|
|
|
68
85
|
},
|
|
69
86
|
"dependencies": {
|
|
70
87
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
71
|
-
"@
|
|
72
|
-
"@usine/
|
|
73
|
-
"@usine/
|
|
74
|
-
"@usine/
|
|
75
|
-
"@usine/
|
|
76
|
-
"@usine/
|
|
77
|
-
"@usine/
|
|
88
|
+
"@effect/platform-node-shared": "4.0.0-rc.111",
|
|
89
|
+
"@usine/config": "0.3.0",
|
|
90
|
+
"@usine/executor": "0.3.0",
|
|
91
|
+
"@usine/expression": "0.3.0",
|
|
92
|
+
"@usine/github": "0.2.0",
|
|
93
|
+
"@usine/engine": "0.4.0",
|
|
94
|
+
"@usine/durable": "0.1.0",
|
|
95
|
+
"@usine/core": "0.4.0"
|
|
78
96
|
},
|
|
79
97
|
"devDependencies": {
|
|
80
98
|
"@effect/vitest": "4.0.0-rc.111",
|
|
81
99
|
"effect": "4.0.0-rc.111",
|
|
82
100
|
"typescript": "7.0.2",
|
|
83
101
|
"vitest": "4.1.11",
|
|
102
|
+
"@usine/agents": "0.4.0",
|
|
103
|
+
"@usine/gateway": "0.1.0",
|
|
84
104
|
"@usine/tsconfig": "0.0.0"
|
|
85
105
|
},
|
|
86
106
|
"peerDependencies": {
|
|
@@ -95,6 +115,7 @@
|
|
|
95
115
|
"test": "vitest run --exclude 'test/integration/**'",
|
|
96
116
|
"test:integration": "vitest run test/integration/polling-triggers.test.ts",
|
|
97
117
|
"test:integration:agent": "vitest run test/integration/agent-run.test.ts",
|
|
98
|
-
"test:exe-dev": "vitest run test/integration/exe-dev-worker.test.ts"
|
|
118
|
+
"test:exe-dev": "vitest run test/integration/exe-dev-worker.test.ts",
|
|
119
|
+
"test:ssh": "vitest run --disable-console-intercept test/integration/ssh-worker.test.ts"
|
|
99
120
|
}
|
|
100
121
|
}
|