Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): preserve malformed submission outcomes
liugaoweie20bd96df2f6
diff --git a/apps/desktop/src/main/cindy-media/__tests__/invocationService.test.ts b/apps/desktop/src/main/cindy-media/__tests__/invocationService.test.tsindex 2bc8ad369c..281feb41e3 100644--- a/apps/desktop/src/main/cindy-media/__tests__/invocationService.test.ts+++ b/apps/desktop/src/main/cindy-media/__tests__/invocationService.test.ts@@ -530,6 +530,32 @@ describe('Cindy Core media invocation state and security boundary', () => {expect(mocks.outboundFetch).toHaveBeenCalledTimes(1);});+ it('付费提交收到 2xx 非法 JSON 时保留 unknown,禁止再次 POST', async () => {+ mocks.guide.mockResolvedValue(+ resolvedGuide(+ operation({+ mode: 'sync',+ media: [{ path: ['data'], encoding: 'base64', kind: 'image' }],+ }),+ ),+ );+ mocks.outboundFetch.mockResolvedValue(new Response('{invalid-json', { status: 200 }));++ const invocationId = await prepare();+ await expect(+ callCindyMedia({ action: 'request', invocationId, body: { prompt: 'cat' } }),+ ).resolves.toMatchObject({+ ok: false,+ errorCode: 'SUBMISSION_OUTCOME_UNKNOWN',+ outcomeKnown: false,+ });+ expect(mocks.rows.get(invocationId)?.state).toBe('unknown');+ await expect(+ callCindyMedia({ action: 'request', invocationId, body: { prompt: 'cat' } }),+ ).resolves.toMatchObject({ ok: false, errorCode: 'INVOCATION_ALREADY_USED' });+ expect(mocks.outboundFetch).toHaveBeenCalledTimes(1);+ });+it('建连失败发生在派发前时恢复 prepared,不把 invocation 卡在 submitting', async () => {const resolved = resolvedGuide(operation({diff --git a/apps/desktop/src/main/cindy-media/invocationService.ts b/apps/desktop/src/main/cindy-media/invocationService.tsindex f5fb2d7fcc..6fb4940bf6 100644--- a/apps/desktop/src/main/cindy-media/invocationService.ts+++ b/apps/desktop/src/main/cindy-media/invocationService.ts@@ -400,6 +400,13 @@ async function dispatchRequest(input: {try {return JSON.parse(buffer.toString('utf8')) as unknown;} catch {+ if (input.operation === 'submit') {+ throw new MediaInvocationError(+ 'SUBMISSION_OUTCOME_UNKNOWN',+ '上游已返回成功状态,但响应不是合法 JSON,无法确认任务结果;不要自动重提',+ true,+ );+ }throw new MediaInvocationError('UPSTREAM_RESPONSE_INVALID', '上游成功响应不是合法 JSON');}} catch (error) {