@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.
Files changed (126) hide show
  1. package/dist/assets/ApiTokensPage-DCmYvZdE.js +1 -0
  2. package/dist/assets/ChronicleMarkdown-6T_LF-3B.js +1 -0
  3. package/dist/assets/FutureLaunchDetailPage-D5Gc8YmZ.js +1 -0
  4. package/dist/assets/GenericLauncher-4BQGl6fT.js +4 -0
  5. package/dist/assets/GenericLauncher-DRUMMTd7.css +1 -0
  6. package/dist/assets/HomePage-mb9RzXht.js +1 -0
  7. package/dist/assets/ProcessActionsMenu-CEzADnZT.js +1 -0
  8. package/dist/assets/ProcessDetailPage-0c-fMf4Y.js +14 -0
  9. package/dist/assets/ProcessDetailPage-km76G8wj.css +1 -0
  10. package/dist/assets/ProcessFlowDiagram-DI5KZ2Qj.js +1 -0
  11. package/dist/assets/ProcessFlowDiagram-NQ6oEZi7.css +1 -0
  12. package/dist/assets/ProcessesPage-CVvENTJg.js +1 -0
  13. package/dist/assets/ScheduleDateTimePicker-2eJ0jBQ-.css +1 -0
  14. package/dist/assets/ScheduleDateTimePicker-fg0Vau5Z.js +3 -0
  15. package/dist/assets/SettingsPage-BHSV4rl7.css +1 -0
  16. package/dist/assets/SettingsPage-CbNM5RWn.js +2 -0
  17. package/dist/assets/SkillsPage-rCSwSz89.js +2 -0
  18. package/dist/assets/WatchersPage-D-uT5vWk.js +1 -0
  19. package/dist/assets/WikiPage-BNdWnJ6L.js +1 -0
  20. package/dist/assets/WikiPage-Bvnhxl3m.css +1 -0
  21. package/dist/assets/http-client-Cvi3zOou.js +2 -0
  22. package/dist/assets/http-contracts-public-BXXSFKbw.js +1 -0
  23. package/dist/assets/index-DybyOt1_.css +1 -0
  24. package/dist/assets/{index-client-BYQviCtQ.js → index-client-BSAA7n1a.js} +2 -2
  25. package/dist/assets/index-gVt2yBO1.js +21 -0
  26. package/dist/assets/mermaid-render.worker-BN0bcvGc.js +6398 -0
  27. package/dist/assets/retry-config.svelte-HNNF65qc.js +1 -0
  28. package/dist/assets/settings-Dk5UoSQa.js +1 -0
  29. package/dist/index.html +4 -7
  30. package/package.json +10 -9
  31. package/src/App.svelte +9 -0
  32. package/src/chronicle/components/ChronicleActionSection.svelte +10 -2
  33. package/src/chronicle/components/ChronicleEntryHeader.svelte +4 -16
  34. package/src/chronicle/components/ChronicleFlow.svelte +24 -6
  35. package/src/chronicle/components/ChronicleLiveTail.svelte +52 -24
  36. package/src/chronicle/components/ChronicleProcessErrorSection.svelte +14 -0
  37. package/src/chronicle/components/ChronicleQuestionRequest.svelte +1 -1
  38. package/src/chronicle/components/ChronicleRecoverySection.svelte +14 -10
  39. package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +14 -10
  40. package/src/chronicle/components/ChronicleThinkingSection.svelte +8 -2
  41. package/src/chronicle/components/ChronicleToolApproval.svelte +120 -17
  42. package/src/chronicle/components/ChronicleToolCallItem.svelte +32 -6
  43. package/src/chronicle/components/ChronicleTurnCluster.svelte +6 -6
  44. package/src/chronicle/components/ChronicleTurnProgress.svelte +10 -4
  45. package/src/chronicle/components/ChronicleTurnRail.svelte +1 -0
  46. package/src/chronicle/components/RecoveryModelControl.svelte +14 -13
  47. package/src/chronicle/lib/chronicle-projection.ts +74 -376
  48. package/src/chronicle/lib/chronicle-selectable-items.ts +23 -3
  49. package/src/chronicle/lib/recovery-model.ts +17 -0
  50. package/src/components/ConversationTreeDiagram.svelte +93 -30
  51. package/src/components/FormFieldRenderer.svelte +184 -27
  52. package/src/components/GenericLauncher.svelte +378 -166
  53. package/src/components/NamedSelectionList.svelte +77 -0
  54. package/src/components/ProcessSettings.svelte +110 -0
  55. package/src/components/ScheduleDateTimePicker.svelte +9 -4
  56. package/src/components/SettingsField.svelte +317 -0
  57. package/src/components/SettingsOverview.svelte +237 -0
  58. package/src/components/SkillSelector.svelte +15 -3
  59. package/src/components/launcher-form-copy.ts +2 -1
  60. package/src/components/launcher-model-config.ts +8 -7
  61. package/src/components/launcher-selections.ts +123 -0
  62. package/src/lib/api.ts +89 -43
  63. package/src/lib/http-client.ts +20 -1
  64. package/src/lib/instance-tree-layout.ts +41 -10
  65. package/src/lib/primary-path-detail.ts +56 -341
  66. package/src/lib/primary-path-replay.ts +8 -9
  67. package/src/lib/process-history.ts +57 -0
  68. package/src/lib/processes.svelte.ts +71 -79
  69. package/src/lib/reasoning-history.ts +31 -23
  70. package/src/lib/router-logic.ts +101 -51
  71. package/src/lib/router.svelte.ts +4 -4
  72. package/src/lib/settings.ts +114 -0
  73. package/src/lib/wiki.ts +34 -0
  74. package/src/pages/ProcessDetailPage.svelte +55 -344
  75. package/src/pages/ProcessFlowDiagram.svelte +39 -684
  76. package/src/pages/SettingsPage.svelte +265 -0
  77. package/src/pages/SkillsPage.svelte +26 -12
  78. package/src/pages/WikiPage.svelte +9 -0
  79. package/src/pages/process-detail/ProcessDetailChronicle.svelte +57 -13
  80. package/src/pages/process-detail/ProcessDetailHeader.svelte +9 -3
  81. package/src/pages/process-detail/TicketCreationComposer.svelte +49 -10
  82. package/src/pages/process-detail/inspector/ExecutionDetails.svelte +210 -0
  83. package/src/pages/process-detail/inspector/InspectionEvidence.svelte +48 -0
  84. package/src/pages/process-detail/inspector/InspectionMessage.svelte +71 -0
  85. package/src/pages/process-detail/inspector/ProcessInspector.svelte +144 -0
  86. package/src/pages/process-detail/inspector/ProcessModelEditor.svelte +161 -0
  87. package/src/pages/process-detail/inspector/ProcessReference.svelte +166 -0
  88. package/src/pages/process-detail/inspector/inspection-activity.ts +118 -0
  89. package/src/pages/process-detail/inspector/inspection-data.svelte.ts +107 -0
  90. package/src/pages/process-detail/inspector/inspection-tool-call.ts +30 -0
  91. package/src/pages/process-detail/inspector/inspector-navigation.ts +190 -0
  92. package/src/pages/process-detail/inspector/model-source-label.ts +17 -0
  93. package/src/pages/process-detail/process-detail-actions.svelte.ts +10 -0
  94. package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +18 -2
  95. package/src/pages/process-detail/process-detail-view-model.ts +2 -2
  96. package/src/shell/AppShell.svelte +5 -0
  97. package/src/shell/Sidebar.svelte +10 -0
  98. package/src/test-support/mount.ts +34 -0
  99. package/dist/assets/ApiTokensPage-ClJp9PYr.js +0 -1
  100. package/dist/assets/ChronicleMarkdown-lqwX9Ywa.js +0 -16
  101. package/dist/assets/FutureLaunchDetailPage-ygp-IdXC.js +0 -1
  102. package/dist/assets/GenericLauncher-CExW6wei.css +0 -1
  103. package/dist/assets/GenericLauncher-DOwsERpB.js +0 -1
  104. package/dist/assets/HomePage-D1J-Rmsw.js +0 -1
  105. package/dist/assets/PageHeader-DPuQInDo.css +0 -1
  106. package/dist/assets/PageHeader-sphJnWL1.js +0 -1
  107. package/dist/assets/ProcessActionsMenu-DV9zaxNS.js +0 -1
  108. package/dist/assets/ProcessDetailPage-BW1M2IH8.js +0 -14
  109. package/dist/assets/ProcessDetailPage-Cth6A0DN.css +0 -1
  110. package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +0 -1
  111. package/dist/assets/ProcessFlowDiagram-Dx2wheGN.js +0 -2
  112. package/dist/assets/ProcessesPage-CSPH5L7E.js +0 -1
  113. package/dist/assets/ScheduleDateTimePicker-DmojMRxN.js +0 -1
  114. package/dist/assets/ScheduleDateTimePicker-uacJAkIq.css +0 -1
  115. package/dist/assets/SkillsPage-KnLql0n1.js +0 -2
  116. package/dist/assets/WatchersPage-B4jf3Ywp.js +0 -1
  117. package/dist/assets/http-client-VpPXJwbR.js +0 -2
  118. package/dist/assets/index-DPCokDbS.js +0 -6
  119. package/dist/assets/index-DtEI5gsQ.css +0 -1
  120. package/dist/assets/mermaid-render.worker-QW2WZpEE.js +0 -6393
  121. package/dist/assets/process-terminal-display-BQRQwGod.js +0 -1
  122. package/dist/assets/router.svelte-EEldxHlO.js +0 -1
  123. package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +0 -855
  124. package/src/components/ProcessInfoOverlay.svelte +0 -1221
  125. package/src/lib/flow-layout.ts +0 -319
  126. package/src/pages/process-detail/OverlayFrame.svelte +0 -58
