zames_pro 2.9.0 → 2.9.1

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.
@@ -202,25 +202,25 @@ export function isWsl() {
202
202
  catch { }
203
203
  return false;
204
204
  }
205
- // PowerShell one-liner: write the clipboard image as raw PNG bytes to stdout.
206
- const PS_GET_IMAGE = 'Add-Type -AssemblyName System.Windows.Forms,System.Drawing; ' +
207
- '$img=[System.Windows.Forms.Clipboard]::GetImage(); ' +
208
- 'if($img){$ms=New-Object System.IO.MemoryStream; ' +
209
- '$img.Save($ms,[System.Drawing.Imaging.ImageFormat]::Png); ' +
210
- '[Console]::OpenStandardOutput().Write($ms.ToArray(),0,$ms.Length)}';
205
+ // PowerShell image grabber, embedded as a UTF-16LE base64 script and run
206
+ // via powershell.exe -EncodedCommand: it saves the clipboard image to a
207
+ // Windows temp .png and prints the Windows path; we read it from WSL.
208
+ const PS_IMAGE_ENCODED = 'QQBkAGQALQBUAHkAcABlACAALQBBAHMAcwBlAG0AYgBsAHkATgBhAG0AZQAgAFMAeQBzAHQAZQBtAC4AVwBpAG4AZABvAHcAcwAuAEYAbwByAG0AcwAsAFMAeQBzAHQAZQBtAC4ARAByAGEAdwBpAG4AZwAKACQAaQBtAGcAPQBbAFMAeQBzAHQAZQBtAC4AVwBpAG4AZABvAHcAcwAuAEYAbwByAG0AcwAuAEMAbABpAHAAYgBvAGEAcgBkAF0AOgA6AEcAZQB0AEkAbQBhAGcAZQAoACkACgBpAGYAKAAkAGkAbQBnACkAewAkAHAAPQBKAG8AaQBuAC0AUABhAHQAaAAgACQAZQBuAHYAOgBUAEUATQBQACAAKAAiAHoAYQBtAGUAcwAtAGMAbABpAHAALQAiACsAWwBHAHUAaQBkAF0AOgA6AE4AZQB3AEcAdQBpAGQAKAApAC4AVABvAFMAdAByAGkAbgBnACgAKQArACIALgBwAG4AZwAiACkAOwAkAGkAbQBnAC4AUwBhAHYAZQAoACQAcAAsAFsAUwB5AHMAdABlAG0ALgBEAHIAYQB3AGkAbgBnAC4ASQBtAGEAZwBpAG4AZwAuAEkAbQBhAGcAZQBGAG8AcgBtAGEAdABdADoAOgBQAG4AZwApADsAVwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAkAHAAfQAKAA==';
211
209
  // PowerShell one-liner: write the clipboard file paths (CF_HDROP) to stdout.
212
210
  const PS_GET_FILE_DROP = 'Add-Type -AssemblyName System.Windows.Forms; ' +
213
211
  '$d=[System.Windows.Forms.Clipboard]::GetDataObject(); ' +
214
212
  'if($d -and $d.GetDataPresent([System.Windows.Forms.DataFormats]::FileDrop)){' +
215
213
  '$f=$d.GetData([System.Windows.Forms.DataFormats]::FileDrop); $f -join [Environment]::NewLine}';
216
- export function readClipboardImageDetailed() {
214
+ export async function readClipboardImageDetailed() {
217
215
  if (process.platform === 'linux' || process.platform === 'freebsd' || process.platform === 'openbsd') {
218
216
  const wayland = process.env.WAYLAND_DISPLAY;
219
217
  const x11 = process.env.DISPLAY;
220
218
  const attempts = [];
221
219
  // On WSL the Windows clipboard is what the user copies into — read it first.
222
220
  if (isWsl()) {
223
- attempts.push({ bin: 'powershell.exe', args: ['-NoProfile', '-NonInteractive', '-Command', PS_GET_IMAGE], via: 'powershell.exe' });
221
+ const win = await readWindowsClipboardImage();
222
+ if (win)
223
+ return { data: win, via: 'powershell.exe' };
224
224
  }
225
225
  if (wayland || !x11)
226
226
  attempts.push({ bin: 'wl-paste', args: ['--type', 'image/png', '--no-newline'], via: 'wl-paste' });
@@ -261,8 +261,8 @@ export function readClipboardImageDetailed() {
261
261
  return { data: null, via: 'unsupported-platform' };
262
262
  }
263
263
  // Backwards-compatible wrapper used elsewhere.
264
- export function readClipboardImage() {
265
- return readClipboardImageDetailed().data;
264
+ export async function readClipboardImage() {
265
+ return (await readClipboardImageDetailed()).data;
266
266
  }
267
267
  function tryCommand(bin, args) {
268
268
  try {
@@ -303,7 +303,7 @@ export async function findFileByName(workdir, name) {
303
303
  export function readWindowsClipboardFiles() {
304
304
  if (!isWsl())
305
305
  return [];
306
- const out = tryCommand('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', PS_GET_FILE_DROP]);
306
+ const out = tryCommand('powershell.exe', ['-STA', '-NoProfile', '-NonInteractive', '-Command', PS_GET_FILE_DROP]);
307
307
  if (!out)
308
308
  return [];
309
309
  const text = out.toString('utf-8');
@@ -330,3 +330,23 @@ export function winPathToWsl(winPath) {
330
330
  const rest = p.slice(3).split('\\').join('/');
331
331
  return '/mnt/' + drive + '/' + rest;
332
332
  }
333
+ // Run the embedded PowerShell script and return the clipboard image bytes.
334
+ export async function readWindowsClipboardImage() {
335
+ if (!isWsl())
336
+ return null;
337
+ const out = tryCommand('powershell.exe', ['-STA', '-NoProfile', '-NonInteractive', '-EncodedCommand', PS_IMAGE_ENCODED]);
338
+ if (!out)
339
+ return null;
340
+ const first = out.toString('utf-8').trim().split(String.fromCharCode(10))[0].trim();
341
+ if (!first)
342
+ return null;
343
+ const wslPath = winPathToWsl(first);
344
+ if (!wslPath)
345
+ return null;
346
+ try {
347
+ return await fs.readFile(wslPath);
348
+ }
349
+ catch {
350
+ return null;
351
+ }
352
+ }
package/dist/index.js CHANGED
@@ -995,7 +995,7 @@ async function main() {
995
995
  return att;
996
996
  };
997
997
  ed.onClipboard = async () => {
998
- const res = readClipboardImageDetailed();
998
+ const res = await readClipboardImageDetailed();
999
999
  if (!res.data || !res.data.length) {
1000
1000
  // On WSL the user may have copied a FILE in Windows (not an image):
1001
1001
  // the Windows clipboard holds its path - attach it directly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zames_pro",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Terminal coding agent over chat.deepseek.com via Playwright",
5
5
  "type": "module",
6
6
  "bin": {