orchid-ai 1.0.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 (52) hide show
  1. package/README.md +225 -0
  2. package/dist/components/ChatPanel.d.ts +123 -0
  3. package/dist/components/Conversation.d.ts +75 -0
  4. package/dist/components/ErrorBoundary.d.ts +16 -0
  5. package/dist/components/Icon.d.ts +84 -0
  6. package/dist/components/ModelSwitcher.d.ts +24 -0
  7. package/dist/components/SuggestionsPanel.d.ts +27 -0
  8. package/dist/constants.d.ts +353 -0
  9. package/dist/hooks/useAiMerge.d.ts +20 -0
  10. package/dist/hooks/useModelSwitcher.d.ts +65 -0
  11. package/dist/hooks/useStreamingAI.d.ts +29 -0
  12. package/dist/hooks/useSuggestions.d.ts +48 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.esm.js +3385 -0
  15. package/dist/index.js +3400 -0
  16. package/dist/server/components/ChatPanel.d.ts +123 -0
  17. package/dist/server/components/Conversation.d.ts +75 -0
  18. package/dist/server/components/ErrorBoundary.d.ts +16 -0
  19. package/dist/server/components/Icon.d.ts +84 -0
  20. package/dist/server/components/ModelSwitcher.d.ts +24 -0
  21. package/dist/server/components/SuggestionsPanel.d.ts +27 -0
  22. package/dist/server/constants.d.ts +353 -0
  23. package/dist/server/contextual-service.d.ts +59 -0
  24. package/dist/server/document-processor.d.ts +60 -0
  25. package/dist/server/hooks/useAiMerge.d.ts +20 -0
  26. package/dist/server/hooks/useModelSwitcher.d.ts +65 -0
  27. package/dist/server/hooks/useStreamingAI.d.ts +29 -0
  28. package/dist/server/hooks/useSuggestions.d.ts +48 -0
  29. package/dist/server/index.d.ts +7 -0
  30. package/dist/server/index.esm.js +14008 -0
  31. package/dist/server/index.js +14019 -0
  32. package/dist/server/server/contextual-service.d.ts +59 -0
  33. package/dist/server/server/document-processor.d.ts +60 -0
  34. package/dist/server/server/index.d.ts +7 -0
  35. package/dist/server/server/server.d.ts +32 -0
  36. package/dist/server/server/service.d.ts +267 -0
  37. package/dist/server/server/training-schema.d.ts +17 -0
  38. package/dist/server/server/training.d.ts +231 -0
  39. package/dist/server/server/utils.d.ts +209 -0
  40. package/dist/server/server.d.ts +32 -0
  41. package/dist/server/service.d.ts +267 -0
  42. package/dist/server/training-schema.d.ts +17 -0
  43. package/dist/server/training.d.ts +231 -0
  44. package/dist/server/types/types.d.ts +481 -0
  45. package/dist/server/utils/fileHandler.d.ts +20 -0
  46. package/dist/server/utils/mergeWithAi.d.ts +19 -0
  47. package/dist/server/utils.d.ts +209 -0
  48. package/dist/types/types.d.ts +481 -0
  49. package/dist/utils/fileHandler.d.ts +20 -0
  50. package/dist/utils/mergeWithAi.d.ts +19 -0
  51. package/dist/utils.d.ts +19 -0
  52. package/package.json +137 -0
