sidekick-shared 0.29.1 → 0.30.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 +26 -0
- package/README.md +171 -60
- package/dist/aggregation/EventAggregator.d.ts +79 -4
- package/dist/aggregation/EventAggregator.js +391 -37
- package/dist/aggregation/types.d.ts +27 -3
- package/dist/browser.d.ts +7 -3
- package/dist/browser.js +23 -3
- package/dist/context/sessionContext.js +5 -1
- package/dist/esm/aggregation/EventAggregator.js +392 -38
- package/dist/esm/browser.js +3 -1
- package/dist/esm/context/sessionContext.js +6 -2
- package/dist/esm/fileContinuity.js +149 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/node.js +2 -0
- package/dist/esm/parsers/codexParser.js +192 -3
- package/dist/esm/parsers/subagentEndState.js +61 -0
- package/dist/esm/parsers/subagentScanner.js +4 -0
- package/dist/esm/parsers/subagentTraceParser.js +6 -0
- package/dist/esm/promptHistory.js +22 -11
- package/dist/esm/providers/claudeCode.js +50 -27
- package/dist/esm/providers/codex.js +153 -163
- package/dist/esm/providers/codexCompressedReader.js +184 -0
- package/dist/esm/providers/codexDatabase.js +47 -2
- package/dist/esm/providers/codexRollouts.js +20 -2
- package/dist/esm/providers/codexSubagents.js +456 -0
- package/dist/esm/providers/compressedRollouts.js +330 -0
- package/dist/esm/providers/factory.js +4 -1
- package/dist/esm/providers/rolloutWalker.js +32 -4
- package/dist/esm/schemas/sessionEvent.js +32 -4
- package/dist/esm/sessionMonitor.js +7 -1
- package/dist/esm/sessionPreviews.js +9 -0
- package/dist/esm/sessionPromptHistory.js +5 -3
- package/dist/esm/subagentActivity.js +125 -0
- package/dist/esm/subagentDisplayState.js +81 -0
- package/dist/esm/subagentSpawn.js +206 -6
- package/dist/esm/testing/codexSubagentFixtures.js +336 -0
- package/dist/esm/toolCallOrigins.js +17 -10
- package/dist/esm/toolCategory.js +6 -2
- package/dist/esm/transcript.js +6 -2
- package/dist/esm/turns/assistantTurn.js +6 -3
- package/dist/esm/usage/usageEvents.js +4 -1
- package/dist/esm/watchers/eventBridge.js +31 -1
- package/dist/esm/watchers/jsonlTail.js +11 -42
- package/dist/esm/watchers/jsonlWatcher.js +19 -9
- package/dist/esm/watchers/providerReaderWatcher.js +5 -4
- package/dist/fileContinuity.d.ts +95 -0
- package/dist/fileContinuity.js +187 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.js +39 -10
- package/dist/node.d.ts +4 -0
- package/dist/node.js +16 -2
- package/dist/parsers/codexParser.d.ts +44 -0
- package/dist/parsers/codexParser.js +192 -3
- package/dist/parsers/subagentEndState.d.ts +20 -0
- package/dist/parsers/subagentEndState.js +65 -0
- package/dist/parsers/subagentScanner.js +4 -0
- package/dist/parsers/subagentTraceParser.d.ts +8 -0
- package/dist/parsers/subagentTraceParser.js +6 -0
- package/dist/promptHistory.d.ts +13 -3
- package/dist/promptHistory.js +22 -11
- package/dist/providers/claudeCode.js +50 -27
- package/dist/providers/codex.d.ts +35 -5
- package/dist/providers/codex.js +150 -160
- package/dist/providers/codexCompressedReader.d.ts +58 -0
- package/dist/providers/codexCompressedReader.js +221 -0
- package/dist/providers/codexDatabase.d.ts +25 -0
- package/dist/providers/codexDatabase.js +48 -2
- package/dist/providers/codexRollouts.d.ts +16 -2
- package/dist/providers/codexRollouts.js +20 -2
- package/dist/providers/codexSubagents.d.ts +66 -0
- package/dist/providers/codexSubagents.js +495 -0
- package/dist/providers/compressedRollouts.d.ts +114 -0
- package/dist/providers/compressedRollouts.js +380 -0
- package/dist/providers/factory.d.ts +5 -0
- package/dist/providers/factory.js +4 -1
- package/dist/providers/rolloutWalker.d.ts +15 -2
- package/dist/providers/rolloutWalker.js +33 -4
- package/dist/providers/types.d.ts +22 -1
- package/dist/schemas/sessionEvent.d.ts +26 -2
- package/dist/schemas/sessionEvent.js +31 -3
- package/dist/sessionMonitor.d.ts +6 -0
- package/dist/sessionMonitor.js +7 -1
- package/dist/sessionPreviews.js +9 -0
- package/dist/sessionPromptHistory.d.ts +5 -0
- package/dist/sessionPromptHistory.js +5 -36
- package/dist/subagentActivity.d.ts +91 -0
- package/dist/subagentActivity.js +132 -0
- package/dist/subagentDisplayState.d.ts +81 -0
- package/dist/subagentDisplayState.js +86 -0
- package/dist/subagentSpawn.d.ts +100 -5
- package/dist/subagentSpawn.js +218 -7
- package/dist/testing/codexSubagentFixtures.d.ts +48 -0
- package/dist/testing/codexSubagentFixtures.js +344 -0
- package/dist/toolCallOrigins.d.ts +5 -0
- package/dist/toolCallOrigins.js +17 -10
- package/dist/toolCategory.js +6 -2
- package/dist/transcript.js +5 -1
- package/dist/turns/assistantTurn.d.ts +4 -1
- package/dist/turns/assistantTurn.js +5 -2
- package/dist/types/codex.d.ts +71 -2
- package/dist/types/sessionEvent.d.ts +38 -3
- package/dist/usage/usageEvents.d.ts +4 -1
- package/dist/usage/usageEvents.js +4 -1
- package/dist/watchers/eventBridge.js +30 -0
- package/dist/watchers/jsonlTail.js +11 -42
- package/dist/watchers/jsonlWatcher.d.ts +5 -1
- package/dist/watchers/jsonlWatcher.js +18 -8
- package/dist/watchers/providerReaderWatcher.js +5 -4
- package/package.json +1 -1
|
@@ -112,11 +112,12 @@ export class ProviderReaderSessionWatcher {
|
|
|
112
112
|
if (!this._isActive)
|
|
113
113
|
return;
|
|
114
114
|
try {
|
|
115
|
-
if (this.reader.wasTruncated()) {
|
|
116
|
-
this.reader.reset();
|
|
117
|
-
this.callbacks.onReset?.();
|
|
118
|
-
}
|
|
119
115
|
const events = this.reader.readNew();
|
|
116
|
+
// The reader started over (truncated, rewritten, or replaced file):
|
|
117
|
+
// these events are the session from the beginning, so consumers must
|
|
118
|
+
// drop what they built before receiving them.
|
|
119
|
+
if (this.reader.wasTruncated())
|
|
120
|
+
this.callbacks.onReset?.();
|
|
120
121
|
for (const event of events) {
|
|
121
122
|
for (const followEvent of toFollowEvents(event, this.provider.id)) {
|
|
122
123
|
this.callbacks.onEvent(followEvent);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Continuity of a file read incrementally by byte offset: whether the file
|
|
3
|
+
* now at a path is still the content earlier reads consumed, or was
|
|
4
|
+
* truncated, rewritten, or replaced since.
|
|
5
|
+
*
|
|
6
|
+
* {@link FileContinuity} holds the rules `createJsonlTail` applies, so every
|
|
7
|
+
* incremental reader detects the same cases the same way:
|
|
8
|
+
*
|
|
9
|
+
* - `replaced`: another file (by device and inode, read from the open
|
|
10
|
+
* descriptor, so a rename between a stat and an open cannot mix two files)
|
|
11
|
+
* now has the path.
|
|
12
|
+
* - `truncated`: the file is shorter than the read position.
|
|
13
|
+
* - `rewritten`: the mtime changed and either the first {@link HEAD_BYTES}
|
|
14
|
+
* bytes differ from those recorded, or the byte before the committed
|
|
15
|
+
* (resume-safe) offset is no longer a newline.
|
|
16
|
+
*
|
|
17
|
+
* Replacement and truncation are checked on every read; the content probe
|
|
18
|
+
* only when the mtime changed or the recorded head is still short.
|
|
19
|
+
*
|
|
20
|
+
* Known limits: a rewrite that leaves the mtime unchanged (coarse mtime
|
|
21
|
+
* resolution, or an mtime restored on purpose) or that changes only bytes
|
|
22
|
+
* past the first 4 KiB while the resume point still follows a newline goes
|
|
23
|
+
* unnoticed; on filesystems without stable inode numbers (some SMB mounts,
|
|
24
|
+
* Windows) an unchanged file can read as replaced, which costs a replay.
|
|
25
|
+
*
|
|
26
|
+
* @module fileContinuity
|
|
27
|
+
*/
|
|
28
|
+
import * as fs from 'fs';
|
|
29
|
+
import { type FileHead } from './fileHead';
|
|
30
|
+
import type { JsonlTailResetReason } from './watchers/jsonlTail';
|
|
31
|
+
/** The fields of `fs.Stats` the continuity rules read. */
|
|
32
|
+
export type FileContinuityStat = Pick<fs.Stats, 'dev' | 'ino' | 'size' | 'mtimeMs'>;
|
|
33
|
+
/** The bytes the continuity check needs, read before any state changes. */
|
|
34
|
+
export interface FileContinuityProbe {
|
|
35
|
+
/** The file's first `min(HEAD_BYTES, size)` bytes. */
|
|
36
|
+
prefix: Buffer;
|
|
37
|
+
/** The byte before the committed offset, when there is one. */
|
|
38
|
+
before: Buffer | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What one reader knows about the file its offsets refer to: identity,
|
|
42
|
+
* mtime, and a digest of the first bytes, recorded by {@link adopt} after
|
|
43
|
+
* each read.
|
|
44
|
+
*
|
|
45
|
+
* Synchronous readers call {@link check} on the open descriptor, restart
|
|
46
|
+
* from offset 0 when it returns a reason, then call {@link adopt}. A reader
|
|
47
|
+
* that repositions without reading (a seek to a stored offset, a reset)
|
|
48
|
+
* calls {@link forget}, so its next read adopts the file instead of
|
|
49
|
+
* comparing it with the old one. The lower-level methods ({@link needsProbe},
|
|
50
|
+
* {@link reasonFor}, {@link record}) serve asynchronous readers that probe
|
|
51
|
+
* on their own.
|
|
52
|
+
*/
|
|
53
|
+
export declare class FileContinuity {
|
|
54
|
+
private identity;
|
|
55
|
+
private head;
|
|
56
|
+
private lastMtimeMs;
|
|
57
|
+
/** What the last {@link check} probed and decided, for {@link adopt}. */
|
|
58
|
+
private checked;
|
|
59
|
+
/** Device and inode of the adopted file; `null` before the first read and after {@link forget}. */
|
|
60
|
+
get knownIdentity(): {
|
|
61
|
+
dev: number;
|
|
62
|
+
ino: number;
|
|
63
|
+
} | null;
|
|
64
|
+
/** Length and digest of the adopted file's first bytes, once probed. */
|
|
65
|
+
get knownHead(): FileHead | null;
|
|
66
|
+
/** Whether {@link reasonFor} needs bytes from the file to decide. */
|
|
67
|
+
needsProbe(stat: FileContinuityStat, readOffset: number): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Why the reader must start over: the path now names another file, the
|
|
70
|
+
* file shrank below `readOffset`, its first bytes changed, or the resume
|
|
71
|
+
* point no longer follows a newline. `null` when it can continue.
|
|
72
|
+
*/
|
|
73
|
+
reasonFor(stat: FileContinuityStat, readOffset: number, probe: FileContinuityProbe | null): JsonlTailResetReason | null;
|
|
74
|
+
/** Records the identity, mtime, and (from `probe`) first bytes of the file the offsets now refer to. */
|
|
75
|
+
record(stat: FileContinuityStat, probe: FileContinuityProbe | null): void;
|
|
76
|
+
/** Drops the recorded first bytes (the reader restarted); the next {@link record} with a probe sets them again. */
|
|
77
|
+
discardHead(): void;
|
|
78
|
+
/** Records the file as known from `prefix`, its first `min(HEAD_BYTES, size)` bytes. */
|
|
79
|
+
adoptPrefix(stat: FileContinuityStat, prefix: Buffer): void;
|
|
80
|
+
/** Forgets the file, so the next {@link check} adopts whatever file has the path. */
|
|
81
|
+
forget(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Applies the rules to the file open on `fd` (`stat` from `fstat` on that
|
|
84
|
+
* descriptor), reading the bytes they need. `readOffset` is how far the
|
|
85
|
+
* reader has read; `committedOffset` (default `readOffset`) is its
|
|
86
|
+
* resume-safe position just after a newline. Returns why the reader must
|
|
87
|
+
* restart from offset 0, or `null`. Call {@link adopt} with the same
|
|
88
|
+
* `stat` once the reader has acted on the answer.
|
|
89
|
+
*/
|
|
90
|
+
check(fd: number, stat: FileContinuityStat, readOffset: number, committedOffset?: number): JsonlTailResetReason | null;
|
|
91
|
+
/** Records the file just checked as the one the reader's offsets now refer to. */
|
|
92
|
+
adopt(stat: FileContinuityStat): void;
|
|
93
|
+
}
|
|
94
|
+
/** Reads the bytes {@link FileContinuity.reasonFor} compares, from the file open on `fd`. */
|
|
95
|
+
export declare function probeFileContinuity(fd: number, stat: FileContinuityStat, committedOffset: number): FileContinuityProbe;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Continuity of a file read incrementally by byte offset: whether the file
|
|
4
|
+
* now at a path is still the content earlier reads consumed, or was
|
|
5
|
+
* truncated, rewritten, or replaced since.
|
|
6
|
+
*
|
|
7
|
+
* {@link FileContinuity} holds the rules `createJsonlTail` applies, so every
|
|
8
|
+
* incremental reader detects the same cases the same way:
|
|
9
|
+
*
|
|
10
|
+
* - `replaced`: another file (by device and inode, read from the open
|
|
11
|
+
* descriptor, so a rename between a stat and an open cannot mix two files)
|
|
12
|
+
* now has the path.
|
|
13
|
+
* - `truncated`: the file is shorter than the read position.
|
|
14
|
+
* - `rewritten`: the mtime changed and either the first {@link HEAD_BYTES}
|
|
15
|
+
* bytes differ from those recorded, or the byte before the committed
|
|
16
|
+
* (resume-safe) offset is no longer a newline.
|
|
17
|
+
*
|
|
18
|
+
* Replacement and truncation are checked on every read; the content probe
|
|
19
|
+
* only when the mtime changed or the recorded head is still short.
|
|
20
|
+
*
|
|
21
|
+
* Known limits: a rewrite that leaves the mtime unchanged (coarse mtime
|
|
22
|
+
* resolution, or an mtime restored on purpose) or that changes only bytes
|
|
23
|
+
* past the first 4 KiB while the resume point still follows a newline goes
|
|
24
|
+
* unnoticed; on filesystems without stable inode numbers (some SMB mounts,
|
|
25
|
+
* Windows) an unchanged file can read as replaced, which costs a replay.
|
|
26
|
+
*
|
|
27
|
+
* @module fileContinuity
|
|
28
|
+
*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
+
}) : function(o, v) {
|
|
43
|
+
o["default"] = v;
|
|
44
|
+
});
|
|
45
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
46
|
+
var ownKeys = function(o) {
|
|
47
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48
|
+
var ar = [];
|
|
49
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
58
|
+
__setModuleDefault(result, mod);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.FileContinuity = void 0;
|
|
64
|
+
exports.probeFileContinuity = probeFileContinuity;
|
|
65
|
+
const fs = __importStar(require("fs"));
|
|
66
|
+
const fileHead_1 = require("./fileHead");
|
|
67
|
+
/**
|
|
68
|
+
* What one reader knows about the file its offsets refer to: identity,
|
|
69
|
+
* mtime, and a digest of the first bytes, recorded by {@link adopt} after
|
|
70
|
+
* each read.
|
|
71
|
+
*
|
|
72
|
+
* Synchronous readers call {@link check} on the open descriptor, restart
|
|
73
|
+
* from offset 0 when it returns a reason, then call {@link adopt}. A reader
|
|
74
|
+
* that repositions without reading (a seek to a stored offset, a reset)
|
|
75
|
+
* calls {@link forget}, so its next read adopts the file instead of
|
|
76
|
+
* comparing it with the old one. The lower-level methods ({@link needsProbe},
|
|
77
|
+
* {@link reasonFor}, {@link record}) serve asynchronous readers that probe
|
|
78
|
+
* on their own.
|
|
79
|
+
*/
|
|
80
|
+
class FileContinuity {
|
|
81
|
+
identity = null;
|
|
82
|
+
head = null;
|
|
83
|
+
lastMtimeMs = -1;
|
|
84
|
+
/** What the last {@link check} probed and decided, for {@link adopt}. */
|
|
85
|
+
checked = null;
|
|
86
|
+
/** Device and inode of the adopted file; `null` before the first read and after {@link forget}. */
|
|
87
|
+
get knownIdentity() {
|
|
88
|
+
return this.identity;
|
|
89
|
+
}
|
|
90
|
+
/** Length and digest of the adopted file's first bytes, once probed. */
|
|
91
|
+
get knownHead() {
|
|
92
|
+
return this.head;
|
|
93
|
+
}
|
|
94
|
+
/** Whether {@link reasonFor} needs bytes from the file to decide. */
|
|
95
|
+
needsProbe(stat, readOffset) {
|
|
96
|
+
return (this.identity === null ||
|
|
97
|
+
stat.dev !== this.identity.dev ||
|
|
98
|
+
stat.ino !== this.identity.ino ||
|
|
99
|
+
stat.size < readOffset ||
|
|
100
|
+
stat.mtimeMs !== this.lastMtimeMs ||
|
|
101
|
+
this.head === null ||
|
|
102
|
+
this.head.bytes < Math.min(fileHead_1.HEAD_BYTES, stat.size));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Why the reader must start over: the path now names another file, the
|
|
106
|
+
* file shrank below `readOffset`, its first bytes changed, or the resume
|
|
107
|
+
* point no longer follows a newline. `null` when it can continue.
|
|
108
|
+
*/
|
|
109
|
+
reasonFor(stat, readOffset, probe) {
|
|
110
|
+
if (this.identity && (stat.dev !== this.identity.dev || stat.ino !== this.identity.ino)) {
|
|
111
|
+
return 'replaced';
|
|
112
|
+
}
|
|
113
|
+
if (stat.size < readOffset)
|
|
114
|
+
return 'truncated';
|
|
115
|
+
if (this.identity && stat.mtimeMs !== this.lastMtimeMs && probe) {
|
|
116
|
+
if (this.head && !(0, fileHead_1.headMatches)(this.head, probe.prefix))
|
|
117
|
+
return 'rewritten';
|
|
118
|
+
if (probe.before && probe.before[0] !== 0x0a)
|
|
119
|
+
return 'rewritten';
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/** Records the identity, mtime, and (from `probe`) first bytes of the file the offsets now refer to. */
|
|
124
|
+
record(stat, probe) {
|
|
125
|
+
this.identity = { dev: stat.dev, ino: stat.ino };
|
|
126
|
+
this.lastMtimeMs = stat.mtimeMs;
|
|
127
|
+
if (probe && (!this.head || this.head.bytes < Math.min(fileHead_1.HEAD_BYTES, stat.size))) {
|
|
128
|
+
this.head = (0, fileHead_1.fileHeadOf)(probe.prefix);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Drops the recorded first bytes (the reader restarted); the next {@link record} with a probe sets them again. */
|
|
132
|
+
discardHead() {
|
|
133
|
+
this.head = null;
|
|
134
|
+
}
|
|
135
|
+
/** Records the file as known from `prefix`, its first `min(HEAD_BYTES, size)` bytes. */
|
|
136
|
+
adoptPrefix(stat, prefix) {
|
|
137
|
+
this.identity = { dev: stat.dev, ino: stat.ino };
|
|
138
|
+
this.lastMtimeMs = stat.mtimeMs;
|
|
139
|
+
this.head = (0, fileHead_1.fileHeadOf)(prefix);
|
|
140
|
+
}
|
|
141
|
+
/** Forgets the file, so the next {@link check} adopts whatever file has the path. */
|
|
142
|
+
forget() {
|
|
143
|
+
this.identity = null;
|
|
144
|
+
this.head = null;
|
|
145
|
+
this.lastMtimeMs = -1;
|
|
146
|
+
this.checked = null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Applies the rules to the file open on `fd` (`stat` from `fstat` on that
|
|
150
|
+
* descriptor), reading the bytes they need. `readOffset` is how far the
|
|
151
|
+
* reader has read; `committedOffset` (default `readOffset`) is its
|
|
152
|
+
* resume-safe position just after a newline. Returns why the reader must
|
|
153
|
+
* restart from offset 0, or `null`. Call {@link adopt} with the same
|
|
154
|
+
* `stat` once the reader has acted on the answer.
|
|
155
|
+
*/
|
|
156
|
+
check(fd, stat, readOffset, committedOffset = readOffset) {
|
|
157
|
+
const probe = this.needsProbe(stat, readOffset)
|
|
158
|
+
? probeFileContinuity(fd, stat, committedOffset)
|
|
159
|
+
: null;
|
|
160
|
+
const reason = this.reasonFor(stat, readOffset, probe);
|
|
161
|
+
this.checked = { probe, reset: reason !== null };
|
|
162
|
+
return reason;
|
|
163
|
+
}
|
|
164
|
+
/** Records the file just checked as the one the reader's offsets now refer to. */
|
|
165
|
+
adopt(stat) {
|
|
166
|
+
const checked = this.checked;
|
|
167
|
+
this.checked = null;
|
|
168
|
+
if (checked?.reset)
|
|
169
|
+
this.head = null;
|
|
170
|
+
this.record(stat, checked?.probe ?? null);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.FileContinuity = FileContinuity;
|
|
174
|
+
/** Reads the bytes {@link FileContinuity.reasonFor} compares, from the file open on `fd`. */
|
|
175
|
+
function probeFileContinuity(fd, stat, committedOffset) {
|
|
176
|
+
return {
|
|
177
|
+
prefix: readAt(fd, 0, Math.min(fileHead_1.HEAD_BYTES, stat.size)),
|
|
178
|
+
before: committedOffset > 0 && committedOffset <= stat.size
|
|
179
|
+
? readAt(fd, committedOffset - 1, 1)
|
|
180
|
+
: null,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function readAt(fd, position, length) {
|
|
184
|
+
const buffer = Buffer.alloc(length);
|
|
185
|
+
const count = length > 0 ? fs.readSync(fd, buffer, 0, length, position) : 0;
|
|
186
|
+
return buffer.subarray(0, count);
|
|
187
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export { addDecision, decisionFingerprint } from './writers/decisions';
|
|
|
74
74
|
export { addNote } from './writers/notes';
|
|
75
75
|
export { renderHandoffUrlTemplate } from './handoffUrl';
|
|
76
76
|
export type { HandoffUrlIdentifiers } from './handoffUrl';
|
|
77
|
-
export type { ProviderId, SessionProvider, SessionProviderBase, SessionEnumerationCounters, ListSessionFilesOptions, WatchedSessionFile, SessionFileStats, SessionFileStatsAvailability, SessionFileInfo, SearchHit, ProjectFolderInfo, SessionReader, SessionProviderOptions, ProviderOperationStatus, SessionProviderDiagnostic, SessionProviderDiagnosticKind, SessionProviderDiagnosticPhase, SessionProviderDiagnosticSeverity, ProviderRuntimeStatus, } from './providers/types';
|
|
77
|
+
export type { ProviderId, SessionProvider, SessionProviderBase, SessionEnumerationCounters, ListSessionFilesOptions, WatchedSessionFile, SessionFileStats, SessionFileStatsAvailability, SessionFileInfo, SearchHit, ProjectFolderInfo, SessionReader, SessionReaderReset, SessionProviderOptions, ProviderOperationStatus, SessionProviderDiagnostic, SessionProviderDiagnosticKind, SessionProviderDiagnosticPhase, SessionProviderDiagnosticSeverity, ProviderRuntimeStatus, } from './providers/types';
|
|
78
78
|
export { SESSION_PROVIDER_IDS } from './providers/types';
|
|
79
79
|
export { createSessionProviders } from './providers/factory';
|
|
80
80
|
export type { CreateSessionProvidersOptions, CreateSessionProvidersResult, } from './providers/factory';
|
|
@@ -86,7 +86,9 @@ export { OpenCodeProvider, getOpenCodeDataDir } from './providers/openCode';
|
|
|
86
86
|
export { CodexProvider, findCodexRolloutFile } from './providers/codex';
|
|
87
87
|
export { walkRolloutFiles, walkRolloutFilesAsync } from './providers/rolloutWalker';
|
|
88
88
|
export type { RolloutFileInfo, WalkRolloutFilesOptions } from './providers/rolloutWalker';
|
|
89
|
-
export type { FindCodexRolloutFileOptions } from './providers/codex';
|
|
89
|
+
export type { CodexProviderOptions, FindCodexRolloutFileOptions } from './providers/codex';
|
|
90
|
+
export { COMPRESSED_ROLLOUT_SUFFIX, isCompressedRolloutPath, isZstdDecompressionAvailable, readRolloutBuffer, readRolloutText, resolveRolloutPath, } from './providers/compressedRollouts';
|
|
91
|
+
export type { ReadRolloutOptions } from './providers/compressedRollouts';
|
|
90
92
|
export { JsonlParser, TRUNCATION_PATTERNS } from './parsers/jsonl';
|
|
91
93
|
export type { RawSessionEvent, JsonlParserCallbacks, JsonlParserOptions } from './parsers/jsonl';
|
|
92
94
|
export { normalizeToolName, normalizeToolInput, detectPlanModeFromText, convertOpenCodeMessage, parseDbMessageData, parseDbPartData, } from './parsers/openCodeParser';
|
|
@@ -94,6 +96,8 @@ export { CodexRolloutParser, DEFAULT_MAX_TRACKED_TOOL_CALLS, extractPatchFilePat
|
|
|
94
96
|
export type { CodexPendingStats, CodexRolloutParserOptions, CodexRolloutResumeState, } from './parsers/codexParser';
|
|
95
97
|
export { codexRolloutOrigin, codexSpawnParentFromSource } from './parsers/codexRolloutOrigin';
|
|
96
98
|
export type { CodexRolloutOrigin } from './parsers/codexRolloutOrigin';
|
|
99
|
+
export { SUBAGENT_ACTIVITY_BLOCK_TYPE, SUBAGENT_ACTIVITY_ORIGIN_KIND, describeSubagentActivity, isSubagentActivitySystemEvent, parseCodexAgentMessageText, subagentActivityFromEvent, } from './subagentActivity';
|
|
100
|
+
export type { CodexAgentMessageText, SubagentActivity, SubagentActivityKind, } from './subagentActivity';
|
|
97
101
|
export { scanSubagentDir, extractTaskInfo, readAgentMeta } from './parsers/subagentScanner';
|
|
98
102
|
export type { AgentMeta } from './parsers/subagentScanner';
|
|
99
103
|
export { ClaudeUsageDeduper, SYNTHETIC_MODEL, dedupedRawClaudeUsage, normalizeClaudeUsage, } from './usage/claudeUsageDedupe';
|
|
@@ -115,7 +119,8 @@ export type { AsyncSessionPreviewOptions, ListSessionPreviewsAsyncOptions, ListS
|
|
|
115
119
|
export { parseDebugLog, filterByLevel, collapseDuplicates, discoverDebugLogs, } from './parsers/debugLogParser';
|
|
116
120
|
export type { DebugLogEntry, DebugLogFile, DebugLogLevel } from './parsers/debugLogParser';
|
|
117
121
|
export { OpenCodeDatabase } from './providers/openCodeDatabase';
|
|
118
|
-
export { CodexDatabase } from './providers/codexDatabase';
|
|
122
|
+
export { CodexDatabase, isCodexSubagentThread } from './providers/codexDatabase';
|
|
123
|
+
export type { CodexSpawnedThread } from './providers/codexDatabase';
|
|
119
124
|
export { searchSessions } from './search/sessionSearch';
|
|
120
125
|
export type { SearchResult, SessionSearchOptions } from './search/sessionSearch';
|
|
121
126
|
export { FilterEngine } from './search/advancedFilter';
|
|
@@ -124,8 +129,10 @@ export { composeContext } from './context/composer';
|
|
|
124
129
|
export type { Fidelity, ContextResult } from './context/composer';
|
|
125
130
|
export { buildSessionContextSnapshot, calculateSessionContextPressure, createSessionContextProjector, readSessionContextSnapshot, } from './context/sessionContext';
|
|
126
131
|
export type { BuildSessionContextSnapshotOptions, ReadSessionContextSnapshotOptions, SessionContextCapabilities, SessionContextLayerBreakdown, SessionContextPressure, SessionContextProjector, SessionContextSnapshot, SessionContextSource, SessionContextSourceType, } from './context/sessionContext';
|
|
127
|
-
export { SUBAGENT_SPAWN_TOOL_NAMES, isSubagentSpawnTool, isTaskNotificationSystemEvent, parseTaskNotification, taskNotificationFromEvent, } from './subagentSpawn';
|
|
128
|
-
export type { TaskNotification } from './subagentSpawn';
|
|
132
|
+
export { SUBAGENT_SPAWN_TOOL_NAMES, agentsStoppedNoticeFromEvent, isAgentsKilledSystemEvent, isCodexSubagentSpawnTool, isSubagentSpawnTool, isTaskNotificationSystemEvent, isTaskStatusSystemEvent, parseAgentsStoppedNotice, parseCodexSpawnLaunch, parseTaskNotification, taskNotificationFromEvent, taskStatusFromAttachment, taskStatusFromEvent, } from './subagentSpawn';
|
|
133
|
+
export type { AgentsStoppedNotice, CodexSpawnLaunch, SubagentTaskStatus, TaskNotification, } from './subagentSpawn';
|
|
134
|
+
export { SUBAGENT_PARENT_IDLE_ENDED_MS, SUBAGENT_UNREPORTED_QUIET_MS, resolveSubagentDisplayState, subagentDisplayLabel, } from './subagentDisplayState';
|
|
135
|
+
export type { SubagentDisplayLifecycle, SubagentDisplayOptions, SubagentDisplayReason, SubagentDisplayState, SubagentDisplayStateName, SubagentDisplayTrace, } from './subagentDisplayState';
|
|
129
136
|
export { assistantTurnEventsFromSessionEvents, extractTurnSubagents, isAssistantTurnSubagentTool, reasoningSummary, segmentAssistantTurn, } from './turns/assistantTurn';
|
|
130
137
|
export type { AssistantTurnEvent, AssistantTurnEventType, AssistantTurnProcess, AssistantTurnProcessStep, AssistantTurnProjection, AssistantTurnSubagent, AssistantTurnSubagentStatus, AssistantTurnTimelineItem, AssistantTurnToolRef, ExtractTurnSubagentsOptions, ReasoningSummary, SegmentAssistantTurnOptions, } from './turns/assistantTurn';
|
|
131
138
|
export { PlanExtractor, parsePlanMarkdown as parsePlanMarkdownShared, extractProposedPlan as extractProposedPlanShared, } from './parsers/planExtractor';
|
|
@@ -152,10 +159,10 @@ export type { PhraseCategory } from './phrases';
|
|
|
152
159
|
export { EventAggregator, parseTodoDependencies } from './aggregation/EventAggregator';
|
|
153
160
|
export { SessionMonitor } from './sessionMonitor';
|
|
154
161
|
export type { SessionMonitorOptions, SessionMonitorSubscribeOptions } from './sessionMonitor';
|
|
155
|
-
export type { SerializedAggregatorState } from './aggregation/EventAggregator';
|
|
162
|
+
export type { SerializedAggregatorState, SubagentEvidence } from './aggregation/EventAggregator';
|
|
156
163
|
export { saveSnapshot, loadSnapshot, deleteSnapshot, isSnapshotValid, pruneSnapshots, MAX_SNAPSHOT_FILES, getSnapshotPath, } from './aggregation/snapshot';
|
|
157
164
|
export type { SessionSnapshot } from './aggregation/snapshot';
|
|
158
|
-
export type { EventAggregatorOptions, AggregatedCostProvenance, AggregatedTokens, ModelUsageStats, BurnRateInfo, SubagentLifecycle, SubagentOutcome, AggregatedMetrics, FrequencyMetric, PatternMetric, HeatmapBucketMetric, ErrorRollup, ErrorRollupEntry, ErrorBucketMetric, } from './aggregation/types';
|
|
165
|
+
export type { EventAggregatorOptions, AggregatedCostProvenance, AggregatedTokens, ModelUsageStats, BurnRateInfo, SubagentLifecycle, SubagentOutcome, SubagentSettledBy, AggregatedMetrics, FrequencyMetric, PatternMetric, HeatmapBucketMetric, ErrorRollup, ErrorRollupEntry, ErrorBucketMetric, } from './aggregation/types';
|
|
159
166
|
export { ERROR_HISTORY_SCHEMA_VERSION, MAX_ERROR_HISTORY_SESSIONS, appendErrorHistory, getTopFailingTools, readErrorHistory, } from './errorHistory';
|
|
160
167
|
export type { ErrorHistorySessionRecord, ErrorHistoryStore, TopFailingTool } from './errorHistory';
|
|
161
168
|
export { FrequencyTracker } from './aggregation/FrequencyTracker';
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.applySessionSummary = exports.pruneUsageCache = exports.getUsageCacheDir = exports.collectUsageEvents = exports.USAGE_CACHE_VERSION = exports.MAX_USAGE_CACHE_FILES = exports.findActiveBillingBlock = exports.computeBillingBlocks = exports.BILLING_BLOCK_DURATION_MS = exports.writeStateFile = exports.readStateFile = exports.quotaToStateFile = exports.getStateFilePath = exports.billingBlockToStateFile = exports.STATE_FILE_SCHEMA_VERSION = exports.STATE_FILE_NAME = exports.sessionFingerprintParts = exports.fingerprintString = exports.readSessionReportInputs = exports.readSessionFileStats = exports.providerContextSizeFn = exports.firstUserPrompt = exports.computeSessionFileStats = exports.isHumanPrompt = exports.humanPromptText = exports.HUMAN_CODEX_SOURCES = exports.HUMAN_CLAUDE_ENTRYPOINTS = exports.collectSessionPromptHistory = exports.findToolCallOrigins = exports.PROMPT_HISTORY_ORDINAL_MAX_RECORD_BYTES = exports.parsePromptHistoryCursor = exports.isPromptHistorySessionSettled = exports.collectPromptHistory = exports.readSessionTranscript = exports.listRecentSessions = exports.projectSessionTranscript = exports.estimateSerializedTokens = exports.estimateTextTokens = exports.ASCII_CHARS_PER_TOKEN = exports.TOKEN_TOTAL_LABEL = exports.TOKEN_SUBAGENTS_LABEL = exports.TOKEN_SESSION_TOTAL_LABEL = exports.TOKEN_MAIN_THREAD_LABEL = exports.TOKEN_CONTEXT_LABEL = exports.sumTokenTotals = exports.summarizeTokens = exports.formatTokenBreakdown = exports.calculateNormalizedUsageCost = exports.extractNormalizedUsage = exports.normalizeProviderUsage = void 0;
|
|
7
7
|
exports.getPlanAnalytics = exports.writePlans = exports.getLatestPlan = exports.readPlans = exports.readLatestHandoff = exports.readHistory = exports.readNotes = exports.readDecisions = exports.readTasks = exports.migrateLegacyProjectStores = exports.resolveProjectIdentity = exports.getProjectSlugRaw = exports.getProjectSlug = exports.encodeWorkspacePath = exports.getGlobalDataPath = exports.getProjectDataPath = exports.setConfigDir = exports.getDefaultConfigDir = exports.getConfigDirOverride = exports.getConfigDir = exports.CONFIG_DIR_ENV_VAR = exports.MAX_PLANS_PER_PROJECT = exports.PLAN_SCHEMA_VERSION = exports.createEmptyDataStore = exports.createEmptyTokenTotals = exports.HISTORICAL_SESSION_RETENTION_LIMIT = exports.HISTORICAL_DATA_SCHEMA_VERSION = exports.STALENESS_THRESHOLDS = exports.IMPORTANCE_DECAY_FACTORS = exports.KNOWLEDGE_NOTE_SCHEMA_VERSION = exports.DECISION_LOG_SCHEMA_VERSION = exports.normalizeTaskStatus = exports.TASK_PERSISTENCE_SCHEMA_VERSION = exports.isAggregateCodexLimit = exports.splitWatchedPath = exports.DirectoryListingCache = exports.fileFingerprintParts = exports.fileFingerprint = exports.observedSessionSourceFromProvider = exports.ObservedSessionCollector = exports.weekKey = exports.usageBucketKey = exports.summarizeUsageRows = exports.bucketUsage = exports.importSessionHistory = exports.ACTIVE_SESSION_MTIME_THRESHOLD_MS = exports.sessionSummaryFromStats = exports.removeSessionSummary = exports.markFileImported = exports.isFileImported = void 0;
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
8
|
+
exports.codexSpawnParentFromSource = exports.codexRolloutOrigin = exports.resolveCodexCallUsage = exports.normalizeCodexToolInput = exports.normalizeCodexToolName = exports.extractPatchFilePaths = exports.DEFAULT_MAX_TRACKED_TOOL_CALLS = exports.CodexRolloutParser = exports.parseDbPartData = exports.parseDbMessageData = exports.convertOpenCodeMessage = exports.detectPlanModeFromText = exports.normalizeToolInput = exports.normalizeToolName = exports.TRUNCATION_PATTERNS = exports.JsonlParser = exports.resolveRolloutPath = exports.readRolloutText = exports.readRolloutBuffer = exports.isZstdDecompressionAvailable = exports.isCompressedRolloutPath = exports.COMPRESSED_ROLLOUT_SUFFIX = exports.walkRolloutFilesAsync = exports.walkRolloutFiles = exports.findCodexRolloutFile = exports.CodexProvider = exports.getOpenCodeDataDir = exports.OpenCodeProvider = exports.ClaudeCodeProvider = exports.getAllDetectedProviders = exports.detectProvider = exports._resetProviderDetectionCache = exports.getObservedActivityReason = exports.derivePendingUserRequestV1 = exports.createProviderSessionAdapterV1 = exports.createSessionProviders = exports.SESSION_PROVIDER_IDS = exports.renderHandoffUrlTemplate = exports.addNote = exports.decisionFingerprint = exports.addDecision = exports.completeTask = exports.addTask = exports.withFileLockSync = exports.updateJsonStoreAtomicSync = exports.updateJsonStoreAtomic = exports.atomicWriteFileSync = exports.atomicWriteJsonSync = exports.atomicWriteJson = exports.readClaudeCodePlanFiles = void 0;
|
|
9
|
+
exports.OpenCodeDatabase = exports.discoverDebugLogs = exports.collapseDuplicates = exports.filterByLevel = exports.parseDebugLog = exports.readSessionPreviewAsync = exports.readSessionPreview = exports.listSessionPreviewsAsync = exports.listSessionPreviews = exports.readCodexHistory = exports.parseMcpToolName = exports.scanSubagentTraces = exports.findAllSessionsWithWorktrees = exports.discoverWorktreeSiblings = exports.resolveWorktreeMainRepo = exports.getAllClaudeProjectFolders = exports.decodeEncodedPath = exports.getMostRecentlyActiveSessionDir = exports.findSubdirectorySessionDirs = exports.findSessionFilesWithStats = exports.findSessionsInDirectory = exports.findAllClaudeSessions = exports.findActiveClaudeSession = exports.discoverSessionDirectory = exports.getClaudeSessionDirectory = exports.encodeClaudeWorkspacePath = exports.SESSION_ACTIVITY_STALENESS_MS = exports.SESSION_ACTIVITY_GRACE_PERIOD_MS = exports.refreshSessionActivityState = exports.detectSessionActivity = exports.classifySessionActivity = exports.subagentTokenTotals = exports.scanSessionSubagents = exports.readMainThreadTokenTotals = exports.combineSessionTokenTotals = exports.collectSessionTokenTotals = exports.addUsageToSubagent = exports.normalizeClaudeUsage = exports.dedupedRawClaudeUsage = exports.SYNTHETIC_MODEL = exports.ClaudeUsageDeduper = exports.readAgentMeta = exports.extractTaskInfo = exports.scanSubagentDir = exports.subagentActivityFromEvent = exports.parseCodexAgentMessageText = exports.isSubagentActivitySystemEvent = exports.describeSubagentActivity = exports.SUBAGENT_ACTIVITY_ORIGIN_KIND = exports.SUBAGENT_ACTIVITY_BLOCK_TYPE = void 0;
|
|
10
|
+
exports.parseLocalDateKey = exports.formatTokenCount = exports.formatLocalDateKey = exports.formatDurationMs = exports.addLocalDays = exports.verifyJsonlCheckpoint = exports.JsonlTailSymlinkError = exports.JSONL_TAIL_CHECKPOINT_VERSION = exports.DEFAULT_JSONL_TAIL_READ_BYTES = exports.DEFAULT_JSONL_TAIL_MAX_LINE_BYTES = exports.createJsonlTail = exports.captureJsonlCheckpoint = exports.toFollowEvents = exports.resolveSessionPath = exports.createWatcher = exports.parseChangelog = exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.PlanExtractor = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.subagentDisplayLabel = exports.resolveSubagentDisplayState = exports.SUBAGENT_UNREPORTED_QUIET_MS = exports.SUBAGENT_PARENT_IDLE_ENDED_MS = exports.taskStatusFromEvent = exports.taskStatusFromAttachment = exports.taskNotificationFromEvent = exports.parseTaskNotification = exports.parseCodexSpawnLaunch = exports.parseAgentsStoppedNotice = exports.isTaskStatusSystemEvent = exports.isTaskNotificationSystemEvent = exports.isSubagentSpawnTool = exports.isCodexSubagentSpawnTool = exports.isAgentsKilledSystemEvent = exports.agentsStoppedNoticeFromEvent = exports.SUBAGENT_SPAWN_TOOL_NAMES = exports.readSessionContextSnapshot = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.composeContext = exports.FilterEngine = exports.searchSessions = exports.isCodexSubagentThread = exports.CodexDatabase = void 0;
|
|
11
|
+
exports.deleteStoredCredentials = exports.writeActiveCredentials = exports.readClaudeCredentialStore = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscriptFromEvents = exports.parseTranscript = exports.generateHtmlReport = exports.formatCompactionLedger = exports.calculateCompactionLedger = exports.describeCostProvenance = exports.classifyCostProvenance = exports.calculateCodeImpact = exports.scoreSessionQuality = exports.calculateQualityTrend = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.readErrorHistory = exports.getTopFailingTools = exports.appendErrorHistory = exports.MAX_ERROR_HISTORY_SESSIONS = exports.ERROR_HISTORY_SCHEMA_VERSION = exports.getSnapshotPath = exports.MAX_SNAPSHOT_FILES = exports.pruneSnapshots = exports.isSnapshotValid = exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.SessionMonitor = exports.parseTodoDependencies = exports.EventAggregator = exports.getRandomPhrase = exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = void 0;
|
|
12
|
+
exports.spawnAccountLogin = exports.finalizeAccountLoginAsync = exports.finalizeAccountLogin = exports.getAccountLoginStatusAsync = exports.getAccountLoginStatus = exports.beginAccountLogin = exports.isMultiAccountEnabled = exports.resolveActiveClaudeAccount = exports.getActiveAccount = exports.listAccounts = exports.removeAccount = exports.reconcileClaudeAuthState = exports.applyActiveClaudeToLiveHome = exports.resolveActiveClaudeHome = exports.cleanupAbandonedClaudeLogins = exports.syncClaudeLiveState = exports.switchToAccountAsync = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.compareCodexAuthFreshness = exports.codexRefreshFingerprint = exports.codexIdentitiesMatch = exports.readCodexAccessTokenExpiry = exports.readCodexLastRefresh = exports.readCodexAuthIdentity = exports.parseCodexAuthJson = exports.CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS = exports.CLAUDE_ACCESS_TOKEN_LIFETIME_MS = exports.mergeClaudeLoginIntoLive = exports.claudeLoginOnly = exports.claudeRefreshFingerprint = exports.resolveClaudeRefreshExpiry = exports.isNewerClaudeCredential = exports.claudeCredentialFreshness = exports.parseClaudeCredentialBlob = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentialsRaw = exports.readClaudeMaxCredentials = exports.parseKeychainDump = exports.repairClaudeCredentialStores = exports.inspectClaudeCredentialStores = exports.getClaudeCredentialLedgerPath = exports.readClaudeCredentialLedger = exports.decideLiveClaudeWrite = exports.SIDEKICK_KEYCHAIN_COMMENT_PREFIX = exports.ClaudeCredentialWriteError = void 0;
|
|
13
|
+
exports.getDefaultClaudeHome = exports.getLiveClaudeHome = exports.readLiveClaudeIdentity = exports.readClaudeProfileIdentity = exports.isClaudeProfileAuthenticated = exports.CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV = exports.buildClaudeChildEnv = exports.claudeKeychainAccountName = exports.claudeKeychainService = exports.claudeKeychainSuffix = exports.getClaudeConfigPath = exports.getClaudeProfileHome = exports.getClaudeProfilesDir = exports.onAccountsChanged = exports.getActiveAccountStatus = exports.ACCOUNT_PROVIDER_IDS = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.ACCOUNT_CONSUMER_REACHABILITY = exports.describeAccountConsumer = exports.detectRunningAccountConsumersSync = exports.detectRunningAccountConsumers = exports.findRunningProcessesSync = exports.findRunningProcesses = exports.keepAliveCommand = exports.refreshInactiveAccounts = exports.getAccountLaunchEnv = exports.getHealthSidecarPath = exports.readHealthSidecar = exports.listAccountsWithHealth = exports.getAccountHealth = exports.cleanupAbandonedLogins = exports.syncLiveAccountStateSync = exports.syncLiveAccountState = exports.getLastSwitchPath = exports.readLastSwitch = exports.discardAccountLogin = exports.resolveClaudeLoginCommand = exports.listAllAccounts = exports.getLastSwitch = exports.undoLastSwitch = exports.switchAccountAsync = exports.switchAccount = void 0;
|
|
14
|
+
exports.classifyQuotaFreshness = exports.resolveQuota = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = exports.withQuotaProjections = exports.withClaudePlan = exports.quotaWindowShortLabel = exports.quotaWindowLabel = exports.quotaWindowHasData = exports.quotaWindowApplies = exports.quotaStateFromClaudeUsagePayload = exports.quotaSampleExpired = exports.projectQuotaWindow = exports.formatExtraUsage = exports.fetchQuota = exports.extraQuotaRows = exports.claudePlanLabel = exports.SEVEN_DAY_WINDOW_MS = exports.QUOTA_PROVIDER_IDS = exports.FIVE_HOUR_WINDOW_MS = exports.AutoSwitchController = exports.decideAutoSwitch = exports.DEFAULT_AUTO_SWITCH_CONFIG = exports.removeLauncher = exports.writeLauncher = exports.writeAccountLauncher = exports.CODEX_KEYRING_FIX_HINT = exports.getCodexCredentialStoreMode = exports.cleanupAbandonedCodexLogins = exports.syncCodexLiveState = exports.removeCodexAccount = exports.switchToCodexAccountAsync = exports.switchToCodexAccount = exports.finalizeCodexAccountAsync = exports.finalizeCodexAccount = exports.prepareCodexAccountAsync = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.resolveActiveCodexAccount = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getClaudeProjectsDir = exports.isDefaultClaudeHome = void 0;
|
|
15
|
+
exports.isMovingModelAlias = exports.canonicalModelId = exports.MODEL_PROVIDER_IDS = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.resolveModelPricing = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.resolveModelContextWindow = exports.getModelContextWindowSize = exports.selectStatuslineAccount = exports.formatStatusline = exports.estimateTimeToQuota = exports.BurnRateCalculator = exports.RUNTIME_QUOTA_PROVIDER_IDS = exports.MultiProviderQuotaService = exports.resolveZaiQuota = exports.readZaiCredentials = exports.quotaStateFromZaiQuotaLimitPayload = exports.fetchZaiQuotaFromApi = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.fetchCodexResetCreditsFromApi = exports.quotaHistoryWindow = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.quotaFromStatuslinePayload = exports.parseClaudeStatuslinePayload = exports.evaluateQuotaThresholds = exports.describeQuotaThresholdAlert = exports.DEFAULT_QUOTA_THRESHOLDS = exports.QUOTA_FRESH_MAX_AGE_MS = exports.QUOTA_AGING_MAX_AGE_MS = exports.formatQuotaAge = void 0;
|
|
16
|
+
exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.codexResetCreditsSnapshotSchema = exports.codexResetCreditSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaExtraUsageSchema = exports.quotaLimitRowSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.ToolCallTracker = exports.extractToolCalls = exports.extractToolCall = exports.extractErrorMessage = exports.categorizeError = exports.gatherAssetsForCwd = exports.codexSessions = exports.readCodexAssets = exports.claudeSessions = exports.readClaudeAssets = exports.extractCommands = exports.extractFilePaths = exports.extractUrls = exports.extractTokenUsage = exports.getObservedContextWindowPath = exports.recordObservedContextWindow = exports.loadObservedContextWindows = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmContextWindows = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.RESOLVED_MODEL_CATALOG_SCHEMA_VERSION = exports.resolveModelAlias = exports.registerModelAlias = exports.importResolvedModelCatalog = exports.exportResolvedModelCatalog = exports.mergeCostComponents = exports.costSourceFromPricingProvenance = exports.getPricingCatalogInfo = exports.clearRegisteredModelPricing = exports.registerModelPricing = void 0;
|
|
17
|
+
exports.diagnoseProviderFailure = exports.mergeFailingToolWindows = exports.failingToolTrend = exports.FAILING_TOOL_TREND_ARROWS = exports.scopePeakHoursToSessionProvider = exports.PEAK_HOURS_DESCRIPTION = exports.PEAK_HOURS_CACHE_MS = exports.isClaudeCodeSessionProvider = exports.getScheduledPeakHoursState = exports.fetchPeakHoursStatus = exports.DEFAULT_PEAK_HOURS_TIMEOUT_MS = exports.createPeakHoursNotApplicableState = exports._resetPeakHoursCache = exports.runDoctor = exports.getSessionDiagnostics = exports.formatHealthReport = exports.toLegacyProviderStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.providerFailureDiagnosisSchema = exports.providerRetryAfterSchema = exports.providerFailureEvidenceSchema = exports.providerAuthenticationEvidenceSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.zaiProviderQuotaStateSchema = exports.codexProviderQuotaStateSchema = void 0;
|
|
18
|
+
exports.resolveWorkspaceRoots = exports.TOOL_CATEGORIES = exports.classifyTool = exports.CODEX_ARCHIVED_SESSIONS_SUBDIR = exports.CODEX_SESSIONS_SUBDIR = exports.forceFileCredentialStore = exports.getCodexSessionsDirs = exports.syncCodexLiveStateAsync = exports.readStoredCodexAccount = exports.repairCodexCredentialStores = exports.inspectCodexCredentialStores = exports.fetchProviderServiceStatus = exports.parseCodexLoginStatus = exports.parseClaudeAuthStatus = exports.decodeCodexErrorInfo = exports.CODEX_ERROR_INFO_KINDS = exports.PROVIDER_RECOVERY_ACTIONS = exports.PROVIDER_FAILURE_EVIDENCE_SOURCES = exports.PROVIDER_FAILURE_CODES = exports.PROVIDER_CREDENTIAL_KINDS = exports.PROVIDER_AUTHENTICATION_STATES = exports.PROVIDER_AUTHENTICATION_SOURCES = void 0;
|
|
18
19
|
var usageNormalization_1 = require("./usageNormalization");
|
|
19
20
|
Object.defineProperty(exports, "normalizeProviderUsage", { enumerable: true, get: function () { return usageNormalization_1.normalizeProviderUsage; } });
|
|
20
21
|
Object.defineProperty(exports, "extractNormalizedUsage", { enumerable: true, get: function () { return usageNormalization_1.extractNormalizedUsage; } });
|
|
@@ -193,6 +194,13 @@ Object.defineProperty(exports, "findCodexRolloutFile", { enumerable: true, get:
|
|
|
193
194
|
var rolloutWalker_1 = require("./providers/rolloutWalker");
|
|
194
195
|
Object.defineProperty(exports, "walkRolloutFiles", { enumerable: true, get: function () { return rolloutWalker_1.walkRolloutFiles; } });
|
|
195
196
|
Object.defineProperty(exports, "walkRolloutFilesAsync", { enumerable: true, get: function () { return rolloutWalker_1.walkRolloutFilesAsync; } });
|
|
197
|
+
var compressedRollouts_1 = require("./providers/compressedRollouts");
|
|
198
|
+
Object.defineProperty(exports, "COMPRESSED_ROLLOUT_SUFFIX", { enumerable: true, get: function () { return compressedRollouts_1.COMPRESSED_ROLLOUT_SUFFIX; } });
|
|
199
|
+
Object.defineProperty(exports, "isCompressedRolloutPath", { enumerable: true, get: function () { return compressedRollouts_1.isCompressedRolloutPath; } });
|
|
200
|
+
Object.defineProperty(exports, "isZstdDecompressionAvailable", { enumerable: true, get: function () { return compressedRollouts_1.isZstdDecompressionAvailable; } });
|
|
201
|
+
Object.defineProperty(exports, "readRolloutBuffer", { enumerable: true, get: function () { return compressedRollouts_1.readRolloutBuffer; } });
|
|
202
|
+
Object.defineProperty(exports, "readRolloutText", { enumerable: true, get: function () { return compressedRollouts_1.readRolloutText; } });
|
|
203
|
+
Object.defineProperty(exports, "resolveRolloutPath", { enumerable: true, get: function () { return compressedRollouts_1.resolveRolloutPath; } });
|
|
196
204
|
// Parsers — JSONL
|
|
197
205
|
var jsonl_1 = require("./parsers/jsonl");
|
|
198
206
|
Object.defineProperty(exports, "JsonlParser", { enumerable: true, get: function () { return jsonl_1.JsonlParser; } });
|
|
@@ -216,6 +224,13 @@ Object.defineProperty(exports, "resolveCodexCallUsage", { enumerable: true, get:
|
|
|
216
224
|
var codexRolloutOrigin_1 = require("./parsers/codexRolloutOrigin");
|
|
217
225
|
Object.defineProperty(exports, "codexRolloutOrigin", { enumerable: true, get: function () { return codexRolloutOrigin_1.codexRolloutOrigin; } });
|
|
218
226
|
Object.defineProperty(exports, "codexSpawnParentFromSource", { enumerable: true, get: function () { return codexRolloutOrigin_1.codexSpawnParentFromSource; } });
|
|
227
|
+
var subagentActivity_1 = require("./subagentActivity");
|
|
228
|
+
Object.defineProperty(exports, "SUBAGENT_ACTIVITY_BLOCK_TYPE", { enumerable: true, get: function () { return subagentActivity_1.SUBAGENT_ACTIVITY_BLOCK_TYPE; } });
|
|
229
|
+
Object.defineProperty(exports, "SUBAGENT_ACTIVITY_ORIGIN_KIND", { enumerable: true, get: function () { return subagentActivity_1.SUBAGENT_ACTIVITY_ORIGIN_KIND; } });
|
|
230
|
+
Object.defineProperty(exports, "describeSubagentActivity", { enumerable: true, get: function () { return subagentActivity_1.describeSubagentActivity; } });
|
|
231
|
+
Object.defineProperty(exports, "isSubagentActivitySystemEvent", { enumerable: true, get: function () { return subagentActivity_1.isSubagentActivitySystemEvent; } });
|
|
232
|
+
Object.defineProperty(exports, "parseCodexAgentMessageText", { enumerable: true, get: function () { return subagentActivity_1.parseCodexAgentMessageText; } });
|
|
233
|
+
Object.defineProperty(exports, "subagentActivityFromEvent", { enumerable: true, get: function () { return subagentActivity_1.subagentActivityFromEvent; } });
|
|
219
234
|
// Parsers — Subagent scanning
|
|
220
235
|
var subagentScanner_1 = require("./parsers/subagentScanner");
|
|
221
236
|
Object.defineProperty(exports, "scanSubagentDir", { enumerable: true, get: function () { return subagentScanner_1.scanSubagentDir; } });
|
|
@@ -284,6 +299,7 @@ var openCodeDatabase_1 = require("./providers/openCodeDatabase");
|
|
|
284
299
|
Object.defineProperty(exports, "OpenCodeDatabase", { enumerable: true, get: function () { return openCodeDatabase_1.OpenCodeDatabase; } });
|
|
285
300
|
var codexDatabase_1 = require("./providers/codexDatabase");
|
|
286
301
|
Object.defineProperty(exports, "CodexDatabase", { enumerable: true, get: function () { return codexDatabase_1.CodexDatabase; } });
|
|
302
|
+
Object.defineProperty(exports, "isCodexSubagentThread", { enumerable: true, get: function () { return codexDatabase_1.isCodexSubagentThread; } });
|
|
287
303
|
// Search
|
|
288
304
|
var sessionSearch_1 = require("./search/sessionSearch");
|
|
289
305
|
Object.defineProperty(exports, "searchSessions", { enumerable: true, get: function () { return sessionSearch_1.searchSessions; } });
|
|
@@ -300,10 +316,23 @@ Object.defineProperty(exports, "readSessionContextSnapshot", { enumerable: true,
|
|
|
300
316
|
// Subagent spawns (`Agent` / `Task`) and background-task notifications
|
|
301
317
|
var subagentSpawn_1 = require("./subagentSpawn");
|
|
302
318
|
Object.defineProperty(exports, "SUBAGENT_SPAWN_TOOL_NAMES", { enumerable: true, get: function () { return subagentSpawn_1.SUBAGENT_SPAWN_TOOL_NAMES; } });
|
|
319
|
+
Object.defineProperty(exports, "agentsStoppedNoticeFromEvent", { enumerable: true, get: function () { return subagentSpawn_1.agentsStoppedNoticeFromEvent; } });
|
|
320
|
+
Object.defineProperty(exports, "isAgentsKilledSystemEvent", { enumerable: true, get: function () { return subagentSpawn_1.isAgentsKilledSystemEvent; } });
|
|
321
|
+
Object.defineProperty(exports, "isCodexSubagentSpawnTool", { enumerable: true, get: function () { return subagentSpawn_1.isCodexSubagentSpawnTool; } });
|
|
303
322
|
Object.defineProperty(exports, "isSubagentSpawnTool", { enumerable: true, get: function () { return subagentSpawn_1.isSubagentSpawnTool; } });
|
|
304
323
|
Object.defineProperty(exports, "isTaskNotificationSystemEvent", { enumerable: true, get: function () { return subagentSpawn_1.isTaskNotificationSystemEvent; } });
|
|
324
|
+
Object.defineProperty(exports, "isTaskStatusSystemEvent", { enumerable: true, get: function () { return subagentSpawn_1.isTaskStatusSystemEvent; } });
|
|
325
|
+
Object.defineProperty(exports, "parseAgentsStoppedNotice", { enumerable: true, get: function () { return subagentSpawn_1.parseAgentsStoppedNotice; } });
|
|
326
|
+
Object.defineProperty(exports, "parseCodexSpawnLaunch", { enumerable: true, get: function () { return subagentSpawn_1.parseCodexSpawnLaunch; } });
|
|
305
327
|
Object.defineProperty(exports, "parseTaskNotification", { enumerable: true, get: function () { return subagentSpawn_1.parseTaskNotification; } });
|
|
306
328
|
Object.defineProperty(exports, "taskNotificationFromEvent", { enumerable: true, get: function () { return subagentSpawn_1.taskNotificationFromEvent; } });
|
|
329
|
+
Object.defineProperty(exports, "taskStatusFromAttachment", { enumerable: true, get: function () { return subagentSpawn_1.taskStatusFromAttachment; } });
|
|
330
|
+
Object.defineProperty(exports, "taskStatusFromEvent", { enumerable: true, get: function () { return subagentSpawn_1.taskStatusFromEvent; } });
|
|
331
|
+
var subagentDisplayState_1 = require("./subagentDisplayState");
|
|
332
|
+
Object.defineProperty(exports, "SUBAGENT_PARENT_IDLE_ENDED_MS", { enumerable: true, get: function () { return subagentDisplayState_1.SUBAGENT_PARENT_IDLE_ENDED_MS; } });
|
|
333
|
+
Object.defineProperty(exports, "SUBAGENT_UNREPORTED_QUIET_MS", { enumerable: true, get: function () { return subagentDisplayState_1.SUBAGENT_UNREPORTED_QUIET_MS; } });
|
|
334
|
+
Object.defineProperty(exports, "resolveSubagentDisplayState", { enumerable: true, get: function () { return subagentDisplayState_1.resolveSubagentDisplayState; } });
|
|
335
|
+
Object.defineProperty(exports, "subagentDisplayLabel", { enumerable: true, get: function () { return subagentDisplayState_1.subagentDisplayLabel; } });
|
|
307
336
|
// Assistant turn projection
|
|
308
337
|
var assistantTurn_1 = require("./turns/assistantTurn");
|
|
309
338
|
Object.defineProperty(exports, "assistantTurnEventsFromSessionEvents", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnEventsFromSessionEvents; } });
|
package/dist/node.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export { findCodexRolloutFile } from './providers/codex';
|
|
|
43
43
|
export { walkRolloutFiles, walkRolloutFilesAsync } from './providers/rolloutWalker';
|
|
44
44
|
export type { RolloutFileInfo, WalkRolloutFilesOptions } from './providers/rolloutWalker';
|
|
45
45
|
export type { FindCodexRolloutFileOptions } from './providers/codex';
|
|
46
|
+
export { COMPRESSED_ROLLOUT_SUFFIX, isCompressedRolloutPath, isZstdDecompressionAvailable, readRolloutBuffer, readRolloutText, resolveRolloutPath, } from './providers/compressedRollouts';
|
|
47
|
+
export type { ReadRolloutOptions } from './providers/compressedRollouts';
|
|
46
48
|
export { readCodexHistory } from './parsers/codexHistory';
|
|
47
49
|
export type { CodexHistoryEntry, ReadCodexHistoryOptions } from './parsers/codexHistory';
|
|
48
50
|
export { listSessionPreviews, listSessionPreviewsAsync, readSessionPreview, readSessionPreviewAsync, } from './sessionPreviews';
|
|
@@ -67,6 +69,8 @@ export { parseClaudeAuthStatus, parseCodexLoginStatus } from './authStatus';
|
|
|
67
69
|
export type { ParsedClaudeAuthStatus, ParsedCodexLoginStatus } from './authStatus';
|
|
68
70
|
export { codexRolloutOrigin, codexSpawnParentFromSource } from './parsers/codexRolloutOrigin';
|
|
69
71
|
export type { CodexRolloutOrigin } from './parsers/codexRolloutOrigin';
|
|
72
|
+
export { SUBAGENT_ACTIVITY_BLOCK_TYPE, SUBAGENT_ACTIVITY_ORIGIN_KIND, describeSubagentActivity, isSubagentActivitySystemEvent, parseCodexAgentMessageText, subagentActivityFromEvent, } from './subagentActivity';
|
|
73
|
+
export type { CodexAgentMessageText, SubagentActivity, SubagentActivityKind, } from './subagentActivity';
|
|
70
74
|
export { getPricingCatalogInfo, registerModelPricing, clearRegisteredModelPricing, } from './modelInfo';
|
|
71
75
|
export type { PricingCatalogInfo, PricingCatalogSource, RegisterModelPricingOptions, } from './modelInfo';
|
|
72
76
|
export type { ProviderServiceSeverity, ProviderServiceComponent, ProviderServiceIncident, ProviderServiceStatusFailureReason, ObservedProviderServiceStatus, UnavailableProviderServiceStatus, ProviderServiceStatus, FetchProviderServiceStatusOptions, } from './providerServiceStatusTypes';
|