Skip to content

Commit 4143df7

Browse files
committed
test(agents): type attribution stream mock
1 parent 3b521f1 commit 4143df7

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/agents/sessions/sdk.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// session write-lock behavior.
33
import { Type } from "typebox";
44
import { beforeEach, describe, expect, it, vi } from "vitest";
5+
import type { Context, Model, SimpleStreamOptions } from "../../llm/types.js";
56

67
const thinkingMocks = vi.hoisted(() => ({
78
resolveThinkingDefaultForModel: vi.fn(() => "medium"),
89
}));
910
const streamMocks = vi.hoisted(() => ({
10-
streamSimple: vi.fn(() => "stream"),
11+
streamSimple: vi.fn(
12+
(_model: Model, _context: Context, _options?: SimpleStreamOptions) => "stream",
13+
),
1114
}));
1215

1316
vi.mock("../../auto-reply/thinking.js", () => ({
@@ -16,7 +19,6 @@ vi.mock("../../auto-reply/thinking.js", () => ({
1619
vi.mock("../../llm/stream.js", () => ({
1720
streamSimple: streamMocks.streamSimple,
1821
}));
19-
import type { Model } from "../../llm/types.js";
2022
import { AuthStorage } from "./auth-storage.js";
2123
import { createExtensionRuntime } from "./extensions/loader.js";
2224
import type { LoadExtensionsResult, ToolDefinition } from "./extensions/types.js";
@@ -85,7 +87,7 @@ function createResourceLoaderWithHandlers(
8587
};
8688
}
8789

88-
async function createSessionAndStreamModel(model: Model): Promise<Record<string, unknown>> {
90+
async function createSessionAndStreamModel(model: Model): Promise<SimpleStreamOptions> {
8991
streamMocks.streamSimple.mockClear();
9092
const { session } = await createAgentSession({
9193
model,
@@ -105,7 +107,7 @@ async function createSessionAndStreamModel(model: Model): Promise<Record<string,
105107
{},
106108
);
107109

108-
return streamMocks.streamSimple.mock.calls.at(-1)?.[2] as Record<string, unknown>;
110+
return streamMocks.streamSimple.mock.lastCall?.[2] ?? {};
109111
}
110112

111113
describe("createAgentSession attribution headers", () => {

0 commit comments

Comments
 (0)