@copilotkit/aimock 1.36.1 → 1.37.1
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.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/dist/agui-recorder.cjs +62 -0
- package/dist/agui-recorder.cjs.map +1 -1
- package/dist/agui-recorder.d.cts +23 -1
- package/dist/agui-recorder.d.cts.map +1 -1
- package/dist/agui-recorder.d.ts +23 -1
- package/dist/agui-recorder.d.ts.map +1 -1
- package/dist/agui-recorder.js +60 -1
- package/dist/agui-recorder.js.map +1 -1
- package/dist/agui-types.d.cts +13 -0
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/agui-types.d.ts +13 -0
- package/dist/agui-types.d.ts.map +1 -1
- package/dist/fixture-loader.cjs +0 -0
- package/dist/fixture-loader.cjs.map +1 -1
- package/dist/fixture-loader.d.cts.map +1 -1
- package/dist/fixture-loader.d.ts.map +1 -1
- package/dist/fixture-loader.js +0 -0
- package/dist/fixture-loader.js.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/recorder.cjs +12 -4
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +12 -4
- package/dist/recorder.js.map +1 -1
- package/dist/router.cjs +59 -25
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +20 -0
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts +20 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +59 -25
- package/dist/router.js.map +1 -1
- package/dist/stream-collapse.cjs +120 -27
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +31 -8
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +31 -8
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +119 -28
- package/dist/stream-collapse.js.map +1 -1
- package/dist/types.d.cts +13 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ws-gemini-live.d.ts +2 -2
- package/dist/ws-realtime.d.ts +2 -2
- package/package.json +2 -2
- package/skills/write-fixtures/SKILL.md +40 -31
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;UAQiB,SAAA;qBAER,MAAA,CAAK,sBACL,MAAA,CAAK,mCAET;EALY,aAAS,EAAA,MAAA,EAMD,GAAA,CAAI,MANH,EAAA,IAAA,EAMiB,MANjB,EAAA,QAAA,EAAA,MAAA,CAAA,EAM4C,OAN5C,CAAA,OAAA,CAAA;EAAA,MAAA,GAAA,EAAA;IAEjB,MAAK,EAAA,MAAA;IACL,CAAA,GAAA,EAAK,MAAA,CAAA,EAAA,OAAA;;YAGe,EAAA,OAAA,EAEN,OAFM,CAAA,EAAA,IAAA;YAAc,EAAA,GAAA,EAAA,MAAA,CAAA,EAAA,IAAA;aAA2B,EAAA,QAAA,EAI7C,eAJ6C,CAAA,EAAA,IAAA;;AAI7C,UAGR,WAAA,CAHQ;EAAe,IAAA,EAAA,MAAA;EAGvB,IAAA,CAAA,EAAA,MAAA;EAMA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAW,OAAA;;AAER,UAFH,WAAA,CAEG;MAEL,EAAA,QAAA,GAAA,MAAA,GAAA,WAAA,GAAA,MAAA;EAAe,OAAA,EAAA,MAAA,GAFV,WAEU,EAAA,GAAA,IAAA;EAIb,IAAA,CAAA,EAAA,MAAA;EAMA,UAAA,CAAA,EAVF,eAUuB,EAAA;EAAA,YAAA,CAAA,EAAA,MAAA;;AAO5B,UAbO,eAAA,CAaP;EAAc,EAAA,EAAA,MAAA;EAoBP,IAAA,EAAA,UAAA;EAOA,QAAA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qBAKS;oBACD;;UAEV;;;;;;UASO,YAAA;;;;;WAKN;QACH;;;;aAIK;;;;;;;;;;;;;;;;kBAgBK;;;;;UAQD,QAAA;;;;;WAKN;;;;;;;;UAKM,SAAA;;SAER;;;;UAKQ,QAAA;;;;eAIF;;UAGE,gBAAA;;;;;;;;;UASA,cAAA;;;;;WAKN;;;;;;;;UAKM,oBAAA;;WAEN;;;;UAKM,qBAAA;;;;;eAKF;;KAKH,iBAAA;UAgBK,YAAA;aACJ,QAAQ,OAAO;;;;;;;;;;;;;iBAaX,QAAQ,OAAO;;;;;;;;;;;;;;;;QAgBxB;;;;;;oBAMY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuDH,2BAAA;;;;;;;;;;;;;;;;UAiBA,eAAA;;;;;;UAOA,iBAAA;;;;;;;;UAQP;;;;;;WAMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAkCgB,0BAA0B;;;;;;;;;;;aAWxC;;;;;;;;oBAQO;;;;;;;;aAQP;;;;;;;cAOC;;;;;;;UAQG,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;UA6BA,eAAA;;;;UAIP;UACA;aACG;WACF;;2BAEgB,0BAA0B;aACxC;oBACO;aACP;cACC"}
|
package/dist/ws-gemini-live.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Journal } from "./journal.js";
|
|
|
2
2
|
import { Logger } from "./logger.js";
|
|
3
3
|
import { ChatCompletionRequest, Fixture } from "./types.js";
|
|
4
4
|
import { WebSocketConnection } from "./ws-framing.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as node_http0 from "node:http";
|
|
6
6
|
|
|
7
7
|
//#region src/ws-gemini-live.d.ts
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ declare function handleWebSocketGeminiLive(ws: WebSocketConnection, fixtures: Fi
|
|
|
15
15
|
strict?: boolean;
|
|
16
16
|
requestTransform?: (req: ChatCompletionRequest) => ChatCompletionRequest;
|
|
17
17
|
testId?: string;
|
|
18
|
-
upgradeHeaders?:
|
|
18
|
+
upgradeHeaders?: node_http0.IncomingHttpHeaders;
|
|
19
19
|
}): void;
|
|
20
20
|
//# sourceMappingURL=ws-gemini-live.d.ts.map
|
|
21
21
|
//#endregion
|
package/dist/ws-realtime.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Journal } from "./journal.js";
|
|
|
2
2
|
import { Logger } from "./logger.js";
|
|
3
3
|
import { ChatCompletionRequest, Fixture } from "./types.js";
|
|
4
4
|
import { WebSocketConnection } from "./ws-framing.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as node_http1 from "node:http";
|
|
6
6
|
|
|
7
7
|
//#region src/ws-realtime.d.ts
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ declare function handleWebSocketRealtime(ws: WebSocketConnection, fixtures: Fixt
|
|
|
15
15
|
strict?: boolean;
|
|
16
16
|
requestTransform?: (req: ChatCompletionRequest) => ChatCompletionRequest;
|
|
17
17
|
testId?: string;
|
|
18
|
-
upgradeHeaders?:
|
|
18
|
+
upgradeHeaders?: node_http1.IncomingHttpHeaders;
|
|
19
19
|
}): void;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { handleWebSocketRealtime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/aimock",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.1",
|
|
4
4
|
"description": "Mock infrastructure for AI application testing — LLM APIs, image generation, image editing, text-to-speech, transcription, audio translation, audio generation, video generation, embeddings, MCP tools, A2A agents, AG-UI event streams, vector databases, search, rerank, and moderation. One package, one port, zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"test:exports": "publint && attw --pack .",
|
|
170
170
|
"lint": "eslint .",
|
|
171
171
|
"format:check": "prettier --check .",
|
|
172
|
-
"release": "pnpm build && pnpm test && pnpm lint && npm publish",
|
|
172
|
+
"release": "pnpm format:check && pnpm build && pnpm test && pnpm lint && pnpm test:exports && npm publish",
|
|
173
173
|
"prepare": "husky || true"
|
|
174
174
|
},
|
|
175
175
|
"lint-staged": {
|
|
@@ -19,25 +19,26 @@ aimock is a zero-dependency mock infrastructure for AI apps. Fixture-driven. Mul
|
|
|
19
19
|
|
|
20
20
|
## Match Field Reference
|
|
21
21
|
|
|
22
|
-
| Field
|
|
23
|
-
|
|
|
24
|
-
| `userMessage`
|
|
25
|
-
| `userMessage`
|
|
26
|
-
| `systemMessage`
|
|
27
|
-
| `systemMessage`
|
|
28
|
-
| `systemMessage`
|
|
29
|
-
| `inputText`
|
|
30
|
-
| `inputText`
|
|
31
|
-
| `toolName`
|
|
32
|
-
| `toolCallId`
|
|
33
|
-
| `
|
|
34
|
-
| `model`
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
22
|
+
| Field | Type | Matches Against |
|
|
23
|
+
| -------------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| `userMessage` | `string` | Substring of last `role: "user"` message text |
|
|
25
|
+
| `userMessage` | `RegExp` | Pattern test on last `role: "user"` message text |
|
|
26
|
+
| `systemMessage` | `string` | Substring of the concatenated text of every `role: "system"` message in the request. Use to gate a fixture on host-supplied context (persona, agent-context entries) so changes to that context cause the fixture to fall through instead of returning a stale baked response |
|
|
27
|
+
| `systemMessage` | `string[]` | Array of substrings — ALL must be present in the joined system text (AND semantics). Use when the gate must combine multiple non-adjacent tokens whose serialisation order isn't stable |
|
|
28
|
+
| `systemMessage` | `RegExp` | Pattern test on the concatenated system-message text |
|
|
29
|
+
| `inputText` | `string` | Substring of embedding input text (concatenated if multiple inputs) |
|
|
30
|
+
| `inputText` | `RegExp` | Pattern test on embedding input text |
|
|
31
|
+
| `toolName` | `string` | Exact match on any tool in request's `tools[]` array (by `function.name`) |
|
|
32
|
+
| `toolCallId` | `string` | Exact match on `tool_call_id` of last `role: "tool"` message |
|
|
33
|
+
| `toolResultContains` | `string` | Substring of the last tool message's text content, gated on that message being the request's LAST message (same rule as `toolCallId`). Discriminates resume paths that share a `tool_call_id` and differ only inside the tool-result payload (e.g. approve `{"chosen_time": …}` vs cancel `{"cancelled": true}`) |
|
|
34
|
+
| `model` | `string` | Exact match on `req.model` |
|
|
35
|
+
| `model` | `RegExp` | Pattern test on `req.model` |
|
|
36
|
+
| `responseFormat` | `string` | Exact match on `req.response_format.type` (`"json_object"`, `"json_schema"`) |
|
|
37
|
+
| `sequenceIndex` | `number` | Matches only when this fixture's match count equals the given index (0-based) |
|
|
38
|
+
| `turnIndex` | `number` | Stateless conversation-depth matching. Counts `role: "assistant"` messages in the request; matches when that count equals the value. `turnIndex: 0` = first turn (no prior assistant messages). Use instead of `sequenceIndex` for shared/deployed instances where stateful counters break under concurrency |
|
|
39
|
+
| `hasToolResult` | `boolean` | Stateless tool-message presence matching. `true` matches when any `role: "tool"` message exists in the request; `false` matches when none exist. Provider-consistent across all aimock handlers (OpenAI, Claude, Gemini, Bedrock, Ollama, Cohere) |
|
|
40
|
+
| `endpoint` | `string` | Restrict to endpoint type: `"chat"`, `"image"`, `"speech"`, `"transcription"`, `"video"`, `"embedding"` |
|
|
41
|
+
| `predicate` | `(req: ChatCompletionRequest) => boolean` | Custom function — full access to request |
|
|
41
42
|
|
|
42
43
|
**AND logic**: all specified fields must match. Empty match `{}` = catch-all.
|
|
43
44
|
|
|
@@ -45,14 +46,15 @@ Multi-part content (e.g., `[{type: "text", text: "hello"}]`) is automatically ex
|
|
|
45
46
|
|
|
46
47
|
### When to Use Each Multi-turn Matching Approach
|
|
47
48
|
|
|
48
|
-
| Approach
|
|
49
|
-
|
|
|
50
|
-
| `turnIndex`
|
|
51
|
-
| `hasToolResult`
|
|
52
|
-
| `sequenceIndex`
|
|
53
|
-
| `toolCallId`
|
|
49
|
+
| Approach | Stateless? | Best For |
|
|
50
|
+
| -------------------- | ---------- | --------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `turnIndex` | Yes | Shared/deployed instances; matches on conversation depth (count of assistant messages in request) |
|
|
52
|
+
| `hasToolResult` | Yes | Simplest option for 2-step tool flows — boolean: are there tool results in the request? |
|
|
53
|
+
| `sequenceIndex` | No | Single-client unit tests with repeated identical requests (server-side counter, breaks under concurrency) |
|
|
54
|
+
| `toolCallId` | Yes | Matching specific tool result IDs in the conversation history |
|
|
55
|
+
| `toolResultContains` | Yes | Same tool call id, different outcomes — match on the tool-result payload (approve vs cancel legs) |
|
|
54
56
|
|
|
55
|
-
**Prefer stateless approaches** (`turnIndex`, `hasToolResult`) for shared aimock instances (deployed via Docker, used by multiple test runners). Use `sequenceIndex` only in isolated single-client unit tests where the counter won't be corrupted by concurrent requests.
|
|
57
|
+
**Prefer stateless approaches** (`turnIndex`, `hasToolResult`, `toolResultContains`) for shared aimock instances (deployed via Docker, used by multiple test runners). Use `sequenceIndex` only in isolated single-client unit tests where the counter won't be corrupted by concurrent requests.
|
|
56
58
|
|
|
57
59
|
### Multi-turn fixture examples
|
|
58
60
|
|
|
@@ -64,6 +66,11 @@ Multi-part content (e.g., `[{type: "text", text: "hello"}]`) is automatically ex
|
|
|
64
66
|
// Same thing with hasToolResult (simpler for 2-step)
|
|
65
67
|
{"match": {"userMessage": "trip to mars", "hasToolResult": false}, "response": {"toolCalls": [{"id": "call_001", "name": "generate_steps", "arguments": "{}"}]}}
|
|
66
68
|
{"match": {"userMessage": "trip to mars", "hasToolResult": true}, "response": {"content": "Great choices!"}}
|
|
69
|
+
|
|
70
|
+
// HITL suspend tool where approve and cancel resume with the SAME tool call id —
|
|
71
|
+
// discriminate on the tool-result payload; put the cancel leg first (first match wins)
|
|
72
|
+
{"match": {"toolCallId": "call_001", "toolResultContains": "\"cancelled\""}, "response": {"content": "No problem — nothing was booked."}}
|
|
73
|
+
{"match": {"toolCallId": "call_001"}, "response": {"content": "Booked: Monday 9:00 AM confirmed."}}
|
|
67
74
|
```
|
|
68
75
|
|
|
69
76
|
## Response Types
|
|
@@ -255,7 +262,7 @@ mock.on(
|
|
|
255
262
|
mock.on({ userMessage: "status", sequenceIndex: 1 }, { content: "All systems operational." });
|
|
256
263
|
```
|
|
257
264
|
|
|
258
|
-
Match counts are tracked per fixture group
|
|
265
|
+
Match counts are tracked per fixture group. Use `resetMatchCounts()` between tests to reset counts while keeping loaded fixtures. `reset()` also clears the fixture pool, so avoid it between tests that share a loaded fixture set.
|
|
259
266
|
|
|
260
267
|
### Streaming physics (realistic timing)
|
|
261
268
|
|
|
@@ -500,7 +507,7 @@ These fields map correctly across all provider formats — for example, `finishR
|
|
|
500
507
|
|
|
501
508
|
10. **Embeddings auto-generate if no fixture matches** — deterministic vectors are generated from the input text hash. You don't need a catch-all for embedding requests.
|
|
502
509
|
|
|
503
|
-
11. **Sequential response counts are tracked per fixture** —
|
|
510
|
+
11. **Sequential response counts are tracked per fixture** — use `resetMatchCounts()` between tests to reset counts while keeping loaded fixtures; `reset()` also clears the fixture pool, so don't use it between tests that share a loaded fixture set. The count increments after each match of that fixture group (all fixtures sharing the same non-`sequenceIndex` match fields).
|
|
504
511
|
|
|
505
512
|
12. **Bedrock uses Anthropic Messages format internally** — the adapter normalizes Bedrock requests to `ChatCompletionRequest`, so the same fixtures work. Bedrock supports both non-streaming (`/invoke`, `/converse`) and streaming (`/invoke-with-response-stream`, `/converse-stream`) endpoints.
|
|
506
513
|
|
|
@@ -549,7 +556,7 @@ await suite.start();
|
|
|
549
556
|
// suite.llm — the LLMock instance
|
|
550
557
|
// suite.url — base URL
|
|
551
558
|
|
|
552
|
-
afterEach(() => suite.
|
|
559
|
+
afterEach(() => suite.llm.resetMatchCounts()); // reset sequence counts, keep fixtures
|
|
553
560
|
afterAll(() => suite.stop());
|
|
554
561
|
```
|
|
555
562
|
|
|
@@ -684,8 +691,8 @@ mock.loadFixtureDir("./fixtures");
|
|
|
684
691
|
await mock.start();
|
|
685
692
|
process.env.OPENAI_BASE_URL = `${mock.url}/v1`;
|
|
686
693
|
|
|
687
|
-
// Per-test cleanup
|
|
688
|
-
afterEach(() => mock.
|
|
694
|
+
// Per-test cleanup — reset sequence match counts, keep the loaded fixtures
|
|
695
|
+
afterEach(() => mock.resetMatchCounts());
|
|
689
696
|
|
|
690
697
|
// Teardown
|
|
691
698
|
afterAll(async () => await mock.stop());
|
|
@@ -736,6 +743,8 @@ const mock = await LLMock.create({ port: 0 }); // creates + starts in one call
|
|
|
736
743
|
| `url` / `baseUrl` | Server URL (throws if not started) |
|
|
737
744
|
| `port` | Server port number |
|
|
738
745
|
|
|
746
|
+
Between tests that share a loaded fixture set, use `resetMatchCounts()` (not `reset()`, which also clears fixtures). For a `MockSuite`, call `suite.llm.resetMatchCounts()` — the suite itself has no `resetMatchCounts()`.
|
|
747
|
+
|
|
739
748
|
Sequential responses use `on()` with `sequenceIndex` in the match — there is no dedicated convenience method.
|
|
740
749
|
|
|
741
750
|
## Record-and-Replay (VCR Mode)
|