@hasna/machines 0.0.6 → 0.0.8

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.
package/dist/cli/index.js CHANGED
@@ -18112,6 +18112,12 @@ function jsonResponse(response, status, data) {
18112
18112
  response.end(JSON.stringify(data));
18113
18113
  }
18114
18114
  var currentContentHash = null;
18115
+ function getCurrentContentHash() {
18116
+ return currentContentHash;
18117
+ }
18118
+ function setCurrentContentHash(hash) {
18119
+ currentContentHash = hash;
18120
+ }
18115
18121
  function startClipboardServer(options = {}) {
18116
18122
  const config = options.config || readClipboardConfig();
18117
18123
  const port = options.port || config.port;
@@ -18219,15 +18225,32 @@ function hasDisplayServer() {
18219
18225
  const wayland = process.env["WAYLAND_DISPLAY"] || "";
18220
18226
  if (display || wayland)
18221
18227
  return true;
18222
- try {
18223
- const result = Bun.spawnSync(["wl-paste", "--no-newline"], { stdout: "pipe", stderr: "pipe", env: process.env, timeout: 2000 });
18224
- if (result.exitCode === 0) {
18225
- const output = result.stdout.toString("utf8");
18226
- if (/\x1b\]52;/.test(output))
18227
- return false;
18228
- return output.length > 0;
18229
- }
18230
- } catch {}
18228
+ if (process.platform === "darwin")
18229
+ return true;
18230
+ if (process.platform === "linux") {
18231
+ try {
18232
+ const result = Bun.spawnSync(["loginctl", "list-sessions", "--no-legend"], { stdout: "pipe", stderr: "pipe", env: process.env, timeout: 2000 });
18233
+ if (result.exitCode === 0) {
18234
+ const sessions = result.stdout.toString("utf8").trim();
18235
+ if (sessions) {
18236
+ for (const line of sessions.split(`
18237
+ `)) {
18238
+ const sessionId = line.trim().split(/\s+/)[0];
18239
+ if (sessionId) {
18240
+ const typeResult = Bun.spawnSync(["loginctl", "show-session", sessionId, "-p", "Type", "--value"], { stdout: "pipe", stderr: "pipe", env: process.env, timeout: 2000 });
18241
+ if (typeResult.exitCode === 0) {
18242
+ const sessionType = typeResult.stdout.toString("utf8").trim();
18243
+ if (sessionType === "wayland" || sessionType === "x11") {
18244
+ return true;
18245
+ }
18246
+ }
18247
+ }
18248
+ }
18249
+ }
18250
+ }
18251
+ } catch {}
18252
+ return false;
18253
+ }
18231
18254
  return false;
18232
18255
  }
18233
18256
  function computeHash2(content) {
@@ -18276,7 +18299,6 @@ function startClipboardDaemon(port) {
18276
18299
  console.log(`clipboard daemon started on port ${daemonPort} (pid ${process.pid})`);
18277
18300
  writePid(process.pid);
18278
18301
  });
18279
- let lastHash = "";
18280
18302
  const secret = loadSharedSecret2();
18281
18303
  const machineId = process.env["HASNA_MACHINES_MACHINE_ID"] || "unknown";
18282
18304
  const hasDisplay = hasDisplayServer();
@@ -18290,9 +18312,10 @@ function startClipboardDaemon(port) {
18290
18312
  if (!content)
18291
18313
  return;
18292
18314
  const hash = computeHash2(content);
18293
- if (hash === lastHash)
18315
+ const currentContentHash2 = getCurrentContentHash();
18316
+ if (hash === currentContentHash2)
18294
18317
  return;
18295
- lastHash = hash;
18318
+ setCurrentContentHash(hash);
18296
18319
  const peers = await discoverPeers();
18297
18320
  for (const peer of peers) {
18298
18321
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard-daemon.d.ts","sourceRoot":"","sources":["../../src/commands/clipboard-daemon.ts"],"names":[],"mappings":"AA4GA,wBAAgB,mBAAmB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAO9E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CA6DxD"}
1
+ {"version":3,"file":"clipboard-daemon.d.ts","sourceRoot":"","sources":["../../src/commands/clipboard-daemon.ts"],"names":[],"mappings":"AA2HA,wBAAgB,mBAAmB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAO9E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CA6DxD"}
@@ -9,6 +9,8 @@ export interface ClipboardServerHandle {
9
9
  port: number;
10
10
  close: () => Promise<void>;
11
11
  }
12
+ export declare function getCurrentContentHash(): string | null;
13
+ export declare function setCurrentContentHash(hash: string): void;
12
14
  export declare function startClipboardServer(options?: ClipboardServerOptions): ClipboardServerHandle;
13
15
  export declare function pushClipboardToPeer(host: string, port: number, token: string): Promise<{
14
16
  sent: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard-server.d.ts","sourceRoot":"","sources":["../../src/commands/clipboard-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAKpF,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAuFnE,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAID,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,sBAA2B,GAAG,qBAAqB,CA6ChG;AA6DD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA4ChI"}
1
+ {"version":3,"file":"clipboard-server.d.ts","sourceRoot":"","sources":["../../src/commands/clipboard-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAKpF,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAuFnE,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAID,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAA+B;AACrF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAA+B;AAExF,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,sBAA2B,GAAG,qBAAqB,CA6ChG;AA6DD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA4ChI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/machines",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Machine fleet management CLI + MCP for developers",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",