Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(models): direct image calls and the chain cost total on the hosted tool card and IM line (#2651)

Call White3382dd14033b
diff --git a/core/hosted_activity.py b/core/hosted_activity.py
index 3a472d1a1..eec1c00b4 100644
--- a/core/hosted_activity.py
+++ b/core/hosted_activity.py
@@ -76,6 +76,8 @@ class HostedActivity:
# How many calls ``cost`` covers: a native response's figure is for all its calls.
cost_calls: int
duration_ms: Optional[int] = None
+ # ``cost`` is a lower bound: an attempt reported no price, so the call cost at least this.
+ cost_at_least: bool = False
# The stable code of a reason Avibe worded itself (``HOSTED_ERROR_CODES``), by
# which each surface says it in its reader's language; None for a provider's own.
error_code: Optional[str] = None
@@ -128,6 +130,8 @@ class HostedActivity:
cost: dict[str, Any] = {"basis": self.cost.basis, "calls": self.cost_calls}
if self.cost.usd is not None:
cost["usd"] = self.cost.usd
+ if self.cost_at_least:
+ cost["at_least"] = True
payload["cost"] = cost
return payload
@@ -240,7 +244,7 @@ def proxy_activity(
)
size = arguments.get("size") if isinstance(arguments.get("size"), str) else None
execution = result.execution
- cost, cost_calls = _chain_cost(execution)
+ cost, at_least = _chain_cost(execution)
# What the executor reports it did (an image's rendered prompt and resolved size and quality), read as a native
# call's block action is.
ran = result.action if result.action is not None and result.action.type == "generate" else None
@@ -264,29 +268,31 @@ def proxy_activity(
quality=ran.quality if ran is not None else None,
revised_prompt=ran.prompt if ran is not None else None,
cost=cost,
- cost_calls=cost_calls,
+ cost_calls=1,
duration_ms=duration_ms,
+ cost_at_least=at_least,
)
-def _chain_cost(execution: Optional[ProxyExecution]) -> tuple[Optional[HostedCost], int]:
- """What a proxied call cost over every executor attempt it billed, and how many attempts that is (§6).
+def _chain_cost(execution: Optional[ProxyExecution]) -> tuple[Optional[HostedCost], bool]:
+ """What a proxied call cost over every executor attempt it billed, and whether that is only a lower bound (§6).
``execution.cost`` is the last attempt's own, and ``failed_attempts`` the earlier billed ones. Every attempt
included is ``included``; otherwise the known figures are summed, ``reported`` only when each is. An attempt
- without a cost leaves the total unknown rather than understated.
+ without a cost makes the sum a lower bound, never a complete figure; with no priced attempt to sum, the cost is
+ unknown rather than "at least $0".
"""
if execution is None:
- return None, 1
+ return None, False
costs = [*(attempt.cost for attempt in execution.failed_attempts), execution.cost]
- if any(cost is None for cost in costs):
- return None, len(costs)
- if all(cost.basis == "included" for cost in costs):
- return HostedCost(basis="included"), len(costs)
- priced = [cost for cost in costs if cost.basis != "included"]
+ known = [cost for cost in costs if cost is not None]
+ unpriced = len(known) < len(costs)
+ priced = [cost for cost in known if cost.basis != "included"]
+ if not priced:
+ return (HostedCost(basis="included"), False) if known and not unpriced else (None, False)
basis = "reported" if all(cost.basis == "reported" for cost in priced) else "list"
- return HostedCost(basis=basis, usd=round(sum(cost.usd or 0.0 for cost in priced), 6)), len(costs)
+ return HostedCost(basis=basis, usd=round(sum(cost.usd or 0.0 for cost in priced), 6)), unpriced
def _vendor_label(provider: Optional[str]) -> Optional[str]:
@@ -333,6 +339,8 @@ def _cost(activity: HostedActivity, lang: str) -> Optional[str]:
else:
key = "hostedTools.cost.list" if cost.basis == "list" else "hostedTools.cost.reported"
text = i18n_t(key, lang, usd=_usd(cost.usd))
+ if activity.cost_at_least:
+ text = i18n_t("hostedTools.cost.atLeast", lang, cost=text)
if activity.cost_calls > 1:
text = i18n_t("hostedTools.cost.calls", lang, cost=text, calls=activity.cost_calls)
return text
diff --git a/docs/plans/vibey-hosted-tools.md b/docs/plans/vibey-hosted-tools.md
index 3c0845d5c..3f9275015 100644
--- a/docs/plans/vibey-hosted-tools.md
+++ b/docs/plans/vibey-hosted-tools.md
@@ -519,9 +519,10 @@ These rules are C-1 rows in `cross-provider.md` and per-protocol rows in `conver
both render: `usd` is the sum of the known figures over the record's attempt and `failed_attempts[]`; every
attempt `included` gives `included`; the basis is `reported` only when every summed figure is reported, else
`list` (shown with ≈); an attempt without a `cost` makes the total a lower bound, shown as "at least $X" /
- "至少 $X", never as complete. With `failed_attempts`, the card also names the attempt count ("3 attempts" /
- "尝试 3 次"). B1 ships the sum, its basis and the attempt count (as the projection's `calls`); until D2 adds the
- lower-bound form, an attempt without a `cost` leaves the total unknown rather than shown as complete.
+ "至少 $X", never as complete. The projection carries the lower bound as `cost.at_least`; `cost.calls` stays the
+ number of calls one native response's figure covers. With no priced attempt to sum, the cost is unknown rather
+ than "at least $0". No attempt count is shown: the producer lists billable attempts only and does not say whether
+ the last attempt was billed, so any count would be inferred, and the total already says what the call cost.
- The executor request is a short model request because no vendor exposes search without a model: Anthropic,
OpenAI's public API, xAI and Google all run search inside a model call.
- **The result is the canonical record** (v1's rules, unchanged): a `HostedRecord` with `sources[]` in the
diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yaml
index 4650faa32..919a89360 100644
--- a/tests/scenarios/model_hub/catalog.yaml
+++ b/tests/scenarios/model_hub/catalog.yaml
@@ -237,11 +237,14 @@ scenarios:
- tests/test_provider_overlay.py::test_an_image_model_entry_is_read_in_a_stable_form
- tests/test_provider_overlay.py::test_each_vendors_executor_model_runs_every_search_tool_the_vendor_offers
- id: MH-HOSTED-UI-008
- name: The execution-process group draws a native and a proxied hosted call as one card, with how it ran, its known cost and its sources or image
+ name: The execution-process group draws a native, a proxied and a direct hosted call as one card, with how it ran, its known cost (a lower bound when an attempt was unpriced) and its sources or image
status: covered
kind: observation
layer: unit
- test: ui/src/components/workbench/HostedToolRow.test.tsx::MH-HOSTED-UI-008
+ test:
+ - 'ui/src/components/workbench/HostedToolRow.test.tsx::MH-HOSTED-UI-008: shows a native and a proxied call the same way, each with how it ran and its known cost'
+ - 'ui/src/components/workbench/HostedToolRow.test.tsx::MH-HOSTED-UI-008: shows a direct image call with how it ran, its file and the prompt it rendered, and no cost when none is known'
+ - 'ui/src/components/workbench/HostedToolRow.test.tsx::MH-HOSTED-UI-008: shows a total an unpriced attempt left only as a lower bound'
- id: MH-HOSTED-UI-009
name: A hosted call's card payload is projected from the canonical C-1 records in the shape the Web renders
status: covered
diff --git a/tests/test_hosted_activity.py b/tests/test_hosted_activity.py
index d4a2d6caf..9d554b57d 100644
--- a/tests/test_hosted_activity.py
+++ b/tests/test_hosted_activity.py
@@ -171,7 +171,21 @@ def proxy_unreachable():
)
[email protected]("build", [native_web_search, proxy_x_search, direct_image, proxy_failed, proxy_unreachable])
+def proxy_retried():
+ """An X search whose first executor failed after it billed and reported no price: the cost is a lower bound."""
+ return proxy_activity(
+ _x_call("call_x6", "from:OpenAI"),
+ HostedResult(
+ record=HostedRecord(status="completed", sources=POSTS[:1]),
+ execution=replace(XAI, failed_attempts=(_attempt("src_relaygpt1", "metered", None),)),
+ ),
+ source_names=NAMES,
+ )
+
+
+ "build", [native_web_search, proxy_x_search, direct_image, proxy_failed, proxy_unreachable, proxy_retried]
+)
def test_payloads_match_the_shape_the_web_card_renders(build):
"""MH-HOSTED-UI-009: every mode and outcome the card distinguishes, from the canonical records each producer writes.
@@ -300,22 +314,27 @@ def _attempt(source_id: str, billing: str, cost: HostedCost | None):
@pytest.mark.parametrize(
- ("failed", "last", "cost", "line_cost"),
+ ("failed", "last", "cost", "line_tail"),
[
- # A metered failure before the call that ran: both charges, and how many calls they cover.
+ # A metered failure before the call that ran: both charges, summed.
((("src_relaygpt1", "metered", HostedCost(basis="list", usd=0.02)),), HostedCost(basis="reported", usd=0.11),
- {"basis": "list", "usd": 0.13, "calls": 2}, "≈ $0.13 for 2 calls"),
+ {"basis": "list", "usd": 0.13, "calls": 1}, "≈ $0.13"),
((("src_relaygpt1", "metered", HostedCost(basis="reported", usd=0.02)),), HostedCost(basis="reported", usd=0.11),
- {"basis": "reported", "usd": 0.13, "calls": 2}, "$0.13 for 2 calls"),
+ {"basis": "reported", "usd": 0.13, "calls": 1}, "$0.13"),
# A subscription attempt adds no money.
((("src_chatgpt01", "monthly", HostedCost(basis="included")),), HostedCost(basis="reported", usd=0.11),
- {"basis": "reported", "usd": 0.11, "calls": 2}, "$0.11 for 2 calls"),
- # A billed attempt with no known price: the total is unknown, never shown smaller than it was.
- ((("src_relaygpt1", "metered", None),), HostedCost(basis="reported", usd=0.11), None, None),
+ {"basis": "reported", "usd": 0.11, "calls": 1}, "$0.11"),
+ # A billed attempt with no known price: the total is a lower bound, never shown as complete.
+ ((("src_relaygpt1", "metered", None),), HostedCost(basis="reported", usd=0.11),
+ {"basis": "reported", "usd": 0.11, "calls": 1, "at_least": True}, "at least $0.11"),
+ # Nothing priced to sum: the cost is unknown, not "at least $0".
+ ((("src_chatgpt01", "monthly", HostedCost(basis="included")),), None, None, None),
+ ((("src_relaygpt1", "metered", None),), None, None, None),
],
)
-def test_a_proxied_calls_cost_counts_every_billed_attempt(failed, last, cost, line_cost):
- """MH-HOSTED-GATEWAY-005: the card and the IM line show what the whole executor chain cost, never less."""
+def test_a_proxied_calls_cost_counts_every_billed_attempt(failed, last, cost, line_tail):
+ """MH-HOSTED-GATEWAY-005: the card and the IM line show what the whole executor chain cost, never less, and a
+ total an attempt left unpriced only as a lower bound."""
activity = proxy_activity(
_x_call("call_x5", "from:OpenAI"),
@@ -324,9 +343,10 @@ def test_a_proxied_calls_cost_counts_every_billed_attempt(failed, last, cost, li
execution=replace(XAI, cost=last, failed_attempts=tuple(_attempt(*item) for item in failed)),
),
)
- assert activity.to_payload().get("cost") == cost
+ payload = activity.to_payload()
+ assert payload.get("cost") == cost
line = hosted_line(activity, "en")
- assert line.endswith(f" · {line_cost}") if line_cost else "$" not in line
+ assert line.endswith(f" · {line_tail}") if line_tail else "$" not in line
def test_the_im_line_escapes_the_quoted_subject_for_its_destination():
diff --git a/ui/src/components/workbench/HostedToolRow.test.tsx b/ui/src/components/workbench/HostedToolRow.test.tsx
index 5b7e3cdab..1cb42b4c6 100644
--- a/ui/src/components/workbench/HostedToolRow.test.tsx
+++ b/ui/src/components/workbench/HostedToolRow.test.tsx
@@ -81,22 +81,33 @@ describe('hosted tool cards', () => {
within(failed).getByText('no Source is verified for X search');
});
- it('shows a generated image with its prompt and file, and no cost when none is known', () => {
+ it('MH-HOSTED-UI-008: shows a direct image call with how it ran, its file and the prompt it rendered, and no cost when none is known', () => {
renderGroup([{
- ...fixture.native_image,
- images: [{ ...fixture.native_image.images[0], media_url: '/api/media/tok_3f2a?w=1536&h=1024', bytes: 1_993_000 }],
+ ...fixture.direct_image,
+ images: [{ ...fixture.direct_image.images[0], media_url: '/api/media/tok_3f2a?w=1536&h=1024', bytes: 1_993_000 }],
}]);
- const image = row('ig_01');
+ const image = row('call_ig1');
+ within(image).getByText('image_generate');
+ within(image).getByText('Direct · OpenAI');
within(image).getByText('1 image · 1536×1024');
expect(image.textContent).not.toMatch(/\$/);
fireEvent.click(within(image).getByRole('button'));
- const figure = image.querySelector('[data-hosted-image="ig_01"]') as HTMLElement;
+ within(image).getByText('Ran directly on relay-gpt · gpt-image-2');
+ const figure = image.querySelector('[data-hosted-image="call_ig1"]') as HTMLElement;
expect((figure.querySelector('img') as HTMLImageElement).getAttribute('src')).toBe('/api/media/tok_3f2a?w=1536&h=1024');
within(figure).getByRole('link', { name: '3f2a.png' });
within(figure).getByText('1.9 MB');
within(figure).getByText('Revised prompt');
- within(figure).getByText(fixture.native_image.revised_prompt);
+ within(figure).getByText(fixture.direct_image.revised_prompt);
+ });
+
+ it('MH-HOSTED-UI-008: shows a total an unpriced attempt left only as a lower bound', () => {
+ renderGroup(['proxy_retried'], 'zh');
+ within(row('call_x6')).getByText('至少 $0.11');
+ cleanup();
+ renderGroup(['proxy_retried']);
+ within(row('call_x6')).getByText('at least $0.11');
});
it.each([
diff --git a/ui/src/components/workbench/HostedToolRow.tsx b/ui/src/components/workbench/HostedToolRow.tsx
index af5a26e54..59baba315 100644
--- a/ui/src/components/workbench/HostedToolRow.tsx
+++ b/ui/src/components/workbench/HostedToolRow.tsx
@@ -1,10 +1,10 @@
// A hosted tool call in the execution-process group (`vibey-hosted-tools.md` §6.4,
-// design.pen frames DA8aJ and t2P7VH): the query, how it ran (natively, or by which
-// executor), what it cost when known, and the sources or image it produced. A
-// native and a proxied call draw the same card from the same record.
+// design.pen frames DA8aJ and t2P7VH): the query, how it ran (natively, by which
+// executor, or directly on an image endpoint), what it cost when known, and the
+// sources or image it produced. Every mode draws the same card from the same record.
import * as React from 'react';
import { useTranslation } from 'react-i18next';
-import { AtSign, Check, ChevronRight, CircleSlash, Download, FileImage, Globe, Image as ImageIcon, TriangleAlert, Waypoints, WandSparkles } from 'lucide-react';
+import { AtSign, Check, ChevronRight, CircleSlash, Download, FileImage, Globe, Image as ImageIcon, TriangleAlert, Waypoints, WandSparkles, Zap } from 'lucide-react';
import clsx from 'clsx';
import { ChatImage } from '../ui/chat-image';
@@ -15,7 +15,13 @@ import { hostedCompleted, type HostedActivity, type HostedActivityImage, type Ho
const TOOL_ICON: Record<HostedToolName, React.ComponentType<{ className?: string }>> = {
web_search: Globe,
x_search: AtSign,
- image_generation: ImageIcon,
+ image_generate: ImageIcon,
+};
+
+const RAN_KEY: Record<HostedActivity['mode'], 'ranNative' | 'ranProxy' | 'ranDirect'> = {
+ native: 'ranNative',
+ proxy: 'ranProxy',
+ direct: 'ranDirect',
};
const vendorLabel = (provider: string | undefined): string | null =>
@@ -41,18 +47,22 @@ const fileName = (path: string): string => path.split(/[\\/]/).pop() || path;
const formatBytes = (bytes: number): string =>
bytes >= 1024 * 1024 ? `${(bytes / (1024 * 1024)).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`;
-/** What a call cost, only when it is known; unknown is never shown as zero. */
+/**
+ * What a call cost, only when it is known; unknown is never shown as zero, and a
+ * lower bound (an attempt reported no price) never as a complete figure.
+ */
const useHostedCost = (card: HostedActivity): string | null => {
const { t } = useTranslation();
const cost = card.cost;
if (!cost) return null;
const figure = cost.basis === 'included'
- ? t('chat.agentActivity.hosted.cost.included')
+ ? t('chat.agentActivity.hosted.cost.included') as string
: cost.usd === undefined
? null
- : t(cost.basis === 'list' ? 'chat.agentActivity.hosted.cost.list' : 'chat.agentActivity.hosted.cost.reported', { usd: formatUsd(cost.usd) });
+ : t(cost.basis === 'list' ? 'chat.agentActivity.hosted.cost.list' : 'chat.agentActivity.hosted.cost.reported', { usd: formatUsd(cost.usd) }) as string;
if (figure === null) return null;
- return cost.calls > 1 ? t('chat.agentActivity.hosted.cost.calls', { cost: figure, count: cost.calls }) : figure;
+ const bounded = cost.at_least ? t('chat.agentActivity.hosted.cost.atLeast', { cost: figure }) as string : figure;
+ return cost.calls > 1 ? t('chat.agentActivity.hosted.cost.calls', { cost: bounded, count: cost.calls }) as string : bounded;
};
/** 「原生 · Anthropic」 or 「由 xAI 代理」 once it completed; until then, its status. */
@@ -74,6 +84,14 @@ export const HostedModeChip: React.FC<{ card: HostedActivity }> = ({ card }) =>
}
const vendor = vendorLabel(card.provider);
if (!vendor) return null;
+ if (card.mode === 'direct') {
+ return (
+ <span className="inline-flex shrink-0 items-center gap-1 rounded-full border border-cyan/40 bg-cyan-soft px-2 py-px text-[11px] font-medium text-cyan-ink">
+ <Zap className="size-3" aria-hidden="true" />
+ {t('chat.agentActivity.hosted.mode.direct', { provider: vendor })}
+ </span>
+ );
+ }
return card.mode === 'native' ? (
<span className="inline-flex shrink-0 items-center gap-1 rounded-full border border-mint/40 bg-mint-soft px-2 py-px text-[11px] font-medium text-mint-ink">
<Check className="size-3" aria-hidden="true" />
@@ -91,7 +109,7 @@ export const HostedModeChip: React.FC<{ card: HostedActivity }> = ({ card }) =>
const useCountLabel = (card: HostedActivity): string | null => {
const { t } = useTranslation();
if (!hostedCompleted(card)) return null;
- if (card.tool === 'image_generation') {
+ if (card.tool === 'image_generate') {
if (card.images.length === 0) return null;
const [first] = card.images;
const count = t('chat.agentActivity.hosted.count.images', { count: card.images.length });
@@ -144,7 +162,7 @@ const HostedDetail: React.FC<{ card: HostedActivity }> = ({ card }) => {
const completed = hostedCompleted(card);
const where = completed ? [card.source_name ?? vendorLabel(card.provider), card.model].filter(Boolean).join(' · ') : '';
const facts = [
- where && t(card.mode === 'proxy' ? 'chat.agentActivity.hosted.ranProxy' : 'chat.agentActivity.hosted.ranNative', { where }),
+ where && t(`chat.agentActivity.hosted.${RAN_KEY[card.mode]}`, { where }),
completed && card.duration_ms !== undefined && t('chat.agentActivity.hosted.duration', { seconds: Math.max(1, Math.round(card.duration_ms / 1000)) }),
cost,
].filter(Boolean);
@@ -152,9 +170,11 @@ const HostedDetail: React.FC<{ card: HostedActivity }> = ({ card }) => {
<div className="mx-1.5 mb-1 mt-0.5 flex flex-col overflow-hidden rounded-md border border-border bg-foreground/[0.03]">
{facts.length > 0 && (
<div className="flex items-center gap-1.5 border-b border-border px-2.5 py-1.5 text-[11px] text-muted">
- {completed && (card.mode === 'proxy'
- ? <Waypoints className="size-3 shrink-0 text-cyan-ink" aria-hidden="true" />
- : <Check className="size-3 shrink-0 text-mint-ink" aria-hidden="true" />)}
+ {completed && (card.mode === 'native'
+ ? <Check className="size-3 shrink-0 text-mint-ink" aria-hidden="true" />
+ : card.mode === 'direct'
+ ? <Zap className="size-3 shrink-0 text-cyan-ink" aria-hidden="true" />
+ : <Waypoints className="size-3 shrink-0 text-cyan-ink" aria-hidden="true" />)}
<span className="min-w-0">{facts.join(' · ')}</span>
</div>
)}
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index c671c256c..5eb0ba580 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -4959,7 +4959,8 @@
},
"mode": {
"native": "Native · {{provider}}",
- "proxy": "Via {{provider}} proxy"
+ "proxy": "Via {{provider}} proxy",
+ "direct": "Direct · {{provider}}"
},
"status": {
"failed": "Failed",
@@ -4970,6 +4971,7 @@
"included": "Included in subscription",
"list": "≈ ${{usd}}",
"reported": "${{usd}}",
+ "atLeast": "at least {{cost}}",
"calls_one": "{{cost}} for {{count}} call",
"calls_other": "{{cost}} for {{count}} calls"
},
@@ -4983,6 +4985,7 @@
},
"ranNative": "Ran natively on {{where}}",
"ranProxy": "Run by proxy executor {{where}}",
+ "ranDirect": "Ran directly on {{where}}",
"duration": "took {{seconds}} s",
"alsoSearched": "Also searched: {{queries}}",
"image": {
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index a3fc07d5d..3d3648655 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -4959,7 +4959,8 @@
},
"mode": {
"native": "原生 · {{provider}}",
- "proxy": "由 {{provider}} 代理"
+ "proxy": "由 {{provider}} 代理",
+ "direct": "{{provider}} 直连"
},
"status": {
"failed": "失败",
@@ -4970,6 +4971,7 @@
"included": "订阅内含",
"list": "≈ ${{usd}}",
"reported": "${{usd}}",
+ "atLeast": "至少 {{cost}}",
"calls_one": "{{cost}}({{count}} 次调用)",
"calls_other": "{{cost}}({{count}} 次调用)"
},
@@ -4983,6 +4985,7 @@
},
"ranNative": "原生执行:{{where}}",
"ranProxy": "代理执行:{{where}}",
+ "ranDirect": "直连执行:{{where}}",
"duration": "用时 {{seconds}} 秒",
"alsoSearched": "还搜索了:{{queries}}",
"image": {
diff --git a/ui/src/lib/hostedActivity.fixture.json b/ui/src/lib/hostedActivity.fixture.json
index 9ca4be885..9cdcf7e76 100644
--- a/ui/src/lib/hostedActivity.fixture.json
+++ b/ui/src/lib/hostedActivity.fixture.json
@@ -43,24 +43,6 @@
"images": [],
"cost": { "basis": "reported", "usd": 0.11, "calls": 1 }
},
- "native_image": {
- "version": 1,
- "call_id": "ig_01",
- "tool": "image_generation",
- "mode": "native",
- "status": "completed",
- "subject": "A wide photo of an open laptop on a desk at night, empty dark space in the upper right",
- "revised_prompt": "A wide photo of an open laptop on a desk at night, empty dark space in the upper right",
- "action": "generate",
- "provider": "openai",
- "source_id": "src_relaygpt1",
- "source_name": "relay-gpt",
- "model": "gpt-6.1-sol",
- "size": "1536x1024",
- "quality": "medium",
- "sources": [],
- "images": [{ "path": "/media/3f2a.png", "mime": "image/png", "width": 1536, "height": 1024, "bytes": 1993000 }]
- },
"proxy_failed": {
"version": 1,
"call_id": "call_x2",
@@ -100,5 +82,32 @@
"size": "1536x1024",
"quality": "medium",
"revised_prompt": "A wide photo of an open laptop on a desk at night, empty dark space in the upper right"
+ },
+ "proxy_retried": {
+ "version": 1,
+ "call_id": "call_x6",
+ "tool": "x_search",
+ "mode": "proxy",
+ "status": "completed",
+ "sources": [
+ {
+ "url": "https://x.com/OpenAI/status/1",
+ "title": "DevDay 2026 recap: everything we shipped this week",
+ "snippet": "Recordings and the launch list in one post.",
+ "page_age": "2 days ago"
+ }
+ ],
+ "images": [],
+ "subject": "from:OpenAI",
+ "provider": "xai",
+ "source_id": "src_grok0001",
+ "source_name": "Grok",
+ "model": "grok-4.6",
+ "cost": {
+ "basis": "reported",
+ "calls": 1,
+ "usd": 0.11,
+ "at_least": true
+ }
}
}
diff --git a/ui/src/lib/hostedActivity.ts b/ui/src/lib/hostedActivity.ts
index 7856a94b6..4b292db3d 100644
--- a/ui/src/lib/hostedActivity.ts
+++ b/ui/src/lib/hostedActivity.ts
@@ -3,7 +3,7 @@
// ``hostedActivity.fixture.json``). The row's ``text`` is the IM line; the Web
// renders the card from these fields instead.
-export type HostedToolName = 'web_search' | 'x_search' | 'image_generation';
+export type HostedToolName = 'web_search' | 'x_search' | 'image_generate';
export type HostedActivitySource = {
url: string;
@@ -26,7 +26,8 @@ export type HostedActivity = {
version: 1;
call_id: string;
tool: HostedToolName;
- mode: 'native' | 'proxy';
+ /** Natively in the model's response, by a search executor, or on an image endpoint directly. */
+ mode: 'native' | 'proxy' | 'direct';
status: 'completed' | 'failed' | 'incomplete' | 'pending';
/** Model-facing English, shown as is only for a provider's own reason. */
error?: string;
@@ -47,11 +48,12 @@ export type HostedActivity = {
quality?: string;
revised_prompt?: string;
duration_ms?: number;
- /** Absent when no price is known: unknown is never shown as zero. ``calls`` is how many calls it covers. */
- cost?: { basis: 'reported' | 'list' | 'included'; usd?: number; calls: number };
+ /** Absent when no price is known: unknown is never shown as zero. ``calls`` is how many calls it covers, and
+ * ``at_least`` marks a lower bound: an attempt reported no price. */
+ cost?: { basis: 'reported' | 'list' | 'included'; usd?: number; calls: number; at_least?: boolean };
};
-const TOOLS: readonly string[] = ['web_search', 'x_search', 'image_generation'];
+const TOOLS: readonly string[] = ['web_search', 'x_search', 'image_generate'];
const STATUSES: readonly string[] = ['completed', 'failed', 'incomplete', 'pending'];
/** The card a row carries, or undefined for anything that is not one this client reads. */
@@ -60,7 +62,7 @@ export const hostedActivityFrom = (raw: unknown): HostedActivity | undefined =>
const card = raw as Record<string, unknown>;
if (card.version !== 1 || typeof card.call_id !== 'string') return undefined;
if (typeof card.tool !== 'string' || !TOOLS.includes(card.tool)) return undefined;
- if (card.mode !== 'native' && card.mode !== 'proxy') return undefined;
+ if (card.mode !== 'native' && card.mode !== 'proxy' && card.mode !== 'direct') return undefined;
if (typeof card.status !== 'string' || !STATUSES.includes(card.status)) return undefined;
return {
...(card as unknown as HostedActivity),
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index 705d717d9..419925ef7 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -1807,7 +1807,8 @@
"included": "included in subscription",
"list": "≈ ${usd}",
"reported": "${usd}",
- "calls": "{cost} for {calls} calls"
+ "calls": "{cost} for {calls} calls",
+ "atLeast": "at least {cost}"
},
"status": {
"failed": "failed: {error}",
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index 77cf45ee6..eb9ceeea2 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -1807,7 +1807,8 @@
"included": "订阅内含",
"list": "≈ ${usd}",
"reported": "${usd}",
- "calls": "{cost}({calls} 次调用)"
+ "calls": "{cost}({calls} 次调用)",
+ "atLeast": "至少 {cost}"
},
"status": {
"failed": "失败:{error}",