@joe-broadhead/opencode-mem 0.12.1 → 0.12.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/package.json +1 -1
  3. package/src/collector-service.js +1 -1
  4. package/src/collector.js +75 -21
  5. package/src/plugins/locate.js +15 -4
  6. package/src/plugins/source-contract/index.js +2 -2
  7. package/src/plugins/source-contract/policy.js +3 -7
  8. package/src/plugins/source-contract/vendor/PROVENANCE.json +8 -8
  9. package/src/plugins/source-contract/vendor/RELEASE-SHA256SUMS +3 -3
  10. package/src/plugins/source-contract/vendor/RELEASE.json +9 -9
  11. package/src/plugins/source-contract/vendor/SHA256SUMS +28 -28
  12. package/src/plugins/source-contract/vendor/broker-client.js +14 -14
  13. package/src/plugins/source-contract/vendor/chunks/{chunk-Q3RQA5J2.js → chunk-77MJETEE.js} +9 -9
  14. package/src/plugins/source-contract/vendor/chunks/{chunk-6HDIB2SA.js → chunk-BOUWB5UP.js} +2 -2
  15. package/src/plugins/source-contract/vendor/chunks/{chunk-KYWBTAF4.js → chunk-EHIOPXPL.js} +9 -8
  16. package/src/plugins/source-contract/vendor/chunks/{chunk-RYNKNCPP.js → chunk-F4K2Y64D.js} +1 -1
  17. package/src/plugins/source-contract/vendor/chunks/{chunk-RRUAIQ4I.js → chunk-HVBOAYBO.js} +43 -9
  18. package/src/plugins/source-contract/vendor/chunks/{chunk-ELPJD3ND.js → chunk-IL565TRX.js} +1 -1
  19. package/src/plugins/source-contract/vendor/chunks/{chunk-W5SHR7DQ.js → chunk-JUWIMDGF.js} +2 -2
  20. package/src/{vendor/source-contract/chunks/chunk-I2RXJJJM.js → plugins/source-contract/vendor/chunks/chunk-NUEROZNU.js} +1 -1
  21. package/src/plugins/source-contract/vendor/chunks/{chunk-3M5PAKSS.js → chunk-OZMX7VR7.js} +22 -2
  22. package/src/plugins/source-contract/vendor/chunks/{chunk-HLVAKAYG.js → chunk-T4QM7B3S.js} +1 -1
  23. package/src/plugins/source-contract/vendor/chunks/{chunk-KWEWSZ4V.js → chunk-X6XP7YK2.js} +24 -4
  24. package/src/plugins/source-contract/vendor/chunks/{chunk-4ERCA4TK.js → chunk-XVA6H6OO.js} +2 -2
  25. package/src/plugins/source-contract/vendor/chunks/{chunk-ZUKF7P6U.js → chunk-YH323FAZ.js} +51 -10
  26. package/src/plugins/source-contract/vendor/cursor.js +3 -3
  27. package/src/plugins/source-contract/vendor/descriptor.js +11 -11
  28. package/src/plugins/source-contract/vendor/events.js +9 -5
  29. package/src/plugins/source-contract/vendor/index.js +3 -3
  30. package/src/plugins/source-contract/vendor/params.js +3 -3
  31. package/src/plugins/source-contract/vendor/permission.js +9 -3
  32. package/src/plugins/source-contract/vendor/pick.js +5 -5
  33. package/src/plugins/source-contract/vendor/read.js +14 -14
  34. package/src/plugins/source-contract/vendor/registry.js +4 -4
  35. package/src/plugins/source-contract/vendor/schema.js +8 -8
  36. package/src/plugins/source-contract/vendor/schemas/sources.json +158 -4
  37. package/src/plugins/source-contract/vendor/schemas.js +9 -9
  38. package/src/plugins/source-contract/vendor/tools-rpc.js +4 -4
  39. package/src/sources.js +44 -0
  40. package/src/tools/spaces.js +54 -18
  41. package/src/vendor/source-contract/README.md +6 -5
  42. package/src/vendor/source-contract/VENDOR.json +46 -46
  43. package/src/vendor/source-contract/chunks/{chunk-6HDIB2SA.js → chunk-BOUWB5UP.js} +2 -2
  44. package/src/vendor/source-contract/chunks/{chunk-W5SHR7DQ.js → chunk-JUWIMDGF.js} +2 -2
  45. package/src/{plugins/source-contract/vendor/chunks/chunk-I2RXJJJM.js → vendor/source-contract/chunks/chunk-NUEROZNU.js} +1 -1
  46. package/src/vendor/source-contract/chunks/{chunk-3M5PAKSS.js → chunk-OZMX7VR7.js} +22 -2
  47. package/src/vendor/source-contract/chunks/{chunk-HLVAKAYG.js → chunk-T4QM7B3S.js} +1 -1
  48. package/src/vendor/source-contract/chunks/{chunk-KWEWSZ4V.js → chunk-X6XP7YK2.js} +24 -4
  49. package/src/vendor/source-contract/chunks/{chunk-ZUKF7P6U.js → chunk-YH323FAZ.js} +51 -10
  50. package/src/vendor/source-contract/cursor.js +3 -3
  51. package/src/vendor/source-contract/events.js +9 -5
  52. package/src/vendor/source-contract/registry.js +4 -4
  53. package/src/vendor/source-contract/tools-rpc.js +4 -4
