diggylab 0.1.33 → 0.1.34

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 (2) hide show
  1. package/cli.js +22 -11
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -2583,7 +2583,7 @@ function pairErrorMessage(error, origin) {
2583
2583
  const code = error instanceof DesktopAgentClientError ? error.code : null;
2584
2584
  switch (code) {
2585
2585
  case "PAIRING_CODE_INVALID":
2586
- return "The pairing code is invalid, already used, or older than 10 minutes. Create a new code and pair again.";
2586
+ return "The pairing code is invalid, already used, or older than 10 minutes. Codes belong to one environment: check --api and create a new code.";
2587
2587
  case "PLAN_RESTRICTED":
2588
2588
  return "This account's plan does not include the Desktop Agent.";
2589
2589
  case "CREDENTIAL_REVOKED":
@@ -2708,10 +2708,16 @@ async function commandRun(runtime, io) {
2708
2708
  const session = new DesktopAgentSession({
2709
2709
  agentVersion: agentVersion(),
2710
2710
  clearTimer: (timer) => clearTimeout(timer),
2711
- createSocket: (url, accessToken) => new WebSocket(url, {
2712
- headers: { authorization: `Bearer ${accessToken}` },
2713
- maxPayload: 16 * 1024
2714
- }),
2711
+ createSocket: (url, accessToken) => {
2712
+ const socket = new WebSocket(url, {
2713
+ headers: { authorization: `Bearer ${accessToken}` },
2714
+ maxPayload: 16 * 1024
2715
+ });
2716
+ socket.on("close", (code, reason) => {
2717
+ io.log(`socket closed: ${code}${reason?.length ? ` (${reason.toString()})` : ""}`);
2718
+ });
2719
+ return socket;
2720
+ },
2715
2721
  credentials: runtime.manager,
2716
2722
  getFacebookReady: () => facebookReady,
2717
2723
  platform: resolvePlatform(),
@@ -2764,12 +2770,17 @@ async function commandRun(runtime, io) {
2764
2770
  await scanRunner.recover();
2765
2771
  await session.start();
2766
2772
  io.log(`Worker running as "${stored.device.name}". Press Ctrl+C to stop.`);
2767
- await new Promise((resolve) => {
2768
- process.once("SIGINT", resolve);
2769
- process.once("SIGTERM", resolve);
2770
- });
2771
- session.stop();
2772
- scanRunner.stop();
2773
+ const keepAlive = setInterval(() => void 0, 6e4);
2774
+ try {
2775
+ await new Promise((resolve) => {
2776
+ process.once("SIGINT", resolve);
2777
+ process.once("SIGTERM", resolve);
2778
+ });
2779
+ } finally {
2780
+ clearInterval(keepAlive);
2781
+ session.stop();
2782
+ scanRunner.stop();
2783
+ }
2773
2784
  return 0;
2774
2785
  }
2775
2786
  async function commandStatus(runtime, io) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diggylab",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "DiggyLab Desktop Agent collects posts and information from Facebook Groups on a paired computer. (headless CLI)",
5
5
  "type": "module",
6
6
  "bin": {