@copilotkit/aimock 1.22.0 → 1.22.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.
Files changed (178) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +15 -0
  4. package/dist/agui-types.d.cts.map +1 -1
  5. package/dist/agui-types.d.ts.map +1 -1
  6. package/dist/aimock-cli.cjs +0 -0
  7. package/dist/aimock-cli.js +0 -0
  8. package/dist/bedrock-converse.cjs +62 -22
  9. package/dist/bedrock-converse.cjs.map +1 -1
  10. package/dist/bedrock-converse.d.cts.map +1 -1
  11. package/dist/bedrock-converse.d.ts.map +1 -1
  12. package/dist/bedrock-converse.js +62 -22
  13. package/dist/bedrock-converse.js.map +1 -1
  14. package/dist/bedrock.cjs +59 -20
  15. package/dist/bedrock.cjs.map +1 -1
  16. package/dist/bedrock.d.cts.map +1 -1
  17. package/dist/bedrock.d.ts.map +1 -1
  18. package/dist/bedrock.js +59 -20
  19. package/dist/bedrock.js.map +1 -1
  20. package/dist/cli.cjs +1 -1
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/cli.js +1 -1
  23. package/dist/cli.js.map +1 -1
  24. package/dist/cohere.cjs +29 -9
  25. package/dist/cohere.cjs.map +1 -1
  26. package/dist/cohere.d.cts.map +1 -1
  27. package/dist/cohere.d.ts.map +1 -1
  28. package/dist/cohere.js +30 -10
  29. package/dist/cohere.js.map +1 -1
  30. package/dist/config-loader.d.cts.map +1 -1
  31. package/dist/constants.cjs +8 -0
  32. package/dist/constants.cjs.map +1 -0
  33. package/dist/constants.d.cts +8 -0
  34. package/dist/constants.d.cts.map +1 -0
  35. package/dist/constants.d.ts +8 -0
  36. package/dist/constants.d.ts.map +1 -0
  37. package/dist/constants.js +7 -0
  38. package/dist/constants.js.map +1 -0
  39. package/dist/elevenlabs-audio.cjs +41 -18
  40. package/dist/elevenlabs-audio.cjs.map +1 -1
  41. package/dist/elevenlabs-audio.d.cts.map +1 -1
  42. package/dist/elevenlabs-audio.d.ts.map +1 -1
  43. package/dist/elevenlabs-audio.js +42 -19
  44. package/dist/elevenlabs-audio.js.map +1 -1
  45. package/dist/embeddings.cjs +19 -17
  46. package/dist/embeddings.cjs.map +1 -1
  47. package/dist/embeddings.d.cts.map +1 -1
  48. package/dist/embeddings.d.ts.map +1 -1
  49. package/dist/embeddings.js +20 -18
  50. package/dist/embeddings.js.map +1 -1
  51. package/dist/fal-audio.cjs +128 -39
  52. package/dist/fal-audio.cjs.map +1 -1
  53. package/dist/fal-audio.d.cts.map +1 -1
  54. package/dist/fal-audio.d.ts.map +1 -1
  55. package/dist/fal-audio.js +129 -40
  56. package/dist/fal-audio.js.map +1 -1
  57. package/dist/fal.cjs +25 -8
  58. package/dist/fal.cjs.map +1 -1
  59. package/dist/fal.d.cts.map +1 -1
  60. package/dist/fal.d.ts.map +1 -1
  61. package/dist/fal.js +26 -9
  62. package/dist/fal.js.map +1 -1
  63. package/dist/fixture-loader.cjs +9 -1
  64. package/dist/fixture-loader.cjs.map +1 -1
  65. package/dist/fixture-loader.js +9 -1
  66. package/dist/fixture-loader.js.map +1 -1
  67. package/dist/gemini-interactions.cjs +29 -7
  68. package/dist/gemini-interactions.cjs.map +1 -1
  69. package/dist/gemini-interactions.js +28 -8
  70. package/dist/gemini-interactions.js.map +1 -1
  71. package/dist/gemini.cjs +45 -19
  72. package/dist/gemini.cjs.map +1 -1
  73. package/dist/gemini.d.cts.map +1 -1
  74. package/dist/gemini.d.ts.map +1 -1
  75. package/dist/gemini.js +45 -19
  76. package/dist/gemini.js.map +1 -1
  77. package/dist/helpers.cjs +51 -8
  78. package/dist/helpers.cjs.map +1 -1
  79. package/dist/helpers.d.cts +6 -0
  80. package/dist/helpers.d.cts.map +1 -1
  81. package/dist/helpers.d.ts +6 -0
  82. package/dist/helpers.d.ts.map +1 -1
  83. package/dist/helpers.js +51 -9
  84. package/dist/helpers.js.map +1 -1
  85. package/dist/images.cjs +26 -8
  86. package/dist/images.cjs.map +1 -1
  87. package/dist/images.d.cts.map +1 -1
  88. package/dist/images.d.ts.map +1 -1
  89. package/dist/images.js +27 -9
  90. package/dist/images.js.map +1 -1
  91. package/dist/index.cjs +2 -1
  92. package/dist/index.d.cts +2 -1
  93. package/dist/index.d.ts +2 -1
  94. package/dist/index.js +2 -1
  95. package/dist/journal.cjs +17 -7
  96. package/dist/journal.cjs.map +1 -1
  97. package/dist/journal.d.cts +2 -3
  98. package/dist/journal.d.cts.map +1 -1
  99. package/dist/journal.d.ts +2 -3
  100. package/dist/journal.d.ts.map +1 -1
  101. package/dist/journal.js +15 -4
  102. package/dist/journal.js.map +1 -1
  103. package/dist/messages.cjs +33 -12
  104. package/dist/messages.cjs.map +1 -1
  105. package/dist/messages.d.cts.map +1 -1
  106. package/dist/messages.d.ts.map +1 -1
  107. package/dist/messages.js +33 -12
  108. package/dist/messages.js.map +1 -1
  109. package/dist/ollama.cjs +59 -18
  110. package/dist/ollama.cjs.map +1 -1
  111. package/dist/ollama.d.cts.map +1 -1
  112. package/dist/ollama.d.ts.map +1 -1
  113. package/dist/ollama.js +60 -19
  114. package/dist/ollama.js.map +1 -1
  115. package/dist/recorder.cjs +11 -7
  116. package/dist/recorder.cjs.map +1 -1
  117. package/dist/recorder.d.cts.map +1 -1
  118. package/dist/recorder.d.ts.map +1 -1
  119. package/dist/recorder.js +11 -7
  120. package/dist/recorder.js.map +1 -1
  121. package/dist/responses.cjs +61 -52
  122. package/dist/responses.cjs.map +1 -1
  123. package/dist/responses.d.cts +1 -1
  124. package/dist/responses.d.cts.map +1 -1
  125. package/dist/responses.d.ts +1 -1
  126. package/dist/responses.d.ts.map +1 -1
  127. package/dist/responses.js +62 -53
  128. package/dist/responses.js.map +1 -1
  129. package/dist/server.cjs +63 -179
  130. package/dist/server.cjs.map +1 -1
  131. package/dist/server.d.cts.map +1 -1
  132. package/dist/server.d.ts.map +1 -1
  133. package/dist/server.js +39 -155
  134. package/dist/server.js.map +1 -1
  135. package/dist/speech.cjs +26 -8
  136. package/dist/speech.cjs.map +1 -1
  137. package/dist/speech.d.cts.map +1 -1
  138. package/dist/speech.d.ts.map +1 -1
  139. package/dist/speech.js +27 -9
  140. package/dist/speech.js.map +1 -1
  141. package/dist/transcription.cjs +57 -19
  142. package/dist/transcription.cjs.map +1 -1
  143. package/dist/transcription.d.cts.map +1 -1
  144. package/dist/transcription.d.ts.map +1 -1
  145. package/dist/transcription.js +58 -20
  146. package/dist/transcription.js.map +1 -1
  147. package/dist/types.d.cts +2 -0
  148. package/dist/types.d.cts.map +1 -1
  149. package/dist/types.d.ts +2 -0
  150. package/dist/types.d.ts.map +1 -1
  151. package/dist/vector-types.d.ts.map +1 -1
  152. package/dist/video.cjs +50 -14
  153. package/dist/video.cjs.map +1 -1
  154. package/dist/video.d.cts +8 -1
  155. package/dist/video.d.cts.map +1 -1
  156. package/dist/video.d.ts +8 -1
  157. package/dist/video.d.ts.map +1 -1
  158. package/dist/video.js +51 -15
  159. package/dist/video.js.map +1 -1
  160. package/dist/ws-gemini-live.cjs +34 -27
  161. package/dist/ws-gemini-live.cjs.map +1 -1
  162. package/dist/ws-gemini-live.d.cts.map +1 -1
  163. package/dist/ws-gemini-live.d.ts.map +1 -1
  164. package/dist/ws-gemini-live.js +34 -27
  165. package/dist/ws-gemini-live.js.map +1 -1
  166. package/dist/ws-realtime.cjs +251 -12
  167. package/dist/ws-realtime.cjs.map +1 -1
  168. package/dist/ws-realtime.d.cts.map +1 -1
  169. package/dist/ws-realtime.d.ts.map +1 -1
  170. package/dist/ws-realtime.js +251 -12
  171. package/dist/ws-realtime.js.map +1 -1
  172. package/dist/ws-responses.cjs +48 -12
  173. package/dist/ws-responses.cjs.map +1 -1
  174. package/dist/ws-responses.d.cts.map +1 -1
  175. package/dist/ws-responses.d.ts.map +1 -1
  176. package/dist/ws-responses.js +49 -13
  177. package/dist/ws-responses.js.map +1 -1
  178. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, getTestId, isAudioResponse, isContentWithToolCallsResponse, isErrorResponse, isTextResponse, isToolCallResponse, resolveResponse, resolveStrictMode, strictOverrideField } from "./helpers.js";