@@ -1,4 +1,4 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  MAX_PICK_PATHS,
4
4
  MAX_PICK_PATH_LENGTH,
@@ -7,10 +7,10 @@ import {
7
7
  pick,
8
8
  pickProblems,
9
9
  pickProblemsForOutput
10
- } from "./chunks/chunk-4ERCA4TK.js";
11
- import "./chunks/chunk-6HDIB2SA.js";
12
- import "./chunks/chunk-W5SHR7DQ.js";
13
- import "./chunks/chunk-HLVAKAYG.js";
10
+ } from "./chunks/chunk-XVA6H6OO.js";
11
+ import "./chunks/chunk-BOUWB5UP.js";
12
+ import "./chunks/chunk-JUWIMDGF.js";
13
+ import "./chunks/chunk-T4QM7B3S.js";
14
14
  export {
15
15
  MAX_PICK_PATHS,
16
16
  MAX_PICK_PATH_LENGTH,
@@ -1,4 +1,4 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  acceptAnswer,
4
4
  checkReadRequest,
@@ -6,19 +6,19 @@ import {
6
6
  probe,
7
7
  read,
8
8
  readDetail
9
- } from "./chunks/chunk-Q3RQA5J2.js";
10
- import "./chunks/chunk-KYWBTAF4.js";
11
- import "./chunks/chunk-RRUAIQ4I.js";
12
- import "./chunks/chunk-KWEWSZ4V.js";
13
- import "./chunks/chunk-ELPJD3ND.js";
14
- import "./chunks/chunk-ZUKF7P6U.js";
15
- import "./chunks/chunk-I2RXJJJM.js";
16
- import "./chunks/chunk-RYNKNCPP.js";
17
- import "./chunks/chunk-3M5PAKSS.js";
18
- import "./chunks/chunk-4ERCA4TK.js";
19
- import "./chunks/chunk-6HDIB2SA.js";
20
- import "./chunks/chunk-W5SHR7DQ.js";
21
- import "./chunks/chunk-HLVAKAYG.js";
9
+ } from "./chunks/chunk-77MJETEE.js";
10
+ import "./chunks/chunk-EHIOPXPL.js";
11
+ import "./chunks/chunk-HVBOAYBO.js";
12
+ import "./chunks/chunk-X6XP7YK2.js";
13
+ import "./chunks/chunk-IL565TRX.js";
14
+ import "./chunks/chunk-YH323FAZ.js";
15
+ import "./chunks/chunk-NUEROZNU.js";
16
+ import "./chunks/chunk-F4K2Y64D.js";
17
+ import "./chunks/chunk-OZMX7VR7.js";
18
+ import "./chunks/chunk-XVA6H6OO.js";
19
+ import "./chunks/chunk-BOUWB5UP.js";
20
+ import "./chunks/chunk-JUWIMDGF.js";
21
+ import "./chunks/chunk-T4QM7B3S.js";
22
22
  export {
23
23
  acceptAnswer,
24
24
  checkReadRequest,
@@ -1,4 +1,4 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  EXTENSION_OUTPUT,
4
4
  IMAGE_DATA_URI_MAX,
@@ -8,9 +8,9 @@ import {
8
8
  isExtensionOutput,
9
9
  isOutputName,
10
10
  outputValidator
11
- } from "./chunks/chunk-6HDIB2SA.js";
12
- import "./chunks/chunk-W5SHR7DQ.js";
13
- import "./chunks/chunk-HLVAKAYG.js";
11
+ } from "./chunks/chunk-BOUWB5UP.js";
12
+ import "./chunks/chunk-JUWIMDGF.js";
13
+ import "./chunks/chunk-T4QM7B3S.js";
14
14
  export {
15
15
  EXTENSION_OUTPUT,
16
16
  IMAGE_DATA_URI_MAX,
@@ -1,15 +1,15 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  MAX_BYTES_DEFAULT,
4
4
  MAX_BYTES_LIMIT,
5
5
  SOURCES_SCHEMA
6
- } from "./chunks/chunk-RRUAIQ4I.js";
7
- import "./chunks/chunk-KWEWSZ4V.js";
8
- import "./chunks/chunk-ZUKF7P6U.js";
9
- import "./chunks/chunk-I2RXJJJM.js";
10
- import "./chunks/chunk-3M5PAKSS.js";
11
- import "./chunks/chunk-W5SHR7DQ.js";
12
- import "./chunks/chunk-HLVAKAYG.js";
6
+ } from "./chunks/chunk-HVBOAYBO.js";
7
+ import "./chunks/chunk-X6XP7YK2.js";
8
+ import "./chunks/chunk-YH323FAZ.js";
9
+ import "./chunks/chunk-NUEROZNU.js";
10
+ import "./chunks/chunk-OZMX7VR7.js";
11
+ import "./chunks/chunk-JUWIMDGF.js";
12
+ import "./chunks/chunk-T4QM7B3S.js";
13
13
  export {
14
14
  MAX_BYTES_DEFAULT,
15
15
  MAX_BYTES_LIMIT,
@@ -56,6 +56,12 @@
56
56
  "named": {
57
57
  "type": "boolean",
58
58
  "description": "True when the source reads more than one account, so a read names one."
59
+ },
60
+ "server": {
61
+ "description": "For a plugin with one MCP server per account (#30, item 9): the server a named account's MCP tools live on, with {account} for the account, such as plaud-{account}. A bare operation is then <server>_<operation> for an account other than default; the default account keeps the namespace.",
62
+ "type": "string",
63
+ "maxLength": 64,
64
+ "pattern": "^[a-z][a-z0-9_-]*\\{account\\}[a-z0-9_-]*$"
59
65
  }
60
66
  },
