@catamorphic/work-server 0.1.0-alpha.43 → 0.1.0-alpha.44
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 +4 -1
- package/dist/{chunk-kcck20aw.js → chunk-ynxz0am9.js} +80 -9
- package/dist/chunk-ynxz0am9.js.map +11 -0
- package/dist/cluster.d.ts +19 -1
- package/dist/cluster.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +784 -197
- package/dist/index.js.map +18 -16
- package/dist/machines/contract.d.ts +138 -14
- package/dist/machines/contract.d.ts.map +1 -1
- package/dist/machines/sequencer.d.ts +33 -6
- package/dist/machines/sequencer.d.ts.map +1 -1
- package/dist/machines/simulation.d.ts +64 -0
- package/dist/machines/simulation.d.ts.map +1 -1
- package/dist/machines/work-machines.d.ts +20 -2
- package/dist/machines/work-machines.d.ts.map +1 -1
- package/dist/server.d.ts +11 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +208 -17
- package/dist/testing.js.map +4 -4
- package/dist/workers/cache-archive-routes.d.ts +24 -0
- package/dist/workers/cache-archive-routes.d.ts.map +1 -0
- package/dist/workers/harness-sign-ins.d.ts +32 -1
- package/dist/workers/harness-sign-ins.d.ts.map +1 -1
- package/dist/workers/machine-store.d.ts +37 -0
- package/dist/workers/machine-store.d.ts.map +1 -1
- package/dist/workers/member-machine-routes.d.ts +3 -0
- package/dist/workers/member-machine-routes.d.ts.map +1 -1
- package/dist/workers/member-machines.d.ts +52 -5
- package/dist/workers/member-machines.d.ts.map +1 -1
- package/dist/workers/placement.d.ts +10 -0
- package/dist/workers/placement.d.ts.map +1 -1
- package/dist/workers/sign-in-store.d.ts +67 -0
- package/dist/workers/sign-in-store.d.ts.map +1 -0
- package/dist/workers/sign-ins.d.ts +4 -6
- package/dist/workers/sign-ins.d.ts.map +1 -1
- package/dist/workers/worker-protocol.d.ts +9 -1
- package/dist/workers/worker-protocol.d.ts.map +1 -1
- package/dist/workers/worker-registry.d.ts +20 -6
- package/dist/workers/worker-registry.d.ts.map +1 -1
- package/dist/workers/worker-runtime.d.ts.map +1 -1
- package/package.json +18 -19
- package/src/cluster.ts +62 -7
- package/src/index.ts +7 -0
- package/src/machines/contract-kit.ts +1 -1
- package/src/machines/contract.ts +191 -19
- package/src/machines/sequencer.ts +106 -11
- package/src/machines/simulation.ts +370 -20
- package/src/machines/work-machines.ts +33 -3
- package/src/server.ts +106 -9
- package/src/testing.ts +1 -0
- package/src/workers/cache-archive-routes.ts +125 -0
- package/src/workers/harness-sign-ins.ts +207 -22
- package/src/workers/machine-store.ts +337 -56
- package/src/workers/member-machine-routes.ts +58 -3
- package/src/workers/member-machines.ts +168 -14
- package/src/workers/placement.ts +7 -0
- package/src/workers/sign-in-store.ts +241 -0
- package/src/workers/sign-ins.ts +9 -33
- package/src/workers/worker-protocol.ts +9 -1
- package/src/workers/worker-registry.ts +47 -6
- package/src/workers/worker-runtime.ts +5 -1
- package/dist/chunk-kcck20aw.js.map +0 -11
|
@@ -26,9 +26,24 @@ export interface DesiredMachine {
|
|
|
26
26
|
name: string;
|
|
27
27
|
/**
|
|
28
28
|
* Who may place work here: users, projects, chat keys. Omitted: anyone
|
|
29
|
-
* whose role and Environment allow it. An empty list: nobody
|
|
29
|
+
* whose role and Environment allow it. An empty list: nobody.
|
|
30
30
|
*/
|
|
31
31
|
for?: readonly MachinePrincipal[];
|
|
32
|
+
/**
|
|
33
|
+
* A spare for one project's chats (ADR 0360): `for` names that project
|
|
34
|
+
* alone. It takes the project's cache fills and preparations, and the
|
|
35
|
+
* first chat with a chat key placed on it takes the machine: as Work
|
|
36
|
+
* places that chat, under the machine's lock, it narrows `for` to that
|
|
37
|
+
* key, so no second key is placed there. Nothing is reset. Plan it for
|
|
38
|
+
* its key from then on (its facts say whose it is), or drop it.
|
|
39
|
+
*/
|
|
40
|
+
spare?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The project that accounts for the machine (ADR 0364): its events are
|
|
43
|
+
* recorded for that project as well as the projects in `for`, so its
|
|
44
|
+
* workflows hear about its people's machines. It grants nobody access.
|
|
45
|
+
*/
|
|
46
|
+
project?: string;
|
|
32
47
|
/** Labels an Environment's `pool` selects on. */
|
|
33
48
|
labels?: Readonly<Record<string, string>>;
|
|
34
49
|
/** Default "running". "stopped" keeps the disk. */
|
|
@@ -48,6 +63,8 @@ export interface DesiredMachine {
|
|
|
48
63
|
export declare const DesiredMachineSchema: z.ZodObject<{
|
|
49
64
|
name: z.ZodString;
|
|
50
65
|
for: z.ZodOptional<z.ZodArray<z.ZodType<MachinePrincipal, MachinePrincipal, z.core.$ZodTypeInternals<MachinePrincipal, MachinePrincipal>>>>;
|
|
66
|
+
spare: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
project: z.ZodOptional<z.ZodUUID>;
|
|
51
68
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
52
69
|
state: z.ZodOptional<z.ZodEnum<{
|
|
53
70
|
running: "running";
|
|
@@ -63,6 +80,8 @@ export declare const MAX_PLANNED_MACHINES = 1000;
|
|
|
63
80
|
export declare const MachinePlanSchema: z.ZodArray<z.ZodObject<{
|
|
64
81
|
name: z.ZodString;
|
|
65
82
|
for: z.ZodOptional<z.ZodArray<z.ZodType<MachinePrincipal, MachinePrincipal, z.core.$ZodTypeInternals<MachinePrincipal, MachinePrincipal>>>>;
|
|
83
|
+
spare: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
project: z.ZodOptional<z.ZodUUID>;
|
|
66
85
|
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
67
86
|
state: z.ZodOptional<z.ZodEnum<{
|
|
68
87
|
running: "running";
|
|
@@ -81,14 +100,31 @@ export declare const MachinePlanSchema: z.ZodArray<z.ZodObject<{
|
|
|
81
100
|
* - `serving`: connected and taking work.
|
|
82
101
|
* - `draining`: the plan no longer names it; it takes no new work and is
|
|
83
102
|
* destroyed once it holds none.
|
|
84
|
-
* - `stopping`, `stopped`, `resuming`: its disk is kept
|
|
85
|
-
* capacity until it
|
|
103
|
+
* - `stopping`, `stopped`, `resuming`: its disk is kept, and the quiet
|
|
104
|
+
* workspaces it stopped with (ADR 0361); it offers no capacity until it
|
|
105
|
+
* serves again.
|
|
86
106
|
* - `unreachable`: it was serving and has not called since its lease lapsed.
|
|
87
107
|
* - `lost`: unreachable for its limit; its work is retired.
|
|
88
108
|
* - `disabled`: an operator disabled it; its work waits and it is never lost.
|
|
89
109
|
* - `destroying`: Work is asking the hook to destroy it.
|
|
90
110
|
*/
|
|
91
111
|
export type MachineState = "starting" | "serving" | "draining" | "stopping" | "stopped" | "resuming" | "unreachable" | "lost" | "disabled" | "destroying";
|
|
112
|
+
/**
|
|
113
|
+
* A machine's preparation for one Environment of a project (ADR 0360).
|
|
114
|
+
* `prepared`: the Environment's image is on the machine and each cache it
|
|
115
|
+
* declares has a copy there, so a chat placed on it builds and fills
|
|
116
|
+
* nothing. `preparing`: on its way. `failed`: see `error`; ask again.
|
|
117
|
+
*/
|
|
118
|
+
export interface MachinePreparation {
|
|
119
|
+
project: string;
|
|
120
|
+
environment: string;
|
|
121
|
+
status: "preparing" | "prepared" | "failed";
|
|
122
|
+
/** The published revision it was prepared from; null until it starts. */
|
|
123
|
+
commit: string | null;
|
|
124
|
+
error: string | null;
|
|
125
|
+
/** Since when it is in `status` (ISO 8601). */
|
|
126
|
+
since: string;
|
|
127
|
+
}
|
|
92
128
|
/** One machine Work knows, as the plan reads it. */
|
|
93
129
|
export interface MachineFacts {
|
|
94
130
|
name: string;
|
|
@@ -102,17 +138,36 @@ export interface MachineFacts {
|
|
|
102
138
|
labels: Readonly<Record<string, string>>;
|
|
103
139
|
/** Who may place work here; null for anyone. */
|
|
104
140
|
for: readonly MachinePrincipal[] | null;
|
|
141
|
+
/** A spare no chat key has taken yet (ADR 0360). */
|
|
142
|
+
spare: boolean;
|
|
143
|
+
/** The project that accounts for it, as the plan named it (ADR 0364). */
|
|
144
|
+
project: string | null;
|
|
145
|
+
/** What it was prepared for, so a plan tells a warm machine from a cold one. */
|
|
146
|
+
preparations: readonly MachinePreparation[];
|
|
105
147
|
trusted: boolean;
|
|
106
148
|
/** The options it was created with. */
|
|
107
149
|
options: Readonly<Record<string, unknown>>;
|
|
108
150
|
reason: string | null;
|
|
109
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* Live workspaces on it and whose they are, and the stopped workspaces it
|
|
153
|
+
* keeps (ADR 0361): saved, their sandboxes stopped, each woken when its
|
|
154
|
+
* chat next works while the machine serves.
|
|
155
|
+
*/
|
|
110
156
|
holding: {
|
|
111
157
|
workspaces: number;
|
|
158
|
+
stopped: number;
|
|
112
159
|
for: readonly MachinePrincipal[];
|
|
113
160
|
};
|
|
114
|
-
/**
|
|
115
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Since when nothing on it has been in use (ADR 0361), while it serves or
|
|
163
|
+
* drains: it holds no live workspace, or every one it holds is quiet (no
|
|
164
|
+
* turn queued, held or running in a chat working there, no terminal,
|
|
165
|
+
* preview or workflow command in the last two minutes, no preparation).
|
|
166
|
+
* Null while something is in use, or while it does not serve. A plan
|
|
167
|
+
* stops a machine quiet for long enough: Work stops its quiet workspaces
|
|
168
|
+
* with it and keeps them.
|
|
169
|
+
*/
|
|
170
|
+
quietSince: string | null;
|
|
116
171
|
/** When its worker last called; null before its first call. */
|
|
117
172
|
lastSeenAt: string | null;
|
|
118
173
|
/** What it offers, from its worker's own report; null before it first connected. */
|
|
@@ -148,13 +203,22 @@ export interface MachineFacts {
|
|
|
148
203
|
at: string;
|
|
149
204
|
} | null;
|
|
150
205
|
}
|
|
151
|
-
export type MachineVerb = "create" | "destroy" | "stop" | "start" | "describe";
|
|
206
|
+
export type MachineVerb = "create" | "destroy" | "stop" | "start" | "describe" | "onConnected";
|
|
207
|
+
/**
|
|
208
|
+
* Minutes a sign-in begun on a stopped machine waits for it (ADR 0363):
|
|
209
|
+
* after this it is no reason for the machine to start.
|
|
210
|
+
*/
|
|
211
|
+
export declare const SIGN_IN_WAIT_MINUTES = 10;
|
|
152
212
|
/** Work that has no machine yet. */
|
|
153
213
|
export interface WaitingWork {
|
|
154
|
-
/** The chat's or
|
|
214
|
+
/** The chat's, run's or sign-in's id. */
|
|
155
215
|
id: string;
|
|
156
|
-
/**
|
|
157
|
-
|
|
216
|
+
/**
|
|
217
|
+
* A chat, a workflow run, a cache fill, or a member's sign-in begun on a
|
|
218
|
+
* stopped machine of their own (ADR 0363), which needs that machine
|
|
219
|
+
* running and no workspace on it.
|
|
220
|
+
*/
|
|
221
|
+
kind: "chat" | "run" | "fill" | "sign-in";
|
|
158
222
|
project: string;
|
|
159
223
|
/** The member whose work it is; null for the project's own. */
|
|
160
224
|
user: string | null;
|
|
@@ -175,6 +239,14 @@ export interface WaitingWork {
|
|
|
175
239
|
};
|
|
176
240
|
/** No machine open to it had room (`capacity`), or none was online (`unavailable`). */
|
|
177
241
|
reason: "capacity" | "unavailable";
|
|
242
|
+
/**
|
|
243
|
+
* The one machine it waits for, by name, which only that machine takes:
|
|
244
|
+
* the machine keeping the chat's stopped workspace (ADR 0361), or the
|
|
245
|
+
* member's machine a sign-in was begun on (ADR 0363). Null for work any
|
|
246
|
+
* machine open to it takes. A plan starts that machine and makes no
|
|
247
|
+
* other for it.
|
|
248
|
+
*/
|
|
249
|
+
machine: string | null;
|
|
178
250
|
/** ISO 8601. */
|
|
179
251
|
waitingSince: string;
|
|
180
252
|
}
|
|
@@ -276,6 +348,8 @@ export interface MachineEvent {
|
|
|
276
348
|
managed: boolean;
|
|
277
349
|
labels: Readonly<Record<string, string>>;
|
|
278
350
|
for: readonly MachinePrincipal[] | null;
|
|
351
|
+
/** The project that accounts for it; null for none. */
|
|
352
|
+
project: string | null;
|
|
279
353
|
options: Readonly<Record<string, unknown>>;
|
|
280
354
|
reason: string | null;
|
|
281
355
|
};
|
|
@@ -322,8 +396,10 @@ export interface MachinesHook {
|
|
|
322
396
|
done: boolean;
|
|
323
397
|
}>;
|
|
324
398
|
/**
|
|
325
|
-
* Stop the machine and keep its disk.
|
|
326
|
-
*
|
|
399
|
+
* Stop the machine and keep its disk. Work asks once everything on it is
|
|
400
|
+
* quiet, having stopped its workspaces (ADR 0361). `requestedAt` is
|
|
401
|
+
* stable for this stop request. Without a stop verb, no machine is
|
|
402
|
+
* stopped.
|
|
327
403
|
*/
|
|
328
404
|
stop?(args: MachineTarget & {
|
|
329
405
|
requestedAt: string;
|
|
@@ -351,7 +427,51 @@ export interface MachinesHook {
|
|
|
351
427
|
* also records each for the projects named in the machine's `for`.
|
|
352
428
|
*/
|
|
353
429
|
onEvent?(event: MachineEvent): Promise<void> | void;
|
|
430
|
+
/**
|
|
431
|
+
* Run when a machine's worker connected and it serves (ADR 0360): made
|
|
432
|
+
* through this hook, resumed, or enrolled by hand. Plain host code: it
|
|
433
|
+
* may prepare the machine for the Environments it will run, start a
|
|
434
|
+
* workflow, or tell another system. Work calls it once per connection
|
|
435
|
+
* and again until it resolves, so make it safe to repeat. Nothing waits
|
|
436
|
+
* for it: the machine takes work meanwhile.
|
|
437
|
+
*/
|
|
438
|
+
onConnected?(args: MachineConnected): Promise<void> | void;
|
|
354
439
|
}
|
|
440
|
+
/** What `onConnected` is given. */
|
|
441
|
+
export interface MachineConnected {
|
|
442
|
+
/** The machine as the plan reads it. */
|
|
443
|
+
machine: MachineFacts;
|
|
444
|
+
/**
|
|
445
|
+
* Prepare this machine for an Environment of a project, before any chat
|
|
446
|
+
* needs it: its image is built or pulled there, and each cache it
|
|
447
|
+
* declares is filled there (restored from the host's cache store where it
|
|
448
|
+
* holds one). Answers at once; the machine's `preparations` say how it
|
|
449
|
+
* goes. Safe to call again: it joins the preparation under way and starts
|
|
450
|
+
* a failed one again.
|
|
451
|
+
*/
|
|
452
|
+
prepare(args: {
|
|
453
|
+
project: string;
|
|
454
|
+
environment: string;
|
|
455
|
+
/** A revision of main that went live; the current one by default. */
|
|
456
|
+
commit?: string;
|
|
457
|
+
}): Promise<MachinePreparation>;
|
|
458
|
+
}
|
|
459
|
+
/** The project a spare is for: its one principal, a project with no key. */
|
|
460
|
+
export declare function spareProject(principals: readonly MachinePrincipal[] | null | undefined): string | undefined;
|
|
461
|
+
/**
|
|
462
|
+
* The chat key a spare of `project` was handed to: its one principal now, a
|
|
463
|
+
* key of that project.
|
|
464
|
+
*/
|
|
465
|
+
export declare function handedOffKey(args: {
|
|
466
|
+
project: string;
|
|
467
|
+
for: readonly MachinePrincipal[] | null;
|
|
468
|
+
}): string | undefined;
|
|
469
|
+
/** Whether a machine is prepared for an Environment of a project. */
|
|
470
|
+
export declare function preparedFor(args: {
|
|
471
|
+
machine: Pick<MachineFacts, "preparations">;
|
|
472
|
+
project: string;
|
|
473
|
+
environment: string;
|
|
474
|
+
}): boolean;
|
|
355
475
|
/** Whether two principals name the same thing. */
|
|
356
476
|
export declare function samePrincipal(left: MachinePrincipal, right: MachinePrincipal): boolean;
|
|
357
477
|
/**
|
|
@@ -375,9 +495,13 @@ export declare function samePrincipals(left: readonly MachinePrincipal[] | null,
|
|
|
375
495
|
export declare function servesOneOwner(principals: readonly MachinePrincipal[] | null): boolean;
|
|
376
496
|
/** A machine taking no one's work: any isolation is enough. */
|
|
377
497
|
export declare function servesNobody(principals: readonly MachinePrincipal[] | null): boolean;
|
|
378
|
-
/**
|
|
498
|
+
/**
|
|
499
|
+
* Whether a machine for `principals` takes this waiting work. A spare takes
|
|
500
|
+
* only its project's chats that have a key, and its cache fills.
|
|
501
|
+
*/
|
|
379
502
|
export declare function principalsTake(args: {
|
|
380
503
|
for: readonly MachinePrincipal[] | null;
|
|
381
|
-
|
|
504
|
+
spare?: boolean;
|
|
505
|
+
work: Pick<WaitingWork, "project" | "user" | "key" | "kind">;
|
|
382
506
|
}): boolean;
|
|
383
507
|
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/machines/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/machines/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAC5C,gBAAgB,EAChB,gBAAgB,CAQhB,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,eAAe,YAAI,MAAM,EAAE,OAAO,CAAU,CAAC;AAE1D,eAAO,MAAM,mBAAmB,uCAa7B,CAAC;AAEJ,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,aAK3B,CAAC;AAEJ,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,mDAAmD;IACnD,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC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;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,IAAI,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACzC,EAAE,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;CACxC,GAAG,OAAO,CAKV;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,SAAS,gBAAgB,EAAE,GACtC,gBAAgB,EAAE,CAWpB;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,EACxC,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,GACxC,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,GAC7C,OAAO,CAET;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,GAC7C,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;CAC9D,GAAG,OAAO,CAcV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DesiredMachine, type MachineEvent, type MachineFacts, type MachinePrincipal, type MachineState, type MachinesHook, type MachineVerb, type PersonFacts, type WaitingWork } from "./contract.js";
|
|
1
|
+
import { type DesiredMachine, type MachineEvent, type MachineFacts, type MachinePreparation, type MachinePrincipal, type MachineState, type MachinesHook, type MachineVerb, type PersonFacts, type WaitingWork } from "./contract.js";
|
|
2
2
|
/** Where Work stands with a machine; what it stores. */
|
|
3
3
|
export type MachinePhase = "starting" | "running" | "stopping" | "stopped" | "resuming" | "destroying";
|
|
4
4
|
/**
|
|
@@ -32,11 +32,17 @@ export interface MachineRecord {
|
|
|
32
32
|
lostAfterMinutes: number | null;
|
|
33
33
|
/** An operator revoked its worker. */
|
|
34
34
|
revoked: boolean;
|
|
35
|
+
/** Its worker connected, and the host's `onConnected` has not heard yet. */
|
|
36
|
+
connectedPending: boolean;
|
|
35
37
|
}
|
|
36
38
|
/** A desired machine with every default filled in. */
|
|
37
39
|
export interface PlannedMachine {
|
|
38
40
|
name: string;
|
|
39
41
|
for: readonly MachinePrincipal[] | null;
|
|
42
|
+
/** A spare the first chat key placed on it takes (ADR 0360). */
|
|
43
|
+
spare: boolean;
|
|
44
|
+
/** The project that accounts for it (ADR 0364). */
|
|
45
|
+
project: string | null;
|
|
40
46
|
labels: Readonly<Record<string, string>>;
|
|
41
47
|
state: "running" | "stopped";
|
|
42
48
|
options: Readonly<Record<string, unknown>>;
|
|
@@ -90,6 +96,22 @@ export interface MachineWorld {
|
|
|
90
96
|
trusted: boolean;
|
|
91
97
|
reason: string | null;
|
|
92
98
|
lostAfterMinutes: number | null;
|
|
99
|
+
spare: boolean;
|
|
100
|
+
project: string | null;
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Prepare a machine for an Environment of a project (ADR 0360): join the
|
|
104
|
+
* preparation under way, start one, or start a failed one again.
|
|
105
|
+
*/
|
|
106
|
+
prepare(args: {
|
|
107
|
+
name: string;
|
|
108
|
+
project: string;
|
|
109
|
+
environment: string;
|
|
110
|
+
commit?: string;
|
|
111
|
+
}): Promise<MachinePreparation>;
|
|
112
|
+
/** The host's `onConnected` heard this connection. */
|
|
113
|
+
heardConnected(args: {
|
|
114
|
+
name: string;
|
|
93
115
|
}): Promise<void>;
|
|
94
116
|
/** Whom it is for from now on; also ends a reset that is no longer wanted. */
|
|
95
117
|
setFor(args: {
|
|
@@ -133,8 +155,9 @@ export interface MachineWorld {
|
|
|
133
155
|
unseenForMs: number;
|
|
134
156
|
}): Promise<boolean>;
|
|
135
157
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
158
|
+
* Stop its quiet workspaces, then take no new work and become
|
|
159
|
+
* `stopping`, under its lock (ADR 0361): only while every workspace it
|
|
160
|
+
* holds is stopped. False while something on it is in use.
|
|
138
161
|
*/
|
|
139
162
|
beginStop(args: {
|
|
140
163
|
name: string;
|
|
@@ -258,10 +281,14 @@ export declare function runMachinePass(args: {
|
|
|
258
281
|
}): Promise<MachinePassSummary>;
|
|
259
282
|
/**
|
|
260
283
|
* Whether a machine would take a piece of waiting work once it serves: its
|
|
261
|
-
* labels (and `plane: worker`) satisfy the work's pool,
|
|
262
|
-
* work's owner
|
|
284
|
+
* labels (and `plane: worker`) satisfy the work's pool, it is for the
|
|
285
|
+
* work's owner, and it is the machine the work waits for by name, if any
|
|
286
|
+
* (its stopped workspace is there, ADR 0361, or a member's sign-in was
|
|
287
|
+
* begun on it, ADR 0363).
|
|
263
288
|
*/
|
|
264
|
-
export declare function machineTakes(machine: Pick<MachineFacts, "
|
|
289
|
+
export declare function machineTakes(machine: Pick<MachineFacts, "name" | "labels" | "for"> & {
|
|
290
|
+
spare?: boolean;
|
|
291
|
+
}, work: Pick<WaitingWork, "pool" | "project" | "user" | "key" | "kind" | "machine">): boolean;
|
|
265
292
|
/** JSON with sorted keys: stored jsonb reorders keys, so compare this way. */
|
|
266
293
|
export declare function canonical(value: unknown): string;
|
|
267
294
|
//# sourceMappingURL=sequencer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/machines/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/machines/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,cAAc,EAKnB,KAAK,YAAY,EAEjB,KAAK,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,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsE9B;AAmiBD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC,GAAG;IACvD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,EACD,IAAI,EAAE,IAAI,CACR,WAAW,EACX,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CACzD,GACA,OAAO,CAWT;AA2GD,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUhD"}
|
|
@@ -13,12 +13,36 @@ export interface SimulatedCall {
|
|
|
13
13
|
/** What it threw. */
|
|
14
14
|
error?: string;
|
|
15
15
|
}
|
|
16
|
+
/** How a piece of work started on its machine. */
|
|
17
|
+
export interface SimulatedStart {
|
|
18
|
+
machine: string;
|
|
19
|
+
/** ISO 8601, by the simulation's clock. */
|
|
20
|
+
at: string;
|
|
21
|
+
/**
|
|
22
|
+
* What its own preparation had to do there: build or pull the
|
|
23
|
+
* Environment's image, fill its caches. Both false on a machine prepared
|
|
24
|
+
* for its Environment.
|
|
25
|
+
*/
|
|
26
|
+
imageBuilt: boolean;
|
|
27
|
+
cachesFilled: boolean;
|
|
28
|
+
}
|
|
16
29
|
export interface SimulatedWorkOptions {
|
|
17
30
|
hook: MachinesHook;
|
|
18
31
|
/** ISO 8601 start of the simulation's clock. */
|
|
19
32
|
start?: string;
|
|
20
33
|
/** Seconds a created or started machine takes to connect (default 60). */
|
|
21
34
|
bootSeconds?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Seconds a preparation takes: the image build and the cache fills
|
|
37
|
+
* (default 600).
|
|
38
|
+
*/
|
|
39
|
+
prepareSeconds?: number;
|
|
40
|
+
/** A preparation that fails, with this error, instead of finishing. */
|
|
41
|
+
failPreparation?: (args: {
|
|
42
|
+
machine: string;
|
|
43
|
+
project: string;
|
|
44
|
+
environment: string;
|
|
45
|
+
}) => string | undefined;
|
|
22
46
|
/** Workspaces one machine holds at once (default 4). */
|
|
23
47
|
workspacesPerMachine?: number;
|
|
24
48
|
/** How machines isolate agents (default "sandbox"). */
|
|
@@ -40,6 +64,7 @@ export declare class SimulatedWork {
|
|
|
40
64
|
private readonly machines;
|
|
41
65
|
private waitingWork;
|
|
42
66
|
private readonly waitingFor;
|
|
67
|
+
private readonly starts;
|
|
43
68
|
private workCount;
|
|
44
69
|
private generations;
|
|
45
70
|
private readonly neverConnect;
|
|
@@ -60,12 +85,37 @@ export declare class SimulatedWork {
|
|
|
60
85
|
} | undefined;
|
|
61
86
|
/** Where a piece of work runs, once it has a machine. */
|
|
62
87
|
placedOn(workId: string): string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* How a piece of work started: on which machine, and whether its own
|
|
90
|
+
* preparation built the image or filled the caches there.
|
|
91
|
+
*/
|
|
92
|
+
startOf(workId: string): SimulatedStart | undefined;
|
|
63
93
|
/** Add work that needs a machine; it waits until one takes it. */
|
|
64
94
|
addWork(work: Partial<Omit<WaitingWork, "id">> & {
|
|
65
95
|
project: string;
|
|
66
96
|
}): WaitingWork;
|
|
67
97
|
/** The work ended: its workspace is given back. */
|
|
68
98
|
finishWork(workId: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* The work's turn ended and nobody uses its workspace (ADR 0361): the
|
|
101
|
+
* machine keeps it, quiet, and may stop with it.
|
|
102
|
+
*/
|
|
103
|
+
quietWork(workId: string): void;
|
|
104
|
+
/**
|
|
105
|
+
* The work's chat works again in its kept workspace (ADR 0361): a quiet
|
|
106
|
+
* one is busy at once; a stopped one is woken while its machine serves,
|
|
107
|
+
* or waits for that machine by name.
|
|
108
|
+
*/
|
|
109
|
+
workAgain(workId: string): void;
|
|
110
|
+
private heldWorkspace;
|
|
111
|
+
/** It takes work now: running, live, and neither dropped nor being reset. */
|
|
112
|
+
private serves;
|
|
113
|
+
/**
|
|
114
|
+
* A machine's stopped workspaces go with it (ADR 0361): work waiting for
|
|
115
|
+
* it waits for any machine open to it instead. A sign-in stays for its
|
|
116
|
+
* member's machine (ADR 0363).
|
|
117
|
+
*/
|
|
118
|
+
private forgetStopped;
|
|
69
119
|
/** An operator enrolls a machine by hand; it connects after it boots. */
|
|
70
120
|
enrollByHand(args: {
|
|
71
121
|
name: string;
|
|
@@ -81,6 +131,18 @@ export declare class SimulatedWork {
|
|
|
81
131
|
neverConnects(name: string): void;
|
|
82
132
|
/** An operator disables or enables a machine. */
|
|
83
133
|
setDisabled(name: string, disabled: boolean): void;
|
|
134
|
+
/**
|
|
135
|
+
* A member begins a sign-in on a stopped machine of their own (ADR
|
|
136
|
+
* 0363): work for exactly that machine, which it takes once it serves
|
|
137
|
+
* (the app begins the sign-in again there). It holds no workspace, and
|
|
138
|
+
* after {@link SIGN_IN_WAIT_MINUTES} it waits no more.
|
|
139
|
+
*/
|
|
140
|
+
beginSignIn(args: {
|
|
141
|
+
machine: string;
|
|
142
|
+
member: string;
|
|
143
|
+
project: string;
|
|
144
|
+
environment?: string;
|
|
145
|
+
}): WaitingWork;
|
|
84
146
|
/**
|
|
85
147
|
* The next create's answer is lost on its way back (the server stopped,
|
|
86
148
|
* the network failed): the hook made its machine, and Work must ask again.
|
|
@@ -111,6 +173,8 @@ export declare class SimulatedWork {
|
|
|
111
173
|
/** Boot what is due, renew what is alive, and place waiting work. */
|
|
112
174
|
private tick;
|
|
113
175
|
private place;
|
|
176
|
+
private warm;
|
|
177
|
+
private preparationsOf;
|
|
114
178
|
private emit;
|
|
115
179
|
private records;
|
|
116
180
|
/** The hook, with every call recorded and a lost answer simulated. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../src/machines/simulation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../src/machines/simulation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAGhB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,kBAAkB,EAQxB,MAAM,gBAAgB,CAAC;AAcxB,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB;AAgED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,YAAY,CAAC;IACnB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA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Ac;IAWtB,OAAO,CAAC,IAAI;IAmBZ,OAAO,CAAC,OAAO;IAoHf,sEAAsE;IACtE,OAAO,CAAC,aAAa;IAkGrB,OAAO,CAAC,KAAK;IAkPb,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7B;CACF;AAMD,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAejE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type WorkWakeups } from "@catamorphic/core";
|
|
2
2
|
import type { DB } from "@catamorphic/db";
|
|
3
3
|
import type { Kysely } from "kysely";
|
|
4
|
-
import type
|
|
5
|
-
import type { MachineEvent, MachinesHook, PersonFacts } from "./contract.js";
|
|
4
|
+
import { type WorkWorkerRegistry } from "../workers/worker-registry.js";
|
|
5
|
+
import type { MachineEvent, MachinePreparation, MachinesHook, PersonFacts } from "./contract.js";
|
|
6
6
|
import { type MachinePassSummary, type MachineWorld } from "./sequencer.js";
|
|
7
7
|
/** How often a replica looks for change a plan reads (see `check`). */
|
|
8
8
|
export declare const MACHINE_CHECK_INTERVAL_MS = 10000;
|
|
@@ -19,6 +19,24 @@ export declare function workMachineWorld(deps: {
|
|
|
19
19
|
controlPlaneUrl: string;
|
|
20
20
|
people: () => Promise<PersonFacts[]>;
|
|
21
21
|
event: (event: MachineEvent) => Promise<void>;
|
|
22
|
+
/** Prepare a machine for an Environment of a project (ADR 0360). */
|
|
23
|
+
prepare: (args: {
|
|
24
|
+
name: string;
|
|
25
|
+
project: string;
|
|
26
|
+
environment: string;
|
|
27
|
+
commit?: string;
|
|
28
|
+
}) => Promise<MachinePreparation>;
|
|
29
|
+
/**
|
|
30
|
+
* Stop a machine's quiet workspaces before it stops (ADR 0361): core's
|
|
31
|
+
* `stopQuietWorkspaces`. Without it, a machine stops only once it holds
|
|
32
|
+
* no workspace at all.
|
|
33
|
+
*/
|
|
34
|
+
stopQuietWorkspaces?: (args: {
|
|
35
|
+
workerNodeId: string;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
stopped: number;
|
|
38
|
+
busy: number;
|
|
39
|
+
}>;
|
|
22
40
|
resetWaitMs?: number;
|
|
23
41
|
}): MachineWorld;
|
|
24
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-machines.d.ts","sourceRoot":"","sources":["../../src/machines/work-machines.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"work-machines.d.ts","sourceRoot":"","sources":["../../src/machines/work-machines.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AAOxB,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,eAAe,EA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A6D;IAC7D,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAYlC;IAED,wFAAwF;IACxF,QAAQ,IAAI,IAAI,CAIf;IAED,4DAA4D;IACtD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAE5B;IAED;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED;;;;;;;;OAQG;IACG,KAAK,CAAC,IAAI,EAAE;QAChB,MAAM,EAAE,WAAW,CAAC;QACpB,OAAO,EAAE,WAAW,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB;IAED,OAAO,KAAK,OAAO,GAElB;YAEa,WAAW;CAyE1B"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentCapabilityOptions } from "@catamorphic/core";
|
|
2
|
-
import { type ConnectionActionGuard, type ConnectionProvider, type ModelRequestRewrite } from "@catamorphic/core";
|
|
2
|
+
import { type CacheStore, type ConnectionActionGuard, type ConnectionProvider, type ModelRequestRewrite } from "@catamorphic/core";
|
|
3
3
|
import { type Catamorphic, type CreateCatamorphicConfig, type GithubConnectionOptions } from "@catamorphic/server-sdk";
|
|
4
4
|
import { type FastifyInstance } from "fastify";
|
|
5
5
|
import type { WorkAuth } from "./auth/work-auth-types.js";
|
|
@@ -77,6 +77,16 @@ export interface WorkServerHooks {
|
|
|
77
77
|
* registry packs. With no hook, machines are enrolled by hand.
|
|
78
78
|
*/
|
|
79
79
|
machines?: MachinesHook;
|
|
80
|
+
/**
|
|
81
|
+
* The host's cache store (ADR 0360): where every machine's copy of an
|
|
82
|
+
* Environment cache can come from. After a trusted fill publishes a cache
|
|
83
|
+
* on one machine Work saves it there, and a machine that lacks the cache
|
|
84
|
+
* restores it from there before it fills from nothing. Two verbs, `save`
|
|
85
|
+
* and `restore`, over streams; the registry ships one for a shared
|
|
86
|
+
* directory. Archives pass through this server on their way, a cache's
|
|
87
|
+
* size at a time. With no store, every machine fills its own.
|
|
88
|
+
*/
|
|
89
|
+
cacheStore?: CacheStore;
|
|
80
90
|
/** Mount additional host routes on the public application. */
|
|
81
91
|
routes?: (args: {
|
|
82
92
|
app: FastifyInstance;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAIvB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EAIvB,KAAK,mBAAmB,EAMzB,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAQ5B,KAAK,uBAAuB,EAY7B,MAAM,yBAAyB,CAAC;AAKjC,OAAgB,EAAE,KAAK,eAAe,EAAuB,MAAM,SAAS,CAAC;AAgB7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAQ1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAWpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAEV,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAyChC;;;;;;GAMG;AAEH,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,yCAAyC,CA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,KAAK,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,GAAG,EAAE,eAAe,CAAC;IACrB,yEAAyE;IACzE,WAAW,EAAE,eAAe,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;IACzB,iEAAiE;IACjE,QAAQ,EAAE,QAAQ,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAsBrB"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* `SimulatedWork` is that simulation, for a host's own scenarios.
|
|
5
5
|
*/
|
|
6
6
|
export { type ContractFacts, checkMachineProvisioner, checkMachinesHook, type MachineProvisioner, MachinesContractError, MemoryCloud, type MemoryCloudMachine, machinesHook, type PlatformProbe, } from "./machines/contract-kit.js";
|
|
7
|
-
export { quietSummary, type SimulatedCall, SimulatedWork, type SimulatedWorkOptions, } from "./machines/simulation.js";
|
|
7
|
+
export { quietSummary, type SimulatedCall, type SimulatedStart, SimulatedWork, type SimulatedWorkOptions, } from "./machines/simulation.js";
|
|
8
8
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,KAAK,aAAa,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,WAAW,EACX,KAAK,kBAAkB,EACvB,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,KAAK,aAAa,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,WAAW,EACX,KAAK,kBAAkB,EACvB,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC"}
|