@@ -0,0 +1,161 @@
1
+ <script lang="ts">
2
+ import type {
3
+ ProcessModelConfigPatch,
4
+ ProcessModelConfigurationView,
5
+ } from "@leitwerk-dev/protocol/http-contracts";
6
+ import { tick } from "svelte";
7
+ import { type ProcessDetailData, updateProcessModelConfig } from "../../../lib/api.js";
8
+ import { loadProcessDetail } from "../../../lib/processes.svelte.js";
9
+ import { modelSourceLabel as sourceLabel } from "./model-source-label.js";
10
+
11
+ let { detail }: { detail: ProcessDetailData } = $props();
12
+ let editing = $state(false);
13
+ let saving = $state(false);
14
+ let previewing = $state(false);
15
+ let error = $state("");
16
+ let notice = $state("");
17
+ let defaultValue = $state("");
18
+ let turnValues = $state<Record<string, string>>({});
19
+ let baseline = $state<ProcessModelConfigurationView | null>(null);
20
+ let preview = $state<ProcessModelConfigurationView | null>(null);
21
+ let editButton = $state<HTMLButtonElement>();
22
+ let defaultSelect = $state<HTMLSelectElement>();
23
+ let revision = 0;
24
+ const configuration = $derived(preview ?? detail.modelConfiguration);
25
+ const editable = $derived(
26
+ !["completed", "aborted"].includes(detail.process.lifecycleStatus) &&
27
+ detail.modelConfiguration.state.kind === "ready",
28
+ );
29
+ const patch = $derived.by((): ProcessModelConfigPatch => {
30
+ const turnConfigs = Object.fromEntries(
31
+ Object.entries(turnValues)
32
+ .filter(
33
+ ([id, value]) =>
34
+ value !==
35
+ (baseline?.turns.find((turn) => turn.turnId === id)?.instanceModelProfileId ?? ""),
36
+ )
37
+ .map(([id, value]) => [id, { modelProfileId: value || null }]),
38
+ );
39
+ return {
40
+ ...(defaultValue !== (baseline?.defaultModel.instanceModelProfileId ?? "")
41
+ ? { defaultModelProfileId: defaultValue || null }
42
+ : {}),
43
+ ...(Object.keys(turnConfigs).length ? { turnConfigs } : {}),
44
+ };
45
+ });
46
+ const dirty = $derived(Object.keys(patch).length > 0);
47
+ async function begin() {
48
+ baseline = detail.modelConfiguration;
49
+ defaultValue = baseline.defaultModel.instanceModelProfileId ?? "";
50
+ turnValues = Object.fromEntries(
51
+ baseline.turns.map((turn) => [turn.turnId, turn.instanceModelProfileId ?? ""]),
52
+ );
53
+ preview = null;
54
+ error = "";
55
+ notice = "";
56
+ editing = true;
57
+ await tick();
58
+ defaultSelect?.focus();
59
+ }
60
+ async function cancel() {
61
+ revision++;
62
+ editing = false;
63
+ preview = null;
64
+ error = "";
65
+ previewing = false;
66
+ await tick();
67
+ editButton?.focus();
68
+ }
69
+ async function refreshPreview() {
70
+ const current = ++revision;
71
+ error = "";
72
+ previewing = true;
73
+ try {
74
+ const result = await updateProcessModelConfig(detail.process.id, patch, true);
75
+ if (current === revision) preview = result.modelConfiguration;
76
+ } catch (cause) {
77
+ if (current === revision)
78
+ error = cause instanceof Error ? cause.message : "Couldn't preview model settings";
79
+ } finally {
80
+ if (current === revision) previewing = false;
81
+ }
82
+ }
83
+ async function save() {
84
+ if (saving || !editable) return;
85
+ saving = true;
86
+ error = "";
87
+ try {
88
+ await updateProcessModelConfig(detail.process.id, patch);
89
+ await loadProcessDetail(detail.process.id);
90
+ await cancel();
91
+ notice = "Model settings saved. Future executions will use these settings.";
92
+ } catch (cause) {
93
+ error =
94
+ cause instanceof Error
95
+ ? cause.message
96
+ : "Couldn't save model settings. Your draft is retained.";
97
+ } finally {
98
+ saving = false;
99
+ }
100
+ }
101
+ </script>
102
+ <div class="model-settings">
103
+ <p class="note">Changes apply to future executions and inherited scheduled actions. The current execution keeps its model.</p>
104
+ <p class="note">Default at creation: {detail.process.initialDefaultModelProfileId ?? "Not recorded"}</p>
105
+ {#if detail.modelConfiguration.state.kind === "blocked"}
106
+ <p role="alert">Saved model configuration is malformed and must be repaired before editing.</p>
107
+ {:else if editing}
108
+ <form onchange={refreshPreview} onsubmit={event => { event.preventDefault(); void save(); }}>
109
+ <fieldset disabled={saving || !editable}>
110
+ <div class="model-field">
111
+ <label for="instance-default-model">Default profile</label>
112
+ <select id="instance-default-model" bind:this={defaultSelect} bind:value={defaultValue}>
113
+ <option value="">Use inherited values by purpose</option>
114
+ {#each detail.modelConfiguration.availableProfiles as option (option.id)}<option value={option.id} disabled={option.availability !== "available"}>{option.label}{option.availability !== "available" ? ` · ${option.availability}` : ""}</option>{/each}
115
+ </select>
116
+ <p class="note">Effective default: {configuration.defaultModel.effectiveModelProfileId ?? "Not configured"}</p>
117
+ </div>
118
+ <p class="note">Clearing a step override restores the instance default, then inherited purpose and configured defaults.</p>
119
+ {#each configuration.turns as turn (turn.turnId)}
120
+ <div class="model-field">
121
+ {#if turn.fixedModelProfileId}
122
+ <span>{turn.description}</span><p>{turn.fixedModelProfileId}</p><p class="note">Fixed system model. This step cannot be overridden.</p>
123
+ {:else}
124
+ <label for={`step-model-${turn.turnId}`}>{turn.description}</label>
125
+ <select id={`step-model-${turn.turnId}`} bind:value={turnValues[turn.turnId]}>
126
+ <option value="">Use inherited value</option>
127
+ {#each detail.modelConfiguration.availableProfiles as option (option.id)}<option value={option.id} disabled={option.availability !== "available"}>{option.label}{option.availability !== "available" ? ` · ${option.availability}` : ""}</option>{/each}
128
+ </select>
129
+ {#if turn.effectiveError}<p role="alert">{turn.effectiveError}</p>{/if}
130
+ <p class="note">{turn.effectiveModelProfileId ?? turn.effectiveConfiguredModelProfileId ?? configuration.defaultModel.effectiveModelProfileId ?? "Not configured"} · {sourceLabel(turn.effectiveSource ?? turn.source)}</p>
131
+ {/if}
132
+ </div>
133
+ {/each}
134
+ </fieldset>
135
+ {#if !editable}<p role="status">This process is now read-only. Your draft has not been saved.</p>{/if}
136
+ <div class="actions"><button class="ui-button" type="submit" disabled={saving || previewing || !dirty || !editable}>{saving ? "Saving…" : "Save changes"}</button><button class="ui-button" type="button" disabled={saving} onclick={cancel}>Cancel</button><span class="note" role="status">{previewing ? "Updating preview…" : ""}</span></div>
137
+ </form>
138
+ {:else}
139
+ <dl><div><dt>Current default</dt><dd>{configuration.defaultModel.effectiveModelProfileId ?? "Not configured"}</dd></div>
140
+ {#each configuration.turns as turn (turn.turnId)}<div><dt>{turn.description}</dt><dd>{turn.effectiveModelProfileId ?? turn.effectiveConfiguredModelProfileId ?? configuration.defaultModel.effectiveModelProfileId ?? "Not configured"}<span class="note"> · {turn.fixedModelProfileId ? "Fixed system model" : sourceLabel(turn.effectiveSource ?? turn.source)}</span></dd></div>{/each}
141
+ </dl>
142
+ {#if editable}<button class="ui-button" bind:this={editButton} onclick={begin}>Edit models</button>{/if}
143
+ {/if}
144
+ {#if error}<p role="alert">{error}</p>{/if}
145
+ <p role="status">{notice}</p>
146
+ </div>
147
+ <style>
148
+ .model-settings,form,fieldset {display:grid; gap:var(--space-md); min-width:0;}
149
+ fieldset {padding:0; margin:0; border:0;}
150
+ .model-field {display:grid; gap:var(--space-xs); min-width:0;}
151
+ label {font-weight:600;} p,dd,dl {margin:0;}
152
+ p,dl,label,select {font-size:var(--type-body-sm); line-height:1.6;}
153
+ .note,dt {color:var(--chronicle-text-muted);}
154
+ select {width:100%; min-width:0; padding:var(--space-sm); color:var(--chronicle-text); background:var(--chronicle-panel-surface); border:1px solid var(--chronicle-border); border-radius:var(--radius-sm);}
155
+ select:focus-visible {outline:2px solid var(--chronicle-accent); outline-offset:2px;}
156
+ select:disabled {opacity:0.65;}
157
+ dl {display:grid; gap:var(--space-md);} dl > div {display:grid; grid-template-columns:minmax(120px,1fr) 2fr; gap:var(--space-md);}
158
+ .actions {display:flex; gap:var(--space-sm); flex-wrap:wrap; align-items:center;}
159
+ .ui-button {justify-self:start;}
160
+ @media(max-width:720px) {dl > div {grid-template-columns:1fr; gap:var(--space-xs);}}
161
+ </style>
@@ -0,0 +1,166 @@
1
+ <script lang="ts">
2
+ import { tick } from "svelte";
3
+ import ChronicleMarkdown from "../../../chronicle/components/ChronicleMarkdown.svelte";
4
+ import ChronicleUsageStats from "../../../chronicle/components/ChronicleUsageStats.svelte";
5
+ import ConversationTreeDiagram from "../../../components/ConversationTreeDiagram.svelte";
6
+ import ExternalLink from "../../../components/ExternalLink.svelte";
7
+ import ProcessSettings from "../../../components/ProcessSettings.svelte";
8
+ import type { ProcessDetailData } from "../../../lib/api.js";
9
+ import { buildInspectorPath, type InspectorTarget } from "../../../lib/router-logic.js";
10
+ import ProcessFlowDiagram from "../../ProcessFlowDiagram.svelte";
11
+ import InspectionEvidence from "./InspectionEvidence.svelte";
12
+ import type { ChronicleTarget } from "./inspector-navigation.js";
13
+ import { modelSourceLabel as sourceLabel } from "./model-source-label.js";
14
+ import ProcessModelEditor from "./ProcessModelEditor.svelte";
15
+
16
+ let {
17
+ detail,
18
+ target,
19
+ onNavigate,
20
+ onChronicle,
21
+ onShowSummary,
22
+ onReady,
23
+ }: {
24
+ detail: ProcessDetailData;
25
+ target: Extract<InspectorTarget, { scope: "process" | "step" }>;
26
+ onNavigate: (target: InspectorTarget) => void;
27
+ onChronicle: (target: ChronicleTarget) => void;
28
+ onShowSummary?: () => void;
29
+ onReady?: () => boolean | void;
30
+ } = $props();
31
+ const node = $derived(
32
+ target.scope === "step"
33
+ ? detail.processFlow.nodes.find((node) => node.turnId === target.turnId)
34
+ : null,
35
+ );
36
+ const definition = $derived(detail.runDetails.turns.find((turn) => turn.turnId === node?.turnId));
37
+ const model = $derived(
38
+ detail.modelConfiguration.turns.find((turn) => turn.turnId === node?.turnId),
39
+ );
40
+ const transitions = $derived(detail.processFlow.edges.filter((edge) => edge.from === node?.turnId));
41
+ const usage = $derived(detail.usageEstimate);
42
+ const resources = $derived(
43
+ detail.timeline.turns.flatMap((turn) =>
44
+ (turn.resources ?? []).map((link) => ({ ...link, turnRecordId: turn.id })),
45
+ ),
46
+ );
47
+ const request = $derived(detail.timeline.prompt.text);
48
+ const parameters = $derived(
49
+ detail.launchConfiguration.parameters.filter((parameter) => parameter.value !== request),
50
+ );
51
+ const source = $derived(
52
+ detail.process.externalId ?? detail.launchConfiguration.launcherLabel ?? "Source",
53
+ );
54
+ let contextView = $state<"map" | "list">("map");
55
+ let contextList = $state<HTMLUListElement>();
56
+ $effect(() => {
57
+ const selected = target;
58
+ if (
59
+ selected.scope === "process" &&
60
+ selected.section === "context-map" &&
61
+ detail.instanceTree.nodes.length
62
+ )
63
+ return;
64
+ let cancelled = false;
65
+ void tick().then(() => {
66
+ if (!cancelled) onReady?.();
67
+ });
68
+ return () => {
69
+ cancelled = true;
70
+ };
71
+ });
72
+ $effect(() => {
73
+ const list = contextList;
74
+ const selected = target.scope === "process" ? target.turnRecordId : undefined;
75
+ if (!list || !selected) return;
76
+ let cancelled = false;
77
+ void tick().then(() => {
78
+ if (cancelled || onReady?.()) return;
79
+ const item = list.querySelector<HTMLElement>(".selected");
80
+ if (item) list.scrollTop = item.offsetTop - (list.clientHeight - item.clientHeight) / 2;
81
+ });
82
+ return () => {
83
+ cancelled = true;
84
+ };
85
+ });
86
+ function selectStep(turnId: string) {
87
+ onNavigate({ scope: "step", turnId });
88
+ }
89
+ function selectExecution(turnRecordId: string) {
90
+ onNavigate({ scope: "execution", turnRecordId, section: "context" });
91
+ }
92
+ </script>
93
+ <div class="process-reference" class:workflow-map={target.scope === "process" && target.section === "workflow"} class:process-overview={target.scope === "process" && target.section === "overview"} class:context-map={target.scope === "process" && target.section === "context-map"}>
94
+ {#if target.scope === "step"}
95
+ {#if !node}<p class="notice" role="status">This step is unavailable in the current workflow. Its recorded executions remain in the chronicle.</p>
96
+ {:else}
97
+ <p class="reference-note">Current workflow definition · {node.turnType} step</p>
98
+ <section><h2>Purpose</h2><p>{node.description}</p><code>{node.turnId}</code></section>
99
+ <button class="ui-button" onclick={() => onChronicle({turnId:node.turnId})}>Reveal matching executions in chronicle</button>
100
+ <section><h2>Input and output contracts</h2>
101
+ {#if definition}<dl><div><dt>Declared inputs</dt><dd>{(definition.consumedProducts ?? []).join(", ") || "No named products declared"}</dd></div><div><dt>Published products</dt><dd>{(definition.publishedProducts ?? []).join(", ") || "No named products declared"}</dd></div></dl><p class="note">Declarations describe possible inputs. Execution Context shows which versions were actually supplied.</p>
102
+ {#if definition.definitionContract}<InspectionEvidence label="Current step contract" evidence={{state:"recorded", value:definition.definitionContract}} />{/if}
103
+ {#each definition.outcomeActions as outcome (outcome.name)}<InspectionEvidence label={`${outcome.name} · ${outcome.description}`} evidence={{state:"recorded", value:outcome.parameters}} id={`contract:${node.turnId}:${outcome.name}`} />{/each}
104
+ {:else}<p class="note">No inspectable input or output schema is exposed by this definition.</p>{/if}
105
+ </section>
106
+ {#if node.turnType === "llm"}
107
+ <section><h2>Current model policy</h2><p>{model?.effectiveConfiguredModelProfileId ?? detail.modelConfiguration.defaultModel.effectiveModelProfileId ?? "No configured model"}</p><p class="note">{sourceLabel(model?.source ?? detail.modelConfiguration.defaultModel.source)}</p></section>
108
+ <section><h2>Available tools</h2><p>{[...(definition?.activePiToolNames ?? []), ...(definition?.integrationToolNames ?? [])].join(", ") || "No built-in tools declared"}</p><p class="note">These are current declarations. Recorded tool definitions are in each execution’s Configuration.</p></section>
109
+ <section><h2>Current instructions reference</h2><InspectionEvidence label="Current system prompt setting" evidence={detail.runDetails.systemPrompt === null ? {state:"not_recorded", reason:"No process-level system prompt override is configured. This does not describe the effective prompt of a past execution."} : {state:"recorded", value:detail.runDetails.systemPrompt}} /><InspectionEvidence label="Current appended instructions setting" evidence={{state:"recorded", value:detail.runDetails.appendSystemPrompt ?? ""}} /></section>
110
+ {:else}<p class="note">This {node.turnType} step does not invoke a model.</p>{/if}
111
+ <section><h2>Possible transitions</h2><ul class="transition-list">{#each transitions as edge}<li><span>{edge.label ?? edge.kind}</span>{#if edge.to}<button class="text-link" onclick={() => selectStep(edge.to ?? "")}>{detail.processFlow.nodes.find(node => node.turnId === edge.to)?.description ?? edge.to}</button>{:else}<span>{edge.lifecycleStatus}</span>{/if}</li>{:else}<li>No static transitions declared.</li>{/each}</ul></section>
112
+ {/if}
113
+ {:else if target.section === "overview"}
114
+ <section><h2>Run overview</h2><dl class="fact-grid"><div><dt>Status</dt><dd>{detail.process.lifecycleStatus}</dd></div><div><dt>Process</dt><dd>{detail.processDisplayName ?? detail.process.processId}</dd></div><div><dt>Created</dt><dd><time datetime={detail.process.createdAt}>{new Date(detail.process.createdAt).toLocaleString()}</time></dd></div><div><dt>Last updated</dt><dd><time datetime={detail.process.updatedAt}>{new Date(detail.process.updatedAt).toLocaleString()}</time></dd></div><div><dt>Run ID</dt><dd><code>{detail.process.id}</code></dd></div><div><dt>Source</dt><dd>{#if detail.process.externalUrl}<ExternalLink href={detail.process.externalUrl} label={source} />{:else}{detail.process.externalId ?? detail.launchConfiguration.launcherLabel ?? "Not recorded"}{/if}</dd></div></dl>
115
+ {#if onShowSummary}<button class="ui-button" onclick={onShowSummary}>Show process summary</button>{/if}
116
+ </section>
117
+ <section><h2>Usage and cost</h2>{#if detail.usageEstimate?.historyLimited}<p class="note">Totals cover the most recent steps loaded with this process.</p>{/if}{#if usage}<ChronicleUsageStats usage={usage.usage} size="md" /><p class="note">{usage.coveredTurnCount}/{usage.totalLlmTurnCount} model executions with usage · {usage.missingUsageTurnCount} missing usage · {usage.missingCostTurnCount} missing cost{usage.isPartial ? " · Partial totals" : ""}</p>{:else}<p class="note">No usage recorded.</p>{/if}</section>
118
+ {#if detail.launchConfiguration.projects.length}<section><h2>Recorded repositories and branches</h2><p class="note">Repository configuration does not prove a repository was changed.</p>{#each detail.launchConfiguration.projects as project (project.key)}<div class="repository"><div class="repository-identity"><h3>{#if project.externalUrl}<ExternalLink href={project.externalUrl} label={project.key} resourceType="project" />{:else}{project.key}{/if}</h3><p><code>{project.repoLocator}</code></p></div><dl class="repository-branches"><div><dt>Base branch</dt><dd>{project.baseBranch}</dd></div><div><dt>Work branch</dt><dd>{project.workBranch ?? "Not recorded"}</dd></div></dl></div>{/each}</section>{/if}
119
+ <section><h2>Deliverables and evidence</h2>{#if resources.length}<ul class="resource-list">{#each resources as resource (`${resource.turnRecordId}:${resource.id}`)}<li><ExternalLink href={resource.url} label={resource.label} /><button class="text-link" onclick={() => onNavigate({scope:"execution", turnRecordId:resource.turnRecordId, section:"trace"})}>Recorded by execution</button></li>{/each}</ul>{:else}<p class="note">No deliverable links were recorded. Results and decisions remain in the chronicle.</p>{/if}</section>
120
+ {:else if target.section === "workflow"}
121
+ <section><h2>Workflow</h2><p class="reference-note">Current definition · A launch-time graph snapshot was not retained.</p><ProcessFlowDiagram flow={detail.processFlow} mode="full" onSelectTurn={selectStep} />
122
+ <nav class="step-list" aria-label="Workflow steps">{#each detail.processFlow.nodes as step (step.turnId)}<a href={buildInspectorPath(detail.process.id, {scope:"step", turnId:step.turnId})} onclick={event => {if (!event.metaKey && !event.ctrlKey) {event.preventDefault(); selectStep(step.turnId);}}}><span>{step.description}</span><span class="note">{step.turnType}</span></a>{/each}</nav></section>
123
+ {:else if target.section === "inputs"}
124
+ <section><h2>Original request</h2>{#if request}<ChronicleMarkdown markdown={request} /><InspectionEvidence label="Raw original request" evidence={{state:"recorded", value:request}} />{:else}<p class="note">No original request was recorded.</p>{/if}</section>
125
+ <section><h2>Recorded launch parameters</h2>{#if detail.launchConfiguration.paramsParseError}<p class="notice">{detail.launchConfiguration.paramsParseError}</p>{/if}<dl>{#each parameters as parameter (parameter.fieldId)}<div><dt>{parameter.label}</dt><dd>{parameter.value ?? "Not set"}</dd></div>{:else}<div><dd>No additional launch parameters recorded.</dd></div>{/each}</dl><InspectionEvidence label="Raw launch values" evidence={{state:"recorded", value:Object.fromEntries(detail.launchConfiguration.parameters.map(parameter => [parameter.fieldId, parameter.rawValue ?? parameter.value]))}} /></section>
126
+ <section><h2>Model defaults and overrides</h2><ProcessModelEditor {detail} /></section>
127
+ {#key detail.process.id}<ProcessSettings instanceId={detail.process.id} refreshVersion={detail.process.updatedAt} />{/key}
128
+ <InspectionEvidence label="Launcher and infrastructure details" evidence={{state:"recorded", value:{launcherId:detail.launchConfiguration.launcherId, launcher:detail.launchConfiguration.launcherLabel, form:detail.launchConfiguration.launcherSchemaTitle, projects:detail.launchConfiguration.projects}}} />
129
+ {:else if target.section === "context-map"}
130
+ <section class="context-map-section">
131
+ <div class="context-heading"><h2>Context map</h2><div class="context-views" role="group" aria-label="Context map view"><button class="ui-button" aria-pressed={contextView === "map"} onclick={() => contextView = "map"}>Map</button><button class="ui-button" aria-pressed={contextView === "list"} onclick={() => contextView = "list"}>List</button></div></div>
132
+ <details class="map-description" data-disclosure-key="context-map-description"><summary>About this map</summary><p class="note">Conversation inheritance and explicitly supplied products. Unconnected executions can have unknown context; they are not assumed to be fresh.</p></details>
133
+ {#if target.turnRecordId && !detail.instanceTree.nodes.some(node => node.id === target.turnRecordId)}<p class="notice" role="status">The selected execution is unavailable in this process.</p>{/if}
134
+ {#if !detail.instanceTree.nodes.length}<p class="note">No execution context has been recorded yet.</p>
135
+ {:else if contextView === "map"}<ConversationTreeDiagram tree={detail.instanceTree} selectedTurnRecordId={target.turnRecordId} onSelectExecution={selectExecution} {onReady} />
136
+ {:else}
137
+ <h3>Context ancestry list · {detail.instanceTree.nodes.length} executions</h3>
138
+ <ul class="context-list" bind:this={contextList} aria-label="Context ancestry list" tabindex="0">{#each detail.instanceTree.nodes as execution (execution.id)}<li class:selected={target.turnRecordId === execution.id}><button class="text-link" onclick={() => selectExecution(execution.id)}>{execution.label} · {execution.resultState}</button><p class="note">{execution.origin?.summary ?? "Context origin not recorded"}</p>{#each detail.instanceTree.edges.filter(edge => edge.targetNodeId === execution.id && edge.productLabels.length) as edge (edge.id)}<p class="note">Supplied {edge.productLabels.join(", ")} from <button class="text-link" onclick={() => selectExecution(edge.sourceNodeId)}>{detail.instanceTree.nodes.find(node => node.id === edge.sourceNodeId)?.label ?? edge.sourceNodeId}</button></p>{/each}</li>{/each}</ul>
139
+ {/if}
140
+ </section>
141
+ {/if}
142
+ </div>
143
+ <style>
144
+ .process-reference {max-width:960px; margin:0 auto; display:grid; gap:var(--space-lg); min-width:0; overflow-wrap:anywhere;}
145
+ .workflow-map {max-width:none;}
146
+ .process-overview {gap:var(--space-md);} .process-overview section {gap:var(--space-xs); padding-bottom:var(--space-md);}
147
+ section {display:grid; gap:var(--space-md); padding-bottom:var(--space-lg); border-bottom:1px solid var(--chronicle-border); min-width:0;}
148
+ h2,h3,p,dl,dd {margin:0;} h2 {font-size:var(--type-title-sm); font-weight:650;} h3 {font-size:var(--type-body); font-weight:650;} p,dl,li {font-size:var(--type-body-sm); line-height:1.65;}
149
+ .note,.reference-note,dt {color:var(--chronicle-text-muted);} .reference-note {padding:var(--space-sm) var(--space-md); background:var(--chronicle-panel-muted); border-radius:var(--radius-sm);}
150
+ dl {display:grid; gap:var(--space-md);} dl > div {display:grid; grid-template-columns:minmax(120px,1fr) 2fr; gap:var(--space-md);} .fact-grid {grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-xs) var(--space-lg);} .fact-grid > div {grid-template-columns:6rem minmax(0,1fr); gap:var(--space-xs); align-items:baseline;} dt {font-size:var(--type-caption);} code {font-size:var(--type-caption); overflow-wrap:anywhere;}
151
+ .repository {display:grid; grid-template-columns:minmax(0,1.4fr) minmax(0,1fr); gap:var(--space-md); padding:var(--space-xs) 0; align-items:start;} .repository-identity {display:grid; gap:var(--space-2xs);} .repository-branches {grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-sm);} .repository-branches > div {display:block;} .ui-button {justify-self:start;}
152
+ .text-link {border:0; padding:var(--space-xs) 0; background:transparent; color:var(--chronicle-accent); font:inherit; font-size:var(--type-body-sm); cursor:pointer; text-align:left; text-decoration:underline; text-underline-offset:3px;}
153
+ .text-link:focus-visible,.step-list a:focus-visible {outline:2px solid var(--chronicle-accent); outline-offset:3px;}
154
+ .step-list {display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-sm) var(--space-lg);} .step-list a {display:flex; align-items:baseline; justify-content:space-between; gap:var(--space-md); padding:var(--space-sm) 0; border-bottom:1px solid var(--chronicle-border); color:var(--chronicle-accent); font-size:var(--type-body-sm); text-decoration:none;}
155
+ .transition-list,.resource-list,.context-list {list-style:none; padding:0; margin:0; display:grid; gap:var(--space-sm);} .transition-list li,.resource-list li {display:flex; gap:var(--space-md); align-items:baseline; flex-wrap:wrap;}
156
+ .context-map {max-width:none; height:100%; display:flex; flex-direction:column;}
157
+ .context-map-section {flex:1; min-height:0; display:flex; flex-direction:column; gap:var(--space-xs); padding-bottom:0; border-bottom:0;}
158
+ .context-heading {display:flex; align-items:center; justify-content:space-between; gap:var(--space-sm); flex-wrap:wrap;}
159
+ .context-views {display:flex; gap:var(--space-2xs);} .context-views [aria-pressed="true"] {background:var(--chronicle-accent-soft); border-color:var(--chronicle-accent); color:var(--chronicle-accent);}
160
+ .map-description {font-size:var(--type-body-sm);} .map-description summary {cursor:pointer; color:var(--chronicle-text-muted);} .map-description p {margin-top:var(--space-xs);}
161
+ .context-list {position:relative; flex:1; min-height:0; overflow:auto; align-content:start; gap:0; overscroll-behavior:contain;}
162
+ .context-list li {padding:var(--space-xs) var(--space-sm); border-bottom:1px solid var(--chronicle-border);} .context-list li.selected {background:var(--chronicle-accent-soft);}
163
+ .context-list:focus-visible,.map-description summary:focus-visible {outline:2px solid var(--chronicle-accent); outline-offset:2px;}
164
+ .notice {padding:var(--space-md); background:var(--chronicle-panel-muted); border-radius:var(--radius-sm);}
165
+ @media(max-width:720px) {.fact-grid,.step-list,.repository {grid-template-columns:1fr;} dl > div {grid-template-columns:1fr; gap:var(--space-xs);} .fact-grid > div {grid-template-columns:6rem minmax(0,1fr);} .repository {gap:var(--space-xs);} }
166
+ </style>
@@ -0,0 +1,118 @@
1
+ import type { ProcessEvent } from "@leitwerk-dev/domain";
2
+ import type {
3
+ ExecutionInspectionTrace,
4
+ InspectionTraceMessage,
5
+ TurnTraceSnapshot,
6
+ } from "@leitwerk-dev/protocol";
7
+
8
+ export type InspectionActivity =
9
+ | { kind: "message"; id: string; timestamp: string; message: InspectionTraceMessage }
10
+ | { kind: "event"; id: string; timestamp: string; event: ProcessEvent };
11
+ /** A presentation of the reconciler's ordered events, with durable message aliases. */
12
+ export function inspectionActivity(
13
+ trace: ExecutionInspectionTrace,
14
+ events: readonly ProcessEvent[],
15
+ live: TurnTraceSnapshot | null,
16
+ ): InspectionActivity[] {
17
+ const messages = [...trace.messages];
18
+ const aliases = new Set(messages.flatMap((m) => m.aliases));
19
+ const streamed: InspectionTraceMessage[] = [];
20
+ const operations: InspectionActivity[] = [];
21
+ let assistant: InspectionTraceMessage | null = null;
22
+ let previousTurn: unknown;
23
+ for (const event of events) {
24
+ const id = `event:${event.eventSequence ?? event.id}`;
25
+ const data = event.data;
26
+ const type = event.eventType;
27
+ if (type === "pi.stream.delta") {
28
+ if (aliases.has(id)) continue;
29
+ if (!assistant || previousTurn !== data.turnId) {
30
+ assistant = {
31
+ id,
32
+ entryId: null,
33
+ aliases: [],
34
+ role: "assistant",
35
+ timestamp: event.createdAt,
36
+ blocks: [],
37
+ toolCallId: null,
38
+ toolName: null,
39
+ isError: false,
40
+ };
41
+ streamed.push(assistant);
42
+ }
43
+ previousTurn = data.turnId;
44
+ assistant.aliases.push(id);
45
+ const text = typeof data.text === "string" ? data.text : "";
46
+ const thinking = data.streamType === "thinking";
47
+ const last = assistant.blocks.at(-1)?.content;
48
+ if (thinking && last?.type === "thinking") last.thinking += text;
49
+ else if (!thinking && last?.type === "text") last.text += text;
50
+ else
51
+ assistant.blocks.push({
52
+ id,
53
+ content: thinking ? { type: "thinking", thinking: text } : { type: "text", text },
54
+ });
55
+ } else if (
56
+ ["pi.tool.call", "pi.tool.started", "pi.tool.result", "pi.tool.completed"].includes(type)
57
+ ) {
58
+ assistant = null;
59
+ if (aliases.has(id)) continue;
60
+ const tool = live?.toolCalls.find((tool) => tool.toolCallId === data.toolCallId);
61
+ if (!tool) continue;
62
+ const result = type === "pi.tool.result" || type === "pi.tool.completed";
63
+ streamed.push({
64
+ id,
65
+ entryId: null,
66
+ aliases: [],
67
+ role: result ? "toolResult" : "assistant",
68
+ timestamp: event.createdAt,
69
+ blocks: [
70
+ {
71
+ id: `${id}:content`,
72
+ content: result
73
+ ? { type: "text", text: tool.resultText ?? "Result not recorded" }
74
+ : {
75
+ type: "toolCall",
76
+ id: tool.toolCallId,
77
+ name: tool.toolName,
78
+ arguments: tool.arguments ?? {},
79
+ },
80
+ },
81
+ ],
82
+ toolCallId: result ? tool.toolCallId : null,
83
+ toolName: result ? tool.toolName : null,
84
+ isError: tool.isError,
85
+ });
86
+ } else if (
87
+ !type.endsWith("usage") &&
88
+ !["pi.turn.start", "pi.turn.end", "pi.stream.started", "pi.stream.completed"].includes(type)
89
+ ) {
90
+ operations.push({ kind: "event", id, timestamp: event.createdAt, event });
91
+ } else assistant = null;
92
+ }
93
+ const result: InspectionActivity[] = [...messages, ...streamed].map((message) => ({
94
+ kind: "message" as const,
95
+ id: message.id,
96
+ timestamp: message.timestamp,
97
+ message,
98
+ }));
99
+ const selected = trace.target?.state === "available" ? trace.target.itemId : null;
100
+ if (
101
+ selected?.startsWith("event:") &&
102
+ ![...result, ...operations].some(
103
+ (item) =>
104
+ item.id === selected ||
105
+ (item.kind === "message" && item.message.aliases.includes(selected)),
106
+ )
107
+ ) {
108
+ const event = events.find((event) => `event:${event.eventSequence}` === selected);
109
+ if (event) operations.push({ kind: "event", id: selected, timestamp: event.createdAt, event });
110
+ }
111
+ const sequence = (item: InspectionActivity) =>
112
+ item.id.startsWith("event:") ? Number(item.id.slice(6)) : null;
113
+ return [...result, ...operations].sort((a, b) => {
114
+ const left = sequence(a),
115
+ right = sequence(b);
116
+ return left !== null && right !== null ? left - right : a.timestamp.localeCompare(b.timestamp);
117
+ });
118
+ }
@@ -0,0 +1,107 @@
1
+ import type { ExecutionInspectionSummary } from "@leitwerk-dev/protocol";
2
+ import { onDestroy, tick, untrack } from "svelte";
3
+ import { fetchExecutionInspection, type InspectionSections } from "../../../lib/api.js";
4
+ import { subscribeReasoningFrames } from "../../../lib/processes.svelte.js";
5
+ import { ReasoningHistory } from "../../../lib/reasoning-history.js";
6
+ import type { InspectorRoute } from "../../../lib/router-logic.js";
7
+
8
+ class InspectionData {
9
+ summary = $state.raw<ExecutionInspectionSummary | null>(null);
10
+ summaryError = $state<string | null>(null);
11
+ expanded = $state.raw<Partial<InspectionSections>>({});
12
+ error = $state<string | null>(null);
13
+ loading = $state(false);
14
+ loadedTraceTarget = $state("");
15
+ live = $state.raw<ReturnType<ReasoningHistory["snapshot"]> | null>(null);
16
+ activity = $state(0);
17
+ }
18
+
19
+ export function createInspectionData(args: {
20
+ get instanceId(): string;
21
+ get target(): NonNullable<InspectorRoute>;
22
+ get refreshKey(): string;
23
+ ready(): void;
24
+ }) {
25
+ const data = new InspectionData();
26
+ let selected = "";
27
+ let controller: AbortController | null = null;
28
+ let history: ReasoningHistory | null = null;
29
+ const unsubscribe = subscribeReasoningFrames((frame) => {
30
+ if (args.target.scope !== "execution" || args.target.section !== "trace" || !history) return;
31
+ const next = history.push(frame);
32
+ if (next) {
33
+ data.live = next;
34
+ data.activity++;
35
+ }
36
+ });
37
+ async function load() {
38
+ controller?.abort();
39
+ const target = args.target;
40
+ if (target.scope !== "execution") return;
41
+ const targetKey = JSON.stringify(target);
42
+ const instanceId = args.instanceId;
43
+ const key = `${instanceId}/${target.turnRecordId}`;
44
+ const abort = new AbortController();
45
+ controller = abort;
46
+ if (selected !== key) {
47
+ selected = key;
48
+ data.summary = null;
49
+ data.summaryError = null;
50
+ data.expanded = {};
51
+ data.live = null;
52
+ data.activity = 0;
53
+ history = new ReasoningHistory(instanceId, target.turnRecordId);
54
+ }
55
+ data.error = null;
56
+ data.loading = true;
57
+ if (target.section === "trace") history?.beginRequest();
58
+ await tick();
59
+ if (abort.signal.aborted) return;
60
+ void fetchExecutionInspection(instanceId, target.turnRecordId, "summary", {}, abort.signal)
61
+ .then((value) => {
62
+ if (!abort.signal.aborted) {
63
+ data.summary = value;
64
+ data.summaryError = null;
65
+ }
66
+ })
67
+ .catch((cause) => {
68
+ if (!abort.signal.aborted) data.summaryError = cause.message;
69
+ });
70
+ try {
71
+ const value = await fetchExecutionInspection(
72
+ instanceId,
73
+ target.turnRecordId,
74
+ target.section,
75
+ target,
76
+ abort.signal,
77
+ );
78
+ if (abort.signal.aborted) return;
79
+ data.expanded = { ...data.expanded, [target.section]: value };
80
+ if (target.section === "trace" && "reasoning" in value && history) {
81
+ data.live = history.accept(value);
82
+ data.loadedTraceTarget = targetKey;
83
+ }
84
+ data.loading = false;
85
+ await tick();
86
+ if (!abort.signal.aborted && target.section !== "trace") args.ready();
87
+ } catch (cause) {
88
+ if (abort.signal.aborted) return;
89
+ history?.failedRequest();
90
+ data.loading = false;
91
+ data.error = cause instanceof Error ? cause.message : "Couldn't load execution evidence";
92
+ }
93
+ }
94
+ $effect(() => {
95
+ args.target;
96
+ args.instanceId;
97
+ args.refreshKey;
98
+ untrack(() => {
99
+ void load();
100
+ });
101
+ });
102
+ onDestroy(() => {
103
+ controller?.abort();
104
+ unsubscribe();
105
+ });
106
+ return Object.assign(data, { retry: load });
107
+ }
@@ -0,0 +1,30 @@
1
+ import type { InspectionTraceMessage, TurnTraceSnapshot } from "@leitwerk-dev/protocol";
2
+
3
+ /** Correlate retained outcomes without inferring success from a missing live projection. @internal */
4
+ export function inspectionToolCall(
5
+ call: Extract<InspectionTraceMessage["blocks"][number]["content"], { type: "toolCall" }>,
6
+ timestamp: string,
7
+ messages: readonly InspectionTraceMessage[],
8
+ live: TurnTraceSnapshot | null,
9
+ ) {
10
+ const recorded = live?.toolCalls.find((tool) => tool.toolCallId === call.id);
11
+ if (recorded) return recorded;
12
+ const result = messages.find(
13
+ (message) => message.role === "toolResult" && message.toolCallId === call.id,
14
+ );
15
+ return {
16
+ toolCallId: call.id,
17
+ toolName: call.name,
18
+ arguments: call.arguments,
19
+ status: result ? ("completed" as const) : ("unknown" as const),
20
+ startedAt: timestamp,
21
+ completedAt: result?.timestamp ?? null,
22
+ resultText: result
23
+ ? result.blocks
24
+ .flatMap((block) => (block.content.type === "text" ? [block.content.text] : []))
25
+ .join("\n")
26
+ : null,
27
+ truncated: false,
28
+ isError: result?.isError ?? false,
29
+ };
30
+ }