@wenathlan/devthink 2.0.15 → 2.0.19

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 (444) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/{dist/bridge.d.ts → bridge.d.ts} +1 -1
  3. package/bridge.d.ts.map +1 -0
  4. package/bridge.js +1877 -0
  5. package/bun.d.ts.map +1 -0
  6. package/bun.js +52329 -0
  7. package/caps/background.json +712 -0
  8. package/caps/cli.json +360 -0
  9. package/caps/library.json +3611 -0
  10. package/caps/mcp.json +126 -0
  11. package/caps/pagebridge.json +377 -0
  12. package/caps/popup.json +51 -0
  13. package/caps/sidepanel.json +522 -0
  14. package/checksums.txt +142 -0
  15. package/cli.d.ts.map +1 -0
  16. package/{dist/cli.js → cli.js} +2 -2
  17. package/companion.d.ts.map +1 -0
  18. package/companion.js +389 -0
  19. package/crossbrowser.d.ts.map +1 -0
  20. package/crossbrowser.js +1191 -0
  21. package/dashdone.d.ts.map +1 -0
  22. package/dashdone.js +368 -0
  23. package/deno.d.ts.map +1 -0
  24. package/deno.js +52325 -0
  25. package/devthink.umd.js +52346 -0
  26. package/fixtures/bun.ts +7 -0
  27. package/fixtures/cjs.js +6 -0
  28. package/fixtures/deno.ts +6 -0
  29. package/fixtures/example-org-pagestate.json +22 -0
  30. package/fixtures/importers/automa-workflow.json +18 -0
  31. package/fixtures/importers/selenium-side.json +20 -0
  32. package/fixtures/importers/tabular-plan.csv +7 -0
  33. package/fixtures/importers/uivision-macro.json +10 -0
  34. package/fixtures/importers/v1-plan.json +13 -0
  35. package/fixtures/mcp-client.mjs +14 -0
  36. package/fixtures/pages/checkout.html +192 -0
  37. package/fixtures/pages/dashboard.html +110 -0
  38. package/fixtures/pages/feed.html +113 -0
  39. package/fixtures/pages/product-grid.html +150 -0
  40. package/fixtures/plans/form-inventory-plan.json +11 -0
  41. package/fixtures/plans/release-notes-plan.json +11 -0
  42. package/fixtures/recipes/agentscompete.json +11 -0
  43. package/fixtures/recipes/agentsforms.json +11 -0
  44. package/fixtures/recipes/agentsmonitor.json +11 -0
  45. package/fixtures/recipes/agentsreview.json +29 -0
  46. package/fixtures/recipes/agentswarm.json +11 -0
  47. package/fixtures/recipes/fillcalendar.json +12 -0
  48. package/fixtures/recipes/fillcheckout.json +13 -0
  49. package/fixtures/recipes/filldependentdropdowns.json +12 -0
  50. package/fixtures/recipes/fillfromcsv.json +13 -0
  51. package/fixtures/recipes/fillloginform.json +12 -0
  52. package/fixtures/recipes/fillmultistepwizard.json +13 -0
  53. package/fixtures/recipes/fillregistration.json +12 -0
  54. package/fixtures/recipes/fillsearchfilters.json +12 -0
  55. package/fixtures/recipes/filltypeahead.json +11 -0
  56. package/fixtures/recipes/monitoralerts.json +12 -0
  57. package/fixtures/recipes/monitoravailability.json +11 -0
  58. package/fixtures/recipes/monitornetworkquiet.json +12 -0
  59. package/fixtures/recipes/monitorpagechanges.json +11 -0
  60. package/fixtures/recipes/monitorpricechange.json +11 -0
  61. package/fixtures/recipes/monitorschedule.json +12 -0
  62. package/fixtures/recipes/scrapedynamicprices.json +13 -0
  63. package/fixtures/recipes/scrapeimagegallery.json +12 -0
  64. package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
  65. package/fixtures/recipes/scrapenestedlists.json +12 -0
  66. package/fixtures/recipes/scrapeproductgrid.json +12 -0
  67. package/fixtures/recipes/scrapereviews.json +12 -0
  68. package/fixtures/recipes/scrapesearchresults.json +12 -0
  69. package/fixtures/recipes/scrapetablepagination.json +12 -0
  70. package/fixtures/recipes/testaccessibility.json +34 -0
  71. package/fixtures/recipes/testconsoleerrors.json +12 -0
  72. package/fixtures/recipes/testdeeplinks.json +12 -0
  73. package/fixtures/recipes/testformvalidation.json +13 -0
  74. package/fixtures/recipes/testlayoutshift.json +12 -0
  75. package/fixtures/recipes/testlinkcheck.json +12 -0
  76. package/fixtures/recipes/testloadtiming.json +12 -0
  77. package/fixtures/recipes/testvisualdiff.json +12 -0
  78. package/fixtures/workflows/changelog-digest-workflow.json +13 -0
  79. package/fixtures/workflows/form-survey-workflow.json +13 -0
  80. package/gallery.json +706 -0
  81. package/hardening.d.ts.map +1 -0
  82. package/hardening.js +188 -0
  83. package/headless.d.ts.map +1 -0
  84. package/headless.js +11522 -0
  85. package/http.d.ts.map +1 -0
  86. package/http.js +2165 -0
  87. package/index.cjs +54682 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +52310 -0
  90. package/index.neutral.js +46343 -0
  91. package/{web/manifest.json → manifest.json} +1 -1
  92. package/mcp.d.ts.map +1 -0
  93. package/mcp.js +20515 -0
  94. package/memory.d.ts.map +1 -0
  95. package/{memory.ts → memory.js} +2310 -3834
  96. package/nativehost.template.json +10 -0
  97. package/node.cjs +54686 -0
  98. package/node.d.ts.map +1 -0
  99. package/pack.d.ts.map +1 -0
  100. package/pack.js +805 -0
  101. package/package.json +83 -176
  102. package/policy.d.ts.map +1 -0
  103. package/{policy.ts → policy.js} +4679 -5073
  104. package/progress.d.ts.map +1 -0
  105. package/progress.js +645 -0
  106. package/protocol.d.ts.map +1 -0
  107. package/protocol.js +8334 -0
  108. package/schemas/audit.schema.json +226 -0
  109. package/schemas/capability.schema.json +113 -0
  110. package/schemas/envelope.schema.json +162 -0
  111. package/schemas/memory.schema.json +51 -0
  112. package/schemas/observation.schema.json +113 -0
  113. package/schemas/plan.schema.json +208 -0
  114. package/schemas/progress.schema.json +126 -0
  115. package/schemas/proposal.schema.json +68 -0
  116. package/schemas/session.schema.json +82 -0
  117. package/schemas/tool.schema.json +94 -0
  118. package/server.d.ts.map +1 -0
  119. package/server.js +28877 -0
  120. package/umd-example.html +18 -0
  121. package/umd.d.ts.map +1 -0
  122. package/accounts.ts +0 -2087
  123. package/agent.ts +0 -2331
  124. package/antigravity.ts +0 -2139
  125. package/apifreeze.ts +0 -4146
  126. package/auth.ts +0 -642
  127. package/background.ts +0 -16837
  128. package/bridge.ts +0 -2080
  129. package/build.ts +0 -54
  130. package/bun.ts +0 -26
  131. package/capture.ts +0 -1614
  132. package/checksecrets.ts +0 -72
  133. package/cjs.ts +0 -9
  134. package/cli.ts +0 -3500
  135. package/commands.ts +0 -1101
  136. package/companion.ts +0 -450
  137. package/compatibility.ts +0 -37
  138. package/config.ts +0 -3137
  139. package/constants.ts +0 -943
  140. package/core.ts +0 -1473
  141. package/crossbrowser.ts +0 -1359
  142. package/dashdone.ts +0 -605
  143. package/data.ts +0 -943
  144. package/database.ts +0 -133
  145. package/debug.ts +0 -850
  146. package/deno.ts +0 -27
  147. package/devthink.ts +0 -707
  148. package/dist/accounts.d.ts +0 -409
  149. package/dist/agent.d.ts +0 -837
  150. package/dist/antigravity.d.ts +0 -380
  151. package/dist/apifreeze.d.ts +0 -113
  152. package/dist/auth.d.ts +0 -224
  153. package/dist/capture.d.ts +0 -595
  154. package/dist/cjs.d.ts +0 -6
  155. package/dist/commands.d.ts +0 -310
  156. package/dist/compatibility.d.ts +0 -17
  157. package/dist/config.d.ts +0 -1853
  158. package/dist/constants.d.ts +0 -637
  159. package/dist/core.d.ts +0 -361
  160. package/dist/data.d.ts +0 -330
  161. package/dist/database.d.ts +0 -24
  162. package/dist/debug.d.ts +0 -270
  163. package/dist/engine.d.ts +0 -74
  164. package/dist/environments.d.ts +0 -244
  165. package/dist/evidence.d.ts +0 -277
  166. package/dist/export.d.ts +0 -311
  167. package/dist/fingerprint.d.ts +0 -594
  168. package/dist/flow.d.ts +0 -300
  169. package/dist/gates.d.ts +0 -103
  170. package/dist/identity.d.ts +0 -51
  171. package/dist/ids.d.ts +0 -7
  172. package/dist/llm.d.ts +0 -652
  173. package/dist/models.d.ts +0 -1807
  174. package/dist/net.d.ts +0 -325
  175. package/dist/neutral.d.ts +0 -41
  176. package/dist/oauth.d.ts +0 -703
  177. package/dist/page.d.ts +0 -1166
  178. package/dist/perf.d.ts +0 -481
  179. package/dist/plan.d.ts +0 -134
  180. package/dist/project.d.ts +0 -395
  181. package/dist/providers.d.ts +0 -37
  182. package/dist/quota.d.ts +0 -453
  183. package/dist/recovery.d.ts +0 -621
  184. package/dist/request.d.ts +0 -1492
  185. package/dist/run.d.ts +0 -779
  186. package/dist/runtime.d.ts +0 -212
  187. package/dist/search.d.ts +0 -375
  188. package/dist/security.d.ts +0 -534
  189. package/dist/serve.d.ts +0 -136
  190. package/dist/session.d.ts +0 -296
  191. package/dist/storage.d.ts +0 -53
  192. package/dist/streaming.d.ts +0 -1119
  193. package/dist/swarm.d.ts +0 -328
  194. package/dist/tools.d.ts +0 -170
  195. package/dist/types.d.ts +0 -8357
  196. package/dist/utils.d.ts +0 -82
  197. package/dist/version.d.ts +0 -7
  198. package/dist/versionregistry.d.ts +0 -406
  199. package/dist/views.d.ts +0 -579
  200. package/dist/workbenchsession.d.ts +0 -69
  201. package/dist/workflow.d.ts +0 -649
  202. package/docs/readme.md +0 -92
  203. package/docs/schemas/antigravity.json +0 -192
  204. package/engine.ts +0 -1524
  205. package/environments.ts +0 -1005
  206. package/evidence.ts +0 -643
  207. package/export.ts +0 -889
  208. package/fingerprint.ts +0 -1458
  209. package/flow.ts +0 -1190
  210. package/gates.ts +0 -307
  211. package/gateway.ts +0 -34
  212. package/hardening.ts +0 -191
  213. package/headless.ts +0 -369
  214. package/http.ts +0 -2110
  215. package/identity.ts +0 -246
  216. package/ids.ts +0 -26
  217. package/index.ts +0 -369
  218. package/llm.ts +0 -2682
  219. package/mcp.ts +0 -1835
  220. package/models.ts +0 -3805
  221. package/modes.ts +0 -43
  222. package/net.ts +0 -1214
  223. package/neutral.ts +0 -362
  224. package/node.ts +0 -26
  225. package/oauth.ts +0 -2216
  226. package/offscreen.ts +0 -170
  227. package/pack.ts +0 -956
  228. package/page.ts +0 -7824
  229. package/pagebridge.ts +0 -1116
  230. package/perf.ts +0 -957
  231. package/plan.ts +0 -672
  232. package/plugin.ts +0 -76
  233. package/prisma.config.ts +0 -27
  234. package/progress.ts +0 -1308
  235. package/project.ts +0 -1291
  236. package/protocol.ts +0 -4187
  237. package/providers.ts +0 -246
  238. package/quota.ts +0 -1887
  239. package/recovery.ts +0 -2433
  240. package/request.ts +0 -4482
  241. package/run.ts +0 -2135
  242. package/runtime.ts +0 -526
  243. package/search.ts +0 -1760
  244. package/security.ts +0 -1673
  245. package/serve.ts +0 -419
  246. package/server.ts +0 -5538
  247. package/session.ts +0 -1162
  248. package/storage.ts +0 -182
  249. package/streaming.ts +0 -4101
  250. package/swarm.ts +0 -884
  251. package/sync.ts +0 -56
  252. package/tests/agentcert.test.ts +0 -128
  253. package/tests/agentfleet.test.ts +0 -214
  254. package/tests/agentreview.test.ts +0 -241
  255. package/tests/agentstream.test.ts +0 -335
  256. package/tests/agentwork.test.ts +0 -356
  257. package/tests/apifreeze.test.ts +0 -290
  258. package/tests/apimap.test.ts +0 -112
  259. package/tests/approvalgate.test.ts +0 -175
  260. package/tests/artifactmanifest.test.ts +0 -204
  261. package/tests/attentionfeed.test.ts +0 -163
  262. package/tests/backgroundruns.test.ts +0 -100
  263. package/tests/batchscheduling.test.ts +0 -131
  264. package/tests/blackboard.test.ts +0 -238
  265. package/tests/bridge.test.ts +0 -1088
  266. package/tests/browsercoverage.test.ts +0 -134
  267. package/tests/browserpolyfills.test.ts +0 -124
  268. package/tests/build.mjs +0 -1260
  269. package/tests/clientauth.test.ts +0 -223
  270. package/tests/clitools.test.ts +0 -578
  271. package/tests/confirmgates.test.ts +0 -190
  272. package/tests/containerpack.test.ts +0 -143
  273. package/tests/controlflow.test.ts +0 -2120
  274. package/tests/coordination.test.ts +0 -345
  275. package/tests/copyscreen.test.ts +0 -139
  276. package/tests/core.test.ts +0 -417
  277. package/tests/costcert.test.ts +0 -95
  278. package/tests/crossbrowser.test.ts +0 -115
  279. package/tests/cspaudit.test.ts +0 -79
  280. package/tests/dashdone.test.ts +0 -615
  281. package/tests/datagrid.test.ts +0 -137
  282. package/tests/doccheck.test.ts +0 -107
  283. package/tests/dombatch.test.ts +0 -109
  284. package/tests/emulation.test.ts +0 -282
  285. package/tests/environments.test.ts +0 -259
  286. package/tests/evidenceviews.test.ts +0 -88
  287. package/tests/exporttools.test.ts +0 -185
  288. package/tests/firefoxprep.test.ts +0 -134
  289. package/tests/flowlibrary.test.ts +0 -242
  290. package/tests/flowrun.test.ts +0 -303
  291. package/tests/forensics.test.ts +0 -439
  292. package/tests/gateway.test.ts +0 -939
  293. package/tests/headlesslib.test.ts +0 -171
  294. package/tests/httpstream.test.ts +0 -277
  295. package/tests/immutablelog.test.ts +0 -157
  296. package/tests/inboundguard.test.ts +0 -177
  297. package/tests/lazyload.test.ts +0 -72
  298. package/tests/librarymodes.test.ts +0 -623
  299. package/tests/llm.test.ts +0 -696
  300. package/tests/manifest.test.ts +0 -226
  301. package/tests/maskinputs.test.ts +0 -150
  302. package/tests/matrixverify.test.ts +0 -111
  303. package/tests/mavenpack.test.ts +0 -75
  304. package/tests/mcpserver.test.ts +0 -704
  305. package/tests/memory.test.ts +0 -4155
  306. package/tests/memorycare.test.ts +0 -230
  307. package/tests/migrateplan.test.ts +0 -349
  308. package/tests/minimization.test.ts +0 -414
  309. package/tests/modelroute.test.ts +0 -112
  310. package/tests/multiagent.test.ts +0 -440
  311. package/tests/nativebridge.test.ts +0 -807
  312. package/tests/navigation.test.ts +0 -284
  313. package/tests/nugetpack.test.ts +0 -83
  314. package/tests/orchestration.test.ts +0 -449
  315. package/tests/originpolicy.test.ts +0 -405
  316. package/tests/outputcompare.test.ts +0 -97
  317. package/tests/package.test.ts +0 -91
  318. package/tests/pagebridge.test.ts +0 -5909
  319. package/tests/pentest.test.ts +0 -75
  320. package/tests/perfrecords.test.ts +0 -257
  321. package/tests/permdiff.test.ts +0 -85
  322. package/tests/phishguard.test.ts +0 -128
  323. package/tests/pickerviews.test.ts +0 -155
  324. package/tests/pipelines.test.ts +0 -381
  325. package/tests/planlint.test.ts +0 -240
  326. package/tests/planreview.test.ts +0 -383
  327. package/tests/platformtargets.test.ts +0 -56
  328. package/tests/policy.test.ts +0 -8284
  329. package/tests/portability.test.ts +0 -96
  330. package/tests/progress.test.ts +0 -1036
  331. package/tests/promptlibrary.test.ts +0 -116
  332. package/tests/protocol.test.ts +0 -4793
  333. package/tests/publishingpipeline.test.ts +0 -314
  334. package/tests/quickactions.test.ts +0 -164
  335. package/tests/readiness.test.ts +0 -78
  336. package/tests/recipes.test.ts +0 -163
  337. package/tests/redactshots.test.ts +0 -216
  338. package/tests/registernvidiakeys.ts +0 -51
  339. package/tests/relayserve.test.ts +0 -304
  340. package/tests/releasenotes.test.ts +0 -276
  341. package/tests/resilience.test.ts +0 -467
  342. package/tests/resourceaware.test.ts +0 -187
  343. package/tests/runbudget.test.ts +0 -125
  344. package/tests/runhistory.test.ts +0 -299
  345. package/tests/runreplay.test.ts +0 -113
  346. package/tests/runresume.test.ts +0 -184
  347. package/tests/runstate.test.ts +0 -288
  348. package/tests/runtimeadapters.test.ts +0 -251
  349. package/tests/safariskeleton.test.ts +0 -115
  350. package/tests/sandboxframe.test.ts +0 -196
  351. package/tests/sbom.test.ts +0 -105
  352. package/tests/secretvault.test.ts +0 -188
  353. package/tests/selcache.test.ts +0 -111
  354. package/tests/sessioninterface.test.ts +0 -791
  355. package/tests/sessions.test.ts +0 -591
  356. package/tests/siteprefs.test.ts +0 -228
  357. package/tests/snapshotdelta.test.ts +0 -165
  358. package/tests/statusviews.test.ts +0 -237
  359. package/tests/stepmeter.test.ts +0 -200
  360. package/tests/streamparse.test.ts +0 -163
  361. package/tests/stylepruning.test.ts +0 -90
  362. package/tests/surfaces.test.ts +0 -282
  363. package/tests/sweep.test.ts +0 -78
  364. package/tests/syncbridge.test.ts +0 -164
  365. package/tests/taskqueue.test.ts +0 -206
  366. package/tests/toolcalls.test.ts +0 -336
  367. package/tests/toolcatalog.test.ts +0 -201
  368. package/tests/torture-agent.test.ts +0 -706
  369. package/tests/torture-auth.test.ts +0 -461
  370. package/tests/torture-commands.test.ts +0 -895
  371. package/tests/torture-data.test.ts +0 -923
  372. package/tests/torture-environments.test.ts +0 -285
  373. package/tests/torture-export.test.ts +0 -263
  374. package/tests/torture-http.test.ts +0 -1379
  375. package/tests/torture-llm.test.ts +0 -808
  376. package/tests/torture-memory.test.ts +0 -1084
  377. package/tests/torture-plan.test.ts +0 -829
  378. package/tests/torture-run.test.ts +0 -626
  379. package/tests/torture-session.test.ts +0 -928
  380. package/tests/torture-swarm.test.ts +0 -1245
  381. package/tests/torture-tools.test.ts +0 -964
  382. package/tests/torture-workflow.test.ts +0 -2354
  383. package/tests/tourviews.test.ts +0 -52
  384. package/tests/transparency.test.ts +0 -147
  385. package/tests/trigger.test.ts +0 -941
  386. package/tests/v1sunset.test.ts +0 -428
  387. package/tests/virtlist.test.ts +0 -94
  388. package/tests/vision.test.ts +0 -540
  389. package/tests/vsixpack.test.ts +0 -145
  390. package/tests/webapi.test.ts +0 -523
  391. package/tests/workflow.test.ts +0 -1785
  392. package/tests/workfloweditor.test.ts +0 -759
  393. package/tests/xpipack.test.ts +0 -128
  394. package/tools.ts +0 -734
  395. package/types.ts +0 -9908
  396. package/umd.ts +0 -9
  397. package/utils.ts +0 -249
  398. package/version.ts +0 -8
  399. package/versionregistry.ts +0 -1310
  400. package/views.ts +0 -2153
  401. package/vitest.config.ts +0 -12
  402. package/web/App.tsx +0 -78
  403. package/web/README.md +0 -47
  404. package/web/capacitor.config.ts +0 -46
  405. package/web/const.ts +0 -19
  406. package/web/control.shell.tsx +0 -66
  407. package/web/dashboardpage.ts +0 -554
  408. package/web/db.ts +0 -493
  409. package/web/design.html +0 -541
  410. package/web/gatewayview/Gateway.tsx +0 -345
  411. package/web/gatewayview/config.ts +0 -1042
  412. package/web/gatewayview/definition.ts +0 -174
  413. package/web/icons.ts +0 -15
  414. package/web/optionspage.ts +0 -691
  415. package/web/popup.ts +0 -1651
  416. package/web/schema.prisma +0 -176
  417. package/web/sidepanel.ts +0 -7941
  418. package/web/sitemanifest.json +0 -13
  419. package/web/terminal-ui.tsx +0 -622
  420. package/web/transparencypage.ts +0 -541
  421. package/web/vite.config.ts +0 -39
  422. package/web/workspace.ts +0 -23
  423. package/workbenchmemory.ts +0 -104
  424. package/workbenchsession.ts +0 -304
  425. package/workflow.ts +0 -4495
  426. /package/{dist/bun.d.ts → bun.d.ts} +0 -0
  427. /package/{dist/cli.d.ts → cli.d.ts} +0 -0
  428. /package/{dist/companion.d.ts → companion.d.ts} +0 -0
  429. /package/{dist/crossbrowser.d.ts → crossbrowser.d.ts} +0 -0
  430. /package/{dist/dashdone.d.ts → dashdone.d.ts} +0 -0
  431. /package/{dist/deno.d.ts → deno.d.ts} +0 -0
  432. /package/{dist/hardening.d.ts → hardening.d.ts} +0 -0
  433. /package/{dist/headless.d.ts → headless.d.ts} +0 -0
  434. /package/{dist/http.d.ts → http.d.ts} +0 -0
  435. /package/{dist/index.d.ts → index.d.ts} +0 -0
  436. /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
  437. /package/{dist/memory.d.ts → memory.d.ts} +0 -0
  438. /package/{dist/node.d.ts → node.d.ts} +0 -0
  439. /package/{dist/pack.d.ts → pack.d.ts} +0 -0
  440. /package/{dist/policy.d.ts → policy.d.ts} +0 -0
  441. /package/{dist/progress.d.ts → progress.d.ts} +0 -0
  442. /package/{dist/protocol.d.ts → protocol.d.ts} +0 -0
  443. /package/{dist/server.d.ts → server.d.ts} +0 -0
  444. /package/{dist/umd.d.ts → umd.d.ts} +0 -0
