@walkhi/code-relax 0.1.0-beta.30 → 0.1.0-beta.31

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 (185) hide show
  1. package/README.md +95 -89
  2. package/dist/bin/cleanup-accounts.mjs +63 -63
  3. package/dist/bin/codex-remote.mjs +374 -367
  4. package/dist/bin/manage-relay-admin.mjs +20 -20
  5. package/dist/bin/migrate-relay-db.mjs +109 -109
  6. package/dist/bin/publish-android-release.mjs +62 -58
  7. package/dist/bin/self-relay-admin.mjs +8 -8
  8. package/dist/bin/self-relay-demo.mjs +33 -33
  9. package/dist/bin/self-relay-server.mjs +66 -66
  10. package/dist/build-platform.json +1 -1
  11. package/dist/get-lan-networks.ps1 +40 -40
  12. package/dist/get-shared-service-url.ps1 +6 -6
  13. package/dist/shared/app-server-events.cjs +422 -412
  14. package/dist/shared/code-browser.cjs +159 -159
  15. package/dist/shared/file-changes.cjs +31 -31
  16. package/dist/shared/file-citations.cjs +117 -117
  17. package/dist/shared/file-mentions.cjs +92 -92
  18. package/dist/shared/message-delivery.cjs +54 -54
  19. package/dist/shared/p2p-data-channel.cjs +72 -72
  20. package/dist/shared/p2p-diagnostics.cjs +28 -28
  21. package/dist/shared/p2p-file-channel.cjs +74 -74
  22. package/dist/shared/plan-pricing.cjs +32 -32
  23. package/dist/shared/question-attention.cjs +40 -0
  24. package/dist/shared/server-requests.cjs +219 -219
  25. package/dist/shared/timeline-sync.cjs +173 -173
  26. package/dist/skills/code-relax/SKILL.md +22 -22
  27. package/dist/src/archived-threads.mjs +22 -0
  28. package/dist/src/background-process.mjs +18 -18
  29. package/dist/src/bounded-process-log.mjs +63 -63
  30. package/dist/src/celsius-client.mjs +107 -107
  31. package/dist/src/code-browser.mjs +100 -100
  32. package/dist/src/desktop-launcher.mjs +46 -46
  33. package/dist/src/dots-approval-timeline.mjs +99 -99
  34. package/dist/src/dots-avatar.mjs +42 -42
  35. package/dist/src/dots-chat-projection.mjs +50 -50
  36. package/dist/src/dots-chat-server.mjs +461 -461
  37. package/dist/src/dots-message-images.mjs +319 -319
  38. package/dist/src/dots-profile.mjs +77 -77
  39. package/dist/src/dots-room-activity.mjs +94 -94
  40. package/dist/src/dots-room-client.mjs +135 -135
  41. package/dist/src/dots-room-projection.mjs +94 -94
  42. package/dist/src/dots-schedules.mjs +66 -66
  43. package/dist/src/dots-summary-tasks.mjs +32 -32
  44. package/dist/src/dots-task-catalog.mjs +430 -430
  45. package/dist/src/dots-task-files.mjs +52 -52
  46. package/dist/src/execution-health.mjs +26 -26
  47. package/dist/src/file-transfer-range.mjs +22 -22
  48. package/dist/src/file-upload-session.mjs +130 -130
  49. package/dist/src/hosted-history-app-server.mjs +103 -103
  50. package/dist/src/hosted-history-cache.mjs +113 -113
  51. package/dist/src/lan-socket-server.mjs +265 -263
  52. package/dist/src/managed-app-server.mjs +244 -244
  53. package/dist/src/message-images.mjs +9 -9
  54. package/dist/src/message-upload-files.mjs +74 -74
  55. package/dist/src/onboarding.mjs +12 -12
  56. package/dist/src/plan-pricing.mjs +47 -47
  57. package/dist/src/platform/README.md +12 -12
  58. package/dist/src/platform/codex-protocol.mjs +46 -46
  59. package/dist/src/platform/codex-runtime.mjs +3 -3
  60. package/dist/src/platform/credential-store.mjs +3 -3
  61. package/dist/src/platform/desktop-host.mjs +3 -3
  62. package/dist/src/platform/desktop-project-registration.mjs +3 -3
  63. package/dist/src/platform/desktop-project-store.mjs +208 -149
  64. package/dist/src/platform/file-opener.mjs +9 -0
  65. package/dist/src/platform/linux/README.md +3 -3
  66. package/dist/src/platform/linux/codex-runtime.mjs +56 -0
  67. package/dist/src/platform/linux/credential-store.mjs +28 -0
  68. package/dist/src/platform/linux/desktop-host.mjs +83 -0
  69. package/dist/src/platform/linux/desktop-installation.mjs +36 -0
  70. package/dist/src/platform/linux/desktop-project-registration.mjs +11 -0
  71. package/dist/src/platform/linux/network-info.mjs +11 -0
  72. package/dist/src/platform/linux/process.mjs +42 -0
  73. package/dist/src/platform/linux/project-locations.mjs +17 -0
  74. package/dist/src/platform/linux/resident-startup.mjs +52 -0
  75. package/dist/src/platform/linux/retained-runtime.mjs +76 -0
  76. package/dist/src/platform/linux/service-host.mjs +18 -0
  77. package/dist/src/platform/linux/system.mjs +49 -0
  78. package/dist/src/platform/linux/user-environment.mjs +7 -0
  79. package/dist/src/platform/macos/README.md +3 -3
  80. package/dist/src/platform/macos/codex-runtime.mjs +125 -125
  81. package/dist/src/platform/macos/credential-store.mjs +10 -10
  82. package/dist/src/platform/macos/desktop-host.mjs +82 -82
  83. package/dist/src/platform/macos/desktop-project-registration.mjs +11 -10
  84. package/dist/src/platform/macos/network-info.mjs +8 -28
  85. package/dist/src/platform/macos/project-locations.mjs +8 -8
  86. package/dist/src/platform/macos/resident-startup.mjs +84 -84
  87. package/dist/src/platform/macos/retained-runtime.mjs +127 -127
  88. package/dist/src/platform/macos/service-host.mjs +18 -18
  89. package/dist/src/platform/macos/system.mjs +29 -29
  90. package/dist/src/platform/macos/user-environment.mjs +7 -7
  91. package/dist/src/platform/native-package.mjs +58 -46
  92. package/dist/src/platform/network-info.mjs +3 -3
  93. package/dist/src/platform/path-identity.mjs +5 -5
  94. package/dist/src/platform/posix/network-candidates.mjs +23 -0
  95. package/dist/src/platform/posix/runtime-paths.mjs +25 -25
  96. package/dist/src/platform/project-locations.mjs +3 -3
  97. package/dist/src/platform/runtime-paths.mjs +8 -8
  98. package/dist/src/platform/select.mjs +5 -5
  99. package/dist/src/platform/service-host.mjs +3 -3
  100. package/dist/src/platform/user-environment.mjs +3 -3
  101. package/dist/src/platform/windows/IsolatedProcess.cs +79 -79
  102. package/dist/src/platform/windows/activate-desktop.ps1 +48 -48
  103. package/dist/src/platform/windows/background-process.mjs +30 -30
  104. package/dist/src/platform/windows/codex-runtime.mjs +215 -215
  105. package/dist/src/platform/windows/credential-store.mjs +27 -27
  106. package/dist/src/platform/windows/credential-store.ps1 +49 -49
  107. package/dist/src/platform/windows/desktop-helper.mjs +179 -179
  108. package/dist/src/platform/windows/desktop-host.mjs +58 -58
  109. package/dist/src/platform/windows/desktop-info.ps1 +14 -14
  110. package/dist/src/platform/windows/desktop-project-registration.mjs +4 -4
  111. package/dist/src/platform/windows/desktop-runtime.ps1 +10 -10
  112. package/dist/src/platform/windows/desktop-shortcuts.ps1 +21 -21
  113. package/dist/src/platform/windows/dots-profile.mjs +49 -49
  114. package/dist/src/platform/windows/launch-worker.mjs +41 -41
  115. package/dist/src/platform/windows/network-info.mjs +34 -34
  116. package/dist/src/platform/windows/project-locations.mjs +16 -16
  117. package/dist/src/platform/windows/resident-start.js +20 -20
  118. package/dist/src/platform/windows/resident-start.ps1 +7 -7
  119. package/dist/src/platform/windows/resident-startup.ps1 +83 -83
  120. package/dist/src/platform/windows/resolve-state-root.ps1 +14 -14
  121. package/dist/src/platform/windows/runtime-paths.mjs +20 -20
  122. package/dist/src/platform/windows/rustdesk-video-probe.mjs +167 -167
  123. package/dist/src/platform/windows/service-host.mjs +31 -31
  124. package/dist/src/platform/windows/start-hidden-console.ps1 +49 -49
  125. package/dist/src/platform/windows/stop-desktop.ps1 +22 -22
  126. package/dist/src/platform/windows/user-environment.mjs +50 -50
  127. package/dist/src/platform/windows/user-environment.ps1 +41 -41
  128. package/dist/src/project-archive.mjs +30 -0
  129. package/dist/src/project-create.mjs +121 -119
  130. package/dist/src/project-management.mjs +59 -69
  131. package/dist/src/project-remove.mjs +55 -0
  132. package/dist/src/project-update.mjs +56 -0
  133. package/dist/src/runtime-discovery.mjs +47 -47
  134. package/dist/src/self-relay/account-cleanup.mjs +30 -30
  135. package/dist/src/self-relay/account-connections.mjs +52 -52
  136. package/dist/src/self-relay/admin-cloud.mjs +101 -101
  137. package/dist/src/self-relay/admin-page.mjs +80 -80
  138. package/dist/src/self-relay/admin-server.mjs +74 -74
  139. package/dist/src/self-relay/admin-state.mjs +127 -127
  140. package/dist/src/self-relay/admin-style.mjs +14 -14
  141. package/dist/src/self-relay/android-releases.mjs +61 -61
  142. package/dist/src/self-relay/client.mjs +61 -61
  143. package/dist/src/self-relay/connector.mjs +439 -438
  144. package/dist/src/self-relay/debug-allowlist.mjs +33 -33
  145. package/dist/src/self-relay/demo.mjs +37 -37
  146. package/dist/src/self-relay/device-info.mjs +27 -0
  147. package/dist/src/self-relay/device-store.mjs +92 -84
  148. package/dist/src/self-relay/diagnostics.mjs +54 -54
  149. package/dist/src/self-relay/email-accounts.mjs +183 -183
  150. package/dist/src/self-relay/file-wire.mjs +13 -13
  151. package/dist/src/self-relay/lan-authorizations.mjs +71 -42
  152. package/dist/src/self-relay/lifecycle.mjs +264 -250
  153. package/dist/src/self-relay/long-pairing.mjs +40 -40
  154. package/dist/src/self-relay/mysql-state.mjs +118 -105
  155. package/dist/src/self-relay/p2p-probe.mjs +159 -159
  156. package/dist/src/self-relay/privacy-page.mjs +26 -26
  157. package/dist/src/self-relay/public-releases.mjs +34 -0
  158. package/dist/src/self-relay/rtc-file-bridge.mjs +41 -41
  159. package/dist/src/self-relay/server.mjs +1006 -932
  160. package/dist/src/self-relay/usage-daily.mjs +55 -55
  161. package/dist/src/self-relay/usage-meter.mjs +141 -141
  162. package/dist/src/self-relay/windows-route-helper.mjs +75 -75
  163. package/dist/src/self-relay/wire.mjs +36 -36
  164. package/dist/src/server.mjs +1861 -1778
  165. package/dist/src/service-control.mjs +82 -82
  166. package/dist/src/service-doctor.mjs +110 -110
  167. package/dist/src/service-health.mjs +33 -33
  168. package/dist/src/service-install.mjs +91 -91
  169. package/dist/src/service-lifecycle.mjs +138 -138
  170. package/dist/src/service-restart.mjs +81 -81
  171. package/dist/src/shared-app-server.mjs +615 -611
  172. package/dist/src/shared-catalog.mjs +132 -132
  173. package/dist/src/shared-recovery.mjs +146 -146
  174. package/dist/src/shared-thread-stream.mjs +164 -164
  175. package/dist/src/skill-install.mjs +51 -51
  176. package/dist/src/thread-title-generation.mjs +150 -150
  177. package/dist/src/turn-model-history.mjs +47 -47
  178. package/dist/src/usage-reset.mjs +17 -17
  179. package/dist/src/workstation-downloads.mjs +120 -120
  180. package/dist/tools/rtc-route-helper.ps1 +99 -99
  181. package/dist/tools/start-rtc-route-helper.ps1 +15 -15
  182. package/dist/web/vendor/markdown-it.LICENSE.txt +22 -22
  183. package/dist/web/vendor/markdown-it.umd.min.js +13 -13
  184. package/package.json +7 -6
  185. package/tools/postinstall.mjs +127 -127
