@rfany/rf 0.16.0 → 0.17.1

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 (3) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/rf.mjs +97 -88
package/README.md CHANGED
@@ -8,6 +8,8 @@ People's command line for [rollforward](https://github.com/spoj/rollforward): wh
8
8
  rf opens the page, which asks you to allow it if it shows the same code as rf; or make a token on the page, under Tokens, and
9
9
  `rf login URL TOKEN`. `rf` alone lists the commands and `rf help COMMAND` gives one's usage; `rf help` is the guide for an agent, read before it first uses rf. Without saved config, help works offline; once signed in, it reads your current capabilities from the server.
10
10
 
11
+ `rf series owner WORKSPACE/SERIES EMAIL` explicitly transfers the whole series, not one instance; only its current owner or a workspace manager may do it. Old runs stop and execution consent is cleared. The incoming owner selects a series-wide ceiling with `rf series credentials WORKSPACE/SERIES --set OFFER,... --autonomous false`, or `--clear` for an explicit empty selection. The owner's acts and answers by whom the agent's ask named start runs under current consent. Other collaborators' words stay notes. Scheduled/autonomous execution needs `--autonomous true`. `rf new instance` never changes credentials; `rf new task` without `--creds` or `--clear` establishes no execution consent.
12
+
11
13
  `rf site ask NAME WORKSPACE REASON` asks its owners to use your login there, or approves it at once where you may. `rf grants` describes the system and what runs may do; general platforms and high-risk or failed checks need an admin. Only admins allow hosts, with `rf logins allow SITE HOST --person EMAIL`; you remove one with `rf logins disallow SITE HOST`.
12
14
 
13
15
  On servers with client VPN support, only people explicitly granted `vpn` see its commands in help; being an admin is not enough. `rf vpns` lists definitions and your connection states; sign in on the page. `rf site set NAME --via VPN` selects one for your website, `--via ''` clears it, and `rf sites` shows it. Opted-in admins manage definitions with `rf vpn add NAME fortinet HOST:PORT [--servercert pin-sha256:HASH]` and `rf vpn remove NAME`; admins grant access with `rf can vpn EMAIL|GROUP,...` and revoke it with `rf can vpn --clear`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.16.0",
