mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-29 03:35:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47573fde57 |
@@ -7,10 +7,7 @@ import {
|
||||
} from "@/stores/session-store";
|
||||
import type { StreamItem } from "@/types/stream";
|
||||
import { normalizeAgentSnapshot } from "@/utils/agent-snapshots";
|
||||
import {
|
||||
createPluginAgentSnapshot,
|
||||
createPluginWorkspaceSnapshot,
|
||||
} from "@/plugins/client-state/snapshots";
|
||||
import { createPluginWorkspaceSnapshot } from "@/plugins/client-state/snapshots";
|
||||
import { ReplicaCache } from ".";
|
||||
import type { DirectoryCheckpoint } from "@/runtime/replica-cache";
|
||||
import type { ReplicaHostRows, ReplicaRow, ReplicaRowChanges, ReplicaRowStore } from "./row-store";
|
||||
@@ -161,7 +158,6 @@ function agent(id = "agent-1"): Agent {
|
||||
persistence: null,
|
||||
title: "Cached agent",
|
||||
labels: {},
|
||||
metadata: {},
|
||||
},
|
||||
SERVER_ID,
|
||||
),
|
||||
@@ -1437,40 +1433,3 @@ it("retains workspace metadata across replica-cache reload and invalidates pre-m
|
||||
projects: checkpoint.projects,
|
||||
});
|
||||
});
|
||||
|
||||
it("restores agent metadata for plugins when the directory cache reopens", async () => {
|
||||
const storage = new MemoryStorage();
|
||||
const writer = createCache(storage);
|
||||
const baseline = directory();
|
||||
const metadata = { "plugin.waiting": { kind: "plan", at: "2026-07-18T08:02:00.000Z" } };
|
||||
baseline.agents.set("agent-1", { ...agent(), metadata });
|
||||
commitDirectory(writer, SERVER_ID, baseline);
|
||||
await writer.flush();
|
||||
|
||||
const restored = await createCache(storage).readDirectory(SERVER_ID);
|
||||
expect(
|
||||
createPluginAgentSnapshot(restored.agents.get("agent-1")!, "workspace-1").metadata,
|
||||
).toEqual(metadata);
|
||||
expect(restored.checkpoint).toEqual(baseline.checkpoint);
|
||||
});
|
||||
|
||||
it("discards the agent cursor when a pre-metadata agent row is restored", async () => {
|
||||
const storage = new MemoryStorage();
|
||||
const writer = createCache(storage);
|
||||
const baseline = directory({
|
||||
agents: { generation: "g", afterSeq: 12 },
|
||||
projects: { generation: "g", afterSeq: 4 },
|
||||
});
|
||||
commitDirectory(writer, SERVER_ID, baseline);
|
||||
await writer.flush();
|
||||
|
||||
const key = `${SERVER_ID}:agent:agent-1`;
|
||||
const row = storage.rows.get(key)!;
|
||||
const legacyPayload = JSON.parse(row.payload) as { snapshot: Record<string, unknown> };
|
||||
delete legacyPayload.snapshot.metadata;
|
||||
storage.rows.set(key, { ...row, payload: JSON.stringify(legacyPayload) });
|
||||
|
||||
const restored = await createCache(storage).readDirectory(SERVER_ID);
|
||||
expect(restored.checkpoint).toEqual({ projects: baseline.checkpoint.projects });
|
||||
expect(restored.agents.size).toBe(0);
|
||||
});
|
||||
|
||||
@@ -257,8 +257,6 @@ const StoredAgentSnapshotSchema = z.strictObject({
|
||||
lastError: z.string().optional(),
|
||||
title: z.string().nullable(),
|
||||
labels: z.record(z.string(), z.string()),
|
||||
// Require metadata so older rows invalidate the agent cursor and refetch from the daemon.
|
||||
metadata: z.record(z.string(), z.unknown() as z.ZodType<JsonValue>),
|
||||
// Optional: clients without background_agents never received a background agent to cache.
|
||||
background: z.boolean().optional(),
|
||||
requiresAttention: z.boolean().optional(),
|
||||
@@ -707,7 +705,6 @@ function serializeAgent(agent: Agent): StoredAgent {
|
||||
...(agent.lastError ? { lastError: agent.lastError } : {}),
|
||||
title: agent.title,
|
||||
labels: agent.labels,
|
||||
metadata: agent.metadata ?? {},
|
||||
...(agent.background ? { background: true } : {}),
|
||||
requiresAttention: agent.requiresAttention ?? false,
|
||||
backgroundWork: agent.backgroundWork,
|
||||
|
||||
@@ -136,12 +136,11 @@ describe.skipIf(isPlatform("win32"))("createForgeCliRunner", () => {
|
||||
}
|
||||
}
|
||||
|
||||
it("kills a hung CLI invocation after the configured timeout", async () => {
|
||||
const cli = writeSlowCli();
|
||||
it("kills a CLI that ignores SIGTERM at the configured timeout", async () => {
|
||||
const runner = createForgeCliRunner({
|
||||
binary: cli,
|
||||
binary: process.execPath,
|
||||
envOverlay: {},
|
||||
timeoutMs: 100,
|
||||
timeoutMs: 500,
|
||||
isAuthFailureText: () => false,
|
||||
errorClasses: {
|
||||
isAlreadyClassified: () => false,
|
||||
@@ -152,7 +151,12 @@ describe.skipIf(isPlatform("win32"))("createForgeCliRunner", () => {
|
||||
},
|
||||
});
|
||||
|
||||
await expect(runner.run(["arg"], { cwd: tempDir })).rejects.toThrow();
|
||||
await expect(
|
||||
runner.run(
|
||||
["-e", "process.on('SIGTERM', () => {}); setTimeout(() => process.exit(7), 2000);"],
|
||||
{ cwd: tempDir },
|
||||
),
|
||||
).rejects.toMatchObject({ killed: true, signal: "SIGKILL" });
|
||||
});
|
||||
|
||||
it("classifies a timed-out invocation through normalizeError", async () => {
|
||||
|
||||
@@ -161,6 +161,8 @@ export function createForgeCliRunner(options: CreateForgeCliRunnerOptions): Forg
|
||||
envOverlay: { ...options.envOverlay, ...runOptions.envOverlay },
|
||||
maxBuffer: 10 * 1024 * 1024,
|
||||
timeout: options.timeoutMs,
|
||||
// execFile sends one signal at the deadline. A CLI can ignore SIGTERM.
|
||||
killSignal: "SIGKILL",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -653,39 +653,6 @@ describe("createTerminal", () => {
|
||||
expect(session.getExitInfo()).toEqual(exitInfo);
|
||||
});
|
||||
|
||||
it.runIf(isPlatform("win32"))(
|
||||
"starts a ConPTY program when the event loop stalls past five seconds after spawn",
|
||||
async () => {
|
||||
// node-pty reports the ConPTY output worker ready by a worker message, and failed the
|
||||
// spawn with exit code -1 when that message came after 5 s. A loaded runner delays it
|
||||
// that long; blocking the event loop for 6 s makes the delay certain. Spawning and
|
||||
// blocking inside a check-phase callback makes the next loop iteration start with the
|
||||
// timers phase, so the old 5 s timer always runs before the worker message is delivered.
|
||||
const child = await new Promise<pty.IPty>((resolve) => {
|
||||
setImmediate(() => {
|
||||
const spawned = pty.spawn(process.execPath, ["-e", "process.stdout.write('STARTED')"], {
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
cwd: realpathSync(tmpdir()),
|
||||
});
|
||||
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 6000);
|
||||
resolve(spawned);
|
||||
});
|
||||
});
|
||||
let output = "";
|
||||
child.onData((data) => {
|
||||
output += data;
|
||||
});
|
||||
const exited = new Promise<number>((resolve) => {
|
||||
child.onExit(({ exitCode }) => resolve(exitCode));
|
||||
});
|
||||
|
||||
expect(await exited).toBe(0);
|
||||
expect(output).toContain("STARTED");
|
||||
},
|
||||
30_000,
|
||||
);
|
||||
|
||||
it("retains the final lines after output far exceeds the recent-output char cap", async () => {
|
||||
// Emit many small chunks whose total length is well past the 16000-char
|
||||
// recent-output cap, so the chunk-trimming path runs repeatedly. The final
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
diff --git a/node_modules/node-pty/lib/windowsPtyAgent.js b/node_modules/node-pty/lib/windowsPtyAgent.js
|
||||
index 90ffd8f..d9567b1 100644
|
||||
--- a/node_modules/node-pty/lib/windowsPtyAgent.js
|
||||
+++ b/node_modules/node-pty/lib/windowsPtyAgent.js
|
||||
@@ -21,7 +21,10 @@ var conptyNative;
|
||||
* has started.
|
||||
*/
|
||||
var FLUSH_DATA_INTERVAL = 1000;
|
||||
-var CONNECTION_TIMEOUT = 5000;
|
||||
+// Paseo: the output worker is a worker thread that reports ready by message. A busy event loop
|
||||
+// or a loaded machine can delay that message past 5 s, and the spawn then fails with exit
|
||||
+// code -1 before the program starts. Wait 30 s instead; a worker that fails still errors at once.
|
||||
+var CONNECTION_TIMEOUT = 30000;
|
||||
var defaultWindowsPtyAgentOptions = {
|
||||
connectionTimeout: CONNECTION_TIMEOUT,
|
||||
conoutConnectionFactory: function (conoutPipeName, useConptyDll) { return new windowsConoutConnection_1.ConoutConnection(conoutPipeName, useConptyDll); }
|
||||
@@ -123,14 +123,6 @@ const patchedPackages = [
|
||||
patchPrefix: "@opencode-ai+sdk+",
|
||||
cwd: "packages/server",
|
||||
},
|
||||
// Windows: wait 30 s instead of 5 s for the ConPTY output worker to report ready. A loaded
|
||||
// machine delays that message past 5 s, and the program then exits with code -1 before it
|
||||
// starts. Upstream keeps 5 s through 1.2.0-beta.18; keep while the server uses node-pty.
|
||||
{
|
||||
nodeModulesPath: "packages/server/node_modules/node-pty",
|
||||
patchPrefix: "node-pty+",
|
||||
cwd: "packages/server",
|
||||
},
|
||||
];
|
||||
|
||||
const installedPackages = patchedPackages.filter(({ nodeModulesPath }) =>
|
||||
|
||||
Reference in New Issue
Block a user