@avantf/dsh-mem 0.6.4 → 0.8.0

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 (150) hide show
  1. package/README.md +19 -10
  2. package/lib/client.js +1665 -3466
  3. package/lib/dsh-build.json +6 -5
  4. package/lib/engine/graph-recall/in-memory.d.ts +93 -0
  5. package/lib/engine/graph-recall/index.d.ts +22 -0
  6. package/lib/engine/graph-recall/traverse.d.ts +119 -0
  7. package/lib/engine/graph-recall/types.d.ts +188 -0
  8. package/lib/engine/mem/config/config_files.d.ts +1 -1
  9. package/lib/engine/mem/config/loader.d.ts +2 -3
  10. package/lib/engine/mem/config/paths.d.ts +2 -13
  11. package/lib/engine/mem/db/dao/contradictions.d.ts +4 -22
  12. package/lib/engine/mem/db/dao/entities.d.ts +80 -7
  13. package/lib/engine/mem/db/dao/fact_sources.d.ts +3 -13
  14. package/lib/engine/mem/db/dao/facts.d.ts +311 -56
  15. package/lib/engine/mem/db/dao/triples.d.ts +1 -26
  16. package/lib/engine/mem/db/graph.d.ts +249 -0
  17. package/lib/engine/mem/db/journal_notes.d.ts +35 -0
  18. package/lib/engine/mem/db/migrations.d.ts +9 -0
  19. package/lib/engine/mem/db/port.d.ts +22 -3
  20. package/lib/engine/mem/db/schema.d.ts +119 -0
  21. package/lib/engine/mem/db/tokenizer.d.ts +9 -0
  22. package/lib/engine/mem/dbdrivers/fake/driver.d.ts +75 -0
  23. package/lib/engine/mem/dbdrivers/fake/index.d.ts +7 -0
  24. package/lib/engine/mem/dbdrivers/fake/surface.d.ts +34 -0
  25. package/lib/engine/mem/dbdrivers/fake/transport.d.ts +61 -0
  26. package/lib/engine/mem/dbdrivers/sqlite/connection.d.ts +14 -0
  27. package/lib/engine/mem/dbdrivers/sqlite/contradictions.d.ts +35 -0
  28. package/lib/engine/mem/dbdrivers/sqlite/dao/index.d.ts +16 -0
  29. package/lib/engine/mem/dbdrivers/sqlite/driver.d.ts +54 -0
  30. package/lib/engine/mem/dbdrivers/sqlite/facts.d.ts +117 -0
  31. package/lib/engine/mem/dbdrivers/sqlite/index.d.ts +6 -0
  32. package/lib/engine/mem/dbdrivers/sqlite/migrations.d.ts +15 -0
  33. package/lib/engine/mem/dbdrivers/sqlite/relations.d.ts +62 -0
  34. package/lib/engine/mem/dbdrivers/sqlite/search.d.ts +56 -0
  35. package/lib/engine/mem/dbdrivers/sqlite/sources.d.ts +37 -0
  36. package/lib/engine/mem/defaults.d.ts +3 -4
  37. package/lib/engine/mem/dispatch.d.ts +7 -32
  38. package/lib/engine/mem/entities/extract.d.ts +44 -47
  39. package/lib/engine/mem/eval/derived_runner.d.ts +6 -1
  40. package/lib/engine/mem/eval/relation_gold.d.ts +251 -0
  41. package/lib/engine/mem/eval/write_metrics.d.ts +1 -1
  42. package/lib/engine/mem/facts_io.d.ts +328 -0
  43. package/lib/engine/mem/index.d.ts +10 -2
  44. package/lib/engine/mem/interfaces/capabilities.d.ts +30 -0
  45. package/lib/engine/mem/interfaces/common.d.ts +11 -0
  46. package/lib/engine/mem/interfaces/errors.d.ts +65 -0
  47. package/lib/engine/mem/interfaces/index.d.ts +18 -0
  48. package/lib/engine/mem/interfaces/migrations.d.ts +21 -0
  49. package/lib/engine/mem/interfaces/repositories.d.ts +471 -0
  50. package/lib/engine/mem/interfaces/search_index.d.ts +113 -0
  51. package/lib/engine/mem/interfaces/storage_backend.d.ts +84 -0
  52. package/lib/engine/mem/interfaces/storage_driver.d.ts +43 -0
  53. package/lib/engine/mem/interfaces/version.d.ts +34 -0
  54. package/lib/engine/mem/lifecycle/contradiction.d.ts +2 -2
  55. package/lib/engine/mem/maintenance_paths.d.ts +41 -0
  56. package/lib/engine/mem/modelBootstrap.d.ts +1 -1
  57. package/lib/engine/mem/relations/confidence.d.ts +39 -0
  58. package/lib/engine/mem/relations/extract.d.ts +128 -0
  59. package/lib/engine/mem/relations/index.d.ts +32 -0
  60. package/lib/engine/mem/relations/name-quality.d.ts +78 -0
  61. package/lib/engine/mem/relations/normalize.d.ts +275 -0
  62. package/lib/engine/mem/relations/patterns.d.ts +67 -0
  63. package/lib/engine/mem/relations/statement.d.ts +88 -0
  64. package/lib/engine/mem/relations/types.d.ts +79 -0
  65. package/lib/engine/mem/runtime.d.ts +117 -90
  66. package/lib/engine/mem/storage/create.d.ts +42 -0
  67. package/lib/engine/mem/storage/errors.d.ts +65 -0
  68. package/lib/engine/mem/storage/index.d.ts +15 -0
  69. package/lib/engine/mem/storage/ports.d.ts +472 -0
  70. package/lib/engine/mem/storage/registry.d.ts +37 -0
  71. package/lib/engine/mem/storage/sqlite.d.ts +28 -0
  72. package/lib/engine/mem/store/common.d.ts +1 -1
  73. package/lib/engine/mem/store/entity_leg.d.ts +59 -2
  74. package/lib/engine/mem/store/entity_sweep.d.ts +4 -3
  75. package/lib/engine/mem/store/explicit_relations.d.ts +52 -0
  76. package/lib/engine/mem/store/facts_restore.d.ts +124 -0
  77. package/lib/engine/mem/store/floors.d.ts +4 -1
  78. package/lib/engine/mem/store/graph_reader.d.ts +146 -0
  79. package/lib/engine/mem/store/hybrid.d.ts +50 -13
  80. package/lib/engine/mem/store/kinds.d.ts +47 -0
  81. package/lib/engine/mem/store/legs.d.ts +24 -29
  82. package/lib/engine/mem/store/lexical.d.ts +36 -45
  83. package/lib/engine/mem/store/memory.d.ts +486 -82
  84. package/lib/engine/mem/store/recall_policy.d.ts +49 -0
  85. package/lib/engine/mem/store/relation_backfill.d.ts +210 -0
  86. package/lib/engine/mem/store/relation_planner.d.ts +191 -0
  87. package/lib/engine/mem/store/secret_guard.d.ts +0 -1
  88. package/lib/engine/mem/store/self_query.d.ts +4 -2
  89. package/lib/engine/mem/store/time_filter.d.ts +121 -0
  90. package/lib/engine/mem/store/titles.d.ts +52 -0
  91. package/lib/engine/mem/store/vector_repair.d.ts +44 -54
  92. package/lib/engine/mem-contract/config.d.ts +44 -38
  93. package/lib/engine/mem-contract/text.d.ts +1 -1
  94. package/lib/engine/mem-contract/tools.d.ts +184 -117
  95. package/lib/engine/mem-contract/types.d.ts +364 -288
  96. package/lib/index.js +13898 -11500
  97. package/lib/interface-version.json +1 -1
  98. package/lib/types/client/index.d.ts +2 -2
  99. package/lib/types/client/index.d.ts.map +1 -1
  100. package/lib/types/client/paging.d.ts +3 -12
  101. package/lib/types/client/paging.d.ts.map +1 -1
  102. package/lib/types/client/summarize.d.ts.map +1 -1
  103. package/lib/types/command.d.ts +61 -0
  104. package/lib/types/command.d.ts.map +1 -0
  105. package/lib/types/envinit-bootstrap.d.ts +1 -1
  106. package/lib/types/envinit.d.ts +2 -6
  107. package/lib/types/envinit.d.ts.map +1 -1
  108. package/lib/types/hints.d.ts +28 -24
  109. package/lib/types/hints.d.ts.map +1 -1
  110. package/lib/types/index.d.ts +21 -40
  111. package/lib/types/index.d.ts.map +1 -1
  112. package/lib/types/inject.d.ts +3 -2
  113. package/lib/types/inject.d.ts.map +1 -1
  114. package/lib/types/interface_gate.d.ts +9 -9
  115. package/lib/types/prompt.d.ts +17 -41
  116. package/lib/types/prompt.d.ts.map +1 -1
  117. package/lib/types/provision.d.ts +3 -0
  118. package/lib/types/provision.d.ts.map +1 -1
  119. package/lib/types/remote.d.ts +23 -9
  120. package/lib/types/remote.d.ts.map +1 -1
  121. package/lib/types/render.d.ts +3 -3
  122. package/lib/types/tool_schema.d.ts +4 -0
  123. package/lib/types/tool_schema.d.ts.map +1 -1
  124. package/lib/types/vectorMigration.d.ts +5 -7
  125. package/lib/types/vectorMigration.d.ts.map +1 -1
  126. package/package.json +16 -15
  127. package/lib/engine/mem/config/domains.d.ts +0 -20
  128. package/lib/engine/mem/db/dao/chunks.d.ts +0 -231
  129. package/lib/engine/mem/db/dao/documents.d.ts +0 -51
  130. package/lib/engine/mem/db/hash.d.ts +0 -2
  131. package/lib/engine/mem/db/knowledge.d.ts +0 -17
  132. package/lib/engine/mem/eval/index.d.ts +0 -4
  133. package/lib/engine/mem/git.d.ts +0 -73
  134. package/lib/engine/mem/router.d.ts +0 -51
  135. package/lib/engine/mem/store/doc_files.d.ts +0 -125
  136. package/lib/engine/mem/store/document_text.d.ts +0 -47
  137. package/lib/engine/mem/store/ingest_guard.d.ts +0 -25
  138. package/lib/engine/mem/store/knowledge.d.ts +0 -598
  139. package/lib/engine/mem/store/source_picker.d.ts +0 -43
  140. package/lib/engine/mem-retrieval/adapters/local_reranker.d.ts +0 -52
  141. package/lib/engine/mem-retrieval/adapters/none_reranker.d.ts +0 -10
  142. package/lib/engine/mem-retrieval/rerank.d.ts +0 -13
  143. package/lib/types/client/domains.d.ts +0 -53
  144. package/lib/types/client/domains.d.ts.map +0 -1
  145. package/lib/types/client/ingest.d.ts +0 -24
  146. package/lib/types/client/ingest.d.ts.map +0 -1
  147. package/lib/types/open.d.ts +0 -77
  148. package/lib/types/open.d.ts.map +0 -1
  149. package/lib/types/reconcile.d.ts +0 -64
  150. package/lib/types/reconcile.d.ts.map +0 -1
