@tidegap/cli 0.0.0-stage → 0.19.0
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/LICENSE +201 -0
- package/README.md +136 -2
- package/dist/commands/clients.d.ts +20 -0
- package/dist/commands/clients.d.ts.map +1 -0
- package/dist/commands/clients.js +36 -0
- package/dist/commands/clients.js.map +1 -0
- package/dist/commands/env-file.d.ts +54 -0
- package/dist/commands/env-file.d.ts.map +1 -0
- package/dist/commands/env-file.js +153 -0
- package/dist/commands/env-file.js.map +1 -0
- package/dist/commands/install.d.ts +83 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +297 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/queue.d.ts +139 -0
- package/dist/commands/queue.d.ts.map +1 -0
- package/dist/commands/queue.js +491 -0
- package/dist/commands/queue.js.map +1 -0
- package/dist/commands/receipts.d.ts +15 -0
- package/dist/commands/receipts.d.ts.map +1 -0
- package/dist/commands/receipts.js +70 -0
- package/dist/commands/receipts.js.map +1 -0
- package/dist/commands/register-wake.d.ts +21 -0
- package/dist/commands/register-wake.d.ts.map +1 -0
- package/dist/commands/register-wake.js +76 -0
- package/dist/commands/register-wake.js.map +1 -0
- package/dist/commands/stats.d.ts +31 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +165 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/tick.d.ts +73 -0
- package/dist/commands/tick.d.ts.map +1 -0
- package/dist/commands/tick.js +294 -0
- package/dist/commands/tick.js.map +1 -0
- package/dist/commands/ui.d.ts +33 -0
- package/dist/commands/ui.d.ts.map +1 -0
- package/dist/commands/ui.js +119 -0
- package/dist/commands/ui.js.map +1 -0
- package/dist/commands/verify.d.ts +32 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +135 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/env.d.ts +57 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +105 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +366 -0
- package/dist/index.js.map +1 -0
- package/dist/platform/index.d.ts +30 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +66 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/linux.d.ts +81 -0
- package/dist/platform/linux.d.ts.map +1 -0
- package/dist/platform/linux.js +158 -0
- package/dist/platform/linux.js.map +1 -0
- package/dist/platform/macos.d.ts +69 -0
- package/dist/platform/macos.d.ts.map +1 -0
- package/dist/platform/macos.js +151 -0
- package/dist/platform/macos.js.map +1 -0
- package/dist/platform/windows.d.ts +31 -0
- package/dist/platform/windows.d.ts.map +1 -0
- package/dist/platform/windows.js +58 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/ui/api.d.ts +66 -0
- package/dist/ui/api.d.ts.map +1 -0
- package/dist/ui/api.js +613 -0
- package/dist/ui/api.js.map +1 -0
- package/dist/ui/clients.d.ts +65 -0
- package/dist/ui/clients.d.ts.map +1 -0
- package/dist/ui/clients.js +179 -0
- package/dist/ui/clients.js.map +1 -0
- package/dist/ui/discovery.d.ts +25 -0
- package/dist/ui/discovery.d.ts.map +1 -0
- package/dist/ui/discovery.js +46 -0
- package/dist/ui/discovery.js.map +1 -0
- package/dist/ui/dispatcher.d.ts +84 -0
- package/dist/ui/dispatcher.d.ts.map +1 -0
- package/dist/ui/dispatcher.js +150 -0
- package/dist/ui/dispatcher.js.map +1 -0
- package/dist/ui/events.d.ts +27 -0
- package/dist/ui/events.d.ts.map +1 -0
- package/dist/ui/events.js +85 -0
- package/dist/ui/events.js.map +1 -0
- package/dist/ui/server.d.ts +84 -0
- package/dist/ui/server.d.ts.map +1 -0
- package/dist/ui/server.js +322 -0
- package/dist/ui/server.js.map +1 -0
- package/dist/ui/summary.d.ts +47 -0
- package/dist/ui/summary.d.ts.map +1 -0
- package/dist/ui/summary.js +120 -0
- package/dist/ui/summary.js.map +1 -0
- package/package.json +53 -3
- package/ui/agenda.js +256 -0
- package/ui/api.js +114 -0
- package/ui/app.css +713 -0
- package/ui/app.js +599 -0
- package/ui/clients.js +104 -0
- package/ui/detail.js +431 -0
- package/ui/dialog.js +284 -0
- package/ui/dnd.js +131 -0
- package/ui/dom.js +255 -0
- package/ui/index.html +38 -0
- package/ui/journal.js +207 -0
- package/ui/keys.js +92 -0
- package/ui/row.js +153 -0
- package/ui/state.js +412 -0
- package/ui/timeline.js +202 -0
- package/ui/toast.js +69 -0
- package/ui/tokens.css +108 -0
- package/ui/views.js +31 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tidegap install` — write a launchd plist (macOS) or systemd user units
|
|
3
|
+
* (Linux). Windows is not auto-installed: it prints a ready-to-paste
|
|
4
|
+
* `schtasks` command instead.
|
|
5
|
+
*
|
|
6
|
+
* The daemon's invocation is resolved at install time to
|
|
7
|
+
* `[process.execPath, realpathSync(process.argv[1])]` — the exact node
|
|
8
|
+
* interpreter plus the real dist entry. This is immune to launchd's bare
|
|
9
|
+
* PATH and to `#!/usr/bin/env node` shebangs (the historical bug: a
|
|
10
|
+
* hardcoded `/usr/local/bin/ebb` (0.17 name) that does not exist on Apple Silicon /
|
|
11
|
+
* homebrew / nvm). `TIDEGAP_BINARY` remains as a documented override.
|
|
12
|
+
*
|
|
13
|
+
* A 0.17 unit (`com.ebb-ai.tick`, `ebb-tick.timer`) is detected, never
|
|
14
|
+
* removed: the next steps print the commands that unload and remove it.
|
|
15
|
+
*
|
|
16
|
+
* In --laptop mode we additionally drop a tiny helper script and print
|
|
17
|
+
* the wake-event story (which needs a sudoers entry); --server skips it.
|
|
18
|
+
*/
|
|
19
|
+
import { type PlatformName } from "../platform/index.js";
|
|
20
|
+
export type InstallMode = "laptop" | "server";
|
|
21
|
+
export interface InstallOptions {
|
|
22
|
+
mode: InstallMode;
|
|
23
|
+
/** Override platform detection (tests). */
|
|
24
|
+
platform?: PlatformName;
|
|
25
|
+
/**
|
|
26
|
+
* Override the resolved launcher argv (tests). When set, this is used
|
|
27
|
+
* verbatim as the leading `ProgramArguments` / `ExecStart` tokens
|
|
28
|
+
* instead of resolving `process.execPath` + the real script path.
|
|
29
|
+
*/
|
|
30
|
+
launcher?: string[];
|
|
31
|
+
/** Override the SQLite path (tests). */
|
|
32
|
+
dbPath?: string;
|
|
33
|
+
/** Override the tick interval. Defaults to 300s. */
|
|
34
|
+
tickIntervalSec?: number;
|
|
35
|
+
/** If true, do not write any files; only return the rendered strings. */
|
|
36
|
+
dryRun?: boolean;
|
|
37
|
+
/** Override the home directory (tests). */
|
|
38
|
+
home?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface InstallArtifacts {
|
|
41
|
+
platform: PlatformName;
|
|
42
|
+
/** Resolved launcher argv used for the daemon invocation. */
|
|
43
|
+
launcher: string[];
|
|
44
|
+
/** Warnings surfaced during resolution (e.g. a launcher path that does not exist). */
|
|
45
|
+
warnings: string[];
|
|
46
|
+
/** Path to the standardized secrets file (~/.config/tidegap/env). */
|
|
47
|
+
envFilePath: string;
|
|
48
|
+
/** True when this run created the secrets file. */
|
|
49
|
+
envFileCreated: boolean;
|
|
50
|
+
/** Where the daemon writes its log (`~/.tidegap/logs/tick.log`). */
|
|
51
|
+
logPath: string;
|
|
52
|
+
/** Path that would be written, or "" for non-macOS. */
|
|
53
|
+
plistPath: string;
|
|
54
|
+
/** The rendered plist XML, or "" for non-macOS. */
|
|
55
|
+
plistContent: string;
|
|
56
|
+
/** Path for the systemd `.service` unit, or "" for non-linux. */
|
|
57
|
+
servicePath: string;
|
|
58
|
+
/** The rendered `.service` unit content, or "" for non-linux. */
|
|
59
|
+
serviceContent: string;
|
|
60
|
+
/** Path for the systemd `.timer` unit, or "" for non-linux. */
|
|
61
|
+
timerPath: string;
|
|
62
|
+
/** The rendered `.timer` unit content, or "" for non-linux. */
|
|
63
|
+
timerContent: string;
|
|
64
|
+
/** Path for the laptop-wake helper script, or "" if --server or unsupported. */
|
|
65
|
+
helperPath: string;
|
|
66
|
+
/** Rendered helper script content, or "" if --server or unsupported. */
|
|
67
|
+
helperContent: string;
|
|
68
|
+
/** Human-facing next-steps message. */
|
|
69
|
+
nextSteps: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the daemon invocation. Preference order:
|
|
73
|
+
* 1. explicit `override` (tests),
|
|
74
|
+
* 2. `TIDEGAP_BINARY` env — a single documented override binary,
|
|
75
|
+
* 3. `[process.execPath, realpathSync(process.argv[1])]` — pin the
|
|
76
|
+
* exact node + the real dist entry.
|
|
77
|
+
*
|
|
78
|
+
* Pushes a loud warning onto `warnings` if a resolved path does not
|
|
79
|
+
* exist on disk.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveLauncher(override: string[] | undefined, warnings: string[]): string[];
|
|
82
|
+
export declare function runInstall(opts: InstallOptions): Promise<InstallArtifacts>;
|
|
83
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAO9B,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,YAAY,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sFAAsF;IACtF,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,cAAc,EAAE,OAAO,CAAC;IACxB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,EAAE,CAiDV;AAmCD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA4M3B"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tidegap install` — write a launchd plist (macOS) or systemd user units
|
|
3
|
+
* (Linux). Windows is not auto-installed: it prints a ready-to-paste
|
|
4
|
+
* `schtasks` command instead.
|
|
5
|
+
*
|
|
6
|
+
* The daemon's invocation is resolved at install time to
|
|
7
|
+
* `[process.execPath, realpathSync(process.argv[1])]` — the exact node
|
|
8
|
+
* interpreter plus the real dist entry. This is immune to launchd's bare
|
|
9
|
+
* PATH and to `#!/usr/bin/env node` shebangs (the historical bug: a
|
|
10
|
+
* hardcoded `/usr/local/bin/ebb` (0.17 name) that does not exist on Apple Silicon /
|
|
11
|
+
* homebrew / nvm). `TIDEGAP_BINARY` remains as a documented override.
|
|
12
|
+
*
|
|
13
|
+
* A 0.17 unit (`com.ebb-ai.tick`, `ebb-tick.timer`) is detected, never
|
|
14
|
+
* removed: the next steps print the commands that unload and remove it.
|
|
15
|
+
*
|
|
16
|
+
* In --laptop mode we additionally drop a tiny helper script and print
|
|
17
|
+
* the wake-event story (which needs a sudoers entry); --server skips it.
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, mkdirSync, realpathSync, writeFileSync, } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { homedir } from "node:os";
|
|
22
|
+
import { resolveTidegapHome, TIDEGAP_HOME_DIR } from "@tidegap/core";
|
|
23
|
+
import { readEnvCredentials } from "../env.js";
|
|
24
|
+
import { currentPlatform, } from "../platform/index.js";
|
|
25
|
+
import { LAUNCHD_LABEL, LEGACY_LAUNCHD_LABEL, launchdPlist } from "../platform/macos.js";
|
|
26
|
+
import { LEGACY_SYSTEMD_UNIT, SYSTEMD_UNIT, systemdService, systemdTimer } from "../platform/linux.js";
|
|
27
|
+
import { schtasksTemplate } from "../platform/windows.js";
|
|
28
|
+
import { defaultDbPath } from "./tick.js";
|
|
29
|
+
import { ensureEnvFile, envFilePath, oldEnvFileNotice } from "./env-file.js";
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the daemon invocation. Preference order:
|
|
32
|
+
* 1. explicit `override` (tests),
|
|
33
|
+
* 2. `TIDEGAP_BINARY` env — a single documented override binary,
|
|
34
|
+
* 3. `[process.execPath, realpathSync(process.argv[1])]` — pin the
|
|
35
|
+
* exact node + the real dist entry.
|
|
36
|
+
*
|
|
37
|
+
* Pushes a loud warning onto `warnings` if a resolved path does not
|
|
38
|
+
* exist on disk.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveLauncher(override, warnings) {
|
|
41
|
+
if (override && override.length > 0)
|
|
42
|
+
return override;
|
|
43
|
+
const envBinary = readEnvCredentials().binary;
|
|
44
|
+
if (envBinary) {
|
|
45
|
+
if (!existsSync(envBinary)) {
|
|
46
|
+
warnings.push(`TIDEGAP_BINARY points at ${envBinary}, which does not exist — the daemon will fail to launch.`);
|
|
47
|
+
}
|
|
48
|
+
return [envBinary];
|
|
49
|
+
}
|
|
50
|
+
const node = process.execPath;
|
|
51
|
+
const argv1 = process.argv[1];
|
|
52
|
+
let script;
|
|
53
|
+
if (argv1) {
|
|
54
|
+
try {
|
|
55
|
+
script = realpathSync(argv1);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
script = argv1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!script) {
|
|
62
|
+
warnings.push("Could not resolve the tidegap entry script (process.argv[1] was empty); " +
|
|
63
|
+
"set TIDEGAP_BINARY to the tidegap executable and re-run.");
|
|
64
|
+
return [node];
|
|
65
|
+
}
|
|
66
|
+
if (!existsSync(node)) {
|
|
67
|
+
warnings.push(`Resolved node interpreter ${node} does not exist — the daemon will fail to launch.`);
|
|
68
|
+
}
|
|
69
|
+
if (!existsSync(script)) {
|
|
70
|
+
warnings.push(`Resolved tidegap entry ${script} does not exist — the daemon will fail to launch.`);
|
|
71
|
+
}
|
|
72
|
+
if (/[\\/]@ebb-ai[\\/]cli[\\/]/.test(script)) {
|
|
73
|
+
// Run through the @ebb-ai/cli 0.17.1 shim: the unit would pin a copy
|
|
74
|
+
// inside @ebb-ai/cli and break when that package is uninstalled.
|
|
75
|
+
warnings.push(`The daemon would run ${script}, inside the deprecated @ebb-ai/cli package; it stops working after ` +
|
|
76
|
+
"`npm uninstall -g @ebb-ai/cli`. Run `npm install -g @tidegap/cli`, then `tidegap install` again.");
|
|
77
|
+
}
|
|
78
|
+
return [node, script];
|
|
79
|
+
}
|
|
80
|
+
/** Shell-quote a single argv token for embedding in the helper script. */
|
|
81
|
+
function shq(s) {
|
|
82
|
+
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
83
|
+
}
|
|
84
|
+
function helperScript(opts) {
|
|
85
|
+
const tidegap = opts.launcher.map(shq).join(" ");
|
|
86
|
+
const db = shq(opts.dbPath);
|
|
87
|
+
return `#!/usr/bin/env bash
|
|
88
|
+
# laptop-wake.sh — register wake events for newly-scheduled Tidegap tasks.
|
|
89
|
+
# Generated by \`tidegap install --laptop\`. Re-run any time.
|
|
90
|
+
|
|
91
|
+
set -euo pipefail
|
|
92
|
+
|
|
93
|
+
DB=${db}
|
|
94
|
+
TIDEGAP=(${tidegap})
|
|
95
|
+
|
|
96
|
+
# List scheduled tasks and extract their task ids. The queue table has a
|
|
97
|
+
# header row + a separator row, so we skip the first two lines (\`tail -n
|
|
98
|
+
# +3\`); the id is the first whitespace-delimited column. \`--db "$DB"\` is
|
|
99
|
+
# passed to BOTH invocations so a custom queue path is honoured.
|
|
100
|
+
# register-wake needs a sudoers entry for pmset/rtcwake; it prints the
|
|
101
|
+
# exact command if not authorized.
|
|
102
|
+
"\${TIDEGAP[@]}" queue list --db "$DB" --status scheduled \\
|
|
103
|
+
| tail -n +3 \\
|
|
104
|
+
| awk 'NF { print $1 }' \\
|
|
105
|
+
| while read -r TASK_ID; do
|
|
106
|
+
[ -n "$TASK_ID" ] || continue
|
|
107
|
+
"\${TIDEGAP[@]}" register-wake --db "$DB" "$TASK_ID" || true
|
|
108
|
+
done
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
export async function runInstall(opts) {
|
|
112
|
+
const platform = opts.platform ?? currentPlatform();
|
|
113
|
+
const home = opts.home ?? homedir();
|
|
114
|
+
const warnings = [];
|
|
115
|
+
const launcher = resolveLauncher(opts.launcher, warnings);
|
|
116
|
+
// A real install names a left-over 0.17 ~/.ebb-ai on stderr; a dry run
|
|
117
|
+
// touches nothing.
|
|
118
|
+
const dataHome = opts.dryRun
|
|
119
|
+
? join(home, TIDEGAP_HOME_DIR)
|
|
120
|
+
: resolveTidegapHome(opts.home !== undefined ? { home } : {});
|
|
121
|
+
const dbPath = opts.dbPath ?? (opts.dryRun || opts.home !== undefined ? join(dataHome, "queue.db") : defaultDbPath());
|
|
122
|
+
const logPath = join(dataHome, "logs", "tick.log");
|
|
123
|
+
const tickInterval = opts.tickIntervalSec ?? 300;
|
|
124
|
+
// Create the standardized secrets file (0600) if absent. Never on dry-run
|
|
125
|
+
// (tests). A 0.17 secrets file left alone is named under the warnings.
|
|
126
|
+
const envPath = envFilePath(home);
|
|
127
|
+
const oldEnvNotice = oldEnvFileNotice(home);
|
|
128
|
+
if (oldEnvNotice)
|
|
129
|
+
warnings.push(oldEnvNotice);
|
|
130
|
+
let envFileCreated = false;
|
|
131
|
+
if (!opts.dryRun)
|
|
132
|
+
envFileCreated = ensureEnvFile(envPath).created;
|
|
133
|
+
const secretsNote = `\nProvider keys: ${envFileCreated ? "created" : "expected at"} ${envPath} (0600).\n` +
|
|
134
|
+
` Add ANTHROPIC_API_KEY / OPENAI_API_KEY there; \`tidegap tick\` loads it on startup.`;
|
|
135
|
+
const warnBlock = warnings.length > 0
|
|
136
|
+
? `\n!! WARNING:\n` +
|
|
137
|
+
warnings.map((w) => ` - ${w}`).join("\n") +
|
|
138
|
+
`\n`
|
|
139
|
+
: "";
|
|
140
|
+
if (platform === "macos") {
|
|
141
|
+
const plistContent = launchdPlist({
|
|
142
|
+
tickIntervalSec: tickInterval,
|
|
143
|
+
launcher,
|
|
144
|
+
dbPath,
|
|
145
|
+
logPath,
|
|
146
|
+
});
|
|
147
|
+
const agentsDir = join(home, "Library", "LaunchAgents");
|
|
148
|
+
const plistPath = join(agentsDir, `${LAUNCHD_LABEL}.plist`);
|
|
149
|
+
const legacyPlist = join(agentsDir, `${LEGACY_LAUNCHD_LABEL}.plist`);
|
|
150
|
+
const helperContent = opts.mode === "laptop" ? helperScript({ launcher, dbPath }) : "";
|
|
151
|
+
const helperPath = opts.mode === "laptop" ? join(dataHome, "laptop-wake.sh") : "";
|
|
152
|
+
if (!opts.dryRun) {
|
|
153
|
+
// launchd does not create the StandardOutPath parent directory.
|
|
154
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
155
|
+
mkdirSync(dirname(plistPath), { recursive: true });
|
|
156
|
+
writeFileSync(plistPath, plistContent, "utf8");
|
|
157
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
158
|
+
if (helperPath) {
|
|
159
|
+
mkdirSync(dirname(helperPath), { recursive: true });
|
|
160
|
+
writeFileSync(helperPath, helperContent, {
|
|
161
|
+
encoding: "utf8",
|
|
162
|
+
mode: 0o755,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const wakeNote = opts.mode === "laptop"
|
|
167
|
+
? `\n3. Pre-register wake events as tasks are scheduled:\n` +
|
|
168
|
+
` ${helperPath}\n` +
|
|
169
|
+
` (Requires a sudoers entry so \`pmset schedule wake\` runs without a\n` +
|
|
170
|
+
` password prompt — see \`tidegap register-wake\` output for the exact line.)`
|
|
171
|
+
: "";
|
|
172
|
+
const cleanup = existsSync(legacyPlist)
|
|
173
|
+
? `\n${opts.mode === "laptop" ? 4 : 3}. Remove the 0.17 agent (it ticks the same ledger):\n` +
|
|
174
|
+
` launchctl unload ${legacyPlist}\n` +
|
|
175
|
+
` rm ${legacyPlist}`
|
|
176
|
+
: "";
|
|
177
|
+
const nextSteps = warnBlock +
|
|
178
|
+
`Wrote ${plistPath}.\n` +
|
|
179
|
+
secretsNote +
|
|
180
|
+
`\n\nNext steps:\n` +
|
|
181
|
+
`1. Reload launchd:\n` +
|
|
182
|
+
` launchctl load ${plistPath}\n` +
|
|
183
|
+
`2. (optional) Tail the log:\n` +
|
|
184
|
+
` tail -f ${logPath}${wakeNote}${cleanup}\n`;
|
|
185
|
+
return {
|
|
186
|
+
platform,
|
|
187
|
+
launcher,
|
|
188
|
+
warnings,
|
|
189
|
+
envFilePath: envPath,
|
|
190
|
+
envFileCreated,
|
|
191
|
+
logPath,
|
|
192
|
+
plistPath,
|
|
193
|
+
plistContent,
|
|
194
|
+
servicePath: "",
|
|
195
|
+
serviceContent: "",
|
|
196
|
+
timerPath: "",
|
|
197
|
+
timerContent: "",
|
|
198
|
+
helperPath,
|
|
199
|
+
helperContent,
|
|
200
|
+
nextSteps,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (platform === "linux") {
|
|
204
|
+
const serviceContent = systemdService({
|
|
205
|
+
launcher,
|
|
206
|
+
dbPath,
|
|
207
|
+
logPath,
|
|
208
|
+
});
|
|
209
|
+
const timerContent = systemdTimer({
|
|
210
|
+
tickIntervalSec: tickInterval,
|
|
211
|
+
});
|
|
212
|
+
const systemdDir = join(home, ".config", "systemd", "user");
|
|
213
|
+
const servicePath = join(systemdDir, `${SYSTEMD_UNIT}.service`);
|
|
214
|
+
const timerPath = join(systemdDir, `${SYSTEMD_UNIT}.timer`);
|
|
215
|
+
const legacyService = join(systemdDir, `${LEGACY_SYSTEMD_UNIT}.service`);
|
|
216
|
+
const legacyTimer = join(systemdDir, `${LEGACY_SYSTEMD_UNIT}.timer`);
|
|
217
|
+
const helperContent = opts.mode === "laptop" ? helperScript({ launcher, dbPath }) : "";
|
|
218
|
+
const helperPath = opts.mode === "laptop" ? join(dataHome, "laptop-wake.sh") : "";
|
|
219
|
+
if (!opts.dryRun) {
|
|
220
|
+
// systemd `StandardOutput=append:` does not create the parent directory.
|
|
221
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
222
|
+
mkdirSync(systemdDir, { recursive: true });
|
|
223
|
+
writeFileSync(servicePath, serviceContent, "utf8");
|
|
224
|
+
writeFileSync(timerPath, timerContent, "utf8");
|
|
225
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
226
|
+
if (helperPath) {
|
|
227
|
+
mkdirSync(dirname(helperPath), { recursive: true });
|
|
228
|
+
writeFileSync(helperPath, helperContent, {
|
|
229
|
+
encoding: "utf8",
|
|
230
|
+
mode: 0o755,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const wakeNote = opts.mode === "laptop"
|
|
235
|
+
? `\n3. Pre-register wake events as tasks are scheduled:\n` +
|
|
236
|
+
` ${helperPath}\n` +
|
|
237
|
+
` (Requires a sudoers entry so \`rtcwake\` runs without a password\n` +
|
|
238
|
+
` prompt — see \`tidegap register-wake\` output for the exact line.)`
|
|
239
|
+
: "";
|
|
240
|
+
const cleanup = existsSync(legacyTimer) || existsSync(legacyService)
|
|
241
|
+
? `\n${opts.mode === "laptop" ? 4 : 3}. Remove the 0.17 timer (it ticks the same ledger):\n` +
|
|
242
|
+
` systemctl --user disable --now ${LEGACY_SYSTEMD_UNIT}.timer\n` +
|
|
243
|
+
` rm ${legacyService} ${legacyTimer}\n` +
|
|
244
|
+
` systemctl --user daemon-reload`
|
|
245
|
+
: "";
|
|
246
|
+
const nextSteps = warnBlock +
|
|
247
|
+
`Wrote ${servicePath}\n` +
|
|
248
|
+
`Wrote ${timerPath}` +
|
|
249
|
+
secretsNote +
|
|
250
|
+
`\n\nNext steps:\n` +
|
|
251
|
+
`1. Reload systemd and enable the timer:\n` +
|
|
252
|
+
` systemctl --user daemon-reload && systemctl --user enable --now ${SYSTEMD_UNIT}.timer\n` +
|
|
253
|
+
`2. (optional) Tail the log:\n` +
|
|
254
|
+
` tail -f ${logPath}${wakeNote}${cleanup}\n`;
|
|
255
|
+
return {
|
|
256
|
+
platform,
|
|
257
|
+
launcher,
|
|
258
|
+
warnings,
|
|
259
|
+
envFilePath: envPath,
|
|
260
|
+
envFileCreated,
|
|
261
|
+
logPath,
|
|
262
|
+
plistPath: "",
|
|
263
|
+
plistContent: "",
|
|
264
|
+
servicePath,
|
|
265
|
+
serviceContent,
|
|
266
|
+
timerPath,
|
|
267
|
+
timerContent,
|
|
268
|
+
helperPath,
|
|
269
|
+
helperContent,
|
|
270
|
+
nextSteps,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
// windows — no auto-install; print a ready-to-paste schtasks command.
|
|
274
|
+
const template = schtasksTemplate({
|
|
275
|
+
launcher,
|
|
276
|
+
dbPath,
|
|
277
|
+
tickIntervalSec: tickInterval,
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
platform,
|
|
281
|
+
launcher,
|
|
282
|
+
warnings,
|
|
283
|
+
envFilePath: envPath,
|
|
284
|
+
envFileCreated,
|
|
285
|
+
logPath,
|
|
286
|
+
plistPath: "",
|
|
287
|
+
plistContent: "",
|
|
288
|
+
servicePath: "",
|
|
289
|
+
serviceContent: "",
|
|
290
|
+
timerPath: "",
|
|
291
|
+
timerContent: "",
|
|
292
|
+
helperPath: "",
|
|
293
|
+
helperContent: "",
|
|
294
|
+
nextSteps: warnBlock + template,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,E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ChB,WAAW,EAAE,EAAE;QACf,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,EAAE;QACjB,SAAS,EAAE,SAAS,GAAG,QAAQ;KAChC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tidegap queue list | show | unread` — inspect the ledger.
|
|
3
|
+
* `tidegap queue cancel | reschedule | run-now | reply` — change it (ui v2).
|
|
4
|
+
* Writes go through a `Scheduler` without adapters: they never dispatch;
|
|
5
|
+
* the dispatcher (`tidegap tick` or the OpenClaw loop) runs the task.
|
|
6
|
+
*
|
|
7
|
+
* We deliberately avoid a table-printing dependency. Columns are
|
|
8
|
+
* padded with String.prototype.padEnd to a fixed width.
|
|
9
|
+
*
|
|
10
|
+
* Every task string printed here (title, prompt, result, error, ids) is
|
|
11
|
+
* untrusted: it comes from prompts and model output. It goes through
|
|
12
|
+
* `stripControlChars` so it cannot carry terminal escape sequences.
|
|
13
|
+
*/
|
|
14
|
+
import { Scheduler } from "@tidegap/core";
|
|
15
|
+
import type { DeadlineKind, GridFeed, QuotaResetConfig, TaskRecord, TaskStatus } from "@tidegap/core";
|
|
16
|
+
export declare const VALID_STATUSES: ReadonlySet<TaskStatus>;
|
|
17
|
+
export declare const VALID_KINDS: ReadonlySet<DeadlineKind>;
|
|
18
|
+
export interface QueueListOptions {
|
|
19
|
+
db?: string;
|
|
20
|
+
status?: string;
|
|
21
|
+
/** Only finished (completed / failed) tasks nobody has viewed yet. */
|
|
22
|
+
unread?: boolean;
|
|
23
|
+
/** `absolute` or `quota_reset`. */
|
|
24
|
+
kind?: string;
|
|
25
|
+
json?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* SessionStart-hook mode: one line naming the unread count, or nothing.
|
|
28
|
+
* Never throws; a missing or unreadable ledger prints nothing.
|
|
29
|
+
*/
|
|
30
|
+
hook?: boolean;
|
|
31
|
+
/** Only the occurrences of this series, oldest first (ui v2). */
|
|
32
|
+
series?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface QueueListResult {
|
|
35
|
+
rows: TaskRecord<unknown>[];
|
|
36
|
+
rendered: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function renderQueue(rows: TaskRecord<unknown>[], opts?: {
|
|
39
|
+
lastTickAt?: string;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* The fields `queue list --json` and the `tidegap ui` list API print per task
|
|
43
|
+
* (no prompt, no result).
|
|
44
|
+
*/
|
|
45
|
+
export declare function taskSummary(r: TaskRecord<unknown>): Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Provider and model of a task: what ran (receipt) when it finished, else
|
|
48
|
+
* what the stored body asks for. Closure tasks have neither.
|
|
49
|
+
*/
|
|
50
|
+
export declare function taskProviderModel(r: TaskRecord<unknown>): {
|
|
51
|
+
provider?: string;
|
|
52
|
+
model?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The Claude Code SessionStart line: `N unread Tidegap task(s), run `tidegap ui``,
|
|
56
|
+
* or "" when nothing is unread. It names no task text, so nothing from a
|
|
57
|
+
* prompt or a model reply reaches the session context.
|
|
58
|
+
*/
|
|
59
|
+
export declare function renderHookLine(unreadCount: number): string;
|
|
60
|
+
export declare function runQueueList(opts?: QueueListOptions): Promise<QueueListResult>;
|
|
61
|
+
export interface QueueShowOptions {
|
|
62
|
+
db?: string;
|
|
63
|
+
/** Include the raw vendor payload (`result.raw`). */
|
|
64
|
+
raw?: boolean;
|
|
65
|
+
json?: boolean;
|
|
66
|
+
/** Default true: viewing a finished task marks it read. */
|
|
67
|
+
markRead?: boolean;
|
|
68
|
+
/** Override the ~/.tidegap/config path (tests). */
|
|
69
|
+
config?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface QueueShowResult {
|
|
72
|
+
record: TaskRecord<unknown>;
|
|
73
|
+
rendered: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function rawPayload(record: TaskRecord<unknown>): unknown;
|
|
76
|
+
/** Render one task in text, the CLI twin of the `tidegap ui` detail view. */
|
|
77
|
+
export declare function renderTask(record: TaskRecord<unknown>, opts?: {
|
|
78
|
+
raw?: boolean;
|
|
79
|
+
quota?: QuotaResetConfig;
|
|
80
|
+
children?: readonly string[];
|
|
81
|
+
}): string;
|
|
82
|
+
/**
|
|
83
|
+
* `tidegap queue show <id>`: print one task. A completed or failed task is
|
|
84
|
+
* marked read unless `markRead` is false. Throws on an unknown id.
|
|
85
|
+
*/
|
|
86
|
+
export declare function runQueueShow(taskId: string, opts?: QueueShowOptions): Promise<QueueShowResult>;
|
|
87
|
+
export declare function withoutRaw(result: unknown): unknown;
|
|
88
|
+
/**
|
|
89
|
+
* `tidegap queue unread <id>`: clear a task's read marker so it shows in the
|
|
90
|
+
* inbox again. Throws on an unknown id.
|
|
91
|
+
*/
|
|
92
|
+
export declare function runQueueUnread(taskId: string, opts?: {
|
|
93
|
+
db?: string;
|
|
94
|
+
}): Promise<string>;
|
|
95
|
+
/** Occurrences of one series in order: the series id first, then `~2`, `~3`… */
|
|
96
|
+
export declare function sortSeries(rows: TaskRecord<unknown>[]): TaskRecord<unknown>[];
|
|
97
|
+
export interface QueueWriteOptions {
|
|
98
|
+
db?: string;
|
|
99
|
+
region?: string;
|
|
100
|
+
/** Inject a grid feed (tests); default: the same feed `tidegap tick` builds. */
|
|
101
|
+
feed?: GridFeed;
|
|
102
|
+
now?: () => Date;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The scheduler every write path uses (`tidegap queue` writes and `tidegap ui`): the
|
|
106
|
+
* ledger, the default grid feed and the quota config, and NO adapters, so a
|
|
107
|
+
* write can never dispatch a provider call. Signing is off for the same
|
|
108
|
+
* reason: no receipt is produced here.
|
|
109
|
+
*/
|
|
110
|
+
export declare function actionScheduler(opts: QueueWriteOptions & {
|
|
111
|
+
dbPath: string;
|
|
112
|
+
}): Scheduler;
|
|
113
|
+
/** `30m`, `2h`, `3d`, `1w` from now, or an ISO-8601 instant. */
|
|
114
|
+
export declare function parseWhen(value: string, now?: Date): Date;
|
|
115
|
+
/** Bounds of a local calendar day `yyyy-mm-dd`, as instants (23 to 25 h with DST). */
|
|
116
|
+
export declare function localDayBounds(day: string): {
|
|
117
|
+
dayStart: Date;
|
|
118
|
+
dayEnd: Date;
|
|
119
|
+
};
|
|
120
|
+
/** `tidegap queue cancel <id> [--series]`. Throws (exit 1) on an unknown id. */
|
|
121
|
+
export declare function runQueueCancel(taskId: string, opts?: QueueWriteOptions & {
|
|
122
|
+
series?: boolean;
|
|
123
|
+
}): Promise<string>;
|
|
124
|
+
/** `tidegap queue run-now <id>`. Throws (exit 1) when the task cannot run now. */
|
|
125
|
+
export declare function runQueueRunNow(taskId: string, opts?: QueueWriteOptions): Promise<string>;
|
|
126
|
+
/**
|
|
127
|
+
* `tidegap queue reschedule <id> (--by <when> | --at <iso> | --day <yyyy-mm-dd>)`.
|
|
128
|
+
* Exactly one target. `--day` uses this machine's time zone for the bounds.
|
|
129
|
+
*/
|
|
130
|
+
export declare function runQueueReschedule(taskId: string, opts?: QueueWriteOptions & {
|
|
131
|
+
by?: string;
|
|
132
|
+
at?: string;
|
|
133
|
+
day?: string;
|
|
134
|
+
}): Promise<string>;
|
|
135
|
+
/** `tidegap queue reply <id> <text> [--by <when>]`: a child task with the history. */
|
|
136
|
+
export declare function runQueueReply(taskId: string, text: string, opts?: QueueWriteOptions & {
|
|
137
|
+
by?: string;
|
|
138
|
+
}): Promise<string>;
|
|
139
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/commands/queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAQL,SAAS,EAMV,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,YAAY,EACZ,QAA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