@rfany/rf 0.20.4 → 0.20.6

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 +46 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.20.4",
3
+ "version": "0.20.6",
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
@@ -18,9 +18,9 @@ const usage = (c , vpn = false, admin = false) => {
18
18
  const all = `rf login URL [TOKEN] [--az [--resource URI]] without a TOKEN, through the browser; with --az, short-lived Entra tokens via Azure CLI (no token on disk); run via npx @rfany/rf@latest
19
19
  rf ls [--mine] [--json] every workspace, series and instance you see, with its status, owner, asks waiting and wakes;
20
20
  --mine, only open instances of series you own
21
- rf waiting [--json] what waits on you: asks, proposals, requests and expired logins; also note notices (FYI).
22
- Only admins see hosts a run's browser was refused that the server rates high or finds
23
- at an internal address
21
+ rf waiting [--json] [--dismiss-settled] what waits on you: asks, proposals, requests and expired logins; also note notices (FYI).
22
+ --dismiss-settled dismisses all your settled note notices. Only admins see hosts a
23
+ run's browser was refused that the server rates high or finds at an internal address
24
24
  rf show PATH [--json] an instance: its items, the threads that wait on someone, by id, and its last run
25
25
  rf log PATH [--since SEQ] [--follow] [--json] its log, a line an entry, after SEQ; --follow prints more as they come;
26
26
  --json prints the entries as they are, a line each
@@ -78,8 +78,9 @@ rf logins [--json] your logins, each with its state, keepalive an
78
78
  rf logins offer|unoffer LOGIN SOURCE|OFFER what a login offers runs: Microsoft 365's (m365) mailboxes, sites, folders and
79
79
  files, by address or link, a Databricks login's SQL warehouses, by link; unoffer takes the
80
80
  OFFER rf logins lists
81
- rf logins allow SITE HOST --person EMAIL admins alone allow a host the server left refused; one at an internal address
81
+ rf logins allow SITE HOST --person EMAIL [--rev REV] admins alone allow a host the server left refused; one at an internal address
82
82
  is allowed once for everyone's websites
83
+ rf logins refuse SITE HOST [--person EMAIL] [--rev REV] admins alone keep a refused host blocked so it leaves Waiting on you
83
84
  rf logins disallow SITE HOST a host your website SITE reaches no more, which stays refused, the server's check letting
84
85
  it no more
85
86
  rf logins signout LOGIN${vpn ? '\nrf vpns [--json] client VPNs and whether you are connected to each; sign in on the page' : ''}
@@ -187,7 +188,7 @@ What there is
187
188
  files, and review the work in threads with the agent. One series owner is accountable for every instance: only that person
188
189
  closes and abandons. Their acts and answers by whom the agent's ask named start runs under current consent. Runs use the
189
190
  owner's selected credentials, across every instance. Without consent, nothing runs; selecting none permits work with no
190
- credentials. Scheduled and autonomous runs need a separate opt-in. Other collaborators' comments, uploads and approvals are notes that start nothing.
191
+ credentials. Scheduled and autonomous runs need a separate opt-in. Other collaborators' comments and uploads are notes that start nothing.
191
192
  Transferring the whole series stops old runs and clears consent; old unread instructions become notes. Each act keeps
192
193
  its author, and every run its executor.
193
194
  - rf is quiet: a comment, upload, approval, rejection, new instance or request it starts begins no run unless --wake, and the agent
@@ -196,10 +197,10 @@ What there is
196
197
  - 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
197
198
  opening words, and replies go under any comment in it, cN by its seq, a thread's id its first comment's. The agent asks
198
199
  questions, which wait on someone, the one it names or else the series owner, until a person replies under it, and proposes what it
199
- will do for its series owner, such as sending mail, which waits until someone approves or rejects it, or the agent withdraws it; a
200
+ will do for its series owner, such as sending mail, which waits until the owner or named addressee approves or rejects it, or the agent withdraws it; a
200
201
  proposal missing information should be rejected with feedback, so the agent can revise and propose again. Generic comments
201
202
  are not proposal decisions. rf ls says how many asks wait in each instance. Reactions, thumbs up or down, are
202
- quiet signals kept for later. Anyone who sees the instance may approve a proposal, which commits the instance's folder to its
203
+ quiet signals kept for later. Only the series owner or the person a proposal names (--to) may approve or reject it; approval commits the instance's folder to its
203
204
  history, .git in it, as it is then, as closing does. Whose approval counts, and for what, is the series' call.
204
205
 
205
206
  What rf pull copies, the folders as the agent sees them
@@ -286,7 +287,7 @@ if (cmd === 'comment' || cmd === 'settle') {
286
287
  } else for (let i = 0; i < argv.length; i++) {
287
288
  const flag = argv[i] === '-n' ? 'dry-run' : argv[i] === '-d' ? 'delay' : argv[i].match(/^--(.+)$/)?.[1];
288
289
  if (!flag) args.push(argv[i]);
289
- else if (['wait', 'wake', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo', 'by-amount', 'yes', 'mine', 'daily', 'all', 'az'].includes(flag)) flags[flag] = true;
290
+ else if (['wait', 'wake', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo', 'by-amount', 'yes', 'mine', 'daily', 'all', 'az', 'dismiss-settled'].includes(flag)) flags[flag] = true;
290
291
  else if (argv[i + 1] === undefined) throw new Error(`--${flag} takes a value`);
291
292
  else if (flag === 'exclude') excludes.push(argv[++i]);
292
293
  else flags[flag] = argv[++i];
@@ -666,8 +667,34 @@ if (cmd === 'login' && url) {
666
667
  for (const k of r.wakes) console.log(` wake ${k.id} ${k.at}${k.label ? ` starts ${k.label}` : ''}${k.days ? `, then each ${k.days.join(', ')}` : ''}${k.text ? `: ${k.text}` : ''}${k.check ? `; check ${k.check}${k.deadline ? ` until ${k.deadline}` : ''}${k.maxStaleMin ? `, max-stale ${k.maxStaleMin}m` : ''}${k.backstopHours ? `, backstop ${k.backstopHours}h` : ''}` : ''}`);
667
668
  }
668
669
  } else if (cmd === 'waiting' && !args.length) {
670
+ if (flags['dismiss-settled']) {
671
+ const res = await (await post('/api/messages', { dismissAll: 'settled' })).json();
672
+ console.log(flags.json ? JSON.stringify(res, null, 1) : `dismissed ${res.dismissed} settled note notice${res.dismissed === 1 ? '' : 's'}`);
673
+ } else {
669
674
  const [me, s, all] = await Promise.all([get('/me'), get('/api/status'), get('/api')]), mine = (who ) => (who ?? me.email) === me.email;
670
675
  const series = all.flatMap(w => w.series.map(x => ({ ...x, path: `${w.name}/${x.name}` })));
676
+ const refusedByHost = new Map ();
677
+ for (const w of all) if (!w.archived) for (const x of w.series) if (!x.archived) for (const i of x.instances) for (const r of i.refused ?? []) for (const h of r.hosts ?? []) {
678
+ const key = `${r.login}\0${r.site}\0${h}`, c = r.counts?.[h] ?? r.count ?? 1, hostAt = r.ats?.[h] ?? r.at ?? '', t = Date.parse(hostAt) || 0, rev = r.revs?.[h] ?? r.siteRev;
679
+ const prev = refusedByHost.get(key);
680
+ if (!prev) refusedByHost.set(key, { path: `${w.name}/${x.name}/${i.label}`, since: hostAt, t, run: r.run, site: r.site, ...(rev && { rev }), person: r.login, host: h, why: r.why?.[h] ?? '', count: c });
681
+ else {
682
+ prev.count += c;
683
+ if (t > prev.t || (t === prev.t && (r.run ?? 0) >= prev.run)) Object.assign(prev, { path: `${w.name}/${x.name}/${i.label}`, since: hostAt, t, run: r.run, ...(rev && { rev }), why: r.why?.[h] || prev.why });
684
+ }
685
+ }
686
+ const refusedRows = new Map ();
687
+ for (const h of refusedByHost.values()) {
688
+ const rowKey = `${h.person}\0${h.site}\0${h.path}\0${h.run}`;
689
+ let row = refusedRows.get(rowKey);
690
+ if (!row) refusedRows.set(rowKey, row = { path: h.path, since: h.since, t: h.t, run: h.run, site: h.site, person: h.person, hosts: [], why: {}, counts: {}, ats: {}, revs: {} });
691
+ else if (h.t > row.t) { row.since = h.since; row.t = h.t; }
692
+ row.hosts.push(h.host);
693
+ if (h.why) row.why[h.host] = h.why;
694
+ row.counts[h.host] = h.count;
695
+ if (h.since) row.ats[h.host] = h.since;
696
+ if (h.rev) row.revs[h.host] = h.rev;
697
+ }
671
698
  const rows = [
672
699
  ...s.ownership.map(s => ({ kind: 'owner', path: s.path, text: s.text })),
673
700
  ...s.asks.filter(a => a.who === me.email && !a.legacyNotice).map(a => ({ kind: a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
@@ -675,13 +702,15 @@ if (cmd === 'login' && url) {
675
702
  ...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 ${r.target ? 'wake' : 'start'} ${r.label}${r.text ? `: ${r.text}` : ''}` }))),
