@joe-broadhead/opencode-mem 0.12.4 → 0.12.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 +41 -0
- package/package.json +139 -2
- package/src/actions.js +36 -1
- package/src/collector.js +157 -11
- package/src/records.js +3 -0
- package/src/views/contracts.js +7 -1
- package/src/views/rpc.js +12 -0
- package/src/views/shape.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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.12.5] - 2026-11-18
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- A host-bound source (`history`) is collected on its own machine again. 0.12.4 compared the binding's account with
|
|
11
|
+
the raw host name, so a machine whose name differed from the account only by case or a `.local` suffix left its own
|
|
12
|
+
history alone. The plugin's own probe, run on this machine, now decides; without an answer, the account and the host
|
|
13
|
+
name are compared the way the plugin writes them (lowercase, no `.local`, punctuation as `-`).
|
|
14
|
+
- A bind request learns its account from the plugin. The probe is called without naming an account, so a plugin
|
|
15
|
+
signed in under a real account name, such as a code host's login or a tracker's workspace user, reports it instead of
|
|
16
|
+
refusing `default` with `ACCOUNT_MISMATCH`. A structured "read as" answer is adopted; a real `default` stays `default`.
|
|
17
|
+
- The daily routine sends each model call only the context linked to its units: the people and projects among the
|
|
18
|
+
units' actors or named in their text, and at most 10 current memories and the open commitments linked to them. At a
|
|
19
|
+
large space's sizes, a call's fixed part falls from about 11,000 to about 700 tokens, so a day fits its budget.
|
|
20
|
+
Memories are ranked: those linked to the batch's entities first, then by the distinctive terms they share with the
|
|
21
|
+
batch's text, then by recency. Validation still refuses an id the model invents.
|
|
22
|
+
- Greetings and acknowledgements are noise. An event is noise only when its author is a bot, a service or an
|
|
23
|
+
automation: a bot elsewhere on an event, such as a meeting's notetaker or a notifications address in Cc, is ignored,
|
|
24
|
+
and the event's items are kept.
|
|
25
|
+
- An agent, bot or service actor never becomes a person page: by the role `agent`, by an `opencode-agent:` id, by a
|
|
26
|
+
declared kind, or by an OpenCode agent's name.
|
|
27
|
+
- A model answer cut off at the output cap keeps its complete items, instead of failing the whole batch.
|
|
28
|
+
- Lint skips an item a person forgot, and counts it, instead of failing the run.
|
|
29
|
+
- `RECORDS_ACTIONS_ENABLED` accepts any act the build registers, three-part names such as `space.joinRequest.decide`
|
|
30
|
+
included. An unknown name still fails startup.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- The journal's summary says how many items the run dropped, already knew, rejected and found truncated, and how many
|
|
35
|
+
wait for review.
|
|
36
|
+
- `RECORDS_ROUTINE_BATCH_CHARS` and `RECORDS_ROUTINE_MAX_OUTPUT_TOKENS` set a call's data size and output cap. The
|
|
37
|
+
defaults are unchanged.
|
|
38
|
+
- `commitments.list` items carry `space` and `revision`, so a host can act on a listed commitment without reading it
|
|
39
|
+
again. An item stored without a version carries no `revision`, and the act reads the record's own.
|
|
40
|
+
- `memory.saveLine` saves a line from a conversation as a cited fact. It is the person's statement only when the
|
|
41
|
+
line's author is the person. The line and its citation are both checked for secrets and emails.
|
|
42
|
+
|
|
43
|
+
### Deploy
|
|
44
|
+
|
|
45
|
+
The records service needs a deploy for the routine, act and list changes. No schema change and no migration.
|
|
46
|
+
|
|
6
47
|
## [0.12.4] - 2026-11-18
|
|
7
48
|
|
|
8
49
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joe-broadhead/opencode-mem",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Durable private and shared-space memory for OpenCode agents",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1174,7 +1174,8 @@
|
|
|
1174
1174
|
"state",
|
|
1175
1175
|
"when",
|
|
1176
1176
|
"overdue",
|
|
1177
|
-
"dueToday"
|
|
1177
|
+
"dueToday",
|
|
1178
|
+
"space"
|
|
1178
1179
|
],
|
|
1179
1180
|
"properties": {
|
|
1180
1181
|
"id": {
|
|
@@ -1219,6 +1220,14 @@
|
|
|
1219
1220
|
"type": "string",
|
|
1220
1221
|
"maxLength": 80
|
|
1221
1222
|
},
|
|
1223
|
+
"space": {
|
|
1224
|
+
"type": "string",
|
|
1225
|
+
"maxLength": 128
|
|
1226
|
+
},
|
|
1227
|
+
"revision": {
|
|
1228
|
+
"type": "integer",
|
|
1229
|
+
"minimum": 1
|
|
1230
|
+
},
|
|
1222
1231
|
"closed": {
|
|
1223
1232
|
"type": "string",
|
|
1224
1233
|
"maxLength": 40
|
|
@@ -7534,6 +7543,134 @@
|
|
|
7534
7543
|
},
|
|
7535
7544
|
"tool": "mem.revise"
|
|
7536
7545
|
},
|
|
7546
|
+
{
|
|
7547
|
+
"name": "memory.saveLine",
|
|
7548
|
+
"label": "save a line to Memory",
|
|
7549
|
+
"target": "engine",
|
|
7550
|
+
"class": "chat",
|
|
7551
|
+
"confirm": "never",
|
|
7552
|
+
"views": [
|
|
7553
|
+
"memory"
|
|
7554
|
+
],
|
|
7555
|
+
"done": "Saved.",
|
|
7556
|
+
"input": {
|
|
7557
|
+
"type": "object",
|
|
7558
|
+
"additionalProperties": false,
|
|
7559
|
+
"required": [
|
|
7560
|
+
"text",
|
|
7561
|
+
"from"
|
|
7562
|
+
],
|
|
7563
|
+
"properties": {
|
|
7564
|
+
"text": {
|
|
7565
|
+
"type": "string",
|
|
7566
|
+
"maxLength": 4000
|
|
7567
|
+
},
|
|
7568
|
+
"from": {
|
|
7569
|
+
"type": "object",
|
|
7570
|
+
"additionalProperties": false,
|
|
7571
|
+
"required": [
|
|
7572
|
+
"conversation",
|
|
7573
|
+
"line"
|
|
7574
|
+
],
|
|
7575
|
+
"properties": {
|
|
7576
|
+
"conversation": {
|
|
7577
|
+
"type": "string",
|
|
7578
|
+
"maxLength": 200
|
|
7579
|
+
},
|
|
7580
|
+
"line": {
|
|
7581
|
+
"type": "string",
|
|
7582
|
+
"maxLength": 200
|
|
7583
|
+
},
|
|
7584
|
+
"author": {
|
|
7585
|
+
"type": "string",
|
|
7586
|
+
"maxLength": 200
|
|
7587
|
+
},
|
|
7588
|
+
"at": {
|
|
7589
|
+
"type": "string",
|
|
7590
|
+
"maxLength": 40
|
|
7591
|
+
}
|
|
7592
|
+
}
|
|
7593
|
+
},
|
|
7594
|
+
"space": {
|
|
7595
|
+
"type": "string",
|
|
7596
|
+
"maxLength": 128
|
|
7597
|
+
},
|
|
7598
|
+
"jellySpeaker": {
|
|
7599
|
+
"type": "string"
|
|
7600
|
+
}
|
|
7601
|
+
}
|
|
7602
|
+
},
|
|
7603
|
+
"output": {
|
|
7604
|
+
"type": "object",
|
|
7605
|
+
"required": [
|
|
7606
|
+
"ok"
|
|
7607
|
+
],
|
|
7608
|
+
"properties": {
|
|
7609
|
+
"ok": {
|
|
7610
|
+
"type": "boolean"
|
|
7611
|
+
},
|
|
7612
|
+
"id": {
|
|
7613
|
+
"type": "string",
|
|
7614
|
+
"maxLength": 200
|
|
7615
|
+
},
|
|
7616
|
+
"version": {
|
|
7617
|
+
"type": "integer",
|
|
7618
|
+
"minimum": 0
|
|
7619
|
+
},
|
|
7620
|
+
"state": {
|
|
7621
|
+
"type": "string",
|
|
7622
|
+
"maxLength": 40
|
|
7623
|
+
},
|
|
7624
|
+
"applied": {
|
|
7625
|
+
"type": "string",
|
|
7626
|
+
"maxLength": 200
|
|
7627
|
+
},
|
|
7628
|
+
"space": {
|
|
7629
|
+
"anyOf": [
|
|
7630
|
+
{
|
|
7631
|
+
"type": "string",
|
|
7632
|
+
"maxLength": 200
|
|
7633
|
+
},
|
|
7634
|
+
{
|
|
7635
|
+
"type": "object",
|
|
7636
|
+
"properties": {
|
|
7637
|
+
"id": {
|
|
7638
|
+
"type": "string",
|
|
7639
|
+
"maxLength": 200
|
|
7640
|
+
},
|
|
7641
|
+
"name": {
|
|
7642
|
+
"type": "string",
|
|
7643
|
+
"maxLength": 200
|
|
7644
|
+
}
|
|
7645
|
+
},
|
|
7646
|
+
"additionalProperties": false
|
|
7647
|
+
}
|
|
7648
|
+
]
|
|
7649
|
+
},
|
|
7650
|
+
"count": {
|
|
7651
|
+
"type": "integer",
|
|
7652
|
+
"minimum": 0
|
|
7653
|
+
},
|
|
7654
|
+
"snapshot": {
|
|
7655
|
+
"type": "string",
|
|
7656
|
+
"maxLength": 64
|
|
7657
|
+
},
|
|
7658
|
+
"erased": {
|
|
7659
|
+
"type": "integer",
|
|
7660
|
+
"minimum": 0
|
|
7661
|
+
},
|
|
7662
|
+
"code": {
|
|
7663
|
+
"type": "string",
|
|
7664
|
+
"maxLength": 40
|
|
7665
|
+
},
|
|
7666
|
+
"message": {
|
|
7667
|
+
"type": "string",
|
|
7668
|
+
"maxLength": 600
|
|
7669
|
+
}
|
|
7670
|
+
}
|
|
7671
|
+
},
|
|
7672
|
+
"tool": "mem.remember"
|
|
7673
|
+
},
|
|
7537
7674
|
{
|
|
7538
7675
|
"name": "inbox.decide",
|
|
7539
7676
|
"label": "decide what waits in your Inbox",
|
package/src/actions.js
CHANGED
|
@@ -107,7 +107,8 @@ export const HELD_FOR_CONTROL_P2 = Object.freeze(["share.transfer", "share.decid
|
|
|
107
107
|
* The two acts built for Jelly's #77 and #78, now declared: Jelly 0.4.0-beta.20
|
|
108
108
|
* carries protocol major 7 and caps a declaration at 48 actions, so 28 declared
|
|
109
109
|
* plus the four for control's P2 plus these two are 34. Nothing was merged or
|
|
110
|
-
* trimmed to make room. `memory.saveLine`
|
|
110
|
+
* trimmed to make room. `memory.saveLine` (#58 A14) is the thirty-fifth, built
|
|
111
|
+
* and declared here.
|
|
111
112
|
*/
|
|
112
113
|
export const ACTIONS_NEED_ROOM = true
|
|
113
114
|
|
|
@@ -353,6 +354,36 @@ export const ACTIONS = Object.freeze([
|
|
|
353
354
|
output: actionOutput,
|
|
354
355
|
tool: "mem.revise",
|
|
355
356
|
},
|
|
357
|
+
// A14: "Save to Memory" on one line of a Messages conversation. The click on
|
|
358
|
+
// the line is the whole confirmation (it adds to memory and removes nothing),
|
|
359
|
+
// so `chat` and `never`; the line's citation is required, because a memory
|
|
360
|
+
// the person cannot trace back is one they cannot check. It writes a `fact`
|
|
361
|
+
// and never a preference or a procedure: an instruction-shaped line must not
|
|
362
|
+
// come back as a rule.
|
|
363
|
+
{
|
|
364
|
+
name: "memory.saveLine",
|
|
365
|
+
label: "save a line to Memory",
|
|
366
|
+
target: "engine",
|
|
367
|
+
class: "chat",
|
|
368
|
+
confirm: "never",
|
|
369
|
+
views: ["memory"],
|
|
370
|
+
done: "Saved.",
|
|
371
|
+
input: actionInput(
|
|
372
|
+
{
|
|
373
|
+
text: text(4000),
|
|
374
|
+
from: {
|
|
375
|
+
type: "object",
|
|
376
|
+
additionalProperties: false,
|
|
377
|
+
required: ["conversation", "line"],
|
|
378
|
+
properties: { conversation: text(200), line: text(200), author: text(200), at: text(40) },
|
|
379
|
+
},
|
|
380
|
+
space: text(128),
|
|
381
|
+
},
|
|
382
|
+
["text", "from"],
|
|
383
|
+
),
|
|
384
|
+
output: actionOutput,
|
|
385
|
+
tool: "mem.remember",
|
|
386
|
+
},
|
|
356
387
|
// The Inbox's own decision (Jelly's answers 2 and 6): Memory's key for the
|
|
357
388
|
// item, the decisions the Inbox offers, and the version it showed. It routes
|
|
358
389
|
// to the same review and held-write decisions a review makes.
|
|
@@ -852,6 +883,10 @@ const CODES = Object.freeze({
|
|
|
852
883
|
invalid_id: "NOT_FOUND",
|
|
853
884
|
team_delete_console_only: "NEEDS_APPROVAL",
|
|
854
885
|
page_lines_kept: "NEEDS_APPROVAL",
|
|
886
|
+
// What may not be stored (#58 A14, and any act whose words records refuses):
|
|
887
|
+
// a secret, a person's email address, a home path; and text a person forgot.
|
|
888
|
+
refused: "NOT_STORED",
|
|
889
|
+
forgotten: "FORGOTTEN",
|
|
855
890
|
})
|
|
856
891
|
|
|
857
892
|
/** What this module refuses in its own words, and the code the page shows. */
|
package/src/collector.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isSourceName } from "./source-ids.js"
|
|
|
4
4
|
import { ACCOUNT_NAME, DEFAULT_EVERY_MINUTES, contractRefusal, hostBoundSource, resolveDeclaredSource, rpcDefinition, sourceAllowRules, sourceEntry } from "./sources.js"
|
|
5
5
|
import { acceptAnswer, probe, read } from "./plugins/source-contract/vendor/read.js"
|
|
6
6
|
import { isBrokerAnswer, sourceReader } from "./plugins/source-contract/vendor/broker-client.js"
|
|
7
|
-
import { probeResultProblems } from "./plugins/source-contract/vendor/events.js"
|
|
7
|
+
import { canonicalCode, parseSourceError, probeResultProblems } from "./plugins/source-contract/vendor/events.js"
|
|
8
8
|
import { cursorAdvance, failureAction, failureFromError } from "./plugins/source-contract/policy.js"
|
|
9
9
|
import { memoryResourceAvailable } from "./credentials.js"
|
|
10
10
|
|
|
@@ -134,6 +134,25 @@ export function isAccountName(value) {
|
|
|
134
134
|
return typeof value === "string" && ACCOUNT_NAME.test(value)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* The account a plugin's own structured refusal says to read as, or null. Only
|
|
139
|
+
* an `ACCOUNT_MISMATCH` source error whose own `next` (or `what`) says
|
|
140
|
+
* `read as "<account>"` names one: never free text that does not parse, and
|
|
141
|
+
* never another code (0.12.5).
|
|
142
|
+
*
|
|
143
|
+
* @param {unknown} error
|
|
144
|
+
* @returns {string | null}
|
|
145
|
+
*/
|
|
146
|
+
export function suggestedAccount(error) {
|
|
147
|
+
const read = parseSourceError(error)
|
|
148
|
+
if (!read || (canonicalCode(read.code) ?? read.code) !== "ACCOUNT_MISMATCH") return null
|
|
149
|
+
for (const text of [read.next, read.what]) {
|
|
150
|
+
const match = /read as "([^"]{1,128})"/i.exec(String(text ?? ""))
|
|
151
|
+
if (match && isAccountName(match[1])) return match[1]
|
|
152
|
+
}
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
137
156
|
function bindingKey(binding) {
|
|
138
157
|
return `${binding.source}\u0000${binding.account || DEFAULT_ACCOUNT}`
|
|
139
158
|
}
|
|
@@ -165,12 +184,36 @@ export function collectableSources(sources, { only } = {}) {
|
|
|
165
184
|
return [...seen.values()].sort((a, b) => bindingKey(a).localeCompare(bindingKey(b)))
|
|
166
185
|
}
|
|
167
186
|
|
|
187
|
+
/**
|
|
188
|
+
* The name a plugin gives a machine: lowercase, without a trailing `.local`, and
|
|
189
|
+
* slugged — the history plugin's `identityOf` does
|
|
190
|
+
* `slug(host.replace(/\.local\.?$/i, ""), 63)`, so `Joes-MacBook-Air.local`
|
|
191
|
+
* names the account `joes-macbook-air` (0.12.4).
|
|
192
|
+
*
|
|
193
|
+
* @param {string | null | undefined} name
|
|
194
|
+
* @returns {string}
|
|
195
|
+
*/
|
|
196
|
+
export function machineSlug(name) {
|
|
197
|
+
return String(name ?? "")
|
|
198
|
+
.trim()
|
|
199
|
+
.toLowerCase()
|
|
200
|
+
.replace(/\.local\.?$/, "")
|
|
201
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
202
|
+
.replace(/^-+|-+$/g, "")
|
|
203
|
+
.slice(0, 63)
|
|
204
|
+
}
|
|
205
|
+
|
|
168
206
|
/**
|
|
169
207
|
* The machine a host-bound binding belongs to, when it is not this one, or
|
|
170
208
|
* null. A host-bound source's account names the machine whose own files it
|
|
171
209
|
* reads (src/sources.js `hostBoundSource`): another machine's collector never
|
|
172
210
|
* reads it, and never reports on it, so it cannot turn the binding failing
|
|
173
|
-
* (0.12.3).
|
|
211
|
+
* (0.12.3).
|
|
212
|
+
*
|
|
213
|
+
* **Names are compared the way the plugin names them** (0.12.4): a case or
|
|
214
|
+
* `.local` difference is never another machine. Live at 00:14Z on 2026-11-18,
|
|
215
|
+
* the owner's own `history:joes-macbook-air` was left alone on
|
|
216
|
+
* `Joes-MacBook-Air.local`, so it was never collected.
|
|
174
217
|
*
|
|
175
218
|
* @param {{ source?: string, account?: string }} binding
|
|
176
219
|
* @param {string | null | undefined} host this collector's machine
|
|
@@ -180,8 +223,8 @@ export function foreignHostSource(binding, host) {
|
|
|
180
223
|
if (!hostBoundSource(binding?.source)) return null
|
|
181
224
|
const named = String(binding?.account ?? "").trim()
|
|
182
225
|
const here = String(host ?? "").trim()
|
|
183
|
-
if (!named || !here
|
|
184
|
-
return named
|
|
226
|
+
if (!named || !here) return null
|
|
227
|
+
return machineSlug(named) === machineSlug(here) ? null : named
|
|
185
228
|
}
|
|
186
229
|
|
|
187
230
|
/** The host's tools RPC has no plugin registered under that id right now: the plugin is starting, reloading or unloaded. */
|
|
@@ -189,6 +232,56 @@ function rpcUnavailable(error) {
|
|
|
189
232
|
return error?.type === "rpc.unavailable" || /^RPC is unavailable\b/.test(String(error?.message ?? ""))
|
|
190
233
|
}
|
|
191
234
|
|
|
235
|
+
/**
|
|
236
|
+
* The account the source's own probe names on this machine, or null when it
|
|
237
|
+
* answers nothing (its RPC is not registered, or the read failed). A probe is a
|
|
238
|
+
* read of the source, so a failure here is not the binding's failure and is not
|
|
239
|
+
* reported as one (0.12.4).
|
|
240
|
+
*
|
|
241
|
+
* @param {{ source: string, account?: string }} binding
|
|
242
|
+
* @param {{ lister: any, prober: any, sessionID?: string | ((binding: object) => Promise<string>), log?: any }} where
|
|
243
|
+
* @returns {Promise<string | null>}
|
|
244
|
+
*/
|
|
245
|
+
async function probedMachineAccount(binding, { lister, prober, sessionID, log }) {
|
|
246
|
+
try {
|
|
247
|
+
const entry = resolveDeclaredSource(binding.source).entry ?? sourceEntry(binding.source)
|
|
248
|
+
if (!entry) return null
|
|
249
|
+
const session = typeof sessionID === "function" ? await sessionID(binding) : sessionID
|
|
250
|
+
const answer = entry.contract === "sources"
|
|
251
|
+
? prober
|
|
252
|
+
? await prober(entry.source, { account: binding.account }, session)
|
|
253
|
+
: null
|
|
254
|
+
: lister
|
|
255
|
+
? await lister(binding.source, probeInput(entry, binding.account), session, null)
|
|
256
|
+
: null
|
|
257
|
+
const named = answer?.account ?? answer?.owner?.account
|
|
258
|
+
return typeof named === "string" && named.trim() ? named.trim() : null
|
|
259
|
+
} catch (error) {
|
|
260
|
+
log?.debug?.("a host-bound binding's probe answered nothing", { source: binding?.source, error: errorMessage(error) })
|
|
261
|
+
return null
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Is a host-bound binding another machine's? **The plugin's own probe, run on
|
|
267
|
+
* this machine, wins over the host name** (0.12.4): it names the account this
|
|
268
|
+
* machine's plugin reads, so a binding of that account is this machine's
|
|
269
|
+
* whatever the host is called, and a probe naming another account leaves the
|
|
270
|
+
* binding alone even when the name matches. With no probe answer, the name is
|
|
271
|
+
* compared the way the plugin writes it (`machineSlug`), so a case or `.local`
|
|
272
|
+
* difference is never another machine.
|
|
273
|
+
*
|
|
274
|
+
* @returns {Promise<string | null>} the machine the binding names, when it is not this one
|
|
275
|
+
*/
|
|
276
|
+
async function foreignHostBinding(binding, host, { lister, prober, sessionID, log }) {
|
|
277
|
+
if (!hostBoundSource(binding?.source)) return null
|
|
278
|
+
const named = String(binding?.account ?? "").trim()
|
|
279
|
+
if (!named) return null
|
|
280
|
+
const probed = await probedMachineAccount(binding, { lister, prober, sessionID, log })
|
|
281
|
+
if (probed) return machineSlug(probed) === machineSlug(named) ? null : named
|
|
282
|
+
return foreignHostSource(binding, host)
|
|
283
|
+
}
|
|
284
|
+
|
|
192
285
|
/**
|
|
193
286
|
* Mark a result whose failure is the host's RPC, not the binding's: it keeps
|
|
194
287
|
* its last good state in the store (nothing is reported for it), and the run
|
|
@@ -800,7 +893,38 @@ export async function probeSource({ entry, ctx, sessionID, account, timeoutMs =
|
|
|
800
893
|
},
|
|
801
894
|
}
|
|
802
895
|
const installed = { package: entry.package, version: entry.version ?? "0.0.0", directory: "", sources: entry.descriptor, hash: entry.descriptorHash }
|
|
803
|
-
|
|
896
|
+
// **No account named: the probe learns it** (0.12.5). The contract's own
|
|
897
|
+
// `probe` always names the account it expects and refuses an answer for
|
|
898
|
+
// another, which is exactly what a bind request does not yet know: live at
|
|
899
|
+
// 00:43Z on 2026-11-18, Memory named `default` and github, granola and linear
|
|
900
|
+
// each answered ACCOUNT_MISMATCH. So the method is called with the source's
|
|
901
|
+
// declared input alone, and its answer is checked by the contract's own
|
|
902
|
+
// `probeResultProblems`, which needs no expected account.
|
|
903
|
+
if (account === undefined || account === null) {
|
|
904
|
+
const client = ctx.rpc({ id: entry.rpc, events: {}, methods })
|
|
905
|
+
if (typeof client?.probe !== "function") throw missingMethod("probe")
|
|
906
|
+
const name = typeof entry.item.input?.source === "string" ? { source: entry.item.input.source } : {}
|
|
907
|
+
let answer
|
|
908
|
+
try {
|
|
909
|
+
answer = await boundedSourceCall(client, "probe", name, sessionID, timeoutMs)
|
|
910
|
+
} catch (error) {
|
|
911
|
+
if (error?.type === "rpc.method_not_found") throw missingMethod("probe")
|
|
912
|
+
throw error
|
|
913
|
+
}
|
|
914
|
+
if (answer?.owner === undefined || answer?.owner === null) {
|
|
915
|
+
const error = new Error(`NEEDS_SIGN_IN: ${oneLine(String(entry.source), 40)} is not signed in. Next step: sign the plugin in to the account you mean.`)
|
|
916
|
+
error.code = "NEEDS_SIGN_IN"
|
|
917
|
+
throw error
|
|
918
|
+
}
|
|
919
|
+
const problems = probeResultProblems(answer, name)
|
|
920
|
+
if (problems.length > 0) {
|
|
921
|
+
const error = new Error(`SCHEMA_VIOLATION: ${entry.source}'s probe answer is not the contract's: ${problems[0]} Next step: report it to the plugin's maintainers.`)
|
|
922
|
+
error.code = "SCHEMA_VIOLATION"
|
|
923
|
+
throw error
|
|
924
|
+
}
|
|
925
|
+
return answer
|
|
926
|
+
}
|
|
927
|
+
const outcome = await probe(host, { installed, source: entry.source, account, identityOperations: ["probe"] })
|
|
804
928
|
if (!outcome.ok) {
|
|
805
929
|
const error = new Error(outcome.failure.message)
|
|
806
930
|
error.code = outcome.failure.code
|
|
@@ -809,7 +933,7 @@ export async function probeSource({ entry, ctx, sessionID, account, timeoutMs =
|
|
|
809
933
|
}
|
|
810
934
|
// The contract's one probe check, called by the consumer too: the answer names the source and the account,
|
|
811
935
|
// carries owner { id, label } (never null) and trust: "untrusted", and reads no content (D8, D230).
|
|
812
|
-
const problems = probeResultProblems(outcome.answer, { ...(entry.pageSource ? { source: entry.pageSource } : {}), account
|
|
936
|
+
const problems = probeResultProblems(outcome.answer, { ...(entry.pageSource ? { source: entry.pageSource } : {}), account })
|
|
813
937
|
if (problems.length > 0) {
|
|
814
938
|
const error = new Error(`SCHEMA_VIOLATION: ${entry.source}'s probe answer is not the contract's: ${problems[0]} Next step: report it to the plugin's maintainers.`)
|
|
815
939
|
error.code = "SCHEMA_VIOLATION"
|
|
@@ -825,7 +949,9 @@ export function hostSourceProber(ctx) {
|
|
|
825
949
|
const entry = sourceEntry(source)
|
|
826
950
|
if (!entry) throw new Error(`${oneLine(source, 40)} is not a source Memory knows`)
|
|
827
951
|
if (entry.contract !== "sources") throw new Error(`${oneLine(source, 40)} is read through its events_list, not probed`)
|
|
828
|
-
|
|
952
|
+
// An account is named only when the caller names one: a bind request asks the
|
|
953
|
+
// plugin which account it is signed in to (0.12.5).
|
|
954
|
+
return probeSource({ entry, ctx, sessionID, ...(input?.account ? { account: input.account } : {}) })
|
|
829
955
|
}
|
|
830
956
|
}
|
|
831
957
|
|
|
@@ -921,8 +1047,9 @@ export function createCollector({ scheduler = null, lister = null, prober = null
|
|
|
921
1047
|
lister?.resetBrokerTick?.()
|
|
922
1048
|
for (const binding of collectableSources(sources, { only })) {
|
|
923
1049
|
// Another machine's host-bound binding: not read, not reported, and so
|
|
924
|
-
// never turned failing here (0.12.3). The row says whose it is.
|
|
925
|
-
|
|
1050
|
+
// never turned failing here (0.12.3). The row says whose it is. The
|
|
1051
|
+
// plugin's probe on this machine decides first (0.12.4).
|
|
1052
|
+
const elsewhere = await foreignHostBinding(binding, host, { lister, prober, sessionID, log })
|
|
926
1053
|
if (elsewhere) {
|
|
927
1054
|
results.push({ ...binding, pages: 0, accepted: 0, duplicates: 0, refused: 0, more: false, otherHost: elsewhere, done: true })
|
|
928
1055
|
continue
|
|
@@ -1168,8 +1295,24 @@ export function createCollector({ scheduler = null, lister = null, prober = null
|
|
|
1168
1295
|
// A declared source has the contract's `probe` (D11); the owner-only
|
|
1169
1296
|
// `events_list({ limit: 0 })` page is the previous contract's, and only
|
|
1170
1297
|
// for a plugin that declares no source.
|
|
1298
|
+
// **A declared source's probe is not told an account** (0.12.5): the
|
|
1299
|
+
// plugin answers the account it is signed in to. Live at 00:43Z on
|
|
1300
|
+
// 2026-11-18, Memory named `default`, and github, granola and linear
|
|
1301
|
+
// each answered ACCOUNT_MISMATCH, so none of the three could bind. A
|
|
1302
|
+
// plugin that still refuses is asked once with the account its own
|
|
1303
|
+
// structured answer names, and nothing is adopted from unparsed text.
|
|
1304
|
+
const ask = (input) => (prober ? prober(reading.source, input, session) : Promise.reject(new Error("this host gives plugins no tools RPC, so a source cannot be probed")))
|
|
1305
|
+
const declaredAnswer = async () => {
|
|
1306
|
+
try {
|
|
1307
|
+
return await ask({})
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
const suggested = suggestedAccount(error)
|
|
1310
|
+
if (!suggested) throw error
|
|
1311
|
+
return ask({ account: suggested })
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1171
1314
|
const answer = reading.contract === "sources"
|
|
1172
|
-
? await (
|
|
1315
|
+
? await declaredAnswer()
|
|
1173
1316
|
: await (lister ? lister(asked.source, probeInput(reading, asked.account), session) : Promise.reject(new Error("this host gives plugins no way to call another plugin's events_list")))
|
|
1174
1317
|
// A name the declaration has replaced says which source binds instead:
|
|
1175
1318
|
// the store refuses a retired name, so the person needs the one to use.
|
|
@@ -1181,7 +1324,10 @@ export function createCollector({ scheduler = null, lister = null, prober = null
|
|
|
1181
1324
|
source: asked.source,
|
|
1182
1325
|
account: asked.account,
|
|
1183
1326
|
owner,
|
|
1184
|
-
|
|
1327
|
+
// The account the probe names is the binding's account: the store
|
|
1328
|
+
// confirms it, and a page of a declared source always names it
|
|
1329
|
+
// (0.12.3). A name Memory cannot hold is not reported.
|
|
1330
|
+
...(isAccountName(answer.account) ? { reported_account: answer.account } : {}),
|
|
1185
1331
|
// The installed declaration's digest, read from disk: a re-consent records the digest the installed
|
|
1186
1332
|
// package has now, so jelly never refuses a read made under the old one. Only for the declared id
|
|
1187
1333
|
// itself: a consent recorded under a retired name never reads that declaration.
|
package/src/records.js
CHANGED
|
@@ -109,6 +109,9 @@ export function itemOfRecord(record) {
|
|
|
109
109
|
link: fields.link,
|
|
110
110
|
created: fields.created_day ?? dayOf(record?.created),
|
|
111
111
|
updated: dayOf(record?.updated),
|
|
112
|
+
// The version a change must name, as the commitment acts take it (#97): a
|
|
113
|
+
// list answer carries it, so a control needs no second read of the item.
|
|
114
|
+
revision: Number.isSafeInteger(Number(record?.version)) && Number(record.version) > 0 ? Number(record.version) : undefined,
|
|
112
115
|
closed: fields.closed_at ? dayOf(fields.closed_at) : undefined,
|
|
113
116
|
session: record?.source?.session,
|
|
114
117
|
legacy_id: fields.legacy_id,
|
package/src/views/contracts.js
CHANGED
|
@@ -655,7 +655,9 @@ const commitmentsOutput = {
|
|
|
655
655
|
items: {
|
|
656
656
|
type: "object",
|
|
657
657
|
additionalProperties: false,
|
|
658
|
-
required:
|
|
658
|
+
// `revision` is not required: a read that cannot name a version leaves
|
|
659
|
+
// it out, and the act then reads the record's own (0.12.5 review, L).
|
|
660
|
+
required: ["id", "what", "owner", "state", "when", "overdue", "dueToday", "space"],
|
|
659
661
|
properties: {
|
|
660
662
|
id,
|
|
661
663
|
what: line(300),
|
|
@@ -670,6 +672,10 @@ const commitmentsOutput = {
|
|
|
670
672
|
dueToday: { type: "boolean" },
|
|
671
673
|
trigger: line(200),
|
|
672
674
|
project: line(80),
|
|
675
|
+
/** The space the item is in, as its acts take it (`commitment.done` and the rest). */
|
|
676
|
+
space: line(128),
|
|
677
|
+
/** The item's version, as its acts take it: a press names the one the person saw. */
|
|
678
|
+
revision: { type: "integer", minimum: 1 },
|
|
673
679
|
/** The day it was closed, as "Tue 3 Nov"; closed items only. */
|
|
674
680
|
closed: line(40),
|
|
675
681
|
},
|
package/src/views/rpc.js
CHANGED
|
@@ -418,6 +418,10 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
418
418
|
* The person's commitments, from their personal space's records wiki: open
|
|
419
419
|
* ones overdue first, or closed ones newest first. Only the caller's own
|
|
420
420
|
* space is read; a view can change nothing (closing one opens the agent).
|
|
421
|
+
*
|
|
422
|
+
* Each item carries the two fields every commitment act takes (`space` and
|
|
423
|
+
* `revision`), so a control acts on what the list answered without reading
|
|
424
|
+
* the item again (#97).
|
|
421
425
|
*/
|
|
422
426
|
async function commitmentsList(input) {
|
|
423
427
|
await available()
|
|
@@ -426,6 +430,8 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
426
430
|
const records = (await runtime.records.read(first.scope)).records
|
|
427
431
|
const zone = runtime.clock.zone
|
|
428
432
|
const today = dayIn(runtime.clock.now(), zone)
|
|
433
|
+
// The space this list read, as the acts take it, and its name for the row.
|
|
434
|
+
const here = clip(idOf(first.context?.space_id) || "", 128)
|
|
429
435
|
let items = filterItems(records.items, { state: state === "open" ? "open" : "all" }, zone)
|
|
430
436
|
if (state === "closed") {
|
|
431
437
|
items = items
|
|
@@ -447,6 +453,12 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
447
453
|
dueToday: item.state === "open" && day === today,
|
|
448
454
|
...(item.trigger ? { trigger: clip(item.trigger, 200) } : {}),
|
|
449
455
|
...(item.project ? { project: clip(item.project, 80) } : {}),
|
|
456
|
+
space: here,
|
|
457
|
+
// The version the item's acts take, and only when the read named one:
|
|
458
|
+
// a list that could not name a version leaves it out (the act then
|
|
459
|
+
// reads the record's own), rather than claiming 1, which would make
|
|
460
|
+
// the press stale before it started (0.12.5 review, L).
|
|
461
|
+
...(Number.isSafeInteger(item.revision) && item.revision > 0 ? { revision: item.revision } : {}),
|
|
450
462
|
...(item.state !== "open" && (item.closed || item.updated) ? { closed: clip(formatDay(item.closed ?? item.updated), 40) } : {}),
|
|
451
463
|
}
|
|
452
464
|
}),
|
package/src/views/shape.js
CHANGED
|
@@ -101,13 +101,23 @@ export async function mapLimit(list, limit, work) {
|
|
|
101
101
|
return out
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* A where-it-came-from line for a record's `source` ({ event, turn, session,
|
|
106
|
+
* routine, record, url }), or "". A saved line's citation (#58 A14) is the one
|
|
107
|
+
* pair: `conversation <id> line <id>`, so a memory says which conversation and
|
|
108
|
+
* which line it was taken from.
|
|
109
|
+
*/
|
|
105
110
|
export function sourceLabel(source) {
|
|
106
111
|
if (!source || typeof source !== "object") return ""
|
|
107
112
|
for (const key of ["event", "turn", "session", "routine", "record"]) {
|
|
108
113
|
const ref = typeof source[key] === "string" ? source[key].trim() : ""
|
|
109
114
|
if (ref && /^[\w.:@/-]{1,120}$/.test(ref)) return `${key} ${ref}`
|
|
110
115
|
}
|
|
116
|
+
const conversation = typeof source.conversation === "string" ? source.conversation.trim() : ""
|
|
117
|
+
const line = typeof source.line === "string" ? source.line.trim() : ""
|
|
118
|
+
const named = (value) => Boolean(value) && /^[\w.:@/-]{1,120}$/.test(value)
|
|
119
|
+
if (named(conversation)) return named(line) ? `conversation ${conversation} line ${line}` : `conversation ${conversation}`
|
|
120
|
+
if (named(line)) return `line ${line}`
|
|
111
121
|
const url = typeof source.url === "string" ? source.url.trim() : ""
|
|
112
122
|
return /^https?:\/\/[^\s<>"']{1,190}$/.test(url) ? `url ${url}` : ""
|
|
113
123
|
}
|