@@ -1,3 +1,3 @@
1
- import { platformModule } from './select.mjs';
2
- const adapter = await import(platformModule('user-environment'));
3
- export const { configureManagedEnvironment, clearManagedEnvironment } = adapter;
1
+ import { platformModule } from './select.mjs';
2
+ const adapter = await import(platformModule('user-environment'));
3
+ export const { configureManagedEnvironment, clearManagedEnvironment } = adapter;
@@ -1,79 +1,79 @@
1
- using System;
2
- using System.ComponentModel;
3
- using System.Runtime.InteropServices;
4
- using System.Text;
5
-
6
- // Only the three explicitly opened standard handles cross the process boundary.
7
- // In particular, inherited app-server sockets must not reach background workers.
8
- public static class IsolatedProcess {
9
- [StructLayout(LayoutKind.Sequential)] struct Security { public int length; public IntPtr descriptor; public int inherit; }
10
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Startup {
11
- public int cb; public string reserved, desktop, title;
12
- public int x,y,xSize,ySize,xCount,yCount,fill,flags; public short show,reservedSize;
13
- public IntPtr reservedBytes,input,output,error;
14
- }
15
- [StructLayout(LayoutKind.Sequential)] struct StartupEx { public Startup startup; public IntPtr attributes; }
16
- [StructLayout(LayoutKind.Sequential)] struct ProcessInfo { public IntPtr process,thread; public int pid,tid; }
17
- [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr CreateFileW(string name,uint access,uint share,ref Security security,uint disposition,uint flags,IntPtr template);
18
- [DllImport("kernel32.dll", SetLastError=true)] static extern bool InitializeProcThreadAttributeList(IntPtr list,int count,int flags,ref IntPtr size);
19
- [DllImport("kernel32.dll", SetLastError=true)] static extern bool UpdateProcThreadAttribute(IntPtr list,uint flags,IntPtr attribute,IntPtr value,IntPtr size,IntPtr previous,IntPtr returned);
20
- [DllImport("kernel32.dll")] static extern void DeleteProcThreadAttributeList(IntPtr list);
21
- [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CreateProcessW(string application,StringBuilder command,IntPtr processSecurity,IntPtr threadSecurity,bool inherit,uint flags,IntPtr environment,string cwd,ref StartupEx startup,out ProcessInfo info);
22
- [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
23
- [DllImport("kernel32.dll",CharSet=CharSet.Unicode,SetLastError=true)] static extern uint GetFinalPathNameByHandleW(IntPtr handle,StringBuilder path,uint length,uint flags);
24
- public static string ResolvePath(string path) {
25
- var security=new Security {length=Marshal.SizeOf(typeof(Security))};
26
- var handle=CreateFileW(path,0,7,ref security,3,0x02000000,IntPtr.Zero);
27
- if(handle==new IntPtr(-1)) throw new Win32Exception(Marshal.GetLastWin32Error());
28
- try {
29
- var result=new StringBuilder(32768);
30
- uint length=GetFinalPathNameByHandleW(handle,result,(uint)result.Capacity,0);
31
- if(length==0 || length>=result.Capacity) throw new Win32Exception(Marshal.GetLastWin32Error());
32
- var value=result.ToString();
33
- return value.StartsWith(@"\\?\UNC\") ? @"\\"+value.Substring(8) : value.StartsWith(@"\\?\") ? value.Substring(4) : value;
34
- } finally { CloseHandle(handle); }
35
- }
36
- static string Quote(string value) {
37
- var result=new StringBuilder("\""); int slashes=0;
38
- foreach(char c in value) {
39
- if(c=='\\') { slashes++; continue; }
40
- result.Append('\\', c=='"' ? slashes*2+1 : slashes); slashes=0; result.Append(c);
41
- }
42
- result.Append('\\',slashes*2); return result.Append('"').ToString();
43
- }
44
- static IntPtr File(string file,bool input) {
45
- var sa=new Security { length=Marshal.SizeOf(typeof(Security)), inherit=1 };
46
- // FILE_APPEND_DATA avoids truncating diagnostic history on recovery.
47
- var handle=CreateFileW(file,input?0x80000000u:4u,7,ref sa,input?3u:4u,0x80,IntPtr.Zero);
48
- if(handle==new IntPtr(-1)) throw new Win32Exception(Marshal.GetLastWin32Error());
49
- return handle;
50
- }
51
- public static int Start(string executable,string[] arguments,string stdout,string stderr,string[] environment) {
52
- IntPtr input=IntPtr.Zero,output=IntPtr.Zero,error=IntPtr.Zero,list=IntPtr.Zero,handles=IntPtr.Zero,environmentBlock=IntPtr.Zero;
53
- bool initialized=false;
54
- try {
55
- input=File("NUL",true); output=File(String.IsNullOrEmpty(stdout)?"NUL":stdout,false); error=File(String.IsNullOrEmpty(stderr)?"NUL":stderr,false);
56
- IntPtr size=IntPtr.Zero; InitializeProcThreadAttributeList(IntPtr.Zero,1,0,ref size);
57
- list=Marshal.AllocHGlobal(size);
58
- if(!InitializeProcThreadAttributeList(list,1,0,ref size)) throw new Win32Exception(Marshal.GetLastWin32Error());
59
- initialized=true; handles=Marshal.AllocHGlobal(IntPtr.Size*3);
60
- Marshal.Copy(new IntPtr[]{input,output,error},0,handles,3);
61
- if(!UpdateProcThreadAttribute(list,0,new IntPtr(0x20002),handles,new IntPtr(IntPtr.Size*3),IntPtr.Zero,IntPtr.Zero)) throw new Win32Exception(Marshal.GetLastWin32Error());
62
- var startup=new StartupEx(); startup.startup.cb=Marshal.SizeOf(typeof(StartupEx));
63
- startup.startup.flags=0x101; startup.startup.show=0;
64
- startup.startup.input=input; startup.startup.output=output; startup.startup.error=error; startup.attributes=list;
65
- var command=new StringBuilder(Quote(executable)); foreach(var argument in arguments) command.Append(' ').Append(Quote(argument));
66
- Array.Sort(environment,StringComparer.OrdinalIgnoreCase);
67
- var environmentBytes=Encoding.Unicode.GetBytes(String.Join("\0",environment)+"\0\0");
68
- environmentBlock=Marshal.AllocHGlobal(environmentBytes.Length); Marshal.Copy(environmentBytes,0,environmentBlock,environmentBytes.Length);
69
- ProcessInfo info;
70
- if(!CreateProcessW(executable,command,IntPtr.Zero,IntPtr.Zero,true,0x80410,environmentBlock,null,ref startup,out info)) throw new Win32Exception(Marshal.GetLastWin32Error());
71
- CloseHandle(info.thread); CloseHandle(info.process); return info.pid;
72
- } finally {
73
- if(initialized) DeleteProcThreadAttributeList(list);
74
- if(list!=IntPtr.Zero) Marshal.FreeHGlobal(list); if(handles!=IntPtr.Zero) Marshal.FreeHGlobal(handles);
75
- if(environmentBlock!=IntPtr.Zero) Marshal.FreeHGlobal(environmentBlock);
76
- if(input!=IntPtr.Zero) CloseHandle(input); if(output!=IntPtr.Zero) CloseHandle(output); if(error!=IntPtr.Zero) CloseHandle(error);
77
- }
78
- }
79
- }
1
+ using System;
2
+ using System.ComponentModel;
3
+ using System.Runtime.InteropServices;
4
+ using System.Text;
5
+
6
+ // Only the three explicitly opened standard handles cross the process boundary.
7
+ // In particular, inherited app-server sockets must not reach background workers.
8
+ public static class IsolatedProcess {
9
+ [StructLayout(LayoutKind.Sequential)] struct Security { public int length; public IntPtr descriptor; public int inherit; }
10
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct Startup {
11
+ public int cb; public string reserved, desktop, title;
12
+ public int x,y,xSize,ySize,xCount,yCount,fill,flags; public short show,reservedSize;
13
+ public IntPtr reservedBytes,input,output,error;
14
+ }
15
+ [StructLayout(LayoutKind.Sequential)] struct StartupEx { public Startup startup; public IntPtr attributes; }
16
+ [StructLayout(LayoutKind.Sequential)] struct ProcessInfo { public IntPtr process,thread; public int pid,tid; }
17
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr CreateFileW(string name,uint access,uint share,ref Security security,uint disposition,uint flags,IntPtr template);
18
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool InitializeProcThreadAttributeList(IntPtr list,int count,int flags,ref IntPtr size);
19
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool UpdateProcThreadAttribute(IntPtr list,uint flags,IntPtr attribute,IntPtr value,IntPtr size,IntPtr previous,IntPtr returned);
20
+ [DllImport("kernel32.dll")] static extern void DeleteProcThreadAttributeList(IntPtr list);
21
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool CreateProcessW(string application,StringBuilder command,IntPtr processSecurity,IntPtr threadSecurity,bool inherit,uint flags,IntPtr environment,string cwd,ref StartupEx startup,out ProcessInfo info);
22
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
23
+ [DllImport("kernel32.dll",CharSet=CharSet.Unicode,SetLastError=true)] static extern uint GetFinalPathNameByHandleW(IntPtr handle,StringBuilder path,uint length,uint flags);
24
+ public static string ResolvePath(string path) {
25
+ var security=new Security {length=Marshal.SizeOf(typeof(Security))};
26
+ var handle=CreateFileW(path,0,7,ref security,3,0x02000000,IntPtr.Zero);
27
+ if(handle==new IntPtr(-1)) throw new Win32Exception(Marshal.GetLastWin32Error());
28
+ try {
29
+ var result=new StringBuilder(32768);
30
+ uint length=GetFinalPathNameByHandleW(handle,result,(uint)result.Capacity,0);
31
+ if(length==0 || length>=result.Capacity) throw new Win32Exception(Marshal.GetLastWin32Error());
32
+ var value=result.ToString();
33
+ return value.StartsWith(@"\\?\UNC\") ? @"\\"+value.Substring(8) : value.StartsWith(@"\\?\") ? value.Substring(4) : value;
34
+ } finally { CloseHandle(handle); }
35
+ }
36
+ static string Quote(string value) {
37
+ var result=new StringBuilder("\""); int slashes=0;
38
+ foreach(char c in value) {
39
+ if(c=='\\') { slashes++; continue; }
40
+ result.Append('\\', c=='"' ? slashes*2+1 : slashes); slashes=0; result.Append(c);
41
+ }
42
+ result.Append('\\',slashes*2); return result.Append('"').ToString();
43
+ }
44
+ static IntPtr File(string file,bool input) {
45
+ var sa=new Security { length=Marshal.SizeOf(typeof(Security)), inherit=1 };
46
+ // FILE_APPEND_DATA avoids truncating diagnostic history on recovery.
47
+ var handle=CreateFileW(file,input?0x80000000u:4u,7,ref sa,input?3u:4u,0x80,IntPtr.Zero);
48
+ if(handle==new IntPtr(-1)) throw new Win32Exception(Marshal.GetLastWin32Error());
49
+ return handle;
50
+ }
51
+ public static int Start(string executable,string[] arguments,string stdout,string stderr,string[] environment) {
52
+ IntPtr input=IntPtr.Zero,output=IntPtr.Zero,error=IntPtr.Zero,list=IntPtr.Zero,handles=IntPtr.Zero,environmentBlock=IntPtr.Zero;
53
+ bool initialized=false;
54
+ try {
55
+ input=File("NUL",true); output=File(String.IsNullOrEmpty(stdout)?"NUL":stdout,false); error=File(String.IsNullOrEmpty(stderr)?"NUL":stderr,false);
56
+ IntPtr size=IntPtr.Zero; InitializeProcThreadAttributeList(IntPtr.Zero,1,0,ref size);
57
+ list=Marshal.AllocHGlobal(size);
58
+ if(!InitializeProcThreadAttributeList(list,1,0,ref size)) throw new Win32Exception(Marshal.GetLastWin32Error());
59
+ initialized=true; handles=Marshal.AllocHGlobal(IntPtr.Size*3);
60
+ Marshal.Copy(new IntPtr[]{input,output,error},0,handles,3);
61
+ if(!UpdateProcThreadAttribute(list,0,new IntPtr(0x20002),handles,new IntPtr(IntPtr.Size*3),IntPtr.Zero,IntPtr.Zero)) throw new Win32Exception(Marshal.GetLastWin32Error());
62
+ var startup=new StartupEx(); startup.startup.cb=Marshal.SizeOf(typeof(StartupEx));
63
+ startup.startup.flags=0x101; startup.startup.show=0;
64
+ startup.startup.input=input; startup.startup.output=output; startup.startup.error=error; startup.attributes=list;
65
+ var command=new StringBuilder(Quote(executable)); foreach(var argument in arguments) command.Append(' ').Append(Quote(argument));
66
+ Array.Sort(environment,StringComparer.OrdinalIgnoreCase);
67
+ var environmentBytes=Encoding.Unicode.GetBytes(String.Join("\0",environment)+"\0\0");
68
+ environmentBlock=Marshal.AllocHGlobal(environmentBytes.Length); Marshal.Copy(environmentBytes,0,environmentBlock,environmentBytes.Length);
69
+ ProcessInfo info;
70
+ if(!CreateProcessW(executable,command,IntPtr.Zero,IntPtr.Zero,true,0x80410,environmentBlock,null,ref startup,out info)) throw new Win32Exception(Marshal.GetLastWin32Error());
71
+ CloseHandle(info.thread); CloseHandle(info.process); return info.pid;
72
+ } finally {
73
+ if(initialized) DeleteProcThreadAttributeList(list);
74
+ if(list!=IntPtr.Zero) Marshal.FreeHGlobal(list); if(handles!=IntPtr.Zero) Marshal.FreeHGlobal(handles);
75
+ if(environmentBlock!=IntPtr.Zero) Marshal.FreeHGlobal(environmentBlock);
76
+ if(input!=IntPtr.Zero) CloseHandle(input); if(output!=IntPtr.Zero) CloseHandle(output); if(error!=IntPtr.Zero) CloseHandle(error);
77
+ }
78
+ }
79
+ }
@@ -1,48 +1,48 @@
1
- param(
2
- [Parameter(Mandatory=$true)][string]$Executable,
3
- [Parameter(Mandatory=$true)][string]$AppServerUrl
4
- )
5
- $ErrorActionPreference = 'Stop'
6
- [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false)
7
- $package = Get-AppxPackage OpenAI.Codex | Select-Object -First 1
8
- if (-not $package -or $Executable -ne (Join-Path $package.InstallLocation 'app/ChatGPT.exe')) {
9
- throw 'Desktop executable identity changed; activation stopped.'
10
- }
11
- # Packaged activation uses the user's environment, not the worker's env block.
12
- # Installation already owns and broadcasts this setting. Do not silently launch
13
- # a separate app-server if it has been removed or changed since installation.
14
- if ([Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_WS_URL', 'User') -ne $AppServerUrl) {
15
- throw 'Desktop app-server environment differs from the workstation; run relax setup to repair it.'
16
- }
17
- if ([Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_FORCE_CLI', 'User') -eq '1' -or
18
- [Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_FORCE_CLI', 'Machine') -eq '1') {
19
- throw 'CODEX_APP_SERVER_FORCE_CLI=1 prevents Desktop from connecting to the workstation.'
20
- }
21
- # Activate the registered application so Windows supplies its MSIX identity.
22
- # Never spawn ChatGPT.exe through the hidden-console broker: a bootstrap failure
23
- # can leave a windowless Electron singleton blocking subsequent taskbar launches.
24
- Add-Type -TypeDefinition @'
25
- using System;
26
- using System.Runtime.InteropServices;
27
- namespace CodeRelax {
28
- [ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
29
- interface IApplicationActivationManager {
30
- void ActivateApplication([MarshalAs(UnmanagedType.LPWStr)] string appId,
31
- [MarshalAs(UnmanagedType.LPWStr)] string arguments, uint options, out uint processId);
32
- void ActivateForFile([MarshalAs(UnmanagedType.LPWStr)] string appId, IntPtr items,
33
- [MarshalAs(UnmanagedType.LPWStr)] string verb, out uint processId);
34
- void ActivateForProtocol([MarshalAs(UnmanagedType.LPWStr)] string appId, IntPtr items, out uint processId);
35
- }
36
- public static class DesktopActivation {
37
- public static uint Activate(string appId) {
38
- object instance = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")));
39
- try {
40
- uint processId;
41
- ((IApplicationActivationManager)instance).ActivateApplication(appId, "", 2, out processId);
42
- return processId;
43
- } finally { Marshal.ReleaseComObject(instance); }
44
- }
45
- }
46
- }
47
- '@
48
- [CodeRelax.DesktopActivation]::Activate($package.PackageFamilyName + '!App')
1
+ param(
2
+ [Parameter(Mandatory=$true)][string]$Executable,
3
+ [Parameter(Mandatory=$true)][string]$AppServerUrl
4
+ )
5
+ $ErrorActionPreference = 'Stop'
6
+ [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false)
7
+ $package = Get-AppxPackage OpenAI.Codex | Select-Object -First 1
8
+ if (-not $package -or $Executable -ne (Join-Path $package.InstallLocation 'app/ChatGPT.exe')) {
9
+ throw 'Desktop executable identity changed; activation stopped.'
10
+ }
11
+ # Packaged activation uses the user's environment, not the worker's env block.
12
+ # Installation already owns and broadcasts this setting. Do not silently launch
13
+ # a separate app-server if it has been removed or changed since installation.
14
+ if ([Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_WS_URL', 'User') -ne $AppServerUrl) {
15
+ throw 'Desktop app-server environment differs from the workstation; run relax setup to repair it.'
16
+ }
17
+ if ([Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_FORCE_CLI', 'User') -eq '1' -or
18
+ [Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_FORCE_CLI', 'Machine') -eq '1') {
19
+ throw 'CODEX_APP_SERVER_FORCE_CLI=1 prevents Desktop from connecting to the workstation.'
20
+ }
21
+ # Activate the registered application so Windows supplies its MSIX identity.
22
+ # Never spawn ChatGPT.exe through the hidden-console broker: a bootstrap failure
23
+ # can leave a windowless Electron singleton blocking subsequent taskbar launches.
24
+ Add-Type -TypeDefinition @'
25
+ using System;
26
+ using System.Runtime.InteropServices;
27
+ namespace CodeRelax {
28
+ [ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
29
+ interface IApplicationActivationManager {
30
+ void ActivateApplication([MarshalAs(UnmanagedType.LPWStr)] string appId,
31
+ [MarshalAs(UnmanagedType.LPWStr)] string arguments, uint options, out uint processId);
32
+ void ActivateForFile([MarshalAs(UnmanagedType.LPWStr)] string appId, IntPtr items,
33
+ [MarshalAs(UnmanagedType.LPWStr)] string verb, out uint processId);
34
+ void ActivateForProtocol([MarshalAs(UnmanagedType.LPWStr)] string appId, IntPtr items, out uint processId);
35
+ }
36
+ public static class DesktopActivation {
37
+ public static uint Activate(string appId) {
38
+ object instance = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")));
39
+ try {
40
+ uint processId;
41
+ ((IApplicationActivationManager)instance).ActivateApplication(appId, "", 2, out processId);
42
+ return processId;
43
+ } finally { Marshal.ReleaseComObject(instance); }
44
+ }
45
+ }
46
+ }
47
+ '@
48
+ [CodeRelax.DesktopActivation]::Activate($package.PackageFamilyName + '!App')
@@ -1,30 +1,30 @@
1
- import { spawn } from 'node:child_process';
2
- import { fileURLToPath } from 'node:url';
3
- import path from 'node:path';
4
-
5
- export function startWindowsProcess(executable, args, environment, logs = []) {
6
- return new Promise((resolve, reject) => {
7
- const powershell = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32/WindowsPowerShell/v1.0/powershell.exe');
8
- const helperEnvironment = {};
9
- for (const name of ['SystemRoot', 'windir', 'LOCALAPPDATA', 'USERPROFILE', 'TEMP', 'TMP', 'PSModulePath']) {
10
- const key = Object.keys(process.env).find(item => item.toLowerCase() === name.toLowerCase());
11
- if (key) helperEnvironment[key] = process.env[key];
12
- }
13
- const helper = spawn(powershell, ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File',
14
- fileURLToPath(new URL('./start-hidden-console.ps1', import.meta.url))], {
15
- windowsHide: true, env: helperEnvironment, stdio: ['pipe', 'pipe', 'pipe'],
16
- });
17
- let output = '', error = '';
18
- helper.stdout.setEncoding('utf8').on('data', chunk => { output += chunk; });
19
- helper.stderr.setEncoding('utf8').on('data', chunk => { error += chunk; });
20
- helper.once('error', reject); helper.stdin.on('error', reject);
21
- helper.once('exit', code => {
22
- helper.stdout.destroy(); helper.stderr.destroy(); helper.stdin.destroy();
23
- if (code !== 0) return reject(new Error(error.trim() || `后台启动失败 (${code})`));
24
- const pid = Number(output.trim());
25
- if (!Number.isSafeInteger(pid) || pid <= 0) return reject(new Error('后台启动未返回有效 PID'));
26
- resolve(pid);
27
- });
28
- helper.stdin.end(JSON.stringify({ brokerExecutable: process.execPath, executable, args, logs, environment }));
29
- });
30
- }
1
+ import { spawn } from 'node:child_process';
2
+ import { fileURLToPath } from 'node:url';
3
+ import path from 'node:path';
4
+
5
+ export function startWindowsProcess(executable, args, environment, logs = []) {
6
+ return new Promise((resolve, reject) => {
7
+ const powershell = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32/WindowsPowerShell/v1.0/powershell.exe');
8
+ const helperEnvironment = {};
9
+ for (const name of ['SystemRoot', 'windir', 'LOCALAPPDATA', 'USERPROFILE', 'TEMP', 'TMP', 'PSModulePath']) {
10
+ const key = Object.keys(process.env).find(item => item.toLowerCase() === name.toLowerCase());
11
+ if (key) helperEnvironment[key] = process.env[key];
12
+ }
13
+ const helper = spawn(powershell, ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File',
14
+ fileURLToPath(new URL('./start-hidden-console.ps1', import.meta.url))], {
15
+ windowsHide: true, env: helperEnvironment, stdio: ['pipe', 'pipe', 'pipe'],
16
+ });
17
+ let output = '', error = '';
18
+ helper.stdout.setEncoding('utf8').on('data', chunk => { output += chunk; });
19
+ helper.stderr.setEncoding('utf8').on('data', chunk => { error += chunk; });
20
+ helper.once('error', reject); helper.stdin.on('error', reject);
21
+ helper.once('exit', code => {
22
+ helper.stdout.destroy(); helper.stderr.destroy(); helper.stdin.destroy();
23
+ if (code !== 0) return reject(new Error(error.trim() || `后台启动失败 (${code})`));
24
+ const pid = Number(output.trim());
25
+ if (!Number.isSafeInteger(pid) || pid <= 0) return reject(new Error('后台启动未返回有效 PID'));
26
+ resolve(pid);
27
+ });
28
+ helper.stdin.end(JSON.stringify({ brokerExecutable: process.execPath, executable, args, logs, environment }));
29
+ });
30
+ }