@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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aka-codex",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
4
4
  "description": "AI Traffic Control \u2014 inspect and govern AI prompts in Codex CLI. Detection runs locally; events are recorded to a local SQLite store on your machine.",
5
5
  "hooks": "./hooks/hooks.json",
6
6
  "skills": "./skills",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akasecurity/ai-tc-codex",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in Codex CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -8783,7 +8783,11 @@ var ListFindingTypesQuery = object({
8783
8783
  // and so is not bounded by what any page happens to hold.
8784
8784
  includeId: string2().optional(),
8785
8785
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8786
- cursor: string2().optional()
8786
+ cursor: string2().optional(),
8787
+ // A row position to read from, for jumping to a page instead of stepping to
8788
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8789
+ // from wherever it lands.
8790
+ offset: coerce_exports.number().int().min(0).optional()
8787
8791
  });
8788
8792
  var ListFindingTypesResponse = object({
8789
8793
  totals: object({
@@ -8864,7 +8868,11 @@ var ListFindingInstancesQuery = object({
8864
8868
  sessionId: string2().optional(),
8865
8869
  from: iso_exports.datetime().optional(),
8866
8870
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8867
- cursor: string2().optional()
8871
+ cursor: string2().optional(),
8872
+ // A row position to read from, for jumping to a page instead of stepping to
8873
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8874
+ // from wherever it lands.
8875
+ offset: coerce_exports.number().int().min(0).optional()
8868
8876
  });
8869
8877
  var ListFindingInstancesResponse = object({
8870
8878
  // Instances matching the filters across the whole scope, not just this
@@ -8936,7 +8944,11 @@ var ListFindingLocationsQuery = object({
8936
8944
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8937
8945
  includeId: string2().optional(),
8938
8946
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8939
- cursor: string2().optional()
8947
+ cursor: string2().optional(),
8948
+ // A row position to read from, for jumping to a page instead of stepping to
8949
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8950
+ // from wherever it lands.
8951
+ offset: coerce_exports.number().int().min(0).optional()
8940
8952
  });
8941
8953
  var ListFindingLocationsResponse = object({
8942
8954
  totals: object({
@@ -11410,7 +11422,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11410
11422
  var ListVaultInventoryQuery = object({
11411
11423
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11412
11424
  // Opaque; names the last row of the page just served.
11413
- cursor: string2().optional()
11425
+ cursor: string2().optional(),
11426
+ // A row position to read from, for jumping to a page instead of stepping to
11427
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11428
+ // from wherever it lands.
11429
+ offset: coerce_exports.number().int().min(0).optional()
11414
11430
  });
11415
11431
  var ListVaultInventoryResponse = object({
11416
11432
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11422,7 +11438,11 @@ var ListVaultInventoryResponse = object({
11422
11438
  });
11423
11439
  var ListVaultReuseQuery = object({
11424
11440
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11425
- cursor: string2().optional()
11441
+ cursor: string2().optional(),
11442
+ // A row position to read from, for jumping to a page instead of stepping to
11443
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11444
+ // from wherever it lands.
11445
+ offset: coerce_exports.number().int().min(0).optional()
11426
11446
  });
11427
11447
  var ListVaultReuseResponse = object({
11428
11448
  // Reused values across the whole store — the number the section's claim
@@ -11438,9 +11458,15 @@ var ListVaultDerefsQuery = object({
11438
11458
  // over a Server Action, which preserves the type, never as a URL param.
11439
11459
  includeBatched: boolean2().optional(),
11440
11460
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11441
- cursor: string2().optional()
11461
+ cursor: string2().optional(),
11462
+ // A row position to read from, for jumping to a page instead of stepping to
11463
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11464
+ // from wherever it lands.
11465
+ offset: coerce_exports.number().int().min(0).optional()
11442
11466
  });
11443
11467
  var ListVaultDerefsResponse = object({
11468
+ // Rows this filter selects across the whole trail, not just this page.
11469
+ totals: object({ derefs: number2().int().nonnegative() }),
11444
11470
  items: array(VaultDeref),
11445
11471
  nextCursor: string2().nullable(),
11446
11472
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -18876,7 +18902,7 @@ var SqliteFindingsRepository = class {
18876
18902
  };
18877
18903
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
18878
18904
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
18879
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
18905
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
18880
18906
  const page = sorted.slice(start, start + limit);
18881
18907
  const lastOnPage = page.at(-1);
18882
18908
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -18970,7 +18996,7 @@ var SqliteFindingsRepository = class {
18970
18996
  accumulator.add(row);
18971
18997
  if (!matchesInstanceFilters(row, opts)) continue;
18972
18998
  total += 1;
18973
- if (!isPastCursor(row)) continue;
18999
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
18974
19000
  if (items.length < limit) {
18975
19001
  items.push(toInstanceDetail(row));
18976
19002
  last = row;
@@ -19059,7 +19085,7 @@ var SqliteFindingsRepository = class {
19059
19085
  }
19060
19086
  }
19061
19087
  sorted.sort(compareLocationOrder);
19062
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
19088
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
19063
19089
  const page = sorted.slice(start, start + limit);
19064
19090
  const lastOnPage = page.at(-1);
19065
19091
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -21687,6 +21713,9 @@ function pageLimit(requested, fallback) {
21687
21713
  if (requested === void 0) return fallback;
21688
21714
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
21689
21715
  }
21716
+ function pageOffset(requested) {
21717
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
21718
+ }
21690
21719
  function encodeReuseCursor(payload) {
21691
21720
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
21692
21721
  }
@@ -22034,7 +22063,8 @@ var SqliteSecretVaultRepository = class {
22034
22063
  */
22035
22064
  listInventory(query = {}, now = Date.now()) {
22036
22065
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22037
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22066
+ const offset = pageOffset(query.offset);
22067
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22038
22068
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
22039
22069
  const rows = allRows(
22040
22070
  this.db.prepare(
@@ -22048,11 +22078,12 @@ var SqliteSecretVaultRepository = class {
22048
22078
  FROM secret_vault v
22049
22079
  ${where}
22050
22080
  ORDER BY v.last_seen DESC, v.pointer_id DESC
22051
- LIMIT :limit`
22081
+ LIMIT :limit OFFSET :offset`
22052
22082
  ),
22053
22083
  bindParams({
22054
22084
  now,
22055
22085
  limit: limit + 1,
22086
+ offset,
22056
22087
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
22057
22088
  })
22058
22089
  );
@@ -22076,7 +22107,8 @@ var SqliteSecretVaultRepository = class {
22076
22107
  */
22077
22108
  listReuse(query = {}, now = Date.now()) {
22078
22109
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22079
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
22110
+ const offset = pageOffset(query.offset);
22111
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
22080
22112
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
22081
22113
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
22082
22114
  const rows = allRows(
@@ -22091,11 +22123,12 @@ var SqliteSecretVaultRepository = class {
22091
22123
  FROM secret_vault v
22092
22124
  WHERE ${REUSED_PREDICATE} ${after}
22093
22125
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
22094
- LIMIT :limit`
22126
+ LIMIT :limit OFFSET :offset`
22095
22127
  ),
22096
22128
  bindParams({
22097
22129
  now,
22098
22130
  limit: limit + 1,
22131
+ offset,
22099
22132
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
22100
22133
  })
22101
22134
  );
@@ -22120,7 +22153,8 @@ var SqliteSecretVaultRepository = class {
22120
22153
  */
22121
22154
  listDerefs(query = {}) {
22122
22155
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
22123
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22156
+ const offset = pageOffset(query.offset);
22157
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22124
22158
  const conditions = [];
22125
22159
  if (query.includeBatched !== true) {
22126
22160
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -22133,21 +22167,28 @@ var SqliteSecretVaultRepository = class {
22133
22167
  this.db.prepare(
22134
22168
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
22135
22169
  FROM secret_vault_deref ${where}
22136
- ORDER BY at DESC, id DESC LIMIT :limit`
22170
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
22137
22171
  ),
22138
22172
  bindParams({
22139
22173
  limit: limit + 1,
22174
+ offset,
22140
22175
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
22141
22176
  })
22142
22177
  );
22143
22178
  const hasMore = rows.length > limit;
22144
22179
  const page = hasMore ? rows.slice(0, limit) : rows;
22145
22180
  const last = page[page.length - 1];
22146
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
22147
- this.db,
22148
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
22149
- );
22181
+ const counts = getRow(
22182
+ this.db.prepare(
22183
+ `SELECT count(*) AS total,
22184
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
22185
+ FROM secret_vault_deref`
22186
+ )
22187
+ ) ?? { total: 0, hidden: 0 };
22188
+ const includeBatched = query.includeBatched === true;
22189
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
22150
22190
  return {
22191
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
22151
22192
  items: page.map((r) => ({
22152
22193
  id: r.id,
22153
22194
  pointerId: r.pointer_id,
@@ -8783,7 +8783,11 @@ var ListFindingTypesQuery = object({
8783
8783
  // and so is not bounded by what any page happens to hold.
8784
8784
  includeId: string2().optional(),
8785
8785
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8786
- cursor: string2().optional()
8786
+ cursor: string2().optional(),
8787
+ // A row position to read from, for jumping to a page instead of stepping to
8788
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8789
+ // from wherever it lands.
8790
+ offset: coerce_exports.number().int().min(0).optional()
8787
8791
  });
8788
8792
  var ListFindingTypesResponse = object({
8789
8793
  totals: object({
@@ -8864,7 +8868,11 @@ var ListFindingInstancesQuery = object({
8864
8868
  sessionId: string2().optional(),
8865
8869
  from: iso_exports.datetime().optional(),
8866
8870
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8867
- cursor: string2().optional()
8871
+ cursor: string2().optional(),
8872
+ // A row position to read from, for jumping to a page instead of stepping to
8873
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8874
+ // from wherever it lands.
8875
+ offset: coerce_exports.number().int().min(0).optional()
8868
8876
  });
8869
8877
  var ListFindingInstancesResponse = object({
8870
8878
  // Instances matching the filters across the whole scope, not just this
@@ -8936,7 +8944,11 @@ var ListFindingLocationsQuery = object({
8936
8944
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8937
8945
  includeId: string2().optional(),
8938
8946
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8939
- cursor: string2().optional()
8947
+ cursor: string2().optional(),
8948
+ // A row position to read from, for jumping to a page instead of stepping to
8949
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8950
+ // from wherever it lands.
8951
+ offset: coerce_exports.number().int().min(0).optional()
8940
8952
  });
8941
8953
  var ListFindingLocationsResponse = object({
8942
8954
  totals: object({
@@ -11573,7 +11585,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11573
11585
  var ListVaultInventoryQuery = object({
11574
11586
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11575
11587
  // Opaque; names the last row of the page just served.
11576
- cursor: string2().optional()
11588
+ cursor: string2().optional(),
11589
+ // A row position to read from, for jumping to a page instead of stepping to
11590
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11591
+ // from wherever it lands.
11592
+ offset: coerce_exports.number().int().min(0).optional()
11577
11593
  });
11578
11594
  var ListVaultInventoryResponse = object({
11579
11595
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11585,7 +11601,11 @@ var ListVaultInventoryResponse = object({
11585
11601
  });
11586
11602
  var ListVaultReuseQuery = object({
11587
11603
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11588
- cursor: string2().optional()
11604
+ cursor: string2().optional(),
11605
+ // A row position to read from, for jumping to a page instead of stepping to
11606
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11607
+ // from wherever it lands.
11608
+ offset: coerce_exports.number().int().min(0).optional()
11589
11609
  });
11590
11610
  var ListVaultReuseResponse = object({
11591
11611
  // Reused values across the whole store — the number the section's claim
@@ -11601,9 +11621,15 @@ var ListVaultDerefsQuery = object({
11601
11621
  // over a Server Action, which preserves the type, never as a URL param.
11602
11622
  includeBatched: boolean2().optional(),
11603
11623
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11604
- cursor: string2().optional()
11624
+ cursor: string2().optional(),
11625
+ // A row position to read from, for jumping to a page instead of stepping to
11626
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11627
+ // from wherever it lands.
11628
+ offset: coerce_exports.number().int().min(0).optional()
11605
11629
  });
11606
11630
  var ListVaultDerefsResponse = object({
11631
+ // Rows this filter selects across the whole trail, not just this page.
11632
+ totals: object({ derefs: number2().int().nonnegative() }),
11607
11633
  items: array(VaultDeref),
11608
11634
  nextCursor: string2().nullable(),
11609
11635
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -25267,7 +25293,7 @@ var SqliteFindingsRepository = class {
25267
25293
  };
25268
25294
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25269
25295
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25270
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25296
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25271
25297
  const page = sorted.slice(start, start + limit);
25272
25298
  const lastOnPage = page.at(-1);
25273
25299
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25361,7 +25387,7 @@ var SqliteFindingsRepository = class {
25361
25387
  accumulator.add(row);
25362
25388
  if (!matchesInstanceFilters(row, opts)) continue;
25363
25389
  total += 1;
25364
- if (!isPastCursor(row)) continue;
25390
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25365
25391
  if (items.length < limit) {
25366
25392
  items.push(toInstanceDetail(row));
25367
25393
  last = row;
@@ -25450,7 +25476,7 @@ var SqliteFindingsRepository = class {
25450
25476
  }
25451
25477
  }
25452
25478
  sorted.sort(compareLocationOrder);
25453
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25479
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25454
25480
  const page = sorted.slice(start, start + limit);
25455
25481
  const lastOnPage = page.at(-1);
25456
25482
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -28078,6 +28104,9 @@ function pageLimit(requested, fallback) {
28078
28104
  if (requested === void 0) return fallback;
28079
28105
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
28080
28106
  }
28107
+ function pageOffset(requested) {
28108
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28109
+ }
28081
28110
  function encodeReuseCursor(payload) {
28082
28111
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
28083
28112
  }
@@ -28425,7 +28454,8 @@ var SqliteSecretVaultRepository = class {
28425
28454
  */
28426
28455
  listInventory(query = {}, now = Date.now()) {
28427
28456
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28428
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28457
+ const offset = pageOffset(query.offset);
28458
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28429
28459
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28430
28460
  const rows = allRows(
28431
28461
  this.db.prepare(
@@ -28439,11 +28469,12 @@ var SqliteSecretVaultRepository = class {
28439
28469
  FROM secret_vault v
28440
28470
  ${where}
28441
28471
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28442
- LIMIT :limit`
28472
+ LIMIT :limit OFFSET :offset`
28443
28473
  ),
28444
28474
  bindParams({
28445
28475
  now,
28446
28476
  limit: limit + 1,
28477
+ offset,
28447
28478
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28448
28479
  })
28449
28480
  );
@@ -28467,7 +28498,8 @@ var SqliteSecretVaultRepository = class {
28467
28498
  */
28468
28499
  listReuse(query = {}, now = Date.now()) {
28469
28500
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28470
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28501
+ const offset = pageOffset(query.offset);
28502
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28471
28503
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28472
28504
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28473
28505
  const rows = allRows(
@@ -28482,11 +28514,12 @@ var SqliteSecretVaultRepository = class {
28482
28514
  FROM secret_vault v
28483
28515
  WHERE ${REUSED_PREDICATE} ${after}
28484
28516
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28485
- LIMIT :limit`
28517
+ LIMIT :limit OFFSET :offset`
28486
28518
  ),
28487
28519
  bindParams({
28488
28520
  now,
28489
28521
  limit: limit + 1,
28522
+ offset,
28490
28523
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28491
28524
  })
28492
28525
  );
@@ -28511,7 +28544,8 @@ var SqliteSecretVaultRepository = class {
28511
28544
  */
28512
28545
  listDerefs(query = {}) {
28513
28546
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28514
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28547
+ const offset = pageOffset(query.offset);
28548
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28515
28549
  const conditions = [];
28516
28550
  if (query.includeBatched !== true) {
28517
28551
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28524,21 +28558,28 @@ var SqliteSecretVaultRepository = class {
28524
28558
  this.db.prepare(
28525
28559
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28526
28560
  FROM secret_vault_deref ${where}
28527
- ORDER BY at DESC, id DESC LIMIT :limit`
28561
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28528
28562
  ),
28529
28563
  bindParams({
28530
28564
  limit: limit + 1,
28565
+ offset,
28531
28566
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28532
28567
  })
28533
28568
  );
28534
28569
  const hasMore = rows.length > limit;
28535
28570
  const page = hasMore ? rows.slice(0, limit) : rows;
28536
28571
  const last = page[page.length - 1];
28537
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28538
- this.db,
28539
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28540
- );
28572
+ const counts = getRow(
28573
+ this.db.prepare(
28574
+ `SELECT count(*) AS total,
28575
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28576
+ FROM secret_vault_deref`
28577
+ )
28578
+ ) ?? { total: 0, hidden: 0 };
28579
+ const includeBatched = query.includeBatched === true;
28580
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28541
28581
  return {
28582
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28542
28583
  items: page.map((r) => ({
28543
28584
  id: r.id,
28544
28585
  pointerId: r.pointer_id,
@@ -31014,8 +31055,25 @@ function scanText2(text, ruleVersions, options = {}) {
31014
31055
  }
31015
31056
  }
31016
31057
 
31058
+ // ../../packages/plugin-sdk/src/regular-file.ts
31059
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
31060
+ function notRegularFile(path) {
31061
+ return `not a regular file: ${path}`;
31062
+ }
31063
+ function readRegularFile(path, maxBytes) {
31064
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
31065
+ try {
31066
+ const stat2 = fstatSync(fd);
31067
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
31068
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
31069
+ return readFileSync16(fd, "utf8");
31070
+ } finally {
31071
+ closeSync2(fd);
31072
+ }
31073
+ }
31074
+
31017
31075
  // ../../packages/plugin-sdk/src/repo.ts
31018
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
31076
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
31019
31077
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
31020
31078
  function remoteWithoutCredentials(remote) {
31021
31079
  const withoutInfo = withoutUserinfo(remote);
@@ -31119,9 +31177,10 @@ function resolveGitContext(root) {
31119
31177
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
31120
31178
  return { configPath: join24(commonGitDir, "config"), headRoot };
31121
31179
  }
31180
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
31122
31181
  function safeRead(path) {
31123
31182
  try {
31124
- return readFileSync16(path, "utf8");
31183
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
31125
31184
  } catch {
31126
31185
  return void 0;
31127
31186
  }
@@ -36289,10 +36348,10 @@ import { isAbsolute as isAbsolute5, normalize as normalize2, resolve as resolveP
36289
36348
  // src/history/tail.ts
36290
36349
  import { createHash as createHash13 } from "crypto";
36291
36350
  import {
36292
- closeSync as closeSync2,
36293
- fstatSync,
36351
+ closeSync as closeSync3,
36352
+ fstatSync as fstatSync2,
36294
36353
  mkdirSync as mkdirSync2,
36295
- openSync as openSync2,
36354
+ openSync as openSync3,
36296
36355
  readFileSync as readFileSync26,
36297
36356
  readSync,
36298
36357
  writeFileSync as writeFileSync7