@almadar/ui 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.
@@ -0,0 +1,1006 @@
1
+ import { OrbitalSchema } from '@almadar/core';
2
+ import { E as EventBusContextType, a as EventListener } from '../event-bus-types-8-cjyMxw.js';
3
+ export { K as KFlowEvent, U as Unsubscribe } from '../event-bus-types-8-cjyMxw.js';
4
+ export { D as DEFAULT_SLOTS, R as RenderUIConfig, b as SlotAnimation, c as SlotChangeCallback, S as SlotContent, a as UISlot, U as UISlotManager, u as useUISlotManager } from '../useUISlots-mnggE9X9.js';
5
+ import * as _tanstack_react_query from '@tanstack/react-query';
6
+ import { Entity, getEntity, getByType, getAllEntities, getSingleton, spawnEntity, updateEntity, updateSingleton, removeEntity, clearEntities } from '../stores/index.js';
7
+
8
+ /**
9
+ * useOrbitalHistory Hook
10
+ *
11
+ * Provides version control timeline for OrbitalSchema changes.
12
+ * Tracks changesets and snapshots, supports reverting to previous versions.
13
+ */
14
+
15
+ interface ChangeSummary {
16
+ added: number;
17
+ modified: number;
18
+ removed: number;
19
+ }
20
+ interface HistoryTimelineItem {
21
+ id: string;
22
+ type: 'changeset' | 'snapshot';
23
+ version: number;
24
+ timestamp: number;
25
+ description: string;
26
+ source?: string;
27
+ summary?: ChangeSummary;
28
+ reason?: string;
29
+ }
30
+ interface RevertResult {
31
+ success: boolean;
32
+ error?: string;
33
+ restoredSchema?: OrbitalSchema;
34
+ }
35
+ interface UseOrbitalHistoryOptions {
36
+ appId: string | null;
37
+ /** Firebase auth token for authenticated API requests */
38
+ authToken?: string | null;
39
+ /** User ID for x-user-id header (required for Firestore path) */
40
+ userId?: string | null;
41
+ onHistoryChange?: (timeline: HistoryTimelineItem[]) => void;
42
+ onRevertSuccess?: (restoredSchema: OrbitalSchema) => void;
43
+ }
44
+ interface UseOrbitalHistoryResult {
45
+ timeline: HistoryTimelineItem[];
46
+ currentVersion: number;
47
+ isLoading: boolean;
48
+ error: string | null;
49
+ revertToSnapshot: (snapshotId: string) => Promise<RevertResult>;
50
+ refresh: () => Promise<void>;
51
+ }
52
+ declare function useOrbitalHistory(options: UseOrbitalHistoryOptions): UseOrbitalHistoryResult;
53
+
54
+ /**
55
+ * useFileSystem Hook
56
+ *
57
+ * Provides file system operations for WebContainer-based file management.
58
+ * Handles booting, mounting files, reading/writing, and tree operations.
59
+ */
60
+ interface FileNode {
61
+ path: string;
62
+ name: string;
63
+ type: 'file' | 'directory';
64
+ children?: FileNode[];
65
+ }
66
+ type FileSystemStatus = 'idle' | 'booting' | 'ready' | 'running' | 'error';
67
+ interface FileSystemFile {
68
+ path: string;
69
+ content: string;
70
+ }
71
+ interface SelectedFile {
72
+ path: string;
73
+ content: string;
74
+ language?: string;
75
+ isDirty?: boolean;
76
+ }
77
+ interface UseFileSystemResult {
78
+ status: FileSystemStatus;
79
+ error: string | null;
80
+ isLoading: boolean;
81
+ files: FileNode[];
82
+ selectedFile: SelectedFile | null;
83
+ selectedPath: string | null;
84
+ previewUrl: string | null;
85
+ boot: () => Promise<void>;
86
+ mountFiles: (files: FileSystemFile[] | Record<string, unknown>) => Promise<void>;
87
+ readFile: (path: string) => Promise<string>;
88
+ writeFile: (path: string, content: string) => Promise<void>;
89
+ selectFile: (path: string) => Promise<void>;
90
+ updateContent: (pathOrContent: string, content?: string) => void;
91
+ updateSelectedContent: (content: string) => void;
92
+ refreshTree: () => Promise<void>;
93
+ runCommand: (command: string) => Promise<{
94
+ exitCode: number;
95
+ output: string;
96
+ }>;
97
+ startDevServer: () => Promise<void>;
98
+ }
99
+ declare function useFileSystem(): UseFileSystemResult;
100
+
101
+ /**
102
+ * useExtensions Hook
103
+ *
104
+ * Manages loading and accessing language/editor extensions.
105
+ */
106
+ interface Extension {
107
+ id: string;
108
+ name: string;
109
+ language?: string;
110
+ loaded: boolean;
111
+ }
112
+ interface ExtensionEntry {
113
+ file: string;
114
+ language?: string;
115
+ }
116
+ interface ExtensionManifest {
117
+ languages: Record<string, {
118
+ extensions: string[];
119
+ icon?: string;
120
+ color?: string;
121
+ }>;
122
+ extensions: ExtensionEntry[];
123
+ }
124
+ interface UseExtensionsOptions {
125
+ appId: string;
126
+ loadOnMount?: boolean;
127
+ }
128
+ interface UseExtensionsResult {
129
+ extensions: Extension[];
130
+ manifest: ExtensionManifest;
131
+ isLoading: boolean;
132
+ error: string | null;
133
+ loadExtension: (extensionId: string) => Promise<void>;
134
+ loadExtensions: () => Promise<void>;
135
+ getExtensionForFile: (filename: string) => Extension | null;
136
+ }
137
+ declare function useExtensions(options: UseExtensionsOptions): UseExtensionsResult;
138
+
139
+ /**
140
+ * useFileEditor Hook
141
+ *
142
+ * Manages file editing state and operations.
143
+ */
144
+
145
+ interface OpenFile {
146
+ path: string;
147
+ content: string;
148
+ isDirty: boolean;
149
+ language?: string;
150
+ }
151
+ interface UseFileEditorOptions {
152
+ extensions: UseExtensionsResult;
153
+ fileSystem: UseFileSystemResult;
154
+ onSchemaUpdate?: (schema: OrbitalSchema) => Promise<void>;
155
+ }
156
+ interface FileEditResult {
157
+ success: boolean;
158
+ action?: 'updated_schema' | 'converted_extension' | 'saved_extension' | 'saved';
159
+ error?: string;
160
+ }
161
+ interface UseFileEditorResult {
162
+ openFiles: OpenFile[];
163
+ activeFile: OpenFile | null;
164
+ isSaving: boolean;
165
+ openFile: (path: string) => Promise<void>;
166
+ closeFile: (path: string) => void;
167
+ setActiveFile: (path: string) => void;
168
+ updateFileContent: (path: string, content: string) => void;
169
+ handleFileEdit: (path: string, content: string) => Promise<FileEditResult>;
170
+ saveFile: (path: string) => Promise<void>;
171
+ saveAllFiles: () => Promise<void>;
172
+ }
173
+ declare function useFileEditor(options: UseFileEditorOptions): UseFileEditorResult;
174
+
175
+ /**
176
+ * useCompile Hook
177
+ *
178
+ * Handles schema compilation to generate application files.
179
+ */
180
+ interface SchemaLike {
181
+ name: string;
182
+ version?: string;
183
+ [key: string]: unknown;
184
+ }
185
+ type CompileStage = 'idle' | 'compiling' | 'done' | 'error';
186
+ interface CompileResult {
187
+ success: boolean;
188
+ files?: Array<{
189
+ path: string;
190
+ content: string;
191
+ }>;
192
+ errors?: string[];
193
+ }
194
+ interface UseCompileResult {
195
+ isCompiling: boolean;
196
+ stage: CompileStage;
197
+ lastResult: CompileResult | null;
198
+ error: string | null;
199
+ compileSchema: (schema: SchemaLike) => Promise<CompileResult | null>;
200
+ }
201
+ declare function useCompile(): UseCompileResult;
202
+
203
+ /**
204
+ * usePreview Hook
205
+ *
206
+ * Stub implementation for app preview state management.
207
+ * Actual API calls should be implemented by the consuming client.
208
+ */
209
+
210
+ interface PreviewApp {
211
+ id: string;
212
+ name: string;
213
+ status: 'loading' | 'ready' | 'error';
214
+ schema?: OrbitalSchema;
215
+ graphView: {
216
+ version: string;
217
+ };
218
+ }
219
+ interface Notification {
220
+ id: string;
221
+ type: 'info' | 'warning' | 'error' | 'success';
222
+ title: string;
223
+ message: string;
224
+ timestamp: number;
225
+ read?: boolean;
226
+ actionLabel?: string;
227
+ onAction?: () => void;
228
+ autoDismiss?: boolean;
229
+ dismissAfter?: number;
230
+ }
231
+ interface NotificationsState {
232
+ notifications: Notification[];
233
+ isPanelOpen: boolean;
234
+ closePanel: () => void;
235
+ dismissNotification: (id: string) => void;
236
+ markAsRead: (id: string) => void;
237
+ clearAll: () => void;
238
+ }
239
+ interface ErrorToast {
240
+ message: string;
241
+ }
242
+ interface UsePreviewResult {
243
+ previewUrl: string | null;
244
+ isLoading: boolean;
245
+ error: string | null;
246
+ loadError: string | null;
247
+ app: PreviewApp | null;
248
+ isFullscreen: boolean;
249
+ isExecutingEvent: boolean;
250
+ errorToast: ErrorToast | null;
251
+ currentStateName: string | null;
252
+ notifications: NotificationsState;
253
+ startPreview: () => Promise<void>;
254
+ stopPreview: () => Promise<void>;
255
+ refresh: () => Promise<void>;
256
+ handleRefresh: () => Promise<void>;
257
+ handleReset: () => Promise<void>;
258
+ toggleFullscreen: () => void;
259
+ setErrorToast: (toast: ErrorToast | null) => void;
260
+ dismissErrorToast: () => void;
261
+ }
262
+ interface UsePreviewOptions {
263
+ appId?: string;
264
+ }
265
+ declare function usePreview(options?: UsePreviewOptions): UsePreviewResult;
266
+
267
+ /**
268
+ * useDeepAgentGeneration Hook
269
+ *
270
+ * Stub implementation for deep agent generation functionality.
271
+ */
272
+
273
+ interface DeepAgentActionRequest {
274
+ id: string;
275
+ type: string;
276
+ tool: string;
277
+ args: Record<string, unknown>;
278
+ description?: string;
279
+ allowedDecisions: ('approve' | 'edit' | 'reject')[];
280
+ status: 'pending' | 'approved' | 'rejected' | 'edited';
281
+ }
282
+ interface DeepAgentInterrupt {
283
+ id: string;
284
+ type: 'tool_calls' | 'confirmation' | 'error';
285
+ message?: string;
286
+ actionRequests: DeepAgentActionRequest[];
287
+ timestamp: number;
288
+ threadId?: string;
289
+ }
290
+ interface GenerationRequest {
291
+ id: string;
292
+ prompt: string;
293
+ status: 'pending' | 'running' | 'completed' | 'failed';
294
+ result?: OrbitalSchema;
295
+ error?: string;
296
+ }
297
+ interface GenerationProgress {
298
+ stage: string;
299
+ percent: number;
300
+ message: string;
301
+ }
302
+ interface UseDeepAgentGenerationResult {
303
+ requests: GenerationRequest[];
304
+ currentRequest: GenerationRequest | null;
305
+ isGenerating: boolean;
306
+ isLoading: boolean;
307
+ isComplete: boolean;
308
+ progress: GenerationProgress;
309
+ error: string | null;
310
+ interrupt: DeepAgentInterrupt | null;
311
+ generate: (prompt: string) => Promise<OrbitalSchema | null>;
312
+ startGeneration: (skill: string, prompt: string, options?: Record<string, unknown>) => Promise<void>;
313
+ cancelGeneration: () => void;
314
+ clearRequests: () => void;
315
+ submitInterruptDecisions: (decisions: unknown[]) => void;
316
+ }
317
+ declare function useDeepAgentGeneration(): UseDeepAgentGenerationResult;
318
+
319
+ /**
320
+ * useAgentChat Hook
321
+ *
322
+ * Stub implementation for agent chat functionality.
323
+ */
324
+
325
+ interface ChatMessage {
326
+ id: string;
327
+ role: 'user' | 'assistant' | 'system';
328
+ content: string;
329
+ timestamp: number;
330
+ }
331
+ type AvatarRole = 'user' | 'assistant' | 'system';
332
+ type FileOperation = 'ls' | 'read_file' | 'write_file' | 'edit_file';
333
+ type Activity = {
334
+ type: 'message';
335
+ role: AvatarRole;
336
+ content: string;
337
+ timestamp: number;
338
+ isStreaming?: boolean;
339
+ } | {
340
+ type: 'tool_call';
341
+ tool: string;
342
+ args: Record<string, unknown>;
343
+ timestamp: number;
344
+ isExecuting?: boolean;
345
+ } | {
346
+ type: 'tool_result';
347
+ tool: string;
348
+ result: unknown;
349
+ success: boolean;
350
+ timestamp: number;
351
+ } | {
352
+ type: 'file_operation';
353
+ operation: FileOperation;
354
+ path: string;
355
+ success?: boolean;
356
+ timestamp: number;
357
+ } | {
358
+ type: 'schema_diff';
359
+ filePath: string;
360
+ hunks: DiffHunk[];
361
+ timestamp: number;
362
+ } | {
363
+ type: 'error';
364
+ message: string;
365
+ code?: string;
366
+ timestamp: number;
367
+ };
368
+ interface TodoActivity {
369
+ type: 'thinking' | 'tool_call' | 'tool_result' | 'code_change';
370
+ content: string;
371
+ timestamp: number;
372
+ tool?: string;
373
+ success?: boolean;
374
+ filePath?: string;
375
+ diff?: string;
376
+ }
377
+ interface Todo {
378
+ id: string;
379
+ task: string;
380
+ status: 'pending' | 'in_progress' | 'completed';
381
+ latestActivity?: TodoActivity;
382
+ activityHistory?: TodoActivity[];
383
+ }
384
+ interface DiffHunk {
385
+ oldStart: number;
386
+ oldLines: number;
387
+ newStart: number;
388
+ newLines: number;
389
+ lines: Array<{
390
+ type: 'add' | 'remove' | 'context';
391
+ content: string;
392
+ }>;
393
+ }
394
+ interface SchemaDiff {
395
+ id: string;
396
+ filePath: string;
397
+ hunks: DiffHunk[];
398
+ timestamp: number;
399
+ addedLines: number;
400
+ removedLines: number;
401
+ }
402
+ type AgentStatus = 'idle' | 'running' | 'complete' | 'error' | 'interrupted';
403
+ interface UseAgentChatOptions {
404
+ appId?: string;
405
+ onComplete?: (schema?: unknown) => void;
406
+ onSchemaChange?: (diff?: unknown) => void;
407
+ onError?: (error: Error | string) => void;
408
+ }
409
+ interface UseAgentChatResult {
410
+ messages: ChatMessage[];
411
+ status: AgentStatus;
412
+ activities: Activity[];
413
+ todos: Todo[];
414
+ schemaDiffs: SchemaDiff[];
415
+ isLoading: boolean;
416
+ error: string | null;
417
+ threadId: string | null;
418
+ interrupt: DeepAgentInterrupt | null;
419
+ sendMessage: (content: string) => Promise<void>;
420
+ startGeneration: (skill: string | string[], prompt: string, options?: Record<string, unknown>) => Promise<void>;
421
+ continueConversation: (message: string | string[]) => Promise<void>;
422
+ resumeWithDecision: (decisions: unknown[]) => Promise<void>;
423
+ cancel: () => void;
424
+ clearMessages: () => void;
425
+ clearHistory: () => void;
426
+ }
427
+ declare function useAgentChat(options?: UseAgentChatOptions): UseAgentChatResult;
428
+
429
+ /**
430
+ * useValidation Hook
431
+ *
432
+ * Stub implementation for schema validation.
433
+ */
434
+ interface LLMErrorContext {
435
+ rawValuePreview?: string;
436
+ expectedType?: string;
437
+ actualType?: string;
438
+ source?: {
439
+ agent: 'requirements' | 'builder' | 'view-planner';
440
+ operation: string;
441
+ promptHash?: string;
442
+ };
443
+ tokenUsage?: {
444
+ prompt: number;
445
+ completion: number;
446
+ };
447
+ }
448
+ interface ValidationError {
449
+ code: string;
450
+ message: string;
451
+ path?: string;
452
+ severity: 'error' | 'warning';
453
+ suggestion?: string;
454
+ validValues?: string[];
455
+ expectedShape?: string;
456
+ fixGuidance?: string;
457
+ llmContext?: LLMErrorContext;
458
+ }
459
+ interface ValidationResult {
460
+ valid: boolean;
461
+ errors: ValidationError[];
462
+ warnings: ValidationError[];
463
+ }
464
+ type ValidationStage = 'idle' | 'validating' | 'fixing' | 'complete';
465
+ interface UseValidationResult {
466
+ result: ValidationResult | null;
467
+ isValidating: boolean;
468
+ error: string | null;
469
+ stage: ValidationStage;
470
+ isFixing: boolean;
471
+ progressMessage: string | null;
472
+ errors: ValidationError[];
473
+ warnings: ValidationError[];
474
+ isValid: boolean;
475
+ validate: (appId: string) => Promise<ValidationResult>;
476
+ clearResult: () => void;
477
+ reset: () => void;
478
+ }
479
+ declare function useValidation(): UseValidationResult;
480
+
481
+ /**
482
+ * useEventBus Hook
483
+ *
484
+ * Provides event bus utilities for component communication.
485
+ * This connects to the EventBusProvider for real applications
486
+ * or provides a simple in-memory bus for design system / Storybook.
487
+ *
488
+ * @packageDocumentation
489
+ */
490
+
491
+ /**
492
+ * Hook for accessing the event bus.
493
+ *
494
+ * Uses EventBusProvider context if available, otherwise falls back to
495
+ * a simple in-memory event bus (for design system / Storybook).
496
+ *
497
+ * @returns Event bus instance with emit, on, once, and hasListeners methods
498
+ *
499
+ * @example
500
+ * ```tsx
501
+ * const eventBus = useEventBus();
502
+ *
503
+ * // Emit an event
504
+ * eventBus.emit('UI:CLICK', { id: '123' });
505
+ *
506
+ * // Subscribe to an event
507
+ * useEffect(() => {
508
+ * return eventBus.on('UI:CLICK', (event) => {
509
+ * console.log('Clicked:', event.payload);
510
+ * });
511
+ * }, []);
512
+ * ```
513
+ */
514
+ declare function useEventBus(): EventBusContextType;
515
+ /**
516
+ * Hook for subscribing to a specific event.
517
+ * Automatically cleans up subscription on unmount.
518
+ *
519
+ * @param event - Event name to subscribe to
520
+ * @param handler - Event handler function
521
+ *
522
+ * @example
523
+ * ```tsx
524
+ * useEventListener('UI:CLICK', (event) => {
525
+ * console.log('Clicked:', event.payload);
526
+ * });
527
+ * ```
528
+ */
529
+ declare function useEventListener(event: string, handler: EventListener): void;
530
+ /**
531
+ * Hook for emitting events.
532
+ * Returns a memoized emit function.
533
+ *
534
+ * @returns Function to emit events
535
+ *
536
+ * @example
537
+ * ```tsx
538
+ * const emit = useEmitEvent();
539
+ *
540
+ * const handleClick = () => {
541
+ * emit('UI:CLICK', { id: '123' });
542
+ * };
543
+ * ```
544
+ */
545
+ declare function useEmitEvent(): (type: string, payload?: Record<string, unknown>) => void;
546
+
547
+ /**
548
+ * useUIEvents - UI Event to State Machine Bridge
549
+ *
550
+ * Listens for UI events from the event bus and dispatches
551
+ * corresponding state machine events.
552
+ *
553
+ * Components emit events like `UI:VIEW`, `UI:SAVE`, `UI:CANCEL`
554
+ * This hook translates them to state machine dispatch calls.
555
+ */
556
+
557
+ /**
558
+ * Hook to bridge UI events to state machine dispatch
559
+ *
560
+ * @param dispatch - The state machine dispatch function
561
+ * @param validEvents - Optional array of valid event names (filters which events to handle)
562
+ * @param eventBusInstance - Optional event bus instance (for testing, uses hook if not provided)
563
+ */
564
+ declare function useUIEvents<E extends string>(dispatch: (event: E, payload?: unknown) => void, validEvents?: readonly E[], eventBusInstance?: ReturnType<typeof useEventBus>): void;
565
+ /**
566
+ * Hook for selected entity tracking
567
+ * Many list UIs need to track which item is selected.
568
+ *
569
+ * This hook uses SelectionProvider if available (preferred),
570
+ * otherwise falls back to listening to events directly.
571
+ *
572
+ * @example Using with SelectionProvider (recommended)
573
+ * ```tsx
574
+ * function MyPage() {
575
+ * return (
576
+ * <EventBusProvider>
577
+ * <SelectionProvider>
578
+ * <MyComponent />
579
+ * </SelectionProvider>
580
+ * </EventBusProvider>
581
+ * );
582
+ * }
583
+ *
584
+ * function MyComponent() {
585
+ * const [selected, setSelected] = useSelectedEntity<Order>();
586
+ * // selected is automatically updated when UI:VIEW/UI:SELECT events fire
587
+ * }
588
+ * ```
589
+ */
590
+ declare function useSelectedEntity<T>(eventBusInstance?: ReturnType<typeof useEventBus>): [T | null, (entity: T | null) => void];
591
+
592
+ /**
593
+ * useEntityData Hook
594
+ *
595
+ * Provides data fetching utilities for entity lists.
596
+ * This is a stub implementation for the design system that returns mock data.
597
+ * In a real application, this would connect to a backend API.
598
+ *
599
+ * @packageDocumentation
600
+ */
601
+ /**
602
+ * Query key factory for entity data queries.
603
+ * Used with React Query for cache invalidation.
604
+ */
605
+ declare const entityDataKeys: {
606
+ all: readonly ["entities"];
607
+ lists: () => readonly ["entities", "list"];
608
+ list: (entity: string, filters?: Record<string, unknown>) => readonly ["entities", "list", string, Record<string, unknown> | undefined];
609
+ details: () => readonly ["entities", "detail"];
610
+ detail: (entity: string, id: string) => readonly ["entities", "detail", string, string];
611
+ };
612
+ /**
613
+ * Generic entity data record type
614
+ */
615
+ type EntityDataRecord = Record<string, unknown>;
616
+ interface UseEntityListOptions {
617
+ /** Skip fetching */
618
+ skip?: boolean;
619
+ }
620
+ interface UseEntityListResult<T = Record<string, unknown>> {
621
+ /** Fetched data */
622
+ data: T[];
623
+ /** Loading state */
624
+ isLoading: boolean;
625
+ /** Error state */
626
+ error: Error | null;
627
+ /** Refetch function */
628
+ refetch: () => void;
629
+ }
630
+ /**
631
+ * Hook for fetching entity list data
632
+ *
633
+ * @param entity - Entity name to fetch
634
+ * @param options - Fetch options
635
+ * @returns Entity list data and loading states
636
+ *
637
+ * @example
638
+ * ```tsx
639
+ * const { data, isLoading, error } = useEntityList('tasks');
640
+ * ```
641
+ */
642
+ declare function useEntityList<T = Record<string, unknown>>(entity: string | undefined, options?: UseEntityListOptions): UseEntityListResult<T>;
643
+ /**
644
+ * Hook for fetching a single entity by ID
645
+ *
646
+ * @param entity - Entity name
647
+ * @param id - Entity ID
648
+ * @returns Single entity data and loading states
649
+ */
650
+ declare function useEntity$1<T = Record<string, unknown>>(entity: string | undefined, id: string | undefined): {
651
+ data: T | null;
652
+ isLoading: boolean;
653
+ error: Error | null;
654
+ };
655
+ /**
656
+ * Result type for useEntityDetail hook
657
+ */
658
+ interface UseEntityDetailResult<T = Record<string, unknown>> {
659
+ /** Fetched entity data */
660
+ data: T | null;
661
+ /** Loading state */
662
+ isLoading: boolean;
663
+ /** Error state */
664
+ error: Error | null;
665
+ /** Refetch function */
666
+ refetch: () => void;
667
+ }
668
+ /**
669
+ * Hook for fetching entity detail by ID (alias for useEntity with refetch)
670
+ *
671
+ * @param entity - Entity name
672
+ * @param id - Entity ID
673
+ * @returns Entity detail data and loading states
674
+ *
675
+ * @example
676
+ * ```tsx
677
+ * const { data, isLoading, error, refetch } = useEntityDetail('tasks', taskId);
678
+ * ```
679
+ */
680
+ declare function useEntityDetail<T = Record<string, unknown>>(entity: string | undefined, id: string | undefined): UseEntityDetailResult<T>;
681
+
682
+ /**
683
+ * useQuerySingleton Hook
684
+ *
685
+ * Provides query state management for search/filter components.
686
+ * This is a stub implementation for the design system.
687
+ * In a real application, this would connect to the orbital query singleton.
688
+ *
689
+ * @packageDocumentation
690
+ */
691
+ /**
692
+ * Query state for filters and search
693
+ */
694
+ interface QueryState {
695
+ search?: string;
696
+ filters?: Record<string, unknown>;
697
+ sortField?: string;
698
+ sortDirection?: 'asc' | 'desc';
699
+ }
700
+ /**
701
+ * Query singleton entity reference
702
+ */
703
+ interface QuerySingletonEntity {
704
+ name: string;
705
+ fields: Record<string, unknown>;
706
+ }
707
+ /**
708
+ * Query singleton result type
709
+ */
710
+ interface QuerySingletonResult {
711
+ state: QueryState;
712
+ setState: (state: Partial<QueryState>) => void;
713
+ reset: () => void;
714
+ }
715
+ interface QuerySingletonState {
716
+ /** Current search term */
717
+ search: string;
718
+ /** Set search term */
719
+ setSearch: (value: string) => void;
720
+ /** Current filters */
721
+ filters: Record<string, unknown>;
722
+ /** Set a filter value */
723
+ setFilter: (key: string, value: unknown) => void;
724
+ /** Clear all filters */
725
+ clearFilters: () => void;
726
+ /** Current sort field */
727
+ sortField?: string;
728
+ /** Current sort direction */
729
+ sortDirection?: 'asc' | 'desc';
730
+ /** Set sort */
731
+ setSort: (field: string, direction: 'asc' | 'desc') => void;
732
+ }
733
+ /**
734
+ * Hook for accessing a query singleton by name
735
+ *
736
+ * @param query - Query singleton name (e.g., "@TaskQuery")
737
+ * @returns Query singleton state or null if no query provided
738
+ *
739
+ * @example
740
+ * ```tsx
741
+ * const queryState = useQuerySingleton('@TaskQuery');
742
+ *
743
+ * // Use search state
744
+ * queryState?.search
745
+ * queryState?.setSearch('new search term')
746
+ * ```
747
+ */
748
+ declare function useQuerySingleton(query?: string): QuerySingletonState | null;
749
+ /**
750
+ * Parse a query binding string to extract the query singleton name
751
+ *
752
+ * @param binding - Binding string like "@TaskQuery.search" or "@TaskQuery"
753
+ * @returns Object with query name and optional field path
754
+ *
755
+ * @example
756
+ * ```tsx
757
+ * parseQueryBinding('@TaskQuery.search')
758
+ * // { query: 'TaskQuery', field: 'search' }
759
+ *
760
+ * parseQueryBinding('@TaskQuery')
761
+ * // { query: 'TaskQuery', field: undefined }
762
+ * ```
763
+ */
764
+ declare function parseQueryBinding(binding: string): {
765
+ query: string;
766
+ field?: string;
767
+ };
768
+
769
+ /**
770
+ * useOrbitalMutations - Event-based entity mutations via orbital events route
771
+ *
772
+ * This hook provides entity mutations that go through the orbital events route
773
+ * instead of direct CRUD API calls. This ensures all mutations:
774
+ * 1. Go through trait state machines
775
+ * 2. Enforce guards
776
+ * 3. Execute all trait effects (including persist)
777
+ *
778
+ * This is the Phase 7 replacement for direct CRUD mutations.
779
+ *
780
+ * @example
781
+ * ```tsx
782
+ * const { createEntity, updateEntity, deleteEntity } = useOrbitalMutations('Task', 'TaskManager');
783
+ *
784
+ * // Create - sends ENTITY_CREATE event to orbital
785
+ * await createEntity({ title: 'New Task', status: 'pending' });
786
+ *
787
+ * // Update - sends ENTITY_UPDATE event to orbital
788
+ * await updateEntity(taskId, { status: 'completed' });
789
+ *
790
+ * // Delete - sends ENTITY_DELETE event to orbital
791
+ * await deleteEntity(taskId);
792
+ * ```
793
+ *
794
+ * @packageDocumentation
795
+ */
796
+ /**
797
+ * Standard events for entity mutations
798
+ * These are handled by orbitals with CRUD-capable traits
799
+ */
800
+ declare const ENTITY_EVENTS: {
801
+ readonly CREATE: "ENTITY_CREATE";
802
+ readonly UPDATE: "ENTITY_UPDATE";
803
+ readonly DELETE: "ENTITY_DELETE";
804
+ };
805
+ interface OrbitalEventPayload {
806
+ event: string;
807
+ payload?: Record<string, unknown>;
808
+ entityId?: string;
809
+ }
810
+ interface OrbitalEventResponse {
811
+ success: boolean;
812
+ transitioned: boolean;
813
+ states: Record<string, string>;
814
+ emittedEvents: Array<{
815
+ event: string;
816
+ payload?: unknown;
817
+ }>;
818
+ error?: string;
819
+ }
820
+ /**
821
+ * Hook for event-based entity mutations via orbital events route
822
+ *
823
+ * @param entityName - The entity type name (for cache invalidation)
824
+ * @param orbitalName - The orbital to send events to
825
+ * @param options - Optional configuration
826
+ */
827
+ declare function useOrbitalMutations(entityName: string, orbitalName: string, options?: {
828
+ /** Custom event names for create/update/delete */
829
+ events?: {
830
+ create?: string;
831
+ update?: string;
832
+ delete?: string;
833
+ };
834
+ /** Enable debug logging */
835
+ debug?: boolean;
836
+ }): {
837
+ createEntity: (data: Record<string, unknown>) => Promise<OrbitalEventResponse>;
838
+ updateEntity: (id: string | undefined, data: Record<string, unknown>) => Promise<OrbitalEventResponse | undefined>;
839
+ deleteEntity: (id: string | undefined) => Promise<OrbitalEventResponse | undefined>;
840
+ createMutation: _tanstack_react_query.UseMutationResult<OrbitalEventResponse, Error, Record<string, unknown>, unknown>;
841
+ updateMutation: _tanstack_react_query.UseMutationResult<OrbitalEventResponse, Error, {
842
+ id: string;
843
+ data: Record<string, unknown>;
844
+ }, unknown>;
845
+ deleteMutation: _tanstack_react_query.UseMutationResult<OrbitalEventResponse, Error, string, unknown>;
846
+ isCreating: boolean;
847
+ isUpdating: boolean;
848
+ isDeleting: boolean;
849
+ isMutating: boolean;
850
+ createError: Error | null;
851
+ updateError: Error | null;
852
+ deleteError: Error | null;
853
+ };
854
+ /**
855
+ * Send a custom event to an orbital
856
+ * For non-CRUD operations that go through trait state machines
857
+ */
858
+ declare function useSendOrbitalEvent(orbitalName: string): {
859
+ sendEvent: (event: string, payload?: Record<string, unknown>, entityId?: string) => Promise<OrbitalEventResponse>;
860
+ isPending: boolean;
861
+ error: Error | null;
862
+ data: OrbitalEventResponse | undefined;
863
+ };
864
+
865
+ interface EntityMutationResult {
866
+ id: string;
867
+ [key: string]: unknown;
868
+ }
869
+ /**
870
+ * Hook for creating entities
871
+ */
872
+ declare function useCreateEntity(entityName: string): _tanstack_react_query.UseMutationResult<EntityMutationResult, Error, Record<string, unknown>, unknown>;
873
+ /**
874
+ * Hook for updating entities
875
+ */
876
+ declare function useUpdateEntity(entityName: string): _tanstack_react_query.UseMutationResult<EntityMutationResult, Error, {
877
+ id: string;
878
+ data: Record<string, unknown>;
879
+ }, unknown>;
880
+ /**
881
+ * Hook for deleting entities
882
+ */
883
+ declare function useDeleteEntity(entityName: string): _tanstack_react_query.UseMutationResult<{
884
+ id: string;
885
+ }, Error, string, unknown>;
886
+ interface UseEntityMutationsOptions {
887
+ /**
888
+ * If provided, mutations go through orbital events route instead of direct CRUD.
889
+ * This is the recommended approach for Phase 7+ compliance.
890
+ */
891
+ orbitalName?: string;
892
+ /**
893
+ * Custom event names when using orbital-based mutations
894
+ */
895
+ events?: {
896
+ create?: string;
897
+ update?: string;
898
+ delete?: string;
899
+ };
900
+ }
901
+ /**
902
+ * Combined hook that provides all entity mutations
903
+ * Used by trait hooks for persist_data effects
904
+ *
905
+ * @param entityName - The entity type name
906
+ * @param options - Optional configuration including orbital-based mutations
907
+ *
908
+ * @deprecated For new code, prefer useOrbitalMutations directly
909
+ */
910
+ declare function useEntityMutations(entityName: string, options?: UseEntityMutationsOptions): {
911
+ createEntity: (entityOrData: string | Record<string, unknown>, data?: Record<string, unknown>) => Promise<OrbitalEventResponse | EntityMutationResult | undefined>;
912
+ updateEntity: (id: string | undefined, data: Record<string, unknown>) => Promise<OrbitalEventResponse | EntityMutationResult | undefined>;
913
+ deleteEntity: (id: string | undefined) => Promise<OrbitalEventResponse | {
914
+ id: string;
915
+ } | undefined>;
916
+ isCreating: boolean;
917
+ isUpdating: boolean;
918
+ isDeleting: boolean;
919
+ createError: Error | null;
920
+ updateError: Error | null;
921
+ deleteError: Error | null;
922
+ };
923
+
924
+ /**
925
+ * useEntities Hook
926
+ *
927
+ * React hook to access the entity store.
928
+ * Uses useSyncExternalStore for efficient updates.
929
+ */
930
+
931
+ /**
932
+ * Hook to access all entities
933
+ */
934
+ declare function useEntities(): {
935
+ entities: Map<string, Entity>;
936
+ getEntity: typeof getEntity;
937
+ getByType: typeof getByType;
938
+ getAllEntities: typeof getAllEntities;
939
+ getSingleton: typeof getSingleton;
940
+ spawnEntity: typeof spawnEntity;
941
+ updateEntity: typeof updateEntity;
942
+ updateSingleton: typeof updateSingleton;
943
+ removeEntity: typeof removeEntity;
944
+ clearEntities: typeof clearEntities;
945
+ };
946
+ /**
947
+ * Hook to access a specific entity by ID
948
+ */
949
+ declare function useEntity(id: string): Entity | undefined;
950
+ /**
951
+ * Hook to access entities of a specific type
952
+ */
953
+ declare function useEntitiesByType(type: string): Entity[];
954
+ /**
955
+ * Hook to access a singleton entity by type
956
+ */
957
+ declare function useSingletonEntity<T extends Entity = Entity>(type: string): T | undefined;
958
+ /**
959
+ * Hook for Player entity (convenience)
960
+ */
961
+ declare function usePlayer(): {
962
+ player: Entity | undefined;
963
+ updatePlayer: (updates: Partial<Entity>) => void;
964
+ };
965
+ /**
966
+ * Hook for Physics entity (convenience)
967
+ */
968
+ declare function usePhysics(): {
969
+ physics: Entity | undefined;
970
+ updatePhysics: (updates: Partial<Entity>) => void;
971
+ };
972
+ /**
973
+ * Hook for Input entity (convenience)
974
+ */
975
+ declare function useInput(): {
976
+ input: Entity | undefined;
977
+ updateInput: (updates: Partial<Entity>) => void;
978
+ };
979
+
980
+ /**
981
+ * Auth Context Hook Stub
982
+ *
983
+ * Provides a placeholder auth context for the design system.
984
+ * Applications should provide their own AuthContext provider
985
+ * that implements this interface.
986
+ */
987
+ interface AuthUser {
988
+ uid: string;
989
+ email: string | null;
990
+ displayName: string | null;
991
+ photoURL: string | null;
992
+ }
993
+ interface AuthContextValue {
994
+ user: AuthUser | null;
995
+ loading: boolean;
996
+ signIn?: () => Promise<void>;
997
+ signOut?: () => Promise<void>;
998
+ }
999
+ /**
1000
+ * Stub hook that returns empty auth context.
1001
+ * Applications should wrap their app with an AuthProvider
1002
+ * that supplies real auth state.
1003
+ */
1004
+ declare function useAuthContext(): AuthContextValue;
1005
+
1006
+ export { type AuthContextValue, type AuthUser, type ChangeSummary, type CompileResult, type CompileStage, ENTITY_EVENTS, Entity, type EntityDataRecord, type EntityMutationResult, EventBusContextType, EventListener, type Extension, type ExtensionManifest, type FileSystemFile, type FileSystemStatus, type HistoryTimelineItem, type OpenFile, type OrbitalEventPayload, type OrbitalEventResponse, type QuerySingletonEntity, type QuerySingletonResult, type QuerySingletonState, type QueryState, type RevertResult, type SelectedFile, type UseCompileResult, type UseEntityDetailResult, type UseEntityListOptions, type UseEntityListResult, type UseEntityMutationsOptions, type UseExtensionsOptions, type UseExtensionsResult, type UseFileEditorOptions, type UseFileEditorResult, type UseFileSystemResult, type UseOrbitalHistoryOptions, type UseOrbitalHistoryResult, clearEntities, entityDataKeys, getAllEntities, getByType, getEntity, getSingleton, parseQueryBinding, removeEntity, spawnEntity, updateEntity, updateSingleton, useAgentChat, useAuthContext, useCompile, useCreateEntity, useDeepAgentGeneration, useDeleteEntity, useEmitEvent, useEntities, useEntitiesByType, useEntity$1 as useEntity, useEntity as useEntityById, useEntityDetail, useEntityList, useEntityMutations, useEventBus, useEventListener, useExtensions, useFileEditor, useFileSystem, useInput, useOrbitalHistory, useOrbitalMutations, usePhysics, usePlayer, usePreview, useQuerySingleton, useSelectedEntity, useSendOrbitalEvent, useSingletonEntity, useUIEvents, useUpdateEntity, useValidation };