@dreamlake/dreamlake-cli 0.119.0 → 0.119.2
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/dist/cli/hosts/api.js +12 -2
- package/dist/cli/hosts/enroll.js +1 -1
- package/dist/cli/hosts/ssh.d.ts +7 -0
- package/dist/cli/hosts/ssh.js +24 -4
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
package/dist/cli/hosts/api.js
CHANGED
|
@@ -6,6 +6,15 @@ const SAFE_POWER_CODES = new Set([
|
|
|
6
6
|
"provider_binding_revoked", "enrollment_revoked", "active_work_present", "request_id_conflict",
|
|
7
7
|
"invalid_power_request", "invalid_request_id", "volume_disposition_required", "host_lifecycle_unavailable",
|
|
8
8
|
]);
|
|
9
|
+
// Terminal errors arrive as `error`; they name the failing stage, never a credential.
|
|
10
|
+
const TERMINAL_CODES = new Set([
|
|
11
|
+
"terminal_inventory_limit", "terminal_not_ready", "terminal_unavailable", "terminal_access_denied", "terminal_invalid_request",
|
|
12
|
+
"controlplane_unavailable", "controlplane_identity_conflict",
|
|
13
|
+
]);
|
|
14
|
+
const TERMINAL_GUIDANCE = {
|
|
15
|
+
terminal_inventory_limit: "; the namespace has more terminal targets than one unpaged listing returns. dl exec, ssh and tmux resolve the exact host in current releases: update the CLI",
|
|
16
|
+
terminal_not_ready: "; the enrollment is not online with SSH available. Inspect it with dl hosts enrollments <host>",
|
|
17
|
+
};
|
|
9
18
|
export class HostApiError extends Error {
|
|
10
19
|
status;
|
|
11
20
|
operationId;
|
|
@@ -45,10 +54,11 @@ export async function hostRequest(path, method = "GET", body, connection) {
|
|
|
45
54
|
const retryAt = typeof data.retryAt === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(data.retryAt) && Number.isFinite(Date.parse(data.retryAt)) ? data.retryAt : undefined;
|
|
46
55
|
// A busy control plane refused the write before running it, so the caller may resubmit after Retry-After.
|
|
47
56
|
const busy = result.status === 503 && data.error === "controlplane_busy";
|
|
48
|
-
const code = busy ? "controlplane_busy" : typeof data.code === "string" && SAFE_POWER_CODES.has(data.code) ? data.code
|
|
57
|
+
const code = busy ? "controlplane_busy" : typeof data.code === "string" && SAFE_POWER_CODES.has(data.code) ? data.code
|
|
58
|
+
: typeof data.error === "string" && TERMINAL_CODES.has(data.error) ? data.error : undefined;
|
|
49
59
|
const retryAfter = Number(result.headers.get("retry-after"));
|
|
50
60
|
const busyRetryAt = busy && Number.isFinite(retryAfter) && retryAfter >= 0 ? new Date(Date.now() + retryAfter * 1000).toISOString() : undefined;
|
|
51
|
-
throw new HostApiError(`Host API request failed (HTTP ${result.status})${code ? `: ${code}` : ""}`, result.status, operationId, retryAt ?? busyRetryAt, code);
|
|
61
|
+
throw new HostApiError(`Host API request failed (HTTP ${result.status})${code ? `: ${code}${TERMINAL_GUIDANCE[code] ?? ""}` : ""}`, result.status, operationId, retryAt ?? busyRetryAt, code);
|
|
52
62
|
}
|
|
53
63
|
try {
|
|
54
64
|
return await result.json();
|
package/dist/cli/hosts/enroll.js
CHANGED
|
@@ -94,7 +94,7 @@ export async function hostStatus(selector, opts = {}, request = hostRequest) {
|
|
|
94
94
|
export async function waitForWebTerminal(namespace, hostId, enrollmentId, deadline, request = hostRequest, sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))) {
|
|
95
95
|
while (true) {
|
|
96
96
|
try {
|
|
97
|
-
const result = await request(`/namespaces/${encodeURIComponent(namespace)}/hosts/terminal-targets`);
|
|
97
|
+
const result = await request(`/namespaces/${encodeURIComponent(namespace)}/hosts/terminal-targets?hostId=${encodeURIComponent(hostId)}&enrollmentId=${encodeURIComponent(enrollmentId)}`);
|
|
98
98
|
const target = result.targets?.find((entry) => entry.hostId === hostId && entry.enrollmentId === enrollmentId);
|
|
99
99
|
if (typeof target?.id === "string")
|
|
100
100
|
return { status: "ready", targetId: target.id };
|
package/dist/cli/hosts/ssh.d.ts
CHANGED
|
@@ -88,5 +88,12 @@ export declare class SshRelay extends Duplex {
|
|
|
88
88
|
_final(done: (error?: Error | null) => void): void;
|
|
89
89
|
_destroy(error: Error | null, done: (error?: Error | null) => void): void;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Ready targets of one host, or of one explicit enrollment on it. The exact lookup never lists the namespace, so the
|
|
93
|
+
* rest of the fleet (archived or not) cannot block a connection. An older API
|
|
94
|
+
* ignores the query and returns its whole catalog; the caller's hostId filter
|
|
95
|
+
* still narrows it.
|
|
96
|
+
*/
|
|
97
|
+
export declare function hostTerminalTargets(request: SshIO['request'], base: string, hostId: string, enrollmentId?: string): Promise<SshTarget[]>;
|
|
91
98
|
export declare function runHostSsh(selector: string, opts: SshOptions, argv?: string[], io?: SshIO): Promise<number>;
|
|
92
99
|
export declare function registerHostSshCommands(hosts: Command, program: Command): void;
|
package/dist/cli/hosts/ssh.js
CHANGED
|
@@ -178,6 +178,28 @@ export class SshRelay extends Duplex {
|
|
|
178
178
|
_final(done) { this.ws.send(Buffer.from([1]), { binary: true }, error => done(error ? new Error('SSH relay FIN failed') : undefined)); }
|
|
179
179
|
_destroy(error, done) { this.ws.terminate(); done(error); }
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Ready targets of one host, or of one explicit enrollment on it. The exact lookup never lists the namespace, so the
|
|
183
|
+
* rest of the fleet (archived or not) cannot block a connection. An older API
|
|
184
|
+
* ignores the query and returns its whole catalog; the caller's hostId filter
|
|
185
|
+
* still narrows it.
|
|
186
|
+
*/
|
|
187
|
+
export async function hostTerminalTargets(request, base, hostId, enrollmentId) {
|
|
188
|
+
const targets = [];
|
|
189
|
+
let cursor;
|
|
190
|
+
for (let page = 0; page < 10; page++) {
|
|
191
|
+
const catalog = await request(`${base}/terminal-targets?hostId=${hostId}${enrollmentId ? `&enrollmentId=${enrollmentId}` : ''}&limit=100${cursor ? `&cursor=${cursor}` : ''}`);
|
|
192
|
+
if (!Array.isArray(catalog?.targets))
|
|
193
|
+
throw new Error('Invalid SSH target catalog');
|
|
194
|
+
targets.push(...catalog.targets);
|
|
195
|
+
if (catalog.nextCursor == null)
|
|
196
|
+
return targets;
|
|
197
|
+
if (typeof catalog.nextCursor !== 'string' || !ID.test(catalog.nextCursor) || (cursor !== undefined && catalog.nextCursor <= cursor))
|
|
198
|
+
throw new Error('Invalid SSH target catalog');
|
|
199
|
+
cursor = catalog.nextCursor;
|
|
200
|
+
}
|
|
201
|
+
throw new Error('Invalid SSH target catalog');
|
|
202
|
+
}
|
|
181
203
|
export async function runHostSsh(selector, opts, argv, io = defaultSshIO) {
|
|
182
204
|
if (process.platform === 'win32')
|
|
183
205
|
throw new Error('Host SSH currently requires Linux or macOS and OpenSSH');
|
|
@@ -224,10 +246,8 @@ export async function runHostSsh(selector, opts, argv, io = defaultSshIO) {
|
|
|
224
246
|
if (/^[a-f0-9]{24}$/i.test(selector) ? detail.host.id !== selector.toLowerCase() : detail.host.name !== selector)
|
|
225
247
|
throw new Error('Host API returned a different host identity');
|
|
226
248
|
const base = hostApiPath(namespace);
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
throw new Error('Invalid SSH target catalog');
|
|
230
|
-
const matches = catalog.targets.filter((t) => t.hostId === detail.host.id && (!opts.enrollment || t.enrollmentId === opts.enrollment));
|
|
249
|
+
const targets = await hostTerminalTargets(io.request, base, detail.host.id, opts.enrollment);
|
|
250
|
+
const matches = targets.filter((t) => t.hostId === detail.host.id && (!opts.enrollment || t.enrollmentId === opts.enrollment));
|
|
231
251
|
// Validate every displayed identity before prompting, and preserve the same
|
|
232
252
|
// host/enrollment binding and host-key checks after the selection.
|
|
233
253
|
for (const target of matches) {
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.119.
|
|
1
|
+
export declare const VERSION = "0.119.2";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.119.
|
|
3
|
+
"version": "0.119.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"node": ">=18"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.119.
|
|
41
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.119.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.119.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.119.
|
|
44
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.119.
|
|
45
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.119.
|
|
46
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.119.
|
|
47
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.119.
|
|
40
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.119.2",
|
|
41
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.119.2",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.119.2",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.119.2",
|
|
44
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.119.2",
|
|
45
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.119.2",
|
|
46
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.119.2",
|
|
47
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.119.2"
|
|
48
48
|
}
|
|
49
49
|
}
|