@getengram/cli 0.6.0 → 0.7.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.
Files changed (208) hide show
  1. package/LICENSE +112 -0
  2. package/README.md +1 -1
  3. package/dist/commands/auth.d.ts.map +1 -1
  4. package/dist/commands/auth.js +38 -11
  5. package/dist/commands/auth.js.map +1 -1
  6. package/dist/commands/conversations.d.ts.map +1 -1
  7. package/dist/commands/conversations.js +8 -2
  8. package/dist/commands/conversations.js.map +1 -1
  9. package/dist/commands/exclude.d.ts.map +1 -1
  10. package/dist/commands/exclude.js +73 -21
  11. package/dist/commands/exclude.js.map +1 -1
  12. package/dist/commands/import.d.ts +30 -3
  13. package/dist/commands/import.d.ts.map +1 -1
  14. package/dist/commands/import.js +374 -45
  15. package/dist/commands/import.js.map +1 -1
  16. package/dist/commands/login.d.ts.map +1 -1
  17. package/dist/commands/login.js +144 -29
  18. package/dist/commands/login.js.map +1 -1
  19. package/dist/commands/search.js +2 -2
  20. package/dist/commands/search.js.map +1 -1
  21. package/dist/commands/status.d.ts +16 -0
  22. package/dist/commands/status.d.ts.map +1 -0
  23. package/dist/commands/status.js +51 -0
  24. package/dist/commands/status.js.map +1 -0
  25. package/dist/commands/store.d.ts.map +1 -1
  26. package/dist/commands/store.js +19 -3
  27. package/dist/commands/store.js.map +1 -1
  28. package/dist/commands/upgrade.d.ts +24 -0
  29. package/dist/commands/upgrade.d.ts.map +1 -1
  30. package/dist/commands/upgrade.js +64 -15
  31. package/dist/commands/upgrade.js.map +1 -1
  32. package/dist/commands/usage.d.ts +44 -0
  33. package/dist/commands/usage.d.ts.map +1 -1
  34. package/dist/commands/usage.js +79 -19
  35. package/dist/commands/usage.js.map +1 -1
  36. package/dist/commands/vault.d.ts +11 -2
  37. package/dist/commands/vault.d.ts.map +1 -1
  38. package/dist/commands/vault.js +372 -53
  39. package/dist/commands/vault.js.map +1 -1
  40. package/dist/config-file.d.ts +74 -0
  41. package/dist/config-file.d.ts.map +1 -0
  42. package/dist/config-file.js +152 -0
  43. package/dist/config-file.js.map +1 -0
  44. package/dist/config-guard.d.ts +96 -0
  45. package/dist/config-guard.d.ts.map +1 -0
  46. package/dist/config-guard.js +184 -0
  47. package/dist/config-guard.js.map +1 -0
  48. package/dist/config.d.ts +48 -4
  49. package/dist/config.d.ts.map +1 -1
  50. package/dist/config.js +101 -12
  51. package/dist/config.js.map +1 -1
  52. package/dist/daemon/as-root.d.ts +46 -0
  53. package/dist/daemon/as-root.d.ts.map +1 -0
  54. package/dist/daemon/as-root.js +64 -0
  55. package/dist/daemon/as-root.js.map +1 -0
  56. package/dist/daemon/backoff.d.ts +26 -0
  57. package/dist/daemon/backoff.d.ts.map +1 -0
  58. package/dist/daemon/backoff.js +37 -0
  59. package/dist/daemon/backoff.js.map +1 -0
  60. package/dist/daemon/codex-parser.d.ts +38 -4
  61. package/dist/daemon/codex-parser.d.ts.map +1 -1
  62. package/dist/daemon/codex-parser.js +111 -23
  63. package/dist/daemon/codex-parser.js.map +1 -1
  64. package/dist/daemon/command-path.d.ts +13 -0
  65. package/dist/daemon/command-path.d.ts.map +1 -0
  66. package/dist/daemon/command-path.js +35 -0
  67. package/dist/daemon/command-path.js.map +1 -0
  68. package/dist/daemon/commands.d.ts +153 -3
  69. package/dist/daemon/commands.d.ts.map +1 -1
  70. package/dist/daemon/commands.js +2775 -235
  71. package/dist/daemon/commands.js.map +1 -1
  72. package/dist/daemon/db.d.ts +255 -27
  73. package/dist/daemon/db.d.ts.map +1 -1
  74. package/dist/daemon/db.js +749 -53
  75. package/dist/daemon/db.js.map +1 -1
  76. package/dist/daemon/exclusions.d.ts +23 -3
  77. package/dist/daemon/exclusions.d.ts.map +1 -1
  78. package/dist/daemon/exclusions.js +91 -21
  79. package/dist/daemon/exclusions.js.map +1 -1
  80. package/dist/daemon/homebrew.d.ts +26 -0
  81. package/dist/daemon/homebrew.d.ts.map +1 -0
  82. package/dist/daemon/homebrew.js +43 -0
  83. package/dist/daemon/homebrew.js.map +1 -0
  84. package/dist/daemon/instance.d.ts +427 -0
  85. package/dist/daemon/instance.d.ts.map +1 -0
  86. package/dist/daemon/instance.js +1201 -0
  87. package/dist/daemon/instance.js.map +1 -0
  88. package/dist/daemon/key-source.d.ts +41 -0
  89. package/dist/daemon/key-source.d.ts.map +1 -0
  90. package/dist/daemon/key-source.js +89 -0
  91. package/dist/daemon/key-source.js.map +1 -0
  92. package/dist/daemon/launch.d.ts +56 -0
  93. package/dist/daemon/launch.d.ts.map +1 -0
  94. package/dist/daemon/launch.js +153 -0
  95. package/dist/daemon/launch.js.map +1 -0
  96. package/dist/daemon/launchd.d.ts +215 -0
  97. package/dist/daemon/launchd.d.ts.map +1 -0
  98. package/dist/daemon/launchd.js +527 -0
  99. package/dist/daemon/launchd.js.map +1 -0
  100. package/dist/daemon/login-start.d.ts +2 -0
  101. package/dist/daemon/login-start.d.ts.map +1 -0
  102. package/dist/daemon/login-start.js +25 -0
  103. package/dist/daemon/login-start.js.map +1 -0
  104. package/dist/daemon/ownership.d.ts +123 -0
  105. package/dist/daemon/ownership.d.ts.map +1 -0
  106. package/dist/daemon/ownership.js +245 -0
  107. package/dist/daemon/ownership.js.map +1 -0
  108. package/dist/daemon/package-runner.d.ts +28 -0
  109. package/dist/daemon/package-runner.d.ts.map +1 -0
  110. package/dist/daemon/package-runner.js +113 -0
  111. package/dist/daemon/package-runner.js.map +1 -0
  112. package/dist/daemon/parser.d.ts +50 -5
  113. package/dist/daemon/parser.d.ts.map +1 -1
  114. package/dist/daemon/parser.js +224 -47
  115. package/dist/daemon/parser.js.map +1 -1
  116. package/dist/daemon/powershell.d.ts +25 -0
  117. package/dist/daemon/powershell.d.ts.map +1 -0
  118. package/dist/daemon/powershell.js +30 -0
  119. package/dist/daemon/powershell.js.map +1 -0
  120. package/dist/daemon/preflight.d.ts +0 -17
  121. package/dist/daemon/preflight.d.ts.map +1 -1
  122. package/dist/daemon/preflight.js +32 -6
  123. package/dist/daemon/preflight.js.map +1 -1
  124. package/dist/daemon/prune.d.ts +101 -0
  125. package/dist/daemon/prune.d.ts.map +1 -0
  126. package/dist/daemon/prune.js +287 -0
  127. package/dist/daemon/prune.js.map +1 -0
  128. package/dist/daemon/queue-error.d.ts +47 -0
  129. package/dist/daemon/queue-error.d.ts.map +1 -0
  130. package/dist/daemon/queue-error.js +59 -0
  131. package/dist/daemon/queue-error.js.map +1 -0
  132. package/dist/daemon/root-daemon.d.ts +60 -0
  133. package/dist/daemon/root-daemon.d.ts.map +1 -0
  134. package/dist/daemon/root-daemon.js +86 -0
  135. package/dist/daemon/root-daemon.js.map +1 -0
  136. package/dist/daemon/scoop.d.ts +52 -0
  137. package/dist/daemon/scoop.d.ts.map +1 -0
  138. package/dist/daemon/scoop.js +84 -0
  139. package/dist/daemon/scoop.js.map +1 -0
  140. package/dist/daemon/scrubber.d.ts +456 -0
  141. package/dist/daemon/scrubber.d.ts.map +1 -0
  142. package/dist/daemon/scrubber.js +994 -0
  143. package/dist/daemon/scrubber.js.map +1 -0
  144. package/dist/daemon/status.d.ts +306 -11
  145. package/dist/daemon/status.d.ts.map +1 -1
  146. package/dist/daemon/status.js +568 -43
  147. package/dist/daemon/status.js.map +1 -1
  148. package/dist/daemon/supervise.d.ts +78 -0
  149. package/dist/daemon/supervise.d.ts.map +1 -0
  150. package/dist/daemon/supervise.js +121 -0
  151. package/dist/daemon/supervise.js.map +1 -0
  152. package/dist/daemon/supervisor.d.ts +18 -0
  153. package/dist/daemon/supervisor.d.ts.map +1 -0
  154. package/dist/daemon/supervisor.js +56 -0
  155. package/dist/daemon/supervisor.js.map +1 -0
  156. package/dist/daemon/syncer.d.ts +382 -21
  157. package/dist/daemon/syncer.d.ts.map +1 -1
  158. package/dist/daemon/syncer.js +1448 -178
  159. package/dist/daemon/syncer.js.map +1 -1
  160. package/dist/daemon/systemd.d.ts +109 -0
  161. package/dist/daemon/systemd.d.ts.map +1 -0
  162. package/dist/daemon/systemd.js +363 -0
  163. package/dist/daemon/systemd.js.map +1 -0
  164. package/dist/daemon/types.d.ts +58 -6
  165. package/dist/daemon/types.d.ts.map +1 -1
  166. package/dist/daemon/vault-changed.d.ts +29 -0
  167. package/dist/daemon/vault-changed.d.ts.map +1 -0
  168. package/dist/daemon/vault-changed.js +47 -0
  169. package/dist/daemon/vault-changed.js.map +1 -0
  170. package/dist/daemon/vault-key-missing.d.ts +70 -0
  171. package/dist/daemon/vault-key-missing.d.ts.map +1 -0
  172. package/dist/daemon/vault-key-missing.js +125 -0
  173. package/dist/daemon/vault-key-missing.js.map +1 -0
  174. package/dist/daemon/watcher.d.ts +87 -4
  175. package/dist/daemon/watcher.d.ts.map +1 -1
  176. package/dist/daemon/watcher.js +286 -36
  177. package/dist/daemon/watcher.js.map +1 -1
  178. package/dist/daemon/worker-main.js +363 -51
  179. package/dist/daemon/worker-main.js.map +1 -1
  180. package/dist/daemon/worker.js +19 -1
  181. package/dist/daemon/worker.js.map +1 -1
  182. package/dist/import-resume.d.ts +163 -0
  183. package/dist/import-resume.d.ts.map +1 -0
  184. package/dist/import-resume.js +267 -0
  185. package/dist/import-resume.js.map +1 -0
  186. package/dist/index.js +242 -33
  187. package/dist/index.js.map +1 -1
  188. package/dist/message-bounds.d.ts +52 -0
  189. package/dist/message-bounds.d.ts.map +1 -0
  190. package/dist/message-bounds.js +157 -0
  191. package/dist/message-bounds.js.map +1 -0
  192. package/dist/output.d.ts +14 -0
  193. package/dist/output.d.ts.map +1 -1
  194. package/dist/output.js +33 -5
  195. package/dist/output.js.map +1 -1
  196. package/dist/private-files.d.ts +126 -0
  197. package/dist/private-files.d.ts.map +1 -0
  198. package/dist/private-files.js +372 -0
  199. package/dist/private-files.js.map +1 -0
  200. package/dist/server-url.d.ts +31 -0
  201. package/dist/server-url.d.ts.map +1 -0
  202. package/dist/server-url.js +47 -0
  203. package/dist/server-url.js.map +1 -0
  204. package/dist/vault-key.d.ts +122 -0
  205. package/dist/vault-key.d.ts.map +1 -0
  206. package/dist/vault-key.js +273 -0
  207. package/dist/vault-key.js.map +1 -0
  208. package/package.json +11 -12