3
+ "version": "0.17.1",
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,9 +14,9 @@ process.on('uncaughtException', e => {
14
14
 
15
15
  const usage = (c , vpn = false, admin = false) => {
16
16
  const all = `rf login URL [TOKEN] without a TOKEN, through the browser: type rf's code on the page, and allow it
17
- rf ls [--mine] [--json] every workspace, series and instance you see, with its status, runner, asks waiting and wakes;
18
- --mine, only the open instances you run
19
- rf waiting [--json] what waits on you: asks and notes, instances someone assigned you, requests to start or wake an
17
+ rf ls [--mine] [--json] every workspace, series and instance you see, with its status, owner, asks waiting and wakes;
18
+ --mine, only open instances of series you own
19
+ rf waiting [--json] what waits on you: asks and notes, requests to start or wake an
20
20
  instance or to use a
21
21
  website in a workspace you own, proposals and expired logins; only admins see hosts a run's
22
22
  browser was refused that the server rates high or finds at an internal address
@@ -32,39 +32,38 @@ rf pull PATH DIR [--delete] [-n|--dry-run] [--exclude PATTERN]... [--max-size SI
32
32
  rf help [COMMAND] how rollforward works and how to use rf, for an agent, or COMMAND's usage
33
33
  rf --version rf's own version, to tell whether it's older than what the guide names
34
34
  rf comment PATH TEXT [--item ID] [--ref REF] [--thread cN] [--wake|--wait] a new thread, or a reply under comment cN, as to
35
- an agent's question; --wake starts a run on it, as --wait does, which prints what the agent
36
- says back
35
+ an agent's question; --wake or --wait starts a run for the owner or an answer to the agent's named ask,
36
+ under current consent; --wait prints what the agent says back
37
37
  rf upload PATH FILE [--onto ITEM] [--output] [--wake]
38
- rf approve PATH cN [TEXT] [--wake] approves the agent's proposal cN: it goes ahead with it, and the folder is
39
- committed as it is now, in your name; a reply approves nothing
40
- rf reject PATH cN [TEXT] [--wake] rejects the agent's proposal cN: it won't do it, and carries on as TEXT says
38
+ rf approve PATH cN [TEXT] [--wake] records content approval of proposal cN, not permission to run as you; the folder is
39
+ committed as it is now, in your name
40
+ rf reject PATH cN [TEXT] [--wake] rejects the agent's proposal cN, with feedback on missing information or changes;
41
+ revised work takes a new proposal
41
42
  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
42
- rf close PATH [--as-series NAME] [--wake] the runner makes it the record and an example,
43
+ rf close PATH [--as-series NAME] [--wake] the series owner makes it the record and an example,
43
44
  approving nothing; a task closes as a one-off, or as the first instance of the series NAME it
44
45
  becomes; --wake starts runs of the series' later open instances, which may have used its draft
45
- rf abandon PATH the runner leaves it as it is, neither an example nor a starting point
46
+ rf abandon PATH the series owner leaves it as it is, neither an example nor a starting point
46
47
  rf delete PATH [--yes] its workspace's owners and admins delete an instance, in any status, once they confirm, or
47
48
  with --yes: a run for it is cut, and all the server holds of it goes but its label and place,
48
49
  shown as deleted, by whom and when; it can't be undone, and copies outside the server stay
49
- rf interrupt PATH stops its run: its runner, an owner of its workspace or an admin
50
- rf takeover PATH [--creds OFFER,...] you run it from now on, with those offers of your logins ticked; a run going is stopped
51
- first, if you may stop it
52
- rf assign PATH EMAIL EMAIL runs it from now on, ticking their own logins, none until they do: its runner, its
53
- workspace's owners and admins; a run going is stopped first
54
- rf creds PATH [--set OFFER,...|--clear] what its runs may use: its runner's ticks, and the offers of your logins; --set
55
- ticks anew, as its runner
50
+ rf interrupt PATH stops its run: its series owner, an owner of its workspace or an admin
51
+ rf series owner SERIES [EMAIL] [--json] the whole series' owner; EMAIL transfers every instance, stopping old runs and
52
+ clearing consent; only its current owner or a workspace manager may transfer it
53
+ rf series credentials SERIES [--set OFFER,...|--clear] [--autonomous true|false] [--json]
54
+ credentials for every instance; only the owner saves consent, explicitly including [] with
55
+ --clear; saving requires --autonomous true|false; no credentials or schedules transfer
56
56
  rf rename PATH NAME an instance, a series or a workspace, by its path
57
- rf new task WORKSPACE [LABEL] [--creds OFFER,...] [--comment TEXT [--wake]] a one-off task, Untitled until LABEL or its
58
- first comment names it; --wake starts its run on the comment
59
- rf new instance SERIES LABEL [--creds OFFER,...] [--wake] the series' next instance, which --wake runs at once
57
+ rf new task WORKSPACE [LABEL] [--creds OFFER,...|--clear] [--autonomous true|false] [--comment TEXT [--wake]] a one-off task, Untitled until LABEL or its
58
+ first comment names it; --wake starts its run on the comment; without --creds or --clear,
59
+ no execution consent is granted; --clear explicitly permits work with no credentials
60
+ rf new instance SERIES LABEL [--wake] another instance; anyone in the workspace may create it; only the owner starts it with --wake
60
61
  rf new series PATH NAME the task at PATH becomes the series NAME, itself its first instance
61
62
  rf new workspace NAME yours to own, for admins and those they grant create
62
- rf share PATH on|off [--creds OFFER,...] the series' people, and their agents, wake it as you, with those offers ticked;
63
- off stops it, for its sharer or its workspace's owners
64
63
  rf archive PATH [--undo] a workspace or a series leaves the sidebar, and nothing in it changes or runs, until --undo brings it back;
65
64
  its wakes and requests are cancelled for good
66
- rf request start|drop ID [--creds OFFER,...] [--wake] a request to start or wake an instance, by the ID rf waiting and rf
67
- wakes print; --wake runs the instance it starts or wakes
65
+ rf request start|drop ID [--wake] a request to start or wake an instance, by the ID rf waiting and rf
66
+ wakes print; only the target's current owner may Start; --wake runs it with existing series consent
68
67
  rf logins [--json] your logins, each with its state, keepalive and offers; you sign in to them on the page
69
68
  rf logins offer|unoffer LOGIN SOURCE|OFFER what a login offers runs: Microsoft 365's (m365) mailboxes, sites, folders and
70
69
  files, by address or link, a Databricks login's SQL warehouses, by link; unoffer takes the
@@ -99,8 +98,9 @@ rf correct PATH TEXT [--item ID] [--ref REF] [--superseded] [--see LABEL] a cl
99
98
  wrong, or superseded, as LABEL, another instance of its series, shows; it can't be withdrawn
100
99
  rf wake PATH AT [TEXT] [--label LABEL] [--days DAYS] | rf wake --cancel ID
101
100
  AT now, +<n>m|h|d or a date; PATH an open instance, or a series with LABEL; TEXT a short
102
- message for the run it starts; DAYS, such as mon-fri, repeats it weekly at AT's time; rf ls
103
- shows each wake's ID
101
+ message for the run; the owner's now starts under current consent without autonomous opt-in;
102
+ later or agent-set wakes need it. Collaborators' wakes are requests. DAYS, such as mon-fri,
103
+ repeats weekly at AT's time; rf ls shows each wake's ID
104
104
  rf note SERIES [TEXT] [--json] tells the series something for its runs, about the series rather than one period or while no
105
105
  instance is open, which starts no run; without TEXT, its notes, open and settled
106
106
  rf agents [WORKSPACE] [--set FILE|-] the company's AGENTS.md, or a workspace's; setting the company's is for admins
@@ -128,7 +128,7 @@ rf wakes [PATH] [--json] each series' pending wakes and requests to sta
128
128
  fired, and each instance's pending wakes
129
129
  rf people WORKSPACE [--set FILE|-] [-n] [--force] its owners and admins: its people as lines of owner|member EMAIL-OR-GROUP,
130
130
  each with a comment; --set replaces them, -n shows the changes, --force hides open instances
131
- from their runners
131
+ from their series owners
132
132
 
133
133
  Admins, and those they grant publish:
134
134
  rf skill push DIR DIR/SKILL.md and the rest become the newest version of the skill named DIR's name, live at once
@@ -143,7 +143,7 @@ rf egress [add|remove HOST] the hosts runs may reach beyond package regist
143
143
  rf internal [remove HOST] [--json] the hosts at internal addresses admins let every website reach, each with who let it and
144
144
  when, as rf site set NAME --internal true or allowing one does; remove takes one out, after
145
145
  which everyone's websites at it wait for an admin again
146
- rf connection set NAME TYPE an outside system runs reach as their runner, by a login each person makes: graph,
146
+ rf connection set NAME TYPE an outside system runs reach as their series owner, by a login each person makes: graph,
147
147
  Microsoft 365, or databricks, Azure Databricks, as each person adds what their login
148
148
  offers; service --url http://HOST:PORT --paths 'AP/,GL/2026/' [--key KEY] lends paths
149
149
  through a deployment's service at https://NAME.rf.internal/; websites are rf site's
@@ -167,19 +167,21 @@ What there is
167
167
  - A workspace holds series, and its people. A series is one recurring job; an instance is one period of it, labelled such as
168
168
  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.
169
169
  - An instance's screen is its items: inputs, outputs and steps, each pointing at a file, with what it's made from. People upload
170
- files, and review the work in threads with the agent. The runner is the person whose logins the runs use, and who closes the
171
- 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
172
- runner shares the series, and a reply, approval or rejection from whom an ask names; anyone else's is a note, as are a wake someone else sets, another
173
- instance's agent's comment and rf note's notes on a series: the agent's next run reads it, using what it brings and putting what
174
- it asks for to the runner. The runner changes only by an assign, rf takeover or rf assign, which stops a run going: what came
175
- before it is a note to the agent, whoever said it, and starts nothing.
170
+ files, and review the work in threads with the agent. One series owner is accountable for every instance: only that person
171
+ closes and abandons. Their acts and answers by whom the agent's ask named start runs under current consent. Runs use the
172
+ owner's selected credentials, across every instance. Without consent, nothing runs; selecting none permits work with no
173
+ credentials. Scheduled and autonomous runs need a separate opt-in. Other collaborators' comments, uploads and approvals are notes that start nothing.
174
+ Transferring the whole series stops old runs and clears consent; old unread instructions become notes. Each act keeps
175
+ its author, and every run its executor.
176
176
  - rf is quiet: a comment, upload, approval, rejection, close, new instance or request it starts begins no run unless --wake, and the agent
177
- 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.
177
+ reads it at its next run. The owner's rf wake PATH now starts one under current consent, without autonomous opt-in.
178
+ A quiet upload or comment is committed to the instance's history at once.
178
179
  - 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
179
180
  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
180
- questions, which wait on someone, the one it names or else the runner, until a person replies under it, and proposes what it
181
- will do for its runner, such as sending mail, which waits until someone approves or rejects it, or the agent withdraws it; a
182
- reply under a proposal approves nothing. rf ls says how many asks wait in each instance. Reactions, thumbs up or down, are
181
+ questions, which wait on someone, the one it names or else the series owner, until a person replies under it, and proposes what it
182
+ will do for its series owner, such as sending mail, which waits until someone approves or rejects it, or the agent withdraws it; a
183
+ proposal missing information should be rejected with feedback, so the agent can revise and propose again. Generic comments
184
+ are not proposal decisions. rf ls says how many asks wait in each instance. Reactions, thumbs up or down, are
183
185
  quiet signals kept for later. Anyone who sees the instance may approve a proposal, which commits the instance's folder to its
184
186
  history, .git in it, as it is then, as closing does. Whose approval counts, and for what, is the series' call.
185
187
 
@@ -208,15 +210,15 @@ Usual work
208
210
  - Answer a question: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back. Decide a proposal:
209
211
  rf approve PATH cN [TEXT] --wake, for the agent to go ahead, or rf reject PATH cN [TEXT] --wake. Close an
210
212
  instance once it's the record: rf close PATH.
211
- - Take an instance over: rf creds PATH lists the offers of your logins, and rf takeover PATH --creds OFFER,... ticks them. Hand
212
- one you run, or one in a workspace you own, to someone else: rf assign PATH EMAIL; they tick their own logins with rf creds
213
- PATH --set. Either way, what came before is history to the agent, and the next run waits for the new runner's act.
213
+ - Transfer a whole series, as its current owner or workspace manager: rf series owner SERIES EMAIL. The incoming owner
214
+ selects credentials with rf series credentials SERIES --set OFFER,... --autonomous false, or --clear for none.
215
+ Every instance may use that selection: this is not an instance setting. No self-takeover right for collaborators.
214
216
  - Your logins: rf logins lists them, with what each offers, and an expired one's link to sign in again on the page.
215
217
  - Give an input or a corrected output: rf upload PATH FILE [--onto ITEM] [--output], with --wake on the last for a run on them
216
218
  all.
217
- - Start an instance: rf new instance SERIES LABEL --wake, as you, or rf wake SERIES now --label LABEL, which starts it as
218
- 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
219
- one-off: rf new task WORKSPACE --comment TEXT --wake, which becomes a series with rf new series PATH NAME.
219
+ - Start an instance: rf new instance SERIES LABEL --wake, only as the series owner. Scheduled wakes need that owner's
220
+ autonomous opt-in and keep their authorized credential snapshot; collaborators' wakes become requests for the owner.
221
+ A one-off: rf new task WORKSPACE --clear --comment TEXT --wake. Promotion with rf new series PATH NAME keeps its owner.
220
222
  - Tell a series something for its runs, such as a rule from now on, or while no instance is open: rf note SERIES TEXT, which
221
223
  starts no run; rf note SERIES lists its notes, open, and settled by a run or by hand.
222
224
  - 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
@@ -224,7 +226,7 @@ Usual work
224
226
 
225
227
  Watching over it, for admins and power users; each sees what the caller sees
226
228
  - What's stuck: rf status lists low OpenRouter credit (for admins), runs going, flagging those past --long MIN (30); queued runs, since when and why: their series is
227
- running, an update's drain, the RF_MAX_RUNS cap, or memory; what waits on whom since when: asks, notes for runners, expired logins and the instances
229
+ running, an update's drain, the RF_MAX_RUNS cap, or memory; what waits on whom since when: asks, notes for series owners, expired logins and the instances
228
230
  they hold, and requests to start; open instances whose last run failed; and indexes crawling or failing.
229
231
  - Indexes: rf indexes shows each index of a big library or mailbox you index, every one for admins: its items and size, and per
230
232
  person whether it is crawling or following changes, pages read, when last caught up, and an error, if any, with its next try.
@@ -233,11 +235,11 @@ Watching over it, for admins and power users; each sees what the caller sees
233
235
  workspace|series|person|day|outcome] [--daily] totals them (by the runner for person, plus server calls and OpenRouter key usage
234
236
  for admins). A DATE such as 2026-11-01 starts at its midnight on this machine's clock, the days --by day groups by.
235
237
  - People: rf people (admins) prints everyone as ROLE EMAIL lines, and rf people WORKSPACE (its owners and admins) its owners and
236
- members as owner|member lines; a comment after each says when they last signed in and which open instances they run, and for
237
- everyone those they run in workspaces they aren't in. Edit the lines, see the changes with --set FILE -n (FILE may be - for
238
+ members as owner|member lines; a comment after each says when they last signed in and which series they own, and for
239
+ everyone those they own in workspaces they aren't in. Edit the lines, see the changes with --set FILE -n (FILE may be - for
238
240
  stdin), then --set FILE. For everyone it sets the roles of the people listed and adds new ones, removing no one (rf user remove
239
- does); for a workspace it replaces its people. A change that would hide an open instance from the person who runs it is refused,
240
- naming them, unless --force: have someone who stays take those over first.`;
241
+ does); for a workspace it replaces its people. A change that would hide an owned series from its owner is refused,
242
+ naming them, unless --force: explicitly transfer whole series to someone who stays first.`;
241
243
 
242
244
  const config = join(homedir(), '.config', 'rollforward.json');
243
245
  const [cmd, ...argv] = process.argv.slice(2);
@@ -304,9 +306,9 @@ async function workspaceNamed(name ) {
304
306
  }
305
307
  // An instance's path as rf ls prints it, by its id.
306
308
  const pathOf = async (id ) => (await get('/api')).flatMap(w => w.series.flatMap(s => s.instances.filter(i => i.id === id).map(i => `${w.name}/${s.name}/${i.label}`)))[0];
307
- // The offers of your logins that --creds or --set name, ticked for an instance, and what ticking them agrees to.
309
+ // Explicit series-wide offer selection.
308
310
  const ticks = () => flags.clear ? [] : String(flags.creds ?? flags.set ?? '').split(',').map(o => o.trim()).filter(Boolean);
309
- const consent = (offers ) => offers.length ? `, ticking ${offers.join(', ')}: you agree that agents carry these credentials while acting as you` : ', with no logins ticked';
311
+ const consent = (offers ) => `, series-wide ceiling: ${offers.join(', ') || 'no credentials'}; you explicitly consent to agents acting as you`;
310
312
 
311
313
  // Times as this machine's clock reads them, and lengths of time and costs, for the views.
312
314
  const when = (iso ) => new Date(iso).toLocaleString('sv-SE', { dateStyle: 'short', timeStyle: 'short' });
@@ -469,22 +471,22 @@ if (cmd === 'login' && url) {
469
471
  writeFileSync(config, JSON.stringify({ url, token }), { mode: 0o600 });
470
472
  console.log(`signed in as ${me.email}`);
471
473
  } else if (cmd === 'ls' && !args.length) {
472
- // --mine: the open instances you run, alone.
474
+ // --mine: open instances of series you own.
473
475
  const me = flags.mine && await get('/me'), rows = (await get('/api')).flatMap(w => w.series.flatMap(s => [
474
- ...me ? [] : [{ path: `${w.name}/${s.name}`, id: s.id, requests: s.requests.length, wakes: s.wakes }],
475
- ...s.instances.filter(i => !me || (i.status === 'open' && i.runner === me.email)).map(i => ({ path: `${w.name}/${s.name}/${i.label}`, id: i.id, status: i.status, running: i.running, asks: i.asks.length, runner: i.runner, wakes: i.wakes, ...(i.deleted && { deleted: i.deleted }) })),
476
+ ...me ? [] : [{ path: `${w.name}/${s.name}`, id: s.id, owner: s.owner, requests: s.requests.length, wakes: s.wakes }],
477
+ ...s.instances.filter(i => !me || (i.status === 'open' && i.owner === me.email)).map(i => ({ path: `${w.name}/${s.name}/${i.label}`, id: i.id, status: i.status, running: i.running, asks: i.asks.length, owner: i.owner, wakes: i.wakes, ...(i.deleted && { deleted: i.deleted }) })),
476
478
  ]));
477
479
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
478
480
  else for (const r of rows) {
479
- console.log(r.deleted ? `${r.path} deleted by ${r.deleted.by} ${when(r.deleted.at)}` : r.status ? `${r.path} ${r.status}${r.running ? ', running' : ''}${r.asks ? `, ${r.asks} asks waiting` : ''}, runner ${r.runner}` : `${r.path}${r.requests ? ` ${r.requests} asking to start` : ''}`);
481
+ console.log(r.deleted ? `${r.path} deleted by ${r.deleted.by} ${when(r.deleted.at)}` : r.status ? `${r.path} ${r.status}${r.running ? ', running' : ''}${r.asks ? `, ${r.asks} asks waiting` : ''}, owner ${r.owner}` : `${r.path}${r.requests ? ` ${r.requests} asking to start` : ''}`);
480
482
  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}` : ''}`);
481
483
  }
482
484
  } else if (cmd === 'waiting' && !args.length) {
483
485
  const [me, s, all] = await Promise.all([get('/me'), get('/api/status'), get('/api')]), mine = (who ) => (who ?? me.email) === me.email;
484
486
  const series = all.flatMap(w => w.series.map(x => ({ ...x, path: `${w.name}/${x.name}` })));
485
487
  const rows = [
488
+ ...s.ownership.map(s => ({ kind: 'owner', path: s.path, text: s.text })),
486
489
  ...s.asks.filter(a => a.who === me.email).map(a => ({ kind: a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
487
- ...s.assigned.filter(a => a.who === me.email).map(a => ({ kind: 'assigned', path: a.path, since: a.at, text: `${a.by} assigned you ${a.path}` })),
488
490
  ...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}` : ''}` }))),
489
491
  ...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`}` })),
490
492
  ...s.expired.filter(e => e.who === me.email).map(e => ({ kind: 'expired', login: e.login, holding: e.holding, text: `your ${e.login} login expired` })),
@@ -494,15 +496,15 @@ if (cmd === 'login' && url) {
494
496
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
495
497
  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.kind === 'grant' ? r.text : r.text.split('\n')[0].slice(0, 120)}`).join('\n') || 'Nothing waits on you.');
