@nativestudio/sdk 0.0.0-stage → 0.3.0-rc.2
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/COMPATIBILITY.json +14 -0
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/dist/BUNDLED_DEPENDENCIES.json +1 -0
- package/dist/_chunks/chunk-34KSWLCI.js +1 -0
- package/dist/_chunks/chunk-4IOFVNFG.js +1 -0
- package/dist/_chunks/chunk-4M3AGNTZ.js +1 -0
- package/dist/_chunks/chunk-6NVIN2NI.js +1 -0
- package/dist/_chunks/chunk-7YCEMDNZ.js +1 -0
- package/dist/_chunks/chunk-RK3YLCZP.js +1 -0
- package/dist/_types/contracts/accepted-shot.d.ts +27 -0
- package/dist/_types/contracts/accepted-visual-source.d.ts +120 -0
- package/dist/_types/contracts/agent-execution-lifecycle.d.ts +749 -0
- package/dist/_types/contracts/agent-execution-oauth.d.ts +71 -0
- package/dist/_types/contracts/agent-execution-registration.d.ts +240 -0
- package/dist/_types/contracts/agent-execution-selection.d.ts +107 -0
- package/dist/_types/contracts/agent-host-execution.d.ts +706 -0
- package/dist/_types/contracts/agent-host-generic-transport.d.ts +12 -0
- package/dist/_types/contracts/agent-host.d.ts +226 -0
- package/dist/_types/contracts/artifact-discovery.d.ts +170 -0
- package/dist/_types/contracts/artifact.d.ts +188 -0
- package/dist/_types/contracts/audio.d.ts +331 -0
- package/dist/_types/contracts/brief.d.ts +178 -0
- package/dist/_types/contracts/caption-render.d.ts +20 -0
- package/dist/_types/contracts/caption-transcript.d.ts +102 -0
- package/dist/_types/contracts/captions.d.ts +420 -0
- package/dist/_types/contracts/clip-framing.d.ts +14 -0
- package/dist/_types/contracts/clip-transition.d.ts +6 -0
- package/dist/_types/contracts/composition-authoring-guide.d.ts +160 -0
- package/dist/_types/contracts/composition-authoring.d.ts +744 -0
- package/dist/_types/contracts/composition-finding-locality.d.ts +24 -0
- package/dist/_types/contracts/composition-frame-render.d.ts +226 -0
- package/dist/_types/contracts/composition-making.d.ts +390 -0
- package/dist/_types/contracts/composition-observation.d.ts +239 -0
- package/dist/_types/contracts/composition-render-base.d.ts +292 -0
- package/dist/_types/contracts/composition-render-observation.d.ts +278 -0
- package/dist/_types/contracts/composition-render.d.ts +406 -0
- package/dist/_types/contracts/composition-repair.d.ts +451 -0
- package/dist/_types/contracts/composition-source-review.d.ts +1042 -0
- package/dist/_types/contracts/consistency-profile.d.ts +845 -0
- package/dist/_types/contracts/continuity-evaluation.d.ts +48 -0
- package/dist/_types/contracts/delivery-completion.d.ts +210 -0
- package/dist/_types/contracts/delivery-manifest.d.ts +11776 -0
- package/dist/_types/contracts/delivery-operations.d.ts +5009 -0
- package/dist/_types/contracts/delivery-output-profile.d.ts +12 -0
- package/dist/_types/contracts/delivery-summary.d.ts +220 -0
- package/dist/_types/contracts/delivery-validation.d.ts +183 -0
- package/dist/_types/contracts/director-proposal.d.ts +1067 -0
- package/dist/_types/contracts/editor-intelligence.d.ts +5751 -0
- package/dist/_types/contracts/exploration-recommendation.d.ts +11863 -0
- package/dist/_types/contracts/external-agent-access.d.ts +95 -0
- package/dist/_types/contracts/final-ready.d.ts +301 -0
- package/dist/_types/contracts/final-render-profile.d.ts +59 -0
- package/dist/_types/contracts/final-render.d.ts +8181 -0
- package/dist/_types/contracts/foundation.d.ts +1 -0
- package/dist/_types/contracts/generation-contract.d.ts +268 -0
- package/dist/_types/contracts/generation-cost.d.ts +70 -0
- package/dist/_types/contracts/health.d.ts +6 -0
- package/dist/_types/contracts/human-identity.d.ts +149 -0
- package/dist/_types/contracts/hyperframe-profile.d.ts +5 -0
- package/dist/_types/contracts/ids.d.ts +41 -0
- package/dist/_types/contracts/index.d.ts +122 -0
- package/dist/_types/contracts/interface/common.d.ts +56 -0
- package/dist/_types/contracts/interface/execution-output.d.ts +99 -0
- package/dist/_types/contracts/interface/index.d.ts +7 -0
- package/dist/_types/contracts/interface/media-output.d.ts +62 -0
- package/dist/_types/contracts/interface/operation.d.ts +61 -0
- package/dist/_types/contracts/interface/output.d.ts +15 -0
- package/dist/_types/contracts/interface/production-snapshot.d.ts +832 -0
- package/dist/_types/contracts/interface/query.d.ts +315 -0
- package/dist/_types/contracts/keyframe-generation.d.ts +349 -0
- package/dist/_types/contracts/keyframe-reference.d.ts +31 -0
- package/dist/_types/contracts/keyframe-review.d.ts +753 -0
- package/dist/_types/contracts/lifecycle-event-projections.d.ts +191 -0
- package/dist/_types/contracts/lifecycle-events.d.ts +156 -0
- package/dist/_types/contracts/listening-evidence.d.ts +37 -0
- package/dist/_types/contracts/local-execution/agent-review.d.ts +560 -0
- package/dist/_types/contracts/local-execution/canonical.d.ts +2 -0
- package/dist/_types/contracts/local-execution/common.d.ts +48 -0
- package/dist/_types/contracts/local-execution/completion.d.ts +128 -0
- package/dist/_types/contracts/local-execution/device.d.ts +134 -0
- package/dist/_types/contracts/local-execution/index.d.ts +11 -0
- package/dist/_types/contracts/local-execution/ipc.d.ts +1202 -0
- package/dist/_types/contracts/local-execution/lifecycle.d.ts +347 -0
- package/dist/_types/contracts/local-execution/local-navigation.d.ts +710 -0
- package/dist/_types/contracts/local-execution/preview.d.ts +3663 -0
- package/dist/_types/contracts/local-execution/tool-selection.d.ts +15 -0
- package/dist/_types/contracts/local-execution/work.d.ts +3441 -0
- package/dist/_types/contracts/matrix-parameter-rule.d.ts +23 -0
- package/dist/_types/contracts/media-export.d.ts +23 -0
- package/dist/_types/contracts/media-observation.d.ts +1159 -0
- package/dist/_types/contracts/model-capability-matrix.d.ts +118 -0
- package/dist/_types/contracts/native-tool-authority-failure.d.ts +38 -0
- package/dist/_types/contracts/native-tool-authority.d.ts +110 -0
- package/dist/_types/contracts/native-tool-execution.d.ts +287 -0
- package/dist/_types/contracts/native-tool-gateway.d.ts +41 -0
- package/dist/_types/contracts/native-video-audio.d.ts +62 -0
- package/dist/_types/contracts/navigation-context.d.ts +253 -0
- package/dist/_types/contracts/navigation-groups.d.ts +51 -0
- package/dist/_types/contracts/navigation.d.ts +238 -0
- package/dist/_types/contracts/observation-profile.d.ts +99 -0
- package/dist/_types/contracts/planning-input.d.ts +177 -0
- package/dist/_types/contracts/principal.d.ts +26 -0
- package/dist/_types/contracts/production-creation.d.ts +66 -0
- package/dist/_types/contracts/production-termination.d.ts +51 -0
- package/dist/_types/contracts/production.d.ts +111 -0
- package/dist/_types/contracts/programmatic-composition.d.ts +762 -0
- package/dist/_types/contracts/programmatic-exploration.d.ts +7459 -0
- package/dist/_types/contracts/programmatic-video-review.d.ts +894 -0
- package/dist/_types/contracts/project-library.d.ts +173 -0
- package/dist/_types/contracts/project.d.ts +93 -0
- package/dist/_types/contracts/provider-catalog.d.ts +421 -0
- package/dist/_types/contracts/provider-models.d.ts +3380 -0
- package/dist/_types/contracts/provider.d.ts +142 -0
- package/dist/_types/contracts/reference-preview.d.ts +36 -0
- package/dist/_types/contracts/repair-lifecycle.d.ts +2896 -0
- package/dist/_types/contracts/repair-plan.d.ts +728 -0
- package/dist/_types/contracts/repair-strategy.d.ts +5751 -0
- package/dist/_types/contracts/review-intelligence-evidence.d.ts +136 -0
- package/dist/_types/contracts/review-intelligence-final-output.d.ts +8705 -0
- package/dist/_types/contracts/review-intelligence.d.ts +11543 -0
- package/dist/_types/contracts/review1-repair-source.d.ts +452 -0
- package/dist/_types/contracts/review1-repair-strategy.d.ts +491 -0
- package/dist/_types/contracts/review1-repair.d.ts +36 -0
- package/dist/_types/contracts/rough-cut-manifest.d.ts +347 -0
- package/dist/_types/contracts/rough-cut-profile.d.ts +37 -0
- package/dist/_types/contracts/rough-cut-review.d.ts +12819 -0
- package/dist/_types/contracts/rough-cut.d.ts +5862 -0
- package/dist/_types/contracts/scene-shot-plan.d.ts +882 -0
- package/dist/_types/contracts/sdk-discovery.d.ts +66 -0
- package/dist/_types/contracts/shot-direction.d.ts +113 -0
- package/dist/_types/contracts/shot-preparation-basis.d.ts +356 -0
- package/dist/_types/contracts/shot-preparation.d.ts +2285 -0
- package/dist/_types/contracts/shot-sound-instruction.d.ts +58 -0
- package/dist/_types/contracts/sound-making-plan.d.ts +1585 -0
- package/dist/_types/contracts/source-sound-policy.d.ts +10 -0
- package/dist/_types/contracts/source-workspace.d.ts +62 -0
- package/dist/_types/contracts/speech.d.ts +424 -0
- package/dist/_types/contracts/story.d.ts +98 -0
- package/dist/_types/contracts/temporal-evidence-operation.d.ts +379 -0
- package/dist/_types/contracts/temporal-evidence-reference.d.ts +18 -0
- package/dist/_types/contracts/temporal-evidence.d.ts +248 -0
- package/dist/_types/contracts/tenant.d.ts +7 -0
- package/dist/_types/contracts/timeline-audio.d.ts +97 -0
- package/dist/_types/contracts/timeline-graphics.d.ts +80 -0
- package/dist/_types/contracts/timeline-manifest.d.ts +702 -0
- package/dist/_types/contracts/timeline-source-sound.d.ts +352 -0
- package/dist/_types/contracts/timeline-v2.d.ts +1263 -0
- package/dist/_types/contracts/timeline-version-reader.d.ts +2945 -0
- package/dist/_types/contracts/timeline-visual-layers.d.ts +1245 -0
- package/dist/_types/contracts/timeline.d.ts +4942 -0
- package/dist/_types/contracts/transcription.d.ts +80 -0
- package/dist/_types/contracts/video-generation.d.ts +643 -0
- package/dist/_types/contracts/video-review.d.ts +1871 -0
- package/dist/_types/contracts/visual-exploration.d.ts +1586 -0
- package/dist/_types/contracts/visual-layer-render.d.ts +2777 -0
- package/dist/_types/contracts/visual-layer.d.ts +112 -0
- package/dist/_types/contracts/visual-sequence.d.ts +121 -0
- package/dist/_types/contracts/writer-proposal.d.ts +268 -0
- package/dist/_types/sdk/account.d.ts +109 -0
- package/dist/_types/sdk/auxiliary-media.d.ts +43 -0
- package/dist/_types/sdk/catalog/agent-host-execution.d.ts +1551 -0
- package/dist/_types/sdk/catalog/agent-host.d.ts +344 -0
- package/dist/_types/sdk/catalog/assembly.d.ts +37634 -0
- package/dist/_types/sdk/catalog/audio-caption.d.ts +1374 -0
- package/dist/_types/sdk/catalog/canonical-repair.d.ts +4584 -0
- package/dist/_types/sdk/catalog/composition-source.d.ts +1556 -0
- package/dist/_types/sdk/catalog/composition.d.ts +2815 -0
- package/dist/_types/sdk/catalog/core.d.ts +3049 -0
- package/dist/_types/sdk/catalog/delivery.d.ts +14169 -0
- package/dist/_types/sdk/catalog/discovery.d.ts +75 -0
- package/dist/_types/sdk/catalog/editor.d.ts +6540 -0
- package/dist/_types/sdk/catalog/generation.d.ts +942 -0
- package/dist/_types/sdk/catalog/imported-visual.d.ts +3111 -0
- package/dist/_types/sdk/catalog/keyframe-review.d.ts +859 -0
- package/dist/_types/sdk/catalog/lifecycle-events.d.ts +329 -0
- package/dist/_types/sdk/catalog/mcp.d.ts +245 -0
- package/dist/_types/sdk/catalog/media-descriptors.d.ts +139 -0
- package/dist/_types/sdk/catalog/media-observation.d.ts +958 -0
- package/dist/_types/sdk/catalog/native-tool-authority.d.ts +281 -0
- package/dist/_types/sdk/catalog/navigation.d.ts +559 -0
- package/dist/_types/sdk/catalog/planning-intelligence.d.ts +2031 -0
- package/dist/_types/sdk/catalog/programmatic-exploration.d.ts +9855 -0
- package/dist/_types/sdk/catalog/programmatic-review.d.ts +1106 -0
- package/dist/_types/sdk/catalog/provider.d.ts +4439 -0
- package/dist/_types/sdk/catalog/reference-preview.d.ts +180 -0
- package/dist/_types/sdk/catalog/repair-strategy.d.ts +8916 -0
- package/dist/_types/sdk/catalog/reviewer.d.ts +23133 -0
- package/dist/_types/sdk/catalog/shot-preparation.d.ts +2974 -0
- package/dist/_types/sdk/catalog/sound-making-plan.d.ts +1778 -0
- package/dist/_types/sdk/catalog/source-sync.d.ts +1313 -0
- package/dist/_types/sdk/catalog/spec.d.ts +37 -0
- package/dist/_types/sdk/catalog/speech.d.ts +397 -0
- package/dist/_types/sdk/catalog/temporal-evidence.d.ts +391 -0
- package/dist/_types/sdk/catalog/video-review.d.ts +2149 -0
- package/dist/_types/sdk/catalog/visual-exploration.d.ts +10838 -0
- package/dist/_types/sdk/client.d.ts +75 -0
- package/dist/_types/sdk/desktop-catalogue.d.ts +25 -0
- package/dist/_types/sdk/desktop-previews.d.ts +118 -0
- package/dist/_types/sdk/desktop-releases.d.ts +75 -0
- package/dist/_types/sdk/errors.d.ts +9 -0
- package/dist/_types/sdk/evidence-image.d.ts +22 -0
- package/dist/_types/sdk/image-media.d.ts +43 -0
- package/dist/_types/sdk/index.d.ts +16 -0
- package/dist/_types/sdk/local-runtime/device-client.d.ts +77 -0
- package/dist/_types/sdk/local-runtime-client.d.ts +932 -0
- package/dist/_types/sdk/mcp-client.d.ts +55 -0
- package/dist/_types/sdk/mcp-image.d.ts +52 -0
- package/dist/_types/sdk/media.d.ts +104 -0
- package/dist/_types/sdk/navigation-client.d.ts +141 -0
- package/dist/_types/sdk/navigation-facade.d.ts +458 -0
- package/dist/_types/sdk/observe.d.ts +51 -0
- package/dist/_types/sdk/runtime-authority.d.ts +103 -0
- package/dist/_types/sdk/transport/http.d.ts +39 -0
- package/dist/account.d.ts +1 -0
- package/dist/account.js +1 -0
- package/dist/desktop-previews.d.ts +1 -0
- package/dist/desktop-previews.js +1 -0
- package/dist/desktop-releases.d.ts +1 -0
- package/dist/desktop-releases.js +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/local-runtime.d.ts +1 -0
- package/dist/local-runtime.js +1 -0
- package/dist/native/Bootstrap.ps1 +90 -0
- package/dist/native/JobNative.cs +127 -0
- package/dist/native/JobRunner.cs +360 -0
- package/dist/native/NativeMain.cs +146 -0
- package/dist/native/PipeBridge.cs +260 -0
- package/dist/native/PrivateAccess.cs +152 -0
- package/dist/runtime-authority.d.ts +1 -0
- package/dist/runtime-authority.js +1 -0
- package/package.json +50 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./_types/sdk/desktop-releases.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{canonicalDesktopJson,compatibleDesktopRelease,desktopCatalogue,desktopDigest,desktopPublicKey,desktopReleasePolicySchema,desktopReleaseSchema,desktopReleaseUrl,parseDesktopReleasePolicy}from"./_chunks/chunk-RK3YLCZP.js";export{canonicalDesktopJson,compatibleDesktopRelease,desktopCatalogue,desktopDigest,desktopPublicKey,desktopReleasePolicySchema,desktopReleaseSchema,desktopReleaseUrl,parseDesktopReleasePolicy};
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {NativeStudioSdkError} from "./_types/sdk/errors.js";
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{NativeStudioSdkError}from"./_chunks/chunk-6NVIN2NI.js";export{NativeStudioSdkError};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {NativeStudioAgentClient,NativeStudioMcpClient,NativeStudioNavigationClient,NativeStudioNavigationFacade,NativeStudioSdkError,sdkOperations,sdkMcpTools,sdkImageMediaTools,queryPages,waitForOperation,NavigationProfile,NavigationProfileKey,NavigationToolNames,CapabilityDescribeSchema,CapabilityGroupsSchema,NavigationGroups,NavigationGroupIdSchema,navigationGroup} from "./_types/sdk/index.js";
|
|
2
|
+
export type {SdkOperation,SdkInput,SdkOutput,NativeStudioMcpOptions,NavigationCaller,NativeStudioHttpOptions,SdkRequestOptions,SdkBinary,SdkMediaInput,SdkMediaIdentity,SdkImageMediaInput,SdkEvidenceImageInput,SdkAuxiliaryMediaInput,SdkMcpImageInput,NavigationGroupId,PagedOperation} from "./_types/sdk/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AgentHostExecutionEventPageSchema,AgentHostExecutionEventQuerySchema,AgentHostExecutionGetSchema,AgentHostExecutionPageSchema,AgentHostExecutionQuerySchema,AgentHostExecutionViewSchema,ArtifactDiscoveryMediaSchema,ArtifactDiscoveryPageSchema,ArtifactDiscoveryQuerySchema,AudioExportResultSchema,AuthorRepairPlanSchema,AuthorReview1RepairSchema,CapabilityDescribeInputSchema,CapabilityDescribeSchema,CapabilityGroupsInputSchema,CapabilityGroupsSchema,CapabilitySearchInputSchema,CapabilitySearchSchema,CaptionExportResultSchema,CompositionAuthoringBriefSchema,CompositionBriefQuerySchema,CompositionCapabilitiesSchema,CompositionGetSchema,CompositionHistorySchema,CompositionInputReceiptSchema,CompositionMakingValidationSchema,CompositionObservationViewSchema,CompositionObserveGetSchema,CompositionPageSchema,CompositionReceiptSchema,CompositionRenderCancellationSchema,CompositionRenderGetSchema,CompositionRenderMediaDescriptorSchema,CompositionRenderPageSchema,CompositionRenderQuerySchema,CompositionRenderReceiptSchema,CompositionRenderStartSchema,CompositionRenderViewSchema,CompositionSampleReceiptSchema,CompositionSampleStartSchema,CompositionScopeSchema,CompositionSourceInspectSchema,CompositionSourceInspectionSchema,CompositionValidationReceiptSchema,CompositionViewSchema,ConfigureDeliveryPolicySchema,ConfigureWebhookSchema,CreateCompositionSchema,CreateProductionRequestSchema,CreatedProductionResultSchema,DecideDeliveryApprovalSchema,DecideFinalReadySchema,DeliveryAdmissionSchema,DeliveryDecisionReceiptSchema,DeliveryManifestGetSchema,DeliveryPolicyReceiptSchema,DeliveryPolicyVersionSchema,DeliverySnapshotSchema,DeliveryTargetSchema,DeliveryValidationGetSchema,DeliveryValidationViewSchema,DisableWebhookSchema,DiscoveryContentTypeSchema,EditorContextInputSchema,EditorContextResultSchema,EditorValidationResultSchema,ExecuteRepairSchema,ExplorationCompareInputSchema,ExplorationComparisonResultSchema,ExplorationContextInputSchema,ExplorationContextResultSchema,ExplorationRecommendationContextInputSchema,ExplorationRecommendationContextResultSchema,ExplorationRecommendationValidationResultSchema,ExplorationValidationResultSchema,ExternalLifecycleEventPageSchema,FinalOutputReviewContextInputSchema,FinalOutputReviewContextResultSchema,FinalReadyPageSchema,FinalReadyQuerySchema,FinalReadyReceiptSchema,FinalReadyViewSchema,FinalRenderAdmissionSchema,FinalRenderEligibilitySchema,FinalRenderGetSchema,FinalRenderPageSchema,FinalRenderQuerySchema,FinalRenderStartSchema,FinalRenderViewSchema,InterfaceCancellationReceiptSchema,InterfaceDownloadDescriptorSchema,LifecycleEventCapabilitiesSchema,LifecycleEventScopeSchema,NativeStudioHttpTransport,NavigationGroupIdSchema,NavigationGroups,NavigationProfile,NavigationProfileKey,NavigationToolNames,OperationQueryInputSchema,OperationQueryPageSchema,OperationSummarySchema,OriginalVideoReadSchema,OriginalVideoResultSchema,PreparationActiveInputSchema,PreparationGetInputSchema,PreparationQueryInputSchema,PreparationQueryPageSchema,PreparationViewSchema,PrepareShotRequestSchema,PrepareShotResultSchema,ProductionQueryInputSchema,ProductionQueryPageSchema,ProductionSnapshotSchema,ProductionTerminationReceiptSchema,ProgrammaticCompareSchema,ProgrammaticComparisonSchema,ProgrammaticRecommendationContextInputSchema,ProgrammaticRecommendationContextSchema,ProgrammaticRecommendationValidationSchema,PublicToolDefinitionSchema,PutCompositionInputSchema,QueryLifecycleEventsSchema,ReadyArtifactRegistrationSchema,RecordRepairProofSchema,RecordReview1RepairProofSchema,ReferencePreviewAdmissionSchema,ReferencePreviewOperationInputSchema,ReferencePreviewResultSchema,RegisterVisualSequenceSchema,RegisteredDeliveryManifestSchema,RepairAuthorReceiptSchema,RepairPlanScopeSchema,RepairPlanViewSchema,RepairProgressSchema,RepairProofReceiptSchema,RepairStrategyContextInputSchema,RepairStrategyContextResultSchema,RepairStrategyValidationResultSchema,ReplayWebhookSchema,Review1RepairSourceQuerySchema,Review1RepairStrategyContextSchema,Review1RepairStrategyValidationSchema,ReviseCompositionSchema,RevokeFinalReadySchema,SceneShotPlanQueryInputSchema,SceneShotPlanQueryPageSchema,ScopedAcceptBriefSchema,ScopedAcceptSceneShotPlanSchema,ScopedAcceptStorySchema,SourceReadSchema,SourceReviewContextInputSchema,SourceReviewContextSchema,SourceTextWindowSchema,StartAgentHostExecutionSchema,StartDeliveryValidationSchema,StartReferencePreviewSchema,StoryQueryInputSchema,StoryQueryPageSchema,StudioCapabilitiesInputSchema,StudioCapabilitiesSchema,StudioNavigateInputSchema,StudioNavigationSchema,StudioStartInputSchema,StudioStartSchema,TemporalEvidenceAdmissionSchema,TemporalEvidenceGetSchema,TemporalEvidenceImageMetadataSchema,TemporalEvidenceImageSchema,TemporalEvidenceMediaSchema,TemporalEvidenceSourceSchema,TemporalEvidenceStartSchema,TemporalEvidenceTargetSchema,TemporalEvidenceViewSchema,TerminateProductionSchema,UploadSourceInputRequestSchema,ValidateCompositionMakingSchema,ValidateCompositionSchema,ValidateEditorProposalSchema,ValidateExplorationPlanSchema,ValidateExplorationRecommendationSchema,ValidateProgrammaticRecommendationSchema,ValidateRepairStrategySchema,ValidateReview1RepairStrategySchema,VisualSequenceGetSchema,VisualSequencePageSchema,VisualSequenceQuerySchema,VisualSequenceViewSchema,WavExportResultSchema,WebhookAttemptPageSchema,WebhookDeliveryPageSchema,WebhookReplayReceiptSchema,WebhookSubscriptionPageSchema,WebhookSubscriptionSchema,abortable,assertResponseBindings,mcpOperation,nativeFailureCodes,navigationGroup,operation,pageQuery,path}from"./_chunks/chunk-34KSWLCI.js";import{CreateProjectRequestSchema,CreatedProjectResultSchema,ProjectLibraryPageSchema,ProjectLibraryQuerySchema,ProjectLibraryScopeSchema,ProjectWorkspaceSchema,SourceLibraryMediaSchema,SourceLibraryPageSchema,SourceLibraryQuerySchema}from"./_chunks/chunk-7YCEMDNZ.js";import{AcceptBriefResultSchema,AcceptSceneShotPlanResultSchema,AcceptStoryResultSchema,AgentHostBindingSchema,AgentHostCurrentSchema,AgentHostHistoryPageSchema,AgentHostHistoryQuerySchema,AgentHostReadinessSchema,AgentHostScopeSchema,AudioBasisSchema,AudioGetSchema,AudioImportRequestSchema,AudioPageSchema,AudioQuerySchema,AudioReceiptSchema,AudioScopeSchema,AudioViewSchema,AuthorCaptionsSchema,AuthorTranscriptCaptionsSchema,BuildTimelineSchema,CaptionBasisSchema,CaptionExportSchema,CaptionGetSchema,CaptionPageSchema,CaptionQuerySchema,CaptionReceiptSchema,CaptionScopeSchema,CaptionTranscriptDraftSchema,CaptionTranscriptPlanSchema,CaptionViewSchema,ConfigureAgentHostSchema,ConfigureConsistencyProfileSchema,ConfigureNativeToolGrantSchema,ConfigureProviderInputSchema,ConfigureProviderModelSchema,ConsistencyProfileReceiptSchema,ConsistencyProfileScopeSchema,ConsistencyProfileVersionQuerySchema,ConsistencyProfileVersionSchema,ConsistencyProfileViewSchema,DecideKeyframeSchema,DecideProgrammaticShotSchema,DecideVideoShotSchema,DirectorContextResultSchema,DirectorScopeSchema,DirectorValidationResultSchema,DisableProviderModelSchema,GeneratedShotAcceptanceDecisionSchema,KeyframeAdmissionSchema,KeyframeDecisionPageSchema,KeyframeDecisionQuerySchema,KeyframeDecisionReceiptSchema,KeyframeGenerationViewSchema,KeyframeGetInputSchema,KeyframeMediaSchema,KeyframeQueryInputSchema,KeyframeQueryPageSchema,KeyframeReferenceScopeSchema,KeyframeReferenceViewSchema,KeyframeReviewPageSchema,KeyframeReviewQuerySchema,KeyframeReviewReceiptSchema,KeyframeReviewScopeSchema,KeyframeReviewTargetSchema,KeyframeStartInputSchema,MAX_SHOT_REVIEW_REQUIREMENTS,NativeToolGrantGetSchema,NativeToolGrantViewSchema,ObservationAdmissionSchema,ObservationGetSchema,ObservationOptionsSchema,ObservationScopeSchema,ObservationStartSchema,ObservationViewSchema,ProductionGuidanceContextSchema,ProgrammaticShotAcceptanceDecisionSchema,ProgrammaticVideoReviewPageSchema,ProgrammaticVideoReviewQuerySchema,ProgrammaticVideoReviewReceiptSchema,ProgrammaticVideoReviewScopeSchema,ProgrammaticVideoReviewTargetSchema,ProviderConnectionCommandSchema,ProviderConnectionPageSchema,ProviderConnectionViewSchema,ProviderCredentialRevokeSchema,ProviderDefaultViewSchema,ProviderModelGetSchema,ProviderModelPageSchema,ProviderModelViewSchema,ProviderModelsViewSchema,ProviderSelectionSchema,ProviderTenantInputSchema,RecordKeyframeReviewSchema,RecordProgrammaticVideoReviewSchema,RecordRoughCutReviewSchema,RecordVideoReviewSchema,ReviewIntelligenceContextInputSchema,ReviewIntelligenceContextResultSchema,ReviewIntelligenceValidationResultSchema,RevokeAgentHostSchema,RevokeKeyframeSchema,RevokeNativeToolGrantSchema,RevokeShotAcceptanceSchema,RoughCutAdmissionSchema,RoughCutFindingPageSchema,RoughCutFindingQuerySchema,RoughCutGetSchema,RoughCutPageSchema,RoughCutQuerySchema,RoughCutReviewPageSchema,RoughCutReviewQuerySchema,RoughCutReviewReceiptSchema,RoughCutReviewScopeSchema,RoughCutReviewTargetSchema,RoughCutStartSchema,RoughCutViewSchema,SceneShotPlanVersionSchema,SetKeyframeDefaultSchema,ShotAcceptanceScopeSchema,ShotAcceptanceViewSchema,ShotDecisionPageSchema,ShotDecisionQuerySchema,ShotDecisionReceiptSchema,SoundPlanAcceptSchema,SoundPlanContextSchema,SoundPlanGetSchema,SoundPlanReceiptSchema,SoundPlanScopeSchema,SoundPlanValidateSchema,SoundPlanValidationSchema,SoundPlanViewSchema,SourceSyncAudioGetSchema,SourceSyncAudioReceiptSchema,SourceSyncAudioStartSchema,SourceSyncAudioVersionSchema,SourceSyncAudioViewSchema,SpeechAdmissionSchema,SpeechGenerationViewSchema,SpeechGetSchema,SpeechOptionsSchema,SpeechScopeSchema,SpeechStartSchema,StoryVersionSchema,TimelineBasisSchema,TimelineBuildReceiptSchema,TimelineGetSchema,TimelinePageSchema,TimelineQuerySchema,TimelineScopeSchema,TimelineViewSchema,UpdateAgentHostSelectionSchema,ValidateDirectorProposalSchema,ValidateReviewIntelligenceSchema,ValidateWriterProposalSchema,VideoAdmissionSchema,VideoGenerationViewSchema,VideoGetInputSchema,VideoObservationSchema,VideoProviderProfileSchema,VideoQueryInputSchema,VideoQueryPageSchema,VideoReviewPageSchema,VideoReviewQuerySchema,VideoReviewReceiptSchema,VideoReviewRecordSchema,VideoReviewScopeSchema,VideoReviewTargetSchema,VideoStartInputSchema,WriterBriefResultSchema,WriterScopeSchema,WriterValidationResultSchema}from"./_chunks/chunk-4IOFVNFG.js";import{InterfaceSemanticStatusSchema,OperationIdSchema,ProductionIdSchema,ProjectIdSchema,ShotIdSchema,TenantIdSchema}from"./_chunks/chunk-4M3AGNTZ.js";import{NativeStudioSdkError,sdkInputError}from"./_chunks/chunk-6NVIN2NI.js";var NativeStudioNavigationFacade=class{constructor(caller){this.caller=caller}caller;find(input,options){return this.caller.call("studio.start",input,options)}overview(input,options){return this.caller.call("studio.navigate",input,options)}next(input,options){return this.overview(input,options)}resume(input,options){return this.caller.call("operation.get",input,options)}groups(input={},options){return this.caller.call("studio.capability.groups",input,options)}search(input,options){return this.caller.call("studio.capability.search",input,options)}describe(input,options){return this.caller.call("studio.capability.describe",input,options)}};import{createHash as createHash4}from"node:crypto";import{createHash}from"node:crypto";function assertExportBytes(value,captionFormat){const v=value;const bytes=v.contentBase64!==void 0?Buffer.from(v.contentBase64,"base64"):Buffer.from(v.text,"utf8");if(v.contentBase64!==void 0&&(bytes.toString("base64")!==v.contentBase64||bytes.length!==v.byteSize||bytes.toString("ascii",0,4)!=="RIFF"||bytes.toString("ascii",8,12)!=="WAVE")||bytes.length>(v.contentBase64!==void 0?12582912:131072)||captionFormat!==void 0&&v.contentType!==(captionFormat==="JSON"?"application/json":"application/x-subrip")||createHash("sha256").update(bytes).digest("hex")!==v.checksumSha256)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}import{createHash as createHash2}from"node:crypto";function assertOriginalVideoBytes(value){const v=value;const bytes=Buffer.from(v.dataBase64,"base64");if(bytes.toString("base64")!==v.dataBase64||bytes.length!==v.source.byteSize||bytes.subarray(4,8).toString("ascii")!=="ftyp"||createHash2("sha256").update(bytes).digest("hex")!==v.source.checksumSha256)throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}import{z}from"zod";var production=z.strictObject({tenantId:TenantIdSchema,productionId:ProductionIdSchema});var sourceUpload=UploadSourceInputRequestSchema.extend({projectId:ProjectIdSchema,idempotencyKey:z.string().trim().min(1).max(200)});var projectProduction=(p,prod,suffix)=>path("projects",p,"productions",prod,suffix);var coreOperations={"visual-sequence.register":operation(RegisterVisualSequenceSchema,VisualSequenceViewSchema,i=>{const{tenantId,projectId,...body}=i;return{method:"POST",path:path("projects",projectId,"visual-sequences"),tenantId,body}},[["projectId","sequence.projectId"]]),"visual-sequence.get":operation(VisualSequenceGetSchema,VisualSequenceViewSchema,i=>({method:"GET",path:path("projects",i.projectId,"visual-sequences",i.artifactId),tenantId:i.tenantId}),[["artifactId","sequence.artifactId"]]),"visual-sequence.query":operation(VisualSequenceQuerySchema,VisualSequencePageSchema,i=>({method:"GET",path:path("projects",i.projectId,"visual-sequences"),tenantId:i.tenantId,query:pageQuery(i)})),"project.create":operation(CreateProjectRequestSchema,CreatedProjectResultSchema,input=>({method:"POST",path:path("projects"),tenantId:input.tenantId,body:input})),"production.create":operation(CreateProductionRequestSchema,CreatedProductionResultSchema,input=>({method:"POST",path:path("projects",input.projectId,"productions"),tenantId:input.tenantId,body:{idempotencyKey:input.idempotencyKey}}),[["projectId","project.id"]]),"production.terminate":operation(TerminateProductionSchema,ProductionTerminationReceiptSchema,input=>({method:"POST",path:path("projects",input.projectId,"productions",input.productionId,"terminate"),tenantId:input.tenantId,body:{outcome:input.outcome,expectedProductionRevision:input.expectedProductionRevision,reason:input.reason,idempotencyKey:input.idempotencyKey}}),[["productionId","productionId"],["projectId","projectId"]]),"project.query":operation(ProjectLibraryQuerySchema,ProjectLibraryPageSchema,input=>({method:"GET",path:path("projects"),tenantId:input.tenantId,query:pageQuery(input)})),"project.get":operation(ProjectLibraryScopeSchema,ProjectWorkspaceSchema,input=>({method:"GET",path:path("projects",input.projectId),tenantId:input.tenantId}),[["projectId","project.id"]]),"source.query":operation(SourceLibraryQuerySchema,SourceLibraryPageSchema,input=>({method:"GET",path:input.projectId?path("projects",input.projectId,"source-artifacts"):path("source-artifacts"),tenantId:input.tenantId,query:pageQuery(input)})),"source.ingest":operation(sourceUpload,ReadyArtifactRegistrationSchema,input=>{const{projectId,...body}=input;return{method:"POST",path:path("projects",projectId,"source-artifacts"),tenantId:input.tenantId,body}}),"source.text":operation(SourceReadSchema,SourceTextWindowSchema,input=>({method:"GET",path:path("projects",input.projectId,"source-artifacts",input.artifactId,"text"),tenantId:input.tenantId,query:{offsetBytes:input.offsetBytes,maxTextBytes:input.maxTextBytes}}),[["artifactId","artifactId"]]),"production.query":operation(ProductionQueryInputSchema.strict(),ProductionQueryPageSchema,input=>({method:"GET",path:path("productions"),tenantId:input.tenantId,query:{...pageQuery(input),projectId:input.projectId,search:input.search,attention:input.attention}})),"production.snapshot":operation(production,ProductionSnapshotSchema,input=>({method:"GET",path:path("productions",input.productionId,"snapshot"),tenantId:input.tenantId})),"brief.accept":operation(ScopedAcceptBriefSchema,AcceptBriefResultSchema,input=>{const{projectId,productionId,...body}=input;return{method:"POST",path:projectProduction(projectId,productionId,"brief-versions"),tenantId:input.tenantId,body}}),"story.accept":operation(ScopedAcceptStorySchema,AcceptStoryResultSchema,input=>{const{projectId,productionId,...body}=input;return{method:"POST",path:projectProduction(projectId,productionId,"story-versions"),tenantId:input.tenantId,body}}),"scene-shot-plan.accept":operation(ScopedAcceptSceneShotPlanSchema,AcceptSceneShotPlanResultSchema,input=>{const{projectId,productionId,...body}=input;return{method:"POST",path:projectProduction(projectId,productionId,"scene-shot-plan-versions"),tenantId:input.tenantId,body}}),"story.query":operation(StoryQueryInputSchema.strict(),StoryQueryPageSchema,input=>({method:"GET",path:path("productions",input.productionId,"stories"),tenantId:input.tenantId,query:pageQuery(input)})),"story.active":operation(production,StoryVersionSchema,input=>({method:"GET",path:path("productions",input.productionId,"stories","active"),tenantId:input.tenantId})),"scene-shot-plan.query":operation(SceneShotPlanQueryInputSchema.strict(),SceneShotPlanQueryPageSchema,input=>({method:"GET",path:path("productions",input.productionId,"scene-shot-plans"),tenantId:input.tenantId,query:pageQuery(input)})),"scene-shot-plan.active":operation(production,SceneShotPlanVersionSchema,input=>({method:"GET",path:path("productions",input.productionId,"scene-shot-plans","active"),tenantId:input.tenantId})),"operation.query":operation(OperationQueryInputSchema.strict(),OperationQueryPageSchema,input=>({method:"GET",path:path("productions",input.productionId,"operations"),tenantId:input.tenantId,query:pageQuery(input)})),"operation.get":operation(production.extend({operationId:OperationIdSchema}),OperationSummarySchema,input=>({method:"GET",path:path("productions",input.productionId,"operations",input.operationId),tenantId:input.tenantId}),[["operationId","id"]])};var navigationOperations={"studio.capability.groups":mcpOperation(CapabilityGroupsInputSchema,CapabilityGroupsSchema,true),"studio.start":mcpOperation(StudioStartInputSchema,StudioStartSchema,true),"studio.capability.search":mcpOperation(CapabilitySearchInputSchema,CapabilitySearchSchema,true),"studio.capability.describe":mcpOperation(CapabilityDescribeInputSchema,CapabilityDescribeSchema,true),"studio.navigate":mcpOperation(StudioNavigateInputSchema,StudioNavigationSchema,true,[["productionId","productionId"],["projectId","projectId"]])};function write(input,suffix){return operation(input,AgentHostBindingSchema,value=>({method:"POST",tenantId:value.tenantId,path:path("projects",value.projectId,"agent-host",...suffix),body:Object.fromEntries(Object.entries(value).filter(([key])=>!["tenantId","projectId"].includes(key)))}),[["bindingId","bindingId"]])}var agentHostOperations={"agent-host.get":operation(AgentHostScopeSchema,AgentHostCurrentSchema,value=>({method:"GET",tenantId:value.tenantId,path:path("projects",value.projectId,"agent-host")})),"agent-host.readiness":operation(AgentHostScopeSchema,AgentHostReadinessSchema,value=>({method:"GET",tenantId:value.tenantId,path:path("projects",value.projectId,"agent-host","readiness")})),"agent-host.history":operation(AgentHostHistoryQuerySchema,AgentHostHistoryPageSchema,value=>({method:"GET",tenantId:value.tenantId,path:path("projects",value.projectId,"agent-host","history"),query:{limit:value.limit,beforeVersion:value.beforeVersion}})),"agent-host.configure":write(ConfigureAgentHostSchema,[]),"agent-host.selection.update":write(UpdateAgentHostSelectionSchema,["selection"]),"agent-host.revoke":write(RevokeAgentHostSchema,["revoke"])};var route=(scope,...suffix)=>path("projects",scope.projectId,"productions",scope.productionId,"agent-host-executions",...suffix);var mutation=action=>operation(AgentHostExecutionGetSchema,AgentHostExecutionViewSchema,value=>({method:"POST",tenantId:value.tenantId,path:route(value,value.executionId,action),body:{}}),[["executionId","executionId"]]);var agentHostExecutionOperations={"agent-host-execution.start":operation(StartAgentHostExecutionSchema,AgentHostExecutionViewSchema,value=>({method:"POST",tenantId:value.tenantId,path:route(value),body:Object.fromEntries(Object.entries(value).filter(([key])=>!["tenantId","projectId","productionId"].includes(key)))}),[["requestId","requestId"],["bindingId","snapshot.binding.bindingId"],["studioInputArtifactId","snapshot.input.intake.artifactId"],["expectedProductionRevision","snapshot.input.productionRevision"],["expectedBindingRevision","snapshot.binding.revision"],["expectedConfigurationVersion","snapshot.binding.configurationVersion"]]),"agent-host-execution.get":operation(AgentHostExecutionGetSchema,AgentHostExecutionViewSchema,value=>({method:"GET",tenantId:value.tenantId,path:route(value,value.executionId)}),[["executionId","executionId"]]),"agent-host-execution.query":operation(AgentHostExecutionQuerySchema,AgentHostExecutionPageSchema,value=>({method:"GET",tenantId:value.tenantId,path:route(value),query:{limit:value.limit,beforeId:value.beforeId}})),"agent-host-execution.events":operation(AgentHostExecutionEventQuerySchema,AgentHostExecutionEventPageSchema,value=>({method:"GET",tenantId:value.tenantId,path:route(value,value.executionId,"events"),query:{limit:value.limit,beforeRevision:value.beforeRevision}}),[["executionId","items.*.executionId"]]),"agent-host-execution.dispatch":mutation("dispatch"),"agent-host-execution.reconcile":mutation("reconcile"),"agent-host-execution.cancel":mutation("cancel")};var route2=(v,...suffix)=>path("projects",v.projectId,"native-tool-grants",...suffix);var nativeToolAuthorityOperations={"native-tool-grant.configure":operation(ConfigureNativeToolGrantSchema,NativeToolGrantViewSchema,v=>({method:"POST",tenantId:v.tenantId,path:route2(v),body:Object.fromEntries(Object.entries(v).filter(([k])=>!["tenantId","projectId"].includes(k)))}),[["bindingId","bindingId"],["expectedBindingRevision","bindingRevision"],["expectedConfigurationVersion","configurationVersion"],["runtimeKey","runtimeKey"],["installationId","installationId"],["installationRevisionId","installationRevisionId"],["publicKey.x","publicKey.x"],["publicKey.y","publicKey.y"]]),"native-tool-grant.get":operation(NativeToolGrantGetSchema,NativeToolGrantViewSchema,v=>({method:"GET",tenantId:v.tenantId,path:route2(v,v.grantId)}),[["grantId","grantId"]]),"native-tool-grant.revoke":operation(RevokeNativeToolGrantSchema,NativeToolGrantViewSchema,v=>({method:"POST",tenantId:v.tenantId,path:route2(v,v.grantId,"revoke"),body:{requestId:v.requestId,expectedRevision:v.expectedRevision}}),[["grantId","grantId"]])};function productionRead(input,output,suffix,query=()=>({}),identity=[]){return operation(input,output,value=>({method:"GET",tenantId:value.tenantId,path:path("productions",value.productionId,...suffix(value)),query:query(value)}),identity)}function productionWrite(input,output,suffix,options={}){return operation(input,output,value=>({method:"POST",tenantId:value.tenantId,path:path("productions",value.productionId,...suffix(value)),body:Object.fromEntries(Object.entries(value).filter(([key])=>key!=="productionId"&&(options.tenantInBody||key!=="tenantId")&&!options.pathFields?.includes(key)))}),options.identity,options.readOnly===void 0?{}:{readOnly:options.readOnly})}var compositionOperations={"composition.render.query":productionRead(CompositionRenderQuerySchema,CompositionRenderPageSchema,()=>["compositions","renders"],i=>({limit:i.limit,next:i.next,shotId:i.shotId,role:i.role}),[["shotId","items.*.render.sourceIdentity.shotId"],["role","items.*.render.sourceIdentity.role"]]),"composition.capabilities":productionRead(CompositionScopeSchema,CompositionCapabilitiesSchema,()=>["compositions","capabilities"]),"composition.brief":productionRead(CompositionBriefQuerySchema,CompositionAuthoringBriefSchema,()=>["compositions","brief"],i=>({...i.shotId?{shotId:i.shotId}:{}})),"composition.put-input":productionWrite(PutCompositionInputSchema,CompositionInputReceiptSchema,()=>["compositions","inputs"]),"composition.making.validate":productionWrite(ValidateCompositionMakingSchema,CompositionMakingValidationSchema,()=>["compositions","making","validate"],{readOnly:true,identity:[["projectId","projectId"],["expectedProductionRevision","authoring.productionRevision"],["basis.briefVersionId","authoring.basis.briefVersionId"],["basis.storyVersionId","authoring.basis.storyVersionId"],["basis.planVersionId","authoring.basis.planVersionId"],["basis.shotId","authoring.basis.shotId"],["proposal.makingIntent","proposal.makingIntent"]]}),"composition.validate":productionWrite(ValidateCompositionSchema,CompositionValidationReceiptSchema,()=>["compositions","validate"],{readOnly:true}),"composition.create":productionWrite(CreateCompositionSchema,CompositionReceiptSchema,()=>["compositions"]),"composition.revise":productionWrite(ReviseCompositionSchema,CompositionReceiptSchema,()=>["compositions","revise"],{identity:[["compositionId","version.compositionId"]]}),"composition.get":productionRead(CompositionGetSchema,CompositionViewSchema,i=>["compositions",i.compositionId],i=>({versionId:i.versionId}),[["compositionId","version.compositionId"],["versionId","version.id"]]),"composition.history":productionRead(CompositionHistorySchema,CompositionPageSchema,i=>["compositions",i.compositionId,"versions"],i=>({limit:i.limit,beforeVersion:i.beforeVersion}),[["compositionId","items.*.version.compositionId"]]),"composition.render":productionWrite(CompositionRenderStartSchema,CompositionRenderReceiptSchema,()=>["compositions","renders"],{identity:[["versionId","compositionVersionId"]]}),"composition.render.get":productionRead(CompositionRenderGetSchema,CompositionRenderViewSchema,i=>["compositions","renders",i.renderId],void 0,[["renderId","receipt.renderId"]]),"composition.render.cancel":productionWrite(CompositionRenderGetSchema,CompositionRenderCancellationSchema,i=>["compositions","renders",i.renderId,"cancel"],{pathFields:["renderId"]}),"composition.sample":productionWrite(CompositionSampleStartSchema,CompositionSampleReceiptSchema,()=>["compositions","samples"],{identity:[["renderId","renderId"]]}),"composition.observe":productionRead(CompositionObserveGetSchema,CompositionObservationViewSchema,i=>["compositions","renders",i.renderId,"observations",i.evidenceId],void 0,[["renderId","renderId"],["evidenceId","evidence.evidenceId"]])};var cancellation=InterfaceCancellationReceiptSchema;var assemblyOperations={"timeline.basis":productionRead(TimelineScopeSchema,TimelineBasisSchema,()=>["timeline","basis"]),"timeline.build":productionWrite(BuildTimelineSchema,TimelineBuildReceiptSchema,()=>["timeline"]),"timeline.current":productionRead(TimelineScopeSchema,TimelineViewSchema,()=>["timeline","current"]),"timeline.get":productionRead(TimelineGetSchema,TimelineViewSchema,i=>["timeline","versions",i.versionId],void 0,[["versionId","version.id"]]),"timeline.query":productionRead(TimelineQuerySchema,TimelinePageSchema,()=>["timeline","versions"],pageQuery),"rough-cut.start":productionWrite(RoughCutStartSchema,RoughCutAdmissionSchema,()=>["rough-cuts"],{tenantInBody:true,identity:[["timelineVersionId","timelineVersionId"],["timelineFingerprint","timelineFingerprint"]]}),"rough-cut.get":productionRead(RoughCutGetSchema,RoughCutViewSchema,i=>["rough-cuts",i.renderId],void 0,[["renderId","renderId"]]),"rough-cut.query":productionRead(RoughCutQuerySchema,RoughCutPageSchema,()=>["rough-cuts"],pageQuery),"rough-cut.cancel":productionWrite(RoughCutGetSchema,cancellation,i=>["rough-cuts",i.renderId,"cancel"],{pathFields:["renderId"]}),"rough-cut.review.target":productionRead(RoughCutReviewScopeSchema,RoughCutReviewTargetSchema,i=>["rough-cut-review",i.renderId],void 0,[["renderId","renderId"]]),"rough-cut.review.record":productionWrite(RecordRoughCutReviewSchema,RoughCutReviewReceiptSchema,i=>["rough-cut-review",i.renderId],{pathFields:["renderId"],identity:[["renderId","review.renderId"]]}),"rough-cut.review.query":productionRead(RoughCutReviewQuerySchema,RoughCutReviewPageSchema,i=>["rough-cut-review",i.renderId,"history"],pageQuery,[["renderId","items.*.renderId"]]),"rough-cut.finding.query":productionRead(RoughCutFindingQuerySchema,RoughCutFindingPageSchema,()=>["rough-cut-review","findings"],i=>({...pageQuery(i),renderId:i.renderId}),[["renderId","items.*.renderId"]]),"final-ready.get":productionRead(TimelineScopeSchema,FinalReadyViewSchema,()=>["final-ready"]),"final-ready.decide":productionWrite(DecideFinalReadySchema,FinalReadyReceiptSchema,()=>["final-ready","decisions"],{identity:[["renderId","decision.renderId"],["reviewId","decision.reviewId"]]}),"final-ready.revoke":productionWrite(RevokeFinalReadySchema,FinalReadyReceiptSchema,()=>["final-ready","revoke"]),"final-ready.query":productionRead(FinalReadyQuerySchema,FinalReadyPageSchema,()=>["final-ready","decisions"],pageQuery),"final-render.eligibility":productionRead(TimelineScopeSchema,FinalRenderEligibilitySchema,()=>["final-renders","eligibility"]),"final-render.start":productionWrite(FinalRenderStartSchema,FinalRenderAdmissionSchema,()=>["final-renders"],{tenantInBody:true,identity:[["selectionId","selectionId"],["timelineVersionId","timelineVersionId"],["timelineFingerprint","timelineFingerprint"]]}),"final-render.get":productionRead(FinalRenderGetSchema,FinalRenderViewSchema,i=>["final-renders",i.renderId],void 0,[["renderId","renderId"]]),"final-render.query":productionRead(FinalRenderQuerySchema,FinalRenderPageSchema,()=>["final-renders"],pageQuery),"final-render.cancel":productionWrite(FinalRenderGetSchema,cancellation,i=>["final-renders",i.renderId,"cancel"],{pathFields:["renderId"]})};var Context=EditorContextInputSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Validate=ValidateEditorProposalSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.scope.tenantId.toLowerCase());var editorOperations={"editor.context":operation(Context,EditorContextResultSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"editor-intelligence","context"),body:{scope:i.scope,timelineVersionId:i.timelineVersionId}}),[["scope.tenantId","basis.scope.tenantId"],["scope.projectId","basis.scope.projectId"],["scope.productionId","basis.scope.productionId"],["timelineVersionId","timeline.version.id"]],{readOnly:true}),"editor.validate":operation(Validate,EditorValidationResultSchema,i=>({method:"POST",tenantId:i.basis.scope.tenantId,path:path("projects",i.basis.scope.projectId,"productions",i.basis.scope.productionId,"editor-intelligence","proposals","validate"),body:{basis:i.basis,proposal:i.proposal}}),[["basis.scope.tenantId","basis.scope.tenantId"],["basis.scope.projectId","basis.scope.projectId"],["basis.scope.productionId","basis.scope.productionId"],["basis.timelineVersionId","basis.timelineVersionId"],["basis.contextFingerprint","basis.contextFingerprint"]],{readOnly:true})};var Context2=ReviewIntelligenceContextInputSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Validate2=ValidateReviewIntelligenceSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.scope.tenantId.toLowerCase());var FinalContext=FinalOutputReviewContextInputSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var reviewerOperations={"reviewer.final-output-context":operation(FinalContext,FinalOutputReviewContextResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"review-intelligence","final-output","context"),body:{scope:i.scope,renderId:i.renderId}}),[["scope","basis.scope"],["renderId","basis.renderId"],["renderId","deliveryTarget.renderId"]],{readOnly:true}),"reviewer.context":operation(Context2,ReviewIntelligenceContextResultSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"review-intelligence","context"),body:{scope:i.scope,target:i.target}}),[["scope.tenantId","basis.scope.tenantId"],["scope.projectId","basis.scope.projectId"],["scope.productionId","basis.scope.productionId"],["target.kind","basis.target.kind"],["target.renderId","basis.target.renderId"],["target.generationId","basis.target.generationId"],["scope.tenantId","reviewTarget.target.tenantId"],["scope.projectId","reviewTarget.target.projectId"],["scope.productionId","reviewTarget.target.productionId"],["target.kind","reviewTarget.kind"],["target.renderId","reviewTarget.target.renderId"],["target.generationId","reviewTarget.target.generationId"]],{readOnly:true}),"reviewer.validate":operation(Validate2,ReviewIntelligenceValidationResultSchema,i=>({method:"POST",tenantId:i.basis.scope.tenantId,path:path("projects",i.basis.scope.projectId,"productions",i.basis.scope.productionId,"review-intelligence","proposals","validate"),body:{basis:i.basis,proposal:i.proposal}}),[["basis.scope.tenantId","basis.scope.tenantId"],["basis.scope.projectId","basis.scope.projectId"],["basis.scope.productionId","basis.scope.productionId"],["basis.target.kind","basis.target.kind"],["basis.target.renderId","basis.target.renderId"],["basis.target.generationId","basis.target.generationId"],["basis.contextFingerprint","basis.contextFingerprint"],["basis.scope.tenantId","recordDraft.input.tenantId"],["basis.scope.productionId","recordDraft.input.productionId"],["basis.target.kind","recordDraft.kind"],["basis.target.renderId","recordDraft.input.renderId"],["basis.target.generationId","recordDraft.input.generationId"]],{readOnly:true})};var Context3=RepairStrategyContextInputSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Validate3=ValidateRepairStrategySchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.scope.tenantId.toLowerCase());var Review1Validate=ValidateReview1RepairStrategySchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.input.tenantId.toLowerCase());var repairStrategyOperations={"repair-strategy.review1.context":operation(Review1RepairSourceQuerySchema,Review1RepairStrategyContextSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("projects",i.projectId,"productions",i.productionId,"repair-strategy","review1","context"),body:i}),[["tenantId","basis.input.tenantId"],["projectId","basis.input.projectId"],["productionId","basis.input.productionId"],["generationId","basis.input.generationId"],["reviewId","basis.input.reviewId"],["requirementKey","basis.input.requirementKey"]],{readOnly:true}),"repair-strategy.review1.validate":operation(Review1Validate,Review1RepairStrategyValidationSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("projects",i.basis.input.projectId,"productions",i.basis.input.productionId,"repair-strategy","review1","proposals","validate"),body:{basis:i.basis,proposal:i.proposal,...i.budget?{budget:i.budget}:{}}}),[["basis","basis"],["proposal.selectedAlternativeId","selectedAlternativeId"]],{readOnly:true}),"repair-strategy.context":operation(Context3,RepairStrategyContextResultSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"repair-strategy","context"),body:{scope:i.scope,findingId:i.findingId}}),[["scope.tenantId","basis.scope.tenantId"],["scope.projectId","basis.scope.projectId"],["scope.productionId","basis.scope.productionId"],["findingId","finding.id"]],{readOnly:true}),"repair-strategy.validate":operation(Validate3,RepairStrategyValidationResultSchema,i=>({method:"POST",tenantId:i.basis.scope.tenantId,path:path("projects",i.basis.scope.projectId,"productions",i.basis.scope.productionId,"repair-strategy","proposals","validate"),body:{basis:i.basis,proposal:i.proposal}}),[["basis.scope.tenantId","basis.scope.tenantId"],["basis.scope.projectId","basis.scope.projectId"],["basis.scope.productionId","basis.scope.productionId"],["basis.findingId","finding.id"],["basis.contextFingerprint","basis.contextFingerprint"],["proposal.selectedAlternativeId","selectedAlternativeId"]],{readOnly:true})};var ownedRequest=(action,i)=>{const{projectId,...body}=i;return{method:"POST",tenantId:i.tenantId,path:path("projects",projectId,"productions",i.productionId,"repairs",action),body}};var Author=AuthorRepairPlanSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.strategy.basis.scope.tenantId.toLowerCase());var canonicalRepairOperations={"canonical-repair.author-review1":operation(AuthorReview1RepairSchema,RepairAuthorReceiptSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("projects",i.projectId,"productions",i.productionId,"repairs","author-review1"),body:i}),[["reviewId","decision.sourceReviewId"],["generationId","decision.review1Source.generationId"],["mediaType","decision.review1Source.mediaType"],["requirementKey","decision.review1Source.requirement.key"]]),"canonical-repair.proof-review1":operation(RecordReview1RepairProofSchema.extend({projectId:ProjectIdSchema}),RepairProofReceiptSchema,i=>ownedRequest("proof-review1",i),[["attemptId","event.attemptId"],["generationId","event.generationId"],["reviewId","event.reviewId"]]),"canonical-repair.author":operation(Author,RepairAuthorReceiptSchema,i=>{const{tenantId,...body}=i;const s=i.strategy.basis.scope;return{method:"POST",tenantId,path:path("projects",s.projectId,"productions",s.productionId,"repairs","author"),body}},[["strategy.basis.scope.tenantId","decision.tenantId"],["strategy.basis.scope.projectId","decision.projectId"],["strategy.basis.scope.productionId","decision.productionId"],["strategy.basis.findingId","decision.basis.findingId"],["strategy.basis.contextFingerprint","decision.basis.contextFingerprint"],["strategy.proposal.selectedAlternativeId","decision.selectedAlternativeId"]]),"canonical-repair.get":operation(RepairPlanScopeSchema.extend({projectId:ProjectIdSchema}),RepairPlanViewSchema,i=>ownedRequest("get",i),[["planId","decision.id"]],{readOnly:true}),"canonical-repair.execute":operation(ExecuteRepairSchema.extend({projectId:ProjectIdSchema}),RepairProgressSchema,i=>ownedRequest("execute",i),[["planId","view.decision.id"]]),"canonical-repair.proof":operation(RecordRepairProofSchema.extend({projectId:ProjectIdSchema}),RepairProofReceiptSchema,i=>ownedRequest("proof",i),[["attemptId","event.attemptId"],["renderId","event.renderId"],["reviewId","event.reviewId"]])};var programmaticReviewOperations={"programmatic-review.target":productionRead(ProgrammaticVideoReviewScopeSchema,ProgrammaticVideoReviewTargetSchema,i=>["video-review","programmatic",i.renderId],void 0,[["renderId","renderId"]]),"programmatic-review.record":productionWrite(RecordProgrammaticVideoReviewSchema,ProgrammaticVideoReviewReceiptSchema,i=>["video-review","programmatic",i.renderId],{pathFields:["renderId"],identity:[["renderId","review.renderId"],["representationId","review.representationId"],["checksumSha256","review.checksumSha256"]]}),"programmatic-review.query":productionRead(ProgrammaticVideoReviewQuerySchema,ProgrammaticVideoReviewPageSchema,i=>["video-review","programmatic",i.renderId,"history"],pageQuery,[["renderId","items.*.renderId"]]),"programmatic-review.decide":productionWrite(DecideProgrammaticShotSchema,ShotDecisionReceiptSchema.extend({decision:ProgrammaticShotAcceptanceDecisionSchema}),i=>["video-review","programmatic",i.renderId,"decisions"],{pathFields:["renderId"],identity:[["renderId","decision.renderId"],["reviewId","decision.reviewId"],["action","decision.action"]]})};var Context4=SourceReviewContextInputSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var compositionSourceOperations={"composition.source.inspect":productionWrite(CompositionSourceInspectSchema,CompositionSourceInspectionSchema,()=>["compositions","source","inspect"],{readOnly:true,identity:[["compositionId","composition.version.compositionId"],["versionId","composition.version.id"],["fingerprint","composition.version.fingerprint"],["file","window.file"],["startLine","selection.startLine"]]}),"reviewer.source-context":operation(Context4,SourceReviewContextSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"review-intelligence","source","context"),body:{scope:i.scope,source:i.source,...i.renderId?{renderId:i.renderId}:{}}}),[["scope.tenantId","basis.input.scope.tenantId"],["scope.projectId","source.composition.version.projectId"],["scope.productionId","source.composition.version.productionId"],["source.compositionId","source.composition.version.compositionId"],["source.versionId","source.composition.version.id"],["source.fingerprint","source.composition.version.fingerprint"],["source.file","source.window.file"],["source.startLine","source.selection.startLine"],["renderId","render.receipt.renderId"]],{readOnly:true})};var Compare=ProgrammaticCompareSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Context5=ProgrammaticRecommendationContextInputSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Validate4=ValidateProgrammaticRecommendationSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.input.scope.tenantId.toLowerCase());var programmaticExplorationOperations={"exploration.programmatic.compare":operation(Compare,ProgrammaticComparisonSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"visual-exploration","programmatic","compare"),body:{scope:i.scope,items:i.items}}),[["scope.tenantId","scope.tenantId"],["scope.projectId","scope.projectId"],["scope.productionId","scope.productionId"],["scope.shotId","scope.shotId"],["items","selection"]],{readOnly:true}),"exploration.programmatic.recommendation.context":operation(Context5,ProgrammaticRecommendationContextSchema,i=>({method:"POST",tenantId:i.scope.tenantId,path:path("projects",i.scope.projectId,"productions",i.scope.productionId,"exploration-recommendation","programmatic","context"),body:{scope:i.scope,items:i.items,criteria:i.criteria}}),[["scope.tenantId","basis.input.scope.tenantId"],["scope.projectId","basis.input.scope.projectId"],["scope.productionId","basis.input.scope.productionId"],["scope.shotId","basis.input.scope.shotId"],["items","basis.input.items"]],{readOnly:true}),"exploration.programmatic.recommendation.validate":operation(Validate4,ProgrammaticRecommendationValidationSchema,i=>({method:"POST",tenantId:i.basis.input.scope.tenantId,path:path("projects",i.basis.input.scope.projectId,"productions",i.basis.input.scope.productionId,"exploration-recommendation","programmatic","proposals","validate"),body:{basis:i.basis,proposal:i.proposal}}),[["basis.contextFingerprint","basis.contextFingerprint"],["basis.input.scope.tenantId","basis.input.scope.tenantId"],["basis.input.scope.projectId","basis.input.scope.projectId"],["basis.input.scope.productionId","basis.input.scope.productionId"],["basis.input.items","basis.input.items"],["proposal.decision.kind","decision.kind"],["proposal.decision.label","decision.label"]],{readOnly:true})};var targetIdentity=prefix=>Object.keys(DeliveryTargetSchema.shape).map(key=>["target."+key,prefix+"."+key]);var deliveryOperations={"delivery.policy.configure":productionWrite(ConfigureDeliveryPolicySchema,DeliveryPolicyReceiptSchema,()=>["deliveries","policy"],{tenantInBody:true}),"delivery.policy.get":productionRead(TimelineScopeSchema,DeliveryPolicyVersionSchema,()=>["deliveries","policy"]),"delivery.snapshot":productionRead(TimelineScopeSchema,DeliverySnapshotSchema,()=>["deliveries","snapshot"]),"delivery.target":productionRead(RoughCutGetSchema,DeliveryTargetSchema,i=>["deliveries","targets",i.renderId],void 0,[["renderId","renderId"]]),"delivery.start":productionWrite(StartDeliveryValidationSchema,DeliveryAdmissionSchema,()=>["deliveries"],{tenantInBody:true,identity:targetIdentity("target")}),"delivery.get":productionRead(DeliveryValidationGetSchema,DeliveryValidationViewSchema,i=>["deliveries",i.validationId],void 0,[["validationId","admission.validationId"]]),"delivery.approve":productionWrite(DecideDeliveryApprovalSchema,DeliveryDecisionReceiptSchema,i=>["deliveries",i.validationId,"approval"],{tenantInBody:true,pathFields:["validationId"],identity:[...targetIdentity("approval.target"),["reviewId","approval.reviewId"],["policyFingerprint","approval.policyFingerprint"],["action","approval.action"]]}),"delivery.cancel":productionWrite(DeliveryValidationGetSchema,cancellation,i=>["deliveries",i.validationId,"cancel"],{pathFields:["validationId"]}),"delivery.manifest":productionRead(DeliveryManifestGetSchema,RegisteredDeliveryManifestSchema,i=>["deliveries","manifests",i.manifestId],void 0,[["manifestId","link.id"]])};var prepare=PrepareShotRequestSchema.extend({projectId:ProjectIdSchema,productionId:ProductionIdSchema,shotId:ShotIdSchema});var shotPreparationOperations={"shot-preparation.prepare":operation(prepare,PrepareShotResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("projects",i.projectId,"productions",i.productionId,"shots",i.shotId,"preparations"),body:Object.fromEntries(Object.entries(i).filter(([k])=>!["projectId","productionId","shotId"].includes(k)))}),[["projectId","preparation.basis.projectId"],["shotId","preparation.basis.shotId"],["expectedPlanVersionId","preparation.basis.planVersionId"],["expectedPlanVersion","preparation.basis.planVersion"],["expectedShotPlanningRevision","preparation.basis.shotPlanningRevision"],["target","preparation.target"]]),"shot-preparation.get":productionRead(PreparationGetInputSchema,PreparationViewSchema,i=>["shot-preparations",i.preparationId],void 0,[["preparationId","preparation.id"]]),"shot-preparation.active":productionRead(PreparationActiveInputSchema,PreparationViewSchema,i=>["shots",i.shotId,"preparations","active"],i=>({mediaType:i.mediaType}),[["shotId","preparation.basis.shotId"],["mediaType","preparation.target.mediaType"]]),"shot-preparation.query":productionRead(PreparationQueryInputSchema,PreparationQueryPageSchema,()=>["shot-preparations"],i=>({...pageQuery(i),shotId:i.shotId,mediaType:i.mediaType}),[["shotId","items.*.preparation.basis.shotId"],["mediaType","items.*.preparation.target.mediaType"]])};var generationOperations={"keyframe.start":productionWrite(KeyframeStartInputSchema,KeyframeAdmissionSchema,()=>["keyframe-generations"],{tenantInBody:true,identity:[["contractId","contractId"]]}),"keyframe.get":productionRead(KeyframeGetInputSchema,KeyframeGenerationViewSchema,i=>["keyframe-generations",i.generationId],void 0,[["generationId","generationId"]]),"keyframe.query":productionRead(KeyframeQueryInputSchema,KeyframeQueryPageSchema,()=>["keyframe-generations"],i=>({...pageQuery(i),shotId:i.shotId}),[["shotId","items.*.shotId"]]),"keyframe.cancel":productionWrite(KeyframeGetInputSchema,InterfaceCancellationReceiptSchema,i=>["keyframe-generations",i.generationId,"cancel"],{pathFields:["generationId"]}),"video.start":productionWrite(VideoStartInputSchema,VideoAdmissionSchema,()=>["video-generations"],{tenantInBody:true,identity:[["contractId","contractId"]]}),"video.get":productionRead(VideoGetInputSchema,VideoGenerationViewSchema,i=>["video-generations",i.generationId],void 0,[["generationId","generationId"]]),"video.query":productionRead(VideoQueryInputSchema,VideoQueryPageSchema,()=>["video-generations"],i=>({...pageQuery(i),shotId:i.shotId}),[["shotId","items.*.shotId"]]),"video.cancel":productionWrite(VideoGetInputSchema,InterfaceCancellationReceiptSchema,i=>["video-generations",i.generationId,"cancel"],{pathFields:["generationId"]})};var keyframeReviewOperations={"keyframe-review.target":productionRead(KeyframeReviewScopeSchema,KeyframeReviewTargetSchema,i=>["keyframe-review",i.generationId],void 0,[["generationId","generationId"]]),"keyframe-review.record":productionWrite(RecordKeyframeReviewSchema,KeyframeReviewReceiptSchema,i=>["keyframe-review",i.generationId],{pathFields:["generationId"],identity:[["generationId","review.generationId"],["candidateId","review.candidateId"],["representationId","review.representationId"],["checksumSha256","review.checksumSha256"]]}),"keyframe-review.query":productionRead(KeyframeReviewQuerySchema,KeyframeReviewPageSchema,i=>["keyframe-review",i.generationId,"history"],pageQuery,[["generationId","items.*.generationId"]]),"keyframe-review.decide":productionWrite(DecideKeyframeSchema,KeyframeDecisionReceiptSchema,i=>["keyframe-review",i.generationId,"decisions"],{pathFields:["generationId"],identity:[["generationId","decision.generationId"],["candidateId","decision.candidateId"],["reviewId","decision.reviewId"],["action","decision.action"]]}),"keyframe-reference.get":productionRead(KeyframeReferenceScopeSchema,KeyframeReferenceViewSchema,i=>["keyframe-review","references",i.shotId,i.framePurpose],void 0,[["shotId","shotId"],["framePurpose","framePurpose"]]),"keyframe-reference.query":productionRead(KeyframeDecisionQuerySchema,KeyframeDecisionPageSchema,i=>["keyframe-review","references",i.shotId,i.framePurpose,"history"],pageQuery,[["shotId","items.*.shotId"],["framePurpose","items.*.framePurpose"]]),"keyframe-reference.revoke":productionWrite(RevokeKeyframeSchema,KeyframeDecisionReceiptSchema,i=>["keyframe-review","references",i.shotId,i.framePurpose,"revoke"],{pathFields:["shotId","framePurpose"],identity:[["shotId","decision.shotId"],["framePurpose","decision.framePurpose"],["acceptanceId","decision.previousAcceptanceId"]]})};var videoReviewOperations={"video-review.target":productionRead(VideoReviewScopeSchema,VideoReviewTargetSchema,i=>["video-review",i.generationId],void 0,[["generationId","generationId"]]),"video-review.record":productionWrite(RecordVideoReviewSchema,VideoReviewReceiptSchema,i=>["video-review",i.generationId],{pathFields:["generationId"],identity:[["generationId","review.generationId"],["candidateId","review.candidateId"],["representationId","review.representationId"],["checksumSha256","review.checksumSha256"]]}),"video-review.query":productionRead(VideoReviewQuerySchema,VideoReviewPageSchema,i=>["video-review",i.generationId,"history"],pageQuery,[["generationId","items.*.generationId"]]),"video-review.decide":productionWrite(DecideVideoShotSchema,ShotDecisionReceiptSchema.extend({decision:GeneratedShotAcceptanceDecisionSchema}),i=>["video-review",i.generationId,"decisions"],{pathFields:["generationId"],identity:[["generationId","decision.generationId"],["candidateId","decision.candidateId"],["reviewId","decision.reviewId"],["action","decision.action"]]}),"shot-acceptance.get":productionRead(ShotAcceptanceScopeSchema,ShotAcceptanceViewSchema,i=>["video-review","shots",i.shotId,"acceptance"],void 0,[["shotId","shotId"]]),"shot-acceptance.query":productionRead(ShotDecisionQuerySchema,ShotDecisionPageSchema,i=>["video-review","shots",i.shotId,"decisions"],pageQuery,[["shotId","items.*.shotId"]]),"shot-acceptance.revoke":productionWrite(RevokeShotAcceptanceSchema,ShotDecisionReceiptSchema,i=>["video-review","shots",i.shotId,"revoke"],{pathFields:["shotId"],identity:[["shotId","decision.shotId"],["acceptanceId","decision.previousAcceptanceId"]]})};import{z as z2}from"zod";var providerOperations={"provider.model.get":operation(ProviderModelGetSchema,ProviderModelViewSchema,i=>({method:"GET",tenantId:i.tenantId,path:path("provider-models",i.id),query:{version:i.version}}),[["id","id"],["version","version"]]),"provider.model.query":operation(ProviderTenantInputSchema,ProviderModelPageSchema,i=>({method:"GET",tenantId:i.tenantId,path:path("provider-models")})),"provider.model.configure":operation(ConfigureProviderModelSchema,ProviderModelViewSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("provider-models","configure"),body:i}),[["definition.profile.id","id"],["definition.profile.version","version"]]),"provider.model.disable":operation(DisableProviderModelSchema,z2.strictObject({disabled:z2.literal(true)}),i=>({method:"POST",tenantId:i.tenantId,path:path("provider-models","disable"),body:i})),"provider.configure":operation(ConfigureProviderInputSchema,ProviderConnectionViewSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("provider-connections","configure"),body:i}),[["connectionId","connectionId"],["configuration","configuration"]]),"provider.query":operation(ProviderTenantInputSchema,ProviderConnectionPageSchema,i=>({method:"GET",tenantId:i.tenantId,path:path("provider-connections")})),"provider.models":operation(ProviderTenantInputSchema,ProviderModelsViewSchema,i=>({method:"GET",tenantId:i.tenantId,path:path("provider-connections","models")})),"provider.keyframe-default.set":operation(SetKeyframeDefaultSchema,ProviderDefaultViewSchema,i=>({method:"POST",tenantId:i.tenantId,path:path("provider-connections","keyframe-default"),body:i}),[["selection","selection"]]),"provider.disable":operation(ProviderConnectionCommandSchema,z2.strictObject({disabled:z2.literal(true)}),i=>({method:"POST",tenantId:i.tenantId,path:path("provider-connections","disable"),body:i})),"provider.revoke":operation(ProviderCredentialRevokeSchema,z2.strictObject({revoked:z2.literal(true)}),i=>({method:"POST",tenantId:i.tenantId,path:path("provider-connections","revoke"),body:i}))};import{z as z3}from"zod";var observationOperations={"production-guidance.context":productionRead(ObservationScopeSchema,ProductionGuidanceContextSchema,()=>["media-observations","context"]),"media-observation.options":productionRead(ObservationScopeSchema,ObservationOptionsSchema,()=>["media-observations","options"]),"media-observation.start":productionWrite(ObservationStartSchema,ObservationAdmissionSchema,()=>["media-observations"]),"media-observation.get":productionRead(ObservationGetSchema,ObservationViewSchema,q=>["media-observations",q.observationId],void 0,[["observationId","observationId"]]),"media-observation.cancel":productionWrite(ObservationGetSchema,z3.strictObject({cancellationRequested:z3.boolean()}),q=>["media-observations",q.observationId,"cancel"],{pathFields:["observationId"]})};import{z as z4}from"zod";var speechOperations={"speech.options":productionRead(SpeechScopeSchema,SpeechOptionsSchema,()=>["speech-generations","options"]),"speech.start":productionWrite(SpeechStartSchema,SpeechAdmissionSchema,()=>["speech-generations"]),"speech.get":productionRead(SpeechGetSchema,SpeechGenerationViewSchema,q=>["speech-generations",q.generationId],void 0,[["generationId","generationId"]]),"speech.cancel":productionWrite(SpeechGetSchema,z4.strictObject({cancellationRequested:z4.boolean()}),q=>["speech-generations",q.generationId,"cancel"],{pathFields:["generationId"]})};var soundMakingPlanOperations={"sound-plan.context":productionRead(SoundPlanScopeSchema,SoundPlanContextSchema,()=>["sound-making-plan","context"],()=>({}),[["tenantId","tenantId"],["productionId","productionId"]]),"sound-plan.get":productionRead(SoundPlanGetSchema,SoundPlanViewSchema,()=>["sound-making-plan"],q=>({versionId:q.versionId}),[["tenantId","version.tenantId"],["productionId","version.productionId"],["versionId","version.id"]]),"sound-plan.validate":productionWrite(SoundPlanValidateSchema,SoundPlanValidationSchema,()=>["sound-making-plan","validate"],{readOnly:true}),"sound-plan.accept":productionWrite(SoundPlanAcceptSchema,SoundPlanReceiptSchema,()=>["sound-making-plan"],{identity:[["tenantId","version.tenantId"],["productionId","version.productionId"]]})};import{z as z5}from"zod";var post=(input,output,action,identity=[],readOnly=false)=>operation(input,output,i=>({method:"POST",tenantId:i.tenantId,path:path("lifecycle-events",action),body:i}),identity,{readOnly});var lifecycleEventOperations={"webhook.configure":post(ConfigureWebhookSchema,WebhookSubscriptionSchema,"configure",[["subscriptionId","subscriptionId"]]),"webhook.disable":post(DisableWebhookSchema,WebhookSubscriptionSchema,"disable",[["subscriptionId","subscriptionId"]]),"webhook.replay":post(ReplayWebhookSchema,WebhookReplayReceiptSchema,"replay",[["eventId","eventId"]]),"lifecycle-event.capabilities":post(LifecycleEventScopeSchema,LifecycleEventCapabilitiesSchema,"capabilities",[],true),"lifecycle-event.subscriptions":post(QueryLifecycleEventsSchema.safeExtend({kind:z5.literal("subscriptions")}),WebhookSubscriptionPageSchema,"query",[["subscriptionId","items.*.subscriptionId"]],true),"lifecycle-event.events":post(QueryLifecycleEventsSchema.safeExtend({kind:z5.literal("events")}),ExternalLifecycleEventPageSchema,"query",[],true),"lifecycle-event.deliveries":post(QueryLifecycleEventsSchema.safeExtend({kind:z5.literal("deliveries")}),WebhookDeliveryPageSchema,"query",[["subscriptionId","items.*.subscriptionId"],["deliveryId","items.*.deliveryId"]],true),"lifecycle-event.attempts":post(QueryLifecycleEventsSchema.safeExtend({kind:z5.literal("attempts")}),WebhookAttemptPageSchema,"query",[],true)};import{z as z6}from"zod";var mediaDescriptorOperations={"composition.render.media-target":mcpOperation(CompositionRenderGetSchema,CompositionRenderMediaDescriptorSchema,true,[],i=>path("productions",i.productionId,"compositions","renders",i.renderId,"media")),"delivery.download":mcpOperation(TimelineScopeSchema,InterfaceDownloadDescriptorSchema,true,[],i=>path("productions",i.productionId,"deliveries","media")),"temporal-evidence.download":mcpOperation(TemporalEvidenceMediaSchema,InterfaceDownloadDescriptorSchema,true,[],i=>path("productions",i.productionId,"temporal-evidence",i.evidenceId,"media",i.kind)+(i.kind==="FRAME"?"?ordinal="+i.ordinal:"")),"video.options":mcpOperation(z6.strictObject({tenantId:TenantIdSchema}),z6.array(z6.strictObject({selection:ProviderSelectionSchema,profile:VideoProviderProfileSchema})).max(200),true)};import{z as z7}from"zod";var NotFound=z7.strictObject({semanticStatus:z7.literal("NOT_FOUND")});var Accepted=z7.strictObject({semanticStatus:z7.literal("ACCEPTED")});var referencePreviewOperations={"studio.capabilities":mcpOperation(StudioCapabilitiesInputSchema,StudioCapabilitiesSchema,true),"reference-preview.start":mcpOperation(StartReferencePreviewSchema,ReferencePreviewAdmissionSchema,false,[["sourceArtifactId","sourceArtifactId"],["expectedBriefVersion","briefVersion"]]),"reference-preview.status":mcpOperation(ReferencePreviewOperationInputSchema,OperationSummarySchema,true,[["operationId","id"]]),"reference-preview.get":mcpOperation(ReferencePreviewOperationInputSchema,z7.union([ReferencePreviewResultSchema,Accepted]),true),"reference-preview.cancel":mcpOperation(ReferencePreviewOperationInputSchema,z7.union([Accepted,NotFound]),false)};var Context6=ExplorationContextInputSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Plan=ValidateExplorationPlanSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.tenantId.toLowerCase());var Compare2=ExplorationCompareInputSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Recommendation=ExplorationRecommendationContextInputSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.scope.tenantId.toLowerCase());var Validate5=ValidateExplorationRecommendationSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.input.scope.tenantId.toLowerCase());var route3=(s,family,...suffix)=>path("projects",s.projectId,"productions",s.productionId,family,...suffix);var ownerOperations={"exploration.context":operation(Context6,ExplorationContextResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:route3(i.scope,"visual-exploration","context"),body:{scope:i.scope,preparationIds:i.preparationIds}}),[["scope.tenantId","basis.tenantId","SUCCESS"],["scope.projectId","basis.projectId","SUCCESS"],["scope.productionId","basis.productionId","SUCCESS"],["scope.shotId","basis.shotId","SUCCESS"]],{readOnly:true}),"exploration.plan.validate":operation(Plan,ExplorationValidationResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:route3(i.basis,"visual-exploration","plans","validate"),body:{basis:i.basis,plan:i.plan}}),[["basis","basis","SUCCESS"]],{readOnly:true}),"exploration.compare":operation(Compare2,ExplorationComparisonResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:route3(i.scope,"visual-exploration","compare"),body:{scope:i.scope,items:i.items}}),[["scope","scope"]],{readOnly:true}),"exploration.recommendation.context":operation(Recommendation,ExplorationRecommendationContextResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:route3(i.scope,"exploration-recommendation","context"),body:{scope:i.scope,items:i.items,criteria:i.criteria}}),[["scope","basis.input.scope"],["items","basis.input.items"],["criteria","basis.input.criteria"]],{readOnly:true}),"exploration.recommendation.validate":operation(Validate5,ExplorationRecommendationValidationResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:route3(i.basis.input.scope,"exploration-recommendation","proposals","validate"),body:{basis:i.basis,proposal:i.proposal}}),[["basis","basis"],["proposal.decision.kind","decision.kind"],["proposal.decision.label","decision.label"]],{readOnly:true})};var visualExplorationOperations={...ownerOperations,"exploration.validate":ownerOperations["exploration.plan.validate"]};import{z as z16}from"zod";import{z as z8}from"zod";var IMPORTED_VISUAL_PROFILE_ID="IMPORTED_H264_SDR_CFR30_VISUAL_V1";var IMPORTED_VISUAL_MAX_BYTES=128*1024*1024;var Hash=z8.string().regex(/^[0-9a-f]{64}$/);var PositiveInteger=z8.int().positive().max(1e9);var ImportedVisualRationalSchema=z8.strictObject({numerator:PositiveInteger,denominator:PositiveInteger});var geometry=limit=>z8.strictObject({width:z8.int().min(2).max(limit).multipleOf(2),height:z8.int().min(2).max(limit).multipleOf(2)}).refine(({width,height})=>width*9===height*16||width*16===height*9,"Only exact 16:9 or 9:16 geometry is supported");var ImportedVisualToolchainSchema=z8.strictObject({ffmpegVersion:z8.string().startsWith("ffmpeg version ").max(512),ffprobeVersion:z8.string().startsWith("ffprobe version ").max(512)});var ImportedVisualSourceInputSchema=z8.strictObject({contentType:z8.literal("video/mp4"),checksumSha256:Hash,byteSize:z8.int().min(32).max(IMPORTED_VISUAL_MAX_BYTES),executionClass:z8.enum(["LIVE","TEST_ONLY"])});var ImportedVisualSourceRangeSchema=z8.strictObject({clock:z8.literal("SOURCE_ZERO_BASED_CFR30"),startFrame:z8.int().min(0).max(1799),endFrame:z8.int().min(1).max(1800)}).refine(v=>v.endFrame>v.startFrame&&v.endFrame-v.startFrame<=360,"The half-open interval must contain 1 to 360 frames");var ImportedVisualNormalizationRequestSchema=z8.strictObject({schemaVersion:z8.literal(1),profileId:z8.literal(IMPORTED_VISUAL_PROFILE_ID),source:ImportedVisualSourceInputSchema,sourceRange:ImportedVisualSourceRangeSchema,output:geometry(1920),audioPolicy:z8.enum(["REQUIRE_NO_AUDIO","SILENT_DERIVATIVE"]),expectedToolchain:ImportedVisualToolchainSchema});var ImportedVisualSourceMetadataSchema=z8.strictObject({...ImportedVisualSourceInputSchema.shape,geometry:geometry(3840),videoCodec:z8.literal("h264"),pixelFormat:z8.literal("yuv420p"),sampleAspectRatio:z8.literal("1:1"),rotationDegrees:z8.literal(0),startPts:z8.literal(0),timeBase:ImportedVisualRationalSchema,frameRate:ImportedVisualRationalSchema,frameCount:z8.int().min(1).max(3600),durationTicks:z8.int().positive().max(6e10),availableCfr30Frames:z8.int().min(0).max(1800),color:z8.strictObject({range:z8.enum(["tv","unknown"]),space:z8.enum(["bt709","unknown"]),transfer:z8.enum(["bt709","unknown"]),primaries:z8.enum(["bt709","unknown"])}),audio:z8.strictObject({codec:z8.literal("aac"),sampleRateHz:z8.union([z8.literal(44100),z8.literal(48e3)]),channels:z8.union([z8.literal(1),z8.literal(2)]),startPts:z8.int(),timeBase:ImportedVisualRationalSchema,durationTicks:z8.int().positive().max(6e10)}).nullable(),fullDecode:z8.literal(true),cfrTimestampsVerified:z8.literal(true)}).superRefine((v,ctx)=>{if(![v.durationTicks,v.timeBase.numerator,v.timeBase.denominator,v.frameRate.numerator,v.frameRate.denominator,v.frameCount,v.availableCfr30Frames].every(Number.isSafeInteger)||v.timeBase.denominator<=0||v.frameRate.numerator<=0||v.frameRate.denominator<=0)return;const ticks=BigInt(v.durationTicks)*BigInt(v.timeBase.numerator);const base=BigInt(v.timeBase.denominator);const declaredFrames=ticks*BigInt(v.frameRate.numerator);const expectedFrames=BigInt(v.frameCount)*base*BigInt(v.frameRate.denominator);if(ticks>60n*base||declaredFrames!==expectedFrames||BigInt(v.availableCfr30Frames)!==ticks*30n/base||v.audio&&BigInt(v.audio.durationTicks)*BigInt(v.audio.timeBase.numerator)>60n*BigInt(v.audio.timeBase.denominator))ctx.addIssue({code:"custom",message:"Media clock/count/duration metadata is inconsistent"})});var ImportedVisualInspectionSchema=z8.strictObject({profileId:z8.literal(IMPORTED_VISUAL_PROFILE_ID),source:ImportedVisualSourceMetadataSchema,toolchain:ImportedVisualToolchainSchema,evidenceScope:z8.literal("TECHNICAL_MEDIA_ONLY")});var ImportedVisualNormalizationReceiptSchema=z8.strictObject({schemaVersion:z8.literal(1),request:ImportedVisualNormalizationRequestSchema,original:ImportedVisualSourceMetadataSchema,output:ImportedVisualSourceMetadataSchema,toolchain:ImportedVisualToolchainSchema,frameMap:z8.array(z8.strictObject({outputFrame:z8.int().min(0).max(359),sourceFrame:z8.int().min(0).max(3599),sourcePts:z8.int().min(0).max(6e10)})).min(1).max(360),audioDisposition:z8.enum(["NO_AUDIO_PRESENT","REMOVED_FROM_DERIVATIVE_ONLY"]),evidenceScope:z8.literal("TECHNICAL_MEDIA_ONLY")}).superRefine((v,ctx)=>{const count=v.request.sourceRange.endFrame-v.request.sourceRange.startFrame;const source=v.original;if(![source.frameRate.numerator,source.frameRate.denominator,source.timeBase.numerator,source.timeBase.denominator,v.request.sourceRange.startFrame].every(Number.isSafeInteger)||source.frameRate.numerator<=0||source.frameRate.denominator<=0)return;const rounded=i=>(2n*BigInt(i)*30n*BigInt(source.frameRate.denominator)+BigInt(source.frameRate.numerator))/(2n*BigInt(source.frameRate.numerator));const exactFrameMap=v.frameMap.every((m,i)=>{if(!Number.isSafeInteger(m.sourcePts)||!Number.isSafeInteger(m.sourceFrame))return false;const absoluteFrame=BigInt(v.request.sourceRange.startFrame+i);return BigInt(m.sourcePts)*BigInt(source.timeBase.numerator)*BigInt(source.frameRate.numerator)===BigInt(m.sourceFrame)*BigInt(source.timeBase.denominator)*BigInt(source.frameRate.denominator)&&rounded(m.sourceFrame)<=absoluteFrame&&(m.sourceFrame+1===source.frameCount||rounded(m.sourceFrame+1)>absoluteFrame)});if(!exactFrameMap||v.request.sourceRange.endFrame>source.availableCfr30Frames||v.output.geometry.width>source.geometry.width||v.output.geometry.height>source.geometry.height||v.output.geometry.width*source.geometry.height!==v.output.geometry.height*source.geometry.width)ctx.addIssue({code:"custom",message:"Receipt frame mapping or geometry violates the pinned profile"});if(v.output.frameCount!==count||v.frameMap.length!==count||v.frameMap.some((m,i)=>m.outputFrame!==i||m.sourceFrame>=v.original.frameCount)||v.output.frameRate.numerator!==30||v.output.frameRate.denominator!==1||v.output.audio||v.original.checksumSha256!==v.request.source.checksumSha256||v.original.byteSize!==v.request.source.byteSize||v.original.executionClass!==v.request.source.executionClass||v.output.executionClass!==v.original.executionClass||v.output.geometry.width!==v.request.output.width||v.output.geometry.height!==v.request.output.height||v.toolchain.ffmpegVersion!==v.request.expectedToolchain.ffmpegVersion||v.toolchain.ffprobeVersion!==v.request.expectedToolchain.ffprobeVersion||v.audioDisposition!==(v.original.audio?"REMOVED_FROM_DERIVATIVE_ONLY":"NO_AUDIO_PRESENT")||v.original.audio&&v.request.audioPolicy!=="SILENT_DERIVATIVE"){ctx.addIssue({code:"custom",message:"Normalization receipt does not match its exact request/source/output"})}});import{z as z9}from"zod";var Uuid=z9.uuid();var Hash2=z9.string().regex(/^[0-9a-f]{64}$/);var ImportedVisualOriginalRegisterSchema=z9.strictObject({projectSourceArtifactId:z9.uuid().optional(),tenantId:Uuid,projectId:Uuid,productionId:Uuid,shotId:Uuid,expectedProductionRevision:z9.int().nonnegative(),source:z9.strictObject({contentType:z9.literal("video/mp4"),checksumSha256:Hash2,byteSize:z9.int().min(32).max(128*1024*1024),executionClass:z9.enum(["LIVE","TEST_ONLY"])}),declaredProvenance:z9.strictObject({originalName:z9.string().trim().min(1).max(255).optional(),authorship:z9.string().trim().min(1).max(500).optional(),license:z9.string().trim().min(1).max(500).optional()}),idempotencyKey:z9.string().trim().min(1).max(200)});var ImportedVisualFromProjectSourceSchema=ImportedVisualOriginalRegisterSchema.omit({source:true,projectSourceArtifactId:true}).extend({projectSourceArtifactId:Uuid});var ImportedVisualOriginalReviseSchema=ImportedVisualOriginalRegisterSchema.extend({sourceId:Uuid,expectedVersion:z9.int().positive()});var ImportedVisualNormalizeStartSchema=z9.strictObject({tenantId:Uuid,projectId:Uuid,productionId:Uuid,shotId:Uuid,sourceId:Uuid,sourceVersionId:Uuid,expectedProductionRevision:z9.int().nonnegative(),request:ImportedVisualNormalizationRequestSchema,idempotencyKey:z9.string().trim().min(1).max(200)});var ImportedVisualGetSchema=z9.strictObject({tenantId:Uuid,productionId:Uuid,normalizationId:Uuid});var ImportedVisualReviewSchema=z9.strictObject({tenantId:Uuid,productionId:Uuid,normalizationId:Uuid,representationId:Uuid,checksumSha256:Hash2,expectedReviewVersion:z9.int().nonnegative(),observations:z9.array(VideoObservationSchema).min(1).max(MAX_SHOT_REVIEW_REQUIREMENTS),summary:z9.string().trim().min(1).max(2500),idempotencyKey:z9.string().trim().min(1).max(200)});var ImportedVisualDecisionSchema=z9.strictObject({tenantId:Uuid,productionId:Uuid,normalizationId:Uuid,reviewId:Uuid,expectedAcceptanceVersion:z9.int().nonnegative(),action:z9.enum(["ACCEPT","REJECT"]),acknowledgeWarnings:z9.boolean().default(false),reason:z9.string().trim().min(1).max(2500),idempotencyKey:z9.string().trim().min(1).max(200)});var ImportedVisualOriginalViewSchema=z9.strictObject({sourceId:Uuid,versionId:Uuid,version:z9.int().positive(),tenantId:Uuid,projectId:Uuid,productionId:Uuid,shotId:Uuid,artifactId:Uuid,representationId:Uuid,metadata:ImportedVisualSourceMetadataSchema,declaredProvenance:ImportedVisualOriginalRegisterSchema.shape.declaredProvenance.optional(),executionClass:z9.enum(["LIVE","TEST_ONLY"]),current:z9.boolean(),createdAt:z9.iso.datetime({offset:true})});var ImportedVisualNormalizationViewSchema=z9.strictObject({normalizationId:Uuid,runtimeJobId:Uuid,sourceId:Uuid,sourceVersionId:Uuid,lifecycle:z9.string(),cancellationRequested:z9.boolean(),receipt:ImportedVisualNormalizationReceiptSchema.nullable(),output:z9.strictObject({artifactId:Uuid,representationId:Uuid,posterArtifactId:Uuid,posterRepresentationId:Uuid}).nullable()});import{z as z10}from"zod";var id=z10.uuid().toLowerCase();var SourceSyncRuntimeScopeSchema=z10.strictObject({tenantId:id,productionId:id,requestId:id});var SourceSyncRuntimeAdmissionSchema=z10.strictObject({requestId:id,runtimeJobId:id,productionRevision:z10.int().positive()});var SourceSyncRuntimeViewSchema=SourceSyncRuntimeAdmissionSchema.extend({normalizationId:id,lifecycle:z10.enum(["PENDING","READY","RUNNING","WAITING","SUCCEEDED","FAILED","CANCELLED","SUPERSEDED"]),cancellationRequested:z10.boolean(),output:SourceSyncAudioReceiptSchema.nullable()});import{z as z11}from"zod";var id2=z11.uuid().toLowerCase();var hash=z11.string().regex(/^[0-9a-f]{64}$/);var SourceSyncMediaIdentitySchema=z11.strictObject({artifactId:id2,representationId:id2,checksumSha256:hash});var sampleRange=z11.strictObject({startSample:z11.int().nonnegative(),endSample:z11.int().positive()}).refine(v=>v.endSample>v.startSample);var frameRange=z11.strictObject({startFrame:z11.int().nonnegative(),endFrame:z11.int().positive()}).refine(v=>v.endFrame>v.startFrame);var SourceSyncListeningEvidenceSchema=z11.discriminatedUnion("kind",[z11.strictObject({id:z11.string().trim().min(1).max(100),kind:z11.literal("AUDIO_LISTENING"),media:SourceSyncMediaIdentitySchema,coverage:z11.array(sampleRange).min(1).max(64),producer:z11.string().trim().min(1).max(200)}),z11.strictObject({id:z11.string().trim().min(1).max(100),kind:z11.literal("VIDEO_PLAYBACK"),media:SourceSyncMediaIdentitySchema,coverage:z11.array(frameRange).min(1).max(64),producer:z11.string().trim().min(1).max(200)})]);var SourceSyncObservationSchema=z11.strictObject({key:z11.enum(["AUDIBILITY","AUDIO_VISUAL_ALIGNMENT"]),status:z11.enum(["SATISFIED","VIOLATED","NOT_OBSERVABLE"]),confidence:z11.enum(["CLEAR","UNCERTAIN"]),observed:z11.string().trim().min(1).max(2e3),evidenceIds:z11.array(z11.string().trim().min(1).max(100)).max(64)});var SourceSyncReviewTargetSchema=z11.strictObject({version:SourceSyncAudioVersionSchema,audio:SourceSyncMediaIdentitySchema,visual:SourceSyncMediaIdentitySchema,sampleCount:z11.int().positive(),frameCount:z11.int().positive().max(360),currentReviewVersion:z11.int().nonnegative(),declarationScope:z11.literal("ATTRIBUTED_OBSERVATIONS_NOT_LISTENING_ATTESTATION")});var SourceSyncReviewInputSchema=SourceSyncAudioGetSchema.extend({tenantId:id2,productionId:id2,shotId:id2,versionId:id2,expectedReviewVersion:z11.int().nonnegative(),audio:SourceSyncMediaIdentitySchema,visual:SourceSyncMediaIdentitySchema,evidence:z11.array(SourceSyncListeningEvidenceSchema).max(64),observations:z11.array(SourceSyncObservationSchema).length(2),summary:z11.string().trim().min(1).max(4e3),idempotencyKey:z11.string().trim().min(1).max(200)});var SourceSyncReviewRecordSchema=z11.strictObject({id:id2,versionId:id2,reviewVersion:z11.int().positive(),tenantId:id2,productionId:id2,shotId:id2,audio:SourceSyncMediaIdentitySchema,visual:SourceSyncMediaIdentitySchema,evidence:z11.array(SourceSyncListeningEvidenceSchema).max(64),observations:z11.array(SourceSyncObservationSchema).length(2),outcome:z11.enum(["PASS","FAIL","NEEDS_REVIEW"]),summary:z11.string(),createdByPrincipalId:id2,executionClass:z11.enum(["LIVE","TEST_ONLY"]),createdAt:z11.iso.datetime({offset:true})});var SourceSyncReviewGetSchema=SourceSyncAudioGetSchema.extend({tenantId:id2,productionId:id2,shotId:id2,versionId:id2,reviewId:id2});import{z as z12}from"zod";var ImportedVideoReviewRecordSchema=VideoReviewRecordSchema.omit({generationId:true,candidateId:true,preparationId:true,contractId:true,contractFingerprint:true}).extend({sourceKind:z12.literal("IMPORTED"),normalizationId:z12.uuid(),sourceId:z12.uuid(),sourceVersionId:z12.uuid(),planVersionId:z12.uuid(),shotPlanningRevision:z12.int().positive()});var ImportedVideoReviewReceiptSchema=z12.strictObject({semanticStatus:z12.literal("SUCCESS"),review:ImportedVideoReviewRecordSchema,productionRevision:z12.int().positive()});import{z as z13}from"zod";var ImportedVisualCancellationSchema=z13.strictObject({cancellationRequested:z13.boolean()});var ImportedVisualAdmissionSchema=z13.strictObject({semanticStatus:z13.literal("ACCEPTED"),normalizationId:z13.uuid(),runtimeJobId:z13.uuid(),sourceId:z13.uuid(),sourceVersionId:z13.uuid(),productionRevision:z13.int().positive()});var ImportedVisualReviewTargetSchema=ProgrammaticVideoReviewTargetSchema.omit({renderId:true,compositionId:true,compositionVersionId:true,compositionVersion:true,compositionFingerprint:true,renderManifestFingerprint:true}).extend({sourceKind:z13.literal("IMPORTED"),normalizationId:z13.uuid(),sourceId:z13.uuid(),sourceVersionId:z13.uuid(),latestReview:ImportedVideoReviewRecordSchema.nullable()});import{z as z14}from"zod";var ImportedVisualOriginalGetSchema=z14.strictObject({tenantId:z14.uuid(),productionId:z14.uuid(),sourceId:z14.uuid(),version:z14.int().positive().optional()});var ImportedVisualOriginalHistoryQuerySchema=z14.strictObject({tenantId:z14.uuid(),productionId:z14.uuid(),sourceId:z14.uuid(),beforeVersion:z14.int().positive().optional(),limit:z14.int().min(1).max(50).default(20)});var ImportedVisualOriginalHistorySchema=z14.strictObject({sourceId:z14.uuid(),items:z14.array(ImportedVisualOriginalViewSchema).max(50),nextBeforeVersion:z14.int().positive().nullable()});var ImportedVisualOriginalQuerySchema=z14.strictObject({tenantId:z14.uuid().toLowerCase(),productionId:z14.uuid().toLowerCase(),shotId:z14.uuid().toLowerCase().optional(),afterSourceId:z14.uuid().toLowerCase().optional(),limit:z14.int().min(1).max(50).default(20)});var ImportedVisualOriginalPageSchema=z14.strictObject({tenantId:z14.uuid(),productionId:z14.uuid(),items:z14.array(ImportedVisualOriginalViewSchema).max(50),nextAfterSourceId:z14.uuid().nullable()}).refine(p=>p.nextAfterSourceId===null||p.items.at(-1)?.sourceId===p.nextAfterSourceId);import{z as z15}from"zod";var Content=z15.string().min(44).max(178956972).refine(value=>{if(value.length%4||/[^A-Za-z0-9+/=]/.test(value))return false;const padding=value.endsWith("==")?2:value.endsWith("=")?1:0;return value.indexOf("=")===(padding?value.length-padding:-1)},"Invalid base64").refine(value=>{const alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";return value.endsWith("==")?alphabet.indexOf(value.at(-3))%16===0:value.endsWith("=")?alphabet.indexOf(value.at(-2))%4===0:true},"Noncanonical base64");var ImportedVisualOriginalUploadSchema=ImportedVisualOriginalRegisterSchema.extend({contentBase64:Content});var ImportedVisualOriginalRevisionUploadSchema=ImportedVisualOriginalReviseSchema.extend({contentBase64:Content});var ownerOperations2={"imported-visual.query":productionRead(ImportedVisualOriginalQuerySchema,ImportedVisualOriginalPageSchema,()=>["imported-visuals","originals"],i=>({limit:i.limit,afterSourceId:i.afterSourceId,shotId:i.shotId}),[["shotId","items.*.shotId"]]),"imported-visual.register-source":productionWrite(ImportedVisualFromProjectSourceSchema,ImportedVisualOriginalViewSchema,()=>["imported-visuals","originals","from-source"],{identity:[["projectId","projectId"],["shotId","shotId"]]}),"imported-visual.register":operation(ImportedVisualOriginalUploadSchema,ImportedVisualOriginalViewSchema,i=>{const{contentBase64,tenantId,productionId,...fields}=i;return{method:"POST",tenantId,path:path("productions",productionId,"imported-visuals","originals","bytes"),importedVideo:{bytes:Buffer.from(contentBase64,"base64"),metadata:Buffer.from(JSON.stringify(fields)).toString("base64url")}}},[["shotId","shotId"]]),"imported-visual.revise":productionWrite(ImportedVisualOriginalRevisionUploadSchema,ImportedVisualOriginalViewSchema,i=>["imported-visuals","originals",i.sourceId,"revisions"],{pathFields:["sourceId"],identity:[["sourceId","sourceId"],["shotId","shotId"]]}),"imported-visual.original":productionRead(ImportedVisualOriginalGetSchema,ImportedVisualOriginalViewSchema,i=>["imported-visuals","originals",i.sourceId],i=>({version:i.version}),[["sourceId","sourceId"],["version","version"]]),"imported-visual.history":productionRead(ImportedVisualOriginalHistoryQuerySchema,ImportedVisualOriginalHistorySchema,i=>["imported-visuals","originals",i.sourceId,"history"],i=>({limit:i.limit,beforeVersion:i.beforeVersion}),[["sourceId","sourceId"],["sourceId","items.*.sourceId"]]),"imported-visual.normalize":productionWrite(ImportedVisualNormalizeStartSchema,ImportedVisualAdmissionSchema,()=>["imported-visuals","normalizations"],{identity:[["sourceId","sourceId"],["sourceVersionId","sourceVersionId"]]}),"imported-visual.get":productionRead(ImportedVisualGetSchema,ImportedVisualNormalizationViewSchema,i=>["imported-visuals","normalizations",i.normalizationId],void 0,[["normalizationId","normalizationId"]]),"imported-visual.review.target":productionRead(ImportedVisualGetSchema,ImportedVisualReviewTargetSchema,i=>["imported-visuals","normalizations",i.normalizationId,"review-target"],void 0,[["normalizationId","normalizationId"]]),"imported-visual.review.record":productionWrite(ImportedVisualReviewSchema,ImportedVideoReviewReceiptSchema,i=>["imported-visuals","normalizations",i.normalizationId,"reviews"],{pathFields:["normalizationId"],identity:[["normalizationId","review.normalizationId"],["representationId","review.representationId"],["checksumSha256","review.checksumSha256"]]}),"imported-visual.decide":productionWrite(ImportedVisualDecisionSchema,ShotDecisionReceiptSchema,i=>["imported-visuals","normalizations",i.normalizationId,"decisions"],{pathFields:["normalizationId"],identity:[["normalizationId","decision.normalizationId"],["reviewId","decision.reviewId"]]}),"imported-visual.cancel":productionWrite(ImportedVisualGetSchema,z16.strictObject({cancellationRequested:z16.boolean()}),i=>["imported-visuals","normalizations",i.normalizationId,"cancel"],{pathFields:["normalizationId"]})};var importedVisualOperations={...ownerOperations2,"imported-visual.review-target":ownerOperations2["imported-visual.review.target"],"imported-visual.review":ownerOperations2["imported-visual.review.record"]};var versionPath=i=>["source-sync-audios","shots",i.shotId,"versions",i.versionId];var ownerOperations3={"source-sync.start":productionWrite(SourceSyncAudioStartSchema,SourceSyncRuntimeAdmissionSchema,()=>["source-sync-audios","requests"]),"source-sync.get":productionRead(SourceSyncRuntimeScopeSchema,SourceSyncRuntimeViewSchema,i=>["source-sync-audios","requests",i.requestId],void 0,[["requestId","requestId"]]),"source-sync.cancel":productionWrite(SourceSyncRuntimeScopeSchema,ImportedVisualCancellationSchema,i=>["source-sync-audios","requests",i.requestId,"cancel"],{pathFields:["requestId"]}),"source-sync.audio":productionRead(SourceSyncAudioGetSchema,WavExportResultSchema,i=>[...versionPath(i),"audio"]),"source-sync.version":productionRead(SourceSyncAudioGetSchema,SourceSyncAudioViewSchema,versionPath,void 0,[["versionId","version.id"],["shotId","version.shotId"]]),"source-sync.review-target":productionRead(SourceSyncAudioGetSchema,SourceSyncReviewTargetSchema,i=>[...versionPath(i),"review-target"],void 0,[["versionId","version.id"],["shotId","version.shotId"]]),"source-sync.review":productionWrite(SourceSyncReviewInputSchema,SourceSyncReviewRecordSchema,i=>[...versionPath(i),"reviews"],{pathFields:["shotId","versionId"],identity:[["versionId","versionId"],["shotId","shotId"],["audio","audio"],["visual","visual"]]}),"source-sync.review-get":productionRead(SourceSyncReviewGetSchema,SourceSyncReviewRecordSchema,i=>[...versionPath(i),"reviews",i.reviewId],void 0,[["versionId","versionId"],["shotId","shotId"],["reviewId","id"]])};var sourceSyncOperations={...ownerOperations3,"source-sync.review.target":ownerOperations3["source-sync.review-target"],"source-sync.review.record":ownerOperations3["source-sync.review"],"source-sync.review.get":ownerOperations3["source-sync.review-get"]};var Writer=ValidateWriterProposalSchema.extend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.tenantId.toLowerCase());var Director=ValidateDirectorProposalSchema.safeExtend({tenantId:TenantIdSchema}).refine(i=>i.tenantId.toLowerCase()===i.basis.tenantId.toLowerCase());var projectProduction2=(scope,...suffix)=>path("projects",scope.projectId,"productions",scope.productionId,...suffix);var planningIntelligenceOperations={"brief.active":operation(WriterScopeSchema,WriterBriefResultSchema,i=>({method:"GET",tenantId:i.tenantId,path:projectProduction2(i,"brief-versions","active")})),"writer.validate":operation(Writer,WriterValidationResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:projectProduction2(i.basis,"writer-proposals","validate"),body:{basis:i.basis,proposal:i.proposal,...i.revisionReason?{revisionReason:i.revisionReason}:{}}}),[["basis","basis","SUCCESS"]],{readOnly:true}),"director.context":operation(DirectorScopeSchema,DirectorContextResultSchema,i=>({method:"GET",tenantId:i.tenantId,path:projectProduction2(i,"director","context")})),"director.validate":operation(Director,DirectorValidationResultSchema,i=>({method:"POST",tenantId:i.tenantId,path:projectProduction2(i.basis,"director-proposals","validate"),body:{basis:i.basis,proposal:i.proposal,...i.revisionReason?{revisionReason:i.revisionReason}:{}}}),[["basis","basis","SUCCESS"]],{readOnly:true}),"consistency-profile.get":productionRead(ConsistencyProfileScopeSchema,ConsistencyProfileViewSchema,()=>["consistency-profile"]),"consistency-profile.version":productionRead(ConsistencyProfileVersionQuerySchema,ConsistencyProfileVersionSchema,i=>["consistency-profile","versions",i.profileId],void 0,[["profileId","id"]]),"consistency-profile.configure":productionWrite(ConfigureConsistencyProfileSchema,ConsistencyProfileReceiptSchema,()=>["consistency-profile"],{tenantInBody:true})};var audioCaptionOperations={"caption.transcript_draft":productionWrite(CaptionTranscriptPlanSchema,CaptionTranscriptDraftSchema,()=>["captions","transcript-draft"],{readOnly:true}),"caption.author_transcript":productionWrite(AuthorTranscriptCaptionsSchema,CaptionReceiptSchema,()=>["captions","from-transcript"]),"audio.export":mcpOperation(AudioGetSchema,AudioExportResultSchema,true),"caption.export":mcpOperation(CaptionExportSchema,CaptionExportResultSchema,true),"audio.basis":productionRead(AudioScopeSchema,AudioBasisSchema,i=>["audio",i.purpose,"basis"],void 0,[["purpose","purpose"]]),"audio.current":productionRead(AudioScopeSchema,AudioViewSchema,i=>["audio",i.purpose,"current"],void 0,[["purpose","version.purpose"]]),"audio.get":productionRead(AudioGetSchema,AudioViewSchema,i=>["audio",i.purpose,"versions",i.versionId],void 0,[["versionId","version.id"],["purpose","version.purpose"]]),"audio.query":productionRead(AudioQuerySchema,AudioPageSchema,i=>["audio",i.purpose,"versions"],pageQuery,[["purpose","items.*.version.purpose"]]),"audio.import":productionWrite(AudioImportRequestSchema,AudioReceiptSchema,i=>["audio",i.purpose],{pathFields:["purpose"],identity:[["purpose","version.purpose"]]}),"caption.basis":productionRead(CaptionScopeSchema,CaptionBasisSchema,()=>["captions","basis"]),"caption.current":productionRead(CaptionScopeSchema,CaptionViewSchema,()=>["captions","current"]),"caption.get":productionRead(CaptionGetSchema,CaptionViewSchema,i=>["captions","versions",i.versionId],void 0,[["versionId","version.id"]]),"caption.query":productionRead(CaptionQuerySchema,CaptionPageSchema,()=>["captions","versions"],pageQuery),"caption.author":productionWrite(AuthorCaptionsSchema,CaptionReceiptSchema,()=>["captions"])};var discoveryOperations={"artifact.query":operation(ArtifactDiscoveryQuerySchema,ArtifactDiscoveryPageSchema,input=>({method:"GET",tenantId:input.tenantId,path:path("artifact-discovery"),query:{...pageQuery(input),projectId:input.projectId,productionId:input.productionId,family:input.family,search:input.search,lifecycle:input.lifecycle}}))};var temporalEvidenceOperations={"temporal-evidence.read-video":productionWrite(OriginalVideoReadSchema,OriginalVideoResultSchema,()=>["temporal-evidence","original-video"],{tenantInBody:true,readOnly:true,identity:[["tenantId","source.tenantId"],["productionId","source.productionId"],["artifactId","source.artifactId"],["representationId","source.representationId"],["checksumSha256","source.checksumSha256"]]}),"temporal-evidence.target":productionWrite(TemporalEvidenceTargetSchema,TemporalEvidenceSourceSchema,()=>["temporal-evidence","target"],{tenantInBody:true,readOnly:true,identity:[["artifactId","artifactId"],["representationId","representationId"],["checksumSha256","checksumSha256"]]}),"temporal-evidence.start":productionWrite(TemporalEvidenceStartSchema,TemporalEvidenceAdmissionSchema,()=>["temporal-evidence"],{tenantInBody:true,identity:[["artifactId","source.artifactId"],["representationId","source.representationId"],["checksumSha256","source.checksumSha256"]]}),"temporal-evidence.get":productionRead(TemporalEvidenceGetSchema,TemporalEvidenceViewSchema,i=>["temporal-evidence",i.evidenceId],void 0,[["evidenceId","evidenceId"]]),"temporal-evidence.cancel":productionWrite(TemporalEvidenceGetSchema,cancellation,i=>["temporal-evidence",i.evidenceId,"cancel"],{pathFields:["evidenceId"]})};import{createHash as createHash3}from"node:crypto";import{z as z17}from"zod";var render=RoughCutGetSchema.omit({tenantId:true});var mediaInput=z17.discriminatedUnion("kind",[AudioGetSchema.omit({tenantId:true}).extend({kind:z17.literal("AUDIO")}),CaptionExportSchema.omit({tenantId:true}).extend({kind:z17.literal("CAPTION")}),ArtifactDiscoveryMediaSchema.omit({tenantId:true}).extend({kind:z17.literal("DISCOVERED_ARTIFACT"),contentType:DiscoveryContentTypeSchema}),AudioGetSchema.omit({tenantId:true}).extend({kind:z17.literal("AUDIO_WAV")}),CaptionGetSchema.omit({tenantId:true}).extend({kind:z17.enum(["CAPTION_JSON","CAPTION_SRT"])}),TemporalEvidenceGetSchema.omit({tenantId:true}).extend({kind:z17.literal("TEMPORAL_FRAME"),ordinal:z17.int().nonnegative().max(63)}),TemporalEvidenceGetSchema.omit({tenantId:true}).extend({kind:z17.enum(["TEMPORAL_SHEET","TEMPORAL_MANIFEST"])}),VideoGetInputSchema.omit({tenantId:true}).extend({kind:z17.enum(["VIDEO_GENERATION","VIDEO_GENERATION_POSTER"])}),render.extend({kind:z17.literal("CODE_VIDEO")}),render.extend({kind:z17.enum(["ROUGH_CUT_VIDEO","ROUGH_CUT_POSTER","FINAL_VIDEO","FINAL_POSTER"])}),TimelineScopeSchema.omit({tenantId:true}).extend({kind:z17.literal("DELIVERED_VIDEO")}),DeliveryManifestGetSchema.omit({tenantId:true}).extend({kind:z17.literal("DELIVERY_MANIFEST")})]);var expectedInput=z17.strictObject({checksumSha256:z17.string().regex(/^[0-9a-f]{64}$/),byteSize:z17.int().positive().max(128*1024*1024).optional()});async function readNativeMedia(transport,tenantId,raw,expected,options){if(!raw||raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==tenantId.toLowerCase()))sdkInputError();const parsed=mediaInput.safeParse(Object.fromEntries(Object.entries(raw).filter(([key])=>key!=="tenantId"))),identity=expectedInput.safeParse({checksumSha256:expected?.checksumSha256,byteSize:expected?.byteSize});if(!parsed.success||!identity.success)sdkInputError();const input=parsed.data;let suffix,contentType;if(input.kind==="DISCOVERED_ARTIFACT"){suffix=[];contentType=input.contentType}else if(input.kind==="AUDIO"||input.kind==="AUDIO_WAV"){suffix=["audio",input.purpose,"versions",input.versionId,"export"];contentType="audio/wav"}else if("versionId"in input){suffix=["captions","versions",input.versionId,"export"];contentType=(input.kind==="CAPTION"?input.format==="JSON":input.kind==="CAPTION_JSON")?"application/json":"application/x-subrip"}else if("evidenceId"in input){const kind=input.kind==="TEMPORAL_FRAME"?"FRAME":input.kind==="TEMPORAL_SHEET"?"SHEET":"MANIFEST";if(!TemporalEvidenceMediaSchema.safeParse({tenantId,productionId:input.productionId,evidenceId:input.evidenceId,kind,...input.kind==="TEMPORAL_FRAME"?{ordinal:input.ordinal}:{}}).success)sdkInputError();suffix=["temporal-evidence",input.evidenceId,"media",kind];contentType=kind==="MANIFEST"?"application/json":"image/png"}else if("generationId"in input){suffix=["video-generations",input.generationId,input.kind==="VIDEO_GENERATION"?"media":"poster"];contentType=input.kind==="VIDEO_GENERATION"?"video/mp4":"image/png"}else if(input.kind==="DELIVERED_VIDEO"){suffix=["deliveries","media"];contentType="video/mp4"}else if(input.kind==="CODE_VIDEO"){suffix=["compositions","renders",input.renderId,"media"];contentType="video/mp4"}else if(input.kind==="DELIVERY_MANIFEST"){suffix=["deliveries","manifests",input.manifestId,"download"];contentType="application/json"}else{const poster=input.kind.endsWith("POSTER");suffix=[input.kind.startsWith("ROUGH_CUT")?"rough-cuts":"final-renders",input.renderId,poster?"poster":"media"];contentType=poster?"image/png":"video/mp4"}const result=await transport.binary({method:"GET",tenantId,path:input.kind==="DISCOVERED_ARTIFACT"?path("projects",input.projectId,"artifacts",input.artifactId,"representations",input.representationId,"media"):path("productions",input.productionId,...suffix),...input.kind==="TEMPORAL_FRAME"?{query:{ordinal:input.ordinal}}:{},...input.kind==="CAPTION"?{query:{format:input.format}}:{},...input.kind==="CAPTION_JSON"||input.kind==="CAPTION_SRT"?{query:{format:input.kind==="CAPTION_JSON"?"JSON":"SRT"}}:{}},[contentType],Math.min(identity.data.byteSize??128*1024*1024,input.kind==="AUDIO"||input.kind==="AUDIO_WAV"?12582912:input.kind.startsWith("CAPTION")?131072:128*1024*1024),options);const checksumSha256=createHash3("sha256").update(result.bytes).digest("hex");if(checksumSha256!==identity.data.checksumSha256||identity.data.byteSize!==void 0&&result.bytes.byteLength!==identity.data.byteSize||result.etag&&result.etag!==`"${checksumSha256}"`)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{...result,checksumSha256}}var sdkOperations=Object.freeze({...coreOperations,...navigationOperations,...discoveryOperations,...agentHostOperations,...agentHostExecutionOperations,...nativeToolAuthorityOperations,...compositionOperations,...assemblyOperations,...editorOperations,...reviewerOperations,...repairStrategyOperations,...canonicalRepairOperations,...programmaticReviewOperations,...compositionSourceOperations,...programmaticExplorationOperations,...deliveryOperations,...shotPreparationOperations,...generationOperations,...keyframeReviewOperations,...videoReviewOperations,...providerOperations,...speechOperations,...observationOperations,...soundMakingPlanOperations,...lifecycleEventOperations,...temporalEvidenceOperations,...audioCaptionOperations,...planningIntelligenceOperations,...importedVisualOperations,...sourceSyncOperations,...visualExplorationOperations,...referencePreviewOperations,...mediaDescriptorOperations});var NativeStudioAgentClient=class{navigation=new NativeStudioNavigationFacade(this);tenantId;transport;constructor(config){const tenant=TenantIdSchema.safeParse(config.tenantId);if(!tenant.success)sdkInputError();this.tenantId=tenant.data.toLowerCase();this.transport=new NativeStudioHttpTransport(config)}async call(key,raw,options={}){if(!Object.hasOwn(sdkOperations,key)||!raw||typeof raw!=="object"||Array.isArray(raw))sdkInputError();if(raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==this.tenantId))sdkInputError();const spec=sdkOperations[key];if(spec.request===null)throw new NativeStudioSdkError("CAPABILITY_UNAVAILABLE","CAPABILITY_UNAVAILABLE","NO_WRITE");const parsed=spec.input.safeParse({...raw,tenantId:this.tenantId});if(!parsed.success)sdkInputError();const request=spec.request(parsed.data);const result=await this.transport.json({...request,readOnly:spec.readOnly},spec.output,options);assertResponseBindings(result,parsed.data,spec.identity,spec.readOnly?"GET":request.method,void 0,spec.identityWhenPresent);if(key==="temporal-evidence.read-video")assertOriginalVideoBytes(result);if(key==="source-sync.audio")assertExportBytes(result);return result}async sourceMedia(raw,options={},expected){if(Object.hasOwn(raw,"tenantId"))sdkInputError();const parsed=SourceLibraryMediaSchema.safeParse({...raw,tenantId:this.tenantId});if(!parsed.success)sdkInputError();const input=parsed.data;const result=await this.transport.binary({method:"GET",tenantId:this.tenantId,path:path("projects",input.projectId,"source-artifacts",input.artifactId,"media")},["image/png","image/jpeg","image/webp","text/plain","application/json"],8*1024*1024,options);const checksumSha256=createHash4("sha256").update(result.bytes).digest("hex");if(result.etag&&result.etag!==`"${checksumSha256}"`||expected&&(expected.checksumSha256!==checksumSha256||expected.byteSize!==result.bytes.byteLength))throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{...result,checksumSha256}}media(input,expected,options={}){return readNativeMedia(this.transport,this.tenantId,input,expected,options)}async keyframeMedia(raw,expected,options={}){if(!raw||Object.hasOwn(raw,"tenantId")||!/^[a-f0-9]{64}$/.test(expected?.checksumSha256??"")||expected?.byteSize!==void 0&&(!Number.isSafeInteger(expected.byteSize)||expected.byteSize<1||expected.byteSize>8*1024*1024))sdkInputError();const parsed=KeyframeGetInputSchema.safeParse({...raw,tenantId:this.tenantId});if(!parsed.success)sdkInputError();const i=parsed.data,value=await this.transport.json({method:"GET",tenantId:this.tenantId,path:path("productions",i.productionId,"keyframe-generations",i.generationId,"media")},KeyframeMediaSchema,options);const bytes=Buffer.from(value.contentBase64,"base64"),checksumSha256=createHash4("sha256").update(bytes).digest("hex");if(bytes.toString("base64")!==value.contentBase64||bytes.length!==value.byteSize||checksumSha256!==value.checksumSha256||checksumSha256!==expected.checksumSha256||expected.byteSize!==void 0&&bytes.length!==expected.byteSize)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{bytes,checksumSha256,contentType:value.contentType}}};import{createHash as createHash5}from"node:crypto";function assertPreviewBytes(value){const v=value;if(v.semanticStatus!=="SUCCESS")return;const data=v.contentBase64;if(typeof data!=="string"||data.length>4*Math.ceil(8*1024*1024/3))throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");const bytes=Buffer.from(data,"base64");if(bytes.length!==v.byteSize||bytes.toString("base64")!==data||!bytes.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))||createHash5("sha256").update(bytes).digest("hex")!==v.checksumSha256)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}import{createHash as createHash6}from"node:crypto";import{z as z18}from"zod";var Input=z18.discriminatedUnion("kind",[KeyframeGetInputSchema.extend({kind:z18.literal("KEYFRAME")}),VideoGetInputSchema.extend({kind:z18.literal("VIDEO_POSTER")}),RoughCutGetSchema.extend({kind:z18.enum(["ROUGH_CUT_POSTER","FINAL_POSTER"])})]);var sdkImageMediaTools={KEYFRAME:"keyframe_media",VIDEO_POSTER:"video_poster",ROUGH_CUT_POSTER:"rough_cut_poster",FINAL_POSTER:"final_render_poster"};var Identity=z18.strictObject({checksumSha256:z18.string().regex(/^[0-9a-f]{64}$/),byteSize:z18.int().positive().max(16*1024*1024).optional()});var Metadata=KeyframeMediaSchema.omit({contentBase64:true});async function readMcpImageMedia(config,raw,expected,options){if(!raw||raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==config.tenantId))sdkInputError();const input=Input.safeParse({...raw,tenantId:config.tenantId}),identity=Identity.safeParse(expected);if(!input.success||!identity.success)sdkInputError();const{kind,...argumentsInput}=input.data;const timeout=AbortSignal.timeout(config.timeoutMs),signal=options.signal?AbortSignal.any([timeout,options.signal]):timeout;if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let response;try{response=await abortable(config.client.callTool({name:sdkImageMediaTools[kind],arguments:argumentsInput},{signal,timeout:config.timeoutMs}),signal)}catch{throw new NativeStudioSdkError(signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}try{if(Buffer.byteLength(JSON.stringify(response),"utf8")>config.maxJsonBytes)throw Error();const envelope=z18.object({semanticStatus:InterfaceSemanticStatusSchema,data:z18.unknown().optional(),error:z18.object({code:z18.string()}).optional()}).parse(response.structuredContent);if(response.isError||envelope.semanticStatus!=="SUCCESS"){const status=["SUCCESS","ACCEPTED"].includes(envelope.semanticStatus)?"INTERNAL_OPERATIONAL_FAILURE":envelope.semanticStatus;throw new NativeStudioSdkError(envelope.error&&nativeFailureCodes.has(envelope.error.code)?envelope.error.code:status,status,"NO_WRITE")}const metadata=Metadata.parse(envelope.data),images=response.content.filter(c=>c.type==="image");if(images.length!==1||response.content.length!==1)throw Error();const block=images[0],bytes=Buffer.from(block.data,"base64"),checksumSha256=createHash6("sha256").update(bytes).digest("hex");if(bytes.toString("base64")!==block.data||bytes.length!==metadata.byteSize||block.mimeType!==metadata.contentType||checksumSha256!==metadata.checksumSha256||checksumSha256!==identity.data.checksumSha256||identity.data.byteSize!==void 0&&bytes.length!==identity.data.byteSize)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{...metadata,bytes}}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}}var sdkMcpTools=Object.freeze({"studio.capability.groups":"studio_capability_groups","studio.start":"studio_start","studio.capability.search":"studio_capability_search","studio.capability.describe":"studio_capability_describe","studio.navigate":"studio_navigate","sound-plan.context":"sound_plan_context","sound-plan.get":"sound_plan_get","sound-plan.validate":"sound_plan_validate","sound-plan.accept":"sound_plan_accept","media-observation.options":"media_observation_options","media-observation.start":"media_observation_start","media-observation.get":"media_observation_get","media-observation.cancel":"media_observation_cancel","production-guidance.context":"production_guidance_context","speech.options":"speech_options","provider.model.get":"provider_model_get","speech.start":"speech_start","speech.get":"speech_get","speech.cancel":"speech_cancel","provider.model.query":"provider_model_catalog_query","provider.model.configure":"provider_model_configure","provider.model.disable":"provider_model_disable","artifact.query":"artifact_discovery_query","imported-visual.query":"imported_visual_query","imported-visual.review.target":"imported_visual_review_target","imported-visual.review.record":"imported_visual_review","source-sync.review.target":"source_sync_review_target","source-sync.review.record":"source_sync_review","source-sync.review.get":"source_sync_review_get","exploration.validate":"exploration_plan_validate","temporal-evidence.read-video":"temporal_evidence_read_video","temporal-evidence.target":"temporal_evidence_target","temporal-evidence.start":"temporal_evidence_start","temporal-evidence.get":"temporal_evidence_get","temporal-evidence.cancel":"temporal_evidence_cancel","visual-sequence.register":"visual_sequence_register","visual-sequence.get":"visual_sequence_get","visual-sequence.query":"visual_sequence_query","project.create":"project_create","production.create":"production_create","production.terminate":"production_terminate","project.query":"project_query","project.get":"project_get","source.query":"source_query","source.ingest":"source_ingest","source.text":"source_read","production.query":"production_query","production.snapshot":"production_snapshot","brief.accept":"brief_accept","story.accept":"story_accept","scene-shot-plan.accept":"scene_shot_plan_accept","story.query":"story_query","story.active":"story_active","scene-shot-plan.query":"scene_shot_plan_query","scene-shot-plan.active":"scene_shot_plan_active","operation.query":"operation_query","operation.get":"operation_get","agent-host.get":"agent_host_binding_get","agent-host.readiness":"agent_host_readiness","agent-host.history":"agent_host_binding_history","agent-host.configure":null,"agent-host.selection.update":"agent_host_selection_update","agent-host.revoke":"agent_host_binding_revoke","agent-host-execution.start":"agent_host_execution_start","agent-host-execution.get":"agent_host_execution_get","agent-host-execution.query":"agent_host_execution_query","agent-host-execution.events":"agent_host_execution_events","agent-host-execution.dispatch":"agent_host_execution_dispatch","agent-host-execution.reconcile":"agent_host_execution_reconcile","agent-host-execution.cancel":"agent_host_execution_cancel","native-tool-grant.configure":"native_tool_grant_configure","native-tool-grant.get":"native_tool_grant_get","native-tool-grant.revoke":"native_tool_grant_revoke","composition.capabilities":"composition_capabilities","composition.brief":"composition_brief","composition.put-input":"composition_put_input","composition.making.validate":"composition_making_validate","composition.validate":"composition_validate","composition.create":"composition_create","composition.revise":"composition_revise","composition.get":"composition_get","composition.history":"composition_history","composition.render":"composition_render","composition.render.get":"composition_render_get","composition.render.query":"composition_render_query","composition.render.cancel":"composition_render_cancel","composition.sample":"composition_sample","composition.observe":"composition_observe","timeline.basis":"timeline_basis","timeline.build":"timeline_build","timeline.current":"timeline_current","timeline.get":"timeline_get","timeline.query":"timeline_query","rough-cut.start":"rough_cut_start","rough-cut.get":"rough_cut_get","rough-cut.query":"rough_cut_query","rough-cut.cancel":"rough_cut_cancel","rough-cut.review.target":"rough_cut_review_target","rough-cut.review.record":"rough_cut_review_record","rough-cut.review.query":"rough_cut_review_query","rough-cut.finding.query":"rough_cut_finding_query","final-ready.get":"final_ready_get","final-ready.decide":"final_ready_decide","final-ready.revoke":"final_ready_revoke","final-ready.query":"final_ready_query","final-render.eligibility":"final_render_eligibility","final-render.start":"final_render_start","final-render.get":"final_render_get","final-render.query":"final_render_query","final-render.cancel":"final_render_cancel","editor.context":"editor_context","editor.validate":"editor_validate","reviewer.final-output-context":"reviewer_final_output_context","reviewer.context":"reviewer_context","reviewer.validate":"reviewer_proposal_validate","repair-strategy.review1.context":"repair_strategy_review1_context","repair-strategy.review1.validate":"repair_strategy_review1_validate","repair-strategy.context":"repair_strategy_context","repair-strategy.validate":"repair_strategy_validate","canonical-repair.author":"repair_author","canonical-repair.author-review1":"repair_author_review1","canonical-repair.proof-review1":"repair_proof_review1","canonical-repair.get":"repair_get","canonical-repair.execute":"repair_execute","canonical-repair.proof":"repair_proof","programmatic-review.target":"composition_review_target","programmatic-review.record":"composition_review_record","programmatic-review.query":"composition_review_query","programmatic-review.decide":"composition_acceptance_decide","composition.source.inspect":"composition_source_inspect","reviewer.source-context":"reviewer_source_context","exploration.programmatic.compare":"exploration_programmatic_compare","exploration.programmatic.recommendation.context":"exploration_programmatic_recommendation_context","exploration.programmatic.recommendation.validate":"exploration_programmatic_recommendation_validate","delivery.policy.configure":"delivery_configure","delivery.policy.get":"delivery_policy","delivery.snapshot":"delivery_snapshot","delivery.target":"delivery_target","delivery.start":"delivery_start","delivery.get":"delivery_get","delivery.approve":"delivery_approve","delivery.cancel":"delivery_cancel","delivery.manifest":"delivery_manifest","shot-preparation.prepare":"shot_prepare","shot-preparation.get":"shot_preparation_get","shot-preparation.active":"shot_preparation_active","shot-preparation.query":"shot_preparation_query","keyframe.start":"keyframe_start","keyframe.get":"keyframe_get","imported-visual.register-source":"imported_visual_register_source","imported-visual.register":"imported_visual_register","imported-visual.revise":"imported_visual_revise","imported-visual.original":"imported_visual_original","imported-visual.history":"imported_visual_history","imported-visual.normalize":"imported_visual_normalize","imported-visual.get":"imported_visual_get","imported-visual.review-target":"imported_visual_review_target","imported-visual.review":"imported_visual_review","imported-visual.decide":"imported_visual_decide","imported-visual.cancel":"imported_visual_cancel","source-sync.start":"source_sync_start","source-sync.get":"source_sync_get","source-sync.cancel":"source_sync_cancel","source-sync.version":"source_sync_version","source-sync.review-target":"source_sync_review_target","source-sync.review":"source_sync_review","source-sync.review-get":"source_sync_review_get","exploration.context":"exploration_context","exploration.plan.validate":"exploration_plan_validate","exploration.compare":"exploration_compare","exploration.recommendation.context":"exploration_recommendation_context","exploration.recommendation.validate":"exploration_recommendation_validate","composition.render.media-target":"composition_render_media","delivery.download":"delivery_download","temporal-evidence.download":"temporal_evidence_download","video.options":"video_options","studio.capabilities":"studio_capabilities","reference-preview.start":"reference_preview_start","reference-preview.status":"reference_preview_status","reference-preview.get":"reference_preview_get","reference-preview.cancel":"reference_preview_cancel","brief.active":"brief_active","writer.validate":"writer_proposal_validate","director.context":"director_context","director.validate":"director_proposal_validate","consistency-profile.get":"consistency_profile_get","consistency-profile.version":"consistency_profile_version","consistency-profile.configure":"consistency_profile_configure","audio.export":"audio_export","caption.export":"caption_export","source-sync.audio":"source_sync_audio","audio.basis":"audio_basis","audio.current":"audio_current","audio.get":"audio_get","audio.query":"audio_query","audio.import":"audio_import","caption.basis":"caption_basis","caption.current":"caption_current","caption.get":"caption_get","caption.query":"caption_query","caption.author":"caption_author","caption.transcript_draft":"caption_transcript_draft","caption.author_transcript":"caption_author_transcript","keyframe.query":"keyframe_query","keyframe.cancel":"keyframe_cancel","video.start":"video_start","video.get":"video_get","video.query":"video_query","video.cancel":"video_cancel","keyframe-review.target":"keyframe_review_target","keyframe-review.record":"keyframe_review_record","keyframe-review.query":"keyframe_review_query","keyframe-review.decide":"keyframe_reference_decide","keyframe-reference.get":"keyframe_reference_get","keyframe-reference.query":"keyframe_reference_query","keyframe-reference.revoke":"keyframe_reference_revoke","video-review.target":"video_review_target","video-review.record":"video_review_record","video-review.query":"video_review_query","video-review.decide":"shot_acceptance_decide","shot-acceptance.get":"shot_acceptance_get","shot-acceptance.query":"shot_acceptance_query","shot-acceptance.revoke":"shot_acceptance_revoke","provider.configure":null,"provider.query":"provider_connection_query","provider.models":"provider_model_query","provider.keyframe-default.set":"provider_keyframe_default_set","provider.disable":"provider_connection_disable","provider.revoke":"provider_credential_revoke","webhook.configure":"webhook_configure","webhook.disable":"webhook_disable","webhook.replay":"webhook_replay","lifecycle-event.capabilities":"lifecycle_events_capabilities","lifecycle-event.subscriptions":"lifecycle_events_query","lifecycle-event.events":"lifecycle_events_query","lifecycle-event.deliveries":"lifecycle_events_query","lifecycle-event.attempts":"lifecycle_events_query"});var nestedScope=new Set(["exploration.validate","writer.validate","exploration.context","exploration.plan.validate","exploration.compare","exploration.recommendation.context","exploration.recommendation.validate","director.validate","editor.context","editor.validate","reviewer.final-output-context","reviewer.context","reviewer.validate","reviewer.source-context","repair-strategy.context","repair-strategy.validate","repair-strategy.review1.validate","exploration.programmatic.compare","exploration.programmatic.recommendation.context","exploration.programmatic.recommendation.validate","canonical-repair.author"]);var projectInPath=new Set(["canonical-repair.proof-review1","canonical-repair.get","canonical-repair.execute","canonical-repair.proof"]);function sdkMcpInput(key,input){return Object.fromEntries(Object.entries(input).filter(([k])=>!(k==="tenantId"&&nestedScope.has(key))&&!(k==="projectId"&&projectInPath.has(key))))}import{createHash as createHash7}from"node:crypto";import{z as z19}from"zod";var expectedSchema=z19.strictObject({checksumSha256:z19.string().regex(/^[a-f0-9]{64}$/),byteSize:z19.int().positive().max(16*1024*1024).optional()});async function readMcpEvidenceImage(config,raw,expected,options){if(!raw||raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==config.tenantId))sdkInputError();const input=TemporalEvidenceImageSchema.safeParse({...raw,tenantId:config.tenantId}),identity=expectedSchema.safeParse({checksumSha256:expected?.checksumSha256,byteSize:expected?.byteSize});if(!input.success||!identity.success)sdkInputError();const deadline=AbortSignal.timeout(config.timeoutMs),signal=options.signal?AbortSignal.any([options.signal,deadline]):deadline;if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let reply;try{reply=await abortable(config.client.callTool({name:"temporal_evidence_read_image",arguments:input.data},{signal,timeout:config.timeoutMs}),signal)}catch{throw new NativeStudioSdkError(signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}try{if(Buffer.byteLength(JSON.stringify(reply),"utf8")>config.maxJsonBytes)throw Error();const texts=reply.content.filter(block2=>block2.type==="text"),images=reply.content.filter(block2=>block2.type==="image");const carrier=reply.structuredContent!==void 0?reply.structuredContent:texts.length===1?JSON.parse(texts[0].text):void 0;const envelope=z19.object({semanticStatus:InterfaceSemanticStatusSchema,data:z19.unknown().optional(),error:z19.object({code:z19.string()}).optional()}).parse(carrier);if(reply.isError)throw new NativeStudioSdkError(envelope.error&&nativeFailureCodes.has(envelope.error.code)?envelope.error.code:envelope.semanticStatus,envelope.semanticStatus==="SUCCESS"||envelope.semanticStatus==="ACCEPTED"?"INTERNAL_OPERATIONAL_FAILURE":envelope.semanticStatus,"REJECTED");if(envelope.semanticStatus!=="SUCCESS"||images.length!==1||(reply.structuredContent!==void 0?reply.content.length!==1||texts.length!==0:reply.content.length!==2||texts.length!==1))throw Error();const metadata=TemporalEvidenceImageMetadataSchema.parse(envelope.data);assertResponseBindings(metadata,input.data,[["evidenceId","evidenceId"],["kind","kind"],["ordinal","ordinal"]],"GET");const block=images[0],bytes=Buffer.from(block.data,"base64"),checksumSha256=createHash7("sha256").update(bytes).digest("hex");if(block.mimeType!==metadata.contentType||bytes.toString("base64")!==block.data||bytes.byteLength!==metadata.byteSize||checksumSha256!==metadata.checksumSha256||checksumSha256!==identity.data.checksumSha256||identity.data.byteSize!==void 0&&bytes.byteLength!==identity.data.byteSize)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{...metadata,bytes}}catch(e){if(e instanceof NativeStudioSdkError)throw e;throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}}import{createHash as createHash8}from"node:crypto";import{z as z20}from"zod";var inputSchema=z20.discriminatedUnion("kind",[AudioGetSchema.extend({kind:z20.literal("AUDIO_WAV")}),CaptionGetSchema.extend({kind:z20.enum(["CAPTION_JSON","CAPTION_SRT"])}),SourceSyncAudioGetSchema.extend({kind:z20.literal("SOURCE_SYNC_WAV")})]);var expectedSchema2=z20.strictObject({checksumSha256:z20.string().regex(/^[0-9a-f]{64}$/),byteSize:z20.int().positive().max(12582912).optional()});var outputSchema=z20.strictObject({semanticStatus:z20.literal("SUCCESS"),data:z20.strictObject({contentType:z20.enum(["audio/wav","application/json","application/x-subrip"]),checksumSha256:z20.string().regex(/^[0-9a-f]{64}$/),representationId:z20.uuid().optional(),byteSize:z20.int().positive().max(12582912).optional(),contentBase64:z20.string().max(16777216).optional(),text:z20.string().max(131072).optional()})});async function readMcpAuxiliaryMedia(config,raw,expected,options){if(!raw||raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==config.tenantId))sdkInputError();const parsed=inputSchema.safeParse({...raw,tenantId:config.tenantId}),identity=expectedSchema2.safeParse(expected);if(!parsed.success||!identity.success)sdkInputError();const{kind,...arguments_}=parsed.data;const name=kind==="AUDIO_WAV"?"audio_export":kind==="SOURCE_SYNC_WAV"?"source_sync_audio":"caption_export";const contentType=kind.endsWith("WAV")?"audio/wav":kind==="CAPTION_JSON"?"application/json":"application/x-subrip";const deadline=AbortSignal.timeout(config.timeoutMs),signal=options.signal?AbortSignal.any([options.signal,deadline]):deadline;if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let reply;try{reply=await abortable(config.client.callTool({name,arguments:{...arguments_,...kind.startsWith("CAPTION")?{format:kind==="CAPTION_JSON"?"JSON":"SRT"}:{}}},{signal,timeout:config.timeoutMs}),signal)}catch{throw new NativeStudioSdkError(signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}try{if(Buffer.byteLength(JSON.stringify(reply),"utf8")>config.maxJsonBytes||reply.isError)throw Error();const texts=reply.content.filter(x=>x.type==="text");const result=outputSchema.parse(reply.structuredContent??(texts.length===1?JSON.parse(texts[0].text):void 0)).data;const wav=contentType==="audio/wav";if(result.contentType!==contentType||(wav?result.text!==void 0||result.contentBase64===void 0:result.contentBase64!==void 0||result.text===void 0))throw Error();const bytes=wav?Buffer.from(result.contentBase64,"base64"):Buffer.from(result.text,"utf8");const checksumSha256=createHash8("sha256").update(bytes).digest("hex");if(wav&&bytes.toString("base64")!==result.contentBase64||bytes.length>(wav?12582912:131072)||checksumSha256!==result.checksumSha256||checksumSha256!==identity.data.checksumSha256||result.byteSize!==void 0&&bytes.length!==result.byteSize||identity.data.byteSize!==void 0&&bytes.length!==identity.data.byteSize)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{bytes,contentType,checksumSha256,etag:null}}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}}import{createHash as createHash9}from"node:crypto";import{z as z21}from"zod";var inputSchema2=z21.discriminatedUnion("kind",[KeyframeGetInputSchema.extend({kind:z21.literal("KEYFRAME")}),VideoGetInputSchema.extend({kind:z21.literal("VIDEO_POSTER")}),RoughCutGetSchema.extend({kind:z21.literal("ROUGH_CUT_POSTER")}),FinalRenderGetSchema.extend({kind:z21.literal("FINAL_POSTER")}),ReferencePreviewOperationInputSchema.extend({kind:z21.literal("REFERENCE_PREVIEW")})]);var sdkMcpImageTools=Object.freeze({KEYFRAME:"keyframe_media",VIDEO_POSTER:"video_poster",ROUGH_CUT_POSTER:"rough_cut_poster",FINAL_POSTER:"final_render_poster",REFERENCE_PREVIEW:"reference_preview_get"});var identitySchema=z21.strictObject({checksumSha256:z21.string().regex(/^[a-f0-9]{64}$/),byteSize:z21.int().positive().max(16*1024*1024).optional()});var metadataSchema=z21.strictObject({contentType:z21.enum(["image/png","image/jpeg","image/webp"]),checksumSha256:identitySchema.shape.checksumSha256,byteSize:z21.int().positive().max(16*1024*1024)});async function readMcpImage(config,raw,expected,options){if(!raw||raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==config.tenantId))sdkInputError();const input=inputSchema2.safeParse({...raw,tenantId:config.tenantId}),identity=identitySchema.safeParse(expected);if(!input.success||!identity.success)sdkInputError();const{kind,...arguments_}=input.data;const deadline=AbortSignal.timeout(config.timeoutMs),signal=options.signal?AbortSignal.any([options.signal,deadline]):deadline;if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let reply;try{reply=await abortable(config.client.callTool({name:sdkMcpImageTools[kind],arguments:arguments_},{signal,timeout:config.timeoutMs}),signal)}catch{throw new NativeStudioSdkError(signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}try{if(Buffer.byteLength(JSON.stringify(reply),"utf8")>config.maxJsonBytes)throw Error();const texts=reply.content.filter(b=>b.type==="text"),images=reply.content.filter(b=>b.type==="image");const carrier=reply.structuredContent??(texts.length===1?JSON.parse(texts[0].text):void 0);const envelope=z21.object({semanticStatus:InterfaceSemanticStatusSchema,data:z21.unknown().optional(),error:z21.object({code:z21.string()}).optional()}).parse(carrier);if(reply.isError)throw new NativeStudioSdkError(envelope.error&&nativeFailureCodes.has(envelope.error.code)?envelope.error.code:"RESPONSE_INVALID",envelope.semanticStatus==="SUCCESS"?"INTERNAL_OPERATIONAL_FAILURE":envelope.semanticStatus,"NO_WRITE");if(envelope.semanticStatus!=="SUCCESS"||images.length!==1||reply.content.length!==(kind==="REFERENCE_PREVIEW"?2:1)||texts.length!==(kind==="REFERENCE_PREVIEW"?1:0))throw Error();const metadata=kind==="REFERENCE_PREVIEW"?ReferencePreviewResultSchema.parse(envelope.data):metadataSchema.parse(envelope.data);const block=images[0],bytes=Buffer.from(block.data,"base64"),checksumSha256=createHash9("sha256").update(bytes).digest("hex");if(block.mimeType!==metadata.contentType||bytes.toString("base64")!==block.data||bytes.length>(kind==="KEYFRAME"?8:16)*1024*1024||bytes.length!==metadata.byteSize||checksumSha256!==metadata.checksumSha256||checksumSha256!==identity.data.checksumSha256||identity.data.byteSize!==void 0&&bytes.length!==identity.data.byteSize||"contentBase64"in metadata&&metadata.contentBase64!==block.data)throw new NativeStudioSdkError("MEDIA_IDENTITY_MISMATCH","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");return{bytes,contentType:metadata.contentType,checksumSha256,etag:null}}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}}var NativeStudioMcpClient=class{constructor(config){this.config=config;const tenant=TenantIdSchema.safeParse(config.tenantId);if(!tenant.success||typeof config.client?.callTool!=="function")sdkInputError();this.tenantId=tenant.data.toLowerCase();this.timeout=config.timeoutMs??3e4;this.limit=config.maxJsonBytes??16*1024*1024;if(!Number.isSafeInteger(this.timeout)||this.timeout<1||this.timeout>3e5||!Number.isSafeInteger(this.limit)||this.limit<1024||this.limit>32*1024*1024)sdkInputError()}config;navigation=new NativeStudioNavigationFacade(this);tenantId;timeout;limit;imageMedia(input,expected,options={}){return readMcpImageMedia({...this.config,tenantId:this.tenantId,timeoutMs:this.timeout,maxJsonBytes:this.limit},input,expected,options)}evidenceImage(input,expected,options={}){return readMcpEvidenceImage({...this.config,tenantId:this.tenantId,timeoutMs:this.timeout,maxJsonBytes:this.limit},input,expected,options)}auxiliaryMedia(input,expected,options={}){return readMcpAuxiliaryMedia({...this.config,tenantId:this.tenantId,timeoutMs:this.timeout,maxJsonBytes:this.limit},input,expected,options)}image(input,expected,options={}){return readMcpImage({...this.config,tenantId:this.tenantId,timeoutMs:this.timeout,maxJsonBytes:this.limit},input,expected,options)}async call(key,raw,options={}){if(!Object.hasOwn(sdkOperations,key)||!raw||typeof raw!=="object"||Array.isArray(raw))sdkInputError();if(raw.tenantId!==void 0&&(typeof raw.tenantId!=="string"||raw.tenantId.toLowerCase()!==this.tenantId))sdkInputError();const tool=sdkMcpTools[key];if(tool===null)throw new NativeStudioSdkError("CAPABILITY_UNAVAILABLE","CAPABILITY_UNAVAILABLE","NO_WRITE");const spec=sdkOperations[key],parsed=spec.input.safeParse({...raw,tenantId:this.tenantId});if(!parsed.success)sdkInputError();const input=parsed.data;if(Buffer.byteLength(JSON.stringify(input),"utf8")>18*1024*1024)sdkInputError();const request=spec.request===null?{method:spec.readOnly?"GET":"POST"}:spec.request(input);const write2=request.method==="POST"&&!spec.readOnly,outcome=write2?"UNKNOWN":"NO_WRITE";const signal=options.signal?AbortSignal.any([options.signal,AbortSignal.timeout(this.timeout)]):AbortSignal.timeout(this.timeout);if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let result;try{result=await abortable(this.config.client.callTool({name:tool,arguments:sdkMcpInput(key,input)},{signal,timeout:this.timeout}),signal)}catch{throw new NativeStudioSdkError(write2?"OUTCOME_UNKNOWN":signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE",outcome)}let value;try{if(Buffer.byteLength(JSON.stringify(result),"utf8")>this.limit)throw new Error;if("structuredContent"in result&&result.structuredContent!==void 0)value=result.structuredContent;else if("content"in result&&result.content.length===1&&result.content[0]?.type==="text")value=JSON.parse(result.content[0].text);else throw new Error}catch{throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE",outcome)}const envelope=value&&typeof value==="object"&&!Array.isArray(value)?value:{};if("isError"in result&&result.isError){const status=InterfaceSemanticStatusSchema.safeParse(envelope.semanticStatus);const semantic=status.success&&!["SUCCESS","ACCEPTED"].includes(status.data)?status.data:"INTERNAL_OPERATIONAL_FAILURE";const code=envelope.error&&typeof envelope.error==="object"?envelope.error.code:void 0;throw new NativeStudioSdkError(typeof code==="string"&&nativeFailureCodes.has(code)?code:semantic,semantic,semantic==="INTERNAL_OPERATIONAL_FAILURE"?outcome:"REJECTED")}if(envelope.semanticStatus==="NOT_FOUND"&&envelope.data===void 0)throw new NativeStudioSdkError("NOT_FOUND","NOT_FOUND",write2?"REJECTED":"NO_WRITE");const schema=spec.output;for(const candidate of[value,envelope.data,envelope.data&&typeof envelope.data==="object"&&!Array.isArray(envelope.data)?{...envelope.data,semanticStatus:envelope.semanticStatus}:void 0]){const parsedOutput=schema.safeParse(candidate);if(parsedOutput.success){if(key==="reference-preview.get")assertPreviewBytes(parsedOutput.data);if(key==="temporal-evidence.read-video")assertOriginalVideoBytes(parsedOutput.data);if(key==="audio.export"||key==="caption.export"||key==="source-sync.audio")assertExportBytes(parsedOutput.data,key==="caption.export"&&"format"in input?String(input.format):void 0);assertResponseBindings(parsedOutput.data,input,spec.identity,write2?"POST":"GET",spec.expectedPath?spec.expectedPath(input):void 0,spec.identityWhenPresent);return parsedOutput.data}}throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE",outcome)}};var NativeStudioNavigationClient=class{constructor(config){this.config=config;if(typeof config.client?.listTools!=="function"||typeof config.client?.callTool!=="function")sdkInputError();this.native=new NativeStudioMcpClient({...config,client:{callTool:async(params,options)=>{const definition=this.definitions.get(params.name);const result=await config.client.callTool(params,{...options,...definition?{toolDefinition:definition}:{}});if(params.name==="studio_capability_describe"&&!result.isError){const parsed=CapabilityDescribeSchema.safeParse(result.structuredContent);const projectId=params.arguments?.projectId;if(parsed.success&&parsed.data.tenantId.toLowerCase()===config.tenantId.toLowerCase()&&parsed.data.tool===params.arguments?.tool){this.contexts.set(parsed.data.schemaCursor,{tool:parsed.data.tool,...typeof projectId==="string"?{projectId}:{}});if(this.contexts.size>32)this.contexts.delete(this.contexts.keys().next().value)}}return result}}})}config;native;definitions=new Map;contexts=new Map;async entrypoints(options={}){const timeout=this.config.timeoutMs??3e4;const signal=options.signal?AbortSignal.any([options.signal,AbortSignal.timeout(timeout)]):AbortSignal.timeout(timeout);if(signal.aborted)throw new NativeStudioSdkError("REQUEST_ABORTED","BLOCKED","NO_WRITE");let value;try{value=await abortable(this.config.client.listTools(void 0,{signal,timeout,cacheMode:"bypass"}),signal)}catch{throw new NativeStudioSdkError(signal.aborted?"REQUEST_ABORTED":"TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}if(!value||!Array.isArray(value.tools)||value.nextCursor||value.tools.length>512||value.tools.some(tool=>!PublicToolDefinitionSchema.safeParse(tool).success||tool.inputSchema?.type!=="object")||new Set(value.tools.map(t=>t.name)).size!==value.tools.length||Buffer.byteLength(JSON.stringify(value))>(this.config.maxJsonBytes??16*1024*1024))this.invalid();const names=new Set([...NavigationToolNames,"nvs_open_execution"]);const tools=value.tools.filter(tool=>names.has(tool.name));if(NavigationToolNames.some(name=>!tools.some(tool=>tool.name===name)))this.invalid();this.definitions.clear();this.contexts.clear();for(const tool of tools)this.remember(tool);return{tools}}async selectedSchema(reference,expectedTool,options={}){if(!reference||reference.length>2048||!/^[a-zA-Z0-9_-]{1,120}$/.test(expectedTool))sdkInputError();const context=this.contexts.get(reference);if(context&&context.tool!==expectedTool)this.invalid();const projectId=options.projectId??context?.projectId;const description=await this.native.call("studio.capability.describe",{tool:expectedTool,schemaCursor:reference,...projectId?{projectId}:{}},options);const definition=description.definition;if(!definition||definition.name!==expectedTool||JSON.stringify(definition.inputSchema)!==JSON.stringify(description.inputSchema)||JSON.stringify(definition.outputSchema??null)!==JSON.stringify(description.outputSchema))this.invalid();const selected=definition;this.remember(selected);return{tools:[selected]}}remember(tool){if(!PublicToolDefinitionSchema.safeParse(tool).success||tool.inputSchema?.type!=="object"||Buffer.byteLength(JSON.stringify(tool))>160*1024)this.invalid();this.definitions.delete(tool.name);this.definitions.set(tool.name,structuredClone(tool));if(this.definitions.size>32)this.definitions.delete(this.definitions.keys().next().value)}invalid(){throw new NativeStudioSdkError("RESPONSE_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}};import{setTimeout as delay}from"node:timers/promises";async function*queryPages(client,key,input,options={}){const maxPages=options.maxPages??50,maxItems=options.maxItems??1e3;if(!Number.isSafeInteger(maxPages)||maxPages<1||maxPages>500||!Number.isSafeInteger(maxItems)||maxItems<1||maxItems>1e4)sdkInputError();const seen=new Set;let next=input.next,count=0;if(next)seen.add(next);for(let pageNumber=0;pageNumber<maxPages;pageNumber++){const page=await client.call(key,{...input,...next===void 0?{}:{next}},options);count+=page.items.length;if(count>maxItems)throw new NativeStudioSdkError("OBSERVATION_LIMIT","WAITING_INPUT","NO_WRITE");if(page.page.hasMore&&(!page.page.next||seen.has(page.page.next)))throw new NativeStudioSdkError("CONTINUATION_INVALID","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE");yield page;if(!page.page.hasMore)return;next=page.page.next;seen.add(next)}throw new NativeStudioSdkError("OBSERVATION_LIMIT","WAITING_INPUT","NO_WRITE")}async function waitForOperation(client,input,options={}){const maxPolls=options.maxPolls??60,timeoutMs=options.timeoutMs??9e4,intervalMs=options.intervalMs??1e3;if(!Number.isSafeInteger(maxPolls)||maxPolls<1||maxPolls>1e3||!Number.isSafeInteger(timeoutMs)||timeoutMs<1||timeoutMs>18e5||!Number.isSafeInteger(intervalMs)||intervalMs<10||intervalMs>1e4)sdkInputError();const deadline=AbortSignal.timeout(timeoutMs),signal=options.signal?AbortSignal.any([options.signal,deadline]):deadline;try{for(let poll=0;poll<maxPolls;poll++){const result=await client.call("operation.get",input,{signal});if(!["ACCEPTED","WAITING_PROVIDER","RETRYING"].includes(result.semanticStatus))return result;if(poll<maxPolls-1)await delay(intervalMs,void 0,{signal})}}catch(error){if(!deadline.aborted||options.signal?.aborted)throw error}throw new NativeStudioSdkError("OBSERVATION_LIMIT","WAITING_INPUT","NO_WRITE")}export{CapabilityDescribeSchema,CapabilityGroupsSchema,NativeStudioAgentClient,NativeStudioMcpClient,NativeStudioNavigationClient,NativeStudioNavigationFacade,NativeStudioSdkError,NavigationGroupIdSchema,NavigationGroups,NavigationProfile,NavigationProfileKey,NavigationToolNames,navigationGroup,queryPages,sdkImageMediaTools,sdkMcpTools,sdkOperations,waitForOperation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./_types/sdk/local-runtime-client.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{KeyframeObservationSchema,NativeRuntimePublicKeySchema,ReviewEvidenceMediaSchema,ReviewIntelligenceBasisSchema,ReviewIntelligenceContextResultSchema,RoughCutAdmissionSchema,RoughCutManifestReaderSchema,RoughCutStartSchema,RoughCutTechnicalSchema,ValidateReviewIntelligenceSchema,VisualRequirementSchema}from"./_chunks/chunk-4IOFVNFG.js";import{OperationIdSchema}from"./_chunks/chunk-4M3AGNTZ.js";import{NativeStudioSdkError}from"./_chunks/chunk-6NVIN2NI.js";import{lstat as lstat2,mkdir,open,rename,link,unlink}from"node:fs/promises";import{dirname,isAbsolute as isAbsolute2,join as join2}from"node:path";import{createHash as createHash2}from"node:crypto";import{execFile,spawn}from"node:child_process";import{once}from"node:events";import{readFile,realpath,lstat}from"node:fs/promises";import{createHash,randomUUID}from"node:crypto";import{fileURLToPath}from"node:url";import{join,win32,isAbsolute}from"node:path";var nativeAssetNames=["Bootstrap.ps1","NativeMain.cs","PrivateAccess.cs","PipeBridge.cs","JobNative.cs","JobRunner.cs"];var executable;var assetDirectory;async function windowsHelper(){if(process.platform!=="win32"||process.arch!=="x64")throw Error("WINDOWS_PLATFORM_REQUIRED");return executable??=bootstrap().catch(error=>{executable=void 0;throw error})}async function bootstrap(){const directory=assetDirectory??fileURLToPath(new URL("./dist/native/",import.meta.resolve("@nativestudio/sdk/package.json")));const hash=createHash("sha256");for(const name of nativeAssetNames){hash.update(name+"\n");hash.update(await readFile(join(directory,name)))}const sourceDigest=hash.digest("hex"),system=process.env.SystemRoot??process.env.SYSTEMROOT;if(!system||!win32.isAbsolute(system)||system.startsWith("\\\\"))throw Error("WINDOWS_SYSTEM_UNAVAILABLE");const shell=join(system,"System32/WindowsPowerShell/v1.0/powershell.exe"),script=(await readFile(join(directory,"Bootstrap.ps1"))).toString("utf8");const result=await new Promise((resolve,reject)=>{const child=execFile(shell,["-NoLogo","-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from(script,"utf16le").toString("base64")],{timeout:15e3,maxBuffer:32768,windowsHide:true},(error,stdout)=>error?reject(Error("WINDOWS_HELPER_UNAVAILABLE")):resolve(stdout));child.stdin.on("error",()=>{});child.stdin.end(JSON.stringify({directory,sourceDigest}))});const value=JSON.parse(result);if(value.sourceDigest!==sourceDigest||!/^[a-f0-9]{64}$/.test(value.sha256)||!win32.isAbsolute(value.path))throw Error("WINDOWS_HELPER_INVALID");const path=await realpath(value.path),stat=await lstat(path);if(!stat.isFile()||stat.isSymbolicLink()||stat.nlink!==1||stat.size>2*1024*1024||createHash("sha256").update(await readFile(path)).digest("hex")!==value.sha256)throw Error("WINDOWS_HELPER_INVALID");return path}var service;async function connection(){return service??=(async()=>{const child=spawn(await windowsHelper(),["service",String(process.pid)],{shell:false,windowsHide:true,stdio:["pipe","pipe","pipe"]});const pending=new Map;let bytes=Buffer.alloc(0),stderr=0;const close=()=>{for(const item of pending.values()){clearTimeout(item.timer);item.reject(Error("WINDOWS_HELPER_UNAVAILABLE"))}pending.clear();service=void 0};child.stdout.on("data",part=>{bytes=Buffer.concat([bytes,part]);if(bytes.length>2*1024*1024)return child.kill();for(;;){const end=bytes.indexOf(10);if(end<0)break;const line=bytes.subarray(0,end);bytes=bytes.subarray(end+1);try{const value=JSON.parse(line.toString());const item=pending.get(value.id);if(!item)continue;pending.delete(value.id);clearTimeout(item.timer);if(value.ok)item.resolve(value.data);else item.reject(Error(value.error==="EXISTS"?"EXISTS":"WINDOWS_ACCESS_DENIED"))}catch{child.kill()}}});child.stderr.on("data",b=>{if((stderr+=b.length)>65536)child.kill()});child.on("error",close);child.on("close",close);child.stdin.on("error",close);await once(child,"spawn");child.unref();child.stdout.unref();child.stderr.unref();child.stdin.unref();return{child,pending}})().catch(error=>{service=void 0;throw error})}async function windowsRequest(request3,timeoutMs=1e4,signal){signal?.throwIfAborted();const{child,pending}=await connection();signal?.throwIfAborted();if(child.exitCode!==null||child.signalCode!==null||child.stdin.destroyed)throw Error("WINDOWS_HELPER_UNAVAILABLE");if(pending.size>=32)throw Error("WINDOWS_HELPER_BUSY");const id=randomUUID(),data=JSON.stringify({...request3,id});if(Buffer.byteLength(data)>1024*1024)throw Error("WINDOWS_HELPER_INPUT_LIMIT");return new Promise((resolve,reject)=>{const abort=()=>{child.stdin.write(JSON.stringify({operation:"cancel",target:id})+"\n")};const timer=setTimeout(()=>{abort();pending.delete(id);signal?.removeEventListener("abort",abort);reject(Error("WINDOWS_HELPER_TIMEOUT"))},timeoutMs);pending.set(id,{timer,resolve:v=>{signal?.removeEventListener("abort",abort);resolve(v)},reject:e=>{signal?.removeEventListener("abort",abort);reject(e)}});signal?.addEventListener("abort",abort,{once:true});child.stdin.write(data+"\n");if(signal?.aborted)abort()})}function localSocketPath(root,platform=process.platform){if(platform!=="win32")return join2(root,"runtime.sock");return"\\\\.\\pipe\\nvs-"+createHash2("sha256").update(root.toLowerCase()).digest("hex")}async function privateAccess(path,kind){if(process.platform==="win32"){if(kind!=="pipe")await lstat2(path);await windowsRequest({operation:"check",path,kind});return}const s=await lstat2(path);if(s.isSymbolicLink()||s.uid!==process.getuid?.()||s.mode&63||(kind==="directory"?!s.isDirectory():kind==="pipe"?!s.isSocket():!s.isFile()))throw Error("LOCAL_PERMISSIONS_INVALID")}async function privateDirectory(path,create=false){if(!isAbsolute2(path)||!["win32","darwin","linux"].includes(process.platform))throw Error("LOCAL_LOCATION_INVALID");if(process.platform==="win32")await windowsRequest({operation:create?"directory":"check",path,kind:"directory"});else{if(create)await mkdir(path,{recursive:true,mode:448});await privateAccess(path,"directory")}}import{spawn as spawn2}from"node:child_process";import{Duplex}from"node:stream";import{randomUUID as randomUUID2,createHash as createHash3}from"node:crypto";import{request}from"node:http";import{z as z11}from"zod";import{z}from"zod";var LocalIdSchema=z.uuid().transform(v=>v.toLowerCase());var LocalDigestSchema=z.string().length(64).regex(/^[0-9a-f]{64}$/);var LocalRevisionSchema=z.int().positive();var LocalTimeSchema=z.iso.datetime({offset:true});var LocalPackageVersionSchema=z.string().max(120).regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/).refine(v=>v===v.trim());var LocalProjectScopeSchema=z.strictObject({tenantId:LocalIdSchema,projectId:LocalIdSchema});var LocalWorkScopeSchema=LocalProjectScopeSchema.extend({productionId:LocalIdSchema,runtimeJobId:LocalIdSchema});var LocalPlacementPolicySchema=z.discriminatedUnion("mode",[z.strictObject({mode:z.literal("local-only"),deviceId:LocalIdSchema}),z.strictObject({mode:z.literal("local-preferred"),deviceId:LocalIdSchema}),z.strictObject({mode:z.literal("cloud-only")})]);var LocalPlacementAvailabilitySchema=z.discriminatedUnion("status",[z.strictObject({status:z.literal("AVAILABLE"),deviceId:LocalIdSchema}),z.strictObject({status:z.literal("UNAVAILABLE"),deviceId:LocalIdSchema,reason:z.enum(["OFFLINE","UNQUALIFIED","BUSY"])}),z.strictObject({status:z.literal("DENIED"),reason:z.enum(["FORBIDDEN","APPROVAL_REQUIRED","INVALID_INPUT"])})]);import{z as z2}from"zod";var LocalDevicePlatformSchema=z2.strictObject({os:z2.enum(["darwin","linux","win32"]),architecture:z2.enum(["x64","arm64"])});var EnrollLocalDeviceSchema=z2.strictObject({tenantId:LocalIdSchema,requestId:LocalIdSchema,label:z2.string().trim().min(1).max(120),platform:LocalDevicePlatformSchema,runtimeVersion:LocalPackageVersionSchema,publicKey:NativeRuntimePublicKeySchema});var LocalDeviceViewSchema=EnrollLocalDeviceSchema.omit({requestId:true}).extend({deviceId:LocalIdSchema,revision:LocalRevisionSchema,enrolledByPrincipalId:LocalIdSchema,createdAt:LocalTimeSchema,verifiedAt:LocalTimeSchema.nullable(),revokedAt:LocalTimeSchema.nullable()}).refine(v=>[v.verifiedAt,v.revokedAt].every(time=>time===null||Date.parse(time)>=Date.parse(v.createdAt)));var LocalDeviceChallengeSchema=z2.strictObject({tenantId:LocalIdSchema,deviceId:LocalIdSchema,deviceRevision:LocalRevisionSchema,challengeId:LocalIdSchema,audience:z2.string().min(1).max(2048),issuedAt:LocalTimeSchema,expiresAt:LocalTimeSchema}).refine(v=>{const ttl=Date.parse(v.expiresAt)-Date.parse(v.issuedAt);return ttl>0&&ttl<=3e5});var LocalDeviceProofClaimsSchema=z2.strictObject({protocol:z2.literal("NVS_LOCAL_DEVICE_PROOF_V1"),tenantId:LocalIdSchema,deviceId:LocalIdSchema,deviceRevision:LocalRevisionSchema,challengeId:LocalIdSchema,audience:z2.string().min(1).max(2048),jti:LocalIdSchema,iat:z2.int().nonnegative(),exp:z2.int().positive()}).refine(v=>v.exp>v.iat&&v.exp-v.iat<=60);var ProveLocalDeviceSchema=z2.strictObject({tenantId:LocalIdSchema,deviceId:LocalIdSchema,deviceRevision:LocalRevisionSchema,challengeId:LocalIdSchema,assertion:z2.string().max(4096).regex(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/).meta({writeOnly:true})});var GrantLocalDeviceSchema=LocalProjectScopeSchema.extend({requestId:LocalIdSchema,deviceId:LocalIdSchema,deviceRevision:LocalRevisionSchema,expectedRevision:z2.int().nonnegative(),expiresAt:LocalTimeSchema,capability:z2.literal("ROUGH_CUT_PREVIEW_V1")});var LocalDeviceGrantSchema=GrantLocalDeviceSchema.omit({requestId:true,expectedRevision:true}).extend({grantId:LocalIdSchema,revision:LocalRevisionSchema,approvedByPrincipalId:LocalIdSchema,createdAt:LocalTimeSchema,revokedAt:LocalTimeSchema.nullable()}).refine(v=>Date.parse(v.expiresAt)>Date.parse(v.createdAt));var RevokeLocalDeviceGrantSchema=LocalProjectScopeSchema.extend({grantId:LocalIdSchema,requestId:LocalIdSchema,expectedRevision:LocalRevisionSchema});var RevokeLocalDeviceSchema=z2.strictObject({tenantId:LocalIdSchema,deviceId:LocalIdSchema,requestId:LocalIdSchema,expectedRevision:LocalRevisionSchema});import{z as z3}from"zod";var LocalExecutionProfileSchema=z3.strictObject({kind:z3.literal("ROUGH_CUT_PREVIEW_V1"),profileId:z3.literal("PREVIEW_H264_480P_V1"),contractDigest:LocalDigestSchema});var LocalToolchainSchema=z3.strictObject({platform:LocalDevicePlatformSchema,rendererVersion:LocalPackageVersionSchema,rendererDigest:LocalDigestSchema,ffmpeg:z3.strictObject({version:z3.string().min(1).max(160),binaryDigest:LocalDigestSchema}),ffprobe:z3.strictObject({version:z3.string().min(1).max(160),binaryDigest:LocalDigestSchema}),profile:LocalExecutionProfileSchema});var LocalFrozenWorkSchema=LocalWorkScopeSchema.extend({protocol:z3.literal("NVS_LOCAL_WORK_V1"),operationId:OperationIdSchema,renderId:LocalIdSchema,productionRevision:LocalRevisionSchema,executionClass:z3.enum(["LIVE","TEST_ONLY"]),policy:LocalPlacementPolicySchema,profile:LocalExecutionProfileSchema,manifest:RoughCutManifestReaderSchema,manifestFingerprint:LocalDigestSchema,sources:z3.array(z3.strictObject({artifactId:LocalIdSchema,representationId:LocalIdSchema,checksumSha256:LocalDigestSchema,byteSize:z3.int().positive(),contentType:z3.string().min(1).max(100)})).min(1).max(512)}).superRefine((v,ctx)=>{const t=v.manifest.timeline;if(t.tenantId!==v.tenantId||t.projectId!==v.projectId||t.productionId!==v.productionId||t.executionClass!==v.executionClass)ctx.addIssue({code:"custom",message:"Frozen manifest scope/class mismatch"});if(new Set(v.sources.map(s=>s.representationId)).size!==v.sources.length)ctx.addIssue({code:"custom",message:"Duplicate source representation"})});var LocalLeaseBindingSchema=LocalWorkScopeSchema.extend({attemptId:LocalIdSchema,assignmentRevision:LocalRevisionSchema,workerId:z3.string().min(1).max(200),workFingerprint:LocalDigestSchema,toolchainFingerprint:LocalDigestSchema});var target=z3.discriminatedUnion("kind",[z3.strictObject({kind:z3.literal("DEVICE"),deviceId:LocalIdSchema,deviceRevision:LocalRevisionSchema,grantId:LocalIdSchema,grantRevision:LocalRevisionSchema}),z3.strictObject({kind:z3.literal("SERVER")})]);var LocalExecutionLeaseSchema=LocalLeaseBindingSchema.extend({target,issuedAt:LocalTimeSchema,expiresAt:LocalTimeSchema}).refine(v=>Date.parse(v.expiresAt)>Date.parse(v.issuedAt));var LocalWorkAssignmentSchema=z3.strictObject({work:LocalFrozenWorkSchema,lease:LocalExecutionLeaseSchema,toolchain:LocalToolchainSchema}).superRefine(({work,lease,toolchain},ctx)=>{if(["tenantId","projectId","productionId","runtimeJobId"].some(k=>work[k]!==lease[k]))ctx.addIssue({code:"custom",message:"Assignment work scope mismatch"});const p=work.policy,t=lease.target;if(p.mode==="cloud-only"&&t.kind!=="SERVER"||p.mode==="local-only"&&t.kind!=="DEVICE"||t.kind==="DEVICE"&&(p.mode==="cloud-only"||p.deviceId!==t.deviceId))ctx.addIssue({code:"custom",message:"Assignment contradicts placement policy"});if(work.profile.contractDigest!==toolchain.profile.contractDigest)ctx.addIssue({code:"custom",message:"Unqualified execution profile"})});import{z as z4}from"zod";var output=z4.discriminatedUnion("role",[z4.strictObject({role:z4.literal("VIDEO"),receiptId:LocalIdSchema,checksumSha256:LocalDigestSchema,byteSize:z4.int().positive().max(128*1024*1024),contentType:z4.literal("video/mp4")}),z4.strictObject({role:z4.literal("POSTER"),receiptId:LocalIdSchema,checksumSha256:LocalDigestSchema,byteSize:z4.int().positive().max(2*1024*1024),contentType:z4.literal("image/png")})]);var LocalCompletionSubmissionSchema=LocalLeaseBindingSchema.extend({requestId:LocalIdSchema,outputs:z4.array(output).length(2),technical:RoughCutTechnicalSchema}).superRefine((v,ctx)=>{const video=v.outputs.find(o=>o.role==="VIDEO");if(new Set(v.outputs.map(o=>o.role)).size!==2||new Set(v.outputs.map(o=>o.receiptId)).size!==2||!video||video.checksumSha256!==v.technical.checksumSha256||video.byteSize!==v.technical.byteSize)ctx.addIssue({code:"custom",message:"Exact video/poster receipts required"})});var LocalVerifiedUploadSchema=z4.strictObject({binding:LocalLeaseBindingSchema,output,verifiedAt:LocalTimeSchema});var LocalCompletionReceiptSchema=LocalLeaseBindingSchema.extend({submissionFingerprint:LocalDigestSchema.optional(),semanticStatus:z4.literal("SUCCESS"),requestId:LocalIdSchema,renderId:LocalIdSchema,operationId:OperationIdSchema,artifactId:LocalIdSchema,videoRepresentationId:LocalIdSchema,posterRepresentationId:LocalIdSchema,checksumSha256:LocalDigestSchema,acceptedAt:LocalTimeSchema});var GetLocalCompletionReceiptSchema=LocalLeaseBindingSchema.pick({tenantId:true,projectId:true,productionId:true,runtimeJobId:true}).extend({requestId:LocalIdSchema});import{z as z8}from"zod";import{z as z6}from"zod";import{z as z5}from"zod";var executable2=z5.strictObject({path:z5.string().min(1).max(4096),digest:LocalDigestSchema});var LocalToolSelectionSchema=z5.strictObject({mode:z5.enum(["MANAGED","INSTALLED"]),ffmpeg:executable2,ffprobe:executable2});var LocalRuntimeDescriptorSchema=z6.strictObject({protocol:z6.literal("NVS_RUNTIME_DESCRIPTOR_V1"),version:LocalPackageVersionSchema,node:z6.strictObject({major:z6.literal(24),minMinor:z6.literal(12)}),platform:LocalDevicePlatformSchema,ipcProtocol:z6.literal("NVS_LOCAL_IPC_V1"),workProtocol:z6.literal("NVS_LOCAL_WORK_V1"),journalSchema:z6.literal(1),rendererDigest:LocalDigestSchema,profileDigest:LocalDigestSchema});var LocalSessionConnectorSchema=z6.strictObject({protocol:z6.literal("NVS_LOCAL_CONNECTOR_V1"),stateDirectory:z6.string().min(1).max(4096),credential:z6.string().length(43).regex(/^[A-Za-z0-9_-]{43}$/),expiresAt:LocalTimeSchema,projects:z6.array(LocalProjectScopeSchema).min(1).max(100)});var LocalManagementInventorySchema=z6.strictObject({runtimeRevision:z6.int().positive(),descriptor:LocalRuntimeDescriptorSchema,activeProcesses:z6.int().nonnegative(),pendingExecutions:z6.int().nonnegative(),pendingRequests:z6.int().nonnegative(),pendingRenderers:z6.array(LocalDigestSchema).max(64)});var LocalReleaseAssetSchema=z6.strictObject({url:z6.string().url().max(2048),byteSize:z6.int().positive().max(256*1024*1024),sha512:z6.string().length(128).regex(/^[0-9a-f]{128}$/)});var LocalReleaseSchema=z6.strictObject({descriptor:LocalRuntimeDescriptorSchema,package:LocalReleaseAssetSchema,tools:z6.strictObject({ffmpeg:LocalReleaseAssetSchema.extend({sha256:LocalDigestSchema}),ffprobe:LocalReleaseAssetSchema.extend({sha256:LocalDigestSchema})}).nullable()});var LocalReleaseCatalogueSchema=z6.strictObject({protocol:z6.literal("NVS_LOCAL_RELEASE_CATALOGUE_V1"),issuedAt:LocalTimeSchema,expiresAt:LocalTimeSchema,releases:z6.array(LocalReleaseSchema).min(1).max(32)}).refine(v=>Date.parse(v.expiresAt)>Date.parse(v.issuedAt)&&Date.parse(v.expiresAt)-Date.parse(v.issuedAt)<=7*864e5&&new Set(v.releases.map(r=>[r.descriptor.version,r.descriptor.platform.os,r.descriptor.platform.architecture].join(":"))).size===v.releases.length);var LocalSignedCatalogueSchema=z6.strictObject({catalogue:LocalReleaseCatalogueSchema,signature:z6.string().length(86).regex(/^[A-Za-z0-9_-]{85}[AQgw]$/)});var LocalToolChoiceSchema=z6.discriminatedUnion("mode",[z6.strictObject({mode:z6.literal("MANAGED")}),LocalToolSelectionSchema.extend({mode:z6.literal("INSTALLED")})]);var LocalUpdatePlanSchema=z6.strictObject({protocol:z6.literal("NVS_LOCAL_UPDATE_PLAN_V1"),planId:LocalIdSchema,installationRevision:z6.int().nonnegative(),runtimeRevision:z6.int().positive().nullable(),catalogueFingerprint:LocalDigestSchema,trustFingerprint:LocalDigestSchema.optional(),release:LocalReleaseSchema,toolSelection:LocalToolChoiceSchema.optional(),fingerprint:LocalDigestSchema,createdAt:LocalTimeSchema,expiresAt:LocalTimeSchema});var LocalClientNextActionSchema=z6.strictObject({surface:z6.enum(["CLI","LOCAL_IPC","REMOTE"]),operation:z6.enum(["runtime.status","local.configure","local.install","local.start","local.connect","local.grant","local.status","local.doctor","local.stop","local.update.check","local.update.prepare","local.update.apply","local.update.reconcile","execution.inspect","rough_cut_get","operation_get"]),availability:z6.enum(["AVAILABLE","BLOCKED"]),reason:z6.enum(["READY","INSTALL_REQUIRED","AUTHORIZATION_REQUIRED","VERSION_INCOMPATIBLE","UPDATE_AVAILABLE","RECOVERY_REQUIRED","USER_APPROVAL_REQUIRED","TRUST_REQUIRED","UNAVAILABLE"])});import{z as z7}from"zod";function canonicalLocalJson(value){if(value===null||typeof value==="string"||typeof value==="boolean")return JSON.stringify(value);if(typeof value==="number"&&Number.isFinite(value))return JSON.stringify(value);if(Array.isArray(value))return"["+value.map(canonicalLocalJson).join(",")+"]";if(typeof value==="object")return"{"+Object.entries(value).filter(([,v])=>v!==void 0).sort(([a],[b])=>a<b?-1:a>b?1:0).map(([k,v])=>JSON.stringify(k)+":"+canonicalLocalJson(v)).join(",")+"}";throw new Error("Fingerprint input must be finite JSON data")}var sha=z7.string().regex(/^[a-f0-9]{64}$/);var qualifiedVersion=z7.enum(["0.164.0","0.165.0"]);var LocalAgentGrantSchema=z7.strictObject({protocol:z7.literal("NVS_CODEX_REVIEW_GRANT_V1"),binary:z7.string().min(1).max(4096).startsWith("/"),binaryDigest:sha,version:qualifiedVersion,model:z7.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$/),reasoningEffort:z7.enum(["low","medium","high","xhigh"]).optional(),reviewerLabel:z7.string().trim().min(1).max(100),inference:z7.literal("REMOTE_OPENAI"),remoteUseApproved:z7.literal(true),imageDisclosureApproved:z7.literal(true).optional(),projects:z7.array(LocalProjectScopeSchema).min(1).max(100),expiresAt:z7.iso.datetime({offset:true})});var LocalAgentSnapshotSchema=z7.strictObject({basis:ReviewIntelligenceBasisSchema.extend({target:z7.strictObject({kind:z7.literal("IMAGE"),generationId:z7.uuid()})}),productionRevision:z7.int().positive(),reviewVersion:z7.int().nonnegative(),executionClass:z7.enum(["LIVE","TEST_ONLY"]),media:ReviewEvidenceMediaSchema,requirements:z7.array(VisualRequirementSchema).min(1).max(64),image:z7.strictObject({contentType:z7.literal("image/png"),byteSize:z7.int().positive().max(8388608),width:z7.int().positive().max(4096),height:z7.int().positive().max(4096)}).optional()}).refine(v=>new TextEncoder().encode(JSON.stringify(v)).length<=32768).refine(v=>new Set(v.requirements.map(r=>r.key)).size===v.requirements.length);var LocalAgentProbeSchema=z7.strictObject({configured:z7.boolean(),available:z7.boolean(),reason:z7.enum(["GRANT_REQUIRED","READY","RUNTIME_UNAVAILABLE","GRANT_EXPIRED"]),grantFingerprint:sha.nullable(),inference:z7.literal("REMOTE_OPENAI")});var LocalAgentPlanSchema=z7.strictObject({protocol:z7.literal("NVS_LOCAL_AGENT_REVIEW_V1"),id:z7.uuid(),grantFingerprint:sha,snapshot:LocalAgentSnapshotSchema,expiresAt:z7.iso.datetime({offset:true}),fingerprint:sha});var LocalAgentMetadataAnswerSchema=z7.strictObject({summary:z7.string().trim().min(1).max(1500),observations:z7.array(z7.strictObject({key:z7.string().min(1).max(200),observed:z7.string().trim().min(1).max(1e3)})).min(1).max(64)});var LocalAgentPixelAnswerSchema=z7.strictObject({summary:z7.string().trim().min(1).max(1500),imageReadback:z7.string().trim().min(1).max(800),observations:z7.array(KeyframeObservationSchema.omit({region:true})).min(1).max(64)});var LocalAgentAnswerSchema=z7.union([LocalAgentMetadataAnswerSchema,LocalAgentPixelAnswerSchema]).refine(v=>new TextEncoder().encode(JSON.stringify(v)).length<=96*1024);var LocalAgentImageReceiptSchema=z7.strictObject({protocol:z7.literal("NVS_LOCAL_AGENT_IMAGE_V1"),draftId:z7.uuid(),media:ReviewEvidenceMediaSchema,byteSize:z7.int().positive().max(8388608),contentType:z7.literal("image/png"),width:z7.int().positive().max(4096),height:z7.int().positive().max(4096)});var LocalAgentReviewViewSchema=z7.strictObject({plan:LocalAgentPlanSchema,revision:z7.int().positive(),phase:z7.enum(["PREPARED","RUNNING","RESULT_PENDING","UNKNOWN"]),answer:LocalAgentAnswerSchema.nullable(),imageReceipt:LocalAgentImageReceiptSchema.optional(),provenance:z7.strictObject({adapter:z7.literal("CODEX_METADATA_V1"),binaryDigest:sha,version:qualifiedVersion,model:z7.string().max(100),reasoningEffort:z7.enum(["low","medium","high","xhigh"]).optional(),reviewerLabel:z7.string().max(100),inference:z7.literal("REMOTE_OPENAI"),evidence:z7.enum(["METADATA_ONLY","IMAGE_PIXELS"])})}).refine(v=>{const image=v.plan.snapshot.image,receipt=v.imageReceipt;if(receipt&&(!image||receipt.draftId!==v.plan.id||canonicalLocalJson(receipt.media)!==canonicalLocalJson(v.plan.snapshot.media)||canonicalLocalJson({contentType:receipt.contentType,byteSize:receipt.byteSize,width:receipt.width,height:receipt.height})!==canonicalLocalJson(image)))return false;if(v.phase==="RESULT_PENDING"!==!!v.answer)return false;if(v.answer&&!!image!=="imageReadback"in v.answer)return false;const pixels=v.phase==="RESULT_PENDING"&&!!image;return v.provenance.evidence===(pixels?"IMAGE_PIXELS":"METADATA_ONLY")&&(!pixels||!!receipt)});function localAgentSnapshotFromContext(raw,includeImage=false){const c=ReviewIntelligenceContextResultSchema.parse(raw);if(c.reviewTarget.kind!=="IMAGE"||c.basis.target.kind!=="IMAGE"||c.ownerContext.semanticStatus!=="SUCCESS")throw Error("LOCAL_AGENT_CONTEXT_UNAVAILABLE");const t=c.reviewTarget.target,scope=c.basis.scope;if(!t.runtimeSucceeded||t.candidate.availability!=="AVAILABLE"||t.candidate.freshness!=="CURRENT_BASIS"||!t.productionRunnable||t.freshness!=="CURRENT_BASIS"||t.generationId!==c.basis.target.generationId||t.tenantId!==scope.tenantId||t.projectId!==scope.projectId||t.productionId!==scope.productionId||c.ownerContext.basis.tenantId!==scope.tenantId||c.ownerContext.basis.projectId!==scope.projectId||c.ownerContext.basis.productionId!==scope.productionId)throw Error("LOCAL_AGENT_CONTEXT_UNAVAILABLE");return LocalAgentSnapshotSchema.parse({basis:c.basis,productionRevision:c.ownerContext.basis.productionRevision,reviewVersion:t.reviewVersion,executionClass:t.executionClass,media:{artifactId:t.candidate.artifactId,representationId:t.candidate.representationId,checksumSha256:t.candidate.checksumSha256},requirements:t.requirements,...includeImage?{image:{contentType:t.candidate.contentType,byteSize:t.candidate.byteSize,width:t.candidate.width,height:t.candidate.height}}:{}})}function localAgentNativeProposal(raw){const v=LocalAgentReviewViewSchema.parse(raw);if(v.phase!=="RESULT_PENDING"||!v.answer)throw Error("LOCAL_AGENT_RESULT_UNAVAILABLE");const keys=new Set(v.answer.observations.map(o=>o.key));if(keys.size!==v.answer.observations.length||keys.size!==v.plan.snapshot.requirements.length||v.plan.snapshot.requirements.some(r=>!keys.has(r.key)))throw Error("LOCAL_AGENT_RESULT_UNAVAILABLE");const p=v.provenance;const pixels=p.evidence==="IMAGE_PIXELS";return ValidateReviewIntelligenceSchema.parse({basis:v.plan.snapshot.basis,proposal:{origin:{kind:"EXTERNAL_AGENT_HOST",label:p.reviewerLabel},summary:`${pixels?"IMAGE_PIXELS":"METADATA_ONLY; no visual inspection"}. Codex ${p.version}; model ${p.model}; effort ${p.reasoningEffort??"DEFAULT"}; binary ${p.binaryDigest}; draft ${v.plan.id}; plan ${v.plan.fingerprint}. ${v.answer.summary}`,evidence:pixels?[{id:"original_image",label:"Verified ORIGINAL PNG attachment",producer:"EXTERNAL_AGENT_HOST",kind:"IMAGE_PIXELS",media:v.plan.snapshot.media}]:[],review:{kind:"IMAGE",observations:v.answer.observations.map(o=>({...o,status:pixels&&"status"in o?o.status:"NOT_OBSERVABLE",confidence:pixels&&"confidence"in o?o.confidence:"UNCERTAIN",evidenceIds:pixels?["original_image"]:[]}))}}})}var projectInput=LocalProjectScopeSchema;var LocalExecutionListInputSchema=LocalProjectScopeSchema.extend({after:z8.string().length(64).regex(/^[0-9a-f]{64}$/).nullable().default(null),limit:z8.int().min(1).max(16).default(8)});var LocalIpcCallSchema=z8.discriminatedUnion("operation",[z8.strictObject({operation:z8.literal("agent.grant"),grant:LocalAgentGrantSchema,approval:z8.string().regex(/^[a-f0-9]{64}$/)}),z8.strictObject({operation:z8.literal("agent.probe")}),z8.strictObject({operation:z8.literal("agent.revoke"),approval:z8.string().regex(/^[a-f0-9]{64}$/)}),z8.strictObject({operation:z8.literal("agent.prepare"),snapshot:LocalAgentSnapshotSchema}),z8.strictObject({operation:z8.literal("agent.start"),id:z8.uuid(),expectedRevision:LocalRevisionSchema,approval:z8.string().regex(/^[a-f0-9]{64}$/)}),z8.strictObject({operation:z8.literal("agent.inspect"),id:z8.uuid()}),z8.strictObject({operation:z8.literal("runtime.status")}),z8.strictObject({operation:z8.literal("runtime.doctor")}),z8.strictObject({operation:z8.literal("runtime.inventory")}),z8.strictObject({operation:z8.literal("session.issue"),projects:z8.array(projectInput).min(1).max(100),expiresAt:z8.iso.datetime({offset:true})}),z8.strictObject({operation:z8.literal("runtime.stop"),expectedRuntimeRevision:LocalRevisionSchema}),z8.strictObject({operation:z8.literal("execution.inspect"),input:LocalWorkScopeSchema}),z8.strictObject({operation:z8.literal("execution.list"),input:LocalExecutionListInputSchema}),z8.strictObject({operation:z8.literal("update.check")}),z8.strictObject({operation:z8.literal("update.prepare"),targetVersion:LocalPackageVersionSchema,expectedRuntimeRevision:LocalRevisionSchema}),z8.strictObject({operation:z8.literal("update.apply"),planId:LocalIdSchema,targetVersion:LocalPackageVersionSchema,expectedRuntimeRevision:LocalRevisionSchema})]);var LocalNextActionSchema=z8.strictObject({call:LocalIpcCallSchema,availability:z8.enum(["AVAILABLE","BLOCKED"]),reason:z8.enum(["READY","INSTALL_REQUIRED","AUTHORIZATION_REQUIRED","VERSION_INCOMPATIBLE","UPDATE_AVAILABLE","RECOVERY_REQUIRED"])});var LocalIpcRequestSchema=z8.strictObject({protocol:z8.literal("NVS_LOCAL_IPC_V1"),requestId:LocalIdSchema,call:LocalIpcCallSchema});var LocalVersionReportSchema=z8.strictObject({component:z8.enum(["CLI","SDK","MCP","RUNTIME","MEDIA_TOOLS"]),installedVersion:LocalPackageVersionSchema.nullable(),runningVersion:LocalPackageVersionSchema.nullable(),availableVersion:LocalPackageVersionSchema.nullable(),executablePath:z8.string().min(1).max(4096).nullable(),installOwner:z8.enum(["NPM_GLOBAL","PROJECT","NPX","MANAGED","TARBALL","UNKNOWN"])});var LocalRuntimeStatusSchema=z8.strictObject({protocol:z8.literal("NVS_LOCAL_IPC_V1"),runtimeRevision:LocalRevisionSchema,state:z8.enum(["IDLE","EXECUTING","DRAINING","RECOVERY_REQUIRED"]),journalSchemaVersion:z8.literal(1),workProtocols:z8.array(z8.literal("NVS_LOCAL_WORK_V1")).min(1).max(1),versions:z8.array(LocalVersionReportSchema).max(8),authorizedProjects:z8.array(projectInput).max(100),nextActions:z8.array(LocalNextActionSchema).max(8)});var LocalDoctorReportSchema=z8.strictObject({mode:z8.enum(["MANAGED","INSTALLED"]),availability:z8.enum(["AVAILABLE","UNAVAILABLE"]),reason:z8.enum(["QUALIFIED_PROCESS_TOOLS","MANAGED_TOOLS_MISSING","TOOL_QUALIFICATION_FAILED"]),nativeExecutionReady:z8.boolean(),tools:z8.array(z8.strictObject({name:z8.enum(["FFMPEG","FFPROBE"]),path:z8.string().min(1).max(4096),version:z8.string().min(1).max(200),digest:z8.string().regex(/^[0-9a-f]{64}$/)})).max(2)});var LocalExecutionInspectionSchema=z8.strictObject({binding:LocalLeaseBindingSchema,revision:LocalRevisionSchema,phase:z8.enum(["STAGED","RUNNING","RECOVERY_REQUIRED","OUTPUT_PENDING","RECEIPT_RECORDED","FENCED"]),checkpoint:z8.enum(["ADOPTED","SOURCES_READY","PROCESS_STARTED","OUTPUT_STAGED"])});var LocalExecutionPageSchema=z8.strictObject({items:z8.array(LocalExecutionInspectionSchema).max(16),nextCursor:z8.string().length(64).regex(/^[0-9a-f]{64}$/).nullable()});var LocalIpcErrorCodeSchema=z8.enum(["FORBIDDEN","INVALID_INPUT","FRAME_LIMIT","BUSY","AUTHORIZATION_REQUIRED","REVISION_CONFLICT","CAPABILITY_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","AGENT_APPROVAL_REQUIRED","AGENT_GRANT_REQUIRED","AGENT_OUTCOME_UNKNOWN","AGENT_IMAGE_REQUIRED","AGENT_IMAGE_INVALID","AGENT_IMAGE_BUDGET_EXCEEDED","AGENT_IMAGE_AUTHORIZATION_REQUIRED"]);var LocalIpcResponseSchema=z8.discriminatedUnion("semanticStatus",[z8.strictObject({protocol:z8.literal("NVS_LOCAL_IPC_V1"),requestId:LocalIdSchema,semanticStatus:z8.literal("SUCCESS"),data:z8.union([LocalRuntimeStatusSchema,LocalDoctorReportSchema,LocalExecutionInspectionSchema.nullable(),z8.strictObject({state:z8.literal("DRAINING"),inventory:LocalManagementInventorySchema.optional(),backupPath:z8.string().min(1).max(4096).optional()}),LocalSessionConnectorSchema,LocalManagementInventorySchema,LocalExecutionPageSchema,LocalAgentProbeSchema,LocalAgentReviewViewSchema])}),z8.strictObject({protocol:z8.literal("NVS_LOCAL_IPC_V1"),requestId:LocalIdSchema.nullable(),semanticStatus:z8.enum(["BLOCKED","INVALID_INPUT"]),error:z8.strictObject({code:LocalIpcErrorCodeSchema})})]);import{z as z9}from"zod";var StartLocalPreviewSchema=RoughCutStartSchema.extend({placement:LocalPlacementPolicySchema});var LocalDeviceScopeSchema=z9.strictObject({tenantId:LocalIdSchema,deviceId:LocalIdSchema});var LocalDeviceSessionSchema=z9.strictObject({...LocalDeviceScopeSchema.shape,expiresAt:LocalTimeSchema,credential:z9.string().length(43).regex(/^[A-Za-z0-9_-]+$/).meta({writeOnly:true})});var LocalDeviceHeartbeatSchema=LocalDeviceScopeSchema.extend({toolchain:LocalToolchainSchema,available:z9.boolean()});var ClaimLocalPreviewSchema=LocalProjectScopeSchema.extend({requestId:LocalIdSchema,deviceId:LocalIdSchema});var LocalOutputStageSchema=LocalLeaseBindingSchema.extend({uploadRequestId:LocalIdSchema,role:z9.enum(["VIDEO","POSTER"]),checksumSha256:LocalDigestSchema,byteSize:z9.int().positive().max(128*1024*1024)});var LocalOutputTicketSchema=z9.strictObject({receiptId:LocalIdSchema,role:z9.enum(["VIDEO","POSTER"]),checksumSha256:LocalDigestSchema,byteSize:z9.int().positive(),uploaded:z9.boolean()});var LocalSourceRequestSchema=LocalLeaseBindingSchema.extend({representationId:LocalIdSchema});var LocalProofChallengeRequestSchema=LocalDeviceScopeSchema.extend({deviceRevision:z9.int().positive()});var LocalPreviewPlacementViewSchema=z9.strictObject({target:z9.enum(["DEVICE","SERVER"]),reason:z9.enum(["LOCAL_AVAILABLE","CLOUD_ONLY","OFFLINE","UNQUALIFIED","BUSY","LEASE_RECOVERY"]),policy:LocalPlacementPolicySchema});var LocalDeviceTransportConfigurationSchema=z9.strictObject({endpoint:z9.string().url().max(2048),tenantId:LocalIdSchema,deviceId:LocalIdSchema,deviceRevision:z9.int().positive(),projects:z9.array(LocalProjectScopeSchema).min(1).max(20),privateKeyFile:z9.string().min(1).max(4096),platform:LocalDevicePlatformSchema});var LocalPreviewAdmissionSchema=RoughCutAdmissionSchema.extend({placement:LocalPreviewPlacementViewSchema});var LocalClaimReceiptSchema=z9.strictObject({found:z9.boolean(),assignment:LocalWorkAssignmentSchema.nullable()});var LocalWorkStateSchema=z9.strictObject({binding:LocalLeaseBindingSchema,status:z9.enum(["ACTIVE","FENCED","OUTCOME_UNKNOWN"]),assignment:LocalWorkAssignmentSchema.nullable()});import{z as z10}from"zod";var LocalMcpToolNameSchema=z10.enum(["local_navigate","local_capability_describe","local_runtime_status","local_execution_list","local_execution_inspect","local_update_check"]);var LocalMcpActionSchema=z10.strictObject({tool:LocalMcpToolNameSchema,arguments:z10.record(z10.string(),z10.unknown()),availability:z10.enum(["AVAILABLE","BLOCKED"]).optional(),reason:z10.string().max(100).optional()});var LocalMcpNavigationSchema=z10.strictObject({location:z10.literal("LOCAL"),state:z10.enum(["UNAVAILABLE","IDLE","EXECUTING","DRAINING","RECOVERY_REQUIRED"]),authorizedProjects:z10.array(LocalProjectScopeSchema).max(100).optional(),groups:z10.array(z10.strictObject({id:z10.string().max(40),label:z10.string().max(100),tools:z10.array(LocalMcpToolNameSchema).max(6)})).max(4),nextActions:z10.array(z10.union([LocalMcpActionSchema,LocalClientNextActionSchema])).max(16)});var LocalMcpExecutionPageSchema=LocalExecutionPageSchema.extend({nextActions:z10.array(LocalMcpActionSchema).max(16)});var LocalMcpInspectionSchema=z10.strictObject({location:z10.literal("LOCAL"),execution:LocalExecutionInspectionSchema.nullable(),nextActions:z10.array(LocalMcpActionSchema).max(4)});var LocalMcpUpdateSchema=z10.strictObject({location:z10.literal("LOCAL"),running:z10.array(LocalVersionReportSchema).max(8),available:z10.array(LocalRuntimeDescriptorSchema).max(32),nextActions:z10.array(LocalClientNextActionSchema).max(4)});var LocalMcpDescriptionSchema=z10.strictObject({location:z10.literal("LOCAL"),tool:LocalMcpToolNameSchema,schema:z10.object({name:LocalMcpToolNameSchema,description:z10.string(),inputSchema:z10.record(z10.string(),z10.unknown())}).passthrough()});var LocalMcpFailureSchema=z10.strictObject({semanticStatus:z10.enum(["BLOCKED","INVALID_INPUT"]),error:z10.strictObject({code:z10.enum(["AUTHORIZATION_REQUIRED","FORBIDDEN","LOCAL_RUNTIME_UNAVAILABLE","RELEASE_UNAVAILABLE","VERSION_INCOMPATIBLE","INVALID_INPUT","LOCAL_CAPABILITY_UNAVAILABLE"]),outcome:z10.literal("NO_WRITE")}),nextActions:z10.array(LocalClientNextActionSchema).max(4)});var LocalMcpOutputSchemas={local_navigate:LocalMcpNavigationSchema,local_capability_describe:LocalMcpDescriptionSchema,local_runtime_status:LocalRuntimeStatusSchema.omit({nextActions:true}).extend({nextActions:z10.array(LocalMcpActionSchema).max(8)}),local_execution_list:LocalMcpExecutionPageSchema,local_execution_inspect:LocalMcpInspectionSchema,local_update_check:LocalMcpUpdateSchema};import{constants}from"node:fs";import{open as open2,realpath as realpath2}from"node:fs/promises";async function checkedLocalDirectory(path){await privateDirectory(path);return realpath2(path)}async function readLocalCredential(path,maximum=32768){await privateAccess(path,"file");const file=await open2(path,constants.O_RDONLY|constants.O_NOFOLLOW);try{const stat=await file.stat();if(!stat.isFile()||stat.nlink!==1||process.platform!=="win32"&&(stat.uid!==process.getuid?.()||stat.mode&63)||stat.size>maximum)throw Error("LOCAL_CREDENTIAL_INVALID");const bytes=Buffer.alloc(Math.min(maximum+1,stat.size+1));let used=0;while(used<bytes.length){const part=await file.read(bytes,used,bytes.length-used,null);if(!part.bytesRead)break;used+=part.bytesRead}if(used>stat.size)throw Error("LOCAL_CREDENTIAL_INVALID");if(used>maximum)throw Error("LOCAL_CREDENTIAL_INVALID");return bytes.subarray(0,used)}finally{await file.close()}}function localBudget(timeoutMs,parent){if(!Number.isInteger(timeoutMs)||timeoutMs<1||timeoutMs>6e4)throw Error("LOCAL_DEADLINE_INVALID");const controller=new AbortController,timer=setTimeout(()=>controller.abort(),timeoutMs);return{signal:parent?AbortSignal.any([parent,controller.signal]):controller.signal,close:()=>clearTimeout(timer)}}async function localAbortable(work,signal){if(signal.aborted)void work.catch(()=>{});signal.throwIfAborted();return new Promise((resolve,reject)=>{const abort=()=>reject(Error("LOCAL_DEADLINE"));signal.addEventListener("abort",abort,{once:true});work.then(v=>{signal.removeEventListener("abort",abort);resolve(v)},e=>{signal.removeEventListener("abort",abort);reject(e)});if(signal.aborted)abort()})}async function stageAgentImage(options,view,input,signal){const budget=localBudget(options.timeoutMs??1e4,signal);let dispatched=false;try{budget.signal.throwIfAborted();if(input.byteLength>8388608)throw Error();const bytes=Buffer.from(input),snapshot=view.plan.snapshot,id=z11.uuid().parse(view.plan.id),requestId=randomUUID2();if(!snapshot.image||bytes.length!==snapshot.image.byteSize||bytes.length>8388608||createHash3("sha256").update(bytes).digest("hex")!==snapshot.media.checksumSha256)throw Error();const root=await checkedLocalDirectory(options.stateDirectory),path=localSocketPath(root);await privateAccess(path,"pipe");const auth=await localAbortable(Promise.resolve().then(options.authorization),budget.signal);budget.signal.throwIfAborted();if(!/^Bearer [A-Za-z0-9_-]{43}$/.test(auth))throw Error();const reply=await new Promise((resolve,reject)=>{const req=request({socketPath:path,path:"/ipc/v1/agent-images/"+id,method:"PUT",signal:budget.signal,headers:{authorization:auth,"content-type":"image/png","content-length":bytes.length,"x-nvs-request-id":requestId}},res=>{let size=0;const chunks=[];res.on("error",reject);res.on("aborted",()=>reject(Error()));res.on("data",b=>{size+=b.length;if(size>262144)req.destroy(Error());else chunks.push(b)});res.on("end",()=>{try{resolve(JSON.parse(Buffer.concat(chunks).toString()))}catch{reject(Error())}})});req.on("error",reject);dispatched=true;req.end(bytes)});const response=LocalIpcResponseSchema.parse(reply);if(response.requestId!==requestId&&!(response.requestId===null&&response.semanticStatus!=="SUCCESS"&&["BUSY","FORBIDDEN"].includes(response.error.code)))throw Error();if(response.semanticStatus!=="SUCCESS")throw new NativeStudioSdkError(response.error.code,response.semanticStatus,response.error.code==="INTERNAL_OPERATIONAL_FAILURE"?"UNKNOWN":"REJECTED");const v=LocalAgentReviewViewSchema.parse(response.data),receipt=v.imageReceipt;if(v.plan.id!==id||canonicalLocalJson(v.plan)!==canonicalLocalJson(view.plan)||v.revision<view.revision||v.phase!=="PREPARED"||!receipt||receipt.draftId!==id||canonicalLocalJson(receipt.media)!==canonicalLocalJson(snapshot.media)||canonicalLocalJson({contentType:receipt.contentType,byteSize:receipt.byteSize,width:receipt.width,height:receipt.height})!==canonicalLocalJson(snapshot.image))throw Error();return v}catch(e){if(e instanceof NativeStudioSdkError)throw e;throw new NativeStudioSdkError("LOCAL_AGENT_IMAGE_TRANSFER_FAILED","BLOCKED",dispatched?"UNKNOWN":"NO_WRITE")}finally{budget.close()}}import{randomUUID as randomUUID3}from"node:crypto";import{request as request2}from"node:http";import{z as z12}from"zod";var NativeStudioLocalDeviceClient=class{constructor(options){this.options=options;const u=new URL(options.baseUrl);if(u.username||u.password||u.search||u.hash||u.pathname!=="/"||u.protocol!=="https:"&&!(u.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(u.hostname)))throw new NativeStudioSdkError("INVALID_INPUT","INVALID_INPUT","NO_WRITE");this.origin=u.origin}options;origin;async command(route,raw,input,output2,signal){let started=false;const budget=localBudget(15e3,signal);try{const i=input.parse(raw);if(i.tenantId!==this.options.tenantId)throw Error();budget.signal.throwIfAborted();const authorization=await localAbortable(Promise.resolve().then(()=>this.options.authorization()),budget.signal);if(authorization!==authorization.trim()||!/^Bearer [A-Za-z0-9._~-]{1,8192}$/.test(authorization))throw Error();const body=JSON.stringify(i);if(Buffer.byteLength(body)>65536)throw Error();budget.signal.throwIfAborted();started=true;const r=await fetch(this.origin+"/v1/local-execution/"+route,{method:"POST",headers:{authorization,"content-type":"application/json"},body,redirect:"error",signal:budget.signal});if(!r.ok){await r.body?.cancel();throw new NativeStudioSdkError(r.status===403||r.status===401?"FORBIDDEN":"LOCAL_COMMAND_REFUSED","BLOCKED",r.status>=500?"UNKNOWN":"REJECTED",r.status)}const parts=[];let size=0;for await(const b of r.body??[]){size+=b.length;if(size>262144)throw Error();parts.push(b)}const value=output2.parse(JSON.parse(Buffer.concat(parts).toString()));if(value&&typeof value==="object"){const result=value,request3=i;for(const key of["tenantId","projectId","deviceId"])if(key in result&&key in request3&&result[key]!==request3[key])throw Error()}return value}catch(e){if(e instanceof NativeStudioSdkError)throw e;throw new NativeStudioSdkError(started?"LOCAL_COMMAND_UNKNOWN":"INVALID_INPUT",started?"BLOCKED":"INVALID_INPUT",started?"UNKNOWN":"NO_WRITE")}finally{budget.close()}}enroll(input,signal){return this.command("devices/enroll",input,EnrollLocalDeviceSchema,LocalDeviceViewSchema,signal)}grant(input,signal){return this.command("devices/grant",input,GrantLocalDeviceSchema,LocalDeviceGrantSchema,signal)}revokeDevice(input,signal){return this.command("devices/revoke",input,RevokeLocalDeviceSchema,z12.strictObject({semanticStatus:z12.literal("SUCCESS")}),signal)}revokeGrant(input,signal){return this.command("devices/revoke-grant",input,RevokeLocalDeviceGrantSchema,z12.strictObject({semanticStatus:z12.literal("SUCCESS")}),signal)}startPreview(input,signal){return this.command("previews",input,StartLocalPreviewSchema,LocalPreviewAdmissionSchema,signal)}};var NativeStudioLocalRuntimeClient=class _NativeStudioLocalRuntimeClient{constructor(options){this.options=options}options;static async fromConnector(path){const initial=LocalSessionConnectorSchema.parse(JSON.parse((await readLocalCredential(path)).toString()));return new _NativeStudioLocalRuntimeClient({stateDirectory:initial.stateDirectory,projects:initial.projects,authorization:async()=>{const current=LocalSessionConnectorSchema.parse(JSON.parse((await readLocalCredential(path)).toString()));if(current.stateDirectory!==initial.stateDirectory||canonicalLocalJson(current.projects)!==canonicalLocalJson(initial.projects)||Date.parse(current.expiresAt)>Date.parse(initial.expiresAt)||Date.parse(current.expiresAt)<=Date.now())throw Error("LOCAL_AUTHORIZATION_REQUIRED");return"Bearer "+current.credential}})}async call(call,signal){let started=false;const budget=localBudget(this.options.timeoutMs??(["runtime.doctor","agent.probe","agent.grant","agent.start"].includes(call.operation)?6e4:1e4),signal);const readOnly=["runtime.status","runtime.doctor","runtime.inventory","execution.inspect","execution.list","update.check","agent.probe","agent.inspect"].includes(call.operation);try{const input=LocalIpcRequestSchema.parse({protocol:"NVS_LOCAL_IPC_V1",requestId:randomUUID3(),call});const root=await checkedLocalDirectory(this.options.stateDirectory);const path=localSocketPath(root);await privateAccess(path,"pipe");budget.signal.throwIfAborted();const auth=await localAbortable(Promise.resolve().then(()=>this.options.authorization()),budget.signal);budget.signal.throwIfAborted();if(auth.length!==50||!/^Bearer [A-Za-z0-9_-]{43}$/.test(auth))throw Error();const body=JSON.stringify(input);const reply=await new Promise((resolve,reject)=>{const abort=budget.signal;const req=request2({socketPath:path,method:"POST",path:"/ipc/v1",signal:abort,headers:{authorization:auth,"content-type":"application/json","content-length":Buffer.byteLength(body)}},res=>{const chunks=[];let length=0;res.on("error",reject);res.on("aborted",()=>reject(Error()));res.on("data",b=>{length+=b.length;if(length>256*1024)req.destroy(Error());else chunks.push(b)});res.on("end",()=>{try{resolve(JSON.parse(Buffer.concat(chunks).toString()))}catch{reject(Error())}})});req.on("error",reject);started=true;req.end(body)});const value=LocalIpcResponseSchema.parse(reply);if(value.requestId!==input.requestId&&!(value.requestId===null&&value.semanticStatus!=="SUCCESS"&&["FORBIDDEN","BUSY","INVALID_INPUT"].includes(value.error.code)))throw Error();if(value.semanticStatus!=="SUCCESS")throw new NativeStudioSdkError(value.error.code,value.semanticStatus,readOnly?"NO_WRITE":value.error.code==="INTERNAL_OPERATIONAL_FAILURE"?"UNKNOWN":"REJECTED");if(value.requestId!==input.requestId)throw Error();return value.data}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError("LOCAL_RUNTIME_UNAVAILABLE","BLOCKED",started&&!readOnly?"UNKNOWN":"NO_WRITE")}finally{budget.close()}}response(schema,raw){const result=schema.safeParse(raw);if(!result.success)throw new NativeStudioSdkError("LOCAL_RESPONSE_INVALID","BLOCKED","NO_WRITE");return result.data}async status(signal){const value=this.response(LocalRuntimeStatusSchema,await this.call({operation:"runtime.status"},signal));if(this.options.projects&&value.authorizedProjects.some(p=>!this.options.projects.some(q=>q.tenantId===p.tenantId&&q.projectId===p.projectId)))throw new NativeStudioSdkError("LOCAL_SCOPE_INVALID","BLOCKED","NO_WRITE");return value}async doctor(signal){return this.response(LocalDoctorReportSchema,await this.call({operation:"runtime.doctor"},signal))}async inventory(signal){return this.response(LocalManagementInventorySchema,await this.call({operation:"runtime.inventory"},signal))}async grantAgent(raw,approval){return this.response(LocalAgentProbeSchema,await this.call({operation:"agent.grant",grant:LocalAgentGrantSchema.parse(raw),approval}))}async revokeAgent(approval){return this.response(LocalAgentProbeSchema,await this.call({operation:"agent.revoke",approval}))}async probeAgent(){return this.response(LocalAgentProbeSchema,await this.call({operation:"agent.probe"}))}async prepareAgentReview(snapshot){const input=LocalAgentSnapshotSchema.parse(snapshot);const v=this.response(LocalAgentReviewViewSchema,await this.call({operation:"agent.prepare",snapshot:input}));if(canonicalLocalJson(v.plan.snapshot)!==canonicalLocalJson(input))throw new NativeStudioSdkError("LOCAL_RESPONSE_INVALID","BLOCKED","UNKNOWN");return v}async startAgentReview(id,expectedRevision,approval){const v=this.response(LocalAgentReviewViewSchema,await this.call({operation:"agent.start",id,expectedRevision,approval}));if(v.plan.id!==id||v.plan.fingerprint!==approval)throw new NativeStudioSdkError("LOCAL_RESPONSE_INVALID","BLOCKED","UNKNOWN");return v}async stageAgentImage(id,bytes,signal){const budget=localBudget(this.options.timeoutMs??1e4,signal);try{return await stageAgentImage(this.options,await this.inspectAgentReview(id,budget.signal),bytes,budget.signal)}finally{budget.close()}}async inspectAgentReview(id,signal){const v=this.response(LocalAgentReviewViewSchema,await this.call({operation:"agent.inspect",id},signal));if(v.plan.id!==id)throw new NativeStudioSdkError("LOCAL_RESPONSE_INVALID","BLOCKED","NO_WRITE");return v}async executions(input,signal){const i=LocalExecutionListInputSchema.parse(input);if(this.options.projects&&!this.options.projects.some(p=>p.tenantId===i.tenantId&&p.projectId===i.projectId))throw new NativeStudioSdkError("FORBIDDEN","BLOCKED","NO_WRITE");const page=this.response(LocalExecutionPageSchema,await this.call({operation:"execution.list",input:i},signal));if(page.items.some(e=>e.binding.tenantId!==i.tenantId||e.binding.projectId!==i.projectId))throw new NativeStudioSdkError("LOCAL_SCOPE_INVALID","BLOCKED","NO_WRITE");return page}async inspect(raw,signal){const input=LocalWorkScopeSchema.parse(raw);if(this.options.projects&&!this.options.projects.some(p=>p.tenantId===input.tenantId&&p.projectId===input.projectId))throw new NativeStudioSdkError("FORBIDDEN","BLOCKED","NO_WRITE");const value=this.response(LocalExecutionInspectionSchema.nullable(),await this.call({operation:"execution.inspect",input},signal));if(value&&["tenantId","projectId","productionId","runtimeJobId"].some(k=>value.binding[k]!==input[k]))throw new NativeStudioSdkError("LOCAL_SCOPE_INVALID","BLOCKED","NO_WRITE");return value}};export{EnrollLocalDeviceSchema,GrantLocalDeviceSchema,LocalAgentGrantSchema,LocalAgentSnapshotSchema,LocalClientNextActionSchema,LocalSessionConnectorSchema as LocalConnectorSchema,LocalDeviceTransportConfigurationSchema,LocalDoctorReportSchema,LocalExecutionListInputSchema,LocalExecutionPageSchema,LocalManagementInventorySchema,LocalMcpFailureSchema,LocalMcpOutputSchemas,LocalReleaseSchema,LocalRuntimeDescriptorSchema,LocalSessionConnectorSchema,LocalSignedCatalogueSchema,LocalToolChoiceSchema,LocalToolSelectionSchema,LocalUpdatePlanSchema,LocalWorkScopeSchema,NativeStudioLocalDeviceClient,NativeStudioLocalRuntimeClient,NativeStudioSdkError,RevokeLocalDeviceGrantSchema,RevokeLocalDeviceSchema,StartLocalPreviewSchema,canonicalLocalJson,localAgentNativeProposal,localAgentSnapshotFromContext};
|