@getengram/cli 0.3.4 → 0.4.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/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +2 -0
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/import.d.ts +114 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +309 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +75 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/usage.d.ts +7 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +62 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/vault.d.ts +40 -0
- package/dist/commands/vault.d.ts.map +1 -0
- package/dist/commands/vault.js +186 -0
- package/dist/commands/vault.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon/adapters.d.ts +5 -0
- package/dist/daemon/adapters.d.ts.map +1 -0
- package/dist/daemon/adapters.js +35 -0
- package/dist/daemon/adapters.js.map +1 -0
- package/dist/daemon/codex-parser.d.ts +16 -0
- package/dist/daemon/codex-parser.d.ts.map +1 -0
- package/dist/daemon/codex-parser.js +65 -0
- package/dist/daemon/codex-parser.js.map +1 -0
- package/dist/daemon/commands.d.ts +8 -0
- package/dist/daemon/commands.d.ts.map +1 -1
- package/dist/daemon/commands.js +68 -0
- package/dist/daemon/commands.js.map +1 -1
- package/dist/daemon/parser.d.ts +2 -3
- package/dist/daemon/parser.d.ts.map +1 -1
- package/dist/daemon/parser.js +1 -0
- package/dist/daemon/parser.js.map +1 -1
- package/dist/daemon/syncer.d.ts.map +1 -1
- package/dist/daemon/syncer.js +7 -3
- package/dist/daemon/syncer.js.map +1 -1
- package/dist/daemon/types.d.ts +32 -1
- package/dist/daemon/types.d.ts.map +1 -1
- package/dist/daemon/watcher.d.ts +7 -5
- package/dist/daemon/watcher.d.ts.map +1 -1
- package/dist/daemon/watcher.js +12 -8
- package/dist/daemon/watcher.js.map +1 -1
- package/dist/daemon/worker.js +16 -6
- package/dist/daemon/worker.js.map +1 -1
- package/dist/index.js +76 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Render a progress bar like "[████████████░░░░░░░░] 62%". Exported for tests. */
|
|
2
|
+
export declare function renderBar(used: number, limit: number, width?: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* `engram usage` — show memory storage and monthly usage with visual bars.
|
|
5
|
+
*/
|
|
6
|
+
export declare function usage(_args: string[], flags: Record<string, string>): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAKA,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAOzE;AAYD;;GAEG;AACH,wBAAsB,KAAK,CACzB,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { loadConfig, getBaseUrl } from "../config.js";
|
|
2
|
+
import { bold, dim, red, json as printJson } from "../output.js";
|
|
3
|
+
const API_URL = process.env.ENGRAM_BASE_URL ?? getBaseUrl();
|
|
4
|
+
/** Render a progress bar like "[████████████░░░░░░░░] 62%". Exported for tests. */
|
|
5
|
+
export function renderBar(used, limit, width = 20) {
|
|
6
|
+
const pct = limit > 0 ? Math.min(100, Math.round((used / limit) * 100)) : 0;
|
|
7
|
+
// Any nonzero usage shows at least one filled segment so the bar never
|
|
8
|
+
// reads as empty (an all-░ bar renders as a blank grey pill in many fonts).
|
|
9
|
+
const minFilled = used > 0 && limit > 0 ? 1 : 0;
|
|
10
|
+
const filled = Math.max(minFilled, Math.min(width, Math.round((pct / 100) * width)));
|
|
11
|
+
return `[${"█".repeat(filled)}${"░".repeat(width - filled)}] ${String(pct).padStart(3)}%`;
|
|
12
|
+
}
|
|
13
|
+
const fmt = (n) => n.toLocaleString("en-US");
|
|
14
|
+
/**
|
|
15
|
+
* `engram usage` — show memory storage and monthly usage with visual bars.
|
|
16
|
+
*/
|
|
17
|
+
export async function usage(_args, flags) {
|
|
18
|
+
const config = await loadConfig();
|
|
19
|
+
const apiKey = process.env.ENGRAM_API_KEY ?? config.apiKey;
|
|
20
|
+
if (!apiKey) {
|
|
21
|
+
console.error(red("Not authenticated. Run 'engram signup' first."));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const res = await fetch(`${API_URL}/api/usage`, {
|
|
25
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
26
|
+
});
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
console.error(red(`Failed to fetch usage (${res.status}).`));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
const data = (await res.json());
|
|
32
|
+
if ("json" in flags) {
|
|
33
|
+
printJson(data);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.log(`\n${bold("Plan:")} ${data.tier}\n`);
|
|
37
|
+
if (data.storage) {
|
|
38
|
+
if (data.storage.limit === -1) {
|
|
39
|
+
console.log(` ${bold("Memory")} unlimited ${dim(`· ${fmt(data.storage.used)} messages stored · never expires`)}`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(` ${bold("Memory")} ${renderBar(data.storage.used, data.storage.limit)} ` +
|
|
43
|
+
`${fmt(data.storage.used)} / ${fmt(data.storage.limit)} messages ${dim("· never expires")}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (data.messages.limit !== -1) {
|
|
47
|
+
console.log(` ${bold("This month")} ${renderBar(data.messages.used, data.messages.limit)} ` +
|
|
48
|
+
`${fmt(data.messages.used)} / ${fmt(data.messages.limit)} messages`);
|
|
49
|
+
}
|
|
50
|
+
console.log(` ${bold("Searches")} ${fmt(data.searches.used)} this month\n`);
|
|
51
|
+
if (data.storage && data.storage.limit > 0) {
|
|
52
|
+
const pct = data.storage.used / data.storage.limit;
|
|
53
|
+
if (pct >= 1) {
|
|
54
|
+
console.log(dim(" Memory is full — nothing expires, but new saves are paused."));
|
|
55
|
+
console.log(dim(" Free space by deleting conversations, or upgrade: engram upgrade\n"));
|
|
56
|
+
}
|
|
57
|
+
else if (pct >= 0.8) {
|
|
58
|
+
console.log(dim(" Heads up: memory is over 80% full. More room: engram upgrade\n"));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,UAAU,EAAE,CAAC;AAE5D,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,KAAK,GAAG,EAAE;IAC/D,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,C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AI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI;YACjF,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CACtE,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAEjF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnD,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC,CAAC;YAClF,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,sEAAsE,CAAC,CAAC,CAAC;QAC3F,CAAC;aAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,kEAAkE,CAAC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Engram } from "@getengram/sdk";
|
|
2
|
+
export declare function vaultKeygen(_args: string[], flags: Record<string, string>): Promise<void>;
|
|
3
|
+
export declare function vaultStatus(): Promise<void>;
|
|
4
|
+
export declare function loadVaultKey(): Promise<string | undefined>;
|
|
5
|
+
/**
|
|
6
|
+
* Store a named secret. Follows GitHub Secrets pattern:
|
|
7
|
+
* - Reads value from stdin, --value flag, or positional arg (in that order)
|
|
8
|
+
* - Value is encrypted client-side before transmission
|
|
9
|
+
* - Shell history is avoided when using stdin
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* echo "postgres://..." | engram vault set DATABASE_URL
|
|
13
|
+
* engram vault set DATABASE_URL --value "postgres://..."
|
|
14
|
+
* engram vault set DATABASE_URL "postgres://..."
|
|
15
|
+
*/
|
|
16
|
+
export declare function vaultSet(client: Engram, args: string[], flags: Record<string, string>): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve a named secret. Decrypts locally with your vault key.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* engram vault get DATABASE_URL
|
|
22
|
+
* engram vault get DATABASE_URL --json
|
|
23
|
+
*/
|
|
24
|
+
export declare function vaultGet(client: Engram, args: string[], flags: Record<string, string>): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* List all named secrets (names and metadata only, never values).
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* engram vault list
|
|
30
|
+
* engram vault list --json
|
|
31
|
+
*/
|
|
32
|
+
export declare function vaultList(client: Engram, _args: string[], flags: Record<string, string>): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete a named secret permanently.
|
|
35
|
+
*
|
|
36
|
+
* Usage:
|
|
37
|
+
* engram vault delete DATABASE_URL
|
|
38
|
+
*/
|
|
39
|
+
export declare function vaultDelete(client: Engram, args: string[], _flags: Record<string, string>): Promise<void>;
|
|
40
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../src/commands/vault.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK/D,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBjD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAYhE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { generateVaultKey } from "@getengram/sdk";
|
|
5
|
+
import { bold, dim } from "../output.js";
|
|
6
|
+
const VAULT_KEY_FILE = join(homedir(), ".engram", "vault-key");
|
|
7
|
+
export async function vaultKeygen(_args, flags) {
|
|
8
|
+
const key = await generateVaultKey();
|
|
9
|
+
if (flags.save !== undefined) {
|
|
10
|
+
await writeFile(VAULT_KEY_FILE, key + "\n", { mode: 0o600 });
|
|
11
|
+
console.log(`${bold("Vault key generated and saved to:")} ${VAULT_KEY_FILE}`);
|
|
12
|
+
console.log(dim("Permissions set to owner-only (600)."));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.log(key);
|
|
16
|
+
}
|
|
17
|
+
console.log();
|
|
18
|
+
console.log(dim("Store this key securely — Engram never sees it."));
|
|
19
|
+
console.log(dim("If you lose it, vaulted secrets cannot be recovered."));
|
|
20
|
+
console.log();
|
|
21
|
+
console.log(`${bold("Usage with SDK:")}`);
|
|
22
|
+
console.log(dim(` const engram = new Engram({ apiKey: "...", vault: { encryptionKey: "${key.slice(0, 8)}..." } })`));
|
|
23
|
+
console.log();
|
|
24
|
+
console.log(`${bold("Usage with environment variable:")}`);
|
|
25
|
+
console.log(dim(" export ENGRAM_VAULT_KEY=" + key.slice(0, 8) + "..."));
|
|
26
|
+
}
|
|
27
|
+
export async function vaultStatus() {
|
|
28
|
+
try {
|
|
29
|
+
const key = await readFile(VAULT_KEY_FILE, "utf-8");
|
|
30
|
+
const trimmed = key.trim();
|
|
31
|
+
const bytes = Buffer.from(trimmed, "base64");
|
|
32
|
+
if (bytes.length === 32) {
|
|
33
|
+
console.log(`${bold("Vault:")} configured (key at ${VAULT_KEY_FILE})`);
|
|
34
|
+
console.log(dim(`Key prefix: ${trimmed.slice(0, 8)}...`));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(`${bold("Vault:")} invalid key (expected 32 bytes, got ${bytes.length})`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
console.log(`${bold("Vault:")} not configured`);
|
|
42
|
+
console.log(dim("Run 'engram vault keygen --save' to generate a key."));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function loadVaultKey() {
|
|
46
|
+
// Environment variable takes precedence
|
|
47
|
+
const envKey = process.env.ENGRAM_VAULT_KEY;
|
|
48
|
+
if (envKey)
|
|
49
|
+
return envKey;
|
|
50
|
+
// Fall back to file
|
|
51
|
+
try {
|
|
52
|
+
const key = await readFile(VAULT_KEY_FILE, "utf-8");
|
|
53
|
+
return key.trim() || undefined;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Store a named secret. Follows GitHub Secrets pattern:
|
|
61
|
+
* - Reads value from stdin, --value flag, or positional arg (in that order)
|
|
62
|
+
* - Value is encrypted client-side before transmission
|
|
63
|
+
* - Shell history is avoided when using stdin
|
|
64
|
+
*
|
|
65
|
+
* Usage:
|
|
66
|
+
* echo "postgres://..." | engram vault set DATABASE_URL
|
|
67
|
+
* engram vault set DATABASE_URL --value "postgres://..."
|
|
68
|
+
* engram vault set DATABASE_URL "postgres://..."
|
|
69
|
+
*/
|
|
70
|
+
export async function vaultSet(client, args, flags) {
|
|
71
|
+
const name = args[0];
|
|
72
|
+
if (!name) {
|
|
73
|
+
console.error("Usage: engram vault set <NAME> [value]");
|
|
74
|
+
console.error(" echo 'value' | engram vault set <NAME>");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
let value;
|
|
78
|
+
// 1. Check --value flag
|
|
79
|
+
if (flags.value !== undefined) {
|
|
80
|
+
value = flags.value;
|
|
81
|
+
}
|
|
82
|
+
// 2. Check positional arg
|
|
83
|
+
else if (args[1]) {
|
|
84
|
+
value = args[1];
|
|
85
|
+
}
|
|
86
|
+
// 3. Check stdin (piped input)
|
|
87
|
+
else if (!process.stdin.isTTY) {
|
|
88
|
+
const chunks = [];
|
|
89
|
+
for await (const chunk of process.stdin) {
|
|
90
|
+
chunks.push(chunk);
|
|
91
|
+
}
|
|
92
|
+
value = Buffer.concat(chunks).toString("utf-8").trim();
|
|
93
|
+
}
|
|
94
|
+
if (!value) {
|
|
95
|
+
console.error("No value provided.");
|
|
96
|
+
console.error("Usage: engram vault set <NAME> <value>");
|
|
97
|
+
console.error(" echo 'value' | engram vault set <NAME>");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
await client.vault.set(name, value);
|
|
101
|
+
console.log(`${bold("Secret stored:")} ${name}`);
|
|
102
|
+
console.log(dim("Encrypted client-side. The server never sees the plaintext value."));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Retrieve a named secret. Decrypts locally with your vault key.
|
|
106
|
+
*
|
|
107
|
+
* Usage:
|
|
108
|
+
* engram vault get DATABASE_URL
|
|
109
|
+
* engram vault get DATABASE_URL --json
|
|
110
|
+
*/
|
|
111
|
+
export async function vaultGet(client, args, flags) {
|
|
112
|
+
const name = args[0];
|
|
113
|
+
if (!name) {
|
|
114
|
+
console.error("Usage: engram vault get <NAME>");
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
const value = await client.vault.get(name);
|
|
118
|
+
if (value === null) {
|
|
119
|
+
console.error(`Secret "${name}" not found.`);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
if (flags.json !== undefined) {
|
|
123
|
+
console.log(JSON.stringify({ name, value }));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Output raw value (suitable for piping)
|
|
127
|
+
process.stdout.write(value);
|
|
128
|
+
// Add newline only if stdout is a TTY
|
|
129
|
+
if (process.stdout.isTTY) {
|
|
130
|
+
console.log();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* List all named secrets (names and metadata only, never values).
|
|
136
|
+
*
|
|
137
|
+
* Usage:
|
|
138
|
+
* engram vault list
|
|
139
|
+
* engram vault list --json
|
|
140
|
+
*/
|
|
141
|
+
export async function vaultList(client, _args, flags) {
|
|
142
|
+
const secrets = await client.vault.list();
|
|
143
|
+
if (flags.json !== undefined) {
|
|
144
|
+
console.log(JSON.stringify({ secrets, total: secrets.length }));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (secrets.length === 0) {
|
|
148
|
+
console.log(dim("No secrets stored."));
|
|
149
|
+
console.log(dim("Run 'engram vault set <NAME> <value>' to store one."));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Table header
|
|
153
|
+
const nameWidth = Math.max(4, ...secrets.map((s) => s.name.length)) + 2;
|
|
154
|
+
const typeWidth = Math.max(4, ...secrets.map((s) => s.secretType.length)) + 2;
|
|
155
|
+
console.log(bold("NAME".padEnd(nameWidth)) +
|
|
156
|
+
bold("TYPE".padEnd(typeWidth)) +
|
|
157
|
+
bold("UPDATED"));
|
|
158
|
+
for (const s of secrets) {
|
|
159
|
+
const updated = s.updatedAt.split("T")[0];
|
|
160
|
+
console.log(s.name.padEnd(nameWidth) +
|
|
161
|
+
dim(s.secretType.padEnd(typeWidth)) +
|
|
162
|
+
dim(updated));
|
|
163
|
+
}
|
|
164
|
+
console.log();
|
|
165
|
+
console.log(dim(`${secrets.length} secret(s)`));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Delete a named secret permanently.
|
|
169
|
+
*
|
|
170
|
+
* Usage:
|
|
171
|
+
* engram vault delete DATABASE_URL
|
|
172
|
+
*/
|
|
173
|
+
export async function vaultDelete(client, args, _flags) {
|
|
174
|
+
const name = args[0];
|
|
175
|
+
if (!name) {
|
|
176
|
+
console.error("Usage: engram vault delete <NAME>");
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
const deleted = await client.vault.delete(name);
|
|
180
|
+
if (!deleted) {
|
|
181
|
+
console.error(`Secret "${name}" not found.`);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
console.log(`${bold("Deleted:")} ${name}`);
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=vault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../../src/commands/vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,OAAO,EAA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/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface Config {
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
|
+
/** "off" = the user explicitly stopped capture; the CLI must not
|
|
5
|
+
* resurrect the daemon until they run start/install again. */
|
|
6
|
+
autocapture?: "on" | "off";
|
|
4
7
|
}
|
|
5
8
|
export declare function loadConfig(): Promise<Config>;
|
|
6
9
|
export declare function saveConfig(config: Config): Promise<void>;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,UAAU,MAAM;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,UAAU,MAAM;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;mEAC+D;IAC/D,WAAW,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;CAC5B;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAOlD;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9D;AAED,wBAAgB,SAAS,IAAI,MAAM,CAalC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAA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1B,uBAAuB;YACvB,UAAU;YACV,8CAA8C,CACjD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,2BAA2B,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/daemon/adapters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AA+B1D,eAAO,MAAM,YAAY,EAAE,WAAW,EAAsC,CAAC;AAE7E,iEAAiE;AACjE,wBAAgB,iBAAiB,IAAI,WAAW,EAAE,CAEjD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { Parser } from "./parser.js";
|
|
5
|
+
import { CodexParser } from "./codex-parser.js";
|
|
6
|
+
// Registry of capturable hosts (engram#261). Add a host by adding an
|
|
7
|
+
// adapter here — the watcher, syncer, and status are all host-agnostic.
|
|
8
|
+
const claudeCodeAdapter = {
|
|
9
|
+
id: "claude-code",
|
|
10
|
+
label: "Claude Code",
|
|
11
|
+
watchDir: join(homedir(), ".claude", "projects"),
|
|
12
|
+
available() {
|
|
13
|
+
return existsSync(this.watchDir);
|
|
14
|
+
},
|
|
15
|
+
createParser(onMessages) {
|
|
16
|
+
return new Parser(onMessages);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const codexAdapter = {
|
|
20
|
+
id: "codex",
|
|
21
|
+
label: "Codex CLI",
|
|
22
|
+
watchDir: join(homedir(), ".codex", "sessions"),
|
|
23
|
+
available() {
|
|
24
|
+
return existsSync(this.watchDir);
|
|
25
|
+
},
|
|
26
|
+
createParser(onMessages) {
|
|
27
|
+
return new CodexParser(onMessages);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const ALL_ADAPTERS = [claudeCodeAdapter, codexAdapter];
|
|
31
|
+
/** Adapters whose host is actually installed on this machine. */
|
|
32
|
+
export function availableAdapters() {
|
|
33
|
+
return ALL_ADAPTERS.filter((a) => a.available());
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../src/daemon/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qEAAqE;AACrE,wEAAwE;AAExE,MAAM,iBAAiB,GAAgB;IACrC,EAAE,EAAE,aAAa;IACjB,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC;IAChD,SAAS;QACP,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,YAAY,CAAC,UAAsB;QACjC,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;CACF,CAAC;AAEF,MAAM,YAAY,GAAgB;IAChC,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,WAAW;IAClB,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC;IAC/C,SAAS;QACP,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,YAAY,CAAC,UAAsB;QACjC,OAAO,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAkB,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAE7E,iEAAiE;AACjE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LineParser, OnMessages } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses Codex CLI rollout JSONL into Engram messages.
|
|
4
|
+
* Emits per completed user/assistant message (one line = one message).
|
|
5
|
+
*/
|
|
6
|
+
export declare class CodexParser implements LineParser {
|
|
7
|
+
private onMessages;
|
|
8
|
+
private sessionId;
|
|
9
|
+
private cwd;
|
|
10
|
+
constructor(onMessages: OnMessages);
|
|
11
|
+
processLine(line: string, filePath: string): void;
|
|
12
|
+
flush(): void;
|
|
13
|
+
/** rollout-2026-07-23T04-46-50-<uuid>.jsonl → <uuid> */
|
|
14
|
+
private sessionIdFromPath;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=codex-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-parser.d.ts","sourceRoot":"","sources":["../../src/daemon/codex-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAA8B,MAAM,YAAY,CAAC;AAsBrF;;;GAGG;AACH,qBAAa,WAAY,YAAW,UAAU;IAC5C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,GAAG,CAAqB;gBAEpB,UAAU,EAAE,UAAU;IAIlC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IA2CjD,KAAK,IAAI,IAAI;IAIb,wDAAwD;IACxD,OAAO,CAAC,iBAAiB;CAI1B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Codex injects its own context blocks as "user" messages — skip them.
|
|
2
|
+
const CONTEXT_PREFIX = /^<(environment_context|recommended_plugins|user_instructions)/;
|
|
3
|
+
/**
|
|
4
|
+
* Parses Codex CLI rollout JSONL into Engram messages.
|
|
5
|
+
* Emits per completed user/assistant message (one line = one message).
|
|
6
|
+
*/
|
|
7
|
+
export class CodexParser {
|
|
8
|
+
onMessages;
|
|
9
|
+
sessionId = null;
|
|
10
|
+
cwd;
|
|
11
|
+
constructor(onMessages) {
|
|
12
|
+
this.onMessages = onMessages;
|
|
13
|
+
}
|
|
14
|
+
processLine(line, filePath) {
|
|
15
|
+
let data;
|
|
16
|
+
try {
|
|
17
|
+
data = JSON.parse(line);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const p = data.payload ?? {};
|
|
23
|
+
if (data.type === "session_meta") {
|
|
24
|
+
this.sessionId = p.session_id ?? p.id ?? this.sessionId;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (data.type === "turn_context" && p.cwd) {
|
|
28
|
+
this.cwd = p.cwd;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (data.type !== "response_item" || p.type !== "message")
|
|
32
|
+
return;
|
|
33
|
+
const role = p.role;
|
|
34
|
+
if (role !== "user" && role !== "assistant")
|
|
35
|
+
return; // skip developer/system/tool
|
|
36
|
+
const text = (p.content ?? [])
|
|
37
|
+
.map((c) => c.text ?? c.input_text ?? "")
|
|
38
|
+
.join("")
|
|
39
|
+
.trim();
|
|
40
|
+
if (!text || CONTEXT_PREFIX.test(text))
|
|
41
|
+
return;
|
|
42
|
+
// Fall back to the rollout filename's uuid if session_meta wasn't seen
|
|
43
|
+
// (offset-based reads can start mid-file).
|
|
44
|
+
const sessionId = this.sessionId ?? this.sessionIdFromPath(filePath);
|
|
45
|
+
if (!sessionId)
|
|
46
|
+
return;
|
|
47
|
+
const meta = {
|
|
48
|
+
sessionId,
|
|
49
|
+
cwd: this.cwd,
|
|
50
|
+
projectDir: this.cwd ?? "",
|
|
51
|
+
host: "codex",
|
|
52
|
+
};
|
|
53
|
+
const message = { role, content: text };
|
|
54
|
+
this.onMessages(sessionId, meta, [message]);
|
|
55
|
+
}
|
|
56
|
+
flush() {
|
|
57
|
+
// No buffering — each line emits immediately.
|
|
58
|
+
}
|
|
59
|
+
/** rollout-2026-07-23T04-46-50-<uuid>.jsonl → <uuid> */
|
|
60
|
+
sessionIdFromPath(filePath) {
|
|
61
|
+
const m = filePath.match(/rollout-[\dT-]+-([0-9a-f-]{36})\.jsonl$/i);
|
|
62
|
+
return m ? m[1] : null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=codex-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-parser.js","sourceRoot":"","sources":["../../src/daemon/codex-parser.ts"],"names":[],"mappings":"AAmBA,uEAAuE;AACvE,MAAM,cAAc,GAAG,+DAA+D,CAAC;AAEvF;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,UAAU,CAAa;IACvB,SAAS,GAAkB,IAAI,CAAC;IAChC,GAAG,CAAqB;IAEhC,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,QAAgB;QACxC,IAAI,IAAiB,CAAC;QACtB,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QAE7B,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS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AAO,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK;QACH,8CAA8C;IAChD,CAAC;IAED,wDAAwD;IAChD,iBAAiB,CAAC,QAAgB;QACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACrE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -2,5 +2,13 @@ export declare function daemonStart(_args: string[], flags: Record<string, strin
|
|
|
2
2
|
export declare function daemonStop(): Promise<void>;
|
|
3
3
|
export declare function daemonStatus(): Promise<void>;
|
|
4
4
|
export declare function daemonInstall(): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Auto-capture is the product default: a successful interactive login
|
|
7
|
+
* turns the capture daemon on and enables start-at-login, loudly, with a
|
|
8
|
+
* one-line off switch. Never fatal — login must succeed even if the
|
|
9
|
+
* daemon can't start. Skipped for scripted logins (no TTY) and when
|
|
10
|
+
* ENGRAM_NO_AUTOCAPTURE is set.
|
|
11
|
+
*/
|
|
12
|
+
export declare function autoEnableCapture(): Promise<void>;
|
|
5
13
|
export declare function daemonUninstall(): Promise<void>;
|
|
6
14
|
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/daemon/commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/daemon/commands.ts"],"names":[],"mappings":"AAuFA,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiDf;AAYD,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBhD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAwClD;AA6GD,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAGnD;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6BvD;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAGrD"}
|
package/dist/daemon/commands.js
CHANGED
|
@@ -3,8 +3,20 @@ import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync, openSyn
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
5
|
import { bold, dim, red } from "../output.js";
|
|
6
|
+
import { loadConfig, saveConfig } from "../config.js";
|
|
6
7
|
import { DaemonDb } from "./db.js";
|
|
7
8
|
import { readStatus } from "./status.js";
|
|
9
|
+
import { ALL_ADAPTERS } from "./adapters.js";
|
|
10
|
+
/** Render the per-host capture status (engram#261). */
|
|
11
|
+
function printHostStatus() {
|
|
12
|
+
console.log(`${dim("Hosts:")}`);
|
|
13
|
+
for (const a of ALL_ADAPTERS) {
|
|
14
|
+
const on = a.available();
|
|
15
|
+
const mark = on ? "✓" : "·";
|
|
16
|
+
const state = on ? "capturing" : "not installed";
|
|
17
|
+
console.log(` ${mark} ${a.label.padEnd(14)} ${dim(state)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
const ENGRAM_DIR = join(homedir(), ".engram");
|
|
9
21
|
const PID_FILE = join(ENGRAM_DIR, "daemon.pid");
|
|
10
22
|
const DB_FILE = join(ENGRAM_DIR, "daemon.db");
|
|
@@ -69,6 +81,7 @@ function readLaunchdPid() {
|
|
|
69
81
|
return null;
|
|
70
82
|
}
|
|
71
83
|
export async function daemonStart(_args, flags) {
|
|
84
|
+
await recordCaptureIntent("on");
|
|
72
85
|
const existing = readPid();
|
|
73
86
|
if (existing) {
|
|
74
87
|
console.log(`Daemon already running (pid ${existing})`);
|
|
@@ -109,7 +122,18 @@ export async function daemonStart(_args, flags) {
|
|
|
109
122
|
process.exit(1);
|
|
110
123
|
}
|
|
111
124
|
}
|
|
125
|
+
async function recordCaptureIntent(v) {
|
|
126
|
+
try {
|
|
127
|
+
const config = await loadConfig();
|
|
128
|
+
config.autocapture = v;
|
|
129
|
+
await saveConfig(config);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// config write failures never block daemon management
|
|
133
|
+
}
|
|
134
|
+
}
|
|
112
135
|
export async function daemonStop() {
|
|
136
|
+
await recordCaptureIntent("off");
|
|
113
137
|
const pid = readPid();
|
|
114
138
|
if (!pid) {
|
|
115
139
|
console.log("Daemon is not running.");
|
|
@@ -152,6 +176,7 @@ export async function daemonStatus() {
|
|
|
152
176
|
console.log(`${dim("Pending sync:")} ${stats.pendingMessages} messages`);
|
|
153
177
|
console.log(`${dim("Files tracked:")} ${stats.trackedFiles}`);
|
|
154
178
|
}
|
|
179
|
+
printHostStatus();
|
|
155
180
|
// Show sync health warnings
|
|
156
181
|
const syncStatus = readStatus();
|
|
157
182
|
printSyncWarnings(syncStatus);
|
|
@@ -257,9 +282,52 @@ function uninstallLaunchd() {
|
|
|
257
282
|
console.log(`${bold("Auto-start disabled")} — launchd agent removed`);
|
|
258
283
|
}
|
|
259
284
|
export async function daemonInstall() {
|
|
285
|
+
await recordCaptureIntent("on");
|
|
260
286
|
installLaunchd();
|
|
261
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Auto-capture is the product default: a successful interactive login
|
|
290
|
+
* turns the capture daemon on and enables start-at-login, loudly, with a
|
|
291
|
+
* one-line off switch. Never fatal — login must succeed even if the
|
|
292
|
+
* daemon can't start. Skipped for scripted logins (no TTY) and when
|
|
293
|
+
* ENGRAM_NO_AUTOCAPTURE is set.
|
|
294
|
+
*/
|
|
295
|
+
export async function autoEnableCapture() {
|
|
296
|
+
if (process.env.ENGRAM_NO_AUTOCAPTURE)
|
|
297
|
+
return;
|
|
298
|
+
if (!process.stdin.isTTY)
|
|
299
|
+
return;
|
|
300
|
+
if (process.platform !== "darwin" && process.platform !== "linux")
|
|
301
|
+
return;
|
|
302
|
+
try {
|
|
303
|
+
const config = await loadConfig();
|
|
304
|
+
if (config.autocapture === "off")
|
|
305
|
+
return; // user said stop; respect it
|
|
306
|
+
if (!(process.env.ENGRAM_API_KEY ?? config.apiKey))
|
|
307
|
+
return; // nothing to capture into
|
|
308
|
+
if (!readPid()) {
|
|
309
|
+
mkdirSync(ENGRAM_DIR, { recursive: true });
|
|
310
|
+
const logFd = openSync(LOG_FILE, "a");
|
|
311
|
+
const child = spawn(process.execPath, [getWorkerPath()], {
|
|
312
|
+
detached: true,
|
|
313
|
+
stdio: ["ignore", logFd, logFd],
|
|
314
|
+
env: { ...process.env },
|
|
315
|
+
});
|
|
316
|
+
child.unref();
|
|
317
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
318
|
+
}
|
|
319
|
+
if (process.platform === "darwin" && !isLaunchdInstalled()) {
|
|
320
|
+
installLaunchd();
|
|
321
|
+
}
|
|
322
|
+
console.log(`${bold("Auto-capture is on")} — conversations from supported agents on this machine save to your Engram.`);
|
|
323
|
+
console.log(dim(" Turn off anytime: engram stop && engram uninstall"));
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
// Non-fatal by design: capture is a convenience, login is the job.
|
|
327
|
+
}
|
|
328
|
+
}
|
|
262
329
|
export async function daemonUninstall() {
|
|
330
|
+
await recordCaptureIntent("off");
|
|
263
331
|
uninstallLaunchd();
|
|
264
332
|
}
|
|
265
333
|
//# sourceMappingURL=commands.js.map
|