@agentex/agent 0.0.39 → 0.0.42
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 +50 -0
- package/README.md +26 -4
- package/dist/history/fs.d.ts.map +1 -1
- package/dist/history/fs.js +6 -12
- package/dist/history/fs.js.map +1 -1
- package/dist/providers/antigravity/execute.d.ts.map +1 -1
- package/dist/providers/antigravity/execute.js +9 -3
- package/dist/providers/antigravity/execute.js.map +1 -1
- package/dist/providers/antigravity/runtime.d.ts +4 -2
- package/dist/providers/antigravity/runtime.d.ts.map +1 -1
- package/dist/providers/antigravity/runtime.js +7 -4
- package/dist/providers/antigravity/runtime.js.map +1 -1
- package/dist/providers/antigravity/session.d.ts.map +1 -1
- package/dist/providers/antigravity/session.js +59 -17
- package/dist/providers/antigravity/session.js.map +1 -1
- package/dist/providers/claude/attach.d.ts.map +1 -1
- package/dist/providers/claude/attach.js +4 -6
- package/dist/providers/claude/attach.js.map +1 -1
- package/dist/providers/claude/transcript.d.ts.map +1 -1
- package/dist/providers/claude/transcript.js +9 -20
- package/dist/providers/claude/transcript.js.map +1 -1
- package/dist/providers/codex/attach.d.ts.map +1 -1
- package/dist/providers/codex/attach.js +4 -0
- package/dist/providers/codex/attach.js.map +1 -1
- package/dist/providers/codex/history.d.ts.map +1 -1
- package/dist/providers/codex/history.js +11 -0
- package/dist/providers/codex/history.js.map +1 -1
- package/dist/providers/codex/parse.d.ts +7 -0
- package/dist/providers/codex/parse.d.ts.map +1 -1
- package/dist/providers/codex/parse.js +56 -0
- package/dist/providers/codex/parse.js.map +1 -1
- package/dist/providers/codex/permissions.d.ts +40 -0
- package/dist/providers/codex/permissions.d.ts.map +1 -0
- package/dist/providers/codex/permissions.js +50 -0
- package/dist/providers/codex/permissions.js.map +1 -0
- package/dist/providers/codex/session.d.ts +34 -0
- package/dist/providers/codex/session.d.ts.map +1 -1
- package/dist/providers/codex/session.js +213 -20
- package/dist/providers/codex/session.js.map +1 -1
- package/dist/providers/codex/transcript-normalize.d.ts +12 -3
- package/dist/providers/codex/transcript-normalize.d.ts.map +1 -1
- package/dist/providers/codex/transcript-normalize.js +87 -10
- package/dist/providers/codex/transcript-normalize.js.map +1 -1
- package/dist/providers/codex/transcript.d.ts.map +1 -1
- package/dist/providers/codex/transcript.js +5 -10
- package/dist/providers/codex/transcript.js.map +1 -1
- package/dist/providers/codex/usage-scanner.d.ts.map +1 -1
- package/dist/providers/codex/usage-scanner.js +4 -6
- package/dist/providers/codex/usage-scanner.js.map +1 -1
- package/dist/utils/auth.d.ts.map +1 -1
- package/dist/utils/auth.js +12 -10
- package/dist/utils/auth.js.map +1 -1
- package/dist/utils/jsonl-lines.d.ts +35 -0
- package/dist/utils/jsonl-lines.d.ts.map +1 -0
- package/dist/utils/jsonl-lines.js +61 -0
- package/dist/utils/jsonl-lines.js.map +1 -0
- package/package.json +1 -1
- package/src/history/fs.ts +6 -12
- package/src/providers/antigravity/execute.ts +10 -3
- package/src/providers/antigravity/runtime.ts +7 -4
- package/src/providers/antigravity/session.ts +59 -18
- package/src/providers/claude/attach.ts +4 -6
- package/src/providers/claude/transcript.ts +9 -22
- package/src/providers/codex/attach.ts +4 -0
- package/src/providers/codex/history.ts +11 -0
- package/src/providers/codex/parse.ts +59 -0
- package/src/providers/codex/permissions.ts +61 -0
- package/src/providers/codex/session.ts +238 -19
- package/src/providers/codex/transcript-normalize.ts +85 -10
- package/src/providers/codex/transcript.ts +5 -11
- package/src/providers/codex/usage-scanner.ts +4 -7
- package/src/utils/auth.ts +12 -11
- package/src/utils/jsonl-lines.ts +80 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line splitting for JSONL files on disk.
|
|
3
|
+
*
|
|
4
|
+
* `node:readline` also breaks lines at U+2028 (LINE SEPARATOR), U+2029
|
|
5
|
+
* (PARAGRAPH SEPARATOR) and a lone `\r`. JSON allows U+2028/U+2029 unescaped
|
|
6
|
+
* inside strings, and both `JSON.stringify` (Claude Code) and serde_json
|
|
7
|
+
* (Codex) write them raw, typically in text copied from web pages. readline
|
|
8
|
+
* cuts such a record in two, both halves fail to parse, and the record
|
|
9
|
+
* silently disappears. Every byte offset after it also drifts by two bytes
|
|
10
|
+
* per separator, so a resume offset can land mid-record.
|
|
11
|
+
*
|
|
12
|
+
* {@link readJsonlLines} splits on `\n` only, drops the `\r` of a `\r\n`
|
|
13
|
+
* ending, and reports exact byte offsets.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface JsonlLine {
|
|
17
|
+
/** Line text without its `\n` or `\r\n` terminator. */
|
|
18
|
+
text: string;
|
|
19
|
+
/** Byte offset of the line's first byte. */
|
|
20
|
+
start: number;
|
|
21
|
+
/**
|
|
22
|
+
* Byte offset just past the line's `\n`, which is where the next line
|
|
23
|
+
* starts. For a final line with no `\n`, the end of the file.
|
|
24
|
+
*/
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const NEWLINE = 0x0a;
|
|
29
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
30
|
+
|
|
31
|
+
function decodeLine(bytes: Buffer): string {
|
|
32
|
+
const length = bytes.length > 0 && bytes[bytes.length - 1] === CARRIAGE_RETURN
|
|
33
|
+
? bytes.length - 1
|
|
34
|
+
: bytes.length;
|
|
35
|
+
return bytes.toString("utf8", 0, length);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Yield the lines of a byte stream, typically `createReadStream(path, { start })`
|
|
40
|
+
* opened without an encoding. `startOffset` is the stream's starting byte
|
|
41
|
+
* offset in the file, so reported offsets are file offsets.
|
|
42
|
+
*
|
|
43
|
+
* Splitting happens on bytes before decoding. A `\n` byte never occurs inside
|
|
44
|
+
* a multi-byte UTF-8 sequence, so no character is split across lines.
|
|
45
|
+
*/
|
|
46
|
+
export async function* readJsonlLines(
|
|
47
|
+
input: AsyncIterable<Buffer | string>,
|
|
48
|
+
startOffset = 0,
|
|
49
|
+
): AsyncGenerator<JsonlLine> {
|
|
50
|
+
let pending: Buffer[] = [];
|
|
51
|
+
let pendingBytes = 0;
|
|
52
|
+
let lineStart = startOffset;
|
|
53
|
+
|
|
54
|
+
for await (const value of input) {
|
|
55
|
+
const chunk = typeof value === "string" ? Buffer.from(value, "utf8") : value;
|
|
56
|
+
let from = 0;
|
|
57
|
+
let newline = chunk.indexOf(NEWLINE, from);
|
|
58
|
+
while (newline !== -1) {
|
|
59
|
+
const piece = chunk.subarray(from, newline);
|
|
60
|
+
const bytes = pendingBytes > 0 ? Buffer.concat([...pending, piece], pendingBytes + piece.length) : piece;
|
|
61
|
+
const end = lineStart + bytes.length + 1;
|
|
62
|
+
yield { text: decodeLine(bytes), start: lineStart, end };
|
|
63
|
+
lineStart = end;
|
|
64
|
+
pending = [];
|
|
65
|
+
pendingBytes = 0;
|
|
66
|
+
from = newline + 1;
|
|
67
|
+
newline = chunk.indexOf(NEWLINE, from);
|
|
68
|
+
}
|
|
69
|
+
if (from < chunk.length) {
|
|
70
|
+
const tail = chunk.subarray(from);
|
|
71
|
+
pending.push(tail);
|
|
72
|
+
pendingBytes += tail.length;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (pendingBytes > 0) {
|
|
77
|
+
const bytes = Buffer.concat(pending, pendingBytes);
|
|
78
|
+
yield { text: decodeLine(bytes), start: lineStart, end: lineStart + bytes.length };
|
|
79
|
+
}
|
|
80
|
+
}
|