@copilotkit/aimock 1.30.0 → 1.32.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/dist/agui-types.d.ts.map +1 -1
- package/dist/cli.cjs +18 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +18 -1
- package/dist/cli.js.map +1 -1
- package/dist/fal-audio.cjs +12 -6
- package/dist/fal-audio.cjs.map +1 -1
- package/dist/fal-audio.d.cts.map +1 -1
- package/dist/fal-audio.d.ts.map +1 -1
- package/dist/fal-audio.js +14 -8
- package/dist/fal-audio.js.map +1 -1
- package/dist/fal.cjs +100 -54
- package/dist/fal.cjs.map +1 -1
- package/dist/fal.d.cts +13 -0
- package/dist/fal.d.cts.map +1 -1
- package/dist/fal.d.ts +13 -0
- package/dist/fal.d.ts.map +1 -1
- package/dist/fal.js +101 -55
- package/dist/fal.js.map +1 -1
- package/dist/index.cjs +10 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -3
- package/dist/llmock.cjs +8 -3
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts +5 -5
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts +5 -5
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +8 -3
- package/dist/llmock.js.map +1 -1
- package/dist/metrics.cjs +9 -0
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +7 -1
- package/dist/metrics.js.map +1 -1
- package/dist/openrouter-video.cjs +1609 -0
- package/dist/openrouter-video.cjs.map +1 -0
- package/dist/openrouter-video.d.cts +154 -0
- package/dist/openrouter-video.d.cts.map +1 -0
- package/dist/openrouter-video.d.ts +154 -0
- package/dist/openrouter-video.d.ts.map +1 -0
- package/dist/openrouter-video.js +1601 -0
- package/dist/openrouter-video.js.map +1 -0
- package/dist/recorder.cjs +48 -7
- 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 +46 -8
- package/dist/recorder.js.map +1 -1
- package/dist/server.cjs +158 -10
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +2 -0
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +159 -11
- package/dist/server.js.map +1 -1
- package/dist/types.d.cts +100 -9
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +100 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-types.d.cts.map +1 -1
- package/package.json +2 -2
package/dist/server.cjs
CHANGED
|
@@ -20,9 +20,10 @@ const require_transcription = require('./transcription.cjs');
|
|
|
20
20
|
const require_images = require('./images.cjs');
|
|
21
21
|
const require_speech = require('./speech.cjs');
|
|
22
22
|
const require_video = require('./video.cjs');
|
|
23
|
-
const require_elevenlabs_audio = require('./elevenlabs-audio.cjs');
|
|
24
|
-
const require_fal = require('./fal.cjs');
|
|
25
23
|
const require_fal_audio = require('./fal-audio.cjs');
|
|
24
|
+
const require_fal = require('./fal.cjs');
|
|
25
|
+
const require_openrouter_video = require('./openrouter-video.cjs');
|
|
26
|
+
const require_elevenlabs_audio = require('./elevenlabs-audio.cjs');
|
|
26
27
|
const require_ollama = require('./ollama.cjs');
|
|
27
28
|
const require_cohere = require('./cohere.cjs');
|
|
28
29
|
const require_search = require('./search.cjs');
|
|
@@ -55,7 +56,6 @@ const SPEECH_PATH = "/v1/audio/speech";
|
|
|
55
56
|
const TRANSCRIPTIONS_PATH = "/v1/audio/transcriptions";
|
|
56
57
|
const TRANSLATIONS_PATH = "/v1/audio/translations";
|
|
57
58
|
const VIDEOS_PATH = "/v1/videos";
|
|
58
|
-
const VIDEOS_STATUS_RE = /^\/v1\/videos\/([^/]+)$/;
|
|
59
59
|
const GEMINI_PREDICT_RE = /^\/v1beta\/models\/([^:]+):predict$/;
|
|
60
60
|
const ELEVENLABS_SOUND_GENERATION_PATH = "/v1/sound-generation";
|
|
61
61
|
const ELEVENLABS_TTS_RE = /^\/v1\/text-to-speech\/([^/]+)$/;
|
|
@@ -106,6 +106,8 @@ const OLLAMA_GENERATE_PATH = "/api/generate";
|
|
|
106
106
|
const OLLAMA_EMBEDDINGS_PATH = "/api/embeddings";
|
|
107
107
|
const OLLAMA_EMBED_PATH = "/api/embed";
|
|
108
108
|
const OLLAMA_TAGS_PATH = "/api/tags";
|
|
109
|
+
const OPENROUTER_VIDEOS_PATH = "/api/v1/videos";
|
|
110
|
+
const OPENROUTER_VIDEO_MODELS_PATH = "/api/v1/videos/models";
|
|
109
111
|
const HEALTH_PATH = "/health";
|
|
110
112
|
const READY_PATH = "/ready";
|
|
111
113
|
const MODELS_PATH = "/v1/models";
|
|
@@ -144,10 +146,11 @@ const CONTROL_PREFIX = "/__aimock";
|
|
|
144
146
|
* `aimock_fixtures_loaded` gauge. Shared by `/reset/fixtures` and the
|
|
145
147
|
* deprecated `/reset` alias.
|
|
146
148
|
*/
|
|
147
|
-
function performFixturesReset(fixtures, journal, videoStates, defaults) {
|
|
149
|
+
function performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults) {
|
|
148
150
|
fixtures.length = 0;
|
|
149
151
|
journal.clear();
|
|
150
152
|
videoStates.clear();
|
|
153
|
+
openRouterVideoJobs.clear();
|
|
151
154
|
require_fal_audio.falJobs.clear();
|
|
152
155
|
require_fal.falQueueStates.clear();
|
|
153
156
|
require_gemini_interactions.resetInteractionCounter();
|
|
@@ -158,7 +161,7 @@ function performFixturesReset(fixtures, journal, videoStates, defaults) {
|
|
|
158
161
|
* Handle requests under `/__aimock/`. Returns `true` if the request was
|
|
159
162
|
* handled, `false` if the path doesn't match the control prefix.
|
|
160
163
|
*/
|
|
161
|
-
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, defaults) {
|
|
164
|
+
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults) {
|
|
162
165
|
if (!pathname.startsWith(CONTROL_PREFIX)) return false;
|
|
163
166
|
const subPath = pathname.slice(9);
|
|
164
167
|
setCorsHeaders(res);
|
|
@@ -222,7 +225,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
222
225
|
return true;
|
|
223
226
|
}
|
|
224
227
|
if (subPath === "/reset/fixtures" && req.method === "POST") {
|
|
225
|
-
performFixturesReset(fixtures, journal, videoStates, defaults);
|
|
228
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
226
229
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
227
230
|
res.end(JSON.stringify({ reset: true }));
|
|
228
231
|
return true;
|
|
@@ -234,7 +237,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
234
237
|
return true;
|
|
235
238
|
}
|
|
236
239
|
if (subPath === "/reset" && req.method === "POST") {
|
|
237
|
-
performFixturesReset(fixtures, journal, videoStates, defaults);
|
|
240
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
238
241
|
const deprecation = "POST /__aimock/reset is deprecated; use POST /__aimock/reset/fixtures (full reset) or POST /__aimock/reset/journal (journal only)";
|
|
239
242
|
defaults.logger.warn("POST /__aimock/reset is deprecated; use /__aimock/reset/fixtures or /__aimock/reset/journal");
|
|
240
243
|
res.writeHead(200, {
|
|
@@ -698,6 +701,9 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
698
701
|
},
|
|
699
702
|
get falQueue() {
|
|
700
703
|
return serverOptions.falQueue;
|
|
704
|
+
},
|
|
705
|
+
get openRouterVideo() {
|
|
706
|
+
return serverOptions.openRouterVideo;
|
|
701
707
|
}
|
|
702
708
|
};
|
|
703
709
|
if (options?.chaos) {
|
|
@@ -717,11 +723,31 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
717
723
|
];
|
|
718
724
|
for (const { name, value } of chaosRates) if (value !== void 0 && (value < 0 || value > 1)) logger.warn(`Chaos ${name} (${value}) is outside 0-1 range — will be clamped at runtime`);
|
|
719
725
|
}
|
|
726
|
+
for (const { name, config } of [{
|
|
727
|
+
name: "falQueue",
|
|
728
|
+
config: options?.falQueue
|
|
729
|
+
}, {
|
|
730
|
+
name: "openRouterVideo",
|
|
731
|
+
config: options?.openRouterVideo
|
|
732
|
+
}]) {
|
|
733
|
+
if (!config) continue;
|
|
734
|
+
for (const field of ["pollsBeforeInProgress", "pollsBeforeCompleted"]) {
|
|
735
|
+
const value = config[field];
|
|
736
|
+
if (value === void 0) continue;
|
|
737
|
+
if (!Number.isFinite(value)) logger.warn(`${name}.${field} (${value}) is not a finite number — treating as unset`);
|
|
738
|
+
else if (!Number.isInteger(value) || value < 0) logger.warn(`${name}.${field} (${value}) is not a non-negative integer — flooring/clamping to a non-negative integer`);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
{
|
|
742
|
+
const cap = options?.record?.openRouterVideo?.maxContentBytes;
|
|
743
|
+
if (cap !== void 0 && (!Number.isInteger(cap) || cap < 0)) logger.warn(`record.openRouterVideo.maxContentBytes (${cap}) is not a non-negative integer — using the default cap (${require_openrouter_video.OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES})`);
|
|
744
|
+
}
|
|
720
745
|
const journal = new require_journal.Journal({
|
|
721
746
|
maxEntries: options?.journalMaxEntries ?? 1e3,
|
|
722
747
|
fixtureCountsMaxTestIds: options?.fixtureCountsMaxTestIds ?? 500
|
|
723
748
|
});
|
|
724
749
|
const videoStates = new require_video.VideoStateMap();
|
|
750
|
+
const openRouterVideoJobs = new require_openrouter_video.OpenRouterVideoJobMap();
|
|
725
751
|
if (mounts) for (const { handler } of mounts) {
|
|
726
752
|
if (handler.setJournal) handler.setJournal(journal);
|
|
727
753
|
if (registry && handler.setRegistry) handler.setRegistry(registry);
|
|
@@ -768,7 +794,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
768
794
|
}
|
|
769
795
|
});
|
|
770
796
|
if (pathname.startsWith(CONTROL_PREFIX)) {
|
|
771
|
-
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, defaults);
|
|
797
|
+
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
772
798
|
return;
|
|
773
799
|
}
|
|
774
800
|
if (mounts) {
|
|
@@ -832,6 +858,125 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
832
858
|
res.end(JSON.stringify({ models }));
|
|
833
859
|
return;
|
|
834
860
|
}
|
|
861
|
+
const openRouterVideoContentMatch = pathname.match(require_metrics.OPENROUTER_VIDEO_CONTENT_RE);
|
|
862
|
+
if (openRouterVideoContentMatch && req.method === "GET") {
|
|
863
|
+
try {
|
|
864
|
+
await require_openrouter_video.handleOpenRouterVideoContent(req, res, openRouterVideoContentMatch[1], journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
865
|
+
} catch (err) {
|
|
866
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
867
|
+
defaults.logger.error(`openrouter-video content: ${msg}`);
|
|
868
|
+
if (!res.headersSent) {
|
|
869
|
+
try {
|
|
870
|
+
journal.add({
|
|
871
|
+
method: req.method ?? "GET",
|
|
872
|
+
path: req.url ?? pathname,
|
|
873
|
+
headers: require_helpers.flattenHeaders(req.headers),
|
|
874
|
+
body: null,
|
|
875
|
+
response: {
|
|
876
|
+
status: 500,
|
|
877
|
+
fixture: null
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
} catch (jErr) {
|
|
881
|
+
defaults.logger.warn(`openrouter-video content: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
882
|
+
}
|
|
883
|
+
require_sse_writer.writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
884
|
+
message: msg,
|
|
885
|
+
type: "server_error"
|
|
886
|
+
} }));
|
|
887
|
+
} else if (!res.writableEnded) res.destroy();
|
|
888
|
+
}
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (pathname === OPENROUTER_VIDEO_MODELS_PATH && req.method === "GET") {
|
|
892
|
+
try {
|
|
893
|
+
await require_openrouter_video.handleOpenRouterVideoModels(req, res, fixtures, journal, defaults, setCorsHeaders);
|
|
894
|
+
} catch (err) {
|
|
895
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
896
|
+
defaults.logger.error(`openrouter-video models: ${msg}`);
|
|
897
|
+
if (!res.headersSent) {
|
|
898
|
+
try {
|
|
899
|
+
journal.add({
|
|
900
|
+
method: req.method ?? "GET",
|
|
901
|
+
path: req.url ?? pathname,
|
|
902
|
+
headers: require_helpers.flattenHeaders(req.headers),
|
|
903
|
+
body: null,
|
|
904
|
+
response: {
|
|
905
|
+
status: 500,
|
|
906
|
+
fixture: null
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
} catch (jErr) {
|
|
910
|
+
defaults.logger.warn(`openrouter-video models: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
911
|
+
}
|
|
912
|
+
require_sse_writer.writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
913
|
+
message: msg,
|
|
914
|
+
type: "server_error"
|
|
915
|
+
} }));
|
|
916
|
+
} else if (!res.writableEnded) res.destroy();
|
|
917
|
+
}
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
const openRouterVideoStatusMatch = pathname.match(require_metrics.OPENROUTER_VIDEO_STATUS_RE);
|
|
921
|
+
if (openRouterVideoStatusMatch && req.method === "GET") {
|
|
922
|
+
try {
|
|
923
|
+
await require_openrouter_video.handleOpenRouterVideoStatus(req, res, openRouterVideoStatusMatch[1], fixtures, journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
924
|
+
} catch (err) {
|
|
925
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
926
|
+
defaults.logger.error(`openrouter-video status: ${msg}`);
|
|
927
|
+
if (!res.headersSent) {
|
|
928
|
+
try {
|
|
929
|
+
journal.add({
|
|
930
|
+
method: req.method ?? "GET",
|
|
931
|
+
path: req.url ?? pathname,
|
|
932
|
+
headers: require_helpers.flattenHeaders(req.headers),
|
|
933
|
+
body: null,
|
|
934
|
+
response: {
|
|
935
|
+
status: 500,
|
|
936
|
+
fixture: null
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
} catch (jErr) {
|
|
940
|
+
defaults.logger.warn(`openrouter-video status: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
941
|
+
}
|
|
942
|
+
require_sse_writer.writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
943
|
+
message: msg,
|
|
944
|
+
type: "server_error"
|
|
945
|
+
} }));
|
|
946
|
+
} else if (!res.writableEnded) res.destroy();
|
|
947
|
+
}
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (pathname === OPENROUTER_VIDEOS_PATH && req.method === "POST") {
|
|
951
|
+
setCorsHeaders(res);
|
|
952
|
+
try {
|
|
953
|
+
await require_openrouter_video.handleOpenRouterVideoCreate(req, res, await require_helpers.readBody(req), fixtures, journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
954
|
+
} catch (err) {
|
|
955
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
956
|
+
defaults.logger.error(`openrouter-video submit: ${msg}`);
|
|
957
|
+
if (!res.headersSent) {
|
|
958
|
+
try {
|
|
959
|
+
journal.add({
|
|
960
|
+
method: req.method ?? "POST",
|
|
961
|
+
path: req.url ?? pathname,
|
|
962
|
+
headers: require_helpers.flattenHeaders(req.headers),
|
|
963
|
+
body: null,
|
|
964
|
+
response: {
|
|
965
|
+
status: 500,
|
|
966
|
+
fixture: null
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
} catch (jErr) {
|
|
970
|
+
defaults.logger.warn(`openrouter-video submit: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
971
|
+
}
|
|
972
|
+
require_sse_writer.writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
973
|
+
message: msg,
|
|
974
|
+
type: "server_error"
|
|
975
|
+
} }));
|
|
976
|
+
} else if (!res.writableEnded) res.destroy();
|
|
977
|
+
}
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
835
980
|
let azureDeploymentId;
|
|
836
981
|
const azureMatch = pathname.match(AZURE_DEPLOYMENT_RE);
|
|
837
982
|
if (azureMatch && req.method === "POST") {
|
|
@@ -1107,7 +1252,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1107
1252
|
}
|
|
1108
1253
|
return;
|
|
1109
1254
|
}
|
|
1110
|
-
const videoStatusMatch = pathname.match(
|
|
1255
|
+
const videoStatusMatch = pathname.match(require_metrics.OPENAI_VIDEO_STATUS_RE);
|
|
1111
1256
|
if (videoStatusMatch && req.method === "GET") {
|
|
1112
1257
|
const videoId = videoStatusMatch[1];
|
|
1113
1258
|
require_video.handleVideoStatus(req, res, videoId, journal, defaults, setCorsHeaders, videoStates);
|
|
@@ -1529,6 +1674,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1529
1674
|
server.close = function(callback) {
|
|
1530
1675
|
for (const ws of activeConnections) ws.close(1001, "Server shutting down");
|
|
1531
1676
|
activeConnections.clear();
|
|
1677
|
+
videoStates.clear();
|
|
1678
|
+
openRouterVideoJobs.clear();
|
|
1532
1679
|
originalClose(callback);
|
|
1533
1680
|
return this;
|
|
1534
1681
|
};
|
|
@@ -1549,7 +1696,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1549
1696
|
journal,
|
|
1550
1697
|
url,
|
|
1551
1698
|
defaults,
|
|
1552
|
-
videoStates
|
|
1699
|
+
videoStates,
|
|
1700
|
+
openRouterVideoJobs
|
|
1553
1701
|
});
|
|
1554
1702
|
});
|
|
1555
1703
|
});
|