@nanocollective/roster 0.1.0-beta.3 → 0.1.0-beta.31
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/README.md +8 -0
- package/dist/agents-POITEZRI.js +232 -0
- package/dist/chunk-FF2WBNNW.js +370 -0
- package/dist/chunk-GDAJPOHK.js +562 -0
- package/dist/cli.js +3391 -1239
- package/dist/compose-5DBEHSEV.js +17 -0
- package/dist/connectors-5E5ZMGZV.js +23 -0
- package/dist/worker/assets/assets/css/astryx.css +948 -0
- package/dist/worker/assets/assets/css/base.css +51 -110
- package/dist/worker/assets/assets/css/brain.css +28 -2
- package/dist/worker/assets/assets/css/connectors.css +58 -0
- package/dist/worker/assets/assets/css/graph.css +9 -12
- package/dist/worker/assets/assets/css/health.css +4 -7
- package/dist/worker/assets/assets/css/home.css +155 -60
- package/dist/worker/assets/assets/css/inbox.css +11 -0
- package/dist/worker/assets/assets/css/layout.css +18 -22
- package/dist/worker/assets/assets/css/markdown.css +22 -1
- package/dist/worker/assets/assets/css/routines.css +43 -0
- package/dist/worker/assets/assets/css/runs.css +5 -3
- package/dist/worker/assets/assets/css/search.css +3 -6
- package/dist/worker/assets/assets/css/setup.css +8 -15
- package/dist/worker/assets/assets/js/api.js +3 -0
- package/dist/worker/assets/assets/js/app.js +28 -1
- package/dist/worker/assets/assets/js/astryx-ui.js +34 -0
- package/dist/worker/assets/assets/js/dom.js +1 -1
- package/dist/worker/assets/assets/js/homesort.js +66 -20
- package/dist/worker/assets/assets/js/icons.js +6 -0
- package/dist/worker/assets/assets/js/md.js +7 -2
- package/dist/worker/assets/assets/js/mention.js +2 -1
- package/dist/worker/assets/assets/js/readiness.js +36 -0
- package/dist/worker/assets/assets/js/refcard.js +216 -0
- package/dist/worker/assets/assets/js/refresh.js +8 -2
- package/dist/worker/assets/assets/js/report.js +51 -0
- package/dist/worker/assets/assets/js/select.js +362 -0
- package/dist/worker/assets/assets/js/state.js +14 -1
- package/dist/worker/assets/assets/js/views/connectors.js +428 -0
- package/dist/worker/assets/assets/js/views/graph.js +67 -28
- package/dist/worker/assets/assets/js/views/health.js +11 -5
- package/dist/worker/assets/assets/js/views/home.js +453 -174
- package/dist/worker/assets/assets/js/views/inbox.js +82 -17
- package/dist/worker/assets/assets/js/views/notready.js +60 -0
- package/dist/worker/assets/assets/js/views/org.js +16 -1
- package/dist/worker/assets/assets/js/views/people.js +109 -0
- package/dist/worker/assets/assets/js/views/routines.js +395 -0
- package/dist/worker/assets/assets/js/views/runonce.js +5 -0
- package/dist/worker/assets/assets/js/views/runs.js +14 -2
- package/dist/worker/assets/assets/js/views/staff.js +18 -3
- package/dist/worker/assets/docs-images/brain.jpg +0 -0
- package/dist/worker/assets/docs-images/home.jpg +0 -0
- package/dist/worker/assets/docs-images/org.jpg +0 -0
- package/dist/worker/assets/docs-images/prompt.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
- package/dist/worker/assets/docs-images/staff.jpg +0 -0
- package/dist/worker/assets/index.html +19 -3
- package/dist/worker/index.js +4478 -1098
- package/docs/README.md +2 -0
- package/docs/architecture.md +23 -4
- package/docs/commands.md +111 -9
- package/docs/concepts.md +2 -1
- package/docs/connectors.md +169 -0
- package/docs/cost.md +1 -1
- package/docs/developing.md +3 -3
- package/docs/doctor-codes.md +8 -2
- package/docs/export.md +4 -3
- package/docs/extending.md +1 -1
- package/docs/getting-started.md +20 -3
- package/docs/hosting.md +67 -3
- package/docs/images/brain.jpg +0 -0
- package/docs/images/home.jpg +0 -0
- package/docs/images/org.jpg +0 -0
- package/docs/images/prompt.jpg +0 -0
- package/docs/images/setup-org.jpg +0 -0
- package/docs/images/setup-plan.jpg +0 -0
- package/docs/images/staff.jpg +0 -0
- package/docs/memory.md +3 -2
- package/docs/org-yaml.md +58 -5
- package/docs/portal.md +52 -11
- package/docs/prompts.md +3 -2
- package/docs/routines.md +65 -0
- package/docs/security.md +37 -4
- package/docs/session-workflow.md +31 -8
- package/docs/staff-yaml.md +7 -3
- package/docs/troubleshooting.md +1 -1
- package/docs/upgrading.md +1 -1
- package/docs/writing-a-charter.md +1 -1
- package/package.json +8 -1
- package/templates/brain/.gitattributes +3 -0
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +24 -15
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +12 -10
- package/templates/brain/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- package/templates/brain/staff.yaml +3 -0
- package/templates/ops/.gitattributes +3 -0
- package/templates/ops/.github/workflows/session.yaml +92 -13
- package/templates/ops/agents.mjs +38 -11
- package/templates/ops/compose.mjs +60 -2
- package/templates/ops/connectors.mjs +722 -0
- package/templates/ops/org/operating.md +10 -0
- package/templates/ops/org/voice.md +21 -3
- package/templates/ops/prompts/_identity.md +20 -0
- package/templates/ops/prompts/daily.md +70 -19
- package/templates/ops/prompts/mention.md +7 -2
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/astryx.css +948 -0
- package/templates/portal/css/base.css +51 -110
- package/templates/portal/css/brain.css +28 -2
- package/templates/portal/css/connectors.css +58 -0
- package/templates/portal/css/graph.css +9 -12
- package/templates/portal/css/health.css +4 -7
- package/templates/portal/css/home.css +155 -60
- package/templates/portal/css/inbox.css +11 -0
- package/templates/portal/css/layout.css +18 -22
- package/templates/portal/css/markdown.css +22 -1
- package/templates/portal/css/routines.css +43 -0
- package/templates/portal/css/runs.css +5 -3
- package/templates/portal/css/search.css +3 -6
- package/templates/portal/css/setup.css +8 -15
- package/templates/portal/index.html +19 -3
- package/templates/portal/js/api.js +3 -0
- package/templates/portal/js/app.js +28 -1
- package/templates/portal/js/astryx-ui.js +34 -0
- package/templates/portal/js/dom.js +1 -1
- package/templates/portal/js/homesort.js +66 -20
- package/templates/portal/js/icons.js +6 -0
- package/templates/portal/js/md.js +7 -2
- package/templates/portal/js/mention.js +2 -1
- package/templates/portal/js/readiness.js +36 -0
- package/templates/portal/js/refcard.js +216 -0
- package/templates/portal/js/refresh.js +8 -2
- package/templates/portal/js/report.js +51 -0
- package/templates/portal/js/select.js +362 -0
- package/templates/portal/js/state.js +14 -1
- package/templates/portal/js/views/connectors.js +428 -0
- package/templates/portal/js/views/graph.js +67 -28
- package/templates/portal/js/views/health.js +11 -5
- package/templates/portal/js/views/home.js +453 -174
- package/templates/portal/js/views/inbox.js +82 -17
- package/templates/portal/js/views/notready.js +60 -0
- package/templates/portal/js/views/org.js +16 -1
- package/templates/portal/js/views/people.js +109 -0
- package/templates/portal/js/views/routines.js +395 -0
- package/templates/portal/js/views/runonce.js +5 -0
- package/templates/portal/js/views/runs.js +14 -2
- package/templates/portal/js/views/staff.js +18 -3
- package/templates/skill/SKILL.md +115 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/* The Routines screen: when each staff member wakes, and what they do then.
|
|
2
|
+
*
|
|
3
|
+
* Every staff member has a daily round. A routine is one more wake-up with its own job: a time,
|
|
4
|
+
* a name, and what to do in the person's own words. Saving writes the staff member's
|
|
5
|
+
* staff.yaml, routines/<id>.md and the daily caller in one commit, as you.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { post } from "../api.js";
|
|
9
|
+
import { sheet } from "../dialog.js";
|
|
10
|
+
import { el, grow } from "../dom.js";
|
|
11
|
+
import { icon } from "../icons.js";
|
|
12
|
+
import { canRun, whatsLeft } from "../readiness.js";
|
|
13
|
+
import { render } from "../router.js";
|
|
14
|
+
import { S } from "../state.js";
|
|
15
|
+
import { commandLine, notReadyNote, whenKnown } from "./notready.js";
|
|
16
|
+
|
|
17
|
+
/* The last answer, so a repaint after Save does not flash an empty screen. */
|
|
18
|
+
let last = null;
|
|
19
|
+
|
|
20
|
+
export function viewRoutines(m) {
|
|
21
|
+
const add = el("button", { className: "ghbtn primary", textContent: "New routine" });
|
|
22
|
+
m.append(el("div", { className: "routhead" }, [el("h1", { textContent: "Routines" }), add]));
|
|
23
|
+
const body = el("div");
|
|
24
|
+
m.append(body);
|
|
25
|
+
if (last) draw(body, last, add);
|
|
26
|
+
else body.append(el("p", { className: "sub", textContent: "Loading…" }));
|
|
27
|
+
fetch("/api/routines")
|
|
28
|
+
.then((r) => r.json())
|
|
29
|
+
.then((d) => {
|
|
30
|
+
if (d.error) throw new Error(d.error);
|
|
31
|
+
last = d;
|
|
32
|
+
body.replaceChildren();
|
|
33
|
+
draw(body, d, add);
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => body.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) })));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function draw(body, d, add) {
|
|
39
|
+
add.onclick = () => edit(d, null, null);
|
|
40
|
+
add.disabled = !d.staff.length;
|
|
41
|
+
if (!d.staff.length) {
|
|
42
|
+
body.append(el("p", { className: "sub", textContent: S.hosted ? "Hire a staff member first, on your machine:" : "Hire a staff member first, under Staff." }));
|
|
43
|
+
if (S.hosted) body.append(commandLine("hire cto --apply"));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const s of d.staff) {
|
|
47
|
+
const list = el("div", { className: "connlist routlist" });
|
|
48
|
+
list.append(dailyRow(s, d));
|
|
49
|
+
for (const r of s.routines) list.append(routineRow(s, r, d));
|
|
50
|
+
const more = el("button", { className: "routadd" }, [icon("plus"), el("span", { textContent: "Add a routine for " + s.name })]);
|
|
51
|
+
more.onclick = () => edit(d, s, null);
|
|
52
|
+
list.append(more);
|
|
53
|
+
// Routines run on the same App and credential as everything else, so they wait on setup too.
|
|
54
|
+
const who = whole(s);
|
|
55
|
+
body.append(el("h2", { className: "connhead", textContent: s.name }), whenKnown(who, () => notReadyNote(who)), list);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function dailyRow(s, d) {
|
|
60
|
+
const change = el("button", { className: "ghbtn", textContent: "Change time" });
|
|
61
|
+
change.onclick = () => editDaily(d, s);
|
|
62
|
+
return el("div", { className: "connrow routrow" }, [
|
|
63
|
+
el("span", { className: "connicon" }, [icon("refresh")]),
|
|
64
|
+
el("div", { className: "conntext" }, [
|
|
65
|
+
el("b", { textContent: "Daily round" }),
|
|
66
|
+
el("span", { className: "routwhen", textContent: s.dailyWhen }),
|
|
67
|
+
]),
|
|
68
|
+
el("div", { className: "row connacts" }, [change]),
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function routineRow(s, r, d) {
|
|
73
|
+
const run = el("button", { className: "ghbtn", textContent: "Run now" });
|
|
74
|
+
run.onclick = () => runNow(s, r, run);
|
|
75
|
+
const who = whole(s);
|
|
76
|
+
whatsLeft(who).then(() => {
|
|
77
|
+
if (canRun(s.handle)) return;
|
|
78
|
+
run.disabled = true;
|
|
79
|
+
run.title = `${s.name} is not set up yet`;
|
|
80
|
+
}, () => {});
|
|
81
|
+
const change = el("button", { className: "ghbtn", textContent: "Edit" });
|
|
82
|
+
change.onclick = () => edit(d, s, r);
|
|
83
|
+
const remove = el("button", { className: "ghbtn", textContent: "Remove" });
|
|
84
|
+
remove.onclick = () => confirmRemove(s, r, remove);
|
|
85
|
+
return el("div", { className: "connrow routrow" }, [
|
|
86
|
+
el("span", { className: "connicon" }, [icon("clock")]),
|
|
87
|
+
el("div", { className: "conntext" }, [
|
|
88
|
+
el("b", { textContent: r.title }),
|
|
89
|
+
el("span", { className: "routwhen", textContent: r.when }),
|
|
90
|
+
r.body ? el("span", { className: "routbody", textContent: r.body }) : null,
|
|
91
|
+
].filter(Boolean)),
|
|
92
|
+
el("div", { className: "row connacts" }, [run, change, remove]),
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The staff member as the org export has them, which is what readiness reads. */
|
|
97
|
+
function whole(s) {
|
|
98
|
+
return (S.data?.staff ?? []).find((x) => x.handle === s.handle) ?? s;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function runNow(s, r, btn) {
|
|
102
|
+
btn.disabled = true;
|
|
103
|
+
btn.textContent = "Starting…";
|
|
104
|
+
try {
|
|
105
|
+
const res = await post({ staff: s.handle, routine: r.id }, "/api/run/start");
|
|
106
|
+
btn.replaceWith(el("a", { className: "ghbtn", href: res.url, target: "_blank", rel: "noopener", textContent: "Started" }));
|
|
107
|
+
} catch (err) {
|
|
108
|
+
btn.disabled = false;
|
|
109
|
+
btn.textContent = "Run now";
|
|
110
|
+
btn.title = String(err.message || err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function confirmRemove(s, r, btn) {
|
|
115
|
+
if (btn.dataset.sure !== "1") {
|
|
116
|
+
btn.dataset.sure = "1";
|
|
117
|
+
btn.textContent = "Remove " + r.title + "?";
|
|
118
|
+
btn.classList.add("danger");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
btn.disabled = true;
|
|
122
|
+
btn.textContent = "Removing…";
|
|
123
|
+
try {
|
|
124
|
+
await save(s, s.daily, s.routines.filter((x) => x.id !== r.id));
|
|
125
|
+
last = null;
|
|
126
|
+
render();
|
|
127
|
+
} catch (err) {
|
|
128
|
+
btn.textContent = String(err.message || err);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** One staff member's whole schedule, as the server wants it. */
|
|
133
|
+
function save(s, daily, routines) {
|
|
134
|
+
return post(
|
|
135
|
+
{
|
|
136
|
+
staff: s.handle,
|
|
137
|
+
daily,
|
|
138
|
+
routines: routines.map((r) => ({ id: r.id, title: r.title, body: r.body, schedule: r.schedule })),
|
|
139
|
+
},
|
|
140
|
+
"/api/routines/save",
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* --------------------------------- editors --------------------------------- */
|
|
145
|
+
|
|
146
|
+
function edit(d, s, r) {
|
|
147
|
+
let box = null;
|
|
148
|
+
const node = routineForm(d, s, r, () => box?.close());
|
|
149
|
+
box = sheet({ node, onClose: () => {} });
|
|
150
|
+
if (!box) document.querySelector("#main")?.append(node);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function editDaily(d, s) {
|
|
154
|
+
let box = null;
|
|
155
|
+
const close = () => box?.close();
|
|
156
|
+
const out = el("div", { className: "routform" });
|
|
157
|
+
out.append(el("h2", { className: "sheettitle", textContent: s.name + "'s daily round" }));
|
|
158
|
+
const when = whenField(s.daily);
|
|
159
|
+
out.append(when.node);
|
|
160
|
+
const status = el("div");
|
|
161
|
+
const ok = el("button", { className: "ghbtn primary", textContent: "Save" });
|
|
162
|
+
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
163
|
+
cancel.onclick = close;
|
|
164
|
+
ok.onclick = async () => {
|
|
165
|
+
ok.disabled = true;
|
|
166
|
+
ok.textContent = "Saving…";
|
|
167
|
+
try {
|
|
168
|
+
await save(s, when.value(), s.routines);
|
|
169
|
+
last = null;
|
|
170
|
+
close();
|
|
171
|
+
render();
|
|
172
|
+
} catch (err) {
|
|
173
|
+
ok.disabled = false;
|
|
174
|
+
ok.textContent = "Save";
|
|
175
|
+
status.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
out.append(status, el("div", { className: "row connfoot" }, [ok, cancel]));
|
|
179
|
+
box = sheet({ node: out, onClose: () => {} });
|
|
180
|
+
if (!box) document.querySelector("#main")?.append(out);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function routineForm(d, s, r, close) {
|
|
184
|
+
const out = el("div", { className: "routform" });
|
|
185
|
+
out.append(el("h2", { className: "sheettitle", textContent: r ? r.title : "New routine" }));
|
|
186
|
+
|
|
187
|
+
let who = s ?? d.staff[0];
|
|
188
|
+
const pick = el("div", { className: "routwho" });
|
|
189
|
+
if (!r) {
|
|
190
|
+
for (const p of d.staff) {
|
|
191
|
+
const chip = el("button", { className: "routchip" + (p === who ? " on" : ""), textContent: p.name, type: "button" });
|
|
192
|
+
chip.onclick = () => {
|
|
193
|
+
who = p;
|
|
194
|
+
for (const c of pick.children) c.classList.toggle("on", c === chip);
|
|
195
|
+
say();
|
|
196
|
+
};
|
|
197
|
+
pick.append(chip);
|
|
198
|
+
}
|
|
199
|
+
out.append(field("Who", pick));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const name = el("input", { type: "text", value: r?.title ?? "", placeholder: "Monday plan", spellcheck: true });
|
|
203
|
+
out.append(field("Name", name));
|
|
204
|
+
|
|
205
|
+
const when = whenField(r?.schedule ?? "0 9 * * 1");
|
|
206
|
+
out.append(when.node);
|
|
207
|
+
|
|
208
|
+
const todo = el("textarea", {
|
|
209
|
+
className: "routtodo",
|
|
210
|
+
value: r?.body ?? "",
|
|
211
|
+
rows: 8,
|
|
212
|
+
placeholder: "Plan the week. Read last week's status issue and this month's priorities, then open one issue per thing to ship this week, ranked.",
|
|
213
|
+
});
|
|
214
|
+
out.append(field("What to do", todo));
|
|
215
|
+
|
|
216
|
+
const preview = el("div", { className: "routpreview" });
|
|
217
|
+
out.append(preview);
|
|
218
|
+
const say = () => {
|
|
219
|
+
const text = todo.value.trim();
|
|
220
|
+
preview.replaceChildren(
|
|
221
|
+
el("span", { className: "connicon" }, [icon("clock")]),
|
|
222
|
+
el("div", {}, [
|
|
223
|
+
el("b", { textContent: describe(when.value()) + ", " + who.name + " wakes up and:" }),
|
|
224
|
+
el("p", { textContent: text || "…" }),
|
|
225
|
+
]),
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
name.oninput = say;
|
|
229
|
+
todo.oninput = () => {
|
|
230
|
+
grow(todo);
|
|
231
|
+
say();
|
|
232
|
+
};
|
|
233
|
+
when.onchange(say);
|
|
234
|
+
say();
|
|
235
|
+
|
|
236
|
+
const status = el("div");
|
|
237
|
+
const ok = el("button", { className: "ghbtn primary", textContent: "Save" });
|
|
238
|
+
const cancel = el("button", { className: "ghbtn", textContent: "Cancel" });
|
|
239
|
+
cancel.onclick = close;
|
|
240
|
+
ok.onclick = async () => {
|
|
241
|
+
const next = { id: r?.id, title: name.value.trim(), body: todo.value, schedule: when.value() };
|
|
242
|
+
if (!next.title) return status.replaceChildren(el("p", { className: "err", textContent: "Give it a name." }));
|
|
243
|
+
if (!next.body.trim()) return status.replaceChildren(el("p", { className: "err", textContent: "Say what to do." }));
|
|
244
|
+
ok.disabled = true;
|
|
245
|
+
ok.textContent = "Saving…";
|
|
246
|
+
try {
|
|
247
|
+
const routines = r ? who.routines.map((x) => (x.id === r.id ? next : x)) : [...who.routines, next];
|
|
248
|
+
await save(who, who.daily, routines);
|
|
249
|
+
last = null;
|
|
250
|
+
close();
|
|
251
|
+
render();
|
|
252
|
+
} catch (err) {
|
|
253
|
+
ok.disabled = false;
|
|
254
|
+
ok.textContent = "Save";
|
|
255
|
+
status.replaceChildren(el("p", { className: "err", textContent: String(err.message || err) }));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
out.append(status, el("div", { className: "row connfoot" }, [ok, cancel]));
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function field(label, control) {
|
|
263
|
+
return el("div", { className: "field routfield" }, [el("span", { textContent: label }), control]);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* --------------------------------- the time --------------------------------- */
|
|
267
|
+
|
|
268
|
+
const DAYS = [
|
|
269
|
+
["1", "Mon"],
|
|
270
|
+
["2", "Tue"],
|
|
271
|
+
["3", "Wed"],
|
|
272
|
+
["4", "Thu"],
|
|
273
|
+
["5", "Fri"],
|
|
274
|
+
["6", "Sat"],
|
|
275
|
+
["0", "Sun"],
|
|
276
|
+
];
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* When, as days and a time, or a day of the month, rather than as cron. The value is still a
|
|
280
|
+
* cron, because that is what goes in the workflow. A cron the picker cannot show is kept as
|
|
281
|
+
* typed, in a box of its own.
|
|
282
|
+
*/
|
|
283
|
+
function whenField(cron) {
|
|
284
|
+
const parsed = parseCron(cron);
|
|
285
|
+
const listeners = [];
|
|
286
|
+
const changed = () => {
|
|
287
|
+
for (const f of listeners) f();
|
|
288
|
+
said.textContent = describe(value()) + local(time.value);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const repeat = el("select");
|
|
292
|
+
repeat.append(
|
|
293
|
+
el("option", { value: "week", textContent: "Days of the week" }),
|
|
294
|
+
el("option", { value: "month", textContent: "Day of the month" }),
|
|
295
|
+
el("option", { value: "cron", textContent: "Cron" }),
|
|
296
|
+
);
|
|
297
|
+
repeat.value = parsed.kind;
|
|
298
|
+
|
|
299
|
+
const days = new Set(parsed.days);
|
|
300
|
+
const dayRow = el("div", { className: "routdays" });
|
|
301
|
+
for (const [v, label] of DAYS) {
|
|
302
|
+
const chip = el("button", { className: "routchip" + (days.has(v) ? " on" : ""), textContent: label, type: "button" });
|
|
303
|
+
chip.onclick = () => {
|
|
304
|
+
days.has(v) ? days.delete(v) : days.add(v);
|
|
305
|
+
chip.classList.toggle("on", days.has(v));
|
|
306
|
+
changed();
|
|
307
|
+
};
|
|
308
|
+
dayRow.append(chip);
|
|
309
|
+
}
|
|
310
|
+
const dom = el("input", { type: "number", min: "1", max: "28", value: String(parsed.dom), style: "width:80px" });
|
|
311
|
+
const time = el("input", { type: "time", step: "60", value: parsed.time, style: "width:130px" });
|
|
312
|
+
const raw = el("input", { type: "text", value: cron, spellcheck: false, placeholder: "0 9 * * 1" });
|
|
313
|
+
const said = el("small", { className: "routsaid" });
|
|
314
|
+
|
|
315
|
+
const domRow = el("div", { className: "row" }, [el("span", { className: "meta", textContent: "Day" }), dom]);
|
|
316
|
+
const timeRow = el("div", { className: "row" }, [time, el("span", { className: "meta", textContent: "UTC" })]);
|
|
317
|
+
const show = () => {
|
|
318
|
+
dayRow.hidden = repeat.value !== "week";
|
|
319
|
+
domRow.hidden = repeat.value !== "month";
|
|
320
|
+
timeRow.hidden = repeat.value === "cron";
|
|
321
|
+
raw.hidden = repeat.value !== "cron";
|
|
322
|
+
};
|
|
323
|
+
repeat.onchange = () => {
|
|
324
|
+
show();
|
|
325
|
+
changed();
|
|
326
|
+
};
|
|
327
|
+
for (const input of [dom, time, raw]) input.oninput = changed;
|
|
328
|
+
|
|
329
|
+
function value() {
|
|
330
|
+
if (repeat.value === "cron") return raw.value.trim();
|
|
331
|
+
const [h, m] = (time.value || "09:00").split(":").map(Number);
|
|
332
|
+
if (repeat.value === "month") return `${m} ${h} ${Math.min(28, Math.max(1, Number(dom.value) || 1))} * *`;
|
|
333
|
+
const picked = DAYS.map(([v]) => v).filter((v) => days.has(v));
|
|
334
|
+
return `${m} ${h} * * ${dayList(picked)}`;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
show();
|
|
338
|
+
said.textContent = describe(value()) + local(time.value);
|
|
339
|
+
const node = el("div", { className: "field routfield" }, [
|
|
340
|
+
el("span", { textContent: "When" }),
|
|
341
|
+
el("div", { className: "routwhenpick" }, [repeat, dayRow, domRow, timeRow, raw, said]),
|
|
342
|
+
]);
|
|
343
|
+
return { node, value, onchange: (f) => listeners.push(f) };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Days for cron, in its own short forms where there is one. */
|
|
347
|
+
function dayList(picked) {
|
|
348
|
+
const set = new Set(picked);
|
|
349
|
+
if (set.size === 0 || set.size === 7) return "*";
|
|
350
|
+
if (set.size === 5 && ["1", "2", "3", "4", "5"].every((d) => set.has(d))) return "1-5";
|
|
351
|
+
return [...set].map(Number).sort((a, b) => a - b).join(",");
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function parseCron(cron) {
|
|
355
|
+
const [min, hour, dom, mon, dow] = String(cron).trim().split(/\s+/);
|
|
356
|
+
const plain = /^\d+$/.test(min ?? "") && /^\d+$/.test(hour ?? "") && mon === "*";
|
|
357
|
+
const time = plain ? `${hour.padStart(2, "0")}:${min.padStart(2, "0")}` : "09:00";
|
|
358
|
+
if (plain && dom === "*") {
|
|
359
|
+
const days =
|
|
360
|
+
dow === "*" ? ["0", "1", "2", "3", "4", "5", "6"] : dow === "1-5" ? ["1", "2", "3", "4", "5"] : /^[0-6](,[0-6])*$/.test(dow) ? dow.split(",") : null;
|
|
361
|
+
if (days) return { kind: "week", days, time, dom: 1 };
|
|
362
|
+
}
|
|
363
|
+
if (plain && /^\d+$/.test(dom ?? "") && dow === "*") return { kind: "month", days: ["1"], time, dom: Number(dom) };
|
|
364
|
+
return { kind: "cron", days: ["1"], time, dom: 1 };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const DAY_NAME = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
368
|
+
|
|
369
|
+
/** The same words the server gives a schedule, so the preview and the list agree. */
|
|
370
|
+
export function describe(cron) {
|
|
371
|
+
const p = parseCron(cron);
|
|
372
|
+
const at = "at " + p.time + " UTC";
|
|
373
|
+
if (p.kind === "month") return `On the ${ordinal(p.dom)} of each month ${at}`;
|
|
374
|
+
if (p.kind === "cron") return cron || "No time yet";
|
|
375
|
+
const d = cron.trim().split(/\s+/)[4];
|
|
376
|
+
if (d === "*") return "Every day " + at;
|
|
377
|
+
if (d === "1-5") return "Weekdays " + at;
|
|
378
|
+
if (d === "0,6" || d === "6,0") return "Weekends " + at;
|
|
379
|
+
const names = p.days.map((x) => DAY_NAME[Number(x)] + "s");
|
|
380
|
+
return (names.length > 1 ? names.slice(0, -1).join(", ") + " and " + names.at(-1) : names[0]) + " " + at;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function ordinal(n) {
|
|
384
|
+
const tens = n % 100;
|
|
385
|
+
return n + (tens >= 11 && tens <= 13 ? "th" : (["th", "st", "nd", "rd"][n % 10] ?? "th"));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** What that UTC time is where the person reading it is, when the two differ. */
|
|
389
|
+
function local(hhmm) {
|
|
390
|
+
if (!hhmm) return "";
|
|
391
|
+
const [h, m] = hhmm.split(":").map(Number);
|
|
392
|
+
const at = new Date(Date.UTC(2026, 0, 5, h, m));
|
|
393
|
+
const here = at.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
|
|
394
|
+
return here === hhmm ? "" : " · " + here + " where you are";
|
|
395
|
+
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { runStatus, startRun } from "../api.js";
|
|
8
8
|
import { askYes } from "../dialog.js";
|
|
9
9
|
import { el } from "../dom.js";
|
|
10
|
+
import { whatsLeft } from "../readiness.js";
|
|
11
|
+
import { S } from "../state.js";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* @param {{staff: string, name: string, onDone?: (ok: boolean) => void}} opts
|
|
@@ -86,6 +88,9 @@ export function runOnce(opts) {
|
|
|
86
88
|
for (const f of now.failedAt ?? []) done.append(el("p", { className: "sub", textContent: "Failed at " + f }));
|
|
87
89
|
if (!ok) done.append(el("p", { className: "sub", textContent: "Troubleshooting, in the docs, has what each failure usually means." }));
|
|
88
90
|
out.replaceChildren(done);
|
|
91
|
+
// "Run once" is done now, and every screen that said otherwise should stop saying it.
|
|
92
|
+
const who = (S.data?.staff ?? []).find((x) => x.handle === opts.staff);
|
|
93
|
+
if (ok && who) whatsLeft(who, true).catch(() => {});
|
|
89
94
|
opts.onDone?.(ok);
|
|
90
95
|
};
|
|
91
96
|
tick();
|
|
@@ -7,6 +7,7 @@ import { getRuns } from "../api.js";
|
|
|
7
7
|
import { ago, el, esc, skeleton } from "../dom.js";
|
|
8
8
|
import { render } from "../router.js";
|
|
9
9
|
import { S } from "../state.js";
|
|
10
|
+
import { notReadyNote, whenKnown } from "./notready.js";
|
|
10
11
|
|
|
11
12
|
/** How many runs a staff member's table shows. The spend covers all of the last 30 days. */
|
|
12
13
|
const SHOWN = 15;
|
|
@@ -89,6 +90,9 @@ function paint(m, data) {
|
|
|
89
90
|
}, 3000);
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
if (!(data.staff ?? []).length) {
|
|
94
|
+
m.append(el("p", { className: "hnote", textContent: "Nobody hired yet, so nothing has run. Home says what is left." }));
|
|
95
|
+
}
|
|
92
96
|
for (const s of data.staff ?? []) m.append(...staffSection(s));
|
|
93
97
|
|
|
94
98
|
m.append(
|
|
@@ -111,7 +115,13 @@ function staffSection(s) {
|
|
|
111
115
|
const body = el("div", { className: "hbody runs" });
|
|
112
116
|
for (const e of s.errors ?? []) body.append(el("p", { className: "hnote err", textContent: e }));
|
|
113
117
|
if (!(s.runs ?? []).length) {
|
|
114
|
-
|
|
118
|
+
// "No runs" read as idle, when the truth was that they could not run at all.
|
|
119
|
+
const who = (S.data?.staff ?? []).find((x) => x.handle === s.handle) ?? s;
|
|
120
|
+
body.append(
|
|
121
|
+
whenKnown(who, () =>
|
|
122
|
+
notReadyNote(who) ?? el("p", { className: "hnote", textContent: "No runs in the last 30 days." }),
|
|
123
|
+
),
|
|
124
|
+
);
|
|
115
125
|
return [head, body];
|
|
116
126
|
}
|
|
117
127
|
|
|
@@ -142,7 +152,9 @@ function row(r) {
|
|
|
142
152
|
tr.innerHTML =
|
|
143
153
|
'<td title="' + esc(r.createdAt) + '">' + esc(ago(r.createdAt)) + "</td>" +
|
|
144
154
|
"<td>" + esc(r.kind) + "</td>" +
|
|
145
|
-
|
|
155
|
+
(out.tone === "ok"
|
|
156
|
+
? '<td><span class="runok"><i></i>' + esc(out.word) + "</span></td>"
|
|
157
|
+
: '<td><span class="chip ' + out.tone + '">' + esc(out.word) + "</span></td>") +
|
|
146
158
|
"<td>" + (mins != null ? Math.round(mins) + "m" : "–") + "</td>" +
|
|
147
159
|
"<td>" + (rec.turns ?? "–") + "</td>" +
|
|
148
160
|
"<td>" + (typeof rec.cost_usd === "number" ? "$" + rec.cost_usd.toFixed(2) : "–") + "</td>" +
|
|
@@ -9,10 +9,11 @@ import { post } from "../api.js";
|
|
|
9
9
|
import { askYes, sheet } from "../dialog.js";
|
|
10
10
|
import { pending } from "../inflight.js";
|
|
11
11
|
import { ago, el, esc } from "../dom.js";
|
|
12
|
-
import { sentence, staffProgress, whatsLeft } from "../readiness.js";
|
|
12
|
+
import { sentence, staffProgress, stepCommand, whatsLeft } from "../readiness.js";
|
|
13
13
|
import { refreshAll } from "../refresh.js";
|
|
14
14
|
import { S } from "../state.js";
|
|
15
15
|
import { hireFlow, line, rolePicker } from "./hire.js";
|
|
16
|
+
import { commandLine } from "./notready.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Resolves once nothing is loading and `node` has stopped changing for a moment, or after a few
|
|
@@ -50,7 +51,15 @@ let current = null;
|
|
|
50
51
|
export function viewStaff(m, o = {}) {
|
|
51
52
|
m.append(el("h1", { textContent: "Staff" }));
|
|
52
53
|
const empty = !S.data.staff.length;
|
|
53
|
-
|
|
54
|
+
/* Hosted, the picker led to a hire that only the server on your machine can do, and it
|
|
55
|
+
failed there. The command is the way in. */
|
|
56
|
+
if (empty && S.hosted) {
|
|
57
|
+
m.append(
|
|
58
|
+
el("p", { className: "sub", textContent: "No staff yet. Hiring creates repos and an App, so it is done on your machine:" }),
|
|
59
|
+
commandLine("hire cto --apply"),
|
|
60
|
+
el("p", { className: "sub", textContent: "cmo and support are the other roles, or any handle with --name." }),
|
|
61
|
+
);
|
|
62
|
+
} else if (empty) m.append(el("p", { className: "sub", textContent: "No staff yet. Pick a role to hire your first." }));
|
|
54
63
|
|
|
55
64
|
const pane = el("div", { className: "hirepane" });
|
|
56
65
|
|
|
@@ -83,7 +92,7 @@ export function viewStaff(m, o = {}) {
|
|
|
83
92
|
if (current) current.close();
|
|
84
93
|
else pane.replaceChildren();
|
|
85
94
|
S.staffOpen = null;
|
|
86
|
-
if (empty) pick();
|
|
95
|
+
if (empty && !S.hosted) pick();
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
// With nobody hired the roles are the page. After that they are a dialog behind Hire someone.
|
|
@@ -196,6 +205,12 @@ export function viewStaff(m, o = {}) {
|
|
|
196
205
|
warn.textContent =
|
|
197
206
|
"Not ready to run. " + (p ? `${p.done} of ${p.total} done. ` : "") +
|
|
198
207
|
"Still to do: " + sentence(left) + ".";
|
|
208
|
+
// Hosted has no Finish setting up, so each step comes with what to run instead.
|
|
209
|
+
if (S.hosted) {
|
|
210
|
+
const cmds = [...new Set(left.map((x) => stepCommand(x, s.handle)).filter(Boolean))];
|
|
211
|
+
warn.classList.add("notready");
|
|
212
|
+
warn.replaceChildren(el("span", { textContent: warn.textContent }), ...cmds.map(commandLine));
|
|
213
|
+
}
|
|
199
214
|
});
|
|
200
215
|
d.append(warn);
|
|
201
216
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
2
|
+
<html lang="en" data-astryx-theme="neutral">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>roster</title>
|
|
7
|
-
<!-- Inline, so a local page with no network still has a tab icon and the console stays clean.
|
|
8
|
-
|
|
7
|
+
<!-- Inline, so a local page with no network still has a tab icon and the console stays clean.
|
|
8
|
+
The mark in the theme's accent, light or dark as the system is, like the one in the sidebar. -->
|
|
9
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%3E%3Cstyle%3Erect%7Bfill:%231b1b1b%7Dpath%7Bstroke:%23fff%7D%40media%20%28prefers-color-scheme:dark%29%7Brect%7Bfill:%23f1f1f1%7Dpath%7Bstroke:%23111%7D%7D%3C/style%3E%3Crect%20width='32'%20height='32'%20rx='8'/%3E%3Cpath%20d='M11%2023V10h6a4%204%200%200%201%200%208h-6m6%200%204.5%205'%20fill='none'%20stroke-width='2.6'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3C/svg%3E">
|
|
9
10
|
<!-- Stylesheets and modules are served from /assets by `roster portal`. No build step:
|
|
10
11
|
editing one of these files and reloading is the whole edit loop. -->
|
|
12
|
+
<!-- Astryx's neutral theme and its components, under the portal's own class names. First, so
|
|
13
|
+
it is the floor every stylesheet below builds on. Generated by scripts/astryx.mjs. -->
|
|
14
|
+
<link rel="stylesheet" href="/assets/css/astryx.css">
|
|
15
|
+
<!-- Figtree is the theme's face. Offline, the system font it names next stands in. -->
|
|
16
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
17
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
18
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap">
|
|
11
19
|
<link rel="stylesheet" href="/assets/css/base.css">
|
|
12
20
|
<link rel="stylesheet" href="/assets/css/layout.css">
|
|
13
21
|
<link rel="stylesheet" href="/assets/css/markdown.css">
|
|
@@ -20,6 +28,8 @@
|
|
|
20
28
|
<link rel="stylesheet" href="/assets/css/health.css">
|
|
21
29
|
<link rel="stylesheet" href="/assets/css/runs.css">
|
|
22
30
|
<link rel="stylesheet" href="/assets/css/setup.css">
|
|
31
|
+
<link rel="stylesheet" href="/assets/css/connectors.css">
|
|
32
|
+
<link rel="stylesheet" href="/assets/css/routines.css">
|
|
23
33
|
</head>
|
|
24
34
|
<body>
|
|
25
35
|
<div class="app">
|
|
@@ -56,6 +66,12 @@
|
|
|
56
66
|
<button class="nav" id="staffnav" data-view="staff">
|
|
57
67
|
<span class="ic" data-icon="person"></span> Staff
|
|
58
68
|
</button>
|
|
69
|
+
<button class="nav" id="routinesnav" data-view="routines" title="When the staff wake up, and what they do then">
|
|
70
|
+
<span class="ic" data-icon="clock"></span> Routines
|
|
71
|
+
</button>
|
|
72
|
+
<button class="nav" id="connectorsnav" data-view="connectors" title="Outside services the staff can use">
|
|
73
|
+
<span class="ic" data-icon="plug"></span> Connectors
|
|
74
|
+
</button>
|
|
59
75
|
<button class="nav" id="docsnav" data-view="docs">
|
|
60
76
|
<span class="ic" data-icon="docs"></span> Docs
|
|
61
77
|
</button>
|