@nativestudio/cli 0.3.0-rc.11 → 0.3.0-rc.15

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.
Files changed (177) hide show
  1. package/COMPATIBILITY.json +14 -10
  2. package/components/runtime.json +10 -6
  3. package/components/runtime.tgz +0 -0
  4. package/dist/_chunks/chunk-5UJEP7FY.js +1 -0
  5. package/dist/_chunks/chunk-6UYY5KHI.js +1 -0
  6. package/dist/_chunks/chunk-AAGFHT2D.js +1 -0
  7. package/dist/_chunks/{chunk-M2KVQQ4X.js → chunk-BBTZJB2G.js} +1 -1
  8. package/dist/_chunks/chunk-BX2SNMA4.js +1 -0
  9. package/dist/_chunks/chunk-CFZNDURD.js +1 -0
  10. package/dist/_chunks/{chunk-3AVC742O.js → chunk-FX5UVDTH.js} +1 -1
  11. package/dist/_chunks/{chunk-HR34UMPP.js → chunk-H6EZKOYR.js} +1 -1
  12. package/dist/_chunks/chunk-I5KYSPUJ.js +1 -0
  13. package/dist/_chunks/chunk-KOCUZ3AE.js +1 -0
  14. package/dist/_chunks/{chunk-L543FEDK.js → chunk-NPDLPC5B.js} +1 -1
  15. package/dist/_chunks/{chunk-LISB5W7B.js → chunk-NQVUVPW5.js} +1 -1
  16. package/dist/_chunks/{chunk-EGUJ2YRX.js → chunk-O47YYPL7.js} +1 -1
  17. package/dist/_chunks/{chunk-65FQPXKC.js → chunk-OVIR77ET.js} +1 -1
  18. package/dist/_chunks/{chunk-VDNNFVTZ.js → chunk-OW6R4MAQ.js} +1 -1
  19. package/dist/_chunks/{chunk-ODGPV7MM.js → chunk-PB2HLRXG.js} +1 -1
  20. package/dist/_chunks/chunk-PDQYFIQQ.js +1 -0
  21. package/dist/_chunks/chunk-RUPH3HZ2.js +1 -0
  22. package/dist/_chunks/chunk-SAPEOZ2V.js +1 -0
  23. package/dist/_chunks/chunk-SKAVQ4UW.js +1 -0
  24. package/dist/_chunks/{chunk-4U4Y2K73.js → chunk-TTB7CYC5.js} +1 -1
  25. package/dist/_chunks/chunk-U5FT4VBR.js +1 -0
  26. package/dist/_chunks/chunk-VOGKKZQH.js +1 -0
  27. package/dist/_chunks/chunk-YV447AB5.js +1 -0
  28. package/dist/_chunks/{chunk-LUAH3KAS.js → chunk-ZADAXKKY.js} +1 -1
  29. package/dist/_chunks/{chunk-QAJH4RJQ.js → chunk-ZOODOQBH.js} +1 -1
  30. package/dist/_chunks/{connect-5YMO6MAR.js → connect-RIODOO3C.js} +1 -1
  31. package/dist/_chunks/{device-management-2OTGEBJQ.js → device-management-VECG3RA4.js} +1 -1
  32. package/dist/_chunks/{device-preflight-XPHFZGLO.js → device-preflight-73KVSHZG.js} +1 -1
  33. package/dist/_chunks/{devices-inventory-VWNTU5TE.js → devices-inventory-E6TE4H7T.js} +1 -1
  34. package/dist/_chunks/{devices-main-VQ4APRVS.js → devices-main-7JHMJNGV.js} +1 -1
  35. package/dist/_chunks/{files-TTIQ7LYJ.js → files-72BEXD7E.js} +1 -1
  36. package/dist/_chunks/{host-main-H7DPLV7B.js → host-main-KDORT44Q.js} +1 -1
  37. package/dist/_chunks/http-profile-QINBH2FP.js +1 -0
  38. package/dist/_chunks/{library-main-SAC3V2ML.js → library-main-AWUEMZFQ.js} +1 -1
  39. package/dist/_chunks/local-main-BNFNAPRG.js +1 -0
  40. package/dist/_chunks/{local-mcp-ONCANLPH.js → local-mcp-HU6MII3G.js} +1 -1
  41. package/dist/_chunks/main-BSMCHALI.js +2 -0
  42. package/dist/_chunks/mcp-3VZZFXNG.js +1 -0
  43. package/dist/_chunks/oauth-QBJ62PIA.js +1 -0
  44. package/dist/_chunks/observe-entry-D7F6OQ7Y.js +1 -0
  45. package/dist/_chunks/remote-client-XIJ6RQLU.js +1 -0
  46. package/dist/_chunks/{render-main-GYWKP72O.js → render-main-O3IN6EFV.js} +1 -1
  47. package/dist/_chunks/{source-import-BC5GNCUZ.js → source-import-Y2Z3BVWY.js} +1 -1
  48. package/dist/_chunks/src-3S6CAUSJ.js +1 -0
  49. package/dist/_chunks/{stdio-main-RIJS5REB.js → stdio-main-T4WMBNKB.js} +1 -1
  50. package/dist/_chunks/workspace-main-KWFTVTZG.js +1 -0
  51. package/dist/_types/cli/local/desktop-contract.d.ts +64 -6
  52. package/dist/_types/cli/local/desktop-device-contract.d.ts +25 -12
  53. package/dist/_types/cli/local/desktop-device-owner.d.ts +34 -8
  54. package/dist/_types/cli/local/desktop-device-state.d.ts +64 -12
  55. package/dist/_types/cli/local/desktop-owner.d.ts +58 -9
  56. package/dist/_types/cli/local/ledger.d.ts +10 -10
  57. package/dist/_types/cli/local/manager.d.ts +121 -18
  58. package/dist/_types/cli/local/mcp-tools.d.ts +14 -13
  59. package/dist/_types/cli/local/releases.d.ts +2 -2
  60. package/dist/_types/cli/local-management.d.ts +3 -0
  61. package/dist/_types/contracts/artifact-discovery.d.ts +60 -0
  62. package/dist/_types/contracts/audio.d.ts +162 -0
  63. package/dist/_types/contracts/consistency-profile.d.ts +102 -6
  64. package/dist/_types/contracts/continuity-evaluation.d.ts +1 -1
  65. package/dist/_types/contracts/delivery-operations.d.ts +150 -0
  66. package/dist/_types/contracts/device-render.d.ts +2 -0
  67. package/dist/_types/contracts/editor-intelligence.d.ts +280 -42
  68. package/dist/_types/contracts/final-render.d.ts +188 -24
  69. package/dist/_types/contracts/human-links.d.ts +58 -0
  70. package/dist/_types/contracts/index.d.ts +8 -0
  71. package/dist/_types/contracts/interface/media-output.d.ts +90 -0
  72. package/dist/_types/contracts/interface/operation.d.ts +30 -0
  73. package/dist/_types/contracts/interface/production-snapshot.d.ts +60 -0
  74. package/dist/_types/contracts/interface/query.d.ts +60 -0
  75. package/dist/_types/contracts/keyframe-generation.d.ts +1 -1
  76. package/dist/_types/contracts/lifecycle-event-projections.d.ts +15 -0
  77. package/dist/_types/contracts/lifecycle-events.d.ts +53 -1
  78. package/dist/_types/contracts/local-execution/agent-context.d.ts +23 -3
  79. package/dist/_types/contracts/local-execution/agent-review.d.ts +29 -3
  80. package/dist/_types/contracts/local-execution/audio-profile.d.ts +6 -0
  81. package/dist/_types/contracts/local-execution/cpu-preparation.d.ts +46 -0
  82. package/dist/_types/contracts/local-execution/cpu-resources.d.ts +55 -0
  83. package/dist/_types/contracts/local-execution/cpu-speech-job.d.ts +70 -0
  84. package/dist/_types/contracts/local-execution/cpu-speech.d.ts +161 -0
  85. package/dist/_types/contracts/local-execution/descriptor.d.ts +1 -1
  86. package/dist/_types/contracts/local-execution/device-inventory.d.ts +2 -2
  87. package/dist/_types/contracts/local-execution/device.d.ts +3 -3
  88. package/dist/_types/contracts/local-execution/index.d.ts +6 -0
  89. package/dist/_types/contracts/local-execution/ipc.d.ts +18 -2
  90. package/dist/_types/contracts/local-execution/library-result.d.ts +16 -0
  91. package/dist/_types/contracts/local-execution/lifecycle.d.ts +49 -7
  92. package/dist/_types/contracts/local-execution/local-navigation.d.ts +15 -14
  93. package/dist/_types/contracts/local-execution/management.d.ts +15 -11
  94. package/dist/_types/contracts/local-execution/preview.d.ts +38 -3
  95. package/dist/_types/contracts/local-execution/processor-capability.d.ts +2 -0
  96. package/dist/_types/contracts/local-execution/processor-recipes.d.ts +43 -0
  97. package/dist/_types/contracts/local-execution/processor-toolchain.d.ts +47 -0
  98. package/dist/_types/contracts/local-execution/processor.d.ts +184 -3
  99. package/dist/_types/contracts/local-execution/speech.d.ts +1 -1
  100. package/dist/_types/contracts/local-execution/tool-selection.d.ts +26 -0
  101. package/dist/_types/contracts/local-execution/work.d.ts +16 -2
  102. package/dist/_types/contracts/native-speech-model.d.ts +53 -0
  103. package/dist/_types/contracts/native-speech-options.d.ts +25 -0
  104. package/dist/_types/contracts/navigation-context.d.ts +2 -2
  105. package/dist/_types/contracts/navigation-groups.d.ts +1 -1
  106. package/dist/_types/contracts/navigation.d.ts +35 -5
  107. package/dist/_types/contracts/production-creation.d.ts +30 -0
  108. package/dist/_types/contracts/production-feedback.d.ts +452 -0
  109. package/dist/_types/contracts/production.d.ts +30 -0
  110. package/dist/_types/contracts/project-library.d.ts +30 -0
  111. package/dist/_types/contracts/project.d.ts +30 -0
  112. package/dist/_types/contracts/provider-models.d.ts +193 -0
  113. package/dist/_types/contracts/repair-lifecycle.d.ts +4 -4
  114. package/dist/_types/contracts/repair-plan.d.ts +1 -1
  115. package/dist/_types/contracts/repair-strategy.d.ts +9 -5
  116. package/dist/_types/contracts/review-intelligence-final-output.d.ts +90 -0
  117. package/dist/_types/contracts/review-intelligence.d.ts +3 -1
  118. package/dist/_types/contracts/rough-cut-manifest.d.ts +19 -4
  119. package/dist/_types/contracts/rough-cut-review.d.ts +10 -1
  120. package/dist/_types/contracts/rough-cut.d.ts +111 -12
  121. package/dist/_types/contracts/shares.d.ts +135 -0
  122. package/dist/_types/contracts/shot-preparation-basis.d.ts +2 -2
  123. package/dist/_types/contracts/shot-preparation.d.ts +4 -4
  124. package/dist/_types/contracts/sound-making-plan.d.ts +207 -0
  125. package/dist/_types/contracts/speech-cost.d.ts +15 -0
  126. package/dist/_types/contracts/speech-parameters.d.ts +39 -0
  127. package/dist/_types/contracts/speech.d.ts +470 -39
  128. package/dist/_types/contracts/timeline-audio.d.ts +19 -4
  129. package/dist/_types/contracts/timeline-manifest.d.ts +38 -8
  130. package/dist/_types/contracts/timeline-source-sound.d.ts +41 -4
  131. package/dist/_types/contracts/timeline-v2.d.ts +120 -16
  132. package/dist/_types/contracts/timeline-version-reader.d.ts +278 -40
  133. package/dist/_types/contracts/timeline-visual-layers.d.ts +120 -16
  134. package/dist/_types/contracts/video-generation.d.ts +1 -1
  135. package/dist/_types/contracts/visual-exploration.d.ts +1 -1
  136. package/dist/_types/contracts/visual-layer-render.d.ts +240 -32
  137. package/dist/_types/contracts/visual-sequence.d.ts +1 -1
  138. package/dist/_types/contracts/voice-consistency.d.ts +183 -0
  139. package/dist/_types/contracts/voice-profile/contracts.d.ts +821 -0
  140. package/dist/_types/contracts/voice-profile/identity.d.ts +27 -0
  141. package/dist/_types/contracts/voice-profile/interface.d.ts +89 -0
  142. package/dist/_types/contracts/voice-profile/reference.d.ts +106 -0
  143. package/dist/_types/contracts/voice-review.d.ts +1194 -0
  144. package/dist/_types/contracts/workspace.d.ts +51 -0
  145. package/dist/_types/sdk/local-runtime/device-client.d.ts +54 -2
  146. package/dist/_types/sdk/local-runtime-client.d.ts +169 -28
  147. package/dist/entry.js +1 -1
  148. package/dist/local-management.js +1 -1
  149. package/dist/local-navigation.js +1 -1
  150. package/dist/native/helper.exe +0 -0
  151. package/dist/native/helper.json +1 -0
  152. package/package.json +1 -1
  153. package/dist/_chunks/chunk-37PAJCKA.js +0 -1
  154. package/dist/_chunks/chunk-6DVZBKNV.js +0 -1
  155. package/dist/_chunks/chunk-6LU6GJKW.js +0 -1
  156. package/dist/_chunks/chunk-6N433ZWR.js +0 -1
  157. package/dist/_chunks/chunk-FU3524Z6.js +0 -1
  158. package/dist/_chunks/chunk-GZBWA4YN.js +0 -1
  159. package/dist/_chunks/chunk-KB2GVAN7.js +0 -1
  160. package/dist/_chunks/chunk-PUBMDP4E.js +0 -1
  161. package/dist/_chunks/chunk-PUNG4ND7.js +0 -1
  162. package/dist/_chunks/chunk-Q57YFNK5.js +0 -1
  163. package/dist/_chunks/chunk-VPYAXWXY.js +0 -1
  164. package/dist/_chunks/chunk-WFRRNWO5.js +0 -1
  165. package/dist/_chunks/http-profile-MNJX6OXO.js +0 -1
  166. package/dist/_chunks/local-main-D6B3APK6.js +0 -1
  167. package/dist/_chunks/main-PW6HB3NC.js +0 -2
  168. package/dist/_chunks/mcp-ZIGBYFUW.js +0 -1
  169. package/dist/_chunks/oauth-HC6TI7HB.js +0 -1
  170. package/dist/_chunks/src-R6DNU336.js +0 -1
  171. package/dist/_chunks/workspace-main-GNSKHKBG.js +0 -1
  172. package/dist/native/Bootstrap.ps1 +0 -90
  173. package/dist/native/JobNative.cs +0 -137
  174. package/dist/native/JobRunner.cs +0 -381
  175. package/dist/native/NativeMain.cs +0 -161
  176. package/dist/native/PipeBridge.cs +0 -260
  177. package/dist/native/PrivateAccess.cs +0 -152
