poe-code 3.0.308 → 3.0.309

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/index.js CHANGED
@@ -76217,7 +76217,16 @@ async function* followManagedLogs(options) {
76217
76217
  throw new Error(`Invalid managed log poll interval: ${pollIntervalMs}`);
76218
76218
  }
76219
76219
  const cursor2 = createFollowLogCursor();
76220
- await primeFollowCursor(fs28, options.baseDir, options.id, stream, cursor2);
76220
+ const initialLines = options.lines === void 0 ? [] : await readInitialFollowLogWindow(fs28, options.baseDir, options.id, stream, options.lines, cursor2);
76221
+ if (options.lines === void 0) {
76222
+ await primeFollowCursor(fs28, options.baseDir, options.id, stream, cursor2);
76223
+ }
76224
+ for (const line of initialLines) {
76225
+ if (options.signal?.aborted) {
76226
+ return;
76227
+ }
76228
+ yield line;
76229
+ }
76221
76230
  while (!options.signal?.aborted) {
76222
76231
  await sleep4(pollIntervalMs);
76223
76232
  if (options.signal?.aborted) {
@@ -76237,6 +76246,30 @@ function createFollowLogCursor() {
76237
76246
  remainder: ""
76238
76247
  };
76239
76248
  }
76249
+ async function readInitialFollowLogWindow(fs28, baseDir, id, stream, lines, cursor2) {
76250
+ assertValidLogLineCount(lines);
76251
+ const stat33 = await statFollowedLog(fs28, baseDir, id, stream);
76252
+ resetFollowCursor(cursor2, stat33?.fileId ?? null);
76253
+ if (stat33 === null) {
76254
+ return [];
76255
+ }
76256
+ const bytes = await readFollowedLogBytes(
76257
+ fs28,
76258
+ resolveCurrentLogPath(baseDir, id, stream),
76259
+ 0
76260
+ );
76261
+ cursor2.offset = bytes.byteLength;
76262
+ const allLines = consumeFollowedLogBytes(cursor2, bytes);
76263
+ if (lines === 0) {
76264
+ return [];
76265
+ }
76266
+ return allLines.slice(-lines);
76267
+ }
76268
+ function assertValidLogLineCount(lines) {
76269
+ if (!Number.isFinite(lines) || !Number.isInteger(lines) || lines < 0) {
76270
+ throw new Error("lines must be a finite non-negative integer");
76271
+ }
76272
+ }
76240
76273
  async function primeFollowCursor(fs28, baseDir, id, stream, cursor2) {
76241
76274
  const stat33 = await statFollowedLog(fs28, baseDir, id, stream);
76242
76275
  resetFollowCursor(cursor2, stat33?.fileId ?? null);
@@ -137188,7 +137221,7 @@ var init_package2 = __esm({
137188
137221
  "package.json"() {
137189
137222
  package_default2 = {
137190
137223
  name: "poe-code",
137191
- version: "3.0.308",
137224
+ version: "3.0.309",
137192
137225
  description: "CLI tool to configure Poe API for developer workflows.",
137193
137226
  type: "module",
137194
137227
  main: "./dist/index.js",