@agent-native/core 0.99.1 → 0.99.3

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 (170) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +19 -0
  3. package/corpus/core/docs/content/a2a-protocol.mdx +42 -0
  4. package/corpus/core/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
  5. package/corpus/core/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
  6. package/corpus/core/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
  7. package/corpus/core/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
  8. package/corpus/core/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
  9. package/corpus/core/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
  10. package/corpus/core/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
  11. package/corpus/core/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
  12. package/corpus/core/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
  13. package/corpus/core/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
  14. package/corpus/core/package.json +1 -1
  15. package/corpus/core/src/agent/production-agent.ts +12 -38
  16. package/corpus/core/src/audit/config.ts +0 -1
  17. package/corpus/core/src/chat-threads/store.ts +57 -41
  18. package/corpus/core/src/client/AssistantChat.tsx +1 -2
  19. package/corpus/core/src/client/chat/message-components.tsx +15 -3
  20. package/corpus/core/src/client/chat/tool-call-display.tsx +18 -1
  21. package/corpus/core/src/client/extensions/EmbeddedExtension.tsx +5 -9
  22. package/corpus/core/src/client/extensions/ExtensionViewer.tsx +0 -133
  23. package/corpus/core/src/client/index.ts +7 -0
  24. package/corpus/core/src/client/settings/DemoModeSection.tsx +9 -65
  25. package/corpus/core/src/client/settings/SettingsPanel.tsx +1 -1
  26. package/corpus/core/src/client/use-db-sync.ts +3 -15
  27. package/corpus/core/src/client/use-demo-mode-status.ts +16 -30
  28. package/corpus/core/src/demo/browser-state.ts +47 -0
  29. package/corpus/core/src/demo/fetch-interceptor.ts +12 -59
  30. package/corpus/core/src/deploy/workspace-deploy.ts +2 -2
  31. package/corpus/core/src/server/action-discovery.ts +0 -1
  32. package/corpus/core/src/server/core-routes-plugin.ts +0 -30
  33. package/corpus/core/src/templates/workspace-core/.agents/skills/native-navigation/SKILL.md +67 -0
  34. package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +48 -7
  35. package/corpus/templates/analytics/AGENTS.md +4 -4
  36. package/corpus/templates/analytics/actions/compose-dashboard.ts +12 -1
  37. package/corpus/templates/analytics/actions/dashboard-mutation-api.ts +15 -4
  38. package/corpus/templates/analytics/actions/mutate-dashboard.ts +2 -1
  39. package/corpus/templates/analytics/actions/update-dashboard.ts +14 -0
  40. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +21 -27
  41. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +4 -1
  42. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/interpolate.ts +21 -0
  43. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +14 -0
  44. package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +31 -12
  45. package/corpus/templates/analytics/changelog/2026-07-13-dashboard-charts-now-honor-the-selected-time-range-by-defaul.md +6 -0
  46. package/corpus/templates/analytics/changelog/2026-07-13-keep-real-authorized-identities-in-analytics-incident-lookup.md +6 -0
  47. package/corpus/templates/analytics/changelog/2026-07-13-the-analytics-agents-tab-is-available-again-from-the-main-na.md +6 -0
  48. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +3 -3
  49. package/corpus/templates/analytics/server/lib/agent-readable-resource-context.ts +4 -0
  50. package/corpus/templates/analytics/server/lib/dashboard-time-scope.ts +170 -0
  51. package/corpus/templates/analytics/server/lib/error-capture.ts +6 -62
  52. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +20 -5
  53. package/corpus/templates/analytics/server/lib/session-replay-agent-context.ts +1 -1
  54. package/corpus/templates/analytics/server/lib/session-replay.ts +5 -111
  55. package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -0
  56. package/corpus/templates/assets/app/routes/library.tsx +3 -4
  57. package/corpus/templates/assets/changelog/2026-07-13-internal-library-links-open-in-new-tabs.md +6 -0
  58. package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +43 -40
  59. package/corpus/templates/calendar/app/pages/ManageBookingPage.tsx +6 -8
  60. package/corpus/templates/calendar/changelog/2026-07-13-booking-links-and-previews-open-in-new-tabs.md +6 -0
  61. package/corpus/templates/clips/app/components/player/sign-in-prompt-dialog.tsx +4 -7
  62. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +19 -9
  63. package/corpus/templates/clips/app/routes/share.$shareId.tsx +5 -3
  64. package/corpus/templates/clips/changelog/2026-07-13-recording-links-open-in-new-tabs.md +6 -0
  65. package/corpus/templates/content/app/components/editor/ContentReferencePreview.tsx +6 -8
  66. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +5 -3
  67. package/corpus/templates/content/app/components/editor/database/FormView.tsx +6 -9
  68. package/corpus/templates/content/changelog/2026-07-13-document-links-open-in-new-tabs.md +6 -0
  69. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +33 -16
  70. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +18 -1
  71. package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +4 -4
  72. package/corpus/templates/design/app/pages/DesignSystems.tsx +8 -10
  73. package/corpus/templates/design/app/pages/Index.tsx +6 -1
  74. package/corpus/templates/design/app/pages/Present.tsx +12 -6
  75. package/corpus/templates/design/changelog/2026-07-13-design-navigation-links-open-in-new-tabs.md +6 -0
  76. package/corpus/templates/design/changelog/2026-07-13-design-session-replays-include-preview-iframes.md +6 -0
  77. package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +11 -11
  78. package/corpus/templates/forms/app/pages/FormsListPage.tsx +6 -8
  79. package/corpus/templates/forms/changelog/2026-07-13-form-navigation-links-open-in-new-tabs.md +6 -0
  80. package/corpus/templates/mail/app/pages/DraftQueuePage.tsx +3 -8
  81. package/corpus/templates/mail/changelog/2026-07-13-settings-links-open-in-new-tabs.md +6 -0
  82. package/dist/agent/production-agent.d.ts.map +1 -1
  83. package/dist/agent/production-agent.js +13 -37
  84. package/dist/agent/production-agent.js.map +1 -1
  85. package/dist/audit/config.d.ts.map +1 -1
  86. package/dist/audit/config.js +0 -1
  87. package/dist/audit/config.js.map +1 -1
  88. package/dist/chat-threads/store.d.ts.map +1 -1
  89. package/dist/chat-threads/store.js +47 -33
  90. package/dist/chat-threads/store.js.map +1 -1
  91. package/dist/client/AssistantChat.d.ts.map +1 -1
  92. package/dist/client/AssistantChat.js +1 -1
  93. package/dist/client/AssistantChat.js.map +1 -1
  94. package/dist/client/chat/message-components.d.ts.map +1 -1
  95. package/dist/client/chat/message-components.js +9 -3
  96. package/dist/client/chat/message-components.js.map +1 -1
  97. package/dist/client/chat/tool-call-display.d.ts +3 -1
  98. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  99. package/dist/client/chat/tool-call-display.js +10 -2
  100. package/dist/client/chat/tool-call-display.js.map +1 -1
  101. package/dist/client/extensions/EmbeddedExtension.js +2 -6
  102. package/dist/client/extensions/EmbeddedExtension.js.map +1 -1
  103. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  104. package/dist/client/extensions/ExtensionViewer.js +2 -59
  105. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  106. package/dist/client/index.d.ts +2 -0
  107. package/dist/client/index.d.ts.map +1 -1
  108. package/dist/client/index.js +2 -0
  109. package/dist/client/index.js.map +1 -1
  110. package/dist/client/settings/DemoModeSection.d.ts +1 -13
  111. package/dist/client/settings/DemoModeSection.d.ts.map +1 -1
  112. package/dist/client/settings/DemoModeSection.js +5 -52
  113. package/dist/client/settings/DemoModeSection.js.map +1 -1
  114. package/dist/client/settings/SettingsPanel.js +1 -1
  115. package/dist/client/settings/SettingsPanel.js.map +1 -1
  116. package/dist/client/use-db-sync.d.ts.map +1 -1
  117. package/dist/client/use-db-sync.js +3 -7
  118. package/dist/client/use-db-sync.js.map +1 -1
  119. package/dist/client/use-demo-mode-status.d.ts +3 -4
  120. package/dist/client/use-demo-mode-status.d.ts.map +1 -1
  121. package/dist/client/use-demo-mode-status.js +8 -23
  122. package/dist/client/use-demo-mode-status.js.map +1 -1
  123. package/dist/collab/awareness.d.ts +2 -2
  124. package/dist/collab/awareness.d.ts.map +1 -1
  125. package/dist/collab/routes.d.ts +2 -2
  126. package/dist/collab/struct-routes.d.ts +1 -1
  127. package/dist/demo/browser-state.d.ts +10 -0
  128. package/dist/demo/browser-state.d.ts.map +1 -0
  129. package/dist/demo/browser-state.js +49 -0
  130. package/dist/demo/browser-state.js.map +1 -0
  131. package/dist/demo/fetch-interceptor.d.ts +2 -7
  132. package/dist/demo/fetch-interceptor.d.ts.map +1 -1
  133. package/dist/demo/fetch-interceptor.js +12 -56
  134. package/dist/demo/fetch-interceptor.js.map +1 -1
  135. package/dist/deploy/workspace-deploy.js +2 -2
  136. package/dist/deploy/workspace-deploy.js.map +1 -1
  137. package/dist/notifications/routes.d.ts +2 -2
  138. package/dist/observability/routes.d.ts +5 -5
  139. package/dist/resources/handlers.d.ts +3 -3
  140. package/dist/secrets/routes.d.ts +9 -9
  141. package/dist/server/action-discovery.d.ts.map +1 -1
  142. package/dist/server/action-discovery.js +0 -1
  143. package/dist/server/action-discovery.js.map +1 -1
  144. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  145. package/dist/server/core-routes-plugin.js +0 -27
  146. package/dist/server/core-routes-plugin.js.map +1 -1
  147. package/dist/templates/workspace-core/.agents/skills/native-navigation/SKILL.md +67 -0
  148. package/docs/content/a2a-protocol.mdx +42 -0
  149. package/docs/content/locales/ar-SA/a2a-protocol.mdx +42 -0
  150. package/docs/content/locales/de-DE/a2a-protocol.mdx +42 -0
  151. package/docs/content/locales/es-ES/a2a-protocol.mdx +42 -0
  152. package/docs/content/locales/fr-FR/a2a-protocol.mdx +42 -0
  153. package/docs/content/locales/hi-IN/a2a-protocol.mdx +42 -0
  154. package/docs/content/locales/ja-JP/a2a-protocol.mdx +42 -0
  155. package/docs/content/locales/ko-KR/a2a-protocol.mdx +42 -0
  156. package/docs/content/locales/pt-BR/a2a-protocol.mdx +42 -0
  157. package/docs/content/locales/zh-CN/a2a-protocol.mdx +42 -0
  158. package/docs/content/locales/zh-TW/a2a-protocol.mdx +42 -0
  159. package/package.json +1 -1
  160. package/src/templates/workspace-core/.agents/skills/native-navigation/SKILL.md +67 -0
  161. package/corpus/core/src/demo/actions/toggle-demo-mode.ts +0 -23
  162. package/corpus/core/src/demo/config.ts +0 -57
  163. package/dist/demo/actions/toggle-demo-mode.d.ts +0 -8
  164. package/dist/demo/actions/toggle-demo-mode.d.ts.map +0 -1
  165. package/dist/demo/actions/toggle-demo-mode.js +0 -21
  166. package/dist/demo/actions/toggle-demo-mode.js.map +0 -1
  167. package/dist/demo/config.d.ts +0 -9
  168. package/dist/demo/config.d.ts.map +0 -1
  169. package/dist/demo/config.js +0 -58
  170. package/dist/demo/config.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.99.1",
