@catamorphic/work-server 0.1.0-alpha.38 → 0.1.0-alpha.41
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/NOTICE.txt +7 -0
- package/README.md +9 -9
- package/dist/admission/routes.d.ts +1 -1
- package/dist/admission/routes.d.ts.map +1 -1
- package/dist/agent-capabilities.d.ts.map +1 -1
- package/dist/agents.d.ts +5 -6
- package/dist/agents.d.ts.map +1 -1
- package/dist/auth/fastify-auth.d.ts.map +1 -1
- package/dist/auth/work-auth-types.d.ts +2 -0
- package/dist/auth/work-auth-types.d.ts.map +1 -1
- package/dist/auth/work-auth.d.ts.map +1 -1
- package/dist/chunk-kcck20aw.js +676 -0
- package/dist/chunk-kcck20aw.js.map +11 -0
- package/dist/cluster.d.ts +8 -7
- package/dist/cluster.d.ts.map +1 -1
- package/dist/config.d.ts +5 -15
- package/dist/config.d.ts.map +1 -1
- package/dist/execution-config.d.ts +22 -0
- package/dist/execution-config.d.ts.map +1 -1
- package/dist/fake-agent.d.ts +1 -0
- package/dist/fake-agent.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2730 -2851
- package/dist/index.js.map +28 -28
- package/dist/machines/contract-kit.d.ts +91 -0
- package/dist/machines/contract-kit.d.ts.map +1 -0
- package/dist/machines/contract.d.ts +383 -0
- package/dist/machines/contract.d.ts.map +1 -0
- package/dist/machines/sequencer.d.ts +267 -0
- package/dist/machines/sequencer.d.ts.map +1 -0
- package/dist/machines/simulation.d.ts +124 -0
- package/dist/machines/simulation.d.ts.map +1 -0
- package/dist/machines/work-machines.d.ts +61 -0
- package/dist/machines/work-machines.d.ts.map +1 -0
- package/dist/server.d.ts +15 -11
- package/dist/server.d.ts.map +1 -1
- package/dist/setup/machines.d.ts +9 -17
- package/dist/setup/machines.d.ts.map +1 -1
- package/dist/shares/share-routes.d.ts +1 -1
- package/dist/shares/share-routes.d.ts.map +1 -1
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1013 -0
- package/dist/testing.js.map +11 -0
- package/dist/workers/disk-care.d.ts +41 -0
- package/dist/workers/disk-care.d.ts.map +1 -0
- package/dist/workers/harness-sign-ins.d.ts +146 -0
- package/dist/workers/harness-sign-ins.d.ts.map +1 -0
- package/dist/workers/machine-store.d.ts +196 -0
- package/dist/workers/machine-store.d.ts.map +1 -0
- package/dist/workers/member-machine-routes.d.ts +5 -3
- package/dist/workers/member-machine-routes.d.ts.map +1 -1
- package/dist/workers/member-machines.d.ts +47 -28
- package/dist/workers/member-machines.d.ts.map +1 -1
- package/dist/workers/placement.d.ts +23 -40
- package/dist/workers/placement.d.ts.map +1 -1
- package/dist/workers/sign-ins.d.ts +44 -17
- package/dist/workers/sign-ins.d.ts.map +1 -1
- package/dist/workers/worker-protocol.d.ts +5 -2
- package/dist/workers/worker-protocol.d.ts.map +1 -1
- package/dist/workers/worker-registry.d.ts +174 -223
- package/dist/workers/worker-registry.d.ts.map +1 -1
- package/dist/workers/worker-routes.d.ts.map +1 -1
- package/dist/workers/worker-runtime.d.ts.map +1 -1
- package/package.json +44 -34
- package/src/admission/routes.ts +5 -2
- package/src/agent-capabilities.ts +22 -8
- package/src/agents.ts +52 -23
- package/src/auth/fastify-auth.ts +149 -17
- package/src/auth/work-auth-types.ts +2 -0
- package/src/auth/work-auth.ts +27 -0
- package/src/cluster.ts +115 -42
- package/src/config.ts +15 -41
- package/src/execution-config.ts +40 -0
- package/src/fake-agent.ts +21 -4
- package/src/index.ts +26 -12
- package/src/machines/contract-kit.ts +648 -0
- package/src/machines/contract.ts +522 -0
- package/src/machines/sequencer.ts +1010 -0
- package/src/machines/simulation.ts +833 -0
- package/src/machines/work-machines.ts +231 -0
- package/src/server.ts +235 -150
- package/src/setup/machines.ts +128 -121
- package/src/shares/share-routes.ts +17 -1
- package/src/testing.ts +22 -0
- package/src/workers/disk-care.ts +121 -0
- package/src/workers/fake-claude-cli.ts +95 -0
- package/src/workers/fake-codex-cli.ts +11 -4
- package/src/workers/harness-sign-ins.ts +580 -0
- package/src/workers/machine-store.ts +1065 -0
- package/src/workers/member-machine-routes.ts +92 -20
- package/src/workers/member-machines.ts +163 -99
- package/src/workers/placement.ts +59 -70
- package/src/workers/sign-ins.ts +109 -52
- package/src/workers/worker-protocol.ts +5 -2
- package/src/workers/worker-registry.ts +894 -754
- package/src/workers/worker-routes.ts +4 -1
- package/src/workers/worker-runtime.ts +55 -23
- package/dist/test-support.d.ts +0 -133
- package/dist/test-support.d.ts.map +0 -1
- package/dist/workers/codex-sign-ins.d.ts +0 -107
- package/dist/workers/codex-sign-ins.d.ts.map +0 -1
- package/dist/workers/install-script.d.ts +0 -71
- package/dist/workers/install-script.d.ts.map +0 -1
- package/dist/workers/machine-classes.d.ts +0 -115
- package/dist/workers/machine-classes.d.ts.map +0 -1
- package/dist/workers/machine-rules.d.ts +0 -402
- package/dist/workers/machine-rules.d.ts.map +0 -1
- package/src/test-support.ts +0 -404
- package/src/workers/codex-sign-ins.ts +0 -360
- package/src/workers/install-script.ts +0 -394
- package/src/workers/machine-classes.ts +0 -152
- package/src/workers/machine-rules.ts +0 -1954
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MachineDiskSchema,
|
|
2
3
|
REMOTE_EPOCH_PATTERN,
|
|
3
4
|
RemoteExecutorLeaseLostError,
|
|
4
5
|
RemoteReceiptRefusedError,
|
|
@@ -22,6 +23,8 @@ import {
|
|
|
22
23
|
} from "./worker-registry.js";
|
|
23
24
|
|
|
24
25
|
const Session = z.strictObject({ session: z.string().uuid() });
|
|
26
|
+
/** A renewal may carry the worker's latest disk measurement (ADR 0336). */
|
|
27
|
+
const Renewal = Session.extend({ disk: MachineDiskSchema.optional() });
|
|
25
28
|
/** A retried poll repeats its id and receives what that poll took. */
|
|
26
29
|
const Poll = Session.extend({
|
|
27
30
|
pollId: z.string().uuid(),
|
|
@@ -174,7 +177,7 @@ export function registerWorkerRoutes(
|
|
|
174
177
|
app.post("/api/workers/renew", async (request, reply) => {
|
|
175
178
|
const worker = await authenticated(request, reply);
|
|
176
179
|
if (!worker) return reply;
|
|
177
|
-
const body =
|
|
180
|
+
const body = Renewal.safeParse(request.body);
|
|
178
181
|
if (!body.success) return reply.status(400).send({ error: "No session" });
|
|
179
182
|
try {
|
|
180
183
|
await registry.renew({ nodeId: worker.nodeId, ...body.data });
|
|
@@ -5,6 +5,7 @@ import { nodeExecutor, RETIRED_KEY_RETENTION_MS } from "@catamorphic/core";
|
|
|
5
5
|
import {
|
|
6
6
|
executorPublicKey,
|
|
7
7
|
generateExecutorKeyPair,
|
|
8
|
+
MACHINE_CAPABILITIES,
|
|
8
9
|
type SandboxProvider,
|
|
9
10
|
} from "@catamorphic/sandbox";
|
|
10
11
|
import {
|
|
@@ -20,7 +21,8 @@ import {
|
|
|
20
21
|
type WorkExecutionSettings,
|
|
21
22
|
workExecution,
|
|
22
23
|
} from "../execution-config.js";
|
|
23
|
-
import {
|
|
24
|
+
import { startDiskCare } from "./disk-care.js";
|
|
25
|
+
import { HarnessSignIns } from "./harness-sign-ins.js";
|
|
24
26
|
import { removeMachineSignIns, signInCapabilities } from "./sign-ins.js";
|
|
25
27
|
import { startVolumePruning } from "./volume-pruning.js";
|
|
26
28
|
import {
|
|
@@ -217,26 +219,47 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
217
219
|
retentionMs: execution.volumeRetentionMs,
|
|
218
220
|
log,
|
|
219
221
|
});
|
|
222
|
+
// Its disk, measured and reported with its offer and its renewals, and
|
|
223
|
+
// what Work left there removed (ADR 0336).
|
|
224
|
+
const diskCare = startDiskCare({
|
|
225
|
+
provider,
|
|
226
|
+
...(execution.diskFloorMb !== undefined
|
|
227
|
+
? { floorMb: execution.diskFloorMb }
|
|
228
|
+
: {}),
|
|
229
|
+
...(execution.diskCriticalMb !== undefined
|
|
230
|
+
? { criticalMb: execution.diskCriticalMb }
|
|
231
|
+
: {}),
|
|
232
|
+
graceMs: execution.imageRetentionMs,
|
|
233
|
+
log,
|
|
234
|
+
});
|
|
235
|
+
await diskCare.measure();
|
|
236
|
+
/** The measurement a renewal last carried: each is sent once. */
|
|
237
|
+
let diskSent: string | undefined;
|
|
220
238
|
/**
|
|
221
239
|
* What this worker offers, read again for every connect: members'
|
|
222
240
|
* sign-ins come and go on the machine (ADR 0199), and only the fact that
|
|
223
241
|
* one exists is reported.
|
|
224
242
|
*/
|
|
225
|
-
const currentOffer = (): WorkerOffer =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
243
|
+
const currentOffer = (): WorkerOffer => {
|
|
244
|
+
const disk = diskCare.latest();
|
|
245
|
+
return {
|
|
246
|
+
isolation: execution.isolation,
|
|
247
|
+
resourceLimits: [...(provider.resourceLimits ?? [])],
|
|
248
|
+
workspaceRoot: provider.workspaceRoot ?? "/workspace",
|
|
249
|
+
processes: Boolean(provider.processes),
|
|
250
|
+
capabilities: [
|
|
251
|
+
...(provider.capabilities ?? []),
|
|
252
|
+
...execution.machineCapabilities,
|
|
253
|
+
...(disk ? [MACHINE_CAPABILITIES.disk] : []),
|
|
254
|
+
...signInCapabilities(execution.signInRoot),
|
|
255
|
+
],
|
|
256
|
+
capacity: execution.capacity,
|
|
257
|
+
defaults: execution.defaults,
|
|
258
|
+
...(options.version ? { version: options.version } : {}),
|
|
259
|
+
...(disk ? { disk } : {}),
|
|
260
|
+
backend: execution.backend,
|
|
261
|
+
};
|
|
262
|
+
};
|
|
240
263
|
// This process's epoch: the node's lease token while it runs. A restart
|
|
241
264
|
// chooses a later one, and the control plane fails what the old one was
|
|
242
265
|
// sent as uncertain.
|
|
@@ -333,10 +356,11 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
333
356
|
const sandboxes = new PersistedSandboxes(
|
|
334
357
|
path.join(options.dataDir, "sandboxes.json"),
|
|
335
358
|
);
|
|
336
|
-
// Members sign in to Codex on this machine from the app
|
|
337
|
-
// The connected session's own re-offer, run when a
|
|
359
|
+
// Members sign in to Claude Code and Codex on this machine from the app
|
|
360
|
+
// (ADRs 0213, 0342). The connected session's own re-offer, run when a
|
|
361
|
+
// sign-in changes here.
|
|
338
362
|
const offerSignIns = { now: () => {} };
|
|
339
|
-
const
|
|
363
|
+
const harnessSignIns = new HarnessSignIns({
|
|
340
364
|
signInRoot: execution.signInRoot,
|
|
341
365
|
dataDir: options.dataDir,
|
|
342
366
|
// The machine's own PATH, where its sandboxes find their tools too.
|
|
@@ -351,7 +375,7 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
351
375
|
.catch(() => undefined)
|
|
352
376
|
.then(() => {
|
|
353
377
|
// Logins still waiting end before their homes go.
|
|
354
|
-
|
|
378
|
+
harnessSignIns.stop();
|
|
355
379
|
return resetMachine({
|
|
356
380
|
provider,
|
|
357
381
|
sandboxes,
|
|
@@ -474,9 +498,16 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
474
498
|
once: true,
|
|
475
499
|
});
|
|
476
500
|
});
|
|
501
|
+
diskSent = offer.disk?.measuredAt;
|
|
477
502
|
const transport: ClientRunnerTransport = {
|
|
478
503
|
renew: async () => {
|
|
479
|
-
|
|
504
|
+
const disk = diskCare.latest();
|
|
505
|
+
const fresh = disk && disk.measuredAt !== diskSent ? disk : undefined;
|
|
506
|
+
await call({
|
|
507
|
+
route: "renew",
|
|
508
|
+
body: { session: token, ...(fresh ? { disk: fresh } : {}) },
|
|
509
|
+
});
|
|
510
|
+
if (fresh) diskSent = fresh.measuredAt;
|
|
480
511
|
},
|
|
481
512
|
poll: async ({ pollId, max, signal }) => {
|
|
482
513
|
const polled = await call({
|
|
@@ -519,7 +550,7 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
519
550
|
sandboxes,
|
|
520
551
|
// A pooled machine returns to its pool (ADR 0205).
|
|
521
552
|
resetMachine: reset,
|
|
522
|
-
|
|
553
|
+
harnessSignIn: (request) => harnessSignIns.handle(request),
|
|
523
554
|
keepSandboxes: true,
|
|
524
555
|
maxSandboxes: execution.capacity.workspaces,
|
|
525
556
|
// One slot per workspace, so one long command never blocks the others.
|
|
@@ -623,7 +654,8 @@ export async function startWorkWorker(options: WorkWorkerOptions): Promise<{
|
|
|
623
654
|
stop: async () => {
|
|
624
655
|
stopping.abort();
|
|
625
656
|
stopPruning();
|
|
626
|
-
|
|
657
|
+
diskCare.stop();
|
|
658
|
+
harnessSignIns.stop();
|
|
627
659
|
await loop;
|
|
628
660
|
await Promise.allSettled(
|
|
629
661
|
[...sandboxes].map((id) => provider.stopSandbox(id)),
|
package/dist/test-support.d.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { AgentTurnUsage, Item, Turn } from "@catamorphic/agent-protocol";
|
|
2
|
-
import { type AgentSessionsService, type Identity } from "@catamorphic/core";
|
|
3
|
-
import { type WorkExecutionSettings } from "./execution-config.js";
|
|
4
|
-
import { type DirectoryAccountStatus, type DirectoryProvider } from "./identity/directory.js";
|
|
5
|
-
import type { WorkServerOptions } from "./server.js";
|
|
6
|
-
/**
|
|
7
|
-
* A directory (ADR 0161) governing Better Auth's local "credential"
|
|
8
|
-
* accounts, whose account id is the user id, so every lifecycle path runs
|
|
9
|
-
* through the real OAuth server and token gate. Accounts it does not know
|
|
10
|
-
* are active in no group; it answers only about the groups it is asked.
|
|
11
|
-
*/
|
|
12
|
-
export declare class FakeDirectory implements DirectoryProvider {
|
|
13
|
-
readonly providerId = "credential";
|
|
14
|
-
readonly requiredGroups: string[];
|
|
15
|
-
/** Replica memory (single process): a test's directory, never a host's. */
|
|
16
|
-
readonly accounts: Map<string, DirectoryAccountStatus>;
|
|
17
|
-
unavailable: boolean;
|
|
18
|
-
calls: number;
|
|
19
|
-
check(args: {
|
|
20
|
-
accountId: string;
|
|
21
|
-
groups: readonly string[];
|
|
22
|
-
}): Promise<DirectoryAccountStatus>;
|
|
23
|
-
}
|
|
24
|
-
/** Test servers boot from the same env parser as the image. */
|
|
25
|
-
export declare function testServerOptions(args: {
|
|
26
|
-
dataDir: string;
|
|
27
|
-
publicBases?: string[];
|
|
28
|
-
env: Record<string, string | undefined>;
|
|
29
|
-
}): WorkServerOptions;
|
|
30
|
-
/**
|
|
31
|
-
* A test worker's execution settings, from the same parser as the image.
|
|
32
|
-
* Like {@link testServerOptions}, trusted subprocesses unless the test
|
|
33
|
-
* chooses a backend: `auto` would pick containers on a runner with Docker.
|
|
34
|
-
*/
|
|
35
|
-
export declare function testExecutionSettings(env: Record<string, string | undefined>): WorkExecutionSettings;
|
|
36
|
-
/**
|
|
37
|
-
* A database of its own on the server at `DATABASE_URL`: a deployment's
|
|
38
|
-
* replicas share one origin and secrets, which other suites do not.
|
|
39
|
-
*/
|
|
40
|
-
export declare function createTestDatabase(prefix: string): Promise<{
|
|
41
|
-
url: string;
|
|
42
|
-
drop(): Promise<void>;
|
|
43
|
-
}>;
|
|
44
|
-
interface InjectableApp {
|
|
45
|
-
inject(options: {
|
|
46
|
-
method: "GET" | "POST";
|
|
47
|
-
url: string;
|
|
48
|
-
headers?: Record<string, string>;
|
|
49
|
-
payload?: unknown;
|
|
50
|
-
}): Promise<{
|
|
51
|
-
statusCode: number;
|
|
52
|
-
headers: Record<string, string | string[] | number | undefined>;
|
|
53
|
-
json(): Record<string, unknown>;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
/** Accept the signed authorization prompt before exchanging the code. */
|
|
57
|
-
export declare function acceptOAuthConsent(args: {
|
|
58
|
-
app: InjectableApp;
|
|
59
|
-
location: string;
|
|
60
|
-
cookie: string;
|
|
61
|
-
}): Promise<string>;
|
|
62
|
-
/**
|
|
63
|
-
* The OAuth flow an MCP client runs, in process: local sign-in, dynamic
|
|
64
|
-
* client registration, PKCE authorization, and the code exchange.
|
|
65
|
-
*/
|
|
66
|
-
export declare function oauthAccessToken(args: {
|
|
67
|
-
app: InjectableApp;
|
|
68
|
-
username: string;
|
|
69
|
-
password: string;
|
|
70
|
-
}): Promise<string>;
|
|
71
|
-
/**
|
|
72
|
-
* Drop a test's own database once the servers that used it have closed
|
|
73
|
-
* their connections. Forcing it while a pool is still closing a client
|
|
74
|
-
* terminates that client, which surfaces as an uncaught error; a
|
|
75
|
-
* connection still open after 10 seconds is a leak, so the test fails.
|
|
76
|
-
*/
|
|
77
|
-
export declare function dropTestDatabase(args: {
|
|
78
|
-
admin: {
|
|
79
|
-
query(text: string, values?: unknown[]): Promise<{
|
|
80
|
-
rows: Array<{
|
|
81
|
-
connections?: number;
|
|
82
|
-
}>;
|
|
83
|
-
}>;
|
|
84
|
-
};
|
|
85
|
-
database: string;
|
|
86
|
-
}): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* A settled turn as tests read it: the agent's final reply (or the turn's
|
|
89
|
-
* error, for one that failed), its usage, and the turn.
|
|
90
|
-
*/
|
|
91
|
-
export declare function replyOf(result: {
|
|
92
|
-
reply: Item | null;
|
|
93
|
-
turn: Turn;
|
|
94
|
-
}): {
|
|
95
|
-
content: string;
|
|
96
|
-
usage: AgentTurnUsage | undefined;
|
|
97
|
-
turn: Turn;
|
|
98
|
-
};
|
|
99
|
-
/** Send a message and wait for its turn: {@link replyOf} that turn. */
|
|
100
|
-
export declare function say(input: {
|
|
101
|
-
sessions: AgentSessionsService;
|
|
102
|
-
identity: Identity;
|
|
103
|
-
projectId: string;
|
|
104
|
-
sessionId: string;
|
|
105
|
-
text: string;
|
|
106
|
-
}): Promise<ReturnType<typeof replyOf>>;
|
|
107
|
-
/** Queue a message without waiting for it; resolves its turn's id. */
|
|
108
|
-
export declare function enqueue(input: {
|
|
109
|
-
sessions: AgentSessionsService;
|
|
110
|
-
identity: Identity;
|
|
111
|
-
projectId: string;
|
|
112
|
-
sessionId: string;
|
|
113
|
-
text: string;
|
|
114
|
-
}): Promise<string>;
|
|
115
|
-
/**
|
|
116
|
-
* Every regular file under a directory, links not followed. A sandbox's
|
|
117
|
-
* transient files (a lock, an index being rewritten) may go while it is
|
|
118
|
-
* walked: what is gone by then is not listed. The directory itself must be
|
|
119
|
-
* there, so a scan of it never passes for want of files.
|
|
120
|
-
*/
|
|
121
|
-
export declare function filesUnder(directory: string): string[];
|
|
122
|
-
/**
|
|
123
|
-
* Files under a directory whose bytes contain the text, as a leak check
|
|
124
|
-
* reads them: a file gone before it is read holds nothing.
|
|
125
|
-
*/
|
|
126
|
-
export declare function filesHolding(directory: string, text: string): string[];
|
|
127
|
-
/**
|
|
128
|
-
* A registry pack's files by their project targets, from the built catalog
|
|
129
|
-
* an agent's `registry.read` returns (ADR 0262).
|
|
130
|
-
*/
|
|
131
|
-
export declare function registryPack(name: string): Record<string, string>;
|
|
132
|
-
export {};
|
|
133
|
-
//# sourceMappingURL=test-support.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../src/test-support.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,iBAAiB;IACrD,QAAQ,CAAC,UAAU,gBAAgB;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAM;IACvC,2EAA2E;IAC3E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;AAED,sEAAsE;AACtE,wBAAsB,OAAO,CAAC,KAAK,EAAE;IACnC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBlB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtD;AAiBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAStE;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcjE"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** What a member does with Codex on a machine. */
|
|
3
|
-
export type CodexSignInRequest = {
|
|
4
|
-
action: "begin";
|
|
5
|
-
member: string;
|
|
6
|
-
} | {
|
|
7
|
-
action: "status";
|
|
8
|
-
member: string;
|
|
9
|
-
attempt: string;
|
|
10
|
-
} | {
|
|
11
|
-
action: "cancel";
|
|
12
|
-
member: string;
|
|
13
|
-
attempt: string;
|
|
14
|
-
} | {
|
|
15
|
-
action: "signOut";
|
|
16
|
-
member: string;
|
|
17
|
-
};
|
|
18
|
-
export declare const CodexSignInStartedSchema: z.ZodObject<{
|
|
19
|
-
attempt: z.ZodString;
|
|
20
|
-
verificationUrl: z.ZodString;
|
|
21
|
-
userCode: z.ZodString;
|
|
22
|
-
expiresAt: z.ZodString;
|
|
23
|
-
}, z.core.$strict>;
|
|
24
|
-
export type CodexSignInStarted = z.infer<typeof CodexSignInStartedSchema>;
|
|
25
|
-
export declare const CodexSignInStatusSchema: z.ZodObject<{
|
|
26
|
-
state: z.ZodEnum<{
|
|
27
|
-
cancelled: "cancelled";
|
|
28
|
-
expired: "expired";
|
|
29
|
-
failed: "failed";
|
|
30
|
-
"signed-in": "signed-in";
|
|
31
|
-
waiting: "waiting";
|
|
32
|
-
}>;
|
|
33
|
-
message: z.ZodOptional<z.ZodString>;
|
|
34
|
-
}, z.core.$strict>;
|
|
35
|
-
export type CodexSignInStatus = z.infer<typeof CodexSignInStatusSchema>;
|
|
36
|
-
export type CodexSignInState = CodexSignInStatus["state"];
|
|
37
|
-
export declare const CodexSignedOutSchema: z.ZodObject<{
|
|
38
|
-
signedOut: z.ZodBoolean;
|
|
39
|
-
}, z.core.$strict>;
|
|
40
|
-
/** A login this machine would not start, and why, for the member to read. */
|
|
41
|
-
export declare const CodexSignInRefusedSchema: z.ZodObject<{
|
|
42
|
-
refused: z.ZodString;
|
|
43
|
-
}, z.core.$strict>;
|
|
44
|
-
/** Codex's output without its colors. */
|
|
45
|
-
export declare function plainOutput(text: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* The link, one-time code and lifetime `codex login --device-auth` printed,
|
|
48
|
-
* once it printed both.
|
|
49
|
-
*/
|
|
50
|
-
export declare function parseDeviceCode(output: string): {
|
|
51
|
-
verificationUrl: string;
|
|
52
|
-
userCode: string;
|
|
53
|
-
minutes: number;
|
|
54
|
-
} | undefined;
|
|
55
|
-
export declare class CodexSignInRefusedError extends Error {
|
|
56
|
-
constructor(message: string);
|
|
57
|
-
}
|
|
58
|
-
export declare class CodexSignIns {
|
|
59
|
-
private readonly options;
|
|
60
|
-
/**
|
|
61
|
-
* Replica memory (a): the logins this machine's own process runs, each a
|
|
62
|
-
* child process here; a machine that restarts forgets them and the
|
|
63
|
-
* member starts again.
|
|
64
|
-
*/
|
|
65
|
-
private readonly attempts;
|
|
66
|
-
constructor(options: {
|
|
67
|
-
/** The machine's sign-in root (`<data>/sign-ins`). */
|
|
68
|
-
signInRoot: string;
|
|
69
|
-
/** The machine's data directory, for signing out. */
|
|
70
|
-
dataDir: string;
|
|
71
|
-
env?: NodeJS.ProcessEnv;
|
|
72
|
-
now?: () => number;
|
|
73
|
-
/**
|
|
74
|
-
* A member's sign-in was placed or removed: the machine tells
|
|
75
|
-
* placement now rather than at its next scan.
|
|
76
|
-
*/
|
|
77
|
-
onChange?: () => void;
|
|
78
|
-
});
|
|
79
|
-
/** One request from the control plane (or this server's own routes). */
|
|
80
|
-
handle(request: CodexSignInRequest): Promise<CodexSignInStarted | {
|
|
81
|
-
refused: string;
|
|
82
|
-
} | CodexSignInStatus | {
|
|
83
|
-
signedOut: boolean;
|
|
84
|
-
}>;
|
|
85
|
-
/**
|
|
86
|
-
* Start Codex's device-code login for a member. Resolves once Codex
|
|
87
|
-
* printed its link and code; one login runs per member, so a new one
|
|
88
|
-
* replaces theirs.
|
|
89
|
-
*/
|
|
90
|
-
begin(input: {
|
|
91
|
-
member: string;
|
|
92
|
-
}): Promise<CodexSignInStarted>;
|
|
93
|
-
status(input: {
|
|
94
|
-
member: string;
|
|
95
|
-
attempt: string;
|
|
96
|
-
}): CodexSignInStatus;
|
|
97
|
-
cancel(input: {
|
|
98
|
-
member: string;
|
|
99
|
-
attempt: string;
|
|
100
|
-
}): CodexSignInStatus;
|
|
101
|
-
/** End every login this machine runs, when it stops. */
|
|
102
|
-
stop(): void;
|
|
103
|
-
private finish;
|
|
104
|
-
private prune;
|
|
105
|
-
private now;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=codex-sign-ins.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codex-sign-ins.d.ts","sourceRoot":"","sources":["../../src/workers/codex-sign-ins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAA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M,CAAC;QAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;QACnB;;;WAGG;QACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;KACvB,EACC;IAEJ,wEAAwE;IAClE,MAAM,CACV,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CACN,kBAAkB,GAClB;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GACnB,iBAAiB,GACjB;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CACzB,CAuBA;IAED;;;;OAIG;IACG,KAAK,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgIlE;IAED,MAAM,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,CAYpE;IAED,MAAM,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,CAKpE;IAED,wDAAwD;IACxD,IAAI,IAAI,IAAI,CAGX;IAED,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,GAAG;CAGZ"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { FastifyInstance } from "fastify";
|
|
2
|
-
/** What every machine installs from this control plane (ADR 0205). */
|
|
3
|
-
export interface InstallTarget {
|
|
4
|
-
/** The control plane's public origin the worker dials. */
|
|
5
|
-
controlPlaneUrl: string;
|
|
6
|
-
/** The deployment's explicitly selected worker image. */
|
|
7
|
-
image: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The install target, or why machines cannot install from this server: a
|
|
11
|
-
* deployment-owned worker image is needed (`WORK_WORKER_IMAGE`), and a public origin other machines reach.
|
|
12
|
-
*/
|
|
13
|
-
export declare function installTarget(args: {
|
|
14
|
-
publicBase: string;
|
|
15
|
-
workerImage?: string;
|
|
16
|
-
}): {
|
|
17
|
-
target: InstallTarget;
|
|
18
|
-
} | {
|
|
19
|
-
unavailable: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The sandbox backend a machine the script installs runs (`--sandbox`):
|
|
23
|
-
* `auto` picks microVMs where KVM is usable and gVisor elsewhere.
|
|
24
|
-
*/
|
|
25
|
-
export type WorkerSandbox = "auto" | "microsandbox" | "container";
|
|
26
|
-
/** The data directory the script uses unless told otherwise. */
|
|
27
|
-
export declare const DEFAULT_WORKER_DATA_DIR = "/var/lib/work";
|
|
28
|
-
/**
|
|
29
|
-
* The worker install script (ADR 0205): a POSIX sh script with the control
|
|
30
|
-
* plane and image baked in, holding no secret. It installs Docker where it
|
|
31
|
-
* is missing; with no usable `/dev/kvm`, or `--sandbox container`, it
|
|
32
|
-
* installs gVisor and registers the `runsc` runtime with Work's arguments
|
|
33
|
-
* (ADR 0204); then it runs the worker image with `WORK_SANDBOX` (`auto`
|
|
34
|
-
* unless `--sandbox` names a backend), the Docker socket, `/dev/kvm` when
|
|
35
|
-
* microVMs use it, and its data directory mounted at the same path.
|
|
36
|
-
*
|
|
37
|
-
* microsandbox runs each microVM through libkrun, which only opens
|
|
38
|
-
* `/dev/kvm` and keeps the guest's network in user space: the device and
|
|
39
|
-
* its group are all the worker container needs, never `--privileged` or
|
|
40
|
-
* added capabilities.
|
|
41
|
-
*
|
|
42
|
-
* Downloads land in files that are checked before use, never piped into a
|
|
43
|
-
* shell. Package installation waits, within bounds, for another one to
|
|
44
|
-
* finish, as on a cloud machine's first boot. The data directory, which is
|
|
45
|
-
* made private to the worker, is never a system directory.
|
|
46
|
-
*/
|
|
47
|
-
export declare function workerInstallScript(target: InstallTarget): string;
|
|
48
|
-
/** Where cloud-init writes the script on a cloud machine. */
|
|
49
|
-
export declare const CLOUD_INIT_SCRIPT_PATH = "/usr/local/sbin/work-install-worker";
|
|
50
|
-
/**
|
|
51
|
-
* Cloud-init user data for a cloud machine (ADR 0205): the install script
|
|
52
|
-
* itself, written to disk and run once with the machine's enrollment code.
|
|
53
|
-
* Nothing is fetched over the network to start it.
|
|
54
|
-
*/
|
|
55
|
-
export declare function workerCloudInit(args: {
|
|
56
|
-
script: string;
|
|
57
|
-
code: string;
|
|
58
|
-
/** The machine's sandbox backend, when its class names one. */
|
|
59
|
-
sandbox?: WorkerSandbox;
|
|
60
|
-
}): string;
|
|
61
|
-
/**
|
|
62
|
-
* `GET /api/workers/install.sh`, public: what a machine runs to become a
|
|
63
|
-
* worker. Answers 503 naming what is missing when machines cannot install
|
|
64
|
-
* from this server.
|
|
65
|
-
*/
|
|
66
|
-
export declare function registerInstallScriptRoute(app: FastifyInstance, install: {
|
|
67
|
-
target: InstallTarget;
|
|
68
|
-
} | {
|
|
69
|
-
unavailable: string;
|
|
70
|
-
}): void;
|
|
71
|
-
//# sourceMappingURL=install-script.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-script.d.ts","sourceRoot":"","sources":["../../src/workers/install-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,eAAe,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CActD;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,cAAc,GAAG,WAAW,CAAC;AAElE,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAmQjE;AAED,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,wCAAwC,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,GAAG,MAAM,CAwBT;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3D,IAAI,CAYN"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Machine class and rule names: lowercase letters, digits, dashes inside.
|
|
4
|
-
* They become parts of host names and cloud labels.
|
|
5
|
-
*/
|
|
6
|
-
export declare const MachineName: z.ZodString;
|
|
7
|
-
/**
|
|
8
|
-
* A Hetzner Cloud server per machine (ADR 0205). The API token is
|
|
9
|
-
* `WORK_HETZNER_TOKEN`, never part of the class.
|
|
10
|
-
*/
|
|
11
|
-
export declare const HetznerCloudClassSchema: z.ZodObject<{
|
|
12
|
-
platform: z.ZodLiteral<"hetzner-cloud">;
|
|
13
|
-
serverType: z.ZodString;
|
|
14
|
-
location: z.ZodString;
|
|
15
|
-
image: z.ZodString;
|
|
16
|
-
sshKeys: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
17
|
-
firewalls: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
18
|
-
networks: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
19
|
-
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
20
|
-
snapshot: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
22
|
-
auto: "auto";
|
|
23
|
-
container: "container";
|
|
24
|
-
microsandbox: "microsandbox";
|
|
25
|
-
}>>;
|
|
26
|
-
}, z.core.$strict>;
|
|
27
|
-
/** Machines the operator enrolled into a pool with this class label. */
|
|
28
|
-
export declare const PoolClassSchema: z.ZodObject<{
|
|
29
|
-
platform: z.ZodLiteral<"pool">;
|
|
30
|
-
}, z.core.$strict>;
|
|
31
|
-
/**
|
|
32
|
-
* Machines the `machineProvisioner` hook creates and destroys. `options`
|
|
33
|
-
* is the hook's own (an instance type, an image, a subnet): Work passes it
|
|
34
|
-
* through to every `create` unread.
|
|
35
|
-
*/
|
|
36
|
-
export declare const CustomClassSchema: z.ZodObject<{
|
|
37
|
-
platform: z.ZodLiteral<"custom">;
|
|
38
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
39
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
40
|
-
auto: "auto";
|
|
41
|
-
container: "container";
|
|
42
|
-
microsandbox: "microsandbox";
|
|
43
|
-
}>>;
|
|
44
|
-
}, z.core.$strict>;
|
|
45
|
-
export declare const MachineClassSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
-
platform: z.ZodLiteral<"hetzner-cloud">;
|
|
47
|
-
serverType: z.ZodString;
|
|
48
|
-
location: z.ZodString;
|
|
49
|
-
image: z.ZodString;
|
|
50
|
-
sshKeys: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
51
|
-
firewalls: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
52
|
-
networks: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
53
|
-
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
54
|
-
snapshot: z.ZodDefault<z.ZodBoolean>;
|
|
55
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
56
|
-
auto: "auto";
|
|
57
|
-
container: "container";
|
|
58
|
-
microsandbox: "microsandbox";
|
|
59
|
-
}>>;
|
|
60
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
-
platform: z.ZodLiteral<"pool">;
|
|
62
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
-
platform: z.ZodLiteral<"custom">;
|
|
64
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
65
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
66
|
-
auto: "auto";
|
|
67
|
-
container: "container";
|
|
68
|
-
microsandbox: "microsandbox";
|
|
69
|
-
}>>;
|
|
70
|
-
}, z.core.$strict>], "platform">;
|
|
71
|
-
export type MachineClass = z.output<typeof MachineClassSchema>;
|
|
72
|
-
export type MachinePlatform = MachineClass["platform"];
|
|
73
|
-
/** `WORK_MACHINES_CONFIG`: the machine classes rules may name. */
|
|
74
|
-
export declare const MachinesConfigSchema: z.ZodObject<{
|
|
75
|
-
classes: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
76
|
-
platform: z.ZodLiteral<"hetzner-cloud">;
|
|
77
|
-
serverType: z.ZodString;
|
|
78
|
-
location: z.ZodString;
|
|
79
|
-
image: z.ZodString;
|
|
80
|
-
sshKeys: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
81
|
-
firewalls: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
82
|
-
networks: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
83
|
-
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
84
|
-
snapshot: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
86
|
-
auto: "auto";
|
|
87
|
-
container: "container";
|
|
88
|
-
microsandbox: "microsandbox";
|
|
89
|
-
}>>;
|
|
90
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
91
|
-
platform: z.ZodLiteral<"pool">;
|
|
92
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
-
platform: z.ZodLiteral<"custom">;
|
|
94
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
95
|
-
sandbox: z.ZodOptional<z.ZodEnum<{
|
|
96
|
-
auto: "auto";
|
|
97
|
-
container: "container";
|
|
98
|
-
microsandbox: "microsandbox";
|
|
99
|
-
}>>;
|
|
100
|
-
}, z.core.$strict>], "platform">>;
|
|
101
|
-
}, z.core.$strict>;
|
|
102
|
-
export type MachinesConfig = z.output<typeof MachinesConfigSchema>;
|
|
103
|
-
/** Read and validate the machines file; errors name the file. */
|
|
104
|
-
export declare function machinesConfigFromFile(file: string): MachinesConfig;
|
|
105
|
-
/**
|
|
106
|
-
* Check machine classes against what the server has: a Hetzner token for
|
|
107
|
-
* `hetzner-cloud` classes and a provisioner for `custom` ones. Returns the
|
|
108
|
-
* reason a server cannot start with them, if any.
|
|
109
|
-
*/
|
|
110
|
-
export declare function machineClassesProblem(args: {
|
|
111
|
-
classes: Readonly<Record<string, MachineClass>>;
|
|
112
|
-
hetznerToken: boolean;
|
|
113
|
-
provisioner: boolean;
|
|
114
|
-
}): string | undefined;
|
|
115
|
-
//# sourceMappingURL=machine-classes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"machine-classes.d.ts","sourceRoot":"","sources":["../../src/workers/machine-classes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,WAAW,aAKrB,CAAC;AAuCJ;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;kBAsBlC,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,eAAe;;kBAAkD,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;kBAK5B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;gCAI7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC/D,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;AAEvD,kEAAkE;AAClE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAuBnE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAChD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAQrB"}
|