@rfany/rf 0.14.0 → 0.15.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rf.mjs +70 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "rollforward's command line for people: what its page does, from a shell or a desktop agent, as you",
5
5
  "license": "MIT",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/spoj/rollforward.git", "directory": "cli" },
package/rf.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // rf for people: what the page does, from a shell or a desktop agent, as you, with a personal token made on the page (Tokens).
3
3
  // Published to npm as @rfany/rf, from cli/. PATH is workspace/series/label, as `rf ls` prints it.
4
- import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, statSync, utimesSync, writeFileSync } from 'node:fs';
4
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmdirSync, rmSync, statSync, utimesSync, writeFileSync } from 'node:fs';
5
5
  import { spawn } from 'node:child_process';
6
6
  import { homedir, hostname } from 'node:os';
7
7
  import { basename, dirname, join, relative, resolve, sep } from 'node:path';
@@ -16,7 +16,8 @@ const USAGE = `rf login URL [TOKEN] without a TOKEN, through the
16
16
  rf ls [--json] every workspace, series and instance you see, with its status, runner, asks waiting and wakes
17
17
  rf waiting [--json] what waits on you: asks and notes, requests to start an instance or to use a
18
18
  website in a workspace you own, proposals, expired logins, and hosts a run's browser on a
19
- website you added was refused
19
+ website of yours was refused that the server's check left, or for admins anyone's it rates
20
+ high risk or finds at an internal address
20
21
  rf show PATH [--json] an instance: its items, the threads that wait on someone, by id, and its last run
21
22
  rf log PATH [--since SEQ] [--follow] [--json] its log, a line an entry, after SEQ; --follow prints more as they come;
22
23
  --json prints the entries as they are, a line each
@@ -30,7 +31,7 @@ rf --version rf's own version, to tell whether it's older t
30
31
  rf comment PATH TEXT [--item ID] [--ref REF] [--thread cN] [--wake|--wait] a new thread, or a reply under comment cN, as to
31
32
  an agent's ask; --wake starts a run on it, as --wait does, which prints what the agent says back
32
33
  rf upload PATH FILE [--onto ITEM] [--output] [--wake]
33
- rf signoff PATH cN [TEXT] [--wake] signs off the agent's ask cN, which pins files, as they are, which commits the folder
34
+ rf signoff PATH cN [TEXT] [--wake] signs off the agent's ask cN, saying yes to it, which commits the folder
34
35
  in your name; to say no, reply
35
36
  rf react PATH [cN] up|down|none your thumbs up or down on comment cN, or on the instance, or none; quiet, open or closed
36
37
  rf close PATH [--as-series NAME] [--wake] the runner makes it the record and an example,
@@ -50,27 +51,32 @@ rf new workspace NAME yours to own, for admins and those they grant
50
51
  rf copy PATH LABEL [--creds OFFER,...] a closed or abandoned instance, copied into a new open one without its agent session
51
52
  rf share PATH on|off [--creds OFFER,...] the series' people, and their agents, wake it as you, with those offers ticked;
52
53
  off stops it, for its sharer or its workspace's owners
53
- rf archive PATH [--undo] a workspace or a series leaves the sidebar as it is, until --undo brings it back
54
+ rf archive PATH [--undo] a workspace or a series leaves the sidebar, and nothing in it changes or runs, until --undo brings it back
54
55
  rf request start|drop ID [--creds OFFER,...] [--wake] a request to start an instance, by the ID rf waiting and rf wakes
55
56
  print; --wake runs the instance it starts
56
57
  rf logins [--json] your logins, each with its state, keepalive and offers; you sign in to them on the page
57
58
  rf logins offer|unoffer LOGIN SOURCE|OFFER what a login offers runs: Microsoft 365's (m365) mailboxes, sites, folders and
58
59
  files, by address or link, a Databricks login's SQL warehouses, by link; unoffer takes the
59
60
  OFFER rf logins lists
60
- rf logins allow SITE HOST a host the pages of SITE, a website you added or, for admins, any, need; once a grant to it
61
- is approved, only within the domains it reaches, beyond which admins allow them
61
+ rf logins allow SITE HOST [--person EMAIL] a host the pages of your website SITE need; once a grant to it is approved,
62
+ only within the domains it reaches, beyond which admins allow them, with --person; one at
63
+ an internal address an admin allows once, for everyone's websites
64
+ rf logins disallow SITE HOST a host your website SITE reaches no more, which stays refused, the server's check letting
65
+ it no more
62
66
  rf logins signout LOGIN
63
- rf site add NAME URL a website whose sign-in starts at URL, which you sign in to on the page; at an address a
64
- website has already, it's that one, whose name rf prints
65
- rf site set NAME [--title TITLE] [--header NAME] [--keepalive PAGE] [--every 10m] [--writeback false]
66
- a website you added, or for admins any: its name as people see it, a header its sign-in
67
- needs that its pages never send, such as x-bot-token, whose value each person gives, the
68
- page a login kept alive loads, by address or path, else its address, and how often, 10m
69
- unless given, and whether a run's browser writes its state back; admins also set
70
- --off true|false, for no one to use it, and --internal true|false, for its browsers to
71
- reach internal hosts
72
- rf site remove NAME a website you added, while no one else has a grant to it pending or approved, or for admins
73
- any: its grants go with it, and everyone's login to it
67
+ rf sites [--json] your websites, each with its address and the other hosts it reaches, with what the server's
68
+ check said of those it let it reach
69
+ rf site add NAME URL [--header NAME] a website of your own, by a NAME you choose, whose sign-in starts at URL, which you
70
+ sign in to on the page; --header names a header its sign-in needs that its pages never
71
+ send, such as x-bot-token, whose value you give as you sign in
72
+ rf site set NAME [--header NAME] [--keepalive PAGE] [--every 10m] [--writeback false]
73
+ your website NAME: a header its sign-in needs that its pages never send, such as
74
+ x-bot-token, whose value you give as you sign in, the page a login kept alive loads, by
75
+ address or path, else its address, and how often, 10m unless given, and whether a run's
76
+ browser writes its state back; admins set --internal true|false, with --person EMAIL for
77
+ someone's, for its browsers to reach internal hosts, and its hosts at internal addresses
78
+ everyone's websites, with no admin again, until one sets it false
79
+ rf site remove NAME your website NAME, with your login to it and your grants for it
74
80
  rf site ask NAME WORKSPACE REASON to use your login to NAME in WORKSPACE's runs, for REASON, which one of its owners approves
75
81
  or denies, seeing the server's check of the website, or an admin, where it rates it high
76
82
  risk; a login no approved grant uses is signed out a week after you signed in, and once
@@ -119,6 +125,9 @@ rf people [--set FILE|-] [-n] [--force] everyone as lines of ROLE EMAIL, each
119
125
  rf user add EMAIL [admin] | role EMAIL admin|user [--force] | disable EMAIL | enable EMAIL | signout EMAIL | remove EMAIL
120
126
  rf egress [add|remove HOST] the hosts runs may reach beyond package registries, GitHub and documentation sites, such as
121
127
  api.example.com or *.example.org; admins add and remove them
128
+ rf internal [remove HOST] [--json] the hosts at internal addresses admins let every website reach, each with who let it and
129
+ when, as rf site set NAME --internal true or allowing one does; remove takes one out, after
130
+ which everyone's websites at it wait for an admin again
122
131
  rf connection set NAME TYPE an outside system runs reach as their runner, by a login each person makes: graph,
123
132
  Microsoft 365, or databricks, Azure Databricks, as each person adds what their login
124
133
  offers; websites are rf site's
@@ -149,14 +158,14 @@ What there is
149
158
  - A comment starts a thread, on the instance or on an item, at a cell such as Base!C25 or a line of a markdown file by its
150
159
  opening words, and replies go under any comment in it, cN by its seq, a thread's id its first comment's. An ask is the agent's
151
160
  comment that waits on someone, the one it names or else the runner, until someone replies under it. rf ls says how many asks
152
- wait in each instance. Reactions, thumbs up or down, are quiet signals kept for later. An ask
153
- may pin files, kept with their sha256 as the agent asks; anyone who sees the instance may sign it off, which commits the
154
- instance's folder to its history, .git in it, as closing does. Whose sign-off counts, and for what, is the series' call.
161
+ wait in each instance. Reactions, thumbs up or down, are quiet signals kept for later. Anyone
162
+ who sees the instance may sign an ask off, saying yes, which commits the instance's folder to its history, .git in it, as it
163
+ is then, as closing does. Whose sign-off counts, and for what, is the series' call.
155
164
 
156
165
  What rf pull copies, the folders as the agent sees them
157
166
  AGENTS.md the company's conventions; <workspace>/AGENTS.md the workspace's
158
167
  <workspace>/<series>/<label>/
159
- screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source, destination, as_of}]}
168
+ screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source, destination}]}
160
169
  log.jsonl every event, by seq: by is a person's email, "server" or "agent"; op is upload, comment (thread, item,
161
170
  ref, parent, text, files, ask, to), signoff (someone's, on the ask it names, with its commit), react,
162
171
  commit, point and item (the screen changing), run, done (its cost, or error), close, and the rest
@@ -172,7 +181,7 @@ The copy is read-only: only rf's commands change what's on the server.
172
181
 
173
182
  Usual work
174
183
  - What waits on me: rf waiting, then rf show PATH, which names each comment that waits by its id.
175
- - Answer an ask: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back; sign off one that pins files:
184
+ - Answer an ask: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back; or sign it off:
176
185
  rf signoff PATH cN [TEXT] --wake, for the agent to carry on. Close an
177
186
  instance once it's the record: rf close PATH.
178
187
  - Take an instance over: rf creds PATH lists the offers of your logins, and rf takeover PATH --creds OFFER,... ticks them.
@@ -279,11 +288,16 @@ function write(path , data , mtime ) {
279
288
 
280
289
  // A path the server named, under `base`, or undefined where a name in it can't be one here: on Windows a name may hold \ or :, which
281
290
  // would put the file elsewhere, even in another workspace's folder, or another file's stream; or name a device, such as CON; or end
282
- // in a dot or a space, which Windows drops.
291
+ // in a dot or a space, which Windows drops. A link where one of its folders goes, or `base`, would take the file elsewhere too, and is refused.
283
292
  const under = (base , rel ) => {
284
293
  const names = rel.split('/');
285
294
  if (names.some(n => !n || n === '.' || n === '..' || basename(n) !== n
286
295
  || (process.platform === 'win32' && (/[<>:"|?*\x00-\x1f]|[. ]$/.test(n) || /^(con|prn|aux|nul|com\d|lpt\d)(\.|$)/i.test(n))))) return undefined;
296
+ let folder = base;
297
+ for (const name of ['', ...names.slice(0, -1)]) {
298
+ folder = join(folder, name);
299
+ if (lstatSync(folder, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error(`${folder} is a symlink: remove it or pull into another directory`);
300
+ }
287
301
  return join(base, ...names);
288
302
  };
289
303
 
@@ -293,7 +307,8 @@ const globs = excludes.map(p => [p.replace(/^\/|\/$/g, '').includes('/'), new Re
293
307
  const excluded = (rel ) => globs.some(([whole, re]) => rel.split('/').some((name, k, all) => re.test(whole ? all.slice(0, k + 1).join('/') : name)));
294
308
 
295
309
  // Copies PATH's files into DIR as rsync does, from the server only and whole: a file whose size or time differ from the server's is
296
- // fetched, and given the server's time, so the next pull compares against it. Nothing is kept besides the files.
310
+ // fetched, and given the server's time, so the next pull compares against it. Nothing is kept besides the files. DIR may be a link, as the
311
+ // person who names it chose; no folder in it may.
297
312
  async function pull(path , dir ) {
298
313
  const at = path.replace(/^\/+/, ''), from = at.replace(/\/+$/, ''), dry = !!flags['dry-run'];
299
314
  const size = /^(\d+)([KMG]?)$/i.exec(String(flags['max-size'] ?? '0'));
@@ -301,7 +316,8 @@ async function pull(path , dir ) {
301
316
  const max = flags['max-size'] === undefined ? Infinity : Number(size[1]) * 1024 ** ' KMG'.indexOf(size[2].toUpperCase() || ' ');
302
317
  const list = await get(`/api/files?path=${encodeURIComponent(from)}`);
303
318
  if (!list.length) throw new Error(`nothing you can see at ${path}`);
304
- const into = !from || at.endsWith('/') ? resolve(dir) : under(resolve(dir), from.slice(from.lastIndexOf('/') + 1)), rel = (f ) => f.path.slice(from ? from.length + 1 : 0);
319
+ const to = existsSync(dir) ? realpathSync(dir) : resolve(dir);
320
+ const into = !from || at.endsWith('/') ? to : under(to, from.slice(from.lastIndexOf('/') + 1)), rel = (f ) => f.path.slice(from ? from.length + 1 : 0);
305
321
  if (!into) throw new Error(`${from} can't be a name here: pull ${from}/ into a folder of your choosing`);
