@cogitator-ai/test-utils 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,7 @@ export class MockLLMBackend {
58
58
  this.streamIndex = 0;
59
59
  }
60
60
  async chat(request) {
61
- this._calls.push(request);
61
+ this._calls.push(snapshot(request));
62
62
  const mockResponse = this.responses[this.responseIndex] ?? this.responses[0];
63
63
  if (this.responseIndex < this.responses.length - 1) {
64
64
  this.responseIndex++;
@@ -90,7 +90,7 @@ export class MockLLMBackend {
90
90
  };
91
91
  }
92
92
  async *chatStream(request) {
93
- this._calls.push(request);
93
+ this._calls.push(snapshot(request));
94
94
  const chunks = this.streamChunks[this.streamIndex] ?? this.streamChunks[0] ?? [];
95
95
  if (this.streamIndex < this.streamChunks.length - 1) {
96
96
  this.streamIndex++;
@@ -147,3 +147,15 @@ export class MockLLMBackend {
147
147
  export function createMockLLMBackend() {
148
148
  return new MockLLMBackend();
149
149
  }
150
+ /**
151
+ * The request as it was sent: callers keep appending to the same messages
152
+ * array, so a recorded call would otherwise show the final conversation.
153
+ */
154
+ function snapshot(request) {
155
+ return {
156
+ ...request,
157
+ messages: [...request.messages],
158
+ ...(request.tools && { tools: [...request.tools] }),
159
+ ...(request.stop && { stop: [...request.stop] }),
160
+ };
161
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogitator-ai/test-utils",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Shared testing utilities for Cogitator packages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "node": ">=22.12.0"
19
19
  },
20
20
  "dependencies": {
21
- "@cogitator-ai/types": "0.28.0",
21
+ "@cogitator-ai/types": "0.30.0",
22
22
  "nanoid": "^6.0.1"
23
23
  },
24
24
  "devDependencies": {