@wenathlan/devthink 2.0.15 → 2.0.20

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 +54 -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
package/bridge.js ADDED
@@ -0,0 +1,1877 @@
1
+ /*! devthink 2.0.20 — consent-first browser agent library — GPL-3.0-only — https://github.com/wenathlan/devthink */
2
+
3
+ // version.ts
4
+ var packageversion = "2.0.20";
5
+ var protocolmajor = 2;
6
+
7
+ // types.ts
8
+ var protocolversion = packageversion;
9
+ var protocolmajorversion = protocolmajor;
10
+ var pinnedprotocolversion = Object.freeze({ protocolversion, protocolmajor: protocolmajorversion });
11
+ var actionkindids = Object.freeze([
12
+ "observe",
13
+ "inspect",
14
+ "extract",
15
+ "wait",
16
+ "waitfor",
17
+ "waittext",
18
+ "readattribute",
19
+ "readstyle",
20
+ "readgeometry",
21
+ "readvalue",
22
+ "readtext",
23
+ "readhtml",
24
+ "countelements",
25
+ "readtable",
26
+ "readlinks",
27
+ "readimages",
28
+ "readmeta",
29
+ "readforms",
30
+ "readstorage",
31
+ "highlight",
32
+ "tablist",
33
+ "windowlist",
34
+ "tabsnapshot",
35
+ "focus",
36
+ "scroll",
37
+ "hover",
38
+ "clickdeep",
39
+ "rightclick",
40
+ "doubleclick",
41
+ "scrollpage",
42
+ "scrollby",
43
+ "scrollend",
44
+ "scrolltop",
45
+ "fullscreen",
46
+ "zoomset",
47
+ "click",
48
+ "type",
49
+ "navigate",
50
+ "select",
51
+ "presskey",
52
+ "drag",
53
+ "drop",
54
+ "upload",
55
+ "clear",
56
+ "check",
57
+ "uncheck",
58
+ "toggle",
59
+ "submit",
60
+ "reload",
61
+ "back",
62
+ "forward",
63
+ "writestorage",
64
+ "setattribute",
65
+ "removeattribute",
66
+ "evaluate",
67
+ "tabcreate",
68
+ "tabactivate",
69
+ "tabclose",
70
+ "tabreload",
71
+ "windowcreate",
72
+ "windowclose",
73
+ "windowresize",
74
+ "downloadfile",
75
+ "movepointer",
76
+ "clickpoint",
77
+ "shiftclick",
78
+ "clicktext",
79
+ "clickaria",
80
+ "clickname",
81
+ "resolvexpath",
82
+ "typetime",
83
+ "appendtext",
84
+ "setvalue",
85
+ "typeedit",
86
+ "keyhold",
87
+ "keyrelease",
88
+ "submitsearch",
89
+ "selectmulti",
90
+ "chooseradio",
91
+ "setslider",
92
+ "setdate",
93
+ "setcolor",
94
+ "expanddetails",
95
+ "dismissdialog",
96
+ "pierceshadow",
97
+ "enterframe",
98
+ "retryaction",
99
+ "mapclicks",
100
+ "verifyvisible",
101
+ "verifyenabled",
102
+ "a11ytree",
103
+ "readvisible",
104
+ "readertree",
105
+ "detectlists",
106
+ "detecttables",
107
+ "readjson",
108
+ "watchmutate",
109
+ "waitquiet",
110
+ "watchbanner",
111
+ "detectinfinitescroll",
112
+ "detectvirtual",
113
+ "detectlazy",
114
+ "readscrollpos",
115
+ "readlang",
116
+ "readoutline",
117
+ "countpages",
118
+ "listshadow",
119
+ "listframes",
120
+ "classifypage",
121
+ "fingerprintsection",
122
+ "diffsnapshots",
123
+ "readselection",
124
+ "watchfocus",
125
+ "detectsticky",
126
+ "detectscrolllock",
127
+ "readopengraph",
128
+ "detectlanguage",
129
+ "deriveselector",
130
+ "openlink",
131
+ "openprivate",
132
+ "reloadcache",
133
+ "stopnav",
134
+ "waitload",
135
+ "waiturl",
136
+ "followlink",
137
+ "spanav",
138
+ "spawait",
139
+ "rewritequery",
140
+ "setfragment",
141
+ "navlist",
142
+ "navprofile",
143
+ "detecthttp",
144
+ "readredirects",
145
+ "readfinalurl",
146
+ "handleauth",
147
+ "printpdf",
148
+ "prefetch",
149
+ "preconnect",
150
+ "deeplink",
151
+ "reopentab",
152
+ "trailaudit",
153
+ "pausenav",
154
+ "navintent",
155
+ "navrate",
156
+ "openclipboard",
157
+ "checksafe",
158
+ "batchopen",
159
+ "querytabs",
160
+ "duplicatetab",
161
+ "closepattern",
162
+ "pintab",
163
+ "mutetab",
164
+ "movetab",
165
+ "movetabwindow",
166
+ "grouptabs",
167
+ "colorgroup",
168
+ "collapsegroup",
169
+ "discardtab",
170
+ "reloadtabs",
171
+ "zoomin",
172
+ "zoomout",
173
+ "watchtab",
174
+ "switchtab",
175
+ "maximizewindow",
176
+ "minimizewindow",
177
+ "restorewindow",
178
+ "focuswindow",
179
+ "scratchwindow",
180
+ "incognitowindow",
181
+ "restoretab",
182
+ "savelayout",
183
+ "restorelayout",
184
+ "findclones",
185
+ "searchtabs",
186
+ "badgetab",
187
+ "attachmeta",
188
+ "listaudio",
189
+ "reopenrun",
190
+ "snapshotsession",
191
+ "fillform",
192
+ "filllabel",
193
+ "fillplaceholder",
194
+ "detectfields",
195
+ "generatevalues",
196
+ "saveprofiles",
197
+ "asksubmit",
198
+ "submitform",
199
+ "readerrors",
200
+ "retryform",
201
+ "runwizard",
202
+ "selectchain",
203
+ "picktypeahead",
204
+ "pickdate",
205
+ "attachfile",
206
+ "handoffcaptcha",
207
+ "fillcard",
208
+ "fillcode",
209
+ "consentpassword",
210
+ "skiphoneypot",
211
+ "detectlogin",
212
+ "detecttemplate",
213
+ "scrapetable",
214
+ "exportcsv",
215
+ "exportjson",
216
+ "exportexcel",
217
+ "copytable",
218
+ "pushsheets",
219
+ "importcsv",
220
+ "looprows",
221
+ "transformvalues",
222
+ "deduperows",
223
+ "paginateextract",
224
+ "mergepages",
225
+ "stamplerows",
226
+ "previewgrid",
227
+ "streamdisk",
228
+ "resumeextract",
229
+ "logprovenance",
230
+ "batchdownload",
231
+ "pausedownload",
232
+ "resumedownload",
233
+ "verifydownload",
234
+ "interceptmime",
235
+ "exportnetlog",
236
+ "readclipboard",
237
+ "writeclipboard",
238
+ "copyscreen",
239
+ "quarantinedownload",
240
+ "scanvirus",
241
+ "namecaptures",
242
+ "cleanupartifacts",
243
+ "shotview",
244
+ "shotfullpage",
245
+ "shotelement",
246
+ "shotregion",
247
+ "contactsheet",
248
+ "capturepdf",
249
+ "recordscreen",
250
+ "captureaudio",
251
+ "captureframe",
252
+ "downloadimages",
253
+ "shotcanvas",
254
+ "probestream",
255
+ "readmedia",
256
+ "readassets",
257
+ "timelapse",
258
+ "convertimage",
259
+ "makethumbs",
260
+ "fetchurl",
261
+ "parsejson",
262
+ "parsehtml",
263
+ "callrest",
264
+ "callgraphql",
265
+ "opensocket",
266
+ "sendmessage",
267
+ "waitmessage",
268
+ "watchrequests",
269
+ "readheaders",
270
+ "capturebodies",
271
+ "subscribesse",
272
+ "longpoll",
273
+ "mapapi",
274
+ "extractapi",
275
+ "blockrequest",
276
+ "mockresponse",
277
+ "rewriteheaders",
278
+ "setcookies",
279
+ "readcookies",
280
+ "clearcookies",
281
+ "authflow",
282
+ "saveapikey",
283
+ "routeproxy",
284
+ "postform",
285
+ "postfiles",
286
+ "watchconsole",
287
+ "watcherrors",
288
+ "watchtasks",
289
+ "attachcdp",
290
+ "detachcdp",
291
+ "cdpcmd",
292
+ "watchcdp",
293
+ "setbreakpoint",
294
+ "stepcode",
295
+ "watchexpr",
296
+ "overridescript",
297
+ "measureflow",
298
+ "heapshot",
299
+ "trackmemory",
300
+ "profilecpu",
301
+ "watchshifts",
302
+ "traceload",
303
+ "annotatetrace",
304
+ "replaytrace",
305
+ "capturesourcemaps",
306
+ "emulatedevice",
307
+ "emulatenetwork",
308
+ "emulatelocate",
309
+ "setuseragent",
310
+ "overridepermission",
311
+ "blackboxscripts",
312
+ "persiststate",
313
+ "capturesession",
314
+ "restoresession",
315
+ "namedsessions",
316
+ "diffsessions",
317
+ "searchsessions",
318
+ "exportsessions",
319
+ "importsessions",
320
+ "composeworkflow",
321
+ "savetemplate",
322
+ "runworkflow",
323
+ "dryrun",
324
+ "delay",
325
+ "waitelement",
326
+ "compute",
327
+ "extractvars",
328
+ "listruns",
329
+ "condition",
330
+ "branch",
331
+ "loop",
332
+ "repeatuntil",
333
+ "whileloop",
334
+ "foreach",
335
+ "parallel",
336
+ "trycatch",
337
+ "visitrule",
338
+ "urlrule",
339
+ "menurule",
340
+ "keyrule",
341
+ "buttonrule",
342
+ "cronrule",
343
+ "intervalrule",
344
+ "urllistrule",
345
+ "webhookrule",
346
+ "eventrule"
347
+ ]);
348
+ var servercontractversion = 1;
349
+
350
+ // auth.ts
351
+ function pairingcountdown(record, now) {
352
+ const secondsleft = Math.max(0, Math.ceil((record.code.expiresat - now) / 1e3));
353
+ const expired = now >= record.code.expiresat || record.code.usedat !== void 0;
354
+ const minutes = Math.floor(secondsleft / 60);
355
+ const seconds = secondsleft % 60;
356
+ const label = expired ? `The pairing code ${record.code.code} expired.` : `The pairing code ${record.code.code} expires in ${minutes}m ${String(seconds).padStart(2, "0")}s.`;
357
+ return { secondsleft, expired, label };
358
+ }
359
+
360
+ // serve.ts
361
+ function notificationframe(method, params) {
362
+ return { jsonrpc: "2.0", method, ...params !== void 0 ? { params } : {} };
363
+ }
364
+
365
+ // net.ts
366
+ function reconnectwaits(attempts, base, ceiling) {
367
+ const count = Math.max(0, Math.floor(attempts));
368
+ const waits = [];
369
+ let wait = Math.max(0, base);
370
+ for (let index = 0; index < count; index += 1) {
371
+ waits.push(wait);
372
+ const next = wait * 2;
373
+ wait = ceiling !== void 0 && Number.isFinite(ceiling) && ceiling >= 0 ? Math.min(next, ceiling) : next;
374
+ }
375
+ return waits;
376
+ }
377
+
378
+ // bridge.ts
379
+ var serveroperations = ["sessioncreate", "sessionjoin", "eventpost", "eventstream"];
380
+ var servereventtypes = ["chat", "planproposal", "planreview", "progress"];
381
+ var pagecontentkeys = [
382
+ "html",
383
+ "content",
384
+ "body",
385
+ "textpreview",
386
+ "preview",
387
+ "dom",
388
+ "markup",
389
+ "screenshot",
390
+ "pagetext",
391
+ "outerhtml",
392
+ "innertext"
393
+ ];
394
+ function contractcapabilities(version = servercontractversion) {
395
+ return {
396
+ version,
397
+ operations: [...serveroperations],
398
+ events: [...servereventtypes],
399
+ heartbeat: true,
400
+ multiplex: true
401
+ };
402
+ }
403
+ function stableopid(seed, sequence) {
404
+ const trimmed = seed.trim();
405
+ if (trimmed === "")
406
+ throw new Error("The operation id names its sender seed; an empty seed never correlates a reply.");
407
+ if (!Number.isInteger(sequence) || sequence < 1)
408
+ throw new Error("The operation id sequence stays a positive whole number per sender.");
409
+ return `op-${trimmed}-${sequence}`;
410
+ }
411
+ function negotiatecapabilities(ours, theirs) {
412
+ if (!Number.isInteger(ours.version) || ours.version < 1 || !Number.isInteger(theirs.version) || theirs.version < 1)
413
+ return {
414
+ ok: false,
415
+ version: 0,
416
+ operations: [],
417
+ events: [],
418
+ heartbeat: false,
419
+ multiplex: false,
420
+ reason: "The servercontract version stays a positive whole number on both sides of the handshake."
421
+ };
422
+ const version = Math.min(ours.version, theirs.version);
423
+ const operations = serveroperations.filter(
424
+ (operation) => ours.operations.includes(operation) && theirs.operations.includes(operation)
425
+ );
426
+ const events = servereventtypes.filter((event) => ours.events.includes(event) && theirs.events.includes(event));
427
+ if (version < 1)
428
+ return {
429
+ ok: false,
430
+ version: 0,
431
+ operations: [],
432
+ events: [],
433
+ heartbeat: false,
434
+ multiplex: false,
435
+ reason: "The two handshake sides share no servercontract version."
436
+ };
437
+ if (operations.length === 0)
438
+ return {
439
+ ok: false,
440
+ version,
441
+ operations: [],
442
+ events: [],
443
+ heartbeat: false,
444
+ multiplex: false,
445
+ reason: "The two handshake sides share no wire operation."
446
+ };
447
+ if (events.length === 0)
448
+ return {
449
+ ok: false,
450
+ version,
451
+ operations: [],
452
+ events: [],
453
+ heartbeat: false,
454
+ multiplex: false,
455
+ reason: "The two handshake sides share no event type."
456
+ };
457
+ return {
458
+ ok: true,
459
+ version,
460
+ operations,
461
+ events,
462
+ heartbeat: ours.heartbeat === true && theirs.heartbeat === true,
463
+ multiplex: ours.multiplex === true && theirs.multiplex === true
464
+ };
465
+ }
466
+ function composeenvelope(input) {
467
+ const opid = input.opid.trim();
468
+ if (opid === "")
469
+ throw new Error("The envelope carries its stable operation id; an empty id never correlates a reply.");
470
+ if (!serveroperations.includes(input.op))
471
+ throw new Error(`The envelope operation ${input.op} sits outside the servercontract operations.`);
472
+ if (!Number.isFinite(input.at)) throw new Error("The envelope carries its timestamp.");
473
+ return {
474
+ version: input.version ?? servercontractversion,
475
+ op: input.op,
476
+ opid,
477
+ at: input.at,
478
+ ...input.sessionid !== void 0 && input.sessionid.trim() !== "" ? { sessionid: input.sessionid.trim() } : {},
479
+ ...input.token !== void 0 && input.token.trim() !== "" ? { token: input.token.trim() } : {},
480
+ ...input.body !== void 0 ? { body: input.body } : {}
481
+ };
482
+ }
483
+ function parseenvelope(value) {
484
+ if (!value || typeof value !== "object" || Array.isArray(value))
485
+ throw new Error("The servercontract envelope must be a json object.");
486
+ const entry = value;
487
+ if (!Number.isInteger(entry.version) || entry.version < 1)
488
+ throw new Error("The envelope version must be a positive whole number.");
489
+ if (typeof entry.op !== "string" || !serveroperations.includes(entry.op))
490
+ throw new Error(`The envelope operation ${String(entry.op)} sits outside the servercontract operations.`);
491
+ if (typeof entry.opid !== "string" || entry.opid.trim() === "")
492
+ throw new Error("The envelope operation id must be a non-empty string.");
493
+ if (entry.sessionid !== void 0 && (typeof entry.sessionid !== "string" || entry.sessionid.trim() === ""))
494
+ throw new Error("The envelope session id must be a non-empty string when present.");
495
+ if (entry.token !== void 0 && (typeof entry.token !== "string" || entry.token.trim() === ""))
496
+ throw new Error("The envelope frame token must be a non-empty string when present.");
497
+ if (!Number.isFinite(entry.at)) throw new Error("The envelope timestamp must be a finite number.");
498
+ if (entry.body !== void 0 && (!entry.body || typeof entry.body !== "object" || Array.isArray(entry.body)))
499
+ throw new Error("The envelope body must be a json object when present.");
500
+ return {
501
+ version: entry.version,
502
+ op: entry.op,
503
+ opid: entry.opid.trim(),
504
+ at: entry.at,
505
+ ...entry.sessionid !== void 0 ? { sessionid: entry.sessionid.trim() } : {},
506
+ ...entry.token !== void 0 ? { token: entry.token.trim() } : {},
507
+ ...entry.body !== void 0 ? { body: entry.body } : {}
508
+ };
509
+ }
510
+ function envelopeacceptance(value) {
511
+ try {
512
+ return { ok: true, envelope: parseenvelope(value) };
513
+ } catch (error) {
514
+ return { ok: false, reason: error instanceof Error ? error.message : String(error) };
515
+ }
516
+ }
517
+ function sessioncreatebody(input) {
518
+ const memberid = input.memberid.trim();
519
+ if (memberid === "") throw new Error("The sessioncreate body names its member id.");
520
+ if (input.role !== "extension" && input.role !== "site")
521
+ throw new Error("The sessioncreate role is the extension or the site side.");
522
+ return {
523
+ role: input.role,
524
+ memberid,
525
+ capabilities: input.capabilities,
526
+ ...input.pairingcode !== void 0 && input.pairingcode.trim() !== "" ? { pairingcode: input.pairingcode.trim() } : {}
527
+ };
528
+ }
529
+ function sessionjoinbody(input) {
530
+ const sessionid = (input.sessionid ?? "").trim();
531
+ const pairingcode = (input.pairingcode ?? "").trim();
532
+ if (sessionid === "" && pairingcode === "")
533
+ throw new Error(
534
+ "The sessionjoin body names its session id or rides its pairing code; one of the two identifies the join."
535
+ );
536
+ const memberid = input.memberid.trim();
537
+ if (memberid === "") throw new Error("The sessionjoin body names its member id.");
538
+ if (input.role !== "extension" && input.role !== "site")
539
+ throw new Error("The sessionjoin role is the extension or the site side.");
540
+ return {
541
+ ...sessionid !== "" ? { sessionid } : {},
542
+ role: input.role,
543
+ memberid,
544
+ capabilities: input.capabilities,
545
+ ...pairingcode !== "" ? { pairingcode } : {}
546
+ };
547
+ }
548
+ function eventpostbody(input) {
549
+ if (!servereventtypes.includes(input.event.kind))
550
+ throw new Error(`The event type ${input.event.kind} sits outside the servercontract event types.`);
551
+ const stream = input.event.stream.trim();
552
+ if (stream === "") throw new Error("The eventpost body names its multiplexed stream.");
553
+ if (!input.event.payload || typeof input.event.payload !== "object" || Array.isArray(input.event.payload))
554
+ throw new Error("The eventpost payload must be a json object.");
555
+ return { kind: input.event.kind, stream, payload: input.event.payload };
556
+ }
557
+ function eventstreambody(input) {
558
+ const streams = input.streams.map((stream) => stream.trim()).filter((stream) => stream !== "");
559
+ if (streams.length === 0) throw new Error("The eventstream body names at least one multiplexed stream.");
560
+ if (input.since !== void 0 && !Number.isFinite(input.since))
561
+ throw new Error("The eventstream resume timestamp stays a finite number.");
562
+ return { streams, ...input.since !== void 0 ? { since: input.since } : {} };
563
+ }
564
+ function chateventpayload(input) {
565
+ const text = input.text.trim();
566
+ if (text === "") throw new Error("The chat event carries its task text.");
567
+ const from = input.from.trim();
568
+ if (from === "") throw new Error("The chat event names its sender.");
569
+ return { text, from };
570
+ }
571
+ function planproposaleventpayload(card) {
572
+ const proposalid = card.proposalid.trim();
573
+ if (proposalid === "") throw new Error("The plan proposal names its proposal id.");
574
+ const title = card.title.trim();
575
+ if (title === "") throw new Error("The plan proposal names its plan title.");
576
+ if (card.steps.length === 0) throw new Error("The plan proposal carries at least one step of its digest.");
577
+ return {
578
+ proposalid,
579
+ title,
580
+ steps: card.steps.map((step) => ({ id: step.id, kind: step.kind, origin: step.origin, sensitive: step.sensitive })),
581
+ ...card.timeoutat !== void 0 ? { timeoutat: card.timeoutat } : {}
582
+ };
583
+ }
584
+ function planrevieweventpayload(decision) {
585
+ const proposalid = decision.proposalid.trim();
586
+ if (proposalid === "") throw new Error("The plan review names its proposal id.");
587
+ if (decision.decision !== "approved" && decision.decision !== "changes" && decision.decision !== "refused")
588
+ throw new Error("The plan review decision is approved, changes or refused.");
589
+ const by = decision.by.trim();
590
+ if (by === "") throw new Error("The plan review names its reviewer.");
591
+ return {
592
+ proposalid,
593
+ decision: decision.decision,
594
+ by,
595
+ ...decision.note !== void 0 && decision.note.trim() !== "" ? { note: decision.note.trim() } : {}
596
+ };
597
+ }
598
+ function progresseventpayload(input) {
599
+ const stepid = input.stepid.trim();
600
+ if (stepid === "") throw new Error("The progress event names its step id.");
601
+ const status = input.status.trim();
602
+ if (status === "") throw new Error("The progress event names its status word.");
603
+ return { stepid, status };
604
+ }
605
+ function heartbeatevent(now) {
606
+ if (!Number.isFinite(now)) throw new Error("The heartbeat event carries its timestamp.");
607
+ return {
608
+ kind: "progress",
609
+ stream: "heartbeat",
610
+ payload: progresseventpayload({ stepid: "heartbeat", status: "alive" })
611
+ };
612
+ }
613
+ function bridgepayload(kind, payload, pageconsent) {
614
+ if (kind === "chat") return { payload, held: [] };
615
+ const held = [];
616
+ const minimized = {};
617
+ for (const [key, value] of Object.entries(payload)) {
618
+ if (pagecontentkeys.includes(key) && pageconsent !== true) {
619
+ held.push(key);
620
+ continue;
621
+ }
622
+ minimized[key] = value;
623
+ }
624
+ return { payload: minimized, held };
625
+ }
626
+ function minimalplandigest(plan, statuses = {}) {
627
+ const objective = plan.objective.trim();
628
+ if (objective === "") throw new Error("The plan digest names its objective.");
629
+ return {
630
+ title: objective,
631
+ steps: plan.steps.map((step) => ({ id: step.id, kind: step.kind, status: statuses[step.id] ?? "pending" }))
632
+ };
633
+ }
634
+ function frameof(envelope) {
635
+ return JSON.stringify(envelope);
636
+ }
637
+ function parsewireframe(text) {
638
+ let parsed;
639
+ try {
640
+ parsed = JSON.parse(text);
641
+ } catch {
642
+ throw new Error("The wire frame must be json text.");
643
+ }
644
+ return parseenvelope(parsed);
645
+ }
646
+ function sitemanifestof(version = servercontractversion) {
647
+ return { name: "devthink site", servercontract: version, capabilities: contractcapabilities(version) };
648
+ }
649
+ function relayorigin(url) {
650
+ try {
651
+ const parsed = new URL(url.trim());
652
+ if (parsed.protocol !== "wss:" && parsed.protocol !== "ws:") return "";
653
+ const protocol = parsed.protocol === "wss:" ? "https:" : "http:";
654
+ return `${protocol}//${parsed.host}`;
655
+ } catch {
656
+ return "";
657
+ }
658
+ }
659
+ function newrelayclient(input) {
660
+ const memberid = input.memberid.trim();
661
+ if (memberid === "") throw new Error("The bridge client names its member id.");
662
+ const url = input.url.trim();
663
+ if (url !== "" && relayorigin(url) === "") throw new Error("The relay url must be a wss or ws url the user chose.");
664
+ return {
665
+ url,
666
+ origin: relayorigin(url),
667
+ sessionid: (input.sessionid ?? "").trim(),
668
+ token: (input.token ?? "").trim(),
669
+ memberid,
670
+ role: input.role,
671
+ state: url === "" ? "idle" : "connecting",
672
+ attempts: 0,
673
+ rotations: 0,
674
+ sent: 0,
675
+ received: 0,
676
+ lastframeat: input.now,
677
+ lastheartbeatat: input.now,
678
+ streams: {},
679
+ acks: [],
680
+ queue: [],
681
+ capabilities: input.capabilities,
682
+ rate: { used: 0, windowstartedat: input.now },
683
+ sequence: 0
684
+ };
685
+ }
686
+ function verifyframeauth(envelope, state) {
687
+ if (state.sessionid === "" || state.token === "") return false;
688
+ return envelope.sessionid === state.sessionid && envelope.token === state.token;
689
+ }
690
+ function frameauth(envelope, state) {
691
+ return { ...envelope, sessionid: state.sessionid, token: state.token };
692
+ }
693
+ function bridgeframerate(input) {
694
+ const window = input.window !== void 0 && Number.isFinite(input.window) && input.window > 0 ? input.window : void 0;
695
+ if (window === void 0)
696
+ return { allowed: true, used: input.rate.used, windowstartedat: input.rate.windowstartedat };
697
+ if (input.now - input.rate.windowstartedat >= window)
698
+ return {
699
+ allowed: input.cap === void 0 || input.cap >= 1,
700
+ used: input.cap === void 0 ? input.rate.used : 1,
701
+ windowstartedat: input.now,
702
+ resetsat: input.now + window
703
+ };
704
+ const used = input.rate.used + 1;
705
+ if (input.cap !== void 0 && Number.isFinite(input.cap) && input.cap >= 1 && used > input.cap)
706
+ return {
707
+ allowed: false,
708
+ used: input.rate.used,
709
+ windowstartedat: input.rate.windowstartedat,
710
+ resetsat: input.rate.windowstartedat + window
711
+ };
712
+ return {
713
+ allowed: true,
714
+ used,
715
+ windowstartedat: input.rate.windowstartedat,
716
+ resetsat: input.rate.windowstartedat + window
717
+ };
718
+ }
719
+ function sendframe(state, socket, envelope, now) {
720
+ if (state.state !== "connected")
721
+ return { state, sent: false, reason: "The bridge socket stays down; the frame waits in the offline queue." };
722
+ const stamped = frameauth(envelope, state);
723
+ socket.send(frameof(stamped));
724
+ return { state: { ...state, sent: state.sent + 1, lastframeat: now }, sent: true };
725
+ }
726
+ function receiveframe(state, frame, now) {
727
+ let envelope;
728
+ try {
729
+ envelope = parsewireframe(frame);
730
+ } catch (error) {
731
+ return { state, rejection: error instanceof Error ? error.message : String(error) };
732
+ }
733
+ if (!verifyframeauth(envelope, state))
734
+ return {
735
+ state,
736
+ rejection: `The frame ${envelope.opid} failed the frame authentication of the session ${state.sessionid}.`
737
+ };
738
+ if (envelope.op === "eventpost" && envelope.body !== void 0) {
739
+ const stream = typeof envelope.body.stream === "string" ? envelope.body.stream.trim() : "";
740
+ const kind = typeof envelope.body.kind === "string" ? envelope.body.kind : "";
741
+ if (stream !== "") {
742
+ const record = {
743
+ id: envelope.opid,
744
+ sessionid: state.sessionid,
745
+ kind,
746
+ opid: envelope.opid,
747
+ stream,
748
+ payload: envelope.body.payload ?? {},
749
+ at: envelope.at,
750
+ delivered: true
751
+ };
752
+ const next = {
753
+ ...state,
754
+ received: state.received + 1,
755
+ lastframeat: now,
756
+ acks: [...state.acks, envelope],
757
+ streams: { ...state.streams, [stream]: [...state.streams[stream] ?? [], record] }
758
+ };
759
+ return { state: next, envelope };
760
+ }
761
+ }
762
+ return {
763
+ state: { ...state, received: state.received + 1, lastframeat: now, acks: [...state.acks, envelope] },
764
+ envelope
765
+ };
766
+ }
767
+ function enqueuebridge(state, input) {
768
+ if (state.queue.some((record2) => record2.opid === input.opid)) return state;
769
+ const record = {
770
+ opid: input.opid,
771
+ op: input.op,
772
+ sessionid: state.sessionid,
773
+ body: input.body,
774
+ queuedat: input.now,
775
+ attempts: 0
776
+ };
777
+ return { ...state, queue: [...state.queue, record] };
778
+ }
779
+ function replaybridgequeue(state, socket, now) {
780
+ let replayed = 0;
781
+ let deduped = 0;
782
+ const seen = /* @__PURE__ */ new Set();
783
+ const queue = [];
784
+ let sent = state.sent;
785
+ for (const record of state.queue) {
786
+ if (seen.has(record.opid)) {
787
+ deduped += 1;
788
+ continue;
789
+ }
790
+ seen.add(record.opid);
791
+ if (record.sentat !== void 0 || state.state !== "connected") {
792
+ queue.push(record);
793
+ continue;
794
+ }
795
+ socket.send(
796
+ frameof(frameauth(composeenvelope({ op: record.op, opid: record.opid, at: now, body: record.body }), state))
797
+ );
798
+ queue.push({ ...record, attempts: record.attempts + 1, sentat: now });
799
+ replayed += 1;
800
+ sent += 1;
801
+ }
802
+ return { state: { ...state, queue, sent, lastframeat: now }, replayed, deduped };
803
+ }
804
+ function postevent(state, socket, event, now, rate) {
805
+ const opid = `op-${state.memberid}-${state.sequence + 1}`;
806
+ const body = eventpostbody({ event });
807
+ if (state.state !== "connected" || socket === void 0) {
808
+ return {
809
+ state: enqueuebridge({ ...state, sequence: state.sequence + 1 }, { op: "eventpost", opid, body, now }),
810
+ sent: false,
811
+ queued: true,
812
+ reason: "The bridge socket stays down; the event waits in the offline queue."
813
+ };
814
+ }
815
+ const window = bridgeframerate({
816
+ rate: state.rate,
817
+ ...rate?.cap !== void 0 ? { cap: rate.cap } : {},
818
+ ...rate?.window !== void 0 ? { window: rate.window } : {},
819
+ now
820
+ });
821
+ if (!window.allowed) {
822
+ return {
823
+ state: enqueuebridge(
824
+ {
825
+ ...state,
826
+ sequence: state.sequence + 1,
827
+ rate: { used: window.used, windowstartedat: window.windowstartedat }
828
+ },
829
+ { op: "eventpost", opid, body, now }
830
+ ),
831
+ sent: false,
832
+ queued: true,
833
+ reason: `The bridge rate window holds its ${rate?.cap} frame cap; the event waits for the window reset.`
834
+ };
835
+ }
836
+ const sent = sendframe(
837
+ { ...state, sequence: state.sequence + 1, rate: { used: window.used, windowstartedat: window.windowstartedat } },
838
+ socket,
839
+ composeenvelope({ op: "eventpost", opid, at: now, body }),
840
+ now
841
+ );
842
+ return { state: sent.state, sent: true, queued: false };
843
+ }
844
+ function heartbeattick(state, socket, now, interval) {
845
+ if (state.state !== "connected" || socket === void 0) return { state, beat: false };
846
+ if (interval === void 0 || !Number.isFinite(interval) || interval <= 0) return { state, beat: false };
847
+ if (now - state.lastheartbeatat < interval) return { state, beat: false };
848
+ const event = heartbeatevent(now);
849
+ const opid = `op-${state.memberid}-heartbeat-${state.sent + 1}`;
850
+ const sent = sendframe(
851
+ state,
852
+ socket,
853
+ composeenvelope({ op: "eventpost", opid, at: now, body: eventpostbody({ event }) }),
854
+ now
855
+ );
856
+ return { state: { ...sent.state, lastheartbeatat: now }, beat: true };
857
+ }
858
+ function idleexpired(state, now, idlewindow) {
859
+ if (idlewindow === void 0 || !Number.isFinite(idlewindow) || idlewindow <= 0) return false;
860
+ return now - state.lastframeat >= idlewindow;
861
+ }
862
+ function disconnectrelay(state, now, reason) {
863
+ return { ...state, state: "closed", closedat: now, ...reason !== void 0 ? { lasterror: reason } : {} };
864
+ }
865
+ function bridgestatusview(state) {
866
+ if (state.url === "")
867
+ return {
868
+ status: "disabled",
869
+ paired: false,
870
+ queued: state.queue.filter((record) => record.sentat === void 0).length
871
+ };
872
+ const paired = state.sessionid !== "" && state.token !== "";
873
+ if (state.state === "connected")
874
+ return { status: "connected", paired, queued: state.queue.filter((record) => record.sentat === void 0).length };
875
+ if (paired)
876
+ return {
877
+ status: "paired",
878
+ paired: true,
879
+ queued: state.queue.filter((record) => record.sentat === void 0).length
880
+ };
881
+ return {
882
+ status: "offline",
883
+ paired: false,
884
+ queued: state.queue.filter((record) => record.sentat === void 0).length
885
+ };
886
+ }
887
+ async function connectrelay(input) {
888
+ const sleep = input.sleep ?? ((milliseconds) => new Promise((resolve) => setTimeout(resolve, Math.max(0, milliseconds))));
889
+ const now = input.now ?? Date.now;
890
+ if (input.state.url.trim() === "")
891
+ return {
892
+ state: {
893
+ ...input.state,
894
+ state: "idle",
895
+ lasterror: "The bridge stays disabled because no relay url is configured; the url is always the user's setting."
896
+ },
897
+ error: "The bridge stays disabled because no relay url is configured; the url is always the user's setting."
898
+ };
899
+ const budget = Math.max(1, Math.floor(input.attempts ?? 1));
900
+ const waits = reconnectwaits(budget - 1, input.backoffbase ?? 0, input.backoffceiling);
901
+ let state = { ...input.state, state: "connecting" };
902
+ let lasterror = "";
903
+ for (let attempt = 0; attempt < budget; attempt += 1) {
904
+ let socket;
905
+ try {
906
+ socket = await input.open(state.url);
907
+ } catch (error) {
908
+ lasterror = error instanceof Error ? error.message : String(error);
909
+ if (attempt < budget - 1) {
910
+ const wait = waits[attempt] ?? 0;
911
+ if (wait > 0) await sleep(wait);
912
+ state = { ...state, attempts: state.attempts + 1, state: "reconnecting" };
913
+ if (input.rotate !== void 0) {
914
+ try {
915
+ state = { ...state, token: await input.rotate(), rotations: state.rotations + 1 };
916
+ } catch {
917
+ }
918
+ }
919
+ }
920
+ continue;
921
+ }
922
+ state = { ...state, state: "authenticating" };
923
+ const opid = `op-${state.memberid}-join-${state.attempts + 1}`;
924
+ const firstjoin = state.sessionid === "";
925
+ const reply = await new Promise((resolve) => {
926
+ socket.onmessage = (frame) => resolve({ frame });
927
+ socket.onclose = (code) => resolve({
928
+ error: `The relay socket closed with code ${code} before the ${firstjoin ? "session create" : "join"} reply.`
929
+ });
930
+ socket.onerror = (error) => resolve({ error });
931
+ const createsession = firstjoin && state.role === "extension";
932
+ const body = createsession ? {
933
+ role: state.role,
934
+ memberid: state.memberid,
935
+ capabilities: state.capabilities,
936
+ ...input.pairingcode !== void 0 && input.pairingcode.trim() !== "" ? { pairingcode: input.pairingcode.trim() } : {}
937
+ } : firstjoin ? {
938
+ role: state.role,
939
+ memberid: state.memberid,
940
+ capabilities: state.capabilities,
941
+ ...input.pairingcode !== void 0 && input.pairingcode.trim() !== "" ? { pairingcode: input.pairingcode.trim() } : {}
942
+ } : {
943
+ sessionid: state.sessionid,
944
+ role: state.role,
945
+ memberid: state.memberid,
946
+ capabilities: state.capabilities
947
+ };
948
+ socket.send(
949
+ frameof(
950
+ frameauth(composeenvelope({ op: createsession ? "sessioncreate" : "sessionjoin", opid, at: now(), body }), {
951
+ ...state,
952
+ token: state.token
953
+ })
954
+ )
955
+ );
956
+ });
957
+ if (reply.frame === void 0) {
958
+ lasterror = reply.error ?? "The relay socket closed before the join reply.";
959
+ try {
960
+ socket.close(1e3);
961
+ } catch {
962
+ }
963
+ if (attempt < budget - 1) {
964
+ const wait = waits[attempt] ?? 0;
965
+ if (wait > 0) await sleep(wait);
966
+ state = { ...state, attempts: state.attempts + 1, state: "reconnecting" };
967
+ if (input.rotate !== void 0) {
968
+ try {
969
+ state = { ...state, token: await input.rotate(), rotations: state.rotations + 1 };
970
+ } catch {
971
+ }
972
+ }
973
+ }
974
+ continue;
975
+ }
976
+ let envelope;
977
+ try {
978
+ envelope = parsewireframe(reply.frame);
979
+ } catch (error) {
980
+ lasterror = error instanceof Error ? error.message : String(error);
981
+ try {
982
+ socket.close(1e3);
983
+ } catch {
984
+ }
985
+ continue;
986
+ }
987
+ if (envelope.opid !== opid) {
988
+ lasterror = `The join reply ${envelope.opid} does not correlate the join request ${opid}.`;
989
+ try {
990
+ socket.close(1e3);
991
+ } catch {
992
+ }
993
+ continue;
994
+ }
995
+ if (envelope.body !== void 0 && typeof envelope.body.error === "string" && envelope.body.error.trim() !== "") {
996
+ lasterror = envelope.body.error;
997
+ try {
998
+ socket.close(1e3);
999
+ } catch {
1000
+ }
1001
+ if (attempt < budget - 1) {
1002
+ const wait = waits[attempt] ?? 0;
1003
+ if (wait > 0) await sleep(wait);
1004
+ state = { ...state, attempts: state.attempts + 1, state: "reconnecting" };
1005
+ }
1006
+ continue;
1007
+ }
1008
+ const rotatedtoken = envelope.body !== void 0 && typeof envelope.body.token === "string" ? envelope.body.token.trim() : "";
1009
+ const sessionid = envelope.body !== void 0 && typeof envelope.body.sessionid === "string" ? envelope.body.sessionid.trim() : state.sessionid;
1010
+ state = {
1011
+ ...state,
1012
+ state: "connected",
1013
+ sessionid: sessionid !== "" ? sessionid : state.sessionid,
1014
+ token: rotatedtoken !== "" ? rotatedtoken : state.token,
1015
+ rotations: rotatedtoken !== "" ? state.rotations + 1 : state.rotations,
1016
+ openedat: now(),
1017
+ lastframeat: now(),
1018
+ lastheartbeatat: now(),
1019
+ acks: [...state.acks, envelope]
1020
+ };
1021
+ return { state, socket };
1022
+ }
1023
+ return {
1024
+ state: { ...state, state: "closed", attempts: state.attempts, closedat: now(), lasterror },
1025
+ error: lasterror
1026
+ };
1027
+ }
1028
+ function chatrowsof(events, memberid) {
1029
+ return events.filter((event) => event.kind === "chat").map((event) => ({
1030
+ from: typeof event.payload.from === "string" ? event.payload.from : "",
1031
+ text: typeof event.payload.text === "string" ? event.payload.text : "",
1032
+ mine: typeof event.payload.from === "string" && event.payload.from === memberid,
1033
+ at: event.at
1034
+ }));
1035
+ }
1036
+ function reviewcardsof(events) {
1037
+ return events.filter((event) => event.kind === "planproposal").map((event) => {
1038
+ const steps = Array.isArray(event.payload.steps) ? event.payload.steps.filter((step) => typeof step.id === "string" && typeof step.kind === "string").map((step) => ({
1039
+ id: String(step.id),
1040
+ kind: String(step.kind),
1041
+ origin: typeof step.origin === "string" ? step.origin : "",
1042
+ sensitive: step.sensitive === true
1043
+ })) : [];
1044
+ return {
1045
+ proposalid: typeof event.payload.proposalid === "string" ? event.payload.proposalid : "",
1046
+ title: typeof event.payload.title === "string" ? event.payload.title : "",
1047
+ steps,
1048
+ ...typeof event.payload.timeoutat === "number" ? { timeoutat: event.payload.timeoutat } : {},
1049
+ at: event.at
1050
+ };
1051
+ }).filter((card) => card.proposalid !== "" && card.title !== "");
1052
+ }
1053
+ function carddecision(card, decision, by, now, note) {
1054
+ if (card.proposalid.trim() === "") throw new Error("The review decision names its proposal.");
1055
+ if (decision !== "approved" && decision !== "changes" && decision !== "refused")
1056
+ throw new Error("The review decision is approved, changes or refused.");
1057
+ const reviewer = by.trim();
1058
+ if (reviewer === "") throw new Error("The review decision names its reviewer.");
1059
+ return {
1060
+ proposalid: card.proposalid,
1061
+ decision,
1062
+ by: reviewer,
1063
+ ...note !== void 0 && note.trim() !== "" ? { note: note.trim() } : {},
1064
+ at: now
1065
+ };
1066
+ }
1067
+ function decisionpayload(decision) {
1068
+ return planrevieweventpayload(decision);
1069
+ }
1070
+ function reviewgateoutcome(decision) {
1071
+ if (decision.decision === "approved")
1072
+ return {
1073
+ state: "approved",
1074
+ reason: `The site review approved the plan proposal ${decision.proposalid}${decision.note !== void 0 ? ` with the note ${decision.note}` : ""}; the extension review gate resolves as approved and the extension stays the only executor.`
1075
+ };
1076
+ return {
1077
+ state: "refused",
1078
+ reason: `The site review returned ${decision.decision} for the plan proposal ${decision.proposalid}${decision.note !== void 0 ? ` with the note ${decision.note}` : ""}; the proposal returns to the review surface and no step executes.`
1079
+ };
1080
+ }
1081
+ function chateventof(text, from) {
1082
+ return { kind: "chat", stream: "chat", payload: chateventpayload({ text, from }) };
1083
+ }
1084
+ function planproposaleventof(card) {
1085
+ return { kind: "planproposal", stream: "review", payload: planproposaleventpayload(card) };
1086
+ }
1087
+ function widgetview(input) {
1088
+ const cards = reviewcardsof(input.events);
1089
+ const answered = new Set(
1090
+ input.events.filter((event) => event.kind === "planreview").map((event) => typeof event.payload.proposalid === "string" ? event.payload.proposalid : "").filter((id) => id !== "")
1091
+ );
1092
+ return {
1093
+ status: input.status,
1094
+ rows: chatrowsof(input.events, input.memberid),
1095
+ cards,
1096
+ pending: cards.filter((card) => !answered.has(card.proposalid)).length
1097
+ };
1098
+ }
1099
+ function pairingpanel(record, now) {
1100
+ const countdown = pairingcountdown(record, now);
1101
+ return {
1102
+ code: record.code.code,
1103
+ secondsleft: countdown.secondsleft,
1104
+ expired: countdown.expired,
1105
+ label: countdown.label
1106
+ };
1107
+ }
1108
+ function sitemanifest() {
1109
+ return sitemanifestof();
1110
+ }
1111
+ function bridgestatuslabel(view) {
1112
+ if (view.status === "connected")
1113
+ return `Bridge: connected${view.paired ? " and paired" : ""}${view.queued > 0 ? ` \xB7 ${view.queued} queued frame${view.queued === 1 ? "" : "s"}` : ""}.`;
1114
+ if (view.status === "paired")
1115
+ return `Bridge: paired, socket offline${view.queued > 0 ? ` \xB7 ${view.queued} queued frame${view.queued === 1 ? "" : "s"}` : ""}.`;
1116
+ if (view.status === "offline")
1117
+ return `Bridge: offline${view.queued > 0 ? ` \xB7 ${view.queued} queued frame${view.queued === 1 ? "" : "s"}` : ""}.`;
1118
+ return "Bridge: disabled (no relay url set).";
1119
+ }
1120
+ var wsbridgelocalhosts = ["127.0.0.1", "localhost", "::1", "[::1]"];
1121
+ var wsbridgestreamname = "nativetransport";
1122
+ function wsbridgebindcheck(input) {
1123
+ const bind = (input.bind ?? "").trim() === "" ? "127.0.0.1" : (input.bind ?? "").trim();
1124
+ if (!wsbridgelocalhosts.includes(bind))
1125
+ return {
1126
+ ok: false,
1127
+ bind,
1128
+ port: 0,
1129
+ reason: `The wsbridge binds a localhost address only; the ${bind} address accepts connections from other machines and the bridge never leaves the machine.`
1130
+ };
1131
+ const port = input.port ?? 0;
1132
+ if (!Number.isInteger(port) || port < 0 || port > 65535)
1133
+ return {
1134
+ ok: false,
1135
+ bind,
1136
+ port: 0,
1137
+ reason: `The wsbridge port stays a whole number between zero and 65535; the zero port asks the socket for a random free port.`
1138
+ };
1139
+ return { ok: true, bind, port };
1140
+ }
1141
+ function wsbridgesessionstart(input) {
1142
+ if (!Number.isInteger(input.port) || input.port < 0 || input.port > 65535)
1143
+ throw new Error("The wsbridge session port stays a whole number between zero and 65535.");
1144
+ const token = input.token.trim();
1145
+ if (token === "")
1146
+ throw new Error("The wsbridge session carries its per session token; an empty token authenticates nothing.");
1147
+ if (input.idlewindow !== void 0 && (!Number.isFinite(input.idlewindow) || input.idlewindow <= 0))
1148
+ throw new Error("The wsbridge idle window stays a positive millisecond count the user chose.");
1149
+ return {
1150
+ id: input.id ?? `wsbridge-${input.now}`,
1151
+ port: input.port,
1152
+ tokenhash: input.hashof(token),
1153
+ boundat: input.now,
1154
+ ...input.idlewindow !== void 0 ? { idlewindow: input.idlewindow, expiresat: input.now + input.idlewindow } : {},
1155
+ extensionconnected: false,
1156
+ connections: 0,
1157
+ received: 0,
1158
+ sent: 0
1159
+ };
1160
+ }
1161
+ function wsbridgeconnection(session, now) {
1162
+ const idlewindow = session.idlewindow;
1163
+ return {
1164
+ ...session,
1165
+ connections: session.connections + 1,
1166
+ lastframeat: now,
1167
+ ...idlewindow !== void 0 ? { expiresat: now + idlewindow } : {}
1168
+ };
1169
+ }
1170
+ function wsbridgeextensionconnect(session, now) {
1171
+ if (session.extensionconnected)
1172
+ return {
1173
+ refused: `The wsbridge session holds one extension connection at a time; the extension side of the session ${session.id} stays taken.`
1174
+ };
1175
+ const connected = wsbridgeconnection(session, now);
1176
+ return { session: { ...connected, extensionconnected: true } };
1177
+ }
1178
+ function wsbridgeframeauth(session, token, hashof) {
1179
+ const trimmed = (token ?? "").trim();
1180
+ if (trimmed === "")
1181
+ return {
1182
+ ok: false,
1183
+ reason: "The wsbridge frame carries its session token; an anonymous frame refuses at the door."
1184
+ };
1185
+ if (hashof(trimmed) !== session.tokenhash)
1186
+ return {
1187
+ ok: false,
1188
+ reason: `The wsbridge frame token fails the session ${session.id} authentication; a wrong token never reaches the body.`
1189
+ };
1190
+ return { ok: true };
1191
+ }
1192
+ function wsbridgeidlesweep(session, now) {
1193
+ if (session.idlewindow === void 0 || session.expiresat === void 0) return { expired: false, session };
1194
+ if (session.lastframeat !== void 0 && session.lastframeat > session.expiresat - session.idlewindow) {
1195
+ const slid = { ...session, expiresat: session.lastframeat + session.idlewindow };
1196
+ if (now < slid.expiresat) return { expired: false, session: slid };
1197
+ }
1198
+ if (now >= session.expiresat)
1199
+ return {
1200
+ expired: true,
1201
+ session,
1202
+ reason: `The wsbridge session ${session.id} sat quiet past its ${session.idlewindow} millisecond idle window; the session expired and the token stopped verifying.`
1203
+ };
1204
+ return { expired: false, session };
1205
+ }
1206
+ function wsbridgeenvelopeof(input) {
1207
+ return composeenvelope({
1208
+ op: "eventpost",
1209
+ opid: input.opid,
1210
+ at: input.at,
1211
+ version: input.version ?? servercontractversion,
1212
+ ...input.sessionid !== void 0 && input.sessionid !== "" ? { sessionid: input.sessionid } : {},
1213
+ ...input.token !== void 0 && input.token !== "" ? { token: input.token } : {},
1214
+ body: { kind: "progress", stream: wsbridgestreamname, payload: { frame: input.frame } }
1215
+ });
1216
+ }
1217
+ function wsbridgeframeof(envelope) {
1218
+ if (envelope.op !== "eventpost")
1219
+ return {
1220
+ reason: `The wsbridge envelope carries the eventpost operation; a ${envelope.op} envelope never reaches the native transport.`
1221
+ };
1222
+ const body = envelope.body ?? {};
1223
+ if (body.stream !== wsbridgestreamname)
1224
+ return {
1225
+ reason: `The wsbridge envelope rides the ${wsbridgestreamname} stream; a ${String(body.stream)} envelope stays outside the native transport.`
1226
+ };
1227
+ const frame = body.payload;
1228
+ if (frame === void 0 || frame === null || typeof frame !== "object" || Array.isArray(frame))
1229
+ return { reason: "The wsbridge envelope payload carries the native frame object." };
1230
+ const candidate = frame.frame;
1231
+ if (candidate === void 0 || candidate === null || typeof candidate !== "object" || Array.isArray(candidate))
1232
+ return { reason: "The wsbridge envelope payload wraps its native frame under the frame key." };
1233
+ const typed = candidate;
1234
+ if (typeof typed.kind !== "string" || typeof typed.correlationid !== "string")
1235
+ return { reason: "The wsbridge native frame carries its kind and its correlation id." };
1236
+ return {
1237
+ frame: {
1238
+ kind: typed.kind,
1239
+ correlationid: typed.correlationid,
1240
+ ...typeof typed.sessionid === "string" ? { sessionid: typed.sessionid } : {},
1241
+ ...typed.body !== void 0 && typed.body !== null && typeof typed.body === "object" && !Array.isArray(typed.body) ? { body: typed.body } : {}
1242
+ }
1243
+ };
1244
+ }
1245
+ function wsbridgeadvertiseframe(session, token, correlationid) {
1246
+ const trimmed = token.trim();
1247
+ if (trimmed === "")
1248
+ throw new Error("The wsbridge advertisement carries the per session token; an empty token advertises nothing.");
1249
+ return {
1250
+ kind: "advertisement",
1251
+ correlationid,
1252
+ body: {
1253
+ port: session.port,
1254
+ token: trimmed,
1255
+ ...session.idlewindow !== void 0 ? { idlewindow: session.idlewindow } : {}
1256
+ }
1257
+ };
1258
+ }
1259
+ function wsbridgereport(session, now) {
1260
+ const sweep = wsbridgeidlesweep(session, now);
1261
+ return {
1262
+ id: session.id,
1263
+ port: session.port,
1264
+ connections: session.connections,
1265
+ extensionconnected: session.extensionconnected,
1266
+ expired: sweep.expired,
1267
+ received: session.received,
1268
+ sent: session.sent
1269
+ };
1270
+ }
1271
+ function wsbridgeframecounted(session, direction, now) {
1272
+ const idlewindow = session.idlewindow;
1273
+ return {
1274
+ ...session,
1275
+ received: session.received + (direction === "received" ? 1 : 0),
1276
+ sent: session.sent + (direction === "sent" ? 1 : 0),
1277
+ lastframeat: now,
1278
+ ...idlewindow !== void 0 ? { expiresat: now + idlewindow } : {}
1279
+ };
1280
+ }
1281
+ var nativebridgeprotocolmajor = 1;
1282
+ var nativehostinstallerversion = protocolversion;
1283
+ var nativehostidplaceholder = "__generated_extension_id__";
1284
+ var nativemessagingdirname = "NativeMessagingHosts";
1285
+ function nativesurfacecatalog() {
1286
+ return [
1287
+ {
1288
+ surface: "osdialog",
1289
+ callclass: "sensitive",
1290
+ description: "Opens one os dialog on the user desktop; the surface addresses the user directly, so the call class stays sensitive and the surface asks for its own consent grant."
1291
+ },
1292
+ {
1293
+ surface: "notification",
1294
+ callclass: "interaction",
1295
+ description: "Posts one os notification on the user desktop; the surface writes outside the browser, so the call class stays interaction and the surface asks for its own consent grant."
1296
+ }
1297
+ ];
1298
+ }
1299
+ function nativehostcapabilities() {
1300
+ return {
1301
+ protocol: nativebridgeprotocolmajor,
1302
+ surfaces: nativesurfacecatalog().map((entry) => entry.surface),
1303
+ heartbeat: true
1304
+ };
1305
+ }
1306
+ function nativehostmanifesttemplate(input) {
1307
+ const hostname = input.hostname.trim();
1308
+ if (hostname === "") throw new Error("The native host manifest names its host; an empty host name never registers.");
1309
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(hostname))
1310
+ throw new Error(
1311
+ `The native host name ${hostname} stays a plain dns style token; a name with spaces or capitals never registers.`
1312
+ );
1313
+ const companionpath = input.companionpath.trim();
1314
+ if (companionpath === "")
1315
+ throw new Error(
1316
+ "The native host manifest carries the companion path the user chose; an empty path never launches a host."
1317
+ );
1318
+ const extensionid = (input.extensionid ?? "").trim();
1319
+ const scheme = "chrome-extension:";
1320
+ const origin = extensionid === "" ? `${scheme}//${nativehostidplaceholder}/` : `${scheme}//${extensionid}/`;
1321
+ const manifest = {
1322
+ name: hostname,
1323
+ description: "The devthink companion process: an optional native host that speaks length prefixed json over stdio and never runs until the user installs it.",
1324
+ path: companionpath,
1325
+ type: "stdio",
1326
+ allowed_origins: [origin]
1327
+ };
1328
+ return { manifest, text: `${JSON.stringify(manifest, null, 2)}
1329
+ ` };
1330
+ }
1331
+ function trailslashes(value) {
1332
+ let end = value.length;
1333
+ while (end > 0) {
1334
+ const last = value.charCodeAt(end - 1);
1335
+ if (last !== 47 && last !== 92) break;
1336
+ end -= 1;
1337
+ }
1338
+ return value.slice(0, end);
1339
+ }
1340
+ function hostmanifestdestination(input) {
1341
+ const hostname = input.hostname.trim();
1342
+ if (hostname === "")
1343
+ return {
1344
+ path: "",
1345
+ systemwide: false,
1346
+ refused: "The host manifest destination names its host; an empty host name never writes."
1347
+ };
1348
+ const systemwide = input.systemwide === true;
1349
+ const profiledir = (input.profiledir ?? "").trim();
1350
+ if (!systemwide && profiledir === "")
1351
+ return {
1352
+ path: "",
1353
+ systemwide: false,
1354
+ refused: "The installer writes the host manifest into the user profile directory; a system wide install needs the explicit flag and the user never gets one silently."
1355
+ };
1356
+ if (systemwide) {
1357
+ const platform = input.platform ?? "linux";
1358
+ const base = platform === "linux" ? "/etc/opt/chrome/native-messaging-hosts" : platform === "macos" ? "/Library/Google/Chrome/NativeMessagingHosts" : "C:\\Program Files\\Google\\Chrome\\Application\\native-messaging-hosts";
1359
+ return { path: `${base}/${hostname}.json`, systemwide: true };
1360
+ }
1361
+ return { path: `${trailslashes(profiledir)}/${nativemessagingdirname}/${hostname}.json`, systemwide: false };
1362
+ }
1363
+ async function installnativehost(input) {
1364
+ if (!input.consent)
1365
+ return {
1366
+ state: nativedefaultstate(),
1367
+ manifestpath: "",
1368
+ refused: "The install consent gate explains the scope before any host registration; the installer writes no manifest without the recorded consent."
1369
+ };
1370
+ const extensionid = input.extensionid.trim();
1371
+ if (extensionid === "")
1372
+ return {
1373
+ state: nativedefaultstate(),
1374
+ manifestpath: "",
1375
+ refused: "The host manifest allows the origins of one extension id; an empty id never registers a host."
1376
+ };
1377
+ if (input.systemwide === true && (input.profiledir ?? "").trim() !== "")
1378
+ return {
1379
+ state: nativedefaultstate(),
1380
+ manifestpath: "",
1381
+ refused: "The install targets either the user profile directory or, with the explicit flag, the system directory; never both at once."
1382
+ };
1383
+ const destination = hostmanifestdestination({
1384
+ hostname: input.hostname,
1385
+ ...input.profiledir !== void 0 ? { profiledir: input.profiledir } : {},
1386
+ ...input.systemwide !== void 0 ? { systemwide: input.systemwide } : {},
1387
+ ...input.platform !== void 0 ? { platform: input.platform } : {}
1388
+ });
1389
+ if (destination.refused !== void 0)
1390
+ return { state: nativedefaultstate(), manifestpath: "", refused: destination.refused };
1391
+ const template = nativehostmanifesttemplate({
1392
+ hostname: input.hostname,
1393
+ companionpath: input.companionpath,
1394
+ extensionid
1395
+ });
1396
+ const dir = destination.path.slice(0, destination.path.lastIndexOf("/"));
1397
+ await input.io.mkdir(dir);
1398
+ await input.io.writefile(destination.path, template.text);
1399
+ const state = {
1400
+ installed: true,
1401
+ hostname: template.manifest.name,
1402
+ extensionid,
1403
+ installerversion: nativehostinstallerversion,
1404
+ port: "detached",
1405
+ installedat: input.now,
1406
+ updatedat: input.now,
1407
+ lasterrors: []
1408
+ };
1409
+ return { state, manifestpath: destination.path };
1410
+ }
1411
+ async function uninstallnativehost(input) {
1412
+ const destination = hostmanifestdestination({
1413
+ hostname: input.hostname,
1414
+ ...input.profiledir !== void 0 ? { profiledir: input.profiledir } : {},
1415
+ ...input.systemwide !== void 0 ? { systemwide: input.systemwide } : {},
1416
+ ...input.platform !== void 0 ? { platform: input.platform } : {}
1417
+ });
1418
+ if (destination.refused !== void 0)
1419
+ return { state: nativedefaultstate(), manifestpath: "", removed: false, refused: destination.refused };
1420
+ const present = await input.io.exists(destination.path);
1421
+ if (present) await input.io.removefile(destination.path);
1422
+ return { state: nativedefaultstate(), manifestpath: destination.path, removed: present };
1423
+ }
1424
+ function nativedefaultstate() {
1425
+ return { installed: false, port: "detached", lasterrors: [] };
1426
+ }
1427
+ function nativechoices(settings) {
1428
+ const current = settings ?? {};
1429
+ return {
1430
+ ...current.nativeinstallconsent !== void 0 ? { nativeinstallconsent: current.nativeinstallconsent } : {},
1431
+ ...current.nativetransportconsent !== void 0 ? { nativetransportconsent: current.nativetransportconsent } : {},
1432
+ ...current.nativecallclassconsents !== void 0 ? { nativecallclassconsents: current.nativecallclassconsents } : {},
1433
+ ...current.nativesurfaceconsents !== void 0 ? { nativesurfaceconsents: current.nativesurfaceconsents } : {},
1434
+ ...current.nativeidlewindow !== void 0 ? { nativeidlewindow: current.nativeidlewindow } : {},
1435
+ ...current.nativeheartbeatinterval !== void 0 ? { nativeheartbeatinterval: current.nativeheartbeatinterval } : {},
1436
+ ...current.nativecallratelimit !== void 0 ? { nativecallratelimit: current.nativecallratelimit } : {},
1437
+ ...current.nativecallratewindow !== void 0 ? { nativecallratewindow: current.nativecallratewindow } : {}
1438
+ };
1439
+ }
1440
+ function nativetransportenabled(state, settings) {
1441
+ return (state?.installed ?? false) && settings?.nativetransportconsent === true;
1442
+ }
1443
+ function nativecorrelationid(seed, sequence) {
1444
+ const trimmed = seed.trim();
1445
+ if (trimmed === "")
1446
+ throw new Error("The correlation id names its sender seed; an empty seed never correlates a frame.");
1447
+ if (!Number.isInteger(sequence) || sequence < 1)
1448
+ throw new Error("The correlation id sequence stays a positive whole number per run.");
1449
+ return `run-${trimmed}-${sequence}`;
1450
+ }
1451
+ function nativeframeof(kind, correlationid, body, sessionid) {
1452
+ const trimmed = correlationid.trim();
1453
+ if (trimmed === "")
1454
+ throw new Error("The native frame carries its correlation id; an empty id never correlates a frame.");
1455
+ return {
1456
+ kind,
1457
+ correlationid: trimmed,
1458
+ ...sessionid !== void 0 && sessionid !== "" ? { sessionid } : {},
1459
+ ...body !== void 0 ? { body } : {}
1460
+ };
1461
+ }
1462
+ function companionhandshakeframe(correlationid) {
1463
+ return nativeframeof("handshake", correlationid, { protocol: nativebridgeprotocolmajor });
1464
+ }
1465
+ function parsecompanionhandshake(frame, now) {
1466
+ if (frame.kind !== "handshake")
1467
+ return {
1468
+ error: nativeerrorof(
1469
+ "handshake",
1470
+ `The handshake answer carries the handshake kind; a ${frame.kind} frame never completes a handshake.`,
1471
+ "reconnect",
1472
+ now
1473
+ )
1474
+ };
1475
+ const body = frame.body ?? {};
1476
+ const build = typeof body.build === "string" ? body.build.trim() : "";
1477
+ if (build === "")
1478
+ return {
1479
+ error: nativeerrorof(
1480
+ "handshake",
1481
+ "The handshake answer carries the companion build version; an empty version never attaches.",
1482
+ "reconnect",
1483
+ now
1484
+ )
1485
+ };
1486
+ const protocol = typeof body.protocol === "number" ? body.protocol : Number.parseInt(String(body.protocol ?? ""), 10);
1487
+ if (!Number.isInteger(protocol) || protocol < 1)
1488
+ return {
1489
+ error: nativeerrorof(
1490
+ "handshake",
1491
+ "The handshake answer carries its native bridge protocol version as a positive whole number.",
1492
+ "reconnect",
1493
+ now
1494
+ )
1495
+ };
1496
+ const surfaces = Array.isArray(body.surfaces) ? body.surfaces.filter(
1497
+ (surface) => surface === "osdialog" || surface === "notification"
1498
+ ) : [];
1499
+ const wsbridgeport = typeof body.wsbridgeport === "number" ? body.wsbridgeport : 0;
1500
+ if (!Number.isInteger(wsbridgeport) || wsbridgeport < 0)
1501
+ return {
1502
+ error: nativeerrorof(
1503
+ "handshake",
1504
+ "The handshake answer carries the wsbridge port as a whole number; zero keeps the bridge down.",
1505
+ "reconnect",
1506
+ now
1507
+ )
1508
+ };
1509
+ return { handshake: { build, protocol: String(protocol), surfaces, wsbridgeport } };
1510
+ }
1511
+ function nativemajorversion(protocol) {
1512
+ const value = typeof protocol === "number" ? String(protocol) : protocol.trim();
1513
+ const major = Number.parseInt(value.split(/[.\s]/)[0] ?? "", 10);
1514
+ return Number.isInteger(major) && major >= 1 ? major : 0;
1515
+ }
1516
+ function nativeprotocolcompatible(ours, theirs) {
1517
+ const ourmajor = nativemajorversion(ours);
1518
+ const theirmajor = nativemajorversion(theirs);
1519
+ return { ok: ourmajor === theirmajor && ourmajor >= 1, ours: ourmajor, theirs: theirmajor };
1520
+ }
1521
+ function negotiatenativecapabilities(input) {
1522
+ const ours = input.ours ?? nativehostcapabilities();
1523
+ const compat = nativeprotocolcompatible(ours.protocol, input.theirs.protocol);
1524
+ if (!compat.ok)
1525
+ return {
1526
+ ok: false,
1527
+ protocol: 0,
1528
+ surfaces: [],
1529
+ heartbeat: false,
1530
+ reason: `The companion speaks the native bridge protocol major version ${compat.theirs} while this build speaks ${compat.ours}; the upgrade path keeps compatibility for one major version and the run degrades with the transport off.`
1531
+ };
1532
+ const order = nativesurfacecatalog().map((entry) => entry.surface);
1533
+ const surfaces = order.filter((surface) => input.theirs.surfaces.includes(surface));
1534
+ return { ok: true, protocol: compat.ours, surfaces, heartbeat: ours.heartbeat && input.theirs.heartbeat === true };
1535
+ }
1536
+ function attachnativehost(state, handshake, now) {
1537
+ return {
1538
+ ...state,
1539
+ installed: true,
1540
+ port: "attached",
1541
+ companionversion: handshake.build,
1542
+ companionprotocol: handshake.protocol,
1543
+ wsbridgeport: handshake.wsbridgeport,
1544
+ attachedat: now,
1545
+ updatedat: now
1546
+ };
1547
+ }
1548
+ function crashnativehost(state, now) {
1549
+ return {
1550
+ ...state,
1551
+ port: "crashed",
1552
+ updatedat: now,
1553
+ lasterrors: [
1554
+ nativeerrorof(
1555
+ "port",
1556
+ "The companion process crashed under the native port; the run stays alive and the extension reattaches on the next host start.",
1557
+ "reconnect",
1558
+ now
1559
+ ),
1560
+ ...state.lasterrors ?? []
1561
+ ].slice(0, 10)
1562
+ };
1563
+ }
1564
+ function reattachnativehost(state, handshake, now) {
1565
+ return { ...attachnativehost(state, handshake, now), updatedat: now };
1566
+ }
1567
+ function detachnativehost(state, now) {
1568
+ return { ...state, port: "detached", updatedat: now };
1569
+ }
1570
+ function nativeheartbeatframe(correlationid, now) {
1571
+ return nativeframeof("heartbeat", correlationid, { at: now });
1572
+ }
1573
+ function nativeportliveness(input) {
1574
+ if (input.interval === void 0)
1575
+ return {
1576
+ alive: true,
1577
+ reason: "The heartbeat interval stays unset; the liveness check never expires a host without the user configured cadence."
1578
+ };
1579
+ if (input.lastheartbeatat === void 0)
1580
+ return {
1581
+ alive: false,
1582
+ reason: "The native port heard no heartbeat yet; the host stays silent under the configured interval."
1583
+ };
1584
+ if (input.now - input.lastheartbeatat > input.interval)
1585
+ return {
1586
+ alive: false,
1587
+ reason: `The last heartbeat sits ${input.now - input.lastheartbeatat} milliseconds back, past the ${input.interval} millisecond interval; the host process stays silent and the extension reattaches on its restart.`
1588
+ };
1589
+ return { alive: true };
1590
+ }
1591
+ function nativeframecheck(frame, sessionid) {
1592
+ if (frame.correlationid.trim() === "")
1593
+ return {
1594
+ allowed: false,
1595
+ reason: "The native frame carries its correlation id; an anonymous frame never reaches the engine."
1596
+ };
1597
+ if (sessionid.trim() === "")
1598
+ return {
1599
+ allowed: false,
1600
+ reason: "The native transport pairs its frames with the session id; a transport without a session never accepts a frame."
1601
+ };
1602
+ if (frame.sessionid !== void 0 && frame.sessionid !== sessionid)
1603
+ return {
1604
+ allowed: false,
1605
+ reason: `The native frame session ${frame.sessionid} sits outside the paired session ${sessionid}; the origin and session checks refuse the frame.`
1606
+ };
1607
+ return { allowed: true };
1608
+ }
1609
+ var nativesecretkeys = [
1610
+ "apikey",
1611
+ "api_key",
1612
+ "key",
1613
+ "token",
1614
+ "secret",
1615
+ "password",
1616
+ "authorization",
1617
+ "credential",
1618
+ "privatekey"
1619
+ ];
1620
+ function nativesecretexclusion(frame) {
1621
+ const body = frame.body ?? {};
1622
+ const held = Object.keys(body).filter(
1623
+ (key) => nativesecretkeys.includes(key.toLowerCase().replaceAll(" ", "").replaceAll("-", ""))
1624
+ );
1625
+ return { ok: held.length === 0, held };
1626
+ }
1627
+ function redactnativeframe(frame) {
1628
+ const body = frame.body ?? {};
1629
+ const redacted = {};
1630
+ for (const [key, value] of Object.entries(body))
1631
+ if (!nativesecretkeys.includes(key.toLowerCase().replaceAll(" ", "").replaceAll("-", ""))) redacted[key] = value;
1632
+ return { ...frame, body: redacted };
1633
+ }
1634
+ function nativeerrorof(family, message, retry, now) {
1635
+ return { family, message, retry, at: now };
1636
+ }
1637
+ function nativefailureof(error) {
1638
+ const retryhint = error.retry === "reconnect" ? "retry" : error.retry === "reinstall" ? "wait" : "none";
1639
+ return { retryhint, reason: `${error.family} failure: ${error.message}` };
1640
+ }
1641
+ function nativedegradationof(input) {
1642
+ if ((input.state?.installed ?? false) === false)
1643
+ return {
1644
+ degraded: true,
1645
+ reason: "The native host stays absent: nothing installed, the transport disabled and the run alive with every step inside the browser."
1646
+ };
1647
+ if (input.negotiated !== void 0 && !input.negotiated.ok)
1648
+ return {
1649
+ degraded: true,
1650
+ reason: input.negotiated.reason ?? "The native host speaks another native bridge protocol major version; the run stays alive with the transport off."
1651
+ };
1652
+ if (input.state?.port === "crashed")
1653
+ return {
1654
+ degraded: true,
1655
+ reason: "The native host crashed under the port; the run stays alive and waits for the reattach on the host restart."
1656
+ };
1657
+ return {
1658
+ degraded: false,
1659
+ reason: "The native host sits attached with a negotiated capability set; the transport carries the consented call classes."
1660
+ };
1661
+ }
1662
+ function nativeratecheck(input) {
1663
+ if (input.cap === void 0) return { allowed: true, used: input.calls.length };
1664
+ if (!Number.isFinite(input.cap) || input.cap < 1)
1665
+ return {
1666
+ allowed: false,
1667
+ used: input.calls.length,
1668
+ cap: input.cap,
1669
+ reason: `The native transport rate cap of ${String(input.cap)} stays a finite positive count.`
1670
+ };
1671
+ const window = input.window ?? Number.POSITIVE_INFINITY;
1672
+ const used = input.calls.filter(
1673
+ (record) => window === Number.POSITIVE_INFINITY || input.now - record.at <= window
1674
+ ).length;
1675
+ if (used >= input.cap)
1676
+ return {
1677
+ allowed: false,
1678
+ used,
1679
+ cap: input.cap,
1680
+ reason: `The native transport hit its ${input.cap} call cap with ${used} calls inside the window; the cap stays the user's choice and the session waits.`
1681
+ };
1682
+ return { allowed: true, used, cap: input.cap };
1683
+ }
1684
+ function nativecallrecordof(input) {
1685
+ return {
1686
+ id: input.id,
1687
+ correlationid: input.correlationid,
1688
+ surface: input.surface,
1689
+ callclass: input.callclass,
1690
+ outcome: input.outcome,
1691
+ ...input.reason !== void 0 && input.reason !== "" ? { reason: input.reason } : {},
1692
+ at: input.now
1693
+ };
1694
+ }
1695
+ function recordnativecall(records, record) {
1696
+ return [record, ...records.filter((candidate) => candidate.id !== record.id)];
1697
+ }
1698
+ function nativecallevent(record) {
1699
+ return notificationframe("native/call", {
1700
+ surface: record.surface,
1701
+ callclass: record.callclass,
1702
+ outcome: record.outcome,
1703
+ correlationid: record.correlationid,
1704
+ at: record.at
1705
+ });
1706
+ }
1707
+ function nativesurfacegrant(surface, settings) {
1708
+ const known = nativesurfacecatalog().find((entry) => entry.surface === surface);
1709
+ if (known === void 0)
1710
+ return {
1711
+ allowed: false,
1712
+ reason: `The native surface ${surface} sits outside the surface catalog; an unknown surface never grants.`
1713
+ };
1714
+ if ((settings?.nativesurfaceconsents ?? []).includes(known.surface))
1715
+ return {
1716
+ allowed: true,
1717
+ reason: `The user granted the ${known.surface} surface its own consent stamp; the surface runs behind the class gate too.`
1718
+ };
1719
+ return {
1720
+ allowed: false,
1721
+ reason: `The native surface ${known.surface} holds no consent grant; a desktop surface never opens from a class grant alone.`
1722
+ };
1723
+ }
1724
+ function nativeclassgrant(callclass, settings) {
1725
+ if ((settings?.nativecallclassconsents ?? []).includes(callclass))
1726
+ return { allowed: true, reason: `The user consented to the ${callclass} call class over the native transport.` };
1727
+ return {
1728
+ allowed: false,
1729
+ reason: `The ${callclass} call class holds no consent grant over the native transport; the gate asks per class and never widens a read grant.`
1730
+ };
1731
+ }
1732
+ function nativesurfaceresult(input) {
1733
+ const catalog = nativesurfacecatalog().find((entry) => entry.surface === input.surface);
1734
+ const callclass = catalog?.callclass ?? input.callclass;
1735
+ const held = Object.keys(input.details).filter(
1736
+ (key) => nativesecretkeys.includes(key.toLowerCase().replaceAll(" ", "").replaceAll("-", ""))
1737
+ );
1738
+ const details = { ...input.details };
1739
+ for (const key of held) delete details[key];
1740
+ return { surface: input.surface, callclass, details, at: input.now };
1741
+ }
1742
+ function nativediagnostics(input) {
1743
+ const state = input.state ?? nativedefaultstate();
1744
+ const settings = input.settings;
1745
+ const sessions = (input.sessions ?? []).map((session) => ({
1746
+ port: session.port,
1747
+ connections: session.connections,
1748
+ expired: session.expiresat !== void 0 && session.expiresat <= input.now
1749
+ }));
1750
+ return {
1751
+ installed: state.installed,
1752
+ port: state.port,
1753
+ ...state.hostname !== void 0 ? { hostname: state.hostname } : {},
1754
+ ...state.extensionid !== void 0 ? { extensionid: state.extensionid } : {},
1755
+ ...state.installerversion !== void 0 ? { installerversion: state.installerversion } : {},
1756
+ ...state.companionversion !== void 0 ? { companionversion: state.companionversion } : {},
1757
+ ...state.companionprotocol !== void 0 ? { companionprotocol: state.companionprotocol } : {},
1758
+ ...state.wsbridgeport !== void 0 ? { wsbridgeport: state.wsbridgeport } : {},
1759
+ nativebridgeprotocol: nativebridgeprotocolmajor,
1760
+ degraded: nativedegradationof({
1761
+ state,
1762
+ ...input.negotiated !== void 0 ? { negotiated: input.negotiated } : {}
1763
+ }),
1764
+ transportconsent: settings?.nativetransportconsent === true,
1765
+ classconsents: settings?.nativecallclassconsents ?? [],
1766
+ surfaceconsents: settings?.nativesurfaceconsents ?? [],
1767
+ sessions,
1768
+ lasterrors: state.lasterrors ?? []
1769
+ };
1770
+ }
1771
+ export {
1772
+ attachnativehost,
1773
+ bridgeframerate,
1774
+ bridgepayload,
1775
+ bridgestatuslabel,
1776
+ bridgestatusview,
1777
+ carddecision,
1778
+ chateventof,
1779
+ chateventpayload,
1780
+ chatrowsof,
1781
+ companionhandshakeframe,
1782
+ composeenvelope,
1783
+ connectrelay,
1784
+ contractcapabilities,
1785
+ crashnativehost,
1786
+ decisionpayload,
1787
+ detachnativehost,
1788
+ disconnectrelay,
1789
+ enqueuebridge,
1790
+ envelopeacceptance,
1791
+ eventpostbody,
1792
+ eventstreambody,
1793
+ frameauth,
1794
+ frameof,
1795
+ heartbeatevent,
1796
+ heartbeattick,
1797
+ hostmanifestdestination,
1798
+ idleexpired,
1799
+ installnativehost,
1800
+ minimalplandigest,
1801
+ nativebridgeprotocolmajor,
1802
+ nativecallevent,
1803
+ nativecallrecordof,
1804
+ nativechoices,
1805
+ nativeclassgrant,
1806
+ nativecorrelationid,
1807
+ nativedefaultstate,
1808
+ nativedegradationof,
1809
+ nativediagnostics,
1810
+ nativeerrorof,
1811
+ nativefailureof,
1812
+ nativeframecheck,
1813
+ nativeframeof,
1814
+ nativeheartbeatframe,
1815
+ nativehostcapabilities,
1816
+ nativehostidplaceholder,
1817
+ nativehostinstallerversion,
1818
+ nativehostmanifesttemplate,
1819
+ nativemajorversion,
1820
+ nativemessagingdirname,
1821
+ nativeportliveness,
1822
+ nativeprotocolcompatible,
1823
+ nativeratecheck,
1824
+ nativesecretexclusion,
1825
+ nativesecretkeys,
1826
+ nativesurfacecatalog,
1827
+ nativesurfacegrant,
1828
+ nativesurfaceresult,
1829
+ nativetransportenabled,
1830
+ negotiatecapabilities,
1831
+ negotiatenativecapabilities,
1832
+ newrelayclient,
1833
+ pagecontentkeys,
1834
+ pairingpanel,
1835
+ parsecompanionhandshake,
1836
+ parseenvelope,
1837
+ parsewireframe,
1838
+ planproposaleventof,
1839
+ planproposaleventpayload,
1840
+ planrevieweventpayload,
1841
+ postevent,
1842
+ progresseventpayload,
1843
+ reattachnativehost,
1844
+ receiveframe,
1845
+ recordnativecall,
1846
+ redactnativeframe,
1847
+ relayorigin,
1848
+ replaybridgequeue,
1849
+ reviewcardsof,
1850
+ reviewgateoutcome,
1851
+ sendframe,
1852
+ servercontractversion,
1853
+ servereventtypes,
1854
+ serveroperations,
1855
+ sessioncreatebody,
1856
+ sessionjoinbody,
1857
+ sitemanifest,
1858
+ sitemanifestof,
1859
+ stableopid,
1860
+ uninstallnativehost,
1861
+ verifyframeauth,
1862
+ widgetview,
1863
+ wsbridgeadvertiseframe,
1864
+ wsbridgebindcheck,
1865
+ wsbridgeconnection,
1866
+ wsbridgeenvelopeof,
1867
+ wsbridgeextensionconnect,
1868
+ wsbridgeframeauth,
1869
+ wsbridgeframecounted,
1870
+ wsbridgeframeof,
1871
+ wsbridgeidlesweep,
1872
+ wsbridgelocalhosts,
1873
+ wsbridgereport,
1874
+ wsbridgesessionstart,
1875
+ wsbridgestreamname
1876
+ };
1877
+ //# sourceMappingURL=bridge.js.map