@@ -1,6 +1,42 @@
1
1
  import { z } from 'zod';
2
+ import { type StatusFilter } from './types.js';
3
+ /**
4
+ * One structured relation a WRITE may declare (STRUCTURED_RELATIONS §2).
5
+ *
6
+ * It is the caller STATING a relation, not the extractor guessing one, which is why
7
+ * `kind: "note"` is the only layer that accepts it: a journal entry is an episode, and a relation
8
+ * that is worth remembering is a fact about the world (promote it: write a note, `source_ref` it
9
+ * back to the journal). Every slot is a NAME — the engine runs it through the same entity/predicate
10
+ * normalization and the same name-shape gate the extractor's edges pass.
11
+ */
12
+ export declare const RelationInputSchema: z.ZodObject<{
13
+ subject: z.ZodString;
14
+ predicate: z.ZodString;
15
+ object: z.ZodString;
16
+ }, z.core.$strict>;
17
+ /** One structured relation, as a write carries it. */
18
+ export type RelationInput = z.infer<typeof RelationInputSchema>;
19
+ /**
20
+ * How many relations ONE write may declare.
21
+ *
22
+ * A single fact states a handful of relations; a caller passing dozens has stopped describing a
23
+ * fact and started importing a graph. The cap keeps one call's work bounded (and the tool argument
24
+ * readable) without pretending to be a per-fact model of the corpus.
25
+ */
26
+ export declare const MAX_RELATIONS_PER_WRITE = 20;
2
27
  export declare const CONTRADICTION_RESOLUTIONS: readonly ["true_positive", "false_positive"];