61
67
  "required": [
@@ -160,6 +166,17 @@
160
166
  "usd": {
161
167
  "type": "number",
162
168
  "minimum": 0
169
+ },
170
+ "conditions": {
171
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
172
+ "type": "string",
173
+ "minLength": 1,
174
+ "maxLength": 200
175
+ },
176
+ "min": {
177
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
178
+ "type": "number",
179
+ "minimum": 0
163
180
  }
164
181
  },
165
182
  "required": [
@@ -181,6 +198,17 @@
181
198
  "usd": {
182
199
  "type": "number",
183
200
  "minimum": 0
201
+ },
202
+ "conditions": {
203
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
204
+ "type": "string",
205
+ "minLength": 1,
206
+ "maxLength": 200
207
+ },
208
+ "min": {
209
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
210
+ "type": "number",
211
+ "minimum": 0
184
212
  }
185
213
  },
186
214
  "required": [
@@ -218,6 +246,17 @@
218
246
  "usd": {
219
247
  "type": "number",
220
248
  "minimum": 0
249
+ },
250
+ "conditions": {
251
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
252
+ "type": "string",
253
+ "minLength": 1,
254
+ "maxLength": 200
255
+ },
256
+ "min": {
257
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
258
+ "type": "number",
259
+ "minimum": 0
221
260
  }
222
261
  },
223
262
  "required": [
@@ -239,6 +278,17 @@
239
278
  "usd": {
240
279
  "type": "number",
241
280
  "minimum": 0
281
+ },
282
+ "conditions": {
283
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
284
+ "type": "string",
285
+ "minLength": 1,
286
+ "maxLength": 200
287
+ },
288
+ "min": {
289
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
290
+ "type": "number",
291
+ "minimum": 0
242
292
  }
243
293
  },
244
294
  "required": [
@@ -357,8 +407,7 @@
357
407
  "not": {}
358
408
  },
359
409
  "identity": {
360
- "description": "The identity operations probe asserts for this source (#4, #8); each is among permission.operations, and no content read asserts it.",
361
- "minItems": 1,
410
+ "description": "The identity operations probe asserts for this source (#4, #8); each is among permission.operations, and no content read asserts it. Empty when the probe asserts only sources.probe.action; absent when the source does not declare it, so a consumer uses its fallback.",
362
411
  "type": "array",
363
412
  "items": {
364
413
  "type": "string",
@@ -366,6 +415,10 @@
366
415
  "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,199}$"
367
416
  }
368
417
  },
