@rfany/rf 0.18.0 → 0.19.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.
- package/package.json +1 -1
- package/rf.mjs +28 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rfany/rf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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
|
@@ -96,11 +96,12 @@ rf grant approve|deny ID [TEXT] a request to use a website in a workspace you
|
|
|
96
96
|
rf grant revoke ID a grant pending or approved, yours or in a workspace you own; its runs' browsers close
|
|
97
97
|
rf correct PATH TEXT [--item ID] [--ref REF] [--superseded] [--see LABEL] a closed instance, or its item ID at REF, is
|
|
98
98
|
wrong, or superseded, as LABEL, another instance of its series, shows; it can't be withdrawn
|
|
99
|
-
rf wake PATH AT [TEXT] [--label LABEL] [--days DAYS] | rf wake --cancel ID
|
|
99
|
+
rf wake PATH AT [TEXT] [--label LABEL] [--days DAYS] [--check PATH [--deadline ISO]] | rf wake --cancel ID
|
|
100
100
|
AT now, +<n>m|h|d or a date; PATH an open instance, or a series with LABEL; TEXT a short
|
|
101
101
|
message for the run; the owner's now starts under current consent without autonomous opt-in;
|
|
102
102
|
later or agent-set wakes need it. Collaborators' wakes are requests. DAYS, such as mon-fri,
|
|
103
|
-
repeats weekly at AT's time
|
|
103
|
+
repeats weekly at AT's time. With the owner's wake-check capability, --check working/FILE.py (or .ts)
|
|
104
|
+
gates a scheduled wake; optional --deadline TIME (ISO with offset) runs Pi even if the check stops.
|
|
104
105
|
rf note SERIES [TEXT] [--json] tells the series something for its runs, about the series rather than one period or while no
|
|
105
106
|
instance is open, which starts no run; without TEXT, its notes, open and settled
|
|
106
107
|
rf agents [WORKSPACE] [--set FILE|-] the company's AGENTS.md, or a workspace's; setting the company's is for admins
|
|
@@ -158,11 +159,10 @@ rf connection remove NAME
|
|
|
158
159
|
rf brand [--text TEXT] [--logo FILE] [--clear] the deployment's text and logo, a .png, .jpg, .gif, .webp or .svg, which top
|
|
159
160
|
the sidebar and are the page's title and icon; --clear goes back to the plain look, and with
|
|
160
161
|
no option it prints them
|
|
161
|
-
rf can [CAP [EMAIL|GROUP,...
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
prints whom each is granted to${vpn ? '\n vpn, using client VPNs, needs an explicit grant even for admins' : ''}${vpn && admin ? '\nrf vpn add NAME fortinet HOST:PORT [--servercert pin-sha256:HASH] admins with vpn add a client VPN definition, which each\n person signs in to on the page; --servercert pins the gateway key, as a refusal names it\nrf vpn remove NAME admins with vpn remove a client VPN definition' : ''}`;
|
|
162
|
+
rf can [CAP [EMAIL|GROUP,... | --add EMAIL|GROUP,... | --remove EMAIL|GROUP,... | --clear]]
|
|
163
|
+
grants to emails and Entra group ids. A bare list replaces the grants; --add and --remove
|
|
164
|
+
change only the named grantees; --clear grants to no one. With no change it lists them.
|
|
165
|
+
publish, create and keepalive are implicit for admins; wake-check needs an explicit grant${vpn ? '\n vpn, using client VPNs, needs an explicit grant even for admins' : ''}${vpn && admin ? '\nrf vpn add NAME fortinet HOST:PORT [--servercert pin-sha256:HASH] admins with vpn add a client VPN definition, which each\n person signs in to on the page; --servercert pins the gateway key, as a refusal names it\nrf vpn remove NAME admins with vpn remove a client VPN definition' : ''}`;
|
|
166
166
|
return (c && all.split(/\n(?=\S)/).map(e => e.trimEnd()).filter(e => e.split(/\s/)[1] === c).join('\n')) || all;
|
|
167
167
|
};
|
|
168
168
|
|
|
@@ -531,12 +531,13 @@ if (cmd === 'login' && url) {
|
|
|
531
531
|
// --mine: open instances of series you own.
|
|
532
532
|
const me = flags.mine && await get('/me'), rows = (await get('/api')).flatMap(w => w.series.flatMap(s => [
|
|
533
533
|
...me ? [] : [{ path: `${w.name}/${s.name}`, id: s.id, owner: s.owner, requests: s.requests.length, wakes: s.wakes }],
|
|
534
|
-
...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 }) })),
|
|
534
|
+
...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.wakeCheck && { wakeCheck: i.wakeCheck }), ...(i.deleted && { deleted: i.deleted }) })),
|
|
535
535
|
]));
|
|
536
536
|
if (flags.json) console.log(JSON.stringify(rows, null, 1));
|
|
537
537
|
else for (const r of rows) {
|
|
538
538
|
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` : ''}`);
|
|
539
|
-
|
|
539
|
+
if (r.wakeCheck) console.log(` Wake check stopped: ${clip(r.wakeCheck.message.replace(/[\x00-\x1f\x7f-\x9f]/g, ' '), TEXT_COLS)}`);
|
|
540
|
+
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}` : ''}${k.check ? `; check ${k.check}${k.deadline ? ` until ${k.deadline}` : ''}` : ''}`);
|
|
540
541
|
}
|
|
541
542
|
} else if (cmd === 'waiting' && !args.length) {
|
|
542
543
|
const [me, s, all] = await Promise.all([get('/me'), get('/api/status'), get('/api')]), mine = (who ) => (who ?? me.email) === me.email;
|
|
@@ -772,8 +773,8 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
772
773
|
} else if (cmd === 'wake' && [2, 3].includes(args.length)) {
|
|
773
774
|
const { series, inst } = await find(args[0]);
|
|
774
775
|
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]);
|
|
775
|
-
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] }, 'PUT')).json();
|
|
776
|
-
console.log(`wake ${w.id} at ${w.at}${w.days ? `, then each ${w.days.join(', ')}` : ''}`);
|
|
776
|
+
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
|
+
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}` : ''}` : ''}`);
|
|
777
778
|
} else if (cmd === 'note' && [1, 2].includes(args.length)) {
|
|
778
779
|
const at = `/api/series/${(await seriesAt(args[0])).id}/notes`;
|
|
779
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`);
|
|
@@ -879,8 +880,8 @@ else if (cmd === 'indexes' && !args.length) {
|
|
|
879
880
|
} else if (cmd === 'runs' && args.length <= 1) await watch(async () => {
|
|
880
881
|
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));
|
|
881
882
|
if (flags.json) return JSON.stringify(rows, null, 1);
|
|
882
|
-
return rows.length ? table(['START', 'PATH', 'RUN', 'OUTCOME', 'TIME', 'COST', 'STARTED BY', 'ERROR'], rows.map(r => [when(r.at), clip(r.path, PATH_COLS), String(r.run),
|
|
883
|
-
`${r.outcome}${r.failure ? ` (${r.failure})` : ''}`, took(r.seconds), usdNote(r.cost, r.estimated), r.started ? `${r.started.op} by ${r.started.by}` : '', r.error ? brief(r.error, TEXT_COLS) : '']), '') : 'No runs.';
|
|
883
|
+
return rows.length ? table(['START', 'PATH', 'RUN', 'OUTCOME', 'TIME', 'COST', 'STARTED BY', 'MESSAGE / ERROR'], rows.map(r => [when(r.at), clip(r.path, PATH_COLS), r.run === null ? '—' : String(r.run),
|
|
884
|
+
`${r.outcome}${r.failure ? ` (${r.failure})` : ''}`, took(r.seconds), usdNote(r.cost, r.estimated), r.started ? `${r.started.op} by ${r.started.by}` : '', r.error ? brief(r.error, TEXT_COLS) : clip((r.message ?? '').replace(/[\x00-\x1f\x7f-\x9f]/g, ' '), TEXT_COLS)]), '') : 'No runs.';
|
|
884
885
|
});
|
|
885
886
|
else if (cmd === 'top' && !args.length) await watch(async () => {
|
|
886
887
|
const m = await get('/monitor');
|
|
@@ -982,7 +983,7 @@ else if (cmd === 'kill' && args.length === 1 && /^\d+$/.test(args[0])) {
|
|
|
982
983
|
if (flags.json) console.log(JSON.stringify(rows, null, 1));
|
|
983
984
|
else for (const r of rows) {
|
|
984
985
|
console.log(`${r.path} last woken ${r.fired ? when(r.fired) : 'never'}${r.wakes.length || r.requests.length ? '' : ', none pending'}`);
|
|
985
|
-
for (const k of r.wakes) console.log(` wake ${k.id} ${when(k.at)}${k.label ? ` starts ${k.label}` : ''}${k.days ? `, then each ${k.days.join(', ')}` : ''}, set by ${k.from}${k.text ? `: ${k.text}` : ''}`);
|
|
986
|
+
for (const k of r.wakes) console.log(` wake ${k.id} ${when(k.at)}${k.label ? ` starts ${k.label}` : ''}${k.days ? `, then each ${k.days.join(', ')}` : ''}, set by ${k.from}${k.text ? `: ${k.text}` : ''}${k.check ? `; check ${k.check}${k.deadline ? ` until ${k.deadline}` : ''}` : ''}`);
|
|
986
987
|
for (const q of r.requests) console.log(` request ${q.id} to ${q.target ? 'wake' : 'start'} ${q.label}, from ${q.from} since ${when(q.at)}, waits on ${q.who ?? 'anyone'}${q.text ? `: ${q.text}` : ''}`);
|
|
987
988
|
}
|
|
988
989
|
} else if (cmd === 'activity' && args.length <= 1) {
|
|
@@ -1050,10 +1051,20 @@ else if (cmd === 'kill' && args.length === 1 && /^\d+$/.test(args[0])) {
|
|
|
1050
1051
|
console.log(flags.json ? JSON.stringify(brand) : text || logo ? `${text ?? 'no text'}, ${logo ? 'with a logo' : 'no logo'}` : 'no brand: the plain look');
|
|
1051
1052
|
}
|
|
1052
1053
|
} else if (cmd === 'can' && args.length <= 2) {
|
|
1053
|
-
const [cap, list] = args,
|
|
1054
|
-
|
|
1054
|
+
const [cap, list] = args, edits = [list, flags.add, flags.remove, flags.clear].filter(x => x !== undefined);
|
|
1055
|
+
if (edits.length > 1 || (edits.length && !cap)) {
|
|
1056
|
+
console.error(usage(cmd));
|
|
1057
|
+
process.exit(2);
|
|
1058
|
+
}
|
|
1059
|
+
const people = flags.clear ? [] : String(edits[0] ?? '').split(',').map(p => p.trim()).filter(Boolean);
|
|
1060
|
+
if ((flags.add || flags.remove) && !people.length) {
|
|
1061
|
+
console.error(usage(cmd));
|
|
1062
|
+
process.exit(2);
|
|
1063
|
+
}
|
|
1064
|
+
const key = flags.add ? 'add' : flags.remove ? 'remove' : 'people';
|
|
1065
|
+
const all = await (await (edits.length ? post('/capabilities', { cap, [key]: people }, 'PUT') : api('/capabilities'))).json();
|
|
1055
1066
|
if (flags.json) console.log(JSON.stringify(all, null, 1));
|
|
1056
|
-
else for (const [c, who] of Object.entries(all)) if (!cap || c === cap) console.log(`${c}: ${who.join(', ') || (c === 'vpn' ? 'no one' : 'admins only')}`);
|
|
1067
|
+
else for (const [c, who] of Object.entries(all)) if (!cap || c === cap) console.log(`${c}: ${who.join(', ') || (c === 'vpn' || c === 'wake-check' ? 'no one' : 'admins only')}`);
|
|
1057
1068
|
} else if (cmd === 'user' && args.length >= 2) {
|
|
1058
1069
|
const [what, email, role] = args, at = `/users/${encodeURIComponent(email)}`;
|
|
1059
1070
|
if (what === 'add') await post('/users', { roles: { [email]: role ?? 'user' } }, 'PUT');
|