@mostra/cli 0.9.0 → 0.10.0
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/bin.js +2 -2
- package/dist/bootstrap-BStzS_41.js +1 -0
- package/dist/{bootstrap-Dc-SQHRF.js → bootstrap-_iCl_HaO.js} +3 -2
- package/dist/bootstrap-_iCl_HaO.js.map +1 -0
- package/dist/{flush-C16w3JL8.js → flush-znWmNZA1.js} +11 -3
- package/dist/flush-znWmNZA1.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/reference/cli.md +144 -4
- package/dist/reference/diagnostics.json +90 -0
- package/dist/reference/errors/MOSTRA_ARTIFACT_BUNDLE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_HOME_NETWORK_FILESYSTEM.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_CONFIG_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_LOGIN_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_NOT_OWNER_INSTANCE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_OWNER_OFFLINE.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_QUEUE_FULL.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_RATE_LIMITED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_SIGN_IN_REQUIRED.md +23 -0
- package/dist/reference/errors/MOSTRA_REMOTE_UNREACHABLE.md +23 -0
- package/dist/{run-DdYT3iHQ.js → run-Aq4HVIY0.js} +234 -15
- package/dist/run-Aq4HVIY0.js.map +1 -0
- package/dist/run-D1U_RFEP.js +1 -0
- package/dist/skill/SKILL.md +3 -3
- package/dist/skill/references/answers.md +36 -0
- package/dist/skill/references/mcp.md +3 -3
- package/dist/skill/references/sharing.md +54 -4
- package/dist/telemetry/flush-main.js +1 -1
- package/package.json +5 -5
- package/src/client.ts +1 -1
- package/src/commands/admin.ts +11 -1
- package/src/commands/authoring.ts +85 -3
- package/src/commands/index.ts +16 -3
- package/src/commands/remote.ts +113 -0
- package/src/commands/sharing.ts +33 -6
- package/src/commands/viewing.ts +20 -2
- package/src/detached.ts +2 -0
- package/src/exit.ts +2 -0
- package/src/telemetry/store.ts +15 -4
- package/dist/bootstrap-Dc-SQHRF.js.map +0 -1
- package/dist/bootstrap-aaE5wFo9.js +0 -1
- package/dist/flush-C16w3JL8.js.map +0 -1
- package/dist/run-Bw4_6kcW.js +0 -1
- package/dist/run-DdYT3iHQ.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as GLOBAL_FLAGS, c as parseCommandLine, d as EXIT, f as exitCodeFor, l as topWords, m as defineCommand, o as durationMs, p as commandName, r as progressReporter, s as globalFlags, u as usage } from "./bootstrap-
|
|
2
|
-
import { _ as packageRoot, a as detachedEnvironment, c as durationBucket, d as mcpSessionFields, f as buildEndpoint, g as fromSource, h as cliVersion, i as detachedDirectory, l as minute, m as truthy, n as startFlusher, o as TelemetryEvent, p as decide, r as TelemetryStore, s as catalogCodes, u as detectHarness } from "./flush-
|
|
1
|
+
import { a as GLOBAL_FLAGS, c as parseCommandLine, d as EXIT, f as exitCodeFor, l as topWords, m as defineCommand, o as durationMs, p as commandName, r as progressReporter, s as globalFlags, u as usage } from "./bootstrap-_iCl_HaO.js";
|
|
2
|
+
import { _ as packageRoot, a as detachedEnvironment, c as durationBucket, d as mcpSessionFields, f as buildEndpoint, g as fromSource, h as cliVersion, i as detachedDirectory, l as minute, m as truthy, n as startFlusher, o as TelemetryEvent, p as decide, r as TelemetryStore, s as catalogCodes, u as detectHarness } from "./flush-znWmNZA1.js";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { extname, isAbsolute, join, resolve, win32 } from "node:path";
|
|
6
|
-
import { ARTIFACT_PROGRESS, CLI_CLIENT_NAME, DEFAULT_DOCS_BASE, DEV_NOTIFY, FieldOp, HOST_PROTOCOL_REVISIONS, LineSplitter, MutationId, RpcError, RpcPeer, artifactCreateMethod, artifactGetMethod, artifactListMethod, artifactPublishMethod, artifactVerifyMethod, createDiagnostic, depsAddMethod, devStartMethod, devStopMethod, diagnosticCatalog, encodeLine, gcRunMethod, instanceCheckMethod, instanceStatusMethod, livePushMethod, mostraInitializeMethod, mostraShutdownMethod, resultsGetMethod, secretDeleteMethod, secretListMethod, secretSetMethod, shareListMethod, shareStartMethod, shareStopMethod, stateGetMethod, statePatchMethod, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, waitMethod } from "@mostra/protocol";
|
|
6
|
+
import { ARTIFACT_PROGRESS, CLI_CLIENT_NAME, DEFAULT_DOCS_BASE, DEV_NOTIFY, FieldOp, HOST_PROTOCOL_REVISIONS, LineSplitter, MutationId, RpcError, RpcPeer, artifactCreateMethod, artifactExportMethod, artifactGetMethod, artifactImportMethod, artifactListMethod, artifactPublishMethod, artifactVerifyMethod, createDiagnostic, depsAddMethod, devStartMethod, devStopMethod, diagnosticCatalog, encodeLine, gcRunMethod, instanceCheckMethod, instanceStatusMethod, livePushMethod, mostraInitializeMethod, mostraShutdownMethod, remoteLoginMethod, remoteLoginWaitMethod, remoteLogoutMethod, resultsGetMethod, secretDeleteMethod, secretListMethod, secretSetMethod, shareListMethod, shareStartMethod, shareStopMethod, stateGetMethod, statePatchMethod, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, waitMethod } from "@mostra/protocol";
|
|
7
7
|
import { checkBrowser, checkFiles, connectControl, enclosingBundle, readBundle, readSetup, resolveRuntime } from "@mostra/sdk";
|
|
8
8
|
import { homedir, tmpdir } from "node:os";
|
|
9
9
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
@@ -1561,9 +1561,10 @@ const statusCommand = defineCommand({
|
|
|
1561
1561
|
};
|
|
1562
1562
|
}
|
|
1563
1563
|
const status = await context.call(instanceStatusMethod, {});
|
|
1564
|
+
const links = (status.links ?? []).map((link) => `${link.server} ${link.state}${link.default ? " default" : ""}${link.pendingPushes > 0 ? ` ${link.pendingPushes} pushes waiting` : ""}${link.lastError ? ` (${link.lastError})` : ""}\n`).join("");
|
|
1564
1565
|
return {
|
|
1565
1566
|
result: status,
|
|
1566
|
-
human: pretty(status)
|
|
1567
|
+
human: `${pretty(status)}${links ? `\nRemote servers:\n${links}` : ""}`
|
|
1567
1568
|
};
|
|
1568
1569
|
}
|
|
1569
1570
|
});
|
|
@@ -2191,8 +2192,9 @@ const telemetryOffCommand = defineCommand({
|
|
|
2191
2192
|
//#endregion
|
|
2192
2193
|
//#region src/commands/authoring.ts
|
|
2193
2194
|
/**
|
|
2194
|
-
* Authoring: `new`, `verify`, `publish` and `add`, thin clients of
|
|
2195
|
-
* `artifact/verify`, `artifact/publish`
|
|
2195
|
+
* Authoring: `new`, `verify`, `publish`, `export`, `run` and `add`, thin clients of
|
|
2196
|
+
* `artifact/create`, `artifact/verify`, `artifact/publish`, `artifact/export`, `artifact/import`
|
|
2197
|
+
* and `deps/add` (INTERFACES §6, §15).
|
|
2196
2198
|
*/
|
|
2197
2199
|
/** `mostra new <dir>`. */
|
|
2198
2200
|
const newCommand = defineCommand({
|
|
@@ -2379,6 +2381,90 @@ const publishCommand = defineCommand({
|
|
|
2379
2381
|
};
|
|
2380
2382
|
}
|
|
2381
2383
|
});
|
|
2384
|
+
/** `mostra export <artifact> --as bundle --out <path>`. */
|
|
2385
|
+
const exportCommand = defineCommand({
|
|
2386
|
+
path: ["export"],
|
|
2387
|
+
summary: "Write a published version out of the home, as a portable bundle another home can run.",
|
|
2388
|
+
args: [{
|
|
2389
|
+
name: "artifact",
|
|
2390
|
+
summary: "The artifact: its source path or its ID."
|
|
2391
|
+
}],
|
|
2392
|
+
flags: [
|
|
2393
|
+
{
|
|
2394
|
+
name: "as",
|
|
2395
|
+
kind: "string",
|
|
2396
|
+
value: "<class>",
|
|
2397
|
+
choices: ["bundle"],
|
|
2398
|
+
default: "bundle",
|
|
2399
|
+
summary: "What to write: `bundle`, the version's builds, manifest, lockfile and source."
|
|
2400
|
+
},
|
|
2401
|
+
{
|
|
2402
|
+
name: "out",
|
|
2403
|
+
kind: "string",
|
|
2404
|
+
value: "<path>",
|
|
2405
|
+
summary: "Where: a new directory, or one archive when it ends in .tar.zst."
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
name: "version",
|
|
2409
|
+
kind: "string",
|
|
2410
|
+
value: "<number|id>",
|
|
2411
|
+
summary: "The version. Default: the latest."
|
|
2412
|
+
}
|
|
2413
|
+
],
|
|
2414
|
+
output: {
|
|
2415
|
+
type: "ArtifactExportResult",
|
|
2416
|
+
topic: "cli"
|
|
2417
|
+
},
|
|
2418
|
+
exits: [EXIT.failure],
|
|
2419
|
+
example: "export ./sidebar-review --out ./sidebar-review.tar.zst",
|
|
2420
|
+
async run(context) {
|
|
2421
|
+
const out = flag(context, "out");
|
|
2422
|
+
if (out === void 0) throw usage("\"mostra export\" needs --out <path>.");
|
|
2423
|
+
const version = flag(context, "version");
|
|
2424
|
+
const result = await context.call(artifactExportMethod, {
|
|
2425
|
+
artifact: artifactRef(arg(context, "artifact"), context.cwd),
|
|
2426
|
+
as: "bundle",
|
|
2427
|
+
out: resolve(context.cwd, out),
|
|
2428
|
+
...version !== void 0 ? { version: /^\d+$/.test(version) ? Number(version) : version } : {}
|
|
2429
|
+
});
|
|
2430
|
+
return {
|
|
2431
|
+
result,
|
|
2432
|
+
human: `Exported ${result.versionId} to ${result.files.join(", ")}\n`
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
/** `mostra run <bundle>`. */
|
|
2437
|
+
const runCommand = defineCommand({
|
|
2438
|
+
path: ["run"],
|
|
2439
|
+
summary: "Make a bundle `mostra export` wrote a version of this home, with the same IDs, and print its link.",
|
|
2440
|
+
args: [{
|
|
2441
|
+
name: "bundle",
|
|
2442
|
+
summary: "The bundle: its directory or its .tar.zst archive."
|
|
2443
|
+
}],
|
|
2444
|
+
flags: [{
|
|
2445
|
+
name: "request-id",
|
|
2446
|
+
kind: "string",
|
|
2447
|
+
value: "<id>",
|
|
2448
|
+
summary: "Make a retry return the first attempt's receipt."
|
|
2449
|
+
}],
|
|
2450
|
+
output: {
|
|
2451
|
+
type: "PublishReceipt",
|
|
2452
|
+
topic: "cli"
|
|
2453
|
+
},
|
|
2454
|
+
exits: [EXIT.failure],
|
|
2455
|
+
example: "run ./sidebar-review.tar.zst",
|
|
2456
|
+
async run(context) {
|
|
2457
|
+
const requestId = flag(context, "request-id");
|
|
2458
|
+
const receipt = await context.call(artifactImportMethod, {
|
|
2459
|
+
bundle: resolve(context.cwd, arg(context, "bundle")),
|
|
2460
|
+
...requestId !== void 0 ? { requestId } : {}
|
|
2461
|
+
});
|
|
2462
|
+
return {
|
|
2463
|
+
result: receipt,
|
|
2464
|
+
human: `${receipt.reused ? "Already here" : "Imported"}: version ${receipt.version} (${receipt.versionId}) of ${receipt.artifactId}\n${receipt.url ?? ""}\n`
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2382
2468
|
/** `mostra add <package…>`. */
|
|
2383
2469
|
const addCommand = defineCommand({
|
|
2384
2470
|
path: ["add"],
|
|
@@ -3666,12 +3752,108 @@ const mcpCommand = defineCommand({
|
|
|
3666
3752
|
}
|
|
3667
3753
|
});
|
|
3668
3754
|
//#endregion
|
|
3755
|
+
//#region src/commands/remote.ts
|
|
3756
|
+
/**
|
|
3757
|
+
* `mostra login` and `mostra logout` (INTERFACES §18.7, D165 items 2, 15): this home signs in to a
|
|
3758
|
+
* remote server by the OAuth device authorization grant, so `mostra share --cloud` can host its
|
|
3759
|
+
* artifacts there, and signs out again. The instance keeps the refresh token in the home,
|
|
3760
|
+
* owner-only; signing out keeps its instance link, so the artifacts it shared stay its own at the
|
|
3761
|
+
* next sign-in, unless `--forget`. Clients of `remote/login`, `remote/login.wait` and
|
|
3762
|
+
* `remote/logout`.
|
|
3763
|
+
*/
|
|
3764
|
+
/** How long `mostra login` waits for the person to approve, in all (the code lives 10 minutes). */
|
|
3765
|
+
const LOGIN_WAIT_MS = 6e5;
|
|
3766
|
+
/** Each wait asks the instance for this long, so a slow approval never meets a request timeout. */
|
|
3767
|
+
const LOGIN_STEP_MS = 3e4;
|
|
3768
|
+
/** `mostra login [<server>] [--default]`. */
|
|
3769
|
+
const loginCommand = defineCommand({
|
|
3770
|
+
path: ["login"],
|
|
3771
|
+
summary: "Sign this machine's Mostra in to a remote server, so mostra share --cloud can host pages there.",
|
|
3772
|
+
args: [{
|
|
3773
|
+
name: "server",
|
|
3774
|
+
summary: "The server's address, such as https://api.example.com. Default: the server signed in to last.",
|
|
3775
|
+
optional: true
|
|
3776
|
+
}],
|
|
3777
|
+
flags: [{
|
|
3778
|
+
name: "default",
|
|
3779
|
+
kind: "boolean",
|
|
3780
|
+
summary: "Make this machine the account's default, the one chat apps create pages on. Default: the first machine linked."
|
|
3781
|
+
}],
|
|
3782
|
+
output: {
|
|
3783
|
+
type: "RemoteLoginWaitResult",
|
|
3784
|
+
topic: "cli"
|
|
3785
|
+
},
|
|
3786
|
+
exits: [EXIT.failure, EXIT.environment],
|
|
3787
|
+
example: "login https://api.example.com",
|
|
3788
|
+
async run(context) {
|
|
3789
|
+
const server = context.args["server"];
|
|
3790
|
+
const started = await context.call(remoteLoginMethod, {
|
|
3791
|
+
...typeof server === "string" ? { server: server.replace(/\/+$/, "") } : {},
|
|
3792
|
+
...context.flags["default"] === true ? { default: true } : {}
|
|
3793
|
+
});
|
|
3794
|
+
const where = started.verificationUriComplete ?? started.verificationUri;
|
|
3795
|
+
context.emit({
|
|
3796
|
+
kind: "code",
|
|
3797
|
+
...started
|
|
3798
|
+
}, `Open ${where} and check that it shows the code ${started.userCode}, then approve.\nWaiting for you to approve…`);
|
|
3799
|
+
const deadline = Date.now() + LOGIN_WAIT_MS;
|
|
3800
|
+
for (;;) {
|
|
3801
|
+
const waited = await context.call(remoteLoginWaitMethod, {
|
|
3802
|
+
loginId: started.loginId,
|
|
3803
|
+
timeoutMs: Math.max(0, Math.min(LOGIN_STEP_MS, deadline - Date.now()))
|
|
3804
|
+
});
|
|
3805
|
+
if (waited.status === "signed-in") return {
|
|
3806
|
+
result: waited,
|
|
3807
|
+
human: `Signed in to ${waited.server} as ${waited.account.name ?? waited.account.id}. This machine is ${waited.instanceId}.\n`
|
|
3808
|
+
};
|
|
3809
|
+
if (Date.now() >= deadline) return {
|
|
3810
|
+
result: waited,
|
|
3811
|
+
human: "The code wasn't approved in time. Run mostra login again for a new one.\n",
|
|
3812
|
+
exit: EXIT.timeout
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
});
|
|
3817
|
+
/** `mostra logout [<server>] [--forget]`. */
|
|
3818
|
+
const logoutCommand = defineCommand({
|
|
3819
|
+
path: ["logout"],
|
|
3820
|
+
summary: "Sign this machine's Mostra out of a remote server; its hosted pages keep working, and their answers wait for the next sign-in.",
|
|
3821
|
+
args: [{
|
|
3822
|
+
name: "server",
|
|
3823
|
+
summary: "The server's address. Default: the server signed in to last.",
|
|
3824
|
+
optional: true
|
|
3825
|
+
}],
|
|
3826
|
+
flags: [{
|
|
3827
|
+
name: "forget",
|
|
3828
|
+
kind: "boolean",
|
|
3829
|
+
summary: "Also forget this machine's link to the server: the pages it shared there are no longer its own."
|
|
3830
|
+
}],
|
|
3831
|
+
output: {
|
|
3832
|
+
type: "RemoteLogoutResult",
|
|
3833
|
+
topic: "cli"
|
|
3834
|
+
},
|
|
3835
|
+
exits: [EXIT.failure, EXIT.environment],
|
|
3836
|
+
example: "logout",
|
|
3837
|
+
async run(context) {
|
|
3838
|
+
const server = context.args["server"];
|
|
3839
|
+
const result = await context.call(remoteLogoutMethod, {
|
|
3840
|
+
...typeof server === "string" ? { server: server.replace(/\/+$/, "") } : {},
|
|
3841
|
+
...context.flags["forget"] === true ? { forget: true } : {}
|
|
3842
|
+
});
|
|
3843
|
+
return {
|
|
3844
|
+
result,
|
|
3845
|
+
human: result.servers.length === 0 ? "This machine wasn't signed in to a server.\n" : `Signed out of ${result.servers.join(", ")}.\n`
|
|
3846
|
+
};
|
|
3847
|
+
}
|
|
3848
|
+
});
|
|
3849
|
+
//#endregion
|
|
3669
3850
|
//#region src/commands/sharing.ts
|
|
3670
3851
|
/**
|
|
3671
3852
|
* `mostra share`: an artifact opened to people beyond this machine through a tunnel the daemon
|
|
3672
3853
|
* runs (D47, D158): `--tailnet` (Tailscale Serve, inside your tailnet, with each person's
|
|
3673
3854
|
* identity) or `--public` (a Cloudflare quick tunnel by default, or Tailscale Funnel with `--via
|
|
3674
|
-
* funnel`), whose link expires (1 hour by default, 7 days at most)
|
|
3855
|
+
* funnel`), whose link expires (1 hour by default, 7 days at most); or `--cloud` (D165 item 15),
|
|
3856
|
+
* hosted on a remote server this home signed in to, so the link works while this machine sleeps. The share lives in the
|
|
3675
3857
|
* daemon, so the command returns at once with the link; `share stop` ends it and `share list`
|
|
3676
3858
|
* shows what is shared. A client of `share/start`, `share/stop` and `share/list`.
|
|
3677
3859
|
*/
|
|
@@ -3680,7 +3862,8 @@ const SHARE_ID = /^shr_[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
|
3680
3862
|
const THROUGH = {
|
|
3681
3863
|
tailnet: "Tailscale Serve, inside your tailnet",
|
|
3682
3864
|
funnel: "Tailscale Funnel, public",
|
|
3683
|
-
cloudflare: "a Cloudflare quick tunnel, public"
|
|
3865
|
+
cloudflare: "a Cloudflare quick tunnel, public",
|
|
3866
|
+
remote: "a remote server, hosted"
|
|
3684
3867
|
};
|
|
3685
3868
|
/**
|
|
3686
3869
|
* What a tailnet viewer's device needs, found on a real tailnet in WP-13: the tailnet's access
|
|
@@ -3701,12 +3884,21 @@ function line(share) {
|
|
|
3701
3884
|
/** `mostra share <artifact> --tailnet | --public`. */
|
|
3702
3885
|
const shareCommand = defineCommand({
|
|
3703
3886
|
path: ["share"],
|
|
3704
|
-
summary: "Open an artifact to people beyond this machine: inside your tailnet,
|
|
3887
|
+
summary: "Open an artifact to people beyond this machine: inside your tailnet, publicly with a link that expires, or hosted on a server.",
|
|
3705
3888
|
args: [{
|
|
3706
3889
|
name: "artifact",
|
|
3707
3890
|
summary: "The artifact: its source path or its ID."
|
|
3891
|
+
}, {
|
|
3892
|
+
name: "server",
|
|
3893
|
+
summary: "With --cloud: the server's address. Default: the server signed in to last.",
|
|
3894
|
+
optional: true
|
|
3708
3895
|
}],
|
|
3709
3896
|
flags: [
|
|
3897
|
+
{
|
|
3898
|
+
name: "cloud",
|
|
3899
|
+
kind: "boolean",
|
|
3900
|
+
summary: "Host it on a remote server you signed in to with mostra login: the link keeps working while this machine sleeps."
|
|
3901
|
+
},
|
|
3710
3902
|
{
|
|
3711
3903
|
name: "tailnet",
|
|
3712
3904
|
kind: "boolean",
|
|
@@ -3761,15 +3953,22 @@ const shareCommand = defineCommand({
|
|
|
3761
3953
|
topic: "cli"
|
|
3762
3954
|
},
|
|
3763
3955
|
exits: [EXIT.failure, EXIT.environment],
|
|
3764
|
-
example: "share ./sidebar-review --
|
|
3956
|
+
example: "share ./sidebar-review --cloud",
|
|
3765
3957
|
async run(context) {
|
|
3766
3958
|
const artifact = artifactRef(arg(context, "artifact"), context.cwd);
|
|
3767
3959
|
const tailnet = context.flags["tailnet"] === true;
|
|
3768
3960
|
const publicly = context.flags["public"] === true;
|
|
3769
|
-
|
|
3961
|
+
const cloud = context.flags["cloud"] === true;
|
|
3962
|
+
if ([
|
|
3963
|
+
tailnet,
|
|
3964
|
+
publicly,
|
|
3965
|
+
cloud
|
|
3966
|
+
].filter(Boolean).length !== 1) throw usage("Give one of --tailnet, --public or --cloud.");
|
|
3770
3967
|
const viaFlag = flag(context, "via");
|
|
3771
3968
|
if (viaFlag !== void 0 && !publicly) throw usage("--via chooses a public tunnel: add --public.");
|
|
3772
|
-
const
|
|
3969
|
+
const server = context.args["server"];
|
|
3970
|
+
if (server !== void 0 && !cloud) throw usage("A server names where --cloud hosts it.");
|
|
3971
|
+
const via = cloud ? "remote" : tailnet ? "tailnet" : viaFlag === "funnel" ? "funnel" : "cloudflare";
|
|
3773
3972
|
const ttl = flag(context, "ttl");
|
|
3774
3973
|
const scopes = context.flags["scope"];
|
|
3775
3974
|
const viewerRef = flag(context, "viewer");
|
|
@@ -3779,6 +3978,7 @@ const shareCommand = defineCommand({
|
|
|
3779
3978
|
const share = await context.call(shareStartMethod, {
|
|
3780
3979
|
artifact,
|
|
3781
3980
|
via,
|
|
3981
|
+
...typeof server === "string" ? { server: server.replace(/\/+$/, "") } : {},
|
|
3782
3982
|
...ttl !== void 0 ? { ttl } : {},
|
|
3783
3983
|
...scopes !== void 0 ? { scopes } : {},
|
|
3784
3984
|
...viewerRef !== void 0 ? { viewer: {
|
|
@@ -3877,10 +4077,25 @@ function wantsBrowser(context) {
|
|
|
3877
4077
|
if (context.flags["browser"] === true) return true;
|
|
3878
4078
|
return context.tty.stdout && !context.json && hasDisplay(context.env);
|
|
3879
4079
|
}
|
|
3880
|
-
/**
|
|
4080
|
+
/**
|
|
4081
|
+
* Why no browser was opened, for stderr (#114): an agent's shell isn't a terminal, so without a
|
|
4082
|
+
* word it would tell its person the page is open when it isn't.
|
|
4083
|
+
*/
|
|
4084
|
+
function notOpenedReason(context, tried) {
|
|
4085
|
+
if (context.flags["no-browser"] === true) return void 0;
|
|
4086
|
+
if (tried) return "No browser opened: none could be started here. Give the person the link.";
|
|
4087
|
+
if (!hasDisplay(context.env)) return "No browser opened: this session has no display. Give the person the link.";
|
|
4088
|
+
return "No browser opened: this isn't a terminal. Pass --browser to open it here, or give the person the link.";
|
|
4089
|
+
}
|
|
4090
|
+
/** The link, opened in a browser when wanted; why not on stderr when it wasn't. */
|
|
3881
4091
|
async function show(context, link) {
|
|
3882
4092
|
let opened = false;
|
|
3883
|
-
|
|
4093
|
+
const tried = wantsBrowser(context);
|
|
4094
|
+
if (tried) opened = await openInBrowser((await context.call(viewLaunchMethod, { tokenId: link.tokenId })).url, context.env);
|
|
4095
|
+
if (!opened) {
|
|
4096
|
+
const reason = notOpenedReason(context, tried);
|
|
4097
|
+
if (reason !== void 0) context.log(reason);
|
|
4098
|
+
}
|
|
3884
4099
|
return {
|
|
3885
4100
|
result: {
|
|
3886
4101
|
...link,
|
|
@@ -4015,6 +4230,8 @@ const COMMANDS = [
|
|
|
4015
4230
|
shareCommand,
|
|
4016
4231
|
shareStopCommand,
|
|
4017
4232
|
shareListCommand,
|
|
4233
|
+
loginCommand,
|
|
4234
|
+
logoutCommand,
|
|
4018
4235
|
waitCommand,
|
|
4019
4236
|
resultsCommand,
|
|
4020
4237
|
stateGetCommand,
|
|
@@ -4022,6 +4239,8 @@ const COMMANDS = [
|
|
|
4022
4239
|
statePatchCommand,
|
|
4023
4240
|
pushCommand,
|
|
4024
4241
|
addCommand,
|
|
4242
|
+
exportCommand,
|
|
4243
|
+
runCommand,
|
|
4025
4244
|
secretSetCommand,
|
|
4026
4245
|
secretListCommand,
|
|
4027
4246
|
secretRmCommand,
|
|
@@ -4480,4 +4699,4 @@ async function runRuntime(io, args, stdio) {
|
|
|
4480
4699
|
//#endregion
|
|
4481
4700
|
export { COMMANDS as a, referenceMarkdown as i, commandDefinition as n, commandHelp as r, run as t };
|
|
4482
4701
|
|
|
4483
|
-
//# sourceMappingURL=run-
|
|
4702
|
+
//# sourceMappingURL=run-Aq4HVIY0.js.map
|