@larkup/tool-video-intelligence 0.3.5 → 0.3.7
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/README.md +25 -6
- package/dist/agent.js +13 -2
- package/dist/client.d.ts +11 -1
- package/dist/client.js +20 -0
- package/dist/contracts.d.ts +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -4
- package/runtime/Dockerfile +18 -2
- package/runtime/app/model_configuration.py +8 -3
- package/runtime/app/services/brain.py +9 -7
- package/runtime/app/services/pipeline.py +11 -1
- package/runtime/app/services/vision.py +13 -0
- package/scripts/grant-cloud-credits.sh +2 -40
- package/scripts/manage-cloud-usage.sh +116 -0
- package/tool.manifest.json +1 -1
package/README.md
CHANGED
|
@@ -226,18 +226,37 @@ curl -X POST "$VIDEO_ENDPOINT/v1/admin/devices/$USER_ID/entitlement" \
|
|
|
226
226
|
-d '{"sourceMinutesPerMonth":60,"maxConcurrentJobs":1,"requestsPerMinute":60,"plan":"support-grant"}'
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
an
|
|
229
|
+
Use the support script to inspect or change an installation by the generated
|
|
230
|
+
user ID shown in Installed Tools. It calls the authenticated control plane and
|
|
231
|
+
does not write to a Neon database. `set`, `add`, and `remove` change the monthly
|
|
232
|
+
allowance; `reset` clears consumed minutes for the current billing period.
|
|
233
|
+
Meter corrections are rejected while the user has an active job so reserved
|
|
234
|
+
minutes cannot be lost.
|
|
234
235
|
|
|
235
236
|
```bash
|
|
236
237
|
export LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT='https://video.example.com'
|
|
237
238
|
export LARKUP_VIDEO_ADMIN_TOKEN='...'
|
|
238
|
-
|
|
239
|
+
|
|
240
|
+
# Read the current allowance and consumption.
|
|
241
|
+
bash scripts/manage-cloud-usage.sh status <user-id>
|
|
242
|
+
|
|
243
|
+
# Clear current-period consumption, preserving the monthly allowance.
|
|
244
|
+
bash scripts/manage-cloud-usage.sh reset <user-id>
|
|
245
|
+
|
|
246
|
+
# Set, add, or remove monthly source-minute allowance.
|
|
247
|
+
bash scripts/manage-cloud-usage.sh set <user-id> 120 support-grant
|
|
248
|
+
bash scripts/manage-cloud-usage.sh add <user-id> 60 support-grant
|
|
249
|
+
bash scripts/manage-cloud-usage.sh remove <user-id> 30 support-grant
|
|
250
|
+
|
|
251
|
+
# Correct the consumed-minute meter when support needs an exact adjustment.
|
|
252
|
+
bash scripts/manage-cloud-usage.sh usage-set <user-id> 15
|
|
253
|
+
bash scripts/manage-cloud-usage.sh usage-add <user-id> 5
|
|
254
|
+
bash scripts/manage-cloud-usage.sh usage-remove <user-id> 2.5
|
|
239
255
|
```
|
|
240
256
|
|
|
257
|
+
`grant-cloud-credits.sh <user-id> <minutes> [plan]` remains as a compatibility
|
|
258
|
+
alias for `manage-cloud-usage.sh set`.
|
|
259
|
+
|
|
241
260
|
`$USER_ID` is the generated ID shown in Installed Tools and included in the Resend support request. Each local Larkup installation receives a separate key, while DynamoDB stores only hashes of keys and installation identifiers plus aggregate usage.
|
|
242
261
|
|
|
243
262
|
Access codes remain available for support-issued or upgraded plans:
|
package/dist/agent.js
CHANGED
|
@@ -61,7 +61,7 @@ export const AGENT_TOOLS = [
|
|
|
61
61
|
method: 'queryVideoEvidence',
|
|
62
62
|
workflow: 'evidence-query',
|
|
63
63
|
evidenceInput: 'media-asset',
|
|
64
|
-
systemPromptFragment: 'Use this action for media questions. On every call, derive investigation from the user’s meaning in their own language: use focused for one local moment, temporal for a relationship or development across moments, and source when the answer must account for the recording as a whole. Set answer, compare, trace, enumerate, or synthesize according to the reasoning operation—not the video genre or a word list. If the user supplies a specific source time or range, put its resolved seconds in investigation.timeRange; otherwise omit it. For a source enumeration, set recordSet to source-authored for units authored in the recording, source-questions for only authored questions and their answers, observed for time-grounded observed facts, or all when both are needed. Choose source plus synthesize for the overall narrative. Focused questions use ranked evidence; source enumerations use a chronological database scan; source explanations use a durable navigation aggregate. Never turn a complete-source request into top-K retrieval. For an exhaustive result, follow continuation.nextCursor until hasMore=false; do not mistake one page for the complete answer. Never say you do not know or that the source lacks an answer before this action has attempted its available fallback. State a value, identity, count, or exact visible fact only when established. observedSubjects, when present, is the reconciled frame-grounded visibility ledger: use its ranges for visible-presence and timing claims, never speech, titles, or a source name. Its durations are observed intervals, not inferred continuous screen time. Answer as a viewer who remembers the material: lead with the answer itself, and when natural say "I saw" or "I heard" rather than describing a system. Do not say "the video shows", "the analysis indicates", or "according to retrieved evidence". Never mention retrieval, search, indexing, frames, tools, or analysis unless the user asks how the answer was found.',
|
|
64
|
+
systemPromptFragment: 'Use this action for media questions. On every call, derive investigation from the user’s meaning in their own language: use focused for one local moment, temporal for a relationship or development across moments, and source when the answer must account for the recording as a whole. Set answer, compare, trace, enumerate, or synthesize according to the reasoning operation—not the video genre or a word list. If the user supplies a specific source time or range, put its resolved seconds in investigation.timeRange; otherwise omit it. For a source enumeration, set recordSet to source-authored for units authored in the recording, source-questions for only authored questions and their answers, observed for time-grounded observed facts, or all when both are needed. For exact spoken or sung wording across the recording, use source plus enumerate, speech evidence, and recordSet all. Choose source plus synthesize for the overall narrative. Focused questions use ranked evidence; source enumerations use a chronological database scan; source explanations use a durable navigation aggregate. Never turn a complete-source request into top-K retrieval. For an exhaustive result, follow continuation.nextCursor until hasMore=false; do not mistake one page for the complete answer. Answer in the returned sourceLanguage by default, including notes, speech, and lyrics; translate only when the user explicitly asks. Never default to English. Never say you do not know or that the source lacks an answer before this action has attempted its available fallback. State a value, identity, count, or exact visible fact only when established. observedSubjects, when present, is the reconciled frame-grounded visibility ledger: use its ranges for visible-presence and timing claims, never speech, titles, or a source name. Its durations are observed intervals, not inferred continuous screen time. Answer as a viewer who remembers the material: lead with the answer itself, and when natural say "I saw" or "I heard" rather than describing a system. Do not say "the video shows", "the analysis indicates", or "according to retrieved evidence". Never mention retrieval, search, indexing, frames, tools, or analysis unless the user asks how the answer was found.',
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
name: 'inspectVideoKnowledge',
|
|
@@ -104,6 +104,7 @@ export function attachVideoIntelligenceAgentClient(client, fetcher = globalThis.
|
|
|
104
104
|
const asset = await mediaEvidence.getAsset(input.mediaAssetId);
|
|
105
105
|
if (!asset || asset.processingStatus !== 'completed')
|
|
106
106
|
return { success: false, error: 'A completed video asset is required.' };
|
|
107
|
+
const sourceLanguage = asset.sourceLanguage?.trim();
|
|
107
108
|
const focusedQuery = focusQuestion(input.query, asset.fileName);
|
|
108
109
|
const directive = validInvestigation(input.investigation)
|
|
109
110
|
? input.investigation
|
|
@@ -143,6 +144,9 @@ export function attachVideoIntelligenceAgentClient(client, fetcher = globalThis.
|
|
|
143
144
|
kind: sourceInventory ? 'source-inventory' : 'all-evidence',
|
|
144
145
|
cursor: input.cursor,
|
|
145
146
|
limit: input.limit,
|
|
147
|
+
...(!sourceInventory && (plan.modalities?.length ?? 0) > 0
|
|
148
|
+
? { modalities: plan.modalities }
|
|
149
|
+
: {}),
|
|
146
150
|
});
|
|
147
151
|
if (scanned) {
|
|
148
152
|
// A source inventory can contain headings, slides, and literal list
|
|
@@ -178,14 +182,18 @@ export function attachVideoIntelligenceAgentClient(client, fetcher = globalThis.
|
|
|
178
182
|
timestamp: new Date().toISOString(),
|
|
179
183
|
});
|
|
180
184
|
const observedSubjects = observedSubjectsForAnswer(aggregate, directive);
|
|
185
|
+
const recordSet = !sourceInventory && plan.modalities?.length === 1 && plan.modalities[0] === 'transcript'
|
|
186
|
+
? 'speech'
|
|
187
|
+
: (focusedInput.investigation.recordSet ?? 'all');
|
|
181
188
|
return {
|
|
182
189
|
success: true,
|
|
183
190
|
mediaAssetId: input.mediaAssetId,
|
|
184
191
|
fileName: asset.fileName,
|
|
192
|
+
...(sourceLanguage ? { sourceLanguage } : {}),
|
|
185
193
|
evidence,
|
|
186
194
|
...(observedSubjects.length > 0 ? { observedSubjects } : {}),
|
|
187
195
|
inventory: {
|
|
188
|
-
recordSet
|
|
196
|
+
recordSet,
|
|
189
197
|
coverage: {
|
|
190
198
|
complete,
|
|
191
199
|
...(scanned.coverage.reason ? { reason: scanned.coverage.reason } : {}),
|
|
@@ -300,6 +308,7 @@ export function attachVideoIntelligenceAgentClient(client, fetcher = globalThis.
|
|
|
300
308
|
success: true,
|
|
301
309
|
mediaAssetId: input.mediaAssetId,
|
|
302
310
|
fileName: asset.fileName,
|
|
311
|
+
...(sourceLanguage ? { sourceLanguage } : {}),
|
|
303
312
|
evidence: indexedEvidence,
|
|
304
313
|
supportingClip,
|
|
305
314
|
ui: citationSurface(asset, context, established.map((reading) => ({
|
|
@@ -412,6 +421,7 @@ export function attachVideoIntelligenceAgentClient(client, fetcher = globalThis.
|
|
|
412
421
|
success: true,
|
|
413
422
|
mediaAssetId: input.mediaAssetId,
|
|
414
423
|
fileName: asset.fileName,
|
|
424
|
+
...(sourceLanguage ? { sourceLanguage } : {}),
|
|
415
425
|
evidence,
|
|
416
426
|
...(supportingClip ? { supportingClip } : {}),
|
|
417
427
|
...(assessment.sufficient && supportingClip
|
|
@@ -513,6 +523,7 @@ function investigationDirectiveForOutput(directive) {
|
|
|
513
523
|
return {
|
|
514
524
|
scope: directive.scope,
|
|
515
525
|
goal: directive.goal,
|
|
526
|
+
...(directive.evidence?.length ? { evidence: directive.evidence } : {}),
|
|
516
527
|
...(directive.recordSet ? { recordSet: directive.recordSet } : {}),
|
|
517
528
|
...(directive.timeRange ? { timeRange: directive.timeRange } : {}),
|
|
518
529
|
};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubmitVideoJobRequest, VideoIntelligenceClientContract, VideoJob, VideoRuntimeMode, VideoServiceEntitlement, VideoServiceUsage } from './contracts.js';
|
|
1
|
+
import type { SubmitVideoJobRequest, VideoIntelligenceClientContract, VideoJob, VideoMaterializationJob, VideoRuntimeMode, VideoServiceEntitlement, VideoServiceUsage } from './contracts.js';
|
|
2
2
|
export interface VideoIntelligenceClientOptions {
|
|
3
3
|
mode: VideoRuntimeMode;
|
|
4
4
|
endpoint?: string;
|
|
@@ -38,6 +38,16 @@ export declare class VideoIntelligenceClient implements VideoIntelligenceClientC
|
|
|
38
38
|
alreadyStopped?: boolean;
|
|
39
39
|
}>;
|
|
40
40
|
getUsage(): Promise<VideoServiceUsage>;
|
|
41
|
+
submitMaterialization(request: {
|
|
42
|
+
sourceUrl: string;
|
|
43
|
+
fileName?: string;
|
|
44
|
+
durationSecs?: number;
|
|
45
|
+
}): Promise<VideoMaterializationJob>;
|
|
46
|
+
getMaterialization(jobId: string): Promise<VideoMaterializationJob>;
|
|
47
|
+
acknowledgeMaterialization(jobId: string): Promise<{
|
|
48
|
+
status: string;
|
|
49
|
+
}>;
|
|
50
|
+
cancelMaterialization(jobId: string): Promise<VideoMaterializationJob>;
|
|
41
51
|
redeemAccessCode(code: string): Promise<{
|
|
42
52
|
apiKey: string;
|
|
43
53
|
entitlement: VideoServiceEntitlement;
|
package/dist/client.js
CHANGED
|
@@ -94,6 +94,26 @@ export class VideoIntelligenceClient {
|
|
|
94
94
|
getUsage() {
|
|
95
95
|
return this.request('/v1/usage');
|
|
96
96
|
}
|
|
97
|
+
submitMaterialization(request) {
|
|
98
|
+
return this.request('/v1/materializations', {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
body: JSON.stringify(request),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getMaterialization(jobId) {
|
|
104
|
+
return this.request(`/v1/materializations/${encodeURIComponent(jobId)}`);
|
|
105
|
+
}
|
|
106
|
+
acknowledgeMaterialization(jobId) {
|
|
107
|
+
return this.request(`/v1/materializations/${encodeURIComponent(jobId)}/ack`, {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
body: JSON.stringify({}),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
cancelMaterialization(jobId) {
|
|
113
|
+
return this.request(`/v1/materializations/${encodeURIComponent(jobId)}`, {
|
|
114
|
+
method: 'DELETE',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
97
117
|
redeemAccessCode(code) {
|
|
98
118
|
return this.request('/v1/access-codes/redeem', {
|
|
99
119
|
method: 'POST',
|
package/dist/contracts.d.ts
CHANGED
|
@@ -104,6 +104,22 @@ export interface VideoJob {
|
|
|
104
104
|
resultUrl?: string | null;
|
|
105
105
|
error: string | null;
|
|
106
106
|
}
|
|
107
|
+
export interface VideoMaterializationSource {
|
|
108
|
+
url: string;
|
|
109
|
+
fileName: string;
|
|
110
|
+
mimeType: string;
|
|
111
|
+
sizeBytes: number;
|
|
112
|
+
durationSecs: number;
|
|
113
|
+
}
|
|
114
|
+
export interface VideoMaterializationJob {
|
|
115
|
+
id: string;
|
|
116
|
+
status: VideoJobStatus;
|
|
117
|
+
createdAt: string;
|
|
118
|
+
updatedAt: string;
|
|
119
|
+
progress: VideoJobProgress;
|
|
120
|
+
source: VideoMaterializationSource | null;
|
|
121
|
+
error: string | null;
|
|
122
|
+
}
|
|
107
123
|
export interface TranscriptEvidence {
|
|
108
124
|
startMs: number;
|
|
109
125
|
endMs: number;
|
|
@@ -379,6 +395,16 @@ export interface VideoIntelligenceClientContract {
|
|
|
379
395
|
status: string;
|
|
380
396
|
}>;
|
|
381
397
|
cancelJob(jobId: string): Promise<VideoJob>;
|
|
398
|
+
submitMaterialization(request: {
|
|
399
|
+
sourceUrl: string;
|
|
400
|
+
fileName?: string;
|
|
401
|
+
durationSecs?: number;
|
|
402
|
+
}): Promise<VideoMaterializationJob>;
|
|
403
|
+
getMaterialization(jobId: string): Promise<VideoMaterializationJob>;
|
|
404
|
+
acknowledgeMaterialization(jobId: string): Promise<{
|
|
405
|
+
status: string;
|
|
406
|
+
}>;
|
|
407
|
+
cancelMaterialization(jobId: string): Promise<VideoMaterializationJob>;
|
|
382
408
|
/** Removes a local runtime's durable source/result cache for a deleted asset. */
|
|
383
409
|
purgeJobData(jobId: string): Promise<void>;
|
|
384
410
|
getUsage(): Promise<VideoServiceUsage>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './ui.js';
|
|
|
9
9
|
export declare const TOOL_META: {
|
|
10
10
|
readonly id: "video-intelligence";
|
|
11
11
|
readonly name: "Video Intelligence";
|
|
12
|
-
readonly version: "0.3.
|
|
12
|
+
readonly version: "0.3.7";
|
|
13
13
|
};
|
|
14
14
|
export declare const TOOL_EXTENSION: {
|
|
15
15
|
id: "video-intelligence";
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export * from './ui.js';
|
|
|
11
11
|
export const TOOL_META = {
|
|
12
12
|
id: 'video-intelligence',
|
|
13
13
|
name: 'Video Intelligence',
|
|
14
|
-
version: '0.3.
|
|
14
|
+
version: '0.3.7',
|
|
15
15
|
};
|
|
16
16
|
/** Managed infrastructure stays an implementation detail of Larkup Cloud. */
|
|
17
17
|
const MANAGED_CLOUD_ENDPOINT = process.env.LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT ??
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larkup/tool-video-intelligence",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Installable local and cloud video intelligence with evidence-first indexing.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"types": "./dist/runtime.d.ts",
|
|
26
26
|
"import": "./dist/runtime.js",
|
|
27
27
|
"default": "./dist/runtime.js"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"./manifest": "./tool.manifest.json"
|
|
29
30
|
},
|
|
30
31
|
"bin": {
|
|
31
32
|
"larkup-video-intelligence": "./scripts/runtime.mjs"
|
|
@@ -55,13 +56,13 @@
|
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@larkup/core": "0.
|
|
59
|
+
"@larkup/core": "0.8.1"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@types/node": "^26",
|
|
62
63
|
"typescript": "^7.0.2",
|
|
63
64
|
"vitest": "^5.0.0",
|
|
64
|
-
"@larkup/marketplace": "0.3.
|
|
65
|
+
"@larkup/marketplace": "0.3.10"
|
|
65
66
|
},
|
|
66
67
|
"publishConfig": {
|
|
67
68
|
"access": "public"
|
package/runtime/Dockerfile
CHANGED
|
@@ -50,7 +50,7 @@ ARG YOLOX_MODEL_URL=https://github.com/Megvii-BaseDetection/YOLOX/releases/downl
|
|
|
50
50
|
|
|
51
51
|
RUN apt-get update \
|
|
52
52
|
&& apt-get dist-upgrade -y \
|
|
53
|
-
&& apt-get install -y --no-install-recommends ca-certificates curl ffmpeg libgomp1 python3 python3-pip \
|
|
53
|
+
&& apt-get install -y --no-install-recommends ca-certificates curl ffmpeg fonts-liberation libasound2 libatk-bridge2.0-0 libgbm1 libgomp1 libgtk-3-0 libnss3 python3 python3-pip unzip xz-utils xvfb \
|
|
54
54
|
&& rm -rf /var/lib/apt/lists/*
|
|
55
55
|
|
|
56
56
|
WORKDIR /service
|
|
@@ -58,7 +58,7 @@ WORKDIR /service
|
|
|
58
58
|
FROM system AS runtime
|
|
59
59
|
COPY runtime/requirements.txt ./requirements.txt
|
|
60
60
|
RUN python3 -m pip install --no-cache-dir --upgrade pip \
|
|
61
|
-
&& python3 -m pip install --no-cache-dir paddlepaddle==3.0.0
|
|
61
|
+
&& python3 -m pip install --no-cache-dir paddlepaddle==3.0.0 \
|
|
62
62
|
&& python3 -m pip install --no-cache-dir -r requirements.txt
|
|
63
63
|
|
|
64
64
|
RUN mkdir -p /models /data \
|
|
@@ -87,6 +87,22 @@ CMD ["python3", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port",
|
|
|
87
87
|
|
|
88
88
|
FROM runtime AS runpod
|
|
89
89
|
|
|
90
|
+
ARG NODE_VERSION=22.23.0
|
|
91
|
+
ARG CHROME_VERSION=155.0.8059.79
|
|
92
|
+
|
|
93
|
+
RUN curl --fail --location --retry 4 "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" --output /tmp/node.tar.xz \
|
|
94
|
+
&& mkdir -p /opt/node \
|
|
95
|
+
&& tar -xJf /tmp/node.tar.xz --strip-components=1 -C /opt/node \
|
|
96
|
+
&& curl --fail --location --retry 4 "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip" --output /tmp/chrome.zip \
|
|
97
|
+
&& unzip -q /tmp/chrome.zip -d /opt \
|
|
98
|
+
&& mv /opt/chrome-linux64 /opt/chrome \
|
|
99
|
+
&& rm -f /tmp/node.tar.xz /tmp/chrome.zip \
|
|
100
|
+
&& python3 -m pip install --no-cache-dir 'yt-dlp[default]==2026.8.19' 'yt-dlp-getpot-wpc==1.1.2' \
|
|
101
|
+
&& mv /usr/local/bin/yt-dlp /usr/local/bin/yt-dlp-python
|
|
102
|
+
|
|
103
|
+
COPY --chmod=0755 deploy/gpu_providers/yt-dlp-wrapper.sh /usr/local/bin/yt-dlp
|
|
104
|
+
COPY --chmod=0755 deploy/gpu_providers/chrome-wrapper.sh /usr/local/bin/larkup-chrome
|
|
105
|
+
|
|
90
106
|
# The RunPod entrypoint is deliberately kept out of runtime/app (and out of
|
|
91
107
|
# the published npm package) -- see deploy/gpu_providers/README.md. It still
|
|
92
108
|
# has to land inside the `app` package here because its imports and the
|
|
@@ -105,9 +105,14 @@ def temporary_model_environment(payload: dict[str, Any]) -> Iterator[None]:
|
|
|
105
105
|
|
|
106
106
|
audio = parsed["audio"]
|
|
107
107
|
os.environ["LARKUP_VIDEO_TRANSCRIPTION_PROVIDER"] = audio["provider"]
|
|
108
|
-
#
|
|
109
|
-
#
|
|
110
|
-
|
|
108
|
+
# Keep transcription complete when a hosted recognizer cannot hear
|
|
109
|
+
# a source (notably singing, noisy recordings, or an unsupported
|
|
110
|
+
# language). This is the same canonical Modal worker, not a second
|
|
111
|
+
# control plane or provider pipeline; it runs only after the
|
|
112
|
+
# selected provider has failed or returned no usable speech.
|
|
113
|
+
os.environ["LARKUP_VIDEO_TRANSCRIPTION_FALLBACK"] = (
|
|
114
|
+
"whisper" if audio["provider"] != "whisper" else ""
|
|
115
|
+
)
|
|
111
116
|
key_name, model_names = {
|
|
112
117
|
"deepgram": (
|
|
113
118
|
"DEEPGRAM_API_KEY",
|
|
@@ -2073,14 +2073,16 @@ def _synthesis_prompt(
|
|
|
2073
2073
|
"- keyEvents are moments something happened. Include one when the evidence shows it, and say what "
|
|
2074
2074
|
"the evidence shows rather than what it implies. An event that would move a tracked value belongs "
|
|
2075
2075
|
"here only when the ledger actually moves to that value and stays there.\n"
|
|
2076
|
+
"- Write every generated natural-language summary value -- overview, participant roles, states, "
|
|
2077
|
+
"events, narrative notes, context facts, and uncertainties -- in the dominant spoken language "
|
|
2078
|
+
"identified by sourceLanguage (or the dominant language of transcriptEvidence when it is auto). "
|
|
2079
|
+
"Preserve names and exact on-screen text as supplied rather than translating them.\n"
|
|
2076
2080
|
"- narrative is the human notebook: a compact, continuous chronological account that combines "
|
|
2077
2081
|
"the synchronized speech, named participants, visual layout, appearance, on-screen labels, states, "
|
|
2078
2082
|
"and events. Each entry must make sense after the preceding entry, so preserve who is on which side "
|
|
2079
2083
|
"or in which group and carry that identity forward only while the evidence supports it. Replace vague "
|
|
2080
2084
|
"descriptions such as 'two people discuss something' with the supported names, relationships, and "
|
|
2081
|
-
"purpose available anywhere in the supplied evidence. Do not invent a bridge across an edit.
|
|
2082
|
-
"narrative text in the dominant spoken language identified by sourceLanguage (or the dominant language "
|
|
2083
|
-
"of transcriptEvidence when it is auto), while preserving names and exact on-screen text as supplied. "
|
|
2085
|
+
"purpose available anywhere in the supplied evidence. Do not invent a bridge across an edit. "
|
|
2084
2086
|
"Do not repeatedly say 'the video shows' or describe the act of analysis.\n"
|
|
2085
2087
|
"- recurringOnScreenText lists short text that stayed legible across several frames. It marks "
|
|
2086
2088
|
"where a display existed and when it changed. It never states what that text means: use it to "
|
|
@@ -2548,10 +2550,10 @@ def _fallback_knowledge_summary(
|
|
|
2548
2550
|
elif len(key_events) == 1:
|
|
2549
2551
|
overview = key_events[0]["event"]
|
|
2550
2552
|
else:
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2553
|
+
# Keep deterministic fallback text in the same language as the
|
|
2554
|
+
# semantic observations. English connective prose here was enough to
|
|
2555
|
+
# make an otherwise-Arabic index appear translated.
|
|
2556
|
+
overview = f"{key_events[0]['event']} … {key_events[-1]['event']}"[:2_000]
|
|
2555
2557
|
return {
|
|
2556
2558
|
"overview": overview,
|
|
2557
2559
|
"participants": list(participants_by_name.values())[:50],
|
|
@@ -1406,6 +1406,16 @@ def _link_chronological_notes(
|
|
|
1406
1406
|
)
|
|
1407
1407
|
|
|
1408
1408
|
|
|
1409
|
+
def _supplied_transcript_language(
|
|
1410
|
+
brief: dict[str, Any], transcript: list[dict[str, Any]]
|
|
1411
|
+
) -> str | None:
|
|
1412
|
+
"""Carry source/caption language through jobs that intentionally skip local STT."""
|
|
1413
|
+
if not transcript:
|
|
1414
|
+
return None
|
|
1415
|
+
language = str(brief.get("detectedLanguage") or brief.get("language") or "").strip()
|
|
1416
|
+
return language if language and language.casefold() != "auto" else None
|
|
1417
|
+
|
|
1418
|
+
|
|
1409
1419
|
def _apply_video_embedding_policy(
|
|
1410
1420
|
plan: ExtractionPlan,
|
|
1411
1421
|
brief: dict[str, Any],
|
|
@@ -1506,7 +1516,7 @@ def _run_pipeline(
|
|
|
1506
1516
|
for segment in (brief.get("transcriptContext") or [])
|
|
1507
1517
|
if isinstance(segment, dict)
|
|
1508
1518
|
]
|
|
1509
|
-
detected_language: str | None =
|
|
1519
|
+
detected_language: str | None = _supplied_transcript_language(brief, transcript)
|
|
1510
1520
|
transcription_error: BaseException | None = None
|
|
1511
1521
|
transcription_units = {"completed": 0, "total": 1}
|
|
1512
1522
|
transcription_units_lock = threading.Lock()
|
|
@@ -1495,6 +1495,19 @@ class SemanticVisionService:
|
|
|
1495
1495
|
)
|
|
1496
1496
|
if part
|
|
1497
1497
|
)
|
|
1498
|
+
source_language = str(
|
|
1499
|
+
brief.get("detectedLanguage") or brief.get("language") or ""
|
|
1500
|
+
).strip()
|
|
1501
|
+
if source_language and source_language.casefold() != "auto":
|
|
1502
|
+
goal = "\n".join(
|
|
1503
|
+
part
|
|
1504
|
+
for part in (
|
|
1505
|
+
goal,
|
|
1506
|
+
"Write every generated note and event in the source language "
|
|
1507
|
+
f"({source_language}); translate only when explicitly requested.",
|
|
1508
|
+
)
|
|
1509
|
+
if part
|
|
1510
|
+
)
|
|
1498
1511
|
requests_ = [
|
|
1499
1512
|
ClipCaptionRequest(clip_id=clip_id, start_ms=start_ms, end_ms=end_ms, frames=frames)
|
|
1500
1513
|
for clip_id, (start_ms, end_ms, frames) in clips.items()
|
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
echo "Requires LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN." >&2
|
|
7
|
-
exit 64
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
USER_ID="${1:-}"
|
|
11
|
-
SOURCE_MINUTES="${2:-}"
|
|
12
|
-
PLAN="${3:-support-grant}"
|
|
13
|
-
|
|
14
|
-
[[ -n "$USER_ID" && -n "$SOURCE_MINUTES" ]] || usage
|
|
15
|
-
[[ "$USER_ID" =~ ^[A-Za-z0-9._-]{32,128}$ ]] || {
|
|
16
|
-
echo "User ID must be the generated ID shown in Installed Tools." >&2
|
|
17
|
-
exit 64
|
|
18
|
-
}
|
|
19
|
-
[[ "$SOURCE_MINUTES" =~ ^[0-9]+([.][0-9]+)?$ ]] || {
|
|
20
|
-
echo "Monthly source minutes must be a non-negative number." >&2
|
|
21
|
-
exit 64
|
|
22
|
-
}
|
|
23
|
-
[[ "$PLAN" =~ ^[A-Za-z0-9._-]{1,80}$ ]] || {
|
|
24
|
-
echo "Plan may contain only letters, numbers, dots, underscores, and hyphens." >&2
|
|
25
|
-
exit 64
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
ENDPOINT="${LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT:-}"
|
|
29
|
-
ADMIN_TOKEN="${LARKUP_VIDEO_ADMIN_TOKEN:-}"
|
|
30
|
-
[[ -n "$ENDPOINT" && -n "$ADMIN_TOKEN" ]] || {
|
|
31
|
-
echo "Set LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN first." >&2
|
|
32
|
-
exit 64
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
ENDPOINT="${ENDPOINT%/}"
|
|
36
|
-
PAYLOAD=$(printf '{"sourceMinutesPerMonth":%s,"plan":"%s"}' "$SOURCE_MINUTES" "$PLAN")
|
|
37
|
-
|
|
38
|
-
curl --fail-with-body --silent --show-error \
|
|
39
|
-
--request POST "$ENDPOINT/v1/admin/devices/$USER_ID/entitlement" \
|
|
40
|
-
--header 'Content-Type: application/json' \
|
|
41
|
-
--header "X-Larkup-Admin-Token: $ADMIN_TOKEN" \
|
|
42
|
-
--data "$PAYLOAD"
|
|
43
|
-
echo
|
|
4
|
+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
|
5
|
+
exec "$SCRIPT_DIR/manage-cloud-usage.sh" set "$@"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
usage() {
|
|
5
|
+
cat >&2 <<'EOF'
|
|
6
|
+
Usage:
|
|
7
|
+
manage-cloud-usage.sh status <user-id>
|
|
8
|
+
manage-cloud-usage.sh reset <user-id>
|
|
9
|
+
manage-cloud-usage.sh set <user-id> <monthly-source-minutes> [plan]
|
|
10
|
+
manage-cloud-usage.sh add <user-id> <monthly-source-minutes> [plan]
|
|
11
|
+
manage-cloud-usage.sh remove <user-id> <monthly-source-minutes> [plan]
|
|
12
|
+
manage-cloud-usage.sh usage-set <user-id> <used-source-minutes>
|
|
13
|
+
manage-cloud-usage.sh usage-add <user-id> <used-source-minutes>
|
|
14
|
+
manage-cloud-usage.sh usage-remove <user-id> <used-source-minutes>
|
|
15
|
+
|
|
16
|
+
set/add/remove change the monthly allowance. reset clears current-period usage.
|
|
17
|
+
Requires LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN.
|
|
18
|
+
EOF
|
|
19
|
+
exit 64
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ACTION="${1:-}"
|
|
23
|
+
USER_ID="${2:-}"
|
|
24
|
+
VALUE="${3:-}"
|
|
25
|
+
PLAN="${4:-support-grant}"
|
|
26
|
+
|
|
27
|
+
case "$ACTION" in
|
|
28
|
+
status|reset) [[ $# -eq 2 ]] || usage ;;
|
|
29
|
+
set|add|remove) [[ $# -ge 3 && $# -le 4 ]] || usage ;;
|
|
30
|
+
usage-set|usage-add|usage-remove) [[ $# -eq 3 ]] || usage ;;
|
|
31
|
+
*) usage ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
[[ "$USER_ID" =~ ^[A-Za-z0-9._-]{32,128}$ ]] || {
|
|
35
|
+
echo "User ID must be the generated ID shown in Installed Tools." >&2
|
|
36
|
+
exit 64
|
|
37
|
+
}
|
|
38
|
+
if [[ -n "$VALUE" ]]; then
|
|
39
|
+
[[ "$VALUE" =~ ^[0-9]+([.][0-9]+)?$ ]] || {
|
|
40
|
+
echo "Source minutes must be a non-negative number." >&2
|
|
41
|
+
exit 64
|
|
42
|
+
}
|
|
43
|
+
fi
|
|
44
|
+
[[ "$PLAN" =~ ^[A-Za-z0-9._-]{1,80}$ ]] || {
|
|
45
|
+
echo "Plan may contain only letters, numbers, dots, underscores, and hyphens." >&2
|
|
46
|
+
exit 64
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ENDPOINT="${LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT:-}"
|
|
50
|
+
ADMIN_TOKEN="${LARKUP_VIDEO_ADMIN_TOKEN:-}"
|
|
51
|
+
[[ -n "$ENDPOINT" && -n "$ADMIN_TOKEN" ]] || {
|
|
52
|
+
echo "Set LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN first." >&2
|
|
53
|
+
exit 64
|
|
54
|
+
}
|
|
55
|
+
command -v jq >/dev/null || {
|
|
56
|
+
echo "jq is required." >&2
|
|
57
|
+
exit 69
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ENDPOINT="${ENDPOINT%/}"
|
|
61
|
+
USAGE_URL="$ENDPOINT/v1/admin/devices/$USER_ID/usage"
|
|
62
|
+
ENTITLEMENT_URL="$ENDPOINT/v1/admin/devices/$USER_ID/entitlement"
|
|
63
|
+
|
|
64
|
+
request() {
|
|
65
|
+
local method="$1"
|
|
66
|
+
local url="$2"
|
|
67
|
+
local payload="${3:-}"
|
|
68
|
+
local args=(
|
|
69
|
+
--fail-with-body
|
|
70
|
+
--silent
|
|
71
|
+
--show-error
|
|
72
|
+
--request "$method"
|
|
73
|
+
"$url"
|
|
74
|
+
--header 'Content-Type: application/json'
|
|
75
|
+
--header "X-Larkup-Admin-Token: $ADMIN_TOKEN"
|
|
76
|
+
)
|
|
77
|
+
if [[ -n "$payload" ]]; then
|
|
78
|
+
args+=(--data "$payload")
|
|
79
|
+
fi
|
|
80
|
+
curl "${args[@]}"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
case "$ACTION" in
|
|
84
|
+
status)
|
|
85
|
+
request GET "$USAGE_URL"
|
|
86
|
+
;;
|
|
87
|
+
reset)
|
|
88
|
+
request POST "$USAGE_URL" '{"operation":"reset"}'
|
|
89
|
+
;;
|
|
90
|
+
usage-set|usage-add|usage-remove)
|
|
91
|
+
operation="${ACTION#usage-}"
|
|
92
|
+
payload=$(jq -cn --arg operation "$operation" --argjson sourceMinutes "$VALUE" \
|
|
93
|
+
'{operation: $operation, sourceMinutes: $sourceMinutes}')
|
|
94
|
+
request POST "$USAGE_URL" "$payload"
|
|
95
|
+
;;
|
|
96
|
+
set|add|remove)
|
|
97
|
+
target="$VALUE"
|
|
98
|
+
if [[ "$ACTION" != "set" ]]; then
|
|
99
|
+
current=$(request GET "$USAGE_URL" | jq -er '.sourceMinutesLimit | select(type == "number")') || {
|
|
100
|
+
echo "Cannot add to or remove from an unlimited monthly allowance; use set instead." >&2
|
|
101
|
+
exit 65
|
|
102
|
+
}
|
|
103
|
+
if [[ "$ACTION" == "add" ]]; then
|
|
104
|
+
target=$(jq -cn --argjson current "$current" --argjson amount "$VALUE" '$current + $amount')
|
|
105
|
+
else
|
|
106
|
+
target=$(jq -cn --argjson current "$current" --argjson amount "$VALUE" \
|
|
107
|
+
'[$current - $amount, 0] | max')
|
|
108
|
+
fi
|
|
109
|
+
fi
|
|
110
|
+
payload=$(jq -cn --argjson sourceMinutesPerMonth "$target" --arg plan "$PLAN" \
|
|
111
|
+
'{sourceMinutesPerMonth: $sourceMinutesPerMonth, plan: $plan}')
|
|
112
|
+
request POST "$ENTITLEMENT_URL" "$payload" >/dev/null
|
|
113
|
+
request GET "$USAGE_URL"
|
|
114
|
+
;;
|
|
115
|
+
esac
|
|
116
|
+
echo
|
package/tool.manifest.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"description": "Help your AI understand your videos, so you can ask questions and get answers from the right moments.",
|
|
8
8
|
"longDescription": "Turn videos into knowledge your AI can understand. It listens to what is said, reads what appears on screen, and helps you find the moments that matter.",
|
|
9
9
|
"category": "media",
|
|
10
|
-
"version": "0.3.
|
|
10
|
+
"version": "0.3.7",
|
|
11
11
|
"pricing": "free",
|
|
12
12
|
"emoji": "🎥",
|
|
13
13
|
"icon": "Film",
|