@chaaskit/client 0.1.0

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 (135) hide show
  1. package/dist/favicon.svg +11 -0
  2. package/dist/index.html +17 -0
  3. package/dist/lib/LoadingSkeletons-IcIC2JPq.js +132 -0
  4. package/dist/lib/LoadingSkeletons-IcIC2JPq.js.map +1 -0
  5. package/dist/lib/ServerThemeProvider-DNF0LAyk.js +42 -0
  6. package/dist/lib/ServerThemeProvider-DNF0LAyk.js.map +1 -0
  7. package/dist/lib/extensions.js +10 -0
  8. package/dist/lib/extensions.js.map +1 -0
  9. package/dist/lib/favicon.svg +11 -0
  10. package/dist/lib/index.js +74126 -0
  11. package/dist/lib/index.js.map +1 -0
  12. package/dist/lib/logo.svg +12 -0
  13. package/dist/lib/routes/AcceptInviteRoute.js +19 -0
  14. package/dist/lib/routes/AcceptInviteRoute.js.map +1 -0
  15. package/dist/lib/routes/AdminDashboardRoute.js +19 -0
  16. package/dist/lib/routes/AdminDashboardRoute.js.map +1 -0
  17. package/dist/lib/routes/AdminTeamRoute.js +19 -0
  18. package/dist/lib/routes/AdminTeamRoute.js.map +1 -0
  19. package/dist/lib/routes/AdminTeamsRoute.js +19 -0
  20. package/dist/lib/routes/AdminTeamsRoute.js.map +1 -0
  21. package/dist/lib/routes/AdminUsersRoute.js +19 -0
  22. package/dist/lib/routes/AdminUsersRoute.js.map +1 -0
  23. package/dist/lib/routes/ApiKeysRoute.js +19 -0
  24. package/dist/lib/routes/ApiKeysRoute.js.map +1 -0
  25. package/dist/lib/routes/AutomationsRoute.js +19 -0
  26. package/dist/lib/routes/AutomationsRoute.js.map +1 -0
  27. package/dist/lib/routes/ChatRoute.js +19 -0
  28. package/dist/lib/routes/ChatRoute.js.map +1 -0
  29. package/dist/lib/routes/DocumentsRoute.js +19 -0
  30. package/dist/lib/routes/DocumentsRoute.js.map +1 -0
  31. package/dist/lib/routes/OAuthConsentRoute.js +19 -0
  32. package/dist/lib/routes/OAuthConsentRoute.js.map +1 -0
  33. package/dist/lib/routes/PricingRoute.js +19 -0
  34. package/dist/lib/routes/PricingRoute.js.map +1 -0
  35. package/dist/lib/routes/PrivacyRoute.js +19 -0
  36. package/dist/lib/routes/PrivacyRoute.js.map +1 -0
  37. package/dist/lib/routes/TeamSettingsRoute.js +19 -0
  38. package/dist/lib/routes/TeamSettingsRoute.js.map +1 -0
  39. package/dist/lib/routes/TermsRoute.js +19 -0
  40. package/dist/lib/routes/TermsRoute.js.map +1 -0
  41. package/dist/lib/routes/VerifyEmailRoute.js +19 -0
  42. package/dist/lib/routes/VerifyEmailRoute.js.map +1 -0
  43. package/dist/lib/routes.js +79 -0
  44. package/dist/lib/routes.js.map +1 -0
  45. package/dist/lib/ssr-utils.js +29 -0
  46. package/dist/lib/ssr-utils.js.map +1 -0
  47. package/dist/lib/ssr.js +60 -0
  48. package/dist/lib/ssr.js.map +1 -0
  49. package/dist/lib/styles.css +2410 -0
  50. package/dist/lib/useExtensions-B5nX_8XD.js +155 -0
  51. package/dist/lib/useExtensions-B5nX_8XD.js.map +1 -0
  52. package/dist/logo.svg +12 -0
  53. package/package.json +84 -0
  54. package/src/components/AgentSelector.tsx +90 -0
  55. package/src/components/BranchModal.tsx +129 -0
  56. package/src/components/ClientOnly.tsx +27 -0
  57. package/src/components/ExportMenu.tsx +122 -0
  58. package/src/components/LoadingSkeletons.tsx +110 -0
  59. package/src/components/MCPCredentialsSection.tsx +309 -0
  60. package/src/components/MentionChip.tsx +149 -0
  61. package/src/components/MentionDropdown.tsx +175 -0
  62. package/src/components/MentionInput.tsx +293 -0
  63. package/src/components/MessageItem.tsx +300 -0
  64. package/src/components/MessageList.tsx +159 -0
  65. package/src/components/OAuthAppsSection.tsx +124 -0
  66. package/src/components/ProjectFolder.tsx +141 -0
  67. package/src/components/ProjectModal.tsx +296 -0
  68. package/src/components/SSRMessageList.tsx +153 -0
  69. package/src/components/SearchModal.tsx +173 -0
  70. package/src/components/SettingsModal.tsx +412 -0
  71. package/src/components/ShareModal.tsx +280 -0
  72. package/src/components/Sidebar.tsx +491 -0
  73. package/src/components/TeamSwitcher.tsx +273 -0
  74. package/src/components/ToolCallDisplay.tsx +473 -0
  75. package/src/components/ToolConfirmationModal.tsx +130 -0
  76. package/src/components/UsageChart.tsx +177 -0
  77. package/src/components/content/CodeBlock.tsx +69 -0
  78. package/src/components/content/MarkdownRenderer.tsx +64 -0
  79. package/src/components/content/SSRMarkdownRenderer.tsx +158 -0
  80. package/src/contexts/AuthContext.tsx +119 -0
  81. package/src/contexts/ConfigContext.tsx +214 -0
  82. package/src/contexts/ProjectContext.tsx +167 -0
  83. package/src/contexts/ServerConfigProvider.tsx +41 -0
  84. package/src/contexts/ServerThemeProvider.tsx +47 -0
  85. package/src/contexts/TeamContext.tsx +255 -0
  86. package/src/contexts/ThemeContext.tsx +113 -0
  87. package/src/extensions/index.ts +15 -0
  88. package/src/extensions/registry.ts +187 -0
  89. package/src/extensions/useExtensions.ts +52 -0
  90. package/src/hooks/useAppPath.ts +34 -0
  91. package/src/hooks/useBasePath.ts +13 -0
  92. package/src/hooks/useKeyboardShortcuts.ts +50 -0
  93. package/src/hooks/useMentionSearch.ts +106 -0
  94. package/src/index.tsx +116 -0
  95. package/src/layouts/MainLayout.tsx +98 -0
  96. package/src/pages/AcceptInvitePage.tsx +175 -0
  97. package/src/pages/AdminDashboardPage.tsx +362 -0
  98. package/src/pages/AdminTeamPage.tsx +304 -0
  99. package/src/pages/AdminTeamsPage.tsx +242 -0
  100. package/src/pages/AdminUsersPage.tsx +385 -0
  101. package/src/pages/ApiKeysPage.tsx +449 -0
  102. package/src/pages/ChatPage.tsx +310 -0
  103. package/src/pages/DocumentsPage.tsx +577 -0
  104. package/src/pages/LoginPage.tsx +232 -0
  105. package/src/pages/OAuthConsentPage.tsx +234 -0
  106. package/src/pages/PricingPage.tsx +314 -0
  107. package/src/pages/PrivacyPage.tsx +65 -0
  108. package/src/pages/RegisterPage.tsx +153 -0
  109. package/src/pages/ScheduledPromptsPage.tsx +702 -0
  110. package/src/pages/SharedThreadPage.tsx +116 -0
  111. package/src/pages/TeamSettingsPage.tsx +1085 -0
  112. package/src/pages/TermsPage.tsx +82 -0
  113. package/src/pages/VerifyEmailPage.tsx +202 -0
  114. package/src/routes/AcceptInviteRoute.tsx +24 -0
  115. package/src/routes/AdminDashboardRoute.tsx +24 -0
  116. package/src/routes/AdminTeamRoute.tsx +24 -0
  117. package/src/routes/AdminTeamsRoute.tsx +24 -0
  118. package/src/routes/AdminUsersRoute.tsx +24 -0
  119. package/src/routes/ApiKeysRoute.tsx +24 -0
  120. package/src/routes/AutomationsRoute.tsx +24 -0
  121. package/src/routes/ChatRoute.tsx +28 -0
  122. package/src/routes/DocumentsRoute.tsx +24 -0
  123. package/src/routes/OAuthConsentRoute.tsx +24 -0
  124. package/src/routes/PricingRoute.tsx +24 -0
  125. package/src/routes/PrivacyRoute.tsx +24 -0
  126. package/src/routes/TeamSettingsRoute.tsx +24 -0
  127. package/src/routes/TermsRoute.tsx +24 -0
  128. package/src/routes/VerifyEmailRoute.tsx +24 -0
  129. package/src/routes/index.ts +57 -0
  130. package/src/ssr-utils.tsx +84 -0
  131. package/src/ssr.ts +123 -0
  132. package/src/stores/chatStore.ts +670 -0
  133. package/src/styles/index.css +254 -0
  134. package/src/utils/api.ts +78 -0
  135. package/src/vite-env.d.ts +13 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Route modules for @chaaskit/client
