@copilotkit/aimock 1.34.0 → 1.35.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +2 -1
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/bedrock-converse.cjs +110 -8
- package/dist/bedrock-converse.cjs.map +1 -1
- package/dist/bedrock-converse.d.cts.map +1 -1
- package/dist/bedrock-converse.d.ts.map +1 -1
- package/dist/bedrock-converse.js +111 -9
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +141 -4
- package/dist/bedrock.cjs.map +1 -1
- package/dist/bedrock.d.cts.map +1 -1
- package/dist/bedrock.d.ts.map +1 -1
- package/dist/bedrock.js +142 -5
- package/dist/bedrock.js.map +1 -1
- package/dist/cohere.cjs +89 -7
- package/dist/cohere.cjs.map +1 -1
- package/dist/cohere.d.cts.map +1 -1
- package/dist/cohere.d.ts.map +1 -1
- package/dist/cohere.js +90 -8
- package/dist/cohere.js.map +1 -1
- package/dist/config-loader.d.cts.map +1 -1
- package/dist/fixture-loader.cjs +121 -20
- 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 +121 -20
- package/dist/fixture-loader.js.map +1 -1
- package/dist/gemini-interactions.cjs +97 -60
- package/dist/gemini-interactions.cjs.map +1 -1
- package/dist/gemini-interactions.d.cts.map +1 -1
- package/dist/gemini-interactions.d.ts.map +1 -1
- package/dist/gemini-interactions.js +98 -61
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +71 -6
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts.map +1 -1
- package/dist/gemini.d.ts.map +1 -1
- package/dist/gemini.js +72 -7
- package/dist/gemini.js.map +1 -1
- package/dist/grok-video.cjs +834 -0
- package/dist/grok-video.cjs.map +1 -0
- package/dist/grok-video.d.cts +74 -0
- package/dist/grok-video.d.cts.map +1 -0
- package/dist/grok-video.d.ts +74 -0
- package/dist/grok-video.d.ts.map +1 -0
- package/dist/grok-video.js +829 -0
- package/dist/grok-video.js.map +1 -0
- package/dist/helpers.cjs +181 -2
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +33 -3
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts +33 -3
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +181 -3
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/messages.cjs +99 -10
- package/dist/messages.cjs.map +1 -1
- package/dist/messages.d.cts.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +100 -11
- package/dist/messages.js.map +1 -1
- package/dist/metrics.cjs +11 -1
- 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 +8 -1
- package/dist/metrics.js.map +1 -1
- package/dist/ollama.cjs +74 -4
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts.map +1 -1
- package/dist/ollama.d.ts.map +1 -1
- package/dist/ollama.js +75 -5
- package/dist/ollama.js.map +1 -1
- package/dist/openrouter-video.cjs +19 -138
- package/dist/openrouter-video.cjs.map +1 -1
- package/dist/openrouter-video.d.cts.map +1 -1
- package/dist/openrouter-video.d.ts.map +1 -1
- package/dist/openrouter-video.js +1 -120
- package/dist/openrouter-video.js.map +1 -1
- package/dist/recorder.cjs +36 -20
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.js +36 -20
- package/dist/recorder.js.map +1 -1
- package/dist/responses.cjs +136 -58
- package/dist/responses.cjs.map +1 -1
- package/dist/responses.d.cts +2 -2
- package/dist/responses.d.cts.map +1 -1
- package/dist/responses.d.ts +2 -2
- package/dist/responses.d.ts.map +1 -1
- package/dist/responses.js +137 -59
- package/dist/responses.js.map +1 -1
- package/dist/server.cjs +162 -20
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -0
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +164 -22
- package/dist/server.js.map +1 -1
- package/dist/stream-collapse.cjs +300 -74
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +17 -1
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +17 -1
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +300 -74
- package/dist/stream-collapse.js.map +1 -1
- package/dist/types.d.cts +104 -7
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +104 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-types.d.cts.map +1 -1
- package/dist/vector-types.d.ts.map +1 -1
- package/dist/veo-video.cjs +794 -0
- package/dist/veo-video.cjs.map +1 -0
- package/dist/veo-video.d.cts +50 -0
- package/dist/veo-video.d.cts.map +1 -0
- package/dist/veo-video.d.ts +50 -0
- package/dist/veo-video.d.ts.map +1 -0
- package/dist/veo-video.js +789 -0
- package/dist/veo-video.js.map +1 -0
- package/dist/video-proxy-shared.cjs +145 -0
- package/dist/video-proxy-shared.cjs.map +1 -0
- package/dist/video-proxy-shared.js +140 -0
- package/dist/video-proxy-shared.js.map +1 -0
- package/dist/ws-gemini-live.cjs +96 -3
- package/dist/ws-gemini-live.cjs.map +1 -1
- package/dist/ws-gemini-live.d.cts.map +1 -1
- package/dist/ws-gemini-live.d.ts.map +1 -1
- package/dist/ws-gemini-live.js +97 -4
- package/dist/ws-gemini-live.js.map +1 -1
- package/dist/ws-realtime.cjs +281 -4
- package/dist/ws-realtime.cjs.map +1 -1
- package/dist/ws-realtime.d.cts.map +1 -1
- package/dist/ws-realtime.d.ts.map +1 -1
- package/dist/ws-realtime.js +282 -5
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +1 -1
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.js +1 -1
- package/dist/ws-responses.js.map +1 -1
- package/fixtures/examples/llm/blocks-tool-first.json +13 -0
- package/package.json +1 -1
- package/skills/write-fixtures/SKILL.md +19 -1
package/dist/server.d.cts
CHANGED
|
@@ -5,6 +5,8 @@ import { RerankFixture } from "./rerank.cjs";
|
|
|
5
5
|
import { ModerationFixture } from "./moderation.cjs";
|
|
6
6
|
import { VideoStateMap } from "./video.cjs";
|
|
7
7
|
import { OpenRouterVideoJobMap } from "./openrouter-video.cjs";
|
|
8
|
+
import { VeoVideoJobMap } from "./veo-video.cjs";
|
|
9
|
+
import { GrokVideoJobMap } from "./grok-video.cjs";
|
|
8
10
|
import * as http$1 from "node:http";
|
|
9
11
|
|
|
10
12
|
//#region src/server.d.ts
|
|
@@ -15,6 +17,8 @@ interface ServerInstance {
|
|
|
15
17
|
defaults: HandlerDefaults;
|
|
16
18
|
videoStates: VideoStateMap;
|
|
17
19
|
openRouterVideoJobs: OpenRouterVideoJobMap;
|
|
20
|
+
veoVideoJobs: VeoVideoJobMap;
|
|
21
|
+
grokVideoJobs: GrokVideoJobMap;
|
|
18
22
|
}
|
|
19
23
|
interface ServiceFixtures {
|
|
20
24
|
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":";;;;;;;;;;;;UA+FiB,cAAA;UACP,MAAA,CAAK;EADE,OAAA,EAEN,OAFM;EAAc,GAAA,EAAA,MAAA;UACrB,EAGE,eAHG;aACJ,EAGI,aAHJ;qBAEC,EAEW,qBAFX;cACG,EAEC,cAFD;eACQ,EAEN,eAFM;;AAEN,UAq+BA,eAAA,CAr+BA;EAAe,MAAA,EAs+BtB,aAt+BsB,EAAA;EAq+Bf,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
|
@@ -5,6 +5,8 @@ import { RerankFixture } from "./rerank.js";
|
|
|
5
5
|
import { ModerationFixture } from "./moderation.js";
|
|
6
6
|
import { VideoStateMap } from "./video.js";
|
|
7
7
|
import { OpenRouterVideoJobMap } from "./openrouter-video.js";
|
|
8
|
+
import { VeoVideoJobMap } from "./veo-video.js";
|
|
9
|
+
import { GrokVideoJobMap } from "./grok-video.js";
|
|
8
10
|
import * as http$1 from "node:http";
|
|
9
11
|
|
|
10
12
|
//#region src/server.d.ts
|
|
@@ -15,6 +17,8 @@ interface ServerInstance {
|
|
|
15
17
|
defaults: HandlerDefaults;
|
|
16
18
|
videoStates: VideoStateMap;
|
|
17
19
|
openRouterVideoJobs: OpenRouterVideoJobMap;
|
|
20
|
+
veoVideoJobs: VeoVideoJobMap;
|
|
21
|
+
grokVideoJobs: GrokVideoJobMap;
|
|
18
22
|
}
|
|
19
23
|
interface ServiceFixtures {
|
|
20
24
|
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":";;;;;;;;;;;;UA+FiB,cAAA;UACP,MAAA,CAAK;EADE,OAAA,EAEN,OAFM;EAAc,GAAA,EAAA,MAAA;UACrB,EAGE,eAHG;aACJ,EAGI,aAHJ;qBAEC,EAEW,qBAFX;cACG,EAEC,cAFD;eACQ,EAEN,eAFM;;AAEN,UAq+BA,eAAA,CAr+BA;EAAe,MAAA,EAs+BtB,aAt+BsB,EAAA;EAq+Bf,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
|
@@ -18,10 +18,12 @@ import { handleEmbeddings } from "./embeddings.js";
|
|
|
18
18
|
import { handleTranscription } from "./transcription.js";
|
|
19
19
|
import { handleImageEdit, handleImageVariations, handleImages } from "./images.js";
|
|
20
20
|
import { handleSpeech } from "./speech.js";
|
|
21
|
-
import { VideoStateMap, handleVideoCreate
|
|
21
|
+
import { VideoStateMap, handleVideoCreate } from "./video.js";
|
|
22
22
|
import { falJobs, handleFalQueue } from "./fal-audio.js";
|
|
23
23
|
import { falQueueStates, handleFal } from "./fal.js";
|
|
24
24
|
import { OPENROUTER_VIDEO_DEFAULT_MAX_CONTENT_BYTES, OpenRouterVideoJobMap, handleOpenRouterVideoContent, handleOpenRouterVideoCreate, handleOpenRouterVideoModels, handleOpenRouterVideoStatus } from "./openrouter-video.js";
|
|
25
|
+
import { VeoVideoJobMap, handleVeoVideoCreate, handleVeoVideoStatus } from "./veo-video.js";
|
|
26
|
+
import { GrokVideoJobMap, handleGrokVideoCreate, handleGrokVideoStatus } from "./grok-video.js";
|
|
25
27
|
import { handleElevenLabsAudio, handleElevenLabsTTS } from "./elevenlabs-audio.js";
|
|
26
28
|
import { handleOllama, handleOllamaEmbeddings, handleOllamaGenerate } from "./ollama.js";
|
|
27
29
|
import { handleCohere, handleCohereEmbed } from "./cohere.js";
|
|
@@ -32,7 +34,7 @@ import { upgradeToWebSocket } from "./ws-framing.js";
|
|
|
32
34
|
import { handleWebSocketResponses } from "./ws-responses.js";
|
|
33
35
|
import { handleWebSocketRealtime } from "./ws-realtime.js";
|
|
34
36
|
import { handleWebSocketGeminiLive } from "./ws-gemini-live.js";
|
|
35
|
-
import {
|
|
37
|
+
import { GROK_VIDEO_STATUS_RE, GROK_VIDEO_SUBMIT_PATH, OPENROUTER_VIDEO_CONTENT_RE, OPENROUTER_VIDEO_STATUS_RE, VEO_OPERATION_RE, VEO_PREDICT_LRO_RE, createMetricsRegistry, normalizePathLabel } from "./metrics.js";
|
|
36
38
|
import * as http$1 from "node:http";
|
|
37
39
|
|
|
38
40
|
//#region src/server.ts
|
|
@@ -144,11 +146,13 @@ 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, openRouterVideoJobs, defaults) {
|
|
149
|
+
function performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults) {
|
|
148
150
|
fixtures.length = 0;
|
|
149
151
|
journal.clear();
|
|
150
152
|
videoStates.clear();
|
|
151
153
|
openRouterVideoJobs.clear();
|
|
154
|
+
veoVideoJobs.clear();
|
|
155
|
+
grokVideoJobs.clear();
|
|
152
156
|
falJobs.clear();
|
|
153
157
|
falQueueStates.clear();
|
|
154
158
|
resetInteractionCounter();
|
|
@@ -159,7 +163,7 @@ function performFixturesReset(fixtures, journal, videoStates, openRouterVideoJob
|
|
|
159
163
|
* Handle requests under `/__aimock/`. Returns `true` if the request was
|
|
160
164
|
* handled, `false` if the path doesn't match the control prefix.
|
|
161
165
|
*/
|
|
162
|
-
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults) {
|
|
166
|
+
async function handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults) {
|
|
163
167
|
if (!pathname.startsWith(CONTROL_PREFIX)) return false;
|
|
164
168
|
const subPath = pathname.slice(9);
|
|
165
169
|
setCorsHeaders(res);
|
|
@@ -223,7 +227,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
223
227
|
return true;
|
|
224
228
|
}
|
|
225
229
|
if (subPath === "/reset/fixtures" && req.method === "POST") {
|
|
226
|
-
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
230
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults);
|
|
227
231
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
228
232
|
res.end(JSON.stringify({ reset: true }));
|
|
229
233
|
return true;
|
|
@@ -235,7 +239,7 @@ async function handleControlAPI(req, res, pathname, fixtures, journal, videoStat
|
|
|
235
239
|
return true;
|
|
236
240
|
}
|
|
237
241
|
if (subPath === "/reset" && req.method === "POST") {
|
|
238
|
-
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
242
|
+
performFixturesReset(fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults);
|
|
239
243
|
const deprecation = "POST /__aimock/reset is deprecated; use POST /__aimock/reset/fixtures (full reset) or POST /__aimock/reset/journal (journal only)";
|
|
240
244
|
defaults.logger.warn("POST /__aimock/reset is deprecated; use /__aimock/reset/fixtures or /__aimock/reset/journal");
|
|
241
245
|
res.writeHead(200, {
|
|
@@ -528,12 +532,12 @@ async function handleCompletions(req, res, fixtures, journal, defaults, modelFal
|
|
|
528
532
|
}
|
|
529
533
|
});
|
|
530
534
|
if (body.stream !== true) {
|
|
531
|
-
const completion = buildContentWithToolCallsCompletion(response.content, response.toolCalls, body.model, effReasoning, overrides, body.messages);
|
|
535
|
+
const completion = buildContentWithToolCallsCompletion(response.content ?? "", response.toolCalls ?? [], body.model, effReasoning, overrides, body.messages);
|
|
532
536
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
533
537
|
res.end(JSON.stringify(completion));
|
|
534
538
|
} else {
|
|
535
|
-
const chunks = buildContentWithToolCallsChunks(response.content, response.toolCalls, body.model, chunkSize, effReasoning, overrides);
|
|
536
|
-
const completionText = response.content + response.toolCalls.map((tc) => tc.name + tc.arguments).join("");
|
|
539
|
+
const chunks = buildContentWithToolCallsChunks(response.content ?? "", response.toolCalls ?? [], body.model, chunkSize, effReasoning, overrides, response.blocks);
|
|
540
|
+
const completionText = (response.content ?? "") + (response.toolCalls ?? []).map((tc) => tc.name + tc.arguments).join("");
|
|
537
541
|
const usageChunk = includeUsage ? buildUsageChunk(chunks[0]?.id ?? "chatcmpl-unknown", overrides?.model ?? body.model, chunks[0]?.created ?? Math.floor(Date.now() / 1e3), overrides?.usage ? {
|
|
538
542
|
prompt_tokens: overrides.usage.prompt_tokens ?? 0,
|
|
539
543
|
completion_tokens: overrides.usage.completion_tokens ?? 0,
|
|
@@ -702,6 +706,12 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
702
706
|
},
|
|
703
707
|
get openRouterVideo() {
|
|
704
708
|
return serverOptions.openRouterVideo;
|
|
709
|
+
},
|
|
710
|
+
get veoVideo() {
|
|
711
|
+
return serverOptions.veoVideo;
|
|
712
|
+
},
|
|
713
|
+
get grokVideo() {
|
|
714
|
+
return serverOptions.grokVideo;
|
|
705
715
|
}
|
|
706
716
|
};
|
|
707
717
|
if (options?.chaos) {
|
|
@@ -721,13 +731,24 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
721
731
|
];
|
|
722
732
|
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`);
|
|
723
733
|
}
|
|
724
|
-
for (const { name, config } of [
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
734
|
+
for (const { name, config } of [
|
|
735
|
+
{
|
|
736
|
+
name: "falQueue",
|
|
737
|
+
config: options?.falQueue
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
name: "openRouterVideo",
|
|
741
|
+
config: options?.openRouterVideo
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: "veoVideo",
|
|
745
|
+
config: options?.veoVideo
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
name: "grokVideo",
|
|
749
|
+
config: options?.grokVideo
|
|
750
|
+
}
|
|
751
|
+
]) {
|
|
731
752
|
if (!config) continue;
|
|
732
753
|
for (const field of ["pollsBeforeInProgress", "pollsBeforeCompleted"]) {
|
|
733
754
|
const value = config[field];
|
|
@@ -746,6 +767,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
746
767
|
});
|
|
747
768
|
const videoStates = new VideoStateMap();
|
|
748
769
|
const openRouterVideoJobs = new OpenRouterVideoJobMap();
|
|
770
|
+
const veoVideoJobs = new VeoVideoJobMap();
|
|
771
|
+
const grokVideoJobs = new GrokVideoJobMap();
|
|
749
772
|
if (mounts) for (const { handler } of mounts) {
|
|
750
773
|
if (handler.setJournal) handler.setJournal(journal);
|
|
751
774
|
if (registry && handler.setRegistry) handler.setRegistry(registry);
|
|
@@ -792,7 +815,7 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
792
815
|
}
|
|
793
816
|
});
|
|
794
817
|
if (pathname.startsWith(CONTROL_PREFIX)) {
|
|
795
|
-
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, defaults);
|
|
818
|
+
await handleControlAPI(req, res, pathname, fixtures, journal, videoStates, openRouterVideoJobs, veoVideoJobs, grokVideoJobs, defaults);
|
|
796
819
|
return;
|
|
797
820
|
}
|
|
798
821
|
if (mounts) {
|
|
@@ -1237,6 +1260,36 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1237
1260
|
}
|
|
1238
1261
|
return;
|
|
1239
1262
|
}
|
|
1263
|
+
if (pathname === GROK_VIDEO_SUBMIT_PATH && req.method === "POST") {
|
|
1264
|
+
setCorsHeaders(res);
|
|
1265
|
+
try {
|
|
1266
|
+
await handleGrokVideoCreate(req, res, await readBody(req), fixtures, journal, defaults, setCorsHeaders, grokVideoJobs);
|
|
1267
|
+
} catch (err) {
|
|
1268
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
1269
|
+
defaults.logger.error(`grok-video submit: ${msg}`);
|
|
1270
|
+
if (!res.headersSent) {
|
|
1271
|
+
try {
|
|
1272
|
+
journal.add({
|
|
1273
|
+
method: req.method ?? "POST",
|
|
1274
|
+
path: req.url ?? pathname,
|
|
1275
|
+
headers: flattenHeaders(req.headers),
|
|
1276
|
+
body: null,
|
|
1277
|
+
response: {
|
|
1278
|
+
status: 500,
|
|
1279
|
+
fixture: null
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
} catch (jErr) {
|
|
1283
|
+
defaults.logger.warn(`grok-video submit: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
1284
|
+
}
|
|
1285
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
1286
|
+
message: msg,
|
|
1287
|
+
type: "server_error"
|
|
1288
|
+
} }));
|
|
1289
|
+
} else if (!res.writableEnded) res.destroy();
|
|
1290
|
+
}
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1240
1293
|
if (pathname === VIDEOS_PATH && req.method === "POST") {
|
|
1241
1294
|
try {
|
|
1242
1295
|
await handleVideoCreate(req, res, await readBody(req), fixtures, journal, defaults, setCorsHeaders, videoStates);
|
|
@@ -1250,10 +1303,95 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1250
1303
|
}
|
|
1251
1304
|
return;
|
|
1252
1305
|
}
|
|
1253
|
-
const
|
|
1254
|
-
if (
|
|
1255
|
-
|
|
1256
|
-
|
|
1306
|
+
const grokVideoStatusMatch = pathname.match(GROK_VIDEO_STATUS_RE);
|
|
1307
|
+
if (grokVideoStatusMatch && grokVideoStatusMatch[1] !== "generations" && req.method === "GET") {
|
|
1308
|
+
try {
|
|
1309
|
+
await handleGrokVideoStatus(req, res, grokVideoStatusMatch[1], fixtures, journal, defaults, setCorsHeaders, grokVideoJobs, videoStates);
|
|
1310
|
+
} catch (err) {
|
|
1311
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
1312
|
+
defaults.logger.error(`grok-video status: ${msg}`);
|
|
1313
|
+
if (!res.headersSent) {
|
|
1314
|
+
try {
|
|
1315
|
+
journal.add({
|
|
1316
|
+
method: req.method ?? "GET",
|
|
1317
|
+
path: req.url ?? pathname,
|
|
1318
|
+
headers: flattenHeaders(req.headers),
|
|
1319
|
+
body: null,
|
|
1320
|
+
response: {
|
|
1321
|
+
status: 500,
|
|
1322
|
+
fixture: null
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
} catch (jErr) {
|
|
1326
|
+
defaults.logger.warn(`grok-video status: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
1327
|
+
}
|
|
1328
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
1329
|
+
message: msg,
|
|
1330
|
+
type: "server_error"
|
|
1331
|
+
} }));
|
|
1332
|
+
} else if (!res.writableEnded) res.destroy();
|
|
1333
|
+
}
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const veoPredictMatch = pathname.match(VEO_PREDICT_LRO_RE);
|
|
1337
|
+
if (veoPredictMatch && req.method === "POST") {
|
|
1338
|
+
setCorsHeaders(res);
|
|
1339
|
+
try {
|
|
1340
|
+
await handleVeoVideoCreate(req, res, await readBody(req), veoPredictMatch[1], fixtures, journal, defaults, setCorsHeaders, veoVideoJobs);
|
|
1341
|
+
} catch (err) {
|
|
1342
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
1343
|
+
defaults.logger.error(`veo-video submit: ${msg}`);
|
|
1344
|
+
if (!res.headersSent) {
|
|
1345
|
+
try {
|
|
1346
|
+
journal.add({
|
|
1347
|
+
method: req.method ?? "POST",
|
|
1348
|
+
path: req.url ?? pathname,
|
|
1349
|
+
headers: flattenHeaders(req.headers),
|
|
1350
|
+
body: null,
|
|
1351
|
+
response: {
|
|
1352
|
+
status: 500,
|
|
1353
|
+
fixture: null
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
} catch (jErr) {
|
|
1357
|
+
defaults.logger.warn(`veo-video submit: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
1358
|
+
}
|
|
1359
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
1360
|
+
message: msg,
|
|
1361
|
+
type: "server_error"
|
|
1362
|
+
} }));
|
|
1363
|
+
} else if (!res.writableEnded) res.destroy();
|
|
1364
|
+
}
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
const veoOperationMatch = pathname.match(VEO_OPERATION_RE);
|
|
1368
|
+
if (veoOperationMatch && req.method === "GET") {
|
|
1369
|
+
try {
|
|
1370
|
+
await handleVeoVideoStatus(req, res, veoOperationMatch[1], fixtures, journal, defaults, setCorsHeaders, veoVideoJobs);
|
|
1371
|
+
} catch (err) {
|
|
1372
|
+
const msg = err instanceof Error ? err.message : "Internal error";
|
|
1373
|
+
defaults.logger.error(`veo-video status: ${msg}`);
|
|
1374
|
+
if (!res.headersSent) {
|
|
1375
|
+
try {
|
|
1376
|
+
journal.add({
|
|
1377
|
+
method: req.method ?? "GET",
|
|
1378
|
+
path: req.url ?? pathname,
|
|
1379
|
+
headers: flattenHeaders(req.headers),
|
|
1380
|
+
body: null,
|
|
1381
|
+
response: {
|
|
1382
|
+
status: 500,
|
|
1383
|
+
fixture: null
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
} catch (jErr) {
|
|
1387
|
+
defaults.logger.warn(`veo-video status: journal write failed after handler error: ${jErr instanceof Error ? jErr.message : String(jErr)}`);
|
|
1388
|
+
}
|
|
1389
|
+
writeErrorResponse(res, 500, JSON.stringify({ error: {
|
|
1390
|
+
message: msg,
|
|
1391
|
+
type: "server_error"
|
|
1392
|
+
} }));
|
|
1393
|
+
} else if (!res.writableEnded) res.destroy();
|
|
1394
|
+
}
|
|
1257
1395
|
return;
|
|
1258
1396
|
}
|
|
1259
1397
|
const geminiPredictMatch = pathname.match(GEMINI_PREDICT_RE);
|
|
@@ -1674,6 +1812,8 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1674
1812
|
activeConnections.clear();
|
|
1675
1813
|
videoStates.clear();
|
|
1676
1814
|
openRouterVideoJobs.clear();
|
|
1815
|
+
veoVideoJobs.clear();
|
|
1816
|
+
grokVideoJobs.clear();
|
|
1677
1817
|
originalClose(callback);
|
|
1678
1818
|
return this;
|
|
1679
1819
|
};
|
|
@@ -1695,7 +1835,9 @@ async function createServer(fixtures, options, mounts, serviceFixtures) {
|
|
|
1695
1835
|
url,
|
|
1696
1836
|
defaults,
|
|
1697
1837
|
videoStates,
|
|
1698
|
-
openRouterVideoJobs
|
|
1838
|
+
openRouterVideoJobs,
|
|
1839
|
+
veoVideoJobs,
|
|
1840
|
+
grokVideoJobs
|
|
1699
1841
|
});
|
|
1700
1842
|
});
|
|
1701
1843
|
});
|