@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,74 +0,0 @@
1
- /**
2
- * Fetch a FRESH agent-grant attestation from tot-mcp (#8500 sponsored agents; review X4):
3
- * `POST /internal/dev-access/agent-grant-attestation {grantId, agent}`.
4
- *
5
- * tot-mcp re-reads the agent-sponsorship grant live and answers `{ attestation }` (a
6
- * short-lived JWT tot20 verifies against tot-mcp's broker key) or `{ attestation: null }`
7
- * once the grant is revoked or expired. The storefront never verifies, stores or logs it:
8
- * it travels in flight beside one delegated broker assertion.
9
- *
10
- * The request is PINNED to the MCP origin that introspected the agent's token: only the
11
- * code-owned trusted origins are accepted, each reached through its own seam authority,
12
- * and a request the seam would address anywhere else fails before it leaves.
13
- */
14
- import { callMcpService, type McpServiceTransport } from "@/lib/developer-experience/http/mcpServiceCall";
15
- import { FetchHttpTransport } from "@/lib/developer-experience/http/fetchTransport";
16
-
17
- /** `string` when the grant is live, `null` when it is dead, `"fault"` when unknown. */
18
- export type AgentGrantAttestationResult = string | null | "fault";
19
-
20
- export interface AgentGrantAttestationRequest {
21
- grantId: string;
22
- /** The agent subject, `agent:<id>`. */
23
- agentId: string;
24
- /** The trusted MCP origin that introspected the agent's token. */
25
- mcpOrigin: string;
26
- }
27
-
28
- /**
29
- * The code-owned trusted MCP origins and the seam authority that reaches each: the same
30
- * pair `/api/dev/cli-session` advertises. Any other origin fails closed.
31
- */
32
- const MCP_AUTHORITY_BY_ORIGIN: ReadonlyMap<string, "grant" | undefined> = new Map([
33
- ["https://mcp.tokenoftrust.com", undefined],
34
- ["https://mcp.qa.tokenoftrust.com", "grant"],
35
- ]);
36
-
37
- function pinnedTransport(inner: McpServiceTransport, origin: string): McpServiceTransport {
38
- return {
39
- post: async (url, headers, body) => {
40
- if (!inner.post || new URL(url).origin !== origin) {
41
- throw new Error("agent attestation request is not addressed to the session's MCP");
42
- }
43
- return inner.post(url, headers, body);
44
- },
45
- };
46
- }
47
-
48
- export async function fetchAgentGrantAttestation(
49
- request: AgentGrantAttestationRequest,
50
- transport: McpServiceTransport = new FetchHttpTransport({ timeoutMs: 5000 }),
51
- ): Promise<AgentGrantAttestationResult> {
52
- if (!MCP_AUTHORITY_BY_ORIGIN.has(request.mcpOrigin)) return "fault";
53
- let outcome;
54
- try {
55
- outcome = await callMcpService({
56
- method: "POST",
57
- path: "/internal/dev-access/agent-grant-attestation",
58
- body: { grantId: request.grantId, agent: request.agentId },
59
- authority: MCP_AUTHORITY_BY_ORIGIN.get(request.mcpOrigin),
60
- transport: pinnedTransport(transport, request.mcpOrigin),
61
- });
62
- } catch {
63
- return "fault";
64
- }
65
- if (outcome.kind !== "ok") return "fault";
66
- let payload: unknown;
67
- try {
68
- payload = await outcome.json();
69
- } catch {
70
- return "fault";
71
- }
72
- const attestation = (payload as Record<string, unknown> | null)?.attestation;
73
- return typeof attestation === "string" && attestation.length > 0 ? attestation : null;
74
- }
@@ -1,308 +0,0 @@
1
- // The floating "✦ ask" affordance for `tot dev`'s inline-AI edit loop (WS5 G1).
2
- // Injected into every page ONLY in `astro dev` by inlineAiEditPlugin in
3
- // astro.config.mjs (never bundled into the production build — this file isn't
4
- // imported by any Astro page/component, only served verbatim by that dev-only
5
- // Vite middleware). Talks to /__tot/ai-edit and /__tot/ai-undo, which
6
- // scripts/dev/ai-edit.mjs implements against the tenant this `tot dev` run is
7
- // serving (TOT_DEV_TENANT).
8
- //
9
- // Plain vanilla JS, no build step, no framework — this never ships to users.
10
-
11
- (function () {
12
- const ROOT_ID = "__tot-ai-widget";
13
- if (document.getElementById(ROOT_ID)) return; // one instance per page
14
-
15
- const root = document.createElement("div");
16
- root.id = ROOT_ID;
17
- root.innerHTML = `
18
- <style>
19
- #${ROOT_ID} { position: fixed; right: 1rem; bottom: 1rem; z-index: 2147483647;
20
- font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
21
- #${ROOT_ID} .toggle { width: 3rem; height: 3rem; border-radius: 999px; border: none;
22
- background: #16181d; color: #e8e6e0; font-size: 1.25rem; cursor: pointer;
23
- box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); }
24
- #${ROOT_ID} .toggle:hover { background: #23262d; }
25
- #${ROOT_ID} .panel { display: none; position: absolute; right: 0; bottom: 3.75rem;
26
- width: 22rem; max-width: 90vw; background: #fff; color: #16191d; border-radius: 12px;
27
- box-shadow: 0 16px 40px -12px rgba(0,0,0,.35); border: 1px solid #e4e0d6; padding: .9rem; }
28
- #${ROOT_ID}.open .panel { display: block; }
29
- #${ROOT_ID} textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 3.5rem;
30
- border: 1px solid #d8d4c8; border-radius: 8px; padding: .5rem .6rem; font: inherit; }
31
- #${ROOT_ID} .row { display: flex; gap: .4rem; margin-top: .5rem; }
32
- #${ROOT_ID} button.primary { flex: 1; background: #0f7b6c; color: #fff; border: none;
33
- border-radius: 8px; padding: .5rem .7rem; font: 600 .85rem/1 inherit; cursor: pointer; }
34
- #${ROOT_ID} button.primary:disabled { opacity: .5; cursor: default; }
35
- #${ROOT_ID} button.secondary { background: #ece9e0; color: #2a2d31; border: none;
36
- border-radius: 8px; padding: .5rem .7rem; font: 600 .8rem/1 inherit; cursor: pointer; }
37
- #${ROOT_ID} .status { margin-top: .6rem; font-size: .82rem; white-space: pre-wrap; }
38
- #${ROOT_ID} .status.error { color: #a83a3a; }
39
- #${ROOT_ID} .status.ok { color: #0f7b6c; }
40
- #${ROOT_ID} details { margin-top: .5rem; }
41
- #${ROOT_ID} pre { max-height: 12rem; overflow: auto; background: #16181d; color: #dbe3ea;
42
- border-radius: 8px; padding: .5rem .6rem; font-size: .75rem; }
43
- /* Locate mode (C7): highlight box, hint, and result toast — top-level ids so
44
- they overlay the whole page, outside the widget's own stacking. */
45
- #${ROOT_ID}-locate-hi { position: fixed; z-index: 2147483646; pointer-events: none;
46
- border: 2px solid #0f7b6c; background: rgba(15,123,108,.12); border-radius: 3px; display: none; }
47
- #${ROOT_ID}-locate-hint { position: fixed; left: 50%; top: 1rem; transform: translateX(-50%);
48
- z-index: 2147483647; background: #16181d; color: #e8e6e0; font: 600 .8rem/1 -apple-system, sans-serif;
49
- padding: .55rem .9rem; border-radius: 999px; box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); display: none; }
50
- #${ROOT_ID}-locate-toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%) translateY(160%);
51
- z-index: 2147483647; background: #16181d; color: #e8e6e0; display: flex; align-items: center;
52
- font: 500 .8rem/1.3 ui-monospace, Menlo, monospace; padding: .6rem 1rem; border-radius: 8px;
53
- box-shadow: 0 8px 24px -8px rgba(0,0,0,.45); transition: transform .25s; max-width: 90vw; }
54
- #${ROOT_ID}-locate-toast.show { transform: translateX(-50%) translateY(0); }
55
- </style>
56
- <button class="toggle" type="button" aria-label="Ask AI to edit this site" title="Ask AI to edit this site">✦</button>
57
- <div class="panel">
58
- <textarea placeholder="e.g. make it darker but still friendly" aria-label="Describe the change"></textarea>
59
- <div class="row">
60
- <button class="primary" type="button" data-action="ask">Ask</button>
61
- <button class="secondary" type="button" data-action="undo">Undo last</button>
62
- <button class="secondary" type="button" data-action="locate" title="Click an element on the page to jump to its source">◎ Locate</button>
63
- </div>
64
- <div class="status" role="status" aria-live="polite"></div>
65
- </div>
66
- `;
67
- document.body.appendChild(root);
68
-
69
- const toggle = root.querySelector(".toggle");
70
- const textarea = root.querySelector("textarea");
71
- const askBtn = root.querySelector('[data-action="ask"]');
72
- const undoBtn = root.querySelector('[data-action="undo"]');
73
- const status = root.querySelector(".status");
74
-
75
- toggle.addEventListener("click", () => root.classList.toggle("open"));
76
-
77
- function setStatus(text, kind) {
78
- status.textContent = text;
79
- status.className = "status" + (kind ? " " + kind : "");
80
- }
81
-
82
- function renderResult(result) {
83
- if (!result.ok) {
84
- setStatus(result.message || `Refused (${result.status}).`, "error");
85
- return;
86
- }
87
- if (result.status === "noop") {
88
- setStatus(result.summary || "No change was needed.", "ok");
89
- return;
90
- }
91
- setStatus(`✔ ${result.summary} — reloading…`, "ok");
92
- // The file write already fires the existing content/theme HMR watch (see
93
- // astro.config.mjs's tenantHotReload); nothing else to do here.
94
- }
95
-
96
- async function postJson(path, body) {
97
- const res = await fetch(path, {
98
- method: "POST",
99
- headers: { "content-type": "application/json" },
100
- body: JSON.stringify(body || {}),
101
- });
102
- return res.json();
103
- }
104
-
105
- askBtn.addEventListener("click", async () => {
106
- const prompt = textarea.value.trim();
107
- if (!prompt) return;
108
- askBtn.disabled = true;
109
- setStatus("Asking…");
110
- try {
111
- const result = await postJson("/__tot/ai-edit", { prompt });
112
- renderResult(result);
113
- } catch (e) {
114
- setStatus(`Request failed: ${e.message}`, "error");
115
- } finally {
116
- askBtn.disabled = false;
117
- }
118
- });
119
-
120
- undoBtn.addEventListener("click", async () => {
121
- undoBtn.disabled = true;
122
- setStatus("Undoing…");
123
- try {
124
- const result = await postJson("/__tot/ai-undo", {});
125
- if (!result.ok) {
126
- setStatus(result.message || "Nothing to undo.", "error");
127
- } else {
128
- setStatus(`↺ Reverted "${result.undid}" — reloading…`, "ok");
129
- }
130
- } catch (e) {
131
- setStatus(`Request failed: ${e.message}`, "error");
132
- } finally {
133
- undoBtn.disabled = false;
134
- }
135
- });
136
-
137
- textarea.addEventListener("keydown", (e) => {
138
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) askBtn.click();
139
- });
140
-
141
- // ── Locate mode (C7): click an element → its source file:line:col ──────────
142
- // Enter locate mode, hover to highlight, click an element: we capture a DOM path
143
- // and POST it to /__tot/locate, which (server-side, scripts/dev/dev-locate.mjs)
144
- // parses the raw-HTML tenant source with parse5 and walks the SAME path to a
145
- // line:col. captureDomPath MUST stay in lockstep with scripts/dev/locate.mjs's
146
- // walk (see its header + locate.test.mjs's round-trip): a DOM path is an array of
147
- // { tag, index } from <body>'s child down to the target, index = 0-based position
148
- // among same-tag element siblings (nth-of-type). Raw-HTML tenants only; the server
149
- // refuses templated pages with { status: "not_raw_html" }.
150
- function captureDomPath(el) {
151
- const path = [];
152
- let node = el;
153
- while (node && node.tagName && node.tagName.toLowerCase() !== "body") {
154
- const parent = node.parentElement;
155
- if (!parent) break;
156
- const tag = node.tagName.toLowerCase();
157
- let index = 0;
158
- for (let sib = node.previousElementSibling; sib; sib = sib.previousElementSibling) {
159
- if (sib.tagName.toLowerCase() === tag) index += 1;
160
- }
161
- path.unshift({ tag, index });
162
- if (parent.tagName && parent.tagName.toLowerCase() === "body") break;
163
- node = parent;
164
- }
165
- return path;
166
- }
167
- // Exposed for the in-browser verification harness (dev-only, harmless in prod
168
- // since this whole file is never bundled into the production build).
169
- window.__totCaptureDomPath = captureDomPath;
170
-
171
- const locateBtn = root.querySelector('[data-action="locate"]');
172
- let hi, hint, ltoast, locating = false, lastHover = null;
173
-
174
- function ensureLocateEls() {
175
- if (hi) return;
176
- hi = document.createElement("div");
177
- hi.id = ROOT_ID + "-locate-hi";
178
- hint = document.createElement("div");
179
- hint.id = ROOT_ID + "-locate-hint";
180
- hint.textContent = "Click an element to jump to its source · Esc to cancel";
181
- ltoast = document.createElement("div");
182
- ltoast.id = ROOT_ID + "-locate-toast";
183
- document.body.append(hi, hint, ltoast);
184
- }
185
-
186
- function inWidget(el) {
187
- return !!el && (el === root || root.contains(el) || el === hi || el === hint || el === ltoast);
188
- }
189
-
190
- function onMove(e) {
191
- const el = document.elementFromPoint(e.clientX, e.clientY);
192
- if (!el || inWidget(el)) {
193
- hi.style.display = "none";
194
- lastHover = null;
195
- return;
196
- }
197
- lastHover = el;
198
- const r = el.getBoundingClientRect();
199
- hi.style.display = "block";
200
- hi.style.left = r.left + "px";
201
- hi.style.top = r.top + "px";
202
- hi.style.width = r.width + "px";
203
- hi.style.height = r.height + "px";
204
- }
205
-
206
- function showLToast(text, located) {
207
- ensureLocateEls();
208
- ltoast.textContent = text;
209
- if (located) {
210
- // Best-effort $EDITOR jump (server degrades gracefully when unset).
211
- const open = document.createElement("button");
212
- open.textContent = "Open in editor";
213
- open.style.cssText =
214
- "margin-left:.7rem;background:#0f7b6c;color:#fff;border:none;border-radius:6px;" +
215
- "padding:.3rem .6rem;font:600 .72rem/1 -apple-system,sans-serif;cursor:pointer";
216
- open.addEventListener("click", () => {
217
- postJson("/__tot/open-in-editor", located).catch(() => {});
218
- });
219
- ltoast.appendChild(open);
220
- }
221
- ltoast.classList.add("show");
222
- clearTimeout(showLToast._t);
223
- showLToast._t = setTimeout(() => ltoast.classList.remove("show"), 6000);
224
- }
225
-
226
- async function onClick(e) {
227
- if (inWidget(e.target)) return; // clicks on the widget itself pass through
228
- e.preventDefault();
229
- e.stopPropagation();
230
- const el = lastHover || document.elementFromPoint(e.clientX, e.clientY);
231
- exitLocate();
232
- if (!el) return;
233
- const domPath = captureDomPath(el);
234
- // C8 (capstone) branches HERE: when framed (window !== window.parent) it
235
- // postMessages { type:"tot:locate", path, line, col } to the parent editor
236
- // instead of this standalone toast. C7 ships the standalone path only.
237
- let res, body;
238
- try {
239
- res = await fetch("/__tot/locate", {
240
- method: "POST",
241
- headers: { "content-type": "application/json" },
242
- body: JSON.stringify({ domPath, path: location.pathname }),
243
- });
244
- body = await res.json();
245
- } catch (err) {
246
- showLToast("Locate unavailable — is tot dev running?");
247
- return;
248
- }
249
- // C8 capstone: when this page is FRAMED (the live-preview iframe inside /dev),
250
- // deliver the result to the parent cockpit instead of a standalone toast — the
251
- // parent opens the file + places the cursor. Only content-region hits (a real
252
- // {line,col}) are forwarded; chrome/refused clicks stay silent inside the frame
253
- // (no toast over the preview, no misleading jump), honoring the content-region
254
- // decision. targetOrigin is our own origin (same-origin preview) — never "*".
255
- const framed = window !== window.parent;
256
- if (!res.ok || (body && body.status)) {
257
- if (framed) return; // refused inside the frame — quietly no-op
258
- showLToast(
259
- body && body.status === "not_raw_html"
260
- ? "Locate works on raw-HTML tenants only — this page is templated."
261
- : "Couldn’t find that element in the source.",
262
- );
263
- return;
264
- }
265
- if (framed) {
266
- try {
267
- window.parent.postMessage(
268
- { type: "tot:locate", path: body.path, line: body.line, col: body.col },
269
- window.location.origin,
270
- );
271
- } catch (err) { /* parent gone / cross-origin — nothing to do */ }
272
- return;
273
- }
274
- showLToast(`${body.path}:${body.line}:${body.col}`, body);
275
- }
276
-
277
- function onEsc(e) {
278
- if (e.key === "Escape") {
279
- e.preventDefault();
280
- exitLocate();
281
- }
282
- }
283
-
284
- function enterLocate() {
285
- ensureLocateEls();
286
- locating = true;
287
- root.classList.remove("open");
288
- hint.style.display = "block";
289
- document.addEventListener("mousemove", onMove, true);
290
- document.addEventListener("click", onClick, true);
291
- document.addEventListener("keydown", onEsc, true);
292
- document.body.style.cursor = "crosshair";
293
- }
294
-
295
- function exitLocate() {
296
- locating = false;
297
- if (hi) hi.style.display = "none";
298
- if (hint) hint.style.display = "none";
299
- document.removeEventListener("mousemove", onMove, true);
300
- document.removeEventListener("click", onClick, true);
301
- document.removeEventListener("keydown", onEsc, true);
302
- document.body.style.cursor = "";
303
- }
304
-
305
- if (locateBtn) {
306
- locateBtn.addEventListener("click", () => (locating ? exitLocate() : enterLocate()));
307
- }
308
- })();
@@ -1,17 +0,0 @@
1
- /**
2
- * Environment-aware endpoint base for the /dev cockpit (file tree/viewer/diff +
3
- * click-to-source). Local `astro dev` serves these off dev-server-only plugins at
4
- * `/__tot/*` (dev-plugins/dev-file-browser.mjs, dev-write.mjs, dev-diff.mjs, ...) —
5
- * paths that don't exist in the deployed Cloudflare Worker. The hosted Worker instead
6
- * serves the SAME shape off `/api/dev/*` Astro API routes
7
- * (cp-tree, cp-file, cp-write, cp-diff, cp-locate). One dev.astro UI, one resolver.
8
- *
9
- * `basePath` is the request's tenant prefix ("" host-routed, "/<tenant>" path-routed).
10
- * The HOSTED routes are tenant-scoped through the middleware's host/path resolution, so
11
- * a `/<tenant>/cockpit` render must call `/<tenant>/api/dev/*` for `locals.tenant` to be
12
- * that store on the API request (not the generic home host). The local `/__tot/*` dev
13
- * plugins are single-tenant and take no prefix.
14
- */
15
- export function resolveDevApiBase(isDev: boolean, basePath = ""): string {
16
- return isDev ? "/__tot" : `${basePath}/api/dev`;
17
- }
@@ -1,124 +0,0 @@
1
- /**
2
- * Mint a browserless "get going" command for an ALREADY-AUTHENTICATED developer — the
3
- * second half of the invite story. The developer accepted the magic link (OTP-free web
4
- * sign-in) and landed on /cockpit; this hands them a single-copy, THREE-LINE paste — line 1
5
- * installs the CLI, line 2 signs the terminal in, line 3 runs `start` (checkout → run →
6
- * open the browser on the working site) — so they go from web sign-in to a running store
7
- * with NO second browser round-trip and NO OTP.
8
- *
9
- * The paste carries a NON-SECRET rendezvous handle minted by the MCP's
10
- * POST /oauth/device/rendezvous (RFC 8628 rendezvous), authenticated by the storefront's
11
- * SIGNED CLIENT ASSERTION (private_key_jwt) — NOT a shared secret. `tot login --code <handle>`
12
- * then ATTACHES the terminal's own PKCE key and the developer approves it by fingerprint
13
- * back here in the cockpit (see the /api/dev/cli-signin-{status,approve} routes). The handle
14
- * is not a credential: intercepting it grants nothing without the terminal's private key,
15
- * and the developer must still approve the matching fingerprint.
16
- *
17
- * Line 2 appends `--mcp <origin>` ONLY when the MCP is not the CLI's built-in prod default —
18
- * on prod the shortest form is emitted.
19
- *
20
- * `activityBridge` (optional) piggybacks the local→hosted activity-bridge credential
21
- * (see lib/developer-experience/dev/activityIngestToken.ts) onto the SAME pasted line as two extra `tot login`
22
- * flags — no second browser round-trip. Omitted entirely when the caller has no SESSION KV
23
- * to mint against — the local loop then simply runs with no hosted signal.
24
- */
25
- import { readEnv } from "@/lib/publication/shared/env";
26
- import { redactEmailForHint } from "@/lib/access/privacy/emailHint";
27
- import { createRendezvous, type RendezvousDeps } from "@/lib/developer-experience/dev/rendezvousBroker";
28
-
29
- // The CLI's built-in default MCP (packages/cli login.mjs DEFAULT_MCP_URL). When the derived
30
- // MCP origin equals this, --mcp is redundant noise, so we omit it.
31
- const PROD_MCP_ORIGIN = "https://mcp.tokenoftrust.com";
32
-
33
- export type CliSignInCodeResult =
34
- | { ok: true; command: string; rendezvousCode: string; expiresAt: string | null }
35
- | { ok: false; status: 502 | 503; reason: string };
36
-
37
- /**
38
- * Mint the ready-to-paste CLI sign-in command for `email`. The caller MUST pass the
39
- * VERIFIED session email (never a client-supplied value) — a signed-in developer can only
40
- * start a rendezvous for themselves. `tenant` (the developer's own vendor, session-derived)
41
- * is threaded so the CLI session lands already bound to that store (no client_list
42
- * round-trip). Fail-closed: an unconfigured seam or a 401/403 (assertion rejected / client
43
- * not entitled to broker) is a 503; any other fault is a 502. Never throws.
44
- *
45
- * Returns the pasteable `command` AND the `rendezvousCode` — the cockpit polls the latter
46
- * for a terminal attaching, then shows the fingerprint approval prompt.
47
- */
48
- export async function mintCliSignInCommand(
49
- email: string,
50
- tenant: string | null = null,
51
- deps: RendezvousDeps = {},
52
- activityBridge: { token: string; url: string } | null = null,
53
- traceId: string | null = null,
54
- ): Promise<CliSignInCodeResult> {
55
- // MCP_BASE_URL is the MCP tier this storefront's client assertion is registered
56
- // with (where the rendezvous is created), so the pasted `--mcp` host MUST match it
57
- // — the terminal redeems the rendezvous against that same MCP. (The retired shim
58
- // used MCP_APP_BINDING_URL, which may point at a different tier.)
59
- const baseUrl = await readEnv("MCP_BASE_URL");
60
- if (!baseUrl) {
61
- return { ok: false, status: 503, reason: "not-configured" };
62
- }
63
- let mcpOrigin: string;
64
- try {
65
- mcpOrigin = new URL(baseUrl).origin;
66
- } catch {
67
- return { ok: false, status: 503, reason: "bad-mcp-url" };
68
- }
69
-
70
- const created = await createRendezvous(email, tenant, deps);
71
- if (!created.ok) {
72
- // 503 = seam not configured / assertion rejected / not entitled on this env;
73
- // 502 = MCP fault. Surface neither internal detail nor any token.
74
- return { ok: false, status: created.status, reason: created.reason };
75
- }
76
-
77
- const mcpFlag = mcpOrigin === PROD_MCP_ORIGIN ? "" : ` --mcp ${mcpOrigin}`;
78
- // Display-only recovery hint for a stale one-use handle. If sign-in fails before
79
- // anything is cached locally, `tot login` can still send the developer back to
80
- // cockpit with the right address prefilled.
81
- const emailHint = redactEmailForHint(email);
82
- const emailHintFlag = emailHint ? ` --email-hint ${emailHint}` : "";
83
- // Piggyback the activity-bridge credential onto the SAME login line — additive
84
- // flags, ignored by older CLI builds that don't yet recognize them.
85
- const activityFlags = activityBridge
86
- ? ` --activity-token ${activityBridge.token} --activity-url ${activityBridge.url}`
87
- : "";
88
- // The invite→terminal→problem trace id, minted once with this rendezvous and baked
89
- // into the activity-ingest-token claims. Emitted here too so `tot login` records it
90
- // locally — additive, ignored by older CLI builds.
91
- const traceFlag = traceId ? ` --trace-id ${traceId}` : "";
92
- // The EXACT version this build was cut alongside — baked in at build time (astro.config
93
- // Vite define) so the paste installs precisely the CLI this cockpit expects. `typeof`
94
- // guard: the define isn't applied under vitest, where it falls back to the unpinned spec.
95
- const cliInstallSpec =
96
- typeof __CLI_INSTALL_SPEC__ !== "undefined" ? __CLI_INSTALL_SPEC__ : "@tokenoftrust/cli";
97
- // `hash -r` after the install clears the shell's cached command path so the
98
- // just-installed `tot` is the one that runs — without it, a shell that already
99
- // resolved an OLDER `tot` (e.g. a stray Homebrew/other-prefix install earlier in
100
- // this session) keeps running the stale binary, and `npm i -g` silently updates a
101
- // file the shell never consults. Portable across bash/zsh/sh; fish can't run the
102
- // `&&` chain anyway. This is what makes the pinned version actually take effect.
103
- // A first-line no-op stamping which cockpit build generated this command (short git
104
- // SHA — the same one /health reports) + the CLI it pins, so a paste can be matched to
105
- // a deploy at a glance (pairs with `tot login`'s runtime version banner). Uses the
106
- // `: '…'` null-command form, NOT a `#` comment — interactive zsh doesn't treat `#` as
107
- // a comment (no INTERACTIVE_COMMENTS) and errors on it; `: '…'` is a portable no-op.
108
- const cockpitBuild = (typeof __GIT_SHA__ !== "undefined" ? __GIT_SHA__ : "unknown").slice(0, 7);
109
- const command = [
110
- `: 'tot setup (cockpit ${cockpitBuild}, ${cliInstallSpec})'`,
111
- `npm i -g ${cliInstallSpec} &&`,
112
- `hash -r &&`,
113
- `tot login --code ${created.rendezvousCode}${emailHintFlag}${mcpFlag}${traceFlag}${activityFlags} &&`,
114
- // `start` must talk to the SAME MCP the session was minted on — it otherwise defaults
115
- // to the prod MCP and won't see a qa session (→ "not signed in" → sample fallback).
116
- `tot start${mcpFlag}`,
117
- ].join("\n");
118
- return {
119
- ok: true,
120
- command,
121
- rendezvousCode: created.rendezvousCode,
122
- expiresAt: created.expiresIn != null ? new Date(Date.now() + created.expiresIn * 1000).toISOString() : null,
123
- };
124
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * "Stuck? Ask" recovery affordance. A quiet FAB that opens a scoped Q&A
3
- * for "why isn't the loop working" — NOT general AI editing. Static answers
4
- * ship as markup; the two stateful answers (is it running? / save-vs-reload)
5
- * update from the shared tot:loop-state signal + window.__totLoop (monitor.ts
6
- * — no second poll). "Reconnect preview" reloads the page, re-establishing
7
- * the HMR connection and re-reading loop state (recovers a stale client); a
8
- * fully-down server is handled by the answer text (run tot start). Imported
9
- * from a processed `<script>` in cockpit.astro (ADR 0013), rendered only when
10
- * isLocalDevLoop.
11
- */
12
- export function initAsk(): void {
13
- const fab = document.getElementById("askFab");
14
- const panel = document.getElementById("askPanel");
15
- if (!fab || !panel) return;
16
- const ansRunning = document.getElementById("ans-running");
17
- const ansChange = document.getElementById("ans-change");
18
- const restart = document.getElementById("restartBtn");
19
-
20
- fab.addEventListener("click", (e) => { e.stopPropagation(); panel.classList.toggle("open"); });
21
- document.addEventListener("click", (e) => {
22
- if (!panel.contains(e.target as Node) && e.target !== fab && !fab.contains(e.target as Node)) panel.classList.remove("open");
23
- });
24
- if (restart) restart.addEventListener("click", () => { location.reload(); });
25
-
26
- function rel(ts: number | string): string {
27
- const d = Math.max(0, Math.round((Date.now() - Number(ts)) / 1000));
28
- return d < 2 ? "just now" : d < 60 ? d + "s ago" : Math.floor(d / 60) + "m ago";
29
- }
30
- function update(s: any) {
31
- if (!s) return;
32
- if (ansRunning) {
33
- ansRunning.textContent = (s.offline || !s.server)
34
- ? "Your dev server isn't reachable right now — run tot start in your terminal, then reload this page."
35
- : "Yes — your server is running" + (s.port ? " on port " + s.port : "") + ". This page is connected to it.";
36
- }
37
- if (ansChange) {
38
- if (!s.lastSaveAt) {
39
- ansChange.textContent = "No saves seen yet. Edit a watched file (like content/home.html) and save — it'll show up here.";
40
- } else if ((s.lastReloadAt || 0) >= s.lastSaveAt) {
41
- ansChange.textContent = "Working: your last save (" + rel(s.lastSaveAt) + ") triggered a reload (" + rel(s.lastReloadAt) + "). If the page didn't visibly change, make sure you edited the file the page renders from.";
42
- } else {
43
- ansChange.textContent = "Your save (" + rel(s.lastSaveAt) + ") hasn't been reflected by a reload yet — the preview may be stale. Try Reconnect preview below.";
44
- }
45
- }
46
- }
47
- window.addEventListener("tot:loop-state", (e: any) => { update(e.detail); });
48
- if (window.__totLoop) update(window.__totLoop);
49
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * C8 · Click-to-source capstone — the cockpit side. Runs the live-preview
3
- * iframe (mini + full-screen dialog) and LISTENS for the framed picker's
4
- * tot:locate postMessage. The picker (ai-widget-client.js, auto-injected into
5
- * the same-origin preview) resolves a click to {path,line,col} via
6
- * /__tot/locate, then — because it is framed — postMessages the result here
7
- * instead of showing its own toast. We verify event.origin === our origin,
8
- * then hand off to files.ts's window.__totOpenFileAt to open the source +
9
- * drop the caret. Only content-region hits ever arrive (chrome/refused
10
- * clicks stay silent in the frame), per decision
11
- * click-to-source-anchors-at-content-region. Imported from a processed
12
- * `<script>` in cockpit.astro (ADR 0013), rendered only when isLocalDevLoop.
13
- * isDev and the hosted app domain are read from `document.body.dataset`.
14
- */
15
- export function initClickToSource(): void {
16
- const isDev = document.body.dataset.cockpitIsDev === "true";
17
- const hostedAppDomain = document.body.dataset.cockpitAppDomain || "";
18
- const dlg: any = document.getElementById("previewDialog");
19
- const expandBtn = document.getElementById("previewExpand");
20
- const closeBtn = document.getElementById("previewClose");
21
- const dlgFrame: any = document.getElementById("previewDialogFrame");
22
- const miniFrame: any = document.getElementById("previewFrame");
23
- const urlEl = document.getElementById("previewUrl");
24
-
25
- if (miniFrame) {
26
- if (isDev) {
27
- // Point the preview at the DEV tenant (TOT_DEV_TENANT), read from the server
28
- // via /__tot/dev-loop-status — NOT the SSR appDomain (workerd can't see
29
- // TOT_DEV_*). Same-origin, so the auto-injected picker can postMessage back.
30
- fetch("/__tot/dev-loop-status")
31
- .then((r) => r.json())
32
- .then((s) => {
33
- const tenant = s && s.tenant;
34
- if (!tenant) return;
35
- const src = "/" + tenant + "/";
36
- miniFrame.src = src;
37
- if (urlEl) urlEl.textContent = "localhost preview · " + tenant;
38
- })
39
- .catch(() => { /* dev server unreachable — preview stays blank */ });
40
- } else if (hostedAppDomain) {
41
- // Hosted: the SSR-resolved tenant IS the signed-in developer's own store
42
- // (cp-env's capability gate already scoped it) — same-origin, so a cp-write
43
- // save + this reload shows the developer's own draft overlay via the
44
- // middleware's tot_dev_draft cookie check.
45
- miniFrame.src = "/" + hostedAppDomain + "/";
46
- if (urlEl) urlEl.textContent = "your store · " + hostedAppDomain;
47
- }
48
- }
49
-
50
- if (expandBtn && dlg) {
51
- expandBtn.addEventListener("click", () => {
52
- if (dlgFrame && !dlgFrame.getAttribute("src") && miniFrame) dlgFrame.src = miniFrame.getAttribute("src") || miniFrame.src;
53
- if (typeof dlg.showModal === "function") dlg.showModal(); else dlg.setAttribute("open", "");
54
- });
55
- }
56
- if (closeBtn && dlg) closeBtn.addEventListener("click", () => { dlg.close ? dlg.close() : dlg.removeAttribute("open"); });
57
- if (dlg) dlg.addEventListener("click", (e: MouseEvent) => { if (e.target === dlg) { dlg.close ? dlg.close() : dlg.removeAttribute("open"); } });
58
-
59
- // The one privileged inbound message: a source location from OUR OWN origin's
60
- // framed preview. Reject any other origin, shape, or type outright.
61
- window.addEventListener("message", (e) => {
62
- if (e.origin !== window.location.origin) return;
63
- const d: any = e.data;
64
- if (!d || d.type !== "tot:locate" || typeof d.path !== "string") return;
65
- if (typeof (window as any).__totOpenFileAt === "function") {
66
- const opened = (window as any).__totOpenFileAt(d.path, d.line, d.col);
67
- // If the preview was expanded full-screen, close it so the editor + caret are visible.
68
- if (opened && dlg && dlg.open) { dlg.close ? dlg.close() : dlg.removeAttribute("open"); }
69
- }
70
- });
71
- }