@prestyj/cli 5.36.0 → 5.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/cli/command-routing.d.ts +1 -1
  2. package/dist/cli/command-routing.js +3 -1
  3. package/dist/cli/command-routing.js.map +1 -1
  4. package/dist/cli/fleet.d.ts +6 -0
  5. package/dist/cli/fleet.js +304 -0
  6. package/dist/cli/fleet.js.map +1 -0
  7. package/dist/cli/node.d.ts +5 -0
  8. package/dist/cli/node.js +308 -0
  9. package/dist/cli/node.js.map +1 -0
  10. package/dist/cli/validate.js +31 -7
  11. package/dist/cli/validate.js.map +1 -1
  12. package/dist/cli.js +6 -0
  13. package/dist/cli.js.map +1 -1
  14. package/dist/core/agent-notifications.d.ts +1 -1
  15. package/dist/core/agent-session.d.ts +1 -0
  16. package/dist/core/agent-session.js +6 -0
  17. package/dist/core/agent-session.js.map +1 -1
  18. package/dist/core/fleet/browser.d.ts +13 -0
  19. package/dist/core/fleet/browser.js +50 -0
  20. package/dist/core/fleet/browser.js.map +1 -0
  21. package/dist/core/fleet/client.d.ts +70 -0
  22. package/dist/core/fleet/client.js +240 -0
  23. package/dist/core/fleet/client.js.map +1 -0
  24. package/dist/core/fleet/discovery.d.ts +33 -0
  25. package/dist/core/fleet/discovery.js +82 -0
  26. package/dist/core/fleet/discovery.js.map +1 -0
  27. package/dist/core/fleet/fleet-scheduler.d.ts +44 -0
  28. package/dist/core/fleet/fleet-scheduler.js +108 -0
  29. package/dist/core/fleet/fleet-scheduler.js.map +1 -0
  30. package/dist/core/fleet/git.d.ts +32 -0
  31. package/dist/core/fleet/git.js +113 -0
  32. package/dist/core/fleet/git.js.map +1 -0
  33. package/dist/core/fleet/node/agents.d.ts +15 -0
  34. package/dist/core/fleet/node/agents.js +461 -0
  35. package/dist/core/fleet/node/agents.js.map +1 -0
  36. package/dist/core/fleet/node/config.d.ts +52 -0
  37. package/dist/core/fleet/node/config.js +191 -0
  38. package/dist/core/fleet/node/config.js.map +1 -0
  39. package/dist/core/fleet/node/context.d.ts +43 -0
  40. package/dist/core/fleet/node/context.js +2 -0
  41. package/dist/core/fleet/node/context.js.map +1 -0
  42. package/dist/core/fleet/node/docker.d.ts +23 -0
  43. package/dist/core/fleet/node/docker.js +214 -0
  44. package/dist/core/fleet/node/docker.js.map +1 -0
  45. package/dist/core/fleet/node/exec.d.ts +24 -0
  46. package/dist/core/fleet/node/exec.js +64 -0
  47. package/dist/core/fleet/node/exec.js.map +1 -0
  48. package/dist/core/fleet/node/info.d.ts +36 -0
  49. package/dist/core/fleet/node/info.js +209 -0
  50. package/dist/core/fleet/node/info.js.map +1 -0
  51. package/dist/core/fleet/node/jobs.d.ts +88 -0
  52. package/dist/core/fleet/node/jobs.js +702 -0
  53. package/dist/core/fleet/node/jobs.js.map +1 -0
  54. package/dist/core/fleet/node/server.d.ts +37 -0
  55. package/dist/core/fleet/node/server.js +416 -0
  56. package/dist/core/fleet/node/server.js.map +1 -0
  57. package/dist/core/fleet/node/services.d.ts +71 -0
  58. package/dist/core/fleet/node/services.js +532 -0
  59. package/dist/core/fleet/node/services.js.map +1 -0
  60. package/dist/core/fleet/node/state.d.ts +48 -0
  61. package/dist/core/fleet/node/state.js +43 -0
  62. package/dist/core/fleet/node/state.js.map +1 -0
  63. package/dist/core/fleet/node/workspace.d.ts +41 -0
  64. package/dist/core/fleet/node/workspace.js +153 -0
  65. package/dist/core/fleet/node/workspace.js.map +1 -0
  66. package/dist/core/fleet/project-config.d.ts +52 -0
  67. package/dist/core/fleet/project-config.js +449 -0
  68. package/dist/core/fleet/project-config.js.map +1 -0
  69. package/dist/core/fleet/protocol.d.ts +225 -0
  70. package/dist/core/fleet/protocol.js +11 -0
  71. package/dist/core/fleet/protocol.js.map +1 -0
  72. package/dist/core/fleet/registry.d.ts +34 -0
  73. package/dist/core/fleet/registry.js +79 -0
  74. package/dist/core/fleet/registry.js.map +1 -0
  75. package/dist/core/fleet/remote-agent-nodes.d.ts +31 -0
  76. package/dist/core/fleet/remote-agent-nodes.js +96 -0
  77. package/dist/core/fleet/remote-agent-nodes.js.map +1 -0
  78. package/dist/core/fleet/remote-agent.d.ts +115 -0
  79. package/dist/core/fleet/remote-agent.js +590 -0
  80. package/dist/core/fleet/remote-agent.js.map +1 -0
  81. package/dist/core/fleet/service.d.ts +185 -0
  82. package/dist/core/fleet/service.js +1140 -0
  83. package/dist/core/fleet/service.js.map +1 -0
  84. package/dist/core/fleet/session-hook.d.ts +3 -0
  85. package/dist/core/fleet/session-hook.js +45 -0
  86. package/dist/core/fleet/session-hook.js.map +1 -0
  87. package/dist/core/fleet/store.d.ts +37 -0
  88. package/dist/core/fleet/store.js +115 -0
  89. package/dist/core/fleet/store.js.map +1 -0
  90. package/dist/core/fleet/types.d.ts +88 -0
  91. package/dist/core/fleet/types.js +16 -0
  92. package/dist/core/fleet/types.js.map +1 -0
  93. package/dist/core/mcp/store.d.ts +2 -2
  94. package/dist/core/subagent-manager.d.ts +39 -0
  95. package/dist/core/subagent-manager.js +67 -7
  96. package/dist/core/subagent-manager.js.map +1 -1
  97. package/dist/core/validation/backends.d.ts +5 -2
  98. package/dist/core/validation/backends.js +17 -1
  99. package/dist/core/validation/backends.js.map +1 -1
  100. package/dist/core/validation/config.d.ts +10 -2
  101. package/dist/core/validation/config.js +30 -3
  102. package/dist/core/validation/config.js.map +1 -1
  103. package/dist/core/validation/exec.js +6 -1
  104. package/dist/core/validation/exec.js.map +1 -1
  105. package/dist/core/validation/github-actions-backend.d.ts +49 -2
  106. package/dist/core/validation/github-actions-backend.js +257 -3
  107. package/dist/core/validation/github-actions-backend.js.map +1 -1
  108. package/dist/core/validation/node-backend.d.ts +56 -0
  109. package/dist/core/validation/node-backend.js +184 -0
  110. package/dist/core/validation/node-backend.js.map +1 -0
  111. package/dist/core/validation/scheduler.d.ts +38 -0
  112. package/dist/core/validation/scheduler.js +133 -0
  113. package/dist/core/validation/scheduler.js.map +1 -0
  114. package/dist/core/validation/service.d.ts +53 -3
  115. package/dist/core/validation/service.js +272 -56
  116. package/dist/core/validation/service.js.map +1 -1
  117. package/dist/core/validation/session-hook.js +9 -2
  118. package/dist/core/validation/session-hook.js.map +1 -1
  119. package/dist/core/validation/types.d.ts +52 -1
  120. package/dist/core/validation/types.js +2 -0
  121. package/dist/core/validation/types.js.map +1 -1
  122. package/dist/tools/browser-session.d.ts +24 -1
  123. package/dist/tools/browser-session.js +31 -10
  124. package/dist/tools/browser-session.js.map +1 -1
  125. package/dist/tools/fleet.d.ts +26 -0
  126. package/dist/tools/fleet.js +144 -0
  127. package/dist/tools/fleet.js.map +1 -0
  128. package/dist/tools/index.js +6 -2
  129. package/dist/tools/index.js.map +1 -1
  130. package/dist/tools/prompt-hints.js +2 -0
  131. package/dist/tools/prompt-hints.js.map +1 -1
  132. package/dist/tools/steroids.d.ts +1 -1
  133. package/dist/tools/subagent-control.js +10 -1
  134. package/dist/tools/subagent-control.js.map +1 -1
  135. package/dist/tools/tasks.d.ts +1 -1
  136. package/dist/tools/tool-tiers.js +1 -0
  137. package/dist/tools/tool-tiers.js.map +1 -1
  138. package/dist/tools/validate.js +4 -5
  139. package/dist/tools/validate.js.map +1 -1
  140. package/package.json +7 -5
