weavatrix 0.3.14 → 1.1.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 (306) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +132 -200
  3. package/bin/native/darwin-arm64/weavatrix +0 -0
  4. package/bin/native/darwin-x64/weavatrix +0 -0
  5. package/bin/native/linux-arm64/weavatrix +0 -0
  6. package/bin/native/linux-x64/weavatrix +0 -0
  7. package/bin/native/win32-arm64/weavatrix.exe +0 -0
  8. package/bin/native/win32-x64/weavatrix.exe +0 -0
  9. package/bin/resolve-binary.mjs +73 -0
  10. package/bin/run-native.mjs +26 -0
  11. package/bin/weavatrix-mcp.mjs +7 -6
  12. package/bin/weavatrix.mjs +5 -0
  13. package/package.json +10 -67
  14. package/server.json +38 -0
  15. package/skill/SKILL.md +62 -374
  16. package/skill/agents/openai.yaml +4 -0
  17. package/skill/references/tool-routing.md +45 -0
  18. package/SECURITY.md +0 -101
  19. package/docs/adr/0001-v0.3-offline-online-split.md +0 -60
  20. package/docs/agent-task-benchmark.md +0 -58
  21. package/docs/releases/v0.2.19.md +0 -33
  22. package/docs/releases/v0.3.0.md +0 -43
  23. package/docs/releases/v0.3.1.md +0 -30
  24. package/docs/releases/v0.3.10.md +0 -76
  25. package/docs/releases/v0.3.11.md +0 -55
  26. package/docs/releases/v0.3.12.md +0 -44
  27. package/docs/releases/v0.3.13.md +0 -34
  28. package/docs/releases/v0.3.14.md +0 -37
  29. package/docs/releases/v0.3.2.md +0 -15
  30. package/docs/releases/v0.3.3.md +0 -25
  31. package/docs/releases/v0.3.4.md +0 -40
  32. package/docs/releases/v0.3.5.md +0 -50
  33. package/docs/releases/v0.3.6.md +0 -44
  34. package/docs/releases/v0.3.7.md +0 -37
  35. package/docs/releases/v0.3.8.md +0 -21
  36. package/docs/releases/v0.3.9.md +0 -36
  37. package/scripts/run-agent-task-benchmark.mjs +0 -118
  38. package/src/analysis/allowed-test-runner.js +0 -70
  39. package/src/analysis/architecture/contract-graph.js +0 -119
  40. package/src/analysis/architecture/contract-schema.js +0 -110
  41. package/src/analysis/architecture/contract-storage.js +0 -35
  42. package/src/analysis/architecture/contract-verification.js +0 -168
  43. package/src/analysis/architecture-contract.js +0 -16
  44. package/src/analysis/audit-debt.js +0 -94
  45. package/src/analysis/audit-extensions.js +0 -60
  46. package/src/analysis/cargo-dependency-evidence.js +0 -108
  47. package/src/analysis/cargo-manifests.js +0 -81
  48. package/src/analysis/change-classification/diff-parser.js +0 -103
  49. package/src/analysis/change-classification/options.js +0 -40
  50. package/src/analysis/change-classification/symbol-classifier.js +0 -177
  51. package/src/analysis/change-classification.js +0 -188
  52. package/src/analysis/coverage-reports-tarpaulin.js +0 -112
  53. package/src/analysis/coverage-reports.js +0 -246
  54. package/src/analysis/cycle-route.js +0 -14
  55. package/src/analysis/data-flow-evidence.js +0 -114
  56. package/src/analysis/dead-check.js +0 -300
  57. package/src/analysis/dead-code-review/candidates.js +0 -194
  58. package/src/analysis/dead-code-review/policy.js +0 -23
  59. package/src/analysis/dead-code-review.js +0 -119
  60. package/src/analysis/dep-check-ecosystems.js +0 -205
  61. package/src/analysis/dep-check.js +0 -290
  62. package/src/analysis/dep-rules.js +0 -10
  63. package/src/analysis/dependency/conventions.js +0 -16
  64. package/src/analysis/dependency/scoped-dependencies.js +0 -51
  65. package/src/analysis/dependency/source-references.js +0 -21
  66. package/src/analysis/duplicate-groups.js +0 -104
  67. package/src/analysis/duplicates-worker.js +0 -11
  68. package/src/analysis/duplicates.compute.js +0 -269
  69. package/src/analysis/duplicates.js +0 -15
  70. package/src/analysis/duplicates.run.js +0 -52
  71. package/src/analysis/duplicates.tokenize.js +0 -199
  72. package/src/analysis/endpoints/common.js +0 -79
  73. package/src/analysis/endpoints/extract.js +0 -120
  74. package/src/analysis/endpoints/inventory.js +0 -84
  75. package/src/analysis/endpoints/mounts.js +0 -129
  76. package/src/analysis/endpoints-java.js +0 -260
  77. package/src/analysis/endpoints-rust.js +0 -124
  78. package/src/analysis/endpoints.js +0 -3
  79. package/src/analysis/findings.js +0 -70
  80. package/src/analysis/git-history/analytics.js +0 -177
  81. package/src/analysis/git-history/collector.js +0 -67
  82. package/src/analysis/git-history/options.js +0 -66
  83. package/src/analysis/git-history.js +0 -143
  84. package/src/analysis/git-ref-graph.js +0 -76
  85. package/src/analysis/go-dependency-evidence.js +0 -62
  86. package/src/analysis/graph-analysis.aggregate.js +0 -296
  87. package/src/analysis/graph-analysis.edges.js +0 -24
  88. package/src/analysis/graph-analysis.js +0 -7
  89. package/src/analysis/graph-analysis.refs.js +0 -202
  90. package/src/analysis/graph-analysis.summaries.js +0 -65
  91. package/src/analysis/health-capabilities.js +0 -83
  92. package/src/analysis/hot-path-review.js +0 -266
  93. package/src/analysis/http-contract-wrappers.js +0 -241
  94. package/src/analysis/http-contracts/analysis.js +0 -179
  95. package/src/analysis/http-contracts/client-call-detection.js +0 -82
  96. package/src/analysis/http-contracts/client-call-parser.js +0 -273
  97. package/src/analysis/http-contracts/graph-context.js +0 -143
  98. package/src/analysis/http-contracts/matching.js +0 -61
  99. package/src/analysis/http-contracts/shared.js +0 -85
  100. package/src/analysis/http-contracts.js +0 -6
  101. package/src/analysis/internal-audit/dependency-health.js +0 -113
  102. package/src/analysis/internal-audit/python-manifests.js +0 -78
  103. package/src/analysis/internal-audit/repo-files.js +0 -50
  104. package/src/analysis/internal-audit/supply-chain.js +0 -149
  105. package/src/analysis/internal-audit.collect.js +0 -213
  106. package/src/analysis/internal-audit.js +0 -9
  107. package/src/analysis/internal-audit.reach.js +0 -201
  108. package/src/analysis/internal-audit.run.js +0 -256
  109. package/src/analysis/java-source.js +0 -36
  110. package/src/analysis/jvm-artifact-index.js +0 -87
  111. package/src/analysis/jvm-dependency-evidence.js +0 -138
  112. package/src/analysis/jvm-manifests.js +0 -114
  113. package/src/analysis/manifests.js +0 -123
  114. package/src/analysis/package-reachability.js +0 -39
  115. package/src/analysis/source-complexity.ast.js +0 -97
  116. package/src/analysis/source-complexity.constants.js +0 -55
  117. package/src/analysis/source-complexity.js +0 -14
  118. package/src/analysis/source-complexity.report.js +0 -81
  119. package/src/analysis/source-complexity.walk.js +0 -228
  120. package/src/analysis/source-correctness/retry-patterns.js +0 -93
  121. package/src/analysis/source-correctness.js +0 -222
  122. package/src/analysis/static-test-reachability.js +0 -150
  123. package/src/analysis/structure/dependency-graph.js +0 -151
  124. package/src/analysis/structure/findings.js +0 -162
  125. package/src/analysis/task-retrieval.js +0 -107
  126. package/src/analysis/transport-contracts.js +0 -224
  127. package/src/analysis/transport-runtime-evidence.js +0 -155
  128. package/src/analysis-kit.mjs +0 -17
  129. package/src/bounds.js +0 -4
  130. package/src/build-graph.js +0 -209
  131. package/src/child-env.js +0 -7
  132. package/src/config.js +0 -5
  133. package/src/extension/local-services.mjs +0 -75
  134. package/src/git-exec.js +0 -67
  135. package/src/graph/build-worker.js +0 -49
  136. package/src/graph/builder/go-receiver-resolution.js +0 -112
  137. package/src/graph/builder/js/dynamic-import.js +0 -26
  138. package/src/graph/builder/js/queries.js +0 -48
  139. package/src/graph/builder/lang-csharp.js +0 -40
  140. package/src/graph/builder/lang-css.js +0 -29
  141. package/src/graph/builder/lang-go.js +0 -140
  142. package/src/graph/builder/lang-html.js +0 -29
  143. package/src/graph/builder/lang-java-calls.js +0 -142
  144. package/src/graph/builder/lang-java.js +0 -215
  145. package/src/graph/builder/lang-js.js +0 -291
  146. package/src/graph/builder/lang-python.js +0 -235
  147. package/src/graph/builder/lang-rust-calls.js +0 -63
  148. package/src/graph/builder/lang-rust.js +0 -299
  149. package/src/graph/builder/lang-solidity.js +0 -126
  150. package/src/graph/builder/lang-sql.js +0 -263
  151. package/src/graph/builder/pass2-resolution.js +0 -81
  152. package/src/graph/builder/spec-pkg.js +0 -87
  153. package/src/graph/community.js +0 -27
  154. package/src/graph/edge-provenance.js +0 -31
  155. package/src/graph/file-lock.js +0 -69
  156. package/src/graph/freshness-probe.js +0 -142
  157. package/src/graph/graph-filter.js +0 -63
  158. package/src/graph/incremental-refresh.js +0 -235
  159. package/src/graph/internal-builder.barrels.js +0 -235
  160. package/src/graph/internal-builder.build.js +0 -300
  161. package/src/graph/internal-builder.java.js +0 -33
  162. package/src/graph/internal-builder.js +0 -12
  163. package/src/graph/internal-builder.langs.js +0 -157
  164. package/src/graph/internal-builder.pass2.js +0 -163
  165. package/src/graph/internal-builder.resolvers.js +0 -286
  166. package/src/graph/layout.js +0 -51
  167. package/src/graph/node-id.js +0 -7
  168. package/src/graph/parser-artifact-boundary.js +0 -55
  169. package/src/graph/relations.js +0 -4
  170. package/src/graph/repo-registry.js +0 -124
  171. package/src/graph/resolvers/rust.js +0 -117
  172. package/src/infra/infra-items.js +0 -255
  173. package/src/infra/infra-registry.js +0 -184
  174. package/src/infra/infra.detect.js +0 -119
  175. package/src/infra/infra.js +0 -38
  176. package/src/infra/infra.match.js +0 -102
  177. package/src/infra/infra.scan.js +0 -93
  178. package/src/mcp/actions/graph-lifecycle.mjs +0 -148
  179. package/src/mcp/architecture-bootstrap.mjs +0 -168
  180. package/src/mcp/architecture-starter.mjs +0 -234
  181. package/src/mcp/catalog.mjs +0 -233
  182. package/src/mcp/company-contract-page.mjs +0 -142
  183. package/src/mcp/company-contract-reconcile.mjs +0 -87
  184. package/src/mcp/company-contract-verdict.mjs +0 -42
  185. package/src/mcp/evidence/bun-lock-graph.mjs +0 -209
  186. package/src/mcp/evidence/duplicate-member-order.mjs +0 -8
  187. package/src/mcp/evidence/package-graph-common.mjs +0 -115
  188. package/src/mcp/evidence/package-lock-graph.mjs +0 -92
  189. package/src/mcp/evidence-snapshot.architecture.mjs +0 -80
  190. package/src/mcp/evidence-snapshot.common.mjs +0 -158
  191. package/src/mcp/evidence-snapshot.duplicates.mjs +0 -213
  192. package/src/mcp/evidence-snapshot.health.mjs +0 -102
  193. package/src/mcp/evidence-snapshot.inventory.mjs +0 -148
  194. package/src/mcp/evidence-snapshot.mjs +0 -50
  195. package/src/mcp/evidence-snapshot.package-graph.mjs +0 -34
  196. package/src/mcp/evidence-snapshot.structure.mjs +0 -84
  197. package/src/mcp/extension-api.mjs +0 -77
  198. package/src/mcp/git-output.mjs +0 -7
  199. package/src/mcp/graph/context-core.mjs +0 -111
  200. package/src/mcp/graph/context-seeds.mjs +0 -207
  201. package/src/mcp/graph/context-state.mjs +0 -85
  202. package/src/mcp/graph/reverse-reach.mjs +0 -42
  203. package/src/mcp/graph/tools-core.mjs +0 -143
  204. package/src/mcp/graph/tools-query.mjs +0 -276
  205. package/src/mcp/graph-context.mjs +0 -5
  206. package/src/mcp/graph-diff.mjs +0 -218
  207. package/src/mcp/health/audit-format.mjs +0 -199
  208. package/src/mcp/health/audit.mjs +0 -199
  209. package/src/mcp/health/dead-code.mjs +0 -110
  210. package/src/mcp/health/duplicates.mjs +0 -121
  211. package/src/mcp/health/endpoints.mjs +0 -71
  212. package/src/mcp/health/structure.mjs +0 -220
  213. package/src/mcp/runtime-version.mjs +0 -31
  214. package/src/mcp/server/auto-refresh.mjs +0 -66
  215. package/src/mcp/server/runtime-config.mjs +0 -43
  216. package/src/mcp/server/shutdown.mjs +0 -40
  217. package/src/mcp/staleness-notice.mjs +0 -20
  218. package/src/mcp/sync/evidence-architecture.mjs +0 -54
  219. package/src/mcp/sync/evidence-common.mjs +0 -88
  220. package/src/mcp/sync/evidence-duplicates.mjs +0 -97
  221. package/src/mcp/sync/evidence-health.mjs +0 -56
  222. package/src/mcp/sync/evidence-packages.mjs +0 -95
  223. package/src/mcp/sync/payload-common.mjs +0 -97
  224. package/src/mcp/sync/payload-v2.mjs +0 -54
  225. package/src/mcp/sync/payload-v3.mjs +0 -79
  226. package/src/mcp/sync-evidence.mjs +0 -23
  227. package/src/mcp/sync-payload.mjs +0 -70
  228. package/src/mcp/tool-result.mjs +0 -54
  229. package/src/mcp/tools-actions.mjs +0 -11
  230. package/src/mcp/tools-architecture.mjs +0 -177
  231. package/src/mcp/tools-company.mjs +0 -251
  232. package/src/mcp/tools-context.mjs +0 -222
  233. package/src/mcp/tools-endpoints.mjs +0 -207
  234. package/src/mcp/tools-graph-hubs.mjs +0 -78
  235. package/src/mcp/tools-graph.mjs +0 -17
  236. package/src/mcp/tools-health.mjs +0 -24
  237. package/src/mcp/tools-history.mjs +0 -28
  238. package/src/mcp/tools-impact-change.mjs +0 -220
  239. package/src/mcp/tools-impact-precision.mjs +0 -89
  240. package/src/mcp/tools-impact.mjs +0 -169
  241. package/src/mcp/tools-source.mjs +0 -238
  242. package/src/mcp/tools-verified-change.mjs +0 -200
  243. package/src/mcp-rg.mjs +0 -50
  244. package/src/mcp-runtime.mjs +0 -2
  245. package/src/mcp-server.mjs +0 -298
  246. package/src/mcp-source-tools.mjs +0 -163
  247. package/src/path-classification.js +0 -226
  248. package/src/path-ignore.js +0 -69
  249. package/src/precision/lsp-client/constants.js +0 -12
  250. package/src/precision/lsp-client/environment.js +0 -20
  251. package/src/precision/lsp-client/errors.js +0 -15
  252. package/src/precision/lsp-client/lifecycle.js +0 -114
  253. package/src/precision/lsp-client/message-parser.js +0 -81
  254. package/src/precision/lsp-client/protocol.js +0 -212
  255. package/src/precision/lsp-client/registry.js +0 -59
  256. package/src/precision/lsp-client/repo-uri.js +0 -60
  257. package/src/precision/lsp-client/stdio-client.js +0 -140
  258. package/src/precision/lsp-client.js +0 -10
  259. package/src/precision/lsp-overlay/budget-policy.js +0 -78
  260. package/src/precision/lsp-overlay/build.js +0 -261
  261. package/src/precision/lsp-overlay/contract.js +0 -61
  262. package/src/precision/lsp-overlay/reference-results.js +0 -108
  263. package/src/precision/lsp-overlay/semantic-inputs.js +0 -62
  264. package/src/precision/lsp-overlay/source-session.js +0 -142
  265. package/src/precision/lsp-overlay/store.js +0 -150
  266. package/src/precision/lsp-overlay/target-index.js +0 -152
  267. package/src/precision/lsp-overlay/target-query.js +0 -55
  268. package/src/precision/lsp-overlay.js +0 -11
  269. package/src/precision/symbol-query.js +0 -224
  270. package/src/precision/typescript-lsp-provider.js +0 -12
  271. package/src/precision/typescript-provider/client.js +0 -89
  272. package/src/precision/typescript-provider/discovery.js +0 -124
  273. package/src/precision/typescript-provider/isolated-runtime.js +0 -39
  274. package/src/precision/typescript-provider/project-host.js +0 -254
  275. package/src/precision/typescript-provider/project-safety.js +0 -166
  276. package/src/precision/typescript-provider/reference-usage.js +0 -53
  277. package/src/process.js +0 -95
  278. package/src/repo-path.js +0 -53
  279. package/src/scan/discover.inventory.js +0 -78
  280. package/src/scan/discover.js +0 -5
  281. package/src/scan/discover.list.js +0 -79
  282. package/src/scan/discover.stack.js +0 -227
  283. package/src/scan/search.core.js +0 -24
  284. package/src/scan/search.git.js +0 -102
  285. package/src/scan/search.js +0 -9
  286. package/src/scan/search.node.js +0 -83
  287. package/src/scan/search.preview.js +0 -49
  288. package/src/scan/search.rg.js +0 -145
  289. package/src/security/advisory-store.js +0 -172
  290. package/src/security/installed-jvm-rust.js +0 -46
  291. package/src/security/installed.js +0 -280
  292. package/src/security/malware-file-heuristics.js +0 -121
  293. package/src/security/malware-heuristics.exclusions.js +0 -134
  294. package/src/security/malware-heuristics.js +0 -15
  295. package/src/security/malware-heuristics.roots.js +0 -145
  296. package/src/security/malware-heuristics.scan.js +0 -89
  297. package/src/security/malware-heuristics.sweep.js +0 -122
  298. package/src/security/malware-scoring.js +0 -105
  299. package/src/security/match.js +0 -85
  300. package/src/security/registry-sig.classify.js +0 -137
  301. package/src/security/registry-sig.js +0 -18
  302. package/src/security/registry-sig.rules.js +0 -192
  303. package/src/security/rust-advisory-report.js +0 -60
  304. package/src/security/typosquat.js +0 -81
  305. package/src/util.js +0 -40
  306. package/src/version.js +0 -7
