observal-pi 1.4.3 → 1.5.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/extensions/observal.ts +24 -13
- package/package.json +1 -1
package/extensions/observal.ts
CHANGED
|
@@ -348,19 +348,30 @@ export default function (pi: ExtensionAPI) {
|
|
|
348
348
|
.filter((l) => l.trim());
|
|
349
349
|
|
|
350
350
|
if (lines.length > 0) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
351
|
+
let pushOk = true;
|
|
352
|
+
for (let offset = 0; offset < lines.length; offset += MAX_LINES_PER_CHUNK) {
|
|
353
|
+
const chunk = lines.slice(offset, offset + MAX_LINES_PER_CHUNK);
|
|
354
|
+
const isLastChunk = offset + MAX_LINES_PER_CHUNK >= lines.length;
|
|
355
|
+
const payload = JSON.stringify({
|
|
356
|
+
session_id: sessionId,
|
|
357
|
+
ide: "pi",
|
|
358
|
+
agent_id: s.config?.agent_id ?? null,
|
|
359
|
+
agent_version: s.config?.agent_version ?? null,
|
|
360
|
+
lines: chunk,
|
|
361
|
+
start_offset: entry.line_count + offset,
|
|
362
|
+
hook_event: "CrashRecovery",
|
|
363
|
+
final: isLastChunk,
|
|
364
|
+
...(isLastChunk
|
|
365
|
+
? {
|
|
366
|
+
total_line_count: entry.line_count + lines.length,
|
|
367
|
+
total_offset: fileStat.size,
|
|
368
|
+
}
|
|
369
|
+
: {}),
|
|
370
|
+
});
|
|
371
|
+
const ok = await postWithTimeout(s.config!, "/api/v1/ingest/session", payload);
|
|
372
|
+
if (!ok) { pushOk = false; break; }
|
|
373
|
+
}
|
|
374
|
+
if (!pushOk) continue; // skip finalization, retry next startup
|
|
364
375
|
}
|
|
365
376
|
|
|
366
377
|
writeCursor(sessionId, fileStat.size, entry.line_count + lines.length, true);
|