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