@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.
@@ -8781,7 +8781,11 @@ var ListFindingTypesQuery = object({
8781
8781
  // and so is not bounded by what any page happens to hold.
8782
8782
  includeId: string2().optional(),
8783
8783
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8784
- cursor: string2().optional()
8784
+ cursor: string2().optional(),
8785
+ // A row position to read from, for jumping to a page instead of stepping to
8786
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8787
+ // from wherever it lands.
8788
+ offset: coerce_exports.number().int().min(0).optional()
8785
8789
  });
8786
8790
  var ListFindingTypesResponse = object({
8787
8791
  totals: object({
@@ -8862,7 +8866,11 @@ var ListFindingInstancesQuery = object({
8862
8866
  sessionId: string2().optional(),
8863
8867
  from: iso_exports.datetime().optional(),
8864
8868
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8865
- cursor: string2().optional()
8869
+ cursor: string2().optional(),
8870
+ // A row position to read from, for jumping to a page instead of stepping to
8871
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8872
+ // from wherever it lands.
8873
+ offset: coerce_exports.number().int().min(0).optional()
8866
8874
  });
8867
8875
  var ListFindingInstancesResponse = object({
8868
8876
  // Instances matching the filters across the whole scope, not just this
@@ -8934,7 +8942,11 @@ var ListFindingLocationsQuery = object({
8934
8942
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8935
8943
  includeId: string2().optional(),
8936
8944
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8937
- cursor: string2().optional()
8945
+ cursor: string2().optional(),
8946
+ // A row position to read from, for jumping to a page instead of stepping to
8947
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8948
+ // from wherever it lands.
8949
+ offset: coerce_exports.number().int().min(0).optional()
8938
8950
  });
8939
8951
  var ListFindingLocationsResponse = object({
8940
8952
  totals: object({
@@ -11571,7 +11583,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11571
11583
  var ListVaultInventoryQuery = object({
11572
11584
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11573
11585
  // Opaque; names the last row of the page just served.
11574
- cursor: string2().optional()
11586
+ cursor: string2().optional(),
11587
+ // A row position to read from, for jumping to a page instead of stepping to
11588
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11589
+ // from wherever it lands.
11590
+ offset: coerce_exports.number().int().min(0).optional()
11575
11591
  });
11576
11592
  var ListVaultInventoryResponse = object({
11577
11593
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11583,7 +11599,11 @@ var ListVaultInventoryResponse = object({
11583
11599
  });
11584
11600
  var ListVaultReuseQuery = object({
11585
11601
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11586
- cursor: string2().optional()
11602
+ cursor: string2().optional(),
11603
+ // A row position to read from, for jumping to a page instead of stepping to
11604
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11605
+ // from wherever it lands.
11606
+ offset: coerce_exports.number().int().min(0).optional()
11587
11607
  });
11588
11608
  var ListVaultReuseResponse = object({
11589
11609
  // Reused values across the whole store — the number the section's claim
@@ -11599,9 +11619,15 @@ var ListVaultDerefsQuery = object({
11599
11619
  // over a Server Action, which preserves the type, never as a URL param.
11600
11620
  includeBatched: boolean2().optional(),
11601
11621
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11602
- cursor: string2().optional()
11622
+ cursor: string2().optional(),
11623
+ // A row position to read from, for jumping to a page instead of stepping to
11624
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11625
+ // from wherever it lands.
11626
+ offset: coerce_exports.number().int().min(0).optional()
11603
11627
  });
11604
11628
  var ListVaultDerefsResponse = object({
11629
+ // Rows this filter selects across the whole trail, not just this page.
11630
+ totals: object({ derefs: number2().int().nonnegative() }),
11605
11631
  items: array(VaultDeref),
11606
11632
  nextCursor: string2().nullable(),
11607
11633
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -20413,7 +20439,7 @@ var SqliteFindingsRepository = class {
20413
20439
  };
20414
20440
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
20415
20441
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
20416
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
20442
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
20417
20443
  const page = sorted.slice(start, start + limit);
20418
20444
  const lastOnPage = page.at(-1);
20419
20445
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -20507,7 +20533,7 @@ var SqliteFindingsRepository = class {
20507
20533
  accumulator.add(row);
20508
20534
  if (!matchesInstanceFilters(row, opts)) continue;
20509
20535
  total += 1;
20510
- if (!isPastCursor(row)) continue;
20536
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
20511
20537
  if (items.length < limit) {
20512
20538
  items.push(toInstanceDetail(row));
20513
20539
  last = row;
@@ -20596,7 +20622,7 @@ var SqliteFindingsRepository = class {
20596
20622
  }
20597
20623
  }
20598
20624
  sorted.sort(compareLocationOrder);
20599
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
20625
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
20600
20626
  const page = sorted.slice(start, start + limit);
20601
20627
  const lastOnPage = page.at(-1);
20602
20628
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -23224,6 +23250,9 @@ function pageLimit(requested, fallback) {
23224
23250
  if (requested === void 0) return fallback;
23225
23251
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
23226
23252
  }
23253
+ function pageOffset(requested) {
23254
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
23255
+ }
23227
23256
  function encodeReuseCursor(payload) {
23228
23257
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
23229
23258
  }
@@ -23571,7 +23600,8 @@ var SqliteSecretVaultRepository = class {
23571
23600
  */
23572
23601
  listInventory(query = {}, now = Date.now()) {
23573
23602
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23574
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23603
+ const offset = pageOffset(query.offset);
23604
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23575
23605
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
23576
23606
  const rows = allRows(
23577
23607
  this.db.prepare(
@@ -23585,11 +23615,12 @@ var SqliteSecretVaultRepository = class {
23585
23615
  FROM secret_vault v
23586
23616
  ${where}
23587
23617
  ORDER BY v.last_seen DESC, v.pointer_id DESC
23588
- LIMIT :limit`
23618
+ LIMIT :limit OFFSET :offset`
23589
23619
  ),
23590
23620
  bindParams({
23591
23621
  now,
23592
23622
  limit: limit + 1,
23623
+ offset,
23593
23624
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
23594
23625
  })
23595
23626
  );
@@ -23613,7 +23644,8 @@ var SqliteSecretVaultRepository = class {
23613
23644
  */
23614
23645
  listReuse(query = {}, now = Date.now()) {
23615
23646
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23616
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
23647
+ const offset = pageOffset(query.offset);
23648
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
23617
23649
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
23618
23650
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
23619
23651
  const rows = allRows(
@@ -23628,11 +23660,12 @@ var SqliteSecretVaultRepository = class {
23628
23660
  FROM secret_vault v
23629
23661
  WHERE ${REUSED_PREDICATE} ${after}
23630
23662
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
23631
- LIMIT :limit`
23663
+ LIMIT :limit OFFSET :offset`
23632
23664
  ),
23633
23665
  bindParams({
23634
23666
  now,
23635
23667
  limit: limit + 1,
23668
+ offset,
23636
23669
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
23637
23670
  })
23638
23671
  );
@@ -23657,7 +23690,8 @@ var SqliteSecretVaultRepository = class {
23657
23690
  */
23658
23691
  listDerefs(query = {}) {
23659
23692
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
23660
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23693
+ const offset = pageOffset(query.offset);
23694
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23661
23695
  const conditions = [];
23662
23696
  if (query.includeBatched !== true) {
23663
23697
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -23670,21 +23704,28 @@ var SqliteSecretVaultRepository = class {
23670
23704
  this.db.prepare(
23671
23705
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
23672
23706
  FROM secret_vault_deref ${where}
23673
- ORDER BY at DESC, id DESC LIMIT :limit`
23707
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
23674
23708
  ),
23675
23709
  bindParams({
23676
23710
  limit: limit + 1,
23711
+ offset,
23677
23712
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
23678
23713
  })
23679
23714
  );
23680
23715
  const hasMore = rows.length > limit;
23681
23716
  const page = hasMore ? rows.slice(0, limit) : rows;
23682
23717
  const last = page[page.length - 1];
23683
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
23684
- this.db,
23685
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
23686
- );
23718
+ const counts = getRow(
23719
+ this.db.prepare(
23720
+ `SELECT count(*) AS total,
23721
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
23722
+ FROM secret_vault_deref`
23723
+ )
23724
+ ) ?? { total: 0, hidden: 0 };
23725
+ const includeBatched = query.includeBatched === true;
23726
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
23687
23727
  return {
23728
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
23688
23729
  items: page.map((r) => ({
23689
23730
  id: r.id,
23690
23731
  pointerId: r.pointer_id,
@@ -30847,8 +30888,25 @@ function bundledMaskingRules() {
30847
30888
  return ensureBundledPacks() ? getLoadedRules() : null;
30848
30889
  }
30849
30890
 
30891
+ // ../../packages/plugin-sdk/src/regular-file.ts
30892
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30893
+ function notRegularFile(path) {
30894
+ return `not a regular file: ${path}`;
30895
+ }
30896
+ function readRegularFile(path, maxBytes) {
30897
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30898
+ try {
30899
+ const stat2 = fstatSync(fd);
30900
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30901
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30902
+ return readFileSync16(fd, "utf8");
30903
+ } finally {
30904
+ closeSync2(fd);
30905
+ }
30906
+ }
30907
+
30850
30908
  // ../../packages/plugin-sdk/src/repo.ts
30851
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30909
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30852
30910
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30853
30911
  function resolveRepo(cwd) {
30854
30912
  try {
@@ -30927,9 +30985,10 @@ function resolveGitContext(root) {
30927
30985
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30928
30986
  return { configPath: join24(commonGitDir, "config"), headRoot };
30929
30987
  }
30988
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30930
30989
  function safeRead(path) {
30931
30990
  try {
30932
- return readFileSync16(path, "utf8");
30991
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30933
30992
  } catch {
30934
30993
  return void 0;
30935
30994
  }
@@ -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