@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akasecurity/ai-tc-copilot",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in GitHub Copilot",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,12 +28,12 @@
28
28
  "typescript": "^5.8.0",
29
29
  "vitest": "^4.1.12",
30
30
  "@akasecurity/eslint-config": "0.8.0",
31
- "@akasecurity/persistence": "0.8.0",
32
31
  "@akasecurity/plugin-runtime": "0.8.0",
32
+ "@akasecurity/persistence": "0.8.0",
33
+ "@akasecurity/plugin-sdk": "0.8.0",
33
34
  "@akasecurity/scanner": "0.8.0",
34
35
  "@akasecurity/schema": "0.8.0",
35
- "@akasecurity/setup-wizard": "0.8.0",
36
- "@akasecurity/plugin-sdk": "0.8.0"
36
+ "@akasecurity/setup-wizard": "0.8.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsup",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aka-copilot",
3
- "version": "0.9.23",
3
+ "version": "0.9.24",
4
4
  "description": "AI Traffic Control — inspect and govern AI prompts in GitHub Copilot. Detection runs locally; events are recorded to a local SQLite store on your machine.",
5
5
  "hooks": "./hooks.json",
6
6
  "skills": "./skills",
@@ -8757,7 +8757,11 @@ var ListFindingTypesQuery = object({
8757
8757
  // and so is not bounded by what any page happens to hold.
8758
8758
  includeId: string2().optional(),
8759
8759
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8760
- cursor: string2().optional()
8760
+ cursor: string2().optional(),
8761
+ // A row position to read from, for jumping to a page instead of stepping to
8762
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8763
+ // from wherever it lands.
8764
+ offset: coerce_exports.number().int().min(0).optional()
8761
8765
  });