418
+ "readsIdentity": {
419
+ "description": "True when the source's content reads assert an identity operation (#30, item 4); every identity operation is still declared.",
420
+ "type": "boolean"
421
+ },
369
422
  "operations": {
370
423
  "description": "Every operation the source's reads assert, and nothing else. Absent when `rules` states them.",
371
424
  "minItems": 1,
@@ -400,6 +453,30 @@
400
453
  ],
401
454
  "additionalProperties": false
402
455
  }
456
+ },
457
+ "identityRules": {
458
+ "description": "For a rules source: the grants probe asserts for this source, verbatim, each among permission.rules (#30, item 10). Empty when the probe asserts only sources.probe.action; absent when undeclared. A rules source's equivalent of identity.",
459
+ "type": "array",
460
+ "items": {
461
+ "type": "object",
462
+ "properties": {
463
+ "action": {
464
+ "type": "string",
465
+ "maxLength": 80,
466
+ "pattern": "^(?:[a-z][a-z0-9_]*\\.[a-z][a-z0-9_]*|[a-z][a-z0-9]*_[a-z][a-z0-9_]*)$"
467
+ },
468
+ "resource": {
469
+ "type": "string",
470
+ "maxLength": 200,
471
+ "description": "The resource the action is asserted on, such as GET /user."
472
+ }
473
+ },
474
+ "required": [
475
+ "action",
476
+ "resource"
477
+ ],
478
+ "additionalProperties": false
479
+ }
403
480
  }
404
481
  },
405
482
  "required": [
@@ -454,6 +531,12 @@
454
531
  "named": {
455
532
  "type": "boolean",
456
533
  "description": "True when the source reads more than one account, so a read names one."
534
+ },
535
+ "server": {
536
+ "description": "For a plugin with one MCP server per account (#30, item 9): the server a named account's MCP tools live on, with {account} for the account, such as plaud-{account}. A bare operation is then <server>_<operation> for an account other than default; the default account keeps the namespace.",
537
+ "type": "string",
538
+ "maxLength": 64,
539
+ "pattern": "^[a-z][a-z0-9_-]*\\{account\\}[a-z0-9_-]*$"
457
540
  }
458
541
  },
459
542
  "required": [
@@ -558,6 +641,17 @@
558
641
  "usd": {
559
642
  "type": "number",
560
643
  "minimum": 0
644
+ },
645
+ "conditions": {
646
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
647
+ "type": "string",
648
+ "minLength": 1,
649
+ "maxLength": 200
650
+ },
651
+ "min": {
652
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
653
+ "type": "number",
654
+ "minimum": 0
561
655
  }
562
656
  },
563
657
  "required": [
@@ -579,6 +673,17 @@
579
673
  "usd": {
580
674
  "type": "number",
581
675
  "minimum": 0
676
+ },
677
+ "conditions": {
678
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
679
+ "type": "string",
680
+ "minLength": 1,
681
+ "maxLength": 200
682
+ },
683
+ "min": {
684
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
685
+ "type": "number",
686
+ "minimum": 0
582
687
  }
583
688
  },
584
689
  "required": [
@@ -616,6 +721,17 @@
616
721
  "usd": {
617
722
  "type": "number",
618
723
  "minimum": 0
724
+ },
725
+ "conditions": {
726
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
727
+ "type": "string",
728
+ "minLength": 1,
729
+ "maxLength": 200
730
+ },
731
+ "min": {
732
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
733
+ "type": "number",
734
+ "minimum": 0
619
735
  }
620
736
  },
621
737
  "required": [
@@ -637,6 +753,17 @@
637
753
  "usd": {
638
754
  "type": "number",
639
755
  "minimum": 0
756
+ },
757
+ "conditions": {
758
+ "description": "The short sentence shown at consent when this price applies, such as X app owners only.",
759
+ "type": "string",
760
+ "minLength": 1,
761
+ "maxLength": 200
762
+ },
763
+ "min": {
764
+ "description": "The lowest rate that may apply, in US dollars: at most usd.",
765
+ "type": "number",
766
+ "minimum": 0
640
767
  }
641
768
  },
642
769
  "required": [
@@ -731,8 +858,7 @@
731
858
  "not": {}
732
859
  },
733
860
  "identity": {
734
- "description": "The identity operations probe asserts for this source (#4, #8); each is among permission.operations, and no content read asserts it.",
735
- "minItems": 1,
861
+ "description": "The identity operations probe asserts for this source (#4, #8); each is among permission.operations, and no content read asserts it. Empty when the probe asserts only sources.probe.action; absent when the source does not declare it, so a consumer uses its fallback.",
736
862
  "type": "array",
737
863
  "items": {
738
864
  "type": "string",
@@ -740,6 +866,10 @@
740
866
  "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,199}$"
741
867
  }
742
868
  },
