@leitwerk-dev/ui 0.1.8 → 0.2.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/assets/ApiTokensPage-B15IzsLp.css +1 -0
- package/dist/assets/ApiTokensPage-ClJp9PYr.js +1 -0
- package/dist/assets/ChronicleMarkdown-lqwX9Ywa.js +16 -0
- package/dist/assets/ChronicleMarkdown-wsUF8Z75.css +1 -0
- package/dist/assets/FutureLaunchDetailPage-BOoZaG11.css +1 -0
- package/dist/assets/FutureLaunchDetailPage-Bdlgm4cJ.js +1 -0
- package/dist/assets/GenericLauncher-Bf7Eb1Rw.js +1 -0
- package/dist/assets/GenericLauncher-CExW6wei.css +1 -0
- package/dist/assets/HomePage-4Q7aqPBl.css +1 -0
- package/dist/assets/HomePage-CSkNdC4m.js +1 -0
- package/dist/assets/PageHeader-DPuQInDo.css +1 -0
- package/dist/assets/PageHeader-sphJnWL1.js +1 -0
- package/dist/assets/ProcessActionsMenu-DLMywI9c.js +1 -0
- package/dist/assets/ProcessActionsMenu-VKT7PE6z.css +1 -0
- package/dist/assets/ProcessDetailPage-Cth6A0DN.css +1 -0
- package/dist/assets/ProcessDetailPage-fvvdvO19.js +14 -0
- package/dist/assets/ProcessFlowDiagram-Dx2wheGN.js +2 -0
- package/dist/assets/ProcessesPage-uLl7LXp8.js +1 -0
- package/dist/assets/ProcessesPage-yPjjrzjg.css +1 -0
- package/dist/assets/ScheduleDateTimePicker-DmojMRxN.js +1 -0
- package/dist/assets/{ScheduleDateTimePicker-CadXN9z7.css → ScheduleDateTimePicker-uacJAkIq.css} +1 -1
- package/dist/assets/SkillsPage-CJrtt8xU.css +1 -0
- package/dist/assets/SkillsPage-CotbGUxm.js +2 -0
- package/dist/assets/WatchersPage-ByWGNJet.js +1 -0
- package/dist/assets/WatchersPage-cRBnmTAD.css +1 -0
- package/dist/assets/external-links-CX92-VRP.js +1 -0
- package/dist/assets/http-client-VpPXJwbR.js +2 -0
- package/dist/assets/index-C7zNe3je.js +6 -0
- package/dist/assets/index-DtEI5gsQ.css +1 -0
- package/dist/assets/index-client-BYQviCtQ.js +2 -0
- package/dist/assets/{mermaid-render.worker-DAVgiVRG.js → mermaid-render.worker-QW2WZpEE.js} +12 -12
- package/dist/assets/process-terminal-display-BQRQwGod.js +1 -0
- package/dist/assets/router.svelte-EEldxHlO.js +1 -0
- package/dist/index.html +8 -8
- package/package.json +8 -8
- package/src/App.svelte +41 -2
- package/src/chronicle/components/ChronicleActionSection.svelte +70 -143
- package/src/chronicle/components/ChronicleCreateIssueButton.svelte +22 -0
- package/src/chronicle/components/ChronicleEntryHeader.svelte +76 -0
- package/src/chronicle/components/ChronicleExpandButton.svelte +11 -34
- package/src/chronicle/components/ChronicleFailureMessage.svelte +41 -0
- package/src/chronicle/components/ChronicleFlow.svelte +135 -28
- package/src/chronicle/components/ChronicleLeafOutcomeRendererHost.svelte +1 -8
- package/src/chronicle/components/ChronicleLeafOutcomeSection.svelte +25 -52
- package/src/chronicle/components/ChronicleLiveChip.svelte +1 -35
- package/src/chronicle/components/ChronicleLiveTail.svelte +55 -154
- package/src/chronicle/components/ChronicleMarkdown.svelte +6 -6
- package/src/chronicle/components/ChronicleOperatorInputSection.svelte +5 -18
- package/src/chronicle/components/ChronicleProcessErrorSection.svelte +10 -107
- package/src/chronicle/components/ChroniclePromptSection.svelte +6 -26
- package/src/chronicle/components/ChronicleQuestionRequest.svelte +22 -5
- package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +71 -109
- package/src/chronicle/components/ChronicleRecoverySection.svelte +99 -262
- package/src/chronicle/components/ChronicleScheduledActionSection.svelte +1 -1
- package/src/chronicle/components/ChronicleSectionHeader.svelte +1 -4
- package/src/chronicle/components/ChronicleStartupHistory.svelte +63 -0
- package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +10 -26
- package/src/chronicle/components/ChronicleThinkingSection.svelte +25 -165
- package/src/chronicle/components/ChronicleThinkingText.svelte +1 -0
- package/src/chronicle/components/ChronicleToolApproval.svelte +40 -0
- package/src/chronicle/components/ChronicleToolCallItem.svelte +1 -1
- package/src/chronicle/components/ChronicleTurnCluster.svelte +209 -282
- package/src/chronicle/components/ChronicleTurnDetailsButton.svelte +16 -0
- package/src/chronicle/components/ChronicleTurnProgress.svelte +94 -0
- package/src/chronicle/components/ChronicleTurnRail.svelte +339 -394
- package/src/chronicle/components/CompactActionComposer.svelte +36 -13
- package/src/chronicle/components/ReadonlyJsonValue.svelte +30 -0
- package/src/chronicle/lib/action-bindings.ts +1 -1
- package/src/chronicle/lib/action-model-display.ts +2 -2
- package/src/chronicle/lib/action-preview.ts +1 -1
- package/src/chronicle/lib/chronicle-projection.ts +135 -108
- package/src/chronicle/lib/chronicle-rail-groups.ts +158 -0
- package/src/chronicle/lib/chronicle-selectable-items.ts +16 -11
- package/src/chronicle/lib/chronicle-ticket-artifact.ts +7 -0
- package/src/chronicle/lib/formatting.ts +19 -0
- package/src/chronicle/lib/leaf-outcome-loader.ts +30 -111
- package/src/chronicle/lib/leaf-outcome-runtime.ts +3 -15
- package/src/chronicle/lib/result-presentation.ts +40 -0
- package/src/chronicle/lib/retry-groups.ts +24 -0
- package/src/chronicle/lib/scroll-sync.ts +1 -0
- package/src/chronicle/lib/tool-call-summary.ts +1 -9
- package/src/chronicle/ticket-selection.ts +23 -0
- package/src/components/ElapsedTime.svelte +31 -0
- package/src/components/ExternalLink.svelte +39 -0
- package/src/components/FormFieldRenderer.svelte +4 -1
- package/src/components/GenericLauncher.svelte +40 -15
- package/src/components/KeyboardShortcutsModal.svelte +2 -2
- package/src/components/LaunchChecklist.svelte +184 -0
- package/src/components/ModalShell.svelte +49 -15
- package/src/components/PageHeader.svelte +36 -35
- package/src/components/ProcessActionsMenu.svelte +247 -138
- package/src/components/ProcessInfoOverlay.svelte +13 -21
- package/src/components/ProgressChecklist.svelte +46 -0
- package/src/components/ProgressChecklistRows.svelte +80 -0
- package/src/components/launcher-form-copy.ts +4 -1
- package/src/components/launcher-model-config.ts +1 -1
- package/src/extension-ui-dev-server.ts +2 -5
- package/src/lib/api-tokens.ts +34 -0
- package/src/lib/api.ts +330 -455
- package/src/lib/elapsed-time.ts +19 -0
- package/src/lib/external-links.ts +81 -0
- package/src/lib/flow-layout.ts +1 -8
- package/src/lib/format.ts +3 -26
- package/src/lib/future-launch-detail.ts +1 -1
- package/src/lib/http-client.ts +79 -0
- package/src/lib/launch-updates.ts +17 -0
- package/src/lib/markdown.ts +8 -1
- package/src/lib/primary-path-detail.ts +97 -3
- package/src/lib/primary-path-replay.ts +13 -7
- package/src/lib/process-row-view.ts +1 -1
- package/src/lib/process-terminal-display.ts +4 -7
- package/src/lib/processes.svelte.ts +41 -9
- package/src/lib/reasoning-history.ts +95 -0
- package/src/lib/retry-config.svelte.ts +1 -1
- package/src/lib/rich-markdown-elements.ts +2 -2
- package/src/lib/router-logic.ts +3 -0
- package/src/lib/runtime-config.ts +1 -3
- package/src/lib/test-fixtures.ts +1 -1
- package/src/lib/tool-call-rendering.ts +4 -1
- package/src/lib/ui-extensions.svelte.ts +78 -127
- package/src/lib/ws-classifier.ts +8 -1
- package/src/pages/ApiTokensPage.svelte +213 -0
- package/src/pages/FutureLaunchDetailPage.svelte +8 -38
- package/src/pages/HomePage.svelte +8 -11
- package/src/pages/ProcessCard.svelte +1 -1
- package/src/pages/ProcessDetailPage.svelte +161 -62
- package/src/pages/ProcessGallery.svelte +1 -3
- package/src/pages/ProcessesPage.svelte +7 -42
- package/src/pages/SkillsPage.svelte +32 -24
- package/src/pages/WatchersPage.svelte +31 -55
- package/src/pages/process-detail/ProcessDetailChronicle.svelte +415 -19
- package/src/pages/process-detail/ProcessDetailHeader.svelte +66 -25
- package/src/pages/process-detail/ProcessSummary.svelte +35 -0
- package/src/pages/process-detail/TicketCreationComposer.svelte +219 -0
- package/src/pages/process-detail/process-detail-action-drafts.svelte.ts +5 -5
- package/src/pages/process-detail/process-detail-actions.svelte.ts +4 -2
- package/src/pages/process-detail/process-detail-chronicle-dom.ts +39 -14
- package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +68 -10
- package/src/pages/process-detail/process-detail-view-model.ts +10 -23
- package/src/shell/AppShell.svelte +260 -6
- package/src/shell/RouteLoadBoundary.svelte +48 -12
- package/src/shell/Sidebar.svelte +304 -172
- package/src/styles/controls.css +188 -0
- package/dist/assets/ChronicleMarkdown-D6hFzERy.css +0 -1
- package/dist/assets/ChronicleMarkdown-iH1VLv7x.js +0 -16
- package/dist/assets/FutureLaunchDetailPage-BJphZBFH.js +0 -1
- package/dist/assets/FutureLaunchDetailPage-VPMBtpYc.css +0 -1
- package/dist/assets/GenericLauncher-D_GMtsQ5.css +0 -1
- package/dist/assets/GenericLauncher-tr1to52a.js +0 -1
- package/dist/assets/HomePage-CSHVQefI.js +0 -1
- package/dist/assets/HomePage-DYh_QHXv.css +0 -1
- package/dist/assets/PageHeader-6PdvYODN.css +0 -1
- package/dist/assets/PageHeader-C4j3zJKF.js +0 -1
- package/dist/assets/ProcessActionsMenu-BT2r9vO8.css +0 -1
- package/dist/assets/ProcessActionsMenu-gNiZGUCZ.js +0 -1
- package/dist/assets/ProcessDetailPage-CGyVxjeH.js +0 -12
- package/dist/assets/ProcessDetailPage-CSrjzajF.css +0 -1
- package/dist/assets/ProcessFlowDiagram-BX_Zjm2n.js +0 -2
- package/dist/assets/ProcessesPage-BcM38HMs.css +0 -1
- package/dist/assets/ProcessesPage-D3jjufse.js +0 -1
- package/dist/assets/ScheduleDateTimePicker-D72J6EhE.js +0 -1
- package/dist/assets/SkillsPage-B30FAFia.css +0 -1
- package/dist/assets/SkillsPage-CcYm4ATy.js +0 -2
- package/dist/assets/WatchersPage-Bac86WLp.js +0 -1
- package/dist/assets/WatchersPage-Dnfi1zUK.css +0 -1
- package/dist/assets/api-HGtUzekR.js +0 -1
- package/dist/assets/dist-DVNpSD5l.js +0 -2
- package/dist/assets/index-66T4Gmbl.css +0 -1
- package/dist/assets/index-ChVsVf6R.js +0 -7
- package/dist/assets/index-client-BqF3_t3P.js +0 -2
- package/dist/assets/retry-config.svelte-DFKCJtCe.js +0 -1
- package/dist/assets/router.svelte-C2wi6I7k.js +0 -1
- package/src/lib/process-initial-prompt.ts +0 -7
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function elapsedMilliseconds(
|
|
2
|
+
start: string | null,
|
|
3
|
+
end: string | null,
|
|
4
|
+
now: number | null,
|
|
5
|
+
): number | null {
|
|
6
|
+
if (!start || (!end && now === null)) return null;
|
|
7
|
+
const startMs = Date.parse(start);
|
|
8
|
+
const endMs = end ? Date.parse(end) : now;
|
|
9
|
+
if (!Number.isFinite(startMs) || endMs === null || !Number.isFinite(endMs) || endMs < startMs)
|
|
10
|
+
return null;
|
|
11
|
+
return endMs - startMs;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function formatElapsedTime(ms: number): string {
|
|
15
|
+
if (ms < 1000) return `${Math.round(ms)}ms`;
|
|
16
|
+
if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;
|
|
17
|
+
const seconds = Math.floor(ms / 1000);
|
|
18
|
+
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
19
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const EXTERNAL_LINK_CLASS = "external-link";
|
|
2
|
+
export const EXTERNAL_LINK_ICON_CLASS = "external-link-icon";
|
|
3
|
+
export const EXTERNAL_LINK_A11Y_CLASS = "external-link-a11y";
|
|
4
|
+
export const EXTERNAL_LINK_ICON = "↗";
|
|
5
|
+
export const NEW_TAB_ANNOUNCEMENT = "opens in a new tab";
|
|
6
|
+
export const NEW_TAB_REL = "noopener noreferrer";
|
|
7
|
+
export const NEW_TAB_WINDOW_FEATURES = "noopener,noreferrer";
|
|
8
|
+
|
|
9
|
+
export type ExternalResourceType =
|
|
10
|
+
| "issue"
|
|
11
|
+
| "pull_request"
|
|
12
|
+
| "merge_request"
|
|
13
|
+
| "commit"
|
|
14
|
+
| "pipeline"
|
|
15
|
+
| "project"
|
|
16
|
+
| "external_resource";
|
|
17
|
+
|
|
18
|
+
const RESOURCE_LABELS: Record<ExternalResourceType, string> = {
|
|
19
|
+
issue: "Issue",
|
|
20
|
+
pull_request: "Pull request",
|
|
21
|
+
merge_request: "Merge request",
|
|
22
|
+
commit: "Commit",
|
|
23
|
+
pipeline: "Pipeline",
|
|
24
|
+
project: "External project",
|
|
25
|
+
external_resource: "External resource",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function externalResourceLabel(type: ExternalResourceType): string {
|
|
29
|
+
return RESOURCE_LABELS[type];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isExternalHref(href: string, baseUri: string = document.baseURI): boolean {
|
|
33
|
+
if (href.trim().startsWith("#")) return false;
|
|
34
|
+
try {
|
|
35
|
+
const base = new URL(baseUri);
|
|
36
|
+
const destination = new URL(href, base);
|
|
37
|
+
return destination.origin !== base.origin;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function removeDecoration(link: HTMLAnchorElement): void {
|
|
44
|
+
link.classList.remove(EXTERNAL_LINK_CLASS);
|
|
45
|
+
link
|
|
46
|
+
.querySelectorAll(`.${EXTERNAL_LINK_ICON_CLASS}, .${EXTERNAL_LINK_A11Y_CLASS}`)
|
|
47
|
+
.forEach((node) => {
|
|
48
|
+
node.remove();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function secureAnchorNewTab(link: HTMLAnchorElement): void {
|
|
53
|
+
link.target = "_blank";
|
|
54
|
+
link.rel = NEW_TAB_REL;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function decorateExternalLink(link: HTMLAnchorElement): void {
|
|
58
|
+
removeDecoration(link);
|
|
59
|
+
link.classList.add(EXTERNAL_LINK_CLASS);
|
|
60
|
+
secureAnchorNewTab(link);
|
|
61
|
+
|
|
62
|
+
const icon = document.createElement("span");
|
|
63
|
+
icon.className = EXTERNAL_LINK_ICON_CLASS;
|
|
64
|
+
icon.setAttribute("aria-hidden", "true");
|
|
65
|
+
icon.textContent = EXTERNAL_LINK_ICON;
|
|
66
|
+
const announcement = document.createElement("span");
|
|
67
|
+
announcement.className = EXTERNAL_LINK_A11Y_CLASS;
|
|
68
|
+
announcement.textContent = ` (${NEW_TAB_ANNOUNCEMENT})`;
|
|
69
|
+
link.append(icon, announcement);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function normalizeLinkNavigation(link: HTMLAnchorElement, baseUri?: string): void {
|
|
73
|
+
const href = link.getAttribute("href") ?? "";
|
|
74
|
+
if (isExternalHref(href, baseUri)) {
|
|
75
|
+
decorateExternalLink(link);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
removeDecoration(link);
|
|
79
|
+
link.removeAttribute("target");
|
|
80
|
+
link.removeAttribute("rel");
|
|
81
|
+
}
|
package/src/lib/flow-layout.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ProcessTurnTerminalLifecycleStatus,
|
|
7
7
|
ProcessTurnType,
|
|
8
8
|
} from "@leitwerk-dev/domain";
|
|
9
|
+
import { getProcessTerminalHeading as endNodeTitle } from "./process-terminal-display.js";
|
|
9
10
|
|
|
10
11
|
export type FlowLayoutNodeKind = "turn" | "end";
|
|
11
12
|
|
|
@@ -88,10 +89,6 @@ export function endNodeId(status: ProcessTurnTerminalLifecycleStatus): string {
|
|
|
88
89
|
return `${END_NODE_PREFIX}${status}`;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
function endNodeTitle(status: ProcessTurnTerminalLifecycleStatus): string {
|
|
92
|
-
return status === "completed" ? "Completed" : "Aborted";
|
|
93
|
-
}
|
|
94
|
-
|
|
95
92
|
/**
|
|
96
93
|
* Short text drawn on a merged edge: the single label when only one transition
|
|
97
94
|
* was merged, or a self-describing `N transitions` count when several share the
|
|
@@ -118,8 +115,6 @@ export function turnTypeLabel(turnType: ProcessTurnType): string {
|
|
|
118
115
|
return "External wait";
|
|
119
116
|
case "automatic":
|
|
120
117
|
return "Automatic";
|
|
121
|
-
case "server_automatic":
|
|
122
|
-
return "Server step";
|
|
123
118
|
}
|
|
124
119
|
}
|
|
125
120
|
|
|
@@ -138,8 +133,6 @@ export function turnTypeDescription(turnType: ProcessTurnType): string {
|
|
|
138
133
|
return "The process pauses until an outside system or event reports back.";
|
|
139
134
|
case "automatic":
|
|
140
135
|
return "A deterministic step runs automatically in the workspace, with no AI or operator input.";
|
|
141
|
-
case "server_automatic":
|
|
142
|
-
return "The server runs this step automatically to prepare or finalize process state.";
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
138
|
|
package/src/lib/format.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { formatProcessIdentifier, type ProcessLifecycleStatus } from "@leitwerk-dev/domain";
|
|
2
2
|
|
|
3
3
|
const STATUS_LABELS: Record<ProcessLifecycleStatus, string> = {
|
|
4
4
|
discovered: "Queued",
|
|
@@ -9,37 +9,14 @@ const STATUS_LABELS: Record<ProcessLifecycleStatus, string> = {
|
|
|
9
9
|
aborted: "Aborted",
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
api: "API",
|
|
14
|
-
id: "ID",
|
|
15
|
-
llm: "LLM",
|
|
16
|
-
mr: "MR",
|
|
17
|
-
pi: "Pi",
|
|
18
|
-
ui: "UI",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function formatIdentifier(value: string): string {
|
|
22
|
-
return value
|
|
23
|
-
.split(/[_-]+/)
|
|
24
|
-
.filter((part) => part.length > 0)
|
|
25
|
-
.map((part) => {
|
|
26
|
-
const normalizedPart = part.toLowerCase();
|
|
27
|
-
return IDENTIFIER_WORD_LABELS[normalizedPart] ?? part.charAt(0).toUpperCase() + part.slice(1);
|
|
28
|
-
})
|
|
29
|
-
.join(" ");
|
|
30
|
-
}
|
|
31
|
-
|
|
12
|
+
export { formatProcessIdentifier as formatDefinition };
|
|
32
13
|
export function formatStatus(status: ProcessLifecycleStatus): string {
|
|
33
14
|
return STATUS_LABELS[status] ?? status;
|
|
34
15
|
}
|
|
35
16
|
|
|
36
17
|
export function formatTurnId(turnId: string | null): string {
|
|
37
18
|
if (!turnId) return "Unknown";
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function formatDefinition(id: string): string {
|
|
42
|
-
return formatIdentifier(id);
|
|
19
|
+
return formatProcessIdentifier(turnId);
|
|
43
20
|
}
|
|
44
21
|
|
|
45
22
|
export function formatRelativeTime(iso: string): string {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { copiedUnknownRecordSchema as unknownRecordSchema } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { ErrorResponseBody } from "@leitwerk-dev/protocol/http-contracts";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { getFetchImpl, resolveApiUrl } from "./runtime-config.js";
|
|
5
|
+
|
|
6
|
+
export { unknownRecordSchema };
|
|
7
|
+
|
|
8
|
+
export async function tryReadJson(response: Response): Promise<unknown> {
|
|
9
|
+
try {
|
|
10
|
+
return await response.json();
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function readJsonObject<T extends object>(
|
|
17
|
+
response: Response,
|
|
18
|
+
context: string,
|
|
19
|
+
): Promise<T> {
|
|
20
|
+
const body = await tryReadJson(response);
|
|
21
|
+
if (!v.safeParse(unknownRecordSchema, body).success) {
|
|
22
|
+
throw new Error(`${context}: response body must be a JSON object`);
|
|
23
|
+
}
|
|
24
|
+
return body as T;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function jsonRequestInit(method: string, body: unknown): RequestInit {
|
|
28
|
+
return {
|
|
29
|
+
method,
|
|
30
|
+
headers: { "content-type": "application/json" },
|
|
31
|
+
body: JSON.stringify(body),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ResponseError = string | ((response: Response, body: unknown) => Error);
|
|
36
|
+
|
|
37
|
+
export async function requireSuccessfulResponse(
|
|
38
|
+
response: Response,
|
|
39
|
+
error?: ResponseError,
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
if (response.ok) return;
|
|
42
|
+
const body = await tryReadJson(response);
|
|
43
|
+
throw typeof error === "string"
|
|
44
|
+
? new Error(readErrorMessage(body) ?? `${error}: ${response.status}`)
|
|
45
|
+
: (error?.(response, body) ?? new Error(`Request failed: ${response.status}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function requestMutation(
|
|
49
|
+
path: string,
|
|
50
|
+
error: ResponseError,
|
|
51
|
+
init: RequestInit,
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
await requireSuccessfulResponse(await getFetchImpl()(resolveApiUrl(path), init), error);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function requestJson<T extends object>(input: {
|
|
57
|
+
path: string;
|
|
58
|
+
init?: RequestInit;
|
|
59
|
+
malformed: string;
|
|
60
|
+
error?: ResponseError;
|
|
61
|
+
onError?: (response: Response, body: unknown) => T | Promise<T>;
|
|
62
|
+
}): Promise<T> {
|
|
63
|
+
const fetchImpl = getFetchImpl();
|
|
64
|
+
const url = resolveApiUrl(input.path);
|
|
65
|
+
const response = input.init ? await fetchImpl(url, input.init) : await fetchImpl(url);
|
|
66
|
+
if (!response.ok && input.onError) return input.onError(response, await tryReadJson(response));
|
|
67
|
+
await requireSuccessfulResponse(response, input.error);
|
|
68
|
+
return readJsonObject<T>(response, input.malformed);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function readOptionalString(value: unknown): string | null {
|
|
72
|
+
return typeof value === "string" ? value : null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function readErrorMessage(body: unknown): string | null {
|
|
76
|
+
const response = body as (ErrorResponseBody & { message?: unknown }) | null;
|
|
77
|
+
const error = readOptionalString(response?.error) ?? readOptionalString(response?.message);
|
|
78
|
+
return error && error.trim() !== "" ? error : null;
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WsFrame } from "@leitwerk-dev/protocol";
|
|
2
|
+
|
|
3
|
+
type LaunchUpdatedFrame = Extract<WsFrame, { type: "launch.updated" }>;
|
|
4
|
+
type Listener = (frame: LaunchUpdatedFrame) => void;
|
|
5
|
+
|
|
6
|
+
const listeners = new Set<Listener>();
|
|
7
|
+
|
|
8
|
+
export function dispatchLaunchUpdated(frame: WsFrame): boolean {
|
|
9
|
+
if (frame.type !== "launch.updated") return false;
|
|
10
|
+
for (const listener of listeners) listener(frame as LaunchUpdatedFrame);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function onLaunchUpdated(listener: Listener): () => void {
|
|
15
|
+
listeners.add(listener);
|
|
16
|
+
return () => listeners.delete(listener);
|
|
17
|
+
}
|
package/src/lib/markdown.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { normalizeMarkdownLineEndings } from "@leitwerk-dev/domain";
|
|
|
2
2
|
import { parseManagedResultImagePath } from "@leitwerk-dev/worker-protocol/worker-result-image";
|
|
3
3
|
import createDOMPurify from "dompurify";
|
|
4
4
|
import MarkdownIt from "markdown-it";
|
|
5
|
+
import { normalizeLinkNavigation } from "./external-links.js";
|
|
5
6
|
|
|
6
7
|
function createMarkdownRenderer(options: { rich: boolean }): MarkdownIt {
|
|
7
8
|
const renderer = new MarkdownIt({
|
|
@@ -41,7 +42,7 @@ function sanitizeRenderedHtml(renderedHtml: string): string {
|
|
|
41
42
|
throw new Error("renderMarkdownToHtml requires a DOM-capable environment for DOMPurify");
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
const sanitizedHtml = htmlSanitizer.sanitize(renderedHtml, {
|
|
45
46
|
FORBID_TAGS: [
|
|
46
47
|
"audio",
|
|
47
48
|
"embed",
|
|
@@ -55,6 +56,12 @@ function sanitizeRenderedHtml(renderedHtml: string): string {
|
|
|
55
56
|
],
|
|
56
57
|
FORBID_ATTR: ["poster", "srcset"],
|
|
57
58
|
});
|
|
59
|
+
const template = globalThis.document.createElement("template");
|
|
60
|
+
template.innerHTML = sanitizedHtml;
|
|
61
|
+
for (const link of template.content.querySelectorAll<HTMLAnchorElement>("a[href]")) {
|
|
62
|
+
normalizeLinkNavigation(link);
|
|
63
|
+
}
|
|
64
|
+
return template.innerHTML;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
export function renderMarkdownToHtml(markdown: string): string {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
emptyCompactTurnSummary,
|
|
2
3
|
type PrimaryPathActiveTurnSnapshot,
|
|
3
4
|
type PrimaryPathSnapshot,
|
|
4
5
|
type PrimaryPathToolCallSnapshot,
|
|
5
6
|
type PrimaryPathTraceItemSnapshot,
|
|
7
|
+
type PrimaryPathUiSnapshot,
|
|
6
8
|
type PrimaryPathWsFrame,
|
|
7
9
|
WS_PRIMARY_PATH_TYPES,
|
|
8
10
|
} from "@leitwerk-dev/protocol";
|
|
@@ -115,7 +117,7 @@ function ensureToolTraceItem(
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
export function getPrimaryPathActiveTurnOutput(
|
|
118
|
-
activeTurn: PrimaryPathActiveTurnSnapshot | null | undefined,
|
|
120
|
+
activeTurn: Pick<PrimaryPathActiveTurnSnapshot, "assistant"> | null | undefined,
|
|
119
121
|
): string {
|
|
120
122
|
if (!activeTurn) {
|
|
121
123
|
return "";
|
|
@@ -123,7 +125,7 @@ export function getPrimaryPathActiveTurnOutput(
|
|
|
123
125
|
return activeTurn.assistant.text.trim();
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
function applyFullPrimaryPathFrame<TSnapshot extends PrimaryPathSnapshot>(
|
|
127
129
|
snapshot: TSnapshot,
|
|
128
130
|
frame: PrimaryPathWsFrame,
|
|
129
131
|
): TSnapshot {
|
|
@@ -307,7 +309,7 @@ export function applyPrimaryPathFrame<TSnapshot extends PrimaryPathSnapshot>(
|
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
311
|
|
|
310
|
-
|
|
312
|
+
function cloneFullPrimaryPathSnapshot<TSnapshot extends PrimaryPathSnapshot>(
|
|
311
313
|
snapshot: TSnapshot,
|
|
312
314
|
): TSnapshot {
|
|
313
315
|
return {
|
|
@@ -335,3 +337,95 @@ export function clonePrimaryPathSnapshot<TSnapshot extends PrimaryPathSnapshot>(
|
|
|
335
337
|
},
|
|
336
338
|
};
|
|
337
339
|
}
|
|
340
|
+
|
|
341
|
+
export function applyPrimaryPathFrame<T extends PrimaryPathSnapshot | PrimaryPathUiSnapshot>(
|
|
342
|
+
snapshot: T,
|
|
343
|
+
frame: PrimaryPathWsFrame,
|
|
344
|
+
): T {
|
|
345
|
+
if (!("entriesOmitted" in snapshot))
|
|
346
|
+
return applyFullPrimaryPathFrame(snapshot as PrimaryPathSnapshot, frame) as T;
|
|
347
|
+
const compact = snapshot as PrimaryPathUiSnapshot;
|
|
348
|
+
if (frame.eventSequence !== undefined && frame.eventSequence <= compact.throughEventSequence)
|
|
349
|
+
return snapshot;
|
|
350
|
+
if (frame.type === WS_PRIMARY_PATH_TYPES.SUMMARY_UPDATED) {
|
|
351
|
+
const active = compact.turnState.activeTurn;
|
|
352
|
+
if (
|
|
353
|
+
!active ||
|
|
354
|
+
active.turnRecordId !== frame.payload.turnRecordId ||
|
|
355
|
+
frame.payload.summary.throughEventSequence <= active.throughEventSequence
|
|
356
|
+
)
|
|
357
|
+
return snapshot;
|
|
358
|
+
return {
|
|
359
|
+
...compact,
|
|
360
|
+
throughEventSequence: frame.eventSequence ?? compact.throughEventSequence,
|
|
361
|
+
turnState: {
|
|
362
|
+
...compact.turnState,
|
|
363
|
+
activeTurn: { ...active, ...frame.payload.summary, summaryPending: false },
|
|
364
|
+
},
|
|
365
|
+
} as T;
|
|
366
|
+
}
|
|
367
|
+
if (frame.type === WS_PRIMARY_PATH_TYPES.TURN_STARTED) {
|
|
368
|
+
const turn = frame.payload.turnRecord;
|
|
369
|
+
return {
|
|
370
|
+
...compact,
|
|
371
|
+
throughEventSequence: frame.eventSequence ?? compact.throughEventSequence,
|
|
372
|
+
turnState: {
|
|
373
|
+
...compact.turnState,
|
|
374
|
+
currentTurnRecordId: turn.id,
|
|
375
|
+
isStreaming: true,
|
|
376
|
+
activeTurn: {
|
|
377
|
+
...emptyCompactTurnSummary(),
|
|
378
|
+
turnRecordId: turn.id,
|
|
379
|
+
turnId: turn.turnId,
|
|
380
|
+
turnType: turn.turnType,
|
|
381
|
+
pathType: turn.pathType,
|
|
382
|
+
startedAt: turn.startedAt,
|
|
383
|
+
summaryPending: true,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
} as T;
|
|
387
|
+
}
|
|
388
|
+
if (
|
|
389
|
+
[
|
|
390
|
+
WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL,
|
|
391
|
+
WS_PRIMARY_PATH_TYPES.USAGE_UPDATED,
|
|
392
|
+
WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED,
|
|
393
|
+
WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED,
|
|
394
|
+
].includes(frame.type as typeof WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL)
|
|
395
|
+
)
|
|
396
|
+
return snapshot;
|
|
397
|
+
if (
|
|
398
|
+
frame.type === WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED &&
|
|
399
|
+
compact.turnState.activeTurn &&
|
|
400
|
+
compact.turnState.activeTurn.turnRecordId !== frame.payload.turnRecord.id
|
|
401
|
+
)
|
|
402
|
+
return snapshot;
|
|
403
|
+
const metadata = applyFullPrimaryPathFrame(
|
|
404
|
+
{ ...compact, turnState: { ...compact.turnState, activeTurn: null } },
|
|
405
|
+
frame,
|
|
406
|
+
);
|
|
407
|
+
return {
|
|
408
|
+
...metadata,
|
|
409
|
+
throughEventSequence: frame.eventSequence ?? compact.throughEventSequence,
|
|
410
|
+
turnState:
|
|
411
|
+
frame.type === WS_PRIMARY_PATH_TYPES.ASSISTANT_COMMITTED
|
|
412
|
+
? metadata.turnState
|
|
413
|
+
: compact.turnState,
|
|
414
|
+
} as T;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function clonePrimaryPathSnapshot<T extends PrimaryPathSnapshot | PrimaryPathUiSnapshot>(
|
|
418
|
+
snapshot: T,
|
|
419
|
+
): T {
|
|
420
|
+
if ("entriesOmitted" in snapshot)
|
|
421
|
+
return {
|
|
422
|
+
...snapshot,
|
|
423
|
+
turnState: {
|
|
424
|
+
...snapshot.turnState,
|
|
425
|
+
activeTurn: snapshot.turnState.activeTurn
|
|
426
|
+
? structuredClone(snapshot.turnState.activeTurn)
|
|
427
|
+
: null,
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
return cloneFullPrimaryPathSnapshot(snapshot as PrimaryPathSnapshot) as T;
|
|
431
|
+
}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compareTimestampStrings,
|
|
3
3
|
type PrimaryPathSnapshot,
|
|
4
|
+
type PrimaryPathUiSnapshot,
|
|
4
5
|
type PrimaryPathWsFrame,
|
|
5
6
|
} from "@leitwerk-dev/protocol";
|
|
6
7
|
import { applyPrimaryPathFrame, clonePrimaryPathSnapshot } from "./primary-path-detail.js";
|
|
7
8
|
|
|
8
9
|
export function shouldReplayPrimaryPathFrameAfterSnapshot(
|
|
9
|
-
frame: Pick<PrimaryPathWsFrame, "sentAt">,
|
|
10
|
-
snapshot: Pick<PrimaryPathSnapshot, "rebuiltAt"
|
|
10
|
+
frame: Pick<PrimaryPathWsFrame, "sentAt" | "eventSequence">,
|
|
11
|
+
snapshot: Pick<PrimaryPathSnapshot, "rebuiltAt"> & { throughEventSequence?: number },
|
|
11
12
|
): boolean {
|
|
13
|
+
if (frame.eventSequence !== undefined && snapshot.throughEventSequence !== undefined)
|
|
14
|
+
return frame.eventSequence > snapshot.throughEventSequence;
|
|
12
15
|
return compareTimestampStrings(frame.sentAt, snapshot.rebuiltAt) > 0;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export function replayPrimaryPathFramesAfterSnapshot<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
): TSnapshot {
|
|
18
|
+
export function replayPrimaryPathFramesAfterSnapshot<
|
|
19
|
+
TSnapshot extends PrimaryPathSnapshot | PrimaryPathUiSnapshot,
|
|
20
|
+
>(snapshot: TSnapshot, frames: readonly PrimaryPathWsFrame[]): TSnapshot {
|
|
19
21
|
let nextSnapshot = clonePrimaryPathSnapshot(snapshot);
|
|
20
|
-
for (const frame of frames)
|
|
22
|
+
for (const frame of [...frames].sort((a, b) =>
|
|
23
|
+
a.eventSequence !== undefined && b.eventSequence !== undefined
|
|
24
|
+
? a.eventSequence - b.eventSequence
|
|
25
|
+
: compareTimestampStrings(a.sentAt, b.sentAt),
|
|
26
|
+
)) {
|
|
21
27
|
if (!shouldReplayPrimaryPathFrameAfterSnapshot(frame, nextSnapshot)) {
|
|
22
28
|
continue;
|
|
23
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ProcessRowSlot, sortProcessRows } from "@leitwerk-dev/domain";
|
|
2
|
-
import type { ProcessOverviewItem } from "
|
|
2
|
+
import type { ProcessOverviewItem } from "@leitwerk-dev/protocol/http-contracts";
|
|
3
3
|
import { formatDefinition, formatStatus, formatTurnId } from "./format.js";
|
|
4
4
|
|
|
5
5
|
export interface ProcessRowView extends ProcessRowSlot {
|
|
@@ -8,10 +8,7 @@ export function getProcessTerminalHeading(status: ProcessTerminalStatus): string
|
|
|
8
8
|
return status === "completed" ? "Completed" : "Aborted";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function getProcessTerminalVerb(status: ProcessTerminalStatus): string {
|
|
16
|
-
return status === "completed" ? "Completed" : "Aborted";
|
|
17
|
-
}
|
|
11
|
+
export {
|
|
12
|
+
getProcessTerminalHeading as getProcessTerminalRailTitle,
|
|
13
|
+
getProcessTerminalHeading as getProcessTerminalVerb,
|
|
14
|
+
};
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
projectFutureExecutionOverview,
|
|
3
|
+
WS_PRIMARY_PATH_TYPES,
|
|
4
|
+
type WsFrame,
|
|
5
|
+
} from "@leitwerk-dev/protocol";
|
|
6
|
+
import type {
|
|
7
|
+
ProcessBrowseFacets,
|
|
8
|
+
ProcessBrowseItem,
|
|
9
|
+
ProcessBrowsePagination,
|
|
10
|
+
ProcessOverviewItem,
|
|
11
|
+
} from "@leitwerk-dev/protocol/http-contracts";
|
|
2
12
|
import { derived, get, writable } from "svelte/store";
|
|
3
13
|
import {
|
|
4
14
|
type FullFutureExecution,
|
|
@@ -6,12 +16,8 @@ import {
|
|
|
6
16
|
fetchProcessBrowse,
|
|
7
17
|
fetchProcessDetail,
|
|
8
18
|
fetchProcessesList,
|
|
9
|
-
type ProcessBrowseFacets,
|
|
10
|
-
type ProcessBrowseItem,
|
|
11
|
-
type ProcessBrowsePagination,
|
|
12
19
|
type ProcessBrowseRequest,
|
|
13
20
|
type ProcessDetailData,
|
|
14
|
-
type ProcessOverviewItem,
|
|
15
21
|
} from "./api";
|
|
16
22
|
import { upsertFutureExecutionSummary } from "./future-executions-logic.js";
|
|
17
23
|
import { applyPrimaryPathFrame } from "./primary-path-detail.js";
|
|
@@ -104,8 +110,17 @@ function clearPendingPrimaryPathFrames(instanceId?: string) {
|
|
|
104
110
|
|
|
105
111
|
function bufferPrimaryPathFrame(action: Extract<WsAction, { kind: "apply_primary_path_frame" }>) {
|
|
106
112
|
const queuedFrames = pendingPrimaryPathFramesByInstanceId.get(action.instanceId) ?? [];
|
|
113
|
+
if (action.frame.type === WS_PRIMARY_PATH_TYPES.SUMMARY_UPDATED) {
|
|
114
|
+
// Summaries replace earlier summaries, so buffering a slow page request stays bounded.
|
|
115
|
+
const id = action.frame.payload.turnRecordId;
|
|
116
|
+
const prior = queuedFrames.findIndex(
|
|
117
|
+
(frame) =>
|
|
118
|
+
frame.type === WS_PRIMARY_PATH_TYPES.SUMMARY_UPDATED && frame.payload.turnRecordId === id,
|
|
119
|
+
);
|
|
120
|
+
if (prior >= 0) queuedFrames.splice(prior, 1);
|
|
121
|
+
}
|
|
107
122
|
queuedFrames.push(action.frame);
|
|
108
|
-
pendingPrimaryPathFramesByInstanceId.set(action.instanceId, queuedFrames
|
|
123
|
+
pendingPrimaryPathFramesByInstanceId.set(action.instanceId, queuedFrames);
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
function takePendingPrimaryPathFrames(instanceId: string) {
|
|
@@ -276,6 +291,8 @@ function scheduleLoadProcessDetail(instanceId: string, delayMs = 120) {
|
|
|
276
291
|
}
|
|
277
292
|
|
|
278
293
|
export function clearDetail() {
|
|
294
|
+
setCurrentDetailInstanceId(null);
|
|
295
|
+
clearPendingPrimaryPathFrames();
|
|
279
296
|
clearScheduledDetailReload();
|
|
280
297
|
detailState.set({
|
|
281
298
|
data: null,
|
|
@@ -286,12 +303,26 @@ export function clearDetail() {
|
|
|
286
303
|
detailGuard.invalidate();
|
|
287
304
|
}
|
|
288
305
|
|
|
306
|
+
const reasoningFrameListeners = new Set<(frame: WsFrame) => void>();
|
|
307
|
+
export function subscribeReasoningFrames(listener: (frame: WsFrame) => void) {
|
|
308
|
+
reasoningFrameListeners.add(listener);
|
|
309
|
+
return () => {
|
|
310
|
+
reasoningFrameListeners.delete(listener);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
289
314
|
function executePrimaryPathFrame(action: WsAction & { kind: "apply_primary_path_frame" }) {
|
|
290
315
|
const current = get(detailState);
|
|
291
|
-
if (
|
|
292
|
-
|
|
316
|
+
if (
|
|
317
|
+
[
|
|
318
|
+
WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL,
|
|
319
|
+
WS_PRIMARY_PATH_TYPES.USAGE_UPDATED,
|
|
320
|
+
WS_PRIMARY_PATH_TYPES.TOOL_CALL_STARTED,
|
|
321
|
+
WS_PRIMARY_PATH_TYPES.TOOL_CALL_COMPLETED,
|
|
322
|
+
].includes(action.frame.type as typeof WS_PRIMARY_PATH_TYPES.ASSISTANT_PARTIAL)
|
|
323
|
+
)
|
|
293
324
|
return;
|
|
294
|
-
|
|
325
|
+
if (detailInstanceId === action.instanceId && current.loading) bufferPrimaryPathFrame(action);
|
|
295
326
|
if (current.data?.process.id !== action.instanceId) {
|
|
296
327
|
return;
|
|
297
328
|
}
|
|
@@ -302,6 +333,7 @@ function executePrimaryPathFrame(action: WsAction & { kind: "apply_primary_path_
|
|
|
302
333
|
}
|
|
303
334
|
|
|
304
335
|
export function handleWsEvent(frame: WsFrame) {
|
|
336
|
+
for (const listener of reasoningFrameListeners) listener(frame);
|
|
305
337
|
const actions = classifyWsEvent(frame, detailInstanceId);
|
|
306
338
|
|
|
307
339
|
for (const action of actions) {
|