@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.
package/scripts/sync.js CHANGED
@@ -9656,7 +9656,11 @@ var ListFindingTypesQuery = object({
9656
9656
  // and so is not bounded by what any page happens to hold.
9657
9657
  includeId: string2().optional(),
9658
9658
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
9659
- cursor: string2().optional()
9659
+ cursor: string2().optional(),
9660
+ // A row position to read from, for jumping to a page instead of stepping to
9661
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
9662
+ // from wherever it lands.
9663
+ offset: coerce_exports.number().int().min(0).optional()
9660
9664
  });
9661
9665
  var ListFindingTypesResponse = object({
9662
9666
  totals: object({
@@ -9737,7 +9741,11 @@ var ListFindingInstancesQuery = object({
9737
9741
  sessionId: string2().optional(),
9738
9742
  from: iso_exports.datetime().optional(),
9739
9743
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
9740
- cursor: string2().optional()
9744
+ cursor: string2().optional(),
9745
+ // A row position to read from, for jumping to a page instead of stepping to
9746
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
9747
+ // from wherever it lands.
9748
+ offset: coerce_exports.number().int().min(0).optional()
9741
9749
  });
9742
9750
  var ListFindingInstancesResponse = object({
9743
9751
  // Instances matching the filters across the whole scope, not just this
@@ -9809,7 +9817,11 @@ var ListFindingLocationsQuery = object({
9809
9817
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
9810
9818
  includeId: string2().optional(),
9811
9819
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
9812
- cursor: string2().optional()
9820
+ cursor: string2().optional(),
9821
+ // A row position to read from, for jumping to a page instead of stepping to
9822
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
9823
+ // from wherever it lands.
9824
+ offset: coerce_exports.number().int().min(0).optional()
9813
9825
  });
9814
9826
  var ListFindingLocationsResponse = object({
9815
9827
  totals: object({
@@ -12446,7 +12458,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
12446
12458
  var ListVaultInventoryQuery = object({
12447
12459
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
12448
12460
  // Opaque; names the last row of the page just served.
12449
- cursor: string2().optional()
12461
+ cursor: string2().optional(),
12462
+ // A row position to read from, for jumping to a page instead of stepping to
12463
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
12464
+ // from wherever it lands.
12465
+ offset: coerce_exports.number().int().min(0).optional()
12450
12466
  });
12451
12467
  var ListVaultInventoryResponse = object({
12452
12468
  // Vaulted values across the whole store, not just this page — cursor-
@@ -12458,7 +12474,11 @@ var ListVaultInventoryResponse = object({
12458
12474
  });
12459
12475
  var ListVaultReuseQuery = object({
12460
12476
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
12461
- cursor: string2().optional()
12477
+ cursor: string2().optional(),
12478
+ // A row position to read from, for jumping to a page instead of stepping to
12479
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
12480
+ // from wherever it lands.
12481
+ offset: coerce_exports.number().int().min(0).optional()
12462
12482
  });
12463
12483
  var ListVaultReuseResponse = object({
12464
12484
  // Reused values across the whole store — the number the section's claim
@@ -12474,9 +12494,15 @@ var ListVaultDerefsQuery = object({
12474
12494
  // over a Server Action, which preserves the type, never as a URL param.
12475
12495
  includeBatched: boolean2().optional(),
12476
12496
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
12477
- cursor: string2().optional()
12497
+ cursor: string2().optional(),
12498
+ // A row position to read from, for jumping to a page instead of stepping to
12499
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
12500
+ // from wherever it lands.
12501
+ offset: coerce_exports.number().int().min(0).optional()
12478
12502
  });
12479
12503
  var ListVaultDerefsResponse = object({
12504
+ // Rows this filter selects across the whole trail, not just this page.
12505
+ totals: object({ derefs: number2().int().nonnegative() }),
12480
12506
  items: array(VaultDeref),
12481
12507
  nextCursor: string2().nullable(),
12482
12508
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -21841,7 +21867,7 @@ var SqliteFindingsRepository = class {
21841
21867
  };
21842
21868
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
21843
21869
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
21844
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
21870
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
21845
21871
  const page = sorted.slice(start, start + limit);
21846
21872
  const lastOnPage = page.at(-1);
21847
21873
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -21935,7 +21961,7 @@ var SqliteFindingsRepository = class {
21935
21961
  accumulator.add(row);
21936
21962
  if (!matchesInstanceFilters(row, opts)) continue;
21937
21963
  total += 1;
21938
- if (!isPastCursor(row)) continue;
21964
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
21939
21965
  if (items.length < limit) {
21940
21966
  items.push(toInstanceDetail(row));
21941
21967
  last = row;
@@ -22024,7 +22050,7 @@ var SqliteFindingsRepository = class {
22024
22050
  }
22025
22051
  }
22026
22052
  sorted.sort(compareLocationOrder);
22027
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
22053
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
22028
22054
  const page = sorted.slice(start, start + limit);
22029
22055
  const lastOnPage = page.at(-1);
22030
22056
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -24652,6 +24678,9 @@ function pageLimit(requested, fallback) {
24652
24678
  if (requested === void 0) return fallback;
24653
24679
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
24654
24680
  }
24681
+ function pageOffset(requested) {
24682
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
24683
+ }
24655
24684
  function encodeReuseCursor(payload) {
24656
24685
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
24657
24686
  }
@@ -24999,7 +25028,8 @@ var SqliteSecretVaultRepository = class {
24999
25028
  */
25000
25029
  listInventory(query = {}, now = Date.now()) {
25001
25030
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
25002
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
25031
+ const offset = pageOffset(query.offset);
25032
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
25003
25033
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
25004
25034
  const rows = allRows(
25005
25035
  this.db.prepare(
@@ -25013,11 +25043,12 @@ var SqliteSecretVaultRepository = class {
25013
25043
  FROM secret_vault v
25014
25044
  ${where}
25015
25045
  ORDER BY v.last_seen DESC, v.pointer_id DESC
25016
- LIMIT :limit`
25046
+ LIMIT :limit OFFSET :offset`
25017
25047
  ),
25018
25048
  bindParams({
25019
25049
  now,
25020
25050
  limit: limit + 1,
25051
+ offset,
25021
25052
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
25022
25053
  })
25023
25054
  );
@@ -25041,7 +25072,8 @@ var SqliteSecretVaultRepository = class {
25041
25072
  */
25042
25073
  listReuse(query = {}, now = Date.now()) {
25043
25074
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
25044
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
25075
+ const offset = pageOffset(query.offset);
25076
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
25045
25077
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
25046
25078
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
25047
25079
  const rows = allRows(
@@ -25056,11 +25088,12 @@ var SqliteSecretVaultRepository = class {
25056
25088
  FROM secret_vault v
25057
25089
  WHERE ${REUSED_PREDICATE} ${after}
25058
25090
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
25059
- LIMIT :limit`
25091
+ LIMIT :limit OFFSET :offset`
25060
25092
  ),
25061
25093
  bindParams({
25062
25094
  now,
25063
25095
  limit: limit + 1,
25096
+ offset,
25064
25097
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
25065
25098
  })
25066
25099
  );
@@ -25085,7 +25118,8 @@ var SqliteSecretVaultRepository = class {
25085
25118
  */
25086
25119
  listDerefs(query = {}) {
25087
25120
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
25088
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
25121
+ const offset = pageOffset(query.offset);
25122
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
25089
25123
  const conditions = [];
25090
25124
  if (query.includeBatched !== true) {
25091
25125
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -25098,21 +25132,28 @@ var SqliteSecretVaultRepository = class {
25098
25132
  this.db.prepare(
25099
25133
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
25100
25134
  FROM secret_vault_deref ${where}
25101
- ORDER BY at DESC, id DESC LIMIT :limit`
25135
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
25102
25136
  ),
25103
25137
  bindParams({
25104
25138
  limit: limit + 1,
25139
+ offset,
25105
25140
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
25106
25141
  })
25107
25142
  );
25108
25143
  const hasMore = rows.length > limit;
25109
25144
  const page = hasMore ? rows.slice(0, limit) : rows;
25110
25145
  const last = page[page.length - 1];
25111
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
25112
- this.db,
25113
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
25114
- );
25146
+ const counts = getRow(
25147
+ this.db.prepare(
25148
+ `SELECT count(*) AS total,
25149
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
25150
+ FROM secret_vault_deref`
25151
+ )
25152
+ ) ?? { total: 0, hidden: 0 };
25153
+ const includeBatched = query.includeBatched === true;
25154
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
25115
25155
  return {
25156
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
25116
25157
  items: page.map((r) => ({
25117
25158
  id: r.id,
25118
25159
  pointerId: r.pointer_id,
@@ -33523,8 +33564,25 @@ function bundledMaskingRules() {
33523
33564
  return ensureBundledPacks() ? getLoadedRules() : null;
33524
33565
  }
33525
33566
 
33567
+ // ../../packages/plugin-sdk/src/regular-file.ts
33568
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
33569
+ function notRegularFile(path2) {
33570
+ return `not a regular file: ${path2}`;
33571
+ }
33572
+ function readRegularFile(path2, maxBytes) {
33573
+ const fd = openSync2(path2, constants.O_RDONLY | constants.O_NONBLOCK);
33574
+ try {
33575
+ const stat2 = fstatSync(fd);
33576
+ if (!stat2.isFile()) throw new Error(notRegularFile(path2));
33577
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path2}`);
33578
+ return readFileSync16(fd, "utf8");
33579
+ } finally {
33580
+ closeSync2(fd);
33581
+ }
33582
+ }
33583
+
33526
33584
  // ../../packages/plugin-sdk/src/repo.ts
33527
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
33585
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
33528
33586
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
33529
33587
  function remoteWithoutCredentials(remote) {
33530
33588
  const withoutInfo = withoutUserinfo(remote);
@@ -33635,9 +33693,10 @@ function resolveGitContext(root) {
33635
33693
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
33636
33694
  return { configPath: join24(commonGitDir, "config"), headRoot };
33637
33695
  }
33696
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
33638
33697
  function safeRead(path2) {
33639
33698
  try {
33640
- return readFileSync16(path2, "utf8");
33699
+ return readRegularFile(path2, MAX_GIT_METADATA_BYTES);
33641
33700
  } catch {
33642
33701
  return void 0;
33643
33702
  }
@@ -34258,11 +34317,10 @@ function createGuardedScanner(partition, gateway, opts) {
34258
34317
 
34259
34318
  // ../../packages/plugin-sdk/src/ignore-layers.ts
34260
34319
  var import_ignore = __toESM(require_ignore(), 1);
34261
- import { readFileSync as readFileSync17 } from "fs";
34262
34320
  import { join as join25 } from "path";
34263
34321
  function readIgnoreLayer(dir, filename, anchorLen) {
34264
34322
  try {
34265
- return { matcher: (0, import_ignore.default)().add(readFileSync17(join25(dir, filename), "utf8")), anchorLen };
34323
+ return { matcher: (0, import_ignore.default)().add(readRegularFile(join25(dir, filename))), anchorLen };
34266
34324
  } catch {
34267
34325
  return void 0;
34268
34326
  }
@@ -36506,7 +36564,7 @@ function sessionToolIsKeyed(tool) {
36506
36564
 
36507
36565
  // ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
36508
36566
  import { createHash as createHash12 } from "crypto";
36509
- import { readFileSync as readFileSync19 } from "fs";
36567
+ import { readFileSync as readFileSync18 } from "fs";
36510
36568
  import { join as join29 } from "path";
36511
36569
 
36512
36570
  // ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
@@ -36606,7 +36664,7 @@ async function publishByRename(tmp, file, move = rename2) {
36606
36664
 
36607
36665
  // ../../packages/plugin-runtime/src/attached/capture-settings.ts
36608
36666
  import { randomUUID as randomUUID18 } from "crypto";
36609
- import { readFileSync as readFileSync18 } from "fs";
36667
+ import { readFileSync as readFileSync17 } from "fs";
36610
36668
  import { rm, writeFile as writeFile2 } from "fs/promises";
36611
36669
  import { join as join27 } from "path";
36612
36670
  var HookCaptureSettingsSchema = CaptureSettings.pick({
@@ -37077,7 +37135,7 @@ function machineWideDigest(requests) {
37077
37135
  function readStagedEntries(dataDir2) {
37078
37136
  let parsed2;
37079
37137
  try {
37080
- parsed2 = JSON.parse(readFileSync19(stagedConfigInventoryPath(dataDir2), "utf8"));
37138
+ parsed2 = JSON.parse(readFileSync18(stagedConfigInventoryPath(dataDir2), "utf8"));
37081
37139
  } catch {
37082
37140
  return [];
37083
37141
  }
@@ -37111,7 +37169,7 @@ function readStagedReports(dataDir2) {
37111
37169
  function readDelivered(dataDir2, attachment) {
37112
37170
  const empty = { attachment, reports: {}, global: {} };
37113
37171
  try {
37114
- const parsed2 = JSON.parse(readFileSync19(configInventoryStatePath(dataDir2), "utf8"));
37172
+ const parsed2 = JSON.parse(readFileSync18(configInventoryStatePath(dataDir2), "utf8"));
37115
37173
  if (parsed2?.attachment !== attachment) return empty;
37116
37174
  const reports = {};
37117
37175
  for (const [key, value] of Object.entries(asRecord(parsed2.reports))) {
@@ -37152,7 +37210,7 @@ function asRecord(value) {
37152
37210
  }
37153
37211
 
37154
37212
  // ../../packages/plugin-runtime/src/attached/forward-drops.ts
37155
- import { readFileSync as readFileSync20 } from "fs";
37213
+ import { readFileSync as readFileSync19 } from "fs";
37156
37214
  import { join as join30 } from "path";
37157
37215
  var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
37158
37216
  function forwardDropsPath(dataDir2) {
@@ -37174,7 +37232,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
37174
37232
  }
37175
37233
  function readForwardDrops(dataDir2) {
37176
37234
  try {
37177
- const parsed2 = JSON.parse(readFileSync20(forwardDropsPath(dataDir2), "utf8"));
37235
+ const parsed2 = JSON.parse(readFileSync19(forwardDropsPath(dataDir2), "utf8"));
37178
37236
  if (typeof parsed2 !== "object" || parsed2 === null) return null;
37179
37237
  const record2 = parsed2;
37180
37238
  if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
@@ -38278,7 +38336,7 @@ function toWireInspection(insp, nameKey) {
38278
38336
  }
38279
38337
 
38280
38338
  // ../../packages/plugin-runtime/src/attached/plugin-block.ts
38281
- import { readFileSync as readFileSync21 } from "fs";
38339
+ import { readFileSync as readFileSync20 } from "fs";
38282
38340
 
38283
38341
  // ../../packages/plugin-runtime/src/attached/install-record.ts
38284
38342
  import { readFile as readFile3, stat } from "fs/promises";
@@ -38351,7 +38409,7 @@ async function readInstalledVersionBounded(installRoot) {
38351
38409
  }
38352
38410
 
38353
38411
  // ../../packages/plugin-runtime/src/attached/posture-report-state.ts
38354
- import { readFileSync as readFileSync22 } from "fs";
38412
+ import { readFileSync as readFileSync21 } from "fs";
38355
38413
  import { join as join32 } from "path";
38356
38414
  var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
38357
38415
  var OUTCOME_KEYS = {
@@ -38627,7 +38685,7 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
38627
38685
  }
38628
38686
 
38629
38687
  // ../../packages/plugin-runtime/src/attached/label-drops.ts
38630
- import { readFileSync as readFileSync23 } from "fs";
38688
+ import { readFileSync as readFileSync22 } from "fs";
38631
38689
  import { join as join34 } from "path";
38632
38690
  function path(dataDir2) {
38633
38691
  return join34(dataDir2, ATTACHED_LABEL_SYNC_FILENAME);
@@ -38648,7 +38706,7 @@ function recordUnsendableLabels(dataDir2, count, nowMs) {
38648
38706
  }
38649
38707
  function readUnsendableLabels(dataDir2) {
38650
38708
  try {
38651
- const parsed2 = JSON.parse(readFileSync23(path(dataDir2), "utf8"));
38709
+ const parsed2 = JSON.parse(readFileSync22(path(dataDir2), "utf8"));
38652
38710
  if (typeof parsed2 !== "object" || parsed2 === null) return null;
38653
38711
  const record2 = parsed2;
38654
38712
  if (typeof record2.unsendable !== "number" || !Number.isFinite(record2.unsendable)) return null;
@@ -38661,7 +38719,7 @@ function readUnsendableLabels(dataDir2) {
38661
38719
  }
38662
38720
 
38663
38721
  // ../../packages/plugin-runtime/src/attached/sync-state.ts
38664
- import { readFileSync as readFileSync24 } from "fs";
38722
+ import { readFileSync as readFileSync23 } from "fs";
38665
38723
  import { join as join35 } from "path";
38666
38724
  var SYNC_STATE_FILENAME = ATTACHED_SYNC_STATE_FILENAME;
38667
38725
  function syncStatePath(dataDir2) {
@@ -39277,14 +39335,14 @@ var DISCOVER_SKIP = /* @__PURE__ */ new Set([
39277
39335
  import { basename as basename6, relative as relative3 } from "path";
39278
39336
 
39279
39337
  // ../../packages/scanner/src/scan.ts
39280
- import { existsSync as existsSync13, readFileSync as readFileSync26 } from "fs";
39338
+ import { existsSync as existsSync13, readFileSync as readFileSync25 } from "fs";
39281
39339
  import { dirname as dirname13, extname as extname2, isAbsolute as isAbsolute4, relative as relative5 } from "path";
39282
39340
 
39283
39341
  // ../../packages/scanner/src/manifests.ts
39284
39342
  import { statSync as statSync11 } from "fs";
39285
39343
 
39286
39344
  // ../../packages/scanner/src/walk.ts
39287
- import { readdirSync as readdirSync5, readFileSync as readFileSync25, statSync as statSync10 } from "fs";
39345
+ import { readdirSync as readdirSync5, readFileSync as readFileSync24, statSync as statSync10 } from "fs";
39288
39346
  import { homedir as homedir3 } from "os";
39289
39347
  import { join as join38, relative as relative4, sep as sep7 } from "path";
39290
39348
  var import_ignore2 = __toESM(require_ignore(), 1);
@@ -39412,7 +39470,7 @@ function* walkSourceFiles(opts = {}) {
39412
39470
  if (opts.shouldRead && !opts.shouldRead(meta3)) continue;
39413
39471
  let content;
39414
39472
  try {
39415
- content = readFileSync25(file.path, "utf8");
39473
+ content = readFileSync24(file.path, "utf8");
39416
39474
  } catch {
39417
39475
  continue;
39418
39476
  }
@@ -39860,7 +39918,7 @@ function scanManifests(egress, ledger, updates, rootDir, scopeKeyOf2, onReposito
39860
39918
  }
39861
39919
  let content;
39862
39920
  try {
39863
- content = readFileSync26(manifest.path, "utf8");
39921
+ content = readFileSync25(manifest.path, "utf8");
39864
39922
  } catch {
39865
39923
  continue;
39866
39924
  }
@@ -8782,7 +8782,11 @@ var ListFindingTypesQuery = object({
8782
8782
  // and so is not bounded by what any page happens to hold.
8783
8783
  includeId: string2().optional(),
8784
8784
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8785
- cursor: string2().optional()
8785
+ cursor: string2().optional(),
8786
+ // A row position to read from, for jumping to a page instead of stepping to
8787
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8788
+ // from wherever it lands.
8789
+ offset: coerce_exports.number().int().min(0).optional()
8786
8790
  });
8787
8791
  var ListFindingTypesResponse = object({
8788
8792
  totals: object({
@@ -8863,7 +8867,11 @@ var ListFindingInstancesQuery = object({
8863
8867
  sessionId: string2().optional(),
8864
8868
  from: iso_exports.datetime().optional(),
8865
8869
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8866
- cursor: string2().optional()
8870
+ cursor: string2().optional(),
8871
+ // A row position to read from, for jumping to a page instead of stepping to
8872
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8873
+ // from wherever it lands.
8874
+ offset: coerce_exports.number().int().min(0).optional()
8867
8875
  });
8868
8876
  var ListFindingInstancesResponse = object({
8869
8877
  // Instances matching the filters across the whole scope, not just this
@@ -8935,7 +8943,11 @@ var ListFindingLocationsQuery = object({
8935
8943
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8936
8944
  includeId: string2().optional(),
8937
8945
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8938
- cursor: string2().optional()
8946
+ cursor: string2().optional(),
8947
+ // A row position to read from, for jumping to a page instead of stepping to
8948
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8949
+ // from wherever it lands.
8950
+ offset: coerce_exports.number().int().min(0).optional()
8939
8951
  });
8940
8952
  var ListFindingLocationsResponse = object({
8941
8953
  totals: object({
@@ -11572,7 +11584,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11572
11584
  var ListVaultInventoryQuery = object({
11573
11585
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11574
11586
  // Opaque; names the last row of the page just served.
11575
- cursor: string2().optional()
11587
+ cursor: string2().optional(),
11588
+ // A row position to read from, for jumping to a page instead of stepping to
11589
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11590
+ // from wherever it lands.
11591
+ offset: coerce_exports.number().int().min(0).optional()
11576
11592
  });
11577
11593
  var ListVaultInventoryResponse = object({
11578
11594
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11584,7 +11600,11 @@ var ListVaultInventoryResponse = object({
11584
11600
  });
11585
11601
  var ListVaultReuseQuery = object({
11586
11602
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11587
- cursor: string2().optional()
11603
+ cursor: string2().optional(),
11604
+ // A row position to read from, for jumping to a page instead of stepping to
11605
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11606
+ // from wherever it lands.
11607
+ offset: coerce_exports.number().int().min(0).optional()
11588
11608
  });
11589
11609
  var ListVaultReuseResponse = object({
11590
11610
  // Reused values across the whole store — the number the section's claim
@@ -11600,9 +11620,15 @@ var ListVaultDerefsQuery = object({
11600
11620
  // over a Server Action, which preserves the type, never as a URL param.
11601
11621
  includeBatched: boolean2().optional(),
11602
11622
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11603
- cursor: string2().optional()
11623
+ cursor: string2().optional(),
11624
+ // A row position to read from, for jumping to a page instead of stepping to
11625
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11626
+ // from wherever it lands.
11627
+ offset: coerce_exports.number().int().min(0).optional()
11604
11628
  });
11605
11629
  var ListVaultDerefsResponse = object({
11630
+ // Rows this filter selects across the whole trail, not just this page.
11631
+ totals: object({ derefs: number2().int().nonnegative() }),
11606
11632
  items: array(VaultDeref),
11607
11633
  nextCursor: string2().nullable(),
11608
11634
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -25166,7 +25192,7 @@ var SqliteFindingsRepository = class {
25166
25192
  };
25167
25193
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
25168
25194
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
25169
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
25195
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
25170
25196
  const page = sorted.slice(start, start + limit);
25171
25197
  const lastOnPage = page.at(-1);
25172
25198
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -25260,7 +25286,7 @@ var SqliteFindingsRepository = class {
25260
25286
  accumulator.add(row);
25261
25287
  if (!matchesInstanceFilters(row, opts)) continue;
25262
25288
  total += 1;
25263
- if (!isPastCursor(row)) continue;
25289
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
25264
25290
  if (items.length < limit) {
25265
25291
  items.push(toInstanceDetail(row));
25266
25292
  last = row;
@@ -25349,7 +25375,7 @@ var SqliteFindingsRepository = class {
25349
25375
  }
25350
25376
  }
25351
25377
  sorted.sort(compareLocationOrder);
25352
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
25378
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
25353
25379
  const page = sorted.slice(start, start + limit);
25354
25380
  const lastOnPage = page.at(-1);
25355
25381
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -27977,6 +28003,9 @@ function pageLimit(requested, fallback) {
27977
28003
  if (requested === void 0) return fallback;
27978
28004
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
27979
28005
  }
28006
+ function pageOffset(requested) {
28007
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
28008
+ }
27980
28009
  function encodeReuseCursor(payload) {
27981
28010
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
27982
28011
  }
@@ -28324,7 +28353,8 @@ var SqliteSecretVaultRepository = class {
28324
28353
  */
28325
28354
  listInventory(query = {}, now = Date.now()) {
28326
28355
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28327
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28356
+ const offset = pageOffset(query.offset);
28357
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28328
28358
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
28329
28359
  const rows = allRows(
28330
28360
  this.db.prepare(
@@ -28338,11 +28368,12 @@ var SqliteSecretVaultRepository = class {
28338
28368
  FROM secret_vault v
28339
28369
  ${where}
28340
28370
  ORDER BY v.last_seen DESC, v.pointer_id DESC
28341
- LIMIT :limit`
28371
+ LIMIT :limit OFFSET :offset`
28342
28372
  ),
28343
28373
  bindParams({
28344
28374
  now,
28345
28375
  limit: limit + 1,
28376
+ offset,
28346
28377
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
28347
28378
  })
28348
28379
  );
@@ -28366,7 +28397,8 @@ var SqliteSecretVaultRepository = class {
28366
28397
  */
28367
28398
  listReuse(query = {}, now = Date.now()) {
28368
28399
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
28369
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
28400
+ const offset = pageOffset(query.offset);
28401
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
28370
28402
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
28371
28403
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
28372
28404
  const rows = allRows(
@@ -28381,11 +28413,12 @@ var SqliteSecretVaultRepository = class {
28381
28413
  FROM secret_vault v
28382
28414
  WHERE ${REUSED_PREDICATE} ${after}
28383
28415
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
28384
- LIMIT :limit`
28416
+ LIMIT :limit OFFSET :offset`
28385
28417
  ),
28386
28418
  bindParams({
28387
28419
  now,
28388
28420
  limit: limit + 1,
28421
+ offset,
28389
28422
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
28390
28423
  })
28391
28424
  );
@@ -28410,7 +28443,8 @@ var SqliteSecretVaultRepository = class {
28410
28443
  */
28411
28444
  listDerefs(query = {}) {
28412
28445
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
28413
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
28446
+ const offset = pageOffset(query.offset);
28447
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
28414
28448
  const conditions = [];
28415
28449
  if (query.includeBatched !== true) {
28416
28450
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -28423,21 +28457,28 @@ var SqliteSecretVaultRepository = class {
28423
28457
  this.db.prepare(
28424
28458
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
28425
28459
  FROM secret_vault_deref ${where}
28426
- ORDER BY at DESC, id DESC LIMIT :limit`
28460
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
28427
28461
  ),
28428
28462
  bindParams({
28429
28463
  limit: limit + 1,
28464
+ offset,
28430
28465
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
28431
28466
  })
28432
28467
  );
28433
28468
  const hasMore = rows.length > limit;
28434
28469
  const page = hasMore ? rows.slice(0, limit) : rows;
28435
28470
  const last = page[page.length - 1];
28436
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
28437
- this.db,
28438
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
28439
- );
28471
+ const counts = getRow(
28472
+ this.db.prepare(
28473
+ `SELECT count(*) AS total,
28474
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
28475
+ FROM secret_vault_deref`
28476
+ )
28477
+ ) ?? { total: 0, hidden: 0 };
28478
+ const includeBatched = query.includeBatched === true;
28479
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
28440
28480
  return {
28481
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
28441
28482
  items: page.map((r) => ({
28442
28483
  id: r.id,
28443
28484
  pointerId: r.pointer_id,
@@ -30898,8 +30939,25 @@ function bundledMaskingRules() {
30898
30939
  return ensureBundledPacks() ? getLoadedRules() : null;
30899
30940
  }
30900
30941
 
30942
+ // ../../packages/plugin-sdk/src/regular-file.ts
30943
+ import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
30944
+ function notRegularFile(path) {
30945
+ return `not a regular file: ${path}`;
30946
+ }
30947
+ function readRegularFile(path, maxBytes) {
30948
+ const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
30949
+ try {
30950
+ const stat2 = fstatSync(fd);
30951
+ if (!stat2.isFile()) throw new Error(notRegularFile(path));
30952
+ if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
30953
+ return readFileSync16(fd, "utf8");
30954
+ } finally {
30955
+ closeSync2(fd);
30956
+ }
30957
+ }
30958
+
30901
30959
  // ../../packages/plugin-sdk/src/repo.ts
30902
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync7 } from "fs";
30960
+ import { existsSync as existsSync9, statSync as statSync7 } from "fs";
30903
30961
  import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
30904
30962
  function remoteWithoutCredentials(remote) {
30905
30963
  const withoutInfo = withoutUserinfo(remote);
@@ -30988,9 +31046,10 @@ function resolveGitContext(root) {
30988
31046
  const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
30989
31047
  return { configPath: join24(commonGitDir, "config"), headRoot };
30990
31048
  }
31049
+ var MAX_GIT_METADATA_BYTES = 1024 * 1024;
30991
31050
  function safeRead(path) {
30992
31051
  try {
30993
- return readFileSync16(path, "utf8");
31052
+ return readRegularFile(path, MAX_GIT_METADATA_BYTES);
30994
31053
  } catch {
30995
31054
  return void 0;
30996
31055
  }