@melaya/runner 1.0.65 → 1.0.68

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.
@@ -1162,6 +1162,16 @@ export async function connect(opts) {
1162
1162
  }
1163
1163
  catch { /* best-effort */ }
1164
1164
  });
1165
+ // Server relays this when the user cancels a stuck LinkedIn sign-in to retry.
1166
+ socket.on("linkedin:cancel-login", async (_req) => {
1167
+ try {
1168
+ const { cancelActiveLinkedInLogin } = await import("./linkedinLogin.js");
1169
+ const closed = await cancelActiveLinkedInLogin();
1170
+ if (closed)
1171
+ console.log(chalk.gray(" [linkedin] sign-in window closed at server's request (cancel & retry)."));
1172
+ }
1173
+ catch { /* best-effort */ }
1174
+ });
1165
1175
  // ── Kill command ───────────────────────────────────────────────────
1166
1176
  socket.on("runner:kill", (data) => {
1167
1177
  const proc = activeProcesses.get(data.runId);
@@ -55,6 +55,9 @@ export type LinkedInLoginOutcome = LinkedInLoginResult | LinkedInLoginError;
55
55
  interface ProgressEmitter {
56
56
  (msg: string): void;
57
57
  }
58
+ /** Close the in-flight LinkedIn sign-in browser, if any. Returns true if a
59
+ * window was actually open. Best-effort — never throws. */
60
+ export declare function cancelActiveLinkedInLogin(): Promise<boolean>;
58
61
  export declare function runLinkedInLoginFlow(progress: ProgressEmitter): Promise<LinkedInLoginOutcome>;
59
62
  /**
60
63
  * Pretty-print a one-liner summary of the outcome — used by the runner
@@ -116,6 +116,24 @@ function _pageLooksLoggedIn(url) {
116
116
  return false;
117
117
  }
118
118
  }
119
+ // Handle to the in-flight sign-in browser so the server's `linkedin:cancel-login`
120
+ // (relayed via connection.ts) can close a window the user abandoned. Only one
121
+ // login runs per runner at a time, so a single module-level handle suffices.
122
+ // Closing it makes the poll loop's page.url() throw → flow returns user_cancelled.
123
+ let _activeLoginBrowser = null;
124
+ /** Close the in-flight LinkedIn sign-in browser, if any. Returns true if a
125
+ * window was actually open. Best-effort — never throws. */
126
+ export async function cancelActiveLinkedInLogin() {
127
+ const b = _activeLoginBrowser;
128
+ if (!b)
129
+ return false;
130
+ _activeLoginBrowser = null;
131
+ try {
132
+ await b.close();
133
+ }
134
+ catch { /* already closed */ }
135
+ return true;
136
+ }
119
137
  export async function runLinkedInLoginFlow(progress) {
120
138
  // 1. Ensure Playwright + Chromium are available.
121
139
  let playwright;
@@ -143,6 +161,7 @@ export async function runLinkedInLoginFlow(progress) {
143
161
  "--disable-blink-features=AutomationControlled",
144
162
  ],
145
163
  });
164
+ _activeLoginBrowser = browser;
146
165
  const context = await browser.newContext({
147
166
  userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
148
167
  "(KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
@@ -228,6 +247,7 @@ export async function runLinkedInLoginFlow(progress) {
228
247
  }
229
248
  catch { /* already closed */ }
230
249
  }
250
+ _activeLoginBrowser = null;
231
251
  }
232
252
  }
233
253
  /**
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "@melaya/runner",
3
- "version": "1.0.65",
4
- "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
- "license": "UNLICENSED",
6
- "private": false,
7
- "type": "module",
8
- "bin": {
9
- "melaya-runner": "dist/cli.js"
10
- },
11
- "main": "dist/index.js",
12
- "files": [
13
- "dist/**/*.js",
14
- "dist/**/*.d.ts",
15
- "dist/**/*.py",
16
- "localRagIngest.py",
17
- "nltk_data/**",
18
- "README.md"
19
- ],
20
- "scripts": {
21
- "build": "tsc && node -e \"require('fs').copyFileSync('localRagIngest.py','dist/localRagIngest.py')\"",
22
- "prepublishOnly": "npm run build"
23
- },
24
- "dependencies": {
25
- "socket.io-client": "^4.8.0",
26
- "commander": "^12.0.0",
27
- "chalk": "^5.3.0",
28
- "ora": "^8.0.0",
29
- "playwright": "^1.47.0"
30
- },
31
- "devDependencies": {
32
- "typescript": "^5.5.0",
33
- "@types/node": "^20.0.0"
34
- },
35
- "engines": {
36
- "node": ">=18"
37
- },
38
- "publishConfig": {
39
- "access": "public"
40
- }
41
- }
1
+ {
2
+ "name": "@melaya/runner",
3
+ "version": "1.0.68",
4
+ "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
+ "license": "UNLICENSED",
6
+ "private": false,
7
+ "type": "module",
8
+ "bin": {
9
+ "melaya-runner": "dist/cli.js"
10
+ },
11
+ "main": "dist/index.js",
12
+ "files": [
13
+ "dist/**/*.js",
14
+ "dist/**/*.d.ts",
15
+ "dist/**/*.py",
16
+ "localRagIngest.py",
17
+ "nltk_data/**",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc && node -e \"require('fs').copyFileSync('localRagIngest.py','dist/localRagIngest.py')\"",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "dependencies": {
25
+ "socket.io-client": "^4.8.0",
26
+ "commander": "^12.0.0",
27
+ "chalk": "^5.3.0",
28
+ "ora": "^8.0.0",
29
+ "playwright": "^1.47.0"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.5.0",
33
+ "@types/node": "^20.0.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }