@catamorphic/work-server 0.1.0-alpha.39 → 0.1.0-alpha.42
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 +31 -21
- 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,69 +1,88 @@
|
|
|
1
1
|
import type { Identity, WorkerNode } from "@catamorphic/core";
|
|
2
|
-
import { type
|
|
3
|
-
import {
|
|
2
|
+
import { type SignInHarness } from "@catamorphic/sandbox";
|
|
3
|
+
import type { MachineFacts, MachineState } from "../machines/contract.js";
|
|
4
|
+
import { type HarnessSignInRequest, type HarnessSignInStarted, type HarnessSignInStatus, type HarnessSignIns } from "./harness-sign-ins.js";
|
|
5
|
+
export type MemberSignInState = "signed-in" | "signed-out";
|
|
4
6
|
export interface MemberMachine {
|
|
5
7
|
id: string;
|
|
6
8
|
name: string;
|
|
9
|
+
/** Connected and taking work now. */
|
|
7
10
|
available: boolean;
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Where the machine stands (ADRs 0349, 0350), so its owner sees that it
|
|
13
|
+
* is starting, stopped or coming back rather than only "unavailable".
|
|
14
|
+
* `serving` for a single server's own machine.
|
|
15
|
+
*/
|
|
16
|
+
state: MachineState;
|
|
17
|
+
/** Why it exists or was stopped, when its host says. */
|
|
18
|
+
reason: string | null;
|
|
19
|
+
/** Whether the member is signed in to each harness on this machine. */
|
|
20
|
+
signIns: Record<SignInHarness, MemberSignInState>;
|
|
9
21
|
}
|
|
10
22
|
/** The machine is not one the member may sign in on. */
|
|
11
23
|
export declare class NotYourMachineError extends Error {
|
|
12
24
|
constructor();
|
|
13
25
|
}
|
|
26
|
+
/** One of the member's machines and a harness on it. */
|
|
27
|
+
interface Target {
|
|
28
|
+
identity: Identity;
|
|
29
|
+
machineId: string;
|
|
30
|
+
harness: SignInHarness;
|
|
31
|
+
}
|
|
14
32
|
export declare class MemberMachines {
|
|
15
33
|
private readonly deps;
|
|
16
34
|
constructor(deps: {
|
|
17
35
|
nodes: () => Promise<readonly WorkerNode[]>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
owner: (userId: string) => Promise<{
|
|
21
|
-
userId: string;
|
|
22
|
-
groups: string[];
|
|
23
|
-
} | undefined>;
|
|
36
|
+
/** Every machine Work knows, with whom it is for and where it stands. */
|
|
37
|
+
machines: () => Promise<readonly MachineFacts[]>;
|
|
24
38
|
/**
|
|
25
39
|
* The server's own machine, when it may hold a member's sign-in: a
|
|
26
40
|
* single server whose operator accepted personal credentials.
|
|
27
41
|
*/
|
|
28
42
|
ownMachine?: {
|
|
29
43
|
nodeId: string;
|
|
30
|
-
signIns:
|
|
44
|
+
signIns: HarnessSignIns;
|
|
31
45
|
};
|
|
32
46
|
/** A request to a worker through the operation queue. */
|
|
33
47
|
worker: (args: {
|
|
34
48
|
nodeId: string;
|
|
35
|
-
request:
|
|
49
|
+
request: HarnessSignInRequest;
|
|
36
50
|
}) => Promise<unknown>;
|
|
37
51
|
});
|
|
38
52
|
list(identity: Identity): Promise<MemberMachine[]>;
|
|
39
|
-
/** Throws {@link
|
|
40
|
-
begin(args:
|
|
41
|
-
identity: Identity;
|
|
42
|
-
machineId: string;
|
|
43
|
-
}): Promise<CodexSignInStarted>;
|
|
53
|
+
/** Throws {@link HarnessSignInRefusedError} with the machine's reason. */
|
|
54
|
+
begin(args: Target): Promise<HarnessSignInStarted>;
|
|
44
55
|
/**
|
|
45
56
|
* Where a sign-in stands. Signed in means usable: the machine placed the
|
|
46
57
|
* login and placement sees it, so a chat started at once finds it.
|
|
47
58
|
*/
|
|
48
|
-
status(args: {
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
status(args: Target & {
|
|
60
|
+
attempt: string;
|
|
61
|
+
}): Promise<HarnessSignInStatus>;
|
|
62
|
+
/**
|
|
63
|
+
* Hand a waiting login the code the member copied from their browser.
|
|
64
|
+
* Answers where the sign-in stands, never the code. Throws
|
|
65
|
+
* {@link HarnessSignInRefusedError} when the machine would not take it.
|
|
66
|
+
*/
|
|
67
|
+
input(args: Target & {
|
|
51
68
|
attempt: string;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
machineId: string;
|
|
69
|
+
text: string;
|
|
70
|
+
}): Promise<HarnessSignInStatus>;
|
|
71
|
+
cancel(args: Target & {
|
|
56
72
|
attempt: string;
|
|
57
73
|
}): Promise<void>;
|
|
58
|
-
signOut(args: {
|
|
59
|
-
identity: Identity;
|
|
60
|
-
machineId: string;
|
|
61
|
-
}): Promise<{
|
|
74
|
+
signOut(args: Target): Promise<{
|
|
62
75
|
signedOut: boolean;
|
|
63
76
|
}>;
|
|
77
|
+
/** A machine's "signed in" counts once placement sees the sign-in too. */
|
|
78
|
+
private usable;
|
|
64
79
|
/** The member's own machine gets the request, and only then. */
|
|
65
80
|
private send;
|
|
66
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The machines that are the member's own, by node id: workers for that
|
|
83
|
+
* member alone (with their facts), and a single server's own machine.
|
|
84
|
+
*/
|
|
67
85
|
private own;
|
|
68
86
|
}
|
|
87
|
+
export {};
|
|
69
88
|
//# sourceMappingURL=member-machines.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member-machines.d.ts","sourceRoot":"","sources":["../../src/workers/member-machines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"member-machines.d.ts","sourceRoot":"","sources":["../../src/workers/member-machines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAEzB,KAAK,mBAAmB,EAExB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAc/B,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB,wDAAwD;IACxD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;CACnD;AAED,wDAAwD;AACxD,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,cAGC;CACF;AAED,wDAAwD;AACxD,UAAU,MAAM;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,qBAAa,cAAc;IAE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G;YACW,GAAG;CA+BlB"}
|
|
@@ -1,59 +1,42 @@
|
|
|
1
1
|
import type { NodeAccess } from "@catamorphic/sandbox";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
import { type MachinePrincipal, RESERVED_LABELS, servesNobody, servesOneOwner } from "../machines/contract.js";
|
|
4
|
+
export { RESERVED_LABELS, servesNobody, servesOneOwner };
|
|
5
5
|
export declare const NodeLabelsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Control-plane state; a worker never declares it.
|
|
7
|
+
* A machine's placement (ADRs 0167, 0349): the labels an Environment's
|
|
8
|
+
* `pool` selects on, whom it is for (users, projects' own work, single
|
|
9
|
+
* chat keys, or anyone when absent), and whether those it serves trust
|
|
10
|
+
* each other. Control-plane state; a worker never declares it.
|
|
11
11
|
*/
|
|
12
|
-
export declare const WorkerAccessSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
13
|
-
everyone: z.ZodLiteral<true>;
|
|
14
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
-
nobody: z.ZodLiteral<true>;
|
|
16
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
17
|
-
people: z.ZodDefault<z.ZodArray<z.ZodEmail>>;
|
|
18
|
-
groups: z.ZodDefault<z.ZodArray<z.ZodEmail>>;
|
|
19
|
-
projects: z.ZodDefault<z.ZodArray<z.ZodUUID>>;
|
|
20
|
-
}, z.core.$strict>]>;
|
|
21
|
-
export type WorkerAccess = z.output<typeof WorkerAccessSchema>;
|
|
22
12
|
export declare const WorkerPlacementSchema: z.ZodObject<{
|
|
23
13
|
labels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
|
-
|
|
25
|
-
everyone: z.ZodLiteral<true>;
|
|
26
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
-
nobody: z.ZodLiteral<true>;
|
|
28
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
-
people: z.ZodDefault<z.ZodArray<z.ZodEmail>>;
|
|
30
|
-
groups: z.ZodDefault<z.ZodArray<z.ZodEmail>>;
|
|
31
|
-
projects: z.ZodDefault<z.ZodArray<z.ZodUUID>>;
|
|
32
|
-
}, z.core.$strict>]>>;
|
|
14
|
+
for: z.ZodOptional<z.ZodArray<z.ZodType<MachinePrincipal, MachinePrincipal, z.core.$ZodTypeInternals<MachinePrincipal, MachinePrincipal>>>>;
|
|
33
15
|
trusted: z.ZodDefault<z.ZodBoolean>;
|
|
34
16
|
}, z.core.$strict>;
|
|
35
|
-
export
|
|
17
|
+
export interface WorkerPlacement {
|
|
18
|
+
labels: Readonly<Record<string, string>>;
|
|
19
|
+
/** Null: anyone whose role and Environment allow it. */
|
|
20
|
+
for: readonly MachinePrincipal[] | null;
|
|
21
|
+
trusted: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A parsed placement, with "anyone" as null and principals in order. */
|
|
24
|
+
export declare function workerPlacement(input: z.input<typeof WorkerPlacementSchema>): WorkerPlacement;
|
|
36
25
|
/**
|
|
37
|
-
* A worker's placement as the scheduler reads it. A
|
|
38
|
-
*
|
|
26
|
+
* A worker's placement as the scheduler reads it. A machine that is not
|
|
27
|
+
* `accepting` (the plan dropped it, it is stopping, stopped, resuming or
|
|
28
|
+
* being reset, ADRs 0349, 0350) takes no new work and keeps serving the
|
|
29
|
+
* Allocations it holds.
|
|
39
30
|
*/
|
|
40
31
|
export type ScheduledPlacement = WorkerPlacement & {
|
|
41
|
-
|
|
32
|
+
accepting: boolean;
|
|
33
|
+
admissionRevision: string | null;
|
|
42
34
|
};
|
|
43
|
-
export declare function nodeAccess(
|
|
44
|
-
/**
|
|
45
|
-
* One named person, or one project's own work, and nobody else: no one
|
|
46
|
-
* else's work lands here, so process isolation is enough.
|
|
47
|
-
*/
|
|
48
|
-
export declare function servesOneOwner(access: WorkerAccess): boolean;
|
|
49
|
-
/** A worker taking no one's work: any isolation is enough. */
|
|
50
|
-
export declare function servesNobody(access: WorkerAccess): boolean;
|
|
51
|
-
/** The directory groups an access list names. */
|
|
52
|
-
export declare function accessGroupsOf(access: WorkerAccess): readonly string[];
|
|
35
|
+
export declare function nodeAccess(principals: readonly MachinePrincipal[] | null): NodeAccess;
|
|
53
36
|
/** Stored placement, validated on the way out of the database. */
|
|
54
37
|
export declare function storedPlacement(row: {
|
|
55
38
|
labels: unknown;
|
|
56
|
-
|
|
39
|
+
serves: unknown;
|
|
57
40
|
trusted: boolean;
|
|
58
41
|
}): WorkerPlacement;
|
|
59
42
|
//# sourceMappingURL=placement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/workers/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/workers/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,gBAAgB,EAGrB,eAAe,EACf,YAAY,EACZ,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAEzD,eAAO,MAAM,gBAAgB,uCAAsB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;kBAShC,CAAC;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzC,wDAAwD;IACxD,GAAG,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,GAC3C,eAAe,CAOjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,UAAU,CACxB,UAAU,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,GAC7C,UAAU,CAYZ;AAID,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,GAAG,EAAE;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,eAAe,CAMlB"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type SpawnSyncReturns } from "node:child_process";
|
|
2
2
|
import { type SignInHarness } from "@catamorphic/sandbox";
|
|
3
3
|
/**
|
|
4
|
-
* Members' own Codex sign-ins on this machine (ADRs 0199,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Members' own Claude Code and Codex sign-ins on this machine (ADRs 0199,
|
|
5
|
+
* 0213, 0342). Each is the harness's own home for one member under the
|
|
6
|
+
* machine's data directory, made by the harness's own unmodified login on
|
|
7
|
+
* this machine. Work never reads, copies or sends what is inside: the
|
|
8
|
+
* machine reports only who is signed in, and a sandbox of that member's
|
|
9
|
+
* chat mounts their home. What differs between harnesses is in
|
|
10
|
+
* `SIGN_IN_SPECS`.
|
|
10
11
|
*/
|
|
11
12
|
export declare function signInRoot(dataDir: string): string;
|
|
12
13
|
export interface MachineSignIn {
|
|
@@ -14,16 +15,22 @@ export interface MachineSignIn {
|
|
|
14
15
|
member: string;
|
|
15
16
|
home: string;
|
|
16
17
|
}
|
|
18
|
+
/** Whether a home holds the file its harness's completed login leaves. */
|
|
19
|
+
export declare function signedIn(input: {
|
|
20
|
+
harness: SignInHarness;
|
|
21
|
+
home: string;
|
|
22
|
+
}): boolean;
|
|
17
23
|
/** The sign-in homes on this machine that hold a completed login. */
|
|
18
24
|
export declare function listMachineSignIns(root: string): MachineSignIn[];
|
|
19
|
-
/** A machine holds one person's
|
|
25
|
+
/** A machine holds one person's sign-ins at most (ADRs 0213, 0342). */
|
|
20
26
|
export declare class MachineHeldError extends Error {
|
|
21
27
|
constructor();
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
|
-
* Refuse a member's login on a machine that holds someone else's
|
|
25
|
-
* machine signed in to several accounts reads to
|
|
26
|
-
* or resold account.
|
|
30
|
+
* Refuse a member's login on a machine that holds someone else's, of any
|
|
31
|
+
* harness: one machine signed in to several people's accounts reads to a
|
|
32
|
+
* provider as a shared or resold account. One person may hold a sign-in of
|
|
33
|
+
* each harness there.
|
|
27
34
|
*/
|
|
28
35
|
export declare function assertMachineFree(input: {
|
|
29
36
|
root: string;
|
|
@@ -36,17 +43,20 @@ export declare function assertMachineFree(input: {
|
|
|
36
43
|
*/
|
|
37
44
|
export declare function signInCapabilities(root: string): string[];
|
|
38
45
|
/**
|
|
39
|
-
* The
|
|
40
|
-
* this package carries (the version Work's Codex harness speaks),
|
|
41
|
-
* this process's runtime
|
|
46
|
+
* The CLI to sign in with: the machine's own on `PATH`. For Codex, else
|
|
47
|
+
* the one this package carries (the version Work's Codex harness speaks),
|
|
48
|
+
* run with this process's runtime: the image has no `codex` on its `PATH`.
|
|
49
|
+
* Claude Code is always the machine's own unmodified `claude`.
|
|
42
50
|
*/
|
|
43
|
-
export declare function
|
|
51
|
+
export declare function harnessCommand(harness: SignInHarness, env?: NodeJS.ProcessEnv): {
|
|
44
52
|
command: string;
|
|
45
53
|
args: string[];
|
|
46
54
|
};
|
|
47
|
-
/**
|
|
55
|
+
/** The harness's own login, pointed at one home. */
|
|
48
56
|
export declare function signInCommand(input: {
|
|
57
|
+
harness: SignInHarness;
|
|
49
58
|
home: string;
|
|
59
|
+
/** Instead of the harness's default login arguments. */
|
|
50
60
|
args?: readonly string[];
|
|
51
61
|
env?: NodeJS.ProcessEnv;
|
|
52
62
|
}): {
|
|
@@ -54,6 +64,16 @@ export declare function signInCommand(input: {
|
|
|
54
64
|
args: string[];
|
|
55
65
|
env: Record<string, string>;
|
|
56
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* The environment a login runs in: this process's, pointed at the login's
|
|
69
|
+
* home, without any variable that would hand the CLI another credential
|
|
70
|
+
* (an organization's key on a single server is not the member's sign-in).
|
|
71
|
+
*/
|
|
72
|
+
export declare function signInEnvironment(input: {
|
|
73
|
+
harness: SignInHarness;
|
|
74
|
+
base: NodeJS.ProcessEnv;
|
|
75
|
+
login: Record<string, string>;
|
|
76
|
+
}): NodeJS.ProcessEnv;
|
|
57
77
|
/**
|
|
58
78
|
* A login runs in a home of its own beside the member's, so a pending or
|
|
59
79
|
* abandoned one is never reported as signed in and never disturbs a
|
|
@@ -72,12 +92,18 @@ export declare function placeSignIn(input: {
|
|
|
72
92
|
member: string;
|
|
73
93
|
staging: string;
|
|
74
94
|
}): string;
|
|
95
|
+
/**
|
|
96
|
+
* Why a login that exited cleanly left no sign-in in its home, for a
|
|
97
|
+
* person to read. On macOS Claude Code keeps its sign-in in the Keychain,
|
|
98
|
+
* keyed to the home it ran in, which no sandbox mounts.
|
|
99
|
+
*/
|
|
100
|
+
export declare function noSignInLeft(harness: SignInHarness): string;
|
|
75
101
|
type Spawn = (command: string, args: string[], options: {
|
|
76
102
|
env: NodeJS.ProcessEnv;
|
|
77
103
|
stdio: "inherit";
|
|
78
104
|
}) => Pick<SpawnSyncReturns<Buffer>, "status" | "error">;
|
|
79
105
|
/**
|
|
80
|
-
* Run
|
|
106
|
+
* Run a harness's own login for a member, interactively, in this terminal.
|
|
81
107
|
* Only a login that completes becomes the member's home, and only on a
|
|
82
108
|
* machine that holds no one else's ({@link assertMachineFree}).
|
|
83
109
|
*/
|
|
@@ -85,12 +111,13 @@ export declare function signInOnMachine(input: {
|
|
|
85
111
|
dataDir: string;
|
|
86
112
|
harness: SignInHarness;
|
|
87
113
|
member: string;
|
|
88
|
-
/**
|
|
114
|
+
/** Instead of the harness's default login arguments. */
|
|
89
115
|
args?: readonly string[];
|
|
90
116
|
spawn?: Spawn;
|
|
91
117
|
}): {
|
|
92
118
|
home: string;
|
|
93
119
|
exitCode: number;
|
|
120
|
+
reason?: string;
|
|
94
121
|
};
|
|
95
122
|
/**
|
|
96
123
|
* Delete every member's sign-in home from this machine, when a pooled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-ins.d.ts","sourceRoot":"","sources":["../../src/workers/sign-ins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAKtE,OAAO,
|
|
1
|
+
{"version":3,"file":"sign-ins.d.ts","sourceRoot":"","sources":["../../src/workers/sign-ins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AAKtE,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAIV;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAmBhE;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* 3: the `egress.widen` and `egress.narrow` operations open a setup's
|
|
16
16
|
* network in a running sandbox and close it again (ADR 0257).
|
|
17
|
+
* 4: `machine.harnessSignIn` replaces `machine.codexSignIn`, names its
|
|
18
|
+
* harness and hands a login the code it waits for (ADR 0342); a worker of
|
|
19
|
+
* protocol 3 could parse none of it.
|
|
17
20
|
*/
|
|
18
21
|
export declare const WORKER_PROTOCOL: {
|
|
19
|
-
readonly server:
|
|
20
|
-
readonly minimum:
|
|
22
|
+
readonly server: 4;
|
|
23
|
+
readonly minimum: 4;
|
|
21
24
|
};
|
|
22
25
|
/** What a control plane answers a worker it cannot drive, with status 426. */
|
|
23
26
|
export interface UpgradeRequiredAnswer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["../../src/workers/worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"worker-protocol.d.ts","sourceRoot":"","sources":["../../src/workers/worker-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe;aAC1B,MAAM,EAAE,CAAC;aACT,OAAO,EAAE,CAAC;CACF,CAAC;AAEX,8EAA8E;AAC9E,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,kBAAkB,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GACpC,qBAAqB,GAAG,SAAS,CAkBnC;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAIT"}
|