teamshare-bridge 0.21.66 → 0.21.70
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/bridge/autostart-launcher.d.ts +96 -0
- package/dist/bridge/autostart-launcher.js +218 -0
- package/dist/bridge/autostart-launcher.js.map +1 -0
- package/dist/bridge/daemon-inbox.d.ts +46 -0
- package/dist/bridge/daemon-inbox.js +388 -0
- package/dist/bridge/daemon-inbox.js.map +1 -0
- package/dist/bridge/daemon-support.d.ts +58 -0
- package/dist/bridge/daemon-support.js +227 -0
- package/dist/bridge/daemon-support.js.map +1 -0
- package/dist/bridge/daemon.d.ts +1 -0
- package/dist/bridge/daemon.js +106 -1247
- package/dist/bridge/daemon.js.map +1 -1
- package/dist/bridge/doctor.js +38 -2
- package/dist/bridge/doctor.js.map +1 -1
- package/dist/bridge/index.js +32 -8
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/protocol.d.ts +12 -0
- package/dist/bridge/protocol.js +419 -70
- package/dist/bridge/protocol.js.map +1 -1
- package/dist/bridge/service.d.ts +6 -1
- package/dist/bridge/service.js +85 -83
- package/dist/bridge/service.js.map +1 -1
- package/dist/bridge/session-relay.js +3 -1
- package/dist/bridge/session-relay.js.map +1 -1
- package/dist/bridge/spawn.d.ts +21 -3
- package/dist/bridge/spawn.js +28 -3
- package/dist/bridge/spawn.js.map +1 -1
- package/dist/bridge/wake-handler.d.ts +35 -0
- package/dist/bridge/wake-handler.js +682 -0
- package/dist/bridge/wake-handler.js.map +1 -0
- package/dist/bridge/wake-routing.d.ts +114 -0
- package/dist/bridge/wake-routing.js +120 -0
- package/dist/bridge/wake-routing.js.map +1 -0
- package/dist/cli/commands/browse.js +104 -3369
- package/dist/cli/commands/browse.js.map +1 -1
- package/dist/cli/commands/build.js +16 -8
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/chat.js +162 -9
- package/dist/cli/commands/chat.js.map +1 -1
- package/dist/cli/commands/doc.js +7 -3
- package/dist/cli/commands/doc.js.map +1 -1
- package/dist/cli/commands/plan.js +10 -3
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/planner.js +54 -12
- package/dist/cli/commands/planner.js.map +1 -1
- package/dist/cli/commands/research.js +10 -3
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/run.js +20 -6
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/worker.js +13 -5
- package/dist/cli/commands/worker.js.map +1 -1
- package/dist/cli/index.js +3 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils.d.ts +38 -2
- package/dist/cli/utils.js +66 -0
- package/dist/cli/utils.js.map +1 -1
- package/dist/lib/api-agents.d.ts +156 -0
- package/dist/lib/api-agents.js +135 -0
- package/dist/lib/api-agents.js.map +1 -0
- package/dist/lib/api-content.d.ts +258 -0
- package/dist/lib/api-content.js +297 -0
- package/dist/lib/api-content.js.map +1 -0
- package/dist/lib/api-core.d.ts +28 -0
- package/dist/lib/api-core.js +118 -0
- package/dist/lib/api-core.js.map +1 -0
- package/dist/lib/api-tasks.d.ts +160 -0
- package/dist/lib/api-tasks.js +193 -0
- package/dist/lib/api-tasks.js.map +1 -0
- package/dist/lib/api-types.d.ts +330 -0
- package/dist/lib/api-types.js +8 -0
- package/dist/lib/api-types.js.map +1 -0
- package/dist/lib/api.d.ts +21 -903
- package/dist/lib/api.js +27 -693
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/brief.js +19 -0
- package/dist/lib/brief.js.map +1 -1
- package/dist/lib/browser/browse-actions.d.ts +29 -0
- package/dist/lib/browser/browse-actions.js +610 -0
- package/dist/lib/browser/browse-actions.js.map +1 -0
- package/dist/lib/browser/browse-cdp.d.ts +52 -0
- package/dist/lib/browser/browse-cdp.js +289 -0
- package/dist/lib/browser/browse-cdp.js.map +1 -0
- package/dist/lib/browser/browse-editor.d.ts +76 -0
- package/dist/lib/browser/browse-editor.js +706 -0
- package/dist/lib/browser/browse-editor.js.map +1 -0
- package/dist/lib/browser/browse-llm.d.ts +78 -0
- package/dist/lib/browser/browse-llm.js +849 -0
- package/dist/lib/browser/browse-llm.js.map +1 -0
- package/dist/lib/browser/browse-safety.d.ts +43 -0
- package/dist/lib/browser/browse-safety.js +130 -0
- package/dist/lib/browser/browse-safety.js.map +1 -0
- package/dist/lib/browser/browse-stealth.d.ts +64 -0
- package/dist/lib/browser/browse-stealth.js +532 -0
- package/dist/lib/browser/browse-stealth.js.map +1 -0
- package/dist/lib/browser/browse-types.d.ts +136 -0
- package/dist/lib/browser/browse-types.js +275 -0
- package/dist/lib/browser/browse-types.js.map +1 -0
- package/dist/lib/chat/board-reply.js +6 -0
- package/dist/lib/chat/board-reply.js.map +1 -1
- package/dist/lib/chat/chat-reply.d.ts +38 -0
- package/dist/lib/chat/chat-reply.js +40 -5
- package/dist/lib/chat/chat-reply.js.map +1 -1
- package/dist/lib/chat/daemon-reporter.js +2 -1
- package/dist/lib/chat/daemon-reporter.js.map +1 -1
- package/dist/lib/chat/doc-reply.js +5 -3
- package/dist/lib/chat/doc-reply.js.map +1 -1
- package/dist/lib/chat/session-stream.d.ts +19 -0
- package/dist/lib/chat/session-stream.js +41 -4
- package/dist/lib/chat/session-stream.js.map +1 -1
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/documents/job-runner.js +7 -34
- package/dist/lib/documents/job-runner.js.map +1 -1
- package/dist/lib/documents/source.d.ts +29 -0
- package/dist/lib/documents/source.js +50 -0
- package/dist/lib/documents/source.js.map +1 -0
- package/dist/lib/git/git-branch.d.ts +28 -0
- package/dist/lib/git/git-branch.js +109 -0
- package/dist/lib/git/git-branch.js.map +1 -0
- package/dist/lib/git/git-core.d.ts +17 -0
- package/dist/lib/git/git-core.js +44 -0
- package/dist/lib/git/git-core.js.map +1 -0
- package/dist/lib/git/git-discovery.d.ts +33 -0
- package/dist/lib/git/git-discovery.js +189 -0
- package/dist/lib/git/git-discovery.js.map +1 -0
- package/dist/lib/git/git-finalize.d.ts +63 -0
- package/dist/lib/git/git-finalize.js +436 -0
- package/dist/lib/git/git-finalize.js.map +1 -0
- package/dist/lib/git/git-pipeline.d.ts +35 -194
- package/dist/lib/git/git-pipeline.js +15 -958
- package/dist/lib/git/git-pipeline.js.map +1 -1
- package/dist/lib/git/git-prepare.d.ts +87 -0
- package/dist/lib/git/git-prepare.js +232 -0
- package/dist/lib/git/git-prepare.js.map +1 -0
- package/dist/lib/harness/agy-pty.d.ts +2 -2
- package/dist/lib/harness/harness-adapter.d.ts +11 -1
- package/dist/lib/harness/harness-adapter.js +24 -2
- package/dist/lib/harness/harness-adapter.js.map +1 -1
- package/dist/lib/harness/harness-output.d.ts +15 -3
- package/dist/lib/harness/harness-output.js +143 -26
- package/dist/lib/harness/harness-output.js.map +1 -1
- package/dist/lib/harness/harness.js +30 -14
- package/dist/lib/harness/harness.js.map +1 -1
- package/dist/lib/harness/index.d.ts +4 -2
- package/dist/lib/harness/index.js +7 -1
- package/dist/lib/harness/index.js.map +1 -1
- package/dist/lib/harness/line-assembler.d.ts +28 -0
- package/dist/lib/harness/line-assembler.js +60 -0
- package/dist/lib/harness/line-assembler.js.map +1 -0
- package/dist/lib/harness/plan-gate.d.ts +38 -0
- package/dist/lib/harness/plan-gate.js +42 -0
- package/dist/lib/harness/plan-gate.js.map +1 -0
- package/dist/lib/harness/spawn.js +76 -16
- package/dist/lib/harness/spawn.js.map +1 -1
- package/dist/lib/llm/llm-chat.d.ts +37 -0
- package/dist/lib/llm/llm-chat.js +239 -0
- package/dist/lib/llm/llm-chat.js.map +1 -0
- package/dist/lib/llm/llm-core.d.ts +54 -0
- package/dist/lib/llm/llm-core.js +15 -0
- package/dist/lib/llm/llm-core.js.map +1 -0
- package/dist/lib/llm/llm-tools.d.ts +29 -0
- package/dist/lib/llm/llm-tools.js +472 -0
- package/dist/lib/llm/llm-tools.js.map +1 -0
- package/dist/lib/llm/llm.d.ts +6 -69
- package/dist/lib/llm/llm.js +25 -612
- package/dist/lib/llm/llm.js.map +1 -1
- package/dist/lib/llm/retry.js +3 -0
- package/dist/lib/llm/retry.js.map +1 -1
- package/dist/lib/orchestrator/client.js +5 -0
- package/dist/lib/orchestrator/client.js.map +1 -1
- package/dist/lib/orchestrator/handlers/cv-parse.d.ts +18 -0
- package/dist/lib/orchestrator/handlers/cv-parse.js +165 -0
- package/dist/lib/orchestrator/handlers/cv-parse.js.map +1 -0
- package/dist/lib/orchestrator/handlers/index.d.ts +1 -0
- package/dist/lib/orchestrator/handlers/index.js +3 -1
- package/dist/lib/orchestrator/handlers/index.js.map +1 -1
- package/dist/lib/orchestrator/handlers/planner.js +18 -0
- package/dist/lib/orchestrator/handlers/planner.js.map +1 -1
- package/dist/lib/tools/cv-parse-deterministic.d.ts +56 -0
- package/dist/lib/tools/cv-parse-deterministic.js +814 -0
- package/dist/lib/tools/cv-parse-deterministic.js.map +1 -0
- package/dist/lib/tools/docx-source.d.ts +36 -0
- package/dist/lib/tools/docx-source.js +74 -0
- package/dist/lib/tools/docx-source.js.map +1 -0
- package/dist/lib/tools/docx-to-pdf.d.ts +9 -1
- package/dist/lib/tools/docx-to-pdf.js +84 -11
- package/dist/lib/tools/docx-to-pdf.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** Stable state dir - survives npm upgrades, reinstalls and dist cleans. */
|
|
2
|
+
export declare const TEAMSHARE_STATE_DIR: string;
|
|
3
|
+
/** Registration marker written by `autostart on` / removed by `autostart off`. */
|
|
4
|
+
export declare const AUTOSTART_MARKER_PATH: string;
|
|
5
|
+
/** Watchdog script referenced by the TeamShareBridge scheduled task. */
|
|
6
|
+
export declare const SUPERVISOR_VBS_PATH: string;
|
|
7
|
+
/** Protocol-handler script referenced by HKCU\Software\Classes\teamshare. */
|
|
8
|
+
export declare const SERVE_VBS_PATH: string;
|
|
9
|
+
/** Logon-only fallback when the per-user scheduled task can't be created. */
|
|
10
|
+
export declare const STARTUP_VBS_PATH: string;
|
|
11
|
+
/**
|
|
12
|
+
* The launcher entry point (`dist/bridge/index.js`). Lives in THIS module's
|
|
13
|
+
* `__dirname`, which is the same directory the old package-dir copies were
|
|
14
|
+
* written to - also where `legacyLauncherPath()` looks.
|
|
15
|
+
*/
|
|
16
|
+
export declare function currentEntryPath(): string;
|
|
17
|
+
/** Old package-dir copy (<=0.21.x) of a generated launcher. */
|
|
18
|
+
export declare function legacyLauncherPath(kind: 'supervisor' | 'serve'): string;
|
|
19
|
+
/** Quotes one token of a Windows command line (paths routinely contain spaces). */
|
|
20
|
+
export declare function cmdQuote(value: string): string;
|
|
21
|
+
/** Renders a plain string as a VBScript string literal (`"` -> `""`). */
|
|
22
|
+
export declare function vbsLiteral(value: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Builds a hidden Windows Script Host launcher for `cmdline`.
|
|
25
|
+
*
|
|
26
|
+
* Two rules, both here because they were once broken:
|
|
27
|
+
* - the executable MUST be quoted. `process.execPath` is normally
|
|
28
|
+
* `C:\Program Files\nodejs\node.exe`, and an UNQUOTED path with a space
|
|
29
|
+
* makes `WScript.Shell.Run` fail with 0x80070002 ("The system cannot find
|
|
30
|
+
* the file specified") - the modal Windows Script Host dialog that popped
|
|
31
|
+
* up at every logon while the watchdog never actually started.
|
|
32
|
+
* - failures never surface as a WSH popup. They are appended to daemon.log
|
|
33
|
+
* and reported through a NON-ZERO exit code so Task Scheduler's
|
|
34
|
+
* RestartCount/RestartInterval retries every minute instead of leaving a
|
|
35
|
+
* dialog on the user's desktop.
|
|
36
|
+
*
|
|
37
|
+
* `wait: true` blocks until the child exits and forwards its exit code
|
|
38
|
+
* (that is what makes the scheduled task a restart-on-failure watchdog).
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildWindowsLauncherVbs(cmdline: string, opts: {
|
|
41
|
+
wait: boolean;
|
|
42
|
+
logPath: string;
|
|
43
|
+
}): string;
|
|
44
|
+
/**
|
|
45
|
+
* Builds the hidden `teamshare://` protocol launcher: wscript.exe is a
|
|
46
|
+
* GUI-subsystem binary, so no console window is ever created (zero flash on
|
|
47
|
+
* deep link). The URL arrives as the first argument.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildServeVbs(nodeBin: string, entry: string): string;
|
|
50
|
+
/** Writes `content` to `path`, creating the parent directory when missing. */
|
|
51
|
+
export declare function writeLauncherFile(path: string, content: string): void;
|
|
52
|
+
/** Reads a UTF-8 text file, or null when it is missing/unreadable. */
|
|
53
|
+
export declare function readTextFile(path: string): string | null;
|
|
54
|
+
/** Best-effort delete of a generated launcher (missing file is fine). */
|
|
55
|
+
export declare function removeLauncherFile(path: string): void;
|
|
56
|
+
export interface AutostartMarker {
|
|
57
|
+
/** Which mechanism `autostart on` actually registered. */
|
|
58
|
+
mode: 'task' | 'startup';
|
|
59
|
+
/** Absolute path of the launcher the mechanism references. */
|
|
60
|
+
vbs: string;
|
|
61
|
+
/** Install entry point the launcher was built for (detects reinstalls). */
|
|
62
|
+
entry: string;
|
|
63
|
+
/** node binary the launcher was built for. */
|
|
64
|
+
execPath: string;
|
|
65
|
+
/** ISO timestamp of the registration. */
|
|
66
|
+
at: string;
|
|
67
|
+
}
|
|
68
|
+
export declare function readAutostartMarker(path?: string): AutostartMarker | null;
|
|
69
|
+
export declare function writeAutostartMarker(marker: Omit<AutostartMarker, 'at'> & {
|
|
70
|
+
at?: string;
|
|
71
|
+
}, path?: string): void;
|
|
72
|
+
export declare function removeAutostartMarker(path?: string): void;
|
|
73
|
+
export interface LauncherHealth {
|
|
74
|
+
ok: boolean;
|
|
75
|
+
/** Human-readable failure cause ("" when ok). */
|
|
76
|
+
reason: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Pure health check for a registered launcher: the marker must match the
|
|
80
|
+
* CURRENT install (entry + node path) and the launcher file must exist and
|
|
81
|
+
* have been built for that same install. Any mismatch means an upgrade or
|
|
82
|
+
* reinstall moved the goalposts and the registration must be redone.
|
|
83
|
+
*/
|
|
84
|
+
export declare function launcherHealth(input: {
|
|
85
|
+
marker: AutostartMarker | null;
|
|
86
|
+
content: string | null;
|
|
87
|
+
entry: string;
|
|
88
|
+
execPath: string;
|
|
89
|
+
}): LauncherHealth;
|
|
90
|
+
/** True when `vbsPath` exists and was built for the current entry + node. */
|
|
91
|
+
export declare function launcherFileHealthy(vbsPath: string, entry?: string, execPath?: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Health of the registered autostart launcher (whatever mechanism the last
|
|
94
|
+
* `autostart on` recorded). Read-only - never registers anything itself.
|
|
95
|
+
*/
|
|
96
|
+
export declare function supervisorLauncherHealth(): LauncherHealth;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STARTUP_VBS_PATH = exports.SERVE_VBS_PATH = exports.SUPERVISOR_VBS_PATH = exports.AUTOSTART_MARKER_PATH = exports.TEAMSHARE_STATE_DIR = void 0;
|
|
4
|
+
exports.currentEntryPath = currentEntryPath;
|
|
5
|
+
exports.legacyLauncherPath = legacyLauncherPath;
|
|
6
|
+
exports.cmdQuote = cmdQuote;
|
|
7
|
+
exports.vbsLiteral = vbsLiteral;
|
|
8
|
+
exports.buildWindowsLauncherVbs = buildWindowsLauncherVbs;
|
|
9
|
+
exports.buildServeVbs = buildServeVbs;
|
|
10
|
+
exports.writeLauncherFile = writeLauncherFile;
|
|
11
|
+
exports.readTextFile = readTextFile;
|
|
12
|
+
exports.removeLauncherFile = removeLauncherFile;
|
|
13
|
+
exports.readAutostartMarker = readAutostartMarker;
|
|
14
|
+
exports.writeAutostartMarker = writeAutostartMarker;
|
|
15
|
+
exports.removeAutostartMarker = removeAutostartMarker;
|
|
16
|
+
exports.launcherHealth = launcherHealth;
|
|
17
|
+
exports.launcherFileHealthy = launcherFileHealthy;
|
|
18
|
+
exports.supervisorLauncherHealth = supervisorLauncherHealth;
|
|
19
|
+
/**
|
|
20
|
+
* Windows launcher helpers for the two VBS scripts Windows references from
|
|
21
|
+
* OUTSIDE the package:
|
|
22
|
+
* - supervisor.vbs -> scheduled task `TeamShareBridge` (logon watchdog)
|
|
23
|
+
* - serve.vbs -> HKCU `teamshare://` protocol handler
|
|
24
|
+
*
|
|
25
|
+
* Both scripts used to be written INSIDE the installed package dir
|
|
26
|
+
* (`.../node_modules/teamshare-bridge/dist/bridge/`) and were destroyed by
|
|
27
|
+
* every `npm i -g` upgrade (the file is generated at runtime, never shipped
|
|
28
|
+
* in the tarball) while the task/registry references survived - producing
|
|
29
|
+
* the "Can not find script file ...\supervisor.vbs" Windows Script Host
|
|
30
|
+
* dialog at every logon. They now live under ~/.teamshare (survives
|
|
31
|
+
* upgrades, reinstalls and `rm -rf dist`), and every registration records a
|
|
32
|
+
* marker so `ensureAutostartDefault` can detect a missing/stale launcher and
|
|
33
|
+
* re-register instead of returning early just because "the task exists".
|
|
34
|
+
*
|
|
35
|
+
* Everything here is pure/read-only except the explicit write/remove
|
|
36
|
+
* helpers, which all take an optional path so tests never touch the real
|
|
37
|
+
* ~/.teamshare.
|
|
38
|
+
*/
|
|
39
|
+
const node_fs_1 = require("node:fs");
|
|
40
|
+
const node_os_1 = require("node:os");
|
|
41
|
+
const node_path_1 = require("node:path");
|
|
42
|
+
/** Stable state dir - survives npm upgrades, reinstalls and dist cleans. */
|
|
43
|
+
exports.TEAMSHARE_STATE_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), '.teamshare');
|
|
44
|
+
/** Registration marker written by `autostart on` / removed by `autostart off`. */
|
|
45
|
+
exports.AUTOSTART_MARKER_PATH = (0, node_path_1.join)(exports.TEAMSHARE_STATE_DIR, 'autostart.json');
|
|
46
|
+
/** Watchdog script referenced by the TeamShareBridge scheduled task. */
|
|
47
|
+
exports.SUPERVISOR_VBS_PATH = (0, node_path_1.join)(exports.TEAMSHARE_STATE_DIR, 'supervisor.vbs');
|
|
48
|
+
/** Protocol-handler script referenced by HKCU\Software\Classes\teamshare. */
|
|
49
|
+
exports.SERVE_VBS_PATH = (0, node_path_1.join)(exports.TEAMSHARE_STATE_DIR, 'serve.vbs');
|
|
50
|
+
/** Logon-only fallback when the per-user scheduled task can't be created. */
|
|
51
|
+
exports.STARTUP_VBS_PATH = (0, node_path_1.join)((0, node_os_1.homedir)(), 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup', 'teamshare-bridge.vbs');
|
|
52
|
+
/**
|
|
53
|
+
* The launcher entry point (`dist/bridge/index.js`). Lives in THIS module's
|
|
54
|
+
* `__dirname`, which is the same directory the old package-dir copies were
|
|
55
|
+
* written to - also where `legacyLauncherPath()` looks.
|
|
56
|
+
*/
|
|
57
|
+
function currentEntryPath() {
|
|
58
|
+
return (0, node_path_1.join)(__dirname, 'index.js');
|
|
59
|
+
}
|
|
60
|
+
/** Old package-dir copy (<=0.21.x) of a generated launcher. */
|
|
61
|
+
function legacyLauncherPath(kind) {
|
|
62
|
+
return (0, node_path_1.join)(__dirname, `${kind}.vbs`);
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------- VBS builds
|
|
65
|
+
/** Quotes one token of a Windows command line (paths routinely contain spaces). */
|
|
66
|
+
function cmdQuote(value) {
|
|
67
|
+
return `"${value}"`;
|
|
68
|
+
}
|
|
69
|
+
/** Renders a plain string as a VBScript string literal (`"` -> `""`). */
|
|
70
|
+
function vbsLiteral(value) {
|
|
71
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Builds a hidden Windows Script Host launcher for `cmdline`.
|
|
75
|
+
*
|
|
76
|
+
* Two rules, both here because they were once broken:
|
|
77
|
+
* - the executable MUST be quoted. `process.execPath` is normally
|
|
78
|
+
* `C:\Program Files\nodejs\node.exe`, and an UNQUOTED path with a space
|
|
79
|
+
* makes `WScript.Shell.Run` fail with 0x80070002 ("The system cannot find
|
|
80
|
+
* the file specified") - the modal Windows Script Host dialog that popped
|
|
81
|
+
* up at every logon while the watchdog never actually started.
|
|
82
|
+
* - failures never surface as a WSH popup. They are appended to daemon.log
|
|
83
|
+
* and reported through a NON-ZERO exit code so Task Scheduler's
|
|
84
|
+
* RestartCount/RestartInterval retries every minute instead of leaving a
|
|
85
|
+
* dialog on the user's desktop.
|
|
86
|
+
*
|
|
87
|
+
* `wait: true` blocks until the child exits and forwards its exit code
|
|
88
|
+
* (that is what makes the scheduled task a restart-on-failure watchdog).
|
|
89
|
+
*/
|
|
90
|
+
function buildWindowsLauncherVbs(cmdline, opts) {
|
|
91
|
+
const lines = [
|
|
92
|
+
'On Error Resume Next',
|
|
93
|
+
'Set sh = CreateObject("WScript.Shell")',
|
|
94
|
+
'Set fso = CreateObject("Scripting.FileSystemObject")',
|
|
95
|
+
`cmd = ${vbsLiteral(cmdline)}`,
|
|
96
|
+
`rc = ${opts.wait ? 1 : 0}`,
|
|
97
|
+
opts.wait ? 'rc = sh.Run(cmd, 0, True)' : 'sh.Run cmd, 0, False',
|
|
98
|
+
'If Err.Number <> 0 Then',
|
|
99
|
+
' n = Err.Number',
|
|
100
|
+
' d = Err.Description',
|
|
101
|
+
' Err.Clear',
|
|
102
|
+
` Set ts = fso.OpenTextFile(${vbsLiteral(opts.logPath)}, 8, True)`,
|
|
103
|
+
' If Not ts Is Nothing Then',
|
|
104
|
+
' ts.WriteLine "[" & Now & "] [autostart.vbs] launch failed (" & n & " " & d & "): " & cmd',
|
|
105
|
+
' ts.Close',
|
|
106
|
+
' End If',
|
|
107
|
+
' WScript.Quit 1',
|
|
108
|
+
'End If',
|
|
109
|
+
opts.wait ? 'WScript.Quit rc' : "' fire-and-forget: nothing to forward",
|
|
110
|
+
'',
|
|
111
|
+
];
|
|
112
|
+
return lines.join('\r\n');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Builds the hidden `teamshare://` protocol launcher: wscript.exe is a
|
|
116
|
+
* GUI-subsystem binary, so no console window is ever created (zero flash on
|
|
117
|
+
* deep link). The URL arrives as the first argument.
|
|
118
|
+
*/
|
|
119
|
+
function buildServeVbs(nodeBin, entry) {
|
|
120
|
+
const escapedNode = nodeBin.replace(/"/g, '""');
|
|
121
|
+
const escapedScript = entry.replace(/"/g, '""');
|
|
122
|
+
return [
|
|
123
|
+
'Set sh = CreateObject("WScript.Shell")',
|
|
124
|
+
'Dim url',
|
|
125
|
+
'If WScript.Arguments.Count > 0 Then',
|
|
126
|
+
' url = WScript.Arguments(0)',
|
|
127
|
+
'Else',
|
|
128
|
+
' url = ""',
|
|
129
|
+
'End If',
|
|
130
|
+
`sh.Run """${escapedNode}"" ""${escapedScript}"" serve """ & url & """ --hidden", 0, False`,
|
|
131
|
+
].join('\r\n');
|
|
132
|
+
}
|
|
133
|
+
// ---------------------------------------------------------------- file io
|
|
134
|
+
/** Writes `content` to `path`, creating the parent directory when missing. */
|
|
135
|
+
function writeLauncherFile(path, content) {
|
|
136
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
137
|
+
(0, node_fs_1.writeFileSync)(path, content, 'utf8');
|
|
138
|
+
}
|
|
139
|
+
/** Reads a UTF-8 text file, or null when it is missing/unreadable. */
|
|
140
|
+
function readTextFile(path) {
|
|
141
|
+
try {
|
|
142
|
+
return (0, node_fs_1.readFileSync)(path, 'utf8');
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** Best-effort delete of a generated launcher (missing file is fine). */
|
|
149
|
+
function removeLauncherFile(path) {
|
|
150
|
+
try {
|
|
151
|
+
(0, node_fs_1.rmSync)(path, { force: true });
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
/* best-effort */
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function readAutostartMarker(path = exports.AUTOSTART_MARKER_PATH) {
|
|
158
|
+
try {
|
|
159
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(path, 'utf8'));
|
|
160
|
+
if (parsed === null || typeof parsed !== 'object')
|
|
161
|
+
return null;
|
|
162
|
+
const m = parsed;
|
|
163
|
+
if (m.mode !== 'task' && m.mode !== 'startup')
|
|
164
|
+
return null;
|
|
165
|
+
if (typeof m.vbs === 'string' && typeof m.entry === 'string' && typeof m.execPath === 'string') {
|
|
166
|
+
return m;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function writeAutostartMarker(marker, path = exports.AUTOSTART_MARKER_PATH) {
|
|
175
|
+
writeLauncherFile(path, JSON.stringify({ ...marker, at: marker.at ?? new Date().toISOString() }, null, 2));
|
|
176
|
+
}
|
|
177
|
+
function removeAutostartMarker(path = exports.AUTOSTART_MARKER_PATH) {
|
|
178
|
+
removeLauncherFile(path);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Pure health check for a registered launcher: the marker must match the
|
|
182
|
+
* CURRENT install (entry + node path) and the launcher file must exist and
|
|
183
|
+
* have been built for that same install. Any mismatch means an upgrade or
|
|
184
|
+
* reinstall moved the goalposts and the registration must be redone.
|
|
185
|
+
*/
|
|
186
|
+
function launcherHealth(input) {
|
|
187
|
+
const { marker, content, entry, execPath } = input;
|
|
188
|
+
if (!marker)
|
|
189
|
+
return { ok: false, reason: 'no registration marker' };
|
|
190
|
+
if (marker.entry !== entry || marker.execPath !== execPath) {
|
|
191
|
+
return { ok: false, reason: 'stale install paths' };
|
|
192
|
+
}
|
|
193
|
+
if (content === null)
|
|
194
|
+
return { ok: false, reason: 'launcher file missing' };
|
|
195
|
+
if (!content.includes(entry) || !content.includes(execPath)) {
|
|
196
|
+
return { ok: false, reason: 'launcher content stale' };
|
|
197
|
+
}
|
|
198
|
+
return { ok: true, reason: '' };
|
|
199
|
+
}
|
|
200
|
+
/** True when `vbsPath` exists and was built for the current entry + node. */
|
|
201
|
+
function launcherFileHealthy(vbsPath, entry = currentEntryPath(), execPath = process.execPath) {
|
|
202
|
+
const content = readTextFile(vbsPath);
|
|
203
|
+
return content !== null && content.includes(entry) && content.includes(execPath);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Health of the registered autostart launcher (whatever mechanism the last
|
|
207
|
+
* `autostart on` recorded). Read-only - never registers anything itself.
|
|
208
|
+
*/
|
|
209
|
+
function supervisorLauncherHealth() {
|
|
210
|
+
const marker = readAutostartMarker();
|
|
211
|
+
return launcherHealth({
|
|
212
|
+
marker,
|
|
213
|
+
content: marker ? readTextFile(marker.vbs) : null,
|
|
214
|
+
entry: currentEntryPath(),
|
|
215
|
+
execPath: process.execPath,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=autostart-launcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autostart-launcher.js","sourceRoot":"","sources":["../../src/bridge/autostart-launcher.ts"],"names":[],"mappings":";;;AAkDA,4CAEC;AAGD,gDAEC;AAKD,4BAEC;AAGD,gCAEC;AAmBD,0DA0BC;AAOD,sCAaC;AAKD,8CAGC;AAGD,oCAMC;AAGD,gDAMC;AAiBD,kDAaC;AAED,oDAKC;AAED,sDAEC;AAgBD,wCAgBC;AAGD,kDAOC;AAMD,4DAQC;AAjQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qCAAyE;AACzE,qCAAkC;AAClC,yCAA0C;AAE1C,4EAA4E;AAC/D,QAAA,mBAAmB,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,YAAY,CAAC,CAAC;AACjE,kFAAkF;AACrE,QAAA,qBAAqB,GAAG,IAAA,gBAAI,EAAC,2BAAmB,EAAE,gBAAgB,CAAC,CAAC;AACjF,wEAAwE;AAC3D,QAAA,mBAAmB,GAAG,IAAA,gBAAI,EAAC,2BAAmB,EAAE,gBAAgB,CAAC,CAAC;AAC/E,6EAA6E;AAChE,QAAA,cAAc,GAAG,IAAA,gBAAI,EAAC,2BAAmB,EAAE,WAAW,CAAC,CAAC;AAC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AC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daemon inbox pumps: the periodic mention + stranded-assignment poll and
|
|
3
|
+
* the reconnect re-sync drain. Both used to be inline in startAgentLoop and
|
|
4
|
+
* dominated daemon.ts; they only need a small deps bag (API client, config
|
|
5
|
+
* getter, wake queue, settings cache). Split out of daemon.ts (line budget).
|
|
6
|
+
*/
|
|
7
|
+
import { TeamshareApi } from '../lib/api';
|
|
8
|
+
import { loadConfig } from '../lib/config';
|
|
9
|
+
import { type WakeEvent } from './wake-routing';
|
|
10
|
+
import type { SessionSettings } from './spawn';
|
|
11
|
+
/** Cadence of the periodic mention + stranded-assignment poll. */
|
|
12
|
+
export declare const MENTION_POLL_MS: number;
|
|
13
|
+
/** Everything the two inbox pumps need from the daemon/agent loop. */
|
|
14
|
+
export interface InboxDeps {
|
|
15
|
+
/** Authenticated API client for this agent (inbox fetches). */
|
|
16
|
+
api: TeamshareApi;
|
|
17
|
+
/** Base URL so a fresh client can be built with `TeamshareApi.forAgent`. */
|
|
18
|
+
apiBase: string;
|
|
19
|
+
agent: {
|
|
20
|
+
agentId: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
};
|
|
23
|
+
/** Fresh config getter - project links / wake rules apply live. */
|
|
24
|
+
config: () => ReturnType<typeof loadConfig>;
|
|
25
|
+
wakeQueue: Map<string, WakeEvent[]>;
|
|
26
|
+
recentSpawns: Map<string, number>;
|
|
27
|
+
gateWarned: Set<string>;
|
|
28
|
+
settingsByAgent: Map<string, SessionSettings | null>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Periodic mention poll (catches wakes lost while connected - WS emits are
|
|
32
|
+
* best-effort, so a silent hiccup loses the wake until the next reconnect)
|
|
33
|
+
* plus stranded-assignment recovery: open assigned tasks no session has
|
|
34
|
+
* claimed yet. Queued/deferred/blocked outcomes stay unmarked so the next
|
|
35
|
+
* cycle retries them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pollInboxMentions(deps: InboxDeps): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Re-sync (IMP-562): a wake emitted while the socket was down is LOST
|
|
40
|
+
* (nothing queues it server-side). On every (re)connect, drain the agent
|
|
41
|
+
* inbox and re-wake for assigned tasks still open - the server-side claim
|
|
42
|
+
* guard makes concurrent spawns safe. Also replays inbox.mentions (task +
|
|
43
|
+
* document comment mentions) which used to be consumed and dropped.
|
|
44
|
+
* A drain loop handles >50 item backlogs (server caps each bucket at 50).
|
|
45
|
+
*/
|
|
46
|
+
export declare function resyncInbox(deps: InboxDeps): void;
|