@xiaohhhh1/canvas-agent 0.4.62 → 0.4.64
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.
|
@@ -30,11 +30,13 @@ type VideoArchiveUpload = {
|
|
|
30
30
|
publicUrl: string;
|
|
31
31
|
headers?: Record<string, string>;
|
|
32
32
|
maxBytes?: number;
|
|
33
|
+
alreadyUploaded?: boolean;
|
|
34
|
+
downloadUrl?: string | null;
|
|
33
35
|
};
|
|
34
36
|
export declare function shouldUploadVideoArchive(input: {
|
|
35
37
|
kind: "uploaded-mp4" | "tiktok";
|
|
36
38
|
url: string;
|
|
37
|
-
}, publicUrl: string): boolean;
|
|
39
|
+
}, publicUrl: string, alreadyUploaded?: boolean): boolean;
|
|
38
40
|
export declare class LocalVideoIntelligence {
|
|
39
41
|
private readonly fastmoss;
|
|
40
42
|
constructor(fastmoss: FastMossIntegration);
|
|
@@ -8,10 +8,10 @@ import { videoEvidenceTimestamps } from "../integrations/fastmoss.js";
|
|
|
8
8
|
const ANALYSIS_TIMEOUT_MS = 10 * 60_000;
|
|
9
9
|
const TRANSCRIPT_LANGUAGES = "en.*,es.*,zh.*,pt.*,fr.*,de.*,vi.*,th.*,id.*,ms.*,ja.*,ko.*";
|
|
10
10
|
const LOCAL_ASR_MODEL = "onnx-community/whisper-base";
|
|
11
|
-
const VIDEO_INTELLIGENCE_SCHEMA_VERSION = "commerce-video-intelligence-
|
|
11
|
+
const VIDEO_INTELLIGENCE_SCHEMA_VERSION = "commerce-video-intelligence-v6";
|
|
12
12
|
let localAsrPipeline;
|
|
13
|
-
export function shouldUploadVideoArchive(input, publicUrl) {
|
|
14
|
-
return input.kind !== "uploaded-mp4" || input.url !== publicUrl;
|
|
13
|
+
export function shouldUploadVideoArchive(input, publicUrl, alreadyUploaded = false) {
|
|
14
|
+
return !alreadyUploaded && (input.kind !== "uploaded-mp4" || input.url !== publicUrl);
|
|
15
15
|
}
|
|
16
16
|
export class LocalVideoIntelligence {
|
|
17
17
|
fastmoss;
|
|
@@ -19,7 +19,10 @@ export class LocalVideoIntelligence {
|
|
|
19
19
|
this.fastmoss = fastmoss;
|
|
20
20
|
}
|
|
21
21
|
async archive(source, upload) {
|
|
22
|
-
const
|
|
22
|
+
const verifiedInput = verifiedVideoLearningSource(source);
|
|
23
|
+
const input = upload?.downloadUrl
|
|
24
|
+
? { ...verifiedInput, url: verifiedHttpsUrl(upload.downloadUrl, "站内下载地址无效") }
|
|
25
|
+
: verifiedInput;
|
|
23
26
|
const uploadUrl = verifiedHttpsUrl(upload?.uploadUrl, "站内上传地址无效");
|
|
24
27
|
const publicUrl = verifiedHttpsUrl(upload?.publicUrl, "站内视频地址无效");
|
|
25
28
|
const maxBytes = Math.min(500 * 1024 * 1024, Math.max(1, Number(upload?.maxBytes || 100 * 1024 * 1024)));
|
|
@@ -29,7 +32,7 @@ export class LocalVideoIntelligence {
|
|
|
29
32
|
? await downloadUploadedMp4(input.url, workDir, maxBytes)
|
|
30
33
|
: await downloadVideoArchive(input.url, workDir, maxBytes);
|
|
31
34
|
const bytes = await readFile(downloaded.file);
|
|
32
|
-
if (shouldUploadVideoArchive(input, publicUrl)) {
|
|
35
|
+
if (shouldUploadVideoArchive(input, publicUrl, upload.alreadyUploaded)) {
|
|
33
36
|
const response = await fetch(uploadUrl, {
|
|
34
37
|
method: "PUT",
|
|
35
38
|
headers: { "Content-Type": "video/mp4" },
|
|
@@ -141,6 +144,7 @@ export function localVideoAnalysisPrompt(source, durationMs, transcript, attachm
|
|
|
141
144
|
`6. 目标是学习、融合、进化:只提炼可迁移机制,不复制原文案、人物、视觉资产或连续镜头顺序。\n` +
|
|
142
145
|
`7. 必须单独输出 creativeMutationProfile,识别这条视频怎样把普通商品变成反常但现实可拍的完整画面事件。mutationAxes 是开放维度,不是固定模板轮换;从实际证据判断人物身份/关系、场景错位、规模/数量、群体反应、角色反转、构图视角、感官材质、当地行为/审美和真实商品证明,也允许发现新的维度。\n` +
|
|
143
146
|
`8. culturalSignals 必须引用画面时间证据,说明当地行为、环境、幽默、地位符号、色彩/画面密度或消费场景怎样参与叙事,并写清迁移条件和避免刻板印象的方法。只出现当地字幕、旗帜或民族服装不等于理解了文化。\n\n` +
|
|
147
|
+
`9. 必须从画面、字幕和口播中判断视频实际售卖的具体商品与具体品类,并输出 productDetection。只写证据支持的名称;无法确认就把 productTitle/category 写成 null,并在 ambiguity 说明原因。未知绝不能写成 ALL、global、全品类或通用。applicability 只表示结构适用范围:category-specific、cross-category-structure 或 unclear,不能代替商品品类。\n\n` +
|
|
144
148
|
`样本:${JSON.stringify({
|
|
145
149
|
sourceUrl: source.sourceUrl || source.source_url,
|
|
146
150
|
platformVideoId: source.platformVideoId || source.platform_video_id,
|
|
@@ -157,6 +161,7 @@ export function localVideoAnalysisPrompt(source, durationMs, transcript, attachm
|
|
|
157
161
|
`只返回一个 JSON 对象,不要 Markdown。字段必须是:schemaVersion="${VIDEO_INTELLIGENCE_SCHEMA_VERSION}";durationMs;language;summary;` +
|
|
158
162
|
`sellingFormat{primary,label,secondary,rationale,evidence[{startMs,endMs,observation}],confidence};` +
|
|
159
163
|
`hook{startMs,endMs,visual,spokenText,onScreenText,patternInterrupt,openLoop};productFirstSeenMs;` +
|
|
164
|
+
`productDetection{productTitle,category,confidence,applicability,ambiguity,evidence[{startMs,endMs,observation}]};` +
|
|
160
165
|
`segments[{startMs,endMs,role,visual,spokenText,onScreenText,audio,editing,confidence}](至少2段);` +
|
|
161
166
|
`creativeMutationProfile{coreVisualPremise,mutationAxes[至少2项],culturalSignals[{market,signal,narrativeRole,aestheticRole,transferConditions,avoidStereotype,evidence[{startMs,endMs,observation}]}],firstFrameComposition,spectacleMechanism,productIntegration,captureProfile{subjectDominance,depthAndDensity,colorLightContrast,materialTexture,cameraEnergy,captureImperfections},transferableRule,culturalLimitations,doNotCopy,evidence[{startMs,endMs,observation}],confidence};` +
|
|
162
167
|
`mechanisms[{type,label,mechanism,whyItMayWork,evidence[{startMs,endMs,observation}],confidence,replicationRisk}](type 仅 hook/conflict/proof/pacing/trust/product-reveal/offer-framing/cta/audio/visual-grammar/environment/visual-mutation/culture-code/spectacle);` +
|