@nimiplatform/sdk 0.15.0 → 0.21.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/CHANGELOG.md +430 -1
- package/README.md +125 -18
- package/dist/core/ai/capability-configuration.d.ts +15 -0
- package/dist/core/ai/capability-configuration.d.ts.map +1 -1
- package/dist/core/ai/capability-configuration.js +36 -0
- package/dist/core/ai/capability-configuration.js.map +1 -1
- package/dist/core/ai/embeddings.d.ts +5 -0
- package/dist/core/ai/embeddings.d.ts.map +1 -1
- package/dist/core/ai/embeddings.js +30 -4
- package/dist/core/ai/embeddings.js.map +1 -1
- package/dist/core/ai/index.d.ts +4 -0
- package/dist/core/ai/index.d.ts.map +1 -1
- package/dist/core/ai/index.js +3 -0
- package/dist/core/ai/index.js.map +1 -1
- package/dist/core/ai/local-app-model.d.ts +15 -4
- package/dist/core/ai/local-app-model.d.ts.map +1 -1
- package/dist/core/ai/local-app-model.js +57 -18
- package/dist/core/ai/local-app-model.js.map +1 -1
- package/dist/core/ai/music-input-wire.d.ts +4 -0
- package/dist/core/ai/music-input-wire.d.ts.map +1 -0
- package/dist/core/ai/music-input-wire.js +9 -0
- package/dist/core/ai/music-input-wire.js.map +1 -0
- package/dist/core/ai/music-input.d.ts +44 -0
- package/dist/core/ai/music-input.d.ts.map +1 -0
- package/dist/core/ai/music-input.js +69 -0
- package/dist/core/ai/music-input.js.map +1 -0
- package/dist/core/ai/reasoning.d.ts +32 -0
- package/dist/core/ai/reasoning.d.ts.map +1 -0
- package/dist/core/ai/reasoning.js +74 -0
- package/dist/core/ai/reasoning.js.map +1 -0
- package/dist/core/ai/runtime-model.d.ts +2 -19
- package/dist/core/ai/runtime-model.d.ts.map +1 -1
- package/dist/core/ai/runtime-model.js +3 -47
- package/dist/core/ai/runtime-model.js.map +1 -1
- package/dist/core/ai/speech-input.d.ts +9 -0
- package/dist/core/ai/speech-input.d.ts.map +1 -0
- package/dist/core/ai/speech-input.js +16 -0
- package/dist/core/ai/speech-input.js.map +1 -0
- package/dist/core/ai/text-runner.js +11 -4
- package/dist/core/ai/text-runner.js.map +1 -1
- package/dist/core/app/desktop-open.d.ts +4 -1
- package/dist/core/app/desktop-open.d.ts.map +1 -1
- package/dist/core/app/desktop-open.js +5 -1
- package/dist/core/app/desktop-open.js.map +1 -1
- package/dist/core/app/index.d.ts +29 -4
- package/dist/core/app/index.d.ts.map +1 -1
- package/dist/core/app/index.js +18 -0
- package/dist/core/app/index.js.map +1 -1
- package/dist/core/app/local-app-agent-introduction.d.ts +30 -0
- package/dist/core/app/local-app-agent-introduction.d.ts.map +1 -0
- package/dist/core/app/local-app-agent-introduction.js +64 -0
- package/dist/core/app/local-app-agent-introduction.js.map +1 -0
- package/dist/core/app/local-app-agent-work-input.d.ts +24 -0
- package/dist/core/app/local-app-agent-work-input.d.ts.map +1 -0
- package/dist/core/app/local-app-agent-work-input.js +50 -0
- package/dist/core/app/local-app-agent-work-input.js.map +1 -0
- package/dist/core/app/local-app-audio-separation.d.ts +9 -0
- package/dist/core/app/local-app-audio-separation.d.ts.map +1 -1
- package/dist/core/app/local-app-audio-separation.js +64 -3
- package/dist/core/app/local-app-audio-separation.js.map +1 -1
- package/dist/core/app/local-app-bytes.d.ts +10 -0
- package/dist/core/app/local-app-bytes.d.ts.map +1 -0
- package/dist/core/app/local-app-bytes.js +27 -0
- package/dist/core/app/local-app-bytes.js.map +1 -0
- package/dist/core/app/local-app-music-transcription.d.ts +43 -0
- package/dist/core/app/local-app-music-transcription.d.ts.map +1 -0
- package/dist/core/app/local-app-music-transcription.js +94 -0
- package/dist/core/app/local-app-music-transcription.js.map +1 -0
- package/dist/core/app/local-app-music.d.ts +50 -0
- package/dist/core/app/local-app-music.d.ts.map +1 -0
- package/dist/core/app/local-app-music.js +135 -0
- package/dist/core/app/local-app-music.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts +59 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.js +283 -0
- package/dist/core/app/local-app-runtime-platform-activity-view.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity.d.ts +219 -0
- package/dist/core/app/local-app-runtime-platform-activity.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-activity.js +749 -0
- package/dist/core/app/local-app-runtime-platform-activity.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-agent-references.d.ts +4 -0
- package/dist/core/app/local-app-runtime-platform-agent-references.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-references.js +21 -9
- package/dist/core/app/local-app-runtime-platform-agent-references.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-agent-work.d.ts +88 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.js +165 -0
- package/dist/core/app/local-app-runtime-platform-agent-work.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-ai-config.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.js +55 -1
- package/dist/core/app/local-app-runtime-platform-ai-config.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.d.ts +154 -36
- package/dist/core/app/local-app-runtime-platform-ai.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-ai.js +738 -121
- package/dist/core/app/local-app-runtime-platform-ai.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-assets.js +37 -12
- package/dist/core/app/local-app-runtime-platform-assets.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.d.ts +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-configure.js +10 -10
- package/dist/core/app/local-app-runtime-platform-configure.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts +7 -4
- package/dist/core/app/local-app-runtime-platform-conversation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-conversation.js +15 -10
- package/dist/core/app/local-app-runtime-platform-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.d.ts +5 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.js +38 -0
- package/dist/core/app/local-app-runtime-platform-direct-agent-work.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js +6 -6
- package/dist/core/app/local-app-runtime-platform-direct-conversation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-integration.d.ts +128 -0
- package/dist/core/app/local-app-runtime-platform-integration.d.ts.map +1 -0
- package/dist/core/app/local-app-runtime-platform-integration.js +263 -0
- package/dist/core/app/local-app-runtime-platform-integration.js.map +1 -0
- package/dist/core/app/local-app-runtime-platform-validation.d.ts +2 -0
- package/dist/core/app/local-app-runtime-platform-validation.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-validation.js +42 -3
- package/dist/core/app/local-app-runtime-platform-validation.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.d.ts +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform-vision.js +5 -5
- package/dist/core/app/local-app-runtime-platform-vision.js.map +1 -1
- package/dist/core/app/local-app-runtime-platform.d.ts +19 -15
- package/dist/core/app/local-app-runtime-platform.d.ts.map +1 -1
- package/dist/core/app/local-app-runtime-platform.js +17 -6
- package/dist/core/app/local-app-runtime-platform.js.map +1 -1
- package/dist/core/app/local-app-speaker-embedding.d.ts +6 -0
- package/dist/core/app/local-app-speaker-embedding.d.ts.map +1 -0
- package/dist/core/app/local-app-speaker-embedding.js +14 -0
- package/dist/core/app/local-app-speaker-embedding.js.map +1 -0
- package/dist/core/app/local-app-text-decision.d.ts +114 -0
- package/dist/core/app/local-app-text-decision.d.ts.map +1 -0
- package/dist/core/app/local-app-text-decision.js +444 -0
- package/dist/core/app/local-app-text-decision.js.map +1 -0
- package/dist/core/app/local-app-text.d.ts +7 -1
- package/dist/core/app/local-app-text.d.ts.map +1 -1
- package/dist/core/app/local-app-text.js +16 -15
- package/dist/core/app/local-app-text.js.map +1 -1
- package/dist/core/app/local-app-transcription.d.ts +11 -0
- package/dist/core/app/local-app-transcription.d.ts.map +1 -1
- package/dist/core/app/local-app-transcription.js +22 -2
- package/dist/core/app/local-app-transcription.js.map +1 -1
- package/dist/core/app/local-app-voice-convert.d.ts +61 -0
- package/dist/core/app/local-app-voice-convert.d.ts.map +1 -0
- package/dist/core/app/local-app-voice-convert.js +133 -0
- package/dist/core/app/local-app-voice-convert.js.map +1 -0
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts +2 -2
- package/dist/core/app/runtime-account-realm-source-readiness.generated.d.ts.map +1 -1
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js +5 -3
- package/dist/core/app/runtime-account-realm-source-readiness.generated.js.map +1 -1
- package/dist/core/text-stream-cleanup.d.ts +3 -0
- package/dist/core/text-stream-cleanup.d.ts.map +1 -0
- package/dist/core/text-stream-cleanup.js +19 -0
- package/dist/core/text-stream-cleanup.js.map +1 -0
- package/dist/core-generated/realm-client.d.ts.map +1 -1
- package/dist/core-generated/realm-client.js +10 -4
- package/dist/core-generated/realm-client.js.map +1 -1
- package/dist/core-generated/realm-typed-client.d.ts +86 -29
- package/dist/core-generated/realm-typed-client.d.ts.map +1 -1
- package/dist/core-generated/realm-typed-client.js +19 -8
- package/dist/core-generated/realm-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-client.js +312 -0
- package/dist/core-generated/runtime-client.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts +21 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js +41 -5
- package/dist/core-generated/runtime-protobuf/runtime/v1/account.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.d.ts +158 -1
- 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 +299 -2
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_service.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.d.ts +5 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.js +4 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_source_materialization.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.d.ts +625 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.js +1369 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/agent_work.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts +1872 -106
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js +4718 -1513
- package/dist/core-generated/runtime-protobuf/runtime/v1/ai.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts +40 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js +72 -3
- package/dist/core-generated/runtime-protobuf/runtime/v1/app.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.d.ts +859 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.js +1663 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/app_activity.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/auth.d.ts +20 -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 +38 -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 +456 -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 +869 -6
- 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 +146 -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 +145 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/common.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts +43 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js +88 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/connector.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.d.ts +53 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.js +118 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/development.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts +1293 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.d.ts.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js +2898 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/integration.js.map +1 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.d.ts +166 -0
- 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 +217 -4
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.d.ts +8 -0
- 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 +9 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/local_runtime_recommendation.js.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts +69 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.d.ts.map +1 -1
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.js +120 -0
- package/dist/core-generated/runtime-protobuf/runtime/v1/runtime_service_control.js.map +1 -1
- package/dist/core-generated/runtime-public-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-client.js +296 -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 +37 -1
- package/dist/core-generated/runtime-public-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.d.ts +44 -5
- package/dist/core-generated/runtime-public-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-public-wire-codecs.js +44 -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 +39 -0
- package/dist/core-generated/runtime-rpc-auth-posture.js.map +1 -1
- package/dist/core-generated/runtime-typed-client.d.ts +66 -16
- package/dist/core-generated/runtime-typed-client.d.ts.map +1 -1
- package/dist/core-generated/runtime-typed-client.js +398 -3
- package/dist/core-generated/runtime-typed-client.js.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.d.ts +47 -5
- package/dist/core-generated/runtime-wire-codecs.d.ts.map +1 -1
- package/dist/core-generated/runtime-wire-codecs.js +47 -5
- package/dist/core-generated/runtime-wire-codecs.js.map +1 -1
- package/dist/features/generation/index.d.ts +14 -2
- package/dist/features/generation/index.d.ts.map +1 -1
- package/dist/features/generation/index.js +14 -1
- package/dist/features/generation/index.js.map +1 -1
- package/dist/features/generation/media-params.d.ts +0 -3
- package/dist/features/generation/media-params.d.ts.map +1 -1
- package/dist/features/generation/media-params.js +8 -6
- package/dist/features/generation/media-params.js.map +1 -1
- package/dist/features/generation/runtime-generation-build.d.ts +0 -1
- package/dist/features/generation/runtime-generation-build.d.ts.map +1 -1
- package/dist/features/generation/runtime-generation-build.js +6 -1
- package/dist/features/generation/runtime-generation-build.js.map +1 -1
- package/dist/features/generation/runtime-image-generation.d.ts +5 -1
- package/dist/features/generation/runtime-image-generation.d.ts.map +1 -1
- package/dist/features/generation/runtime-image-generation.js +4 -0
- package/dist/features/generation/runtime-image-generation.js.map +1 -1
- package/dist/features/generation/runtime-job-builders.d.ts +0 -1
- package/dist/features/generation/runtime-job-builders.d.ts.map +1 -1
- package/dist/features/generation/runtime-job-builders.js +8 -10
- package/dist/features/generation/runtime-job-builders.js.map +1 -1
- package/dist/realm/index.d.ts +1 -1
- package/dist/realm/index.d.ts.map +1 -1
- package/dist/realm/index.js +3 -2
- package/dist/realm/index.js.map +1 -1
- package/dist/runtime/chatgpt-plan.d.ts +7 -0
- package/dist/runtime/chatgpt-plan.d.ts.map +1 -0
- package/dist/runtime/chatgpt-plan.js +15 -0
- package/dist/runtime/chatgpt-plan.js.map +1 -0
- package/dist/runtime/config-projections.d.ts +2 -0
- package/dist/runtime/config-projections.d.ts.map +1 -1
- package/dist/runtime/config-projections.js +3 -0
- package/dist/runtime/config-projections.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition-client.d.ts +3 -6
- package/dist/runtime/connector-auth-acquisition-client.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition-client.js +18 -11
- package/dist/runtime/connector-auth-acquisition-client.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition-profiles.generated.d.ts +10 -11
- package/dist/runtime/connector-auth-acquisition-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition-profiles.generated.js +13 -14
- package/dist/runtime/connector-auth-acquisition-profiles.generated.js.map +1 -1
- package/dist/runtime/connector-auth-acquisition.d.ts +26 -19
- package/dist/runtime/connector-auth-acquisition.d.ts.map +1 -1
- package/dist/runtime/connector-auth-acquisition.js +352 -269
- package/dist/runtime/connector-auth-acquisition.js.map +1 -1
- package/dist/runtime/connector-auth-profiles.generated.d.ts +1 -1
- package/dist/runtime/connector-auth-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/connector-auth-profiles.generated.js +4 -4
- package/dist/runtime/connector-auth-profiles.generated.js.map +1 -1
- package/dist/runtime/connector-inventory.d.ts +11 -2
- package/dist/runtime/connector-inventory.d.ts.map +1 -1
- package/dist/runtime/connector-inventory.js +10 -1
- package/dist/runtime/connector-inventory.js.map +1 -1
- package/dist/runtime/desktop-audit.js +4 -1
- package/dist/runtime/desktop-audit.js.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts +130 -2
- package/dist/runtime/first-party-protected-runtime-profiles.generated.d.ts.map +1 -1
- package/dist/runtime/first-party-protected-runtime-profiles.generated.js +34 -2
- 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/host.d.ts +3 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/host.js +4 -0
- package/dist/runtime/host.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/machine-loadouts.d.ts +18 -0
- package/dist/runtime/machine-loadouts.d.ts.map +1 -1
- package/dist/runtime/machine-loadouts.js +26 -0
- package/dist/runtime/machine-loadouts.js.map +1 -1
- package/dist/runtime/node-grpc-errors.js +3 -3
- package/dist/runtime/node-grpc-errors.js.map +1 -1
- package/dist/runtime/product-control-projection.d.ts.map +1 -1
- package/dist/runtime/product-control-projection.js +11 -2
- package/dist/runtime/product-control-projection.js.map +1 -1
- package/dist/runtime/product-control-types.d.ts +13 -2
- package/dist/runtime/product-control-types.d.ts.map +1 -1
- package/dist/runtime/product-control-types.js.map +1 -1
- package/dist/runtime/reason-messages.d.ts +3 -0
- package/dist/runtime/reason-messages.d.ts.map +1 -1
- package/dist/runtime/reason-messages.js +11 -2
- package/dist/runtime/reason-messages.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-projections.js +19 -19
- package/dist/runtime/runtime-local-environment-client-projections.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client-types.d.ts +42 -20
- package/dist/runtime/runtime-local-environment-client-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-values.d.ts +3 -1
- package/dist/runtime/runtime-local-environment-client-values.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client-values.js +43 -0
- package/dist/runtime/runtime-local-environment-client-values.js.map +1 -1
- package/dist/runtime/runtime-local-environment-client.d.ts.map +1 -1
- package/dist/runtime/runtime-local-environment-client.js +7 -2
- package/dist/runtime/runtime-local-environment-client.js.map +1 -1
- package/dist/runtime/runtime-local-recommendation-types.d.ts +3 -0
- package/dist/runtime/runtime-local-recommendation-types.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.d.ts.map +1 -1
- package/dist/runtime/runtime-local-recommendation.js +1 -0
- package/dist/runtime/runtime-local-recommendation.js.map +1 -1
- package/dist/runtime/scenario-jobs.d.ts +23 -1
- package/dist/runtime/scenario-jobs.d.ts.map +1 -1
- package/dist/runtime/scenario-jobs.js +227 -264
- package/dist/runtime/scenario-jobs.js.map +1 -1
- package/dist/runtime/shared-local-agent-ai-config.d.ts.map +1 -1
- package/dist/runtime/shared-local-agent-ai-config.js +3 -0
- package/dist/runtime/shared-local-agent-ai-config.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-enums.d.ts +2 -1
- package/dist/runtime/wire-types/agent-participation-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/agent-participation-enums.js +2 -1
- package/dist/runtime/wire-types/agent-participation-enums.js.map +1 -1
- package/dist/runtime/wire-types/agent-participation-types.d.ts +4 -2
- package/dist/runtime/wire-types/agent-participation-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts +112 -3
- package/dist/runtime/wire-types/ai-scenario-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-enums.js +128 -0
- package/dist/runtime/wire-types/ai-scenario-enums.js.map +1 -1
- package/dist/runtime/wire-types/ai-scenario-types.d.ts +8 -6
- package/dist/runtime/wire-types/ai-scenario-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.d.ts +47 -0
- package/dist/runtime/wire-types/identity-app-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/identity-app-enums.js +55 -0
- package/dist/runtime/wire-types/identity-app-enums.js.map +1 -1
- package/dist/runtime/wire-types/identity-app-types.d.ts +6 -4
- package/dist/runtime/wire-types/identity-app-types.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts +31 -1
- package/dist/runtime/wire-types/local-memory-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/local-memory-enums.js +34 -0
- package/dist/runtime/wire-types/local-memory-enums.js.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts +28 -1
- package/dist/runtime/wire-types/reason-code-enums.d.ts.map +1 -1
- package/dist/runtime/wire-types/reason-code-enums.js +27 -0
- package/dist/runtime/wire-types/reason-code-enums.js.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +2 -2
- package/dist/types/errors.js.map +1 -1
- package/dist/types/reason-code.d.ts +2 -0
- package/dist/types/reason-code.d.ts.map +1 -1
- package/dist/types/reason-code.js +2 -0
- package/dist/types/reason-code.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import { validateNimiLocalAppVoiceConvertSpec, validateNimiLocalAppVoiceConversion, runtimeVoiceConvertSpec, localVoiceConvertSpec, localVoiceConversion, runtimeVoiceConversion } from './local-app-voice-convert.js';
|
|
2
|
+
import { validateNimiLocalAppMusicTranscribeSpec, validateNimiLocalAppMusicTranscription, runtimeMusicTranscribeSpec, localMusicTranscribeSpec, localMusicTranscription, runtimeMusicTranscription } from './local-app-music-transcription.js';
|
|
3
|
+
import { validateNimiLocalAppMusicGenerateSpec, validateNimiLocalAppMusicGeneration, runtimeMusicGenerateSpec, localMusicGenerateSpec, localMusicGeneration, runtimeMusicGeneration } from './local-app-music.js';
|
|
1
4
|
import { validateNimiLocalAppTextAnnotationResult } from './local-app-text-annotation.js';
|
|
2
5
|
import { validateNimiLocalAppSpeechTranscript } from './local-app-transcription.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
6
|
+
import { validateNimiLocalAppSpeakerEmbedding } from './local-app-speaker-embedding.js';
|
|
7
|
+
import { validateNimiLocalAppAudioSeparation, localAudioSeparation, runtimeAudioSeparation } from './local-app-audio-separation.js';
|
|
8
|
+
import { prepareNimiLocalAppTextDecideSpec, validateNimiLocalAppTextDecideOutput, runtimeTextDecideSpec, localTextDecideOutputFromRuntime, } from './local-app-text-decision.js';
|
|
9
|
+
import { ReasonCode, createNimiError } from '../../types/index.js';
|
|
10
|
+
import { withTextStreamCleanupFailure } from '../text-stream-cleanup.js';
|
|
11
|
+
import { TextEmbedPurpose } from '../../core-generated/runtime-protobuf/runtime/v1/ai.js';
|
|
12
|
+
import { copyNimiLocalAppBytes, exactNimiLocalAppBytes, isNimiLocalAppByteView } from './local-app-bytes.js';
|
|
13
|
+
import { CanonicalChannelMode, ChatContentPartType, ExecutionMode, FaceSwapNoFacePolicy, FinishReason, ResponseFormatKind, ToolChoiceMode, ReasonCode as RuntimeReasonCode, RoutePolicy, ScenarioJobEventType, ScenarioJobStatus, ScenarioType, SpeechTimingMode, SpeechTranscriptStatus, SpeechDiarizationStatus, VideoContentRole, VideoContentType, VideoMode, VoiceAssetStatus, VoiceCreationSource, VoiceReferenceKind, VisionLocateGeometry, WorldImageProjection, } from '../../core-generated/runtime-typed-client.js';
|
|
5
14
|
import { toRuntimeMessages, toRuntimeTools, toRuntimeStruct, toNimiToolCall, toNimiTextOutputItems } from '../ai/runtime-model-text-projection.js';
|
|
15
|
+
import { toRuntimeReasoningConfig } from '../ai/reasoning.js';
|
|
6
16
|
import { validateLocalAppTextInput, projectLocalAppToolCall, projectLocalAppTextItems, projectLocalAppContinuity, modelTextOutputToLocalApp, localAppTextOutputToModel, } from './local-app-text.js';
|
|
7
|
-
import { asRecord, assertExactKeys, assertExactProjectionKeys, assertNoAuthorityMaterial, assertSafeProjection, localAppError, localAppProjectionError, projectionText, requireText, } from './local-app-runtime-platform-validation.js';
|
|
17
|
+
import { asRecord, assertExactKeys, assertExactProjectionKeys, assertNoAuthorityMaterial, assertSafeProjection, projectLocalAppSpeechAlignment, localAppError, localAppProjectionError, projectionText, requireText, } from './local-app-runtime-platform-validation.js';
|
|
8
18
|
import { projectVisionLocateResult, localVisionLocateFromRuntime, runtimeVisionLocateFromLocal, localLocateGeometry, projectLocalExecutionInterruption, localInterruptionFromRuntime, runtimeInterruptionFromLocal, } from './local-app-runtime-platform-vision.js';
|
|
9
19
|
const MAX_RESULT_BYTES = 256 * 1024;
|
|
10
20
|
const MAX_ARTIFACT_BYTES = 32 * 1024 * 1024;
|
|
@@ -25,6 +35,11 @@ export function createNimiLocalAppAIConsumptionClient(shell) {
|
|
|
25
35
|
let sequence = 0n;
|
|
26
36
|
let terminal = false;
|
|
27
37
|
let hasPrimary = false;
|
|
38
|
+
let lastIndex = -1;
|
|
39
|
+
let lastKind = '';
|
|
40
|
+
let summaryOpen = false;
|
|
41
|
+
let failed = false;
|
|
42
|
+
let primaryFailure;
|
|
28
43
|
const toolIds = new Set();
|
|
29
44
|
try {
|
|
30
45
|
for await (const event of stream) {
|
|
@@ -32,6 +47,23 @@ export function createNimiLocalAppAIConsumptionClient(shell) {
|
|
|
32
47
|
break;
|
|
33
48
|
if (terminal || BigInt(event.sequence) !== ++sequence)
|
|
34
49
|
localAppProjectionError('text-turn event sequence');
|
|
50
|
+
if ('itemIndex' in event) {
|
|
51
|
+
if (event.itemIndex === lastIndex) {
|
|
52
|
+
if (!(event.type === 'delta' && lastKind === 'delta') && !(event.type === 'reasoning-summary' && lastKind === 'reasoning-summary' && summaryOpen))
|
|
53
|
+
localAppProjectionError('text-turn item sequence');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (event.itemIndex !== lastIndex + 1 || summaryOpen)
|
|
57
|
+
localAppProjectionError('text-turn item sequence');
|
|
58
|
+
lastIndex = event.itemIndex;
|
|
59
|
+
lastKind = event.type;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (event.type === 'reasoning-summary') {
|
|
63
|
+
if (input.reasoning?.presentation !== 'summary')
|
|
64
|
+
localAppProjectionError('unrequested reasoning summary');
|
|
65
|
+
summaryOpen = !event.itemCompleted;
|
|
66
|
+
}
|
|
35
67
|
if (event.type === 'delta')
|
|
36
68
|
hasPrimary = true;
|
|
37
69
|
if (event.type === 'tool-call') {
|
|
@@ -40,28 +72,64 @@ export function createNimiLocalAppAIConsumptionClient(shell) {
|
|
|
40
72
|
localAppProjectionError('duplicate text tool call');
|
|
41
73
|
toolIds.add(event.toolCall.id);
|
|
42
74
|
}
|
|
43
|
-
if (event.type === 'completed' && !hasPrimary)
|
|
44
|
-
localAppProjectionError('missing primary text output');
|
|
75
|
+
if (event.type === 'completed' && (!hasPrimary || summaryOpen))
|
|
76
|
+
localAppProjectionError('missing primary text output or incomplete summary');
|
|
45
77
|
terminal = event.type === 'completed' || event.type === 'failed';
|
|
46
78
|
yield event;
|
|
47
79
|
}
|
|
48
80
|
if (!terminal && !canceled)
|
|
49
81
|
localAppProjectionError('text-turn missing terminal event');
|
|
50
82
|
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
failed = true;
|
|
85
|
+
primaryFailure = error;
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
51
88
|
finally {
|
|
52
|
-
|
|
89
|
+
try {
|
|
90
|
+
await cancel();
|
|
91
|
+
}
|
|
92
|
+
catch (cleanupError) {
|
|
93
|
+
if (failed)
|
|
94
|
+
throw withTextStreamCleanupFailure(primaryFailure, cleanupError);
|
|
95
|
+
throw cleanupError;
|
|
96
|
+
}
|
|
53
97
|
}
|
|
54
98
|
},
|
|
55
99
|
cancel,
|
|
56
100
|
});
|
|
57
101
|
},
|
|
58
102
|
}),
|
|
103
|
+
// @nimi-authority: rule.nimi.sdks.feature-clients.scenario-execute-call-control
|
|
59
104
|
scenario: Object.freeze({
|
|
60
|
-
execute: async (spec) =>
|
|
105
|
+
execute: async (spec, options) => {
|
|
106
|
+
const call = validateScenarioExecuteOptions(options);
|
|
107
|
+
if (call.signal?.aborted)
|
|
108
|
+
throw scenarioExecuteCanceledError();
|
|
109
|
+
const prepared = prepareScenarioExecuteSpec(spec);
|
|
110
|
+
return runScenarioExecuteCall(call, (shellOptions) => shell.scenario.execute(prepared.shellSpec, shellOptions), (value) => {
|
|
111
|
+
const projected = projectScenarioExecute(value, prepared.decide);
|
|
112
|
+
if (prepared.shellSpec.type === 'text-generate' && projected.output.type === 'text-generate'
|
|
113
|
+
&& prepared.shellSpec.reasoning?.presentation !== 'summary' && projected.output.items.some((item) => item.type === 'reasoning-summary'))
|
|
114
|
+
localAppProjectionError('unrequested reasoning summary');
|
|
115
|
+
if (prepared.shellSpec.type === 'text-embed') {
|
|
116
|
+
const output = projected.output;
|
|
117
|
+
if (output.type !== 'text-embed')
|
|
118
|
+
localAppProjectionError('text embed output type');
|
|
119
|
+
const dimensions = prepared.shellSpec.dimensions ?? output.vectors[0]?.length;
|
|
120
|
+
if (output.vectors.length !== prepared.shellSpec.inputs.length ||
|
|
121
|
+
output.vectors.some((row) => row.length !== dimensions)) {
|
|
122
|
+
localAppProjectionError('text embed output contract');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return projected;
|
|
126
|
+
});
|
|
127
|
+
},
|
|
61
128
|
}),
|
|
62
129
|
scenarioJobs: Object.freeze({
|
|
63
|
-
submit: async (spec, options = {}) => projectScenarioJobSubmit(await shell.scenarioJobs.submit(validateScenarioSpec(spec, false), validateScenarioJobSubmitOptions(options))),
|
|
130
|
+
submit: async (spec, options = {}) => projectScenarioJobSubmit(await shell.scenarioJobs.submit(detachScenarioJobSpecBytes(validateScenarioSpec(spec, false)), validateScenarioJobSubmitOptions(options))),
|
|
64
131
|
get: async (jobId) => projectScenarioJobGet(await shell.scenarioJobs.get(boundedIdentifier(jobId, 'jobId'))),
|
|
132
|
+
lookupSubmission: async (clientSubmissionId) => projectScenarioJobGet(await shell.scenarioJobs.get('', validateClientSubmissionId(clientSubmissionId))),
|
|
65
133
|
subscribe: async (jobId) => projectSubscription(await shell.scenarioJobs.subscribe(boundedIdentifier(jobId, 'jobId')), projectScenarioJobEvent),
|
|
66
134
|
cancel: async (jobId, reason = '') => {
|
|
67
135
|
if (typeof reason !== 'string' || reason.trim() !== reason || utf8Length(reason) > 512 || hasControl(reason)) {
|
|
@@ -73,13 +141,8 @@ export function createNimiLocalAppAIConsumptionClient(shell) {
|
|
|
73
141
|
artifacts: Object.freeze({
|
|
74
142
|
read: async (artifactId) => projectArtifactRead(await shell.artifacts.read(boundedIdentifier(artifactId, 'artifactId'))),
|
|
75
143
|
upload: async (input) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!(input.bytes instanceof Uint8Array) || input.bytes.byteLength === 0
|
|
79
|
-
|| input.bytes.byteLength > MAX_ARTIFACT_BYTES || !isArtifactUploadMime(input.mimeType)) {
|
|
80
|
-
invalidAIInput('artifact upload is invalid');
|
|
81
|
-
}
|
|
82
|
-
return projectArtifactUpload(await shell.artifacts.upload({ bytes: [...input.bytes], mimeType: input.mimeType }), input.bytes.byteLength, input.mimeType);
|
|
144
|
+
const prepared = prepareArtifactUploadInput(input);
|
|
145
|
+
return projectArtifactUpload(await shell.artifacts.upload(prepared), prepared.bytes?.length, prepared.mimeType, prepared.audioPreparation);
|
|
83
146
|
},
|
|
84
147
|
}),
|
|
85
148
|
voiceAssets,
|
|
@@ -109,8 +172,17 @@ export function createNimiLocalAppAIConsumptionRuntimeClient(runtime) {
|
|
|
109
172
|
},
|
|
110
173
|
},
|
|
111
174
|
scenario: {
|
|
112
|
-
async execute(spec) {
|
|
113
|
-
|
|
175
|
+
async execute(spec, options) {
|
|
176
|
+
// The deadline travels in the request so Runtime owns it; the transport
|
|
177
|
+
// only bounds the call a little beyond it, so Runtime records an elapsed
|
|
178
|
+
// deadline as a timeout and an abort, which cancels at once, as a cancel.
|
|
179
|
+
const request = runtimeExecuteRequest(spec, options?.timeoutMs ?? 0);
|
|
180
|
+
const response = options
|
|
181
|
+
? await runtime.executeLocalAppScenario(request, {
|
|
182
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
183
|
+
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs + RUNTIME_DEADLINE_GRACE_MS } : {}),
|
|
184
|
+
})
|
|
185
|
+
: await runtime.executeLocalAppScenario(request);
|
|
114
186
|
return projectRuntimeScenarioExecuteResponse(response);
|
|
115
187
|
},
|
|
116
188
|
},
|
|
@@ -118,14 +190,16 @@ export function createNimiLocalAppAIConsumptionRuntimeClient(runtime) {
|
|
|
118
190
|
async submit(spec, options = {}) {
|
|
119
191
|
const response = await runtime.submitLocalAppScenarioJob({
|
|
120
192
|
spec: runtimeLocalJobSpec(spec),
|
|
121
|
-
timeoutMs:
|
|
193
|
+
timeoutMs: 0,
|
|
194
|
+
clientSubmissionId: options.clientSubmissionId ?? '',
|
|
122
195
|
});
|
|
123
196
|
return { job: projectRuntimeLocalJob(requiredRuntimeValue(response.job, 'scenario Job')) };
|
|
124
197
|
},
|
|
125
|
-
async get(jobId) {
|
|
126
|
-
const response = await runtime.getLocalAppScenarioJob({ jobId });
|
|
198
|
+
async get(jobId, clientSubmissionId = '') {
|
|
199
|
+
const response = await runtime.getLocalAppScenarioJob({ jobId, clientSubmissionId });
|
|
127
200
|
return {
|
|
128
201
|
...(response.visionLocate ? { visionLocate: localVisionLocateFromRuntime(response.visionLocate) } : {}),
|
|
202
|
+
...(response.observationIssue ? { observationIssue: { reasonCode: runtimeReasonToken(response.observationIssue.reasonCode), observedAt: plainRuntimeTimestamp(response.observationIssue.observedAt) } } : {}),
|
|
129
203
|
job: projectRuntimeLocalJob(requiredRuntimeValue(response.job, 'scenario Job')),
|
|
130
204
|
asset: response.asset ? projectRuntimeLocalAppVoiceAsset(response.asset) : null,
|
|
131
205
|
voiceReference: response.voiceReference
|
|
@@ -155,30 +229,47 @@ export function createNimiLocalAppAIConsumptionRuntimeClient(runtime) {
|
|
|
155
229
|
async read(artifactId) {
|
|
156
230
|
const response = await runtime.readLocalAppArtifact({ artifactId });
|
|
157
231
|
return {
|
|
158
|
-
bytes:
|
|
232
|
+
bytes: response.bytes,
|
|
159
233
|
mimeType: response.mimeType,
|
|
160
234
|
sizeBytes: runtimeSafeInteger(response.sizeBytes, 'artifact size'),
|
|
161
235
|
};
|
|
162
236
|
},
|
|
163
237
|
async upload(input) {
|
|
164
238
|
const response = await runtime.uploadLocalAppArtifact({
|
|
165
|
-
bytes:
|
|
239
|
+
bytes: input.bytes ?? new Uint8Array(),
|
|
166
240
|
mimeType: input.mimeType,
|
|
241
|
+
appAssetRelativePath: input.source?.kind === 'app-asset' ? input.source.relativePath : '',
|
|
242
|
+
sourceArtifactId: input.source?.kind === 'artifact' ? input.source.artifactId : '',
|
|
243
|
+
audioPreparation: input.audioPreparation ? {
|
|
244
|
+
targetSampleRateHz: input.audioPreparation.targetSampleRateHz ?? 0,
|
|
245
|
+
channelMode: input.audioPreparation.channelMode === 'PRESERVE' ? CanonicalChannelMode.PRESERVE
|
|
246
|
+
: input.audioPreparation.channelMode === 'MONO_TO_STEREO' ? CanonicalChannelMode.MONO_TO_STEREO
|
|
247
|
+
: input.audioPreparation.channelMode === 'STEREO_TO_MONO' ? CanonicalChannelMode.STEREO_TO_MONO
|
|
248
|
+
: CanonicalChannelMode.UNSPECIFIED,
|
|
249
|
+
} : undefined,
|
|
167
250
|
});
|
|
168
251
|
return {
|
|
169
252
|
artifactId: response.artifactId,
|
|
170
253
|
sizeBytes: runtimeSafeInteger(response.sizeBytes, 'artifact size'),
|
|
171
254
|
mimeType: response.mimeType,
|
|
255
|
+
...(response.expiresAt ? { expiresAt: plainRuntimeTimestamp(response.expiresAt) } : {}),
|
|
256
|
+
...(response.audioInfo ? { audioInfo: {
|
|
257
|
+
sampleRateHz: response.audioInfo.sampleRateHz,
|
|
258
|
+
channels: response.audioInfo.channels,
|
|
259
|
+
frameCount: runtimeSafeInteger(response.audioInfo.frameCount, 'audio frames'),
|
|
260
|
+
durationMs: runtimeSafeInteger(response.audioInfo.durationMs, 'audio duration'),
|
|
261
|
+
} } : {}),
|
|
172
262
|
};
|
|
173
263
|
},
|
|
174
264
|
},
|
|
175
265
|
voiceAssets: {
|
|
176
266
|
list: (input) => voiceAssets.list(input),
|
|
267
|
+
delete: (voiceAssetId) => voiceAssets.delete(voiceAssetId),
|
|
177
268
|
},
|
|
178
269
|
});
|
|
179
270
|
}
|
|
180
271
|
export function createNimiLocalAppVoiceAssetsClient(shell) {
|
|
181
|
-
return createNimiLocalAppVoiceAssetsProjector((input) => shell.list(input));
|
|
272
|
+
return createNimiLocalAppVoiceAssetsProjector((input) => shell.list(input), (voiceAssetId) => shell.delete(voiceAssetId));
|
|
182
273
|
}
|
|
183
274
|
export function createNimiLocalAppVoiceAssetsRuntimeClient(runtime) {
|
|
184
275
|
return createNimiLocalAppVoiceAssetsProjector(async (input) => {
|
|
@@ -190,10 +281,16 @@ export function createNimiLocalAppVoiceAssetsRuntimeClient(runtime) {
|
|
|
190
281
|
assets: response.assets.map(projectRuntimeLocalAppVoiceAsset),
|
|
191
282
|
nextPageToken: response.nextPageToken,
|
|
192
283
|
};
|
|
193
|
-
});
|
|
284
|
+
}, (voiceAssetId) => runtime.deleteLocalAppVoiceAsset({ voiceAssetId }));
|
|
194
285
|
}
|
|
195
|
-
function createNimiLocalAppVoiceAssetsProjector(list) {
|
|
286
|
+
function createNimiLocalAppVoiceAssetsProjector(list, remove) {
|
|
196
287
|
return Object.freeze({
|
|
288
|
+
async delete(voiceAssetId) {
|
|
289
|
+
const result = asRecord(await remove(boundedIdentifier(voiceAssetId, 'voiceAssetId')));
|
|
290
|
+
if (!result || Object.keys(result).length !== 1 || result.deleted !== true)
|
|
291
|
+
localAppProjectionError('voice asset deletion was not confirmed');
|
|
292
|
+
return Object.freeze({ deleted: true });
|
|
293
|
+
},
|
|
197
294
|
async list(input = {}) {
|
|
198
295
|
const page = validateVoiceAssetsListInput(input);
|
|
199
296
|
return projectVoiceAssetsList(await list(page));
|
|
@@ -215,10 +312,11 @@ export function createNimiLocalAppRuntimeScenarioJobClient(ai) {
|
|
|
215
312
|
const client = {
|
|
216
313
|
terminalVoiceAssetProjection: 'protected-local',
|
|
217
314
|
async submitScenarioJob(request) {
|
|
315
|
+
if (request.head?.timeoutMs !== undefined && request.head.timeoutMs !== 0) {
|
|
316
|
+
invalidAIInput('Scenario Job business timeout is no longer supported');
|
|
317
|
+
}
|
|
218
318
|
const spec = localJobSpecFromRuntimeRequest(request);
|
|
219
|
-
const result = await ai.scenarioJobs.submit(spec, {
|
|
220
|
-
timeoutMs: boundedInteger(request.head?.timeoutMs ?? 0, 'Scenario Job timeoutMs', 0, 2_147_483_647),
|
|
221
|
-
});
|
|
319
|
+
const result = await ai.scenarioJobs.submit(spec, request.idempotencyKey ? { clientSubmissionId: validateClientSubmissionId(request.idempotencyKey) } : {});
|
|
222
320
|
return {
|
|
223
321
|
job: runtimeJobFromLocal(result.job),
|
|
224
322
|
};
|
|
@@ -228,6 +326,7 @@ export function createNimiLocalAppRuntimeScenarioJobClient(ai) {
|
|
|
228
326
|
const result = await ai.scenarioJobs.get(request.jobId);
|
|
229
327
|
return {
|
|
230
328
|
...(result.visionLocate ? { visionLocate: runtimeVisionLocateFromLocal(result.visionLocate) } : {}),
|
|
329
|
+
...(result.observationIssue ? { observationIssue: { reasonCode: runtimeReasonCode(result.observationIssue.reasonCode), observedAt: runtimeTimestamp(result.observationIssue.observedAt) } } : {}),
|
|
231
330
|
job: runtimeJobFromLocal(result.job),
|
|
232
331
|
asset: result.asset ? runtimeVoiceAssetFromLocal(result.asset) : undefined,
|
|
233
332
|
voiceReference: result.voiceReference ? {
|
|
@@ -244,18 +343,27 @@ export function createNimiLocalAppRuntimeScenarioJobClient(ai) {
|
|
|
244
343
|
const result = await ai.scenarioJobs.cancel(request.jobId, request.reason);
|
|
245
344
|
return { job: runtimeJobFromLocal(result.job) };
|
|
246
345
|
},
|
|
247
|
-
subscribeScenarioJobEvents(request) {
|
|
346
|
+
subscribeScenarioJobEvents(request, options) {
|
|
248
347
|
assertExactKeys(request, ['jobId'], 'local-app Scenario Job subscribe request');
|
|
249
348
|
return {
|
|
250
349
|
async *[Symbol.asyncIterator]() {
|
|
251
350
|
const subscription = await ai.scenarioJobs.subscribe(request.jobId);
|
|
351
|
+
let closing;
|
|
352
|
+
const close = () => closing ??= subscription.cancel();
|
|
353
|
+
const abort = () => { void close().catch(() => undefined); };
|
|
354
|
+
options?.signal?.addEventListener('abort', abort, { once: true });
|
|
355
|
+
if (options?.signal?.aborted)
|
|
356
|
+
abort();
|
|
252
357
|
try {
|
|
253
358
|
for await (const event of subscription) {
|
|
359
|
+
if (options?.signal?.aborted)
|
|
360
|
+
break;
|
|
254
361
|
yield runtimeJobEventFromLocal(event);
|
|
255
362
|
}
|
|
256
363
|
}
|
|
257
364
|
finally {
|
|
258
|
-
|
|
365
|
+
options?.signal?.removeEventListener('abort', abort);
|
|
366
|
+
await close();
|
|
259
367
|
}
|
|
260
368
|
},
|
|
261
369
|
};
|
|
@@ -269,6 +377,19 @@ export function createNimiLocalAppRuntimeScenarioJobClient(ai) {
|
|
|
269
377
|
};
|
|
270
378
|
return Object.freeze(client);
|
|
271
379
|
}
|
|
380
|
+
// The shell receives a detached exact byte range, so IPC carries neither a
|
|
381
|
+
// larger backing buffer nor later caller writes. Each Job spec has at most one
|
|
382
|
+
// inline audio field.
|
|
383
|
+
function detachScenarioJobSpecBytes(spec) {
|
|
384
|
+
const record = spec;
|
|
385
|
+
for (const key of ['audioSource', 'referenceAudio']) {
|
|
386
|
+
const source = asRecord(record[key]);
|
|
387
|
+
if (source?.type === 'bytes' && isNimiLocalAppByteView(source.bytes)) {
|
|
388
|
+
return { ...record, [key]: { type: 'bytes', bytes: copyNimiLocalAppBytes(source.bytes) } };
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return spec;
|
|
392
|
+
}
|
|
272
393
|
function validateScenarioSpec(spec, execute) {
|
|
273
394
|
const record = asRecord(spec);
|
|
274
395
|
if (!record || typeof record.type !== 'string')
|
|
@@ -279,6 +400,14 @@ function validateScenarioSpec(spec, execute) {
|
|
|
279
400
|
const { type: _type, ...input } = record;
|
|
280
401
|
return Object.freeze({ type: 'text-generate', ...validateLocalAppTextInput(input) });
|
|
281
402
|
}
|
|
403
|
+
if (record.type === 'text-decide') {
|
|
404
|
+
// App JSON state is product content: its keys are never read as authority
|
|
405
|
+
// fields. The closed envelope and exact bounds are checked instead.
|
|
406
|
+
if (!execute)
|
|
407
|
+
invalidAIInput('text-decide is a synchronous Scenario, not an async Job');
|
|
408
|
+
prepareNimiLocalAppTextDecideSpec(record);
|
|
409
|
+
return spec;
|
|
410
|
+
}
|
|
282
411
|
assertNoAuthorityMaterial(record);
|
|
283
412
|
switch (record.type) {
|
|
284
413
|
// @nimi-authority: rule.nimi.runtime.ai-provider.face-swap-video-job
|
|
@@ -311,13 +440,23 @@ function validateScenarioSpec(spec, execute) {
|
|
|
311
440
|
case 'text-embed':
|
|
312
441
|
if (!execute)
|
|
313
442
|
invalidAIInput('text-embed is not an async Job spec');
|
|
314
|
-
assertExactKeys(record, ['type', 'inputs'], 'text embed spec');
|
|
443
|
+
assertExactKeys(record, ['type', 'inputs', 'dimensions', 'purpose'], 'text embed spec');
|
|
444
|
+
if (record.purpose !== undefined && record.purpose !== 'retrieval-document' && record.purpose !== 'retrieval-query')
|
|
445
|
+
invalidAIInput('text embed purpose');
|
|
446
|
+
optionalBoundedInteger(record.dimensions, 'text embed dimensions', 1, 0xffff_ffff);
|
|
315
447
|
if (!Array.isArray(record.inputs) || record.inputs.length === 0 || record.inputs.length > 16) {
|
|
316
448
|
invalidAIInput('text embed inputs are invalid');
|
|
317
449
|
}
|
|
318
450
|
record.inputs.forEach((value, index) => boundedContent(value, `text embed input ${index}`, 32 * 1024));
|
|
319
|
-
|
|
451
|
+
return Object.freeze({
|
|
452
|
+
type: 'text-embed',
|
|
453
|
+
inputs: Object.freeze([...record.inputs]),
|
|
454
|
+
...(record.dimensions !== undefined ? { dimensions: record.dimensions } : {}),
|
|
455
|
+
...(record.purpose !== undefined ? { purpose: record.purpose } : {}),
|
|
456
|
+
});
|
|
320
457
|
case 'image-generate':
|
|
458
|
+
if (execute)
|
|
459
|
+
invalidAIInput('image-generate requires an async Job');
|
|
321
460
|
assertExactKeys(record, ['type', 'prompt', 'negativePrompt', 'n', 'size', 'aspectRatio', 'quality', 'style', 'seed', 'referenceImages', 'referenceImageArtifactId', 'mask', 'maskArtifactId', 'strength', 'responseFormat'], 'image spec');
|
|
322
461
|
boundedContent(record.prompt, 'image prompt', 32 * 1024);
|
|
323
462
|
optionalBoundedText(record.negativePrompt, 'image negativePrompt', 32 * 1024);
|
|
@@ -326,7 +465,7 @@ function validateScenarioSpec(spec, execute) {
|
|
|
326
465
|
boundedToken(record.aspectRatio, 'image aspectRatio', 128);
|
|
327
466
|
boundedToken(record.quality, 'image quality', 128);
|
|
328
467
|
boundedToken(record.style, 'image style', 128);
|
|
329
|
-
optionalBoundedInteger(record.seed, 'image seed',
|
|
468
|
+
optionalBoundedInteger(record.seed, 'image seed', -1, 2_147_483_647);
|
|
330
469
|
if (!Array.isArray(record.referenceImages) || record.referenceImages.length > 1)
|
|
331
470
|
invalidAIInput('image referenceImages are invalid');
|
|
332
471
|
record.referenceImages.forEach((value, index) => boundedHttpsUrl(value, `image reference ${index}`));
|
|
@@ -379,33 +518,69 @@ function validateScenarioSpec(spec, execute) {
|
|
|
379
518
|
|| record.texts.reduce((sum, text) => sum + new TextEncoder().encode(text).byteLength, 0) > 524288)
|
|
380
519
|
invalidAIInput('text annotation requires bounded Unicode documents');
|
|
381
520
|
break;
|
|
521
|
+
case 'audio-speaker-embed':
|
|
522
|
+
if (execute)
|
|
523
|
+
invalidAIInput('audio-speaker-embed is not a synchronous spec');
|
|
524
|
+
assertExactKeys(record, ['type', 'mimeType', 'audioSource', 'sourceAudio'], 'speaker representation spec');
|
|
525
|
+
boundedToken(record.mimeType, 'speaker mimeType', 128);
|
|
526
|
+
if ((record.audioSource === undefined) === (record.sourceAudio === undefined))
|
|
527
|
+
invalidAIInput('speaker encoding requires exactly one source');
|
|
528
|
+
if (record.audioSource !== undefined)
|
|
529
|
+
validateAudioSource(record.audioSource, MAX_ARTIFACT_BYTES, 'speaker audioSource');
|
|
530
|
+
if (record.sourceAudio !== undefined)
|
|
531
|
+
validateMusicAudioInput(record.sourceAudio, 'speaker sourceAudio', Number.MAX_SAFE_INTEGER);
|
|
532
|
+
break;
|
|
382
533
|
case 'audio-separate':
|
|
383
534
|
if (execute)
|
|
384
535
|
invalidAIInput('audio-separate is not a synchronous spec');
|
|
385
|
-
assertExactKeys(record, ['type', 'mimeType', 'audioSource'], 'audio separation spec');
|
|
536
|
+
assertExactKeys(record, ['type', 'mimeType', 'audioSource', 'sourceAudio', 'includeInstrumentParts'], 'audio separation spec');
|
|
386
537
|
boundedToken(record.mimeType, 'audio separation mimeType', 128);
|
|
387
|
-
|
|
538
|
+
if ((record.audioSource === undefined) === (record.sourceAudio === undefined))
|
|
539
|
+
invalidAIInput('audio separation requires exactly one source');
|
|
540
|
+
if (record.audioSource !== undefined)
|
|
541
|
+
validateAudioSource(record.audioSource, MAX_ARTIFACT_BYTES, 'audio separation audioSource');
|
|
542
|
+
if (record.sourceAudio !== undefined)
|
|
543
|
+
validateMusicAudioInput(record.sourceAudio, 'audio separation sourceAudio');
|
|
544
|
+
if (record.includeInstrumentParts !== undefined && typeof record.includeInstrumentParts !== 'boolean')
|
|
545
|
+
invalidAIInput('audio separation includeInstrumentParts');
|
|
388
546
|
break;
|
|
389
547
|
case 'voice-create':
|
|
390
548
|
if (execute)
|
|
391
549
|
invalidAIInput('voice-create is not a synchronous spec');
|
|
392
550
|
validateVoiceCreateSpec(record);
|
|
393
551
|
break;
|
|
552
|
+
case 'music-transcribe':
|
|
553
|
+
if (execute)
|
|
554
|
+
invalidAIInput('music-transcribe is not a synchronous spec');
|
|
555
|
+
validateNimiLocalAppMusicTranscribeSpec(record);
|
|
556
|
+
break;
|
|
557
|
+
case 'audio-voice-convert':
|
|
558
|
+
if (execute)
|
|
559
|
+
invalidAIInput('audio-voice-convert is not a synchronous spec');
|
|
560
|
+
validateNimiLocalAppVoiceConvertSpec(record);
|
|
561
|
+
break;
|
|
394
562
|
case 'music-generate':
|
|
395
563
|
if (execute)
|
|
396
564
|
invalidAIInput('music-generate is not a synchronous spec');
|
|
397
|
-
|
|
398
|
-
boundedContent(record.prompt, 'music prompt', 32 * 1024);
|
|
399
|
-
boundedContent(record.lyrics, 'music lyrics', 32 * 1024);
|
|
400
|
-
if (record.durationSeconds !== undefined && (!Number.isSafeInteger(record.durationSeconds)
|
|
401
|
-
|| Number(record.durationSeconds) < 1 || Number(record.durationSeconds) > 180))
|
|
402
|
-
invalidAIInput('music durationSeconds must be an integer from 1 through 180');
|
|
565
|
+
validateNimiLocalAppMusicGenerateSpec(record);
|
|
403
566
|
break;
|
|
404
567
|
case 'world-generate':
|
|
405
568
|
if (execute)
|
|
406
569
|
invalidAIInput('world-generate is not a synchronous spec');
|
|
407
|
-
assertExactKeys(record, ['type', 'prompt', 'displayName'], 'world spec');
|
|
408
|
-
|
|
570
|
+
assertExactKeys(record, ['type', 'prompt', 'displayName', 'image'], 'world spec');
|
|
571
|
+
if (record.prompt !== undefined)
|
|
572
|
+
optionalBoundedText(record.prompt, 'world prompt', 32 * 1024);
|
|
573
|
+
if (record.image !== undefined) {
|
|
574
|
+
const image = asRecord(record.image);
|
|
575
|
+
if (!image)
|
|
576
|
+
invalidAIInput('world image is invalid');
|
|
577
|
+
assertExactKeys(image, ['artifactId', 'projection'], 'world image');
|
|
578
|
+
boundedIdentifier(image.artifactId, 'world image artifactId');
|
|
579
|
+
if (image.projection !== 'ordinary' && image.projection !== 'equirectangular-360')
|
|
580
|
+
invalidAIInput('world projection is required');
|
|
581
|
+
}
|
|
582
|
+
else
|
|
583
|
+
boundedContent(record.prompt, 'world prompt', 32 * 1024);
|
|
409
584
|
optionalBoundedText(record.displayName, 'world displayName', 256);
|
|
410
585
|
break;
|
|
411
586
|
default:
|
|
@@ -414,11 +589,140 @@ function validateScenarioSpec(spec, execute) {
|
|
|
414
589
|
return spec;
|
|
415
590
|
}
|
|
416
591
|
function validateScenarioJobSubmitOptions(options) {
|
|
417
|
-
assertExactKeys(options, ['
|
|
592
|
+
assertExactKeys(options, ['clientSubmissionId'], 'Scenario Job submit options');
|
|
593
|
+
return Object.freeze({
|
|
594
|
+
...(options.clientSubmissionId !== undefined ? { clientSubmissionId: validateClientSubmissionId(options.clientSubmissionId) } : {}),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
const MAX_SCENARIO_EXECUTE_TIMEOUT_MS = 120_000;
|
|
598
|
+
// How long past the caller deadline the transport waits for Runtime's own
|
|
599
|
+
// deadline reply before it gives up on an unresponsive service.
|
|
600
|
+
const RUNTIME_DEADLINE_GRACE_MS = 2_000;
|
|
601
|
+
function validateScenarioExecuteOptions(options) {
|
|
602
|
+
if (options === undefined)
|
|
603
|
+
return {};
|
|
604
|
+
assertExactKeys(options, ['signal', 'timeoutMs'], 'scenario execute options');
|
|
605
|
+
const signal = options.signal;
|
|
606
|
+
if (signal !== undefined && !isAbortSignal(signal))
|
|
607
|
+
invalidAIInput('scenario execute signal must be an AbortSignal');
|
|
608
|
+
const timeoutMs = options.timeoutMs === undefined
|
|
609
|
+
? undefined
|
|
610
|
+
: boundedInteger(options.timeoutMs, 'scenario execute timeoutMs', 1, MAX_SCENARIO_EXECUTE_TIMEOUT_MS);
|
|
418
611
|
return Object.freeze({
|
|
419
|
-
|
|
612
|
+
...(signal !== undefined ? { signal } : {}),
|
|
613
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
function isAbortSignal(value) {
|
|
617
|
+
if (!value || typeof value !== 'object')
|
|
618
|
+
return false;
|
|
619
|
+
const candidate = value;
|
|
620
|
+
return typeof candidate.aborted === 'boolean'
|
|
621
|
+
&& typeof candidate.addEventListener === 'function'
|
|
622
|
+
&& typeof candidate.removeEventListener === 'function';
|
|
623
|
+
}
|
|
624
|
+
function prepareScenarioExecuteSpec(spec) {
|
|
625
|
+
if (asRecord(spec)?.type === 'text-decide') {
|
|
626
|
+
const decide = prepareNimiLocalAppTextDecideSpec(spec);
|
|
627
|
+
return { shellSpec: decide, decide };
|
|
628
|
+
}
|
|
629
|
+
return { shellSpec: validateScenarioSpec(spec, true) };
|
|
630
|
+
}
|
|
631
|
+
// Settles the caller exactly once: an abort or an elapsed caller deadline
|
|
632
|
+
// rejects immediately without waiting for the carrier, and a late carrier
|
|
633
|
+
// result is never projected. An abort cancels the carrier call; the deadline
|
|
634
|
+
// travels with the call, so Runtime ends it there and records a timeout
|
|
635
|
+
// rather than the cancel an abort would be.
|
|
636
|
+
function runScenarioExecuteCall(call, invoke, project) {
|
|
637
|
+
if (!call.signal && call.timeoutMs === undefined) {
|
|
638
|
+
return invoke(undefined).then(project);
|
|
639
|
+
}
|
|
640
|
+
const controller = new AbortController();
|
|
641
|
+
const callerSignal = call.signal;
|
|
642
|
+
return new Promise((resolve, reject) => {
|
|
643
|
+
let settled = false;
|
|
644
|
+
let timer;
|
|
645
|
+
const settle = (complete) => {
|
|
646
|
+
if (settled)
|
|
647
|
+
return;
|
|
648
|
+
settled = true;
|
|
649
|
+
if (timer !== undefined)
|
|
650
|
+
clearTimeout(timer);
|
|
651
|
+
callerSignal?.removeEventListener('abort', onAbort);
|
|
652
|
+
complete();
|
|
653
|
+
};
|
|
654
|
+
const stop = (error) => {
|
|
655
|
+
settle(() => reject(error));
|
|
656
|
+
if (!controller.signal.aborted)
|
|
657
|
+
controller.abort(error);
|
|
658
|
+
};
|
|
659
|
+
const onAbort = () => stop(scenarioExecuteCanceledError());
|
|
660
|
+
callerSignal?.addEventListener('abort', onAbort, { once: true });
|
|
661
|
+
if (call.timeoutMs !== undefined) {
|
|
662
|
+
const timeoutMs = call.timeoutMs;
|
|
663
|
+
timer = setTimeout(() => settle(() => reject(scenarioExecuteTimeoutError(timeoutMs))), timeoutMs);
|
|
664
|
+
}
|
|
665
|
+
let pending;
|
|
666
|
+
try {
|
|
667
|
+
pending = invoke({
|
|
668
|
+
signal: controller.signal,
|
|
669
|
+
...(call.timeoutMs !== undefined ? { timeoutMs: call.timeoutMs } : {}),
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
settle(() => reject(error));
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
pending.then((value) => {
|
|
677
|
+
if (settled || callerSignal?.aborted)
|
|
678
|
+
return;
|
|
679
|
+
let projected;
|
|
680
|
+
try {
|
|
681
|
+
projected = project(value);
|
|
682
|
+
}
|
|
683
|
+
catch (error) {
|
|
684
|
+
settle(() => reject(error));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
settle(() => resolve(projected));
|
|
688
|
+
}, (error) => {
|
|
689
|
+
// A carrier deadline surfaces as the same typed caller timeout.
|
|
690
|
+
settle(() => reject(call.timeoutMs !== undefined && isCarrierTimeout(error)
|
|
691
|
+
? scenarioExecuteTimeoutError(call.timeoutMs)
|
|
692
|
+
: error));
|
|
693
|
+
});
|
|
420
694
|
});
|
|
421
695
|
}
|
|
696
|
+
function isCarrierTimeout(error) {
|
|
697
|
+
const reasonCode = error && typeof error === 'object' ? error.reasonCode : undefined;
|
|
698
|
+
return reasonCode === 'timeout' || reasonCode === ReasonCode.OPERATION_TIMEOUT;
|
|
699
|
+
}
|
|
700
|
+
function scenarioExecuteCanceledError() {
|
|
701
|
+
return createNimiError({
|
|
702
|
+
message: 'Local-app scenario execution was canceled by its caller.',
|
|
703
|
+
code: ReasonCode.OPERATION_ABORTED,
|
|
704
|
+
reasonCode: ReasonCode.OPERATION_ABORTED,
|
|
705
|
+
actionHint: 'retry_if_still_needed',
|
|
706
|
+
retryable: false,
|
|
707
|
+
source: 'sdk',
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
function scenarioExecuteTimeoutError(timeoutMs) {
|
|
711
|
+
return createNimiError({
|
|
712
|
+
message: `Local-app scenario execution exceeded its ${timeoutMs} ms caller deadline.`,
|
|
713
|
+
code: ReasonCode.OPERATION_TIMEOUT,
|
|
714
|
+
reasonCode: ReasonCode.OPERATION_TIMEOUT,
|
|
715
|
+
actionHint: 'retry_with_a_longer_timeout',
|
|
716
|
+
retryable: true,
|
|
717
|
+
source: 'sdk',
|
|
718
|
+
details: { timeoutMs },
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
function validateClientSubmissionId(value) {
|
|
722
|
+
if (typeof value !== 'string' || !/^[A-Za-z0-9_-]{1,128}$/.test(value))
|
|
723
|
+
invalidAIInput('clientSubmissionId is invalid');
|
|
724
|
+
return value;
|
|
725
|
+
}
|
|
422
726
|
function validateVideoSpec(record) {
|
|
423
727
|
assertExactKeys(record, ['type', 'prompt', 'negativePrompt', 'mode', 'content', 'options'], 'video spec');
|
|
424
728
|
optionalBoundedText(record.prompt, 'video prompt', 32 * 1024);
|
|
@@ -462,7 +766,19 @@ function validateVideoSpec(record) {
|
|
|
462
766
|
}
|
|
463
767
|
}
|
|
464
768
|
function validateSpeechSynthesizeSpec(record) {
|
|
465
|
-
assertExactKeys(record, ['type', 'text', 'language', 'audioFormat', 'sampleRateHz', 'speed', 'pitch', 'volume', 'emotion', 'voiceRef', 'timingMode', 'voiceRenderHints'], 'speech synthesize spec');
|
|
769
|
+
assertExactKeys(record, ['type', 'text', 'language', 'audioFormat', 'sampleRateHz', 'speed', 'pitch', 'volume', 'emotion', 'voiceRef', 'timingMode', 'voiceRenderHints', 'identityAudio', 'performanceAudio'], 'speech synthesize spec');
|
|
770
|
+
for (const key of ['identityAudio', 'performanceAudio']) {
|
|
771
|
+
if (record[key] !== undefined) {
|
|
772
|
+
const reference = asRecord(record[key]);
|
|
773
|
+
assertExactKeys(reference, key === 'identityAudio' ? ['artifactId'] : ['artifactId', 'text'], key);
|
|
774
|
+
boundedIdentifier(reference.artifactId, key + ' artifactId');
|
|
775
|
+
if (key === 'performanceAudio') {
|
|
776
|
+
boundedContent(reference.text, 'performance transcript', 32768);
|
|
777
|
+
if (!String(reference.text).trim())
|
|
778
|
+
invalidAIInput('Performance transcript is required');
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
466
782
|
boundedContent(record.text, 'speech text', 32 * 1024);
|
|
467
783
|
boundedToken(record.language, 'speech language', 64);
|
|
468
784
|
boundedToken(record.audioFormat, 'speech audioFormat', 64);
|
|
@@ -535,7 +851,7 @@ function validateAudioSource(value, maxBytes, field) {
|
|
|
535
851
|
invalidAIInput(`${field} is invalid`);
|
|
536
852
|
if (source.type === 'bytes') {
|
|
537
853
|
assertExactKeys(source, ['type', 'bytes'], field);
|
|
538
|
-
|
|
854
|
+
validateInputBytes(source.bytes, field, maxBytes, false);
|
|
539
855
|
}
|
|
540
856
|
else if (source.type === 'uri') {
|
|
541
857
|
assertExactKeys(source, ['type', 'uri'], field);
|
|
@@ -544,6 +860,19 @@ function validateAudioSource(value, maxBytes, field) {
|
|
|
544
860
|
else
|
|
545
861
|
invalidAIInput(`${field} type is invalid`);
|
|
546
862
|
}
|
|
863
|
+
function validateMusicAudioInput(value, field, maxFrame = 57600000) {
|
|
864
|
+
const source = asRecord(value);
|
|
865
|
+
assertExactKeys(source, ['artifactId', 'range'], field);
|
|
866
|
+
boundedIdentifier(source?.artifactId, `${field} artifactId`);
|
|
867
|
+
if (source?.range !== undefined) {
|
|
868
|
+
const range = asRecord(source.range);
|
|
869
|
+
assertExactKeys(range, ['startFrame', 'endFrame'], field);
|
|
870
|
+
if (!range || !Number.isSafeInteger(range.startFrame) || range.startFrame < 0 || range.startFrame > maxFrame
|
|
871
|
+
|| !Number.isSafeInteger(range.endFrame) || range.endFrame < 1 || range.endFrame > maxFrame
|
|
872
|
+
|| range.startFrame >= range.endFrame)
|
|
873
|
+
invalidAIInput(`${field} range`);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
547
876
|
function projectSubscription(subscription, projector) {
|
|
548
877
|
const record = asRecord(subscription);
|
|
549
878
|
assertExactProjectionKeys(record, ['events', 'cancel'], 'AI subscription');
|
|
@@ -572,6 +901,14 @@ function projectTextTurnEvent(value) {
|
|
|
572
901
|
assertExactProjectionKeys(record, ['type', 'sequence', 'traceId', 'itemIndex', 'toolCall'], 'text tool call');
|
|
573
902
|
return Object.freeze({ ...base, type: 'tool-call', itemIndex: projectionInteger(record.itemIndex, 'tool item index', 0, 4_294_967_295), toolCall: projectLocalAppToolCall(record.toolCall) });
|
|
574
903
|
}
|
|
904
|
+
if (record.type === 'reasoning-summary') {
|
|
905
|
+
assertExactProjectionKeys(record, ['type', 'sequence', 'traceId', 'itemIndex', 'text', 'itemCompleted'], 'text reasoning summary');
|
|
906
|
+
if (typeof record.itemCompleted !== 'boolean' || (record.text === '' && !record.itemCompleted))
|
|
907
|
+
localAppProjectionError('summary seal');
|
|
908
|
+
if (typeof record.text !== 'string')
|
|
909
|
+
localAppProjectionError('reasoning summary');
|
|
910
|
+
return Object.freeze({ ...base, type: 'reasoning-summary', itemIndex: projectionInteger(record.itemIndex, 'summary item index', 0, 4_294_967_295), text: optionalProjectionContent(record.text, 'reasoning summary', 64 * 1024), itemCompleted: record.itemCompleted });
|
|
911
|
+
}
|
|
575
912
|
if (record.type === 'reasoning-continuity') {
|
|
576
913
|
assertExactProjectionKeys(record, ['type', 'sequence', 'traceId', 'itemIndex', 'carrier'], 'text continuity');
|
|
577
914
|
return Object.freeze({ ...base, type: 'reasoning-continuity', itemIndex: projectionInteger(record.itemIndex, 'continuity item index', 0, 4_294_967_295), carrier: projectLocalAppContinuity(record.carrier) });
|
|
@@ -589,13 +926,18 @@ function projectTextTurnEvent(value) {
|
|
|
589
926
|
}
|
|
590
927
|
return localAppProjectionError('text-turn event type');
|
|
591
928
|
}
|
|
592
|
-
function projectScenarioExecute(value) {
|
|
929
|
+
function projectScenarioExecute(value, decide) {
|
|
593
930
|
const record = asRecord(value);
|
|
594
931
|
assertExactProjectionKeys(record, ['output', 'traceId'], 'scenario execute');
|
|
595
932
|
const output = asRecord(record.output);
|
|
596
933
|
if (!output)
|
|
597
934
|
localAppProjectionError('scenario execute output');
|
|
598
935
|
const traceId = boundedProjectionText(record.traceId, 'scenario execute traceId', 512);
|
|
936
|
+
if ((output.type === 'text-decide') !== Boolean(decide))
|
|
937
|
+
localAppProjectionError('scenario execute output type');
|
|
938
|
+
if (decide) {
|
|
939
|
+
return Object.freeze({ output: validateNimiLocalAppTextDecideOutput(output, decide), traceId });
|
|
940
|
+
}
|
|
599
941
|
if (output.type === 'text-generate') {
|
|
600
942
|
assertExactProjectionKeys(output, ['type', 'items', 'finishReason'], 'text generate output');
|
|
601
943
|
const items = projectLocalAppTextItems(output.items);
|
|
@@ -606,7 +948,7 @@ function projectScenarioExecute(value) {
|
|
|
606
948
|
}
|
|
607
949
|
assertSafeProjection(record);
|
|
608
950
|
if (output.type === 'text-embed') {
|
|
609
|
-
assertExactProjectionKeys(output, ['type', 'vectors', 'spaceId'], 'text embed output');
|
|
951
|
+
assertExactProjectionKeys(output, ['type', 'vectors', 'spaceId', ...(output.usage !== undefined ? ['usage'] : [])], 'text embed output');
|
|
610
952
|
const spaceId = boundedProjectionText(output.spaceId, 'embedding spaceId', 128);
|
|
611
953
|
if (!Array.isArray(output.vectors) || output.vectors.length === 0 || output.vectors.length > 16)
|
|
612
954
|
localAppProjectionError('text embed vectors');
|
|
@@ -616,11 +958,8 @@ function projectScenarioExecute(value) {
|
|
|
616
958
|
localAppProjectionError('text embed vector');
|
|
617
959
|
return Object.freeze([...vector]);
|
|
618
960
|
});
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
if (output.type === 'image-generate') {
|
|
622
|
-
assertExactProjectionKeys(output, ['type', 'artifacts'], 'image execute output');
|
|
623
|
-
return Object.freeze({ output: Object.freeze({ type: 'image-generate', artifacts: projectArtifacts(output.artifacts) }), traceId });
|
|
961
|
+
const usage = output.usage === undefined ? undefined : projectEmbeddingUsage(output.usage);
|
|
962
|
+
return Object.freeze({ output: Object.freeze({ type: 'text-embed', vectors: Object.freeze(vectors), spaceId, ...(usage ? { usage } : {}) }), traceId });
|
|
624
963
|
}
|
|
625
964
|
return localAppProjectionError('scenario execute output type');
|
|
626
965
|
}
|
|
@@ -631,7 +970,8 @@ function projectScenarioJobSubmit(value) {
|
|
|
631
970
|
}
|
|
632
971
|
function projectScenarioJobGet(value) {
|
|
633
972
|
const record = asRecord(value);
|
|
634
|
-
assertExactProjectionKeys(record, ['job', 'asset', 'voiceReference', ...(record && Object.hasOwn(record, 'visionLocate') ? ['visionLocate'] : [])], 'scenario Job result');
|
|
973
|
+
assertExactProjectionKeys(record, ['job', 'asset', 'voiceReference', ...(record && Object.hasOwn(record, 'visionLocate') ? ['visionLocate'] : []), ...(record && Object.hasOwn(record, 'observationIssue') ? ['observationIssue'] : [])], 'scenario Job result');
|
|
974
|
+
const observationIssue = record.observationIssue === undefined ? undefined : projectJobObservationIssue(record.observationIssue);
|
|
635
975
|
const job = projectScenarioJob(record.job);
|
|
636
976
|
const visionLocate = record.visionLocate === undefined ? undefined : projectVisionLocateResult(record.visionLocate);
|
|
637
977
|
if ((job.scenarioType === 'vision-locate' && job.status === 'completed') !== (visionLocate !== undefined) || (visionLocate && job.artifacts.length !== 0))
|
|
@@ -647,6 +987,7 @@ function projectScenarioJobGet(value) {
|
|
|
647
987
|
job,
|
|
648
988
|
asset,
|
|
649
989
|
voiceReference,
|
|
990
|
+
...(observationIssue ? { observationIssue } : {}),
|
|
650
991
|
...(visionLocate ? { visionLocate } : {}),
|
|
651
992
|
});
|
|
652
993
|
}
|
|
@@ -657,7 +998,7 @@ function projectScenarioJobEnvelope(value) {
|
|
|
657
998
|
}
|
|
658
999
|
function projectScenarioJob(value) {
|
|
659
1000
|
const record = asRecord(value);
|
|
660
|
-
assertExactProjectionKeys(record, ['jobId', 'scenarioType', 'status', 'progressPercent', 'progressCurrentStep', 'progressTotalSteps', 'reasonCode', 'reasonDetail', 'artifacts', 'traceId', 'createdAt', 'updatedAt', 'transcriptionText', ...(record && Object.hasOwn(record, 'textAnnotation') ? ['textAnnotation'] : []), ...(record && Object.hasOwn(record, 'audioSeparation') ? ['audioSeparation'] : []), ...(record && Object.hasOwn(record, 'transcription') ? ['transcription'] : []), ...(record && Object.hasOwn(record, 'interruption') ? ['interruption'] : []), ...(record && Object.hasOwn(record, 'videoFaceSwapSummary') ? ['videoFaceSwapSummary'] : [])], 'scenario Job');
|
|
1001
|
+
assertExactProjectionKeys(record, [...(record && Object.hasOwn(record, 'submissionOutcome') ? ['submissionOutcome'] : []), ...(record && Object.hasOwn(record, 'stopOutcome') ? ['stopOutcome'] : []), ...(record && Object.hasOwn(record, 'recoveryExpiresAt') ? ['recoveryExpiresAt'] : []), 'jobId', 'scenarioType', 'status', 'progressPercent', 'progressCurrentStep', 'progressTotalSteps', 'reasonCode', 'reasonDetail', 'artifacts', 'traceId', 'createdAt', 'updatedAt', 'transcriptionText', ...(record && Object.hasOwn(record, 'textAnnotation') ? ['textAnnotation'] : []), ...(record && Object.hasOwn(record, 'audioSeparation') ? ['audioSeparation'] : []), ...(record && Object.hasOwn(record, 'speakerEmbedding') ? ['speakerEmbedding'] : []), ...(record && Object.hasOwn(record, 'musicGeneration') ? ['musicGeneration'] : []), ...(record && Object.hasOwn(record, 'musicTranscription') ? ['musicTranscription'] : []), ...(record && Object.hasOwn(record, 'voiceConversion') ? ['voiceConversion'] : []), ...(record && Object.hasOwn(record, 'transcription') ? ['transcription'] : []), ...(record && Object.hasOwn(record, 'interruption') ? ['interruption'] : []), ...(record && Object.hasOwn(record, 'videoFaceSwapSummary') ? ['videoFaceSwapSummary'] : [])], 'scenario Job');
|
|
661
1002
|
assertSafeProjection(record);
|
|
662
1003
|
if (!LOCAL_SCENARIO_TYPES.includes(record.scenarioType) || !LOCAL_JOB_STATUSES.includes(record.status))
|
|
663
1004
|
localAppProjectionError('scenario Job enum');
|
|
@@ -679,10 +1020,33 @@ function projectScenarioJob(value) {
|
|
|
679
1020
|
if ((record.textAnnotation !== undefined) !== (record.scenarioType === 'text-annotate' && record.status === 'completed'))
|
|
680
1021
|
localAppProjectionError('text annotation state');
|
|
681
1022
|
const textAnnotation = record.textAnnotation === undefined ? undefined : validateNimiLocalAppTextAnnotationResult(record.textAnnotation);
|
|
1023
|
+
if ((record.speakerEmbedding !== undefined) !== (record.scenarioType === 'audio-speaker-embed' && record.status === 'completed'))
|
|
1024
|
+
localAppProjectionError('speaker representation state');
|
|
1025
|
+
const speakerEmbedding = record.speakerEmbedding === undefined ? undefined : validateNimiLocalAppSpeakerEmbedding(record.speakerEmbedding);
|
|
1026
|
+
if (speakerEmbedding && artifacts.length)
|
|
1027
|
+
localAppProjectionError('speaker representation artifacts');
|
|
682
1028
|
const audioSeparation = record.audioSeparation === undefined ? undefined : validateNimiLocalAppAudioSeparation(record.audioSeparation, artifacts);
|
|
1029
|
+
if ((record.musicGeneration !== undefined) !== (record.scenarioType === 'music-generate' && record.status === 'completed'))
|
|
1030
|
+
localAppProjectionError('music generation state');
|
|
1031
|
+
if ((record.musicTranscription !== undefined) !== (record.scenarioType === 'music-transcribe' && record.status === 'completed'))
|
|
1032
|
+
localAppProjectionError('music transcription state');
|
|
1033
|
+
const musicTranscription = record.musicTranscription === undefined ? undefined : validateNimiLocalAppMusicTranscription(record.musicTranscription, artifacts);
|
|
1034
|
+
if ((record.voiceConversion !== undefined) !== (record.scenarioType === 'audio-voice-convert' && record.status === 'completed'))
|
|
1035
|
+
localAppProjectionError('voice conversion state');
|
|
1036
|
+
const voiceConversion = record.voiceConversion === undefined ? undefined : validateNimiLocalAppVoiceConversion(record.voiceConversion, artifacts);
|
|
1037
|
+
const musicGeneration = record.musicGeneration === undefined ? undefined : validateNimiLocalAppMusicGeneration(record.musicGeneration, artifacts);
|
|
1038
|
+
const recoveryExpiresAt = record.recoveryExpiresAt === undefined ? undefined : projectTimestamp(record.recoveryExpiresAt, 'music recovery expiry');
|
|
1039
|
+
if (record.recoveryExpiresAt !== undefined && (!recoveryExpiresAt || !['music-generate', 'music-transcribe', 'audio-voice-convert', 'voice-create'].includes(String(record.scenarioType)) || !['completed', 'failed', 'canceled', 'timeout'].includes(String(record.status))))
|
|
1040
|
+
localAppProjectionError('music recovery expiry state');
|
|
683
1041
|
return Object.freeze({
|
|
1042
|
+
...projectJobFacts(record),
|
|
1043
|
+
...(recoveryExpiresAt ? { recoveryExpiresAt } : {}),
|
|
1044
|
+
...(musicGeneration ? { musicGeneration } : {}),
|
|
1045
|
+
...(musicTranscription ? { musicTranscription } : {}),
|
|
1046
|
+
...(voiceConversion ? { voiceConversion } : {}),
|
|
684
1047
|
...(textAnnotation ? { textAnnotation } : {}),
|
|
685
1048
|
...(audioSeparation ? { audioSeparation } : {}),
|
|
1049
|
+
...(speakerEmbedding ? { speakerEmbedding } : {}),
|
|
686
1050
|
...(videoFaceSwapSummary ? { videoFaceSwapSummary } : {}),
|
|
687
1051
|
...(transcription ? { transcription } : {}),
|
|
688
1052
|
...(interruption ? { interruption } : {}),
|
|
@@ -701,6 +1065,51 @@ function projectScenarioJob(value) {
|
|
|
701
1065
|
transcriptionText: optionalProjectionContent(record.transcriptionText, 'scenario Job transcriptionText', 1 << 20),
|
|
702
1066
|
});
|
|
703
1067
|
}
|
|
1068
|
+
const SUBMISSION_OUTCOMES = [undefined, 'not-dispatched', 'unknown', 'accepted', 'rejected'];
|
|
1069
|
+
const STOP_OUTCOMES = [undefined, 'not-dispatched', 'confirmed', 'unconfirmed'];
|
|
1070
|
+
function localJobFactsFromRuntime(job) {
|
|
1071
|
+
const submission = job.submissionOutcome ?? 0;
|
|
1072
|
+
const stop = job.stopOutcome ?? 0;
|
|
1073
|
+
if (!Number.isInteger(submission) || submission < 0 || submission >= SUBMISSION_OUTCOMES.length
|
|
1074
|
+
|| !Number.isInteger(stop) || stop < 0 || stop >= STOP_OUTCOMES.length)
|
|
1075
|
+
localAppProjectionError('Job outcome enum');
|
|
1076
|
+
return { ...(submission ? { submissionOutcome: SUBMISSION_OUTCOMES[submission] } : {}), ...(stop ? { stopOutcome: STOP_OUTCOMES[stop] } : {}) };
|
|
1077
|
+
}
|
|
1078
|
+
function projectJobFacts(record) {
|
|
1079
|
+
const submission = record.submissionOutcome;
|
|
1080
|
+
const stop = record.stopOutcome;
|
|
1081
|
+
if (!SUBMISSION_OUTCOMES.includes(submission) || !STOP_OUTCOMES.includes(stop))
|
|
1082
|
+
localAppProjectionError('Job outcome enum');
|
|
1083
|
+
if (record.status !== 'canceled' && stop !== undefined)
|
|
1084
|
+
localAppProjectionError('uncanceled Job stop facts');
|
|
1085
|
+
if (submission !== undefined) {
|
|
1086
|
+
const valid = record.status === 'submitted' || record.status === 'queued' ? submission === 'not-dispatched'
|
|
1087
|
+
: record.status === 'running' ? submission === 'unknown' || submission === 'accepted'
|
|
1088
|
+
: record.status === 'completed' ? submission === 'accepted'
|
|
1089
|
+
: record.status === 'timeout' ? submission !== 'rejected'
|
|
1090
|
+
: record.status === 'canceled' ? submission === 'not-dispatched' ? stop === 'not-dispatched'
|
|
1091
|
+
: submission === 'unknown' ? stop === 'unconfirmed' : stop === 'confirmed' || stop === 'unconfirmed'
|
|
1092
|
+
: record.status === 'failed';
|
|
1093
|
+
if (!valid)
|
|
1094
|
+
localAppProjectionError('Job outcome combination');
|
|
1095
|
+
if (record.reasonCode === 'ai-provider-task-canceled' && (record.status !== 'canceled' || submission !== 'accepted' || stop !== 'confirmed'))
|
|
1096
|
+
localAppProjectionError('provider cancellation facts');
|
|
1097
|
+
if (record.reasonCode === 'ai-provider-task-expired' && (record.status !== 'timeout' || submission !== 'accepted'))
|
|
1098
|
+
localAppProjectionError('provider expiration facts');
|
|
1099
|
+
}
|
|
1100
|
+
return { ...(submission !== undefined ? { submissionOutcome: submission } : {}), ...(stop !== undefined ? { stopOutcome: stop } : {}) };
|
|
1101
|
+
}
|
|
1102
|
+
function projectJobObservationIssue(value) {
|
|
1103
|
+
const record = asRecord(value);
|
|
1104
|
+
assertExactProjectionKeys(record, ['reasonCode', 'observedAt'], 'Job observation issue');
|
|
1105
|
+
const reasonCode = boundedProjectionText(record.reasonCode, 'observation reason', 128);
|
|
1106
|
+
if (runtimeReasonCode(reasonCode) === RuntimeReasonCode.REASON_CODE_UNSPECIFIED)
|
|
1107
|
+
localAppProjectionError('observation reason');
|
|
1108
|
+
const observedAt = projectTimestamp(record.observedAt, 'observation timestamp');
|
|
1109
|
+
if (!observedAt)
|
|
1110
|
+
localAppProjectionError('observation timestamp');
|
|
1111
|
+
return Object.freeze({ reasonCode, observedAt });
|
|
1112
|
+
}
|
|
704
1113
|
function projectVideoFaceSwapSummary(value) {
|
|
705
1114
|
const record = asRecord(value);
|
|
706
1115
|
assertExactProjectionKeys(record, ['totalFrames', 'transformedFrames', 'preservedFrames', 'durationUs', 'frameRate', 'audioPreserved'], 'video face replacement summary');
|
|
@@ -718,20 +1127,27 @@ function projectArtifacts(value) {
|
|
|
718
1127
|
return Object.freeze(value.map((entry) => {
|
|
719
1128
|
const record = asRecord(entry);
|
|
720
1129
|
const hasSeed = Boolean(record && Object.hasOwn(record, 'seed'));
|
|
1130
|
+
const hasAlignment = Boolean(record && Object.hasOwn(record, 'speechAlignment'));
|
|
721
1131
|
assertExactProjectionKeys(record, [
|
|
722
1132
|
'artifactId', 'mimeType', 'bytes', 'sizeBytes', 'sha256', 'durationMs',
|
|
723
|
-
'width', 'height', 'sampleRateHz', 'channels', ...(hasSeed ? ['seed'] : []),
|
|
1133
|
+
'width', 'height', 'sampleRateHz', 'channels', ...(record && Object.hasOwn(record, 'frameCount') ? ['frameCount'] : []), ...(hasSeed ? ['seed'] : []), ...(hasAlignment ? ['speechAlignment'] : []),
|
|
724
1134
|
], 'scenario artifact');
|
|
725
1135
|
const bytes = validateProjectionBytes(record.bytes, 'scenario artifact bytes');
|
|
726
1136
|
const sizeBytes = projectionInteger(record.sizeBytes, 'scenario artifact sizeBytes', 0, Number.MAX_SAFE_INTEGER);
|
|
727
|
-
if (bytes.
|
|
1137
|
+
if (bytes.byteLength > 0 && bytes.byteLength !== sizeBytes)
|
|
728
1138
|
localAppProjectionError('scenario artifact byte size');
|
|
729
1139
|
const mimeType = mimeProjection(record.mimeType);
|
|
730
1140
|
const seed = hasSeed
|
|
731
|
-
? projectionInteger(record.seed, 'scenario artifact seed',
|
|
1141
|
+
? projectionInteger(record.seed, 'scenario artifact seed', 0, 2_147_483_647)
|
|
732
1142
|
: undefined;
|
|
733
1143
|
if (hasSeed && !mimeType.startsWith('image/'))
|
|
734
1144
|
localAppProjectionError('scenario artifact seed mime');
|
|
1145
|
+
if (hasAlignment && !mimeType.startsWith('audio/'))
|
|
1146
|
+
localAppProjectionError('speech alignment requires audio');
|
|
1147
|
+
const speechAlignment = hasAlignment ? projectLocalAppSpeechAlignment(record.speechAlignment) : undefined;
|
|
1148
|
+
const frameCount = record.frameCount === undefined ? undefined : projectionInteger(record.frameCount, 'audio frame count', 1, Number.MAX_SAFE_INTEGER);
|
|
1149
|
+
if (frameCount !== undefined && (!mimeType.startsWith('audio/') || !(Number(record.sampleRateHz) > 0) || !(Number(record.channels) > 0)))
|
|
1150
|
+
localAppProjectionError('audio frame count requires an audio format');
|
|
735
1151
|
return Object.freeze({
|
|
736
1152
|
artifactId: boundedProjectionText(record.artifactId, 'scenario artifact id', MAX_IDENTIFIER_BYTES),
|
|
737
1153
|
mimeType,
|
|
@@ -743,34 +1159,129 @@ function projectArtifacts(value) {
|
|
|
743
1159
|
height: projectionInteger(record.height, 'scenario artifact height', 0, Number.MAX_SAFE_INTEGER),
|
|
744
1160
|
sampleRateHz: projectionInteger(record.sampleRateHz, 'scenario artifact sampleRateHz', 0, Number.MAX_SAFE_INTEGER),
|
|
745
1161
|
channels: projectionInteger(record.channels, 'scenario artifact channels', 0, Number.MAX_SAFE_INTEGER),
|
|
1162
|
+
...(frameCount !== undefined ? { frameCount } : {}),
|
|
746
1163
|
...(seed !== undefined ? { seed } : {}),
|
|
1164
|
+
...(speechAlignment ? { speechAlignment } : {}),
|
|
747
1165
|
});
|
|
748
1166
|
}));
|
|
749
1167
|
}
|
|
750
|
-
function projectArtifactUpload(value, expectedSize, expectedMimeType) {
|
|
1168
|
+
function projectArtifactUpload(value, expectedSize, expectedMimeType, preparation) {
|
|
751
1169
|
const record = asRecord(value);
|
|
752
|
-
assertExactProjectionKeys(record, ['artifactId', 'sizeBytes', 'mimeType'], 'artifact upload result');
|
|
1170
|
+
assertExactProjectionKeys(record, ['artifactId', 'sizeBytes', 'mimeType', ...(preparation ? ['audioInfo', 'expiresAt'] : expectedMimeType === 'text/vnd.abc' ? ['expiresAt'] : [])], 'artifact upload result');
|
|
753
1171
|
assertNoAuthorityMaterial(record);
|
|
754
1172
|
const artifactId = projectionText(record.artifactId, 'artifact upload artifactId');
|
|
755
1173
|
if (utf8Length(artifactId) > MAX_IDENTIFIER_BYTES
|
|
756
|
-
|| !Number.isSafeInteger(record.sizeBytes)
|
|
757
|
-
|| record.sizeBytes < 1 || record.sizeBytes > MAX_ARTIFACT_BYTES
|
|
758
|
-
|| record.mimeType !==
|
|
1174
|
+
|| typeof record.sizeBytes !== 'number' || !Number.isSafeInteger(record.sizeBytes)
|
|
1175
|
+
|| record.sizeBytes < 1 || record.sizeBytes > (preparation ? 512 * 1024 * 1024 : MAX_ARTIFACT_BYTES)
|
|
1176
|
+
|| record.mimeType !== (preparation ? 'audio/wav' : expectedMimeType)
|
|
1177
|
+
|| !isArtifactUploadMime(record.mimeType)) {
|
|
759
1178
|
localAppProjectionError('artifact upload result');
|
|
760
1179
|
}
|
|
761
|
-
|
|
1180
|
+
if (!preparation) {
|
|
1181
|
+
if (record.sizeBytes !== expectedSize || record.audioInfo !== undefined)
|
|
1182
|
+
localAppProjectionError('artifact upload result');
|
|
1183
|
+
if (expectedMimeType === 'text/vnd.abc') {
|
|
1184
|
+
const expiresAt = projectTimestamp(record.expiresAt, 'score expiry');
|
|
1185
|
+
if (!expiresAt || Number(record.sizeBytes) > 1048576)
|
|
1186
|
+
localAppProjectionError('score expiry or size');
|
|
1187
|
+
return Object.freeze({ artifactId, sizeBytes: record.sizeBytes, mimeType: record.mimeType, expiresAt });
|
|
1188
|
+
}
|
|
1189
|
+
return Object.freeze({ artifactId, sizeBytes: record.sizeBytes, mimeType: record.mimeType });
|
|
1190
|
+
}
|
|
1191
|
+
const audio = asRecord(record.audioInfo);
|
|
1192
|
+
const expiresAt = projectTimestamp(record.expiresAt, 'canonical audio expiry');
|
|
1193
|
+
if (!expiresAt)
|
|
1194
|
+
localAppProjectionError('canonical audio expiry');
|
|
1195
|
+
assertExactProjectionKeys(audio, ['sampleRateHz', 'channels', 'frameCount', 'durationMs'], 'canonical audio facts');
|
|
1196
|
+
const sampleRateHz = projectionInteger(audio.sampleRateHz, 'sampleRateHz', 8000, 96000);
|
|
1197
|
+
const channels = projectionInteger(audio.channels, 'channels', 1, 2);
|
|
1198
|
+
const frameCount = projectionInteger(audio.frameCount, 'frameCount', 1, sampleRateHz * 600);
|
|
1199
|
+
const durationMs = projectionInteger(audio.durationMs, 'durationMs', 0, 600000);
|
|
1200
|
+
if (durationMs !== Math.floor(frameCount * 1000 / sampleRateHz)
|
|
1201
|
+
|| Number(record.sizeBytes) < frameCount * channels * 4 + 44
|
|
1202
|
+
|| (preparation.targetSampleRateHz !== undefined && preparation.targetSampleRateHz !== sampleRateHz)
|
|
1203
|
+
|| (preparation.channelMode === 'MONO_TO_STEREO' && channels !== 2)
|
|
1204
|
+
|| (preparation.channelMode === 'STEREO_TO_MONO' && channels !== 1)) {
|
|
1205
|
+
localAppProjectionError('canonical audio facts');
|
|
1206
|
+
}
|
|
1207
|
+
return Object.freeze({ artifactId, sizeBytes: record.sizeBytes, mimeType: record.mimeType,
|
|
1208
|
+
expiresAt,
|
|
1209
|
+
audioInfo: Object.freeze({ sampleRateHz, channels, frameCount, durationMs }) });
|
|
1210
|
+
}
|
|
1211
|
+
// @nimi-authority: rule.nimi.runtime.ai-provider.canonical-audio-upload
|
|
1212
|
+
function prepareArtifactUploadInput(input) {
|
|
1213
|
+
assertExactKeys(input, ['bytes', 'source', 'mimeType', 'audioPreparation'], 'artifact upload input');
|
|
1214
|
+
assertNoAuthorityMaterial(input);
|
|
1215
|
+
if (!isArtifactUploadMime(input.mimeType) || (input.bytes !== undefined) === (input.source !== undefined)) {
|
|
1216
|
+
invalidAIInput('artifact upload requires exactly one source');
|
|
1217
|
+
}
|
|
1218
|
+
let source;
|
|
1219
|
+
if (input.source !== undefined) {
|
|
1220
|
+
if (!input.source || typeof input.source !== 'object')
|
|
1221
|
+
invalidAIInput('artifact source is invalid');
|
|
1222
|
+
if (input.source.kind === 'app-asset') {
|
|
1223
|
+
assertExactKeys(input.source, ['kind', 'relativePath'], 'artifact source');
|
|
1224
|
+
const relativePath = input.source.relativePath;
|
|
1225
|
+
if (typeof relativePath !== 'string' || !relativePath || utf8Length(relativePath) > 4096 || relativePath.includes('\0'))
|
|
1226
|
+
invalidAIInput('artifact source path is invalid');
|
|
1227
|
+
source = { kind: 'app-asset', relativePath };
|
|
1228
|
+
}
|
|
1229
|
+
else if (input.source.kind === 'artifact') {
|
|
1230
|
+
assertExactKeys(input.source, ['kind', 'artifactId'], 'artifact source');
|
|
1231
|
+
source = { kind: 'artifact', artifactId: boundedIdentifier(input.source.artifactId, 'artifactId') };
|
|
1232
|
+
}
|
|
1233
|
+
else
|
|
1234
|
+
invalidAIInput('artifact source kind is invalid');
|
|
1235
|
+
}
|
|
1236
|
+
else if (!isNimiLocalAppByteView(input.bytes) || input.bytes.byteLength === 0 || input.bytes.byteLength > MAX_ARTIFACT_BYTES) {
|
|
1237
|
+
invalidAIInput('artifact upload bytes are invalid');
|
|
1238
|
+
}
|
|
1239
|
+
if (input.mimeType === 'text/vnd.abc' && (!input.bytes || input.bytes.byteLength > 1048576 || source || input.audioPreparation))
|
|
1240
|
+
invalidAIInput('ABC requires inline bytes up to 1 MiB');
|
|
1241
|
+
let audioPreparation;
|
|
1242
|
+
if (input.audioPreparation !== undefined) {
|
|
1243
|
+
const candidate = input.audioPreparation;
|
|
1244
|
+
if (!candidate || typeof candidate !== 'object')
|
|
1245
|
+
invalidAIInput('audio preparation is invalid');
|
|
1246
|
+
assertExactKeys(candidate, ['profile', 'targetSampleRateHz', 'channelMode'], 'audio preparation');
|
|
1247
|
+
if (candidate.profile !== 'canonical-pcm-v1' || !['audio/wav', 'audio/mpeg', 'audio/flac'].includes(input.mimeType)
|
|
1248
|
+
|| (candidate.targetSampleRateHz !== undefined && (!Number.isInteger(candidate.targetSampleRateHz) || candidate.targetSampleRateHz < 8000 || candidate.targetSampleRateHz > 96000 || input.mimeType !== 'audio/wav'))
|
|
1249
|
+
|| (candidate.channelMode !== undefined && !['PRESERVE', 'MONO_TO_STEREO', 'STEREO_TO_MONO'].includes(candidate.channelMode))) {
|
|
1250
|
+
invalidAIInput('audio preparation is unsupported');
|
|
1251
|
+
}
|
|
1252
|
+
audioPreparation = { profile: 'canonical-pcm-v1',
|
|
1253
|
+
...(candidate.targetSampleRateHz !== undefined ? { targetSampleRateHz: candidate.targetSampleRateHz } : {}),
|
|
1254
|
+
...(candidate.channelMode !== undefined ? { channelMode: candidate.channelMode } : {}) };
|
|
1255
|
+
}
|
|
1256
|
+
if ((source || input.mimeType === 'audio/flac') && !audioPreparation)
|
|
1257
|
+
invalidAIInput('this source requires canonical audio preparation');
|
|
1258
|
+
if (source?.kind === 'artifact' && input.mimeType !== 'audio/wav')
|
|
1259
|
+
invalidAIInput('artifact source must already be canonical WAV');
|
|
1260
|
+
return { mimeType: input.mimeType, ...(source ? { source } : { bytes: copyNimiLocalAppBytes(input.bytes) }), ...(audioPreparation ? { audioPreparation } : {}) };
|
|
1261
|
+
}
|
|
1262
|
+
// Shared protected-carrier validation; this projects no ownership or readiness.
|
|
1263
|
+
export function validateNimiLocalAppArtifactUploadShellInput(value) {
|
|
1264
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
1265
|
+
invalidAIInput('artifact upload input is invalid');
|
|
1266
|
+
const record = value;
|
|
1267
|
+
if (record.bytes !== undefined && !isNimiLocalAppByteView(record.bytes))
|
|
1268
|
+
invalidAIInput('artifact upload bytes are invalid');
|
|
1269
|
+
return prepareArtifactUploadInput(record);
|
|
1270
|
+
}
|
|
1271
|
+
export function validateNimiLocalAppArtifactUploadResult(value, input) {
|
|
1272
|
+
return projectArtifactUpload(value, input.bytes?.byteLength, input.mimeType, input.audioPreparation);
|
|
762
1273
|
}
|
|
763
1274
|
function isArtifactUploadMime(value) {
|
|
764
|
-
return value === 'image/png' || value === 'image/jpeg' || value === 'image/webp' || value === 'image/gif' || value === 'audio/wav' || value === 'audio/mpeg' || value === 'video/mp4';
|
|
1275
|
+
return value === 'image/png' || value === 'image/jpeg' || value === 'image/webp' || value === 'image/gif' || value === 'audio/wav' || value === 'audio/mpeg' || value === 'audio/flac' || value === 'video/mp4' || value === 'text/vnd.abc';
|
|
765
1276
|
}
|
|
766
1277
|
function projectArtifactRead(value) {
|
|
767
1278
|
const record = asRecord(value);
|
|
768
1279
|
assertExactProjectionKeys(record, ['bytes', 'mimeType', 'sizeBytes'], 'artifact read');
|
|
769
1280
|
const bytes = validateProjectionBytes(record.bytes, 'artifact read bytes');
|
|
770
1281
|
const sizeBytes = projectionInteger(record.sizeBytes, 'artifact read sizeBytes', 0, MAX_ARTIFACT_BYTES);
|
|
771
|
-
if (bytes.
|
|
1282
|
+
if (bytes.byteLength !== sizeBytes)
|
|
772
1283
|
localAppProjectionError('artifact read byte size');
|
|
773
|
-
return Object.freeze({ bytes
|
|
1284
|
+
return Object.freeze({ bytes, mimeType: mimeProjection(record.mimeType), sizeBytes });
|
|
774
1285
|
}
|
|
775
1286
|
function projectScenarioJobEvent(value) {
|
|
776
1287
|
const record = asRecord(value);
|
|
@@ -856,6 +1367,7 @@ function runtimeTextTurnRequest(input) {
|
|
|
856
1367
|
return {
|
|
857
1368
|
messages,
|
|
858
1369
|
tools: toRuntimeTools(input.tools),
|
|
1370
|
+
...(input.reasoning === undefined ? {} : { reasoning: toRuntimeReasoningConfig(input.reasoning, (detail) => localAppError(detail, 'SDK_LOCAL_APP_INPUT_INVALID', 'provide_admitted_local_app_text_input')) }),
|
|
859
1371
|
toolChoice: choice === 'none' ? ToolChoiceMode.NONE : choice === 'auto' ? ToolChoiceMode.AUTO
|
|
860
1372
|
: choice === 'required' ? ToolChoiceMode.REQUIRED : choice ? ToolChoiceMode.TOOL : ToolChoiceMode.UNSPECIFIED,
|
|
861
1373
|
toolChoiceName: typeof choice === 'object' ? choice.name : '',
|
|
@@ -874,13 +1386,26 @@ function runtimeTextTurnRequest(input) {
|
|
|
874
1386
|
...(input.seed === undefined ? {} : { seed: String(input.seed) }),
|
|
875
1387
|
};
|
|
876
1388
|
}
|
|
877
|
-
function
|
|
1389
|
+
function projectEmbeddingUsage(value) {
|
|
1390
|
+
const usage = asRecord(value);
|
|
1391
|
+
assertExactProjectionKeys(usage, ['promptTokens', 'completionTokens', 'totalTokens'], 'embedding usage');
|
|
1392
|
+
const promptTokens = projectionInteger(usage.promptTokens, 'embedding prompt tokens', 0, Number.MAX_SAFE_INTEGER);
|
|
1393
|
+
const completionTokens = projectionInteger(usage.completionTokens, 'embedding completion tokens', 0, Number.MAX_SAFE_INTEGER);
|
|
1394
|
+
const totalTokens = projectionInteger(usage.totalTokens, 'embedding total tokens', 0, Number.MAX_SAFE_INTEGER);
|
|
1395
|
+
if (totalTokens !== promptTokens + completionTokens)
|
|
1396
|
+
localAppProjectionError('embedding total tokens');
|
|
1397
|
+
return Object.freeze({ promptTokens, completionTokens, totalTokens });
|
|
1398
|
+
}
|
|
1399
|
+
function runtimeExecuteRequest(spec, timeoutMs) {
|
|
878
1400
|
if (spec.type === 'text-generate')
|
|
879
|
-
return { spec: { oneofKind: 'textGenerate', textGenerate: runtimeTextTurnRequest(spec) } };
|
|
1401
|
+
return { spec: { oneofKind: 'textGenerate', textGenerate: runtimeTextTurnRequest(spec) }, timeoutMs };
|
|
880
1402
|
if (spec.type === 'text-embed') {
|
|
881
|
-
return { spec: { oneofKind: 'textEmbed', textEmbed: { inputs: [...spec.inputs] } } };
|
|
1403
|
+
return { spec: { oneofKind: 'textEmbed', textEmbed: { inputs: [...spec.inputs], purpose: spec.purpose === 'retrieval-document' ? TextEmbedPurpose.RETRIEVAL_DOCUMENT : spec.purpose === 'retrieval-query' ? TextEmbedPurpose.RETRIEVAL_QUERY : TextEmbedPurpose.UNSPECIFIED, ...(spec.dimensions !== undefined ? { dimensions: spec.dimensions } : {}) } }, timeoutMs };
|
|
882
1404
|
}
|
|
883
|
-
|
|
1405
|
+
if (spec.type === 'text-decide') {
|
|
1406
|
+
return { spec: { oneofKind: 'textDecide', textDecide: runtimeTextDecideSpec(spec) }, timeoutMs };
|
|
1407
|
+
}
|
|
1408
|
+
return invalidAIInput('unsupported synchronous Scenario spec');
|
|
884
1409
|
}
|
|
885
1410
|
function runtimeLocalJobSpec(spec) {
|
|
886
1411
|
switch (spec.type) {
|
|
@@ -938,14 +1463,24 @@ function runtimeLocalJobSpec(spec) {
|
|
|
938
1463
|
...(spec.voiceRef === null ? {} : { voiceRef: runtimeVoiceReference(spec.voiceRef) }),
|
|
939
1464
|
timingMode: runtimeSpeechTimingMode(spec.timingMode),
|
|
940
1465
|
...(spec.voiceRenderHints === null ? {} : { voiceRenderHints: { ...spec.voiceRenderHints } }),
|
|
1466
|
+
...(spec.identityAudio ? { identityAudio: { ...spec.identityAudio } } : {}),
|
|
1467
|
+
...(spec.performanceAudio ? { performanceAudio: { ...spec.performanceAudio } } : {}),
|
|
941
1468
|
},
|
|
942
1469
|
};
|
|
943
1470
|
case 'text-annotate':
|
|
944
1471
|
return { oneofKind: 'textAnnotate', textAnnotate: { language: spec.language, texts: [...spec.texts] } };
|
|
1472
|
+
case 'audio-speaker-embed':
|
|
1473
|
+
return { oneofKind: 'audioSpeakerEmbed', audioSpeakerEmbed: { mimeType: spec.mimeType,
|
|
1474
|
+
audioSource: spec.audioSource ? { source: spec.audioSource.type === 'bytes' ? { oneofKind: 'audioBytes', audioBytes: spec.audioSource.bytes } : { oneofKind: 'audioUri', audioUri: spec.audioSource.uri } } : undefined,
|
|
1475
|
+
sourceAudio: spec.sourceAudio ? { artifactId: spec.sourceAudio.artifactId, range: spec.sourceAudio.range ? { startFrame: String(spec.sourceAudio.range.startFrame), endFrame: String(spec.sourceAudio.range.endFrame) } : undefined } : undefined } };
|
|
945
1476
|
case 'audio-separate':
|
|
946
|
-
return { oneofKind: 'audioSeparate', audioSeparate: { mimeType: spec.mimeType,
|
|
947
|
-
|
|
948
|
-
|
|
1477
|
+
return { oneofKind: 'audioSeparate', audioSeparate: { mimeType: spec.mimeType,
|
|
1478
|
+
audioSource: spec.audioSource ? { source: spec.audioSource.type === 'bytes'
|
|
1479
|
+
? { oneofKind: 'audioBytes', audioBytes: spec.audioSource.bytes }
|
|
1480
|
+
: { oneofKind: 'audioUri', audioUri: spec.audioSource.uri } } : undefined,
|
|
1481
|
+
sourceAudio: spec.sourceAudio ? { artifactId: spec.sourceAudio.artifactId,
|
|
1482
|
+
range: spec.sourceAudio.range ? { startFrame: String(spec.sourceAudio.range.startFrame), endFrame: String(spec.sourceAudio.range.endFrame) } : undefined } : undefined,
|
|
1483
|
+
includeInstrumentParts: spec.includeInstrumentParts ?? false } };
|
|
949
1484
|
case 'speech-transcribe':
|
|
950
1485
|
return {
|
|
951
1486
|
oneofKind: 'speechTranscribe',
|
|
@@ -959,7 +1494,7 @@ function runtimeLocalJobSpec(spec) {
|
|
|
959
1494
|
responseFormat: spec.responseFormat,
|
|
960
1495
|
audioSource: {
|
|
961
1496
|
source: spec.audioSource.type === 'bytes'
|
|
962
|
-
? { oneofKind: 'audioBytes', audioBytes:
|
|
1497
|
+
? { oneofKind: 'audioBytes', audioBytes: spec.audioSource.bytes }
|
|
963
1498
|
: { oneofKind: 'audioUri', audioUri: spec.audioSource.uri },
|
|
964
1499
|
},
|
|
965
1500
|
},
|
|
@@ -973,7 +1508,7 @@ function runtimeLocalJobSpec(spec) {
|
|
|
973
1508
|
oneofKind: 'referenceAudio',
|
|
974
1509
|
referenceAudio: {
|
|
975
1510
|
referenceAudioBytes: spec.referenceAudio.type === 'bytes'
|
|
976
|
-
?
|
|
1511
|
+
? spec.referenceAudio.bytes
|
|
977
1512
|
: new Uint8Array(),
|
|
978
1513
|
referenceAudioUri: spec.referenceAudio.type === 'uri' ? spec.referenceAudio.uri : '',
|
|
979
1514
|
referenceAudioMime: spec.referenceAudioMime,
|
|
@@ -999,13 +1534,17 @@ function runtimeLocalJobSpec(spec) {
|
|
|
999
1534
|
},
|
|
1000
1535
|
},
|
|
1001
1536
|
};
|
|
1537
|
+
case 'music-transcribe':
|
|
1538
|
+
return { oneofKind: 'musicTranscribe', musicTranscribe: runtimeMusicTranscribeSpec(spec) };
|
|
1539
|
+
case 'audio-voice-convert':
|
|
1540
|
+
return { oneofKind: 'audioVoiceConvert', audioVoiceConvert: runtimeVoiceConvertSpec(spec) };
|
|
1002
1541
|
case 'music-generate':
|
|
1003
1542
|
return {
|
|
1004
1543
|
oneofKind: 'musicGenerate',
|
|
1005
|
-
musicGenerate:
|
|
1544
|
+
musicGenerate: runtimeMusicGenerateSpec(spec),
|
|
1006
1545
|
};
|
|
1007
1546
|
case 'world-generate':
|
|
1008
|
-
return { oneofKind: 'worldGenerate', worldGenerate: { prompt: spec.prompt, displayName: spec.displayName } };
|
|
1547
|
+
return { oneofKind: 'worldGenerate', worldGenerate: { prompt: spec.prompt ?? '', displayName: spec.displayName, ...(spec.image ? { image: { artifactId: spec.image.artifactId, projection: spec.image.projection === 'ordinary' ? WorldImageProjection.ORDINARY : WorldImageProjection.EQUIRECTANGULAR_360 } } : {}) } };
|
|
1009
1548
|
}
|
|
1010
1549
|
}
|
|
1011
1550
|
function runtimeImageSpec(spec) {
|
|
@@ -1070,6 +1609,8 @@ function runtimeVoiceReference(value) {
|
|
|
1070
1609
|
function projectRuntimeTextTurnEvent(event) {
|
|
1071
1610
|
const base = { sequence: event.sequence, traceId: event.traceId };
|
|
1072
1611
|
switch (event.payload.oneofKind) {
|
|
1612
|
+
case 'reasoningSummary':
|
|
1613
|
+
return { ...base, type: 'reasoning-summary', ...event.payload.reasoningSummary };
|
|
1073
1614
|
case 'reasoningContinuity': {
|
|
1074
1615
|
const carrier = event.payload.reasoningContinuity.carrier;
|
|
1075
1616
|
if (!carrier)
|
|
@@ -1111,17 +1652,16 @@ function projectRuntimeScenarioExecuteResponse(response) {
|
|
|
1111
1652
|
type: 'text-embed',
|
|
1112
1653
|
vectors: response.output.textEmbed.vectors.map((vector) => [...vector.values]),
|
|
1113
1654
|
spaceId: response.output.textEmbed.spaceId,
|
|
1655
|
+
...(response.output.textEmbed.usage ? { usage: {
|
|
1656
|
+
promptTokens: Number(response.output.textEmbed.usage.inputTokens),
|
|
1657
|
+
completionTokens: Number(response.output.textEmbed.usage.outputTokens),
|
|
1658
|
+
totalTokens: Number(response.output.textEmbed.usage.inputTokens) + Number(response.output.textEmbed.usage.outputTokens),
|
|
1659
|
+
} } : {}),
|
|
1114
1660
|
},
|
|
1115
1661
|
traceId: response.traceId,
|
|
1116
1662
|
};
|
|
1117
|
-
case '
|
|
1118
|
-
return {
|
|
1119
|
-
output: {
|
|
1120
|
-
type: 'image-generate',
|
|
1121
|
-
artifacts: response.output.imageGenerate.artifacts.map(projectRuntimeLocalArtifact),
|
|
1122
|
-
},
|
|
1123
|
-
traceId: response.traceId,
|
|
1124
|
-
};
|
|
1663
|
+
case 'textDecide':
|
|
1664
|
+
return { output: localTextDecideOutputFromRuntime(response.output.textDecide), traceId: response.traceId };
|
|
1125
1665
|
default:
|
|
1126
1666
|
return localAppProjectionError('scenario Runtime output');
|
|
1127
1667
|
}
|
|
@@ -1129,6 +1669,7 @@ function projectRuntimeScenarioExecuteResponse(response) {
|
|
|
1129
1669
|
function projectRuntimeLocalJob(job) {
|
|
1130
1670
|
const interruption = localInterruptionFromRuntime(job.interruption);
|
|
1131
1671
|
return {
|
|
1672
|
+
...localJobFactsFromRuntime(job),
|
|
1132
1673
|
...(job.videoFaceSwapSummary ? { videoFaceSwapSummary: { ...job.videoFaceSwapSummary, durationUs: runtimeSafeInteger(job.videoFaceSwapSummary.durationUs, 'video duration') } } : {}),
|
|
1133
1674
|
...(interruption ? { interruption } : {}),
|
|
1134
1675
|
jobId: job.jobId,
|
|
@@ -1143,9 +1684,14 @@ function projectRuntimeLocalJob(job) {
|
|
|
1143
1684
|
traceId: job.traceId,
|
|
1144
1685
|
createdAt: plainRuntimeTimestamp(job.createdAt),
|
|
1145
1686
|
updatedAt: plainRuntimeTimestamp(job.updatedAt),
|
|
1687
|
+
...(job.recoveryExpiresAt ? { recoveryExpiresAt: plainRuntimeTimestamp(job.recoveryExpiresAt) } : {}),
|
|
1146
1688
|
transcriptionText: job.transcriptionText,
|
|
1147
1689
|
...(job.textAnnotation ? { textAnnotation: job.textAnnotation } : {}),
|
|
1148
|
-
...(job.
|
|
1690
|
+
...(job.speakerEmbedding ? { speakerEmbedding: validateNimiLocalAppSpeakerEmbedding({ vector: job.speakerEmbedding.vector?.values, spaceId: job.speakerEmbedding.spaceId }) } : {}),
|
|
1691
|
+
...(job.audioSeparation ? { audioSeparation: localAudioSeparation(job.audioSeparation) } : {}),
|
|
1692
|
+
...(job.musicGeneration ? { musicGeneration: localMusicGeneration(job.musicGeneration) } : {}),
|
|
1693
|
+
...(job.musicTranscription ? { musicTranscription: localMusicTranscription(job.musicTranscription) } : {}),
|
|
1694
|
+
...(job.voiceConversion ? { voiceConversion: localVoiceConversion(job.voiceConversion) } : {}),
|
|
1149
1695
|
...(job.transcription ? { transcription: localTranscriptionFromRuntime(job.transcription) } : {}),
|
|
1150
1696
|
};
|
|
1151
1697
|
}
|
|
@@ -1153,7 +1699,7 @@ function projectRuntimeLocalArtifact(artifact) {
|
|
|
1153
1699
|
return {
|
|
1154
1700
|
artifactId: artifact.artifactId,
|
|
1155
1701
|
mimeType: artifact.mimeType,
|
|
1156
|
-
bytes:
|
|
1702
|
+
bytes: artifact.bytes,
|
|
1157
1703
|
sizeBytes: runtimeSafeInteger(artifact.sizeBytes, 'scenario artifact size'),
|
|
1158
1704
|
sha256: artifact.sha256,
|
|
1159
1705
|
durationMs: runtimeSafeInteger(artifact.durationMs, 'scenario artifact duration'),
|
|
@@ -1161,7 +1707,12 @@ function projectRuntimeLocalArtifact(artifact) {
|
|
|
1161
1707
|
height: artifact.height,
|
|
1162
1708
|
sampleRateHz: artifact.sampleRateHz,
|
|
1163
1709
|
channels: artifact.channels,
|
|
1710
|
+
...(BigInt(artifact.frameCount ?? '0') > 0n ? { frameCount: runtimeSafeInteger(artifact.frameCount, 'audio frames') } : {}),
|
|
1164
1711
|
...(artifact.seed !== undefined ? { seed: artifact.seed } : {}),
|
|
1712
|
+
...(artifact.speechAlignment ? { speechAlignment: {
|
|
1713
|
+
unit: artifact.speechAlignment.unit === 1 ? 'word' : artifact.speechAlignment.unit === 2 ? 'char' : 'invalid',
|
|
1714
|
+
tokens: artifact.speechAlignment.tokens.map(token => ({ token: token.token, startMs: runtimeSafeInteger(token.startMs, 'alignment start'), endMs: runtimeSafeInteger(token.endMs, 'alignment end') })),
|
|
1715
|
+
} } : {}),
|
|
1165
1716
|
};
|
|
1166
1717
|
}
|
|
1167
1718
|
function projectRuntimeLocalJobEvent(event) {
|
|
@@ -1190,9 +1741,12 @@ function runtimeScenarioTypeName(value) {
|
|
|
1190
1741
|
[ScenarioType.SPEECH_SYNTHESIZE]: 'speech-synthesize',
|
|
1191
1742
|
[ScenarioType.SPEECH_TRANSCRIBE]: 'speech-transcribe',
|
|
1192
1743
|
[ScenarioType.TEXT_ANNOTATE]: 'text-annotate',
|
|
1744
|
+
[ScenarioType.AUDIO_SPEAKER_EMBED]: 'audio-speaker-embed',
|
|
1193
1745
|
[ScenarioType.AUDIO_SEPARATE]: 'audio-separate',
|
|
1194
1746
|
[ScenarioType.VOICE_CREATE]: 'voice-create',
|
|
1195
1747
|
[ScenarioType.MUSIC_GENERATE]: 'music-generate',
|
|
1748
|
+
[ScenarioType.MUSIC_TRANSCRIBE]: 'music-transcribe',
|
|
1749
|
+
[ScenarioType.AUDIO_VOICE_CONVERT]: 'audio-voice-convert',
|
|
1196
1750
|
[ScenarioType.WORLD_GENERATE]: 'world-generate',
|
|
1197
1751
|
};
|
|
1198
1752
|
return types[value] ?? localAppProjectionError('scenario Runtime type');
|
|
@@ -1272,8 +1826,13 @@ function localVoiceCreationSource(source) {
|
|
|
1272
1826
|
return 'text-description';
|
|
1273
1827
|
return localAppProjectionError('voice asset creationSource');
|
|
1274
1828
|
}
|
|
1275
|
-
const LOCAL_SCENARIO_TYPES = ['image-generate', 'image-face-swap', 'video-face-swap', 'vision-locate', 'video-generate', 'speech-synthesize', 'speech-transcribe', 'text-annotate', 'audio-separate', 'voice-create', 'music-generate', 'world-generate'];
|
|
1829
|
+
const LOCAL_SCENARIO_TYPES = ['image-generate', 'image-face-swap', 'video-face-swap', 'vision-locate', 'video-generate', 'speech-synthesize', 'speech-transcribe', 'text-annotate', 'audio-speaker-embed', 'audio-separate', 'voice-create', 'music-generate', 'music-transcribe', 'audio-voice-convert', 'world-generate'];
|
|
1276
1830
|
const LOCAL_JOB_STATUSES = ['submitted', 'queued', 'running', 'completed', 'failed', 'canceled', 'timeout'];
|
|
1831
|
+
export function validateNimiLocalAppSpeakerEmbedSpec(value) {
|
|
1832
|
+
if (asRecord(value)?.type !== 'audio-speaker-embed')
|
|
1833
|
+
adapterInputError('speaker representation spec is required');
|
|
1834
|
+
return validateScenarioSpec(value, false);
|
|
1835
|
+
}
|
|
1277
1836
|
function localJobSpecFromRuntimeRequest(request) {
|
|
1278
1837
|
assertExactKeys(request, ['head', 'scenarioType', 'executionMode', 'spec', 'requestId', 'idempotencyKey', 'labels', 'extensions'], 'Runtime Scenario Job adapter request');
|
|
1279
1838
|
if (request.executionMode !== ExecutionMode.ASYNC_JOB || request.extensions.length > 0)
|
|
@@ -1282,6 +1841,30 @@ function localJobSpecFromRuntimeRequest(request) {
|
|
|
1282
1841
|
if (!spec || spec.oneofKind === undefined)
|
|
1283
1842
|
adapterInputError('missing Scenario spec');
|
|
1284
1843
|
switch (spec.oneofKind) {
|
|
1844
|
+
case 'audioSpeakerEmbed': {
|
|
1845
|
+
requireScenarioType(request, ScenarioType.AUDIO_SPEAKER_EMBED);
|
|
1846
|
+
assertExactKeys(spec.audioSpeakerEmbed, ['mimeType', 'audioSource', 'sourceAudio'], 'Runtime speaker representation spec');
|
|
1847
|
+
const inline = spec.audioSpeakerEmbed.audioSource?.source;
|
|
1848
|
+
const owned = spec.audioSpeakerEmbed.sourceAudio;
|
|
1849
|
+
if ((spec.audioSpeakerEmbed.audioSource !== undefined) === (owned !== undefined))
|
|
1850
|
+
adapterInputError('Local App speaker representation requires exactly one source');
|
|
1851
|
+
if (spec.audioSpeakerEmbed.audioSource !== undefined && (!inline || (inline.oneofKind !== 'audioBytes' && inline.oneofKind !== 'audioUri')))
|
|
1852
|
+
adapterInputError('Local App speaker representation requires bytes or URI audio');
|
|
1853
|
+
if (inline) {
|
|
1854
|
+
assertExactKeys(spec.audioSpeakerEmbed.audioSource, ['source'], 'Runtime speaker audio source');
|
|
1855
|
+
assertExactKeys(inline, ['oneofKind', inline.oneofKind], 'Runtime speaker audio content');
|
|
1856
|
+
}
|
|
1857
|
+
if (owned) {
|
|
1858
|
+
assertExactKeys(owned, ['artifactId', 'range'], 'Runtime speaker owned audio');
|
|
1859
|
+
if (owned.range)
|
|
1860
|
+
assertExactKeys(owned.range, ['startFrame', 'endFrame'], 'Runtime speaker frame range');
|
|
1861
|
+
}
|
|
1862
|
+
return validateNimiLocalAppSpeakerEmbedSpec({ type: 'audio-speaker-embed', mimeType: spec.audioSpeakerEmbed.mimeType,
|
|
1863
|
+
...(inline?.oneofKind === 'audioBytes' ? { audioSource: { type: 'bytes', bytes: inline.audioBytes } }
|
|
1864
|
+
: inline?.oneofKind === 'audioUri' ? { audioSource: { type: 'uri', uri: inline.audioUri } } : {}),
|
|
1865
|
+
...(owned ? { sourceAudio: { artifactId: owned.artifactId, ...(owned.range ? { range: { startFrame: safeOptionalInt64(owned.range.startFrame, 'speaker source start frame'), endFrame: safeOptionalInt64(owned.range.endFrame, 'speaker source end frame') } } : {}) } } : {}),
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1285
1868
|
case 'videoFaceSwap':
|
|
1286
1869
|
requireScenarioType(request, ScenarioType.VIDEO_FACE_SWAP);
|
|
1287
1870
|
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);
|
|
@@ -1325,11 +1908,18 @@ function localJobSpecFromRuntimeRequest(request) {
|
|
|
1325
1908
|
return validateScenarioSpec({ type: 'text-annotate', language: spec.textAnnotate.language, texts: [...spec.textAnnotate.texts] }, false);
|
|
1326
1909
|
case 'audioSeparate': {
|
|
1327
1910
|
requireScenarioType(request, ScenarioType.AUDIO_SEPARATE);
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1911
|
+
const inline = spec.audioSeparate.audioSource?.source;
|
|
1912
|
+
const owned = spec.audioSeparate.sourceAudio;
|
|
1913
|
+
if ((inline !== undefined) === (owned !== undefined))
|
|
1914
|
+
adapterInputError('Local App separation requires exactly one source');
|
|
1915
|
+
if (inline && (inline.oneofKind === undefined || inline.oneofKind === 'audioChunks'))
|
|
1330
1916
|
adapterInputError('Local App separation requires bytes or URI audio');
|
|
1331
|
-
return validateScenarioSpec({ type: 'audio-separate', mimeType: spec.audioSeparate.mimeType,
|
|
1332
|
-
|
|
1917
|
+
return validateScenarioSpec({ type: 'audio-separate', mimeType: spec.audioSeparate.mimeType,
|
|
1918
|
+
...(inline ? { audioSource: inline.oneofKind === 'audioBytes'
|
|
1919
|
+
? { type: 'bytes', bytes: exactNimiLocalAppBytes(inline.audioBytes) } : { type: 'uri', uri: inline.audioUri } } : {}),
|
|
1920
|
+
...(owned ? { sourceAudio: { artifactId: owned.artifactId,
|
|
1921
|
+
...(owned.range ? { range: { startFrame: Number(owned.range.startFrame), endFrame: Number(owned.range.endFrame) } } : {}) } } : {}),
|
|
1922
|
+
...(spec.audioSeparate.includeInstrumentParts ? { includeInstrumentParts: true } : {}) }, false);
|
|
1333
1923
|
}
|
|
1334
1924
|
case 'voiceCreate': {
|
|
1335
1925
|
requireScenarioType(request, ScenarioType.VOICE_CREATE);
|
|
@@ -1359,20 +1949,32 @@ function localJobSpecFromRuntimeRequest(request) {
|
|
|
1359
1949
|
}
|
|
1360
1950
|
return adapterInputError('voice create source is invalid');
|
|
1361
1951
|
}
|
|
1952
|
+
case 'musicTranscribe':
|
|
1953
|
+
requireScenarioType(request, ScenarioType.MUSIC_TRANSCRIBE);
|
|
1954
|
+
return localMusicTranscribeSpec(spec.musicTranscribe);
|
|
1955
|
+
case 'audioVoiceConvert':
|
|
1956
|
+
requireScenarioType(request, ScenarioType.AUDIO_VOICE_CONVERT);
|
|
1957
|
+
return localVoiceConvertSpec(spec.audioVoiceConvert);
|
|
1362
1958
|
case 'musicGenerate':
|
|
1363
1959
|
requireScenarioType(request, ScenarioType.MUSIC_GENERATE);
|
|
1364
|
-
|
|
1365
|
-
|| spec.musicGenerate.instrumental) {
|
|
1366
|
-
return adapterInputError('unsupported MiniMax-Music3 fields are unavailable to Local Apps');
|
|
1367
|
-
}
|
|
1368
|
-
return validateScenarioSpec({ type: 'music-generate', prompt: spec.musicGenerate.prompt, lyrics: spec.musicGenerate.lyrics,
|
|
1369
|
-
...(spec.musicGenerate.durationSeconds !== 0 ? { durationSeconds: spec.musicGenerate.durationSeconds } : {}) }, false);
|
|
1960
|
+
return localMusicGenerateSpec(spec.musicGenerate);
|
|
1370
1961
|
case 'worldGenerate':
|
|
1371
1962
|
requireScenarioType(request, ScenarioType.WORLD_GENERATE);
|
|
1372
|
-
if (spec.worldGenerate.
|
|
1373
|
-
return adapterInputError('Local App worlds accept
|
|
1963
|
+
if (spec.worldGenerate.tags.length > 0 || spec.worldGenerate.seed !== '0')
|
|
1964
|
+
return adapterInputError('Local App worlds do not accept tags or seed');
|
|
1965
|
+
{
|
|
1966
|
+
const conditioning = spec.worldGenerate.conditioning;
|
|
1967
|
+
let image;
|
|
1968
|
+
if (conditioning.oneofKind !== undefined) {
|
|
1969
|
+
if (conditioning.oneofKind !== 'imagePrompt' || conditioning.imagePrompt.content?.source.oneofKind !== 'artifactId')
|
|
1970
|
+
return adapterInputError('Local App worlds require an owned image');
|
|
1971
|
+
const projection = conditioning.imagePrompt.projection;
|
|
1972
|
+
if (projection !== WorldImageProjection.ORDINARY && projection !== WorldImageProjection.EQUIRECTANGULAR_360)
|
|
1973
|
+
return adapterInputError('World projection is required');
|
|
1974
|
+
image = { artifactId: conditioning.imagePrompt.content.source.artifactId, projection: projection === WorldImageProjection.ORDINARY ? 'ordinary' : 'equirectangular-360' };
|
|
1975
|
+
}
|
|
1976
|
+
return validateScenarioSpec({ type: 'world-generate', prompt: spec.worldGenerate.textPrompt, displayName: spec.worldGenerate.displayName, ...(image ? { image } : {}) }, false);
|
|
1374
1977
|
}
|
|
1375
|
-
return validateScenarioSpec({ type: 'world-generate', prompt: spec.worldGenerate.textPrompt, displayName: spec.worldGenerate.displayName }, false);
|
|
1376
1978
|
default:
|
|
1377
1979
|
return adapterInputError(`Scenario type ${spec.oneofKind} is unavailable to Local Apps`);
|
|
1378
1980
|
}
|
|
@@ -1428,6 +2030,8 @@ function runtimeSpeechSynthesizeSpec(spec) {
|
|
|
1428
2030
|
...(spec.volume !== undefined ? { volume: spec.volume } : {}),
|
|
1429
2031
|
emotion: spec.emotion, voiceRef, timingMode: speechTimingName(spec.timingMode),
|
|
1430
2032
|
voiceRenderHints: spec.voiceRenderHints ? { ...spec.voiceRenderHints } : null,
|
|
2033
|
+
...(spec.identityAudio ? { identityAudio: { ...spec.identityAudio } } : {}),
|
|
2034
|
+
...(spec.performanceAudio ? { performanceAudio: { ...spec.performanceAudio } } : {}),
|
|
1431
2035
|
};
|
|
1432
2036
|
}
|
|
1433
2037
|
function runtimeSpeechTranscribeSpec(spec) {
|
|
@@ -1441,14 +2045,14 @@ function runtimeSpeechTranscribeSpec(spec) {
|
|
|
1441
2045
|
...(spec.speakerCount !== undefined ? { speakerCount: spec.speakerCount } : {}),
|
|
1442
2046
|
prompt: spec.prompt, responseFormat: spec.responseFormat,
|
|
1443
2047
|
audioSource: source.oneofKind === 'audioBytes'
|
|
1444
|
-
? { type: 'bytes', bytes:
|
|
2048
|
+
? { type: 'bytes', bytes: exactNimiLocalAppBytes(source.audioBytes) }
|
|
1445
2049
|
: { type: 'uri', uri: source.audioUri },
|
|
1446
2050
|
};
|
|
1447
2051
|
}
|
|
1448
2052
|
function runtimeVoiceAudio(bytes, uri) {
|
|
1449
2053
|
if (bytes.length > 0 === Boolean(uri))
|
|
1450
2054
|
adapterInputError('voice reference audio must select exactly one source');
|
|
1451
|
-
return bytes.length > 0 ? { type: 'bytes', bytes:
|
|
2055
|
+
return bytes.length > 0 ? { type: 'bytes', bytes: exactNimiLocalAppBytes(bytes) } : { type: 'uri', uri };
|
|
1452
2056
|
}
|
|
1453
2057
|
function runtimeJobFromLocal(job) {
|
|
1454
2058
|
return {
|
|
@@ -1456,14 +2060,21 @@ function runtimeJobFromLocal(job) {
|
|
|
1456
2060
|
...(job.interruption ? { interruption: runtimeInterruptionFromLocal(job.interruption) } : {}),
|
|
1457
2061
|
jobId: job.jobId, head: undefined, scenarioType: runtimeScenarioType(job.scenarioType), executionMode: ExecutionMode.ASYNC_JOB,
|
|
1458
2062
|
routeDecision: RoutePolicy.UNSPECIFIED, modelResolved: '', status: runtimeJobStatus(job.status), providerJobId: '',
|
|
2063
|
+
submissionOutcome: SUBMISSION_OUTCOMES.indexOf(job.submissionOutcome),
|
|
2064
|
+
stopOutcome: STOP_OUTCOMES.indexOf(job.stopOutcome),
|
|
1459
2065
|
reasonCode: runtimeReasonCode(job.reasonCode), reasonDetail: job.reasonDetail, retryCount: 0,
|
|
1460
2066
|
createdAt: runtimeTimestamp(job.createdAt), updatedAt: runtimeTimestamp(job.updatedAt), nextPollAt: undefined,
|
|
2067
|
+
recoveryExpiresAt: runtimeTimestamp(job.recoveryExpiresAt ?? null),
|
|
1461
2068
|
artifacts: job.artifacts.map((artifact) => runtimeArtifactFromLocal(artifact)), usage: undefined, traceId: job.traceId,
|
|
1462
2069
|
ignoredExtensions: [], reasonMetadata: undefined, progressPercent: job.progressPercent,
|
|
1463
2070
|
progressCurrentStep: job.progressCurrentStep, progressTotalSteps: job.progressTotalSteps,
|
|
1464
2071
|
transcriptionText: job.transcriptionText,
|
|
1465
2072
|
transcription: runtimeTranscriptionFromLocal(job.transcription),
|
|
1466
|
-
audioSeparation: job.audioSeparation,
|
|
2073
|
+
audioSeparation: runtimeAudioSeparation(job.audioSeparation),
|
|
2074
|
+
speakerEmbedding: job.speakerEmbedding ? { vector: { values: [...job.speakerEmbedding.vector] }, spaceId: job.speakerEmbedding.spaceId } : undefined,
|
|
2075
|
+
musicGeneration: runtimeMusicGeneration(job.musicGeneration),
|
|
2076
|
+
musicTranscription: runtimeMusicTranscription(job.musicTranscription),
|
|
2077
|
+
voiceConversion: runtimeVoiceConversion(job.voiceConversion),
|
|
1467
2078
|
textAnnotation: runtimeAnnotationFromLocal(job.textAnnotation),
|
|
1468
2079
|
};
|
|
1469
2080
|
}
|
|
@@ -1477,17 +2088,20 @@ function runtimeVoiceAssetFromLocal(asset) {
|
|
|
1477
2088
|
creationSource: runtimeVoiceCreationSource(asset.creationSource),
|
|
1478
2089
|
};
|
|
1479
2090
|
}
|
|
1480
|
-
function runtimeArtifactFromLocal(artifact, bytes =
|
|
1481
|
-
return { artifactId: artifact.artifactId, mimeType, bytes, uri: '', sha256: artifact.sha256, sizeBytes: String(sizeBytes), durationMs: String(artifact.durationMs), fps: 0, width: artifact.width, height: artifact.height, sampleRateHz: artifact.sampleRateHz, channels: artifact.channels,
|
|
2091
|
+
function runtimeArtifactFromLocal(artifact, bytes = artifact.bytes, mimeType = artifact.mimeType, sizeBytes = artifact.sizeBytes) {
|
|
2092
|
+
return { artifactId: artifact.artifactId, mimeType, bytes, uri: '', sha256: artifact.sha256, sizeBytes: String(sizeBytes), durationMs: String(artifact.durationMs), fps: 0, width: artifact.width, height: artifact.height, sampleRateHz: artifact.sampleRateHz, channels: artifact.channels, frameCount: String(artifact.frameCount ?? 0), speechAlignment: artifact.speechAlignment ? {
|
|
2093
|
+
unit: artifact.speechAlignment.unit === 'word' ? 1 : 2,
|
|
2094
|
+
tokens: artifact.speechAlignment.tokens.map(token => ({ token: token.token, startMs: String(token.startMs), endMs: String(token.endMs) })),
|
|
2095
|
+
} : undefined, metadata: undefined, seed: artifact.seed };
|
|
1482
2096
|
}
|
|
1483
2097
|
function runtimeJobEventFromLocal(event) {
|
|
1484
2098
|
return { eventType: runtimeJobEventType(event.eventType), sequence: event.sequence, traceId: event.traceId, timestamp: runtimeTimestamp(event.timestamp), job: runtimeJobFromLocal(event.job) };
|
|
1485
2099
|
}
|
|
1486
2100
|
function runtimeArtifactResponse(job, artifacts) {
|
|
1487
|
-
const output = runtimeOutput(job.scenarioType, artifacts, job.transcriptionText, job.videoFaceSwapSummary, job.transcription, job.audioSeparation, job.textAnnotation);
|
|
2101
|
+
const output = runtimeOutput(job.scenarioType, artifacts, job.transcriptionText, job.videoFaceSwapSummary, job.transcription, job.audioSeparation, job.textAnnotation, job.musicGeneration, job.musicTranscription, job.voiceConversion, job.speakerEmbedding);
|
|
1488
2102
|
return { jobId: job.jobId, artifacts, traceId: job.traceId, output };
|
|
1489
2103
|
}
|
|
1490
|
-
function runtimeOutput(type, artifacts, transcriptionText, videoFaceSwapSummary, transcription, audioSeparation, textAnnotation) {
|
|
2104
|
+
function runtimeOutput(type, artifacts, transcriptionText, videoFaceSwapSummary, transcription, audioSeparation, textAnnotation, musicGeneration, musicTranscription, voiceConversion, speakerEmbedding) {
|
|
1491
2105
|
switch (type) {
|
|
1492
2106
|
case 'video-face-swap': return videoFaceSwapSummary ? { output: { oneofKind: 'videoFaceSwap', videoFaceSwap: { artifacts, summary: { ...videoFaceSwapSummary, durationUs: String(videoFaceSwapSummary.durationUs) } } } } : undefined;
|
|
1493
2107
|
case 'image-face-swap': return { output: { oneofKind: 'imageFaceSwap', imageFaceSwap: { artifacts } } };
|
|
@@ -1500,13 +2114,16 @@ function runtimeOutput(type, artifacts, transcriptionText, videoFaceSwapSummary,
|
|
|
1500
2114
|
return { output: { oneofKind: 'speechTranscribe', speechTranscribe: { text: transcriptionText, artifacts, transcription: runtimeTranscriptionFromLocal(transcription) } } };
|
|
1501
2115
|
}
|
|
1502
2116
|
case 'text-annotate': return { output: { oneofKind: 'textAnnotation', textAnnotation: runtimeAnnotationFromLocal(textAnnotation) } };
|
|
1503
|
-
case 'audio-
|
|
1504
|
-
case '
|
|
2117
|
+
case 'audio-speaker-embed': return speakerEmbedding ? { output: { oneofKind: 'audioSpeakerEmbed', audioSpeakerEmbed: { vector: { values: [...speakerEmbedding.vector] }, spaceId: speakerEmbedding.spaceId } } } : undefined;
|
|
2118
|
+
case 'audio-separate': return { output: { oneofKind: 'audioSeparate', audioSeparate: { artifacts, separation: runtimeAudioSeparation(audioSeparation) } } };
|
|
2119
|
+
case 'music-transcribe': return { output: { oneofKind: 'musicTranscribe', musicTranscribe: { artifacts, transcription: runtimeMusicTranscription(musicTranscription) } } };
|
|
2120
|
+
case 'audio-voice-convert': return { output: { oneofKind: 'audioVoiceConvert', audioVoiceConvert: { artifacts, conversion: runtimeVoiceConversion(voiceConversion) } } };
|
|
2121
|
+
case 'music-generate': return { output: { oneofKind: 'musicGenerate', musicGenerate: { artifacts, generation: runtimeMusicGeneration(musicGeneration) } } };
|
|
1505
2122
|
default: return undefined;
|
|
1506
2123
|
}
|
|
1507
2124
|
}
|
|
1508
2125
|
function runtimeScenarioType(type) {
|
|
1509
|
-
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, 'text-annotate': ScenarioType.TEXT_ANNOTATE, 'audio-separate': ScenarioType.AUDIO_SEPARATE, 'voice-create': ScenarioType.VOICE_CREATE, 'music-generate': ScenarioType.MUSIC_GENERATE, 'world-generate': ScenarioType.WORLD_GENERATE })[type];
|
|
2126
|
+
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, 'text-annotate': ScenarioType.TEXT_ANNOTATE, 'audio-speaker-embed': ScenarioType.AUDIO_SPEAKER_EMBED, 'audio-separate': ScenarioType.AUDIO_SEPARATE, 'voice-create': ScenarioType.VOICE_CREATE, 'music-generate': ScenarioType.MUSIC_GENERATE, 'music-transcribe': ScenarioType.MUSIC_TRANSCRIBE, 'audio-voice-convert': ScenarioType.AUDIO_VOICE_CONVERT, 'world-generate': ScenarioType.WORLD_GENERATE })[type];
|
|
1510
2127
|
}
|
|
1511
2128
|
function runtimeJobStatus(status) {
|
|
1512
2129
|
return ({ submitted: ScenarioJobStatus.SUBMITTED, queued: ScenarioJobStatus.QUEUED, running: ScenarioJobStatus.RUNNING, completed: ScenarioJobStatus.COMPLETED, failed: ScenarioJobStatus.FAILED, canceled: ScenarioJobStatus.CANCELED, timeout: ScenarioJobStatus.TIMEOUT })[status];
|
|
@@ -1645,17 +2262,15 @@ function optionalBoundedInteger(value, field, minimum, maximum) {
|
|
|
1645
2262
|
function optionalBoundedNumber(value, field, minimum, maximum) {
|
|
1646
2263
|
return value === undefined ? undefined : boundedNumber(value, field, minimum, maximum);
|
|
1647
2264
|
}
|
|
1648
|
-
function
|
|
1649
|
-
if (!
|
|
1650
|
-
|| value.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255))
|
|
2265
|
+
function validateInputBytes(value, field, maximum, allowEmpty) {
|
|
2266
|
+
if (!isNimiLocalAppByteView(value) || (!allowEmpty && value.byteLength === 0) || value.byteLength > maximum)
|
|
1651
2267
|
invalidAIInput(`${field} is invalid`);
|
|
1652
2268
|
return value;
|
|
1653
2269
|
}
|
|
1654
2270
|
function validateProjectionBytes(value, field) {
|
|
1655
|
-
if (!
|
|
1656
|
-
|| value.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255))
|
|
2271
|
+
if (!isNimiLocalAppByteView(value) || value.byteLength > MAX_ARTIFACT_BYTES)
|
|
1657
2272
|
localAppProjectionError(field);
|
|
1658
|
-
return
|
|
2273
|
+
return exactNimiLocalAppBytes(value);
|
|
1659
2274
|
}
|
|
1660
2275
|
function projectionInteger(value, field, minimum, maximum) {
|
|
1661
2276
|
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < minimum || value > maximum)
|
|
@@ -1707,10 +2322,12 @@ function adapterInputError(reason) {
|
|
|
1707
2322
|
}
|
|
1708
2323
|
function localTranscriptionFromRuntime(value) {
|
|
1709
2324
|
const status = value.status === SpeechTranscriptStatus.TRANSCRIBED ? 'transcribed' : value.status === SpeechTranscriptStatus.NO_SPEECH ? 'no-speech' : '';
|
|
1710
|
-
return validateNimiLocalAppSpeechTranscript({ status, text: value.text, language: value.language, words: value.words.map((word) => ({ ...word }))
|
|
2325
|
+
return validateNimiLocalAppSpeechTranscript({ status, text: value.text, language: value.language, words: value.words.map((word) => ({ ...word })),
|
|
2326
|
+
...(value.diarization ? { diarization: { status: value.diarization.status === SpeechDiarizationStatus.DIARIZED ? 'diarized' : value.diarization.status === SpeechDiarizationStatus.NO_SPEAKERS ? 'no-speakers' : '', durationSeconds: value.diarization.durationSeconds, intervals: value.diarization.intervals.map((interval) => ({ ...interval })) } } : {}) });
|
|
1711
2327
|
}
|
|
1712
2328
|
function runtimeTranscriptionFromLocal(value) {
|
|
1713
|
-
return value ? { status: value.status === 'transcribed' ? SpeechTranscriptStatus.TRANSCRIBED : SpeechTranscriptStatus.NO_SPEECH, text: value.text, language: value.language, words: value.words.map((word) => ({ ...word }))
|
|
2329
|
+
return value ? { status: value.status === 'transcribed' ? SpeechTranscriptStatus.TRANSCRIBED : SpeechTranscriptStatus.NO_SPEECH, text: value.text, language: value.language, words: value.words.map((word) => ({ ...word })),
|
|
2330
|
+
...(value.diarization ? { diarization: { status: value.diarization.status === 'diarized' ? SpeechDiarizationStatus.DIARIZED : SpeechDiarizationStatus.NO_SPEAKERS, durationSeconds: value.diarization.durationSeconds, intervals: value.diarization.intervals.map((interval) => ({ ...interval })) } } : {}) } : undefined;
|
|
1714
2331
|
}
|
|
1715
2332
|
function runtimeAnnotationFromLocal(value) {
|
|
1716
2333
|
return value ? { documents: value.documents.map((doc) => ({ text: doc.text, language: doc.language,
|