@seanhogg/builderforce-webcontainers 2026.10.12 → 2026.10.14

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 (372) hide show
  1. package/README.md +22 -0
  2. package/dist/adaptive/controller.d.ts +39 -0
  3. package/dist/adaptive/controller.d.ts.map +1 -0
  4. package/dist/adaptive/controller.js +108 -0
  5. package/dist/adaptive/controller.js.map +1 -0
  6. package/dist/adaptive/costModel.d.ts +37 -0
  7. package/dist/adaptive/costModel.d.ts.map +1 -0
  8. package/dist/adaptive/costModel.js +102 -0
  9. package/dist/adaptive/costModel.js.map +1 -0
  10. package/dist/adaptive/planner.d.ts +22 -0
  11. package/dist/adaptive/planner.d.ts.map +1 -0
  12. package/dist/adaptive/planner.js +114 -0
  13. package/dist/adaptive/planner.js.map +1 -0
  14. package/dist/adaptive/types.d.ts +138 -0
  15. package/dist/adaptive/types.d.ts.map +1 -0
  16. package/dist/adaptive/types.js +12 -0
  17. package/dist/adaptive/types.js.map +1 -0
  18. package/dist/assets.js +2 -2
  19. package/dist/check/cachedFetch.js.map +1 -1
  20. package/dist/check/index.d.ts +6 -1
  21. package/dist/check/index.d.ts.map +1 -1
  22. package/dist/check/index.js +6 -1
  23. package/dist/check/index.js.map +1 -1
  24. package/dist/componentCompilers.d.ts.map +1 -1
  25. package/dist/componentCompilers.js.map +1 -1
  26. package/dist/esbuildWasm.js.map +1 -1
  27. package/dist/host.d.ts +11 -5
  28. package/dist/host.d.ts.map +1 -1
  29. package/dist/host.js +19 -8
  30. package/dist/host.js.map +1 -1
  31. package/dist/inference/backends/mock.d.ts +24 -0
  32. package/dist/inference/backends/mock.d.ts.map +1 -0
  33. package/dist/inference/backends/mock.js +55 -0
  34. package/dist/inference/backends/mock.js.map +1 -0
  35. package/dist/inference/backends/onnx.d.ts +33 -0
  36. package/dist/inference/backends/onnx.d.ts.map +1 -0
  37. package/dist/inference/backends/onnx.js +60 -0
  38. package/dist/inference/backends/onnx.js.map +1 -0
  39. package/dist/inference/backends/webllm.d.ts +27 -0
  40. package/dist/inference/backends/webllm.d.ts.map +1 -0
  41. package/dist/inference/backends/webllm.js +52 -0
  42. package/dist/inference/backends/webllm.js.map +1 -0
  43. package/dist/inference/backends/wllama.d.ts +29 -0
  44. package/dist/inference/backends/wllama.d.ts.map +1 -0
  45. package/dist/inference/backends/wllama.js +51 -0
  46. package/dist/inference/backends/wllama.js.map +1 -0
  47. package/dist/inference/capabilities.d.ts +20 -0
  48. package/dist/inference/capabilities.d.ts.map +1 -0
  49. package/dist/inference/capabilities.js +33 -0
  50. package/dist/inference/capabilities.js.map +1 -0
  51. package/dist/inference/client.d.ts +45 -0
  52. package/dist/inference/client.d.ts.map +1 -0
  53. package/dist/inference/client.js +201 -0
  54. package/dist/inference/client.js.map +1 -0
  55. package/dist/inference/modelCache.d.ts +71 -0
  56. package/dist/inference/modelCache.d.ts.map +1 -0
  57. package/dist/inference/modelCache.js +91 -0
  58. package/dist/inference/modelCache.js.map +1 -0
  59. package/dist/inference/protocol.d.ts +94 -0
  60. package/dist/inference/protocol.d.ts.map +1 -0
  61. package/dist/inference/protocol.js +19 -0
  62. package/dist/inference/protocol.js.map +1 -0
  63. package/dist/inference/tokenStream.d.ts +26 -0
  64. package/dist/inference/tokenStream.d.ts.map +1 -0
  65. package/dist/inference/tokenStream.js +79 -0
  66. package/dist/inference/tokenStream.js.map +1 -0
  67. package/dist/inference/types.d.ts +108 -0
  68. package/dist/inference/types.d.ts.map +1 -0
  69. package/dist/inference/types.js +8 -0
  70. package/dist/inference/types.js.map +1 -0
  71. package/dist/inference/worker.bundle.js +5 -0
  72. package/dist/inference/worker.d.ts +35 -0
  73. package/dist/inference/worker.d.ts.map +1 -0
  74. package/dist/inference/worker.js +157 -0
  75. package/dist/inference/worker.js.map +1 -0
  76. package/dist/inference/workerEntry.d.ts +15 -0
  77. package/dist/inference/workerEntry.d.ts.map +1 -0
  78. package/dist/inference/workerEntry.js +17 -0
  79. package/dist/inference/workerEntry.js.map +1 -0
  80. package/dist/kvcache/advanced.d.ts +39 -0
  81. package/dist/kvcache/advanced.d.ts.map +1 -0
  82. package/dist/kvcache/advanced.js +59 -0
  83. package/dist/kvcache/advanced.js.map +1 -0
  84. package/dist/kvcache/compatibility.d.ts +14 -0
  85. package/dist/kvcache/compatibility.d.ts.map +1 -0
  86. package/dist/kvcache/compatibility.js +44 -0
  87. package/dist/kvcache/compatibility.js.map +1 -0
  88. package/dist/kvcache/lru.d.ts +45 -0
  89. package/dist/kvcache/lru.d.ts.map +1 -0
  90. package/dist/kvcache/lru.js +91 -0
  91. package/dist/kvcache/lru.js.map +1 -0
  92. package/dist/kvcache/paged.d.ts +86 -0
  93. package/dist/kvcache/paged.d.ts.map +1 -0
  94. package/dist/kvcache/paged.js +238 -0
  95. package/dist/kvcache/paged.js.map +1 -0
  96. package/dist/kvcache/quant.d.ts +30 -0
  97. package/dist/kvcache/quant.d.ts.map +1 -0
  98. package/dist/kvcache/quant.js +73 -0
  99. package/dist/kvcache/quant.js.map +1 -0
  100. package/dist/kvcache/radix.d.ts +28 -0
  101. package/dist/kvcache/radix.d.ts.map +1 -0
  102. package/dist/kvcache/radix.js +58 -0
  103. package/dist/kvcache/radix.js.map +1 -0
  104. package/dist/kvcache/runtime.d.ts +11 -0
  105. package/dist/kvcache/runtime.d.ts.map +1 -0
  106. package/dist/kvcache/runtime.js +204 -0
  107. package/dist/kvcache/runtime.js.map +1 -0
  108. package/dist/kvcache/types.d.ts +151 -0
  109. package/dist/kvcache/types.d.ts.map +1 -0
  110. package/dist/kvcache/types.js +10 -0
  111. package/dist/kvcache/types.js.map +1 -0
  112. package/dist/learning/fingerprint.d.ts +17 -0
  113. package/dist/learning/fingerprint.d.ts.map +1 -0
  114. package/dist/learning/fingerprint.js +46 -0
  115. package/dist/learning/fingerprint.js.map +1 -0
  116. package/dist/learning/index.d.ts +5 -0
  117. package/dist/learning/index.d.ts.map +1 -0
  118. package/dist/learning/index.js +3 -0
  119. package/dist/learning/index.js.map +1 -0
  120. package/dist/learning/learner.d.ts +21 -0
  121. package/dist/learning/learner.d.ts.map +1 -0
  122. package/dist/learning/learner.js +272 -0
  123. package/dist/learning/learner.js.map +1 -0
  124. package/dist/learning/ledger.d.ts +26 -0
  125. package/dist/learning/ledger.d.ts.map +1 -0
  126. package/dist/learning/ledger.js +40 -0
  127. package/dist/learning/ledger.js.map +1 -0
  128. package/dist/learning/selection.d.ts +44 -0
  129. package/dist/learning/selection.d.ts.map +1 -0
  130. package/dist/learning/selection.js +111 -0
  131. package/dist/learning/selection.js.map +1 -0
  132. package/dist/learning/stats.d.ts +19 -0
  133. package/dist/learning/stats.d.ts.map +1 -0
  134. package/dist/learning/stats.js +31 -0
  135. package/dist/learning/stats.js.map +1 -0
  136. package/dist/learning/types.d.ts +133 -0
  137. package/dist/learning/types.d.ts.map +1 -0
  138. package/dist/learning/types.js +8 -0
  139. package/dist/learning/types.js.map +1 -0
  140. package/dist/memory/envProbe.d.ts +16 -0
  141. package/dist/memory/envProbe.d.ts.map +1 -0
  142. package/dist/memory/envProbe.js +28 -0
  143. package/dist/memory/envProbe.js.map +1 -0
  144. package/dist/memory/estimates.d.ts +46 -0
  145. package/dist/memory/estimates.d.ts.map +1 -0
  146. package/dist/memory/estimates.js +72 -0
  147. package/dist/memory/estimates.js.map +1 -0
  148. package/dist/memory/eviction.d.ts +42 -0
  149. package/dist/memory/eviction.d.ts.map +1 -0
  150. package/dist/memory/eviction.js +143 -0
  151. package/dist/memory/eviction.js.map +1 -0
  152. package/dist/memory/manager.d.ts +34 -0
  153. package/dist/memory/manager.d.ts.map +1 -0
  154. package/dist/memory/manager.js +346 -0
  155. package/dist/memory/manager.js.map +1 -0
  156. package/dist/memory/managerTypes.d.ts +49 -0
  157. package/dist/memory/managerTypes.d.ts.map +1 -0
  158. package/dist/memory/managerTypes.js +7 -0
  159. package/dist/memory/managerTypes.js.map +1 -0
  160. package/dist/memory/pressure.d.ts +56 -0
  161. package/dist/memory/pressure.d.ts.map +1 -0
  162. package/dist/memory/pressure.js +80 -0
  163. package/dist/memory/pressure.js.map +1 -0
  164. package/dist/memory/spillTier.d.ts +47 -0
  165. package/dist/memory/spillTier.d.ts.map +1 -0
  166. package/dist/memory/spillTier.js +128 -0
  167. package/dist/memory/spillTier.js.map +1 -0
  168. package/dist/memory/storageSink.d.ts +69 -0
  169. package/dist/memory/storageSink.d.ts.map +1 -0
  170. package/dist/memory/storageSink.js +221 -0
  171. package/dist/memory/storageSink.js.map +1 -0
  172. package/dist/memory/types.d.ts +202 -0
  173. package/dist/memory/types.d.ts.map +1 -0
  174. package/dist/memory/types.js +15 -0
  175. package/dist/memory/types.js.map +1 -0
  176. package/dist/memory/victims.d.ts +32 -0
  177. package/dist/memory/victims.d.ts.map +1 -0
  178. package/dist/memory/victims.js +74 -0
  179. package/dist/memory/victims.js.map +1 -0
  180. package/dist/memory/workspace.d.ts +34 -0
  181. package/dist/memory/workspace.d.ts.map +1 -0
  182. package/dist/memory/workspace.js +55 -0
  183. package/dist/memory/workspace.js.map +1 -0
  184. package/dist/memoryIntegration/index.d.ts +8 -0
  185. package/dist/memoryIntegration/index.d.ts.map +1 -0
  186. package/dist/memoryIntegration/index.js +4 -0
  187. package/dist/memoryIntegration/index.js.map +1 -0
  188. package/dist/memoryIntegration/knowledgeMemory.d.ts +43 -0
  189. package/dist/memoryIntegration/knowledgeMemory.d.ts.map +1 -0
  190. package/dist/memoryIntegration/knowledgeMemory.js +285 -0
  191. package/dist/memoryIntegration/knowledgeMemory.js.map +1 -0
  192. package/dist/memoryIntegration/persistence.d.ts +15 -0
  193. package/dist/memoryIntegration/persistence.d.ts.map +1 -0
  194. package/dist/memoryIntegration/persistence.js +43 -0
  195. package/dist/memoryIntegration/persistence.js.map +1 -0
  196. package/dist/memoryIntegration/text.d.ts +57 -0
  197. package/dist/memoryIntegration/text.d.ts.map +1 -0
  198. package/dist/memoryIntegration/text.js +179 -0
  199. package/dist/memoryIntegration/text.js.map +1 -0
  200. package/dist/memoryIntegration/types.d.ts +131 -0
  201. package/dist/memoryIntegration/types.d.ts.map +1 -0
  202. package/dist/memoryIntegration/types.js +11 -0
  203. package/dist/memoryIntegration/types.js.map +1 -0
  204. package/dist/ml.d.ts +52 -0
  205. package/dist/ml.d.ts.map +1 -0
  206. package/dist/ml.js +33 -0
  207. package/dist/ml.js.map +1 -0
  208. package/dist/node/childRelay.d.ts +10 -0
  209. package/dist/node/childRelay.d.ts.map +1 -1
  210. package/dist/node/childRelay.js +12 -2
  211. package/dist/node/childRelay.js.map +1 -1
  212. package/dist/node/index.js.map +1 -1
  213. package/dist/node/portResponder.d.ts +2 -0
  214. package/dist/node/portResponder.d.ts.map +1 -1
  215. package/dist/node/portResponder.js +3 -3
  216. package/dist/node/portResponder.js.map +1 -1
  217. package/dist/node/processHost.d.ts +4 -1
  218. package/dist/node/processHost.d.ts.map +1 -1
  219. package/dist/node/processHost.js +19 -16
  220. package/dist/node/processHost.js.map +1 -1
  221. package/dist/node/protocol.d.ts +1 -0
  222. package/dist/node/protocol.d.ts.map +1 -1
  223. package/dist/node/responseWire.d.ts.map +1 -1
  224. package/dist/node/worker.js +127 -120
  225. package/dist/node/workerProcess.js +1 -1
  226. package/dist/node/workerProcess.js.map +1 -1
  227. package/dist/prefetch/admission.d.ts +41 -0
  228. package/dist/prefetch/admission.d.ts.map +1 -0
  229. package/dist/prefetch/admission.js +49 -0
  230. package/dist/prefetch/admission.js.map +1 -0
  231. package/dist/prefetch/loadRegistry.d.ts +56 -0
  232. package/dist/prefetch/loadRegistry.d.ts.map +1 -0
  233. package/dist/prefetch/loadRegistry.js +108 -0
  234. package/dist/prefetch/loadRegistry.js.map +1 -0
  235. package/dist/prefetch/predictor.d.ts +40 -0
  236. package/dist/prefetch/predictor.d.ts.map +1 -0
  237. package/dist/prefetch/predictor.js +178 -0
  238. package/dist/prefetch/predictor.js.map +1 -0
  239. package/dist/prefetch/prefetcher.d.ts +37 -0
  240. package/dist/prefetch/prefetcher.d.ts.map +1 -0
  241. package/dist/prefetch/prefetcher.js +339 -0
  242. package/dist/prefetch/prefetcher.js.map +1 -0
  243. package/dist/prefetch/residentStore.d.ts +49 -0
  244. package/dist/prefetch/residentStore.d.ts.map +1 -0
  245. package/dist/prefetch/residentStore.js +87 -0
  246. package/dist/prefetch/residentStore.js.map +1 -0
  247. package/dist/prefetch/selfTuner.d.ts +40 -0
  248. package/dist/prefetch/selfTuner.d.ts.map +1 -0
  249. package/dist/prefetch/selfTuner.js +78 -0
  250. package/dist/prefetch/selfTuner.js.map +1 -0
  251. package/dist/prefetch/stats.d.ts +52 -0
  252. package/dist/prefetch/stats.d.ts.map +1 -0
  253. package/dist/prefetch/stats.js +72 -0
  254. package/dist/prefetch/stats.js.map +1 -0
  255. package/dist/prefetch/streaming.d.ts +132 -0
  256. package/dist/prefetch/streaming.d.ts.map +1 -0
  257. package/dist/prefetch/streaming.js +141 -0
  258. package/dist/prefetch/streaming.js.map +1 -0
  259. package/dist/prefetch/targetIndex.d.ts +18 -0
  260. package/dist/prefetch/targetIndex.d.ts.map +1 -0
  261. package/dist/prefetch/targetIndex.js +32 -0
  262. package/dist/prefetch/targetIndex.js.map +1 -0
  263. package/dist/prefetch/types.d.ts +283 -0
  264. package/dist/prefetch/types.d.ts.map +1 -0
  265. package/dist/prefetch/types.js +19 -0
  266. package/dist/prefetch/types.js.map +1 -0
  267. package/dist/previewBridge.d.ts +6 -0
  268. package/dist/previewBridge.d.ts.map +1 -1
  269. package/dist/previewBridge.js +25 -5
  270. package/dist/previewBridge.js.map +1 -1
  271. package/dist/previewMessages.d.ts +4 -3
  272. package/dist/previewMessages.d.ts.map +1 -1
  273. package/dist/previewMessages.js +12 -6
  274. package/dist/previewMessages.js.map +1 -1
  275. package/dist/process-worker.js +127 -120
  276. package/dist/relay.html +1 -1
  277. package/dist/shared/clock.d.ts +7 -0
  278. package/dist/shared/clock.d.ts.map +1 -0
  279. package/dist/shared/clock.js +10 -0
  280. package/dist/shared/clock.js.map +1 -0
  281. package/dist/shared/hardwareProbe.d.ts +26 -0
  282. package/dist/shared/hardwareProbe.d.ts.map +1 -0
  283. package/dist/shared/hardwareProbe.js +62 -0
  284. package/dist/shared/hardwareProbe.js.map +1 -0
  285. package/dist/shared/idb.d.ts +41 -0
  286. package/dist/shared/idb.d.ts.map +1 -0
  287. package/dist/shared/idb.js +184 -0
  288. package/dist/shared/idb.js.map +1 -0
  289. package/dist/shared/tokens.d.ts +7 -0
  290. package/dist/shared/tokens.d.ts.map +1 -0
  291. package/dist/shared/tokens.js +9 -0
  292. package/dist/shared/tokens.js.map +1 -0
  293. package/dist/snapshotStore.d.ts +2 -1
  294. package/dist/snapshotStore.d.ts.map +1 -1
  295. package/dist/snapshotStore.js +27 -12
  296. package/dist/snapshotStore.js.map +1 -1
  297. package/dist/styleCompilers.d.ts.map +1 -1
  298. package/dist/styleCompilers.js.map +1 -1
  299. package/dist/transport.js.map +1 -1
  300. package/package.json +11 -5
  301. package/src/adaptive/controller.ts +151 -0
  302. package/src/adaptive/costModel.ts +131 -0
  303. package/src/adaptive/planner.ts +127 -0
  304. package/src/adaptive/types.ts +137 -0
  305. package/src/check/index.ts +6 -1
  306. package/src/host.ts +33 -11
  307. package/src/inference/backends/mock.ts +77 -0
  308. package/src/inference/backends/onnx.ts +91 -0
  309. package/src/inference/backends/webllm.ts +79 -0
  310. package/src/inference/backends/wllama.ts +79 -0
  311. package/src/inference/capabilities.ts +46 -0
  312. package/src/inference/client.ts +276 -0
  313. package/src/inference/modelCache.ts +145 -0
  314. package/src/inference/protocol.ts +119 -0
  315. package/src/inference/tokenStream.ts +92 -0
  316. package/src/inference/types.ts +115 -0
  317. package/src/inference/worker.ts +191 -0
  318. package/src/inference/workerEntry.ts +18 -0
  319. package/src/kvcache/advanced.ts +86 -0
  320. package/src/kvcache/compatibility.ts +51 -0
  321. package/src/kvcache/lru.ts +100 -0
  322. package/src/kvcache/paged.ts +270 -0
  323. package/src/kvcache/quant.ts +88 -0
  324. package/src/kvcache/radix.ts +68 -0
  325. package/src/kvcache/runtime.ts +239 -0
  326. package/src/kvcache/types.ts +167 -0
  327. package/src/learning/fingerprint.ts +50 -0
  328. package/src/learning/index.ts +15 -0
  329. package/src/learning/learner.ts +304 -0
  330. package/src/learning/ledger.ts +54 -0
  331. package/src/learning/selection.ts +137 -0
  332. package/src/learning/stats.ts +39 -0
  333. package/src/learning/types.ts +142 -0
  334. package/src/memory/envProbe.ts +30 -0
  335. package/src/memory/estimates.ts +98 -0
  336. package/src/memory/eviction.ts +145 -0
  337. package/src/memory/manager.ts +380 -0
  338. package/src/memory/managerTypes.ts +61 -0
  339. package/src/memory/pressure.ts +120 -0
  340. package/src/memory/spillTier.ts +159 -0
  341. package/src/memory/storageSink.ts +289 -0
  342. package/src/memory/types.ts +217 -0
  343. package/src/memory/victims.ts +80 -0
  344. package/src/memory/workspace.ts +74 -0
  345. package/src/memoryIntegration/index.ts +7 -0
  346. package/src/memoryIntegration/knowledgeMemory.ts +339 -0
  347. package/src/memoryIntegration/persistence.ts +54 -0
  348. package/src/memoryIntegration/text.ts +185 -0
  349. package/src/memoryIntegration/types.ts +145 -0
  350. package/src/ml.ts +180 -0
  351. package/src/node/childRelay.ts +16 -3
  352. package/src/node/portResponder.ts +5 -3
  353. package/src/node/processHost.ts +16 -15
  354. package/src/node/protocol.ts +1 -1
  355. package/src/node/workerProcess.ts +1 -1
  356. package/src/prefetch/admission.ts +74 -0
  357. package/src/prefetch/loadRegistry.ts +156 -0
  358. package/src/prefetch/predictor.ts +199 -0
  359. package/src/prefetch/prefetcher.ts +369 -0
  360. package/src/prefetch/residentStore.ts +121 -0
  361. package/src/prefetch/selfTuner.ts +110 -0
  362. package/src/prefetch/stats.ts +120 -0
  363. package/src/prefetch/streaming.ts +231 -0
  364. package/src/prefetch/targetIndex.ts +40 -0
  365. package/src/prefetch/types.ts +307 -0
  366. package/src/previewBridge.ts +25 -5
  367. package/src/previewMessages.ts +11 -6
  368. package/src/shared/clock.ts +9 -0
  369. package/src/shared/hardwareProbe.ts +68 -0
  370. package/src/shared/idb.ts +203 -0
  371. package/src/shared/tokens.ts +8 -0
  372. package/src/snapshotStore.ts +25 -10