@@ -15,18 +15,66 @@ export interface SessionMeta {
15
15
  version?: string;
16
16
  /** Host that produced the session (engram#261): "claude-code", "codex". */
17
17
  host?: string;
18
+ /**
19
+ * Set when the daemon rebuilt this metadata from local state because the
20
+ * session's own was lost — messages queued by a daemon older than
21
+ * engram#370 (see DaemonDb.adoptOrphanedPendingRows).
22
+ */
23
+ recovered?: boolean;
18
24
  }
19
- /** Emits fully-parsed messages for a session as they complete. */
25
+ /**
26
+ * Emits fully-parsed messages for a session as they complete. Returns once
27
+ * they are queued; throws a QueueWriteError when they couldn't be
28
+ * (engram#584), and the parser lets it propagate to the watcher.
29
+ */
20
30
  export type OnMessages = (sessionId: string, meta: SessionMeta, messages: ParsedMessage[]) => void;
21
31
  /**
22
32
  * A per-line transcript parser for one host format (engram#261). The
23
- * watcher feeds it complete lines from a session file; it emits messages
24
- * via the OnMessages callback it was constructed with.
33
+ * watcher feeds it complete lines from a host's session files; it emits
34
+ * messages via the OnMessages callback it was constructed with.
35
+ *
36
+ * One parser serves every file of its host, and the files are read
37
+ * interleaved, so any state a parser keeps between lines is kept per file
38
+ * (engram#579).
25
39
  */
