@prestyj/cli 5.38.0 → 5.39.1
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 +92 -42
- package/dist/app-sidecar/fleet-adapter.d.ts +138 -0
- package/dist/app-sidecar/fleet-adapter.js +356 -0
- package/dist/app-sidecar/fleet-adapter.js.map +1 -0
- package/dist/app-sidecar/fleet-routes.d.ts +4 -0
- package/dist/app-sidecar/fleet-routes.js +109 -0
- package/dist/app-sidecar/fleet-routes.js.map +1 -0
- package/dist/app-sidecar/goal-routes.d.ts +20 -0
- package/dist/app-sidecar/goal-routes.js +42 -1
- package/dist/app-sidecar/goal-routes.js.map +1 -1
- package/dist/app-sidecar.js +5 -0
- package/dist/app-sidecar.js.map +1 -1
- package/dist/cli/cloud.d.ts +45 -0
- package/dist/cli/cloud.js +241 -0
- package/dist/cli/cloud.js.map +1 -0
- package/dist/cli/command-routing.d.ts +3 -2
- package/dist/cli/command-routing.js +24 -3
- package/dist/cli/command-routing.js.map +1 -1
- package/dist/cli/fleet.d.ts +19 -3
- package/dist/cli/fleet.js +107 -33
- package/dist/cli/fleet.js.map +1 -1
- package/dist/cli/goals.d.ts +11 -0
- package/dist/cli/goals.js +115 -0
- package/dist/cli/goals.js.map +1 -0
- package/dist/cli/node.d.ts +18 -1
- package/dist/cli/node.js +303 -33
- package/dist/cli/node.js.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -0
- package/dist/core/agent-session.js +18 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cloud/claude.d.ts +128 -0
- package/dist/core/cloud/claude.js +836 -0
- package/dist/core/cloud/claude.js.map +1 -0
- package/dist/core/cloud/cloud-agent.d.ts +136 -0
- package/dist/core/cloud/cloud-agent.js +783 -0
- package/dist/core/cloud/cloud-agent.js.map +1 -0
- package/dist/core/cloud/codex.d.ts +154 -0
- package/dist/core/cloud/codex.js +622 -0
- package/dist/core/cloud/codex.js.map +1 -0
- package/dist/core/cloud/config.d.ts +69 -0
- package/dist/core/cloud/config.js +86 -0
- package/dist/core/cloud/config.js.map +1 -0
- package/dist/core/cloud/git.d.ts +15 -0
- package/dist/core/cloud/git.js +33 -0
- package/dist/core/cloud/git.js.map +1 -0
- package/dist/core/cloud/registry.d.ts +13 -0
- package/dist/core/cloud/registry.js +64 -0
- package/dist/core/cloud/registry.js.map +1 -0
- package/dist/core/cloud/runner.d.ts +46 -0
- package/dist/core/cloud/runner.js +99 -0
- package/dist/core/cloud/runner.js.map +1 -0
- package/dist/core/cloud/snapshot.d.ts +23 -0
- package/dist/core/cloud/snapshot.js +98 -0
- package/dist/core/cloud/snapshot.js.map +1 -0
- package/dist/core/cloud/types.d.ts +139 -0
- package/dist/core/cloud/types.js +28 -0
- package/dist/core/cloud/types.js.map +1 -0
- package/dist/core/fleet/client.d.ts +106 -6
- package/dist/core/fleet/client.js +352 -20
- package/dist/core/fleet/client.js.map +1 -1
- package/dist/core/fleet/cloud-jobs.d.ts +59 -0
- package/dist/core/fleet/cloud-jobs.js +131 -0
- package/dist/core/fleet/cloud-jobs.js.map +1 -0
- package/dist/core/fleet/discovery.d.ts +2 -0
- package/dist/core/fleet/discovery.js +3 -1
- package/dist/core/fleet/discovery.js.map +1 -1
- package/dist/core/fleet/fleet-scheduler.d.ts +4 -0
- package/dist/core/fleet/fleet-scheduler.js +11 -1
- package/dist/core/fleet/fleet-scheduler.js.map +1 -1
- package/dist/core/fleet/git.d.ts +7 -0
- package/dist/core/fleet/git.js +22 -1
- package/dist/core/fleet/git.js.map +1 -1
- package/dist/core/fleet/machines.d.ts +112 -0
- package/dist/core/fleet/machines.js +219 -0
- package/dist/core/fleet/machines.js.map +1 -0
- package/dist/core/fleet/node/agents.d.ts +2 -0
- package/dist/core/fleet/node/agents.js +195 -9
- package/dist/core/fleet/node/agents.js.map +1 -1
- package/dist/core/fleet/node/config.d.ts +37 -3
- package/dist/core/fleet/node/config.js +201 -40
- package/dist/core/fleet/node/config.js.map +1 -1
- package/dist/core/fleet/node/context.d.ts +19 -1
- package/dist/core/fleet/node/docker.d.ts +13 -5
- package/dist/core/fleet/node/docker.js +132 -66
- package/dist/core/fleet/node/docker.js.map +1 -1
- package/dist/core/fleet/node/doctor.d.ts +29 -0
- package/dist/core/fleet/node/doctor.js +202 -0
- package/dist/core/fleet/node/doctor.js.map +1 -0
- package/dist/core/fleet/node/env.d.ts +7 -0
- package/dist/core/fleet/node/env.js +51 -0
- package/dist/core/fleet/node/env.js.map +1 -0
- package/dist/core/fleet/node/gc.d.ts +46 -0
- package/dist/core/fleet/node/gc.js +140 -0
- package/dist/core/fleet/node/gc.js.map +1 -0
- package/dist/core/fleet/node/goals.d.ts +43 -0
- package/dist/core/fleet/node/goals.js +418 -0
- package/dist/core/fleet/node/goals.js.map +1 -0
- package/dist/core/fleet/node/jobs.d.ts +37 -2
- package/dist/core/fleet/node/jobs.js +236 -15
- package/dist/core/fleet/node/jobs.js.map +1 -1
- package/dist/core/fleet/node/local-client.d.ts +9 -0
- package/dist/core/fleet/node/local-client.js +29 -0
- package/dist/core/fleet/node/local-client.js.map +1 -0
- package/dist/core/fleet/node/ops-routes.d.ts +15 -0
- package/dist/core/fleet/node/ops-routes.js +84 -0
- package/dist/core/fleet/node/ops-routes.js.map +1 -0
- package/dist/core/fleet/node/pair-code-route.d.ts +14 -0
- package/dist/core/fleet/node/pair-code-route.js +76 -0
- package/dist/core/fleet/node/pair-code-route.js.map +1 -0
- package/dist/core/fleet/node/secrets.d.ts +43 -0
- package/dist/core/fleet/node/secrets.js +184 -0
- package/dist/core/fleet/node/secrets.js.map +1 -0
- package/dist/core/fleet/node/server.d.ts +22 -1
- package/dist/core/fleet/node/server.js +210 -21
- package/dist/core/fleet/node/server.js.map +1 -1
- package/dist/core/fleet/node/state.d.ts +24 -1
- package/dist/core/fleet/node/state.js +12 -3
- package/dist/core/fleet/node/state.js.map +1 -1
- package/dist/core/fleet/node/tls.d.ts +17 -0
- package/dist/core/fleet/node/tls.js +49 -0
- package/dist/core/fleet/node/tls.js.map +1 -0
- package/dist/core/fleet/node/uninstall.d.ts +27 -0
- package/dist/core/fleet/node/uninstall.js +100 -0
- package/dist/core/fleet/node/uninstall.js.map +1 -0
- package/dist/core/fleet/node/update.d.ts +28 -0
- package/dist/core/fleet/node/update.js +62 -0
- package/dist/core/fleet/node/update.js.map +1 -0
- package/dist/core/fleet/node/workspace.d.ts +4 -0
- package/dist/core/fleet/node/workspace.js +38 -9
- package/dist/core/fleet/node/workspace.js.map +1 -1
- package/dist/core/fleet/node-load.d.ts +4 -0
- package/dist/core/fleet/node-load.js +62 -0
- package/dist/core/fleet/node-load.js.map +1 -0
- package/dist/core/fleet/project-config.d.ts +10 -0
- package/dist/core/fleet/project-config.js +39 -1
- package/dist/core/fleet/project-config.js.map +1 -1
- package/dist/core/fleet/prompt-hint.d.ts +11 -0
- package/dist/core/fleet/prompt-hint.js +47 -0
- package/dist/core/fleet/prompt-hint.js.map +1 -0
- package/dist/core/fleet/propose-config.d.ts +26 -0
- package/dist/core/fleet/propose-config.js +95 -0
- package/dist/core/fleet/propose-config.js.map +1 -0
- package/dist/core/fleet/protocol.d.ts +97 -1
- package/dist/core/fleet/protocol.js +10 -1
- package/dist/core/fleet/protocol.js.map +1 -1
- package/dist/core/fleet/registry.d.ts +12 -1
- package/dist/core/fleet/registry.js +39 -7
- package/dist/core/fleet/registry.js.map +1 -1
- package/dist/core/fleet/remote-agent-nodes.d.ts +56 -8
- package/dist/core/fleet/remote-agent-nodes.js +162 -22
- package/dist/core/fleet/remote-agent-nodes.js.map +1 -1
- package/dist/core/fleet/remote-agent.d.ts +52 -1
- package/dist/core/fleet/remote-agent.js +220 -40
- package/dist/core/fleet/remote-agent.js.map +1 -1
- package/dist/core/fleet/service.d.ts +95 -3
- package/dist/core/fleet/service.js +762 -35
- package/dist/core/fleet/service.js.map +1 -1
- package/dist/core/fleet/store.js +22 -5
- package/dist/core/fleet/store.js.map +1 -1
- package/dist/core/fleet/types.d.ts +36 -1
- package/dist/core/fleet/types.js +12 -2
- package/dist/core/fleet/types.js.map +1 -1
- package/dist/core/goal-controller.d.ts +1 -0
- package/dist/core/goal-controller.js +1 -1
- package/dist/core/goal-controller.js.map +1 -1
- package/dist/core/goal-fleet.d.ts +117 -0
- package/dist/core/goal-fleet.js +441 -0
- package/dist/core/goal-fleet.js.map +1 -0
- package/dist/core/goal-headless.d.ts +45 -0
- package/dist/core/goal-headless.js +177 -0
- package/dist/core/goal-headless.js.map +1 -0
- package/dist/core/goal-remote-worker.d.ts +45 -0
- package/dist/core/goal-remote-worker.js +157 -0
- package/dist/core/goal-remote-worker.js.map +1 -0
- package/dist/core/goal-store.d.ts +36 -0
- package/dist/core/goal-store.js +69 -1
- package/dist/core/goal-store.js.map +1 -1
- package/dist/core/goal-verifier.d.ts +5 -0
- package/dist/core/goal-verifier.js +10 -0
- package/dist/core/goal-verifier.js.map +1 -1
- package/dist/core/goal-worker.d.ts +12 -0
- package/dist/core/goal-worker.js +162 -8
- package/dist/core/goal-worker.js.map +1 -1
- package/dist/core/subagent-manager.d.ts +12 -5
- package/dist/core/subagent-manager.js +15 -10
- package/dist/core/subagent-manager.js.map +1 -1
- package/dist/core/validation/backends.d.ts +34 -5
- package/dist/core/validation/backends.js +45 -5
- package/dist/core/validation/backends.js.map +1 -1
- package/dist/core/validation/cloud-backend.d.ts +77 -0
- package/dist/core/validation/cloud-backend.js +343 -0
- package/dist/core/validation/cloud-backend.js.map +1 -0
- package/dist/core/validation/config.js +9 -2
- package/dist/core/validation/config.js.map +1 -1
- package/dist/core/validation/node-backend.d.ts +2 -0
- package/dist/core/validation/node-backend.js +5 -0
- package/dist/core/validation/node-backend.js.map +1 -1
- package/dist/core/validation/scheduler.d.ts +11 -0
- package/dist/core/validation/scheduler.js +34 -7
- package/dist/core/validation/scheduler.js.map +1 -1
- package/dist/core/validation/service.d.ts +6 -0
- package/dist/core/validation/service.js +51 -13
- package/dist/core/validation/service.js.map +1 -1
- package/dist/core/validation/types.d.ts +14 -0
- package/dist/modes/acp-mode.d.ts +3 -1
- package/dist/modes/acp-mode.js +2 -1
- package/dist/modes/acp-mode.js.map +1 -1
- package/dist/system-prompt.d.ts +5 -0
- package/dist/system-prompt.js +3 -0
- package/dist/system-prompt.js.map +1 -1
- package/dist/tools/fleet.d.ts +40 -4
- package/dist/tools/fleet.js +228 -17
- package/dist/tools/fleet.js.map +1 -1
- package/dist/tools/goals.d.ts +4 -1
- package/dist/tools/goals.js +45 -5
- package/dist/tools/goals.js.map +1 -1
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.js +6 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/steroids.d.ts +1 -1
- package/dist/tools/subagent-control.js +1 -1
- package/dist/tools/subagent-control.js.map +1 -1
- package/dist/tools/validate.js +1 -1
- package/dist/tools/validate.js.map +1 -1
- package/dist/ui/App.js +2 -0
- package/dist/ui/App.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export type CloudProviderId = "claude-cloud" | "codex-cloud";
|
|
2
|
+
export declare const CLOUD_PROVIDER_IDS: readonly CloudProviderId[];
|
|
3
|
+
export declare function isCloudProviderId(value: string): value is CloudProviderId;
|
|
4
|
+
export declare const CLOUD_LABELS: Record<CloudProviderId, string>;
|
|
5
|
+
/** Whether a provider can take work for a project right now, and why not. */
|
|
6
|
+
export interface CloudAvailability {
|
|
7
|
+
id: CloudProviderId;
|
|
8
|
+
available: boolean;
|
|
9
|
+
/** Signed-in account, for display (email or plan). */
|
|
10
|
+
account?: string;
|
|
11
|
+
/** Environment tasks run in (Claude env_…, Codex environment id). */
|
|
12
|
+
environmentId?: string;
|
|
13
|
+
environmentName?: string;
|
|
14
|
+
/** One line for `ezcoder cloud status` / `validate workers`. */
|
|
15
|
+
detail: string;
|
|
16
|
+
/** What the user can do once to make it available. */
|
|
17
|
+
setupHint?: string;
|
|
18
|
+
/** Plan usage was exhausted; cloud is benched until then (ISO). */
|
|
19
|
+
limitedUntil?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The code a task starts from. */
|
|
22
|
+
export interface CloudSource {
|
|
23
|
+
/** Local repository root. */
|
|
24
|
+
repoRoot: string;
|
|
25
|
+
/** GitHub owner/name when the project has one. */
|
|
26
|
+
repo?: string;
|
|
27
|
+
/** Commit the work is based on (validation: the exact commit tested). */
|
|
28
|
+
sha: string;
|
|
29
|
+
/**
|
|
30
|
+
* Binary patch of uncommitted work on top of `sha` (agents only). Its
|
|
31
|
+
* result is the tree the task starts from.
|
|
32
|
+
*/
|
|
33
|
+
patch?: Buffer;
|
|
34
|
+
branch?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface CloudTaskRequest {
|
|
37
|
+
title: string;
|
|
38
|
+
prompt: string;
|
|
39
|
+
source: CloudSource;
|
|
40
|
+
/** Model id (provider default when absent). */
|
|
41
|
+
model?: string;
|
|
42
|
+
/** Hard cap on agent turns (validation: a handful). */
|
|
43
|
+
maxTurns?: number;
|
|
44
|
+
/** Tools the cloud agent may not use (validation: no edits). */
|
|
45
|
+
disallowedTools?: string[];
|
|
46
|
+
/** Longest one command may run, minutes (validation: stage timeout). */
|
|
47
|
+
commandTimeoutMinutes?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Runner tasks: the one exact shell command the sandbox may run. When its
|
|
50
|
+
* permission check pauses on that command, the provider approves it; any
|
|
51
|
+
* other command it asks about is denied.
|
|
52
|
+
*/
|
|
53
|
+
approveCommand?: string;
|
|
54
|
+
/** A runner task: lean system prompt and the shell tool only. */
|
|
55
|
+
runner?: boolean;
|
|
56
|
+
/** Plain environment for the sandbox. Never secrets. */
|
|
57
|
+
env?: Record<string, string>;
|
|
58
|
+
}
|
|
59
|
+
export interface CloudTaskHandle {
|
|
60
|
+
provider: CloudProviderId;
|
|
61
|
+
/** session_… (Claude) or task id (Codex). */
|
|
62
|
+
id: string;
|
|
63
|
+
url: string;
|
|
64
|
+
/** Tree hash of the code the task started from (snapshot); used to build diffs. */
|
|
65
|
+
baseTree?: string;
|
|
66
|
+
/** Local commit (created with commit-tree) whose tree the task started from. */
|
|
67
|
+
baseCommit?: string;
|
|
68
|
+
/** Local repository the task came from (providers that build diffs with local git). */
|
|
69
|
+
repoRoot?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The one command permission prompts may approve (CloudTaskRequest.approveCommand),
|
|
72
|
+
* kept on the handle so a restarted poller can rebuild it.
|
|
73
|
+
*/
|
|
74
|
+
approveCommand?: string;
|
|
75
|
+
}
|
|
76
|
+
export type CloudTaskState = "starting" | "running" | "idle" | "failed" | "cancelled";
|
|
77
|
+
/** A command the sandbox ran, as recorded by the provider's harness (not the model). */
|
|
78
|
+
export interface CloudCommandRecord {
|
|
79
|
+
command: string;
|
|
80
|
+
output: string;
|
|
81
|
+
isError: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface CloudTaskStatus {
|
|
84
|
+
state: CloudTaskState;
|
|
85
|
+
/** Last assistant text of the latest turn. */
|
|
86
|
+
finalText?: string;
|
|
87
|
+
/** Commands recorded by the harness, oldest first. */
|
|
88
|
+
commands: CloudCommandRecord[];
|
|
89
|
+
/** Turns finished so far. */
|
|
90
|
+
turns: number;
|
|
91
|
+
/** Plan usage stopped the task, or nearly did. */
|
|
92
|
+
usage?: {
|
|
93
|
+
limited: boolean;
|
|
94
|
+
utilization?: number;
|
|
95
|
+
resetsAt?: string;
|
|
96
|
+
};
|
|
97
|
+
/** Why the task failed, when it did. */
|
|
98
|
+
error?: string;
|
|
99
|
+
/** Activity for progress display: last tool name and its input. */
|
|
100
|
+
activity?: {
|
|
101
|
+
tool: string;
|
|
102
|
+
input: Record<string, unknown>;
|
|
103
|
+
}[];
|
|
104
|
+
usageTokens?: {
|
|
105
|
+
input: number;
|
|
106
|
+
output: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** One cloud backend. Implementations must never put secrets into a task. */
|
|
110
|
+
export interface CloudProvider {
|
|
111
|
+
readonly id: CloudProviderId;
|
|
112
|
+
/** Signed in, plan allows it, environment ready for this project? */
|
|
113
|
+
detect(project?: {
|
|
114
|
+
repoRoot?: string;
|
|
115
|
+
repo?: string;
|
|
116
|
+
}): Promise<CloudAvailability>;
|
|
117
|
+
start(request: CloudTaskRequest): Promise<CloudTaskHandle>;
|
|
118
|
+
status(handle: CloudTaskHandle): Promise<CloudTaskStatus>;
|
|
119
|
+
/** Queue a follow-up message into the task. */
|
|
120
|
+
send(handle: CloudTaskHandle, message: string): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* The task's changes as a binary patch against the tree it started from
|
|
123
|
+
* (`handle.baseTree`); empty when it changed nothing.
|
|
124
|
+
*/
|
|
125
|
+
diff(handle: CloudTaskHandle): Promise<Buffer>;
|
|
126
|
+
/** Stop the current turn. */
|
|
127
|
+
interrupt(handle: CloudTaskHandle): Promise<void>;
|
|
128
|
+
/** Remove it from the user's task list (best effort). */
|
|
129
|
+
archive(handle: CloudTaskHandle): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
export declare class CloudError extends Error {
|
|
132
|
+
readonly code: "not_signed_in" | "not_allowed" | "no_environment" | "usage_limited" | "too_large" | "http" | "unreachable" | "not_found";
|
|
133
|
+
readonly status?: number | undefined;
|
|
134
|
+
/** Usage limits: when it lifts (ISO). */
|
|
135
|
+
readonly until?: string | undefined;
|
|
136
|
+
constructor(message: string, code: "not_signed_in" | "not_allowed" | "no_environment" | "usage_limited" | "too_large" | "http" | "unreachable" | "not_found", status?: number | undefined,
|
|
137
|
+
/** Usage limits: when it lifts (ISO). */
|
|
138
|
+
until?: string | undefined);
|
|
139
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Cloud agent environments as compute: Claude Code cloud sessions and Codex
|
|
2
|
+
// cloud tasks. Both are AI sandboxes (a model runs the commands), reached with
|
|
3
|
+
// the subscription sign-ins EZ Coder already holds, so nothing is installed
|
|
4
|
+
// and no extra login is needed. Used as a fallback when self-hosted machines
|
|
5
|
+
// are busy or offline: validation stages, one-off jobs and helper agents.
|
|
6
|
+
export const CLOUD_PROVIDER_IDS = ["claude-cloud", "codex-cloud"];
|
|
7
|
+
export function isCloudProviderId(value) {
|
|
8
|
+
return CLOUD_PROVIDER_IDS.includes(value);
|
|
9
|
+
}
|
|
10
|
+
export const CLOUD_LABELS = {
|
|
11
|
+
"claude-cloud": "Claude Code cloud",
|
|
12
|
+
"codex-cloud": "Codex cloud",
|
|
13
|
+
};
|
|
14
|
+
export class CloudError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
status;
|
|
17
|
+
until;
|
|
18
|
+
constructor(message, code, status,
|
|
19
|
+
/** Usage limits: when it lifts (ISO). */
|
|
20
|
+
until) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.until = until;
|
|
25
|
+
this.name = "CloudError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/cloud/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAI1E,MAAM,CAAC,MAAM,kBAAkB,GAA+B,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AAE9F,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAQ,kBAAwC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAoC;IAC3D,cAAc,EAAE,mBAAmB;IACnC,aAAa,EAAE,aAAa;CAC7B,CAAC;AAgIF,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGxB;IASA;IAEA;IAbX,YACE,OAAe,EACN,IAQM,EACN,MAAe;IACxB,yCAAyC;IAChC,KAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAbN,SAAI,GAAJ,IAAI,CAQE;QACN,WAAM,GAAN,MAAM,CAAS;QAEf,UAAK,GAAL,KAAK,CAAS;QAGvB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,22 +1,105 @@
|
|
|
1
|
-
import
|
|
1
|
+
import https from "node:https";
|
|
2
|
+
import { type Duplex } from "node:stream";
|
|
3
|
+
import { type AgentDiff, type AgentRequest, type AgentWorkspaceStatus, type DoctorReport, type ExecRequest, type ExecResponse, type HelloResponse, type JobRequest, type JobStatus, type NodeInfo, type PairCodeResponse, type RotateTokenResponse, type ServiceRequest, type ServiceStatus, type ShareAuthRequest, type UpdateRequest, type UpdateResponse } from "./protocol.js";
|
|
2
4
|
import { type FleetNode } from "./registry.js";
|
|
3
|
-
export type FleetErrorCode = "unreachable" | "timeout" | "auth" | "busy" | "not_found" | "bad_request" | "http"
|
|
5
|
+
export type FleetErrorCode = "unreachable" | "timeout" | "auth" | "busy" | "not_found" | "bad_request" | "http"
|
|
6
|
+
/** S3: the two sides speak no common protocol; `update` names the side to update. */
|
|
7
|
+
| "incompatible"
|
|
8
|
+
/** R8: the node already has credentials (409). */
|
|
9
|
+
| "exists"
|
|
10
|
+
/** S9: pairing code wrong, expired or used. */
|
|
11
|
+
| "bad_code" | "rate_limited"
|
|
12
|
+
/** X5: the node runs only containerised work. */
|
|
13
|
+
| "docker_only"
|
|
14
|
+
/** X10: the node's certificate is not the pinned one. */
|
|
15
|
+
| "tls_mismatch";
|
|
4
16
|
export declare class FleetClientError extends Error {
|
|
5
17
|
readonly code: FleetErrorCode;
|
|
6
18
|
readonly status?: number | undefined;
|
|
7
|
-
|
|
19
|
+
/** For "incompatible": which side must be updated. */
|
|
20
|
+
readonly update?: "node" | "controller" | undefined;
|
|
21
|
+
/** For "busy": how long the node asked us to wait (Retry-After), ms. */
|
|
22
|
+
readonly retryAfterMs?: number | undefined;
|
|
23
|
+
constructor(message: string, code: FleetErrorCode, status?: number | undefined,
|
|
24
|
+
/** For "incompatible": which side must be updated. */
|
|
25
|
+
update?: "node" | "controller" | undefined,
|
|
26
|
+
/** For "busy": how long the node asked us to wait (Retry-After), ms. */
|
|
27
|
+
retryAfterMs?: number | undefined);
|
|
8
28
|
}
|
|
29
|
+
/** This machine's EZ Coder version (sent as VERSION_HEADER, compared with nodes for S7). */
|
|
30
|
+
export declare function controllerVersion(): string;
|
|
31
|
+
/** -1 / 0 / 1 for dotted versions ("1.2.10" > "1.2.9"); a pre-release sorts before its release. */
|
|
32
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
33
|
+
export interface ProtocolProblem {
|
|
34
|
+
update: "node" | "controller";
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* S3: can this controller work with a node that answered `hello`? Compatible
|
|
39
|
+
* when the node's protocol is in our range, or the (newer) node still accepts
|
|
40
|
+
* ours. Otherwise the side with the lower protocol must be updated.
|
|
41
|
+
*/
|
|
42
|
+
export declare function protocolProblem(name: string, hello: Pick<HelloResponse, "protocol" | "minProtocol">): ProtocolProblem | undefined;
|
|
43
|
+
/** Safe relative artifact path: no absolute paths, no `..`, no `.git` segment (R7). */
|
|
44
|
+
export declare function safeArtifactPath(p: string): string | undefined;
|
|
45
|
+
export declare class TlsPinError extends Error {
|
|
46
|
+
readonly expected: string;
|
|
47
|
+
readonly actual: string;
|
|
48
|
+
constructor(expected: string, actual: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* An https Agent that accepts exactly one certificate: the one whose SHA-256
|
|
52
|
+
* is `fingerprint` (self-signed node certs have no CA). The socket reaches the
|
|
53
|
+
* request only after the check, so nothing (not even the token) is sent to an
|
|
54
|
+
* impostor. Without a pin it only records the certificate seen (`onPeer`).
|
|
55
|
+
*/
|
|
56
|
+
export declare class PinnedTlsAgent extends https.Agent {
|
|
57
|
+
private readonly fingerprint;
|
|
58
|
+
private readonly onPeer?;
|
|
59
|
+
constructor(fingerprint: string | undefined, onPeer?: ((fingerprint: string) => void) | undefined);
|
|
60
|
+
createConnection(options: https.RequestOptions, callback?: (err: Error | null, stream: Duplex) => void): Duplex | null | undefined;
|
|
61
|
+
}
|
|
62
|
+
/** fetch() over node:https with a given Agent (global fetch can't pin a self-signed cert). */
|
|
63
|
+
export declare function pinnedFetch(agent: https.Agent): typeof fetch;
|
|
64
|
+
/** https Agent for WebSockets (`ws` option `agent`) to a pinned node. */
|
|
65
|
+
export declare function pinnedTlsAgent(fingerprint: string): https.Agent;
|
|
9
66
|
export interface FleetClientOptions {
|
|
10
67
|
/** Per-request timeout (default 15 s). */
|
|
11
68
|
timeoutMs?: number;
|
|
12
69
|
fetch?: typeof fetch;
|
|
70
|
+
/** Pinned TLS certificate (64 hex) for https nodes. */
|
|
71
|
+
fingerprint?: string;
|
|
72
|
+
/** https without a pin: report the certificate seen (pairing by code). */
|
|
73
|
+
onPeerFingerprint?: (fingerprint: string) => void;
|
|
74
|
+
}
|
|
75
|
+
export interface LogQuery {
|
|
76
|
+
/** Last N lines (after grep). */
|
|
77
|
+
tail?: number;
|
|
78
|
+
/** Bytes from this offset. */
|
|
79
|
+
offset?: number;
|
|
80
|
+
/** Max bytes from offset. */
|
|
81
|
+
limit?: number;
|
|
82
|
+
/** JS regex (max 200 chars) filtering lines on the node. */
|
|
83
|
+
grep?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface LogSlice {
|
|
86
|
+
text: string;
|
|
87
|
+
/** Whole log size in bytes (X-Log-Size). */
|
|
88
|
+
size: number;
|
|
89
|
+
/** The node capped the log and dropped its middle (R6). */
|
|
90
|
+
truncated: boolean;
|
|
13
91
|
}
|
|
92
|
+
/** Retry-After (seconds or an HTTP date) in ms; undefined when absent or unreadable. Capped at 10 min. */
|
|
93
|
+
export declare function parseRetryAfter(v: string | null, now?: number): number | undefined;
|
|
94
|
+
/** Pairing codes are 8 Crockford base32 characters, shown as XXXX-XXXX. */
|
|
95
|
+
export declare function normalizePairCode(code: string): string | undefined;
|
|
14
96
|
export declare class FleetClient {
|
|
15
97
|
readonly name: string;
|
|
16
|
-
private
|
|
98
|
+
private token;
|
|
17
99
|
readonly baseUrl: string;
|
|
18
100
|
private readonly timeoutMs;
|
|
19
101
|
private readonly doFetch;
|
|
102
|
+
private readonly fingerprint;
|
|
20
103
|
constructor(name: string, baseUrl: string, token: string | undefined, opts?: FleetClientOptions);
|
|
21
104
|
static forNode(node: FleetNode, opts?: FleetClientOptions): FleetClient;
|
|
22
105
|
private where;
|
|
@@ -28,7 +111,17 @@ export declare class FleetClient {
|
|
|
28
111
|
}): Promise<Response>;
|
|
29
112
|
private json;
|
|
30
113
|
hello(timeoutMs?: number): Promise<HelloResponse>;
|
|
114
|
+
/** hello plus the S3 protocol check: throws "incompatible" naming the side to update. */
|
|
115
|
+
handshake(timeoutMs?: number): Promise<HelloResponse>;
|
|
31
116
|
info(): Promise<NodeInfo>;
|
|
117
|
+
/** S1/A4: the node checks itself (Docker, GPU, git access to `repo`, login, disk, ...). */
|
|
118
|
+
doctor(repo?: string): Promise<DoctorReport>;
|
|
119
|
+
/** S4: a new token on the node; the old one stops working at once. This client switches over. */
|
|
120
|
+
rotateToken(): Promise<RotateTokenResponse>;
|
|
121
|
+
/** S7: ask the node to install another CLI version (default latest) and restart. */
|
|
122
|
+
update(req?: UpdateRequest): Promise<UpdateResponse>;
|
|
123
|
+
/** S9: trade a short pairing code (no token needed) for the full pairing string. */
|
|
124
|
+
pairWithCode(code: string): Promise<PairCodeResponse>;
|
|
32
125
|
submitJob(req: JobRequest): Promise<JobStatus>;
|
|
33
126
|
job(id: string): Promise<JobStatus>;
|
|
34
127
|
/** Log bytes from `offset`; `size` is the whole log's size (X-Log-Size). */
|
|
@@ -36,7 +129,12 @@ export declare class FleetClient {
|
|
|
36
129
|
text: string;
|
|
37
130
|
size: number;
|
|
38
131
|
}>;
|
|
39
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* A slice of a job's log, cut on the node (A2): the last `tail` lines (after
|
|
134
|
+
* `grep`), or `limit` bytes from `offset`. A tail never downloads the whole log.
|
|
135
|
+
*/
|
|
136
|
+
logs(id: string, q?: LogQuery): Promise<LogSlice>;
|
|
137
|
+
/** Download one artifact to `dest`: streamed to a temp file, then renamed (R7). */
|
|
40
138
|
downloadArtifact(id: string, artifactPath: string, dest: string): Promise<number>;
|
|
41
139
|
cancelJob(id: string, purge?: boolean): Promise<JobStatus>;
|
|
42
140
|
services(): Promise<ServiceStatus[]>;
|
|
@@ -48,11 +146,13 @@ export declare class FleetClient {
|
|
|
48
146
|
createAgent(req: AgentRequest): Promise<AgentWorkspaceStatus>;
|
|
49
147
|
agentDiff(id: string): Promise<AgentDiff>;
|
|
50
148
|
deleteAgent(id: string): Promise<void>;
|
|
51
|
-
/** WebSocket URL + headers for GET /v1/agents/:id/attach. */
|
|
149
|
+
/** WebSocket URL + headers for GET /v1/agents/:id/attach (`agent` pins TLS nodes). */
|
|
52
150
|
attachTarget(id: string): {
|
|
53
151
|
url: string;
|
|
54
152
|
headers: Record<string, string>;
|
|
153
|
+
agent?: https.Agent;
|
|
55
154
|
};
|
|
155
|
+
/** Throws FleetClientError "exists" (409) when the node has credentials and `force` is unset (R8). */
|
|
56
156
|
shareAuth(req: ShareAuthRequest): Promise<void>;
|
|
57
157
|
}
|
|
58
158
|
export interface NodeLookupOptions extends FleetClientOptions {
|