@copilotkit/aimock 1.30.0 → 1.31.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 +16 -0
- package/README.md +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 +10 -4
- 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 +12 -6
- package/dist/fal-audio.js.map +1 -1
- package/dist/fal.cjs +51 -44
- package/dist/fal.cjs.map +1 -1
- package/dist/fal.d.cts +8 -0
- package/dist/fal.d.cts.map +1 -1
- package/dist/fal.d.ts +8 -0
- package/dist/fal.d.ts.map +1 -1
- package/dist/fal.js +52 -45
- 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 +2 -1
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +2 -1
- 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 +81 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +81 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/ws-gemini-live.d.cts +2 -2
- package/dist/ws-realtime.d.cts +2 -2
- package/package.json +2 -2
package/dist/server.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ import { SearchFixture } from "./search.cjs";
|
|
|
4
4
|
import { RerankFixture } from "./rerank.cjs";
|
|
5
5
|
import { ModerationFixture } from "./moderation.cjs";
|
|
6
6
|
import { VideoStateMap } from "./video.cjs";
|
|
7
|
+
import { OpenRouterVideoJobMap } from "./openrouter-video.cjs";
|
|
7
8
|
import * as http$1 from "node:http";
|
|
8
9
|
|
|
9
10
|
//#region src/server.d.ts
|
|
@@ -13,6 +14,7 @@ interface ServerInstance {
|
|
|
13
14
|
url: string;
|
|
14
15
|
defaults: HandlerDefaults;
|
|
15
16
|
videoStates: VideoStateMap;
|
|
17
|
+
openRouterVideoJobs: OpenRouterVideoJobMap;
|
|
16
18
|
}
|
|
17
19
|
interface ServiceFixtures {
|
|
18
20
|
search: SearchFixture[];
|
package/dist/server.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.cts","names":[],"sources":["../src/server.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.cts","names":[],"sources":["../src/server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UA0FiB,cAAA;UACP,MAAA,CAAK;EADE,OAAA,EAEN,OAFM;EAAc,GAAA,EAAA,MAAA;UACrB,EAGE,eAHG;aACJ,EAGI,aAHJ;qBAEC,EAEW,qBAFX;;AAEW,UAw8BN,eAAA,CAx8BM;EAAqB,MAAA,EAy8BlC,aAz8BkC,EAAA;EAw8B3B,MAAA,EAEP,aAFsB,EAAA;EAAA,UAAA,EAGlB,iBAHkB,EAAA;;AAEtB,iBAOY,YAAA,CAPZ,QAAA,EAQE,OARF,EAAA,EAAA,OAAA,CAAA,EASE,iBATF,EAAA,MAOV,CAPU,EAUC,KAVD,CAAA;MACI,EAAA,MAAA;EAAiB,OAAA,EASW,SATX;AAM/B,CAAA,CAAA,EAAsB,eAAY,CAAA,EAId,eAJc,CAAA,EAK/B,OAL+B,CAKvB,cALuB,CAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { SearchFixture } from "./search.js";
|
|
|
4
4
|
import { RerankFixture } from "./rerank.js";
|
|
5
5
|
import { ModerationFixture } from "./moderation.js";
|
|
6
6
|
import { VideoStateMap } from "./video.js";
|
|
7
|
+
import { OpenRouterVideoJobMap } from "./openrouter-video.js";
|
|
7
8
|
import * as http$1 from "node:http";
|
|
8
9
|
|
|
9
10
|
//#region src/server.d.ts
|
|
@@ -13,6 +14,7 @@ interface ServerInstance {
|
|
|
13
14
|
url: string;
|
|
14
15
|
defaults: HandlerDefaults;
|
|
15
16
|
videoStates: VideoStateMap;
|
|
17
|
+
openRouterVideoJobs: OpenRouterVideoJobMap;
|
|
16
18
|
}
|
|
17
19
|
interface ServiceFixtures {
|
|
18
20
|
search: SearchFixture[];
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UA0FiB,cAAA;UACP,MAAA,CAAK;EADE,OAAA,EAEN,OAFM;EAAc,GAAA,EAAA,MAAA;UACrB,EAGE,eAHG;aACJ,EAGI,aAHJ;qBAEC,EAEW,qBAFX;;AAEW,UAw8BN,eAAA,CAx8BM;EAAqB,MAAA,EAy8BlC,aAz8BkC,EAAA;EAw8B3B,MAAA,EAEP,aAFsB,EAAA;EAAA,UAAA,EAGlB,iBAHkB,EAAA;;AAEtB,iBAOY,YAAA,CAPZ,QAAA,EAQE,OARF,EAAA,EAAA,OAAA,CAAA,EASE,iBATF,EAAA,MAOV,CAPU,EAUC,KAVD,CAAA;MACI,EAAA,MAAA;EAAiB,OAAA,EASW,SATX;AAM/B,CAAA,CAAA,EAAsB,eAAY,CAAA,EAId,eAJc,CAAA,EAK/B,OAL+B,CAKvB,cALuB,CAAA"}
|
package/dist/server.js
CHANGED
|
@@ -19,9 +19,10 @@ import { handleTranscription } from "./transcription.js";
|
|
|
19
19
|
import { handleImageEdit, handleImageVariations, handleImages } from "./images.js";
|
|
20
20
|
import { handleSpeech } from "./speech.js";
|
|
21
21
|
import { VideoStateMap, handleVideoCreate, handleVideoStatus } from "./video.js";
|
|
22
|
-
import { handleElevenLabsAudio, handleElevenLabsTTS } from "./elevenlabs-audio.js";
|
|
23
|
-
import { falQueueStates, handleFal } from "./fal.js";
|
|
24
22
|
import { falJobs, handleFalQueue } from "./fal-audio.js";
|
|
23
|
+
import { falQueueStates, handleFal } from "./fal.js";
|
|
24
|
+
import { OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OpenRouterVideoJobMap, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus } from "./openrouter-video.js";
|
|
25
|
+
import { handleElevenLabsAudio, handleElevenLabsTTS } from "./elevenlabs-audio.js";
|
|
25
26
|
import { handleOllama, handleOllamaEmbeddings, handleOllamaGenerate } from "./ollama.js";
|
|
26
27
|
import { handleCohere, handleCohereEmbed } from "./cohere.js";
|
|
27
28
|
import { handleSearch } from "./search.js";
|
|
@@ -31,7 +32,7 @@ import { upgradeToWebSocket } from "./ws-framing.js";
|
|
|
31
32
|
import { handleWebSocketResponses } from "./ws-responses.js";
|
|
32
33
|
import { handleWebSocketRealtime } from "./ws-realtime.js";
|
|
33
34
|
import { handleWebSocketGeminiLive } from "./ws-gemini-live.js";
|
|
34
|
-
import { createMetricsRegistry, normalizePathLabel } from "./metrics.js";
|
|
35
|
+
import { OPENAI_VIDEO_STATUS_RE, OPENROUTER_VIDEO_CONTENT_RE, OPENROUTER_VIDEO_STATUS_RE, createMetricsRegistry, normalizePathLabel } from "./metrics.js";
|
|
35
36
|
import * as http$1 from "node:http";
|
|
36
37
|
|
|
37
38
|
//#region src/server.ts
|
|
@@ -53,7 +54,6 @@ const SPEECH_PATH = "/v1/audio/speech";
|
|
|
53
54
|
const TRANSCRIPTIONS_PATH = "/v1/audio/transcriptions";
|
|
54
55
|
const TRANSLATIONS_PATH = "/v1/audio/translations";
|
|
55
56
|
const VIDEOS_PATH = "/v1/videos";
|
|
56
|
-
const VIDEOS_STATUS_RE = /^\/v1\/videos\/([^/]+)$/;
|
|
57
57
|
const GEMINI_PREDICT_RE = /^\/v1beta\/models\/([^:]+):predict$/;
|
|
58
58
|
const ELEVENLABS_SOUND_GENERATION_PATH = "/v1/sound-generation";
|
|
59
59
|
const ELEVENLABS_TTS_RE = /^\/v1\/text-to-speech\/([^/]+)$/;
|
|
@@ -104,6 +104,8 @@ const OLLAMA_GENERATE_PATH = "/api/generate";
|
|
|
104
104
|
const OLLAMA_EMBEDDINGS_PATH = "/api/embeddings";
|
|
105
105
|
const OLLAMA_EMBED_PATH = "/api/embed";
|
|
106
106
|
const OLLAMA_TAGS_PATH = "/api/tags";
|
|
107
|
+
const OPENROUTER_VIDEOS_PATH = "/api/v1/videos";
|
|
108
|
+
const OPENROUTER_VIDEO_MODELS_PATH = "/api/v1/videos/models";
|
|
107
109
|
const HEALTH_PATH = "/health";
|
|
108
110
|
const READY_PATH = "/ready";
|
|
109
111
|
const MODELS_PATH = "/v1/models";
|
|
@@ -142,10 +144,11 @@ const CONTROL_PREFIX = "/__aimock";
|
|
|
142
144
|
* `aimock_fixtures_loaded` gauge. Shared by `/reset/fixtures` and the
|
|
143
145
|
* deprecated `/reset` alias.
|
|
144
146
|
*/
|
|
145
|
-
function performFixturesReset(fixtures, journal, videoStates, defaults) {
|
|
147
|
+
function performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults) {
|
|
146
148
|
fixtures.length = 0;
|
|
147
149
|
journal.clear();
|
|
148
150
|
videoStates.clear();
|
|
151
|
+
openRouterVideoJobs.clear();
|
|
149
152
|
falJobs.clear();
|
|
150
153
|
falQueueStates.clear();
|
|
151
154
|
resetInteractionCounter();
|
|
@@ -156,7 +159,7 @@ function performFixturesReset(fixtures, journal, videoStates, defaults) {
|
|
|
156
159
|
* Handle requests under `/__aimock/`. Returns `true` if the request was
|
|
157
160
|
* handled, `false` if the path doesn't match the control prefix.
|
|
158
161
|
*/
|
|
159
|
-
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, defaults) {
|
|
162
|
+
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults) {
|
|
160
163
|
if (!pathname.startsWith(CONTROL_PREFIX)) return false;
|
|
161
164
|
const subPath = pathname.slice(9);
|
|
162
165
|
setCorsHeaders(res);
|
|
@@ -220,7 +223,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
220
223
|
return true;
|
|
221
224
|
}
|
|
222
225
|
if (subPath === "/reset/fixtures" && req.method === "POST") {
|
|
223
|
-
performFixturesReset(fixtures, journal, videoStates, defaults);
|
|
226
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
224
227
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
225
228
|
res.end(JSON.stringify({ reset: true }));
|
|
226
229
|
return true;
|
|
@@ -232,7 +235,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
232
235
|
return true;
|
|
233
236
|
}
|
|
234
237
|
if (subPath === "/reset" && req.method === "POST") {
|
|
235
|
-
performFixturesReset(fixtures, journal, videoStates, defaults);
|
|
238
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
236
239
|
const deprecation = "POST /__aimock/reset is deprecated; use POST /__aimock/reset/fixtures (full reset) or POST /__aimock/reset/journal (journal only)";
|
|
237
240
|
defaults.logger.warn("POST /__aimock/reset is deprecated; use /__aimock/reset/fixtures or /__aimock/reset/journal");
|
|
238
241
|
res.writeHead(200, {
|
|
@@ -696,6 +699,9 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
696
699
|
},
|
|
697
700
|
get falQueue() {
|
|
698
701
|
return serverOptions.falQueue;
|
|
702
|
+
},
|
|
703
|
+
get openRouterVideo() {
|
|
704
|
+
return serverOptions.openRouterVideo;
|
|
699
705
|
}
|
|
700
706
|
};
|
|
701
707
|
if (options?.chaos) {
|
|
@@ -715,11 +721,31 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
715
721
|
];
|
|
716
722
|
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`);
|
|
717
723
|
}
|
|
724
|
+
for (const { name, config } of [{
|
|
725
|
+
name: "falQueue",
|
|
726
|
+
config: options?.falQueue
|
|
727
|
+
}, {
|
|
728
|
+
name: "openRouterVideo",
|
|
729
|
+
config: options?.openRouterVideo
|
|
730
|
+
}]) {
|
|
731
|
+
if (!config) continue;
|
|
732
|
+
for (const field of ["pollsBeforeInProgress", "pollsBeforeCompleted"]) {
|
|
733
|
+
const value = config[field];
|
|
734
|
+
if (value === void 0) continue;
|
|
735
|
+
if (!Number.isFinite(value)) logger.warn(`${name}.${field} (${value}) is not a finite number — treating as unset`);
|
|
736
|
+
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`);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
{
|
|
740
|
+
const cap = options?.record?.openRouterVideo?.maxContentBytes;
|
|
741
|
+
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 (${OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES})`);
|
|
742
|
+
}
|
|
718
743
|
const journal = new Journal({
|
|
719
744
|
maxEntries: options?.journalMaxEntries ?? 1e3,
|
|
720
745
|
fixtureCountsMaxTestIds: options?.fixtureCountsMaxTestIds ?? 500
|
|
721
746
|
});
|
|
722
747
|
const videoStates = new VideoStateMap();
|
|
748
|
+
const openRouterVideoJobs = new OpenRouterVideoJobMap();
|
|
723
749
|
if (mounts) for (const { handler } of mounts) {
|
|
724
750
|
if (handler.setJournal) handler.setJournal(journal);
|
|
725
751
|
if (registry && handler.setRegistry) handler.setRegistry(registry);
|
|
@@ -766,7 +792,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
766
792
|
}
|
|
767
793
|
});
|
|
768
794
|
if (pathname.startsWith(CONTROL_PREFIX)) {
|
|
769
|
-
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, defaults);
|
|
795
|
+
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
770
796
|
return;
|
|
771
797
|
}
|
|
772
798
|
if (mounts) {
|
|
@@ -830,6 +856,125 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
830
856
|
res.end(JSON.stringify({ models }));
|
|
831
857
|
return;
|
|
832
858
|
}
|
|
859
|
+
const openRouterVideoContentMatch = pathname.match(OPENROUTER_VIDEO_CONTENT_RE);
|
|
860
|
+
if (openRouterVideoContentMatch && req.method === "GET") {
|
|
861
|
+
try {
|
|
862
|
+
await handleOpenRouterVideoContent(req, res, openRouterVideoContentMatch[1], journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
863
|
+
} catch (err) {
|
|
864
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
865
|
+
defaults.logger.error(`openrouter-video content: ${msg}`);
|
|
866
|
+
if (!res.headersSent) {
|
|
867
|
+
try {
|
|
868
|
+
journal.add({
|
|
869
|
+
method: req.method ?? "GET",
|
|
870
|
+
path: req.url ?? pathname,
|
|
871
|
+
headers: flattenHeaders(req.headers),
|
|
872
|
+
body: null,
|
|
873
|
+
response: {
|
|
874
|
+
status: 500,
|
|
875
|
+
fixture: null
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
} catch (jErr) {
|
|
879
|
+
defaults.logger.warn(`openrouter-video content: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
880
|
+
}
|
|
881
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
882
|
+
message: msg,
|
|
883
|
+
type: "server_error"
|
|
884
|
+
} }));
|
|
885
|
+
} else if (!res.writableEnded) res.destroy();
|
|
886
|
+
}
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (pathname === OPENROUTER_VIDEO_MODELS_PATH && req.method === "GET") {
|
|
890
|
+
try {
|
|
891
|
+
await handleOpenRouterVideoModels(req, res, fixtures, journal, defaults, setCorsHeaders);
|
|
892
|
+
} catch (err) {
|
|
893
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
894
|
+
defaults.logger.error(`openrouter-video models: ${msg}`);
|
|
895
|
+
if (!res.headersSent) {
|
|
896
|
+
try {
|
|
897
|
+
journal.add({
|
|
898
|
+
method: req.method ?? "GET",
|
|
899
|
+
path: req.url ?? pathname,
|
|
900
|
+
headers: flattenHeaders(req.headers),
|
|
901
|
+
body: null,
|
|
902
|
+
response: {
|
|
903
|
+
status: 500,
|
|
904
|
+
fixture: null
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
} catch (jErr) {
|
|
908
|
+
defaults.logger.warn(`openrouter-video models: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
909
|
+
}
|
|
910
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
911
|
+
message: msg,
|
|
912
|
+
type: "server_error"
|
|
913
|
+
} }));
|
|
914
|
+
} else if (!res.writableEnded) res.destroy();
|
|
915
|
+
}
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
const openRouterVideoStatusMatch = pathname.match(OPENROUTER_VIDEO_STATUS_RE);
|
|
919
|
+
if (openRouterVideoStatusMatch && req.method === "GET") {
|
|
920
|
+
try {
|
|
921
|
+
await handleOpenRouterVideoStatus(req, res, openRouterVideoStatusMatch[1], fixtures, journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
922
|
+
} catch (err) {
|
|
923
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
924
|
+
defaults.logger.error(`openrouter-video status: ${msg}`);
|
|
925
|
+
if (!res.headersSent) {
|
|
926
|
+
try {
|
|
927
|
+
journal.add({
|
|
928
|
+
method: req.method ?? "GET",
|
|
929
|
+
path: req.url ?? pathname,
|
|
930
|
+
headers: flattenHeaders(req.headers),
|
|
931
|
+
body: null,
|
|
932
|
+
response: {
|
|
933
|
+
status: 500,
|
|
934
|
+
fixture: null
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
} catch (jErr) {
|
|
938
|
+
defaults.logger.warn(`openrouter-video status: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
939
|
+
}
|
|
940
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
941
|
+
message: msg,
|
|
942
|
+
type: "server_error"
|
|
943
|
+
} }));
|
|
944
|
+
} else if (!res.writableEnded) res.destroy();
|
|
945
|
+
}
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (pathname === OPENROUTER_VIDEOS_PATH && req.method === "POST") {
|
|
949
|
+
setCorsHeaders(res);
|
|
950
|
+
try {
|
|
951
|
+
await handleOpenRouterVideoCreate(req, res, await readBody(req), fixtures, journal, defaults, setCorsHeaders, openRouterVideoJobs);
|
|
952
|
+
} catch (err) {
|
|
953
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
954
|
+
defaults.logger.error(`openrouter-video submit: ${msg}`);
|
|
955
|
+
if (!res.headersSent) {
|
|
956
|
+
try {
|
|
957
|
+
journal.add({
|
|
958
|
+
method: req.method ?? "POST",
|
|
959
|
+
path: req.url ?? pathname,
|
|
960
|
+
headers: flattenHeaders(req.headers),
|
|
961
|
+
body: null,
|
|
962
|
+
response: {
|
|
963
|
+
status: 500,
|
|
964
|
+
fixture: null
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
} catch (jErr) {
|
|
968
|
+
defaults.logger.warn(`openrouter-video submit: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
969
|
+
}
|
|
970
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
971
|
+
message: msg,
|
|
972
|
+
type: "server_error"
|
|
973
|
+
} }));
|
|
974
|
+
} else if (!res.writableEnded) res.destroy();
|
|
975
|
+
}
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
833
978
|
let azureDeploymentId;
|
|
834
979
|
const azureMatch = pathname.match(AZURE_DEPLOYMENT_RE);
|
|
835
980
|
if (azureMatch && req.method === "POST") {
|
|
@@ -1105,7 +1250,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1105
1250
|
}
|
|
1106
1251
|
return;
|
|
1107
1252
|
}
|
|
1108
|
-
const videoStatusMatch = pathname.match(
|
|
1253
|
+
const videoStatusMatch = pathname.match(OPENAI_VIDEO_STATUS_RE);
|
|
1109
1254
|
if (videoStatusMatch && req.method === "GET") {
|
|
1110
1255
|
const videoId = videoStatusMatch[1];
|
|
1111
1256
|
handleVideoStatus(req, res, videoId, journal, defaults, setCorsHeaders, videoStates);
|
|
@@ -1527,6 +1672,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1527
1672
|
server.close = function(callback) {
|
|
1528
1673
|
for (const ws of activeConnections) ws.close(1001, "Server shutting down");
|
|
1529
1674
|
activeConnections.clear();
|
|
1675
|
+
videoStates.clear();
|
|
1676
|
+
openRouterVideoJobs.clear();
|
|
1530
1677
|
originalClose(callback);
|
|
1531
1678
|
return this;
|
|
1532
1679
|
};
|
|
@@ -1547,7 +1694,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1547
1694
|
journal,
|
|
1548
1695
|
url,
|
|
1549
1696
|
defaults,
|
|
1550
|
-
videoStates
|
|
1697
|
+
videoStates,
|
|
1698
|
+
openRouterVideoJobs
|
|
1551
1699
|
});
|
|
1552
1700
|
});
|
|
1553
1701
|
});
|