@adminide-stack/yantra-mobile 12.0.121 → 12.0.123
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/features/apps/appArt.js +1 -1
- package/lib/features/apps/appArt.js.map +1 -1
- package/lib/features/apps/mobileAppCatalog.js +15 -11
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/canvas/CanvasAgentChatPane.js +82 -20
- package/lib/features/canvas/CanvasAgentChatPane.js.map +1 -1
- package/lib/features/canvas/CanvasBoardsGrid.js +291 -100
- package/lib/features/canvas/CanvasBoardsGrid.js.map +1 -1
- package/lib/features/canvas/CanvasEditToolsPanel.js +105 -12
- package/lib/features/canvas/CanvasEditToolsPanel.js.map +1 -1
- package/lib/features/canvas/CanvasExperience.js +266 -68
- package/lib/features/canvas/CanvasExperience.js.map +1 -1
- package/lib/features/canvas/CanvasGeneratePanel.js +204 -66
- package/lib/features/canvas/CanvasGeneratePanel.js.map +1 -1
- package/lib/features/canvas/CanvasLibrarySheet.js +31 -13
- package/lib/features/canvas/CanvasLibrarySheet.js.map +1 -1
- package/lib/features/canvas/CanvasModelPicker.js +176 -0
- package/lib/features/canvas/CanvasModelPicker.js.map +1 -0
- package/lib/features/canvas/CanvasTasksPanel.js +325 -29
- package/lib/features/canvas/CanvasTasksPanel.js.map +1 -1
- package/lib/features/canvas/CanvasTemplatesPanel.js +5 -4
- package/lib/features/canvas/CanvasTemplatesPanel.js.map +1 -1
- package/lib/features/canvas/CanvasToolDock.js +137 -61
- package/lib/features/canvas/CanvasToolDock.js.map +1 -1
- package/lib/features/canvas/FrameExtractorExperience.js +33 -2
- package/lib/features/canvas/FrameExtractorExperience.js.map +1 -1
- package/lib/features/canvas/GeneratorReferenceSlots.js +197 -0
- package/lib/features/canvas/GeneratorReferenceSlots.js.map +1 -0
- package/lib/features/canvas/NativeCanvasViewer.js +89 -11
- package/lib/features/canvas/NativeCanvasViewer.js.map +1 -1
- package/lib/features/canvas/PromoContextFields.js +55 -2
- package/lib/features/canvas/PromoContextFields.js.map +1 -1
- package/lib/features/canvas/SetStudioExperience.js +323 -13
- package/lib/features/canvas/SetStudioExperience.js.map +1 -1
- package/lib/features/canvas/VideoEditExperience.js +1 -53
- package/lib/features/canvas/VideoEditExperience.js.map +1 -1
- package/lib/features/canvas/VideoEditorExperience.js +697 -506
- package/lib/features/canvas/VideoEditorExperience.js.map +1 -1
- package/lib/features/canvas/VideoGeneratorExperience.js +22 -5
- package/lib/features/canvas/VideoGeneratorExperience.js.map +1 -1
- package/lib/features/canvas/canvasAgentChat.js +125 -11
- package/lib/features/canvas/canvasAgentChat.js.map +1 -1
- package/lib/features/canvas/canvasCore.js +117 -12
- package/lib/features/canvas/canvasCore.js.map +1 -1
- package/lib/features/canvas/canvasEditOps.js +148 -111
- package/lib/features/canvas/canvasEditOps.js.map +1 -1
- package/lib/features/canvas/canvasTaskSync.js +235 -0
- package/lib/features/canvas/canvasTaskSync.js.map +1 -0
- package/lib/features/canvas/canvasTasks.js +98 -11
- package/lib/features/canvas/canvasTasks.js.map +1 -1
- package/lib/features/canvas/createTiles.js +247 -0
- package/lib/features/canvas/createTiles.js.map +1 -0
- package/lib/features/canvas/deepLinks.js +83 -0
- package/lib/features/canvas/deepLinks.js.map +1 -0
- package/lib/features/canvas/frameExtract.js +13 -1
- package/lib/features/canvas/frameExtract.js.map +1 -1
- package/lib/features/canvas/generationModels.js +36 -8
- package/lib/features/canvas/generationModels.js.map +1 -1
- package/lib/features/canvas/generatorCommands.js +106 -0
- package/lib/features/canvas/generatorCommands.js.map +1 -0
- package/lib/features/canvas/generatorReferences.js +82 -0
- package/lib/features/canvas/generatorReferences.js.map +1 -0
- package/lib/features/canvas/homeWork.js +74 -0
- package/lib/features/canvas/homeWork.js.map +1 -0
- package/lib/features/canvas/linksRpc.js +130 -0
- package/lib/features/canvas/linksRpc.js.map +1 -0
- package/lib/features/canvas/mediaRecheck.js +176 -0
- package/lib/features/canvas/mediaRecheck.js.map +1 -0
- package/lib/features/canvas/mediaUrls.js +258 -0
- package/lib/features/canvas/mediaUrls.js.map +1 -0
- package/lib/features/canvas/nativeViewerRegistry.js.map +1 -1
- package/lib/features/canvas/promoProjectImport.js +80 -13
- package/lib/features/canvas/promoProjectImport.js.map +1 -1
- package/lib/features/canvas/promoVideo.js +106 -15
- package/lib/features/canvas/promoVideo.js.map +1 -1
- package/lib/features/canvas/reframe.js +228 -0
- package/lib/features/canvas/reframe.js.map +1 -0
- package/lib/features/canvas/serverTasks.js +697 -0
- package/lib/features/canvas/serverTasks.js.map +1 -0
- package/lib/features/canvas/set/SetViewportWebView.js +207 -28
- package/lib/features/canvas/set/SetViewportWebView.js.map +1 -1
- package/lib/features/canvas/set/agent/prompt.js +66 -0
- package/lib/features/canvas/set/agent/prompt.js.map +1 -0
- package/lib/features/canvas/set/agent/setOps.js +203 -0
- package/lib/features/canvas/set/agent/setOps.js.map +1 -0
- package/lib/features/canvas/set/agent/setTurn.js +128 -0
- package/lib/features/canvas/set/agent/setTurn.js.map +1 -0
- package/lib/features/canvas/set/agent/snapshot.js +43 -0
- package/lib/features/canvas/set/agent/snapshot.js.map +1 -0
- package/lib/features/canvas/set/agent/tools.js +580 -0
- package/lib/features/canvas/set/agent/tools.js.map +1 -0
- package/lib/features/canvas/set/setProject.js +43 -4
- package/lib/features/canvas/set/setProject.js.map +1 -1
- package/lib/features/canvas/set/supplyLibrary.js +397 -0
- package/lib/features/canvas/set/supplyLibrary.js.map +1 -0
- package/lib/features/canvas/storageLibrary.js +113 -52
- package/lib/features/canvas/storageLibrary.js.map +1 -1
- package/lib/features/canvas/studioCatalog.js +15 -2
- package/lib/features/canvas/studioCatalog.js.map +1 -1
- package/lib/features/canvas/studioLooks.js +1 -8
- package/lib/features/canvas/studioLooks.js.map +1 -1
- package/lib/features/canvas/useBoardMediaRefresh.js +66 -0
- package/lib/features/canvas/useBoardMediaRefresh.js.map +1 -0
- package/lib/features/canvas/useMediaSource.js +84 -0
- package/lib/features/canvas/useMediaSource.js.map +1 -0
- package/lib/features/canvas/video3d.js +11 -10
- package/lib/features/canvas/video3d.js.map +1 -1
- package/lib/features/canvas/videoEditor/BlurBoxOverlay.js +46 -0
- package/lib/features/canvas/videoEditor/BlurBoxOverlay.js.map +1 -0
- package/lib/features/canvas/videoEditor/ExportTaskCard.js +134 -0
- package/lib/features/canvas/videoEditor/ExportTaskCard.js.map +1 -0
- package/lib/features/canvas/videoEditor/agent/AgentCutPane.js +45 -7
- package/lib/features/canvas/videoEditor/agent/AgentCutPane.js.map +1 -1
- package/lib/features/canvas/videoEditor/agent/agentLoop.js +4 -2
- package/lib/features/canvas/videoEditor/agent/agentLoop.js.map +1 -1
- package/lib/features/canvas/videoEditor/agent/attachments.js +304 -0
- package/lib/features/canvas/videoEditor/agent/attachments.js.map +1 -0
- package/lib/features/canvas/videoEditor/agent/brainClient.js +3 -2
- package/lib/features/canvas/videoEditor/agent/brainClient.js.map +1 -1
- package/lib/features/canvas/videoEditor/agent/cutTools.js +207 -7
- package/lib/features/canvas/videoEditor/agent/cutTools.js.map +1 -1
- package/lib/features/canvas/videoEditor/blurBox.js +34 -0
- package/lib/features/canvas/videoEditor/blurBox.js.map +1 -0
- package/lib/features/canvas/videoEditor/compileTimeline.js +668 -0
- package/lib/features/canvas/videoEditor/compileTimeline.js.map +1 -0
- package/lib/features/canvas/videoEditor/editorModel.js +56 -22
- package/lib/features/canvas/videoEditor/editorModel.js.map +1 -1
- package/lib/features/canvas/videoEditor/exportPipeline.js +77 -0
- package/lib/features/canvas/videoEditor/exportPipeline.js.map +1 -0
- package/lib/features/canvas/videoEditor/exportRenderer.js +19 -12
- package/lib/features/canvas/videoEditor/exportRenderer.js.map +1 -1
- package/lib/features/canvas/videoEditor/exportTask.js +216 -0
- package/lib/features/canvas/videoEditor/exportTask.js.map +1 -0
- package/lib/features/canvas/videoEditor/formWidgets.js +142 -0
- package/lib/features/canvas/videoEditor/formWidgets.js.map +1 -0
- package/lib/features/canvas/videoEditor/produce/ProduceVideoSheet.js +195 -0
- package/lib/features/canvas/videoEditor/produce/ProduceVideoSheet.js.map +1 -0
- package/lib/features/canvas/videoEditor/produce/produceScenes.js +158 -0
- package/lib/features/canvas/videoEditor/produce/produceScenes.js.map +1 -0
- package/lib/features/canvas/videoEditor/remoteMediaClient.js +17 -5
- package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
- package/lib/features/canvas/videoEditor/renderTimeline.js +207 -0
- package/lib/features/canvas/videoEditor/renderTimeline.js.map +1 -0
- package/lib/features/canvas/videoEditor/renewLinks.js +64 -0
- package/lib/features/canvas/videoEditor/renewLinks.js.map +1 -0
- package/lib/features/canvas/videoEditor/sceneLayers.js +101 -0
- package/lib/features/canvas/videoEditor/sceneLayers.js.map +1 -0
- package/lib/features/canvas/videoEditor/tools/ToolsDrawer.js +283 -0
- package/lib/features/canvas/videoEditor/tools/ToolsDrawer.js.map +1 -0
- package/lib/features/canvas/videoEditor/tools/catalog.js +576 -0
- package/lib/features/canvas/videoEditor/tools/catalog.js.map +1 -0
- package/lib/features/canvas/videoEditor/videoProjectsStore.js +27 -3
- package/lib/features/canvas/videoEditor/videoProjectsStore.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +29 -1
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +8 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/codezenHandoff.js +108 -0
- package/lib/features/webbuilder/codezenHandoff.js.map +1 -0
- package/lib/features/webbuilder/workflow.js.map +1 -1
- package/lib/hooks/useChatApi.js +1 -2
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/screens/CanvasBoard/index.js +12 -1
- package/lib/screens/CanvasBoard/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/HomeSuggestions.js +3 -3
- package/lib/screens/Home/components/HomeSuggestions.js.map +1 -1
- package/lib/screens/WebBuilder/index.js +4 -2
- package/lib/screens/WebBuilder/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +29 -2
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +30 -6
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +3 -3
- /package/lib/assets/apps/{paper2poster.webp → poster.webp} +0 -0
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
import {PROMO_POLL_EVERY_MS,PRODUCE_STATUS_ACTION,PROMO_CONNECTOR,promoRunTimeoutMs}from'./promoVideo.js';import {deriveBackendGraphqlUrl,runActionAcceptsJob}from'./videoEditor/remoteMediaClient.js';import {tokenClaims}from'./sessionIdentity.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
const CANVAS_SURFACE = "canvas";
|
|
33
|
+
const PROMO_LANE = "promo";
|
|
34
|
+
const EXPORT_LANE = "video-export";
|
|
35
|
+
const LIPSYNC_LANE = "lipsync";
|
|
36
|
+
const SURFACE_JOB_KIND = "surface-job";
|
|
37
|
+
const DEADLINE_VERDICT_ERROR = "Stopped responding before it finished";
|
|
38
|
+
const JOB_DEADLINE_GRACE_MS = 10 * 6e4;
|
|
39
|
+
const AGENT_OWNED_GRACE_MS = 2 * 6e4;
|
|
40
|
+
const SERVER_JOB_BUDGET_MS = 2e3;
|
|
41
|
+
const LEGACY_JOB_DEADLINE_MS = 24 * 60 * 6e4;
|
|
42
|
+
const LIPSYNC_BUDGET_MS = 15 * 6e4;
|
|
43
|
+
const jobDeadlineAt = (startedAt, budgetMs) => startedAt + budgetMs + JOB_DEADLINE_GRACE_MS;
|
|
44
|
+
const jobKey = (job) => `${job.surface}:${job.id}`;
|
|
45
|
+
const canvasJobKey = (localId) => `${CANVAS_SURFACE}:${localId}`;
|
|
46
|
+
function jobDeadline(job) {
|
|
47
|
+
var _a;
|
|
48
|
+
return (_a = job.deadlineAt) != null ? _a : job.createdAt + LEGACY_JOB_DEADLINE_MS;
|
|
49
|
+
}
|
|
50
|
+
function isStaleJob(job, now = Date.now()) {
|
|
51
|
+
return job.state === "running" && now > jobDeadline(job);
|
|
52
|
+
}
|
|
53
|
+
const isDeadlineVerdict = (record) => record.state === "failed" && record.verdictBy === "deadline";
|
|
54
|
+
function jobBoardId(job) {
|
|
55
|
+
const handle = job.handle;
|
|
56
|
+
if (!handle) return void 0;
|
|
57
|
+
if (typeof handle.boardId === "string" && handle.boardId) return handle.boardId;
|
|
58
|
+
return handle.kind === "channel" && typeof handle.channelId === "string" && handle.channelId ? handle.channelId : void 0;
|
|
59
|
+
}
|
|
60
|
+
const isWebUrl = (value) => typeof value === "string" && /^https?:\/\//i.test(value);
|
|
61
|
+
const WIRE_FIELD_MAX_CHARS = 16 * 1024;
|
|
62
|
+
const fits = (value) => {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.stringify(value).length <= WIRE_FIELD_MAX_CHARS;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function browserDetails(job) {
|
|
70
|
+
const _a = job, {
|
|
71
|
+
remoteId: _remoteId,
|
|
72
|
+
agentOwned: _agentOwned,
|
|
73
|
+
verdictBy: _verdictBy,
|
|
74
|
+
result: _result,
|
|
75
|
+
hasResult: _hasResult,
|
|
76
|
+
resultUrl: _resultUrl,
|
|
77
|
+
updatedAt: _updatedAt,
|
|
78
|
+
results,
|
|
79
|
+
pageUrl,
|
|
80
|
+
input,
|
|
81
|
+
handle
|
|
82
|
+
} = _a, rest = __objRest(_a, [
|
|
83
|
+
"remoteId",
|
|
84
|
+
"agentOwned",
|
|
85
|
+
"verdictBy",
|
|
86
|
+
"result",
|
|
87
|
+
"hasResult",
|
|
88
|
+
"resultUrl",
|
|
89
|
+
"updatedAt",
|
|
90
|
+
"results",
|
|
91
|
+
"pageUrl",
|
|
92
|
+
"input",
|
|
93
|
+
"handle"
|
|
94
|
+
]);
|
|
95
|
+
const webResults = results == null ? void 0 : results.filter((r) => isWebUrl(r.url)).slice(0, 50);
|
|
96
|
+
const keptInput = input ? fits(input) ? input : input.prompt ? {
|
|
97
|
+
prompt: input.prompt.slice(0, 4e3)
|
|
98
|
+
} : void 0 : void 0;
|
|
99
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, rest), (webResults == null ? void 0 : webResults.length) ? {
|
|
100
|
+
results: webResults
|
|
101
|
+
} : {}), isWebUrl(pageUrl) ? {
|
|
102
|
+
pageUrl
|
|
103
|
+
} : {}), keptInput ? {
|
|
104
|
+
input: keptInput
|
|
105
|
+
} : {}), handle && fits(handle) ? {
|
|
106
|
+
handle
|
|
107
|
+
} : {});
|
|
108
|
+
}
|
|
109
|
+
function jobFingerprint(job) {
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
111
|
+
return JSON.stringify([job.state, job.title, job.brief, (_a = job.progress) != null ? _a : "", job.stage ? [job.stage.index, job.stage.total, job.stage.label, (_b = job.stage.detail) != null ? _b : ""] : null, (_c = job.results) != null ? _c : [], (_d = job.error) != null ? _d : "", (_e = job.delivered) != null ? _e : false, (_f = job.startedAt) != null ? _f : 0, (_g = job.endedAt) != null ? _g : 0]);
|
|
112
|
+
}
|
|
113
|
+
function jobStateFor(status) {
|
|
114
|
+
if (status === "COMPLETED") return "succeeded";
|
|
115
|
+
if (status === "IN_PROGRESS" || status === "NOT_STARTED") return "running";
|
|
116
|
+
return "failed";
|
|
117
|
+
}
|
|
118
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
119
|
+
const str = (v) => typeof v === "string" && v ? v : void 0;
|
|
120
|
+
function timestampMs(value) {
|
|
121
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
122
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
123
|
+
const ms = /^\d+$/.test(value) ? Number(value) : Date.parse(value);
|
|
124
|
+
return Number.isFinite(ms) ? ms : void 0;
|
|
125
|
+
}
|
|
126
|
+
function parseResults(v) {
|
|
127
|
+
if (!Array.isArray(v)) return void 0;
|
|
128
|
+
const out = [];
|
|
129
|
+
for (const item of v) {
|
|
130
|
+
if (!item || typeof item !== "object") continue;
|
|
131
|
+
const r = item;
|
|
132
|
+
const url = str(r.url);
|
|
133
|
+
if (!url) continue;
|
|
134
|
+
const kind = r.kind === "image" || r.kind === "video" || r.kind === "audio" || r.kind === "text" ? r.kind : "text";
|
|
135
|
+
out.push(__spreadValues({
|
|
136
|
+
url,
|
|
137
|
+
kind
|
|
138
|
+
}, str(r.title) ? {
|
|
139
|
+
title: str(r.title)
|
|
140
|
+
} : {}));
|
|
141
|
+
}
|
|
142
|
+
return out.length ? out : void 0;
|
|
143
|
+
}
|
|
144
|
+
function parseStage(v) {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
if (!v || typeof v !== "object") return void 0;
|
|
147
|
+
const s = v;
|
|
148
|
+
const label = str(s.label);
|
|
149
|
+
if (!label) return void 0;
|
|
150
|
+
return __spreadValues({
|
|
151
|
+
label,
|
|
152
|
+
index: (_a = num(s.index)) != null ? _a : 1,
|
|
153
|
+
total: Math.max(1, (_b = num(s.total)) != null ? _b : 1)
|
|
154
|
+
}, str(s.detail) ? {
|
|
155
|
+
detail: str(s.detail)
|
|
156
|
+
} : {});
|
|
157
|
+
}
|
|
158
|
+
function parseInput(v) {
|
|
159
|
+
if (!v || typeof v !== "object") return void 0;
|
|
160
|
+
const i = v;
|
|
161
|
+
const refs = Array.isArray(i.references) ? i.references.filter((r) => typeof r === "string" && !!r) : [];
|
|
162
|
+
const input = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, str(i.prompt) ? {
|
|
163
|
+
prompt: str(i.prompt)
|
|
164
|
+
} : {}), str(i.model) ? {
|
|
165
|
+
model: str(i.model)
|
|
166
|
+
} : {}), str(i.aspectRatio) ? {
|
|
167
|
+
aspectRatio: str(i.aspectRatio)
|
|
168
|
+
} : {}), refs.length ? {
|
|
169
|
+
references: refs
|
|
170
|
+
} : {}), str(i.connector) ? {
|
|
171
|
+
connector: str(i.connector)
|
|
172
|
+
} : {}), str(i.action) ? {
|
|
173
|
+
action: str(i.action)
|
|
174
|
+
} : {}), i.params && typeof i.params === "object" ? {
|
|
175
|
+
params: i.params
|
|
176
|
+
} : {});
|
|
177
|
+
return Object.keys(input).length ? input : void 0;
|
|
178
|
+
}
|
|
179
|
+
function jobFromTaskRow(row) {
|
|
180
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
181
|
+
const details = (_a = row == null ? void 0 : row.source) == null ? void 0 : _a.details;
|
|
182
|
+
if (!details || typeof details !== "object") return null;
|
|
183
|
+
const d = details;
|
|
184
|
+
if (d.kind !== SURFACE_JOB_KIND) return null;
|
|
185
|
+
const id = str(d.id);
|
|
186
|
+
const surface = str(d.surface);
|
|
187
|
+
if (!id || !surface) return null;
|
|
188
|
+
const stored = str(d.state);
|
|
189
|
+
const state = (row == null ? void 0 : row.status) ? jobStateFor(row.status) : stored === "running" || stored === "succeeded" || stored === "failed" ? stored : "running";
|
|
190
|
+
const createdAt = (_c = (_b = num(d.createdAt)) != null ? _b : timestampMs(row == null ? void 0 : row.createdAt)) != null ? _c : 0;
|
|
191
|
+
const results = parseResults(d.results);
|
|
192
|
+
const stage = parseStage(d.stage);
|
|
193
|
+
const input = parseInput(d.input);
|
|
194
|
+
const handle = d.handle && typeof d.handle === "object" ? d.handle : void 0;
|
|
195
|
+
const verdictBy = d.verdictBy === "agent" || d.verdictBy === "browser" || d.verdictBy === "deadline" ? d.verdictBy : void 0;
|
|
196
|
+
const updatedAt = timestampMs(row == null ? void 0 : row.updatedAt);
|
|
197
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
198
|
+
id,
|
|
199
|
+
surface,
|
|
200
|
+
lane: (_d = str(d.lane)) != null ? _d : "job",
|
|
201
|
+
title: (_f = (_e = str(d.title)) != null ? _e : str(row == null ? void 0 : row.title)) != null ? _f : "Job",
|
|
202
|
+
brief: (_h = (_g = str(d.brief)) != null ? _g : str(row == null ? void 0 : row.description)) != null ? _h : "",
|
|
203
|
+
state,
|
|
204
|
+
createdAt
|
|
205
|
+
}, num(d.startedAt) !== void 0 ? {
|
|
206
|
+
startedAt: num(d.startedAt)
|
|
207
|
+
} : {}), num(d.endedAt) !== void 0 ? {
|
|
208
|
+
endedAt: num(d.endedAt)
|
|
209
|
+
} : {}), str(d.progress) ? {
|
|
210
|
+
progress: str(d.progress)
|
|
211
|
+
} : {}), stage ? {
|
|
212
|
+
stage
|
|
213
|
+
} : {}), results ? {
|
|
214
|
+
results
|
|
215
|
+
} : {}), str(d.error) ? {
|
|
216
|
+
error: str(d.error)
|
|
217
|
+
} : {}), d.delivered === true ? {
|
|
218
|
+
delivered: true
|
|
219
|
+
} : {}), str(d.owner) ? {
|
|
220
|
+
owner: str(d.owner)
|
|
221
|
+
} : {}), str(d.pageUrl) ? {
|
|
222
|
+
pageUrl: str(d.pageUrl)
|
|
223
|
+
} : {}), input ? {
|
|
224
|
+
input
|
|
225
|
+
} : {}), handle ? {
|
|
226
|
+
handle
|
|
227
|
+
} : {}), str(row == null ? void 0 : row.id) ? {
|
|
228
|
+
remoteId: str(row == null ? void 0 : row.id)
|
|
229
|
+
} : {}), num(d.deadlineAt) !== void 0 ? {
|
|
230
|
+
deadlineAt: num(d.deadlineAt)
|
|
231
|
+
} : {}), d.agentOwned === true ? {
|
|
232
|
+
agentOwned: true
|
|
233
|
+
} : {}), verdictBy ? {
|
|
234
|
+
verdictBy
|
|
235
|
+
} : {}), d.result !== void 0 && d.result !== null ? {
|
|
236
|
+
result: d.result
|
|
237
|
+
} : {}), d.hasResult === true ? {
|
|
238
|
+
hasResult: true
|
|
239
|
+
} : {}), str(d.resultUrl) ? {
|
|
240
|
+
resultUrl: str(d.resultUrl)
|
|
241
|
+
} : {}), updatedAt !== void 0 ? {
|
|
242
|
+
updatedAt
|
|
243
|
+
} : {});
|
|
244
|
+
}
|
|
245
|
+
function sortJobs(jobs) {
|
|
246
|
+
return [...jobs].sort((a, b) => {
|
|
247
|
+
const ra = a.state === "running" ? 0 : 1;
|
|
248
|
+
const rb = b.state === "running" ? 0 : 1;
|
|
249
|
+
return ra - rb || b.createdAt - a.createdAt;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const isExportTask = (task) => task.kind === "export" || task.kind === "video-export";
|
|
253
|
+
function canvasTaskToJob(task) {
|
|
254
|
+
var _a, _b, _c, _d;
|
|
255
|
+
const t = task;
|
|
256
|
+
const isExport = isExportTask(task);
|
|
257
|
+
const handle = (_a = t.handle) != null ? _a : {};
|
|
258
|
+
const request = (_b = t.request) != null ? _b : {};
|
|
259
|
+
const resultTitle = !isExport ? (_c = t.result) == null ? void 0 : _c.title : void 0;
|
|
260
|
+
return __spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
261
|
+
id: t.id,
|
|
262
|
+
surface: CANVAS_SURFACE,
|
|
263
|
+
lane: isExport ? EXPORT_LANE : PROMO_LANE,
|
|
264
|
+
title: t.title,
|
|
265
|
+
brief: t.brief,
|
|
266
|
+
state: t.state === "submitting" ? "running" : t.state,
|
|
267
|
+
createdAt: t.createdAt
|
|
268
|
+
}, t.startedAt ? {
|
|
269
|
+
startedAt: t.startedAt
|
|
270
|
+
} : {}), t.endedAt ? {
|
|
271
|
+
endedAt: t.endedAt
|
|
272
|
+
} : {}), t.lastLine ? {
|
|
273
|
+
progress: t.lastLine
|
|
274
|
+
} : {}), t.step ? {
|
|
275
|
+
stage: __spreadValues({}, t.step)
|
|
276
|
+
} : {}), ((_d = t.result) == null ? void 0 : _d.url) ? {
|
|
277
|
+
results: [__spreadValues({
|
|
278
|
+
url: t.result.url,
|
|
279
|
+
kind: isExport && request.media === "image" ? "image" : "video"
|
|
280
|
+
}, resultTitle ? {
|
|
281
|
+
title: resultTitle
|
|
282
|
+
} : {})]
|
|
283
|
+
} : {}), t.error ? {
|
|
284
|
+
error: t.error
|
|
285
|
+
} : {}), t.delivered ? {
|
|
286
|
+
delivered: true
|
|
287
|
+
} : {}), t.owner ? {
|
|
288
|
+
owner: t.owner
|
|
289
|
+
} : {}), {
|
|
290
|
+
input: isExport ? {
|
|
291
|
+
prompt: t.brief
|
|
292
|
+
} : {
|
|
293
|
+
prompt: t.brief,
|
|
294
|
+
params: request
|
|
295
|
+
},
|
|
296
|
+
handle: __spreadValues(__spreadValues(__spreadValues({
|
|
297
|
+
boardId: t.boardId
|
|
298
|
+
}, typeof handle.projectId === "string" ? {
|
|
299
|
+
projectId: handle.projectId
|
|
300
|
+
} : {}), typeof handle.sandboxId === "string" ? {
|
|
301
|
+
sandboxId: handle.sandboxId
|
|
302
|
+
} : {}), typeof handle.runId === "string" ? {
|
|
303
|
+
runId: handle.runId
|
|
304
|
+
} : {})
|
|
305
|
+
}), t.deadlineAt ? {
|
|
306
|
+
deadlineAt: t.deadlineAt
|
|
307
|
+
} : {}), t.verdictBy ? {
|
|
308
|
+
verdictBy: t.verdictBy
|
|
309
|
+
} : {});
|
|
310
|
+
}
|
|
311
|
+
const PROMO_FOLLOW_SLACK_MS = 15 * 6e4;
|
|
312
|
+
function promoFollowSpec(opts) {
|
|
313
|
+
return {
|
|
314
|
+
connector: PROMO_CONNECTOR,
|
|
315
|
+
action: PRODUCE_STATUS_ACTION,
|
|
316
|
+
params: {
|
|
317
|
+
projectId: "projectId",
|
|
318
|
+
sandboxId: "sandboxId"
|
|
319
|
+
},
|
|
320
|
+
interval_ms: PROMO_POLL_EVERY_MS,
|
|
321
|
+
deadline_ms: promoRunTimeoutMs(opts) + PROMO_FOLLOW_SLACK_MS,
|
|
322
|
+
state_key: "state",
|
|
323
|
+
succeeded: ["succeeded"],
|
|
324
|
+
failed: ["failed"]
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
const LIPSYNC_FOLLOW = {
|
|
328
|
+
connector: "yantra-audio",
|
|
329
|
+
action: "YANTRA_AUDIO_LIPSYNC_STATUS",
|
|
330
|
+
params: {
|
|
331
|
+
statusUrl: "statusUrl",
|
|
332
|
+
responseUrl: "responseUrl"
|
|
333
|
+
},
|
|
334
|
+
interval_ms: 5e3,
|
|
335
|
+
deadline_ms: 15 * 6e4,
|
|
336
|
+
state_key: "status",
|
|
337
|
+
succeeded: ["completed"],
|
|
338
|
+
failed: ["failed"]
|
|
339
|
+
};
|
|
340
|
+
const isSettledStatus = (status) => status === "COMPLETED" || status === "BLOCKED";
|
|
341
|
+
function createTaskApiTransport(token, graphqlUrl) {
|
|
342
|
+
return {
|
|
343
|
+
async post(query, variables = {}) {
|
|
344
|
+
var _a, _b;
|
|
345
|
+
const resp = await fetch(graphqlUrl, {
|
|
346
|
+
method: "POST",
|
|
347
|
+
headers: {
|
|
348
|
+
"content-type": "application/json",
|
|
349
|
+
authorization: `Bearer ${token}`
|
|
350
|
+
},
|
|
351
|
+
body: JSON.stringify({
|
|
352
|
+
query,
|
|
353
|
+
variables
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
const body = await resp.json().catch(() => ({}));
|
|
357
|
+
const text = ((_a = body.errors) != null ? _a : []).map((e) => e.message || "error").join("; ");
|
|
358
|
+
if (!resp.ok) throw new Error(`task api: HTTP ${resp.status}${text ? `: ${text}` : ""}`);
|
|
359
|
+
if ((_b = body.errors) == null ? void 0 : _b.length) throw new Error(`task api: ${text}`);
|
|
360
|
+
return body;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
let transport = null;
|
|
365
|
+
let owner;
|
|
366
|
+
function configureServerTasks(session) {
|
|
367
|
+
const graphqlUrl = session.indexUrl ? deriveBackendGraphqlUrl(session.indexUrl) : null;
|
|
368
|
+
transport = session.token && graphqlUrl ? createTaskApiTransport(session.token, graphqlUrl) : null;
|
|
369
|
+
const sub = tokenClaims(session.token).sub;
|
|
370
|
+
owner = typeof sub === "string" && sub ? sub : void 0;
|
|
371
|
+
}
|
|
372
|
+
const taskApiTransport = () => transport;
|
|
373
|
+
let missing = /* @__PURE__ */ new WeakMap();
|
|
374
|
+
const isMissing = (t, field) => {
|
|
375
|
+
var _a;
|
|
376
|
+
return ((_a = missing.get(t)) == null ? void 0 : _a.has(field)) === true;
|
|
377
|
+
};
|
|
378
|
+
function markMissing(t, field) {
|
|
379
|
+
var _a;
|
|
380
|
+
const set = (_a = missing.get(t)) != null ? _a : /* @__PURE__ */ new Set();
|
|
381
|
+
set.add(field);
|
|
382
|
+
missing.set(t, set);
|
|
383
|
+
}
|
|
384
|
+
const isMissingField = (err, field) => new RegExp(`Cannot query field ["']${field}["']`).test(err instanceof Error ? err.message : String(err != null ? err : ""));
|
|
385
|
+
async function optionalField(t, field, query, variables) {
|
|
386
|
+
var _a, _b;
|
|
387
|
+
if (isMissing(t, field)) return void 0;
|
|
388
|
+
try {
|
|
389
|
+
const res = await t.post(query, variables);
|
|
390
|
+
return (_b = (_a = res.data) == null ? void 0 : _a[field]) != null ? _b : null;
|
|
391
|
+
} catch (err) {
|
|
392
|
+
if (!isMissingField(err, field)) throw err;
|
|
393
|
+
markMissing(t, field);
|
|
394
|
+
return void 0;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const ROW = "id title description status createdAt updatedAt source { type id details }";
|
|
398
|
+
const RECORD = `mutation SurfaceJobRecord($job: JSON!) {
|
|
399
|
+
recordSurfaceJob(job: $job) { id status reportToken }
|
|
400
|
+
}`;
|
|
401
|
+
const PATCH = `mutation SurfaceJobPatch($id: ID!, $patch: JSON!) {
|
|
402
|
+
updateSurfaceJob(id: $id, patch: $patch)
|
|
403
|
+
}`;
|
|
404
|
+
const CLAIM = `mutation SurfaceJobClaim($id: ID!) {
|
|
405
|
+
claimSurfaceJobDelivery(id: $id)
|
|
406
|
+
}`;
|
|
407
|
+
const DELETE = `mutation SurfaceJobDelete($id: ID!) {
|
|
408
|
+
removeSurfaceJob(id: $id)
|
|
409
|
+
}`;
|
|
410
|
+
const LIST_OWN = `query SurfaceJobsOwn($surface: String, $limit: Int) {
|
|
411
|
+
getSurfaceJobs(surface: $surface, limit: $limit) { ${ROW} }
|
|
412
|
+
}`;
|
|
413
|
+
const READ_OWN = `query SurfaceJobOne($id: ID!) {
|
|
414
|
+
getSurfaceJob(id: $id) { ${ROW} }
|
|
415
|
+
}`;
|
|
416
|
+
async function recordSurfaceJob(t, job) {
|
|
417
|
+
const rec = await optionalField(t, "recordSurfaceJob", RECORD, {
|
|
418
|
+
job: browserDetails(job)
|
|
419
|
+
});
|
|
420
|
+
if (!rec || typeof rec.id !== "string" || !rec.id) return null;
|
|
421
|
+
return __spreadValues(__spreadValues({
|
|
422
|
+
remoteId: rec.id
|
|
423
|
+
}, typeof rec.status === "string" ? {
|
|
424
|
+
status: rec.status
|
|
425
|
+
} : {}), typeof rec.reportToken === "string" && rec.reportToken ? {
|
|
426
|
+
reportToken: rec.reportToken
|
|
427
|
+
} : {});
|
|
428
|
+
}
|
|
429
|
+
const PATCH_KEYS = ["progress", "stage", "results", "error", "delivered", "state", "startedAt", "endedAt", "title", "brief", "input", "handle", "deadlineAt"];
|
|
430
|
+
function surfaceJobPatch(job) {
|
|
431
|
+
const wire = browserDetails(job);
|
|
432
|
+
const patch = {};
|
|
433
|
+
for (const key of PATCH_KEYS) if (wire[key] !== void 0) patch[key] = wire[key];
|
|
434
|
+
return patch;
|
|
435
|
+
}
|
|
436
|
+
async function updateSurfaceJob(t, remoteId, patch) {
|
|
437
|
+
return await optionalField(t, "updateSurfaceJob", PATCH, {
|
|
438
|
+
id: remoteId,
|
|
439
|
+
patch
|
|
440
|
+
}) === true;
|
|
441
|
+
}
|
|
442
|
+
async function claimDelivery(t, remoteId) {
|
|
443
|
+
const value = await optionalField(t, "claimSurfaceJobDelivery", CLAIM, {
|
|
444
|
+
id: remoteId
|
|
445
|
+
});
|
|
446
|
+
return value === void 0 ? void 0 : value === true;
|
|
447
|
+
}
|
|
448
|
+
async function removeSurfaceJob(t, remoteId) {
|
|
449
|
+
return await optionalField(t, "removeSurfaceJob", DELETE, {
|
|
450
|
+
id: remoteId
|
|
451
|
+
}) === true;
|
|
452
|
+
}
|
|
453
|
+
function rowsOf(value) {
|
|
454
|
+
if (Array.isArray(value)) return value;
|
|
455
|
+
const data = value == null ? void 0 : value.data;
|
|
456
|
+
return Array.isArray(data) ? data : [];
|
|
457
|
+
}
|
|
458
|
+
async function listRemoteJobs(t, surface = CANVAS_SURFACE, limit = 100) {
|
|
459
|
+
const own = await optionalField(t, "getSurfaceJobs", LIST_OWN, {
|
|
460
|
+
surface,
|
|
461
|
+
limit
|
|
462
|
+
});
|
|
463
|
+
if (own === void 0) return [];
|
|
464
|
+
const jobs = [];
|
|
465
|
+
for (const row of rowsOf(own)) {
|
|
466
|
+
const job = jobFromTaskRow(row);
|
|
467
|
+
if (job && job.surface === surface) jobs.push(job);
|
|
468
|
+
}
|
|
469
|
+
return jobs;
|
|
470
|
+
}
|
|
471
|
+
async function getRemoteJob(t, remoteId) {
|
|
472
|
+
const row = await optionalField(t, "getSurfaceJob", READ_OWN, {
|
|
473
|
+
id: remoteId
|
|
474
|
+
});
|
|
475
|
+
if (row === void 0) return void 0;
|
|
476
|
+
return jobFromTaskRow(row);
|
|
477
|
+
}
|
|
478
|
+
const pendingJobs = /* @__PURE__ */ new Map();
|
|
479
|
+
const heldJobs = /* @__PURE__ */ new Map();
|
|
480
|
+
async function recordServerJob(t, job, budgetMs = SERVER_JOB_BUDGET_MS) {
|
|
481
|
+
let timer;
|
|
482
|
+
const outOfTime = new Promise((resolve) => {
|
|
483
|
+
timer = setTimeout(() => resolve(null), budgetMs);
|
|
484
|
+
});
|
|
485
|
+
try {
|
|
486
|
+
return await Promise.race([recordSurfaceJob(t, job).catch(() => null), outOfTime]);
|
|
487
|
+
} finally {
|
|
488
|
+
clearTimeout(timer);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function recordLocalJob(job, options = {}) {
|
|
492
|
+
const t = options.transport === void 0 ? transport : options.transport;
|
|
493
|
+
const key = jobKey(job);
|
|
494
|
+
if (!t) return Promise.resolve(null);
|
|
495
|
+
const recorded = recordServerJob(t, job, options.budgetMs).then((server) => {
|
|
496
|
+
if (!server) return null;
|
|
497
|
+
if (options.exists && !options.exists()) {
|
|
498
|
+
void removeSurfaceJob(t, server.remoteId).catch(() => void 0);
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
heldJobs.set(key, __spreadValues({
|
|
502
|
+
remoteId: server.remoteId
|
|
503
|
+
}, server.reportToken && !isSettledStatus(server.status) ? {
|
|
504
|
+
reportToken: server.reportToken
|
|
505
|
+
} : {}));
|
|
506
|
+
return server;
|
|
507
|
+
}).catch(() => null);
|
|
508
|
+
pendingJobs.set(key, recorded);
|
|
509
|
+
return recorded;
|
|
510
|
+
}
|
|
511
|
+
async function serverJobRef(key, extras = {}) {
|
|
512
|
+
await pendingJobs.get(key);
|
|
513
|
+
const held = heldJobs.get(key);
|
|
514
|
+
if (!(held == null ? void 0 : held.reportToken)) return void 0;
|
|
515
|
+
return __spreadValues(__spreadValues({
|
|
516
|
+
task_id: held.remoteId,
|
|
517
|
+
report_token: held.reportToken
|
|
518
|
+
}, extras.expects ? {
|
|
519
|
+
expects: extras.expects
|
|
520
|
+
} : {}), extras.follow ? {
|
|
521
|
+
follow: extras.follow
|
|
522
|
+
} : {});
|
|
523
|
+
}
|
|
524
|
+
async function lookupRemoteJobId(localId) {
|
|
525
|
+
var _a;
|
|
526
|
+
const t = transport;
|
|
527
|
+
if (!t) return void 0;
|
|
528
|
+
const jobs = await listRemoteJobs(t, CANVAS_SURFACE);
|
|
529
|
+
return (_a = jobs.find((job) => job.id === localId)) == null ? void 0 : _a.remoteId;
|
|
530
|
+
}
|
|
531
|
+
const serverJobId = (key) => {
|
|
532
|
+
var _a;
|
|
533
|
+
return (_a = heldJobs.get(key)) == null ? void 0 : _a.remoteId;
|
|
534
|
+
};
|
|
535
|
+
function forgetServerJob(key) {
|
|
536
|
+
pendingJobs.delete(key);
|
|
537
|
+
heldJobs.delete(key);
|
|
538
|
+
}
|
|
539
|
+
async function runWithJob(run, connector, action, params, job) {
|
|
540
|
+
if (job && runActionAcceptsJob(run)) {
|
|
541
|
+
return {
|
|
542
|
+
result: await run(connector, action, params, {
|
|
543
|
+
job
|
|
544
|
+
}),
|
|
545
|
+
handed: true
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
result: await run(connector, action, params),
|
|
550
|
+
handed: false
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
const AGENT_VERDICT_INTERVAL_MS = 5e3;
|
|
554
|
+
const MAX_READ_MISSES = 6;
|
|
555
|
+
async function awaitAgentVerdict(remoteId, options) {
|
|
556
|
+
const t = options.transport === void 0 ? transport : options.transport;
|
|
557
|
+
if (!t) return null;
|
|
558
|
+
const {
|
|
559
|
+
submittedAt,
|
|
560
|
+
deadlineAt,
|
|
561
|
+
intervalMs = AGENT_VERDICT_INTERVAL_MS,
|
|
562
|
+
graceMs = AGENT_OWNED_GRACE_MS,
|
|
563
|
+
onProgress,
|
|
564
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
565
|
+
now = () => Date.now()
|
|
566
|
+
} = options;
|
|
567
|
+
let misses = 0;
|
|
568
|
+
for (; ; ) {
|
|
569
|
+
await sleep(intervalMs);
|
|
570
|
+
let job;
|
|
571
|
+
try {
|
|
572
|
+
job = await getRemoteJob(t, remoteId);
|
|
573
|
+
misses = 0;
|
|
574
|
+
} catch (e) {
|
|
575
|
+
if (++misses >= MAX_READ_MISSES) return null;
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
if (!job) return null;
|
|
579
|
+
if (job.state !== "running") return job;
|
|
580
|
+
const at = now();
|
|
581
|
+
if (job.agentOwned) onProgress == null ? void 0 : onProgress(job);
|
|
582
|
+
else if (at - submittedAt >= graceMs) return null;
|
|
583
|
+
if (at >= deadlineAt) throw new Error(DEADLINE_VERDICT_ERROR);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function serverProgressLine(job) {
|
|
587
|
+
if (job.stage) {
|
|
588
|
+
const step = `Step ${job.stage.index} of ${job.stage.total}`;
|
|
589
|
+
return job.stage.detail ? `${step} \xB7 ${job.stage.detail}` : `${step} \xB7 ${job.stage.label}`;
|
|
590
|
+
}
|
|
591
|
+
return job.progress;
|
|
592
|
+
}
|
|
593
|
+
function promoVideoFromVerdict(job) {
|
|
594
|
+
var _a, _b, _c, _d, _e, _f;
|
|
595
|
+
const video = (_c = (_a = job.results) == null ? void 0 : _a.find((r) => r.kind === "video" && r.url)) != null ? _c : (_b = job.results) == null ? void 0 : _b.find((r) => r.url);
|
|
596
|
+
if (video) return __spreadValues({
|
|
597
|
+
url: video.url
|
|
598
|
+
}, video.title ? {
|
|
599
|
+
title: video.title
|
|
600
|
+
} : {});
|
|
601
|
+
const answer = (_d = job.result) != null ? _d : {};
|
|
602
|
+
const inner = answer.data && typeof answer.data === "object" ? answer.data : answer;
|
|
603
|
+
const nested = inner.result && typeof inner.result === "object" ? inner.result : inner;
|
|
604
|
+
const url = (_f = (_e = str(nested.url)) != null ? _e : str(nested.videoUrl)) != null ? _f : str(nested.video_url);
|
|
605
|
+
return url ? __spreadValues({
|
|
606
|
+
url
|
|
607
|
+
}, str(nested.title) ? {
|
|
608
|
+
title: str(nested.title)
|
|
609
|
+
} : {}) : void 0;
|
|
610
|
+
}
|
|
611
|
+
async function registerPromoJob(task, exists) {
|
|
612
|
+
const job = canvasTaskToJob(task);
|
|
613
|
+
const withOwner = owner ? __spreadProps(__spreadValues({}, job), {
|
|
614
|
+
owner
|
|
615
|
+
}) : job;
|
|
616
|
+
await recordLocalJob(withOwner, {
|
|
617
|
+
exists
|
|
618
|
+
});
|
|
619
|
+
return serverJobRef(canvasJobKey(task.id), {
|
|
620
|
+
follow: promoFollowSpec(task.request)
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function lipSyncVideoFromVerdict(verdict) {
|
|
624
|
+
var _a, _b, _c;
|
|
625
|
+
const fromResults = (_b = (_a = verdict.results) == null ? void 0 : _a.find((r) => r.kind === "video" && r.url)) == null ? void 0 : _b.url;
|
|
626
|
+
if (fromResults) return fromResults;
|
|
627
|
+
const answer = (_c = verdict.result) != null ? _c : {};
|
|
628
|
+
const inner = answer.data && typeof answer.data === "object" ? answer.data : answer;
|
|
629
|
+
return typeof inner.videoUrl === "string" ? inner.videoUrl : "";
|
|
630
|
+
}
|
|
631
|
+
let lipSeq = 0;
|
|
632
|
+
async function trackLipSync(input) {
|
|
633
|
+
var _a;
|
|
634
|
+
const id = `lipsync-${Date.now().toString(36)}-${(lipSeq++).toString(36)}`;
|
|
635
|
+
const createdAt = Date.now();
|
|
636
|
+
const base = __spreadValues(__spreadValues({
|
|
637
|
+
id,
|
|
638
|
+
surface: CANVAS_SURFACE,
|
|
639
|
+
lane: LIPSYNC_LANE,
|
|
640
|
+
title: "Lip sync",
|
|
641
|
+
brief: ((_a = input.text) == null ? void 0 : _a.trim()) || "Lip sync",
|
|
642
|
+
state: "running",
|
|
643
|
+
createdAt,
|
|
644
|
+
startedAt: createdAt,
|
|
645
|
+
deadlineAt: jobDeadlineAt(createdAt, LIPSYNC_BUDGET_MS),
|
|
646
|
+
input: __spreadProps(__spreadValues({}, input.text ? {
|
|
647
|
+
prompt: input.text
|
|
648
|
+
} : {}), {
|
|
649
|
+
connector: "yantra-audio",
|
|
650
|
+
action: "YANTRA_AUDIO_LIPSYNC_SUBMIT",
|
|
651
|
+
params: __spreadValues({
|
|
652
|
+
videoUrl: input.videoUrl
|
|
653
|
+
}, input.text ? {
|
|
654
|
+
text: input.text
|
|
655
|
+
} : {})
|
|
656
|
+
})
|
|
657
|
+
}, {}), owner ? {
|
|
658
|
+
owner
|
|
659
|
+
} : {});
|
|
660
|
+
const key = jobKey(base);
|
|
661
|
+
const server = await recordLocalJob(base).catch(() => null);
|
|
662
|
+
const job = server ? await serverJobRef(key, {
|
|
663
|
+
follow: LIPSYNC_FOLLOW,
|
|
664
|
+
expects: "media"
|
|
665
|
+
}) : void 0;
|
|
666
|
+
return __spreadProps(__spreadValues({
|
|
667
|
+
id
|
|
668
|
+
}, job ? {
|
|
669
|
+
job
|
|
670
|
+
} : {}), {
|
|
671
|
+
awaitAgent: (startedAt) => server ? awaitAgentVerdict(server.remoteId, {
|
|
672
|
+
submittedAt: startedAt,
|
|
673
|
+
deadlineAt: base.deadlineAt
|
|
674
|
+
}) : Promise.resolve(null),
|
|
675
|
+
settle: ({
|
|
676
|
+
videoUrl,
|
|
677
|
+
error
|
|
678
|
+
}) => {
|
|
679
|
+
const t = transport;
|
|
680
|
+
forgetServerJob(key);
|
|
681
|
+
if (!server || !t) return;
|
|
682
|
+
const done = __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, base), {
|
|
683
|
+
state: videoUrl ? "succeeded" : "failed",
|
|
684
|
+
endedAt: Date.now()
|
|
685
|
+
}), videoUrl ? {
|
|
686
|
+
results: [{
|
|
687
|
+
url: videoUrl,
|
|
688
|
+
kind: "video"
|
|
689
|
+
}],
|
|
690
|
+
delivered: true
|
|
691
|
+
} : {}), error ? {
|
|
692
|
+
error
|
|
693
|
+
} : {});
|
|
694
|
+
void updateSurfaceJob(t, server.remoteId, surfaceJobPatch(done)).catch(() => void 0);
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
}export{AGENT_OWNED_GRACE_MS,AGENT_VERDICT_INTERVAL_MS,CANVAS_SURFACE,DEADLINE_VERDICT_ERROR,EXPORT_LANE,JOB_DEADLINE_GRACE_MS,LEGACY_JOB_DEADLINE_MS,LIPSYNC_BUDGET_MS,LIPSYNC_FOLLOW,LIPSYNC_LANE,PROMO_FOLLOW_SLACK_MS,PROMO_LANE,SERVER_JOB_BUDGET_MS,SURFACE_JOB_KIND,awaitAgentVerdict,browserDetails,canvasJobKey,canvasTaskToJob,claimDelivery,configureServerTasks,createTaskApiTransport,forgetServerJob,getRemoteJob,isDeadlineVerdict,isExportTask,isSettledStatus,isStaleJob,jobBoardId,jobDeadline,jobDeadlineAt,jobFingerprint,jobFromTaskRow,jobKey,jobStateFor,lipSyncVideoFromVerdict,listRemoteJobs,lookupRemoteJobId,promoFollowSpec,promoVideoFromVerdict,recordLocalJob,recordServerJob,recordSurfaceJob,registerPromoJob,removeSurfaceJob,runWithJob,serverJobId,serverJobRef,serverProgressLine,sortJobs,surfaceJobPatch,taskApiTransport,trackLipSync,updateSurfaceJob};//# sourceMappingURL=serverTasks.js.map
|