@sipher.dev/connector-win32-x64 0.6.18 → 0.6.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.
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/agents-connector.exe
3
- size: 93402624 bytes
4
- sha256: 8c2171e4b4e25a9adf00d2f33f3d349d9e3f2aff193c5b54da800854adb0da10
3
+ size: 93425152 bytes
4
+ sha256: 02f6236c070b296004bbdfb42ac7d1be7fbc5709242a9633942fb788b7413d8c
@@ -0,0 +1,381 @@
1
+ $ErrorActionPreference = 'Stop'
2
+ Add-Type -AssemblyName System.Windows.Forms
3
+ Add-Type -AssemblyName System.Drawing
4
+ Add-Type -ReferencedAssemblies System.Windows.Forms, System.Drawing -TypeDefinition @'
5
+ using System;
6
+ using System.Collections.Generic;
7
+ using System.Diagnostics;
8
+ using System.Drawing;
9
+ using System.Runtime.InteropServices;
10
+ using System.Text;
11
+ using System.Threading;
12
+ using System.Windows.Forms;
13
+
14
+ internal static class IndicatorNative
15
+ {
16
+ [StructLayout(LayoutKind.Sequential)]
17
+ private struct UserObjectFlags
18
+ {
19
+ public int Inherit;
20
+ public int Reserved;
21
+ public uint Flags;
22
+ }
23
+
24
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
25
+ private struct OsVersion
26
+ {
27
+ public uint Size;
28
+ public uint Major;
29
+ public uint Minor;
30
+ public uint Build;
31
+ public uint Platform;
32
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
33
+ public string ServicePack;
34
+ }
35
+
36
+ [DllImport("user32.dll")]
37
+ private static extern IntPtr GetProcessWindowStation();
38
+ [DllImport("user32.dll", EntryPoint = "GetUserObjectInformationW")]
39
+ private static extern bool GetStationFlags(IntPtr station, int index, out UserObjectFlags flags, uint size, out uint needed);
40
+ [DllImport("user32.dll", CharSet = CharSet.Unicode)]
41
+ private static extern bool GetUserObjectInformation(IntPtr handle, int index, StringBuilder value, uint size, out uint needed);
42
+ [DllImport("user32.dll")]
43
+ private static extern IntPtr OpenInputDesktop(uint flags, bool inherit, uint access);
44
+ [DllImport("user32.dll")]
45
+ private static extern bool CloseDesktop(IntPtr desktop);
46
+ [DllImport("user32.dll")]
47
+ private static extern IntPtr GetThreadDesktop(uint threadId);
48
+ [DllImport("kernel32.dll")]
49
+ private static extern uint GetCurrentThreadId();
50
+ [DllImport("ntdll.dll", CharSet = CharSet.Unicode)]
51
+ private static extern int RtlGetVersion(ref OsVersion version);
52
+ [DllImport("user32.dll")]
53
+ private static extern bool SetWindowDisplayAffinity(IntPtr window, uint affinity);
54
+ [DllImport("user32.dll")]
55
+ private static extern bool SetWindowPos(IntPtr window, IntPtr after, int left, int top, int width, int height, uint flags);
56
+ [DllImport("user32.dll")]
57
+ private static extern bool GetWindowDisplayAffinity(IntPtr window, out uint affinity);
58
+ [DllImport("user32.dll")]
59
+ internal static extern bool SetLayeredWindowAttributes(IntPtr window, uint color, byte alpha, uint flags);
60
+ [DllImport("user32.dll")]
61
+ private static extern bool SetProcessDPIAware();
62
+ [DllImport("shcore.dll")]
63
+ private static extern int SetProcessDpiAwareness(int awareness);
64
+ [DllImport("user32.dll")]
65
+ private static extern IntPtr MonitorFromPoint(Point point, uint flags);
66
+ [DllImport("shcore.dll")]
67
+ private static extern int GetDpiForMonitor(IntPtr monitor, int type, out uint horizontal, out uint vertical);
68
+
69
+ internal static bool InteractiveStation()
70
+ {
71
+ UserObjectFlags flags;
72
+ uint needed;
73
+ return Process.GetCurrentProcess().SessionId != 0 &&
74
+ GetStationFlags(GetProcessWindowStation(), 1, out flags, (uint)Marshal.SizeOf(typeof(UserObjectFlags)), out needed) &&
75
+ (flags.Flags & 1) != 0;
76
+ }
77
+
78
+ internal static bool InputDesktop()
79
+ {
80
+ IntPtr input = OpenInputDesktop(0, false, 1);
81
+ if (input == IntPtr.Zero) return false;
82
+ try
83
+ {
84
+ uint needed;
85
+ StringBuilder inputName = new StringBuilder(256);
86
+ StringBuilder ownName = new StringBuilder(256);
87
+ return GetUserObjectInformation(input, 2, inputName, 512, out needed) &&
88
+ GetUserObjectInformation(GetThreadDesktop(GetCurrentThreadId()), 2, ownName, 512, out needed) &&
89
+ inputName.ToString() == "Default" && ownName.ToString() == inputName.ToString();
90
+ }
91
+ finally { CloseDesktop(input); }
92
+ }
93
+
94
+ internal static bool CaptureExclusionAvailable()
95
+ {
96
+ OsVersion version = new OsVersion();
97
+ version.Size = (uint)Marshal.SizeOf(typeof(OsVersion));
98
+ return RtlGetVersion(ref version) == 0 && version.Build >= 19041;
99
+ }
100
+
101
+ internal static bool Exclude(IntPtr window)
102
+ {
103
+ uint affinity;
104
+ return CaptureExclusionAvailable() && SetWindowDisplayAffinity(window, 0x11) &&
105
+ GetWindowDisplayAffinity(window, out affinity) && affinity == 0x11;
106
+ }
107
+
108
+ internal static void SetBounds(IntPtr window, Rectangle bounds)
109
+ {
110
+ if (!SetWindowPos(window, IntPtr.Zero, bounds.Left, bounds.Top, bounds.Width, bounds.Height, 0x14))
111
+ throw new InvalidOperationException("Cannot size machine indicator.");
112
+ }
113
+
114
+ internal static void EnableDpi()
115
+ {
116
+ try { SetProcessDpiAwareness(2); }
117
+ catch (DllNotFoundException) { SetProcessDPIAware(); }
118
+ catch (EntryPointNotFoundException) { SetProcessDPIAware(); }
119
+ }
120
+
121
+ internal static float Scale(Screen screen)
122
+ {
123
+ try
124
+ {
125
+ uint horizontal, vertical;
126
+ if (GetDpiForMonitor(MonitorFromPoint(screen.Bounds.Location, 2), 0, out horizontal, out vertical) == 0)
127
+ return Math.Max(1, horizontal / 96f);
128
+ }
129
+ catch (DllNotFoundException) { }
130
+ catch (EntryPointNotFoundException) { }
131
+ return 1;
132
+ }
133
+ }
134
+
135
+ internal sealed class IndicatorWindow : Form
136
+ {
137
+ internal bool CaptureExcluded;
138
+ private Rectangle bounds;
139
+ private readonly bool label;
140
+ private readonly float scale;
141
+ private string state;
142
+
143
+ internal IndicatorWindow(Rectangle bounds, bool label, float scale, string state)
144
+ {
145
+ this.label = label;
146
+ this.scale = scale;
147
+ this.state = state;
148
+ this.bounds = bounds;
149
+ AutoScaleMode = AutoScaleMode.None;
150
+ FormBorderStyle = FormBorderStyle.None;
151
+ ShowInTaskbar = false;
152
+ StartPosition = FormStartPosition.Manual;
153
+ Bounds = bounds;
154
+ TopMost = true;
155
+ DoubleBuffered = true;
156
+ }
157
+
158
+ protected override bool ShowWithoutActivation { get { return true; } }
159
+
160
+ protected override CreateParams CreateParams
161
+ {
162
+ get
163
+ {
164
+ CreateParams parameters = base.CreateParams;
165
+ parameters.ExStyle |= 0x080800A8;
166
+ return parameters;
167
+ }
168
+ }
169
+
170
+ protected override void OnHandleCreated(EventArgs args)
171
+ {
172
+ base.OnHandleCreated(args);
173
+ if (!IndicatorNative.SetLayeredWindowAttributes(Handle, 0, 255, 2))
174
+ throw new InvalidOperationException("Cannot make machine indicator click-through.");
175
+ CaptureExcluded = IndicatorNative.Exclude(Handle);
176
+ if (!CaptureExcluded)
177
+ bounds.Size = new Size(Math.Min(bounds.Width, 240), Math.Min(bounds.Height, 26));
178
+ IndicatorNative.SetBounds(Handle, bounds);
179
+ }
180
+
181
+ protected override void OnShown(EventArgs args)
182
+ {
183
+ base.OnShown(args);
184
+ IndicatorNative.SetBounds(Handle, bounds);
185
+ }
186
+
187
+ protected override void WndProc(ref Message message)
188
+ {
189
+ if (message.Msg == 0x84) { message.Result = new IntPtr(-1); return; }
190
+ if (message.Msg == 0x21) { message.Result = new IntPtr(3); return; }
191
+ base.WndProc(ref message);
192
+ }
193
+
194
+ internal void SetState(string next)
195
+ {
196
+ state = next;
197
+ Invalidate();
198
+ }
199
+
200
+ protected override void OnPaint(PaintEventArgs args)
201
+ {
202
+ Color accent = state == "held" ? Color.FromArgb(218, 53, 53) : Color.FromArgb(211, 142, 18);
203
+ args.Graphics.Clear(accent);
204
+ if (!label) return;
205
+ using (Font font = new Font("Segoe UI", Math.Min(16, 12 * scale), FontStyle.Bold, GraphicsUnit.Pixel))
206
+ {
207
+ TextRenderer.DrawText(args.Graphics, state == "held" ? "Agent working" : "Agents may start work",
208
+ font, ClientRectangle, Color.White,
209
+ TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine);
210
+ }
211
+ }
212
+ }
213
+
214
+ public sealed class VesperMachineIndicator : ApplicationContext
215
+ {
216
+ private readonly object gate = new object();
217
+ private string state = "hidden";
218
+ private long received = Stopwatch.GetTimestamp();
219
+ private bool inputClosed;
220
+ private string displayed = "hidden";
221
+ private string layout = "";
222
+ private bool fallback;
223
+ private bool fallbackLogged;
224
+ private readonly List<IndicatorWindow> windows = new List<IndicatorWindow>();
225
+ private readonly System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
226
+
227
+ private VesperMachineIndicator()
228
+ {
229
+ Thread reader = new Thread(ReadInput);
230
+ reader.IsBackground = true;
231
+ reader.Start();
232
+ timer.Interval = 250;
233
+ timer.Tick += Tick;
234
+ timer.Start();
235
+ }
236
+
237
+ private void ReadInput()
238
+ {
239
+ try
240
+ {
241
+ char[] line = new char[11];
242
+ int length = 0;
243
+ for (;;)
244
+ {
245
+ int value = Console.In.Read();
246
+ if (value < 0) break;
247
+ if (value == '\n')
248
+ {
249
+ int count = length > 0 && line[length - 1] == '\r' ? length - 1 : length;
250
+ string next = new string(line, 0, count);
251
+ if (next != "held" && next != "windowOpen" && next != "hidden")
252
+ throw new InvalidOperationException("Invalid machine indicator state.");
253
+ lock (gate) { state = next; received = Stopwatch.GetTimestamp(); }
254
+ length = 0;
255
+ }
256
+ else
257
+ {
258
+ if (length == line.Length) throw new InvalidOperationException("Machine indicator state too long.");
259
+ line[length++] = (char)value;
260
+ }
261
+ }
262
+ }
263
+ catch (Exception error) { Console.Error.WriteLine(error.Message); }
264
+ finally { lock (gate) { inputClosed = true; } }
265
+ }
266
+
267
+ private void Tick(object sender, EventArgs args)
268
+ {
269
+ string next;
270
+ bool closed;
271
+ lock (gate)
272
+ {
273
+ closed = inputClosed;
274
+ next = (Stopwatch.GetTimestamp() - received) / (double)Stopwatch.Frequency >= 150 ? "hidden" : state;
275
+ }
276
+ if (closed) { ExitThread(); return; }
277
+ if (!IndicatorNative.InputDesktop()) next = "hidden";
278
+ if (next == "hidden")
279
+ {
280
+ ClearWindows();
281
+ displayed = "hidden";
282
+ return;
283
+ }
284
+ Screen[] screens = Screen.AllScreens;
285
+ StringBuilder signature = new StringBuilder();
286
+ foreach (Screen screen in screens)
287
+ signature.Append(screen.DeviceName).Append(screen.Bounds).Append(screen.WorkingArea).Append(IndicatorNative.Scale(screen));
288
+ bool failed = !fallback && windows.Exists(delegate(IndicatorWindow window) { return !window.CaptureExcluded; });
289
+ if (windows.Count == 0 || signature.ToString() != layout || failed)
290
+ {
291
+ ClearWindows();
292
+ layout = signature.ToString();
293
+ fallback = !IndicatorNative.CaptureExclusionAvailable() || failed;
294
+ if (!fallback)
295
+ {
296
+ foreach (Screen screen in screens)
297
+ {
298
+ if (CreateEdges(screen, next)) continue;
299
+ fallback = true;
300
+ ClearWindows();
301
+ break;
302
+ }
303
+ }
304
+ if (fallback)
305
+ {
306
+ if (!fallbackLogged)
307
+ {
308
+ Console.Error.WriteLine("Machine indicator capture exclusion unavailable; using tiny 240x26 markers (visible in captures).");
309
+ fallbackLogged = true;
310
+ }
311
+ foreach (Screen screen in screens)
312
+ {
313
+ Rectangle bounds = screen.Bounds;
314
+ IndicatorWindow tiny = new IndicatorWindow(new Rectangle(bounds.Left, bounds.Top,
315
+ Math.Min(bounds.Width, 240), Math.Min(bounds.Height, 26)), true, 1, next);
316
+ windows.Add(tiny);
317
+ tiny.Show();
318
+ }
319
+ }
320
+ }
321
+ if (next != displayed)
322
+ foreach (IndicatorWindow window in windows) window.SetState(next);
323
+ displayed = next;
324
+ }
325
+
326
+ private bool CreateEdges(Screen screen, string next)
327
+ {
328
+ float scale = IndicatorNative.Scale(screen);
329
+ Rectangle bounds = screen.Bounds;
330
+ int edge = Math.Max(2, (int)(3 * scale));
331
+ Rectangle[] edges = {
332
+ new Rectangle(bounds.Left, bounds.Top, bounds.Width, edge),
333
+ new Rectangle(bounds.Left, bounds.Bottom - edge, bounds.Width, edge),
334
+ new Rectangle(bounds.Left, bounds.Top + edge, edge, Math.Max(1, bounds.Height - edge * 2)),
335
+ new Rectangle(bounds.Right - edge, bounds.Top + edge, edge, Math.Max(1, bounds.Height - edge * 2)),
336
+ new Rectangle(bounds.Left + edge, bounds.Top + edge, Math.Min(320, (int)(240 * scale)), Math.Min(36, (int)(26 * scale)))
337
+ };
338
+ int index = 0;
339
+ foreach (Rectangle rectangle in edges)
340
+ {
341
+ IndicatorWindow window = new IndicatorWindow(rectangle, index++ == 4, scale, next);
342
+ windows.Add(window);
343
+ IntPtr handle = window.Handle;
344
+ if (!window.CaptureExcluded) return false;
345
+ }
346
+ foreach (IndicatorWindow window in windows)
347
+ if (!window.Visible) window.Show();
348
+ return true;
349
+ }
350
+
351
+ private void ClearWindows()
352
+ {
353
+ foreach (IndicatorWindow window in windows) window.Dispose();
354
+ windows.Clear();
355
+ }
356
+
357
+ protected override void ExitThreadCore()
358
+ {
359
+ timer.Stop();
360
+ ClearWindows();
361
+ base.ExitThreadCore();
362
+ }
363
+
364
+ protected override void Dispose(bool disposing)
365
+ {
366
+ if (disposing) { timer.Dispose(); ClearWindows(); }
367
+ base.Dispose(disposing);
368
+ }
369
+
370
+ public static void Run()
371
+ {
372
+ if (!IndicatorNative.InteractiveStation())
373
+ throw new InvalidOperationException("Machine indicator requires an interactive window station outside session 0.");
374
+ IndicatorNative.EnableDpi();
375
+ Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
376
+ using (VesperMachineIndicator indicator = new VesperMachineIndicator())
377
+ Application.Run(indicator);
378
+ }
379
+ }
380
+ '@
381
+ [VesperMachineIndicator]::Run()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sipher.dev/connector-win32-x64",
3
- "version": "0.6.18",
3
+ "version": "0.6.20",
4
4
  "description": "Internal self-contained Vesper Machine connector for win32/x64.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1 +1 @@