@@ -1,623 +0,0 @@
1
- import { afterAll, describe, expect, it } from "vitest";
2
- import { execFile } from "node:child_process";
3
- import { createHash } from "node:crypto";
4
- import { existsSync } from "node:fs";
5
- import { access, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
6
- import { tmpdir } from "node:os";
7
- import { dirname, join, resolve } from "node:path";
8
- import { createRequire } from "node:module";
9
- import { promisify } from "node:util";
10
- import { build } from "esbuild";
11
- import { stripstrings, underscorednames } from "./bundlescan.mjs";
12
- import { umdwrap } from "./umdwrap.mjs";
13
- import { matrixverify, matrixtargetof, platformtargets, targetoutput } from "../runtime.js";
14
- import { clicommands, surfacepalette } from "../views.js";
15
- import {
16
- browserplatformadapter,
17
- defaultclock,
18
- denoplatformadapter,
19
- detectadapterruntime,
20
- loggeradapterof,
21
- nodeplatformadapter,
22
- platformadapterof,
23
- setsharedadapter,
24
- sharedadapter,
25
- } from "../runtime.js";
26
- import { denoconfigread } from "../deno.js";
27
- import { memorystorageadapter } from "../runtime.js";
28
- import { sessionmemory } from "../memory.js";
29
- import { progressnow, recordoutcomewithclock } from "../progress.js";
30
- import { parseheadlessfixture, resolvefixture } from "../cli.js";
31
- import * as policymodule from "../policy.js";
32
- import * as protocolmodule from "../protocol.js";
33
- import * as memorymodule from "../memory.js";
34
- import * as progressmodule from "../progress.js";
35
- import type { stepoutcome } from "../types.js";
36
-
37
- const execute = promisify(execFile);
38
- const require = createRequire(import.meta.url);
39
- const outbase = await mkdtemp(join(tmpdir(), "devthink-library-"));
40
-
41
- /** Resolves the repo-local tsc binary the declaration pass rides: the merged repo carries typescript as its own devdependency, so the emission needs no package-manager exec indirection (pnpm exec retired with the merge — the same resolution tests/build.mjs uses). */
42
- function resolvetsc(): string {
43
- const self = require.resolve("typescript/package.json");
44
- return join(dirname(self), "bin", "tsc");
45
- }
46
-
47
- /** Builds one entry of the matrix into the temp directory with the format and platform its target declares; the umd format wraps its cjs core in the umd envelope the build ships. */
48
- async function buildtarget(
49
- entry: string,
50
- format: "esm" | "cjs" | "umd",
51
- platform: "browser" | "node" | "neutral",
52
- output: string,
53
- ): Promise<string> {
54
- if (format === "umd") {
55
- const core = output.replace(/\.js$/, ".core.cjs");
56
- await build({
57
- entryPoints: [entry],
58
- outfile: core,
59
- bundle: true,
60
- format: "cjs",
61
- platform,
62
- target: platform === "browser" ? "chrome120" : "es2022",
63
- sourcemap: false,
64
- });
65
- const body = await readFile(core, "utf8");
66
- await writeFile(output, umdwrap(body, "devthink"), "utf8");
67
- await rm(core, { force: true });
68
- return output;
69
- }
70
- await build({
71
- entryPoints: [entry],
72
- outfile: output,
73
- bundle: true,
74
- format,
75
- platform,
76
- target: platform === "browser" ? "chrome120" : platform === "node" ? "node22" : "es2022",
77
- sourcemap: true,
78
- });
79
- return output;
80
- }
81
-
82
- describe("the library on every runtime", () => {
83
- /* the bundle builds answer the slowest runners and the emulated container legs with the env-scaled ceiling the vitest config reads, because one esbuild pass over the whole matrix legitimately runs past the five second default on a two vcpu runner (the 2.0.10 container leg proved a sixteen millisecond overrun fails a green test) */
84
- it("builds and loads the esm core in node with tree shakable exports", {
85
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 60000),
86
- }, async () => {
87
- const output = await buildtarget("index.ts", "esm", "neutral", join(outbase, "index.mjs"));
88
- const loaded = await import(output);
89
- expect(typeof loaded.surfacepalette).toBe("function");
90
- expect(typeof loaded.portablerulesetof).toBe("function");
91
- expect(loaded.platformtargets()).toHaveLength(4);
92
- const content = await readFile(output, "utf8");
93
- expect(content).toContain("export");
94
- });
95
-
96
- it("builds and loads the cjs core in node for require based consumers", async () => {
97
- const output = await buildtarget("index.ts", "cjs", "node", join(outbase, "index.cjs"));
98
- const loaded = require(output) as Record<string, unknown>;
99
- expect(typeof loaded.surfacepalette).toBe("function");
100
- expect(typeof loaded.runflow).toBe("function");
101
- expect(typeof loaded.exportrecords).toBe("function");
102
- });
103
-
104
- it("builds every platform target of the matrix in one run and loads each bundle", {
105
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 120000),
106
- }, async () => {
107
- const present: string[] = [];
108
- for (const target of platformtargets()) {
109
- const output = await buildtarget(
110
- target.entry,
111
- target.format,
112
- target.platform,
113
- join(outbase, targetoutput(target)),
114
- );
115
- present.push(target.entry);
116
- const content = await readFile(output, "utf8");
117
- expect(content.length).toBeGreaterThan(0);
118
- if (target.format === "esm") {
119
- const loaded = await import(output);
120
- expect(typeof loaded.surfacepalette).toBe("function");
121
- } else {
122
- const loaded = require(output) as Record<string, unknown>;
123
- const expected =
124
- matrixtargetof(platformtargets(), target.runtime).runtime === "node" ? "nodeadapter" : "surfacepalette";
125
- expect(typeof loaded[expected]).toBe("function");
126
- }
127
- }
128
- expect(matrixverify({ targets: platformtargets(), present }).complete).toBe(true);
129
- });
130
-
131
- it("keeps the deno entry free of node shims and loads it as neutral esm", async () => {
132
- const output = await buildtarget("deno.ts", "esm", "neutral", join(outbase, "deno-check.mjs"));
133
- const content = await readFile(output, "utf8");
134
- expect(content).not.toMatch(/from\s*["']node:/);
135
- expect(content).not.toMatch(/require\(\s*["']node:/);
136
- const loaded = await import(output);
137
- expect(typeof loaded.denoadapter).toBe("function");
138
- const deno = await execute("deno", ["--version"]).catch(() => undefined);
139
- if (deno === undefined)
140
- return; /* the deno binary stays optional in the local matrix; the neutral bundle above still proves the entry */
141
- await writeFile(
142
- join(outbase, "deno-entry.test.ts"),
143
- 'import { surfacepalette } from "./deno-check.mjs";\nDeno.test("loads the deno entry", () => { if (surfacepalette().length === 0) throw new Error("The deno entry loaded an empty palette."); });\n',
144
- "utf8",
145
- );
146
- await execute("deno", ["test", "--allow-read", "deno-entry.test.ts"], { cwd: outbase });
147
- });
148
-
149
- it("runs the bun entry under bun test", async () => {
150
- const bunversion = await execute("bun", ["--version"]).catch(() => undefined);
151
- if (bunversion === undefined) return; /* the bun binary stays optional in the local matrix */
152
- const output = await buildtarget("bun.ts", "esm", "node", join(outbase, "bun-entry.mjs"));
153
- await writeFile(
154
- join(outbase, "bun-entry.test.ts"),
155
- `import { expect, test } from "bun:test";\nimport * as library from "${output}";\ntest("loads the bun entry", () => { expect(typeof library.bunadapter).toBe("function"); expect(typeof library.surfacepalette).toBe("function"); });\n`,
156
- "utf8",
157
- );
158
- const result = await execute("bun", ["test", join(outbase, "bun-entry.test.ts")]);
159
- expect(`${result.stdout}${result.stderr}`).toContain("1 pass");
160
- });
161
-
162
- it("emits declaration files for every entry point of the matrix", async () => {
163
- const outdir = await mkdtemp(join(tmpdir(), "devthink-types-"));
164
- await execute(resolvetsc(), ["-p", "tsconfig.build.json", "--outDir", outdir]);
165
- for (const entry of [
166
- "index",
167
- "umd",
168
- "node",
169
- "bun",
170
- "deno",
171
- "plan",
172
- "flow",
173
- "export",
174
- "headless",
175
- "cli",
176
- "agent",
177
- "auth",
178
- "http",
179
- "server",
180
- "page",
181
- "memory",
182
- "mcp",
183
- "runtime",
184
- ]) {
185
- const declaration = await readFile(join(outdir, `${entry}.d.ts`), "utf8");
186
- expect(declaration.length).toBeGreaterThan(0);
187
- }
188
- await rm(outdir, { recursive: true, force: true });
189
- }, 120_000);
190
-
191
- it("shares the command registry between the cli and the commandpalette definitions", () => {
192
- const palette = surfacepalette();
193
- const registry = clicommands(palette);
194
- const terminal = registry.filter((command) => command.terminal);
195
- const shared = registry.filter((command) => !command.terminal);
196
- expect(terminal.map((command) => command.id)).toEqual([
197
- "manifest",
198
- "describe",
199
- "commands",
200
- "planlint",
201
- "migrateplan",
202
- "recipes",
203
- "flowrun",
204
- "runworkflow",
205
- "exportdata",
206
- "headless",
207
- "serve",
208
- "native",
209
- "export",
210
- "init",
211
- "doctor",
212
- "help",
213
- ]);
214
- expect(shared).toHaveLength(palette.length);
215
- for (const entry of palette) {
216
- const command = shared.find((item) => item.id === entry.id);
217
- expect(command?.label).toBe(entry.label);
218
- expect(command?.keywords).toEqual(entry.keywords);
219
- }
220
- });
221
- });
222
-
223
- /** Builds one consumption mode bundle once for the whole mode suite: the cached build lets every mode test read one bundle instead of rebuilding per assertion. */
224
- const modecache = new Map<string, Promise<string>>();
225
- async function modebundle(key: string, buildit: () => Promise<string>): Promise<string> {
226
- const cached = modecache.get(key);
227
- if (cached !== undefined) return cached;
228
- const built = buildit();
229
- modecache.set(key, built);
230
- return built;
231
- }
232
-
233
- /** Reads the sorted export names of one mode bundle: an esm or neutral bundle answers through import and a cjs bundle answers through require. */
234
- async function modekeys(output: string): Promise<string[]> {
235
- if (output.endsWith(".cjs")) return Object.keys(require(output) as Record<string, unknown>).sort();
236
- return Object.keys(await import(output)).sort();
237
- }
238
-
239
- /** Runs one umd bundle source against a sandbox global and answers the sandbox, so the global surface and the deprecation shim verify without a browser. */
240
- function umdglobal(source: string): Record<string, unknown> {
241
- const sandbox: Record<string, unknown> = {};
242
- sandbox.self = sandbox;
243
- new Function("self", source)(sandbox);
244
- return sandbox;
245
- }
246
-
247
- describe("the library modes of 1.1.81", () => {
248
- it("freezes the public api surface across the esm, cjs and umd modes", {
249
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 120000),
250
- }, async () => {
251
- const esm = await modekeys(
252
- await modebundle("esm", () => buildtarget("index.ts", "esm", "neutral", join(outbase, "mode-index.mjs"))),
253
- );
254
- const cjs = await modekeys(
255
- await modebundle("cjs", () => buildtarget("cjs.ts", "cjs", "node", join(outbase, "mode-index.cjs"))),
256
- );
257
- expect(cjs).toEqual(esm);
258
- const umdsource = await readFile(
259
- await modebundle("umd", () => buildtarget("umd.ts", "umd", "browser", join(outbase, "mode-devthink.umd.js"))),
260
- "utf8",
261
- );
262
- const globalkeys = Object.keys(umdglobal(umdsource).devthink as Record<string, unknown>).sort();
263
- expect(globalkeys).toEqual(esm);
264
- expect(esm.length).toBeGreaterThan(1000);
265
- const probes: Array<[string, string, Record<string, unknown>]> = [
266
- ["policy", "canexecute", policymodule],
267
- ["protocol", "parseproposal", protocolmodule],
268
- ["memory", "sessionmemory", memorymodule],
269
- ["progress", "recordstep", progressmodule],
270
- ];
271
- for (const [modulename, probe, source] of probes) {
272
- const output = await modebundle(`module-${modulename}`, () =>
273
- buildtarget(`${modulename}.ts`, "esm", "neutral", join(outbase, `mode-${modulename}.mjs`)),
274
- );
275
- const loaded = await import(output);
276
- expect(typeof loaded[probe]).toBe("function");
277
- expect(Object.keys(loaded).sort()).toEqual(Object.keys(source).sort());
278
- expect(Object.keys(loaded).length).toBeGreaterThan(1);
279
- }
280
- });
281
-
282
- it("keeps the shared adapter registry consistent across the esm and cjs modes of one process", {
283
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 60000),
284
- }, async () => {
285
- const esm = await import(
286
- await modebundle("esm", () => buildtarget("index.ts", "esm", "neutral", join(outbase, "mode-index.mjs")))
287
- );
288
- const cjs = require(
289
- await modebundle("cjs", () => buildtarget("cjs.ts", "cjs", "node", join(outbase, "mode-index.cjs"))),
290
- ) as typeof esm;
291
- expect(esm.bundlestamp().mode).toBe("esm");
292
- expect(cjs.bundlestamp().mode).toBe("cjs");
293
- expect(cjs.bundlestamp().version).toBe(esm.bundlestamp().version);
294
- expect(cjs.bundlestamp().target).toBe("index.cjs");
295
- esm.setsharedadapter(esm.platformadapterof({ runtime: "node", storage: esm.memorystorageadapter() }));
296
- const throughcjs = cjs.sharedadapter();
297
- expect(throughcjs?.runtime).toBe("node");
298
- expect(throughcjs?.mode).toBe("cjs");
299
- await throughcjs?.storage.set("sharedstate", { written: "esm" });
300
- expect(await esm.sharedadapter()?.storage.get("sharedstate")).toEqual({ written: "esm" });
301
- expect(await cjs.sharedadapter()?.storage.get("sharedstate")).toEqual({ written: "esm" });
302
- });
303
-
304
- it("exposes the window.devthink global with the consent gates intact and the sunset removed the deprecated uppercase shim", {
305
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 60000),
306
- }, async () => {
307
- const umdsource = await readFile(
308
- await modebundle("umd", () => buildtarget("umd.ts", "umd", "browser", join(outbase, "mode-devthink.umd.js"))),
309
- "utf8",
310
- );
311
- const notices: string[] = [];
312
- const originalwarn = console.warn;
313
- console.warn = ((line: string) => {
314
- notices.push(line);
315
- }) as typeof console.warn;
316
- try {
317
- const sandbox = umdglobal(umdsource);
318
- const globalobject = sandbox.devthink as Record<string, unknown>;
319
- expect(typeof globalobject.surfacepalette).toBe("function");
320
- expect(typeof globalobject.canexecute).toBe("function");
321
- expect(typeof globalobject.planlint).toBe("function");
322
- expect(typeof globalobject.cookiegate).toBe("function");
323
- expect(typeof globalobject.openheadlesssession).toBe("function");
324
- expect((globalobject.bundlestamp as () => { mode: string })().mode).toBe("umd");
325
- expect(sandbox.devthink).toBe(globalobject);
326
- /* the 2.0.0 sunset removed the deprecated uppercase global the deprecation window carried: the envelope declares the lowercase surface only and no deprecation notice fires anywhere */
327
- expect((sandbox as Record<string, unknown>).Devthink).toBeUndefined();
328
- expect(notices).toHaveLength(0);
329
- } finally {
330
- console.warn = originalwarn;
331
- }
332
- });
333
-
334
- it("covers the node, browser and deno default adapters behind the platform seam", async () => {
335
- const files = new Map<string, string>();
336
- const node = nodeplatformadapter({
337
- profiledir: "profiles",
338
- fs: {
339
- readfile: async (path) => {
340
- if (!files.has(path)) throw new Error(`No file at ${path}.`);
341
- return files.get(path) as string;
342
- },
343
- writefile: async (path, data) => {
344
- files.set(path, data);
345
- },
346
- mkdir: async () => undefined,
347
- join: (...parts) => parts.join("/"),
348
- },
349
- });
350
- expect(node.mode).toBe("cjs");
351
- expect(node.declaration.storage).toBe("filesystem");
352
- expect(node.probes.dom).toBe(false);
353
- await node.storage.set("plan", { goal: "read" });
354
- expect(await node.storage.get<{ goal: string }>("plan")).toEqual({ goal: "read" });
355
-
356
- const area = new Map<string, unknown>();
357
- const browser = browserplatformadapter({
358
- area: {
359
- get: async (key) => area.get(key),
360
- set: async (key, value) => {
361
- area.set(key, value);
362
- },
363
- },
364
- });
365
- expect(browser.mode).toBe("umd");
366
- expect(browser.declaration.storage).toBe("chrome");
367
- expect(browser.probes.dom).toBe(true);
368
- await browser.storage.set("session", { state: "active" });
369
- expect(area.get("session")).toEqual({ state: "active" });
370
- const fallback = browserplatformadapter();
371
- await fallback.storage.set("key", "value");
372
- expect(await fallback.storage.get("key")).toBe("value");
373
-
374
- const kv = new Map<string, unknown>();
375
- const deno = denoplatformadapter({
376
- kv: {
377
- get: async (key: string) => kv.get(key),
378
- set: async (key: string, value: unknown) => {
379
- kv.set(key, value);
380
- },
381
- } as never,
382
- });
383
- expect(deno.declaration.storage).toBe("denokv");
384
- await deno.storage.set("kv", 1);
385
- expect(kv.get("kv")).toBe(1);
386
-
387
- expect(typeof defaultclock().now()).toBe("number");
388
- const lines: string[] = [];
389
- const sink = loggeradapterof({
390
- log: (line) => lines.push(`log:${line}`),
391
- warn: (line) => lines.push(`warn:${line}`),
392
- error: (line) => lines.push(`error:${line}`),
393
- });
394
- sink.log("a");
395
- sink.warn("b");
396
- sink.error("c");
397
- expect(lines).toEqual(["log:a", "warn:b", "error:c"]);
398
- expect(detectadapterruntime()).toBe("node");
399
-
400
- const memory = new sessionmemory(memorystorageadapter());
401
- await memory.setplan({} as never);
402
- expect(await memory.getplan()).toEqual({});
403
- const clock = { now: () => 1_000, schedule: () => 0 };
404
- expect(progressnow(clock)).toBe(1_000);
405
- const outcome: stepoutcome = { stepid: "observe", ok: true, summary: "observed", at: 1_000 } as stepoutcome;
406
- const stepped = recordoutcomewithclock(undefined, "plan", outcome, clock);
407
- expect(stepped.updatedat).toBe(1_000);
408
- expect(stepped.outcomes).toHaveLength(1);
409
-
410
- const fixturefile = JSON.parse(await readFile("tests/code/example-org-pagestate.json", "utf8")) as unknown;
411
- const fixture = parseheadlessfixture(fixturefile);
412
- expect(resolvefixture([fixture], fixture.origin)).toBe(fixture);
413
- if (!existsSync("deno.json"))
414
- return; /* the deno runtime config rides the deno lane of the matrix: the adapter seam above proves the deno platform adapter without it, and the exports pass below carries the config contract once the deno.json restoration lands */
415
- const config = await denoconfigread(async () => await readFile("deno.json", "utf8"));
416
- expect(config.imports).toBeDefined();
417
- expect(config.tasks).toBeDefined();
418
- });
419
-
420
- it("resolves every exports condition, selects the neutral target under the browser condition and keeps the engines in sync", async () => {
421
- const packagejson = JSON.parse(await readFile("package.json", "utf8")) as {
422
- version: string;
423
- sideEffects?: boolean;
424
- publishConfig?: { registry?: string };
425
- engines: Record<string, string>;
426
- exports: Record<string, Record<string, string>>;
427
- };
428
- const root = packagejson.exports["."];
429
- if (root === undefined) throw new Error("The package exports map carries no root entry.");
430
- expect(Object.keys(root)).toEqual(["types", "browser", "import", "require", "default"]);
431
- expect(root.browser).toBe("./dist/index.neutral.js");
432
- expect(root.import).toBe("./dist/index.js");
433
- expect(root.require).toBe("./dist/index.cjs");
434
- for (const entry of [
435
- "./policy",
436
- "./protocol",
437
- "./memory",
438
- "./progress",
439
- "./cli",
440
- "./umd",
441
- "./node",
442
- "./bun",
443
- "./deno",
444
- "./headless",
445
- ]) {
446
- if (packagejson.exports[entry] === undefined)
447
- throw new Error(`The package exports map lacks the ${entry} entry.`);
448
- }
449
- expect(packagejson.exports["./umd"]?.default).toBe("./dist/devthink.umd.js");
450
- expect(packagejson.exports["./policy"]?.import).toBe("./dist/policy.js");
451
- expect(packagejson.exports["./progress"]?.import).toBe("./dist/progress.js");
452
- expect(packagejson.exports["./cli"]?.import).toBe("./dist/cli.js");
453
- expect(packagejson.sideEffects).toBe(false);
454
- expect(packagejson.publishConfig?.registry).toBe("https://registry.npmjs.org/");
455
- const nvmversion = (await readFile(".nvmrc", "utf8")).trim();
456
- expect(packagejson.engines.node).toContain(nvmversion);
457
- const verifyworkflow = await readFile(".github/workflows/verify.yml", "utf8");
458
- const bunminimum = (packagejson.engines.bun ?? "").match(/>=([\d.]+)/)?.[1];
459
- expect(verifyworkflow).toContain(`bun-version: ${bunminimum}`);
460
- expect(verifyworkflow).toContain("denoland/setup-deno");
461
- const denojson = JSON.parse(await readFile("deno.json", "utf8")) as {
462
- imports: Record<string, string>;
463
- tasks: Record<string, string>;
464
- };
465
- expect(denojson.imports["@wenathlan/devthink"]).toBe(`npm:@wenathlan/devthink@${packagejson.version}`);
466
- expect(denojson.tasks.check).toContain("dist/deno.js");
467
- if (!existsSync("dist/checksums.txt"))
468
- return; /* the validate chain runs the tests before the build; the file existence pass runs on the next pass and in the ci lanes that build first */
469
- const referenced = new Set<string>();
470
- for (const entry of Object.values(packagejson.exports))
471
- for (const target of Object.values(entry)) referenced.add(target.replace(/^\.\//, ""));
472
- for (const file of referenced) await access(join(process.cwd(), file));
473
- });
474
-
475
- it("stamps the version, the mode and the license banner into every built bundle", {
476
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 60000),
477
- }, async () => {
478
- if (!existsSync("dist/checksums.txt"))
479
- return; /* the validate chain runs the tests before the build; the stamp pass runs on the next pass and in the ci lanes that build first */
480
- const packagejson = JSON.parse(await readFile("package.json", "utf8")) as { version: string };
481
- const checksums = (await readFile("dist/checksums.txt", "utf8")).trim().split("\n");
482
- expect(checksums.length).toBeGreaterThan(20);
483
- for (const line of checksums) {
484
- const file = line.slice(66);
485
- if (file === "manifest.json key")
486
- continue; /* the identity record of the published key pins the manifest identity digest beside the bundle checksums, so the pin rides the generated artifact and no license banner applies */
487
- if (file === "gallery.json")
488
- continue; /* the example gallery index ships as data the recipes runner reads: the checksum and the artifact manifest cover it, no license banner rides a data file */
489
- if (file.startsWith("site/"))
490
- continue; /* the static site assets carry their own manifest, not the library banner */
491
- if (file.endsWith(".zip"))
492
- continue; /* the zipped declaration bundle of the publishing pipeline is an assembled binary artifact: its checksum and manifest entry carry it, no text banner rides a zip */
493
- if (file.startsWith("caps/") || file.startsWith("schemas/") || file.startsWith("fixtures/"))
494
- continue; /* the contract data artifacts the 1.1.98 consolidation emits for the packages carry the frozen lists and the example set: the checksum, the artifact manifest and the freeze gate cover them, no license banner rides a data file */
495
- const content = await readFile(join("dist", file), "utf8");
496
- expect(content).toContain(`devthink ${packagejson.version}`);
497
- expect(content).toContain("GPL-3.0-only");
498
- }
499
- const esm = await import(resolve("dist/index.js"));
500
- const cjs = require(resolve("dist/index.cjs")) as Record<string, () => { version: string; mode: string }>;
501
- const neutral = await import(resolve("dist/index.neutral.js"));
502
- expect(esm.bundlestamp().version).toBe(packagejson.version);
503
- expect(esm.bundlestamp().mode).toBe("esm");
504
- expect(cjs.bundlestamp!().version).toBe(packagejson.version);
505
- expect(cjs.bundlestamp!().mode).toBe("cjs");
506
- expect(neutral.bundlestamp().mode).toBe("neutral");
507
- expect(neutral.bundlestamp().version).toBe(packagejson.version);
508
- const umdsource = await readFile("dist/devthink.umd.js", "utf8");
509
- const sandbox = umdglobal(umdsource);
510
- expect((sandbox.devthink as Record<string, () => { version: string }>).bundlestamp!().version).toBe(
511
- packagejson.version,
512
- );
513
- });
514
-
515
- it("verifies the checksums, the sourcemaps and the minified parity of every dist target", {
516
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 60000),
517
- }, async () => {
518
- if (!existsSync("dist/checksums.txt"))
519
- return; /* the validate chain runs the tests before the build; the artifact pass runs on the next pass and in the ci lanes that build first */
520
- const packagejson = JSON.parse(await readFile("package.json", "utf8")) as { version: string };
521
- const checksums = (await readFile("dist/checksums.txt", "utf8")).trim().split("\n");
522
- for (const line of checksums) {
523
- const digest = line.slice(0, 64);
524
- const file = line.slice(66);
525
- if (file === "manifest.json key") {
526
- /* the identity record of the published key: the build writes the manifest key digest beside the bundle checksums so the pin rides the generated artifact, never a hard coded source constant */
527
- const manifestsource = JSON.parse(await readFile("web/manifest.json", "utf8")) as { key: string };
528
- expect(createHash("sha256").update(Buffer.from(manifestsource.key, "base64")).digest("hex")).toBe(digest);
529
- continue;
530
- }
531
- expect(
532
- createHash("sha256")
533
- .update(await readFile(join("dist", file)))
534
- .digest("hex"),
535
- ).toBe(digest);
536
- if (file.startsWith("site/")) continue; /* the static site assets carry no sourcemaps or minified pairs */
537
- if (file.startsWith("caps/") || file.startsWith("schemas/") || file.startsWith("fixtures/"))
538
- continue; /* the contract data artifacts ship as data for the packages, not as built bundles: no sourcemap and no minified pair */
539
- if (!file.endsWith(".js") && !file.endsWith(".cjs"))
540
- continue; /* the json template of the native bridge carries the banner and the checksum without a minified pair, because a manifest template is data the installer stamps, not a runnable bundle */
541
- const map = JSON.parse(await readFile(join("dist", `${file}.map`), "utf8")) as {
542
- version: number;
543
- sources: string[];
544
- };
545
- expect(map.version).toBe(3);
546
- expect(map.sources.length).toBeGreaterThan(0);
547
- if (file.includes(".min.")) continue; /* the minified variant is itself the pair of its unminified bundle */
548
- const minified = file.replace(/\.js$/, ".min.js").replace(/\.cjs$/, ".min.cjs");
549
- await access(join("dist", minified));
550
- expect((await stat(join("dist", minified))).size).toBeLessThan((await stat(join("dist", file))).size);
551
- }
552
- const minifiedesm = await import(resolve("dist/index.min.js"));
553
- expect(typeof minifiedesm.surfacepalette).toBe("function");
554
- expect(minifiedesm.bundlestamp().version).toBe(packagejson.version);
555
- const minifiedcjs = require(resolve("dist/index.min.cjs")) as Record<string, unknown>;
556
- expect(typeof minifiedcjs.surfacepalette).toBe("function");
557
- const headless = await import(resolve("dist/headless.js"));
558
- expect(headless.bundlestamp().mode).toBe("headless");
559
- });
560
-
561
- it("keeps the policy and protocol modules free of platform imports and the browser bundles free of node imports", async () => {
562
- for (const module of ["policy.ts", "protocol.ts", "progress.ts", "runtime.ts", "memory.ts"]) {
563
- const source = await readFile(module, "utf8");
564
- expect(source).not.toMatch(/from\s*["']node:/);
565
- expect(source).not.toMatch(/require\(/);
566
- expect(source).not.toMatch(/import\(\s*["']node:/);
567
- }
568
- if (!existsSync("dist/checksums.txt"))
569
- return; /* the source purity holds on every pass; the bundle purity pass runs on the built dist */
570
- for (const file of [
571
- "index.neutral.js",
572
- "index.neutral.min.js",
573
- "devthink.umd.js",
574
- "devthink.umd.min.js",
575
- "policy.js",
576
- "protocol.js",
577
- "progress.js",
578
- "memory.js",
579
- ]) {
580
- const content = await readFile(join("dist", file), "utf8");
581
- expect(content).not.toMatch(/(?:from\s*|require\(\s*)["']node:/);
582
- }
583
- for (const file of [
584
- "index.js",
585
- "index.cjs",
586
- "index.neutral.js",
587
- "devthink.umd.js",
588
- "policy.js",
589
- "protocol.js",
590
- "memory.js",
591
- "progress.js",
592
- "headless.js",
593
- "cli.js",
594
- ]) {
595
- const stripped = stripstrings(await readFile(join("dist", file), "utf8"));
596
- expect(underscorednames(stripped)).toHaveLength(0);
597
- }
598
- }, 480_000);
599
-
600
- it("loads the headless entry under the esm and cjs modes without browser globals", {
601
- timeout: Number(process.env.DEVTHINK_TEST_TIMEOUT_MS ?? 120000),
602
- }, async () => {
603
- const esm = await import(
604
- await modebundle("headless-esm", () =>
605
- buildtarget("headless.ts", "esm", "node", join(outbase, "mode-headless.mjs")),
606
- )
607
- );
608
- expect(typeof esm.openlibraryrun).toBe("function");
609
- expect(typeof esm.openheadlesssession).toBe("function");
610
- expect(esm.bundlestamp().mode).toBe("headless");
611
- const cjs = require(
612
- await modebundle("headless-cjs", () =>
613
- buildtarget("headless.ts", "cjs", "node", join(outbase, "mode-headless.cjs")),
614
- ),
615
- ) as Record<string, unknown>;
616
- expect(typeof cjs.openlibraryrun).toBe("function");
617
- expect(typeof cjs.openheadlesssession).toBe("function");
618
- });
619
- });
620
-
621
- afterAll(async () => {
622
- await rm(outbase, { recursive: true, force: true });
623
- }, 120_000);