@nativestudio/cli 0.3.0-rc.2 → 0.3.0-rc.20

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 (283) hide show
  1. package/COMPATIBILITY.json +37 -8
  2. package/LICENSE +201 -21
  3. package/components/runtime.json +33 -4
  4. package/components/runtime.tgz +0 -0
  5. package/dist/_chunks/chunk-27KI24GK.js +1 -0
  6. package/dist/_chunks/{chunk-C33A2DW4.js → chunk-3TOXIJ7K.js} +1 -1
  7. package/dist/_chunks/chunk-4M2SOMSN.js +1 -0
  8. package/dist/_chunks/chunk-4PAVWOPA.js +1 -0
  9. package/dist/_chunks/chunk-6EZX2TRX.js +1 -0
  10. package/dist/_chunks/chunk-7I7ARCY7.js +1 -0
  11. package/dist/_chunks/chunk-7P2NA6TH.js +1 -0
  12. package/dist/_chunks/chunk-AFNJRZLJ.js +1 -0
  13. package/dist/_chunks/chunk-APNZQZFB.js +1 -0
  14. package/dist/_chunks/chunk-D74NHT4I.js +45 -0
  15. package/dist/_chunks/chunk-DLW42PJ6.js +1 -0
  16. package/dist/_chunks/chunk-ELUJ44BO.js +1 -0
  17. package/dist/_chunks/chunk-FVY3PLG7.js +1 -0
  18. package/dist/_chunks/chunk-GLAF74UU.js +1 -0
  19. package/dist/_chunks/chunk-HBDPYWMI.js +1 -0
  20. package/dist/_chunks/chunk-IYDHDLTR.js +1 -0
  21. package/dist/_chunks/chunk-K35CWLDH.js +1 -0
  22. package/dist/_chunks/chunk-KOCUZ3AE.js +1 -0
  23. package/dist/_chunks/chunk-L3QA7FLZ.js +1 -0
  24. package/dist/_chunks/chunk-LBK42NHW.js +1 -0
  25. package/dist/_chunks/chunk-MLZ3ZPGU.js +1 -0
  26. package/dist/_chunks/chunk-NG4BDFEY.js +1 -0
  27. package/dist/_chunks/chunk-OSO6KRE2.js +1 -0
  28. package/dist/_chunks/{chunk-VDNNFVTZ.js → chunk-OW6R4MAQ.js} +1 -1
  29. package/dist/_chunks/chunk-QE7O57PQ.js +1 -0
  30. package/dist/_chunks/chunk-QGK6G6YS.js +1 -0
  31. package/dist/_chunks/chunk-QK4XPVKT.js +1 -0
  32. package/dist/_chunks/chunk-ROGOASYF.js +1 -0
  33. package/dist/_chunks/chunk-TT7IA5HB.js +1 -0
  34. package/dist/_chunks/chunk-UYKCN5DU.js +1 -0
  35. package/dist/_chunks/chunk-WTJVS2VS.js +1 -0
  36. package/dist/_chunks/chunk-XUSVNPR5.js +1 -0
  37. package/dist/_chunks/component-contract-KXK7WIUI.js +1 -0
  38. package/dist/_chunks/component-preflight-WECLCZLF.js +1 -0
  39. package/dist/_chunks/connect-7TJDWXV4.js +1 -0
  40. package/dist/_chunks/device-management-TLRUMZL5.js +1 -0
  41. package/dist/_chunks/device-preflight-C7FFUXI2.js +1 -0
  42. package/dist/_chunks/devices-inventory-BZF53UAU.js +1 -0
  43. package/dist/_chunks/devices-main-V3YHCB2C.js +1 -0
  44. package/dist/_chunks/files-JJ6YOULB.js +1 -0
  45. package/dist/_chunks/host-component-Q5IHRHRI.js +1 -0
  46. package/dist/_chunks/host-help-7BGYR4ET.js +1 -0
  47. package/dist/_chunks/host-main-JLIBRHC2.js +1 -0
  48. package/dist/_chunks/http-profile-3VVSWYA5.js +1 -0
  49. package/dist/_chunks/library-main-ATRFEAVN.js +1 -0
  50. package/dist/_chunks/local-main-KTYCLHDA.js +1 -0
  51. package/dist/_chunks/local-mcp-ISMU6ADI.js +1 -0
  52. package/dist/_chunks/main-MOZS2EK3.js +2 -0
  53. package/dist/_chunks/mcp-M2SO3J2H.js +1 -0
  54. package/dist/_chunks/oauth-RPME2XYB.js +1 -0
  55. package/dist/_chunks/observe-entry-E6DFHIMW.js +1 -0
  56. package/dist/_chunks/remote-client-T75C45JO.js +1 -0
  57. package/dist/_chunks/render-main-OGCO2LX4.js +1 -0
  58. package/dist/_chunks/series-main-FBERVYWG.js +1 -0
  59. package/dist/_chunks/source-import-55JJ26AA.js +1 -0
  60. package/dist/_chunks/src-V2K52JDH.js +1 -0
  61. package/dist/_chunks/stdio-main-HNLJCG45.js +1 -0
  62. package/dist/_chunks/workspace-main-3P56DSEQ.js +1 -0
  63. package/dist/_types/cli/local/desktop-contract.d.ts +1981 -22
  64. package/dist/_types/cli/local/desktop-device-contract.d.ts +807 -0
  65. package/dist/_types/cli/local/desktop-device-navigation.d.ts +3 -0
  66. package/dist/_types/cli/local/desktop-device-owner.d.ts +273 -0
  67. package/dist/_types/cli/local/desktop-device-state.d.ts +455 -0
  68. package/dist/_types/cli/local/desktop-library.d.ts +853 -0
  69. package/dist/_types/cli/local/desktop-owner.d.ts +787 -4
  70. package/dist/_types/cli/local/ledger.d.ts +76 -20
  71. package/dist/_types/cli/local/manager.d.ts +1233 -49
  72. package/dist/_types/cli/local/mcp-tools.d.ts +313 -54
  73. package/dist/_types/cli/local/releases.d.ts +30 -7
  74. package/dist/_types/cli/local-management.d.ts +9 -2
  75. package/dist/_types/cli/local-navigation.d.ts +1 -0
  76. package/dist/_types/contracts/agent-execution-lifecycle.d.ts +55 -43
  77. package/dist/_types/contracts/agent-execution-oauth.d.ts +2 -2
  78. package/dist/_types/contracts/agent-execution-registration.d.ts +59 -15
  79. package/dist/_types/contracts/agent-execution-selection.d.ts +7 -7
  80. package/dist/_types/contracts/agent-host-contract.d.ts +189 -0
  81. package/dist/_types/contracts/agent-host-execution.d.ts +92 -61
  82. package/dist/_types/contracts/agent-host-generic-transport.d.ts +4 -4
  83. package/dist/_types/contracts/agent-host-legacy-release.d.ts +31 -0
  84. package/dist/_types/contracts/agent-host-protocol.d.ts +71 -0
  85. package/dist/_types/contracts/agent-host-wire.d.ts +263 -0
  86. package/dist/_types/contracts/agent-host.d.ts +126 -65
  87. package/dist/_types/contracts/artifact-discovery.d.ts +143 -11
  88. package/dist/_types/contracts/audio.d.ts +166 -0
  89. package/dist/_types/contracts/component-status.d.ts +241 -0
  90. package/dist/_types/contracts/composition-authoring.d.ts +8 -8
  91. package/dist/_types/contracts/composition-frame-render.d.ts +4 -4
  92. package/dist/_types/contracts/composition-observation.d.ts +1 -1
  93. package/dist/_types/contracts/composition-render-base.d.ts +5 -4
  94. package/dist/_types/contracts/composition-render.d.ts +8 -8
  95. package/dist/_types/contracts/composition-repair.d.ts +10 -10
  96. package/dist/_types/contracts/composition-source-review.d.ts +13 -13
  97. package/dist/_types/contracts/consistency-profile.d.ts +102 -6
  98. package/dist/_types/contracts/continuity-evaluation.d.ts +1 -1
  99. package/dist/_types/contracts/delivery-completion.d.ts +1 -1
  100. package/dist/_types/contracts/delivery-manifest.d.ts +25 -11729
  101. package/dist/_types/contracts/delivery-operations.d.ts +207 -3915
  102. package/dist/_types/contracts/delivery-summary.d.ts +4 -4
  103. package/dist/_types/contracts/delivery-validation.d.ts +25 -2
  104. package/dist/_types/contracts/device-onboarding.d.ts +35 -0
  105. package/dist/_types/contracts/device-render.d.ts +113 -0
  106. package/dist/_types/contracts/editor-intelligence.d.ts +392 -2531
  107. package/dist/_types/contracts/enterprise-brand.d.ts +302 -0
  108. package/dist/_types/contracts/exploration-recommendation.d.ts +263 -11607
  109. package/dist/_types/contracts/external-agent-access.d.ts +4 -6
  110. package/dist/_types/contracts/federation-event-link-receiver.d.ts +200 -0
  111. package/dist/_types/contracts/federation-event-link.d.ts +485 -0
  112. package/dist/_types/contracts/federation-result.d.ts +239 -0
  113. package/dist/_types/contracts/final-ready.d.ts +24 -24
  114. package/dist/_types/contracts/final-render.d.ts +1742 -6949
  115. package/dist/_types/contracts/human-identity.d.ts +13 -0
  116. package/dist/_types/contracts/human-links.d.ts +58 -0
  117. package/dist/_types/contracts/index.d.ts +26 -0
  118. package/dist/_types/contracts/interface/common.d.ts +18 -0
  119. package/dist/_types/contracts/interface/execution-output.d.ts +9 -6
  120. package/dist/_types/contracts/interface/media-output.d.ts +118 -0
  121. package/dist/_types/contracts/interface/operation.d.ts +30 -0
  122. package/dist/_types/contracts/interface/production-snapshot.d.ts +81 -199
  123. package/dist/_types/contracts/interface/query.d.ts +60 -0
  124. package/dist/_types/contracts/keyframe-generation.d.ts +31 -2
  125. package/dist/_types/contracts/keyframe-review.d.ts +7 -7
  126. package/dist/_types/contracts/lifecycle-event-projections.d.ts +17 -2
  127. package/dist/_types/contracts/lifecycle-events.d.ts +54 -2
  128. package/dist/_types/contracts/local-execution/agent-component-status.d.ts +109 -0
  129. package/dist/_types/contracts/local-execution/agent-context.d.ts +385 -0
  130. package/dist/_types/contracts/local-execution/agent-evidence.d.ts +79 -0
  131. package/dist/_types/contracts/local-execution/agent-grant.d.ts +31 -0
  132. package/dist/_types/contracts/local-execution/agent-review.d.ts +529 -71
  133. package/dist/_types/contracts/local-execution/audio-profile.d.ts +6 -0
  134. package/dist/_types/contracts/local-execution/common.d.ts +12 -11
  135. package/dist/_types/contracts/local-execution/completion.d.ts +41 -45
  136. package/dist/_types/contracts/local-execution/components.d.ts +45 -0
  137. package/dist/_types/contracts/local-execution/cpu-preparation.d.ts +46 -0
  138. package/dist/_types/contracts/local-execution/cpu-resources.d.ts +55 -0
  139. package/dist/_types/contracts/local-execution/cpu-speech-job.d.ts +70 -0
  140. package/dist/_types/contracts/local-execution/cpu-speech.d.ts +161 -0
  141. package/dist/_types/contracts/local-execution/descriptor.d.ts +38 -0
  142. package/dist/_types/contracts/local-execution/device-authority.d.ts +31 -0
  143. package/dist/_types/contracts/local-execution/device-inventory.d.ts +108 -0
  144. package/dist/_types/contracts/local-execution/device-workspace.d.ts +11 -0
  145. package/dist/_types/contracts/local-execution/device.d.ts +24 -55
  146. package/dist/_types/contracts/local-execution/enrollment-credential.d.ts +141 -0
  147. package/dist/_types/contracts/local-execution/enrollment-handoff.d.ts +44 -0
  148. package/dist/_types/contracts/local-execution/external-generation.d.ts +199 -0
  149. package/dist/_types/contracts/local-execution/index.d.ts +36 -0
  150. package/dist/_types/contracts/local-execution/ipc.d.ts +2809 -231
  151. package/dist/_types/contracts/local-execution/library-command.d.ts +620 -0
  152. package/dist/_types/contracts/local-execution/library-result.d.ts +428 -0
  153. package/dist/_types/contracts/local-execution/library.d.ts +873 -0
  154. package/dist/_types/contracts/local-execution/lifecycle.d.ts +262 -48
  155. package/dist/_types/contracts/local-execution/local-navigation.d.ts +304 -67
  156. package/dist/_types/contracts/local-execution/management.d.ts +407 -0
  157. package/dist/_types/contracts/local-execution/media-recipe.d.ts +207 -0
  158. package/dist/_types/contracts/local-execution/media-validation-request.d.ts +232 -0
  159. package/dist/_types/contracts/local-execution/media-validation.d.ts +262 -0
  160. package/dist/_types/contracts/local-execution/object-transfer.d.ts +155 -0
  161. package/dist/_types/contracts/local-execution/offline.d.ts +59 -0
  162. package/dist/_types/contracts/local-execution/preview.d.ts +177 -3561
  163. package/dist/_types/contracts/local-execution/processor-capability.d.ts +49 -0
  164. package/dist/_types/contracts/local-execution/processor-direct.d.ts +290 -0
  165. package/dist/_types/contracts/local-execution/processor-recipes.d.ts +1194 -0
  166. package/dist/_types/contracts/local-execution/processor-toolchain.d.ts +47 -0
  167. package/dist/_types/contracts/local-execution/processor.d.ts +6424 -0
  168. package/dist/_types/contracts/local-execution/project-source-direct.d.ts +201 -0
  169. package/dist/_types/contracts/local-execution/qwen-tts.d.ts +31 -0
  170. package/dist/_types/contracts/local-execution/recognition.d.ts +170 -0
  171. package/dist/_types/contracts/local-execution/speech.d.ts +95 -0
  172. package/dist/_types/contracts/local-execution/tool-selection.d.ts +71 -5
  173. package/dist/_types/contracts/local-execution/whisper.d.ts +24 -0
  174. package/dist/_types/contracts/local-execution/work.d.ts +124 -3402
  175. package/dist/_types/contracts/local-execution/workspace.d.ts +141 -0
  176. package/dist/_types/contracts/mcp-capabilities.d.ts +16 -0
  177. package/dist/_types/contracts/media-category.d.ts +11 -0
  178. package/dist/_types/contracts/media-observation.d.ts +930 -9
  179. package/dist/_types/contracts/native-speech-model.d.ts +53 -0
  180. package/dist/_types/contracts/native-speech-options.d.ts +25 -0
  181. package/dist/_types/contracts/native-tool-authority.d.ts +25 -21
  182. package/dist/_types/contracts/native-tool-execution.d.ts +60 -39
  183. package/dist/_types/contracts/navigation-context.d.ts +28 -8
  184. package/dist/_types/contracts/navigation-groups.d.ts +2 -2
  185. package/dist/_types/contracts/navigation.d.ts +78 -25
  186. package/dist/_types/contracts/observation-profile.d.ts +3 -3
  187. package/dist/_types/contracts/production-creation.d.ts +30 -0
  188. package/dist/_types/contracts/production-feedback.d.ts +452 -0
  189. package/dist/_types/contracts/production.d.ts +30 -0
  190. package/dist/_types/contracts/programmatic-composition.d.ts +24 -24
  191. package/dist/_types/contracts/programmatic-exploration.d.ts +362 -5999
  192. package/dist/_types/contracts/programmatic-video-review.d.ts +5 -5
  193. package/dist/_types/contracts/project-library.d.ts +30 -0
  194. package/dist/_types/contracts/project.d.ts +30 -0
  195. package/dist/_types/contracts/provider-catalog.d.ts +3 -3
  196. package/dist/_types/contracts/provider-models.d.ts +209 -8
  197. package/dist/_types/contracts/provider.d.ts +66 -1
  198. package/dist/_types/contracts/reference-preview.d.ts +20 -0
  199. package/dist/_types/contracts/render-readiness.d.ts +175 -0
  200. package/dist/_types/contracts/repair-lifecycle.d.ts +64 -396
  201. package/dist/_types/contracts/repair-plan.d.ts +18 -100
  202. package/dist/_types/contracts/repair-strategy.d.ts +163 -4478
  203. package/dist/_types/contracts/review-intelligence-final-output.d.ts +418 -8150
  204. package/dist/_types/contracts/review-intelligence.d.ts +455 -11423
  205. package/dist/_types/contracts/review1-repair-source.d.ts +6 -6
  206. package/dist/_types/contracts/review1-repair-strategy.d.ts +4 -4
  207. package/dist/_types/contracts/rough-cut-manifest.d.ts +27 -7
  208. package/dist/_types/contracts/rough-cut-profile.d.ts +12 -3
  209. package/dist/_types/contracts/rough-cut-review.d.ts +144 -12495
  210. package/dist/_types/contracts/rough-cut.d.ts +1170 -5673
  211. package/dist/_types/contracts/series-canon.d.ts +97 -0
  212. package/dist/_types/contracts/series-character.d.ts +23 -0
  213. package/dist/_types/contracts/series-improvement.d.ts +1639 -0
  214. package/dist/_types/contracts/series-standard.d.ts +1641 -0
  215. package/dist/_types/contracts/shares.d.ts +135 -0
  216. package/dist/_types/contracts/shot-preparation-basis.d.ts +2 -2
  217. package/dist/_types/contracts/shot-preparation.d.ts +4 -4
  218. package/dist/_types/contracts/sound-making-plan.d.ts +210 -2
  219. package/dist/_types/contracts/speech-cost.d.ts +96 -0
  220. package/dist/_types/contracts/speech-parameters.d.ts +39 -0
  221. package/dist/_types/contracts/speech.d.ts +603 -23
  222. package/dist/_types/contracts/temporal-evidence-operation.d.ts +2 -1
  223. package/dist/_types/contracts/timeline-audio.d.ts +20 -4
  224. package/dist/_types/contracts/timeline-manifest.d.ts +40 -8
  225. package/dist/_types/contracts/timeline-source-sound.d.ts +42 -4
  226. package/dist/_types/contracts/timeline-v2.d.ts +124 -16
  227. package/dist/_types/contracts/timeline-version-reader.d.ts +288 -40
  228. package/dist/_types/contracts/timeline-visual-layers.d.ts +124 -16
  229. package/dist/_types/contracts/timeline.d.ts +50 -4850
  230. package/dist/_types/contracts/transcription.d.ts +1 -1
  231. package/dist/_types/contracts/video-generation.d.ts +35 -2
  232. package/dist/_types/contracts/video-review.d.ts +7 -7
  233. package/dist/_types/contracts/visual-exploration.d.ts +3 -3
  234. package/dist/_types/contracts/visual-layer-render.d.ts +298 -47
  235. package/dist/_types/contracts/visual-sequence.d.ts +22 -0
  236. package/dist/_types/contracts/voice-consistency.d.ts +183 -0
  237. package/dist/_types/contracts/voice-profile/contracts.d.ts +821 -0
  238. package/dist/_types/contracts/voice-profile/identity.d.ts +27 -0
  239. package/dist/_types/contracts/voice-profile/interface.d.ts +89 -0
  240. package/dist/_types/contracts/voice-profile/reference.d.ts +106 -0
  241. package/dist/_types/contracts/voice-review.d.ts +1194 -0
  242. package/dist/_types/contracts/workspace.d.ts +83 -0
  243. package/dist/_types/sdk/errors.d.ts +9 -3
  244. package/dist/_types/sdk/local-runtime/components.d.ts +2 -0
  245. package/dist/_types/sdk/local-runtime/device-client.d.ts +181 -19
  246. package/dist/_types/sdk/local-runtime/library.d.ts +268 -0
  247. package/dist/_types/sdk/local-runtime/workspace.d.ts +186 -0
  248. package/dist/_types/sdk/local-runtime-client.d.ts +1934 -96
  249. package/dist/entry.js +1 -1
  250. package/dist/local-management.js +1 -1
  251. package/dist/local-navigation.js +1 -1
  252. package/dist/native/helper.exe +0 -0
  253. package/dist/native/helper.json +1 -0
  254. package/package.json +2 -8
  255. package/README.md +0 -95
  256. package/dist/_chunks/chunk-66CUOZVI.js +0 -1
  257. package/dist/_chunks/chunk-6NVIN2NI.js +0 -1
  258. package/dist/_chunks/chunk-7S3DJ2QE.js +0 -1
  259. package/dist/_chunks/chunk-BVSTJQJI.js +0 -1
  260. package/dist/_chunks/chunk-C753RRRA.js +0 -1
  261. package/dist/_chunks/chunk-E57YVMQ4.js +0 -1
  262. package/dist/_chunks/chunk-GJ7BZJLW.js +0 -1
  263. package/dist/_chunks/chunk-HLKERZIE.js +0 -1
  264. package/dist/_chunks/chunk-K6LVS2IN.js +0 -1
  265. package/dist/_chunks/chunk-KHKUJXQX.js +0 -1
  266. package/dist/_chunks/chunk-PUNG4ND7.js +0 -1
  267. package/dist/_chunks/chunk-VC3ODN3M.js +0 -1
  268. package/dist/_chunks/chunk-VPYAXWXY.js +0 -1
  269. package/dist/_chunks/files-FZEK2ZZJ.js +0 -1
  270. package/dist/_chunks/local-main-NLFS74Q4.js +0 -1
  271. package/dist/_chunks/local-mcp-OLHBBVNN.js +0 -1
  272. package/dist/_chunks/main-VRIQTI6R.js +0 -2
  273. package/dist/_chunks/mcp-EIMXNRH3.js +0 -1
  274. package/dist/_chunks/oauth-F7EZGVME.js +0 -1
  275. package/dist/_chunks/project-connect-MXM7IY55.js +0 -1
  276. package/dist/_chunks/src-7F6ZEU3U.js +0 -1
  277. package/dist/_chunks/stdio-main-KOGQ5OWF.js +0 -1
  278. package/dist/native/Bootstrap.ps1 +0 -90
  279. package/dist/native/JobNative.cs +0 -127
  280. package/dist/native/JobRunner.cs +0 -360
  281. package/dist/native/NativeMain.cs +0 -146
  282. package/dist/native/PipeBridge.cs +0 -260
  283. package/dist/native/PrivateAccess.cs +0 -152
