longtable 0.1.48 → 0.1.49
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/package.json +1 -1
- package/src/autostart.mjs +70 -0
- package/src/run.mjs +7 -2
package/package.json
CHANGED
package/src/autostart.mjs
CHANGED
|
@@ -160,8 +160,78 @@ export function keepStartupCurrent(nodePath, binPath, version) {
|
|
|
160
160
|
} catch (e) { console.error(`keeping the start-up task current failed: ${e.message}`); }
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// The reconnect link: longtable:// on this computer starts the connection when none is running, so the website's
|
|
164
|
+
// Reconnect button can bring it back (the browser asks the person first). It carries nothing: whatever follows the
|
|
165
|
+
// scheme is ignored, and it never replaces a running connection. Written by the RUNNING connection, which Windows'
|
|
166
|
+
// own task starts outside the Claude app: from inside that app the registry entry could stay in the app's own copy,
|
|
167
|
+
// where no browser looks. Returns whether the link is there.
|
|
168
|
+
const desktopFile = () => join(homedir(), ".local", "share", "applications", "longtable-wake.desktop");
|
|
169
|
+
const wakeApp = () => join(homedir(), "Applications", "Longtable Wake.app");
|
|
170
|
+
const LSREGISTER = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
|
|
171
|
+
const WIN_KEY = "HKCU\\Software\\Classes\\longtable";
|
|
172
|
+
|
|
173
|
+
export function keepWakeLink() {
|
|
174
|
+
if (!ownsStartup()) return false;
|
|
175
|
+
if (process.platform === "win32") {
|
|
176
|
+
const starter = join(home, "start.vbs");
|
|
177
|
+
if (!existsSync(starter)) return false;
|
|
178
|
+
const command = `wscript.exe "${starter}"`;
|
|
179
|
+
const now = spawnSync("reg", ["query", `${WIN_KEY}\\shell\\open\\command`, "/ve"], { windowsHide: true, encoding: "utf8" });
|
|
180
|
+
if (now.status === 0 && now.stdout.includes(command)) return true;
|
|
181
|
+
const add = (args) => spawnSync("reg", ["add", ...args, "/f"], { windowsHide: true, encoding: "utf8" });
|
|
182
|
+
const steps = [
|
|
183
|
+
add([WIN_KEY, "/ve", "/d", "URL:Longtable"]),
|
|
184
|
+
add([WIN_KEY, "/v", "URL Protocol", "/d", ""]),
|
|
185
|
+
add([`${WIN_KEY}\\shell\\open\\command`, "/ve", "/d", command]),
|
|
186
|
+
];
|
|
187
|
+
const bad = steps.find((r) => r.status !== 0);
|
|
188
|
+
if (bad) throw new Error(`the reconnect link was not written: ${(bad.stderr || bad.stdout || "").trim().slice(0, 200)}`);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (process.platform === "darwin") {
|
|
192
|
+
const app = wakeApp();
|
|
193
|
+
const exe = join(app, "Contents", "MacOS", "wake");
|
|
194
|
+
if (existsSync(exe)) return true;
|
|
195
|
+
mkdirSync(join(app, "Contents", "MacOS"), { recursive: true });
|
|
196
|
+
writeFileSync(join(app, "Contents", "Info.plist"), `<?xml version="1.0" encoding="UTF-8"?>
|
|
197
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
198
|
+
<plist version="1.0"><dict>
|
|
199
|
+
<key>CFBundleIdentifier</key><string>chat.longtable.wake</string>
|
|
200
|
+
<key>CFBundleName</key><string>Longtable Wake</string>
|
|
201
|
+
<key>CFBundleExecutable</key><string>wake</string>
|
|
202
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
203
|
+
<key>LSBackgroundOnly</key><true/>
|
|
204
|
+
<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLName</key><string>Longtable</string><key>CFBundleURLSchemes</key><array><string>longtable</string></array></dict></array>
|
|
205
|
+
</dict></plist>
|
|
206
|
+
`);
|
|
207
|
+
// launchd already knows the connection: asking it to start the agent starts it only when it is not running.
|
|
208
|
+
writeFileSync(exe, `#!/bin/sh\nlaunchctl kickstart "gui/$(id -u)/chat.longtable.connection" >/dev/null 2>&1\nexit 0\n`, { mode: 0o755 });
|
|
209
|
+
spawnSync(LSREGISTER, ["-f", app], { stdio: "ignore" });
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
if (process.platform === "linux") {
|
|
213
|
+
if (existsSync(desktopFile())) return true;
|
|
214
|
+
mkdirSync(dirname(desktopFile()), { recursive: true });
|
|
215
|
+
writeFileSync(desktopFile(), "[Desktop Entry]\nType=Application\nName=Longtable Wake\nNoDisplay=true\nExec=systemctl --user start longtable.service\nMimeType=x-scheme-handler/longtable;\n");
|
|
216
|
+
spawnSync("xdg-mime", ["default", "longtable-wake.desktop", "x-scheme-handler/longtable"], { stdio: "ignore" });
|
|
217
|
+
spawnSync("update-desktop-database", [dirname(desktopFile())], { stdio: "ignore" });
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function removeWakeLink() {
|
|
224
|
+
if (process.platform === "win32") spawnSync("reg", ["delete", WIN_KEY, "/f"], { windowsHide: true, stdio: "ignore" });
|
|
225
|
+
if (process.platform === "darwin" && existsSync(wakeApp())) {
|
|
226
|
+
spawnSync(LSREGISTER, ["-u", wakeApp()], { stdio: "ignore" });
|
|
227
|
+
rmSync(wakeApp(), { recursive: true, force: true });
|
|
228
|
+
}
|
|
229
|
+
if (process.platform === "linux" && existsSync(desktopFile())) rmSync(desktopFile(), { force: true });
|
|
230
|
+
}
|
|
231
|
+
|
|
163
232
|
export function disableAutostart() {
|
|
164
233
|
if (!ownsStartup()) return;
|
|
234
|
+
removeWakeLink();
|
|
165
235
|
if (process.platform === "win32") {
|
|
166
236
|
removeTask(TASK);
|
|
167
237
|
rmSync(join(home, "start.vbs"), { force: true });
|
package/src/run.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { MARKER, inert } from "./fence.mjs";
|
|
|
9
9
|
import { CLIENT_PROMISES, CLIENT_STYLE, DESK, LOOK_PASS, OWN_TASK, checkClientReply, clientFields, clientSystem, tryAgain } from "./client-rules.mjs";
|
|
10
10
|
import { canCheck, newErrors, remember as rememberCheck, remembered as rememberedCheck, typeCheck } from "./typecheck.mjs";
|
|
11
11
|
import { newer, ownDir, ownVersion, restartOnNew, updateTo } from "./update.mjs";
|
|
12
|
-
import { keepStartupCurrent } from "./autostart.mjs";
|
|
12
|
+
import { keepStartupCurrent, keepWakeLink } from "./autostart.mjs";
|
|
13
13
|
import { SESSION_IDLE_MS, endAllSessions, endIdleSessions, endSession, keepForSession, stopLeftovers, stopProcs, touchSession } from "./procs.mjs";
|
|
14
14
|
import { forgetSession, giveBackSession, sessionInUse, newSessionId, remember as rememberSession, sessionFor, tableSessionIds, takeSession, unseen } from "./sessions.mjs";
|
|
15
15
|
import { attachedPrompt, commandPrompt, fetchAttachments, loadCommand, materialsPrompt, scanCommands, shareable } from "./extras.mjs";
|
|
@@ -532,13 +532,16 @@ export function cleanSources(dir, sources) {
|
|
|
532
532
|
return out.slice(0, 6);
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
+
// Whether longtable:// on this computer starts the connection (keepWakeLink, at start).
|
|
536
|
+
let wakeLink = false;
|
|
537
|
+
|
|
535
538
|
// After each job, the person's plan limits go to the table, so its Usage page shows real numbers.
|
|
536
539
|
// The model that did the work goes with them, so the table's home shows what each person's AI is running.
|
|
537
540
|
async function report(rpc, seat, limits, model) {
|
|
538
541
|
if (!limits && !model) return;
|
|
539
542
|
// Whether fast mode can serve this person's Claude, as Claude Code itself last said, so their AI's window can say so.
|
|
540
543
|
const fast = seat.kind === "claude" && claudeSays.fast ? { fast: claudeSays.fast, fast_why: claudeSays.fastWhy } : {};
|
|
541
|
-
try { await rpc("runner_report", { token: seat.token, limits: { ai: seat.kind, ...(limits || {}), ...fast, version: ownVersion(), reads: readsOf(seat), tools: toolsHere(), ...(model ? { model } : {}) } }); } catch (e) { log(`limits report failed: ${e.message}`); }
|
|
544
|
+
try { await rpc("runner_report", { token: seat.token, limits: { ai: seat.kind, ...(limits || {}), ...fast, version: ownVersion(), wake: wakeLink, reads: readsOf(seat), tools: toolsHere(), ...(model ? { model } : {}) } }); } catch (e) { log(`limits report failed: ${e.message}`); }
|
|
542
545
|
}
|
|
543
546
|
|
|
544
547
|
// What its AI window says it reads: the repository's address (never a sign-in in it), the name of their own folder
|
|
@@ -1547,6 +1550,8 @@ export async function runLoop({ pollMs = 1000, backup = false } = {}) {
|
|
|
1547
1550
|
process.on("unhandledRejection", (e) => log(`tripwire: unhandled ${e?.stack?.split(String.fromCharCode(10)).slice(0, 3).join(" | ") || e}`));
|
|
1548
1551
|
// The computer's start-up entry as this version writes it (with its watchdog), once per version.
|
|
1549
1552
|
try { keepStartupCurrent(process.execPath, join(ownDir(), "bin", "longtable.mjs"), ownVersion()); } catch (e) { log(`start-up entry not refreshed: ${e.message}`); }
|
|
1553
|
+
// The reconnect link the website's Reconnect button opens; the table hears whether this computer has it.
|
|
1554
|
+
try { wakeLink = keepWakeLink(); } catch (e) { log(`reconnect link not written: ${e.message}`); }
|
|
1550
1555
|
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(sig, () => { stopAll(); unlock(); process.exit(0); });
|
|
1551
1556
|
// Starting with no network yet (right after sign-in) is normal: keep trying. A table that took this connection
|
|
1552
1557
|
// off is skipped, and the others carry on.
|