869
+ "readsIdentity": {
870
+ "description": "True when the source's content reads assert an identity operation (#30, item 4); every identity operation is still declared.",
871
+ "type": "boolean"
872
+ },
743
873
  "operations": {
744
874
  "description": "Every operation the source's reads assert, and nothing else. Absent when `rules` states them.",
745
875
  "minItems": 1,
@@ -774,6 +904,30 @@
774
904
  ],
775
905
  "additionalProperties": false
776
906
  }
907
+ },
908
+ "identityRules": {
909
+ "description": "For a rules source: the grants probe asserts for this source, verbatim, each among permission.rules (#30, item 10). Empty when the probe asserts only sources.probe.action; absent when undeclared. A rules source's equivalent of identity.",
910
+ "type": "array",
911
+ "items": {
912
+ "type": "object",
913
+ "properties": {
914
+ "action": {
915
+ "type": "string",
916
+ "maxLength": 80,
917
+ "pattern": "^(?:[a-z][a-z0-9_]*\\.[a-z][a-z0-9_]*|[a-z][a-z0-9]*_[a-z][a-z0-9_]*)$"
918
+ },
919
+ "resource": {
920
+ "type": "string",
921
+ "maxLength": 200,
922
+ "description": "The resource the action is asserted on, such as GET /user."
923
+ }
924
+ },
925
+ "required": [
926
+ "action",
927
+ "resource"
928
+ ],
929
+ "additionalProperties": false
930
+ }
777
931
  }
778
932
  },
779
933
  "required": [
@@ -1,16 +1,16 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  SOURCES_SCHEMA
4
- } from "./chunks/chunk-RRUAIQ4I.js";
5
- import "./chunks/chunk-KWEWSZ4V.js";
6
- import "./chunks/chunk-ZUKF7P6U.js";
7
- import "./chunks/chunk-I2RXJJJM.js";
8
- import "./chunks/chunk-3M5PAKSS.js";
4
+ } from "./chunks/chunk-HVBOAYBO.js";
5
+ import "./chunks/chunk-X6XP7YK2.js";
6
+ import "./chunks/chunk-YH323FAZ.js";
7
+ import "./chunks/chunk-NUEROZNU.js";
8
+ import "./chunks/chunk-OZMX7VR7.js";
9
9
  import {
10
10
  OUTPUTS
11
- } from "./chunks/chunk-6HDIB2SA.js";
12
- import "./chunks/chunk-W5SHR7DQ.js";
13
- import "./chunks/chunk-HLVAKAYG.js";
11
+ } from "./chunks/chunk-BOUWB5UP.js";
12
+ import "./chunks/chunk-JUWIMDGF.js";
13
+ import "./chunks/chunk-T4QM7B3S.js";
14
14
 
15
15
  // src/schemas.ts
16
16
  var SCHEMAS = [SOURCES_SCHEMA, ...Object.values(OUTPUTS)];