676
703
  ...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`}` })),
677
704
  ...s.expired.filter(e => e.who === me.email).map(e => ({ kind: 'expired', login: e.login, holding: e.holding, text: `your ${e.login} login expired` })),
678
- ...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(', ')}` })))),
705
+ ...[...refusedRows.values()].map(r => ({ kind: 'refused', path: r.path, since: r.since, site: r.site, hosts: r.hosts, person: r.person, why: r.why, counts: r.counts, ats: r.ats, ...(Object.keys(r.revs).length && { revs: r.revs }), text: `run ${r.run}'s browser on ${r.person}'s ${r.site} was refused ${r.hosts.map(h => { const c = r.counts[h]; const meta = [c > 1 ? `${c}×` : '', r.why[h] ?? ''].filter(Boolean).join(', '); return meta ? `${h} (${meta})` : h; }).join(', ')}` })),
706
+ ...all.filter(w => !w.archived).flatMap(w => w.series.filter(x => !x.archived).flatMap(x => x.instances.filter(i => i.wrong && i.owner === me.email).map(i => ({ kind: 'correction', path: `${w.name}/${x.name}/${i.label}`, since: i.active, count: i.wrong, text: `${i.wrong} correction${i.wrong === 1 ? '' : 's'} say${i.wrong === 1 ? 's' : ''} it's wrong` })))),
679
707
  ...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: grantText(g) }))),
