@rfany/rf 0.11.0 → 0.13.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 +125 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.11.0",
3
+ "version": "0.13.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,18 @@ 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 egress [add|remove HOST] the hosts runs may reach beyond package registries, GitHub and documentation sites, such as
118
+ api.example.com or *.example.org; admins add and remove them
119
+ rf connection set NAME TYPE an outside system runs reach as their runner, by a login each person makes: graph,
120
+ Microsoft 365, or databricks, Azure Databricks, as each person adds what their login
121
+ offers; websites are rf site's
105
122
  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
123
  rf brand [--text TEXT] [--logo FILE] [--clear] the deployment's text and logo, a .png, .jpg, .gif, .webp or .svg, which top
108
124
  the sidebar and are the page's title and icon; --clear goes back to the plain look, and with
109
125
  no option it prints them
110
126
  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
127
+ create, make workspaces; and keepalive, keep their website logins alive for up to a
128
+ week as they sign in; a list grants CAP to those
113
129
  emails and Entra group ids in place of whom it had, --clear to no one, and with neither it
114
130
  prints whom each is granted to`;
115
131
 
@@ -120,23 +136,27 @@ COMMAND gives one's usage, every read takes --json, and a failure is one line on
120
136
  What there is
121
137
  - A workspace holds series, and its people. A series is one recurring job; an instance is one period of it, labelled such as
122
138
  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.
139
+ - An instance's screen is its items: inputs, outputs and steps, each pointing at a file, with what it's made from. People upload
140
+ files, and review the work in threads with the agent. The runner is the person whose logins the runs use, and who closes the
141
+ 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
142
+ 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
143
+ does.
144
+ - rf is quiet: a comment, upload, sign-off, close, new instance or request it starts begins no run unless --wake, and the agent
145
+ 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.
146
+ - 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
147
+ 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
148
+ comment that waits on someone, the one it names or else the runner, until someone replies under it. rf ls says how many asks
149
+ wait in each instance. Reactions, thumbs up or down, are quiet signals kept for later. An ask
150
+ may pin files, kept with their sha256 as the agent asks; anyone who sees the instance may sign it off, which commits the
151
+ instance's folder to its history, .git in it, as closing does. Whose sign-off counts, and for what, is the series' call.
131
152
 
132
153
  What rf pull copies, the folders as the agent sees them
133
154
  AGENTS.md the company's conventions; <workspace>/AGENTS.md the workspace's
134
155
  <workspace>/<series>/<label>/
135
- screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source}]}
156
+ screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source, destination, as_of}]}
136
157
  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
158
+ ref, parent, text, files, ask, to), signoff (someone's, on the ask it names, with its commit), react,
159
+ commit, point and item (the screen changing), run, done (its cost, or error), close, and the rest
140
160
  upload/ what people uploaded, their comments' attachments in upload/attachments/
141
161
  working/ what the agent made, its scripts, and process.md, how it does this series
142
162
  session/ each session's transcript, which may carry several runs: every message and tool call
@@ -148,15 +168,17 @@ What rf pull copies, the folders as the agent sees them
148
168
  The copy is read-only: only rf's commands change what's on the server.
149
169
 
150
170
  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.
171
+ - What waits on me: rf waiting, then rf show PATH, which names each comment that waits by its id.
172
+ - Answer an ask: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back; sign off one that pins files:
173
+ rf signoff PATH cN [TEXT] --wake, for the agent to carry on. Close an
174
+ instance once it's the record: rf close PATH.
154
175
  - Take an instance over: rf creds PATH lists the offers of your logins, and rf takeover PATH --creds OFFER,... ticks them.
155
176
  - 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.
177
+ - Give an input or a corrected output: rf upload PATH FILE [--onto ITEM] [--output], with --wake on the last for a run on them
178
+ all.
179
+ - Start an instance: rf new instance SERIES LABEL --wake, as you, or rf wake SERIES now --label LABEL, which starts it as
180
+ 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
181
+ one-off: rf new task WORKSPACE --comment TEXT --wake, which becomes a series with rf new series PATH NAME.
160
182
  - 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
183
  for a file; rf pull PATH/ DIR copies the folder, with session/ for every step.
162
184
 
@@ -167,7 +189,7 @@ Watching over it, for admins and power users; each sees what the caller sees
167
189
  - 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
190
  person whether it is crawling or following changes, pages read, when last caught up, and an error, if any, with its next try.
169
191
  - 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
192
+ outcome, time taken, cost, what started it and by whom, and any error. rf costs [PATH] [--since DATE] [--by
171
193
  workspace|series|person|day] totals them, by the runner for person.
172
194
  - People: rf people (admins) prints everyone as ROLE EMAIL lines, and rf people WORKSPACE (its owners and admins) its owners and
173
195
  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 +207,7 @@ const flags = {}, excludes = [], args
185
207
  for (let i = 0; i < argv.length; i++) {
186
208
  const flag = argv[i] === '-n' ? 'dry-run' : argv[i].match(/^--(.+)$/)?.[1];
187
209
  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;
210
+ else if (['wait', 'wake', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo', 'by-amount'].includes(flag)) flags[flag] = true;
189
211
  else if (argv[i + 1] === undefined) throw new Error(`--${flag} takes a value`);
190
212
  else if (flag === 'exclude') excludes.push(argv[++i]);
191
213
  else flags[flag] = argv[++i];
@@ -360,30 +382,28 @@ if (cmd === 'login' && url) {
360
382
  const [me, s, all] = await Promise.all([get('/me'), get('/api/status'), get('/api')]), mine = (who ) => (who ?? me.email) === me.email;
361
383
  const series = all.flatMap(w => w.series.map(x => ({ ...x, path: `${w.name}/${x.name}` })));
362
384
  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 })),
385
+ ...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
386
  ...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
387
  ...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
388
  ...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
389
  ...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(', ')}` })))),
