@gmickel/gno 1.45.1 → 2.0.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 (236) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +46 -0
  3. package/assets/skill/SKILL.md +7 -6
  4. package/assets/skill/cli-reference.md +14 -6
  5. package/assets/skill/mcp-reference.md +4 -1
  6. package/assets/spa-production.json.gz +0 -0
  7. package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip +0 -0
  8. package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip.sha256 +1 -0
  9. package/browser-extension/dist/chunk-4tc9v0ja.js +74 -0
  10. package/browser-extension/dist/manifest.json +1 -1
  11. package/browser-extension/dist/preview.html +1 -1
  12. package/browser-extension/dist/service-worker.js +32 -33
  13. package/bunfig.toml +2 -0
  14. package/package.json +40 -26
  15. package/spec/cli.md +30 -11
  16. package/spec/db/schema.sql +146 -1
  17. package/spec/mcp.md +26 -0
  18. package/src/app/context-runtime-types.ts +3 -0
  19. package/src/app/context-runtime.ts +2 -0
  20. package/src/cli/commands/ask.ts +6 -1
  21. package/src/cli/commands/daemon.ts +21 -8
  22. package/src/cli/commands/embed.ts +77 -41
  23. package/src/cli/commands/mcp/install.ts +20 -0
  24. package/src/cli/commands/mcp/paths.ts +25 -0
  25. package/src/cli/commands/mcp/status.ts +6 -0
  26. package/src/cli/detach.ts +3 -2
  27. package/src/cli/program.ts +6 -0
  28. package/src/config/types.ts +3 -3
  29. package/src/converters/adapters/markitdownTs/adapter.ts +1 -2
  30. package/src/converters/adapters/officeparser/adapter.ts +1 -2
  31. package/src/converters/versions.ts +6 -8
  32. package/src/core/context-evidence.ts +8 -4
  33. package/src/core/job-manager.ts +95 -13
  34. package/src/core/network-boundary-inventory.ts +10 -0
  35. package/src/core/shutdown-budget.ts +45 -0
  36. package/src/embed/backlog.ts +107 -4
  37. package/src/embed/batch.ts +42 -2
  38. package/src/embed/fingerprint.ts +16 -0
  39. package/src/embed/retry.ts +113 -5
  40. package/src/embed/variant-backlog.ts +105 -0
  41. package/src/embed/variant-plan.ts +62 -0
  42. package/src/embed/variant-retry.ts +113 -0
  43. package/src/ingestion/graph-reconciliation.ts +327 -0
  44. package/src/ingestion/sync.ts +9 -272
  45. package/src/llm/http-inference.ts +6 -0
  46. package/src/llm/httpEmbedding.ts +37 -6
  47. package/src/llm/httpGeneration.ts +18 -3
  48. package/src/llm/httpRerank.ts +23 -5
  49. package/src/llm/inference-cancellation.ts +168 -0
  50. package/src/llm/inference-scope.ts +202 -0
  51. package/src/llm/lazy-ports.ts +115 -0
  52. package/src/llm/native-worker/client.ts +541 -0
  53. package/src/llm/native-worker/dispatcher.ts +228 -0
  54. package/src/llm/native-worker/embedding-identity.ts +33 -0
  55. package/src/llm/native-worker/entry.ts +173 -0
  56. package/src/llm/native-worker/errors.ts +32 -0
  57. package/src/llm/native-worker/evaluation.ts +16 -0
  58. package/src/llm/native-worker/owned-exit.ts +108 -0
  59. package/src/llm/native-worker/owner.ts +141 -0
  60. package/src/llm/native-worker/ports.ts +317 -0
  61. package/src/llm/native-worker/protocol.ts +442 -0
  62. package/src/llm/native-worker/runtime-config.ts +92 -0
  63. package/src/llm/nodeLlamaCpp/adapter.ts +77 -20
  64. package/src/llm/nodeLlamaCpp/embedding.ts +130 -46
  65. package/src/llm/nodeLlamaCpp/generation.ts +34 -5
  66. package/src/llm/nodeLlamaCpp/lifecycle-options.ts +99 -0
  67. package/src/llm/nodeLlamaCpp/lifecycle.ts +209 -204
  68. package/src/llm/nodeLlamaCpp/rerank-capacity.ts +111 -0
  69. package/src/llm/nodeLlamaCpp/rerank.ts +118 -27
  70. package/src/llm/nodeLlamaCpp/simulator-handle.ts +73 -0
  71. package/src/llm/nodeLlamaCpp/simulator-install.ts +124 -0
  72. package/src/llm/nodeLlamaCpp/simulator-session.ts +240 -0
  73. package/src/llm/nodeLlamaCpp/simulator-types.ts +80 -0
  74. package/src/llm/types.ts +35 -5
  75. package/src/mcp/context.ts +27 -0
  76. package/src/mcp/http-transport.ts +12 -10
  77. package/src/mcp/server.ts +3 -0
  78. package/src/mcp/tool-profile.ts +30 -8
  79. package/src/mcp/tools/context.ts +8 -11
  80. package/src/mcp/tools/embed.ts +1 -1
  81. package/src/mcp/tools/index-cmd.ts +1 -1
  82. package/src/mcp/tools/index.ts +10 -8
  83. package/src/mcp/tools/query.ts +14 -30
  84. package/src/mcp/tools/vsearch.ts +1 -1
  85. package/src/pipeline/answer.ts +23 -3
  86. package/src/pipeline/claim-verifier.ts +6 -0
  87. package/src/pipeline/expansion.ts +43 -40
  88. package/src/pipeline/explain.ts +6 -2
  89. package/src/pipeline/filters.ts +63 -0
  90. package/src/pipeline/fusion.ts +29 -9
  91. package/src/pipeline/graph-retrieval.ts +29 -9
  92. package/src/pipeline/hybrid.ts +198 -55
  93. package/src/pipeline/hydration.ts +161 -0
  94. package/src/pipeline/owner-fusion.ts +87 -0
  95. package/src/pipeline/rerank.ts +35 -11
  96. package/src/pipeline/search.ts +13 -2
  97. package/src/pipeline/types.ts +5 -3
  98. package/src/pipeline/vsearch.ts +87 -7
  99. package/src/sdk/client.ts +47 -3
  100. package/src/sdk/embed.ts +63 -39
  101. package/src/serve/background-runtime.ts +1 -1
  102. package/src/serve/context.ts +41 -56
  103. package/src/serve/embed-scheduler.ts +58 -35
  104. package/src/serve/public/components/IndexingProgress.tsx +46 -60
  105. package/src/serve/public/globals.built.css +1 -1
  106. package/src/serve/public/lib/shiki-language-ids.ts +14 -0
  107. package/src/serve/resident-admission.ts +36 -36
  108. package/src/serve/resident-background-work.ts +20 -2
  109. package/src/serve/resident-request.ts +11 -5
  110. package/src/serve/resident-runtime.ts +97 -61
  111. package/src/serve/resident-shutdown.ts +153 -0
  112. package/src/serve/routes/api.ts +3 -1
  113. package/src/serve/server.ts +47 -26
  114. package/src/store/migrations/028-vector-variants.ts +54 -0
  115. package/src/store/migrations/029-graph-reference-state.ts +77 -0
  116. package/src/store/migrations/index.ts +4 -0
  117. package/src/store/sqlite/adapter.ts +251 -183
  118. package/src/store/sqlite/eligibility.ts +174 -0
  119. package/src/store/sqlite/graph-edge-application.ts +66 -0
  120. package/src/store/sqlite/graph-reference-state.ts +194 -0
  121. package/src/store/sqlite/legacy-vector-ownership.ts +79 -0
  122. package/src/store/types.ts +80 -12
  123. package/src/store/vector/eligibility.ts +36 -0
  124. package/src/store/vector/freshness.ts +33 -6
  125. package/src/store/vector/lazy.ts +81 -0
  126. package/src/store/vector/sqlite-vec.ts +106 -54
  127. package/src/store/vector/stats.ts +14 -3
  128. package/src/store/vector/types.ts +35 -2
  129. package/src/store/vector/variant-search.ts +192 -0
  130. package/src/store/vector/variants.ts +451 -0
  131. package/vendor/converters/markitdown-ts/LICENSE +21 -0
  132. package/vendor/converters/markitdown-ts/dist/index.cjs +1180 -0
  133. package/vendor/converters/markitdown-ts/dist/index.d.cts +46 -0
  134. package/vendor/converters/markitdown-ts/dist/index.d.mts +46 -0
  135. package/vendor/converters/markitdown-ts/dist/index.d.ts +46 -0
  136. package/vendor/converters/markitdown-ts/dist/index.mjs +1152 -0
  137. package/vendor/converters/markitdown-ts/package.json +77 -0
  138. package/vendor/converters/officeparser/LICENSE +21 -0
  139. package/vendor/converters/officeparser/dist/OfficeConverter.d.ts +47 -0
  140. package/vendor/converters/officeparser/dist/OfficeConverter.js +76 -0
  141. package/vendor/converters/officeparser/dist/OfficeGenerator.d.ts +23 -0
  142. package/vendor/converters/officeparser/dist/OfficeGenerator.js +73 -0
  143. package/vendor/converters/officeparser/dist/OfficeParser.d.ts +106 -0
  144. package/vendor/converters/officeparser/dist/OfficeParser.js +332 -0
  145. package/vendor/converters/officeparser/dist/cli.d.ts +28 -0
  146. package/vendor/converters/officeparser/dist/cli.js +381 -0
  147. package/vendor/converters/officeparser/dist/defaults.d.ts +41 -0
  148. package/vendor/converters/officeparser/dist/defaults.js +218 -0
  149. package/vendor/converters/officeparser/dist/generators/BaseGenerator.d.ts +107 -0
  150. package/vendor/converters/officeparser/dist/generators/BaseGenerator.js +248 -0
  151. package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.d.ts +82 -0
  152. package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.js +797 -0
  153. package/vendor/converters/officeparser/dist/generators/CsvGenerator.d.ts +38 -0
  154. package/vendor/converters/officeparser/dist/generators/CsvGenerator.js +245 -0
  155. package/vendor/converters/officeparser/dist/generators/EpubGenerator.d.ts +43 -0
  156. package/vendor/converters/officeparser/dist/generators/EpubGenerator.js +315 -0
  157. package/vendor/converters/officeparser/dist/generators/HtmlGenerator.d.ts +59 -0
  158. package/vendor/converters/officeparser/dist/generators/HtmlGenerator.js +1942 -0
  159. package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.d.ts +96 -0
  160. package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.js +1175 -0
  161. package/vendor/converters/officeparser/dist/generators/PdfGenerator.d.ts +22 -0
  162. package/vendor/converters/officeparser/dist/generators/PdfGenerator.js +194 -0
  163. package/vendor/converters/officeparser/dist/generators/RtfGenerator.d.ts +29 -0
  164. package/vendor/converters/officeparser/dist/generators/RtfGenerator.js +316 -0
  165. package/vendor/converters/officeparser/dist/generators/TextGenerator.d.ts +13 -0
  166. package/vendor/converters/officeparser/dist/generators/TextGenerator.js +201 -0
  167. package/vendor/converters/officeparser/dist/index.d.ts +60 -0
  168. package/vendor/converters/officeparser/dist/index.js +72 -0
  169. package/vendor/converters/officeparser/dist/index.mjs +18 -0
  170. package/vendor/converters/officeparser/dist/officeparser.browser.d.ts +2621 -0
  171. package/vendor/converters/officeparser/dist/officeparser.browser.iife.js +1336 -0
  172. package/vendor/converters/officeparser/dist/officeparser.browser.mjs +1335 -0
  173. package/vendor/converters/officeparser/dist/officeparser.browser.slim.d.ts +2621 -0
  174. package/vendor/converters/officeparser/dist/officeparser.browser.slim.iife.js +1336 -0
  175. package/vendor/converters/officeparser/dist/officeparser.browser.slim.mjs +1335 -0
  176. package/vendor/converters/officeparser/dist/parsers/CsvParser.d.ts +9 -0
  177. package/vendor/converters/officeparser/dist/parsers/CsvParser.js +115 -0
  178. package/vendor/converters/officeparser/dist/parsers/EpubParser.d.ts +8 -0
  179. package/vendor/converters/officeparser/dist/parsers/EpubParser.js +217 -0
  180. package/vendor/converters/officeparser/dist/parsers/ExcelParser.d.ts +32 -0
  181. package/vendor/converters/officeparser/dist/parsers/ExcelParser.js +736 -0
  182. package/vendor/converters/officeparser/dist/parsers/HtmlParser.d.ts +2 -0
  183. package/vendor/converters/officeparser/dist/parsers/HtmlParser.js +1287 -0
  184. package/vendor/converters/officeparser/dist/parsers/MarkdownParser.d.ts +2 -0
  185. package/vendor/converters/officeparser/dist/parsers/MarkdownParser.js +1272 -0
  186. package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.d.ts +31 -0
  187. package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.js +1819 -0
  188. package/vendor/converters/officeparser/dist/parsers/PdfParser.d.ts +67 -0
  189. package/vendor/converters/officeparser/dist/parsers/PdfParser.js +848 -0
  190. package/vendor/converters/officeparser/dist/parsers/PowerPointParser.d.ts +32 -0
  191. package/vendor/converters/officeparser/dist/parsers/PowerPointParser.js +950 -0
  192. package/vendor/converters/officeparser/dist/parsers/RtfParser.d.ts +187 -0
  193. package/vendor/converters/officeparser/dist/parsers/RtfParser.js +1801 -0
  194. package/vendor/converters/officeparser/dist/parsers/WordParser.d.ts +79 -0
  195. package/vendor/converters/officeparser/dist/parsers/WordParser.js +1177 -0
  196. package/vendor/converters/officeparser/dist/sbom.cdx.json +1763 -0
  197. package/vendor/converters/officeparser/dist/types.d.ts +2507 -0
  198. package/vendor/converters/officeparser/dist/types.js +107 -0
  199. package/vendor/converters/officeparser/dist/utils/astUtils.d.ts +16 -0
  200. package/vendor/converters/officeparser/dist/utils/astUtils.js +33 -0
  201. package/vendor/converters/officeparser/dist/utils/chartUtils.d.ts +6 -0
  202. package/vendor/converters/officeparser/dist/utils/chartUtils.js +257 -0
  203. package/vendor/converters/officeparser/dist/utils/configUtils.d.ts +44 -0
  204. package/vendor/converters/officeparser/dist/utils/configUtils.js +315 -0
  205. package/vendor/converters/officeparser/dist/utils/dateUtils.d.ts +17 -0
  206. package/vendor/converters/officeparser/dist/utils/dateUtils.js +69 -0
  207. package/vendor/converters/officeparser/dist/utils/envUtils.d.ts +29 -0
  208. package/vendor/converters/officeparser/dist/utils/envUtils.js +152 -0
  209. package/vendor/converters/officeparser/dist/utils/errorUtils.d.ts +72 -0
  210. package/vendor/converters/officeparser/dist/utils/errorUtils.js +245 -0
  211. package/vendor/converters/officeparser/dist/utils/imageUtils.d.ts +66 -0
  212. package/vendor/converters/officeparser/dist/utils/imageUtils.js +133 -0
  213. package/vendor/converters/officeparser/dist/utils/mathUtils.d.ts +42 -0
  214. package/vendor/converters/officeparser/dist/utils/mathUtils.js +385 -0
  215. package/vendor/converters/officeparser/dist/utils/moduleLoader.d.ts +18 -0
  216. package/vendor/converters/officeparser/dist/utils/moduleLoader.js +106 -0
  217. package/vendor/converters/officeparser/dist/utils/ocrUtils.d.ts +42 -0
  218. package/vendor/converters/officeparser/dist/utils/ocrUtils.js +428 -0
  219. package/vendor/converters/officeparser/dist/utils/sanitize.d.ts +148 -0
  220. package/vendor/converters/officeparser/dist/utils/sanitize.js +344 -0
  221. package/vendor/converters/officeparser/dist/utils/sheetUtils.d.ts +7 -0
  222. package/vendor/converters/officeparser/dist/utils/sheetUtils.js +35 -0
  223. package/vendor/converters/officeparser/dist/utils/styleMapper.d.ts +36 -0
  224. package/vendor/converters/officeparser/dist/utils/styleMapper.js +224 -0
  225. package/vendor/converters/officeparser/dist/utils/xmlUtils.d.ts +163 -0
  226. package/vendor/converters/officeparser/dist/utils/xmlUtils.js +461 -0
  227. package/vendor/converters/officeparser/dist/utils/zipUtils.d.ts +134 -0
  228. package/vendor/converters/officeparser/dist/utils/zipUtils.js +337 -0
  229. package/vendor/converters/officeparser/package.json +147 -0
  230. package/vendor/converters/upstream-manifest.json +124 -0
  231. package/vendor/dependency-fixes/README.md +77 -0
  232. package/vendor/dependency-fixes/vendor-converters.py +83 -0
  233. package/browser-extension/artifacts/gno-browser-clipper-v1.45.1.zip +0 -0
  234. package/browser-extension/artifacts/gno-browser-clipper-v1.45.1.zip.sha256 +0 -1
  235. package/browser-extension/dist/chunk-627emwpj.js +0 -75
  236. /package/browser-extension/dist/{chunk-ydfx5d7p.css → chunk-z74y8n8c.css} +0 -0
