@akasecurity/ai-tc-copilot 0.9.22 → 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.22",
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",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aka-copilot",
3
- "version": "0.9.22",
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,
@@ -22379,6 +22420,43 @@ var SqliteSecretVaultRepository = class {
22379
22420
  `SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
22380
22421
  );
22381
22422
  }
22423
+ /**
22424
+ * Every entry held, and how many of them are NOT under `currentVersion` — the
22425
+ * standing record of a fingerprint-key rotation whose re-key did not reach
22426
+ * every row.
22427
+ *
22428
+ * This is the durable form of what `SecretVault.refreshFingerprints` reports
22429
+ * once. That count is an event, gone the moment it is printed; this is the
22430
+ * condition, and it stays true until some later rotation re-keys the rows. It
22431
+ * is therefore the one that can answer "is a shortfall still outstanding?" —
22432
+ * including for a rotation run from the CLI, which no dashboard render saw.
22433
+ *
22434
+ * `<>` rather than `<`: a row ahead of the current version is equally
22435
+ * unmatchable, and that is reachable — a key file restored from a backup, or
22436
+ * replaced after being lost, leaves rows stamped higher than the key is.
22437
+ *
22438
+ * Both numbers come from ONE statement, which is why this returns a pair
22439
+ * instead of offering two counts to call. Read separately, a purge landing
22440
+ * between them hands back a `stale` counted over rows the later `total` no
22441
+ * longer includes, and a disclosure built from that pair states a fraction
22442
+ * true of no state of the table — "1 of 0 stored values", or a negative
22443
+ * remainder. Same reasoning as `purgeVault`'s count, which comes from the
22444
+ * delete rather than from a `countEntries` standing beside it.
22445
+ */
22446
+ countFingerprintEpochs(currentVersion) {
22447
+ const row = getRow(
22448
+ this.db.prepare(
22449
+ `SELECT COUNT(*) AS total,
22450
+ COALESCE(
22451
+ SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
22452
+ 0
22453
+ ) AS stale
22454
+ FROM secret_vault`
22455
+ ),
22456
+ { currentVersion }
22457
+ ) ?? { stale: 0, total: 0 };
22458
+ return { stale: row.stale, total: row.total };
22459
+ }
22382
22460
  };
22383
22461
 
22384
22462
  // ../../packages/persistence/src/repositories/security.ts
@@ -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