1
- {"schemaVersion":1,"releaseId":"1aa68774-9ead-4df1-8321-b6199c044565","runtimeVersion":"0.6.18","bunVersion":"1.4.0","packageName":"@sipher.dev/connector-win32-x64","platform":"win32","arch":"x64","protocol":{"min":3,"max":3},"rescue":{"min":1,"max":1},"launcherSchemaVersion":2,"executable":"bin/agents-connector.exe","files":[{"path":"bin/agents-connector.exe","type":"file","size":93402624,"mode":493,"sha256":"8c2171e4b4e25a9adf00d2f33f3d349d9e3f2aff193c5b54da800854adb0da10"},{"path":"package.json","type":"file","size":415,"mode":420,"sha256":"ad4d2eaef85cc83741b4b205f2b2d22e320f4b1689882ebaa0cc0f40a7bb99b1"},{"path":"release-trust-anchor.json","type":"file","size":420,"mode":420,"sha256":"d088185aa1dc8fef0cefa1bdb9b8a6588318ce6b26918c8f73cc467166111da9"}]}
1
+ {"schemaVersion":1,"releaseId":"633a2ce5-27ef-4bab-bda2-76ada3511af5","runtimeVersion":"0.6.20","bunVersion":"1.4.0","packageName":"@sipher.dev/connector-win32-x64","platform":"win32","arch":"x64","protocol":{"min":3,"max":3},"rescue":{"min":1,"max":1},"launcherSchemaVersion":2,"executable":"bin/agents-connector.exe","files":[{"path":"bin/agents-connector.exe","type":"file","size":93425152,"mode":493,"sha256":"02f6236c070b296004bbdfb42ac7d1be7fbc5709242a9633942fb788b7413d8c"},{"path":"bin/machine-indicator.ps1","type":"file","size":14795,"mode":420,"sha256":"cb15c59a59a62e2f0b87a85d0d2aeb7415d9d05c33795d0cc46a8170a2b13797"},{"path":"package.json","type":"file","size":415,"mode":420,"sha256":"a029f9df185cd560fed5dfe771e8752a9ab0c186894b744d90634b1ac71e911e"},{"path":"release-trust-anchor.json","type":"file","size":420,"mode":420,"sha256":"931a02789cfb4bbf38d4a8237245578af7e49f13b429fa4dfdd23950bc1ed852"}]}
@@ -1 +1 @@
1
- z+ol+IkKTLerxoKc72tcF+iC74p9cPKJZ6JvHGopOhebpaZ8fKGs++fQi4LjLEHQmLGvtlaiRe5qVYYG0RzvAg==
1
+ mIZZGF/7qlJK1lm74KbqFzpk+Qxh/Ptw1EmPq49DMMpYB2ENP3pUe05DKIGBnW4osBN5BaNP1ZvFPwBZIBpiAg==
@@ -4,8 +4,8 @@
4
4
  "npmRegistryOrigin": "https://registry.npmjs.org",
5
5
  "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAOjoSJrN1tu1cMZp/biuSMAdqsIGshWkyttGYtlmcDSs=\n-----END PUBLIC KEY-----\n",
6
6
  "latest": {
7
- "sequence": 38,
8
- "indexVersion": "0.6.17",
9
- "digest": "617f5617025c9066dedb9e03f744cefec06fc05c12f93432df09084845168639"
7
+ "sequence": 40,
8
+ "indexVersion": "0.6.19",
9
+ "digest": "9b50c01ab82f895620f3b181655b4b935d14e188e0e75666275a07e2c337b6e7"
10
10
  }
11
11
  }