skydive-cli 0.4.0-beta.1332 → 0.4.0-beta.1352
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 +4 -0
- package/dist/js/bin.mjs +292 -21
- package/dist/js/{boot-Cw_SOMZH.mjs → boot-D4tjj6LN.mjs} +5 -149
- package/dist/js/{daemon-DOWC0OOB.mjs → daemon-DaUaCMwC.mjs} +19 -1
- package/dist/js/daemon-client-CJxbCLOb.mjs +168 -0
- package/dist/js/daemon-client-DlblQIR9.mjs +6 -0
- package/dist/js/{daemon-wUaIOwEj.mjs → daemon-imLBqTGg.mjs} +1 -1
- package/dist/js/{profiler-Dh7VeDnQ.mjs → profiler-CZtc7-p8.mjs} +1 -1
- package/dist/js/raw-pty-3EkG-jjH.mjs +5 -0
- package/package.json +2 -1
- package/dist/js/raw-pty-skuWh-QO.mjs +0 -5
- /package/dist/js/{print-share-BBz_FpXL.mjs → print-share-CT4ltX7u.mjs} +0 -0
- /package/dist/js/{raw-pty-C7PxMDc1.mjs → raw-pty-B6mAroiI.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `skydive fs` — a namespace for working with the files on an agent's computer (its sandbox) from your own machine. Its first subcommand, `skydive fs edit <path>`, reads a remote file down over the same relay `skydive sandbox` uses, opens it in your local editor (`$VISUAL`/`$EDITOR`, override with `--editor`, defaults to `vi`), and writes your changes back atomically when you save and close — so you can edit a remote file as if it were local without opening the chat TUI. A path that doesn't exist yet is created on save; no changes means nothing is written. Access is gated on EDIT permission for the agent, exactly like `skydive sandbox`. (A first-class `fs` relay channel and `skydive fs mount` land in follow-ups.)
|
|
13
|
+
|
|
10
14
|
## [0.4.0] - 2026-08-07
|
|
11
15
|
|
|
12
16
|
### Added
|
package/dist/js/bin.mjs
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as ensureActiveOrganization, D as setActiveWorkspace, E as listWorkspaces, O as name, T as getSessionIdentity, a as installCrashHandler, k as version, t as maybeStartProfiling, u as brandHelpArt, w as getActiveWorkspaceId, x as themes } from "./profiler-
|
|
2
|
+
import { C as ensureActiveOrganization, D as setActiveWorkspace, E as listWorkspaces, O as name, T as getSessionIdentity, a as installCrashHandler, k as version, t as maybeStartProfiling, u as brandHelpArt, w as getActiveWorkspaceId, x as themes } from "./profiler-CZtc7-p8.mjs";
|
|
3
3
|
import { A as getStoredApiKeyWorkspaceName, C as getLastSeenVersion, F as resolveManagementAuth, I as resolveSession, M as resolveAppUrl, N as resolveChatAuth, O as getShareMachineDefault, P as resolveConfig, R as saveConfig, S as getConfigPath, T as getPromptHistoryPath, V as setLastSeenVersion, _ as API_KEY_PREFIX, b as PREFERENCES, g as API_KEY_FAMILY_PREFIX, h as API_KEYS_URL, i as resolveAgent, j as getUpdateCheckDisabled, k as getStoredApiKeyId, v as DEFAULT_API_URL, w as getPreference, x as deleteConfig, z as saveSession } from "./print-CbayCa87.mjs";
|
|
4
4
|
import { n as printError, r as printTable, t as output } from "./output-DYzzdXYV.mjs";
|
|
5
5
|
import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
|
|
6
6
|
import { t as createRestClient } from "./rest-BY2nADw5.mjs";
|
|
7
7
|
import "./billing-blocked-2wju4gC_.mjs";
|
|
8
8
|
import { a as registerPortalDevice, c as machineIdentity, i as grantPortalAccess, n as fetchPortalDevices, o as revokePortalAccess, r as findThisDevice } from "./client-Cf7cvftg.mjs";
|
|
9
|
-
import { c as PORTAL_DAEMON_FLAG, i as queryDaemonStatus, l as daemonPaths, n as ensureDaemonRunning, o as stopDaemon } from "./daemon-
|
|
9
|
+
import { c as PORTAL_DAEMON_FLAG, i as queryDaemonStatus, l as daemonPaths, n as ensureDaemonRunning, o as stopDaemon } from "./daemon-DaUaCMwC.mjs";
|
|
10
10
|
import { t as SandboxStream } from "./client-Cn2af31H.mjs";
|
|
11
11
|
import { hideBin } from "yargs/helpers";
|
|
12
12
|
import yargs from "yargs";
|
|
13
|
-
import os, { hostname } from "node:os";
|
|
14
|
-
import path from "node:path";
|
|
13
|
+
import os, { hostname, tmpdir } from "node:os";
|
|
14
|
+
import path, { join } from "node:path";
|
|
15
15
|
import { err, ok } from "neverthrow";
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import open from "open";
|
|
18
18
|
import fs from "node:fs";
|
|
19
19
|
import { spawn, spawnSync } from "node:child_process";
|
|
20
|
-
import { createHash } from "node:crypto";
|
|
20
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
21
21
|
import zlib from "node:zlib";
|
|
22
|
-
import fsp from "node:fs/promises";
|
|
22
|
+
import fsp, { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
23
|
+
import { quote } from "shell-quote";
|
|
23
24
|
import semver from "semver";
|
|
24
25
|
import { createInterface } from "node:readline";
|
|
25
26
|
|
|
@@ -1515,7 +1516,7 @@ const importCommand = {
|
|
|
1515
1516
|
process.exit(1);
|
|
1516
1517
|
}
|
|
1517
1518
|
}
|
|
1518
|
-
const { runChat } = await import("./boot-
|
|
1519
|
+
const { runChat } = await import("./boot-D4tjj6LN.mjs");
|
|
1519
1520
|
await runChat({
|
|
1520
1521
|
appUrl,
|
|
1521
1522
|
sessionToken: session.value.sessionToken,
|
|
@@ -1542,7 +1543,7 @@ async function runImportPrintMode({ argv, appUrl }) {
|
|
|
1542
1543
|
printError(`${session.error.message} For non-interactive use, run \`skydive auth login --web\` first, or set SKYDIVE_SESSION_TOKEN.`);
|
|
1543
1544
|
process.exit(1);
|
|
1544
1545
|
}
|
|
1545
|
-
const { connectMachineShare } = await import("./print-share-
|
|
1546
|
+
const { connectMachineShare } = await import("./print-share-CT4ltX7u.mjs");
|
|
1546
1547
|
const machineShare = await connectMachineShare({
|
|
1547
1548
|
appUrl,
|
|
1548
1549
|
sessionToken: session.value.sessionToken,
|
|
@@ -1927,7 +1928,7 @@ const chatCommand = {
|
|
|
1927
1928
|
sessionToken: auth.value.token,
|
|
1928
1929
|
agentSelector: argv.agent ?? null
|
|
1929
1930
|
});
|
|
1930
|
-
const { runChat } = await import("./boot-
|
|
1931
|
+
const { runChat } = await import("./boot-D4tjj6LN.mjs");
|
|
1931
1932
|
await runChat({
|
|
1932
1933
|
appUrl: auth.value.appUrl,
|
|
1933
1934
|
sessionToken: auth.value.token,
|
|
@@ -2019,7 +2020,7 @@ async function runPrintMode({ argv, appUrl }) {
|
|
|
2019
2020
|
process.exit(1);
|
|
2020
2021
|
}
|
|
2021
2022
|
} else {
|
|
2022
|
-
const { connectMachineShare } = await import("./print-share-
|
|
2023
|
+
const { connectMachineShare } = await import("./print-share-CT4ltX7u.mjs");
|
|
2023
2024
|
machineShare = await connectMachineShare({
|
|
2024
2025
|
appUrl: auth.value.appUrl,
|
|
2025
2026
|
sessionToken: auth.value.token,
|
|
@@ -2286,7 +2287,7 @@ const switchCommand = {
|
|
|
2286
2287
|
printError("The workspace picker needs the Bun runtime and it could not be set up automatically. Pass a workspace slug instead, or install Bun and retry.");
|
|
2287
2288
|
process.exit(1);
|
|
2288
2289
|
}
|
|
2289
|
-
const { runWorkspacePicker } = await import("./boot-
|
|
2290
|
+
const { runWorkspacePicker } = await import("./boot-D4tjj6LN.mjs");
|
|
2290
2291
|
await runWorkspacePicker(session);
|
|
2291
2292
|
return;
|
|
2292
2293
|
}
|
|
@@ -2364,16 +2365,15 @@ const openCommand = {
|
|
|
2364
2365
|
const agent = argv.agent ? resolveAgent((await fetchPortalDevices(session)).agents, argv.agent) : null;
|
|
2365
2366
|
const cwd = argv.cwd ? path.resolve(argv.cwd) : process.cwd();
|
|
2366
2367
|
const { machineName } = machineIdentity();
|
|
2367
|
-
const {
|
|
2368
|
+
const { PortalDaemonClient } = await import("./daemon-client-DlblQIR9.mjs");
|
|
2368
2369
|
let lastLine = "";
|
|
2369
2370
|
let signalConnected;
|
|
2370
2371
|
const connected = new Promise((resolve) => {
|
|
2371
2372
|
signalConnected = resolve;
|
|
2372
2373
|
});
|
|
2373
|
-
const client = new
|
|
2374
|
+
const client = new PortalDaemonClient({
|
|
2374
2375
|
appUrl: session.appUrl,
|
|
2375
2376
|
sessionToken: session.sessionToken,
|
|
2376
|
-
resolveCwd: () => cwd,
|
|
2377
2377
|
onState: (state) => {
|
|
2378
2378
|
if (state.status === "connected") signalConnected();
|
|
2379
2379
|
const line = state.status === "error" ? `portal: connection error: ${state.error ?? "unknown"}; retrying` : `portal: ${state.status}`;
|
|
@@ -2389,6 +2389,8 @@ const openCommand = {
|
|
|
2389
2389
|
};
|
|
2390
2390
|
process.on("SIGINT", stop);
|
|
2391
2391
|
process.on("SIGTERM", stop);
|
|
2392
|
+
await client.start();
|
|
2393
|
+
client.setFallbackCwd(cwd);
|
|
2392
2394
|
client.enable();
|
|
2393
2395
|
await connected;
|
|
2394
2396
|
if (agent) {
|
|
@@ -2599,7 +2601,7 @@ const portalCommand = {
|
|
|
2599
2601
|
//#endregion
|
|
2600
2602
|
//#region src/commands/sandbox.ts
|
|
2601
2603
|
/** POSIX single-quote one word so the remote shell treats it as one token. */
|
|
2602
|
-
function shellQuote(word) {
|
|
2604
|
+
function shellQuote$1(word) {
|
|
2603
2605
|
if (/^[A-Za-z0-9_@%+=:,./-]+$/.test(word)) return word;
|
|
2604
2606
|
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
2605
2607
|
}
|
|
@@ -2614,7 +2616,7 @@ function shellQuote(word) {
|
|
|
2614
2616
|
* for too. yargs number-coerces bare numerals, so words are stringified.
|
|
2615
2617
|
*/
|
|
2616
2618
|
function joinCommandWords(words) {
|
|
2617
|
-
return words.map(String).map(shellQuote).join(" ").trim();
|
|
2619
|
+
return words.map(String).map(shellQuote$1).join(" ").trim();
|
|
2618
2620
|
}
|
|
2619
2621
|
/**
|
|
2620
2622
|
* `skydive sandbox` — the standalone counterpart to the chat TUI's `/sandbox`
|
|
@@ -2707,7 +2709,7 @@ async function runPty({ session, agentId, agentName }) {
|
|
|
2707
2709
|
return 1;
|
|
2708
2710
|
}
|
|
2709
2711
|
console.error(`Connecting to ${agentName}'s sandbox… (Ctrl-] detaches)`);
|
|
2710
|
-
const { runRawPtyPassthrough } = await import("./raw-pty-
|
|
2712
|
+
const { runRawPtyPassthrough } = await import("./raw-pty-3EkG-jjH.mjs");
|
|
2711
2713
|
const result = await runRawPtyPassthrough({
|
|
2712
2714
|
stdin: process.stdin,
|
|
2713
2715
|
stdout: process.stdout,
|
|
@@ -2719,6 +2721,275 @@ async function runPty({ session, agentId, agentName }) {
|
|
|
2719
2721
|
return result.code;
|
|
2720
2722
|
}
|
|
2721
2723
|
|
|
2724
|
+
//#endregion
|
|
2725
|
+
//#region src/commands/fs.ts
|
|
2726
|
+
/**
|
|
2727
|
+
* POSIX-quote one word so the remote shell treats it as a single token. Wraps
|
|
2728
|
+
* `shell-quote`'s `quote` (already a repo dependency, used elsewhere in the
|
|
2729
|
+
* CLI) rather than hand-rolling the escaping — it is the well-tested source of
|
|
2730
|
+
* truth for making a path/arg with spaces, quotes, `$`, `;`, globs, etc. inert
|
|
2731
|
+
* when interpolated into an `sh -c` line.
|
|
2732
|
+
*/
|
|
2733
|
+
function shellQuote(word) {
|
|
2734
|
+
return quote([word]);
|
|
2735
|
+
}
|
|
2736
|
+
const MISSING_FILE_EXIT = 44;
|
|
2737
|
+
/**
|
|
2738
|
+
* Build the remote shell command that base64-encodes a file to stdout. Exits
|
|
2739
|
+
* {@link MISSING_FILE_EXIT} when the path doesn't exist, 1 when it's a
|
|
2740
|
+
* directory, so the caller can tell "create new" from a genuine error.
|
|
2741
|
+
*/
|
|
2742
|
+
function buildReadCommand(path) {
|
|
2743
|
+
const q = shellQuote(path);
|
|
2744
|
+
return `sh -c ${shellQuote(`if [ ! -e ${q} ]; then exit ${MISSING_FILE_EXIT}; fi; if [ -d ${q} ]; then echo 'path is a directory' >&2; exit 1; fi; base64 < ${q}`)}`;
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Build the remote shell command that decodes `b64` and writes it to `path`
|
|
2748
|
+
* atomically (temp file + `mv`) so a dropped connection can't truncate the
|
|
2749
|
+
* original in place. `token` is a caller-supplied unique suffix for the temp
|
|
2750
|
+
* file — generated in JS (not the shell's `$$`, which shell-quote would escape
|
|
2751
|
+
* to a literal, so every write would collide on the same temp name).
|
|
2752
|
+
*/
|
|
2753
|
+
function buildWriteCommand(path, b64, token) {
|
|
2754
|
+
const tmp = `${path}.skydive-edit.${token}`;
|
|
2755
|
+
return `sh -c ${shellQuote(`printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(tmp)} && mv -f ${shellQuote(tmp)} ${shellQuote(path)}`)}`;
|
|
2756
|
+
}
|
|
2757
|
+
/**
|
|
2758
|
+
* Resolve the editor command from an explicit override, then $VISUAL, $EDITOR,
|
|
2759
|
+
* then `vi`. Split so `EDITOR="code --wait"` (command + flags) is honored.
|
|
2760
|
+
*/
|
|
2761
|
+
function resolveEditor(override, env) {
|
|
2762
|
+
const parts = (override || env.VISUAL || env.EDITOR || "vi").split(/\s+/).filter(Boolean);
|
|
2763
|
+
return {
|
|
2764
|
+
bin: parts[0] ?? "vi",
|
|
2765
|
+
args: parts.slice(1)
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* `skydive fs edit <path>` — edit a file that lives on the agent's computer
|
|
2770
|
+
* (its sandbox) with your LOCAL editor. It reads the remote file down over the
|
|
2771
|
+
* same relay `skydive sandbox` uses, opens it in `$EDITOR`, and writes your
|
|
2772
|
+
* changes back when you save and close — so you edit a remote file as if it
|
|
2773
|
+
* were local, without opening the chat TUI.
|
|
2774
|
+
*
|
|
2775
|
+
* There is no server-side "file" endpoint yet: this rides entirely on the
|
|
2776
|
+
* existing one-shot `exec` mode of the sandbox stream. Contents move
|
|
2777
|
+
* base64-encoded in BOTH directions (exec has no stdin, so the write payload is
|
|
2778
|
+
* embedded in the command string) which keeps binary bytes, trailing newlines,
|
|
2779
|
+
* and CRLF intact. Access gating (EDIT on the agent + the sandbox kill switch)
|
|
2780
|
+
* is enforced by the relay, exactly as for `skydive sandbox`. A future PR adds
|
|
2781
|
+
* a first-class `fs` channel that `edit` (and `fs mount`) will ride instead.
|
|
2782
|
+
*/
|
|
2783
|
+
const fsEditCommand = {
|
|
2784
|
+
command: "edit <path>",
|
|
2785
|
+
describe: "Edit a file on the agent's computer (its sandbox) with your local $EDITOR",
|
|
2786
|
+
builder: (y) => y.positional("path", {
|
|
2787
|
+
type: "string",
|
|
2788
|
+
demandOption: true,
|
|
2789
|
+
describe: "Absolute or sandbox-relative path of the file to edit"
|
|
2790
|
+
}).option("agent", {
|
|
2791
|
+
type: "string",
|
|
2792
|
+
describe: "Target agent, by id, slug, or name. Optional when the account has exactly one agent."
|
|
2793
|
+
}).option("editor", {
|
|
2794
|
+
type: "string",
|
|
2795
|
+
describe: "Editor command to open (defaults to $VISUAL, then $EDITOR, then vi)"
|
|
2796
|
+
}).example("skydive fs edit --agent grace /tmp/notes.md", "Edit a remote file").example("EDITOR=nano skydive fs edit ~/.self/soul.md", "Pick the editor via $EDITOR"),
|
|
2797
|
+
handler: async (argv) => {
|
|
2798
|
+
const session = requireSession(argv);
|
|
2799
|
+
const remotePath = argv.path;
|
|
2800
|
+
const { createRestClient } = await import("./rest-DADJh0bi.mjs");
|
|
2801
|
+
const { resolveAgent } = await import("./print-ba_0hiV9.mjs");
|
|
2802
|
+
const client = createRestClient({
|
|
2803
|
+
appUrl: session.appUrl,
|
|
2804
|
+
sessionToken: session.sessionToken
|
|
2805
|
+
});
|
|
2806
|
+
let agent;
|
|
2807
|
+
try {
|
|
2808
|
+
agent = resolveAgent(await client.listAgents({
|
|
2809
|
+
scope: "org",
|
|
2810
|
+
onPage: null
|
|
2811
|
+
}), argv.agent ?? null);
|
|
2812
|
+
} catch (error) {
|
|
2813
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
2814
|
+
process.exit(1);
|
|
2815
|
+
}
|
|
2816
|
+
const opts = {
|
|
2817
|
+
session,
|
|
2818
|
+
agentId: agent.id
|
|
2819
|
+
};
|
|
2820
|
+
console.error(`Reading ${remotePath} from ${agent.name}'s sandbox…`);
|
|
2821
|
+
const read = await readRemote({
|
|
2822
|
+
...opts,
|
|
2823
|
+
path: remotePath
|
|
2824
|
+
});
|
|
2825
|
+
if (read.kind === "error") {
|
|
2826
|
+
printError(read.message);
|
|
2827
|
+
process.exit(1);
|
|
2828
|
+
}
|
|
2829
|
+
const original = read.content;
|
|
2830
|
+
if (read.kind === "missing") console.error(`${remotePath} does not exist yet — it will be created when you save.`);
|
|
2831
|
+
const dir = await mkdtemp(join(tmpdir(), "skydive-edit-"));
|
|
2832
|
+
const local = join(dir, remotePath.split("/").pop() || "file");
|
|
2833
|
+
try {
|
|
2834
|
+
await writeFile(local, original);
|
|
2835
|
+
if (!await openEditor(argv.editor, local)) {
|
|
2836
|
+
printError("Editor exited non-zero; not saving any changes.");
|
|
2837
|
+
process.exit(1);
|
|
2838
|
+
}
|
|
2839
|
+
const edited = await readFile(local);
|
|
2840
|
+
if (edited.equals(original)) {
|
|
2841
|
+
console.error("No changes — nothing written.");
|
|
2842
|
+
process.exit(0);
|
|
2843
|
+
}
|
|
2844
|
+
console.error(`Writing changes back to ${remotePath}…`);
|
|
2845
|
+
const wrote = await writeRemote({
|
|
2846
|
+
...opts,
|
|
2847
|
+
path: remotePath,
|
|
2848
|
+
content: edited
|
|
2849
|
+
});
|
|
2850
|
+
if (wrote.kind === "error") {
|
|
2851
|
+
printError(`${wrote.message}\nYour edited copy is kept at ${local} so you don't lose it.`);
|
|
2852
|
+
process.exit(1);
|
|
2853
|
+
}
|
|
2854
|
+
console.error("Saved.");
|
|
2855
|
+
process.exit(0);
|
|
2856
|
+
} finally {
|
|
2857
|
+
await rm(dir, {
|
|
2858
|
+
recursive: true,
|
|
2859
|
+
force: true
|
|
2860
|
+
}).catch((error) => {
|
|
2861
|
+
console.error(`Note: could not remove temp dir ${dir}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
/**
|
|
2867
|
+
* Read a remote file as bytes. Runs `base64` on the file in the sandbox and
|
|
2868
|
+
* decodes the streamed stdout locally. Distinguishes "file is missing" (exit
|
|
2869
|
+
* code 44, so `edit` can create it) from a real read failure.
|
|
2870
|
+
*/
|
|
2871
|
+
function readRemote({ session, agentId, path }) {
|
|
2872
|
+
const command = buildReadCommand(path);
|
|
2873
|
+
const chunks = [];
|
|
2874
|
+
const stderr = [];
|
|
2875
|
+
return new Promise((resolve) => {
|
|
2876
|
+
SandboxStream.open({
|
|
2877
|
+
mode: "exec",
|
|
2878
|
+
appUrl: session.appUrl,
|
|
2879
|
+
sessionToken: session.sessionToken,
|
|
2880
|
+
agentId,
|
|
2881
|
+
command,
|
|
2882
|
+
onEvent: (e) => {
|
|
2883
|
+
switch (e.type) {
|
|
2884
|
+
case "data":
|
|
2885
|
+
chunks.push(Buffer.from(e.bytes));
|
|
2886
|
+
break;
|
|
2887
|
+
case "exit":
|
|
2888
|
+
if (e.code === MISSING_FILE_EXIT) resolve({
|
|
2889
|
+
kind: "missing",
|
|
2890
|
+
content: Buffer.alloc(0)
|
|
2891
|
+
});
|
|
2892
|
+
else if (e.code === 0) resolve({
|
|
2893
|
+
kind: "ok",
|
|
2894
|
+
content: Buffer.from(Buffer.concat(chunks).toString("utf8").replace(/\s+/g, ""), "base64")
|
|
2895
|
+
});
|
|
2896
|
+
else resolve({
|
|
2897
|
+
kind: "error",
|
|
2898
|
+
message: stderr.join("").trim() || `Could not read the file (exit ${e.code}).`
|
|
2899
|
+
});
|
|
2900
|
+
break;
|
|
2901
|
+
case "error":
|
|
2902
|
+
stderr.push(e.message);
|
|
2903
|
+
break;
|
|
2904
|
+
case "close":
|
|
2905
|
+
resolve({
|
|
2906
|
+
kind: "error",
|
|
2907
|
+
message: e.failure || "The connection to the sandbox closed before the file could be read."
|
|
2908
|
+
});
|
|
2909
|
+
break;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
});
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
/**
|
|
2916
|
+
* Write bytes to a remote file. Exec has no stdin, so the base64 payload is
|
|
2917
|
+
* embedded in the command and decoded on the far side. Writes atomically via a
|
|
2918
|
+
* temp file + `mv` so a dropped connection mid-write can't leave a truncated
|
|
2919
|
+
* file in place of the original.
|
|
2920
|
+
*/
|
|
2921
|
+
function writeRemote({ session, agentId, path, content }) {
|
|
2922
|
+
const token = randomBytes(6).toString("hex");
|
|
2923
|
+
const command = buildWriteCommand(path, content.toString("base64"), token);
|
|
2924
|
+
const stderr = [];
|
|
2925
|
+
return new Promise((resolve) => {
|
|
2926
|
+
SandboxStream.open({
|
|
2927
|
+
mode: "exec",
|
|
2928
|
+
appUrl: session.appUrl,
|
|
2929
|
+
sessionToken: session.sessionToken,
|
|
2930
|
+
agentId,
|
|
2931
|
+
command,
|
|
2932
|
+
onEvent: (e) => {
|
|
2933
|
+
switch (e.type) {
|
|
2934
|
+
case "data":
|
|
2935
|
+
stderr.push(Buffer.from(e.bytes).toString("utf8"));
|
|
2936
|
+
break;
|
|
2937
|
+
case "exit":
|
|
2938
|
+
resolve(e.code === 0 ? { kind: "ok" } : {
|
|
2939
|
+
kind: "error",
|
|
2940
|
+
message: stderr.join("").trim() || `Could not write the file (exit ${e.code}).`
|
|
2941
|
+
});
|
|
2942
|
+
break;
|
|
2943
|
+
case "error":
|
|
2944
|
+
stderr.push(e.message);
|
|
2945
|
+
break;
|
|
2946
|
+
case "close":
|
|
2947
|
+
resolve({
|
|
2948
|
+
kind: "error",
|
|
2949
|
+
message: e.failure || "The connection to the sandbox closed before the file was written."
|
|
2950
|
+
});
|
|
2951
|
+
break;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
});
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* Open `file` in the caller's editor and resolve to whether it exited cleanly.
|
|
2959
|
+
* Precedence: explicit `--editor`, then $VISUAL, $EDITOR, then `vi`. The editor
|
|
2960
|
+
* inherits the real TTY so full-screen editors (vim/nano) work.
|
|
2961
|
+
*/
|
|
2962
|
+
function openEditor(override, file) {
|
|
2963
|
+
const { bin, args: editorArgs } = resolveEditor(override, process.env);
|
|
2964
|
+
const args = [...editorArgs, file];
|
|
2965
|
+
return new Promise((resolve) => {
|
|
2966
|
+
const child = spawn(bin, args, { stdio: "inherit" });
|
|
2967
|
+
child.on("error", (err) => {
|
|
2968
|
+
printError(`Could not launch editor "${bin}": ${err.message}`);
|
|
2969
|
+
resolve(false);
|
|
2970
|
+
});
|
|
2971
|
+
child.on("exit", (code) => resolve(code === 0));
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* `skydive fs` — work with the files on an agent's computer (its sandbox) from
|
|
2976
|
+
* your own machine. The namespace for filesystem access:
|
|
2977
|
+
*
|
|
2978
|
+
* - `fs edit <path>` edit one remote file with your local editor (shipped).
|
|
2979
|
+
* - `fs mount <dir>` mount the whole sandbox filesystem locally (coming in a
|
|
2980
|
+
* later PR, on a first-class `fs` relay channel).
|
|
2981
|
+
*
|
|
2982
|
+
* Grouping these under one command keeps the file surface discoverable and
|
|
2983
|
+
* leaves room to grow (`fs ls`, `fs cat`, `fs pull`) without adding more
|
|
2984
|
+
* top-level commands.
|
|
2985
|
+
*/
|
|
2986
|
+
const fsCommand = {
|
|
2987
|
+
command: "fs <command>",
|
|
2988
|
+
describe: "Work with the files on an agent's computer (its sandbox)",
|
|
2989
|
+
builder: (y) => y.command(fsEditCommand).demandCommand(1, "Specify a subcommand: edit"),
|
|
2990
|
+
handler: () => {}
|
|
2991
|
+
};
|
|
2992
|
+
|
|
2722
2993
|
//#endregion
|
|
2723
2994
|
//#region src/update-check/manifest.ts
|
|
2724
2995
|
/**
|
|
@@ -3527,7 +3798,7 @@ const configCommand = {
|
|
|
3527
3798
|
//#endregion
|
|
3528
3799
|
//#region src/cli.ts
|
|
3529
3800
|
function createCli(argv) {
|
|
3530
|
-
return yargs(argv).scriptName("skydive").usage("$0 <command> [options]").parserConfiguration({ "populate--": true }).example("skydive auth login", "Store your API key").example("skydive chat", "Open the interactive chat TUI (prod)").example("skydive chat --api-url http://localhost:4500", "Chat against a local dev API").example("skydive agents list", "List your agents").example("skydive completion install", "Set up TAB completion for your shell").example("skydive keys create \"my-key\"", "Create an API key").example("skydive secrets set OPENAI_API_KEY --agent-id <id>", "Set a secret (value from stdin)").example("skydive workspace list", "List workspaces on your account").example("skydive config set updateCheck false", "Disable the daily update check").example("skydive workspace switch acme-team", "Switch the workspace all `skydive` commands act on").example("skydive portal open --agent grace", "Open the portal to this machine for an agent, headless (no TUI)").option("json", {
|
|
3801
|
+
return yargs(argv).scriptName("skydive").usage("$0 <command> [options]").parserConfiguration({ "populate--": true }).example("skydive auth login", "Store your API key").example("skydive chat", "Open the interactive chat TUI (prod)").example("skydive chat --api-url http://localhost:4500", "Chat against a local dev API").example("skydive agents list", "List your agents").example("skydive completion install", "Set up TAB completion for your shell").example("skydive keys create \"my-key\"", "Create an API key").example("skydive secrets set OPENAI_API_KEY --agent-id <id>", "Set a secret (value from stdin)").example("skydive workspace list", "List workspaces on your account").example("skydive config set updateCheck false", "Disable the daily update check").example("skydive workspace switch acme-team", "Switch the workspace all `skydive` commands act on").example("skydive portal open --agent grace", "Open the portal to this machine for an agent, headless (no TUI)").example("skydive fs edit --agent grace /tmp/notes.md", "Edit a file on the agent's computer with your local editor").option("json", {
|
|
3531
3802
|
type: "boolean",
|
|
3532
3803
|
default: false,
|
|
3533
3804
|
global: true,
|
|
@@ -3541,7 +3812,7 @@ function createCli(argv) {
|
|
|
3541
3812
|
type: "string",
|
|
3542
3813
|
global: true,
|
|
3543
3814
|
describe: "Override API base URL"
|
|
3544
|
-
}).command(authCommand).command(chatCommand).command(messagesCommand).command(conversationsCommand).command(agentsCommand).command(importCommand).command(keysCommand).command(secretsCommand).command(workspaceCommand).command(portalCommand).command(sandboxCommand).command(updateCommand).command(configCommand).command(completionCommand).demandCommand(1, "Specify a command. Run --help for usage.").strict().wrap(null).version(version).alias("v", "version").alias("h", "help").help().fail((msg, err) => {
|
|
3815
|
+
}).command(authCommand).command(chatCommand).command(messagesCommand).command(conversationsCommand).command(agentsCommand).command(importCommand).command(keysCommand).command(secretsCommand).command(workspaceCommand).command(portalCommand).command(sandboxCommand).command(fsCommand).command(updateCommand).command(configCommand).command(completionCommand).demandCommand(1, "Specify a command. Run --help for usage.").strict().wrap(null).version(version).alias("v", "version").alias("h", "help").help().fail((msg, err) => {
|
|
3545
3816
|
printError(err ? err instanceof Error ? err.message : String(err) : msg ?? "Unknown error");
|
|
3546
3817
|
process.exit(1);
|
|
3547
3818
|
});
|
|
@@ -3754,7 +4025,7 @@ function setupUpdateCheck(argv) {
|
|
|
3754
4025
|
|
|
3755
4026
|
//#endregion
|
|
3756
4027
|
//#region src/changelog.generated.ts
|
|
3757
|
-
const CHANGELOG_MD = "# Changelog\n\nAll notable changes to the Skydive CLI are documented here.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n\n## [0.4.0] - 2026-08-07\n\n### Added\n\n- `skydive chat` works with API key auth: an API key alone now opens the chat TUI (and headless `chat -p`) without a browser login, using the key's pinned workspace.\n- `skydive config` command to view and set the safe, hand-editable CLI preferences (`shareMachineDefault`, `updateCheck`) without opening `config.json`. `config`/`config list` shows each key, its effective value, and whether it comes from the file or the built-in default; `config get`/`set`/`unset` read and change one key; `config path` prints the config file location. It only ever touches those preference keys, never credentials or flow-managed state.\n- Billing-blocked sends and runs now surface the server-authored recovery\n guidance from the typed billing outcome. The chat TUI renders it as a\n warning-toned system-notice row — live when a send is refused or a run is\n stopped at the billing boundary, and again when reopening a conversation\n that holds a persisted billing notice — instead of a generic error.\n Headless `chat -p` and `messages get` print the guidance (state, recovery\n step, and manage-billing URL) on stderr, keep any partial output already\n streamed on stdout, and exit with code `5` (distinct from the generic `1`)\n so scripted callers can tell a billing pause from a failure.\n- Syntax highlighting for 14 more languages in the chat transcript and file/review panes (python, bash, go, rust, c, cpp, java, ruby, css, html, json, yaml, and more) — previously only JavaScript/TypeScript rendered colored.\n\n### Changed\n\n- `skydive agent list` lists the full agent roster by default instead of a truncated page.\n\n### Fixed\n\n- Long multi-line bash tool-call commands (e.g. heredocs) are clamped with a `+N more · click to expand` tail instead of dumping their whole body into the scrollback.\n- Tool error output is clipped the same way as ok output, so a failing command no longer floods the transcript.\n- The TUI toast overlay has an opaque background instead of letting the transcript bleed through.\n\n## [0.3.0] - 2026-08-04\n\n### Added\n\n**Chat TUI**\n\n- `/fork` slash command to fork a conversation at any point and continue in a new thread.\n- `/conversation` switches threads from inside a live session.\n- `/compact` triggers manual conversation compaction.\n- `/portal` and `/copy` slash commands.\n- Archive the current conversation from the chat TUI.\n- `--new` flag on `skydive chat` to start a fresh conversation.\n- Debounced server-side conversation search in the picker, with title matches ranked first.\n- File review pane orientation toggle, and review comments in the file pane.\n- Pinned plan card controls and a jump-to-latest hint.\n- Terminal title (OSC) follows the live conversation title on every screen; inside cmux the workspace is renamed too, and linked PRs are pushed to the cmux sidebar.\n- Every participating agent shows in the conversation list; connect cards each have their own identity, and ctrl+r asks which connect card to act on.\n- Colored Skydive splash art in `skydive --help` and the TUI pickers.\n- New-agent name prefilled from the server's suggestion.\n\n**CLI & platform**\n\n- `skydive update` self-updater, with an update notice when a new version is available.\n- Shell completions for bash, zsh, and fish via `completion install`.\n- Portal daemon: one connection per host with per-conversation working directories.\n- Agent-led coding-agent import (`skydive import`).\n- Per-workspace scoping on the REST client, and cross-org `--agent <uuid>` auto-switches workspace.\n- `skydive-beta` wrapper for the canary channel.\n\n### Fixed\n\n- `skydive update` no longer claims an update is available on every npm install.\n- Chat memory is bounded (payload clamps + windowed rows) with a memory watchdog and OOM diagnostic report; transcript rows are memoized so streaming stops re-rendering the whole chat.\n- Chat-send failures map to real error messages.\n- Notification and sidebar previews use the last text block of the reply and strip inline markdown.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n- Sending to non-web channel conversations is blocked in the TUI.\n- GitHub bot connect opens on the web front door, not api.skydive.com.\n- TUI activity counter times from the run, not the screen.\n\n## [0.2.0] - 2026-07-29\n\n### Added\n\n**Sandbox & machine access**\n\n- Standalone `skydive sandbox` command for direct access to an agent's sandbox.\n- `/sandbox` in the chat TUI — live PTY session and one-shot command execution.\n- Headless machine sharing via `skydive portal`, with self-registering portal grants.\n- `shareMachineDefault` config key for always-on portal sharing.\n\n**Chat TUI**\n\n- File pane (`ctrl+g`) with Changes and Files tabs: a shared file tree plus source viewer and a workspace browser, mouse-resizable and responsive to terminal size.\n- Agent todo list rendered in the chat TUI, above the composer, mirroring the web chat's todo card.\n- Fuzzy finder in the conversation and agent pickers.\n- Slash-command autocomplete menu.\n- Paste or drag-and-drop any file into the composer; paste clipboard images with Cmd+V.\n- Run local shell commands with `!` in the composer.\n- Conversation recaps, streamed live title updates, and per-agent attribution on assistant turns.\n- Working timer rolls up into minutes and hours.\n- Conversation picker paginates past 50 conversations and shows only your own conversations.\n- Esc leaves a live run; typing `exit` quits the chat.\n- Cursor Dark theme.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n\n**Headless & scripting**\n\n- Resume a conversation by id.\n- `conversations list` and `conversations show` for transcript reads.\n- `messages get`, with run recovery keyed on message id.\n- Connect cards surface in headless `-p` mode so a driving agent never gets stuck.\n\n**Authentication**\n\n- `skydive auth login` via the browser now auto-mints an API key, so one login yields both a chat session and a usable management credential. Management commands announce the key's pinned workspace when it drives them, so a workspace mismatch is visible at use time.\n- Workspace picker on the device authorization page.\n- Account and workspace identity shown in `auth status`.\n\n**Platform**\n\n- Standalone binary builds compiling the CLI into a per-target executable.\n- Interactive workspace switcher; management commands follow the active workspace.\n- Terminal host integrations and agent notifications.\n\n### Fixed\n\n- Transcript errors collapse to one line, click to expand (REST and portal errors keep their full body).\n- Dragged/pasted image file paths attach the file instead of inserting path text, including macOS paths with literal parentheses.\n- Bare URLs in chat markdown are hyperlinked so they survive text wrap.\n- Composer draft is preserved across TUI overlays.\n- Relative connect links resolve before opening the browser.\n- Numbered markdown headings render colored in the TUI.\n- Chat transcript pages by 75% of a screen; picker rows stay on one line.\n- Run starts push to the TUI over the conversation stream.\n- Security: remediated high-severity dependency findings and cleared tar/shell-quote CVEs.\n\n## [0.1.0] - 2026-07-21\n\nInitial public release: `skydive chat` TUI, agent and conversation management,\ndevice authorization, and headless `-p` mode.\n";
|
|
4028
|
+
const CHANGELOG_MD = "# Changelog\n\nAll notable changes to the Skydive CLI are documented here.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [Unreleased]\n\n### Added\n\n- `skydive fs` — a namespace for working with the files on an agent's computer (its sandbox) from your own machine. Its first subcommand, `skydive fs edit <path>`, reads a remote file down over the same relay `skydive sandbox` uses, opens it in your local editor (`$VISUAL`/`$EDITOR`, override with `--editor`, defaults to `vi`), and writes your changes back atomically when you save and close — so you can edit a remote file as if it were local without opening the chat TUI. A path that doesn't exist yet is created on save; no changes means nothing is written. Access is gated on EDIT permission for the agent, exactly like `skydive sandbox`. (A first-class `fs` relay channel and `skydive fs mount` land in follow-ups.)\n\n## [0.4.0] - 2026-08-07\n\n### Added\n\n- `skydive chat` works with API key auth: an API key alone now opens the chat TUI (and headless `chat -p`) without a browser login, using the key's pinned workspace.\n- `skydive config` command to view and set the safe, hand-editable CLI preferences (`shareMachineDefault`, `updateCheck`) without opening `config.json`. `config`/`config list` shows each key, its effective value, and whether it comes from the file or the built-in default; `config get`/`set`/`unset` read and change one key; `config path` prints the config file location. It only ever touches those preference keys, never credentials or flow-managed state.\n- Billing-blocked sends and runs now surface the server-authored recovery\n guidance from the typed billing outcome. The chat TUI renders it as a\n warning-toned system-notice row — live when a send is refused or a run is\n stopped at the billing boundary, and again when reopening a conversation\n that holds a persisted billing notice — instead of a generic error.\n Headless `chat -p` and `messages get` print the guidance (state, recovery\n step, and manage-billing URL) on stderr, keep any partial output already\n streamed on stdout, and exit with code `5` (distinct from the generic `1`)\n so scripted callers can tell a billing pause from a failure.\n- Syntax highlighting for 14 more languages in the chat transcript and file/review panes (python, bash, go, rust, c, cpp, java, ruby, css, html, json, yaml, and more) — previously only JavaScript/TypeScript rendered colored.\n\n### Changed\n\n- `skydive agent list` lists the full agent roster by default instead of a truncated page.\n\n### Fixed\n\n- Long multi-line bash tool-call commands (e.g. heredocs) are clamped with a `+N more · click to expand` tail instead of dumping their whole body into the scrollback.\n- Tool error output is clipped the same way as ok output, so a failing command no longer floods the transcript.\n- The TUI toast overlay has an opaque background instead of letting the transcript bleed through.\n\n## [0.3.0] - 2026-08-04\n\n### Added\n\n**Chat TUI**\n\n- `/fork` slash command to fork a conversation at any point and continue in a new thread.\n- `/conversation` switches threads from inside a live session.\n- `/compact` triggers manual conversation compaction.\n- `/portal` and `/copy` slash commands.\n- Archive the current conversation from the chat TUI.\n- `--new` flag on `skydive chat` to start a fresh conversation.\n- Debounced server-side conversation search in the picker, with title matches ranked first.\n- File review pane orientation toggle, and review comments in the file pane.\n- Pinned plan card controls and a jump-to-latest hint.\n- Terminal title (OSC) follows the live conversation title on every screen; inside cmux the workspace is renamed too, and linked PRs are pushed to the cmux sidebar.\n- Every participating agent shows in the conversation list; connect cards each have their own identity, and ctrl+r asks which connect card to act on.\n- Colored Skydive splash art in `skydive --help` and the TUI pickers.\n- New-agent name prefilled from the server's suggestion.\n\n**CLI & platform**\n\n- `skydive update` self-updater, with an update notice when a new version is available.\n- Shell completions for bash, zsh, and fish via `completion install`.\n- Portal daemon: one connection per host with per-conversation working directories.\n- Agent-led coding-agent import (`skydive import`).\n- Per-workspace scoping on the REST client, and cross-org `--agent <uuid>` auto-switches workspace.\n- `skydive-beta` wrapper for the canary channel.\n\n### Fixed\n\n- `skydive update` no longer claims an update is available on every npm install.\n- Chat memory is bounded (payload clamps + windowed rows) with a memory watchdog and OOM diagnostic report; transcript rows are memoized so streaming stops re-rendering the whole chat.\n- Chat-send failures map to real error messages.\n- Notification and sidebar previews use the last text block of the reply and strip inline markdown.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n- Sending to non-web channel conversations is blocked in the TUI.\n- GitHub bot connect opens on the web front door, not api.skydive.com.\n- TUI activity counter times from the run, not the screen.\n\n## [0.2.0] - 2026-07-29\n\n### Added\n\n**Sandbox & machine access**\n\n- Standalone `skydive sandbox` command for direct access to an agent's sandbox.\n- `/sandbox` in the chat TUI — live PTY session and one-shot command execution.\n- Headless machine sharing via `skydive portal`, with self-registering portal grants.\n- `shareMachineDefault` config key for always-on portal sharing.\n\n**Chat TUI**\n\n- File pane (`ctrl+g`) with Changes and Files tabs: a shared file tree plus source viewer and a workspace browser, mouse-resizable and responsive to terminal size.\n- Agent todo list rendered in the chat TUI, above the composer, mirroring the web chat's todo card.\n- Fuzzy finder in the conversation and agent pickers.\n- Slash-command autocomplete menu.\n- Paste or drag-and-drop any file into the composer; paste clipboard images with Cmd+V.\n- Run local shell commands with `!` in the composer.\n- Conversation recaps, streamed live title updates, and per-agent attribution on assistant turns.\n- Working timer rolls up into minutes and hours.\n- Conversation picker paginates past 50 conversations and shows only your own conversations.\n- Esc leaves a live run; typing `exit` quits the chat.\n- Cursor Dark theme.\n- Picker rows no longer overlap when a conversation title contains a newline, tab, or control character.\n\n**Headless & scripting**\n\n- Resume a conversation by id.\n- `conversations list` and `conversations show` for transcript reads.\n- `messages get`, with run recovery keyed on message id.\n- Connect cards surface in headless `-p` mode so a driving agent never gets stuck.\n\n**Authentication**\n\n- `skydive auth login` via the browser now auto-mints an API key, so one login yields both a chat session and a usable management credential. Management commands announce the key's pinned workspace when it drives them, so a workspace mismatch is visible at use time.\n- Workspace picker on the device authorization page.\n- Account and workspace identity shown in `auth status`.\n\n**Platform**\n\n- Standalone binary builds compiling the CLI into a per-target executable.\n- Interactive workspace switcher; management commands follow the active workspace.\n- Terminal host integrations and agent notifications.\n\n### Fixed\n\n- Transcript errors collapse to one line, click to expand (REST and portal errors keep their full body).\n- Dragged/pasted image file paths attach the file instead of inserting path text, including macOS paths with literal parentheses.\n- Bare URLs in chat markdown are hyperlinked so they survive text wrap.\n- Composer draft is preserved across TUI overlays.\n- Relative connect links resolve before opening the browser.\n- Numbered markdown headings render colored in the TUI.\n- Chat transcript pages by 75% of a screen; picker rows stay on one line.\n- Run starts push to the TUI over the conversation stream.\n- Security: remediated high-severity dependency findings and cleared tar/shell-quote CVEs.\n\n## [0.1.0] - 2026-07-21\n\nInitial public release: `skydive chat` TUI, agent and conversation management,\ndevice authorization, and headless `-p` mode.\n";
|
|
3758
4029
|
|
|
3759
4030
|
//#endregion
|
|
3760
4031
|
//#region src/whats-new.ts
|
|
@@ -3897,7 +4168,7 @@ if (process.argv.includes(UPDATE_WORKER_FLAG)) {
|
|
|
3897
4168
|
process.exit(0);
|
|
3898
4169
|
}
|
|
3899
4170
|
if (process.argv.includes(PORTAL_DAEMON_FLAG)) {
|
|
3900
|
-
const { runPortalDaemon } = await import("./daemon-
|
|
4171
|
+
const { runPortalDaemon } = await import("./daemon-imLBqTGg.mjs");
|
|
3901
4172
|
runPortalDaemon(process.argv);
|
|
3902
4173
|
} else runCli();
|
|
3903
4174
|
function runCli() {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as setActiveWorkspace, E as listWorkspaces, S as themesForMode, _ as themeForMode, a as installCrashHandler, b as themeVersion, c as MARK_CELLS, d as DEFAULT_THEME_ID, f as applyTheme, g as theme, h as noColorRequested, i as writeArtifact, l as WORDMARK, m as monoTheme, n as profilingEnabled, o as buildCrashReport, p as findTheme, r as record, s as writeCrashReport, v as themeMode, w as getActiveWorkspaceId, y as themeModeFromColorFgBg } from "./profiler-
|
|
2
|
+
import { D as setActiveWorkspace, E as listWorkspaces, S as themesForMode, _ as themeForMode, a as installCrashHandler, b as themeVersion, c as MARK_CELLS, d as DEFAULT_THEME_ID, f as applyTheme, g as theme, h as noColorRequested, i as writeArtifact, l as WORDMARK, m as monoTheme, n as profilingEnabled, o as buildCrashReport, p as findTheme, r as record, s as writeCrashReport, v as themeMode, w as getActiveWorkspaceId, y as themeModeFromColorFgBg } from "./profiler-CZtc7-p8.mjs";
|
|
3
3
|
import { B as saveTheme, D as getSavedTheme, E as getReviewStateDir, L as resolveWebUrl, S as getConfigPath, c as cardActionErrorMessage, d as reconcileMaskedInput, f as resolveConnectUrl, i as resolveAgent, l as parseExternalOauthConnectParams, m as specKeyFor, p as parseConnectCard, s as MASK_CHAR, u as parseOauthConnectParams, v as DEFAULT_API_URL, y as DEFAULT_APP_URL } from "./print-CbayCa87.mjs";
|
|
4
4
|
import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
|
|
5
5
|
import { a as isRecord, i as errorMessage, n as errorDetail, r as sendErrorMessage, t as createRestClient } from "./rest-BY2nADw5.mjs";
|
|
6
6
|
import { i as billingBlockedOutcomeFromSendResponse } from "./billing-blocked-2wju4gC_.mjs";
|
|
7
7
|
import { t as PortalClient } from "./client-Cf7cvftg.mjs";
|
|
8
|
-
import
|
|
8
|
+
import "./daemon-DaUaCMwC.mjs";
|
|
9
9
|
import { t as SandboxStream } from "./client-Cn2af31H.mjs";
|
|
10
|
-
import { t as
|
|
10
|
+
import { t as PortalDaemonClient } from "./daemon-client-CJxbCLOb.mjs";
|
|
11
|
+
import { t as runRawPtyPassthrough } from "./raw-pty-B6mAroiI.mjs";
|
|
11
12
|
import * as os$1 from "node:os";
|
|
12
13
|
import { homedir, platform, release, tmpdir } from "node:os";
|
|
13
14
|
import path, { basename, extname, isAbsolute, join, win32 } from "node:path";
|
|
@@ -15,7 +16,7 @@ import { z } from "zod";
|
|
|
15
16
|
import open from "open";
|
|
16
17
|
import { constants } from "node:fs";
|
|
17
18
|
import { execFile, spawn } from "node:child_process";
|
|
18
|
-
import { createHash
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
19
20
|
import { connect, createConnection } from "node:net";
|
|
20
21
|
import { access, appendFile, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
21
22
|
import { MarkdownRenderable, RenderableEvents, StyledText, SyntaxStyle, addDefaultParsers, createCliRenderer, decodePasteBytes, detectLinks, fg, link } from "@opentui/core";
|
|
@@ -293,151 +294,6 @@ async function resolveInitialScreen({ rest, agentSelector, conversationId, newCo
|
|
|
293
294
|
};
|
|
294
295
|
}
|
|
295
296
|
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region ../portal-daemon/src/daemon-client.ts
|
|
298
|
-
var PortalDaemonClient = class {
|
|
299
|
-
sessionId = randomUUID();
|
|
300
|
-
socket = null;
|
|
301
|
-
disposed = false;
|
|
302
|
-
reconnectTimer = null;
|
|
303
|
-
lastBind = null;
|
|
304
|
-
wantEnabled = false;
|
|
305
|
-
pendingGrants = /* @__PURE__ */ new Set();
|
|
306
|
-
grantedAgentIds = /* @__PURE__ */ new Set();
|
|
307
|
-
constructor(opts) {
|
|
308
|
-
this.opts = opts;
|
|
309
|
-
}
|
|
310
|
-
/** Spawn the daemon if needed and attach. Idempotent. */
|
|
311
|
-
async start() {
|
|
312
|
-
if (this.disposed) return;
|
|
313
|
-
await ensureDaemonRunning(this.opts.appUrl);
|
|
314
|
-
this.connect();
|
|
315
|
-
}
|
|
316
|
-
connect() {
|
|
317
|
-
if (this.disposed) return;
|
|
318
|
-
const { socketPath } = daemonPaths(this.opts.appUrl);
|
|
319
|
-
const socket = connect(socketPath);
|
|
320
|
-
socket.setEncoding("utf8");
|
|
321
|
-
this.socket = socket;
|
|
322
|
-
const parse = makeLineParser();
|
|
323
|
-
socket.on("connect", () => {
|
|
324
|
-
this.send({
|
|
325
|
-
t: "hello",
|
|
326
|
-
v: LOCAL_PROTOCOL_VERSION,
|
|
327
|
-
sessionId: this.sessionId,
|
|
328
|
-
token: this.opts.sessionToken
|
|
329
|
-
});
|
|
330
|
-
if (this.wantEnabled) this.send({ t: "enable" });
|
|
331
|
-
if (this.lastBind) this.send({
|
|
332
|
-
t: "bind",
|
|
333
|
-
sessionId: this.sessionId,
|
|
334
|
-
conversationId: this.lastBind.conversationId,
|
|
335
|
-
cwd: this.lastBind.cwd
|
|
336
|
-
});
|
|
337
|
-
for (const agentId of this.pendingGrants) this.send({
|
|
338
|
-
t: "grant",
|
|
339
|
-
agentId
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
socket.on("data", (chunk) => {
|
|
343
|
-
for (const line of parse(chunk)) {
|
|
344
|
-
const msg = parseDaemonMessage(line);
|
|
345
|
-
if (msg) this.onMessage(msg);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
const onClose = () => {
|
|
349
|
-
if (this.socket === socket) this.socket = null;
|
|
350
|
-
this.scheduleReconnect();
|
|
351
|
-
};
|
|
352
|
-
socket.on("close", onClose);
|
|
353
|
-
socket.on("error", onClose);
|
|
354
|
-
}
|
|
355
|
-
scheduleReconnect() {
|
|
356
|
-
if (this.disposed || this.reconnectTimer) return;
|
|
357
|
-
this.reconnectTimer = setTimeout(() => {
|
|
358
|
-
this.reconnectTimer = null;
|
|
359
|
-
this.start();
|
|
360
|
-
}, 500);
|
|
361
|
-
this.reconnectTimer.unref();
|
|
362
|
-
}
|
|
363
|
-
onMessage(msg) {
|
|
364
|
-
if (msg.t === "state") {
|
|
365
|
-
this.grantedAgentIds = new Set(msg.grantedAgentIds);
|
|
366
|
-
this.opts.onState({
|
|
367
|
-
status: msg.status,
|
|
368
|
-
machineName: msg.machineName,
|
|
369
|
-
friendlyName: msg.friendlyName,
|
|
370
|
-
error: msg.error,
|
|
371
|
-
grantedAgentIds: msg.grantedAgentIds
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/** Whether this agent is currently authorized on the machine (last daemon state). */
|
|
376
|
-
isGranted(agentId) {
|
|
377
|
-
return this.grantedAgentIds.has(agentId);
|
|
378
|
-
}
|
|
379
|
-
/** Whether the user has turned machine sharing on from this CLI. */
|
|
380
|
-
isEnabled() {
|
|
381
|
-
return this.wantEnabled;
|
|
382
|
-
}
|
|
383
|
-
send(msg) {
|
|
384
|
-
if (this.socket?.writable) this.socket.write(encodeLine(msg));
|
|
385
|
-
}
|
|
386
|
-
/** Turn machine sharing on (the daemon connects the portal). */
|
|
387
|
-
enable() {
|
|
388
|
-
this.wantEnabled = true;
|
|
389
|
-
this.send({ t: "enable" });
|
|
390
|
-
}
|
|
391
|
-
/** Turn machine sharing off. */
|
|
392
|
-
disable() {
|
|
393
|
-
this.wantEnabled = false;
|
|
394
|
-
this.send({ t: "disable" });
|
|
395
|
-
}
|
|
396
|
-
/** Register / update this conversation's working directory for exec routing. */
|
|
397
|
-
bind(conversationId, cwd) {
|
|
398
|
-
this.lastBind = {
|
|
399
|
-
conversationId,
|
|
400
|
-
cwd
|
|
401
|
-
};
|
|
402
|
-
this.send({
|
|
403
|
-
t: "bind",
|
|
404
|
-
sessionId: this.sessionId,
|
|
405
|
-
conversationId,
|
|
406
|
-
cwd
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Authorize one agent to run commands on this machine. Resolves once the
|
|
411
|
-
* request is sent to the daemon (the daemon performs the grant and pushes the
|
|
412
|
-
* updated state); kept async so it's a drop-in for the old in-process client's
|
|
413
|
-
* awaited `grantAgent`.
|
|
414
|
-
*/
|
|
415
|
-
grantAgent(agentId) {
|
|
416
|
-
this.pendingGrants.add(agentId);
|
|
417
|
-
this.send({
|
|
418
|
-
t: "grant",
|
|
419
|
-
agentId
|
|
420
|
-
});
|
|
421
|
-
return Promise.resolve();
|
|
422
|
-
}
|
|
423
|
-
/** Detach this CLI. The daemon keeps running for other clients. */
|
|
424
|
-
dispose() {
|
|
425
|
-
this.disposed = true;
|
|
426
|
-
if (this.reconnectTimer) {
|
|
427
|
-
clearTimeout(this.reconnectTimer);
|
|
428
|
-
this.reconnectTimer = null;
|
|
429
|
-
}
|
|
430
|
-
this.send({
|
|
431
|
-
t: "bye",
|
|
432
|
-
sessionId: this.sessionId
|
|
433
|
-
});
|
|
434
|
-
try {
|
|
435
|
-
this.socket?.destroy();
|
|
436
|
-
} catch (_error) {}
|
|
437
|
-
this.socket = null;
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
|
|
441
297
|
//#endregion
|
|
442
298
|
//#region ../portal-daemon/src/create-portal-client.ts
|
|
443
299
|
/**
|
|
@@ -95,6 +95,15 @@ const clientBindSchema = z.object({
|
|
|
95
95
|
/** `enable`/`disable` — turn machine sharing on/off (user-initiated). */
|
|
96
96
|
const clientEnableSchema = z.object({ t: z.literal("enable") });
|
|
97
97
|
const clientDisableSchema = z.object({ t: z.literal("disable") });
|
|
98
|
+
/**
|
|
99
|
+
* `cwd` — set the directory an exec runs in when its conversation is unknown.
|
|
100
|
+
* `skydive portal open` has no conversation of its own: it shares the machine
|
|
101
|
+
* for one directory, so it sets the fallback directly instead of binding.
|
|
102
|
+
*/
|
|
103
|
+
const clientCwdSchema = z.object({
|
|
104
|
+
t: z.literal("cwd"),
|
|
105
|
+
cwd: z.string().min(1)
|
|
106
|
+
});
|
|
98
107
|
/** `grant` — authorize one agent to reach this machine (user-initiated). */
|
|
99
108
|
const clientGrantSchema = z.object({
|
|
100
109
|
t: z.literal("grant"),
|
|
@@ -122,6 +131,7 @@ const clientMessageSchema = z.discriminatedUnion("t", [
|
|
|
122
131
|
clientBindSchema,
|
|
123
132
|
clientEnableSchema,
|
|
124
133
|
clientDisableSchema,
|
|
134
|
+
clientCwdSchema,
|
|
125
135
|
clientGrantSchema,
|
|
126
136
|
clientByeSchema,
|
|
127
137
|
clientStatusSchema,
|
|
@@ -289,7 +299,8 @@ var PortalDaemon = class {
|
|
|
289
299
|
const conn = {
|
|
290
300
|
socket,
|
|
291
301
|
sessionId: null,
|
|
292
|
-
conversations: /* @__PURE__ */ new Set()
|
|
302
|
+
conversations: /* @__PURE__ */ new Set(),
|
|
303
|
+
wantsShare: false
|
|
293
304
|
};
|
|
294
305
|
this.conns.add(conn);
|
|
295
306
|
this.clearIdleTimer();
|
|
@@ -323,12 +334,17 @@ var PortalDaemon = class {
|
|
|
323
334
|
this.persistState();
|
|
324
335
|
return;
|
|
325
336
|
case "enable":
|
|
337
|
+
conn.wantsShare = true;
|
|
326
338
|
this.ensureClient();
|
|
327
339
|
this.client?.enable();
|
|
328
340
|
return;
|
|
329
341
|
case "disable":
|
|
342
|
+
for (const other of this.conns) other.wantsShare = false;
|
|
330
343
|
this.client?.disable();
|
|
331
344
|
return;
|
|
345
|
+
case "cwd":
|
|
346
|
+
this.fallbackCwd = msg.cwd;
|
|
347
|
+
return;
|
|
332
348
|
case "grant":
|
|
333
349
|
this.ensureClient();
|
|
334
350
|
this.client?.grantAgent(msg.agentId).catch((error) => {
|
|
@@ -353,6 +369,8 @@ var PortalDaemon = class {
|
|
|
353
369
|
try {
|
|
354
370
|
conn.socket.destroy();
|
|
355
371
|
} catch (_error) {}
|
|
372
|
+
conn.wantsShare = false;
|
|
373
|
+
if (![...this.conns].some((c) => c.wantsShare)) this.client?.disable();
|
|
356
374
|
if (this.conns.size === 0) this.armIdleTimer();
|
|
357
375
|
}
|
|
358
376
|
/** Create the single PortalClient the first time a client needs the portal. */
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { d as makeLineParser, f as parseDaemonMessage, l as daemonPaths, n as ensureDaemonRunning, s as LOCAL_PROTOCOL_VERSION, u as encodeLine } from "./daemon-DaUaCMwC.mjs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { connect } from "node:net";
|
|
5
|
+
|
|
6
|
+
//#region ../portal-daemon/src/daemon-client.ts
|
|
7
|
+
var PortalDaemonClient = class {
|
|
8
|
+
sessionId = randomUUID();
|
|
9
|
+
socket = null;
|
|
10
|
+
disposed = false;
|
|
11
|
+
reconnectTimer = null;
|
|
12
|
+
lastBind = null;
|
|
13
|
+
fallbackCwd = null;
|
|
14
|
+
wantEnabled = false;
|
|
15
|
+
pendingGrants = /* @__PURE__ */ new Set();
|
|
16
|
+
grantedAgentIds = /* @__PURE__ */ new Set();
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
this.opts = opts;
|
|
19
|
+
}
|
|
20
|
+
/** Spawn the daemon if needed and attach. Idempotent. */
|
|
21
|
+
async start() {
|
|
22
|
+
if (this.disposed) return;
|
|
23
|
+
await ensureDaemonRunning(this.opts.appUrl);
|
|
24
|
+
this.connect();
|
|
25
|
+
}
|
|
26
|
+
connect() {
|
|
27
|
+
if (this.disposed) return;
|
|
28
|
+
const { socketPath } = daemonPaths(this.opts.appUrl);
|
|
29
|
+
const socket = connect(socketPath);
|
|
30
|
+
socket.setEncoding("utf8");
|
|
31
|
+
this.socket = socket;
|
|
32
|
+
const parse = makeLineParser();
|
|
33
|
+
socket.on("connect", () => {
|
|
34
|
+
this.send({
|
|
35
|
+
t: "hello",
|
|
36
|
+
v: LOCAL_PROTOCOL_VERSION,
|
|
37
|
+
sessionId: this.sessionId,
|
|
38
|
+
token: this.opts.sessionToken
|
|
39
|
+
});
|
|
40
|
+
if (this.wantEnabled) this.send({ t: "enable" });
|
|
41
|
+
if (this.fallbackCwd) this.send({
|
|
42
|
+
t: "cwd",
|
|
43
|
+
cwd: this.fallbackCwd
|
|
44
|
+
});
|
|
45
|
+
if (this.lastBind) this.send({
|
|
46
|
+
t: "bind",
|
|
47
|
+
sessionId: this.sessionId,
|
|
48
|
+
conversationId: this.lastBind.conversationId,
|
|
49
|
+
cwd: this.lastBind.cwd
|
|
50
|
+
});
|
|
51
|
+
for (const agentId of this.pendingGrants) this.send({
|
|
52
|
+
t: "grant",
|
|
53
|
+
agentId
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
socket.on("data", (chunk) => {
|
|
57
|
+
for (const line of parse(chunk)) {
|
|
58
|
+
const msg = parseDaemonMessage(line);
|
|
59
|
+
if (msg) this.onMessage(msg);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const onClose = () => {
|
|
63
|
+
if (this.socket === socket) this.socket = null;
|
|
64
|
+
this.scheduleReconnect();
|
|
65
|
+
};
|
|
66
|
+
socket.on("close", onClose);
|
|
67
|
+
socket.on("error", onClose);
|
|
68
|
+
}
|
|
69
|
+
scheduleReconnect() {
|
|
70
|
+
if (this.disposed || this.reconnectTimer) return;
|
|
71
|
+
this.reconnectTimer = setTimeout(() => {
|
|
72
|
+
this.reconnectTimer = null;
|
|
73
|
+
this.start();
|
|
74
|
+
}, 500);
|
|
75
|
+
this.reconnectTimer.unref();
|
|
76
|
+
}
|
|
77
|
+
onMessage(msg) {
|
|
78
|
+
if (msg.t === "state") {
|
|
79
|
+
this.grantedAgentIds = new Set(msg.grantedAgentIds);
|
|
80
|
+
this.opts.onState({
|
|
81
|
+
status: msg.status,
|
|
82
|
+
machineName: msg.machineName,
|
|
83
|
+
friendlyName: msg.friendlyName,
|
|
84
|
+
error: msg.error,
|
|
85
|
+
grantedAgentIds: msg.grantedAgentIds
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Whether this agent is currently authorized on the machine (last daemon state). */
|
|
90
|
+
isGranted(agentId) {
|
|
91
|
+
return this.grantedAgentIds.has(agentId);
|
|
92
|
+
}
|
|
93
|
+
/** Whether the user has turned machine sharing on from this CLI. */
|
|
94
|
+
isEnabled() {
|
|
95
|
+
return this.wantEnabled;
|
|
96
|
+
}
|
|
97
|
+
send(msg) {
|
|
98
|
+
if (this.socket?.writable) this.socket.write(encodeLine(msg));
|
|
99
|
+
}
|
|
100
|
+
/** Turn machine sharing on (the daemon connects the portal). */
|
|
101
|
+
enable() {
|
|
102
|
+
this.wantEnabled = true;
|
|
103
|
+
this.send({ t: "enable" });
|
|
104
|
+
}
|
|
105
|
+
/** Turn machine sharing off. */
|
|
106
|
+
disable() {
|
|
107
|
+
this.wantEnabled = false;
|
|
108
|
+
this.send({ t: "disable" });
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Set the directory an exec runs in when the daemon can't place its
|
|
112
|
+
* conversation. `skydive portal open` shares one directory and has no
|
|
113
|
+
* conversation of its own, so this is how it routes.
|
|
114
|
+
*/
|
|
115
|
+
setFallbackCwd(cwd) {
|
|
116
|
+
this.fallbackCwd = cwd;
|
|
117
|
+
this.send({
|
|
118
|
+
t: "cwd",
|
|
119
|
+
cwd
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** Register / update this conversation's working directory for exec routing. */
|
|
123
|
+
bind(conversationId, cwd) {
|
|
124
|
+
this.lastBind = {
|
|
125
|
+
conversationId,
|
|
126
|
+
cwd
|
|
127
|
+
};
|
|
128
|
+
this.send({
|
|
129
|
+
t: "bind",
|
|
130
|
+
sessionId: this.sessionId,
|
|
131
|
+
conversationId,
|
|
132
|
+
cwd
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Authorize one agent to run commands on this machine. Resolves once the
|
|
137
|
+
* request is sent to the daemon (the daemon performs the grant and pushes the
|
|
138
|
+
* updated state); kept async so it's a drop-in for the old in-process client's
|
|
139
|
+
* awaited `grantAgent`.
|
|
140
|
+
*/
|
|
141
|
+
grantAgent(agentId) {
|
|
142
|
+
this.pendingGrants.add(agentId);
|
|
143
|
+
this.send({
|
|
144
|
+
t: "grant",
|
|
145
|
+
agentId
|
|
146
|
+
});
|
|
147
|
+
return Promise.resolve();
|
|
148
|
+
}
|
|
149
|
+
/** Detach this CLI. The daemon keeps running for other clients. */
|
|
150
|
+
dispose() {
|
|
151
|
+
this.disposed = true;
|
|
152
|
+
if (this.reconnectTimer) {
|
|
153
|
+
clearTimeout(this.reconnectTimer);
|
|
154
|
+
this.reconnectTimer = null;
|
|
155
|
+
}
|
|
156
|
+
this.send({
|
|
157
|
+
t: "bye",
|
|
158
|
+
sessionId: this.sessionId
|
|
159
|
+
});
|
|
160
|
+
try {
|
|
161
|
+
this.socket?.destroy();
|
|
162
|
+
} catch (_error) {}
|
|
163
|
+
this.socket = null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
export { PortalDaemonClient as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "./client-Cf7cvftg.mjs";
|
|
3
|
-
import { a as runPortalDaemon, i as queryDaemonStatus, n as ensureDaemonRunning, o as stopDaemon, r as isDaemonListening, t as PortalDaemon } from "./daemon-
|
|
3
|
+
import { a as runPortalDaemon, i as queryDaemonStatus, n as ensureDaemonRunning, o as stopDaemon, r as isDaemonListening, t as PortalDaemon } from "./daemon-DaUaCMwC.mjs";
|
|
4
4
|
|
|
5
5
|
export { runPortalDaemon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skydive-cli",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.1352",
|
|
4
4
|
"description": "Skydive CLI — cloud agents from the command line",
|
|
5
5
|
"homepage": "https://skydive.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"react-devtools-core": "^7.0.1",
|
|
42
42
|
"safe-stable-stringify": "^2.3.1",
|
|
43
43
|
"semver": "^7.7.4",
|
|
44
|
+
"shell-quote": "1.9.0",
|
|
44
45
|
"web-tree-sitter": "0.25.10",
|
|
45
46
|
"ws": "^8.21.0",
|
|
46
47
|
"yargs": "^17.7.2",
|
|
File without changes
|
|
File without changes
|