@tokenoftrust/storefront-runner 7.3.2 → 7.5.1

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 (420) hide show
  1. package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
  2. package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
  3. package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
  4. package/apps/storefront/astro.config.mjs +8 -2
  5. package/apps/storefront/package.json +1 -2
  6. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
  7. package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
  8. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
  9. package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
  10. package/apps/storefront/src/layouts/Layout.astro +17 -0
  11. package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
  12. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +32 -8
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
  14. package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
  15. package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
  16. package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
  17. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  18. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  19. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  20. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  21. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  22. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  23. package/apps/storefront/src/lib/activity/store.ts +9 -3
  24. package/apps/storefront/src/lib/checkout/agent/checkoutProtocol.ts +196 -0
  25. package/apps/storefront/src/lib/checkout/agent/checkoutSession.ts +296 -0
  26. package/apps/storefront/src/lib/checkout/agent/webBotAuth.ts +347 -0
  27. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  28. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  29. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  30. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  31. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  32. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  33. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +522 -0
  34. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  35. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  36. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  37. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  38. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  39. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  40. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  41. package/apps/storefront/src/middleware/index.ts +7 -3
  42. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  43. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  44. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  45. package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +9 -0
  46. package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +8 -0
  47. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  48. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  49. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  50. package/apps/storefront/tsconfig.astro.json +11 -0
  51. package/package.json +1 -1
  52. package/packages/public-runtime/src/activity/README.md +12 -0
  53. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  54. package/packages/public-runtime/src/activity/event.ts +19 -0
  55. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  56. package/packages/public-runtime/src/catalog-files.ts +3 -2
  57. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  58. package/packages/public-runtime/src/checkout.ts +70 -0
  59. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  60. package/packages/public-runtime/src/compliance/index.ts +1 -1
  61. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  62. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  63. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  64. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  65. package/packages/public-runtime/src/product.ts +9 -1
  66. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  67. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  68. package/pnpm-lock.runner.yaml +0 -15
  69. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  70. package/scripts/tenant/validate.mjs +128 -0
  71. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  72. package/apps/storefront/drizzle.config.apps.ts +0 -13
  73. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  74. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  75. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  76. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  77. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  78. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  79. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  80. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  81. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  82. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  83. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  84. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  85. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  86. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  87. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  88. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  89. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  90. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  91. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  92. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  93. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  94. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  95. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  96. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  97. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  98. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  99. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  100. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  101. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  102. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  103. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  104. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  105. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  106. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  107. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  108. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  109. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  110. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  111. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  112. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  113. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  114. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  115. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  116. package/apps/storefront/perf/README.md +0 -64
  117. package/apps/storefront/perf/assert-budgets.ts +0 -159
  118. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  119. package/apps/storefront/playwright.config.ts +0 -23
  120. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  121. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  122. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  123. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  124. package/apps/storefront/public/js/dashboard-team.js +0 -356
  125. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  126. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  127. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  128. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  129. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  130. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  131. package/apps/storefront/src/config/storeName.ts +0 -34
  132. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  133. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  134. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  135. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  136. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  137. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  138. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  139. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  140. package/apps/storefront/src/lib/access/dashboard/agentStoreEntry.ts +0 -253
  141. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  142. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
  143. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
  144. package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
  145. package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
  146. package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
  147. package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
  148. package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
  149. package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
  150. package/apps/storefront/src/lib/activity/alerts.ts +0 -426
  151. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
  152. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
  153. package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
  154. package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
  155. package/apps/storefront/src/lib/activity/query.ts +0 -403
  156. package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
  157. package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
  158. package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
  159. package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
  160. package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
  161. package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
  162. package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
  163. package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
  164. package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
  165. package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
  166. package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
  167. package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
  168. package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
  169. package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
  170. package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
  171. package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
  172. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
  173. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
  174. package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
  175. package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
  176. package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
  177. package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
  178. package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
  179. package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
  180. package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
  181. package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
  182. package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
  183. package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
  184. package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
  185. package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
  186. package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
  187. package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
  188. package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
  189. package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
  190. package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
  191. package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
  192. package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
  193. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
  194. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
  195. package/apps/storefront/src/lib/content/index.ts +0 -27
  196. package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
  197. package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
  198. package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
  199. package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
  200. package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
  201. package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
  202. package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
  203. package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
  204. package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
  205. package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
  206. package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
  207. package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
  208. package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
  209. package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
  210. package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
  211. package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
  212. package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
  213. package/apps/storefront/src/lib/developer-experience/dev/agentGrantAttestation.ts +0 -74
  214. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  215. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  216. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  221. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  222. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  223. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  224. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  225. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  226. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  227. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  228. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  229. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  230. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  231. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  232. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  233. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  234. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  235. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  236. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  237. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  238. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  239. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  240. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  241. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  242. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  243. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  244. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  245. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  246. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  247. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  248. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  249. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  250. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  251. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  252. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  253. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  254. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  255. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  256. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  257. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  258. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  259. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  260. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  261. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  262. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  263. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  264. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  265. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  266. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  267. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  268. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  269. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  270. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  271. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  272. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  273. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  274. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  275. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  276. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  277. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  278. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  279. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  280. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  281. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  282. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  283. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  284. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  285. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  286. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  287. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  288. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  289. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  290. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  291. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  292. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  293. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  294. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  295. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  296. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  297. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  298. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  299. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  300. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  301. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  302. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  303. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  304. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  305. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  306. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  307. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  308. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  309. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  310. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  311. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  312. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  313. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  314. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  315. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  316. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  317. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  318. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  319. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  320. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  321. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  322. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  323. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  324. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  325. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  326. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  327. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  328. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  329. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  330. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  331. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  332. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  333. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  334. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  335. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  336. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  337. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  338. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  339. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  340. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  341. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  342. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  343. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  344. package/apps/storefront/src/pages/api/contact.ts +0 -144
  345. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  346. package/apps/storefront/src/styles/admin.css +0 -1161
  347. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  348. package/apps/storefront/test/pipeline/harness.ts +0 -209
  349. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  350. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  351. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  352. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  353. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  354. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  355. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  356. package/apps/storefront/vitest.config.cts +0 -44
  357. package/apps/storefront/vitest.faults.config.cts +0 -13
  358. package/apps/storefront/vitest.workers.config.cts +0 -7
  359. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  360. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  361. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  362. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  363. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  364. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  365. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  366. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  367. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  368. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  369. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  370. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  371. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  372. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  373. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  374. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  375. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  376. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  377. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  378. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  379. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  380. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  381. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  382. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  383. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  384. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  385. package/packages/feedback/package.json +0 -35
  386. package/packages/feedback/scripts/build-player.mjs +0 -28
  387. package/packages/feedback/src/index.ts +0 -1
  388. package/packages/feedback/src/primitives/composer.ts +0 -639
  389. package/packages/feedback/src/primitives/dialog.ts +0 -263
  390. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  391. package/packages/feedback/src/primitives/index.ts +0 -10
  392. package/packages/feedback/src/primitives/launcher.ts +0 -200
  393. package/packages/feedback/src/primitives/picker.ts +0 -663
  394. package/packages/feedback/src/primitives/redaction.ts +0 -204
  395. package/packages/feedback/src/primitives/selection.ts +0 -49
  396. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  397. package/packages/feedback/src/primitives/styles.ts +0 -77
  398. package/packages/feedback/src/primitives/surface.ts +0 -124
  399. package/packages/feedback/src/primitives/target.ts +0 -293
  400. package/packages/feedback/src/tour/canonical.ts +0 -27
  401. package/packages/feedback/src/tour/index.ts +0 -3
  402. package/packages/feedback/src/tour/player/browser.ts +0 -5
  403. package/packages/feedback/src/tour/player/host.ts +0 -12
  404. package/packages/feedback/src/tour/player/index.ts +0 -205
  405. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  406. package/packages/feedback/src/tour/player/player.css +0 -130
  407. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  408. package/packages/feedback/src/tour/player/surface.ts +0 -295
  409. package/packages/feedback/src/tour/player/types.ts +0 -8
  410. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  411. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  412. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  413. package/packages/feedback/src/tour/sanitize.ts +0 -76
  414. package/packages/feedback/src/tour/schema.ts +0 -362
  415. package/packages/feedback/src/v1/guards.ts +0 -335
  416. package/packages/feedback/src/v1/index.ts +0 -3
  417. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  418. package/packages/feedback/src/v1/types.ts +0 -177
  419. package/packages/feedback/tsconfig.json +0 -9
  420. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,116 +0,0 @@
