@nativestudio/cli 0.0.0-stage → 0.3.0-rc.11

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 (266) hide show
  1. package/COMPATIBILITY.json +45 -0
  2. package/LICENSE +201 -0
  3. package/components/runtime.json +31 -0
  4. package/components/runtime.tgz +0 -0
  5. package/dist/BUNDLED_DEPENDENCIES.json +1 -0
  6. package/dist/_chunks/chunk-2UYKJ6YN.js +1 -0
  7. package/dist/_chunks/chunk-37PAJCKA.js +1 -0
  8. package/dist/_chunks/chunk-3AVC742O.js +1 -0
  9. package/dist/_chunks/chunk-4U4Y2K73.js +1 -0
  10. package/dist/_chunks/chunk-65FQPXKC.js +1 -0
  11. package/dist/_chunks/chunk-6DVZBKNV.js +1 -0
  12. package/dist/_chunks/chunk-6LU6GJKW.js +1 -0
  13. package/dist/_chunks/chunk-6N433ZWR.js +1 -0
  14. package/dist/_chunks/chunk-EGUJ2YRX.js +1 -0
  15. package/dist/_chunks/chunk-FU3524Z6.js +1 -0
  16. package/dist/_chunks/chunk-GZBWA4YN.js +1 -0
  17. package/dist/_chunks/chunk-HR34UMPP.js +1 -0
  18. package/dist/_chunks/chunk-HTUTYIRU.js +1 -0
  19. package/dist/_chunks/chunk-JFC6ZIGA.js +1 -0
  20. package/dist/_chunks/chunk-KB2GVAN7.js +1 -0
  21. package/dist/_chunks/chunk-L543FEDK.js +1 -0
  22. package/dist/_chunks/chunk-LISB5W7B.js +1 -0
  23. package/dist/_chunks/chunk-LUAH3KAS.js +1 -0
  24. package/dist/_chunks/chunk-M2KVQQ4X.js +1 -0
  25. package/dist/_chunks/chunk-ODGPV7MM.js +1 -0
  26. package/dist/_chunks/chunk-PUBMDP4E.js +1 -0
  27. package/dist/_chunks/chunk-PUNG4ND7.js +1 -0
  28. package/dist/_chunks/chunk-Q57YFNK5.js +1 -0
  29. package/dist/_chunks/chunk-QAJH4RJQ.js +1 -0
  30. package/dist/_chunks/chunk-VDNNFVTZ.js +3 -0
  31. package/dist/_chunks/chunk-VPYAXWXY.js +1 -0
  32. package/dist/_chunks/chunk-WFRRNWO5.js +1 -0
  33. package/dist/_chunks/connect-5YMO6MAR.js +1 -0
  34. package/dist/_chunks/device-management-2OTGEBJQ.js +1 -0
  35. package/dist/_chunks/device-preflight-XPHFZGLO.js +1 -0
  36. package/dist/_chunks/devices-inventory-VWNTU5TE.js +1 -0
  37. package/dist/_chunks/devices-main-VQ4APRVS.js +1 -0
  38. package/dist/_chunks/files-TTIQ7LYJ.js +1 -0
  39. package/dist/_chunks/host-main-H7DPLV7B.js +1 -0
  40. package/dist/_chunks/http-profile-MNJX6OXO.js +1 -0
  41. package/dist/_chunks/library-main-SAC3V2ML.js +1 -0
  42. package/dist/_chunks/local-main-D6B3APK6.js +1 -0
  43. package/dist/_chunks/local-mcp-ONCANLPH.js +1 -0
  44. package/dist/_chunks/main-PW6HB3NC.js +2 -0
  45. package/dist/_chunks/mcp-ZIGBYFUW.js +1 -0
  46. package/dist/_chunks/oauth-HC6TI7HB.js +1 -0
  47. package/dist/_chunks/render-main-GYWKP72O.js +1 -0
  48. package/dist/_chunks/source-import-BC5GNCUZ.js +1 -0
  49. package/dist/_chunks/src-R6DNU336.js +1 -0
  50. package/dist/_chunks/stdio-main-RIJS5REB.js +1 -0
  51. package/dist/_chunks/workspace-main-GNSKHKBG.js +1 -0
  52. package/dist/_types/cli/local/desktop-channel.d.ts +18 -0
  53. package/dist/_types/cli/local/desktop-contract.d.ts +2176 -0
  54. package/dist/_types/cli/local/desktop-device-contract.d.ts +779 -0
  55. package/dist/_types/cli/local/desktop-device-navigation.d.ts +3 -0
  56. package/dist/_types/cli/local/desktop-device-owner.d.ts +244 -0
  57. package/dist/_types/cli/local/desktop-device-state.d.ts +397 -0
  58. package/dist/_types/cli/local/desktop-library.d.ts +853 -0
  59. package/dist/_types/cli/local/desktop-node.d.ts +1 -0
  60. package/dist/_types/cli/local/desktop-owner.d.ts +766 -0
  61. package/dist/_types/cli/local/ledger.d.ts +363 -0
  62. package/dist/_types/cli/local/manager.d.ts +1695 -0
  63. package/dist/_types/cli/local/mcp-tools.d.ts +660 -0
  64. package/dist/_types/cli/local/releases.d.ts +123 -0
  65. package/dist/_types/cli/local-management.d.ts +16 -0
  66. package/dist/_types/cli/local-navigation.d.ts +4 -0
  67. package/dist/_types/contracts/accepted-shot.d.ts +27 -0
  68. package/dist/_types/contracts/accepted-visual-source.d.ts +120 -0
  69. package/dist/_types/contracts/agent-execution-lifecycle.d.ts +749 -0
  70. package/dist/_types/contracts/agent-execution-oauth.d.ts +71 -0
  71. package/dist/_types/contracts/agent-execution-registration.d.ts +240 -0
  72. package/dist/_types/contracts/agent-execution-selection.d.ts +107 -0
  73. package/dist/_types/contracts/agent-host-execution.d.ts +706 -0
  74. package/dist/_types/contracts/agent-host-generic-transport.d.ts +12 -0
  75. package/dist/_types/contracts/agent-host.d.ts +226 -0
  76. package/dist/_types/contracts/artifact-discovery.d.ts +242 -0
  77. package/dist/_types/contracts/artifact.d.ts +188 -0
  78. package/dist/_types/contracts/audio.d.ts +335 -0
  79. package/dist/_types/contracts/brief.d.ts +178 -0
  80. package/dist/_types/contracts/caption-render.d.ts +20 -0
  81. package/dist/_types/contracts/caption-transcript.d.ts +102 -0
  82. package/dist/_types/contracts/captions.d.ts +420 -0
  83. package/dist/_types/contracts/clip-framing.d.ts +14 -0
  84. package/dist/_types/contracts/clip-transition.d.ts +6 -0
  85. package/dist/_types/contracts/composition-authoring-guide.d.ts +160 -0
  86. package/dist/_types/contracts/composition-authoring.d.ts +744 -0
  87. package/dist/_types/contracts/composition-finding-locality.d.ts +24 -0
  88. package/dist/_types/contracts/composition-frame-render.d.ts +226 -0
  89. package/dist/_types/contracts/composition-making.d.ts +390 -0
  90. package/dist/_types/contracts/composition-observation.d.ts +239 -0
  91. package/dist/_types/contracts/composition-render-base.d.ts +293 -0
  92. package/dist/_types/contracts/composition-render-observation.d.ts +278 -0
  93. package/dist/_types/contracts/composition-render.d.ts +406 -0
  94. package/dist/_types/contracts/composition-repair.d.ts +451 -0
  95. package/dist/_types/contracts/composition-source-review.d.ts +1042 -0
  96. package/dist/_types/contracts/consistency-profile.d.ts +845 -0
  97. package/dist/_types/contracts/continuity-evaluation.d.ts +48 -0
  98. package/dist/_types/contracts/delivery-completion.d.ts +210 -0
  99. package/dist/_types/contracts/delivery-manifest.d.ts +72 -0
  100. package/dist/_types/contracts/delivery-operations.d.ts +1151 -0
  101. package/dist/_types/contracts/delivery-output-profile.d.ts +12 -0
  102. package/dist/_types/contracts/delivery-summary.d.ts +220 -0
  103. package/dist/_types/contracts/delivery-validation.d.ts +206 -0
  104. package/dist/_types/contracts/device-render.d.ts +77 -0
  105. package/dist/_types/contracts/director-proposal.d.ts +1067 -0
  106. package/dist/_types/contracts/editor-intelligence.d.ts +3374 -0
  107. package/dist/_types/contracts/exploration-recommendation.d.ts +519 -0
  108. package/dist/_types/contracts/external-agent-access.d.ts +93 -0
  109. package/dist/_types/contracts/final-ready.d.ts +301 -0
  110. package/dist/_types/contracts/final-render-profile.d.ts +59 -0
  111. package/dist/_types/contracts/final-render.d.ts +2810 -0
  112. package/dist/_types/contracts/foundation.d.ts +1 -0
  113. package/dist/_types/contracts/generation-contract.d.ts +268 -0
  114. package/dist/_types/contracts/generation-cost.d.ts +70 -0
  115. package/dist/_types/contracts/health.d.ts +6 -0
  116. package/dist/_types/contracts/human-identity.d.ts +162 -0
  117. package/dist/_types/contracts/hyperframe-profile.d.ts +5 -0
  118. package/dist/_types/contracts/ids.d.ts +41 -0
  119. package/dist/_types/contracts/index.d.ts +126 -0
  120. package/dist/_types/contracts/interface/common.d.ts +56 -0
  121. package/dist/_types/contracts/interface/execution-output.d.ts +99 -0
  122. package/dist/_types/contracts/interface/index.d.ts +7 -0
  123. package/dist/_types/contracts/interface/media-output.d.ts +90 -0
  124. package/dist/_types/contracts/interface/operation.d.ts +61 -0
  125. package/dist/_types/contracts/interface/output.d.ts +15 -0
  126. package/dist/_types/contracts/interface/production-snapshot.d.ts +654 -0
  127. package/dist/_types/contracts/interface/query.d.ts +315 -0
  128. package/dist/_types/contracts/keyframe-generation.d.ts +378 -0
  129. package/dist/_types/contracts/keyframe-reference.d.ts +31 -0
  130. package/dist/_types/contracts/keyframe-review.d.ts +753 -0
  131. package/dist/_types/contracts/lifecycle-event-projections.d.ts +191 -0
  132. package/dist/_types/contracts/lifecycle-events.d.ts +156 -0
  133. package/dist/_types/contracts/listening-evidence.d.ts +37 -0
  134. package/dist/_types/contracts/local-execution/agent-context.d.ts +365 -0
  135. package/dist/_types/contracts/local-execution/agent-evidence.d.ts +79 -0
  136. package/dist/_types/contracts/local-execution/agent-grant.d.ts +31 -0
  137. package/dist/_types/contracts/local-execution/agent-review.d.ts +992 -0
  138. package/dist/_types/contracts/local-execution/canonical.d.ts +2 -0
  139. package/dist/_types/contracts/local-execution/common.d.ts +49 -0
  140. package/dist/_types/contracts/local-execution/completion.d.ts +124 -0
  141. package/dist/_types/contracts/local-execution/components.d.ts +45 -0
  142. package/dist/_types/contracts/local-execution/descriptor.d.ts +38 -0
  143. package/dist/_types/contracts/local-execution/device-authority.d.ts +31 -0
  144. package/dist/_types/contracts/local-execution/device-inventory.d.ts +76 -0
  145. package/dist/_types/contracts/local-execution/device-workspace.d.ts +11 -0
  146. package/dist/_types/contracts/local-execution/device.d.ts +102 -0
  147. package/dist/_types/contracts/local-execution/external-generation.d.ts +199 -0
  148. package/dist/_types/contracts/local-execution/index.d.ts +37 -0
  149. package/dist/_types/contracts/local-execution/ipc.d.ts +3730 -0
  150. package/dist/_types/contracts/local-execution/library-command.d.ts +620 -0
  151. package/dist/_types/contracts/local-execution/library-result.d.ts +408 -0
  152. package/dist/_types/contracts/local-execution/library.d.ts +873 -0
  153. package/dist/_types/contracts/local-execution/lifecycle.d.ts +519 -0
  154. package/dist/_types/contracts/local-execution/local-navigation.d.ts +929 -0
  155. package/dist/_types/contracts/local-execution/management.d.ts +400 -0
  156. package/dist/_types/contracts/local-execution/media-recipe.d.ts +207 -0
  157. package/dist/_types/contracts/local-execution/media-validation-request.d.ts +232 -0
  158. package/dist/_types/contracts/local-execution/media-validation.d.ts +262 -0
  159. package/dist/_types/contracts/local-execution/object-transfer.d.ts +155 -0
  160. package/dist/_types/contracts/local-execution/offline.d.ts +59 -0
  161. package/dist/_types/contracts/local-execution/preview.d.ts +243 -0
  162. package/dist/_types/contracts/local-execution/processor-capability.d.ts +39 -0
  163. package/dist/_types/contracts/local-execution/processor-direct.d.ts +290 -0
  164. package/dist/_types/contracts/local-execution/processor-recipes.d.ts +1122 -0
  165. package/dist/_types/contracts/local-execution/processor.d.ts +6173 -0
  166. package/dist/_types/contracts/local-execution/project-source-direct.d.ts +201 -0
  167. package/dist/_types/contracts/local-execution/qwen-tts.d.ts +31 -0
  168. package/dist/_types/contracts/local-execution/recognition.d.ts +170 -0
  169. package/dist/_types/contracts/local-execution/speech.d.ts +95 -0
  170. package/dist/_types/contracts/local-execution/tool-selection.d.ts +55 -0
  171. package/dist/_types/contracts/local-execution/whisper.d.ts +24 -0
  172. package/dist/_types/contracts/local-execution/work.d.ts +149 -0
  173. package/dist/_types/contracts/local-execution/workspace.d.ts +141 -0
  174. package/dist/_types/contracts/matrix-parameter-rule.d.ts +23 -0
  175. package/dist/_types/contracts/media-category.d.ts +11 -0
  176. package/dist/_types/contracts/media-export.d.ts +23 -0
  177. package/dist/_types/contracts/media-observation.d.ts +2080 -0
  178. package/dist/_types/contracts/model-capability-matrix.d.ts +118 -0
  179. package/dist/_types/contracts/native-tool-authority-failure.d.ts +38 -0
  180. package/dist/_types/contracts/native-tool-authority.d.ts +110 -0
  181. package/dist/_types/contracts/native-tool-execution.d.ts +287 -0
  182. package/dist/_types/contracts/native-tool-gateway.d.ts +41 -0
  183. package/dist/_types/contracts/native-video-audio.d.ts +62 -0
  184. package/dist/_types/contracts/navigation-context.d.ts +253 -0
  185. package/dist/_types/contracts/navigation-groups.d.ts +51 -0
  186. package/dist/_types/contracts/navigation.d.ts +248 -0
  187. package/dist/_types/contracts/observation-profile.d.ts +99 -0
  188. package/dist/_types/contracts/planning-input.d.ts +177 -0
  189. package/dist/_types/contracts/principal.d.ts +26 -0
  190. package/dist/_types/contracts/production-creation.d.ts +66 -0
  191. package/dist/_types/contracts/production-termination.d.ts +51 -0
  192. package/dist/_types/contracts/production.d.ts +111 -0
  193. package/dist/_types/contracts/programmatic-composition.d.ts +762 -0
  194. package/dist/_types/contracts/programmatic-exploration.d.ts +1822 -0
  195. package/dist/_types/contracts/programmatic-video-review.d.ts +894 -0
  196. package/dist/_types/contracts/project-library.d.ts +173 -0
  197. package/dist/_types/contracts/project.d.ts +93 -0
  198. package/dist/_types/contracts/provider-catalog.d.ts +421 -0
  199. package/dist/_types/contracts/provider-models.d.ts +3388 -0
  200. package/dist/_types/contracts/provider.d.ts +207 -0
  201. package/dist/_types/contracts/reference-preview.d.ts +55 -0
  202. package/dist/_types/contracts/repair-lifecycle.d.ts +2564 -0
  203. package/dist/_types/contracts/repair-plan.d.ts +646 -0
  204. package/dist/_types/contracts/repair-strategy.d.ts +1432 -0
  205. package/dist/_types/contracts/review-intelligence-evidence.d.ts +136 -0
  206. package/dist/_types/contracts/review-intelligence-final-output.d.ts +883 -0
  207. package/dist/_types/contracts/review-intelligence.d.ts +573 -0
  208. package/dist/_types/contracts/review1-repair-source.d.ts +452 -0
  209. package/dist/_types/contracts/review1-repair-strategy.d.ts +491 -0
  210. package/dist/_types/contracts/review1-repair.d.ts +36 -0
  211. package/dist/_types/contracts/rough-cut-manifest.d.ts +352 -0
  212. package/dist/_types/contracts/rough-cut-profile.d.ts +46 -0
  213. package/dist/_types/contracts/rough-cut-review.d.ts +459 -0
  214. package/dist/_types/contracts/rough-cut.d.ts +1260 -0
  215. package/dist/_types/contracts/scene-shot-plan.d.ts +882 -0
  216. package/dist/_types/contracts/sdk-discovery.d.ts +66 -0
  217. package/dist/_types/contracts/shot-direction.d.ts +113 -0
  218. package/dist/_types/contracts/shot-preparation-basis.d.ts +356 -0
  219. package/dist/_types/contracts/shot-preparation.d.ts +2285 -0
  220. package/dist/_types/contracts/shot-sound-instruction.d.ts +58 -0
  221. package/dist/_types/contracts/sound-making-plan.d.ts +1586 -0
  222. package/dist/_types/contracts/source-sound-policy.d.ts +10 -0
  223. package/dist/_types/contracts/source-workspace.d.ts +62 -0
  224. package/dist/_types/contracts/speech-cost.d.ts +81 -0
  225. package/dist/_types/contracts/speech.d.ts +573 -0
  226. package/dist/_types/contracts/story.d.ts +98 -0
  227. package/dist/_types/contracts/temporal-evidence-operation.d.ts +380 -0
  228. package/dist/_types/contracts/temporal-evidence-reference.d.ts +18 -0
  229. package/dist/_types/contracts/temporal-evidence.d.ts +248 -0
  230. package/dist/_types/contracts/tenant.d.ts +7 -0
  231. package/dist/_types/contracts/timeline-audio.d.ts +98 -0
  232. package/dist/_types/contracts/timeline-graphics.d.ts +80 -0
  233. package/dist/_types/contracts/timeline-manifest.d.ts +704 -0
  234. package/dist/_types/contracts/timeline-source-sound.d.ts +353 -0
  235. package/dist/_types/contracts/timeline-v2.d.ts +1267 -0
  236. package/dist/_types/contracts/timeline-version-reader.d.ts +2955 -0
  237. package/dist/_types/contracts/timeline-visual-layers.d.ts +1249 -0
  238. package/dist/_types/contracts/timeline.d.ts +142 -0
  239. package/dist/_types/contracts/transcription.d.ts +80 -0
  240. package/dist/_types/contracts/video-generation.d.ts +676 -0
  241. package/dist/_types/contracts/video-review.d.ts +1871 -0
  242. package/dist/_types/contracts/visual-exploration.d.ts +1586 -0
  243. package/dist/_types/contracts/visual-layer-render.d.ts +2820 -0
  244. package/dist/_types/contracts/visual-layer.d.ts +112 -0
  245. package/dist/_types/contracts/visual-sequence.d.ts +143 -0
  246. package/dist/_types/contracts/workspace.d.ts +32 -0
  247. package/dist/_types/contracts/writer-proposal.d.ts +268 -0
  248. package/dist/_types/sdk/errors.d.ts +14 -0
  249. package/dist/_types/sdk/local-runtime/components.d.ts +2 -0
  250. package/dist/_types/sdk/local-runtime/device-client.d.ts +187 -0
  251. package/dist/_types/sdk/local-runtime/library.d.ts +268 -0
  252. package/dist/_types/sdk/local-runtime/workspace.d.ts +186 -0
  253. package/dist/_types/sdk/local-runtime-client.d.ts +2616 -0
  254. package/dist/entry.js +2 -0
  255. package/dist/local-management.d.ts +1 -0
  256. package/dist/local-management.js +1 -0
  257. package/dist/local-navigation.d.ts +1 -0
  258. package/dist/local-navigation.js +1 -0
  259. package/dist/native/Bootstrap.ps1 +90 -0
  260. package/dist/native/JobNative.cs +137 -0
  261. package/dist/native/JobRunner.cs +381 -0
  262. package/dist/native/NativeMain.cs +161 -0
  263. package/dist/native/PipeBridge.cs +260 -0
  264. package/dist/native/PrivateAccess.cs +152 -0
  265. package/package.json +27 -3
  266. package/README.md +0 -3