390
+ ...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
391
  ];
369
392
  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.');
393
+ 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
394
  } 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 }] : [];
395
+ const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, runner, waiting: w } = await get(at);
396
+ const waiting = w.map(({ who, seq }) => {
397
+ const e = log[seq - 1], first = log.find(x => `c${x.seq}` === e.thread);
398
+ 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
399
  });
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;
400
+ const done = log.findLast(e => e.op === 'done'), last = done ? { run: done.run, cost: done.cost, error: done.error ?? null } : null;
381
401
  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
402
  else {
383
403
  console.log(`${args[0]} ${doc.status}, runner ${runner.by}${run ? `, run ${run.n} going, ${usd(run.cost)}` : queued ? ', queued' : ''}`);
384
404
  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'}`);
405
+ 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)}`);
406
+ if (last) console.log(`last run ${last.run} ${usd(last.cost ?? 0)}${last.error ? ` ${last.error}` : ''}`);
387
407
  }
388
408
  } else if (cmd === 'log' && args.length === 1) {
389
409
  const { at } = await instanceAt(args[0]);
@@ -403,7 +423,7 @@ if (cmd === 'login' && url) {
403
423
  } else if (cmd === 'pull' && args.length === 2) await pull(args[0], args[1]);
404
424
  else if (cmd === 'comment' && args.length === 2) {
405
425
  const { at } = await instanceAt(args[0]);
406
- await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread });
426
+ await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
407
427
  const { log, runner } = await get(at), { seq, note } = log.at(-1);
408
428
  if (note) console.log(`a note for the runner, ${runner.by}, seq ${seq}: it starts no run until they act`);
409
429
  else if (!flags.wait) console.log(`commented, seq ${seq}`);
@@ -413,19 +433,21 @@ else if (cmd === 'comment' && args.length === 2) {
413
433
  const log = (await get(at)).log, done = log.find(e => e.op === 'done' && e.seen >= seq);
414
434
  if (!done) continue;
415
435
  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`);
436
+ 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
437
  if (done.error) console.log(`The run failed: ${done.error}`);
418
438
  break;
