@agent-native/core 0.86.0 → 0.86.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 (183) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +9 -0
  3. package/corpus/core/package.json +2 -1
  4. package/corpus/core/src/client/AgentPanel.tsx +10 -0
  5. package/corpus/core/src/client/AssistantChat.tsx +91 -27
  6. package/corpus/core/src/client/ErrorBoundary.tsx +67 -12
  7. package/corpus/core/src/client/ErrorReportActions.tsx +69 -0
  8. package/corpus/core/src/client/FeedbackButton.tsx +8 -4
  9. package/corpus/core/src/client/db-admin/DbAdminPage.tsx +41 -13
  10. package/corpus/core/src/client/db-admin/SqlEditor.tsx +10 -3
  11. package/corpus/core/src/client/db-admin/TableEditor.tsx +12 -5
  12. package/corpus/core/src/client/db-admin/useAgentSync.ts +10 -3
  13. package/corpus/core/src/client/db-admin/useDbAdmin.ts +65 -16
  14. package/corpus/core/src/client/error-reporting.ts +100 -0
  15. package/corpus/core/src/client/index.ts +11 -0
  16. package/corpus/core/src/client/org/RequireActiveOrg.tsx +12 -0
  17. package/corpus/core/src/client/visual-style-controls.tsx +615 -2
  18. package/corpus/core/src/db-admin/index.ts +26 -0
  19. package/corpus/core/src/db-admin/operations.ts +87 -49
  20. package/corpus/core/src/localization/default-messages.ts +4 -0
  21. package/corpus/core/src/server/builder-design-systems.ts +328 -9
  22. package/corpus/core/src/server/index.ts +15 -0
  23. package/corpus/core/src/templates/default/app/root.tsx +47 -0
  24. package/corpus/templates/analytics/AGENTS.md +6 -4
  25. package/corpus/templates/analytics/actions/delete-db-admin-connection.ts +19 -0
  26. package/corpus/templates/analytics/actions/list-db-admin-connections.ts +18 -0
  27. package/corpus/templates/analytics/actions/navigate.ts +17 -3
  28. package/corpus/templates/analytics/actions/save-db-admin-connection.ts +33 -0
  29. package/corpus/templates/analytics/actions/view-screen.ts +11 -3
  30. package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +11 -2
  31. package/corpus/templates/analytics/app/i18n/zh-TW.ts +23 -2
  32. package/corpus/templates/analytics/app/i18n-data.ts +230 -20
  33. package/corpus/templates/analytics/app/pages/Agents.tsx +398 -4
  34. package/corpus/templates/analytics/changelog/2026-07-03-connect-other-app-databases-from-analytics.md +6 -0
  35. package/corpus/templates/analytics/server/db/schema.ts +27 -0
  36. package/corpus/templates/analytics/server/lib/db-admin-connections.ts +458 -0
  37. package/corpus/templates/analytics/server/plugins/db.ts +35 -0
  38. package/corpus/templates/analytics/server/routes/[base]/_agent-native/analytics-db-admin/[...path].ts +1 -0
  39. package/corpus/templates/analytics/server/routes/_agent-native/analytics-db-admin/[...path].ts +160 -0
  40. package/corpus/templates/content/app/root.tsx +9 -0
  41. package/corpus/templates/content/changelog/2026-07-03-error-screens-now-include-a-feedback-button-with-debug-info.md +6 -0
  42. package/corpus/templates/design/AGENTS.md +13 -7
  43. package/corpus/templates/design/actions/get-design-system.ts +21 -0
  44. package/corpus/templates/design/actions/index-design-system-with-builder.ts +14 -37
  45. package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbench.tsx +3 -3
  46. package/corpus/templates/design/app/components/design/code-workbench/SideBar.tsx +70 -9
  47. package/corpus/templates/design/app/components/design/code-workbench/editor/EditorTabs.tsx +11 -2
  48. package/corpus/templates/design/app/components/design/code-workbench/editor/MonacoHost.tsx +1 -1
  49. package/corpus/templates/design/app/components/design/code-workbench/editor/StatusBar.tsx +1 -1
  50. package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +8 -2
  51. package/corpus/templates/design/app/components/design/code-workbench/explorer/FileTree.tsx +7 -3
  52. package/corpus/templates/design/app/components/design/code-workbench/store.tsx +48 -0
  53. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +6 -0
  54. package/corpus/templates/design/app/i18n/zh-TW.ts +15 -14
  55. package/corpus/templates/design/app/i18n-data.ts +154 -142
  56. package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +32 -14
  57. package/corpus/templates/design/changelog/2026-07-03-design-system-setup-now-indexes-figma-code-and-design-md-sou.md +6 -0
  58. package/corpus/templates/design/changelog/2026-07-03-the-code-editor-is-easier-to-use-with-top-sidebar-tabs-clear.md +6 -0
  59. package/corpus/templates/design/server/lib/builder-design-system-proxy.ts +16 -106
  60. package/corpus/templates/mail/app/root.tsx +60 -1
  61. package/corpus/templates/mail/changelog/2026-07-03-error-screens-now-include-a-feedback-button-with-debug-info.md +6 -0
  62. package/corpus/templates/plan/app/i18n/ar-SA.ts +3 -0
  63. package/corpus/templates/plan/app/i18n/de-DE.ts +4 -0
  64. package/corpus/templates/plan/app/i18n/en-US.ts +4 -0
  65. package/corpus/templates/plan/app/i18n/es-ES.ts +4 -0
  66. package/corpus/templates/plan/app/i18n/fr-FR.ts +4 -0
  67. package/corpus/templates/plan/app/i18n/hi-IN.ts +3 -0
  68. package/corpus/templates/plan/app/i18n/ja-JP.ts +4 -0
  69. package/corpus/templates/plan/app/i18n/ko-KR.ts +4 -0
  70. package/corpus/templates/plan/app/i18n/pt-BR.ts +4 -0
  71. package/corpus/templates/plan/app/i18n/zh-CN.ts +3 -0
  72. package/corpus/templates/plan/app/i18n/zh-TW.ts +3 -0
  73. package/corpus/templates/plan/app/pages/PlansPage.tsx +74 -3
  74. package/corpus/templates/plan/changelog/2026-07-03-error-screens-now-include-a-feedback-button-with-debug-info.md +6 -0
  75. package/corpus/templates/slides/AGENTS.md +7 -3
  76. package/corpus/templates/slides/actions/get-design-system.ts +21 -0
  77. package/corpus/templates/slides/actions/import-file.ts +15 -7
  78. package/corpus/templates/slides/actions/index-design-system-with-builder.ts +14 -37
  79. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +32 -8
  80. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +2 -2
  81. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +2 -4
  82. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +163 -154
  83. package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +19 -15
  84. package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +56 -6
  85. package/corpus/templates/slides/app/components/layout/Layout.tsx +6 -1
  86. package/corpus/templates/slides/app/i18n/ar-SA.ts +8 -7
  87. package/corpus/templates/slides/app/i18n/de-DE.ts +7 -8
  88. package/corpus/templates/slides/app/i18n/en-US.ts +8 -7
  89. package/corpus/templates/slides/app/i18n/es-ES.ts +7 -8
  90. package/corpus/templates/slides/app/i18n/fr-FR.ts +7 -8
  91. package/corpus/templates/slides/app/i18n/hi-IN.ts +8 -7
  92. package/corpus/templates/slides/app/i18n/ja-JP.ts +7 -8
  93. package/corpus/templates/slides/app/i18n/ko-KR.ts +7 -7
  94. package/corpus/templates/slides/app/i18n/pt-BR.ts +7 -8
  95. package/corpus/templates/slides/app/i18n/zh-CN.ts +8 -7
  96. package/corpus/templates/slides/app/i18n/zh-TW.ts +8 -7
  97. package/corpus/templates/slides/app/lib/canvas-zoom.ts +16 -1
  98. package/corpus/templates/slides/app/pages/DeckEditor.tsx +3 -3
  99. package/corpus/templates/slides/changelog/2026-07-03-design-system-setup-now-indexes-figma-code-and-design-md-sou.md +6 -0
  100. package/corpus/templates/slides/changelog/2026-07-03-slide-editing-now-keeps-thumbnails-speaker-notes-styling-and.md +6 -0
  101. package/corpus/templates/slides/server/lib/builder-design-system-proxy.ts +16 -104
  102. package/dist/client/AgentPanel.d.ts.map +1 -1
  103. package/dist/client/AgentPanel.js +2 -1
  104. package/dist/client/AgentPanel.js.map +1 -1
  105. package/dist/client/AssistantChat.d.ts.map +1 -1
  106. package/dist/client/AssistantChat.js +77 -25
  107. package/dist/client/AssistantChat.js.map +1 -1
  108. package/dist/client/ErrorBoundary.d.ts.map +1 -1
  109. package/dist/client/ErrorBoundary.js +37 -2
  110. package/dist/client/ErrorBoundary.js.map +1 -1
  111. package/dist/client/ErrorReportActions.d.ts +13 -0
  112. package/dist/client/ErrorReportActions.d.ts.map +1 -0
  113. package/dist/client/ErrorReportActions.js +14 -0
  114. package/dist/client/ErrorReportActions.js.map +1 -0
  115. package/dist/client/FeedbackButton.d.ts +3 -1
  116. package/dist/client/FeedbackButton.d.ts.map +1 -1
  117. package/dist/client/FeedbackButton.js +6 -5
  118. package/dist/client/FeedbackButton.js.map +1 -1
  119. package/dist/client/db-admin/DbAdminPage.d.ts +9 -1
  120. package/dist/client/db-admin/DbAdminPage.d.ts.map +1 -1
  121. package/dist/client/db-admin/DbAdminPage.js +17 -13
  122. package/dist/client/db-admin/DbAdminPage.js.map +1 -1
  123. package/dist/client/db-admin/SqlEditor.d.ts +3 -1
  124. package/dist/client/db-admin/SqlEditor.d.ts.map +1 -1
  125. package/dist/client/db-admin/SqlEditor.js +3 -3
  126. package/dist/client/db-admin/SqlEditor.js.map +1 -1
  127. package/dist/client/db-admin/TableEditor.d.ts +3 -1
  128. package/dist/client/db-admin/TableEditor.d.ts.map +1 -1
  129. package/dist/client/db-admin/TableEditor.js +6 -6
  130. package/dist/client/db-admin/TableEditor.js.map +1 -1
  131. package/dist/client/db-admin/useAgentSync.d.ts +3 -2
  132. package/dist/client/db-admin/useAgentSync.d.ts.map +1 -1
  133. package/dist/client/db-admin/useAgentSync.js +8 -4
  134. package/dist/client/db-admin/useAgentSync.js.map +1 -1
  135. package/dist/client/db-admin/useDbAdmin.d.ts +11 -7
  136. package/dist/client/db-admin/useDbAdmin.d.ts.map +1 -1
  137. package/dist/client/db-admin/useDbAdmin.js +45 -20
  138. package/dist/client/db-admin/useDbAdmin.js.map +1 -1
  139. package/dist/client/error-reporting.d.ts +19 -0
  140. package/dist/client/error-reporting.d.ts.map +1 -0
  141. package/dist/client/error-reporting.js +71 -0
  142. package/dist/client/error-reporting.js.map +1 -0
  143. package/dist/client/index.d.ts +3 -1
  144. package/dist/client/index.d.ts.map +1 -1
  145. package/dist/client/index.js +3 -1
  146. package/dist/client/index.js.map +1 -1
  147. package/dist/client/org/RequireActiveOrg.d.ts.map +1 -1
  148. package/dist/client/org/RequireActiveOrg.js +2 -1
  149. package/dist/client/org/RequireActiveOrg.js.map +1 -1
  150. package/dist/client/visual-style-controls.d.ts +11 -0
  151. package/dist/client/visual-style-controls.d.ts.map +1 -1
  152. package/dist/client/visual-style-controls.js +350 -1
  153. package/dist/client/visual-style-controls.js.map +1 -1
  154. package/dist/collab/routes.d.ts +1 -1
  155. package/dist/collab/struct-routes.d.ts +1 -1
  156. package/dist/db-admin/index.d.ts +3 -0
  157. package/dist/db-admin/index.d.ts.map +1 -0
  158. package/dist/db-admin/index.js +2 -0
  159. package/dist/db-admin/index.js.map +1 -0
  160. package/dist/db-admin/operations.d.ts +26 -5
  161. package/dist/db-admin/operations.d.ts.map +1 -1
  162. package/dist/db-admin/operations.js +66 -55
  163. package/dist/db-admin/operations.js.map +1 -1
  164. package/dist/localization/default-messages.d.ts +3 -0
  165. package/dist/localization/default-messages.d.ts.map +1 -1
  166. package/dist/localization/default-messages.js +3 -0
  167. package/dist/localization/default-messages.js.map +1 -1
  168. package/dist/notifications/routes.d.ts +1 -1
  169. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  170. package/dist/resources/handlers.d.ts +1 -1
  171. package/dist/secrets/routes.d.ts +9 -9
  172. package/dist/server/builder-design-systems.d.ts +61 -0
  173. package/dist/server/builder-design-systems.d.ts.map +1 -1
  174. package/dist/server/builder-design-systems.js +219 -14
  175. package/dist/server/builder-design-systems.js.map +1 -1
  176. package/dist/server/index.d.ts +1 -1
  177. package/dist/server/index.d.ts.map +1 -1
  178. package/dist/server/index.js +1 -1
  179. package/dist/server/index.js.map +1 -1
  180. package/dist/server/transcribe-voice.d.ts +1 -1
  181. package/dist/templates/default/app/root.tsx +47 -0
  182. package/package.json +2 -1
  183. package/src/templates/default/app/root.tsx +47 -0
