@usine/executor 0.0.1 → 0.2.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 +85 -2
- package/dist/child-command.d.ts +21 -0
- package/dist/child-command.d.ts.map +1 -0
- package/dist/child-command.js +50 -0
- package/dist/child-command.js.map +1 -0
- package/dist/exe-dev/channel.d.ts +11 -0
- package/dist/exe-dev/channel.d.ts.map +1 -0
- package/dist/exe-dev/channel.js +41 -0
- package/dist/exe-dev/channel.js.map +1 -0
- package/dist/exe-dev/commands.d.ts +22 -0
- package/dist/exe-dev/commands.d.ts.map +1 -0
- package/dist/exe-dev/commands.js +66 -0
- package/dist/exe-dev/commands.js.map +1 -0
- package/dist/exe-dev/exe-dev.d.ts +8 -0
- package/dist/exe-dev/exe-dev.d.ts.map +1 -0
- package/dist/exe-dev/exe-dev.js +153 -0
- package/dist/exe-dev/exe-dev.js.map +1 -0
- package/dist/exe-dev/grants.d.ts +8 -0
- package/dist/exe-dev/grants.d.ts.map +1 -0
- package/dist/exe-dev/grants.js +104 -0
- package/dist/exe-dev/grants.js.map +1 -0
- package/dist/exe-dev/model.d.ts +43 -0
- package/dist/exe-dev/model.d.ts.map +1 -0
- package/dist/exe-dev/model.js +26 -0
- package/dist/exe-dev/model.js.map +1 -0
- package/dist/exe-dev/preflight.d.ts +10 -0
- package/dist/exe-dev/preflight.d.ts.map +1 -0
- package/dist/exe-dev/preflight.js +82 -0
- package/dist/exe-dev/preflight.js.map +1 -0
- package/dist/exe-dev/shell.d.ts +12 -0
- package/dist/exe-dev/shell.d.ts.map +1 -0
- package/dist/exe-dev/shell.js +31 -0
- package/dist/exe-dev/shell.js.map +1 -0
- package/dist/exe-dev/sweep.d.ts +10 -0
- package/dist/exe-dev/sweep.d.ts.map +1 -0
- package/dist/exe-dev/sweep.js +117 -0
- package/dist/exe-dev/sweep.js.map +1 -0
- package/dist/executor.d.ts +118 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +98 -0
- package/dist/executor.js.map +1 -0
- package/dist/harness-preflight.d.ts +6 -0
- package/dist/harness-preflight.d.ts.map +1 -0
- package/dist/harness-preflight.js +50 -0
- package/dist/harness-preflight.js.map +1 -0
- package/dist/invalid-frame.d.ts +17 -0
- package/dist/invalid-frame.d.ts.map +1 -0
- package/dist/invalid-frame.js +111 -0
- package/dist/invalid-frame.js.map +1 -0
- package/dist/keyed-lock.d.ts +11 -0
- package/dist/keyed-lock.d.ts.map +1 -0
- package/dist/keyed-lock.js +21 -0
- package/dist/keyed-lock.js.map +1 -0
- package/dist/local/local.d.ts +20 -0
- package/dist/local/local.d.ts.map +1 -0
- package/dist/local/local.js +273 -0
- package/dist/local/local.js.map +1 -0
- package/dist/prepared-attempt.d.ts +5 -0
- package/dist/prepared-attempt.d.ts.map +1 -0
- package/dist/prepared-attempt.js +40 -0
- package/dist/prepared-attempt.js.map +1 -0
- package/dist/provision.d.ts +43 -0
- package/dist/provision.d.ts.map +1 -0
- package/dist/provision.js +147 -0
- package/dist/provision.js.map +1 -0
- package/dist/run-host-session.d.ts +26 -0
- package/dist/run-host-session.d.ts.map +1 -0
- package/dist/run-host-session.js +241 -0
- package/dist/run-host-session.js.map +1 -0
- package/package.json +21 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
+
import { RepositoryName } from "@usine/core/repository";
|
|
3
|
+
import { InstanceDirectory } from "@usine/core/instance";
|
|
4
|
+
import { Effect, FileSystem, Layer, Path, Redacted, Result, Schema, Stream, } from "effect";
|
|
5
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
6
|
+
import { allowlistedEnvironment, collectCommand, requireSuccess } from "../child-command.js";
|
|
7
|
+
import { CheckoutRequest, CredentialProvider, Executor, ExecutorError, ExecutorOperationError, logPreflightFailure, WorkerCapabilityError, } from "../executor.js";
|
|
8
|
+
import { verifyHarnesses } from "../harness-preflight.js";
|
|
9
|
+
import { prepareAttempt } from "../prepared-attempt.js";
|
|
10
|
+
import { keyedLockFor } from "../keyed-lock.js";
|
|
11
|
+
import { cacheDirectoryName, isCacheDirectoryName, provisionWorktree, safeSegment, } from "../provision.js";
|
|
12
|
+
import { runHostSessionFor } from "../run-host-session.js";
|
|
13
|
+
const isExecutorError = Schema.is(ExecutorError);
|
|
14
|
+
/**
|
|
15
|
+
* The run host inherits only these variables. The App private key and every
|
|
16
|
+
* other orchestrator secret stay out; the single-repo worker token is the only
|
|
17
|
+
* credential it receives (ADR 0011).
|
|
18
|
+
*/
|
|
19
|
+
const HOST_ENVIRONMENT_ALLOWLIST = [
|
|
20
|
+
"HOME",
|
|
21
|
+
"LANG",
|
|
22
|
+
"LC_ALL",
|
|
23
|
+
"PATH",
|
|
24
|
+
"SHELL",
|
|
25
|
+
"TMPDIR",
|
|
26
|
+
"USER",
|
|
27
|
+
];
|
|
28
|
+
const executorError = (operation, message, cause) => new ExecutorOperationError({ operation, message, cause });
|
|
29
|
+
/** Removes the credential from text before it can reach a persisted error message. */
|
|
30
|
+
const scrubbed = (text, credential) => text.replaceAll(Redacted.value(credential), "[REDACTED]");
|
|
31
|
+
const credentialEnvironment = (base, credential) => {
|
|
32
|
+
const token = Redacted.value(credential);
|
|
33
|
+
return {
|
|
34
|
+
...base,
|
|
35
|
+
GH_TOKEN: token,
|
|
36
|
+
GITHUB_TOKEN: token,
|
|
37
|
+
GIT_CONFIG_COUNT: "1",
|
|
38
|
+
GIT_CONFIG_KEY_0: "credential.helper",
|
|
39
|
+
GIT_CONFIG_VALUE_0: "!f() { echo username=x-access-token; echo password=$GITHUB_TOKEN; }; f",
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const makeLocalExecutor = (options) => Effect.gen(function* () {
|
|
43
|
+
const credentials = yield* CredentialProvider;
|
|
44
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
47
|
+
const fetches = yield* keyedLockFor();
|
|
48
|
+
const baseEnvironment = yield* allowlistedEnvironment(HOST_ENVIRONMENT_ALLOWLIST);
|
|
49
|
+
const repositoryUrl = options.repositoryUrl ??
|
|
50
|
+
((repository) => `https://github.com/${repository}.git`);
|
|
51
|
+
const runHost = options.runHost;
|
|
52
|
+
const interruptGrace = options.interruptGrace ?? "2 seconds";
|
|
53
|
+
const workersRoot = path.join(options.instanceDirectory, ".usine", "workers");
|
|
54
|
+
const executeCommand = Effect.fn("LocalExecutor.executeCommand")(function* (operation, command, args, commandOptions = {}) {
|
|
55
|
+
yield* Effect.annotateCurrentSpan({ host: "local", operation });
|
|
56
|
+
const result = yield* collectCommand(spawner, operation, command, args, {
|
|
57
|
+
env: baseEnvironment,
|
|
58
|
+
extendEnv: false,
|
|
59
|
+
...commandOptions,
|
|
60
|
+
});
|
|
61
|
+
return yield* requireSuccess(operation, "local", command, args, result);
|
|
62
|
+
});
|
|
63
|
+
const run = Effect.fn("LocalExecutor.run")(function* (operation, command, args, commandOptions = {}) {
|
|
64
|
+
yield* executeCommand(operation, command, args, commandOptions);
|
|
65
|
+
});
|
|
66
|
+
// Worktrees never outlive their Attempt (ADR 0006). A crashed orchestrator
|
|
67
|
+
// leaves directories and bare-cache registrations behind; the sweep reclaims
|
|
68
|
+
// them at the next layer build, before new Attempts start.
|
|
69
|
+
const sweepAbandonedWorktrees = Effect.fn("LocalExecutor.sweepAbandonedWorktrees")(function* () {
|
|
70
|
+
if (!(yield* fileSystem.exists(workersRoot)))
|
|
71
|
+
return;
|
|
72
|
+
const workers = yield* fileSystem.readDirectory(workersRoot);
|
|
73
|
+
for (const worker of workers) {
|
|
74
|
+
const attemptsRoot = path.join(workersRoot, worker, "attempts");
|
|
75
|
+
if (yield* fileSystem.exists(attemptsRoot)) {
|
|
76
|
+
const leftovers = yield* fileSystem.readDirectory(attemptsRoot);
|
|
77
|
+
for (const leftover of leftovers) {
|
|
78
|
+
const target = path.join(attemptsRoot, leftover);
|
|
79
|
+
yield* Effect.logInfo("Sweeping abandoned Attempt worktree", {
|
|
80
|
+
worker,
|
|
81
|
+
host: "local",
|
|
82
|
+
worktree: target,
|
|
83
|
+
});
|
|
84
|
+
yield* fileSystem.remove(target, { recursive: true, force: true });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const reposRoot = path.join(workersRoot, worker, "repos");
|
|
88
|
+
if (yield* fileSystem.exists(reposRoot)) {
|
|
89
|
+
const entries = yield* fileSystem.readDirectory(reposRoot);
|
|
90
|
+
let pruned = 0;
|
|
91
|
+
let skipped = 0;
|
|
92
|
+
let failed = 0;
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (!isCacheDirectoryName(entry)) {
|
|
95
|
+
yield* Effect.logDebug("Skipping a non-cache entry during the local cache sweep", {
|
|
96
|
+
worker,
|
|
97
|
+
host: "local",
|
|
98
|
+
entry,
|
|
99
|
+
});
|
|
100
|
+
skipped += 1;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const result = yield* run("cleanup", "git", [
|
|
104
|
+
"--git-dir",
|
|
105
|
+
path.join(reposRoot, entry),
|
|
106
|
+
"worktree",
|
|
107
|
+
"prune",
|
|
108
|
+
]).pipe(Effect.tapError((error) => Effect.logWarning("Could not prune a bare cache during the sweep", {
|
|
109
|
+
worker,
|
|
110
|
+
host: "local",
|
|
111
|
+
cache: entry,
|
|
112
|
+
message: error.message,
|
|
113
|
+
})), Effect.result);
|
|
114
|
+
if (Result.isSuccess(result)) {
|
|
115
|
+
pruned += 1;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
failed += 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
yield* Effect.logInfo("Local cache sweep completed", {
|
|
122
|
+
worker,
|
|
123
|
+
host: "local",
|
|
124
|
+
pruned,
|
|
125
|
+
skipped,
|
|
126
|
+
failed,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
yield* sweepAbandonedWorktrees().pipe(Effect.tapError((error) => Effect.logWarning("Abandoned-worktree sweep failed; continuing", {
|
|
132
|
+
message: String(error),
|
|
133
|
+
})), Effect.ignore);
|
|
134
|
+
const preflight = Effect.fn("LocalExecutor.preflight")(function* (worker, brains) {
|
|
135
|
+
yield* Effect.annotateCurrentSpan({ worker, host: "local" });
|
|
136
|
+
const gitVersion = (yield* executeCommand("preflight", "git", ["--version"])).trim();
|
|
137
|
+
if (!gitVersion.startsWith("git version ")) {
|
|
138
|
+
return yield* new WorkerCapabilityError({
|
|
139
|
+
worker,
|
|
140
|
+
capability: "toolchain",
|
|
141
|
+
message: `Worker ${worker} returned an unrecognized git version`,
|
|
142
|
+
cause: new Error(gitVersion),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const reported = (yield* executeCommand("preflight", runHost.command, [
|
|
146
|
+
...runHost.args,
|
|
147
|
+
"--protocol-version",
|
|
148
|
+
])).trim();
|
|
149
|
+
if (reported !== String(AttemptChannel.PROTOCOL_VERSION)) {
|
|
150
|
+
return yield* new WorkerCapabilityError({
|
|
151
|
+
worker,
|
|
152
|
+
capability: "run-host",
|
|
153
|
+
message: `Worker ${worker} has run-host protocol ${reported || "unknown"}; expected ${AttemptChannel.PROTOCOL_VERSION}`,
|
|
154
|
+
cause: new Error("run-host protocol mismatch"),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
yield* verifyHarnesses(worker, brains, runHost, (command, args) => executeCommand("preflight", command, args));
|
|
158
|
+
yield* Effect.logInfo("Worker preflight verified", {
|
|
159
|
+
worker,
|
|
160
|
+
host: "local",
|
|
161
|
+
gitVersion,
|
|
162
|
+
protocolVersion: AttemptChannel.PROTOCOL_VERSION,
|
|
163
|
+
});
|
|
164
|
+
}, logPreflightFailure);
|
|
165
|
+
const prepare = Effect.fn("LocalExecutor.prepare")(function* (request) {
|
|
166
|
+
yield* Effect.annotateCurrentSpan({
|
|
167
|
+
attemptId: request.attemptId,
|
|
168
|
+
worker: request.worker,
|
|
169
|
+
host: "local",
|
|
170
|
+
repository: request.repository,
|
|
171
|
+
});
|
|
172
|
+
yield* verifyHarnesses(request.worker, [request.agent.brain], runHost, (command, args) => executeCommand("preflight", command, args));
|
|
173
|
+
const credential = yield* Effect.acquireRelease(credentials.issue(request.repository, request.attemptId), (token) => Effect.sync(() => {
|
|
174
|
+
Redacted.wipeUnsafe(token);
|
|
175
|
+
}), { interruptible: true });
|
|
176
|
+
const workerRoot = path.join(workersRoot, request.worker);
|
|
177
|
+
const cache = path.join(workerRoot, "repos", cacheDirectoryName(request.repository));
|
|
178
|
+
const worktree = path.join(workerRoot, "attempts", safeSegment(request.attemptId));
|
|
179
|
+
const environment = credentialEnvironment(baseEnvironment, credential);
|
|
180
|
+
const commandOptions = { env: environment, extendEnv: false };
|
|
181
|
+
yield* Effect.logInfo("Preparing Attempt workspace", {
|
|
182
|
+
attemptId: request.attemptId,
|
|
183
|
+
worker: request.worker,
|
|
184
|
+
repository: request.repository,
|
|
185
|
+
revision: request.revision,
|
|
186
|
+
cache,
|
|
187
|
+
worktree,
|
|
188
|
+
});
|
|
189
|
+
const remove = (_operation, target) => fileSystem.remove(target, { recursive: true, force: true });
|
|
190
|
+
const ops = {
|
|
191
|
+
ensureRoots: Effect.andThen(fileSystem.makeDirectory(path.dirname(cache), { recursive: true }), fileSystem.makeDirectory(path.dirname(worktree), { recursive: true })),
|
|
192
|
+
removePath: remove,
|
|
193
|
+
cacheExists: fileSystem.exists(cache),
|
|
194
|
+
promoteStaging: fileSystem.rename(`${cache}.cloning`, cache),
|
|
195
|
+
git: (operation, args) => Effect.gen(function* () {
|
|
196
|
+
// Git can echo the ambient token in diagnostics. Scrub before forming
|
|
197
|
+
// an error or passing its stdout to the revision parser.
|
|
198
|
+
const result = yield* collectCommand(spawner, operation, "git", args, commandOptions);
|
|
199
|
+
return yield* requireSuccess(operation, "local", "git", args, {
|
|
200
|
+
...result,
|
|
201
|
+
stdout: scrubbed(result.stdout, credential),
|
|
202
|
+
stderr: scrubbed(result.stderr, credential),
|
|
203
|
+
});
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
206
|
+
const prepared = yield* fetches
|
|
207
|
+
.withLock(request.repository)(provisionWorktree({
|
|
208
|
+
request,
|
|
209
|
+
url: repositoryUrl(request.repository),
|
|
210
|
+
host: "local",
|
|
211
|
+
layout: { cache, staging: `${cache}.cloning`, worktree },
|
|
212
|
+
ops,
|
|
213
|
+
}))
|
|
214
|
+
.pipe(Effect.mapError((error) => isExecutorError(error)
|
|
215
|
+
? error
|
|
216
|
+
: executorError("prepare", "Attempt workspace preparation failed", error)));
|
|
217
|
+
yield* Effect.logInfo("Attempt workspace ready", {
|
|
218
|
+
attemptId: request.attemptId,
|
|
219
|
+
baseCommit: prepared.spec.baseCommit,
|
|
220
|
+
worktree,
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
workspace: prepared,
|
|
224
|
+
launch: (io) => session.launch(prepared, io, (input) => spawn(prepared, credential, input)),
|
|
225
|
+
};
|
|
226
|
+
}, prepareAttempt);
|
|
227
|
+
const spawn = Effect.fn("LocalExecutor.spawnRunHost")(function* (prepared, credential, input) {
|
|
228
|
+
const attemptId = prepared.spec.attemptId;
|
|
229
|
+
yield* Effect.annotateCurrentSpan({
|
|
230
|
+
attemptId,
|
|
231
|
+
worker: prepared.worker,
|
|
232
|
+
host: "local",
|
|
233
|
+
});
|
|
234
|
+
// A linked worktree's git common dir is the bare cache itself, and Turbo
|
|
235
|
+
// puts its cache next to the common dir, so an unscoped run from the
|
|
236
|
+
// worktree would write `repos/.turbo` beside the bare caches. The Worker
|
|
237
|
+
// cache is shared across that Worker's Attempts and stays out of the
|
|
238
|
+
// directory the startup sweep treats as cache storage.
|
|
239
|
+
const turboCache = path.join(workersRoot, prepared.worker, "turbo");
|
|
240
|
+
yield* Effect.logInfo("Launching the run host", {
|
|
241
|
+
attemptId,
|
|
242
|
+
worker: prepared.worker,
|
|
243
|
+
host: "local",
|
|
244
|
+
command: runHost.command,
|
|
245
|
+
worktree: prepared.worktree,
|
|
246
|
+
turboCache,
|
|
247
|
+
});
|
|
248
|
+
const handle = yield* spawner.spawn(ChildProcess.make(runHost.command, runHost.args, {
|
|
249
|
+
cwd: prepared.worktree,
|
|
250
|
+
env: {
|
|
251
|
+
...credentialEnvironment(baseEnvironment, credential),
|
|
252
|
+
TURBO_CACHE_DIR: turboCache,
|
|
253
|
+
},
|
|
254
|
+
extendEnv: false,
|
|
255
|
+
stdin: { stream: Stream.fromQueue(input), endOnDone: true },
|
|
256
|
+
}));
|
|
257
|
+
return {
|
|
258
|
+
handle,
|
|
259
|
+
host: "local",
|
|
260
|
+
scrub: (text) => scrubbed(text, credential),
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
const session = yield* runHostSessionFor({ interruptGrace });
|
|
264
|
+
return Executor.of({
|
|
265
|
+
kind: "local",
|
|
266
|
+
cancel: session.cancel,
|
|
267
|
+
preflight,
|
|
268
|
+
prepare,
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
/** Runs Attempts in isolated checkouts on the local machine. Requires Node; worker contracts are platform-free. */
|
|
272
|
+
export const layer = (options) => Layer.effect(Executor, makeLocalExecutor(options));
|
|
273
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/local/local.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,IAAI,EAEJ,QAAQ,EACR,MAAM,EACN,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AM;YACN,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,CAAC,IAAY,EAAU,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;SAC5D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAE7D,OAAO,QAAQ,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS;QACT,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,mHAAmH;AACnH,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,OAA6B,EAK7B,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect, Scope } from "effect";
|
|
2
|
+
import type { CheckoutRequest, ExecutorError, PreparedAttempt } from "./executor.ts";
|
|
3
|
+
/** Owns partial preparation and the run host in one child scope, released at the Attempt's end. */
|
|
4
|
+
export declare const prepareAttempt: (acquire: Effect.Effect<PreparedAttempt, ExecutorError, Scope.Scope>, request: CheckoutRequest) => Effect.Effect<PreparedAttempt, ExecutorError, Scope.Scope>;
|
|
5
|
+
//# sourceMappingURL=prepared-attempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepared-attempt.d.ts","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoB,KAAK,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErF,mGAAmG;AACnG,eAAO,MAAM,cAAc,YAChB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,WAC1D,eAAe,KACvB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,KAAK,CAqDzD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InfraFailure } from "@usine/core/attempt/failure";
|
|
2
|
+
import { Effect, Exit, Fiber, Ref, Scope } from "effect";
|
|
3
|
+
/** Owns partial preparation and the run host in one child scope, released at the Attempt's end. */
|
|
4
|
+
export const prepareAttempt = (acquire, request) => Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
5
|
+
const scope = yield* Scope.fork(yield* Effect.scope);
|
|
6
|
+
// acquireRelease masks acquisition by default in Effect rc.111. Only the
|
|
7
|
+
// ownership transfer is masked here; clone, fetch, and lock waits must stop
|
|
8
|
+
// promptly. Each acquiring implementation registers its own finalizers.
|
|
9
|
+
const prepared = yield* restore(acquire).pipe(Scope.provide(scope), Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))));
|
|
10
|
+
const unavailable = yield* Ref.make(false);
|
|
11
|
+
yield* Scope.addFinalizer(scope, Ref.set(unavailable, true));
|
|
12
|
+
return {
|
|
13
|
+
workspace: prepared.workspace,
|
|
14
|
+
launch: Effect.fn("PreparedAttempt.launch")(function* (io) {
|
|
15
|
+
const attemptId = prepared.workspace.spec.attemptId;
|
|
16
|
+
yield* Effect.annotateCurrentSpan({ attemptId, worker: prepared.workspace.worker });
|
|
17
|
+
if (yield* Ref.getAndSet(unavailable, true)) {
|
|
18
|
+
yield* Effect.logWarning("Attempt was already launched or released", { attemptId });
|
|
19
|
+
return yield* new InfraFailure({
|
|
20
|
+
message: `Attempt ${attemptId} was already launched or released`,
|
|
21
|
+
cause: new Error("prepared Attempt is no longer available"),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// Closing the owner's scope interrupts the session before checkout and
|
|
25
|
+
// credential finalizers. Interrupting a caller waiting on join must also
|
|
26
|
+
// stop that scoped fiber, so timeout/cancel completes the handshake first.
|
|
27
|
+
return yield* Effect.acquireUseRelease(Effect.forkIn(prepared.launch(io).pipe(
|
|
28
|
+
// End the timer with the live session. Checkout/grant finalizers run
|
|
29
|
+
// afterward and cannot turn completed agent work into a retry.
|
|
30
|
+
Effect.timeoutOrElse({
|
|
31
|
+
duration: `${request.maxAttemptMinutes} minutes`,
|
|
32
|
+
orElse: () => Effect.fail(new InfraFailure({
|
|
33
|
+
message: `Attempt exceeded the ${request.maxAttemptMinutes}-minute budget`,
|
|
34
|
+
cause: new Error("attempt timeout"),
|
|
35
|
+
})),
|
|
36
|
+
})), scope), Fiber.join, Fiber.interrupt).pipe(Effect.onExit((exit) => Scope.close(scope, exit)));
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
}));
|
|
40
|
+
//# sourceMappingURL=prepared-attempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepared-attempt.js","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGzD,mGAAmG;AACnG,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAmE,EACnE,OAAwB,EACoC,EAAE,CAC9D,MAAM,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,EAAE,CACrC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrD,yEAAyE;IACzE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAC3C,KAAK,CAAC,O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EAAE,CAAC,CAAC,IAAI;YACtB,qEAAqE;YACrE,+DAA+D;YAC/D,MAAM,CAAC,aAAa,CAAC;gBACnB,QAAQ,EAAE,GAAG,OAAO,CAAC,iBAAiB,UAAU;gBAChD,MAAM,EAAE,GAAG,EAAE,CACX,MAAM,CAAC,IAAI,CACT,IAAI,YAAY,CAAC;oBACf,OAAO,EAAE,wBAAwB,OAAO,CAAC,iBAAiB,gBAAgB;oBAC1E,KAAK,EAAE,IAAI,KAAK,CAAC,iBAAiB,CAAC;iBACpC,CAAC,CACH;aACJ,CAAC,CACH,EACD,KAAK,CACN,EACD,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,SAAS,CAChB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC;KACuB,CAAC;AAC9B,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RepositoryName } from "@usine/core/repository";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { ExecutorOperationError, AttemptWorkspace, type CheckoutRequest } from "./executor.ts";
|
|
4
|
+
export declare const safeSegment: (value: string) => string;
|
|
5
|
+
/** The bare cache directory name for a repository under `repos/`, shared by every adapter. */
|
|
6
|
+
export declare const cacheDirectoryName: (repository: RepositoryName) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a `repos/` entry is one of our bare caches, decided by the name we
|
|
9
|
+
* mint rather than by probing contents: a `HEAD` lookup fails with ENOTDIR on
|
|
10
|
+
* a stray file, and a `.cloning` leftover or a tool's scratch directory must
|
|
11
|
+
* never reach `git worktree prune`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isCacheDirectoryName: (entry: string) => boolean;
|
|
14
|
+
interface WorkspaceLayout {
|
|
15
|
+
readonly cache: string;
|
|
16
|
+
readonly staging: string;
|
|
17
|
+
readonly worktree: string;
|
|
18
|
+
}
|
|
19
|
+
/** The adapter-specific primitives; everything else about provisioning is shared. */
|
|
20
|
+
export interface WorkspaceOps<E> {
|
|
21
|
+
readonly ensureRoots: Effect.Effect<void, E>;
|
|
22
|
+
readonly removePath: (operation: "prepare" | "cleanup", target: string) => Effect.Effect<void, E>;
|
|
23
|
+
readonly cacheExists: Effect.Effect<boolean, E>;
|
|
24
|
+
/** Atomically promote the finished staging clone to the cache path. */
|
|
25
|
+
readonly promoteStaging: Effect.Effect<void, E>;
|
|
26
|
+
readonly git: (operation: "prepare" | "cleanup", args: ReadonlyArray<string>) => Effect.Effect<string, E>;
|
|
27
|
+
}
|
|
28
|
+
export interface ProvisionOptions<E> {
|
|
29
|
+
readonly request: CheckoutRequest;
|
|
30
|
+
readonly url: string;
|
|
31
|
+
readonly host: string;
|
|
32
|
+
readonly layout: WorkspaceLayout;
|
|
33
|
+
readonly ops: WorkspaceOps<E>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The clone-to-worktree sequence every Executor shares: clone into a staging
|
|
37
|
+
* sibling and promote it on success, so an interrupted clone never leaves a
|
|
38
|
+
* half-initialized cache that later fetches would poison; then fetch the
|
|
39
|
+
* requested revision and check out a detached worktree at the resolved commit.
|
|
40
|
+
*/
|
|
41
|
+
export declare const provisionWorktree: <E>(options: ProvisionOptions<E>) => Effect.Effect<AttemptWorkspace, E | ExecutorOperationError, import("effect/Scope").Scope>;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=provision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAEhB,KAAK,eAAe,EACrB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e,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAsD,CAAC,4HAwJnF,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
+
import { RepositoryName, CommitSha } from "@usine/core/repository";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
import { ExecutorOperationError, AttemptWorkspace, WorktreePath, } from "./executor.js";
|
|
5
|
+
export const safeSegment = (value) => value.replaceAll(/[^A-Za-z0-9_.-]/gu, "_");
|
|
6
|
+
const CACHE_DIRECTORY_SUFFIX = ".git";
|
|
7
|
+
/** The bare cache directory name for a repository under `repos/`, shared by every adapter. */
|
|
8
|
+
export const cacheDirectoryName = (repository) => `${safeSegment(repository)}${CACHE_DIRECTORY_SUFFIX}`;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a `repos/` entry is one of our bare caches, decided by the name we
|
|
11
|
+
* mint rather than by probing contents: a `HEAD` lookup fails with ENOTDIR on
|
|
12
|
+
* a stray file, and a `.cloning` leftover or a tool's scratch directory must
|
|
13
|
+
* never reach `git worktree prune`.
|
|
14
|
+
*/
|
|
15
|
+
export const isCacheDirectoryName = (entry) => entry.length > CACHE_DIRECTORY_SUFFIX.length && entry.endsWith(CACHE_DIRECTORY_SUFFIX);
|
|
16
|
+
const decodeCommit = Schema.decodeUnknownEffect(CommitSha);
|
|
17
|
+
/**
|
|
18
|
+
* The clone-to-worktree sequence every Executor shares: clone into a staging
|
|
19
|
+
* sibling and promote it on success, so an interrupted clone never leaves a
|
|
20
|
+
* half-initialized cache that later fetches would poison; then fetch the
|
|
21
|
+
* requested revision and check out a detached worktree at the resolved commit.
|
|
22
|
+
*/
|
|
23
|
+
export const provisionWorktree = Effect.fn("Executor.provisionWorktree")(function* (options) {
|
|
24
|
+
const { layout, ops, request } = options;
|
|
25
|
+
yield* Effect.annotateCurrentSpan({
|
|
26
|
+
attemptId: request.attemptId,
|
|
27
|
+
worker: request.worker,
|
|
28
|
+
host: options.host,
|
|
29
|
+
repository: request.repository,
|
|
30
|
+
});
|
|
31
|
+
const cleanup = (resource, effect) => effect.pipe(Effect.tapError((error) => Effect.logError("Attempt cleanup operation failed", {
|
|
32
|
+
attemptId: request.attemptId,
|
|
33
|
+
worker: request.worker,
|
|
34
|
+
host: options.host,
|
|
35
|
+
worktree: layout.worktree,
|
|
36
|
+
resource,
|
|
37
|
+
message: String(error),
|
|
38
|
+
})), Effect.ignore);
|
|
39
|
+
// Register before any filesystem mutation. This also covers failed worktree
|
|
40
|
+
// creation, which can leave both a directory and a bare-cache registration.
|
|
41
|
+
yield* Effect.addFinalizer(Effect.fn("Executor.releaseWorktree")(function* () {
|
|
42
|
+
yield* Effect.annotateCurrentSpan({
|
|
43
|
+
attemptId: request.attemptId,
|
|
44
|
+
worker: request.worker,
|
|
45
|
+
repository: request.repository,
|
|
46
|
+
host: options.host,
|
|
47
|
+
});
|
|
48
|
+
yield* Effect.logInfo("Cleaning Attempt workspace", {
|
|
49
|
+
attemptId: request.attemptId,
|
|
50
|
+
worker: request.worker,
|
|
51
|
+
host: options.host,
|
|
52
|
+
worktree: layout.worktree,
|
|
53
|
+
});
|
|
54
|
+
const cacheExists = yield* ops.cacheExists.pipe(Effect.tapError((error) => Effect.logWarning("Could not inspect cache during cleanup", {
|
|
55
|
+
attemptId: request.attemptId,
|
|
56
|
+
message: String(error),
|
|
57
|
+
})), Effect.orElseSucceed(() => false));
|
|
58
|
+
if (cacheExists) {
|
|
59
|
+
yield* cleanup("git-worktree", ops.git("cleanup", [
|
|
60
|
+
"--git-dir",
|
|
61
|
+
layout.cache,
|
|
62
|
+
"worktree",
|
|
63
|
+
"remove",
|
|
64
|
+
"--force",
|
|
65
|
+
layout.worktree,
|
|
66
|
+
]));
|
|
67
|
+
}
|
|
68
|
+
yield* cleanup("worktree-directory", ops.removePath("cleanup", layout.worktree));
|
|
69
|
+
if (cacheExists) {
|
|
70
|
+
yield* cleanup("cache-registration", ops.git("cleanup", ["--git-dir", layout.cache, "worktree", "prune"]));
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
yield* ops.ensureRoots;
|
|
74
|
+
yield* ops.removePath("prepare", layout.worktree);
|
|
75
|
+
if (yield* ops.cacheExists) {
|
|
76
|
+
yield* ops.git("prepare", [
|
|
77
|
+
"--git-dir",
|
|
78
|
+
layout.cache,
|
|
79
|
+
"remote",
|
|
80
|
+
"set-url",
|
|
81
|
+
"origin",
|
|
82
|
+
options.url,
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Staging belongs to this locked clone only. Release it before unlocking,
|
|
87
|
+
// including interruption between clone completion and cache promotion.
|
|
88
|
+
yield* Effect.scoped(Effect.gen(function* () {
|
|
89
|
+
yield* Effect.addFinalizer(() => cleanup("partial-clone", ops.removePath("cleanup", layout.staging)));
|
|
90
|
+
yield* ops.removePath("prepare", layout.staging);
|
|
91
|
+
yield* ops.git("prepare", [
|
|
92
|
+
"clone",
|
|
93
|
+
"--bare",
|
|
94
|
+
"--filter=blob:none",
|
|
95
|
+
options.url,
|
|
96
|
+
layout.staging,
|
|
97
|
+
]);
|
|
98
|
+
yield* ops.promoteStaging;
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
yield* ops.git("prepare", [
|
|
102
|
+
"--git-dir",
|
|
103
|
+
layout.cache,
|
|
104
|
+
"fetch",
|
|
105
|
+
"--force",
|
|
106
|
+
"--prune",
|
|
107
|
+
"origin",
|
|
108
|
+
request.revision,
|
|
109
|
+
]);
|
|
110
|
+
const resolved = (yield* ops.git("prepare", [
|
|
111
|
+
"--git-dir",
|
|
112
|
+
layout.cache,
|
|
113
|
+
"rev-parse",
|
|
114
|
+
"FETCH_HEAD",
|
|
115
|
+
])).trim();
|
|
116
|
+
const baseCommit = yield* decodeCommit(resolved).pipe(Effect.mapError((cause) => new ExecutorOperationError({
|
|
117
|
+
operation: "prepare",
|
|
118
|
+
message: "git returned an invalid object id",
|
|
119
|
+
cause,
|
|
120
|
+
})));
|
|
121
|
+
yield* ops.git("prepare", [
|
|
122
|
+
"--git-dir",
|
|
123
|
+
layout.cache,
|
|
124
|
+
"worktree",
|
|
125
|
+
"add",
|
|
126
|
+
"--detach",
|
|
127
|
+
layout.worktree,
|
|
128
|
+
baseCommit,
|
|
129
|
+
]);
|
|
130
|
+
return new AttemptWorkspace({
|
|
131
|
+
worker: request.worker,
|
|
132
|
+
spec: new AttemptChannel.RunSpec({
|
|
133
|
+
attemptId: request.attemptId,
|
|
134
|
+
repository: request.repository,
|
|
135
|
+
revision: request.revision,
|
|
136
|
+
baseCommit,
|
|
137
|
+
payload: request.payload,
|
|
138
|
+
task: request.task,
|
|
139
|
+
agent: request.agent,
|
|
140
|
+
parentModel: request.parentModel,
|
|
141
|
+
maxChildren: request.maxChildren,
|
|
142
|
+
parentEffort: request.parentEffort,
|
|
143
|
+
}),
|
|
144
|
+
worktree: WorktreePath.make(layout.worktree),
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=provision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provision.js","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,GAEb,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AAEjG,MAAM,sBAAsB,GAAG,M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ClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC;QACF,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;KAC7C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
+
import { AttemptFailure } from "@usine/core/attempt/failure";
|
|
3
|
+
import { AttemptId } from "@usine/core/attempt";
|
|
4
|
+
import { StepResult } from "@usine/core/step/result";
|
|
5
|
+
import { Cause, Effect, Queue, Scope, type PlatformError } from "effect";
|
|
6
|
+
import type { ChildProcessHandle } from "effect/unstable/process/ChildProcessSpawner";
|
|
7
|
+
import { ExecutorError, type AttemptWorkspace } from "./executor.ts";
|
|
8
|
+
interface SpawnedRunHost {
|
|
9
|
+
readonly handle: ChildProcessHandle;
|
|
10
|
+
readonly host: string;
|
|
11
|
+
/** Redacts the Attempt credential from run-host output before it is persisted. */
|
|
12
|
+
readonly scrub: (text: string) => string;
|
|
13
|
+
}
|
|
14
|
+
export type RunHostInput = Queue.Queue<Uint8Array, Cause.Done>;
|
|
15
|
+
export interface RunHostSessionOptions {
|
|
16
|
+
readonly interruptGrace: Parameters<typeof Effect.timeoutOption>[1];
|
|
17
|
+
}
|
|
18
|
+
type SpawnRunHost = (input: RunHostInput) => Effect.Effect<SpawnedRunHost, AttemptFailure | PlatformError.PlatformError, Scope.Scope>;
|
|
19
|
+
export interface RunHostSession {
|
|
20
|
+
readonly cancel: (attemptId: AttemptId) => Effect.Effect<void, ExecutorError>;
|
|
21
|
+
readonly launch: (prepared: AttemptWorkspace, io: AttemptChannel.Sink, spawn: SpawnRunHost) => Effect.Effect<StepResult, AttemptFailure>;
|
|
22
|
+
}
|
|
23
|
+
/** The run-host byte-channel session every process-backed Executor shares. */
|
|
24
|
+
export declare const runHostSessionFor: (options: RunHostSessionOptions) => Effect.Effect<RunHostSession>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=run-host-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-host-session.d.ts","sourceRoot":"","sources":["../src/run-host-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAgB,cAAc,EAAgB,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,KAAK,EAEL,MAAM,EAGN,KAAK,EAIL,KAAK,EAEL,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,aAAa,EAA0B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG7F,UAAU,cAAc;IACtB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAED,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACrE;AAED,KAAK,YAAY,GAAG,CAClB,KAAK,EAAE,YAAY,KAChB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,aAAa,CAAC,a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