3
- export declare const QUERY_KINDS: readonly ["all", "fact", "doc_chunk"];
28
+ /** The `time` object of `mem_recall`'s two time-aware actions. */
29
+ export declare const TimeFilterSchema: z.ZodObject<{
30
+ field: z.ZodEnum<{
31
+ created: "created";
32
+ updated: "updated";
33
+ event: "event";
34
+ }>;
35
+ on: z.ZodOptional<z.ZodString>;
36
+ from: z.ZodOptional<z.ZodString>;
37
+ to: z.ZodOptional<z.ZodString>;
38
+ timezone: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>;
4
40
  /**
5
41
  * The longest retrieval query the contract accepts, in characters.
6
42
  *
@@ -35,7 +71,7 @@ export declare const MAX_REPORTED_CONFLICTS = 20;
35
71
  */
36
72
  export declare const RETENTION_VOCABULARY: readonly ["衰减", "消退", "遗忘", "强化", "活跃使用日", "信任度", "永久记忆", "长期有效的信息"];
37
73
  /**
38
- * Admin actions that return a FACT VIEW. Their payload goes through
74
+ * The admin actions that return a FACT VIEW. Their payload goes through
39
75
  * {@link modelFacingToolResult}, which drops the retention diagnostics; the other admin
40
76
  * actions (`trust_diagnose`, `vectors_diagnose`, …) are diagnostics the caller asked for and
41
77
  * pass through untouched.
@@ -48,24 +84,50 @@ export declare const FACT_VIEW_ADMIN_ACTIONS: readonly ["list", "detail"];
48
84
  * explicitly with `mem_admin`'s diagnostic actions.
49
85
  */
50
86
  export declare function modelFacingToolResult(toolKey: string, action: unknown, value: unknown): unknown;
87
+ /**
88
+ * The statuses an export may narrow to. Declared here (next to the tool schema that exposes it) so
89
+ * the core export path, the CLI flag validation and the admin action read ONE set: a value added
90
+ * here moves the contract, the CLI and the engine together.
91
+ */
92
+ export declare const EXPORT_STATUSES: readonly ["active", "archived", "all"];
93
+ export type ExportStatus = StatusFilter;
51
94
  export declare const REMEMBER_ACTIONS: readonly ["add", "update", "remove", "helpful", "unhelpful"];
52
95
  export declare const RememberUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
96
  action: z.ZodLiteral<"add">;
54
97
  content: z.ZodString;
55
- category: z.ZodOptional<z.ZodString>;
98
+ kind: z.ZodOptional<z.ZodEnum<{
99
+ journal: "journal";
100
+ note: "note";
101
+ }>>;
102
+ title: z.ZodOptional<z.ZodString>;
56
103
  ttl_days: z.ZodOptional<z.ZodNumber>;
57
104
  source_ref: z.ZodOptional<z.ZodString>;
58
105
  event_date: z.ZodOptional<z.ZodString>;
59
106
  valid_until: z.ZodOptional<z.ZodString>;
107
+ relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
108
+ subject: z.ZodString;
109
+ predicate: z.ZodString;
110
+ object: z.ZodString;
111
+ }, z.core.$strict>>>;
60
112
  }, z.core.$strip>, z.ZodObject<{
61
113
  action: z.ZodLiteral<"update">;
62
114
  fact_id: z.ZodNumber;
63
115
  content: z.ZodString;
64
- category: z.ZodOptional<z.ZodString>;
116
+ kind: z.ZodOptional<z.ZodEnum<{
117
+ journal: "journal";
118
+ note: "note";
119
+ }>>;
120
+ title: z.ZodOptional<z.ZodString>;
121
+ retitle: z.ZodOptional<z.ZodLiteral<true>>;
65
122
  ttl_days: z.ZodOptional<z.ZodNumber>;
66
123
  source_ref: z.ZodOptional<z.ZodString>;
67
124
  event_date: z.ZodOptional<z.ZodString>;
68
125
  valid_until: z.ZodOptional<z.ZodString>;
126
+ relations: z.ZodOptional<z.ZodArray<z.ZodObject<{
127
+ subject: z.ZodString;
128
+ predicate: z.ZodString;
129
+ object: z.ZodString;
130
+ }, z.core.$strict>>>;
69
131
  }, z.core.$strip>, z.ZodObject<{
70
132
  action: z.ZodLiteral<"remove">;
71
133
  fact_id: z.ZodNumber;
@@ -77,13 +139,36 @@ export declare const RememberUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
77
139
  action: z.ZodLiteral<"unhelpful">;
78
140
  fact_id: z.ZodNumber;
79
141
  }, z.core.$strip>], "action">;
