@joe-broadhead/opencode-mem 0.8.4 → 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/CHANGELOG.md +455 -0
- package/README.md +114 -61
- package/docs/agent-protocol.md +67 -177
- package/package.json +1351 -98
- package/skills/mem.pages/SKILL.md +143 -0
- package/skills/mem.sharing/SKILL.md +82 -0
- package/skills/mem.sources/SKILL.md +93 -0
- package/skills/mem.usage/SKILL.md +118 -492
- package/src/backend/records.js +285 -0
- package/src/bootstrap.js +49 -45
- package/src/call-shapes.js +41 -10
- package/src/collector-lock.js +162 -0
- package/src/collector-service.js +441 -0
- package/src/collector.js +381 -0
- package/src/commands.js +3 -3
- package/src/config.js +12 -1
- package/src/curation.js +1 -1
- package/src/permissions.js +18 -2
- package/src/protocol.js +55 -24
- package/src/recall.js +104 -27
- package/src/records-store.js +280 -120
- package/src/records.js +63 -11
- package/src/runtime.js +23 -14
- package/src/skills.js +44 -18
- package/src/sources.js +58 -0
- package/src/spaces.js +93 -10
- package/src/tools/aliases.js +163 -0
- package/src/tools/commitments.js +12 -9
- package/src/tools/index.js +88 -19
- package/src/tools/ingest.js +277 -0
- package/src/tools/knowledge.js +6 -1
- package/src/tools/memory.js +640 -210
- package/src/tools/page.js +411 -0
- package/src/tools/recall.js +363 -112
- package/src/tools/records-kit.js +142 -0
- package/src/tools/share.js +1012 -0
- package/src/tools/shared.js +8 -1
- package/src/tools/spaces.js +431 -143
- package/src/tools/status.js +87 -58
- package/src/tools/wiki.js +2 -2
- package/src/views/contracts.js +273 -3
- package/src/views/records-reads.js +675 -0
- package/src/views/rpc.js +17 -100
- package/src/views/shape.js +61 -0
- package/views/commitments.html +4 -0
- package/views/graph.html +753 -0
- package/views/home.html +11 -5
- package/views/journal.html +621 -0
- package/views/memory.html +7 -1
- package/views/pages.html +636 -0
- package/views/review.html +406 -0
- package/views/today.html +309 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-Mu0RHsnl4soOriDcqIPW3UAB9TS1K9/BqMAd7wl4T7U='; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
|
6
|
+
<title>Review</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color: var(--jelly-text, CanvasText);
|
|
10
|
+
background: var(--jelly-surface, Canvas);
|
|
11
|
+
font: 14px/1.45 var(--jelly-font, system-ui, sans-serif);
|
|
12
|
+
}
|
|
13
|
+
* { box-sizing: border-box; }
|
|
14
|
+
body { margin: 0; padding: 2px; }
|
|
15
|
+
p { margin: 0; }
|
|
16
|
+
h1 { font-size: 16px; margin: 0 0 4px; overflow-wrap: anywhere; }
|
|
17
|
+
.muted { color: var(--jelly-muted, GrayText); font-size: 12px; }
|
|
18
|
+
.state { font-weight: 600; display: flex; align-items: center; gap: 6px; }
|
|
19
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jelly-accent, Highlight); flex: none; }
|
|
20
|
+
.dot.off { background: transparent; border: 1.5px solid var(--jelly-muted, GrayText); }
|
|
21
|
+
.dot.danger { background: var(--jelly-danger, CanvasText); }
|
|
22
|
+
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
|
|
23
|
+
.bar.flat { margin: 0; }
|
|
24
|
+
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
25
|
+
.button, .chip, select, textarea, input {
|
|
26
|
+
font: inherit; font-size: 12px; color: var(--jelly-text, CanvasText); background: var(--jelly-raised, Canvas);
|
|
27
|
+
border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px);
|
|
28
|
+
}
|
|
29
|
+
.button { padding: 2px 8px; cursor: pointer; white-space: nowrap; }
|
|
30
|
+
.button[aria-pressed="true"] { color: var(--jelly-on-accent, HighlightText); background: var(--jelly-accent, Highlight); border-color: var(--jelly-accent, Highlight); }
|
|
31
|
+
.button.quiet { border-color: transparent; background: transparent; padding-left: 0; }
|
|
32
|
+
select { padding: 2px 4px; }
|
|
33
|
+
textarea { width: 100%; padding: 4px 6px; resize: vertical; }
|
|
34
|
+
.button:focus-visible, .chip:focus-visible, .row:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
|
|
35
|
+
outline: 2px solid var(--jelly-accent, Highlight); outline-offset: 2px;
|
|
36
|
+
}
|
|
37
|
+
.chip {
|
|
38
|
+
display: inline-block; max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
39
|
+
vertical-align: bottom; padding: 0 7px; margin: 0 2px; border-radius: 999px; cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
.chip.event, .chip.turn { border-style: dashed; }
|
|
42
|
+
.badge { display: inline-block; font-size: 11px; font-weight: 600; border: 1px solid var(--jelly-border, GrayText); border-radius: 999px; padding: 0 6px; margin-left: 4px; }
|
|
43
|
+
.badge.warn { border-color: var(--jelly-danger, CanvasText); color: var(--jelly-danger, CanvasText); }
|
|
44
|
+
ul.rows { list-style: none; margin: 0; padding: 0; }
|
|
45
|
+
ul.rows > li { border-top: 1px solid var(--jelly-border, GrayText); }
|
|
46
|
+
ul.rows > li:first-child { border-top: 0; }
|
|
47
|
+
.row {
|
|
48
|
+
display: block; width: 100%; text-align: left; font: inherit; color: var(--jelly-text, CanvasText); background: transparent;
|
|
49
|
+
border: 0; padding: 6px 2px; cursor: pointer; overflow-wrap: anywhere;
|
|
50
|
+
}
|
|
51
|
+
.row > span { display: block; }
|
|
52
|
+
.row .title { font-weight: 600; }
|
|
53
|
+
.md { overflow-wrap: anywhere; }
|
|
54
|
+
.md h2 { font-size: 15px; margin: 12px 0 4px; }
|
|
55
|
+
.md h3 { font-size: 14px; margin: 10px 0 4px; }
|
|
56
|
+
.md h4, .md h5 { font-size: 13px; margin: 8px 0 2px; }
|
|
57
|
+
.md p, .md ul, .md ol, .md pre, .md blockquote { margin: 4px 0; }
|
|
58
|
+
.md ul, .md ol { padding-left: 20px; }
|
|
59
|
+
.md li.nested { margin-left: 16px; }
|
|
60
|
+
.md hr { border: 0; border-top: 1px solid var(--jelly-border, GrayText); margin: 10px 0; }
|
|
61
|
+
.md blockquote, blockquote.quote { margin: 4px 0; padding-left: 8px; border-left: 3px solid var(--jelly-border, GrayText); }
|
|
62
|
+
.md pre { overflow: auto; padding: 6px 8px; background: var(--jelly-raised, Canvas); border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px); }
|
|
63
|
+
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
64
|
+
.link { text-decoration: underline; }
|
|
65
|
+
.address { color: var(--jelly-muted, GrayText); overflow-wrap: anywhere; }
|
|
66
|
+
.panel { margin: 8px 0; padding: 8px; border: 1px solid var(--jelly-border, GrayText); border-radius: var(--jelly-radius, 8px); background: var(--jelly-raised, Canvas); }
|
|
67
|
+
.panel:empty { display: none; }
|
|
68
|
+
.panel h2 { font-size: 14px; margin: 0 0 4px; }
|
|
69
|
+
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 6px 0; font-size: 12px; }
|
|
70
|
+
dl.fields dt { color: var(--jelly-muted, GrayText); }
|
|
71
|
+
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
|
|
72
|
+
footer, .section { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--jelly-border, GrayText); }
|
|
73
|
+
details > summary { cursor: pointer; font-size: 12px; }
|
|
74
|
+
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
75
|
+
.proposal { padding: 8px 0; }
|
|
76
|
+
.proposal > * + * { margin-top: 4px; }
|
|
77
|
+
.title { font-weight: 600; }
|
|
78
|
+
</style>
|
|
79
|
+
</head>
|
|
80
|
+
<body>
|
|
81
|
+
<main id="root" aria-live="polite"><p class="muted">Loading…</p></main>
|
|
82
|
+
<script>
|
|
83
|
+
// jelly-view.js: a client of Jelly's view bridge. Paste it into the page's own <script>:
|
|
84
|
+
// a sealed page loads no script by URL and is given no global. Call jellyView() as the
|
|
85
|
+
// script starts; it resolves with the client when the app says hello.
|
|
86
|
+
function jellyView() {
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
addEventListener("message", function hello(event) {
|
|
89
|
+
const said = event.data;
|
|
90
|
+
if (event.source !== parent || said?.v !== 1 || said.kind !== "hello" || !event.ports[0])
|
|
91
|
+
return;
|
|
92
|
+
removeEventListener("message", hello);
|
|
93
|
+
const port = event.ports[0];
|
|
94
|
+
const listeners = new Set();
|
|
95
|
+
const latest = new Map();
|
|
96
|
+
const queue = [];
|
|
97
|
+
let sequence = 0;
|
|
98
|
+
let current;
|
|
99
|
+
const theme = (tokens) => {
|
|
100
|
+
const style = document.documentElement.style;
|
|
101
|
+
for (const [name, value] of Object.entries(tokens))
|
|
102
|
+
if (name === "scheme") style.colorScheme = value;
|
|
103
|
+
else style.setProperty(`--jelly-${name}`, value);
|
|
104
|
+
};
|
|
105
|
+
// The app answers one request at a time, so requests go in turn.
|
|
106
|
+
const next = () => {
|
|
107
|
+
if (current !== undefined || queue.length === 0) return;
|
|
108
|
+
current = queue.shift();
|
|
109
|
+
current.timer = setTimeout(
|
|
110
|
+
() => settle({ ok: false, error: "No answer from the app" }),
|
|
111
|
+
15000,
|
|
112
|
+
);
|
|
113
|
+
port.postMessage(current.message);
|
|
114
|
+
};
|
|
115
|
+
const settle = (answer) => {
|
|
116
|
+
const done = current;
|
|
117
|
+
current = undefined;
|
|
118
|
+
clearTimeout(done.timer);
|
|
119
|
+
if (answer.ok) done.resolve(answer.value);
|
|
120
|
+
else done.reject(new Error(answer.error));
|
|
121
|
+
next();
|
|
122
|
+
};
|
|
123
|
+
port.onmessage = ({ data }) => {
|
|
124
|
+
if (data?.v !== 1) return;
|
|
125
|
+
if (typeof data.kind !== "string") {
|
|
126
|
+
if (current !== undefined && data.re === current.message.id) settle(data);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// A call waiting for the person is answered by `until`, not in 15 s.
|
|
130
|
+
if (data.kind === "rpc.waiting" && data.re === current?.message.id) {
|
|
131
|
+
clearTimeout(current.timer);
|
|
132
|
+
current.timer = setTimeout(
|
|
133
|
+
() => settle({ ok: false, error: "No answer from the app" }),
|
|
134
|
+
Math.max(0, Date.parse(data.until) - Date.now()) + 15000,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
if (data.kind === "theme.changed") theme(data.theme);
|
|
138
|
+
// A wait is news only while it lasts, so a later listener is not told of it.
|
|
139
|
+
if (data.kind !== "rpc.waiting") latest.set(data.kind, data);
|
|
140
|
+
for (const listener of listeners) listener(data);
|
|
141
|
+
};
|
|
142
|
+
port.start();
|
|
143
|
+
theme(said.theme);
|
|
144
|
+
const request = (op, fields = {}) =>
|
|
145
|
+
new Promise((resolve, reject) => {
|
|
146
|
+
queue.push({ resolve, reject, message: { ...fields, v: 1, id: String(++sequence), op } });
|
|
147
|
+
next();
|
|
148
|
+
});
|
|
149
|
+
resolve({
|
|
150
|
+
hello: said,
|
|
151
|
+
// A listener first hears the latest push of each kind that came before it.
|
|
152
|
+
on(listener) {
|
|
153
|
+
for (const push of latest.values()) listener(push);
|
|
154
|
+
listeners.add(listener);
|
|
155
|
+
return () => listeners.delete(listener);
|
|
156
|
+
},
|
|
157
|
+
request,
|
|
158
|
+
data: () => request("data.get"),
|
|
159
|
+
state: () => request("state.get"),
|
|
160
|
+
setState: (revision, data) => request("state.set", { revision, data }),
|
|
161
|
+
call: (method, input = {}) => request("rpc.call", { method, input }),
|
|
162
|
+
openAgent: (prefill) => request("open-agent", prefill === undefined ? {} : { prefill }),
|
|
163
|
+
resize: (height) =>
|
|
164
|
+
request("resize", { height: Math.min(1200, Math.max(1, Math.ceil(height))) }),
|
|
165
|
+
decline: () => request("decline"),
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
</script>
|
|
171
|
+
<script>
|
|
172
|
+
const root = document.getElementById("root");
|
|
173
|
+
let view = null;
|
|
174
|
+
// The space a read goes to: a shared space's id, or undefined for the person's own.
|
|
175
|
+
let space;
|
|
176
|
+
let spaceKind = "personal";
|
|
177
|
+
|
|
178
|
+
function el(tag, className, text) {
|
|
179
|
+
const node = document.createElement(tag);
|
|
180
|
+
if (className) node.className = className;
|
|
181
|
+
if (text !== undefined) node.textContent = text;
|
|
182
|
+
return node;
|
|
183
|
+
}
|
|
184
|
+
function button(label, onClick, className = "button") {
|
|
185
|
+
const node = el("button", className, label);
|
|
186
|
+
node.type = "button";
|
|
187
|
+
node.addEventListener("click", onClick);
|
|
188
|
+
return node;
|
|
189
|
+
}
|
|
190
|
+
function state(words, dot) {
|
|
191
|
+
const line = el("p", "state");
|
|
192
|
+
const mark = el("span", `dot ${dot}`);
|
|
193
|
+
mark.setAttribute("aria-hidden", "true");
|
|
194
|
+
line.append(mark, words);
|
|
195
|
+
return line;
|
|
196
|
+
}
|
|
197
|
+
function fit() {
|
|
198
|
+
// The body's own height: the document is at least as tall as the frame, so it never shrinks.
|
|
199
|
+
if (view) view.resize(document.body.getBoundingClientRect().height).catch(() => undefined);
|
|
200
|
+
}
|
|
201
|
+
function show(...nodes) {
|
|
202
|
+
root.replaceChildren(...nodes);
|
|
203
|
+
root.removeAttribute("aria-busy");
|
|
204
|
+
fit();
|
|
205
|
+
}
|
|
206
|
+
function busy() {
|
|
207
|
+
root.setAttribute("aria-busy", "true");
|
|
208
|
+
}
|
|
209
|
+
// A read's input: the page's own fields and the chosen space.
|
|
210
|
+
function input(fields = {}) {
|
|
211
|
+
return space ? { ...fields, space } : fields;
|
|
212
|
+
}
|
|
213
|
+
// What every view says when the server has no records service (src/views/contracts.js).
|
|
214
|
+
const RECORDS_OFF = "This Memory server has no records service yet, so memories, journals, pages and review can't be shown. Ask whoever runs it to turn it on.";
|
|
215
|
+
function failed(what, error, retry) {
|
|
216
|
+
if (error.message === RECORDS_OFF) return show(el("p", "muted", RECORDS_OFF));
|
|
217
|
+
return show(state(what, "danger"), el("p", "muted", error.message), button("Try again", retry));
|
|
218
|
+
}
|
|
219
|
+
function number(value) {
|
|
220
|
+
return Number(value || 0).toLocaleString("en-GB");
|
|
221
|
+
}
|
|
222
|
+
// "Sun 8 Nov" for a day, from YYYY-MM-DD or an ISO time.
|
|
223
|
+
function dayWords(value) {
|
|
224
|
+
const date = new Date(/^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T00:00:00Z` : value);
|
|
225
|
+
if (Number.isNaN(date.getTime())) return value || "";
|
|
226
|
+
return date.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short", timeZone: "UTC" });
|
|
227
|
+
}
|
|
228
|
+
function waiting(push, what) {
|
|
229
|
+
if (push.kind === "rpc.waiting") show(state("Waiting for you", "off"), el("p", "muted", `Allow this in Jelly to see ${what}.`));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// The space picker, when the person has more than one space; null otherwise.
|
|
233
|
+
let spaceList = null;
|
|
234
|
+
async function spacePicker(redraw) {
|
|
235
|
+
if (spaceList === null) {
|
|
236
|
+
try {
|
|
237
|
+
spaceList = (await view.call("spaces.list")).spaces;
|
|
238
|
+
} catch {
|
|
239
|
+
spaceList = [];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (spaceList.length < 2) return null;
|
|
243
|
+
const label = el("label", "muted", "Space ");
|
|
244
|
+
const select = el("select");
|
|
245
|
+
for (const entry of spaceList) {
|
|
246
|
+
const option = el("option", "", entry.kind === "personal" ? `${entry.name} (yours)` : entry.name);
|
|
247
|
+
option.value = entry.kind === "personal" ? "" : entry.id;
|
|
248
|
+
if ((space ?? "") === option.value) option.selected = true;
|
|
249
|
+
select.append(option);
|
|
250
|
+
}
|
|
251
|
+
select.addEventListener("change", () => {
|
|
252
|
+
space = select.value || undefined;
|
|
253
|
+
spaceKind = space ? spaceList.find((entry) => entry.id === space)?.kind ?? "shared" : "personal";
|
|
254
|
+
redraw();
|
|
255
|
+
});
|
|
256
|
+
label.append(select);
|
|
257
|
+
return label;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Memory's Review: what the evening routine suggests but waits for you to say yes to, with
|
|
261
|
+
// why it waits and the words it rests on. Deciding starts a message for you to send, as Mark
|
|
262
|
+
// done and Forget do: your agent then decides it with mem_spaces (review), under your rules,
|
|
263
|
+
// and in a shared space Jelly asks you first (memory.revise). The message names the proposal
|
|
264
|
+
// by its id and carries only what you typed: never a proposal's own words.
|
|
265
|
+
const PROPOSAL_ID = /^rec_[0-9A-Za-z]{1,64}$/;
|
|
266
|
+
const MESSAGE_MAX = 2000;
|
|
267
|
+
const ACTIONS = {
|
|
268
|
+
create: "New memory or page",
|
|
269
|
+
append: "Add to a page",
|
|
270
|
+
supersede: "Replace a record",
|
|
271
|
+
merge: "Merge two people",
|
|
272
|
+
close_commitment: "Close a commitment",
|
|
273
|
+
open_commitment: "New commitment",
|
|
274
|
+
share: "Share",
|
|
275
|
+
};
|
|
276
|
+
const SAID_BY = {
|
|
277
|
+
person: "You said this",
|
|
278
|
+
agent: "Your agent said this",
|
|
279
|
+
inferred: "Memory inferred this",
|
|
280
|
+
external: "Someone else said this",
|
|
281
|
+
unknown: "Source unknown",
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// The message that decides one proposal: its id, the decision, where, and your own words.
|
|
285
|
+
function decisionMessage(decision, id, typed, where) {
|
|
286
|
+
if (!PROPOSAL_ID.test(id)) return null;
|
|
287
|
+
const place = where.kind === "personal" ? "my personal memory" : `the shared space ${where.name} (space ${where.id})`;
|
|
288
|
+
const words = String(typed || "").trim().slice(0, 1500);
|
|
289
|
+
const head = `Memory review: ${decision} proposal ${id} in ${place}`;
|
|
290
|
+
if (decision === "reject") return `${head}.${words ? ` My reason: ${words}` : ""}`.slice(0, MESSAGE_MAX);
|
|
291
|
+
if (decision === "edit") return `${head}, applying this text instead:\n${words}`.slice(0, MESSAGE_MAX);
|
|
292
|
+
return `${head}.`;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function evidenceOf(item) {
|
|
296
|
+
if (item.evidence.length === 0) return null;
|
|
297
|
+
const box = el("div");
|
|
298
|
+
for (const quote of item.evidence) {
|
|
299
|
+
const said = el("blockquote", "quote", `“${quote.quote}”`);
|
|
300
|
+
const from = quote.kind === "turn" ? "your conversation" : quote.kind === "record" ? "a record" : "a message";
|
|
301
|
+
said.append(el("span", "muted", ` (from ${from}, ${quote.ref})`));
|
|
302
|
+
box.append(said);
|
|
303
|
+
}
|
|
304
|
+
return box;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function proposalRow(item, where, status) {
|
|
308
|
+
const row = el("li", "proposal");
|
|
309
|
+
const head = el("p", "title");
|
|
310
|
+
head.append(el("span", "badge", ACTIONS[item.action] || item.action || "Proposal"));
|
|
311
|
+
if (item.external) head.append(el("span", "badge warn", "From someone else"));
|
|
312
|
+
const text = el("p", "grow", item.proposed || item.title);
|
|
313
|
+
const meta = [SAID_BY[item.stated_by] || SAID_BY.unknown];
|
|
314
|
+
if (item.target) meta.push(`changes ${item.target}`);
|
|
315
|
+
if (item.expires) meta.push(`waits until ${dayWords(item.expires)}`);
|
|
316
|
+
const details = [head, text, el("p", "muted", meta.join(" · "))];
|
|
317
|
+
if (item.reason) details.push(el("p", "muted", `Why it waits: ${item.reason}`));
|
|
318
|
+
const evidence = evidenceOf(item);
|
|
319
|
+
if (evidence) details.push(evidence);
|
|
320
|
+
|
|
321
|
+
const form = el("div");
|
|
322
|
+
const decide = async (decision, typed) => {
|
|
323
|
+
const message = decisionMessage(decision, item.id, typed, where);
|
|
324
|
+
if (!message) {
|
|
325
|
+
status.textContent = "This proposal has no id Memory can decide.";
|
|
326
|
+
return fit();
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
await view.openAgent(message);
|
|
330
|
+
status.textContent = where.kind === "personal"
|
|
331
|
+
? "Your message is ready. Send it, and your agent records the decision."
|
|
332
|
+
: "Your message is ready. Send it, and Jelly asks you before your agent changes the shared space.";
|
|
333
|
+
} catch (error) {
|
|
334
|
+
status.textContent = `Couldn't start the message: ${error.message}`;
|
|
335
|
+
}
|
|
336
|
+
form.replaceChildren();
|
|
337
|
+
fit();
|
|
338
|
+
};
|
|
339
|
+
const ask = (decision, label, hint, start) => {
|
|
340
|
+
const id = `${decision}-${item.id}`;
|
|
341
|
+
const field = el("label", "muted", label);
|
|
342
|
+
field.htmlFor = id;
|
|
343
|
+
const box = el("textarea");
|
|
344
|
+
box.id = id;
|
|
345
|
+
box.rows = 3;
|
|
346
|
+
box.value = start;
|
|
347
|
+
const note = el("p", "muted", hint);
|
|
348
|
+
note.id = `${id}-hint`;
|
|
349
|
+
box.setAttribute("aria-describedby", note.id);
|
|
350
|
+
const go = button("Start the message", () => decide(decision, box.value));
|
|
351
|
+
form.replaceChildren(field, box, note, el("div", "bar"));
|
|
352
|
+
form.lastChild.append(go, button("Cancel", () => {
|
|
353
|
+
form.replaceChildren();
|
|
354
|
+
fit();
|
|
355
|
+
}));
|
|
356
|
+
box.focus();
|
|
357
|
+
fit();
|
|
358
|
+
};
|
|
359
|
+
const actions = el("div", "bar");
|
|
360
|
+
const short = (item.proposed || item.title).slice(0, 60);
|
|
361
|
+
const accept = button("Accept…", () => decide("accept", ""));
|
|
362
|
+
accept.setAttribute("aria-label", `Accept: ${short}`);
|
|
363
|
+
const edit = button("Edit…", () => ask("edit", "Text to apply", "Your agent applies this instead of the suggestion.", item.proposed || item.title));
|
|
364
|
+
edit.setAttribute("aria-label", `Edit: ${short}`);
|
|
365
|
+
const reject = button("Reject…", () => ask("reject", "Why not? (optional)", "Memory keeps your reason as a preference, so the next run doesn't suggest it again.", ""));
|
|
366
|
+
reject.setAttribute("aria-label", `Reject: ${short}`);
|
|
367
|
+
actions.append(accept, edit, reject);
|
|
368
|
+
row.append(...details, actions, form);
|
|
369
|
+
return row;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async function draw() {
|
|
373
|
+
busy();
|
|
374
|
+
let answer;
|
|
375
|
+
try {
|
|
376
|
+
answer = await view.call("review.list", input());
|
|
377
|
+
} catch (error) {
|
|
378
|
+
return failed("Couldn't read what waits for review", error, draw);
|
|
379
|
+
}
|
|
380
|
+
const bar = el("div", "bar");
|
|
381
|
+
const picker = await spacePicker(draw);
|
|
382
|
+
if (picker) bar.append(picker);
|
|
383
|
+
const where = { ...answer.space, kind: answer.space.kind === "shared" ? "shared" : "personal" };
|
|
384
|
+
if (answer.items.length === 0) {
|
|
385
|
+
return show(bar, state("Nothing waits for review", "off"), el("p", "muted", "When the evening routine isn't sure about something, it waits here for you."));
|
|
386
|
+
}
|
|
387
|
+
const status = el("p", "muted");
|
|
388
|
+
status.setAttribute("role", "status");
|
|
389
|
+
const list = el("ul", "rows");
|
|
390
|
+
list.setAttribute("aria-label", "Waiting for review");
|
|
391
|
+
list.append(...answer.items.map((item) => proposalRow(item, where, status)));
|
|
392
|
+
const head = state(`${answer.items.length}${answer.more ? "+" : ""} waiting for review${where.kind === "shared" ? ` in ${where.name}` : ""}`, "");
|
|
393
|
+
const nodes = [bar, head, status, list];
|
|
394
|
+
if (where.kind === "shared") nodes.splice(2, 0, el("p", "muted", "A decision here changes what everyone in the space reads, so Jelly asks you first."));
|
|
395
|
+
if (answer.more) nodes.push(el("p", "muted", "More wait than are shown: decide these first, or ask your agent for the rest."));
|
|
396
|
+
show(...nodes);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
jellyView().then((client) => {
|
|
400
|
+
view = client;
|
|
401
|
+
view.on((push) => waiting(push, "what waits for review"));
|
|
402
|
+
draw();
|
|
403
|
+
});
|
|
404
|
+
</script>
|
|
405
|
+
</body>
|
|
406
|
+
</html>
|