@copilotkit/aimock 1.38.0 → 1.39.0

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 (58) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +23 -2
  4. package/dist/agui-handler.cjs +20 -18
  5. package/dist/agui-handler.cjs.map +1 -1
  6. package/dist/agui-handler.d.cts +8 -1
  7. package/dist/agui-handler.d.cts.map +1 -1
  8. package/dist/agui-handler.d.ts +8 -1
  9. package/dist/agui-handler.d.ts.map +1 -1
  10. package/dist/agui-handler.js +20 -18
  11. package/dist/agui-handler.js.map +1 -1
  12. package/dist/agui-stub.d.cts +2 -2
  13. package/dist/agui-stub.d.ts +2 -2
  14. package/dist/agui-types.d.cts +19 -1
  15. package/dist/agui-types.d.cts.map +1 -1
  16. package/dist/agui-types.d.ts +19 -1
  17. package/dist/agui-types.d.ts.map +1 -1
  18. package/dist/aimock-cli.cjs +1 -1
  19. package/dist/aimock-cli.cjs.map +1 -1
  20. package/dist/aimock-cli.js +1 -1
  21. package/dist/aimock-cli.js.map +1 -1
  22. package/dist/cli.cjs +10 -10
  23. package/dist/cli.cjs.map +1 -1
  24. package/dist/cli.js +10 -10
  25. package/dist/cli.js.map +1 -1
  26. package/dist/config-loader.d.ts.map +1 -1
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/llmock.cjs +23 -9
  30. package/dist/llmock.cjs.map +1 -1
  31. package/dist/llmock.d.cts +22 -0
  32. package/dist/llmock.d.cts.map +1 -1
  33. package/dist/llmock.d.ts +22 -0
  34. package/dist/llmock.d.ts.map +1 -1
  35. package/dist/llmock.js +25 -11
  36. package/dist/llmock.js.map +1 -1
  37. package/dist/openrouter-video.cjs.map +1 -1
  38. package/dist/openrouter-video.js.map +1 -1
  39. package/dist/server.cjs +34 -17
  40. package/dist/server.cjs.map +1 -1
  41. package/dist/server.d.cts +6 -1
  42. package/dist/server.d.cts.map +1 -1
  43. package/dist/server.d.ts +6 -1
  44. package/dist/server.d.ts.map +1 -1
  45. package/dist/server.js +34 -18
  46. package/dist/server.js.map +1 -1
  47. package/dist/stream-collapse.cjs +77 -0
  48. package/dist/stream-collapse.cjs.map +1 -1
  49. package/dist/stream-collapse.d.cts.map +1 -1
  50. package/dist/stream-collapse.d.ts.map +1 -1
  51. package/dist/stream-collapse.js +77 -0
  52. package/dist/stream-collapse.js.map +1 -1
  53. package/dist/vector-types.d.ts.map +1 -1
  54. package/dist/ws-gemini-live.cjs +41 -6
  55. package/dist/ws-gemini-live.cjs.map +1 -1
  56. package/dist/ws-gemini-live.js +41 -6
  57. package/dist/ws-gemini-live.js.map +1 -1
  58. package/package.json +3 -2
package/dist/server.cjs CHANGED
@@ -145,23 +145,31 @@ function handleNotFound(res, message) {
145
145
  }
146
146
  const CONTROL_PREFIX = "/__aimock";
147
147
  /**
148
- * Perform a full fixtures reset: clear the fixtures array, journal, video/fal
149
- * generation state, and the interaction/event-id counters, then zero the
150
- * `aimock_fixtures_loaded` gauge. Shared by `/reset/fixtures` and the
151
- * deprecated `/reset` alias.
148
+ * Perform a full reset: clear the fixtures array, the journal (entries *and*
149
+ * per-test fixture match-counts, i.e. sequence position), the video and fal.ai
150
+ * job/queue state, and the Gemini interaction/event-id counters, then re-zero
151
+ * the `aimock_fixtures_loaded` gauge.
152
+ *
153
+ * `targets` is `null` when no server is running (an in-process `reset()` before
154
+ * `start()`). The process-global generation state is reset either way, since it
155
+ * is not owned by any one server instance.
156
+ *
157
+ * Shared by `POST /__aimock/reset` (canonical), its deprecated
158
+ * `POST /__aimock/reset/fixtures` alias, and `LLMock.reset()`.
152
159
  */