142
+ /**
143
+ * The runtime/CLI-visible write request. The base zod union keeps `kind` optional so the CLI's
144
+ * `add` without `--kind` (new row -> note) and `edit` without it (inherit the replaced row) keep
145
+ * working; the MODEL-facing `ModelRememberUnion` below re-declares it as required (N7).
146
+ */
80
147
  export type RememberRequest = z.infer<typeof RememberUnion>;
81
- export declare const RECALL_ACTIONS: readonly ["search", "ask", "chain", "probe", "reason", "related", "contradict"];
148
+ /**
149
+ * The writes the model may make. `helpful` / `unhelpful` are operator feedback: the model cannot
150
+ * observe the retention clocks they move, and a model that could would be able to "refresh" a fact by
151
+ * voting on it — the exact behaviour the retention policy exists to prevent.
152
+ */
153
+ export declare const MODEL_REMEMBER_ACTIONS: readonly ["add", "update", "remove"];
154
+ export declare const ModelRememberUnion: z.ZodDiscriminatedUnion<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], string>;
155
+ /**
156
+ * The public recall surface: TWO actions (docs/RECALL_INTERFACE.md).
157
+ *
158
+ * The engine decides whether a query is answered by the literal (exact) pass or by the fuzzy
159
+ * retrieval; the caller never chooses, never passes a relevance threshold, and never sees the
160
+ * pagination knobs of the fuzzy pass. `search` is content, `titles` is title — nothing else.
161
+ */
162
+ export declare const RECALL_ACTIONS: readonly ["search", "titles"];
82
163
  export declare const RecallUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