680
708
  ];
681
709
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
682
710
  else console.log(rows.map(r => r.kind === 'open' || r.kind === 'settled'
683
711
  ? `note ${r.kind} ${r.path}#${r.id} by ${r.by} at ${when(r.at)}: ${gist(r.text, 120)}`
684
712
  : `${r.kind} ${r.path ?? r.login}${r.since ? ` since ${when(r.since)}` : ''}${r.id ? `, ${r.kind === 'grant' ? 'grant' : 'request'} ${r.id}` : ''}: ${r.kind === 'grant' ? r.text : r.text.split('\n')[0].slice(0, 120)}`).join('\n') || 'Nothing waits on you.');
713
+ }
685
714
  } else if (cmd === 'show' && args.length === 1) {
686
715
  const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, owner, waiting: w } = await get(at);
687
716
  const waiting = w.map(({ who, seq }) => {
@@ -920,13 +949,17 @@ else if (cmd === 'comment' && args.length < 2) {
920
949
  // A website's login offers itself alone.
921
950
  for (const o of l.offers.filter(o => o.id !== l.id)) console.log(` offers ${o.id} ${o.name}`);
922
951
  }
923
- } else if (cmd === 'logins' && ['offer', 'unoffer', 'allow', 'disallow'].includes(args[0]) && args.length === 3) {
952
+ } else if (cmd === 'logins' && ['offer', 'unoffer', 'allow', 'refuse', 'disallow'].includes(args[0]) && args.length === 3) {
924
953
  const [what, login, x] = args, at = `/logins/${encodeURIComponent(login)}`;
925
954
  if (what === 'offer') await post(`${at}/offers`, { add: x });
926
955
  else if (what === 'unoffer') await api(`${at}/offers/${encodeURIComponent(x)}`, { method: 'DELETE' });
927
956
  else if (what === 'disallow') await api(`/logins/web/${encodeURIComponent(login)}/hosts/${encodeURIComponent(x)}`, { method: 'DELETE' });
928
- else await post(`/logins/web/${encodeURIComponent(login)}/hosts${flags.person ? `?person=${encodeURIComponent(String(flags.person))}` : ''}`, { host: x });
929
- console.log(`${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches', disallow: 'no longer reaches' }[what]} ${x}`);
957
+ else if (what === 'refuse' || what === 'allow') {
958
+ if (flags.rev !== undefined && !String(flags.rev).trim()) throw new Error('--rev: site revision cannot be empty');
959
+ const rev = flags.rev !== undefined ? { siteRev: String(flags.rev) } : {};
960
+ await post(`/logins/web/${encodeURIComponent(login)}/hosts${flags.person ? `?person=${encodeURIComponent(String(flags.person))}` : ''}`, { host: x, ...(what === 'refuse' && { allow: false }), ...rev });
961
+ }
962
+ console.log(what === 'refuse' ? `${login} keeps ${x} blocked` : `${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches', disallow: 'no longer reaches' }[what]} ${x}`);
930
963
  } else if (cmd === 'vpns' && !args.length) {
931
964
  const all = await get('/vpns');
932
965
  if (flags.json) console.log(JSON.stringify(all, null, 1));
@@ -1191,7 +1224,7 @@ else if (cmd === 'kill' && args.length === 1 && /^\d+$/.test(args[0])) {
1191
1224
  } else if (cmd === 'wakes' && args.length <= 1) {
1192
1225
  const at = (args[0] ?? '').replace(/\/+$/, ''), rows = (await get('/api')).flatMap(w => w.series.filter(s => !s.archived).flatMap(s => [
1193
1226
  ...(s.single ? [] : [{ path: `${w.name}/${s.name}`, fired: s.fired, wakes: s.wakes, requests: s.requests }]),
1194
- ...s.instances.filter(i => i.wakes.length).map(i => ({ path: `${w.name}/${s.name}/${i.label}`, fired: i.fired, wakes: i.wakes, requests: [] })),
1227
+ ...s.instances.filter(i => i.wakes.length || (s.single && s.requests.length)).map(i => ({ path: `${w.name}/${s.name}/${i.label}`, fired: i.fired, wakes: i.wakes, requests: s.single ? s.requests : [] })),
1195
1228
  ])).filter(r => !at || r.path === at || r.path.startsWith(at + '/'));
1196
1229
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
1197
1230
  else for (const r of rows) {