Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(lizi-mcps): 补齐 review 指出的漏套标量数组参数
Zhang Yunjin901e5db47629
diff --git a/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts b/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.tsindex 3ee7159c7d..94200e395d 100644--- a/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/archiveSessionsTool.test.ts@@ -60,6 +60,12 @@ describe('archive_sessions tool', () => {sessionIds: ['s1', 's2'],status: 'archived',});+ // 折叠形态也要自愈(glm 兼容层 <item> 序列化,同 #6369/images 病),不得报 INVALID_ARGS。+ await registry.call('archive_sessions', { session_ids: { item: ['s3', 's4'] } });+ expect(setSessionsStatus).toHaveBeenLastCalledWith({+ sessionIds: ['s3', 's4'],+ status: 'archived',+ });expect(parse(res)).toMatchObject({ok: true,status: 'archived',diff --git a/packages/lizi-mcps/src/__tests__/getChatHistoryTool.test.ts b/packages/lizi-mcps/src/__tests__/getChatHistoryTool.test.tsindex 6eafe00f59..a3f9cb50b8 100644--- a/packages/lizi-mcps/src/__tests__/getChatHistoryTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/getChatHistoryTool.test.ts@@ -109,4 +109,30 @@ describe('get_chat_history role defaults', () => {rolesDefaulted: false,}));});++ it('unwraps XML-style {item:[...]} folded session_ids and roles arrays', async () => {+ // glm 兼容层把数组参数序列化成 <item> 重复标签(同 #6369/images 病),不得报 INVALID_ARGS。+ const getMessages = vi.fn(async () => ({+ ok: true as const,+ page: { items: [], nextCursor: null, hasMore: false },+ }));+ const history = {+ listWorkdirs: vi.fn(),+ listSessions: vi.fn(),+ getMessages,+ searchChatHistory: vi.fn(),+ } satisfies XdtHelperHistoryDeps;+ const registry = new XdtHelperToolRegistry();+ registerGetChatHistoryTool(registry, { history });++ const result = await registry.call('get_chat_history', {+ session_ids: { item: ['device-a::session-1'] },+ roles: { item: ['ask_user'] },+ });+ expect(result.isError).toBeUndefined();+ expect(getMessages).toHaveBeenLastCalledWith(expect.objectContaining({+ roles: ['ask_user'],+ rolesDefaulted: false,+ }));+ });});diff --git a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.tsindex cb81b9b3bb..c82f32d0d9 100644--- a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts+++ b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts@@ -432,6 +432,18 @@ describe("cindy_helper MCP server", () => {}),);+ // 折叠形态的 context_refs 也要自愈(glm 兼容层 <item> 序列化,同 #6369/images 病)。+ const foldedRefs = parsePayload(+ await client.callTool({ name: "call_tool", arguments: { name: "start_session_task", args: {+ instruction: "Summarize the demo state.",+ context_refs: { item: ["note-1", "note-2"] },+ } } }),+ );+ expect(foldedRefs).toMatchObject({ ok: true, task_id: "session-task-1" });+ expect(startSessionTask).toHaveBeenLastCalledWith(+ expect.objectContaining({ contextRefs: ["note-1", "note-2"] }),+ );+// An old local-only group cannot carry the task's messages: the teammate must not promise them there.startSessionTask.mockResolvedValueOnce({ ok: true as const, delegationId: "session-task-2", childSessionId: "desktop-child-2",status: "running", completionDestination: 'private', deadlineAt: 1_788_000_000_000 });diff --git a/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts b/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.tsindex 591552f894..5fe481a96f 100644--- a/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts@@ -84,6 +84,20 @@ describe('search_chat_history tool', () => {expect(args.fromMs).toBeNull();});+ it('unwraps XML-style {item:[...]} folded session_ids and roles arrays', async () => {+ // glm 兼容层把数组参数序列化成 <item> 重复标签(同 #6369/images 病),不得报 INVALID_ARGS。+ const { registry, searchChatHistory } = setup(makeResult());+ const res = await registry.call('search_chat_history', {+ query: '登录报错',+ session_ids: { item: ['s-1', 's-2'] },+ roles: { item: ['user'] },+ });+ expect(res.isError).toBeFalsy();+ const args = searchChatHistory.mock.calls[0][0];+ expect(args.sessionIds).toEqual(['s-1', 's-2']);+ expect(args.roles).toEqual(['user']);+ });+it('非法 from ISO → INVALID_ARGS, 不调 host', async () => {const { registry, searchChatHistory } = setup(makeResult());const res = await registry.call('search_chat_history', { query: 'x', from: 'not-a-date' });diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.tsindex 161b44aeb7..dcb5890a00 100644--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts@@ -38,6 +38,7 @@ import { registerGrokLoginTools, type GrokLoginCallbacks } from './xdt-helper/grimport { registerInputHandoffTool, type InputHandoffCallbacks } from './xdt-helper/input_handoff.js';import { jsonObjectArg } from './json-object-arg.js';import { registerAsyncQuestionTool, supportsAsyncQuestionTool, type AskUserQuestionAsyncCallback } from './xdt-helper/ask_user_question_async.js';+import { stringArrayParam } from './xdt-helper/_array-param.js';import { XdtHelperToolRegistry } from './lizi_xdtHelperToolRegistry.js';import { registerCreateProjectTool, type CreateProjectCallback } from './xdt-helper/create_project.js';@@ -397,7 +398,7 @@ function registerStartSessionTaskEntry(title: z.string().min(1).max(120).optional(),working_dir: z.string().min(1).max(1_024).optional(),use_worktree: z.boolean().optional(),- context_refs: z.array(z.string().max(512)).max(32).optional(),+ context_refs: stringArrayParam(z.array(z.string().max(512)).max(32)).optional(),timeout_ms: z.number().int().min(1_000).max(86_400_000).optional(),},handler: async ({ instruction, title, working_dir, use_worktree, context_refs, timeout_ms, model_selection }) => {diff --git a/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts b/packages/lizi-mcps/src/xdt-helper/archive_sessions.tsindex eb37f63105..8639107d8a 100644--- a/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts+++ b/packages/lizi-mcps/src/xdt-helper/archive_sessions.ts@@ -20,6 +20,7 @@ import type { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { ControlResult } from '../lizi_xdtHelperMcpServer.js';import type { LiziMcpSessionContext } from '../types.js';import { errorPayload, okPayload } from './_payload.js';+import { stringArrayParam } from './_array-param.js';import { parseQualifiedSessionId } from './send_to_session.js';const MAX_BATCH_SIZE = 50;@@ -125,10 +126,7 @@ function registerSessionStatusTool(category: 'control',description: config.description,inputShape: {- session_ids: z- .array(z.string().min(1))- .min(1)- .max(MAX_BATCH_SIZE)+ session_ids: stringArrayParam(z.array(z.string().min(1)).min(1).max(MAX_BATCH_SIZE)).describe(config.idsDescription),},handler: async ({ session_ids }) => {diff --git a/packages/lizi-mcps/src/xdt-helper/get_chat_history.ts b/packages/lizi-mcps/src/xdt-helper/get_chat_history.tsindex 71305326e8..a0293bfdfa 100644--- a/packages/lizi-mcps/src/xdt-helper/get_chat_history.ts+++ b/packages/lizi-mcps/src/xdt-helper/get_chat_history.ts@@ -18,6 +18,7 @@ import { z } from 'zod';import type { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { XdtHelperHistoryDeps, HistoryRole } from './_history_types.js';import { okPayload, errorPayload } from './_payload.js';+import { stringArrayParam } from './_array-param.js';import { encodeCursor, decodeCursor } from './_history_cursor.js';import { resolveHistoryScope } from './_history_scope.js';@@ -99,9 +100,7 @@ export function registerGetChatHistoryTool(description: DESCRIPTION,inputShape: {// device-link hosts may use one `deviceId::sessionId`; the host enforces the trusted route.- session_ids: z- .array(z.string().min(1))- .max(50)+ session_ids: stringArrayParam(z.array(z.string().min(1)).max(50)).optional().describe('一批 sessionId(最多 50 个)。与 workdir / 时间段可叠加(AND)。'),workdir: z@@ -120,8 +119,7 @@ export function registerGetChatHistoryTool(.enum(['cc', 'codex', 'pi']).optional().describe('按 session.agentKind 过滤; 不传 = 全部返。'),- roles: z- .array(z.enum(ROLE_VALUES))+ roles: stringArrayParam(z.array(z.enum(ROLE_VALUES))).optional().describe('只返这些 role 的消息。不传 = 默认只返问答类(user/assistant/ask_user/plan_review),' +diff --git a/packages/lizi-mcps/src/xdt-helper/search_chat_history.ts b/packages/lizi-mcps/src/xdt-helper/search_chat_history.tsindex 9c554727bf..1d14718be3 100644--- a/packages/lizi-mcps/src/xdt-helper/search_chat_history.ts+++ b/packages/lizi-mcps/src/xdt-helper/search_chat_history.ts@@ -29,6 +29,7 @@ import { z } from 'zod';import type { XdtHelperToolRegistry } from '../lizi_xdtHelperToolRegistry.js';import type { XdtHelperHistoryDeps, HistoryRole } from './_history_types.js';import { okPayload, errorPayload } from './_payload.js';+import { stringArrayParam } from './_array-param.js';import { resolveHistoryScope } from './_history_scope.js';import { historyDeviceShape, HISTORY_DEVICE_DESCRIPTION, queryHistoryDevices } from './_history_devices.js';@@ -88,9 +89,7 @@ export function registerSearchChatHistoryTool(inputShape: {...historyDeviceShape,query: z.string().min(1).max(256).describe('自然语言查询(必填, 最长 256)。例: "上次怎么修的语音输入授权问题"。'),- session_ids: z- .array(z.string().min(1))- .max(50)+ session_ids: stringArrayParam(z.array(z.string().min(1)).max(50)).optional().describe('限定一批 sessionId(最多 50)。与其它过滤叠加(AND)。'),workdir: z.string().optional().describe('精确匹配 sessions.workingDir。'),@@ -100,8 +99,7 @@ export function registerSearchChatHistoryTool(.enum(['cc', 'codex', 'pi']).optional().describe('按 session.agentKind 过滤; 不传 = 全部搜。'),- roles: z- .array(z.enum(ROLE_VALUES))+ roles: stringArrayParam(z.array(z.enum(ROLE_VALUES))).optional().describe('只命中这些 role 的消息(也用于上下文窗口过滤)。不传 = 问答类' +