3
+ "version": "0.99.3",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: native-navigation
3
+ description: >-
4
+ Use when adding or reviewing UI navigation so internal routes preserve
5
+ normal SPA behavior plus Cmd/Ctrl-click and middle-click new-tab semantics.
6
+ scope: dev
7
+ ---
8
+
9
+ # Native Navigation
10
+
11
+ ## Rule
12
+
13
+ Pure navigation must render a real React Router `<Link>` for same-SPA routes,
14
+ a native `<a href>` for external/public or explicit new-tab destinations, or a
15
+ shadcn `Button asChild` wrapper around one. Do not use a button whose only job
16
+ is to call `navigate()`, `window.open()`, or `window.location`.
17
+
18
+ ## Why
19
+
20
+ Browser modifier-click, middle-click, keyboard activation, accessibility, and
21
+ normal client-side routing come from real links. Imperative JavaScript
22
+ navigation hides the destination and blocks those browser semantics.
23
+
24
+ ## How
25
+
26
+ ```tsx
27
+ import { Link } from "react-router";
28
+
29
+ <Link to={`/items/${item.id}`}>...</Link>
30
+
31
+ <Button asChild>
32
+ <Link to="/settings">Settings</Link>
33
+ </Button>
34
+
35
+ <a href={previewUrl} target="_blank" rel="noopener noreferrer">
36
+ Preview
37
+ </a>
38
+ ```
39
+
40
+ - Use `Link` for same-SPA internal routes.
41
+ - Use `<a>` when the URL is external, crosses an app/public boundary, is an
42
+ auth or sign-in destination, or intentionally opens in a new tab.
43
+ - Preserve query strings and hashes in `to` or `href`.
44
+ - For cards with nested actions, link only the non-interactive card region or
45
+ use a transparent Link overlay; never nest links or buttons.
46
+ - If selection mode changes click behavior, prevent default only for an
47
+ unmodified primary click and preserve modified clicks.
48
+
49
+ Keep imperative navigation for post-mutation redirects, OAuth and popup flows,
50
+ downloads, media/blob URLs, playback, keyboard shortcuts, and stateful tabs.
51
+
52
+ ## Review
53
+
54
+ Search for `onClick={() => navigate`, `window.open`, `window.location`,
55
+ `onAuxClick`, and buttons whose only purpose is routing. For each candidate,
56
+ confirm whether it is pure navigation or a stateful workflow before changing
57
+ it.
58
+
59
+ Verify the rendered DOM exposes an `href`, then test normal click, Cmd/Ctrl-click,
60
+ middle-click, keyboard Enter, and nested controls where applicable. Run oxfmt
61
+ and focused app tests or typechecks for the touched package.
62
+
63
+ ## Related Skills
64
+
65
+ - `client-side-routing`
66
+ - `frontend-design`
67
+ - `shadcn-ui`
@@ -1,23 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { defineAction } from "../../action.js";
4
- import { writeAppState } from "../../application-state/script-helpers.js";
5
-
6
- export default defineAction({
7
- description:
8
- "Turn demo mode on or off. When demo mode is on, the UI replaces every email address with anonymous@builder.io and supported dashboards reshape chart values for presentations. Agent-visible results use the same anonymous email and anonymize numbers while keeping names, free text, labels, IDs, dates, and structure intact. Use when the user asks to 'hide my data', 'turn on demo mode', 'anonymize this for a screen share / recording', or similar. This is the same toggle as the Demo mode switch in settings.",
9
- schema: z.object({
10
- enabled: z
11
- .boolean()
12
- .describe("true to turn demo mode on, false to turn it off."),
13
- }),
14
- run: async ({ enabled }) => {
15
- await writeAppState("demo-mode", { enabled });
16
- return {
17
- enabled,
18
- message: enabled
19
- ? "Demo mode is ON — UI emails are anonymized and supported dashboard charts are reshaped for presentation. Agent-visible emails and numbers are also anonymized. Names, free text, labels, IDs, and structure are preserved."
20
- : "Demo mode is OFF — real data is shown again.",
21
- };
22
- },
23
- });
@@ -1,57 +0,0 @@
1
- /**
2
- * Demo mode gate.
3
- *
4
- * Demo mode replaces every email address with `anonymous@builder.io` and
5
- * anonymizes numbers in every action result — for both the UI and what the
6
- * agent sees — while preserving names, free text, labels, IDs, dates, URLs,
7
- * and structure so the app keeps working. The redaction WALK (see ./redact.ts)
8
- * is expensive on large payloads, so callers MUST gate it behind this function
9
- * and only walk when it returns true.
10
- *
11
- * This gate itself is intentionally cheap:
12
- * - An env-forced deployment (a hosted demo site) short-circuits with zero
13
- * I/O — `DEMO_MODE=true`.
14
- * - The per-user runtime toggle lives in `application_state` under the
15
- * `demo-mode` key (`{ enabled: boolean }`), written by the settings UI and
16
- * the `toggle-demo-mode` agent action. It's read behind a short in-process
17
- * TTL cache keyed by user, so a tight agent tool-call loop doesn't hit the
18
- * DB on every result.
19
- */
20
- import { readAppState } from "../application-state/script-helpers.js";
21
-
22
- const TTL_MS = 3_000;
23
- const cache = new Map<string, { value: boolean; at: number }>();
24
-
25
- /** Deployment-wide force (hosted demo site). Zero cost — no I/O. */
26
- export function isDemoModeForced(): boolean {
27
- return process.env.DEMO_MODE === "true";
28
- }
29
-
30
- /**
31
- * Whether demo-mode redaction should run for the current request/user.
32
- * Cheap by design — safe to call before every action result; the expensive
33
- * walk only happens when this is true.
34
- */
35
- export async function isDemoModeEnabled(): Promise<boolean> {
36
- if (isDemoModeForced()) return true;
37
- try {
38
- let sessionKey = "_";
39
- try {
40
- const { getRequestUserEmail } =
41
- await import("../server/request-context.js");
42
- sessionKey = getRequestUserEmail() ?? process.env.AGENT_USER_EMAIL ?? "_";
43
- } catch {
44
- // request-context unavailable (CLI / non-server) — use default key
45
- }
46
- const now = Date.now();
47
- const hit = cache.get(sessionKey);
48
- if (hit && now - hit.at < TTL_MS) return hit.value;
49
- const state = await readAppState("demo-mode");
50
- const enabled = state?.enabled === true;
51
- cache.set(sessionKey, { value: enabled, at: now });
52
- return enabled;
53
- } catch {
54
- // No request context / DB unavailable — fail closed (no redaction).
55
- return false;
56
- }
57
- }
@@ -1,8 +0,0 @@
1
- declare const _default: import("../../action.js").ActionDefinition<{
2
- enabled: boolean;
3
- }, {
4
- enabled: boolean;
5
- message: string;
6
- }>;
7
- export default _default;
8
- //# sourceMappingURL=toggle-demo-mode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toggle-demo-mode.d.ts","sourceRoot":"","sources":["../../../src/demo/actions/toggle-demo-mode.ts"],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- import { z } from "zod";
2
- import { defineAction } from "../../action.js";
3
- import { writeAppState } from "../../application-state/script-helpers.js";
4
- export default defineAction({
5
- description: "Turn demo mode on or off. When demo mode is on, the UI replaces every email address with anonymous@builder.io and supported dashboards reshape chart values for presentations. Agent-visible results use the same anonymous email and anonymize numbers while keeping names, free text, labels, IDs, dates, and structure intact. Use when the user asks to 'hide my data', 'turn on demo mode', 'anonymize this for a screen share / recording', or similar. This is the same toggle as the Demo mode switch in settings.",
6
- schema: z.object({
7
- enabled: z
8
- .boolean()
9
- .describe("true to turn demo mode on, false to turn it off."),
10
- }),
11
- run: async ({ enabled }) => {
12
- await writeAppState("demo-mode", { enabled });
13
- return {
14
- enabled,
15
- message: enabled
16
- ? "Demo mode is ON — UI emails are anonymized and supported dashboard charts are reshaped for presentation. Agent-visible emails and numbers are also anonymized. Names, free text, labels, IDs, and structure are preserved."
17
- : "Demo mode is OFF — real data is shown again.",
18
- };
19
- },
20
- });
21
- //# sourceMappingURL=toggle-demo-mode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toggle-demo-mode.js","sourceRoot":"","sources":["../../../src/demo/actions/toggle-demo-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,4fAA4f;IAC9f,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC;aACP,OAAO,EAAE;aACT,QAAQ,CAAC,kDAAkD,CAAC;KAChE,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACzB,MAAM,aAAa,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO;YACL,OAAO;YACP,OAAO,EAAE,OAAO;gBACd,CAAC,CAAC,4NAA4N;gBAC9N,CAAC,CAAC,8CAA8C;SACnD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { writeAppState } from \"../../application-state/script-helpers.js\";\n\nexport default defineAction({\n description:\n \"Turn demo mode on or off. When demo mode is on, the UI replaces every email address with anonymous@builder.io and supported dashboards reshape chart values for presentations. Agent-visible results use the same anonymous email and anonymize numbers while keeping names, free text, labels, IDs, dates, and structure intact. Use when the user asks to 'hide my data', 'turn on demo mode', 'anonymize this for a screen share / recording', or similar. This is the same toggle as the Demo mode switch in settings.\",\n schema: z.object({\n enabled: z\n .boolean()\n .describe(\"true to turn demo mode on, false to turn it off.\"),\n }),\n run: async ({ enabled }) => {\n await writeAppState(\"demo-mode\", { enabled });\n return {\n enabled,\n message: enabled\n ? \"Demo mode is ON — UI emails are anonymized and supported dashboard charts are reshaped for presentation. Agent-visible emails and numbers are also anonymized. Names, free text, labels, IDs, and structure are preserved.\"\n : \"Demo mode is OFF — real data is shown again.\",\n };\n },\n});\n"]}
@@ -1,9 +0,0 @@
1
- /** Deployment-wide force (hosted demo site). Zero cost — no I/O. */
2
- export declare function isDemoModeForced(): boolean;
3
- /**
4
- * Whether demo-mode redaction should run for the current request/user.
5
- * Cheap by design — safe to call before every action result; the expensive
6
- * walk only happens when this is true.
7
- */
8
- export declare function isDemoModeEnabled(): Promise<boolean>;
9
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/demo/config.ts"],"names":[],"mappings":"AAwBA,oEAAoE;AACpE,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAsB1D"}
@@ -1,58 +0,0 @@
1
- /**
2
- * Demo mode gate.
3
- *
4
- * Demo mode replaces every email address with `anonymous@builder.io` and
5
- * anonymizes numbers in every action result — for both the UI and what the
6
- * agent sees — while preserving names, free text, labels, IDs, dates, URLs,
7
- * and structure so the app keeps working. The redaction WALK (see ./redact.ts)
8
- * is expensive on large payloads, so callers MUST gate it behind this function
9
- * and only walk when it returns true.
10
- *
11
- * This gate itself is intentionally cheap:
12
- * - An env-forced deployment (a hosted demo site) short-circuits with zero
13
- * I/O — `DEMO_MODE=true`.
14
- * - The per-user runtime toggle lives in `application_state` under the
15
- * `demo-mode` key (`{ enabled: boolean }`), written by the settings UI and
16
- * the `toggle-demo-mode` agent action. It's read behind a short in-process
17
- * TTL cache keyed by user, so a tight agent tool-call loop doesn't hit the
18
- * DB on every result.
19
- */
20
- import { readAppState } from "../application-state/script-helpers.js";
21
- const TTL_MS = 3_000;
22
- const cache = new Map();
23
- /** Deployment-wide force (hosted demo site). Zero cost — no I/O. */
24
- export function isDemoModeForced() {
25
- return process.env.DEMO_MODE === "true";
26
- }
27
- /**
28
- * Whether demo-mode redaction should run for the current request/user.
29
- * Cheap by design — safe to call before every action result; the expensive
30
- * walk only happens when this is true.
31
- */
32
- export async function isDemoModeEnabled() {
33
- if (isDemoModeForced())
34
- return true;
35
- try {
36
- let sessionKey = "_";
37
- try {
38
- const { getRequestUserEmail } = await import("../server/request-context.js");
39
- sessionKey = getRequestUserEmail() ?? process.env.AGENT_USER_EMAIL ?? "_";
40
- }
41
- catch {
42
- // request-context unavailable (CLI / non-server) — use default key
43
- }
44
- const now = Date.now();
45
- const hit = cache.get(sessionKey);
46
- if (hit && now - hit.at < TTL_MS)
47
- return hit.value;
48
- const state = await readAppState("demo-mode");
49
- const enabled = state?.enabled === true;
50
- cache.set(sessionKey, { value: enabled, at: now });
51
- return enabled;
52
- }
53
- catch {
54
- // No request context / DB unavailable — fail closed (no redaction).
55
- return false;
56
- }
57
- }
58
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/demo/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,MAAM,MAAM,GAAG,KAAK,CAAC;AACrB,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0C,CAAC;AAEhE,oEAAoE;AACpE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,gBAAgB,EAAE;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,CAAC;QACH,IAAI,UAAU,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,EAAE,mBAAmB,EAAE,GAC3B,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;YAC/C,UAAU,GAAG,mBAAmB,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,mEAAmE;QACrE,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAClC,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,EAAE,GAAG,MAAM;YAAE,OAAO,GAAG,CAAC,KAAK,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,WAAW,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QACxC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;QACpE,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["/**\n * Demo mode gate.\n *\n * Demo mode replaces every email address with `anonymous@builder.io` and\n * anonymizes numbers in every action result — for both the UI and what the\n * agent sees — while preserving names, free text, labels, IDs, dates, URLs,\n * and structure so the app keeps working. The redaction WALK (see ./redact.ts)\n * is expensive on large payloads, so callers MUST gate it behind this function\n * and only walk when it returns true.\n *\n * This gate itself is intentionally cheap:\n * - An env-forced deployment (a hosted demo site) short-circuits with zero\n * I/O — `DEMO_MODE=true`.\n * - The per-user runtime toggle lives in `application_state` under the\n * `demo-mode` key (`{ enabled: boolean }`), written by the settings UI and\n * the `toggle-demo-mode` agent action. It's read behind a short in-process\n * TTL cache keyed by user, so a tight agent tool-call loop doesn't hit the\n * DB on every result.\n */\nimport { readAppState } from \"../application-state/script-helpers.js\";\n\nconst TTL_MS = 3_000;\nconst cache = new Map<string, { value: boolean; at: number }>();\n\n/** Deployment-wide force (hosted demo site). Zero cost — no I/O. */\nexport function isDemoModeForced(): boolean {\n return process.env.DEMO_MODE === \"true\";\n}\n\n/**\n * Whether demo-mode redaction should run for the current request/user.\n * Cheap by design — safe to call before every action result; the expensive\n * walk only happens when this is true.\n */\nexport async function isDemoModeEnabled(): Promise<boolean> {\n if (isDemoModeForced()) return true;\n try {\n let sessionKey = \"_\";\n try {\n const { getRequestUserEmail } =\n await import(\"../server/request-context.js\");\n sessionKey = getRequestUserEmail() ?? process.env.AGENT_USER_EMAIL ?? \"_\";\n } catch {\n // request-context unavailable (CLI / non-server) — use default key\n }\n const now = Date.now();\n const hit = cache.get(sessionKey);\n if (hit && now - hit.at < TTL_MS) return hit.value;\n const state = await readAppState(\"demo-mode\");\n const enabled = state?.enabled === true;\n cache.set(sessionKey, { value: enabled, at: now });\n return enabled;\n } catch {\n // No request context / DB unavailable — fail closed (no redaction).\n return false;\n }\n}\n"]}