@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.
Files changed (145) hide show
  1. package/README.md +89 -28
  2. package/cordis.patch.yml +17 -0
  3. package/lib/client.js +155 -14
  4. package/lib/dsh-build.json +5 -5
  5. package/lib/engine/mem/config/config_files.d.ts +26 -0
  6. package/lib/engine/mem/config/domains.d.ts +20 -0
  7. package/lib/engine/mem/config/loader.d.ts +35 -0
  8. package/lib/engine/mem/config/paths.d.ts +53 -0
  9. package/lib/engine/mem/db/chunk.d.ts +26 -0
  10. package/lib/engine/mem/db/conn.d.ts +13 -0
  11. package/lib/engine/mem/db/dao/chunks.d.ts +150 -0
  12. package/lib/engine/mem/db/dao/contradictions.d.ts +98 -0
  13. package/lib/engine/mem/db/dao/documents.d.ts +51 -0
  14. package/lib/engine/mem/db/dao/entities.d.ts +67 -0
  15. package/lib/engine/mem/db/dao/facts.d.ts +472 -0
  16. package/lib/engine/mem/db/dao/stats.d.ts +14 -0
  17. package/lib/engine/mem/db/dao/triples.d.ts +80 -0
  18. package/lib/engine/mem/db/hash.d.ts +2 -0
  19. package/lib/engine/mem/db/knowledge.d.ts +17 -0
  20. package/lib/engine/mem/db/migrations.d.ts +71 -0
  21. package/lib/engine/mem/db/port.d.ts +57 -0
  22. package/lib/engine/mem/db/schema.d.ts +26 -0
  23. package/lib/engine/mem/db/sqlite.d.ts +89 -0
  24. package/lib/engine/mem/db/store.d.ts +35 -0
  25. package/lib/engine/mem/db/tokenizer.d.ts +61 -0
  26. package/lib/engine/mem/db/vectors.d.ts +50 -0
  27. package/lib/engine/mem/dispatch.d.ts +51 -0
  28. package/lib/engine/mem/entities/extract.d.ts +84 -0
  29. package/lib/engine/mem/eval/loader.d.ts +19 -0
  30. package/lib/engine/mem/eval/metrics.d.ts +25 -0
  31. package/lib/engine/mem/eval/runner.d.ts +10 -0
  32. package/lib/engine/mem/eval/write_metrics.d.ts +88 -0
  33. package/lib/engine/mem/git.d.ts +73 -0
  34. package/lib/engine/mem/hrr/algebra.d.ts +30 -0
  35. package/lib/engine/mem/hrr/atoms.d.ts +22 -0
  36. package/lib/engine/mem/hrr/encode.d.ts +32 -0
  37. package/lib/engine/mem/hrr/index.d.ts +3 -0
  38. package/lib/engine/mem/index.d.ts +27 -0
  39. package/lib/engine/mem/lifecycle/contradiction.d.ts +156 -0
  40. package/lib/engine/mem/lifecycle/index.d.ts +5 -0
  41. package/lib/engine/mem/lifecycle/maintenance.d.ts +48 -0
  42. package/lib/engine/mem/lifecycle/presence.d.ts +29 -0
  43. package/lib/engine/mem/lifecycle/tick.d.ts +43 -0
  44. package/lib/engine/mem/lifecycle/trust.d.ts +90 -0
  45. package/lib/engine/mem/modelBootstrap.d.ts +207 -0
  46. package/lib/engine/mem/router.d.ts +51 -0
  47. package/lib/engine/mem/runtime.d.ts +232 -0
  48. package/lib/engine/mem/store/common.d.ts +82 -0
  49. package/lib/engine/mem/store/doc_files.d.ts +125 -0
  50. package/lib/engine/mem/store/document_text.d.ts +47 -0
  51. package/lib/engine/mem/store/floors.d.ts +191 -0
  52. package/lib/engine/mem/store/hybrid.d.ts +232 -0
  53. package/lib/engine/mem/store/ingest_guard.d.ts +25 -0
  54. package/lib/engine/mem/store/knowledge.d.ts +483 -0
  55. package/lib/engine/mem/store/lexical.d.ts +67 -0
  56. package/lib/engine/mem/store/memory.d.ts +543 -0
  57. package/lib/engine/mem/store/source_picker.d.ts +43 -0
  58. package/lib/engine/mem-contract/config.d.ts +129 -0
  59. package/lib/engine/mem-contract/env.d.ts +31 -0
  60. package/lib/engine/mem-contract/family.d.ts +25 -0
  61. package/lib/engine/mem-contract/index.d.ts +8 -0
  62. package/lib/engine/mem-contract/log.d.ts +29 -0
  63. package/lib/engine/mem-contract/remote.d.ts +80 -0
  64. package/lib/engine/mem-contract/text.d.ts +92 -0
  65. package/lib/engine/mem-contract/tools.d.ts +284 -0
  66. package/lib/engine/mem-contract/types.d.ts +615 -0
  67. package/lib/engine/mem-retrieval/adapters/auto_vstore.d.ts +47 -0
  68. package/lib/engine/mem-retrieval/adapters/hnswlib.d.ts +174 -0
  69. package/lib/engine/mem-retrieval/adapters/local_bge.d.ts +121 -0
  70. package/lib/engine/mem-retrieval/adapters/local_numpy.d.ts +28 -0
  71. package/lib/engine/mem-retrieval/adapters/local_reranker.d.ts +52 -0
  72. package/lib/engine/mem-retrieval/adapters/none_reranker.d.ts +10 -0
  73. package/lib/engine/mem-retrieval/adapters/warm_gate.d.ts +46 -0
  74. package/lib/engine/mem-retrieval/budget.d.ts +30 -0
  75. package/lib/engine/mem-retrieval/fusion.d.ts +53 -0
  76. package/lib/engine/mem-retrieval/index.d.ts +14 -0
  77. package/lib/engine/mem-retrieval/interfaces.d.ts +82 -0
  78. package/lib/engine/mem-retrieval/log.d.ts +11 -0
  79. package/lib/engine/mem-retrieval/registry.d.ts +23 -0
  80. package/lib/engine/mem-retrieval/rerank.d.ts +13 -0
  81. package/lib/engine/mem-retrieval/stats.d.ts +64 -0
  82. package/lib/engine/mem-retrieval/text_budget.d.ts +52 -0
  83. package/lib/index.js +1773 -473
  84. package/lib/interface-version.json +2 -2
  85. package/lib/types/client/domains.d.ts +5 -4
  86. package/lib/types/client/domains.d.ts.map +1 -1
  87. package/lib/types/client/index.d.ts.map +1 -1
  88. package/lib/types/client/ingest.d.ts +1 -1
  89. package/lib/types/client/wire.d.ts +36 -0
  90. package/lib/types/client/wire.d.ts.map +1 -0
  91. package/lib/types/envinit-bootstrap.d.ts +3 -2
  92. package/lib/types/envinit.d.ts +2 -19
  93. package/lib/types/envinit.d.ts.map +1 -1
  94. package/lib/types/hints.d.ts +1 -1
  95. package/lib/types/index.d.ts +8 -3
  96. package/lib/types/index.d.ts.map +1 -1
  97. package/lib/types/open.d.ts +61 -11
  98. package/lib/types/open.d.ts.map +1 -1
  99. package/lib/types/prompt.d.ts +19 -1
  100. package/lib/types/prompt.d.ts.map +1 -1
  101. package/lib/types/provision.d.ts +1 -1
  102. package/lib/types/provision.d.ts.map +1 -1
  103. package/lib/types/reconcile.d.ts +64 -0
  104. package/lib/types/reconcile.d.ts.map +1 -0
  105. package/lib/types/remote.d.ts +53 -0
  106. package/lib/types/remote.d.ts.map +1 -1
  107. package/lib/types/render.d.ts +35 -0
  108. package/lib/types/render.d.ts.map +1 -0
  109. package/lib/types/tool_schema.d.ts +3 -13
  110. package/lib/types/tool_schema.d.ts.map +1 -1
  111. package/package.json +27 -18
  112. package/lib/client.js.map +0 -1
  113. package/lib/types/client/domains.js +0 -25
  114. package/lib/types/client/domains.js.map +0 -1
  115. package/lib/types/client/index.js +0 -1371
  116. package/lib/types/client/index.js.map +0 -1
  117. package/lib/types/client/ingest.js +0 -30
  118. package/lib/types/client/ingest.js.map +0 -1
  119. package/lib/types/client/paging.js +0 -36
  120. package/lib/types/client/paging.js.map +0 -1
  121. package/lib/types/client/summarize.js +0 -79
  122. package/lib/types/client/summarize.js.map +0 -1
  123. package/lib/types/data_home.js +0 -26
  124. package/lib/types/data_home.js.map +0 -1
  125. package/lib/types/envinit-bootstrap.js +0 -333
  126. package/lib/types/envinit.js +0 -402
  127. package/lib/types/envinit.js.map +0 -1
  128. package/lib/types/hints.js +0 -53
  129. package/lib/types/hints.js.map +0 -1
  130. package/lib/types/index.js +0 -755
  131. package/lib/types/index.js.map +0 -1
  132. package/lib/types/inject.js +0 -14
  133. package/lib/types/inject.js.map +0 -1
  134. package/lib/types/interface_gate.js +0 -84
  135. package/lib/types/interface_gate.js.map +0 -1
  136. package/lib/types/open.js +0 -133
  137. package/lib/types/open.js.map +0 -1
  138. package/lib/types/prompt.js +0 -148
  139. package/lib/types/prompt.js.map +0 -1
  140. package/lib/types/provision.js +0 -177
  141. package/lib/types/provision.js.map +0 -1
  142. package/lib/types/remote.js +0 -247
  143. package/lib/types/remote.js.map +0 -1
  144. package/lib/types/tool_schema.js +0 -149
  145. package/lib/types/tool_schema.js.map +0 -1