package/dist/entry.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- if(process.argv[2]==="local"){if(process.argv[3]==="mcp"){const{runLocalMcp}=await import("./_chunks/local-mcp-OLHBBVNN.js");process.exitCode=await runLocalMcp(process.argv.slice(4))}else{const{runLocalCli}=await import("./_chunks/local-main-NLFS74Q4.js");const result=await runLocalCli(process.argv.slice(3));process.stdout.write(JSON.stringify(result.output)+"\n");process.exitCode=result.exitCode}}else if(process.argv[2]==="mcp"){const{runMcpStdio}=await import("./_chunks/stdio-main-KOGQ5OWF.js");process.exitCode=await runMcpStdio(process.argv.slice(3),process.env)}else{const{runRemoteCli}=await import("./_chunks/main-VRIQTI6R.js");const result=await runRemoteCli(process.argv.slice(2));process.stdout.write(JSON.stringify(result.output)+"\n");process.exitCode=result.exitCode}
2
+ if(process.argv[2]==="observe"){process.exitCode=await(await import("./_chunks/observe-entry-E6DFHIMW.js")).runObservationEntry(process.argv.slice(3))}else if(process.argv[2]==="host"){const{runHostCli}=await import("./_chunks/host-main-JLIBRHC2.js");const result=await runHostCli(process.argv.slice(3));process.stdout.write(JSON.stringify(result.output)+"\n");process.exitCode=result.exitCode}else if(process.argv[2]==="local"){if(process.argv[3]==="mcp"){const{runLocalMcp}=await import("./_chunks/local-mcp-ISMU6ADI.js");process.exitCode=await runLocalMcp(process.argv.slice(4))}else{const{runLocalCli}=await import("./_chunks/local-main-KTYCLHDA.js");const result=await runLocalCli(process.argv.slice(3));process.stdout.write(JSON.stringify(result.output)+"\n");process.exitCode=result.exitCode}}else if(process.argv[2]==="mcp"){const{runMcpStdio}=await import("./_chunks/stdio-main-HNLJCG45.js");process.exitCode=await runMcpStdio(process.argv.slice(3),process.env)}else{const{runRemoteCli}=await import("./_chunks/main-MOZS2EK3.js");const result=await runRemoteCli(process.argv.slice(2));process.stdout.write(JSON.stringify(result.output)+"\n");process.exitCode=result.exitCode}
@@ -1 +1 @@
1
- import{LocalInstallationManager,captureInstalledTools,socketAbsent,toolPreference}from"./_chunks/chunk-K6LVS2IN.js";import{LocalRuntimeDescriptorSchema,canonicalLocalJson,endpoint}from"./_chunks/chunk-KHKUJXQX.js";import"./_chunks/chunk-HLKERZIE.js";import"./_chunks/chunk-VPYAXWXY.js";import{LocalClientError,directory,fail,read,sha256,write}from"./_chunks/chunk-66CUOZVI.js";import"./_chunks/chunk-6NVIN2NI.js";import{z}from"zod";var version=LocalRuntimeDescriptorSchema.shape.version;var fingerprint=z.string().regex(/^[a-f0-9]{64}$/);var DesktopRuntimeChannelSchema=z.strictObject({protocol:z.literal("NVS_DESKTOP_RUNTIME_CHANNEL_V1"),catalogueUrl:z.string().url().max(4096),publicKey:z.string().min(32).max(16384)});var DesktopOwnerRequestSchema=z.discriminatedUnion("operation",[z.strictObject({operation:z.enum(["status","start","stop","check","configuration","recovery"])}),z.strictObject({operation:z.enum(["prepare","reject"]),version}),z.strictObject({operation:z.literal("tools-prepare"),version,choice:z.discriminatedUnion("mode",[z.strictObject({mode:z.literal("MANAGED")}),z.strictObject({mode:z.literal("INSTALLED"),ffmpeg:z.string().min(1).max(4096),ffprobe:z.string().min(1).max(4096)})])}),z.strictObject({operation:z.literal("configure"),channelFingerprint:fingerprint}),z.strictObject({operation:z.enum(["apply","recover"]),planId:z.uuid(),fingerprint})]);var DesktopRuntimeStatusSchema=z.strictObject({protocol:z.literal("NVS_DESKTOP_RUNTIME_STATUS_V1"),state:z.enum(["RUNNING","STOPPED","UNAVAILABLE","INSTALL_REQUIRED"]),activeVersion:version.nullable(),phase:z.string().regex(/^[A-Z_]{1,64}$/),toolMode:z.enum(["MANAGED","INSTALLED"]).nullable().optional()});var DesktopUpdateCheckSchema=z.strictObject({protocol:z.literal("NVS_DESKTOP_RUNTIME_UPDATES_V1"),activeVersion:version.nullable(),versions:z.array(z.strictObject({version,rejected:z.boolean()})).max(128),notifications:z.boolean()});var DesktopOwnerPlanSchema=z.strictObject({protocol:z.literal("NVS_DESKTOP_OWNER_PLAN_V1"),plan:z.strictObject({kind:z.enum(["APPLY","RECOVER"]),toolMode:z.enum(["MANAGED","INSTALLED"]).optional(),planId:z.uuid(),fingerprint,version,previousVersion:version.nullable(),expiresAt:z.iso.datetime(),phase:z.string().regex(/^[A-Z_]{1,64}$/)}).nullable()});var DesktopChannelInfoSchema=z.strictObject({protocol:z.literal("NVS_DESKTOP_CHANNEL_INFO_V1"),configured:z.boolean(),source:z.enum(["EXISTING","BUNDLED","UNAVAILABLE"]),host:z.string().max(512).nullable(),channelFingerprint:fingerprint.nullable()});var desktopOwnerResponses={status:DesktopRuntimeStatusSchema,start:DesktopRuntimeStatusSchema,stop:DesktopRuntimeStatusSchema,configure:DesktopRuntimeStatusSchema,apply:DesktopRuntimeStatusSchema,recover:DesktopRuntimeStatusSchema,reject:DesktopRuntimeStatusSchema,check:DesktopUpdateCheckSchema,configuration:DesktopChannelInfoSchema,prepare:DesktopOwnerPlanSchema,"tools-prepare":DesktopOwnerPlanSchema,recovery:DesktopOwnerPlanSchema};async function desktopRuntimeStatus(manager){const status=await manager.status();const stopped=!status.running&&status.activeVersion?await socketAbsent((await manager.configuration()).stateDirectory):false;const active=(await manager.ledger.current()).value.active;const toolMode=active?.toolsConfigPath?(await toolPreference(active.toolsConfigPath,null)).mode:null;return DesktopRuntimeStatusSchema.parse({protocol:"NVS_DESKTOP_RUNTIME_STATUS_V1",state:status.running?"RUNNING":stopped?"STOPPED":status.activeVersion?"UNAVAILABLE":"INSTALL_REQUIRED",activeVersion:status.activeVersion,phase:status.phase,toolMode})}import{createPublicKey}from"node:crypto";import{join}from"node:path";function desktopRuntimeChannel(raw){const channel=DesktopRuntimeChannelSchema.parse(raw);const url=endpoint(channel.catalogueUrl),key=createPublicKey(channel.publicKey);if(key.asymmetricKeyType!=="ed25519"||channel.publicKey.replace(/\r\n/g,"\n").trim()!==key.export({type:"spki",format:"pem"}).toString().trim())fail("RELEASE_SIGNATURE_INVALID");const value={...channel,catalogueUrl:url.href,publicKey:key.export({type:"spki",format:"pem"}).toString()};return{value,host:url.host,fingerprint:sha256(canonicalLocalJson(value))}}async function desktopChannelInfo(manager,bundled){let channel,configured=false;try{const config=await manager.configuration();channel=desktopRuntimeChannel({protocol:"NVS_DESKTOP_RUNTIME_CHANNEL_V1",catalogueUrl:config.catalogueUrl,publicKey:(await read(config.publicKeyFile,16384)).toString()});configured=true}catch(error){if(!(error instanceof LocalClientError&&error.code==="CONFIGURATION_REQUIRED"))throw error;if(bundled!==void 0)channel=desktopRuntimeChannel(bundled)}return DesktopChannelInfoSchema.parse({protocol:"NVS_DESKTOP_CHANNEL_INFO_V1",configured,source:configured?"EXISTING":channel?"BUNDLED":"UNAVAILABLE",host:channel?.host??null,channelFingerprint:channel?.fingerprint??null})}async function configureDesktopChannel(manager,expectedFingerprint,bundled){const info=await desktopChannelInfo(manager,bundled);if(!info.channelFingerprint)fail("DESKTOP_CHANNEL_REQUIRED");if(info.channelFingerprint!==expectedFingerprint)fail("DESKTOP_CHANNEL_CHANGED");if(info.configured)return;const stateDirectory=join(manager.ledger.root,"runtime-state");if(process.platform!=="win32"&&Buffer.byteLength(join(stateDirectory,"runtime.sock"))>100)fail("SOCKET_PATH_TOO_LONG");const channel=desktopRuntimeChannel(bundled),publicKeyFile=join(manager.ledger.root,"desktop-release-"+channel.fingerprint+".pem");try{await write(publicKeyFile,channel.value.publicKey,true)}catch(error){if(error.code!=="EEXIST")throw error;if((await read(publicKeyFile,16384)).toString()!==channel.value.publicKey)fail("DESKTOP_CHANNEL_CHANGED")}try{await manager.configure({stateDirectory,catalogueUrl:channel.value.catalogueUrl,publicKeyFile,notifications:true},{ifAbsent:true})}catch(error){if(error.code==="EEXIST")fail("DESKTOP_CHANNEL_CHANGED");throw error}}async function runDesktopOwnerRequest(home,raw,bundledChannel){const request=DesktopOwnerRequestSchema.parse(raw),manager=await LocalInstallationManager.open(home);let result;switch(request.operation){case"status":case"start":case"stop":if(request.operation==="start")await manager.start();if(request.operation==="stop")await manager.stop();result=await desktopRuntimeStatus(manager);break;case"configuration":result=await desktopChannelInfo(manager,bundledChannel);break;case"configure":await configureDesktopChannel(manager,request.channelFingerprint,bundledChannel);result=await desktopRuntimeStatus(manager);break;case"check":{const checked=await manager.check();result={protocol:"NVS_DESKTOP_RUNTIME_UPDATES_V1",activeVersion:checked.installation.activeVersion,versions:checked.available.map(v=>({version:v.version,rejected:checked.rejectedVersions.includes(v.version)})),notifications:checked.notifications};break}case"prepare":case"tools-prepare":{const choice=request.operation==="tools-prepare"?request.choice.mode==="MANAGED"?request.choice:await captureInstalledTools(request.choice):void 0;const plan=await manager.prepare(request.version,choice);result={protocol:"NVS_DESKTOP_OWNER_PLAN_V1",plan:{kind:"APPLY",...choice?{toolMode:choice.mode}:{},planId:plan.planId,fingerprint:plan.fingerprint,version:plan.release.descriptor.version,previousVersion:(await manager.status()).activeVersion,expiresAt:plan.expiresAt,phase:"PREPARED"}};break}case"recovery":{const current=(await manager.ledger.current()).value,transition=current.transition;let plan=null;if(transition){const original=await manager.plan(transition.planId);if(original.fingerprint!==transition.fingerprint)fail("PLAN_CHANGED");plan={kind:"RECOVER",planId:original.planId,fingerprint:original.fingerprint,version:original.release.descriptor.version,previousVersion:transition.previous?.descriptor.version??null,expiresAt:original.expiresAt,phase:transition.phase}}result={protocol:"NVS_DESKTOP_OWNER_PLAN_V1",plan};break}case"apply":case"recover":if(request.operation==="apply")await manager.apply(request.planId,request.fingerprint);else await manager.reconcile(request.planId,request.fingerprint);result=await desktopRuntimeStatus(manager);break;case"reject":await manager.reject(request.version);result=await desktopRuntimeStatus(manager);break}return desktopOwnerResponses[request.operation].parse(result)}import{lstat,readFile,chmod}from"node:fs/promises";import{join as join2,isAbsolute,dirname}from"node:path";async function verifiedSource(source,expected,limit){if(!isAbsolute(source)||!/^[a-f0-9]{64}$/.test(expected))fail("DESKTOP_DISTRIBUTION_INVALID");const stat=await lstat(source);if(!stat.isFile()||stat.isSymbolicLink()||stat.size>limit)fail("DESKTOP_DISTRIBUTION_INVALID");const bytes=await readFile(source);if(bytes.length>limit||sha256(bytes)!==expected)fail("DESKTOP_DISTRIBUTION_INVALID");return bytes}async function retain(target,bytes,expected,limit,mode){try{if(sha256(await read(target,limit))!==expected)fail("DESKTOP_DISTRIBUTION_INVALID")}catch(error){if(error.code!=="ENOENT")throw error;try{await write(target,bytes,true)}catch(error2){if(error2.code!=="EEXIST")throw error2}if(sha256(await read(target,limit))!==expected)fail("DESKTOP_DISTRIBUTION_INVALID")}await chmod(target,mode)}async function materializeDesktopNode(home,source,expected,licenseDigest){const bytes=await verifiedSource(source,expected,160*1024*1024);const license=licenseDigest?await verifiedSource(join2(dirname(source),"LICENSE.txt"),licenseDigest,2*1024*1024):null;const base=await directory(join2(await directory(home),"nodes",expected)),target=join2(base,process.platform==="win32"?"node.exe":"node");if(license)await retain(join2(base,"LICENSE.txt"),license,licenseDigest,2*1024*1024,256);await retain(target,bytes,expected,160*1024*1024,320);return target}async function runLocalManagement(home,operation){if(!["status","start","stop"].includes(operation))throw Error("INVALID_INPUT");const manager=await LocalInstallationManager.open(home);if(operation==="start")await manager.start();if(operation==="stop")await manager.stop();return desktopRuntimeStatus(manager)}export{DesktopOwnerRequestSchema,desktopOwnerResponses,desktopRuntimeChannel,materializeDesktopNode,runDesktopOwnerRequest,runLocalManagement};
1
+ import{prepareInstalledCpuSpeech}from"./_chunks/chunk-FVY3PLG7.js";import{configureDesktopChannel,desktopChannelInfo,desktopRuntimeChannel}from"./_chunks/chunk-4PAVWOPA.js";import{DesktopBootstrapReplySchema,DesktopBootstrapRequestSchema,DesktopOwnerRequestSchema,DesktopRuntimeStatusSchema,desktopOwnerResponses,runDesktopAgentRequest,runDesktopOfflineRequest,runDesktopStorageRequest,runDesktopWorkspaceRequest}from"./_chunks/chunk-4M2SOMSN.js";import{DesktopLibraryImportRequestSchema,DesktopLibraryImportSeedSchema,DesktopLibraryMediaRequestSchema,DesktopLibraryPrepareRequestSchema,DesktopLibraryReplySchema,DesktopLibraryRequestSchema,prepareDesktopLibraryImport,runDesktopLibraryImport,runDesktopLibraryMedia,runDesktopLibraryRequest}from"./_chunks/chunk-L3QA7FLZ.js";import{desktopDevicePending,runDesktopDeviceRequest}from"./_chunks/chunk-ROGOASYF.js";import"./_chunks/chunk-HBDPYWMI.js";import{disableDesktopAutomation}from"./_chunks/chunk-MLZ3ZPGU.js";import{LocalInstallationManager,captureInstalledTools,ownerClient,socketAbsent,toolPreference}from"./_chunks/chunk-ELUJ44BO.js";import{desktopDeviceConnector}from"./_chunks/chunk-AFNJRZLJ.js";import{DesktopDeviceReplySchema,DesktopDeviceScopeSchema}from"./_chunks/chunk-IYDHDLTR.js";import{LocalReleaseSchema,catalogue,newerVersion}from"./_chunks/chunk-6EZX2TRX.js";import{canonicalLocalJson}from"./_chunks/chunk-APNZQZFB.js";import{directory,fail,optional,read,sha256,write}from"./_chunks/chunk-DLW42PJ6.js";import"./_chunks/chunk-WTJVS2VS.js";import"./_chunks/chunk-TT7IA5HB.js";async function desktopRuntimeStatus(manager){const status=await manager.status();const stopped=!status.running&&status.activeVersion?await socketAbsent((await manager.configuration()).stateDirectory):false;const active=(await manager.ledger.current()).value.active;const tools=active?.toolsConfigPath?await toolPreference(active.toolsConfigPath,null):null;return DesktopRuntimeStatusSchema.parse({protocol:"NVS_DESKTOP_RUNTIME_STATUS_V1",state:status.running?"RUNNING":stopped?"STOPPED":status.activeVersion?"UNAVAILABLE":"INSTALL_REQUIRED",activeVersion:status.activeVersion,phase:status.phase,toolMode:tools?.mode??null,...tools?.cpuSpeech?{speech:{voiceIds:tools.cpuSpeech.voiceIds}}:{}})}import{z}from"zod";import{join}from"node:path";import{randomUUID}from"node:crypto";var digest=z.string().regex(/^[a-f0-9]{64}$/);var intentSchema=z.strictObject({id:z.uuid(),channel:z.strictObject({protocol:z.literal("NVS_DESKTOP_RUNTIME_CHANNEL_V1"),catalogueUrl:z.string().url(),publicKey:z.string()}),release:LocalReleaseSchema,installationRevision:z.int().nonnegative(),expiresAt:z.iso.datetime()});async function runDesktopBootstrap(home,raw,bundled){const{call}=DesktopBootstrapRequestSchema.parse(raw),manager=await LocalInstallationManager.open(home),root=await directory(join(home,"bootstrap-plans"));let intent,fingerprint;if(call.action==="prepare"){const info=await desktopChannelInfo(manager,bundled);if(!info.channelFingerprint)fail("DESKTOP_CHANNEL_REQUIRED");const configuration=info.configured?await manager.configuration():null;if(configuration&&!configuration.publicKeyFile)fail("DESKTOP_CHANNEL_CHANGED");const channel=desktopRuntimeChannel(configuration?{protocol:"NVS_DESKTOP_RUNTIME_CHANNEL_V1",catalogueUrl:configuration.catalogueUrl,publicKey:(await read(configuration.publicKeyFile,16384)).toString()}:bundled);const publicKeyFile=join(root,channel.fingerprint+".pem");try{await write(publicKeyFile,channel.value.publicKey,true)}catch(e){if(e.code!=="EEXIST"||(await read(publicKeyFile,16384)).toString()!==channel.value.publicKey)throw e}const trusted=await catalogue({catalogueUrl:channel.value.catalogueUrl,publicKeyFile});const candidates=trusted.signed.catalogue.releases.filter(r=>r.descriptor.workProtocol==="NVS_LOCAL_WORK_V2"&&r.descriptor.platform.os===process.platform&&r.descriptor.platform.architecture===process.arch&&!!r.tools);const release=candidates.reduce((a,b)=>!a||newerVersion(b.descriptor.version,a.descriptor.version)?b:a,null);if(!release)fail("LOCAL_PROFILE_UNAVAILABLE");intent=intentSchema.parse({id:randomUUID(),channel:channel.value,release,installationRevision:(await manager.ledger.current()).value.revision,expiresAt:new Date(Math.min(Date.now()+18e5,Date.parse(trusted.signed.catalogue.expiresAt))).toISOString()});fingerprint=sha256(canonicalLocalJson(intent));await write(join(root,intent.id+".json"),canonicalLocalJson({intent,fingerprint}),true)}else{const saved=z.strictObject({intent:intentSchema,fingerprint:digest}).parse(JSON.parse((await read(join(root,call.id+".json"),131072)).toString()));intent=saved.intent;fingerprint=saved.fingerprint;if(fingerprint!==call.fingerprint||fingerprint!==sha256(canonicalLocalJson(intent))||intent.id!==call.id)fail("PLAN_CHANGED");const receiptFile=join(root,intent.id+".installation.json");const receipt=z.strictObject({id:z.uuid(),fingerprint:digest}).nullable().parse(await optional(receiptFile));if(receipt){const state=(await manager.ledger.current()).value;if(state.transition){if(state.transition.planId!==receipt.id)fail("RECOVERY_REQUIRED");await manager.reconcile(receipt.id,receipt.fingerprint)}}else{if(Date.parse(intent.expiresAt)<=Date.now()||(await manager.ledger.current()).value.revision!==intent.installationRevision)fail("PLAN_CHANGED");const trust=desktopRuntimeChannel(intent.channel);await configureDesktopChannel(manager,trust.fingerprint,intent.channel);const plan=await manager.prepare(intent.release.descriptor.version,{mode:"MANAGED"});if(canonicalLocalJson(plan.release)!==canonicalLocalJson(intent.release))fail("PLAN_CHANGED");await write(receiptFile,canonicalLocalJson({id:plan.planId,fingerprint:plan.fingerprint}),true);await manager.apply(plan.planId,plan.fingerprint)}const installed=(await manager.ledger.current()).value;if(installed.transition||canonicalLocalJson(installed.active?.descriptor)!==canonicalLocalJson(intent.release.descriptor))fail("RECOVERY_REQUIRED");const configuration=await manager.configuration(),report=await(await ownerClient(configuration.stateDirectory)).doctor();if(!report.executionProfiles?.includes("STUDIO_MEDIA_V2"))fail("LOCAL_PROFILE_UNAVAILABLE");if((await desktopRuntimeStatus(manager)).state!=="RUNNING")fail("RECOVERY_REQUIRED")}return DesktopBootstrapReplySchema.parse({id:intent.id,fingerprint,version:intent.release.descriptor.version,host:new URL(intent.channel.catalogueUrl).host,bytes:intent.release.package.byteSize+Object.values(intent.release.tools??{}).reduce((sum,a)=>sum+a.byteSize,0),expiresAt:intent.expiresAt,installed:call.action==="apply"})}async function runDesktopOwnerRequest(home,raw,bundledChannel){const request=DesktopOwnerRequestSchema.parse(raw),manager=await LocalInstallationManager.open(home);let result;switch(request.operation){case"library":result=await runDesktopLibraryRequest(home,request);break;case"library-import":result=await runDesktopLibraryImport(home,request);break;case"library-import-prepare":result=await prepareDesktopLibraryImport(request);break;case"bootstrap":result=await runDesktopBootstrap(home,request,bundledChannel);break;case"agent":result=await runDesktopAgentRequest(home,request);break;case"offline":result=await runDesktopOfflineRequest(home,request);break;case"storage":result=await runDesktopStorageRequest(home,request);break;case"workspace":result=await runDesktopWorkspaceRequest(home,request);break;case"device":result=await runDesktopDeviceRequest(home,request);break;case"status":case"start":case"stop":if(request.operation==="start")await manager.start();if(request.operation==="stop"){await disableDesktopAutomation(home);await manager.stop()}result=await desktopRuntimeStatus(manager);break;case"configuration":result=await desktopChannelInfo(manager,bundledChannel);break;case"configure":await configureDesktopChannel(manager,request.channelFingerprint,bundledChannel);result=await desktopRuntimeStatus(manager);break;case"check":{const checked=await manager.check();result={protocol:"NVS_DESKTOP_RUNTIME_UPDATES_V1",activeVersion:checked.installation.activeVersion,versions:checked.available.map(v=>({version:v.version,rejected:checked.rejectedVersions.includes(v.version)})),notifications:checked.notifications};break}case"speech-prepare":{const prepared=await prepareInstalledCpuSpeech(manager,request.input),plan=prepared.plan;result={protocol:"NVS_DESKTOP_OWNER_PLAN_V1",plan:{kind:"APPLY",toolMode:plan.toolSelection?.mode,planId:plan.planId,fingerprint:plan.fingerprint,version:plan.release.descriptor.version,previousVersion:(await manager.status()).activeVersion,expiresAt:plan.expiresAt,phase:"PREPARED"}};break}case"prepare":case"tools-prepare":{const choice=request.operation==="tools-prepare"?request.choice.mode==="MANAGED"?request.choice:await captureInstalledTools(request.choice):void 0;const plan=await manager.prepare(request.version,choice);result={protocol:"NVS_DESKTOP_OWNER_PLAN_V1",plan:{kind:"APPLY",...choice?{toolMode:choice.mode}:{},planId:plan.planId,fingerprint:plan.fingerprint,version:plan.release.descriptor.version,previousVersion:(await manager.status()).activeVersion,expiresAt:plan.expiresAt,phase:"PREPARED"}};break}case"recovery":{const current=(await manager.ledger.current()).value,transition=current.transition;let plan=null;if(transition){const original=await manager.plan(transition.planId);if(original.fingerprint!==transition.fingerprint)fail("PLAN_CHANGED");plan={kind:"RECOVER",planId:original.planId,fingerprint:original.fingerprint,version:original.release.descriptor.version,previousVersion:transition.previous?.descriptor.version??null,expiresAt:original.expiresAt,phase:transition.phase}}result={protocol:"NVS_DESKTOP_OWNER_PLAN_V1",plan};break}case"apply":case"recover":if(request.operation==="apply")await manager.apply(request.planId,request.fingerprint);else await manager.reconcile(request.planId,request.fingerprint);result=await desktopRuntimeStatus(manager);break;case"reject":await manager.reject(request.version);result=await desktopRuntimeStatus(manager);break}return desktopOwnerResponses[request.operation].parse(result)}import{lstat,readFile,chmod}from"node:fs/promises";import{join as join2,isAbsolute,dirname}from"node:path";async function verifiedSource(source,expected,limit){if(!isAbsolute(source)||!/^[a-f0-9]{64}$/.test(expected))fail("DESKTOP_DISTRIBUTION_INVALID");const stat=await lstat(source);if(!stat.isFile()||stat.isSymbolicLink()||stat.size>limit)fail("DESKTOP_DISTRIBUTION_INVALID");const bytes=await readFile(source);if(bytes.length>limit||sha256(bytes)!==expected)fail("DESKTOP_DISTRIBUTION_INVALID");return bytes}async function retain(target,bytes,expected,limit,mode){try{if(sha256(await read(target,limit))!==expected)fail("DESKTOP_DISTRIBUTION_INVALID")}catch(error){if(error.code!=="ENOENT")throw error;try{await write(target,bytes,true)}catch(error2){if(error2.code!=="EEXIST")throw error2}if(sha256(await read(target,limit))!==expected)fail("DESKTOP_DISTRIBUTION_INVALID")}await chmod(target,mode)}async function materializeDesktopNode(home,source,expected,licenseDigest){const bytes=await verifiedSource(source,expected,160*1024*1024);const license=licenseDigest?await verifiedSource(join2(dirname(source),"LICENSE.txt"),licenseDigest,2*1024*1024):null;const base=await directory(join2(await directory(home),"nodes",expected)),target=join2(base,process.platform==="win32"?"node.exe":"node");if(license)await retain(join2(base,"LICENSE.txt"),license,licenseDigest,2*1024*1024,256);await retain(target,bytes,expected,160*1024*1024,320);return target}async function runLocalManagement(home,operation){if(!["status","start","stop"].includes(operation))throw Error("INVALID_INPUT");const manager=await LocalInstallationManager.open(home);if(operation==="start")await manager.start();if(operation==="stop")await manager.stop();return desktopRuntimeStatus(manager)}export{DesktopDeviceReplySchema,DesktopDeviceScopeSchema,DesktopLibraryImportRequestSchema,DesktopLibraryImportSeedSchema,DesktopLibraryMediaRequestSchema,DesktopLibraryPrepareRequestSchema,DesktopLibraryReplySchema,DesktopLibraryRequestSchema,DesktopOwnerRequestSchema,desktopDeviceConnector,desktopDevicePending,desktopOwnerResponses,desktopRuntimeChannel,materializeDesktopNode,prepareDesktopLibraryImport,runDesktopLibraryMedia,runDesktopOwnerRequest,runLocalManagement};
@@ -1 +1 @@
1
- import{LocalMcpTools}from"./_chunks/chunk-VC3ODN3M.js";import"./_chunks/chunk-KHKUJXQX.js";import"./_chunks/chunk-HLKERZIE.js";import"./_chunks/chunk-VPYAXWXY.js";import"./_chunks/chunk-66CUOZVI.js";import"./_chunks/chunk-6NVIN2NI.js";export{LocalMcpTools};
1
+ import{LocalMcpTools}from"./_chunks/chunk-QK4XPVKT.js";import{desktopDeviceConnector}from"./_chunks/chunk-AFNJRZLJ.js";import{DesktopDeviceScopeSchema}from"./_chunks/chunk-IYDHDLTR.js";import"./_chunks/chunk-6EZX2TRX.js";import"./_chunks/chunk-APNZQZFB.js";import"./_chunks/chunk-DLW42PJ6.js";import"./_chunks/chunk-WTJVS2VS.js";import"./_chunks/chunk-TT7IA5HB.js";async function openDesktopDeviceTools(raw,home){const scope=DesktopDeviceScopeSchema.parse(raw);return LocalMcpTools.open(await desktopDeviceConnector(home,scope),home)}export{LocalMcpTools,openDesktopDeviceTools};
Binary file
@@ -0,0 +1 @@
1
+ {"protocol":"NVS_WINDOWS_HELPER_V1","format":"PE_AMD64_NETFRAMEWORK48","sourceDigest":"7c72ed925f68ed26348e8eedf9ac194133475402368a780477221d13efbe0b29","sha256":"5865bcc8a60cb05053e62b1b244852127d96a732802338e572bc48ade2ad969e","byteSize":33280,"sdkVersion":"10.0.404","sdkSha512":"88ca5dac50562b619f852b1b9845f85243f00434be52d2149db18ab4dc05f527f3fca8e1dac82e87b9eeb46a98de1ba4a6d612714caf2222f37b95aeebb611b6","referenceVersion":"1.0.3","referenceSha512":"5d62a0c9e35a74d71341a215bd007c06b74236b11aafa7e8fdd7b539d41167d1c5cb48dc05268cf08579abae196a6a6c4a70bc0254ec002686654ba8170e3544"}
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@nativestudio/cli",
3
- "version": "0.3.0-rc.2",
3
+ "version": "0.3.0-rc.20",
4
4
  "type": "module",
