@joe-broadhead/opencode-mem 0.9.1 → 0.9.5
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 +337 -0
- package/README.md +33 -9
- package/docs/agent-protocol.md +1 -1
- package/package.json +254 -5
- package/skills/mem.usage/SKILL.md +10 -0
- package/src/backend/records.js +427 -31
- package/src/call-shapes.js +1 -1
- package/src/capture.js +6 -5
- package/src/config.js +14 -1
- package/src/connect.js +353 -0
- package/src/copies.js +28 -3
- package/src/credentials.js +35 -7
- package/src/curation.js +27 -4
- package/src/forgotten.js +204 -0
- package/src/index.js +20 -3
- package/src/runtime.js +5 -1
- package/src/tools/commitments.js +1 -2
- package/src/tools/held-write.js +9 -1
- package/src/tools/index.js +4 -1
- package/src/tools/ingest.js +1 -1
- package/src/tools/memory.js +106 -8
- package/src/tools/recall.js +44 -12
- package/src/tools/records-kit.js +1 -1
- package/src/tools/share.js +14 -9
- package/src/tools/spaces.js +25 -7
- package/src/tools/wiki.js +1 -1
- package/src/util.js +39 -0
- package/src/views/contracts.js +137 -6
- package/src/views/overdue.js +125 -0
- package/src/views/profile.js +155 -0
- package/src/views/records-reads.js +126 -32
- package/src/views/rpc.js +63 -12
- package/src/views/shape.js +49 -0
- package/views/commitments.html +31 -4
- package/views/home.html +22 -3
- package/views/memory.html +126 -24
package/src/views/shape.js
CHANGED
|
@@ -59,3 +59,52 @@ export function spaceOf(context) {
|
|
|
59
59
|
|
|
60
60
|
/** UTF-8 bytes of a value as JSON. */
|
|
61
61
|
export const jsonBytes = (value) => Buffer.byteLength(JSON.stringify(value))
|
|
62
|
+
|
|
63
|
+
/** Each answer is held under this many bytes of JSON, below Jelly's 64 KB cap. */
|
|
64
|
+
export const ANSWER_BYTES = 56_000
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Keep adding `items` to `answer[key]` while the whole answer stays under the
|
|
68
|
+
* byte cap; whether any were left out.
|
|
69
|
+
*/
|
|
70
|
+
export function fitList(answer, key, items) {
|
|
71
|
+
let fitted = false
|
|
72
|
+
for (const item of items) {
|
|
73
|
+
answer[key].push(item)
|
|
74
|
+
if (jsonBytes(answer) > ANSWER_BYTES) {
|
|
75
|
+
answer[key].pop()
|
|
76
|
+
fitted = true
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return fitted
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Run `work` over `list` with at most `limit` at a time, keeping the order of
|
|
85
|
+
* the answers. `work` is expected to settle its own failures.
|
|
86
|
+
*/
|
|
87
|
+
export async function mapLimit(list, limit, work) {
|
|
88
|
+
const out = new Array(list.length)
|
|
89
|
+
let next = 0
|
|
90
|
+
const worker = async () => {
|
|
91
|
+
for (;;) {
|
|
92
|
+
const at = next++
|
|
93
|
+
if (at >= list.length) return
|
|
94
|
+
out[at] = await work(list[at], at)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
await Promise.all(Array.from({ length: Math.min(limit, list.length) }, worker))
|
|
98
|
+
return out
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A where-it-came-from line for a record's `source` ({ event, turn, session, routine, record, url }), or "". */
|
|
102
|
+
export function sourceLabel(source) {
|
|
103
|
+
if (!source || typeof source !== "object") return ""
|
|
104
|
+
for (const key of ["event", "turn", "session", "routine", "record"]) {
|
|
105
|
+
const ref = typeof source[key] === "string" ? source[key].trim() : ""
|
|
106
|
+
if (ref && /^[\w.:@/-]{1,120}$/.test(ref)) return `${key} ${ref}`
|
|
107
|
+
}
|
|
108
|
+
const url = typeof source.url === "string" ? source.url.trim() : ""
|
|
109
|
+
return /^https?:\/\/[^\s<>"']{1,190}$/.test(url) ? `url ${url}` : ""
|
|
110
|
+
}
|
package/views/commitments.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en-GB">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-EAE0IDrikWE0chPIVODVlKBvBg1sDxCO9UEtFartZJY=' 'sha256-1S0YL3xJhJNv3HZDaqKXlt343g7Vx93lOVeHtK/Fts8='; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
|
6
6
|
<title>Commitments</title>
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
@@ -124,6 +124,33 @@ function jellyView() {
|
|
|
124
124
|
}
|
|
125
125
|
</script>
|
|
126
126
|
<script>
|
|
127
|
+
// done-message.js: the message "Mark done" drafts, for Memory's Commitments views. Paste it into
|
|
128
|
+
// the page's own <script>, as jelly-view.js is. The person reads and sends this text, so it holds
|
|
129
|
+
// no record id: "Mark 'Send the Q4 numbers' as done." The agent finds the commitment by its
|
|
130
|
+
// words (mem_commitments list). Only when another open commitment reads the same (spacing and
|
|
131
|
+
// case aside) does it add what tells them apart, in this order: the due date, the owner, the
|
|
132
|
+
// trigger. Only when two still match exactly does it fall back to the id.
|
|
133
|
+
function doneMessage(item, others) {
|
|
134
|
+
const words = (value) => String(value ?? "").replace(/\s+/g, " ").trim();
|
|
135
|
+
const fold = (value) => words(value).toLowerCase();
|
|
136
|
+
const said = words(item.what);
|
|
137
|
+
const same = (others || []).filter((other) => other !== item && other.id !== item.id && other.state === "open" && fold(other.what) === fold(item.what));
|
|
138
|
+
const draft = (detail) => `Mark '${said}'${detail ? ` (${detail})` : ""} as done.`;
|
|
139
|
+
if (same.length === 0) return draft("");
|
|
140
|
+
const owner = (value) => (value === "user" ? "yours" : value === "agent" ? "your agent's" : `waiting on ${words(value)}`);
|
|
141
|
+
const kinds = [
|
|
142
|
+
[(one) => words(one.when), (one) => `due ${words(one.when)}`],
|
|
143
|
+
[(one) => fold(one.owner), (one) => owner(one.owner)],
|
|
144
|
+
[(one) => fold(one.trigger), (one) => `when ${words(one.trigger)}`],
|
|
145
|
+
];
|
|
146
|
+
for (const [read, say] of kinds) {
|
|
147
|
+
const mine = read(item);
|
|
148
|
+
if (mine && same.every((other) => read(other) !== mine)) return draft(say(item));
|
|
149
|
+
}
|
|
150
|
+
return `Mark '${said}' as done (${item.id}).`;
|
|
151
|
+
}
|
|
152
|
+
</script>
|
|
153
|
+
<script>
|
|
127
154
|
// Memory's Commitments card: what you promised, what your agent promised, and
|
|
128
155
|
// what you're waiting on, overdue first. Nothing is fetched; the list comes
|
|
129
156
|
// from the plugin over the bridge. Marking one done starts a message for the
|
|
@@ -169,7 +196,7 @@ function dueWords(item) {
|
|
|
169
196
|
if (item.when) return item.when;
|
|
170
197
|
return item.trigger ? `${item.trigger.charAt(0).toUpperCase()}${item.trigger.slice(1)}` : "No date";
|
|
171
198
|
}
|
|
172
|
-
function row(item, status) {
|
|
199
|
+
function row(item, status, all) {
|
|
173
200
|
const line = el("li");
|
|
174
201
|
const words = el("div", "grow");
|
|
175
202
|
words.append(el("div", "", item.what), el("div", item.overdue ? "when overdue" : "when", `${dueWords(item)} · ${ownerWords(item.owner)}`));
|
|
@@ -178,7 +205,7 @@ function row(item, status) {
|
|
|
178
205
|
done.setAttribute("aria-label", `Mark done: ${item.what.slice(0, 60)}`);
|
|
179
206
|
done.addEventListener("click", async () => {
|
|
180
207
|
try {
|
|
181
|
-
await view.openAgent(
|
|
208
|
+
await view.openAgent(doneMessage(item, all));
|
|
182
209
|
status.textContent = "Your message is ready. Send it, and the agent marks this as done.";
|
|
183
210
|
} catch (error) {
|
|
184
211
|
status.textContent = `Couldn't start the message: ${error.message}`;
|
|
@@ -208,7 +235,7 @@ async function draw() {
|
|
|
208
235
|
const status = el("p", "muted");
|
|
209
236
|
status.setAttribute("role", "status");
|
|
210
237
|
const list = el("ul");
|
|
211
|
-
list.append(...answer.items.slice(0, SHOWN).map((item) => row(item, status)));
|
|
238
|
+
list.append(...answer.items.slice(0, SHOWN).map((item) => row(item, status, answer.items)));
|
|
212
239
|
const head = overdue > 0
|
|
213
240
|
? state(`${overdue} overdue, ${answer.items.length} open`, "danger")
|
|
214
241
|
: state(`${answer.items.length} open · today is ${answer.today}`, "");
|
package/views/home.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en-GB">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-22O46M2mU2RIOdoFEj4fhYvcXdOjuNJ87aUdLWSkqio='; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
|
6
6
|
<title>Memory</title>
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
@@ -150,6 +150,11 @@ function show(...nodes) {
|
|
|
150
150
|
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.";
|
|
151
151
|
const count = (value, one, many) => `${value.toLocaleString("en-GB")} ${value === 1 ? one : many}`;
|
|
152
152
|
|
|
153
|
+
// The reason, without repeating the headline it sits under.
|
|
154
|
+
function unreachableDetail(overview) {
|
|
155
|
+
return String(overview.reason || "").replace(/^\s*memory\s+can['\u2019]t\s+be\s+reached\s+just\s+now\s*[.:!]?\s*/i, "") || "Try again in a moment.";
|
|
156
|
+
}
|
|
157
|
+
|
|
153
158
|
async function draw() {
|
|
154
159
|
tile.setAttribute("aria-busy", "true");
|
|
155
160
|
let overview;
|
|
@@ -161,11 +166,25 @@ async function draw() {
|
|
|
161
166
|
retry.addEventListener("click", draw);
|
|
162
167
|
return show(state("Couldn't read memory", "danger"), el("p", "muted", error.message), retry);
|
|
163
168
|
}
|
|
164
|
-
if (!overview.connected)
|
|
169
|
+
if (!overview.connected) {
|
|
170
|
+
// Memory set up and not answering is only that: nothing to change in Settings, so a retry, as Commitments has.
|
|
171
|
+
if (overview.state === "unreachable") {
|
|
172
|
+
const retry = el("button", "button", "Try again");
|
|
173
|
+
retry.type = "button";
|
|
174
|
+
retry.addEventListener("click", draw);
|
|
175
|
+
return show(state("Memory can't be reached just now", "danger"), el("p", "muted", unreachableDetail(overview)), retry);
|
|
176
|
+
}
|
|
165
177
|
return show(
|
|
166
178
|
state("Not connected", "off"),
|
|
167
|
-
el(
|
|
179
|
+
el(
|
|
180
|
+
"p",
|
|
181
|
+
"muted",
|
|
182
|
+
overview.state === "refused"
|
|
183
|
+
? "Memory refused the key. Open Settings, then Plugins, then Memory, to check it."
|
|
184
|
+
: "Open Settings, then Plugins, then Memory, to connect it.",
|
|
185
|
+
),
|
|
168
186
|
);
|
|
187
|
+
}
|
|
169
188
|
const counts = overview.counts ?? { memories: 0, conversations: 0 };
|
|
170
189
|
const lines = [state(overview.capture ? "Remembering" : "Not saving conversations", overview.capture ? "" : "off")];
|
|
171
190
|
// Memories are records from 0.9: a server without the records service says so in one line.
|
package/views/memory.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en-GB">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'sha256-5dtPKkjegOPG8bawdSzGBjixnIaSCLYcZOUAwbRWFAc=' 'sha256-EAE0IDrikWE0chPIVODVlKBvBg1sDxCO9UEtFartZJY=' 'sha256-Q8fg8cAZZmRD62VpizjSMkhTSUfbnStU+/9BjGxdfVg='; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
|
|
6
6
|
<title>Your memory</title>
|
|
7
7
|
<style>
|
|
8
8
|
:root {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
p { margin: 0 0 8px; }
|
|
17
17
|
.muted { color: var(--jelly-muted, GrayText); }
|
|
18
18
|
.danger { color: var(--jelly-danger, CanvasText); }
|
|
19
|
-
|
|
19
|
+
/* Six tabs are wider than a phone: the row wraps, and the border runs under the last line. */
|
|
20
|
+
.tabs { display: flex; flex-wrap: wrap; gap: 2px 4px; border-bottom: 1px solid var(--jelly-border, GrayText); margin-bottom: 12px; }
|
|
20
21
|
.tab {
|
|
21
22
|
font: inherit; color: var(--jelly-muted, GrayText); background: none; border: 0;
|
|
22
23
|
border-bottom: 2px solid transparent; padding: 6px 10px; margin-bottom: -1px; cursor: pointer;
|
|
@@ -29,9 +30,9 @@
|
|
|
29
30
|
}
|
|
30
31
|
.button.primary { background: var(--jelly-accent, Highlight); color: var(--jelly-on-accent, HighlightText); border-color: transparent; }
|
|
31
32
|
.link { font: inherit; color: var(--jelly-accent, LinkText); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
|
|
32
|
-
dl { display: grid; grid-template-columns:
|
|
33
|
+
dl { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); gap: 6px 16px; margin: 12px 0 0; }
|
|
33
34
|
dt { color: var(--jelly-muted, GrayText); }
|
|
34
|
-
dd { margin: 0; }
|
|
35
|
+
dd { margin: 0; overflow-wrap: anywhere; }
|
|
35
36
|
ul.rows { list-style: none; margin: 0; padding: 0; }
|
|
36
37
|
ul.rows > li { border-top: 1px solid var(--jelly-border, GrayText); padding: 10px 0; display: flex; gap: 12px; align-items: flex-start; }
|
|
37
38
|
ul.rows > li:first-child { border-top: 0; }
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
<button class="tab" role="tab" id="tab-spaces" aria-controls="panel" aria-selected="false" tabindex="-1" data-tab="spaces">Spaces</button>
|
|
54
55
|
<button class="tab" role="tab" id="tab-wiki" aria-controls="panel" aria-selected="false" tabindex="-1" data-tab="wiki">Wiki</button>
|
|
55
56
|
<button class="tab" role="tab" id="tab-recent" aria-controls="panel" aria-selected="false" tabindex="-1" data-tab="recent">Recent</button>
|
|
57
|
+
<button class="tab" role="tab" id="tab-profile" aria-controls="panel" aria-selected="false" tabindex="-1" data-tab="profile">About you</button>
|
|
56
58
|
</div>
|
|
57
59
|
<main id="panel" role="tabpanel" aria-labelledby="tab-overview" aria-live="polite"></main>
|
|
58
60
|
<script>
|
|
@@ -145,6 +147,33 @@ function jellyView() {
|
|
|
145
147
|
}
|
|
146
148
|
</script>
|
|
147
149
|
<script>
|
|
150
|
+
// done-message.js: the message "Mark done" drafts, for Memory's Commitments views. Paste it into
|
|
151
|
+
// the page's own <script>, as jelly-view.js is. The person reads and sends this text, so it holds
|
|
152
|
+
// no record id: "Mark 'Send the Q4 numbers' as done." The agent finds the commitment by its
|
|
153
|
+
// words (mem_commitments list). Only when another open commitment reads the same (spacing and
|
|
154
|
+
// case aside) does it add what tells them apart, in this order: the due date, the owner, the
|
|
155
|
+
// trigger. Only when two still match exactly does it fall back to the id.
|
|
156
|
+
function doneMessage(item, others) {
|
|
157
|
+
const words = (value) => String(value ?? "").replace(/\s+/g, " ").trim();
|
|
158
|
+
const fold = (value) => words(value).toLowerCase();
|
|
159
|
+
const said = words(item.what);
|
|
160
|
+
const same = (others || []).filter((other) => other !== item && other.id !== item.id && other.state === "open" && fold(other.what) === fold(item.what));
|
|
161
|
+
const draft = (detail) => `Mark '${said}'${detail ? ` (${detail})` : ""} as done.`;
|
|
162
|
+
if (same.length === 0) return draft("");
|
|
163
|
+
const owner = (value) => (value === "user" ? "yours" : value === "agent" ? "your agent's" : `waiting on ${words(value)}`);
|
|
164
|
+
const kinds = [
|
|
165
|
+
[(one) => words(one.when), (one) => `due ${words(one.when)}`],
|
|
166
|
+
[(one) => fold(one.owner), (one) => owner(one.owner)],
|
|
167
|
+
[(one) => fold(one.trigger), (one) => `when ${words(one.trigger)}`],
|
|
168
|
+
];
|
|
169
|
+
for (const [read, say] of kinds) {
|
|
170
|
+
const mine = read(item);
|
|
171
|
+
if (mine && same.every((other) => read(other) !== mine)) return draft(say(item));
|
|
172
|
+
}
|
|
173
|
+
return `Mark '${said}' as done (${item.id}).`;
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
176
|
+
<script>
|
|
148
177
|
// Memory's Settings section. Everything shown comes over the bridge; nothing is
|
|
149
178
|
// fetched. Text from memory is set as text, never parsed as markup.
|
|
150
179
|
const panel = document.getElementById("panel");
|
|
@@ -206,13 +235,21 @@ const plural = (count, one, many) => `${count.toLocaleString("en-GB")} ${count =
|
|
|
206
235
|
/* ------------------------------------------------------------- not connected */
|
|
207
236
|
|
|
208
237
|
function notConnected(overview) {
|
|
238
|
+
// Set up and not answering: nothing to change in settings, so a retry and the reason.
|
|
239
|
+
if (overview.state === "unreachable")
|
|
240
|
+
return el("div", { class: "note", role: "status" },
|
|
241
|
+
el("h2", {}, "Memory can't be reached just now"),
|
|
242
|
+
p(String(overview.reason || "").replace(/^\s*memory\s+can['\u2019]t\s+be\s+reached\s+just\s+now\s*[.:!]?\s*/i, "") || "Try again in a moment."),
|
|
243
|
+
p("Nothing needs changing in this plugin's settings.", "muted"),
|
|
244
|
+
el("div", { class: "actions" }, button("Try again", () => open("overview"))),
|
|
245
|
+
);
|
|
209
246
|
const steps = [];
|
|
210
247
|
if (overview.credential === "none")
|
|
211
248
|
steps.push("Use Jelly with an account that offers Memory, or paste the key from Memory's /account page into Memory key, in this plugin's settings.");
|
|
212
249
|
if (!overview.address) steps.push("If you use your own memory service, put its address in Memory address, in this plugin's settings.");
|
|
213
250
|
if (steps.length === 0) steps.push("Check Memory address and Memory key in this plugin's settings, then try again.");
|
|
214
251
|
return el("div", { class: "note", role: "status" },
|
|
215
|
-
el("h2", {}, "Memory isn't connected"),
|
|
252
|
+
el("h2", {}, overview.state === "refused" ? (overview.credential === "jelly" ? "Memory refused this sign-in" : "Memory refused the key") : "Memory isn't connected"),
|
|
216
253
|
p(overview.reason || "Memory can't be used from this agent yet."),
|
|
217
254
|
el("p", { class: "muted" }, "What to do:"),
|
|
218
255
|
el("ul", {}, steps.map((step) => el("li", {}, step))),
|
|
@@ -416,7 +453,24 @@ function forgetMessage(memory) {
|
|
|
416
453
|
return `Forget this memory: “${start}” (${memory.id}).`;
|
|
417
454
|
}
|
|
418
455
|
|
|
419
|
-
|
|
456
|
+
// Whether a row is the person's own: only their own memories start a Forget message.
|
|
457
|
+
// A shared space's memory is managed in that space, and one held for review is
|
|
458
|
+
// settled in Review, so neither offers it.
|
|
459
|
+
function recentRow(memory, status, own, named) {
|
|
460
|
+
const proposed = memory.status === "proposed";
|
|
461
|
+
const meta = [
|
|
462
|
+
memory.type.replaceAll("_", " "),
|
|
463
|
+
named ? memory.space.name : "",
|
|
464
|
+
memory.status === "contested" ? "Contested" : "",
|
|
465
|
+
memory.stated_by === "external" ? "From someone else" : "",
|
|
466
|
+
date(memory.at),
|
|
467
|
+
].filter(Boolean);
|
|
468
|
+
const body = el("div", { class: "grow" },
|
|
469
|
+
el("div", {}, memory.text),
|
|
470
|
+
el("div", { class: "meta" }, meta.join(" · ")),
|
|
471
|
+
proposed ? el("div", { class: "meta" }, "Waiting for your review, not saved as a memory yet. Decide it in Review.") : null,
|
|
472
|
+
);
|
|
473
|
+
if (proposed || !own) return el("li", {}, body, proposed ? el("span", { class: "badge" }, "Waiting for review") : null);
|
|
420
474
|
const forget = button("Forget…", async () => {
|
|
421
475
|
try {
|
|
422
476
|
await view.openAgent(forgetMessage(memory));
|
|
@@ -427,12 +481,15 @@ function recentRow(memory, status) {
|
|
|
427
481
|
fit();
|
|
428
482
|
});
|
|
429
483
|
forget.setAttribute("aria-label", `Forget: ${memory.text.slice(0, 60)}`);
|
|
430
|
-
return el("li", {},
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
484
|
+
return el("li", {}, body, forget);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** What the list could not read, in words: a space is never left out without saying so. */
|
|
488
|
+
function recentIncomplete(answer) {
|
|
489
|
+
if (answer.incomplete.length === 0) return null;
|
|
490
|
+
return el("div", { class: "note", role: "status" },
|
|
491
|
+
el("p", {}, el("strong", {}, "Some memories are missing from this list.")),
|
|
492
|
+
el("ul", {}, answer.incomplete.map((space) => el("li", {}, `${space.name}: ${space.reason}`))),
|
|
436
493
|
);
|
|
437
494
|
}
|
|
438
495
|
|
|
@@ -447,15 +504,28 @@ async function recentTab(offset = 0, list = null) {
|
|
|
447
504
|
return fit();
|
|
448
505
|
}
|
|
449
506
|
const status = el("p", { class: "muted", role: "status" });
|
|
507
|
+
// The space is named on each row when the list covers more than the person's own.
|
|
508
|
+
const named = answer.spaces.length > 1 || answer.items.some((memory) => memory.space.id !== answer.space.id);
|
|
450
509
|
if (list === null) {
|
|
451
510
|
if (answer.items.length === 0)
|
|
452
|
-
return show(
|
|
511
|
+
return show(
|
|
512
|
+
p("Nothing remembered yet. Memories show here as your agents save them.", "muted"),
|
|
513
|
+
recentIncomplete(answer),
|
|
514
|
+
);
|
|
453
515
|
list = el("ul", { class: "rows" });
|
|
454
|
-
show(
|
|
516
|
+
show(
|
|
517
|
+
p(named
|
|
518
|
+
? "Your newest memories, and those in your shared spaces, newest first. Forget starts a message for you to send, for your own memories."
|
|
519
|
+
: "Your newest memories, newest first. Forget starts a message for you to send."),
|
|
520
|
+
recentIncomplete(answer),
|
|
521
|
+
status,
|
|
522
|
+
list,
|
|
523
|
+
);
|
|
455
524
|
} else {
|
|
456
525
|
panel.querySelector(".more")?.remove();
|
|
457
526
|
}
|
|
458
|
-
|
|
527
|
+
const own = (memory) => memory.space.id === answer.space.id;
|
|
528
|
+
list.append(...answer.items.map((memory) => recentRow(memory, panel.querySelector("[role=status]") ?? status, own(memory), named)));
|
|
459
529
|
if (answer.more) {
|
|
460
530
|
const more = el("div", { class: "actions more" }, button("Show more", () => recentTab(offset + 50, list)));
|
|
461
531
|
list.after(more);
|
|
@@ -465,6 +535,42 @@ async function recentTab(offset = 0, list = null) {
|
|
|
465
535
|
fit();
|
|
466
536
|
}
|
|
467
537
|
|
|
538
|
+
/* ----------------------------------------------------------------- about you */
|
|
539
|
+
|
|
540
|
+
// What Memory holds about the person: the persona and the scenarios under it.
|
|
541
|
+
// The text is Memory's own, written from conversations, so it is shown as text
|
|
542
|
+
// and labelled as data; erasing is asked of an agent, which previews it first.
|
|
543
|
+
async function profileTab() {
|
|
544
|
+
loading();
|
|
545
|
+
let answer;
|
|
546
|
+
try {
|
|
547
|
+
answer = await call("profile.read", {});
|
|
548
|
+
} catch (error) {
|
|
549
|
+
return failed(error, () => open("profile"));
|
|
550
|
+
}
|
|
551
|
+
const notes = answer.notes.length > 0
|
|
552
|
+
? el("div", { class: "note", role: "status" },
|
|
553
|
+
answer.incomplete ? el("p", {}, el("strong", {}, "This may be less than Memory holds.")) : null,
|
|
554
|
+
el("ul", {}, answer.notes.map((note) => el("li", {}, note))))
|
|
555
|
+
: null;
|
|
556
|
+
if (answer.items.length === 0)
|
|
557
|
+
return show(p("Memory holds nothing about you yet. It writes this from your conversations, once it has enough of them.", "muted"), notes);
|
|
558
|
+
const several = new Set(answer.items.map((item) => item.agent)).size > 1;
|
|
559
|
+
const part = (item) => el("section", { class: "spaced" },
|
|
560
|
+
el("h2", {}, item.layer === "persona" ? "Your profile" : item.summary || item.path),
|
|
561
|
+
el("div", { class: "meta" }, [item.layer === "persona" ? "" : item.path, several ? `Agent ${item.agent}` : "", date(item.updated)].filter(Boolean).join(" · ")),
|
|
562
|
+
el("div", { class: "page" }, item.text),
|
|
563
|
+
item.clipped ? p("This is long, so only its start is shown.", "muted") : null,
|
|
564
|
+
);
|
|
565
|
+
show(
|
|
566
|
+
p(answer.label, "muted"),
|
|
567
|
+
notes,
|
|
568
|
+
answer.items.map(part),
|
|
569
|
+
answer.more ? p("Memory holds more than this page shows.", "muted spaced") : null,
|
|
570
|
+
p("To erase something, ask an agent to forget it. It shows you what would go first.", "muted spaced"),
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
|
|
468
574
|
/* --------------------------------------------------------------- commitments */
|
|
469
575
|
|
|
470
576
|
// Words for who will do it: never colour alone, and never the stored "user".
|
|
@@ -481,11 +587,7 @@ function dueWords(item) {
|
|
|
481
587
|
if (item.when) return item.when;
|
|
482
588
|
return item.trigger ? `${item.trigger.charAt(0).toUpperCase()}${item.trigger.slice(1)}` : "No date";
|
|
483
589
|
}
|
|
484
|
-
|
|
485
|
-
function doneMessage(item) {
|
|
486
|
-
return `Mark '${item.what.replace(/\s+/g, " ").trim()}' as done (${item.id}).`;
|
|
487
|
-
}
|
|
488
|
-
function commitmentRow(item, status) {
|
|
590
|
+
function commitmentRow(item, status, all) {
|
|
489
591
|
const meta = [ownerWords(item.owner), item.project ? `Project ${item.project}` : ""].filter(Boolean).join(" · ");
|
|
490
592
|
const row = el("li", {},
|
|
491
593
|
el("div", { class: "grow" },
|
|
@@ -497,7 +599,7 @@ function commitmentRow(item, status) {
|
|
|
497
599
|
if (item.state === "open") {
|
|
498
600
|
const done = button("Mark done…", async () => {
|
|
499
601
|
try {
|
|
500
|
-
await view.openAgent(doneMessage(item));
|
|
602
|
+
await view.openAgent(doneMessage(item, all));
|
|
501
603
|
status.textContent = "Your message is ready. Send it, and the agent marks this as done.";
|
|
502
604
|
} catch (error) {
|
|
503
605
|
status.textContent = `Couldn't start the message: ${error.message}`;
|
|
@@ -526,13 +628,13 @@ async function commitmentsTab() {
|
|
|
526
628
|
if (openList.items.length === 0) {
|
|
527
629
|
parts.push(p("Nothing due. When you ask your agent to remind you of something, it shows here.", "muted"));
|
|
528
630
|
} else {
|
|
529
|
-
parts.push(el("ul", { class: "rows" }, openList.items.map((item) => commitmentRow(item, status))));
|
|
631
|
+
parts.push(el("ul", { class: "rows" }, openList.items.map((item) => commitmentRow(item, status, openList.items))));
|
|
530
632
|
if (openList.more) parts.push(p("Only the first 100 are shown. Ask your agent for the rest.", "muted"));
|
|
531
633
|
}
|
|
532
634
|
if (closed.items.length > 0) {
|
|
533
635
|
parts.push(
|
|
534
636
|
el("h2", { class: "spaced" }, "Done recently"),
|
|
535
|
-
el("ul", { class: "rows" }, closed.items.slice(0, 20).map((item) => commitmentRow(item, status))),
|
|
637
|
+
el("ul", { class: "rows" }, closed.items.slice(0, 20).map((item) => commitmentRow(item, status, openList.items))),
|
|
536
638
|
p("Closed commitments are kept for 90 days.", "muted"),
|
|
537
639
|
);
|
|
538
640
|
}
|
|
@@ -541,7 +643,7 @@ async function commitmentsTab() {
|
|
|
541
643
|
|
|
542
644
|
/* ---------------------------------------------------------------------- tabs */
|
|
543
645
|
|
|
544
|
-
const SCREENS = { overview: overviewTab, commitments: commitmentsTab, spaces: spacesTab, wiki: wikiTab, recent: () => recentTab() };
|
|
646
|
+
const SCREENS = { overview: overviewTab, commitments: commitmentsTab, spaces: spacesTab, wiki: wikiTab, recent: () => recentTab(), profile: profileTab };
|
|
545
647
|
|
|
546
648
|
function open(name) {
|
|
547
649
|
shown = name;
|