@@ -0,0 +1,260 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.IO.Pipes;
4
+ using System.Collections.Generic;
5
+ using System.Collections.Concurrent;
6
+ using System.Runtime.InteropServices;
7
+ using System.Threading;
8
+ using Microsoft.Win32.SafeHandles;
9
+ namespace NativeStudio.Platform
10
+ {
11
+ public static class PipeBridge
12
+ {
13
+ sealed class Client
14
+ {
15
+ public NamedPipeServerStream Pipe;
16
+ public readonly ManualResetEventSlim Flow = new ManualResetEventSlim(true);
17
+ public readonly BlockingCollection<byte[]> Writes = new BlockingCollection<byte[]>(8);
18
+ }
19
+ static readonly Dictionary<string, Client> Clients = new Dictionary<string, Client>();
20
+ static readonly object Sync = new object();
21
+ static NamedPipeServerStream waiting;
22
+ static volatile bool closed;
23
+ [StructLayout(LayoutKind.Sequential)]
24
+ struct SecurityAttributes
25
+ {
26
+ public int length; public IntPtr descriptor; public int inherit;
27
+ }
28
+ [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(string s, uint revision, out IntPtr sd, out uint length);
29
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern SafePipeHandle CreateNamedPipe(string name, uint access, uint mode, uint max, uint output, uint input, uint timeout, ref SecurityAttributes sa);
30
+ [DllImport("kernel32.dll")] static extern IntPtr LocalFree(IntPtr p);
31
+ static NamedPipeServerStream Create(string path, bool first)
32
+ {
33
+ IntPtr sd;
34
+ uint length;
35
+ if (!ConvertStringSecurityDescriptorToSecurityDescriptor("O:" + PrivateAccess.User.Value + "D:P(D;;GA;;;NU)(A;;GA;;;" + PrivateAccess.User.Value + ")", 1, out sd, out length))
36
+ throw new Exception("PIPE_SECURITY");
37
+ try
38
+ {
39
+ var attributes = new SecurityAttributes { length = Marshal.SizeOf(typeof(SecurityAttributes)), descriptor = sd, inherit = 0 };
40
+ var handle = CreateNamedPipe(path, 3U | 0x40000000U | (first ? 0x80000U : 0U), 8, 16, 65536, 65536, 0, ref attributes);
41
+ if (handle.IsInvalid)
42
+ {
43
+ handle.Dispose();
44
+ throw new Exception("PIPE_IN_USE");
45
+ }
46
+ return new NamedPipeServerStream(PipeDirection.InOut, true, false, handle);
47
+ }
48
+ finally { LocalFree(sd); }
49
+ }
50
+ static void End(string id)
51
+ {
52
+ Client client;
53
+ lock (Sync)
54
+ {
55
+ if (!Clients.TryGetValue(id, out client))
56
+ return;
57
+ Clients.Remove(id);
58
+ }
59
+ lock (client)
60
+ client.Writes.CompleteAdding();
61
+ client.Flow.Set();
62
+ client.Pipe.Dispose();
63
+ NativeMain.Send(new
64
+ {
65
+ kind = "close",
66
+ id = id
67
+ });
68
+ }
69
+ static void Write(Client client, string id)
70
+ {
71
+ try
72
+ {
73
+ foreach (var bytes in client.Writes.GetConsumingEnumerable())
74
+ {
75
+ var task = client.Pipe.WriteAsync(bytes, 0, bytes.Length);
76
+ if (!task.Wait(2000))
77
+ {
78
+ // Closing this owned pipe cancels the pending overlapped write.
79
+ task.ContinueWith(t => GC.KeepAlive(t.Exception), System.Threading.Tasks.TaskContinuationOptions.OnlyOnFaulted);
80
+ break;
81
+ }
82
+ NativeMain.Send(new
83
+ {
84
+ kind = "written",
85
+ id = id
86
+ });
87
+ }
88
+ using (var timeout = new Timer(delegate
89
+ {
90
+ End(id);
91
+ }, null, 2000, Timeout.Infinite))
92
+ client.Pipe.WaitForPipeDrain();
93
+ }
94
+ catch { }
95
+ finally { End(id); }
96
+ }
97
+ static void Accept(string path)
98
+ {
99
+ bool first = true;
100
+ try
101
+ {
102
+ while (!closed)
103
+ {
104
+ lock (Sync)
105
+ {
106
+ if (Clients.Count >= 15)
107
+ {
108
+ Monitor.Wait(Sync, 100);
109
+ continue;
110
+ }
111
+ }
112
+ waiting = Create(path, first);
113
+ if (first)
114
+ {
115
+ NativeMain.Send(new
116
+ {
117
+ kind = "ready"
118
+ });
119
+ first = false;
120
+ }
121
+ var pipe = waiting;
122
+ pipe.WaitForConnection();
123
+ waiting = null;
124
+ if (closed)
125
+ {
126
+ pipe.Dispose();
127
+ break;
128
+ }
129
+ var id = Guid.NewGuid().ToString();
130
+ var client = new Client { Pipe = pipe };
131
+ lock (Sync)
132
+ Clients.Add(id, client);
133
+ NativeMain.Send(new
134
+ {
135
+ kind = "open",
136
+ id = id
137
+ });
138
+ var writer = new Thread(delegate ()
139
+ {
140
+ Write(client, id);
141
+ });
142
+ writer.IsBackground = true;
143
+ writer.Start();
144
+ ThreadPool.QueueUserWorkItem(delegate
145
+ {
146
+ try
147
+ {
148
+ var buffer = new byte[4096];
149
+ int count;
150
+ while (!closed)
151
+ {
152
+ if (!client.Flow.Wait(65000))
153
+ break;
154
+ count = pipe.Read(buffer, 0, buffer.Length);
155
+ if (count <= 0)
156
+ break;
157
+ NativeMain.Send(new
158
+ {
159
+ kind = "data",
160
+ id = id,
161
+ data = Convert.ToBase64String(buffer, 0, count)
162
+ });
163
+ }
164
+ }
165
+ catch { }
166
+ finally { End(id); }
167
+ });
168
+ }
169
+ }
170
+ catch { if (!closed) Environment.Exit(1); }
171
+ }
172
+ public static void Run(string path)
173
+ {
174
+ if (!System.Text.RegularExpressions.Regex.IsMatch(path, @"^\\\\\.\\pipe\\nvs-[0-9a-f]{64}$"))
175
+ throw new Exception("PIPE");
176
+ var thread = new Thread(delegate ()
177
+ {
178
+ Accept(path);
179
+ });
180
+ thread.IsBackground = true;
181
+ thread.Start();
182
+ try
183
+ {
184
+ for (; ; )
185
+ {
186
+ var line = NativeMain.Line(65536);
187
+ if (line == null)
188
+ break;
189
+ Dictionary<string, object> r;
190
+ lock (NativeMain.Json)
191
+ r = NativeMain.Json.Deserialize<Dictionary<string, object>>(line);
192
+ var id = NativeMain.Text(r, "id");
193
+ var kind = NativeMain.Text(r, "kind");
194
+ if (kind == "close")
195
+ {
196
+ End(id);
197
+ continue;
198
+ }
199
+ if (kind == "finish")
200
+ {
201
+ Client selected;
202
+ lock (Sync)
203
+ Clients.TryGetValue(id, out selected);
204
+ if (selected != null)
205
+ lock (selected)
206
+ selected.Writes.CompleteAdding();
207
+ continue;
208
+ }
209
+ if (kind == "pause" || kind == "resume")
210
+ {
211
+ Client selected;
212
+ lock (Sync)
213
+ Clients.TryGetValue(id, out selected);
214
+ if (selected != null)
215
+ {
216
+ if (kind == "pause")
217
+ selected.Flow.Reset();
218
+ else
219
+ selected.Flow.Set();
220
+ }
221
+ continue;
222
+ }
223
+ if (kind != "data")
224
+ throw new Exception("FRAME");
225
+ var bytes = Convert.FromBase64String(NativeMain.Text(r, "data"));
226
+ if (bytes.Length > 16384)
227
+ throw new Exception("FRAME");
228
+ Client client;
229
+ lock (Sync)
230
+ Clients.TryGetValue(id, out client);
231
+ if (client != null)
232
+ {
233
+ bool full;
234
+ lock (client)
235
+ full = !client.Writes.IsAddingCompleted && !client.Writes.TryAdd(bytes);
236
+ if (full)
237
+ End(id);
238
+ }
239
+ }
240
+ }
241
+ finally
242
+ {
243
+ closed = true;
244
+ if (waiting != null)
245
+ waiting.Dispose();
246
+ lock (Sync)
247
+ {
248
+ foreach (var client in Clients.Values)
249
+ {
250
+ lock (client)
251
+ client.Writes.CompleteAdding();
252
+ client.Flow.Set();
253
+ client.Pipe.Dispose();
254
+ }
255
+ Clients.Clear();
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
@@ -0,0 +1,152 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.ComponentModel;
4
+ using System.Runtime.InteropServices;
5
+ using System.Security.AccessControl;
6
+ using System.Security.Principal;
7
+ using Microsoft.Win32.SafeHandles;
8
+ namespace NativeStudio.Platform
9
+ {
10
+ public static class PrivateAccess
11
+ {
12
+ public static readonly SecurityIdentifier User = WindowsIdentity.GetCurrent().User;
13
+ static readonly string Installer = ((SecurityIdentifier)new NTAccount("NT SERVICE", "TrustedInstaller").Translate(typeof(SecurityIdentifier))).Value;
14
+ static bool Privileged(string sid)
15
+ {
16
+ return sid == User.Value || sid == "S-1-5-18" || sid == "S-1-5-32-544" || sid == Installer;
17
+ }
18
+ public static string PathOf(string path)
19
+ {
20
+ if (String.IsNullOrEmpty(path) || !System.Text.RegularExpressions.Regex.IsMatch(path, @"^[A-Za-z]:[\\/]") || path.StartsWith("\\\\") || path.IndexOf(':', 2) >= 0)
21
+ throw new Exception("PATH");
22
+ var full = Path.GetFullPath(path);
23
+ var drive = new DriveInfo(Path.GetPathRoot(full));
24
+ if (drive.DriveType != DriveType.Fixed || drive.DriveFormat != "NTFS")
25
+ throw new Exception("PRIVATE_NTFS_REQUIRED");
26
+ return full;
27
+ }
28
+ static void Rules(FileSystemSecurity acl, bool privacy)
29
+ {
30
+ if (privacy && acl.GetOwner(typeof(SecurityIdentifier)).Value != User.Value)
31
+ throw new Exception("OWNER");
32
+ foreach (FileSystemAccessRule rule in acl.GetAccessRules(true, true, typeof(SecurityIdentifier)))
33
+ {
34
+ if ((rule.PropagationFlags & PropagationFlags.InheritOnly) != 0 || rule.AccessControlType != AccessControlType.Allow || Privileged(rule.IdentityReference.Value))
35
+ continue;
36
+ const FileSystemRights write = FileSystemRights.Write | FileSystemRights.Delete | FileSystemRights.DeleteSubdirectoriesAndFiles | FileSystemRights.ChangePermissions | FileSystemRights.TakeOwnership;
37
+ if (privacy || (rule.FileSystemRights & write) != 0)
38
+ throw new Exception("ACL");
39
+ }
40
+ }
41
+ static void Ancestors(string path)
42
+ {
43
+ var parent = new DirectoryInfo(Path.GetDirectoryName(path));
44
+ while (parent != null && parent.Parent != null)
45
+ {
46
+ if ((parent.Attributes & FileAttributes.ReparsePoint) != 0)
47
+ throw new Exception("REPARSE");
48
+ Rules(parent.GetAccessControl(), false);
49
+ parent = parent.Parent;
50
+ }
51
+ }
52
+ public static void Directory(string path)
53
+ {
54
+ path = PathOf(path);
55
+ if (!System.IO.Directory.Exists(path))
56
+ {
57
+ var parent = Path.GetDirectoryName(path);
58
+ if (!System.IO.Directory.Exists(parent))
59
+ Directory(parent);
60
+ Ancestors(path);
61
+ var acl = new DirectorySecurity();
62
+ acl.SetOwner(User);
63
+ acl.SetAccessRuleProtection(true, false);
64
+ acl.AddAccessRule(new FileSystemAccessRule(User, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
65
+ System.IO.Directory.CreateDirectory(path, acl);
66
+ }
67
+ Check(path, "directory", true);
68
+ }
69
+ public static void Check(string path, string kind, bool privacy)
70
+ {
71
+ if (kind == "pipe")
72
+ {
73
+ CheckPipe(path);
74
+ return;
75
+ }
76
+ path = PathOf(path);
77
+ Ancestors(path);
78
+ var attributes = File.GetAttributes(path);
79
+ if ((attributes & FileAttributes.ReparsePoint) != 0 || ((attributes & FileAttributes.Directory) != 0) != (kind == "directory"))
80
+ throw new Exception("KIND");
81
+ Rules(kind == "directory" ? (FileSystemSecurity)new DirectoryInfo(path).GetAccessControl() : new FileInfo(path).GetAccessControl(), privacy);
82
+ }
83
+ public static void Move(string source, string target, bool exclusive)
84
+ {
85
+ source = PathOf(source);
86
+ target = PathOf(target);
87
+ if (!String.Equals(Path.GetDirectoryName(source), Path.GetDirectoryName(target), StringComparison.OrdinalIgnoreCase))
88
+ throw new Exception("PATH");
89
+ Check(source, "file", true);
90
+ Check(Path.GetDirectoryName(source), "directory", true);
91
+ if (File.Exists(target))
92
+ {
93
+ if (exclusive)
94
+ throw new Exception("EXISTS");
95
+ Check(target, "file", true);
96
+ }
97
+ if (!MoveFileEx(source, target, 8U | (exclusive ? 0U : 1U)))
98
+ {
99
+ int error = Marshal.GetLastWin32Error();
100
+ if (error == 80 || error == 183)
101
+ throw new Exception("EXISTS");
102
+ throw new Win32Exception(error);
103
+ }
104
+ Check(target, "file", true);
105
+ }
106
+ static void CheckPipe(string path)
107
+ {
108
+ if (!System.Text.RegularExpressions.Regex.IsMatch(path, @"^\\\\\.\\pipe\\nvs-[0-9a-f]{64}$"))
109
+ throw new Exception("PIPE");
110
+ using (var handle = OpenPipe(path))
111
+ {
112
+ if (handle.IsInvalid)
113
+ throw new Win32Exception(Marshal.GetLastWin32Error());
114
+ IntPtr owner, group, dacl, sacl, descriptor;
115
+ uint result = GetSecurityInfo(handle, 1, 5, out owner, out group, out dacl, out sacl, out descriptor);
116
+ if (result != 0)
117
+ throw new Win32Exception((int)result);
118
+ try
119
+ {
120
+ uint length = GetSecurityDescriptorLength(descriptor);
121
+ var bytes = new byte[length];
122
+ Marshal.Copy(descriptor, bytes, 0, bytes.Length);
123
+ var acl = new FileSecurity();
124
+ acl.SetSecurityDescriptorBinaryForm(bytes);
125
+ Rules(acl, true);
126
+ }
127
+ finally { LocalFree(descriptor); }
128
+ }
129
+ }
130
+ static SafeFileHandle OpenPipe(string path)
131
+ {
132
+ for (int attempt = 0; attempt < 4; attempt++)
133
+ {
134
+ var handle = CreateFile(path, 0x20000, 0, IntPtr.Zero, 3, 0, IntPtr.Zero);
135
+ if (!handle.IsInvalid)
136
+ return handle;
137
+ int error = Marshal.GetLastWin32Error();
138
+ handle.Dispose();
139
+ // Bounded readiness observation only; no authenticated request is retried.
140
+ if (error != 231 || attempt == 3 || !WaitNamedPipe(path, 250))
141
+ throw new Win32Exception(error);
142
+ }
143
+ throw new Exception("PIPE_BUSY");
144
+ }
145
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool MoveFileEx(string source, string target, uint flags);
146
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern SafeFileHandle CreateFile(string path, uint access, uint share, IntPtr sa, uint creation, uint flags, IntPtr template);
147
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern bool WaitNamedPipe(string path, uint milliseconds);
148
+ [DllImport("advapi32.dll", SetLastError = true)] static extern uint GetSecurityInfo(SafeFileHandle h, int type, uint info, out IntPtr owner, out IntPtr group, out IntPtr dacl, out IntPtr sacl, out IntPtr sd);
149
+ [DllImport("advapi32.dll")] static extern uint GetSecurityDescriptorLength(IntPtr sd);
150
+ [DllImport("kernel32.dll")] static extern IntPtr LocalFree(IntPtr p);
151
+ }
152
+ }
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@nativestudio/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.0-rc.11",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "engines": {
7
+ "node": ">=24.12 <25"
8
+ },
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ "./local-navigation": {
12
+ "types": "./dist/local-navigation.d.ts",
13
+ "import": "./dist/local-navigation.js"
14
+ },
15
+ "./local-management": {
16
+ "types": "./dist/local-management.d.ts",
17
+ "import": "./dist/local-management.js"
18
+ }
19
+ },
20
+ "dependencies": {
21
+ "zod": "4.6.7",
22
+ "@modelcontextprotocol/client": "2.4.0"
23
+ },
24
+ "bin": {
25
+ "nvs": "./dist/entry.js"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ }
6
30
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.