306
322
  let fetched = 0, same = 0, deleted = 0, failed = 0, big = 0;
307
323
  const fetches = [];
@@ -389,8 +405,8 @@ if (cmd === 'login' && url) {
389
405
  ...series.flatMap(x => x.requests.filter(r => mine(r.who)).map(r => ({ kind: 'request', path: x.path, since: r.at, id: r.id, text: `${r.from} asks to start ${r.label}` }))),
390
406
  ...all.filter(w => w.manage && w.proposal?.into === w.id).map(({ proposal: p }) => ({ kind: 'proposal', path: p.to, since: p.at, text: `${p.by} proposes to ${p.kind === 'merge' ? `merge ${p.from} into it` : `move ${p.from}/${p.series} to it`}` })),
391
407
  ...s.expired.filter(e => e.who === me.email).map(e => ({ kind: 'expired', login: e.login, holding: e.holding, text: `your ${e.login} login expired` })),
392
- ...series.flatMap(x => x.instances.flatMap(i => i.refused.map(r => ({ kind: 'refused', path: `${x.path}/${i.label}`, since: r.at, site: r.site, hosts: r.hosts, text: `run ${r.run}'s browser on ${r.site} was refused ${r.hosts.join(', ')}` })))),
393
- ...all.filter(w => w.manage).flatMap(w => w.grants.filter(g => g.state === 'pending').map(g => ({ kind: 'grant', path: w.name, since: g.at, id: g.id, text: `${g.person} asks to use ${g.site} here: ${g.reason} (${g.check?.risk ? `${g.check.risk} risk` : 'not checked'})` }))),
408
+ ...series.flatMap(x => x.instances.flatMap(i => i.refused.map(r => ({ kind: 'refused', path: `${x.path}/${i.label}`, since: r.at, site: r.site, hosts: r.hosts, person: r.login, why: r.why, text: `run ${r.run}'s browser on ${r.login}'s ${r.site} was refused ${r.hosts.map((h ) => r.why[h] ? `${h} (${r.why[h]})` : h).join(', ')}` })))),
409
+ ...all.filter(w => w.manage).flatMap(w => w.grants.filter(g => g.state === 'pending').map(g => ({ kind: 'grant', path: w.name, since: g.at, id: g.id, text: `${g.person} asks to use ${g.site}, at ${g.url}, here: ${g.reason} (${g.check?.risk ? `${g.check.risk} risk` : 'not checked'})` }))),
394
410
  ];
