@@ -11,23 +11,26 @@ describe("OllamaClient", () => {
1111 mockServer = null;
1212 });
1313
14- test("should create client with default config", () => {
15- client = new OllamaClient();
14+ test("should create client with config", () => {
15+ client = new OllamaClient({
16+ baseUrl: "http://localhost:11434",
17+ model: "qwen3:8b",
18+ options: { temperature: 1.2 },
19+ timeout: 8000,
20+ });
1621 const config = client.getConfig();
1722
1823 expect(config.baseUrl).toBe("http://localhost:11434");
1924 expect(config.model).toBe("qwen3:8b");
20- expect(config.temperature).toBe(1.2);
21- expect(config.thinking).toBe(false);
25+ expect(config.options).toEqual({ temperature: 1.2 });
2226 expect(config.timeout).toBe(8000);
2327 });
2428
25- test("should create client with custom config", () => {
29+ test("should create client with custom options", () => {
2630 client = new OllamaClient({
2731 baseUrl: "http://custom:9999",
2832 model: "custom-model",
29- temperature: 0.5,
30- thinking: true,
33+ options: { temperature: 0.5, thinking: true },
3134 timeout: 5000,
3235 });
3336
@@ -35,18 +38,22 @@ describe("OllamaClient", () => {
3538
3639 expect(config.baseUrl).toBe("http://custom:9999");
3740 expect(config.model).toBe("custom-model");
38- expect(config.temperature).toBe(0.5);
39- expect(config.thinking).toBe(true);
41+ expect(config.options).toEqual({ temperature: 0.5, thinking: true });
4042 expect(config.timeout).toBe(5000);
4143 });
4244
4345 test("should update config", () => {
44- client = new OllamaClient();
45- client.updateConfig({ model: "new-model", temperature: 0.8 });
46+ client = new OllamaClient({
47+ baseUrl: "http://localhost:11434",
48+ model: "old-model",
49+ options: { temperature: 1.2 },
50+ timeout: 8000,
51+ });
52+ client.updateConfig({ model: "new-model", options: { temperature: 0.8 } });
4653
4754 const config = client.getConfig();
4855 expect(config.model).toBe("new-model");
49- expect(config.temperature).toBe(0.8);
56+ expect(config.options).toEqual({ temperature: 0.8 });
5057 });
5158
5259 test("should make successful generation request", async () => {
@@ -65,10 +72,14 @@ describe("OllamaClient", () => {
6572
6673 client = new OllamaClient({
6774 baseUrl: `http://localhost:${mockServer.port}`,
75+ model: "test-model",
76+ options: {},
77+ timeout: 8000,
6878 });
6979
70- const response = await client.generate("test prompt");
71- expect(response).toBe("test response");
80+ const result = await client.generate("test prompt");
81+ expect(result.response).toBe("test response");
82+ expect(result.thinking).toBeUndefined();
7283 });
7384
7485 test("should trim response", async () => {
@@ -86,10 +97,13 @@ describe("OllamaClient", () => {
8697
8798 client = new OllamaClient({
8899 baseUrl: `http://localhost:${mockServer.port}`,
100+ model: "test-model",
101+ options: {},
102+ timeout: 8000,
89103 });
90104
91- const response = await client.generate("test");
92- expect(response).toBe("trimmed");
105+ const result = await client.generate("test");
106+ expect(result.response).toBe("trimmed");
93107 });
94108
95109 test("should handle timeout", async () => {
@@ -103,6 +117,8 @@ describe("OllamaClient", () => {
103117
104118 client = new OllamaClient({
105119 baseUrl: `http://localhost:${mockServer.port}`,
120+ model: "test-model",
121+ options: {},
106122 timeout: 100,
107123 });
108124
@@ -119,6 +135,9 @@ describe("OllamaClient", () => {
119135
120136 client = new OllamaClient({
121137 baseUrl: `http://localhost:${mockServer.port}`,
138+ model: "test-model",
139+ options: {},
140+ timeout: 8000,
122141 });
123142
124143 await expect(client.generate("test")).rejects.toThrow(/status 500/);
@@ -137,13 +156,16 @@ describe("OllamaClient", () => {
137156
138157 client = new OllamaClient({
139158 baseUrl: `http://localhost:${mockServer.port}`,
159+ model: "test-model",
160+ options: {},
161+ timeout: 8000,
140162 });
141163
142164 await expect(client.generate("test")).rejects.toThrow(/missing 'response' field/);
143165 });
144166
145- test("should include thinking when enabled", async () => {
146- let capturedRequest: { options: { thinking?: boolean } } | null = null;
167+ test("should pass options with thinking enabled", async () => {
168+ let capturedRequest: { options: Record<string, unknown> } | null = null;
147169
148170 mockServer = Bun.serve({
149171 port: 0,
@@ -160,17 +182,20 @@ describe("OllamaClient", () => {
160182
161183 client = new OllamaClient({
162184 baseUrl: `http://localhost:${mockServer.port}`,
163- thinking: true,
185+ model: "test-model",
186+ options: { thinking: true, temperature: 1.2 },
187+ timeout: 8000,
164188 });
165189
166190 await client.generate("test");
167191
168192 expect(capturedRequest).not.toBeNull();
169193 expect(capturedRequest!.options.thinking).toBe(true);
194+ expect(capturedRequest!.options.temperature).toBe(1.2);
170195 });
171196
172- test("should not include thinking when false", async () => {
173- let capturedRequest: { options: { thinking?: boolean } } | null = null;
197+ test("should pass options without thinking", async () => {
198+ let capturedRequest: { options: Record<string, unknown> } | null = null;
174199
175200 mockServer = Bun.serve({
176201 port: 0,
@@ -187,11 +212,41 @@ describe("OllamaClient", () => {
187212
188213 client = new OllamaClient({
189214 baseUrl: `http://localhost:${mockServer.port}`,
215+ model: "test-model",
216+ options: { temperature: 0.8 },
217+ timeout: 8000,
190218 });
191219
192220 await client.generate("test");
193221
194222 expect(capturedRequest).not.toBeNull();
195223 expect(capturedRequest!.options.thinking).toBeUndefined();
224+ expect(capturedRequest!.options.temperature).toBe(0.8);
225+ });
226+
227+ test("should return thinking content when provided", async () => {
228+ mockServer = Bun.serve({
229+ port: 0,
230+ fetch: async () => {
231+ return Response.json({
232+ model: "test",
233+ created_at: new Date().toISOString(),
234+ response: "final answer",
235+ thinking: "reasoning process here",
236+ done: true,
237+ });
238+ },
239+ });
240+
241+ client = new OllamaClient({
242+ baseUrl: `http://localhost:${mockServer.port}`,
243+ model: "test-model",
244+ options: { thinking: true },
245+ timeout: 8000,
246+ });
247+
248+ const result = await client.generate("test");
249+ expect(result.response).toBe("final answer");
250+ expect(result.thinking).toBe("reasoning process here");
196251 });
197252 });