@avantf/dsh-mem 0.3.0 → 0.4.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.
- package/README.md +89 -28
- package/cordis.patch.yml +17 -0
- package/lib/client.js +155 -14
- package/lib/dsh-build.json +5 -5
- package/lib/engine/mem/config/config_files.d.ts +26 -0
- package/lib/engine/mem/config/domains.d.ts +20 -0
- package/lib/engine/mem/config/loader.d.ts +35 -0
- package/lib/engine/mem/config/paths.d.ts +53 -0
- package/lib/engine/mem/db/chunk.d.ts +26 -0
- package/lib/engine/mem/db/conn.d.ts +13 -0
- package/lib/engine/mem/db/dao/chunks.d.ts +150 -0
- package/lib/engine/mem/db/dao/contradictions.d.ts +98 -0
- package/lib/engine/mem/db/dao/documents.d.ts +51 -0
- package/lib/engine/mem/db/dao/entities.d.ts +67 -0
- package/lib/engine/mem/db/dao/facts.d.ts +472 -0
- package/lib/engine/mem/db/dao/stats.d.ts +14 -0
- package/lib/engine/mem/db/dao/triples.d.ts +80 -0
- package/lib/engine/mem/db/hash.d.ts +2 -0
- package/lib/engine/mem/db/knowledge.d.ts +17 -0
- package/lib/engine/mem/db/migrations.d.ts +71 -0
- package/lib/engine/mem/db/port.d.ts +57 -0
- package/lib/engine/mem/db/schema.d.ts +26 -0
- package/lib/engine/mem/db/sqlite.d.ts +89 -0
- package/lib/engine/mem/db/store.d.ts +35 -0
- package/lib/engine/mem/db/tokenizer.d.ts +61 -0
- package/lib/engine/mem/db/vectors.d.ts +50 -0
- package/lib/engine/mem/dispatch.d.ts +51 -0
- package/lib/engine/mem/entities/extract.d.ts +84 -0
- package/lib/engine/mem/eval/loader.d.ts +19 -0
- package/lib/engine/mem/eval/metrics.d.ts +25 -0
- package/lib/engine/mem/eval/runner.d.ts +10 -0
- package/lib/engine/mem/eval/write_metrics.d.ts +88 -0
- package/lib/engine/mem/git.d.ts +73 -0
- package/lib/engine/mem/hrr/algebra.d.ts +30 -0
- package/lib/engine/mem/hrr/atoms.d.ts +22 -0
- package/lib/engine/mem/hrr/encode.d.ts +32 -0
- package/lib/engine/mem/hrr/index.d.ts +3 -0
- package/lib/engine/mem/index.d.ts +27 -0
- package/lib/engine/mem/lifecycle/contradiction.d.ts +156 -0
- package/lib/engine/mem/lifecycle/index.d.ts +5 -0
- package/lib/engine/mem/lifecycle/maintenance.d.ts +48 -0
- package/lib/engine/mem/lifecycle/presence.d.ts +29 -0
- package/lib/engine/mem/lifecycle/tick.d.ts +43 -0
- package/lib/engine/mem/lifecycle/trust.d.ts +90 -0
- package/lib/engine/mem/modelBootstrap.d.ts +207 -0
- package/lib/engine/mem/router.d.ts +51 -0
- package/lib/engine/mem/runtime.d.ts +232 -0
- package/lib/engine/mem/store/common.d.ts +82 -0
- package/lib/engine/mem/store/doc_files.d.ts +125 -0
- package/lib/engine/mem/store/document_text.d.ts +47 -0
- package/lib/engine/mem/store/floors.d.ts +191 -0
- package/lib/engine/mem/store/hybrid.d.ts +232 -0
- package/lib/engine/mem/store/ingest_guard.d.ts +25 -0
- package/lib/engine/mem/store/knowledge.d.ts +483 -0
- package/lib/engine/mem/store/lexical.d.ts +67 -0
- package/lib/engine/mem/store/memory.d.ts +543 -0
- package/lib/engine/mem/store/source_picker.d.ts +43 -0
- package/lib/engine/mem-contract/config.d.ts +129 -0
- package/lib/engine/mem-contract/env.d.ts +31 -0
- package/lib/engine/mem-contract/family.d.ts +25 -0
- package/lib/engine/mem-contract/index.d.ts +8 -0
- package/lib/engine/mem-contract/log.d.ts +29 -0
- package/lib/engine/mem-contract/remote.d.ts +80 -0
- package/lib/engine/mem-contract/text.d.ts +92 -0
- package/lib/engine/mem-contract/tools.d.ts +284 -0
- package/lib/engine/mem-contract/types.d.ts +615 -0
- package/lib/engine/mem-retrieval/adapters/auto_vstore.d.ts +47 -0
- package/lib/engine/mem-retrieval/adapters/hnswlib.d.ts +174 -0
- package/lib/engine/mem-retrieval/adapters/local_bge.d.ts +121 -0
- package/lib/engine/mem-retrieval/adapters/local_numpy.d.ts +28 -0
- package/lib/engine/mem-retrieval/adapters/local_reranker.d.ts +52 -0
- package/lib/engine/mem-retrieval/adapters/none_reranker.d.ts +10 -0
- package/lib/engine/mem-retrieval/adapters/warm_gate.d.ts +46 -0
- package/lib/engine/mem-retrieval/budget.d.ts +30 -0
- package/lib/engine/mem-retrieval/fusion.d.ts +53 -0
- package/lib/engine/mem-retrieval/index.d.ts +14 -0
- package/lib/engine/mem-retrieval/interfaces.d.ts +82 -0
- package/lib/engine/mem-retrieval/log.d.ts +11 -0
- package/lib/engine/mem-retrieval/registry.d.ts +23 -0
- package/lib/engine/mem-retrieval/rerank.d.ts +13 -0
- package/lib/engine/mem-retrieval/stats.d.ts +64 -0
- package/lib/engine/mem-retrieval/text_budget.d.ts +52 -0
- package/lib/index.js +1773 -473
- package/lib/interface-version.json +2 -2
- package/lib/types/client/domains.d.ts +5 -4
- package/lib/types/client/domains.d.ts.map +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/ingest.d.ts +1 -1
- package/lib/types/client/wire.d.ts +36 -0
- package/lib/types/client/wire.d.ts.map +1 -0
- package/lib/types/envinit-bootstrap.d.ts +3 -2
- package/lib/types/envinit.d.ts +2 -19
- package/lib/types/envinit.d.ts.map +1 -1
- package/lib/types/hints.d.ts +1 -1
- package/lib/types/index.d.ts +8 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/open.d.ts +61 -11
- package/lib/types/open.d.ts.map +1 -1
- package/lib/types/prompt.d.ts +19 -1
- package/lib/types/prompt.d.ts.map +1 -1
- package/lib/types/provision.d.ts +1 -1
- package/lib/types/provision.d.ts.map +1 -1
- package/lib/types/reconcile.d.ts +64 -0
- package/lib/types/reconcile.d.ts.map +1 -0
- package/lib/types/remote.d.ts +53 -0
- package/lib/types/remote.d.ts.map +1 -1
- package/lib/types/render.d.ts +35 -0
- package/lib/types/render.d.ts.map +1 -0
- package/lib/types/tool_schema.d.ts +3 -13
- package/lib/types/tool_schema.d.ts.map +1 -1
- package/package.json +27 -18
- package/lib/client.js.map +0 -1
- package/lib/types/client/domains.js +0 -25
- package/lib/types/client/domains.js.map +0 -1
- package/lib/types/client/index.js +0 -1371
- package/lib/types/client/index.js.map +0 -1
- package/lib/types/client/ingest.js +0 -30
- package/lib/types/client/ingest.js.map +0 -1
- package/lib/types/client/paging.js +0 -36
- package/lib/types/client/paging.js.map +0 -1
- package/lib/types/client/summarize.js +0 -79
- package/lib/types/client/summarize.js.map +0 -1
- package/lib/types/data_home.js +0 -26
- package/lib/types/data_home.js.map +0 -1
- package/lib/types/envinit-bootstrap.js +0 -333
- package/lib/types/envinit.js +0 -402
- package/lib/types/envinit.js.map +0 -1
- package/lib/types/hints.js +0 -53
- package/lib/types/hints.js.map +0 -1
- package/lib/types/index.js +0 -755
- package/lib/types/index.js.map +0 -1
- package/lib/types/inject.js +0 -14
- package/lib/types/inject.js.map +0 -1
- package/lib/types/interface_gate.js +0 -84
- package/lib/types/interface_gate.js.map +0 -1
- package/lib/types/open.js +0 -133
- package/lib/types/open.js.map +0 -1
- package/lib/types/prompt.js +0 -148
- package/lib/types/prompt.js.map +0 -1
- package/lib/types/provision.js +0 -177
- package/lib/types/provision.js.map +0 -1
- package/lib/types/remote.js +0 -247
- package/lib/types/remote.js.map +0 -1
- package/lib/types/tool_schema.js +0 -149
- package/lib/types/tool_schema.js.map +0 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CONTRADICTION_RESOLUTIONS: readonly ["true_positive", "false_positive"];
|
|
3
|
+
export declare const QUERY_KINDS: readonly ["all", "fact", "doc_chunk"];
|
|
4
|
+
/**
|
|
5
|
+
* The longest retrieval query the contract accepts, in characters.
|
|
6
|
+
*
|
|
7
|
+
* There is no useful query beyond this, and there IS a cost: a CJK query is expanded into one trigram
|
|
8
|
+
* OR-phrase per character and evaluated by SQLite **synchronously on the host's event loop** (200 000
|
|
9
|
+
* characters measured at 119 seconds, of which the expansion was 27–52 ms — the rest was `MATCH`). The
|
|
10
|
+
* cap belongs HERE because every entry point derives from this union: the plugin's tools, the MCP
|
|
11
|
+
* inputSchema, the CLI's argv validation and the browser payload are all this same object.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_QUERY_CHARS = 2000;
|
|
14
|
+
export type ContradictionResolution = (typeof CONTRADICTION_RESOLUTIONS)[number];
|
|
15
|
+
/** Action unions — one source of truth for tool schemas, MCP inputSchema, CLI args, UI payloads. */
|
|
16
|
+
/**
|
|
17
|
+
* Cap on the conflicts reported back to a WRITER. A hub fact can be named in many open
|
|
18
|
+
* pairs, and the write path's payload goes to a model; the full list stays available
|
|
19
|
+
* through `contradict` / the settings page. Ordered by score, so a cap drops the least
|
|
20
|
+
* severe first.
|
|
21
|
+
*
|
|
22
|
+
* Declared here (not in `core`) because the write path takes the cap from the contract. The
|
|
23
|
+
* `mem_remember` description deliberately does NOT state the number any more — model-facing
|
|
24
|
+
* text describes what a call does, never the shape of its result.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MAX_REPORTED_CONFLICTS = 20;
|
|
27
|
+
/**
|
|
28
|
+
* Vocabulary that describes HOW memory is retained, banned from every model-facing string.
|
|
29
|
+
*
|
|
30
|
+
* The model cannot observe those clocks and has no action to take on them; the one thing such
|
|
31
|
+
* text enables is rewriting a fact to "refresh" it, which defeats the policy it just described.
|
|
32
|
+
* It binds every tool description and parameter description AND the DSH plugin's system-prompt
|
|
33
|
+
* section, because the prompt section is prompt text too and a second copy of the list is a copy
|
|
34
|
+
* that drifts.
|
|
35
|
+
*/
|
|
36
|
+
export declare const RETENTION_VOCABULARY: readonly ["衰减", "消退", "遗忘", "强化", "活跃使用日", "信任度", "永久记忆", "长期有效的信息"];
|
|
37
|
+
/**
|
|
38
|
+
* Admin actions that return a FACT VIEW. Their payload goes through
|
|
39
|
+
* {@link modelFacingToolResult}, which drops the retention diagnostics; the other admin
|
|
40
|
+
* actions (`trust_diagnose`, `vectors_diagnose`, …) are diagnostics the caller asked for and
|
|
41
|
+
* pass through untouched.
|
|
42
|
+
*/
|
|
43
|
+
export declare const FACT_VIEW_ADMIN_ACTIONS: readonly ["list", "detail"];
|
|
44
|
+
/**
|
|
45
|
+
* Shape one validated tool result for the MODEL. Applied at the two model-facing boundaries
|
|
46
|
+
* (`@avantf/dsh-mem`'s tool runner and the MCP dispatch); the Remote gateway that drives the
|
|
47
|
+
* operator UI keeps the full payload, and a caller that wants the numbers can ask for them
|
|
48
|
+
* explicitly with `mem_admin`'s diagnostic actions.
|
|
49
|
+
*/
|
|
50
|
+
export declare function modelFacingToolResult(toolKey: string, action: unknown, value: unknown): unknown;
|
|
51
|
+
export declare const REMEMBER_ACTIONS: readonly ["add", "update", "remove", "helpful", "unhelpful"];
|
|
52
|
+
export declare const RememberUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
53
|
+
action: z.ZodLiteral<"add">;
|
|
54
|
+
content: z.ZodString;
|
|
55
|
+
category: z.ZodOptional<z.ZodString>;
|
|
56
|
+
ttl_days: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
action: z.ZodLiteral<"update">;
|
|
59
|
+
fact_id: z.ZodNumber;
|
|
60
|
+
content: z.ZodString;
|
|
61
|
+
category: z.ZodOptional<z.ZodString>;
|
|
62
|
+
ttl_days: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
action: z.ZodLiteral<"remove">;
|
|
65
|
+
fact_id: z.ZodNumber;
|
|
66
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
+
action: z.ZodLiteral<"helpful">;
|
|
69
|
+
fact_id: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
+
action: z.ZodLiteral<"unhelpful">;
|
|
72
|
+
fact_id: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>], "action">;
|
|
74
|
+
export type RememberRequest = z.infer<typeof RememberUnion>;
|
|
75
|
+
export declare const RECALL_ACTIONS: readonly ["search", "ask", "chain", "probe", "reason", "related", "contradict"];
|
|
76
|
+
export declare const RecallUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
77
|
+
action: z.ZodLiteral<"search">;
|
|
78
|
+
query: z.ZodString;
|
|
79
|
+
category: z.ZodOptional<z.ZodString>;
|
|
80
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
floors: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
strict: "strict";
|
|
84
|
+
loose: "loose";
|
|
85
|
+
}>>;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
action: z.ZodLiteral<"ask">;
|
|
88
|
+
subj: z.ZodOptional<z.ZodString>;
|
|
89
|
+
pred: z.ZodOptional<z.ZodString>;
|
|
90
|
+
obj: z.ZodOptional<z.ZodString>;
|
|
91
|
+
query: z.ZodOptional<z.ZodString>;
|
|
92
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
+
action: z.ZodLiteral<"chain">;
|
|
95
|
+
subj: z.ZodString;
|
|
96
|
+
pred: z.ZodOptional<z.ZodString>;
|
|
97
|
+
second_pred: z.ZodOptional<z.ZodString>;
|
|
98
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
100
|
+
action: z.ZodLiteral<"probe">;
|
|
101
|
+
entity: z.ZodString;
|
|
102
|
+
category: z.ZodOptional<z.ZodString>;
|
|
103
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
105
|
+
action: z.ZodLiteral<"reason">;
|
|
106
|
+
entities: z.ZodArray<z.ZodString>;
|
|
107
|
+
category: z.ZodOptional<z.ZodString>;
|
|
108
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
action: z.ZodLiteral<"related">;
|
|
111
|
+
entity: z.ZodString;
|
|
112
|
+
category: z.ZodOptional<z.ZodString>;
|
|
113
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
action: z.ZodLiteral<"contradict">;
|
|
116
|
+
category: z.ZodOptional<z.ZodString>;
|
|
117
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
}, z.core.$strip>], "action">;
|
|
119
|
+
export type RecallRequest = z.infer<typeof RecallUnion>;
|
|
120
|
+
export declare const ADMIN_ACTIONS: readonly ["stats", "list", "detail", "archive", "restore", "pin", "unpin", "trust_diagnose", "vectors_diagnose", "vectors_fix", "contradict_check", "contradict_resolve", "maintenance"];
|
|
121
|
+
export declare const AdminUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
122
|
+
action: z.ZodLiteral<"stats">;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
action: z.ZodLiteral<"list">;
|
|
125
|
+
category: z.ZodOptional<z.ZodString>;
|
|
126
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
127
|
+
active: "active";
|
|
128
|
+
archived: "archived";
|
|
129
|
+
}>>;
|
|
130
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
+
action: z.ZodLiteral<"detail">;
|
|
134
|
+
fact_id: z.ZodNumber;
|
|
135
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
136
|
+
action: z.ZodLiteral<"archive">;
|
|
137
|
+
fact_id: z.ZodNumber;
|
|
138
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
action: z.ZodLiteral<"restore">;
|
|
141
|
+
fact_id: z.ZodNumber;
|
|
142
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
143
|
+
action: z.ZodLiteral<"pin">;
|
|
144
|
+
fact_id: z.ZodNumber;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
action: z.ZodLiteral<"unpin">;
|
|
147
|
+
fact_id: z.ZodNumber;
|
|
148
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
149
|
+
action: z.ZodLiteral<"trust_diagnose">;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
action: z.ZodLiteral<"vectors_diagnose">;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
action: z.ZodLiteral<"vectors_fix">;
|
|
154
|
+
dry_run: z.ZodOptional<z.ZodBoolean>;
|
|
155
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
156
|
+
action: z.ZodLiteral<"contradict_check">;
|
|
157
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
158
|
+
action: z.ZodLiteral<"contradict_resolve">;
|
|
159
|
+
contradiction_id: z.ZodNumber;
|
|
160
|
+
resolution: z.ZodEnum<{
|
|
161
|
+
true_positive: "true_positive";
|
|
162
|
+
false_positive: "false_positive";
|
|
163
|
+
}>;
|
|
164
|
+
loser_fact_id: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
166
|
+
action: z.ZodLiteral<"maintenance">;
|
|
167
|
+
}, z.core.$strip>], "action">;
|
|
168
|
+
export type AdminRequest = z.infer<typeof AdminUnion>;
|
|
169
|
+
/** The `source` a write gets when it omits one; a document's identity is `(domain, source, title)`. */
|
|
170
|
+
export declare const DEFAULT_KB_SOURCE = "default";
|
|
171
|
+
export declare const KbUnion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
172
|
+
action: z.ZodLiteral<"ingest">;
|
|
173
|
+
text: z.ZodOptional<z.ZodString>;
|
|
174
|
+
source_uri: z.ZodOptional<z.ZodString>;
|
|
175
|
+
domain: z.ZodString;
|
|
176
|
+
source: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
177
|
+
title: z.ZodOptional<z.ZodString>;
|
|
178
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
180
|
+
action: z.ZodLiteral<"import">;
|
|
181
|
+
paths: z.ZodArray<z.ZodString>;
|
|
182
|
+
domain: z.ZodString;
|
|
183
|
+
source: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
184
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
185
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
186
|
+
action: z.ZodLiteral<"list">;
|
|
187
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
188
|
+
source: z.ZodOptional<z.ZodString>;
|
|
189
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
191
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
192
|
+
action: z.ZodLiteral<"detail">;
|
|
193
|
+
doc_id: z.ZodNumber;
|
|
194
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
195
|
+
action: z.ZodLiteral<"remove">;
|
|
196
|
+
doc_id: z.ZodNumber;
|
|
197
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
198
|
+
action: z.ZodLiteral<"reindex">;
|
|
199
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
200
|
+
dry_run: z.ZodOptional<z.ZodBoolean>;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
action: z.ZodLiteral<"sync">;
|
|
203
|
+
doc_id: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
adopt: z.ZodOptional<z.ZodBoolean>;
|
|
205
|
+
dry_run: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
+
}, z.core.$strip>], "action">;
|
|
207
|
+
export type KbRequest = z.infer<typeof KbUnion>;
|
|
208
|
+
export declare const QueryUnion: z.ZodObject<{
|
|
209
|
+
query: z.ZodString;
|
|
210
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
211
|
+
fact: "fact";
|
|
212
|
+
doc_chunk: "doc_chunk";
|
|
213
|
+
all: "all";
|
|
214
|
+
}>>;
|
|
215
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
217
|
+
source: z.ZodOptional<z.ZodString>;
|
|
218
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
219
|
+
floors: z.ZodOptional<z.ZodEnum<{
|
|
220
|
+
strict: "strict";
|
|
221
|
+
loose: "loose";
|
|
222
|
+
}>>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
export type QueryRequest = z.infer<typeof QueryUnion>;
|
|
225
|
+
/** Transport-agnostic tool spec: name / key / description / zod input. */
|
|
226
|
+
export interface ToolSpec {
|
|
227
|
+
key: string;
|
|
228
|
+
name: string;
|
|
229
|
+
description: string;
|
|
230
|
+
input: z.ZodType;
|
|
231
|
+
}
|
|
232
|
+
export declare const REMEMBER_TOOL: ToolSpec;
|
|
233
|
+
export declare const RECALL_TOOL: ToolSpec;
|
|
234
|
+
export declare const ADMIN_TOOL: ToolSpec;
|
|
235
|
+
export declare const KB_TOOL: ToolSpec;
|
|
236
|
+
export declare const QUERY_TOOL: ToolSpec;
|
|
237
|
+
/** One new document, or a batch import — never an update (see the tool description). */
|
|
238
|
+
export declare const KB_ADD_TOOL: ToolSpec;
|
|
239
|
+
/**
|
|
240
|
+
* The parsed `kb_add` input, no `overwrite`: the add-only MODE is a property of the runtime face
|
|
241
|
+
* (`rt.kbAdd`), not a field the model can set. Spelled out (rather than `z.infer` of
|
|
242
|
+
* `KB_ADD_TOOL.input`, which is widened to `z.ZodType` by `ToolSpec`) so the runtime method and the
|
|
243
|
+
* plugin handler agree on the request. `source` is present because the contract defaults it.
|
|
244
|
+
*/
|
|
245
|
+
export interface KbAddRequest {
|
|
246
|
+
domain: string;
|
|
247
|
+
source: string;
|
|
248
|
+
title?: string;
|
|
249
|
+
text?: string;
|
|
250
|
+
source_uri?: string;
|
|
251
|
+
paths?: string[];
|
|
252
|
+
}
|
|
253
|
+
/** The corpus listing, with the managed path — the entry point for editing a document. */
|
|
254
|
+
export declare const KB_LIST_TOOL: ToolSpec;
|
|
255
|
+
export declare const KB_REMOVE_TOOL: ToolSpec;
|
|
256
|
+
export declare const KB_REINDEX_TOOL: ToolSpec;
|
|
257
|
+
export declare const TOOL_SPECS: ToolSpec[];
|
|
258
|
+
/**
|
|
259
|
+
* Compose the top-level (merged) description for a union field.
|
|
260
|
+
*
|
|
261
|
+
* Descriptions are authored per action ("action=update 时必填"), so taking the
|
|
262
|
+
* first branch's text verbatim told a model that `fact_id` only matters for
|
|
263
|
+
* `update` although `remove/helpful/unhelpful` require it too. The action-clause
|
|
264
|
+
* is stripped and replaced by the derived set of actions that make the field
|
|
265
|
+
* required.
|
|
266
|
+
*
|
|
267
|
+
* Both model-facing surfaces call this: `toolInputJsonSchema` (MCP `inputSchema`) and
|
|
268
|
+
* `@avantf/dsh-mem`'s `flattenToolSpec` (DSH tool parameters). They each walk the union and must
|
|
269
|
+
* agree field for field — deriving the sentence in ONE place is what makes that so.
|
|
270
|
+
*/
|
|
271
|
+
export declare function mergedFieldDescription(base: string | undefined, requiredIn: string[]): string | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Derive a full JSON Schema (draft-07) for a tool's input — used as the MCP
|
|
274
|
+
* `inputSchema`.
|
|
275
|
+
*
|
|
276
|
+
* A discriminated union emits `oneOf` with ONE schema per action: each branch
|
|
277
|
+
* carries its own `required` list, so `{"action":"search"}` (no `query`) is
|
|
278
|
+
* rejected exactly like the server's own contract validation rejects it. The
|
|
279
|
+
* merged `properties` map is kept alongside for MCP clients that ignore `oneOf`,
|
|
280
|
+
* with every field's description stating which actions require it. Field-level
|
|
281
|
+
* value constraints (`minimum`/`maximum`/`minLength`/`minItems`/`default`) are
|
|
282
|
+
* carried over from zod. A plain object marks its own required fields.
|
|
283
|
+
*/
|
|
284
|
+
export declare function toolInputJsonSchema(spec: ToolSpec): Record<string, unknown>;
|