@getengram/cli 0.6.1 → 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.
- package/README.md +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +38 -11
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/conversations.d.ts.map +1 -1
- package/dist/commands/conversations.js +8 -2
- package/dist/commands/conversations.js.map +1 -1
- package/dist/commands/exclude.d.ts.map +1 -1
- package/dist/commands/exclude.js +73 -21
- package/dist/commands/exclude.js.map +1 -1
- package/dist/commands/import.d.ts +30 -3
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +374 -45
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +144 -29
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/search.js +2 -2
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/status.d.ts +16 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +51 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/store.d.ts.map +1 -1
- package/dist/commands/store.js +19 -3
- package/dist/commands/store.js.map +1 -1
- package/dist/commands/upgrade.d.ts +24 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +64 -15
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/usage.d.ts +44 -0
- package/dist/commands/usage.d.ts.map +1 -1
- package/dist/commands/usage.js +79 -19
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/vault.d.ts +11 -2
- package/dist/commands/vault.d.ts.map +1 -1
- package/dist/commands/vault.js +372 -53
- package/dist/commands/vault.js.map +1 -1
- package/dist/config-file.d.ts +74 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +152 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config-guard.d.ts +96 -0
- package/dist/config-guard.d.ts.map +1 -0
- package/dist/config-guard.js +184 -0
- package/dist/config-guard.js.map +1 -0
- package/dist/config.d.ts +48 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +101 -12
- package/dist/config.js.map +1 -1
- package/dist/daemon/as-root.d.ts +46 -0
- package/dist/daemon/as-root.d.ts.map +1 -0
- package/dist/daemon/as-root.js +64 -0
- package/dist/daemon/as-root.js.map +1 -0
- package/dist/daemon/backoff.d.ts +26 -0
- package/dist/daemon/backoff.d.ts.map +1 -0
- package/dist/daemon/backoff.js +37 -0
- package/dist/daemon/backoff.js.map +1 -0
- package/dist/daemon/codex-parser.d.ts +38 -4
- package/dist/daemon/codex-parser.d.ts.map +1 -1
- package/dist/daemon/codex-parser.js +111 -23
- package/dist/daemon/codex-parser.js.map +1 -1
- package/dist/daemon/command-path.d.ts +13 -0
- package/dist/daemon/command-path.d.ts.map +1 -0
- package/dist/daemon/command-path.js +35 -0
- package/dist/daemon/command-path.js.map +1 -0
- package/dist/daemon/commands.d.ts +146 -5
- package/dist/daemon/commands.d.ts.map +1 -1
- package/dist/daemon/commands.js +2766 -316
- package/dist/daemon/commands.js.map +1 -1
- package/dist/daemon/db.d.ts +255 -27
- package/dist/daemon/db.d.ts.map +1 -1
- package/dist/daemon/db.js +749 -53
- package/dist/daemon/db.js.map +1 -1
- package/dist/daemon/exclusions.d.ts +23 -3
- package/dist/daemon/exclusions.d.ts.map +1 -1
- package/dist/daemon/exclusions.js +91 -21
- package/dist/daemon/exclusions.js.map +1 -1
- package/dist/daemon/homebrew.d.ts +26 -0
- package/dist/daemon/homebrew.d.ts.map +1 -0
- package/dist/daemon/homebrew.js +43 -0
- package/dist/daemon/homebrew.js.map +1 -0
- package/dist/daemon/instance.d.ts +427 -0
- package/dist/daemon/instance.d.ts.map +1 -0
- package/dist/daemon/instance.js +1201 -0
- package/dist/daemon/instance.js.map +1 -0
- package/dist/daemon/key-source.d.ts +41 -0
- package/dist/daemon/key-source.d.ts.map +1 -0
- package/dist/daemon/key-source.js +89 -0
- package/dist/daemon/key-source.js.map +1 -0
- package/dist/daemon/launch.d.ts +56 -0
- package/dist/daemon/launch.d.ts.map +1 -0
- package/dist/daemon/launch.js +153 -0
- package/dist/daemon/launch.js.map +1 -0
- package/dist/daemon/launchd.d.ts +215 -0
- package/dist/daemon/launchd.d.ts.map +1 -0
- package/dist/daemon/launchd.js +527 -0
- package/dist/daemon/launchd.js.map +1 -0
- package/dist/daemon/login-start.d.ts +2 -0
- package/dist/daemon/login-start.d.ts.map +1 -0
- package/dist/daemon/login-start.js +25 -0
- package/dist/daemon/login-start.js.map +1 -0
- package/dist/daemon/ownership.d.ts +123 -0
- package/dist/daemon/ownership.d.ts.map +1 -0
- package/dist/daemon/ownership.js +245 -0
- package/dist/daemon/ownership.js.map +1 -0
- package/dist/daemon/package-runner.d.ts +28 -0
- package/dist/daemon/package-runner.d.ts.map +1 -0
- package/dist/daemon/package-runner.js +113 -0
- package/dist/daemon/package-runner.js.map +1 -0
- package/dist/daemon/parser.d.ts +45 -7
- package/dist/daemon/parser.d.ts.map +1 -1
- package/dist/daemon/parser.js +153 -53
- package/dist/daemon/parser.js.map +1 -1
- package/dist/daemon/powershell.d.ts +25 -0
- package/dist/daemon/powershell.d.ts.map +1 -0
- package/dist/daemon/powershell.js +30 -0
- package/dist/daemon/powershell.js.map +1 -0
- package/dist/daemon/preflight.d.ts.map +1 -1
- package/dist/daemon/preflight.js +5 -1
- package/dist/daemon/preflight.js.map +1 -1
- package/dist/daemon/prune.d.ts +101 -0
- package/dist/daemon/prune.d.ts.map +1 -0
- package/dist/daemon/prune.js +287 -0
- package/dist/daemon/prune.js.map +1 -0
- package/dist/daemon/queue-error.d.ts +47 -0
- package/dist/daemon/queue-error.d.ts.map +1 -0
- package/dist/daemon/queue-error.js +59 -0
- package/dist/daemon/queue-error.js.map +1 -0
- package/dist/daemon/root-daemon.d.ts +60 -0
- package/dist/daemon/root-daemon.d.ts.map +1 -0
- package/dist/daemon/root-daemon.js +86 -0
- package/dist/daemon/root-daemon.js.map +1 -0
- package/dist/daemon/scoop.d.ts +52 -0
- package/dist/daemon/scoop.d.ts.map +1 -0
- package/dist/daemon/scoop.js +84 -0
- package/dist/daemon/scoop.js.map +1 -0
- package/dist/daemon/scrubber.d.ts +396 -14
- package/dist/daemon/scrubber.d.ts.map +1 -1
- package/dist/daemon/scrubber.js +915 -52
- package/dist/daemon/scrubber.js.map +1 -1
- package/dist/daemon/status.d.ts +306 -11
- package/dist/daemon/status.d.ts.map +1 -1
- package/dist/daemon/status.js +568 -43
- package/dist/daemon/status.js.map +1 -1
- package/dist/daemon/supervise.d.ts +78 -0
- package/dist/daemon/supervise.d.ts.map +1 -0
- package/dist/daemon/supervise.js +121 -0
- package/dist/daemon/supervise.js.map +1 -0
- package/dist/daemon/supervisor.d.ts +18 -0
- package/dist/daemon/supervisor.d.ts.map +1 -0
- package/dist/daemon/supervisor.js +56 -0
- package/dist/daemon/supervisor.js.map +1 -0
- package/dist/daemon/syncer.d.ts +380 -21
- package/dist/daemon/syncer.d.ts.map +1 -1
- package/dist/daemon/syncer.js +1432 -182
- package/dist/daemon/syncer.js.map +1 -1
- package/dist/daemon/systemd.d.ts +109 -0
- package/dist/daemon/systemd.d.ts.map +1 -0
- package/dist/daemon/systemd.js +363 -0
- package/dist/daemon/systemd.js.map +1 -0
- package/dist/daemon/types.d.ts +58 -6
- package/dist/daemon/types.d.ts.map +1 -1
- package/dist/daemon/vault-changed.d.ts +29 -0
- package/dist/daemon/vault-changed.d.ts.map +1 -0
- package/dist/daemon/vault-changed.js +47 -0
- package/dist/daemon/vault-changed.js.map +1 -0
- package/dist/daemon/vault-key-missing.d.ts +70 -0
- package/dist/daemon/vault-key-missing.d.ts.map +1 -0
- package/dist/daemon/vault-key-missing.js +125 -0
- package/dist/daemon/vault-key-missing.js.map +1 -0
- package/dist/daemon/watcher.d.ts +87 -4
- package/dist/daemon/watcher.d.ts.map +1 -1
- package/dist/daemon/watcher.js +286 -36
- package/dist/daemon/watcher.js.map +1 -1
- package/dist/daemon/worker-main.js +352 -64
- package/dist/daemon/worker-main.js.map +1 -1
- package/dist/daemon/worker.js +19 -1
- package/dist/daemon/worker.js.map +1 -1
- package/dist/import-resume.d.ts +163 -0
- package/dist/import-resume.d.ts.map +1 -0
- package/dist/import-resume.js +267 -0
- package/dist/import-resume.js.map +1 -0
- package/dist/index.js +242 -33
- package/dist/index.js.map +1 -1
- package/dist/message-bounds.d.ts +52 -0
- package/dist/message-bounds.d.ts.map +1 -0
- package/dist/message-bounds.js +157 -0
- package/dist/message-bounds.js.map +1 -0
- package/dist/output.d.ts +14 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +33 -5
- package/dist/output.js.map +1 -1
- package/dist/private-files.d.ts +126 -0
- package/dist/private-files.d.ts.map +1 -0
- package/dist/private-files.js +372 -0
- package/dist/private-files.js.map +1 -0
- package/dist/server-url.d.ts +31 -0
- package/dist/server-url.d.ts.map +1 -0
- package/dist/server-url.js +47 -0
- package/dist/server-url.js.map +1 -0
- package/dist/vault-key.d.ts +122 -0
- package/dist/vault-key.d.ts.map +1 -0
- package/dist/vault-key.js +273 -0
- package/dist/vault-key.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { Conversation, Message, MessageInput } from "@getengram/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Picking an interrupted import up where it stopped (engram#751).
|
|
4
|
+
*
|
|
5
|
+
* `engram import` used to be all or nothing for each conversation: one that
|
|
6
|
+
* Engram already had was skipped as "already imported". So a conversation
|
|
7
|
+
* cut off partway, by a rate limit, a lost connection, a plan limit or
|
|
8
|
+
* Ctrl+C, kept only its first messages however often the import ran again.
|
|
9
|
+
*
|
|
10
|
+
* Now each request that stores a conversation's messages carries a marker,
|
|
11
|
+
* the import cursor. It says how many of the file's messages Engram has
|
|
12
|
+
* once that request is stored, with a digest of them. Engram takes it off
|
|
13
|
+
* the message and records it on the conversation in the same write as the
|
|
14
|
+
* messages (apps/mcp-server/src/services/import-cursor.ts), so it is never
|
|
15
|
+
* ahead of or behind what is stored. A re-run reads it and sends the rest.
|
|
16
|
+
*
|
|
17
|
+
* Counting the conversation's messages can't stand in for it: deleting a
|
|
18
|
+
* message lowers the count, so a re-run that trusted it would send one
|
|
19
|
+
* message twice, or bring back one the user deleted.
|
|
20
|
+
*/
|
|
21
|
+
export declare const IMPORT_CURSOR_KEY = "import_cursor";
|
|
22
|
+
export interface ImportCursor {
|
|
23
|
+
v: 1;
|
|
24
|
+
/** How many of the source conversation's messages Engram has. */
|
|
25
|
+
next: number;
|
|
26
|
+
/** ImportDigest of those messages, hex. */
|
|
27
|
+
digest: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A cursor exactly as the CLI writes it, or null. The same rules as the
|
|
31
|
+
* worker's parseImportCursor (a test runs both over the same values): what
|
|
32
|
+
* Engram records is what a re-run reads.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseImportCursor(value: unknown): ImportCursor | null;
|
|
35
|
+
/**
|
|
36
|
+
* What a cursor's digest covers: each message's role and length, in order,
|
|
37
|
+
* and never its words.
|
|
38
|
+
*
|
|
39
|
+
* It only has to tell whether the file still begins with the messages an
|
|
40
|
+
* earlier run sent, and a different version of a conversation (an earlier
|
|
41
|
+
* message edited, another branch followed) changes the lengths. A hash of
|
|
42
|
+
* the text would do that too, but it would sit in Engram next to messages
|
|
43
|
+
* whose secrets were taken out of them: [VAULT:…] for what the vault
|
|
44
|
+
* encrypted on this machine, [REDACTED] for what Engram redacts. Anyone
|
|
45
|
+
* who could read the conversation could then test guesses at a short
|
|
46
|
+
* secret, a password or an SSN, against the hash, offline. The lengths
|
|
47
|
+
* give them nothing to test a guess against.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ImportDigest {
|
|
50
|
+
private readonly hash;
|
|
51
|
+
add(m: MessageInput): void;
|
|
52
|
+
hex(): string;
|
|
53
|
+
}
|
|
54
|
+
/** The digest of the first `n` messages. */
|
|
55
|
+
export declare function prefixDigest(messages: readonly MessageInput[], n: number): string;
|
|
56
|
+
/** The batch with `cursor` in its last message's metadata, the one place Engram reads it. */
|
|
57
|
+
export declare function markBatch(batch: readonly MessageInput[], cursor: ImportCursor): MessageInput[];
|
|
58
|
+
/** What a re-run does with a conversation Engram already has. */
|
|
59
|
+
export type ResumePlan =
|
|
60
|
+
/** Send the file's messages from `from` on: Engram has the ones before. */
|
|
61
|
+
{
|
|
62
|
+
kind: "send";
|
|
63
|
+
from: number;
|
|
64
|
+
}
|
|
65
|
+
/** Engram has every message the file has. */
|
|
66
|
+
| {
|
|
67
|
+
kind: "done";
|
|
68
|
+
}
|
|
69
|
+
/** The file's copy of the conversation differs from the one imported before. */
|
|
70
|
+
| {
|
|
71
|
+
kind: "changed";
|
|
72
|
+
}
|
|
73
|
+
/** Engram has `stored` messages and can't tell they're the file's first ones. */
|
|
74
|
+
| {
|
|
75
|
+
kind: "kept";
|
|
76
|
+
stored: number;
|
|
77
|
+
}
|
|
78
|
+
/** Imported before the cursor: read what Engram has and compare (planFromStored). */
|
|
79
|
+
| {
|
|
80
|
+
kind: "check";
|
|
81
|
+
};
|
|
82
|
+
/** A plan with nothing left to check. */
|
|
83
|
+
export type SettledPlan = Exclude<ResumePlan, {
|
|
84
|
+
kind: "check";
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* A time as Engram's database writes it ("2026-11-12 20:55:44", UTC), in
|
|
88
|
+
* milliseconds, or null for anything else.
|
|
89
|
+
*/
|
|
90
|
+
export declare function serverTime(value: unknown): number | null;
|
|
91
|
+
/**
|
|
92
|
+
* What to do with a conversation Engram already has, from what Engram says
|
|
93
|
+
* of it: its cursor, else (imported before there was one) its message count
|
|
94
|
+
* and times.
|
|
95
|
+
*/
|
|
96
|
+
export declare function planResume(conversation: Conversation, source: readonly MessageInput[]): ResumePlan;
|
|
97
|
+
/**
|
|
98
|
+
* Most an append's last message and the conversation's update time can
|
|
99
|
+
* differ by. Engram's database writes both, to the second, in the one batch
|
|
100
|
+
* that stores the messages, so they differ by a second at most, when the
|
|
101
|
+
* batch runs across one. The rest is margin.
|
|
102
|
+
*/
|
|
103
|
+
export declare const SAME_WRITE_MS = 2000;
|
|
104
|
+
/**
|
|
105
|
+
* What to do with a conversation imported before there were cursors, from
|
|
106
|
+
* every message Engram has of it (`stored`, in order) and the conversation
|
|
107
|
+
* as Engram described it when the last of them was read.
|
|
108
|
+
*
|
|
109
|
+
* Engram's messages must be exactly the file's first ones, role for role,
|
|
110
|
+
* and the last thing written to the conversation must be the append that
|
|
111
|
+
* stored the last of them: deleting a message moves the conversation's
|
|
112
|
+
* update time, so a conversation whose last messages the user deleted is
|
|
113
|
+
* left as it is rather than given them back. Anything that can't be
|
|
114
|
+
* checked (a body hidden by the account's privacy setting, a time that
|
|
115
|
+
* doesn't parse, a count that moved while reading) leaves it as it is too.
|
|
116
|
+
*/
|
|
117
|
+
export declare function planFromStored(stored: readonly Message[], conversation: Conversation, source: readonly MessageInput[]): SettledPlan;
|
|
118
|
+
/**
|
|
119
|
+
* At most how many of the file's messages an import sends to a conversation
|
|
120
|
+
* Engram already has, from what Engram says of the conversation without
|
|
121
|
+
* reading its messages (engram#754): what planExisting plans, and for one
|
|
122
|
+
* imported before there was a cursor, the messages past the ones Engram
|
|
123
|
+
* has, which is what it sends when those are the file's first ones.
|
|
124
|
+
*/
|
|
125
|
+
export declare function mostToSend(conversation: Conversation, source: readonly MessageInput[]): number;
|
|
126
|
+
/**
|
|
127
|
+
* Whether `stored` is `source` as Engram stores it: the same text, but
|
|
128
|
+
* where `stored` has a stand-in for something taken out ([REDACTED], or
|
|
129
|
+
* [VAULT:…]), `source` has at least one character of anything.
|
|
130
|
+
*
|
|
131
|
+
* Read in one pass, with no regular expression built from either text:
|
|
132
|
+
* each piece of text between stand-ins is found at the first place it can
|
|
133
|
+
* start, which leaves the most room for the pieces after it, so the first
|
|
134
|
+
* match found is a match if any is.
|
|
135
|
+
*/
|
|
136
|
+
export declare function sameAsStored(stored: string, source: string): boolean;
|
|
137
|
+
/** A refusal that says nothing was stored, and passes: waited out, then tried again. */
|
|
138
|
+
export type Waitable = "rate_limit" | "paused";
|
|
139
|
+
/** How long a call waits out one kind of refusal in a row before the import stops. */
|
|
140
|
+
export declare const PATIENCE_MS: Record<Waitable, number>;
|
|
141
|
+
/** The import stopped waiting: Engram kept refusing for longer than PATIENCE_MS. */
|
|
142
|
+
export declare class StillRefused extends Error {
|
|
143
|
+
readonly kind: Waitable;
|
|
144
|
+
readonly refusal: unknown;
|
|
145
|
+
constructor(kind: Waitable, refusal: unknown);
|
|
146
|
+
}
|
|
147
|
+
/** The waits, replaceable in tests. */
|
|
148
|
+
export declare const importTiming: {
|
|
149
|
+
sleep: (ms: number) => Promise<void>;
|
|
150
|
+
random: () => number;
|
|
151
|
+
};
|
|
152
|
+
/** The wait before try `attempt + 1` of a rate-limited call: 5 s doubling to a minute, each with some jitter. */
|
|
153
|
+
export declare function rateLimitWait(attempt: number, random?: number): number;
|
|
154
|
+
/** The wait between tries while Engram is paused for maintenance. */
|
|
155
|
+
export declare const PAUSE_WAIT_MS = 30000;
|
|
156
|
+
/**
|
|
157
|
+
* A caller that waits out a rate limit or a maintenance pause and tries
|
|
158
|
+
* again: Engram refuses both before anything is written, so trying again
|
|
159
|
+
* can't store a message twice. Every other failure is thrown at once.
|
|
160
|
+
* `say` hears of each kind once, the first time a call waits for it.
|
|
161
|
+
*/
|
|
162
|
+
export declare function patientCaller(say: (kind: Waitable) => void): <T>(call: () => Promise<T>) => Promise<T>;
|
|
163
|
+
//# sourceMappingURL=import-resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resume.d.ts","sourceRoot":"","sources":["../src/import-resume.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI1E;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;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QAAQ,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAsBtG"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { classifyError } from "./daemon/status.js";
|
|
3
|
+
import { boundContent } from "./message-bounds.js";
|
|
4
|
+
/**
|
|
5
|
+
* Picking an interrupted import up where it stopped (engram#751).
|
|
6
|
+
*
|
|
7
|
+
* `engram import` used to be all or nothing for each conversation: one that
|
|
8
|
+
* Engram already had was skipped as "already imported". So a conversation
|
|
9
|
+
* cut off partway, by a rate limit, a lost connection, a plan limit or
|
|
10
|
+
* Ctrl+C, kept only its first messages however often the import ran again.
|
|
11
|
+
*
|
|
12
|
+
* Now each request that stores a conversation's messages carries a marker,
|
|
13
|
+
* the import cursor. It says how many of the file's messages Engram has
|
|
14
|
+
* once that request is stored, with a digest of them. Engram takes it off
|
|
15
|
+
* the message and records it on the conversation in the same write as the
|
|
16
|
+
* messages (apps/mcp-server/src/services/import-cursor.ts), so it is never
|
|
17
|
+
* ahead of or behind what is stored. A re-run reads it and sends the rest.
|
|
18
|
+
*
|
|
19
|
+
* Counting the conversation's messages can't stand in for it: deleting a
|
|
20
|
+
* message lowers the count, so a re-run that trusted it would send one
|
|
21
|
+
* message twice, or bring back one the user deleted.
|
|
22
|
+
*/
|
|
23
|
+
export const IMPORT_CURSOR_KEY = "import_cursor";
|
|
24
|
+
const DIGEST = /^[0-9a-f]{64}$/;
|
|
25
|
+
/**
|
|
26
|
+
* A cursor exactly as the CLI writes it, or null. The same rules as the
|
|
27
|
+
* worker's parseImportCursor (a test runs both over the same values): what
|
|
28
|
+
* Engram records is what a re-run reads.
|
|
29
|
+
*/
|
|
30
|
+
export function parseImportCursor(value) {
|
|
31
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
32
|
+
return null;
|
|
33
|
+
const c = value;
|
|
34
|
+
if (c.v !== 1)
|
|
35
|
+
return null;
|
|
36
|
+
if (typeof c.next !== "number" || !Number.isSafeInteger(c.next) || c.next < 1)
|
|
37
|
+
return null;
|
|
38
|
+
if (typeof c.digest !== "string" || !DIGEST.test(c.digest))
|
|
39
|
+
return null;
|
|
40
|
+
return { v: 1, next: c.next, digest: c.digest };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What a cursor's digest covers: each message's role and length, in order,
|
|
44
|
+
* and never its words.
|
|
45
|
+
*
|
|
46
|
+
* It only has to tell whether the file still begins with the messages an
|
|
47
|
+
* earlier run sent, and a different version of a conversation (an earlier
|
|
48
|
+
* message edited, another branch followed) changes the lengths. A hash of
|
|
49
|
+
* the text would do that too, but it would sit in Engram next to messages
|
|
50
|
+
* whose secrets were taken out of them: [VAULT:…] for what the vault
|
|
51
|
+
* encrypted on this machine, [REDACTED] for what Engram redacts. Anyone
|
|
52
|
+
* who could read the conversation could then test guesses at a short
|
|
53
|
+
* secret, a password or an SSN, against the hash, offline. The lengths
|
|
54
|
+
* give them nothing to test a guess against.
|
|
55
|
+
*/
|
|
56
|
+
export class ImportDigest {
|
|
57
|
+
hash = createHash("sha256").update("engram-import-cursor/1\n");
|
|
58
|
+
add(m) {
|
|
59
|
+
this.hash.update(`${m.role} ${m.content.length}\n`);
|
|
60
|
+
}
|
|
61
|
+
hex() {
|
|
62
|
+
return this.hash.copy().digest("hex");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** The digest of the first `n` messages. */
|
|
66
|
+
export function prefixDigest(messages, n) {
|
|
67
|
+
const digest = new ImportDigest();
|
|
68
|
+
for (let i = 0; i < n; i++)
|
|
69
|
+
digest.add(messages[i]);
|
|
70
|
+
return digest.hex();
|
|
71
|
+
}
|
|
72
|
+
/** The batch with `cursor` in its last message's metadata, the one place Engram reads it. */
|
|
73
|
+
export function markBatch(batch, cursor) {
|
|
74
|
+
const marked = batch.slice();
|
|
75
|
+
const last = marked[marked.length - 1];
|
|
76
|
+
marked[marked.length - 1] = { ...last, metadata: { ...last.metadata, [IMPORT_CURSOR_KEY]: cursor } };
|
|
77
|
+
return marked;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A time as Engram's database writes it ("2026-11-12 20:55:44", UTC), in
|
|
81
|
+
* milliseconds, or null for anything else.
|
|
82
|
+
*/
|
|
83
|
+
export function serverTime(value) {
|
|
84
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(value)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const t = Date.parse(`${value.replace(" ", "T").replace(/Z$/, "")}Z`);
|
|
88
|
+
return Number.isFinite(t) ? t : null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* What to do with a conversation Engram already has, from what Engram says
|
|
92
|
+
* of it: its cursor, else (imported before there was one) its message count
|
|
93
|
+
* and times.
|
|
94
|
+
*/
|
|
95
|
+
export function planResume(conversation, source) {
|
|
96
|
+
const metadata = conversation.metadata;
|
|
97
|
+
const recorded = metadata !== null && typeof metadata === "object" && !Array.isArray(metadata)
|
|
98
|
+
? metadata[IMPORT_CURSOR_KEY]
|
|
99
|
+
: undefined;
|
|
100
|
+
const cursor = parseImportCursor(recorded);
|
|
101
|
+
if (cursor) {
|
|
102
|
+
// Deleted messages don't matter here: the cursor counts what was sent.
|
|
103
|
+
if (cursor.next > source.length || cursor.digest !== prefixDigest(source, cursor.next)) {
|
|
104
|
+
return { kind: "changed" };
|
|
105
|
+
}
|
|
106
|
+
return cursor.next === source.length ? { kind: "done" } : { kind: "send", from: cursor.next };
|
|
107
|
+
}
|
|
108
|
+
const stored = conversation.messageCount;
|
|
109
|
+
if (!Number.isSafeInteger(stored) || stored < 0)
|
|
110
|
+
return { kind: "kept", stored: 0 };
|
|
111
|
+
if (stored >= source.length)
|
|
112
|
+
return { kind: "done" };
|
|
113
|
+
if (stored > 0)
|
|
114
|
+
return { kind: "check" };
|
|
115
|
+
// Empty. Send it all only if nothing was ever written to it: an append
|
|
116
|
+
// and a message delete each move updated_at, so a conversation emptied
|
|
117
|
+
// by deletes is the user's, and stays as it is.
|
|
118
|
+
const created = serverTime(conversation.createdAt);
|
|
119
|
+
return created !== null && conversation.updatedAt === conversation.createdAt
|
|
120
|
+
? { kind: "send", from: 0 }
|
|
121
|
+
: { kind: "kept", stored: 0 };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Most an append's last message and the conversation's update time can
|
|
125
|
+
* differ by. Engram's database writes both, to the second, in the one batch
|
|
126
|
+
* that stores the messages, so they differ by a second at most, when the
|
|
127
|
+
* batch runs across one. The rest is margin.
|
|
128
|
+
*/
|
|
129
|
+
export const SAME_WRITE_MS = 2_000;
|
|
130
|
+
/**
|
|
131
|
+
* What to do with a conversation imported before there were cursors, from
|
|
132
|
+
* every message Engram has of it (`stored`, in order) and the conversation
|
|
133
|
+
* as Engram described it when the last of them was read.
|
|
134
|
+
*
|
|
135
|
+
* Engram's messages must be exactly the file's first ones, role for role,
|
|
136
|
+
* and the last thing written to the conversation must be the append that
|
|
137
|
+
* stored the last of them: deleting a message moves the conversation's
|
|
138
|
+
* update time, so a conversation whose last messages the user deleted is
|
|
139
|
+
* left as it is rather than given them back. Anything that can't be
|
|
140
|
+
* checked (a body hidden by the account's privacy setting, a time that
|
|
141
|
+
* doesn't parse, a count that moved while reading) leaves it as it is too.
|
|
142
|
+
*/
|
|
143
|
+
export function planFromStored(stored, conversation, source) {
|
|
144
|
+
if (stored.length >= source.length)
|
|
145
|
+
return { kind: "done" };
|
|
146
|
+
const kept = { kind: "kept", stored: stored.length };
|
|
147
|
+
if (stored.length === 0 || conversation.messageCount !== stored.length)
|
|
148
|
+
return kept;
|
|
149
|
+
for (const [i, m] of stored.entries()) {
|
|
150
|
+
const want = source[i];
|
|
151
|
+
if (m.role !== want.role || typeof m.content !== "string")
|
|
152
|
+
return kept;
|
|
153
|
+
if (!sameAsStored(m.content, want.content) && !sameAsStored(m.content, boundContent(want.content))) {
|
|
154
|
+
return kept;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const last = serverTime(stored[stored.length - 1].createdAt);
|
|
158
|
+
const updated = serverTime(conversation.updatedAt);
|
|
159
|
+
if (last === null || updated === null || Math.abs(updated - last) > SAME_WRITE_MS)
|
|
160
|
+
return kept;
|
|
161
|
+
return { kind: "send", from: stored.length };
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* At most how many of the file's messages an import sends to a conversation
|
|
165
|
+
* Engram already has, from what Engram says of the conversation without
|
|
166
|
+
* reading its messages (engram#754): what planExisting plans, and for one
|
|
167
|
+
* imported before there was a cursor, the messages past the ones Engram
|
|
168
|
+
* has, which is what it sends when those are the file's first ones.
|
|
169
|
+
*/
|
|
170
|
+
export function mostToSend(conversation, source) {
|
|
171
|
+
if (conversation.messageCount >= source.length)
|
|
172
|
+
return 0;
|
|
173
|
+
const plan = planResume(conversation, source);
|
|
174
|
+
if (plan.kind === "send")
|
|
175
|
+
return source.length - plan.from;
|
|
176
|
+
if (plan.kind === "check")
|
|
177
|
+
return source.length - conversation.messageCount;
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
/** What stands in for text Engram didn't store: Engram's redaction, and the vault's reference to a secret it encrypted. */
|
|
181
|
+
const STAND_IN = /\[REDACTED\]|\[VAULT:[^\]\s]{1,100}\]/g;
|
|
182
|
+
/**
|
|
183
|
+
* Whether `stored` is `source` as Engram stores it: the same text, but
|
|
184
|
+
* where `stored` has a stand-in for something taken out ([REDACTED], or
|
|
185
|
+
* [VAULT:…]), `source` has at least one character of anything.
|
|
186
|
+
*
|
|
187
|
+
* Read in one pass, with no regular expression built from either text:
|
|
188
|
+
* each piece of text between stand-ins is found at the first place it can
|
|
189
|
+
* start, which leaves the most room for the pieces after it, so the first
|
|
190
|
+
* match found is a match if any is.
|
|
191
|
+
*/
|
|
192
|
+
export function sameAsStored(stored, source) {
|
|
193
|
+
const pieces = stored.split(STAND_IN);
|
|
194
|
+
if (pieces.length === 1)
|
|
195
|
+
return stored === source;
|
|
196
|
+
const head = pieces[0];
|
|
197
|
+
const tail = pieces[pieces.length - 1];
|
|
198
|
+
if (!source.startsWith(head) || !source.endsWith(tail))
|
|
199
|
+
return false;
|
|
200
|
+
const end = source.length - tail.length;
|
|
201
|
+
let at = head.length;
|
|
202
|
+
for (const piece of pieces.slice(1, -1)) {
|
|
203
|
+
const found = source.indexOf(piece, at + 1);
|
|
204
|
+
if (found === -1)
|
|
205
|
+
return false;
|
|
206
|
+
at = found + piece.length;
|
|
207
|
+
}
|
|
208
|
+
return end - at >= 1;
|
|
209
|
+
}
|
|
210
|
+
/** How long a call waits out one kind of refusal in a row before the import stops. */
|
|
211
|
+
export const PATIENCE_MS = { rate_limit: 15 * 60_000, paused: 30 * 60_000 };
|
|
212
|
+
/** The import stopped waiting: Engram kept refusing for longer than PATIENCE_MS. */
|
|
213
|
+
export class StillRefused extends Error {
|
|
214
|
+
kind;
|
|
215
|
+
refusal;
|
|
216
|
+
constructor(kind, refusal) {
|
|
217
|
+
super(kind === "paused" ? "Engram is still paused for maintenance" : "Engram is still limiting how fast this account can save");
|
|
218
|
+
this.kind = kind;
|
|
219
|
+
this.refusal = refusal;
|
|
220
|
+
this.name = "StillRefused";
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** The waits, replaceable in tests. */
|
|
224
|
+
export const importTiming = {
|
|
225
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
226
|
+
random: () => Math.random(),
|
|
227
|
+
};
|
|
228
|
+
/** The wait before try `attempt + 1` of a rate-limited call: 5 s doubling to a minute, each with some jitter. */
|
|
229
|
+
export function rateLimitWait(attempt, random = importTiming.random()) {
|
|
230
|
+
const base = Math.min(60_000, 5_000 * 2 ** Math.min(attempt, 4));
|
|
231
|
+
return Math.round(base / 2 + (random * base) / 2);
|
|
232
|
+
}
|
|
233
|
+
/** The wait between tries while Engram is paused for maintenance. */
|
|
234
|
+
export const PAUSE_WAIT_MS = 30_000;
|
|
235
|
+
/**
|
|
236
|
+
* A caller that waits out a rate limit or a maintenance pause and tries
|
|
237
|
+
* again: Engram refuses both before anything is written, so trying again
|
|
238
|
+
* can't store a message twice. Every other failure is thrown at once.
|
|
239
|
+
* `say` hears of each kind once, the first time a call waits for it.
|
|
240
|
+
*/
|
|
241
|
+
export function patientCaller(say) {
|
|
242
|
+
const said = new Set();
|
|
243
|
+
return async function patiently(call) {
|
|
244
|
+
let waited = 0;
|
|
245
|
+
let attempt = 0;
|
|
246
|
+
for (;;) {
|
|
247
|
+
try {
|
|
248
|
+
return await call();
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
const kind = classifyError(err);
|
|
252
|
+
if (kind !== "rate_limit" && kind !== "paused")
|
|
253
|
+
throw err;
|
|
254
|
+
const wait = kind === "paused" ? PAUSE_WAIT_MS : rateLimitWait(attempt++);
|
|
255
|
+
if (waited + wait > PATIENCE_MS[kind])
|
|
256
|
+
throw new StillRefused(kind, err);
|
|
257
|
+
if (!said.has(kind)) {
|
|
258
|
+
said.add(kind);
|
|
259
|
+
say(kind);
|
|
260
|
+
}
|
|
261
|
+
await importTiming.sleep(wait);
|
|
262
|
+
waited += wait;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=import-resume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resume.js","sourceRoot":"","sources":["../src/import-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,CAAC,MAAM,iBAAiB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