skydive-cli 0.6.0-beta.23 → 0.6.0-beta.232
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 +11 -0
- package/dist/js/bin.mjs +871 -90
- package/dist/js/{boot-BtEzGVMb.mjs → boot-DryzgwlS.mjs} +11350 -9716
- package/dist/js/client-BKmjgUos.mjs +5 -0
- package/dist/js/{client-DJ0bPjqx.mjs → client-CXIx3OUL.mjs} +67 -8
- package/dist/js/{client-l6orYfqq.mjs → client-Cxk3khQu.mjs} +18 -4
- package/dist/js/{daemon-ccNQRdJd.mjs → daemon-B243dK4y.mjs} +117 -27
- package/dist/js/{daemon-BNxycRkd.mjs → daemon-CGWUrptn.mjs} +2 -2
- package/dist/js/{daemon-client-1Nh5ITt9.mjs → daemon-client-C5OyfC2Z.mjs} +29 -4
- package/dist/js/daemon-client-Wq3InJ9R.mjs +8 -0
- package/dist/js/{install-CdbqsofY.mjs → install-Cjtu-R4t.mjs} +82 -10
- package/dist/js/{print-CHSPHoin.mjs → print-BUPzBh79.mjs} +13 -12
- package/dist/js/{print-D79MKwnp.mjs → print-COum65TR.mjs} +2 -2
- package/dist/js/{print-share-ZtOgZIWk.mjs → print-share-DkP-BN3f.mjs} +1 -1
- package/dist/js/{raw-pty-dndn1Kxc.mjs → raw-pty-B-WKaaE3.mjs} +1 -1
- package/dist/js/raw-pty-BJIs_xjQ.mjs +5 -0
- package/dist/js/{rest-B5EVWw0j.mjs → rest-CF9IwcFW.mjs} +1 -1
- package/dist/js/{rest-CQ76yHFR.mjs → rest-DV-7jMam.mjs} +148 -15
- package/package.json +9 -8
- package/dist/js/client-rIw2WPPz.mjs +0 -5
- package/dist/js/daemon-client-BvbBPCJF.mjs +0 -8
- package/dist/js/raw-pty-DRZuf1oW.mjs +0 -5
package/dist/js/bin.mjs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as version, s as name, t as createRestClient } from "./rest-
|
|
3
|
-
import { A as
|
|
4
|
-
import { A as
|
|
2
|
+
import { c as version, s as name, t as createRestClient } from "./rest-DV-7jMam.mjs";
|
|
3
|
+
import { A as getPreference, B as resolveChatAuth, C as DEFAULT_API_URL, D as getConfigPath, E as deleteConfig, F as getStoredApiKeyId, G as saveConfig, H as resolveManagementAuth, I as getStoredApiKeyWorkspaceName, J as setLastSeenVersion, K as saveSession, L as getUpdateCheckDisabled, O as getDefaultAgent, P as getShareMachineDefault, S as API_KEY_PREFIX, T as PREFERENCES, U as resolveSession$1, V as resolveConfig, b as API_KEYS_URL, i as resolveAgent$1, j as getPromptHistoryPath, k as getLastSeenVersion, x as API_KEY_FAMILY_PREFIX, z as resolveAppUrl } from "./print-BUPzBh79.mjs";
|
|
4
|
+
import { A as aliasActivationHint, B as getActiveWorkspaceId, E as themes, F as SUPPORTED_SHELLS, H as listWorkspaces, I as defaultInstallEnv, L as detectShell, M as installAgentAlias, N as slugifyAliasName, O as buildImportSeedPrompt, P as takenAliasNames, R as openBestEffort, U as resolveWorkspaceId, V as getSessionIdentity, W as setActiveWorkspace, c as brandHelpArt, d as maybeStartProfiling, f as profileDir, j as dedupeAliasName, k as machineOsFromPlatform, t as installCrashHandler, u as getAutomaticLogsDir, z as ensureActiveOrganization } from "./install-Cjtu-R4t.mjs";
|
|
5
5
|
import { n as printError, r as printTable, t as output } from "./output-C9mb3sUB.mjs";
|
|
6
6
|
import { t as HttpError } from "./http-error-BF2NZZE3.mjs";
|
|
7
7
|
import "./billing-blocked-D3l5kJlX.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { s as resolveMachineIdentity } from "./client-CXIx3OUL.mjs";
|
|
9
9
|
import "./tls-cert-Rua2oV7n.mjs";
|
|
10
10
|
import { i as grantPortalAccess, n as fetchPortalDevices, o as registerPortalDevice, r as findThisDevice, s as revokePortalAccess } from "./api-BFQ4PQDA.mjs";
|
|
11
|
-
import { d as daemonPaths, i as queryDaemonStatus, n as ensureDaemonRunning, s as stopDaemon, u as PORTAL_DAEMON_FLAG } from "./daemon-
|
|
12
|
-
import { a as
|
|
11
|
+
import { d as daemonPaths, i as queryDaemonStatus, n as ensureDaemonRunning, s as stopDaemon, u as PORTAL_DAEMON_FLAG } from "./daemon-B243dK4y.mjs";
|
|
12
|
+
import { a as FS_MAX_BLOB_BYTES, i as streamSpecToQuery, n as DEFAULT_EXEC_TIMEOUT_MS, o as decodeFsResponse, r as SANDBOX_STREAM_PATH, s as encodeFsRequest, t as SandboxStream } from "./client-Cxk3khQu.mjs";
|
|
13
13
|
import { hideBin } from "yargs/helpers";
|
|
14
14
|
import yargs from "yargs";
|
|
15
15
|
import { hostname, tmpdir } from "node:os";
|
|
16
16
|
import path, { join } from "node:path";
|
|
17
17
|
import { err, ok } from "neverthrow";
|
|
18
|
+
import fsp, { mkdtemp, open, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
18
19
|
import { z } from "zod";
|
|
19
|
-
import open from "open";
|
|
20
20
|
import fs from "node:fs";
|
|
21
21
|
import { spawn, spawnSync } from "node:child_process";
|
|
22
22
|
import { createHash } from "node:crypto";
|
|
23
23
|
import zlib from "node:zlib";
|
|
24
|
-
import fsp, { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
25
24
|
import { WebSocket } from "ws";
|
|
26
25
|
import semver from "semver";
|
|
27
26
|
import { createInterface } from "node:readline";
|
|
@@ -71,7 +70,47 @@ const ApiKeySchema = z.object({
|
|
|
71
70
|
const CreatedApiKeySchema = ApiKeySchema.extend({ key: z.string() });
|
|
72
71
|
const ListApiKeysResponseSchema = z.object({ keys: z.array(ApiKeySchema) });
|
|
73
72
|
const ListSecretKeysResponseSchema = z.object({ keys: z.array(z.string()) });
|
|
73
|
+
const GitTokenSchema = z.object({
|
|
74
|
+
id: z.string(),
|
|
75
|
+
token: z.string(),
|
|
76
|
+
cloneUrl: z.string(),
|
|
77
|
+
remoteUrl: z.string(),
|
|
78
|
+
permissions: z.string(),
|
|
79
|
+
label: z.string().nullable()
|
|
80
|
+
});
|
|
81
|
+
const ListedGitTokenSchema = z.object({
|
|
82
|
+
id: z.string(),
|
|
83
|
+
permissions: z.string(),
|
|
84
|
+
label: z.string().nullable(),
|
|
85
|
+
lastUsedAt: z.string().nullable(),
|
|
86
|
+
createdAt: z.string()
|
|
87
|
+
});
|
|
88
|
+
const ListGitTokensResponseSchema = z.object({ tokens: z.array(ListedGitTokenSchema) });
|
|
74
89
|
const SetSecretResponseSchema = z.object({ key: z.string() });
|
|
90
|
+
const AvatarPresignResponseSchema = z.object({
|
|
91
|
+
uploadUrl: z.string(),
|
|
92
|
+
ttlSeconds: z.number()
|
|
93
|
+
});
|
|
94
|
+
const AvatarCommitResponseSchema = z.object({ avatarUrl: z.string() });
|
|
95
|
+
/** Same cap the server enforces at avatar commit; enforced client-side too so
|
|
96
|
+
* oversized files fail before the presign/PUT round-trip. */
|
|
97
|
+
const MAX_AGENT_AVATAR_BYTES = 5 * 1024 * 1024;
|
|
98
|
+
/**
|
|
99
|
+
* Sniff an agent-avatar media type from file magic bytes. Kept in sync with
|
|
100
|
+
* the api's commit sniff — `apps/anyone/api/src/lib/agent-avatar.ts`
|
|
101
|
+
* `sniffAvatarMediaType` — so the declared type always matches what the
|
|
102
|
+
* server accepts; the CLI deliberately has no @createinc/anyone-* deps (and
|
|
103
|
+
* no barrel imports, see the CLI bundle rules), so this stays a local copy.
|
|
104
|
+
* If you add a type here, add it there too or the server 415s at commit.
|
|
105
|
+
* null means the file is not an avatar-acceptable raster and the server
|
|
106
|
+
* would reject it.
|
|
107
|
+
*/
|
|
108
|
+
function sniffAgentAvatarMediaType(bytes) {
|
|
109
|
+
if (bytes.byteLength >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71) return "image/png";
|
|
110
|
+
if (bytes.byteLength >= 3 && bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) return "image/jpeg";
|
|
111
|
+
if (bytes.byteLength >= 12 && bytes[0] === 82 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 70 && bytes[8] === 87 && bytes[9] === 69 && bytes[10] === 66 && bytes[11] === 80) return "image/webp";
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
75
114
|
var SkydiveApiClient = class {
|
|
76
115
|
baseUrl;
|
|
77
116
|
token;
|
|
@@ -161,6 +200,99 @@ var SkydiveApiClient = class {
|
|
|
161
200
|
path: `/agents/${encodeURIComponent(agentId)}/secrets/${encodeURIComponent(key)}`
|
|
162
201
|
});
|
|
163
202
|
}
|
|
203
|
+
async listGitTokens(agentId) {
|
|
204
|
+
return this.request({
|
|
205
|
+
method: "GET",
|
|
206
|
+
path: `/agents/${encodeURIComponent(agentId)}/git-tokens`,
|
|
207
|
+
schema: ListGitTokensResponseSchema
|
|
208
|
+
}).then((r) => r.map((res) => res.tokens));
|
|
209
|
+
}
|
|
210
|
+
async createGitToken(agentId, params) {
|
|
211
|
+
return this.request({
|
|
212
|
+
method: "POST",
|
|
213
|
+
path: `/agents/${encodeURIComponent(agentId)}/git-tokens`,
|
|
214
|
+
body: params,
|
|
215
|
+
schema: GitTokenSchema
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async revokeGitToken(agentId, tokenId) {
|
|
219
|
+
return this.request({
|
|
220
|
+
method: "DELETE",
|
|
221
|
+
path: `/agents/${encodeURIComponent(agentId)}/git-tokens/${encodeURIComponent(tokenId)}`
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Set an agent's avatar photo, driving the server's presigned-PUT flow end
|
|
226
|
+
* to end: read the local file, sniff its raster type, presign, PUT the bytes
|
|
227
|
+
* straight to storage, then commit. Returns the versioned avatar URL the
|
|
228
|
+
* server stored.
|
|
229
|
+
*/
|
|
230
|
+
async setAgentAvatar(params) {
|
|
231
|
+
const prefix = Buffer.alloc(16);
|
|
232
|
+
let sniffBytes;
|
|
233
|
+
try {
|
|
234
|
+
const handle = await open(params.filePath, "r");
|
|
235
|
+
try {
|
|
236
|
+
const { bytesRead } = await handle.read(prefix, 0, prefix.byteLength, 0);
|
|
237
|
+
sniffBytes = prefix.subarray(0, bytesRead);
|
|
238
|
+
} finally {
|
|
239
|
+
await handle.close();
|
|
240
|
+
}
|
|
241
|
+
} catch (e) {
|
|
242
|
+
return err({
|
|
243
|
+
message: `Cannot read ${params.filePath}: ${e instanceof Error ? e.message : String(e)}`,
|
|
244
|
+
status: null
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const mediaType = sniffAgentAvatarMediaType(sniffBytes);
|
|
248
|
+
if (!mediaType) return err({
|
|
249
|
+
message: "Not an avatar the server accepts: it must be a PNG, JPEG, or WebP image.",
|
|
250
|
+
status: null
|
|
251
|
+
});
|
|
252
|
+
let bytes;
|
|
253
|
+
try {
|
|
254
|
+
bytes = await readFile(params.filePath);
|
|
255
|
+
} catch (e) {
|
|
256
|
+
return err({
|
|
257
|
+
message: `Cannot read ${params.filePath}: ${e instanceof Error ? e.message : String(e)}`,
|
|
258
|
+
status: null
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (bytes.byteLength > MAX_AGENT_AVATAR_BYTES) return err({
|
|
262
|
+
message: "image exceeds 5 MB",
|
|
263
|
+
status: null
|
|
264
|
+
});
|
|
265
|
+
const presign = await this.request({
|
|
266
|
+
method: "POST",
|
|
267
|
+
path: `/agents/${encodeURIComponent(params.agentId)}/avatar/presign`,
|
|
268
|
+
body: { mediaType },
|
|
269
|
+
schema: AvatarPresignResponseSchema
|
|
270
|
+
});
|
|
271
|
+
if (presign.isErr()) return err(presign.error);
|
|
272
|
+
const put = await fetch(presign.value.uploadUrl, {
|
|
273
|
+
method: "PUT",
|
|
274
|
+
headers: { "content-type": mediaType },
|
|
275
|
+
body: new Uint8Array(bytes)
|
|
276
|
+
});
|
|
277
|
+
if (!put.ok) return err({
|
|
278
|
+
message: `Avatar upload failed: HTTP ${put.status}`,
|
|
279
|
+
status: put.status
|
|
280
|
+
});
|
|
281
|
+
return this.request({
|
|
282
|
+
method: "POST",
|
|
283
|
+
path: `/agents/${encodeURIComponent(params.agentId)}/avatar`,
|
|
284
|
+
body: { mediaType },
|
|
285
|
+
schema: AvatarCommitResponseSchema
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
/** Remove an agent's uploaded avatar photo; the generated preset takes
|
|
289
|
+
* over. Idempotent server-side — removing an agent with no photo succeeds. */
|
|
290
|
+
async deleteAgentAvatar(agentId) {
|
|
291
|
+
return this.request({
|
|
292
|
+
method: "DELETE",
|
|
293
|
+
path: `/agents/${encodeURIComponent(agentId)}/avatar`
|
|
294
|
+
});
|
|
295
|
+
}
|
|
164
296
|
async request(params) {
|
|
165
297
|
const url = `${this.baseUrl}${params.path}`;
|
|
166
298
|
const headers = {
|
|
@@ -189,7 +321,7 @@ var SkydiveApiClient = class {
|
|
|
189
321
|
const body = await response.json();
|
|
190
322
|
if (body.error && typeof body.error === "string") message = body.error;
|
|
191
323
|
else if (body.error?.message) message = body.error.message;
|
|
192
|
-
} catch {}
|
|
324
|
+
} catch (_error) {}
|
|
193
325
|
if (response.status === 401 && this.authKind === "session") message = `${message}. Your chat session may have expired. Run \`skydive auth login\`.`;
|
|
194
326
|
return err({
|
|
195
327
|
message,
|
|
@@ -200,7 +332,7 @@ var SkydiveApiClient = class {
|
|
|
200
332
|
let body;
|
|
201
333
|
try {
|
|
202
334
|
body = await response.json();
|
|
203
|
-
} catch {
|
|
335
|
+
} catch (_error) {
|
|
204
336
|
return err({
|
|
205
337
|
message: "Invalid JSON response",
|
|
206
338
|
status: response.status
|
|
@@ -345,7 +477,7 @@ async function loginWithDevice({ appUrl, openBrowser = true }) {
|
|
|
345
477
|
const verificationUrl = code.verification_uri_complete ?? code.verification_uri;
|
|
346
478
|
process.stderr.write(`\nTo sign in, open:\n ${verificationUrl}\n`);
|
|
347
479
|
process.stderr.write(`and enter the code: ${formatUserCode(code.user_code)}\n\n`);
|
|
348
|
-
if (openBrowser) await
|
|
480
|
+
if (openBrowser) await openBestEffort({ target: verificationUrl });
|
|
349
481
|
process.stderr.write("Waiting for approval…\n");
|
|
350
482
|
let intervalMs = (code.interval ?? 5) * 1e3 || DEFAULT_INTERVAL_MS;
|
|
351
483
|
const expiresAt = Date.now() + code.expires_in * 1e3;
|
|
@@ -582,6 +714,7 @@ async function runBrowserLogin(argv) {
|
|
|
582
714
|
if (identity?.activeWorkspaceName) console.log(` Workspace: ${identity.activeWorkspaceName}`);
|
|
583
715
|
if (minted.isOk()) console.log(` API key: ${minted.value.prefix}… (${minted.value.name})`);
|
|
584
716
|
console.log(` Config: ${getConfigPath()}`);
|
|
717
|
+
console.log(" Git: to push to an agent repo from this machine, run `skydive agents git token create <agent>`");
|
|
585
718
|
}
|
|
586
719
|
/** CI / headless path: validate and persist an existing key, no browser. */
|
|
587
720
|
async function runApiKeyLogin(argv, apiKey) {
|
|
@@ -1027,6 +1160,40 @@ function requireManagementClient(argv, opts = {}) {
|
|
|
1027
1160
|
...opts.workspaceId ? { workspaceId: opts.workspaceId } : {}
|
|
1028
1161
|
});
|
|
1029
1162
|
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Resolve an agent-targeting command's agent selector (id or name) against
|
|
1165
|
+
* the management roster, returning the id, or exit with the candidate list.
|
|
1166
|
+
*
|
|
1167
|
+
* `secrets` and `keys` historically took a raw `--agent-id` and hit
|
|
1168
|
+
* `/agents/<value>/...` directly, so a name 404'd "agent not found" for a
|
|
1169
|
+
* perfectly real agent, while `sandbox`/`fs`/`portal` resolved the same
|
|
1170
|
+
* string happily (ANY-8977). Reads one page (the same 100 `skydive agents
|
|
1171
|
+
* list` shows), so the error's candidates are what the user was looking at.
|
|
1172
|
+
*/
|
|
1173
|
+
async function resolveTargetAgentId(client, selector) {
|
|
1174
|
+
if (!selector) {
|
|
1175
|
+
printError("Missing --agent <id or name>. Run `skydive agents list` for candidates.");
|
|
1176
|
+
process.exit(1);
|
|
1177
|
+
}
|
|
1178
|
+
const { resolveAgent } = await import("./print-COum65TR.mjs");
|
|
1179
|
+
const result = await client.listAgents({
|
|
1180
|
+
scope: "org",
|
|
1181
|
+
limit: 100
|
|
1182
|
+
});
|
|
1183
|
+
if (result.isErr()) {
|
|
1184
|
+
printError(result.error.message);
|
|
1185
|
+
process.exit(1);
|
|
1186
|
+
}
|
|
1187
|
+
try {
|
|
1188
|
+
return resolveAgent(result.value.agents.map((agent) => ({
|
|
1189
|
+
id: agent.id,
|
|
1190
|
+
name: agent.name
|
|
1191
|
+
})), selector).id;
|
|
1192
|
+
} catch (error) {
|
|
1193
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
1194
|
+
process.exit(1);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1030
1197
|
/** Resolve the session (see {@link requireSession}) and build a REST client. */
|
|
1031
1198
|
function requireRestClient(argv) {
|
|
1032
1199
|
const auth = resolveChatAuth({ appUrl: resolveAppUrl({ appUrl: argv["api-url"] }) });
|
|
@@ -1040,6 +1207,171 @@ function requireRestClient(argv) {
|
|
|
1040
1207
|
});
|
|
1041
1208
|
}
|
|
1042
1209
|
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/auth/git-credentials.ts
|
|
1212
|
+
/**
|
|
1213
|
+
* Laptop-side git credentials for an agent's repo.
|
|
1214
|
+
*
|
|
1215
|
+
* The in-sandbox push path (`git -> in-sandbox credential helper -> daemon ->
|
|
1216
|
+
* /git-credentials route -> git storage`) mints a short-lived credential per
|
|
1217
|
+
* push, which only works inside the sandbox. From a laptop, the supported
|
|
1218
|
+
* path is a git-proxy token: `POST /v1/agents/:agentId/git-tokens` returns a
|
|
1219
|
+
* long-lived `skdv_…` token plus a tokenless remote URL on the git-proxy
|
|
1220
|
+
* host. This module holds the pure logic for naming the token. The command
|
|
1221
|
+
* prints the values and changes nothing on the machine: what to do with the
|
|
1222
|
+
* token (credential store, remotes) is left to the user's own tools.
|
|
1223
|
+
*/
|
|
1224
|
+
/** Label stamped on the git-proxy token a machine mints for itself, so the
|
|
1225
|
+
* token is identifiable in `git token list` and on the web settings page. */
|
|
1226
|
+
function gitTokenLabel() {
|
|
1227
|
+
return `CLI git (${hostname()})`;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region src/commands/git-setup.ts
|
|
1232
|
+
/** Create one read_write git-proxy token for the agent and print it. The
|
|
1233
|
+
* API returns the ready-to-use tokenless remote URL, so the CLI does no URL
|
|
1234
|
+
* parsing. The command's job ends at the credential: it changes nothing on
|
|
1235
|
+
* this machine (no git config writes, no credential-store plumbing) — what
|
|
1236
|
+
* to do with the token is the caller's tool's business. The label is
|
|
1237
|
+
* metadata only, so a re-run accumulates rather than revokes. */
|
|
1238
|
+
const gitTokenCreateCommand = {
|
|
1239
|
+
command: "create <agent>",
|
|
1240
|
+
describe: "Create a git token to push to the agent's repo from your machine",
|
|
1241
|
+
builder: (y) => y.positional("agent", {
|
|
1242
|
+
type: "string",
|
|
1243
|
+
demandOption: true,
|
|
1244
|
+
describe: "Agent ID or name (see `skydive agents list`)"
|
|
1245
|
+
}),
|
|
1246
|
+
handler: async (argv) => {
|
|
1247
|
+
const client = requireManagementClient(argv);
|
|
1248
|
+
const agent = await resolveAgent(client, argv.agent);
|
|
1249
|
+
const created = await client.createGitToken(agent.id, {
|
|
1250
|
+
permissions: "read_write",
|
|
1251
|
+
label: gitTokenLabel()
|
|
1252
|
+
});
|
|
1253
|
+
if (created.isErr()) {
|
|
1254
|
+
printError(`Could not create a git token: ${created.error.message}`);
|
|
1255
|
+
process.exit(1);
|
|
1256
|
+
}
|
|
1257
|
+
const { token, remoteUrl } = created.value;
|
|
1258
|
+
if (argv.json) {
|
|
1259
|
+
output(argv, {
|
|
1260
|
+
agentId: agent.id,
|
|
1261
|
+
agentName: agent.name,
|
|
1262
|
+
remoteUrl,
|
|
1263
|
+
tokenLabel: created.value.label,
|
|
1264
|
+
token
|
|
1265
|
+
});
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
if (argv.quiet) {
|
|
1269
|
+
console.log(token);
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
console.log(`Git token for ${agent.name} (read_write).`);
|
|
1273
|
+
console.log(` Token: ${token}`);
|
|
1274
|
+
console.log(` Remote: ${remoteUrl} (password is the token)`);
|
|
1275
|
+
console.log(" Nothing was written to git on this machine; pipe these into whatever manages your credentials.");
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
/** List the agent's git tokens (id, label, permissions, last use) so a revoke
|
|
1279
|
+
* has an id to take. Token values only come back from creating. */
|
|
1280
|
+
const gitTokenListCommand = {
|
|
1281
|
+
command: "list <agent>",
|
|
1282
|
+
describe: "List the agent's git tokens",
|
|
1283
|
+
builder: (y) => y.positional("agent", {
|
|
1284
|
+
type: "string",
|
|
1285
|
+
demandOption: true,
|
|
1286
|
+
describe: "Agent ID or name (see `skydive agents list`)"
|
|
1287
|
+
}),
|
|
1288
|
+
handler: async (argv) => {
|
|
1289
|
+
const client = requireManagementClient(argv);
|
|
1290
|
+
const agent = await resolveAgent(client, argv.agent);
|
|
1291
|
+
const listed = await client.listGitTokens(agent.id);
|
|
1292
|
+
if (listed.isErr()) {
|
|
1293
|
+
printError(`Could not list this agent's git tokens: ${listed.error.message}`);
|
|
1294
|
+
process.exit(1);
|
|
1295
|
+
}
|
|
1296
|
+
if (argv.json) {
|
|
1297
|
+
output(argv, {
|
|
1298
|
+
agentId: agent.id,
|
|
1299
|
+
agentName: agent.name,
|
|
1300
|
+
tokens: listed.value
|
|
1301
|
+
});
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
if (argv.quiet) {
|
|
1305
|
+
for (const token of listed.value) console.log(token.id);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
if (listed.value.length === 0) {
|
|
1309
|
+
console.log(`No git tokens for ${agent.name}.`);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
printTable([
|
|
1313
|
+
"ID",
|
|
1314
|
+
"Label",
|
|
1315
|
+
"Permissions",
|
|
1316
|
+
"Last used"
|
|
1317
|
+
], listed.value.map((t) => [
|
|
1318
|
+
t.id,
|
|
1319
|
+
t.label ?? "",
|
|
1320
|
+
t.permissions,
|
|
1321
|
+
t.lastUsedAt ?? "never"
|
|
1322
|
+
]));
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
/** Revoke one git token by id (run `git token list` for the ids). */
|
|
1326
|
+
const gitTokenRevokeCommand = {
|
|
1327
|
+
command: "revoke <agent> <token-id>",
|
|
1328
|
+
describe: "Revoke one of the agent's git tokens by id",
|
|
1329
|
+
builder: (y) => y.positional("agent", {
|
|
1330
|
+
type: "string",
|
|
1331
|
+
demandOption: true,
|
|
1332
|
+
describe: "Agent ID or name (see `skydive agents list`)"
|
|
1333
|
+
}).positional("token-id", {
|
|
1334
|
+
type: "string",
|
|
1335
|
+
demandOption: true,
|
|
1336
|
+
describe: "Token id (see `skydive agents git token list`)"
|
|
1337
|
+
}),
|
|
1338
|
+
handler: async (argv) => {
|
|
1339
|
+
const client = requireManagementClient(argv);
|
|
1340
|
+
const agent = await resolveAgent(client, argv.agent);
|
|
1341
|
+
const revoked = await client.revokeGitToken(agent.id, argv["token-id"]);
|
|
1342
|
+
if (revoked.isErr()) {
|
|
1343
|
+
printError(`Could not revoke git token ${argv["token-id"]}: ${revoked.error.message}`);
|
|
1344
|
+
process.exit(1);
|
|
1345
|
+
}
|
|
1346
|
+
console.log(`Revoked git token ${argv["token-id"]} for ${agent.name}.`);
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
const gitTokenCommand = {
|
|
1350
|
+
command: "token <command>",
|
|
1351
|
+
describe: "Create, list, or revoke git-proxy tokens for an agent's repo",
|
|
1352
|
+
builder: (y) => y.command(gitTokenCreateCommand).command(gitTokenListCommand).command(gitTokenRevokeCommand).demandCommand(1, "Specify a subcommand: create, list, revoke"),
|
|
1353
|
+
handler: () => {}
|
|
1354
|
+
};
|
|
1355
|
+
/**
|
|
1356
|
+
* `skydive agents git` — git access to an agent's repo from your own machine.
|
|
1357
|
+
* The in-sandbox push path (git -> in-sandbox credential helper -> daemon ->
|
|
1358
|
+
* git storage) only works inside the sandbox; from a laptop, the supported
|
|
1359
|
+
* path is a git-proxy token via the same routes the web settings page uses:
|
|
1360
|
+
*
|
|
1361
|
+
* - `git token create <agent>` create a token and print it.
|
|
1362
|
+
* - `git token list <agent>` list the agent's tokens by id.
|
|
1363
|
+
* - `git token revoke <agent> <id>` revoke one token.
|
|
1364
|
+
*
|
|
1365
|
+
* The command's job ends at the credential: it changes nothing on this
|
|
1366
|
+
* machine — what to do with the token is the caller's tool's business.
|
|
1367
|
+
*/
|
|
1368
|
+
const gitCommand = {
|
|
1369
|
+
command: "git <command>",
|
|
1370
|
+
describe: "Git access to an agent's repo from your machine",
|
|
1371
|
+
builder: (y) => y.command(gitTokenCommand).demandCommand(1, "Specify a subcommand: token"),
|
|
1372
|
+
handler: () => {}
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1043
1375
|
//#endregion
|
|
1044
1376
|
//#region src/commands/agents.ts
|
|
1045
1377
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -1067,7 +1399,7 @@ async function resolveAgent(client, selector) {
|
|
|
1067
1399
|
if (matches.length === 0) throw new Error(`No agent named "${selector}". Pass an id, or run \`skydive agents list\`.`);
|
|
1068
1400
|
throw new Error(`Multiple agents named "${selector}". Pass the id instead:\n${matches.map((a) => ` ${a.name} ${a.id}`).join("\n")}`);
|
|
1069
1401
|
}
|
|
1070
|
-
const listCommand$
|
|
1402
|
+
const listCommand$7 = {
|
|
1071
1403
|
command: "list",
|
|
1072
1404
|
describe: "List agents in the active workspace",
|
|
1073
1405
|
builder: (y) => y.option("limit", {
|
|
@@ -1288,10 +1620,76 @@ const aliasCommand = {
|
|
|
1288
1620
|
console.log(aliasActivationHint(result));
|
|
1289
1621
|
}
|
|
1290
1622
|
};
|
|
1623
|
+
const avatarSetCommand = {
|
|
1624
|
+
command: "set <agent>",
|
|
1625
|
+
describe: "Set an agent's avatar photo (PNG, JPEG, or WebP, max 5 MB)",
|
|
1626
|
+
builder: (y) => y.positional("agent", {
|
|
1627
|
+
type: "string",
|
|
1628
|
+
demandOption: true,
|
|
1629
|
+
describe: "Agent id or name to set the avatar on"
|
|
1630
|
+
}).option("file", {
|
|
1631
|
+
type: "string",
|
|
1632
|
+
demandOption: true,
|
|
1633
|
+
describe: "Path to the image file to upload"
|
|
1634
|
+
}).example("skydive agents avatar set Ripple --file avatar.png", "upload a photo"),
|
|
1635
|
+
handler: async (argv) => {
|
|
1636
|
+
const client = requireManagementClient(argv);
|
|
1637
|
+
const agent = await resolveAgent(client, argv.agent);
|
|
1638
|
+
const result = await client.setAgentAvatar({
|
|
1639
|
+
agentId: agent.id,
|
|
1640
|
+
filePath: argv.file
|
|
1641
|
+
});
|
|
1642
|
+
if (result.isErr()) {
|
|
1643
|
+
printError(result.error.message);
|
|
1644
|
+
process.exit(1);
|
|
1645
|
+
}
|
|
1646
|
+
if (argv.json) {
|
|
1647
|
+
output(argv, {
|
|
1648
|
+
agent: agent.id,
|
|
1649
|
+
avatarUrl: result.value.avatarUrl
|
|
1650
|
+
});
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
if (argv.quiet) {
|
|
1654
|
+
console.log(result.value.avatarUrl);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
console.log(`Avatar set for ${agent.name}.`);
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
const avatarRemoveCommand = {
|
|
1661
|
+
command: "remove <agent>",
|
|
1662
|
+
describe: "Remove an agent's uploaded avatar (the generated preset takes over)",
|
|
1663
|
+
builder: (y) => y.positional("agent", {
|
|
1664
|
+
type: "string",
|
|
1665
|
+
demandOption: true,
|
|
1666
|
+
describe: "Agent id or name to remove the avatar from"
|
|
1667
|
+
}),
|
|
1668
|
+
handler: async (argv) => {
|
|
1669
|
+
const client = requireManagementClient(argv);
|
|
1670
|
+
const agent = await resolveAgent(client, argv.agent);
|
|
1671
|
+
const result = await client.deleteAgentAvatar(agent.id);
|
|
1672
|
+
if (result.isErr()) {
|
|
1673
|
+
printError(result.error.message);
|
|
1674
|
+
process.exit(1);
|
|
1675
|
+
}
|
|
1676
|
+
if (argv.json) {
|
|
1677
|
+
output(argv, { agent: agent.id });
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
console.log(`Avatar removed for ${agent.name}.`);
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
const avatarCommand = {
|
|
1684
|
+
command: "avatar",
|
|
1685
|
+
describe: "Manage an agent's avatar photo",
|
|
1686
|
+
builder: (y) => y.command(avatarSetCommand).command(avatarRemoveCommand).demandCommand(1, "Specify a subcommand: set, remove"),
|
|
1687
|
+
handler: () => {}
|
|
1688
|
+
};
|
|
1291
1689
|
const agentsCommand = {
|
|
1292
1690
|
command: "agents",
|
|
1293
1691
|
describe: "Manage agents",
|
|
1294
|
-
builder: (y) => y.command(listCommand$
|
|
1692
|
+
builder: (y) => y.command(listCommand$7).command(getCommand$2).command(createCommand$1).command(aliasCommand).command(gitCommand).command(avatarCommand).demandCommand(1, "Specify a subcommand: list, get, create, alias, git, avatar"),
|
|
1295
1693
|
handler: () => {}
|
|
1296
1694
|
};
|
|
1297
1695
|
|
|
@@ -1361,7 +1759,7 @@ function isExecutableFile(p) {
|
|
|
1361
1759
|
if (!fs.statSync(p).isFile()) return false;
|
|
1362
1760
|
if (process.platform !== "win32") fs.accessSync(p, fs.constants.X_OK);
|
|
1363
1761
|
return true;
|
|
1364
|
-
} catch {
|
|
1762
|
+
} catch (_error) {
|
|
1365
1763
|
return false;
|
|
1366
1764
|
}
|
|
1367
1765
|
}
|
|
@@ -1586,7 +1984,7 @@ const importCommand = {
|
|
|
1586
1984
|
process.exit(1);
|
|
1587
1985
|
}
|
|
1588
1986
|
}
|
|
1589
|
-
const { runChat } = await import("./boot-
|
|
1987
|
+
const { runChat } = await import("./boot-DryzgwlS.mjs");
|
|
1590
1988
|
await runChat({
|
|
1591
1989
|
appUrl,
|
|
1592
1990
|
sessionToken: session.value.sessionToken,
|
|
@@ -1599,7 +1997,10 @@ const importCommand = {
|
|
|
1599
1997
|
newConversation: false,
|
|
1600
1998
|
defaultAgentSelector: getDefaultAgent(),
|
|
1601
1999
|
forceOnboarding: false,
|
|
1602
|
-
seedPrompt: buildImportSeedPrompt(
|
|
2000
|
+
seedPrompt: buildImportSeedPrompt({
|
|
2001
|
+
projectDir: process.cwd(),
|
|
2002
|
+
os: machineOsFromPlatform(process.platform)
|
|
2003
|
+
})
|
|
1603
2004
|
});
|
|
1604
2005
|
}
|
|
1605
2006
|
};
|
|
@@ -1616,15 +2017,18 @@ async function runImportPrintMode({ argv, appUrl }) {
|
|
|
1616
2017
|
printError(`${session.error.message} For non-interactive use, run \`skydive auth login --web\` first, or set SKYDIVE_SESSION_TOKEN.`);
|
|
1617
2018
|
process.exit(1);
|
|
1618
2019
|
}
|
|
1619
|
-
const { connectMachineShare } = await import("./print-share-
|
|
2020
|
+
const { connectMachineShare } = await import("./print-share-DkP-BN3f.mjs");
|
|
1620
2021
|
const machineShare = await connectMachineShare({
|
|
1621
2022
|
appUrl,
|
|
1622
2023
|
sessionToken: session.value.sessionToken,
|
|
1623
2024
|
timeoutHint: "Check `skydive portal status`, then re-run."
|
|
1624
2025
|
});
|
|
1625
2026
|
const extra = (argv.print ?? "").trim();
|
|
1626
|
-
const prompt = buildImportSeedPrompt(
|
|
1627
|
-
|
|
2027
|
+
const prompt = buildImportSeedPrompt({
|
|
2028
|
+
projectDir: process.cwd(),
|
|
2029
|
+
os: machineOsFromPlatform(process.platform)
|
|
2030
|
+
}) + (extra ? `\n\nAdditional instructions: ${extra}` : "");
|
|
2031
|
+
const { runPrint } = await import("./print-COum65TR.mjs");
|
|
1628
2032
|
try {
|
|
1629
2033
|
const result = await runPrint({
|
|
1630
2034
|
appUrl,
|
|
@@ -1648,11 +2052,13 @@ async function runImportPrintMode({ argv, appUrl }) {
|
|
|
1648
2052
|
|
|
1649
2053
|
//#endregion
|
|
1650
2054
|
//#region src/commands/keys.ts
|
|
1651
|
-
const listCommand$
|
|
2055
|
+
const listCommand$6 = {
|
|
1652
2056
|
command: "list",
|
|
1653
2057
|
describe: "List API keys for an agent",
|
|
1654
2058
|
handler: async (argv) => {
|
|
1655
|
-
const
|
|
2059
|
+
const client = requireManagementClient(argv);
|
|
2060
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2061
|
+
const result = await client.listKeys(agentId);
|
|
1656
2062
|
if (result.isErr()) {
|
|
1657
2063
|
printError(result.error.message);
|
|
1658
2064
|
process.exit(1);
|
|
@@ -1688,7 +2094,9 @@ const createCommand = {
|
|
|
1688
2094
|
describe: "Key name"
|
|
1689
2095
|
}),
|
|
1690
2096
|
handler: async (argv) => {
|
|
1691
|
-
const
|
|
2097
|
+
const client = requireManagementClient(argv);
|
|
2098
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2099
|
+
const result = await client.createKey(agentId, argv.name);
|
|
1692
2100
|
if (result.isErr()) {
|
|
1693
2101
|
printError(result.error.message);
|
|
1694
2102
|
process.exit(1);
|
|
@@ -1718,7 +2126,9 @@ const revokeCommand$1 = {
|
|
|
1718
2126
|
describe: "Key ID"
|
|
1719
2127
|
}),
|
|
1720
2128
|
handler: async (argv) => {
|
|
1721
|
-
const
|
|
2129
|
+
const client = requireManagementClient(argv);
|
|
2130
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2131
|
+
const result = await client.revokeKey(agentId, argv.id);
|
|
1722
2132
|
if (result.isErr()) {
|
|
1723
2133
|
printError(result.error.message);
|
|
1724
2134
|
process.exit(1);
|
|
@@ -1733,11 +2143,13 @@ const revokeCommand$1 = {
|
|
|
1733
2143
|
const keysCommand = {
|
|
1734
2144
|
command: "keys",
|
|
1735
2145
|
describe: "Manage API keys for an agent",
|
|
1736
|
-
builder: (y) => y.option("agent
|
|
2146
|
+
builder: (y) => y.option("agent", {
|
|
1737
2147
|
type: "string",
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
2148
|
+
describe: "Target agent, by id or name (e.g. --agent my-agent)"
|
|
2149
|
+
}).option("agent-id", {
|
|
2150
|
+
type: "string",
|
|
2151
|
+
describe: "Target agent id (legacy; prefer --agent)"
|
|
2152
|
+
}).command(listCommand$6).command(createCommand).command(revokeCommand$1).demandCommand(1, "Specify a subcommand: list, create, revoke"),
|
|
1741
2153
|
handler: () => {}
|
|
1742
2154
|
};
|
|
1743
2155
|
|
|
@@ -1749,11 +2161,13 @@ async function readStdin() {
|
|
|
1749
2161
|
for await (const chunk of process.stdin) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1750
2162
|
return Buffer.concat(chunks).toString("utf8").replace(/\n$/, "");
|
|
1751
2163
|
}
|
|
1752
|
-
const listCommand$
|
|
2164
|
+
const listCommand$5 = {
|
|
1753
2165
|
command: "list",
|
|
1754
2166
|
describe: "List secret names for an agent (values are never shown)",
|
|
1755
2167
|
handler: async (argv) => {
|
|
1756
|
-
const
|
|
2168
|
+
const client = requireManagementClient(argv);
|
|
2169
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2170
|
+
const result = await client.listSecrets(agentId);
|
|
1757
2171
|
if (result.isErr()) {
|
|
1758
2172
|
printError(result.error.message);
|
|
1759
2173
|
process.exit(1);
|
|
@@ -1794,7 +2208,9 @@ const setCommand$1 = {
|
|
|
1794
2208
|
printError("Empty secret value.");
|
|
1795
2209
|
process.exit(1);
|
|
1796
2210
|
}
|
|
1797
|
-
const
|
|
2211
|
+
const client = requireManagementClient(argv);
|
|
2212
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2213
|
+
const result = await client.setSecret(agentId, argv.key, value);
|
|
1798
2214
|
if (result.isErr()) {
|
|
1799
2215
|
printError(result.error.message);
|
|
1800
2216
|
process.exit(1);
|
|
@@ -1816,7 +2232,9 @@ const rmCommand = {
|
|
|
1816
2232
|
describe: "Secret name"
|
|
1817
2233
|
}),
|
|
1818
2234
|
handler: async (argv) => {
|
|
1819
|
-
const
|
|
2235
|
+
const client = requireManagementClient(argv);
|
|
2236
|
+
const agentId = await resolveTargetAgentId(client, argv.agent ?? argv["agent-id"]);
|
|
2237
|
+
const result = await client.deleteSecret(agentId, argv.key);
|
|
1820
2238
|
if (result.isErr()) {
|
|
1821
2239
|
printError(result.error.message);
|
|
1822
2240
|
process.exit(1);
|
|
@@ -1831,11 +2249,13 @@ const rmCommand = {
|
|
|
1831
2249
|
const secretsCommand = {
|
|
1832
2250
|
command: "secrets",
|
|
1833
2251
|
describe: "Manage an agent’s secrets",
|
|
1834
|
-
builder: (y) => y.option("agent
|
|
2252
|
+
builder: (y) => y.option("agent", {
|
|
1835
2253
|
type: "string",
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
2254
|
+
describe: "Target agent, by id or name (e.g. --agent my-agent)"
|
|
2255
|
+
}).option("agent-id", {
|
|
2256
|
+
type: "string",
|
|
2257
|
+
describe: "Target agent id (legacy; prefer --agent)"
|
|
2258
|
+
}).command(listCommand$5).command(setCommand$1).command(rmCommand).demandCommand(1, "Specify a subcommand: list, set, rm"),
|
|
1839
2259
|
handler: () => {}
|
|
1840
2260
|
};
|
|
1841
2261
|
|
|
@@ -2031,7 +2451,7 @@ const chatCommand = {
|
|
|
2031
2451
|
sessionToken: auth.value.token,
|
|
2032
2452
|
agentSelector: argv.agent ?? null
|
|
2033
2453
|
});
|
|
2034
|
-
const { runChat } = await import("./boot-
|
|
2454
|
+
const { runChat } = await import("./boot-DryzgwlS.mjs");
|
|
2035
2455
|
await runChat({
|
|
2036
2456
|
appUrl: auth.value.appUrl,
|
|
2037
2457
|
sessionToken: auth.value.token,
|
|
@@ -2115,7 +2535,7 @@ async function runPrintMode({ argv, appUrl }) {
|
|
|
2115
2535
|
printError(`${auth.error.message} For non-interactive use, run \`skydive auth login\` first, or set SKYDIVE_API_KEY / SKYDIVE_SESSION_TOKEN.`);
|
|
2116
2536
|
process.exit(1);
|
|
2117
2537
|
}
|
|
2118
|
-
const { runPrint, readStdin } = await import("./print-
|
|
2538
|
+
const { runPrint, readStdin } = await import("./print-COum65TR.mjs");
|
|
2119
2539
|
const workspaceId = await resolveWorkspaceFlag({
|
|
2120
2540
|
appUrl,
|
|
2121
2541
|
sessionToken: auth.value.token,
|
|
@@ -2145,7 +2565,7 @@ async function runPrintMode({ argv, appUrl }) {
|
|
|
2145
2565
|
process.exit(1);
|
|
2146
2566
|
}
|
|
2147
2567
|
} else {
|
|
2148
|
-
const { connectMachineShare } = await import("./print-share-
|
|
2568
|
+
const { connectMachineShare } = await import("./print-share-DkP-BN3f.mjs");
|
|
2149
2569
|
machineShare = await connectMachineShare({
|
|
2150
2570
|
appUrl: auth.value.appUrl,
|
|
2151
2571
|
sessionToken: auth.value.token,
|
|
@@ -2210,7 +2630,7 @@ const getCommand$1 = {
|
|
|
2210
2630
|
printError(`${auth.error.message} Run \`skydive auth login\` first, or set SKYDIVE_API_KEY / SKYDIVE_SESSION_TOKEN.`);
|
|
2211
2631
|
process.exit(1);
|
|
2212
2632
|
}
|
|
2213
|
-
const { messageGet } = await import("./print-
|
|
2633
|
+
const { messageGet } = await import("./print-COum65TR.mjs");
|
|
2214
2634
|
try {
|
|
2215
2635
|
const result = await messageGet({
|
|
2216
2636
|
appUrl: auth.value.appUrl,
|
|
@@ -2257,7 +2677,7 @@ function messageToText(message) {
|
|
|
2257
2677
|
}
|
|
2258
2678
|
return chunks.join("\n").trim();
|
|
2259
2679
|
}
|
|
2260
|
-
const listCommand$
|
|
2680
|
+
const listCommand$4 = {
|
|
2261
2681
|
command: "list",
|
|
2262
2682
|
describe: "List an agent's conversations",
|
|
2263
2683
|
builder: (y) => y.option("agent", {
|
|
@@ -2347,7 +2767,7 @@ const conversationsCommand = {
|
|
|
2347
2767
|
command: "conversations",
|
|
2348
2768
|
aliases: ["conv"],
|
|
2349
2769
|
describe: "List and read agent conversations",
|
|
2350
|
-
builder: (y) => y.command(listCommand$
|
|
2770
|
+
builder: (y) => y.command(listCommand$4).command(showCommand).demandCommand(1, "Specify a subcommand: list, show"),
|
|
2351
2771
|
handler: () => {}
|
|
2352
2772
|
};
|
|
2353
2773
|
|
|
@@ -2389,7 +2809,7 @@ async function runList(argv, { hint }) {
|
|
|
2389
2809
|
]));
|
|
2390
2810
|
if (hint && !argv.quiet) console.log("\nRun `skydive workspace switch` to pick a workspace, or pass its slug directly.");
|
|
2391
2811
|
}
|
|
2392
|
-
const listCommand$
|
|
2812
|
+
const listCommand$3 = {
|
|
2393
2813
|
command: "list",
|
|
2394
2814
|
describe: "List workspaces on your account",
|
|
2395
2815
|
handler: (argv) => runList(argv, { hint: false })
|
|
@@ -2413,7 +2833,7 @@ const switchCommand = {
|
|
|
2413
2833
|
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.");
|
|
2414
2834
|
process.exit(1);
|
|
2415
2835
|
}
|
|
2416
|
-
const { runWorkspacePicker } = await import("./boot-
|
|
2836
|
+
const { runWorkspacePicker } = await import("./boot-DryzgwlS.mjs");
|
|
2417
2837
|
await runWorkspacePicker(session);
|
|
2418
2838
|
return;
|
|
2419
2839
|
}
|
|
@@ -2446,7 +2866,7 @@ const switchCommand = {
|
|
|
2446
2866
|
const workspaceCommand = {
|
|
2447
2867
|
command: "workspace",
|
|
2448
2868
|
describe: "List or switch the workspace all `skydive` commands act on",
|
|
2449
|
-
builder: (y) => y.command(listCommand$
|
|
2869
|
+
builder: (y) => y.command(listCommand$3).command(switchCommand),
|
|
2450
2870
|
handler: (argv) => runList(argv, { hint: true })
|
|
2451
2871
|
};
|
|
2452
2872
|
|
|
@@ -2492,7 +2912,7 @@ const openCommand = {
|
|
|
2492
2912
|
const agent = argv.agent ? resolveAgent$1((await fetchPortalDevices(session)).agents, argv.agent) : null;
|
|
2493
2913
|
const cwd = argv.cwd ? path.resolve(argv.cwd) : process.cwd();
|
|
2494
2914
|
const { machineName } = await resolveMachineIdentity(null);
|
|
2495
|
-
const { PortalDaemonClient } = await import("./daemon-client-
|
|
2915
|
+
const { PortalDaemonClient } = await import("./daemon-client-Wq3InJ9R.mjs");
|
|
2496
2916
|
let lastLine = "";
|
|
2497
2917
|
let signalConnected;
|
|
2498
2918
|
const connected = new Promise((resolve) => {
|
|
@@ -2846,11 +3266,14 @@ const sandboxCommand = {
|
|
|
2846
3266
|
type: "string",
|
|
2847
3267
|
array: true,
|
|
2848
3268
|
describe: "Command to run one-shot (streams output, exits with its exit code). Omit for a live interactive terminal. Put it after `--` if it has flags of its own."
|
|
3269
|
+
}).option("timeout", {
|
|
3270
|
+
type: "number",
|
|
3271
|
+
describe: `One-shot commands: kill the command after this many seconds. Without it the server default (~${Math.round(DEFAULT_EXEC_TIMEOUT_MS / 6e4)} min) applies.`
|
|
2849
3272
|
}).example("skydive sandbox --agent grace", "Live terminal (Ctrl-] detaches)").example("skydive sandbox --agent grace -- tail -n 50 /tmp/harness.log", "One-shot command (use `--` so its flags reach the sandbox)").example("skydive sandbox --agent grace -- sh -c 'ls /tmp | wc -l'", "Shell features go through an explicit `sh -c`"),
|
|
2850
3273
|
handler: async (argv) => {
|
|
2851
3274
|
const session = requireSession(argv);
|
|
2852
|
-
const { createRestClient } = await import("./rest-
|
|
2853
|
-
const { resolveAgent } = await import("./print-
|
|
3275
|
+
const { createRestClient } = await import("./rest-CF9IwcFW.mjs");
|
|
3276
|
+
const { resolveAgent } = await import("./print-COum65TR.mjs");
|
|
2854
3277
|
const client = createRestClient({
|
|
2855
3278
|
appUrl: session.appUrl,
|
|
2856
3279
|
sessionToken: session.sessionToken
|
|
@@ -2866,10 +3289,20 @@ const sandboxCommand = {
|
|
|
2866
3289
|
process.exit(1);
|
|
2867
3290
|
}
|
|
2868
3291
|
const command = joinCommandWords([...argv.command ?? [], ...argv["--"] ?? []]);
|
|
3292
|
+
if (argv.timeout !== void 0 && !command) {
|
|
3293
|
+
printError("--timeout applies to a one-shot command; pass one after `--`.");
|
|
3294
|
+
process.exit(1);
|
|
3295
|
+
}
|
|
3296
|
+
if (argv.timeout !== void 0 && (!Number.isFinite(argv.timeout) || argv.timeout <= 0)) {
|
|
3297
|
+
printError("--timeout must be a positive number of seconds.");
|
|
3298
|
+
process.exit(1);
|
|
3299
|
+
}
|
|
3300
|
+
const timeoutMs = argv.timeout !== void 0 ? Math.round(argv.timeout * 1e3) : void 0;
|
|
2869
3301
|
const code = command ? await runExec({
|
|
2870
3302
|
session,
|
|
2871
3303
|
agentId: agent.id,
|
|
2872
|
-
command
|
|
3304
|
+
command,
|
|
3305
|
+
timeoutMs
|
|
2873
3306
|
}) : await runPty({
|
|
2874
3307
|
session,
|
|
2875
3308
|
agentId: agent.id,
|
|
@@ -2879,18 +3312,19 @@ const sandboxCommand = {
|
|
|
2879
3312
|
}
|
|
2880
3313
|
};
|
|
2881
3314
|
/** One-shot exec: stream output to stdout, resolve to the command's exit code. */
|
|
2882
|
-
function runExec({ session, agentId, command }) {
|
|
3315
|
+
function runExec({ session, agentId, command, timeoutMs }) {
|
|
2883
3316
|
console.error("Connecting to the sandbox…");
|
|
2884
3317
|
return new Promise((resolve) => {
|
|
2885
3318
|
const finish = (code) => {
|
|
2886
3319
|
process.stdout.write("", () => resolve(code));
|
|
2887
3320
|
};
|
|
2888
|
-
SandboxStream.open({
|
|
3321
|
+
const stream = SandboxStream.open({
|
|
2889
3322
|
mode: "exec",
|
|
2890
3323
|
appUrl: session.appUrl,
|
|
2891
3324
|
sessionToken: session.sessionToken,
|
|
2892
3325
|
agentId,
|
|
2893
3326
|
command,
|
|
3327
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
2894
3328
|
onEvent: (e) => {
|
|
2895
3329
|
switch (e.type) {
|
|
2896
3330
|
case "data":
|
|
@@ -2908,10 +3342,45 @@ function runExec({ session, agentId, command }) {
|
|
|
2908
3342
|
finish(1);
|
|
2909
3343
|
break;
|
|
2910
3344
|
}
|
|
3345
|
+
stopStdinForwarding();
|
|
2911
3346
|
}
|
|
2912
3347
|
});
|
|
3348
|
+
forwardStdinToStream({
|
|
3349
|
+
stdin: process.stdin,
|
|
3350
|
+
stream
|
|
3351
|
+
});
|
|
2913
3352
|
});
|
|
2914
3353
|
}
|
|
3354
|
+
const STDIN_EOF_INPUT = new Uint8Array(0);
|
|
3355
|
+
let forwardingStdin = null;
|
|
3356
|
+
/**
|
|
3357
|
+
* Forward the caller's stdin into the sandbox stream as INPUT frames (one per
|
|
3358
|
+
* stdin chunk; an empty payload marks end-of-stdin so the remote command gets
|
|
3359
|
+
* a real EOF — `sh -c 'cat > file'` finishes instead of hanging). Nothing is
|
|
3360
|
+
* forwarded when stdin is already closed (no pipe, nothing piped in), which
|
|
3361
|
+
* keeps the plain scripted case exactly where it was.
|
|
3362
|
+
*/
|
|
3363
|
+
function forwardStdinToStream({ stdin, stream }) {
|
|
3364
|
+
if (stdin.readableEnded || stdin.destroyed) return;
|
|
3365
|
+
const onData = (chunk) => stream.sendInput(new Uint8Array(chunk));
|
|
3366
|
+
const onEnd = () => stream.sendInput(STDIN_EOF_INPUT);
|
|
3367
|
+
forwardingStdin = {
|
|
3368
|
+
stdin,
|
|
3369
|
+
onData,
|
|
3370
|
+
onEnd
|
|
3371
|
+
};
|
|
3372
|
+
stdin.on("data", onData);
|
|
3373
|
+
stdin.once("end", onEnd);
|
|
3374
|
+
stdin.resume();
|
|
3375
|
+
}
|
|
3376
|
+
/** Stop forwarding stdin (on a terminal stream event) without killing reads. */
|
|
3377
|
+
function stopStdinForwarding() {
|
|
3378
|
+
const current = forwardingStdin;
|
|
3379
|
+
if (!current) return;
|
|
3380
|
+
forwardingStdin = null;
|
|
3381
|
+
current.stdin.off("data", current.onData);
|
|
3382
|
+
current.stdin.off("end", current.onEnd);
|
|
3383
|
+
}
|
|
2915
3384
|
/** Live terminal on the caller's real TTY. */
|
|
2916
3385
|
async function runPty({ session, agentId, agentName }) {
|
|
2917
3386
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
@@ -2919,7 +3388,7 @@ async function runPty({ session, agentId, agentName }) {
|
|
|
2919
3388
|
return 1;
|
|
2920
3389
|
}
|
|
2921
3390
|
console.error(`Connecting to ${agentName}'s sandbox… (Ctrl-] detaches)`);
|
|
2922
|
-
const { runRawPtyPassthrough } = await import("./raw-pty-
|
|
3391
|
+
const { runRawPtyPassthrough } = await import("./raw-pty-BJIs_xjQ.mjs");
|
|
2923
3392
|
const result = await runRawPtyPassthrough({
|
|
2924
3393
|
stdin: process.stdin,
|
|
2925
3394
|
stdout: process.stdout,
|
|
@@ -3090,6 +3559,53 @@ function resolveEditor(override, env, platform = process.platform) {
|
|
|
3090
3559
|
};
|
|
3091
3560
|
}
|
|
3092
3561
|
/**
|
|
3562
|
+
* Resolve the target agent and open the multiplexed fs channel to its
|
|
3563
|
+
* sandbox. Shared by every `fs` subcommand. A failed agent listing or a
|
|
3564
|
+
* failed upgrade (expired session, an agent the caller can't edit, or the
|
|
3565
|
+
* `sandbox-fs-enabled` kill switch) exits here before any file work.
|
|
3566
|
+
*/
|
|
3567
|
+
async function openAgentFs(session, agentSelector) {
|
|
3568
|
+
const { createRestClient } = await import("./rest-CF9IwcFW.mjs");
|
|
3569
|
+
const { resolveAgent } = await import("./print-COum65TR.mjs");
|
|
3570
|
+
let agent;
|
|
3571
|
+
try {
|
|
3572
|
+
agent = resolveAgent(await createRestClient({
|
|
3573
|
+
appUrl: session.appUrl,
|
|
3574
|
+
sessionToken: session.sessionToken
|
|
3575
|
+
}).listAgents({
|
|
3576
|
+
scope: "org",
|
|
3577
|
+
onPage: null
|
|
3578
|
+
}), agentSelector);
|
|
3579
|
+
} catch (error) {
|
|
3580
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
3581
|
+
process.exit(1);
|
|
3582
|
+
}
|
|
3583
|
+
let fs;
|
|
3584
|
+
try {
|
|
3585
|
+
fs = await SandboxFsClient.connect({
|
|
3586
|
+
appUrl: session.appUrl,
|
|
3587
|
+
sessionToken: session.sessionToken,
|
|
3588
|
+
agentId: agent.id
|
|
3589
|
+
});
|
|
3590
|
+
} catch (error) {
|
|
3591
|
+
printError(`Could not open the sandbox filesystem channel: ${error instanceof Error ? error.message : String(error)}`);
|
|
3592
|
+
process.exit(1);
|
|
3593
|
+
}
|
|
3594
|
+
return {
|
|
3595
|
+
agent,
|
|
3596
|
+
fs
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* The oversized-file error for `fs put` and `fs cp`. The fs channel's write
|
|
3601
|
+
* op is whole-file only (no offset or append), so the CLI cannot chunk a
|
|
3602
|
+
* file larger than the relay's per-write cap — the web Files tab is the path
|
|
3603
|
+
* for those.
|
|
3604
|
+
*/
|
|
3605
|
+
function oversizeWriteError(label, size) {
|
|
3606
|
+
return `${label} is ${size} bytes, over the ${Math.floor(FS_MAX_BLOB_BYTES / (1024 * 1024))}MB per-write cap of the sandbox filesystem channel. Upload larger files through the Files tab in the web app instead.`;
|
|
3607
|
+
}
|
|
3608
|
+
/**
|
|
3093
3609
|
* `skydive fs edit <path>` — edit a file that lives on the agent's computer
|
|
3094
3610
|
* (its sandbox) with your LOCAL editor. It reads the remote file down over the
|
|
3095
3611
|
* multiplexed `fs` sandbox-stream channel, opens it in `$EDITOR`, and writes
|
|
@@ -3121,33 +3637,7 @@ const fsEditCommand = {
|
|
|
3121
3637
|
handler: async (argv) => {
|
|
3122
3638
|
const session = requireSession(argv);
|
|
3123
3639
|
const remotePath = argv.path;
|
|
3124
|
-
const {
|
|
3125
|
-
const { resolveAgent } = await import("./print-D79MKwnp.mjs");
|
|
3126
|
-
const client = createRestClient({
|
|
3127
|
-
appUrl: session.appUrl,
|
|
3128
|
-
sessionToken: session.sessionToken
|
|
3129
|
-
});
|
|
3130
|
-
let agent;
|
|
3131
|
-
try {
|
|
3132
|
-
agent = resolveAgent(await client.listAgents({
|
|
3133
|
-
scope: "org",
|
|
3134
|
-
onPage: null
|
|
3135
|
-
}), argv.agent ?? null);
|
|
3136
|
-
} catch (error) {
|
|
3137
|
-
printError(error instanceof Error ? error.message : String(error));
|
|
3138
|
-
process.exit(1);
|
|
3139
|
-
}
|
|
3140
|
-
let fs;
|
|
3141
|
-
try {
|
|
3142
|
-
fs = await SandboxFsClient.connect({
|
|
3143
|
-
appUrl: session.appUrl,
|
|
3144
|
-
sessionToken: session.sessionToken,
|
|
3145
|
-
agentId: agent.id
|
|
3146
|
-
});
|
|
3147
|
-
} catch (error) {
|
|
3148
|
-
printError(`Could not open the sandbox filesystem channel: ${error instanceof Error ? error.message : String(error)}`);
|
|
3149
|
-
process.exit(1);
|
|
3150
|
-
}
|
|
3640
|
+
const { agent, fs } = await openAgentFs(session, argv.agent ?? null);
|
|
3151
3641
|
const cleanup = async (dir) => {
|
|
3152
3642
|
await rm(dir, {
|
|
3153
3643
|
recursive: true,
|
|
@@ -3212,21 +3702,157 @@ function openEditor(override, file) {
|
|
|
3212
3702
|
});
|
|
3213
3703
|
}
|
|
3214
3704
|
/**
|
|
3705
|
+
* Upload a local file to a path on the agent's sandbox in one `write` op.
|
|
3706
|
+
* The relay caps a single write's payload at {@link FS_MAX_BLOB_BYTES} and the
|
|
3707
|
+
* write op is whole-file only (no offset/append), so a larger file is
|
|
3708
|
+
* rejected up front with a pointer to the web Files tab rather than a
|
|
3709
|
+
* truncated or partial upload.
|
|
3710
|
+
*/
|
|
3711
|
+
const fsPutCommand = {
|
|
3712
|
+
command: "put <agent> <local-file> <remote-path>",
|
|
3713
|
+
describe: "Copy a file from your machine onto the agent's sandbox",
|
|
3714
|
+
builder: (y) => y.positional("agent", {
|
|
3715
|
+
type: "string",
|
|
3716
|
+
demandOption: true,
|
|
3717
|
+
describe: "Target agent, by id, slug, or name"
|
|
3718
|
+
}).positional("local-file", {
|
|
3719
|
+
type: "string",
|
|
3720
|
+
demandOption: true,
|
|
3721
|
+
describe: "Path of the file on your machine to upload"
|
|
3722
|
+
}).positional("remote-path", {
|
|
3723
|
+
type: "string",
|
|
3724
|
+
demandOption: true,
|
|
3725
|
+
describe: "Absolute or sandbox-relative path to write it to"
|
|
3726
|
+
}).example("skydive fs put grace ./report.pdf /home/user/Downloads/report.pdf", "Upload a local file to the sandbox"),
|
|
3727
|
+
handler: async (argv) => {
|
|
3728
|
+
const { fs } = await openAgentFs(requireSession(argv), argv.agent ?? null);
|
|
3729
|
+
try {
|
|
3730
|
+
const localStat = await stat(argv["local-file"]);
|
|
3731
|
+
if (localStat.isDirectory()) {
|
|
3732
|
+
printError(`${argv["local-file"]} is a directory; fs put copies a single file.`);
|
|
3733
|
+
process.exit(1);
|
|
3734
|
+
}
|
|
3735
|
+
if (localStat.size > FS_MAX_BLOB_BYTES) {
|
|
3736
|
+
printError(oversizeWriteError(argv["local-file"], localStat.size));
|
|
3737
|
+
process.exit(1);
|
|
3738
|
+
}
|
|
3739
|
+
const bytes = await readFile(argv["local-file"]);
|
|
3740
|
+
await fs.write(argv["remote-path"], new Uint8Array(bytes));
|
|
3741
|
+
fs.close();
|
|
3742
|
+
} catch (error) {
|
|
3743
|
+
fs.close();
|
|
3744
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
3745
|
+
process.exit(1);
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
/**
|
|
3750
|
+
* Download a file from the agent's sandbox to a local path. Reads are
|
|
3751
|
+
* range-based, so a file of any size comes down in chunks of
|
|
3752
|
+
* {@link FS_MAX_BLOB_BYTES}; the chunks are concatenated into one local
|
|
3753
|
+
* write. Silent on success so it composes in scripts (exit code carries the
|
|
3754
|
+
* result).
|
|
3755
|
+
*/
|
|
3756
|
+
const fsGetCommand = {
|
|
3757
|
+
command: "get <agent> <remote-path> <local-path>",
|
|
3758
|
+
describe: "Copy a file from the agent's sandbox onto your machine",
|
|
3759
|
+
builder: (y) => y.positional("agent", {
|
|
3760
|
+
type: "string",
|
|
3761
|
+
demandOption: true,
|
|
3762
|
+
describe: "Target agent, by id, slug, or name"
|
|
3763
|
+
}).positional("remote-path", {
|
|
3764
|
+
type: "string",
|
|
3765
|
+
demandOption: true,
|
|
3766
|
+
describe: "Absolute or sandbox-relative path of the file to download"
|
|
3767
|
+
}).positional("local-path", {
|
|
3768
|
+
type: "string",
|
|
3769
|
+
demandOption: true,
|
|
3770
|
+
describe: "Path on your machine to write it to"
|
|
3771
|
+
}).example("skydive fs get grace /home/user/.self/soul.md ./soul.md", "Download a file from the sandbox"),
|
|
3772
|
+
handler: async (argv) => {
|
|
3773
|
+
const { fs } = await openAgentFs(requireSession(argv), argv.agent ?? null);
|
|
3774
|
+
try {
|
|
3775
|
+
const remoteStat = await fs.stat(argv["remote-path"]);
|
|
3776
|
+
if (remoteStat.type === "dir") {
|
|
3777
|
+
printError(`${argv["remote-path"]} is a directory; fs get copies a single file.`);
|
|
3778
|
+
process.exit(1);
|
|
3779
|
+
}
|
|
3780
|
+
const chunks = [];
|
|
3781
|
+
for (let offset = 0; offset < remoteStat.size; offset += FS_MAX_BLOB_BYTES) chunks.push(await fs.read(argv["remote-path"], {
|
|
3782
|
+
offset,
|
|
3783
|
+
length: FS_MAX_BLOB_BYTES
|
|
3784
|
+
}));
|
|
3785
|
+
await writeFile(argv["local-path"], Buffer.concat(chunks));
|
|
3786
|
+
fs.close();
|
|
3787
|
+
} catch (error) {
|
|
3788
|
+
fs.close();
|
|
3789
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
3790
|
+
process.exit(1);
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
};
|
|
3794
|
+
/**
|
|
3795
|
+
* Copy a file from one sandbox path to another, via one read and one write.
|
|
3796
|
+
* Same per-write cap as `fs put`: the write op is whole-file only, so a
|
|
3797
|
+
* source larger than {@link FS_MAX_BLOB_BYTES} is rejected up front.
|
|
3798
|
+
*/
|
|
3799
|
+
const fsCpCommand = {
|
|
3800
|
+
command: "cp <agent> <src> <dst>",
|
|
3801
|
+
describe: "Copy a file to another path inside the agent's sandbox",
|
|
3802
|
+
builder: (y) => y.positional("agent", {
|
|
3803
|
+
type: "string",
|
|
3804
|
+
demandOption: true,
|
|
3805
|
+
describe: "Target agent, by id, slug, or name"
|
|
3806
|
+
}).positional("src", {
|
|
3807
|
+
type: "string",
|
|
3808
|
+
demandOption: true,
|
|
3809
|
+
describe: "Absolute or sandbox-relative path of the file to copy"
|
|
3810
|
+
}).positional("dst", {
|
|
3811
|
+
type: "string",
|
|
3812
|
+
demandOption: true,
|
|
3813
|
+
describe: "Absolute or sandbox-relative path to copy it to"
|
|
3814
|
+
}).example("skydive fs cp grace /tmp/notes.md /home/user/.self/notes.md", "Copy a file within the sandbox"),
|
|
3815
|
+
handler: async (argv) => {
|
|
3816
|
+
const { fs } = await openAgentFs(requireSession(argv), argv.agent ?? null);
|
|
3817
|
+
try {
|
|
3818
|
+
const srcStat = await fs.stat(argv.src);
|
|
3819
|
+
if (srcStat.type === "dir") {
|
|
3820
|
+
printError(`${argv.src} is a directory; fs cp copies a single file.`);
|
|
3821
|
+
process.exit(1);
|
|
3822
|
+
}
|
|
3823
|
+
if (srcStat.size > FS_MAX_BLOB_BYTES) {
|
|
3824
|
+
printError(oversizeWriteError(argv.src, srcStat.size));
|
|
3825
|
+
process.exit(1);
|
|
3826
|
+
}
|
|
3827
|
+
const bytes = await fs.read(argv.src, null);
|
|
3828
|
+
await fs.write(argv.dst, bytes);
|
|
3829
|
+
fs.close();
|
|
3830
|
+
} catch (error) {
|
|
3831
|
+
fs.close();
|
|
3832
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
3833
|
+
process.exit(1);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3837
|
+
/**
|
|
3215
3838
|
* `skydive fs` — work with the files on an agent's computer (its sandbox) from
|
|
3216
3839
|
* your own machine. The namespace for filesystem access:
|
|
3217
3840
|
*
|
|
3218
|
-
* - `fs edit <path>` edit one remote file with your local editor
|
|
3841
|
+
* - `fs edit <path>` edit one remote file with your local editor.
|
|
3842
|
+
* - `fs put ...` upload a local file to the sandbox.
|
|
3843
|
+
* - `fs get ...` download a sandbox file to your machine.
|
|
3844
|
+
* - `fs cp ...` copy a file within the sandbox.
|
|
3219
3845
|
* - `fs mount <dir>` mount the whole sandbox filesystem locally (coming in a
|
|
3220
3846
|
* later PR, on the same first-class `fs` relay channel).
|
|
3221
3847
|
*
|
|
3222
3848
|
* Grouping these under one command keeps the file surface discoverable and
|
|
3223
|
-
* leaves room to grow (`fs ls`, `fs cat
|
|
3224
|
-
*
|
|
3849
|
+
* leaves room to grow (`fs ls`, `fs cat`) without adding more top-level
|
|
3850
|
+
* commands.
|
|
3225
3851
|
*/
|
|
3226
3852
|
const fsCommand = {
|
|
3227
3853
|
command: "fs <command>",
|
|
3228
3854
|
describe: "Work with the files on an agent's computer (its sandbox)",
|
|
3229
|
-
builder: (y) => y.command(fsEditCommand).demandCommand(1, "Specify a subcommand: edit"),
|
|
3855
|
+
builder: (y) => y.command(fsEditCommand).command(fsPutCommand).command(fsGetCommand).command(fsCpCommand).demandCommand(1, "Specify a subcommand: edit, put, get, cp"),
|
|
3230
3856
|
handler: () => {}
|
|
3231
3857
|
};
|
|
3232
3858
|
|
|
@@ -3784,7 +4410,8 @@ async function offerPackageManagerUpdate(opts) {
|
|
|
3784
4410
|
function relaunchCli(argv = process.argv) {
|
|
3785
4411
|
try {
|
|
3786
4412
|
const [, script, ...rest] = argv;
|
|
3787
|
-
|
|
4413
|
+
const args = script?.startsWith("/$bunfs/") ? rest : script ? [script, ...rest] : rest;
|
|
4414
|
+
spawn(process.execPath, args, { stdio: "inherit" }).on("exit", (code) => process.exit(code ?? 0));
|
|
3788
4415
|
} catch (_error) {
|
|
3789
4416
|
process.exit(0);
|
|
3790
4417
|
}
|
|
@@ -3953,7 +4580,7 @@ function snapshot(pref) {
|
|
|
3953
4580
|
describe: pref.describe
|
|
3954
4581
|
};
|
|
3955
4582
|
}
|
|
3956
|
-
const listCommand$
|
|
4583
|
+
const listCommand$2 = {
|
|
3957
4584
|
command: "list",
|
|
3958
4585
|
aliases: ["ls"],
|
|
3959
4586
|
describe: "Show every editable preference, its value, and its source",
|
|
@@ -4058,8 +4685,162 @@ const pathCommand$1 = {
|
|
|
4058
4685
|
const configCommand = {
|
|
4059
4686
|
command: "config",
|
|
4060
4687
|
describe: "View and set CLI preferences (safe, hand-editable keys only)",
|
|
4061
|
-
builder: (y) => y.command(listCommand$
|
|
4062
|
-
handler: (argv) => listCommand$
|
|
4688
|
+
builder: (y) => y.command(listCommand$2).command(getCommand).command(setCommand).command(unsetCommand).command(pathCommand$1),
|
|
4689
|
+
handler: (argv) => listCommand$2.handler(argv)
|
|
4690
|
+
};
|
|
4691
|
+
|
|
4692
|
+
//#endregion
|
|
4693
|
+
//#region src/commands/proxy.ts
|
|
4694
|
+
/**
|
|
4695
|
+
* `skydive proxy skip-list` — manage the sandbox egress proxy's custom skip
|
|
4696
|
+
* list. The agent-visible verbs are `skip-list add <host…>` / `skip-list
|
|
4697
|
+
* remove <host…>`; a bare `skip-list` lists what is currently skipped.
|
|
4698
|
+
*
|
|
4699
|
+
* Skipped hosts leave the sandbox RAW: the mitmproxy addon forwards them
|
|
4700
|
+
* without rewriting through the transparent proxy, which means NO platform
|
|
4701
|
+
* credential injection (that's the point — a user's own API keys go straight
|
|
4702
|
+
* to the provider), but also no agent rules, no content policy, no billing
|
|
4703
|
+
* gate, and no platform-side record of the egress.
|
|
4704
|
+
*
|
|
4705
|
+
* Config is agent-scoped runtime state: it lives in the in-sandbox daemon's
|
|
4706
|
+
* env and survives daemon restarts and pause/resume, but resets on a fresh
|
|
4707
|
+
* box (a new sandbox cold-create starts with the addon's built-in defaults
|
|
4708
|
+
* only). Platform control-plane hosts can never be skipped.
|
|
4709
|
+
*
|
|
4710
|
+
* Loopback-only daemon routes: this command only works INSIDE a sandbox
|
|
4711
|
+
* (where the egress proxy actually runs).
|
|
4712
|
+
*/
|
|
4713
|
+
const DAEMON_BASE_URL = process.env["SKYDIVE_DAEMON_URL"] ?? "http://localhost:38994";
|
|
4714
|
+
async function daemonFetch(path, init) {
|
|
4715
|
+
try {
|
|
4716
|
+
const res = await fetch(`${DAEMON_BASE_URL}${path}`, {
|
|
4717
|
+
...init,
|
|
4718
|
+
headers: {
|
|
4719
|
+
"Content-Type": "application/json",
|
|
4720
|
+
...init?.headers
|
|
4721
|
+
}
|
|
4722
|
+
});
|
|
4723
|
+
const parsed = z.object({
|
|
4724
|
+
hosts: z.array(z.string()).optional(),
|
|
4725
|
+
error: z.string().optional()
|
|
4726
|
+
}).safeParse(await res.json().catch((_error) => ({})));
|
|
4727
|
+
const body = parsed.success ? parsed.data : {};
|
|
4728
|
+
return {
|
|
4729
|
+
status: res.status,
|
|
4730
|
+
body
|
|
4731
|
+
};
|
|
4732
|
+
} catch (err) {
|
|
4733
|
+
return {
|
|
4734
|
+
status: 0,
|
|
4735
|
+
body: { error: `Could not reach the sandbox daemon at ${DAEMON_BASE_URL}. This command only works inside a sandbox. (${err instanceof Error ? err.message : String(err)})` }
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
function printHosts(argv, hosts) {
|
|
4740
|
+
if (argv.json) {
|
|
4741
|
+
output(argv, { hosts });
|
|
4742
|
+
return;
|
|
4743
|
+
}
|
|
4744
|
+
if (hosts.length === 0) {
|
|
4745
|
+
console.log("No custom skip hosts. (Platform defaults still apply.)");
|
|
4746
|
+
return;
|
|
4747
|
+
}
|
|
4748
|
+
printTable(["Host"], hosts.map((h) => [h]));
|
|
4749
|
+
}
|
|
4750
|
+
const listCommand$1 = {
|
|
4751
|
+
command: "list",
|
|
4752
|
+
aliases: ["ls"],
|
|
4753
|
+
describe: "Show the custom proxy skip hosts (same as bare `skip-list`)",
|
|
4754
|
+
handler: async (argv) => {
|
|
4755
|
+
const { status, body } = await daemonFetch("/v1/proxy/skip-list", null);
|
|
4756
|
+
if (status !== 200) {
|
|
4757
|
+
printError(body.error ?? `daemon /v1/proxy/skip-list: ${status}`);
|
|
4758
|
+
process.exit(1);
|
|
4759
|
+
}
|
|
4760
|
+
printHosts(argv, body.hosts ?? []);
|
|
4761
|
+
}
|
|
4762
|
+
};
|
|
4763
|
+
const addCommand = {
|
|
4764
|
+
command: "add <hosts..>",
|
|
4765
|
+
describe: "Skip the proxy for exact host(s). Their traffic leaves the sandbox RAW: no platform credential injection, no agent rules, no billing gate.",
|
|
4766
|
+
builder: (y) => y.positional("hosts", {
|
|
4767
|
+
type: "string",
|
|
4768
|
+
array: true,
|
|
4769
|
+
demandOption: true,
|
|
4770
|
+
describe: "One or more exact hostnames (api.example.com), no wildcards"
|
|
4771
|
+
}),
|
|
4772
|
+
handler: async (argv) => {
|
|
4773
|
+
for (const host of argv.hosts) {
|
|
4774
|
+
const { status, body } = await daemonFetch("/v1/proxy/skip-list/add", {
|
|
4775
|
+
method: "POST",
|
|
4776
|
+
body: JSON.stringify({ host })
|
|
4777
|
+
});
|
|
4778
|
+
if (status === 0) {
|
|
4779
|
+
printError(body.error ?? `daemon unreachable (host ${host})`);
|
|
4780
|
+
process.exitCode = 1;
|
|
4781
|
+
continue;
|
|
4782
|
+
}
|
|
4783
|
+
if (status !== 200) {
|
|
4784
|
+
printError(`${host}: ${body.error ?? status}`);
|
|
4785
|
+
process.exitCode = 1;
|
|
4786
|
+
continue;
|
|
4787
|
+
}
|
|
4788
|
+
if (argv.json) output(argv, {
|
|
4789
|
+
host,
|
|
4790
|
+
hosts: body.hosts ?? []
|
|
4791
|
+
});
|
|
4792
|
+
else console.log(`${host} is now skipped: requests to it leave the sandbox raw (no platform credential injection).`);
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
};
|
|
4796
|
+
const removeCommand = {
|
|
4797
|
+
command: "remove <hosts..>",
|
|
4798
|
+
aliases: ["rm"],
|
|
4799
|
+
describe: "Remove host(s) from the custom skip list",
|
|
4800
|
+
builder: (y) => y.positional("hosts", {
|
|
4801
|
+
type: "string",
|
|
4802
|
+
array: true,
|
|
4803
|
+
demandOption: true,
|
|
4804
|
+
describe: "Exact hostnames to remove"
|
|
4805
|
+
}),
|
|
4806
|
+
handler: async (argv) => {
|
|
4807
|
+
for (const host of argv.hosts) {
|
|
4808
|
+
const { status, body } = await daemonFetch("/v1/proxy/skip-list/remove", {
|
|
4809
|
+
method: "POST",
|
|
4810
|
+
body: JSON.stringify({ host })
|
|
4811
|
+
});
|
|
4812
|
+
if (status === 0) {
|
|
4813
|
+
printError(body.error ?? `daemon unreachable (host ${host})`);
|
|
4814
|
+
process.exitCode = 1;
|
|
4815
|
+
continue;
|
|
4816
|
+
}
|
|
4817
|
+
if (status !== 200) {
|
|
4818
|
+
printError(`${host}: ${body.error ?? status}`);
|
|
4819
|
+
process.exitCode = 1;
|
|
4820
|
+
continue;
|
|
4821
|
+
}
|
|
4822
|
+
if (argv.json) output(argv, {
|
|
4823
|
+
host,
|
|
4824
|
+
hosts: body.hosts ?? []
|
|
4825
|
+
});
|
|
4826
|
+
else console.log(`${host} removed from the skip list.`);
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
};
|
|
4830
|
+
/** `skydive proxy skip-list` — no subcommand lists; add/remove mutate. */
|
|
4831
|
+
const skipListCommand = {
|
|
4832
|
+
command: "skip-list [command]",
|
|
4833
|
+
describe: "Manage hosts that bypass the egress proxy",
|
|
4834
|
+
builder: (y) => y.command(listCommand$1).command(addCommand).command(removeCommand).default("command", "list"),
|
|
4835
|
+
handler: async (argv) => {
|
|
4836
|
+
if (argv.command === "list" || argv.command === "ls") await listCommand$1.handler(argv);
|
|
4837
|
+
}
|
|
4838
|
+
};
|
|
4839
|
+
const proxyCommand = {
|
|
4840
|
+
command: "proxy <command>",
|
|
4841
|
+
describe: "Inspect and configure the sandbox egress proxy",
|
|
4842
|
+
builder: (y) => y.command(skipListCommand).demandCommand(1, "Run `skydive proxy skip-list`"),
|
|
4843
|
+
handler: () => {}
|
|
4063
4844
|
};
|
|
4064
4845
|
|
|
4065
4846
|
//#endregion
|
|
@@ -4116,7 +4897,7 @@ async function offerIssueReport(archivePath) {
|
|
|
4116
4897
|
console.log(`File an issue: ${ISSUE_REPOSITORY_URL}`);
|
|
4117
4898
|
return;
|
|
4118
4899
|
}
|
|
4119
|
-
await
|
|
4900
|
+
await openBestEffort({ target: issueUrl(archivePath) });
|
|
4120
4901
|
console.log(`Attach the diagnostics archive: ${archivePath}`);
|
|
4121
4902
|
} finally {
|
|
4122
4903
|
prompt.close();
|
|
@@ -4219,7 +5000,7 @@ function createCli(argv) {
|
|
|
4219
5000
|
type: "string",
|
|
4220
5001
|
global: true,
|
|
4221
5002
|
describe: "Override API base URL"
|
|
4222
|
-
}).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(logsCommand).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) => {
|
|
5003
|
+
}).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(proxyCommand).command(logsCommand).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) => {
|
|
4223
5004
|
printError(err ? err instanceof Error ? err.message : String(err) : msg ?? "Unknown error");
|
|
4224
5005
|
process.exit(1);
|
|
4225
5006
|
});
|
|
@@ -4432,7 +5213,7 @@ function setupUpdateCheck(argv) {
|
|
|
4432
5213
|
|
|
4433
5214
|
//#endregion
|
|
4434
5215
|
//#region src/changelog.generated.ts
|
|
4435
|
-
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### Changed\n\n- `/fork` in the chat TUI now works while the agent is mid-run. It used to refuse with \"finish or cancel the run first\"; now it copies the conversation up to the last completed message and opens the copy, while the agent keeps working on the original — reopen the original to reattach, exactly as after `esc`. This matches the web \"Fork chat\" menu item, which never had the restriction.\n- The two cards pinned above the chat TUI composer — **subagents** and **plan** — can now be minimized to a single header row. Click a card's header (the `▾`/`▸` chevron shows which way it goes), or use `/subagent minimize` and `/plan minimize`; the same again, or `/plan expand`, brings the rows back. Minimized, a card keeps its label and its progress counter (`Subagents 7/10`), so a ten-task fan-out costs one row instead of ten and the rest of the terminal goes back to the transcript. `/plan expand` and `/plan collapse` keep their meaning (unfold and re-fold the completed rows the card windows away); clicking the card's _body_ still does the same, and the hints now say which surface does which.\n- Reopening a conversation whose subagents and plan are all finished now opens both pinned cards minimized to their header row (`▸ ✔ Subagents 4/4`, `▸ Plan 5/5`) instead of spending up to ten rows above the composer on finished work. A card that opens this way pops back open by itself the moment new work goes live in that conversation (a fresh fan-out, a new in-progress step); a card you minimized yourself stays minimized, as before. Work still running when you open the conversation shows its rows, exactly as it did.\n\n- The chat TUI status bar now always shows where the portal stands, instead of only lighting up once everything already worked. It reads `portal off`, `portal connecting`, `portal on` (open on this machine, but this agent has no grant), `portal shared` (green — this agent can run commands here), `portal error`, or `portal unavailable` when you signed in with an API key and no portal is possible. Previously the badge rendered nothing in every one of those states, so \"why can't the agent reach my machine?\" had no answer on screen.\n- One word for that feature across the whole CLI: **portal**. The footer hint is now `ctrl+t portal` / `ctrl+t close portal` (was `local access` / `revoke access`), `/status` reports a `portal` row (was `local access`), and `/share` and `/portal` describe themselves as opening the portal and granting an agent access to your machine. `/portal` used to say \"access your computer\", which collided with `/computer` — that command still means the **agent's** sandbox, and \"computer\" stays reserved for it. `--share-machine` and the `shareMachineDefault` config key are unchanged.\n- `npm i -g skydive-cli` (and yarn/pnpm/bun) now installs a tiny launcher plus one prebuilt, os/cpu-matched binary that carries its own runtime — so on the common platforms `skydive chat` and `skydive import` start instantly and **do not download a Bun runtime on first use**. On any platform without a prebuilt binary (or if the optional dependency is skipped), the CLI automatically falls back to the existing behavior: it runs under your Node and provisions Bun on first `chat`, exactly as before. Nothing about the commands, flags, config, or `SKYDIVE_*` environment variables changes, and `skydive update` still upgrades npm installs via your package manager and standalone-binary installs in place.\n\n### Added\n\n- Files an agent shares into the conversation now show as a saveable row in the chat TUI. When the agent sends you a file (a report, an export, a screenshot), it appears as a `📎` row with the filename and size and a \"click to save\" hint; clicking it downloads the file to your `~/Downloads` (falling back to your home directory) and opens it with your default app, then the row shows where it landed. Clicking a saved row again re-opens it. Previously these files were only reachable in the web app — in the terminal they were invisible.\n- `platform ask` forms now render in the chat TUI. The card lists each question with lettered options (A/B/C/D plus Other); `ctrl+r` opens a full overlay picker (one question at a time, arrows + enter, Other as a typed row — the Claude Code interaction). The answer sends as a normal message. Headless `chat -p` prints the question as an `[action needed]` block instead of dropping it.\n- Every API request now reports this install's version (`x-skydive-cli-version`) so the server can refuse features the installed CLI cannot render — `platform ask` needs the #21411 canary (`0.5.0-beta.43` or newer), not 0.4.0 and not earlier 0.5.0 betas.\n- `/search` (alias `/find`) in the chat TUI — opens the conversation picker with its search field focused, so \"find a conversation\" has a discoverable command instead of being a feature you had to know the bare picker already had. Pass a query inline (`/search billing deep dive`) and the picker opens already narrowed to the matches; bare `/search` opens it ready for you to type. The search runs server-side across conversation titles, message bodies, and participant names, the same search the picker exposes.\n- First run in a workspace with no agents now sets you up automatically: instead of dropping you on an empty agent picker, `skydive` creates your first agent for you (with a suggested name and avatar, mirroring the web onboarding flow) and then offers to have it learn how you already work — reading the other coding agents set up on your machine (Claude Code, Cursor, Codex, and more), the same import that `skydive import` runs, with a plan shown first and credentials never copied. Decline and you go straight into the new agent's chat. You can replay this flow anytime with `skydive --onboarding` (or `SKYDIVE_FORCE_ONBOARDING=1`), even in a workspace that already has agents.\n- `/computer` in the chat TUI — a snapshot of the agent's sandbox drawn as colored bar graphs: CPU, memory, and disk usage. Bars turn amber past 75%% and red past 90%% so a glance tells you whether the box is under pressure. The numbers come from the Skydive API (the same live resource sample the web computer view reads), not by connecting to the sandbox — so the card shows instantly, never waking or hanging on a box that isn't running: when the agent has no live sandbox it simply reads \"no sandbox running\". The card keeps itself current quietly (a slow background refresh, no flicker or \"updating\" chrome); only the most recent card refreshes, and it silently stops while you're scrolled up (no wasted polls on a card you're not looking at) and resumes at the bottom.\n- `/computer restart` in the chat TUI — reboot the agent's sandbox from chat. It asks a `y`/`n` confirm first (the restart stops whatever run is going and brings up a fresh box), then enqueues the same restart the web \"Restart\" control does. Available to anyone with edit access to the agent; view-only members are told they can't.\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";
|
|
5216
|
+
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 put`, `fs get`, and `fs cp` — move files between your machine and an agent's sandbox without opening the chat TUI or the web app. `fs put [agent] <local-file> <remote-path>` uploads a file, `fs get [agent] <remote-path> <local-path>` downloads one, and `fs cp [agent] <src> <dst>` copies a file to another path inside the sandbox. They ride the same first-class `fs` relay channel as `fs edit` (same EDIT-permission and kill-switch gating); downloads stream in 8MB ranges so large files come down fine, while uploads and in-sandbox copies are capped at the relay's 8MB per-write limit — a bigger file is rejected up front with a pointer to the web Files tab. Silent on success so they compose in scripts; exit code carries the result.\n\n### Changed\n\n- `skydive secrets` and `skydive keys` now accept `--agent <id or name>` (the same flag every other agent-targeting command uses), resolving the name against your agent roster. They used to take only a raw `--agent-id`, so passing the name every other command accepts 404'd \"agent not found\" for a perfectly real agent; `--agent-id` still works.\n\n- `/fork` in the chat TUI now works while the agent is mid-run. It used to refuse with \"finish or cancel the run first\"; now it copies the conversation up to the last completed message and opens the copy, while the agent keeps working on the original — reopen the original to reattach, exactly as after `esc`. This matches the web \"Fork chat\" menu item, which never had the restriction.\n- The two cards pinned above the chat TUI composer — **subagents** and **plan** — can now be minimized to a single header row. Click a card's header (the `▾`/`▸` chevron shows which way it goes), or use `/subagent minimize` and `/plan minimize`; the same again, or `/plan expand`, brings the rows back. Minimized, a card keeps its label and its progress counter (`Subagents 7/10`), so a ten-task fan-out costs one row instead of ten and the rest of the terminal goes back to the transcript. `/plan expand` and `/plan collapse` keep their meaning (unfold and re-fold the completed rows the card windows away); clicking the card's _body_ still does the same, and the hints now say which surface does which.\n- Reopening a conversation whose subagents and plan are all finished now opens both pinned cards minimized to their header row (`▸ ✔ Subagents 4/4`, `▸ Plan 5/5`) instead of spending up to ten rows above the composer on finished work. A card that opens this way pops back open by itself the moment new work goes live in that conversation (a fresh fan-out, a new in-progress step); a card you minimized yourself stays minimized, as before. Work still running when you open the conversation shows its rows, exactly as it did.\n\n- The chat TUI status bar now always shows where the portal stands, instead of only lighting up once everything already worked. It reads `portal off`, `portal connecting`, `portal on` (open on this machine, but this agent has no grant), `portal shared` (green — this agent can run commands here), `portal error`, or `portal unavailable` when you signed in with an API key and no portal is possible. Previously the badge rendered nothing in every one of those states, so \"why can't the agent reach my machine?\" had no answer on screen.\n- One word for that feature across the whole CLI: **portal**. The footer hint is now `ctrl+t portal` / `ctrl+t close portal` (was `local access` / `revoke access`), `/status` reports a `portal` row (was `local access`), and `/share` and `/portal` describe themselves as opening the portal and granting an agent access to your machine. `/portal` used to say \"access your computer\", which collided with `/computer` — that command still means the **agent's** sandbox, and \"computer\" stays reserved for it. `--share-machine` and the `shareMachineDefault` config key are unchanged.\n- `npm i -g skydive-cli` (and yarn/pnpm/bun) now installs a tiny launcher plus one prebuilt, os/cpu-matched binary that carries its own runtime — so on the common platforms `skydive chat` and `skydive import` start instantly and **do not download a Bun runtime on first use**. On any platform without a prebuilt binary (or if the optional dependency is skipped), the CLI automatically falls back to the existing behavior: it runs under your Node and provisions Bun on first `chat`, exactly as before. Nothing about the commands, flags, config, or `SKYDIVE_*` environment variables changes, and `skydive update` still upgrades npm installs via your package manager and standalone-binary installs in place.\n\n### Added\n\n- `skydive agents git token` — create, list, and revoke git-proxy tokens for an agent's repo from your machine. `agents git token create <agent>` prints a read_write token plus the tokenless remote URL (the same routes the web settings page uses); `… git token list <agent>` shows the agent's tokens by id, and `… git token revoke <agent> <token-id>` revokes one. The command's job ends at the credential: it writes nothing to git on your machine, so what to do with the token (credential store, remote URLs) stays with whatever tooling you already pipe credentials through. `auth login` now points at it for laptop git setup.\n- Files an agent shares into the conversation now show as a saveable row in the chat TUI. When the agent sends you a file (a report, an export, a screenshot), it appears as a `📎` row with the filename and size and a \"click to save\" hint; clicking it downloads the file to your `~/Downloads` (falling back to your home directory) and opens it with your default app, then the row shows where it landed. Clicking a saved row again re-opens it. Previously these files were only reachable in the web app — in the terminal they were invisible.\n- `platform ask` forms now render in the chat TUI. The card lists each question with lettered options (A/B/C/D plus Other); `ctrl+r` opens a full overlay picker (one question at a time, arrows + enter, Other as a typed row — the Claude Code interaction). The answer sends as a normal message. Headless `chat -p` prints the question as an `[action needed]` block instead of dropping it.\n- Every API request now reports this install's version (`x-skydive-cli-version`) so the server can refuse features the installed CLI cannot render — `platform ask` needs the #21411 canary (`0.5.0-beta.43` or newer), not 0.4.0 and not earlier 0.5.0 betas.\n- `/search` (alias `/find`) in the chat TUI — opens the conversation picker with its search field focused, so \"find a conversation\" has a discoverable command instead of being a feature you had to know the bare picker already had. Pass a query inline (`/search billing deep dive`) and the picker opens already narrowed to the matches; bare `/search` opens it ready for you to type. The search runs server-side across conversation titles, message bodies, and participant names, the same search the picker exposes.\n- First run in a workspace with no agents now sets you up automatically: instead of dropping you on an empty agent picker, `skydive` creates your first agent for you (with a suggested name and avatar, mirroring the web onboarding flow) and then offers to have it learn how you already work — reading the other coding agents set up on your machine (Claude Code, Cursor, Codex, and more), the same import that `skydive import` runs, with a plan shown first and credentials never copied. Decline and you go straight into the new agent's chat. You can replay this flow anytime with `skydive --onboarding` (or `SKYDIVE_FORCE_ONBOARDING=1`), even in a workspace that already has agents.\n- `/computer` in the chat TUI — a snapshot of the agent's sandbox drawn as colored bar graphs: CPU, memory, and disk usage. Bars turn amber past 75%% and red past 90%% so a glance tells you whether the box is under pressure. The numbers come from the Skydive API (the same live resource sample the web computer view reads), not by connecting to the sandbox — so the card shows instantly, never waking or hanging on a box that isn't running: when the agent has no live sandbox it simply reads \"no sandbox running\". The card keeps itself current quietly (a slow background refresh, no flicker or \"updating\" chrome); only the most recent card refreshes, and it silently stops while you're scrolled up (no wasted polls on a card you're not looking at) and resumes at the bottom.\n- `/computer restart` in the chat TUI — reboot the agent's sandbox from chat. It asks a `y`/`n` confirm first (the restart stops whatever run is going and brings up a fresh box), then enqueues the same restart the web \"Restart\" control does. Available to anyone with edit access to the agent; view-only members are told they can't.\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### Fixed\n\n- The chat TUI's \"finished responding\" notification no longer pings while the agent is visibly still working. It fired once per run, but one task can span several runs: a subagent finishing, a scheduled or agent-to-agent check-in, or an auto-restart retry all start a follow-up run seconds after the previous run settles, so you'd get pinged \"finished\" and open the conversation to find it still running. The ping now waits behind a short grace window - a successor run starting in that window cancels it - and cancelled or superseded runs never ping at all.\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";
|
|
4436
5217
|
|
|
4437
5218
|
//#endregion
|
|
4438
5219
|
//#region src/whats-new.ts
|
|
@@ -4575,7 +5356,7 @@ if (process.argv.includes(UPDATE_WORKER_FLAG)) {
|
|
|
4575
5356
|
process.exit(0);
|
|
4576
5357
|
}
|
|
4577
5358
|
if (process.argv.includes(PORTAL_DAEMON_FLAG)) {
|
|
4578
|
-
const { runPortalDaemon } = await import("./daemon-
|
|
5359
|
+
const { runPortalDaemon } = await import("./daemon-CGWUrptn.mjs");
|
|
4579
5360
|
runPortalDaemon(process.argv);
|
|
4580
5361
|
} else runCli();
|
|
4581
5362
|
function runCli() {
|