83
164
  action: z.ZodLiteral<"search">;
84
- query: z.ZodString;
85
- category: z.ZodOptional<z.ZodString>;
165
+ query: z.ZodOptional<z.ZodString>;
166
+ kind: z.ZodOptional<z.ZodEnum<{
167
+ journal: "journal";
168
+ note: "note";
169
+ }>>;
86
170
  source: z.ZodOptional<z.ZodString>;
171
+ offset: z.ZodOptional<z.ZodNumber>;
87
172
  limit: z.ZodOptional<z.ZodNumber>;
88
173
  max_tokens: z.ZodOptional<z.ZodNumber>;
89
174
  floors: z.ZodOptional<z.ZodEnum<{
@@ -91,51 +176,76 @@ export declare const RecallUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
91
176
  loose: "loose";
92
177
  }>>;
93
178
  include_scores: z.ZodOptional<z.ZodBoolean>;
179
+ time: z.ZodOptional<z.ZodObject<{
180
+ field: z.ZodEnum<{
181
+ created: "created";
182
+ updated: "updated";
183
+ event: "event";
184
+ }>;
185
+ on: z.ZodOptional<z.ZodString>;
186
+ from: z.ZodOptional<z.ZodString>;
187
+ to: z.ZodOptional<z.ZodString>;
188
+ timezone: z.ZodOptional<z.ZodString>;
189
+ }, z.core.$strict>>;
94
190
  }, z.core.$strip>, z.ZodObject<{
95
- action: z.ZodLiteral<"ask">;
96
- subj: z.ZodOptional<z.ZodString>;
97
- pred: z.ZodOptional<z.ZodString>;
98
- obj: z.ZodOptional<z.ZodString>;
99
- query: z.ZodOptional<z.ZodString>;
100
- limit: z.ZodOptional<z.ZodNumber>;
101
- }, z.core.$strip>, z.ZodObject<{
102
- action: z.ZodLiteral<"chain">;
103
- subj: z.ZodString;
104
- pred: z.ZodOptional<z.ZodString>;
105
- second_pred: z.ZodOptional<z.ZodString>;
106
- limit: z.ZodOptional<z.ZodNumber>;
107
- }, z.core.$strip>, z.ZodObject<{
108
- action: z.ZodLiteral<"probe">;
109
- entity: z.ZodString;
110
- category: z.ZodOptional<z.ZodString>;
111
- limit: z.ZodOptional<z.ZodNumber>;
112
- }, z.core.$strip>, z.ZodObject<{
113
- action: z.ZodLiteral<"reason">;
114
- entities: z.ZodArray<z.ZodString>;
115
- category: z.ZodOptional<z.ZodString>;
116
- limit: z.ZodOptional<z.ZodNumber>;
117
- }, z.core.$strip>, z.ZodObject<{
118
- action: z.ZodLiteral<"related">;
119
- entity: z.ZodString;
120
- category: z.ZodOptional<z.ZodString>;
121
- limit: z.ZodOptional<z.ZodNumber>;
122
- }, z.core.$strip>, z.ZodObject<{
123
- action: z.ZodLiteral<"contradict">;
124
- category: z.ZodOptional<z.ZodString>;
191
+ action: z.ZodLiteral<"titles">;
192
+ query: z.ZodString;
193
+ kind: z.ZodOptional<z.ZodEnum<{
194
+ journal: "journal";
195
+ note: "note";
196
+ }>>;
197
+ status: z.ZodOptional<z.ZodEnum<{
198
+ active: "active";
199
+ archived: "archived";
200
+ all: "all";
201
+ }>>;
202
+ time: z.ZodOptional<z.ZodObject<{
203
+ field: z.ZodEnum<{
204
+ created: "created";
205
+ updated: "updated";
206
+ event: "event";
207
+ }>;
208
+ on: z.ZodOptional<z.ZodString>;
209
+ from: z.ZodOptional<z.ZodString>;
210
+ to: z.ZodOptional<z.ZodString>;
211
+ timezone: z.ZodOptional<z.ZodString>;
212
+ }, z.core.$strict>>;
213
+ offset: z.ZodOptional<z.ZodNumber>;
125
214
  limit: z.ZodOptional<z.ZodNumber>;
215
+ include_excerpt: z.ZodOptional<z.ZodBoolean>;
126
216
  }, z.core.$strip>], "action">;