419
439
  }
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]}`);
440
+ } else if (cmd === 'react' && [2, 3].includes(args.length) && ['up', 'down', 'none'].includes(args.at(-1) )) {
441
+ const on = args.length === 3 ? Number(args[1].replace(/^c/, '')) : undefined, up = { up: true, down: false, none: null }[args.at(-1) ];
442
+ await post(`${(await instanceAt(args[0])).at}/react`, { ...(on !== undefined && { on }), up });
443
+ console.log(`${args.at(-1)} on ${args.length === 3 ? args[1] : args[0]}`);
444
+ } else if (cmd === 'signoff' && [2, 3].includes(args.length)) {
445
+ await post(`${(await instanceAt(args[0])).at}/signoff`, { thread: args[1], text: args[2], quiet: !flags.wake });
446
+ console.log(`signed off ${args[1]}`);
425
447
  } else if (['close', 'abandon', 'interrupt'].includes(cmd) && args.length === 1) {
426
448
  const { series, at } = await instanceAt(args[0]);
427
449
  if (cmd === 'close' && typeof flags['as-series'] === 'string') await post(`/api/series/${series.id}/promote`, { name: flags['as-series'] });
428
- await post(`${at}/${cmd}`, {});
450
+ await post(`${at}/${cmd}`, { quiet: !flags.wake });
429
451
  console.log(`${cmd === 'close' ? 'closed' : `${cmd}ed`} ${args[0]}`);
430
452
  } else if (cmd === 'takeover' && args.length === 1) {
431
453
  await post(`${(await instanceAt(args[0])).at}/takeover`, { logins: ticks() });
@@ -450,10 +472,10 @@ else if (cmd === 'comment' && args.length === 2) {
450
472
  } else if (cmd === 'new' && args[0] === 'task' && [2, 3].includes(args.length)) {
451
473
  const { instance } = await (await post('/api/series', { workspace: (await workspaceNamed(args[1])).id, single: true, logins: ticks() })).json();
452
474
  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 });
475
+ if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment, quiet: !flags.wake });
454
476
  console.log(`made ${await pathOf(instance)}${consent(ticks())}`);
455
477
  } 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();
478
+ const { id } = await (await post(`/api/series/${(await seriesAt(args[1])).id}`, { label: args[2], logins: ticks(), quiet: !flags.wake })).json();
457
479
  console.log(`made ${await pathOf(id)}${consent(ticks())}`);
458
480
  } else if (cmd === 'new' && args[0] === 'series' && args.length === 3) {
459
481
  await post(`/api/series/${(await find(args[1])).series.id}/promote`, { name: args[2] });
@@ -473,7 +495,7 @@ else if (cmd === 'comment' && args.length === 2) {
473
495
  console.log(`${flags.undo ? 'brought back' : 'archived'} ${args[0]}`);
474
496
  } else if (cmd === 'request' && ['start', 'drop'].includes(args[0]) && args.length === 2) {
475
497
  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())}`);
