@rfany/rf 0.7.0 → 0.9.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.
- package/package.json +1 -1
- package/rf.mjs +74 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rfany/rf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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,12 +14,18 @@ rf pull PATH DIR [--delete] [-n|--dry-run] [--exclude PATTERN]...
|
|
|
14
14
|
rf help how rollforward works and how to use rf, for an agent
|
|
15
15
|
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
|
|
16
16
|
rf upload PATH FILE [--onto ITEM] [--output]
|
|
17
|
-
rf wake PATH AT
|
|
17
|
+
rf wake PATH AT [--label LABEL] [--days DAYS] | rf wake --cancel ID
|
|
18
|
+
AT now, +<n>m|h|d or a date; PATH an open instance, or a series with LABEL; DAYS, such as
|
|
19
|
+
mon-fri, repeats it weekly at AT's time; rf ls shows each wake's ID
|
|
18
20
|
rf agents [WORKSPACE] [--set FILE|-] the company's AGENTS.md, or a workspace's; setting the company's is for admins
|
|
19
21
|
rf skills
|
|
22
|
+
rf skill pull ID [DIR] [--version N] the newest version, or N, into DIR, ./ID by default, new or empty, as push reads it
|
|
23
|
+
rf skill versions ID
|
|
20
24
|
rf connections
|
|
21
25
|
rf status [--long MIN] [--json] what goes on and what's stuck: runs going, flagged past MIN minutes (30), and queued, with why;
|
|
22
26
|
what waits on whom since when; open instances whose last run failed
|
|
27
|
+
rf indexes [--json] each index of a source you index, all for admins: its kind, items and size, and per person
|
|
28
|
+
its phase, crawl or follow, pages read, when last caught up, and its error and next try
|
|
23
29
|
rf runs [PATH] [--since DATE] [--failed] [--running] [--long MIN] [--json]
|
|
24
30
|
a line per run: start, path, run, outcome, time, cost, what started it, summary or error
|
|
25
31
|
rf costs [PATH] [--since DATE] [--by workspace|series|person|day] [--json] totals, runs and cost per run; person is the runner
|
|
@@ -27,24 +33,31 @@ rf people WORKSPACE [--set FILE|-] [-n] [--force] its owners and admins: its p
|
|
|
27
33
|
each with a comment; --set replaces them, -n shows the changes, --force hides open instances
|
|
28
34
|
from their runners
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
Admins, and those they grant publish:
|
|
31
37
|
rf skill push DIR DIR/SKILL.md and the rest become the newest version of the skill named DIR's name, live at once
|
|
32
|
-
rf skill versions ID
|
|
33
38
|
rf skill rollback ID N pushes version N again, as the newest
|
|
34
39
|
|
|
35
40
|
Admins:
|
|
36
41
|
rf people [--set FILE|-] [-n] [--force] everyone as lines of ROLE EMAIL, each with a comment; --set sets the roles of the people
|
|
37
42
|
listed and adds new ones, removing no one
|
|
38
|
-
rf user add EMAIL [admin
|
|
43
|
+
rf user add EMAIL [admin] | role EMAIL admin|user [--force] | disable EMAIL | enable EMAIL | signout EMAIL | remove EMAIL
|
|
39
44
|
rf connection set NAME TYPE [--SETTING VALUE]... an outside system runs reach as their runner, by a login each person makes:
|
|
40
45
|
graph, Microsoft 365, with no settings; databricks, --host HOST --warehouse ID, a workspace
|
|
41
46
|
and its SQL warehouse; website, --url URL [--hosts HOST,...] [--title TITLE] [--writeback
|
|
42
|
-
false]
|
|
43
|
-
|
|
47
|
+
false] [--header NAME] [--keepalive PAGE --every 10m [--hours 08:00-19:00]] [--people
|
|
48
|
+
EMAIL|GROUP,...], where people sign in, the other hosts its pages need, such as
|
|
49
|
+
*.example.com, whether a run's browser writes its state back, a header its sign-in needs
|
|
50
|
+
that its pages never send, such as x-bot-token, whose value each person gives, a page, by
|
|
51
|
+
its address or path, such as https://patriarch.patrina.net/PatriArchMVC/, to load in each
|
|
52
|
+
live login's browser every so often, in office hours on weekdays if given, so idle sessions
|
|
53
|
+
stay alive, and who alone may use it, by email or Entra group id
|
|
44
54
|
rf connection remove NAME
|
|
45
55
|
rf brand [--text TEXT] [--logo FILE] [--clear] the deployment's text and logo, a .png, .jpg, .gif, .webp or .svg, which top
|
|
46
56
|
the sidebar and are the page's title and icon; --clear goes back to the plain look, and with
|
|
47
|
-
no option it prints them
|
|
57
|
+
no option it prints them
|
|
58
|
+
rf can [CAP [EMAIL|GROUP,...] [--clear]] what users may do beyond the rest, as admins may: publish, push skills, and
|
|
59
|
+
create, make workspaces; a list grants CAP to those emails and Entra group ids in place of
|
|
60
|
+
whom it had, --clear to no one, and with neither it prints whom each is granted to`;
|
|
48
61
|
|
|
49
62
|
const GUIDE = `rollforward runs a team's recurring work, such as a weekly borrowing base or a month-end reconciliation, with an agent
|
|
50
63
|
that does each period's work and people who check it. rf does what its page does, as you.
|
|
@@ -64,30 +77,37 @@ What there is
|
|
|
64
77
|
What rf pull copies, the folders as the agent sees them
|
|
65
78
|
AGENTS.md the company's conventions; <workspace>/AGENTS.md the workspace's
|
|
66
79
|
<workspace>/<series>/<label>/
|
|
67
|
-
|
|
80
|
+
screen.json the screen: {rev, status, items: [{id, name, kind, file, from, headline, source}]}
|
|
68
81
|
log.jsonl every event, by seq: by is a person's email, "server" or "agent"; op is upload, comment (thread, item,
|
|
69
82
|
ref, text, ask, to, signoff), resolve, signoff (the runner's answer, with its commit), commit, point and
|
|
70
83
|
item (the screen changing), run, report (the agent's account of a run), done (its cost, summary or
|
|
71
84
|
error), close, and the rest
|
|
72
85
|
upload/ what people uploaded, their comments' attachments in upload/attachments/
|
|
73
86
|
working/ what the agent made, its scripts, and process.md, how it does this series
|
|
74
|
-
session/
|
|
87
|
+
session/ each run's session: every message and tool call of it
|
|
75
88
|
browser/ each run's browser requests, and its screenshots
|
|
89
|
+
skills/ the skills the latest run loaded
|
|
90
|
+
names.tsv each instance in the latest run's reach, id<TAB>/work/<workspace>/<series>/<label>: names can
|
|
91
|
+
change, so where a path in a file doesn't match, look its id up in the names.tsv of the commit
|
|
92
|
+
that last changed the file (git log -1 -- FILE, then git show H:names.tsv), and its name now in
|
|
93
|
+
rf ls
|
|
76
94
|
The copy is read-only, and only rf changes what's on the server: comment, upload and wake.
|
|
77
95
|
|
|
78
96
|
Usual work
|
|
79
97
|
- What waits on me: rf ls, then the asks in that instance's log.jsonl, ask true, whose thread has nothing after them.
|
|
80
98
|
- Answer an ask: rf comment PATH TEXT --thread T --wait, which prints what the agent says back.
|
|
81
99
|
- Give an input or a corrected output: rf upload PATH FILE [--onto ITEM] [--output].
|
|
82
|
-
- Start an instance: rf wake SERIES now
|
|
83
|
-
someone to start it; take one you run up later: rf wake PATH +2h
|
|
100
|
+
- Start an instance: rf wake SERIES now --label LABEL, which starts it as whoever shares the series, else asks on the page for
|
|
101
|
+
someone to start it; take one you run up later: rf wake PATH +2h.
|
|
84
102
|
- Read what a run did: rf pull PATH/ DIR, then its report and done entries in log.jsonl, the files in working/, and session/ for
|
|
85
103
|
every step.
|
|
86
104
|
|
|
87
105
|
Watching over it, for admins and power users; each sees what the caller sees, and takes --json
|
|
88
106
|
- What's stuck: rf status lists runs going, flagging those past --long MIN (30); queued runs, since when and why: their series is
|
|
89
107
|
running, the RF_MAX_RUNS cap, or memory; what waits on whom since when: asks, notes for runners, expired logins and the instances
|
|
90
|
-
they hold, and requests to start;
|
|
108
|
+
they hold, and requests to start; open instances whose last run failed; and indexes crawling or failing.
|
|
109
|
+
- Indexes: rf indexes shows each index of a big library or mailbox you index, every one for admins: its items and size, and per
|
|
110
|
+
person whether it is crawling or following changes, pages read, when last caught up, and an error, if any, with its next try.
|
|
91
111
|
- History: rf runs [PATH] [--since DATE] [--failed] [--running] [--long MIN] prints a line per run: its start, path, run number,
|
|
92
112
|
outcome, time taken, cost, what started it and by whom, and its summary or error. rf costs [PATH] [--since DATE] [--by
|
|
93
113
|
workspace|series|person|day] totals them, by the runner for person.
|
|
@@ -231,9 +251,16 @@ if (cmd === 'login' && url) {
|
|
|
231
251
|
writeFileSync(config, JSON.stringify({ url, token }), { mode: 0o600 });
|
|
232
252
|
console.log(`signed in as ${me.email}`);
|
|
233
253
|
} else if (cmd === 'ls') {
|
|
254
|
+
const wakes = (list ) => {
|
|
255
|
+
for (const k of list) console.log(` wake ${k.id} ${k.at}${k.label ? ` starts ${k.label}` : ''}${k.days ? `, then each ${k.days.join(', ')}` : ''}`);
|
|
256
|
+
};
|
|
234
257
|
for (const w of await get('/api')) for (const s of w.series) {
|
|
235
|
-
console.log(`${w.name}/${s.name}${s.
|
|
236
|
-
|
|
258
|
+
console.log(`${w.name}/${s.name}${s.requests.length ? ` ${s.requests.length} asking to start` : ''}`);
|
|
259
|
+
wakes(s.wakes);
|
|
260
|
+
for (const i of s.instances) {
|
|
261
|
+
console.log(`${w.name}/${s.name}/${i.label} ${i.status}${i.running ? ', running' : ''}${i.asks.length ? `, ${i.asks.length} asks waiting` : ''}, runner ${i.runner}`);
|
|
262
|
+
wakes(i.wakes);
|
|
263
|
+
}
|
|
237
264
|
}
|
|
238
265
|
} else if (cmd === 'pull' && args.length === 2) await pull(args[0], args[1]);
|
|
239
266
|
else if (cmd === 'comment' && args.length === 2) {
|
|
@@ -256,11 +283,14 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
256
283
|
const q = new URLSearchParams({ name: basename(args[1]), pane: flags.output ? 'out' : 'in', ...(typeof flags.onto === 'string' && { onto: flags.onto }) });
|
|
257
284
|
await api(`${(await find(args[0])).at}/upload?${q}`, { method: 'POST', body: readFileSync(args[1]) });
|
|
258
285
|
console.log('uploaded');
|
|
259
|
-
} else if (cmd === 'wake' && args.length
|
|
286
|
+
} else if (cmd === 'wake' && typeof flags.cancel === 'string' && !args.length) {
|
|
287
|
+
await api(`/api/wakes/${flags.cancel}`, { method: 'DELETE' });
|
|
288
|
+
console.log('cancelled');
|
|
289
|
+
} else if (cmd === 'wake' && args.length === 2) {
|
|
260
290
|
const { series, inst } = await find(args[0]);
|
|
261
291
|
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]);
|
|
262
|
-
const w = await (await post(`/api/wakes/${inst?.id ?? series.id}`, { at: new Date(at).toISOString(),
|
|
263
|
-
console.log(`
|
|
292
|
+
const w = await (await post(`/api/wakes/${inst?.id ?? series.id}`, { at: new Date(at).toISOString(), label: flags.label, days: flags.days }, 'PUT')).json();
|
|
293
|
+
console.log(`wake ${w.id} at ${w.at}${w.days ? `, then each ${w.days.join(', ')}` : ''}`);
|
|
264
294
|
} else if (cmd === 'agents' && args.length <= 1) {
|
|
265
295
|
const ws = args[0] === undefined ? undefined : (await get('/api')).find(w => w.name === args[0]);
|
|
266
296
|
if (args[0] !== undefined && !ws) throw new Error(`no workspace ${args[0]}`);
|
|
@@ -274,6 +304,17 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
274
304
|
const files = Object.fromEntries(readdirSync(args[1], { recursive: true, withFileTypes: true }).filter(d => d.isFile())
|
|
275
305
|
.map(d => [relative(args[1], join(d.parentPath, d.name)).split(sep).join('/'), readFileSync(join(d.parentPath, d.name)).toString('base64')]));
|
|
276
306
|
console.log(await (await post(`/skills/${encodeURIComponent(basename(resolve(args[1])))}/versions`, { files })).text());
|
|
307
|
+
} else if (cmd === 'skill' && args[0] === 'pull' && args[1] && args.length <= 3) {
|
|
308
|
+
const id = encodeURIComponent(args[1]), dir = resolve(args[2] ?? args[1]), n = flags.version ?? (await get(`/skills/${id}/versions`)).at(-1)?.version;
|
|
309
|
+
if (n === undefined) throw new Error(`no skill ${args[1]}`);
|
|
310
|
+
if (existsSync(dir) && readdirSync(dir).length) throw new Error(`${dir} isn't empty: pull into a new folder, so nothing stale goes along when you push it`);
|
|
311
|
+
for (const [rel, data] of Object.entries (await get(`/skills/${id}/versions/${n}`))) {
|
|
312
|
+
const path = under(dir, rel);
|
|
313
|
+
if (!path) throw new Error(`${rel} can't be a file's name here`);
|
|
314
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
315
|
+
writeFileSync(path, Buffer.from(data, 'base64'));
|
|
316
|
+
}
|
|
317
|
+
console.log(`pulled ${args[1]} version ${n} into ${dir}`);
|
|
277
318
|
} else if (cmd === 'skill' && args[0] === 'versions' && args[1]) {
|
|
278
319
|
for (const v of await get(`/skills/${encodeURIComponent(args[1])}/versions`)) console.log(`${v.version} ${v.at} ${v.by}`);
|
|
279
320
|
} else if (cmd === 'skill' && args[0] === 'rollback' && args.length === 3) {
|
|
@@ -289,8 +330,8 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
289
330
|
await api(`/connections/${encodeURIComponent(args[1])}`, { method: 'DELETE' });
|
|
290
331
|
console.log('removed');
|
|
291
332
|
} else if (cmd === 'status' && !args.length) {
|
|
292
|
-
const s = await get('/api/status'), long = Number(flags.long ?? 30);
|
|
293
|
-
if (flags.json) console.log(JSON.stringify(s, null, 1));
|
|
333
|
+
const [s, ix] = await Promise.all([get('/api/status'), get('/api/indexes')]), long = Number(flags.long ?? 30);
|
|
334
|
+
if (flags.json) console.log(JSON.stringify({ ...s, indexes: ix }, null, 1));
|
|
294
335
|
else {
|
|
295
336
|
const sections = [
|
|
296
337
|
[`Running`, s.running.map(r => `${r.path} run ${r.run} for ${took((Date.now() - Date.parse(r.at)) / 1000)} ${usd(r.cost)}${Date.now() - Date.parse(r.at) > long * 60e3 ? ` LONG, past ${long}m` : ''}`)],
|
|
@@ -298,12 +339,19 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
298
339
|
[`Waiting`, [
|
|
299
340
|
...s.asks.sort((a, b) => a.who.localeCompare(b.who) || a.since.localeCompare(b.since)).map(a => `${a.who} ${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)}`),
|
|
300
341
|
...s.expired.map(e => `${e.who} their ${e.login} login expired${e.holding.length ? `, holding ${e.holding.join(', ')}` : ''}`),
|
|
301
|
-
...s.requests.map(r => `${r.path} ${r.from} asks to start ${r.label}, since ${when(r.at)}
|
|
342
|
+
...s.requests.map(r => `${r.path} ${r.from} asks to start ${r.label}, since ${when(r.at)}`),
|
|
302
343
|
]],
|
|
303
344
|
[`Last run failed`, s.failed.map(f => `${f.path} run ${f.run} at ${when(f.at)}: ${f.error}`)],
|
|
345
|
+
[`Indexes crawling or failing`, ix.filter(x => x.people.some(p => p.phase === 'crawl' || p.error)).map(x => `${x.name} ${x.people.filter(p => p.phase === 'crawl' || p.error)
|
|
346
|
+
.map(p => `${p.who} ${p.error ? `failing${p.retry_at ? `, again ${when(p.retry_at)}` : ''}: ${p.error.split('\n')[0].slice(0, 80)}` : `crawling, ${p.pages} pages`}`).join('; ')}`)],
|
|
304
347
|
].filter(([, rows]) => rows.length);
|
|
305
348
|
console.log(sections.map(([title, rows]) => `${title} (${rows.length})\n${rows.map(r => ` ${r}`).join('\n')}`).join('\n\n') || 'Nothing is running, queued, waiting or failed.');
|
|
306
349
|
}
|
|
350
|
+
} else if (cmd === 'indexes' && !args.length) {
|
|
351
|
+
const ix = await get('/api/indexes');
|
|
352
|
+
if (flags.json) console.log(JSON.stringify(ix, null, 1));
|
|
353
|
+
else console.log(ix.map(x => [`${x.name} ${x.kind} ${x.items} items ${(x.bytes / 2 ** 20).toFixed(1)} MB`, ...x.people.map(p =>
|
|
354
|
+
` ${p.who} ${p.phase} ${p.pages} pages caught up ${p.caught_up ? when(p.caught_up) : 'never'}${p.error ? ` ${p.retry_at ? `again ${when(p.retry_at)}` : 'stopped'}: ${p.error}` : ''}`)].join('\n')).join('\n\n') || 'No indexes.');
|
|
307
355
|
} else if (cmd === 'runs' && args.length <= 1) {
|
|
308
356
|
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));
|
|
309
357
|
if (flags.json) console.log(JSON.stringify(rows, null, 1));
|
|
@@ -329,10 +377,10 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
329
377
|
: (await get('/users')).map(u => ({ kind: u.role, who: u.email, note: [u.disabled && 'disabled', last(u.last_login), `in ${u.workspaces.join(', ') || 'none'}`, u.outside.length && `runs outside them: ${u.outside.join(', ')}`] }));
|
|
330
378
|
if (typeof flags.set !== 'string') {
|
|
331
379
|
const w = Math.max(0, ...now.map(p => p.who.length));
|
|
332
|
-
for (const p of now) console.log(`${p.kind.padEnd(
|
|
380
|
+
for (const p of now) console.log(`${p.kind.padEnd(6)} ${p.who.padEnd(w)} # ${p.note.filter(Boolean).join('; ')}`);
|
|
333
381
|
if (!now.length) console.log('# no one is in it: only admins see it');
|
|
334
382
|
} else {
|
|
335
|
-
const kinds = ws ? ['owner', 'member'] : ['admin', '
|
|
383
|
+
const kinds = ws ? ['owner', 'member'] : ['admin', 'user'];
|
|
336
384
|
const want = readFileSync(flags.set === '-' ? 0 : flags.set, 'utf8').split('\n').map(l => l.replace(/#.*/, '').trim()).filter(Boolean).map(l => l.split(/\s+/));
|
|
337
385
|
const bad = want.find(([kind, who, more]) => !kinds.includes(kind) || !who || more);
|
|
338
386
|
if (bad) throw new Error(`each line is ${kinds.join('|')} ${ws ? 'EMAIL-OR-GROUP' : 'EMAIL'}, not: ${bad.join(' ')}`);
|
|
@@ -356,6 +404,10 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
356
404
|
const { text, logo } = (await get('/me')).brand;
|
|
357
405
|
console.log(text || logo ? `${text ?? 'no text'}, ${logo ? 'with a logo' : 'no logo'}` : 'no brand: the plain look');
|
|
358
406
|
}
|
|
407
|
+
} else if (cmd === 'can' && args.length <= 2) {
|
|
408
|
+
const [cap, list] = args, people = flags.clear ? [] : list?.split(',').map(p => p.trim()).filter(Boolean);
|
|
409
|
+
const all = await (await (people ? post('/capabilities', { cap, people }, 'PUT') : api('/capabilities'))).json();
|
|
410
|
+
for (const [c, who] of Object.entries(all)) if (!cap || c === cap) console.log(`${c}: ${who.join(', ') || 'admins only'}`);
|
|
359
411
|
} else if (cmd === 'user' && args.length >= 2) {
|
|
360
412
|
const [what, email, role] = args, at = `/users/${encodeURIComponent(email)}`;
|
|
361
413
|
if (what === 'add') await post('/users', { roles: { [email]: role ?? 'user' } }, 'PUT');
|