8762
8766
  var ListFindingTypesResponse = object({
8763
8767
  totals: object({
@@ -8838,7 +8842,11 @@ var ListFindingInstancesQuery = object({
8838
8842
  sessionId: string2().optional(),
8839
8843
  from: iso_exports.datetime().optional(),
8840
8844
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8841
- cursor: string2().optional()
8845
+ cursor: string2().optional(),
8846
+ // A row position to read from, for jumping to a page instead of stepping to
8847
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8848
+ // from wherever it lands.
8849
+ offset: coerce_exports.number().int().min(0).optional()
8842
8850
  });
8843
8851
  var ListFindingInstancesResponse = object({
8844
8852
  // Instances matching the filters across the whole scope, not just this
@@ -8910,7 +8918,11 @@ var ListFindingLocationsQuery = object({
8910
8918
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8911
8919
  includeId: string2().optional(),
8912
8920
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8913
- cursor: string2().optional()
8921
+ cursor: string2().optional(),
8922
+ // A row position to read from, for jumping to a page instead of stepping to
8923
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8924
+ // from wherever it lands.
8925
+ offset: coerce_exports.number().int().min(0).optional()
8914
8926
  });
8915
8927
  var ListFindingLocationsResponse = object({
8916
8928
  totals: object({
@@ -11399,7 +11411,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11399
11411
  var ListVaultInventoryQuery = object({
11400
11412
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11401
11413
  // Opaque; names the last row of the page just served.
11402
- cursor: string2().optional()
11414
+ cursor: string2().optional(),
11415
+ // A row position to read from, for jumping to a page instead of stepping to
11416
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11417
+ // from wherever it lands.
11418
+ offset: coerce_exports.number().int().min(0).optional()
11403
11419
  });
11404
11420
  var ListVaultInventoryResponse = object({
11405
11421
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11411,7 +11427,11 @@ var ListVaultInventoryResponse = object({
11411
11427
  });
11412
11428
  var ListVaultReuseQuery = object({
11413
11429
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11414
- cursor: string2().optional()
11430
+ cursor: string2().optional(),
11431
+ // A row position to read from, for jumping to a page instead of stepping to
11432
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11433
+ // from wherever it lands.
11434
+ offset: coerce_exports.number().int().min(0).optional()
11415
11435
  });
11416
11436
  var ListVaultReuseResponse = object({
11417
11437
  // Reused values across the whole store — the number the section's claim
@@ -11427,9 +11447,15 @@ var ListVaultDerefsQuery = object({
11427
11447
  // over a Server Action, which preserves the type, never as a URL param.
11428
11448
  includeBatched: boolean2().optional(),
11429
11449
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11430
- cursor: string2().optional()
11450
+ cursor: string2().optional(),
11451
+ // A row position to read from, for jumping to a page instead of stepping to
11452
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11453
+ // from wherever it lands.
11454
+ offset: coerce_exports.number().int().min(0).optional()
11431
11455
  });
11432
11456
  var ListVaultDerefsResponse = object({
11457
+ // Rows this filter selects across the whole trail, not just this page.
11458
+ totals: object({ derefs: number2().int().nonnegative() }),
11433
11459
  items: array(VaultDeref),
11434
11460
  nextCursor: string2().nullable(),
11435
11461
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -19083,7 +19109,7 @@ var SqliteFindingsRepository = class {
19083
19109
  };
19084
19110
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
19085
19111
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
19086
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
19112
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
19087
19113
  const page = sorted.slice(start, start + limit);
19088
19114
  const lastOnPage = page.at(-1);
19089
19115
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -19177,7 +19203,7 @@ var SqliteFindingsRepository = class {
19177
19203
  accumulator.add(row);
19178
19204
  if (!matchesInstanceFilters(row, opts)) continue;
19179
19205
  total += 1;
19180
- if (!isPastCursor(row)) continue;
19206
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
19181
19207
  if (items.length < limit) {
19182
19208
  items.push(toInstanceDetail(row));
19183
19209
  last = row;
@@ -19266,7 +19292,7 @@ var SqliteFindingsRepository = class {
19266
19292
  }
19267
19293
  }
19268
19294
  sorted.sort(compareLocationOrder);
19269
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
19295
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
19270
19296
  const page = sorted.slice(start, start + limit);
19271
19297
  const lastOnPage = page.at(-1);
19272
19298
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -21894,6 +21920,9 @@ function pageLimit(requested, fallback) {
21894
21920
  if (requested === void 0) return fallback;
21895
21921
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
21896
21922
  }
21923
+ function pageOffset(requested) {
21924
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
21925
+ }
21897
21926
  function encodeReuseCursor(payload) {
21898
21927
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
21899
21928
  }
@@ -22241,7 +22270,8 @@ var SqliteSecretVaultRepository = class {
22241
22270
  */
22242
22271
  listInventory(query = {}, now = Date.now()) {
22243
22272
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22244
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22273
+ const offset = pageOffset(query.offset);
22274
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22245
22275
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
22246
22276
  const rows = allRows(
22247
22277
  this.db.prepare(
@@ -22255,11 +22285,12 @@ var SqliteSecretVaultRepository = class {
22255
22285
  FROM secret_vault v
22256
22286
  ${where}
22257
22287
  ORDER BY v.last_seen DESC, v.pointer_id DESC
22258
- LIMIT :limit`
22288
+ LIMIT :limit OFFSET :offset`
22259
22289
  ),
22260
22290
  bindParams({
22261
22291
  now,
22262
22292
  limit: limit + 1,
22293
+ offset,
22263
22294
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
22264
22295
  })
22265
22296
  );
@@ -22283,7 +22314,8 @@ var SqliteSecretVaultRepository = class {
22283
22314
  */
22284
22315
  listReuse(query = {}, now = Date.now()) {
22285
22316
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
22286
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
22317
+ const offset = pageOffset(query.offset);
22318
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
22287
22319
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
22288
22320
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
22289
22321
  const rows = allRows(
@@ -22298,11 +22330,12 @@ var SqliteSecretVaultRepository = class {
22298
22330
  FROM secret_vault v
22299
22331
  WHERE ${REUSED_PREDICATE} ${after}
22300
22332
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
22301
- LIMIT :limit`
22333
+ LIMIT :limit OFFSET :offset`
22302
22334
  ),
22303
22335
  bindParams({
22304
22336
  now,
22305
22337
  limit: limit + 1,
22338
+ offset,
22306
22339
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
22307
22340
  })
22308
22341
  );
@@ -22327,7 +22360,8 @@ var SqliteSecretVaultRepository = class {
22327
22360
  */
22328
22361
  listDerefs(query = {}) {
22329
22362
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
22330
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
22363
+ const offset = pageOffset(query.offset);
22364
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
22331
22365
  const conditions = [];
22332
22366
  if (query.includeBatched !== true) {
22333
22367
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -22340,21 +22374,28 @@ var SqliteSecretVaultRepository = class {
22340
22374
  this.db.prepare(
22341
22375
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
22342
22376
  FROM secret_vault_deref ${where}
22343
- ORDER BY at DESC, id DESC LIMIT :limit`
22377
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
22344
22378
  ),
22345
22379
  bindParams({
22346
22380
  limit: limit + 1,
22381
+ offset,
22347
22382
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
22348
22383
  })
22349
22384
  );
22350
22385
  const hasMore = rows.length > limit;
22351
22386
  const page = hasMore ? rows.slice(0, limit) : rows;
22352
22387
  const last = page[page.length - 1];
22353
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
22354
- this.db,
22355
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
22356
- );
22388
+ const counts = getRow(
22389
+ this.db.prepare(
22390
+ `SELECT count(*) AS total,
22391
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
22392
+ FROM secret_vault_deref`
22393
+ )
22394
+ ) ?? { total: 0, hidden: 0 };
22395
+ const includeBatched = query.includeBatched === true;
22396
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
22357
22397
  return {
22398
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
22358
22399
  items: page.map((r) => ({
22359
22400
  id: r.id,
22360
22401
  pointerId: r.pointer_id,
@@ -8334,7 +8334,11 @@ var ListFindingTypesQuery = object({
8334
8334
  // and so is not bounded by what any page happens to hold.
8335
8335
  includeId: string2().optional(),
8336
8336
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8337
- cursor: string2().optional()
8337
+ cursor: string2().optional(),
8338
+ // A row position to read from, for jumping to a page instead of stepping to
8339
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8340
+ // from wherever it lands.
8341
+ offset: coerce_exports.number().int().min(0).optional()
8338
8342
  });
8339
8343
  var ListFindingTypesResponse = object({
8340
8344
  totals: object({
@@ -8414,7 +8418,11 @@ var ListFindingInstancesQuery = object({
8414
8418
  sessionId: string2().optional(),
8415
8419
  from: iso_exports.datetime().optional(),
8416
8420
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8417
- cursor: string2().optional()
8421
+ cursor: string2().optional(),
8422
+ // A row position to read from, for jumping to a page instead of stepping to
8423
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8424
+ // from wherever it lands.
8425
+ offset: coerce_exports.number().int().min(0).optional()
8418
8426
  });
8419
8427
  var ListFindingInstancesResponse = object({
8420
8428
  // Instances matching the filters across the whole scope, not just this
@@ -8485,7 +8493,11 @@ var ListFindingLocationsQuery = object({
8485
8493
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8486
8494
  includeId: string2().optional(),
8487
8495
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8488
- cursor: string2().optional()
8496
+ cursor: string2().optional(),
8497
+ // A row position to read from, for jumping to a page instead of stepping to
8498
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8499
+ // from wherever it lands.
8500
+ offset: coerce_exports.number().int().min(0).optional()
8489
8501
  });
8490
8502
  var ListFindingLocationsResponse = object({
8491
8503
  totals: object({
@@ -10885,7 +10897,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
10885
10897
  var ListVaultInventoryQuery = object({
10886
10898
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10887
10899
  // Opaque; names the last row of the page just served.
10888
- cursor: string2().optional()
10900
+ cursor: string2().optional(),
10901
+ // A row position to read from, for jumping to a page instead of stepping to
10902
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10903
+ // from wherever it lands.
10904
+ offset: coerce_exports.number().int().min(0).optional()
10889
10905
  });
10890
10906
  var ListVaultInventoryResponse = object({
10891
10907
  // Vaulted values across the whole store, not just this page — cursor-
@@ -10897,7 +10913,11 @@ var ListVaultInventoryResponse = object({
10897
10913
  });
10898
10914
  var ListVaultReuseQuery = object({
10899
10915
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10900
- cursor: string2().optional()
10916
+ cursor: string2().optional(),
10917
+ // A row position to read from, for jumping to a page instead of stepping to
10918
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10919
+ // from wherever it lands.
10920
+ offset: coerce_exports.number().int().min(0).optional()
10901
10921
  });
10902
10922
  var ListVaultReuseResponse = object({
10903
10923
  // Reused values across the whole store — the number the section's claim
@@ -10913,9 +10933,15 @@ var ListVaultDerefsQuery = object({
10913
10933
  // over a Server Action, which preserves the type, never as a URL param.
10914
10934
  includeBatched: boolean2().optional(),
10915
10935
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
10916
- cursor: string2().optional()
10936
+ cursor: string2().optional(),
10937
+ // A row position to read from, for jumping to a page instead of stepping to
10938
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
10939
+ // from wherever it lands.
10940
+ offset: coerce_exports.number().int().min(0).optional()
10917
10941
  });
10918
10942
  var ListVaultDerefsResponse = object({
10943
+ // Rows this filter selects across the whole trail, not just this page.
10944
+ totals: object({ derefs: number2().int().nonnegative() }),
10919
10945
  items: array(VaultDeref),
10920
10946
  nextCursor: string2().nullable(),
10921
10947
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -8763,7 +8763,11 @@ var ListFindingTypesQuery = object({
8763
8763
  // and so is not bounded by what any page happens to hold.
8764
8764
  includeId: string2().optional(),
8765
8765
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
8766
- cursor: string2().optional()
8766
+ cursor: string2().optional(),
8767
+ // A row position to read from, for jumping to a page instead of stepping to
8768
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8769
+ // from wherever it lands.
8770
+ offset: coerce_exports.number().int().min(0).optional()
8767
8771
  });
8768
8772
  var ListFindingTypesResponse = object({
8769
8773
  totals: object({
@@ -8844,7 +8848,11 @@ var ListFindingInstancesQuery = object({
8844
8848
  sessionId: string2().optional(),
8845
8849
  from: iso_exports.datetime().optional(),
8846
8850
  limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
8847
- cursor: string2().optional()
8851
+ cursor: string2().optional(),
8852
+ // A row position to read from, for jumping to a page instead of stepping to
8853
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8854
+ // from wherever it lands.
8855
+ offset: coerce_exports.number().int().min(0).optional()
8848
8856
  });
8849
8857
  var ListFindingInstancesResponse = object({
8850
8858
  // Instances matching the filters across the whole scope, not just this
@@ -8916,7 +8924,11 @@ var ListFindingLocationsQuery = object({
8916
8924
  // rather than a deep-link corner. Never affects totals, facets or the cursor.
8917
8925
  includeId: string2().optional(),
8918
8926
  limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
8919
- cursor: string2().optional()
8927
+ cursor: string2().optional(),
8928
+ // A row position to read from, for jumping to a page instead of stepping to
8929
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
8930
+ // from wherever it lands.
8931
+ offset: coerce_exports.number().int().min(0).optional()
8920
8932
  });
8921
8933
  var ListFindingLocationsResponse = object({
8922
8934
  totals: object({
@@ -11469,7 +11481,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
11469
11481
  var ListVaultInventoryQuery = object({
11470
11482
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11471
11483
  // Opaque; names the last row of the page just served.
11472
- cursor: string2().optional()
11484
+ cursor: string2().optional(),
11485
+ // A row position to read from, for jumping to a page instead of stepping to
11486
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11487
+ // from wherever it lands.
11488
+ offset: coerce_exports.number().int().min(0).optional()
11473
11489
  });
11474
11490
  var ListVaultInventoryResponse = object({
11475
11491
  // Vaulted values across the whole store, not just this page — cursor-
@@ -11481,7 +11497,11 @@ var ListVaultInventoryResponse = object({
11481
11497
  });
11482
11498
  var ListVaultReuseQuery = object({
11483
11499
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11484
- cursor: string2().optional()
11500
+ cursor: string2().optional(),
11501
+ // A row position to read from, for jumping to a page instead of stepping to
11502
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11503
+ // from wherever it lands.
11504
+ offset: coerce_exports.number().int().min(0).optional()
11485
11505
  });
11486
11506
  var ListVaultReuseResponse = object({
11487
11507
  // Reused values across the whole store — the number the section's claim
@@ -11497,9 +11517,15 @@ var ListVaultDerefsQuery = object({
11497
11517
  // over a Server Action, which preserves the type, never as a URL param.
11498
11518
  includeBatched: boolean2().optional(),
11499
11519
  limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
11500
- cursor: string2().optional()
11520
+ cursor: string2().optional(),
11521
+ // A row position to read from, for jumping to a page instead of stepping to
11522
+ // it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
11523
+ // from wherever it lands.
11524
+ offset: coerce_exports.number().int().min(0).optional()
11501
11525
  });
11502
11526
  var ListVaultDerefsResponse = object({
11527
+ // Rows this filter selects across the whole trail, not just this page.
11528
+ totals: object({ derefs: number2().int().nonnegative() }),
11503
11529
  items: array(VaultDeref),
11504
11530
  nextCursor: string2().nullable(),
11505
11531
  // Display/view-render rows the query hid, over the WHOLE trail rather than
@@ -19871,7 +19897,7 @@ var SqliteFindingsRepository = class {
19871
19897
  };
19872
19898
  const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
19873
19899
  const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
19874
- const start = cursor === null ? 0 : firstAfter(sorted, cursor);
19900
+ const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
19875
19901
  const page = sorted.slice(start, start + limit);
19876
19902
  const lastOnPage = page.at(-1);
19877
19903
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
@@ -19965,7 +19991,7 @@ var SqliteFindingsRepository = class {
19965
19991
  accumulator.add(row);
19966
19992
  if (!matchesInstanceFilters(row, opts)) continue;
19967
19993
  total += 1;
19968
- if (!isPastCursor(row)) continue;
19994
+ if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
19969
19995
  if (items.length < limit) {
19970
19996
  items.push(toInstanceDetail(row));
19971
19997
  last = row;
@@ -20054,7 +20080,7 @@ var SqliteFindingsRepository = class {
20054
20080
  }
20055
20081
  }
20056
20082
  sorted.sort(compareLocationOrder);
20057
- const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
20083
+ const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
20058
20084
  const page = sorted.slice(start, start + limit);
20059
20085
  const lastOnPage = page.at(-1);
20060
20086
  const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
@@ -22682,6 +22708,9 @@ function pageLimit(requested, fallback) {
22682
22708
  if (requested === void 0) return fallback;
22683
22709
  return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
22684
22710
  }
22711
+ function pageOffset(requested) {
22712
+ return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
22713
+ }
22685
22714
  function encodeReuseCursor(payload) {
22686
22715
  return Buffer.from(JSON.stringify(payload)).toString("base64url");
22687
22716
  }
@@ -23029,7 +23058,8 @@ var SqliteSecretVaultRepository = class {
23029
23058
  */
23030
23059
  listInventory(query = {}, now = Date.now()) {
23031
23060
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23032
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23061
+ const offset = pageOffset(query.offset);
23062
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23033
23063
  const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
23034
23064
  const rows = allRows(
23035
23065
  this.db.prepare(
@@ -23043,11 +23073,12 @@ var SqliteSecretVaultRepository = class {
23043
23073
  FROM secret_vault v
23044
23074
  ${where}
23045
23075
  ORDER BY v.last_seen DESC, v.pointer_id DESC
23046
- LIMIT :limit`
23076
+ LIMIT :limit OFFSET :offset`
23047
23077
  ),
23048
23078
  bindParams({
23049
23079
  now,
23050
23080
  limit: limit + 1,
23081
+ offset,
23051
23082
  ...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
23052
23083
  })
23053
23084
  );
@@ -23071,7 +23102,8 @@ var SqliteSecretVaultRepository = class {
23071
23102
  */
23072
23103
  listReuse(query = {}, now = Date.now()) {
23073
23104
  const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
23074
- const cursor = query.cursor === void 0 ? null : decodeReuseCursor(query.cursor);
23105
+ const offset = pageOffset(query.offset);
23106
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
23075
23107
  const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
23076
23108
  OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
23077
23109
  const rows = allRows(
@@ -23086,11 +23118,12 @@ var SqliteSecretVaultRepository = class {
23086
23118
  FROM secret_vault v
23087
23119
  WHERE ${REUSED_PREDICATE} ${after}
23088
23120
  ORDER BY v.occurrence_count DESC, v.pointer_id DESC
23089
- LIMIT :limit`
23121
+ LIMIT :limit OFFSET :offset`
23090
23122
  ),
23091
23123
  bindParams({
23092
23124
  now,
23093
23125
  limit: limit + 1,
23126
+ offset,
23094
23127
  ...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
23095
23128
  })
23096
23129
  );
@@ -23115,7 +23148,8 @@ var SqliteSecretVaultRepository = class {
23115
23148
  */
23116
23149
  listDerefs(query = {}) {
23117
23150
  const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
23118
- const cursor = query.cursor === void 0 ? null : decodeKeysetCursor(query.cursor);
23151
+ const offset = pageOffset(query.offset);
23152
+ const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
23119
23153
  const conditions = [];
23120
23154
  if (query.includeBatched !== true) {
23121
23155
  conditions.push(`reason NOT IN ('display', 'view-render')`);
@@ -23128,21 +23162,28 @@ var SqliteSecretVaultRepository = class {
23128
23162
  this.db.prepare(
23129
23163
  `SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
23130
23164
  FROM secret_vault_deref ${where}
23131
- ORDER BY at DESC, id DESC LIMIT :limit`
23165
+ ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
23132
23166
  ),
23133
23167
  bindParams({
23134
23168
  limit: limit + 1,
23169
+ offset,
23135
23170
  ...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
23136
23171
  })
23137
23172
  );
23138
23173
  const hasMore = rows.length > limit;
23139
23174
  const page = hasMore ? rows.slice(0, limit) : rows;
23140
23175
  const last = page[page.length - 1];
23141
- const hiddenBatched = query.includeBatched === true ? 0 : countScalar(
23142
- this.db,
23143
- `SELECT count(*) AS n FROM secret_vault_deref WHERE reason IN ('display', 'view-render')`
23144
- );
23176
+ const counts = getRow(
23177
+ this.db.prepare(
23178
+ `SELECT count(*) AS total,
23179
+ count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
23180
+ FROM secret_vault_deref`
23181
+ )
23182
+ ) ?? { total: 0, hidden: 0 };
23183
+ const includeBatched = query.includeBatched === true;
23184
+ const hiddenBatched = includeBatched ? 0 : counts.hidden;
23145
23185
  return {
23186
+ totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
23146
23187
  items: page.map((r) => ({
23147
23188
  id: r.id,
23148
23189
  pointerId: r.pointer_id,