Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(agent): clarify rich answers and input handoff discovery

Chrisd8ac309af08d
diff --git a/docs/product-rules/input-handoff.md b/docs/product-rules/input-handoff.md
index e8b5dd6fe9..c611c159a7 100644
--- a/docs/product-rules/input-handoff.md
+++ b/docs/product-rules/input-handoff.md
@@ -7,6 +7,8 @@
## 1. 用户应该得到什么
+工具发现入口:`cindy_helper.list_tools` 的简介直接指向 `auth` 类目的登录、验证码和二维码交接;类目概览同时说明通用代输入与 Grok 设备码授权。展开 `auth` 时返回工具说明和参数 schema,模型无需先发错误调用才能知道 `purpose`、`target` 等参数。三种 Harness 共用同一 MCP 工具目录;Pi 通过原有 MCP 网关发现它,不另外增加 system prompt。
+
Agent 在任何界面遇到只有主人才能填的输入框——账号、密码、验证码、它不知道的个人信息——调用
`request_input_handoff`,本轮结束。宿主读取目标窗口**当前这一步**,在主人的设备上、**输入框上方**出现一条
代输入条:图标、Agent 说的用途、宿主核实的位置(安全网站显示锁 + 站点,否则显示来源或应用名),右侧「跳过」
diff --git a/docs/rich-answers.md b/docs/rich-answers.md
index 20ade3649a..57feef7e1c 100644
--- a/docs/rich-answers.md
+++ b/docs/rich-answers.md
@@ -36,6 +36,8 @@ Desktop 使用原生 React 组件;Mobile 使用原生 View/Text 与既有媒
公共交付说明以表达目标、阅读层次和视觉组织为框架,明确要求优雅、美观、易读;模型根据内容自行决定组件、布局和强调方式,不使用场景白名单或固定组件组合。图文、图标、图表与控件是可组合能力,不要求用户点名后才使用。协议例子只说明语法,验收场景不构成输出模板。简短内容仍可简短表达,用户指定格式优先。
+公共说明开头直接要求主动把组件与 Markdown 组合使用,适用于各种题材和答案长度;不只描述“可以渲染”的能力。说明原位压缩重复介绍,不增加预置段落、发现调用或额外模型调用。组件协议、颜色边界和三个 Harness 的注入位置不变。
+
流程图按阅读效果与用户指定格式选择表达方式:`diagram` 是 Mermaid 自动布局的入口,不是所有流程图的必选组件;需要控制几何与连线路径时可以用 `svg`,也可以把小图与文字、分栏、折叠区或页签组合。两种格式都不能保证天然易读。用户要求画图或看样稿时应实际展示图,而不是只描述布局方案。
复杂图应保留判断、分支、汇合和回路,通过路径分组、结果标注及对应清楚的连接点减少交叉线;分段展示时必须交代段间关系并保留完整逻辑。按实际显示宽度检查文字,不把整张 Mermaid 或 SVG 缩小当成可读性方案。`svg` 没有内建缩放、平移或节点点击能力;需要小屏可读时用现有组件分段组织,不虚构渲染器交互。此选择指引复用上述公共入口,不改 Harness 原生指令、组件协议或历史消息渲染。
diff --git a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
index c82f32d0d9..b86a1df996 100644
--- a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
+++ b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
@@ -18,6 +18,41 @@ function parsePayload(result: unknown): Record<string, unknown> {
}
describe("cindy_helper MCP server", () => {
+ // Discovery used to describe auth as Grok-only and omit the handoff schema.
+ // Unit: a fresh client must discover the required window/purpose arguments
+ // before its first call, without using an invalid call to obtain the schema.
+ it('discovers input handoff and its required arguments before starting it', async () => {
+ const start = vi.fn(async () => ({ ok: true as const, requestId: 'handoff-1' }));
+ const server = createXdtHelperMcpServer({ inputHandoff: { start } }, {
+ agentKind: 'codex', workingDir: '/repo', sessionId: 'current-task',
+ getSessionContext: () => ({
+ agentKind: 'codex', workingDir: '/repo', sessionId: 'current-task', sessionInstanceId: 'instance-1',
+ }),
+ });
+ const client = new Client({ name: 'handoff-discovery-test', version: '1' });
+ const [ct, st] = InMemoryTransport.createLinkedPair();
+ await Promise.all([server.connect(st), client.connect(ct)]);
+ try {
+ const overview = parsePayload(await client.callTool({ name: 'list_tools', arguments: {} }));
+ expect(overview.categories).toEqual(expect.arrayContaining([
+ expect.objectContaining({ name: 'auth', description: expect.stringContaining('二维码') }),
+ ]));
+ const catalog = parsePayload(await client.callTool({ name: 'list_tools', arguments: { category: 'auth' } }));
+ const handoff = (catalog.tools as Array<{ name: string; inputSchema: Record<string, unknown> }>)[0]!;
+ expect(handoff.name).toBe('request_input_handoff');
+ expect(handoff.inputSchema).toMatchObject({
+ required: ['purpose', 'target'],
+ properties: { purpose: { type: 'string' }, target: { type: 'object', properties: { app: { type: 'string' } } } },
+ });
+ expect(parsePayload(await client.callTool({ name: 'call_tool', arguments: {
+ name: handoff.name, args: { purpose: 'Sign in to continue', target: { app: 'Google Chrome' } },
+ } }))).toMatchObject({ ok: true, request_id: 'handoff-1', status: 'pending' });
+ expect(start).toHaveBeenCalledWith(expect.objectContaining({ sessionId: 'current-task' }), {
+ purpose: 'Sign in to continue', target: { app: 'Google Chrome' },
+ });
+ } finally { await client.close(); await server.close(); }
+ });
+
it.each(['default', 'bot-main'] as const)('exposes runtime declarations through the same helper tool for %s', async (surface) => {
const runtimeCapabilities = vi.fn(async () => ({ ok: true, capabilities: [{ server: 'fixture' }] }));
const server = createXdtHelperMcpServer({ resolveSurface: async () => surface, runtimeCapabilities }, {
diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
index 23be3cfa91..95a8999841 100644
--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
@@ -122,14 +122,14 @@ export type {
// ── Entry-tool descriptions ─────────────────────────────────────────────────
const D_LIST_TOOLS =
- `探索当前任务获准使用的 ${BRAND_NAME} 辅助能力。` +
- '不传 category 先取得可用类目(含每类的用途与作用范围:本机 / 可跨电脑);只在确有需要时查看一个类目,再用 call_tool 执行。';
+ `探索当前任务获准的 ${BRAND_NAME} 能力:登录、验证码、二维码交接查 auth;` +
+ '其它先不传 category 查看用途与本机/跨电脑范围,再按类目发现工具,用 call_tool 执行。';
const D_CALL_TOOL =
'调用 list_tools 为当前任务返回的一个具体工具。不要猜工具名,也不要把它当成通用命令入口。';
const LIST_TOOLS_INPUT = {
- category: z.string().optional().describe('list_tools 上一步返回的类目;不传则先取类目概览。'),
+ category: z.string().optional().describe('要查看的类目;不传则取当前任务的可用类目概览。'),
};
const CALL_TOOL_INPUT = {
name: z.string().describe('工具名,从 list_tools 获取(如 get_capabilities)'),
@@ -147,7 +147,7 @@ const CATEGORY_ENUM = ['cindy', 'auth', 'control', 'history', 'feedback', 'hando
*/
export const HELPER_CATEGORY_DESCRIPTIONS: Record<(typeof CATEGORY_ENUM)[number], string> = {
cindy: `${BRAND_NAME} 能力说明与当前任务信息;get_capabilities({key:"self-management"}) 是管理自己的任务、定时任务、项目、伙伴的工具索引。本机。`,
- auth: '供应商授权登录(Grok 设备码)。本机。',
+ auth: '本机窗口的账号、密码、验证码、二维码交给主人填写或扫码(request_input_handoff);Grok 设备码授权。',
control: '管理任务与项目:归档/取消归档支持本机与跨电脑(deviceId::sessionId);改名、移动、标签、排队消息、插话、停止、运行设置、项目列表与增删改仅本机。',
history: '按话题查找跨渠道聊天,支持伙伴归属(teammate_id)、最近活动时间与真实来源;不要默认限制当前工作目录或创建日期。查询任务、工作目录、聊天记录、任务摘要与输入队列;任务结果附带可直接引用的 sessionUrl,已知 id 要链接用 get_task_digest。任务列表、搜索、读取聊天记录、任务摘要(get_task_digest)可跨电脑(device 参数 / deviceId::sessionId);其余本机。',
feedback: `向 ${BRAND_NAME} 官方提交反馈。`,
@@ -284,7 +284,7 @@ function registerListToolsEntry(
tools: tools.map((t) => ({
name: t.name,
description: t.description,
- ...(t.category === 'bots' || t.category === 'skills' ? {
+ ...(t.category === 'bots' || t.category === 'skills' || t.category === 'auth' ? {
inputSchema: z.toJSONSchema(z.strictObject(registry.get(t.name)!.inputShape)),
} : {}),
})),
diff --git a/packages/maker-shared/src/richAnswerGuide.ts b/packages/maker-shared/src/richAnswerGuide.ts
index c3581e94a4..fb039c4783 100644
--- a/packages/maker-shared/src/richAnswerGuide.ts
+++ b/packages/maker-shared/src/richAnswerGuide.ts
@@ -1,7 +1,7 @@
/** Single delivery protocol used by host instructions and optional capability lookup. */
-export const RICH_ANSWER_GUIDE = `Cindy can render a streaming component document directly in an assistant progress message or final answer. You choose content and layout; ordinary Markdown remains available. No HTML file or extra model call is needed.
+export const RICH_ANSWER_GUIDE = `Write streaming cindy-ui components directly in progress messages or final answers, alongside Markdown. Choose content and layout freely; no HTML file, tool call or extra model call is needed.
-Your canvas is an inline, progressively rendered part of the conversation, on Cindy's own surface. Layout, hierarchy, typography and spacing are yours; colors and backgrounds belong to Cindy so every answer stays calm and consistent with the application.
+Your canvas is inline on Cindy's conversation surface. Layout, hierarchy, typography and spacing are yours; colors and backgrounds belong to Cindy so answers stay calm and consistent.
Choose a diagram's format for readability and the user's requested output. Mermaid is an option, not a requirement for flowcharts or technical explanations. Use diagram for Mermaid's automatic layout; use svg when custom geometry and routing improve clarity, or compose smaller diagrams with text, rows, details or tabs. Neither format is inherently more readable. When asked to draw or preview, show the diagram rather than only describing a proposed layout.
@@ -52,7 +52,7 @@ Keep blocks under 128 KB, with no more than 2048 nodes and depth 32. Finish each
/** Host addition only: native CLI instructions and execution remain unchanged. */
export const ANSWER_DELIVERY_PROMPT = `## Cindy answer delivery
-Create beautiful, elegant, readable answers. You decide the layout, typography and charts within Cindy's colors, following the user's request and presentation preferences. Cindy's component defaults are fallbacks, not design requirements. These capabilities apply to tasks and companions without changing your tool use or native workflow.
+Create beautiful, elegant, readable answers. On Cindy surfaces, compose your answer in cindy-ui components, with Markdown within or alongside them. This applies across subjects and answer lengths; no rich-media request, fixed scenario or template is needed. Follow user format preferences. You own layout, typography and charts; Cindy supplies colors. Defaults are fallbacks. Preserve native workflows.
The component protocol is rendered on Cindy conversation surfaces. External channels retain their required formats. Controls hold local viewing state. Optional button/form send actions let the user explicitly submit visible text as a normal message to continue the conversation; they do not directly execute work or tools.