@@ -12,6 +12,68 @@ export interface BuilderDesignSystemIndexFile {
12
12
  mimeType?: string;
13
13
  }
14
14
 
15
+ export interface BuilderDesignSystemCodeFileInput {
16
+ filename: string;
17
+ content: string;
18
+ mimeType?: string;
19
+ }
20
+
21
+ export interface BuildBuilderDesignSystemIndexFilesOptions {
22
+ codeFiles?: BuilderDesignSystemCodeFileInput[];
23
+ designMd?: string;
24
+ designMdFilename?: string;
25
+ maxCodeFiles?: number;
26
+ maxTotalCodeBytes?: number;
27
+ }
28
+
29
+ export interface BuilderDesignSystemProxyFieldsOptions {
30
+ result: BuilderDesignSystemIndexResult;
31
+ projectName?: string;
32
+ description?: string;
33
+ surface: "design" | "slides";
34
+ }
35
+
36
+ export interface BuilderDesignSystemProxyFields {
37
+ title: string;
38
+ description: string;
39
+ data: string;
40
+ customInstructions: string;
41
+ }
42
+
43
+ export interface BuilderDesignSystemProxyReference {
44
+ source: "builder";
45
+ builderDesignSystemId: string;
46
+ builderJobId: string;
47
+ builderProjectId?: string;
48
+ builderUrl?: string;
49
+ builderStatus?: string;
50
+ }
51
+
52
+ export interface BuilderDesignSystemDocsOptions {
53
+ page?: number;
54
+ pageSize?: number;
55
+ minimal?: boolean;
56
+ type?: string;
57
+ }
58
+
59
+ export interface BuilderDesignSystemDocument {
60
+ id?: string;
61
+ name?: string;
62
+ type?: string;
63
+ description?: string;
64
+ content?: string;
65
+ tokenValues?: Record<string, string>;
66
+ rawTokens?: string[];
67
+ relevantFiles?: string[];
68
+ relatedComponents?: string[];
69
+ }
70
+
71
+ export interface BuilderDesignSystemHydratedReference extends BuilderDesignSystemProxyReference {
72
+ docs: BuilderDesignSystemDocument[];
73
+ tokenValues: Record<string, string>;
74
+ docCount: number;
75
+ }
76
+
15
77
  export interface BuilderDesignSystemIndexOptions {
16
78
  projectName?: string;
17
79
  description?: string;
@@ -49,6 +111,10 @@ interface GenerateResponse {
49
111
  designSystemId?: string;
50
112
  }
51
113
 
114
+ const DEFAULT_MAX_CODE_FILES = 50;
115
+ const DEFAULT_MAX_TOTAL_CODE_BYTES = 2 * 1024 * 1024;
116
+ const MAX_DOC_CONTENT_CHARS = 4_000;
117
+
52
118
  function trimTrailingSlash(value: string): string {
53
119
  return value.replace(/\/+$/, "");
54
120
  }
@@ -89,6 +155,66 @@ function makeBuilderHeaders(
89
155
  };
90
156
  }
