@joe-broadhead/opencode-mem 0.6.2 → 0.7.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/README.md CHANGED
@@ -194,8 +194,9 @@ account you sign in to Jelly with.
194
194
  `baseURL` and `knowledgeURL` default to `<origin>/core` and `<origin>/knowledge`.
195
195
 
196
196
  A token is never logged, spooled, or written to a file. With no credential the
197
- plugin still loads and registers its nine tools; each answers one sentence
198
- saying why memory is unavailable, and nothing is captured, spooled, or sent.
197
+ plugin still loads and registers its nine tools and its view RPC; each tool
198
+ answers one sentence saying why memory is unavailable, and nothing is
199
+ captured, spooled, or sent.
199
200
 
200
201
  **Icon.** The declaration's `icon` is `assets/icon.svg`, shipped in the
201
202
  package: a flat brain mark on a square `viewBox`, made only of the elements
@@ -258,9 +259,10 @@ The declaration has no sign-ins: the Jelly account is the host's sign-in, and
258
259
  the pasted key is a secret setting. `npm run check:jelly -- <Jelly checkout>`
259
260
  parses the declaration with Jelly's own `PluginDeclarationSchema`, checks that
260
261
  `resources` is kept and not required, that `asks` is not required and is kept
261
- when that Jelly knows it, and runs the icon through Jelly's
262
- `cleanPluginIcon`; `test/jelly-declaration.test.js` checks the same in CI,
263
- with the schema and the cleaner restated.
262
+ when that Jelly knows it, runs the icon through Jelly's `cleanPluginIcon`,
263
+ and checks the views ([Views in Jelly](#views-in-jelly));
264
+ `test/jelly-declaration.test.js` and `test/views-contract.test.js` check the
265
+ same in CI, with the rules restated.
264
266
 
265
267
  **One memory per person.** Every Jelly engine runs the OpenCode agent `agent`,
266
268
  so a person's Jelly agents read and write one personal memory, under agent
@@ -268,6 +270,75 @@ so a person's Jelly agents read and write one personal memory, under agent
268
270
  persona and scenarios of their other OpenCode agents (`build`, `plan`, …),
269
271
  which are keyed by agent name. `agent` is not a reserved name.
270
272
 
273
+ ### Views in Jelly
274
+
275
+ Memory's screens in Jelly are the plugin's own views (`jelly.views`), shown
276
+ with the person's Jelly sign-in: there is no second sign-in, and Jelly holds
277
+ no screen of its own for memory. Each page is a static file in the package
278
+ (`views/*.html`), run by Jelly in a sealed frame with no network; it reaches
279
+ only this plugin's read-only RPC, and only for the agent it is shown for.
280
+
281
+ | View | Place | Shows | Grants |
282
+ |---|---|---|---|
283
+ | `home` "Memory" | Home tile, small | Whether conversations are remembered, and how many memories are kept | `rpc`: `memory.overview` |
284
+ | `memory` "Your memory" | This plugin's card in Settings → Plugins | Four tabs: **Overview** (what memory is, the sign-in in use, the address, Remember conversations, health, counts), **Spaces**, **Wiki** (browse and read), **Recent** (the newest 100 memories, with Forget) | `data`, `rpc`: all six methods, `open-agent` |
285
+
286
+ **The RPC** (`src/views/rpc.js`, schemas in `src/views/contracts.js`). The
287
+ plugin registers it with the engine under its package name, the only id Jelly
288
+ calls for its views. Jelly holds each call to the agent's rules for the
289
+ method's permission, the one the matching tool reads under, before the plugin
290
+ sees it:
291
+
292
+ | Method | Permission | Reads |
293
+ |---|---|---|
294
+ | `memory.overview` | `mem_status` | The credential source, the address, capture as this engine runs it, health, the personal space and its counts |
295
+ | `spaces.list` | `mem_spaces` | `GET /v1/spaces` |
296
+ | `memories.recent` | `mem_recall` | The personal space's newest L1 atoms (`/v3/atomic/query`), 50 a page, two pages |
297
+ | `wiki.list`, `wiki.pages`, `wiki.read` | `mem_wiki` | The personal space's wikis, a wiki's pages, one page (at most 48,000 characters) |
298
+
299
+ Every call is a read the tools already make, through the gateway with the
300
+ credential chain above, so no gateway route is added for the views and the
301
+ gateway scopes each one to the caller. A view never names a user, a space or
302
+ a container. Reads are under the engine's own primary agents
303
+ (`ctx.agent.list()`, which inside Jelly is `agent`), or the `agent` option
304
+ when it is set. A wiki or page id from another person's memory is refused.
305
+ With no credential the overview says why and what to do, and every other
306
+ read refuses with the same sentence the tools give.
307
+
308
+ **Writes go through the agent.** Forget on a recent memory fills the
309
+ composer with "Forget this memory: “<its first 80 characters>” (<id>)." The id
310
+ is all `mem_forget` needs: it finds the memory under the agent the person is
311
+ talking to, which is the agent the views read under, so no agent name is
312
+ written. The person sends it, and `mem_forget` runs under
313
+ their rules, as any forget does. **Remember conversations** stays a declared
314
+ setting on the plugin's card, on by default. Because memory is on for every
315
+ Jelly user, the Home tile and the top of the Overview say plainly what it
316
+ saves ("Memory saves your finished conversations to your private memory"),
317
+ what private means (only you and your agents; nothing goes to a shared space
318
+ unless you choose, and Jelly asks first), and where to turn it off
319
+ (Settings → Plugins → Memory). A view cannot open a setting, so the place is
320
+ named in words. The Overview also notes when a saved change waits for the
321
+ engine's next start.
322
+
323
+ **No recall view yet.** Jelly runs the memory tools through Code Mode, and a
324
+ view is not given the result of a call made inside it, so there is no view
325
+ behind `mem_recall`, and its result is exactly 0.6.2's. What Jelly would need:
326
+ [jelly-views-later.md](docs/design/jelly-views-later.md).
327
+
328
+ **No `pattern` in the schemas.** The pinned engine's RPC refuses to register a
329
+ method whose schema has a `pattern` ("Patterns may block validation and are
330
+ disabled"), so the schemas bound ids by length and the handlers check their
331
+ form, refusing a bad one in words. `check:jelly` and the tests refuse a
332
+ `pattern`.
333
+
334
+ `npm run check:jelly` checks the views against Jelly's own code: the subset
335
+ rules, each method's schemas through Jelly's reader with a sample answer of
336
+ each (`test/fixtures/view-answers.js`), and each page carrying Jelly's bridge
337
+ helper as it is (`views/jelly-view.js`, pasted into every page). With a
338
+ Chrome, `npm run shots:views -- <Jelly checkout> <out dir>` draws every
339
+ screen, in Jelly and Jelly Night, under the policy Jelly serves pages with,
340
+ and fails on any refusal or page error.
341
+
271
342
  ## Spaces, grants, and memory
272
343
 
273
344
  Each user has one personal space, in a memory container of its own: upstream
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joe-broadhead/opencode-mem",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "Durable private and shared-space memory for OpenCode agents",
6
6
  "license": "MIT",
@@ -74,8 +74,446 @@
74
74
  "skills": [
75
75
  "mem.usage"
76
76
  ],
77
- "rpc": [],
78
- "views": [],
77
+ "rpc": [
78
+ {
79
+ "name": "memory.overview",
80
+ "label": "say whether memory is connected and how much it holds",
81
+ "permission": "mem_status",
82
+ "readOnly": true,
83
+ "input": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "properties": {}
87
+ },
88
+ "output": {
89
+ "type": "object",
90
+ "additionalProperties": false,
91
+ "required": [
92
+ "connected",
93
+ "credential",
94
+ "capture",
95
+ "health"
96
+ ],
97
+ "properties": {
98
+ "connected": {
99
+ "type": "boolean"
100
+ },
101
+ "reason": {
102
+ "type": "string",
103
+ "maxLength": 400
104
+ },
105
+ "credential": {
106
+ "type": "string",
107
+ "enum": [
108
+ "jelly",
109
+ "key",
110
+ "option",
111
+ "none"
112
+ ]
113
+ },
114
+ "refused": {
115
+ "type": "string",
116
+ "maxLength": 40
117
+ },
118
+ "address": {
119
+ "type": "string",
120
+ "maxLength": 300
121
+ },
122
+ "capture": {
123
+ "type": "boolean"
124
+ },
125
+ "health": {
126
+ "type": "string",
127
+ "enum": [
128
+ "ok",
129
+ "unreachable",
130
+ "unknown"
131
+ ]
132
+ },
133
+ "space": {
134
+ "type": "object",
135
+ "additionalProperties": false,
136
+ "required": [
137
+ "id",
138
+ "name",
139
+ "kind"
140
+ ],
141
+ "properties": {
142
+ "id": {
143
+ "type": "string",
144
+ "maxLength": 200
145
+ },
146
+ "name": {
147
+ "type": "string",
148
+ "maxLength": 200
149
+ },
150
+ "kind": {
151
+ "type": "string",
152
+ "enum": [
153
+ "personal",
154
+ "shared",
155
+ "unknown"
156
+ ]
157
+ }
158
+ }
159
+ },
160
+ "counts": {
161
+ "type": "object",
162
+ "additionalProperties": false,
163
+ "required": [
164
+ "memories",
165
+ "conversations",
166
+ "summaries",
167
+ "profile"
168
+ ],
169
+ "properties": {
170
+ "memories": {
171
+ "type": "integer",
172
+ "minimum": 0
173
+ },
174
+ "conversations": {
175
+ "type": "integer",
176
+ "minimum": 0
177
+ },
178
+ "summaries": {
179
+ "type": "integer",
180
+ "minimum": 0
181
+ },
182
+ "profile": {
183
+ "type": "boolean"
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ },
190
+ {
191
+ "name": "spaces.list",
192
+ "label": "list your memory spaces",
193
+ "permission": "mem_spaces",
194
+ "readOnly": true,
195
+ "input": {
196
+ "type": "object",
197
+ "additionalProperties": false,
198
+ "properties": {}
199
+ },
200
+ "output": {
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "required": [
204
+ "spaces"
205
+ ],
206
+ "properties": {
207
+ "spaces": {
208
+ "type": "array",
209
+ "maxItems": 100,
210
+ "items": {
211
+ "type": "object",
212
+ "additionalProperties": false,
213
+ "required": [
214
+ "id",
215
+ "name",
216
+ "kind",
217
+ "role"
218
+ ],
219
+ "properties": {
220
+ "id": {
221
+ "type": "string",
222
+ "maxLength": 200
223
+ },
224
+ "name": {
225
+ "type": "string",
226
+ "maxLength": 200
227
+ },
228
+ "kind": {
229
+ "type": "string",
230
+ "enum": [
231
+ "personal",
232
+ "shared",
233
+ "unknown"
234
+ ]
235
+ },
236
+ "role": {
237
+ "type": "string",
238
+ "maxLength": 40
239
+ }
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ },
246
+ {
247
+ "name": "memories.recent",
248
+ "label": "list your newest memories",
249
+ "permission": "mem_recall",
250
+ "readOnly": true,
251
+ "input": {
252
+ "type": "object",
253
+ "additionalProperties": false,
254
+ "properties": {
255
+ "offset": {
256
+ "type": "integer",
257
+ "minimum": 0,
258
+ "maximum": 50,
259
+ "multipleOf": 50
260
+ }
261
+ }
262
+ },
263
+ "output": {
264
+ "type": "object",
265
+ "additionalProperties": false,
266
+ "required": [
267
+ "space",
268
+ "items",
269
+ "more"
270
+ ],
271
+ "properties": {
272
+ "space": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": [
276
+ "id",
277
+ "name",
278
+ "kind"
279
+ ],
280
+ "properties": {
281
+ "id": {
282
+ "type": "string",
283
+ "maxLength": 200
284
+ },
285
+ "name": {
286
+ "type": "string",
287
+ "maxLength": 200
288
+ },
289
+ "kind": {
290
+ "type": "string",
291
+ "enum": [
292
+ "personal",
293
+ "shared",
294
+ "unknown"
295
+ ]
296
+ }
297
+ }
298
+ },
299
+ "items": {
300
+ "type": "array",
301
+ "maxItems": 50,
302
+ "items": {
303
+ "type": "object",
304
+ "additionalProperties": false,
305
+ "required": [
306
+ "id",
307
+ "text",
308
+ "type",
309
+ "at"
310
+ ],
311
+ "properties": {
312
+ "id": {
313
+ "type": "string",
314
+ "maxLength": 200
315
+ },
316
+ "text": {
317
+ "type": "string",
318
+ "maxLength": 600
319
+ },
320
+ "type": {
321
+ "type": "string",
322
+ "maxLength": 40
323
+ },
324
+ "at": {
325
+ "type": "string",
326
+ "maxLength": 40
327
+ }
328
+ }
329
+ }
330
+ },
331
+ "more": {
332
+ "type": "boolean"
333
+ }
334
+ }
335
+ }
336
+ },
337
+ {
338
+ "name": "wiki.list",
339
+ "label": "list your wikis",
340
+ "permission": "mem_wiki",
341
+ "readOnly": true,
342
+ "input": {
343
+ "type": "object",
344
+ "additionalProperties": false,
345
+ "properties": {}
346
+ },
347
+ "output": {
348
+ "type": "object",
349
+ "additionalProperties": false,
350
+ "required": [
351
+ "wikis"
352
+ ],
353
+ "properties": {
354
+ "wikis": {
355
+ "type": "array",
356
+ "maxItems": 100,
357
+ "items": {
358
+ "type": "object",
359
+ "additionalProperties": false,
360
+ "required": [
361
+ "id",
362
+ "name",
363
+ "pages"
364
+ ],
365
+ "properties": {
366
+ "id": {
367
+ "type": "string",
368
+ "maxLength": 200
369
+ },
370
+ "name": {
371
+ "type": "string",
372
+ "maxLength": 200
373
+ },
374
+ "pages": {
375
+ "type": "integer",
376
+ "minimum": 0
377
+ }
378
+ }
379
+ }
380
+ }
381
+ }
382
+ }
383
+ },
384
+ {
385
+ "name": "wiki.pages",
386
+ "label": "list a wiki's pages",
387
+ "permission": "mem_wiki",
388
+ "readOnly": true,
389
+ "input": {
390
+ "type": "object",
391
+ "additionalProperties": false,
392
+ "required": [
393
+ "wiki"
394
+ ],
395
+ "properties": {
396
+ "wiki": {
397
+ "type": "string",
398
+ "maxLength": 200
399
+ }
400
+ }
401
+ },
402
+ "output": {
403
+ "type": "object",
404
+ "additionalProperties": false,
405
+ "required": [
406
+ "pages"
407
+ ],
408
+ "properties": {
409
+ "pages": {
410
+ "type": "array",
411
+ "maxItems": 100,
412
+ "items": {
413
+ "type": "object",
414
+ "additionalProperties": false,
415
+ "required": [
416
+ "ref",
417
+ "title"
418
+ ],
419
+ "properties": {
420
+ "ref": {
421
+ "type": "string",
422
+ "maxLength": 200
423
+ },
424
+ "title": {
425
+ "type": "string",
426
+ "maxLength": 200
427
+ }
428
+ }
429
+ }
430
+ }
431
+ }
432
+ }
433
+ },
434
+ {
435
+ "name": "wiki.read",
436
+ "label": "read a wiki page",
437
+ "permission": "mem_wiki",
438
+ "readOnly": true,
439
+ "input": {
440
+ "type": "object",
441
+ "additionalProperties": false,
442
+ "required": [
443
+ "wiki",
444
+ "ref"
445
+ ],
446
+ "properties": {
447
+ "wiki": {
448
+ "type": "string",
449
+ "maxLength": 200
450
+ },
451
+ "ref": {
452
+ "type": "string",
453
+ "maxLength": 200
454
+ }
455
+ }
456
+ },
457
+ "output": {
458
+ "type": "object",
459
+ "additionalProperties": false,
460
+ "required": [
461
+ "ref",
462
+ "content",
463
+ "clipped"
464
+ ],
465
+ "properties": {
466
+ "ref": {
467
+ "type": "string",
468
+ "maxLength": 200
469
+ },
470
+ "content": {
471
+ "type": "string",
472
+ "maxLength": 48000
473
+ },
474
+ "clipped": {
475
+ "type": "boolean"
476
+ }
477
+ }
478
+ }
479
+ }
480
+ ],
481
+ "views": [
482
+ {
483
+ "v": 1,
484
+ "id": "home",
485
+ "place": "home-widget",
486
+ "title": "Memory",
487
+ "size": "s",
488
+ "page": "views/home.html",
489
+ "grants": [
490
+ "rpc"
491
+ ],
492
+ "rpc": [
493
+ "memory.overview"
494
+ ]
495
+ },
496
+ {
497
+ "v": 1,
498
+ "id": "memory",
499
+ "place": "settings-section",
500
+ "title": "Your memory",
501
+ "page": "views/memory.html",
502
+ "grants": [
503
+ "data",
504
+ "rpc",
505
+ "open-agent"
506
+ ],
507
+ "rpc": [
508
+ "memory.overview",
509
+ "spaces.list",
510
+ "memories.recent",
511
+ "wiki.list",
512
+ "wiki.pages",
513
+ "wiki.read"
514
+ ]
515
+ }
516
+ ],
79
517
  "signIns": [],
80
518
  "contributes": {
81
519
  "homeFeeds": [],
@@ -118,6 +556,8 @@
118
556
  "src",
119
557
  "skills",
120
558
  "assets/icon.svg",
559
+ "views/home.html",
560
+ "views/memory.html",
121
561
  "docs/agent-protocol.md",
122
562
  "!docs/README.md",
123
563
  "README.md",
@@ -168,7 +608,8 @@
168
608
  "check:docs": "node scripts/check-docs.mjs",
169
609
  "check:docker": "node scripts/check-docker-imports.mjs",
170
610
  "check:compose": "node scripts/check-compose.mjs",
171
- "check:jelly": "bun scripts/check-jelly-declaration.mjs"
611
+ "check:jelly": "bun scripts/check-jelly-declaration.mjs",
612
+ "shots:views": "node scripts/view-shots.mjs"
172
613
  },
173
614
  "keywords": [
174
615
  "opencode",
@@ -179,7 +620,7 @@
179
620
  ],
180
621
  "repository": {
181
622
  "type": "git",
182
- "url": "https://github.com/joe-broadhead/opencode-mem.git"
623
+ "url": "git+https://github.com/joe-broadhead/opencode-mem.git"
183
624
  },
184
625
  "homepage": "https://github.com/joe-broadhead/opencode-mem",
185
626
  "bugs": {
package/src/index.js CHANGED
@@ -8,6 +8,7 @@ import { syncSkills, registerBuiltinSkill } from "./skills.js"
8
8
  import { registerCommands } from "./commands.js"
9
9
  import { attachMemoryHooks } from "./hooks.js"
10
10
  import { attachCapture } from "./events.js"
11
+ import { registerViewRpc } from "./views/rpc.js"
11
12
  import { errorMessage, versionAtLeast } from "./util.js"
12
13
 
13
14
  /**
@@ -129,6 +130,15 @@ export default {
129
130
  log.error("tool registration failed", error)
130
131
  }
131
132
 
133
+ // Memory's views in Jelly call this RPC. It registers even while memory is
134
+ // unavailable, so the views can say why and what to do.
135
+ try {
136
+ const views = await registerViewRpc(ctx, runtime)
137
+ if (views) disposers.push(() => views.dispose())
138
+ } catch (error) {
139
+ log.error("view RPC registration failed", error)
140
+ }
141
+
132
142
  try {
133
143
  await runtime.refreshSkills()
134
144
  } catch (error) {