vidspotai-shared 1.0.55 → 1.0.57
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/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/google/google.service.js +35 -0
- package/lib/utils/errors.d.ts +24 -2
- package/lib/utils/errors.d.ts.map +1 -1
- package/lib/utils/errors.js +23 -3
- package/package.json +1 -1
- package/lib/globals/aiModels/providers/alibaba.d.ts +0 -4
- package/lib/globals/aiModels/providers/alibaba.d.ts.map +0 -1
- package/lib/globals/aiModels/providers/alibaba.js +0 -183
- package/lib/globals/aiModels/providers/elevenlabs.d.ts +0 -13
- package/lib/globals/aiModels/providers/elevenlabs.d.ts.map +0 -1
- package/lib/globals/aiModels/providers/elevenlabs.js +0 -25
- package/lib/globals/aiModels/providers/pixverseTemplates.d.ts +0 -36
- package/lib/globals/aiModels/providers/pixverseTemplates.d.ts.map +0 -1
- package/lib/globals/aiModels/providers/pixverseTemplates.js +0 -42
- package/lib/globals/aiModels/tierHelpers.d.ts +0 -27
- package/lib/globals/aiModels/tierHelpers.d.ts.map +0 -1
- package/lib/globals/aiModels/tierHelpers.js +0 -73
- package/lib/globals/ttsModels/providers/minimax.d.ts +0 -8
- package/lib/globals/ttsModels/providers/minimax.d.ts.map +0 -1
- package/lib/globals/ttsModels/providers/minimax.js +0 -18
- package/lib/globals/ttsModels/providers/openai.d.ts +0 -8
- package/lib/globals/ttsModels/providers/openai.d.ts.map +0 -1
- package/lib/globals/ttsModels/providers/openai.js +0 -18
- package/lib/models/agent.model.d.ts +0 -117
- package/lib/models/agent.model.d.ts.map +0 -1
- package/lib/models/agent.model.js +0 -13
- package/lib/models/cachedAsset.model.d.ts +0 -18
- package/lib/models/cachedAsset.model.d.ts.map +0 -1
- package/lib/models/cachedAsset.model.js +0 -2
- package/lib/models/cachedRawAsset.model.d.ts +0 -20
- package/lib/models/cachedRawAsset.model.d.ts.map +0 -1
- package/lib/models/cachedRawAsset.model.js +0 -2
- package/lib/schemas/agentPersona.schema.d.ts +0 -10
- package/lib/schemas/agentPersona.schema.d.ts.map +0 -1
- package/lib/schemas/agentPersona.schema.js +0 -11
- package/lib/schemas/brandKit.schema.d.ts +0 -101
- package/lib/schemas/brandKit.schema.d.ts.map +0 -1
- package/lib/schemas/brandKit.schema.js +0 -46
- package/lib/schemas/brief.schema.d.ts +0 -216
- package/lib/schemas/brief.schema.d.ts.map +0 -1
- package/lib/schemas/brief.schema.js +0 -118
- package/lib/schemas/index.d.ts +0 -6
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/index.js +0 -21
- package/lib/schemas/project.schema.d.ts +0 -1005
- package/lib/schemas/project.schema.d.ts.map +0 -1
- package/lib/schemas/project.schema.js +0 -238
- package/lib/schemas/videoPlan.schema.d.ts +0 -145
- package/lib/schemas/videoPlan.schema.d.ts.map +0 -1
- package/lib/schemas/videoPlan.schema.js +0 -109
- package/lib/services/agent/beatSnap.d.ts +0 -10
- package/lib/services/agent/beatSnap.d.ts.map +0 -1
- package/lib/services/agent/beatSnap.js +0 -128
- package/lib/services/agent/costPreflight.d.ts +0 -22
- package/lib/services/agent/costPreflight.d.ts.map +0 -1
- package/lib/services/agent/costPreflight.js +0 -75
- package/lib/services/agent/critic.d.ts +0 -103
- package/lib/services/agent/critic.d.ts.map +0 -1
- package/lib/services/agent/critic.js +0 -132
- package/lib/services/agent/eval/index.d.ts +0 -5
- package/lib/services/agent/eval/index.d.ts.map +0 -1
- package/lib/services/agent/eval/index.js +0 -20
- package/lib/services/agent/eval/judge.d.ts +0 -14
- package/lib/services/agent/eval/judge.d.ts.map +0 -1
- package/lib/services/agent/eval/judge.js +0 -95
- package/lib/services/agent/eval/recorder.d.ts +0 -17
- package/lib/services/agent/eval/recorder.d.ts.map +0 -1
- package/lib/services/agent/eval/recorder.js +0 -65
- package/lib/services/agent/eval/seedBriefs.d.ts +0 -16
- package/lib/services/agent/eval/seedBriefs.d.ts.map +0 -1
- package/lib/services/agent/eval/seedBriefs.js +0 -1188
- package/lib/services/agent/eval/types.d.ts +0 -196
- package/lib/services/agent/eval/types.d.ts.map +0 -1
- package/lib/services/agent/eval/types.js +0 -65
- package/lib/services/agent/executor.d.ts +0 -50
- package/lib/services/agent/executor.d.ts.map +0 -1
- package/lib/services/agent/executor.js +0 -188
- package/lib/services/agent/index.d.ts +0 -15
- package/lib/services/agent/index.d.ts.map +0 -1
- package/lib/services/agent/index.js +0 -30
- package/lib/services/agent/llmCaller.d.ts +0 -77
- package/lib/services/agent/llmCaller.d.ts.map +0 -1
- package/lib/services/agent/llmCaller.js +0 -16
- package/lib/services/agent/llmCallerGateway.d.ts +0 -39
- package/lib/services/agent/llmCallerGateway.d.ts.map +0 -1
- package/lib/services/agent/llmCallerGateway.js +0 -246
- package/lib/services/agent/llmCallerRegistry.d.ts +0 -4
- package/lib/services/agent/llmCallerRegistry.d.ts.map +0 -1
- package/lib/services/agent/llmCallerRegistry.js +0 -19
- package/lib/services/agent/modelRouter.d.ts +0 -41
- package/lib/services/agent/modelRouter.d.ts.map +0 -1
- package/lib/services/agent/modelRouter.js +0 -57
- package/lib/services/agent/musicSelect.d.ts +0 -23
- package/lib/services/agent/musicSelect.d.ts.map +0 -1
- package/lib/services/agent/musicSelect.js +0 -65
- package/lib/services/agent/personas.d.ts +0 -60
- package/lib/services/agent/personas.d.ts.map +0 -1
- package/lib/services/agent/personas.js +0 -156
- package/lib/services/agent/planner.d.ts +0 -56
- package/lib/services/agent/planner.d.ts.map +0 -1
- package/lib/services/agent/planner.js +0 -237
- package/lib/services/agent/toolRegistry.d.ts +0 -64
- package/lib/services/agent/toolRegistry.d.ts.map +0 -1
- package/lib/services/agent/toolRegistry.js +0 -78
- package/lib/services/agent/tools/analyzeReference.tool.d.ts +0 -36
- package/lib/services/agent/tools/analyzeReference.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/analyzeReference.tool.js +0 -44
- package/lib/services/agent/tools/animateImage.tool.d.ts +0 -23
- package/lib/services/agent/tools/animateImage.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/animateImage.tool.js +0 -58
- package/lib/services/agent/tools/animateImageWithMotionBrush.tool.d.ts +0 -30
- package/lib/services/agent/tools/animateImageWithMotionBrush.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/animateImageWithMotionBrush.tool.js +0 -90
- package/lib/services/agent/tools/composeScene.tool.d.ts +0 -948
- package/lib/services/agent/tools/composeScene.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/composeScene.tool.js +0 -90
- package/lib/services/agent/tools/estimateCost.tool.d.ts +0 -342
- package/lib/services/agent/tools/estimateCost.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/estimateCost.tool.js +0 -62
- package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts +0 -32
- package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/generateAvatarVideo.tool.js +0 -112
- package/lib/services/agent/tools/generateImage.tool.d.ts +0 -28
- package/lib/services/agent/tools/generateImage.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/generateImage.tool.js +0 -97
- package/lib/services/agent/tools/generateVideo.tool.d.ts +0 -30
- package/lib/services/agent/tools/generateVideo.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/generateVideo.tool.js +0 -84
- package/lib/services/agent/tools/generateVoiceover.tool.d.ts +0 -18
- package/lib/services/agent/tools/generateVoiceover.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/generateVoiceover.tool.js +0 -72
- package/lib/services/agent/tools/index.d.ts +0 -19
- package/lib/services/agent/tools/index.d.ts.map +0 -1
- package/lib/services/agent/tools/index.js +0 -34
- package/lib/services/agent/tools/planVideo.tool.d.ts +0 -191
- package/lib/services/agent/tools/planVideo.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/planVideo.tool.js +0 -46
- package/lib/services/agent/tools/render.tool.d.ts +0 -357
- package/lib/services/agent/tools/render.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/render.tool.js +0 -48
- package/lib/services/agent/tools/searchMusic.tool.d.ts +0 -49
- package/lib/services/agent/tools/searchMusic.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/searchMusic.tool.js +0 -74
- package/lib/services/agent/tools/searchStock.tool.d.ts +0 -37
- package/lib/services/agent/tools/searchStock.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/searchStock.tool.js +0 -101
- package/lib/services/agent/tools/searchUserLibrary.tool.d.ts +0 -59
- package/lib/services/agent/tools/searchUserLibrary.tool.d.ts.map +0 -1
- package/lib/services/agent/tools/searchUserLibrary.tool.js +0 -58
- package/lib/services/aiGen/canonicalAdapters/cameraControl.types.d.ts +0 -31
- package/lib/services/aiGen/canonicalAdapters/cameraControl.types.d.ts.map +0 -1
- package/lib/services/aiGen/canonicalAdapters/cameraControl.types.js +0 -2
- package/lib/services/aiGen/canonicalAdapters/index.d.ts +0 -3
- package/lib/services/aiGen/canonicalAdapters/index.d.ts.map +0 -1
- package/lib/services/aiGen/canonicalAdapters/index.js +0 -18
- package/lib/services/aiGen/canonicalAdapters/multiShot.types.d.ts +0 -23
- package/lib/services/aiGen/canonicalAdapters/multiShot.types.d.ts.map +0 -1
- package/lib/services/aiGen/canonicalAdapters/multiShot.types.js +0 -12
- package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts +0 -18
- package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts.map +0 -1
- package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.js +0 -100
- package/lib/services/aiGen/providers/fal/falImage.service.d.ts +0 -9
- package/lib/services/aiGen/providers/fal/falImage.service.d.ts.map +0 -1
- package/lib/services/aiGen/providers/fal/falImage.service.js +0 -102
- package/lib/services/aiGen/providers/fal/index.d.ts +0 -2
- package/lib/services/aiGen/providers/fal/index.d.ts.map +0 -1
- package/lib/services/aiGen/providers/fal/index.js +0 -17
- package/lib/services/aiGen/providers/kling/cameraAdapter.d.ts +0 -4
- package/lib/services/aiGen/providers/kling/cameraAdapter.d.ts.map +0 -1
- package/lib/services/aiGen/providers/kling/cameraAdapter.js +0 -53
- package/lib/services/aiGen/providers/pexels/index.d.ts +0 -2
- package/lib/services/aiGen/providers/pexels/index.d.ts.map +0 -1
- package/lib/services/aiGen/providers/pexels/index.js +0 -17
- package/lib/services/aiGen/providers/pexels/pexels.service.d.ts +0 -11
- package/lib/services/aiGen/providers/pexels/pexels.service.d.ts.map +0 -1
- package/lib/services/aiGen/providers/pexels/pexels.service.js +0 -118
- package/lib/services/aiGen/providers/runway/cameraAdapter.d.ts +0 -3
- package/lib/services/aiGen/providers/runway/cameraAdapter.d.ts.map +0 -1
- package/lib/services/aiGen/providers/runway/cameraAdapter.js +0 -46
- package/lib/services/asr/assemblyai.service.d.ts +0 -72
- package/lib/services/asr/assemblyai.service.d.ts.map +0 -1
- package/lib/services/asr/assemblyai.service.js +0 -89
- package/lib/services/asr/index.d.ts +0 -2
- package/lib/services/asr/index.d.ts.map +0 -1
- package/lib/services/asr/index.js +0 -17
- package/lib/services/assetCache.service.d.ts +0 -54
- package/lib/services/assetCache.service.d.ts.map +0 -1
- package/lib/services/assetCache.service.js +0 -96
- package/lib/services/audioAnalysis/index.d.ts +0 -2
- package/lib/services/audioAnalysis/index.d.ts.map +0 -1
- package/lib/services/audioAnalysis/index.js +0 -17
- package/lib/services/audioAnalysis/onsetDetection.service.d.ts +0 -50
- package/lib/services/audioAnalysis/onsetDetection.service.d.ts.map +0 -1
- package/lib/services/audioAnalysis/onsetDetection.service.js +0 -136
- package/lib/services/editor/designToProject.d.ts +0 -60
- package/lib/services/editor/designToProject.d.ts.map +0 -1
- package/lib/services/editor/designToProject.js +0 -194
- package/lib/services/musicGen/index.d.ts +0 -6
- package/lib/services/musicGen/index.d.ts.map +0 -1
- package/lib/services/musicGen/index.js +0 -26
- package/lib/services/musicGen/musicSearchFactory.service.d.ts +0 -14
- package/lib/services/musicGen/musicSearchFactory.service.d.ts.map +0 -1
- package/lib/services/musicGen/musicSearchFactory.service.js +0 -59
- package/lib/services/musicGen/providers/curated.service.d.ts +0 -22
- package/lib/services/musicGen/providers/curated.service.d.ts.map +0 -1
- package/lib/services/musicGen/providers/curated.service.js +0 -171
- package/lib/services/musicGen/providers/jamendo.service.d.ts +0 -8
- package/lib/services/musicGen/providers/jamendo.service.d.ts.map +0 -1
- package/lib/services/musicGen/providers/jamendo.service.js +0 -93
- package/lib/services/musicGen/providers/mubert.service.d.ts +0 -9
- package/lib/services/musicGen/providers/mubert.service.d.ts.map +0 -1
- package/lib/services/musicGen/providers/mubert.service.js +0 -113
- package/lib/services/musicGen/types.d.ts +0 -42
- package/lib/services/musicGen/types.d.ts.map +0 -1
- package/lib/services/musicGen/types.js +0 -10
- package/lib/services/tts/providers/minimax.service.d.ts +0 -14
- package/lib/services/tts/providers/minimax.service.d.ts.map +0 -1
- package/lib/services/tts/providers/minimax.service.js +0 -78
- package/lib/services/tts/providers/openai.service.d.ts +0 -14
- package/lib/services/tts/providers/openai.service.d.ts.map +0 -1
- package/lib/services/tts/providers/openai.service.js +0 -71
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { ChatRequest, ChatResponse, LlmCaller, StructuredRequest, StructuredResponse } from "./llmCaller";
|
|
3
|
-
/**
|
|
4
|
-
* Vercel AI Gateway LlmCaller — OpenAI-compatible /v1/chat/completions surface.
|
|
5
|
-
* Single endpoint, multi-provider routing via "{provider}/{modelId}" model id.
|
|
6
|
-
*
|
|
7
|
-
* No SDK dependency: pure fetch keeps the shared package light. Structured
|
|
8
|
-
* output uses JSON-schema response_format (supported by gateway across
|
|
9
|
-
* Anthropic / OpenAI / Google providers — gateway normalises it).
|
|
10
|
-
*/
|
|
11
|
-
export interface GatewayConfig {
|
|
12
|
-
/** Full base url, e.g. "https://ai-gateway.vercel.sh/v1". */
|
|
13
|
-
baseUrl: string;
|
|
14
|
-
/** Bearer token. */
|
|
15
|
-
apiKey: string;
|
|
16
|
-
/** Default request timeout in ms. */
|
|
17
|
-
timeoutMs?: number;
|
|
18
|
-
/** Optional fetch impl override (tests). */
|
|
19
|
-
fetchImpl?: typeof fetch;
|
|
20
|
-
}
|
|
21
|
-
export declare class GatewayLlmCaller implements LlmCaller {
|
|
22
|
-
private readonly cfg;
|
|
23
|
-
private readonly fetchImpl;
|
|
24
|
-
private readonly timeoutMs;
|
|
25
|
-
constructor(cfg: GatewayConfig);
|
|
26
|
-
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
27
|
-
structured<T extends z.ZodTypeAny>(req: StructuredRequest<T>): Promise<StructuredResponse<T>>;
|
|
28
|
-
structuredStream<T extends z.ZodTypeAny>(req: StructuredRequest<T>): {
|
|
29
|
-
tokens: AsyncIterable<string>;
|
|
30
|
-
result: Promise<StructuredResponse<T>>;
|
|
31
|
-
};
|
|
32
|
-
private createStreamingIterator;
|
|
33
|
-
private modelId;
|
|
34
|
-
private encodeMessage;
|
|
35
|
-
private toDataUri;
|
|
36
|
-
private usage;
|
|
37
|
-
private post;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=llmCallerGateway.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llmCallerGateway.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAYD,qBAAa,gBAAiB,YAAW,SAAS;IAIpC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEN,GAAG,EAAE,aAAa;IAKzC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAmB7C,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IA8CjC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB;QACD,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;YAoBc,uBAAuB;IAoHtC,OAAO,CAAC,OAAO;YAID,aAAa;YAqBb,SAAS;IAcvB,OAAO,CAAC,KAAK;YAQC,IAAI;CA2BnB"}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GatewayLlmCaller = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
class GatewayLlmCaller {
|
|
6
|
-
constructor(cfg) {
|
|
7
|
-
this.cfg = cfg;
|
|
8
|
-
this.fetchImpl = cfg.fetchImpl ?? fetch;
|
|
9
|
-
this.timeoutMs = cfg.timeoutMs ?? 60000;
|
|
10
|
-
}
|
|
11
|
-
async chat(req) {
|
|
12
|
-
const messages = await Promise.all(req.messages.map((m) => this.encodeMessage(m)));
|
|
13
|
-
const raw = await this.post({
|
|
14
|
-
model: this.modelId(req.model),
|
|
15
|
-
messages,
|
|
16
|
-
temperature: req.temperature,
|
|
17
|
-
max_tokens: req.maxTokens,
|
|
18
|
-
stop: req.stop,
|
|
19
|
-
});
|
|
20
|
-
const text = raw.choices?.[0]?.message?.content ?? "";
|
|
21
|
-
return {
|
|
22
|
-
text: typeof text === "string" ? text : JSON.stringify(text),
|
|
23
|
-
usage: this.usage(raw),
|
|
24
|
-
requestId: raw.id,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async structured(req) {
|
|
28
|
-
const jsonSchema = zod_1.z.toJSONSchema(req.schema, { target: "draft-7" });
|
|
29
|
-
const messages = await Promise.all(req.messages.map((m) => this.encodeMessage(m)));
|
|
30
|
-
const raw = await this.post({
|
|
31
|
-
model: this.modelId(req.model),
|
|
32
|
-
messages,
|
|
33
|
-
temperature: req.temperature,
|
|
34
|
-
max_tokens: req.maxTokens,
|
|
35
|
-
response_format: {
|
|
36
|
-
type: "json_schema",
|
|
37
|
-
json_schema: {
|
|
38
|
-
name: req.schemaName,
|
|
39
|
-
schema: jsonSchema,
|
|
40
|
-
strict: true,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
const txt = raw.choices?.[0]?.message?.content ?? "";
|
|
45
|
-
if (!txt || typeof txt !== "string") {
|
|
46
|
-
throw new Error(`GatewayLlmCaller.structured: empty response for schema ${req.schemaName}`);
|
|
47
|
-
}
|
|
48
|
-
let parsed;
|
|
49
|
-
try {
|
|
50
|
-
parsed = JSON.parse(txt);
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
throw new Error(`GatewayLlmCaller.structured: model returned non-JSON for schema ${req.schemaName}: ${txt.slice(0, 200)}`);
|
|
54
|
-
}
|
|
55
|
-
const result = req.schema.safeParse(parsed);
|
|
56
|
-
if (!result.success) {
|
|
57
|
-
throw new Error(`GatewayLlmCaller.structured: schema validation failed for ${req.schemaName}: ${result.error.message}`);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
data: result.data,
|
|
61
|
-
usage: this.usage(raw),
|
|
62
|
-
requestId: raw.id,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
structuredStream(req) {
|
|
66
|
-
// We fan one upstream stream out to two consumers: the caller iterates
|
|
67
|
-
// `tokens` to forward chunks to the UI, while we accumulate the same
|
|
68
|
-
// chunks into a buffer that we parse + Zod-validate at end-of-stream.
|
|
69
|
-
let resolveResult;
|
|
70
|
-
let rejectResult;
|
|
71
|
-
const result = new Promise((resolve, reject) => {
|
|
72
|
-
resolveResult = resolve;
|
|
73
|
-
rejectResult = reject;
|
|
74
|
-
});
|
|
75
|
-
const self = this;
|
|
76
|
-
const tokens = {
|
|
77
|
-
[Symbol.asyncIterator]() {
|
|
78
|
-
return self.createStreamingIterator(req, resolveResult, rejectResult);
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
return { tokens, result };
|
|
82
|
-
}
|
|
83
|
-
async *createStreamingIterator(req, resolveResult, rejectResult) {
|
|
84
|
-
const jsonSchema = zod_1.z.toJSONSchema(req.schema, { target: "draft-7" });
|
|
85
|
-
const messages = await Promise.all(req.messages.map((m) => this.encodeMessage(m)));
|
|
86
|
-
const ctrl = new AbortController();
|
|
87
|
-
const t = setTimeout(() => ctrl.abort(), this.timeoutMs);
|
|
88
|
-
let accumulated = "";
|
|
89
|
-
let requestId;
|
|
90
|
-
let usage;
|
|
91
|
-
try {
|
|
92
|
-
const res = await this.fetchImpl(`${this.cfg.baseUrl.replace(/\/$/, "")}/chat/completions`, {
|
|
93
|
-
method: "POST",
|
|
94
|
-
headers: {
|
|
95
|
-
"content-type": "application/json",
|
|
96
|
-
authorization: `Bearer ${this.cfg.apiKey}`,
|
|
97
|
-
},
|
|
98
|
-
body: JSON.stringify({
|
|
99
|
-
model: this.modelId(req.model),
|
|
100
|
-
messages,
|
|
101
|
-
temperature: req.temperature,
|
|
102
|
-
max_tokens: req.maxTokens,
|
|
103
|
-
stream: true,
|
|
104
|
-
response_format: {
|
|
105
|
-
type: "json_schema",
|
|
106
|
-
json_schema: {
|
|
107
|
-
name: req.schemaName,
|
|
108
|
-
schema: jsonSchema,
|
|
109
|
-
strict: true,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
signal: ctrl.signal,
|
|
114
|
-
});
|
|
115
|
-
if (!res.ok || !res.body) {
|
|
116
|
-
const text = await res.text().catch(() => "");
|
|
117
|
-
const err = new Error(`GatewayLlmCaller.structuredStream: ${res.status} ${res.statusText} — ${text.slice(0, 500)}`);
|
|
118
|
-
rejectResult(err);
|
|
119
|
-
throw err;
|
|
120
|
-
}
|
|
121
|
-
const reader = res.body.getReader();
|
|
122
|
-
const decoder = new TextDecoder();
|
|
123
|
-
let buf = "";
|
|
124
|
-
while (true) {
|
|
125
|
-
const { value, done } = await reader.read();
|
|
126
|
-
if (done)
|
|
127
|
-
break;
|
|
128
|
-
buf += decoder.decode(value, { stream: true });
|
|
129
|
-
let nl;
|
|
130
|
-
while ((nl = buf.indexOf("\n")) !== -1) {
|
|
131
|
-
const line = buf.slice(0, nl).trim();
|
|
132
|
-
buf = buf.slice(nl + 1);
|
|
133
|
-
if (!line || !line.startsWith("data:"))
|
|
134
|
-
continue;
|
|
135
|
-
const payload = line.slice(5).trim();
|
|
136
|
-
if (payload === "[DONE]")
|
|
137
|
-
break;
|
|
138
|
-
try {
|
|
139
|
-
const obj = JSON.parse(payload);
|
|
140
|
-
if (obj.id)
|
|
141
|
-
requestId = obj.id;
|
|
142
|
-
if (obj.usage) {
|
|
143
|
-
usage = {
|
|
144
|
-
promptTokens: obj.usage.prompt_tokens,
|
|
145
|
-
completionTokens: obj.usage.completion_tokens,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
const delta = obj.choices?.[0]?.delta?.content ?? "";
|
|
149
|
-
if (delta) {
|
|
150
|
-
accumulated += delta;
|
|
151
|
-
yield delta;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
// skip malformed line
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
let parsed;
|
|
160
|
-
try {
|
|
161
|
-
parsed = JSON.parse(accumulated);
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
const err = new Error(`GatewayLlmCaller.structuredStream: model returned non-JSON for ${req.schemaName}: ${accumulated.slice(0, 200)}`);
|
|
165
|
-
rejectResult(err);
|
|
166
|
-
throw err;
|
|
167
|
-
}
|
|
168
|
-
const validated = req.schema.safeParse(parsed);
|
|
169
|
-
if (!validated.success) {
|
|
170
|
-
const err = new Error(`GatewayLlmCaller.structuredStream: schema validation failed for ${req.schemaName}: ${validated.error.message}`);
|
|
171
|
-
rejectResult(err);
|
|
172
|
-
throw err;
|
|
173
|
-
}
|
|
174
|
-
resolveResult({ data: validated.data, usage, requestId });
|
|
175
|
-
}
|
|
176
|
-
catch (e) {
|
|
177
|
-
rejectResult(e);
|
|
178
|
-
throw e;
|
|
179
|
-
}
|
|
180
|
-
finally {
|
|
181
|
-
clearTimeout(t);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
modelId(m) {
|
|
185
|
-
return `${m.provider}/${m.modelId}`;
|
|
186
|
-
}
|
|
187
|
-
async encodeMessage(m) {
|
|
188
|
-
if (!m.imageUrls?.length) {
|
|
189
|
-
return { role: m.role, content: m.content };
|
|
190
|
-
}
|
|
191
|
-
// Fetch + base64-encode each URL into a data URI. The gateway's Anthropic
|
|
192
|
-
// translator rejects raw https URLs ("URL sources are not supported"); data
|
|
193
|
-
// URIs round-trip through every provider's OpenAI-compat shim correctly.
|
|
194
|
-
const dataUris = await Promise.all(m.imageUrls.map((u) => this.toDataUri(u)));
|
|
195
|
-
return {
|
|
196
|
-
role: m.role,
|
|
197
|
-
content: [
|
|
198
|
-
{ type: "text", text: m.content },
|
|
199
|
-
...dataUris.map((url) => ({ type: "image_url", image_url: { url } })),
|
|
200
|
-
],
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
async toDataUri(url) {
|
|
204
|
-
if (url.startsWith("data:"))
|
|
205
|
-
return url;
|
|
206
|
-
const res = await this.fetchImpl(url);
|
|
207
|
-
if (!res.ok) {
|
|
208
|
-
throw new Error(`GatewayLlmCaller.toDataUri: ${res.status} ${res.statusText} fetching ${url}`);
|
|
209
|
-
}
|
|
210
|
-
const contentType = res.headers.get("content-type")?.split(";")[0]?.trim() || "image/jpeg";
|
|
211
|
-
const buf = Buffer.from(await res.arrayBuffer());
|
|
212
|
-
return `data:${contentType};base64,${buf.toString("base64")}`;
|
|
213
|
-
}
|
|
214
|
-
usage(raw) {
|
|
215
|
-
if (!raw.usage)
|
|
216
|
-
return undefined;
|
|
217
|
-
return {
|
|
218
|
-
promptTokens: raw.usage.prompt_tokens,
|
|
219
|
-
completionTokens: raw.usage.completion_tokens,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
async post(body) {
|
|
223
|
-
const ctrl = new AbortController();
|
|
224
|
-
const t = setTimeout(() => ctrl.abort(), this.timeoutMs);
|
|
225
|
-
try {
|
|
226
|
-
const res = await this.fetchImpl(`${this.cfg.baseUrl.replace(/\/$/, "")}/chat/completions`, {
|
|
227
|
-
method: "POST",
|
|
228
|
-
headers: {
|
|
229
|
-
"content-type": "application/json",
|
|
230
|
-
authorization: `Bearer ${this.cfg.apiKey}`,
|
|
231
|
-
},
|
|
232
|
-
body: JSON.stringify(body),
|
|
233
|
-
signal: ctrl.signal,
|
|
234
|
-
});
|
|
235
|
-
if (!res.ok) {
|
|
236
|
-
const text = await res.text().catch(() => "");
|
|
237
|
-
throw new Error(`GatewayLlmCaller: ${res.status} ${res.statusText} — ${text.slice(0, 500)}`);
|
|
238
|
-
}
|
|
239
|
-
return (await res.json());
|
|
240
|
-
}
|
|
241
|
-
finally {
|
|
242
|
-
clearTimeout(t);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
exports.GatewayLlmCaller = GatewayLlmCaller;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llmCallerRegistry.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAY/D,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAEpD;AAED,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setLlmCaller = setLlmCaller;
|
|
4
|
-
exports.getLlmCaller = getLlmCaller;
|
|
5
|
-
const llmCaller_1 = require("./llmCaller");
|
|
6
|
-
/**
|
|
7
|
-
* Singleton LlmCaller accessor. Host wires a concrete impl at boot
|
|
8
|
-
* (e.g. GatewayLlmCaller); agent code reads via getLlmCaller().
|
|
9
|
-
*
|
|
10
|
-
* Throwing UnconfiguredLlmCaller is the default so tests fail loud
|
|
11
|
-
* if the host forgets to wire.
|
|
12
|
-
*/
|
|
13
|
-
let instance = new llmCaller_1.UnconfiguredLlmCaller();
|
|
14
|
-
function setLlmCaller(caller) {
|
|
15
|
-
instance = caller;
|
|
16
|
-
}
|
|
17
|
-
function getLlmCaller() {
|
|
18
|
-
return instance;
|
|
19
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model router — picks the right LLM per agent role.
|
|
3
|
-
*
|
|
4
|
-
* Roles split because their cost/quality profiles differ wildly:
|
|
5
|
-
* - router : single classification call, pick persona from first message
|
|
6
|
-
* - planner : structured-output, must produce valid VideoPlan
|
|
7
|
-
* - executor : narrow tool-routing loop, mostly mechanical
|
|
8
|
-
* - critic : vision QA across scenes, rubric-following
|
|
9
|
-
* - reference : ingest a TikTok/Reel URL, extract structure
|
|
10
|
-
*
|
|
11
|
-
* The actual LLM call is delegated to an injected LlmCaller (wired to
|
|
12
|
-
* Vercel AI Gateway / OpenRouter at the host layer) — this keeps the
|
|
13
|
-
* agent code provider-agnostic and easy to A/B test against the eval set.
|
|
14
|
-
*/
|
|
15
|
-
export type AgentRole = "router" | "planner" | "executor" | "critic" | "reference";
|
|
16
|
-
export interface ModelChoice {
|
|
17
|
-
/** Logical model id, e.g. "claude-sonnet-4.6", "claude-haiku-4.5", "gpt-5". */
|
|
18
|
-
modelId: string;
|
|
19
|
-
/** Provider key for the LLM gateway, e.g. "anthropic", "openai", "google". */
|
|
20
|
-
provider: string;
|
|
21
|
-
/** Vision input supported. */
|
|
22
|
-
vision?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface ModelRoutingPolicy {
|
|
25
|
-
/** Default per-role model. */
|
|
26
|
-
primary: Record<AgentRole, ModelChoice>;
|
|
27
|
-
/** Fallback if primary is unavailable / rate-limited. Optional per-role. */
|
|
28
|
-
fallback?: Partial<Record<AgentRole, ModelChoice>>;
|
|
29
|
-
/** Premium tier upgrade — Premium-budget briefs route planner to this model. */
|
|
30
|
-
premiumPlanner?: ModelChoice;
|
|
31
|
-
}
|
|
32
|
-
export declare const DEFAULT_MODEL_ROUTING: ModelRoutingPolicy;
|
|
33
|
-
export declare class ModelRouter {
|
|
34
|
-
private readonly policy;
|
|
35
|
-
constructor(policy?: ModelRoutingPolicy);
|
|
36
|
-
pickFor(role: AgentRole, opts?: {
|
|
37
|
-
premium?: boolean;
|
|
38
|
-
}): ModelChoice;
|
|
39
|
-
fallbackFor(role: AgentRole): ModelChoice | undefined;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=modelRouter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modelRouter.d.ts","sourceRoot":"","sources":["../../../src/services/agent/modelRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACxC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IACnD,gFAAgF;IAChF,cAAc,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,eAAO,MAAM,qBAAqB,EAAE,kBAwBnC,CAAC;AAEF,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,GAAE,kBAA0C;IAE/E,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,WAAW;IAOnE,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS;CAGtD"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Model router — picks the right LLM per agent role.
|
|
4
|
-
*
|
|
5
|
-
* Roles split because their cost/quality profiles differ wildly:
|
|
6
|
-
* - router : single classification call, pick persona from first message
|
|
7
|
-
* - planner : structured-output, must produce valid VideoPlan
|
|
8
|
-
* - executor : narrow tool-routing loop, mostly mechanical
|
|
9
|
-
* - critic : vision QA across scenes, rubric-following
|
|
10
|
-
* - reference : ingest a TikTok/Reel URL, extract structure
|
|
11
|
-
*
|
|
12
|
-
* The actual LLM call is delegated to an injected LlmCaller (wired to
|
|
13
|
-
* Vercel AI Gateway / OpenRouter at the host layer) — this keeps the
|
|
14
|
-
* agent code provider-agnostic and easy to A/B test against the eval set.
|
|
15
|
-
*/
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ModelRouter = exports.DEFAULT_MODEL_ROUTING = void 0;
|
|
18
|
-
exports.DEFAULT_MODEL_ROUTING = {
|
|
19
|
-
primary: {
|
|
20
|
-
router: { modelId: "claude-haiku-4-5", provider: "anthropic" },
|
|
21
|
-
planner: { modelId: "claude-sonnet-4-6", provider: "anthropic" },
|
|
22
|
-
executor: { modelId: "claude-haiku-4-5", provider: "anthropic" },
|
|
23
|
-
critic: {
|
|
24
|
-
modelId: "claude-sonnet-4-6",
|
|
25
|
-
provider: "anthropic",
|
|
26
|
-
vision: true,
|
|
27
|
-
},
|
|
28
|
-
reference: {
|
|
29
|
-
modelId: "gemini-2.5-pro",
|
|
30
|
-
provider: "google",
|
|
31
|
-
vision: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
fallback: {
|
|
35
|
-
router: { modelId: "gpt-5-mini", provider: "openai" },
|
|
36
|
-
planner: { modelId: "gpt-5", provider: "openai" },
|
|
37
|
-
executor: { modelId: "deepseek-chat", provider: "deepseek" },
|
|
38
|
-
critic: { modelId: "gpt-5", provider: "openai", vision: true },
|
|
39
|
-
reference: { modelId: "claude-sonnet-4-6", provider: "anthropic" },
|
|
40
|
-
},
|
|
41
|
-
premiumPlanner: { modelId: "claude-opus-4-7", provider: "anthropic" },
|
|
42
|
-
};
|
|
43
|
-
class ModelRouter {
|
|
44
|
-
constructor(policy = exports.DEFAULT_MODEL_ROUTING) {
|
|
45
|
-
this.policy = policy;
|
|
46
|
-
}
|
|
47
|
-
pickFor(role, opts) {
|
|
48
|
-
if (role === "planner" && opts?.premium && this.policy.premiumPlanner) {
|
|
49
|
-
return this.policy.premiumPlanner;
|
|
50
|
-
}
|
|
51
|
-
return this.policy.primary[role];
|
|
52
|
-
}
|
|
53
|
-
fallbackFor(role) {
|
|
54
|
-
return this.policy.fallback?.[role];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.ModelRouter = ModelRouter;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { VideoPlan } from "../../schemas/videoPlan.schema";
|
|
2
|
-
/**
|
|
3
|
-
* selectMusicForPlan — runs once after the planner returns and before the
|
|
4
|
-
* beat-snap pass, attaching a real track URL + bpm to plan.music.
|
|
5
|
-
*
|
|
6
|
-
* Why post-planner instead of letting the planner call search_music itself:
|
|
7
|
-
* the planner is a single structured-output call, not a tool-using agent.
|
|
8
|
-
* Adding a tool-call cycle here would double LLM latency and cost for a
|
|
9
|
-
* step that is fully mechanical — query string → provider → URL.
|
|
10
|
-
*
|
|
11
|
-
* No-ops when:
|
|
12
|
-
* - plan.music.strategy === "none"
|
|
13
|
-
* - plan.music.url is already set (user / brand kit pre-selected a track)
|
|
14
|
-
* - all music providers are unconfigured (curated catalog should always
|
|
15
|
-
* be available, so this branch should be rare in practice).
|
|
16
|
-
*
|
|
17
|
-
* On failure (no provider returns a hit) we leave plan.music.url unset and
|
|
18
|
-
* the snap pass falls back to BPM math; the editor can still attach music
|
|
19
|
-
* downstream. Not surfacing this as an error — music is enhancement, not
|
|
20
|
-
* a blocker.
|
|
21
|
-
*/
|
|
22
|
-
export declare function selectMusicForPlan(plan: VideoPlan): Promise<VideoPlan>;
|
|
23
|
-
//# sourceMappingURL=musicSelect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"musicSelect.d.ts","sourceRoot":"","sources":["../../../src/services/agent/musicSelect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAyC5E"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectMusicForPlan = selectMusicForPlan;
|
|
4
|
-
const audioAnalysis_1 = require("../audioAnalysis");
|
|
5
|
-
const musicGen_1 = require("../musicGen");
|
|
6
|
-
const beatSnap_1 = require("./beatSnap");
|
|
7
|
-
const personas_1 = require("./personas");
|
|
8
|
-
/**
|
|
9
|
-
* selectMusicForPlan — runs once after the planner returns and before the
|
|
10
|
-
* beat-snap pass, attaching a real track URL + bpm to plan.music.
|
|
11
|
-
*
|
|
12
|
-
* Why post-planner instead of letting the planner call search_music itself:
|
|
13
|
-
* the planner is a single structured-output call, not a tool-using agent.
|
|
14
|
-
* Adding a tool-call cycle here would double LLM latency and cost for a
|
|
15
|
-
* step that is fully mechanical — query string → provider → URL.
|
|
16
|
-
*
|
|
17
|
-
* No-ops when:
|
|
18
|
-
* - plan.music.strategy === "none"
|
|
19
|
-
* - plan.music.url is already set (user / brand kit pre-selected a track)
|
|
20
|
-
* - all music providers are unconfigured (curated catalog should always
|
|
21
|
-
* be available, so this branch should be rare in practice).
|
|
22
|
-
*
|
|
23
|
-
* On failure (no provider returns a hit) we leave plan.music.url unset and
|
|
24
|
-
* the snap pass falls back to BPM math; the editor can still attach music
|
|
25
|
-
* downstream. Not surfacing this as an error — music is enhancement, not
|
|
26
|
-
* a blocker.
|
|
27
|
-
*/
|
|
28
|
-
async function selectMusicForPlan(plan) {
|
|
29
|
-
if (!plan.music || plan.music.strategy === "none" || plan.music.url)
|
|
30
|
-
return plan;
|
|
31
|
-
const personaDefaultBpm = personas_1.PERSONA_PACKS[plan.persona]?.defaultBpm;
|
|
32
|
-
const bpmTarget = plan.music.bpm ?? personaDefaultBpm;
|
|
33
|
-
const totalSec = Math.ceil(plan.totalDurationMs / 1000);
|
|
34
|
-
const result = await (0, musicGen_1.searchAllMusicSources)({
|
|
35
|
-
query: plan.music.query,
|
|
36
|
-
mood: plan.music.moodTag,
|
|
37
|
-
bpmTarget,
|
|
38
|
-
durationSecMin: totalSec,
|
|
39
|
-
limit: 5,
|
|
40
|
-
});
|
|
41
|
-
const track = result.tracks[0];
|
|
42
|
-
if (!track)
|
|
43
|
-
return plan;
|
|
44
|
-
// Onset detection runs best-effort: timeout / disabled / WASM error all
|
|
45
|
-
// resolve to undefined and the snap pass falls back to BPM math. When it
|
|
46
|
-
// succeeds we get both a corrected BPM (essentia is more accurate than
|
|
47
|
-
// the provider's metadata) and a list of transient timestamps.
|
|
48
|
-
const onsetAnalysis = await (0, audioAnalysis_1.detectOnsets)(track.url);
|
|
49
|
-
return {
|
|
50
|
-
...plan,
|
|
51
|
-
music: {
|
|
52
|
-
...plan.music,
|
|
53
|
-
url: track.url,
|
|
54
|
-
bpm: onsetAnalysis?.bpm
|
|
55
|
-
?? track.bpm
|
|
56
|
-
?? plan.music.bpm
|
|
57
|
-
?? (0, beatSnap_1.resolveBpm)(plan)
|
|
58
|
-
?? personaDefaultBpm,
|
|
59
|
-
durationSec: track.durationSec,
|
|
60
|
-
source: track.source,
|
|
61
|
-
attribution: track.attribution,
|
|
62
|
-
onsets: onsetAnalysis?.onsets,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { AgentPersona, AgentPersonaSchema } from "../../schemas/agentPersona.schema";
|
|
2
|
-
import { LlmCaller } from "./llmCaller";
|
|
3
|
-
import { ModelRouter } from "./modelRouter";
|
|
4
|
-
export type { AgentPersona };
|
|
5
|
-
export { AgentPersonaSchema };
|
|
6
|
-
/**
|
|
7
|
-
* Vertical agent personas. Each persona = curated planner system prompt
|
|
8
|
-
* + recommended tier mix + critic rubric. Router LLM picks the persona
|
|
9
|
-
* from the user's first message (single classification call, Haiku-tier).
|
|
10
|
-
*
|
|
11
|
-
* Why personas: vertical specialisation is what makes a small model and
|
|
12
|
-
* a small team feel like a domain expert. invideo / Captions both win
|
|
13
|
-
* on this. v1 ships 5; v2 adds general + niche personas.
|
|
14
|
-
*/
|
|
15
|
-
export interface PersonaPack {
|
|
16
|
-
id: AgentPersona;
|
|
17
|
-
/** Short user-facing label. */
|
|
18
|
-
label: string;
|
|
19
|
-
/** Single-sentence pitch shown in persona picker. */
|
|
20
|
-
blurb: string;
|
|
21
|
-
/** Default brief axes the persona pre-fills (used when LLM confidence is low). */
|
|
22
|
-
defaults: {
|
|
23
|
-
aspect: "16:9" | "9:16" | "1:1";
|
|
24
|
-
durationSec: number;
|
|
25
|
-
tone: string;
|
|
26
|
-
pacing: "slow" | "medium" | "fast" | "very-fast";
|
|
27
|
-
hookStyle: string;
|
|
28
|
-
tierBudget: "T0" | "T1" | "T2" | "T3";
|
|
29
|
-
};
|
|
30
|
-
/** Planner system-prompt addendum: niche-specific structural priors. */
|
|
31
|
-
plannerPrompt: string;
|
|
32
|
-
/**
|
|
33
|
-
* Default BPM for the beat-snap pass when neither the user nor the planner
|
|
34
|
-
* specifies one. Personas where steady BPM cuts feel right (recap, UGC) set
|
|
35
|
-
* a value; cinematic / educational personas leave it undefined so cuts stay
|
|
36
|
-
* free-form.
|
|
37
|
-
*/
|
|
38
|
-
defaultBpm?: number;
|
|
39
|
-
/** Critic rubric weights (override the global judge). */
|
|
40
|
-
criticEmphasis: Partial<{
|
|
41
|
-
hookStrength: number;
|
|
42
|
-
voVisualSync: number;
|
|
43
|
-
pacingFit: number;
|
|
44
|
-
brandSafety: number;
|
|
45
|
-
costVsTier: number;
|
|
46
|
-
intentMatch: number;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
|
49
|
-
export declare const PERSONA_PACKS: Record<AgentPersona, PersonaPack>;
|
|
50
|
-
export declare class PersonaRouter {
|
|
51
|
-
private readonly llm;
|
|
52
|
-
private readonly router;
|
|
53
|
-
constructor(llm: LlmCaller, router?: ModelRouter);
|
|
54
|
-
route(rawPrompt: string): Promise<{
|
|
55
|
-
persona: AgentPersona;
|
|
56
|
-
confidence: number;
|
|
57
|
-
reason: string;
|
|
58
|
-
}>;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=personas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"personas.d.ts","sourceRoot":"","sources":["../../../src/services/agent/personas.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,YAAY,EAAE,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B;;;;;;;;GAQG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;QAChC,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;QACjD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;KACvC,CAAC;IACF,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,cAAc,EAAE,OAAO,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,YAAY,EAAE,WAAW,CA8G3D,CAAC;AAQF,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,GAAG,EAAE,SAAS,EACd,MAAM,GAAE,WAA+B;IAGpD,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACtC,OAAO,EAAE,YAAY,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CA2BH"}
|