Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(chat): list a turn's web sources inline under its answer

M3gA-Mind44bb2e70b9b5
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index a872bdc2c2..317f1fb41c 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -125,6 +125,20 @@ export type ThreadComponents = {
* process behind it, so a plain answer gets no footer.
*/
TurnFooter?: ComponentType | undefined;
+ /**
+ * Host-owned list of the web sources this turn visited, rendered at the end
+ * of the message *content* rather than in the footer row.
+ *
+ * Deliberately not part of the footer: that row is a single-line
+ * `flex items-center` whose height is reserved by `ACTION_BAR_HEIGHT` and
+ * asserted in `thread.actionBarSpacing.test.tsx`, so a block that can grow
+ * to several lines does not belong in it. Placed inside the content div it
+ * inherits the `[&>*+*]:mt-3` rhythm the other blocks use.
+ *
+ * Like `TurnFooter`, the component reads the message's own metadata and
+ * returns `null` when the turn visited none, so a plain answer gets nothing.
+ */
+ TurnSources?: ComponentType | undefined;
/** Host-owned attachment previews rendered above the editor. */
ComposerAttachments?: ComponentType | undefined;
/** Host-owned attachment picker rendered in the action row. */
@@ -909,6 +923,7 @@ const AssistantMessage: FC = () => {
ToolGroup,
ReasoningGroup,
TurnFooter,
+ TurnSources,
} = useContext(ThreadComponentsContext);
const ACTION_BAR_PT = 'pt-1.5';
@@ -1027,6 +1042,7 @@ const AssistantMessage: FC = () => {
}
}}
</MessagePrimitive.GroupedParts>
+ {TurnSources ? <TurnSources /> : null}
<MessageError />
</div>
diff --git a/app/src/features/conversations/components/AgentProcessSourcePanel.tsx b/app/src/features/conversations/components/AgentProcessSourcePanel.tsx
index 326ba82287..23f44e7b9c 100644
--- a/app/src/features/conversations/components/AgentProcessSourcePanel.tsx
+++ b/app/src/features/conversations/components/AgentProcessSourcePanel.tsx
@@ -1,15 +1,12 @@
import createDebug from 'debug';
-import { Source, Sources, SourcesContent, SourcesTrigger } from '../../../components/ai-elements';
+import { Sources, SourcesContent, SourcesTrigger } from '../../../components/ai-elements';
import Button from '../../../components/ui/Button';
import { SheetContent, SheetRoot, SheetTitle } from '../../../components/ui/Sheet';
import { useT } from '../../../lib/i18n/I18nContext';
import type { ProcessingTranscriptItem, ToolTimelineEntry } from '../../../store/chatRuntimeSlice';
-import {
- type AgentSource,
- extractAgentSources,
- formatTimelineEntry,
-} from '../../../utils/toolTimelineFormatting';
+import { extractAgentSources, formatTimelineEntry } from '../../../utils/toolTimelineFormatting';
+import { AgentSourceRow } from './AgentSourceRow';
import { AgentSparkIcon } from './AgentTimelineRail';
import { AssistantUiSubagentCall } from './AssistantUiSubagentCall';
import { ProcessingTranscriptView } from './ProcessingTranscriptView';
@@ -17,53 +14,6 @@ import { ToolTimelineBlock } from './ToolTimelineBlock';
const log = createDebug('app:conversations:agent-process-source');
-/** Compact globe glyph for a source row. Inherits `currentColor`. */
-function GlobeIcon({ className }: { className?: string }) {
- return (
- <svg
- viewBox="0 0 12 12"
- width="12"
- height="12"
- aria-hidden
- className={className}
- focusable="false">
- <circle cx="6" cy="6" r="5" fill="none" stroke="currentColor" strokeWidth="1" />
- <path
- d="M1 6h10M6 1c1.8 1.4 1.8 8.6 0 10M6 1c-1.8 1.4-1.8 8.6 0 10"
- fill="none"
- stroke="currentColor"
- strokeWidth="1"
- />
- </svg>
- );
-}
-
-/**
- * One web-source row: globe + hostname title (left) + full URL (right).
- *
- * The anchor itself is `ai-elements`' {@link Source}, which owns the
- * `target="_blank"` + `rel` hardening and the `data-slot="source"` contract;
- * the two-column body is this panel's own, passed as children so the shared
- * primitive does not have to grow a layout variant for it.
- */
-function AgentSourceRow({ source }: { source: AgentSource }) {
- return (
- <li>
- <Source
- href={source.url}
- rel="noreferrer noopener"
- className="flex items-center justify-between gap-3 rounded-md px-1.5 py-1 text-[11px] text-content-secondary hover:bg-surface-hover"
- data-testid="agent-source-row">
- <span className="flex min-w-0 items-center gap-1.5">
- <GlobeIcon className="shrink-0 text-content-faint" />
- <span className="truncate text-content-secondary">{source.title}</span>
- </span>
- <span className="shrink-0 truncate text-content-faint">{source.url}</span>
- </Source>
- </li>
- );
-}
-
function normalizeScopedBody(value: string | undefined | null): string | undefined {
const trimmed = value?.trim();
return trimmed ? trimmed : undefined;
diff --git a/app/src/features/conversations/components/AgentSourceRow.tsx b/app/src/features/conversations/components/AgentSourceRow.tsx
new file mode 100644
index 0000000000..f1bb14efaa
--- /dev/null
+++ b/app/src/features/conversations/components/AgentSourceRow.tsx
@@ -0,0 +1,59 @@
+/**
+ * One web source the agent visited, as a link row.
+ *
+ * Shared by the two surfaces that list sources — the process rail
+ * (`AgentProcessSourcePanel`) and the inline row under a settled answer
+ * (`aui/TurnSources`). Deliberately shared rather than duplicated: this is the
+ * component that renders a model-supplied URL into an `<a href>`, and the URL
+ * is a raw tool-call argument, so it is prompt-injection-influenceable. The
+ * scheme filtering happens upstream in `extractAgentSources`
+ * (`utils/toolTimelineFormatting.ts`, `isHttpUrl`), and keeping one row
+ * component is what stops a second surface from growing its own link markup
+ * that forgets to come through that extractor.
+ *
+ * Layout stays with each caller — the rail's list and the inline disclosure
+ * want different density — but the anchor does not.
+ */
+import { Source } from '../../../components/ai-elements';
+import type { AgentSource } from '../../../utils/toolTimelineFormatting';
+
+/** Compact globe glyph for a source row. Inherits `currentColor`. */
+export function GlobeIcon({ className }: { className?: string }) {
+ return (
+ <svg
+ viewBox="0 0 12 12"
+ width="12"
+ height="12"
+ aria-hidden
+ className={className}
+ focusable="false">
+ <circle cx="6" cy="6" r="5" fill="none" stroke="currentColor" strokeWidth="1" />
+ <path
+ d="M1 6h10M6 1c1.8 1.4 1.8 8.6 0 10M6 1c-1.8 1.4-1.8 8.6 0 10"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1"
+ />
+ </svg>
+ );
+}
+
+export function AgentSourceRow({ source }: { source: AgentSource }) {
+ return (
+ <li>
+ <Source
+ href={source.url}
+ rel="noreferrer noopener"
+ className="flex items-center justify-between gap-3 rounded-md px-1.5 py-1 text-[11px] text-content-secondary hover:bg-surface-hover"
+ data-testid="agent-source-row">
+ <span className="flex min-w-0 items-center gap-1.5">
+ <GlobeIcon className="shrink-0 text-content-faint" />
+ <span className="truncate text-content-secondary">{source.title}</span>
+ </span>
+ <span className="shrink-0 truncate text-content-faint">{source.url}</span>
+ </Source>
+ </li>
+ );
+}
+
+export default AgentSourceRow;
diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsx
index 9bb57429f1..01ad578c1e 100644
--- a/app/src/features/conversations/components/AssistantUiChat.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.tsx
@@ -18,6 +18,7 @@ import { AssistantUiInferenceStatus } from './AssistantUiInferenceStatus';
import { SubagentDrawerHost } from './aui/subagentDrawerHost';
import { TurnFooter } from './aui/TurnFooter';
import { TurnFooterHost } from './aui/turnFooterHost';
+import { TurnSources } from './aui/TurnSources';
import { ChatToolFallback, ChatToolGroup } from './ChatToolParts';
import { contextUsageFromTokenUsage, ContextWindowPill } from './composer/ContextWindowPill';
@@ -282,9 +283,14 @@ export function AssistantUiChat({
// Phase / reasoning round / active tool for the turn in flight. Reads the
// runtime's `extras`, so it needs no props and no dependency here.
RunningStatus: AssistantUiInferenceStatus,
- // One-line process summary under a settled answer, and the only door to
- // the reasoning / narration / tool detail that no longer renders inline.
+ // One-line process summary under a settled answer, and the door to the
+ // reasoning / narration / tool detail that does not render inline.
TurnFooter,
+ // The web sources that turn visited, inline under the answer. The rail
+ // still lists them too — it carries the scoped single-step view and the
+ // whole-run view this does not. Reads the turn's own metadata, so no
+ // props and no dependency here.
+ TurnSources,
onSwitchToMicCloud,
...(attachmentsEnabled
? {
diff --git a/app/src/features/conversations/components/aui/TurnFooter.tsx b/app/src/features/conversations/components/aui/TurnFooter.tsx
index 5473d5bafe..23c3739f3e 100644
--- a/app/src/features/conversations/components/aui/TurnFooter.tsx
+++ b/app/src/features/conversations/components/aui/TurnFooter.tsx
@@ -1,29 +1,11 @@
import { type AssistantState, useAuiState } from '@assistant-ui/react';
import { useT } from '../../../../lib/i18n/I18nContext';
-import type { TurnProcessTrail } from '../../../../providers/assistantUiMessages';
import { useTurnFooterHost } from './turnFooterHost';
+import { readProcessTrail } from './turnProcessTrail';
const selectMessageMetadata = (state: AssistantState) => state.message.metadata;
-/**
- * Narrow the runtime's untyped `message.metadata.custom` back to our own shape.
- *
- * `custom` is `unknown` by contract and the footer can be mounted on a message
- * this projection did not build (the kit's own demo runtime, a test harness),
- * so this returns `null` rather than asserting.
- */
-function readProcessTrail(metadata: unknown): TurnProcessTrail | null {
- if (typeof metadata !== 'object' || metadata === null) return null;
- const custom = (metadata as { custom?: unknown }).custom;
- if (typeof custom !== 'object' || custom === null) return null;
- const trail = (custom as { processTrail?: unknown }).processTrail;
- if (typeof trail !== 'object' || trail === null) return null;
- const candidate = trail as Partial<TurnProcessTrail>;
- if (typeof candidate.steps !== 'number' || typeof candidate.tools !== 'number') return null;
- return candidate as TurnProcessTrail;
-}
-
/**
* The settled turn's one-line process footer — `8 steps · 2 tools` — and the
* single door to the detail behind it.
diff --git a/app/src/features/conversations/components/aui/TurnSources.test.tsx b/app/src/features/conversations/components/aui/TurnSources.test.tsx
new file mode 100644
index 0000000000..e5c7ba0d1a
--- /dev/null
+++ b/app/src/features/conversations/components/aui/TurnSources.test.tsx
@@ -0,0 +1,228 @@
+/**
+ * Inline source list under a settled answer.
+ *
+ * Three things are under test, and the second is the one that matters:
+ *
+ * 1. the list renders the turn's `http(s)` sources;
+ * 2. it is actually **reached from the live `/chat` surface** — mounted through
+ * `AssistantUiChat`, with the trail arriving by the real route (the derived
+ * transcript RPC → `mapDisplayItems` → the adapter → message metadata), not
+ * by rendering `TurnSources` directly with a hand-made prop. A component that
+ * renders correctly in isolation while nothing mounts it is the defect shape
+ * this codebase keeps producing (`legacyMainPanel`, the assistant-ui
+ * reasoning part, the suggestion chips), so proving the wiring is the point;
+ * 3. a non-`http(s)` URL never becomes a link. Sources are derived from the
+ * `url` argument of a fetch tool call, which is raw model output, so a
+ * `javascript:` value must not reach an `<a href>`. `extractAgentSources`
+ * enforces that; this pins that the enforcement survives the trip through
+ * the inline surface.
+ *
+ * Only the RPC is stubbed — the boundary a unit test should stub. Everything
+ * between it and the DOM is production code.
+ */
+import { combineReducers, configureStore } from '@reduxjs/toolkit';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { Provider } from 'react-redux';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { threadApi } from '../../../../services/api/threadApi';
+import chatRuntimeReducer from '../../../../store/chatRuntimeSlice';
+import mascotReducer from '../../../../store/mascotSlice';
+import threadReducer from '../../../../store/threadSlice';
+import type { DerivedDisplayItem } from '../../../../types/derivedTranscript';
+import type { ThreadMessage } from '../../../../types/thread';
+import { AssistantUiChat } from '../AssistantUiChat';
+import { readProcessTrail } from './turnProcessTrail';
+
+const THREAD_ID = 't-sources';
+const REQUEST_ID = 'req-sources';
+const ANSWER = 'Here is what those pages say.';
+
+function toolCall(callId: string, url: string): DerivedDisplayItem {
+ return { kind: 'toolCall', callId, name: 'web_fetch', args: { url }, status: 'success' };
+}
+
+/**
+ * A transcript page as the RPC returns one: **newest-first**.
+ * `mapDisplayItems` reverses it, so the turn boundary has to sit last here to
+ * end up first chronologically — otherwise the tool calls anchor to no turn.
+ */
+function page(...newestFirst: DerivedDisplayItem[]) {
+ return {
+ items: [...newestFirst, { kind: 'turnBoundary', requestId: REQUEST_ID } as DerivedDisplayItem],
+ hasTranscript: true,
+ hasMore: false,
+ };
+}
+
+function agentMessage(): ThreadMessage {
+ return {
+ id: 'm-1',
+ content: ANSWER,
+ type: 'text',
+ extraMetadata: { requestId: REQUEST_ID },
+ sender: 'agent',
+ createdAt: '2026-01-01T00:00:00.000Z',
+ };
+}
+
+function buildStore() {
+ return configureStore({
+ reducer: combineReducers({
+ thread: threadReducer,
+ chatRuntime: chatRuntimeReducer,
+ mascot: mascotReducer,
+ }),
+ preloadedState: {
+ thread: {
+ threads: [
+ {
+ id: THREAD_ID,
+ title: 'Sources thread',
+ chatId: null,
+ isActive: false,
+ messageCount: 1,
+ lastMessageAt: '2026-01-01T00:00:00.000Z',
+ createdAt: '2026-01-01T00:00:00.000Z',
+ labels: [],
+ },
+ ],
+ selectedThreadId: THREAD_ID,
+ activeThreadIds: {},
+ welcomeThreadId: null,
+ messagesByThreadId: { [THREAD_ID]: [agentMessage()] },
+ messages: [agentMessage()],
+ isLoadingThreads: false,
+ isLoadingMessages: false,
+ messagesError: null,
+ },
+ } as never,
+ });
+}
+
+/** Mounted exactly as `/chat` mounts it — never `<TurnSources />` directly. */
+function renderChat() {
+ return render(
+ <Provider store={buildStore()}>
+ <AssistantUiChat
+ model={null}
+ onModelChange={vi.fn()}
+ inputValue=""
+ onInputValueChange={vi.fn()}
+ attachments={[]}
+ onAttachFiles={vi.fn()}
+ onRemoveAttachment={vi.fn()}
+ maxAttachments={5}
+ attachmentsEnabled={false}
+ attachmentInteractionBlocked={false}
+ onAttachmentOnlySend={vi.fn()}
+ />
+ </Provider>
+ );
+}
+
+/**
+ * Open the disclosure. Collapsed is the shipped default — the answer stays the
+ * top of the turn — so the rows are genuinely absent from the DOM until the
+ * reader asks for them, and a test that asserted hrefs without this would be
+ * asserting against the closed state.
+ */
+async function expandSources(): Promise<void> {
+ await userEvent.click(document.querySelector('[data-slot="sources-trigger"]') as HTMLElement);
+}
+
+function sourceHrefs(): (string | null)[] {
+ return Array.from(
+ document.querySelectorAll<HTMLAnchorElement>('[data-testid="agent-source-row"]')
+ ).map(anchor => anchor.getAttribute('href'));
+}
+
+beforeEach(() => {
+ vi.restoreAllMocks();
+});
+
+describe('inline turn sources', () => {
+ it('lists the turn sources on the live chat surface', async () => {
+ vi.spyOn(threadApi, 'getDerivedTranscript').mockResolvedValue(
+ page(toolCall('c2', 'https://docs.rs/b'), toolCall('c1', 'https://example.com/a')) as never
+ );
+
+ renderChat();
+
+ // Reached through `AssistantUiChat` -> `Thread` -> the `TurnSources` slot,
+ // so this proves the wiring and not merely the component.
+ await waitFor(() => expect(screen.getByTestId('turn-sources')).toBeTruthy());
+
+ // Collapsed by design: the count is visible, the rows are not yet.
+ expect(screen.getByText(/\(2\)$/)).toBeTruthy();
+ expect(sourceHrefs()).toEqual([]);
+
+ await expandSources();
+ expect(sourceHrefs()).toEqual(['https://example.com/a', 'https://docs.rs/b']);
+ });
+
+ it('renders nothing when the turn visited no sources', async () => {
+ vi.spyOn(threadApi, 'getDerivedTranscript').mockResolvedValue(page() as never);
+
+ renderChat();
+
+ // Guarded so the absence cannot pass on a blank tree: the answer has to be
+ // on screen for this assertion to mean anything.
+ await waitFor(() => expect(screen.getByText(ANSWER)).toBeTruthy());
+ expect(document.querySelector('[data-testid="turn-sources"]')).toBeNull();
+ });
+
+ it('never renders a non-http(s) url as a link', async () => {
+ vi.spyOn(threadApi, 'getDerivedTranscript').mockResolvedValue(
+ page(
+ toolCall('c2', 'https://example.com/safe'),
+ toolCall('c1', 'javascript:alert(1)')
+ ) as never
+ );
+
+ renderChat();
+
+ await waitFor(() => expect(screen.getByTestId('turn-sources')).toBeTruthy());
+ await expandSources();
+
+ // One row, not two: the `javascript:` entry is dropped by
+ // `extractAgentSources`, so it is never counted and never linked.
+ expect(sourceHrefs()).toEqual(['https://example.com/safe']);
+ expect(document.body.innerHTML).not.toContain('javascript:');
+ });
+});
+
+/**
+ * The validator both trail consumers share.
+ *
+ * It used to check `steps` and `tools` and then cast to `TurnProcessTrail`,
+ * which claimed more than it had proven — `timeline` was never inspected, and
+ * `TurnSources` reads exactly that field. These pin the tightened version.
+ */
+describe('readProcessTrail', () => {
+ const trail = (over: Record<string, unknown>) => ({
+ custom: { processTrail: { steps: 2, tools: 1, timeline: [], transcript: [], ...over } },
+ });
+
+ it('accepts a complete trail', () => {
+ expect(readProcessTrail(trail({}))).not.toBeNull();
+ });
+
+ it('rejects a trail whose timeline is not an array', () => {
+ // The field `TurnSources` spreads. Before the validator checked it, this
+ // shape type-checked as a `TurnProcessTrail` and threw at the spread.
+ expect(readProcessTrail(trail({ timeline: undefined }))).toBeNull();
+ expect(readProcessTrail(trail({ timeline: 'not-an-array' }))).toBeNull();
+ });
+
+ it('rejects a trail whose transcript is not an array', () => {
+ expect(readProcessTrail(trail({ transcript: undefined }))).toBeNull();
+ });
+
+ it('rejects metadata that carries no trail at all', () => {
+ expect(readProcessTrail(undefined)).toBeNull();
+ expect(readProcessTrail({})).toBeNull();
+ expect(readProcessTrail({ custom: {} })).toBeNull();
+ });
+});
diff --git a/app/src/features/conversations/components/aui/TurnSources.tsx b/app/src/features/conversations/components/aui/TurnSources.tsx
new file mode 100644
index 0000000000..66b9d8f906
--- /dev/null
+++ b/app/src/features/conversations/components/aui/TurnSources.tsx
@@ -0,0 +1,69 @@
+/**
+ * The web sources a settled turn visited, listed inline under its answer.
+ *
+ * ## Why inline, when the rail already lists them
+ *
+ * The process rail (`AgentProcessSourcePanel`) has shown sources for a while,
+ * behind the `TurnFooter` click. This is not a second copy of something already
+ * on screen: on a settled turn the URL is not visible anywhere without a click.
+ * `web_fetch` implements no `display_detail`, so its tool card's collapsed
+ * trigger carries no URL chip (`AssistantUiToolCall` renders that chip only when
+ * `detail` is present), and the arguments live in the card's body inside a
+ * `Collapsible` whose `defaultOpen` is `running` — i.e. closed once the turn
+ * finishes. So "which pages did it read?" currently costs either one expand per
+ * fetch card or a trip to the rail.
+ *
+ * ## Why it reuses `extractAgentSources`
+ *
+ * Sources are not a model-declared message part — nothing in this app emits an
+ * assistant-ui `source` part. They are derived client-side from the `url`
+ * argument of the fetch/browse tools (`URL_SOURCE_TOOLS`). That argument is raw
+ * model output and therefore prompt-injection-influenceable, which is why
+ * `extractAgentSources` admits only `http(s)` URLs — a `javascript:` or `file:`
+ * value must never reach an `<a href>`. Deriving sources here through any other
+ * path would mean re-implementing that filter, so this calls the one extractor
+ * and renders the one shared row component.
+ *
+ * Collapsed by default, unlike the rail's copy: the answer stays the top of the
+ * turn. Same reasoning that put the process behind the footer to begin with.
+ */
+import { type AssistantState, useAuiState } from '@assistant-ui/react';
+
+import { Sources, SourcesContent, SourcesTrigger } from '../../../../components/ai-elements';
+import { useT } from '../../../../lib/i18n/I18nContext';
+import { extractAgentSources } from '../../../../utils/toolTimelineFormatting';
+import { AgentSourceRow } from '../AgentSourceRow';
+import { readProcessTrail } from './turnProcessTrail';
+
+const selectMessageMetadata = (state: AssistantState) => state.message.metadata;
+
+export function TurnSources() {
+ const { t } = useT();
+ const trail = readProcessTrail(useAuiState(selectMessageMetadata));
+ // `readProcessTrail` now validates `timeline` is an array, so this cannot be
+ // an unchecked read; a message with no trail at all yields `null` above.
+ const sources = trail ? extractAgentSources([...trail.timeline]) : [];
+
+ if (sources.length === 0) return null;
+
+ return (
+ <Sources asChild className="mb-0 text-content-muted">
+ <section data-testid="turn-sources">
+ <SourcesTrigger
+ count={sources.length}
+ className="text-content-muted hover:text-content-secondary text-xs transition-colors">
+ {t('conversations.agentTaskInsights.sourcesHeading')} ({sources.length})
+ </SourcesTrigger>
+ <SourcesContent className="mt-1 w-full gap-0">
+ <ul className="space-y-0.5">
+ {sources.map(source => (
+ <AgentSourceRow key={source.id} source={source} />
+ ))}
+ </ul>
+ </SourcesContent>
+ </section>
+ </Sources>
+ );
+}
+
+export default TurnSources;
diff --git a/app/src/features/conversations/components/aui/turnProcessTrail.ts b/app/src/features/conversations/components/aui/turnProcessTrail.ts
new file mode 100644
index 0000000000..c034896765
--- /dev/null
+++ b/app/src/features/conversations/components/aui/turnProcessTrail.ts
@@ -0,0 +1,34 @@
+/**
+ * Read the settled turn's `TurnProcessTrail` off assistant-ui's message
+ * metadata.
+ *
+ * Shared by the two consumers of that trail — `TurnFooter` (the `8 steps ·
+ * 2 tools` door) and `TurnSources` (the inline source list) — so both agree on
+ * what counts as a usable trail.
+ */
+import type { TurnProcessTrail } from '../../../../providers/assistantUiMessages';
+
+/**
+ * Narrow the runtime's untyped `message.metadata.custom` back to our own shape.
+ *
+ * `custom` is `unknown` by contract and either consumer can be mounted on a
+ * message this projection did not build (the kit's own demo runtime, a test
+ * harness), so this returns `null` rather than asserting.
+ *
+ * **Every field is checked, including the two arrays.** The previous version
+ * validated `steps` and `tools` and then cast, which asserted more than it had
+ * proven: a caller reading `trail.timeline` got a typed array that the
+ * validator had never looked at. `TurnSources` reads exactly that field, so the
+ * gap stopped being theoretical.
+ */
+export function readProcessTrail(metadata: unknown): TurnProcessTrail | null {
+ if (typeof metadata !== 'object' || metadata === null) return null;
+ const custom = (metadata as { custom?: unknown }).custom;
+ if (typeof custom !== 'object' || custom === null) return null;
+ const trail = (custom as { processTrail?: unknown }).processTrail;
+ if (typeof trail !== 'object' || trail === null) return null;
+ const candidate = trail as Partial<TurnProcessTrail>;
+ if (typeof candidate.steps !== 'number' || typeof candidate.tools !== 'number') return null;
+ if (!Array.isArray(candidate.timeline) || !Array.isArray(candidate.transcript)) return null;
+ return candidate as TurnProcessTrail;
+}
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
index f060a8853a..cea81728a9 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_conversation_intelligence.rs
@@ -129,6 +129,20 @@ Capability {
status: CapabilityStatus::Beta,
privacy: None,
},
+Capability {
+ id: "conversation.agent_sources",
+ name: "Agent Sources",
+ domain: "conversation",
+ category: CapabilityCategory::Conversation,
+ description: "List the web pages an answer was built from, derived from the agent's own \
+ fetch/browse calls rather than claimed by the model. Only http(s) addresses are \
+ linked.",
+ how_to: "Chat > Sources, under a settled answer (collapsed; click to expand). The same \
+ list, plus per-step detail and the whole run, is in Chat > the turn's process \
+ footer > Sources.",
+ status: CapabilityStatus::Beta,
+ privacy: None,
+ },
Capability {
id: "conversation.plan_review",
name: "Plan Review",