@ai-matrx/agents 0.59.270 → 0.59.272

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
@@ -1,9 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.59.272
4
+
5
+ - New export `./context/rules-corpus.json` (shipped in `files`): the context-rules parity corpus, so a consumer test (chat) reads it through the dependency instead of a path into this package. Additive; no consumer action required.
6
+
7
+ - `./settings`: `reasoning_effort` leaves `AUTO_MEANS_UNSET_KEYS` — a person's "auto" is saved and
8
+ sent (owner ruling 2026-10-24: unset effort runs at the platform default "low"; "auto" only when a
9
+ person picks it). New `NEVER_IMPLICIT_AUTO_KEYS` + `isNeverImplicitChoice`; `startingValueFor`
10
+ never starts a row at "auto". Consumer action: none beyond adopting latest — every writer reads
11
+ `isUnsetChoice` already.
12
+
13
+ ## 0.59.271
14
+
15
+ Automatic changed-only republish (docs/metadata drift since the last published version; verified: `git diff 8a4ed656ea 2c48e64133 -- apps/shared/matrx-agents/src`
16
+ has no shipped-source changes outside tests, fixtures and docs). No consumer action required.
17
+
3
18
  ## 0.59.270
4
19
 
5
- UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
- Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/matrx-agents/src`.
20
+ Automatic changed-only republish (docs/metadata drift since the last published version; verified: `git diff 4c08cba6c4 8a4ed656ea -- apps/shared/matrx-agents/src`
21
+ has no shipped-source changes outside tests, fixtures and docs). No consumer action required.
7
22
 
8
23
  ## 0.59.269
9
24
 
@@ -0,0 +1,238 @@
1
+ {
2
+ "version": 1,
3
+ "about": "THE parity corpus for context value rules (common-docs/systems/data/scopes-context/context-delivery/RULES.md). Run by the package vitest (context/rules.test.ts) AND aidream pytest (tests/test_context_rules_corpus.py). Expectations are hand-derived from RULES.md section 2 — never regenerate them from either implementation.",
4
+ "defaults": { "cap": 50000 },
5
+ "rules_cases": [
6
+ { "name": "bare value under default", "input": { "chars": 150 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
7
+ { "name": "bare value at the default is inline (<=)", "input": { "chars": 200 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
8
+ { "name": "bare value one over the default", "input": { "chars": 201 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
9
+ { "name": "unresolved lazy source is on request", "input": { "chars": null }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
10
+ { "name": "server per-key default (small lazy document)", "input": { "default_max": 6000, "chars": 5000 }, "expect": { "include": true, "max_inline_chars": 6000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
11
+ { "name": "server per-key default zero (IDE diagnostics)", "input": { "default_max": 0, "chars": 10 }, "expect": { "include": true, "max_inline_chars": 0, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
12
+ { "name": "page limit raises the default", "input": { "surface": { "declared": true, "auto_context": true, "max_inline_chars": 8000 }, "chars": 7000 }, "expect": { "include": true, "max_inline_chars": 8000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": false } },
13
+ { "name": "agent ceiling below page limit wins", "input": { "agent": { "declared": true, "max_inline_chars": 1000 }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 8000 }, "chars": 5000 }, "expect": { "include": true, "max_inline_chars": 1000, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "agent" }, "clamped": false } },
14
+ { "name": "page limit below agent ceiling wins", "input": { "agent": { "declared": true, "max_inline_chars": 1000 }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 500 }, "chars": 400 }, "expect": { "include": true, "max_inline_chars": 500, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": false } },
15
+ { "name": "agent and page tie — agent named", "input": { "agent": { "declared": true, "max_inline_chars": 1000 }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 1000 }, "chars": 1000 }, "expect": { "include": true, "max_inline_chars": 1000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "agent" }, "clamped": false } },
16
+ { "name": "agent declares key without a limit — page limit applies", "input": { "agent": { "declared": true, "max_inline_chars": null }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 8000 }, "chars": 3000 }, "expect": { "include": true, "max_inline_chars": 8000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": false } },
17
+ { "name": "agent limit ignored when the key is not declared", "input": { "agent": { "declared": false, "max_inline_chars": 1000 }, "chars": 300 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
18
+ { "name": "page zero beats agent ceiling", "input": { "agent": { "declared": true, "max_inline_chars": 1000 }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 0 }, "chars": 5 }, "expect": { "include": true, "max_inline_chars": 0, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": false } },
19
+ { "name": "agent zero with no page", "input": { "agent": { "declared": true, "max_inline_chars": 0 }, "chars": 5 }, "expect": { "include": true, "max_inline_chars": 0, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "agent" }, "clamped": false } },
20
+ { "name": "page auto_context off drops an undeclared value", "input": { "surface": { "declared": true, "auto_context": false, "max_inline_chars": null }, "chars": 50 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "default" }, "clamped": false } },
21
+ { "name": "agent declaration re-admits a page auto_context off value", "input": { "agent": { "declared": true }, "surface": { "declared": true, "auto_context": false }, "chars": 50 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "agent", "max_inline_chars": "default" }, "clamped": false } },
22
+ { "name": "auto_context off on an undeclared surface value is not a page rule", "input": { "surface": { "declared": false, "auto_context": false }, "chars": 50 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
23
+ { "name": "kill switch drops an undeclared key", "input": { "agent": { "declared": false, "kill_switch": true }, "chars": 50 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "agent", "max_inline_chars": "default" }, "clamped": false } },
24
+ { "name": "kill switch keeps a declared key", "input": { "agent": { "declared": true, "kill_switch": true }, "chars": 50 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
25
+ { "name": "kill switch beats a page auto_context on", "input": { "agent": { "declared": false, "kill_switch": true }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 8000 }, "chars": 50 }, "expect": { "include": false, "max_inline_chars": 8000, "delivery": "off", "decided_by": { "include": "agent", "max_inline_chars": "page" }, "clamped": false } },
26
+ { "name": "YOU re-admit past the kill switch", "input": { "agent": { "declared": false, "kill_switch": true }, "user": { "include": true }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
27
+ { "name": "YOU re-admit past page auto_context off", "input": { "surface": { "declared": true, "auto_context": false }, "user": { "include": true }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
28
+ { "name": "YOU turn a value off", "input": { "user": { "include": false }, "chars": 100 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
29
+ { "name": "YOU turn off an agent-declared value", "input": { "agent": { "declared": true, "max_inline_chars": 5000 }, "user": { "include": false }, "chars": 100 }, "expect": { "include": false, "max_inline_chars": 5000, "delivery": "off", "decided_by": { "include": "you", "max_inline_chars": "agent" }, "clamped": false } },
30
+ { "name": "YOUR limit beats a lower agent ceiling", "input": { "agent": { "declared": true, "max_inline_chars": 1000 }, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 500 }, "user": { "max_inline_chars": 20000 }, "chars": 15000 }, "expect": { "include": true, "max_inline_chars": 20000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "you" }, "clamped": false } },
31
+ { "name": "YOUR limit zero means never inline", "input": { "user": { "max_inline_chars": 0 }, "chars": 5 }, "expect": { "include": true, "max_inline_chars": 0, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "you" }, "clamped": false } },
32
+ { "name": "YOUR limit at exact size is inline", "input": { "user": { "max_inline_chars": 300 }, "chars": 300 }, "expect": { "include": true, "max_inline_chars": 300, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "you" }, "clamped": false } },
33
+ { "name": "YOUR limit above the cap is clamped and says so", "input": { "user": { "max_inline_chars": 60000 }, "chars": 55000 }, "expect": { "include": true, "max_inline_chars": 50000, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "you" }, "clamped": true } },
34
+ { "name": "agent limit above the cap is clamped", "input": { "agent": { "declared": true, "max_inline_chars": 70000 }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 50000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "agent" }, "clamped": true } },
35
+ { "name": "lowered cap knob clamps a page limit", "input": { "cap": 1000, "surface": { "declared": true, "auto_context": true, "max_inline_chars": 8000 }, "chars": 900 }, "expect": { "include": true, "max_inline_chars": 1000, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": true } },
36
+ { "name": "negative user limit is ignored", "input": { "user": { "max_inline_chars": -5 }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
37
+ { "name": "fractional user limit is ignored", "input": { "user": { "max_inline_chars": 12.5 }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
38
+ { "name": "non-boolean user include is ignored", "input": { "user": { "include": "no" }, "chars": 100 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
39
+ { "name": "user limit only — include still decided by the page", "input": { "surface": { "declared": true, "auto_context": false }, "user": { "max_inline_chars": 900 }, "chars": 100 }, "expect": { "include": false, "max_inline_chars": 900, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "you" }, "clamped": false } },
40
+ { "name": "user limit on an unresolved lazy source stays on request", "input": { "user": { "max_inline_chars": 20000 }, "chars": null }, "expect": { "include": true, "max_inline_chars": 20000, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "you" }, "clamped": false } },
41
+ { "name": "identity survives the agent kill switch", "input": { "identity": true, "agent": { "declared": false, "kill_switch": true }, "chars": 120 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
42
+ { "name": "identity survives a page that switched auto context off", "input": { "identity": true, "surface": { "declared": true, "auto_context": false }, "chars": 120 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
43
+ { "name": "identity under the kill switch: the person's off rule still wins", "input": { "identity": true, "agent": { "declared": false, "kill_switch": true }, "user": { "include": false }, "chars": 120 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
44
+ { "name": "a page's own conversation never gets the page: the lock turns it off", "input": { "surface": { "declared": true, "auto_context": false, "own": true }, "chars": 10 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "default" }, "clamped": false } },
45
+ { "name": "the person's saved on rule cannot reopen a page's own conversation", "input": { "surface": { "declared": true, "auto_context": false, "own": true }, "user": { "include": true }, "chars": 10 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "default" }, "clamped": false } },
46
+ { "name": "the agent's own declaration cannot reopen a page's own conversation", "input": { "agent": { "declared": true, "kill_switch": false }, "surface": { "declared": true, "auto_context": false, "own": true }, "chars": 10 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "default" }, "clamped": false } },
47
+ { "name": "identity is never locked by a page's own conversation", "input": { "identity": true, "surface": { "declared": true, "auto_context": false, "own": true }, "chars": 10 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "default", "max_inline_chars": "default" }, "clamped": false } },
48
+ { "name": "identity under a switched-off page: the person's off rule still wins", "input": { "identity": true, "surface": { "declared": true, "auto_context": false }, "user": { "include": false }, "chars": 120 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
49
+ { "name": "identity on the page's own conversation with the person's on rule is sent", "input": { "identity": true, "surface": { "declared": true, "auto_context": false }, "user": { "include": true }, "chars": 120 }, "expect": { "include": true, "max_inline_chars": 200, "delivery": "inline", "decided_by": { "include": "you", "max_inline_chars": "default" }, "clamped": false } },
50
+ { "name": "the same page-off layer closes a value that is not identity", "input": { "surface": { "declared": true, "auto_context": false }, "chars": 120 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "page", "max_inline_chars": "default" }, "clamped": false } },
51
+ { "name": "identity's limit still resolves like any value", "input": { "identity": true, "agent": { "declared": false, "kill_switch": true }, "surface": { "declared": true, "auto_context": false, "max_inline_chars": 100 }, "chars": 120 }, "expect": { "include": true, "max_inline_chars": 100, "delivery": "on_request", "decided_by": { "include": "default", "max_inline_chars": "page" }, "clamped": false } },
52
+ { "name": "a value that is not identity is still closed by the kill switch", "input": { "identity": false, "agent": { "declared": false, "kill_switch": true }, "chars": 120 }, "expect": { "include": false, "max_inline_chars": 200, "delivery": "off", "decided_by": { "include": "agent", "max_inline_chars": "default" }, "clamped": false } }
53
+ ],
54
+ "lookup_cases": [
55
+ { "name": "no rows", "rows": {}, "surface_key": "matrx-user/notes", "key": "note_bundle", "expect": null },
56
+ { "name": "default row only", "rows": { "_default": { "note_bundle": { "include": false } } }, "surface_key": "matrx-user/notes", "key": "note_bundle", "expect": { "include": false } },
57
+ { "name": "surface row merges over default per field", "rows": { "_default": { "note_bundle": { "max_inline_chars": 1000 } }, "matrx-user/notes": { "note_bundle": { "include": false } } }, "surface_key": "matrx-user/notes", "key": "note_bundle", "expect": { "include": false, "max_inline_chars": 1000 } },
58
+ { "name": "surface row field wins over default field", "rows": { "_default": { "note_bundle": { "include": false } }, "matrx-user/notes": { "note_bundle": { "include": true } } }, "surface_key": "matrx-user/notes", "key": "note_bundle", "expect": { "include": true } },
59
+ { "name": "other surface rows never apply", "rows": { "matrx-user/tasks": { "note_bundle": { "include": false } } }, "surface_key": "matrx-user/notes", "key": "note_bundle", "expect": null },
60
+ { "name": "no-surface value reads the default row", "rows": { "_default": { "attached_document_1": { "max_inline_chars": 9000 } } }, "surface_key": "_default", "key": "attached_document_1", "expect": { "max_inline_chars": 9000 } },
61
+ { "name": "other key absent", "rows": { "_default": { "a": { "include": false } } }, "surface_key": "_default", "key": "b", "expect": null }
62
+ ],
63
+ "chars_cases": [
64
+ { "name": "plain string", "value": "hello", "chars": 5 },
65
+ { "name": "empty string", "value": "", "chars": 0 },
66
+ { "name": "accented string counts code points", "value": "héllo", "chars": 5 },
67
+ { "name": "astral emoji is ONE code point (JS .length would say 2)", "value": "😀ab", "chars": 3 },
68
+ { "name": "string with a raw newline is itself", "value": "a\nb", "chars": 3 },
69
+ { "name": "object pretty-printed at indent 2", "value": { "a": 1 }, "chars": 12 },
70
+ { "name": "empty object", "value": {}, "chars": 2 },
71
+ { "name": "empty array", "value": [], "chars": 2 },
72
+ { "name": "array pretty-printed", "value": [1, 2], "chars": 12 },
73
+ { "name": "nested with empty array", "value": { "a": { "b": [] } }, "chars": 28 },
74
+ { "name": "object with non-ASCII value (ensure_ascii off)", "value": { "k": "é😀" }, "chars": 15 },
75
+ { "name": "object with newline in a string escapes it", "value": { "t": "a\nb" }, "chars": 17 },
76
+ { "name": "boolean", "value": true, "chars": 4 },
77
+ { "name": "null", "value": null, "chars": 4 },
78
+ { "name": "integer", "value": 42, "chars": 2 }
79
+ ],
80
+ "server_default_cases": [
81
+ { "name": "plain string has no server default", "value": "hello", "expect": null },
82
+ { "name": "plain object has no server default", "value": {"a": 1}, "expect": null },
83
+ { "name": "envelope with content only", "value": {"content": "x", "label": "Note"}, "expect": null },
84
+ { "name": "envelope default_max_inline_chars is the server default", "value": {"content": "x", "default_max_inline_chars": 9000}, "expect": 9000 },
85
+ { "name": "envelope default zero (IDE diagnostics)", "value": {"content": "x", "default_max_inline_chars": 0}, "expect": 0 },
86
+ { "name": "negative envelope default is ignored", "value": {"content": "x", "default_max_inline_chars": -1}, "expect": null },
87
+ { "name": "boolean envelope default is ignored", "value": {"content": "x", "default_max_inline_chars": true}, "expect": null },
88
+ { "name": "fractional envelope default is ignored", "value": {"content": "x", "default_max_inline_chars": 12.5}, "expect": null },
89
+ { "name": "string envelope default is ignored", "value": {"content": "x", "default_max_inline_chars": "9000"}, "expect": null },
90
+ { "name": "a page limit is not a server default", "value": {"content": "x", "max_inline_chars": 8000}, "expect": null },
91
+ { "name": "lazy source pointer (no content) is 6000", "value": {"source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111", "field": "content"}, "type": "json", "label": "Doc"}, "expect": 6000 },
92
+ { "name": "lazy source with null content is 6000", "value": {"content": null, "source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111"}}, "expect": 6000 },
93
+ { "name": "a source with content is not lazy", "value": {"content": "body", "source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111"}}, "expect": null },
94
+ { "name": "normalized resource source is descriptor-first", "value": {"source": {"kind": "file", "id": "11111111-1111-4111-8111-111111111111", "extra": {"resource_type": "file"}}, "type": "json"}, "expect": 0 },
95
+ { "name": "explicit default beats the lazy default", "value": {"source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111"}, "default_max_inline_chars": 100}, "expect": 100 },
96
+ { "name": "a source without kind is raw content", "value": {"source": {"id": "11111111-1111-4111-8111-111111111111"}}, "expect": null },
97
+ { "name": "an unknown key makes the dict raw JSON", "value": {"content": "x", "default_max_inline_chars": 9000, "other": 1}, "expect": null },
98
+ { "name": "bare resource reference is descriptor-first", "value": {"__kind": "resource_ref", "resource_type": "file", "resource_id": "11111111-1111-4111-8111-111111111111"}, "expect": 0 },
99
+ { "name": "resource reference nested as envelope content is not promoted", "value": {"content": {"__kind": "resource_ref", "resource_type": "file", "resource_id": "11111111-1111-4111-8111-111111111111"}}, "expect": null },
100
+ { "name": "resource reference without a UUID id is raw content", "value": {"__kind": "resource_ref", "resource_type": "file", "resource_id": "not-a-uuid"}, "expect": null }
101
+ ],
102
+ "envelope_cases": [
103
+ { "name": "a record that merely has content is raw content", "value": {"id": "11111111-1111-4111-8111-111111111111", "title": "Q3 vendor review", "content": "Follow up with Acme"}, "expect": {"content": {"id": "11111111-1111-4111-8111-111111111111", "title": "Q3 vendor review", "content": "Follow up with Acme"}, "overrides": {}} },
104
+ { "name": "a true envelope splits content from its fields", "value": {"content": "Follow up with Acme", "label": "Current note", "max_inline_chars": 8000}, "expect": {"content": "Follow up with Acme", "overrides": {"label": "Current note", "max_inline_chars": 8000}} },
105
+ { "name": "an envelope with an unknown key is raw content", "value": {"content": "x", "label": "L", "pinned": true}, "expect": {"content": {"content": "x", "label": "L", "pinned": true}, "overrides": {}} },
106
+ { "name": "an envelope keeps default_max_inline_chars as a field", "value": {"content": "2 errors", "default_max_inline_chars": 0}, "expect": {"content": "2 errors", "overrides": {"default_max_inline_chars": 0}} },
107
+ { "name": "a lazy source pointer has null content", "value": {"source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111"}, "type": "json", "label": "Doc"}, "expect": {"content": null, "overrides": {"source": {"kind": "note", "id": "11111111-1111-4111-8111-111111111111"}, "type": "json", "label": "Doc"}} },
108
+ { "name": "a source without kind and no content is raw content", "value": {"source": {"id": "11111111-1111-4111-8111-111111111111"}, "label": "Doc"}, "expect": {"content": {"source": {"id": "11111111-1111-4111-8111-111111111111"}, "label": "Doc"}, "overrides": {}} },
109
+ { "name": "a plain string is content", "value": "hello", "expect": {"content": "hello", "overrides": {}} },
110
+ { "name": "an array is content", "value": [1, 2], "expect": {"content": [1, 2], "overrides": {}} }
111
+ ],
112
+ "wire_passthrough_cases": [
113
+ { "name": "an attached file reference ships as-is", "key": "attached_file_22222222-2222-4222-8222-222222222222", "value": {"__kind": "resource_ref", "resource_type": "file", "resource_id": "22222222-2222-4222-8222-222222222222"}, "passthrough": true },
114
+ { "name": "a reference with its own policy ships as-is", "key": "attached_file_22222222-2222-4222-8222-222222222222", "value": {"__kind": "resource_ref", "resource_type": "file", "resource_id": "22222222-2222-4222-8222-222222222222", "promote": [{"representation": "clean_text", "max_chars": 5000}], "exclude": ["image"]}, "passthrough": true },
115
+ { "name": "a processed document reference ships as-is", "key": "source_doc", "value": {"__kind": "resource_ref", "resource_type": "processed_document", "resource_id": "22222222-2222-4222-8222-222222222222"}, "passthrough": true },
116
+ { "name": "a bare file id under file_id ships as-is", "key": "file_id", "value": "22222222-2222-4222-8222-222222222222", "passthrough": true },
117
+ { "name": "a bare file id under a *_file_id key ships as-is", "key": "attached_file_id", "value": "22222222-2222-4222-8222-222222222222", "passthrough": true },
118
+ { "name": "a record with content is wrapped", "key": "current_note", "value": {"id": "22222222-2222-4222-8222-222222222222", "title": "Q3 vendor review", "content": "Follow up"}, "passthrough": false },
119
+ { "name": "a plain string is wrapped", "key": "current_note", "value": "Follow up with Acme", "passthrough": false }
120
+ ],
121
+ "server_resolved_cases": [
122
+ { "name": "bare note id is server-resolved", "key": "note_id", "value": "33333333-3333-4333-8333-333333333333", "expect": true, "server_promotes": true },
123
+ { "name": "prefixed note id is server-resolved", "key": "current_note_id", "value": "33333333-3333-4333-8333-333333333333", "expect": true, "server_promotes": true },
124
+ { "name": "an id key is case-insensitive", "key": "Note_ID", "value": "33333333-3333-4333-8333-333333333333", "expect": true, "server_promotes": true },
125
+ { "name": "a braced UUID is a UUID", "key": "file_id", "value": "{33333333-3333-4333-8333-333333333333}", "expect": true, "server_promotes": true },
126
+ { "name": "a hyphenless UUID is a UUID", "key": "file_id", "value": "33333333333343338333333333333333", "expect": true, "server_promotes": true },
127
+ { "name": "a urn UUID is a UUID", "key": "note_id", "value": "urn:uuid:33333333-3333-4333-8333-333333333333", "expect": true, "server_promotes": true },
128
+ { "name": "a top-level resource reference is server-resolved", "key": "current_note", "value": {"__kind": "resource_ref", "resource_type": "note", "resource_id": "33333333-3333-4333-8333-333333333333"}, "expect": true, "server_promotes": true },
129
+ { "name": "an unregistered id noun: the client stops predicting, the server keeps it raw", "key": "model_id", "value": "33333333-3333-4333-8333-333333333333", "expect": true, "server_promotes": false },
130
+ { "name": "a resource reference as envelope content: the client stops predicting", "key": "current_note", "value": {"content": {"__kind": "resource_ref", "resource_type": "note", "resource_id": "33333333-3333-4333-8333-333333333333"}, "label": "Note"}, "expect": true, "server_promotes": false },
131
+ { "name": "a UUID under a non-id key is plain text", "key": "note", "value": "33333333-3333-4333-8333-333333333333", "expect": false, "server_promotes": false },
132
+ { "name": "a non-UUID under an id key is plain text", "key": "note_id", "value": "not-a-uuid", "expect": false, "server_promotes": false },
133
+ { "name": "a plain record is not server-resolved", "key": "current_note", "value": {"id": "33333333-3333-4333-8333-333333333333", "title": "Q3 vendor review", "content": "Follow up"}, "expect": false, "server_promotes": false }
134
+ ],
135
+ "effective_lookup_cases": [
136
+ { "name": "declared on both sides: page key", "rows": {"matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "matrx-user/notes", "key": "current_note_published_to_web", "expect": {"include": false} },
137
+ { "name": "declared client-only: the server files it under _default and still reads the page rule", "rows": {"matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "current_note_published_to_web", "expect": {"include": false} },
138
+ { "name": "rule in _default only, page key", "rows": {"_default": {"current_note_published_to_web": {"max_inline_chars": 1000}}}, "primary_surface": "matrx-user/notes", "surface_key": "matrx-user/notes", "key": "current_note_published_to_web", "expect": {"max_inline_chars": 1000} },
139
+ { "name": "rule in _default only, _default key", "rows": {"_default": {"current_note_published_to_web": {"max_inline_chars": 1000}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "current_note_published_to_web", "expect": {"max_inline_chars": 1000} },
140
+ { "name": "rule in P only, _default key", "rows": {"matrx-user/notes": {"attached_document_1": {"max_inline_chars": 9000}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "attached_document_1", "expect": {"max_inline_chars": 9000} },
141
+ { "name": "both rows merge per field, page key", "rows": {"_default": {"current_note_published_to_web": {"max_inline_chars": 1000}}, "matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "matrx-user/notes", "key": "current_note_published_to_web", "expect": {"include": false, "max_inline_chars": 1000} },
142
+ { "name": "both rows merge per field, _default key", "rows": {"_default": {"current_note_published_to_web": {"max_inline_chars": 1000}}, "matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "current_note_published_to_web", "expect": {"include": false, "max_inline_chars": 1000} },
143
+ { "name": "P wins a field both rows set", "rows": {"_default": {"current_note_published_to_web": {"include": true, "max_inline_chars": 1000}}, "matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "current_note_published_to_web", "expect": {"include": false, "max_inline_chars": 1000} },
144
+ { "name": "a surroundings key keeps its own surface", "rows": {"matrx-user/sidebar": {"sidebar_filter": {"include": false}}, "matrx-user/notes": {"sidebar_filter": {"include": true}}}, "primary_surface": "matrx-user/notes", "surface_key": "matrx-user/sidebar", "key": "sidebar_filter", "expect": {"include": false} },
145
+ { "name": "a surroundings key never reads P", "rows": {"matrx-user/notes": {"sidebar_filter": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "matrx-user/sidebar", "key": "sidebar_filter", "expect": null },
146
+ { "name": "no primary surface: _default key reads _default only", "rows": {"matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": null, "surface_key": "_default", "key": "current_note_published_to_web", "expect": null },
147
+ { "name": "no primary surface: surface key merges as before", "rows": {"_default": {"current_note_published_to_web": {"max_inline_chars": 1000}}, "matrx-user/notes": {"current_note_published_to_web": {"include": false}}}, "primary_surface": null, "surface_key": "matrx-user/notes", "key": "current_note_published_to_web", "expect": {"include": false, "max_inline_chars": 1000} },
148
+ { "name": "other surfaces' rows never apply", "rows": {"matrx-user/tasks": {"current_note_published_to_web": {"include": false}}}, "primary_surface": "matrx-user/notes", "surface_key": "_default", "key": "current_note_published_to_web", "expect": null },
149
+ { "name": "a value a screen mounted inside the page published keeps that screen's surface", "rows": {"matrx-user/transcripts": {"transcript_title": {"include": false}}, "matrx-user/knowledge": {"transcript_title": {"include": true, "max_inline_chars": 9}}, "_default": {"transcript_title": {"max_inline_chars": 700}}}, "primary_surface": "matrx-user/knowledge", "surface_key": "matrx-user/transcripts", "origin": "client", "key": "transcript_title", "expect": {"include": false, "max_inline_chars": 700} },
150
+ { "name": "a mounted screen's value never reads the primary's row", "rows": {"matrx-user/knowledge": {"transcript_title": {"include": false}}}, "primary_surface": "matrx-user/knowledge", "surface_key": "matrx-user/transcripts", "origin": "client", "key": "transcript_title", "expect": null }
151
+ ],
152
+ "humanize_cases": [
153
+ { "name": "snake case to title words", "key": "current_note", "expect": "Current Note" },
154
+ { "name": "id is an acronym", "key": "note_id", "expect": "Note ID" },
155
+ { "name": "a long page key", "key": "current_note_published_to_web", "expect": "Current Note Published To Web" },
156
+ { "name": "several acronyms", "key": "source_url_pdf", "expect": "Source URL PDF" },
157
+ { "name": "acronyms are whole parts only", "key": "url2pdf_source", "expect": "Url2pdf Source" },
158
+ { "name": "hyphens split like underscores", "key": "ai-model-settings", "expect": "AI Model Settings" },
159
+ { "name": "runs of separators collapse", "key": "attached__file--id", "expect": "Attached File ID" },
160
+ { "name": "leading and trailing separators drop", "key": "_internal_key_", "expect": "Internal Key" },
161
+ { "name": "upper-case input is normalized", "key": "API_KEY_STATUS", "expect": "API Key Status" },
162
+ { "name": "camelCase splits into words", "key": "myValue_ID", "expect": "My Value ID" },
163
+ { "name": "uuid and json", "key": "resource_uuid_json", "expect": "Resource UUID JSON" },
164
+ { "name": "every listed acronym", "key": "id_url_pdf_html_json_api_ai_ui_csv_sms_seo_llm_mcp_uuid_iso", "expect": "ID URL PDF HTML JSON API AI UI CSV SMS SEO LLM MCP UUID ISO" },
165
+ { "name": "a word that only contains an acronym stays a word", "key": "idea_guide", "expect": "Idea Guide" },
166
+ { "name": "digits stay", "key": "attached_document_2", "expect": "Attached Document 2" },
167
+ { "name": "a single word", "key": "notes", "expect": "Notes" },
168
+ { "name": "empty key", "key": "", "expect": "" },
169
+ { "name": "already words stay as written", "key": "Normal Text", "expect": "Normal Text" },
170
+ { "name": "a person's phrase keeps its casing and apostrophe", "key": "Customer's iPhone model", "expect": "Customer's iPhone model" },
171
+ { "name": "a phrase with a version number is not split on the dot", "key": "Version 2.0", "expect": "Version 2.0" },
172
+ { "name": "a lowercase phrase gains only a capital first letter", "key": "lowercase words here", "expect": "Lowercase words here" },
173
+ { "name": "a plural acronym tail stays whole", "key": "userIDs", "expect": "User IDs" },
174
+ { "name": "a plural acronym part", "key": "user_ids", "expect": "User IDs" },
175
+ { "name": "api key", "key": "api_key", "expect": "API Key" },
176
+ { "name": "user id", "key": "user_id", "expect": "User ID" },
177
+ { "name": "an upper-case run before a word splits", "key": "HTMLParser", "expect": "HTML Parser" },
178
+ { "name": "digits stay inside a part", "key": "step2_output", "expect": "Step2 Output" },
179
+ { "name": "a short versioned key", "key": "v2", "expect": "V2" },
180
+ { "name": "no key at all", "key": null, "expect": "" }
181
+ ],
182
+ "attachment_key_cases_about": "attached_resource_ + encode(provider + ':' + resource_ref): ASCII letters, digits and '-' kept; every other UTF-8 byte is '_' + two lowercase hex digits ('_' itself is _5f), so the key is unique across providers, case-preserving and stable, and every client derives it from GET /conversations/{id}/attachments (provider, resource_ref).",
183
+ "attachment_key_cases": [
184
+ { "name": "a GitHub repository", "provider": "github", "resource_ref": "harbor-point/work-orders", "expect": "attached_resource_github_3aharbor-point_2fwork-orders" },
185
+ { "name": "a Drive file id keeps its case", "provider": "google", "resource_ref": "1AbCvendorSchedule", "expect": "attached_resource_google_3a1AbCvendorSchedule" },
186
+ { "name": "ids that differ only by case stay distinct", "provider": "google", "resource_ref": "1abcvendorschedule", "expect": "attached_resource_google_3a1abcvendorschedule" },
187
+ { "name": "an underscore is escaped, so it never collides with a slash", "provider": "github", "resource_ref": "harbor_point/ops", "expect": "attached_resource_github_3aharbor_5fpoint_2fops" },
188
+ { "name": "slash form", "provider": "github", "resource_ref": "a/b", "expect": "attached_resource_github_3aa_2fb" },
189
+ { "name": "underscore form", "provider": "github", "resource_ref": "a_b", "expect": "attached_resource_github_3aa_5fb" },
190
+ { "name": "the same ref under another provider is another key", "provider": "microsoft", "resource_ref": "1AbC", "expect": "attached_resource_microsoft_3a1AbC" },
191
+ { "name": "the same ref under Google", "provider": "google", "resource_ref": "1AbC", "expect": "attached_resource_google_3a1AbC" },
192
+ { "name": "a synced record ref with dots, colons and @", "provider": "google", "resource_ref": "calendar.events:abc123@google.com", "expect": "attached_resource_google_3acalendar_2eevents_3aabc123_40google_2ecom" },
193
+ { "name": "non-ASCII is escaped byte by byte (UTF-8)", "provider": "github", "resource_ref": "café", "expect": "attached_resource_github_3acaf_c3_a9" },
194
+ { "name": "spaces and dots", "provider": "microsoft", "resource_ref": "Q4 Budget.xlsx", "expect": "attached_resource_microsoft_3aQ4_20Budget_2exlsx" },
195
+ { "name": "an empty ref still names the provider", "provider": "github", "resource_ref": "", "expect": "attached_resource_github_3a" }
196
+ ],
197
+ "server_authoritative_keys_about": "The keys whose value the SERVER states itself, never the client's copy (RULES.md section 5a, owner ruling 2026-10-01: identity is the server's truth, never the page's claim), and where it states each: active_context = the turn's <active_context> block; manifest = a server-built context value. aidream SERVER_AUTHORITATIVE_KEYS and the package SERVER_AUTHORITATIVE_KEYS must equal this table exactly.",
198
+ "server_authoritative_keys": { "user": "manifest", "client": "manifest", "organization": "active_context", "active_scopes": "active_context" },
199
+ "pointer_inline_ceilings_about": "The page-layer limits the client DERIVES instead of reading from the page (owner ruling 2026-09-30, the person's pointer): a selection and the text around it inline up to these sizes on every page, never below the page's own number; pageless_content is a launch with no page behind it. A sent value carries the number on its envelope; a WITHHELD value does not, so the server holds the same table for its receipt row. matrx-frontend POINTER_INLINE_CEILINGS / PAGELESS_CONTENT_INLINE_CEILING and aidream POINTER_INLINE_CEILINGS / PAGELESS_CONTENT_INLINE_CEILING must equal this table exactly.",
200
+ "pointer_inline_ceilings": { "selection": 10000, "text_before": 2500, "text_after": 2500 },
201
+ "pageless_content_inline_ceiling": 6000,
202
+ "consumed_key_cases_about": "The reserved keys the server never keeps under their own name (RULES.md section 5 consumed_as): each still gets a receipt row naming what became of it. aidream RESERVED_CONSUMED_KEYS and the package RESERVED_CONSUMED_KEYS must equal this table exactly.",
203
+ "consumed_key_cases": [
204
+ { "name": "the registered screens around the page expand into <surface>::<value> rows", "key": "surface_chain", "consumed_as": "expanded" },
205
+ { "name": "open unregistered windows expand into window::<title> rows", "key": "window_forms", "consumed_as": "expanded" },
206
+ { "name": "a table-access grant is a directive the server acts on", "key": "__table_access", "consumed_as": "directive" },
207
+ { "name": "attached Google files are a directive the server acts on", "key": "__google_files", "consumed_as": "directive" },
208
+ { "name": "an Orchestra member step's connection is a directive the server acts on", "key": "__orchestra_member", "consumed_as": "directive" }
209
+ ],
210
+ "surroundings_key_cases_about": "The key the server delivers each value of a surface_chain level under (aidream chain_context_key), which the composer lists before the send (expandSurroundingsForDisplay): one key, so the composer, the person's rule and the receipt name the same value.",
211
+ "surroundings_key_cases": [
212
+ { "name": "the canvas beside the chat delivers its active organization id under its own surface", "surface": "matrx-user/canvas", "value": "active_organization_id", "key": "matrx-user/canvas::active_organization_id" },
213
+ { "name": "a window's value keeps its window surface", "surface": "matrx-user/data-tables-row-editor", "value": "row_draft", "key": "matrx-user/data-tables-row-editor::row_draft" }
214
+ ],
215
+ "page_context_cases_about": "RULES.md section 0: a page's OWN conversation (mode own) and a conversation whose page switch is off (mode off) never receive the page. The listed keys are withheld at the PAGE layer (declared, auto_context off), as is any value from the screens around the page (origin surroundings) and any value the page itself declared; the person values are never withheld. withheld null = the default list for the mode. aidream page_context.py and the package's pageContextWithholds must agree with every case.",
216
+ "page_context_defaults": {
217
+ "off": ["route_brief", "surface_chain", "window_forms", "surface_closed"],
218
+ "own": ["route_brief", "surface_chain", "window_forms", "surface_closed", "conversation"],
219
+ "person_values": ["user", "client", "organization", "project", "task", "active_scopes"]
220
+ },
221
+ "page_context_cases": [
222
+ { "name": "an own conversation never gets its route", "mode": "own", "withheld": null, "key": "route_brief", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": true },
223
+ { "name": "an own conversation never gets its own id", "mode": "own", "withheld": null, "key": "conversation", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": true },
224
+ { "name": "a switched-off page still lets the conversation know its id", "mode": "off", "withheld": null, "key": "conversation", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": false },
225
+ { "name": "a switched-off page withholds its route", "mode": "off", "withheld": null, "key": "route_brief", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": true },
226
+ { "name": "the person is never withheld", "mode": "own", "withheld": null, "key": "user", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": false },
227
+ { "name": "the organization is never withheld, even when the page declares it", "mode": "own", "withheld": null, "key": "organization", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/chat", "expect": false },
228
+ { "name": "the conversation's working document is never withheld, even when the page declares the name", "mode": "own", "withheld": null, "key": "working_document", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/chat", "expect": false },
229
+ { "name": "the conversation's scratchpad is never withheld from its own conversation", "mode": "own", "withheld": null, "key": "user_scratchpad", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/chat", "expect": false },
230
+ { "name": "an attached scratchpad is never withheld by a switched-off page", "mode": "off", "withheld": null, "key": "user_scratchpad_ab12cd34", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/chat", "expect": false },
231
+ { "name": "a page's own declared value is withheld from its own conversation", "mode": "own", "withheld": null, "key": "battle_columns", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/agent-battle", "expect": true },
232
+ { "name": "a screen around the page is withheld", "mode": "own", "withheld": null, "key": "matrx-user/notes::content", "origin": "surroundings", "surface_declared": true, "surface_key": "matrx-user/notes", "expect": true },
233
+ { "name": "an attachment is not the page", "mode": "own", "withheld": null, "key": "attached_document_x", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": false },
234
+ { "name": "a page that declares its own list overrides the default", "mode": "own", "withheld": ["conversation"], "key": "route_brief", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": false },
235
+ { "name": "a declared list can never withhold the person", "mode": "own", "withheld": ["user", "conversation"], "key": "user", "origin": "client", "surface_declared": false, "surface_key": "_default", "expect": false },
236
+ { "name": "a switched-off page withholds what a screen mounted inside it published", "mode": "off", "withheld": null, "key": "transcript_title", "origin": "client", "surface_declared": true, "surface_key": "matrx-user/transcripts", "expect": true }
237
+ ]
238
+ }
@@ -38,6 +38,7 @@ __export(models_exports, {
38
38
  GgufError: () => GgufError,
39
39
  INPUT_MODALITIES: () => INPUT_MODALITIES,
40
40
  INTERACTION_MODES: () => INTERACTION_MODES,
41
+ LLM_INTERACTIONS: () => LLM_INTERACTIONS,
41
42
  MAX_SUCCESSION_HOPS: () => MAX_SUCCESSION_HOPS,
42
43
  MODEL_CATALOG_KINDS: () => MODEL_CATALOG_KINDS,
43
44
  MODEL_FAVORITE_ENTITY_TYPE: () => MODEL_FAVORITE_ENTITY_TYPE,
@@ -47,6 +48,7 @@ __export(models_exports, {
47
48
  SERVICE_LABEL_PLURAL: () => SERVICE_LABEL_PLURAL,
48
49
  TOP_TIER_COST_RATING: () => TOP_TIER_COST_RATING,
49
50
  TOP_TIER_LOCKED_TITLE: () => TOP_TIER_LOCKED_TITLE,
51
+ UNKNOWN_MODEL_KIND: () => UNKNOWN_MODEL_KIND,
50
52
  acceptsTextInstructions: () => acceptsTextInstructions,
51
53
  announceModelCatalogChanged: () => announceModelCatalogChanged,
52
54
  availableOnDevices: () => availableOnDevices,
@@ -57,6 +59,7 @@ __export(models_exports, {
57
59
  catalogForApp: () => catalogForApp,
58
60
  catalogKeyColumn: () => catalogKeyColumn,
59
61
  catalogKindOf: () => catalogKindOf,
62
+ catalogKindVerdict: () => catalogKindVerdict,
60
63
  cheapestAdequateModel: () => cheapestAdequateModel,
61
64
  classConfigKey: () => classConfigKey,
62
65
  collapseTiersByClass: () => collapseTiersByClass,
@@ -74,6 +77,7 @@ __export(models_exports, {
74
77
  fitsNeed: () => fitsNeed,
75
78
  fitsThisComputer: () => fitsThisComputer,
76
79
  followModelCatalogChanges: () => followModelCatalogChanges,
80
+ followModelCatalogVisibility: () => followModelCatalogVisibility,
77
81
  formatMemoryBytes: () => formatMemoryBytes,
78
82
  fromDiscovery: () => fromDiscovery,
79
83
  ggufEngine: () => ggufEngine,
@@ -122,6 +126,7 @@ __export(models_exports, {
122
126
  readDeviceModelFiles: () => readDeviceModelFiles,
123
127
  readGgufHeader: () => readGgufHeader,
124
128
  readModelCatalog: () => readModelCatalog,
129
+ readModelCatalogStamp: () => readModelCatalogStamp,
125
130
  readModelIdentities: () => readModelIdentities,
126
131
  readPublicModel: () => readPublicModel,
127
132
  reconcileModelFavoriteIds: () => reconcileModelFavoriteIds,
@@ -937,42 +942,6 @@ var OUTPUT_MODALITIES = [
937
942
  "decision"
938
943
  ];
939
944
 
940
- // models/catalog/changes.ts
941
- var KEY2 = /* @__PURE__ */ Symbol.for("ai-matrx.agents.model-catalog-changes");
942
- function hub() {
943
- const g = globalThis;
944
- return g[KEY2] ??= { listeners: /* @__PURE__ */ new Set(), revision: 0 };
945
- }
946
- function isModelCatalogChange(payload) {
947
- const catalog = payload?.["catalog"];
948
- return catalog === void 0 || catalog === null || catalog === "models";
949
- }
950
- function onModelCatalogChanged(listener) {
951
- const h = hub();
952
- h.listeners.add(listener);
953
- return () => {
954
- h.listeners.delete(listener);
955
- };
956
- }
957
- function modelCatalogRevision() {
958
- return hub().revision;
959
- }
960
- function announceModelCatalogChanged(payload = {}) {
961
- if (!isModelCatalogChange(payload)) return;
962
- const h = hub();
963
- h.revision += 1;
964
- for (const l of [...h.listeners]) {
965
- try {
966
- l(payload);
967
- } catch (err) {
968
- console.error("[@ai-matrx/agents/models] a catalog_changed listener threw", err);
969
- }
970
- }
971
- }
972
- function followModelCatalogChanges(subscribe) {
973
- return subscribe("catalog_changed", (payload) => announceModelCatalogChanged(payload ?? {}));
974
- }
975
-
976
945
  // models/label.ts
977
946
  function modelDisplayLabel(row) {
978
947
  if (!row) return void 0;
@@ -1564,6 +1533,102 @@ async function readPublicModel(client, key) {
1564
1533
  if (error) return { row: null, error: error.message };
1565
1534
  return { row: data ?? null, error: null };
1566
1535
  }
1536
+ async function readModelCatalogStamp(client) {
1537
+ const q = client.schema("ai").from("model_definition").select("updated_at").order("updated_at", { ascending: false, nullsFirst: false });
1538
+ if (!q.limit) throw new Error("readModelCatalogStamp: the client has no .limit() (a supabase-js client does)");
1539
+ const { data, error } = await q.limit(1).maybeSingle();
1540
+ if (error) throw new Error(error.message);
1541
+ const stamp = data?.updated_at;
1542
+ return typeof stamp === "string" ? stamp : null;
1543
+ }
1544
+
1545
+ // models/catalog/changes.ts
1546
+ var KEY2 = /* @__PURE__ */ Symbol.for("ai-matrx.agents.model-catalog-changes");
1547
+ function hub() {
1548
+ const g = globalThis;
1549
+ return g[KEY2] ??= { listeners: /* @__PURE__ */ new Set(), revision: 0 };
1550
+ }
1551
+ function isModelCatalogChange(payload) {
1552
+ const catalog = payload?.["catalog"];
1553
+ return catalog === void 0 || catalog === null || catalog === "models";
1554
+ }
1555
+ function onModelCatalogChanged(listener) {
1556
+ const h = hub();
1557
+ h.listeners.add(listener);
1558
+ return () => {
1559
+ h.listeners.delete(listener);
1560
+ };
1561
+ }
1562
+ function modelCatalogRevision() {
1563
+ return hub().revision;
1564
+ }
1565
+ function announceModelCatalogChanged(payload = {}) {
1566
+ if (!isModelCatalogChange(payload)) return;
1567
+ const h = hub();
1568
+ h.revision += 1;
1569
+ for (const l of [...h.listeners]) {
1570
+ try {
1571
+ l(payload);
1572
+ } catch (err) {
1573
+ console.error("[@ai-matrx/agents/models] a catalog_changed listener threw", err);
1574
+ }
1575
+ }
1576
+ }
1577
+ function followModelCatalogChanges(subscribe) {
1578
+ return subscribe("catalog_changed", (payload) => announceModelCatalogChanged(payload ?? {}));
1579
+ }
1580
+ function followModelCatalogVisibility(options) {
1581
+ const page = options.page ?? (typeof document !== "undefined" && typeof window !== "undefined" ? { document, window } : null);
1582
+ if (!page) return () => {
1583
+ };
1584
+ const minIntervalMs = options.minIntervalMs ?? 2e4;
1585
+ const now = options.now ?? (() => Date.now());
1586
+ const sink = options.errorSink ?? ((e) => {
1587
+ console.error(`[@ai-matrx/agents/models] ${e.code}: ${e.message}`);
1588
+ });
1589
+ let baseline;
1590
+ let inFlight = null;
1591
+ let lastShownRead = -Infinity;
1592
+ const stamp = () => inFlight ??= readModelCatalogStamp(options.client).finally(() => {
1593
+ inFlight = null;
1594
+ });
1595
+ const fail = (err) => sink({ code: "model-catalog-stamp-failed", message: err instanceof Error ? err.message : String(err) });
1596
+ const learnBaseline = () => {
1597
+ if (baseline !== void 0) return;
1598
+ void stamp().then((s4) => {
1599
+ if (baseline === void 0) baseline = s4;
1600
+ }, fail);
1601
+ };
1602
+ const onHidden = () => {
1603
+ if (page.document.visibilityState === "hidden") learnBaseline();
1604
+ };
1605
+ const onShown = () => {
1606
+ if (page.document.visibilityState === "hidden") return;
1607
+ const t = now();
1608
+ if (t - lastShownRead < minIntervalMs) return;
1609
+ lastShownRead = t;
1610
+ const known = baseline;
1611
+ if (known === void 0) return learnBaseline();
1612
+ void stamp().then((s4) => {
1613
+ if (s4 === known) return;
1614
+ baseline = s4;
1615
+ announceModelCatalogChanged({ catalog: "models", change: "catch_up_visible" });
1616
+ }, fail);
1617
+ };
1618
+ const offChanges = onModelCatalogChanged(() => {
1619
+ baseline = void 0;
1620
+ if (page.document.visibilityState === "hidden") learnBaseline();
1621
+ });
1622
+ const onVisibility = () => page.document.visibilityState === "hidden" ? onHidden() : onShown();
1623
+ page.document.addEventListener("visibilitychange", onVisibility);
1624
+ page.window.addEventListener("focus", onShown);
1625
+ if (page.document.visibilityState === "hidden") learnBaseline();
1626
+ return () => {
1627
+ offChanges();
1628
+ page.document.removeEventListener("visibilitychange", onVisibility);
1629
+ page.window.removeEventListener("focus", onShown);
1630
+ };
1631
+ }
1567
1632
 
1568
1633
  // models/catalog/store.ts
1569
1634
  var IDLE = { status: "idle", models: [], error: null, loadedAt: null };
@@ -2819,6 +2884,7 @@ var DeviceModelUnavailableError = class extends Error {
2819
2884
  };
2820
2885
 
2821
2886
  // models/catalog-reader.ts
2887
+ var UNKNOWN_MODEL_KIND = "unknown";
2822
2888
  var MODEL_CATALOG_KINDS = /* @__PURE__ */ new Set([
2823
2889
  "llm_model",
2824
2890
  "whisper_model",
@@ -2827,23 +2893,35 @@ var MODEL_CATALOG_KINDS = /* @__PURE__ */ new Set([
2827
2893
  "video_gen_model",
2828
2894
  "ner_model",
2829
2895
  "wake_word_model",
2830
- "lora"
2896
+ "lora",
2897
+ "embedding_model",
2898
+ UNKNOWN_MODEL_KIND
2831
2899
  ]);
2832
- function catalogKindOf(m, kindOfEntry) {
2900
+ var LLM_INTERACTIONS = /* @__PURE__ */ new Set(["turn", "single", "agent"]);
2901
+ function catalogKindVerdict(m, kindOfEntry) {
2833
2902
  for (const v of m.variants)
2834
2903
  for (const id of v.catalog_entry_ids ?? []) {
2835
2904
  const k = kindOfEntry.get(id);
2836
- if (k && MODEL_CATALOG_KINDS.has(k)) return k;
2905
+ if (k && k !== UNKNOWN_MODEL_KIND && MODEL_CATALOG_KINDS.has(k)) return { kind: k, reason: null };
2837
2906
  }
2838
2907
  const out = m.capabilities.output ?? [];
2839
2908
  const inp = m.capabilities.input ?? [];
2840
- if (m.presentation?.shelf === "loras") return "lora";
2841
- if (out.includes("video")) return "video_gen_model";
2842
- if (out.includes("image")) return "image_gen_model";
2843
- if (out.includes("audio")) return "tts_model_file";
2844
- if (inp.includes("audio")) return "whisper_model";
2845
- if (m.capabilities.interaction === "extraction") return "ner_model";
2846
- return "llm_model";
2909
+ const interaction = m.capabilities.interaction ?? "";
2910
+ const placed = (kind) => ({ kind, reason: null });
2911
+ if (m.presentation?.shelf === "loras" || interaction === "adapter") return placed("lora");
2912
+ if (out.includes("video")) return placed("video_gen_model");
2913
+ if (out.includes("image")) return placed("image_gen_model");
2914
+ if (out.includes("embedding")) return placed("embedding_model");
2915
+ if (out.includes("audio")) return placed("tts_model_file");
2916
+ if (inp.includes("audio") && (out.includes("decision") || interaction === "detection")) return placed("wake_word_model");
2917
+ if (inp.includes("audio") && out.includes("text")) return placed("whisper_model");
2918
+ if (interaction === "extraction") return placed("ner_model");
2919
+ if (inp.includes("text") && out.includes("text") && LLM_INTERACTIONS.has(interaction)) return placed("llm_model");
2920
+ const shape = `input [${inp.join(", ")}], output [${out.join(", ")}], interaction ${interaction || "(none)"}`;
2921
+ return { kind: UNKNOWN_MODEL_KIND, reason: `no kind rule places ${shape}` };
2922
+ }
2923
+ function catalogKindOf(m, kindOfEntry) {
2924
+ return catalogKindVerdict(m, kindOfEntry).kind;
2847
2925
  }
2848
2926
  function canonicalJson(value) {
2849
2927
  if (value === void 0) return "null";
@@ -2922,6 +3000,8 @@ async function readCatalogWith(client, opts, preread) {
2922
3000
  const p = presentationOf.get(c.id);
2923
3001
  stamp(p);
2924
3002
  const maker = providerById.get(s3(m.provider_id));
3003
+ const verdict = catalogKindVerdict(c, kindOfEntry);
3004
+ if (verdict.reason) warnings.push(`${s3(m.name)}: kind unknown: ${verdict.reason}`);
2925
3005
  return [
2926
3006
  {
2927
3007
  id: s3(m.id),
@@ -2932,7 +3012,7 @@ async function readCatalogWith(client, opts, preread) {
2932
3012
  maker_logo_file_id: sn3(maker?.logo_file_id),
2933
3013
  description: sn3(m.description),
2934
3014
  capabilities: m.capabilities ?? {},
2935
- kind: catalogKindOf(c, kindOfEntry),
3015
+ kind: verdict.kind,
2936
3016
  offered: c.offered,
2937
3017
  updated_at: c.updated_at,
2938
3018
  presentation: p ? {