skydive-cli 0.5.0-beta.4 → 0.5.0-beta.41
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/CHANGELOG.md +8 -0
- package/README.md +35 -4
- package/dist/js/api-DQCaztBg.mjs +315 -0
- package/dist/js/{billing-blocked-Dgu5-oDy.mjs → billing-blocked-SE6tySLd.mjs} +1 -1
- package/dist/js/bin.mjs +655 -278
- package/dist/js/{boot-B_93T51X.mjs → boot-B1Y1D48W.mjs} +2980 -823
- package/dist/js/chunk-BbwQpWto.mjs +33 -0
- package/dist/js/{client-Cn2af31H.mjs → client-Btq6bMzX.mjs} +108 -2
- package/dist/js/client-DCwVlAal.mjs +5 -0
- package/dist/js/{client-Dd5sMXPv.mjs → client-DMYwKALl.mjs} +348 -141
- package/dist/js/daemon-By-I_HVM.mjs +7 -0
- package/dist/js/{daemon-BYlIJN6x.mjs → daemon-D8WoX21I.mjs} +43 -7
- package/dist/js/{daemon-client-DPjmvIDE.mjs → daemon-client-Bp5DMeIi.mjs} +12 -8
- package/dist/js/daemon-client-_SVAskeO.mjs +8 -0
- package/dist/js/dist-CRtjM7ba.mjs +1750 -0
- package/dist/js/forward-zwB55Bls.mjs +208 -0
- package/dist/js/{profiler-RmWjKIHD.mjs → install-BkMcGVYS.mjs} +529 -211
- package/dist/js/launcher.mjs +49 -0
- package/dist/js/localhost-cert-Bn-UBUmj.mjs +67 -0
- package/dist/js/{print-ba_0hiV9.mjs → print-BAmEefvX.mjs} +3 -3
- package/dist/js/{print-CbayCa87.mjs → print-CwbdwCeQ.mjs} +213 -37
- package/dist/js/{print-share-uwUG16Ov.mjs → print-share-azWHVxpt.mjs} +8 -2
- package/dist/js/raw-pty-Ci2qFR9F.mjs +5 -0
- package/dist/js/{raw-pty-B6mAroiI.mjs → raw-pty-D5PhKZSl.mjs} +1 -1
- package/dist/js/rest-B5DVQ1LM.mjs +6 -0
- package/dist/js/{rest-BY2nADw5.mjs → rest-Bbe-RhMy.mjs} +105 -25
- package/dist/js/tls-cert-CLgSQALB.mjs +4 -0
- package/dist/js/tls-cert-CV-pwxVN.mjs +67 -0
- package/package.json +11 -4
- package/dist/js/client-DZstLQ_1.mjs +0 -4
- package/dist/js/daemon-CBvFKDpy.mjs +0 -5
- package/dist/js/daemon-client-Z4Ce4zf-.mjs +0 -6
- package/dist/js/raw-pty-3EkG-jjH.mjs +0 -5
- package/dist/js/rest-DADJh0bi.mjs +0 -6
- /package/dist/js/{billing-blocked-2wju4gC_.mjs → billing-blocked-D3l5kJlX.mjs} +0 -0
- /package/dist/js/{http-error-DzyrsLAZ.mjs → http-error-UHH3mVBF.mjs} +0 -0
- /package/dist/js/{output-DYzzdXYV.mjs → output-wY0VQDea.mjs} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
//#region src/launcher.ts
|
|
8
|
+
const PLATFORM_PACKAGES = {
|
|
9
|
+
"darwin-arm64": "skydive-cli-darwin-arm64",
|
|
10
|
+
"darwin-x64": "skydive-cli-darwin-x64",
|
|
11
|
+
"linux-x64": "skydive-cli-linux-x64",
|
|
12
|
+
"linux-arm64": "skydive-cli-linux-arm64"
|
|
13
|
+
};
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
/** The compiled per-platform binary, or null if none is installed/available. */
|
|
16
|
+
function resolveBinaryPath() {
|
|
17
|
+
const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
|
|
18
|
+
if (!pkg) return null;
|
|
19
|
+
try {
|
|
20
|
+
return require.resolve(`${pkg}/bin`);
|
|
21
|
+
} catch (_error) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** The JS bundle sibling of this launcher (`dist/js/bin.mjs`). */
|
|
26
|
+
function jsBundlePath() {
|
|
27
|
+
return path.join(path.dirname(fileURLToPath(import.meta.url)), "bin.mjs");
|
|
28
|
+
}
|
|
29
|
+
const args = process.argv.slice(2);
|
|
30
|
+
const binaryPath = resolveBinaryPath();
|
|
31
|
+
let child;
|
|
32
|
+
if (binaryPath) {
|
|
33
|
+
const env = { ...process.env };
|
|
34
|
+
if (env["SKYDIVE_CLI_INSTALL_SOURCE"] === void 0) env["SKYDIVE_CLI_INSTALL_SOURCE"] = "package-manager";
|
|
35
|
+
child = spawnSync(binaryPath, args, {
|
|
36
|
+
stdio: "inherit",
|
|
37
|
+
env
|
|
38
|
+
});
|
|
39
|
+
} else child = spawnSync(process.execPath, [jsBundlePath(), ...args], { stdio: "inherit" });
|
|
40
|
+
if (child.error) {
|
|
41
|
+
const what = binaryPath ? `the platform binary (${binaryPath})` : `the CLI under Node (${process.execPath})`;
|
|
42
|
+
process.stderr.write(`skydive: failed to launch ${what}: ${child.error.message}\n`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
if (child.signal) process.kill(process.pid, child.signal);
|
|
46
|
+
else process.exit(child.status ?? 0);
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { r as __toESM } from "./chunk-BbwQpWto.mjs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
6
|
+
|
|
7
|
+
//#region ../portal-daemon/src/localhost-cert.ts
|
|
8
|
+
/**
|
|
9
|
+
* Durable home for the one piece of state devcert doesn't keep for us: the
|
|
10
|
+
* user's decision to skip automatic cert setup. The daemon's own state dir is
|
|
11
|
+
* tmpdir-based (wiped on reboot), and re-raising a system trust prompt on
|
|
12
|
+
* every `portal forward` after a decline is exactly the nagging that trains
|
|
13
|
+
* people to fear the feature.
|
|
14
|
+
*/
|
|
15
|
+
function declineMarkerPath() {
|
|
16
|
+
return path.join(os.homedir(), ".config", "skydive-portal", "tls-declined");
|
|
17
|
+
}
|
|
18
|
+
async function hasDeclined() {
|
|
19
|
+
try {
|
|
20
|
+
await readFile(declineMarkerPath());
|
|
21
|
+
return true;
|
|
22
|
+
} catch (_error) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function recordDecline(reason) {
|
|
27
|
+
const marker = declineMarkerPath();
|
|
28
|
+
try {
|
|
29
|
+
await mkdir(path.dirname(marker), { recursive: true });
|
|
30
|
+
await writeFile(marker, `Automatic localhost TLS setup failed or was declined:\n${reason}\n\nDelete this file to let it try again.\n`);
|
|
31
|
+
} catch (_error) {}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fully automatic localhost cert: devcert generates a per-machine local CA on
|
|
35
|
+
* first use, installs it into the system/browser trust stores (one OS-native
|
|
36
|
+
* consent prompt, the mkcert pattern), signs a `localhost` leaf, and reuses
|
|
37
|
+
* both silently on every later run. The private key never leaves the machine
|
|
38
|
+
* and the CA is unique to it, so trusting it vouches only for this user's own
|
|
39
|
+
* loopback.
|
|
40
|
+
*
|
|
41
|
+
* Every failure — the user declining the trust prompt included — degrades to
|
|
42
|
+
* the plain-http origin (the product default) with one log line, and writes a
|
|
43
|
+
* marker so subsequent runs don't nag. `resetLocalhostCertDecline` (or
|
|
44
|
+
* deleting the marker file) re-arms it.
|
|
45
|
+
*/
|
|
46
|
+
function localhostCertSource(log) {
|
|
47
|
+
return async () => {
|
|
48
|
+
if (await hasDeclined()) return null;
|
|
49
|
+
try {
|
|
50
|
+
const { certificateFor } = await import("./dist-CRtjM7ba.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
51
|
+
const { key, cert } = await certificateFor("localhost", { skipHostsFile: true });
|
|
52
|
+
return {
|
|
53
|
+
key: key.toString(),
|
|
54
|
+
cert: cert.toString(),
|
|
55
|
+
hostname: "localhost"
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
59
|
+
await recordDecline(reason);
|
|
60
|
+
log(`portal: automatic localhost TLS setup didn't complete (${reason}). Continuing with http only; delete ~/.config/skydive-portal/tls-declined to try again.`);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { localhostCertSource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as runPrint, i as resolveAgent, n as messageGet, o as toPrintError, r as readStdin, t as collectRunText } from "./print-
|
|
3
|
-
import "./rest-
|
|
4
|
-
import "./billing-blocked-
|
|
2
|
+
import { a as runPrint, i as resolveAgent, n as messageGet, o as toPrintError, r as readStdin, t as collectRunText } from "./print-CwbdwCeQ.mjs";
|
|
3
|
+
import "./rest-Bbe-RhMy.mjs";
|
|
4
|
+
import "./billing-blocked-D3l5kJlX.mjs";
|
|
5
5
|
|
|
6
6
|
export { messageGet, readStdin, resolveAgent, runPrint };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as HttpError } from "./http-error-
|
|
3
|
-
import { a as isRecord, i as errorMessage, r as sendErrorMessage, t as createRestClient } from "./rest-
|
|
4
|
-
import { i as billingBlockedOutcomeFromSendResponse, n as BillingBlockedError } from "./billing-blocked-
|
|
2
|
+
import { t as HttpError } from "./http-error-UHH3mVBF.mjs";
|
|
3
|
+
import { a as isRecord, i as errorMessage, r as sendErrorMessage, t as createRestClient } from "./rest-Bbe-RhMy.mjs";
|
|
4
|
+
import { i as billingBlockedOutcomeFromSendResponse, n as BillingBlockedError } from "./billing-blocked-D3l5kJlX.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import Conf from "conf";
|
|
7
7
|
import { err, ok } from "neverthrow";
|
|
@@ -9,7 +9,7 @@ import stableStringify from "safe-stable-stringify";
|
|
|
9
9
|
|
|
10
10
|
//#region src/config.ts
|
|
11
11
|
/** Default host for the public management API (`/v1`, API-key auth). */
|
|
12
|
-
const DEFAULT_API_URL = "https://api.skydive.com";
|
|
12
|
+
const DEFAULT_API_URL = typeof SKYDIVE_BUILD_API_URL === "string" ? SKYDIVE_BUILD_API_URL : "https://api.skydive.com";
|
|
13
13
|
/**
|
|
14
14
|
* Default origin for the interactive chat client (`skydive chat`).
|
|
15
15
|
*
|
|
@@ -20,9 +20,9 @@ const DEFAULT_API_URL = "https://api.skydive.com";
|
|
|
20
20
|
* `DEFAULT_API_URL`; override with `--api-url` / `SKYDIVE_APP_URL` for local
|
|
21
21
|
* dev or while the DNS record is still being provisioned.
|
|
22
22
|
*/
|
|
23
|
-
const DEFAULT_APP_URL =
|
|
23
|
+
const DEFAULT_APP_URL = DEFAULT_API_URL;
|
|
24
24
|
/** Web front door, for pages opened in the user's browser. */
|
|
25
|
-
const DEFAULT_WEB_URL = "https://skydive.com";
|
|
25
|
+
const DEFAULT_WEB_URL = typeof SKYDIVE_BUILD_WEB_URL === "string" ? SKYDIVE_BUILD_WEB_URL : "https://skydive.com";
|
|
26
26
|
function resolveWebUrl(appUrl) {
|
|
27
27
|
if (appUrl == null) return appUrl;
|
|
28
28
|
return appUrl === DEFAULT_APP_URL ? DEFAULT_WEB_URL : appUrl;
|
|
@@ -213,6 +213,32 @@ function saveUpdateCheck(value) {
|
|
|
213
213
|
}
|
|
214
214
|
store.set("updateCheck", value);
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Agent a bare `skydive chat` (no --agent/--resume) opens a new conversation
|
|
218
|
+
* with. Any selector `--agent` accepts works: an id, or a unique
|
|
219
|
+
* case-insensitive slug/name, resolved against the active workspace's roster
|
|
220
|
+
* at launch. Null when unset (the launch falls back to the agent picker).
|
|
221
|
+
* A hand-edited blank value counts as unset rather than as a selector no
|
|
222
|
+
* agent could ever match.
|
|
223
|
+
*/
|
|
224
|
+
function getDefaultAgent() {
|
|
225
|
+
const value = store.get("defaultAgent")?.trim();
|
|
226
|
+
return value ? value : null;
|
|
227
|
+
}
|
|
228
|
+
function saveDefaultAgent(value) {
|
|
229
|
+
store.set("defaultAgent", value);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Remember the agent the chat TUI just opened a conversation with, so the
|
|
233
|
+
* next bare `skydive chat` returns to it (last used wins). Records the id —
|
|
234
|
+
* stable across renames, unlike a slug/name selector. Skips the write when
|
|
235
|
+
* the value already matches: this runs on every chat-screen entry, and an
|
|
236
|
+
* unchanged default shouldn't rewrite config.json.
|
|
237
|
+
*/
|
|
238
|
+
function recordDefaultAgent(agentId) {
|
|
239
|
+
if (getDefaultAgent() === agentId) return;
|
|
240
|
+
store.set("defaultAgent", agentId);
|
|
241
|
+
}
|
|
216
242
|
function parseBoolean(raw) {
|
|
217
243
|
const v = raw.trim().toLowerCase();
|
|
218
244
|
if ([
|
|
@@ -229,25 +255,40 @@ function parseBoolean(raw) {
|
|
|
229
255
|
].includes(v)) return ok(false);
|
|
230
256
|
return err(`Expected a boolean (true/false), got "${raw}".`);
|
|
231
257
|
}
|
|
232
|
-
const PREFERENCES = [
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
258
|
+
const PREFERENCES = [
|
|
259
|
+
{
|
|
260
|
+
key: "shareMachineDefault",
|
|
261
|
+
type: "boolean",
|
|
262
|
+
describe: "Share this machine over the portal on `skydive chat` launch, as if --share-machine were passed. Default false.",
|
|
263
|
+
read: () => getShareMachineDefault(),
|
|
264
|
+
isSet: () => store.has("shareMachineDefault"),
|
|
265
|
+
set: (raw) => parseBoolean(raw).map(saveShareMachineDefault),
|
|
266
|
+
clear: () => store.delete("shareMachineDefault")
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
key: "updateCheck",
|
|
270
|
+
type: "boolean",
|
|
271
|
+
describe: "Run the daily background update check and its \"Update available\" notice. Set false to disable. Default true.",
|
|
272
|
+
read: () => !getUpdateCheckDisabled(),
|
|
273
|
+
isSet: () => store.has("updateCheck"),
|
|
274
|
+
set: (raw) => parseBoolean(raw).map(saveUpdateCheck),
|
|
275
|
+
clear: () => store.delete("updateCheck")
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
key: "defaultAgent",
|
|
279
|
+
type: "string",
|
|
280
|
+
describe: "Agent (id, slug, or name) a bare `skydive chat` opens a new conversation with, skipping the agent picker. Unset by default.",
|
|
281
|
+
read: () => getDefaultAgent(),
|
|
282
|
+
isSet: () => getDefaultAgent() !== null,
|
|
283
|
+
set: (raw) => {
|
|
284
|
+
const value = raw.trim();
|
|
285
|
+
if (!value) return err("Expected an agent id, slug, or name (use `config unset defaultAgent` to clear it).");
|
|
286
|
+
saveDefaultAgent(value);
|
|
287
|
+
return ok(void 0);
|
|
288
|
+
},
|
|
289
|
+
clear: () => store.delete("defaultAgent")
|
|
290
|
+
}
|
|
291
|
+
];
|
|
251
292
|
function getPreference(key) {
|
|
252
293
|
return PREFERENCES.find((p) => p.key === key);
|
|
253
294
|
}
|
|
@@ -282,14 +323,15 @@ function parseButton(element) {
|
|
|
282
323
|
const params = isRecord(press.params) ? press.params : {};
|
|
283
324
|
const primary = props.variant === "primary";
|
|
284
325
|
if (press.action === "approve_portal_access") {
|
|
285
|
-
const agentId = params.agentId;
|
|
286
|
-
if (
|
|
326
|
+
const agentId = optionalString(params.agentId);
|
|
327
|
+
if (!agentId) return null;
|
|
287
328
|
return {
|
|
288
329
|
label,
|
|
289
330
|
action: {
|
|
290
331
|
kind: "grant_portal",
|
|
291
332
|
agentId,
|
|
292
|
-
deviceId:
|
|
333
|
+
deviceId: optionalString(params.deviceId),
|
|
334
|
+
conversationId: optionalString(params.conversationId)
|
|
293
335
|
},
|
|
294
336
|
primary
|
|
295
337
|
};
|
|
@@ -323,12 +365,131 @@ function parseButton(element) {
|
|
|
323
365
|
function specKeyFor(spec) {
|
|
324
366
|
return stableStringify(spec) ?? crypto.randomUUID();
|
|
325
367
|
}
|
|
368
|
+
const COMPUTE_TIER_NAMES = {
|
|
369
|
+
small: "Lite",
|
|
370
|
+
large: "Standard",
|
|
371
|
+
xlarge: "Pro",
|
|
372
|
+
xxlarge: "Max",
|
|
373
|
+
xxxlarge: "Ultra"
|
|
374
|
+
};
|
|
375
|
+
function computeTierLabel(tier, memoryGb) {
|
|
376
|
+
const name = typeof tier === "string" ? COMPUTE_TIER_NAMES[tier] ?? null : null;
|
|
377
|
+
const memory = Number(memoryGb);
|
|
378
|
+
const memoryLabel = Number.isFinite(memory) && memory > 0 ? `${Math.round(memory)} GB` : null;
|
|
379
|
+
if (name && memoryLabel) return `${name} (${memoryLabel})`;
|
|
380
|
+
if (name) return name;
|
|
381
|
+
if (memoryLabel) return memoryLabel;
|
|
382
|
+
return typeof tier === "string" && tier ? tier : "unknown tier";
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The card line for a settled decision, shared by the spec parser (a settled
|
|
386
|
+
* re-emission) and the chat screen (the decision POST's response, which on
|
|
387
|
+
* `alreadyDecided` reports whatever decision actually stuck). Wording follows
|
|
388
|
+
* the web card's chips (Upgraded / Kept current / Withdrawn).
|
|
389
|
+
*/
|
|
390
|
+
/**
|
|
391
|
+
* The full status domain the api emits on a compute request. Anything else —
|
|
392
|
+
* missing, or a value this CLI predates — returns null so the caller can
|
|
393
|
+
* refuse it instead of guessing at unknown semantics.
|
|
394
|
+
*/
|
|
395
|
+
function parseComputeRequestStatus(value) {
|
|
396
|
+
switch (value) {
|
|
397
|
+
case "pending":
|
|
398
|
+
case "approved":
|
|
399
|
+
case "denied":
|
|
400
|
+
case "cancelled": return value;
|
|
401
|
+
default: return null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function computeSettledLabel(status) {
|
|
405
|
+
switch (status) {
|
|
406
|
+
case "approved": return "upgraded";
|
|
407
|
+
case "denied": return "kept the current tier";
|
|
408
|
+
case "cancelled": return "withdrawn";
|
|
409
|
+
default: return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The `platform portal request` consent card. The server emits one
|
|
414
|
+
* DesktopHandoffCard spec for every surface (api routes/portal.ts): the web
|
|
415
|
+
* renders it as the "continue in the Skydive desktop app" handoff, but this
|
|
416
|
+
* terminal's own portal daemon can provide the machine, so here it maps onto
|
|
417
|
+
* the existing grant_portal approval instead of a pointer to the app. Without
|
|
418
|
+
* this the spec is not a Card, parses to null, and the request is silently
|
|
419
|
+
* dropped — `platform portal request` looks desktop-only from the CLI
|
|
420
|
+
* (ANY-6521).
|
|
421
|
+
*/
|
|
422
|
+
function parseDesktopHandoffCard(rootEl) {
|
|
423
|
+
const props = isRecord(rootEl.props) ? rootEl.props : {};
|
|
424
|
+
const agentId = optionalString(props.agentId);
|
|
425
|
+
if (!agentId) return null;
|
|
426
|
+
const agentName = optionalString(props.agentName) ?? "This agent";
|
|
427
|
+
return {
|
|
428
|
+
title: `Let ${agentName} use your computer?`,
|
|
429
|
+
subtitle: null,
|
|
430
|
+
description: `Approving shares this machine with ${agentName} while you're signed in. Revoke anytime: skydive portal revoke --agent "${agentName}"`,
|
|
431
|
+
fields: [],
|
|
432
|
+
button: {
|
|
433
|
+
label: "Approve",
|
|
434
|
+
action: {
|
|
435
|
+
kind: "grant_portal",
|
|
436
|
+
agentId,
|
|
437
|
+
deviceId: optionalString(props.deviceId),
|
|
438
|
+
conversationId: optionalString(props.conversationId)
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
state: {},
|
|
442
|
+
computeRequestId: null,
|
|
443
|
+
settled: null
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The `platform compute request` approval card. The web renders it as the
|
|
448
|
+
* Approve/Deny "More compute requested" card; here it maps onto a
|
|
449
|
+
* decide_compute button (ctrl+r opens the y/n decision prompt). Without this
|
|
450
|
+
* the spec is not a Card, parses to null, and the request is silently
|
|
451
|
+
* dropped — the user never sees it and the agent waits on a decision the
|
|
452
|
+
* terminal can't give (ANY-6653). A settled spec (the decision route re-emits
|
|
453
|
+
* the card with its final status) parses to a button-less resolved card. A
|
|
454
|
+
* status this CLI doesn't know also parses to null — rendering it as pending
|
|
455
|
+
* would offer a decision on a request in a state we can't represent.
|
|
456
|
+
*/
|
|
457
|
+
function parseComputeRequestCard(rootEl) {
|
|
458
|
+
const props = isRecord(rootEl.props) ? rootEl.props : {};
|
|
459
|
+
const requestId = optionalString(props.requestId);
|
|
460
|
+
if (!requestId) return null;
|
|
461
|
+
const status = parseComputeRequestStatus(props.status);
|
|
462
|
+
if (status === null) return null;
|
|
463
|
+
const agentName = optionalString(props.agentName) ?? "This agent";
|
|
464
|
+
const from = computeTierLabel(props.fromTier, props.fromMemoryGb);
|
|
465
|
+
const to = computeTierLabel(props.requestedTier, props.requestedMemoryGb);
|
|
466
|
+
const settled = computeSettledLabel(status);
|
|
467
|
+
return {
|
|
468
|
+
title: "More compute requested",
|
|
469
|
+
subtitle: `${agentName}: ${from} → ${to}`,
|
|
470
|
+
description: optionalString(props.reason),
|
|
471
|
+
fields: [],
|
|
472
|
+
button: settled ? null : {
|
|
473
|
+
label: "Decide",
|
|
474
|
+
action: {
|
|
475
|
+
kind: "decide_compute",
|
|
476
|
+
requestId
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
state: {},
|
|
480
|
+
computeRequestId: requestId,
|
|
481
|
+
settled
|
|
482
|
+
};
|
|
483
|
+
}
|
|
326
484
|
function parseConnectCard(spec) {
|
|
327
485
|
if (!isRecord(spec)) return null;
|
|
328
486
|
const { root, elements } = spec;
|
|
329
487
|
if (typeof root !== "string" || !isRecord(elements)) return null;
|
|
330
488
|
const rootEl = elements[root];
|
|
331
|
-
if (!isRecord(rootEl)
|
|
489
|
+
if (!isRecord(rootEl)) return null;
|
|
490
|
+
if (rootEl.type === "DesktopHandoffCard") return parseDesktopHandoffCard(rootEl);
|
|
491
|
+
if (rootEl.type === "ComputeRequestCard") return parseComputeRequestCard(rootEl);
|
|
492
|
+
if (rootEl.type !== "Card") return null;
|
|
332
493
|
const rootProps = isRecord(rootEl.props) ? rootEl.props : {};
|
|
333
494
|
const title = optionalString(rootProps.title);
|
|
334
495
|
if (!title) return null;
|
|
@@ -366,7 +527,9 @@ function parseConnectCard(spec) {
|
|
|
366
527
|
label: preferred.label,
|
|
367
528
|
action: preferred.action
|
|
368
529
|
} : null,
|
|
369
|
-
state: isRecord(spec.state) ? spec.state : {}
|
|
530
|
+
state: isRecord(spec.state) ? spec.state : {},
|
|
531
|
+
computeRequestId: null,
|
|
532
|
+
settled: null
|
|
370
533
|
};
|
|
371
534
|
}
|
|
372
535
|
|
|
@@ -507,6 +670,13 @@ function summarizeConnectCard(card, appUrl) {
|
|
|
507
670
|
agentId: act.agentId
|
|
508
671
|
}
|
|
509
672
|
};
|
|
673
|
+
case "decide_compute": return {
|
|
674
|
+
...base,
|
|
675
|
+
action: {
|
|
676
|
+
kind: "decide_compute",
|
|
677
|
+
requestId: act.requestId
|
|
678
|
+
}
|
|
679
|
+
};
|
|
510
680
|
default: return {
|
|
511
681
|
...base,
|
|
512
682
|
action: { kind: "unsupported" }
|
|
@@ -516,14 +686,16 @@ function summarizeConnectCard(card, appUrl) {
|
|
|
516
686
|
/**
|
|
517
687
|
* Parse a `data-anyone-render-spec` stream chunk into a connect-card summary,
|
|
518
688
|
* or null if the chunk isn't a connect card (other render specs — training,
|
|
519
|
-
* deep-learn
|
|
689
|
+
* deep-learn — parse to null, same as the TUI). A card that arrives already
|
|
690
|
+
* settled (a compute request's decided re-emission) is an FYI, not an action,
|
|
691
|
+
* so it stays out of the "[action needed]" stream too.
|
|
520
692
|
*/
|
|
521
693
|
function connectCardFromChunk(chunk, appUrl) {
|
|
522
694
|
if (chunk["type"] !== "data-anyone-render-spec") return null;
|
|
523
695
|
const data = chunk["data"];
|
|
524
696
|
if (!isRecord(data)) return null;
|
|
525
697
|
const card = parseConnectCard(data["spec"]);
|
|
526
|
-
if (!card) return null;
|
|
698
|
+
if (!card || card.settled !== null) return null;
|
|
527
699
|
return summarizeConnectCard(card, appUrl);
|
|
528
700
|
}
|
|
529
701
|
/** Render a connect-card summary as a human-readable action block. */
|
|
@@ -542,6 +714,9 @@ function formatConnectCard(card) {
|
|
|
542
714
|
case "approve_portal":
|
|
543
715
|
lines.push(`Approve local-machine access for agent ${card.action.agentId} in the TUI or web app.`);
|
|
544
716
|
break;
|
|
717
|
+
case "decide_compute":
|
|
718
|
+
lines.push("Approve or deny this compute increase in the interactive TUI or web app.");
|
|
719
|
+
break;
|
|
545
720
|
case "unsupported":
|
|
546
721
|
lines.push("Open this conversation in the web app to continue.");
|
|
547
722
|
break;
|
|
@@ -562,17 +737,18 @@ function formatConnectCard(card) {
|
|
|
562
737
|
* disambiguate: an `--agent` selector must match exactly one agent, and
|
|
563
738
|
* when it's omitted we only auto-pick if the account has exactly one.
|
|
564
739
|
*/
|
|
565
|
-
async function runPrint({ appUrl, sessionToken, prompt, agentSelector, conversationId, json, machineShare, grantTargetAgent }) {
|
|
740
|
+
async function runPrint({ appUrl, sessionToken, workspaceId, prompt, agentSelector, conversationId, json, machineShare, grantTargetAgent }) {
|
|
566
741
|
const client = createRestClient({
|
|
567
742
|
appUrl,
|
|
568
|
-
sessionToken
|
|
743
|
+
sessionToken,
|
|
744
|
+
workspaceId
|
|
569
745
|
});
|
|
570
746
|
const agent = resolveAgent(await client.listAgents({
|
|
571
747
|
scope: "org",
|
|
572
748
|
onPage: null
|
|
573
749
|
}), agentSelector);
|
|
574
750
|
if (machineShare) {
|
|
575
|
-
if (!machineShare.isGranted(agent.id) && grantTargetAgent) await machineShare.grantAgent(agent.id);
|
|
751
|
+
if (!machineShare.isGranted(agent.id) && grantTargetAgent) await machineShare.grantAgent(agent.id, null);
|
|
576
752
|
if (machineShare.isGranted(agent.id)) console.error(`portal: shared this machine with ${agent.name} for this run (grant persists until revoked)`);
|
|
577
753
|
else console.error(`portal: this machine is shared (shareMachineDefault), but ${agent.name} has no grant. Approve its request, or run \`skydive portal grant --agent ${agent.name}\`.`);
|
|
578
754
|
}
|
|
@@ -657,7 +833,7 @@ async function collectRunText({ client, appUrl, target, onText, messageIdForHint
|
|
|
657
833
|
const onEvent = (event) => {
|
|
658
834
|
if (event.kind === "finished") {
|
|
659
835
|
if (event.outcome) billingBlocked = event.outcome;
|
|
660
|
-
if (event.error) streamError = event.error;
|
|
836
|
+
if (event.error && streamError === null) streamError = event.error;
|
|
661
837
|
return;
|
|
662
838
|
}
|
|
663
839
|
const chunk = event.chunk;
|
|
@@ -760,4 +936,4 @@ async function readStdin() {
|
|
|
760
936
|
}
|
|
761
937
|
|
|
762
938
|
//#endregion
|
|
763
|
-
export {
|
|
939
|
+
export { getShareMachineDefault as A, resolveWebUrl as B, getConfigPath as C, getPromptHistoryPath as D, getPreference as E, resolveAppUrl as F, saveSession as H, resolveChatAuth as I, resolveConfig as L, getStoredApiKeyWorkspaceName as M, getUpdateCheckDisabled as N, getReviewStateDir as O, recordDefaultAgent as P, resolveManagementAuth as R, deleteConfig as S, getLastSeenVersion as T, saveTheme as U, saveConfig as V, setLastSeenVersion as W, API_KEY_FAMILY_PREFIX as _, runPrint as a, DEFAULT_APP_URL as b, cardActionErrorMessage as c, reconcileMaskedInput as d, resolveConnectUrl as f, API_KEYS_URL as g, specKeyFor as h, resolveAgent as i, getStoredApiKeyId as j, getSavedTheme as k, parseExternalOauthConnectParams as l, parseConnectCard as m, messageGet as n, toPrintError as o, computeSettledLabel as p, readStdin as r, MASK_CHAR as s, collectRunText as t, parseOauthConnectParams as u, API_KEY_PREFIX as v, getDefaultAgent as w, PREFERENCES as x, DEFAULT_API_URL as y, resolveSession as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as printError } from "./output-
|
|
2
|
+
import { n as printError } from "./output-wY0VQDea.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/chat/print-share.ts
|
|
5
5
|
/**
|
|
@@ -14,7 +14,8 @@ import { n as printError } from "./output-DYzzdXYV.mjs";
|
|
|
14
14
|
* the reply (and to --json).
|
|
15
15
|
*/
|
|
16
16
|
async function connectMachineShare({ appUrl, sessionToken, timeoutHint }) {
|
|
17
|
-
const { PortalClient } = await import("./client-
|
|
17
|
+
const { PortalClient } = await import("./client-DCwVlAal.mjs");
|
|
18
|
+
const { defaultTlsCertSource } = await import("./tls-cert-CLgSQALB.mjs");
|
|
18
19
|
let signalConnected;
|
|
19
20
|
const connected = new Promise((resolve) => {
|
|
20
21
|
signalConnected = resolve;
|
|
@@ -26,6 +27,11 @@ async function connectMachineShare({ appUrl, sessionToken, timeoutHint }) {
|
|
|
26
27
|
deviceToken: null
|
|
27
28
|
}),
|
|
28
29
|
resolveCwd: () => process.cwd(),
|
|
30
|
+
tlsCertSource: defaultTlsCertSource(process.env, (msg) => {
|
|
31
|
+
console.error(msg);
|
|
32
|
+
}),
|
|
33
|
+
persistedMachineName: null,
|
|
34
|
+
onMachineName: () => {},
|
|
29
35
|
onState: (state) => {
|
|
30
36
|
if (state.status === "connected") signalConnected();
|
|
31
37
|
if (state.status === "error") console.error(`portal: connection error: ${state.error ?? "unknown"}; retrying`);
|