@nativestudio/cli 0.3.0-rc.11 → 0.3.0-rc.14
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 +13 -9
- package/components/runtime.json +9 -5
- package/components/runtime.tgz +0 -0
- package/dist/_chunks/chunk-2AI3WF2O.js +1 -0
- package/dist/_chunks/chunk-5DY7LSZZ.js +1 -0
- package/dist/_chunks/{chunk-65FQPXKC.js → chunk-6LY4JYSG.js} +1 -1
- package/dist/_chunks/chunk-6UYY5KHI.js +1 -0
- package/dist/_chunks/{chunk-6N433ZWR.js → chunk-77IAHNM2.js} +1 -1
- package/dist/_chunks/{chunk-4U4Y2K73.js → chunk-C62JAWRQ.js} +1 -1
- package/dist/_chunks/{chunk-Q57YFNK5.js → chunk-HY7NXJYX.js} +1 -1
- package/dist/_chunks/chunk-PDQYFIQQ.js +1 -0
- package/dist/_chunks/{chunk-L543FEDK.js → chunk-RDIMORUT.js} +1 -1
- package/dist/_chunks/{chunk-LISB5W7B.js → chunk-RK2P3UVF.js} +1 -1
- package/dist/_chunks/{chunk-M2KVQQ4X.js → chunk-ROBBF33U.js} +1 -1
- package/dist/_chunks/{chunk-QAJH4RJQ.js → chunk-S74X4KIC.js} +1 -1
- package/dist/_chunks/{chunk-6DVZBKNV.js → chunk-SV3NF7GO.js} +1 -1
- package/dist/_chunks/chunk-TLPI6P7L.js +1 -0
- package/dist/_chunks/{chunk-HR34UMPP.js → chunk-U7ECMITP.js} +1 -1
- package/dist/_chunks/{chunk-EGUJ2YRX.js → chunk-VD3OQ743.js} +1 -1
- package/dist/_chunks/{chunk-ODGPV7MM.js → chunk-VKLS4QK5.js} +1 -1
- package/dist/_chunks/{chunk-LUAH3KAS.js → chunk-W6C63ZN7.js} +1 -1
- package/dist/_chunks/chunk-ZRSYOFMX.js +1 -0
- package/dist/_chunks/{connect-5YMO6MAR.js → connect-6UH7ZFAC.js} +1 -1
- package/dist/_chunks/{device-management-2OTGEBJQ.js → device-management-H3NIDIPY.js} +1 -1
- package/dist/_chunks/{device-preflight-XPHFZGLO.js → device-preflight-LHFLPVAB.js} +1 -1
- package/dist/_chunks/{devices-inventory-VWNTU5TE.js → devices-inventory-I2E3Q4DA.js} +1 -1
- package/dist/_chunks/{devices-main-VQ4APRVS.js → devices-main-VV2VYU4T.js} +1 -1
- package/dist/_chunks/{host-main-H7DPLV7B.js → host-main-3JFGVU5P.js} +1 -1
- package/dist/_chunks/http-profile-NIQDCFPU.js +1 -0
- package/dist/_chunks/{library-main-SAC3V2ML.js → library-main-CTBW7DAI.js} +1 -1
- package/dist/_chunks/local-main-227MNGEC.js +1 -0
- package/dist/_chunks/{local-mcp-ONCANLPH.js → local-mcp-XB6E3V2W.js} +1 -1
- package/dist/_chunks/{main-PW6HB3NC.js → main-W6NNZFLK.js} +2 -2
- package/dist/_chunks/mcp-EXQ5UAHB.js +1 -0
- package/dist/_chunks/{render-main-GYWKP72O.js → render-main-VTM6WGFP.js} +1 -1
- package/dist/_chunks/{source-import-BC5GNCUZ.js → source-import-KKV2UWJO.js} +1 -1
- package/dist/_chunks/{src-R6DNU336.js → src-OIY5TBQT.js} +1 -1
- package/dist/_chunks/{stdio-main-RIJS5REB.js → stdio-main-Y7N4NVKU.js} +1 -1
- package/dist/_chunks/workspace-main-Y7ZVBRJJ.js +1 -0
- package/dist/_types/cli/local/desktop-contract.d.ts +63 -5
- package/dist/_types/cli/local/desktop-device-contract.d.ts +23 -10
- package/dist/_types/cli/local/desktop-device-owner.d.ts +33 -7
- package/dist/_types/cli/local/desktop-device-state.d.ts +64 -12
- package/dist/_types/cli/local/desktop-owner.d.ts +57 -8
- package/dist/_types/cli/local/ledger.d.ts +10 -10
- package/dist/_types/cli/local/manager.d.ts +121 -18
- package/dist/_types/cli/local/mcp-tools.d.ts +14 -13
- package/dist/_types/cli/local/releases.d.ts +2 -2
- package/dist/_types/cli/local-management.d.ts +3 -0
- package/dist/_types/contracts/artifact-discovery.d.ts +60 -0
- package/dist/_types/contracts/audio.d.ts +162 -0
- package/dist/_types/contracts/consistency-profile.d.ts +102 -6
- package/dist/_types/contracts/continuity-evaluation.d.ts +1 -1
- package/dist/_types/contracts/delivery-operations.d.ts +150 -0
- package/dist/_types/contracts/device-render.d.ts +2 -0
- package/dist/_types/contracts/editor-intelligence.d.ts +280 -42
- package/dist/_types/contracts/final-render.d.ts +188 -24
- package/dist/_types/contracts/human-links.d.ts +58 -0
- package/dist/_types/contracts/index.d.ts +6 -0
- package/dist/_types/contracts/interface/media-output.d.ts +90 -0
- package/dist/_types/contracts/interface/operation.d.ts +30 -0
- package/dist/_types/contracts/interface/production-snapshot.d.ts +60 -0
- package/dist/_types/contracts/interface/query.d.ts +60 -0
- package/dist/_types/contracts/keyframe-generation.d.ts +1 -1
- package/dist/_types/contracts/local-execution/agent-context.d.ts +23 -3
- package/dist/_types/contracts/local-execution/agent-review.d.ts +29 -3
- package/dist/_types/contracts/local-execution/audio-profile.d.ts +6 -0
- package/dist/_types/contracts/local-execution/cpu-preparation.d.ts +46 -0
- package/dist/_types/contracts/local-execution/cpu-resources.d.ts +55 -0
- package/dist/_types/contracts/local-execution/cpu-speech-job.d.ts +70 -0
- package/dist/_types/contracts/local-execution/cpu-speech.d.ts +161 -0
- package/dist/_types/contracts/local-execution/descriptor.d.ts +1 -1
- package/dist/_types/contracts/local-execution/device-inventory.d.ts +2 -2
- package/dist/_types/contracts/local-execution/device.d.ts +3 -3
- package/dist/_types/contracts/local-execution/index.d.ts +6 -0
- package/dist/_types/contracts/local-execution/ipc.d.ts +18 -2
- package/dist/_types/contracts/local-execution/library-result.d.ts +16 -0
- package/dist/_types/contracts/local-execution/lifecycle.d.ts +49 -7
- package/dist/_types/contracts/local-execution/local-navigation.d.ts +15 -14
- package/dist/_types/contracts/local-execution/management.d.ts +15 -11
- package/dist/_types/contracts/local-execution/preview.d.ts +38 -3
- package/dist/_types/contracts/local-execution/processor-capability.d.ts +2 -0
- package/dist/_types/contracts/local-execution/processor-recipes.d.ts +43 -0
- package/dist/_types/contracts/local-execution/processor-toolchain.d.ts +47 -0
- package/dist/_types/contracts/local-execution/processor.d.ts +184 -3
- package/dist/_types/contracts/local-execution/speech.d.ts +1 -1
- package/dist/_types/contracts/local-execution/tool-selection.d.ts +26 -0
- package/dist/_types/contracts/local-execution/work.d.ts +16 -2
- package/dist/_types/contracts/native-speech-model.d.ts +53 -0
- package/dist/_types/contracts/native-speech-options.d.ts +25 -0
- package/dist/_types/contracts/navigation-context.d.ts +2 -2
- package/dist/_types/contracts/navigation-groups.d.ts +1 -1
- package/dist/_types/contracts/navigation.d.ts +35 -5
- package/dist/_types/contracts/production-creation.d.ts +30 -0
- package/dist/_types/contracts/production.d.ts +30 -0
- package/dist/_types/contracts/project-library.d.ts +30 -0
- package/dist/_types/contracts/project.d.ts +30 -0
- package/dist/_types/contracts/provider-models.d.ts +193 -0
- package/dist/_types/contracts/repair-lifecycle.d.ts +4 -4
- package/dist/_types/contracts/repair-plan.d.ts +1 -1
- package/dist/_types/contracts/repair-strategy.d.ts +9 -5
- package/dist/_types/contracts/review-intelligence-final-output.d.ts +90 -0
- package/dist/_types/contracts/review-intelligence.d.ts +3 -1
- package/dist/_types/contracts/rough-cut-manifest.d.ts +19 -4
- package/dist/_types/contracts/rough-cut-review.d.ts +10 -1
- package/dist/_types/contracts/rough-cut.d.ts +111 -12
- package/dist/_types/contracts/shot-preparation-basis.d.ts +2 -2
- package/dist/_types/contracts/shot-preparation.d.ts +4 -4
- package/dist/_types/contracts/sound-making-plan.d.ts +207 -0
- package/dist/_types/contracts/speech-cost.d.ts +15 -0
- package/dist/_types/contracts/speech-parameters.d.ts +39 -0
- package/dist/_types/contracts/speech.d.ts +470 -39
- package/dist/_types/contracts/timeline-audio.d.ts +19 -4
- package/dist/_types/contracts/timeline-manifest.d.ts +38 -8
- package/dist/_types/contracts/timeline-source-sound.d.ts +41 -4
- package/dist/_types/contracts/timeline-v2.d.ts +120 -16
- package/dist/_types/contracts/timeline-version-reader.d.ts +278 -40
- package/dist/_types/contracts/timeline-visual-layers.d.ts +120 -16
- package/dist/_types/contracts/video-generation.d.ts +1 -1
- package/dist/_types/contracts/visual-exploration.d.ts +1 -1
- package/dist/_types/contracts/visual-layer-render.d.ts +240 -32
- package/dist/_types/contracts/visual-sequence.d.ts +1 -1
- package/dist/_types/contracts/voice-consistency.d.ts +183 -0
- package/dist/_types/contracts/voice-profile/contracts.d.ts +821 -0
- package/dist/_types/contracts/voice-profile/identity.d.ts +27 -0
- package/dist/_types/contracts/voice-profile/interface.d.ts +89 -0
- package/dist/_types/contracts/voice-profile/reference.d.ts +106 -0
- package/dist/_types/contracts/voice-review.d.ts +1194 -0
- package/dist/_types/contracts/workspace.d.ts +30 -0
- package/dist/_types/sdk/local-runtime/device-client.d.ts +54 -2
- package/dist/_types/sdk/local-runtime-client.d.ts +169 -28
- package/dist/entry.js +1 -1
- package/dist/local-management.js +1 -1
- package/dist/local-navigation.js +1 -1
- package/package.json +1 -1
- package/dist/_chunks/chunk-37PAJCKA.js +0 -1
- package/dist/_chunks/chunk-GZBWA4YN.js +0 -1
- package/dist/_chunks/chunk-PUBMDP4E.js +0 -1
- package/dist/_chunks/chunk-VPYAXWXY.js +0 -1
- package/dist/_chunks/chunk-WFRRNWO5.js +0 -1
- package/dist/_chunks/http-profile-MNJX6OXO.js +0 -1
- package/dist/_chunks/local-main-D6B3APK6.js +0 -1
- package/dist/_chunks/mcp-ZIGBYFUW.js +0 -1
- package/dist/_chunks/workspace-main-GNSKHKBG.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DesktopDeviceScopeSchema}from"./chunk-
|
|
1
|
+
import{DesktopDeviceScopeSchema}from"./chunk-VD3OQ743.js";import{fail,optional,read,sha256,write}from"./chunk-KB2GVAN7.js";import{canonicalLocalJson}from"./chunk-PDQYFIQQ.js";import{join}from"node:path";import{z}from"zod";var digest=z.string().regex(/^[a-f0-9]{64}$/);var DesktopAutomationSchema=z.strictObject({enabled:z.boolean(),scope:DesktopDeviceScopeSchema,deviceId:z.uuid(),deviceRevision:z.int().positive(),installationFingerprint:digest});async function desktopInstallationIdentity(manager){const active=(await manager.ledger.current()).value.active;if(!active)return null;const tools=active.toolsConfigPath?JSON.parse((await read(active.toolsConfigPath,32768)).toString()):null;return{version:active.descriptor.version,workProtocol:active.descriptor.workProtocol,fingerprint:sha256(canonicalLocalJson({descriptor:active.descriptor,files:active.files,tools}))}}async function desktopAutomation(home){const value=await optional(join(home,"desktop-execution-policy.json"));return value?DesktopAutomationSchema.parse(value):null}function canResumeDesktop(policy,state,installation){if(!policy?.enabled||!installation||!state.device||policy.installationFingerprint!==installation.fingerprint||canonicalLocalJson(policy.scope)!==canonicalLocalJson(state.scope)||policy.deviceId!==state.device.deviceId||policy.deviceRevision!==state.device.revision)return false;return state.device.revokedAt===null}async function rememberDesktopAutomation(home,state,installation,expectedFingerprint){if(!installation||installation.fingerprint!==expectedFingerprint||!state.device)fail("DEVICE_PLAN_CHANGED");const value=DesktopAutomationSchema.parse({enabled:true,scope:state.scope,deviceId:state.device.deviceId,deviceRevision:state.device.revision,installationFingerprint:expectedFingerprint});await write(join(home,"desktop-execution-policy.json"),canonicalLocalJson(value));return value}async function disableDesktopAutomation(home){const policy=await desktopAutomation(home);if(policy)await write(join(home,"desktop-execution-policy.json"),canonicalLocalJson({...policy,enabled:false}))}export{desktopInstallationIdentity,desktopAutomation,canResumeDesktop,rememberDesktopAutomation,disableDesktopAutomation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z}from"zod";var TenantIdSchema=z.uuid().brand();var PrincipalIdSchema=z.uuid().brand();var ProjectIdSchema=z.uuid().brand();var ProductionIdSchema=z.uuid().brand();var ArtifactIdSchema=z.uuid().brand();var ArtifactRepresentationIdSchema=z.uuid().brand();var ArtifactRelationIdSchema=z.uuid().brand();var BriefIdSchema=z.uuid().brand();var BriefVersionIdSchema=z.uuid().brand();var StoryIdSchema=z.uuid().brand();var StoryVersionIdSchema=z.uuid().brand();var SceneShotPlanIdSchema=z.uuid().brand();var SceneShotPlanVersionIdSchema=z.uuid().brand();var SceneIdSchema=z.uuid().brand();var ShotIdSchema=z.uuid().brand();var ContinuityEdgeIdSchema=z.uuid().brand();var RuntimeJobIdSchema=z.uuid().brand();var OperationIdSchema=z.string().regex(/^op_[A-Za-z0-9_-]+$/).max(2048).brand();var RuntimeJobAttemptIdSchema=z.uuid().brand();var OutboxEventIdSchema=z.uuid().brand();import{z as z2}from"zod";var uuid="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";var page=new RegExp(`^/(?:projects(?:/${uuid})?|artifacts|productions/${uuid}(?:/(?:artifacts|delivery|history))?|settings/voices(?:/${uuid}(?:/versions/[1-9][0-9]*)?)?)$`);var HumanLinkScopeSchema=z2.strictObject({tenantId:z2.uuid(),projectId:z2.uuid().optional(),productionId:z2.uuid().optional(),artifactId:z2.uuid().optional(),representationId:z2.uuid().optional(),delivery:z2.boolean().optional(),voices:z2.boolean().optional(),voiceProfileId:z2.uuid().optional(),voiceProfileVersion:z2.int().positive().optional()}).refine(s=>!!s.artifactId===!!s.representationId&&(!s.delivery||!!s.productionId)&&(s.voiceProfileVersion===void 0||!!s.voiceProfileId));var HumanLinkSchema=z2.strictObject({rel:z2.enum(["workspace","project","production","artifact","delivery","voice_profile"]),href:z2.url().max(2048)}).refine(({rel,href})=>{try{const u=new URL(href),q=u.searchParams,parts=u.pathname.split("/"),pathId=parts[1]==="settings"?parts[3]:parts[2];return u.href===href&&!u.username&&!u.password&&!href.includes("#")&&(u.protocol==="https:"||u.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(u.hostname))&&page.test(u.pathname)&&(!pathId||z2.uuid().safeParse(pathId).success)&&(parts[4]!=="versions"||z2.int().positive().safeParse(Number(parts[5])).success)&&new Set(q.keys()).size===q.size&&[...q].every(([key,value])=>["workspace","artifact","representation"].includes(key)&&z2.uuid().safeParse(value).success)&&q.has("workspace")&&q.has("artifact")===q.has("representation")&&(rel==="artifact"?u.pathname.endsWith("/artifacts")&&q.has("artifact"):!q.has("artifact")&&(rel==="workspace"?u.pathname==="/projects":rel==="project"?new RegExp(`^/projects/${uuid}$`).test(u.pathname):rel==="voice_profile"?u.pathname.startsWith("/settings/voices"):rel==="production"?new RegExp(`^/productions/${uuid}$`).test(u.pathname):u.pathname.endsWith("/delivery")))}catch{return false}});var HumanLinksSchema=z2.discriminatedUnion("status",[z2.strictObject({status:z2.literal("AVAILABLE"),items:z2.array(HumanLinkSchema).min(1).max(4)}),z2.strictObject({status:z2.enum(["UNCONFIGURED","UNAVAILABLE"]),items:z2.array(HumanLinkSchema).max(0)})]);import{z as z3}from"zod";var DeliveryOutputProfileSchema=z3.enum(["MP4_H264_1080P","MP4_H264_720P","MP4_H264_480P"]);var finalProfileIds={MP4_H264_1080P:"FINAL_H264_1080P_V1",MP4_H264_720P:"FINAL_H264_720P_V1",MP4_H264_480P:"FINAL_H264_480P_V1"};import{z as z4}from"zod";var InterfaceSemanticStatusSchema=z4.enum(["SUCCESS","ACCEPTED","NO_CHANGE","INVALID_INPUT","NOT_FOUND","REVISION_CONFLICT","STALE_BASIS","BLOCKED","WAITING_PROVIDER","WAITING_INPUT","RETRYING","CAPABILITY_UNAVAILABLE","PROVIDER_UNAVAILABLE","BUDGET_BLOCKED","CANCELLED","SUPERSEDED","INTERNAL_OPERATIONAL_FAILURE"]);var ActionAvailabilitySchema=z4.enum(["AVAILABLE","UNAVAILABLE"]);var NextActionSchema=z4.object({capability:z4.string().min(1).max(120),targetType:z4.string().min(1).max(80),targetId:z4.string().min(1).max(2048),availability:ActionAvailabilitySchema,reason:z4.string().min(1).max(1e3).nullable()});var ContinuationSchema=z4.string().min(1).max(8192);var QueryLimitSchema=z4.int().min(1).max(100).default(20);var QueryPageInfoSchema=z4.object({hasMore:z4.boolean(),next:ContinuationSchema.nullable()});var WorkSummarySchema=z4.object({total:z4.int().nonnegative(),pending:z4.int().nonnegative(),ready:z4.int().nonnegative(),running:z4.int().nonnegative(),waiting:z4.int().nonnegative(),succeeded:z4.int().nonnegative(),failed:z4.int().nonnegative(),cancelled:z4.int().nonnegative(),superseded:z4.int().nonnegative(),attempts:z4.int().nonnegative()});export{TenantIdSchema,PrincipalIdSchema,ProjectIdSchema,ProductionIdSchema,ArtifactIdSchema,ArtifactRepresentationIdSchema,ArtifactRelationIdSchema,BriefIdSchema,BriefVersionIdSchema,StoryIdSchema,StoryVersionIdSchema,SceneShotPlanIdSchema,SceneShotPlanVersionIdSchema,SceneIdSchema,ShotIdSchema,ContinuityEdgeIdSchema,OperationIdSchema,HumanLinksSchema,DeliveryOutputProfileSchema,finalProfileIds,InterfaceSemanticStatusSchema,NextActionSchema,ContinuationSchema,QueryLimitSchema,QueryPageInfoSchema,WorkSummarySchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{localCliVersion}from"./chunk-2UYKJ6YN.js";import{NativeStudioMcpClient}from"./chunk-
|
|
1
|
+
import{localCliVersion}from"./chunk-2UYKJ6YN.js";import{NativeStudioMcpClient}from"./chunk-5DY7LSZZ.js";import{remoteFetch,secureEndpoint}from"./chunk-PUNG4ND7.js";import{NativeStudioSdkError}from"./chunk-HTUTYIRU.js";import{Client,StreamableHTTPClientTransport}from"@modelcontextprotocol/client";async function connectRemoteMcp(endpoint,authorization,tenantId){const url=secureEndpoint(endpoint);const client=new Client({name:"native-studio-remote-cli",version:(await localCliVersion()).version},{versionNegotiation:{mode:"auto"}});try{const transport=new StreamableHTTPClientTransport(url,{requestInit:{headers:{authorization}},fetch:remoteFetch});await client.connect(transport);return{studio:new NativeStudioMcpClient({tenantId,client}),close:()=>client.close()}}catch{await client.close();throw new NativeStudioSdkError("TRANSPORT_UNAVAILABLE","INTERNAL_OPERATIONAL_FAILURE","NO_WRITE")}}export{connectRemoteMcp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{desktopAutomation,desktopInstallationIdentity}from"./chunk-
|
|
1
|
+
import{desktopAutomation,desktopInstallationIdentity}from"./chunk-6LY4JYSG.js";import{LocalInstallationManager,ownerClient,socketAbsent}from"./chunk-ZRSYOFMX.js";import{LocalClientError,fail}from"./chunk-KB2GVAN7.js";import{LocalLibraryCallSchema,LocalLibraryGetSchema,LocalLibraryImportSchema,LocalLibraryItemSchema,LocalLibraryPageSchema,LocalLibraryProjectionPageSchema,LocalLibraryProjectionSchema,LocalLibraryReadReplySchema,LocalLibraryReferenceSchema,LocalLibraryUsageSchema}from"./chunk-PDQYFIQQ.js";import{NativeStudioSdkError}from"./chunk-HTUTYIRU.js";import{z}from"zod";import{isAbsolute}from"node:path";import{constants}from"node:fs";import{open}from"node:fs/promises";import{createHash}from"node:crypto";var same=(a,b)=>a.dev===b.dev&&a.ino===b.ino&&a.size===b.size&&a.mtimeMs===b.mtimeMs&&a.ctimeMs===b.ctimeMs;async function captureLibraryImport(path,seed){const file2=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW).catch(()=>{throw new NativeStudioSdkError("LOCAL_LIBRARY_FILE_UNAVAILABLE","INVALID_INPUT","NO_WRITE")});try{const before=await file2.stat(),hash=createHash("sha256");if(!before.isFile()||before.size>128*1024*1024)fail("LOCAL_LIBRARY_FILE_INVALID");let size=0;for await(const bytes of file2.createReadStream({autoClose:false,start:0})){size+=bytes.length;if(size>before.size)fail("LOCAL_LIBRARY_FILE_CHANGED");hash.update(bytes)}if(size!==before.size||!same(before,await file2.stat()))fail("LOCAL_LIBRARY_FILE_CHANGED");const{tenantId,projectId,deviceId,contentType,...fields}=seed;return LocalLibraryImportSchema.parse({...fields,reference:{tenantId,projectId,deviceId,fileId:seed.requestId,versionId:seed.requestId,contentType,byteSize:size,checksumSha256:hash.digest("hex")}})}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError(error instanceof LocalClientError?error.code:"LOCAL_LIBRARY_FILE_UNAVAILABLE","INVALID_INPUT","NO_WRITE")}finally{await file2.close()}}async function importLibraryFile(library,path,raw){const input=LocalLibraryImportSchema.parse(raw),file2=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW).catch(()=>{throw new NativeStudioSdkError("LOCAL_LIBRARY_FILE_UNAVAILABLE","INVALID_INPUT","NO_WRITE")});let dispatched=false;try{const before=await file2.stat();if(!before.isFile()||before.size!==input.reference.byteSize)fail("LOCAL_LIBRARY_FILE_CHANGED");dispatched=true;const result=await library.import(input,file2.createReadStream({autoClose:false,start:0}));if(!same(before,await file2.stat()))fail("LOCAL_LIBRARY_IMPORT_UNKNOWN");return result}catch(error){if(error instanceof NativeStudioSdkError)throw error;throw new NativeStudioSdkError(error instanceof LocalClientError?error.code:"LOCAL_LIBRARY_IMPORT_UNAVAILABLE","BLOCKED",dispatched?"UNKNOWN":"NO_WRITE")}finally{await file2.close()}}var file=z.string().min(1).max(4096).refine(isAbsolute);var DesktopLibraryImportSeedSchema=LocalLibraryImportSchema.omit({reference:true}).extend({...LocalLibraryReferenceSchema.pick({tenantId:true,projectId:true,deviceId:true,contentType:true}).shape});var DesktopLibraryRequestSchema=z.strictObject({operation:z.literal("library"),call:LocalLibraryCallSchema});var DesktopLibraryImportRequestSchema=z.strictObject({operation:z.literal("library-import"),input:LocalLibraryImportSchema,file});var DesktopLibraryPrepareRequestSchema=z.strictObject({operation:z.literal("library-import-prepare"),seed:DesktopLibraryImportSeedSchema,file});var DesktopLibraryMediaRequestSchema=z.strictObject({operation:z.literal("library-media"),input:LocalLibraryGetSchema,method:z.enum(["GET","HEAD"]).default("GET"),range:z.string().min(1).max(100).optional()});var DesktopLibraryReplySchema=z.union([LocalLibraryItemSchema.nullable(),LocalLibraryPageSchema,LocalLibraryProjectionPageSchema,LocalLibraryProjectionSchema,LocalLibraryUsageSchema,LocalLibraryReadReplySchema]);async function client(home){const manager=await LocalInstallationManager.open(home),config=await manager.configuration();if(!(await manager.status()).running){const policy=await desktopAutomation(home),installation=await desktopInstallationIdentity(manager);if(!policy?.enabled||policy.installationFingerprint!==installation?.fingerprint||!await socketAbsent(config.stateDirectory))fail("RUNTIME_STATUS_REQUIRED");await manager.start()}return ownerClient(config.stateDirectory)}async function runDesktopLibraryRequest(home,raw){const input=DesktopLibraryRequestSchema.parse(raw);return(await client(home)).library.call(input.call)}async function prepareDesktopLibraryImport(raw){const input=DesktopLibraryPrepareRequestSchema.parse(raw);return DesktopLibraryImportRequestSchema.parse({operation:"library-import",file:input.file,input:await captureLibraryImport(input.file,input.seed)})}async function runDesktopLibraryImport(home,raw){const input=DesktopLibraryImportRequestSchema.parse(raw);return importLibraryFile((await client(home)).library,input.file,input.input)}async function runDesktopLibraryMedia(home,raw){const input=DesktopLibraryMediaRequestSchema.parse(raw);return(await client(home)).library.media(input.input,{method:input.method,...input.range?{range:input.range}:{}})}export{DesktopLibraryImportSeedSchema,DesktopLibraryRequestSchema,DesktopLibraryImportRequestSchema,DesktopLibraryPrepareRequestSchema,DesktopLibraryMediaRequestSchema,DesktopLibraryReplySchema,runDesktopLibraryRequest,prepareDesktopLibraryImport,runDesktopLibraryImport,runDesktopLibraryMedia};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{tenantConnection}from"./chunk-
|
|
1
|
+
import{tenantConnection}from"./chunk-SV3NF7GO.js";import{FileOAuthProvider,withProfileLock}from"./chunk-FU3524Z6.js";import{remoteResponse,secureEndpoint}from"./chunk-PUNG4ND7.js";import{NativeStudioSdkError}from"./chunk-HTUTYIRU.js";async function apiMetadata(url){let response;try{response=await remoteResponse(url,{headers:{accept:"application/json"},signal:AbortSignal.timeout(5e3)});if(!response.ok)return void 0;const parts=[];let size=0;for await(const part of response.body??[]){size+=part.byteLength;if(size>16384)return void 0;parts.push(part)}const data=JSON.parse(Buffer.concat(parts).toString());return data&&typeof data==="object"&&!Array.isArray(data)?data:void 0}catch{return void 0}finally{await response?.body?.cancel().catch(()=>{})}}async function profileHttpOrigin(path,resource){return withProfileLock(path,async()=>{const provider=await FileOAuthProvider.load(path);const deny=()=>{throw new NativeStudioSdkError("API_ORIGIN_UNTRUSTED","BLOCKED","NO_WRITE")};if(provider.data.resource!==resource)deny();if(provider.data.pendingExchange)throw new NativeStudioSdkError("OAUTH_OUTCOME_UNKNOWN","BLOCKED","UNKNOWN");tenantConnection(resource);const endpoint=secureEndpoint(resource);const metadataUrl=endpoint.origin+"/.well-known/oauth-protected-resource"+endpoint.pathname;const fresh=await apiMetadata(metadataUrl);if(fresh&&fresh.resource!==resource)deny();const metadata=fresh??provider.data.discovery?.resourceMetadata;const configured=metadata?.nativestudio_api_origin;if(configured===void 0){if(fresh&&provider.data.discovery){const saved={...provider.data.discovery.resourceMetadata,resource};Reflect.deleteProperty(saved,"nativestudio_api_origin");provider.data.discovery.resourceMetadata=saved;provider.data.discovery.resourceMetadataUrl=metadataUrl;await provider.save()}return endpoint.origin}try{if(typeof configured!=="string")return deny();const sourceUrl=metadata===fresh?metadataUrl:provider.data.discovery?.resourceMetadataUrl;if(typeof sourceUrl!=="string"||secureEndpoint(sourceUrl).origin!==endpoint.origin||metadata?.resource!==resource||configured.length>2048)deny();const api=secureEndpoint(configured);if(api.pathname!=="/"||endpoint.protocol==="https:"&&api.protocol!=="https:")deny();if(metadata===fresh&&provider.data.discovery){provider.data.discovery.resourceMetadata={...provider.data.discovery.resourceMetadata,resource,nativestudio_api_origin:api.origin};provider.data.discovery.resourceMetadataUrl=metadataUrl;await provider.save()}return api.origin}catch{return deny()}})}export{profileHttpOrigin};
|