395
411
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
396
412
  else console.log(rows.map(r => `${r.kind} ${r.path ?? r.login}${r.since ? ` since ${when(r.since)}` : ''}${r.id ? `, ${r.kind === 'grant' ? 'grant' : 'request'} ${r.id}` : ''}: ${r.text.split('\n')[0].slice(0, 120)}`).join('\n') || 'Nothing waits on you.');
@@ -426,8 +442,8 @@ if (cmd === 'login' && url) {
426
442
  } else if (cmd === 'pull' && args.length === 2) await pull(args[0], args[1]);
427
443
  else if (cmd === 'comment' && args.length === 2) {
428
444
  const { at } = await instanceAt(args[0]);
429
- await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
430
- const { log, runner } = await get(at), { seq, note } = log.at(-1);
445
+ const posted = await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
446
+ const seq = Number(posted.headers.get('X-RF-Comment-Seq')), { log, runner } = await get(at), { note } = log.find(e => e.seq === seq);
431
447
  if (note) console.log(`a note for the runner, ${runner.by}, seq ${seq}: it starts no run until they act`);
432
448
  else if (!flags.wait) console.log(`commented, seq ${seq}`);
433
449
  else for (;;) {
@@ -449,8 +465,8 @@ else if (cmd === 'comment' && args.length === 2) {
449
465
  console.log(`signed off ${args[1]}`);
450
466
  } else if (['close', 'abandon', 'interrupt'].includes(cmd) && args.length === 1) {
451
467
  const { series, at } = await instanceAt(args[0]);
452
- if (cmd === 'close' && typeof flags['as-series'] === 'string') await post(`/api/series/${series.id}/promote`, { name: flags['as-series'] });
453
468
  await post(`${at}/${cmd}`, { quiet: !flags.wake });
469
+ if (cmd === 'close' && typeof flags['as-series'] === 'string') await post(`/api/series/${series.id}/promote`, { name: flags['as-series'] });
454
470
  console.log(`${cmd === 'close' ? 'closed' : `${cmd}ed`} ${args[0]}`);
455
471
  } else if (cmd === 'takeover' && args.length === 1) {
456
472
  await post(`${(await instanceAt(args[0])).at}/takeover`, { logins: ticks() });
@@ -473,7 +489,9 @@ else if (cmd === 'comment' && args.length === 2) {
473
489
  else await post(`/api/workspaces/${(await workspaceNamed(w)).id}`, { name: args[1] }, 'PUT');
474
490
  console.log(`renamed ${args[0]} ${args[1]}`);
475
491
  } else if (cmd === 'new' && args[0] === 'task' && [2, 3].includes(args.length)) {
476
- const { instance } = await (await post('/api/series', { workspace: (await workspaceNamed(args[1])).id, single: true, logins: ticks() })).json();
492
+ const workspace = await workspaceNamed(args[1]);
493
+ if (workspace.series.some(s => s.name === args[2])) throw new Error(`${args[2]} exists`);
494
+ const { instance } = await (await post('/api/series', { workspace: workspace.id, single: true, logins: ticks() })).json();
477
495
  if (args[2]) await post(`/api/instances/${instance}/rename?as=${encodeURIComponent(args[2])}`, {});
478
496
  if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment, quiet: !flags.wake });
479
497
  console.log(`made ${await pathOf(instance)}${consent(ticks())}`);
@@ -507,17 +525,22 @@ else if (cmd === 'comment' && args.length === 2) {
507
525
  // A website's login offers itself alone.
508
526
  for (const o of l.offers.filter(o => o.id !== l.id)) console.log(` offers ${o.id} ${o.name}`);
509
527
  }
510
- } else if (cmd === 'logins' && ['offer', 'unoffer', 'allow'].includes(args[0]) && args.length === 3) {
528
+ } else if (cmd === 'logins' && ['offer', 'unoffer', 'allow', 'disallow'].includes(args[0]) && args.length === 3) {
511
529
  const [what, login, x] = args, at = `/logins/${encodeURIComponent(login)}`;
512
530
  if (what === 'offer') await post(`${at}/offers`, { add: x });
513
531
  else if (what === 'unoffer') await api(`${at}/offers/${encodeURIComponent(x)}`, { method: 'DELETE' });
514
- else await post(`/logins/web/${encodeURIComponent(login)}/hosts`, { host: x });
515
- console.log(`${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches' }[what]} ${x}`);
532
+ else if (what === 'disallow') await api(`/logins/web/${encodeURIComponent(login)}/hosts/${encodeURIComponent(x)}`, { method: 'DELETE' });
533
+ else await post(`/logins/web/${encodeURIComponent(login)}/hosts${flags.person ? `?person=${encodeURIComponent(String(flags.person))}` : ''}`, { host: x });
534
+ console.log(`${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches', disallow: 'no longer reaches' }[what]} ${x}`);
535
+ } else if (cmd === 'sites' && !args.length) {
536
+ const all = await get('/logins/sites');
537
+ if (flags.json) console.log(JSON.stringify(all, null, 1));
538
+ else for (const [name, w] of Object.entries (all)) console.log(`${name} ${w.url}${w.hosts.map((h ) => `\n reaches ${h}${w.checks?.[h]?.verdict === 'pass' ? `: ${w.checks[h].why}` : ''}`).join('')}`);
516
539
  } else if (cmd === 'site' && args[0] === 'add' && args.length === 3) {
517
- const { site, existing } = await (await post('/logins/sites', { name: args[1], url: args[2] })).json();
518
- console.log(`${existing ? `${args[2]} is ${site}'s` : `added ${site}`}: sign in to it at ${url}/#logins, then rf site ask ${site} WORKSPACE REASON`);
540
+ const { site } = await (await post('/logins/sites', { name: args[1], url: args[2], header: flags.header })).json();
541
+ console.log(`added ${site}: sign in to it at ${url}/#logins, then rf site ask ${site} WORKSPACE REASON`);
519
542
  } else if (cmd === 'site' && args[0] === 'set' && args.length === 2) {
520
- await post(`/logins/sites/${encodeURIComponent(args[1])}`, flags, 'PATCH');
543
+ await post(`/logins/sites/${encodeURIComponent(args[1])}${flags.person ? `?person=${encodeURIComponent(String(flags.person))}` : ''}`, { ...flags, person: undefined }, 'PATCH');
521
544
  console.log('saved');
522
545
  } else if (cmd === 'site' && args[0] === 'remove' && args.length === 2) {
523
546
  await api(`/logins/sites/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
@@ -525,12 +548,12 @@ else if (cmd === 'comment' && args.length === 2) {
525
548
  } else if (cmd === 'site' && args[0] === 'ask' && args.length === 4) {
526
549
  const { id, check: c } = await (await post('/grants', { site: args[1], workspace: (await workspaceNamed(args[2])).id, reason: args[3] })).json();
527
550
  console.log(`asked, as grant ${id}: ${c.risk === 'high' ? 'an admin approves or denies it, as the check rates it high risk' : `one of ${args[2]}'s owners approves or denies it`}\n${!c.risk ? `not checked: ${c.error}`
528
- : `check: ${c.risk} risk${c.flags.length ? ` (${c.flags.join('; ')})` : ''}. ${c.summary}${c.same ? ` It looks like ${c.same}, a website here already.` : ''}${c.hosts.length ? ` Approving lets it reach ${c.hosts.join(', ')}.` : ''}`}`);
551
+ : `check: ${c.risk} risk${c.flags.length ? ` (${c.flags.join('; ')})` : ''}. ${c.summary}${c.hosts.length ? ` Approving lets it reach ${c.hosts.join(', ')}.` : ''}`}`);
529
552
  } else if (cmd === 'grants' && args.length <= 1) {
530
553
  const [all, ws] = await Promise.all([get('/grants'), get('/api')]), name = (id ) => ws.find(w => w.id === id)?.name ?? id;
531
554
  const shown = all.filter(g => !args[0] || name(g.workspace) === args[0]);
532
555
  if (flags.json) console.log(JSON.stringify(shown.map(g => ({ ...g, workspace: name(g.workspace) })), null, 1));
533
- else for (const g of shown) console.log(`${g.id} ${g.state} ${g.site} in ${name(g.workspace)} for ${g.person}, since ${when(g.at)}: ${g.reason}${g.by ? `; ${g.state} by ${g.by}${g.text ? `: ${g.text}` : ''}` : ''} (${g.check?.risk ? `${g.check.risk} risk` : 'not checked'})`);
556
+ else for (const g of shown) console.log(`${g.id} ${g.state} ${g.site} at ${g.url} in ${name(g.workspace)} for ${g.person}, since ${when(g.at)}: ${g.reason}${g.by ? `; ${g.state} by ${g.by}${g.text ? `: ${g.text}` : ''}` : ''} (${g.check?.risk ? `${g.check.risk} risk` : 'not checked'})`);
534
557
  } else if (cmd === 'grant' && ['approve', 'deny'].includes(args[0]) && [2, 3].includes(args.length)) {
535
558
  await post(`/grants/${args[1]}`, { approve: args[0] === 'approve', text: args[2] });
536
559
  console.log(args[0] === 'approve' ? 'approved' : 'denied');
@@ -677,6 +700,14 @@ else if (cmd === 'comment' && args.length === 2) {
677
700
  let hosts = await (await api('/egress')).json();
678
701
  if (args.length) hosts = await (await post('/egress', { hosts: args[0] === 'add' ? [...new Set([...hosts, args[1]])] : hosts.filter(h => h !== args[1]) }, 'PUT')).json();
679
702
  console.log(hosts.join('\n'));
703
+ } else if (cmd === 'internal' && (!args.length || (args.length === 2 && args[0] === 'remove'))) {
704
+ const hosts = args.length ? await (await api(`/internal/${encodeURIComponent(args[1])}`, { method: 'DELETE' })).json() : await get('/internal');
705
+ if (flags.json) console.log(JSON.stringify(hosts, null, 1));
706
+ else {
707
+ const w = Math.max(0, ...Object.keys(hosts).map(h => h.length));
708
+ for (const [h, { by, at }] of Object.entries(hosts)) console.log(`${h.padEnd(w)} ${when(at)} ${by}`);
709
+ if (!Object.keys(hosts).length) console.log('none: an admin lets websites reach one with rf site set NAME --internal true');
710
+ }
680
711
  } else if (cmd === 'people' && args.length <= 1) {
681
712
  // People as lines to edit and set: ROLE EMAIL for everyone, owner|member EMAIL-OR-GROUP for a workspace, each with a comment.
682
713
  const ws = args[0] === undefined ? undefined : await workspaceNamed(args[0]);