@rfany/rf 0.11.0 → 0.12.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 +119 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.11.0",
3
+ "version": "0.12.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
@@ -14,8 +14,9 @@ process.on('uncaughtException', e => {
14
14
 
15
15
  const USAGE = `rf login URL [TOKEN] without a TOKEN, through the browser: type rf's code on the page, and allow it
16
16
  rf ls [--json] every workspace, series and instance you see, with its status, runner, asks waiting and wakes
17
- rf waiting [--json] what waits on you: asks, sign-offs and notes, requests to start an instance, proposals,
18
- expired logins, and hosts a run's browser on a website of your own was refused
17
+ rf waiting [--json] what waits on you: asks and notes, requests to start an instance or to use a
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
20
  rf show PATH [--json] an instance: its items, the threads that wait on someone, by id, and its last run
20
21
  rf log PATH [--since SEQ] [--follow] [--json] its log, a line an entry, after SEQ; --follow prints more as they come;
21
22
  --json prints the entries as they are, a line each
@@ -26,37 +27,57 @@ rf pull PATH DIR [--delete] [-n|--dry-run] [--exclude PATTERN]... [--max-size SI
26
27
  --max-size skips files bigger than SIZE, such as 50M
27
28
  rf help [COMMAND] how rollforward works and how to use rf, for an agent, or COMMAND's usage
28
29
  rf --version rf's own version, to tell whether it's older than what the guide names
29
- rf comment PATH TEXT [--item ID] [--ref REF] [--thread T] [--wait] a new thread, or a reply in T, as to an agent's ask
30
- rf upload PATH FILE [--onto ITEM] [--output]
31
- rf resolve PATH THREAD [TEXT] resolves a thread, with TEXT as a last word; nothing wakes
32
- rf signoff PATH THREAD approve|reject [TEXT] the runner's answer to a sign-off the agent asks for, which commits the folder
33
- rf close PATH [--as-series NAME] the runner stands by it: closed, it's an example; a task closes as a one-off, or as the first
34
- instance of the series NAME it becomes
30
+ rf comment PATH TEXT [--item ID] [--ref REF] [--thread cN] [--wake|--wait] a new thread, or a reply under comment cN, as to
31
+ an agent's ask; --wake starts a run on it, as --wait does, which prints what the agent says back
32
+ 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
+ in your name; to say no, reply
35
+ 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
+ rf close PATH [--as-series NAME] [--wake] the runner makes it the record and an example,
37
+ approving nothing; a task closes as a one-off, or as the first instance of the series NAME it
38
+ becomes; --wake starts runs of the series' later open instances, which may have used its draft
35
39
  rf abandon PATH the runner leaves it as it is, neither an example nor a starting point
36
40
  rf interrupt PATH stops its run
37
41
  rf takeover PATH [--creds OFFER,...] you run it from now on, with those offers of your logins ticked
38
42
  rf creds PATH [--set OFFER,...|--clear] what its runs may use: its runner's ticks, and the offers of your logins; --set
39
43
  ticks anew, as its runner
40
44
  rf rename PATH NAME an instance, a series or a workspace, by its path
41
- rf new task WORKSPACE [LABEL] [--creds OFFER,...] [--comment TEXT] a one-off task, Untitled until LABEL or its first
42
- comment names it; --comment starts its run
43
- rf new instance SERIES LABEL [--creds OFFER,...] the series' next instance, which runs at once
45
+ rf new task WORKSPACE [LABEL] [--creds OFFER,...] [--comment TEXT [--wake]] a one-off task, Untitled until LABEL or its
46
+ first comment names it; --wake starts its run on the comment
47
+ rf new instance SERIES LABEL [--creds OFFER,...] [--wake] the series' next instance, which --wake runs at once
44
48
  rf new series PATH NAME the task at PATH becomes the series NAME, itself its first instance
45
49
  rf new workspace NAME yours to own, for admins and those they grant create
46
50
  rf copy PATH LABEL [--creds OFFER,...] a closed or abandoned instance, copied into a new open one without its agent session
47
51
  rf share PATH on|off [--creds OFFER,...] the series' people, and their agents, wake it as you, with those offers ticked;
48
52
  off stops it, for its sharer or its workspace's owners
49
53
  rf archive PATH [--undo] a workspace or a series leaves the sidebar as it is, until --undo brings it back
50
- rf request start|drop ID [--creds OFFER,...] a request to start an instance, by the ID rf waiting and rf wakes print
54
+ rf request start|drop ID [--creds OFFER,...] [--wake] a request to start an instance, by the ID rf waiting and rf wakes
55
+ print; --wake runs the instance it starts
51
56
  rf logins [--json] your logins, each with its state, keepalive and offers; you sign in to them on the page
52
57
  rf logins offer|unoffer LOGIN SOURCE|OFFER what a login offers runs: Microsoft 365's (m365) mailboxes, sites, folders and
53
58
  files, by address or link, a Databricks login's SQL warehouses, by link; unoffer takes the
54
59
  OFFER rf logins lists
55
- rf logins allow SITE HOST a host the pages of SITE, your own website or, for admins, another, need
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
56
62
  rf logins signout LOGIN
57
- rf site add NAME URL a website of your own, for those granted sites, whose sign-in starts at URL; you sign in to it
58
- on the page
59
- rf site remove NAME a website of yours, with your login to it
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
74
+ 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
+ or denies, seeing the server's check of the website, or an admin, where it rates it high
76
+ risk; a login no approved grant uses is signed out a week after you signed in, and once
77
+ you have no grant to it pending or approved
78
+ rf grants [WORKSPACE] [--json] the grants to use websites, yours and those of the workspaces you own, with their states
79
+ rf grant approve|deny ID [TEXT] a request to use a website in a workspace you own, with TEXT for its asker
80
+ rf grant revoke ID a grant pending or approved, yours or in a workspace you own; its runs' browsers close
60
81
  rf correct PATH TEXT [--item ID] [--ref REF] [--superseded] [--see LABEL] a closed instance, or its item ID at REF, is
61
82
  wrong, or superseded, as LABEL, another instance of its series, shows; it can't be withdrawn
62
83
  rf wake PATH AT [--label LABEL] [--days DAYS] | rf wake --cancel ID
@@ -72,12 +93,13 @@ rf status [--long MIN] [--json] what goes on and what's stuck: runs going, fla
72
93
  rf indexes [--json] each index of a source you index, all for admins: its kind, items and size, and per person
73
94
  its phase, crawl or follow, pages read, when last caught up, and its error and next try
74
95
  rf runs [PATH] [--since DATE] [--failed] [--running] [--long MIN] [--json]
75
- a line per run: start, path, run, outcome, time, cost, what started it, summary or error;
96
+ a line per run: start, path, run, outcome, time, cost, what started it, and any error;
76
97
  the outcome is done, interrupted by a person, cut by a restart, running, or failed, for
77
98
  credits, policy, time limit or other
78
99
  rf costs [PATH] [--since DATE] [--by workspace|series|person|day|outcome] [--json] totals, runs and cost per run; person
79
100
  is the runner; runs leave out those a restart cut, as the next run carries each on
80
- rf activity [PATH] [--since DATE] [--json] per instance, what people said, uploaded and closed, and each run's report
101
+ rf activity [PATH] [--since DATE] [--json] per instance, what people and the agent said, what people uploaded and closed, and
102
+ each run that failed
81
103
  rf wakes [PATH] [--json] each series' pending wakes and requests to start an instance, and when a wake of it last
82
104
  fired, and each instance's pending wakes
83
105
  rf people WORKSPACE [--set FILE|-] [-n] [--force] its owners and admins: its people as lines of owner|member EMAIL-OR-GROUP,
@@ -92,24 +114,16 @@ Admins:
92
114
  rf people [--set FILE|-] [-n] [--force] everyone as lines of ROLE EMAIL, each with a comment; --set sets the roles of the people
93
115
  listed and adds new ones, removing no one
94
116
  rf user add EMAIL [admin] | role EMAIL admin|user [--force] | disable EMAIL | enable EMAIL | signout EMAIL | remove EMAIL
95
- rf connection set NAME TYPE [--SETTING VALUE]... an outside system runs reach as their runner, by a login each person makes:
96
- graph, Microsoft 365, and databricks, Azure Databricks, each with no settings, as each
97
- person adds what their login offers; website, --url URL [--hosts HOST,...] [--title TITLE]
98
- [--writeback false] [--header NAME] [--keepalive PAGE] [--every 10m]
99
- [--people EMAIL|GROUP,...], where people sign in, the other hosts its pages need, such as
100
- *.example.com, whether a run's browser writes its state back, a header its sign-in needs
101
- that its pages never send, such as x-bot-token, whose value each person gives, the page a
102
- login kept alive loads, by its address or path, such as
103
- https://patriarch.patrina.net/PatriArchMVC/, else the address, and how often, 10m unless
104
- given, and who alone may use it, by email or Entra group id
117
+ rf connection set NAME TYPE an outside system runs reach as their runner, by a login each person makes: graph,
118
+ Microsoft 365, or databricks, Azure Databricks, as each person adds what their login
119
+ offers; websites are rf site's
105
120
  rf connection remove NAME
106
- rf connection off|on NAME a website switched off, for no one to use, such as a person's own, or on again
107
121
  rf brand [--text TEXT] [--logo FILE] [--clear] the deployment's text and logo, a .png, .jpg, .gif, .webp or .svg, which top
108
122
  the sidebar and are the page's title and icon; --clear goes back to the plain look, and with
109
123
  no option it prints them
110
124
  rf can [CAP [EMAIL|GROUP,...] [--clear]] what users may do beyond the rest, as admins may: publish, push skills;
111
- create, make workspaces; sites, add websites of their own; and keepalive, keep their
112
- website logins alive for up to a week as they sign in; a list grants CAP to those
125
+ create, make workspaces; and keepalive, keep their website logins alive for up to a
126
+ week as they sign in; a list grants CAP to those
113
127
  emails and Entra group ids in place of whom it had, --clear to no one, and with neither it
114
128
  prints whom each is granted to`;
115
129
 
@@ -120,23 +134,27 @@ COMMAND gives one's usage, every read takes --json, and a failure is one line on
120
134
  What there is
121
135
  - A workspace holds series, and its people. A series is one recurring job; an instance is one period of it, labelled such as
122
136
  2026-08-23. A task is a one-off: a series of one instance, named by its label, until someone makes it a series. PATH is workspace/series/label, as rf ls prints it; for rf pull it may go deeper, into an instance's files.
123
- - An instance's screen is its items: inputs, steps and outputs, each pointing at a file, with what it's made from. People upload
124
- files and comment. The runner is the person whose logins the runs use, and who closes the instance once they stand by it. Their
125
- comments and uploads start a run of the agent, which reads them and carries on, as do everyone's where the runner shares the
126
- series, and a reply from whom an ask names; anyone else's is a note, which the agent takes up once the runner does.
127
- - A comment starts a thread, on the instance or on an item, at a cell such as Base!C25, and others reply in it. An ask is the
128
- agent's comment that waits on someone, the one it names or else the runner, until they reply or resolve it. rf ls says how many
129
- asks wait in each instance. A sign-off, an ask with signoff true, waits on the runner, who approves or rejects it on the page:
130
- either commits the instance's folder to its history, .git in it, as closing does.
137
+ - An instance's screen is its items: inputs, outputs and steps, each pointing at a file, with what it's made from. People upload
138
+ files, and review the work in threads with the agent. The runner is the person whose logins the runs use, and who closes the
139
+ instance, making it the period's record and an example for the next, which approves nothing. Their comments and uploads start a run of the agent, which reads them and carries on, as do everyone's where the
140
+ runner shares the series, and a reply from whom an ask names; anyone else's is a note, which the agent takes up once the runner
141
+ does.
142
+ - rf is quiet: a comment, upload, sign-off, close, new instance or request it starts begins no run unless --wake, and the agent
143
+ reads it at its next run; rf wake PATH now starts one. A quiet upload or comment is committed to the instance's history at once.
144
+ - 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
145
+ 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
146
+ comment that waits on someone, the one it names or else the runner, until someone replies under it. rf ls says how many asks
147
+ wait in each instance. Reactions, thumbs up or down, are quiet signals kept for later. An ask
148
+ may pin files, kept with their sha256 as the agent asks; anyone who sees the instance may sign it off, which commits the
149
+ instance's folder to its history, .git in it, as closing does. Whose sign-off counts, and for what, is the series' call.
131
150
 
132
151
  What rf pull copies, the folders as the agent sees them
133
152
  AGENTS.md the company's conventions; <workspace>/AGENTS.md the workspace's
134
153
  <workspace>/<series>/<label>/
135
- screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source}]}
154
+ screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source, destination, as_of}]}
136
155
  log.jsonl every event, by seq: by is a person's email, "server" or "agent"; op is upload, comment (thread, item,