@@ -22,6 +22,7 @@ import {
22
22
  type WriteLeaseContention,
23
23
  withCliWriteLease,
24
24
  } from "../../core/write-lease";
25
+ import { embedBacklog, prepareEmbeddingBacklog } from "../../embed/backlog";
25
26
  import { getEmbeddingFingerprint } from "../../embed/fingerprint";
26
27
  import {
27
28
  addUniqueSamples,
@@ -38,6 +39,7 @@ import {
38
39
  markIndexStageRunning,
39
40
  readIndexStageState,
40
41
  } from "../../embed/stage-state";
42
+ import { countVariantBacklog } from "../../embed/variant-plan";
41
43
  import { LlmAdapter } from "../../llm/nodeLlamaCpp/adapter";
42
44
  import { resolveDownloadPolicy } from "../../llm/policy";
43
45
  import { resolveModelUri } from "../../llm/registry";
@@ -139,18 +141,6 @@ function isDisposedBatchError(message: string): boolean {
139
141
  return message.toLowerCase().includes("object is disposed");
140
142
  }
141
143
 
142
- async function checkVecAvailable(
143
- db: import("bun:sqlite").Database
144
- ): Promise<boolean> {
145
- try {
146
- const sqliteVec = await import("sqlite-vec");
147
- sqliteVec.load(db);
148
- return true;
149
- } catch {
150
- return false;
151
- }
152
- }
153
-
154
144
  interface BatchContext {
155
145
  db: import("bun:sqlite").Database;
156
146
  stats: VectorStatsPort;
@@ -506,28 +496,6 @@ export async function embed(options: EmbedOptions = {}): Promise<EmbedResult> {
506
496
  const stats: VectorStatsPort = createVectorStatsPort(db);
507
497
 
508
498
  let totalToEmbed = 0;
509
- if (force) {
510
- const forceCount = await getActiveChunkCount(db, options.collection);
511
- if (!forceCount.ok) {
512
- return { success: false, error: forceCount.error.message };
513
- }
514
- totalToEmbed = forceCount.value;
515
-
516
- if (totalToEmbed === 0 || dryRun) {
517
- const vecAvailable = await checkVecAvailable(db);
518
- return {
519
- success: true,
520
- embedded: totalToEmbed,
521
- errors: 0,
522
- contentionErrors: 0,
523
- duration: 0,
524
- model: modelUri,
525
- searchAvailable: vecAvailable,
526
- errorSamples: [],
527
- };
528
- }
529
- }
530
-
531
499
  // Create LLM adapter and embedding port with auto-download
532
500
  let offline = options.offline;
533
501
  if (offline === undefined) {
@@ -585,12 +553,16 @@ export async function embed(options: EmbedOptions = {}): Promise<EmbedResult> {
585
553
  process.stderr.write("\n");
586
554
  }
587
555
 
588
- // Discover dimensions via probe embedding
589
- const probeResult = await embedPort.embed("dimension probe");
590
- if (!probeResult.ok) {
591
- return { success: false, error: probeResult.error.message };
556
+ const initializedPort = await embedPort.init();
557
+ if (!initializedPort.ok)
558
+ return { success: false, error: initializedPort.error.message };
559
+ let dimensions = embedPort.dimensions();
560
+ if (!embedPort.getIdentity?.()) {
561
+ const probeResult = await embedPort.embed("dimension probe");
562
+ if (!probeResult.ok)
563
+ return { success: false, error: probeResult.error.message };
564
+ dimensions = probeResult.value.length;
592
565
  }
593
- const dimensions = probeResult.value.length;
594
566
 
595
567
  // Create vector index port
596
568
  const vectorResult = await createVectorIndexPort(db, {
@@ -602,6 +574,70 @@ export async function embed(options: EmbedOptions = {}): Promise<EmbedResult> {
602
574
  }
603
575
  vectorIndex = vectorResult.value;
604
576
 
577
+ const prepared = await prepareEmbeddingBacklog({
578
+ statsPort: stats,
579
+ embedPort,
580
+ vectorIndex,
581
+ modelUri,
582
+ collection: options.collection,
583
+ batchSize,
584
+ force,
585
+ });
586
+ if (!prepared.ok)
587
+ return { success: false, error: prepared.error.message };
588
+ if (prepared.value.variantStore) {
589
+ totalToEmbed = countVariantBacklog(prepared.value);
590
+ const startedAt = Date.now();
591
+ if (dryRun)
592
+ return {
593
+ success: true,
594
+ embedded: totalToEmbed,
595
+ errors: 0,
596
+ contentionErrors: 0,
597
+ duration: 0,
598
+ model: modelUri,
599
+ searchAvailable: prepared.value.variantStore.searchAvailable,
600
+ errorSamples: [],
601
+ };
602
+ const processed = await embedBacklog({
603
+ ...prepared.value,
604
+ onProgress: !options.json
605
+ ? (embedded, errors) =>
606
+ process.stderr.write(
607
+ `\rEmbedded ${embedded}/${totalToEmbed} owners; ${errors} errors`
608
+ )
609
+ : undefined,
610
+ });
611
+ if (!options.json) process.stderr.write("\n");
612
+ if (!processed.ok)
613
+ return { success: false, error: processed.error.message };
614
+ return {
615
+ success: true,
616
+ ...processed.value,
617
+ contentionErrors: processed.value.contentionErrors ?? 0,
618
+ duration: (Date.now() - startedAt) / 1000,
619
+ model: modelUri,
620
+ searchAvailable: prepared.value.variantStore.searchAvailable,
621
+ errorSamples: [],
622
+ };
623
+ }
624
+ if (force) {
625
+ const count = await getActiveChunkCount(db, options.collection);
626
+ if (!count.ok) return { success: false, error: count.error.message };
627
+ totalToEmbed = count.value;
628
+ if (dryRun || !totalToEmbed)
629
+ return {
630
+ success: true,
631
+ embedded: totalToEmbed,
632
+ errors: 0,
633
+ contentionErrors: 0,
634
+ duration: 0,
635
+ model: modelUri,
636
+ searchAvailable: vectorIndex.searchAvailable,
637
+ errorSamples: [],
638
+ };
639
+ }
640
+
605
641
  if (!force) {
606
642
  const embedFingerprint = getEmbeddingFingerprint({
607
643
  modelUri,
@@ -773,7 +809,7 @@ function getActiveChunks(
773
809
  const sql = after
774
810
  ? `
775
811
  SELECT c.mirror_hash as mirrorHash, c.seq, c.text,
776
- (SELECT d.title FROM documents d WHERE d.mirror_hash = c.mirror_hash AND d.active = 1 LIMIT 1) as title,
812
+ (SELECT d.title FROM documents d WHERE d.mirror_hash = c.mirror_hash AND d.active = 1 ORDER BY d.id LIMIT 1) as title,
777
813
  'force' as reason
778
814
  FROM content_chunks c
779
815
  WHERE EXISTS (
@@ -786,7 +822,7 @@ function getActiveChunks(
786
822
  `
787
823
  : `
788
824
  SELECT c.mirror_hash as mirrorHash, c.seq, c.text,
789
- (SELECT d.title FROM documents d WHERE d.mirror_hash = c.mirror_hash AND d.active = 1 LIMIT 1) as title,
825
+ (SELECT d.title FROM documents d WHERE d.mirror_hash = c.mirror_hash AND d.active = 1 ORDER BY d.id LIMIT 1) as title,
790
826
  'force' as reason
791
827
  FROM content_chunks c
792
828
  WHERE EXISTS (
@@ -6,6 +6,10 @@
6
6
 
7
7
  import { DEFAULT_INDEX_NAME } from "../../../app/constants.js";
8
8
  import { getConfigPaths, toAbsolutePath } from "../../../config/paths.js";
9
+ import {
10
+ type McpToolProfile,
11
+ parseMcpToolProfile,
12
+ } from "../../../mcp/tool-profile.js";
9
13
  import { CliError } from "../../errors.js";
10
14
  import { getGlobals } from "../../program.js";
11
15
  import { resolveMcpConfigLocation } from "./config-discovery.js";
@@ -45,6 +49,8 @@ export interface InstallOptions {
45
49
  force?: boolean;
46
50
  dryRun?: boolean;
47
51
  enableWrite?: boolean;
52
+ /** Advertised tool set written into the registration (`core` or `full`). */
53
+ toolProfile?: McpToolProfile;
48
54
  /** Index identity persisted in the installed MCP command. */
49
55
  indexName?: string;
50
56
  /** Active GNO config persisted as a canonical absolute path. */
@@ -166,6 +172,18 @@ function safeGetGlobals(): { json: boolean; quiet: boolean } {
166
172
  }
167
173
  }
168
174
 
175
+ /** Validate the requested profile before any config file is read or written. */
176
+ function parseInstallToolProfile(value: unknown): McpToolProfile | undefined {
177
+ try {
178
+ return parseMcpToolProfile(value);
179
+ } catch (error) {
180
+ throw new CliError(
181
+ "VALIDATION",
182
+ error instanceof Error ? error.message : String(error)
183
+ );
184
+ }
185
+ }
186
+
169
187
  /**
170
188
  * Install gno MCP server.
171
189
  */
@@ -175,6 +193,7 @@ export async function installMcp(opts: InstallOptions = {}): Promise<void> {
175
193
  const force = opts.force ?? false;
176
194
  const dryRun = opts.dryRun ?? false;
177
195
  const enableWrite = opts.enableWrite ?? false;
196
+ const toolProfile = parseInstallToolProfile(opts.toolProfile);
178
197
  const indexName = opts.indexName ?? DEFAULT_INDEX_NAME;
179
198
  const paths = getConfigPaths();
180
199
  const configPath = toAbsolutePath(
@@ -196,6 +215,7 @@ export async function installMcp(opts: InstallOptions = {}): Promise<void> {
196
215
  // Build server entry (uses process.execPath, always succeeds)
197
216
  const serverEntry = buildMcpServerEntry({
198
217
  enableWrite,
218
+ toolProfile,
199
219
  indexName,
200
220
  configPath,
201
221
  dataDir: toAbsolutePath(paths.dataDir, opts.cwd),
@@ -13,6 +13,11 @@ import type { ConnectorWorkspaceEnvironment } from "../../../core/connector-envi
13
13
  import { resolveDirs } from "../../../app/constants";
14
14
  import { assertValidIndexName } from "../../../app/index-name";
15
15
  import { getCurrentGnoEntrypoint } from "../../../core/runtime-entrypoint";
16
+ import {
17
+ DEFAULT_MCP_TOOL_PROFILE,
18
+ type McpToolProfile,
19
+ isMcpToolProfile,
20
+ } from "../../../mcp/tool-profile.js";
16
21
  import { getTargetDisplayName } from "./target-display.js";
17
22
 
18
23
  export { getTargetDisplayName } from "./target-display.js";
@@ -70,6 +75,8 @@ export interface McpServerEntry {
70
75
 
71
76
  interface McpServerEntryOptions {
72
77
  enableWrite?: boolean;
78
+ /** Advertised MCP tool set the registration starts with; omitted = `full`. */
79
+ toolProfile?: McpToolProfile;
73
80
  indexName?: string;
74
81
  configPath?: string;
75
82
  dataDir?: string;
@@ -485,7 +492,25 @@ function appendMcpArguments(
485
492
  args.push("--config", resolve(options.configPath));
486
493
  }
487
494
  args.push("mcp");
495
+ if (options.toolProfile !== undefined) {
496
+ args.push("--tool-profile", options.toolProfile);
497
+ }
488
498
  if (options.enableWrite) {
489
499
  args.push("--enable-write");
490
500
  }
491
501
  }
502
+
503
+ /**
504
+ * The tool profile a registration starts with, read back from its args.
505
+ * A registration written before the flag existed carries none and runs `full`.
506
+ */
507
+ export function readMcpToolProfileFromArgs(
508
+ args: ReadonlyArray<string>
509
+ ): McpToolProfile {
510
+ const index = args.indexOf("--tool-profile");
511
+ if (index === -1) {
512
+ return DEFAULT_MCP_TOOL_PROFILE;
513
+ }
514
+ const value = args[index + 1];
515
+ return isMcpToolProfile(value) ? value : DEFAULT_MCP_TOOL_PROFILE;
516
+ }
@@ -6,6 +6,7 @@
6
6
 
7
7
  import type { ConnectorWorkspaceEnvironment } from "../../../core/connector-environment";
8
8
  import type { McpConnectorVerificationTarget } from "../../../core/connector-verifier";
9
+ import type { McpToolProfile } from "../../../mcp/tool-profile.js";
9
10
  import type { StandardMcpEntry } from "./config.js";
10
11
 
11
12
  import { normalizeConnectorWorkspaceEnvironment } from "../../../core/connector-environment";
@@ -29,6 +30,7 @@ import {
29
30
  type McpScope,
30
31
  type McpTarget,
31
32
  resolveMcpConfigPath,
33
+ readMcpToolProfileFromArgs,
32
34
  } from "./paths.js";
33
35
 
34
36
  // ─────────────────────────────────────────────────────────────────────────────
@@ -56,6 +58,8 @@ export interface McpTargetStatus {
56
58
  args: string[];
57
59
  env?: ConnectorWorkspaceEnvironment;
58
60
  };
61
+ /** Tool profile the registration starts with; `full` when its args carry none. */
62
+ toolProfile?: McpToolProfile;
59
63
  error?: string;
60
64
  }
61
65
 
@@ -234,6 +238,7 @@ export async function checkMcpTargetStatus(
234
238
  configPath,
235
239
  configured: true,
236
240
  serverEntry,
241
+ toolProfile: readMcpToolProfileFromArgs(serverEntry.args),
237
242
  };
238
243
  configIdentityByStatus.set(status, configIdentity);
239
244
  return status;
@@ -341,6 +346,7 @@ export async function statusMcp(opts: StatusOptions = {}): Promise<void> {
341
346
  if (status.configured && status.serverEntry) {
342
347
  process.stdout.write(` Command: ${status.serverEntry.command}\n`);
343
348
  process.stdout.write(` Args: ${status.serverEntry.args.join(" ")}\n`);
349
+ process.stdout.write(` Profile: ${status.toolProfile ?? "full"}\n`);
344
350
  }
345
351
 
346
352
  if (status.error) {
package/src/cli/detach.ts CHANGED
@@ -25,6 +25,7 @@ import type { ResidentStatus } from "../serve/status-model";
25
25
  import { VERSION, resolveDirs } from "../app/constants";
26
26
  import { toAbsolutePath } from "../config/paths";
27
27
  import { atomicWrite } from "../core/file-ops";
28
+ import { RESIDENT_STOP_GRACE_MS } from "../core/shutdown-budget";
28
29
  import { isResidentStatus } from "../serve/resident-status";
29
30
  import { CliError } from "./errors";
30
31
 
@@ -877,7 +878,7 @@ export async function inspectForeignLive(options: {
877
878
  export interface StopOptions {
878
879
  kind: DetachKind;
879
880
  pidFile: string;
880
- /** Grace period for SIGTERM before we escalate to SIGKILL. Default 10s. */
881
+ /** Grace period for SIGTERM before we escalate to SIGKILL. Default 12s. */
881
882
  timeoutMs?: number;
882
883
  /** Poll interval while waiting for the process to exit. Default 100ms. */
883
884
  pollIntervalMs?: number;
@@ -921,7 +922,7 @@ async function waitForExit(
921
922
  * unlinks stale pid-files it discovers on entry.
922
923
  */
923
924
  export async function stopProcess(options: StopOptions): Promise<StopOutcome> {
924
- const timeoutMs = options.timeoutMs ?? 10_000;
925
+ const timeoutMs = options.timeoutMs ?? RESIDENT_STOP_GRACE_MS;
925
926
  const pollIntervalMs = options.pollIntervalMs ?? 100;
926
927
  const killTimeoutMs = options.killTimeoutMs ?? 2_000;
927
928
  const sleep = options.sleep ?? defaultSleep;
@@ -2234,9 +2234,14 @@ function wireMcpCommand(program: Command): void {
2234
2234
  "--enable-write",
2235
2235
  "Enable write operations in installed MCP configuration"
2236
2236
  )
2237
+ .option(
2238
+ "--tool-profile <profile>",
2239
+ "advertised tool set the registration starts with: core (7 read tools + capture/remember with --enable-write) or full (default)"
2240
+ )
2237
2241
  .option("--json", "JSON output")
2238
2242
  .action(async (cmdOpts: Record<string, unknown>) => {
2239
2243
  const target = cmdOpts.target as string;
2244
+ const toolProfile = parseToolProfileOption(cmdOpts.toolProfile);
2240
2245
  const requestedScope = cmdOpts.scope;
2241
2246
 
2242
2247
  // Import MCP_TARGETS for validation
@@ -2278,6 +2283,7 @@ function wireMcpCommand(program: Command): void {
2278
2283
  force: Boolean(cmdOpts.force),
2279
2284
  dryRun: Boolean(cmdOpts.dryRun),
2280
2285
  enableWrite: Boolean(cmdOpts.enableWrite),
2286
+ toolProfile,
2281
2287
  indexName: globals.index,
2282
2288
  configPath: globals.config,
2283
2289
  // Pass undefined if not set, so global --json can take effect
@@ -425,9 +425,9 @@ export const ModelConfigSchema = z.object({
425
425
  /** Model presets */
426
426
  presets: z.array(ModelPresetSchema).default(DEFAULT_MODEL_PRESETS),
427
427
  /** Model load timeout in ms */
428
- loadTimeout: z.number().default(60_000),
429
- /** Inference timeout in ms */
430
- inferenceTimeout: z.number().default(30_000),
428
+ loadTimeout: z.number().int().min(1).max(2_147_483_647).default(60_000),
429
+ /** Inference timeout in ms, measured from native evaluation start. */
430
+ inferenceTimeout: z.number().int().min(1).max(2_147_483_647).default(30_000),
431
431
  /** Context size used for query expansion generation */
432
432
  expandContextSize: z.number().int().min(256).default(2_048),
433
433
  /** Keep warm model TTL in ms (5 min) */
@@ -3,8 +3,6 @@
3
3
  * Uses convertBuffer() with bytes for determinism.
4
4
  */
5
5
 
6
- import { MarkItDown } from "markitdown-ts";
7
-
8
6
  import type {
9
7
  Converter,
10
8
  ConvertInput,
@@ -12,6 +10,7 @@ import type {
12
10
  ConvertWarning,
13
11
  } from "../../types";
14
12
 
13
+ import { MarkItDown } from "../../../../vendor/converters/markitdown-ts";
15
14
  import {
16
15
  adapterError,
17
16
  corruptError,
@@ -3,8 +3,6 @@
3
3
  * Uses parseOffice() v7 API with Buffer for in-memory extraction.
4
4
  */
5
5
 
6
- import { parseOffice } from "officeparser";
7
-
8
6
  import type {
9
7
  Converter,
10
8
  ConvertInput,
@@ -12,6 +10,7 @@ import type {
12
10
  ConvertWarning,
13
11
  } from "../../types";
14
12
 
13
+ import { parseOffice } from "../../../../vendor/converters/officeparser";
15
14
  import { adapterError, corruptError, tooLargeError } from "../../errors";
16
15
  import { basenameWithoutExt } from "../../path";
17
16
  import { ADAPTER_VERSIONS } from "../../versions";
@@ -2,10 +2,9 @@
2
2
  * Centralized converter version tracking.
3
3
  *
4
4
  * Native converters use our own versioning.
5
- * Adapter versions MUST match the wrapped npm package version.
6
- *
7
- * When updating npm dependencies, update these versions too.
8
- * Run `bun pm ls markitdown-ts officeparser` to check current versions.
5
+ * Adapter versions identify upstream code and security-sensitive parser versions.
6
+ * Update them when changing the vendored distributions or parser dependencies.
7
+ * Upstream identities live in vendor/converters/upstream-manifest.json.
9
8
  */
10
9
 
11
10
  /** Native converter versions (our own) */
@@ -15,10 +14,9 @@ export const NATIVE_VERSIONS = {
15
14
  } as const;
16
15
 
17
16
  /**
18
- * Adapter versions - MUST match npm package versions.
19
- * Update these when running `bun update`.
17
+ * Include repaired parser versions so existing converted content is invalidated.
20
18
  */
21
19
  export const ADAPTER_VERSIONS = {
22
- "markitdown-ts": "0.0.8",
23
- officeparser: "6.0.4",
20
+ "markitdown-ts": "0.0.10+xlsx.0.20.3",
21
+ officeparser: "7.8.0+pdfjs.6.3.289",
24
22
  } as const;
@@ -1,6 +1,7 @@
1
1
  /** Strict indexed-evidence loading for Context Capsule compilation. */
2
2
 
3
3
  import type { EgressPolicy } from "../config/types";
4
+ import type { RequestHydration } from "../pipeline/hydration";
4
5
  import type { SearchResults } from "../pipeline/types";
5
6
  import type {
6
7
  ActivationIndexSnapshot,
@@ -127,6 +128,7 @@ export interface ContextEvidenceProjectionContext {
127
128
 
128
129
  export interface ContextEvidenceCompilerDeps<P> {
129
130
  store: ContextEvidenceStore;
131
+ hydration?: Pick<RequestHydration, "getContentBatch" | "getChunksBatch">;
130
132
  retrieve: (request: ContextRetrievalRequest) => Promise<SearchResults>;
131
133
  projectCanonical: (
132
134
  draft: ContextCanonicalPlanDraft<ContextEvidenceValue>,
@@ -329,7 +331,8 @@ const referenceDocument = (
329
331
  export const materializeContextEvidenceCandidates = async (
330
332
  store: ContextEvidenceStore,
331
333
  candidates: ContextRetrievalCandidate[],
332
- indexNameInput: string
334
+ indexNameInput: string,
335
+ hydration?: ContextEvidenceCompilerDeps<unknown>["hydration"]
333
336
  ): Promise<ContextMaterialization<ContextEvidenceValue>[]> => {
334
337
  if (candidates.length === 0) return [];
335
338
  const indexName = canonicalizeIndexName(indexNameInput);
@@ -363,8 +366,8 @@ export const materializeContextEvidenceCandidates = async (
363
366
  ),
364
367
  ];
365
368
  const [contentResult, chunksResult] = await Promise.all([
366
- store.getContentBatch(mirrorHashes),
367
- store.getChunksBatch(mirrorHashes),
369
+ (hydration ?? store).getContentBatch(mirrorHashes),
370
+ (hydration ?? store).getChunksBatch(mirrorHashes),
368
371
  ]);
369
372
  const contentByHash = unwrapStore(
370
373
  contentResult,
@@ -517,7 +520,8 @@ export const compileContextEvidence = async <P>(
517
520
  materializeContextEvidenceCandidates(
518
521
  deps.store,
519
522
  candidates,
520
- input.indexName
523
+ input.indexName,
524
+ deps.hydration
521
525
  ),
522
526
  projectCanonical: (draft) => deps.projectCanonical(draft, fingerprints),
523
527
  }