1
- /**
2
- * Progressive stepper + staged flow. Drives Run → Edit → What's next with
3
- * progressive disclosure: only the current stage shows, completed stages
4
- * collapse to a done-bar, and the flow AUTO-ADVANCES on monitor.ts's REAL loop
5
- * signal (never a timer) — Step 1 completes when the local server is live,
6
- * Step 2 when a real save→reload is observed since the edit step began.
7
- * Consumes the shared tot:loop-state event from monitor.ts (one poll for the
8
- * whole page). Imported from a processed `<script>` in cockpit.astro (ADR
9
- * 0013), rendered only when isLocalDevLoop.
10
- *
11
- * Progress is persisted in sessionStorage. This is REQUIRED, not a nicety:
12
- * saving a watched file triggers Vite's global full-reload, which reloads
13
- * THIS /dev tab too — resetting in-memory state and re-baselining the very
14
- * save that should advance Edit→Next. Persisting done-flags + current stage +
15
- * the edit baseline (the lastSaveAt watermark captured when the edit step
16
- * began, BEFORE the qualifying save) lets the flow survive that reload and
17
- * credit the save.
18
- */
19
- export function initStepper(): void {
20
- const stepper: any = document.getElementById("stepper");
21
- if (!stepper) return;
22
- const stages: any = { run: document.getElementById("stage-run"), edit: document.getElementById("stage-edit"), next: document.getElementById("stage-next") };
23
- const bars: any = { run: document.getElementById("bar-run"), edit: document.getElementById("bar-edit") };
24
- const celRun = document.getElementById("cel-run");
25
- const celEdit = document.getElementById("cel-edit");
26
- const toNext: any = document.getElementById("toNext");
27
- const detect = document.getElementById("detect");
28
- const detectTxt = document.getElementById("detectTxt");
29
- const detectEdit = document.getElementById("detect-edit");
30
- const detectEditTxt = document.getElementById("detectEditTxt");
31
- const barRunMeta = document.getElementById("bar-run-meta");
32
- const barEditMeta = document.getElementById("bar-edit-meta");
33
- const toast = document.getElementById("toast");
34
- const toastMsg = document.getElementById("toastMsg");
35
- let tT: ReturnType<typeof setTimeout>;
36
- const reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
37
-
38
- const SS = window.sessionStorage;
39
- function load(k: string, d: any) { try { const v = SS.getItem(k); return v === null ? d : JSON.parse(v); } catch (e) { return d; } }
40
- function put(k: string, v: any) { try { SS.setItem(k, JSON.stringify(v)); } catch (e) {} }
41
-
42
- function ping(m: string, once?: string) {
43
- if (once && load(once, false)) return;
44
- if (once) put(once, true);
45
- if (!toast || !toastMsg) return;
46
- toastMsg.textContent = m; toast.classList.add("show");
47
- clearTimeout(tT); tT = setTimeout(() => { toast.classList.remove("show"); }, 1900);
48
- }
49
-
50
- const state = {
51
- unlocked: load("tot.unlocked", { run: true, edit: false, next: false }),
52
- done: load("tot.done", { run: false, edit: false }),
53
- current: load("tot.current", "run"),
54
- };
55
- let editBase = load("tot.editBase", null);
56
- function persist() { put("tot.unlocked", state.unlocked); put("tot.done", state.done); put("tot.current", state.current); }
57
-
58
- function render() {
59
- Array.prototype.forEach.call(stepper.querySelectorAll(".snode"), (n: any) => {
60
- const s = n.getAttribute("data-go");
61
- n.setAttribute("data-st", state.current === s ? "active" : state.done[s] ? "done" : state.unlocked[s] ? "done" : "locked");
62
- });
63
- Object.keys(stages).forEach((s) => { if (stages[s]) stages[s].hidden = state.current !== s; });
64
- if (bars.run) bars.run.hidden = !(state.done.run && state.current !== "run");
65
- if (bars.edit) bars.edit.hidden = !(state.done.edit && state.current !== "edit");
66
- // Contextual celebrate banners reflect achieved state (survive reloads).
67
- if (celRun && state.done.run) celRun.hidden = false;
68
- if (celEdit && state.done.edit) celEdit.hidden = false;
69
- if (toNext) toNext.disabled = !state.unlocked.next;
70
- }
71
- function goTo(s: string) {
72
- if (!state.unlocked[s]) return;
73
- state.current = s; persist(); render();
74
- window.scrollTo({ top: 0, behavior: reduce ? "auto" : "smooth" });
75
- }
76
-
77
- function onSignal(s: any) {
78
- if (!s || s.offline) return;
79
-
80
- // Step 1 — local server is live.
81
- if (s.server && !state.done.run) {
82
- state.done.run = true; state.unlocked.edit = true;
83
- if (editBase === null) { editBase = s.lastSaveAt || 0; put("tot.editBase", editBase); }
84
- persist();
85
- if (barRunMeta && s.port) barRunMeta.textContent = "localhost:" + s.port + (s.tenant ? "/" + s.tenant + "/" : "/");
86
- if (detect) detect.setAttribute("data-listening", "false");
87
- if (detectTxt) detectTxt.textContent = "Your store is live on this machine.";
88
- if (state.current === "run") { goTo("edit"); } else { render(); }
89
- ping("Your store is live", "tot.pinged.run");
90
- }
91
-
92
- // Step 2 — a NEW save (since the edit step began) has been reflected by a reload.
93
- if (state.done.run && !state.done.edit && editBase !== null) {
94
- const newSave = (s.lastSaveAt || 0) > editBase;
95
- const reflected = (s.lastSaveAt || 0) > 0 && (s.lastReloadAt || 0) >= (s.lastSaveAt || 0);
96
- if (newSave && !reflected && detectEditTxt) {
97
- detectEditTxt.textContent = "Change detected — reloading your store…";
98
- }
99
- if (newSave && reflected) {
100
- state.done.edit = true; state.unlocked.next = true; persist();
101
- if (barEditMeta && s.watchedFile) barEditMeta.textContent = s.watchedFile;
102
- if (detectEdit) detectEdit.setAttribute("data-listening", "false");
103
- if (detectEditTxt) detectEditTxt.textContent = "Saved — your store reloaded. That's the loop.";
104
- if (state.current === "edit") { goTo("next"); } else { render(); }
105
- ping("Saved — your page reloaded", "tot.pinged.edit");
106
- }
107
- }
108
- }
109
-
110
- render();
111
- Array.prototype.forEach.call(document.querySelectorAll("[data-go]"), (el: any) => {
112
- el.addEventListener("click", () => { goTo(el.getAttribute("data-go")); });
113
- });
114
- window.addEventListener("tot:loop-state", (e: any) => { onSignal(e.detail); });
115
- if (window.__totLoop) onSignal(window.__totLoop);
116
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Theme toggle: flip data-theme on <html>, seeded from the OS preference on
3
- * first click, and PERSISTED to localStorage so a reload stays on the manual
4
- * choice (the is:inline head seed script reads this same key before first
5
- * paint — that one stays is:inline because it must run synchronously before
6
- * CSS paints, the one legitimate is:inline case per ADR 0013). Clearing
7
- * storage falls back to prefers-color-scheme again, same as a first-ever
8
- * visit. Imported from a processed `<script>` in cockpit.astro.
9
- */
10
- export function initThemeToggle(): void {
11
- const root = document.documentElement;
12
- const btn = document.getElementById("themeBtn");
13
- if (!btn) return;
14
- const KEY = "tot.theme";
15
- function store(v: string) { try { localStorage.setItem(KEY, v); } catch (e) {} }
16
- btn.addEventListener("click", () => {
17
- const cur = root.getAttribute("data-theme");
18
- const next = cur === "dark" ? "light" : cur === "light" ? "dark"
19
- : (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "dark");
20
- root.setAttribute("data-theme", next);
21
- store(next);
22
- });
23
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * Derive the /dev "live tenant preview" plan — whether the page embeds a real, scaled-down
3
- * iframe of the developer's own storefront (click-to-zoom into a fully interactive view),
4
- * and the exact same-origin src to frame. Pure and renderer-safe: reads only public tenant
5
- * shape + the request host + a config flag, never a secret.
6
- *
7
- * WHY AN IFRAME WORKS (no screenshots, no new infra): tenant routing is host-first with a
8
- * `/<appDomain>/…` path-prefix fallback on the same worker (src/lib/access/shared/tenantRouting.ts), so
9
- * the tenant's real site is reachable at a RELATIVE path from /dev. CSP already permits
10
- * same-origin framing both directions (`frame-ancestors 'self'` + `frame-src 'self'`,
11
- * packages/public-runtime/src/csp.ts) alongside `X-Frame-Options: SAMEORIGIN` — no header
12
- * changes. The iframe carries the viewer's own cookies, so a signed-in developer framing
13
- * their own store passes the login gate by construction; /dev only renders the iframe for
14
- * that viewer (the gated/signed-out states keep the static mock).
15
- *
16
- * CROSS-ORIGIN GOTCHA: never frame `hostedStoreUrl` (`*.tokenoftrust.store` subdomains) —
17
- * those are cross-origin from the /dev host and blocked by `frame-src 'self'`. The src here
18
- * is always relative: `/` when the request host itself owns the tenant (host-first routing
19
- * skips the path prefix there), else `/${appDomain}/`.
20
- *
21
- * CONFIG TOGGLE: `DEV_LIVE_PREVIEW` (read via the readEnv seam in dev.astro). UNSET ⇒ ON.
22
- * Set to "off" / "0" / "false" to fall back to the static mock per environment without a
23
- * code change — the just-in-case lever if framing misbehaves somewhere.
24
- */
25
- import type { TenantConfig } from "@tot/public-runtime";
26
-
27
- /** Natural (unscaled) viewport the preview iframe renders at — a standard desktop. */
28
- export const PREVIEW_VIEWPORT = { width: 1280, height: 800 } as const;
29
-
30
- /** Fallback thumbnail scale before script measures the real container width. */
31
- export const PREVIEW_FALLBACK_SCALE = 0.3;
32
-
33
- export interface LivePreviewPlan {
34
- /** Relative, same-origin iframe src for the tenant's real site (never a full URL). */
35
- src: string;
36
- width: number;
37
- height: number;
38
- /** Initial mini-state scale; the page script refines it to fit the container. */
39
- scale: number;
40
- }
41
-
42
- /** `DEV_LIVE_PREVIEW` semantics: default ON; only an explicit off flips it. */
43
- export function livePreviewEnabled(envValue: string | undefined | null): boolean {
44
- const v = (envValue ?? "").trim().toLowerCase();
45
- return v !== "off" && v !== "0" && v !== "false";
46
- }
47
-
48
- /**
49
- * The same-origin src for `tenant` as seen from `requestHost` (port ignored): `/` when the
50
- * host itself owns the tenant (host-first routing serves it at the root there), else the
51
- * path-prefix form `/${appDomain}/`.
52
- */
53
- export function livePreviewSrc(tenant: TenantConfig | null, requestHost: string): string | null {
54
- if (!tenant?.appDomain) return null;
55
- const host = requestHost.split(":")[0]?.trim().toLowerCase() ?? "";
56
- const owned = [tenant.appDomain, tenant.canonicalDomain, ...(tenant.domains ?? [])].some(
57
- (d) => d?.toLowerCase() === host,
58
- );
59
- return owned ? "/" : `/${tenant.appDomain}/`;
60
- }
61
-
62
- /**
63
- * The full plan, or null when the preview shouldn't render (flag off, no tenant, or the
64
- * viewer isn't an admitted developer — those states keep the static mock).
65
- */
66
- export function deriveLivePreview(opts: {
67
- envValue: string | undefined | null;
68
- tenant: TenantConfig | null;
69
- requestHost: string;
70
- /** The viewer is signed in with a developer capability (dev.astro's hasStoreAccess gate). */
71
- admitted: boolean;
72
- }): LivePreviewPlan | null {
73
- if (!opts.admitted || !livePreviewEnabled(opts.envValue)) return null;
74
- const src = livePreviewSrc(opts.tenant, opts.requestHost);
75
- if (!src) return null;
76
- return { src, ...PREVIEW_VIEWPORT, scale: PREVIEW_FALLBACK_SCALE };
77
- }
@@ -1,214 +0,0 @@
1
- /**
2
- * Per-DEVELOPER "startup obstacle" — the FAILURE half of the local→hosted dev
3
- * bridge (v2 §6). Where runtimeStore.ts holds the latest SUCCESSFUL heartbeat and
4
- * activityStore.ts the file-save ring buffer, this holds the latest reason a
5
- * developer's local `tot start` could NOT come up: a Node-version floor miss, a
6
- * missing pnpm, a failed install/clone. The hosted cockpit reads it to turn the
7
- * bridge strip into an actionable obstacle card ("This machine is running Node
8
- * 20.17 — needs 22.12+; fix: …") instead of spinning forever on "watching…".
9
- *
10
- * WHY ITS OWN KEY (not folded into the runtime record): an obstacle is PRECISELY
11
- * the state where no successful heartbeat exists, so it must never carry an
12
- * `aliveAt` that liveness reads — mixing it into the runtime record would flicker
13
- * the loop "live". It is its own latest-wins slot, cleared the moment a real
14
- * heartbeat lands (writeRuntime → clearObstacle) and on a ?reset.
15
- *
16
- * SCOPED PER (tenant, developer email), exactly like the runtime record
17
- * (commit 0d4bb7d): the obstacle is beaconed with the developer's OWN
18
- * activity-ingest token — carried in the setup command's argv — so a machine that
19
- * FAILS the Node gate (no session, no MCP, maybe no global `fetch`) can still
20
- * report it. The viewer's own GET (their email) reads their own obstacle; a
21
- * teammate's failure is theirs.
22
- *
23
- * REMEDIATION COPY LIVES HERE (server-side), keyed by `kind` — so the fix-it
24
- * guidance changes without shipping a new CLI. The CLI reports only a stable,
25
- * machine-readable {kind, have, need}; the human sentence is composed here.
26
- */
27
-
28
- /** The failure modes `tot start` can beacon. Stable machine-readable contract —
29
- * the CLI emitter (a bounded follow-up) POSTs one of these; the human copy is
30
- * composed server-side in describeObstacle(). */
31
- export const OBSTACLE_KINDS = [
32
- "node-too-old",
33
- "pnpm-missing",
34
- "install-failed",
35
- "clone-failed",
36
- ] as const;
37
- export type ObstacleKind = (typeof OBSTACLE_KINDS)[number];
38
-
39
- /** The latest startup obstacle a developer's local loop reported. */
40
- export interface DevObstacle {
41
- kind: ObstacleKind;
42
- /** The version the machine HAS, when the kind carries one (node-too-old). e.g. "20.17.0". */
43
- have?: string;
44
- /** The version the loop NEEDS, when the beacon knows it. e.g. "22.12.0". */
45
- need?: string;
46
- /** The `tot` CLI version that reported the obstacle, when carried. */
47
- cliVersion?: string;
48
- /** Epoch ms the obstacle was reported, stamped by the SERVER at ingest (never
49
- * the client `ts` — skew-proof, matching the runtime record's aliveAt). */
50
- reportedAt: number;
51
- }
52
-
53
- /** The obstacle as the GET feed exposes it: the stored record PLUS the
54
- * server-composed remediation copy the cockpit renders verbatim. */
55
- export interface DevObstacleView extends DevObstacle {
56
- /** Short label for the bridge kicker, e.g. "Node version too old". */
57
- title: string;
58
- /** One-line human explanation, with have/need interpolated. */
59
- message: string;
60
- /** The single shell command that fixes it, when there is one (rendered in mono). */
61
- fixCommand?: string;
62
- /** The instruction around the fix command (or the whole fix, when there is no command). */
63
- fixNote: string;
64
- }
65
-
66
- const KEY_PREFIX = "dev-obstacle:";
67
- /** Match the runtime record's TTL: an obstacle lingers long enough for the
68
- * developer to see it after a failed start, then self-expires. A real heartbeat
69
- * clears it well before this. */
70
- const TTL_SECONDS = 3600;
71
-
72
- /** A reported version ("20.17.0") is short; cap it for KV value-size hygiene. */
73
- const MAX_VERSION_LEN = 32;
74
- const MAX_CLI_LEN = 64;
75
-
76
- /** Astro's engines floor (enforced by CLI 1.3.4-rc.2). Used ONLY as a fallback
77
- * when a node-too-old beacon omits `need`; a beacon that carries `need` wins. */
78
- const NODE_FLOOR = "22.12";
79
-
80
- /** Per-developer record key: `dev-obstacle:<tenant>:<email>` (email lowercased
81
- * for a stable key, mirroring runtimeStore). */
82
- function key(appDomain: string, email: string | undefined): string {
83
- return `${KEY_PREFIX}${appDomain}:${(email ?? "").toLowerCase()}`;
84
- }
85
-
86
- function clip(v: unknown, max: number): string | undefined {
87
- return typeof v === "string" && v.length > 0 ? v.slice(0, max) : undefined;
88
- }
89
-
90
- function isKind(v: unknown): v is ObstacleKind {
91
- return typeof v === "string" && (OBSTACLE_KINDS as readonly string[]).includes(v);
92
- }
93
-
94
- /**
95
- * Normalize a raw obstacle beacon into a stored record, or null when the `kind`
96
- * is unrecognized (the route rejects that as a 400 — an unknown kind has no
97
- * remediation copy, so storing it would render a blank card). Pure + exported so
98
- * the route's validation is unit-tested without KV. have/need/cliVersion are
99
- * bounded strings; `reportedAt` is the SERVER clock, never the client's `ts`.
100
- */
101
- export function shapeObstacle(
102
- body: { kind?: unknown; have?: unknown; need?: unknown; cliVersion?: unknown },
103
- reportedAt: number,
104
- ): DevObstacle | null {
105
- if (!isKind(body.kind)) return null;
106
- const rec: DevObstacle = { kind: body.kind, reportedAt };
107
- const have = clip(body.have, MAX_VERSION_LEN);
108
- const need = clip(body.need, MAX_VERSION_LEN);
109
- const cliVersion = clip(body.cliVersion, MAX_CLI_LEN);
110
- if (have) rec.have = have;
111
- if (need) rec.need = need;
112
- if (cliVersion) rec.cliVersion = cliVersion;
113
- return rec;
114
- }
115
-
116
- /** Read a developer's latest obstacle (their tenant + email), or null when
117
- * none/malformed/unknown-kind. Never throws. */
118
- export async function readObstacle(
119
- kv: KVNamespace,
120
- appDomain: string,
121
- email: string | undefined,
122
- ): Promise<DevObstacle | null> {
123
- try {
124
- const raw = await kv.get(key(appDomain, email));
125
- if (!raw) return null;
126
- const parsed = JSON.parse(raw);
127
- if (
128
- !parsed ||
129
- typeof parsed !== "object" ||
130
- typeof parsed.reportedAt !== "number" ||
131
- !isKind(parsed.kind)
132
- ) {
133
- return null;
134
- }
135
- return parsed as DevObstacle;
136
- } catch {
137
- return null;
138
- }
139
- }
140
-
141
- /** Overwrite a developer's obstacle with their latest beacon (latest-wins, TTL'd),
142
- * scoped to (tenant, email). */
143
- export async function writeObstacle(
144
- kv: KVNamespace,
145
- appDomain: string,
146
- email: string | undefined,
147
- rec: DevObstacle,
148
- ): Promise<void> {
149
- await kv.put(key(appDomain, email), JSON.stringify(rec), { expirationTtl: TTL_SECONDS });
150
- }
151
-
152
- /** Delete a developer's obstacle record — a live heartbeat supersedes it, and a
153
- * ?reset clears it. Idempotent; never throws on an absent key. */
154
- export async function clearObstacle(
155
- kv: KVNamespace,
156
- appDomain: string,
157
- email: string | undefined,
158
- ): Promise<void> {
159
- await kv.delete(key(appDomain, email));
160
- }
161
-
162
- /**
163
- * Compose the human remediation copy for an obstacle, keyed by kind — SERVER-side
164
- * so the fix-it guidance changes without a CLI release. Pure. The exhaustive
165
- * switch means adding a new ObstacleKind is a compile error here until its copy
166
- * exists (so no kind can ship without a fix message).
167
- */
168
- export function describeObstacle(rec: DevObstacle): {
169
- title: string;
170
- message: string;
171
- fixCommand?: string;
172
- fixNote: string;
173
- } {
174
- switch (rec.kind) {
175
- case "node-too-old": {
176
- const need = rec.need || NODE_FLOOR;
177
- const message = rec.have
178
- ? `This machine is running Node ${rec.have} — the dev loop needs ${need} or newer.`
179
- : `The dev loop needs Node ${need} or newer, and this machine's version is too old.`;
180
- return {
181
- title: "Node version too old",
182
- message,
183
- fixCommand: "nvm install 24 && nvm use 24",
184
- fixNote: "then re-run the setup command above. No nvm? Install Node 24 LTS from nodejs.org.",
185
- };
186
- }
187
- case "pnpm-missing":
188
- return {
189
- title: "pnpm not found",
190
- message: "The dev loop needs pnpm, which isn't installed on this machine.",
191
- fixCommand: "npm install -g pnpm",
192
- fixNote: "then re-run the setup command above.",
193
- };
194
- case "install-failed":
195
- return {
196
- title: "Install failed",
197
- message: "Installing the dev runner didn't finish on this machine.",
198
- fixNote:
199
- "Check your terminal for the npm or network error, then re-run the setup command. If it keeps failing, send us that output.",
200
- };
201
- case "clone-failed":
202
- return {
203
- title: "Couldn't fetch your store",
204
- message: "The dev loop couldn't download your store's starter files.",
205
- fixNote: "Check your network and the terminal output, then re-run the setup command.",
206
- };
207
- }
208
- }
209
-
210
- /** Attach the server-composed remediation copy to a stored obstacle — the
211
- * developer-facing view the GET feed returns. Pure. */
212
- export function toObstacleView(rec: DevObstacle): DevObstacleView {
213
- return { ...rec, ...describeObstacle(rec) };
214
- }
@@ -1,87 +0,0 @@
1
- /**
2
- * Read whether a tenant appDomain's store is SET UP — its forge repo is provisioned —
3
- * from the credential-free MCP preview-status seam (tot-mcp
4
- * GET /internal/preview-status; alias /internal/dev-access/preview-status). The
5
- * seam answers `{ tenant, app, repo, provisioned, previewReleased }`.
6
- *
7
- * This is the cockpit's own small reader over the same MCP-origin + service-secret seam
8
- * `cliSignInCode.ts` uses. It gates the CLI sign-in-code mint + the /cockpit setup
9
- * fastpath so a developer whose
10
- * store isn't provisioned yet gets an honest "not set up" state instead of a
11
- * `tot login --code … && tot start` command that would die at checkout on
12
- * "Repo <owner>-main is not provisioned".
13
- *
14
- * - MCP host ← the ORIGIN of MCP_APP_BINDING_URL (one source, so this read hits the
15
- * SAME MCP tier the sign-in-code mint does).
16
- * - auth ← header x-mcp-service-secret: MCP_SERVICE_SHARED_SECRET.
17
- *
18
- * Fail-closed but non-blocking by design: an UNCONFIGURED seam (no URL/secret) →
19
- * { configured:false } so callers keep the default behavior; any non-2xx /
20
- * transport / parse fault → { configured:true, ok:false } so a caller can distinguish
21
- * "definitely not provisioned" (ok + provisioned:false) from "couldn't tell". Never throws.
22
- */
23
- import { callMcpService } from "@/lib/developer-experience/http/mcpServiceCall";
24
- import { FetchHttpTransport, type HttpGetTransport } from "@/lib/developer-experience/http/fetchTransport";
25
-
26
- export type { HttpGetTransport };
27
-
28
- export interface TenantPreviewStatus {
29
- /** False when the seam isn't wired on this deploy (no URL/secret) — gate inactive. */
30
- configured: boolean;
31
- /** True only when we got a definitive answer back from the MCP. */
32
- ok: boolean;
33
- /** The forge repo is provisioned for this owner (checkout/`tot start` can succeed). */
34
- provisioned?: boolean;
35
- /** A released preview exists. TODAY equals `provisioned`; Track B.3 tightens it. */
36
- previewReleased?: boolean;
37
- status?: number;
38
- reason?: string;
39
- }
40
-
41
- export async function readTenantPreviewStatus(
42
- tenant: string | null,
43
- deps: { transport?: HttpGetTransport } = {},
44
- ): Promise<TenantPreviewStatus> {
45
- if (!tenant) return { configured: false, ok: false };
46
- const outcome = await callMcpService({
47
- method: "GET",
48
- path: "/internal/preview-status",
49
- query: { tenant: tenant.toLowerCase() },
50
- transport: deps.transport ?? new FetchHttpTransport(),
51
- });
52
- if (outcome.kind === "not-configured") return { configured: false, ok: false };
53
- if (outcome.kind === "bad-url") return { configured: false, ok: false, reason: "bad-mcp-url" };
54
- if (outcome.kind === "transport-error") {
55
- return { configured: true, ok: false, reason: "mcp request failed: " + outcome.message };
56
- }
57
- if (outcome.kind === "misconfigured" || outcome.kind === "http-error") {
58
- return { configured: true, ok: false, status: outcome.status, reason: `status ${outcome.status}` };
59
- }
60
- const res = outcome;
61
- let payload: unknown;
62
- try {
63
- payload = await res.json();
64
- } catch {
65
- return { configured: true, ok: false, status: res.status, reason: "unparseable mcp response" };
66
- }
67
- const p = (payload ?? {}) as Record<string, unknown>;
68
- return {
69
- configured: true,
70
- ok: true,
71
- status: res.status,
72
- provisioned: p.provisioned === true,
73
- previewReleased: p.previewReleased === true,
74
- };
75
- }
76
-
77
- /**
78
- * The gate signal shared by /cockpit + the CLI sign-in-code mint: TRUE only when the
79
- * seam gave a DEFINITIVE "this store's repo is NOT provisioned" — the exact case where
80
- * `tot clone` / `tot start` would die locally on "Repo … is not provisioned". An
81
- * unconfigured seam or one that couldn't answer returns FALSE — callers then keep today's
82
- * behavior and lean on the CLI's own clean "not set up yet" error as the backstop, rather
83
- * than blocking a possibly-fine developer on a transient MCP blip.
84
- */
85
- export function isStoreNotSetUp(status: TenantPreviewStatus): boolean {
86
- return status.configured && status.ok && status.provisioned === false;
87
- }