Compare commits
6 Commits
cfd338028a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f83311d94 | |||
|
|
36731aac1d | ||
|
|
3d85cc6b8c | ||
|
|
52eaf661c4 | ||
| e93158f670 | |||
|
|
2c6c961e08 |
@@ -84,7 +84,6 @@ src/
|
||||
lib/
|
||||
components/ Svelte components (Backdrop, PageHeader, MessageInput, ...)
|
||||
composables/ Reactive composables (useOrchestration)
|
||||
data/ Sample/demo data generators
|
||||
proto/ Generated protobuf TypeScript
|
||||
services/ gRPC client (orchestrator)
|
||||
stores/ Svelte 5 reactive stores (sessions, audit, memory, theme, ...)
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
| #18 | Dark/light theme toggle | COMPLETED | [issue-018.md](issue-018.md) |
|
||||
| #19 | Responsive layout and mobile support | COMPLETED | [issue-019.md](issue-019.md) |
|
||||
| #20 | Error handling and connection status | COMPLETED | [issue-020.md](issue-020.md) |
|
||||
| #43 | Display inference statistics in chat UI | COMPLETED | [issue-043.md](issue-043.md) |
|
||||
|
||||
60
implementation-plans/issue-043.md
Normal file
60
implementation-plans/issue-043.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Issue #43: Display Inference Statistics in Chat UI
|
||||
|
||||
**Status:** COMPLETED
|
||||
**Issue:** [#43](https://git.shahondin1624.de/llm-multiverse/llm-multiverse-ui/issues/43)
|
||||
**Branch:** `feature/issue-43-inference-stats`
|
||||
|
||||
## Overview
|
||||
|
||||
Add a collapsible UI panel that displays LLM inference statistics (token counts, context window utilization, throughput) below assistant messages after orchestration completes.
|
||||
|
||||
## Phases
|
||||
|
||||
### Phase 1: Proto Types
|
||||
|
||||
**Files:**
|
||||
- `proto/upstream/proto/llm_multiverse/v1/common.proto` — Add `InferenceStats` message
|
||||
- `proto/upstream/proto/llm_multiverse/v1/orchestrator.proto` — Add optional `inference_stats` field to `ProcessRequestResponse`
|
||||
|
||||
**InferenceStats message fields:**
|
||||
- `prompt_tokens` (uint32) — tokens in the prompt
|
||||
- `completion_tokens` (uint32) — tokens generated
|
||||
- `total_tokens` (uint32) — sum of prompt + completion
|
||||
- `context_window_size` (uint32) — model's maximum context length
|
||||
- `tokens_per_second` (float) — generation throughput
|
||||
|
||||
**Then regenerate types:** `npm run generate`
|
||||
|
||||
### Phase 2: Orchestration State
|
||||
|
||||
**Files:**
|
||||
- `src/lib/composables/useOrchestration.svelte.ts` — Extract `inferenceStats` from response, expose via store getter
|
||||
|
||||
### Phase 3: InferenceStatsPanel Component
|
||||
|
||||
**Files:**
|
||||
- `src/lib/components/InferenceStatsPanel.svelte` — New component
|
||||
|
||||
**Design:**
|
||||
- Follow `<details>` pattern from FinalResult.svelte
|
||||
- Collapsed by default
|
||||
- Summary line shows key stat (e.g., total tokens + tokens/sec)
|
||||
- Expanded content shows all stats in a grid layout
|
||||
- Context utilization shown as a progress bar
|
||||
- Blue/indigo color scheme (neutral, info-like)
|
||||
- Full dark mode support
|
||||
|
||||
### Phase 4: Chat Page Integration
|
||||
|
||||
**Files:**
|
||||
- `src/routes/chat/+page.svelte` — Render `InferenceStatsPanel` after `FinalResult` when stats available
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [x] InferenceStats proto message defined and TypeScript types generated
|
||||
- [x] InferenceStatsPanel displays all required metrics
|
||||
- [x] Panel is collapsible, collapsed by default
|
||||
- [x] Context utilization shows visual progress bar
|
||||
- [x] Integrates cleanly into chat page below assistant message
|
||||
- [x] Dark mode support
|
||||
- [x] Build, lint, typecheck pass
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { SubagentResult } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import { ResultStatus, ResultQuality } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import { ResultStatus, ResultQuality, ArtifactType } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import { resultSourceConfig } from '$lib/types/resultSource';
|
||||
|
||||
let { result }: { result: SubagentResult } = $props();
|
||||
@@ -28,10 +28,33 @@
|
||||
});
|
||||
|
||||
const sourceBadge = $derived(resultSourceConfig(result.source));
|
||||
|
||||
const LINE_COLLAPSE_THRESHOLD = 20;
|
||||
|
||||
function contentLineCount(content: string): number {
|
||||
return content.split('\n').length;
|
||||
}
|
||||
|
||||
const URL_RE = /(https?:\/\/[^\s<>"')\]]+)/g;
|
||||
|
||||
function linkify(text: string): string {
|
||||
return text.replace(URL_RE, '<a href="$1" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 underline hover:text-blue-800 dark:hover:text-blue-300 break-all">$1</a>');
|
||||
}
|
||||
|
||||
let copiedIndex: number | null = $state(null);
|
||||
|
||||
async function copyToClipboard(content: string, index: number) {
|
||||
await navigator.clipboard.writeText(content);
|
||||
copiedIndex = index;
|
||||
setTimeout(() => {
|
||||
if (copiedIndex === index) copiedIndex = null;
|
||||
}, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="mx-4 mb-3 rounded-xl border {statusConfig.border} {statusConfig.bg} p-4">
|
||||
<div class="mb-2 flex items-center gap-2">
|
||||
<details class="mx-4 mb-3 rounded-xl border {statusConfig.border} {statusConfig.bg}">
|
||||
<summary class="flex cursor-pointer items-center gap-2 px-4 py-2.5 select-none">
|
||||
<svg class="chevron h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400 transition-transform" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" /></svg>
|
||||
<span class="rounded-full px-2.5 py-0.5 text-xs font-medium {statusConfig.bg} {statusConfig.text}">
|
||||
{statusConfig.label}
|
||||
</span>
|
||||
@@ -45,10 +68,14 @@
|
||||
{sourceBadge.label}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if result.summary}
|
||||
<p class="text-sm {statusConfig.text}">{result.summary}</p>
|
||||
<span class="ml-1 truncate text-xs {statusConfig.text}">{result.summary}</span>
|
||||
{/if}
|
||||
</summary>
|
||||
|
||||
<div class="max-h-96 overflow-y-auto border-t {statusConfig.border} px-4 pb-4 pt-3">
|
||||
{#if result.summary}
|
||||
<p class="text-sm {statusConfig.text}">{@html linkify(result.summary)}</p>
|
||||
{/if}
|
||||
|
||||
{#if result.failureReason}
|
||||
@@ -58,14 +85,98 @@
|
||||
{#if result.artifacts.length > 0}
|
||||
<div class="mt-3 border-t {statusConfig.border} pt-3">
|
||||
<p class="mb-1.5 text-xs font-medium text-gray-600 dark:text-gray-400">Artifacts</p>
|
||||
<ul class="space-y-1">
|
||||
{#each result.artifacts as artifact (artifact)}
|
||||
<li class="flex items-center gap-2 text-sm">
|
||||
<span class="text-gray-400 dark:text-gray-500">📄</span>
|
||||
<span class="font-mono text-xs text-gray-700 dark:text-gray-300">{artifact}</span>
|
||||
</li>
|
||||
<div class="space-y-3">
|
||||
{#each result.artifacts as artifact, i (artifact.label + i)}
|
||||
{#if artifact.artifactType === ArtifactType.CODE}
|
||||
<!-- Code artifact: syntax-highlighted block with filename header -->
|
||||
<div class="rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden">
|
||||
<div class="flex items-center gap-2 bg-gray-100 dark:bg-gray-800 px-3 py-1.5 text-xs">
|
||||
<span class="text-blue-600 dark:text-blue-400">📄</span>
|
||||
<span class="font-mono font-medium text-gray-700 dark:text-gray-300">{artifact.label}</span>
|
||||
<div class="ml-auto flex items-center gap-1.5">
|
||||
{#if artifact.metadata?.language}
|
||||
<span class="rounded bg-gray-200 dark:bg-gray-700 px-1.5 py-0.5 text-[10px] text-gray-500 dark:text-gray-400">{artifact.metadata.language}</span>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => copyToClipboard(artifact.content, i)}
|
||||
class="rounded p-0.5 text-gray-400 hover:bg-gray-200 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-gray-300 transition-colors"
|
||||
title="Copy code"
|
||||
>
|
||||
{#if copiedIndex === i}
|
||||
<svg class="h-3.5 w-3.5 text-green-500" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" /></svg>
|
||||
{:else}
|
||||
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9.75a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184" /></svg>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{#if contentLineCount(artifact.content) > LINE_COLLAPSE_THRESHOLD}
|
||||
<details>
|
||||
<summary class="cursor-pointer bg-gray-50 dark:bg-gray-900 px-3 py-1 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">
|
||||
Show {contentLineCount(artifact.content)} lines
|
||||
</summary>
|
||||
<pre class="overflow-x-auto bg-gray-50 dark:bg-gray-900 p-3 text-xs leading-relaxed text-gray-800 dark:text-gray-200"><code class="language-{artifact.metadata?.language ?? ''}">{artifact.content}</code></pre>
|
||||
</details>
|
||||
{:else}
|
||||
<pre class="overflow-x-auto bg-gray-50 dark:bg-gray-900 p-3 text-xs leading-relaxed text-gray-800 dark:text-gray-200"><code class="language-{artifact.metadata?.language ?? ''}">{artifact.content}</code></pre>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{:else if artifact.artifactType === ArtifactType.COMMAND_OUTPUT}
|
||||
<!-- Command output: terminal-style block -->
|
||||
<div class="rounded-lg border border-gray-700 dark:border-gray-600 overflow-hidden">
|
||||
<div class="flex items-center gap-2 bg-gray-800 dark:bg-gray-900 px-3 py-1.5 text-xs">
|
||||
<span class="text-green-400">▶</span>
|
||||
<span class="font-mono text-gray-300">{artifact.label}</span>
|
||||
</div>
|
||||
{#if contentLineCount(artifact.content) > LINE_COLLAPSE_THRESHOLD}
|
||||
<details>
|
||||
<summary class="cursor-pointer bg-gray-900 dark:bg-black px-3 py-1 text-xs text-gray-400 hover:text-gray-200">
|
||||
Show {contentLineCount(artifact.content)} lines
|
||||
</summary>
|
||||
<pre class="overflow-x-auto bg-gray-900 dark:bg-black p-3 font-mono text-xs leading-relaxed text-green-300 dark:text-green-400">{artifact.content}</pre>
|
||||
</details>
|
||||
{:else}
|
||||
<pre class="overflow-x-auto bg-gray-900 dark:bg-black p-3 font-mono text-xs leading-relaxed text-green-300 dark:text-green-400">{artifact.content}</pre>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{:else if artifact.artifactType === ArtifactType.SEARCH_RESULT}
|
||||
<!-- Search result: card with query title -->
|
||||
<div class="rounded-lg border border-purple-200 dark:border-purple-800 bg-purple-50 dark:bg-purple-900/20 p-3">
|
||||
<div class="mb-1 flex items-center gap-2 text-xs">
|
||||
<span class="text-purple-500">🔍</span>
|
||||
<span class="font-medium text-purple-700 dark:text-purple-300">{artifact.label}</span>
|
||||
</div>
|
||||
{#if contentLineCount(artifact.content) > LINE_COLLAPSE_THRESHOLD}
|
||||
<details>
|
||||
<summary class="cursor-pointer text-xs text-purple-500 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300">
|
||||
Show full results
|
||||
</summary>
|
||||
<p class="mt-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-gray-300">{@html linkify(artifact.content)}</p>
|
||||
</details>
|
||||
{:else}
|
||||
<p class="whitespace-pre-wrap text-xs text-gray-700 dark:text-gray-300">{@html linkify(artifact.content)}</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{:else}
|
||||
<!-- Text / finding artifact: plain text -->
|
||||
<div class="flex items-start gap-2 text-sm">
|
||||
<span class="mt-0.5 text-gray-400 dark:text-gray-500">📄</span>
|
||||
<span class="text-xs text-gray-700 dark:text-gray-300">{@html linkify(artifact.content)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<style>
|
||||
details[open] > summary .chevron {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
</style>
|
||||
|
||||
94
src/lib/components/InferenceStatsPanel.svelte
Normal file
94
src/lib/components/InferenceStatsPanel.svelte
Normal file
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import type { InferenceStats } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
|
||||
let { stats }: { stats: InferenceStats } = $props();
|
||||
|
||||
const utilizationPct = $derived(
|
||||
stats.contextWindowSize > 0
|
||||
? Math.min(100, (stats.totalTokens / stats.contextWindowSize) * 100)
|
||||
: 0
|
||||
);
|
||||
|
||||
const utilizationColor = $derived.by(() => {
|
||||
if (utilizationPct >= 90) return { bar: 'bg-red-500', text: 'text-red-700 dark:text-red-400' };
|
||||
if (utilizationPct >= 70) return { bar: 'bg-amber-500', text: 'text-amber-700 dark:text-amber-400' };
|
||||
return { bar: 'bg-blue-500', text: 'text-blue-700 dark:text-blue-400' };
|
||||
});
|
||||
|
||||
function formatNumber(n: number): string {
|
||||
return n.toLocaleString();
|
||||
}
|
||||
</script>
|
||||
|
||||
<details class="mx-4 mb-3 rounded-xl border border-indigo-200 dark:border-indigo-800 bg-indigo-50 dark:bg-indigo-900/20">
|
||||
<summary class="flex cursor-pointer items-center gap-2 px-4 py-2.5 select-none">
|
||||
<svg class="chevron h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400 transition-transform" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" /></svg>
|
||||
<span class="rounded-full bg-indigo-100 dark:bg-indigo-900/40 px-2.5 py-0.5 text-xs font-medium text-indigo-800 dark:text-indigo-300">
|
||||
Stats
|
||||
</span>
|
||||
<span class="truncate text-xs text-indigo-700 dark:text-indigo-400">
|
||||
{formatNumber(stats.totalTokens)} tokens
|
||||
{#if stats.tokensPerSecond > 0}
|
||||
· {stats.tokensPerSecond.toFixed(1)} tok/s
|
||||
{/if}
|
||||
{#if stats.contextWindowSize > 0}
|
||||
· {utilizationPct.toFixed(0)}% context
|
||||
{/if}
|
||||
</span>
|
||||
</summary>
|
||||
|
||||
<div class="border-t border-indigo-200 dark:border-indigo-800 px-4 pb-4 pt-3">
|
||||
<div class="grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3">
|
||||
<div>
|
||||
<p class="text-[10px] font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">Prompt</p>
|
||||
<p class="text-sm font-semibold text-gray-900 dark:text-gray-100">{formatNumber(stats.promptTokens)}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[10px] font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">Completion</p>
|
||||
<p class="text-sm font-semibold text-gray-900 dark:text-gray-100">{formatNumber(stats.completionTokens)}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[10px] font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">Total</p>
|
||||
<p class="text-sm font-semibold text-gray-900 dark:text-gray-100">{formatNumber(stats.totalTokens)}</p>
|
||||
</div>
|
||||
{#if stats.tokensPerSecond > 0}
|
||||
<div>
|
||||
<p class="text-[10px] font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">Throughput</p>
|
||||
<p class="text-sm font-semibold text-gray-900 dark:text-gray-100">{stats.tokensPerSecond.toFixed(1)} tok/s</p>
|
||||
</div>
|
||||
{/if}
|
||||
{#if stats.contextWindowSize > 0}
|
||||
<div class="col-span-2">
|
||||
<p class="text-[10px] font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">Context Window</p>
|
||||
<p class="text-sm font-semibold text-gray-900 dark:text-gray-100">{formatNumber(stats.contextWindowSize)}</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if stats.contextWindowSize > 0}
|
||||
<div class="mt-3 border-t border-indigo-200 dark:border-indigo-800 pt-3">
|
||||
<div class="flex items-center justify-between text-xs">
|
||||
<span class="font-medium text-gray-600 dark:text-gray-400">Context Utilization</span>
|
||||
<span class="font-semibold {utilizationColor.text}">{utilizationPct.toFixed(1)}%</span>
|
||||
</div>
|
||||
<div class="mt-1.5 h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700">
|
||||
<div
|
||||
class="h-full rounded-full transition-all duration-300 {utilizationColor.bar}"
|
||||
style="width: {utilizationPct}%"
|
||||
role="progressbar"
|
||||
aria-valuenow={utilizationPct}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-label="Context window utilization"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<style>
|
||||
details[open] > summary .chevron {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
</style>
|
||||
@@ -29,7 +29,7 @@
|
||||
{status === 'completed'
|
||||
? 'bg-green-500 text-white'
|
||||
: status === 'active'
|
||||
? 'bg-blue-500 text-white ring-2 ring-blue-300 dark:ring-blue-600 ring-offset-1 dark:ring-offset-gray-800'
|
||||
? 'bg-blue-500 text-white ring-2 ring-blue-300 dark:ring-blue-600 ring-offset-1 dark:ring-offset-gray-800 animate-pulse-ring'
|
||||
: 'bg-gray-200 dark:bg-gray-600 text-gray-500 dark:text-gray-400'}"
|
||||
>
|
||||
{#if status === 'completed'}
|
||||
@@ -46,11 +46,45 @@
|
||||
</span>
|
||||
</div>
|
||||
{#if i < phases.length - 1}
|
||||
<div
|
||||
class="mb-5 h-0.5 flex-1 transition-colors duration-300
|
||||
{getStatus(phases[i + 1].state) !== 'pending' ? 'bg-green-500' : 'bg-gray-200 dark:bg-gray-600'}"
|
||||
></div>
|
||||
{@const nextStatus = getStatus(phases[i + 1].state)}
|
||||
<div class="relative mb-5 h-0.5 flex-1 bg-gray-200 dark:bg-gray-600 overflow-hidden">
|
||||
{#if nextStatus !== 'pending'}
|
||||
<!-- Completed: solid green fill -->
|
||||
<div class="absolute inset-0 bg-green-500"></div>
|
||||
{:else if status === 'active'}
|
||||
<!-- Active: animated fill shimmer -->
|
||||
<div class="absolute inset-0 animate-progress-fill bg-gradient-to-r from-blue-500 via-blue-400 to-blue-500 bg-[length:200%_100%]"></div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@keyframes pulse-ring {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes progress-fill {
|
||||
0% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
|
||||
:global(.animate-pulse-ring) {
|
||||
animation: pulse-ring 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
:global(.animate-progress-fill) {
|
||||
animation: progress-fill 2s linear infinite;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
title,
|
||||
backHref,
|
||||
backLabel = 'Chat',
|
||||
showSampleBadge = false,
|
||||
children
|
||||
}: {
|
||||
title: string;
|
||||
backHref?: string;
|
||||
backLabel?: string;
|
||||
showSampleBadge?: boolean;
|
||||
children?: Snippet;
|
||||
} = $props();
|
||||
</script>
|
||||
@@ -36,10 +34,5 @@
|
||||
{@render children()}
|
||||
{/if}
|
||||
<ThemeToggle />
|
||||
{#if showSampleBadge}
|
||||
<span class="hidden sm:inline rounded-md bg-amber-50 dark:bg-amber-900/30 px-2 py-1 text-xs text-amber-700 dark:text-amber-300">
|
||||
Sample Data
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { ChatMessage } from '$lib/types';
|
||||
import type { SubagentResult } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import type { SubagentResult, InferenceStats } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import type { SessionConfig } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
|
||||
import { processRequest, OrchestratorError, friendlyMessage } from '$lib/services/orchestrator';
|
||||
import { OrchestrationState } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
|
||||
import { sessionStore } from '$lib/stores/sessions.svelte';
|
||||
import { memoryStore } from '$lib/stores/memory.svelte';
|
||||
import { auditStore } from '$lib/stores/audit.svelte';
|
||||
import { toastStore } from '$lib/stores/toast.svelte';
|
||||
import { logger } from '$lib/utils/logger';
|
||||
|
||||
export function createOrchestration() {
|
||||
let isStreaming = $state(false);
|
||||
@@ -15,6 +15,7 @@ export function createOrchestration() {
|
||||
let orchestrationState: OrchestrationState = $state(OrchestrationState.UNSPECIFIED);
|
||||
let intermediateResult: string = $state('');
|
||||
let finalResult: SubagentResult | null = $state(null);
|
||||
let inferenceStats: InferenceStats | null = $state(null);
|
||||
|
||||
async function send(
|
||||
sessionId: string,
|
||||
@@ -27,6 +28,7 @@ export function createOrchestration() {
|
||||
orchestrationState = OrchestrationState.UNSPECIFIED;
|
||||
intermediateResult = '';
|
||||
finalResult = null;
|
||||
inferenceStats = null;
|
||||
|
||||
let lastAuditState = OrchestrationState.UNSPECIFIED;
|
||||
|
||||
@@ -57,6 +59,10 @@ export function createOrchestration() {
|
||||
|
||||
if (response.state !== lastAuditState) {
|
||||
const stateLabel = OrchestrationState[response.state] ?? String(response.state);
|
||||
logger.debug('useOrchestration', `State: ${stateLabel}`, {
|
||||
sessionId,
|
||||
state: response.state
|
||||
});
|
||||
auditStore.addEvent(sessionId, {
|
||||
eventType: 'state_change',
|
||||
details: response.message || `State changed to ${stateLabel}`,
|
||||
@@ -68,6 +74,9 @@ export function createOrchestration() {
|
||||
if (response.intermediateResult) {
|
||||
intermediateResult = response.intermediateResult;
|
||||
}
|
||||
if (response.inferenceStats) {
|
||||
inferenceStats = response.inferenceStats;
|
||||
}
|
||||
if (response.finalResult) {
|
||||
finalResult = response.finalResult;
|
||||
if (response.finalResult.newMemoryCandidates.length > 0) {
|
||||
@@ -88,21 +97,27 @@ export function createOrchestration() {
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
const friendlyMsg =
|
||||
err instanceof OrchestratorError
|
||||
const isOrcErr = err instanceof OrchestratorError;
|
||||
const code = isOrcErr ? err.code : 'unknown';
|
||||
const details = isOrcErr ? err.details : undefined;
|
||||
const friendlyMsg = isOrcErr
|
||||
? friendlyMessage(err.code)
|
||||
: 'An unexpected error occurred';
|
||||
error = friendlyMsg;
|
||||
const displayMsg =
|
||||
code && code !== 'unknown'
|
||||
? `${friendlyMsg} (${code})`
|
||||
: friendlyMsg;
|
||||
error = displayMsg;
|
||||
lastFailedContent = content;
|
||||
toastStore.addToast({ message: friendlyMsg, type: 'error' });
|
||||
logger.error('useOrchestration', 'Request failed', { code, details });
|
||||
auditStore.addEvent(sessionId, {
|
||||
eventType: 'error',
|
||||
details: friendlyMsg
|
||||
details: `${friendlyMsg} | code=${code}${details ? ` | details=${details}` : ''}`
|
||||
});
|
||||
const idx = messages.length - 1;
|
||||
messages[idx] = {
|
||||
...messages[idx],
|
||||
content: `\u26A0 ${friendlyMsg}`
|
||||
content: `\u26A0 ${displayMsg}`
|
||||
};
|
||||
} finally {
|
||||
isStreaming = false;
|
||||
@@ -135,6 +150,7 @@ export function createOrchestration() {
|
||||
function reset() {
|
||||
error = null;
|
||||
finalResult = null;
|
||||
inferenceStats = null;
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -144,8 +160,15 @@ export function createOrchestration() {
|
||||
get orchestrationState() { return orchestrationState; },
|
||||
get intermediateResult() { return intermediateResult; },
|
||||
get finalResult() { return finalResult; },
|
||||
get inferenceStats() { return inferenceStats; },
|
||||
send,
|
||||
retry,
|
||||
reset
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Module-level singleton so orchestration state survives tab/route changes.
|
||||
* The chat page uses this instead of calling createOrchestration() per mount.
|
||||
*/
|
||||
export const orchestrationStore = createOrchestration();
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import { ResultSource } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import type { AuditEvent } from '$lib/stores/audit.svelte';
|
||||
import type { StoredMemoryCandidate } from '$lib/stores/memory.svelte';
|
||||
|
||||
export function getSampleAuditData(): SvelteMap<string, AuditEvent[]> {
|
||||
const samples = new SvelteMap<string, AuditEvent[]>();
|
||||
const now = Date.now();
|
||||
|
||||
samples.set('session-demo-alpha', [
|
||||
{
|
||||
id: 'evt-001',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 300_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Orchestration started — decomposing user request',
|
||||
state: 'DECOMPOSING'
|
||||
},
|
||||
{
|
||||
id: 'evt-002',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 280_000),
|
||||
eventType: 'tool_invocation',
|
||||
details: 'Invoked web_search tool for "SvelteKit best practices"',
|
||||
state: 'DECOMPOSING'
|
||||
},
|
||||
{
|
||||
id: 'evt-003',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 260_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Dispatching subtasks to subagents',
|
||||
state: 'DISPATCHING'
|
||||
},
|
||||
{
|
||||
id: 'evt-004',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 240_000),
|
||||
eventType: 'message',
|
||||
details: 'Researcher agent assigned to subtask "Gather TypeScript patterns"'
|
||||
},
|
||||
{
|
||||
id: 'evt-005',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 220_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Subagents executing tasks',
|
||||
state: 'EXECUTING'
|
||||
},
|
||||
{
|
||||
id: 'evt-006',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 200_000),
|
||||
eventType: 'tool_invocation',
|
||||
details: 'Invoked code_analysis tool on project source files'
|
||||
},
|
||||
{
|
||||
id: 'evt-007',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 180_000),
|
||||
eventType: 'error',
|
||||
details: 'Timeout waiting for code_analysis response (retrying)'
|
||||
},
|
||||
{
|
||||
id: 'evt-008',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 160_000),
|
||||
eventType: 'tool_invocation',
|
||||
details: 'Retry: code_analysis tool succeeded'
|
||||
},
|
||||
{
|
||||
id: 'evt-009',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 140_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Compacting results from subagents',
|
||||
state: 'COMPACTING'
|
||||
},
|
||||
{
|
||||
id: 'evt-010',
|
||||
sessionId: 'session-demo-alpha',
|
||||
timestamp: new Date(now - 120_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Orchestration complete',
|
||||
state: 'COMPLETE'
|
||||
}
|
||||
]);
|
||||
|
||||
samples.set('session-demo-beta', [
|
||||
{
|
||||
id: 'evt-011',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 600_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Orchestration started — decomposing deployment request',
|
||||
state: 'DECOMPOSING'
|
||||
},
|
||||
{
|
||||
id: 'evt-012',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 580_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Dispatching to sysadmin agent',
|
||||
state: 'DISPATCHING'
|
||||
},
|
||||
{
|
||||
id: 'evt-013',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 560_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Executing deployment analysis',
|
||||
state: 'EXECUTING'
|
||||
},
|
||||
{
|
||||
id: 'evt-014',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 540_000),
|
||||
eventType: 'tool_invocation',
|
||||
details: 'Invoked kubectl_check tool for cluster status'
|
||||
},
|
||||
{
|
||||
id: 'evt-015',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 520_000),
|
||||
eventType: 'error',
|
||||
details: 'Permission denied: kubectl access not granted for this session'
|
||||
},
|
||||
{
|
||||
id: 'evt-016',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 500_000),
|
||||
eventType: 'message',
|
||||
details: 'Agent requested elevated permissions for cluster access'
|
||||
},
|
||||
{
|
||||
id: 'evt-017',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 480_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Compacting partial results',
|
||||
state: 'COMPACTING'
|
||||
},
|
||||
{
|
||||
id: 'evt-018',
|
||||
sessionId: 'session-demo-beta',
|
||||
timestamp: new Date(now - 460_000),
|
||||
eventType: 'state_change',
|
||||
details: 'Orchestration complete with warnings',
|
||||
state: 'COMPLETE'
|
||||
}
|
||||
]);
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
export function getSampleMemoryData(): SvelteMap<string, StoredMemoryCandidate[]> {
|
||||
const samples = new SvelteMap<string, StoredMemoryCandidate[]>();
|
||||
samples.set('session-demo-alpha', [
|
||||
{
|
||||
content: 'The user prefers TypeScript strict mode with no implicit any.',
|
||||
source: ResultSource.MODEL_KNOWLEDGE,
|
||||
confidence: 0.92
|
||||
},
|
||||
{
|
||||
content: 'Project uses SvelteKit with Tailwind CSS v4 and Svelte 5 runes.',
|
||||
source: ResultSource.TOOL_OUTPUT,
|
||||
confidence: 0.98
|
||||
},
|
||||
{
|
||||
content: 'Preferred testing framework is Vitest with Playwright for e2e.',
|
||||
source: ResultSource.MODEL_KNOWLEDGE,
|
||||
confidence: 0.75
|
||||
},
|
||||
{
|
||||
content: 'The gRPC backend runs on port 50051 behind a Caddy reverse proxy.',
|
||||
source: ResultSource.TOOL_OUTPUT,
|
||||
confidence: 0.85
|
||||
}
|
||||
]);
|
||||
samples.set('session-demo-beta', [
|
||||
{
|
||||
content: 'User asked about deploying to Kubernetes with Helm charts.',
|
||||
source: ResultSource.WEB,
|
||||
confidence: 0.67
|
||||
},
|
||||
{
|
||||
content: 'The container registry is at registry.example.com.',
|
||||
source: ResultSource.TOOL_OUTPUT,
|
||||
confidence: 0.91
|
||||
},
|
||||
{
|
||||
content: 'Deployment target is a 3-node k3s cluster running on ARM64.',
|
||||
source: ResultSource.WEB,
|
||||
confidence: 0.58
|
||||
}
|
||||
]);
|
||||
samples.set('session-demo-gamma', [
|
||||
{
|
||||
content: 'Database schema uses PostgreSQL with pgvector extension for embeddings.',
|
||||
source: ResultSource.TOOL_OUTPUT,
|
||||
confidence: 0.95
|
||||
},
|
||||
{
|
||||
content: 'The embedding model is all-MiniLM-L6-v2 with 384 dimensions.',
|
||||
source: ResultSource.MODEL_KNOWLEDGE,
|
||||
confidence: 0.82
|
||||
}
|
||||
]);
|
||||
return samples;
|
||||
}
|
||||
@@ -12,7 +12,47 @@ import type { Message } from "@bufbuild/protobuf";
|
||||
* Describes the file llm_multiverse/v1/common.proto.
|
||||
*/
|
||||
export const file_llm_multiverse_v1_common: GenFile = /*@__PURE__*/
|
||||
fileDesc("Ch5sbG1fbXVsdGl2ZXJzZS92MS9jb21tb24ucHJvdG8SEWxsbV9tdWx0aXZlcnNlLnYxImoKD0FnZW50SWRlbnRpZmllchIQCghhZ2VudF9pZBgBIAEoCRIwCgphZ2VudF90eXBlGAIgASgOMhwubGxtX211bHRpdmVyc2UudjEuQ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HkSHgoaUkVTVUxUX1FVQUxJVFlfVU5TUEVDSUZJRUQQABIbChdSRVNVTFRfUVVBTElUWV9WRVJJRklFRBABEhsKF1JFU1VMVF9RVUFMSVRZX0lORkVSUkVEEAISHAoYUkVTVUxUX1FVQUxJVFlfVU5DRVJUQUlOEAMqhgEKDFJlc3VsdFNvdXJjZRIdChlSRVNVTFRfU09VUkNFX1VOU1BFQ0lGSUVEEAASHQoZUkVTVUxUX1NPVVJDRV9UT09MX09VVFBVVBABEiEKHVJFU1VMVF9TT1VSQ0VfTU9ERUxfS05PV0xFREdFEAISFQoRUkVTVUxUX1NPVVJDRV9XRUIQAyqgAQoMQXJ0aWZhY3RUeXBlEh0KGUFSVElGQUNUX1RZUEVfVU5TUEVDSUZJRUQQABIWChJBUlRJRkFDVF9UWVBFX0NPREUQARIWChJBUlRJRkFDVF9UWVBFX1RFWFQQAhIgChxBUlRJRkFDVF9UWVBFX0NPTU1BTkRfT1VUUFVUEAMSHwobQVJUSUZBQ1RfVFlQRV9TRUFSQ0hfUkVTVUxUEARiBnByb3RvMw", [file_google_protobuf_timestamp]);
|
||||
|
||||
/**
|
||||
* A concrete output produced by an agent (code, command output, etc.).
|
||||
*
|
||||
* @generated from message llm_multiverse.v1.Artifact
|
||||
*/
|
||||
export type Artifact = Message<"llm_multiverse.v1.Artifact"> & {
|
||||
/**
|
||||
* Display name (filename, query, etc.)
|
||||
*
|
||||
* @generated from field: string label = 1;
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Full content
|
||||
*
|
||||
* @generated from field: string content = 2;
|
||||
*/
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* @generated from field: llm_multiverse.v1.ArtifactType artifact_type = 3;
|
||||
*/
|
||||
artifactType: ArtifactType;
|
||||
|
||||
/**
|
||||
* language, path, tool_name, exit_code, etc.
|
||||
*
|
||||
* @generated from field: map<string, string> metadata = 4;
|
||||
*/
|
||||
metadata: { [key: string]: string };
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message llm_multiverse.v1.Artifact.
|
||||
* Use `create(ArtifactSchema)` to create a new message.
|
||||
*/
|
||||
export const ArtifactSchema: GenMessage<Artifact> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 0);
|
||||
|
||||
/**
|
||||
* Identifies a single agent in the lineage chain.
|
||||
@@ -41,7 +81,7 @@ export type AgentIdentifier = Message<"llm_multiverse.v1.AgentIdentifier"> & {
|
||||
* Use `create(AgentIdentifierSchema)` to create a new message.
|
||||
*/
|
||||
export const AgentIdentifierSchema: GenMessage<AgentIdentifier> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 0);
|
||||
messageDesc(file_llm_multiverse_v1_common, 1);
|
||||
|
||||
/**
|
||||
* Ordered chain of agents from orchestrator (index 0) to current agent.
|
||||
@@ -61,7 +101,7 @@ export type AgentLineage = Message<"llm_multiverse.v1.AgentLineage"> & {
|
||||
* Use `create(AgentLineageSchema)` to create a new message.
|
||||
*/
|
||||
export const AgentLineageSchema: GenMessage<AgentLineage> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 1);
|
||||
messageDesc(file_llm_multiverse_v1_common, 2);
|
||||
|
||||
/**
|
||||
* Carried in every gRPC request for audit trail and broker enforcement.
|
||||
@@ -100,7 +140,7 @@ export type SessionContext = Message<"llm_multiverse.v1.SessionContext"> & {
|
||||
* Use `create(SessionContextSchema)` to create a new message.
|
||||
*/
|
||||
export const SessionContextSchema: GenMessage<SessionContext> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 2);
|
||||
messageDesc(file_llm_multiverse_v1_common, 3);
|
||||
|
||||
/**
|
||||
* Structured error detail for gRPC error responses.
|
||||
@@ -129,7 +169,7 @@ export type ErrorDetail = Message<"llm_multiverse.v1.ErrorDetail"> & {
|
||||
* Use `create(ErrorDetailSchema)` to create a new message.
|
||||
*/
|
||||
export const ErrorDetailSchema: GenMessage<ErrorDetail> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 3);
|
||||
messageDesc(file_llm_multiverse_v1_common, 4);
|
||||
|
||||
/**
|
||||
* A candidate memory entry proposed by a subagent for persistence.
|
||||
@@ -158,7 +198,56 @@ export type MemoryCandidate = Message<"llm_multiverse.v1.MemoryCandidate"> & {
|
||||
* Use `create(MemoryCandidateSchema)` to create a new message.
|
||||
*/
|
||||
export const MemoryCandidateSchema: GenMessage<MemoryCandidate> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 4);
|
||||
messageDesc(file_llm_multiverse_v1_common, 5);
|
||||
|
||||
/**
|
||||
* Inference statistics surfaced from model-gateway through the orchestrator.
|
||||
*
|
||||
* @generated from message llm_multiverse.v1.InferenceStats
|
||||
*/
|
||||
export type InferenceStats = Message<"llm_multiverse.v1.InferenceStats"> & {
|
||||
/**
|
||||
* Number of tokens in the prompt.
|
||||
*
|
||||
* @generated from field: uint32 prompt_tokens = 1;
|
||||
*/
|
||||
promptTokens: number;
|
||||
|
||||
/**
|
||||
* Number of tokens generated.
|
||||
*
|
||||
* @generated from field: uint32 completion_tokens = 2;
|
||||
*/
|
||||
completionTokens: number;
|
||||
|
||||
/**
|
||||
* Sum of prompt + completion tokens.
|
||||
*
|
||||
* @generated from field: uint32 total_tokens = 3;
|
||||
*/
|
||||
totalTokens: number;
|
||||
|
||||
/**
|
||||
* Model's maximum context length.
|
||||
*
|
||||
* @generated from field: uint32 context_window_size = 4;
|
||||
*/
|
||||
contextWindowSize: number;
|
||||
|
||||
/**
|
||||
* Generation throughput (tokens per second).
|
||||
*
|
||||
* @generated from field: float tokens_per_second = 5;
|
||||
*/
|
||||
tokensPerSecond: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message llm_multiverse.v1.InferenceStats.
|
||||
* Use `create(InferenceStatsSchema)` to create a new message.
|
||||
*/
|
||||
export const InferenceStatsSchema: GenMessage<InferenceStats> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 6);
|
||||
|
||||
/**
|
||||
* Standardized return value from any subagent to its parent.
|
||||
@@ -179,9 +268,11 @@ export type SubagentResult = Message<"llm_multiverse.v1.SubagentResult"> & {
|
||||
summary: string;
|
||||
|
||||
/**
|
||||
* @generated from field: repeated string artifacts = 3;
|
||||
* Structured artifacts produced during the agent loop.
|
||||
*
|
||||
* @generated from field: repeated llm_multiverse.v1.Artifact artifacts = 3;
|
||||
*/
|
||||
artifacts: string[];
|
||||
artifacts: Artifact[];
|
||||
|
||||
/**
|
||||
* @generated from field: llm_multiverse.v1.ResultQuality result_quality = 4;
|
||||
@@ -209,7 +300,7 @@ export type SubagentResult = Message<"llm_multiverse.v1.SubagentResult"> & {
|
||||
* Use `create(SubagentResultSchema)` to create a new message.
|
||||
*/
|
||||
export const SubagentResultSchema: GenMessage<SubagentResult> = /*@__PURE__*/
|
||||
messageDesc(file_llm_multiverse_v1_common, 5);
|
||||
messageDesc(file_llm_multiverse_v1_common, 7);
|
||||
|
||||
/**
|
||||
* Agent types with distinct tool permission manifests.
|
||||
@@ -450,3 +541,49 @@ export enum ResultSource {
|
||||
export const ResultSourceSchema: GenEnum<ResultSource> = /*@__PURE__*/
|
||||
enumDesc(file_llm_multiverse_v1_common, 5);
|
||||
|
||||
/**
|
||||
* Type of artifact produced by an agent during its tool call loop.
|
||||
*
|
||||
* @generated from enum llm_multiverse.v1.ArtifactType
|
||||
*/
|
||||
export enum ArtifactType {
|
||||
/**
|
||||
* @generated from enum value: ARTIFACT_TYPE_UNSPECIFIED = 0;
|
||||
*/
|
||||
UNSPECIFIED = 0,
|
||||
|
||||
/**
|
||||
* Code written via fs_write
|
||||
*
|
||||
* @generated from enum value: ARTIFACT_TYPE_CODE = 1;
|
||||
*/
|
||||
CODE = 1,
|
||||
|
||||
/**
|
||||
* Plain text / file content from fs_read
|
||||
*
|
||||
* @generated from enum value: ARTIFACT_TYPE_TEXT = 2;
|
||||
*/
|
||||
TEXT = 2,
|
||||
|
||||
/**
|
||||
* Output from run_code / run_shell
|
||||
*
|
||||
* @generated from enum value: ARTIFACT_TYPE_COMMAND_OUTPUT = 3;
|
||||
*/
|
||||
COMMAND_OUTPUT = 3,
|
||||
|
||||
/**
|
||||
* Web search results
|
||||
*
|
||||
* @generated from enum value: ARTIFACT_TYPE_SEARCH_RESULT = 4;
|
||||
*/
|
||||
SEARCH_RESULT = 4,
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the enum llm_multiverse.v1.ArtifactType.
|
||||
*/
|
||||
export const ArtifactTypeSchema: GenEnum<ArtifactType> = /*@__PURE__*/
|
||||
enumDesc(file_llm_multiverse_v1_common, 6);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
||||
import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
|
||||
import type { AgentType, OverrideLevel, SessionContext, SubagentResult, ToolType } from "./common_pb";
|
||||
import type { AgentType, InferenceStats, OverrideLevel, SessionContext, SubagentResult, ToolType } from "./common_pb";
|
||||
import { file_llm_multiverse_v1_common } from "./common_pb";
|
||||
import type { Message } from "@bufbuild/protobuf";
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { Message } from "@bufbuild/protobuf";
|
||||
* Describes the file llm_multiverse/v1/orchestrator.proto.
|
||||
*/
|
||||
export const file_llm_multiverse_v1_orchestrator: GenFile = /*@__PURE__*/
|
||||
fileDesc("CiRsbG1fbXVsdGl2ZXJzZS92MS9vcmNoZXN0cmF0b3IucHJvdG8SEWxsbV9tdWx0aXZlcnNlLnYxIn4KDVNlc3Npb25Db25maWcSOAoOb3ZlcnJpZGVfbGV2ZWwYASABKA4yIC5sbG1fbXVsdGl2ZXJzZS52MS5PdmVycmlkZUxldmVsEhYKDmRpc2FibGVkX3Rvb2xzGAIgAygJEhsKE2dyYW50ZWRfcGVybWlzc2lvbnMYAyADKAkirwEKEVN1YnRhc2tEZWZpbml0aW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cQARIjCh9PUkNIRVNUUkFUSU9OX1NUQVRFX0RJU1BBVENISU5HEAISIQodT1JDSEVTVFJBVElPTl9TVEFURV9FWEVDVVRJTkcQAxIiCh5PUkNIRVNUUkFUSU9OX1NUQVRFX0NPTVBBQ1RJTkcQBBIgChxPUkNIRVNUUkFUSU9OX1NUQVRFX0NPTVBMRVRFEAUyfgoTT3JjaGVzdHJhdG9yU2VydmljZRJnCg5Qcm9jZXNzUmVxdWVzdBIoLmxsbV9tdWx0aXZlcnNlLnYxLlByb2Nlc3NSZXF1ZXN0UmVxdWVzdBopLmxsbV9tdWx0aXZlcnNlLnYxLlByb2Nlc3NSZXF1ZXN0UmVzcG9uc2UwAWIGcHJvdG8z", [file_llm_multiverse_v1_common]);
|
||||
|
||||
/**
|
||||
* Per-session configuration for override control.
|
||||
@@ -199,6 +199,13 @@ export type ProcessRequestResponse = Message<"llm_multiverse.v1.ProcessRequestRe
|
||||
* @generated from field: optional llm_multiverse.v1.SubagentResult final_result = 4;
|
||||
*/
|
||||
finalResult?: SubagentResult;
|
||||
|
||||
/**
|
||||
* Inference statistics from the model-gateway (on the final streamed message).
|
||||
*
|
||||
* @generated from field: optional llm_multiverse.v1.InferenceStats inference_stats = 5;
|
||||
*/
|
||||
inferenceStats?: InferenceStats;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createClient } from '@connectrpc/connect';
|
||||
import { createClient, ConnectError, Code } from '@connectrpc/connect';
|
||||
import { createGrpcWebTransport } from '@connectrpc/connect-web';
|
||||
import { OrchestratorService } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
|
||||
import type {
|
||||
@@ -9,6 +9,7 @@ import { create } from '@bufbuild/protobuf';
|
||||
import { ProcessRequestRequestSchema } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
|
||||
import { connectionStore } from '$lib/stores/connection.svelte';
|
||||
import { toastStore } from '$lib/stores/toast.svelte';
|
||||
import { logger } from '$lib/utils/logger';
|
||||
|
||||
/**
|
||||
* Application-level error wrapping gRPC status codes.
|
||||
@@ -112,10 +113,35 @@ function backoffDelay(attempt: number): number {
|
||||
|
||||
const MAX_RETRIES = 3;
|
||||
|
||||
/**
|
||||
* Map numeric Code enum values to lowercase string names matching GRPC_USER_MESSAGES keys.
|
||||
*/
|
||||
const CODE_TO_STRING: Record<number, string> = {
|
||||
[Code.Canceled]: 'cancelled',
|
||||
[Code.Unknown]: 'unknown',
|
||||
[Code.InvalidArgument]: 'failed_precondition',
|
||||
[Code.DeadlineExceeded]: 'deadline_exceeded',
|
||||
[Code.NotFound]: 'not_found',
|
||||
[Code.AlreadyExists]: 'already_exists',
|
||||
[Code.PermissionDenied]: 'permission_denied',
|
||||
[Code.ResourceExhausted]: 'resource_exhausted',
|
||||
[Code.FailedPrecondition]: 'failed_precondition',
|
||||
[Code.Aborted]: 'aborted',
|
||||
[Code.OutOfRange]: 'failed_precondition',
|
||||
[Code.Unimplemented]: 'unimplemented',
|
||||
[Code.Internal]: 'internal',
|
||||
[Code.Unavailable]: 'unavailable',
|
||||
[Code.DataLoss]: 'data_loss',
|
||||
[Code.Unauthenticated]: 'unauthenticated'
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract gRPC error code from an error, normalising to lowercase string.
|
||||
*/
|
||||
function extractCode(err: unknown): string {
|
||||
if (err instanceof ConnectError) {
|
||||
return CODE_TO_STRING[err.code] ?? 'unknown';
|
||||
}
|
||||
if (err instanceof Error && 'code' in err) {
|
||||
const raw = (err as { code: unknown }).code;
|
||||
if (typeof raw === 'string') return raw.toLowerCase();
|
||||
@@ -129,6 +155,14 @@ function extractCode(err: unknown): string {
|
||||
*/
|
||||
function toOrchestratorError(err: unknown): OrchestratorError {
|
||||
if (err instanceof OrchestratorError) return err;
|
||||
if (err instanceof ConnectError) {
|
||||
const code = extractCode(err);
|
||||
const details = [
|
||||
err.rawMessage,
|
||||
err.cause ? String(err.cause) : ''
|
||||
].filter(Boolean).join('; ');
|
||||
return new OrchestratorError(friendlyMessage(code), code, details || undefined);
|
||||
}
|
||||
if (err instanceof Error) {
|
||||
const code = extractCode(err);
|
||||
return new OrchestratorError(friendlyMessage(code), code, err.message);
|
||||
@@ -136,6 +170,13 @@ function toOrchestratorError(err: unknown): OrchestratorError {
|
||||
return new OrchestratorError(friendlyMessage('unknown'), 'unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a diagnostic code suffix to a message, e.g. "(code: unavailable)".
|
||||
*/
|
||||
function diagnosticSuffix(err: OrchestratorError): string {
|
||||
return err.code && err.code !== 'unknown' ? ` (code: ${err.code})` : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the orchestrator and yield streaming responses.
|
||||
*
|
||||
@@ -158,6 +199,11 @@ export async function* processRequest(
|
||||
sessionConfig
|
||||
});
|
||||
|
||||
logger.debug('orchestrator', 'processRequest', {
|
||||
sessionId,
|
||||
messageLength: userMessage.length
|
||||
});
|
||||
|
||||
let lastError: OrchestratorError | null = null;
|
||||
|
||||
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
||||
@@ -169,6 +215,11 @@ export async function* processRequest(
|
||||
if (attempt > 0) {
|
||||
connectionStore.setReconnecting();
|
||||
const delay = backoffDelay(attempt - 1);
|
||||
logger.warn('orchestrator', `Retry attempt ${attempt}/${MAX_RETRIES}`, {
|
||||
sessionId,
|
||||
previousCode: lastError?.code,
|
||||
delay
|
||||
});
|
||||
await sleep(delay);
|
||||
}
|
||||
|
||||
@@ -178,9 +229,11 @@ export async function* processRequest(
|
||||
connectionStore.reportSuccess();
|
||||
yield response;
|
||||
}
|
||||
logger.debug('orchestrator', 'Stream completed', { sessionId });
|
||||
// Completed successfully — no retry needed
|
||||
return;
|
||||
} catch (err: unknown) {
|
||||
logger.grpcError('orchestrator', `Request failed (attempt ${attempt + 1}/${MAX_RETRIES + 1})`, err);
|
||||
lastError = toOrchestratorError(err);
|
||||
const code = lastError.code;
|
||||
|
||||
@@ -192,7 +245,12 @@ export async function* processRequest(
|
||||
|
||||
// Non-transient or exhausted retries
|
||||
connectionStore.reportFailure();
|
||||
toastStore.addToast({ message: lastError.message, type: 'error' });
|
||||
const suffix = diagnosticSuffix(lastError);
|
||||
logger.error('orchestrator', 'Request failed permanently', {
|
||||
code: lastError.code,
|
||||
details: lastError.details
|
||||
});
|
||||
toastStore.addToast({ message: lastError.message + suffix, type: 'error' });
|
||||
throw lastError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import { getSampleAuditData } from '$lib/data/sampleData';
|
||||
|
||||
export type AuditEventType = 'state_change' | 'tool_invocation' | 'error' | 'message';
|
||||
|
||||
@@ -44,15 +43,6 @@ function saveEvents(events: SvelteMap<string, AuditEvent[]>) {
|
||||
function createAuditStore() {
|
||||
const events = $state<SvelteMap<string, AuditEvent[]>>(loadEvents());
|
||||
|
||||
// Seed sample data if store is empty
|
||||
if (events.size === 0) {
|
||||
const samples = getSampleAuditData();
|
||||
for (const [id, evts] of samples) {
|
||||
events.set(id, evts);
|
||||
}
|
||||
saveEvents(events);
|
||||
}
|
||||
|
||||
function addEvent(
|
||||
sessionId: string,
|
||||
event: Omit<AuditEvent, 'id' | 'sessionId' | 'timestamp'>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
import { ResultSource } from '$lib/proto/llm_multiverse/v1/common_pb';
|
||||
import { getSampleMemoryData } from '$lib/data/sampleData';
|
||||
|
||||
export interface StoredMemoryCandidate {
|
||||
content: string;
|
||||
@@ -14,9 +13,11 @@ export interface SessionMemory {
|
||||
}
|
||||
|
||||
const STORAGE_KEY = 'llm-multiverse-memory-candidates';
|
||||
const SAMPLE_CLEANUP_KEY = 'llm-multiverse-sample-data-cleaned';
|
||||
|
||||
function loadMemory(): SvelteMap<string, StoredMemoryCandidate[]> {
|
||||
if (typeof localStorage === 'undefined') return new SvelteMap();
|
||||
_cleanupSampleData();
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return new SvelteMap();
|
||||
@@ -27,6 +28,29 @@ function loadMemory(): SvelteMap<string, StoredMemoryCandidate[]> {
|
||||
}
|
||||
}
|
||||
|
||||
/** One-time removal of previously seeded sample sessions. */
|
||||
function _cleanupSampleData() {
|
||||
if (typeof localStorage === 'undefined') return;
|
||||
if (localStorage.getItem(SAMPLE_CLEANUP_KEY)) return;
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (raw) {
|
||||
const arr: [string, unknown[]][] = JSON.parse(raw);
|
||||
const filtered = arr.filter(([id]) => !id.startsWith('session-demo-'));
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(filtered));
|
||||
}
|
||||
// Also clean audit store
|
||||
const auditKey = 'llm-multiverse-audit-events';
|
||||
const auditRaw = localStorage.getItem(auditKey);
|
||||
if (auditRaw) {
|
||||
const arr: [string, unknown[]][] = JSON.parse(auditRaw);
|
||||
const filtered = arr.filter(([id]) => !id.startsWith('session-demo-'));
|
||||
localStorage.setItem(auditKey, JSON.stringify(filtered));
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
localStorage.setItem(SAMPLE_CLEANUP_KEY, '1');
|
||||
}
|
||||
|
||||
function saveMemory(memory: SvelteMap<string, StoredMemoryCandidate[]>) {
|
||||
if (typeof localStorage === 'undefined') return;
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify([...memory.entries()]));
|
||||
@@ -35,15 +59,6 @@ function saveMemory(memory: SvelteMap<string, StoredMemoryCandidate[]>) {
|
||||
function createMemoryStore() {
|
||||
const memory = $state<SvelteMap<string, StoredMemoryCandidate[]>>(loadMemory());
|
||||
|
||||
// Seed sample data if store is empty
|
||||
if (memory.size === 0) {
|
||||
const samples = getSampleMemoryData();
|
||||
for (const [id, candidates] of samples) {
|
||||
memory.set(id, candidates);
|
||||
}
|
||||
saveMemory(memory);
|
||||
}
|
||||
|
||||
function addCandidates(sessionId: string, candidates: StoredMemoryCandidate[]) {
|
||||
if (candidates.length === 0) return;
|
||||
const existing = memory.get(sessionId) ?? [];
|
||||
|
||||
@@ -151,52 +151,3 @@ export function buildLineageTree(agents: SimpleAgentIdentifier[]): LineageNode[]
|
||||
return roots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns sample/demo lineage data for visualization development.
|
||||
* This will be replaced with real API data when available.
|
||||
*/
|
||||
export function getSampleLineageData(): SimpleAgentIdentifier[] {
|
||||
return [
|
||||
{
|
||||
agentId: 'orch-001',
|
||||
agentType: AgentType.ORCHESTRATOR,
|
||||
spawnDepth: 0
|
||||
},
|
||||
{
|
||||
agentId: 'research-001',
|
||||
agentType: AgentType.RESEARCHER,
|
||||
spawnDepth: 1,
|
||||
parentId: 'orch-001'
|
||||
},
|
||||
{
|
||||
agentId: 'coder-001',
|
||||
agentType: AgentType.CODER,
|
||||
spawnDepth: 1,
|
||||
parentId: 'orch-001'
|
||||
},
|
||||
{
|
||||
agentId: 'sysadmin-001',
|
||||
agentType: AgentType.SYSADMIN,
|
||||
spawnDepth: 1,
|
||||
parentId: 'orch-001'
|
||||
},
|
||||
{
|
||||
agentId: 'assist-001',
|
||||
agentType: AgentType.ASSISTANT,
|
||||
spawnDepth: 2,
|
||||
parentId: 'research-001'
|
||||
},
|
||||
{
|
||||
agentId: 'coder-002',
|
||||
agentType: AgentType.CODER,
|
||||
spawnDepth: 2,
|
||||
parentId: 'coder-001'
|
||||
},
|
||||
{
|
||||
agentId: 'research-002',
|
||||
agentType: AgentType.RESEARCHER,
|
||||
spawnDepth: 3,
|
||||
parentId: 'coder-002'
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
60
src/lib/utils/logger.ts
Normal file
60
src/lib/utils/logger.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Lightweight dev-mode logging utility.
|
||||
* All diagnostic logging flows through this module.
|
||||
*/
|
||||
|
||||
import { ConnectError } from '@connectrpc/connect';
|
||||
|
||||
declare global {
|
||||
var __LLM_DEBUG: boolean | undefined;
|
||||
}
|
||||
|
||||
function isDebugEnabled(): boolean {
|
||||
return import.meta.env.DEV || globalThis.__LLM_DEBUG === true;
|
||||
}
|
||||
|
||||
function fmt(tag: string, message: string): string {
|
||||
return `[${tag}] ${message}`;
|
||||
}
|
||||
|
||||
export const logger = {
|
||||
debug(tag: string, message: string, ...data: unknown[]): void {
|
||||
if (isDebugEnabled()) {
|
||||
console.debug(fmt(tag, message), ...data);
|
||||
}
|
||||
},
|
||||
|
||||
info(tag: string, message: string, ...data: unknown[]): void {
|
||||
if (isDebugEnabled()) {
|
||||
console.info(fmt(tag, message), ...data);
|
||||
}
|
||||
},
|
||||
|
||||
warn(tag: string, message: string, ...data: unknown[]): void {
|
||||
if (isDebugEnabled()) {
|
||||
console.warn(fmt(tag, message), ...data);
|
||||
}
|
||||
},
|
||||
|
||||
error(tag: string, message: string, ...data: unknown[]): void {
|
||||
if (isDebugEnabled()) {
|
||||
console.error(fmt(tag, message), ...data);
|
||||
}
|
||||
},
|
||||
|
||||
/** Always logs regardless of debug toggle. Destructures ConnectError fields. */
|
||||
grpcError(tag: string, label: string, err: unknown): void {
|
||||
if (err instanceof ConnectError) {
|
||||
console.error(fmt(tag, label), {
|
||||
code: err.code,
|
||||
rawMessage: err.rawMessage,
|
||||
cause: err.cause,
|
||||
metadata: Object.fromEntries(err.metadata.entries())
|
||||
});
|
||||
} else if (err instanceof Error) {
|
||||
console.error(fmt(tag, label), { message: err.message });
|
||||
} else {
|
||||
console.error(fmt(tag, label), err);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -40,7 +40,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex h-screen flex-col overflow-hidden bg-gray-50 dark:bg-gray-900">
|
||||
<PageHeader title="Audit Log" backHref={chatHref} showSampleBadge />
|
||||
<PageHeader title="Audit Log" backHref={chatHref} />
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 px-4 py-3 md:px-6">
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import OrchestrationProgress from '$lib/components/OrchestrationProgress.svelte';
|
||||
import ThinkingSection from '$lib/components/ThinkingSection.svelte';
|
||||
import FinalResult from '$lib/components/FinalResult.svelte';
|
||||
import InferenceStatsPanel from '$lib/components/InferenceStatsPanel.svelte';
|
||||
import SessionSidebar from '$lib/components/SessionSidebar.svelte';
|
||||
import ConfigSidebar from '$lib/components/ConfigSidebar.svelte';
|
||||
import ThemeToggle from '$lib/components/ThemeToggle.svelte';
|
||||
@@ -19,7 +20,7 @@
|
||||
import { onMount, untrack } from 'svelte';
|
||||
import { sessionStore } from '$lib/stores/sessions.svelte';
|
||||
import { isNonDefaultConfig } from '$lib/utils/sessionConfig';
|
||||
import { createOrchestration } from '$lib/composables/useOrchestration.svelte';
|
||||
import { orchestrationStore as orchestration } from '$lib/composables/useOrchestration.svelte';
|
||||
|
||||
let messages: ChatMessage[] = $state([]);
|
||||
let initialized = $state(false);
|
||||
@@ -31,8 +32,6 @@
|
||||
const lineageHref = resolveRoute('/lineage');
|
||||
const memoryHref = resolveRoute('/memory');
|
||||
const auditHref = resolveRoute('/audit');
|
||||
|
||||
const orchestration = createOrchestration();
|
||||
const hasNonDefaultConfig = $derived(isNonDefaultConfig(sessionConfig));
|
||||
|
||||
function navigateToSession(sessionId: string, replace = false) {
|
||||
@@ -191,6 +190,10 @@
|
||||
<FinalResult result={orchestration.finalResult} />
|
||||
{/if}
|
||||
|
||||
{#if orchestration.inferenceStats && !orchestration.isStreaming}
|
||||
<InferenceStatsPanel stats={orchestration.inferenceStats} />
|
||||
{/if}
|
||||
|
||||
{#if orchestration.error}
|
||||
<div class="mx-4 mb-2 flex items-center justify-between gap-3 rounded-lg bg-red-50 dark:bg-red-900/30 px-4 py-2 text-sm text-red-600 dark:text-red-400">
|
||||
<span>{orchestration.error}</span>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import type { LineageNode, SimpleAgentIdentifier } from '$lib/types/lineage';
|
||||
import {
|
||||
buildLineageTree,
|
||||
getSampleLineageData,
|
||||
agentTypeLabel,
|
||||
agentTypeColor
|
||||
} from '$lib/types/lineage';
|
||||
@@ -15,7 +14,7 @@
|
||||
|
||||
const chatHref = resolveRoute('/chat');
|
||||
|
||||
let agents: SimpleAgentIdentifier[] = $state(getSampleLineageData());
|
||||
let agents: SimpleAgentIdentifier[] = $state([]);
|
||||
let treeNodes: LineageNode[] = $derived(buildLineageTree(agents));
|
||||
let selectedNode: LineageNode | null = $state(null);
|
||||
|
||||
@@ -34,7 +33,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex h-screen flex-col overflow-hidden bg-gray-50 dark:bg-gray-900">
|
||||
<PageHeader title="Agent Lineage" backHref={chatHref} showSampleBadge />
|
||||
<PageHeader title="Agent Lineage" backHref={chatHref} />
|
||||
|
||||
<div class="flex flex-1 flex-col md:flex-row overflow-hidden">
|
||||
<!-- Main tree area -->
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex h-screen flex-col overflow-hidden bg-gray-50 dark:bg-gray-900">
|
||||
<PageHeader title="Memory Candidates" backHref={chatHref} showSampleBadge />
|
||||
<PageHeader title="Memory Candidates" backHref={chatHref} />
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 px-4 py-3 md:px-6">
|
||||
|
||||
@@ -3,5 +3,13 @@ import tailwindcss from '@tailwindcss/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [tailwindcss(), sveltekit()]
|
||||
plugins: [tailwindcss(), sveltekit()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/llm_multiverse.v1.OrchestratorService': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user