@almadar/ui 4.44.0 → 4.45.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/avl/index.cjs +193 -164
- package/dist/avl/index.js +194 -165
- package/dist/components/index.cjs +104 -63
- package/dist/components/index.js +105 -64
- package/dist/components/organisms/game/three/index.cjs +18 -15
- package/dist/components/organisms/game/three/index.js +18 -15
- package/dist/context/index.cjs +17 -12
- package/dist/context/index.js +17 -12
- package/dist/docs/index.cjs +2 -2
- package/dist/docs/index.js +2 -2
- package/dist/hooks/index.cjs +52 -40
- package/dist/hooks/index.js +52 -40
- package/dist/lib/debug.d.ts +15 -22
- package/dist/lib/index.cjs +61 -47
- package/dist/lib/index.js +62 -48
- package/dist/marketing/index.cjs +2 -2
- package/dist/marketing/index.js +2 -2
- package/dist/providers/EventBusProvider.d.ts +6 -2
- package/dist/providers/index.cjs +112 -89
- package/dist/providers/index.js +112 -89
- package/dist/renderer/index.cjs +57 -56
- package/dist/renderer/index.js +57 -56
- package/dist/runtime/index.cjs +122 -94
- package/dist/runtime/index.js +123 -95
- package/package.json +3 -3
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var providers = require('@almadar/ui/providers');
|
|
5
4
|
var logger = require('@almadar/logger');
|
|
5
|
+
var providers = require('@almadar/ui/providers');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
|
|
8
|
+
var log = logger.createLogger("almadar:ui:orbital-history");
|
|
8
9
|
function useOrbitalHistory(options) {
|
|
9
10
|
const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
|
|
10
11
|
const getHeaders = react.useCallback(() => {
|
|
@@ -66,7 +67,7 @@ function useOrbitalHistory(options) {
|
|
|
66
67
|
setCurrentVersion(mergedTimeline[0].version);
|
|
67
68
|
}
|
|
68
69
|
} catch (err) {
|
|
69
|
-
|
|
70
|
+
log.error("Failed to load history", { error: err instanceof Error ? err : String(err) });
|
|
70
71
|
setError(err instanceof Error ? err.message : "Failed to load history");
|
|
71
72
|
} finally {
|
|
72
73
|
setIsLoading(false);
|
|
@@ -99,7 +100,7 @@ function useOrbitalHistory(options) {
|
|
|
99
100
|
error: data.error || "Unknown error during revert"
|
|
100
101
|
};
|
|
101
102
|
} catch (err) {
|
|
102
|
-
|
|
103
|
+
log.error("Failed to revert", { error: err instanceof Error ? err : String(err) });
|
|
103
104
|
return {
|
|
104
105
|
success: false,
|
|
105
106
|
error: err instanceof Error ? err.message : "Failed to revert"
|
|
@@ -123,6 +124,7 @@ function useOrbitalHistory(options) {
|
|
|
123
124
|
refresh
|
|
124
125
|
};
|
|
125
126
|
}
|
|
127
|
+
var log2 = logger.createLogger("almadar:ui:filesystem");
|
|
126
128
|
function useFileSystem() {
|
|
127
129
|
const [status, setStatus] = react.useState("idle");
|
|
128
130
|
const [error, setError] = react.useState(null);
|
|
@@ -137,7 +139,7 @@ function useFileSystem() {
|
|
|
137
139
|
setError(null);
|
|
138
140
|
setIsLoading(true);
|
|
139
141
|
try {
|
|
140
|
-
|
|
142
|
+
log2.debug("Booting WebContainer");
|
|
141
143
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
142
144
|
setStatus("ready");
|
|
143
145
|
} catch (err) {
|
|
@@ -200,7 +202,7 @@ function useFileSystem() {
|
|
|
200
202
|
setFiles(newTree);
|
|
201
203
|
setStatus("running");
|
|
202
204
|
} catch (err) {
|
|
203
|
-
|
|
205
|
+
log2.error("Failed to mount files", { error: err instanceof Error ? err : String(err) });
|
|
204
206
|
} finally {
|
|
205
207
|
setIsLoading(false);
|
|
206
208
|
}
|
|
@@ -241,7 +243,7 @@ function useFileSystem() {
|
|
|
241
243
|
const path = contentArg !== void 0 ? pathOrContent : selectedPath;
|
|
242
244
|
const content = contentArg !== void 0 ? contentArg : pathOrContent;
|
|
243
245
|
if (!path) {
|
|
244
|
-
|
|
246
|
+
log2.warn("updateContent called without path and no file selected");
|
|
245
247
|
return;
|
|
246
248
|
}
|
|
247
249
|
setFileContents((prev) => {
|
|
@@ -257,14 +259,14 @@ function useFileSystem() {
|
|
|
257
259
|
setSelectedFile((prev) => prev ? { ...prev, content, isDirty: true } : null);
|
|
258
260
|
}, []);
|
|
259
261
|
const refreshTree = react.useCallback(async () => {
|
|
260
|
-
|
|
262
|
+
log2.debug("Refreshing tree");
|
|
261
263
|
}, []);
|
|
262
264
|
const runCommand = react.useCallback(async (command) => {
|
|
263
|
-
|
|
265
|
+
log2.debug("Running command", { command });
|
|
264
266
|
return { exitCode: 0, output: "" };
|
|
265
267
|
}, []);
|
|
266
268
|
const startDevServer = react.useCallback(async () => {
|
|
267
|
-
|
|
269
|
+
log2.debug("Starting dev server");
|
|
268
270
|
setPreviewUrl("http://localhost:5173");
|
|
269
271
|
}, []);
|
|
270
272
|
return {
|
|
@@ -287,6 +289,7 @@ function useFileSystem() {
|
|
|
287
289
|
startDevServer
|
|
288
290
|
};
|
|
289
291
|
}
|
|
292
|
+
var log3 = logger.createLogger("almadar:ui:extensions");
|
|
290
293
|
var defaultManifest = {
|
|
291
294
|
languages: {
|
|
292
295
|
typescript: { extensions: [".ts", ".tsx"], icon: "ts", color: "#3178c6" },
|
|
@@ -305,7 +308,7 @@ function useExtensions(options) {
|
|
|
305
308
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
306
309
|
const [error, setError] = react.useState(null);
|
|
307
310
|
const loadExtension = react.useCallback(async (extensionId) => {
|
|
308
|
-
|
|
311
|
+
log3.debug("Loading extension", { extensionId });
|
|
309
312
|
}, []);
|
|
310
313
|
const loadExtensions = react.useCallback(async () => {
|
|
311
314
|
setIsLoading(true);
|
|
@@ -377,6 +380,7 @@ function useExtensions(options) {
|
|
|
377
380
|
getExtensionForFile
|
|
378
381
|
};
|
|
379
382
|
}
|
|
383
|
+
var log4 = logger.createLogger("almadar:ui:file-editor");
|
|
380
384
|
function useFileEditor(options) {
|
|
381
385
|
const { extensions, fileSystem, onSchemaUpdate } = options;
|
|
382
386
|
const [openFiles, setOpenFiles] = react.useState([]);
|
|
@@ -401,7 +405,7 @@ function useFileEditor(options) {
|
|
|
401
405
|
setOpenFiles((prev) => [...prev, newFile]);
|
|
402
406
|
setActiveFilePath(path);
|
|
403
407
|
} catch (err) {
|
|
404
|
-
|
|
408
|
+
log4.error("Failed to open file", { error: err instanceof Error ? err : String(err) });
|
|
405
409
|
}
|
|
406
410
|
}, [openFiles, fileSystem, extensions]);
|
|
407
411
|
const closeFile = react.useCallback((path) => {
|
|
@@ -462,7 +466,7 @@ function useFileEditor(options) {
|
|
|
462
466
|
}
|
|
463
467
|
}
|
|
464
468
|
} catch (err) {
|
|
465
|
-
|
|
469
|
+
log4.error("Failed to save file", { error: err instanceof Error ? err : String(err) });
|
|
466
470
|
} finally {
|
|
467
471
|
setIsSaving(false);
|
|
468
472
|
}
|
|
@@ -491,6 +495,7 @@ function useFileEditor(options) {
|
|
|
491
495
|
saveAllFiles
|
|
492
496
|
};
|
|
493
497
|
}
|
|
498
|
+
var log5 = logger.createLogger("almadar:ui:compile");
|
|
494
499
|
function useCompile() {
|
|
495
500
|
const [isCompiling, setIsCompiling] = react.useState(false);
|
|
496
501
|
const [stage, setStage] = react.useState("idle");
|
|
@@ -501,7 +506,7 @@ function useCompile() {
|
|
|
501
506
|
setStage("compiling");
|
|
502
507
|
setError(null);
|
|
503
508
|
try {
|
|
504
|
-
|
|
509
|
+
log5.debug("Compiling schema", { name: schema.name });
|
|
505
510
|
const result = {
|
|
506
511
|
success: true,
|
|
507
512
|
files: []
|
|
@@ -527,6 +532,7 @@ function useCompile() {
|
|
|
527
532
|
compileSchema
|
|
528
533
|
};
|
|
529
534
|
}
|
|
535
|
+
var log6 = logger.createLogger("almadar:ui:preview");
|
|
530
536
|
function usePreview(options) {
|
|
531
537
|
const [previewUrl, setPreviewUrl] = react.useState(null);
|
|
532
538
|
const [isLoading, setIsLoading] = react.useState(!!options?.appId);
|
|
@@ -560,17 +566,17 @@ function usePreview(options) {
|
|
|
560
566
|
setIsLoading(false);
|
|
561
567
|
return;
|
|
562
568
|
}
|
|
563
|
-
|
|
569
|
+
log6.debug("Setting up preview for app", { appId });
|
|
564
570
|
setPreviewUrl(`/api/orbitals/${appId}`);
|
|
565
571
|
setIsLoading(false);
|
|
566
572
|
}, [options?.appId]);
|
|
567
573
|
const startPreview = react.useCallback(async () => {
|
|
568
|
-
|
|
574
|
+
log6.debug("startPreview called");
|
|
569
575
|
}, []);
|
|
570
576
|
const stopPreview = react.useCallback(async () => {
|
|
571
577
|
setIsLoading(true);
|
|
572
578
|
try {
|
|
573
|
-
|
|
579
|
+
log6.debug("Stopping preview server");
|
|
574
580
|
setPreviewUrl(null);
|
|
575
581
|
setApp(null);
|
|
576
582
|
} finally {
|
|
@@ -579,15 +585,15 @@ function usePreview(options) {
|
|
|
579
585
|
}, []);
|
|
580
586
|
const refresh = react.useCallback(async () => {
|
|
581
587
|
if (!previewUrl) return;
|
|
582
|
-
|
|
588
|
+
log6.debug("Refreshing preview");
|
|
583
589
|
setPreviewUrl(`${previewUrl.split("?")[0]}?t=${Date.now()}`);
|
|
584
590
|
}, [previewUrl]);
|
|
585
591
|
const handleRefresh = react.useCallback(async () => {
|
|
586
|
-
|
|
592
|
+
log6.debug("Handle refresh");
|
|
587
593
|
await refresh();
|
|
588
594
|
}, [refresh]);
|
|
589
595
|
const handleReset = react.useCallback(async () => {
|
|
590
|
-
|
|
596
|
+
log6.debug("Resetting preview");
|
|
591
597
|
setError(null);
|
|
592
598
|
setLoadError(null);
|
|
593
599
|
setErrorToast(null);
|
|
@@ -621,6 +627,7 @@ function usePreview(options) {
|
|
|
621
627
|
dismissErrorToast
|
|
622
628
|
};
|
|
623
629
|
}
|
|
630
|
+
var log7 = logger.createLogger("almadar:ui:agent-chat");
|
|
624
631
|
function useAgentChat(options) {
|
|
625
632
|
const [messages, setMessages] = react.useState([]);
|
|
626
633
|
const [status, setStatus] = react.useState("idle");
|
|
@@ -643,7 +650,7 @@ function useAgentChat(options) {
|
|
|
643
650
|
timestamp: Date.now()
|
|
644
651
|
};
|
|
645
652
|
setMessages((prev) => [...prev, userMessage]);
|
|
646
|
-
|
|
653
|
+
log7.debug("Sending message", { content });
|
|
647
654
|
const assistantMessage = {
|
|
648
655
|
id: (Date.now() + 1).toString(),
|
|
649
656
|
role: "assistant",
|
|
@@ -666,7 +673,7 @@ function useAgentChat(options) {
|
|
|
666
673
|
setError(null);
|
|
667
674
|
const skillName = Array.isArray(skill) ? skill[0] : skill;
|
|
668
675
|
try {
|
|
669
|
-
|
|
676
|
+
log7.debug("Starting generation", () => ({ skillName, prompt, genOptions: JSON.stringify(genOptions) }));
|
|
670
677
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
671
678
|
setStatus("complete");
|
|
672
679
|
options?.onComplete?.();
|
|
@@ -678,10 +685,10 @@ function useAgentChat(options) {
|
|
|
678
685
|
}
|
|
679
686
|
}, [options]);
|
|
680
687
|
const continueConversation = react.useCallback(async (message) => {
|
|
681
|
-
|
|
688
|
+
log7.debug("Continue conversation", { message: Array.isArray(message) ? message : [message] });
|
|
682
689
|
}, []);
|
|
683
690
|
const resumeWithDecision = react.useCallback(async (decisions) => {
|
|
684
|
-
|
|
691
|
+
log7.debug("Resume with decision", () => ({ decisions: JSON.stringify(decisions), count: decisions.length }));
|
|
685
692
|
setInterrupt(null);
|
|
686
693
|
}, []);
|
|
687
694
|
const cancel = react.useCallback(() => {
|
|
@@ -718,6 +725,7 @@ function useAgentChat(options) {
|
|
|
718
725
|
clearHistory
|
|
719
726
|
};
|
|
720
727
|
}
|
|
728
|
+
var log8 = logger.createLogger("almadar:ui:validation");
|
|
721
729
|
function useValidation() {
|
|
722
730
|
const [result, setResult] = react.useState(null);
|
|
723
731
|
const [isValidating, setIsValidating] = react.useState(false);
|
|
@@ -731,7 +739,7 @@ function useValidation() {
|
|
|
731
739
|
setStage("validating");
|
|
732
740
|
setProgressMessage("Validating schema...");
|
|
733
741
|
try {
|
|
734
|
-
|
|
742
|
+
log8.debug("Validating app", { appId });
|
|
735
743
|
const validationResult = {
|
|
736
744
|
valid: true,
|
|
737
745
|
errors: [],
|
|
@@ -784,6 +792,7 @@ function useValidation() {
|
|
|
784
792
|
reset
|
|
785
793
|
};
|
|
786
794
|
}
|
|
795
|
+
var log9 = logger.createLogger("almadar:ui:deep-agent");
|
|
787
796
|
function useDeepAgentGeneration() {
|
|
788
797
|
const [requests, setRequests] = react.useState([]);
|
|
789
798
|
const [currentRequest, setCurrentRequest] = react.useState(null);
|
|
@@ -807,7 +816,7 @@ function useDeepAgentGeneration() {
|
|
|
807
816
|
setCurrentRequest(request);
|
|
808
817
|
setRequests((prev) => [...prev, request]);
|
|
809
818
|
try {
|
|
810
|
-
|
|
819
|
+
log9.debug("Generating from prompt", { prompt });
|
|
811
820
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
812
821
|
request.status = "completed";
|
|
813
822
|
setCurrentRequest(request);
|
|
@@ -827,7 +836,7 @@ function useDeepAgentGeneration() {
|
|
|
827
836
|
}
|
|
828
837
|
}, []);
|
|
829
838
|
const startGeneration = react.useCallback(async (skill, prompt, _options) => {
|
|
830
|
-
|
|
839
|
+
log9.debug("Starting generation with skill", { skill });
|
|
831
840
|
await generate(prompt);
|
|
832
841
|
}, [generate]);
|
|
833
842
|
const cancelGeneration = react.useCallback(() => {
|
|
@@ -849,7 +858,7 @@ function useDeepAgentGeneration() {
|
|
|
849
858
|
setIsComplete(false);
|
|
850
859
|
}, []);
|
|
851
860
|
const submitInterruptDecisions = react.useCallback((decisions) => {
|
|
852
|
-
|
|
861
|
+
log9.debug("Submitting interrupt decisions", () => ({ decisions: JSON.stringify(decisions), count: decisions.length }));
|
|
853
862
|
setInterrupt(null);
|
|
854
863
|
}, []);
|
|
855
864
|
return {
|
|
@@ -868,7 +877,7 @@ function useDeepAgentGeneration() {
|
|
|
868
877
|
submitInterruptDecisions
|
|
869
878
|
};
|
|
870
879
|
}
|
|
871
|
-
var
|
|
880
|
+
var log10 = logger.createLogger("almadar:eventbus");
|
|
872
881
|
var subLog = logger.createLogger("almadar:eventbus:subscribe");
|
|
873
882
|
var scopeLog = logger.createLogger("almadar:ui:trait-scope");
|
|
874
883
|
function getGlobalEventBus() {
|
|
@@ -888,13 +897,13 @@ var fallbackEventBus = {
|
|
|
888
897
|
source
|
|
889
898
|
};
|
|
890
899
|
const handlers = fallbackListeners.get(type);
|
|
891
|
-
|
|
900
|
+
log10.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
|
|
892
901
|
if (handlers) {
|
|
893
902
|
handlers.forEach((handler) => {
|
|
894
903
|
try {
|
|
895
904
|
handler(event);
|
|
896
905
|
} catch (error) {
|
|
897
|
-
|
|
906
|
+
log10.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
|
|
898
907
|
}
|
|
899
908
|
});
|
|
900
909
|
}
|
|
@@ -902,7 +911,7 @@ var fallbackEventBus = {
|
|
|
902
911
|
try {
|
|
903
912
|
handler(event);
|
|
904
913
|
} catch (error) {
|
|
905
|
-
|
|
914
|
+
log10.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
|
|
906
915
|
}
|
|
907
916
|
});
|
|
908
917
|
},
|
|
@@ -1002,7 +1011,7 @@ function useEmitEvent() {
|
|
|
1002
1011
|
[eventBus]
|
|
1003
1012
|
);
|
|
1004
1013
|
}
|
|
1005
|
-
var
|
|
1014
|
+
var log11 = logger.createLogger("almadar:ui:ui-slots");
|
|
1006
1015
|
var DEFAULT_SOURCE_KEY = "__default__";
|
|
1007
1016
|
var MULTI_SOURCE_STACK_TRAIT = "__multi_source_stack__";
|
|
1008
1017
|
var ALL_SLOTS = [
|
|
@@ -1084,7 +1093,7 @@ function useUISlotManager() {
|
|
|
1084
1093
|
try {
|
|
1085
1094
|
callback(slot, content);
|
|
1086
1095
|
} catch (error) {
|
|
1087
|
-
|
|
1096
|
+
log11.error("Subscriber error", { error: error instanceof Error ? error : String(error) });
|
|
1088
1097
|
}
|
|
1089
1098
|
});
|
|
1090
1099
|
}, []);
|
|
@@ -1096,7 +1105,7 @@ function useUISlotManager() {
|
|
|
1096
1105
|
try {
|
|
1097
1106
|
callback(content);
|
|
1098
1107
|
} catch (error) {
|
|
1099
|
-
|
|
1108
|
+
log11.error("Trait subscriber error", { traitName, error: error instanceof Error ? error : String(error) });
|
|
1100
1109
|
}
|
|
1101
1110
|
});
|
|
1102
1111
|
},
|
|
@@ -1147,9 +1156,12 @@ function useUISlotManager() {
|
|
|
1147
1156
|
const slotSources = prev[config.target] ?? {};
|
|
1148
1157
|
const existing = slotSources[sourceKey];
|
|
1149
1158
|
if (existing && existing.priority > content.priority) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1159
|
+
log11.warn("Slot already has higher priority content", {
|
|
1160
|
+
slot: config.target,
|
|
1161
|
+
sourceKey,
|
|
1162
|
+
existingPriority: existing.priority,
|
|
1163
|
+
newPriority: content.priority
|
|
1164
|
+
});
|
|
1153
1165
|
return prev;
|
|
1154
1166
|
}
|
|
1155
1167
|
const nextSources = {
|
|
@@ -1161,7 +1173,7 @@ function useUISlotManager() {
|
|
|
1161
1173
|
indexTraitRender(content.sourceTrait, content);
|
|
1162
1174
|
notifyTraitSubscribers(content.sourceTrait, content);
|
|
1163
1175
|
}
|
|
1164
|
-
|
|
1176
|
+
log11.info("slot:written", {
|
|
1165
1177
|
slot: config.target,
|
|
1166
1178
|
sourceKey,
|
|
1167
1179
|
sourceTrait: content.sourceTrait,
|
|
@@ -1206,7 +1218,7 @@ function useUISlotManager() {
|
|
|
1206
1218
|
setSources((prev) => {
|
|
1207
1219
|
const slotSources = prev[slot];
|
|
1208
1220
|
if (!slotSources || !(sourceKey in slotSources)) {
|
|
1209
|
-
|
|
1221
|
+
log11.debug("slot:clear-noop", { slot, sourceTrait, reason: !slotSources ? "no-slot" : "no-source" });
|
|
1210
1222
|
return prev;
|
|
1211
1223
|
}
|
|
1212
1224
|
const content = slotSources[sourceKey];
|
|
@@ -1222,7 +1234,7 @@ function useUISlotManager() {
|
|
|
1222
1234
|
}
|
|
1223
1235
|
const nextSources = { ...slotSources };
|
|
1224
1236
|
delete nextSources[sourceKey];
|
|
1225
|
-
|
|
1237
|
+
log11.info("slot:cleared", { slot, sourceTrait, lastPatternType: content.pattern });
|
|
1226
1238
|
notifySubscribers(slot, aggregateSlot(nextSources));
|
|
1227
1239
|
return { ...prev, [slot]: nextSources };
|
|
1228
1240
|
});
|