1
+ import { buildContentWithToolCallsChunks, buildContentWithToolCallsCompletion, buildTextChunks, buildTextCompletion, buildToolCallChunks, buildToolCallCompletion, extractOverrides, flattenHeaders, getTestId, isAudioResponse, isContentWithToolCallsResponse, isErrorResponse, isTextResponse, isToolCallResponse, readBody, resolveResponse, resolveStrictMode, serializeErrorResponse, strictOverrideField } from "./helpers.js";
2
2
  import { Logger } from "./logger.js";
3
3
  import { Journal } from "./journal.js";
4
4
  import { matchFixture } from "./router.js";
@@ -12,7 +12,7 @@ import { handleMessages } from "./messages.js";
12
12
  import { handleGemini } from "./gemini.js";
13
13
  import { handleBedrock, handleBedrockStream } from "./bedrock.js";
14
14
  import { handleConverse, handleConverseStream } from "./bedrock-converse.js";
15
- import { handleGeminiInteractions } from "./gemini-interactions.js";
15
+ import { handleGeminiInteractions, resetEventIdCounter, resetInteractionCounter } from "./gemini-interactions.js";
16
16
  import { handleEmbeddings } from "./embeddings.js";
17
17
  import { handleImages } from "./images.js";
18
18
  import { handleSpeech } from "./speech.js";