@@ -1,81 +0,0 @@
1
- import {TextDecoder} from 'node:util'
2
- import {DEFAULT_MAX_HEADER_BYTES, DEFAULT_MAX_MESSAGE_BYTES, positiveInteger} from './constants.js'
3
- import {LspProtocolError} from './errors.js'
4
-
5
- const HEADER_DELIMITER = Buffer.from('\r\n\r\n', 'ascii')
6
- const UTF8_DECODER = new TextDecoder('utf-8', {fatal: true})
7
-
8
- function asBuffer(chunk) {
9
- if (Buffer.isBuffer(chunk)) return chunk
10
- if (chunk instanceof Uint8Array) return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)
11
- return Buffer.from(chunk)
12
- }
13
-
14
- function parseHeaders(bytes, maxMessageBytes) {
15
- const lines = bytes.toString('ascii').split('\r\n')
16
- let contentLength = null
17
- for (const line of lines) {
18
- const match = /^([!#$%&'*+\-.^_`|~0-9A-Za-z]+):[ \t]*(.*)$/.exec(line)
19
- if (!match) throw new LspProtocolError('Malformed LSP header line')
20
- if (match[1].toLowerCase() !== 'content-length') continue
21
- if (contentLength != null) throw new LspProtocolError('Duplicate Content-Length header')
22
- if (!/^(0|[1-9][0-9]*)$/.test(match[2])) throw new LspProtocolError('Invalid Content-Length header')
23
- contentLength = Number(match[2])
24
- if (!Number.isSafeInteger(contentLength) || contentLength <= 0) {
25
- throw new LspProtocolError('Content-Length must be positive')
26
- }
27
- if (contentLength > maxMessageBytes) {
28
- throw new LspProtocolError(`LSP message exceeds ${maxMessageBytes} byte limit`)
29
- }
30
- }
31
- if (contentLength == null) throw new LspProtocolError('Missing Content-Length header')
32
- return contentLength
33
- }
34
-
35
- /** Incremental parser for the Content-Length framed JSON-RPC transport used by LSP. */
36
- export class ContentLengthMessageParser {
37
- constructor({onMessage, maxMessageBytes = DEFAULT_MAX_MESSAGE_BYTES, maxHeaderBytes = DEFAULT_MAX_HEADER_BYTES} = {}) {
38
- if (typeof onMessage !== 'function') throw new TypeError('onMessage must be a function')
39
- this.onMessage = onMessage
40
- this.maxMessageBytes = positiveInteger(maxMessageBytes, DEFAULT_MAX_MESSAGE_BYTES, 'maxMessageBytes')
41
- this.maxHeaderBytes = positiveInteger(maxHeaderBytes, DEFAULT_MAX_HEADER_BYTES, 'maxHeaderBytes')
42
- this.buffer = Buffer.alloc(0)
43
- this.expectedBodyBytes = null
44
- }
45
-
46
- push(chunk) {
47
- const incoming = asBuffer(chunk)
48
- if (incoming.length === 0) return
49
- this.buffer = this.buffer.length === 0 ? incoming : Buffer.concat([this.buffer, incoming])
50
- while (this.buffer.length > 0) {
51
- if (this.expectedBodyBytes == null) {
52
- const delimiterIndex = this.buffer.indexOf(HEADER_DELIMITER)
53
- if (delimiterIndex < 0) {
54
- if (this.buffer.length > this.maxHeaderBytes) throw new LspProtocolError('LSP header exceeds byte limit')
55
- return
56
- }
57
- if (delimiterIndex === 0) throw new LspProtocolError('Empty LSP header block')
58
- if (delimiterIndex > this.maxHeaderBytes) throw new LspProtocolError('LSP header exceeds byte limit')
59
- this.expectedBodyBytes = parseHeaders(
60
- this.buffer.subarray(0, delimiterIndex),
61
- this.maxMessageBytes,
62
- )
63
- this.buffer = this.buffer.subarray(delimiterIndex + HEADER_DELIMITER.length)
64
- }
65
- if (this.buffer.length < this.expectedBodyBytes) return
66
- const body = this.buffer.subarray(0, this.expectedBodyBytes)
67
- this.buffer = this.buffer.subarray(this.expectedBodyBytes)
68
- this.expectedBodyBytes = null
69
- let value
70
- try {
71
- value = JSON.parse(UTF8_DECODER.decode(body))
72
- } catch (error) {
73
- throw new LspProtocolError('Invalid UTF-8 JSON in LSP message', {cause: error})
74
- }
75
- if (value == null || typeof value !== 'object' || Array.isArray(value)) {
76
- throw new LspProtocolError('LSP message must be a JSON object')
77
- }
78
- this.onMessage(value)
79
- }
80
- }
81
- }
@@ -1,212 +0,0 @@
1
- import {JSON_RPC_VERSION, positiveInteger} from './constants.js'
2
- import {LspProtocolError, LspTimeoutError} from './errors.js'
3
- import {WEAVATRIX_VERSION} from '../../version.js'
4
-
5
- export function assertPosition(position) {
6
- if (position == null || typeof position !== 'object') throw new TypeError('position is required')
7
- const line = Number(position.line)
8
- const character = Number(position.character)
9
- if (!Number.isSafeInteger(line) || line < 0 || !Number.isSafeInteger(character) || character < 0) {
10
- throw new TypeError('position line and character must be non-negative integers')
11
- }
12
- return {line, character}
13
- }
14
-
15
- function normalizeRange(range) {
16
- if (range == null || typeof range !== 'object') throw new LspProtocolError('LSP location is missing a range')
17
- return {start: assertPosition(range.start), end: assertPosition(range.end)}
18
- }
19
-
20
- function jsonRpcError(error) {
21
- const wrapped = new Error(error?.message || 'LSP request failed')
22
- wrapped.name = 'LspResponseError'
23
- wrapped.code = error?.code
24
- wrapped.data = error?.data
25
- return wrapped
26
- }
27
-
28
- export function assertClientWritable(client) {
29
- if (!['running', 'initialized', 'stopping'].includes(client.state) || client.child.stdin?.destroyed) {
30
- throw new Error(`LSP client is not writable (state=${client.state})`)
31
- }
32
- }
33
-
34
- export function writeClientMessage(client, message) {
35
- assertClientWritable(client)
36
- const body = Buffer.from(JSON.stringify(message), 'utf8')
37
- if (body.length > client.maxMessageBytes) {
38
- throw new LspProtocolError(`Outgoing LSP message exceeds ${client.maxMessageBytes} byte limit`)
39
- }
40
- const header = Buffer.from(`Content-Length: ${body.length}\r\n\r\n`, 'ascii')
41
- return new Promise((resolveWrite, rejectWrite) => {
42
- client.child.stdin.write(
43
- Buffer.concat([header, body]),
44
- (error) => error ? rejectWrite(error) : resolveWrite(),
45
- )
46
- })
47
- }
48
-
49
- export async function requestFromClient(client, method, params = null, {timeoutMs = client.requestTimeoutMs} = {}) {
50
- if (typeof method !== 'string' || method === '') throw new TypeError('LSP method is required')
51
- const boundedTimeout = positiveInteger(timeoutMs, client.requestTimeoutMs, 'timeoutMs')
52
- const id = client.nextId++
53
- let entry
54
- const response = new Promise((resolveResponse, rejectResponse) => {
55
- const timer = setTimeout(() => {
56
- if (client.pending.get(id) !== entry) return
57
- client.pending.delete(id)
58
- void writeClientMessage(client, {
59
- jsonrpc: JSON_RPC_VERSION,
60
- method: '$/cancelRequest',
61
- params: {id},
62
- }).catch(() => {})
63
- rejectResponse(new LspTimeoutError(method, boundedTimeout))
64
- }, boundedTimeout)
65
- entry = {method, timer, resolve: resolveResponse, reject: rejectResponse}
66
- client.pending.set(id, entry)
67
- })
68
- try {
69
- await writeClientMessage(client, {jsonrpc: JSON_RPC_VERSION, id, method, params})
70
- } catch (error) {
71
- if (client.pending.get(id) === entry) {
72
- clearTimeout(entry.timer)
73
- client.pending.delete(id)
74
- entry.reject(error)
75
- }
76
- }
77
- return response
78
- }
79
-
80
- export async function notifyClient(client, method, params = null) {
81
- if (typeof method !== 'string' || method === '') throw new TypeError('LSP method is required')
82
- await writeClientMessage(client, {jsonrpc: JSON_RPC_VERSION, method, params})
83
- }
84
-
85
- export async function initializeClient(client, {
86
- capabilities = {},
87
- initializationOptions,
88
- clientInfo = {name: 'weavatrix', version: WEAVATRIX_VERSION},
89
- } = {}) {
90
- if (client.state !== 'running') throw new Error(`LSP initialize is invalid in state=${client.state}`)
91
- const workspaceName = client.normalizer.rootPath.split(/[\\/]/).pop() || 'repository'
92
- const result = await requestFromClient(client, 'initialize', {
93
- processId: process.pid,
94
- clientInfo,
95
- rootUri: client.normalizer.rootUri,
96
- capabilities,
97
- initializationOptions,
98
- workspaceFolders: [{uri: client.normalizer.rootUri, name: workspaceName}],
99
- })
100
- await notifyClient(client, 'initialized', {})
101
- client.state = 'initialized'
102
- return result
103
- }
104
-
105
- export async function openClientDocument(client, {filePath, text, languageId, version = 1}) {
106
- if (client.state !== 'initialized') throw new Error('LSP client is not initialized')
107
- if (typeof text !== 'string') throw new TypeError('document text must be a string')
108
- if (typeof languageId !== 'string' || languageId === '') throw new TypeError('languageId is required')
109
- if (!Number.isSafeInteger(version) || version < 0) {
110
- throw new TypeError('document version must be a non-negative integer')
111
- }
112
- const normalized = client.normalizer.toUri(filePath)
113
- await notifyClient(client, 'textDocument/didOpen', {
114
- textDocument: {uri: normalized.uri, languageId, version, text},
115
- })
116
- client.openDocuments.set(normalized.uri, {file: normalized.file, version, languageId})
117
- return {file: normalized.file, version, languageId}
118
- }
119
-
120
- export async function closeClientDocument(client, filePath) {
121
- const normalized = client.normalizer.toUri(filePath)
122
- if (!client.openDocuments.has(normalized.uri)) return false
123
- await notifyClient(client, 'textDocument/didClose', {textDocument: {uri: normalized.uri}})
124
- client.openDocuments.delete(normalized.uri)
125
- return true
126
- }
127
-
128
- export function normalizeClientLocations(client, result) {
129
- const locations = []
130
- for (const raw of result == null ? [] : Array.isArray(result) ? result : [result]) {
131
- if (raw == null || typeof raw !== 'object') continue
132
- const uri = raw.uri || raw.targetUri
133
- const range = raw.range || raw.targetSelectionRange || raw.targetRange
134
- try {
135
- const normalized = client.normalizer.fromUri(uri)
136
- locations.push({file: normalized.file, range: normalizeRange(range)})
137
- } catch (error) {
138
- if (error instanceof RangeError) continue
139
- throw error
140
- }
141
- }
142
- return locations
143
- }
144
-
145
- export async function queryClientLocations(client, kind, {filePath, position, includeDeclaration = true, timeoutMs}) {
146
- const normalized = client.normalizer.toUri(filePath)
147
- const method = kind === 'references' ? 'textDocument/references' : 'textDocument/definition'
148
- const params = {textDocument: {uri: normalized.uri}, position: assertPosition(position)}
149
- if (kind === 'references') params.context = {includeDeclaration: Boolean(includeDeclaration)}
150
- const result = await requestFromClient(client, method, params, {
151
- timeoutMs: timeoutMs ?? client.requestTimeoutMs,
152
- })
153
- return normalizeClientLocations(client, result)
154
- }
155
-
156
- export async function defaultClientServerRequest(client, method, params) {
157
- if (method === 'workspace/configuration') return Array.isArray(params?.items) ? params.items.map(() => null) : []
158
- if (method === 'workspace/workspaceFolders') {
159
- return [{uri: client.normalizer.rootUri, name: client.normalizer.rootPath.split(/[\\/]/).pop() || 'repository'}]
160
- }
161
- if (['client/registerCapability', 'client/unregisterCapability', 'window/workDoneProgress/create'].includes(method)) return null
162
- if (method === 'workspace/applyEdit') {
163
- return {applied: false, failureReason: 'Weavatrix precision provider is read-only'}
164
- }
165
- const error = new Error(`Unsupported LSP server request: ${method}`)
166
- error.code = -32601
167
- throw error
168
- }
169
-
170
- export async function handleClientServerRequest(client, message) {
171
- try {
172
- const result = client.onServerRequest
173
- ? await client.onServerRequest(message.method, message.params, client)
174
- : await defaultClientServerRequest(client, message.method, message.params)
175
- await writeClientMessage(client, {jsonrpc: JSON_RPC_VERSION, id: message.id, result: result ?? null})
176
- } catch (error) {
177
- try {
178
- await writeClientMessage(client, {
179
- jsonrpc: JSON_RPC_VERSION,
180
- id: message.id,
181
- error: {
182
- code: Number.isInteger(error?.code) ? error.code : -32603,
183
- message: error?.message || 'LSP client error',
184
- },
185
- })
186
- } catch { /* process exited while request handler was running */ }
187
- }
188
- }
189
-
190
- export function handleClientMessage(client, message) {
191
- if (message.jsonrpc !== JSON_RPC_VERSION) throw new LspProtocolError('Unsupported JSON-RPC version from LSP server')
192
- if (typeof message.method === 'string') {
193
- if (message.id != null) void handleClientServerRequest(client, message)
194
- else client.onNotification?.(message.method, message.params, client)
195
- return
196
- }
197
- if (message.id == null) throw new LspProtocolError('LSP response is missing an id')
198
- const entry = client.pending.get(message.id)
199
- if (!entry) return
200
- client.pending.delete(message.id)
201
- clearTimeout(entry.timer)
202
- if (message.error != null) entry.reject(jsonRpcError(message.error))
203
- else entry.resolve(message.result)
204
- }
205
-
206
- export function rejectPendingRequests(client, error) {
207
- for (const entry of client.pending.values()) {
208
- clearTimeout(entry.timer)
209
- entry.reject(error)
210
- }
211
- client.pending.clear()
212
- }
@@ -1,59 +0,0 @@
1
- const ACTIVE_LSP_CLIENTS = new Set()
2
- let acceptingLspClients = true
3
-
4
- export function assertLspClientCreationAllowed() {
5
- if (!acceptingLspClients) throw new Error('LSP process creation is disabled during MCP shutdown')
6
- }
7
-
8
- export function registerLspClient(client) {
9
- ACTIVE_LSP_CLIENTS.add(client)
10
- }
11
-
12
- export function unregisterLspClient(client) {
13
- ACTIVE_LSP_CLIENTS.delete(client)
14
- }
15
-
16
- export function isLspClientActive(client) {
17
- return ACTIVE_LSP_CLIENTS.has(client)
18
- }
19
-
20
- export function activeLspClientCount() {
21
- return ACTIVE_LSP_CLIENTS.size
22
- }
23
-
24
- export function beginLspClientShutdown() {
25
- acceptingLspClients = false
26
- }
27
-
28
- export async function shutdownActiveLspClients({timeoutMs = 3_000} = {}) {
29
- const boundedTimeout = Math.max(250, Math.min(10_000, Number(timeoutMs) || 3_000))
30
- const startedAt = Date.now()
31
- const clients = [...ACTIVE_LSP_CLIENTS]
32
- if (!clients.length) return {requested: 0, remaining: 0, timedOut: false}
33
- let timer
34
- const gracefulBudget = Math.max(125, Math.floor(boundedTimeout * 0.6))
35
- const graceful = Promise.allSettled(clients.map((client) => client.shutdown({timeoutMs: boundedTimeout})))
36
- const outcome = await Promise.race([
37
- graceful.then(() => 'closed'),
38
- new Promise((resolveOutcome) => { timer = setTimeout(() => resolveOutcome('timeout'), gracefulBudget) }),
39
- ])
40
- if (timer) clearTimeout(timer)
41
- const survivors = [...ACTIVE_LSP_CLIENTS]
42
- if (survivors.length) {
43
- const reason = new Error(`MCP shutdown timed out with ${ACTIVE_LSP_CLIENTS.size} active LSP client(s)`)
44
- const forceBudget = Math.max(100, boundedTimeout - (Date.now() - startedAt))
45
- await Promise.allSettled(survivors.map(async (client) => {
46
- if (typeof client.killWindowsTreeAndWait === 'function') await client.killWindowsTreeAndWait(forceBudget)
47
- client.kill(reason)
48
- }))
49
- const reapBudget = Math.max(250, Math.min(1_000, Math.floor(boundedTimeout * 0.4)))
50
- await Promise.allSettled(survivors.map((client) => (
51
- typeof client.waitForExit === 'function' ? client.waitForExit(reapBudget) : undefined
52
- )))
53
- }
54
- return {
55
- requested: clients.length,
56
- remaining: ACTIVE_LSP_CLIENTS.size,
57
- timedOut: outcome === 'timeout' || ACTIVE_LSP_CLIENTS.size > 0,
58
- }
59
- }
@@ -1,60 +0,0 @@
1
- import {realpathSync} from 'node:fs'
2
- import {isAbsolute, relative, resolve, sep} from 'node:path'
3
- import {fileURLToPath, pathToFileURL} from 'node:url'
4
-
5
- function normalizeFilesystemPath(path) {
6
- let normalized = path
7
- if (process.platform === 'win32' && normalized.startsWith('\\\\?\\UNC\\')) normalized = `\\\\${normalized.slice(8)}`
8
- else if (process.platform === 'win32' && normalized.startsWith('\\\\?\\')) normalized = normalized.slice(4)
9
- return resolve(normalized)
10
- }
11
-
12
- function realpathIfPossible(path) {
13
- try { return normalizeFilesystemPath(realpathSync.native(path)) }
14
- catch { return normalizeFilesystemPath(path) }
15
- }
16
-
17
- function existingRealpath(path) {
18
- try { return normalizeFilesystemPath(realpathSync.native(path)) }
19
- catch { return null }
20
- }
21
-
22
- function pathInside(rootPath, candidatePath) {
23
- const rel = relative(rootPath, candidatePath)
24
- return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
25
- }
26
-
27
- function portableRelative(rootPath, candidatePath) {
28
- return relative(rootPath, candidatePath).split(sep).join('/')
29
- }
30
-
31
- /** Repository-bounded path/URI conversion surface used by the client. */
32
- export function createRepoUriNormalizer(repoRoot) {
33
- if (typeof repoRoot !== 'string' || repoRoot.trim() === '') throw new TypeError('repoRoot is required')
34
- const lexicalRoot = normalizeFilesystemPath(resolve(repoRoot))
35
- const absoluteRoot = realpathIfPossible(lexicalRoot)
36
- const toAbsolute = (filePath) => {
37
- if (typeof filePath !== 'string' || filePath.trim() === '') throw new TypeError('filePath is required')
38
- const lexicalPath = normalizeFilesystemPath(resolve(lexicalRoot, filePath))
39
- const canonicalPath = existingRealpath(lexicalPath)
40
- if (canonicalPath == null) {
41
- if (!pathInside(lexicalRoot, lexicalPath)) throw new RangeError('LSP path is outside the repository')
42
- return lexicalPath
43
- }
44
- if (!pathInside(absoluteRoot, canonicalPath)) throw new RangeError('LSP path resolves outside the repository')
45
- return canonicalPath
46
- }
47
- const fromUri = (uri) => {
48
- if (typeof uri !== 'string' || !uri.startsWith('file:')) throw new RangeError('Only file: LSP URIs are accepted')
49
- let filePath
50
- try { filePath = fileURLToPath(uri) }
51
- catch (error) { throw new RangeError('Invalid file: LSP URI', {cause: error}) }
52
- const absolutePath = toAbsolute(filePath)
53
- return {file: portableRelative(absoluteRoot, absolutePath), absolutePath, uri: pathToFileURL(absolutePath).href}
54
- }
55
- const toUri = (filePath) => {
56
- const absolutePath = toAbsolute(filePath)
57
- return {file: portableRelative(absoluteRoot, absolutePath), absolutePath, uri: pathToFileURL(absolutePath).href}
58
- }
59
- return {rootPath: absoluteRoot, rootUri: pathToFileURL(absoluteRoot).href, toAbsolute, toUri, fromUri}
60
- }
@@ -1,140 +0,0 @@
1
- import {spawn as spawnChild} from 'node:child_process'
2
- import {isAbsolute} from 'node:path'
3
- import {
4
- DEFAULT_MAX_HEADER_BYTES,
5
- DEFAULT_MAX_MESSAGE_BYTES,
6
- DEFAULT_REQUEST_TIMEOUT_MS,
7
- positiveInteger,
8
- } from './constants.js'
9
- import {lspChildProcessEnv} from './environment.js'
10
- import {ContentLengthMessageParser} from './message-parser.js'
11
- import {createRepoUriNormalizer} from './repo-uri.js'
12
- import {
13
- assertLspClientCreationAllowed,
14
- registerLspClient,
15
- unregisterLspClient,
16
- } from './registry.js'
17
- import {
18
- closeClientDocument,
19
- handleClientMessage,
20
- initializeClient,
21
- openClientDocument,
22
- queryClientLocations,
23
- rejectPendingRequests,
24
- requestFromClient,
25
- writeClientMessage,
26
- } from './protocol.js'
27
- import {
28
- failClient,
29
- killClient,
30
- killWindowsTreeAndWait,
31
- shutdownClient,
32
- waitForClientExit,
33
- } from './lifecycle.js'
34
-
35
- export class StdioLspClient {
36
- constructor({
37
- repoRoot,
38
- executablePath = process.execPath,
39
- args = [],
40
- env = {},
41
- requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT_MS,
42
- maxMessageBytes = DEFAULT_MAX_MESSAGE_BYTES,
43
- maxHeaderBytes = DEFAULT_MAX_HEADER_BYTES,
44
- onNotification,
45
- onServerRequest,
46
- spawn = spawnChild,
47
- } = {}) {
48
- if (typeof executablePath !== 'string' || !isAbsolute(executablePath)) {
49
- throw new TypeError('LSP executablePath must be absolute')
50
- }
51
- if (!Array.isArray(args) || args.some((arg) => typeof arg !== 'string')) {
52
- throw new TypeError('LSP args must be strings')
53
- }
54
- if (typeof spawn !== 'function') throw new TypeError('spawn must be a function')
55
- assertLspClientCreationAllowed()
56
- this.normalizer = createRepoUriNormalizer(repoRoot)
57
- this.requestTimeoutMs = positiveInteger(requestTimeoutMs, DEFAULT_REQUEST_TIMEOUT_MS, 'requestTimeoutMs')
58
- this.maxMessageBytes = positiveInteger(maxMessageBytes, DEFAULT_MAX_MESSAGE_BYTES, 'maxMessageBytes')
59
- this.onNotification = typeof onNotification === 'function' ? onNotification : null
60
- this.onServerRequest = typeof onServerRequest === 'function' ? onServerRequest : null
61
- this.pending = new Map()
62
- this.openDocuments = new Map()
63
- this.nextId = 1
64
- this.state = 'starting'
65
- this.stderrTail = ''
66
- this.shutdownPromise = null
67
- this.windowsTreeKillPromise = null
68
- this.child = spawn(executablePath, args, {
69
- cwd: this.normalizer.rootPath,
70
- env: lspChildProcessEnv(env),
71
- shell: false,
72
- detached: process.platform !== 'win32',
73
- windowsHide: true,
74
- stdio: ['pipe', 'pipe', 'pipe'],
75
- })
76
- this.processGroupPid = process.platform !== 'win32' && Number.isInteger(this.child.pid)
77
- ? this.child.pid : null
78
- registerLspClient(this)
79
- this.parser = new ContentLengthMessageParser({
80
- maxMessageBytes: this.maxMessageBytes,
81
- maxHeaderBytes,
82
- onMessage: (message) => this.handleMessage(message),
83
- })
84
- this.child.stdout?.on('data', (chunk) => {
85
- try { this.parser.push(chunk) }
86
- catch (error) { this.fail(error) }
87
- })
88
- this.child.stderr?.setEncoding('utf8')
89
- this.child.stderr?.on('data', (chunk) => {
90
- this.stderrTail = `${this.stderrTail}${chunk}`.slice(-16_000)
91
- })
92
- this.spawned = new Promise((resolveSpawn, rejectSpawn) => {
93
- this.child.once('spawn', () => {
94
- if (this.state === 'starting') this.state = 'running'
95
- resolveSpawn(this)
96
- })
97
- this.child.once('error', (error) => {
98
- this.fail(error)
99
- rejectSpawn(error)
100
- })
101
- })
102
- this.exited = new Promise((resolveExit) => {
103
- let settled = false
104
- const finishExit = (code, signal) => {
105
- if (settled) return
106
- settled = true
107
- const wasStopping = this.state === 'stopping' || this.state === 'closed'
108
- this.state = 'closed'
109
- const suffix = this.stderrTail ? `\n${this.stderrTail}` : ''
110
- this.rejectPending(new Error(`LSP server exited (code=${code}, signal=${signal})${suffix}`))
111
- if (!wasStopping && code !== 0) this.openDocuments.clear()
112
- unregisterLspClient(this)
113
- resolveExit({code, signal})
114
- }
115
- this.child.once('exit', finishExit)
116
- this.child.once('close', finishExit)
117
- })
118
- }
119
-
120
- async start() { await this.spawned; return this }
121
- writeMessage(message) { return writeClientMessage(this, message) }
122
- request(method, params, options) { return requestFromClient(this, method, params, options) }
123
- initialize(options) { return initializeClient(this, options) }
124
- openDocument(options) { return openClientDocument(this, options) }
125
- closeDocument(filePath) { return closeClientDocument(this, filePath) }
126
- definition(options) { return queryClientLocations(this, 'definition', options) }
127
- references(options) { return queryClientLocations(this, 'references', options) }
128
- handleMessage(message) { return handleClientMessage(this, message) }
129
- rejectPending(error) { return rejectPendingRequests(this, error) }
130
- fail(error) { return failClient(this, error) }
131
- kill(reason) { return killClient(this, reason) }
132
- killWindowsTreeAndWait(timeoutMs) { return killWindowsTreeAndWait(this, timeoutMs) }
133
- waitForExit(timeoutMs) { return waitForClientExit(this, timeoutMs) }
134
- shutdown(options) { return shutdownClient(this, options) }
135
- }
136
-
137
- export async function startStdioLspClient(options) {
138
- const client = new StdioLspClient(options)
139
- return client.start()
140
- }
@@ -1,10 +0,0 @@
1
- export {
2
- activeLspClientCount,
3
- beginLspClientShutdown,
4
- shutdownActiveLspClients,
5
- } from './lsp-client/registry.js'
6
- export {lspChildProcessEnv} from './lsp-client/environment.js'
7
- export {LspProtocolError, LspTimeoutError} from './lsp-client/errors.js'
8
- export {ContentLengthMessageParser} from './lsp-client/message-parser.js'
9
- export {createRepoUriNormalizer} from './lsp-client/repo-uri.js'
10
- export {StdioLspClient, startStdioLspClient} from './lsp-client/stdio-client.js'
@@ -1,78 +0,0 @@
1
- import {boundedInteger} from '../../bounds.js'
2
-
3
- const DEFAULT_MAX_SYMBOLS = 32
4
- const BOUNDED_MAX_SYMBOLS = 64
5
- const EXPANDED_MAX_SYMBOLS = 10_000
6
- const DEFAULT_MAX_REFERENCES = 2_048
7
- const BOUNDED_MAX_REFERENCES = 16_384
8
- const EXPANDED_MAX_REFERENCES = 131_072
9
- const DEFAULT_MAX_LINKS = 2_048
10
- const BOUNDED_MAX_LINKS = 16_384
11
- const EXPANDED_MAX_LINKS = 131_072
12
- const DEFAULT_TIMEOUT_MS = 45_000
13
- const BOUNDED_MAX_TIMEOUT_MS = 60_000
14
- const EXPANDED_MAX_TIMEOUT_MS = 30 * 60_000
15
-
16
- function configured(value, environmentName) {
17
- if (value !== undefined && value !== null && String(value).trim() !== '') return value
18
- const environmentValue = process.env[environmentName]
19
- return environmentValue != null && String(environmentValue).trim() !== ''
20
- ? environmentValue : undefined
21
- }
22
-
23
- export function precisionPrewarmBudget(options = {}) {
24
- const targetBatch = Array.isArray(options.targetIds) && options.targetIds.length > 0
25
- const configuredMode = String(configured(
26
- options.prewarmMode,
27
- 'WEAVATRIX_PRECISION_PREWARM',
28
- ) || 'bounded').trim().toLowerCase()
29
- const full = configuredMode === 'full' && !targetBatch
30
- const requestedSymbols = configured(options.maxSymbols, 'WEAVATRIX_PRECISION_MAX_SYMBOLS')
31
- const numericSymbols = Number(requestedSymbols)
32
- const expanded = full || (Number.isFinite(numericSymbols) && numericSymbols > BOUNDED_MAX_SYMBOLS)
33
- const maxSymbols = full ? EXPANDED_MAX_SYMBOLS : boundedInteger(
34
- requestedSymbols,
35
- DEFAULT_MAX_SYMBOLS,
36
- 1,
37
- expanded ? EXPANDED_MAX_SYMBOLS : BOUNDED_MAX_SYMBOLS,
38
- )
39
- const referenceFallback = expanded
40
- ? Math.min(EXPANDED_MAX_REFERENCES, Math.max(DEFAULT_MAX_REFERENCES, maxSymbols * 16))
41
- : DEFAULT_MAX_REFERENCES
42
- const linkFallback = expanded
43
- ? Math.min(EXPANDED_MAX_LINKS, Math.max(DEFAULT_MAX_LINKS, maxSymbols * 16))
44
- : DEFAULT_MAX_LINKS
45
- const timeoutFallback = expanded
46
- ? Math.min(15 * 60_000, Math.max(DEFAULT_TIMEOUT_MS, maxSymbols * 1_000))
47
- : DEFAULT_TIMEOUT_MS
48
- const maxReferences = boundedInteger(
49
- configured(options.maxReferences, 'WEAVATRIX_PRECISION_MAX_REFERENCES'),
50
- referenceFallback,
51
- 1,
52
- expanded ? EXPANDED_MAX_REFERENCES : BOUNDED_MAX_REFERENCES,
53
- )
54
- const maxLinks = boundedInteger(
55
- configured(options.maxLinks, 'WEAVATRIX_PRECISION_MAX_LINKS'),
56
- linkFallback,
57
- 1,
58
- expanded ? EXPANDED_MAX_LINKS : BOUNDED_MAX_LINKS,
59
- )
60
- const timeoutMs = boundedInteger(
61
- configured(options.timeoutMs, 'WEAVATRIX_PRECISION_TIMEOUT_MS'),
62
- timeoutFallback,
63
- 100,
64
- expanded ? EXPANDED_MAX_TIMEOUT_MS : BOUNDED_MAX_TIMEOUT_MS,
65
- )
66
- return {
67
- expanded,
68
- full,
69
- maxSymbols,
70
- maxReferences,
71
- maxLinks,
72
- timeoutMs,
73
- maxOpenDocuments: expanded ? 1_024 : 96,
74
- maxOpenBytes: expanded ? 128 * 1024 * 1024 : 32 * 1024 * 1024,
75
- maxClassificationDocuments: expanded ? 1_024 : 96,
76
- maxClassificationBytes: expanded ? 128 * 1024 * 1024 : 32 * 1024 * 1024,
77
- }
78
- }