peerband 0.1.2 → 0.1.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/README.md +1 -0
- package/dist/peerband.mjs +172 -48
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ The plugin adds a persistent tab titled `PeerBand Relay [On]` or `[Off]` that sh
|
|
|
89
89
|
| `peerband status` | Show login, relay, messaging and Herdr state, including whether the Herdr plugin is the right one. `--json` for machine-readable output |
|
|
90
90
|
| `peerband connect` | Run the connector in the foreground. Flags: `--runtime herdr\|mock`, `--read-only`, `--config PATH`, `--server URL` (`--enable-writes` is still accepted but redundant) |
|
|
91
91
|
| `peerband relay` | Open or focus the Relay tab in Herdr. If the plugin is missing the wrong version, a local checkout, or points at another config directory, it offers to repair it first |
|
|
92
|
+
| `peerband share` | Create a single-use invite link that shares this machine with another PeerBand user (read only; `--message` also allows messages; `--expires DAYS`, default 7). `share list` shows who has access and unused links; `share revoke ID` removes access or cancels a link |
|
|
92
93
|
| `peerband herdr install` | Install (or update) the Herdr plugin |
|
|
93
94
|
| `peerband herdr uninstall` | Stop the relay, remove the plugin and its `settings.json` |
|
|
94
95
|
| `peerband --version`, `help [command]` | Version and help |
|
package/dist/peerband.mjs
CHANGED
|
@@ -65,13 +65,13 @@ var require_buffer_util = __commonJS({
|
|
|
65
65
|
"use strict";
|
|
66
66
|
var { EMPTY_BUFFER } = require_constants();
|
|
67
67
|
var FastBuffer = Buffer[Symbol.species];
|
|
68
|
-
function concat(
|
|
69
|
-
if (
|
|
70
|
-
if (
|
|
68
|
+
function concat(list2, totalLength) {
|
|
69
|
+
if (list2.length === 0) return EMPTY_BUFFER;
|
|
70
|
+
if (list2.length === 1) return list2[0];
|
|
71
71
|
const target = Buffer.allocUnsafe(totalLength);
|
|
72
72
|
let offset = 0;
|
|
73
|
-
for (let i = 0; i <
|
|
74
|
-
const buf =
|
|
73
|
+
for (let i = 0; i < list2.length; i++) {
|
|
74
|
+
const buf = list2[i];
|
|
75
75
|
target.set(buf, offset);
|
|
76
76
|
offset += buf.length;
|
|
77
77
|
}
|
|
@@ -1857,14 +1857,14 @@ var require_sender = __commonJS({
|
|
|
1857
1857
|
* @param {Function} [cb] Callback
|
|
1858
1858
|
* @private
|
|
1859
1859
|
*/
|
|
1860
|
-
sendFrame(
|
|
1861
|
-
if (
|
|
1860
|
+
sendFrame(list2, cb) {
|
|
1861
|
+
if (list2.length === 2) {
|
|
1862
1862
|
this._socket.cork();
|
|
1863
|
-
this._socket.write(
|
|
1864
|
-
this._socket.write(
|
|
1863
|
+
this._socket.write(list2[0]);
|
|
1864
|
+
this._socket.write(list2[1], cb);
|
|
1865
1865
|
this._socket.uncork();
|
|
1866
1866
|
} else {
|
|
1867
|
-
this._socket.write(
|
|
1867
|
+
this._socket.write(list2[0], cb);
|
|
1868
1868
|
}
|
|
1869
1869
|
}
|
|
1870
1870
|
};
|
|
@@ -10859,8 +10859,8 @@ var require_dist = __commonJS({
|
|
|
10859
10859
|
return ajv;
|
|
10860
10860
|
}
|
|
10861
10861
|
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
|
10862
|
-
const
|
|
10863
|
-
addFormats2(ajv,
|
|
10862
|
+
const list2 = opts.formats || formats_1.formatNames;
|
|
10863
|
+
addFormats2(ajv, list2, formats, exportName);
|
|
10864
10864
|
if (opts.keywords)
|
|
10865
10865
|
(0, limit_1.default)(ajv);
|
|
10866
10866
|
return ajv;
|
|
@@ -10872,11 +10872,11 @@ var require_dist = __commonJS({
|
|
|
10872
10872
|
throw new Error(`Unknown format "${name}"`);
|
|
10873
10873
|
return f;
|
|
10874
10874
|
};
|
|
10875
|
-
function addFormats2(ajv,
|
|
10875
|
+
function addFormats2(ajv, list2, fs, exportName) {
|
|
10876
10876
|
var _a;
|
|
10877
10877
|
var _b;
|
|
10878
10878
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
10879
|
-
for (const f of
|
|
10879
|
+
for (const f of list2)
|
|
10880
10880
|
ajv.addFormat(f, fs[f]);
|
|
10881
10881
|
}
|
|
10882
10882
|
module.exports = exports = formatsPlugin;
|
|
@@ -12436,12 +12436,13 @@ function enrollmentBase(serverUrl) {
|
|
|
12436
12436
|
throw new Error("Enrollment requires HTTPS except on localhost.");
|
|
12437
12437
|
return base;
|
|
12438
12438
|
}
|
|
12439
|
-
async function redeemEnrollment(serverUrl, grant, name, fetcher = fetch) {
|
|
12439
|
+
async function redeemEnrollment(serverUrl, grant, name, fetcher = fetch, previousCredential) {
|
|
12440
12440
|
const base = enrollmentBase(serverUrl);
|
|
12441
12441
|
const response = await fetcher(new URL("/api/enrollments/redeem", base), {
|
|
12442
12442
|
method: "POST",
|
|
12443
12443
|
headers: { "content-type": "application/json" },
|
|
12444
|
-
|
|
12444
|
+
// previous_credential lets the server keep this machine's record (see DeviceLoginOptions).
|
|
12445
|
+
body: JSON.stringify({ grant, name, ...previousCredential ? { previous_credential: previousCredential } : {} }),
|
|
12445
12446
|
signal: AbortSignal.timeout(15e3)
|
|
12446
12447
|
});
|
|
12447
12448
|
const body = await response.json().catch(() => ({}));
|
|
@@ -12799,7 +12800,11 @@ async function pollDeviceToken(serverUrl, code, options = {}) {
|
|
|
12799
12800
|
if (now() >= deadline) throw expired();
|
|
12800
12801
|
let result;
|
|
12801
12802
|
try {
|
|
12802
|
-
result = await postJson(
|
|
12803
|
+
result = await postJson(
|
|
12804
|
+
url,
|
|
12805
|
+
{ device_code: code.deviceCode, ...options.previousCredential ? { previous_credential: options.previousCredential } : {} },
|
|
12806
|
+
options
|
|
12807
|
+
);
|
|
12803
12808
|
} catch {
|
|
12804
12809
|
if (options.signal?.aborted) throw aborted();
|
|
12805
12810
|
failures = Math.min(failures + 1, 10);
|
|
@@ -12889,11 +12894,11 @@ function suggest(input, candidates) {
|
|
|
12889
12894
|
return best?.name;
|
|
12890
12895
|
}
|
|
12891
12896
|
var HELP_OPTION = { name: "help", short: "h", type: "boolean", description: "Show help for this command." };
|
|
12892
|
-
function parseArgs(
|
|
12893
|
-
const options = [...
|
|
12897
|
+
function parseArgs(spec7, argv) {
|
|
12898
|
+
const options = [...spec7.options, HELP_OPTION];
|
|
12894
12899
|
const values = {};
|
|
12895
12900
|
const positionals = [];
|
|
12896
|
-
const helpHint = `Run \`peerband ${
|
|
12901
|
+
const helpHint = `Run \`peerband ${spec7.name} --help\` for usage.`;
|
|
12897
12902
|
for (let i = 0; i < argv.length; i++) {
|
|
12898
12903
|
const arg = argv[i];
|
|
12899
12904
|
if (arg === "--") {
|
|
@@ -12913,11 +12918,11 @@ function parseArgs(spec6, argv) {
|
|
|
12913
12918
|
option = options.find((candidate) => candidate.name === name);
|
|
12914
12919
|
if (!option) {
|
|
12915
12920
|
const near = suggest(name, options.filter((o) => !o.hidden).map((o) => o.name));
|
|
12916
|
-
throw new UsageError(`Unknown option --${name} for \`peerband ${
|
|
12921
|
+
throw new UsageError(`Unknown option --${name} for \`peerband ${spec7.name}\`.`, near ? `Did you mean --${near}? ${helpHint}` : helpHint);
|
|
12917
12922
|
}
|
|
12918
12923
|
} else {
|
|
12919
12924
|
option = options.find((candidate) => candidate.short === arg.slice(1));
|
|
12920
|
-
if (!option) throw new UsageError(`Unknown option ${arg} for \`peerband ${
|
|
12925
|
+
if (!option) throw new UsageError(`Unknown option ${arg} for \`peerband ${spec7.name}\`.`, helpHint);
|
|
12921
12926
|
}
|
|
12922
12927
|
if (option.type === "boolean") {
|
|
12923
12928
|
if (inline !== void 0) throw new UsageError(`Option --${option.name} does not take a value.`, helpHint);
|
|
@@ -12935,9 +12940,9 @@ function parseArgs(spec6, argv) {
|
|
|
12935
12940
|
}
|
|
12936
12941
|
values[option.name] = value;
|
|
12937
12942
|
}
|
|
12938
|
-
const max =
|
|
12943
|
+
const max = spec7.positionals?.max ?? 0;
|
|
12939
12944
|
if (positionals.length > max) {
|
|
12940
|
-
throw new UsageError(`Unexpected argument "${positionals[max]}" for \`peerband ${
|
|
12945
|
+
throw new UsageError(`Unexpected argument "${positionals[max]}" for \`peerband ${spec7.name}\`.`, helpHint);
|
|
12941
12946
|
}
|
|
12942
12947
|
return { values, positionals };
|
|
12943
12948
|
}
|
|
@@ -13250,7 +13255,7 @@ async function loadHerdrSchema(options = {}) {
|
|
|
13250
13255
|
const promptRef = prompt?.properties?.params?.$ref;
|
|
13251
13256
|
const promptName = promptRef?.split("/").at(-1);
|
|
13252
13257
|
const params = promptName ? schema.schemas.request.$defs?.[promptName] : void 0;
|
|
13253
|
-
const writesHaveAtomicOccupantGuard = Boolean(params?.properties && Object.entries(params.properties).some(([name,
|
|
13258
|
+
const writesHaveAtomicOccupantGuard = Boolean(params?.properties && Object.entries(params.properties).some(([name, spec7]) => /^(expected_generation|expected_terminal_id|expected_agent_session)$/i.test(name) && JSON.stringify(spec7).toLowerCase().includes("occupant")));
|
|
13254
13259
|
return {
|
|
13255
13260
|
schema,
|
|
13256
13261
|
validateRequest,
|
|
@@ -14431,6 +14436,14 @@ async function ensureHerdrPlugin(ctx) {
|
|
|
14431
14436
|
}
|
|
14432
14437
|
|
|
14433
14438
|
// src/cli/commands/login.ts
|
|
14439
|
+
function reusableCredential(previous, serverUrl) {
|
|
14440
|
+
if (!previous) return void 0;
|
|
14441
|
+
try {
|
|
14442
|
+
return new URL(previous.serverUrl).origin === new URL(serverUrl).origin ? previous.credential : void 0;
|
|
14443
|
+
} catch {
|
|
14444
|
+
return void 0;
|
|
14445
|
+
}
|
|
14446
|
+
}
|
|
14434
14447
|
async function persist(ctx, redeemed) {
|
|
14435
14448
|
const credentials = { ...redeemed, enrolledAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
14436
14449
|
await saveCredentials(credentials, credentialsFile(ctx));
|
|
@@ -14439,7 +14452,7 @@ async function persist(ctx, redeemed) {
|
|
|
14439
14452
|
async function loginWithGrant(ctx, options) {
|
|
14440
14453
|
let redeemed;
|
|
14441
14454
|
try {
|
|
14442
|
-
redeemed = await redeemEnrollment(options.serverUrl, options.grant, options.name, ctx.fetch);
|
|
14455
|
+
redeemed = await redeemEnrollment(options.serverUrl, options.grant, options.name, ctx.fetch, options.previousCredential);
|
|
14443
14456
|
} catch (error) {
|
|
14444
14457
|
const message = error.message;
|
|
14445
14458
|
const rejected = /could not be redeemed/i.test(message);
|
|
@@ -14511,7 +14524,7 @@ async function loginWithBrowser(ctx, options) {
|
|
|
14511
14524
|
}
|
|
14512
14525
|
let redeemed;
|
|
14513
14526
|
try {
|
|
14514
|
-
redeemed = await pollDeviceToken(options.serverUrl, code, shared);
|
|
14527
|
+
redeemed = await pollDeviceToken(options.serverUrl, code, { ...shared, ...options.previousCredential ? { previousCredential: options.previousCredential } : {} });
|
|
14515
14528
|
} catch (error) {
|
|
14516
14529
|
throw mapFailure(error, options.serverUrl);
|
|
14517
14530
|
} finally {
|
|
@@ -14549,7 +14562,7 @@ var spec2 = {
|
|
|
14549
14562
|
name: "login",
|
|
14550
14563
|
summary: "Connect this machine to your PeerBand account",
|
|
14551
14564
|
usage: "peerband login [--name NAME] [--no-browser] [--server URL] [--herdr-plugin ask|install|skip]\n peerband login --grant GRANT [--name NAME] [--server URL]",
|
|
14552
|
-
description: "Signs this machine in through your browser. login prints a link and a short code, opens the page (unless you are on SSH, a headless machine or pass --no-browser), and waits while you confirm the code in your PeerBand account. The credential is stored in your PeerBand config directory (readable only by you). Running login again replaces the
|
|
14565
|
+
description: "Signs this machine in through your browser. login prints a link and a short code, opens the page (unless you are on SSH, a headless machine or pass --no-browser), and waits while you confirm the code in your PeerBand account. The credential is stored in your PeerBand config directory (readable only by you). Running login again replaces the stored credential; when you sign in to the same account and server, this machine keeps its record in your account (installation ID and shares).\n\nOn a headless machine or in CI, use a one-time grant instead: create it in the PeerBand dashboard and pass --grant GRANT (or set PEERBAND_GRANT).\n\nWhen login succeeds it checks for Herdr. If the PeerBand plugin is missing, or installed but wrong (another version, a local checkout, a stale config directory), it offers to add or repair it (--herdr-plugin ask, the default; it only asks on a terminal), adds it without asking (install), or just prints the command (skip).",
|
|
14553
14566
|
options: [
|
|
14554
14567
|
{ name: "no-browser", type: "boolean", description: "Do not open a browser; print the link and code only (SSH, containers)." },
|
|
14555
14568
|
{ name: "name", type: "string", valueName: "NAME", description: "Name shown for this machine in the dashboard. Default: this computer's hostname." },
|
|
@@ -14575,9 +14588,12 @@ var spec2 = {
|
|
|
14575
14588
|
delete ctx.env.PEERBAND_GRANT;
|
|
14576
14589
|
if (parsed.values.grant !== void 0 && !grant) throw new UsageError("The grant is empty.", "Pass the grant from your PeerBand dashboard: --grant GRANT.");
|
|
14577
14590
|
const previous = await loadCredentials(credentialsFile(ctx)).catch(() => void 0);
|
|
14578
|
-
const
|
|
14591
|
+
const previousCredential = reusableCredential(previous, serverUrl);
|
|
14592
|
+
const credentials = grant ? await loginWithGrant(ctx, { serverUrl, grant, name, ...previousCredential ? { previousCredential } : {} }) : await loginWithBrowser(ctx, { serverUrl, name, noBrowser: parsed.values["no-browser"] === true, ...previousCredential ? { previousCredential } : {} });
|
|
14579
14593
|
const s = ctx.out.stdout;
|
|
14580
|
-
if (previous
|
|
14594
|
+
if (previous && previous.installationId === credentials.installationId && previous.serverUrl === credentials.serverUrl)
|
|
14595
|
+
ctx.out.print(s.dim("Kept this machine in your account with a new credential; its shares stay in place."));
|
|
14596
|
+
else if (previous) ctx.out.print(s.dim(`Replaced the previous login (${previous.machineName ?? previous.installationId} on ${previous.serverUrl}).`));
|
|
14581
14597
|
const who = credentials.accountEmail ? ` (${credentials.accountEmail})` : "";
|
|
14582
14598
|
ctx.out.print(`${s.green(symbols.ok)} Logged in as ${s.bold(credentials.machineName ?? name)}${who}`);
|
|
14583
14599
|
await herdrSetup(ctx, herdrMode);
|
|
@@ -14641,6 +14657,114 @@ var spec4 = {
|
|
|
14641
14657
|
}
|
|
14642
14658
|
};
|
|
14643
14659
|
|
|
14660
|
+
// src/cli/commands/share.ts
|
|
14661
|
+
var roleLabel = (role) => role === "message" ? "read + message" : "read only";
|
|
14662
|
+
var MAX_EXPIRY_DAYS = 30;
|
|
14663
|
+
async function call(ctx, credentials, method, path, body) {
|
|
14664
|
+
const url = new URL(path, enrollmentBase(credentials.serverUrl));
|
|
14665
|
+
let response;
|
|
14666
|
+
try {
|
|
14667
|
+
response = await ctx.fetch(url, {
|
|
14668
|
+
method,
|
|
14669
|
+
headers: { authorization: `Bearer ${credentials.credential}`, ...body ? { "content-type": "application/json" } : {} },
|
|
14670
|
+
...body ? { body: JSON.stringify(body) } : {},
|
|
14671
|
+
signal: AbortSignal.timeout(15e3)
|
|
14672
|
+
});
|
|
14673
|
+
} catch (error) {
|
|
14674
|
+
throw new CliError(`Could not reach ${url.origin}: ${error.message}`, "Check your network connection and try again.");
|
|
14675
|
+
}
|
|
14676
|
+
if (response.status === 204) return null;
|
|
14677
|
+
const parsed = await response.json().catch(() => ({}));
|
|
14678
|
+
if (response.ok) return parsed;
|
|
14679
|
+
const detail = typeof parsed.detail === "string" ? parsed.detail : `HTTP ${response.status}`;
|
|
14680
|
+
if (response.status === 401) throw new CliError("PeerBand rejected this machine's credential (it may have been revoked).", "Run `peerband login` again to sign in.");
|
|
14681
|
+
if (response.status === 404 && path.endsWith("/sharing") && method === "GET") throw new CliError("This PeerBand server doesn't support sharing yet.");
|
|
14682
|
+
throw new CliError(sanitize(detail));
|
|
14683
|
+
}
|
|
14684
|
+
function expiryDays(raw) {
|
|
14685
|
+
if (raw === void 0) return void 0;
|
|
14686
|
+
const days = Number(raw);
|
|
14687
|
+
if (!Number.isInteger(days) || days < 1 || days > MAX_EXPIRY_DAYS) throw new UsageError(`Invalid --expires value "${raw}".`, `Use a whole number of days from 1 to ${MAX_EXPIRY_DAYS}.`);
|
|
14688
|
+
return days;
|
|
14689
|
+
}
|
|
14690
|
+
async function create(ctx, credentials, role, days, json) {
|
|
14691
|
+
const link = await call(ctx, credentials, "POST", "/api/installation/invites", { role, ...days ? { expires_in_days: days } : {} });
|
|
14692
|
+
if (json) {
|
|
14693
|
+
ctx.out.print(JSON.stringify(link, null, 2));
|
|
14694
|
+
return 0;
|
|
14695
|
+
}
|
|
14696
|
+
const s = ctx.out.stdout;
|
|
14697
|
+
ctx.out.print(`${s.green(symbols.ok)} Invite link for ${s.bold(credentials.machineName ?? "this machine")} (${roleLabel(link.role)}):`);
|
|
14698
|
+
ctx.out.print("");
|
|
14699
|
+
ctx.out.print(` ${s.cyan(sanitize(link.url))}`);
|
|
14700
|
+
ctx.out.print("");
|
|
14701
|
+
ctx.out.print(`Send it to one person. It works once and expires ${sanitize(link.expires_at)}.`);
|
|
14702
|
+
ctx.out.print(s.dim("They sign in to PeerBand (or create an account) and accept. See who has access with `peerband share list`."));
|
|
14703
|
+
return 0;
|
|
14704
|
+
}
|
|
14705
|
+
async function list(ctx, credentials, json) {
|
|
14706
|
+
const sharing = await call(ctx, credentials, "GET", "/api/installation/sharing");
|
|
14707
|
+
if (json) {
|
|
14708
|
+
ctx.out.print(JSON.stringify(sharing, null, 2));
|
|
14709
|
+
return 0;
|
|
14710
|
+
}
|
|
14711
|
+
const s = ctx.out.stdout;
|
|
14712
|
+
ctx.out.print(s.bold("People with access"));
|
|
14713
|
+
if (!sharing.guests.length) ctx.out.print(s.dim(" Nobody else has access yet. Create a link with `peerband share`."));
|
|
14714
|
+
for (const guest of sharing.guests) {
|
|
14715
|
+
const used = guest.last_used_at ? `last used ${sanitize(guest.last_used_at)}` : "not used yet";
|
|
14716
|
+
ctx.out.print(` ${sanitize(guest.email ?? "PeerBand user")} ${roleLabel(guest.role)} ${s.dim(`${used} \xB7 ${guest.id}`)}`);
|
|
14717
|
+
}
|
|
14718
|
+
if (sharing.invites.length) {
|
|
14719
|
+
ctx.out.print("");
|
|
14720
|
+
ctx.out.print(s.bold("Unused links"));
|
|
14721
|
+
for (const invite of sharing.invites) ctx.out.print(` ${roleLabel(invite.role)} ${s.dim(`expires ${sanitize(invite.expires_at)} \xB7 ${invite.id}`)}`);
|
|
14722
|
+
}
|
|
14723
|
+
ctx.out.print("");
|
|
14724
|
+
ctx.out.print(s.dim("Remove access or cancel a link with `peerband share revoke ID`. Change roles in the dashboard."));
|
|
14725
|
+
return 0;
|
|
14726
|
+
}
|
|
14727
|
+
async function revoke(ctx, credentials, id) {
|
|
14728
|
+
if (!id) throw new UsageError("Missing the ID to revoke.", "Run `peerband share list` to see IDs (acc_\u2026 for people, inv_\u2026 for links).");
|
|
14729
|
+
if (!/^(acc|inv)_[\w-]{1,64}$/.test(id)) throw new UsageError(`"${sanitize(id)}" is not a share ID.`, "IDs start with acc_ (a person) or inv_ (a link); see `peerband share list`.");
|
|
14730
|
+
await call(ctx, credentials, "DELETE", `/api/installation/sharing/${encodeURIComponent(id)}`);
|
|
14731
|
+
ctx.out.print(`${ctx.out.stdout.green(symbols.ok)} ${id.startsWith("acc_") ? "Access removed." : "Link cancelled."}`);
|
|
14732
|
+
return 0;
|
|
14733
|
+
}
|
|
14734
|
+
var spec5 = {
|
|
14735
|
+
name: "share",
|
|
14736
|
+
summary: "Share this machine with another PeerBand user",
|
|
14737
|
+
usage: "peerband share [--message] [--expires DAYS] [--json]\n peerband share list [--json]\n peerband share revoke ID",
|
|
14738
|
+
description: "Creates an invitation link for this machine. The person who opens it signs in to PeerBand (or creates an account) and accepts; this machine then appears in their dashboard and in list_machines in their MCP client. Guests can list and read this machine's agents. With --message they can also send messages, if their MCP client has the agents:message consent and this machine allows messages (a machine started with --read-only never does).\n\nEach link works for one person and expires after 7 days unless you pass --expires. You see each guest's email and a log of what they read or send (metadata only) in the dashboard.\n\n`share list` shows who has access and the unused links; `share revoke ID` removes a person's access (acc_\u2026) or cancels a link (inv_\u2026).",
|
|
14739
|
+
options: [
|
|
14740
|
+
{ name: "message", type: "boolean", description: "Also let the guest send messages to agents. Default: read only." },
|
|
14741
|
+
{ name: "expires", type: "string", valueName: "DAYS", description: `Days until the link expires, 1 to ${MAX_EXPIRY_DAYS}. Default: 7.` },
|
|
14742
|
+
{ name: "json", type: "boolean", description: "Print machine-readable JSON." }
|
|
14743
|
+
],
|
|
14744
|
+
positionals: { name: "list | revoke ID", max: 2 },
|
|
14745
|
+
examples: [
|
|
14746
|
+
["peerband share", "Create a read-only invite link for this machine"],
|
|
14747
|
+
["peerband share --message --expires 1", "A link that also allows messages, valid for one day"],
|
|
14748
|
+
["peerband share list", "People with access and unused links"],
|
|
14749
|
+
["peerband share revoke acc_AbC123", "Remove someone's access"]
|
|
14750
|
+
],
|
|
14751
|
+
notes: ["The link is shown once. Anyone who has it can accept it until it is used, so send it only to the person you mean."],
|
|
14752
|
+
async run(parsed, ctx) {
|
|
14753
|
+
const [action, id] = parsed.positionals;
|
|
14754
|
+
const json = flag(parsed, "json");
|
|
14755
|
+
if (action !== void 0 && action !== "list" && action !== "revoke")
|
|
14756
|
+
throw new UsageError(`Unknown share action "${sanitize(action)}".`, "Use `peerband share`, `peerband share list` or `peerband share revoke ID`.");
|
|
14757
|
+
if (action !== "revoke" && id !== void 0) throw new UsageError(`Unexpected argument "${sanitize(id)}".`, "Run `peerband share --help` for usage.");
|
|
14758
|
+
if (action && (parsed.values.message !== void 0 || parsed.values.expires !== void 0))
|
|
14759
|
+
throw new UsageError("--message and --expires only apply when creating a link.", "Run `peerband share --message` to create one.");
|
|
14760
|
+
const days = expiryDays(str(parsed, "expires"));
|
|
14761
|
+
const credentials = await requireCredentials(ctx);
|
|
14762
|
+
if (action === "list") return list(ctx, credentials, json);
|
|
14763
|
+
if (action === "revoke") return revoke(ctx, credentials, id);
|
|
14764
|
+
return create(ctx, credentials, flag(parsed, "message") ? "message" : "read", days, json);
|
|
14765
|
+
}
|
|
14766
|
+
};
|
|
14767
|
+
|
|
14644
14768
|
// src/cli/commands/status.ts
|
|
14645
14769
|
function safeMcpUrl(serverUrl, env) {
|
|
14646
14770
|
try {
|
|
@@ -14734,7 +14858,7 @@ function renderHuman(report, ctx) {
|
|
|
14734
14858
|
const width = Math.max(...rows.map(([key]) => key.length));
|
|
14735
14859
|
for (const [key, value] of rows) ctx.out.print(`${s.bold(key.padEnd(width))} ${value}`);
|
|
14736
14860
|
}
|
|
14737
|
-
var
|
|
14861
|
+
var spec6 = {
|
|
14738
14862
|
name: "status",
|
|
14739
14863
|
summary: "Show login, relay and Herdr status",
|
|
14740
14864
|
usage: "peerband status [--json]",
|
|
@@ -14753,7 +14877,7 @@ var spec5 = {
|
|
|
14753
14877
|
};
|
|
14754
14878
|
|
|
14755
14879
|
// src/cli/registry.ts
|
|
14756
|
-
var commands = [spec2, spec3,
|
|
14880
|
+
var commands = [spec2, spec3, spec6, spec4, spec5, spec];
|
|
14757
14881
|
var herdrCommands = [installSpec, uninstallSpec];
|
|
14758
14882
|
function lookup(words) {
|
|
14759
14883
|
const [first, second] = words;
|
|
@@ -14812,20 +14936,20 @@ function rootHelp(s, version) {
|
|
|
14812
14936
|
return `${lines.join("\n")}
|
|
14813
14937
|
`;
|
|
14814
14938
|
}
|
|
14815
|
-
function commandHelp(s,
|
|
14939
|
+
function commandHelp(s, spec7) {
|
|
14816
14940
|
const lines = [
|
|
14817
|
-
`${s.bold(`peerband ${
|
|
14818
|
-
...section(s, "Usage", [
|
|
14941
|
+
`${s.bold(`peerband ${spec7.name}`)} ${spec7.summary}`,
|
|
14942
|
+
...section(s, "Usage", [spec7.usage]),
|
|
14819
14943
|
"",
|
|
14820
|
-
...
|
|
14821
|
-
...section(s, "Options", table(optionRows(
|
|
14944
|
+
...spec7.description.split("\n").map((line) => ` ${line}`),
|
|
14945
|
+
...section(s, "Options", table(optionRows(spec7.options), s)),
|
|
14822
14946
|
...section(
|
|
14823
14947
|
s,
|
|
14824
14948
|
"Examples",
|
|
14825
|
-
|
|
14949
|
+
spec7.examples.flatMap(([command, comment]) => [`${s.cyan(command)}`, ` ${s.dim(comment)}`])
|
|
14826
14950
|
)
|
|
14827
14951
|
];
|
|
14828
|
-
if (
|
|
14952
|
+
if (spec7.notes?.length) lines.push(...section(s, "Notes", spec7.notes));
|
|
14829
14953
|
return `${lines.join("\n")}
|
|
14830
14954
|
`;
|
|
14831
14955
|
}
|
|
@@ -14843,7 +14967,7 @@ function herdrGroupHelp(s) {
|
|
|
14843
14967
|
}
|
|
14844
14968
|
|
|
14845
14969
|
// src/cli/cli.ts
|
|
14846
|
-
var VERSION = true ? "0.1.
|
|
14970
|
+
var VERSION = true ? "0.1.3" : "0.0.0-dev";
|
|
14847
14971
|
function createContext(overrides = {}) {
|
|
14848
14972
|
const env = overrides.env ?? process.env;
|
|
14849
14973
|
const stdout = overrides.stdout ?? process.stdout;
|
|
@@ -14864,9 +14988,9 @@ function resolveHelpTarget(words, ctx) {
|
|
|
14864
14988
|
const s = ctx.out.stdout;
|
|
14865
14989
|
if (words.length === 0) return rootHelp(s, ctx.version);
|
|
14866
14990
|
if (words[0] === "herdr" && words.length === 1) return herdrGroupHelp(s);
|
|
14867
|
-
const
|
|
14868
|
-
if (!
|
|
14869
|
-
return commandHelp(s,
|
|
14991
|
+
const spec7 = lookup(words);
|
|
14992
|
+
if (!spec7) throw unknownCommand(words.join(" "));
|
|
14993
|
+
return commandHelp(s, spec7);
|
|
14870
14994
|
}
|
|
14871
14995
|
function unknownCommand(name) {
|
|
14872
14996
|
const near = suggest(name, topLevelNames());
|
|
@@ -14909,14 +15033,14 @@ async function run(argv, ctx = createContext()) {
|
|
|
14909
15033
|
words = [first, second];
|
|
14910
15034
|
args = others;
|
|
14911
15035
|
}
|
|
14912
|
-
const
|
|
14913
|
-
if (!
|
|
14914
|
-
const parsed = parseArgs(
|
|
15036
|
+
const spec7 = lookup(words);
|
|
15037
|
+
if (!spec7) throw unknownCommand(first);
|
|
15038
|
+
const parsed = parseArgs(spec7, args);
|
|
14915
15039
|
if (parsed.values.help) {
|
|
14916
|
-
ctx.out.print(commandHelp(ctx.out.stdout,
|
|
15040
|
+
ctx.out.print(commandHelp(ctx.out.stdout, spec7).trimEnd());
|
|
14917
15041
|
return 0;
|
|
14918
15042
|
}
|
|
14919
|
-
return await
|
|
15043
|
+
return await spec7.run(parsed, ctx);
|
|
14920
15044
|
} catch (error) {
|
|
14921
15045
|
if (error instanceof UsageError) {
|
|
14922
15046
|
ctx.out.fail(error.message, error.hint);
|
package/herdr-plugin.toml
CHANGED
package/package.json
CHANGED