26
40
  export interface LineParser {
27
- processLine(line: string, filePath: string): void;
28
- /** Flush any buffered partial message (e.g. a multi-block assistant turn). */
29
- flush(): void;
41
+ /**
42
+ * Feed one complete line. `offset` is the byte position where the line
43
+ * starts in its file: a parser that buffers the line's content reports it
44
+ * from bufferedFrom() until the content is emitted.
45
+ */
46
+ processLine(line: string, filePath: string, offset: number): void;
47
+ /**
48
+ * Byte offset of the first line of `filePath` whose content is buffered
49
+ * and not yet emitted, or null when nothing of that file is buffered. The
50
+ * watcher never saves a resume offset past it, so a crash re-reads the
51
+ * line instead of losing what it held.
52
+ */
53
+ bufferedFrom(filePath: string): number | null;
54
+ /** Emit buffered partial messages (e.g. a multi-block assistant turn):
55
+ * one file's, or every file's when no path is given. */
56
+ flush(filePath?: string): void;
57
+ /**
58
+ * Drop what `filePath` has buffered, without emitting it. The watcher
59
+ * calls this when the file's messages couldn't be queued (engram#584):
60
+ * it reads the file again from before the buffered lines, so they are
61
+ * parsed again then.
62
+ */
63
+ discard(filePath: string): void;
64
+ /**
65
+ * How much of a file to replay through restoreLine() when a new process
66
+ * starts reading it part-way: bytes from the start of the file, and bytes
67
+ * just before the resume point.
68
+ */
69
+ readonly resumeContext: {
70
+ headBytes: number;
71
+ tailBytes: number;
72
+ };
73
+ /**
74
+ * Rebuild per-file state from a line an earlier process already handled
75
+ * (e.g. which session a file belongs to). Never emits.
76
+ */
77
+ restoreLine(line: string, filePath: string): void;
30
78
  }
