@songsid/agend 2.1.12-beta.8 → 2.1.12-beta.9
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/dist/daemon.d.ts +16 -1
- package/dist/daemon.js +144 -43
- package/dist/daemon.js.map +1 -1
- package/dist/kiro-db-reader.d.ts +65 -0
- package/dist/kiro-db-reader.js +258 -0
- package/dist/kiro-db-reader.js.map +1 -0
- package/dist/kiro-transcript-lane.d.ts +56 -0
- package/dist/kiro-transcript-lane.js +141 -0
- package/dist/kiro-transcript-lane.js.map +1 -0
- package/dist/kiro-transcript-worker.d.ts +1 -0
- package/dist/kiro-transcript-worker.js +28 -0
- package/dist/kiro-transcript-worker.js.map +1 -0
- package/dist/transcript-delta-reader.d.ts +28 -0
- package/dist/transcript-delta-reader.js +148 -0
- package/dist/transcript-delta-reader.js.map +1 -0
- package/dist/transcript-monitor.d.ts +2 -0
- package/dist/transcript-monitor.js +19 -3
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-sources.d.ts +12 -47
- package/dist/transcript-sources.js +54 -235
- package/dist/transcript-sources.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #1379: read a CLI transcript forward from a delivery's checkpoint, looking for that delivery's own marker, in looks
|
|
3
|
+
* that are bounded in bytes and in time — because the submission proof that uses it polls every 250 ms while holding
|
|
4
|
+
* the pane lock and the delivery lane:
|
|
5
|
+
* - one look reads at most TRANSCRIPT_PROOF_READ.chunkBytes past where the previous completed look stopped, and only
|
|
6
|
+
* complete lines are decoded, each held to maxLineBytes first (a longer one is skipped whole and proves nothing);
|
|
7
|
+
* - one look settles within lookBudgetMs. A read that has not finished by then is abandoned: its result, when it does
|
|
8
|
+
* come, is dropped whole (neither its bytes nor its verdict are applied), and while it is still outstanding the next
|
|
9
|
+
* look reports "pending" rather than starting a second read.
|
|
10
|
+
* Positive only: the verdict is this delivery's exact marker in a consumed or queued shape, or nothing.
|
|
11
|
+
*/
|
|
12
|
+
import { open, stat } from "node:fs/promises";
|
|
13
|
+
import { transcriptDeltaDeliveryMarker } from "./delivery-reconciliation.js";
|
|
14
|
+
export const TRANSCRIPT_PROOF_READ = {
|
|
15
|
+
/** Bytes one look reads past the reader's position. */
|
|
16
|
+
chunkBytes: 256 * 1024,
|
|
17
|
+
/** A line longer than this (without its newline) is never decoded: skipped. */
|
|
18
|
+
maxLineBytes: 256 * 1024,
|
|
19
|
+
/** A look settles within this; a slower read is abandoned and its late result dropped. */
|
|
20
|
+
lookBudgetMs: 250,
|
|
21
|
+
};
|
|
22
|
+
export class TranscriptDeltaReader {
|
|
23
|
+
path;
|
|
24
|
+
backend;
|
|
25
|
+
deliveryId;
|
|
26
|
+
position;
|
|
27
|
+
carry = Buffer.alloc(0);
|
|
28
|
+
skippingLine = false;
|
|
29
|
+
inFlight = false;
|
|
30
|
+
constructor(path, offset, backend, deliveryId) {
|
|
31
|
+
this.path = path;
|
|
32
|
+
this.backend = backend;
|
|
33
|
+
this.deliveryId = deliveryId;
|
|
34
|
+
this.position = offset;
|
|
35
|
+
}
|
|
36
|
+
/** Where the next look reads from (tests). */
|
|
37
|
+
get readPosition() { return this.position; }
|
|
38
|
+
/** One bounded look. Never throws. */
|
|
39
|
+
async look() {
|
|
40
|
+
if (this.inFlight)
|
|
41
|
+
return "pending";
|
|
42
|
+
this.inFlight = true;
|
|
43
|
+
let abandoned = false;
|
|
44
|
+
let timer;
|
|
45
|
+
const read = this.readChunk().finally(() => { this.inFlight = false; });
|
|
46
|
+
const budget = new Promise(resolve => {
|
|
47
|
+
timer = setTimeout(() => resolve("timeout"), TRANSCRIPT_PROOF_READ.lookBudgetMs);
|
|
48
|
+
timer.unref?.();
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
const got = await Promise.race([read, budget]);
|
|
52
|
+
if (got === "timeout") {
|
|
53
|
+
abandoned = true;
|
|
54
|
+
return "pending";
|
|
55
|
+
}
|
|
56
|
+
if (got === "unavailable")
|
|
57
|
+
return "unavailable";
|
|
58
|
+
if (got === null)
|
|
59
|
+
return "no-match";
|
|
60
|
+
this.position += got.length;
|
|
61
|
+
return this.scan(got) ?? "no-match";
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return "unavailable";
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
if (timer)
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
// An abandoned read's result is dropped whole when it lands: nothing above applied it.
|
|
70
|
+
if (abandoned)
|
|
71
|
+
read.catch(() => { });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** The next chunk past the position (null: nothing new), without touching the reader's state. */
|
|
75
|
+
async readChunk() {
|
|
76
|
+
let size;
|
|
77
|
+
try {
|
|
78
|
+
size = (await stat(this.path)).size;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return "unavailable";
|
|
82
|
+
}
|
|
83
|
+
if (size < this.position)
|
|
84
|
+
return "unavailable"; // truncated or replaced below the checkpoint
|
|
85
|
+
if (size === this.position)
|
|
86
|
+
return null;
|
|
87
|
+
const length = Math.min(TRANSCRIPT_PROOF_READ.chunkBytes, size - this.position);
|
|
88
|
+
let fh;
|
|
89
|
+
try {
|
|
90
|
+
fh = await open(this.path, "r");
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return "unavailable";
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const buffer = Buffer.alloc(length);
|
|
97
|
+
let read = 0;
|
|
98
|
+
while (read < length) {
|
|
99
|
+
const { bytesRead } = await fh.read(buffer, read, length - read, this.position + read);
|
|
100
|
+
if (bytesRead === 0)
|
|
101
|
+
break;
|
|
102
|
+
read += bytesRead;
|
|
103
|
+
}
|
|
104
|
+
return buffer.subarray(0, read);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return "unavailable";
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await fh.close().catch(() => { });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** The complete lines of this chunk (and the carried start of one), each within the cap, judged once. */
|
|
114
|
+
scan(chunk) {
|
|
115
|
+
let data = chunk;
|
|
116
|
+
if (this.skippingLine) {
|
|
117
|
+
const nl = data.indexOf(0x0a);
|
|
118
|
+
if (nl < 0)
|
|
119
|
+
return null;
|
|
120
|
+
data = data.subarray(nl + 1);
|
|
121
|
+
this.skippingLine = false;
|
|
122
|
+
}
|
|
123
|
+
const buffer = this.carry.length ? Buffer.concat([this.carry, data]) : data;
|
|
124
|
+
const lastNl = buffer.lastIndexOf(0x0a);
|
|
125
|
+
let found = null;
|
|
126
|
+
if (lastNl < 0) {
|
|
127
|
+
this.carry = buffer;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.carry = buffer.subarray(lastNl + 1);
|
|
131
|
+
const kept = [];
|
|
132
|
+
for (let start = 0; start <= lastNl;) {
|
|
133
|
+
const nl = buffer.indexOf(0x0a, start);
|
|
134
|
+
if (nl - start <= TRANSCRIPT_PROOF_READ.maxLineBytes)
|
|
135
|
+
kept.push(buffer.subarray(start, nl + 1));
|
|
136
|
+
start = nl + 1;
|
|
137
|
+
}
|
|
138
|
+
if (kept.length)
|
|
139
|
+
found = transcriptDeltaDeliveryMarker(Buffer.concat(kept).toString("utf8"), this.backend, this.deliveryId) ?? null;
|
|
140
|
+
}
|
|
141
|
+
if (this.carry.length > TRANSCRIPT_PROOF_READ.maxLineBytes) {
|
|
142
|
+
this.carry = Buffer.alloc(0);
|
|
143
|
+
this.skippingLine = true;
|
|
144
|
+
}
|
|
145
|
+
return found;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=transcript-delta-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-delta-reader.js","sourceRoot":"","sources":["../src/transcript-delta-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;A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AAK,CAAC,MAAM,GAAG,qBAAqB,CAAC,YAAY,EAAE,CAAC;YAC3D,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -21,6 +21,7 @@ export declare class TranscriptMonitor extends EventEmitter {
|
|
|
21
21
|
private pollTimer;
|
|
22
22
|
private offsetFile;
|
|
23
23
|
private polling;
|
|
24
|
+
private generation;
|
|
24
25
|
constructor(instanceDir: string, logger: Logger, source?: TranscriptSource | null);
|
|
25
26
|
private loadOffset;
|
|
26
27
|
private saveOffset;
|
|
@@ -32,6 +33,7 @@ export declare class TranscriptMonitor extends EventEmitter {
|
|
|
32
33
|
private _doPoll;
|
|
33
34
|
private processEntry;
|
|
34
35
|
startPolling(intervalMs?: number): void;
|
|
36
|
+
initialize(): Promise<void>;
|
|
35
37
|
stop(): void;
|
|
36
38
|
setTranscriptPath(path: string): void;
|
|
37
39
|
resetOffset(): void;
|
|
@@ -22,6 +22,7 @@ export class TranscriptMonitor extends EventEmitter {
|
|
|
22
22
|
pollTimer = null;
|
|
23
23
|
offsetFile;
|
|
24
24
|
polling = false; // reentry guard for pollIncrement
|
|
25
|
+
generation = 0;
|
|
25
26
|
constructor(instanceDir, logger, source = null) {
|
|
26
27
|
super();
|
|
27
28
|
this.instanceDir = instanceDir;
|
|
@@ -108,14 +109,26 @@ export class TranscriptMonitor extends EventEmitter {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
async pollSource() {
|
|
112
|
+
const generation = this.generation;
|
|
111
113
|
try {
|
|
112
114
|
const events = await this.source.poll();
|
|
113
|
-
|
|
115
|
+
if (generation !== this.generation)
|
|
116
|
+
return;
|
|
117
|
+
for (const use of events.toolUses) {
|
|
118
|
+
if (generation !== this.generation)
|
|
119
|
+
return;
|
|
114
120
|
this.emit("tool_use", use.name, use.input);
|
|
115
|
-
|
|
121
|
+
}
|
|
122
|
+
for (const result of events.toolResults) {
|
|
123
|
+
if (generation !== this.generation)
|
|
124
|
+
return;
|
|
116
125
|
this.emit("tool_result", result.name, undefined);
|
|
117
|
-
|
|
126
|
+
}
|
|
127
|
+
for (const text of events.assistantTexts) {
|
|
128
|
+
if (generation !== this.generation)
|
|
129
|
+
return;
|
|
118
130
|
this.emit("assistant_text", text);
|
|
131
|
+
}
|
|
119
132
|
}
|
|
120
133
|
catch (err) {
|
|
121
134
|
this.logger.debug({ err }, "TranscriptSource poll error");
|
|
@@ -196,7 +209,9 @@ export class TranscriptMonitor extends EventEmitter {
|
|
|
196
209
|
return;
|
|
197
210
|
this.pollTimer = setInterval(() => this.pollIncrement(), intervalMs);
|
|
198
211
|
}
|
|
212
|
+
async initialize() { await this.source?.initialize?.(); }
|
|
199
213
|
stop() {
|
|
214
|
+
this.generation++;
|
|
200
215
|
if (this.pollTimer) {
|
|
201
216
|
clearInterval(this.pollTimer);
|
|
202
217
|
this.pollTimer = null;
|
|
@@ -213,6 +228,7 @@ export class TranscriptMonitor extends EventEmitter {
|
|
|
213
228
|
this.transcriptPath = path;
|
|
214
229
|
}
|
|
215
230
|
resetOffset() {
|
|
231
|
+
this.generation++;
|
|
216
232
|
this.byteOffset = 0;
|
|
217
233
|
this.transcriptPath = null;
|
|
218
234
|
this.source?.reset();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-monitor.js","sourceRoot":"","sources":["../src/transcript-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;;;;;;;GAUG;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EAAE,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type RolloutIndex } from "./rollout-index.js";
|
|
2
|
+
import { type KiroDbLane } from "./kiro-transcript-lane.js";
|
|
3
|
+
export { extractKiroAssistantStrings } from "./kiro-db-reader.js";
|
|
2
4
|
export interface ToolUseEvent {
|
|
3
5
|
name: string;
|
|
4
6
|
input: unknown;
|
|
@@ -19,6 +21,8 @@ export interface TranscriptCheckpoint {
|
|
|
19
21
|
export interface TranscriptSource {
|
|
20
22
|
/** Read events that appeared since the previous call. Invoked serially. */
|
|
21
23
|
poll(): Promise<TranscriptEvents>;
|
|
24
|
+
/** Asynchronous baseline barrier, awaited before startup becomes accepting. */
|
|
25
|
+
initialize?(): Promise<void>;
|
|
22
26
|
/** Forget the current position; the next poll re-resolves and re-baselines. */
|
|
23
27
|
reset(): void;
|
|
24
28
|
/** Optional durable-delivery checkpoint taken immediately before pane paste. */
|
|
@@ -103,8 +107,6 @@ export type KiroConversationRead = {
|
|
|
103
107
|
export declare function readKiroConversationStatus(dbPath: string, workingDirectory: string,
|
|
104
108
|
/** False = metadata only (no value read, no JSON parse): the poll fast path. */
|
|
105
109
|
includeHistory?: boolean): KiroConversationRead;
|
|
106
|
-
/** Strings a kiro assistant turn can carry: plain response + tool-call text. */
|
|
107
|
-
export declare function extractKiroAssistantStrings(entry: unknown): string[];
|
|
108
110
|
/**
|
|
109
111
|
* Follows the newest Kiro conversation whose cwd matches this instance.
|
|
110
112
|
* Kiro 2.19 moved primary conversations to conversations_v2 in data.sqlite3;
|
|
@@ -114,57 +116,20 @@ export declare class KiroSessionSource implements TranscriptSource {
|
|
|
114
116
|
private workingDirectory;
|
|
115
117
|
private sessionsDir;
|
|
116
118
|
private dbPath;
|
|
119
|
+
private lane;
|
|
117
120
|
private currentFile;
|
|
118
121
|
private byteOffset;
|
|
119
122
|
private readonly createdAt;
|
|
120
|
-
private
|
|
121
|
-
private
|
|
122
|
-
private
|
|
123
|
-
private
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
* and opening it per poll, for every kiro instance every 2 s, ran on the
|
|
128
|
-
* fleet's event loop.
|
|
129
|
-
*/
|
|
130
|
-
private db;
|
|
131
|
-
/** The store file the handle was opened on; a replaced file is reopened. */
|
|
132
|
-
private dbIno;
|
|
133
|
-
private newestRowStmt;
|
|
134
|
-
private historyStmt;
|
|
135
|
-
private createdAtStmt;
|
|
136
|
-
constructor(workingDirectory: string, sessionsDir?: string, now?: number, dbPath?: string);
|
|
123
|
+
private generation;
|
|
124
|
+
private cursor;
|
|
125
|
+
private lease;
|
|
126
|
+
private ready;
|
|
127
|
+
private needsBaseline;
|
|
128
|
+
constructor(workingDirectory: string, sessionsDir?: string, now?: number, dbPath?: string, lane?: KiroDbLane);
|
|
129
|
+
initialize(): Promise<void>;
|
|
137
130
|
reset(): void;
|
|
138
|
-
/** Resolved once per baseline: realpath is a syscall, and this runs every poll. */
|
|
139
|
-
private dbKeys;
|
|
140
|
-
private workingDirectoryKeys;
|
|
141
131
|
close(): void;
|
|
142
|
-
/** The shared handle, opened on first use; null while the store is absent. */
|
|
143
|
-
private openDb;
|
|
144
|
-
/**
|
|
145
|
-
* The newest conversation for this workspace and its change signal. The
|
|
146
|
-
* size is `octet_length`, which SQLite answers from the record header:
|
|
147
|
-
* `length()` on TEXT counts characters, so it read every conversation in
|
|
148
|
-
* full on every poll (#1048) — 56 ms a round across 13 real kiro
|
|
149
|
-
* workspaces, against 0.05 ms for this. The size stays in the signature
|
|
150
|
-
* because two saves inside one millisecond share an `updated_at`.
|
|
151
|
-
* No `created_at` either: it is stored after `value`, so reading it walks
|
|
152
|
-
* the whole conversation too (9 ms for one 18 MB row); `updated_at` comes
|
|
153
|
-
* from the key index. `conversationCreatedAt()` reads it on a switch.
|
|
154
|
-
*/
|
|
155
|
-
private newestDbRow;
|
|
156
|
-
/** When a conversation began; read only when the poll switches to it. */
|
|
157
|
-
private conversationCreatedAt;
|
|
158
|
-
/** The whole history, read only when the signature says it changed. */
|
|
159
|
-
private readDbHistory;
|
|
160
|
-
/**
|
|
161
|
-
* Kiro 2.19 moved primary conversations into data.sqlite3. Snapshot the
|
|
162
|
-
* active row synchronously at monitor creation so its existing history is
|
|
163
|
-
* never replayed as live tool progress.
|
|
164
|
-
*/
|
|
165
|
-
private snapshotDbBaseline;
|
|
166
132
|
private pollDb;
|
|
167
|
-
private pollDbSync;
|
|
168
133
|
/**
|
|
169
134
|
* What each session's metadata said, keyed by file and valid for the mtime/size it was
|
|
170
135
|
* read at (#1161): the fallback used to re-read and re-parse EVERY session's JSON on every
|