@@ -111,21 +111,6 @@ const CORS_HEADERS = {
111
111
  function setCorsHeaders(res) {
112
112
  for (const [key, value] of Object.entries(CORS_HEADERS)) res.setHeader(key, value);
113
113
  }
114
- const DEFAULT_MAX_BODY_BYTES = 10 * 1024 * 1024;
115
- async function readBody(req, maxBytes = DEFAULT_MAX_BODY_BYTES) {
116
- const buffers = [];
117
- let totalBytes = 0;
118
- for await (const chunk of req) {
119
- const buf = chunk;
120
- totalBytes += buf.length;
121
- if (totalBytes > maxBytes) {
122
- req.destroy();
123
- throw new Error(`Request body exceeded size limit of ${maxBytes} bytes`);
124
- }
125
- buffers.push(buf);
126
- }
127
- return Buffer.concat(buffers).toString();
128
- }
129
114
  function handleOptions(res) {
130
115
  setCorsHeaders(res);
131
116
  res.writeHead(204);
@@ -212,6 +197,8 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
212
197
  videoStates.clear();
213
198
  falJobs.clear();
214
199
  falQueueStates.clear();
200
+ resetInteractionCounter();
201
+ resetEventIdCounter();
215
202
  if (defaults.registry) defaults.registry.setGauge("aimock_fixtures_loaded", {}, fixtures.length);
216
203
  res.writeHead(200, { "Content-Type": "application/json" });
217
204
  res.end(JSON.stringify({ reset: true }));
@@ -369,6 +356,29 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
369
356
  return;
370
357
  }
371
358
  if (!fixture) {
359
+ if (resolveStrictMode(defaults.strict, req.headers)) {
360
+ const strictStatus = 503;
361
+ const strictMessage = "Strict mode: no fixture matched";
362
+ defaults.logger.error(`STRICT: No fixture matched for ${req.method ?? "POST"} ${req.url ?? COMPLETIONS_PATH}`);
363
+ journal.add({
364
+ method: req.method ?? "POST",
365
+ path: req.url ?? COMPLETIONS_PATH,
366
+ headers: flattenHeaders(req.headers),
367
+ body,
368
+ response: {
369
+ status: strictStatus,
370
+ fixture: null,
371
+ ...strictOverrideField(defaults.strict, req.headers)
372
+ }
373
+ });
374
+ writeErrorResponse(res, strictStatus, JSON.stringify({ error: {
375
+ message: strictMessage,
376
+ type: "invalid_request_error",
377
+ param: null,
378
+ code: "no_fixture_match"
379
+ } }));
380
+ return;
381
+ }
372
382
  if (defaults.record && providerKey) {
373
383
  const hookOptions = chaosAction === "malformed" ? {
374
384
  beforeWriteResponse: () => {
@@ -386,7 +396,7 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
386
396
  } : void 0;
387
397
  const outcome = await proxyAndRecord(req, res, body, providerKey, req.url ?? COMPLETIONS_PATH, fixtures, defaults, raw, hookOptions);
388
398
  if (outcome === "handled_by_hook") return;
389
- if (outcome === "relayed") {
399
+ if (outcome !== "not_configured") {
390
400
  journal.add({
391
401
  method: req.method ?? "POST",
392
402
  path: req.url ?? COMPLETIONS_PATH,
@@ -401,23 +411,19 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
401
411
  return;
402
412
  }
403
413
  }
404
- const effectiveStrict = resolveStrictMode(defaults.strict, req.headers);
405
- const strictStatus = effectiveStrict ? 503 : 404;
406
- const strictMessage = effectiveStrict ? "Strict mode: no fixture matched" : "No fixture matched";
407
- if (effectiveStrict) defaults.logger.error(`STRICT: No fixture matched for ${req.method ?? "POST"} ${req.url ?? COMPLETIONS_PATH}`);
408
414
  journal.add({
409
415
  method: req.method ?? "POST",
410
416
  path: req.url ?? COMPLETIONS_PATH,
411
417
  headers: flattenHeaders(req.headers),
412
418
  body,
413
419
  response: {
414
- status: strictStatus,
420
+ status: 404,
415
421
  fixture: null,
416
422
  ...strictOverrideField(defaults.strict, req.headers)
417
423
  }
418
424
  });
419
- writeErrorResponse(res, strictStatus, JSON.stringify({ error: {
420
- message: strictMessage,
425
+ writeErrorResponse(res, 404, JSON.stringify({ error: {
426
+ message: "No fixture matched",
421
427
  type: "invalid_request_error",
422
428
  param: null,
423
429
  code: "no_fixture_match"
@@ -439,13 +445,7 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
439
445
  fixture
440
446
  }
441
447
  });
442
- const errorBody = { error: {
443
- message: response.error.message,
444
- type: response.error.type ?? "server_error",
445
- param: null,
446
- code: response.error.code ?? null
447
- } };
448
- writeErrorResponse(res, status, JSON.stringify(errorBody));
448
+ writeErrorResponse(res, status, serializeErrorResponse(response));
449
449
  return;
450
450
  }
451
451
  if (isAudioResponse(response)) {
@@ -534,6 +534,7 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
534
534
  return;
535
535
  }
536
536
  if (isToolCallResponse(response)) {
537
+ if (response.webSearches?.length) defaults.logger.warn("webSearches in fixture response are not supported for Chat Completions API — ignoring");
537
538
  const overrides = extractOverrides(response);
538
539
  const journalEntry = journal.add({
539
540
  method: req.method ?? "POST",
@@ -1130,35 +1131,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
1130
1131
  if (pathname === ELEVENLABS_SOUND_GENERATION_PATH && req.method === "POST") {
1131
1132
  setCorsHeaders(res);
1132
1133
  try {
1133
- const raw = await readBody(req);
1134
- let elSoundFixture = null;
1135
- try {
1136
- const parsed = JSON.parse(raw);
1137
- const syntheticReq = {
1138
- model: parsed.model_id ?? "eleven_text_to_sound_v2",
1139
- messages: [{
1140
- role: "user",
1141
- content: parsed.text ?? ""
1142
- }],
1143
- _endpointType: "audio-gen"
1144
- };
1145
- const testId = getTestId(req);
1146
- elSoundFixture = matchFixture(fixtures, syntheticReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
1147
- } catch {}
1148
- const chaosAction = evaluateChaos(elSoundFixture, defaults.chaos, req.headers, defaults.logger);
1149
- if (chaosAction) {
1150
- applyChaosAction(chaosAction, res, elSoundFixture, journal, {
1151
- method: req.method ?? "POST",
1152
- path: pathname,
1153
- headers: flattenHeaders(req.headers),
1154
- body: {
1155
- model: "",
1156
- messages: []
1157
- }
1158
- }, "fixture", defaults.registry);
1159
- return;
1160
- }
1161
- await handleElevenLabsAudio(req, res, raw, fixtures, defaults, journal, "sound-generation");
1134
+ await handleElevenLabsAudio(req, res, await readBody(req), fixtures, defaults, journal, "sound-generation");
1162
1135
  } catch (err) {
1163
1136
  const msg = err instanceof Error ? err.message : "Internal error";
1164
1137
  if (!res.headersSent) writeErrorResponse(res, 500, JSON.stringify({ error: {
@@ -1174,36 +1147,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
1174
1147
  setCorsHeaders(res);
1175
1148
  const musicSubType = musicMatch[1] ?? "music";
1176
1149
  try {
1177
- const raw = await readBody(req);
1178
- let elMusicFixture = null;
1179
- try {
1180
- const parsed = JSON.parse(raw);
1181
- const prompt = (typeof parsed.prompt === "string" ? parsed.prompt : null) ?? (parsed.composition_plan != null ? typeof parsed.composition_plan === "string" ? parsed.composition_plan : JSON.stringify(parsed.composition_plan) : "");
1182
- const syntheticReq = {
1183
- model: parsed.model_id ?? "music_v1",
1184
- messages: [{
1185
- role: "user",
1186
- content: prompt
1187
- }],
1188
- _endpointType: "audio-gen"
1189
- };
1190
- const testId = getTestId(req);
1191
- elMusicFixture = matchFixture(fixtures, syntheticReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
1192
- } catch {}
1193
- const chaosAction = evaluateChaos(elMusicFixture, defaults.chaos, req.headers, defaults.logger);
1194
- if (chaosAction) {
1195
- applyChaosAction(chaosAction, res, elMusicFixture, journal, {
1196
- method: req.method ?? "POST",
1197
- path: pathname,
1198
- headers: flattenHeaders(req.headers),
1199
- body: {
1200
- model: "",
1201
- messages: []
1202
- }
1203
- }, "fixture", defaults.registry);
1204
- return;
1205
- }
1206
- await handleElevenLabsAudio(req, res, raw, fixtures, defaults, journal, musicSubType);
1150
+ await handleElevenLabsAudio(req, res, await readBody(req), fixtures, defaults, journal, musicSubType);
1207
1151
  } catch (err) {
1208
1152
  const msg = err instanceof Error ? err.message : "Internal error";
1209
1153
  if (!res.headersSent) writeErrorResponse(res, 500, JSON.stringify({ error: {
@@ -1244,40 +1188,10 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
1244
1188
  return;
1245
1189
  }
1246
1190
  }
1247
- const falQueueSubmitMatch = pathname.match(FAL_QUEUE_SUBMIT_RE);
1248
- if (falQueueSubmitMatch && req.method === "POST") {
1191
+ if (pathname.match(FAL_QUEUE_SUBMIT_RE) && req.method === "POST") {
1249
1192
  setCorsHeaders(res);
1250
1193
  try {
1251
- const raw = falBody ?? await readBody(req);
1252
- let falSubmitFixture = null;
1253
- try {
1254
- const parsed = raw.trim() ? JSON.parse(raw) : {};
1255
- const prompt = (typeof parsed.prompt === "string" ? parsed.prompt : null) ?? (typeof parsed.text === "string" ? parsed.text : null) ?? "";
1256
- const syntheticReq = {
1257
- model: falQueueSubmitMatch[1],
1258
- messages: [{
1259
- role: "user",
1260
- content: prompt
1261
- }],
1262
- _endpointType: "fal-audio"
1263
- };
1264
- const testId = getTestId(req);
1265
- falSubmitFixture = matchFixture(fixtures, syntheticReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
1266
- } catch {}
1267
- const chaosAction = evaluateChaos(falSubmitFixture, defaults.chaos, req.headers, defaults.logger);
1268
- if (chaosAction) {
1269
- applyChaosAction(chaosAction, res, falSubmitFixture, journal, {
1270
- method: req.method ?? "POST",
1271
- path: pathname,
1272
- headers: flattenHeaders(req.headers),
1273
- body: {
1274
- model: "",
1275
- messages: []
1276
- }
1277
- }, "fixture", defaults.registry);
1278
- return;
1279
- }
1280
- await handleFalQueue(req, res, raw, pathname, fixtures, defaults, journal);
1194
+ await handleFalQueue(req, res, falBody ?? await readBody(req), pathname, fixtures, defaults, journal);
1281
1195
  } catch (err) {
1282
1196
  const msg = err instanceof Error ? err.message : "Internal error";
1283
1197
  if (!res.headersSent) writeErrorResponse(res, 500, JSON.stringify({ error: {
@@ -1316,40 +1230,10 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
1316
1230
  }
1317
1231
  return;
1318
1232
  }
1319
- const falRunMatch = pathname.match(FAL_RUN_RE);
1320
- if (falRunMatch && req.method === "POST") {
1233
+ if (pathname.match(FAL_RUN_RE) && req.method === "POST") {
1321
1234
  setCorsHeaders(res);
1322
1235
  try {
1323
- const raw = falBody ?? await readBody(req);
1324
- let falRunFixture = null;
1325
- try {
1326
- const parsed = raw.trim() ? JSON.parse(raw) : {};
1327
- const prompt = (typeof parsed.prompt === "string" ? parsed.prompt : null) ?? (typeof parsed.text === "string" ? parsed.text : null) ?? "";
1328
- const syntheticReq = {
1329
- model: falRunMatch[1],
1330
- messages: [{
1331
- role: "user",
1332
- content: prompt
1333
- }],
1334
- _endpointType: "fal-audio"
1335
- };
1336
- const testId = getTestId(req);
1337
- falRunFixture = matchFixture(fixtures, syntheticReq, journal.getFixtureMatchCountsForTest(testId), defaults.requestTransform);
1338
- } catch {}
1339
- const chaosAction = evaluateChaos(falRunFixture, defaults.chaos, req.headers, defaults.logger);
1340
- if (chaosAction) {
1341
- applyChaosAction(chaosAction, res, falRunFixture, journal, {
1342
- method: req.method ?? "POST",
1343
- path: pathname,
1344
- headers: flattenHeaders(req.headers),
1345
- body: {
1346
- model: "",
1347
- messages: []
1348
- }
1349
- }, "fixture", defaults.registry);
1350
- return;
1351
- }
1352
- await handleFalQueue(req, res, raw, pathname, fixtures, defaults, journal);
1236
+ await handleFalQueue(req, res, falBody ?? await readBody(req), pathname, fixtures, defaults, journal);
1353
1237
  } catch (err) {
1354
1238
  const msg = err instanceof Error ? err.message : "Internal error";
1355
1239
  if (!res.headersSent) writeErrorResponse(res, 500, JSON.stringify({ error: {