127
217
  export type RecallRequest = z.infer<typeof RecallUnion>;
128
- export declare const ADMIN_ACTIONS: readonly ["stats", "list", "detail", "archive", "restore", "pin", "unpin", "trust_diagnose", "vectors_diagnose", "vectors_fix", "contradict_check", "contradict_resolve", "maintenance"];
218
+ /**
219
+ * The retrieval actions the model may call: content and title, nothing else. Exact-vs-fuzzy,
220
+ * thresholds, topK and paging are the ENGINE's rules (docs/RECALL_INTERFACE.md §1).
221
+ */
222
+ export declare const MODEL_RECALL_ACTIONS: readonly ["search", "titles"];
223
+ export declare const ModelRecallUnion: z.ZodDiscriminatedUnion<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], string>;
224
+ export declare const ADMIN_ACTIONS: readonly ["stats", "list", "detail", "archive", "restore", "pin", "unpin", "trust_diagnose", "vectors_diagnose", "vectors_fix", "contradict_check", "contradict_resolve", "contradictions", "maintenance", "export", "import", "merge", "restore_snapshot"];
129
225
  export declare const AdminUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
130
226
  action: z.ZodLiteral<"stats">;
131
227
  }, z.core.$strip>, z.ZodObject<{
132
228
  action: z.ZodLiteral<"list">;
133
- category: z.ZodOptional<z.ZodString>;
229
+ kind: z.ZodOptional<z.ZodEnum<{
230
+ journal: "journal";
231
+ note: "note";
232
+ }>>;
134
233
  status: z.ZodOptional<z.ZodEnum<{
135
234
  active: "active";
136
235
  archived: "archived";
137
236
  }>>;
138
237
  source: z.ZodOptional<z.ZodString>;
238
+ time: z.ZodOptional<z.ZodObject<{
239
+ field: z.ZodEnum<{
240
+ created: "created";
241
+ updated: "updated";
242
+ event: "event";
243
+ }>;
244
+ on: z.ZodOptional<z.ZodString>;
245
+ from: z.ZodOptional<z.ZodString>;
246
+ to: z.ZodOptional<z.ZodString>;
247
+ timezone: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strict>>;
139
249
  limit: z.ZodOptional<z.ZodNumber>;
140
250
  offset: z.ZodOptional<z.ZodNumber>;
141
251
  }, z.core.$strip>, z.ZodObject<{
@@ -161,12 +271,15 @@ export declare const AdminUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
161
271
  }, z.core.$strip>, z.ZodObject<{
162
272
  action: z.ZodLiteral<"vectors_fix">;
163
273
  dry_run: z.ZodOptional<z.ZodBoolean>;
164
- store: z.ZodOptional<z.ZodEnum<{
165
- memory: "memory";
166
- knowledge: "knowledge";
167
- }>>;
168
274
  }, z.core.$strip>, z.ZodObject<{
169
275
  action: z.ZodLiteral<"contradict_check">;
276
+ }, z.core.$strip>, z.ZodObject<{
277
+ action: z.ZodLiteral<"contradictions">;
278
+ kind: z.ZodOptional<z.ZodEnum<{
279
+ journal: "journal";
280
+ note: "note";
281
+ }>>;
282
+ limit: z.ZodOptional<z.ZodNumber>;
170
283
  }, z.core.$strip>, z.ZodObject<{
171
284
  action: z.ZodLiteral<"contradict_resolve">;
172
285
  contradiction_id: z.ZodNumber;
@@ -177,65 +290,41 @@ export declare const AdminUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
177
290
  loser_fact_id: z.ZodOptional<z.ZodNumber>;
178
291
  }, z.core.$strip>, z.ZodObject<{
179
292
  action: z.ZodLiteral<"maintenance">;
180
- }, z.core.$strip>], "action">;
181
- export type AdminRequest = z.infer<typeof AdminUnion>;
182
- /** The `source` a write gets when it omits one; a document's identity is `(domain, source, title)`. */
183
- export declare const DEFAULT_KB_SOURCE = "default";
184
- export declare const KbUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
185
- action: z.ZodLiteral<"ingest">;
186
- text: z.ZodOptional<z.ZodString>;
187
- source_uri: z.ZodOptional<z.ZodString>;
188
- domain: z.ZodString;
189
- source: z.ZodDefault<z.ZodOptional<z.ZodString>>;
190
- title: z.ZodOptional<z.ZodString>;
191
- overwrite: z.ZodOptional<z.ZodBoolean>;
192
293
  }, z.core.$strip>, z.ZodObject<{
193
- action: z.ZodLiteral<"import">;
194
- paths: z.ZodArray<z.ZodString>;
195
- domain: z.ZodString;
196
- source: z.ZodDefault<z.ZodOptional<z.ZodString>>;
197
- overwrite: z.ZodOptional<z.ZodBoolean>;
198
- }, z.core.$strip>, z.ZodObject<{
199
- action: z.ZodLiteral<"list">;
200
- domain: z.ZodOptional<z.ZodString>;
201
- source: z.ZodOptional<z.ZodString>;
202
- limit: z.ZodOptional<z.ZodNumber>;
203
- offset: z.ZodOptional<z.ZodNumber>;
204
- }, z.core.$strip>, z.ZodObject<{
205
- action: z.ZodLiteral<"detail">;
206
- doc_id: z.ZodNumber;
294
+ action: z.ZodLiteral<"export">;
295
+ status: z.ZodOptional<z.ZodEnum<{
296
+ active: "active";
297
+ archived: "archived";
298
+ all: "all";
299
+ }>>;
300
+ file: z.ZodOptional<z.ZodString>;
207
301
  }, z.core.$strip>, z.ZodObject<{
208
- action: z.ZodLiteral<"remove">;
209
- doc_id: z.ZodNumber;
302
+ action: z.ZodLiteral<"import">;
303
+ file: z.ZodString;
304
+ dry_run: z.ZodOptional<z.ZodBoolean>;
210
305
  }, z.core.$strip>, z.ZodObject<{
211
- action: z.ZodLiteral<"reindex">;
212
- domain: z.ZodOptional<z.ZodString>;
306
+ action: z.ZodLiteral<"merge">;
307
+ file: z.ZodString;
213
308
  dry_run: z.ZodOptional<z.ZodBoolean>;
214
309
  }, z.core.$strip>, z.ZodObject<{
215
- action: z.ZodLiteral<"sync">;
216
- doc_id: z.ZodOptional<z.ZodNumber>;
217
- adopt: z.ZodOptional<z.ZodBoolean>;
310
+ action: z.ZodLiteral<"restore_snapshot">;
311
+ file: z.ZodString;
312
+ confirm: z.ZodLiteral<true>;
218
313
  dry_run: z.ZodOptional<z.ZodBoolean>;
219
314
  }, z.core.$strip>], "action">;
