diff --git a/package.json b/package.json
index 12f892ada..35df88e59 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/monorepo",
- "version": "0.12.5",
+ "version": "0.12.6",
"private": true,
"type": "module",
"packageManager": "pnpm@10.23.0",
diff --git a/packages/agent-cli/ts/package.json b/packages/agent-cli/ts/package.json
index 842eb77f1..552a2192f 100644
--- a/packages/agent-cli/ts/package.json
+++ b/packages/agent-cli/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-cli",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Product-neutral command line for a Steerable host. Products supply the bin name and brand.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-client/ts/package.json b/packages/agent-client/ts/package.json
index 1db06fef3..152b76138 100644
--- a/packages/agent-client/ts/package.json
+++ b/packages/agent-client/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-client",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "In-process client for a Steerable host: HTTP-shaped requests, turn streams, and approval replies.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-harness/py/pyproject.toml b/packages/agent-harness/py/pyproject.toml
index a8e828c8a..d032aaec0 100644
--- a/packages/agent-harness/py/pyproject.toml
+++ b/packages/agent-harness/py/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "steerable-agent-harness"
-version = "0.12.5"
+version = "0.12.6"
description = "Steerable harness helpers for Python"
license = { text = "Apache-2.0" }
readme = "README.md"
diff --git a/packages/agent-harness/ts/package.json b/packages/agent-harness/ts/package.json
index 6d79bbac5..1dfd8d055 100644
--- a/packages/agent-harness/ts/package.json
+++ b/packages/agent-harness/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-harness",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Steerable framework Tier 2 \u2014 TypeScript facade over the Python harness (policy, budget, retry, completion, tracing) used for cross-language conformance tests. Production code should depend on the Python harness.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-protocol/py/pyproject.toml b/packages/agent-protocol/py/pyproject.toml
index 8fe3ec81e..f115f76bb 100644
--- a/packages/agent-protocol/py/pyproject.toml
+++ b/packages/agent-protocol/py/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "steerable-agent-protocol"
-version = "0.12.5"
+version = "0.12.6"
description = "Steerable protocol schemas for Python"
license = { text = "Apache-2.0" }
readme = "README.md"
diff --git a/packages/agent-protocol/ts/package.json b/packages/agent-protocol/ts/package.json
index 8b6939a10..a96f012bf 100644
--- a/packages/agent-protocol/ts/package.json
+++ b/packages/agent-protocol/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-protocol",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Steerable framework Tier 1 \u2014 wire-format types (SSEEvent, ChatMessage, ToolCall, ToolResult, AgentSession, HarnessTrace, sidecar JSON-RPC) shared by every Steerable client and server.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-runtime/py/pyproject.toml b/packages/agent-runtime/py/pyproject.toml
index cad901ed0..543626993 100644
--- a/packages/agent-runtime/py/pyproject.toml
+++ b/packages/agent-runtime/py/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "steerable-agent-runtime"
-version = "0.12.5"
+version = "0.12.6"
description = "Steerable agent runtime: LLM, tool, storage, and transport adapters."
license = { text = "Apache-2.0" }
readme = "README.md"
diff --git a/packages/agent-runtime/ts/package.json b/packages/agent-runtime/ts/package.json
index 0d5f61b47..9793a9d3f 100644
--- a/packages/agent-runtime/ts/package.json
+++ b/packages/agent-runtime/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-runtime",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Steerable framework \u2014 official TypeScript production runtime. Owns the embedded Python sidecar lifecycle (spawn / ready handshake / health / bounded auto-restart / graceful drain) and exposes the CoreLoop-level API over the sidecar JSON-RPC surface. There is no TS CoreLoop; this package drives the same Rust CoreLoop the server uses (via the Python sidecar facade), so cross-language conformance holds by construction.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-shell/tauri/package.json b/packages/agent-shell/tauri/package.json
index 982b9b31e..05a78fc4c 100644
--- a/packages/agent-shell/tauri/package.json
+++ b/packages/agent-shell/tauri/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-shell-tauri",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Reusable Tauri Rust host source for @steerable/agent-shell",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-shell/ts/package.json b/packages/agent-shell/ts/package.json
index faa63cfa6..4f5e71388 100644
--- a/packages/agent-shell/ts/package.json
+++ b/packages/agent-shell/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-shell",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Steerable framework \u2014 product-neutral Node HostRuntime and headless HTTP server shared by Tauri desktop and browser deployments; scenario packs extend it through @steerable/pack-sdk.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/",
diff --git a/packages/agent-shell/ts/src/local-backend/skills/80-tool-usage/SKILL.md b/packages/agent-shell/ts/src/local-backend/skills/80-tool-usage/SKILL.md
index f79aaaab6..aeb159b37 100644
--- a/packages/agent-shell/ts/src/local-backend/skills/80-tool-usage/SKILL.md
+++ b/packages/agent-shell/ts/src/local-backend/skills/80-tool-usage/SKILL.md
@@ -63,6 +63,14 @@ tags: [tool, guide]
✅ 正确做法:基于工具返回的数据,**用自然语言**给出对用户有用的结论。例如 "本周完成了 5 个任务" / "卡片 GR 对比相关性 0.92"。
+## 联网检索边界
+
+查询公开资料、政策流程或常见问答时:
+
+- **先用 `web_search` 与可读 `web_fetch`**:当多个可靠搜索结果摘要已经能互相印证关键步骤、费用与注意事项时,直接综合并附上来源链接作答,不要再开浏览器二次逛官网。
+- **遇到 403 / 404 / 空正文(JS SPA)时按需取舍**:先尝试改换 `web_search` 关键词或抓取搜索结果里的其他公开可读页面;只有在搜索结论互相矛盾或缺少权威一手细节时,才用 `browser_navigate` + `browser_read` 有限核对目标页,避免反复点击或截图逛站。
+- **交互任务优先 `browser_*`**:需要点击、填表、登录或用户明确要求在浏览器打开页面时,使用浏览器工具。
+
## 错误处理
- 工具调用失败时,向用户说明真实原因(引用 `error` / `message` / `hint` 字段原文)并建议替代方案
diff --git a/packages/agent-shell/ts/src/sidecar/egress-proxy.ts b/packages/agent-shell/ts/src/sidecar/egress-proxy.ts
index 03fd9a801..67aaf983a 100644
--- a/packages/agent-shell/ts/src/sidecar/egress-proxy.ts
+++ b/packages/agent-shell/ts/src/sidecar/egress-proxy.ts
@@ -430,7 +430,11 @@ export function deriveWebEgressHosts(options: {
const domain = entry.trim().toLowerCase().replace(/^\.+/, '');
if (domain) hosts.push(domain);
}
- if (searchEnv.STEERABLE_WEB_SEARCH_API_KEY || searchEnv.STEERABLE_WEB_SEARCH_PROVIDER === 'ddg') {
+ if (
+ searchEnv.STEERABLE_WEB_SEARCH_API_KEY
+ || searchEnv.STEERABLE_WEB_SEARCH_PROVIDER === 'ddg'
+ || env.STEERABLE_WEB_SEARCH_PROVIDER === 'ddg'
+ ) {
// 与 WebToolsConfig.resolve 的 search_base_url 推导保持一致:显式
// STEERABLE_WEB_SEARCH_BASE_URL 优先,否则按 provider 取默认端点。
// ddg 无钥也在 sidecar 进程内执行,必须放行 html.duckduckgo.com。
@@ -449,6 +453,9 @@ export function deriveWebEgressHosts(options: {
} catch {
/* 畸形 base url:sidecar 侧 resolve 同样失败,web_search 不会注册 */
}
+ if (provider === 'ddg' && !explicit) {
+ hosts.push('www.bing.com', 'cn.bing.com');
+ }
}
// 框架代理对畸形 --allow 条目 fail loud(拒启 → 整体回退端口级)。在
// 这里过滤保住 LLM 通路的按主机管控;被丢的条目本就无法匹配真实主机,
diff --git a/packages/agent-shell/ts/tests/sidecar/egress-proxy.test.ts b/packages/agent-shell/ts/tests/sidecar/egress-proxy.test.ts
index adeb77bc1..50c154bdc 100644
--- a/packages/agent-shell/ts/tests/sidecar/egress-proxy.test.ts
+++ b/packages/agent-shell/ts/tests/sidecar/egress-proxy.test.ts
@@ -357,14 +357,22 @@ describe('deriveWebEgressHosts (3.1b/3.1d)', () => {
env: { STEERABLE_WEB_SEARCH_BASE_URL: 'https://search.internal:8443' },
}),
).toEqual(['search.internal:8443']);
- // ddg is in-process without a key — the lite HTML origin still needs CONNECT.
+ // ddg is in-process without a key — the lite HTML origin still needs CONNECT,
+ // plus Bing RSS fallback hosts when DDG triggers a bot check.
expect(
deriveWebEgressHosts({
webTools: true,
searchEnv: { STEERABLE_WEB_SEARCH_PROVIDER: 'ddg' },
env: {},
}),
- ).toEqual(['html.duckduckgo.com']);
+ ).toEqual(['html.duckduckgo.com', 'www.bing.com', 'cn.bing.com']);
+ expect(
+ deriveWebEgressHosts({
+ webTools: true,
+ searchEnv: {},
+ env: { STEERABLE_WEB_SEARCH_PROVIDER: 'ddg' },
+ }),
+ ).toEqual(['html.duckduckgo.com', 'www.bing.com', 'cn.bing.com']);
});
it('drops malformed entries so the proxy (fail-loud on bad --allow) still starts', () => {
diff --git a/packages/agent-shell/web/package.json b/packages/agent-shell/web/package.json
index bd4eed473..9f01b3532 100644
--- a/packages/agent-shell/web/package.json
+++ b/packages/agent-shell/web/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-shell-web",
- "version": "0.12.5",
+ "version": "0.12.6",
"type": "module",
"description": "Steerable framework \u2014 product-neutral renderer SPA source for @steerable/agent-shell (React + Vite). Consumed by product web entry points via the `@/` alias (anchored at this package's src/) and the createProductViteConfig factory. Published as a source package (src/), plus the compiled vite.base config factory (vite.base.js + .d.ts) for Node-side config loading.",
"license": "Apache-2.0",
diff --git a/packages/agent-shell/web/src/components/chat/TurnProcessGroup.test.tsx b/packages/agent-shell/web/src/components/chat/TurnProcessGroup.test.tsx
index 16abee0dc..d45d2d9c6 100644
--- a/packages/agent-shell/web/src/components/chat/TurnProcessGroup.test.tsx
+++ b/packages/agent-shell/web/src/components/chat/TurnProcessGroup.test.tsx
@@ -429,13 +429,28 @@ describe('TurnProcessGroup', () => {
expect(screen.getAllByTestId('tools-flow')).toHaveLength(2);
});
- it('hides thinking body when the setting is 隐藏, even after expanding work', () => {
+ it('hides thinking body and merges adjacent tools when the setting is 隐藏, even after expanding work', () => {
renderGroup({ isStreaming: false, thinkingDisplay: 'hidden' });
+ expect(processToggle().textContent).toBe('2 tool calls');
fireEvent.click(processToggle());
expect(screen.queryByTestId('turn-thinking')).toBeNull();
expect(screen.queryByTestId('thinking-peek')).toBeNull();
expect(screen.queryByText('先读配置')).toBeNull();
- expect(screen.getAllByTestId('tools-flow')).toHaveLength(2);
+ expect(screen.getAllByTestId('tools-flow')).toHaveLength(1);
+ expect(screen.getByTestId('tools-flow').textContent).toBe('csv_get_config,web_fetch');
+ });
+
+ it('omits the work disclosure after finish when thinking is hidden and no tools or narration exist', () => {
+ renderGroup({
+ isStreaming: false,
+ thinkingDisplay: 'hidden',
+ blocks: [
+ { type: 'reasoning', content: '先想一下' },
+ { type: 'text', content: '直接回答。' },
+ ],
+ });
+ expect(screen.queryByTestId('turn-process-toggle')).toBeNull();
+ expect(screen.getByTestId('answer').textContent).toBe('直接回答。');
});
it('folds a tools-only turn when the setting is off', () => {
diff --git a/packages/agent-shell/web/src/components/chat/TurnProcessGroup.tsx b/packages/agent-shell/web/src/components/chat/TurnProcessGroup.tsx
index 9dce86b83..027cf0758 100644
--- a/packages/agent-shell/web/src/components/chat/TurnProcessGroup.tsx
+++ b/packages/agent-shell/web/src/components/chat/TurnProcessGroup.tsx
@@ -1,10 +1,6 @@
-import { Fragment, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
-import { LuChevronDown, LuChevronRight } from 'react-icons/lu';
+import type { ReactNode } from 'react';
import type { LocalChat, LocalChatAgent } from '@/lib/local-api';
-import {
- useThinkingDisplay,
- type ThinkingDisplayMode,
-} from '@/lib/show-thinking-content';
+import type { ThinkingDisplayMode } from '@/lib/show-thinking-content';
import { Markdown } from './Markdown';
import { ToolsFlow } from './ExecutedActionsCard';
import type { InspectTaskInput } from './executed-actions-model';
@@ -12,12 +8,12 @@ import type { ChildInfo } from './OrchestrationChildrenCard';
import { OrchestrationChildrenCard } from './OrchestrationChildrenCard';
import { TurnUsageLine } from './TurnUsageLine';
import type { TurnUsage } from './turn-usage';
+import type { TurnBlock } from './turn-timeline';
import {
- estimateReasoningDurationMs,
- processStatusLabel,
- thinkingFoldLabel,
-} from './process-status';
-import { splitTurnProcess, type TurnBlock } from './turn-timeline';
+ THINKING_PEEK_HEIGHT,
+ THINKING_PEEK_LINES,
+ TurnProcessTimeline,
+} from './TurnProcessTimeline';
/**
* Codex / DeepSeek-style turn process. Each LLM round keeps three surfaces
@@ -29,289 +25,7 @@ import { splitTurnProcess, type TurnBlock } from './turn-timeline';
* only the live round stays open. Tools and the work row stay independent.
*/
-export const THINKING_PEEK_LINES = 5;
-/** 思考正文行高(`leading-snug`)。 */
-const THINKING_LINE_HEIGHT = 1.375;
-/**
- * 最多 5 行:用 max-height,短思考按内容收,不撑空。
- * 不用 CSS `lh`:Windows Electron 在中文字体尚未就绪时 `lh` 会算成 0,
- * 思考 peek 整块消失,字体加载后又把主列表高度撑跳。
- */
-export const THINKING_PEEK_HEIGHT = `${THINKING_PEEK_LINES * THINKING_LINE_HEIGHT}em`;
-
-const THINKING_TEXT =
- 'border-l border-agent-border/70 pl-2 text-xs leading-snug text-agent-muted-foreground';
-
-function splitThinkingParagraphs(content: string): string[] {
- return content.split(/\n{2,}/).filter((part) => part.length > 0);
-}
-
-function ReasoningBody({
- content,
- showCursor,
-}: {
- content: string;
- showCursor?: boolean;
-}) {
- const parts = splitThinkingParagraphs(content);
- return (
- <>
-
- {parts.map((part, index) => (
-
- {part}
-
- ))}
-
- {showCursor ? (
-
- ) : null}
- >
- );
-}
-
-function resolveThinkingDisplay(
- preference: ThinkingDisplayMode,
- thinkingDisplay?: ThinkingDisplayMode,
- showThinkingContent?: boolean,
-): ThinkingDisplayMode {
- if (thinkingDisplay) return thinkingDisplay;
- if (showThinkingContent === true) return 'full';
- if (showThinkingContent === false) return 'peek';
- return preference;
-}
-
-function useLiveNow(enabled: boolean): number {
- const [now, setNow] = useState(() => Date.now());
- useEffect(() => {
- if (!enabled) return;
- setNow(Date.now());
- const id = window.setInterval(() => setNow(Date.now()), 1000);
- return () => window.clearInterval(id);
- }, [enabled]);
- return now;
-}
-
-function ReasoningPane({
- content,
- showCursor,
- clipped,
-}: {
- content: string;
- showCursor?: boolean;
- clipped?: boolean;
-}) {
- const scrollerRef = useRef(null);
- useLayoutEffect(() => {
- if (!clipped) return;
- const el = scrollerRef.current;
- if (!el) return;
- el.scrollTop = el.scrollHeight;
- }, [clipped, content]);
- const body = (
-
-
-
- );
- if (!clipped) return body;
- return (
-
- {body}
-
- );
-}
-
-function ThinkingFold({
- content,
- label,
- showCursor,
- mode,
- defaultOpen,
-}: {
- content: string;
- label: string;
- showCursor?: boolean;
- mode: ThinkingDisplayMode;
- defaultOpen: boolean;
-}) {
- const [open, setOpen] = useState(defaultOpen);
- useEffect(() => {
- setOpen(defaultOpen);
- }, [defaultOpen]);
-
- if (mode === 'hidden') return null;
-
- return (
-
-
- {open ? (
-
- ) : null}
-
- );
-}
-
-function ProcessBlockItems({
- blocks,
- isStreaming,
- agents,
- chats,
- chatId,
- onInspectTask,
- orchestrationChildren,
- thinkingDisplay,
- keepFinishedThinkingOpen = false,
- thinkingElapsedByIndex,
-}: {
- blocks: TurnBlock[];
- isStreaming: boolean;
- agents: LocalChatAgent[];
- chats: LocalChat[];
- chatId?: string | null;
- onInspectTask?: (task: InspectTaskInput) => void;
- orchestrationChildren?: ChildInfo[];
- thinkingDisplay: ThinkingDisplayMode;
- keepFinishedThinkingOpen?: boolean;
- thinkingElapsedByIndex?: Array;
-}) {
- const lastIndex = blocks.length - 1;
- return (
- <>
- {blocks.map((block, index) => {
- const isLast = index === lastIndex;
- if (block.type === 'reasoning') {
- const isLive = isStreaming && isLast;
- const elapsedMs =
- thinkingElapsedByIndex?.[index]
- ?? block.durationMs
- ?? (isLive ? undefined : estimateReasoningDurationMs(block.content));
- return (
-
- );
- }
- if (block.type === 'tools') {
- return (
-
-
-
- );
- }
- return (
-
-
-
- {block.content}
-
- {isStreaming && isLast ? (
-
- ) : null}
-
-
- );
- })}
- >
- );
-}
-
-function ProcessBlocks({
- blocks,
- isStreaming,
- agents,
- chats,
- chatId,
- onInspectTask,
- orchestrationChildren,
- thinkingDisplay,
- keepFinishedThinkingOpen,
- thinkingElapsedByIndex,
- onContinueChild,
- onStopChild,
- turnUsage,
-}: {
- blocks: TurnBlock[];
- isStreaming: boolean;
- agents: LocalChatAgent[];
- chats: LocalChat[];
- chatId?: string | null;
- onInspectTask?: (task: InspectTaskInput) => void;
- orchestrationChildren?: ChildInfo[];
- thinkingDisplay: ThinkingDisplayMode;
- keepFinishedThinkingOpen: boolean;
- thinkingElapsedByIndex?: Array;
- onContinueChild?: (childId: string, recordId: string) => void;
- onStopChild?: (childId: string) => void;
- /** R6:本回合账单,画在子代理看板下方。 */
- turnUsage?: TurnUsage;
-}) {
- return (
-
-
- {/* R7 子代理看板:挂在过程块之后、正文之前。≥2 个子代理才渲染,
- 单次委派已在工具行里有同一条进度。 */}
-
- {/* R6 回合账单:紧随看板,读的是「父级 + 子代理」的整份数字。 */}
-
-
- );
-}
+export { THINKING_PEEK_HEIGHT, THINKING_PEEK_LINES };
export function TurnProcessGroup({
blocks,
@@ -328,8 +42,8 @@ export function TurnProcessGroup({
streamingHint,
startedAtMs,
durationMs,
- thinkingDisplay: thinkingDisplayProp,
- showThinkingContent: showThinkingContentProp,
+ thinkingDisplay,
+ showThinkingContent,
collapseWhenFinished = true,
renderAnswer,
}: {
@@ -368,129 +82,58 @@ export function TurnProcessGroup({
collapseWhenFinished?: boolean;
renderAnswer: (block: Extract, isLast: boolean) => ReactNode;
}) {
- const preference = useThinkingDisplay();
- const thinkingDisplay = resolveThinkingDisplay(
- preference,
- thinkingDisplayProp,
- showThinkingContentProp,
- );
- const showFullThinking = thinkingDisplay === 'full';
- const { process, answer } = splitTurnProcess(blocks, { finalize: !isStreaming });
- const defaultOpen = isStreaming
- ? thinkingDisplay !== 'hidden'
- : showFullThinking && !collapseWhenFinished;
- const [userOpen, setUserOpen] = useState(null);
- const open = userOpen ?? defaultOpen;
- useEffect(() => {
- setUserOpen(null);
- }, [isStreaming]);
- const answerLenRef = useRef(answer.length);
- answerLenRef.current = answer.length;
- const now = useLiveNow(isStreaming);
- const streamClockRef = useRef(undefined);
- if (isStreaming) {
- streamClockRef.current ??= startedAtMs ?? now;
- } else {
- streamClockRef.current = undefined;
- }
- const liveElapsedMs = isStreaming
- ? Math.max(0, now - (startedAtMs ?? streamClockRef.current ?? now))
- : undefined;
- const lastLiveElapsedRef = useRef(undefined);
- if (isStreaming && liveElapsedMs != null) {
- lastLiveElapsedRef.current = liveElapsedMs;
- }
- const elapsedMs = isStreaming
- ? liveElapsedMs
- : durationMs ?? lastLiveElapsedRef.current;
-
- const lastProcess = process[process.length - 1];
- const lastIsReasoning = lastProcess?.type === 'reasoning';
- const reasoningDurationsRef = useRef([]);
- const reasoningClockRef = useRef<{ index: number; startedAt: number } | null>(null);
- if (isStreaming && lastIsReasoning) {
- const index = process.length - 1;
- if (reasoningClockRef.current?.index !== index) {
- const prev = reasoningClockRef.current;
- if (prev) {
- reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
- }
- reasoningClockRef.current = { index, startedAt: now };
- }
- } else if (reasoningClockRef.current) {
- const prev = reasoningClockRef.current;
- reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
- reasoningClockRef.current = null;
- }
- const thinkingElapsedByIndex = process.map((block, index) => {
- if (block.type !== 'reasoning') return undefined;
- if (
- isStreaming &&
- lastIsReasoning &&
- index === process.length - 1 &&
- reasoningClockRef.current
- ) {
- return Math.max(0, now - reasoningClockRef.current.startedAt);
- }
- return reasoningDurationsRef.current[index];
- });
-
- if (blocks.length === 0) return <>{emptyFallback}>;
-
- const showToggle = process.length > 0;
- const showProcess = !showToggle || open;
- const showStreamingHint =
- Boolean(streamingHint) && isStreaming && answer.length === 0 && !showToggle;
+ const hasChildrenCard = (orchestrationChildren?.length ?? 0) >= 2;
+ const processFooter =
+ hasChildrenCard || Boolean(turnUsage) ? (
+ <>
+ {/* R7 子代理看板:挂在过程块之后、正文之前。≥2 个子代理才渲染,
+ 单次委派已在工具行里有同一条进度。 */}
+
+ {/* R6 回合账单:紧随看板,读的是「父级 + 子代理」的整份数字。 */}
+
+ >
+ ) : undefined;
return (
-
- {showToggle && (
-
- )}
- {showProcess && (
-
(
+
)}
- {showStreamingHint ? streamingHint : null}
- {answer.map((block, index) => (
-
- {renderAnswer(block, index === answer.length - 1)}
-
- ))}
-
+ renderIntermediateText={(block, isLiveLast) => (
+
+
+
+ {block.content}
+
+
+ {isLiveLast ? (
+
+ ) : null}
+
+ )}
+ renderAnswer={(block, isLast) => renderAnswer(block, isLast)}
+ />
);
}
diff --git a/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.test.tsx b/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.test.tsx
new file mode 100644
index 000000000..0c9202909
--- /dev/null
+++ b/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.test.tsx
@@ -0,0 +1,64 @@
+import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { afterEach, describe, expect, it } from 'vitest';
+import { SHOW_THINKING_CONTENT_STORAGE_KEY } from '@/lib/show-thinking-content';
+import type { ProcessTimelineBlock } from './turn-timeline';
+import { TurnProcessTimeline } from './TurnProcessTimeline';
+
+afterEach(() => {
+ cleanup();
+ localStorage.removeItem(SHOW_THINKING_CONTENT_STORAGE_KEY);
+});
+
+interface CustomTool {
+ id: string;
+ name: string;
+}
+
+describe('TurnProcessTimeline', () => {
+ it('supports custom tool shapes, hides thinking, and merges adjacent tool groups in Codex style', () => {
+ const blocks: Array> = [
+ { type: 'reasoning', content: '先搜一下官方说明' },
+ { type: 'text', content: '我先查一下。' },
+ { type: 'tools', actions: [{ id: '1', name: 'web_fetch' }] },
+ { type: 'reasoning', content: '继续翻网页' },
+ {
+ type: 'tools',
+ actions: [
+ { id: '2', name: 'browser_navigate' },
+ { id: '3', name: 'browser_read' },
+ ],
+ },
+ { type: 'reasoning', content: '整理结论' },
+ { type: 'text', content: '最终缴费流程如下。' },
+ ];
+
+ render(
+ (
+ {tools.map((t) => t.name).join(',')}
+ )}
+ renderIntermediateText={(block) => (
+ {block.content}
+ )}
+ renderAnswer={(block) => {block.content}
}
+ />,
+ );
+
+ const toggle = screen.getByTestId('turn-process-toggle');
+ expect(toggle.getAttribute('aria-expanded')).toBe('false');
+ expect(toggle.textContent).toBe('Worked 12s · 3 tool calls');
+ expect(screen.getByTestId('custom-answer').textContent).toBe('最终缴费流程如下。');
+
+ fireEvent.click(toggle);
+ expect(screen.queryByTestId('turn-thinking')).toBeNull();
+ expect(screen.getByTestId('custom-intermediate').textContent).toBe('我先查一下。');
+ expect(screen.getAllByTestId('custom-tools')).toHaveLength(1);
+ expect(screen.getByTestId('custom-tools').textContent).toBe(
+ 'web_fetch,browser_navigate,browser_read',
+ );
+ });
+});
diff --git a/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.tsx b/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.tsx
new file mode 100644
index 000000000..7d9c2fe8e
--- /dev/null
+++ b/packages/agent-shell/web/src/components/chat/TurnProcessTimeline.tsx
@@ -0,0 +1,374 @@
+import { Fragment, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
+import { LuChevronDown, LuChevronRight } from 'react-icons/lu';
+import {
+ useThinkingDisplay,
+ type ThinkingDisplayMode,
+} from '@/lib/show-thinking-content';
+import {
+ estimateReasoningDurationMs,
+ processStatusLabel,
+ thinkingFoldLabel,
+} from './process-status';
+import {
+ compactProcessBlocks,
+ splitTurnProcess,
+ type ProcessTimelineBlock,
+} from './turn-timeline';
+
+/**
+ * Shared Codex / DeepSeek-style turn process disclosure.
+ *
+ * Separates intermediate process steps (`reasoning`, `tools`, pre-tool `text`)
+ * from the trailing final answer, tracks per-round thinking durations while
+ * streaming, and collapses finished work behind one summary line. When
+ * `thinkingDisplay === 'hidden'`, reasoning blocks are filtered out and
+ * adjacent tool groups merge into a single block.
+ */
+
+export const THINKING_PEEK_LINES = 5;
+/** 思考正文行高(`leading-snug`)。 */
+const THINKING_LINE_HEIGHT = 1.375;
+/**
+ * 最多 5 行:用 max-height,短思考按内容收,不撑空。
+ * 不用 CSS `lh`:Windows Electron 在中文字体尚未就绪时 `lh` 会算成 0,
+ * 思考 peek 整块消失,字体加载后又把主列表高度撑跳。
+ */
+export const THINKING_PEEK_HEIGHT = `${THINKING_PEEK_LINES * THINKING_LINE_HEIGHT}em`;
+
+const THINKING_TEXT =
+ 'border-l border-agent-border/70 pl-2 text-xs leading-snug text-agent-muted-foreground';
+
+function splitThinkingParagraphs(content: string): string[] {
+ return content.split(/\n{2,}/).filter((part) => part.length > 0);
+}
+
+function ReasoningBody({
+ content,
+ showCursor,
+}: {
+ content: string;
+ showCursor?: boolean;
+}) {
+ const parts = splitThinkingParagraphs(content);
+ return (
+ <>
+
+ {parts.map((part, index) => (
+
+ {part}
+
+ ))}
+
+ {showCursor ? (
+
+ ) : null}
+ >
+ );
+}
+
+export function resolveThinkingDisplay(
+ preference: ThinkingDisplayMode,
+ thinkingDisplay?: ThinkingDisplayMode,
+ showThinkingContent?: boolean,
+): ThinkingDisplayMode {
+ if (thinkingDisplay) return thinkingDisplay;
+ if (showThinkingContent === true) return 'full';
+ if (showThinkingContent === false) return 'peek';
+ return preference;
+}
+
+function useLiveNow(enabled: boolean): number {
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (!enabled) return;
+ setNow(Date.now());
+ const id = window.setInterval(() => setNow(Date.now()), 1000);
+ return () => window.clearInterval(id);
+ }, [enabled]);
+ return now;
+}
+
+function ReasoningPane({
+ content,
+ showCursor,
+ clipped,
+}: {
+ content: string;
+ showCursor?: boolean;
+ clipped?: boolean;
+}) {
+ const scrollerRef = useRef(null);
+ useLayoutEffect(() => {
+ if (!clipped) return;
+ const el = scrollerRef.current;
+ if (!el) return;
+ el.scrollTop = el.scrollHeight;
+ }, [clipped, content]);
+ const body = (
+
+
+
+ );
+ if (!clipped) return body;
+ return (
+
+ {body}
+
+ );
+}
+
+function ThinkingFold({
+ content,
+ label,
+ showCursor,
+ mode,
+ defaultOpen,
+}: {
+ content: string;
+ label: string;
+ showCursor?: boolean;
+ mode: ThinkingDisplayMode;
+ defaultOpen: boolean;
+}) {
+ const [open, setOpen] = useState(defaultOpen);
+ useEffect(() => {
+ setOpen(defaultOpen);
+ }, [defaultOpen]);
+
+ if (mode === 'hidden') return null;
+
+ return (
+
+
+ {open ? (
+
+ ) : null}
+
+ );
+}
+
+export interface TurnProcessTimelineProps {
+ blocks: ReadonlyArray>;
+ isStreaming: boolean;
+ startedAtMs?: number;
+ durationMs?: number;
+ thinkingDisplay?: ThinkingDisplayMode;
+ showThinkingContent?: boolean;
+ collapseWhenFinished?: boolean;
+ /** When thinkingDisplay === 'hidden', omit reasoning and merge adjacent tool groups. Default true. */
+ compactHiddenProcess?: boolean;
+ emptyFallback?: ReactNode;
+ streamingHint?: ReactNode;
+ processFooter?: ReactNode;
+ renderTools: (actions: TTool[], index: number) => ReactNode;
+ renderIntermediateText: (
+ block: Extract, { type: 'text' }>,
+ isLiveLast: boolean,
+ index: number,
+ ) => ReactNode;
+ renderAnswer: (
+ block: Extract, { type: 'text' }>,
+ isLast: boolean,
+ index: number,
+ ) => ReactNode;
+}
+
+export function TurnProcessTimeline({
+ blocks,
+ isStreaming,
+ startedAtMs,
+ durationMs,
+ thinkingDisplay: thinkingDisplayProp,
+ showThinkingContent: showThinkingContentProp,
+ collapseWhenFinished = true,
+ compactHiddenProcess = true,
+ emptyFallback,
+ streamingHint,
+ processFooter,
+ renderTools,
+ renderIntermediateText,
+ renderAnswer,
+}: TurnProcessTimelineProps) {
+ const preference = useThinkingDisplay();
+ const thinkingDisplay = resolveThinkingDisplay(
+ preference,
+ thinkingDisplayProp,
+ showThinkingContentProp,
+ );
+ const showFullThinking = thinkingDisplay === 'full';
+ const hideThinking = thinkingDisplay === 'hidden';
+ const { process, answer } = splitTurnProcess(blocks, { finalize: !isStreaming });
+ const visibleProcess = compactProcessBlocks(process, {
+ hideThinking: hideThinking && compactHiddenProcess,
+ });
+
+ const defaultOpen = isStreaming
+ ? thinkingDisplay !== 'hidden'
+ : showFullThinking && !collapseWhenFinished;
+ const [userOpen, setUserOpen] = useState(null);
+ const open = userOpen ?? defaultOpen;
+ useEffect(() => {
+ setUserOpen(null);
+ }, [isStreaming]);
+
+ const now = useLiveNow(isStreaming);
+ const streamClockRef = useRef(undefined);
+ if (isStreaming) {
+ streamClockRef.current ??= startedAtMs ?? now;
+ } else {
+ streamClockRef.current = undefined;
+ }
+ const liveElapsedMs = isStreaming
+ ? Math.max(0, now - (startedAtMs ?? streamClockRef.current ?? now))
+ : undefined;
+ const lastLiveElapsedRef = useRef(undefined);
+ if (isStreaming && liveElapsedMs != null) {
+ lastLiveElapsedRef.current = liveElapsedMs;
+ }
+ const elapsedMs = isStreaming
+ ? liveElapsedMs
+ : durationMs ?? lastLiveElapsedRef.current;
+
+ const lastProcess = visibleProcess[visibleProcess.length - 1];
+ const lastIsReasoning = lastProcess?.type === 'reasoning';
+ const reasoningDurationsRef = useRef([]);
+ const reasoningClockRef = useRef<{ index: number; startedAt: number } | null>(null);
+ if (isStreaming && lastIsReasoning) {
+ const index = visibleProcess.length - 1;
+ if (reasoningClockRef.current?.index !== index) {
+ const prev = reasoningClockRef.current;
+ if (prev) {
+ reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
+ }
+ reasoningClockRef.current = { index, startedAt: now };
+ }
+ } else if (reasoningClockRef.current) {
+ const prev = reasoningClockRef.current;
+ reasoningDurationsRef.current[prev.index] = Math.max(0, now - prev.startedAt);
+ reasoningClockRef.current = null;
+ }
+ const thinkingElapsedByIndex = visibleProcess.map((block, index) => {
+ if (block.type !== 'reasoning') return undefined;
+ if (
+ isStreaming &&
+ lastIsReasoning &&
+ index === visibleProcess.length - 1 &&
+ reasoningClockRef.current
+ ) {
+ return Math.max(0, now - reasoningClockRef.current.startedAt);
+ }
+ return reasoningDurationsRef.current[index];
+ });
+
+ if (blocks.length === 0) return <>{emptyFallback}>;
+
+ const showToggle =
+ process.length > 0 &&
+ (isStreaming || visibleProcess.length > 0 || !hideThinking || Boolean(processFooter));
+ const showProcess = !showToggle || open;
+ const showStreamingHint =
+ Boolean(streamingHint) && isStreaming && answer.length === 0 && !showToggle;
+ const processIsLive = isStreaming && answer.length === 0;
+ const lastVisibleIndex = visibleProcess.length - 1;
+
+ return (
+
+ {showToggle && (
+
+ )}
+ {showProcess && (visibleProcess.length > 0 || Boolean(processFooter)) && (
+
+ {visibleProcess.map((block, index) => {
+ const isLast = index === lastVisibleIndex;
+ if (block.type === 'reasoning') {
+ const isLive = processIsLive && isLast;
+ const elapsed =
+ thinkingElapsedByIndex[index] ??
+ block.durationMs ??
+ (isLive ? undefined : estimateReasoningDurationMs(block.content));
+ return (
+
+ );
+ }
+ if (block.type === 'tools') {
+ return (
+
+ {renderTools(block.actions, index)}
+
+ );
+ }
+ return (
+
+ {renderIntermediateText(block, processIsLive && isLast, index)}
+
+ );
+ })}
+ {processFooter}
+
+ )}
+ {showStreamingHint ? streamingHint : null}
+ {answer.map((block, index) => (
+
+ {renderAnswer(block, index === answer.length - 1, index)}
+
+ ))}
+
+ );
+}
diff --git a/packages/agent-shell/web/src/components/chat/process-status.test.ts b/packages/agent-shell/web/src/components/chat/process-status.test.ts
index 05bb60fe9..30798d576 100644
--- a/packages/agent-shell/web/src/components/chat/process-status.test.ts
+++ b/packages/agent-shell/web/src/components/chat/process-status.test.ts
@@ -84,6 +84,14 @@ describe('processStatusLabel', () => {
elapsedMs: 83_000,
}),
).toBe('Worked 1m 23s · Thought 2 times · 1 tool calls');
+ expect(
+ processStatusLabel({
+ process: [reasoning('先读配置'), tool('web_fetch', false), reasoning('再写')],
+ isStreaming: false,
+ elapsedMs: 83_000,
+ hideThinking: true,
+ }),
+ ).toBe('Worked 1m 23s · 1 tool calls');
});
it('omits empty counts and sub-second work time', () => {
diff --git a/packages/agent-shell/web/src/components/chat/process-status.ts b/packages/agent-shell/web/src/components/chat/process-status.ts
index 5a5527f0c..ae4cc1f44 100644
--- a/packages/agent-shell/web/src/components/chat/process-status.ts
+++ b/packages/agent-shell/web/src/components/chat/process-status.ts
@@ -9,6 +9,7 @@ import { formatElapsedCompact } from './elapsed';
import {
countProcessReasoning,
countProcessTools,
+ type ProcessTimelineBlock,
type TurnBlock,
} from './turn-timeline';
@@ -71,15 +72,16 @@ function formatElapsedPart(
/** Work disclosure: live is only 「工作中」; finished is a counts + duration summary. */
export function processStatusLabel(input: {
- process: TurnBlock[];
+ process: ReadonlyArray>;
isStreaming: boolean;
elapsedMs?: number;
+ hideThinking?: boolean;
}): string {
- const { process, isStreaming, elapsedMs } = input;
+ const { process, isStreaming, elapsedMs, hideThinking } = input;
if (isStreaming) return t('Working');
const parts: string[] = [];
- const thinks = countProcessReasoning(process);
+ const thinks = hideThinking ? 0 : countProcessReasoning(process);
const tools = countProcessTools(process);
const elapsed = formatElapsedPart(false, elapsedMs);
if (elapsed) parts.push(t('Worked {elapsed}', { elapsed }));
diff --git a/packages/agent-shell/web/src/components/chat/turn-timeline.test.ts b/packages/agent-shell/web/src/components/chat/turn-timeline.test.ts
index 2636e95d5..c2d227414 100644
--- a/packages/agent-shell/web/src/components/chat/turn-timeline.test.ts
+++ b/packages/agent-shell/web/src/components/chat/turn-timeline.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import type { ExecutedAction } from './ExecutedActionsCard';
import {
appendDelta,
+ compactProcessBlocks,
countProcessTools,
fallbackTimeline,
parseTurnBlocks,
@@ -157,4 +158,26 @@ describe('turn-timeline', () => {
expect(parseTurnBlocks([{ type: 'image' }])).toBeNull();
expect(parseTurnBlocks([])).toBeNull();
});
+
+ it('filters reasoning and merges adjacent tool groups when hideThinking is enabled', () => {
+ const process = [
+ { type: 'reasoning' as const, content: '想1' },
+ { type: 'text' as const, content: '先查一下。' },
+ { type: 'tools' as const, actions: [tool('web_fetch')] },
+ { type: 'reasoning' as const, content: '想2' },
+ { type: 'tools' as const, actions: [tool('browser_navigate'), tool('browser_read')] },
+ { type: 'text' as const, content: '换个方法。' },
+ { type: 'tools' as const, actions: [tool('local_exec_shell')] },
+ ];
+ expect(compactProcessBlocks(process, { hideThinking: false })).toEqual(process);
+ expect(compactProcessBlocks(process, { hideThinking: true })).toEqual([
+ { type: 'text', content: '先查一下。' },
+ {
+ type: 'tools',
+ actions: [tool('web_fetch'), tool('browser_navigate'), tool('browser_read')],
+ },
+ { type: 'text', content: '换个方法。' },
+ { type: 'tools', actions: [tool('local_exec_shell')] },
+ ]);
+ });
});
diff --git a/packages/agent-shell/web/src/components/chat/turn-timeline.ts b/packages/agent-shell/web/src/components/chat/turn-timeline.ts
index 244cb2260..041edd016 100644
--- a/packages/agent-shell/web/src/components/chat/turn-timeline.ts
+++ b/packages/agent-shell/web/src/components/chat/turn-timeline.ts
@@ -10,7 +10,7 @@
import type { ExecutedAction } from './ExecutedActionsCard';
-export type TurnBlock =
+export type ProcessTimelineBlock =
| {
type: 'reasoning';
content: string;
@@ -19,7 +19,9 @@ export type TurnBlock =
durationMs?: number;
}
| { type: 'text'; content: string; sealed?: boolean }
- | { type: 'tools'; actions: ExecutedAction[] };
+ | { type: 'tools'; actions: TTool[] };
+
+export type TurnBlock = ProcessTimelineBlock;
/**
* 内容指纹:只要屏上会多出/变化一行,它就变。过程面板用它决定「要不要把
@@ -204,26 +206,56 @@ export function parseTurnBlocks(raw: unknown): TurnBlock[] | null {
* While streaming, every text block stays in the process as a post-think
* response so the next reasoning burst cannot restyle it as thinking.
*/
-export function splitTurnProcess(
- blocks: TurnBlock[],
+export function splitTurnProcess(
+ blocks: ReadonlyArray>,
options?: { finalize?: boolean },
): {
- process: TurnBlock[];
- answer: Extract[];
+ process: ProcessTimelineBlock[];
+ answer: Extract, { type: 'text' }>[];
} {
const finalize = options?.finalize ?? true;
if (!finalize) {
- return { process: blocks, answer: [] };
+ return { process: [...blocks], answer: [] };
}
let split = blocks.length;
while (split > 0 && blocks[split - 1].type === 'text') split -= 1;
return {
process: blocks.slice(0, split),
- answer: blocks.slice(split) as Extract[],
+ answer: blocks.slice(split) as Extract, { type: 'text' }>[],
};
}
-export function countProcessTools(process: TurnBlock[]): number {
+/**
+ * Filter thinking blocks and merge consecutive tool groups that become adjacent
+ * once reasoning is hidden (Codex-style compact process presentation).
+ */
+export function compactProcessBlocks(
+ process: ReadonlyArray>,
+ options: { hideThinking: boolean; mergeAdjacentTools?: boolean },
+): ProcessTimelineBlock[] {
+ if (!options.hideThinking) return [...process];
+ const mergeAdjacentTools = options.mergeAdjacentTools ?? true;
+ const out: ProcessTimelineBlock[] = [];
+ for (const block of process) {
+ if (block.type === 'reasoning') continue;
+ if (block.type === 'tools' && mergeAdjacentTools) {
+ const prev = out[out.length - 1];
+ if (prev && prev.type === 'tools') {
+ out[out.length - 1] = {
+ type: 'tools',
+ actions: [...prev.actions, ...block.actions],
+ };
+ continue;
+ }
+ }
+ out.push(block);
+ }
+ return out;
+}
+
+export function countProcessTools(
+ process: ReadonlyArray>,
+): number {
let n = 0;
for (const block of process) {
if (block.type === 'tools') n += block.actions.length;
@@ -231,7 +263,9 @@ export function countProcessTools(process: TurnBlock[]): number {
return n;
}
-export function countProcessReasoning(process: TurnBlock[]): number {
+export function countProcessReasoning(
+ process: ReadonlyArray>,
+): number {
let n = 0;
for (const block of process) {
if (block.type === 'reasoning' && block.content.trim().length > 0) n += 1;
@@ -239,6 +273,8 @@ export function countProcessReasoning(process: TurnBlock[]): number {
return n;
}
-export function processHasReasoning(process: TurnBlock[]): boolean {
+export function processHasReasoning(
+ process: ReadonlyArray>,
+): boolean {
return process.some((block) => block.type === 'reasoning' && block.content.trim().length > 0);
}
diff --git a/packages/agent-shell/web/vite.base.ts b/packages/agent-shell/web/vite.base.ts
index a3a89cdda..144a87080 100644
--- a/packages/agent-shell/web/vite.base.ts
+++ b/packages/agent-shell/web/vite.base.ts
@@ -91,6 +91,9 @@ export function createProductViteConfig(options: ProductViteConfigOptions) {
// shell 渲染层源码(产品入口与包 web 模块都以 `@/` 引用它)。
'@': webSrcDir,
},
+ // 跨仓 `shell:link` 时产品与 shell 各自有独立 node_modules;必须去重
+ // React 与 Router,否则 AppShell 的 会读到另一份 Context 而白屏。
+ dedupe: ['react', 'react-dom', 'react-router-dom'],
},
// 静态资产(favicon 等中性默认)随 shell web 包分发;产品可在自己的
// web root 放 public/ 覆盖(vite 不合并双 publicDir——需要产品级资产
diff --git a/packages/agent-ui/ts/package.json b/packages/agent-ui/ts/package.json
index 9fb90336f..26f762594 100644
--- a/packages/agent-ui/ts/package.json
+++ b/packages/agent-ui/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/agent-ui",
- "version": "0.12.5",
+ "version": "0.12.6",
"description": "Steerable framework Tier 4 \u2014 headless React hooks (useAgentSession, useChatStream, useToolCallStatus) and Tailwind-themed components (ChatPanel, MessageList, OrchestrationPlanCard, ToolCallRenderer, SSEStreamView) for embedding Steerable agents in any React app.",
"license": "Apache-2.0",
"homepage": "https://steerableframework.com/storybook/",
diff --git a/packages/pack-sdk/ts/package.json b/packages/pack-sdk/ts/package.json
index 8d71e3305..716b018f3 100644
--- a/packages/pack-sdk/ts/package.json
+++ b/packages/pack-sdk/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@steerable/pack-sdk",
- "version": "0.12.5",
+ "version": "0.12.6",
"type": "module",
"description": "Scenario pack contract for @steerable/agent-shell (pure types, zero runtime). A scenario pack declares every extension a vertical scenario needs \u2014 services, tools, tables, skills, agent seeds, HTTP routes, renderer slots, branding \u2014 and the host composes the selected packs at build time.",
"license": "Apache-2.0",
diff --git a/packages/plugin-sdk/py/pyproject.toml b/packages/plugin-sdk/py/pyproject.toml
index fb584a833..7bbb4cc0e 100644
--- a/packages/plugin-sdk/py/pyproject.toml
+++ b/packages/plugin-sdk/py/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "steerable-plugin-sdk"
-version = "0.12.5"
+version = "0.12.6"
description = "Pure-Python authoring and RPC SDK for Steerable tool plugins"
license = { text = "Apache-2.0" }
readme = "README.md"
diff --git a/packages/sidecar/py/pyproject.toml b/packages/sidecar/py/pyproject.toml
index 616e9ff8a..ac28fb96e 100644
--- a/packages/sidecar/py/pyproject.toml
+++ b/packages/sidecar/py/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "steerable-sidecar"
-version = "0.12.5"
+version = "0.12.6"
description = "Steerable agent runtime sidecar — JSON-RPC over stdio."
license = { text = "Apache-2.0" }
readme = "README.md"
diff --git a/packages/sidecar/py/src/steerable_sidecar/web_tools.py b/packages/sidecar/py/src/steerable_sidecar/web_tools.py
index bf4e1fa4a..b021fe480 100644
--- a/packages/sidecar/py/src/steerable_sidecar/web_tools.py
+++ b/packages/sidecar/py/src/steerable_sidecar/web_tools.py
@@ -69,6 +69,7 @@
import logging
import os
import socket
+import xml.etree.ElementTree as ET
from collections.abc import Awaitable, Callable, Mapping
from dataclasses import dataclass
from html.parser import HTMLParser
@@ -163,6 +164,13 @@ def _confined_error(tool: str, target: str) -> str:
)
+def _clip_snippet(text: str, max_chars: int) -> str:
+ stripped = text.strip()
+ if len(stripped) <= max_chars:
+ return stripped
+ return stripped[: max_chars - 1].rstrip() + "…"
+
+
# ---------------------------------------------------------------------------
# Config
# ---------------------------------------------------------------------------
@@ -219,6 +227,7 @@ class WebToolsConfig:
fetch_max_redirects: int = 5
search_timeout_ms: int = 30_000
search_max_results: int = 8
+ search_max_snippet_chars: int = 350
search_provider: str = "tavily"
search_api_key: str | None = None
search_base_url: str = "https://api.tavily.com"
@@ -268,6 +277,10 @@ def resolve(cls, environ: Mapping[str, str] | None = None) -> "WebToolsConfig":
env, "STEERABLE_WEB_SEARCH_MAX_RESULTS", 8,
minimum=1, ceiling=_SEARCH_RESULTS_CEILING,
),
+ search_max_snippet_chars=_bounded_int(
+ env, "STEERABLE_WEB_SEARCH_MAX_SNIPPET_CHARS", 350,
+ minimum=80, ceiling=4_000,
+ ),
search_provider=provider,
search_api_key=api_key,
# Default base URL follows the provider; an explicit
@@ -622,25 +635,58 @@ def close(self) -> None:
super().close()
+_DEFAULT_BING_RSS_URL = "https://www.bing.com/search"
+_MAX_BING_RSS_REDIRECTS = 3
+
+
+def _is_bing_host(host: str) -> bool:
+ normalized = host.lower().rstrip(".")
+ return normalized == "bing.com" or normalized.endswith(".bing.com")
+
+
+def _parse_bing_rss(xml_text: str) -> list[WebSearchHit]:
+ if not xml_text or len(xml_text) > 2_000_000:
+ return []
+ lowered = xml_text.lower()
+ if " None:
self._endpoint = base_url.rstrip("/") + "/html/"
+ self._bing_rss_url = bing_rss_url
self._timeout = httpx.Timeout(timeout_ms / 1000)
self._allowed_domains = allowed_domains
self._blocked_domains = blocked_domains
@@ -664,7 +710,7 @@ def _policy_allows(self, url: str) -> bool:
return False
return True
- async def _request(
+ async def _request_ddg(
self, client: httpx.AsyncClient, query: str, max_results: int
) -> list[WebSearchHit]:
try:
@@ -709,6 +755,64 @@ async def _request(
break
return hits
+ async def _request_bing_rss(
+ self, client: httpx.AsyncClient, query: str, max_results: int
+ ) -> list[WebSearchHit] | None:
+ if not self._bing_rss_url:
+ return None
+ url = self._bing_rss_url
+ params: dict[str, str] | None = {"format": "rss", "q": query}
+ headers = {
+ "User-Agent": _USER_AGENT,
+ "Accept": "application/rss+xml, application/xml, text/xml",
+ }
+ try:
+ for _ in range(_MAX_BING_RSS_REDIRECTS + 1):
+ response = await client.get(url, params=params, headers=headers)
+ params = None
+ if response.status_code in (301, 302, 303, 307, 308):
+ location = response.headers.get("location")
+ if not location:
+ return None
+ next_url = urljoin(url, location)
+ parsed = urlsplit(next_url)
+ if parsed.scheme not in ("http", "https") or not _is_bing_host(
+ parsed.hostname or ""
+ ):
+ return None
+ url = next_url
+ continue
+ if response.status_code != 200:
+ return None
+ raw_hits = _parse_bing_rss(response.text)
+ if not raw_hits:
+ return None
+ hits: list[WebSearchHit] = []
+ for hit in raw_hits:
+ if not self._policy_allows(hit.url):
+ continue
+ hits.append(hit)
+ if len(hits) >= max_results:
+ break
+ return hits
+ except httpx.HTTPError:
+ return None
+ return None
+
+ async def _request(
+ self, client: httpx.AsyncClient, query: str, max_results: int
+ ) -> list[WebSearchHit]:
+ try:
+ return await self._request_ddg(client, query, max_results)
+ except WebSearchBackendError as ddg_exc:
+ logger.warning(
+ "ddg web_search failed (%s); falling back to Bing RSS", ddg_exc
+ )
+ fallback_hits = await self._request_bing_rss(client, query, max_results)
+ if fallback_hits is not None:
+ return fallback_hits
+ raise ddg_exc
+
class WebSearchBackendError(Exception):
"""A configured search backend failed (distinct from "not configured",
@@ -1135,17 +1239,24 @@ async def _read_response(
charset = response.charset_encoding or "utf-8"
decoded = raw.decode(charset, errors="replace")
content = _html_to_text(decoded) if content_type in ("text/html", "application/xhtml+xml") else decoded
- return ToolResult(
- success=True,
- data={
- "url": url,
- "status": response.status_code,
- "content_type": content_type or None,
- "bytes": len(raw),
- "truncated": truncated,
- "content": content,
- },
- )
+ data: dict[str, Any] = {
+ "url": url,
+ "status": response.status_code,
+ "content_type": content_type or None,
+ "bytes": len(raw),
+ "truncated": truncated,
+ "content": content,
+ }
+ if (
+ content_type in ("text/html", "application/xhtml+xml")
+ and len(raw) > 200
+ and not content.strip()
+ ):
+ data["note"] = (
+ "HTML body yielded empty text (likely a JS-rendered SPA or "
+ "challenge page); prefer web_search or another readable URL."
+ )
+ return ToolResult(success=True, data=data)
# ---------------------------------------------------------------------------
@@ -1341,7 +1452,9 @@ async def web_search(query: str = "", max_results: int | None = None) -> ToolRes
{
"title": hit.title,
"url": hit.url,
- "snippet": hit.snippet,
+ "snippet": _clip_snippet(
+ hit.snippet, cfg.search_max_snippet_chars
+ ),
**(
{"published_at": hit.published_at}
if hit.published_at
diff --git a/packages/sidecar/py/tests/test_web_tools.py b/packages/sidecar/py/tests/test_web_tools.py
index bb3eed3d2..dbb6085d7 100644
--- a/packages/sidecar/py/tests/test_web_tools.py
+++ b/packages/sidecar/py/tests/test_web_tools.py
@@ -848,6 +848,84 @@ async def test_ddg_bot_check_is_actionable() -> None:
assert "DuckDuckGo" in result.error
+async def test_ddg_falls_back_to_bing_rss_on_bot_check() -> None:
+ rss = """
+
+ -
+ Blocked Result
+ https://evil.com/bad
+ Should be filtered by domain policy
+
+ -
+ HK Visa Fee
+ https://www.ustraveldocs.com/hk/
+ Pay via FPS or CITIC Bank.
+
+ """
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ if request.url.host == "html.duckduckgo.com":
+ return httpx.Response(202, text="anomaly-modal")
+ if request.url.host == "www.bing.com":
+ return httpx.Response(
+ 302,
+ headers={"location": "https://cn.bing.com/search?format=rss&q=hk+visa"},
+ )
+ if request.url.host == "cn.bing.com":
+ return httpx.Response(200, text=rss)
+ return httpx.Response(404)
+
+ provider = DdgSearchProvider(
+ timeout_ms=5_000,
+ blocked_domains=("evil.com",),
+ client=httpx.AsyncClient(transport=httpx.MockTransport(handler)),
+ )
+ hits = await provider.search("hk visa", max_results=5)
+ assert hits == [
+ WebSearchHit(
+ title="HK Visa Fee",
+ url="https://www.ustraveldocs.com/hk/",
+ snippet="Pay via FPS or CITIC Bank.",
+ )
+ ]
+
+
+async def test_web_search_clips_oversized_snippets_to_prevent_spill() -> None:
+ assert WebToolsConfig.resolve({}).search_max_snippet_chars == 350
+ with pytest.raises(ValueError):
+ WebToolsConfig.resolve({"STEERABLE_WEB_SEARCH_MAX_SNIPPET_CHARS": "10"})
+
+ long_snippet = "甲" * 2000
+ provider = _FakeSearchProvider(
+ [WebSearchHit(title="Long", url="https://example.com/long", snippet=long_snippet)]
+ )
+ cfg = WebToolsConfig(search_max_snippet_chars=120)
+ router = ToolRouter()
+ register_web_tools(router, config=cfg, search_provider=provider, environ={})
+ result = await _call(router, "web_search", {"query": "q"})
+ assert result.success is True
+ snippet = result.data["results"][0]["snippet"]
+ assert len(snippet) == 120
+ assert snippet.endswith("…")
+
+
+async def test_web_fetch_flags_empty_spa_html_with_note() -> None:
+ spa_html = "App" + ("" * 10) + ""
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ return httpx.Response(
+ 200,
+ headers={"content-type": "text/html; charset=utf-8"},
+ text=spa_html,
+ )
+
+ router = _make_router(handler=httpx.MockTransport(handler), dns=_PUBLIC_DNS)
+ result = await _call(router, "web_fetch", {"url": "https://example.com/"})
+ assert result.success is True
+ assert result.data["content"] == ""
+ assert "SPA" in result.data["note"]
+
+
# ─── approval gating ────────────────────────────────────────────────────────
diff --git a/uv.lock b/uv.lock
index 9a49b7840..6679e94e0 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1709,7 +1709,7 @@ wheels = [
[[package]]
name = "steerable-agent-harness"
-version = "0.12.5"
+version = "0.12.6"
source = { editable = "packages/agent-harness/py" }
dependencies = [
{ name = "pydantic" },
@@ -1724,7 +1724,7 @@ requires-dist = [
[[package]]
name = "steerable-agent-protocol"
-version = "0.12.5"
+version = "0.12.6"
source = { editable = "packages/agent-protocol/py" }
dependencies = [
{ name = "pydantic" },
@@ -1735,7 +1735,7 @@ requires-dist = [{ name = "pydantic", specifier = ">=2.10.0" }]
[[package]]
name = "steerable-agent-runtime"
-version = "0.12.5"
+version = "0.12.6"
source = { editable = "packages/agent-runtime/py" }
dependencies = [
{ name = "httpx", extra = ["socks"] },
@@ -1863,7 +1863,7 @@ dev = [
[[package]]
name = "steerable-plugin-sdk"
-version = "0.12.5"
+version = "0.12.6"
source = { editable = "packages/plugin-sdk/py" }
dependencies = [
{ name = "steerable-agent-harness" },
@@ -1878,7 +1878,7 @@ requires-dist = [
[[package]]
name = "steerable-sidecar"
-version = "0.12.5"
+version = "0.12.6"
source = { editable = "packages/sidecar/py" }
dependencies = [
{ name = "ag-ui-protocol" },