@@ -1,4 +1,4 @@
1
- // @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
1
+ // @we-the-rebel-alliance/source-contract 0.2.0. Built by scripts/build.mjs; do not edit.
2
2
  import {
3
3
  CLASSES,
4
4
  LOCATION_HEADER,
@@ -16,11 +16,11 @@ import {
16
16
  toolsRpcId,
17
17
  toolsRpcIdProblems,
18
18
  upstreamText
19
- } from "./chunks/chunk-KWEWSZ4V.js";
19
+ } from "./chunks/chunk-X6XP7YK2.js";
20
20
  import {
21
21
  evaluate
22
- } from "./chunks/chunk-3M5PAKSS.js";
23
- import "./chunks/chunk-HLVAKAYG.js";
22
+ } from "./chunks/chunk-OZMX7VR7.js";
23
+ import "./chunks/chunk-T4QM7B3S.js";
24
24
  export {
25
25
  CLASSES,
26
26
  LOCATION_HEADER,
package/src/sources.js CHANGED
@@ -307,6 +307,50 @@ export function sourceEntry(source) {
307
307
  return declared.get(name) ?? BY_SOURCE.get(name) ?? null
308
308
  }
309
309
 
310
+ /**
311
+ * Every declared source one name stands for (0.12.3): its id, the name its page
312
+ * carries (`input.source`, which is the previous contract's name for the same
313
+ * feed), its namespace, or its id's last part. The nine family plugins kept
314
+ * their registry names — `granola`, `gmail`, `slack` — as the page names their
315
+ * declarations send, so a bind request names one of them and the declared
316
+ * source is what it means.
317
+ *
318
+ * @param {string} source
319
+ * @returns {object[]} the declared entries, in binding order; empty when nothing declares for the name
320
+ */
321
+ export function declaredForName(source) {
322
+ const wanted = String(source ?? "")
323
+ if (wanted === "") return []
324
+ const exact = declared.get(wanted)
325
+ if (exact) return [exact]
326
+ const byPage = [...declared.values()].filter((entry) => entry.pageSource === wanted)
327
+ if (byPage.length > 0) return byPage
328
+ return [...declared.values()].filter((entry) => entry.namespace === wanted || entry.source.endsWith(`.${wanted}`))
329
+ }
330
+
331
+ /**
332
+ * What a bind request's name means under the installed declarations: the one
333
+ * declared source it stands for, or the several it could be.
334
+ *
335
+ * A name that is one declared source's id, page name or namespace is that
336
+ * source. **Several** declared sources under one name (a namespace such as
337
+ * `gws`, whose `gws.gmail` and `gws.calendar` are different feeds) resolve to
338
+ * none of them: the bind must name the one it means, because reading the wrong
339
+ * feed is not a choice Memory makes for the person. An events source wins over a
340
+ * snapshot source of the same name, and a snapshot alone is returned so the
341
+ * caller can say why this release does not bind it (G1).
342
+ *
343
+ * @param {string} source
344
+ * @returns {{ entry: object | null, options: string[] }} `options`: the ids to name instead, when several
345
+ */
346
+ export function resolveDeclaredSource(source) {
347
+ const matches = declaredForName(source)
348
+ const events = matches.filter((entry) => entry.kind === "events")
349
+ const candidates = events.length > 0 ? events : matches
350
+ if (candidates.length === 1) return { entry: candidates[0], options: [] }
351
+ return { entry: null, options: candidates.map((entry) => entry.source) }
352
+ }
353
+
310
354
  /** True when a package declares a source under the contract, so its legacy alias is retired (audit 1.3). */
311
355
  export function legacyRetired(source) {
312
356
  const entry = BY_SOURCE.get(String(source ?? ""))
@@ -1,6 +1,6 @@
1
1
  import { contextScopeLabel } from "../scope.js"
2
2
  import { DEFAULT_ACCOUNT, isAccountName, isSourceName } from "../collector.js"
3
- import { bindableSource, installedVersionOf, kindProblem, knownSources, releaseNote, sourceEntry } from "../sources.js"
3
+ import { bindableSource, installedVersionOf, kindProblem, knownSources, releaseNote, resolveDeclaredSource, sourceEntry } from "../sources.js"
4
4
  import { createProfileReads, profileText } from "../views/profile.js"
5
5
  import { asksToDecline, latestWord, mustRefuse, namesProposal } from "../requests.js"
6
6
  import { errorMessage, isPlainObject, oneLine } from "../util.js"
@@ -348,22 +348,38 @@ export function createSpacesActions(toolkit) {
348
348
  }
349
349
  }
350
350
 
351
- /** A bind or unbind's source and account; `known` requires a source in the registry (src/sources.js). */
351
+ /**
352
+ * A bind or unbind's source and account; `known` requires a source in the
353
+ * registry (src/sources.js).
354
+ *
355
+ * A name is resolved to the declared source it stands for (0.12.3): its id,
356
+ * the name its page carries (`gmail`, `granola`, `slack`), or its namespace.
357
+ * One declared source is bound under its own id, and the answer says so; a
358
+ * namespace with several (`gws`) names them instead, because which feed to
359
+ * read is the person's choice, not Memory's. Nothing that declares keeps the
360
+ * previous contract's name, so every request, report, binding and listing is
361
+ * keyed by the declared id.
362
+ */
352
363
  function bindingOf(value, { known = false } = {}) {
353
364
  const source = String(value?.source ?? "").trim()
354
365
  const asked = String(value?.account ?? "").trim()
355
366
  const account = asked || DEFAULT_ACCOUNT
356
367
  if (!isSourceName(source)) return { error: `"${oneLine(source || "(none)", 60)}" is not a source name: one of ${knownSources().join(", ")}.` }
357
- if (known && !bindableSource(source)) {
368
+ const resolved = resolveDeclaredSource(source)
369
+ if (resolved.options.length > 1) {
370
+ return { error: `"${oneLine(source, 60)}" names ${resolved.options.length} sources this release binds separately: ${resolved.options.join(", ")}. Bind the one you mean.` }
371
+ }
372
+ const bound = resolved.entry?.source ?? source
373
+ if (known && !bindableSource(bound)) {
358
374
  // Said plainly, and each for its own reason: a kind this release does not
359
375
  // read (G1), or an installed release too old to serve it (G3). A name
360
376
  // Memory does not know at all keeps the list.
361
- const kind = kindProblem(source)
377
+ const kind = kindProblem(bound)
362
378
  if (kind) return { error: `${kind.message} ${kind.next}` }
363
- return { error: `"${oneLine(source, 60)}" is not a source Memory knows: one of ${knownSources().join(", ")}.` }
379
+ return { error: `"${oneLine(bound, 60)}" is not a source Memory knows: one of ${knownSources().join(", ")}.` }
364
380
  }
365
381
  if (!isAccountName(account)) return { error: `"${oneLine(account, 60)}" is not an account name.` }
366
- return { source, account, asked: Boolean(asked) }
382
+ return { source: bound, account, asked: Boolean(asked), from: bound === source ? null : source }
367
383
  }
368
384
 
369
385
  const describeBinding = (row, behind = null) => {
@@ -459,10 +475,24 @@ export function createSpacesActions(toolkit) {
459
475
  * server's refusal, with the server's next step.
460
476
  */
461
477
  async function bindSource(value, space, rows, requests) {
478
+ // A name the previous contract knows is checked against the installs before it
479
+ // is asked for (0.12.3): a package that declares its source now is bound under
480
+ // the declared id, and the scan is the one discovery already makes — read-only,
481
+ // and coalesced with any scan under way. A declared id needs no scan.
482
+ const named = String(value?.source ?? "").trim()
483
+ if (typeof toolkit.plugins?.scan === "function" && sourceEntry(named)?.contract === "events_list" && resolveDeclaredSource(named).entry === null) {
484
+ try {
485
+ await toolkit.plugins.scan("bind")
486
+ } catch (error) {
487
+ log.warn("plugin discovery failed before a bind", { error: errorMessage(error) })
488
+ }
489
+ }
462
490
  const asked = bindingOf(value, { known: true })
463
491
  if (asked.error) return `not bound: ${asked.error}`
464
492
  const name = `${asked.source}${asked.asked ? `:${asked.account}` : ""}`
465
- const label = asked.source
493
+ // The declared source this release binds, and — when the person asked by the
494
+ // previous contract's name — the name they used (0.12.3).
495
+ const label = `${asked.source}${asked.from ? ` (asked as ${oneLine(asked.from, 60)})` : ""}`
466
496
  const link = consoleAt("sources")
467
497
  const matches = (row, ...accounts) => row.source === asked.source && (!asked.asked || accounts.some((account) => (account || DEFAULT_ACCOUNT) === asked.account))
468
498
  const bound = rows.find((row) => matches(row, row.account) && row.status === "confirmed" && (row.enabled === true || row.enabled === 1))
@@ -521,36 +551,42 @@ export function createSpacesActions(toolkit) {
521
551
  if (input?.unbind) {
522
552
  const binding = bindingOf(input.unbind)
523
553
  if (binding.error) return text(`not unbound: ${binding.error}`)
524
- const row = rows.find((entry) => entry.source === binding.source && (entry.account || DEFAULT_ACCOUNT) === binding.account)
525
- const request = requests.find((entry) => entry.source === binding.source && (entry.account || DEFAULT_ACCOUNT) === binding.account)
554
+ // A binding made before its package declared keeps the name it was made
555
+ // under: ending it by that name ends that row, never a declared source of
556
+ // the same account (0.12.3).
557
+ const askedName = String(input?.unbind?.source ?? "").trim()
558
+ const held = [...rows, ...requests].some((entry) => entry.source === askedName && (entry.account || DEFAULT_ACCOUNT) === binding.account)
559
+ const target = binding.from && held ? { ...binding, source: askedName } : binding
560
+ const row = rows.find((entry) => entry.source === target.source && (entry.account || DEFAULT_ACCOUNT) === target.account)
561
+ const request = requests.find((entry) => entry.source === target.source && (entry.account || DEFAULT_ACCOUNT) === target.account)
526
562
  if (!row && request) {
527
563
  if (space.shared) return text(personalOnly("cancelled"))
528
564
  // Only a bind request: nothing was collected, so cancelling it deletes nothing.
529
565
  try {
530
- await records().call("sources.cancel", { source: binding.source, account: binding.account }, space.where)
566
+ await records().call("sources.cancel", { source: target.source, account: binding.account }, space.where)
531
567
  } catch (error) {
532
568
  return fail(`not cancelled: ${recordsFailure(error)}`)
533
569
  }
534
570
  // No session keeps this binding's allow rules once nobody asks for it.
535
- await toolkit.collector?.forgetSession?.({ source: binding.source, account: binding.account })
536
- return text(`cancelled the bind request for ${binding.source}:${binding.account} in ${space.label}; nothing had been collected from it.`)
571
+ await toolkit.collector?.forgetSession?.({ source: target.source, account: binding.account })
572
+ return text(`cancelled the bind request for ${target.source}:${binding.account} in ${space.label}; nothing had been collected from it.`)
537
573
  }
538
- if (!row) return text(`not unbound: ${binding.source}:${binding.account} is not a source in ${space.label}.`)
574
+ if (!row) return text(`not unbound: ${target.source}:${binding.account} is not a source in ${space.label}.`)
539
575
  if (input?.confirm !== true) {
540
576
  return text(
541
- `preview, nothing changed: unbinding ${binding.source}:${binding.account} (${oneLine(row.owner_label || row.owner_id || "owner unknown", 120)}) stops its collection and deletes every event collected from it in ${space.label}. Journal pages and memories already made from them stay. Call again with "confirm": true to unbind.`,
577
+ `preview, nothing changed: unbinding ${target.source}:${binding.account} (${oneLine(row.owner_label || row.owner_id || "owner unknown", 120)}) stops its collection and deletes every event collected from it in ${space.label}. Journal pages and memories already made from them stay. Call again with "confirm": true to unbind.`,
542
578
  )
543
579
  }
544
- const denied = await gateUnbind(binding, `stops collecting ${binding.source}:${binding.account} and deletes every event collected from it in ${oneLine(space.context?.space_name || space.spaceId || "this space", 120)}; pages and memories already made from them stay.`)
580
+ const denied = await gateUnbind(target, `stops collecting ${target.source}:${binding.account} and deletes every event collected from it in ${oneLine(space.context?.space_name || space.spaceId || "this space", 120)}; pages and memories already made from them stay.`)
545
581
  if (denied) return text(`not unbound (approval): ${denied}`)
546
582
  let answer
547
583
  try {
548
- answer = await records().call("sources.unbind", { source: binding.source, account: binding.account }, space.where)
584
+ answer = await records().call("sources.unbind", { source: target.source, account: binding.account }, space.where)
549
585
  } catch (error) {
550
586
  log.warn("sources unbind failed", error)
551
587
  return fail(`${error?.outcomeUnknown ? "unbind outcome unknown" : "not unbound"}: ${recordsFailure(error)}`)
552
588
  }
553
- await toolkit.collector?.forgetSession?.({ source: binding.source, account: binding.account })
589
+ await toolkit.collector?.forgetSession?.({ source: target.source, account: binding.account })
554
590
  let after = rows.filter((entry) => entry !== row)
555
591
  try {
556
592
  after = await listSources(space.where)
@@ -559,7 +595,7 @@ export function createSpacesActions(toolkit) {
559
595
  }
560
596
  const sync = await syncCollector(after)
561
597
  return text(
562
- `unbound ${binding.source}:${binding.account} in ${space.label}: collection stopped and ${Number(answer?.deleted_events) || 0} event(s) were deleted.${sync ? ` ${sync}` : ""}`,
598
+ `unbound ${target.source}:${binding.account} in ${space.label}: collection stopped and ${Number(answer?.deleted_events) || 0} event(s) were deleted.${sync ? ` ${sync}` : ""}`,
563
599
  )
564
600
  }
565
601
 
@@ -1,10 +1,11 @@
1
1
  # Vendored `@we-the-rebel-alliance/source-contract`
2
2
 
3
- **The locked v0.1.0 release.** This is the package's `dist/` at
4
- `381e6c91` — `main` after PR #21, #24 and #25 merged (schema: rpc, probe and identity, one
5
- kind rule, the events page, and verbatim grants), `package.json` version
6
- `0.1.0`. The `v0.1.0` tag is not created yet; whichever commit it names must be
7
- this one, and `VENDOR.json` names the commit and the SHA-256 of every file here.
3
+ **The locked v0.2.0 release.** This is the package's `dist/` at
4
+ `88bdc1e3` — `v0.1.0` plus #29–#41 (the keys a page and a declaration may now
5
+ carry, the probe's scheme-qualified owner, and the checks a rules source and the
6
+ kit now make), `package.json` version `0.2.0`. The `v0.2.0` tag is annotated
7
+ (`6c2eaac8`), and `VENDOR.json` names the commit and the SHA-256 of every file
8
+ here.
8
9
 
9
10
  - **Runtime:** `tools-rpc.js`, `events.js`, `cursor.js` and `registry.js` are what
10
11
  Memory's sources carry the protocol with, so the copy ships inside the plugin (the