@@ -1 +0,0 @@
1
- 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 directory2=assetDirectory??fileURLToPath(new URL("./dist/native/",import.meta.resolve("@nativestudio/cli/package.json")));const hash=createHash("sha256");for(const name of nativeAssetNames){hash.update(name+"\n");hash.update(await readFile(join(directory2,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(directory2,"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:directory2,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(["EXISTS","RESOURCE_BUDGET_EXCEEDED"].includes(value.error??"")?value.error:"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(request,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({...request,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")}}async function syncDirectory(path){if(process.platform==="win32")return;const d=await open(path,"r");try{await d.sync()}finally{await d.close()}}async function atomicMove(source,target,exclusive=false){if(dirname(source)!==dirname(target))throw Error("LOCAL_ATOMIC_MOVE_INVALID");if(process.platform==="win32"){try{await windowsRequest({operation:"move",source,target,exclusive})}catch(error){if(error.message==="EXISTS")throw Object.assign(Error("EXISTS"),{code:"EEXIST"});throw error}}else{if(exclusive){await link(source,target);await unlink(source)}else await rename(source,target);await syncDirectory(dirname(target))}}async function assertExecutable(path){const s=await lstat2(path);if(!isAbsolute2(path)||!s.isFile()||s.isSymbolicLink()||s.nlink!==1)throw Error("LOCAL_EXECUTABLE_INVALID");if(process.platform==="win32"){if(!path.toLowerCase().endsWith(".exe"))throw Error("LOCAL_EXECUTABLE_INVALID");await windowsRequest({operation:"executable",path})}else if(!(s.mode&73)||s.mode&18)throw Error("LOCAL_EXECUTABLE_INVALID")}import{spawn as spawn2}from"node:child_process";import{Duplex}from"node:stream";import{constants}from"node:fs";import{open as open2,realpath as realpath2,rename as rename2,unlink as unlink2,link as link2,readdir}from"node:fs/promises";import{isAbsolute as isAbsolute3,join as join3,dirname as dirname2}from"node:path";import{randomUUID as randomUUID2,createHash as createHash3}from"node:crypto";var sha256=v=>createHash3("sha256").update(v).digest("hex");var sha512=v=>createHash3("sha512").update(v).digest("hex");var LocalClientError=class extends Error{constructor(code){super("NativeStudio local "+code);this.code=code}code};function fail(code){throw new LocalClientError(code)}async function directory(path){if(!isAbsolute3(path))fail("LOCATION_UNSUPPORTED");try{await privateDirectory(path,true)}catch{fail("PRIVATE_LOCATION_REQUIRED")}const root=await realpath2(path);if(/(?:^|[\\/])(?:node_modules|_npx)(?:[\\/]|$)/.test(root))fail("PRIVATE_LOCATION_REQUIRED");return root}async function read(path,maximum=65536,ledger=false){try{await privateAccess(path,"file")}catch(e){if(e.code==="ENOENT")throw e;fail("PRIVATE_FILE_REQUIRED")}const f=await open2(path,constants.O_RDONLY|constants.O_NOFOLLOW);try{const s=await f.stat();if(!s.isFile()||process.platform!=="win32"&&(s.uid!==process.getuid?.()||s.mode&63)||s.size>maximum||(ledger?s.nlink>2:s.nlink!==1))fail("PRIVATE_FILE_REQUIRED");const bytes=Buffer.alloc(Math.min(maximum+1,s.size+1));let used=0;while(used<bytes.length){const part=await f.read(bytes,used,bytes.length-used,null);if(!part.bytesRead)break;used+=part.bytesRead}if(used>s.size)fail("FILE_CHANGED");if(used>maximum)fail("FILE_LIMIT");return bytes.subarray(0,used)}finally{await f.close()}}async function write(path,value,exclusive=false){const temporary=join3(dirname2(path),".tmp-"+randomUUID2());const f=await open2(temporary,"wx",384);try{await f.writeFile(value);await f.sync()}finally{await f.close()}try{if(process.platform==="win32")await atomicMove(temporary,path,exclusive);else if(exclusive)await link2(temporary,path);else{try{await read(path,64*1024*1024)}catch(e){if(e.code!=="ENOENT")throw e}await rename2(temporary,path)}}finally{await unlink2(temporary).catch(e=>{if(e.code!=="ENOENT")throw e})}await syncDirectory(dirname2(path))}async function entries(path){const values=await readdir(path);if(values.length>1e4)fail("HISTORY_LIMIT");return values}async function optional(path){try{return JSON.parse((await read(path)).toString())}catch(e){if(e.code==="ENOENT")return null;throw e}}async function verifyBackup(path,stateDirectory){const base=await realpath2(join3(stateDirectory,"backups")),actual=await realpath2(path);if(dirname2(actual)!==base||!/[0-9a-f-]{36}\.sqlite$/.test(actual))fail("JOURNAL_BACKUP_REQUIRED");try{await privateAccess(actual,"file")}catch{fail("JOURNAL_BACKUP_REQUIRED")}const f=await open2(actual,constants.O_RDONLY|constants.O_NOFOLLOW);try{const stat=await f.stat(),header=Buffer.alloc(16);if(!stat.isFile()||stat.nlink!==1||process.platform!=="win32"&&(stat.uid!==process.getuid?.()||stat.mode&63)||stat.size<100)fail("JOURNAL_BACKUP_REQUIRED");const n=await f.read(header,0,16,0);if(n.bytesRead!==16||header.toString()!=="SQLite format 3\0")fail("JOURNAL_BACKUP_REQUIRED")}finally{await f.close()}}export{localSocketPath,privateAccess,privateDirectory,atomicMove,assertExecutable,sha256,sha512,LocalClientError,fail,directory,read,write,entries,optional,verifyBackup};