@@ -0,0 +1,231 @@
1
+ import type { TrainingConfig, ProcessedTrainingData } from '../types/types.js';
2
+ interface CollectedFile {
3
+ filePath: string;
4
+ path: string;
5
+ content: any;
6
+ }
7
+ export declare function getTrainingDataConfig(chatLevel?: string): TrainingConfig;
8
+ export declare class CommandTrainingCollector {
9
+ private rootDir;
10
+ private config;
11
+ private verboseLogging;
12
+ private rules;
13
+ private structuredData;
14
+ constructor(rootDir: string, config: TrainingConfig, verboseLogging?: boolean);
15
+ log(...args: any[]): void;
16
+ collectTrainingData(): Promise<ProcessedTrainingData>;
17
+ private collectRawData;
18
+ private buildStructuredData;
19
+ private buildDataModels;
20
+ private buildComponents;
21
+ private buildNavigation;
22
+ private buildBusinessRules;
23
+ private buildExamples;
24
+ private updateOverview;
25
+ private generateProviderFormats;
26
+ private guessEntityFromComponent;
27
+ private guessEntitiesFromComponent;
28
+ private extractRouteParams;
29
+ private guessEntityFromPath;
30
+ getTrainingConfig(): TrainingConfig;
31
+ collectFiles(fieldName: string, filePaths?: string[]): Promise<CollectedFile[]>;
32
+ expandGlobPatterns(patterns: string[]): Promise<string[]>;
33
+ extractFileInfo(fieldName: string, content: string): {
34
+ componentName: string | null;
35
+ props: Array<{
36
+ interfaceName: string;
37
+ properties: Array<{
38
+ name: string;
39
+ type: string;
40
+ optional: boolean;
41
+ }>;
42
+ }>;
43
+ state: Array<{
44
+ type: string;
45
+ variable: string | null;
46
+ }>;
47
+ functions: Array<{
48
+ name: string;
49
+ signature: string;
50
+ }>;
51
+ routes: string[];
52
+ formFields: string[];
53
+ imports: string[];
54
+ exports: string[];
55
+ hooks: string[];
56
+ eventHandlers: string[];
57
+ } | {
58
+ modelName: string | null;
59
+ fields: Array<{
60
+ name: string;
61
+ type: string;
62
+ required: boolean;
63
+ dataType: string;
64
+ transform: any;
65
+ validation: any;
66
+ }>;
67
+ indexes: Array<{
68
+ field: string;
69
+ direction: string;
70
+ }>;
71
+ validations: Array<{
72
+ field: string;
73
+ rule: string;
74
+ }>;
75
+ } | {
76
+ definitions: string[];
77
+ constValues: Array<{
78
+ name: string;
79
+ value: any;
80
+ type: string;
81
+ }>;
82
+ enums: Array<{
83
+ name: string;
84
+ members: Array<{
85
+ name: string;
86
+ value: string;
87
+ }>;
88
+ }>;
89
+ enumValues: string[];
90
+ } | {
91
+ types: string[];
92
+ typeDefinitions: Array<{
93
+ name: string;
94
+ definition: string;
95
+ }>;
96
+ interfaces: string[];
97
+ interfaceDefinitions: Array<{
98
+ name: string;
99
+ properties: Array<{
100
+ name: string;
101
+ type: string;
102
+ optional: boolean;
103
+ }>;
104
+ }>;
105
+ enums: Array<{
106
+ name: string;
107
+ members: Array<{
108
+ name: string;
109
+ value: string;
110
+ }>;
111
+ }>;
112
+ enumMembers: string[];
113
+ } | {
114
+ content: string;
115
+ };
116
+ collectComponents(): Promise<CollectedFile[]>;
117
+ collectSchemas(): Promise<CollectedFile[]>;
118
+ collectConstants(): Promise<CollectedFile[]>;
119
+ collectTypes(): Promise<CollectedFile[]>;
120
+ extractComponentInfo(content: string): {
121
+ componentName: string | null;
122
+ props: Array<{
123
+ interfaceName: string;
124
+ properties: Array<{
125
+ name: string;
126
+ type: string;
127
+ optional: boolean;
128
+ }>;
129
+ }>;
130
+ state: Array<{
131
+ type: string;
132
+ variable: string | null;
133
+ }>;
134
+ functions: Array<{
135
+ name: string;
136
+ signature: string;
137
+ }>;
138
+ routes: string[];
139
+ formFields: string[];
140
+ imports: string[];
141
+ exports: string[];
142
+ hooks: string[];
143
+ eventHandlers: string[];
144
+ };
145
+ extractSchemaInfo(content: string): {
146
+ modelName: string | null;
147
+ fields: Array<{
148
+ name: string;
149
+ type: string;
150
+ required: boolean;
151
+ dataType: string;
152
+ transform: any;
153
+ validation: any;
154
+ }>;
155
+ indexes: Array<{
156
+ field: string;
157
+ direction: string;
158
+ }>;
159
+ validations: Array<{
160
+ field: string;
161
+ rule: string;
162
+ }>;
163
+ };
164
+ extractConstantsInfo(content: string): {
165
+ definitions: string[];
166
+ constValues: Array<{
167
+ name: string;
168
+ value: any;
169
+ type: string;
170
+ }>;
171
+ enums: Array<{
172
+ name: string;
173
+ members: Array<{
174
+ name: string;
175
+ value: string;
176
+ }>;
177
+ }>;
178
+ enumValues: string[];
179
+ };
180
+ extractTypeInfo(content: string): {
181
+ types: string[];
182
+ typeDefinitions: Array<{
183
+ name: string;
184
+ definition: string;
185
+ }>;
186
+ interfaces: string[];
187
+ interfaceDefinitions: Array<{
188
+ name: string;
189
+ properties: Array<{
190
+ name: string;
191
+ type: string;
192
+ optional: boolean;
193
+ }>;
194
+ }>;
195
+ enums: Array<{
196
+ name: string;
197
+ members: Array<{
198
+ name: string;
199
+ value: string;
200
+ }>;
201
+ }>;
202
+ enumMembers: string[];
203
+ };
204
+ /**
205
+ * Parse interface properties from a TypeScript interface
206
+ * @param {string} propertiesText - The properties section of an interface
207
+ * @returns {Array<{name: string, type: string, optional: boolean}>}
208
+ */
209
+ parseInterfaceProperties(propertiesText: string): {
210
+ name: string;
211
+ type: string;
212
+ optional: boolean;
213
+ }[];
214
+ /**
215
+ * Parse enum members from a TypeScript enum
216
+ * @param {string} membersText - The members section of an enum
217
+ * @returns {Array<{name: string, value: string}>}
218
+ */
219
+ parseEnumMembers(membersText: string): {
220
+ name: string;
221
+ value: string;
222
+ }[];
223
+ /**
224
+ * Extract state variable name from useState hook
225
+ * @param {string} content - File content
226
+ * @param {number} stateIndex - Index of useState match
227
+ * @returns {string|null}
228
+ */
229
+ extractStateVariable(content: string, stateIndex: number): string | null;
230
+ }
231
+ export {};
@@ -0,0 +1,481 @@
1
+ export interface CommandSuggestion {
2
+ action?: string;
3
+ actionType: Action;
4
+ path?: string;
5
+ queryParams?: Record<string, string>;
6
+ formState?: Record<string, unknown>;
7
+ message?: string;
8
+ user?: User;
9
+ initials?: string;
10
+ color?: string;
11
+ shortcut?: string;
12
+ title?: string;
13
+ description?: string;
14
+ }
15
+ export interface CommandPopupProps {
16
+ isOpen: boolean;
17
+ onClose: () => void;
18
+ userId: string;
19
+ setFormState: (state: Record<string, unknown>) => void;
20
+ }
21
+ export interface User {
22
+ id: string;
23
+ name: string;
24
+ email: string;
25
+ initials: string;
26
+ color: string;
27
+ }
28
+ export interface CommandTheme {
29
+ primary: string;
30
+ primaryHover: string;
31
+ primaryLight: string;
32
+ secondary: string;
33
+ secondaryHover: string;
34
+ background: string;
35
+ backgroundSecondary: string;
36
+ backgroundTertiary: string;
37
+ textPrimary: string;
38
+ textSecondary: string;
39
+ textTertiary: string;
40
+ textInverse: string;
41
+ borderPrimary: string;
42
+ borderSecondary: string;
43
+ success: string;
44
+ warning: string;
45
+ error: string;
46
+ info: string;
47
+ }
48
+ export interface ChatTheme {
49
+ colors: {
50
+ primary: {
51
+ 50: string;
52
+ 100: string;
53
+ 400: string;
54
+ 500: string;
55
+ 600: string;
56
+ 700: string;
57
+ 800: string;
58
+ 900: string;
59
+ };
60
+ background: {
61
+ primary: string;
62
+ secondary: string;
63
+ tertiary: string;
64
+ };
65
+ text: {
66
+ primary: string;
67
+ secondary: string;
68
+ tertiary: string;
69
+ inverse: string;
70
+ };
71
+ border: {
72
+ primary: string;
73
+ secondary: string;
74
+ };
75
+ surface: {
76
+ primary: string;
77
+ secondary: string;
78
+ tertiary: string;
79
+ elevated: string;
80
+ };
81
+ state: {
82
+ error: {
83
+ background: string;
84
+ border: string;
85
+ text: string;
86
+ };
87
+ warning: {
88
+ background: string;
89
+ border: string;
90
+ text: string;
91
+ };
92
+ success: {
93
+ background: string;
94
+ border: string;
95
+ text: string;
96
+ };
97
+ };
98
+ };
99
+ spacing: {
100
+ xs: string;
101
+ sm: string;
102
+ md: string;
103
+ lg: string;
104
+ xl: string;
105
+ };
106
+ borderRadius: {
107
+ sm: string;
108
+ md: string;
109
+ lg: string;
110
+ full: string;
111
+ };
112
+ shadows: {
113
+ sm: string;
114
+ md: string;
115
+ lg: string;
116
+ xl: string;
117
+ };
118
+ }
119
+ export type AIProvider = 'openai' | 'claude' | 'google';
120
+ export type Action = 'create' | 'new' | 'edit' | 'update' | 'delete' | 'remove' | 'view';
121
+ export type AIStatus = 'none' | 'suggesting' | 'thinking' | 'typing';
122
+ export type ChatLevel = 'full' | 'basic' | 'none';
123
+ export interface RouteConfig {
124
+ path: string;
125
+ title: string;
126
+ description: string;
127
+ }
128
+ export interface ServerConfig {
129
+ domain?: string;
130
+ port?: number;
131
+ suffix?: string;
132
+ secure?: boolean;
133
+ schema?: any;
134
+ additionalContext?: string;
135
+ stayOnPage?: boolean;
136
+ }
137
+ export interface TrainingDataPaths {
138
+ components: string[];
139
+ schemas: string[];
140
+ constants: string[];
141
+ types: string[];
142
+ api: string[];
143
+ utils: string[];
144
+ training: string[];
145
+ }
146
+ export interface TrainingCustomData {
147
+ instructions?: string;
148
+ domain?: Record<string, any>;
149
+ options?: Record<string, any>;
150
+ businessRules?: Record<string, any>;
151
+ }
152
+ export interface TrainingConfig {
153
+ filePaths: TrainingDataPaths;
154
+ routes?: RouteConfig[];
155
+ customTrainingData?: TrainingCustomData;
156
+ verboseLogging?: boolean;
157
+ }
158
+ export interface ProcessedTrainingData {
159
+ components: Array<{
160
+ filePath: string;
161
+ content: {
162
+ componentName: string;
163
+ props: Array<{
164
+ name: string;
165
+ type: string;
166
+ required: boolean;
167
+ }>;
168
+ formFields: string[];
169
+ };
170
+ }>;
171
+ schemas: Array<{
172
+ filePath: string;
173
+ content: {
174
+ modelName: string;
175
+ fields: Array<{
176
+ name: string;
177
+ type: string;
178
+ required: boolean;
179
+ dataType: string;
180
+ }>;
181
+ };
182
+ }>;
183
+ constants: Array<{
184
+ filePath: string;
185
+ content: {
186
+ constValues: Array<{
187
+ name: string;
188
+ value: any;
189
+ }>;
190
+ };
191
+ }>;
192
+ types: Array<{
193
+ filePath: string;
194
+ content: {
195
+ typeName: string;
196
+ properties: Array<{
197
+ name: string;
198
+ type: string;
199
+ optional: boolean;
200
+ }>;
201
+ };
202
+ }>;
203
+ routes: RouteConfig[];
204
+ customTrainingData?: TrainingCustomData;
205
+ }
206
+ export interface TrainingData {
207
+ filePaths?: TrainingDataPaths;
208
+ verboseLogging?: boolean;
209
+ components?: Array<{
210
+ filePath: string;
211
+ content: {
212
+ componentName: string;
213
+ props: Array<{
214
+ name: string;
215
+ type: string;
216
+ required: boolean;
217
+ }>;
218
+ formFields: string[];
219
+ };
220
+ }>;
221
+ schemas?: Array<{
222
+ filePath: string;
223
+ content: {
224
+ modelName: string;
225
+ fields: Array<{
226
+ name: string;
227
+ type: string;
228
+ required: boolean;
229
+ dataType: string;
230
+ }>;
231
+ };
232
+ }>;
233
+ constants?: Array<{
234
+ filePath: string;
235
+ content: {
236
+ constValues: Array<{
237
+ name: string;
238
+ value: any;
239
+ }>;
240
+ };
241
+ }>;
242
+ types?: Array<{
243
+ filePath: string;
244
+ content: {
245
+ typeName: string;
246
+ properties: Array<{
247
+ name: string;
248
+ type: string;
249
+ optional: boolean;
250
+ }>;
251
+ };
252
+ }>;
253
+ routes?: RouteConfig[];
254
+ customTrainingData?: TrainingCustomData;
255
+ }
256
+ export interface AIServiceConfig {
257
+ providers?: Record<string, {
258
+ apiKey: string;
259
+ models: string[];
260
+ }>;
261
+ openaiApiKey?: string;
262
+ claudeApiKey?: string;
263
+ geminiApiKey?: string;
264
+ chatLevel?: 'full' | 'basic' | 'none';
265
+ verboseLogging?: boolean;
266
+ trainingData?: ProcessedTrainingData;
267
+ trainingConfig?: TrainingConfig;
268
+ model?: string | null;
269
+ maxTokens?: number;
270
+ temperature?: number;
271
+ writeConfigToFile?: boolean;
272
+ baseDir?: string;
273
+ }
274
+ export interface CommandConfig extends AIServiceConfig {
275
+ service?: AIProvider | null;
276
+ apiKey?: string | null;
277
+ }
278
+ export interface TextContent {
279
+ type: 'text';
280
+ content: string;
281
+ }
282
+ export interface SuggestionsContent {
283
+ type: 'suggestions';
284
+ content: CommandSuggestion[];
285
+ }
286
+ export interface LoadingSuggestionsContent {
287
+ type: 'loading-suggestions';
288
+ content: string;
289
+ }
290
+ export type MessageContent = TextContent | SuggestionsContent | LoadingSuggestionsContent;
291
+ export interface ChatMessage {
292
+ sender: 'user' | 'ai' | 'system';
293
+ content: MessageContent[];
294
+ action?: string;
295
+ isLoading?: boolean;
296
+ aiStatus?: AIStatus;
297
+ isError?: boolean;
298
+ errorType?: string;
299
+ retryAfter?: number;
300
+ timestamp?: number;
301
+ files?: File[];
302
+ suggestions?: CommandSuggestion[];
303
+ }
304
+ export interface ModelCapabilities {
305
+ supportsImages: boolean;
306
+ supportsAudio?: boolean;
307
+ supportsVideo?: boolean;
308
+ maxTokens?: number;
309
+ contextWindow?: number;
310
+ computeWeight?: number;
311
+ }
312
+ export interface CurrentModel {
313
+ model: string;
314
+ provider: string;
315
+ }
316
+ export interface ModelInfo {
317
+ id: string;
318
+ name: string;
319
+ provider: string;
320
+ available: boolean;
321
+ error?: string;
322
+ supportsImages: boolean;
323
+ computeWeight: number;
324
+ description?: string;
325
+ }
326
+ export interface ProviderStats {
327
+ name: string;
328
+ requests: number;
329
+ }
330
+ export interface UsageStats {
331
+ requests: number;
332
+ totalTokens: number;
333
+ totalComputeUnits: number;
334
+ modelSwitches: number;
335
+ uptime: number;
336
+ providers: Array<{
337
+ name: string;
338
+ requests: number;
339
+ computeUnits: number;
340
+ models: string[];
341
+ }>;
342
+ currentProvider: string;
343
+ currentModel: string;
344
+ }
345
+ export interface Store {
346
+ ai: {
347
+ form: Record<string, unknown>;
348
+ setForm: (state: Record<string, unknown>) => void;
349
+ };
350
+ }
351
+ export interface ModelSwitcherData {
352
+ modelsByProvider: Record<string, ModelInfo[]>;
353
+ currentModel: CurrentModel | null;
354
+ currentCapabilities: ModelCapabilities | null;
355
+ usageStats: UsageStats | null;
356
+ isLoading: boolean;
357
+ error: string | null;
358
+ switchModel: (modelId: string, provider: string) => Promise<void>;
359
+ integrationMode: string;
360
+ }
361
+ export interface ServerOptions extends AIServiceConfig {
362
+ port?: number;
363
+ baseDir?: string;
364
+ service?: AIProvider;
365
+ apiKey?: string;
366
+ customTrainingData?: Partial<TrainingCustomData>;
367
+ }
368
+ export interface CommandServer {
369
+ app: any;
370
+ start: () => void;
371
+ stop: () => void;
372
+ getConfig: () => CommandConfig;
373
+ }
374
+ export interface ApiKeys {
375
+ openai?: string;
376
+ claude?: string;
377
+ gemini?: string;
378
+ [key: string]: string | undefined;
379
+ }
380
+ export interface DefaultModels {
381
+ openai: string[];
382
+ claude: string[];
383
+ gemini: string[];
384
+ [key: string]: string[];
385
+ }
386
+ export interface ImageContent {
387
+ type: string;
388
+ source?: {
389
+ type: string;
390
+ media_type: string;
391
+ data: string;
392
+ };
393
+ image_url?: {
394
+ url: string;
395
+ };
396
+ inlineData?: {
397
+ mimeType: string;
398
+ data: string;
399
+ };
400
+ }
401
+ export interface Provider {
402
+ apiKey: string;
403
+ models?: string[];
404
+ }
405
+ export type Intent = 'CORRECTION' | 'COMPLETION' | 'DATA_ENTRY' | 'NAVIGATION' | 'INFORMATION';
406
+ export interface AnalysisContext {
407
+ entities: Map<string, any>;
408
+ formStates: Map<string, any>;
409
+ userPreferences: Map<string, any>;
410
+ recentActions: string[];
411
+ intent: Intent;
412
+ extractedData: Record<string, any>;
413
+ }
414
+ export interface DataType {
415
+ pattern: RegExp;
416
+ convert: (value: string) => any;
417
+ }
418
+ /**
419
+ * JSON Schema definition for data that the AI should generate
420
+ * This follows JSON Schema specification but simplified for common use cases
421
+ */
422
+ export interface SchemaDefinition {
423
+ title?: string;
424
+ description?: string;
425
+ type: 'object' | 'array' | 'string' | 'number' | 'boolean';
426
+ properties?: Record<string, SchemaProperty>;
427
+ required?: string[];
428
+ items?: SchemaProperty;
429
+ }
430
+ /**
431
+ * Individual property definition in a schema
432
+ */
433
+ export interface SchemaProperty {
434
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
435
+ description?: string;
436
+ enum?: string[] | number[];
437
+ items?: SchemaProperty;
438
+ properties?: Record<string, SchemaProperty>;
439
+ required?: string[];
440
+ default?: any;
441
+ format?: string;
442
+ pattern?: string;
443
+ minLength?: number;
444
+ maxLength?: number;
445
+ minimum?: number;
446
+ maximum?: number;
447
+ }
448
+ /**
449
+ * Simplified config for ContextualCommandService
450
+ */
451
+ export interface ContextualServiceConfig {
452
+ openaiApiKey?: string;
453
+ claudeApiKey?: string;
454
+ geminiApiKey?: string;
455
+ providers?: Record<string, {
456
+ apiKey: string;
457
+ models: string[];
458
+ }>;
459
+ chatLevel?: 'full' | 'basic' | 'none';
460
+ temperature?: number;
461
+ maxTokens?: number;
462
+ verboseLogging?: boolean;
463
+ }
464
+ /**
465
+ * Request structure for contextual service
466
+ */
467
+ export interface ContextualRequest {
468
+ command: string;
469
+ schema?: SchemaDefinition;
470
+ chatHistory?: Array<{
471
+ role: 'user' | 'assistant';
472
+ content: string;
473
+ }>;
474
+ modelSelection?: {
475
+ provider: string;
476
+ model: string;
477
+ };
478
+ chatLevel?: 'full' | 'basic' | 'none';
479
+ additionalContext?: string;
480
+ images?: any[];
481
+ }