@joe-broadhead/opencode-mem 0.8.1 → 0.8.3

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 CHANGED
@@ -3,6 +3,123 @@
3
3
  The format follows Keep a Changelog 1.1.0: one `## [x.y.z] - date` section per
4
4
  release.
5
5
 
6
+ ## [0.8.3] - 2026-11-07
7
+
8
+ Memory's views ask for the person who opened them (Jelly's resource-token
9
+ contract v1.5 §6.1, Jelly 0.3.3). Not published yet: it is published from its
10
+ own `v0.8.3` tag by `.github/workflows/release.yml`.
11
+
12
+ ### Changed
13
+
14
+ - **A view call asks as its person.** Every method Memory's views call
15
+ (`memory.overview`, `spaces.list`, `memories.recent`, `wiki.list`,
16
+ `wiki.pages`, `wiki.read`, `commitments.list`) declares an optional string
17
+ `jellySpeaker` in its input, in `package.json`'s `jelly.rpc` and in the
18
+ schema the plugin registers with the engine (`src/views/contracts.js`). A
19
+ Jelly host of v1.5 or later fills it with a speaker id naming the person
20
+ whose device made the call. The handler strips it from the input
21
+ (`splitSpeaker` in `src/views/rpc.js`) and runs the read in `asView(id)`
22
+ (`src/credentials.js`): every request of that call carries
23
+ `token("memory", { session: id })`, asked once per call. On a shared agent a
24
+ member's view now shows the member's own memory, and the owner's view works
25
+ after a plugin's turn.
26
+ - **Kept for the call only.** A view call's token and refusal live in the
27
+ call's scope and go with it: never in the 64-session cache or its refusal
28
+ hold, never reused by a later call, the skill mirror, background work or a
29
+ spool replay. The id is never sent to the gateway, logged (a view call's
30
+ refusal is logged as `view: true`), stored or spooled; a write spooled inside
31
+ a view call would record the account its token named and replay under the
32
+ session rules, never with the id.
33
+ - **An unlinked person.** When Jelly refuses a view call with `not_enrolled`
34
+ and the detail `not_signed_in`, Jelly is asked before any request, the call
35
+ uses no credential (not the pasted key, not the owner's or another session's
36
+ token) and sends nothing, and the view answers "Memory is unavailable: you
37
+ have not linked a Jelly account on this host." Other refusals fall back as
38
+ for a session; `access_denied` does not.
39
+ - **Unchanged without the id:** a Jelly before 0.3.3 and stock OpenCode send no
40
+ `jellySpeaker`, and a view asks `token("memory")` with no options, exactly as
41
+ in 0.8.2. A malformed id runs the call the same way.
42
+ - **The declaration grows by one optional input property per method** and asks
43
+ for nothing more: no tool, permission, resource, sign-in, view or grant
44
+ changes, and a method's `permission` and `label` are unchanged, so Jelly's
45
+ declaration refresh (DECL-REFRESH) applies it at once and puts nothing under
46
+ Changes to review.
47
+
48
+ ### Added
49
+
50
+ - `test/view-speaker.test.js`: the eight Memory tests of the VIEW-SPEAKER
51
+ spec, against the real control plane and gateway: a view call asks with its
52
+ id once; without one it asks as 0.8.2; Sam's and Ana's concurrent calls keep
53
+ their own tokens; no view token outlives its call; an unlinked person's call
54
+ sends nothing; the id never reaches a request, the log or a stored record;
55
+ actions (none declared) and the spool; and the declaration's optional
56
+ `jellySpeaker` on every method, never required.
57
+
58
+ ## [0.8.2] - 2026-11-06
59
+
60
+ A Jelly token per chat, and no fallback for a speaker with no linked account
61
+ (coordinator's decision D30; Jelly's resource-token contract v1.3 §6 and §7).
62
+ Not published yet: it is published from its own `v0.8.2` tag by
63
+ `.github/workflows/release.yml`.
64
+
65
+ ### Changed
66
+
67
+ - **A token per session.** Inside Jelly the plugin asks
68
+ `token("memory", { session })` with the OpenCode session of the work, so on a
69
+ Jelly host with members each person speaking to a shared agent is remembered
70
+ as themselves. A captured turn, a tool call (`context.sessionID`), a command,
71
+ the pinned block, the compaction checkpoint and the replay of a spooled entry
72
+ each use their own session's token (`asSession` in `src/credentials.js`).
73
+ Tokens are cached per session until 60 s before they expire, with one ask in
74
+ flight per session, and a `401` re-asks once for that session only. The cache
75
+ holds at most 64 sessions (least recently used first out) and drops a session
76
+ when OpenCode deletes it; `session.deleted` is read also with
77
+ `capture: false`. Work that belongs to no session (the skill mirror,
78
+ Memory's views, start-up) asks `token("memory")` as before.
79
+ - **Asked again at each user turn.** A second person can speak in a session
80
+ someone else started, so each new user message (the `prompt` hook, which is
81
+ now registered also with `bootstrap: false`, and the admission event) drops
82
+ the session's token and refusal hold; the turn's first memory call asks
83
+ again. A turn superseded by a newer message is still captured with its own
84
+ token. A turn with no user message (a wake, a routine) keeps the cached
85
+ token. A spooled entry records the account its token named
86
+ (`credentialSubject`) and waits while its session's token names someone
87
+ else.
88
+ - **No fallback for an unlinked speaker.** When Jelly refuses a session with
89
+ `not_enrolled` and the detail `not_signed_in` (the person speaking has not
90
+ linked a Jelly account on this host), that session uses no credential: not
91
+ the pasted key, which belongs to whoever pasted it, and not another session's
92
+ token. Its turns are neither captured nor spooled, the context hook adds
93
+ nothing, and every tool and command answers "Memory isn't available in this
94
+ chat because the person speaking hasn't linked their Jelly account on this
95
+ host." The refusal is held 30 s per session; other sessions are unaffected. A
96
+ request that meets it mid-flight fails with `MEMORY_NOT_LINKED`. Other
97
+ refusals behave as in 0.8.1, `access_denied` included.
98
+ - **The spool keeps an entry's identity.** Each entry records
99
+ `credentialSession`, the session it was written in, and is replayed as that
100
+ session whichever session's flush sends it, so one person's turn is never
101
+ sent with another's token. An entry whose session's speaker is unlinked is
102
+ deleted, and the log names the file, never the content. Entries from 0.8.1
103
+ replay as their turn's session, or with no session. `flushSpool` reports
104
+ `dropped` when it deleted one.
105
+ - **Unchanged:** stock OpenCode (the `token` option, `MEMORY_TOKEN`, then the
106
+ pasted key); an accessor that ignores `session`; and Jelly 0.3.2, whose
107
+ accessor refuses `{ session }` as `invalid_target` with the detail
108
+ `invalid_cnf_jwk`: the plugin then asks as before, one token for the engine.
109
+ An accessor that throws on the option is handled as any other throw.
110
+ - The accepted risk is restated: a session that falls back writes as the
111
+ pasted key's user whoever speaks in it; an unlinked speaker never does, as
112
+ long as Jelly passes the refusal's `detail` through
113
+ ([README](README.md#running-inside-jelly)).
114
+
115
+ ### Added
116
+
117
+ - `test/session-tokens.test.js`: two sessions with two speakers, the unlinked
118
+ speaker, the hold per session, the bound and the deletion, the spool, a 401
119
+ per session, stock OpenCode, both shapes of a Jelly 0.3.2 accessor, and a
120
+ new speaker in the same session (A then B, an unlinked B after A, A after an
121
+ unlinked B at once, a superseded turn, the spool waiting for its speaker).
122
+
6
123
  ## [0.8.1] - 2026-11-06
7
124
 
8
125
  Memory follows Jelly's plugin authors' standard, and forgetting asks first. Not
package/README.md CHANGED
@@ -175,23 +175,41 @@ plugin, which then uses the pasted key.
175
175
  2. Jelly's identity accessor, `globalThis[Symbol.for("jelly.identity")]`, when
176
176
  its `resources()` lists `memory`: the host is signed in to a Jelly account
177
177
  whose Jelly ID offers `memory`, and the agent was given this plugin. The
178
- plugin asks `token("memory")` for a ten-minute token, keeps it in memory
178
+ plugin asks for a ten-minute token **per chat** (below), keeps it in memory
179
179
  until 60 s before it expires, and asks again once when the gateway answers
180
180
  `401`;
181
181
  3. the **Memory key** setting: the key pasted from Memory's `/account`
182
182
  page, read with
183
183
  `globalThis[Symbol.for("jelly.plugin-secrets")].get("@joe-broadhead/opencode-mem", "token")`.
184
184
 
185
+ **A token per chat (0.8.2).** On a Jelly host with members, several people
186
+ can talk to one agent, and a Jelly token names one person. So the plugin asks
187
+ `token("memory", { session })` with the OpenCode session of the work: a
188
+ captured turn, a tool call, the pinned block, and the replay of a spooled entry
189
+ each use the token of the session they belong to, which names the person
190
+ speaking there. A second person can speak in a chat someone else started, so
191
+ the token is asked for again at each new user message, and the previous turn
192
+ is still captured with its own speaker's token; a spooled turn is replayed only
193
+ while the chat's token names the person who spoke it. A turn with no user
194
+ message (a wake, a routine) keeps the cached token. Tokens are kept per session, for at most 64 sessions (the least
195
+ recently used goes first), and a session's is dropped when the session is
196
+ deleted. Work that belongs to no chat (the skill mirror, and Memory's views on
197
+ a Jelly before 0.3.3) asks `token("memory")` as before, which Jelly answers
198
+ with the agent owner's token while the agent is private. A Jelly older than members (0.3.2) refuses the
199
+ `session` option; the plugin then asks as before, one token for the agent,
200
+ which on such a host is its owner's.
201
+
185
202
  **When Jelly refuses the token.** `token("memory")` rejects with a code. Jelly's
186
203
  host maps Jelly ID's `400` to `invalid_target`, `401` to `not_enrolled`, `403`
187
204
  to `access_denied`, and everything else, a `503` included, to `unavailable`, so
188
205
  the plugin cannot tell an outage from Jelly ID turning memory off. The host
189
- holds each refusal for 30 s, and so does the plugin: Jelly is not asked again
190
- until the 30 s pass.
206
+ holds each refusal for 30 s, and so does the plugin, per chat: Jelly is not
207
+ asked again for that chat until the 30 s pass.
191
208
 
192
209
  | Code | What the request does |
193
210
  |---|---|
194
- | `invalid_target`, `not_enrolled`, `unavailable` | Uses the pasted key, when one is saved. With no key, it fails with "this agent's Jelly sign-in can't be used for memory: … (`<code>`), and no memory key is saved in the plugin's settings"; a finished turn is spooled for later |
211
+ | `not_enrolled` with the detail `not_signed_in` | The person speaking in this chat has not linked a Jelly account on this host. Memory is off for this chat only: no credential is used, not the pasted key and not another chat's token; nothing is captured or spooled; each tool and command answers "Memory isn't available in this chat because the person speaking hasn't linked their Jelly account on this host." Other chats are not affected |
212
+ | `invalid_target`, `not_enrolled` (no such detail), `unavailable` | Uses the pasted key, when one is saved. With no key, it fails with "this agent's Jelly sign-in can't be used for memory: … (`<code>`), and no memory key is saved in the plugin's settings"; a finished turn is spooled for later |
195
213
  | `access_denied` | Fails: "the Jelly account is disabled or marked for deletion (access_denied); a saved memory key is not used in its place". No fallback |
196
214
 
197
215
  Why no fallback on `access_denied`: Jelly says the account behind this agent is
@@ -205,10 +223,15 @@ Jelly token or not at all, and a refused pasted key is not retried.
205
223
  asked again within 30 s)`, and the log has one warning per refusal (its code,
206
224
  never a token).
207
225
 
208
- **Accepted risk.** If a person's Jelly sign-in and pasted key belong to two
209
- different memory users, a request that falls back writes as the key's user,
210
- into that user's memory, until Jelly answers again. Paste a key from the same
211
- account you sign in to Jelly with.
226
+ **Accepted risk.** The pasted key belongs to whoever pasted it. A chat whose
227
+ token Jelly refuses with a code that falls back (`invalid_target`,
228
+ `unavailable`, or `not_enrolled` without `not_signed_in`) writes as the key's
229
+ memory user, into that user's memory, whoever is speaking in it, until Jelly
230
+ answers again. Paste a key from the same account you sign in to Jelly with, and
231
+ on an agent shared with others prefer no key at all. A speaker Jelly reports as
232
+ unlinked (`not_signed_in`) is never written as the key's user. This relies on
233
+ Jelly passing the refusal's `detail` to the plugin: a Jelly whose accessor drops
234
+ it makes that refusal a plain `not_enrolled`, which falls back.
212
235
 
213
236
  **Gateway origin:** the **Memory address** setting (`controlURL`), else the
214
237
  `url` of the identity accessor's `memory` resource, during a fallback too.
@@ -326,6 +349,30 @@ sees it:
326
349
  | `wiki.list`, `wiki.pages`, `wiki.read` | `mem_wiki` | The personal space's wikis, a wiki's pages, one page (at most 48,000 characters); never the reserved "Memory records" wiki |
327
350
  | `commitments.list` | `mem_commitments` | The personal space's commitments (the records wiki's `commitments.json`): open ones overdue first, or those closed recently |
328
351
 
352
+ **Views ask for the person who opened them (Jelly 0.3.3 and later; 0.8.3).**
353
+ A view is opened by a person on a device, not in a chat, so a view call has no
354
+ session of its own. Every method's input therefore names an optional string,
355
+ `jellySpeaker` (contract v1.5 §6.1). A Jelly of 0.3.3 or later sees it in the
356
+ declared schema and fills it with a short-lived speaker id, `view_…`, naming
357
+ the person whose device made that one call: the owner, a member with a linked
358
+ Jelly account, or a person with none. The handler takes it out of the input
359
+ before the read sees it and asks `token("memory", { session: <id> })` for that
360
+ call, so on a shared agent a member's view shows the member's own memory, and
361
+ a view still works after another plugin's turn. That token is kept for the
362
+ call only: never in the per-chat cache, never for a later call, the skill
363
+ mirror or the spool, and the id never reaches the gateway, the log or a stored
364
+ record. When Jelly answers `not_enrolled` with the detail `not_signed_in`, the
365
+ person who opened the view has not linked a Jelly account on this host: that
366
+ call uses no credential at all (not the pasted key, not the owner's or another
367
+ chat's token), sends nothing, and the view says "Memory is unavailable: you
368
+ have not linked a Jelly account on this host." Other refusals fall back as
369
+ for a chat. A Jelly before 0.3.3, or stock OpenCode, sends no `jellySpeaker`,
370
+ and a view then asks exactly as in 0.8.2. The id is optional and is never in
371
+ `required`; the schemas keep `additionalProperties: false`. Adding it asks for
372
+ nothing more: no tool, permission, resource or sign-in changes, so Jelly's
373
+ declaration refresh applies it with the release and puts nothing under
374
+ Changes to review.
375
+
329
376
  Every call is a read the tools already make, through the gateway with the
330
377
  credential chain above, so no gateway route is added for the views and the
331
378
  gateway scopes each one to the caller. A view never names a user, a space or
package/SECURITY.md CHANGED
@@ -54,7 +54,7 @@ This is the summary.
54
54
  | Credential | Lives in | Purpose |
55
55
  |---|---|---|
56
56
  | Better Auth API key | Client | Authenticates one user to the gateway; expires after `AUTH_KEY_TTL_DAYS` (90); revocable on `/account` or with `deploy/auth/scripts/revoke-user-keys.mjs` |
57
- | Jelly ID resource token | Client (a Jelly host, in memory only) | Authenticates the host's owner to the gateway for ten minutes; verified with the issuer's Ed25519 keys, audience-bound; at the gateway a refused one never falls back to another credential kind ([docs/design/adr-personal-containers.md](docs/design/adr-personal-containers.md)). The plugin's own fallback to a pasted key is a separate request with that key ([README](README.md#running-inside-jelly)) |
57
+ | Jelly ID resource token | Client (a Jelly host, in memory only) | Authenticates one person to the gateway for ten minutes: the host's owner, or (Jelly 0.3.3 members) the person speaking in the OpenCode session the plugin asked for, a token per session; verified with the issuer's Ed25519 keys, audience-bound; at the gateway a refused one never falls back to another credential kind ([docs/design/adr-personal-containers.md](docs/design/adr-personal-containers.md)). The plugin's own fallback to a pasted key is a separate request with that key, never made for a speaker Jelly reports as unlinked (`not_signed_in`) ([README](README.md#running-inside-jelly)) |
58
58
  | `CONTROL_TOKEN` | Gateway | Authenticates the gateway to control; must equal `CONTROL_SERVICE_TOKEN` |
59
59
  | `CONTROL_SERVICE_TOKEN` | Control service | Verifies the gateway's `x-control-user` assertion; never grants admin |
60
60
  | `CONTROL_ADMIN_TOKEN` | Operator/infrastructure, the exporter, the `cell-health` job | Cell and placement administration; separate from the service token |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joe-broadhead/opencode-mem",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "description": "Durable private and shared-space memory for OpenCode agents",
6
6
  "license": "MIT",
@@ -89,7 +89,11 @@
89
89
  "input": {
90
90
  "type": "object",
91
91
  "additionalProperties": false,
92
- "properties": {}
92
+ "properties": {
93
+ "jellySpeaker": {
94
+ "type": "string"
95
+ }
96
+ }
93
97
  },
94
98
  "output": {
95
99
  "type": "object",
@@ -201,7 +205,11 @@
201
205
  "input": {
202
206
  "type": "object",
203
207
  "additionalProperties": false,
204
- "properties": {}
208
+ "properties": {
209
+ "jellySpeaker": {
210
+ "type": "string"
211
+ }
212
+ }
205
213
  },
206
214
  "output": {
207
215
  "type": "object",
@@ -263,6 +271,9 @@
263
271
  "minimum": 0,
264
272
  "maximum": 50,
265
273
  "multipleOf": 50
274
+ },
275
+ "jellySpeaker": {
276
+ "type": "string"
266
277
  }
267
278
  }
268
279
  },
@@ -348,7 +359,11 @@
348
359
  "input": {
349
360
  "type": "object",
350
361
  "additionalProperties": false,
351
- "properties": {}
362
+ "properties": {
363
+ "jellySpeaker": {
364
+ "type": "string"
365
+ }
366
+ }
352
367
  },
353
368
  "output": {
354
369
  "type": "object",
@@ -402,6 +417,9 @@
402
417
  "wiki": {
403
418
  "type": "string",
404
419
  "maxLength": 200
420
+ },
421
+ "jellySpeaker": {
422
+ "type": "string"
405
423
  }
406
424
  }
407
425
  },
@@ -457,6 +475,9 @@
457
475
  "ref": {
458
476
  "type": "string",
459
477
  "maxLength": 200
478
+ },
479
+ "jellySpeaker": {
480
+ "type": "string"
460
481
  }
461
482
  }
462
483
  },
@@ -498,6 +519,9 @@
498
519
  "open",
499
520
  "closed"
500
521
  ]
522
+ },
523
+ "jellySpeaker": {
524
+ "type": "string"
501
525
  }
502
526
  }
503
527
  },
package/src/commands.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { asSession } from "./credentials.js"
1
2
  import { describeBootstrap, describeSpool, errorMessage, oneLine } from "./util.js"
2
3
 
3
4
  /**
@@ -71,11 +72,13 @@ export async function registerCommands(ctx, runtime) {
71
72
  add: (definition) =>
72
73
  target.add({
73
74
  ...definition,
74
- execute: async (input = {}) => {
75
- const reason = runtime.unavailable?.() ?? ""
76
- if (reason) return reply(input?.sessionID, reason)
77
- return definition.execute(input)
78
- },
75
+ // As the command's session: its token, and its speaker's sentence.
76
+ execute: (input = {}) =>
77
+ asSession(input?.sessionID, async () => {
78
+ const reason = (runtime.availability ? await runtime.availability() : runtime.unavailable?.()) ?? ""
79
+ if (reason) return reply(input?.sessionID, reason)
80
+ return definition.execute(input)
81
+ }),
79
82
  }),
80
83
  }
81
84
  editor.add({