153
- function performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults) {
160
+ function performFullReset(fixtures, targets) {
154
161
  fixtures.length = 0;
155
- journal.clear();
156
- videoStates.clear();
157
- openRouterVideoJobs.clear();
158
- veoVideoJobs.clear();
159
- grokVideoJobs.clear();
160
162
  require_fal_audio.falJobs.clear();
161
163
  require_fal.falQueueStates.clear();
162
164
  require_gemini_interactions.resetInteractionCounter();
163
165
  require_gemini_interactions.resetEventIdCounter();
164
- if (defaults.registry) defaults.registry.setGauge("aimock_fixtures_loaded", {}, fixtures.length);
166
+ if (!targets) return;
167
+ targets.journal.clear();
168
+ targets.videoStates.clear();
169
+ targets.openRouterVideoJobs.clear();
170
+ targets.veoVideoJobs.clear();
171
+ targets.grokVideoJobs.clear();
172
+ if (targets.defaults.registry) targets.defaults.registry.setGauge("aimock_fixtures_loaded", {}, fixtures.length);
165
173
  }
166
174
  /**
167
175
  * Handle requests under `/__aimock/`. Returns `true` if the request was
@@ -230,8 +238,16 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
230
238
  res.end(JSON.stringify({ cleared: true }));
231
239
  return true;
232
240
  }
233
- if (subPath === "/reset/fixtures" && req.method === "POST") {
234
- performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults);
241
+ const resetTargets = () => ({
242
+ journal,
243
+ videoStates,
244
+ openRouterVideoJobs,
245
+ veoVideoJobs,
246
+ grokVideoJobs,
247
+ defaults
248
+ });
249
+ if (subPath === "/reset" && req.method === "POST") {
250
+ performFullReset(fixtures, resetTargets());
235
251
  res.writeHead(200, { "Content-Type": "application/json" });
236
252
  res.end(JSON.stringify({ reset: true }));
237
253
  return true;
@@ -242,10 +258,10 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
242
258
  res.end(JSON.stringify({ reset: true }));
243
259
  return true;
244
260
  }
245
- if (subPath === "/reset" && req.method === "POST") {
246
- performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults);
247
- const deprecation = "POST /__aimock/reset is deprecated; use POST /__aimock/reset/fixtures (full reset) or POST /__aimock/reset/journal (journal only)";
248
- defaults.logger.warn("POST /__aimock/reset is deprecated; use /__aimock/reset/fixtures or /__aimock/reset/journal");
261
+ if (subPath === "/reset/fixtures" && req.method === "POST") {
262
+ performFullReset(fixtures, resetTargets());
263
+ const deprecation = "POST /__aimock/reset/fixtures is deprecated; use POST /__aimock/reset (full reset) or POST /__aimock/reset/journal (journal only)";
264
+ defaults.logger.warn("POST /__aimock/reset/fixtures is deprecated; use /__aimock/reset or /__aimock/reset/journal");
249
265
  res.writeHead(200, {
250
266
  "Content-Type": "application/json",
251
267
  Deprecation: "true"
@@ -1940,4 +1956,5 @@ async function createServerWithResolvedAuth(fixtures, options, resolvedAuth, mou
1940
1956
  //#endregion
1941
1957
  exports.createServer = createServer;
1942
1958
  exports.createServerWithResolvedAuth = createServerWithResolvedAuth;
1959
+ exports.performFullReset = performFullReset;
1943
1960
  //# sourceMappingURL=server.cjs.map