498
+ 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
499
  } else if (cmd === 'logins' && !args.length) {
478
500
  const all = await get('/logins');
479
501
  if (flags.json) console.log(JSON.stringify(all, null, 1));
@@ -489,11 +511,29 @@ else if (cmd === 'comment' && args.length === 2) {
489
511
  else await post(`/logins/web/${encodeURIComponent(login)}/hosts`, { host: x });
490
512
  console.log(`${login} ${{ offer: 'offers', unoffer: 'no longer offers', allow: 'reaches' }[what]} ${x}`);
491
513
  } 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`);
514
+ const { site, existing } = await (await post('/logins/sites', { name: args[1], url: args[2] })).json();
515
+ console.log(`${existing ? `${args[2]} is ${site}'s` : `added ${site}`}: sign in to it at ${url}/#logins, then rf site ask ${site} WORKSPACE REASON`);
516
+ } else if (cmd === 'site' && args[0] === 'set' && args.length === 2) {
517
+ await post(`/logins/sites/${encodeURIComponent(args[1])}`, flags, 'PATCH');
518
+ console.log('saved');
494
519
  } else if (cmd === 'site' && args[0] === 'remove' && args.length === 2) {
495
520
  await api(`/logins/sites/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
496
521
  console.log(`removed ${args[1]}`);
522
+ } else if (cmd === 'site' && args[0] === 'ask' && args.length === 4) {
523
+ const { id, check: c } = await (await post('/grants', { site: args[1], workspace: (await workspaceNamed(args[2])).id, reason: args[3] })).json();
524
+ 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}`
525
+ : `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(', ')}.` : ''}`}`);
526
+ } else if (cmd === 'grants' && args.length <= 1) {
527
+ const [all, ws] = await Promise.all([get('/grants'), get('/api')]), name = (id ) => ws.find(w => w.id === id)?.name ?? id;
528
+ const shown = all.filter(g => !args[0] || name(g.workspace) === args[0]);
529
+ if (flags.json) console.log(JSON.stringify(shown.map(g => ({ ...g, workspace: name(g.workspace) })), null, 1));
530
+ 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'})`);
531
+ } else if (cmd === 'grant' && ['approve', 'deny'].includes(args[0]) && [2, 3].includes(args.length)) {
532
+ await post(`/grants/${args[1]}`, { approve: args[0] === 'approve', text: args[2] });
533
+ console.log(args[0] === 'approve' ? 'approved' : 'denied');
534
+ } else if (cmd === 'grant' && args[0] === 'revoke' && args.length === 2) {
535
+ await api(`/grants/${args[1]}`, { method: 'DELETE' });
536
+ console.log('revoked');
497
537
  } else if (cmd === 'logins' && args[0] === 'signout' && args.length === 2) {
498
538
  await api(`/logins/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
499
539
  console.log(`signed out of ${args[1]}`);
@@ -502,7 +542,7 @@ else if (cmd === 'comment' && args.length === 2) {
502
542
  if (flags.see !== undefined && !see) throw new Error(`no instance ${flags.see} in its series`);
503
543
  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
544
  } 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 }) });
545
+ 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
546
  await api(`${(await instanceAt(args[0])).at}/upload?${q}`, { method: 'POST', body: readFileSync(args[1]) });
507
547
  console.log('uploaded');
508
548
  } else if (cmd === 'wake' && typeof flags.cancel === 'string' && !args.length) {
@@ -553,9 +593,6 @@ else if (cmd === 'comment' && args.length === 2) {
553
593
  } else if (cmd === 'connection' && args[0] === 'set' && args.length === 3) {
554
594
  await post(`/connections/${encodeURIComponent(args[1])}`, { type: args[2], ...flags }, 'PUT');
555
595
  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
596
  } else if (cmd === 'connection' && args[0] === 'remove' && args[1]) {
560
597
  await api(`/connections/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
561
598
  console.log('removed');
@@ -569,7 +606,7 @@ else if (cmd === 'comment' && args.length === 2) {
569
606
  [`Waiting`, [
570
607
  ...[...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
608
  ...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)}`),
609
+ .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
610
  ...s.expired.map(e => `${e.who} their ${e.login} login expired${e.holding.length ? `, holding ${e.holding.join(', ')}` : ''}`),
574
611
  ]],
575
612
  [`Last run failed`, s.failed.map(f => `${f.path} run ${f.run} at ${when(f.at)}: ${f.error}`)],
@@ -586,7 +623,7 @@ else if (cmd === 'comment' && args.length === 2) {
586
623
  } else if (cmd === 'runs' && args.length <= 1) {
587
624
  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
625
  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 ?? ''}`);
626
+ 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
627
  } else if (cmd === 'costs' && args.length <= 1) {
591
628
  const by = String(flags.by ?? 'series'), key = {
592
629
  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,9 +657,13 @@ else if (cmd === 'comment' && args.length === 2) {
620
657
  if (flags.json) console.log(JSON.stringify(blocks, null, 1));
621
658
  else for (const b of blocks) {
622
659
  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'}`
660
+ for (const e of b.entries) console.log(` ${when(e.at)} ${e.op === 'done' ? `run ${e.run} failed: ${e.error}`
624
661
  : `${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
662
  }
663
+ } else if (cmd === 'egress' && (!args.length || (args.length === 2 && ['add', 'remove'].includes(args[0])))) {
664
+ let hosts = await (await api('/egress')).json();
665
+ 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();
666
+ console.log(hosts.join('\n'));
626
667
  } else if (cmd === 'people' && args.length <= 1) {
627
668
  // People as lines to edit and set: ROLE EMAIL for everyone, owner|member EMAIL-OR-GROUP for a workspace, each with a comment.
628
669
  const ws = args[0] === undefined ? undefined : await workspaceNamed(args[0]);