@nimiplatform/sdk 0.9.1 → 0.11.0
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/dist/core/ai/profile-authoring.d.ts +1 -1
- package/dist/core/ai/profile-authoring.d.ts.map +1 -1
- package/dist/core/ai/profile-authoring.js.map +1 -1
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/index.d.ts.map +1 -1
- package/dist/core/app/index.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.d.ts +38 -5
- package/dist/core/app/local-app-runtime-platform-ai.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.js +112 -15
- package/dist/core/app/local-app-runtime-platform-ai.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-realtime-shared.d.ts +1 -1
- package/dist/core/app/local-app-runtime-platform-video.d.ts +58 -0
- package/dist/core/app/local-app-runtime-platform-video.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-video.js +155 -0
- package/dist/core/app/local-app-runtime-platform-video.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-vision.d.ts +32 -0
- package/dist/core/app/local-app-runtime-platform-vision.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-vision.js +77 -0
- package/dist/core/app/local-app-runtime-platform-vision.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform.d.ts +5 -1
- package/dist/core/app/local-app-runtime-platform.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform.js +4 -1
- package/dist/core/app/local-app-runtime-platform.js.map +1 -1
- package/dist/core-generated/runtime-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-client.js +136 -8
- package/dist/core-generated/runtime-client.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts +44 -2
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js +93 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts +819 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js +1766 -83
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts +501 -8
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js +1602 -506
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts +53 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js +138 -2
- package/dist/core-generated/runtime-protobuf/runtime/v1/capability_configuration.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts +49 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js +48 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts +55 -82
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js +98 -168
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_asset_catalog.d.ts +8 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_asset_catalog.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_asset_catalog.js +13 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_asset_catalog.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.d.ts +211 -318
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.js +494 -616
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.js.map +1 -1
- package/dist/core-generated/runtime-public-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-client.js +136 -8
- package/dist/core-generated/runtime-public-client.js.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js +17 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.d.ts +22 -5
- package/dist/core-generated/runtime-public-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.js +22 -5
- package/dist/core-generated/runtime-public-wire-codecs.js.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.d.ts.map +1 -1
- package/dist/core-generated/runtime-rpc-auth-posture.js +17 -1
- package/dist/core-generated/runtime-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-typed-client.d.ts +30 -13
- package/dist/core-generated/runtime-typed-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-typed-client.js +172 -12
- package/dist/core-generated/runtime-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.d.ts +22 -5
- package/dist/core-generated/runtime-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.js +22 -5
- package/dist/core-generated/runtime-wire-codecs.js.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.d.ts +3 -3
- package/dist/runtime/desktop-first-party-runtime.d.ts.map +1 -1
- package/dist/runtime/desktop-first-party-runtime.js +11 -1
- package/dist/runtime/desktop-first-party-runtime.js.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts +77 -5
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js +22 -4
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js.map +1 -1
- package/dist/runtime/generated.d.ts +2 -2
- package/dist/runtime/generated.d.ts.map +1 -1
- package/dist/runtime/generated.js +1 -1
- package/dist/runtime/generated.js.map +1 -1
- package/dist/runtime/local-asset-vocabulary.d.ts +2 -1
- package/dist/runtime/local-asset-vocabulary.d.ts.map +1 -1
- package/dist/runtime/local-asset-vocabulary.js +3 -0
- package/dist/runtime/local-asset-vocabulary.js.map +1 -1
- package/dist/runtime/machine-loadouts.d.ts +13 -0
- package/dist/runtime/machine-loadouts.d.ts.map +1 -1
- package/dist/runtime/machine-loadouts.js +22 -1
- package/dist/runtime/machine-loadouts.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.d.ts +2 -4
- package/dist/runtime/runtime-local-environment-client-projections.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.js +2 -64
- package/dist/runtime/runtime-local-environment-client-projections.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-types.d.ts +29 -50
- package/dist/runtime/runtime-local-environment-client-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.d.ts +1 -1
- package/dist/runtime/runtime-local-environment-client.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.js +72 -23
- package/dist/runtime/runtime-local-environment-client.js.map +1 -1
- package/dist/runtime/runtime-local-recommendation-types.d.ts +47 -116
- package/dist/runtime/runtime-local-recommendation-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.d.ts +11 -33
- package/dist/runtime/runtime-local-recommendation.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.js +102 -261
- package/dist/runtime/runtime-local-recommendation.js.map +1 -1
- package/dist/runtime/runtime-method-modules.d.ts +2 -2
- package/dist/runtime/runtime-method-modules.d.ts.map +1 -1
- package/dist/runtime/runtime-method-modules.js +4 -1
- package/dist/runtime/runtime-method-modules.js.map +1 -1
- package/dist/runtime/scenario-jobs.d.ts +2 -1
- package/dist/runtime/scenario-jobs.d.ts.map +1 -1
- package/dist/runtime/scenario-jobs.js +17 -1
- package/dist/runtime/scenario-jobs.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-types.d.ts +2 -2
- package/dist/runtime/wire-types/agent-participation-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts +20 -2
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.js +21 -0
- package/dist/runtime/wire-types/ai-scenario-enums.js.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-types.d.ts +4 -4
- package/dist/runtime/wire-types/ai-scenario-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.d.ts +5 -2
- package/dist/runtime/wire-types/identity-app-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.js +3 -0
- package/dist/runtime/wire-types/identity-app-enums.js.map +1 -1
- package/dist/runtime/wire-types/identity-app-types.d.ts +2 -2
- package/dist/runtime/wire-types/identity-app-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts +13 -45
- package/dist/runtime/wire-types/local-memory-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.js +21 -59
- package/dist/runtime/wire-types/local-memory-enums.js.map +1 -1
- package/dist/runtime/wire-types/local-memory-types.d.ts +4 -4
- package/dist/runtime/wire-types/local-memory-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts +13 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.js +12 -0
- package/dist/runtime/wire-types/reason-code-enums.js.map +1 -1
- package/package.json +1 -1
- package/dist/runtime/runtime-local-recommendation-feed-ui.d.ts +0 -26
- package/dist/runtime/runtime-local-recommendation-feed-ui.d.ts.map +0 -1
- package/dist/runtime/runtime-local-recommendation-feed-ui.js +0 -453
- package/dist/runtime/runtime-local-recommendation-feed-ui.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ExecutionMode, FinishReason, ReasonCode as RuntimeReasonCode, RoutePolicy, ScenarioJobEventType, ScenarioJobStatus, ScenarioType, SpeechTimingMode, VideoContentRole, VideoContentType, VideoMode, VoiceAssetStatus, VoiceCreationSource, VoiceReferenceKind, } from '../../core-generated/runtime-typed-client.js';
|
|
1
|
+
import { ExecutionMode, FaceSwapNoFacePolicy, FinishReason, ReasonCode as RuntimeReasonCode, RoutePolicy, ScenarioJobEventType, ScenarioJobStatus, ScenarioType, SpeechTimingMode, VideoContentRole, VideoContentType, VideoMode, VoiceAssetStatus, VoiceCreationSource, VoiceReferenceKind, VisionLocateGeometry, } from '../../core-generated/runtime-typed-client.js';
|
|
2
2
|
import { asRecord, assertExactKeys, assertExactProjectionKeys, assertNoAuthorityMaterial, assertSafeProjection, localAppError, localAppProjectionError, projectionText, requireText, } from './local-app-runtime-platform-validation.js';
|
|
3
|
+
import { projectVisionLocateResult, localVisionLocateFromRuntime, runtimeVisionLocateFromLocal, localLocateGeometry, projectLocalExecutionInterruption, localInterruptionFromRuntime, runtimeInterruptionFromLocal, } from './local-app-runtime-platform-vision.js';
|
|
3
4
|
const MAX_RESULT_BYTES = 256 * 1024;
|
|
4
5
|
const MAX_ARTIFACT_BYTES = 32 * 1024 * 1024;
|
|
5
6
|
const MAX_IDENTIFIER_BYTES = 128;
|
|
@@ -42,7 +43,7 @@ export function createNimiLocalAppAIConsumptionClient(shell) {
|
|
|
42
43
|
assertExactKeys(input, ['bytes', 'mimeType'], 'artifact upload input');
|
|
43
44
|
assertNoAuthorityMaterial(input);
|
|
44
45
|
if (!(input.bytes instanceof Uint8Array) || input.bytes.byteLength === 0
|
|
45
|
-
|| input.bytes.byteLength > MAX_ARTIFACT_BYTES || !
|
|
46
|
+
|| input.bytes.byteLength > MAX_ARTIFACT_BYTES || !isArtifactUploadMime(input.mimeType)) {
|
|
46
47
|
invalidAIInput('artifact upload is invalid');
|
|
47
48
|
}
|
|
48
49
|
return projectArtifactUpload(await shell.artifacts.upload({ bytes: [...input.bytes], mimeType: input.mimeType }), input.bytes.byteLength, input.mimeType);
|
|
@@ -91,6 +92,7 @@ export function createNimiLocalAppAIConsumptionRuntimeClient(runtime) {
|
|
|
91
92
|
async get(jobId) {
|
|
92
93
|
const response = await runtime.getLocalAppScenarioJob({ jobId });
|
|
93
94
|
return {
|
|
95
|
+
...(response.visionLocate ? { visionLocate: localVisionLocateFromRuntime(response.visionLocate) } : {}),
|
|
94
96
|
job: projectRuntimeLocalJob(requiredRuntimeValue(response.job, 'scenario Job')),
|
|
95
97
|
asset: response.asset ? projectRuntimeLocalAppVoiceAsset(response.asset) : null,
|
|
96
98
|
voiceReference: response.voiceReference
|
|
@@ -192,6 +194,7 @@ export function createNimiLocalAppRuntimeScenarioJobClient(ai) {
|
|
|
192
194
|
assertExactKeys(request, ['jobId'], 'local-app Scenario Job get request');
|
|
193
195
|
const result = await ai.scenarioJobs.get(request.jobId);
|
|
194
196
|
return {
|
|
197
|
+
...(result.visionLocate ? { visionLocate: runtimeVisionLocateFromLocal(result.visionLocate) } : {}),
|
|
195
198
|
job: runtimeJobFromLocal(result.job),
|
|
196
199
|
asset: result.asset ? runtimeVoiceAssetFromLocal(result.asset) : undefined,
|
|
197
200
|
voiceReference: result.voiceReference ? {
|
|
@@ -292,6 +295,33 @@ function validateScenarioSpec(spec, execute) {
|
|
|
292
295
|
invalidAIInput('scenario spec is invalid');
|
|
293
296
|
assertNoAuthorityMaterial(record);
|
|
294
297
|
switch (record.type) {
|
|
298
|
+
// @nimi-authority: rule.nimi.runtime.ai-provider.face-swap-video-job
|
|
299
|
+
case 'video-face-swap':
|
|
300
|
+
if (execute)
|
|
301
|
+
invalidAIInput('video-face-swap requires an async Job');
|
|
302
|
+
assertExactKeys(record, ['type', 'referenceImageArtifactId', 'targetVideoArtifactId', 'noFacePolicy'], 'video face replacement spec');
|
|
303
|
+
boundedIdentifier(record.referenceImageArtifactId, 'referenceImageArtifactId');
|
|
304
|
+
boundedIdentifier(record.targetVideoArtifactId, 'targetVideoArtifactId');
|
|
305
|
+
if (record.noFacePolicy !== 'fail' && record.noFacePolicy !== 'preserve-frame')
|
|
306
|
+
invalidAIInput('video face replacement requires an explicit no-face policy');
|
|
307
|
+
break;
|
|
308
|
+
// @nimi-authority: rule.nimi.runtime.ai-provider.face-swap-image-job
|
|
309
|
+
case 'image-face-swap':
|
|
310
|
+
if (execute)
|
|
311
|
+
invalidAIInput('image-face-swap requires an async Job');
|
|
312
|
+
assertExactKeys(record, ['type', 'referenceImageArtifactId', 'targetImageArtifactId'], 'image face replacement spec');
|
|
313
|
+
boundedIdentifier(record.referenceImageArtifactId, 'referenceImageArtifactId');
|
|
314
|
+
boundedIdentifier(record.targetImageArtifactId, 'targetImageArtifactId');
|
|
315
|
+
break;
|
|
316
|
+
case 'vision-locate':
|
|
317
|
+
if (execute)
|
|
318
|
+
invalidAIInput('vision-locate requires an async Job');
|
|
319
|
+
assertExactKeys(record, ['type', 'imageArtifactId', 'query', 'geometry'], 'Locate spec');
|
|
320
|
+
boundedIdentifier(record.imageArtifactId, 'Locate imageArtifactId');
|
|
321
|
+
boundedContent(record.query, 'Locate query', 8 * 1024);
|
|
322
|
+
if (record.geometry !== 'box' && record.geometry !== 'point')
|
|
323
|
+
invalidAIInput('Locate geometry');
|
|
324
|
+
break;
|
|
295
325
|
case 'text-embed':
|
|
296
326
|
if (!execute)
|
|
297
327
|
invalidAIInput('text-embed is not an async Job spec');
|
|
@@ -361,9 +391,19 @@ function validateScenarioSpec(spec, execute) {
|
|
|
361
391
|
case 'music-generate':
|
|
362
392
|
if (execute)
|
|
363
393
|
invalidAIInput('music-generate is not a synchronous spec');
|
|
364
|
-
assertExactKeys(record, ['type', 'prompt', 'lyrics'], 'music spec');
|
|
394
|
+
assertExactKeys(record, ['type', 'prompt', 'lyrics', 'durationSeconds'], 'music spec');
|
|
365
395
|
boundedContent(record.prompt, 'music prompt', 32 * 1024);
|
|
366
396
|
boundedContent(record.lyrics, 'music lyrics', 32 * 1024);
|
|
397
|
+
if (record.durationSeconds !== undefined && (!Number.isSafeInteger(record.durationSeconds)
|
|
398
|
+
|| Number(record.durationSeconds) < 1 || Number(record.durationSeconds) > 180))
|
|
399
|
+
invalidAIInput('music durationSeconds must be an integer from 1 through 180');
|
|
400
|
+
break;
|
|
401
|
+
case 'world-generate':
|
|
402
|
+
if (execute)
|
|
403
|
+
invalidAIInput('world-generate is not a synchronous spec');
|
|
404
|
+
assertExactKeys(record, ['type', 'prompt', 'displayName'], 'world spec');
|
|
405
|
+
boundedContent(record.prompt, 'world prompt', 32 * 1024);
|
|
406
|
+
optionalBoundedText(record.displayName, 'world displayName', 256);
|
|
367
407
|
break;
|
|
368
408
|
default:
|
|
369
409
|
invalidAIInput('scenario type is invalid');
|
|
@@ -570,8 +610,11 @@ function projectScenarioJobSubmit(value) {
|
|
|
570
610
|
}
|
|
571
611
|
function projectScenarioJobGet(value) {
|
|
572
612
|
const record = asRecord(value);
|
|
573
|
-
assertExactProjectionKeys(record, ['job', 'asset', 'voiceReference'], 'scenario Job result');
|
|
613
|
+
assertExactProjectionKeys(record, ['job', 'asset', 'voiceReference', ...(record && Object.hasOwn(record, 'visionLocate') ? ['visionLocate'] : [])], 'scenario Job result');
|
|
574
614
|
const job = projectScenarioJob(record.job);
|
|
615
|
+
const visionLocate = record.visionLocate === undefined ? undefined : projectVisionLocateResult(record.visionLocate);
|
|
616
|
+
if ((job.scenarioType === 'vision-locate' && job.status === 'completed') !== (visionLocate !== undefined) || (visionLocate && job.artifacts.length !== 0))
|
|
617
|
+
localAppProjectionError('Locate terminal result');
|
|
575
618
|
const asset = record.asset === null ? null : projectVoiceAsset(record.asset);
|
|
576
619
|
const voiceReference = record.voiceReference === null ? null : projectVoiceAssetReference(record.voiceReference);
|
|
577
620
|
if ((asset === null) !== (voiceReference === null)
|
|
@@ -583,6 +626,7 @@ function projectScenarioJobGet(value) {
|
|
|
583
626
|
job,
|
|
584
627
|
asset,
|
|
585
628
|
voiceReference,
|
|
629
|
+
...(visionLocate ? { visionLocate } : {}),
|
|
586
630
|
});
|
|
587
631
|
}
|
|
588
632
|
function projectScenarioJobEnvelope(value) {
|
|
@@ -592,7 +636,7 @@ function projectScenarioJobEnvelope(value) {
|
|
|
592
636
|
}
|
|
593
637
|
function projectScenarioJob(value) {
|
|
594
638
|
const record = asRecord(value);
|
|
595
|
-
assertExactProjectionKeys(record, ['jobId', 'scenarioType', 'status', 'progressPercent', 'progressCurrentStep', 'progressTotalSteps', 'reasonCode', 'reasonDetail', 'artifacts', 'traceId', 'createdAt', 'updatedAt', 'transcriptionText'], 'scenario Job');
|
|
639
|
+
assertExactProjectionKeys(record, ['jobId', 'scenarioType', 'status', 'progressPercent', 'progressCurrentStep', 'progressTotalSteps', 'reasonCode', 'reasonDetail', 'artifacts', 'traceId', 'createdAt', 'updatedAt', 'transcriptionText', ...(record && Object.hasOwn(record, 'interruption') ? ['interruption'] : []), ...(record && Object.hasOwn(record, 'videoFaceSwapSummary') ? ['videoFaceSwapSummary'] : [])], 'scenario Job');
|
|
596
640
|
assertSafeProjection(record);
|
|
597
641
|
if (!LOCAL_SCENARIO_TYPES.includes(record.scenarioType) || !LOCAL_JOB_STATUSES.includes(record.status))
|
|
598
642
|
localAppProjectionError('scenario Job enum');
|
|
@@ -600,7 +644,14 @@ function projectScenarioJob(value) {
|
|
|
600
644
|
const total = projectionInteger(record.progressTotalSteps, 'scenario Job total steps', 0, Number.MAX_SAFE_INTEGER);
|
|
601
645
|
if (current > total)
|
|
602
646
|
localAppProjectionError('scenario Job progress');
|
|
647
|
+
const interruption = projectLocalExecutionInterruption(record.interruption, record.reasonCode, record.status);
|
|
648
|
+
const hasVideoSummary = record.videoFaceSwapSummary !== undefined;
|
|
649
|
+
if (hasVideoSummary !== (record.scenarioType === 'video-face-swap' && record.status === 'completed'))
|
|
650
|
+
localAppProjectionError('video face replacement summary state');
|
|
651
|
+
const videoFaceSwapSummary = hasVideoSummary ? projectVideoFaceSwapSummary(record.videoFaceSwapSummary) : undefined;
|
|
603
652
|
return Object.freeze({
|
|
653
|
+
...(videoFaceSwapSummary ? { videoFaceSwapSummary } : {}),
|
|
654
|
+
...(interruption ? { interruption } : {}),
|
|
604
655
|
jobId: boundedProjectionText(record.jobId, 'scenario Job id', MAX_IDENTIFIER_BYTES),
|
|
605
656
|
scenarioType: record.scenarioType,
|
|
606
657
|
status: record.status,
|
|
@@ -616,6 +667,17 @@ function projectScenarioJob(value) {
|
|
|
616
667
|
transcriptionText: optionalProjectionText(record.transcriptionText, 'scenario Job transcriptionText', MAX_RESULT_BYTES),
|
|
617
668
|
});
|
|
618
669
|
}
|
|
670
|
+
function projectVideoFaceSwapSummary(value) {
|
|
671
|
+
const record = asRecord(value);
|
|
672
|
+
assertExactProjectionKeys(record, ['totalFrames', 'transformedFrames', 'preservedFrames', 'durationUs', 'frameRate', 'audioPreserved'], 'video face replacement summary');
|
|
673
|
+
const totalFrames = projectionInteger(record.totalFrames, 'video total frames', 1, 9000);
|
|
674
|
+
const transformedFrames = projectionInteger(record.transformedFrames, 'video transformed frames', 0, totalFrames);
|
|
675
|
+
const preservedFrames = projectionInteger(record.preservedFrames, 'video preserved frames', 0, totalFrames);
|
|
676
|
+
const frameRate = projectionInteger(record.frameRate, 'video frame rate', 24, 30);
|
|
677
|
+
if (transformedFrames + preservedFrames !== totalFrames || ![24, 25, 30].includes(frameRate) || typeof record.audioPreserved !== 'boolean')
|
|
678
|
+
localAppProjectionError('video face replacement counts or format');
|
|
679
|
+
return Object.freeze({ totalFrames, transformedFrames, preservedFrames, durationUs: projectionInteger(record.durationUs, 'video duration', 1, 300000000), frameRate: frameRate, audioPreserved: record.audioPreserved });
|
|
680
|
+
}
|
|
619
681
|
function projectArtifacts(value) {
|
|
620
682
|
if (!Array.isArray(value) || value.length > 16)
|
|
621
683
|
localAppProjectionError('scenario artifacts');
|
|
@@ -659,13 +721,13 @@ function projectArtifactUpload(value, expectedSize, expectedMimeType) {
|
|
|
659
721
|
if (utf8Length(artifactId) > MAX_IDENTIFIER_BYTES
|
|
660
722
|
|| !Number.isSafeInteger(record.sizeBytes) || record.sizeBytes !== expectedSize
|
|
661
723
|
|| record.sizeBytes < 1 || record.sizeBytes > MAX_ARTIFACT_BYTES
|
|
662
|
-
|| record.mimeType !== expectedMimeType || !
|
|
724
|
+
|| record.mimeType !== expectedMimeType || !isArtifactUploadMime(record.mimeType)) {
|
|
663
725
|
localAppProjectionError('artifact upload result');
|
|
664
726
|
}
|
|
665
727
|
return Object.freeze({ artifactId, sizeBytes: record.sizeBytes, mimeType: record.mimeType });
|
|
666
728
|
}
|
|
667
|
-
function
|
|
668
|
-
return value === 'image/png' || value === 'image/jpeg' || value === 'image/webp' || value === 'image/gif';
|
|
729
|
+
function isArtifactUploadMime(value) {
|
|
730
|
+
return value === 'image/png' || value === 'image/jpeg' || value === 'image/webp' || value === 'image/gif' || value === 'video/mp4';
|
|
669
731
|
}
|
|
670
732
|
function projectArtifactRead(value) {
|
|
671
733
|
const record = asRecord(value);
|
|
@@ -753,6 +815,12 @@ function runtimeExecuteRequest(spec) {
|
|
|
753
815
|
}
|
|
754
816
|
function runtimeLocalJobSpec(spec) {
|
|
755
817
|
switch (spec.type) {
|
|
818
|
+
case 'video-face-swap':
|
|
819
|
+
return { oneofKind: 'videoFaceSwap', videoFaceSwap: { referenceImageArtifactId: spec.referenceImageArtifactId, targetVideoArtifactId: spec.targetVideoArtifactId, noFacePolicy: spec.noFacePolicy === 'fail' ? FaceSwapNoFacePolicy.FAIL : FaceSwapNoFacePolicy.PRESERVE_FRAME } };
|
|
820
|
+
case 'image-face-swap':
|
|
821
|
+
return { oneofKind: 'imageFaceSwap', imageFaceSwap: { referenceImageArtifactId: spec.referenceImageArtifactId, targetImageArtifactId: spec.targetImageArtifactId } };
|
|
822
|
+
case 'vision-locate':
|
|
823
|
+
return { oneofKind: 'visionLocate', visionLocate: { imageArtifactId: spec.imageArtifactId, query: spec.query, geometry: spec.geometry === 'box' ? VisionLocateGeometry.BOX : VisionLocateGeometry.POINT } };
|
|
756
824
|
case 'image-generate':
|
|
757
825
|
return { oneofKind: 'imageGenerate', imageGenerate: runtimeImageSpec(spec) };
|
|
758
826
|
case 'video-generate':
|
|
@@ -859,8 +927,10 @@ function runtimeLocalJobSpec(spec) {
|
|
|
859
927
|
case 'music-generate':
|
|
860
928
|
return {
|
|
861
929
|
oneofKind: 'musicGenerate',
|
|
862
|
-
musicGenerate: { prompt: spec.prompt, lyrics: spec.lyrics },
|
|
930
|
+
musicGenerate: { prompt: spec.prompt, lyrics: spec.lyrics, durationSeconds: spec.durationSeconds ?? 0 },
|
|
863
931
|
};
|
|
932
|
+
case 'world-generate':
|
|
933
|
+
return { oneofKind: 'worldGenerate', worldGenerate: { prompt: spec.prompt, displayName: spec.displayName } };
|
|
864
934
|
}
|
|
865
935
|
}
|
|
866
936
|
function runtimeImageSpec(spec) {
|
|
@@ -967,7 +1037,10 @@ function projectRuntimeScenarioExecuteResponse(response) {
|
|
|
967
1037
|
}
|
|
968
1038
|
}
|
|
969
1039
|
function projectRuntimeLocalJob(job) {
|
|
1040
|
+
const interruption = localInterruptionFromRuntime(job.interruption);
|
|
970
1041
|
return {
|
|
1042
|
+
...(job.videoFaceSwapSummary ? { videoFaceSwapSummary: { ...job.videoFaceSwapSummary, durationUs: runtimeSafeInteger(job.videoFaceSwapSummary.durationUs, 'video duration') } } : {}),
|
|
1043
|
+
...(interruption ? { interruption } : {}),
|
|
971
1044
|
jobId: job.jobId,
|
|
972
1045
|
scenarioType: runtimeScenarioTypeName(job.scenarioType),
|
|
973
1046
|
status: runtimeJobStatusName(job.status),
|
|
@@ -1016,12 +1089,16 @@ function projectRuntimeVoiceReference(reference) {
|
|
|
1016
1089
|
}
|
|
1017
1090
|
function runtimeScenarioTypeName(value) {
|
|
1018
1091
|
const types = {
|
|
1092
|
+
[ScenarioType.VIDEO_FACE_SWAP]: 'video-face-swap',
|
|
1093
|
+
[ScenarioType.IMAGE_FACE_SWAP]: 'image-face-swap',
|
|
1094
|
+
[ScenarioType.VISION_LOCATE]: 'vision-locate',
|
|
1019
1095
|
[ScenarioType.IMAGE_GENERATE]: 'image-generate',
|
|
1020
1096
|
[ScenarioType.VIDEO_GENERATE]: 'video-generate',
|
|
1021
1097
|
[ScenarioType.SPEECH_SYNTHESIZE]: 'speech-synthesize',
|
|
1022
1098
|
[ScenarioType.SPEECH_TRANSCRIBE]: 'speech-transcribe',
|
|
1023
1099
|
[ScenarioType.VOICE_CREATE]: 'voice-create',
|
|
1024
1100
|
[ScenarioType.MUSIC_GENERATE]: 'music-generate',
|
|
1101
|
+
[ScenarioType.WORLD_GENERATE]: 'world-generate',
|
|
1025
1102
|
};
|
|
1026
1103
|
return types[value] ?? localAppProjectionError('scenario Runtime type');
|
|
1027
1104
|
}
|
|
@@ -1098,7 +1175,7 @@ function localVoiceCreationSource(source) {
|
|
|
1098
1175
|
return 'text-description';
|
|
1099
1176
|
return localAppProjectionError('voice asset creationSource');
|
|
1100
1177
|
}
|
|
1101
|
-
const LOCAL_SCENARIO_TYPES = ['image-generate', 'video-generate', 'speech-synthesize', 'speech-transcribe', 'voice-create', 'music-generate'];
|
|
1178
|
+
const LOCAL_SCENARIO_TYPES = ['image-generate', 'image-face-swap', 'video-face-swap', 'vision-locate', 'video-generate', 'speech-synthesize', 'speech-transcribe', 'voice-create', 'music-generate', 'world-generate'];
|
|
1102
1179
|
const LOCAL_JOB_STATUSES = ['submitted', 'queued', 'running', 'completed', 'failed', 'canceled', 'timeout'];
|
|
1103
1180
|
function localJobSpecFromRuntimeRequest(request) {
|
|
1104
1181
|
assertExactKeys(request, ['head', 'scenarioType', 'executionMode', 'spec', 'requestId', 'idempotencyKey', 'labels', 'extensions'], 'Runtime Scenario Job adapter request');
|
|
@@ -1108,6 +1185,15 @@ function localJobSpecFromRuntimeRequest(request) {
|
|
|
1108
1185
|
if (!spec || spec.oneofKind === undefined)
|
|
1109
1186
|
adapterInputError('missing Scenario spec');
|
|
1110
1187
|
switch (spec.oneofKind) {
|
|
1188
|
+
case 'videoFaceSwap':
|
|
1189
|
+
requireScenarioType(request, ScenarioType.VIDEO_FACE_SWAP);
|
|
1190
|
+
return validateScenarioSpec({ type: 'video-face-swap', referenceImageArtifactId: spec.videoFaceSwap.referenceImageArtifactId, targetVideoArtifactId: spec.videoFaceSwap.targetVideoArtifactId, noFacePolicy: spec.videoFaceSwap.noFacePolicy === FaceSwapNoFacePolicy.FAIL ? 'fail' : spec.videoFaceSwap.noFacePolicy === FaceSwapNoFacePolicy.PRESERVE_FRAME ? 'preserve-frame' : adapterInputError('video no-face policy is required') }, false);
|
|
1191
|
+
case 'imageFaceSwap':
|
|
1192
|
+
requireScenarioType(request, ScenarioType.IMAGE_FACE_SWAP);
|
|
1193
|
+
return validateScenarioSpec({ type: 'image-face-swap', referenceImageArtifactId: spec.imageFaceSwap.referenceImageArtifactId, targetImageArtifactId: spec.imageFaceSwap.targetImageArtifactId }, false);
|
|
1194
|
+
case 'visionLocate':
|
|
1195
|
+
requireScenarioType(request, ScenarioType.VISION_LOCATE);
|
|
1196
|
+
return validateScenarioSpec({ type: 'vision-locate', imageArtifactId: spec.visionLocate.imageArtifactId, query: spec.visionLocate.query, geometry: localLocateGeometry(spec.visionLocate.geometry) }, false);
|
|
1111
1197
|
case 'imageGenerate':
|
|
1112
1198
|
requireScenarioType(request, ScenarioType.IMAGE_GENERATE);
|
|
1113
1199
|
return validateScenarioSpec({
|
|
@@ -1168,10 +1254,17 @@ function localJobSpecFromRuntimeRequest(request) {
|
|
|
1168
1254
|
case 'musicGenerate':
|
|
1169
1255
|
requireScenarioType(request, ScenarioType.MUSIC_GENERATE);
|
|
1170
1256
|
if (spec.musicGenerate.negativePrompt || spec.musicGenerate.style || spec.musicGenerate.title
|
|
1171
|
-
|| spec.musicGenerate.
|
|
1257
|
+
|| spec.musicGenerate.instrumental) {
|
|
1172
1258
|
return adapterInputError('unsupported MiniMax-Music3 fields are unavailable to Local Apps');
|
|
1173
1259
|
}
|
|
1174
|
-
return validateScenarioSpec({ type: 'music-generate', prompt: spec.musicGenerate.prompt, lyrics: spec.musicGenerate.lyrics
|
|
1260
|
+
return validateScenarioSpec({ type: 'music-generate', prompt: spec.musicGenerate.prompt, lyrics: spec.musicGenerate.lyrics,
|
|
1261
|
+
...(spec.musicGenerate.durationSeconds !== 0 ? { durationSeconds: spec.musicGenerate.durationSeconds } : {}) }, false);
|
|
1262
|
+
case 'worldGenerate':
|
|
1263
|
+
requireScenarioType(request, ScenarioType.WORLD_GENERATE);
|
|
1264
|
+
if (spec.worldGenerate.conditioning.oneofKind !== undefined || spec.worldGenerate.tags.length > 0 || spec.worldGenerate.seed !== '0') {
|
|
1265
|
+
return adapterInputError('Local App worlds accept text conditioning only');
|
|
1266
|
+
}
|
|
1267
|
+
return validateScenarioSpec({ type: 'world-generate', prompt: spec.worldGenerate.textPrompt, displayName: spec.worldGenerate.displayName }, false);
|
|
1175
1268
|
default:
|
|
1176
1269
|
return adapterInputError(`Scenario type ${spec.oneofKind} is unavailable to Local Apps`);
|
|
1177
1270
|
}
|
|
@@ -1251,6 +1344,8 @@ function runtimeVoiceAudio(bytes, uri) {
|
|
|
1251
1344
|
}
|
|
1252
1345
|
function runtimeJobFromLocal(job) {
|
|
1253
1346
|
return {
|
|
1347
|
+
...(job.videoFaceSwapSummary ? { videoFaceSwapSummary: { ...job.videoFaceSwapSummary, durationUs: String(job.videoFaceSwapSummary.durationUs) } } : {}),
|
|
1348
|
+
...(job.interruption ? { interruption: runtimeInterruptionFromLocal(job.interruption) } : {}),
|
|
1254
1349
|
jobId: job.jobId, head: undefined, scenarioType: runtimeScenarioType(job.scenarioType), executionMode: ExecutionMode.ASYNC_JOB,
|
|
1255
1350
|
routeDecision: RoutePolicy.UNSPECIFIED, modelResolved: '', status: runtimeJobStatus(job.status), providerJobId: '',
|
|
1256
1351
|
reasonCode: runtimeReasonCode(job.reasonCode), reasonDetail: job.reasonDetail, retryCount: 0,
|
|
@@ -1278,11 +1373,13 @@ function runtimeJobEventFromLocal(event) {
|
|
|
1278
1373
|
return { eventType: runtimeJobEventType(event.eventType), sequence: event.sequence, traceId: event.traceId, timestamp: runtimeTimestamp(event.timestamp), job: runtimeJobFromLocal(event.job) };
|
|
1279
1374
|
}
|
|
1280
1375
|
function runtimeArtifactResponse(job, artifacts) {
|
|
1281
|
-
const output = runtimeOutput(job.scenarioType, artifacts, job.transcriptionText);
|
|
1376
|
+
const output = runtimeOutput(job.scenarioType, artifacts, job.transcriptionText, job.videoFaceSwapSummary);
|
|
1282
1377
|
return { jobId: job.jobId, artifacts, traceId: job.traceId, output };
|
|
1283
1378
|
}
|
|
1284
|
-
function runtimeOutput(type, artifacts, transcriptionText) {
|
|
1379
|
+
function runtimeOutput(type, artifacts, transcriptionText, videoFaceSwapSummary) {
|
|
1285
1380
|
switch (type) {
|
|
1381
|
+
case 'video-face-swap': return videoFaceSwapSummary ? { output: { oneofKind: 'videoFaceSwap', videoFaceSwap: { artifacts, summary: { ...videoFaceSwapSummary, durationUs: String(videoFaceSwapSummary.durationUs) } } } } : undefined;
|
|
1382
|
+
case 'image-face-swap': return { output: { oneofKind: 'imageFaceSwap', imageFaceSwap: { artifacts } } };
|
|
1286
1383
|
case 'image-generate': return { output: { oneofKind: 'imageGenerate', imageGenerate: { artifacts } } };
|
|
1287
1384
|
case 'video-generate': return { output: { oneofKind: 'videoGenerate', videoGenerate: { artifacts } } };
|
|
1288
1385
|
case 'speech-synthesize': return { output: { oneofKind: 'speechSynthesize', speechSynthesize: { artifacts } } };
|
|
@@ -1296,7 +1393,7 @@ function runtimeOutput(type, artifacts, transcriptionText) {
|
|
|
1296
1393
|
}
|
|
1297
1394
|
}
|
|
1298
1395
|
function runtimeScenarioType(type) {
|
|
1299
|
-
return ({ 'image-generate': ScenarioType.IMAGE_GENERATE, 'video-generate': ScenarioType.VIDEO_GENERATE, 'speech-synthesize': ScenarioType.SPEECH_SYNTHESIZE, 'speech-transcribe': ScenarioType.SPEECH_TRANSCRIBE, 'voice-create': ScenarioType.VOICE_CREATE, 'music-generate': ScenarioType.MUSIC_GENERATE })[type];
|
|
1396
|
+
return ({ 'image-generate': ScenarioType.IMAGE_GENERATE, 'image-face-swap': ScenarioType.IMAGE_FACE_SWAP, 'video-face-swap': ScenarioType.VIDEO_FACE_SWAP, 'vision-locate': ScenarioType.VISION_LOCATE, 'video-generate': ScenarioType.VIDEO_GENERATE, 'speech-synthesize': ScenarioType.SPEECH_SYNTHESIZE, 'speech-transcribe': ScenarioType.SPEECH_TRANSCRIBE, 'voice-create': ScenarioType.VOICE_CREATE, 'music-generate': ScenarioType.MUSIC_GENERATE, 'world-generate': ScenarioType.WORLD_GENERATE })[type];
|
|
1300
1397
|
}
|
|
1301
1398
|
function runtimeJobStatus(status) {
|
|
1302
1399
|
return ({ submitted: ScenarioJobStatus.SUBMITTED, queued: ScenarioJobStatus.QUEUED, running: ScenarioJobStatus.RUNNING, completed: ScenarioJobStatus.COMPLETED, failed: ScenarioJobStatus.FAILED, canceled: ScenarioJobStatus.CANCELED, timeout: ScenarioJobStatus.TIMEOUT })[status];
|