@akasecurity/ai-tc-copilot 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.
@@ -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
@@ -25161,7 +25187,7 @@ var SqliteFindingsRepository = class {
25161
25187
  };
25162
25188
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25163
25189
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25164
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25190
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25165
25191
  const page = sorted.slice(start, start + limit);
25166
25192
  const lastOnPage = page.at(-1);
25167
25193
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25255,7 +25281,7 @@ var SqliteFindingsRepository = class {
25255
25281
  accumulator.add(row);
25256
25282
  if (!matchesInstanceFilters(row, opts)) continue;
25257
25283
  total += 1;
25258
- if (!isPastCursor(row)) continue;
25284
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25259
25285
  if (items.length < limit) {
25260
25286
  items.push(toInstanceDetail(row));
25261
25287
  last = row;
@@ -25344,7 +25370,7 @@ var SqliteFindingsRepository = class {
25344
25370
  }
25345
25371
  }
25346
25372
  sorted.sort(compareLocationOrder);
25347
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25373
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25348
25374
  const page = sorted.slice(start, start + limit);
25349
25375
  const lastOnPage = page.at(-1);
25350
25376
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -27972,6 +27998,9 @@ function pageLimit(requested, fallback) {
27972
27998
  if (requested === void 0) return fallback;
27973
27999
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
27974
28000
  }
28001
+ function pageOffset(requested) {
28002
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28003
+ }
27975
28004
  function encodeReuseCursor(payload) {
27976
28005
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
27977
28006
  }
@@ -28319,7 +28348,8 @@ var SqliteSecretVaultRepository = class {
28319
28348
  */
28320
28349
  listInventory(query = {}, now = Date.now()) {
28321
28350
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28322
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28351
+ const offset = pageOffset(query.offset);
28352
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28323
28353
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28324
28354
  const rows = allRows(
28325
28355
  this.db.prepare(
@@ -28333,11 +28363,12 @@ var SqliteSecretVaultRepository = class {
28333
28363
  FROM secret_vault v
28334
28364
  ${where}
28335
28365
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28336
- LIMIT :limit`
28366
+ LIMIT :limit OFFSET :offset`
28337
28367
  ),
28338
28368
  bindParams({
28339
28369
  now,
28340
28370
  limit: limit + 1,
28371
+ offset,
28341
28372
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28342
28373
  })
28343
28374
  );
@@ -28361,7 +28392,8 @@ var SqliteSecretVaultRepository = class {
28361
28392
  */
28362
28393
  listReuse(query = {}, now = Date.now()) {
28363
28394
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28364
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28395
+ const offset = pageOffset(query.offset);
28396
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28365
28397
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28366
28398
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28367
28399
  const rows = allRows(
@@ -28376,11 +28408,12 @@ var SqliteSecretVaultRepository = class {
28376
28408
  FROM secret_vault v
28377
28409
  WHERE ${REUSED_PREDICATE} ${after}
28378
28410
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28379
- LIMIT :limit`
28411
+ LIMIT :limit OFFSET :offset`
28380
28412
  ),
28381
28413
  bindParams({
28382
28414
  now,
28383
28415
  limit: limit + 1,
28416
+ offset,
28384
28417
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28385
28418
  })
28386
28419
  );
@@ -28405,7 +28438,8 @@ var SqliteSecretVaultRepository = class {
28405
28438
  */
28406
28439
  listDerefs(query = {}) {
28407
28440
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28408
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28441
+ const offset = pageOffset(query.offset);
28442
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28409
28443
  const conditions = [];
28410
28444
  if (query.includeBatched !== true) {
28411
28445
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28418,21 +28452,28 @@ var SqliteSecretVaultRepository = class {
28418
28452
  this.db.prepare(
28419
28453
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28420
28454
  FROM secret_vault_deref ${where}
28421
- ORDER BY at DESC, id DESC LIMIT :limit`
28455
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28422
28456
  ),
28423
28457
  bindParams({
28424
28458
  limit: limit + 1,
28459
+ offset,
28425
28460
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28426
28461
  })
28427
28462
  );
28428
28463
  const hasMore = rows.length > limit;
28429
28464
  const page = hasMore ? rows.slice(0, limit) : rows;
28430
28465
  const last = page[page.length - 1];
28431
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28432
- this.db,
28433
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28434
- );
28466
+ const counts = getRow(
28467
+ this.db.prepare(
28468
+ `SELECT count(*) AS total,
28469
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28470
+ FROM secret_vault_deref`
28471
+ )
28472
+ ) ?? { total: 0, hidden: 0 };
28473
+ const includeBatched = query.includeBatched === true;
28474
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28435
28475
  return {
28476
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28436
28477
  items: page.map((r) => ({
28437
28478
  id: r.id,
28438
28479
  pointerId: r.pointer_id,
@@ -30893,8 +30934,25 @@ function bundledMaskingRules() {
30893
30934
  return ensureBundledPacks() ? getLoadedRules() : null;
30894
30935
  }
30895
30936
 
30937
+ // ../../packages/plugin-sdk/src/regular-file.ts
30938
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30939
+ function notRegularFile(path) {
30940
+ return `not a regular file: ${path}`;
30941
+ }
30942
+ function readRegularFile(path, maxBytes) {
30943
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30944
+ try {
30945
+ const stat2 = fstatSync(fd);
30946
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30947
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30948
+ return readFileSync16(fd, "utf8");
30949
+ } finally {
30950
+ closeSync2(fd);
30951
+ }
30952
+ }
30953
+
30896
30954
  // ../../packages/plugin-sdk/src/repo.ts
30897
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30955
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30898
30956
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30899
30957
  function remoteWithoutCredentials(remote) {
30900
30958
  const withoutInfo = withoutUserinfo(remote);
@@ -30983,9 +31041,10 @@ function resolveGitContext(root) {
30983
31041
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30984
31042
  return { configPath: join24(commonGitDir, "config"), headRoot };
30985
31043
  }
31044
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30986
31045
  function safeRead(path) {
30987
31046
  try {
30988
- return readFileSync16(path, "utf8");
31047
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30989
31048
  } catch {
30990
31049
  return void 0;
30991
31050
  }
@@ -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
@@ -25161,7 +25187,7 @@ var SqliteFindingsRepository = class {
25161
25187
  };
25162
25188
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25163
25189
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25164
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25190
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25165
25191
  const page = sorted.slice(start, start + limit);
25166
25192
  const lastOnPage = page.at(-1);
25167
25193
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25255,7 +25281,7 @@ var SqliteFindingsRepository = class {
25255
25281
  accumulator.add(row);
25256
25282
  if (!matchesInstanceFilters(row, opts)) continue;
25257
25283
  total += 1;
25258
- if (!isPastCursor(row)) continue;
25284
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25259
25285
  if (items.length < limit) {
25260
25286
  items.push(toInstanceDetail(row));
25261
25287
  last = row;
@@ -25344,7 +25370,7 @@ var SqliteFindingsRepository = class {
25344
25370
  }
25345
25371
  }
25346
25372
  sorted.sort(compareLocationOrder);
25347
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25373
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25348
25374
  const page = sorted.slice(start, start + limit);
25349
25375
  const lastOnPage = page.at(-1);
25350
25376
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -27972,6 +27998,9 @@ function pageLimit(requested, fallback) {
27972
27998
  if (requested === void 0) return fallback;
27973
27999
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
27974
28000
  }
28001
+ function pageOffset(requested) {
28002
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28003
+ }
27975
28004
  function encodeReuseCursor(payload) {
27976
28005
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
27977
28006
  }
@@ -28319,7 +28348,8 @@ var SqliteSecretVaultRepository = class {
28319
28348
  */
28320
28349
  listInventory(query = {}, now = Date.now()) {
28321
28350
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28322
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28351
+ const offset = pageOffset(query.offset);
28352
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28323
28353
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28324
28354
  const rows = allRows(
28325
28355
  this.db.prepare(
@@ -28333,11 +28363,12 @@ var SqliteSecretVaultRepository = class {
28333
28363
  FROM secret_vault v
28334
28364
  ${where}
28335
28365
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28336
- LIMIT :limit`
28366
+ LIMIT :limit OFFSET :offset`
28337
28367
  ),
28338
28368
  bindParams({
28339
28369
  now,
28340
28370
  limit: limit + 1,
28371
+ offset,
28341
28372
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28342
28373
  })
28343
28374
  );
@@ -28361,7 +28392,8 @@ var SqliteSecretVaultRepository = class {
28361
28392
  */
28362
28393
  listReuse(query = {}, now = Date.now()) {
28363
28394
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28364
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28395
+ const offset = pageOffset(query.offset);
28396
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28365
28397
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28366
28398
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28367
28399
  const rows = allRows(
@@ -28376,11 +28408,12 @@ var SqliteSecretVaultRepository = class {
28376
28408
  FROM secret_vault v
28377
28409
  WHERE ${REUSED_PREDICATE} ${after}
28378
28410
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28379
- LIMIT :limit`
28411
+ LIMIT :limit OFFSET :offset`
28380
28412
  ),
28381
28413
  bindParams({
28382
28414
  now,
28383
28415
  limit: limit + 1,
28416
+ offset,
28384
28417
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28385
28418
  })
28386
28419
  );
@@ -28405,7 +28438,8 @@ var SqliteSecretVaultRepository = class {
28405
28438
  */
28406
28439
  listDerefs(query = {}) {
28407
28440
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28408
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28441
+ const offset = pageOffset(query.offset);
28442
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28409
28443
  const conditions = [];
28410
28444
  if (query.includeBatched !== true) {
28411
28445
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28418,21 +28452,28 @@ var SqliteSecretVaultRepository = class {
28418
28452
  this.db.prepare(
28419
28453
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28420
28454
  FROM secret_vault_deref ${where}
28421
- ORDER BY at DESC, id DESC LIMIT :limit`
28455
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28422
28456
  ),
28423
28457
  bindParams({
28424
28458
  limit: limit + 1,
28459
+ offset,
28425
28460
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28426
28461
  })
28427
28462
  );
28428
28463
  const hasMore = rows.length > limit;
28429
28464
  const page = hasMore ? rows.slice(0, limit) : rows;
28430
28465
  const last = page[page.length - 1];
28431
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28432
- this.db,
28433
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28434
- );
28466
+ const counts = getRow(
28467
+ this.db.prepare(
28468
+ `SELECT count(*) AS total,
28469
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28470
+ FROM secret_vault_deref`
28471
+ )
28472
+ ) ?? { total: 0, hidden: 0 };
28473
+ const includeBatched = query.includeBatched === true;
28474
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28435
28475
  return {
28476
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28436
28477
  items: page.map((r) => ({
28437
28478
  id: r.id,
28438
28479
  pointerId: r.pointer_id,
@@ -30890,8 +30931,25 @@ function bundledMaskingRules() {
30890
30931
  return ensureBundledPacks() ? getLoadedRules() : null;
30891
30932
  }
30892
30933
 
30934
+ // ../../packages/plugin-sdk/src/regular-file.ts
30935
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30936
+ function notRegularFile(path) {
30937
+ return `not a regular file: ${path}`;
30938
+ }
30939
+ function readRegularFile(path, maxBytes) {
30940
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30941
+ try {
30942
+ const stat2 = fstatSync(fd);
30943
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30944
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30945
+ return readFileSync16(fd, "utf8");
30946
+ } finally {
30947
+ closeSync2(fd);
30948
+ }
30949
+ }
30950
+
30893
30951
  // ../../packages/plugin-sdk/src/repo.ts
30894
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30952
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30895
30953
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30896
30954
  function remoteWithoutCredentials(remote) {
30897
30955
  const withoutInfo = withoutUserinfo(remote);
@@ -30980,9 +31038,10 @@ function resolveGitContext(root) {
30980
31038
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30981
31039
  return { configPath: join24(commonGitDir, "config"), headRoot };
30982
31040
  }
31041
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30983
31042
  function safeRead(path) {
30984
31043
  try {
30985
- return readFileSync16(path, "utf8");
31044
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30986
31045
  } catch {
30987
31046
  return void 0;
30988
31047
  }
@@ -8329,7 +8329,11 @@ var ListFindingTypesQuery = object({
8329
8329
  // and so is not bounded by what any page happens to hold.
8330
8330
  includeId: string2().optional(),
8331
8331
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8332
- cursor: string2().optional()
8332
+ cursor: string2().optional(),
8333
+ // A row position to read from, for jumping to a page instead of stepping to
8334
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8335
+ // from wherever it lands.
8336
+ offset: coerce_exports.number().int().min(0).optional()
8333
8337
  });
8334
8338
  var ListFindingTypesResponse = object({
8335
8339
  totals: object({
@@ -8409,7 +8413,11 @@ var ListFindingInstancesQuery = object({
8409
8413
  sessionId: string2().optional(),
8410
8414
  from: iso_exports.datetime().optional(),
8411
8415
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8412
- cursor: string2().optional()
8416
+ cursor: string2().optional(),
8417
+ // A row position to read from, for jumping to a page instead of stepping to
8418
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8419
+ // from wherever it lands.
8420
+ offset: coerce_exports.number().int().min(0).optional()
8413
8421
  });
8414
8422
  var ListFindingInstancesResponse = object({
8415
8423
  // Instances matching the filters across the whole scope, not just this
@@ -8480,7 +8488,11 @@ var ListFindingLocationsQuery = object({
8480
8488
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8481
8489
  includeId: string2().optional(),
8482
8490
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8483
- cursor: string2().optional()
8491
+ cursor: string2().optional(),
8492
+ // A row position to read from, for jumping to a page instead of stepping to
8493
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8494
+ // from wherever it lands.
8495
+ offset: coerce_exports.number().int().min(0).optional()
8484
8496
  });
8485
8497
  var ListFindingLocationsResponse = object({
8486
8498
  totals: object({
@@ -10877,7 +10889,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
10877
10889
  var ListVaultInventoryQuery = object({
10878
10890
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10879
10891
  // Opaque; names the last row of the page just served.
10880
- cursor: string2().optional()
10892
+ cursor: string2().optional(),
10893
+ // A row position to read from, for jumping to a page instead of stepping to
10894
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10895
+ // from wherever it lands.
10896
+ offset: coerce_exports.number().int().min(0).optional()
10881
10897
  });
10882
10898
  var ListVaultInventoryResponse = object({
10883
10899
  // Vaulted values across the whole store, not just this page — cursor-
@@ -10889,7 +10905,11 @@ var ListVaultInventoryResponse = object({
10889
10905
  });
10890
10906
  var ListVaultReuseQuery = object({
10891
10907
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10892
- cursor: string2().optional()
10908
+ cursor: string2().optional(),
10909
+ // A row position to read from, for jumping to a page instead of stepping to
10910
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10911
+ // from wherever it lands.
10912
+ offset: coerce_exports.number().int().min(0).optional()
10893
10913
  });
10894
10914
  var ListVaultReuseResponse = object({
10895
10915
  // Reused values across the whole store — the number the section's claim
@@ -10905,9 +10925,15 @@ var ListVaultDerefsQuery = object({
10905
10925
  // over a Server Action, which preserves the type, never as a URL param.
10906
10926
  includeBatched: boolean2().optional(),
10907
10927
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10908
- cursor: string2().optional()
10928
+ cursor: string2().optional(),
10929
+ // A row position to read from, for jumping to a page instead of stepping to
10930
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10931
+ // from wherever it lands.
10932
+ offset: coerce_exports.number().int().min(0).optional()
10909
10933
  });
10910
10934
  var ListVaultDerefsResponse = object({
10935
+ // Rows this filter selects across the whole trail, not just this page.
10936
+ totals: object({ derefs: number2().int().nonnegative() }),
10911
10937
  items: array(VaultDeref),
10912
10938
  nextCursor: string2().nullable(),
10913
10939
  // Display/view-render rows the query hid, over the WHOLE trail rather than