hacklab 0.22.3 → 26.921.1
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/README.md +23 -430
- package/dist/index.js +132 -23
- package/package.json +20 -42
- package/LICENSE +0 -21
- package/dist/agent-handoff.d.ts +0 -51
- package/dist/agent-handoff.d.ts.map +0 -1
- package/dist/agent-handoff.js +0 -91
- package/dist/agent-handoff.js.map +0 -1
- package/dist/api-client.d.ts +0 -18
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-client.js +0 -40
- package/dist/api-client.js.map +0 -1
- package/dist/belt.d.ts +0 -25
- package/dist/belt.d.ts.map +0 -1
- package/dist/belt.js +0 -113
- package/dist/belt.js.map +0 -1
- package/dist/card.d.ts +0 -66
- package/dist/card.d.ts.map +0 -1
- package/dist/card.js +0 -151
- package/dist/card.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -238
- package/dist/cli.js.map +0 -1
- package/dist/commands/book.d.ts +0 -14
- package/dist/commands/book.d.ts.map +0 -1
- package/dist/commands/book.js +0 -90
- package/dist/commands/book.js.map +0 -1
- package/dist/commands/chat.d.ts +0 -36
- package/dist/commands/chat.d.ts.map +0 -1
- package/dist/commands/chat.js +0 -642
- package/dist/commands/chat.js.map +0 -1
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -84
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/daemon.d.ts +0 -19
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -72
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/drop.d.ts +0 -12
- package/dist/commands/drop.d.ts.map +0 -1
- package/dist/commands/drop.js +0 -103
- package/dist/commands/drop.js.map +0 -1
- package/dist/commands/drops.d.ts +0 -9
- package/dist/commands/drops.d.ts.map +0 -1
- package/dist/commands/drops.js +0 -96
- package/dist/commands/drops.js.map +0 -1
- package/dist/commands/essay.d.ts +0 -40
- package/dist/commands/essay.d.ts.map +0 -1
- package/dist/commands/essay.js +0 -651
- package/dist/commands/essay.js.map +0 -1
- package/dist/commands/hackathon.d.ts +0 -2
- package/dist/commands/hackathon.d.ts.map +0 -1
- package/dist/commands/hackathon.js +0 -893
- package/dist/commands/hackathon.js.map +0 -1
- package/dist/commands/hacker.d.ts +0 -2
- package/dist/commands/hacker.d.ts.map +0 -1
- package/dist/commands/hacker.js +0 -87
- package/dist/commands/hacker.js.map +0 -1
- package/dist/commands/jobs.d.ts +0 -18
- package/dist/commands/jobs.d.ts.map +0 -1
- package/dist/commands/jobs.js +0 -138
- package/dist/commands/jobs.js.map +0 -1
- package/dist/commands/keys.d.ts +0 -2
- package/dist/commands/keys.d.ts.map +0 -1
- package/dist/commands/keys.js +0 -138
- package/dist/commands/keys.js.map +0 -1
- package/dist/commands/login.d.ts +0 -83
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -236
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -22
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/org-jobs.d.ts +0 -50
- package/dist/commands/org-jobs.d.ts.map +0 -1
- package/dist/commands/org-jobs.js +0 -383
- package/dist/commands/org-jobs.js.map +0 -1
- package/dist/commands/org.d.ts +0 -67
- package/dist/commands/org.d.ts.map +0 -1
- package/dist/commands/org.js +0 -1244
- package/dist/commands/org.js.map +0 -1
- package/dist/commands/ping.d.ts +0 -2
- package/dist/commands/ping.d.ts.map +0 -1
- package/dist/commands/ping.js +0 -50
- package/dist/commands/ping.js.map +0 -1
- package/dist/commands/profile.d.ts +0 -72
- package/dist/commands/profile.d.ts.map +0 -1
- package/dist/commands/profile.js +0 -672
- package/dist/commands/profile.js.map +0 -1
- package/dist/commands/project.d.ts +0 -2
- package/dist/commands/project.d.ts.map +0 -1
- package/dist/commands/project.js +0 -583
- package/dist/commands/project.js.map +0 -1
- package/dist/commands/referral.d.ts +0 -6
- package/dist/commands/referral.d.ts.map +0 -1
- package/dist/commands/referral.js +0 -93
- package/dist/commands/referral.js.map +0 -1
- package/dist/commands/rtfm.d.ts +0 -9
- package/dist/commands/rtfm.d.ts.map +0 -1
- package/dist/commands/rtfm.js +0 -114
- package/dist/commands/rtfm.js.map +0 -1
- package/dist/commands/scan.d.ts +0 -13
- package/dist/commands/scan.d.ts.map +0 -1
- package/dist/commands/scan.js +0 -286
- package/dist/commands/scan.js.map +0 -1
- package/dist/commands/scout.d.ts +0 -18
- package/dist/commands/scout.d.ts.map +0 -1
- package/dist/commands/scout.js +0 -232
- package/dist/commands/scout.js.map +0 -1
- package/dist/commands/setup-rail.d.ts +0 -58
- package/dist/commands/setup-rail.d.ts.map +0 -1
- package/dist/commands/setup-rail.js +0 -135
- package/dist/commands/setup-rail.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -29
- package/dist/commands/setup.d.ts.map +0 -1
- package/dist/commands/setup.js +0 -442
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/sync.d.ts +0 -9
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -345
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/update.d.ts +0 -2
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -92
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -41
- package/dist/commands/whoami.js.map +0 -1
- package/dist/config.d.ts +0 -78
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -93
- package/dist/config.js.map +0 -1
- package/dist/daily-sync.d.ts +0 -150
- package/dist/daily-sync.d.ts.map +0 -1
- package/dist/daily-sync.js +0 -665
- package/dist/daily-sync.js.map +0 -1
- package/dist/dossier.d.ts +0 -73
- package/dist/dossier.d.ts.map +0 -1
- package/dist/dossier.js +0 -141
- package/dist/dossier.js.map +0 -1
- package/dist/field-normalize.d.ts +0 -4
- package/dist/field-normalize.d.ts.map +0 -1
- package/dist/field-normalize.js +0 -8
- package/dist/field-normalize.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/job-fields.d.ts +0 -47
- package/dist/job-fields.d.ts.map +0 -1
- package/dist/job-fields.js +0 -148
- package/dist/job-fields.js.map +0 -1
- package/dist/machine.d.ts +0 -15
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -64
- package/dist/machine.js.map +0 -1
- package/dist/org-fields.d.ts +0 -57
- package/dist/org-fields.d.ts.map +0 -1
- package/dist/org-fields.js +0 -167
- package/dist/org-fields.js.map +0 -1
- package/dist/posthog.d.ts +0 -38
- package/dist/posthog.d.ts.map +0 -1
- package/dist/posthog.js +0 -224
- package/dist/posthog.js.map +0 -1
- package/dist/project-fields.d.ts +0 -40
- package/dist/project-fields.d.ts.map +0 -1
- package/dist/project-fields.js +0 -79
- package/dist/project-fields.js.map +0 -1
- package/dist/prompt-consent.d.ts +0 -73
- package/dist/prompt-consent.d.ts.map +0 -1
- package/dist/prompt-consent.js +0 -191
- package/dist/prompt-consent.js.map +0 -1
- package/dist/prompt-stats.d.ts +0 -226
- package/dist/prompt-stats.d.ts.map +0 -1
- package/dist/prompt-stats.js +0 -561
- package/dist/prompt-stats.js.map +0 -1
- package/dist/referral.d.ts +0 -14
- package/dist/referral.d.ts.map +0 -1
- package/dist/referral.js +0 -28
- package/dist/referral.js.map +0 -1
- package/dist/registry.d.ts +0 -15
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -180
- package/dist/registry.js.map +0 -1
- package/dist/resolve-command.d.ts +0 -20
- package/dist/resolve-command.d.ts.map +0 -1
- package/dist/resolve-command.js +0 -21
- package/dist/resolve-command.js.map +0 -1
- package/dist/scanners/antigravity.d.ts +0 -41
- package/dist/scanners/antigravity.d.ts.map +0 -1
- package/dist/scanners/antigravity.js +0 -210
- package/dist/scanners/antigravity.js.map +0 -1
- package/dist/scanners/github-copilot-telemetry.d.ts +0 -23
- package/dist/scanners/github-copilot-telemetry.d.ts.map +0 -1
- package/dist/scanners/github-copilot-telemetry.js +0 -220
- package/dist/scanners/github-copilot-telemetry.js.map +0 -1
- package/dist/scanners/github-copilot.d.ts +0 -68
- package/dist/scanners/github-copilot.d.ts.map +0 -1
- package/dist/scanners/github-copilot.js +0 -262
- package/dist/scanners/github-copilot.js.map +0 -1
- package/dist/scanners/incremental.d.ts +0 -282
- package/dist/scanners/incremental.d.ts.map +0 -1
- package/dist/scanners/incremental.js +0 -788
- package/dist/scanners/incremental.js.map +0 -1
- package/dist/scanners/index.d.ts +0 -116
- package/dist/scanners/index.d.ts.map +0 -1
- package/dist/scanners/index.js +0 -726
- package/dist/scanners/index.js.map +0 -1
- package/dist/scanners/sqlite.d.ts +0 -18
- package/dist/scanners/sqlite.d.ts.map +0 -1
- package/dist/scanners/sqlite.js +0 -63
- package/dist/scanners/sqlite.js.map +0 -1
- package/dist/scanners/util.d.ts +0 -112
- package/dist/scanners/util.d.ts.map +0 -1
- package/dist/scanners/util.js +0 -167
- package/dist/scanners/util.js.map +0 -1
- package/dist/session.d.ts +0 -106
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -191
- package/dist/session.js.map +0 -1
- package/dist/share-card-colors.d.ts +0 -19
- package/dist/share-card-colors.d.ts.map +0 -1
- package/dist/share-card-colors.js +0 -36
- package/dist/share-card-colors.js.map +0 -1
- package/dist/share-card.d.ts +0 -31
- package/dist/share-card.d.ts.map +0 -1
- package/dist/share-card.js +0 -380
- package/dist/share-card.js.map +0 -1
- package/dist/share.d.ts +0 -17
- package/dist/share.d.ts.map +0 -1
- package/dist/share.js +0 -75
- package/dist/share.js.map +0 -1
- package/dist/sync.d.ts +0 -100
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js +0 -304
- package/dist/sync.js.map +0 -1
- package/dist/ui.d.ts +0 -33
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -127
- package/dist/ui.js.map +0 -1
- package/dist/utils/npmGlobal.d.ts +0 -30
- package/dist/utils/npmGlobal.d.ts.map +0 -1
- package/dist/utils/npmGlobal.js +0 -69
- package/dist/utils/npmGlobal.js.map +0 -1
- package/dist/utils/openBrowser.d.ts +0 -14
- package/dist/utils/openBrowser.d.ts.map +0 -1
- package/dist/utils/openBrowser.js +0 -47
- package/dist/utils/openBrowser.js.map +0 -1
- package/dist/utils/updateCheck.d.ts +0 -16
- package/dist/utils/updateCheck.d.ts.map +0 -1
- package/dist/utils/updateCheck.js +0 -111
- package/dist/utils/updateCheck.js.map +0 -1
- package/dist/utils/waitForEnter.d.ts +0 -12
- package/dist/utils/waitForEnter.d.ts.map +0 -1
- package/dist/utils/waitForEnter.js +0 -43
- package/dist/utils/waitForEnter.js.map +0 -1
package/dist/config.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
const CONFIG_PATH = join(homedir(), '.hacklab', 'config.json');
|
|
5
|
-
/**
|
|
6
|
-
* Resolve the Cursor credentials from the three places a user can set them,
|
|
7
|
-
* highest priority first:
|
|
8
|
-
*
|
|
9
|
-
* 1. `--cursor-api-key` / `--cursor-email`
|
|
10
|
-
* 2. `CURSOR_API_KEY` / `CURSOR_EMAIL` in the environment
|
|
11
|
-
* 3. `~/.hacklab/config.json` (written by `hacklab config cursor-api-key`)
|
|
12
|
-
*
|
|
13
|
-
* (1) and (2) collapse into one check here because index.ts parks the flags in
|
|
14
|
-
* those same env vars before any command runs — the same trick `--env` uses for
|
|
15
|
-
* HACKLAB_APP_URL. A flag therefore beats an inherited env var for free, and
|
|
16
|
-
* `apiKeySource: 'env'` covers both.
|
|
17
|
-
*
|
|
18
|
-
* The email matters as much as the key: it scopes a *team* key to one member.
|
|
19
|
-
* Without it, Cursor's filtered-usage-events endpoint returns every teammate's
|
|
20
|
-
* events and we'd credit the whole team's tokens to one profile.
|
|
21
|
-
*/
|
|
22
|
-
export async function resolveCursorAuth() {
|
|
23
|
-
const config = await loadConfig();
|
|
24
|
-
const pick = (envName, configValue) => {
|
|
25
|
-
const envValue = process.env[envName]?.trim();
|
|
26
|
-
if (envValue)
|
|
27
|
-
return [envValue, 'env'];
|
|
28
|
-
if (configValue)
|
|
29
|
-
return [configValue, 'config'];
|
|
30
|
-
return [undefined, 'none'];
|
|
31
|
-
};
|
|
32
|
-
const [apiKey, apiKeySource] = pick('CURSOR_API_KEY', config.cursorApiKey);
|
|
33
|
-
const [email, emailSource] = pick('CURSOR_EMAIL', config.cursorEmail);
|
|
34
|
-
return { apiKey, email, apiKeySource, emailSource };
|
|
35
|
-
}
|
|
36
|
-
export async function loadConfig() {
|
|
37
|
-
try {
|
|
38
|
-
const raw = await readFile(CONFIG_PATH, 'utf8');
|
|
39
|
-
return JSON.parse(raw);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export async function saveConfig(config) {
|
|
46
|
-
await mkdir(dirname(CONFIG_PATH), { recursive: true });
|
|
47
|
-
await writeFile(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Read-modify-write the config file for background callers that must not lose
|
|
51
|
-
* the rest of it. Unlike `loadConfig`, which flattens every read failure to
|
|
52
|
-
* `{}`, this refuses to write when the file exists but can't be parsed —
|
|
53
|
-
* spreading `{}` over an unreadable config would silently drop the user's cursor
|
|
54
|
-
* key and prompt-sync consent, and nothing here is worth that.
|
|
55
|
-
*
|
|
56
|
-
* `mutate` returns the config to write, or null for "nothing to change" (no
|
|
57
|
-
* write at all — a background job shouldn't rewrite config.json for nothing).
|
|
58
|
-
* Never throws: resolves true when the config reflects the mutation, false when
|
|
59
|
-
* the write was refused or failed, so the caller can react to not being
|
|
60
|
-
* remembered.
|
|
61
|
-
*/
|
|
62
|
-
export async function updateConfig(mutate) {
|
|
63
|
-
let current = {};
|
|
64
|
-
try {
|
|
65
|
-
const parsed = JSON.parse(await readFile(CONFIG_PATH, 'utf8'));
|
|
66
|
-
// A file that parses to a non-object (`null`, an array, a bare string) is
|
|
67
|
-
// just as unreadable as one that doesn't parse: refuse it too.
|
|
68
|
-
if (typeof parsed !== 'object' ||
|
|
69
|
-
parsed === null ||
|
|
70
|
-
Array.isArray(parsed)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
current = parsed;
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
// No config yet is the normal first-run case; anything else means there IS
|
|
77
|
-
// content we can't see, so leave it alone.
|
|
78
|
-
if (err?.code !== 'ENOENT')
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
const next = mutate(current);
|
|
82
|
-
if (!next)
|
|
83
|
-
return true;
|
|
84
|
-
try {
|
|
85
|
-
await saveConfig(next);
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// Read-only home, no permission, disk full — the caller decides what to say.
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAuCzC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO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W,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuD;IAEvD,IAAI,OAAO,GAAkB,EAAE,CAAA;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAA;QACvE,0EAA0E;QAC1E,+DAA+D;QAC/D,IACE,OAAO,MAAM,KAAK,QAAQ;YAC1B,MAAM,KAAK,IAAI;YACf,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACrB,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,GAAG,MAAuB,CAAA;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,2EAA2E;QAC3E,2CAA2C;QAC3C,IAAK,GAA6B,EAAE,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;IACrE,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC5B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;QACtB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;QAC7E,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
package/dist/daily-sync.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
export type SyncCommand = {
|
|
2
|
-
node: string;
|
|
3
|
-
script: string;
|
|
4
|
-
};
|
|
5
|
-
type ScheduledJobs = {
|
|
6
|
-
mechanism: 'launchd' | 'systemd' | 'schtasks';
|
|
7
|
-
detail: string;
|
|
8
|
-
/** Whether the minutely tick job registered too. Only the schtasks path can
|
|
9
|
-
* come back false: some Windows policies cap task frequency, and a refused
|
|
10
|
-
* tick costs freshness, not the streak — so we keep the daily job and
|
|
11
|
-
* remember not to expect a tick task that will never exist. */
|
|
12
|
-
tick: boolean;
|
|
13
|
-
};
|
|
14
|
-
type InstallFailure = {
|
|
15
|
-
ok: false;
|
|
16
|
-
mechanism: 'manual' | 'unsupported';
|
|
17
|
-
instructions: ManualSchedule;
|
|
18
|
-
};
|
|
19
|
-
export type InstallResult = ({
|
|
20
|
-
ok: true;
|
|
21
|
-
/** Whether we managed to remember this install (see updateConfig). False
|
|
22
|
-
* means the next run can't tell the schedule is current and will reinstall
|
|
23
|
-
* — worth saying out loud rather than churning in silence. */
|
|
24
|
-
recorded: boolean;
|
|
25
|
-
} & ScheduledJobs) | InstallFailure;
|
|
26
|
-
/** The daily background job writes here; launchd/systemd also point stdout+stderr
|
|
27
|
-
* at it. Lives next to the session file so it honors HACKLAB_SESSION_PATH. */
|
|
28
|
-
export declare function syncLogPath(): string;
|
|
29
|
-
export declare const SYNC_LOG_MAX_BYTES = 1000000;
|
|
30
|
-
export declare const SYNC_LOG_KEEP_LINES = 200;
|
|
31
|
-
/** Cut an oversized sync.log down to its last few hundred lines. Best-effort,
|
|
32
|
-
* and a no-op while the log is small — which is the normal case. */
|
|
33
|
-
export declare function trimSyncLog(maxBytes?: number, keepLines?: number): Promise<void>;
|
|
34
|
-
/** Append a timestamped line to the background-sync log (best-effort). */
|
|
35
|
-
export declare function appendSyncLog(line: string): Promise<void>;
|
|
36
|
-
/** Record that the background sync can't continue (e.g. the session expired), so
|
|
37
|
-
* the next interactive `hacklab` run can surface it. */
|
|
38
|
-
export declare function markSyncPaused(reason: string): Promise<void>;
|
|
39
|
-
/** The reason the background sync is paused, or null if it isn't. */
|
|
40
|
-
export declare function readSyncPaused(): Promise<string | null>;
|
|
41
|
-
export declare function clearSyncPaused(): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* An absolute path to *this* node that survives the next upgrade of it.
|
|
44
|
-
*
|
|
45
|
-
* `process.execPath` under a package manager is version-scoped:
|
|
46
|
-
* `/opt/homebrew/Cellar/node/26.5.0/bin/node`. `brew upgrade node` relinks
|
|
47
|
-
* `/opt/homebrew/bin/node` to the new keg and moves the shared libraries with
|
|
48
|
-
* it, leaving the old absolute path resolving to a binary that can no longer
|
|
49
|
-
* start ("Library not loaded: …/libada.3.dylib"). A scheduler holding that path
|
|
50
|
-
* dies silently, which is exactly what happened.
|
|
51
|
-
*
|
|
52
|
-
* So: resolve each well-known stable location and take the first that is
|
|
53
|
-
* *literally the same binary* as the one running now — identity by resolved
|
|
54
|
-
* real path, never by version string and never by trusting the symlink blindly.
|
|
55
|
-
* No match (fnm/nvm/asdf shims are per-shell and version-scoped, so they never
|
|
56
|
-
* match) falls back to `process.execPath`, which is what shipped before.
|
|
57
|
-
*
|
|
58
|
-
* It stays an absolute path either way, never a bare `node`: launchd, systemd
|
|
59
|
-
* and Task Scheduler run with almost no PATH, which is the whole reason this
|
|
60
|
-
* function returns a path at all. Don't "simplify" it to `node`.
|
|
61
|
-
*/
|
|
62
|
-
export declare function stableNodePath(): string;
|
|
63
|
-
/** Absolute `node` + the CLI's own entry script, so the scheduler doesn't depend
|
|
64
|
-
* on a `hacklab` bin being on its PATH. */
|
|
65
|
-
export declare function resolveSyncCommand(): SyncCommand;
|
|
66
|
-
/** Identity of what the jobs were installed with: the command they run plus the
|
|
67
|
-
* template generation that produced them. Stored after a successful install so a
|
|
68
|
-
* later run can tell an up-to-date schedule from one worth replacing. */
|
|
69
|
-
export declare function syncCommandFingerprint(cmd: SyncCommand): string;
|
|
70
|
-
export declare function launchdPlist(cmd: SyncCommand, time: {
|
|
71
|
-
hour: number;
|
|
72
|
-
minute: number;
|
|
73
|
-
}, logPath: string): string;
|
|
74
|
-
/** The minutely tick. StartInterval (not a calendar interval) so launchd just
|
|
75
|
-
* re-runs it every 60s; a tick with nothing to report exits without a request. */
|
|
76
|
-
export declare function launchdTickPlist(cmd: SyncCommand, logPath: string): string;
|
|
77
|
-
export declare function systemdService(cmd: SyncCommand): string;
|
|
78
|
-
export declare function systemdTimer(): string;
|
|
79
|
-
export declare function systemdTickService(cmd: SyncCommand): string;
|
|
80
|
-
export declare function systemdTickTimer(): string;
|
|
81
|
-
/** Where the Windows scheduled task's wrapper batch file lives. Next to the
|
|
82
|
-
* session file so it honors HACKLAB_SESSION_PATH, mirroring syncLogPath(). */
|
|
83
|
-
export declare function syncWrapperPath(): string;
|
|
84
|
-
/** The tick's own wrapper — same pattern, its own file so the two tasks can be
|
|
85
|
-
* created and deleted independently. */
|
|
86
|
-
export declare function tickWrapperPath(): string;
|
|
87
|
-
/** The batch wrapper Task Scheduler runs. schtasks' `/TR` chokes on the nested
|
|
88
|
-
* quotes a full `"node" "script" …` command needs, so we point the task at this
|
|
89
|
-
* one-line .cmd instead and do the quoting here, where plain-batch rules apply.
|
|
90
|
-
* Output is redirected to the same sync.log the job also appends to, so a crash
|
|
91
|
-
* before the CLI's own logging still leaves a trace. */
|
|
92
|
-
export declare function schtasksWrapper(cmd: SyncCommand, logPath: string): string;
|
|
93
|
-
/** Same wrapper for the minutely tick, logging to the same sync.log. */
|
|
94
|
-
export declare function schtasksTickWrapper(cmd: SyncCommand, logPath: string): string;
|
|
95
|
-
/** Args for `schtasks /Create`. The `/TR` value is a single pre-quoted path;
|
|
96
|
-
* spawn must run with windowsVerbatimArguments so Node doesn't re-escape it. */
|
|
97
|
-
export declare function schtasksCreateArgs(wrapperPath: string, time: {
|
|
98
|
-
hour: number;
|
|
99
|
-
minute: number;
|
|
100
|
-
}): string[];
|
|
101
|
-
/** Args for `schtasks /Create` for the tick: every minute, forever. */
|
|
102
|
-
export declare function schtasksTickCreateArgs(wrapperPath: string): string[];
|
|
103
|
-
/** Two jobs the user must schedule by hand, each with the cadence it needs and
|
|
104
|
-
* the full absolute command to run — the paths are long because a scheduler's
|
|
105
|
-
* bare PATH can't find `node` or `hacklab` on its own. */
|
|
106
|
-
export type ManualSchedule = {
|
|
107
|
-
cadence: string;
|
|
108
|
-
command: string;
|
|
109
|
-
}[];
|
|
110
|
-
export declare function manualInstructions(cmd: SyncCommand): ManualSchedule;
|
|
111
|
-
/** Render a ManualSchedule as ready-to-print lines: a dim explainer, then each
|
|
112
|
-
* job as a dim cadence label above its bold, copy-pasteable command. Blank
|
|
113
|
-
* lines separate the two commands so neither reads as a wrapped continuation of
|
|
114
|
-
* the other. */
|
|
115
|
-
export declare function formatManualSchedule(schedule: ManualSchedule): string[];
|
|
116
|
-
/**
|
|
117
|
-
* True when the OS scheduler has the background jobs. A half-install (say a
|
|
118
|
-
* plist that got deleted) reads as not installed, so the next run repairs it.
|
|
119
|
-
*
|
|
120
|
-
* `expectTick: false` drops the tick from that expectation, for the one machine
|
|
121
|
-
* that legitimately has none: a Windows box whose policy refused the minutely
|
|
122
|
-
* task. Without it such a box would read as half-installed forever and reinstall
|
|
123
|
-
* on every scan. Callers that don't know either way get the strict check.
|
|
124
|
-
*/
|
|
125
|
-
export declare function dailySyncInstalled({ expectTick, }?: {
|
|
126
|
-
expectTick?: boolean;
|
|
127
|
-
}): Promise<boolean>;
|
|
128
|
-
/**
|
|
129
|
-
* What a routine run (e.g. `scan`) should do about the background jobs:
|
|
130
|
-
*
|
|
131
|
-
* 'missing' — no jobs, or only half of them: install, and say so.
|
|
132
|
-
* 'stale' — jobs exist but what they run is broken or unknown: reinstall
|
|
133
|
-
* quietly.
|
|
134
|
-
* 'current' — jobs exist and still work: do nothing.
|
|
135
|
-
*
|
|
136
|
-
* "Still work" is deliberately weaker than "match what this process would
|
|
137
|
-
* install": someone alternating node versions or checkouts flips the fingerprint
|
|
138
|
-
* on every run while both schedules remain perfectly runnable, and rebuilding
|
|
139
|
-
* the jobs each way round would be a permanent ping-pong. Only a command that
|
|
140
|
-
* has actually gone missing (or a record we can't read, which includes installs
|
|
141
|
-
* predating the fingerprint) earns a reinstall.
|
|
142
|
-
*/
|
|
143
|
-
export declare function dailySyncState(): Promise<'missing' | 'stale' | 'current'>;
|
|
144
|
-
/** Install (or refresh) both background jobs (tick + daily) for the current OS. */
|
|
145
|
-
export declare function installDailySync(): Promise<InstallResult>;
|
|
146
|
-
/** Remove both background jobs. Best-effort and never throws, so it's safe to
|
|
147
|
-
* call from `logout` whether or not they were ever installed. */
|
|
148
|
-
export declare function uninstallDailySync(): Promise<void>;
|
|
149
|
-
export {};
|
|
150
|
-
//# sourceMappingURL=daily-sync.d.ts.map
|
package/dist/daily-sync.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daily-sync.d.ts","sourceRoot":"","sources":["../src/daily-sync.ts"],"names":[],"mappings":"AA2CA,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd;;;mEAG+D;IAC/D,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,KAAK,CAAA;IACT,SAAS,EAAE,QAAQ,GAAG,aAAa,CAAA;IACnC,YAAY,EAAE,cAAc,CAAA;CAC7B,CAAA;AAKD,MAAM,MAAM,aAAa,GACrB,CAAC;IACC,EAAE,EAAE,IAAI,CAAA;IACR;;kEAE8D;IAC9D,QAAQ,EAAE,OAAO,CAAA;CAClB,GAAG,aAAa,CAAC,GAClB,cAAc,CAAA;AAgBlB;8EAC8E;AAC9E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAQD,eAAO,MAAM,kBAAkB,UAAY,CAAA;AAC3C,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC;oEACoE;AACpE,wBAAsB,WAAW,CAC/B,QAAQ,SAAqB,EAC7B,SAAS,SAAsB,GAC9B,OAAO,CAAC,IAAI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