@@ -1,402 +0,0 @@
1
- /**
2
- * Environment initialisation for the memory plugin, through the family base
3
- * `@avantf/dsh-plugin-base`.
4
- *
5
- * The shape is fixed by the base's DESIGN §7.2 and is the same for every plugin:
6
- *
7
- * bootstrap (inlined) → load the base → register + declare the remaining resources → dispatch the
8
- * `background` set → the plugin's own pre-mount check.
9
- *
10
- * What this plugin needs, in two phases:
11
- *
12
- * 1. **The gate, straight from the base** — the family compatibility gate is part of
13
- * `@avantf/dsh-plugin-base` and arrived WITH the module the bootstrap loaded. There is no
14
- * `mem:compat` item, no npm download and no managed `<home>/compat/**` copy any more; the base's
15
- * `compat` module provides the rules, probes, report and post-registration check, and
16
- * `runtimeFromCompat(framework)` derives this plugin's spec from it. The gate has to be runnable
17
- * BEFORE anything is registered, because a proven incompatible host must refuse the mount with
18
- * nothing half-registered. This replaces the bespoke self-heal the plugin used to run itself
19
- * (`@avantf/mem-provision`'s `ensureCompatBase`), whose private root (`<dataHome>/dsh-compat/**`)
20
- * the base deliberately does not read.
21
- * 2. **`mem:pandoc`** (`binary-archive`, `startup: 'background'`) — the documented "expensive but
22
- * not startup-blocking" resource. It is declared AFTER the runtime exists, because its spec
23
- * comes from the resolved config (`tools.auto_install`, `tools.mirror`), and it is dispatched
24
- * without waiting: the caller continues its own initialisation and hooks the outcome through
25
- * `onSettled`.
26
- * 3. **`mem:model`** (`model-cache`, `startup: 'background'`) — the embedding model. It uses the
27
- * base's `flat` layout, whose files land at `<root>/<repo>/<file>` — exactly the shape
28
- * `@huggingface/transformers` reads under its `cacheDir` — so the runtime loads the base's
29
- * copy instead of fetching a second one. For the default repo the file list is the narrow set
30
- * the runtime actually opens (see {@link MODEL_FILES}); any other repo omits the list, because
31
- * a fixed six-file list made the item fail for a repo whose file set differs. The endpoint is
32
- * the mirror only the operator (env) can move. It is NOT declared when the runtime reads its
33
- * models elsewhere (`AVANTF_MEM_MODEL_CACHE`) — that would install a second, never-read copy.
34
- * A model that cannot be fetched is a WARNING: the semantic path degrades to FTS+entity, it
35
- * never refuses the mount.
36
- *
37
- * Two hard rules:
38
- *
39
- * - **The base is never statically imported.** Only `import type` and the inlined bootstrap
40
- * are static; the value comes from `loadFramework()`. A top-level value import would throw before
41
- * the bootstrap ran — exactly the broken-tree case the bootstrap exists for.
42
- * - **Nothing here refuses the mount.** "Cannot tell" is not "incompatible": a missing base,
43
- * an unavailable gate or a failed resource is a WARNING, and the plugin mounts with its tools,
44
- * service, prompt and Remote face intact.
45
- *
46
- * @module @avantf/dsh-mem/envinit
47
- */
48
- import { homedir } from 'node:os';
49
- import { join, resolve } from 'node:path';
50
- import { fileURLToPath } from 'node:url';
51
- import { envAutoDownload, expandHome } from '@avantf/mem-contract';
52
- import { PANDOC_ARTIFACT_ID, PANDOC_BINARY, PANDOC_PACKS, PANDOC_VERSION } from '@avantf/mem-provision';
53
- import { loadFramework, readDependencyRange } from './envinit-bootstrap.js';
54
- import { baseIsUsable, interfaceVerdict } from './interface_gate.js';
55
- import { COMPAT_PACKAGE, reasonOf, runtimeFromCompat, warn, } from './provision.js';
56
- /** The family base package, as declared in this plugin's `peerDependencies`. */
57
- const FRAMEWORK_PACKAGE = '@avantf/dsh-plugin-base';
58
- /** The plugin namespace every item is declared under (`<plugin>:<name>`, framework DESIGN §13.4). */
59
- const PLUGIN = 'mem';
60
- /**
61
- * The item ids. `resolve()` / `onSettled` are keyed by them, so the DSH plugin compares against these
62
- * names rather than re-spelling literals.
63
- */
64
- export const PANDOC_ITEM = 'mem:pandoc';
65
- export const MODEL_ITEM = 'mem:model';
66
- /**
67
- * The default ONNX embedding repository — the one `semantic.local_model` defaults to and the one
68
- * {@link MODEL_FILES} describes. A DIFFERENT repo is a different file set, which is why the item
69
- * omits `spec.files` for it (see {@link managedModelSpec}).
70
- */
71
- export const DEFAULT_MODEL_REPO = 'Xenova/bge-small-zh-v1.5';
72
- /**
73
- * The files the local embedding runtime actually requests for the DEFAULT ONNX model.
74
- *
75
- * Measured, not guessed: with an empty cache, `@huggingface/transformers@4.x` resolving
76
- * `feature-extraction` for `Xenova/bge-small-zh-v1.5` fetches exactly these four — `config.json`,
77
- * `tokenizer.json`, `tokenizer_config.json` and the fp32 `onnx/model.onnx`. The repo ALSO carries
78
- * `special_tokens_map.json`, `vocab.txt` and seven other ONNX quantisations the default run never
79
- * opens; declaring them would download hundreds of megabytes of dead weight. The list stays narrow
80
- * to what is read.
81
- */
82
- export const MODEL_FILES = [
83
- 'config.json',
84
- 'tokenizer.json',
85
- 'tokenizer_config.json',
86
- 'onnx/model.onnx',
87
- ];
88
- /** Startup budget for the blocking set; the framework's default is the same. */
89
- const DEADLINE_MS = 15_000;
90
- /** This module's warning token, so one grep finds every environment-initialisation line. */
91
- const OWN_PREFIX = 'envinit:';
92
- /**
93
- * The model item the framework should own, or `undefined` when it should not.
94
- *
95
- * Two refusals, both deliberate:
96
- *
97
- * 1. **Not a local backend** — nothing to provision.
98
- * 2. **The runtime reads its models from elsewhere** — `semantic.cache_dir` is not the framework's
99
- * `<home>/models`. That happens through the operator escape hatch `AVANTF_MEM_MODEL_CACHE`
100
- * (env layer ④): the runtime loads from that directory, so a `mem:model` item would install a
101
- * full second copy under `<home>/models` that nothing ever reads (~190 MB). Declaring nothing
102
- * is the fix; the caller warms from the override directory instead.
103
- *
104
- * `files` is the narrow {@link MODEL_FILES} set only for the DEFAULT repo; a user-changed repo has a
105
- * different file set, and a stale six-file list would make the item `failed` while the runtime could
106
- * serve it. Empty means "omit `spec.files`": the framework then installs the repository's own file
107
- * list.
108
- */
109
- export function managedModelSpec(semantic, modelsRoot) {
110
- if (semantic.backend !== 'local_bge')
111
- return undefined;
112
- if (!sameDir(semantic.cache_dir, modelsRoot))
113
- return undefined;
114
- return {
115
- repo: semantic.local_model,
116
- files: semantic.local_model === DEFAULT_MODEL_REPO ? MODEL_FILES : [],
117
- endpoint: semantic.mirror,
118
- };
119
- }
120
- /** Same directory, after `~/` expansion and normalisation (a trailing slash is not a difference). */
121
- function sameDir(a, b) {
122
- return resolve(expandHome(a)) === resolve(expandHome(b));
123
- }
124
- /**
125
- * The family root: `$AVANTF_HOME`, else `~/.avantf/env`.
126
- *
127
- * `AVANTF_HOME` is the same variable the engine uses for its DATA home (`memory/`, `knowledge/`),
128
- * and that is deliberate: setting it redirects a whole tree (data AND managed resources), which is
129
- * exactly what a test or a sandboxed host needs. Unset — the normal case — the family root is the
130
- * framework's documented default and the data home stays `~/.avantf`.
131
- */
132
- function resolveHome() {
133
- const configured = process.env['AVANTF_HOME'];
134
- return configured !== undefined && configured.trim() !== '' ? configured : join(homedir(), '.avantf', 'env');
135
- }
136
- /**
137
- * The download gate. Off when EITHER switch is off:
138
- *
139
- * - `AVANTF_MEM_AUTO_DOWNLOAD=0` — this project's documented kill switch (the CLI, the MCP server
140
- * and every test honour it);
141
- * - `AVANTF_ENVINIT_AUTO_DOWNLOAD=0` — the family framework's switch, so an operator can turn the
142
- * whole family's provisioning off in one place.
143
- *
144
- * The two-variable rule lives in ONE place (`@avantf/mem-contract`'s `envAutoDownload`), which the
145
- * config loader and both model adapters also call: a family switch that stops the framework but not
146
- * the runtime's own fetch is exactly the bug that duplication would reintroduce.
147
- */
148
- function envDownloadsAllowed() {
149
- return envAutoDownload() ?? true;
150
- }
151
- /** A `ProvisionLogger` over the plugin's own logger (the framework also wants `debug`). */
152
- function provisionLogger(log) {
153
- return {
154
- debug: (message) => { log?.info(message); },
155
- info: (message) => { log?.info(message); },
156
- warn: (message) => { log?.warn(message); },
157
- error: (message) => { log?.error(message); },
158
- };
159
- }
160
- /**
161
- * The `mem:pandoc` item: the pinned pandoc release as a `binary-archive`.
162
- *
163
- * The packs are `@avantf/mem-provision`'s (`PANDOC_PACKS`), the single source of the URLs and the
164
- * measured digests; this only re-spells them in the framework's vocabulary (`format` → `archive`,
165
- * and the binary as a NAME the archive search finds rather than a path inside the archive). The
166
- * framework installs it to `<home>/tools/pandoc/3.11/bin/pandoc` — the same layout the converter
167
- * already resolves, which is what makes the handover a config change and not a code change.
168
- */
169
- function pandocItem(framework) {
170
- const packs = {};
171
- for (const [key, pack] of Object.entries(PANDOC_PACKS)) {
172
- if (pack === undefined)
173
- continue;
174
- packs[key] = { url: pack.url, sha256: pack.sha256, archive: pack.format };
175
- }
176
- return {
177
- id: PANDOC_ITEM,
178
- kind: framework.BINARY_ARCHIVE_KIND,
179
- spec: {
180
- id: PANDOC_ARTIFACT_ID,
181
- version: PANDOC_VERSION,
182
- binary: PANDOC_BINARY,
183
- packs,
184
- },
185
- target: { root: 'tools' },
186
- // A missing converter degrades the knowledge base's document ingestion, never the mount.
187
- onMissing: { atStartup: 'degrade', atUse: 'error' },
188
- startup: 'background',
189
- schemaVersion: framework.ITEM_SCHEMA_VERSION,
190
- };
191
- }
192
- /**
193
- * The `mem:model` item: the embedding model as a `model-cache` in the framework's `flat` layout.
194
- *
195
- * `flat` places the files at `<home>/models/<repo>/<file>` — the same tree `semantic.cache_dir`
196
- * points at (the framework root, through `managedRoots`) and the same shape the local runtime reads.
197
- * `files` is the narrow default-repo set (see {@link MODEL_FILES}); it is OMITTED for any other repo,
198
- * whose file set this build cannot know, so the framework installs the repository's own list instead
199
- * of failing on a missing fixed path. `endpoint` is the mirror resolved from the operator's env
200
- * escape hatch, so neither the landing site nor the source is chosen by an end user's `config.yaml`.
201
- *
202
- * A missing model is a degraded semantic path, NOT a refused mount: both `onMissing` axes are
203
- * `degrade`, and the engine falls back to FTS+entity.
204
- */
205
- function modelItem(framework, model) {
206
- return {
207
- id: MODEL_ITEM,
208
- kind: framework.MODEL_CACHE_KIND,
209
- spec: {
210
- repo: model.repo,
211
- revision: 'main',
212
- layout: 'flat',
213
- ...(model.files.length === 0 ? {} : { files: [...model.files] }),
214
- endpoint: model.endpoint,
215
- },
216
- target: { root: 'models' },
217
- onMissing: { atStartup: 'degrade', atUse: 'degrade' },
218
- startup: 'background',
219
- schemaVersion: framework.ITEM_SCHEMA_VERSION,
220
- };
221
- }
222
- let loaded;
223
- let loading;
224
- /**
225
- * Ensure the framework, then the compatibility base, then dispatch the expensive resources.
226
- *
227
- * Never throws. Returns `undefined` when the framework cannot be loaded — the caller then warns and
228
- * mounts on the legacy provisioning path (the engine's own `@avantf/mem-provision` sweep, whose
229
- * default directories are the pre-migration ones). A framework that loads but cannot provide the
230
- * base still returns a runtime, with `compat: undefined`: the mount must continue, and the resource
231
- * items are still worth dispatching.
232
- *
233
- * The result is cached per process; a FAILED load is not, so a profile reload retries instead of
234
- * replaying the first failure for the whole process lifetime.
235
- *
236
- * @param options - logger, family root, download policy and the test seams.
237
- * @returns the loaded runtime, or `undefined` when the framework itself is unavailable.
238
- */
239
- export async function loadEnvinit(options = {}) {
240
- if (loaded !== undefined)
241
- return loaded;
242
- if (loading !== undefined)
243
- return loading;
244
- loading = loadGuarded(options).then((runtime) => {
245
- // A failure is "cannot tell", not a verdict — and it may be transient (offline at boot,
246
- // registry hiccup). Drop the cache so a profile reload, or a second instance in the same
247
- // process, retries instead of replaying the first failure for the whole process lifetime.
248
- if (runtime === undefined)
249
- loading = undefined;
250
- else
251
- loaded = runtime;
252
- return runtime;
253
- }, () => {
254
- loading = undefined;
255
- return undefined;
256
- });
257
- return loading;
258
- }
259
- /** The guard that makes "never throws" true: every failure is a warning plus `undefined`. */
260
- async function loadGuarded(options) {
261
- try {
262
- return await loadOnce(options);
263
- }
264
- catch (error) {
265
- warn(options.log, `${OWN_PREFIX} WARNING — environment initialisation failed (${reasonOf(error)}); the framework is SKIPPED and the plugin will mount anyway`);
266
- return undefined;
267
- }
268
- }
269
- /** The body of {@link loadEnvinit}; the cache above makes it run at most once per process. */
270
- async function loadOnce(options) {
271
- const home = options.home ?? resolveHome();
272
- const range = await readDependencyRange(fileURLToPath(import.meta.url));
273
- const autoDownload = options.autoDownload ?? envDownloadsAllowed();
274
- const deadlineMs = options.deadlineMs ?? DEADLINE_MS;
275
- // Step 1–2: bootstrap → the framework itself (the package manager's copy, zero download). The
276
- // plugin's declared range is not judged here; it goes to `envinitRange` below, per manifest.
277
- const framework = options.framework ?? await loadFramework({
278
- logger: {
279
- warn: (message) => { warn(options.log, `${FRAMEWORK_PACKAGE}: ${message}`); },
280
- info: (message) => { options.log?.info(`${FRAMEWORK_PACKAGE}: ${message}`); },
281
- },
282
- });
283
- if (framework === undefined) {
284
- warn(options.log, `${OWN_PREFIX} WARNING — ${FRAMEWORK_PACKAGE} could not be made available; the plugin falls back to its own provisioning and mounts anyway`);
285
- return undefined;
286
- }
287
- // The RUNTIME interface gate, on its own axis: the generation this artifact was baked for
288
- // (`lib/interface-version.json`, written by `scripts/link-envinit.mjs` with the bootstrap) versus
289
- // the one the loaded base reports. The DECISION is the base's (`checkInterface` together with its
290
- // one reader of the bake record); this plugin only consumes it. Package versions move every release
291
- // and stay the INSTALL-time gate (the peer range), so the generation number is the axis that means
292
- // "the kit and gate helper set I was written against is the one I loaded".
293
- //
294
- // The verdict, and why it is a DEGRADATION now rather than the bare warning it used to be: the
295
- // interface is the family's MAIN contract, so a base from another generation is not a base whose
296
- // shared capabilities this build may use. `incompatible` therefore withholds them — the prompt
297
- // layer falls back to this plugin's own default text, the compatibility gate is skipped and the
298
- // resources take the legacy path — by taking the SAME route as "the base is unavailable", which the
299
- // caller already handles. The mount itself (tools, service, prompt sections, Remote, UI) is never
300
- // refused: the family invariant is that only a PROVEN host break refuses, and a generation mismatch
301
- // is not one. `cannot-tell` (no gate on the loaded base, no bake record) is a warning and nothing
302
- // else — "cannot tell" is never "incompatible".
303
- {
304
- const verdict = interfaceVerdict(framework);
305
- if (!baseIsUsable(verdict)) {
306
- warn(options.log, `${OWN_PREFIX} WARNING — interface: ${verdict.reason ?? 'the loaded base implements another interface generation'};`
307
- + ' the base\'s shared capabilities are NOT used (own prompt defaults, gate skipped, legacy provisioning) and the plugin mounts anyway');
308
- return undefined;
309
- }
310
- if (verdict.status === 'cannot-tell') {
311
- warn(options.log, `${OWN_PREFIX} WARNING — interface: ${verdict.reason ?? 'the interface generation cannot be told'}; using the loaded base anyway ("cannot tell" is never "incompatible")`);
312
- }
313
- }
314
- // The compatibility gate is part of the base package and arrived WITH it: there is no `mem:compat`
315
- // item, no npm download and no managed `~/.avantf/env/compat/**` any more. `runtimeFromCompat`
316
- // takes the loaded base module directly. A gate that cannot be built is a WARNING (the plugin
317
- // mounts and writes its own default prompts), never a refusal.
318
- const disposers = [];
319
- let compat;
320
- try {
321
- compat = runtimeFromCompat(options.compatModule ?? framework);
322
- }
323
- catch (error) {
324
- warn(options.log, `${OWN_PREFIX} WARNING — the ${COMPAT_PACKAGE} compatibility gate could not be initialised (${reasonOf(error)}); the compatibility gate is SKIPPED and the plugin will mount anyway`);
325
- }
326
- let disposed = false;
327
- return {
328
- home,
329
- kit: framework,
330
- compat,
331
- roots: { tools: join(home, 'tools'), models: join(home, 'models') },
332
- provisionResources(plan, onSettled) {
333
- if (disposed)
334
- return;
335
- const items = [];
336
- if (plan.pandoc)
337
- items.push(pandocItem(framework));
338
- if (plan.model !== undefined)
339
- items.push(modelItem(framework, plan.model));
340
- if (items.length === 0)
341
- return;
342
- // A SECOND provisioner, on purpose: `policy.mirrors.archive` is the engine's `tools.mirror`,
343
- // which is only known after the runtime resolved its config — while the compat provisioner had
344
- // to exist before that, to run the gate. Two instances sharing one family root are supported by
345
- // design (framework DESIGN §13.1), and their item sets are disjoint.
346
- //
347
- // `autoDownload` is per KIND: the env kill switches turn everything off, otherwise the model
348
- // follows `semantic.auto_download` while pandoc keeps its own gate (`tools.auto_install`,
349
- // which decides whether it is declared at all). Folding the two into one boolean would let
350
- // `semantic.auto_download: false` skip a pandoc the operator explicitly asked for — or, the
351
- // other way round, let a disabled model still hit the network.
352
- const resources = framework.createProvisioner({
353
- home,
354
- envinitRange: range,
355
- logger: provisionLogger(options.log),
356
- policy: {
357
- autoDownload: autoDownload ? { [framework.MODEL_CACHE_KIND]: plan.modelAutoDownload } : false,
358
- deadlineMs,
359
- mirrors: { archive: [...plan.archiveMirrors] },
360
- },
361
- });
362
- resources.register(framework.binaryArchiveProvider());
363
- resources.register(framework.modelCacheProvider());
364
- resources.declare({ plugin: PLUGIN, items });
365
- disposers.push(resources);
366
- // Dispatched, not awaited: `startup: 'background'` items never occupy the ensure budget.
367
- // The `.catch` is not decoration: an unhandled rejection is FATAL on a strict host (Node's
368
- // default `--unhandled-rejections=throw`), and a memory plugin must not be able to take the
369
- // host down over a resource it could not fetch. The compat ensure above is awaited instead,
370
- // so its rejection is handled by `loadGuarded`.
371
- void resources.ensure({
372
- only: items.map(item => item.id),
373
- onSettled: (entry) => {
374
- try {
375
- onSettled(entry);
376
- }
377
- catch (error) {
378
- warn(options.log, `${OWN_PREFIX} WARNING — the onSettled callback failed (${reasonOf(error)})`);
379
- }
380
- },
381
- }).catch((error) => {
382
- warn(options.log, `${OWN_PREFIX} WARNING — declaring the background resources failed (${reasonOf(error)}); the plugin continues (tools stay registered)`);
383
- });
384
- },
385
- dispose() {
386
- if (disposed)
387
- return;
388
- disposed = true;
389
- for (const instance of disposers.splice(0)) {
390
- try {
391
- instance.dispose();
392
- }
393
- catch {
394
- // Disposal is best-effort; a throwing release must not break unmount.
395
- }
396
- }
397
- loaded = undefined;
398
- loading = undefined;
399
- },
400
- };
401
- }
402
- //# sourceMappingURL=envinit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envinit.js","sourceRoot":"","sources":["../../src/envinit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEvG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBA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gBAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU,yDAAyD,QAAQ,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAA;YAC3J,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3C,IAAI,CAAC;oBACH,QAAQ,CAAC,OAAO,EAAE,CAAA;gBACpB,CAAC;gBAAC,MAAM,CAAC;oBACP,sEAAsE;gBACxE,CAAC;YACH,CAAC;YACD,MAAM,GAAG,SAAS,CAAA;YAClB,OAAO,GAAG,SAAS,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,53 +0,0 @@
1
- /**
2
- * The plugin's CONDITIONAL hint: ONE line, contributed only when either store already holds
3
- * something relevant to the message the user just sent (DESIGN §12).
4
- *
5
- * These are deliberately NOT part of the always-on usage sections. A usage section says WHEN a
6
- * store is worth consulting and therefore has to be paid for on every step of every session; this
7
- * says "there is something here, right now", which is only true sometimes. The two layers compose:
8
- * the section is the fallback for the paraphrase the lexical probe misses, and the hint is the
9
- * concrete nudge for the case it catches.
10
- *
11
- * ONE LINE FOR BOTH STORES, and it names ONE tool. `kb_query` is a cross-store retrieval (document
12
- * chunks AND memory facts), so a single line covers whichever store matched. Per-store lines used
13
- * to name two tools, which invited two overlapping calls — the memory facts came back twice, once
14
- * from `mem_recall` and again inside `kb_query`'s fused result — and made every memory↔knowledge
15
- * transition a fresh snapshot append. `mem_recall` remains the tool for the memory-only actions
16
- * (chain / probe / reason / contradict); the always-on memory usage section is where that is said.
17
- *
18
- * WHY THE LINE NAMES THE PLUGIN. This text is injected as runtime context, and the harness
19
- * materialises that as a USER-role snapshot in the conversation (`dsh-agent-loop`'s
20
- * `runtimeContext.project`). Without an author, a line like "记忆里有相关内容" reads as something
21
- * the user said. The `[avantf-mem]` prefix is what keeps the provenance honest.
22
- */
23
- export const RELEVANCE_HINT = '[avantf-mem] 记忆或知识库里有与上条用户消息相关的内容;需要时用 `kb_query` 检索。';
24
- /**
25
- * Map one answer to the contribution, as text.
26
- *
27
- * An empty string is the "contribute nothing" value: `renderContextSections` drops empty text, so
28
- * "nothing found" costs no tokens at all.
29
- */
30
- export function hintText(hit) {
31
- return hit ? RELEVANCE_HINT : '';
32
- }
33
- /**
34
- * The plain text of an inbox message, or `''` when it carries none.
35
- *
36
- * `dsh-agent-loop`'s own extractor returns `undefined` unless the message is exactly ONE text
37
- * block; a steered or multi-part message would then silently produce no hint. Concatenating the
38
- * text blocks keeps the probe working for those, and non-text blocks (images) are simply skipped —
39
- * the probe is lexical, so it has nothing to say about them anyway.
40
- */
41
- export function messageText(message) {
42
- const content = message?.content;
43
- if (!Array.isArray(content))
44
- return '';
45
- return content
46
- .map((block) => {
47
- const b = block;
48
- return b?.type === 'text' && typeof b.text === 'string' ? b.text : '';
49
- })
50
- .filter(Boolean)
51
- .join('\n');
52
- }
53
- //# sourceMappingURL=hints.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hints.js","sourceRoot":"","sources":["../../src/hints.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,CAAC,MAAM,cAAc,GACzB,uDAAuD,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAiB;IACxC,OAAO,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,OAAO,GAAI,OAAwC,EAAE,OAAO,CAAA;IAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAA;IACtC,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,CAAC,GAAG,KAA0C,CAAA;QACpD,OAAO,CAAC,EAAE,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IACvE,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC"}