Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(helper): skip leading whitespace when validating history dates
Zhao Dengfeng7abc3f18b5d8
diff --git a/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts b/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.tsindex 2396cfdd9f..fc926862b2 100644--- a/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts+++ b/packages/lizi-mcps/src/__tests__/searchChatHistoryTool.test.ts@@ -108,8 +108,10 @@ describe('search_chat_history tool', () => {it('日历上不存在的日期 → INVALID_ARGS, 不静默滚到下个月; 合法闰日照常查询', async () => {const { registry, searchChatHistory } = setup(makeResult());// new Date('2024-02-30') 会被归一化成 2024-03-01, 查询范围静默偏移。- const res = await registry.call('search_chat_history', { query: 'x', from: '2024-02-30' });- expect(parse(res)).toMatchObject({ ok: false, errorCode: 'INVALID_ARGS' });+ for (const from of ['2024-02-30', ' 2024-02-30']) {+ const res = await registry.call('search_chat_history', { query: 'x', from });+ expect(parse(res)).toMatchObject({ ok: false, errorCode: 'INVALID_ARGS' });+ }expect(searchChatHistory).not.toHaveBeenCalled();await registry.call('search_chat_history', { query: 'x', to: '2024-02-29T23:59:59Z' });diff --git a/packages/lizi-mcps/src/xdt-helper/_history_time.ts b/packages/lizi-mcps/src/xdt-helper/_history_time.tsindex 6b6bb9cd1d..b9e2e21916 100644--- a/packages/lizi-mcps/src/xdt-helper/_history_time.ts+++ b/packages/lizi-mcps/src/xdt-helper/_history_time.ts@@ -14,7 +14,8 @@ export function parseIsoMs(s: string | undefined): number | null | 'invalid' {if (s === undefined || s === '') return null;const t = new Date(s).getTime();if (!Number.isFinite(t)) return 'invalid';- const date = /^(\d{4})-(\d{2})-(\d{2})(?![\d])/.exec(s);+ // new Date 会忽略前导空白, 日期部分的定位也要跳过它, 否则 ' 2024-02-30' 绕过校验。+ const date = /^(\d{4})-(\d{2})-(\d{2})(?![\d])/.exec(s.trimStart());if (date) {const year = Number(date[1]);const month = Number(date[2]);