3
+ *
4
+ * Each route exports:
5
+ * - meta() - page metadata for React Router
6
+ * - links() - stylesheet links
7
+ * - default - wrapped component with ChatProviders
8
+ * - LoadingSkeleton - SSR-safe loading component
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * // In your route file
13
+ * import { lazy, Suspense } from 'react';
14
+ * import { ClientOnly, SimpleLoadingSkeleton } from '@chaaskit/client';
15
+ *
16
+ * const ChatRoute = lazy(() => import('@chaaskit/client/routes/ChatRoute'));
17
+ *
18
+ * export { meta, links } from '@chaaskit/client/routes/ChatRoute';
19
+ *
20
+ * export default function Chat() {
21
+ * return (
22
+ * <ClientOnly fallback={<SimpleLoadingSkeleton />}>
23
+ * {() => (
24
+ * <Suspense fallback={<SimpleLoadingSkeleton />}>
25
+ * <ChatRoute />
26
+ * </Suspense>
27
+ * )}
28
+ * </ClientOnly>
29
+ * );
30
+ * }
31
+ * ```
32
+ */
33
+
34
+ // Chat routes (with sidebar layout)
35
+ export { default as ChatRoute, meta as chatMeta, links as chatLinks, LoadingSkeleton as ChatLoadingSkeleton } from './ChatRoute';
36
+
37
+ // Settings/management routes
38
+ export { default as ApiKeysRoute, meta as apiKeysMeta, links as apiKeysLinks, LoadingSkeleton as ApiKeysLoadingSkeleton } from './ApiKeysRoute';
39
+ export { default as DocumentsRoute, meta as documentsMeta, links as documentsLinks, LoadingSkeleton as DocumentsLoadingSkeleton } from './DocumentsRoute';
40
+ export { default as AutomationsRoute, meta as automationsMeta, links as automationsLinks, LoadingSkeleton as AutomationsLoadingSkeleton } from './AutomationsRoute';
41
+ export { default as TeamSettingsRoute, meta as teamSettingsMeta, links as teamSettingsLinks, LoadingSkeleton as TeamSettingsLoadingSkeleton } from './TeamSettingsRoute';
42
+
43
+ // Admin routes
44
+ export { default as AdminDashboardRoute, meta as adminDashboardMeta, links as adminDashboardLinks, LoadingSkeleton as AdminDashboardLoadingSkeleton } from './AdminDashboardRoute';
45
+ export { default as AdminUsersRoute, meta as adminUsersMeta, links as adminUsersLinks, LoadingSkeleton as AdminUsersLoadingSkeleton } from './AdminUsersRoute';
46
+ export { default as AdminTeamsRoute, meta as adminTeamsMeta, links as adminTeamsLinks, LoadingSkeleton as AdminTeamsLoadingSkeleton } from './AdminTeamsRoute';
47
+ export { default as AdminTeamRoute, meta as adminTeamMeta, links as adminTeamLinks, LoadingSkeleton as AdminTeamLoadingSkeleton } from './AdminTeamRoute';
48
+
49
+ // Auth-related routes
50
+ export { default as VerifyEmailRoute, meta as verifyEmailMeta, links as verifyEmailLinks, LoadingSkeleton as VerifyEmailLoadingSkeleton } from './VerifyEmailRoute';
51
+ export { default as AcceptInviteRoute, meta as acceptInviteMeta, links as acceptInviteLinks, LoadingSkeleton as AcceptInviteLoadingSkeleton } from './AcceptInviteRoute';
52
+
53
+ // Public routes
54
+ export { default as PricingRoute, meta as pricingMeta, links as pricingLinks, LoadingSkeleton as PricingLoadingSkeleton } from './PricingRoute';
55
+ export { default as OAuthConsentRoute, meta as oauthConsentMeta, links as oauthConsentLinks, LoadingSkeleton as OAuthConsentLoadingSkeleton } from './OAuthConsentRoute';
56
+ export { default as PrivacyRoute, meta as privacyMeta, links as privacyLinks, LoadingSkeleton as PrivacyLoadingSkeleton } from './PrivacyRoute';
57
+ export { default as TermsRoute, meta as termsMeta, links as termsLinks, LoadingSkeleton as TermsLoadingSkeleton } from './TermsRoute';
@@ -0,0 +1,84 @@
1
+ /**
2
+ * SSR-safe utilities for @chaaskit/client
3
+ *
4
+ * This entry point ONLY exports components that are safe to import during SSR.
5
+ * Use this in route files instead of importing from the main entry point
6
+ * to avoid pulling in browser-only dependencies like react-markdown.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * // In your route file
11
+ * import { createRoute, SimpleLoadingSkeleton } from '@chaaskit/client/ssr-utils';
12
+ *
13
+ * export const { meta, links, default: Component } = createRoute({
14
+ * title: 'Verify Email',
15
+ * load: () => import('@chaaskit/client/routes/VerifyEmailRoute'),
16
+ * });
17
+ * export default Component;
18
+ * ```
19
+ */
20
+
21
+ import { lazy, Suspense, type ComponentType, type LazyExoticComponent } from 'react';
22
+ import { ClientOnly } from './components/ClientOnly';
23
+ import { ChatLoadingSkeleton, SimpleLoadingSkeleton } from './components/LoadingSkeletons';
24
+
25
+ export { ClientOnly, ChatLoadingSkeleton, SimpleLoadingSkeleton };
26
+
27
+ /**
28
+ * Route configuration options
29
+ */
30
+ export interface RouteConfig {
31
+ /** Page title for meta tag */
32
+ title: string;
33
+ /** Dynamic import function for the route component */
34
+ load: () => Promise<{ default: ComponentType<any> }>;
35
+ /** Loading skeleton to show during SSR and lazy load (defaults to SimpleLoadingSkeleton) */
36
+ skeleton?: 'simple' | 'chat';
37
+ }
38
+
39
+ /**
40
+ * Creates a route module with meta, links, and default component.
41
+ * This reduces route files to just a few lines.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * import { createRoute } from '@chaaskit/client/ssr-utils';
46
+ *
47
+ * export const { meta, links, default: VerifyEmail } = createRoute({
48
+ * title: 'Verify Email',
49
+ * load: () => import('@chaaskit/client/routes/VerifyEmailRoute'),
50
+ * });
51
+ * export default VerifyEmail;
52
+ * ```
53
+ */
54
+ export function createRoute(config: RouteConfig) {
55
+ const { title, load, skeleton = 'simple' } = config;
56
+ const LazyComponent = lazy(load);
57
+ const Skeleton = skeleton === 'chat' ? ChatLoadingSkeleton : SimpleLoadingSkeleton;
58
+
59
+ function meta() {
60
+ return [{ title }];
61
+ }
62
+
63
+ function links() {
64
+ return [{ rel: 'stylesheet', href: '/node_modules/@chaaskit/client/dist/lib/styles.css' }];
65
+ }
66
+
67
+ function RouteComponent() {
68
+ return (
69
+ <ClientOnly fallback={<Skeleton />}>
70
+ {() => (
71
+ <Suspense fallback={<Skeleton />}>
72
+ <LazyComponent />
73
+ </Suspense>
74
+ )}
75
+ </ClientOnly>
76
+ );
77
+ }
78
+
79
+ return {
80
+ meta,
81
+ links,
82
+ default: RouteComponent,
83
+ };
84
+ }
package/src/ssr.ts ADDED
@@ -0,0 +1,123 @@
1
+ /**
2
+ * SSR-safe exports for server-side rendering.
3
+ *
4
+ * This module exports components and utilities that can be used on the server
5
+ * without browser APIs like window, document, or localStorage.
6
+ */
7
+
8
+ import type { AppConfig } from '@chaaskit/shared';
9
+
10
+ // SSR-safe context providers
11
+ export {
12
+ ServerConfigProvider,
13
+ useServerConfig,
14
+ useServerConfigLoaded,
15
+ type ServerConfigProviderProps,
16
+ } from './contexts/ServerConfigProvider';
17
+
18
+ export {
19
+ ServerThemeProvider,
20
+ useServerTheme,
21
+ type ServerThemeProviderProps,
22
+ } from './contexts/ServerThemeProvider';
23
+
24
+ // NOTE: SSRMessageList and SSRMarkdownRenderer are NOT exported here because
25
+ // they depend on react-markdown which has browser-only dependencies.
26
+ // Use them only in client-side code wrapped in <ClientOnly>.
27
+
28
+ // ============================================
29
+ // Theme utilities for SSR
30
+ // ============================================
31
+
32
+ /**
33
+ * Converts a hex color to RGB values string (e.g., "#ff0000" -> "255 0 0")
34
+ */
35
+ function hexToRgb(hex: string): string {
36
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
37
+ if (!result) return '';
38
+ return `${parseInt(result[1]!, 16)} ${parseInt(result[2]!, 16)} ${parseInt(result[3]!, 16)}`;
39
+ }
40
+
41
+ /**
42
+ * Generates CSS variables for a theme.
43
+ * Use this in your React Router root.tsx to inject theme styles.
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * // app/root.tsx
48
+ * import { generateThemeCSS } from '@chaaskit/client/ssr';
49
+ *
50
+ * export default function Root() {
51
+ * const themeCSS = generateThemeCSS(config, 'dark');
52
+ * return (
53
+ * <html>
54
+ * <head>
55
+ * <style dangerouslySetInnerHTML={{ __html: themeCSS }} />
56
+ * </head>
57
+ * ...
58
+ * </html>
59
+ * );
60
+ * }
61
+ * ```
62
+ */
63
+ export function generateThemeCSS(config: AppConfig, theme: string): string {
64
+ const themeConfig = config.theming.themes[theme];
65
+ if (!themeConfig) return '';
66
+
67
+ const cssVars = Object.entries(themeConfig.colors)
68
+ .map(([key, value]) => {
69
+ const cssKey = `--color-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
70
+ return `${cssKey}: ${hexToRgb(value)};`;
71
+ })
72
+ .join('\n ');
73
+
74
+ return `
75
+ :root {
76
+ ${cssVars}
77
+ --font-sans: ${config.theming.fonts.sans};
78
+ --font-mono: ${config.theming.fonts.mono};
79
+ --radius-sm: ${config.theming.borderRadius.sm};
80
+ --radius-md: ${config.theming.borderRadius.md};
81
+ --radius-lg: ${config.theming.borderRadius.lg};
82
+ --radius-full: ${config.theming.borderRadius.full};
83
+ }
84
+ `;
85
+ }
86
+
87
+ /**
88
+ * Returns an object of CSS variable name -> value pairs for a theme.
89
+ * Useful if you need programmatic access to theme values.
90
+ */
91
+ export function getThemeVariables(config: AppConfig, theme: string): Record<string, string> {
92
+ const themeConfig = config.theming.themes[theme];
93
+ if (!themeConfig) return {};
94
+
95
+ const vars: Record<string, string> = {};
96
+
97
+ for (const [key, value] of Object.entries(themeConfig.colors)) {
98
+ const cssKey = `--color-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
99
+ vars[cssKey] = hexToRgb(value);
100
+ }
101
+
102
+ vars['--font-sans'] = config.theming.fonts.sans;
103
+ vars['--font-mono'] = config.theming.fonts.mono;
104
+ vars['--radius-sm'] = config.theming.borderRadius.sm;
105
+ vars['--radius-md'] = config.theming.borderRadius.md;
106
+ vars['--radius-lg'] = config.theming.borderRadius.lg;
107
+ vars['--radius-full'] = config.theming.borderRadius.full;
108
+
109
+ return vars;
110
+ }
111
+
112
+ /**
113
+ * Base CSS styles for SSR pages.
114
+ * Include this in your HTML template for consistent styling.
115
+ */
116
+ export const baseStyles = `
117
+ html { font-family: var(--font-sans); }
118
+ body {
119
+ margin: 0;
120
+ background-color: rgb(var(--color-background));
121
+ color: rgb(var(--color-text-primary));
122
+ }
123
+ `;