496
498
  } else if (cmd === 'show' && args.length === 1) {
497
- const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, runner, waiting: w } = await get(at);
499
+ const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, owner, waiting: w } = await get(at);
498
500
  const waiting = w.map(({ who, seq }) => {
499
501
  const e = log[seq - 1], first = log.find(x => `c${x.seq}` === e.thread);
500
502
  return { comment: `c${seq}`, thread: e.thread, kind: e.ask === true ? 'ask' : e.ask ?? 'note', for: who, by: e.by, item: first.item, ref: first.ref, text: e.text };
501
503
  });
502
504
  const done = log.findLast(e => e.op === 'done'), last = done ? { run: done.run, cost: done.cost, ...(done.estimated && { estimated: true }), error: done.error ?? null } : null;
503
- 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, ...(doc.status === 'deleted' && { deleted: { by: log[0].by, at: log[0].at } }) }, null, 1));
505
+ if (flags.json) console.log(JSON.stringify({ path: args[0], id: inst.id, status: doc.status, owner: owner.by, running: run, queued, items: doc.items, waiting, last_run: last, ...(doc.status === 'deleted' && { deleted: { by: log[0].by, at: log[0].at } }) }, null, 1));
504
506
  else {
505
- console.log(doc.status === 'deleted' ? `${args[0]} deleted by ${log[0].by} ${when(log[0].at)}` : `${args[0]} ${doc.status}, runner ${runner.by}${run ? `, run ${run.n} going, ${usdNote(run.cost, run.estimated)}` : queued ? ', queued' : ''}`);
507
+ console.log(doc.status === 'deleted' ? `${args[0]} deleted by ${log[0].by} ${when(log[0].at)}` : `${args[0]} ${doc.status}, series owner ${owner.by}${run ? `, run ${run.n} going, ${usdNote(run.cost, run.estimated)}` : queued ? ', queued' : ''}`);
506
508
  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}` : ''}`);
