@leitwerk-dev/ui 0.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/LICENSE +13 -0
- package/dist/assets/ChronicleMarkdown-BLgtHeEE.js +16 -0
- package/dist/assets/ChronicleMarkdown-D6hFzERy.css +1 -0
- package/dist/assets/FutureLaunchDetailPage-KrXSGzHM.js +1 -0
- package/dist/assets/FutureLaunchDetailPage-VPMBtpYc.css +1 -0
- package/dist/assets/GenericLauncher-Cv38FByt.js +1 -0
- package/dist/assets/GenericLauncher-D_GMtsQ5.css +1 -0
- package/dist/assets/HomePage-Cd3lEtwZ.js +1 -0
- package/dist/assets/HomePage-DYh_QHXv.css +1 -0
- package/dist/assets/PageHeader-6PdvYODN.css +1 -0
- package/dist/assets/PageHeader-D6pP4hIh.js +1 -0
- package/dist/assets/ProcessActionsMenu-1QySGNy9.js +1 -0
- package/dist/assets/ProcessActionsMenu-BT2r9vO8.css +1 -0
- package/dist/assets/ProcessDetailPage-BLuc7sjV.js +12 -0
- package/dist/assets/ProcessDetailPage-CSrjzajF.css +1 -0
- package/dist/assets/ProcessFlowDiagram-BAh_M_rb.js +2 -0
- package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +1 -0
- package/dist/assets/ProcessesPage-BcM38HMs.css +1 -0
- package/dist/assets/ProcessesPage-DtPweRU-.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-CQGvY-Rc.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-CadXN9z7.css +1 -0
- package/dist/assets/SkillsPage-B30FAFia.css +1 -0
- package/dist/assets/SkillsPage-bXuv0kEE.js +2 -0
- package/dist/assets/WatchersPage-DNyUsU1y.js +1 -0
- package/dist/assets/WatchersPage-Dnfi1zUK.css +1 -0
- package/dist/assets/api-CqECFdii.js +1 -0
- package/dist/assets/browser-storage-LbKCyf_w.js +1 -0
- package/dist/assets/dist-B7WNbObw.js +2 -0
- package/dist/assets/index-66T4Gmbl.css +1 -0
- package/dist/assets/index-C8qCggeq.js +7 -0
- package/dist/assets/index-client-BqF3_t3P.js +2 -0
- package/dist/assets/mermaid-render.worker-DAVgiVRG.js +6393 -0
- package/dist/assets/retry-config.svelte-DFKCJtCe.js +1 -0
- package/dist/assets/router.svelte-COr45o9R.js +1 -0
- package/dist/fonts/OFL-Public-Sans.txt +115 -0
- package/dist/fonts/OFL-Spectral.txt +93 -0
- package/dist/fonts/README.md +38 -0
- package/dist/fonts/fonts.css +85 -0
- package/dist/fonts/public-sans-latin-cd00287f.woff2 +0 -0
- package/dist/fonts/public-sans-latin-ext-d025d4ba.woff2 +0 -0
- package/dist/fonts/spectral-latin-89d48951.woff2 +0 -0
- package/dist/fonts/spectral-latin-b7578f14.woff2 +0 -0
- package/dist/fonts/spectral-latin-c4e0a00d.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-260738f4.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-ab18ac17.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-f58c1db3.woff2 +0 -0
- package/dist/index.html +32 -0
- package/package.json +47 -0
- package/src/App.svelte +257 -0
- package/src/chronicle/components/ChronicleActionSection.svelte +1035 -0
- package/src/chronicle/components/ChronicleExpandButton.svelte +70 -0
- package/src/chronicle/components/ChronicleFlow.svelte +289 -0
- package/src/chronicle/components/ChronicleLeafOutcomePlaceholder.svelte +44 -0
- package/src/chronicle/components/ChronicleLeafOutcomeRendererHost.svelte +408 -0
- package/src/chronicle/components/ChronicleLeafOutcomeSection.svelte +253 -0
- package/src/chronicle/components/ChronicleLiveChip.svelte +96 -0
- package/src/chronicle/components/ChronicleLiveTail.svelte +376 -0
- package/src/chronicle/components/ChronicleMarkdown.svelte +168 -0
- package/src/chronicle/components/ChronicleOperatorInputSection.svelte +41 -0
- package/src/chronicle/components/ChronicleProcessErrorSection.svelte +131 -0
- package/src/chronicle/components/ChroniclePromptSection.svelte +54 -0
- package/src/chronicle/components/ChronicleQuestionRequest.svelte +167 -0
- package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +893 -0
- package/src/chronicle/components/ChronicleRecoverySection.svelte +338 -0
- package/src/chronicle/components/ChronicleScheduledActionSection.svelte +192 -0
- package/src/chronicle/components/ChronicleSectionHeader.svelte +135 -0
- package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +138 -0
- package/src/chronicle/components/ChronicleTerminalSummary.svelte +127 -0
- package/src/chronicle/components/ChronicleThinkingSection.svelte +191 -0
- package/src/chronicle/components/ChronicleThinkingText.svelte +46 -0
- package/src/chronicle/components/ChronicleToolCallItem.svelte +477 -0
- package/src/chronicle/components/ChronicleTurnCluster.svelte +325 -0
- package/src/chronicle/components/ChronicleTurnRail.svelte +584 -0
- package/src/chronicle/components/ChronicleUsageStats.svelte +107 -0
- package/src/chronicle/components/CompactActionComposer.svelte +417 -0
- package/src/chronicle/components/ModelProfileOptions.svelte +20 -0
- package/src/chronicle/components/ProviderOptionsEditor.svelte +171 -0
- package/src/chronicle/components/RecoveryModelControl.svelte +95 -0
- package/src/chronicle/lib/action-bindings.ts +90 -0
- package/src/chronicle/lib/action-model-display.ts +133 -0
- package/src/chronicle/lib/action-preview.ts +16 -0
- package/src/chronicle/lib/chronicle-projection.ts +1342 -0
- package/src/chronicle/lib/chronicle-selectable-items.ts +352 -0
- package/src/chronicle/lib/chronicle-view-model.ts +121 -0
- package/src/chronicle/lib/formatting.ts +18 -0
- package/src/chronicle/lib/leaf-outcome-loader.ts +214 -0
- package/src/chronicle/lib/leaf-outcome-runtime.ts +37 -0
- package/src/chronicle/lib/prompt-highlighting.ts +78 -0
- package/src/chronicle/lib/scroll-sync.ts +88 -0
- package/src/chronicle/lib/tool-call-summary.ts +64 -0
- package/src/components/BrowserUiExtensionIndicatorHost.svelte +34 -0
- package/src/components/ConversationTreeDiagram.svelte +393 -0
- package/src/components/FormFieldRenderer.svelte +359 -0
- package/src/components/GenericLauncher.svelte +1970 -0
- package/src/components/KeyboardShortcutsModal.svelte +52 -0
- package/src/components/ModalShell.svelte +105 -0
- package/src/components/PageHeader.svelte +146 -0
- package/src/components/ProcessActionsMenu.svelte +514 -0
- package/src/components/ProcessInfoOverlay.svelte +1229 -0
- package/src/components/ScheduleDateTimePicker.svelte +155 -0
- package/src/components/SkillSelector.svelte +45 -0
- package/src/components/ToastContainer.svelte +192 -0
- package/src/components/launcher-form-copy.ts +172 -0
- package/src/components/launcher-model-config.ts +263 -0
- package/src/components/launcher-schedule.ts +127 -0
- package/src/extension-ui-dev-server.ts +98 -0
- package/src/lib/api.ts +970 -0
- package/src/lib/beautiful-mermaid-elk-instance.ts +54 -0
- package/src/lib/browser-storage.ts +11 -0
- package/src/lib/cost-estimates.ts +41 -0
- package/src/lib/elk-bundled-worker.ts +41 -0
- package/src/lib/flow-layout.ts +326 -0
- package/src/lib/format.ts +96 -0
- package/src/lib/future-executions-logic.ts +12 -0
- package/src/lib/future-launch-detail.ts +145 -0
- package/src/lib/instance-tree-layout.ts +158 -0
- package/src/lib/keyboard-shortcuts-help.ts +20 -0
- package/src/lib/keyboard.ts +40 -0
- package/src/lib/launcher-recent-values.ts +68 -0
- package/src/lib/markdown.ts +94 -0
- package/src/lib/mermaid-render.worker.ts +36 -0
- package/src/lib/pi-stream.ts +3 -0
- package/src/lib/primary-path-detail.ts +337 -0
- package/src/lib/primary-path-replay.ts +27 -0
- package/src/lib/process-browser.ts +179 -0
- package/src/lib/process-initial-prompt.ts +7 -0
- package/src/lib/process-launch-notices.svelte.ts +25 -0
- package/src/lib/process-row-view.ts +60 -0
- package/src/lib/process-terminal-display.ts +17 -0
- package/src/lib/process-toast-focus.svelte.ts +18 -0
- package/src/lib/processes-logic.ts +2 -0
- package/src/lib/processes.svelte.ts +334 -0
- package/src/lib/request-guard.ts +20 -0
- package/src/lib/retry-config.svelte.ts +19 -0
- package/src/lib/rich-markdown-elements.ts +173 -0
- package/src/lib/router-logic.ts +190 -0
- package/src/lib/router.svelte.ts +56 -0
- package/src/lib/runtime-config.ts +96 -0
- package/src/lib/test-fixtures.ts +13 -0
- package/src/lib/toasts.svelte.ts +104 -0
- package/src/lib/tool-call-rendering.ts +66 -0
- package/src/lib/ui-extensions.svelte.ts +381 -0
- package/src/lib/usage-snapshot.ts +9 -0
- package/src/lib/ws-classifier.ts +80 -0
- package/src/lib/ws.svelte.ts +281 -0
- package/src/main.ts +8 -0
- package/src/pages/FutureLaunchDetailPage.svelte +479 -0
- package/src/pages/HomePage.svelte +306 -0
- package/src/pages/ProcessCard.svelte +99 -0
- package/src/pages/ProcessDetailPage.svelte +599 -0
- package/src/pages/ProcessFlowDiagram.svelte +696 -0
- package/src/pages/ProcessGallery.svelte +252 -0
- package/src/pages/ProcessesPage.svelte +994 -0
- package/src/pages/SkillsPage.svelte +665 -0
- package/src/pages/WatchersPage.svelte +330 -0
- package/src/pages/process-detail/OverlayFrame.svelte +58 -0
- package/src/pages/process-detail/ProcessDetailChronicle.svelte +460 -0
- package/src/pages/process-detail/ProcessDetailHeader.svelte +167 -0
- package/src/pages/process-detail/process-detail-action-drafts.svelte.ts +211 -0
- package/src/pages/process-detail/process-detail-actions.svelte.ts +548 -0
- package/src/pages/process-detail/process-detail-chronicle-dom.ts +102 -0
- package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +711 -0
- package/src/pages/process-detail/process-detail-mutations.svelte.ts +91 -0
- package/src/pages/process-detail/process-detail-view-model.ts +149 -0
- package/src/shell/AppShell.svelte +249 -0
- package/src/shell/RouteLoadBoundary.svelte +43 -0
- package/src/shell/Sidebar.svelte +1358 -0
- package/src/shell/test-fixtures/RouteLoadTestComponent.svelte +5 -0
- package/src/vite-env.d.ts +2 -0
- package/src/vite-server-config.ts +27 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LauncherDefaultModelPreview,
|
|
3
|
+
LauncherModelConfigPreview,
|
|
4
|
+
LauncherTurnModelConfigPreview,
|
|
5
|
+
ModelProfileOptionSummary,
|
|
6
|
+
} from "../lib/api.js";
|
|
7
|
+
|
|
8
|
+
export type LauncherModelCustomizationMode =
|
|
9
|
+
| "recommended"
|
|
10
|
+
| "default_only"
|
|
11
|
+
| "turn_overrides_only"
|
|
12
|
+
| "mixed";
|
|
13
|
+
|
|
14
|
+
export type LauncherModelDisplayState =
|
|
15
|
+
| "recommended"
|
|
16
|
+
| "custom"
|
|
17
|
+
| "use_process_default"
|
|
18
|
+
| "missing";
|
|
19
|
+
|
|
20
|
+
export type LauncherModelSummaryMode = "recommended" | "adjusted";
|
|
21
|
+
|
|
22
|
+
export interface LauncherModelCustomizationState {
|
|
23
|
+
mode: LauncherModelCustomizationMode;
|
|
24
|
+
hasCustomizations: boolean;
|
|
25
|
+
hasProcessDefault: boolean;
|
|
26
|
+
turnOverrideCount: number;
|
|
27
|
+
totalCustomizedChoices: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type LauncherModelLineSource =
|
|
31
|
+
| LauncherDefaultModelPreview["source"]
|
|
32
|
+
| LauncherTurnModelConfigPreview["effective"]["source"];
|
|
33
|
+
|
|
34
|
+
export interface LauncherModelDisplayLine {
|
|
35
|
+
kind: "default" | "turn";
|
|
36
|
+
label: string;
|
|
37
|
+
turnId: string | null;
|
|
38
|
+
state: LauncherModelDisplayState;
|
|
39
|
+
source: LauncherModelLineSource;
|
|
40
|
+
profile: ModelProfileOptionSummary | null;
|
|
41
|
+
modelName: string | null;
|
|
42
|
+
statusLabel: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface LauncherModelSummaryTurn {
|
|
46
|
+
turnId: string;
|
|
47
|
+
label: string;
|
|
48
|
+
source: LauncherTurnModelConfigPreview["effective"]["source"];
|
|
49
|
+
profile: ModelProfileOptionSummary | null;
|
|
50
|
+
modelName: string | null;
|
|
51
|
+
isAdjusted: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface LauncherModelSummaryView {
|
|
55
|
+
mode: LauncherModelSummaryMode;
|
|
56
|
+
statusLabel: string;
|
|
57
|
+
turns: LauncherModelSummaryTurn[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function countTurnModelOverrides(values: Record<string, string>): number {
|
|
61
|
+
return Object.values(values).filter((value) => value.trim() !== "").length;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getLauncherModelCustomizationState(input: {
|
|
65
|
+
defaultModelProfileId: string;
|
|
66
|
+
turnModelProfileIds: Record<string, string>;
|
|
67
|
+
}): LauncherModelCustomizationState {
|
|
68
|
+
const hasProcessDefault = input.defaultModelProfileId.trim() !== "";
|
|
69
|
+
const turnOverrideCount = countTurnModelOverrides(input.turnModelProfileIds);
|
|
70
|
+
const totalCustomizedChoices = turnOverrideCount + (hasProcessDefault ? 1 : 0);
|
|
71
|
+
|
|
72
|
+
let mode: LauncherModelCustomizationMode = "recommended";
|
|
73
|
+
if (hasProcessDefault && turnOverrideCount > 0) {
|
|
74
|
+
mode = "mixed";
|
|
75
|
+
} else if (hasProcessDefault) {
|
|
76
|
+
mode = "default_only";
|
|
77
|
+
} else if (turnOverrideCount > 0) {
|
|
78
|
+
mode = "turn_overrides_only";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
mode,
|
|
83
|
+
hasCustomizations: totalCustomizedChoices > 0,
|
|
84
|
+
hasProcessDefault,
|
|
85
|
+
turnOverrideCount,
|
|
86
|
+
totalCustomizedChoices,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isAdjustedTurnSource(
|
|
91
|
+
source: LauncherTurnModelConfigPreview["effective"]["source"],
|
|
92
|
+
): boolean {
|
|
93
|
+
return source === "instance_turn_config";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function getDefaultModelBlankOptionLabel(
|
|
97
|
+
recommendedProfile: ModelProfileOptionSummary | null | undefined,
|
|
98
|
+
): string {
|
|
99
|
+
const modelName = getModelDisplayName(recommendedProfile);
|
|
100
|
+
return modelName ? `Recommended (${modelName})` : "Recommended";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function getDefaultModelSelectableProfiles(input: {
|
|
104
|
+
availableProfiles: readonly ModelProfileOptionSummary[];
|
|
105
|
+
recommendedProfile: ModelProfileOptionSummary | null | undefined;
|
|
106
|
+
}): readonly ModelProfileOptionSummary[] {
|
|
107
|
+
const recommendedProfileId = input.recommendedProfile?.id.trim() ?? "";
|
|
108
|
+
if (recommendedProfileId === "") {
|
|
109
|
+
return input.availableProfiles;
|
|
110
|
+
}
|
|
111
|
+
return input.availableProfiles.filter((option) => option.id !== recommendedProfileId);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function getTurnModelBlankOptionLabel(): string {
|
|
115
|
+
return "Use process default";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getModelDisplayName(profile: ModelProfileOptionSummary | null | undefined): string | null {
|
|
119
|
+
if (!profile) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const preferredValue = profile.id.trim();
|
|
123
|
+
if (preferredValue !== "") {
|
|
124
|
+
return preferredValue;
|
|
125
|
+
}
|
|
126
|
+
const fallbackValue = profile.label.trim();
|
|
127
|
+
return fallbackValue !== "" ? fallbackValue : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function isTurnUsingProcessDefault(source: LauncherModelLineSource): boolean {
|
|
131
|
+
return source === "instance_default" || source === "process_config_default";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isRecommendedTurnSource(source: LauncherModelLineSource): boolean {
|
|
135
|
+
return source === "process_config_turn" || source === "catalog_default";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function formatLauncherModelSummaryStatus(mode: LauncherModelSummaryMode): string {
|
|
139
|
+
return mode === "adjusted" ? "Uses adjusted models" : "Use recommended models";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function formatLauncherModelDisplayValue(line: LauncherModelDisplayLine): string {
|
|
143
|
+
if (line.kind === "default") {
|
|
144
|
+
switch (line.source) {
|
|
145
|
+
case "instance_default":
|
|
146
|
+
return `Custom for this launch (${line.modelName ?? "unknown model"})`;
|
|
147
|
+
case "process_config_default":
|
|
148
|
+
return `Process default (${line.modelName ?? "unknown model"})`;
|
|
149
|
+
case "catalog_default":
|
|
150
|
+
return `Recommended (${line.modelName ?? "unknown model"})`;
|
|
151
|
+
default:
|
|
152
|
+
return "No model available";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
switch (line.source) {
|
|
157
|
+
case "instance_turn_config":
|
|
158
|
+
return `Custom (${line.modelName ?? "unknown model"})`;
|
|
159
|
+
case "instance_default":
|
|
160
|
+
case "process_config_default":
|
|
161
|
+
return "Use process default";
|
|
162
|
+
case "process_config_turn":
|
|
163
|
+
case "catalog_default":
|
|
164
|
+
return `Recommended (${line.modelName ?? "unknown model"})`;
|
|
165
|
+
default:
|
|
166
|
+
return "No model available";
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function describeDefaultModelDisplayLine(
|
|
171
|
+
preview: LauncherDefaultModelPreview | null,
|
|
172
|
+
): LauncherModelDisplayLine {
|
|
173
|
+
const source = preview?.source ?? "none";
|
|
174
|
+
const profile = preview?.profile ?? null;
|
|
175
|
+
if (!profile) {
|
|
176
|
+
return {
|
|
177
|
+
kind: "default",
|
|
178
|
+
label: "Default model",
|
|
179
|
+
turnId: null,
|
|
180
|
+
state: "missing",
|
|
181
|
+
source,
|
|
182
|
+
profile: null,
|
|
183
|
+
modelName: null,
|
|
184
|
+
statusLabel: "No model available",
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const state = source === "instance_default" ? "custom" : "recommended";
|
|
188
|
+
const line: LauncherModelDisplayLine = {
|
|
189
|
+
kind: "default",
|
|
190
|
+
label: "Default model",
|
|
191
|
+
turnId: null,
|
|
192
|
+
state,
|
|
193
|
+
source,
|
|
194
|
+
profile,
|
|
195
|
+
modelName: getModelDisplayName(profile),
|
|
196
|
+
statusLabel: "",
|
|
197
|
+
};
|
|
198
|
+
return { ...line, statusLabel: formatLauncherModelDisplayValue(line) };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function describeTurnModelDisplayLine(input: {
|
|
202
|
+
turnId: string;
|
|
203
|
+
description: string;
|
|
204
|
+
effective: LauncherTurnModelConfigPreview["effective"] | null;
|
|
205
|
+
defaultLine: LauncherModelDisplayLine;
|
|
206
|
+
}): LauncherModelDisplayLine {
|
|
207
|
+
const source = input.effective?.source ?? "none";
|
|
208
|
+
const profile = input.effective?.profile ?? null;
|
|
209
|
+
if (!profile) {
|
|
210
|
+
return {
|
|
211
|
+
kind: "turn",
|
|
212
|
+
label: input.description,
|
|
213
|
+
turnId: input.turnId,
|
|
214
|
+
state: "missing",
|
|
215
|
+
source,
|
|
216
|
+
profile: null,
|
|
217
|
+
modelName: null,
|
|
218
|
+
statusLabel: "No model available",
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let state: LauncherModelDisplayState;
|
|
223
|
+
if (source === "instance_turn_config") {
|
|
224
|
+
state = "custom";
|
|
225
|
+
} else if (isTurnUsingProcessDefault(source)) {
|
|
226
|
+
state = "use_process_default";
|
|
227
|
+
} else if (isRecommendedTurnSource(source)) {
|
|
228
|
+
state = "recommended";
|
|
229
|
+
} else {
|
|
230
|
+
state = "missing";
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const line: LauncherModelDisplayLine = {
|
|
234
|
+
kind: "turn",
|
|
235
|
+
label: input.description,
|
|
236
|
+
turnId: input.turnId,
|
|
237
|
+
state,
|
|
238
|
+
source,
|
|
239
|
+
profile,
|
|
240
|
+
modelName: getModelDisplayName(profile),
|
|
241
|
+
statusLabel: "",
|
|
242
|
+
};
|
|
243
|
+
return { ...line, statusLabel: formatLauncherModelDisplayValue(line) };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function buildLauncherModelSummaryView(input: {
|
|
247
|
+
preview: LauncherModelConfigPreview | null;
|
|
248
|
+
hasCustomizations: boolean;
|
|
249
|
+
}): LauncherModelSummaryView {
|
|
250
|
+
const mode: LauncherModelSummaryMode = input.hasCustomizations ? "adjusted" : "recommended";
|
|
251
|
+
return {
|
|
252
|
+
mode,
|
|
253
|
+
statusLabel: formatLauncherModelSummaryStatus(mode),
|
|
254
|
+
turns: (input.preview?.turns ?? []).map((turn) => ({
|
|
255
|
+
turnId: turn.turnId,
|
|
256
|
+
label: turn.description,
|
|
257
|
+
source: turn.effective.source,
|
|
258
|
+
profile: turn.effective.profile,
|
|
259
|
+
modelName: getModelDisplayName(turn.effective.profile),
|
|
260
|
+
isAdjusted: isAdjustedTurnSource(turn.effective.source),
|
|
261
|
+
})),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export interface LauncherScheduleDateTimeParts {
|
|
2
|
+
date: string;
|
|
3
|
+
time: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface LauncherScheduleTimeParts {
|
|
7
|
+
hour: string;
|
|
8
|
+
minute: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface LauncherScheduleOption {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function padScheduleNumber(value: number): string {
|
|
17
|
+
return String(value).padStart(2, "0");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buildLauncherScheduleHourOptions(): LauncherScheduleOption[] {
|
|
21
|
+
return Array.from({ length: 24 }, (_, index) => {
|
|
22
|
+
const value = padScheduleNumber(index);
|
|
23
|
+
return { value, label: value };
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function buildLauncherScheduleMinuteOptions(stepMinutes = 1): LauncherScheduleOption[] {
|
|
28
|
+
if (
|
|
29
|
+
!Number.isInteger(stepMinutes) ||
|
|
30
|
+
stepMinutes < 1 ||
|
|
31
|
+
stepMinutes > 60 ||
|
|
32
|
+
60 % stepMinutes !== 0
|
|
33
|
+
) {
|
|
34
|
+
throw new Error("stepMinutes must evenly divide 60");
|
|
35
|
+
}
|
|
36
|
+
return Array.from({ length: 60 / stepMinutes }, (_, index) => {
|
|
37
|
+
const value = padScheduleNumber(index * stepMinutes);
|
|
38
|
+
return { value, label: value };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function splitLauncherScheduleTimeString(value: string): LauncherScheduleTimeParts {
|
|
43
|
+
const match = /^(\d{2}):(\d{2})$/.exec(value.trim());
|
|
44
|
+
if (!match) {
|
|
45
|
+
return { hour: "", minute: "" };
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
hour: match[1],
|
|
49
|
+
minute: match[2],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function buildLauncherScheduleTimeString(input: Partial<LauncherScheduleTimeParts>): string {
|
|
54
|
+
const hour = typeof input.hour === "string" ? input.hour.trim() : "";
|
|
55
|
+
const minute = typeof input.minute === "string" ? input.minute.trim() : "";
|
|
56
|
+
return /^\d{2}$/.test(hour) && /^\d{2}$/.test(minute) ? `${hour}:${minute}` : "";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function dateToLocalScheduleDateTimeParts(date: Date): LauncherScheduleDateTimeParts {
|
|
60
|
+
const year = date.getFullYear();
|
|
61
|
+
const month = padScheduleNumber(date.getMonth() + 1);
|
|
62
|
+
const day = padScheduleNumber(date.getDate());
|
|
63
|
+
const hours = padScheduleNumber(date.getHours());
|
|
64
|
+
const minutes = padScheduleNumber(date.getMinutes());
|
|
65
|
+
return {
|
|
66
|
+
date: `${year}-${month}-${day}`,
|
|
67
|
+
time: `${hours}:${minutes}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function currentLocalScheduleDateTimeParts(): LauncherScheduleDateTimeParts {
|
|
72
|
+
return dateToLocalScheduleDateTimeParts(new Date());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function isoToLocalScheduleDateTimeParts(iso: string): LauncherScheduleDateTimeParts {
|
|
76
|
+
return dateToLocalScheduleDateTimeParts(new Date(iso));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function localScheduleDateTimePartsToIso(
|
|
80
|
+
input: Partial<LauncherScheduleDateTimeParts>,
|
|
81
|
+
): string | null {
|
|
82
|
+
const dateValue = typeof input.date === "string" ? input.date.trim() : "";
|
|
83
|
+
const timeValue = typeof input.time === "string" ? input.time.trim() : "";
|
|
84
|
+
if (!dateValue || !timeValue) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const dateMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateValue);
|
|
88
|
+
const timeMatch = /^(\d{2}):(\d{2})$/.exec(timeValue);
|
|
89
|
+
if (!dateMatch || !timeMatch) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const [, yearValue, monthValue, dayValue] = dateMatch;
|
|
93
|
+
const [, hourValue, minuteValue] = timeMatch;
|
|
94
|
+
const year = Number(yearValue);
|
|
95
|
+
const month = Number(monthValue);
|
|
96
|
+
const day = Number(dayValue);
|
|
97
|
+
const hour = Number(hourValue);
|
|
98
|
+
const minute = Number(minuteValue);
|
|
99
|
+
if (
|
|
100
|
+
!Number.isInteger(year) ||
|
|
101
|
+
!Number.isInteger(month) ||
|
|
102
|
+
!Number.isInteger(day) ||
|
|
103
|
+
!Number.isInteger(hour) ||
|
|
104
|
+
!Number.isInteger(minute) ||
|
|
105
|
+
month < 1 ||
|
|
106
|
+
month > 12 ||
|
|
107
|
+
day < 1 ||
|
|
108
|
+
day > 31 ||
|
|
109
|
+
hour < 0 ||
|
|
110
|
+
hour > 23 ||
|
|
111
|
+
minute < 0 ||
|
|
112
|
+
minute > 59
|
|
113
|
+
) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const localDate = new Date(year, month - 1, day, hour, minute, 0, 0);
|
|
117
|
+
if (
|
|
118
|
+
localDate.getFullYear() !== year ||
|
|
119
|
+
localDate.getMonth() !== month - 1 ||
|
|
120
|
+
localDate.getDate() !== day ||
|
|
121
|
+
localDate.getHours() !== hour ||
|
|
122
|
+
localDate.getMinutes() !== minute
|
|
123
|
+
) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return localDate.toISOString();
|
|
127
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
const EXTENSION_MANIFEST_ID_RE = /^[A-Za-z0-9._-]+$/;
|
|
4
|
+
const DEV_UI_SOURCES_ENV = "LEITWERK_DEV_EXTENSION_UI_SOURCES_JSON";
|
|
5
|
+
|
|
6
|
+
export interface ExtensionUiDevSource {
|
|
7
|
+
extensionManifestId: string;
|
|
8
|
+
assetRootDir: string;
|
|
9
|
+
packageRootDir: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ResolvedExtensionUiDevRequest {
|
|
13
|
+
filePath: string;
|
|
14
|
+
search: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isWithinDirectory(rootDir: string, targetPath: string): boolean {
|
|
22
|
+
const relative = path.relative(rootDir, targetPath);
|
|
23
|
+
return (
|
|
24
|
+
relative === "" ||
|
|
25
|
+
(relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parseExtensionUiDevSources(raw: string | undefined): ExtensionUiDevSource[] {
|
|
30
|
+
if (!raw) return [];
|
|
31
|
+
const parsed = JSON.parse(raw) as unknown;
|
|
32
|
+
if (!Array.isArray(parsed)) {
|
|
33
|
+
throw new Error(`${DEV_UI_SOURCES_ENV} must be a JSON array`);
|
|
34
|
+
}
|
|
35
|
+
const seenIds = new Set<string>();
|
|
36
|
+
return parsed.map((value, index) => {
|
|
37
|
+
if (!isRecord(value)) {
|
|
38
|
+
throw new Error(`${DEV_UI_SOURCES_ENV}[${index}] must be an object`);
|
|
39
|
+
}
|
|
40
|
+
const { extensionManifestId, assetRootDir, packageRootDir } = value;
|
|
41
|
+
if (
|
|
42
|
+
typeof extensionManifestId !== "string" ||
|
|
43
|
+
!EXTENSION_MANIFEST_ID_RE.test(extensionManifestId)
|
|
44
|
+
) {
|
|
45
|
+
throw new Error(`${DEV_UI_SOURCES_ENV}[${index}].extensionManifestId must be URL-safe`);
|
|
46
|
+
}
|
|
47
|
+
if (seenIds.has(extensionManifestId)) {
|
|
48
|
+
throw new Error(`${DEV_UI_SOURCES_ENV} contains duplicate id '${extensionManifestId}'`);
|
|
49
|
+
}
|
|
50
|
+
if (typeof assetRootDir !== "string" || assetRootDir.trim() === "") {
|
|
51
|
+
throw new Error(`${DEV_UI_SOURCES_ENV}[${index}].assetRootDir must be a path`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof packageRootDir !== "string" || packageRootDir.trim() === "") {
|
|
54
|
+
throw new Error(`${DEV_UI_SOURCES_ENV}[${index}].packageRootDir must be a path`);
|
|
55
|
+
}
|
|
56
|
+
seenIds.add(extensionManifestId);
|
|
57
|
+
return {
|
|
58
|
+
extensionManifestId,
|
|
59
|
+
assetRootDir: path.resolve(assetRootDir),
|
|
60
|
+
packageRootDir: path.resolve(packageRootDir),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function resolveExtensionUiDevRequest(
|
|
66
|
+
rawUrl: string,
|
|
67
|
+
sources: readonly ExtensionUiDevSource[],
|
|
68
|
+
): ResolvedExtensionUiDevRequest | null {
|
|
69
|
+
let url: URL;
|
|
70
|
+
try {
|
|
71
|
+
url = new URL(rawUrl, "http://leitwerk.local");
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const segments = url.pathname.split("/");
|
|
76
|
+
if (segments.length < 4 || segments[1] !== "ext-ui") return null;
|
|
77
|
+
|
|
78
|
+
let extensionManifestId: string;
|
|
79
|
+
let requestedPath: string;
|
|
80
|
+
try {
|
|
81
|
+
extensionManifestId = decodeURIComponent(segments[2] ?? "");
|
|
82
|
+
requestedPath = segments
|
|
83
|
+
.slice(3)
|
|
84
|
+
.map((segment) => decodeURIComponent(segment))
|
|
85
|
+
.join("/");
|
|
86
|
+
} catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (!requestedPath || requestedPath.includes("\0")) return null;
|
|
90
|
+
const source = sources.find((candidate) => candidate.extensionManifestId === extensionManifestId);
|
|
91
|
+
if (!source) return null;
|
|
92
|
+
|
|
93
|
+
const filePath = path.resolve(source.assetRootDir, requestedPath);
|
|
94
|
+
if (!isWithinDirectory(source.assetRootDir, filePath) || filePath === source.assetRootDir) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return { filePath, search: url.search };
|
|
98
|
+
}
|