@rfany/rf 0.19.2 → 0.20.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 +126 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rfany/rf",
3
- "version": "0.19.2",
3
+ "version": "0.20.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
@@ -5,6 +5,7 @@ import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync,
5
5
  import { spawn } from 'node:child_process';
6
6
  import { homedir, hostname } from 'node:os';
7
7
  import { basename, dirname, join, relative, resolve, sep } from 'node:path';
8
+ import { parseArgs } from 'node:util';
8
9
 
9
10
  // A failure is one line, rf's own or the server's, never a stack.
10
11
  process.on('uncaughtException', e => {
@@ -16,10 +17,9 @@ const usage = (c , vpn = false, admin = false) => {
16
17
  const all = `rf login URL [TOKEN] without a TOKEN, through the browser: type rf's code on the page, and allow it
17
18
  rf ls [--mine] [--json] every workspace, series and instance you see, with its status, owner, asks waiting and wakes;
18
19
  --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
- instance or to use a
21
- website in a workspace you own, proposals and expired logins; only admins see hosts a run's
22
- browser was refused that the server rates high or finds at an internal address
20
+ rf waiting [--json] what waits on you: asks, proposals, requests and expired logins; also note notices (FYI).
21
+ Only admins see hosts a run's browser was refused that the server rates high or finds
22
+ at an internal address
23
23
  rf show PATH [--json] an instance: its items, the threads that wait on someone, by id, and its last run
24
24
  rf log PATH [--since SEQ] [--follow] [--json] its log, a line an entry, after SEQ; --follow prints more as they come;
25
25
  --json prints the entries as they are, a line each
@@ -31,9 +31,18 @@ rf pull PATH DIR [--delete] [-n|--dry-run] [--exclude PATTERN]... [--max-size SI
31
31
  that differ only in case, the second is skipped
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
- 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 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
34
+ rf comment TARGET [--in cN | --on ITEM[@REF]] [--ask | --propose] [--to EMAIL] [--for cN|nN] [--request] [--wake|--wait] TEXT
35
+ TARGET is WORKSPACE/SERIES[/INSTANCE]. On a series, posts a note and starts no run.
36
+ On an instance, starts a thread or replies under cN. --to names who an ask or proposal waits on.
37
+ --for links a proposal to an informing message. A non-owner's note can use --request
38
+ to ask for a proposal without starting a run.
39
+ --wake or --wait starts an instance run for the owner or an answer to a named ask
40
+ under current consent; --wait prints what the agent says back.
41
+ rf comment SERIES [--json] lists Notes on WORKSPACE/SERIES, open and settled
42
+ rf comment --mine [--json] lists your own notes and their settlements
43
+ rf settle TARGET#cN|TARGET#nN taken|aside|withdrawn TEXT
44
+ IDs are local: use WORKSPACE/SERIES/INSTANCE#cN or WORKSPACE/SERIES#nN.
45
+ Say where a note was taken, why it was set aside, or why an ask or proposal was withdrawn.
37
46
  rf upload PATH FILE [--onto ITEM] [--output] [--wake]
38
47
  rf approve PATH cN [TEXT] [--wake] records content approval of proposal cN, not permission to run as you; the folder is
39
48
  committed as it is now, in your name
@@ -102,8 +111,6 @@ rf wake PATH AT [TEXT] [--label LABEL] [--days DAYS] [--check PATH [--deadline I
102
111
  later or agent-set wakes need it. Collaborators' wakes are requests. DAYS, such as mon-fri,
103
112
  repeats weekly at AT's time. With the owner's wake-check capability, --check working/FILE.py (or .ts)
104
113
  gates a scheduled wake; optional --deadline TIME (ISO with offset) runs Pi even if the check stops.
105
- rf note SERIES [TEXT] [--json] tells the series something for its runs, about the series rather than one period or while no
106
- instance is open, which starts no run; without TEXT, its notes, open and settled
107
114
  rf agents [WORKSPACE] [--set FILE|-] the company's AGENTS.md, or a workspace's; setting the company's is for admins
108
115
  rf readers WORKSPACE [add|remove OTHER] the workspaces whose agents read WORKSPACE and those its own read, as each one's
109
116
  owners let them; its owners let OTHER's agents read it, one they see, and its owners or
@@ -213,8 +220,8 @@ What rf pull copies, the folders as the agent sees them
213
220
  The copy is read-only: only rf's commands change what's on the server.
214
221
 
215
222
  Usual work
216
- - What waits on me: rf waiting, then rf show PATH, which names each comment that waits by its id.
217
- - Answer a question: rf comment PATH TEXT --thread cN --wait, which prints what the agent says back. Decide a proposal:
223
+ - What waits on me: rf waiting, then rf show PATH, which names each comment that waits by its id. Note notices are FYI.
224
+ - Answer a question: rf comment PATH --in cN --wait TEXT, which prints what the agent says back. Decide a proposal:
218
225
  rf approve PATH cN [TEXT] --wake, for the agent to go ahead, or rf reject PATH cN [TEXT] --wake. Close an
219
226
  instance once it's the record: rf close PATH.
220
227
  - Transfer a whole series, as its current owner or workspace manager: rf series owner SERIES EMAIL. The incoming owner
@@ -226,8 +233,9 @@ Usual work
226
233
  - Start an instance: rf new instance SERIES LABEL --wake, only as the series owner. Scheduled wakes need that owner's
227
234
  autonomous opt-in and keep their authorized credential snapshot; collaborators' wakes become requests for the owner.
228
235
  A one-off: rf new task WORKSPACE --clear --comment TEXT --wake. Promotion with rf new series PATH NAME keeps its owner.
229
- - 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
230
- starts no run; rf note SERIES lists its notes, open, and settled by a run or by hand.
236
+ - Tell a series something for its runs, or while no instance is open: rf comment SERIES TEXT, which starts no run.
237
+ rf comment SERIES lists its notes; rf comment --mine lists your notes. Settle an informing note with
238
+ rf settle SERIES#nN taken|aside TEXT or rf settle PATH#cN taken|aside TEXT.
231
239
  - 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
232
240
  for a file; rf pull PATH/ DIR copies the folder, with session/ for every step.
233
241
 
@@ -235,7 +243,7 @@ Watching over it, for admins and power users; each sees what the caller sees
235
243
  - 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
236
244
  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
237
245
  they hold, and requests to start, grouped by whom they wait on, the oldest three each unless --all; open instances whose last run
238
- failed; and indexes crawling or failing.
246
+ failed; note notices for you; and indexes crawling or failing.
239
247
  - What runs use (admins): rf top shows the host's CPU, load and memory, each run going with its processes, CPU and memory, and the
240
248
  ten processes of runs busiest by CPU and by memory. rf kill PID ends one, with all it started; rf interrupt PATH stops a run.
241
249
  rf top, rf status and rf runs take -d SECONDS to show again every SECONDS, as top does, until Ctrl+C.
@@ -254,8 +262,25 @@ Watching over it, for admins and power users; each sees what the caller sees
254
262
 
255
263
  const config = join(homedir(), '.config', 'rollforward.json');
256
264
  const [cmd, ...argv] = process.argv.slice(2);
265
+ const replacement = new Map([
266
+ ['note', 'rf comment SERIES [TEXT] or rf comment --mine'],
267
+ ['say', 'rf comment TARGET TEXT'],
268
+ ['ask', 'rf comment TARGET --ask TEXT'],
269
+ ['propose', 'rf comment TARGET --propose TEXT'],
270
+ ['withdraw', 'rf settle TARGET#cN withdrawn TEXT'],
271
+ ]).get(cmd === 'help' ? argv[0] : cmd);
272
+ if (replacement) throw new Error(`use ${replacement}`);
273
+
257
274
  const flags = {}, excludes = [], args = [];
258
- for (let i = 0; i < argv.length; i++) {
275
+ if (cmd === 'comment' || cmd === 'settle') {
276
+ const parsed = parseArgs({ args: argv, allowPositionals: true, options: cmd === 'settle' ? {} : {
277
+ in: { type: 'string' }, on: { type: 'string' }, ask: { type: 'boolean' }, propose: { type: 'boolean' },
278
+ to: { type: 'string' }, for: { type: 'string' }, request: { type: 'boolean' }, mine: { type: 'boolean' },
279
+ json: { type: 'boolean' }, wake: { type: 'boolean' }, wait: { type: 'boolean' },
280
+ } });
281
+ Object.assign(flags, parsed.values);
282
+ args.push(...parsed.positionals);
283
+ } else for (let i = 0; i < argv.length; i++) {
259
284
  const flag = argv[i] === '-n' ? 'dry-run' : argv[i] === '-d' ? 'delay' : argv[i].match(/^--(.+)$/)?.[1];
260
285
  if (!flag) args.push(argv[i]);
261
286
  else if (['wait', 'wake', 'output', 'delete', 'dry-run', 'force', 'json', 'failed', 'running', 'clear', 'follow', 'superseded', 'undo', 'by-amount', 'yes', 'mine', 'daily', 'all'].includes(flag)) flags[flag] = true;
@@ -275,9 +300,9 @@ if ((!cmd || cmd === 'help') && !existsSync(config)) {
275
300
  if (cmd !== 'login' && !existsSync(config)) throw new Error('sign in first: rf login URL');
276
301
  let { url, token } = cmd === 'login' ? { url: args[0]?.replace(/\/$/, ''), token: args[1] } : JSON.parse(readFileSync(config, 'utf8'));
277
302
 
278
- async function api(path , init = {}) {
303
+ async function api(path , init = {}, accept = []) {
279
304
  const r = await fetch(url + path, { ...init, headers: { authorization: `Bearer ${token}` } });
280
- if (!r.ok) throw new Error(`${init.method ?? 'GET'} ${path}: ${r.status} ${await r.text()}`);
305
+ if (!r.ok && !accept.includes(r.status)) throw new Error(`${init.method ?? 'GET'} ${path}: ${r.status} ${await r.text()}`);
281
306
  return r;
282
307
  }
283
308
  const get = async (path ) => (await api(path)).json();
@@ -544,7 +569,8 @@ if (cmd === 'login' && url) {
544
569
  const series = all.flatMap(w => w.series.map(x => ({ ...x, path: `${w.name}/${x.name}` })));
545
570
  const rows = [
546
571
  ...s.ownership.map(s => ({ kind: 'owner', path: s.path, text: s.text })),
547
- ...s.asks.filter(a => a.who === me.email).map(a => ({ kind: a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
572
+ ...s.asks.filter(a => a.who === me.email && !a.legacyNotice).map(a => ({ kind: a.note ? 'note' : 'ask', path: a.path, since: a.since, text: a.text })),
573
+ ...(s.noteNotices ?? []),
548
574
  ...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}` : ''}` }))),
549
575
  ...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`}` })),
550
576
  ...s.expired.filter(e => e.who === me.email).map(e => ({ kind: 'expired', login: e.login, holding: e.holding, text: `your ${e.login} login expired` })),
@@ -552,7 +578,9 @@ if (cmd === 'login' && url) {
552
578
  ...all.filter(w => w.manage).flatMap(w => w.grants.filter(g => g.state === 'pending').map(g => ({ kind: 'grant', path: w.name, since: g.at, id: g.id, text: grantText(g) }))),
553
579
  ];
554
580
  if (flags.json) console.log(JSON.stringify(rows, null, 1));
555
- 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.');
581
+ else console.log(rows.map(r => r.kind === 'open' || r.kind === 'settled'
582
+ ? `note ${r.kind} ${r.path}#${r.id} by ${r.by} at ${when(r.at)}: ${gist(r.text, 120)}`
583
+ : `${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.');
556
584
  } else if (cmd === 'show' && args.length === 1) {
557
585
  const { inst, at } = await instanceAt(args[0]), { doc, log, run, queued, owner, waiting: w } = await get(at);
558
586
  const waiting = w.map(({ who, seq }) => {
@@ -583,36 +611,86 @@ if (cmd === 'login' && url) {
583
611
  if (!f || f.path !== path || more.length) throw new Error(f ? `${args[0]} is a folder: rf pull it` : `nothing you can see at ${args[0]}`);
584
612
  process.stdout.write(f.text ?? Buffer.from(await (await api(f.url)).arrayBuffer()));
585
613
  } else if (cmd === 'pull' && args.length === 2) await pull(args[0], args[1]);
586
- else if (cmd === 'comment' && args.length === 2) {
587
- const { at } = await instanceAt(args[0]);
588
- const posted = await post(`${at}/comment`, { text: args[1], item: flags.item, ref: flags.ref, thread: flags.thread, quiet: !flags.wake && !flags.wait });
589
- 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;
590
- if (!starts && standing?.[seq] !== 'answer') console.log(`recorded for the series owner, ${owner.by}, seq ${seq}: no run starts`);
591
- else if (!flags.wait) console.log(`${note ? `a note for the series owner, ${owner.by}` : 'commented'}, seq ${seq}`);
592
- else if (doc.status !== 'open') console.log(`The instance was ${doc.status}.`);
593
- else for (;;) {
594
- // The run that saw the comment, and what it said from then on: a run ending as it came may not have.
595
- await new Promise(r => setTimeout(r, 5000));
596
- const { doc, log } = await get(at);
597
- const done = log.find(e => e.op === 'done' && (e.seen >= seq || (e.seq > seq && (e.error || e.aborted) && !log.some(w => w.seq > e.seq && ((w.op === 'wake' && w.cause === e.seq) || w.op === 'run')))));
598
- if (done) {
599
- const from = Math.max(seq, log.find(e => e.op === 'run' && e.run === done.run)?.seq ?? 0);
600
- for (const e of log.filter(e => e.seq > from && e.seq < done.seq && e.op === 'comment' && e.by === 'agent' && !e.see)) console.log(`${e.ask === 'proposal' ? 'Proposes' : e.ask ? 'Asks' : 'Says'} in ${e.thread}:\n${e.text}\n`);
601
- if (done.error) console.log(`The run failed: ${done.error}`);
602
- else if (done.aborted && done.seen < seq) console.log('The run was stopped.');
603
- break;
614
+ else if (cmd === 'comment' && args.length < 2) {
615
+ if (Object.keys(flags).some(f => !['json', 'mine'].includes(f)) || (flags.mine ? args.length !== 0 : !args[0]))
616
+ throw new Error('use rf comment SERIES [--json], rf comment --mine [--json], or rf help comment to post');
617
+ let rows;
618
+ if (!flags.mine) rows = await get(`/api/series/${(await seriesAt(args[0])).id}/notes`);
619
+ else {
620
+ const response = await api('/api/messages?mine=1', {}, [404, 405]);
621
+ if (response.ok) rows = await response.json();
622
+ else {
623
+ // Older servers only have per-series Notes; instance notes need the new API.
624
+ const [me, workspaces] = await Promise.all([get('/me'), get('/api')]);
625
+ rows = [];
626
+ for (const w of workspaces) for (const s of w.series.filter(s => !s.single)) {
627
+ const notes = await get(`/api/series/${s.id}/notes`);
628
+ rows.push(...notes.filter(n => n.by === me.email).map(n => ({ ...n, id: `n${n.seq}`, path: `${w.name}/${s.name}` })));
629
+ }
604
630
  }
605
- if (doc.status !== 'open') {
606
- console.log(`The instance was ${doc.status}.`);
607
- break;
631
+ }
632
+ if (flags.json) console.log(JSON.stringify(rows, null, 1));
633
+ else for (const n of rows) {
634
+ const by = n.by === 'agent' && n.see ? `agent of ${n.see.label}, for ${n.runner}` : n.by;
635
+ const how = n.settled?.how ?? n.settled?.op;
636
+ console.log(`${n.path ? `${n.path}#` : ''}${n.id ?? `n${n.seq}`} ${when(n.at)} ${by} ${n.settled ? `${how === 'aside' ? 'set aside' : how} by ${n.settled.by}: ${n.settled.text}` : 'open'}${n.request ? ' (request to propose)' : ''}\n ${n.text.split('\n')[0].slice(0, 200)}`);
637
+ }
638
+ } else if (cmd === 'comment') {
639
+ const [path, ...words] = args, text = words.join(' '), { in: thread, ask, propose, to, for: linked, request, wake, wait } = flags;
640
+ const on = typeof flags.on === 'string' ? flags.on : undefined, split = on?.indexOf('@') ?? -1;
641
+ const item = split < 0 ? on : on .slice(0, split), ref = split < 0 ? undefined : on .slice(split + 1);
642
+ if (flags.json || flags.mine) throw new Error('--json and --mine are for reading notes');
643
+ if (thread !== undefined && (on !== undefined || !/^c\d+$/.test(String(thread)))) throw new Error('use --in cN or --on ITEM[@REF], not both');
644
+ if (on !== undefined && (!item?.trim() || ref?.trim() === '')) throw new Error('use --on ITEM[@REF]');
645
+ if (ask && propose || (to !== undefined && (!String(to).trim() || !(ask || propose)))) throw new Error('use --ask or --propose, with optional --to EMAIL');
646
+ if (linked !== undefined && (!propose || !/^[cn]\d+$/.test(String(linked)))) throw new Error('--for cN|nN requires --propose');
647
+ if (!text.trim()) throw new Error('a comment needs text');
648
+ if (wake && wait) throw new Error('use --wake or --wait, not both');
649
+ const { series, inst, at } = await find(path);
650
+ if (!inst && (wake || wait)) throw new Error('a series note starts no run: omit --wake or --wait');
651
+ const posted = await post('/api/messages', {
652
+ ...(inst ? { instance: inst.id, quiet: !wake && !wait } : { series: series.id }),
653
+ text, thread, item, ref, ask: ask ? 'question' : propose ? 'proposal' : undefined, to, request, for: linked,
654
+ });
655
+ if (!inst) console.log(`noted ${(await posted.json()).id} on ${path}: it starts no run, and its runs read it`);
656
+ else {
657
+ 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;
658
+ if (!starts && standing?.[seq] !== 'answer') console.log(`recorded for the series owner, ${owner.by}, seq ${seq}: no run starts`);
659
+ else if (!wait) console.log(`${note ? `a note for the series owner, ${owner.by}` : 'commented'}, seq ${seq}`);
660
+ else if (doc.status !== 'open') console.log(`The instance was ${doc.status}.`);
661
+ else for (;;) {
662
+ // The run that saw the comment, and what it said from then on: a run ending as it came may not have.
663
+ await new Promise(r => setTimeout(r, 5000));
664
+ const { doc, log } = await get(at);
665
+ const done = log.find(e => e.op === 'done' && (e.seen >= seq || (e.seq > seq && (e.error || e.aborted) && !log.some(w => w.seq > e.seq && ((w.op === 'wake' && w.cause === e.seq) || w.op === 'run')))));
666
+ if (done) {
667
+ const from = Math.max(seq, log.find(e => e.op === 'run' && e.run === done.run)?.seq ?? 0);
668
+ for (const e of log.filter(e => e.seq > from && e.seq < done.seq && e.op === 'comment' && e.by === 'agent' && !e.see)) console.log(`${e.ask === 'proposal' ? 'Proposes' : e.ask ? 'Asks' : 'Says'} in ${e.thread}:\n${e.text}\n`);
669
+ if (done.error) console.log(`The run failed: ${done.error}`);
670
+ else if (done.aborted && done.seen < seq) console.log('The run was stopped.');
671
+ break;
672
+ }
673
+ if (doc.status !== 'open') {
674
+ console.log(`The instance was ${doc.status}.`);
675
+ break;
676
+ }
608
677
  }
609
678
  }
679
+ } else if (cmd === 'settle') {
680
+ const [qualified, how, ...words] = args, text = words.join(' '), target = /^(.+)#([cn]\d+)$/.exec(qualified ?? '');
681
+ if (!target || !['taken', 'aside', 'withdrawn'].includes(how) || !text.trim())
682
+ throw new Error('use rf settle WORKSPACE/SERIES/INSTANCE#cN or WORKSPACE/SERIES#nN, followed by taken|aside|withdrawn TEXT');
683
+ const [, path, id] = target;
684
+ const scope = id.startsWith('c') ? { instance: (await instanceAt(path)).inst.id } : { series: (await seriesAt(path)).id };
685
+ await post('/api/messages', { ...scope, id, how, text });
686
+ console.log(`${qualified} ${how === 'aside' ? 'set aside' : how}`);
610
687
  } else if (cmd === 'react' && [2, 3].includes(args.length) && ['up', 'down', 'none'].includes(args.at(-1) )) {
611
688
  const on = args.length === 3 ? Number(args[1].replace(/^c/, '')) : undefined, up = { up: true, down: false, none: null }[args.at(-1) ];
612
689
  await post(`${(await instanceAt(args[0])).at}/react`, { ...(on !== undefined && { on }), up });
613
690
  console.log(`${args.at(-1)} on ${args.length === 3 ? args[1] : args[0]}`);
614
691
  } else if (['approve', 'reject'].includes(cmd) && [2, 3].includes(args.length)) {
615
- await post(`${(await instanceAt(args[0])).at}/${cmd === 'approve' ? 'signoff' : 'reject'}`, { thread: args[1], text: args[2], quiet: !flags.wake });
692
+ const { inst } = await instanceAt(args[0]);
693
+ await post('/api/messages', { instance: inst.id, id: args[1], how: cmd, text: args[2], quiet: !flags.wake });
616
694
  console.log(`${cmd === 'approve' ? 'approved' : 'rejected'} ${args[1]}`);
617
695
  } else if (['close', 'abandon', 'interrupt'].includes(cmd) && args.length === 1) {
618
696
  const { series, at } = await instanceAt(args[0]);
@@ -673,7 +751,7 @@ else if (cmd === 'comment' && args.length === 2) {
673
751
  if (flags.autonomous !== undefined && !selected) throw new Error('autonomous consent requires --creds OFFER,... or --clear');
674
752
  const { instance } = await (await post('/api/series', { workspace: workspace.id, single: true, ...(selected && { logins: ticks(), autonomous: flags.autonomous === 'true' }) })).json();
675
753
  if (clean && (await pathOf(instance)).split('/').at(-1) !== clean) await post(`/api/instances/${instance}/rename?as=${encodeURIComponent(args[2])}`, {});
676
- if (typeof flags.comment === 'string') await post(`/api/instances/${instance}/comment`, { text: flags.comment, quiet: !flags.wake });
754
+ if (typeof flags.comment === 'string') await post('/api/messages', { instance, text: flags.comment, quiet: !flags.wake });
677
755
  console.log(`made ${await pathOf(instance)}${selected ? consent(ticks()) : '; no execution consent: select series credentials before running'}`);
678
756
  } else if (cmd === 'new' && args[0] === 'instance' && args.length === 3) {
679
757
  if (flags.creds !== undefined || flags.clear || flags.autonomous !== undefined) throw new Error('instance credentials were removed: use rf series credentials SERIES');
@@ -775,14 +853,6 @@ else if (cmd === 'comment' && args.length === 2) {
775
853
  const at = args[1] === 'now' ? Date.now() : args[1].startsWith('+') ? Date.now() + Number(args[1].slice(1, -1)) * { m: 60e3, h: 3600e3, d: 86400e3 }[args[1].at(-1) ] : Date.parse(args[1]);
776
854
  const w = await (await post(`/api/wakes/${inst?.id ?? series.id}`, { at: new Date(at).toISOString(), label: flags.label, days: flags.days, text: args[2], check: flags.check, deadline: flags.deadline }, 'PUT')).json();
777
855
  console.log(`wake ${w.id} at ${w.at}${w.days ? `, then each ${w.days.join(', ')}` : ''}${w.check ? `; check ${w.check}${w.deadline ? ` until ${w.deadline}` : ''}` : ''}`);
778
- } else if (cmd === 'note' && [1, 2].includes(args.length)) {
779
- const at = `/api/series/${(await seriesAt(args[0])).id}/notes`;
780
- if (args[1]) console.log(`noted ${(await (await post(at, { text: args[1] })).json()).id} on ${args[0]}: it starts no run, and its runs read it`);
781
- else {
782
- const all = await get(at);
783
- if (flags.json) console.log(JSON.stringify(all, null, 1));
784
- else for (const n of all) console.log(`n${n.seq} ${when(n.at)} ${n.by === 'agent' ? `agent of ${n.see.label}, for ${n.runner}` : n.by} ${n.settled ? `${n.settled.op === 'taken' ? 'taken' : 'set aside'} by ${n.settled.by === 'agent' ? 'agent' : n.settled.by}: ${n.settled.text}` : 'open'}\n ${n.text.split('\n')[0].slice(0, 200)}`);
785
- }
786
856
  } else if (cmd === 'agents' && args.length <= 1) {
787
857
  const ws = args[0] === undefined ? undefined : await workspaceNamed(args[0]);
788
858
  if (typeof flags.set !== 'string') console.log(ws ? ws.agents : (await get('/agents')).text);
@@ -841,13 +911,14 @@ else if (cmd === 'comment' && args.length === 2) {
841
911
  console.log('removed');
842
912
  } else if (cmd === 'status' && !args.length) await watch(async () => {
843
913
  const [s, ix] = await Promise.all([get('/api/status'), get('/api/indexes')]), long = Number(flags.long ?? 30);
844
- if (flags.json) return JSON.stringify({ ...s, indexes: ix }, null, 1);
914
+ const asks = s.asks.filter(a => !a.legacyNotice);
915
+ if (flags.json) return JSON.stringify({ ...s, asks, indexes: ix }, null, 1);
845
916
  else {
846
917
  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' : ''}` : '';
847
918
  // What waits, by whom it waits on, oldest first, at most WAITING each unless --all.
848
919
  const waiting = [
849
920
  ...s.ownership.map(o => ({ who: 'workspace managers', kind: 'owner', path: o.path, text: o.text })),
850
- ...s.asks.map(a => ({ who: a.who, kind: a.note ? 'note' : 'ask', since: a.since, path: a.path, text: a.text })),
921
+ ...asks.map(a => ({ who: a.who, kind: a.note ? 'note' : 'ask', since: a.since, path: a.path, text: a.text })),
851
922
  ...s.requests.map(r => ({ who: r.who ?? 'anyone', kind: 'request', since: r.at, path: r.path, text: `${r.from} asks to ${r.target ? 'wake' : 'start'} ${r.label}` })),
852
923
  ...s.proposals.map(p => ({ who: `${p.to}'s owners`, kind: 'proposal', since: p.at, path: p.to, text: `${p.by} proposes to ${p.kind === 'merge' ? `merge ${p.from} into it` : `move ${p.from}/${p.series} to it`}` })),
853
924
  ...s.expired.map(e => ({ who: e.who, kind: 'login', path: e.holding.join(', '), text: `their ${e.login} login expired` })),
@@ -860,11 +931,14 @@ else if (cmd === 'comment' && args.length === 2) {
860
931
  ...(g.shown.length < g.all ? [` … ${g.all - g.shown.length} more: rf status --all`] : [])].join('\n'));
861
932
  const failing = ix.flatMap(x => x.people.filter(p => p.phase === 'crawl' || p.error).map(p => [clip(x.name, PATH_COLS), p.who,
862
933
  p.error ? `failing${p.retry_at ? `, again ${when(p.retry_at)}` : ''}` : `crawling, ${p.pages} pages`, p.error ? brief(p.error, TEXT_COLS) : '']));
934
+ const notices = s.noteNotices ?? [];
863
935
  const sections = [
864
936
  ['Running', s.running.length, table(['PATH', 'RUN', 'FOR', 'COST', ''], s.running.map(r => [clip(r.path, PATH_COLS), String(r.run), took((Date.now() - Date.parse(r.at)) / 1000),
865
937
  usdNote(r.cost, r.estimated), Date.now() - Date.parse(r.at) > long * 60e3 ? `LONG, past ${long}m` : '']))],
866
938
  ['Queued', s.queued.length, table(['PATH', 'SINCE', 'WHY'], s.queued.map(q => [clip(q.path, PATH_COLS), when(q.since), q.why]))],
867
939
  [`Waiting on ${byWho.size} ${byWho.size === 1 ? 'person' : 'people'}`, waiting.length, waits.join('\n')],
940
+ ['Note notices (FYI)', notices.length, table(['STATE', 'MESSAGE', 'BY', 'AT', 'TEXT'], notices.map(n =>
941
+ [n.kind, `${clip(n.path, PATH_COLS - n.id.length - 1)}#${n.id}`, n.by, when(n.at), gist(n.text, TEXT_COLS)]))],
868
942
  ['Last run failed', s.failed.length, table(['PATH', 'RUN', 'AT', 'ERROR'], s.failed.map(f => [clip(f.path, PATH_COLS), String(f.run), when(f.at), brief(f.error, TEXT_COLS)]))],
869
943
  ['Indexes crawling or failing', failing.length, table(['INDEX', 'PERSON', 'STATE', 'ERROR'], failing)],
870
944
  ].filter(([, n]) => n) ;