mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
fix(ai): stop streams getting cut off and keep tool steps across messages
This commit is contained in:
1 parent
c5b2b880b6
commit
b4457b6121
17 files changed
+726
-254
No files matched your search
@@ -25,6 +25,7 @@ const state = vi.hoisted(() => ({
|
||||
]),
|
||||
fetchCalls: [] as Array<{ url: string; allowlist: readonly string[] }>,
|
||||
lastTls: null as Record<string, unknown> | null,
|
||||
lastIdleTimeout: undefined as number | undefined,
|
||||
lastSignal: null as AbortSignal | null,
|
||||
lastRedirect: undefined as RequestRedirect | undefined,
|
||||
}));
|
||||
@@ -65,8 +66,10 @@ vi.mock("../../utils/safe-outbound-fetch.js", () => ({
|
||||
init: RequestInit,
|
||||
allowlist: readonly string[],
|
||||
tls: Record<string, unknown> = {},
|
||||
idleTimeoutMs?: number,
|
||||
) => {
|
||||
state.lastTls = tls;
|
||||
state.lastIdleTimeout = idleTimeoutMs;
|
||||
state.lastRedirect = init.redirect;
|
||||
state.lastSignal = init.signal ?? null;
|
||||
state.fetchCalls.push({ url, allowlist });
|
||||
@@ -302,6 +305,12 @@ describe("ctx.fetch", () => {
|
||||
expect(state.lastTls).toEqual({});
|
||||
});
|
||||
|
||||
it("hands the caller's timeout to the guard for the body idle timeout", async () => {
|
||||
const ctx = contextFor(["network:outbound"]);
|
||||
await ctx.fetch("https://example.com/stream", { timeoutMs: 600_000 });
|
||||
expect(state.lastIdleTimeout).toBe(600_000);
|
||||
});
|
||||
|
||||
it("aborts the request, and a streamed body, when the caller's signal fires", async () => {
|
||||
const ctx = contextFor(["network:outbound"]);
|
||||
const controller = new AbortController();
|
||||
|
||||
Reference in new issue
Block a user