@akasecurity/ai-tc-codex 0.9.23 → 0.9.24

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.
@@ -8771,7 +8771,11 @@ var ListFindingTypesQuery = object({
8771
8771
  // and so is not bounded by what any page happens to hold.
8772
8772
  includeId: string2().optional(),
8773
8773
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8774
- cursor: string2().optional()
8774
+ cursor: string2().optional(),
8775
+ // A row position to read from, for jumping to a page instead of stepping to
8776
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8777
+ // from wherever it lands.
8778
+ offset: coerce_exports.number().int().min(0).optional()
8775
8779
  });
8776
8780
  var ListFindingTypesResponse = object({
8777
8781
  totals: object({
@@ -8852,7 +8856,11 @@ var ListFindingInstancesQuery = object({
8852
8856
  sessionId: string2().optional(),
8853
8857
  from: iso_exports.datetime().optional(),
8854
8858
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8855
- cursor: string2().optional()
8859
+ cursor: string2().optional(),
8860
+ // A row position to read from, for jumping to a page instead of stepping to
8861
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8862
+ // from wherever it lands.
8863
+ offset: coerce_exports.number().int().min(0).optional()
8856
8864
  });
8857
8865
  var ListFindingInstancesResponse = object({
8858
8866
  // Instances matching the filters across the whole scope, not just this
@@ -8924,7 +8932,11 @@ var ListFindingLocationsQuery = object({
8924
8932
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8925
8933
  includeId: string2().optional(),
8926
8934
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8927
- cursor: string2().optional()
8935
+ cursor: string2().optional(),
8936
+ // A row position to read from, for jumping to a page instead of stepping to
8937
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8938
+ // from wherever it lands.
8939
+ offset: coerce_exports.number().int().min(0).optional()
8928
8940
  });
8929
8941
  var ListFindingLocationsResponse = object({
8930
8942
  totals: object({
@@ -11499,7 +11511,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11499
11511
  var ListVaultInventoryQuery = object({
11500
11512
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11501
11513
  // Opaque; names the last row of the page just served.
11502
- cursor: string2().optional()
11514
+ cursor: string2().optional(),
11515
+ // A row position to read from, for jumping to a page instead of stepping to
11516
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11517
+ // from wherever it lands.
11518
+ offset: coerce_exports.number().int().min(0).optional()
11503
11519
  });
11504
11520
  var ListVaultInventoryResponse = object({
11505
11521
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11511,7 +11527,11 @@ var ListVaultInventoryResponse = object({
11511
11527
  });
11512
11528
  var ListVaultReuseQuery = object({
11513
11529
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11514
- cursor: string2().optional()
11530
+ cursor: string2().optional(),
11531
+ // A row position to read from, for jumping to a page instead of stepping to
11532
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11533
+ // from wherever it lands.
11534
+ offset: coerce_exports.number().int().min(0).optional()
11515
11535
  });
11516
11536
  var ListVaultReuseResponse = object({
11517
11537
  // Reused values across the whole store — the number the section's claim
@@ -11527,9 +11547,15 @@ var ListVaultDerefsQuery = object({
11527
11547
  // over a Server Action, which preserves the type, never as a URL param.
11528
11548
  includeBatched: boolean2().optional(),
11529
11549
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11530
- cursor: string2().optional()
11550
+ cursor: string2().optional(),
11551
+ // A row position to read from, for jumping to a page instead of stepping to
11552
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11553
+ // from wherever it lands.
11554
+ offset: coerce_exports.number().int().min(0).optional()
11531
11555
  });
11532
11556
  var ListVaultDerefsResponse = object({
11557
+ // Rows this filter selects across the whole trail, not just this page.
11558
+ totals: object({ derefs: number2().int().nonnegative() }),
11533
11559
  items: array(VaultDeref),
11534
11560
  nextCursor: string2().nullable(),
11535
11561
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -19399,7 +19425,7 @@ var SqliteFindingsRepository = class {
19399
19425
  };
19400
19426
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
19401
19427
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
19402
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
19428
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
19403
19429
  const page = sorted.slice(start, start + limit);
19404
19430
  const lastOnPage = page.at(-1);
19405
19431
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -19493,7 +19519,7 @@ var SqliteFindingsRepository = class {
19493
19519
  accumulator.add(row);
19494
19520
  if (!matchesInstanceFilters(row, opts)) continue;
19495
19521
  total += 1;
19496
- if (!isPastCursor(row)) continue;
19522
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
19497
19523
  if (items.length < limit) {
19498
19524
  items.push(toInstanceDetail(row));
19499
19525
  last = row;
@@ -19582,7 +19608,7 @@ var SqliteFindingsRepository = class {
19582
19608
  }
19583
19609
  }
19584
19610
  sorted.sort(compareLocationOrder);
19585
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
19611
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
19586
19612
  const page = sorted.slice(start, start + limit);
19587
19613
  const lastOnPage = page.at(-1);
19588
19614
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -22210,6 +22236,9 @@ function pageLimit(requested, fallback) {
22210
22236
  if (requested === void 0) return fallback;
22211
22237
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
22212
22238
  }
22239
+ function pageOffset(requested) {
22240
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
22241
+ }
22213
22242
  function encodeReuseCursor(payload) {
22214
22243
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
22215
22244
  }
@@ -22557,7 +22586,8 @@ var SqliteSecretVaultRepository = class {
22557
22586
  */
22558
22587
  listInventory(query = {}, now = Date.now()) {
22559
22588
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22560
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22589
+ const offset = pageOffset(query.offset);
22590
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22561
22591
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
22562
22592
  const rows = allRows(
22563
22593
  this.db.prepare(
@@ -22571,11 +22601,12 @@ var SqliteSecretVaultRepository = class {
22571
22601
  FROM secret_vault v
22572
22602
  ${where}
22573
22603
  ORDER BY v.last_seen DESC, v.pointer_id DESC
22574
- LIMIT :limit`
22604
+ LIMIT :limit OFFSET :offset`
22575
22605
  ),
22576
22606
  bindParams({
22577
22607
  now,
22578
22608
  limit: limit + 1,
22609
+ offset,
22579
22610
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
22580
22611
  })
22581
22612
  );
@@ -22599,7 +22630,8 @@ var SqliteSecretVaultRepository = class {
22599
22630
  */
22600
22631
  listReuse(query = {}, now = Date.now()) {
22601
22632
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22602
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
22633
+ const offset = pageOffset(query.offset);
22634
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
22603
22635
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
22604
22636
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
22605
22637
  const rows = allRows(
@@ -22614,11 +22646,12 @@ var SqliteSecretVaultRepository = class {
22614
22646
  FROM secret_vault v
22615
22647
  WHERE ${REUSED_PREDICATE} ${after}
22616
22648
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
22617
- LIMIT :limit`
22649
+ LIMIT :limit OFFSET :offset`
22618
22650
  ),
22619
22651
  bindParams({
22620
22652
  now,
22621
22653
  limit: limit + 1,
22654
+ offset,
22622
22655
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
22623
22656
  })
22624
22657
  );
@@ -22643,7 +22676,8 @@ var SqliteSecretVaultRepository = class {
22643
22676
  */
22644
22677
  listDerefs(query = {}) {
22645
22678
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
22646
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22679
+ const offset = pageOffset(query.offset);
22680
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22647
22681
  const conditions = [];
22648
22682
  if (query.includeBatched !== true) {
22649
22683
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -22656,21 +22690,28 @@ var SqliteSecretVaultRepository = class {
22656
22690
  this.db.prepare(
22657
22691
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
22658
22692
  FROM secret_vault_deref ${where}
22659
- ORDER BY at DESC, id DESC LIMIT :limit`
22693
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
22660
22694
  ),
22661
22695
  bindParams({
22662
22696
  limit: limit + 1,
22697
+ offset,
22663
22698
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
22664
22699
  })
22665
22700
  );
22666
22701
  const hasMore = rows.length > limit;
22667
22702
  const page = hasMore ? rows.slice(0, limit) : rows;
22668
22703
  const last = page[page.length - 1];
22669
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
22670
- this.db,
22671
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
22672
- );
22704
+ const counts = getRow(
22705
+ this.db.prepare(
22706
+ `SELECT count(*) AS total,
22707
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
22708
+ FROM secret_vault_deref`
22709
+ )
22710
+ ) ?? { total: 0, hidden: 0 };
22711
+ const includeBatched = query.includeBatched === true;
22712
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
22673
22713
  return {
22714
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
22674
22715
  items: page.map((r) => ({
22675
22716
  id: r.id,
22676
22717
  pointerId: r.pointer_id,
@@ -8777,7 +8777,11 @@ var ListFindingTypesQuery = object({
8777
8777
  // and so is not bounded by what any page happens to hold.
8778
8778
  includeId: string2().optional(),
8779
8779
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8780
- cursor: string2().optional()
8780
+ cursor: string2().optional(),
8781
+ // A row position to read from, for jumping to a page instead of stepping to
8782
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8783
+ // from wherever it lands.
8784
+ offset: coerce_exports.number().int().min(0).optional()
8781
8785
  });
8782
8786
  var ListFindingTypesResponse = object({
8783
8787
  totals: object({
@@ -8858,7 +8862,11 @@ var ListFindingInstancesQuery = object({
8858
8862
  sessionId: string2().optional(),
8859
8863
  from: iso_exports.datetime().optional(),
8860
8864
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8861
- cursor: string2().optional()
8865
+ cursor: string2().optional(),
8866
+ // A row position to read from, for jumping to a page instead of stepping to
8867
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8868
+ // from wherever it lands.
8869
+ offset: coerce_exports.number().int().min(0).optional()
8862
8870
  });
8863
8871
  var ListFindingInstancesResponse = object({
8864
8872
  // Instances matching the filters across the whole scope, not just this
@@ -8930,7 +8938,11 @@ var ListFindingLocationsQuery = object({
8930
8938
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8931
8939
  includeId: string2().optional(),
8932
8940
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8933
- cursor: string2().optional()
8941
+ cursor: string2().optional(),
8942
+ // A row position to read from, for jumping to a page instead of stepping to
8943
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8944
+ // from wherever it lands.
8945
+ offset: coerce_exports.number().int().min(0).optional()
8934
8946
  });
8935
8947
  var ListFindingLocationsResponse = object({
8936
8948
  totals: object({
@@ -11567,7 +11579,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11567
11579
  var ListVaultInventoryQuery = object({
11568
11580
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11569
11581
  // Opaque; names the last row of the page just served.
11570
- cursor: string2().optional()
11582
+ cursor: string2().optional(),
11583
+ // A row position to read from, for jumping to a page instead of stepping to
11584
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11585
+ // from wherever it lands.
11586
+ offset: coerce_exports.number().int().min(0).optional()
11571
11587
  });
11572
11588
  var ListVaultInventoryResponse = object({
11573
11589
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11579,7 +11595,11 @@ var ListVaultInventoryResponse = object({
11579
11595
  });
11580
11596
  var ListVaultReuseQuery = object({
11581
11597
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11582
- cursor: string2().optional()
11598
+ cursor: string2().optional(),
11599
+ // A row position to read from, for jumping to a page instead of stepping to
11600
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11601
+ // from wherever it lands.
11602
+ offset: coerce_exports.number().int().min(0).optional()
11583
11603
  });
11584
11604
  var ListVaultReuseResponse = object({
11585
11605
  // Reused values across the whole store — the number the section's claim
@@ -11595,9 +11615,15 @@ var ListVaultDerefsQuery = object({
11595
11615
  // over a Server Action, which preserves the type, never as a URL param.
11596
11616
  includeBatched: boolean2().optional(),
11597
11617
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11598
- cursor: string2().optional()
11618
+ cursor: string2().optional(),
11619
+ // A row position to read from, for jumping to a page instead of stepping to
11620
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11621
+ // from wherever it lands.
11622
+ offset: coerce_exports.number().int().min(0).optional()
11599
11623
  });
11600
11624
  var ListVaultDerefsResponse = object({
11625
+ // Rows this filter selects across the whole trail, not just this page.
11626
+ totals: object({ derefs: number2().int().nonnegative() }),
11601
11627
  items: array(VaultDeref),
11602
11628
  nextCursor: string2().nullable(),
11603
11629
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -20508,7 +20534,7 @@ var SqliteFindingsRepository = class {
20508
20534
  };
20509
20535
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
20510
20536
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
20511
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
20537
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
20512
20538
  const page = sorted.slice(start, start + limit);
20513
20539
  const lastOnPage = page.at(-1);
20514
20540
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -20602,7 +20628,7 @@ var SqliteFindingsRepository = class {
20602
20628
  accumulator.add(row);
20603
20629
  if (!matchesInstanceFilters(row, opts)) continue;
20604
20630
  total += 1;
20605
- if (!isPastCursor(row)) continue;
20631
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
20606
20632
  if (items.length < limit) {
20607
20633
  items.push(toInstanceDetail(row));
20608
20634
  last = row;
@@ -20691,7 +20717,7 @@ var SqliteFindingsRepository = class {
20691
20717
  }
20692
20718
  }
20693
20719
  sorted.sort(compareLocationOrder);
20694
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
20720
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
20695
20721
  const page = sorted.slice(start, start + limit);
20696
20722
  const lastOnPage = page.at(-1);
20697
20723
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -23319,6 +23345,9 @@ function pageLimit(requested, fallback) {
23319
23345
  if (requested === void 0) return fallback;
23320
23346
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
23321
23347
  }
23348
+ function pageOffset(requested) {
23349
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
23350
+ }
23322
23351
  function encodeReuseCursor(payload) {
23323
23352
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
23324
23353
  }
@@ -23666,7 +23695,8 @@ var SqliteSecretVaultRepository = class {
23666
23695
  */
23667
23696
  listInventory(query = {}, now = Date.now()) {
23668
23697
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23669
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23698
+ const offset = pageOffset(query.offset);
23699
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23670
23700
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
23671
23701
  const rows = allRows(
23672
23702
  this.db.prepare(
@@ -23680,11 +23710,12 @@ var SqliteSecretVaultRepository = class {
23680
23710
  FROM secret_vault v
23681
23711
  ${where}
23682
23712
  ORDER BY v.last_seen DESC, v.pointer_id DESC
23683
- LIMIT :limit`
23713
+ LIMIT :limit OFFSET :offset`
23684
23714
  ),
23685
23715
  bindParams({
23686
23716
  now,
23687
23717
  limit: limit + 1,
23718
+ offset,
23688
23719
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
23689
23720
  })
23690
23721
  );
@@ -23708,7 +23739,8 @@ var SqliteSecretVaultRepository = class {
23708
23739
  */
23709
23740
  listReuse(query = {}, now = Date.now()) {
23710
23741
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23711
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
23742
+ const offset = pageOffset(query.offset);
23743
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
23712
23744
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
23713
23745
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
23714
23746
  const rows = allRows(
@@ -23723,11 +23755,12 @@ var SqliteSecretVaultRepository = class {
23723
23755
  FROM secret_vault v
23724
23756
  WHERE ${REUSED_PREDICATE} ${after}
23725
23757
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
23726
- LIMIT :limit`
23758
+ LIMIT :limit OFFSET :offset`
23727
23759
  ),
23728
23760
  bindParams({
23729
23761
  now,
23730
23762
  limit: limit + 1,
23763
+ offset,
23731
23764
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
23732
23765
  })
23733
23766
  );
@@ -23752,7 +23785,8 @@ var SqliteSecretVaultRepository = class {
23752
23785
  */
23753
23786
  listDerefs(query = {}) {
23754
23787
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
23755
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23788
+ const offset = pageOffset(query.offset);
23789
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23756
23790
  const conditions = [];
23757
23791
  if (query.includeBatched !== true) {
23758
23792
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -23765,21 +23799,28 @@ var SqliteSecretVaultRepository = class {
23765
23799
  this.db.prepare(
23766
23800
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
23767
23801
  FROM secret_vault_deref ${where}
23768
- ORDER BY at DESC, id DESC LIMIT :limit`
23802
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
23769
23803
  ),
23770
23804
  bindParams({
23771
23805
  limit: limit + 1,
23806
+ offset,
23772
23807
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
23773
23808
  })
23774
23809
  );
23775
23810
  const hasMore = rows.length > limit;
23776
23811
  const page = hasMore ? rows.slice(0, limit) : rows;
23777
23812
  const last = page[page.length - 1];
23778
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
23779
- this.db,
23780
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
23781
- );
23813
+ const counts = getRow(
23814
+ this.db.prepare(
23815
+ `SELECT count(*) AS total,
23816
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
23817
+ FROM secret_vault_deref`
23818
+ )
23819
+ ) ?? { total: 0, hidden: 0 };
23820
+ const includeBatched = query.includeBatched === true;
23821
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
23782
23822
  return {
23823
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
23783
23824
  items: page.map((r) => ({
23784
23825
  id: r.id,
23785
23826
  pointerId: r.pointer_id,
@@ -30992,8 +31033,25 @@ function bundledMaskingRules() {
30992
31033
  return ensureBundledPacks() ? getLoadedRules() : null;
30993
31034
  }
30994
31035
 
31036
+ // ../../packages/plugin-sdk/src/regular-file.ts
31037
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
31038
+ function notRegularFile(path) {
31039
+ return `not a regular file: ${path}`;
31040
+ }
31041
+ function readRegularFile(path, maxBytes) {
31042
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
31043
+ try {
31044
+ const stat2 = fstatSync(fd);
31045
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
31046
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
31047
+ return readFileSync16(fd, "utf8");
31048
+ } finally {
31049
+ closeSync2(fd);
31050
+ }
31051
+ }
31052
+
30995
31053
  // ../../packages/plugin-sdk/src/repo.ts
30996
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
31054
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30997
31055
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30998
31056
  function remoteWithoutCredentials(remote) {
30999
31057
  const withoutInfo = withoutUserinfo(remote);
@@ -31082,9 +31140,10 @@ function resolveGitContext(root) {
31082
31140
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
31083
31141
  return { configPath: join24(commonGitDir, "config"), headRoot };
31084
31142
  }
31143
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
31085
31144
  function safeRead(path) {
31086
31145
  try {
31087
- return readFileSync16(path, "utf8");
31146
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
31088
31147
  } catch {
31089
31148
  return void 0;
31090
31149
  }
@@ -35652,21 +35711,21 @@ function resolveCodexHome(env, home = homedir3()) {
35652
35711
 
35653
35712
  // ../../packages/plugin-sdk/src/account/observation-log.ts
35654
35713
  import { createHash as createHash13 } from "crypto";
35655
- import { closeSync as closeSync2, constants, fstatSync, mkdirSync as mkdirSync2, openSync as openSync2, readSync, writeSync } from "fs";
35714
+ import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, mkdirSync as mkdirSync2, openSync as openSync3, readSync, writeSync } from "fs";
35656
35715
  import { join as join35 } from "path";
35657
35716
  var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
35658
35717
  var SESSION_LOG_TAIL_BYTES = 64 * 1024;
35659
35718
  var NEWLINE = 10;
35660
35719
  var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
35661
35720
  function sessionLogOpenFlags(noFollow) {
35662
- return constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | (noFollow ?? 0);
35721
+ return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
35663
35722
  }
35664
35723
  var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
35665
- constants.O_NOFOLLOW
35724
+ constants2.O_NOFOLLOW
35666
35725
  );
35667
35726
  function closeQuietly2(fd) {
35668
35727
  try {
35669
- closeSync2(fd);
35728
+ closeSync3(fd);
35670
35729
  } catch {
35671
35730
  }
35672
35731
  }
@@ -35689,8 +35748,8 @@ function appendObservation(stateDir, sessionId, observation, capBytes = SESSION_
35689
35748
  let fd;
35690
35749
  try {
35691
35750
  mkdirSync2(stateDir, { recursive: true, mode: DATA_DIR_MODE });
35692
- fd = openSync2(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35693
- if (fstatSync(fd).size + Buffer.byteLength(line) > capBytes) return false;
35751
+ fd = openSync3(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
35752
+ if (fstatSync2(fd).size + Buffer.byteLength(line) > capBytes) return false;
35694
35753
  writeSync(fd, line);
35695
35754
  return true;
35696
35755
  } catch {
@@ -35720,12 +35779,12 @@ function parseLines(buffer, base) {
35720
35779
  function readRange(path, from, capBytes) {
35721
35780
  let fd;
35722
35781
  try {
35723
- fd = openSync2(path, "r");
35782
+ fd = openSync3(path, "r");
35724
35783
  } catch {
35725
35784
  return void 0;
35726
35785
  }
35727
35786
  try {
35728
- const size = fstatSync(fd).size;
35787
+ const size = fstatSync2(fd).size;
35729
35788
  const length = Math.max(0, Math.min(size, capBytes) - from);
35730
35789
  const buffer = Buffer.alloc(length);
35731
35790
  let filled = 0;
@@ -35772,7 +35831,7 @@ function classifyObservation(observation) {
35772
35831
  }
35773
35832
 
35774
35833
  // ../../packages/plugin-sdk/src/account/codex-head.ts
35775
- import { closeSync as closeSync3, openSync as openSync3, readSync as readSync2 } from "fs";
35834
+ import { closeSync as closeSync4, openSync as openSync4, readSync as readSync2 } from "fs";
35776
35835
  var CODEX_HEAD_READ_BYTES = 64 * 1024;
35777
35836
  var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
35778
35837
  var NEWLINE2 = 10;
@@ -35805,7 +35864,7 @@ function parseHead(line) {
35805
35864
  function readCodexHead(rolloutPath) {
35806
35865
  let fd;
35807
35866
  try {
35808
- fd = openSync3(rolloutPath, "r");
35867
+ fd = openSync4(rolloutPath, "r");
35809
35868
  } catch (error2) {
35810
35869
  return isNotFound(error2) ? "pending" : void 0;
35811
35870
  }
@@ -35830,14 +35889,14 @@ function readCodexHead(rolloutPath) {
35830
35889
  return void 0;
35831
35890
  } finally {
35832
35891
  try {
35833
- closeSync3(fd);
35892
+ closeSync4(fd);
35834
35893
  } catch {
35835
35894
  }
35836
35895
  }
35837
35896
  }
35838
35897
 
35839
35898
  // ../../packages/plugin-sdk/src/account/codex-login.ts
35840
- import { closeSync as closeSync4, constants as constants2, fstatSync as fstatSync2, lstatSync as lstatSync6, openSync as openSync4, readSync as readSync3 } from "fs";
35899
+ import { closeSync as closeSync5, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync5, readSync as readSync3 } from "fs";
35841
35900
  import { join as join36 } from "path";
35842
35901
  var CODEX_AUTH_MAX_BYTES = 64 * 1024;
35843
35902
  var CODEX_ID_TOKEN_MAX_CHARS = 16 * 1024;
@@ -35870,8 +35929,8 @@ var DROPPED = new Set(CODEX_DROPPED_FIELDS);
35870
35929
  var PRESENCE = new Set(CODEX_PRESENCE_FIELDS);
35871
35930
  var BASE64URL = /^[A-Za-z0-9_-]+$/;
35872
35931
  var UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35873
- var NOFOLLOW = constants2.O_NOFOLLOW ?? 0;
35874
- var READ_FLAGS = constants2.O_RDONLY | NOFOLLOW;
35932
+ var NOFOLLOW = constants3.O_NOFOLLOW ?? 0;
35933
+ var READ_FLAGS = constants3.O_RDONLY | NOFOLLOW;
35875
35934
  var ABSENT = { status: "absent" };
35876
35935
  var MODE = { status: "mode" };
35877
35936
  var MALFORMED = { status: "malformed" };
@@ -35993,12 +36052,12 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
35993
36052
  let fd;
35994
36053
  try {
35995
36054
  if (platform === "win32" && lstatSync6(path).isSymbolicLink()) return MALFORMED;
35996
- fd = openSync4(path, openFlags);
36055
+ fd = openSync5(path, openFlags);
35997
36056
  } catch (error2) {
35998
36057
  return isNotFound2(error2) ? ABSENT : MALFORMED;
35999
36058
  }
36000
36059
  try {
36001
- const stat2 = fstatSync2(fd);
36060
+ const stat2 = fstatSync3(fd);
36002
36061
  if (!stat2.isFile() || stat2.size > CODEX_AUTH_MAX_BYTES) return MALFORMED;
36003
36062
  if (platform !== "win32" && (stat2.uid !== process.getuid?.() || (stat2.mode & 18) !== 0)) {
36004
36063
  return MALFORMED;
@@ -36010,7 +36069,7 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
36010
36069
  return MALFORMED;
36011
36070
  } finally {
36012
36071
  try {
36013
- closeSync4(fd);
36072
+ closeSync5(fd);
36014
36073
  } catch {
36015
36074
  }
36016
36075
  }