@agent-watch-ai/edge 0.5.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.
- package/CHANGELOG.md +238 -7
- package/README.md +308 -8
- package/dist/billing/billing-mode.d.ts +37 -5
- package/dist/billing/billing-mode.js +28 -19
- package/dist/billing/constants/billing.constants.d.ts +0 -2
- package/dist/billing/constants/billing.constants.js +0 -2
- package/dist/billing/index.d.ts +2 -1
- package/dist/billing/index.js +1 -1
- package/dist/billing/session-billing.d.ts +3 -2
- package/dist/billing/session-billing.js +8 -8
- package/dist/billing/types/billing.types.d.ts +7 -0
- package/dist/capture/capture-env.d.ts +147 -0
- package/dist/capture/capture-env.js +301 -0
- package/dist/capture/captured-step.d.ts +88 -0
- package/dist/capture/captured-step.js +479 -0
- package/dist/capture/constants/capture.constants.d.ts +70 -0
- package/dist/capture/constants/capture.constants.js +72 -0
- package/dist/capture/launched-runs.d.ts +16 -0
- package/dist/capture/launched-runs.js +151 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +823 -0
- package/dist/capture/schemas/capture.schema.d.ts +35 -0
- package/dist/capture/schemas/capture.schema.js +31 -0
- package/dist/capture/types/capture.types.d.ts +20 -0
- package/dist/cli/constants/cli.constants.d.ts +2 -6
- package/dist/cli/constants/cli.constants.js +3 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +13 -0
- package/dist/cli/doctor-run-capture.js +19 -0
- package/dist/cli/doctor.js +16 -67
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +40 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/misc.js +10 -2
- package/dist/cli/replay.d.ts +33 -0
- package/dist/cli/replay.js +193 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +154 -26
- package/dist/cli/status.js +45 -5
- package/dist/cli/toggle.js +10 -0
- package/dist/cli/types/cli.types.d.ts +15 -1
- package/dist/cli/uninstall.js +8 -22
- package/dist/cli.js +104 -17
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.js +2 -0
- package/dist/config/events-transport.d.ts +15 -0
- package/dist/config/events-transport.js +29 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/root-config.d.ts +12 -0
- package/dist/config/root-config.js +24 -0
- package/dist/config/schemas/config.schema.d.ts +13 -0
- package/dist/config/schemas/config.schema.js +42 -6
- package/dist/config/types/config.types.d.ts +7 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/version.d.ts +9 -0
- package/dist/core/version.js +14 -0
- package/dist/core/which.d.ts +11 -0
- package/dist/core/which.js +18 -0
- package/dist/credentials/cloud-claim.d.ts +32 -0
- package/dist/credentials/cloud-claim.js +42 -0
- package/dist/credentials/constants/credentials.constants.d.ts +8 -1
- package/dist/credentials/constants/credentials.constants.js +9 -2
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/sign-in.d.ts +27 -0
- package/dist/credentials/sign-in.js +31 -1
- package/dist/credentials/token-refresher.d.ts +5 -1
- package/dist/credentials/token-refresher.js +10 -2
- package/dist/events/constants/events.constants.d.ts +8 -2
- package/dist/events/constants/events.constants.js +7 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/product-event.d.ts +10 -4
- package/dist/events/types/events.types.d.ts +6 -0
- package/dist/events/types/replay-progress.types.d.ts +26 -0
- package/dist/events/types/replay-progress.types.js +1 -0
- package/dist/events/types/repo-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +25 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- package/dist/feature/ticket-candidates.d.ts +1 -1
- package/dist/git/checkout-root.d.ts +15 -0
- package/dist/git/checkout-root.js +18 -0
- package/dist/git/code-state.d.ts +2 -16
- package/dist/git/code-state.js +11 -12
- package/dist/git/constants/git.constants.d.ts +31 -11
- package/dist/git/constants/git.constants.js +36 -12
- package/dist/git/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +8 -3
- package/dist/git/index.d.ts +1 -2
- package/dist/git/index.js +1 -1
- package/dist/git/repo-snapshot.d.ts +13 -4
- package/dist/git/repo-snapshot.js +47 -9
- package/dist/git/repo-tree.d.ts +69 -0
- package/dist/git/repo-tree.js +130 -0
- package/dist/git/types/git.types.d.ts +5 -2
- package/dist/git/types/snapshot.types.d.ts +14 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
- package/dist/pipeline/constants/pipeline.constants.js +3 -0
- package/dist/pipeline/hook-pipeline.js +112 -72
- package/dist/privacy/product-capture.js +36 -5
- package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.capture.js +5 -0
- package/dist/providers/antigravity/antigravity.detect.js +8 -22
- package/dist/providers/antigravity/antigravity.provider.js +10 -3
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
- package/dist/providers/claude/claude.adapter.js +9 -6
- package/dist/providers/claude/claude.detect.js +2 -17
- package/dist/providers/claude/claude.otel.d.ts +21 -3
- package/dist/providers/claude/claude.otel.js +216 -61
- package/dist/providers/claude/claude.provider.js +17 -1
- package/dist/providers/claude/claude.version.d.ts +9 -0
- package/dist/providers/claude/claude.version.js +28 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.constants.js +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
- package/dist/providers/claude/types/claude.types.d.ts +13 -0
- package/dist/providers/codex/codex.capture.d.ts +76 -0
- package/dist/providers/codex/codex.capture.js +454 -0
- package/dist/providers/codex/codex.detect.js +2 -4
- package/dist/providers/codex/codex.otel.d.ts +38 -2
- package/dist/providers/codex/codex.otel.js +50 -6
- package/dist/providers/codex/codex.provider.js +8 -0
- package/dist/providers/codex/codex.surface.d.ts +9 -0
- package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
- package/dist/providers/codex/codex.titles.d.ts +14 -0
- package/dist/providers/codex/codex.titles.js +35 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
- package/dist/providers/codex/constants/codex.constants.js +4 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
- package/dist/providers/cursor/constants/cursor.constants.js +25 -5
- package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
- package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
- package/dist/providers/cursor/cursor.adapter.js +20 -82
- package/dist/providers/cursor/cursor.capture.d.ts +1 -0
- package/dist/providers/cursor/cursor.capture.js +4 -0
- package/dist/providers/cursor/cursor.detect.d.ts +5 -1
- package/dist/providers/cursor/cursor.detect.js +11 -26
- package/dist/providers/cursor/cursor.hooks.js +2 -2
- package/dist/providers/cursor/cursor.provider.js +16 -7
- package/dist/providers/cursor/cursor.titles.d.ts +14 -0
- package/dist/providers/cursor/cursor.titles.js +20 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
- package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
- package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
- package/dist/providers/gemini/constants/gemini.constants.js +17 -0
- package/dist/providers/gemini/gemini.capture.d.ts +81 -0
- package/dist/providers/gemini/gemini.capture.js +210 -0
- package/dist/providers/gemini/gemini.detect.js +57 -24
- package/dist/providers/gemini/gemini.otel.d.ts +38 -2
- package/dist/providers/gemini/gemini.otel.js +56 -125
- package/dist/providers/gemini/gemini.provider.js +5 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/provider.d.ts +8 -0
- package/dist/providers/provider.js +9 -0
- package/dist/providers/registry.d.ts +14 -0
- package/dist/providers/registry.js +14 -0
- package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
- package/dist/providers/shared/constants/hook-config.constants.js +2 -0
- package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
- package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
- package/dist/providers/shared/editor-paths.d.ts +8 -0
- package/dist/providers/shared/editor-paths.js +18 -0
- package/dist/providers/shared/hook-config.d.ts +5 -0
- package/dist/providers/shared/hook-config.js +39 -1
- package/dist/providers/shared/hooks-marker.d.ts +14 -0
- package/dist/providers/shared/hooks-marker.js +23 -0
- package/dist/providers/shared/install-record.d.ts +29 -0
- package/dist/providers/shared/install-record.js +52 -0
- package/dist/providers/shared/session-title-store.d.ts +23 -0
- package/dist/providers/shared/session-title-store.js +50 -0
- package/dist/providers/shared/terminal-capture.d.ts +41 -0
- package/dist/providers/shared/terminal-capture.js +109 -0
- package/dist/providers/shared/tooling.d.ts +21 -0
- package/dist/providers/shared/tooling.js +36 -1
- package/dist/providers/types/provider.types.d.ts +57 -4
- package/dist/replay/checkout-resolver.d.ts +29 -0
- package/dist/replay/checkout-resolver.js +69 -0
- package/dist/replay/codex-turns.d.ts +24 -0
- package/dist/replay/codex-turns.js +221 -0
- package/dist/replay/constants/replay.constants.d.ts +99 -0
- package/dist/replay/constants/replay.constants.js +102 -0
- package/dist/replay/describe.d.ts +10 -0
- package/dist/replay/describe.js +31 -0
- package/dist/replay/gemini-turns.d.ts +36 -0
- package/dist/replay/gemini-turns.js +192 -0
- package/dist/replay/machine.d.ts +34 -0
- package/dist/replay/machine.js +68 -0
- package/dist/replay/progress-event.d.ts +21 -0
- package/dist/replay/progress-event.js +45 -0
- package/dist/replay/replay-runner.d.ts +58 -0
- package/dist/replay/replay-runner.js +529 -0
- package/dist/replay/replay-scan.d.ts +83 -0
- package/dist/replay/replay-scan.js +170 -0
- package/dist/replay/replay-state.d.ts +108 -0
- package/dist/replay/replay-state.js +199 -0
- package/dist/replay/resume.d.ts +18 -0
- package/dist/replay/resume.js +34 -0
- package/dist/replay/start.d.ts +23 -0
- package/dist/replay/start.js +39 -0
- package/dist/replay/throttle.d.ts +35 -0
- package/dist/replay/throttle.js +41 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +215 -0
- package/dist/replay/turn-event.d.ts +38 -0
- package/dist/replay/turn-event.js +116 -0
- package/dist/replay/types/replay.types.d.ts +162 -0
- package/dist/replay/types/replay.types.js +1 -0
- package/dist/replay/window.d.ts +28 -0
- package/dist/replay/window.js +41 -0
- package/dist/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +74 -42
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +10 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +10 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +37 -4
- package/dist/snapshot/constants/snapshot.constants.js +37 -4
- package/dist/snapshot/index.d.ts +6 -1
- package/dist/snapshot/index.js +3 -1
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +24 -2
- package/dist/snapshot/tree-event.d.ts +14 -0
- package/dist/snapshot/tree-event.js +91 -0
- package/dist/snapshot/tree-pipeline.d.ts +12 -0
- package/dist/snapshot/tree-pipeline.js +172 -0
- package/dist/snapshot/types/snapshot.types.d.ts +62 -2
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -0
- package/dist/transport/delivery-stats.d.ts +13 -1
- package/dist/transport/delivery-stats.js +18 -2
- package/dist/transport/delivery.d.ts +4 -3
- package/dist/transport/delivery.js +21 -7
- package/dist/transport/identity-delivery.d.ts +20 -0
- package/dist/transport/identity-delivery.js +41 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/queue.js +40 -6
- package/dist/transport/types/delivery-flow.types.d.ts +7 -0
- package/dist/turns/claude-transcript.js +4 -12
- package/dist/turns/codex-transcript.d.ts +9 -0
- package/dist/turns/codex-transcript.js +27 -19
- package/dist/turns/constants/turns.constants.d.ts +13 -12
- package/dist/turns/constants/turns.constants.js +15 -19
- package/dist/turns/gemini-transcript.d.ts +19 -1
- package/dist/turns/gemini-transcript.js +29 -18
- package/dist/turns/index.d.ts +3 -4
- package/dist/turns/index.js +2 -3
- package/dist/turns/run-state.d.ts +71 -0
- package/dist/turns/run-state.js +114 -0
- package/dist/turns/tool-events.d.ts +11 -1
- package/dist/turns/tool-events.js +32 -9
- package/dist/turns/transcript.d.ts +15 -14
- package/dist/turns/transcript.js +23 -4
- package/dist/turns/turn-state.d.ts +49 -7
- package/dist/turns/turn-state.js +78 -10
- package/dist/turns/turn-summary.js +10 -6
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +162 -86
- package/dist/turns/types/transcript.types.d.ts +11 -1
- package/dist/turns/types/turn-provider.types.d.ts +33 -0
- package/dist/turns/types/turn-provider.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +9 -0
- package/dist/turns/types/turn-summary.types.d.ts +20 -6
- package/dist/turns/types/turn-tracker.types.d.ts +3 -1
- package/dist/turns/work-checkout.js +1 -2
- package/docs/AUDIT_PROMPT.md +10 -0
- package/docs/DATA_HANDLING.md +269 -32
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +27 -0
- package/package.json +3 -2
- package/dist/events/canonical-event.d.ts +0 -10
- package/dist/events/canonical-event.js +0 -9
- package/dist/git/repository-root.d.ts +0 -39
- package/dist/git/repository-root.js +0 -131
- package/dist/git/types/repository-root.types.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -6
- package/dist/turns/codex-originator.d.ts +0 -11
- package/dist/turns/cursor-transcript.d.ts +0 -21
- package/dist/turns/cursor-transcript.js +0 -66
- package/dist/turns/native-session-titles.d.ts +0 -26
- package/dist/turns/native-session-titles.js +0 -102
- /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
- /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { GIT_ENTRY_ABSENT_CODES, GIT_ENTRY_NAME } from './constants/git.constants.js';
|
|
4
|
-
/**
|
|
5
|
-
* A finder for the repository each file belongs to, when the session's own
|
|
6
|
-
* folder is not one.
|
|
7
|
-
*
|
|
8
|
-
* Bounded by `boundary` — the folder the session started in — for two reasons:
|
|
9
|
-
* a repository outside it is another project's, possibly another tenant's, and
|
|
10
|
-
* a bounded walk is a handful of `stat` calls rather than an unbounded climb to
|
|
11
|
-
* the filesystem root.
|
|
12
|
-
*
|
|
13
|
-
* ponytail: presence of a `.git` entry is the whole test, and the answer is the
|
|
14
|
-
* *nearest* ancestor that has one — so a file inside a submodule or a vendored
|
|
15
|
-
* checkout belongs to that inner repository, which is also what git itself
|
|
16
|
-
* would answer from that directory. It does not understand `GIT_DIR`, a bare
|
|
17
|
-
* repository, or a `.git` file pointing outside the tree. The upgrade path is
|
|
18
|
-
* `git rev-parse --show-toplevel` behind this same cache — deliberately not the
|
|
19
|
-
* implementation: a subprocess per tool call would sit on the coding agent's
|
|
20
|
-
* critical path.
|
|
21
|
-
*
|
|
22
|
-
* @param boundary - Folder the walk stops at, inclusive.
|
|
23
|
-
* @returns A finder whose answers are memoized per directory.
|
|
24
|
-
*/
|
|
25
|
-
export function repositoryRootFinder(boundary) {
|
|
26
|
-
// Directory → its repository root, or undefined for "none, and asked".
|
|
27
|
-
// One turn touches the same handful of directories over and over.
|
|
28
|
-
const cache = new Map();
|
|
29
|
-
return { find: (filePath) => rootFor(path.dirname(filePath), boundary, cache) };
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The repository root at or above one directory, memoizing every level.
|
|
33
|
-
*
|
|
34
|
-
* @param dir - Directory to resolve.
|
|
35
|
-
* @param boundary - Folder the walk stops at, inclusive.
|
|
36
|
-
* @param cache - Directory answers resolved so far.
|
|
37
|
-
* @returns The root, or undefined when there is none inside the boundary.
|
|
38
|
-
*/
|
|
39
|
-
async function rootFor(dir, boundary, cache) {
|
|
40
|
-
if (cache.has(dir))
|
|
41
|
-
return cache.get(dir);
|
|
42
|
-
// A file outside the start folder contributes no repository at all: its
|
|
43
|
-
// repository is not the session's business and could be another tenant's.
|
|
44
|
-
if (!isBeneath(boundary, dir))
|
|
45
|
-
return undefined;
|
|
46
|
-
const root = await walkUp(dir, boundary, cache);
|
|
47
|
-
cache.set(dir, root);
|
|
48
|
-
return root;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* One rung of the walk: this directory, else its parent.
|
|
52
|
-
*
|
|
53
|
-
* @param dir - Directory to test.
|
|
54
|
-
* @param boundary - Folder the walk stops at, inclusive.
|
|
55
|
-
* @param cache - Directory answers resolved so far.
|
|
56
|
-
* @returns The root, or undefined once the boundary is passed.
|
|
57
|
-
*/
|
|
58
|
-
async function walkUp(dir, boundary, cache) {
|
|
59
|
-
const entry = await gitEntry(dir);
|
|
60
|
-
if (entry === 'present')
|
|
61
|
-
return (await isReallyBeneath(boundary, dir)) ? dir : undefined;
|
|
62
|
-
// A `.git` that could not be checked may well be there: climbing past it
|
|
63
|
-
// would hand the file to an enclosing repository — the wrong branch, the
|
|
64
|
-
// wrong config. No repository is the answer this walk gives when unsure.
|
|
65
|
-
if (entry === 'unknown')
|
|
66
|
-
return undefined;
|
|
67
|
-
const parent = path.dirname(dir);
|
|
68
|
-
// `dir === boundary` ends the walk; `parent === dir` is the filesystem root,
|
|
69
|
-
// which only happens when the boundary is not an ancestor at all.
|
|
70
|
-
if (dir === boundary || parent === dir)
|
|
71
|
-
return undefined;
|
|
72
|
-
return rootFor(parent, boundary, cache);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* `isBeneath`, asked of where the two really are.
|
|
76
|
-
*
|
|
77
|
-
* A symlink inside the start folder can point at a checkout anywhere on the
|
|
78
|
-
* machine, and `.git` is found through it: lexically beneath, on disk another
|
|
79
|
-
* project's. Asked only once a root is found, so the walk itself stays `stat`s.
|
|
80
|
-
* A refused root ends the walk rather than climbing past it — the file belongs
|
|
81
|
-
* to that repository, whoever's it is. A path that cannot be resolved — a link
|
|
82
|
-
* removed or retargeted since the `.git` check — is refused too: its real
|
|
83
|
-
* location was never proven to be inside.
|
|
84
|
-
*
|
|
85
|
-
* @param boundary - Folder that bounds the walk.
|
|
86
|
-
* @param dir - Directory a `.git` entry was found in.
|
|
87
|
-
* @returns True when the directory really lies within the boundary.
|
|
88
|
-
*/
|
|
89
|
-
async function isReallyBeneath(boundary, dir) {
|
|
90
|
-
try {
|
|
91
|
-
const [realBoundary, realDir] = await Promise.all([fs.realpath(boundary), fs.realpath(dir)]);
|
|
92
|
-
return isBeneath(realBoundary, realDir);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Whether a `.git` entry sits directly in a directory.
|
|
100
|
-
*
|
|
101
|
-
* @param dir - Directory to test.
|
|
102
|
-
* @returns `present`, `absent`, or `unknown` when the check itself failed.
|
|
103
|
-
*/
|
|
104
|
-
async function gitEntry(dir) {
|
|
105
|
-
try {
|
|
106
|
-
await fs.access(path.join(dir, GIT_ENTRY_NAME));
|
|
107
|
-
return 'present';
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
const code = error.code;
|
|
111
|
-
return code !== undefined && GIT_ENTRY_ABSENT_CODES.has(code) ? 'absent' : 'unknown';
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Whether a path is a directory or lies inside it.
|
|
116
|
-
*
|
|
117
|
-
* The two answers that disqualify it are a relative path that climbs out and
|
|
118
|
-
* one that stays absolute (a different drive or root). A sibling named
|
|
119
|
-
* `..foo` climbs nowhere, which is why the separator is part of the test.
|
|
120
|
-
*
|
|
121
|
-
* Exported because the same question is asked of a repository path read back
|
|
122
|
-
* out of local turn state: one answer, not two that could disagree.
|
|
123
|
-
*
|
|
124
|
-
* @param boundary - Folder that bounds the walk.
|
|
125
|
-
* @param target - Path to test against it.
|
|
126
|
-
* @returns True when the target is the boundary or beneath it.
|
|
127
|
-
*/
|
|
128
|
-
export function isBeneath(boundary, target) {
|
|
129
|
-
const relative = path.relative(boundary, target);
|
|
130
|
-
return !path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`);
|
|
131
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds the repository a file belongs to, bounded by one directory and
|
|
3
|
-
* memoized for the life of the finder.
|
|
4
|
-
*/
|
|
5
|
-
export interface RepositoryRootFinder {
|
|
6
|
-
/**
|
|
7
|
-
* The root of the repository containing `filePath`, or undefined when none
|
|
8
|
-
* lies between the file and the boundary.
|
|
9
|
-
*/
|
|
10
|
-
find(filePath: string): Promise<string | undefined>;
|
|
11
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The contract between delivery and whatever actually moves bytes. Kept
|
|
3
|
-
* separate from the HTTP implementation so the queue, the cooldown and the
|
|
4
|
-
* whole test suite can substitute their own.
|
|
5
|
-
*/
|
|
6
|
-
export type { DeliveryCounters, DeliveryResult, EventTransport, HttpTransportOptions } from './types/transport.types.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether a Codex transcript belongs to a headless `codex exec` run.
|
|
3
|
-
*
|
|
4
|
-
* The hook payload does not say how Codex was started; the transcript's first
|
|
5
|
-
* line (`session_meta`) does. Any failure answers false, so an unreadable
|
|
6
|
-
* transcript reports the default surface rather than failing the hook.
|
|
7
|
-
*
|
|
8
|
-
* @param transcriptPath - Path Codex reported in the hook payload.
|
|
9
|
-
* @returns True only when the originator is `codex_exec`.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isCodexExecTranscript(transcriptPath: string): Promise<boolean>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ReadTurnUsageRetry, TurnUsage } from './types/transcript.types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Forward-compatible token usage from Cursor's transcript JSONL.
|
|
4
|
-
*
|
|
5
|
-
* Today (verified 2026-08) Cursor transcript rows carry only role/message with
|
|
6
|
-
* tool_use blocks — no usage, no timestamps, no message ids — so this reader
|
|
7
|
-
* returns undefined and Cursor turn summaries stay usage_status=pending. Cursor
|
|
8
|
-
* has logged the enrichment request; the parser already accepts `usage` and
|
|
9
|
-
* `message.usage` objects with Anthropic-style token fields, so tokens will
|
|
10
|
-
* appear here without a code change once the format grows them.
|
|
11
|
-
*
|
|
12
|
-
* Rows have no timestamps, so unlike the Claude reader there is no time window:
|
|
13
|
-
* a turn claims every not-yet-claimed usage row, and exactly-once attribution
|
|
14
|
-
* rests entirely on the persisted message-id ledger.
|
|
15
|
-
*
|
|
16
|
-
* @param transcriptPath - Path Cursor reported in the hook payload.
|
|
17
|
-
* @param retry - How long to wait for the transcript flush to settle.
|
|
18
|
-
* @param excludeMessageIds - Rows another turn already claimed.
|
|
19
|
-
* @returns The turn's usage, or undefined while the format carries none.
|
|
20
|
-
*/
|
|
21
|
-
export declare function readCursorTurnUsage(transcriptPath: string, retry?: ReadTurnUsageRetry, excludeMessageIds?: ReadonlySet<string>): Promise<TurnUsage | undefined>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { asRecord, firstStringOf } from '../core/object.js';
|
|
2
|
-
import { accumulateUsage, messageIdFor, parseJsonLine, readTranscriptTail, readUntilSettled } from './transcript.js';
|
|
3
|
-
/**
|
|
4
|
-
* Forward-compatible token usage from Cursor's transcript JSONL.
|
|
5
|
-
*
|
|
6
|
-
* Today (verified 2026-08) Cursor transcript rows carry only role/message with
|
|
7
|
-
* tool_use blocks — no usage, no timestamps, no message ids — so this reader
|
|
8
|
-
* returns undefined and Cursor turn summaries stay usage_status=pending. Cursor
|
|
9
|
-
* has logged the enrichment request; the parser already accepts `usage` and
|
|
10
|
-
* `message.usage` objects with Anthropic-style token fields, so tokens will
|
|
11
|
-
* appear here without a code change once the format grows them.
|
|
12
|
-
*
|
|
13
|
-
* Rows have no timestamps, so unlike the Claude reader there is no time window:
|
|
14
|
-
* a turn claims every not-yet-claimed usage row, and exactly-once attribution
|
|
15
|
-
* rests entirely on the persisted message-id ledger.
|
|
16
|
-
*
|
|
17
|
-
* @param transcriptPath - Path Cursor reported in the hook payload.
|
|
18
|
-
* @param retry - How long to wait for the transcript flush to settle.
|
|
19
|
-
* @param excludeMessageIds - Rows another turn already claimed.
|
|
20
|
-
* @returns The turn's usage, or undefined while the format carries none.
|
|
21
|
-
*/
|
|
22
|
-
export async function readCursorTurnUsage(transcriptPath, retry, excludeMessageIds) {
|
|
23
|
-
return readUntilSettled(() => readOnce(transcriptPath, excludeMessageIds), retry, { bailOnFirstEmpty: true });
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* One pass over the transcript tail.
|
|
27
|
-
*
|
|
28
|
-
* @param transcriptPath - Transcript file.
|
|
29
|
-
* @param excludeMessageIds - Rows another turn already claimed.
|
|
30
|
-
* @returns The usage found in this pass.
|
|
31
|
-
*/
|
|
32
|
-
async function readOnce(transcriptPath, excludeMessageIds) {
|
|
33
|
-
const raw = await readTranscriptTail(transcriptPath);
|
|
34
|
-
if (raw === undefined)
|
|
35
|
-
return undefined;
|
|
36
|
-
const byMessageId = new Map();
|
|
37
|
-
for (const line of raw.split('\n')) {
|
|
38
|
-
if (!line.trim())
|
|
39
|
-
continue;
|
|
40
|
-
const entry = usageRow(line, excludeMessageIds);
|
|
41
|
-
if (entry)
|
|
42
|
-
byMessageId.set(entry.id, entry.value);
|
|
43
|
-
}
|
|
44
|
-
return accumulateUsage(byMessageId);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The usage of one transcript row, when it reports any and no other turn has
|
|
48
|
-
* claimed it.
|
|
49
|
-
*
|
|
50
|
-
* @param line - Verbatim JSONL line.
|
|
51
|
-
* @param excludeMessageIds - Rows another turn already claimed.
|
|
52
|
-
* @returns The entry, or undefined when the row carries no usage.
|
|
53
|
-
*/
|
|
54
|
-
function usageRow(line, excludeMessageIds) {
|
|
55
|
-
const entry = parseJsonLine(line);
|
|
56
|
-
if (!entry)
|
|
57
|
-
return undefined;
|
|
58
|
-
const message = asRecord(entry['message']);
|
|
59
|
-
const usage = asRecord(entry['usage']) ?? asRecord(message?.['usage']);
|
|
60
|
-
if (!usage)
|
|
61
|
-
return undefined;
|
|
62
|
-
const id = messageIdFor(firstStringOf(message?.['id'], entry['id'], entry['message_id']), line);
|
|
63
|
-
if (excludeMessageIds?.has(id))
|
|
64
|
-
return undefined;
|
|
65
|
-
return { id, value: { model: firstStringOf(message?.['model'], entry['model']), usage } };
|
|
66
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Env } from '../core/types/core.types.js';
|
|
2
|
-
import type { SessionTitles } from './types/transcript.types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Read the name and generated title Codex keeps for one thread.
|
|
5
|
-
*
|
|
6
|
-
* Codex does not put either value in its hook payload or rollout. Its own
|
|
7
|
-
* read-model database is therefore the source, opened read-only and queried by
|
|
8
|
-
* the hook's session id.
|
|
9
|
-
*
|
|
10
|
-
* @param env - Environment locating `$CODEX_HOME` or `~/.codex`.
|
|
11
|
-
* @param sessionId - Codex thread id from the hook payload.
|
|
12
|
-
* @returns Codex's latest name and generated title, or neither when unavailable.
|
|
13
|
-
*/
|
|
14
|
-
export declare function readCodexSessionTitles(env: Env, sessionId: string): Promise<SessionTitles>;
|
|
15
|
-
/**
|
|
16
|
-
* Read Cursor's generated conversation title from its local search index.
|
|
17
|
-
*
|
|
18
|
-
* Cursor exposes no title in hooks or transcripts. The desktop app's search
|
|
19
|
-
* index keys the same conversation id the hook sends; Cursor keeps custom and
|
|
20
|
-
* generated titles in one display field, so it maps to `session_title`.
|
|
21
|
-
*
|
|
22
|
-
* @param env - Environment locating Cursor's platform data directory.
|
|
23
|
-
* @param sessionId - Cursor conversation id from the hook payload.
|
|
24
|
-
* @returns Cursor's display title, or neither when unavailable.
|
|
25
|
-
*/
|
|
26
|
-
export declare function readCursorSessionTitles(env: Env, sessionId: string): Promise<SessionTitles>;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { asRecord, compact } from '../core/object.js';
|
|
5
|
-
import { codexHome } from '../providers/codex/codex.detect.js';
|
|
6
|
-
const CODEX_STATE_DATABASE = /^state_(\d+)\.sqlite$/;
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
/**
|
|
9
|
-
* Read the name and generated title Codex keeps for one thread.
|
|
10
|
-
*
|
|
11
|
-
* Codex does not put either value in its hook payload or rollout. Its own
|
|
12
|
-
* read-model database is therefore the source, opened read-only and queried by
|
|
13
|
-
* the hook's session id.
|
|
14
|
-
*
|
|
15
|
-
* @param env - Environment locating `$CODEX_HOME` or `~/.codex`.
|
|
16
|
-
* @param sessionId - Codex thread id from the hook payload.
|
|
17
|
-
* @returns Codex's latest name and generated title, or neither when unavailable.
|
|
18
|
-
*/
|
|
19
|
-
export async function readCodexSessionTitles(env, sessionId) {
|
|
20
|
-
const sqlite = sqliteModule();
|
|
21
|
-
if (!sqlite)
|
|
22
|
-
return {};
|
|
23
|
-
const home = codexHome(env);
|
|
24
|
-
const entries = await fs.readdir(home, { withFileTypes: true });
|
|
25
|
-
const databases = entries
|
|
26
|
-
.flatMap((entry) => {
|
|
27
|
-
const match = entry.isFile() && CODEX_STATE_DATABASE.exec(entry.name);
|
|
28
|
-
return match ? [{ path: path.join(home, entry.name), version: Number(match[1]) }] : [];
|
|
29
|
-
})
|
|
30
|
-
.sort((left, right) => right.version - left.version);
|
|
31
|
-
for (const database of databases) {
|
|
32
|
-
const titles = readTitles(sqlite, database.path, 'SELECT title, name FROM threads WHERE id = ?', sessionId);
|
|
33
|
-
if (titles.custom || titles.generated)
|
|
34
|
-
return titles;
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Read Cursor's generated conversation title from its local search index.
|
|
40
|
-
*
|
|
41
|
-
* Cursor exposes no title in hooks or transcripts. The desktop app's search
|
|
42
|
-
* index keys the same conversation id the hook sends; Cursor keeps custom and
|
|
43
|
-
* generated titles in one display field, so it maps to `session_title`.
|
|
44
|
-
*
|
|
45
|
-
* @param env - Environment locating Cursor's platform data directory.
|
|
46
|
-
* @param sessionId - Cursor conversation id from the hook payload.
|
|
47
|
-
* @returns Cursor's display title, or neither when unavailable.
|
|
48
|
-
*/
|
|
49
|
-
export async function readCursorSessionTitles(env, sessionId) {
|
|
50
|
-
const sqlite = sqliteModule();
|
|
51
|
-
const database = cursorSearchDatabase(env);
|
|
52
|
-
if (!sqlite || !database)
|
|
53
|
-
return {};
|
|
54
|
-
return readTitles(sqlite, database, "SELECT title FROM conversations WHERE source = 'local' AND scope = '' AND id = ?", sessionId);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Open one provider-owned read model and return only its title fields.
|
|
58
|
-
*
|
|
59
|
-
* ponytail: the synchronous stdlib query can briefly block one Stop hook; it is
|
|
60
|
-
* one indexed local lookup. Move it to a worker if measured hook latency makes
|
|
61
|
-
* that visible.
|
|
62
|
-
*/
|
|
63
|
-
function readTitles(sqlite, databasePath, query, sessionId) {
|
|
64
|
-
let database;
|
|
65
|
-
try {
|
|
66
|
-
database = new sqlite.DatabaseSync(databasePath, { readOnly: true });
|
|
67
|
-
const row = asRecord(database.prepare(query).get(sessionId));
|
|
68
|
-
return compact({
|
|
69
|
-
custom: typeof row?.['name'] === 'string' ? row['name'] : undefined,
|
|
70
|
-
generated: typeof row?.['title'] === 'string' ? row['title'] : undefined
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
database?.close();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** Node added enforced read-only SQLite opens in 22.12. */
|
|
81
|
-
function sqliteModule() {
|
|
82
|
-
const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
|
|
83
|
-
if (major < 22 || (major === 22 && minor < 12))
|
|
84
|
-
return undefined;
|
|
85
|
-
try {
|
|
86
|
-
return require('node:sqlite');
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/** Cursor's search index path on each supported desktop platform. */
|
|
93
|
-
function cursorSearchDatabase(env) {
|
|
94
|
-
const suffix = ['Cursor', 'User', 'globalStorage', 'conversation-search.db'];
|
|
95
|
-
if (env.platform === 'darwin')
|
|
96
|
-
return path.join(env.home, 'Library', 'Application Support', ...suffix);
|
|
97
|
-
if (env.platform === 'linux')
|
|
98
|
-
return path.join(env.vars['XDG_CONFIG_HOME'] ?? path.join(env.home, '.config'), ...suffix);
|
|
99
|
-
if (env.platform === 'win32' && env.vars['APPDATA'])
|
|
100
|
-
return path.join(env.vars['APPDATA'], ...suffix);
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
File without changes
|
|
File without changes
|