Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zcode-app-cli",
"version": "3.7.5-11",
"version": "3.7.6-11",
"description": "Unofficial terminal client for the ZCode agent runtime",
"keywords": [
"agent",
Expand Down
2 changes: 0 additions & 2 deletions scripts/check-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ if (!runtimeSource.includes('"plugin://"')
|| !runtimeSource.includes(".subscribeSessionEvents=")
|| !runtimeSource.includes(".sendBackgroundTaskMessage=async")
|| !runtimeSource.includes("backgroundTaskDetails")
|| !runtimeSource.includes('i.includes("AI SDK Warning")&&i.includes("cacheControl breakpoint limit")')
|| !runtimeSource.includes('if(n==="model_not_found")return{code:lr.ModelNotFound')
|| !runtimeSource.includes("autoBackgroundMs:this.config.subagents?.autoBackgroundMs??1e3,outputRootDir:")
|| runtimeSource.split("Detached background agent lifecycle failed").length < 3
|| !runtimeSource.includes('if(e?.restart===!0&&o.status==="running")')
Expand Down
24 changes: 1 addition & 23 deletions scripts/sync-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,6 @@ export function supportsMultiMessageFileRewind(runtime: string): boolean {
.test(runtime);
}

/** Suppress known cache-control warnings before they reach the TUI stderr stream. */
export function patchRuntimeTuiWarnings(runtime: string): string {
const suppression = 'i.includes("AI SDK Warning")&&i.includes("cacheControl breakpoint limit")';
if (runtime.includes(suppression)) return runtime;
const anchor = "if(LKn.test(i)||BKn.test(i)){";
if (!runtime.includes(anchor)) return runtime;
return runtime.replace(anchor, "if(LKn.test(i)||BKn.test(i)||" + suppression + "){");
}

/** Prevent provider model lookup failures from being retried as generic 5xx errors. */
export function patchRuntimeProviderRetryClassification(runtime: string): string {
const classification = 'if(n==="model_not_found")return{code:lr.ModelNotFound,message:o,reason:Ht.InvalidRequest,retryReason:fn.NetworkError,retryable:!1,retryAfterMs:r,statusCode:i};';
if (runtime.includes(classification)) return runtime;
const anchor = 'function QBr(e,t,r){if(!CS(e))return;let o=XBr(e),n=eUr(e),i=AWo(e,t),a=n?ZBr(n):void 0;';
if (!runtime.includes(anchor)) return runtime;
return runtime.replace(anchor, anchor + classification);
}

/** Keep short Agent calls inline, but detach long-running agents from the foreground turn. */
export function patchRuntimeAgentAutoBackground(runtime: string): string {
const marker = "autoBackgroundMs:this.config.subagents?.autoBackgroundMs??1e3,outputRootDir:";
Expand Down Expand Up @@ -743,11 +725,7 @@ async function installTuiBridge(nextVendor: string): Promise<void> {
patchRuntimeAgentAutoBackground(
patchRuntimeDetachedAgentLifecycle(
patchRuntimeTerminalToolProjection(
patchRuntimeProviderRetryClassification(
patchRuntimeTuiWarnings(
patchRuntimeBackgroundTaskProjection(patchRuntimeTuiBridge(runtime))
)
)
patchRuntimeBackgroundTaskProjection(patchRuntimeTuiBridge(runtime))
)
)
)
Expand Down
39 changes: 0 additions & 39 deletions test/sync-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import {
patchRuntimeAgentAutoBackground,
patchRuntimeBackgroundTaskProjection,
patchRuntimeDetachedAgentLifecycle,
patchRuntimeProviderRetryClassification,
patchRuntimeTerminalToolProjection,
patchRuntimeOAuthHttpErrors,
patchRuntimeTuiBridge,
patchRuntimeTuiWarnings,
patchRuntimeZaiDesktopOAuth,
resolveArtifactUrl,
resolveLatestRuntimeLock,
Expand Down Expand Up @@ -411,43 +409,6 @@ describe("runtime synchronization", () => {
expect(modernPatched).not.toContain("Array.isArray(t.targetMessageIds)");
});

test("filters cache-control warnings from the TUI stderr stream", () => {
const runtime = "function UKn(e,t){if(LKn.test(i)||BKn.test(i)){return i}}";
const patched = patchRuntimeTuiWarnings(runtime);
expect(patched).toContain('i.includes("AI SDK Warning")&&i.includes("cacheControl breakpoint limit")');
expect(patchRuntimeTuiWarnings(patched)).toBe(patched);
});

test("does not retry provider model lookup failures reported with HTTP 503", () => {
const runtime = [
'const CS=()=>true,XBr=e=>e.providerMessage,eUr=e=>e.providerCode,AWo=e=>e.responseStatus,ZBr=()=>undefined;',
'const lr={ModelNotFound:"model_not_found"},Ht={InvalidRequest:"invalid_request"},fn={NetworkError:"network_error"};',
"function QBr(e,t,r){if(!CS(e))return;let o=XBr(e),n=eUr(e),i=AWo(e,t),a=n?ZBr(n):void 0;",
"if(a)return a;return i>=500?{retryable:!0,statusCode:i}:{retryable:!1,statusCode:i}}"
].join("");
const patched = patchRuntimeProviderRetryClassification(runtime);
expect(patched).toContain(
'if(n==="model_not_found")return{code:lr.ModelNotFound,message:o,reason:Ht.InvalidRequest,retryReason:fn.NetworkError,retryable:!1'
);
const classify = new Function(`${patched};return QBr;`)() as (
error: { providerCode: string; providerMessage: string; responseStatus: number }
) => { code?: string; retryable: boolean; statusCode: number };
expect(classify({
providerCode: "model_not_found",
providerMessage: "No available channel for model GLM-5.2",
responseStatus: 503
})).toMatchObject({ code: "model_not_found", retryable: false, statusCode: 503 });
expect(classify({
providerCode: "server_error",
providerMessage: "Temporary upstream failure",
responseStatus: 503
})).toMatchObject({ retryable: true, statusCode: 503 });
expect(patchRuntimeProviderRetryClassification(patched)).toBe(patched);
expect(patchRuntimeProviderRetryClassification("runtime without the classifier anchor")).toBe(
"runtime without the classifier anchor"
);
});

test("auto-backgrounds long Agent calls while preserving explicit configuration", () => {
const runtime = "function delay(){return{autoBackgroundMs:this.config.subagents?.autoBackgroundMs,outputRootDir:'tasks'}}";
const patched = patchRuntimeAgentAutoBackground(runtime);
Expand Down
6 changes: 3 additions & 3 deletions zcode-runtime.lock.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"schemaVersion": 1,
"appVersion": "3.7.5",
"appVersion": "3.7.6",
"platform": "linux",
"arch": "x64",
"url": "https://cdn-zcode.z.ai/zcode/electron/releases/3.7.5/linux-x64/ZCode-3.7.5-linux-x64.deb",
"sha512": "+gCFedwyxr4BJEIQ4QWmbj21FlyGn7Gb3LbcQsyx38PKAt2qoRbjAVjM5XVU0Tj5wViuKFZk/1xRuem28Kjf7A=="
"url": "https://cdn-zcode.z.ai/zcode/electron/releases/3.7.6/linux-x64/ZCode-3.7.6-linux-x64.deb",
"sha512": "G2/jCJdOOc7vlCSoqJjCyz7UTdaBWucW7+itRYU5jCEeqvirGOau3hK7HAuf4/Ahv5qQNBO3kU2JjwXx4kdCWQ=="
}