@app-studio/web 0.9.18 → 0.9.19

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.
package/docs/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # App Studio Web Component Library Documentation
2
+
3
+ Welcome to the documentation for the App Studio Web Component Library. This documentation provides comprehensive guides, API references, and examples to help you build high-quality components and applications using our library.
4
+
5
+ ## Documentation Structure
6
+
7
+ - **Getting Started**: Quick start guides to help you begin using the library
8
+ - **Component Development**: Detailed guides for building components
9
+ - **Design System**: Information about the design system, theming, and styling
10
+ - **API Reference**: Detailed API documentation for all components
11
+ - **Tutorials**: Step-by-step tutorials for common tasks
12
+ - **Contributing**: Guidelines for contributing to the library
13
+
14
+ ## Using This Documentation
15
+
16
+ The documentation is organized to support different learning styles and needs:
17
+
18
+ - If you're new to the library, start with the [Getting Started](./getting-started/introduction.md) guide
19
+ - If you're building components, refer to the [Component Development Guide](./component-development/guide.md)
20
+ - If you need detailed API information, check the [API Reference](./api-reference/README.md)
21
+ - If you want to learn through examples, explore the [Tutorials](./tutorials/README.md)
22
+
23
+ ## Documentation Tools
24
+
25
+ This library uses several tools to generate and maintain documentation:
26
+
27
+ - **MDX**: Component documentation is written in MDX format, allowing for interactive examples
28
+ - **bot-doc**: Automated documentation generation tool that creates component documentation
29
+ - **create-docs**: Script to generate or update documentation for components
30
+
31
+ To regenerate documentation for all components, run:
32
+
33
+ ```bash
34
+ npm run create-docs
35
+ ```
36
+
37
+ To generate documentation for a specific component:
38
+
39
+ ```bash
40
+ npm run bot-doc -- ComponentName src/components/ComponentName
41
+ ```
42
+
43
+ ## Contributing to Documentation
44
+
45
+ We welcome contributions to improve our documentation. If you find any issues or have suggestions for improvement, please:
46
+
47
+ 1. Check the existing documentation to avoid duplication
48
+ 2. Follow the same formatting and structure as existing documentation
49
+ 3. Include examples where appropriate
50
+ 4. Submit a pull request with your changes
51
+
52
+ For more detailed guidelines, see the [Contributing Guide](./contributing/documentation.md).
@@ -0,0 +1,316 @@
1
+ # ADK Agent Components
2
+
3
+ This document provides an overview of the React components created for compatibility with the ADK (Agent Development Kit) system.
4
+
5
+ ## Overview
6
+
7
+ The ADK Agent Components are a collection of React components designed to work seamlessly with ADK agents, following the same patterns and protocols used in the original adk-web Angular application. These components provide a complete interface for agent interaction, session management, and more.
8
+
9
+ ## Components
10
+
11
+ ### 1. AgentChat Component
12
+
13
+ **Location**: `src/components/AgentChat/`
14
+
15
+ A comprehensive chat interface for interacting with ADK agents.
16
+
17
+ #### Key Features:
18
+ - ✅ Real-time messaging via Server-Sent Events (SSE)
19
+ - ✅ File upload support (images, videos, audio, documents)
20
+ - ✅ Function call visualization and execution
21
+ - ✅ Code execution and result display
22
+ - ✅ Agent thought process visualization
23
+ - ✅ Evaluation and scoring support
24
+ - ✅ Streaming and non-streaming responses
25
+ - ✅ Fully customizable styling and theming
26
+ - ✅ Accessibility-first design
27
+
28
+ #### Usage:
29
+ ```tsx
30
+ import { AgentChat } from '@app-studio/web';
31
+
32
+ <AgentChat
33
+ appName="my-agent"
34
+ userId="user123"
35
+ enableFileUpload={true}
36
+ enableStreaming={true}
37
+ enableThoughts={true}
38
+ onSessionCreate={(session) => console.log('Session created:', session)}
39
+ onMessageSent={(message) => console.log('Message sent:', message)}
40
+ />
41
+ ```
42
+
43
+ #### Props:
44
+ - `appName` (required): Name of the ADK agent application
45
+ - `userId` (required): Unique identifier for the user
46
+ - `sessionId`: Existing session ID to resume
47
+ - `apiBaseUrl`: Base URL for ADK API endpoints
48
+ - `enableFileUpload`: Enable file attachment functionality
49
+ - `enableStreaming`: Enable real-time streaming responses
50
+ - `enableThoughts`: Show agent thought processes
51
+ - `views`: Custom styling options
52
+
53
+ ### 2. AgentSession Component
54
+
55
+ **Location**: `src/components/AgentSession/`
56
+
57
+ A comprehensive session management component for ADK agents.
58
+
59
+ #### Key Features:
60
+ - ✅ Session creation, listing, and selection
61
+ - ✅ Session deletion and management
62
+ - ✅ Import/export functionality
63
+ - ✅ Search and filtering capabilities
64
+ - ✅ Auto-refresh and real-time updates
65
+ - ✅ Session metadata and tagging
66
+ - ✅ Compact and full display modes
67
+ - ✅ Bulk operations support
68
+
69
+ #### Usage:
70
+ ```tsx
71
+ import { AgentSession } from '@app-studio/web';
72
+
73
+ <AgentSession
74
+ appName="my-agent"
75
+ userId="user123"
76
+ showSessionHistory={true}
77
+ enableSessionImport={true}
78
+ enableSessionExport={true}
79
+ onSessionSelect={(session) => console.log('Selected:', session)}
80
+ onSessionCreate={(session) => console.log('Created:', session)}
81
+ />
82
+ ```
83
+
84
+ #### Props:
85
+ - `appName` (required): Name of the ADK agent application
86
+ - `userId` (required): Unique identifier for the user
87
+ - `showSessionHistory`: Show session history list
88
+ - `enableSessionImport`: Enable session import from JSON
89
+ - `enableSessionExport`: Enable session export to JSON
90
+ - `enableSessionSearch`: Enable search functionality
91
+ - `maxSessions`: Maximum number of sessions to display
92
+ - `views`: Custom styling options
93
+
94
+ ## Architecture
95
+
96
+ ### Component Structure
97
+
98
+ Each component follows the established app-studio pattern:
99
+
100
+ ```
101
+ ComponentName/
102
+ ├── ComponentName.tsx # Main component file
103
+ ├── ComponentName/ # Inner folder for core files
104
+ │ ├── ComponentName.props.ts # Props interface definitions
105
+ │ ├── ComponentName.state.ts # Custom state hook
106
+ │ ├── ComponentName.view.tsx # Presentational component
107
+ │ ├── ComponentName.style.ts # Style constants
108
+ │ └── [SupportingComponents].tsx # Additional components
109
+ └── examples/ # Usage examples
110
+ └── default.tsx # Default usage examples
111
+ ```
112
+
113
+ ### ADK Integration
114
+
115
+ The components are designed to integrate with the ADK backend using the same API patterns as the original adk-web application:
116
+
117
+ #### Required Backend Endpoints:
118
+ - `POST /sessions` - Create new agent session
119
+ - `POST /run_sse` - Send message with streaming response
120
+ - `POST /run` - Send message with regular response
121
+ - `GET /sessions/:id` - Get session details
122
+ - `DELETE /sessions/:id` - Delete session
123
+ - `POST /sessions/import` - Import session
124
+
125
+ #### Message Format:
126
+ The components use the same message format as the original ADK system:
127
+
128
+ ```typescript
129
+ interface AgentRunRequest {
130
+ appName: string;
131
+ userId: string;
132
+ sessionId: string;
133
+ newMessage: {
134
+ role: string;
135
+ parts: MessagePart[];
136
+ };
137
+ streaming?: boolean;
138
+ }
139
+ ```
140
+
141
+ ### Design System Compliance
142
+
143
+ All components follow the app-studio design system:
144
+
145
+ - **Typography**: Inter/Geist font family with standardized sizes (xs:10, sm:12, md:14, lg:16, xl:20)
146
+ - **Spacing**: 4px grid system for consistent spacing
147
+ - **Colors**: app-studio color system (color.[color].[number]) instead of hardcoded values
148
+ - **Shapes**: Consistent border radius and rounded corners
149
+ - **Animations**: Using app-studio Animation object with proper duration and timing
150
+
151
+ ### Reusability
152
+
153
+ The components are designed to be:
154
+
155
+ - **Modular**: Each component can be used independently
156
+ - **Customizable**: Extensive styling options via the `views` prop
157
+ - **Accessible**: ARIA labels, keyboard navigation, and screen reader support
158
+ - **Responsive**: Works across mobile, tablet, and desktop breakpoints
159
+ - **Themeable**: Support for light/dark themes and custom color schemes
160
+
161
+ ## Examples and Documentation
162
+
163
+ ### Demo Pages
164
+
165
+ - **AgentChat Demo**: `src/pages/agentChat.page.tsx`
166
+ - **Component Examples**: Available in each component's `examples/` directory
167
+
168
+ ### Usage Examples
169
+
170
+ Each component includes multiple usage examples:
171
+
172
+ 1. **Default Usage**: Basic implementation with minimal configuration
173
+ 2. **Minimal Usage**: Simplest possible setup
174
+ 3. **Customized Usage**: Advanced styling and configuration options
175
+ 4. **Feature Demos**: Showcasing specific features like function calls, file uploads, etc.
176
+
177
+ ## Integration Guide
178
+
179
+ ### 1. Installation
180
+
181
+ The components are part of the app-studio component library and can be imported directly:
182
+
183
+ ```tsx
184
+ import { AgentChat, AgentSession } from '@app-studio/web';
185
+ ```
186
+
187
+ ### 2. Backend Setup
188
+
189
+ Ensure your ADK backend provides the required endpoints and follows the expected API format.
190
+
191
+ ### 3. Basic Implementation
192
+
193
+ ```tsx
194
+ import React from 'react';
195
+ import { AgentChat, AgentSession } from '@app-studio/web';
196
+ import { View, Horizontal } from 'app-studio';
197
+
198
+ const MyAgentApp = () => {
199
+ return (
200
+ <View height="100vh" padding={20}>
201
+ <Horizontal gap={20} height="100%">
202
+ {/* Session Management */}
203
+ <View width="300px">
204
+ <AgentSession
205
+ appName="my-agent"
206
+ userId="user123"
207
+ />
208
+ </View>
209
+
210
+ {/* Chat Interface */}
211
+ <View flex={1}>
212
+ <AgentChat
213
+ appName="my-agent"
214
+ userId="user123"
215
+ />
216
+ </View>
217
+ </Horizontal>
218
+ </View>
219
+ );
220
+ };
221
+ ```
222
+
223
+ ### 4. Advanced Configuration
224
+
225
+ ```tsx
226
+ <AgentChat
227
+ appName="my-agent"
228
+ userId="user123"
229
+ apiBaseUrl="https://api.example.com"
230
+ enableFileUpload={true}
231
+ enableStreaming={true}
232
+ enableThoughts={true}
233
+ maxFileSize={10 * 1024 * 1024}
234
+ allowedFileTypes={['image/*', 'video/*', 'application/pdf']}
235
+ onSessionCreate={(session) => {
236
+ console.log('New session:', session);
237
+ }}
238
+ onMessageSent={(message) => {
239
+ console.log('Message sent:', message);
240
+ }}
241
+ onError={(error) => {
242
+ console.error('Chat error:', error);
243
+ }}
244
+ views={{
245
+ container: { backgroundColor: 'color.gray.50' },
246
+ userMessage: { backgroundColor: 'color.blue.500' },
247
+ botMessage: { backgroundColor: 'color.green.100' },
248
+ }}
249
+ />
250
+ ```
251
+
252
+ ## Complete Component Library
253
+
254
+ All planned components have been successfully implemented:
255
+
256
+ ### ✅ **AgentTrace Component**
257
+ - **Timeline visualization** of agent execution traces
258
+ - **Event filtering and search** capabilities
259
+ - **Performance metrics** and analytics
260
+ - **Real-time trace updates** via WebSocket
261
+ - **Multiple visualization types** (timeline, tree, table, flamegraph)
262
+ - **Export functionality** (JSON, CSV, SVG)
263
+
264
+ ### ✅ **AgentEval Component**
265
+ - **Evaluation creation and management** interface
266
+ - **Test case execution** and monitoring
267
+ - **Results analysis** and comparison
268
+ - **Metrics calculation** and visualization
269
+ - **Batch evaluation** support
270
+ - **Template system** for reusable evaluations
271
+
272
+ ### ✅ **Agent Service Integration**
273
+ - **Enhanced service layer** for backend communication
274
+ - **React Provider pattern** for service management
275
+ - **Utility functions** for common operations
276
+ - **Real-time updates** via WebSocket and SSE
277
+ - **Error handling and retry logic**
278
+ - **Connection status monitoring**
279
+
280
+ ## Service Integration
281
+
282
+ The ADK components include a comprehensive service layer:
283
+
284
+ ```tsx
285
+ import { AgentServiceProvider, useAgentService } from '@app-studio/web';
286
+
287
+ // Wrap your app with the service provider
288
+ <AgentServiceProvider config={{ baseUrl: 'https://api.example.com' }}>
289
+ <MyApp />
290
+ </AgentServiceProvider>
291
+
292
+ // Use the service in components
293
+ const { service, isConnected } = useAgentService();
294
+ ```
295
+
296
+ ## Demo Page
297
+
298
+ A comprehensive demo page showcasing all components is available at:
299
+ - **File**: `src/pages/adkComponents.page.tsx`
300
+ - **Features**: Interactive demos, customization examples, integration guides
301
+
302
+ ## Support
303
+
304
+ For questions, issues, or contributions related to the ADK Agent Components, please refer to the main app-studio documentation or create an issue in the repository.
305
+
306
+ ## Production Ready
307
+
308
+ All ADK Agent Components are **production-ready** and provide:
309
+ - ✅ Full ADK backend compatibility
310
+ - ✅ TypeScript support with comprehensive type definitions
311
+ - ✅ Accessibility compliance (ARIA labels, keyboard navigation)
312
+ - ✅ Responsive design for mobile, tablet, and desktop
313
+ - ✅ Comprehensive error handling and loading states
314
+ - ✅ Real-time updates and streaming support
315
+ - ✅ Extensive customization options
316
+ - ✅ Complete documentation and examples
@@ -0,0 +1,294 @@
1
+ # ADK Components Quick Start Guide
2
+
3
+ Get up and running with ADK Agent Components in minutes.
4
+
5
+ ## Installation
6
+
7
+ The ADK components are part of the app-studio component library:
8
+
9
+ ```bash
10
+ npm install @app-studio/web
11
+ ```
12
+
13
+ ## Basic Setup
14
+
15
+ ### 1. Import Components
16
+
17
+ ```tsx
18
+ import {
19
+ AgentChat,
20
+ AgentSession,
21
+ AgentTrace,
22
+ AgentEval,
23
+ AgentServiceProvider
24
+ } from '@app-studio/web';
25
+ ```
26
+
27
+ ### 2. Wrap with Service Provider
28
+
29
+ ```tsx
30
+ import { AgentServiceProvider } from '@app-studio/web';
31
+
32
+ function App() {
33
+ return (
34
+ <AgentServiceProvider config={{ baseUrl: 'https://your-adk-api.com' }}>
35
+ <YourApp />
36
+ </AgentServiceProvider>
37
+ );
38
+ }
39
+ ```
40
+
41
+ ### 3. Use Components
42
+
43
+ ```tsx
44
+ function YourApp() {
45
+ return (
46
+ <div style={{ display: 'flex', height: '100vh' }}>
47
+ {/* Session Management */}
48
+ <div style={{ width: '300px' }}>
49
+ <AgentSession
50
+ appName="my-agent"
51
+ userId="user123"
52
+ />
53
+ </div>
54
+
55
+ {/* Chat Interface */}
56
+ <div style={{ flex: 1 }}>
57
+ <AgentChat
58
+ appName="my-agent"
59
+ userId="user123"
60
+ enableFileUpload={true}
61
+ enableStreaming={true}
62
+ />
63
+ </div>
64
+ </div>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ## Component Overview
70
+
71
+ ### AgentChat
72
+ **Purpose**: Real-time chat interface with ADK agents
73
+ **Key Features**: File uploads, streaming, function calls, code execution
74
+
75
+ ```tsx
76
+ <AgentChat
77
+ appName="my-agent"
78
+ userId="user123"
79
+ enableFileUpload={true}
80
+ enableStreaming={true}
81
+ enableThoughts={true}
82
+ onMessageSent={(message) => console.log(message)}
83
+ />
84
+ ```
85
+
86
+ ### AgentSession
87
+ **Purpose**: Session management and organization
88
+ **Key Features**: Create, list, import/export, search sessions
89
+
90
+ ```tsx
91
+ <AgentSession
92
+ appName="my-agent"
93
+ userId="user123"
94
+ showSessionHistory={true}
95
+ enableSessionImport={true}
96
+ enableSessionExport={true}
97
+ />
98
+ ```
99
+
100
+ ### AgentTrace
101
+ **Purpose**: Visualize agent execution traces
102
+ **Key Features**: Timeline view, performance metrics, real-time updates
103
+
104
+ ```tsx
105
+ <AgentTrace
106
+ sessionId="session-123"
107
+ userId="user123"
108
+ appName="my-agent"
109
+ showTimeline={true}
110
+ showMetrics={true}
111
+ enableFiltering={true}
112
+ />
113
+ ```
114
+
115
+ ### AgentEval
116
+ **Purpose**: Run and manage agent evaluations
117
+ **Key Features**: Test creation, execution monitoring, results analysis
118
+
119
+ ```tsx
120
+ <AgentEval
121
+ appName="my-agent"
122
+ userId="user123"
123
+ enableBatchEvaluation={true}
124
+ enableMetricsComparison={true}
125
+ enableResultExport={true}
126
+ />
127
+ ```
128
+
129
+ ## Common Patterns
130
+
131
+ ### 1. Complete Agent Interface
132
+
133
+ ```tsx
134
+ import { Tabs } from 'app-studio';
135
+
136
+ function AgentInterface() {
137
+ return (
138
+ <Tabs defaultValue="chat">
139
+ <Tabs.List>
140
+ <Tabs.Trigger value="chat">Chat</Tabs.Trigger>
141
+ <Tabs.Trigger value="sessions">Sessions</Tabs.Trigger>
142
+ <Tabs.Trigger value="trace">Trace</Tabs.Trigger>
143
+ <Tabs.Trigger value="eval">Evaluation</Tabs.Trigger>
144
+ </Tabs.List>
145
+
146
+ <Tabs.Content value="chat">
147
+ <AgentChat appName="my-agent" userId="user123" />
148
+ </Tabs.Content>
149
+
150
+ <Tabs.Content value="sessions">
151
+ <AgentSession appName="my-agent" userId="user123" />
152
+ </Tabs.Content>
153
+
154
+ <Tabs.Content value="trace">
155
+ <AgentTrace sessionId="current-session" userId="user123" appName="my-agent" />
156
+ </Tabs.Content>
157
+
158
+ <Tabs.Content value="eval">
159
+ <AgentEval appName="my-agent" userId="user123" />
160
+ </Tabs.Content>
161
+ </Tabs>
162
+ );
163
+ }
164
+ ```
165
+
166
+ ### 2. Custom Styling
167
+
168
+ ```tsx
169
+ <AgentChat
170
+ appName="my-agent"
171
+ userId="user123"
172
+ views={{
173
+ container: { backgroundColor: 'color.blue.50' },
174
+ userMessage: { backgroundColor: 'color.blue.500' },
175
+ botMessage: { backgroundColor: 'color.green.100' },
176
+ input: { borderColor: 'color.blue.300' },
177
+ }}
178
+ />
179
+ ```
180
+
181
+ ### 3. Event Handling
182
+
183
+ ```tsx
184
+ function MyComponent() {
185
+ const handleSessionCreate = (session) => {
186
+ console.log('New session created:', session);
187
+ };
188
+
189
+ const handleMessageSent = (message) => {
190
+ console.log('Message sent:', message);
191
+ };
192
+
193
+ const handleError = (error) => {
194
+ console.error('Error:', error);
195
+ };
196
+
197
+ return (
198
+ <AgentChat
199
+ appName="my-agent"
200
+ userId="user123"
201
+ onSessionCreate={handleSessionCreate}
202
+ onMessageSent={handleMessageSent}
203
+ onError={handleError}
204
+ />
205
+ );
206
+ }
207
+ ```
208
+
209
+ ## Backend Requirements
210
+
211
+ Your ADK backend must provide these endpoints:
212
+
213
+ ### Session Management
214
+ - `POST /sessions` - Create session
215
+ - `GET /sessions` - List sessions
216
+ - `GET /sessions/:id` - Get session
217
+ - `DELETE /sessions/:id` - Delete session
218
+
219
+ ### Messaging
220
+ - `POST /run` - Send message (non-streaming)
221
+ - `POST /run_sse` - Send message (streaming)
222
+
223
+ ### Tracing (Optional)
224
+ - `GET /trace/events` - Get trace events
225
+ - `GET /trace/spans` - Get trace spans
226
+ - `GET /trace/metrics` - Get trace metrics
227
+
228
+ ### Evaluation (Optional)
229
+ - `POST /evaluations` - Create evaluation
230
+ - `GET /evaluations` - List evaluations
231
+ - `POST /evaluations/:id/start` - Start evaluation
232
+
233
+ ## Environment Variables
234
+
235
+ ```bash
236
+ # .env
237
+ REACT_APP_AGENT_API_URL=https://your-adk-api.com
238
+ REACT_APP_AGENT_API_KEY=your-api-key
239
+ ```
240
+
241
+ ## TypeScript Support
242
+
243
+ All components include comprehensive TypeScript definitions:
244
+
245
+ ```tsx
246
+ import type {
247
+ AgentChatProps,
248
+ AgentSessionProps,
249
+ AgentTraceProps,
250
+ AgentEvalProps,
251
+ AgentMessage,
252
+ AgentSession,
253
+ TraceEvent,
254
+ EvaluationRun
255
+ } from '@app-studio/web';
256
+ ```
257
+
258
+ ## Troubleshooting
259
+
260
+ ### Common Issues
261
+
262
+ 1. **Components not rendering**: Ensure you've wrapped your app with `AgentServiceProvider`
263
+ 2. **API errors**: Check your backend URL and API endpoints
264
+ 3. **Styling issues**: Verify you're using the app-studio color system
265
+ 4. **TypeScript errors**: Import types from the correct package
266
+
267
+ ### Debug Mode
268
+
269
+ Enable debug logging:
270
+
271
+ ```tsx
272
+ <AgentServiceProvider
273
+ config={{
274
+ baseUrl: 'https://api.example.com',
275
+ enableLogging: true
276
+ }}
277
+ >
278
+ <App />
279
+ </AgentServiceProvider>
280
+ ```
281
+
282
+ ## Next Steps
283
+
284
+ - Explore the [complete documentation](./adk-components.md)
285
+ - Check out the [demo page](../src/pages/adkComponents.page.tsx)
286
+ - View component examples in each component's `examples/` directory
287
+ - Customize components using the `views` prop system
288
+
289
+ ## Support
290
+
291
+ For questions or issues:
292
+ - Check the component documentation
293
+ - Review the example implementations
294
+ - Create an issue in the repository