aicodeman 1.47.0 → 1.48.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 +3 -0
- package/dist/cli-notify.d.ts +34 -0
- package/dist/cli-notify.d.ts.map +1 -0
- package/dist/cli-notify.js +100 -0
- package/dist/cli-notify.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -1
- package/dist/config/cli-registry/patterns.d.ts +1 -1
- package/dist/config/cli-registry/patterns.d.ts.map +1 -1
- package/dist/config/cli-registry/patterns.js +4 -0
- package/dist/config/cli-registry/patterns.js.map +1 -1
- package/dist/config/cli-registry/schema.d.ts +6 -0
- package/dist/config/cli-registry/schema.d.ts.map +1 -1
- package/dist/config/cli-registry/schema.js +62 -2
- package/dist/config/cli-registry/schema.js.map +1 -1
- package/dist/config/cli-registry/stock.d.ts.map +1 -1
- package/dist/config/cli-registry/stock.js +43 -26
- package/dist/config/cli-registry/stock.js.map +1 -1
- package/dist/config/cli-registry/types.d.ts +47 -17
- package/dist/config/cli-registry/types.d.ts.map +1 -1
- package/dist/config/path-probe.d.ts +6 -0
- package/dist/config/path-probe.d.ts.map +1 -1
- package/dist/config/path-probe.js +6 -0
- package/dist/config/path-probe.js.map +1 -1
- package/dist/config-backup.d.ts +1 -1
- package/dist/config-backup.d.ts.map +1 -1
- package/dist/config-backup.js +2 -0
- package/dist/config-backup.js.map +1 -1
- package/dist/custom-model-hosts.d.ts +32 -8
- package/dist/custom-model-hosts.d.ts.map +1 -1
- package/dist/custom-model-hosts.js +10 -0
- package/dist/custom-model-hosts.js.map +1 -1
- package/dist/custom-model-injection-apply.d.ts +19 -5
- package/dist/custom-model-injection-apply.d.ts.map +1 -1
- package/dist/custom-model-injection-apply.js +88 -8
- package/dist/custom-model-injection-apply.js.map +1 -1
- package/dist/custom-model-injection.d.ts +6 -0
- package/dist/custom-model-injection.d.ts.map +1 -1
- package/dist/custom-model-injection.js +92 -10
- package/dist/custom-model-injection.js.map +1 -1
- package/dist/discord-bridge.d.ts +338 -0
- package/dist/discord-bridge.d.ts.map +1 -0
- package/dist/discord-bridge.js +1256 -0
- package/dist/discord-bridge.js.map +1 -0
- package/dist/edit-history-local-source.d.ts +83 -0
- package/dist/edit-history-local-source.d.ts.map +1 -0
- package/dist/edit-history-local-source.js +198 -0
- package/dist/edit-history-local-source.js.map +1 -0
- package/dist/edit-history-parse.d.ts +114 -0
- package/dist/edit-history-parse.d.ts.map +1 -0
- package/dist/edit-history-parse.js +312 -0
- package/dist/edit-history-parse.js.map +1 -0
- package/dist/edit-history-store.d.ts +209 -0
- package/dist/edit-history-store.d.ts.map +1 -0
- package/dist/edit-history-store.js +599 -0
- package/dist/edit-history-store.js.map +1 -0
- package/dist/git-clone.d.ts +6 -1
- package/dist/git-clone.d.ts.map +1 -1
- package/dist/git-clone.js +79 -14
- package/dist/git-clone.js.map +1 -1
- package/dist/image-watcher.js +4 -4
- package/dist/image-watcher.js.map +1 -1
- package/dist/mux-interface.d.ts +10 -1
- package/dist/mux-interface.d.ts.map +1 -1
- package/dist/session-cli-registry-bridge.d.ts.map +1 -1
- package/dist/session-cli-registry-bridge.js +4 -0
- package/dist/session-cli-registry-bridge.js.map +1 -1
- package/dist/session.d.ts +70 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +147 -4
- package/dist/session.js.map +1 -1
- package/dist/tmux-manager.d.ts +40 -0
- package/dist/tmux-manager.d.ts.map +1 -1
- package/dist/tmux-manager.js +62 -0
- package/dist/tmux-manager.js.map +1 -1
- package/dist/types/discord.d.ts +55 -0
- package/dist/types/discord.d.ts.map +1 -0
- package/dist/types/discord.js +18 -0
- package/dist/types/discord.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/session.d.ts +13 -0
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js.map +1 -1
- package/dist/web/case-path.d.ts +2 -0
- package/dist/web/case-path.d.ts.map +1 -1
- package/dist/web/case-path.js +3 -3
- package/dist/web/case-path.js.map +1 -1
- package/dist/web/edit-history-sync.d.ts +158 -0
- package/dist/web/edit-history-sync.d.ts.map +1 -0
- package/dist/web/edit-history-sync.js +445 -0
- package/dist/web/edit-history-sync.js.map +1 -0
- package/dist/web/paste-image-gc.d.ts +6 -0
- package/dist/web/paste-image-gc.d.ts.map +1 -1
- package/dist/web/paste-image-gc.js +6 -0
- package/dist/web/paste-image-gc.js.map +1 -1
- package/dist/web/ports/session-port.d.ts +13 -0
- package/dist/web/ports/session-port.d.ts.map +1 -1
- package/dist/web/public/admin-ui.js.gz +0 -0
- package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
- package/dist/web/public/{app.fe8a6b4c.js → app.963b5ba8.js} +6 -6
- package/dist/web/public/app.963b5ba8.js.br +0 -0
- package/dist/web/public/app.963b5ba8.js.gz +0 -0
- package/dist/web/public/approvals-ui.js.gz +0 -0
- package/dist/web/public/{constants.affcdde6.js → constants.782170e1.js} +114 -25
- package/dist/web/public/constants.782170e1.js.br +0 -0
- package/dist/web/public/constants.782170e1.js.gz +0 -0
- package/dist/web/public/cron-ui.js.gz +0 -0
- package/dist/web/public/edit-history-ui.js +630 -0
- package/dist/web/public/edit-history-ui.js.br +0 -0
- package/dist/web/public/edit-history-ui.js.gz +0 -0
- package/dist/web/public/entrance-animations.js.gz +0 -0
- package/dist/web/public/git-status-ui.js.gz +0 -0
- package/dist/web/public/header-divider.eb2d2463.js.gz +0 -0
- package/dist/web/public/home-sessions.js.gz +0 -0
- package/dist/web/public/host-wake-ui.js.gz +0 -0
- package/dist/web/public/i18n.33f930d7.js +2 -0
- package/dist/web/public/i18n.33f930d7.js.br +0 -0
- package/dist/web/public/i18n.33f930d7.js.gz +0 -0
- package/dist/web/public/image-input.a5d0f8f3.js.gz +0 -0
- package/dist/web/public/index.html +160 -14
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.8bc46081.js.gz +0 -0
- package/dist/web/public/{keyboard-accessory.ff64fafc.js → keyboard-accessory.d4ec5957.js} +72 -1
- package/dist/web/public/keyboard-accessory.d4ec5957.js.br +0 -0
- package/dist/web/public/keyboard-accessory.d4ec5957.js.gz +0 -0
- package/dist/web/public/mobile-handlers.f7c3f692.js.gz +0 -0
- package/dist/web/public/mobile-ime-preview.2dbaf262.js.gz +0 -0
- package/dist/web/public/mobile-overview.js.gz +0 -0
- package/dist/web/public/mobile.5ef2ce85.css +1 -0
- package/dist/web/public/mobile.5ef2ce85.css.br +0 -0
- package/dist/web/public/mobile.5ef2ce85.css.gz +0 -0
- package/dist/web/public/notification-manager.feb82c04.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/{panels-ui.4a56ee63.js → panels-ui.b100727d.js} +2 -2
- package/dist/web/public/panels-ui.b100727d.js.br +0 -0
- package/dist/web/public/{panels-ui.4a56ee63.js.gz → panels-ui.b100727d.js.gz} +0 -0
- package/dist/web/public/ralph-panel.b350e2ef.js.gz +0 -0
- package/dist/web/public/ralph-wizard.b6c0dd19.js.gz +0 -0
- package/dist/web/public/readmymind-ui.js.gz +0 -0
- package/dist/web/public/reboot-restore-ui.js.gz +0 -0
- package/dist/web/public/{respawn-ui.d7adcf6a.js → respawn-ui.304ba0d4.js} +1 -1
- package/dist/web/public/respawn-ui.304ba0d4.js.br +0 -0
- package/dist/web/public/respawn-ui.304ba0d4.js.gz +0 -0
- package/dist/web/public/sanitize-html.e7147e76.js.gz +0 -0
- package/dist/web/public/security-notices.json +1 -21
- package/dist/web/public/session-lineage.js.gz +0 -0
- package/dist/web/public/{session-ui.426fb671.js → session-ui.5ac82f2c.js} +30 -30
- package/dist/web/public/session-ui.5ac82f2c.js.br +0 -0
- package/dist/web/public/session-ui.5ac82f2c.js.gz +0 -0
- package/dist/web/public/settings-ui.d1d4fb99.js +106 -0
- package/dist/web/public/settings-ui.d1d4fb99.js.br +0 -0
- package/dist/web/public/settings-ui.d1d4fb99.js.gz +0 -0
- package/dist/web/public/spreadsheet-preview-worker.js.gz +0 -0
- package/dist/web/public/spreadsheet-preview.75c751de.js.gz +0 -0
- package/dist/web/public/spreadsheet-xlsx-core.js.gz +0 -0
- package/dist/web/public/styles.77dc538f.css +1 -0
- package/dist/web/public/styles.77dc538f.css.br +0 -0
- package/dist/web/public/styles.77dc538f.css.gz +0 -0
- package/dist/web/public/subagent-windows.07277a58.js.gz +0 -0
- package/dist/web/public/sw.js +2 -2
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/tab-layout-browser.2d6189f7.js.gz +0 -0
- package/dist/web/public/tab-rail-resize.b5cdceaf.js.gz +0 -0
- package/dist/web/public/terminal-keycode229-recovery.98843069.js.gz +0 -0
- package/dist/web/public/terminal-split.js.gz +0 -0
- package/dist/web/public/terminal-tile.js.gz +0 -0
- package/dist/web/public/{terminal-ui.7e787829.js → terminal-ui.d7c75ce8.js} +3 -3
- package/dist/web/public/terminal-ui.d7c75ce8.js.br +0 -0
- package/dist/web/public/terminal-ui.d7c75ce8.js.gz +0 -0
- package/dist/web/public/tile-grid.js.gz +0 -0
- package/dist/web/public/ultracode-panel.js.gz +0 -0
- package/dist/web/public/ultracode-windows.js.gz +0 -0
- package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
- package/dist/web/public/vendor/exceljs.min.js.gz +0 -0
- package/dist/web/public/vendor/fflate.min.js.gz +0 -0
- package/dist/web/public/vendor/marked.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-predictive-echo.276b11d9.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.1be42307.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/voice-input.2342c37b.js.gz +0 -0
- package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
- package/dist/web/public/webview-tabs.js.gz +0 -0
- package/dist/web/public/whats-new.json +9 -8
- package/dist/web/routes/case-routes.d.ts.map +1 -1
- package/dist/web/routes/case-routes.js +104 -8
- package/dist/web/routes/case-routes.js.map +1 -1
- package/dist/web/routes/config-backup-routes.d.ts +5 -1
- package/dist/web/routes/config-backup-routes.d.ts.map +1 -1
- package/dist/web/routes/config-backup-routes.js +4 -1
- package/dist/web/routes/config-backup-routes.js.map +1 -1
- package/dist/web/routes/custom-model-routes.d.ts +7 -2
- package/dist/web/routes/custom-model-routes.d.ts.map +1 -1
- package/dist/web/routes/custom-model-routes.js +51 -6
- package/dist/web/routes/custom-model-routes.js.map +1 -1
- package/dist/web/routes/discord-routes.d.ts +25 -0
- package/dist/web/routes/discord-routes.d.ts.map +1 -0
- package/dist/web/routes/discord-routes.js +206 -0
- package/dist/web/routes/discord-routes.js.map +1 -0
- package/dist/web/routes/edit-history-routes.d.ts +43 -0
- package/dist/web/routes/edit-history-routes.d.ts.map +1 -0
- package/dist/web/routes/edit-history-routes.js +106 -0
- package/dist/web/routes/edit-history-routes.js.map +1 -0
- package/dist/web/routes/file-routes.d.ts.map +1 -1
- package/dist/web/routes/file-routes.js +62 -2
- package/dist/web/routes/file-routes.js.map +1 -1
- package/dist/web/routes/index.d.ts +2 -0
- package/dist/web/routes/index.d.ts.map +1 -1
- package/dist/web/routes/index.js +2 -0
- package/dist/web/routes/index.js.map +1 -1
- package/dist/web/routes/session-routes.d.ts +17 -0
- package/dist/web/routes/session-routes.d.ts.map +1 -1
- package/dist/web/routes/session-routes.js +87 -37
- package/dist/web/routes/session-routes.js.map +1 -1
- package/dist/web/routes/system-routes.d.ts.map +1 -1
- package/dist/web/routes/system-routes.js +1 -0
- package/dist/web/routes/system-routes.js.map +1 -1
- package/dist/web/schemas.d.ts +68 -1
- package/dist/web/schemas.d.ts.map +1 -1
- package/dist/web/schemas.js +77 -1
- package/dist/web/schemas.js.map +1 -1
- package/dist/web/sensitive-path.d.ts.map +1 -1
- package/dist/web/sensitive-path.js +15 -0
- package/dist/web/sensitive-path.js.map +1 -1
- package/dist/web/server.d.ts +43 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +219 -11
- package/dist/web/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/public/app.fe8a6b4c.js.br +0 -0
- package/dist/web/public/app.fe8a6b4c.js.gz +0 -0
- package/dist/web/public/constants.affcdde6.js.br +0 -0
- package/dist/web/public/constants.affcdde6.js.gz +0 -0
- package/dist/web/public/i18n.a618ef4e.js +0 -2
- package/dist/web/public/i18n.a618ef4e.js.br +0 -0
- package/dist/web/public/i18n.a618ef4e.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.ff64fafc.js.br +0 -0
- package/dist/web/public/keyboard-accessory.ff64fafc.js.gz +0 -0
- package/dist/web/public/mobile.1bbd2d67.css +0 -1
- package/dist/web/public/mobile.1bbd2d67.css.br +0 -0
- package/dist/web/public/mobile.1bbd2d67.css.gz +0 -0
- package/dist/web/public/panels-ui.4a56ee63.js.br +0 -0
- package/dist/web/public/respawn-ui.d7adcf6a.js.br +0 -0
- package/dist/web/public/respawn-ui.d7adcf6a.js.gz +0 -0
- package/dist/web/public/session-ui.426fb671.js.br +0 -0
- package/dist/web/public/session-ui.426fb671.js.gz +0 -0
- package/dist/web/public/settings-ui.a191154e.js +0 -106
- package/dist/web/public/settings-ui.a191154e.js.br +0 -0
- package/dist/web/public/settings-ui.a191154e.js.gz +0 -0
- package/dist/web/public/styles.4f0c67a0.css +0 -1
- package/dist/web/public/styles.4f0c67a0.css.br +0 -0
- package/dist/web/public/styles.4f0c67a0.css.gz +0 -0
- package/dist/web/public/terminal-ui.7e787829.js.br +0 -0
- package/dist/web/public/terminal-ui.7e787829.js.gz +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Edit history parser: claude JSONL transcript lines → the files the agent
|
|
3
|
+
* edited (with their diff) and the images its Bash calls may have produced.
|
|
4
|
+
*
|
|
5
|
+
* Every `Edit`/`Write` result line carries `toolUseResult.filePath` and a
|
|
6
|
+
* `structuredPatch` (hunks with ` `/`+`/`-` prefixed lines), so a per-edit diff needs no
|
|
7
|
+
* git. The whole-file fields next to it (`originalFile`, `content`) are never kept.
|
|
8
|
+
*
|
|
9
|
+
* Images rarely come from `Write`; they come from scripts run through Bash. A Bash call
|
|
10
|
+
* yields a CANDIDATE: the image-looking paths in its command and output, with the call's
|
|
11
|
+
* start and end time. Whether a candidate file was actually produced by the call (its
|
|
12
|
+
* mtime falls inside that window) is decided later by whoever can stat it, locally or on
|
|
13
|
+
* the remote host: this module does no IO.
|
|
14
|
+
*
|
|
15
|
+
* Chunked input: a transcript is read in byte ranges, so a Bash `tool_use` and its result
|
|
16
|
+
* can land in different chunks. Unanswered calls are handed back as `pending` and passed
|
|
17
|
+
* into the next call.
|
|
18
|
+
*
|
|
19
|
+
* Tests: `test/edit-history-parse.test.ts`.
|
|
20
|
+
*
|
|
21
|
+
* @module edit-history-parse
|
|
22
|
+
*/
|
|
23
|
+
import { posix } from 'node:path';
|
|
24
|
+
/** Per-record budget for kept hunk lines; a larger patch is cut and marked `truncated`. */
|
|
25
|
+
export const MAX_HUNK_BYTES = 64 * 1024;
|
|
26
|
+
/** Image paths kept per Bash call. */
|
|
27
|
+
export const MAX_IMAGE_CANDIDATES = 20;
|
|
28
|
+
/** Unanswered Bash calls carried between chunks (an interrupted call never gets a result). */
|
|
29
|
+
export const MAX_PENDING_BASH = 200;
|
|
30
|
+
/**
|
|
31
|
+
* Command text kept per unanswered Bash call. Pending calls are persisted with the store, so
|
|
32
|
+
* this bounds it; an image path past this point of a command is still found in the output.
|
|
33
|
+
*/
|
|
34
|
+
export const MAX_PENDING_COMMAND_CHARS = 8192;
|
|
35
|
+
/** Longest id, cwd or agent id of an unanswered Bash call; a call with a longer one is not kept. */
|
|
36
|
+
export const MAX_PENDING_FIELD_CHARS = 4096;
|
|
37
|
+
const IMAGE_EXT = '(?:png|jpe?g|gif|webp|avif|svg)';
|
|
38
|
+
const IMAGE_PATH_RE = new RegExp(`\\.${IMAGE_EXT}$`, 'i');
|
|
39
|
+
// After the extension: no further name character, and no `.ext` (a.png.bak).
|
|
40
|
+
const EXT_END = '(?![\\w-])(?!\\.\\w)';
|
|
41
|
+
// Characters that end an unquoted path token.
|
|
42
|
+
const TOKEN_CHAR = '[^\\s\'"`<>|;&()=,:*?]';
|
|
43
|
+
const PATH_TOKEN_RE = new RegExp([
|
|
44
|
+
// 1. file:// URL (Codex: `Saved to: file:///…`), which may contain spaces up to the extension.
|
|
45
|
+
// The lazy scan stops at the next `file://`: otherwise it runs to the line end from
|
|
46
|
+
// every `file://` of a line that repeats it (quadratic). `:` stays allowed, so a
|
|
47
|
+
// timestamped name (`plot-12:30.png`) is still found.
|
|
48
|
+
`file://(/(?:(?!file://)[^\\n])*?\\.${IMAGE_EXT})${EXT_END}`,
|
|
49
|
+
// 2./3. Quoted paths, spaces allowed.
|
|
50
|
+
`"([^"\\n]*\\.${IMAGE_EXT})"`,
|
|
51
|
+
`'([^'\\n]*\\.${IMAGE_EXT})'`,
|
|
52
|
+
// 4. Unquoted token. A match starts only at a token boundary (line start or a character
|
|
53
|
+
// that ends a token), never inside a URL (`:` is not a boundary), a glob or a longer
|
|
54
|
+
// name. Anchoring at boundaries keeps this linear: a lookbehind that only excluded
|
|
55
|
+
// some characters let a match start at every other character of a long token
|
|
56
|
+
// (`####…`, a base64 blob) and rescan the token from each, quadratic in the line
|
|
57
|
+
// length. The name before the extension must not be empty.
|
|
58
|
+
`(?<=^|[\\s'"\`<>|;&()=,*?])((?:${TOKEN_CHAR}*/)?[^\\s'"\`<>|;&()=,:*?/]+\\.${IMAGE_EXT})${EXT_END}`,
|
|
59
|
+
].join('|'), 'gi');
|
|
60
|
+
/** `image` for the image extensions the panel can thumbnail, else `code`. */
|
|
61
|
+
export function classifyEditPath(path) {
|
|
62
|
+
return IMAGE_PATH_RE.test(path) ? 'image' : 'code';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Image-looking paths in a Bash call's command and output, in order of appearance,
|
|
66
|
+
* deduplicated and capped at {@link MAX_IMAGE_CANDIDATES}. Absolute paths are normalised,
|
|
67
|
+
* `~/` paths stay literal (the host that stats them expands `~`), relative ones are
|
|
68
|
+
* resolved against `cwd` and dropped when `cwd` is not absolute. URLs and globs are
|
|
69
|
+
* skipped.
|
|
70
|
+
*/
|
|
71
|
+
export function extractImagePathCandidates(command, stdout, stderr, cwd) {
|
|
72
|
+
const text = [command, stdout, stderr].join('\n');
|
|
73
|
+
const out = [];
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
for (const m of text.matchAll(PATH_TOKEN_RE)) {
|
|
76
|
+
const raw = m[1] ?? m[2] ?? m[3] ?? m[4];
|
|
77
|
+
if (!raw || raw.includes('://') || /[*?]/.test(raw))
|
|
78
|
+
continue;
|
|
79
|
+
let resolved;
|
|
80
|
+
if (raw.startsWith('/'))
|
|
81
|
+
resolved = posix.normalize(raw);
|
|
82
|
+
else if (raw.startsWith('~/'))
|
|
83
|
+
resolved = raw;
|
|
84
|
+
else if (cwd.startsWith('/'))
|
|
85
|
+
resolved = posix.resolve(cwd, raw);
|
|
86
|
+
else
|
|
87
|
+
continue;
|
|
88
|
+
if (seen.has(resolved))
|
|
89
|
+
continue;
|
|
90
|
+
seen.add(resolved);
|
|
91
|
+
out.push(resolved);
|
|
92
|
+
if (out.length >= MAX_IMAGE_CANDIDATES)
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
function isRecord(v) {
|
|
98
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The hunks of `patch` with their string lines, cut once the lines reach {@link MAX_HUNK_BYTES}
|
|
102
|
+
* (`truncated`). Also applied to hunks loaded from a store file.
|
|
103
|
+
*/
|
|
104
|
+
export function capHunks(patch) {
|
|
105
|
+
const hunks = [];
|
|
106
|
+
let budget = MAX_HUNK_BYTES;
|
|
107
|
+
let truncated = false;
|
|
108
|
+
for (const h of patch) {
|
|
109
|
+
if (!isRecord(h) || !Array.isArray(h.lines))
|
|
110
|
+
continue;
|
|
111
|
+
if (truncated)
|
|
112
|
+
break;
|
|
113
|
+
const kept = [];
|
|
114
|
+
for (const l of h.lines) {
|
|
115
|
+
if (typeof l !== 'string')
|
|
116
|
+
continue;
|
|
117
|
+
const cost = Buffer.byteLength(l) + 3;
|
|
118
|
+
if (cost > budget) {
|
|
119
|
+
truncated = true;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
budget -= cost;
|
|
123
|
+
kept.push(l);
|
|
124
|
+
}
|
|
125
|
+
hunks.push({
|
|
126
|
+
oldStart: Number(h.oldStart) || 0,
|
|
127
|
+
oldLines: Number(h.oldLines) || 0,
|
|
128
|
+
newStart: Number(h.newStart) || 0,
|
|
129
|
+
newLines: Number(h.newLines) || 0,
|
|
130
|
+
lines: kept,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return { hunks, truncated };
|
|
134
|
+
}
|
|
135
|
+
function toHunks(patch) {
|
|
136
|
+
let added = 0;
|
|
137
|
+
let removed = 0;
|
|
138
|
+
for (const h of patch) {
|
|
139
|
+
if (!isRecord(h) || !Array.isArray(h.lines))
|
|
140
|
+
continue;
|
|
141
|
+
for (const l of h.lines) {
|
|
142
|
+
if (typeof l !== 'string')
|
|
143
|
+
continue;
|
|
144
|
+
if (l.startsWith('+'))
|
|
145
|
+
added++;
|
|
146
|
+
else if (l.startsWith('-'))
|
|
147
|
+
removed++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { ...capHunks(patch), added, removed };
|
|
151
|
+
}
|
|
152
|
+
/** A new file's content as one all-added hunk, in `structuredPatch` form. */
|
|
153
|
+
function createdFileHunk(content) {
|
|
154
|
+
const lines = content.split('\n');
|
|
155
|
+
if (lines.length > 0 && lines[lines.length - 1] === '')
|
|
156
|
+
lines.pop();
|
|
157
|
+
return { oldStart: 0, oldLines: 0, newStart: 1, newLines: lines.length, lines: lines.map((l) => `+${l}`) };
|
|
158
|
+
}
|
|
159
|
+
function toEditRecord(id, ts, result, agentId) {
|
|
160
|
+
if (!isRecord(result))
|
|
161
|
+
return null;
|
|
162
|
+
const { filePath, structuredPatch } = result;
|
|
163
|
+
if (typeof filePath !== 'string' || !filePath || !Array.isArray(structuredPatch))
|
|
164
|
+
return null;
|
|
165
|
+
const tool = typeof result.type === 'string' ? 'Write' : 'oldString' in result ? 'Edit' : 'edit';
|
|
166
|
+
const kind = classifyEditPath(filePath);
|
|
167
|
+
// A Write that created a file reports an empty patch; its diff is the whole content.
|
|
168
|
+
const patch = result.type === 'create' && structuredPatch.length === 0 && kind !== 'image' && typeof result.content === 'string'
|
|
169
|
+
? [createdFileHunk(result.content)]
|
|
170
|
+
: structuredPatch;
|
|
171
|
+
const { hunks, added, removed, truncated } = toHunks(patch);
|
|
172
|
+
const record = {
|
|
173
|
+
id,
|
|
174
|
+
ts,
|
|
175
|
+
path: filePath,
|
|
176
|
+
kind,
|
|
177
|
+
tool,
|
|
178
|
+
created: result.type === 'create',
|
|
179
|
+
added,
|
|
180
|
+
removed,
|
|
181
|
+
hunks,
|
|
182
|
+
truncated,
|
|
183
|
+
};
|
|
184
|
+
if (agentId)
|
|
185
|
+
record.agentId = agentId;
|
|
186
|
+
return record;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Image paths of a `SendUserFile` result (`{ caption, attachments: [{ path }] }`): the
|
|
190
|
+
* files claude delivered to the user, which is how a session shows generated images.
|
|
191
|
+
*/
|
|
192
|
+
function sentImagePaths(result) {
|
|
193
|
+
if (!isRecord(result) || !Array.isArray(result.attachments))
|
|
194
|
+
return [];
|
|
195
|
+
const out = [];
|
|
196
|
+
for (const a of result.attachments) {
|
|
197
|
+
if (!isRecord(a) || typeof a.path !== 'string' || !a.path.startsWith('/'))
|
|
198
|
+
continue;
|
|
199
|
+
if (IMAGE_PATH_RE.test(a.path) && !out.includes(a.path))
|
|
200
|
+
out.push(a.path);
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
/** The text of a `tool_result` block's content (a string or a list of text blocks). */
|
|
205
|
+
function blockText(content) {
|
|
206
|
+
if (typeof content === 'string')
|
|
207
|
+
return content;
|
|
208
|
+
if (!Array.isArray(content))
|
|
209
|
+
return '';
|
|
210
|
+
return content
|
|
211
|
+
.map((b) => (isRecord(b) && typeof b.text === 'string' ? b.text : ''))
|
|
212
|
+
.filter(Boolean)
|
|
213
|
+
.join('\n');
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Parse transcript lines into edit records and Bash image candidates.
|
|
217
|
+
*
|
|
218
|
+
* @param text complete JSONL lines; a first line cut mid-record (a byte range starting
|
|
219
|
+
* inside it) and anything else that does not parse is skipped.
|
|
220
|
+
* @param pending unanswered Bash calls from the previous chunk.
|
|
221
|
+
*/
|
|
222
|
+
export function parseClaudeEditLines(text, pending = []) {
|
|
223
|
+
const open = new Map(pending.map((p) => [p.id, p]));
|
|
224
|
+
const records = [];
|
|
225
|
+
const candidates = [];
|
|
226
|
+
for (const rawLine of text.split('\n')) {
|
|
227
|
+
const line = rawLine.trim();
|
|
228
|
+
if (!line)
|
|
229
|
+
continue;
|
|
230
|
+
let rec;
|
|
231
|
+
try {
|
|
232
|
+
rec = JSON.parse(line);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (!isRecord(rec))
|
|
238
|
+
continue;
|
|
239
|
+
const message = rec.message;
|
|
240
|
+
const content = isRecord(message) ? message.content : undefined;
|
|
241
|
+
if (!Array.isArray(content))
|
|
242
|
+
continue;
|
|
243
|
+
const parsedTs = typeof rec.timestamp === 'string' ? Date.parse(rec.timestamp) : NaN;
|
|
244
|
+
const ts = Number.isFinite(parsedTs) ? parsedTs : 0;
|
|
245
|
+
const agentId = typeof rec.agentId === 'string' && rec.agentId ? rec.agentId : undefined;
|
|
246
|
+
const cwd = typeof rec.cwd === 'string' ? rec.cwd : '';
|
|
247
|
+
if (rec.type === 'assistant') {
|
|
248
|
+
for (const block of content) {
|
|
249
|
+
if (!isRecord(block) || block.type !== 'tool_use' || block.name !== 'Bash')
|
|
250
|
+
continue;
|
|
251
|
+
if (typeof block.id !== 'string' || !isRecord(block.input))
|
|
252
|
+
continue;
|
|
253
|
+
const command = block.input.command;
|
|
254
|
+
if (typeof command !== 'string')
|
|
255
|
+
continue;
|
|
256
|
+
if ([block.id, cwd, agentId ?? ''].some((f) => f.length > MAX_PENDING_FIELD_CHARS))
|
|
257
|
+
continue;
|
|
258
|
+
const entry = { id: block.id, ts, command: command.slice(0, MAX_PENDING_COMMAND_CHARS), cwd };
|
|
259
|
+
if (agentId)
|
|
260
|
+
entry.agentId = agentId;
|
|
261
|
+
open.delete(block.id);
|
|
262
|
+
open.set(block.id, entry);
|
|
263
|
+
while (open.size > MAX_PENDING_BASH)
|
|
264
|
+
open.delete(open.keys().next().value);
|
|
265
|
+
}
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (rec.type !== 'user')
|
|
269
|
+
continue;
|
|
270
|
+
const results = content.filter((b) => isRecord(b) && b.type === 'tool_result' && typeof b.tool_use_id === 'string');
|
|
271
|
+
// `toolUseResult` describes the line's result; it is unambiguous only for one block.
|
|
272
|
+
const single = results.length === 1;
|
|
273
|
+
for (const block of results) {
|
|
274
|
+
const id = block.tool_use_id;
|
|
275
|
+
if (single) {
|
|
276
|
+
const edit = toEditRecord(id, ts, rec.toolUseResult, agentId);
|
|
277
|
+
if (edit)
|
|
278
|
+
records.push(edit);
|
|
279
|
+
}
|
|
280
|
+
const sent = single ? sentImagePaths(rec.toolUseResult) : [];
|
|
281
|
+
if (sent.length > 0) {
|
|
282
|
+
const candidate = { toolUseId: id, start: ts, end: ts, paths: sent, sent: true };
|
|
283
|
+
if (agentId)
|
|
284
|
+
candidate.agentId = agentId;
|
|
285
|
+
candidates.push(candidate);
|
|
286
|
+
}
|
|
287
|
+
const call = open.get(id);
|
|
288
|
+
if (!call)
|
|
289
|
+
continue;
|
|
290
|
+
open.delete(id);
|
|
291
|
+
const r = single ? rec.toolUseResult : undefined;
|
|
292
|
+
let stdout;
|
|
293
|
+
let stderr = '';
|
|
294
|
+
if (isRecord(r) && (typeof r.stdout === 'string' || typeof r.stderr === 'string')) {
|
|
295
|
+
stdout = typeof r.stdout === 'string' ? r.stdout : '';
|
|
296
|
+
stderr = typeof r.stderr === 'string' ? r.stderr : '';
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
stdout = blockText(block.content);
|
|
300
|
+
}
|
|
301
|
+
const paths = extractImagePathCandidates(call.command, stdout, stderr, call.cwd);
|
|
302
|
+
if (paths.length === 0)
|
|
303
|
+
continue;
|
|
304
|
+
const candidate = { toolUseId: id, start: call.ts, end: ts, paths };
|
|
305
|
+
if (call.agentId)
|
|
306
|
+
candidate.agentId = call.agentId;
|
|
307
|
+
candidates.push(candidate);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return { records, candidates, pending: [...open.values()] };
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=edit-history-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-history-parse.js","sourceRoot":"","sources":["../src/edit-history-parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,c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|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Per-session edit history: the parsed edits and Bash images of one claude
|
|
3
|
+
* session, plus where in each transcript file reading stopped.
|
|
4
|
+
*
|
|
5
|
+
* Sources are the main transcript (`main`) and each subagent transcript
|
|
6
|
+
* (`subagents/agent-<id>.jsonl`). Each has a cursor:
|
|
7
|
+
* - `offset`: the next byte to read forward; always a line boundary.
|
|
8
|
+
* - `floor`: the lowest byte already parsed; > 0 while older lines are unread
|
|
9
|
+
* ("ältere laden" reads `[floor − budget, floor)`, see `olderRange`).
|
|
10
|
+
* The reader (`edit-history-local-source.ts`) reads forward from each `offset` of the
|
|
11
|
+
* current conversation, a file without one from `budget` bytes before its end, and hands the
|
|
12
|
+
* bytes to `apply`. Cuts happen only at `\n`, which never occurs inside a UTF-8 sequence, so
|
|
13
|
+
* multibyte characters split by a chunk boundary are never decoded half.
|
|
14
|
+
*
|
|
15
|
+
* A first read of a file starts `budget` bytes before its end (transcripts reach 100 MB+),
|
|
16
|
+
* drops the cut first line and leaves `floor` there. A line longer than the budget is
|
|
17
|
+
* skipped instead of blocking the cursor, reading forward (`midLine`) and backward
|
|
18
|
+
* (`floorMidLine`); the line after it (forward) or before it (backward) is read whole.
|
|
19
|
+
* That needs every chunk to be a full budget unless it reaches the file's end (forward) or
|
|
20
|
+
* start (older): a chunk with no line end then means one line longer than the budget. The
|
|
21
|
+
* caller does not hand over a chunk that a budget shared by several files cut short.
|
|
22
|
+
*
|
|
23
|
+
* A new conversation (`/clear`, resume) arrives as a new `transcriptId`: cursors and
|
|
24
|
+
* pending Bash calls start over, entries stay. Entries are capped at {@link MAX_ENTRIES}
|
|
25
|
+
* and {@link MAX_STORE_BYTES} of diff text; the oldest by time are dropped. Besides them
|
|
26
|
+
* the file holds one cursor per transcript file of the current conversation, at most
|
|
27
|
+
* {@link MAX_PENDING_BASH} unanswered Bash calls and at most {@link MAX_AGENTS} subagent labels.
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ The file holds secrets: a diff carries whatever the agent wrote, keys and `.env`
|
|
30
|
+
* contents included. So, like `intents.json`, it is written 0600 via tmp+rename, bounded,
|
|
31
|
+
* deleted with the session (`remove()`; `sweep()` at startup removes files no session owns),
|
|
32
|
+
* never fed to `/api/search`, and refused by the attachment, folder and download routes through
|
|
33
|
+
* `isSensitivePath` (`web/sensitive-path.ts`). `load()` takes the file as untrusted: past
|
|
34
|
+
* {@link MAX_FILE_BYTES} it is not parsed, and every part is rebuilt under the same bounds.
|
|
35
|
+
*
|
|
36
|
+
* Persisted as JSON under `dataPath('edit-history', '<sessionId>.json')`, written debounced.
|
|
37
|
+
*
|
|
38
|
+
* Tests: `test/edit-history-store.test.ts`.
|
|
39
|
+
*
|
|
40
|
+
* @module edit-history-store
|
|
41
|
+
*/
|
|
42
|
+
import { type EditRecord, type EditTool, type ImageCandidate } from './edit-history-parse.js';
|
|
43
|
+
export declare const MAX_ENTRIES = 500;
|
|
44
|
+
/** Diff text (and paths) kept per session; see {@link entryBytes}. */
|
|
45
|
+
export declare const MAX_STORE_BYTES: number;
|
|
46
|
+
/** Longest string kept from a subagent's `meta.json` field. */
|
|
47
|
+
export declare const MAX_AGENT_META_CHARS = 1024;
|
|
48
|
+
/**
|
|
49
|
+
* Subagent labels kept; past it the oldest one no entry uses is dropped. One more than
|
|
50
|
+
* {@link MAX_ENTRIES}, so besides the newest label there always is one.
|
|
51
|
+
*/
|
|
52
|
+
export declare const MAX_AGENTS: number;
|
|
53
|
+
/** Bytes read per file and pass (first read, forward step, "older" step). */
|
|
54
|
+
export declare const READ_BUDGET_BYTES: number;
|
|
55
|
+
/**
|
|
56
|
+
* A store file larger than this is not parsed (starts empty). One written within the caps
|
|
57
|
+
* above stays far below it; JSON escaping at most doubles ordinary text.
|
|
58
|
+
*/
|
|
59
|
+
export declare const MAX_FILE_BYTES: number;
|
|
60
|
+
export declare const MAIN_SOURCE = "main";
|
|
61
|
+
/**
|
|
62
|
+
* Names this process's tmp files (`<id>.json.<tag>.tmp`); any other tmp file is left over from
|
|
63
|
+
* an earlier run (`sweep`), even one whose pid this process has again (a container's pid 1).
|
|
64
|
+
*/
|
|
65
|
+
export declare const TMP_TAG: string;
|
|
66
|
+
/** `bash`: an image a Bash call wrote; `sent`: an image claude delivered to the user. */
|
|
67
|
+
export type EditHistoryTool = EditTool | 'bash' | 'sent';
|
|
68
|
+
export interface EditHistoryEntry extends Omit<EditRecord, 'tool'> {
|
|
69
|
+
tool: EditHistoryTool;
|
|
70
|
+
}
|
|
71
|
+
export interface SourceCursor {
|
|
72
|
+
offset: number;
|
|
73
|
+
floor: number;
|
|
74
|
+
/** The next forward read starts inside a line longer than the budget; skip to its end. */
|
|
75
|
+
midLine?: boolean;
|
|
76
|
+
/** `floor` lies inside a line longer than the budget; the next older read drops its tail. */
|
|
77
|
+
floorMidLine?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface AgentMeta {
|
|
80
|
+
description: string;
|
|
81
|
+
agentType: string;
|
|
82
|
+
worktreePath?: string;
|
|
83
|
+
worktreeBranch?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ByteRange {
|
|
86
|
+
offset: number;
|
|
87
|
+
len: number;
|
|
88
|
+
}
|
|
89
|
+
export interface ApplyInput {
|
|
90
|
+
transcriptId: string;
|
|
91
|
+
/** `main` or `subagents/agent-<id>.jsonl`. */
|
|
92
|
+
source: string;
|
|
93
|
+
startOffset: number;
|
|
94
|
+
chunk: Buffer;
|
|
95
|
+
/** Size of the file when the chunk was read. */
|
|
96
|
+
size: number;
|
|
97
|
+
}
|
|
98
|
+
export interface ApplyResult {
|
|
99
|
+
added: number;
|
|
100
|
+
candidates: ImageCandidate[];
|
|
101
|
+
}
|
|
102
|
+
export interface ConfirmedImage {
|
|
103
|
+
toolUseId: string;
|
|
104
|
+
path: string;
|
|
105
|
+
ts: number;
|
|
106
|
+
agentId?: string;
|
|
107
|
+
tool?: 'bash' | 'sent';
|
|
108
|
+
}
|
|
109
|
+
export interface EditHistoryStoreOptions {
|
|
110
|
+
/** Directory holding `<sessionId>.json`; default `dataPath('edit-history')`. */
|
|
111
|
+
dir?: string;
|
|
112
|
+
debounceMs?: number;
|
|
113
|
+
}
|
|
114
|
+
/** What an entry costs against {@link MAX_STORE_BYTES}: its strings and diff lines, plus a fixed overhead. */
|
|
115
|
+
export declare function entryBytes(e: EditHistoryEntry): number;
|
|
116
|
+
/** Parse an `agent-<id>.meta.json` text; null when it is not an object. */
|
|
117
|
+
export declare function parseAgentMeta(text: string): AgentMeta | null;
|
|
118
|
+
export declare class EditHistoryStore {
|
|
119
|
+
readonly sessionId: string;
|
|
120
|
+
private readonly file;
|
|
121
|
+
private readonly debounceMs;
|
|
122
|
+
private transcriptId;
|
|
123
|
+
private cursors;
|
|
124
|
+
private pendingBash;
|
|
125
|
+
private agents;
|
|
126
|
+
private entries;
|
|
127
|
+
/** Sum of {@link entryBytes} over `entries`. */
|
|
128
|
+
private bytes;
|
|
129
|
+
private saveTimer;
|
|
130
|
+
/** The last queued write; `remove()` waits for it. */
|
|
131
|
+
private writing;
|
|
132
|
+
private removed;
|
|
133
|
+
constructor(sessionId: string, opts?: EditHistoryStoreOptions);
|
|
134
|
+
/**
|
|
135
|
+
* A store with the persisted state of `sessionId`; empty when the file is missing,
|
|
136
|
+
* unreadable or larger than {@link MAX_FILE_BYTES}.
|
|
137
|
+
*/
|
|
138
|
+
static load(sessionId: string, opts?: EditHistoryStoreOptions): Promise<EditHistoryStore>;
|
|
139
|
+
/**
|
|
140
|
+
* Delete the stored history of every session `keep` rejects, and tmp files other processes
|
|
141
|
+
* left behind (startup: a crash between removing a session's record and deleting its file,
|
|
142
|
+
* or mid-write; an older build).
|
|
143
|
+
* Returns how many sessions' files were deleted.
|
|
144
|
+
*/
|
|
145
|
+
static sweep(keep: (sessionId: string) => boolean, opts?: Pick<EditHistoryStoreOptions, 'dir'>): Promise<number>;
|
|
146
|
+
/** Delete the stored history of `sessionId` without loading it. */
|
|
147
|
+
static delete(sessionId: string, opts?: Pick<EditHistoryStoreOptions, 'dir'>): Promise<void>;
|
|
148
|
+
getTranscriptId(): string | null;
|
|
149
|
+
getCursor(source: string): SourceCursor | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* True while any source has unread older lines that could still be shown. At a cap (no
|
|
152
|
+
* room left for another entry) an older edit would be dropped the moment it is read, so
|
|
153
|
+
* there is nothing more to load.
|
|
154
|
+
*/
|
|
155
|
+
get backfillTruncated(): boolean;
|
|
156
|
+
/** Entries newest first. */
|
|
157
|
+
list(): EditHistoryEntry[];
|
|
158
|
+
get(id: string): EditHistoryEntry | undefined;
|
|
159
|
+
getAgents(): Record<string, AgentMeta>;
|
|
160
|
+
hasAgentMeta(agentId: string): boolean;
|
|
161
|
+
/** Record a subagent's `meta.json`; ignored when it does not parse. */
|
|
162
|
+
setAgentMeta(agentId: string, metaText: string): void;
|
|
163
|
+
/** The next older range of `source` ("ältere laden"), or null when it is read to its start. */
|
|
164
|
+
olderRange(source: string, budget?: number): ByteRange | null;
|
|
165
|
+
/** Every source with a cursor in the current conversation. */
|
|
166
|
+
knownSources(): string[];
|
|
167
|
+
/** Sources with older lines left. */
|
|
168
|
+
sourcesWithOlder(): string[];
|
|
169
|
+
/**
|
|
170
|
+
* A source whose file is gone (a deleted subagent transcript): its cursor goes, so it no
|
|
171
|
+
* longer offers older lines. Its entries stay.
|
|
172
|
+
*/
|
|
173
|
+
dropSource(source: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* Apply a forward chunk: read from the source's cursor, or, without one, its last `budget`
|
|
176
|
+
* bytes; a full budget unless it reaches the file's end. A file that shrank below its cursor
|
|
177
|
+
* (replaced) loses the cursor and is read from its end next time. Returns new entries and
|
|
178
|
+
* Bash image candidates.
|
|
179
|
+
*/
|
|
180
|
+
apply(input: ApplyInput): ApplyResult;
|
|
181
|
+
/**
|
|
182
|
+
* Apply a chunk read at `olderRange`: a full budget unless it reaches the file's start. It
|
|
183
|
+
* ends at the floor, which is a line start, or with `floorMidLine` lies inside a line longer
|
|
184
|
+
* than the budget (its part in this chunk is dropped).
|
|
185
|
+
*/
|
|
186
|
+
applyOlder(input: ApplyInput): ApplyResult;
|
|
187
|
+
/** Add Bash images whose mtime was confirmed inside their call's window. */
|
|
188
|
+
addImageEntries(images: readonly ConfirmedImage[]): number;
|
|
189
|
+
/**
|
|
190
|
+
* Write pending changes, if any, and wait for a write under way (the store is dropped from
|
|
191
|
+
* memory and loaded again later). Unlike `flush()`, a store without changes writes nothing.
|
|
192
|
+
*/
|
|
193
|
+
settle(): Promise<void>;
|
|
194
|
+
/** Write now (cancels a pending debounced write). Writes run one after another. */
|
|
195
|
+
flush(): Promise<void>;
|
|
196
|
+
/** True once {@link remove} ran: the store ignores every later write. */
|
|
197
|
+
isRemoved(): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Delete the persisted file (session deleted) and forget the content. The store takes no
|
|
200
|
+
* changes afterwards, so a read still in flight neither writes nor refills it.
|
|
201
|
+
*/
|
|
202
|
+
remove(): Promise<void>;
|
|
203
|
+
private write;
|
|
204
|
+
private putAgent;
|
|
205
|
+
private setCursor;
|
|
206
|
+
private addRecords;
|
|
207
|
+
private scheduleSave;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=edit-history-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-history-store.d.ts","sourceRoot":"","sources":["../src/edit-history-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAMH,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,sEAAsE;AACtE,eAAO,MAAM,eAAe,QAAkB,CAAC;AAC/C,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC;;;GAGG;AACH,eAAO,MAAM,UAA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