skydive-cli 0.4.1-beta.1 → 0.4.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/bin.mjs +20 -19
- package/dist/js/{boot-DPmh-zP7.mjs → boot-B04lv7Lk.mjs} +4 -4
- package/dist/js/client-BsTDaKa2.mjs +4 -0
- package/dist/js/{client-Cf7cvftg.mjs → client-DaZyQfQ-.mjs} +84 -21
- package/dist/js/daemon-BKVPOhzU.mjs +5 -0
- package/dist/js/{daemon-DaUaCMwC.mjs → daemon-DpqP-4tS.mjs} +12 -3
- package/dist/js/{daemon-client-CJxbCLOb.mjs → daemon-client-F7gX12Mp.mjs} +1 -1
- package/dist/js/daemon-client-TQuXEURW.mjs +6 -0
- package/dist/js/{print-share-CT4ltX7u.mjs → print-share-Jgn0lqGr.mjs} +1 -1
- package/dist/js/{profiler-QFAEvYKe.mjs → profiler-iQDVJ3Ho.mjs} +1 -1
- package/package.json +1 -1
- package/dist/js/client-CneLVPei.mjs +0 -4
- package/dist/js/daemon-client-DlblQIR9.mjs +0 -6
- package/dist/js/daemon-imLBqTGg.mjs +0 -5
package/dist/js/bin.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as ensureActiveOrganization, D as setActiveWorkspace, E as listWorkspaces, O as name, T as getSessionIdentity, a as installCrashHandler, k as version, t as maybeStartProfiling, u as brandHelpArt, w as getActiveWorkspaceId, x as themes } from "./profiler-
|
|
2
|
+
import { C as ensureActiveOrganization, D as setActiveWorkspace, E as listWorkspaces, O as name, T as getSessionIdentity, a as installCrashHandler, k as version, t as maybeStartProfiling, u as brandHelpArt, w as getActiveWorkspaceId, x as themes } from "./profiler-iQDVJ3Ho.mjs";
|
|
3
3
|
import { A as getStoredApiKeyWorkspaceName, C as getLastSeenVersion, F as resolveManagementAuth, I as resolveSession, M as resolveAppUrl, N as resolveChatAuth, O as getShareMachineDefault, P as resolveConfig, R as saveConfig, S as getConfigPath, T as getPromptHistoryPath, V as setLastSeenVersion, _ as API_KEY_PREFIX, b as PREFERENCES, g as API_KEY_FAMILY_PREFIX, h as API_KEYS_URL, i as resolveAgent, j as getUpdateCheckDisabled, k as getStoredApiKeyId, v as DEFAULT_API_URL, w as getPreference, x as deleteConfig, z as saveSession } from "./print-CbayCa87.mjs";
|
|
4
4
|
import { n as printError, r as printTable, t as output } from "./output-DYzzdXYV.mjs";
|
|
5
5
|
import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
|
|
6
6
|
import { t as createRestClient } from "./rest-BY2nADw5.mjs";
|
|
7
7
|
import "./billing-blocked-2wju4gC_.mjs";
|
|
8
|
-
import { a as registerPortalDevice, c as
|
|
9
|
-
import {
|
|
8
|
+
import { a as registerPortalDevice, c as resolveMachineIdentity, i as grantPortalAccess, n as fetchPortalDevices, o as revokePortalAccess, r as findThisDevice } from "./client-DaZyQfQ-.mjs";
|
|
9
|
+
import { i as queryDaemonStatus, l as PORTAL_DAEMON_FLAG, n as ensureDaemonRunning, s as stopDaemon, u as daemonPaths } from "./daemon-DpqP-4tS.mjs";
|
|
10
10
|
import { t as SandboxStream } from "./client-Cn2af31H.mjs";
|
|
11
11
|
import { hideBin } from "yargs/helpers";
|
|
12
12
|
import yargs from "yargs";
|
|
@@ -1516,7 +1516,7 @@ const importCommand = {
|
|
|
1516
1516
|
process.exit(1);
|
|
1517
1517
|
}
|
|
1518
1518
|
}
|
|
1519
|
-
const { runChat } = await import("./boot-
|
|
1519
|
+
const { runChat } = await import("./boot-B04lv7Lk.mjs");
|
|
1520
1520
|
await runChat({
|
|
1521
1521
|
appUrl,
|
|
1522
1522
|
sessionToken: session.value.sessionToken,
|
|
@@ -1543,7 +1543,7 @@ async function runImportPrintMode({ argv, appUrl }) {
|
|
|
1543
1543
|
printError(`${session.error.message} For non-interactive use, run \`skydive auth login --web\` first, or set SKYDIVE_SESSION_TOKEN.`);
|
|
1544
1544
|
process.exit(1);
|
|
1545
1545
|
}
|
|
1546
|
-
const { connectMachineShare } = await import("./print-share-
|
|
1546
|
+
const { connectMachineShare } = await import("./print-share-Jgn0lqGr.mjs");
|
|
1547
1547
|
const machineShare = await connectMachineShare({
|
|
1548
1548
|
appUrl,
|
|
1549
1549
|
sessionToken: session.value.sessionToken,
|
|
@@ -1928,7 +1928,7 @@ const chatCommand = {
|
|
|
1928
1928
|
sessionToken: auth.value.token,
|
|
1929
1929
|
agentSelector: argv.agent ?? null
|
|
1930
1930
|
});
|
|
1931
|
-
const { runChat } = await import("./boot-
|
|
1931
|
+
const { runChat } = await import("./boot-B04lv7Lk.mjs");
|
|
1932
1932
|
await runChat({
|
|
1933
1933
|
appUrl: auth.value.appUrl,
|
|
1934
1934
|
sessionToken: auth.value.token,
|
|
@@ -2020,7 +2020,7 @@ async function runPrintMode({ argv, appUrl }) {
|
|
|
2020
2020
|
process.exit(1);
|
|
2021
2021
|
}
|
|
2022
2022
|
} else {
|
|
2023
|
-
const { connectMachineShare } = await import("./print-share-
|
|
2023
|
+
const { connectMachineShare } = await import("./print-share-Jgn0lqGr.mjs");
|
|
2024
2024
|
machineShare = await connectMachineShare({
|
|
2025
2025
|
appUrl: auth.value.appUrl,
|
|
2026
2026
|
sessionToken: auth.value.token,
|
|
@@ -2287,7 +2287,7 @@ const switchCommand = {
|
|
|
2287
2287
|
printError("The workspace picker needs the Bun runtime and it could not be set up automatically. Pass a workspace slug instead, or install Bun and retry.");
|
|
2288
2288
|
process.exit(1);
|
|
2289
2289
|
}
|
|
2290
|
-
const { runWorkspacePicker } = await import("./boot-
|
|
2290
|
+
const { runWorkspacePicker } = await import("./boot-B04lv7Lk.mjs");
|
|
2291
2291
|
await runWorkspacePicker(session);
|
|
2292
2292
|
return;
|
|
2293
2293
|
}
|
|
@@ -2336,11 +2336,12 @@ const workspaceCommand = {
|
|
|
2336
2336
|
*/
|
|
2337
2337
|
async function resolveGrantTarget(argv) {
|
|
2338
2338
|
const session = requireSession(argv);
|
|
2339
|
-
const { devices, agents } = await fetchPortalDevices(session);
|
|
2339
|
+
const [{ devices, agents }, identity] = await Promise.all([fetchPortalDevices(session), resolveMachineIdentity()]);
|
|
2340
2340
|
return {
|
|
2341
2341
|
session,
|
|
2342
2342
|
agent: resolveAgent(agents, argv.agent),
|
|
2343
|
-
device: findThisDevice(devices,
|
|
2343
|
+
device: findThisDevice(devices, identity.machineName),
|
|
2344
|
+
identity
|
|
2344
2345
|
};
|
|
2345
2346
|
}
|
|
2346
2347
|
function agentOption(y) {
|
|
@@ -2364,8 +2365,8 @@ const openCommand = {
|
|
|
2364
2365
|
const session = requireSession(argv);
|
|
2365
2366
|
const agent = argv.agent ? resolveAgent((await fetchPortalDevices(session)).agents, argv.agent) : null;
|
|
2366
2367
|
const cwd = argv.cwd ? path.resolve(argv.cwd) : process.cwd();
|
|
2367
|
-
const { machineName } =
|
|
2368
|
-
const { PortalDaemonClient } = await import("./daemon-client-
|
|
2368
|
+
const { machineName } = await resolveMachineIdentity();
|
|
2369
|
+
const { PortalDaemonClient } = await import("./daemon-client-TQuXEURW.mjs");
|
|
2369
2370
|
let lastLine = "";
|
|
2370
2371
|
let signalConnected;
|
|
2371
2372
|
const connected = new Promise((resolve) => {
|
|
@@ -2406,8 +2407,8 @@ const grantCommand = {
|
|
|
2406
2407
|
describe: "Allow an agent to run commands on this machine (persists until revoked)",
|
|
2407
2408
|
builder: agentOption,
|
|
2408
2409
|
handler: async (argv) => {
|
|
2409
|
-
const { session, agent, device } = await resolveGrantTarget(argv);
|
|
2410
|
-
const { machineName, friendlyName } =
|
|
2410
|
+
const { session, agent, device, identity } = await resolveGrantTarget(argv);
|
|
2411
|
+
const { machineName, friendlyName } = identity;
|
|
2411
2412
|
const deviceId = device ? device.id : (await registerPortalDevice(session, {
|
|
2412
2413
|
machineName,
|
|
2413
2414
|
friendlyName
|
|
@@ -2431,8 +2432,8 @@ const revokeCommand = {
|
|
|
2431
2432
|
describe: "Remove an agent's access to this machine",
|
|
2432
2433
|
builder: agentOption,
|
|
2433
2434
|
handler: async (argv) => {
|
|
2434
|
-
const { session, agent, device } = await resolveGrantTarget(argv);
|
|
2435
|
-
if (!device) throw new Error(`this machine (${
|
|
2435
|
+
const { session, agent, device, identity } = await resolveGrantTarget(argv);
|
|
2436
|
+
if (!device) throw new Error(`this machine (${identity.machineName}) isn't registered with the portal, so there's nothing to revoke.`);
|
|
2436
2437
|
await revokePortalAccess(session, {
|
|
2437
2438
|
deviceId: device.id,
|
|
2438
2439
|
agentId: agent.id
|
|
@@ -2463,7 +2464,7 @@ const statusCommand = {
|
|
|
2463
2464
|
console.log("No machines registered. Run `skydive portal open` to register this one.");
|
|
2464
2465
|
return;
|
|
2465
2466
|
}
|
|
2466
|
-
const { headers, rows } = buildDeviceTable(devices, agents,
|
|
2467
|
+
const { headers, rows } = buildDeviceTable(devices, agents, (await resolveMachineIdentity()).machineName);
|
|
2467
2468
|
printTable(headers, rows);
|
|
2468
2469
|
}
|
|
2469
2470
|
};
|
|
@@ -2471,7 +2472,7 @@ const statusCommand = {
|
|
|
2471
2472
|
* Build the `portal status` table. Grant ids are shown as agent names when the
|
|
2472
2473
|
* org roster resolves them (deleted agents fall back to the raw id), and the
|
|
2473
2474
|
* device this CLI would register as is marked so "which row is me" doesn't
|
|
2474
|
-
* depend on
|
|
2475
|
+
* depend on scanning the table.
|
|
2475
2476
|
*/
|
|
2476
2477
|
function buildDeviceTable(devices, agents, thisMachineName) {
|
|
2477
2478
|
const agentNames = new Map(agents.map((a) => [a.id, a.name]));
|
|
@@ -4168,7 +4169,7 @@ if (process.argv.includes(UPDATE_WORKER_FLAG)) {
|
|
|
4168
4169
|
process.exit(0);
|
|
4169
4170
|
}
|
|
4170
4171
|
if (process.argv.includes(PORTAL_DAEMON_FLAG)) {
|
|
4171
|
-
const { runPortalDaemon } = await import("./daemon-
|
|
4172
|
+
const { runPortalDaemon } = await import("./daemon-BKVPOhzU.mjs");
|
|
4172
4173
|
runPortalDaemon(process.argv);
|
|
4173
4174
|
} else runCli();
|
|
4174
4175
|
function runCli() {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { D as setActiveWorkspace, E as listWorkspaces, S as themesForMode, _ as themeForMode, a as installCrashHandler, b as themeVersion, c as MARK_CELLS, d as DEFAULT_THEME_ID, f as applyTheme, g as theme, h as noColorRequested, i as writeArtifact, l as WORDMARK, m as monoTheme, n as profilingEnabled, o as buildCrashReport, p as findTheme, r as record, s as writeCrashReport, v as themeMode, w as getActiveWorkspaceId, y as themeModeFromColorFgBg } from "./profiler-
|
|
2
|
+
import { D as setActiveWorkspace, E as listWorkspaces, S as themesForMode, _ as themeForMode, a as installCrashHandler, b as themeVersion, c as MARK_CELLS, d as DEFAULT_THEME_ID, f as applyTheme, g as theme, h as noColorRequested, i as writeArtifact, l as WORDMARK, m as monoTheme, n as profilingEnabled, o as buildCrashReport, p as findTheme, r as record, s as writeCrashReport, v as themeMode, w as getActiveWorkspaceId, y as themeModeFromColorFgBg } from "./profiler-iQDVJ3Ho.mjs";
|
|
3
3
|
import { B as saveTheme, D as getSavedTheme, E as getReviewStateDir, L as resolveWebUrl, S as getConfigPath, c as cardActionErrorMessage, d as reconcileMaskedInput, f as resolveConnectUrl, i as resolveAgent, l as parseExternalOauthConnectParams, m as specKeyFor, p as parseConnectCard, s as MASK_CHAR, u as parseOauthConnectParams, v as DEFAULT_API_URL, y as DEFAULT_APP_URL } from "./print-CbayCa87.mjs";
|
|
4
4
|
import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
|
|
5
5
|
import { a as isRecord, i as errorMessage, n as errorDetail, r as sendErrorMessage, t as createRestClient } from "./rest-BY2nADw5.mjs";
|
|
6
6
|
import { i as billingBlockedOutcomeFromSendResponse } from "./billing-blocked-2wju4gC_.mjs";
|
|
7
|
-
import { t as PortalClient } from "./client-
|
|
8
|
-
import "./daemon-
|
|
7
|
+
import { t as PortalClient } from "./client-DaZyQfQ-.mjs";
|
|
8
|
+
import "./daemon-DpqP-4tS.mjs";
|
|
9
9
|
import { t as SandboxStream } from "./client-Cn2af31H.mjs";
|
|
10
|
-
import { t as PortalDaemonClient } from "./daemon-client-
|
|
10
|
+
import { t as PortalDaemonClient } from "./daemon-client-F7gX12Mp.mjs";
|
|
11
11
|
import { t as runRawPtyPassthrough } from "./raw-pty-B6mAroiI.mjs";
|
|
12
12
|
import * as os$1 from "node:os";
|
|
13
13
|
import { homedir, platform, release, tmpdir } from "node:os";
|
|
@@ -2,27 +2,51 @@
|
|
|
2
2
|
import { t as HttpError } from "./http-error-DzyrsLAZ.mjs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { spawn } from "node:child_process";
|
|
5
|
+
import { execFile, spawn } from "node:child_process";
|
|
6
6
|
import { WebSocket } from "ws";
|
|
7
7
|
|
|
8
8
|
//#region ../portal-daemon/src/machine.ts
|
|
9
9
|
/**
|
|
10
|
-
* Identity this machine registers under
|
|
10
|
+
* Identity this machine registers under on the portal.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* One device row per (org, user, machine): the daemon owns the host's single
|
|
13
|
+
* portal connection, and every surface (CLI, TUI, desktop app) shares that
|
|
14
|
+
* row, so a grant applies to the machine no matter which surface the user
|
|
15
|
+
* shared from. The name must therefore match what the desktop app registers —
|
|
16
|
+
* on macOS that is `scutil --get LocalHostName` (the Rust client's own
|
|
17
|
+
* derivation, stabler than the network-assigned hostname), with the plain
|
|
18
|
+
* hostname as the fallback for other platforms or a failed read.
|
|
19
|
+
*
|
|
20
|
+
* Historically the CLI suffixed `-cli` to keep a device distinct from the
|
|
21
|
+
* desktop's; `unifyLegacyCliGrants` migrates grants off those rows.
|
|
18
22
|
*/
|
|
19
|
-
function
|
|
20
|
-
const
|
|
23
|
+
async function resolveMachineIdentity() {
|
|
24
|
+
const fallback = fallbackHost();
|
|
25
|
+
if (process.platform !== "darwin") return {
|
|
26
|
+
machineName: fallback,
|
|
27
|
+
friendlyName: fallback
|
|
28
|
+
};
|
|
29
|
+
const local = await scutilRead("LocalHostName") ?? fallback;
|
|
21
30
|
return {
|
|
22
|
-
machineName:
|
|
23
|
-
friendlyName:
|
|
31
|
+
machineName: local,
|
|
32
|
+
friendlyName: await scutilRead("ComputerName") ?? local
|
|
24
33
|
};
|
|
25
34
|
}
|
|
35
|
+
function fallbackHost() {
|
|
36
|
+
return (os.hostname() || "machine").trim().replace(/\.local$/i, "") || "machine";
|
|
37
|
+
}
|
|
38
|
+
function scutilRead(key) {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
execFile("/usr/sbin/scutil", ["--get", key], { timeout: 2e3 }, (error, stdout) => {
|
|
41
|
+
if (error) {
|
|
42
|
+
resolve(null);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const value = stdout.trim();
|
|
46
|
+
resolve(value.length > 0 ? value : null);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
26
50
|
const INHERITED_ENV = [
|
|
27
51
|
"HOME",
|
|
28
52
|
"USER",
|
|
@@ -340,12 +364,34 @@ async function revokePortalAccess(auth, { deviceId, agentId }) {
|
|
|
340
364
|
}
|
|
341
365
|
/**
|
|
342
366
|
* The device row for a given machine identity. Matching is by `machineName`
|
|
343
|
-
* equality — the stable
|
|
344
|
-
*
|
|
367
|
+
* equality — the stable handle the machine registers under, not the display
|
|
368
|
+
* label.
|
|
345
369
|
*/
|
|
346
370
|
function findThisDevice(devices, machineName) {
|
|
347
371
|
return devices.find((device) => device.machineName === machineName) ?? null;
|
|
348
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* One-time grant migration onto the merged device. Earlier CLI builds
|
|
375
|
+
* registered a separate `<machineName>-cli` device, so a user's existing
|
|
376
|
+
* approvals hang off that row; the merged device would start with zero grants
|
|
377
|
+
* and every already-authorized agent would ask again. Copy any grant the
|
|
378
|
+
* merged device is missing (the grant endpoint upserts, so re-runs are
|
|
379
|
+
* no-ops). The legacy row is left in place — an old CLI build may still
|
|
380
|
+
* connect under it. Returns how many grants were copied.
|
|
381
|
+
*/
|
|
382
|
+
async function unifyLegacyCliGrants(auth, machineName) {
|
|
383
|
+
const { devices } = await fetchPortalDevices(auth);
|
|
384
|
+
const merged = findThisDevice(devices, machineName);
|
|
385
|
+
const legacy = findThisDevice(devices, `${machineName}-cli`);
|
|
386
|
+
if (!merged || !legacy) return 0;
|
|
387
|
+
const have = new Set(merged.grantedAgentIds);
|
|
388
|
+
const missing = legacy.grantedAgentIds.filter((id) => !have.has(id));
|
|
389
|
+
for (const agentId of missing) await grantPortalAccess(auth, {
|
|
390
|
+
deviceId: merged.id,
|
|
391
|
+
agentId
|
|
392
|
+
});
|
|
393
|
+
return missing.length;
|
|
394
|
+
}
|
|
349
395
|
|
|
350
396
|
//#endregion
|
|
351
397
|
//#region ../portal-daemon/src/client.ts
|
|
@@ -370,13 +416,11 @@ var PortalClient = class {
|
|
|
370
416
|
error = null;
|
|
371
417
|
deviceId = null;
|
|
372
418
|
granted = /* @__PURE__ */ new Set();
|
|
373
|
-
machineName;
|
|
374
|
-
friendlyName;
|
|
419
|
+
machineName = "";
|
|
420
|
+
friendlyName = "";
|
|
421
|
+
legacyGrantsChecked = false;
|
|
375
422
|
constructor(opts) {
|
|
376
423
|
this.opts = opts;
|
|
377
|
-
const identity = machineIdentity();
|
|
378
|
-
this.machineName = identity.machineName;
|
|
379
|
-
this.friendlyName = identity.friendlyName;
|
|
380
424
|
}
|
|
381
425
|
isEnabled() {
|
|
382
426
|
return this.enabled;
|
|
@@ -438,6 +482,11 @@ var PortalClient = class {
|
|
|
438
482
|
});
|
|
439
483
|
}
|
|
440
484
|
async connectLoop() {
|
|
485
|
+
if (!this.machineName) {
|
|
486
|
+
const identity = await resolveMachineIdentity();
|
|
487
|
+
this.machineName = identity.machineName;
|
|
488
|
+
this.friendlyName = identity.friendlyName;
|
|
489
|
+
}
|
|
441
490
|
let backoff = INITIAL_BACKOFF_MS;
|
|
442
491
|
while (this.enabled && !this.disposed) {
|
|
443
492
|
this.setStatus("connecting");
|
|
@@ -470,7 +519,7 @@ var PortalClient = class {
|
|
|
470
519
|
this.jobs = jobs;
|
|
471
520
|
ws.on("open", () => {
|
|
472
521
|
this.setStatus("connected");
|
|
473
|
-
this.
|
|
522
|
+
this.syncDeviceState();
|
|
474
523
|
});
|
|
475
524
|
ws.on("message", (data, isBinary) => {
|
|
476
525
|
if (isBinary) jobs.handleFrame(toBuffer(data));
|
|
@@ -505,6 +554,20 @@ var PortalClient = class {
|
|
|
505
554
|
this.emit();
|
|
506
555
|
} catch (_error) {}
|
|
507
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Post-connect device sync: read our row, then (once per process) copy any
|
|
559
|
+
* grants still hanging off the legacy `<host>-cli` device onto this one so
|
|
560
|
+
* agents the user already approved keep their access under the merged
|
|
561
|
+
* identity.
|
|
562
|
+
*/
|
|
563
|
+
async syncDeviceState() {
|
|
564
|
+
await this.refreshDevice();
|
|
565
|
+
if (this.legacyGrantsChecked) return;
|
|
566
|
+
this.legacyGrantsChecked = true;
|
|
567
|
+
try {
|
|
568
|
+
if (await unifyLegacyCliGrants(this.opts, this.machineName) > 0) await this.refreshDevice();
|
|
569
|
+
} catch (_error) {}
|
|
570
|
+
}
|
|
508
571
|
};
|
|
509
572
|
function toBuffer(data) {
|
|
510
573
|
if (Buffer.isBuffer(data)) return data;
|
|
@@ -516,4 +579,4 @@ function sleep(ms) {
|
|
|
516
579
|
}
|
|
517
580
|
|
|
518
581
|
//#endregion
|
|
519
|
-
export { registerPortalDevice as a,
|
|
582
|
+
export { registerPortalDevice as a, resolveMachineIdentity as c, grantPortalAccess as i, fetchPortalDevices as n, revokePortalAccess as o, findThisDevice as r, isRecord as s, PortalClient as t };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "./client-DaZyQfQ-.mjs";
|
|
3
|
+
import { a as runPortalDaemon, i as queryDaemonStatus, n as ensureDaemonRunning, o as startPortalDaemon, r as isDaemonListening, s as stopDaemon, t as PortalDaemon } from "./daemon-DpqP-4tS.mjs";
|
|
4
|
+
|
|
5
|
+
export { runPortalDaemon };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { s as isRecord, t as PortalClient } from "./client-
|
|
2
|
+
import { s as isRecord, t as PortalClient } from "./client-DaZyQfQ-.mjs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -510,7 +510,16 @@ async function ensureDaemonRunning(appUrl) {
|
|
|
510
510
|
function runPortalDaemon(argv) {
|
|
511
511
|
const appUrl = argv[argv.indexOf(PORTAL_DAEMON_FLAG) + 1];
|
|
512
512
|
if (!appUrl) process.exit(1);
|
|
513
|
-
|
|
513
|
+
startPortalDaemon(appUrl).catch(() => process.exit(1));
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Become the portal daemon for `appUrl`: bind the control socket and serve
|
|
517
|
+
* attached clients until idle shutdown. Resolves once listening; rejects if
|
|
518
|
+
* the socket can't be bound (another daemon already holds it). Shared by the
|
|
519
|
+
* CLI's re-exec entry above and the standalone `main.ts` entry.
|
|
520
|
+
*/
|
|
521
|
+
function startPortalDaemon(appUrl) {
|
|
522
|
+
return new PortalDaemon(appUrl).listen();
|
|
514
523
|
}
|
|
515
524
|
async function isDaemonListening(socketPath) {
|
|
516
525
|
if (!await pathExists(socketPath)) return false;
|
|
@@ -621,4 +630,4 @@ function sleep(ms) {
|
|
|
621
630
|
}
|
|
622
631
|
|
|
623
632
|
//#endregion
|
|
624
|
-
export { runPortalDaemon as a,
|
|
633
|
+
export { runPortalDaemon as a, LOCAL_PROTOCOL_VERSION as c, encodeLine as d, makeLineParser as f, queryDaemonStatus as i, PORTAL_DAEMON_FLAG as l, ensureDaemonRunning as n, startPortalDaemon as o, parseDaemonMessage as p, isDaemonListening as r, stopDaemon as s, PortalDaemon as t, daemonPaths as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { c as LOCAL_PROTOCOL_VERSION, d as encodeLine, f as makeLineParser, n as ensureDaemonRunning, p as parseDaemonMessage, u as daemonPaths } from "./daemon-DpqP-4tS.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { connect } from "node:net";
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ import { n as printError } from "./output-DYzzdXYV.mjs";
|
|
|
14
14
|
* the reply (and to --json).
|
|
15
15
|
*/
|
|
16
16
|
async function connectMachineShare({ appUrl, sessionToken, timeoutHint }) {
|
|
17
|
-
const { PortalClient } = await import("./client-
|
|
17
|
+
const { PortalClient } = await import("./client-BsTDaKa2.mjs");
|
|
18
18
|
let signalConnected;
|
|
19
19
|
const connected = new Promise((resolve) => {
|
|
20
20
|
signalConnected = resolve;
|
package/package.json
CHANGED