220
- export type KbRequest = z.infer<typeof KbUnion>;
221
- export declare const QueryUnion: z.ZodObject<{
222
- query: z.ZodString;
223
- kind: z.ZodOptional<z.ZodEnum<{
224
- fact: "fact";
225
- doc_chunk: "doc_chunk";
226
- all: "all";
227
- }>>;
228
- max_tokens: z.ZodOptional<z.ZodNumber>;
229
- domain: z.ZodOptional<z.ZodString>;
230
- source: z.ZodOptional<z.ZodString>;
231
- limit: z.ZodDefault<z.ZodNumber>;
232
- floors: z.ZodOptional<z.ZodEnum<{
233
- strict: "strict";
234
- loose: "loose";
235
- }>>;
236
- include_scores: z.ZodOptional<z.ZodBoolean>;
237
- }, z.core.$strip>;
238
- export type QueryRequest = z.infer<typeof QueryUnion>;
315
+ export type AdminRequest = z.infer<typeof AdminUnion>;
316
+ /**
317
+ * The admin actions the model may call: a fact page plus the backup/restore family.
318
+ *
319
+ * Everything else is OPERATOR machinery: diagnostics and repairs (the model cannot see trust values
320
+ * and must not rerun the embedding strategy), curation (pin/archive/contradiction verdicts), and
321
+ * duplicates of what is already model-facing (`detail` is a single-fact view of the same page;
322
+ * `contradictions` is the operator's list of open pairs, plus its verdict action; `merge` is what
323
+ * `import` now does automatically for a SQLite file). The full union stays for the runtime, the
324
+ * Remote gateway (the settings page drives every action) and the CLI.
325
+ */
326
+ export declare const MODEL_ADMIN_ACTIONS: readonly ["list", "contradictions", "export", "import", "restore_snapshot"];
327
+ export declare const ModelAdminUnion: z.ZodDiscriminatedUnion<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], string>;
239
328
  /** Transport-agnostic tool spec: name / key / description / zod input. */