5
- "license": "MIT",
6
- "description": "NativeStudio account-first Agent CLI, MCP relay and local execution manager",
5
+ "license": "Apache-2.0",
7
6
  "engines": {
8
7
  "node": ">=24.12 <25"
9
8
  },
@@ -27,10 +26,5 @@
27
26
  },
28
27
  "publishConfig": {
29
28
  "access": "public"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/SENLIN746/native-video-studio.git",
34
- "directory": "apps/remote-cli"
35
29
  }
36
30
  }
package/README.md DELETED
@@ -1,95 +0,0 @@
1
- # NativeStudio CLI
2
-
3
- One Agent/terminal entry for account login, project navigation, remote stdio MCP
4
- and explicitly authorized local execution. Node.js 24.12 or later in major24 is
5
- required. Preview releases use the `next` channel; pin the exact verified version
6
- shown on the NativeStudio download page. Install `@nativestudio/cli` or run that exact
7
- version through npx. Local qualification uses the inspected tarball. No separate contracts, SDK or Runtime package is required.
8
- Cloud Agents supporting remote HTTP MCP can connect without installing npm packages.
9
-
10
- Use a currently patched Node24 release. The engine floor is API compatibility,
11
- not a recommendation to run an old security patch.
12
-
13
- ## Sign in, choose scope, connect
14
-
15
- ```sh
16
- nvs login --server https://studio.example.com
17
- nvs whoami
18
- nvs workspaces
19
- nvs workspace --id WORKSPACE_ID_FROM_RESPONSE
20
- nvs projects
21
- nvs project --id PROJECT_ID_FROM_RESPONSE
22
- ```
23
-
24
- Login opens the browser; the terminal never asks for your password. The server must
25
- support NativeStudio account handoff. Registration/reset additionally requires its
26
- configured email service. Account sessions expire; an unavailable server capability
27
- is not bypassed by this package. Account login is separate from Project Agent consent.
28
-
29
- Open the returned `connectionPage` and copy its verified MCP connection URL:
30
-
31
- ```sh
32
- nvs connect --mcp-url PROJECT_CONNECTION_URL_FROM_SETTINGS
33
- nvs status
34
- nvs find --query "查找我的制作"
35
- nvs capabilities search --query "找参考素材" --group materials
36
- ```
37
-
38
- Project access is read-only by default. Request `--scope 'nvs:read nvs:write'` only
39
- when needed and explicitly approve the browser consent. Follow native nextActions;
40
- a recommendation is not execution or acceptance. Existing expert `operations` and
41
- `call` commands remain available; authorization, revisions and idempotency still apply.
42
-
43
- Configure the Agent executable as `nvs`, arguments `["mcp"]`. Use the same OS user
44
- and private client home. Restart its MCP process after updating CLI or selecting a
45
- new connection. Tokens, passwords, database settings and Provider keys do not belong
46
- in Agent launch arguments/configuration. `nvs logout` revokes the CLI account session,
47
- not independent Agent grants or native Jobs. Revoke Project grants in Web Settings.
48
-
49
- ## Local execution and updates
50
-
51
- `nvs local` provides installation status, explicit configuration, checks, planning,
52
- apply and recovery. The embedded Runtime is only a code asset cache: its exact bytes
53
- must match a current catalogue signed by the configured trusted key before use.
54
- Missing production channel/tool metadata remains unavailable. There is no self-signed
55
- bootstrap, implicit PATH discovery or activation merely because npm installed code.
56
-
57
- Check first, inspect the exact plan, then approve that plan's fingerprint. Existing
58
- Runtime state, SQLite recovery data, pending results and previous working slots stay
59
- outside npm/npx directories. Updating CLI does not automatically upgrade the daemon.
60
- Qualified FFmpeg/ffprobe are provided by default through the signed Runtime catalogue.
61
- To switch deliberately, prepare a tools plan for the exact installed Runtime version:
62
-
63
- ```sh
64
- nvs local tools-prepare --version VERSION_FROM_CHECK --input /absolute/private/tools.json
65
- nvs local update-apply --plan PLAN_UUID --approve PLAN_FINGERPRINT
66
- ```
67
-
68
- The private JSON is `{ "mode": "MANAGED" }` or
69
- `{ "mode": "INSTALLED", "ffmpeg": "/absolute/ffmpeg", "ffprobe": "/absolute/ffprobe" }`.
70
- The CLI captures exact hashes and qualifies the programs before activation; it does not
71
- search PATH. Installed choices survive later updates. In Desktop, use Local Runtime's
72
- tool choices and the native file pickers. Existing stopped journals need an explicitly
73
- started Runtime for pending-work inspection before a switch; incompatible pending work
74
- blocks it. Timestamp renewal preserves a fresh trust-bound approval, while a changed
75
- key/source/release or expired plan requires a new selection.
76
-
77
- Media executables have their own GPL notices and corresponding source archive; see the
78
- Runtime notices and the download site's media inventory. Platform support depends on the signed catalogue and
79
- qualification evidence; packaging alone does not certify Windows/Apple Silicon QA.
80
-
81
- ## Recovery and private state
82
-
83
- Private credentials, connection epochs and receipts live outside the package under
84
- `~/.nativestudio/client` (or an explicit private `NATIVESTUDIO_CLIENT_HOME`). Failed
85
- login preserves the prior account/connection. An unresolved token exchange is fenced;
86
- start a fresh login/connection rather than replay the exchange. UNKNOWN business writes
87
- must be reconciled through their native Operation or supported explicit idempotency.
88
- Neither a process timeout nor MCP cancellation cancels an admitted Job automatically.
89
-
90
- The implementation remains readable under MIT. Packages exclude source maps,
91
- build-machine paths, raw TypeScript, private credentials and local state. Fixed
92
- Windows C#/PowerShell helper resources are intentional scoped execution assets.
93
- `COMPATIBILITY.json` records protocol and component identities. The local navigation
94
- and management export subpaths are experimental host integrations, not general Agent
95
- permission to control installation or execute shell commands.
@@ -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(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(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,assertExecutable,sha256,sha512,LocalClientError,fail,directory,read,write,entries,optional,verifyBackup};
@@ -1 +0,0 @@
1
- var NativeStudioSdkError=class extends Error{constructor(code,semanticStatus,outcome,status=null){super(`NativeStudio ${code}`);this.code=code;this.semanticStatus=semanticStatus;this.outcome=outcome;this.status=status;this.name="NativeStudioSdkError"}code;semanticStatus;outcome;status};function sdkInputError(){throw new NativeStudioSdkError("INVALID_INPUT","INVALID_INPUT","NO_WRITE")}export{NativeStudioSdkError,sdkInputError};
@@ -1 +0,0 @@
1
- import{secureEndpoint}from"./chunk-PUNG4ND7.js";import{privateAccess,privateDirectory,write}from"./chunk-66CUOZVI.js";import{randomBytes}from"node:crypto";import{open,unlink,constants}from"node:fs/promises";import{dirname,resolve}from"node:path";var FileOAuthProvider=class _FileOAuthProvider{constructor(path,data){this.path=path;this.data=data}path;data;static async create(path,resource,redirect,scope){secureEndpoint(resource);secureEndpoint(redirect);if(!["nvs:read","nvs:read nvs:write"].includes(scope))throw Error();if(process.platform==="win32")await privateDirectory(dirname(resolve(path)));const data={version:1,resource,redirect,scope,state:randomBytes(24).toString("base64url")};await write(resolve(path),JSON.stringify(data),true);return new _FileOAuthProvider(path,data)}static async load(path){if(process.platform==="win32")await privateAccess(resolve(path),"file");const file=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW);let data;try{const stat=await file.stat();if(!stat.isFile()||stat.nlink!==1||process.platform!=="win32"&&(stat.uid!==process.getuid?.()||(stat.mode&63)!==0)||stat.size>65536)throw Error();const bytes=Buffer.alloc(65537);const{bytesRead}=await file.read(bytes,0,bytes.length,0);if(bytesRead>65536)throw Error();data=JSON.parse(bytes.subarray(0,bytesRead).toString("utf8"))}finally{await file.close()}if(![1,2].includes(data.version)||typeof data.state!=="string"||data.state.length<16)throw Error();if(data.pendingExchange!==void 0&&!["CODE","REFRESH"].includes(data.pendingExchange))throw Error();if(data.version===2!==(data.pendingExchange!==void 0))throw Error();secureEndpoint(data.resource);secureEndpoint(data.redirect);if(!["nvs:read","nvs:read nvs:write"].includes(data.scope))throw Error();return new _FileOAuthProvider(path,data)}async save(){if(process.platform==="win32")await privateDirectory(dirname(resolve(this.path)));await write(resolve(this.path),JSON.stringify(this.data))}get redirectUrl(){return this.data.redirect}get clientMetadata(){return{client_name:"NativeStudio CLI",redirect_uris:[this.data.redirect],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],scope:this.data.scope,application_type:"native"}}state(){return this.data.state}clientInformation(){return this.data.client}async saveClientInformation(value){this.data.client=value;await this.save()}tokens(){return this.data.token}async saveTokens(value){this.data.token=value;this.data.expiresAt=Date.now()+(value.expires_in??600)*1e3;this.data.version=1;delete this.data.pendingExchange;await this.save()}async redirectToAuthorization(url){this.data.authorizationUrl=url.href;await this.save()}async saveCodeVerifier(value){this.data.verifier=value;await this.save()}codeVerifier(){if(!this.data.verifier)throw Error();return this.data.verifier}async saveDiscoveryState(value){this.data.discovery=value;await this.save()}discoveryState(){return this.data.discovery}};async function withProfileLock(path,action){if(process.platform==="win32")await privateDirectory(dirname(resolve(path)));const file=await open(path+".lock","wx",384);try{return await action()}finally{await file.close();await unlink(path+".lock")}}export{FileOAuthProvider,withProfileLock};
@@ -1 +0,0 @@
1
- import{privateAccess}from"./chunk-66CUOZVI.js";import{open,constants}from"node:fs/promises";import{resolve}from"node:path";var limit=18*1024*1024;async function readInput(path,stdin){let bytes;if(path==="-"){const chunks=[];let size=0;for await(const chunk of stdin){size+=chunk.byteLength;if(size>limit)throw Error();chunks.push(Buffer.from(chunk))}bytes=Buffer.concat(chunks)}else{const handle=await open(path,constants.O_RDONLY|constants.O_NOFOLLOW);try{const stat=await handle.stat();if(!stat.isFile()||stat.size>limit)throw Error();bytes=Buffer.alloc(limit+1);let used=0;while(used<bytes.byteLength){const read=await handle.read(bytes,used,bytes.byteLength-used,null);if(!read.bytesRead)break;used+=read.bytesRead}if(used>limit)throw Error();bytes=bytes.subarray(0,used)}finally{await handle.close()}}const value=JSON.parse(new TextDecoder("utf-8",{fatal:true}).decode(bytes));if(!value||typeof value!=="object"||Array.isArray(value))throw Error();return value}async function readCredential(options,environment){if(options.has("--token-file")===options.has("--token-env"))throw Error();let token;const key=options.get("--token-env");if(key){if(!/^[A-Z][A-Z0-9_]{0,127}$/.test(key))throw Error();token=environment[key]??""}else{if(process.platform==="win32")await privateAccess(resolve(options.get("--token-file")),"file");const handle=await open(options.get("--token-file"),constants.O_RDONLY|constants.O_NOFOLLOW);try{const stat=await handle.stat();if(!stat.isFile()||process.platform!=="win32"&&(stat.mode&63)!==0||stat.size>8192)throw Error();const bytes=Buffer.alloc(8193);const{bytesRead}=await handle.read(bytes,0,bytes.length,0);if(bytesRead>8192)throw Error();token=bytes.subarray(0,bytesRead).toString("utf8").trim()}finally{await handle.close()}}if(!/^[A-Za-z0-9._~-]{1,8192}$/.test(token))throw Error();return"Bearer "+token}export{readInput,readCredential};
@@ -1 +0,0 @@
1
- import{CliAccountExchangeSchema,CliAccountIdentitySchema,CliAccountSessionSchema,CliAccountStartSchema,CliAccountStartedSchema,ProjectLibraryPageSchema,ProjectWorkspaceSchema}from"./chunk-GJ7BZJLW.js";import{FileOAuthProvider,withProfileLock}from"./chunk-7S3DJ2QE.js";import{secureEndpoint}from"./chunk-PUNG4ND7.js";import{directory,optional,privateDirectory,write}from"./chunk-66CUOZVI.js";import{NativeStudioSdkError}from"./chunk-6NVIN2NI.js";import{homedir}from"node:os";import{isAbsolute,join}from"node:path";import{realpath}from"node:fs/promises";function connectionError(code){throw new NativeStudioSdkError(code,"INVALID_INPUT","NO_WRITE")}async function clientHome(environment,create=false){const path=environment.NATIVESTUDIO_CLIENT_HOME??join(homedir(),".nativestudio","client");if(!isAbsolute(path))connectionError("CLIENT_HOME_ABSOLUTE_REQUIRED");if(create)return directory(path);await privateDirectory(path);const root=await realpath(path);if(/(?:^|[\\/])(?:node_modules|_npx)(?:[\\/]|$)/.test(root))connectionError("CLIENT_HOME_PRIVATE_REQUIRED");return root}import{join as join2}from"node:path";import{z as z2}from"zod";import{z}from"zod";function accountServerOrigin(value){const url=new URL(value);if(url.pathname!=="/"||url.search||url.hash||url.username||url.password||!(url.protocol==="https:"||url.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(url.hostname)))throw new NativeStudioSdkError("ACCOUNT_SERVER_ORIGIN_REQUIRED","INVALID_INPUT","NO_WRITE");return url.origin}var NativeStudioAccountClient=class{constructor(options){this.options=options;this.serverOrigin=accountServerOrigin(options.serverOrigin);if(options.accessToken&&!/^nvsh_[A-Za-z0-9_-]{43}$/.test(options.accessToken))throw new NativeStudioSdkError("INVALID_ACCOUNT_CREDENTIAL","INVALID_INPUT","NO_WRITE")}options;serverOrigin;async request(action,schema,options={}){if(options.credential&&!this.options.accessToken)throw new NativeStudioSdkError("ACCOUNT_LOGIN_REQUIRED","INVALID_INPUT","NO_WRITE");const write2=options.body!==void 0;let response;try{response=await(this.options.fetch??fetch)(`${this.serverOrigin}/api/cli-account/${action}${options.query?"?"+options.query:""}`,{method:write2?"POST":"GET",cache:"no-store",redirect:"error",credentials:"omit",signal:AbortSignal.any([AbortSignal.timeout(15e3),...options.signal?[options.signal]:[]]),headers:{...write2?{"content-type":"application/json"}:{},...options.credential?{authorization:"Bearer "+this.options.accessToken}:{}},...write2?{body:JSON.stringify(options.body)}:{}})}catch{throw new NativeStudioSdkError("ACCOUNT_TRANSPORT_FAILED","BLOCKED",write2?"UNKNOWN":"NO_WRITE")}if(!response.ok){await response.body?.cancel();throw new NativeStudioSdkError(response.status===401?"ACCOUNT_SESSION_EXPIRED_OR_REVOKED":"ACCOUNT_REQUEST_REJECTED","BLOCKED",write2&&response.status>=500?"UNKNOWN":"REJECTED",response.status)}try{if(!(response.headers.get("content-type")??"").startsWith("application/json"))throw Error();const reader=response.body?.getReader();if(!reader)throw Error();const chunks=[];let size=0;try{while(true){const part=await reader.read();if(part.done)break;size+=part.value.byteLength;if(size>1024*1024){await reader.cancel();throw Error()}chunks.push(part.value)}}finally{reader.releaseLock()}const bytes=new Uint8Array(size);let offset=0;for(const part of chunks){bytes.set(part,offset);offset+=part.length}return schema.parse(JSON.parse(new TextDecoder().decode(bytes)))}catch{throw new NativeStudioSdkError("ACCOUNT_RESPONSE_INVALID","BLOCKED",write2?"UNKNOWN":"NO_WRITE")}}async metadata(signal){return this.request("metadata",z.strictObject({protocol:z.literal("NVS_CLI_ACCOUNT_V1"),serverOrigin:z.literal(this.serverOrigin)}),{signal})}start(input,signal){return this.request("start",CliAccountStartedSchema,{body:CliAccountStartSchema.parse(input),signal})}exchange(input,signal){return this.request("exchange",CliAccountSessionSchema,{body:CliAccountExchangeSchema.parse(input),signal})}me(signal){return this.request("me",CliAccountIdentitySchema,{credential:true,signal})}logout(signal){return this.request("logout",z.strictObject({changed:z.literal(true)}),{credential:true,body:{},signal})}async projects(input,signal){const value=z.strictObject({tenantId:z.uuid(),limit:z.number().int().min(1).max(100).optional(),next:z.string().min(1).max(8192).optional()}).parse(input);const result=await this.request("projects",ProjectLibraryPageSchema,{credential:true,signal,query:new URLSearchParams({tenantId:value.tenantId,...value.limit?{limit:String(value.limit)}:{},...value.next?{next:value.next}:{}})});if(result.items.some(p=>p.tenantId!==value.tenantId))throw new NativeStudioSdkError("ACCOUNT_RESPONSE_SCOPE_MISMATCH","BLOCKED","NO_WRITE");return result}async project(input,signal){const value=z.strictObject({tenantId:z.uuid(),projectId:z.uuid()}).parse(input);const result=await this.request("project",ProjectWorkspaceSchema,{credential:true,signal,query:new URLSearchParams(value)});if(result.project.id!==value.projectId||result.project.tenantId!==value.tenantId)throw new NativeStudioSdkError("ACCOUNT_RESPONSE_SCOPE_MISMATCH","BLOCKED","NO_WRITE");return result}};var AccountStateSchema=z2.strictObject({version:z2.literal(1),epoch:z2.uuid(),serverOrigin:z2.string().refine(v=>{try{return accountServerOrigin(v)===v}catch{return false}}),principalId:z2.uuid(),expiresAt:z2.iso.datetime(),workspaceId:z2.uuid().nullable(),projectId:z2.uuid().nullable(),state:z2.enum(["ACTIVE","REVOKE_PENDING","SIGNED_OUT"]),accessToken:z2.string().regex(/^nvsh_[A-Za-z0-9_-]{43}$/).nullable()}).refine(v=>v.state==="SIGNED_OUT"===(v.accessToken===null)&&(!v.projectId||Boolean(v.workspaceId)));function accountError(code,outcome="NO_WRITE"){throw new NativeStudioSdkError(code,outcome==="UNKNOWN"?"INTERNAL_OPERATIONAL_FAILURE":["ACCOUNT_LOGIN_INPUT_INVALID","ACCOUNT_COMMAND_INPUT_INVALID"].includes(code)?"INVALID_INPUT":"BLOCKED",outcome)}async function readAccount(root){const value=await optional(join2(root,"account.json"));if(value===null)return null;const parsed=AccountStateSchema.safeParse(value);if(!parsed.success)accountError("ACCOUNT_STATE_INVALID");return parsed.data}async function saveAccount(root,value){const account=AccountStateSchema.parse(value);const pointer=z2.object({version:z2.literal(1)}).passthrough().safeParse(await optional(join2(root,"connection.json")));if(pointer.success)await write(join2(root,"connection.json"),JSON.stringify({...pointer.data,version:2,accountEpoch:account.epoch}));await write(join2(root,"account.json"),JSON.stringify(account))}async function withAccountLock(root,action){try{return await withProfileLock(join2(root,"account.json"),action)}catch(error){if(error.code==="EEXIST")accountError("ACCOUNT_COMMAND_BUSY");throw error}}function requireAccount(value){if(!value)accountError("ACCOUNT_LOGIN_REQUIRED");if(value.state==="REVOKE_PENDING")accountError("ACCOUNT_LOGOUT_OUTCOME_UNKNOWN","UNKNOWN");if(value.state!=="ACTIVE"||Date.parse(value.expiresAt)<=Date.now())accountError("ACCOUNT_LOGIN_REQUIRED");return value}import{join as join3}from"node:path";var uuid="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";var projectPath=new RegExp(`^/mcp/external/v1/tenants/(${uuid})/projects/(${uuid})$`,"i");function projectConnection(resource){const url=secureEndpoint(resource),match=projectPath.exec(url.pathname);if(!match)connectionError("PROJECT_MCP_URL_REQUIRED");return{resource:url.href,tenantId:match[1],projectId:match[2]}}async function saveConnection(root,profile,expectedEpoch){return withAccountLock(root,()=>saveConnectionLocked(root,profile,expectedEpoch))}async function saveConnectionLocked(root,profile,expectedEpoch){if(!/^profile-[0-9a-f-]{36}\.json$/.test(profile))throw Error();const provider=await FileOAuthProvider.load(join3(root,profile));const scope=projectConnection(provider.data.resource);if(!provider.data.token?.access_token||provider.data.pendingExchange)throw Error();const account=await readAccount(root);if(account?.epoch!==expectedEpoch)connectionError("ACCOUNT_CHANGED_DURING_CONNECTION");if(account&&(account.state!=="ACTIVE"||Date.parse(account.expiresAt)<=Date.now()||account.workspaceId!==scope.tenantId||account.projectId!==scope.projectId))connectionError("ACCOUNT_PROJECT_SELECTION_REQUIRED");await write(join3(root,"connection.json"),JSON.stringify({version:account?2:1,profile,...scope,...account?{accountEpoch:account.epoch}:{}}));return{scope:provider.data.token.scope??provider.data.scope,expiresAt:provider.data.expiresAt}}async function loadConnection(environment,verifyAccount=false){let root;try{root=await clientHome(environment)}catch(e){if(e.code==="ENOENT")return null;throw e}const value=await optional(join3(root,"connection.json"));if(value===null)return null;if(value.version!==1&&value.version!==2||typeof value.profile!=="string"||!/^profile-[0-9a-f-]{36}\.json$/.test(value.profile)||typeof value.resource!=="string")connectionError("CONNECTION_INVALID");const scope=projectConnection(value.resource);if(scope.tenantId!==value.tenantId||scope.projectId!==value.projectId)connectionError("CONNECTION_SCOPE_MISMATCH");const account=await readAccount(root);if(value.version===2&&(!account||typeof value.accountEpoch!=="string"))connectionError("PROJECT_CONNECTION_ACCOUNT_MISMATCH");if(account&&(value.version!==2||account.state!=="ACTIVE"||Date.parse(account.expiresAt)<=Date.now()||value.accountEpoch!==account.epoch||scope.tenantId!==account.workspaceId||scope.projectId!==account.projectId))connectionError("PROJECT_CONNECTION_ACCOUNT_MISMATCH");if(account&&verifyAccount){const identity=await new NativeStudioAccountClient({serverOrigin:account.serverOrigin,accessToken:account.accessToken}).me();if(identity.account.principalId!==account.principalId||!identity.account.tenants.some(t=>t.id===scope.tenantId))connectionError("PROJECT_CONNECTION_ACCOUNT_MISMATCH")}const profile=join3(root,value.profile),provider=await FileOAuthProvider.load(profile);if(provider.data.resource!==scope.resource||!provider.data.token?.access_token)connectionError("CONNECTION_PROFILE_MISMATCH");return{...scope,profile,scope:provider.data.token.scope??provider.data.scope,requestedScope:provider.data.scope,expiresAt:provider.data.expiresAt,exchangeUnresolved:Boolean(provider.data.pendingExchange)}}var authentication=["--profile","--origin","--mcp-url","--token-env","--token-file"];async function defaultConnection(options,environment,tenant){if(authentication.some(key=>options.has(key)))return;const connection=await loadConnection(environment,true);if(!connection)connectionError("PROJECT_CONNECTION_REQUIRED");if(options.has("--tenant")&&options.get("--tenant")!==connection.tenantId)connectionError("CONNECTION_SCOPE_MISMATCH");options.set("--profile",connection.profile);if(tenant)options.set("--tenant",connection.tenantId)}async function connectionStatus(environment){const value=await loadConnection(environment);return{exitCode:0,output:value?{semanticStatus:"SUCCESS",connected:true,credentialPurpose:"PROJECT_MCP",accountSessionVerified:false,verification:"LOCAL_METADATA_ONLY",resource:value.resource,tenantId:value.tenantId,projectId:value.projectId,scope:value.scope,requestedScope:value.requestedScope,expiresAt:value.expiresAt,credentialState:value.exchangeUnresolved?"EXCHANGE_UNRESOLVED":typeof value.expiresAt==="number"&&value.expiresAt>Date.now()+3e4?"CACHED":"REFRESH_REQUIRED",nextSteps:value.exchangeUnresolved?["Wait for the active authorization command. If it returned OAUTH_OUTCOME_UNKNOWN, run nvs connect --mcp-url <project-connection-url>."]:["nvs find --query <intent>","nvs capabilities","nvs mcp"]}:{semanticStatus:"NEEDS_INPUT",connected:false,credentialPurpose:"PROJECT_MCP",accountSessionVerified:false,nextSteps:["Sign in/register your account on Web or Electron, then select a workspace/project and open its Agent connection page.","nvs connect --mcp-url <project-connection-url>"]}}}export{connectionError,clientHome,accountServerOrigin,NativeStudioAccountClient,accountError,readAccount,saveAccount,withAccountLock,requireAccount,projectConnection,saveConnection,defaultConnection,connectionStatus};