@leitwerk-dev/ui 0.3.1 → 0.4.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-DCmYvZdE.js +1 -0
- package/dist/assets/ChronicleMarkdown-6T_LF-3B.js +1 -0
- package/dist/assets/FutureLaunchDetailPage-D5Gc8YmZ.js +1 -0
- package/dist/assets/GenericLauncher-4BQGl6fT.js +4 -0
- package/dist/assets/GenericLauncher-DRUMMTd7.css +1 -0
- package/dist/assets/HomePage-mb9RzXht.js +1 -0
- package/dist/assets/ProcessActionsMenu-CEzADnZT.js +1 -0
- package/dist/assets/ProcessDetailPage-0c-fMf4Y.js +14 -0
- package/dist/assets/ProcessDetailPage-km76G8wj.css +1 -0
- package/dist/assets/ProcessFlowDiagram-DI5KZ2Qj.js +1 -0
- package/dist/assets/ProcessFlowDiagram-NQ6oEZi7.css +1 -0
- package/dist/assets/ProcessesPage-CVvENTJg.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-2eJ0jBQ-.css +1 -0
- package/dist/assets/ScheduleDateTimePicker-fg0Vau5Z.js +3 -0
- package/dist/assets/SettingsPage-BHSV4rl7.css +1 -0
- package/dist/assets/SettingsPage-CbNM5RWn.js +2 -0
- package/dist/assets/SkillsPage-rCSwSz89.js +2 -0
- package/dist/assets/WatchersPage-D-uT5vWk.js +1 -0
- package/dist/assets/WikiPage-BNdWnJ6L.js +1 -0
- package/dist/assets/WikiPage-Bvnhxl3m.css +1 -0
- package/dist/assets/http-client-Cvi3zOou.js +2 -0
- package/dist/assets/http-contracts-public-BXXSFKbw.js +1 -0
- package/dist/assets/index-DybyOt1_.css +1 -0
- package/dist/assets/{index-client-BYQviCtQ.js → index-client-BSAA7n1a.js} +2 -2
- package/dist/assets/index-gVt2yBO1.js +21 -0
- package/dist/assets/mermaid-render.worker-BN0bcvGc.js +6398 -0
- package/dist/assets/retry-config.svelte-HNNF65qc.js +1 -0
- package/dist/assets/settings-Dk5UoSQa.js +1 -0
- package/dist/index.html +4 -7
- package/package.json +10 -9
- package/src/App.svelte +9 -0
- package/src/chronicle/components/ChronicleActionSection.svelte +10 -2
- package/src/chronicle/components/ChronicleEntryHeader.svelte +4 -16
- package/src/chronicle/components/ChronicleFlow.svelte +24 -6
- package/src/chronicle/components/ChronicleLiveTail.svelte +52 -24
- package/src/chronicle/components/ChronicleProcessErrorSection.svelte +14 -0
- package/src/chronicle/components/ChronicleQuestionRequest.svelte +1 -1
- package/src/chronicle/components/ChronicleRecoverySection.svelte +14 -10
- package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +14 -10
- package/src/chronicle/components/ChronicleThinkingSection.svelte +8 -2
- package/src/chronicle/components/ChronicleToolApproval.svelte +120 -17
- package/src/chronicle/components/ChronicleToolCallItem.svelte +32 -6
- package/src/chronicle/components/ChronicleTurnCluster.svelte +6 -6
- package/src/chronicle/components/ChronicleTurnProgress.svelte +10 -4
- package/src/chronicle/components/ChronicleTurnRail.svelte +1 -0
- package/src/chronicle/components/RecoveryModelControl.svelte +14 -13
- package/src/chronicle/lib/chronicle-projection.ts +74 -376
- package/src/chronicle/lib/chronicle-selectable-items.ts +23 -3
- package/src/chronicle/lib/recovery-model.ts +17 -0
- package/src/components/ConversationTreeDiagram.svelte +93 -30
- package/src/components/FormFieldRenderer.svelte +184 -27
- package/src/components/GenericLauncher.svelte +378 -166
- package/src/components/NamedSelectionList.svelte +77 -0
- package/src/components/ProcessSettings.svelte +110 -0
- package/src/components/ScheduleDateTimePicker.svelte +9 -4
- package/src/components/SettingsField.svelte +317 -0
- package/src/components/SettingsOverview.svelte +237 -0
- package/src/components/SkillSelector.svelte +15 -3
- package/src/components/launcher-form-copy.ts +2 -1
- package/src/components/launcher-model-config.ts +8 -7
- package/src/components/launcher-selections.ts +123 -0
- package/src/lib/api.ts +89 -43
- package/src/lib/http-client.ts +20 -1
- package/src/lib/instance-tree-layout.ts +41 -10
- package/src/lib/primary-path-detail.ts +56 -341
- package/src/lib/primary-path-replay.ts +8 -9
- package/src/lib/process-history.ts +57 -0
- package/src/lib/processes.svelte.ts +71 -79
- package/src/lib/reasoning-history.ts +31 -23
- package/src/lib/router-logic.ts +101 -51
- package/src/lib/router.svelte.ts +4 -4
- package/src/lib/settings.ts +114 -0
- package/src/lib/wiki.ts +34 -0
- package/src/pages/ProcessDetailPage.svelte +55 -344
- package/src/pages/ProcessFlowDiagram.svelte +39 -684
- package/src/pages/SettingsPage.svelte +265 -0
- package/src/pages/SkillsPage.svelte +26 -12
- package/src/pages/WikiPage.svelte +9 -0
- package/src/pages/process-detail/ProcessDetailChronicle.svelte +57 -13
- package/src/pages/process-detail/ProcessDetailHeader.svelte +9 -3
- package/src/pages/process-detail/TicketCreationComposer.svelte +49 -10
- package/src/pages/process-detail/inspector/ExecutionDetails.svelte +210 -0
- package/src/pages/process-detail/inspector/InspectionEvidence.svelte +48 -0
- package/src/pages/process-detail/inspector/InspectionMessage.svelte +71 -0
- package/src/pages/process-detail/inspector/ProcessInspector.svelte +144 -0
- package/src/pages/process-detail/inspector/ProcessModelEditor.svelte +161 -0
- package/src/pages/process-detail/inspector/ProcessReference.svelte +166 -0
- package/src/pages/process-detail/inspector/inspection-activity.ts +118 -0
- package/src/pages/process-detail/inspector/inspection-data.svelte.ts +107 -0
- package/src/pages/process-detail/inspector/inspection-tool-call.ts +30 -0
- package/src/pages/process-detail/inspector/inspector-navigation.ts +190 -0
- package/src/pages/process-detail/inspector/model-source-label.ts +17 -0
- package/src/pages/process-detail/process-detail-actions.svelte.ts +10 -0
- package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +18 -2
- package/src/pages/process-detail/process-detail-view-model.ts +2 -2
- package/src/shell/AppShell.svelte +5 -0
- package/src/shell/Sidebar.svelte +10 -0
- package/src/test-support/mount.ts +34 -0
- package/dist/assets/ApiTokensPage-ClJp9PYr.js +0 -1
- package/dist/assets/ChronicleMarkdown-lqwX9Ywa.js +0 -16
- package/dist/assets/FutureLaunchDetailPage-ygp-IdXC.js +0 -1
- package/dist/assets/GenericLauncher-CExW6wei.css +0 -1
- package/dist/assets/GenericLauncher-DOwsERpB.js +0 -1
- package/dist/assets/HomePage-D1J-Rmsw.js +0 -1
- package/dist/assets/PageHeader-DPuQInDo.css +0 -1
- package/dist/assets/PageHeader-sphJnWL1.js +0 -1
- package/dist/assets/ProcessActionsMenu-DV9zaxNS.js +0 -1
- package/dist/assets/ProcessDetailPage-BW1M2IH8.js +0 -14
- package/dist/assets/ProcessDetailPage-Cth6A0DN.css +0 -1
- package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +0 -1
- package/dist/assets/ProcessFlowDiagram-Dx2wheGN.js +0 -2
- package/dist/assets/ProcessesPage-CSPH5L7E.js +0 -1
- package/dist/assets/ScheduleDateTimePicker-DmojMRxN.js +0 -1
- package/dist/assets/ScheduleDateTimePicker-uacJAkIq.css +0 -1
- package/dist/assets/SkillsPage-KnLql0n1.js +0 -2
- package/dist/assets/WatchersPage-B4jf3Ywp.js +0 -1
- package/dist/assets/http-client-VpPXJwbR.js +0 -2
- package/dist/assets/index-DPCokDbS.js +0 -6
- package/dist/assets/index-DtEI5gsQ.css +0 -1
- package/dist/assets/mermaid-render.worker-QW2WZpEE.js +0 -6393
- package/dist/assets/process-terminal-display-BQRQwGod.js +0 -1
- package/dist/assets/router.svelte-EEldxHlO.js +0 -1
- package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +0 -855
- package/src/components/ProcessInfoOverlay.svelte +0 -1221
- package/src/lib/flow-layout.ts +0 -319
- package/src/pages/process-detail/OverlayFrame.svelte +0 -58
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ProcessDetailData } from "./api.js";
|
|
2
|
+
|
|
3
|
+
/** @internal */
|
|
4
|
+
export function mergeUniqueBy<T>(
|
|
5
|
+
items: readonly T[],
|
|
6
|
+
incoming: readonly T[],
|
|
7
|
+
key: (item: T) => string,
|
|
8
|
+
): T[] {
|
|
9
|
+
return [...new Map([...items, ...incoming].map((item) => [key(item), item])).values()];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Add older evidence without replacing live process state or newer versions of records. */
|
|
13
|
+
export function mergeProcessHistory(
|
|
14
|
+
current: ProcessDetailData,
|
|
15
|
+
older: ProcessDetailData,
|
|
16
|
+
): ProcessDetailData {
|
|
17
|
+
const byId = <T extends { id: string }>(a: readonly T[], b: readonly T[]) =>
|
|
18
|
+
mergeUniqueBy(a, b, (item) => item.id);
|
|
19
|
+
return {
|
|
20
|
+
...current,
|
|
21
|
+
timeline: {
|
|
22
|
+
...current.timeline,
|
|
23
|
+
history: older.timeline.history,
|
|
24
|
+
// Only the current snapshot owns live rows, including temporary current: IDs.
|
|
25
|
+
turns: byId(
|
|
26
|
+
older.timeline.turns.filter((turn) => turn.status !== "in_progress"),
|
|
27
|
+
current.timeline.turns,
|
|
28
|
+
).sort((a, b) => a.startedAt.localeCompare(b.startedAt) || a.id.localeCompare(b.id)),
|
|
29
|
+
inputs: byId(older.timeline.inputs, current.timeline.inputs),
|
|
30
|
+
tracePreviewsByTurnRecordId: {
|
|
31
|
+
...older.timeline.tracePreviewsByTurnRecordId,
|
|
32
|
+
...current.timeline.tracePreviewsByTurnRecordId,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
leafOutcomeSnapshots: byId(older.leafOutcomeSnapshots, current.leafOutcomeSnapshots),
|
|
36
|
+
questionRequests: byId(older.questionRequests, current.questionRequests),
|
|
37
|
+
toolApprovalRequests: byId(older.toolApprovalRequests, current.toolApprovalRequests),
|
|
38
|
+
instanceTree: {
|
|
39
|
+
...current.instanceTree,
|
|
40
|
+
nodes: byId(older.instanceTree.nodes, current.instanceTree.nodes),
|
|
41
|
+
edges: byId(older.instanceTree.edges, current.instanceTree.edges),
|
|
42
|
+
},
|
|
43
|
+
startup: {
|
|
44
|
+
...current.startup,
|
|
45
|
+
attempts: mergeUniqueBy(
|
|
46
|
+
older.startup.attempts,
|
|
47
|
+
current.startup.attempts,
|
|
48
|
+
(item) => item.startRecordId,
|
|
49
|
+
),
|
|
50
|
+
workerStarts: mergeUniqueBy(
|
|
51
|
+
older.startup.workerStarts ?? [],
|
|
52
|
+
current.startup.workerStarts ?? [],
|
|
53
|
+
(item) => item.workerLeaseId,
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -20,8 +20,9 @@ import {
|
|
|
20
20
|
type ProcessDetailData,
|
|
21
21
|
} from "./api";
|
|
22
22
|
import { upsertFutureExecutionSummary } from "./future-executions-logic.js";
|
|
23
|
-
import { applyPrimaryPathFrame } from "./primary-path-detail.js";
|
|
23
|
+
import { applyPrimaryPathFrame, isFullPrimaryPathDetailFrame } from "./primary-path-detail.js";
|
|
24
24
|
import { replayPrimaryPathFramesAfterSnapshot } from "./primary-path-replay.js";
|
|
25
|
+
import { mergeProcessHistory, mergeUniqueBy } from "./process-history.js";
|
|
25
26
|
import { buildProcessRowView, sortProcessRowViews } from "./process-row-view.js";
|
|
26
27
|
import { classifyWsEvent, createRequestGuard, type WsAction } from "./processes-logic.js";
|
|
27
28
|
|
|
@@ -53,12 +54,29 @@ export const detailState = writable({
|
|
|
53
54
|
|
|
54
55
|
const PROCESS_BROWSE_WS_REFRESH_DELAY_MS = 100;
|
|
55
56
|
|
|
57
|
+
function createReloadScheduler() {
|
|
58
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
59
|
+
return {
|
|
60
|
+
clear() {
|
|
61
|
+
if (timer) clearTimeout(timer);
|
|
62
|
+
timer = null;
|
|
63
|
+
},
|
|
64
|
+
schedule(reload: () => void, delayMs: number) {
|
|
65
|
+
this.clear();
|
|
66
|
+
timer = setTimeout(() => {
|
|
67
|
+
timer = null;
|
|
68
|
+
reload();
|
|
69
|
+
}, delayMs);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
let browseActive = false;
|
|
57
75
|
let activeBrowseRequest: ProcessBrowseRequest | null = null;
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
const listReload = createReloadScheduler();
|
|
77
|
+
const browseReload = createReloadScheduler();
|
|
60
78
|
let detailInstanceId: string | null = null;
|
|
61
|
-
|
|
79
|
+
const detailReload = createReloadScheduler();
|
|
62
80
|
const pendingPrimaryPathFramesByInstanceId = new Map<
|
|
63
81
|
string,
|
|
64
82
|
Array<Extract<WsAction, { kind: "apply_primary_path_frame" }>["frame"]>
|
|
@@ -67,39 +85,41 @@ const pendingPrimaryPathFramesByInstanceId = new Map<
|
|
|
67
85
|
const listGuard = createRequestGuard();
|
|
68
86
|
const browseGuard = createRequestGuard();
|
|
69
87
|
const detailGuard = createRequestGuard();
|
|
88
|
+
const historyGuard = createRequestGuard();
|
|
89
|
+
export const historyState = writable({ loading: false, error: null as string | null });
|
|
70
90
|
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
export async function loadEarlierProcessHistory() {
|
|
92
|
+
const current = get(detailState).data;
|
|
93
|
+
const before = current?.timeline.history?.beforeTurnRecordId;
|
|
94
|
+
if (!current || !before || get(historyState).loading) return;
|
|
95
|
+
const generation = historyGuard.next();
|
|
96
|
+
historyState.set({ loading: true, error: null });
|
|
97
|
+
try {
|
|
98
|
+
const older = await fetchProcessDetail(current.process.id, before);
|
|
99
|
+
if (historyGuard.isStale(generation)) return;
|
|
100
|
+
detailState.update((state) =>
|
|
101
|
+
state.data?.process.id === current.process.id
|
|
102
|
+
? { ...state, data: mergeProcessHistory(state.data, older) }
|
|
103
|
+
: state,
|
|
104
|
+
);
|
|
105
|
+
historyState.set({ loading: false, error: null });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (historyGuard.isStale(generation)) return;
|
|
108
|
+
historyState.set({
|
|
109
|
+
loading: false,
|
|
110
|
+
error: error instanceof Error ? error.message : "Couldn't load earlier steps",
|
|
111
|
+
});
|
|
82
112
|
}
|
|
83
|
-
clearTimeout(scheduledBrowseReloadTimer);
|
|
84
|
-
scheduledBrowseReloadTimer = null;
|
|
85
113
|
}
|
|
86
114
|
|
|
87
115
|
export function setProcessBrowseActive(active: boolean) {
|
|
88
116
|
browseActive = active;
|
|
89
117
|
if (!active) {
|
|
90
|
-
|
|
118
|
+
browseReload.clear();
|
|
91
119
|
activeBrowseRequest = null;
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
|
|
95
|
-
function clearScheduledDetailReload() {
|
|
96
|
-
if (!scheduledDetailReloadTimer) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
clearTimeout(scheduledDetailReloadTimer);
|
|
100
|
-
scheduledDetailReloadTimer = null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
123
|
function clearPendingPrimaryPathFrames(instanceId?: string) {
|
|
104
124
|
if (typeof instanceId === "string") {
|
|
105
125
|
pendingPrimaryPathFramesByInstanceId.delete(instanceId);
|
|
@@ -129,17 +149,6 @@ function takePendingPrimaryPathFrames(instanceId: string) {
|
|
|
129
149
|
return queuedFrames;
|
|
130
150
|
}
|
|
131
151
|
|
|
132
|
-
function applyPrimaryPathFrameToDetailData(
|
|
133
|
-
data: ProcessDetailData,
|
|
134
|
-
action: Extract<WsAction, { kind: "apply_primary_path_frame" }>,
|
|
135
|
-
): ProcessDetailData {
|
|
136
|
-
const nextData = {
|
|
137
|
-
...data,
|
|
138
|
-
primaryPath: applyPrimaryPathFrame(data.primaryPath, action.frame),
|
|
139
|
-
};
|
|
140
|
-
return nextData;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
152
|
export function setCurrentDetailInstanceId(instanceId: string | null) {
|
|
144
153
|
if (detailInstanceId === instanceId) {
|
|
145
154
|
return;
|
|
@@ -149,7 +158,7 @@ export function setCurrentDetailInstanceId(instanceId: string | null) {
|
|
|
149
158
|
}
|
|
150
159
|
detailInstanceId = instanceId;
|
|
151
160
|
if (!instanceId) {
|
|
152
|
-
|
|
161
|
+
detailReload.clear();
|
|
153
162
|
}
|
|
154
163
|
}
|
|
155
164
|
|
|
@@ -183,20 +192,12 @@ export async function loadProcessesList() {
|
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
194
|
|
|
186
|
-
function mergeUniqueBy<T>(
|
|
187
|
-
items: readonly T[],
|
|
188
|
-
incoming: readonly T[],
|
|
189
|
-
key: (item: T) => string,
|
|
190
|
-
): T[] {
|
|
191
|
-
return [...new Map([...items, ...incoming].map((item) => [key(item), item])).values()];
|
|
192
|
-
}
|
|
193
|
-
|
|
194
195
|
export async function loadProcessBrowse(
|
|
195
196
|
request: ProcessBrowseRequest = {},
|
|
196
197
|
options: { append?: boolean } = {},
|
|
197
198
|
) {
|
|
198
199
|
if (!options.append) {
|
|
199
|
-
|
|
200
|
+
browseReload.clear();
|
|
200
201
|
activeBrowseRequest = { ...request };
|
|
201
202
|
delete activeBrowseRequest.offset;
|
|
202
203
|
}
|
|
@@ -234,21 +235,14 @@ export async function loadProcessBrowse(
|
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
function scheduleActiveProcessBrowseReload(delayMs = PROCESS_BROWSE_WS_REFRESH_DELAY_MS) {
|
|
237
|
-
if (!browseActive || !activeBrowseRequest)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
clearScheduledBrowseReload();
|
|
241
|
-
scheduledBrowseReloadTimer = setTimeout(() => {
|
|
242
|
-
scheduledBrowseReloadTimer = null;
|
|
243
|
-
if (!browseActive || !activeBrowseRequest) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
void loadProcessBrowse(activeBrowseRequest);
|
|
238
|
+
if (!browseActive || !activeBrowseRequest) return;
|
|
239
|
+
browseReload.schedule(() => {
|
|
240
|
+
if (browseActive && activeBrowseRequest) void loadProcessBrowse(activeBrowseRequest);
|
|
247
241
|
}, delayMs);
|
|
248
242
|
}
|
|
249
243
|
|
|
250
244
|
export async function loadProcessDetail(instanceId: string) {
|
|
251
|
-
|
|
245
|
+
detailReload.clear();
|
|
252
246
|
const gen = detailGuard.next();
|
|
253
247
|
setCurrentDetailInstanceId(instanceId);
|
|
254
248
|
detailState.update((state) => ({ ...state, loading: true, error: null }));
|
|
@@ -256,13 +250,20 @@ export async function loadProcessDetail(instanceId: string) {
|
|
|
256
250
|
const result = await fetchProcessDetail(instanceId);
|
|
257
251
|
if (detailGuard.isStale(gen)) return;
|
|
258
252
|
const loadedAtMs = Date.now();
|
|
253
|
+
const previous = get(detailState).data;
|
|
254
|
+
const retained =
|
|
255
|
+
previous?.process.id === instanceId &&
|
|
256
|
+
previous.timeline.history &&
|
|
257
|
+
previous.timeline.turns.some((turn) => turn.id === result.timeline.turns[0]?.id)
|
|
258
|
+
? mergeProcessHistory(result, previous)
|
|
259
|
+
: result;
|
|
259
260
|
const replayedPrimaryPath = replayPrimaryPathFramesAfterSnapshot(
|
|
260
261
|
result.primaryPath,
|
|
261
262
|
takePendingPrimaryPathFrames(instanceId),
|
|
262
263
|
);
|
|
263
264
|
detailState.set({
|
|
264
265
|
data: {
|
|
265
|
-
...
|
|
266
|
+
...retained,
|
|
266
267
|
primaryPath: replayedPrimaryPath,
|
|
267
268
|
},
|
|
268
269
|
loading: false,
|
|
@@ -280,20 +281,16 @@ export async function loadProcessDetail(instanceId: string) {
|
|
|
280
281
|
}
|
|
281
282
|
|
|
282
283
|
function scheduleLoadProcessDetail(instanceId: string, delayMs = 120) {
|
|
283
|
-
if (detailInstanceId
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
clearScheduledDetailReload();
|
|
287
|
-
scheduledDetailReloadTimer = setTimeout(() => {
|
|
288
|
-
scheduledDetailReloadTimer = null;
|
|
289
|
-
void loadProcessDetail(instanceId);
|
|
290
|
-
}, delayMs);
|
|
284
|
+
if (detailInstanceId === instanceId)
|
|
285
|
+
detailReload.schedule(() => void loadProcessDetail(instanceId), delayMs);
|
|
291
286
|
}
|
|
292
287
|
|
|
293
288
|
export function clearDetail() {
|
|
289
|
+
historyGuard.invalidate();
|
|
290
|
+
historyState.set({ loading: false, error: null });
|
|
294
291
|
setCurrentDetailInstanceId(null);
|
|
295
292
|
clearPendingPrimaryPathFrames();
|
|
296
|
-
|
|
293
|
+
detailReload.clear();
|
|
297
294
|
detailState.set({
|
|
298
295
|
data: null,
|
|
299
296
|
loading: false,
|
|
@@ -313,22 +310,17 @@ export function subscribeReasoningFrames(listener: (frame: WsFrame) => void) {
|
|
|
313
310
|
|
|
314
311
|
function executePrimaryPathFrame(action: WsAction & { kind: "apply_primary_path_frame" }) {
|
|
315
312
|
const current = get(detailState);
|
|
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
|
-
)
|
|
324
|
-
return;
|
|
313
|
+
if (isFullPrimaryPathDetailFrame(action.frame)) return;
|
|
325
314
|
if (detailInstanceId === action.instanceId && current.loading) bufferPrimaryPathFrame(action);
|
|
326
315
|
if (current.data?.process.id !== action.instanceId) {
|
|
327
316
|
return;
|
|
328
317
|
}
|
|
329
318
|
detailState.set({
|
|
330
319
|
...current,
|
|
331
|
-
data:
|
|
320
|
+
data: {
|
|
321
|
+
...current.data,
|
|
322
|
+
primaryPath: applyPrimaryPathFrame(current.data.primaryPath, action.frame),
|
|
323
|
+
},
|
|
332
324
|
});
|
|
333
325
|
}
|
|
334
326
|
|
|
@@ -339,7 +331,7 @@ export function handleWsEvent(frame: WsFrame) {
|
|
|
339
331
|
for (const action of actions) {
|
|
340
332
|
switch (action.kind) {
|
|
341
333
|
case "reload_list":
|
|
342
|
-
|
|
334
|
+
listReload.schedule(() => void loadProcessesList(), PROCESS_BROWSE_WS_REFRESH_DELAY_MS);
|
|
343
335
|
break;
|
|
344
336
|
case "refresh_active_browse":
|
|
345
337
|
scheduleActiveProcessBrowseReload();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { ProcessEvent } from "@leitwerk-dev/domain";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
snapshotTurnTrace,
|
|
3
|
+
createLiveTurnProjection,
|
|
4
|
+
restoreTurnTraceProjection,
|
|
5
5
|
type TurnReasoningDetailResponseBody,
|
|
6
|
-
type
|
|
6
|
+
type TurnTraceProjection,
|
|
7
7
|
type WsFrame,
|
|
8
8
|
} from "@leitwerk-dev/protocol";
|
|
9
9
|
|
|
@@ -23,12 +23,12 @@ const PI_EVENT_TYPES: Record<string, string> = {
|
|
|
23
23
|
|
|
24
24
|
/** Owns expanded history only. HTTP recovery replaces its base, then replays later frames once. */
|
|
25
25
|
export class ReasoningHistory {
|
|
26
|
-
private
|
|
26
|
+
private inspectionEvents = new Map<number, ProcessEvent>();
|
|
27
|
+
private projection: TurnTraceProjection = createLiveTurnProjection();
|
|
27
28
|
private boundary = 0;
|
|
28
29
|
private buffered = new Map<number, WsFrame>();
|
|
29
30
|
private pending = false;
|
|
30
31
|
private committed = false;
|
|
31
|
-
private piInput: TurnTraceSnapshot["piInput"] = null;
|
|
32
32
|
constructor(
|
|
33
33
|
readonly instanceId: string,
|
|
34
34
|
readonly turnRecordId: string,
|
|
@@ -41,21 +41,16 @@ export class ReasoningHistory {
|
|
|
41
41
|
this.pending = false;
|
|
42
42
|
this.buffered.clear();
|
|
43
43
|
}
|
|
44
|
-
accept(response: TurnReasoningDetailResponseBody
|
|
44
|
+
accept(response: TurnReasoningDetailResponseBody & { events?: ProcessEvent[] }) {
|
|
45
45
|
if (response.instanceId !== this.instanceId || response.turnRecordId !== this.turnRecordId)
|
|
46
46
|
throw new Error("Reasoning response belongs to another turn");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.projection.toolCallsById = new Map(
|
|
55
|
-
this.projection.toolCalls.map((tool) => [tool.toolCallId, tool]),
|
|
56
|
-
);
|
|
57
|
-
this.projection.usage = response.reasoning.usage;
|
|
58
|
-
this.piInput = response.reasoning.piInput;
|
|
47
|
+
if (response.events)
|
|
48
|
+
this.inspectionEvents = new Map(
|
|
49
|
+
response.events.flatMap((event) =>
|
|
50
|
+
event.eventSequence === undefined ? [] : [[event.eventSequence, event]],
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
this.projection = restoreTurnTraceProjection(response.reasoning);
|
|
59
54
|
this.boundary = response.throughEventSequence;
|
|
60
55
|
this.committed = response.state === "committed";
|
|
61
56
|
this.pending = false;
|
|
@@ -66,7 +61,7 @@ export class ReasoningHistory {
|
|
|
66
61
|
this.buffered.clear();
|
|
67
62
|
return this.snapshot();
|
|
68
63
|
}
|
|
69
|
-
push(frame: WsFrame):
|
|
64
|
+
push(frame: WsFrame): ReturnType<ReasoningHistory["snapshot"]> | null {
|
|
70
65
|
if (
|
|
71
66
|
frame.instanceId !== this.instanceId ||
|
|
72
67
|
!("turnRecordId" in frame.payload) ||
|
|
@@ -81,7 +76,15 @@ export class ReasoningHistory {
|
|
|
81
76
|
private apply(frame: WsFrame): boolean {
|
|
82
77
|
if (this.committed || frame.eventSequence === undefined || frame.eventSequence <= this.boundary)
|
|
83
78
|
return false;
|
|
84
|
-
|
|
79
|
+
this.inspectionEvents.set(frame.eventSequence, {
|
|
80
|
+
id: `event:${frame.eventSequence}`,
|
|
81
|
+
instanceId: this.instanceId,
|
|
82
|
+
eventSequence: frame.eventSequence,
|
|
83
|
+
eventType: PI_EVENT_TYPES[frame.type],
|
|
84
|
+
data: frame.payload as Record<string, unknown>,
|
|
85
|
+
createdAt: frame.sentAt,
|
|
86
|
+
});
|
|
87
|
+
this.projection.apply({
|
|
85
88
|
eventType: PI_EVENT_TYPES[frame.type],
|
|
86
89
|
data: frame.payload as Record<string, unknown>,
|
|
87
90
|
fallbackTimestamp: frame.sentAt,
|
|
@@ -89,7 +92,12 @@ export class ReasoningHistory {
|
|
|
89
92
|
this.boundary = frame.eventSequence;
|
|
90
93
|
return true;
|
|
91
94
|
}
|
|
92
|
-
snapshot()
|
|
93
|
-
return
|
|
95
|
+
snapshot() {
|
|
96
|
+
return {
|
|
97
|
+
...this.projection.snapshot(),
|
|
98
|
+
events: [...this.inspectionEvents.values()].sort(
|
|
99
|
+
(a, b) => (a.eventSequence ?? 0) - (b.eventSequence ?? 0),
|
|
100
|
+
),
|
|
101
|
+
};
|
|
94
102
|
}
|
|
95
103
|
}
|
package/src/lib/router-logic.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type Page =
|
|
2
|
+
| "wiki"
|
|
3
|
+
| "settings"
|
|
2
4
|
| "api-tokens"
|
|
3
5
|
| "home"
|
|
4
6
|
| "processes"
|
|
@@ -12,32 +14,12 @@ export interface Route {
|
|
|
12
14
|
params: Record<string, string>;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export type ProcessDetailOverlayState =
|
|
16
|
-
| { kind: "none" }
|
|
17
|
-
| { kind: "process-info" }
|
|
18
|
-
| { kind: "reasoning"; turnRecordId: string | null };
|
|
19
|
-
|
|
20
|
-
export interface ProcessPathOptions {
|
|
21
|
-
overlay?: "process-info" | "reasoning" | null;
|
|
22
|
-
turnRecordId?: string | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
function stripSearchAndHash(path: string): string {
|
|
26
|
-
|
|
27
|
-
const hashIndex = path.indexOf("#");
|
|
28
|
-
const endIndexes = [searchIndex, hashIndex].filter((index) => index >= 0);
|
|
29
|
-
const endIndex = endIndexes.length > 0 ? Math.min(...endIndexes) : path.length;
|
|
30
|
-
return path.slice(0, endIndex);
|
|
18
|
+
return path.split(/[?#]/, 1)[0];
|
|
31
19
|
}
|
|
32
20
|
|
|
33
21
|
function readSearchParams(path: string): URLSearchParams {
|
|
34
|
-
|
|
35
|
-
if (searchIndex < 0) {
|
|
36
|
-
return new URLSearchParams();
|
|
37
|
-
}
|
|
38
|
-
const hashIndex = path.indexOf("#", searchIndex);
|
|
39
|
-
const search = path.slice(searchIndex + 1, hashIndex >= 0 ? hashIndex : path.length);
|
|
40
|
-
return new URLSearchParams(search);
|
|
22
|
+
return new URL(path, "http://localhost").searchParams;
|
|
41
23
|
}
|
|
42
24
|
|
|
43
25
|
function decodeFirstSegment(pathname: string, prefix: string): string {
|
|
@@ -62,19 +44,8 @@ export function buildProcessesPath(): string {
|
|
|
62
44
|
return "/processes";
|
|
63
45
|
}
|
|
64
46
|
|
|
65
|
-
export function buildProcessPath(instanceId: string
|
|
66
|
-
|
|
67
|
-
const params = new URLSearchParams();
|
|
68
|
-
if (options.overlay === "process-info") {
|
|
69
|
-
params.set("overlay", "process-info");
|
|
70
|
-
} else if (options.overlay === "reasoning") {
|
|
71
|
-
params.set("overlay", "reasoning");
|
|
72
|
-
if (options.turnRecordId) {
|
|
73
|
-
params.set("turnRecordId", options.turnRecordId);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const query = params.toString();
|
|
77
|
-
return query ? `${path}?${query}` : path;
|
|
47
|
+
export function buildProcessPath(instanceId: string): string {
|
|
48
|
+
return `/processes/${encodeURIComponent(instanceId)}`;
|
|
78
49
|
}
|
|
79
50
|
|
|
80
51
|
export function buildWatchersPath(): string {
|
|
@@ -93,25 +64,12 @@ export function buildInstalledSkillPath(skillId: string): string {
|
|
|
93
64
|
return `/skills/installed/${encodeURIComponent(skillId)}`;
|
|
94
65
|
}
|
|
95
66
|
|
|
96
|
-
export function readProcessDetailOverlay(path: string): ProcessDetailOverlayState {
|
|
97
|
-
const params = readSearchParams(path);
|
|
98
|
-
const overlay = params.get("overlay");
|
|
99
|
-
if (overlay === "process-info") {
|
|
100
|
-
return { kind: "process-info" };
|
|
101
|
-
}
|
|
102
|
-
if (overlay === "reasoning") {
|
|
103
|
-
return { kind: "reasoning", turnRecordId: params.get("turnRecordId") };
|
|
104
|
-
}
|
|
105
|
-
return { kind: "none" };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
67
|
function matchPrefixedDetailRoute(
|
|
109
|
-
|
|
68
|
+
pathname: string,
|
|
110
69
|
prefix: string,
|
|
111
70
|
page: "process-detail" | "future-launch-detail",
|
|
112
71
|
paramName: "instanceId" | "futureExecutionId",
|
|
113
72
|
): Route | null {
|
|
114
|
-
const pathname = stripSearchAndHash(pathnameWithSearch);
|
|
115
73
|
if (!pathname.startsWith(prefix)) {
|
|
116
74
|
return null;
|
|
117
75
|
}
|
|
@@ -126,10 +84,19 @@ function matchPrefixedDetailRoute(
|
|
|
126
84
|
|
|
127
85
|
export function matchRoute(pathnameWithSearch: string): Route {
|
|
128
86
|
const pathname = stripSearchAndHash(pathnameWithSearch);
|
|
87
|
+
if (pathname === "/wiki" || pathname.startsWith("/wiki/")) {
|
|
88
|
+
const segments = pathname.split("/").filter(Boolean).slice(1).map(decodeURIComponent);
|
|
89
|
+
return { page: "wiki", params: { topicId: segments[0] ?? "", pageId: segments[1] ?? "" } };
|
|
90
|
+
}
|
|
91
|
+
if (pathname === "/settings" || pathname === "/settings/")
|
|
92
|
+
return {
|
|
93
|
+
page: "settings",
|
|
94
|
+
params: { scope: readSearchParams(pathnameWithSearch).get("scope") ?? "instance" },
|
|
95
|
+
};
|
|
129
96
|
if (pathname === "/account/api-tokens" || pathname === "/account/api-tokens/")
|
|
130
97
|
return { page: "api-tokens", params: {} };
|
|
131
98
|
const processDetailRoute = matchPrefixedDetailRoute(
|
|
132
|
-
|
|
99
|
+
pathname,
|
|
133
100
|
"/processes/",
|
|
134
101
|
"process-detail",
|
|
135
102
|
"instanceId",
|
|
@@ -139,7 +106,7 @@ export function matchRoute(pathnameWithSearch: string): Route {
|
|
|
139
106
|
}
|
|
140
107
|
|
|
141
108
|
const futureLaunchDetailRoute = matchPrefixedDetailRoute(
|
|
142
|
-
|
|
109
|
+
pathname,
|
|
143
110
|
"/future-launches/",
|
|
144
111
|
"future-launch-detail",
|
|
145
112
|
"futureExecutionId",
|
|
@@ -191,3 +158,86 @@ export function matchRoute(pathnameWithSearch: string): Route {
|
|
|
191
158
|
|
|
192
159
|
return { page: "home", params: {} };
|
|
193
160
|
}
|
|
161
|
+
|
|
162
|
+
/** @internal */
|
|
163
|
+
export const inspectorProcessSections = [
|
|
164
|
+
["overview", "Overview"],
|
|
165
|
+
["workflow", "Workflow"],
|
|
166
|
+
["inputs", "Inputs & configuration"],
|
|
167
|
+
["context-map", "Context map"],
|
|
168
|
+
] as const;
|
|
169
|
+
/** @internal */
|
|
170
|
+
export const inspectorExecutionSections = [
|
|
171
|
+
["trace", "Trace"],
|
|
172
|
+
["context", "Context"],
|
|
173
|
+
["configuration", "Configuration"],
|
|
174
|
+
] as const;
|
|
175
|
+
export type InspectorProcessSection = (typeof inspectorProcessSections)[number][0];
|
|
176
|
+
export type InspectorExecutionSection = (typeof inspectorExecutionSections)[number][0];
|
|
177
|
+
export type InspectorTarget =
|
|
178
|
+
| { scope: "process"; section: InspectorProcessSection; turnRecordId?: string }
|
|
179
|
+
| { scope: "step"; turnId: string }
|
|
180
|
+
| {
|
|
181
|
+
scope: "execution";
|
|
182
|
+
turnRecordId: string;
|
|
183
|
+
section: InspectorExecutionSection;
|
|
184
|
+
entryId?: string;
|
|
185
|
+
itemId?: string;
|
|
186
|
+
boundaryFor?: string;
|
|
187
|
+
};
|
|
188
|
+
export type InspectorRoute = InspectorTarget | { scope: "invalid"; reason: string } | null;
|
|
189
|
+
|
|
190
|
+
export function buildInspectorPath(instanceId: string, target: InspectorTarget): string {
|
|
191
|
+
const params = new URLSearchParams({ inspect: target.scope });
|
|
192
|
+
if (target.scope === "step") params.set("turnId", target.turnId);
|
|
193
|
+
else {
|
|
194
|
+
params.set("section", target.section);
|
|
195
|
+
if (target.turnRecordId) params.set("turnRecordId", target.turnRecordId);
|
|
196
|
+
if (target.scope === "execution") {
|
|
197
|
+
if (target.entryId) params.set("entryId", target.entryId);
|
|
198
|
+
if (target.itemId) params.set("itemId", target.itemId);
|
|
199
|
+
if (target.boundaryFor) params.set("boundaryFor", target.boundaryFor);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return `${buildProcessPath(instanceId)}?${params}`;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function readInspectorTarget(path: string): InspectorRoute {
|
|
206
|
+
const params = readSearchParams(path);
|
|
207
|
+
let scope = params.get("inspect");
|
|
208
|
+
if (!scope && params.get("overlay") === "process-info") scope = "process";
|
|
209
|
+
if (!scope && params.get("overlay") === "reasoning") scope = "execution";
|
|
210
|
+
if (!scope) return null;
|
|
211
|
+
const invalid = {
|
|
212
|
+
scope: "invalid",
|
|
213
|
+
reason: "This inspector link has a missing or unsupported target.",
|
|
214
|
+
} as const;
|
|
215
|
+
const section = params.get("section");
|
|
216
|
+
const turnRecordId = params.get("turnRecordId") || undefined;
|
|
217
|
+
if (scope === "step") {
|
|
218
|
+
const turnId = params.get("turnId");
|
|
219
|
+
return turnId ? { scope, turnId } : invalid;
|
|
220
|
+
}
|
|
221
|
+
if (scope === "process") {
|
|
222
|
+
if (section && !inspectorProcessSections.some(([id]) => id === section)) return invalid;
|
|
223
|
+
return {
|
|
224
|
+
scope,
|
|
225
|
+
section: (section ?? "overview") as InspectorProcessSection,
|
|
226
|
+
...(turnRecordId ? { turnRecordId } : {}),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (scope === "execution" && turnRecordId) {
|
|
230
|
+
if (section && !inspectorExecutionSections.some(([id]) => id === section)) return invalid;
|
|
231
|
+
const target: InspectorTarget = {
|
|
232
|
+
scope,
|
|
233
|
+
turnRecordId,
|
|
234
|
+
section: (section ?? "trace") as InspectorExecutionSection,
|
|
235
|
+
};
|
|
236
|
+
for (const key of ["entryId", "itemId", "boundaryFor"] as const) {
|
|
237
|
+
const value = params.get(key);
|
|
238
|
+
if (value) target[key] = value;
|
|
239
|
+
}
|
|
240
|
+
return target;
|
|
241
|
+
}
|
|
242
|
+
return invalid;
|
|
243
|
+
}
|
package/src/lib/router.svelte.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Page,
|
|
1
|
+
export type { Page, Route } from "./router-logic.js";
|
|
2
2
|
export {
|
|
3
3
|
buildAvailableSkillPath,
|
|
4
4
|
buildFutureLaunchPath,
|
|
@@ -9,7 +9,6 @@ export {
|
|
|
9
9
|
buildSkillsPath,
|
|
10
10
|
buildWatchersPath,
|
|
11
11
|
matchRoute,
|
|
12
|
-
readProcessDetailOverlay,
|
|
13
12
|
} from "./router-logic.js";
|
|
14
13
|
|
|
15
14
|
import { derived, writable } from "svelte/store";
|
|
@@ -17,6 +16,7 @@ import { matchRoute } from "./router-logic.js";
|
|
|
17
16
|
|
|
18
17
|
interface NavigateOptions {
|
|
19
18
|
replace?: boolean;
|
|
19
|
+
state?: unknown;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function readCurrentLocationPath(): string {
|
|
@@ -44,9 +44,9 @@ export function followLink(event: MouseEvent, to: string): void {
|
|
|
44
44
|
|
|
45
45
|
export function navigate(to: string, options: NavigateOptions = {}) {
|
|
46
46
|
if (options.replace) {
|
|
47
|
-
history.replaceState(null, "", to);
|
|
47
|
+
history.replaceState(options.state ?? null, "", to);
|
|
48
48
|
} else {
|
|
49
|
-
history.pushState(null, "", to);
|
|
49
|
+
history.pushState(options.state ?? null, "", to);
|
|
50
50
|
}
|
|
51
51
|
currentLocationPath.set(readCurrentLocationPath());
|
|
52
52
|
}
|