Add DeepSeek TUI to ACP catalog
This commit is contained in:
@@ -362,6 +362,33 @@ describe("createLoggedNdJsonStream", () => {
|
||||
consoleError.mockRestore();
|
||||
});
|
||||
|
||||
test("normalizes stringified numeric ACP response ids", async () => {
|
||||
const input = new TransformStream<Uint8Array, Uint8Array>();
|
||||
const output = new TransformStream<Uint8Array, Uint8Array>();
|
||||
const logger = {
|
||||
warn: vi.fn(),
|
||||
};
|
||||
|
||||
const stream = createLoggedNdJsonStream(output.writable, input.readable, {
|
||||
logger: asInternals<ReturnType<typeof createTestLogger>>(logger),
|
||||
provider: "deepseek-tui",
|
||||
});
|
||||
const reader = stream.readable.getReader();
|
||||
const writer = input.writable.getWriter();
|
||||
|
||||
await writer.write(
|
||||
new TextEncoder().encode('{"jsonrpc":"2.0","id":"0","result":{"ok":true}}\n'),
|
||||
);
|
||||
|
||||
const parsed = await reader.read();
|
||||
|
||||
expect(parsed.value).toEqual({ jsonrpc: "2.0", id: 0, result: { ok: true } });
|
||||
expect(logger.warn).not.toHaveBeenCalled();
|
||||
|
||||
await writer.close();
|
||||
reader.releaseLock();
|
||||
});
|
||||
|
||||
test("does not log terminal control sequences from malformed ACP stdout", async () => {
|
||||
const input = new TransformStream<Uint8Array, Uint8Array>();
|
||||
const output = new TransformStream<Uint8Array, Uint8Array>();
|
||||
|
||||
@@ -180,6 +180,26 @@ function summarizeMalformedACPStdoutError(error: unknown): { type: string; messa
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeACPIncomingMessage(message: AnyMessage): AnyMessage {
|
||||
if (
|
||||
"id" in message &&
|
||||
!("method" in message) &&
|
||||
typeof message.id === "string" &&
|
||||
/^\d+$/.test(message.id)
|
||||
) {
|
||||
const numericId = Number(message.id);
|
||||
if (Number.isSafeInteger(numericId)) {
|
||||
return {
|
||||
...message,
|
||||
// COMPAT(deepseek-tui-acp-id): added v0.1.78, remove after 2026-11-19
|
||||
// once the ACP SDK accepts stringified numeric response IDs.
|
||||
id: numericId,
|
||||
} as AnyMessage;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
export function createLoggedNdJsonStream(
|
||||
output: NodeWritableStream,
|
||||
input: NodeReadableStream,
|
||||
@@ -214,7 +234,7 @@ export function createLoggedNdJsonStream(
|
||||
|
||||
try {
|
||||
const message: AnyMessage = JSON.parse(trimmedLine);
|
||||
controller.enqueue(message);
|
||||
controller.enqueue(normalizeACPIncomingMessage(message));
|
||||
} catch (error) {
|
||||
options.logger.warn(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user