137
- ref, text, ask, to, signoff), resolve, signoff (the runner's answer, with its commit), commit, point and
138
- item (the screen changing), run, report (the agent's account of a run), done (its cost, summary or
139
- error), close, and the rest
156
+ ref, parent, text, files, ask, to), signoff (someone's, on the ask it names, with its commit), react,
157
+ commit, point and item (the screen changing), run, done (its cost, or error), close, and the rest
140
158
  upload/ what people uploaded, their comments' attachments in upload/attachments/
141
159
  working/ what the agent made, its scripts, and process.md, how it does this series
142
160
  session/ each session's transcript, which may carry several runs: every message and tool call
@@ -148,15 +166,17 @@ What rf pull copies, the folders as the agent sees them
148
166
  The copy is read-only: only rf's commands change what's on the server.
149
167
 
150
168
  Usual work
151
- - What waits on me: rf waiting, then rf show PATH, which names each thread that waits by its id.
152
- - Answer an ask: rf comment PATH TEXT --thread T --wait, which prints what the agent says back; a sign-off, as its runner:
153
- rf signoff PATH T approve|reject [TEXT]. Close an instance you stand by: rf close PATH.
169
+ - What waits on me: rf waiting, then rf show PATH, which names each comment that waits by its id.
170
+ - Answer an ask: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back; sign off one that pins files:
171
+ rf signoff PATH cN [TEXT] --wake, for the agent to carry on. Close an
172
+ instance once it's the record: rf close PATH.
154
173
  - Take an instance over: rf creds PATH lists the offers of your logins, and rf takeover PATH --creds OFFER,... ticks them.
155
174
  - Your logins: rf logins lists them, with what each offers, and an expired one's link to sign in again on the page.
156
- - Give an input or a corrected output: rf upload PATH FILE [--onto ITEM] [--output].
157
- - Start an instance: rf new instance SERIES LABEL, as you, or rf wake SERIES now --label LABEL, which starts it as whoever
158
- shares the series, else asks on the page for someone to start it; take one you run up later: rf wake PATH +2h. A one-off:
159
- rf new task WORKSPACE --comment TEXT, which becomes a series with rf new series PATH NAME.
175
+ - Give an input or a corrected output: rf upload PATH FILE [--onto ITEM] [--output], with --wake on the last for a run on them
176
+ all.
177
+ - Start an instance: rf new instance SERIES LABEL --wake, as you, or rf wake SERIES now --label LABEL, which starts it as
178
+ whoever shares the series, else asks on the page for someone to start it; take one you run up later: rf wake PATH +2h. A
179
+ one-off: rf new task WORKSPACE --comment TEXT --wake, which becomes a series with rf new series PATH NAME.
160
180
  - Read what a run did: rf show PATH for its last run, rf log PATH for every entry, --follow as they come, and rf cat PATH/FILE
161
181
  for a file; rf pull PATH/ DIR copies the folder, with session/ for every step.
162
182
 
@@ -167,7 +187,7 @@ Watching over it, for admins and power users; each sees what the caller sees
167
187
  - Indexes: rf indexes shows each index of a big library or mailbox you index, every one for admins: its items and size, and per
168
188
  person whether it is crawling or following changes, pages read, when last caught up, and an error, if any, with its next try.
169
189
  - History: rf runs [PATH] [--since DATE] [--failed] [--running] [--long MIN] prints a line per run: its start, path, run number,
170
- outcome, time taken, cost, what started it and by whom, and its summary or error. rf costs [PATH] [--since DATE] [--by
190
+ outcome, time taken, cost, what started it and by whom, and any error. rf costs [PATH] [--since DATE] [--by
171
191
  workspace|series|person|day] totals them, by the runner for person.
172
192
  - People: rf people (admins) prints everyone as ROLE EMAIL lines, and rf people WORKSPACE (its owners and admins) its owners and
173
193
  members as owner|member lines; a comment after each says when they last signed in and which open instances they run, and for
@@ -185,7 +205,7 @@ const flags = {}, excludes = [], args
185
205
  for (let i = 0; i < argv.length; i++) {
186
206
  const flag = argv[i] === '-n' ? 'dry-run' : argv[i].match(/^--(.+)$/)?.[1];
187
207
  if (!flag) args.push(argv[i]);
188
- else if (['wait', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo'].includes(flag)) flags[flag] = true;
208
+ else if (['wait', 'wake', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo', 'by-amount'].includes(flag)) flags[flag] = true;
189
209
  else if (argv[i + 1] === undefined) throw new Error(`--${flag} takes a value`);
190
210
  else if (flag === 'exclude') excludes.push(argv[++i]);
191
211
  else flags[flag] = argv[++i];
@@ -360,30 +380,28 @@ if (cmd === 'login' && url) {
360
380
  const [me, s, all] = await Promise.all([get('/me'), get('/api/status'), get('/api')]), mine = (who ) => (who ?? me.email) === me.email;
361
381
  const series = all.flatMap(w => w.series.map(x => ({ ...x, path: `${w.name}/${x.name}` })));
362
382
  const rows = [
363
- ...s.asks.filter(a => a.who === me.email).map(a => ({ kind: a.signoff ? 'sign-off' : a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
383
+ ...s.asks.filter(a => a.who === me.email).map(a => ({ kind: a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
364
384
  ...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}` }))),
365
385
  ...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`}` })),
366
386
  ...s.expired.filter(e => e.who === me.email).map(e => ({ kind: 'expired', login: e.login, holding: e.holding, text: `your ${e.login} login expired` })),
367
387
  ...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(', ')}` })))),
388
+ ...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'})` }))),
368
389
  ];
369
390
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
370
- else console.log(rows.map(r => `${r.kind} ${r.path ?? r.login}${r.since ? ` since ${when(r.since)}` : ''}${r.id ? `, request ${r.id}` : ''}: ${r.text.split('\n')[0].slice(0, 120)}`).join('\n') || 'Nothing waits on you.');
391
+ 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.');
371
392
  } else if (cmd === 'show' && args.length === 1) {
372
- const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, runner } = await get(at);
373
- const threads = Map.groupBy(log.filter(e => ['comment', 'resolve', 'signoff'].includes(e.op)), e => e.thread);
374
- const waiting = doc.status !== 'open' ? [] : [...threads.values()].flatMap(t => {
375
- const e = t.at(-1);
376
- return e.op === 'comment' && ((e.by === 'agent' && e.ask) || e.note)
377
- ? [{ thread: e.thread, kind: e.signoff ? 'sign-off' : e.ask ? 'ask' : 'note', for: e.to ?? runner.by, by: e.by, seq: e.seq, item: t[0].item, ref: t[0].ref, text: e.text }] : [];
393
+ const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, runner, waiting: w } = await get(at);
394
+ const waiting = w.map(({ who, seq }) => {
395
+ const e = log[seq - 1], first = log.find(x => `c${x.seq}` === e.thread);
396
+ return { comment: `c${seq}`, thread: e.thread, kind: e.ask ? 'ask' : 'note', for: who, by: e.by, item: first.item, ref: first.ref, text: e.text };
378
397
  });
379
- const done = log.findLast(e => e.op === 'done'), report = done && log.findLast(e => e.op === 'report' && e.run === done.run);
380
- const last = done ? { run: done.run, cost: done.cost, summary: done.summary ?? null, error: done.error ?? null, report: report?.text ?? null } : null;
398
+ const done = log.findLast(e => e.op === 'done'), last = done ? { run: done.run, cost: done.cost, error: done.error ?? null } : null;
381
399
  if (flags.json) console.log(JSON.stringify({ path: args[0], id: inst.id, status: doc.status, runner: runner.by, running: run, queued, items: doc.items, waiting, last_run: last }, null, 1));
382
400
  else {
383
401
  console.log(`${args[0]} ${doc.status}, runner ${runner.by}${run ? `, run ${run.n} going, ${usd(run.cost)}` : queued ? ', queued' : ''}`);
384
402
  for (const i of doc.items) console.log(` ${i.kind.padEnd(6)} ${i.id} ${i.name} ${i.file ?? 'no file yet'}${i.from?.length ? ` from ${i.from.join(', ')}` : ''}${i.headline ? ` ${i.headline}` : ''}`);
385
- for (const w of waiting) console.log(`${w.thread} ${w.kind} for ${w.for}${w.item ? `, on ${w.item}${w.ref ? ` at ${w.ref}` : ''}` : ''}, seq ${w.seq}: ${w.text.split('\n')[0].slice(0, 160)}`);
386
- if (last) console.log(`last run ${last.run} ${usd(last.cost ?? 0)} ${last.error ?? last.summary ?? 'no report'}`);
403
+ for (const w of waiting) console.log(`${w.comment} ${w.kind} for ${w.for}${w.comment === w.thread ? '' : ` in ${w.thread}`}${w.item ? `, on ${w.item}${w.ref ? ` at ${w.ref}` : ''}` : ''}: ${w.text.split('\n')[0].slice(0, 160)}`);
404
+ if (last) console.log(`last run ${last.run} ${usd(last.cost ?? 0)}${last.error ? ` ${last.error}` : ''}`);
387
405
  }
388
406
  } else if (cmd === 'log' && args.length === 1) {
389
407
  const { at } = await instanceAt(args[0]);
@@ -403,7 +421,7 @@ if (cmd === 'login' && url) {
403
421
  } else if (cmd === 'pull' && args.length === 2) await pull(args[0], args[1]);
404
422
  else if (cmd === 'comment' && args.length === 2) {
405
423
  const { at } = await instanceAt(args[0]);
406
- await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread });
424
+ await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
407
425
  const { log, runner } = await get(at), { seq, note } = log.at(-1);
408
426
  if (note) console.log(`a note for the runner, ${runner.by}, seq ${seq}: it starts no run until they act`);
409
427
  else if (!flags.wait) console.log(`commented, seq ${seq}`);
@@ -413,19 +431,21 @@ else if (cmd === 'comment' && args.length === 2) {
413
431
  const log = (await get(at)).log, done = log.find(e => e.op === 'done' && e.seen >= seq);
414
432
  if (!done) continue;
415
433
  const from = Math.max(seq, log.find(e => e.op === 'run' && e.run === done.run).seq);
416
- for (const e of log.filter(e => e.seq > from && e.seq < done.seq && ((e.op === 'comment' && e.by === 'agent') || e.op === 'report'))) console.log(`${e.op === 'report' ? 'Report' : `${e.ask ? 'Asks' : 'Says'} in ${e.thread}`}:\n${e.text}\n`);
434
+ for (const e of log.filter(e => e.seq > from && e.seq < done.seq && e.op === 'comment' && e.by === 'agent')) console.log(`${e.ask ? 'Asks' : 'Says'} in ${e.thread}:\n${e.text}\n`);
417
435
  if (done.error) console.log(`The run failed: ${done.error}`);
418
436
  break;
419
437
  }
420
- } else if (cmd === 'resolve' && [2, 3].includes(args.length)) {
421
- console.log(await (await post(`${(await instanceAt(args[0])).at}/resolve`, { thread: args[1], text: args[2] })).text());
422
- } else if (cmd === 'signoff' && ['approve', 'reject'].includes(args[2]) && args.length <= 4) {
423
- await post(`${(await instanceAt(args[0])).at}/signoff`, { thread: args[1], approved: args[2] === 'approve', text: args[3] });
424
- console.log(`${args[2] === 'approve' ? 'approved' : 'rejected'} ${args[1]}`);
438
+ } else if (cmd === 'react' && [2, 3].includes(args.length) && ['up', 'down', 'none'].includes(args.at(-1) )) {
439
+ const on = args.length === 3 ? Number(args[1].replace(/^c/, '')) : undefined, up = { up: true, down: false, none: null }[args.at(-1) ];
440
+ await post(`${(await instanceAt(args[0])).at}/react`, { ...(on !== undefined && { on }), up });
441
+ console.log(`${args.at(-1)} on ${args.length === 3 ? args[1] : args[0]}`);
442
+ } else if (cmd === 'signoff' && [2, 3].includes(args.length)) {
443
+ await post(`${(await instanceAt(args[0])).at}/signoff`, { thread: args[1], text: args[2], quiet: !flags.wake });
444
+ console.log(`signed off ${args[1]}`);
425
445
  } else if (['close', 'abandon', 'interrupt'].includes(cmd) && args.length === 1) {
426
446
  const { series, at } = await instanceAt(args[0]);
427
447
  if (cmd === 'close' && typeof flags['as-series'] === 'string') await post(`/api/series/${series.id}/promote`, { name: flags['as-series'] });
428
- await post(`${at}/${cmd}`, {});
448
+ await post(`${at}/${cmd}`, { quiet: !flags.wake });
429
449
  console.log(`${cmd === 'close' ? 'closed' : `${cmd}ed`} ${args[0]}`);
430
450
  } else if (cmd === 'takeover' && args.length === 1) {
431
451
  await post(`${(await instanceAt(args[0])).at}/takeover`, { logins: ticks() });
@@ -450,10 +470,10 @@ else if (cmd === 'comment' && args.length === 2) {
450
470
  } else if (cmd === 'new' && args[0] === 'task' && [2, 3].includes(args.length)) {
451
471
  const { instance } = await (await post('/api/series', { workspace: (await workspaceNamed(args[1])).id, single: true, logins: ticks() })).json();
452
472
  if (args[2]) await post(`/api/instances/${instance}/rename?as=${encodeURIComponent(args[2])}`, {});
453
- if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment });
473
+ if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment, quiet: !flags.wake });
454
474
  console.log(`made ${await pathOf(instance)}${consent(ticks())}`);
455
475
  } else if (cmd === 'new' && args[0] === 'instance' && args.length === 3) {
456
- const { id } = await (await post(`/api/series/${(await seriesAt(args[1])).id}`, { label: args[2], logins: ticks() })).json();
476
+ const { id } = await (await post(`/api/series/${(await seriesAt(args[1])).id}`, { label: args[2], logins: ticks(), quiet: !flags.wake })).json();
457
477
  console.log(`made ${await pathOf(id)}${consent(ticks())}`);
458
478
  } else if (cmd === 'new' && args[0] === 'series' && args.length === 3) {
459
479
  await post(`/api/series/${(await find(args[1])).series.id}/promote`, { name: args[2] });
@@ -473,7 +493,7 @@ else if (cmd === 'comment' && args.length === 2) {
473
493
  console.log(`${flags.undo ? 'brought back' : 'archived'} ${args[0]}`);
474
494
  } else if (cmd === 'request' && ['start', 'drop'].includes(args[0]) && args.length === 2) {
475
495
  if (args[0] === 'drop') await api(`/api/requests/${args[1]}`, { method: 'DELETE' });
476
- console.log(args[0] === 'drop' ? `dropped request ${args[1]}` : `made ${await pathOf((await (await post(`/api/requests/${args[1]}`, { logins: ticks() })).json()).id)}${consent(ticks())}`);
496
+ console.log(args[0] === 'drop' ? `dropped request ${args[1]}` : `made ${await pathOf((await (await post(`/api/requests/${args[1]}`, { logins: ticks(), quiet: !flags.wake })).json()).id)}${consent(ticks())}`);
477
497
  } else if (cmd === 'logins' && !args.length) {
478
498
  const all = await get('/logins');
479
499
  if (flags.json) console.log(JSON.stringify(all, null, 1));
@@ -489,11 +509,29 @@ else if (cmd === 'comment' && args.length === 2) {
489
509
  else await post(`/logins/web/${encodeURIComponent(login)}/hosts`, { host: x });
490
510
  console.log(`${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches' }[what]} ${x}`);
491
511
  } else if (cmd === 'site' && args[0] === 'add' && args.length === 3) {
492
- await post('/logins/sites', { name: args[1], url: args[2] });
493
- console.log(`added ${args[1]}: sign in to it at ${url}/#logins`);
512
+ const { site, existing } = await (await post('/logins/sites', { name: args[1], url: args[2] })).json();
513
+ console.log(`${existing ? `${args[2]} is ${site}'s` : `added ${site}`}: sign in to it at ${url}/#logins, then rf site ask ${site} WORKSPACE REASON`);
514
+ } else if (cmd === 'site' && args[0] === 'set' && args.length === 2) {
515
+ await post(`/logins/sites/${encodeURIComponent(args[1])}`, flags, 'PATCH');
516
+ console.log('saved');
494
517
  } else if (cmd === 'site' && args[0] === 'remove' && args.length === 2) {
495
518
  await api(`/logins/sites/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
496
519
  console.log(`removed ${args[1]}`);
520
+ } else if (cmd === 'site' && args[0] === 'ask' && args.length === 4) {
521
+ const { id, check: c } = await (await post('/grants', { site: args[1], workspace: (await workspaceNamed(args[2])).id, reason: args[3] })).json();
522
+ 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}`
523
+ : `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(', ')}.` : ''}`}`);
524
+ } else if (cmd === 'grants' && args.length <= 1) {
525
+ const [all, ws] = await Promise.all([get('/grants'), get('/api')]), name = (id ) => ws.find(w => w.id === id)?.name ?? id;
526
+ const shown = all.filter(g => !args[0] || name(g.workspace) === args[0]);
527
+ if (flags.json) console.log(JSON.stringify(shown.map(g => ({ ...g, workspace: name(g.workspace) })), null, 1));
528
+ 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'})`);
529
+ } else if (cmd === 'grant' && ['approve', 'deny'].includes(args[0]) && [2, 3].includes(args.length)) {
530
+ await post(`/grants/${args[1]}`, { approve: args[0] === 'approve', text: args[2] });
531
+ console.log(args[0] === 'approve' ? 'approved' : 'denied');
532
+ } else if (cmd === 'grant' && args[0] === 'revoke' && args.length === 2) {
533
+ await api(`/grants/${args[1]}`, { method: 'DELETE' });
534
+ console.log('revoked');
497
535
  } else if (cmd === 'logins' && args[0] === 'signout' && args.length === 2) {
498
536
  await api(`/logins/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
499
537
  console.log(`signed out of ${args[1]}`);
@@ -502,7 +540,7 @@ else if (cmd === 'comment' && args.length === 2) {
502
540
  if (flags.see !== undefined && !see) throw new Error(`no instance ${flags.see} in its series`);
503
541
  console.log(await (await post(`${at}/correct`, { kind: flags.superseded ? 'superseded' : 'wrong', text: args[1], item: flags.item, ref: flags.ref, see: see?.id })).text());
504
542
  } else if (cmd === 'upload' && args.length === 2) {
505
- const q = new URLSearchParams({ name: basename(args[1]), pane: flags.output ? 'out' : 'in', ...(typeof flags.onto === 'string' && { onto: flags.onto }) });
543
+ const q = new URLSearchParams({ name: basename(args[1]), pane: flags.output ? 'out' : 'in', ...(typeof flags.onto === 'string' && { onto: flags.onto }), ...(!flags.wake && { quiet: '1' }) });
506
544
  await api(`${(await instanceAt(args[0])).at}/upload?${q}`, { method: 'POST', body: readFileSync(args[1]) });
507
545
  console.log('uploaded');
508
546
  } else if (cmd === 'wake' && typeof flags.cancel === 'string' && !args.length) {
@@ -553,9 +591,6 @@ else if (cmd === 'comment' && args.length === 2) {
553
591
  } else if (cmd === 'connection' && args[0] === 'set' && args.length === 3) {
554
592
  await post(`/connections/${encodeURIComponent(args[1])}`, { type: args[2], ...flags }, 'PUT');
555
593
  console.log('saved');
556
- } else if (cmd === 'connection' && ['off', 'on'].includes(args[0]) && args[1]) {
557
- await post(`/connections/${encodeURIComponent(args[1])}`, { off: args[0] === 'off' }, 'PATCH');
558
- console.log(args[0]);
559
594
  } else if (cmd === 'connection' && args[0] === 'remove' && args[1]) {
560
595
  await api(`/connections/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
561
596
  console.log('removed');
@@ -569,7 +604,7 @@ else if (cmd === 'comment' && args.length === 2) {
569
604
  [`Waiting`, [
570
605
  ...[...s.asks, ...s.requests.map(r => ({ ...r, who: r.who ?? 'anyone', since: r.at, text: `${r.from} asks to start ${r.label}`, request: true })),
571
606
  ...s.proposals.map(p => ({ who: `${p.to}'s owners`, 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`}`, proposal: true }))]
572
- .sort((a, b) => a.who.localeCompare(b.who) || a.since.localeCompare(b.since)).map(a => `${a.who} ${a.proposal ? 'a proposal' : a.request ? 'a request' : a.signoff ? 'a sign-off' : a.note ? 'a note' : 'an ask'} in ${a.path} since ${when(a.since)}: ${a.text.split('\n')[0].slice(0, 80)}`),
607
+ .sort((a, b) => a.who.localeCompare(b.who) || a.since.localeCompare(b.since)).map(a => `${a.who} ${a.proposal ? 'a proposal' : a.request ? 'a request' : a.note ? 'a note' : 'an ask'} in ${a.path} since ${when(a.since)}: ${a.text.split('\n')[0].slice(0, 80)}`),
573
608
  ...s.expired.map(e => `${e.who} their ${e.login} login expired${e.holding.length ? `, holding ${e.holding.join(', ')}` : ''}`),
574
609
  ]],
575
610
  [`Last run failed`, s.failed.map(f => `${f.path} run ${f.run} at ${when(f.at)}: ${f.error}`)],
@@ -586,7 +621,7 @@ else if (cmd === 'comment' && args.length === 2) {
586
621
  } else if (cmd === 'runs' && args.length <= 1) {
587
622
  const rows = (await runsIn(args[0])).filter(r => (!flags.failed || r.outcome === 'failed') && (!flags.running || r.outcome === 'running') && (!flags.long || r.seconds >= Number(flags.long) * 60));
588
623
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
589
- else for (const r of rows) console.log(`${when(r.at)} ${r.path} run ${r.run} ${r.outcome}${r.failure ? ` (${r.failure})` : ''} ${took(r.seconds)} ${usd(r.cost)} ${r.started ? `${r.started.op} by ${r.started.by}` : '-'} ${r.error ?? r.summary ?? ''}`);
624
+ else for (const r of rows) console.log(`${when(r.at)} ${r.path} run ${r.run} ${r.outcome}${r.failure ? ` (${r.failure})` : ''} ${took(r.seconds)} ${usd(r.cost)} ${r.started ? `${r.started.op} by ${r.started.by}` : '-'} ${r.error ?? ''}`);
590
625
  } else if (cmd === 'costs' && args.length <= 1) {
591
626
  const by = String(flags.by ?? 'series'), key = {
592
627
  workspace: r => r.path.split('/')[0], series: r => r.path.split('/').slice(0, 2).join('/'), person: r => r.runner, day: r => when(r.at).slice(0, 10),
@@ -620,7 +655,7 @@ else if (cmd === 'comment' && args.length === 2) {
620
655
  if (flags.json) console.log(JSON.stringify(blocks, null, 1));
621
656
  else for (const b of blocks) {
622
657
  console.log(b.path);
623
- for (const e of b.entries) console.log(` ${when(e.at)} ${e.op === 'done' ? `run ${e.run} ${e.error ?? e.summary ?? 'no report'}`
658
+ for (const e of b.entries) console.log(` ${when(e.at)} ${e.op === 'done' ? `run ${e.run} failed: ${e.error}`
624
659
  : `${e.by} ${e.op === 'comment' ? `says: ${e.text.split('\n')[0].slice(0, 200)}` : e.op === 'upload' ? `uploads ${e.file}` : `${e.op === 'close' ? 'closes' : 'abandons'} it`}`}`);
625
660
  }
626
661
  } else if (cmd === 'people' && args.length <= 1) {