91
157
 
158
+ export function mimeTypeForBuilderDesignSystemFilename(
159
+ filename: string,
160
+ explicit?: string,
161
+ ): string {
162
+ if (explicit?.trim()) return explicit.trim();
163
+ const lower = filename.toLowerCase();
164
+ if (lower.endsWith(".fig")) return "application/octet-stream";
165
+ if (lower.endsWith(".pdf")) return "application/pdf";
166
+ if (lower.endsWith(".md") || lower.endsWith(".markdown"))
167
+ return "text/markdown";
168
+ if (lower.endsWith(".mdx")) return "text/markdown";
169
+ if (lower.endsWith(".json")) return "application/json";
170
+ if (lower.endsWith(".css")) return "text/css";
171
+ if (lower.endsWith(".html") || lower.endsWith(".htm")) return "text/html";
172
+ if (lower.endsWith(".svg")) return "image/svg+xml";
173
+ return "text/plain";
174
+ }
175
+
176
+ export function buildBuilderDesignSystemIndexFiles({
177
+ codeFiles,
178
+ designMd,
179
+ designMdFilename,
180
+ maxCodeFiles = DEFAULT_MAX_CODE_FILES,
181
+ maxTotalCodeBytes = DEFAULT_MAX_TOTAL_CODE_BYTES,
182
+ }: BuildBuilderDesignSystemIndexFilesOptions): BuilderDesignSystemIndexFile[] {
183
+ const encoder = new TextEncoder();
184
+ const files: BuilderDesignSystemIndexFile[] = [];
185
+ let totalBytes = 0;
186
+
187
+ function pushTextFile(filename: string, content: string, mimeType?: string) {
188
+ const normalizedName = filename.replace(/^\/+/, "") || "code.txt";
189
+ const data = encoder.encode(content);
190
+ if (data.byteLength === 0) return;
191
+ if (totalBytes + data.byteLength > maxTotalCodeBytes) return;
192
+ totalBytes += data.byteLength;
193
+ files.push({
194
+ name: normalizedName,
195
+ data,
196
+ mimeType: mimeTypeForBuilderDesignSystemFilename(
197
+ normalizedName,
198
+ mimeType,
199
+ ),
200
+ });
201
+ }
202
+
203
+ if (designMd?.trim()) {
204
+ pushTextFile(
205
+ designMdFilename?.trim() || "design.md",
206
+ designMd,
207
+ "text/markdown",
208
+ );
209
+ }
210
+
211
+ for (const file of (codeFiles ?? []).slice(0, maxCodeFiles)) {
212
+ pushTextFile(file.filename, file.content, file.mimeType);
213
+ }
214
+
215
+ return files;
216
+ }
217
+
92
218
  async function resolveBuilderDesignSystemCredentials(): Promise<BuilderDesignSystemCredentials> {
93
219
  const credentials = await resolveBuilderCredentials();
94
220
  if (!credentials.privateKey || !credentials.publicKey) {
@@ -107,15 +233,7 @@ async function resolveBuilderDesignSystemCredentials(): Promise<BuilderDesignSys
107
233
  }
108
234
 
109
235
  function mimeTypeForFile(file: BuilderDesignSystemIndexFile): string {
110
- if (file.mimeType?.trim()) return file.mimeType.trim();
111
- const lower = file.name.toLowerCase();
112
- if (lower.endsWith(".fig")) return "application/octet-stream";
113
- if (lower.endsWith(".pdf")) return "application/pdf";
114
- if (lower.endsWith(".md") || lower.endsWith(".markdown"))
115
- return "text/markdown";
116
- if (lower.endsWith(".json")) return "application/json";
117
- if (lower.endsWith(".css")) return "text/css";
118
- return "text/plain";
236
+ return mimeTypeForBuilderDesignSystemFilename(file.name, file.mimeType);
119
237
  }
120
238
 
121
239
  function makeBody(bytes: Uint8Array, mimeType: string): BodyInit {
@@ -204,6 +322,207 @@ export function builderDesignSystemUrl(designSystemId?: string | null): string {
204
322
  : `${host}/app/design-system-intelligence`;
205
323
  }
206
324
 
325
+ export function localBuilderDesignSystemId(
326
+ builderDesignSystemId: string,
327
+ ): string {
328
+ const slug = builderDesignSystemId
329
+ .replace(/[^a-zA-Z0-9_-]+/g, "-")
330
+ .replace(/^-+|-+$/g, "")
331
+ .slice(0, 96);
332
+ return `builder-${slug || "design-system"}`;
333
+ }
334
+
335
+ export function createBuilderDesignSystemProxyFields({
336
+ result,
337
+ projectName,
338
+ description,
339
+ surface,
340
+ }: BuilderDesignSystemProxyFieldsOptions): BuilderDesignSystemProxyFields {
341
+ const title = projectName?.trim() || "Builder indexed design system";
342
+ const fallbackDescription =
343
+ description ?? `Builder indexed design system ${result.designSystemId}`;
344
+ const surfaceNoun = surface === "slides" ? "slides" : "designs";
345
+ const spacingKey = surface === "slides" ? "slidePadding" : "pagePadding";
346
+ const data = JSON.stringify({
347
+ source: "builder",
348
+ builderDesignSystemId: result.designSystemId,
349
+ builderJobId: result.jobId,
350
+ builderProjectId: result.projectId,
351
+ builderUrl: result.builderUrl,
352
+ builderStatus: result.status,
353
+ colors: {
354
+ primary: "var(--primary)",
355
+ secondary: "var(--secondary)",
356
+ accent: "var(--accent)",
357
+ background: "var(--background)",
358
+ surface: "var(--card)",
359
+ text: "var(--foreground)",
360
+ textMuted: "var(--muted-foreground)",
361
+ },
362
+ typography: {
363
+ headingFont: "inherit",
364
+ bodyFont: "inherit",
365
+ headingWeight: "700",
366
+ bodyWeight: "400",
367
+ headingSizes: { h1: "48px", h2: "32px", h3: "24px" },
368
+ },
369
+ spacing: { elementGap: "24px", [spacingKey]: "48px" },
370
+ borders: { radius: "12px", accentWidth: "1px" },
371
+ logos: [],
372
+ notes: [
373
+ "This is a local selectable proxy for a Builder DSI-indexed design system.",
374
+ `Builder design system id: ${result.designSystemId}`,
375
+ `Builder indexing job id: ${result.jobId}`,
376
+ `Builder project id: ${result.projectId}`,
377
+ `Builder URL: ${result.builderUrl}`,
378
+ projectName ? `Requested name: ${projectName}` : "",
379
+ description ? `Context: ${description}` : "",
380
+ "Builder Design System Intelligence is the source of truth for extracted tokens, components, assets, and usage guidance.",
381
+ ]
382
+ .filter(Boolean)
383
+ .join("\n"),
384
+ });
385
+ const customInstructions = [
386
+ "This design system is indexed by Builder Design System Intelligence (DSI).",
387
+ `Builder design system id: ${result.designSystemId}`,
388
+ `Builder job id: ${result.jobId}`,
389
+ `Builder project id: ${result.projectId}`,
390
+ `Builder URL: ${result.builderUrl}`,
391
+ `When generating ${surfaceNoun}, treat Builder DSI as the source of truth for extracted tokens, components, assets, and usage guidance.`,
392
+ "Call get-design-system for this local id before generation and use the returned builder docs and token values when available.",
393
+ ].join("\n");
394
+
395
+ return {
396
+ title,
397
+ description: fallbackDescription,
398
+ data,
399
+ customInstructions,
400
+ };
401
+ }
402
+
403
+ export function parseBuilderDesignSystemProxyReference(
404
+ data: unknown,
405
+ ): BuilderDesignSystemProxyReference | null {
406
+ let parsed: unknown = data;
407
+ if (typeof data === "string") {
408
+ try {
409
+ parsed = JSON.parse(data);
410
+ } catch {
411
+ return null;
412
+ }
413
+ }
414
+ if (!parsed || typeof parsed !== "object") return null;
415
+ const value = parsed as Record<string, unknown>;
416
+ if (value.source !== "builder") return null;
417
+ if (typeof value.builderDesignSystemId !== "string") return null;
418
+ if (typeof value.builderJobId !== "string") return null;
419
+ return {
420
+ source: "builder",
421
+ builderDesignSystemId: value.builderDesignSystemId,
422
+ builderJobId: value.builderJobId,
423
+ builderProjectId:
424
+ typeof value.builderProjectId === "string"
425
+ ? value.builderProjectId
426
+ : undefined,
427
+ builderUrl:
428
+ typeof value.builderUrl === "string" ? value.builderUrl : undefined,
429
+ builderStatus:
430
+ typeof value.builderStatus === "string" ? value.builderStatus : undefined,
431
+ };
432
+ }
433
+
434
+ function truncateDocContent(content: unknown): string | undefined {
435
+ if (typeof content !== "string") return undefined;
436
+ if (content.length <= MAX_DOC_CONTENT_CHARS) return content;
437
+ return `${content.slice(0, MAX_DOC_CONTENT_CHARS)}\n\n[truncated]`;
438
+ }
439
+
440
+ function normalizeBuilderDesignSystemDocument(
441
+ value: unknown,
442
+ ): BuilderDesignSystemDocument {
443
+ const doc =
444
+ value && typeof value === "object"
445
+ ? (value as Record<string, unknown>)
446
+ : {};
447
+ return {
448
+ id: typeof doc.id === "string" ? doc.id : undefined,
449
+ name: typeof doc.name === "string" ? doc.name : undefined,
450
+ type: typeof doc.type === "string" ? doc.type : undefined,
451
+ description:
452
+ typeof doc.description === "string" ? doc.description : undefined,
453
+ content: truncateDocContent(doc.content),
454
+ tokenValues:
455
+ doc.tokenValues && typeof doc.tokenValues === "object"
456
+ ? (doc.tokenValues as Record<string, string>)
457
+ : undefined,
458
+ rawTokens: Array.isArray(doc.rawTokens)
459
+ ? doc.rawTokens.filter(
460
+ (token): token is string => typeof token === "string",
461
+ )
462
+ : undefined,
463
+ relevantFiles: Array.isArray(doc.relevantFiles)
464
+ ? doc.relevantFiles.filter(
465
+ (file): file is string => typeof file === "string",
466
+ )
467
+ : undefined,
468
+ relatedComponents: Array.isArray(doc.relatedComponents)
469
+ ? doc.relatedComponents.filter(
470
+ (component): component is string => typeof component === "string",
471
+ )
472
+ : undefined,
473
+ };
474
+ }
475
+
476
+ export async function fetchBuilderDesignSystemDocs(
477
+ designSystemId: string,
478
+ options: BuilderDesignSystemDocsOptions = {},
479
+ ): Promise<BuilderDesignSystemDocument[]> {
480
+ const credentials = await resolveBuilderDesignSystemCredentials();
481
+ const url = makeBuilderDesignSystemUrl(
482
+ `${encodeURIComponent(designSystemId)}/docs`,
483
+ credentials,
484
+ );
485
+ if (options.page !== undefined)
486
+ url.searchParams.set("page", String(options.page));
487
+ if (options.pageSize !== undefined)
488
+ url.searchParams.set("pageSize", String(options.pageSize));
489
+ if (options.minimal !== undefined)
490
+ url.searchParams.set("minimal", options.minimal ? "true" : "false");
491
+ if (options.type?.trim()) url.searchParams.set("type", options.type.trim());
492
+
493
+ const response = await fetchWithTimeout(url, {
494
+ method: "GET",
495
+ headers: makeBuilderHeaders(credentials),
496
+ });
497
+ await assertOk(response, "Builder design-system docs fetch failed");
498
+ const json = (await response.json()) as unknown;
499
+ if (!Array.isArray(json)) return [];
500
+ return json.map(normalizeBuilderDesignSystemDocument);
501
+ }
502
+
503
+ export async function hydrateBuilderDesignSystemReference(
504
+ reference: BuilderDesignSystemProxyReference,
505
+ options: BuilderDesignSystemDocsOptions = { page: 0, pageSize: 40 },
506
+ ): Promise<BuilderDesignSystemHydratedReference> {
507
+ const docs = await fetchBuilderDesignSystemDocs(
508
+ reference.builderDesignSystemId,
509
+ options,
510
+ );
511
+ const tokenValues: Record<string, string> = {};
512
+ for (const doc of docs) {
513
+ if (!doc.tokenValues) continue;
514
+ for (const [name, value] of Object.entries(doc.tokenValues)) {
515
+ if (typeof value === "string") tokenValues[name] = value;
516
+ }
517
+ }
518
+ return {
519
+ ...reference,
520
+ docs,
521
+ tokenValues,
522
+ docCount: docs.length,
523
+ };
524
+ }
525
+
207
526
  export async function startBuilderDesignSystemIndex(
208
527
  options: BuilderDesignSystemIndexOptions,
209
528
  ): Promise<BuilderDesignSystemIndexResult> {
@@ -388,11 +388,26 @@ export {
388
388
  } from "./credential-provider.js";
389
389
  export {
390
390
  builderDesignSystemUrl,
391
+ buildBuilderDesignSystemIndexFiles,
392
+ createBuilderDesignSystemProxyFields,
393
+ fetchBuilderDesignSystemDocs,
391
394
  getBuilderDesignSystemsBaseUrl,
395
+ hydrateBuilderDesignSystemReference,
396
+ localBuilderDesignSystemId,
397
+ mimeTypeForBuilderDesignSystemFilename,
398
+ parseBuilderDesignSystemProxyReference,
392
399
  startBuilderDesignSystemIndex,
400
+ type BuildBuilderDesignSystemIndexFilesOptions,
401
+ type BuilderDesignSystemCodeFileInput,
402
+ type BuilderDesignSystemDocsOptions,
403
+ type BuilderDesignSystemDocument,
404
+ type BuilderDesignSystemHydratedReference,
393
405
  type BuilderDesignSystemIndexFile,
394
406
  type BuilderDesignSystemIndexOptions,
395
407
  type BuilderDesignSystemIndexResult,
408
+ type BuilderDesignSystemProxyFields,
409
+ type BuilderDesignSystemProxyFieldsOptions,
410
+ type BuilderDesignSystemProxyReference,
396
411
  } from "./builder-design-systems.js";
397
412
  export {
398
413
  getBuilderBranchProjectId,
@@ -1,6 +1,7 @@
1
1
  import { useDbSync } from "@agent-native/core/client";
2
2
  import {
3
3
  AppProviders,
4
+ ErrorReportActions,
4
5
  appPath,
5
6
  getLocaleInitScript,
6
7
  getThemeInitScript,
@@ -66,6 +67,9 @@ const ERROR_COPY = {
66
67
  "This page doesn't exist. It may have been moved or deleted.",
67
68
  statusTitle: (status: number) => `${status} Error`,
68
69
  goHome: "Go home",
70
+ sendFeedback: "Send feedback",
71
+ feedbackPlaceholder: "Describe what happened before this error appeared.",
72
+ openGitHubIssue: "Open GitHub issue",
69
73
  },
70
74
  "zh-CN": {
71
75
  genericTitle: "出了点问题",
@@ -74,6 +78,9 @@ const ERROR_COPY = {
74
78
  notFoundDetails: "此页面不存在。它可能已被移动或删除。",
75
79
  statusTitle: (status: number) => `${status} 错误`,
76
80
  goHome: "返回首页",
81
+ sendFeedback: "发送反馈",
82
+ feedbackPlaceholder: "描述此错误出现前发生了什么。",
83
+ openGitHubIssue: "打开 GitHub issue",
77
84
  },
78
85
  "zh-TW": {
79
86
  genericTitle: "發生錯誤",
@@ -82,6 +89,9 @@ const ERROR_COPY = {
82
89
  notFoundDetails: "此頁面不存在,可能已被移動或刪除。",
83
90
  statusTitle: (status: number) => `${status} 錯誤`,
84
91
  goHome: "返回首頁",
92
+ sendFeedback: "傳送意見回饋",
93
+ feedbackPlaceholder: "描述此錯誤出現前發生了什麼。",
94
+ openGitHubIssue: "開啟 GitHub issue",
85
95
  },
86
96
  "es-ES": {
87
97
  genericTitle: "Algo salió mal",
@@ -91,6 +101,10 @@ const ERROR_COPY = {
91
101
  "Esta página no existe. Puede que se haya movido o eliminado.",
92
102
  statusTitle: (status: number) => `Error ${status}`,
93
103
  goHome: "Ir al inicio",
104
+ sendFeedback: "Enviar comentarios",
105
+ feedbackPlaceholder:
106
+ "Describe qué pasó antes de que apareciera este error.",
107
+ openGitHubIssue: "Abrir issue en GitHub",
94
108
  },
95
109
  "fr-FR": {
96
110
  genericTitle: "Une erreur est survenue",
@@ -100,6 +114,9 @@ const ERROR_COPY = {
100
114
  "Cette page n'existe pas. Elle a peut-être été déplacée ou supprimée.",
101
115
  statusTitle: (status: number) => `Erreur ${status}`,
102
116
  goHome: "Retour à l'accueil",
117
+ sendFeedback: "Envoyer un retour",
118
+ feedbackPlaceholder: "Décrivez ce qui s'est passé avant cette erreur.",
119
+ openGitHubIssue: "Ouvrir une issue GitHub",
103
120
  },
104
121
  "de-DE": {
105
122
  genericTitle: "Etwas ist schiefgelaufen",
@@ -109,6 +126,9 @@ const ERROR_COPY = {
109
126
  "Diese Seite existiert nicht. Sie wurde möglicherweise verschoben oder gelöscht.",
110
127
  statusTitle: (status: number) => `${status} Fehler`,
111
128
  goHome: "Zur Startseite",
129
+ sendFeedback: "Feedback senden",
130
+ feedbackPlaceholder: "Beschreiben Sie, was vor diesem Fehler passiert ist.",
131
+ openGitHubIssue: "GitHub-Issue öffnen",
112
132
  },
113
133
  "ja-JP": {
114
134
  genericTitle: "問題が発生しました",
@@ -118,6 +138,9 @@ const ERROR_COPY = {
118
138
  "このページは存在しません。移動または削除された可能性があります。",
119
139
  statusTitle: (status: number) => `${status} エラー`,
120
140
  goHome: "ホームへ",
141
+ sendFeedback: "フィードバックを送信",
142
+ feedbackPlaceholder: "このエラーの直前に起きたことを説明してください。",
143
+ openGitHubIssue: "GitHub issue を開く",
121
144
  },
122
145
  "ko-KR": {
123
146
  genericTitle: "문제가 발생했습니다",
@@ -127,6 +150,10 @@ const ERROR_COPY = {
127
150
  "이 페이지는 존재하지 않습니다. 이동되었거나 삭제되었을 수 있습니다.",
128
151
  statusTitle: (status: number) => `${status} 오류`,
129
152
  goHome: "홈으로 이동",
153
+ sendFeedback: "피드백 보내기",
154
+ feedbackPlaceholder:
155
+ "이 오류가 나타나기 전에 무슨 일이 있었는지 적어 주세요.",
156
+ openGitHubIssue: "GitHub issue 열기",
130
157
  },
131
158
  "pt-BR": {
132
159
  genericTitle: "Algo deu errado",
@@ -136,6 +163,9 @@ const ERROR_COPY = {
136
163
  "Esta página não existe. Ela pode ter sido movida ou excluída.",
137
164
  statusTitle: (status: number) => `Erro ${status}`,
138
165
  goHome: "Ir para o início",
166
+ sendFeedback: "Enviar feedback",
167
+ feedbackPlaceholder: "Descreva o que aconteceu antes deste erro aparecer.",
168
+ openGitHubIssue: "Abrir issue no GitHub",
139
169
  },
140
170
  "hi-IN": {
141
171
  genericTitle: "कुछ गलत हुआ",
@@ -144,6 +174,9 @@ const ERROR_COPY = {
144
174
  notFoundDetails: "यह पेज मौजूद नहीं है। इसे स्थानांतरित या हटाया गया हो सकता है।",
145
175
  statusTitle: (status: number) => `${status} त्रुटि`,
146
176
  goHome: "होम जाएं",
177
+ sendFeedback: "फ़ीडबैक भेजें",
178
+ feedbackPlaceholder: "इस त्रुटि से पहले क्या हुआ, उसका वर्णन करें।",
179
+ openGitHubIssue: "GitHub issue खोलें",
147
180
  },
148
181
  "ar-SA": {
149
182
  genericTitle: "حدث خطأ",
@@ -152,6 +185,9 @@ const ERROR_COPY = {
152
185
  notFoundDetails: "هذه الصفحة غير موجودة. ربما تم نقلها أو حذفها.",
153
186
  statusTitle: (status: number) => `خطأ ${status}`,
154
187
  goHome: "الذهاب إلى الرئيسية",
188
+ sendFeedback: "إرسال الملاحظات",
189
+ feedbackPlaceholder: "صف ما حدث قبل ظهور هذا الخطأ.",
190
+ openGitHubIssue: "فتح مشكلة في GitHub",
155
191
  },
156
192
  };
157
193
 
@@ -285,6 +321,17 @@ export function ErrorBoundary() {
285
321
  >
286
322
  {copy.goHome}
287
323
  </Link>
324
+ <ErrorReportActions
325
+ appName="Agent Native"
326
+ title={title}
327
+ details={details}
328
+ status={status}
329
+ issueTitle={`Error screen: ${title}`}
330
+ feedbackLabel={copy.sendFeedback}
331
+ feedbackPlaceholder={copy.feedbackPlaceholder}
332
+ githubLabel={copy.openGitHubIssue}
333
+ className="mt-4"
334
+ />
288
335
  {stack && (
289
336
  <pre className="mt-6 w-full text-left text-xs overflow-auto p-4 bg-muted rounded">
290
337
  <code>{stack}</code>
@@ -86,8 +86,10 @@ details live in `.agents/skills/`.
86
86
  - `/agents` is the Analytics home for core agent-admin surfaces. The default
87
87
  Monitoring view embeds the shared observability dashboard for traces,
88
88
  conversations, evals, experiments, and feedback. The Advanced menu opens
89
- `/agents?view=database`, which embeds the shared Code-mode database admin
90
- tool for table browsing, row editing, and SQL inspection. Keep future
89
+ `/agents?view=database`, where organization owners/admins can connect other
90
+ agent-native app databases and use the shared database admin tool for table
91
+ browsing, row editing, and SQL inspection. This surface is for connected
92
+ target app databases, not broad access to all Analytics data. Keep future
91
93
  agent-admin additions inside this route instead of adding many top-level
92
94
  sidebar tabs.
93
95
  - For dashboard edits, default to `mutate-dashboard` with its typed
@@ -156,8 +158,8 @@ details live in `.agents/skills/`.
156
158
  context.
157
159
  - `navigate` moves the user to the relevant analytics view, including
158
160
  `view="catalog"` for the template catalog, `view="sessions"` for session
159
- replay, and `view="agents"` / `agentsView="database"` for agent monitoring
160
- or advanced database admin.
161
+ replay, and `view="agents"` / `agentsView="database"` with optional
162
+ `dbAdminConnectionId` for agent monitoring or connected app database admin.
161
163
  - Use `view-screen` when the active dashboard/chart context is unclear.
162
164
 
163
165
  ## Session Replay
@@ -0,0 +1,19 @@
1
+ import { defineAction } from "@agent-native/core/action";
2
+ import { z } from "zod";
3
+
4
+ import {
5
+ deleteDbAdminConnection,
6
+ requireDbAdminContextFromRequest,
7
+ } from "../server/lib/db-admin-connections";
8
+
9
+ export default defineAction({
10
+ description:
11
+ "Remove a connected agent-native app database from the Analytics DB admin surface and delete its encrypted connection secrets. Requires active organization owner/admin role.",
12
+ schema: z.object({
13
+ id: z.string().min(1).describe("Connection id to remove."),
14
+ }),
15
+ run: async ({ id }, ctx) => {
16
+ const admin = await requireDbAdminContextFromRequest(ctx);
17
+ return deleteDbAdminConnection(admin, id);
18
+ },
19
+ });
@@ -0,0 +1,18 @@
1
+ import { defineAction } from "@agent-native/core/action";
2
+ import { z } from "zod";
3
+
4
+ import {
5
+ listDbAdminConnections,
6
+ requireDbAdminContextFromRequest,
7
+ } from "../server/lib/db-admin-connections";
8
+
9
+ export default defineAction({
10
+ description:
11
+ "List admin-only connected agent-native app databases available in Analytics DB admin. Requires the caller to be an owner or admin of the active organization.",
12
+ schema: z.object({}),
13
+ http: { method: "GET" },
14
+ run: async (_args, ctx) => {
15
+ const admin = await requireDbAdminContextFromRequest(ctx);
16
+ return listDbAdminConnections(admin);
17
+ },
18
+ });
@@ -31,7 +31,13 @@ export default defineAction({
31
31
  agentsView: z
32
32
  .enum(["monitoring", "database"])
33
33
  .optional()
34
- .describe("Agents subview to open (monitoring or database)"),
34
+ .describe("Agents subview to open (monitoring or app databases)"),
35
+ dbAdminConnectionId: z
36
+ .string()
37
+ .optional()
38
+ .describe(
39
+ "Connected app database id to select when navigating to agentsView=database",
40
+ ),
35
41
  }),
36
42
  http: false,
37
43
  run: async (args) => {
@@ -41,10 +47,11 @@ export default defineAction({
41
47
  !args.analysisId &&
42
48
  !args.extensionId &&
43
49
  !args.recordingId &&
44
- !args.agentsView
50
+ !args.agentsView &&
51
+ !args.dbAdminConnectionId
45
52
  ) {
46
53
  throw new Error(
47
- "At least --view, --dashboardId, --analysisId, --extensionId, --recordingId, or --agentsView is required.",
54
+ "At least --view, --dashboardId, --analysisId, --extensionId, --recordingId, --agentsView, or --dbAdminConnectionId is required.",
48
55
  );
49
56
  }
50
57
  const nav: Record<string, string> = {};
@@ -69,6 +76,11 @@ export default defineAction({
69
76
  nav.agentsView = args.agentsView;
70
77
  if (!args.view) nav.view = "agents";
71
78
  }
79
+ if (args.dbAdminConnectionId) {
80
+ nav.dbAdminConnectionId = args.dbAdminConnectionId;
81
+ nav.agentsView = "database";
82
+ if (!args.view) nav.view = "agents";
83
+ }
72
84
  await writeAppState("navigate", nav);
73
85
 
74
86
  const parts: string[] = [];
@@ -78,6 +90,8 @@ export default defineAction({
78
90
  if (nav.extensionId) parts.push(`extension:${nav.extensionId}`);
79
91
  if (nav.recordingId) parts.push(`recording:${nav.recordingId}`);
80
92
  if (nav.agentsView) parts.push(`agents:${nav.agentsView}`);
93
+ if (nav.dbAdminConnectionId)
94
+ parts.push(`db-admin:${nav.dbAdminConnectionId}`);
81
95
  return `Navigating to ${parts.join(" ")}`;
82
96
  },
83
97
  });
@@ -0,0 +1,33 @@
1
+ import { defineAction } from "@agent-native/core/action";
2
+ import { z } from "zod";
3
+
4
+ import {
5
+ requireDbAdminContextFromRequest,
6
+ saveDbAdminConnection,
7
+ } from "../server/lib/db-admin-connections";
8
+
9
+ export default defineAction({
10
+ description:
11
+ "Create or update an admin-only connected agent-native app database for the Analytics DB admin surface. Requires active organization owner/admin role. Secret values are encrypted and are not returned.",
12
+ schema: z.object({
13
+ id: z.string().optional().describe("Existing connection id to update."),
14
+ name: z.string().min(1).describe("Human-readable app or agent name."),
15
+ appId: z.string().optional().describe("Optional app id, such as plan."),
16
+ appUrl: z
17
+ .string()
18
+ .optional()
19
+ .describe("Optional URL for the connected app."),
20
+ databaseUrl: z
21
+ .string()
22
+ .min(1)
23
+ .describe("Postgres, PostgreSQL, or libSQL database URL."),
24
+ databaseAuthToken: z
25
+ .string()
26
+ .optional()
27
+ .describe("Optional libSQL/Turso auth token. Leave empty for Postgres."),
28
+ }),
29
+ run: async (args, ctx) => {
30
+ const admin = await requireDbAdminContextFromRequest(ctx);
31
+ return saveDbAdminConnection(admin, args);
32
+ },
33
+ });