507
509
  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)}`);
508
510
  if (last) console.log(`last run ${last.run} ${usdNote(last.cost ?? 0, last.estimated)}${last.error ? ` ${last.error}` : ''}`);
@@ -526,9 +528,9 @@ if (cmd === 'login' && url) {
526
528
  else if (cmd === 'comment' && args.length === 2) {
527
529
  const { at } = await instanceAt(args[0]);
528
530
  const posted = await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
529
- const seq = Number(posted.headers.get('X-RF-Comment-Seq')), { doc, log, runner, starts } = await get(at), note = log.find(e => e.seq === seq)?.note;
530
- if (note && !starts) console.log(`a note for the runner, ${runner.by}, seq ${seq}: it starts no run until they act`);
531
- else if (!flags.wait) console.log(`${note ? `a note for the runner, ${runner.by}` : 'commented'}, seq ${seq}`);
531
+ const seq = Number(posted.headers.get('X-RF-Comment-Seq')), { doc, log, owner, starts, standing } = await get(at), note = log.find(e => e.seq === seq)?.note;
532
+ if (!starts && standing?.[seq] !== 'answer') console.log(`recorded for the series owner, ${owner.by}, seq ${seq}: no run starts`);
533
+ else if (!flags.wait) console.log(`${note ? `a note for the series owner, ${owner.by}` : 'commented'}, seq ${seq}`);
532
534
  else if (doc.status !== 'open') console.log(`The instance was ${doc.status}.`);
533
535
  else for (;;) {
534
536
  // The run that saw the comment, and what it said from then on: a run ending as it came may not have.
@@ -572,22 +574,26 @@ else if (cmd === 'comment' && args.length === 2) {
572
574
  }
573
575
  await post(`${at}/delete`, {});
574
576
  console.log(`deleted ${args[0]}`);
575
- } else if (cmd === 'takeover' && args.length === 1) {
576
- await post(`${(await instanceAt(args[0])).at}/assign`, { logins: ticks() });
577
- console.log(`you run ${args[0]} now${consent(ticks())}`);
578
- } else if (cmd === 'assign' && args.length === 2) {
579
- await post(`${(await instanceAt(args[0])).at}/assign`, { to: args[1] });
580
- console.log(`${args[1]} runs ${args[0]} now, with no logins ticked until they tick theirs`);
581
- } else if (cmd === 'creds' && args.length === 1) {
582
- const { at } = await instanceAt(args[0]);
577
+ } else if (cmd === 'series' && args[0] === 'owner' && [2, 3].includes(args.length)) {
578
+ const s = await seriesAt(args[1]);
579
+ if (args.length === 3) {
580
+ if (flags.creds !== undefined || flags.set !== undefined || flags.clear || flags.autonomous !== undefined) throw new Error('a transfer grants no credentials: the incoming owner selects series credentials separately');
581
+ await post(`/api/series/${s.id}/owner`, { owner: args[2] }, 'PUT');
582
+ console.log(`transferred whole series ${args[1]} to ${args[2]}; all instances change owner, old runs stop, consent cleared; starts no run`);
583
+ } else if (flags.json) console.log(JSON.stringify({ owner: s.owner, since: s.since, epoch: s.epoch }, null, 1));
584
+ else console.log(`${args[1]}: series owner ${s.owner ?? 'not selected'}`);
585
+ } else if (cmd === 'series' && args[0] === 'credentials' && args.length === 2) {
586
+ const s = await seriesAt(args[1]);
583
587
  if (flags.set !== undefined || flags.clear) {
584
- await post(`${at}/logins`, { logins: ticks() });
585
- console.log(`saved${consent(ticks())}`);
588
+ if (!['true', 'false'].includes(String(flags.autonomous))) throw new Error('saving requires --autonomous true|false');
589
+ await post(`/api/series/${s.id}/credentials`, { logins: ticks(), autonomous: flags.autonomous === 'true' }, 'PUT');
590
+ console.log(`saved ${args[1]}${consent(ticks())}; autonomous ${flags.autonomous}`);
586
591
  } else {
587
- const [{ runner }, mine] = await Promise.all([get(at), get('/logins')]);
588
- const out = { runner: runner.by, ticked: runner.logins.map((id, k) => ({ id, name: runner.ticked[k] })), yours: mine.flatMap(l => l.offers.map(o => ({ ...o, ...(l.expired && { expired: true }) }))) };
592
+ if (flags.autonomous !== undefined) throw new Error('select credentials with --set OFFER,... or --clear');
593
+ const mine = await get('/logins');
594
+ const out = { owner: s.owner, consent: s.consent, yours: mine.flatMap(l => l.offers.map(o => ({ ...o, ...(l.expired && { expired: true }) }))) };
589
595
  if (flags.json) console.log(JSON.stringify(out, null, 1));
590
- else console.log([`${out.runner} ticks:`, ...out.ticked.map(o => ` ${o.id} ${o.name}`), 'yours:', ...out.yours.map(o => ` ${o.id} ${o.name}${o.expired ? ' expired' : ''}`)].join('\n'));
596
+ else console.log([`Series owner: ${out.owner ?? 'not selected'}`, out.consent ? `Series-wide ceiling: ${out.consent.logins.join(', ') || 'no credentials'}; autonomous ${out.consent.autonomous}` : 'No execution consent', 'your offers:', ...out.yours.map(o => ` ${o.id} ${o.name}${o.expired ? ' expired' : ''}`)].join('\n'));
591
597
  }
592
598
  } else if (cmd === 'rename' && args.length === 2) {
593
599
  const [w, s, l] = args[0].replace(/\/+$/, '').split('/');
@@ -604,22 +610,24 @@ else if (cmd === 'comment' && args.length === 2) {
604
610
  if (Buffer.byteLength(clean) > 200) throw new Error(`a name is 200 bytes at most, about 66 Chinese characters, not ${Buffer.byteLength(clean)}`);
605
611
  if (workspace.series.some((s ) => s.name === clean)) throw new Error(`${clean} exists`);
606
612
  }
607
- const { instance } = await (await post('/api/series', { workspace: workspace.id, single: true, logins: ticks() })).json();
613
+ const selected = flags.creds !== undefined || !!flags.clear;
614
+ if (flags.autonomous !== undefined && !['true', 'false'].includes(String(flags.autonomous))) throw new Error('--autonomous is true or false');
615
+ if (flags.autonomous !== undefined && !selected) throw new Error('autonomous consent requires --creds OFFER,... or --clear');
616
+ const { instance } = await (await post('/api/series', { workspace: workspace.id, single: true, ...(selected && { logins: ticks(), autonomous: flags.autonomous === 'true' }) })).json();
608
617
  if (clean && (await pathOf(instance)).split('/').at(-1) !== clean) await post(`/api/instances/${instance}/rename?as=${encodeURIComponent(args[2])}`, {});
609
618
  if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment, quiet: !flags.wake });
610
- console.log(`made ${await pathOf(instance)}${consent(ticks())}`);
619
+ console.log(`made ${await pathOf(instance)}${selected ? consent(ticks()) : '; no execution consent: select series credentials before running'}`);
611
620
  } else if (cmd === 'new' && args[0] === 'instance' && args.length === 3) {
612
- const { id } = await (await post(`/api/series/${(await seriesAt(args[1])).id}`, { label: args[2], logins: ticks(), quiet: !flags.wake })).json();
613
- console.log(`made ${await pathOf(id)}${consent(ticks())}`);
621
+ if (flags.creds !== undefined || flags.clear || flags.autonomous !== undefined) throw new Error('instance credentials were removed: use rf series credentials SERIES');
622
+ const series = await seriesAt(args[1]);
623
+ const { id } = await (await post(`/api/series/${series.id}`, { label: args[2], quiet: !flags.wake })).json();
624
+ console.log(`made ${await pathOf(id)}; series owner and ceiling unchanged${series.owner ? `; ${series.owner} starts its runs` : ''}`);
614
625
  } else if (cmd === 'new' && args[0] === 'series' && args.length === 3) {
615
626
  await post(`/api/series/${(await find(args[1])).series.id}/promote`, { name: args[2] });
616
627
  console.log(`made the series ${args[1].split('/')[0]}/${args[2]}`);
617
628
  } else if (cmd === 'new' && args[0] === 'workspace' && args.length === 2) {
618
629
  await post('/api/workspaces', { name: args[1] });
619
630
  console.log(`made ${args[1]}`);
620
- } else if (cmd === 'share' && ['on', 'off'].includes(args[1]) && args.length === 2) {
621
- await post(`/api/series/${(await seriesAt(args[0])).id}`, { share: args[1] === 'on', logins: ticks() }, 'PUT');
622
- console.log(args[1] === 'on' ? `shared ${args[0]}${consent(ticks())}` : `stopped sharing ${args[0]}`);
623
631
  } else if (cmd === 'archive' && args.length === 1) {
624
632
  const [w, s] = args[0].replace(/\/+$/, '').split('/');
625
633
  await post(s === undefined ? `/api/workspaces/${(await workspaceNamed(w)).id}` : `/api/series/${(await seriesAt(args[0])).id}`, { archived: !flags.undo }, 'PUT');
@@ -629,10 +637,10 @@ else if (cmd === 'comment' && args.length === 2) {
629
637
  await api(`/api/requests/${args[1]}`, { method: 'DELETE' });
630
638
  console.log(`dropped request ${args[1]}`);
631
639
  } else {
632
- const setCreds = flags.creds !== undefined || !!flags.clear;
633
- const r = await post(`/api/requests/${args[1]}`, { ...(setCreds && { logins: ticks() }), quiet: !flags.wake });
640
+ if (flags.creds !== undefined || flags.clear) throw new Error('request credentials were removed: use rf series credentials SERIES');
641
+ const r = await post(`/api/requests/${args[1]}`, { quiet: !flags.wake });
634
642
  const woke = r.headers.get('X-RF-Woke') === '1', { id } = await r.json();
635
- console.log(`${woke ? 'woke' : 'made'} ${await pathOf(id)}${!woke || setCreds ? consent(ticks()) : ''}`);
643
+ console.log(`${woke ? 'woke' : 'made'} ${await pathOf(id)}; series owner and ceiling unchanged`);
636
644
  }
637
645
  } else if (cmd === 'logins' && !args.length) {
638
646
  const all = await get('/logins');
@@ -777,14 +785,15 @@ else if (cmd === 'comment' && args.length === 2) {
777
785
  const [s, ix] = await Promise.all([get('/api/status'), get('/api/indexes')]), long = Number(flags.long ?? 30);
778
786
  if (flags.json) console.log(JSON.stringify({ ...s, indexes: ix }, null, 1));
779
787
  else {
780
- const lowLine = s.low_credit ? `Low OpenRouter credit: ${usd(s.low_credit.remaining)} remaining${s.low_credit.limit !== null ? ` of ${usd(s.low_credit.limit)} limit` : ''}${s.low_credit.reset ? ` (resets ${s.low_credit.reset})` : ''}` : '';
788
+ const lowLine = s.low_credit ? `Low OpenRouter credit: ${usd(s.low_credit.remaining)} remaining${s.low_credit.limit !== null ? ` of ${usd(s.low_credit.limit)} limit` : ''}${s.low_credit.reset ? ` (resets ${s.low_credit.reset})` : ''}${s.low_credit.key === 'fallback' ? ', on the fallback key, the first being low too' : ''}` : '';
781
789
  const sections = [
782
790
  [`Running`, s.running.map(r => `${r.path} run ${r.run} for ${took((Date.now() - Date.parse(r.at)) / 1000)} ${usdNote(r.cost, r.estimated)}${Date.now() - Date.parse(r.at) > long * 60e3 ? ` LONG, past ${long}m` : ''}`)],
783
791
  [`Queued`, s.queued.map(q => `${q.path} since ${when(q.since)}: ${q.why}`)],
784
792
  [`Waiting`, [
785
- ...[...s.asks, ...s.assigned.map(a => ({ ...a, since: a.at, text: `${a.by} assigned it to them`, assigned: true })), ...s.requests.map(r => ({ ...r, who: r.who ?? 'anyone', since: r.at, text: `${r.from} asks to ${r.target ? 'wake' : 'start'} ${r.label}`, request: true })),
793
+ ...s.ownership.map(s => `${s.path} ${s.text}`),
794
+ ...[...s.asks, ...s.requests.map(r => ({ ...r, who: r.who ?? 'anyone', since: r.at, text: `${r.from} asks to ${r.target ? 'wake' : 'start'} ${r.label}`, request: true })),
786
795
  ...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 }))]
787
- .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.assigned ? 'an assignment' : a.note ? 'a note' : 'an ask'} in ${a.path} since ${when(a.since)}: ${a.text.split('\n')[0].slice(0, 80)}`),
796
+ .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)}`),
788
797
  ...s.expired.map(e => `${e.who} their ${e.login} login expired${e.holding.length ? `, holding ${e.holding.join(', ')}` : ''}`),
789
798
  ]],
790
799
  [`Last run failed`, s.failed.map(f => `${f.path} run ${f.run} at ${when(f.at)}: ${f.error}`)],