@wenathlan/devthink 2.0.14 → 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 +60 -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,230 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- attachprovenance,
4
- auditexportof,
5
- bytesreclaimed,
6
- cleanupbatch,
7
- derivekey,
8
- decryptvalue,
9
- encryptvalue,
10
- expireditems,
11
- expiryof,
12
- exportchunks,
13
- exportready,
14
- issensitiveclass,
15
- matchingrule,
16
- memoryitemof,
17
- migrateitem,
18
- purgeitems,
19
- provenanceof,
20
- quotareportof,
21
- rankedcandidates,
22
- stepsummaryfor,
23
- } from "../memory.js";
24
- import {
25
- auditexportgate,
26
- encryptionsecretgate,
27
- encryptmemorygate,
28
- expirygate,
29
- exportprovenancegate,
30
- quotacleanupgate,
31
- } from "../policy.js";
32
- import { auditexportreport } from "../protocol.js";
33
- import { sessionmemory } from "../memory.js";
34
- import type { purgeoutcome } from "../memory.js";
35
- import type { expiryrule, memoryitem, toolstep } from "../types.js";
36
-
37
- const now = 1_800_000_000_000;
38
- const origin = "https://example.com";
39
- const steps: toolstep[] = [
40
- { id: "s1", kind: "click", target: "#submit", summary: "Click the reviewed submit control.", risk: "sensitive" },
41
- { id: "s2", kind: "observe", summary: "Read the page.", risk: "read" },
42
- ];
43
-
44
- function itemof(key: string, memoryclass?: string, capturedat = now, expiresat?: number): memoryitem {
45
- return memoryitemof({
46
- key,
47
- value: { text: `value of ${key}` },
48
- provenance: provenanceof({ origin, runid: "run1", stepid: "s1", now: capturedat }),
49
- ...(memoryclass !== undefined ? { memoryclass } : {}),
50
- ...(expiresat !== undefined ? { expiresat } : {}),
51
- });
52
- }
53
-
54
- class fakeadapter {
55
- private readonly data = new Map<string, unknown>();
56
- async get<T>(key: string): Promise<T | undefined> {
57
- return this.data.get(key) as T | undefined;
58
- }
59
- async set<T>(key: string, value: T): Promise<void> {
60
- this.data.set(key, value);
61
- }
62
- }
63
-
64
- describe("provenance", () => {
65
- it("attaches a provenance record to every stored memory item and resolves its originating step summary", () => {
66
- const provenance = provenanceof({ origin, runid: "run1", stepid: "s1", now });
67
- expect(provenance).toEqual({ origin, runid: "run1", stepid: "s1", capturedat: now });
68
- expect(() => provenanceof({ origin: " ", runid: "run1", stepid: "s1", now })).toThrow(/origin/i);
69
- expect(() => provenanceof({ origin, runid: " ", stepid: "s1", now })).toThrow(/run id/i);
70
- expect(() => provenanceof({ origin, runid: "run1", stepid: " ", now })).toThrow(/step id/i);
71
- const item = itemof("note:1", "general");
72
- expect(item.provenance).toEqual(provenance);
73
- expect(() => memoryitemof({ key: " ", value: 1, provenance })).toThrow(/key/i);
74
- expect(attachprovenance(item, provenance).provenance).toEqual(provenance);
75
- expect(stepsummaryfor(item, steps)).toBe("Click the reviewed submit control.");
76
- const unknown = { ...item, provenance: { ...provenance, stepid: "sX" } };
77
- expect(stepsummaryfor(unknown, steps)).toMatch(/no longer carries/i);
78
- expect(issensitiveclass("credential")).toBe(true);
79
- expect(issensitiveclass("general")).toBe(false);
80
- expect(issensitiveclass(undefined)).toBe(false);
81
- expect(exportready([item]).ready).toBe(true);
82
- expect(exportready([{ ...item, provenance: { ...provenance, stepid: " " } }]).ready).toBe(false);
83
- expect(exportprovenancegate({ items: [item] }).allowed).toBe(true);
84
- expect(exportprovenancegate({ items: [{ ...item, provenance: { ...provenance, stepid: " " } }] }).allowed).toBe(
85
- false,
86
- );
87
- });
88
- });
89
-
90
- describe("expirememory", () => {
91
- it("evaluates the user expiryrules, purges behind the confirmation and keeps the summaries for the audit trail", () => {
92
- const rules: expiryrule[] = [
93
- { pattern: "note:", lifetime: 60_000 },
94
- { pattern: "*", lifetime: 600_000 },
95
- ];
96
- const fresh = itemof("note:1", "general", now);
97
- const stale = itemof("note:2", "general", now - 120_000);
98
- expect(matchingrule(rules, "note:1")?.pattern).toBe("note:");
99
- expect(matchingrule(rules, "anything")?.pattern).toBe("*");
100
- expect(matchingrule([], "note:1")).toBeUndefined();
101
- expect(expiryof(fresh, rules)).toBe(now + 60_000);
102
- expect(expiryof({ ...fresh, expiresat: now + 5 }, rules)).toBe(now + 5);
103
- expect(expiryof(fresh, [])).toBeUndefined();
104
- expect(expireditems([fresh, stale], rules, now).map((item) => item.key)).toEqual(["note:2"]);
105
- const unconfirmed = purgeitems({ items: [fresh, stale], rules, confirmed: false, now });
106
- expect(unconfirmed.purged).toHaveLength(0);
107
- expect(unconfirmed.kept).toHaveLength(2);
108
- const gate = expirygate({ confirmed: false, count: 1 });
109
- expect(gate.allowed).toBe(false);
110
- expect(gate.reason).toMatch(/waits behind the explicit confirmation/i);
111
- expect(expirygate({ confirmed: true, count: 1 }).allowed).toBe(true);
112
- expect(expirygate({ confirmed: true, count: 0 }).allowed).toBe(false);
113
- const purged = purgeitems({ items: [fresh, stale], rules, confirmed: true, now });
114
- expect(purged.kept.map((item) => item.key)).toEqual(["note:1"]);
115
- expect(purged.purged.map((entry) => entry.key)).toEqual(["note:2"]);
116
- expect(purged.purged[0]?.summary).toMatch(/purged/i);
117
- expect(purged.purged[0]?.provenance.stepid).toBe("s1");
118
- const outcome: purgeoutcome = purged.purged[0]!;
119
- expect(outcome.at).toBe(now);
120
- });
121
- });
122
-
123
- describe("quotawatch", () => {
124
- it("ranks the cleanup candidates by age and expiry policy, proposes batches behind the per batch approval and reports the reclaimed bytes", () => {
125
- const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
126
- const expired = itemof("note:expired", "general", now - 120_000);
127
- const aged = itemof("cache:1", "capture", now - 500_000);
128
- const young = itemof("cache:2", "capture", now - 1_000);
129
- const plain = itemof("other:1", undefined, now);
130
- const report = quotareportof({ usage: 500, quota: 1_000, items: [expired, aged, young, plain], rules, now });
131
- expect(report.remaining).toBe(500);
132
- expect(report.candidates?.map((candidate) => candidate.key)).toEqual(["note:expired", "cache:1", "cache:2"]);
133
- expect(report.candidates?.[0]?.reason).toMatch(/expired under its user expiryrule/i);
134
- expect(report.candidates?.[1]?.reason).toMatch(/aged past its capture/i);
135
- expect(bytesreclaimed(report.candidates ?? []) > 0).toBe(true);
136
- const batch = cleanupbatch(report.candidates ?? [], 2);
137
- expect(batch).toHaveLength(2);
138
- expect(cleanupbatch(report.candidates ?? [], undefined)).toHaveLength(3);
139
- expect(quotacleanupgate({ approved: false, batch, touchesaudit: false }).allowed).toBe(false);
140
- expect(quotacleanupgate({ approved: true, batch, touchesaudit: false }).allowed).toBe(true);
141
- expect(quotacleanupgate({ approved: true, batch, touchesaudit: true }).allowed).toBe(false);
142
- expect(quotacleanupgate({ approved: true, batch: [], touchesaudit: false }).allowed).toBe(false);
143
- expect(bytesreclaimed(batch)).toBe(batch.reduce((total, candidate) => total + candidate.bytes, 0));
144
- });
145
- });
146
-
147
- describe("encryptrest", () => {
148
- it("derives the key from the user secret through the webcrypto api, roundtrips the value and migrates the predating items lazily", async () => {
149
- const key = await derivekey("user secret", "salt:run1");
150
- const value = { text: "sensitive body", count: 2 };
151
- const envelope = await encryptvalue(key, value);
152
- expect(envelope.iv).not.toBe("");
153
- expect(envelope.payload).not.toContain("sensitive body");
154
- const decrypted = await decryptvalue(key, envelope);
155
- expect(decrypted).toEqual(value);
156
- await expect(decryptvalue(await derivekey("other secret", "salt:run1"), envelope)).rejects.toThrow();
157
- await expect(derivekey("", "salt")).rejects.toThrow(/secret/i);
158
- const item = itemof("vault:1", "credential");
159
- const migrated = await migrateitem({ item, key, enabled: true });
160
- expect(migrated.encrypted).toBe(true);
161
- expect(await migrateitem({ item: migrated, key, enabled: true })).toEqual(migrated);
162
- expect(await migrateitem({ item, key, enabled: false })).toEqual(item);
163
- expect(encryptmemorygate({ memoryclass: "credential", enabled: true, encrypted: false }).allowed).toBe(false);
164
- expect(encryptmemorygate({ memoryclass: "credential", enabled: true, encrypted: true }).allowed).toBe(true);
165
- expect(encryptmemorygate({ memoryclass: "credential", enabled: false, encrypted: false }).allowed).toBe(true);
166
- expect(encryptmemorygate({ memoryclass: "general", enabled: true, encrypted: false }).allowed).toBe(true);
167
- const secretgate = encryptionsecretgate({ secret: "user secret", consented: true });
168
- expect(secretgate.allowed).toBe(true);
169
- expect(encryptionsecretgate({ secret: "", consented: true }).allowed).toBe(false);
170
- expect(encryptionsecretgate({ secret: "user secret", consented: false }).allowed).toBe(false);
171
- });
172
- });
173
-
174
- describe("auditexport", () => {
175
- it("bundles runs, memory, provenance and expiry rules into one record that streams without a size cap behind the explicit user action", () => {
176
- const items = [itemof("note:1", "general"), itemof("vault:1", "credential")];
177
- const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
178
- const record = auditexportof({
179
- runs: [
180
- { runid: "run1", planid: "plan", sessionid: "session", state: "completed", createdat: now, updatedat: now },
181
- ],
182
- items,
183
- rules,
184
- timeline: [{ at: now, runid: "run1", source: "step", summary: "completed" }],
185
- locks: [{ holder: "run1", runid: "run1", sessionid: "session", acquiredat: now, expiresat: now + 1 }],
186
- now,
187
- });
188
- expect(record.memory).toHaveLength(2);
189
- expect(record.expiryrules).toEqual(rules);
190
- const chunks = exportchunks(record, 200);
191
- expect(chunks.length).toBeGreaterThan(1);
192
- expect(chunks.at(-1)?.done).toBe(true);
193
- expect(JSON.parse(chunks.map((chunk) => chunk.payload).join(""))).toEqual(record);
194
- expect(() => exportchunks(record, 0)).toThrow(/chunk size/i);
195
- expect(auditexportgate({ useraction: true }).allowed).toBe(true);
196
- expect(auditexportgate({ useraction: false }).allowed).toBe(false);
197
- const envelope = auditexportreport({ record });
198
- expect(envelope.record.at).toBe(now);
199
- });
200
-
201
- it("persists the memory items, the expiry rules, the quotareport, the encryption flag and the purge summaries through the memory accessors", async () => {
202
- const store = new sessionmemory(new fakeadapter());
203
- await store.setmemoryitem(itemof("note:1", "general"));
204
- await store.setmemoryitem(itemof("note:2", "general", now, now + 60_000));
205
- expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:1", "note:2"]);
206
- await store.setmemoryitem({ ...itemof("note:1", "general"), value: { text: "updated" } });
207
- expect(await store.getmemoryitems()).toHaveLength(2);
208
- await store.removememoryitems(["note:1"]);
209
- expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:2"]);
210
- await store.setexpiry([{ pattern: "note:", lifetime: 60_000 }]);
211
- expect(await store.getexpiry()).toEqual([{ pattern: "note:", lifetime: 60_000 }]);
212
- await store.setquotareport({ usage: 10, quota: 100, remaining: 90 });
213
- expect((await store.getquotareport())?.remaining).toBe(90);
214
- expect(await store.getencryptrest()).toBe(false);
215
- await store.setencryptrest(true);
216
- expect(await store.getencryptrest()).toBe(true);
217
- await store.addpurgesummary({
218
- key: "note:1",
219
- summary: "purged",
220
- provenance: provenanceof({ origin, runid: "run1", stepid: "s1", now }),
221
- at: now,
222
- });
223
- expect((await store.listpurgesummaries()).map((entry) => entry.key)).toEqual(["note:1"]);
224
- await store.setlastexpirepass(now);
225
- expect(await store.getlastexpirepass()).toBe(now);
226
- const exported = await store.getexport(now);
227
- expect(exported.memory).toHaveLength(1);
228
- expect(exported.expiryrules).toHaveLength(1);
229
- });
230
- });
@@ -1,349 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- importautoma,
4
- importselenium,
5
- importtabular,
6
- importuivision,
7
- importv1plan,
8
- migrateplanconversion,
9
- parsecsvrows,
10
- planlintfindings,
11
- } from "../cli.js";
12
- import { lintplanfile, parseplanfile } from "../plan.js";
13
- import { actionkindcatalog, portablerulesetof } from "../policy.js";
14
- import { clicommands, surfacepalette } from "../views.js";
15
- import { packageversion } from "../version.js";
16
- import { readFile } from "node:fs/promises";
17
- import type { planfile, planlintdiagnostic, portableruleset } from "../types.js";
18
-
19
- const now = 1_800_000_000_000;
20
- const ruleset: portableruleset = portablerulesetof(now);
21
- const capabilities = actionkindcatalog();
22
-
23
- /** Reads one importer fixture of the tests/code/importers source set the build copies into dist/fixtures/importers. */
24
- async function fixture(name: string): Promise<string> {
25
- return readFile(`tests/code/importers/${name}`, "utf8");
26
- }
27
-
28
- /** Reads one json importer fixture as the parsed source object its importer reads. */
29
- async function jsonfixture(name: string): Promise<unknown> {
30
- return JSON.parse(await fixture(name));
31
- }
32
-
33
- /** Lints one converted plan through the same lint engine the planlint command runs: the portable rule set, the cli findings and the full action kind capability set. */
34
- function lintconverted(file: planfile): planlintdiagnostic[] {
35
- return [...lintplanfile({ file, ruleset, capabilities, now }), ...planlintfindings({ file, capabilities })];
36
- }
37
-
38
- /** The happy path fixtures of every importer with the format the migrateplan command declares for them. */
39
- const happy: Array<{ name: string; format: string }> = [
40
- { name: "v1-plan.json", format: "v1" },
41
- { name: "automa-workflow.json", format: "automa" },
42
- { name: "selenium-side.json", format: "selenium" },
43
- { name: "uivision-macro.json", format: "uivision" },
44
- { name: "tabular-plan.csv", format: "tabular" },
45
- ];
46
-
47
- /** The refusal fixtures of every importer: each one carries one entry the importer must refuse with the entry named. */
48
- const refusals: Array<{ name: string; format: string; pattern: RegExp }> = [
49
- {
50
- name: "v1-unknown.json",
51
- format: "v1",
52
- pattern: /version one step snap[\s\S]*screenshotpage outside the reviewed catalog/,
53
- },
54
- {
55
- name: "automa-unknown.json",
56
- format: "automa",
57
- pattern: /automa block ping of type notification stays outside the conversion table/,
58
- },
59
- {
60
- name: "selenium-unknown.json",
61
- format: "selenium",
62
- pattern: /selenium command roll of mouseOver stays outside the conversion table/,
63
- },
64
- {
65
- name: "uivision-unknown.json",
66
- format: "uivision",
67
- pattern: /ui vision command xclick-2 of XClick stays outside the conversion table/,
68
- },
69
- {
70
- name: "tabular-unknown.csv",
71
- format: "tabular",
72
- pattern: /tabular row 2[\s\S]*dragdrop outside the reviewed catalog/,
73
- },
74
- ];
75
-
76
- describe("migrateplan importer conversion", () => {
77
- it("converts every happy fixture into a plan file that parses under schemastrict and lints with zero diagnostics", async () => {
78
- for (const source of happy) {
79
- const conversion = migrateplanconversion({ format: source.format, text: await fixture(source.name), now });
80
- expect(conversion.file.version).toBe(packageversion);
81
- expect(conversion.file.origin).toBe("https://example.org");
82
- expect(conversion.file.steps.length).toBeGreaterThan(0);
83
- const parsed = parseplanfile(JSON.parse(JSON.stringify(conversion.file)));
84
- expect(parsed).toEqual(conversion.file);
85
- expect(lintconverted(conversion.file)).toEqual([]);
86
- expect(conversion.format).toBe(source.format);
87
- expect(conversion.mapped).toBe(conversion.file.steps.length);
88
- expect(conversion.notes[0]).toContain(`${source.format} importer converted the source`);
89
- expect(conversion.notes[0]).toContain("the frozen plan file grammar carries no metadata field");
90
- }
91
- });
92
-
93
- it("marks every converted sensitive step with the explicit gate declaration while the read steps carry none", async () => {
94
- const v1 = importv1plan({ source: await jsonfixture("v1-plan.json"), now });
95
- expect(v1.file.steps.map((step) => [step.id, step.kind, step.gate])).toEqual([
96
- ["observe", "observe", undefined],
97
- ["read", "readforms", undefined],
98
- ["inspect", "inspect", undefined],
99
- ["answer", "type", true],
100
- ["pause", "delay", undefined],
101
- ]);
102
- expect(v1.file.grants).toEqual(["observe", "readforms", "inspect", "type", "delay"]);
103
- const lifted = v1.file.steps.find((step) => step.id === "pause");
104
- expect(lifted?.options).toBe('{"delay":3000}');
105
- expect(v1.sourceversion).toBe("1");
106
- expect(v1.notes.some((note) => note.includes("milliseconds field of 1 delay step lifted"))).toBe(true);
107
- });
108
-
109
- it("converts the automa blocks through the documented table and lands the trigger block in the report as the paused trigger", async () => {
110
- const conversion = importautoma({ source: await jsonfixture("automa-workflow.json"), now });
111
- expect(conversion.file.goal).toBe("contact survey sweep");
112
- expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
113
- ["tab", "tabcreate", undefined, "https://example.org/contact", true],
114
- ["survey", "fillform", undefined, undefined, true],
115
- ["send", "click", "button.primary", undefined, true],
116
- ["hold", "delay", undefined, undefined, undefined],
117
- ]);
118
- const fields = JSON.parse(conversion.file.steps.find((step) => step.id === "survey")?.options ?? "{}") as {
119
- fields: Array<Record<string, string>>;
120
- };
121
- expect(fields.fields).toEqual([
122
- { name: "email", value: "survey@example.org", selector: "input[name=email]" },
123
- { name: "message", value: "hello from the sweep", selector: "textarea" },
124
- ]);
125
- expect(JSON.parse(conversion.file.steps.find((step) => step.id === "hold")?.options ?? "{}")).toEqual({
126
- delay: 1500,
127
- });
128
- expect(conversion.notes.some((note) => note.includes("paused trigger"))).toBe(true);
129
- expect(conversion.sourceversion).toBe("1.0.0");
130
- });
131
-
132
- it("resolves the selenium locators, the open target and the pause milliseconds onto the reviewed grammar", async () => {
133
- const conversion = importselenium({ source: await jsonfixture("selenium-side.json"), now });
134
- expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
135
- ["open", "navigate", undefined, "https://example.org/contact", true],
136
- ["email", "type", "input[name=email]", "survey@example.org", true],
137
- ["keys", "appendtext", "input[name=email]", " hello", true],
138
- ["pick", "select", "#topic", "general", true],
139
- ["send", "click", "button.primary", undefined, true],
140
- ["hold", "delay", undefined, undefined, undefined],
141
- ]);
142
- expect(JSON.parse(conversion.file.steps.find((step) => step.id === "hold")?.options ?? "{}")).toEqual({
143
- delay: 2000,
144
- });
145
- expect(conversion.sourceversion).toBe("2.0");
146
- });
147
-
148
- it("converts the ui vision macro with its derived stable step ids and the waittext verification", async () => {
149
- const conversion = importuivision({ source: await jsonfixture("uivision-macro.json"), now });
150
- expect(conversion.file.goal).toBe("example releases read");
151
- expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
152
- ["open-1", "navigate", undefined, "https://example.org/releases", true],
153
- ["click-2", "click", "nav a.releases", undefined, true],
154
- ["type-3", "type", "input[name=filter]", "release notes", true],
155
- ["verifytext-4", "waittext", "main h1", "Releases", undefined],
156
- ]);
157
- });
158
-
159
- it("converts the tabular rows onto the step grammar with the preface metadata and the quoted csv cells", async () => {
160
- const conversion = importtabular({ text: await fixture("tabular-plan.csv"), now });
161
- expect(conversion.file.goal).toBe("Survey the releases page of the example project");
162
- expect(conversion.file.steps.map((step) => [step.id, step.kind, step.target, step.value, step.gate])).toEqual([
163
- ["observe-1", "observe", undefined, undefined, undefined],
164
- ["readtext-2", "readtext", "main", undefined, undefined],
165
- ["countelements-3", "countelements", "main section", undefined, undefined],
166
- ["type-4", "type", "input[name=filter]", "release notes, digest", true],
167
- ]);
168
- });
169
-
170
- it("reads the tabular preface markers through the linear scan that closed the polynomial regular expression alerts", async () => {
171
- /* the marker body accepts any spacing after the hash and the colon, and a marker line with no value never clears a value an earlier line set */
172
- const tight = importtabular({
173
- text: "#goal:tight\n#origin:https://example.org\nstep,target,value\nobserve,,\n",
174
- now,
175
- });
176
- expect(tight.file.goal).toBe("tight");
177
- expect(tight.file.origin).toBe("https://example.org");
178
- const spaced = importtabular({
179
- text: "# goal: spaced survey\n# origin: https://example.org\nstep,target,value\nobserve,,\n",
180
- now,
181
- });
182
- expect(spaced.file.goal).toBe("spaced survey");
183
- expect(spaced.file.origin).toBe("https://example.org");
184
- const kept = importtabular({
185
- text: "# goal: kept\n# goal:\n# origin: https://example.org\nstep,target,value\nobserve,,\n",
186
- now,
187
- });
188
- expect(kept.file.goal).toBe("kept");
189
- const sameorigin = importtabular({
190
- text: "# goal: g\n# origin: https://example.org\n# origin:\nstep,target,value\nobserve,,\n",
191
- now,
192
- });
193
- expect(sameorigin.file.origin).toBe("https://example.org");
194
- });
195
- });
196
-
197
- describe("migrateplan refusal semantics", () => {
198
- it("refuses every unmappable entry with the source entry named, never with a silent drop", async () => {
199
- for (const source of refusals) {
200
- const text = await fixture(source.name);
201
- expect(() => migrateplanconversion({ format: source.format, text, now })).toThrow(source.pattern);
202
- }
203
- });
204
-
205
- it("refuses the formats, the shapes and the locators it cannot map instead of guessing", async () => {
206
- expect(() => migrateplanconversion({ format: "playwright", text: "{}", now })).toThrow(
207
- /stays outside the v1, automa, selenium, uivision and tabular source formats/,
208
- );
209
- expect(() => migrateplanconversion({ format: "v1", text: "not json", now })).toThrow(/v1 source parses no json/);
210
- expect(() =>
211
- importv1plan({
212
- source: {
213
- version: "1",
214
- goal: "g",
215
- origin: "https://example.org",
216
- steps: [{ id: "s", action: "observe", label: "l", legacy: true }],
217
- },
218
- now,
219
- }),
220
- ).toThrow(/unknown field legacy/);
221
- expect(() =>
222
- importv1plan({
223
- source: {
224
- version: "1",
225
- goal: "g",
226
- origin: "http://example.org",
227
- steps: [{ id: "s", action: "observe", label: "l" }],
228
- },
229
- now,
230
- }),
231
- ).toThrow(/HTTPS/);
232
- expect(() =>
233
- importv1plan({
234
- source: {
235
- version: "1",
236
- goal: "g",
237
- origin: "https://example.org",
238
- steps: [{ id: "s", action: "click", label: "l", milliseconds: 5 }],
239
- },
240
- now,
241
- }),
242
- ).toThrow(/only the delay action lifts/);
243
- expect(() =>
244
- importautoma({
245
- source: {
246
- name: "n",
247
- blocks: {
248
- tab: { type: "newtab", data: { url: "https://example.org" } },
249
- away: { type: "newtab", data: { url: "https://other.example" } },
250
- },
251
- },
252
- now,
253
- }),
254
- ).toThrow(/automa block away of type newtab navigates to https:\/\/other\.example/);
255
- expect(() =>
256
- importautoma({
257
- source: { name: "n", blocks: { only: { type: "click-element", data: { selector: "button" } } } },
258
- now,
259
- }),
260
- ).toThrow(/carries no newtab block/);
261
- expect(() =>
262
- importselenium({ source: { version: "2.0", name: "n", url: "https://example.org", tests: [] }, now }),
263
- ).toThrow(/carries 0 tests; one plan addresses exactly one test/);
264
- expect(() =>
265
- importselenium({
266
- source: {
267
- version: "2.0",
268
- name: "n",
269
- url: "https://example.org",
270
- tests: [{ name: "t", commands: [{ id: "x", command: "click", target: "xpath=//button", value: "" }] }],
271
- },
272
- now,
273
- }),
274
- ).toThrow(/outside the css=, id= and name= locator prefixes/);
275
- expect(() =>
276
- importuivision({ source: { Name: "n", Commands: [{ Command: "click", Target: "css=button", Value: "" }] }, now }),
277
- ).toThrow(/carries no open command/);
278
- expect(() => importtabular({ text: "step,target,value\nobserve,,\n", now })).toThrow(/no `# goal:` preface line/);
279
- expect(() => importtabular({ text: "# goal: g\nstep,target,value\nobserve,,\n", now })).toThrow(
280
- /no `# origin:` preface line/,
281
- );
282
- expect(() =>
283
- importtabular({ text: "# goal: g\n# origin: http://example.org\nstep,target,value\nobserve,,\n", now }),
284
- ).toThrow(/HTTPS origin/);
285
- expect(() =>
286
- importtabular({ text: "# goal: g\n# origin: https://example.org\nstep,target,extra\nobserve,,\n", now }),
287
- ).toThrow(/column extra outside the step, target and value columns/);
288
- });
289
- });
290
-
291
- describe("the csv parser of the tabular importer", () => {
292
- it("parses headers, quoted cells, escaped quotes, embedded newlines and crlf line endings while refusing an unterminated quote", () => {
293
- expect(parsecsvrows("step,target,value\nobserve,,\n")).toEqual([
294
- ["step", "target", "value"],
295
- ["observe", "", ""],
296
- ]);
297
- expect(parsecsvrows('a,b\n1,"x,y"\n')).toEqual([
298
- ["a", "b"],
299
- ["1", "x,y"],
300
- ]);
301
- expect(parsecsvrows('a,b\n1,"say ""hi"""\n')).toEqual([
302
- ["a", "b"],
303
- ["1", 'say "hi"'],
304
- ]);
305
- expect(parsecsvrows('a,b,c\n1,"two\nlines",3')).toEqual([
306
- ["a", "b", "c"],
307
- ["1", "two\nlines", "3"],
308
- ]);
309
- expect(parsecsvrows("a,b\r\n1,2\r\n")).toEqual([
310
- ["a", "b"],
311
- ["1", "2"],
312
- ]);
313
- expect(parsecsvrows('a,b\n,"","x"\n')).toEqual([
314
- ["a", "b"],
315
- ["", "", "x"],
316
- ]);
317
- expect(parsecsvrows('a,b\n,"""",x\n')).toEqual([
318
- ["a", "b"],
319
- ["", '"', "x"],
320
- ]);
321
- expect(parsecsvrows("")).toEqual([]);
322
- expect(() => parsecsvrows('a,"unterminated')).toThrow(/ends inside a quoted cell/);
323
- });
324
- });
325
-
326
- describe("the migrateplan command surface", () => {
327
- it("registers the migrateplan command in the shared registry the cli help prints", () => {
328
- const entry = clicommands(surfacepalette()).find((command) => command.id === "migrateplan");
329
- expect(entry?.terminal).toBe(true);
330
- expect(entry?.label).toContain("foreign plan source");
331
- expect(entry?.keywords).toContain("automa");
332
- });
333
-
334
- it("keeps the conversion idempotent: converting the already converted output yields the same plan", async () => {
335
- const first = migrateplanconversion({ format: "v1", text: await fixture("v1-plan.json"), now });
336
- const serialized = JSON.stringify(first.file, null, 2);
337
- const second = migrateplanconversion({ format: "v1", text: serialized, now: now + 5_000 });
338
- expect(second.file).toEqual(first.file);
339
- expect(second.mapped).toBe(first.mapped);
340
- expect(second.notes.some((note) => note.includes("passes it through unchanged"))).toBe(true);
341
- const tabular = migrateplanconversion({ format: "tabular", text: await fixture("tabular-plan.csv"), now });
342
- const reimported = migrateplanconversion({
343
- format: "tabular",
344
- text: await fixture("tabular-plan.csv"),
345
- now: now + 5_000,
346
- });
347
- expect(reimported.file).toEqual(tabular.file);
348
- });
349
- });