@@ -0,0 +1,151 @@
1
+ /**
2
+ * AHEC controller — the Adaptive Heterogeneous Execution Controller.
3
+ *
4
+ * Owns the decide -> execute -> measure loop. For each request it:
5
+ * 1. probes hardware facts,
6
+ * 2. builds an explainable execution plan (cost-based, CPU-first),
7
+ * 3. routes local vs remote (local-only unless configured otherwise),
8
+ * 4. drives an injected executor,
9
+ * 5. measures its own overhead against the benefit the plan provided.
10
+ *
11
+ * CPU-only is a first-class configuration; heterogeneous execution is enabled
12
+ * only when the plan estimates it beats CPU-only by the configured margin.
13
+ */
14
+
15
+ import type {
16
+ ControllerConfig,
17
+ ExecutionDecision,
18
+ ExecutionOutcome,
19
+ ExecutorLike,
20
+ HardwareProfile,
21
+ WorkloadProfile,
22
+ } from './types.js';
23
+ import { planExecution } from './planner.js';
24
+ import { estimateWeightBytes } from '../memory/estimates.js';
25
+ import { now as nowMs } from '../shared/clock.js';
26
+ import { estimateTokens } from '../shared/tokens.js';
27
+ import {
28
+ detectCrossOriginIsolated,
29
+ detectSharedArrayBuffer,
30
+ detectWasmSimd,
31
+ detectWebGpu,
32
+ probeDeviceMemoryBytes,
33
+ probeHardwareConcurrency,
34
+ } from '../shared/hardwareProbe.js';
35
+
36
+ /** A linear layer graph derived from the workload, for the planner to partition. */
37
+ function defaultGraph(workload: WorkloadProfile) {
38
+ // A coarse 12-layer transformer-style graph sized to the model. The planner
39
+ // only needs relative per-layer costs to pick a split point.
40
+ const layers = 12;
41
+ const attentionFraction = workload.attentionFraction ?? 0.25;
42
+ const perLayerCpu = workload.residentBytes > 0 ? 0 : 0; // placeholder, costs set below
43
+ void perLayerCpu;
44
+ const base = (workload.promptTokens + workload.decodeTokens) / layers;
45
+ return {
46
+ layers: Array.from({ length: layers }, (_, i) => {
47
+ const isAttention = (i % Math.max(1, Math.round(1 / Math.max(attentionFraction, 0.01)))) === 0;
48
+ const cpuCostMs = base * (isAttention ? 1.2 : 1.0);
49
+ return {
50
+ id: `L${i}`,
51
+ cpuCostMs,
52
+ gpuCostMs: cpuCostMs * 0.3,
53
+ inputBytes: 1024 * workload.promptTokens * 2,
54
+ };
55
+ }),
56
+ };
57
+ }
58
+
59
+ /** RAM assumed when `navigator.deviceMemory` is unreported (4 GiB). */
60
+ const DEFAULT_RAM_BYTES = 4 * 1024 * 1024 * 1024;
61
+
62
+ /** Probe hardware facts from the environment (never throws; facts not gates). */
63
+ export function probeHardware(): HardwareProfile {
64
+ return {
65
+ cores: probeHardwareConcurrency() ?? 4,
66
+ wasmSimd: detectWasmSimd(),
67
+ webgpu: detectWebGpu(),
68
+ crossOriginIsolated: detectCrossOriginIsolated(),
69
+ sharedArrayBuffer: detectSharedArrayBuffer(),
70
+ ramBytes: probeDeviceMemoryBytes() ?? DEFAULT_RAM_BYTES,
71
+ };
72
+ }
73
+
74
+ export interface AdaptiveController {
75
+ /** Decide (and optionally execute) one request. */
76
+ execute(
77
+ model: { id: string; paramsB: number; quantization: 'q4' | 'q5' | 'q8' | 'fp16' },
78
+ request: { prompt: string; maxTokens?: number; signal?: AbortSignal },
79
+ ): Promise<ExecutionOutcome>;
80
+ /** Aggregate controller statistics (overhead vs benefit accounting). */
81
+ stats(): { runs: number; totalOverheadMs: number; totalBenefitMs: number; lastDecision?: ExecutionDecision };
82
+ /** The most recent explainable decision, for audit/UI. */
83
+ lastDecision(): ExecutionDecision | undefined;
84
+ }
85
+
86
+ export function createAdaptiveController(
87
+ executor: ExecutorLike,
88
+ config: ControllerConfig = {},
89
+ ): AdaptiveController {
90
+ // Probe once; the controller treats hardware as stable within a session.
91
+ const hardware = config.hardwareOverride ?? probeHardware();
92
+ let last: ExecutionDecision | undefined;
93
+ let runs = 0;
94
+ let totalOverheadMs = 0;
95
+ let totalBenefitMs = 0;
96
+
97
+ return {
98
+ async execute(model, request) {
99
+ const workload: WorkloadProfile = {
100
+ paramsB: model.paramsB,
101
+ quantization: model.quantization,
102
+ promptTokens: Math.max(1, estimateTokens(request.prompt)),
103
+ decodeTokens: request.maxTokens ?? 128,
104
+ residentBytes: estimateResidentBytes(model),
105
+ };
106
+
107
+ const planStart = nowMs();
108
+ const plan = planExecution({ workload, hardware, graph: defaultGraph(workload), config });
109
+ const overheadMs = nowMs() - planStart;
110
+
111
+ const route = config.allowRemote === true && hardware.webgpu === false && workload.paramsB > 13
112
+ ? ('remote' as const)
113
+ : ('local' as const);
114
+ const decision: ExecutionDecision = { plan, route, hardware, workload };
115
+ if (route === 'remote') {
116
+ decision.plan.reasoning.push('remote route: model too large for local memory and remote allowed');
117
+ }
118
+ last = decision;
119
+ config.onDecision?.(decision);
120
+
121
+ const execStart = nowMs();
122
+ const stream = executor.generate(
123
+ { id: model.id, paramsB: model.paramsB, quantization: model.quantization },
124
+ { prompt: request.prompt, maxTokens: request.maxTokens ?? 128, signal: request.signal },
125
+ );
126
+ let tokens = 0;
127
+ for await (const event of stream) {
128
+ if (event.token) tokens += 1;
129
+ }
130
+ const measuredCostMs = nowMs() - execStart;
131
+
132
+ const benefitMs = decision.plan.estimatedCostMs - measuredCostMs;
133
+ runs += 1;
134
+ totalOverheadMs += overheadMs;
135
+ totalBenefitMs += benefitMs;
136
+
137
+ return { decision, measuredCostMs, overheadMs, benefitMs, tokens };
138
+ },
139
+ stats() {
140
+ return { runs, totalOverheadMs, totalBenefitMs, lastDecision: last };
141
+ },
142
+ lastDecision() {
143
+ return last;
144
+ },
145
+ };
146
+ }
147
+
148
+ /** Weights + ~20% KV/activation headroom, from the canonical memory estimate. */
149
+ function estimateResidentBytes(model: { paramsB: number; quantization: string }): number {
150
+ return estimateWeightBytes(model.paramsB, model.quantization, 1.2);
151
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * AHEC cost model — estimates execution cost from workload + hardware facts.
3
+ *
4
+ * Pure and deterministic: the same inputs always produce the same estimate, so
5
+ * planning decisions are reproducible and explainable. Estimates are coarse by
6
+ * design (they rank strategies, they do not predict wall-clock to the ms).
7
+ */
8
+
9
+ import type { HardwareProfile, WorkloadProfile } from './types.js';
10
+
11
+ /** Cost estimate breakdown for one candidate execution. */
12
+ export interface CostEstimate {
13
+ /** Compute time in ms. */
14
+ computeMs: number;
15
+ /** Data-transfer time in ms (activations/weights crossing the device boundary). */
16
+ transferMs: number;
17
+ /** Fixed per-sync-point overhead in ms. */
18
+ syncMs: number;
19
+ /** Memory-allocation penalty in ms (cold buffers). */
20
+ allocMs: number;
21
+ /** Cache-miss penalty in ms (weights/activations not resident). */
22
+ cacheMissMs: number;
23
+ /** Total wall-clock estimate in ms. */
24
+ totalMs: number;
25
+ }
26
+
27
+ /** Bytes per activation element (fp16 KV / activations in the 1B–4B target range). */
28
+ const BYTES_PER_ELEM = 2;
29
+
30
+ /** Rough per-param per-token FLOPs multiplier for decode (2 for forward pass). */
31
+ const FLOPS_PER_PARAM_PER_TOKEN = 2;
32
+
33
+ /** Assume ~1 GFLOP/ms effective on a single scalar wasm core; SIMD ~4x; multi-core adds a sub-linear gain. */
34
+ function cpuGflopsPerMs(hw: HardwareProfile): number {
35
+ let g = 1.0;
36
+ if (hw.wasmSimd) g *= 4;
37
+ // Sub-linear multi-core gain: cores help prefill (parallel) more than decode.
38
+ g *= 1 + Math.min(hw.cores, 8) * 0.25;
39
+ return g;
40
+ }
41
+
42
+ /** Rough effective GPU throughput multiplier over a single scalar CPU core. */
43
+ function gpuGflopsPerMs(_hw: HardwareProfile): number {
44
+ // Deliberately conservative: integrated/mobile GPUs are far weaker than discrete.
45
+ return 40;
46
+ }
47
+
48
+ /** Working estimate of effective active parameters from the profile. */
49
+ function effectiveParams(workload: WorkloadProfile): number {
50
+ const dense = workload.paramsB * 1e9;
51
+ return dense * (workload.activeFraction ?? 1);
52
+ }
53
+
54
+ /**
55
+ * Estimate the cost of running `workload` entirely on CPU.
56
+ */
57
+ export function estimateCpuCost(workload: WorkloadProfile, hw: HardwareProfile): CostEstimate {
58
+ const params = effectiveParams(workload);
59
+ const flops = params * FLOPS_PER_PARAM_PER_TOKEN * (workload.promptTokens + workload.decodeTokens);
60
+ const computeMs = flops / (cpuGflopsPerMs(hw) * 1e9) * 1000;
61
+
62
+ // KV cache + weight residency: if the model does not fit comfortably in RAM,
63
+ // add a cache-miss penalty proportional to the shortfall.
64
+ const ramBudget = hw.ramBytes * 0.5;
65
+ const cacheMissMs = workload.residentBytes > ramBudget
66
+ ? ((workload.residentBytes - ramBudget) / 1e6) * 2
67
+ : 0;
68
+
69
+ const allocMs = Math.min(workload.residentBytes / 1e7, 200); // cold buffer setup, capped
70
+ return {
71
+ computeMs,
72
+ transferMs: 0,
73
+ syncMs: 0,
74
+ allocMs,
75
+ cacheMissMs,
76
+ totalMs: computeMs + allocMs + cacheMissMs,
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Estimate the cost of running `workload` entirely on GPU (when available).
82
+ */
83
+ export function estimateGpuCost(workload: WorkloadProfile, hw: HardwareProfile): CostEstimate | null {
84
+ if (!hw.webgpu) return null;
85
+ const params = effectiveParams(workload);
86
+ const flops = params * FLOPS_PER_PARAM_PER_TOKEN * (workload.promptTokens + workload.decodeTokens);
87
+ const computeMs = flops / (gpuGflopsPerMs(hw) * 1e9) * 1000;
88
+ // Upload weights once (residentBytes across the bus at ~5 GB/s effective).
89
+ const transferMs = workload.residentBytes / 5e9 * 1000;
90
+ const allocMs = Math.min(workload.residentBytes / 1e7, 200);
91
+ return {
92
+ computeMs,
93
+ transferMs,
94
+ syncMs: 0,
95
+ allocMs,
96
+ cacheMissMs: 0,
97
+ totalMs: computeMs + transferMs + allocMs,
98
+ };
99
+ }
100
+
101
+ /**
102
+ * Estimate a split (heterogeneous) plan: `gpuFraction` of the compute runs on
103
+ * GPU, the rest on CPU, with one transfer + sync at the device boundary.
104
+ */
105
+ export function estimateSplitCost(
106
+ workload: WorkloadProfile,
107
+ hw: HardwareProfile,
108
+ gpuFraction: number,
109
+ transferSyncPenaltyMs: number,
110
+ ): CostEstimate | null {
111
+ const gpu = estimateGpuCost(workload, hw);
112
+ if (!gpu) return null;
113
+ const cpu = estimateCpuCost(workload, hw);
114
+ const gpuPart = gpu.computeMs * gpuFraction;
115
+ const cpuPart = cpu.computeMs * (1 - gpuFraction);
116
+ // Layers run in dependency order; without device overlap the compute is serial.
117
+ const computeMs = gpuPart + cpuPart;
118
+ // Only the boundary activations cross the bus, not the full weights.
119
+ const boundaryBytes = workload.residentBytes * 0.02 + BYTES_PER_ELEM * workload.promptTokens * 1024;
120
+ const transferMs = boundaryBytes / 5e9 * 1000;
121
+ const syncMs = transferSyncPenaltyMs;
122
+ const allocMs = Math.max(cpu.allocMs, gpu.allocMs);
123
+ return {
124
+ computeMs,
125
+ transferMs,
126
+ syncMs,
127
+ allocMs,
128
+ cacheMissMs: cpu.cacheMissMs * (1 - gpuFraction),
129
+ totalMs: computeMs + transferMs + syncMs + allocMs,
130
+ };
131
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * AHEC planner — cost-based execution planning over the layer graph.
3
+ *
4
+ * HEFT-lite: for the linear transformer-style dependency chain (L0 -> L1 -> ...)
5
+ * the partition problem reduces to choosing a split point, which dynamic
6
+ * programming solves exactly in O(n). We also evaluate the all-CPU and all-GPU
7
+ * extremes. A heterogeneous plan is only returned when it beats the best
8
+ * homogeneous plan by the configured margin — heterogeneity is never assumed.
9
+ */
10
+
11
+ import type { ControllerConfig, ExecutionGraph, ExecutionPlan, HardwareProfile, WorkloadProfile } from './types.js';
12
+ import { estimateCpuCost, estimateGpuCost, estimateSplitCost } from './costModel.js';
13
+
14
+ export interface PlanRequest {
15
+ workload: WorkloadProfile;
16
+ hardware: HardwareProfile;
17
+ graph: ExecutionGraph;
18
+ config: ControllerConfig;
19
+ }
20
+
21
+ /**
22
+ * Plan execution for one request. Pure given its inputs — the same request
23
+ * always yields the same plan, which keeps decisions explainable and testable.
24
+ */
25
+ export function planExecution(req: PlanRequest): ExecutionPlan {
26
+ const { workload, hardware, graph, config } = req;
27
+ const reasoning: string[] = [];
28
+ const margin = config.heterogeneityMargin ?? 0.05;
29
+ const syncPenalty = config.transferSyncPenaltyMs ?? 4;
30
+
31
+ const cpuOnlyForced = config.cpuOnly === true;
32
+ if (cpuOnlyForced) reasoning.push('cpu-only forced by config');
33
+
34
+ const cpu = estimateCpuCost(workload, hardware);
35
+ reasoning.push(`cpu estimate ${cpu.totalMs.toFixed(1)}ms`);
36
+
37
+ // CPU-only candidate.
38
+ let best: ExecutionPlan = {
39
+ strategy: 'cpu-only',
40
+ backend: pickBackend(hardware, 'cpu-only'),
41
+ reasoning: [...reasoning, 'cpu-only selected'],
42
+ estimatedCostMs: cpu.totalMs,
43
+ gpuLayerIds: [],
44
+ cpuLayerIds: graph.layers.map((l) => l.id),
45
+ };
46
+ let bestCost = cpu.totalMs;
47
+
48
+ const gpuUsable = !cpuOnlyForced && hardware.webgpu;
49
+ if (!hardware.webgpu) reasoning.push('webgpu unavailable');
50
+
51
+ if (gpuUsable) {
52
+ const gpu = estimateGpuCost(workload, hardware);
53
+ if (gpu) {
54
+ reasoning.push(`gpu estimate ${gpu.totalMs.toFixed(1)}ms`);
55
+ // GPU-only candidate.
56
+ if (gpu.totalMs < bestCost * (1 - margin)) {
57
+ best = {
58
+ strategy: 'gpu-only',
59
+ backend: pickBackend(hardware, 'gpu-only'),
60
+ reasoning: [...reasoning, `gpu-only beats cpu by ${(bestCost - gpu.totalMs).toFixed(1)}ms`],
61
+ estimatedCostMs: gpu.totalMs,
62
+ gpuLayerIds: graph.layers.map((l) => l.id),
63
+ cpuLayerIds: [],
64
+ };
65
+ bestCost = gpu.totalMs;
66
+ }
67
+
68
+ // Split candidates: prefix-on-CPU/suffix-on-GPU and the reverse, plus a
69
+ // mid split. DP over all split points for exactness on the linear chain.
70
+ const n = graph.layers.length;
71
+ if (n > 0) {
72
+ // Cumulative per-layer cost lets us score any split point in O(1).
73
+ let cpuPrefix = 0;
74
+ const cpuCumulative: number[] = [];
75
+ let gpuPrefix = 0;
76
+ const gpuCumulative: number[] = [];
77
+ for (const layer of graph.layers) {
78
+ cpuPrefix += layer.cpuCostMs;
79
+ gpuPrefix += Number.isFinite(layer.gpuCostMs) ? layer.gpuCostMs : layer.cpuCostMs * 4;
80
+ cpuCumulative.push(cpuPrefix);
81
+ gpuCumulative.push(gpuPrefix);
82
+ }
83
+ const totalCpu = cpuPrefix;
84
+ const totalGpu = gpuPrefix;
85
+
86
+ for (let split = 0; split <= n; split++) {
87
+ const cpuPart = cpuCumulative[split - 1] ?? 0;
88
+ const gpuPart = totalGpu - (gpuCumulative[split - 1] ?? 0);
89
+ const gpuFraction = totalGpu > 0 ? gpuPart / totalGpu : 0;
90
+ const est = estimateSplitCost(workload, hardware, gpuFraction, syncPenalty);
91
+ if (!est) continue;
92
+ // Scale the analytic split estimate to the per-layer graph costs so the
93
+ // plan honors the actual dependency structure, not just the analytic model.
94
+ const graphCompute = cpuPart + gpuPart;
95
+ const analyticCompute = est.computeMs || 1;
96
+ const scaled = (est.totalMs - est.computeMs) + graphCompute * (est.computeMs / analyticCompute);
97
+ if (scaled < bestCost * (1 - margin)) {
98
+ const gpuIds = graph.layers.slice(split).map((l) => l.id);
99
+ const cpuIds = graph.layers.slice(0, split).map((l) => l.id);
100
+ best = {
101
+ strategy: split === 0 ? 'gpu-only' : split === n ? 'cpu-only' : 'layer-split',
102
+ backend: pickBackend(hardware, 'layer-split'),
103
+ reasoning: [
104
+ ...reasoning,
105
+ `layer-split at ${split}/${n} (gpu layers ${gpuIds.length}) saves est. ${(bestCost - scaled).toFixed(1)}ms after ${(est.transferMs + est.syncMs).toFixed(1)}ms transfer+sync`,
106
+ ],
107
+ estimatedCostMs: scaled,
108
+ gpuLayerIds: gpuIds,
109
+ cpuLayerIds: cpuIds,
110
+ };
111
+ bestCost = scaled;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ return best;
119
+ }
120
+
121
+ function pickBackend(hw: HardwareProfile, strategy: ExecutionPlan['strategy']): ExecutionPlan['backend'] {
122
+ // WebGPU-present strategies prefer the WebLLM adapter; CPU paths prefer ONNX
123
+ // (Wllama when cross-origin isolation enables threaded decode).
124
+ if (strategy === 'gpu-only') return 'webllm';
125
+ if (hw.crossOriginIsolated && hw.sharedArrayBuffer) return 'wllama';
126
+ return 'onnx';
127
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Adaptive Heterogeneous Execution Controller (AHEC) — types.
3
+ *
4
+ * The controller decides WHERE/HOW to execute an inference workload and WHY.
5
+ * It is deliberately decoupled from the execution engine in `src/inference/`
6
+ * (which only knows HOW to run): the controller routes to an injected executor
7
+ * and picks a backend + strategy from measured hardware capabilities.
8
+ *
9
+ * Browser-compatible only: pure TypeScript, no native code, no dependencies.
10
+ */
11
+
12
+ /** Hardware facts probed from the environment. Facts, not gates. */
13
+ export interface HardwareProfile {
14
+ /** Logical CPU cores available to workers. */
15
+ cores: number;
16
+ /** WebAssembly SIMD is available (v128 probe). */
17
+ wasmSimd: boolean;
18
+ /** WebGPU adapter is present and usable. */
19
+ webgpu: boolean;
20
+ /** Page is cross-origin isolated. */
21
+ crossOriginIsolated: boolean;
22
+ /** SharedArrayBuffer is available. */
23
+ sharedArrayBuffer: boolean;
24
+ /** Usable RAM hint in bytes (navigator.deviceMemory * ~1GiB when present). */
25
+ ramBytes: number;
26
+ }
27
+
28
+ /**
29
+ * Characterization of one inference request, used for planning.
30
+ * All fields are hints the planner reasons over; none are required to be exact.
31
+ */
32
+ export interface WorkloadProfile {
33
+ /** Model size in billions of parameters. */
34
+ paramsB: number;
35
+ /** Quantization bucket, matching `ModelRef.quantization`. */
36
+ quantization: 'q4' | 'q5' | 'q8' | 'fp16';
37
+ /** Expected prompt (prefill) token count. */
38
+ promptTokens: number;
39
+ /** Expected decode (generation) token count. */
40
+ decodeTokens: number;
41
+ /** Approximate resident bytes the model needs (weights + KV headroom). */
42
+ residentBytes: number;
43
+ /** Fraction of layers that are attention (rest treated as FFN). */
44
+ attentionFraction?: number;
45
+ /** Sparsity / MoE: fraction of parameters active per token (1 = dense). */
46
+ activeFraction?: number;
47
+ }
48
+
49
+ /** One node in the layer-dependency graph the planner partitions. */
50
+ export interface LayerNode {
51
+ id: string;
52
+ /** Estimated cost to run this layer on CPU, in ms. */
53
+ cpuCostMs: number;
54
+ /** Estimated cost on GPU, in ms (Infinity if unsupported). */
55
+ gpuCostMs: number;
56
+ /** Bytes of activations this layer consumes from its predecessor. */
57
+ inputBytes: number;
58
+ }
59
+
60
+ /** A linear-dependency layer graph (transformer-style: L0 -> L1 -> ... -> Ln). */
61
+ export interface ExecutionGraph {
62
+ layers: LayerNode[];
63
+ }
64
+
65
+ /** Where a plan runs. */
66
+ export type ExecutionStrategy =
67
+ | 'cpu-only'
68
+ | 'gpu-only'
69
+ | 'cpu-prefill-gpu-decode'
70
+ | 'gpu-prefill-cpu-decode'
71
+ | 'layer-split';
72
+
73
+ /** A chosen execution strategy with its justification. */
74
+ export interface ExecutionPlan {
75
+ strategy: ExecutionStrategy;
76
+ /** Which backend kind the executor should use. */
77
+ backend: 'onnx' | 'wllama' | 'webllm' | 'mock';
78
+ /** Human-readable, auditable reasoning trail for this decision. */
79
+ reasoning: string[];
80
+ /** Estimated wall-clock cost in ms (including transfer + sync). */
81
+ estimatedCostMs: number;
82
+ /** Layers assigned to GPU (empty for cpu-only). */
83
+ gpuLayerIds: string[];
84
+ /** Layers assigned to CPU. */
85
+ cpuLayerIds: string[];
86
+ }
87
+
88
+ /** The decision the controller makes for one request. */
89
+ export interface ExecutionDecision {
90
+ plan: ExecutionPlan;
91
+ /** 'local' | 'remote' — remote is only chosen when explicitly configured. */
92
+ route: 'local' | 'remote';
93
+ /** Probed hardware snapshot the decision was made against. */
94
+ hardware: HardwareProfile;
95
+ /** Workload snapshot the decision was made against. */
96
+ workload: WorkloadProfile;
97
+ }
98
+
99
+ /** Result of running one request through the controller. */
100
+ export interface ExecutionOutcome {
101
+ decision: ExecutionDecision;
102
+ /** Wall-clock ms actually observed for the executor call. */
103
+ measuredCostMs: number;
104
+ /** ms the controller spent planning (its own overhead). */
105
+ overheadMs: number;
106
+ /** planned - measured; positive means the plan beat the estimate. */
107
+ benefitMs: number;
108
+ /** Tokens produced (when the executor reports them). */
109
+ tokens?: number;
110
+ }
111
+
112
+ /** Controller configuration. */
113
+ export interface ControllerConfig {
114
+ /** Force CPU-only planning regardless of probe. Default false. */
115
+ cpuOnly?: boolean;
116
+ /** Allow routing to a remote executor. Default false (local-only). */
117
+ allowRemote?: boolean;
118
+ /** Heterogeneous plans must beat the CPU-only estimate by this margin. Default 0.05 (5%). */
119
+ heterogeneityMargin?: number;
120
+ /** Per-transfer-point fixed sync penalty in ms. Default 4. */
121
+ transferSyncPenaltyMs?: number;
122
+ /** Optional decision logger (explainability sink). */
123
+ onDecision?: (decision: ExecutionDecision) => void;
124
+ /** Test hook: override the probed hardware profile. */
125
+ hardwareOverride?: HardwareProfile;
126
+ }
127
+
128
+ /** Minimal executor surface the controller drives (matches InferenceClient). */
129
+ export interface ExecutorLike {
130
+ load(model: { id: string; paramsB: number; quantization: string }): Promise<unknown>;
131
+ generate(
132
+ model: { id: string; paramsB: number; quantization: string },
133
+ options: { prompt: string; maxTokens: number; signal?: AbortSignal },
134
+ ): AsyncIterable<{ token: string }> & { stats?: () => Promise<{ ttftMs: number; tokensPerSecond: number }> };
135
+ }
136
+
137
+ export type { Quantization } from '../inference/types.js';
@@ -13,7 +13,12 @@ import { CHECK, CHECK_RESULT, isCheckInput, isCheckReply, type CheckReply } from
13
13
  export type { CheckDiagnostic, DiagnosticCategory, TypecheckResult } from '@seanhogg/builderforce-webcontainers-core/check';
14
14
  export { formatDiagnostic } from '@seanhogg/builderforce-webcontainers-core/check';
15
15
 
16
- /** The TypeScript the checker runs. Pinned, so results do not change under a project. */
16
+ /**
17
+ * The TypeScript the checker runs. Pinned, so results do not change under a project.
18
+ * The devDependency `typescript` in packages/core and packages/browser (and the root) must
19
+ * equal this version, so the tests run the compiler that ships. `tsc` in node_modules/.bin is that
20
+ * 5.9.3 API package's, so the package scripts call `typescript-7/bin/tsc` (TS 7) directly.
21
+ */
17
22
  export const TYPESCRIPT_VERSION = '5.9.3';
18
23
  export const DEFAULT_TYPESCRIPT_URL = `https://cdn.jsdelivr.net/npm/typescript@${TYPESCRIPT_VERSION}/lib/typescript.js`;
19
24