31
79
  /**
32
80
  * A capturable host (engram#261). Each adapter knows where its host
@@ -62,6 +110,10 @@ export interface DaemonStats {
62
110
  pid: number | null;
63
111
  trackedFiles: number;
64
112
  pendingMessages: number;
113
+ /** Queued under another account's key (engram#594). */
114
+ heldMessages: number;
115
+ /** Queued for a conversation Engram no longer has (engram#593). */
116
+ notSentMessages: number;
65
117
  sessionsMapped: number;
66
118
  }
67
119
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/daemon/types.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IAC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a,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,SAAS,IAAI,OAAO,CAAC;IACrB,kDAAkD;IAClD,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CAClD;AAED,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `engram vault set` and `engram vault delete` tell a running daemon that
3
+ * the vault changed (engram#701). The daemon then reads the vault again
4
+ * before its next send, rather than within its 10-minute interval, so a
5
+ * secret saved while it runs is scrubbed from the next capture on.
6
+ *
7
+ * The notice is a file in ~/.engram, not a message on the daemon's socket:
8
+ * the socket only answers (see instance.ts), and ~/.engram is the user's
9
+ * alone (engram#627). All the file says is that the vault changed. The
10
+ * daemon reads the vault itself from the server and takes nothing else
11
+ * from the file.
12
+ *
13
+ * IMPORTANT: Node built-ins only, as for private-files.ts.
14
+ */
15
+ export declare const VAULT_CHANGED_FILE: string;
16
+ /**
17
+ * Tell a running daemon that the vault changed. False when the notice
18
+ * couldn't be written. With no ~/.engram it isn't made here: no daemon has
19
+ * run here then.
20
+ */
21
+ export declare function noteVaultChanged(file?: string): boolean;
22
+ /**
23
+ * Which notice is in the file, or null when there is none. Every notice
24
+ * says something of its own, so one that differs from the last read means
25
+ * the vault changed since then. What it says is all that counts: the file
26
+ * touched, or put back as it was, is the same notice.
27
+ */
28
+ export declare function readVaultChanged(file?: string): string | null;
29
+ //# sourceMappingURL=vault-changed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault-changed.d.ts","sourceRoot":"","sources":["../../src/daemon/vault-changed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AAKpE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAA2B,GAAG,OAAO,CAS3E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAA2B,GAAG,MAAM,GAAG,IAAI,CAEjF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `engram vault set` and `engram vault delete` tell a running daemon that
3
+ * the vault changed (engram#701). The daemon then reads the vault again
4
+ * before its next send, rather than within its 10-minute interval, so a
5
+ * secret saved while it runs is scrubbed from the next capture on.
6
+ *
7
+ * The notice is a file in ~/.engram, not a message on the daemon's socket:
8
+ * the socket only answers (see instance.ts), and ~/.engram is the user's
9
+ * alone (engram#627). All the file says is that the vault changed. The
10
+ * daemon reads the vault itself from the server and takes nothing else
11
+ * from the file.
12
+ *
13
+ * IMPORTANT: Node built-ins only, as for private-files.ts.
14
+ */
15
+ import { randomBytes } from "node:crypto";
16
+ import { join } from "node:path";
17
+ import { ENGRAM_DIR } from "./launch.js";
18
+ import { readSmallFileSync, writePrivateFileSync } from "../private-files.js";
19
+ export const VAULT_CHANGED_FILE = join(ENGRAM_DIR, "vault-changed");
20
+ /** Larger than any notice noteVaultChanged writes: a larger file isn't one. */
21
+ const MAX_NOTICE_BYTES = 256;
22
+ /**
23
+ * Tell a running daemon that the vault changed. False when the notice
24
+ * couldn't be written. With no ~/.engram it isn't made here: no daemon has
25
+ * run here then.
26
+ */
27
+ export function noteVaultChanged(file = VAULT_CHANGED_FILE) {
28
+ try {
29
+ // Not flushed to disk: after a power cut the daemon starts again, and
30
+ // reads the whole vault as it starts.
31
+ writePrivateFileSync(file, `${new Date().toISOString()} ${randomBytes(8).toString("hex")}\n`, { durable: false });
32
+ return true;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
38
+ /**
39
+ * Which notice is in the file, or null when there is none. Every notice
40
+ * says something of its own, so one that differs from the last read means
41
+ * the vault changed since then. What it says is all that counts: the file
42
+ * touched, or put back as it was, is the same notice.
43
+ */
44
+ export function readVaultChanged(file = VAULT_CHANGED_FILE) {
45
+ return readSmallFileSync(file, MAX_NOTICE_BYTES)?.data.toString("hex") ?? null;
46
+ }
47
+ //# sourceMappingURL=vault-changed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault-changed.js","sourceRoot":"","sources":["../../src/daemon/vault-changed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,kBAAkB;IAChE,IAAI,CAAC;QACH,sEAAsE;QACtE,sCAAsC;QACtC,oBAAoB,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAClH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe,kBAAkB;IAChE,OAAO,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;AACjF,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * engram#698 — a daemon with no vault key can't remove the values of the
3
+ * account's named secrets from what it captures: only pattern redaction
4
+ * applies (scrubber.ts). That is right for an account with no vault. For one
5
+ * that has secrets, a secret's value that comes up in a conversation is sent
6
+ * as it is, and only daemon.log said why. The secrets may have been saved on
7
+ * another machine, or from a shell whose ENGRAM_VAULT_KEY this daemon never
8
+ * got (engram#690).
9
+ *
10
+ * So a daemon with no key asks whether the account has any: when it starts,
11
+ * when the account changes, and when `engram vault set` or `engram vault
12
+ * delete` says the vault changed (engram#701). Listing needs no key, and
13
+ * gives names and metadata only. Only how many is kept, for status.json and
14
+ * `engram status`: never a name, in a log line or anywhere else. Not on an
15
+ * interval: each list is an audit row on the server.
16
+ *
17
+ * Sends don't wait for the key: that would stop capture on every machine
18
+ * that has the account but not the key. A key that can't be read holds them
19
+ * already (engram#677).
20
+ */
21
+ import type { Account } from "./syncer.js";
22
+ /** How many named secrets an account's vault holds. Throws when it can't be told. */
23
+ export type CountSecrets = (account: Account) => Promise<number>;
24
+ export declare class MissingVaultKey {
25
+ private readonly count;
26
+ private readonly record;
27
+ private readonly log;
28
+ /** No key, and none that sends wait for: each check asks. */
29
+ private keyless;
30
+ /** The account the checks are for: undefined, signed out. */
31
+ private account;
32
+ /**
33
+ * Bumped when what was found no longer holds, for another account or a
34
+ * key found: a check begun before keeps nothing.
35
+ */
36
+ private epoch;
37
+ /** The checks begun, and the last whose answer was kept: none replaces a later one's. */
38
+ private begun;
39
+ private kept;
40
+ /** What status.json says: how many, or null for nothing to say. */
41
+ private recorded;
42
+ /**
43
+ * `keyless`: the daemon started with no key, and none that can't be read
44
+ * (that one holds sends instead). `record`: told how many the account's
45
+ * vault holds while the daemon has no key, and null when there is nothing
46
+ * to say, each time that changes.
47
+ */
48
+ constructor(count: CountSecrets, record: (secrets: number | null) => void, log: (msg: string) => void, keyless: boolean);
49
+ /**
50
+ * Whether `account`'s vault holds secrets, while the daemon has no key.
51
+ * Another account than the last: what was found for that one goes at once,
52
+ * and an answer about it that comes later is dropped. Signed out
53
+ * (undefined): nothing to say. A list that fails changes nothing, and this
54
+ * never throws.
55
+ */
56
+ check(account: Account | undefined): Promise<void>;
57
+ /**
58
+ * The daemon has a key now, or holds sends for one it can't read: from
59
+ * here on it is never without one (scrubber.ts). A check in flight keeps
60
+ * nothing.
61
+ */
62
+ keyFound(): void;
63
+ /**
64
+ * Said in the log when there are some, then recorded: whoever finds the
65
+ * count in status.json finds the line in daemon.log too. A status write or
66
+ * a log that throws throws nothing here.
67
+ */
68
+ private set;
69
+ }
70
+ //# sourceMappingURL=vault-key-missing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault-key-missing.d.ts","sourceRoot":"","sources":["../../src/daemon/vault-key-missing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,qFAAqF;AACrF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEjE,qBAAa,eAAe;IAuBxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAxBtB,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAU;IACzB,6DAA6D;IAC7D,OAAO,CAAC,OAAO,CAAkC;IACjD;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAK;IAClB,yFAAyF;IACzF,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,IAAI,CAAK;IACjB,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAuB;IAEvC;;;;;OAKG;gBAEgB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,EACxC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC3C,OAAO,EAAE,OAAO;IAKlB;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBxD;;;;OAIG;IACH,QAAQ,IAAI,IAAI;IAMhB;;;;OAIG;IACH,OAAO,CAAC,GAAG;CAqBZ"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * engram#698 — a daemon with no vault key can't remove the values of the
3
+ * account's named secrets from what it captures: only pattern redaction
4
+ * applies (scrubber.ts). That is right for an account with no vault. For one
5
+ * that has secrets, a secret's value that comes up in a conversation is sent
6
+ * as it is, and only daemon.log said why. The secrets may have been saved on
7
+ * another machine, or from a shell whose ENGRAM_VAULT_KEY this daemon never
8
+ * got (engram#690).
9
+ *
10
+ * So a daemon with no key asks whether the account has any: when it starts,
11
+ * when the account changes, and when `engram vault set` or `engram vault
12
+ * delete` says the vault changed (engram#701). Listing needs no key, and
13
+ * gives names and metadata only. Only how many is kept, for status.json and
14
+ * `engram status`: never a name, in a log line or anywhere else. Not on an
15
+ * interval: each list is an audit row on the server.
16
+ *
17
+ * Sends don't wait for the key: that would stop capture on every machine
18
+ * that has the account but not the key. A key that can't be read holds them
19
+ * already (engram#677).
20
+ */
21
+ import { plural } from "../output.js";
22
+ import { engramCommand } from "./package-runner.js";
23
+ export class MissingVaultKey {
24
+ count;
25
+ record;
26
+ log;
27
+ /** No key, and none that sends wait for: each check asks. */
28
+ keyless;
29
+ /** The account the checks are for: undefined, signed out. */
30
+ account = undefined;
31
+ /**
32
+ * Bumped when what was found no longer holds, for another account or a
33
+ * key found: a check begun before keeps nothing.
34
+ */
35
+ epoch = 0;
36
+ /** The checks begun, and the last whose answer was kept: none replaces a later one's. */
37
+ begun = 0;
38
+ kept = 0;
39
+ /** What status.json says: how many, or null for nothing to say. */
40
+ recorded = null;
41
+ /**
42
+ * `keyless`: the daemon started with no key, and none that can't be read
43
+ * (that one holds sends instead). `record`: told how many the account's
44
+ * vault holds while the daemon has no key, and null when there is nothing
45
+ * to say, each time that changes.
46
+ */
47
+ constructor(count, record, log, keyless) {
48
+ this.count = count;
49
+ this.record = record;
50
+ this.log = log;
51
+ this.keyless = keyless;
52
+ }
53
+ /**
54
+ * Whether `account`'s vault holds secrets, while the daemon has no key.
55
+ * Another account than the last: what was found for that one goes at once,
56
+ * and an answer about it that comes later is dropped. Signed out
57
+ * (undefined): nothing to say. A list that fails changes nothing, and this
58
+ * never throws.
59
+ */
60
+ async check(account) {
61
+ if (!this.keyless)
62
+ return;
63
+ if (account !== this.account) {
64
+ this.account = account;
65
+ this.epoch++;
66
+ this.set(null);
67
+ }
68
+ if (account === undefined)
69
+ return;
70
+ const epoch = this.epoch;
71
+ const check = ++this.begun;
72
+ let secrets;
73
+ try {
74
+ secrets = await this.count(account);
75
+ }
76
+ catch {
77
+ // Can't tell, so nothing changes: the server may be out of reach, or
78
+ // the key may not be allowed to list. Never the error, which may hold
79
+ // the server's address.
80
+ return;
81
+ }
82
+ if (epoch !== this.epoch || check < this.kept)
83
+ return;
84
+ this.kept = check;
85
+ this.set(Number.isSafeInteger(secrets) && secrets > 0 ? secrets : null);
86
+ }
87
+ /**
88
+ * The daemon has a key now, or holds sends for one it can't read: from
89
+ * here on it is never without one (scrubber.ts). A check in flight keeps
90
+ * nothing.
91
+ */
92
+ keyFound() {
93
+ this.keyless = false;
94
+ this.epoch++;
95
+ this.set(null);
96
+ }
97
+ /**
98
+ * Said in the log when there are some, then recorded: whoever finds the
99
+ * count in status.json finds the line in daemon.log too. A status write or
100
+ * a log that throws throws nothing here.
101
+ */
102
+ set(secrets) {
103
+ if (secrets === this.recorded)
104
+ return;
105
+ this.recorded = secrets;
106
+ if (secrets !== null) {
107
+ const values = secrets === 1 ? "its value isn't" : "their values aren't";
108
+ try {
109
+ this.log(`vault scrubber: off, and this account's vault has ${plural(secrets, "secret")} — with no ` +
110
+ `vault key, ${values} removed from what is captured. Put the key in ~/.engram/vault-key ` +
111
+ `(${engramCommand("vault save-key")}): it is read before the next send.`);
112
+ }
113
+ catch {
114
+ // Recorded in status.json all the same.
115
+ }
116
+ }
117
+ try {
118
+ this.record(secrets);
119
+ }
120
+ catch {
121
+ // status.json is best effort.
122
+ }
123
+ }
124
+ }
125
+ //# sourceMappingURL=vault-key-missing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault-key-missing.js","sourceRoot":"","sources":["../../src/daemon/vault-key-missing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,MAAM,OAAO,eAAe;IAuBP;IACA;IACA;IAxBnB,6DAA6D;IACrD,OAAO,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GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACK,GAAG,CAAC,OAAsB;QAChC,IAAI,OAAO,KAAK,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,qBAAqB,CAAC;YACzE,IAAI,CAAC;gBACH,IAAI,CAAC,GAAG,CACN,qDAAqD,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa;oBACzF,cAAc,MAAM,qEAAqE;oBACzF,IAAI,aAAa,CAAC,gBAAgB,CAAC,qCAAqC,CAC3E,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,wCAAwC;YAC1C,CAAC;QACH,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;IACH,CAAC;CACF"}
@@ -1,20 +1,103 @@
1
1
  import { DaemonDb } from "./db.js";
2
2
  import type { OnMessages, HostAdapter } from "./types.js";
3
+ /**
4
+ * How long a file waits to be read again after daemon.db couldn't queue its
5
+ * messages (engram#584), or config.json couldn't say which folders are
6
+ * excluded (engram#673): 5 s, 30 s, 2 min, then every 5 min. A locked
7
+ * daemon.db, or a config.json caught mid-save, has usually cleared by the
8
+ * first; a full disk or a damaged file waits for a person.
9
+ */
10
+ export declare const RETRY_DELAYS_MS: number[];
11
+ /** A complete line and the byte offset it starts at. */
12
+ export interface FileLine {
13
+ text: string;
14
+ offset: number;
15
+ }
3
16
  /**
4
17
  * Watches one host's session directory for JSONL files and feeds new
5
- * lines to that host's parser (engram#261). Uses byte-offset tracking so
6
- * it never re-reads already-processed content, even after daemon
7
- * restart. One Watcher per host adapter.
18
+ * lines to that host's parser (engram#261). One Watcher per host adapter.
19
+ *
20
+ * Two positions per file (engram#579). The read position is kept in
21
+ * memory, so a running process never reads a line twice. The offset saved
22
+ * in daemon.db, where a restart resumes, never passes a line whose content
23
+ * the parser still holds unemitted: a hard crash re-reads that line rather
24
+ * than skipping it. Everything before the saved offset has been handed to
25
+ * the syncer, which queues it in daemon.db before returning.
26
+ *
27
+ * Neither position passes a line whose messages daemon.db couldn't queue
28
+ * (engram#584). The file is held there and read again from that line after
29
+ * a backoff. (A line the parser can't make sense of is skipped instead:
30
+ * reading it again would fail the same way.)
8
31
  */
9
32
  export declare class Watcher {
10
33
  private db;
11
34
  private parser;
12
35
  private fsWatcher;
13
36
  private watchDir;
37
+ private cursors;
38
+ private held;
39
+ private reading;
40
+ private stopped;
14
41
  readonly host: string;
15
42
  constructor(db: DaemonDb, onMessages: OnMessages, adapter: HostAdapter);
16
43
  start(): void;
17
- stop(): void;
44
+ /**
45
+ * Emits whatever the parser still holds, then saves each such file's
46
+ * offset past it: after a graceful stop, a restart must not read those
47
+ * lines again. What can't be queued now keeps its offset, and the next
48
+ * start reads it again.
49
+ *
50
+ * `drain`: first read what was written but not read yet (engram#594).
51
+ * Capture stops this way when the account changes, so those lines are
52
+ * queued for the account they were written under, not the next one.
53
+ */
54
+ stop(options?: {
55
+ drain?: boolean;
56
+ }): void;
57
+ /**
58
+ * Reads every transcript as far as it is written now: the files this
59
+ * process has read, and any the watcher has found but not reported yet
60
+ * (it waits for a new file's writes to settle first).
61
+ */
62
+ private drain;
18
63
  private processFile;
64
+ /**
65
+ * daemon.db couldn't queue a line's messages (engram#584), or config.json
66
+ * couldn't say whether the session's folder is excluded (engram#673).
67
+ * Holds the file at `at`, where what wasn't queued begins, and reads it
68
+ * again from there after a backoff, instead of moving on past messages
69
+ * that were never queued.
70
+ */
71
+ private hold;
72
+ /** Schedules the next attempt at a held file, each one later than the last. */
73
+ private backoff;
74
+ /** Ends a file's hold: its lines were queued (or dropped as excluded)
75
+ * after all, or there is nothing left to retry. */
76
+ private release;
77
+ /** Saves the resume offset — forward only: back would re-queue lines. */
78
+ private save;
79
+ /** Replays the parser's resume context: the file's head, and the bytes
80
+ * just before where this process starts reading. */
81
+ private restoreContext;
82
+ /**
83
+ * One line the parser can't handle must not wedge the file: every line
84
+ * after it would never be read. A failure to queue is different, as is a
85
+ * config.json that can't say which folders are excluded. Neither says
86
+ * anything about the line, and skipping the line would lose it, so they
87
+ * pass through, and processFile holds the file there (engram#584,
88
+ * engram#673).
89
+ */
90
+ private guard;
19
91
  }
92
+ /**
93
+ * The complete lines lying wholly within [start, end) of an open file, each
94
+ * with the byte offset it starts at, and the offset just past the last one
95
+ * (`start` when there is none). A line that `start` falls inside is skipped.
96
+ * Offsets come from the raw bytes, so text that doesn't decode cleanly
97
+ * can't shift them.
98
+ */
99
+ export declare function readLines(fd: number, start: number, end: number): {
100
+ lines: FileLine[];
101
+ end: number;
102
+ };
20
103
  //# sourceMappingURL=watcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/daemon/watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,EAAE,CAAW;IACrB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,Q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