@@ -0,0 +1,225 @@
1
+ export declare const FLEET_PROTOCOL = 1;
2
+ export declare const DEFAULT_NODE_PORT = 7377;
3
+ /** Platform family the node runs on. */
4
+ export type NodePlatform = "linux" | "wsl2" | "macos" | "windows";
5
+ export interface GpuInfo {
6
+ name: string;
7
+ memoryGb: number;
8
+ /** Currently used memory, GB (from nvidia-smi / system tools). */
9
+ memoryUsedGb?: number;
10
+ utilizationPct?: number;
11
+ vendor: "nvidia" | "amd" | "apple" | "other";
12
+ }
13
+ /** GET /v1/hello (no auth): enough to recognise an EZCODER node during discovery. */
14
+ export interface HelloResponse {
15
+ ezcoderNode: true;
16
+ protocol: number;
17
+ name: string;
18
+ version: string;
19
+ platform: NodePlatform;
20
+ }
21
+ /** Live resources, GET /v1/info. */
22
+ export interface NodeInfo extends HelloResponse {
23
+ hostname: string;
24
+ arch: string;
25
+ cpus: number;
26
+ memoryGb: number;
27
+ memoryFreeGb: number;
28
+ /** 1-minute load average divided by cpus (0..n). */
29
+ load: number;
30
+ diskFreeGb: number;
31
+ gpus: GpuInfo[];
32
+ docker: boolean;
33
+ /** User-assigned labels, e.g. "deploy", "render". "gpu" is added automatically when gpus exist. */
34
+ labels: string[];
35
+ /** Max concurrent jobs + agents (services don't take slots). */
36
+ slots: number;
37
+ slotsUsed: number;
38
+ /** Has its own model credentials (ezcoder login done or shared). */
39
+ modelAuth: boolean;
40
+ jobs: JobStatus[];
41
+ services: ServiceStatus[];
42
+ agents: AgentWorkspaceStatus[];
43
+ }
44
+ export interface Resources {
45
+ cpus?: number;
46
+ memoryGb?: number;
47
+ /** GPUs needed (0/undefined = none). */
48
+ gpus?: number;
49
+ /** Min GPU memory per GPU, GB. */
50
+ gpuMemoryGb?: number;
51
+ /** Labels the node must carry. */
52
+ labels?: string[];
53
+ }
54
+ /**
55
+ * Where the code comes from. The node clones `git` (with its own git/gh
56
+ * credentials) into a fresh per-job folder at exactly `sha`, then applies
57
+ * `patch` (output of `git diff --binary <sha>` incl. intent-to-add untracked
58
+ * files) when given, so uncommitted local work can run remotely too.
59
+ */
60
+ export interface SourceSpec {
61
+ git: string;
62
+ sha: string;
63
+ /** base64 of a binary git patch against `sha`. Max 50 MB. */
64
+ patch?: string;
65
+ /** Sub-folder of the repo to work in. */
66
+ subdir?: string;
67
+ }
68
+ /** How a command is wrapped in Docker on the node (absent = run on the host shell). */
69
+ export interface DockerSpec {
70
+ image?: string;
71
+ /** Build this Dockerfile (path relative to the workspace) and run in it. */
72
+ dockerfile?: string;
73
+ compose?: string;
74
+ service?: string;
75
+ entrypoint?: string;
76
+ /** Pass GPUs through (--gpus all). */
77
+ gpu?: boolean;
78
+ /** Extra docker run args (validated: no --privileged, no host network). */
79
+ args?: string[];
80
+ }
81
+ export type JobKind = "validate" | "build" | "test" | "browser" | "render" | "deploy" | "custom";
82
+ /** POST /v1/jobs. Idempotent on `id` (re-posting an existing id returns its status). */
83
+ export interface JobRequest {
84
+ id: string;
85
+ kind: JobKind;
86
+ /** Project identity, used for cache keys and isolation. */
87
+ project: string;
88
+ source?: SourceSpec;
89
+ command: string;
90
+ docker?: DockerSpec;
91
+ env?: Record<string, string>;
92
+ /** Names of node-local secrets to expose as env vars. Never values. Only nodes labelled "deploy" accept these. */
93
+ secrets?: string[];
94
+ timeoutMinutes: number;
95
+ resources?: Resources;
96
+ /** Globs (relative to the workspace) collected as artifacts when the job ends. */
97
+ artifacts?: string[];
98
+ /** Cache key; defaults to a sanitized `project`. Mounted at /cache (docker) or exported as EZ_CACHE. */
99
+ cacheKey?: string;
100
+ }
101
+ export type NodeJobState = "preparing" | "running" | "passed" | "failed" | "error" | "cancelled"
102
+ /** The node restarted while the job ran and could not re-adopt it. */
103
+ | "lost";
104
+ export interface ArtifactInfo {
105
+ path: string;
106
+ bytes: number;
107
+ }
108
+ export interface JobStatus {
109
+ id: string;
110
+ kind: JobKind;
111
+ project: string;
112
+ state: NodeJobState;
113
+ exitCode?: number;
114
+ summary?: string;
115
+ startedAt?: string;
116
+ finishedAt?: string;
117
+ artifacts?: ArtifactInfo[];
118
+ logBytes: number;
119
+ }
120
+ export type ServiceKind = "inference" | "browser" | "devenv" | "custom";
121
+ export interface PortSpec {
122
+ /** Port inside the container (or on the host for host services). */
123
+ container: number;
124
+ /** Logical name, e.g. "openai", "playwright", "http". */
125
+ name: string;
126
+ protocol?: "http" | "ws" | "tcp";
127
+ }
128
+ /** POST /v1/services. Long-running containers reachable on the node's tailnet address. */
129
+ export interface ServiceRequest {
130
+ id: string;
131
+ kind: ServiceKind;
132
+ project?: string;
133
+ source?: SourceSpec;
134
+ docker: DockerSpec;
135
+ command?: string;
136
+ env?: Record<string, string>;
137
+ ports: PortSpec[];
138
+ resources?: Resources;
139
+ /** Named volume kept across restarts (models, browsers, home dir). */
140
+ persist?: string;
141
+ /** Stop automatically after this many idle minutes (0 = never). */
142
+ idleStopMinutes?: number;
143
+ }
144
+ export type ServiceState = "starting" | "running" | "stopped" | "error";
145
+ export interface ServiceEndpoint {
146
+ name: string;
147
+ /** e.g. http://my-pc.tailnet.ts.net:41234 */
148
+ url: string;
149
+ }
150
+ export interface ServiceStatus {
151
+ id: string;
152
+ kind: ServiceKind;
153
+ project?: string;
154
+ state: ServiceState;
155
+ endpoints: ServiceEndpoint[];
156
+ summary?: string;
157
+ startedAt?: string;
158
+ }
159
+ export interface ExecRequest {
160
+ command: string;
161
+ timeoutSeconds?: number;
162
+ cwd?: string;
163
+ }
164
+ export interface ExecResponse {
165
+ exitCode: number;
166
+ output: string;
167
+ }
168
+ /**
169
+ * Remote agents. POST /v1/agents {id, source, project} prepares an isolated
170
+ * workspace (clone at sha + patch). GET upgrade /v1/agents/:id/attach (WebSocket)
171
+ * spawns `ezcoder --subagent-worker` there (if not already running) and bridges
172
+ * its stdio: every text frame is JSON AgentFrame. The process survives a dropped
173
+ * socket for AGENT_DETACH_GRACE_MS so the controller can re-attach.
174
+ * GET /v1/agents/:id/diff -> AgentDiff (changes vs the prepared base, binary patch).
175
+ * DELETE /v1/agents/:id -> kill the process and remove the workspace.
176
+ */
177
+ export interface AgentRequest {
178
+ id: string;
179
+ project: string;
180
+ source: SourceSpec;
181
+ /** Extra env for the worker (never model credentials). */
182
+ env?: Record<string, string>;
183
+ }
184
+ export interface AgentWorkspaceStatus {
185
+ id: string;
186
+ project: string;
187
+ state: "ready" | "running" | "exited" | "error";
188
+ /** Absolute workspace path on the node. */
189
+ cwd: string;
190
+ pid?: number;
191
+ exitCode?: number;
192
+ createdAt: string;
193
+ }
194
+ export type AgentFrame = {
195
+ t: "stdin";
196
+ data: string;
197
+ } | {
198
+ t: "stdout";
199
+ data: string;
200
+ } | {
201
+ t: "stderr";
202
+ data: string;
203
+ } | {
204
+ t: "exit";
205
+ code: number | null;
206
+ signal?: string | null;
207
+ } | {
208
+ t: "kill";
209
+ signal?: string;
210
+ };
211
+ export declare const AGENT_DETACH_GRACE_MS: number;
212
+ export interface AgentDiff {
213
+ /** base64 binary patch (`git diff --binary <base>` after `git add -A -N`), "" when unchanged. */
214
+ patch: string;
215
+ files: string[];
216
+ base: string;
217
+ }
218
+ /** POST /v1/auth (opt-in `ezcoder fleet share-auth`): provider credentials for the node's own ~/.ezcoder/auth.json. */
219
+ export interface ShareAuthRequest {
220
+ /** Raw auth.json entries keyed by provider id. */
221
+ credentials: Record<string, unknown>;
222
+ }
223
+ export interface ErrorResponse {
224
+ error: string;
225
+ }
@@ -0,0 +1,11 @@
1
+ // Fleet protocol: the HTTP/WebSocket contract between EZCODER on the user's
2
+ // main machine ("controller") and `ezcoder node serve` on every other machine
3
+ // ("node"). Nodes are reached over a private network (Tailscale); every call
4
+ // except GET /v1/hello carries `Authorization: Bearer <node token>`.
5
+ //
6
+ // Shared by the node server (core/fleet/node/*) and the controller client
7
+ // (core/fleet/client.ts). Change only additively; bump FLEET_PROTOCOL on breaks.
8
+ export const FLEET_PROTOCOL = 1;
9
+ export const DEFAULT_NODE_PORT = 7377;
10
+ export const AGENT_DETACH_GRACE_MS = 10 * 60_000;
11
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/core/fleet/protocol.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,0EAA0E;AAC1E,iFAAiF;AAEjF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AA4OtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,MAAM,CAAC"}
@@ -0,0 +1,34 @@
1
+ export interface FleetNode {
2
+ name: string;
3
+ /** Base URL, e.g. http://my-pc.tailnet.ts.net:7377 */
4
+ url: string;
5
+ token: string;
6
+ /** Extra controller-side labels (the node reports its own too). */
7
+ labels: string[];
8
+ addedAt: string;
9
+ }
10
+ export interface Pairing {
11
+ name: string;
12
+ host: string;
13
+ port: number;
14
+ url: string;
15
+ token: string;
16
+ }
17
+ export declare function isValidNodeName(name: string): boolean;
18
+ /** Parse `ezfleet://<name>@<host>[:<port>]#<token>`; throws a plain-words error. */
19
+ export declare function parsePairing(input: string): Pairing;
20
+ export declare class NodeRegistry {
21
+ readonly dir: string;
22
+ private readonly store;
23
+ constructor(dir?: string);
24
+ get file(): string;
25
+ list(): Promise<FleetNode[]>;
26
+ get(name: string): Promise<FleetNode | undefined>;
27
+ /** Add or replace (same name) a node. */
28
+ add(node: Omit<FleetNode, "addedAt"> & {
29
+ addedAt?: string;
30
+ }): Promise<FleetNode>;
31
+ remove(name: string): Promise<boolean>;
32
+ }
33
+ /** Every paired node (for other modules: remote agents, validation). */
34
+ export declare function listNodes(dir?: string): Promise<FleetNode[]>;
@@ -0,0 +1,79 @@
1
+ // The user's paired nodes (~/.ezcoder/fleet/nodes.json, 0600: it holds tokens).
2
+ // Pairing strings come from `ezcoder node serve` on the other machine:
3
+ // ezfleet://<name>@<host>:<port>#<token>
4
+ import { DEFAULT_NODE_PORT } from "./protocol.js";
5
+ import { defaultFleetDir, JsonListStore } from "./store.js";
6
+ const NODE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
7
+ export function isValidNodeName(name) {
8
+ return NODE_NAME.test(name);
9
+ }
10
+ /** Parse `ezfleet://<name>@<host>[:<port>]#<token>`; throws a plain-words error. */
11
+ export function parsePairing(input) {
12
+ const s = input.trim();
13
+ const m = /^ezfleet:\/\/([^@/#\s]+)@(\[[^\]\s]+\]|[^:/#\s]+)(?::(\d{1,5}))?\/?#(\S+)$/i.exec(s);
14
+ if (!m) {
15
+ throw new Error(`not a pairing string: expected ezfleet://<name>@<host>:<port>#<token> (got "${s.slice(0, 60)}")`);
16
+ }
17
+ const name = decodeURIComponent(m[1]);
18
+ const host = m[2];
19
+ const port = m[3] ? Number(m[3]) : DEFAULT_NODE_PORT;
20
+ const token = m[4];
21
+ if (!isValidNodeName(name))
22
+ throw new Error(`invalid node name "${name}"`);
23
+ if (port < 1 || port > 65_535)
24
+ throw new Error(`invalid port ${port}`);
25
+ if (token.length < 16)
26
+ throw new Error("pairing token is too short");
27
+ return { name, host, port, url: `http://${host}:${port}`, token };
28
+ }
29
+ export class NodeRegistry {
30
+ dir;
31
+ store;
32
+ constructor(dir = defaultFleetDir()) {
33
+ this.dir = dir;
34
+ this.store = new JsonListStore(dir, "nodes.json", "nodes", { mode: 0o600 });
35
+ }
36
+ get file() {
37
+ return this.store.file;
38
+ }
39
+ async list() {
40
+ return (await this.store.read()).filter((n) => n && typeof n.name === "string" && typeof n.url === "string");
41
+ }
42
+ async get(name) {
43
+ return (await this.list()).find((n) => n.name === name);
44
+ }
45
+ /** Add or replace (same name) a node. */
46
+ async add(node) {
47
+ if (!isValidNodeName(node.name))
48
+ throw new Error(`invalid node name "${node.name}"`);
49
+ const entry = {
50
+ name: node.name,
51
+ url: node.url.replace(/\/+$/, ""),
52
+ token: node.token,
53
+ labels: node.labels ?? [],
54
+ addedAt: node.addedAt ?? new Date().toISOString(),
55
+ };
56
+ await this.store.update((nodes) => {
57
+ const i = nodes.findIndex((n) => n.name === entry.name);
58
+ if (i >= 0)
59
+ nodes[i] = entry;
60
+ else
61
+ nodes.push(entry);
62
+ });
63
+ return entry;
64
+ }
65
+ async remove(name) {
66
+ return this.store.update((nodes) => {
67
+ const i = nodes.findIndex((n) => n.name === name);
68
+ if (i < 0)
69
+ return false;
70
+ nodes.splice(i, 1);
71
+ return true;
72
+ });
73
+ }
74
+ }
75
+ /** Every paired node (for other modules: remote agents, validation). */
76
+ export async function listNodes(dir) {
77
+ return new NodeRegistry(dir).list();
78
+ }
79
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources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odeEntry {
3
+ name: string;
4
+ /** Base URL, e.g. http://my-pc.tailnet.ts.net:7377 */
5
+ url: string;
6
+ token: string;
7
+ labels?: string[];
8
+ }
9
+ export declare function fleetNodesFile(): string;
10
+ /** Paired nodes; [] when the file is missing or unreadable. */
11
+ export declare function readFleetNodes(file?: string): Promise<FleetNodeEntry[]>;
12
+ export declare function nodeHeaders(node: FleetNodeEntry): Record<string, string>;
13
+ export declare function nodeUrl(node: FleetNodeEntry, route: string): string;
14
+ /** GET /v1/info; undefined when the node can't be reached or refuses. */
15
+ export declare function probeNode(node: FleetNodeEntry, timeoutMs?: number): Promise<NodeInfo | undefined>;
16
+ export interface ProbedNode {
17
+ node: FleetNodeEntry;
18
+ info?: NodeInfo;
19
+ }
20
+ /** Why a probed node can't take an agent now, or undefined when it can. */
21
+ export declare function agentNodeProblem(probed: ProbedNode): string | undefined;
22
+ /** `auto`: a node with model credentials and a free slot, least loaded first. */
23
+ export declare function pickAutoNode(probed: readonly ProbedNode[]): ProbedNode | undefined;
24
+ /**
25
+ * Resolve spawn_agent's `machine` ("auto" or a node name) to a node that can
26
+ * run an agent now. Throws a message the model can act on.
27
+ */
28
+ export declare function selectAgentNode(machine: string, options?: {
29
+ file?: string;
30
+ probe?: (node: FleetNodeEntry) => Promise<NodeInfo | undefined>;
31
+ }): Promise<FleetNodeEntry>;
@@ -0,0 +1,96 @@
1
+ // Node lookup for remote sub-agents (spawn_agent `machine`). Read-only view of
2
+ // the controller's paired nodes in ~/.ezcoder/fleet/nodes.json — the fleet
3
+ // registry owns that file and writes it; this module only reads it, so remote
4
+ // agents don't depend on the registry's internals.
5
+ import fs from "node:fs/promises";
6
+ import path from "node:path";
7
+ import { getAppPaths } from "@prestyj/core";
8
+ export function fleetNodesFile() {
9
+ return path.join(getAppPaths().agentDir, "fleet", "nodes.json");
10
+ }
11
+ /** Paired nodes; [] when the file is missing or unreadable. */
12
+ export async function readFleetNodes(file = fleetNodesFile()) {
13
+ let parsed;
14
+ try {
15
+ parsed = JSON.parse(await fs.readFile(file, "utf-8"));
16
+ }
17
+ catch {
18
+ return [];
19
+ }
20
+ const nodes = parsed?.nodes;
21
+ if (!Array.isArray(nodes))
22
+ return [];
23
+ return nodes.filter((node) => !!node &&
24
+ typeof node.name === "string" &&
25
+ typeof node.url === "string" &&
26
+ typeof node.token === "string");
27
+ }
28
+ export function nodeHeaders(node) {
29
+ return { authorization: `Bearer ${node.token}` };
30
+ }
31
+ export function nodeUrl(node, route) {
32
+ return `${node.url.replace(/\/+$/, "")}${route}`;
33
+ }
34
+ /** GET /v1/info; undefined when the node can't be reached or refuses. */
35
+ export async function probeNode(node, timeoutMs = 4_000) {
36
+ try {
37
+ const res = await fetch(nodeUrl(node, "/v1/info"), {
38
+ headers: nodeHeaders(node),
39
+ signal: AbortSignal.timeout(timeoutMs),
40
+ });
41
+ if (!res.ok)
42
+ return undefined;
43
+ return (await res.json());
44
+ }
45
+ catch {
46
+ return undefined;
47
+ }
48
+ }
49
+ /** Why a probed node can't take an agent now, or undefined when it can. */
50
+ export function agentNodeProblem(probed) {
51
+ const { info } = probed;
52
+ if (!info)
53
+ return "unreachable";
54
+ if (!info.modelAuth)
55
+ return "no model credentials (run `ezcoder login` there, or share-auth)";
56
+ if (info.slotsUsed >= info.slots)
57
+ return `full (${info.slotsUsed}/${info.slots} slots)`;
58
+ return undefined;
59
+ }
60
+ /** `auto`: a node with model credentials and a free slot, least loaded first. */
61
+ export function pickAutoNode(probed) {
62
+ return probed
63
+ .filter((candidate) => agentNodeProblem(candidate) === undefined)
64
+ .sort((a, b) => a.info.load - b.info.load ||
65
+ b.info.slots - b.info.slotsUsed - (a.info.slots - a.info.slotsUsed) ||
66
+ a.node.name.localeCompare(b.node.name))[0];
67
+ }
68
+ /**
69
+ * Resolve spawn_agent's `machine` ("auto" or a node name) to a node that can
70
+ * run an agent now. Throws a message the model can act on.
71
+ */
72
+ export async function selectAgentNode(machine, options = {}) {
73
+ const nodes = await readFleetNodes(options.file);
74
+ if (nodes.length === 0) {
75
+ throw new Error("No fleet nodes are paired. Pair one with `ezcoder fleet add`, or leave machine unset to run locally.");
76
+ }
77
+ const probe = options.probe ?? ((node) => probeNode(node));
78
+ if (machine !== "auto") {
79
+ const node = nodes.find((candidate) => candidate.name === machine);
80
+ if (!node) {
81
+ throw new Error(`Unknown machine "${machine}". Paired: ${nodes.map((n) => n.name).join(", ")} (or "auto").`);
82
+ }
83
+ const problem = agentNodeProblem({ node, info: await probe(node) });
84
+ if (problem)
85
+ throw new Error(`Machine "${machine}" can't run an agent now: ${problem}`);
86
+ return node;
87
+ }
88
+ const probed = await Promise.all(nodes.map(async (node) => ({ node, info: await probe(node) })));
89
+ const picked = pickAutoNode(probed);
90
+ if (!picked) {
91
+ const reasons = probed.map((p) => `${p.node.name}: ${agentNodeProblem(p)}`).join("; ");
92
+ throw new Error(`No paired machine can run an agent now (${reasons}).`);
93
+ }
94
+ return picked.node;
95
+ }
96
+ //# sourceMappingURL=remote-agent-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-agent-nodes.js","sourceRoot":"","sources":["../../../src/core/fleet/remote-agent-nodes.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,mDAAmD;AACnD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAW5C,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAClE,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAI,GAAG,cAAc,EAAE;IAC1D,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,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AI,CAAC,IAAI,CAAC,CAAC;QACvF,MAAM,IAAI,KAAK,CAAC,2CAA2C,OAAO,IAAI,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { PassThrough, Writable } from "node:stream";
3
+ import type { SourceSpec } from "./protocol.js";
4
+ import { type FleetNodeEntry } from "./remote-agent-nodes.js";
5
+ export interface RemoteAgentInfo {
6
+ node: string;
7
+ remoteAgentId: string;
8
+ }
9
+ export interface RemoteWorkerSpawn {
10
+ /** "auto" or a paired node name. */
11
+ machine: string;
12
+ /** Local folder the child works in; its edits come back here. */
13
+ cwd: string;
14
+ localAgentId: string;
15
+ /** Root for per-agent sync state and kept conflict patches. */
16
+ stateRoot: string;
17
+ /** Re-attach to an existing remote agent instead of creating one. */
18
+ resume?: RemoteAgentInfo;
19
+ nodesFile?: string;
20
+ reconnectWindowMs?: number;
21
+ onRemote?: (info: RemoteAgentInfo) => void;
22
+ }
23
+ export interface PreparedRemoteSource {
24
+ repoRoot: string;
25
+ source: SourceSpec;
26
+ /** Raw (not base64) patch of uncommitted work against source.sha. */
27
+ patch: Buffer;
28
+ project: string;
29
+ }
30
+ /**
31
+ * What the node needs to rebuild `cwd`: origin URL, HEAD (which must already
32
+ * be on origin), and a binary patch of uncommitted work including untracked
33
+ * files. The patch is built in a copy of the index so the user's is untouched.
34
+ */
35
+ export declare function prepareRemoteSource(cwd: string): Promise<PreparedRemoteSource>;
36
+ export interface SyncResult {
37
+ /** Files the delta touched (empty when nothing changed since the last sync). */
38
+ files: string[];
39
+ applied: boolean;
40
+ /** Kept patch when it could not be applied cleanly. */
41
+ conflictPatch?: string;
42
+ /** One line for the agent's receipt / stderr. */
43
+ note?: string;
44
+ }
45
+ /**
46
+ * Symlinks the change from tree `from` to `to` adds or retargets that point
47
+ * outside the repository (absolute, `..` escapes) or into `.git`. Applying
48
+ * them would let a node write anywhere through a later local edit.
49
+ */
50
+ export declare function escapingSymlinks(repoRoot: string, from: string, to: string): Promise<string[]>;
51
+ /**
52
+ * Apply to `repoRoot` the change from (base + previous) to (base + next),
53
+ * where both are full remote diffs against `base`. Applying only that delta
54
+ * keeps repeated syncs from re-applying earlier turns. The apply is atomic;
55
+ * when it fails the tree is untouched and the delta is kept under `keepDir`.
56
+ */
57
+ export declare function applyRemoteDelta(options: {
58
+ repoRoot: string;
59
+ base: string;
60
+ previous: Buffer;
61
+ next: Buffer;
62
+ keepDir: string;
63
+ node: string;
64
+ }): Promise<SyncResult>;
65
+ export declare class RemoteWorkerProcess extends EventEmitter {
66
+ private readonly spawnOptions;
67
+ readonly stdout: PassThrough;
68
+ readonly stderr: PassThrough;
69
+ readonly stdin: Writable;
70
+ readonly pid: number | undefined;
71
+ exitCode: number | null;
72
+ signalCode: NodeJS.Signals | null;
73
+ killed: boolean;
74
+ /** Resolves once attached; `resumed` = joined a worker that was already running. */
75
+ readonly attached: Promise<{
76
+ resumed: boolean;
77
+ }>;
78
+ readonly machine: string;
79
+ node?: FleetNodeEntry;
80
+ remoteAgentId?: string;
81
+ private ws?;
82
+ private readonly queue;
83
+ private stdoutPartial;
84
+ private lineChain;
85
+ private finished;
86
+ private exitSeen;
87
+ private created;
88
+ private reconnecting;
89
+ private state?;
90
+ private stateDir?;
91
+ private killTimer?;
92
+ private closing?;
93
+ constructor(spawnOptions: RemoteWorkerSpawn);
94
+ kill(signal?: NodeJS.Signals | number): boolean;
95
+ /**
96
+ * Drop the connection without stopping or removing the remote agent (as a
97
+ * parent restart does); the node keeps it for the detach grace period.
98
+ */
99
+ detach(): void;
100
+ private start;
101
+ private http;
102
+ private connect;
103
+ private reconnect;
104
+ private send;
105
+ private onFrame;
106
+ /** Pass a worker line through; a finished turn first brings its edits home. */
107
+ private forwardLine;
108
+ /** Sync and describe the outcome; never throws (a failed sync is reported, not fatal). */
109
+ private syncNote;
110
+ /** GET the node's diff and apply what changed since the last sync. */
111
+ syncBack(): Promise<SyncResult | undefined>;
112
+ private cleanupAndFinish;
113
+ private removeAndFinish;
114
+ private finish;
115
+ }