240
329
  export interface ToolSpec {
241
330
  key: string;
@@ -246,28 +335,6 @@ export interface ToolSpec {
246
335
  export declare const REMEMBER_TOOL: ToolSpec;
247
336
  export declare const RECALL_TOOL: ToolSpec;
248
337
  export declare const ADMIN_TOOL: ToolSpec;
249
- export declare const KB_TOOL: ToolSpec;
250
- export declare const QUERY_TOOL: ToolSpec;
251
- /** One new document, or a batch import — never an update (see the tool description). */
252
- export declare const KB_ADD_TOOL: ToolSpec;
253
- /**
254
- * The parsed `kb_add` input, no `overwrite`: the add-only MODE is a property of the runtime face
255
- * (`rt.kbAdd`), not a field the model can set. Spelled out (rather than `z.infer` of
256
- * `KB_ADD_TOOL.input`, which is widened to `z.ZodType` by `ToolSpec`) so the runtime method and the
257
- * plugin handler agree on the request. `source` is present because the contract defaults it.
258
- */
259
- export interface KbAddRequest {
260
- domain: string;
261
- source: string;
262
- title?: string;
263
- text?: string;
264
- source_uri?: string;
265
- paths?: string[];
266
- }
267
- /** The corpus listing, with the managed path — the entry point for editing a document. */
268
- export declare const KB_LIST_TOOL: ToolSpec;
269
- export declare const KB_REMOVE_TOOL: ToolSpec;
270
- export declare const KB_REINDEX_TOOL: ToolSpec;
271
338
  export declare const TOOL_SPECS: ToolSpec[];
272
339
  /**
273
340
  * Compose the top-level (merged) description for a union field.