@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.
- package/.codex-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/apply-suppressions.js +60 -19
- package/scripts/backfill.js +83 -24
- package/scripts/content-retention.js +60 -19
- package/scripts/filescan.js +94 -36
- package/scripts/firstrun.js +74 -32
- package/scripts/history-sync.js +60 -19
- package/scripts/intro.js +32 -6
- package/scripts/onboard.js +60 -19
- package/scripts/post-tool-use.js +97 -38
- package/scripts/pre-tool-use.js +97 -38
- package/scripts/query.js +73 -31
- package/scripts/reconcile.js +95 -36
- package/scripts/remediate.js +80 -21
- package/scripts/scan-worker.js +32 -6
- package/scripts/session-start.js +134 -72
- package/scripts/start-light.js +32 -6
- package/scripts/stop.js +78 -36
- package/scripts/sync.js +96 -38
- package/scripts/user-prompt-submit.js +103 -44
package/scripts/query.js
CHANGED
|
@@ -8931,7 +8931,11 @@ var ListFindingTypesQuery = object({
|
|
|
8931
8931
|
// and so is not bounded by what any page happens to hold.
|
|
8932
8932
|
includeId: string2().optional(),
|
|
8933
8933
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8934
|
-
cursor: string2().optional()
|
|
8934
|
+
cursor: string2().optional(),
|
|
8935
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8936
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8937
|
+
// from wherever it lands.
|
|
8938
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8935
8939
|
});
|
|
8936
8940
|
var ListFindingTypesResponse = object({
|
|
8937
8941
|
totals: object({
|
|
@@ -9012,7 +9016,11 @@ var ListFindingInstancesQuery = object({
|
|
|
9012
9016
|
sessionId: string2().optional(),
|
|
9013
9017
|
from: iso_exports.datetime().optional(),
|
|
9014
9018
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
9015
|
-
cursor: string2().optional()
|
|
9019
|
+
cursor: string2().optional(),
|
|
9020
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9021
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9022
|
+
// from wherever it lands.
|
|
9023
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9016
9024
|
});
|
|
9017
9025
|
var ListFindingInstancesResponse = object({
|
|
9018
9026
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -9084,7 +9092,11 @@ var ListFindingLocationsQuery = object({
|
|
|
9084
9092
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
9085
9093
|
includeId: string2().optional(),
|
|
9086
9094
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
9087
|
-
cursor: string2().optional()
|
|
9095
|
+
cursor: string2().optional(),
|
|
9096
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9097
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9098
|
+
// from wherever it lands.
|
|
9099
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9088
9100
|
});
|
|
9089
9101
|
var ListFindingLocationsResponse = object({
|
|
9090
9102
|
totals: object({
|
|
@@ -11721,7 +11733,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11721
11733
|
var ListVaultInventoryQuery = object({
|
|
11722
11734
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11723
11735
|
// Opaque; names the last row of the page just served.
|
|
11724
|
-
cursor: string2().optional()
|
|
11736
|
+
cursor: string2().optional(),
|
|
11737
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11738
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11739
|
+
// from wherever it lands.
|
|
11740
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11725
11741
|
});
|
|
11726
11742
|
var ListVaultInventoryResponse = object({
|
|
11727
11743
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11733,7 +11749,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11733
11749
|
});
|
|
11734
11750
|
var ListVaultReuseQuery = object({
|
|
11735
11751
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11736
|
-
cursor: string2().optional()
|
|
11752
|
+
cursor: string2().optional(),
|
|
11753
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11754
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11755
|
+
// from wherever it lands.
|
|
11756
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11737
11757
|
});
|
|
11738
11758
|
var ListVaultReuseResponse = object({
|
|
11739
11759
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11749,9 +11769,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11749
11769
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11750
11770
|
includeBatched: boolean2().optional(),
|
|
11751
11771
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11752
|
-
cursor: string2().optional()
|
|
11772
|
+
cursor: string2().optional(),
|
|
11773
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11774
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11775
|
+
// from wherever it lands.
|
|
11776
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11753
11777
|
});
|
|
11754
11778
|
var ListVaultDerefsResponse = object({
|
|
11779
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11780
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11755
11781
|
items: array(VaultDeref),
|
|
11756
11782
|
nextCursor: string2().nullable(),
|
|
11757
11783
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -20566,7 +20592,7 @@ var SqliteFindingsRepository = class {
|
|
|
20566
20592
|
};
|
|
20567
20593
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
20568
20594
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
20569
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
20595
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
20570
20596
|
const page = sorted.slice(start, start + limit);
|
|
20571
20597
|
const lastOnPage = page.at(-1);
|
|
20572
20598
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -20660,7 +20686,7 @@ var SqliteFindingsRepository = class {
|
|
|
20660
20686
|
accumulator.add(row);
|
|
20661
20687
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
20662
20688
|
total += 1;
|
|
20663
|
-
if (!isPastCursor(row)) continue;
|
|
20689
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
20664
20690
|
if (items.length < limit) {
|
|
20665
20691
|
items.push(toInstanceDetail(row));
|
|
20666
20692
|
last = row;
|
|
@@ -20749,7 +20775,7 @@ var SqliteFindingsRepository = class {
|
|
|
20749
20775
|
}
|
|
20750
20776
|
}
|
|
20751
20777
|
sorted.sort(compareLocationOrder);
|
|
20752
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
20778
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
20753
20779
|
const page = sorted.slice(start, start + limit);
|
|
20754
20780
|
const lastOnPage = page.at(-1);
|
|
20755
20781
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -23377,6 +23403,9 @@ function pageLimit(requested, fallback) {
|
|
|
23377
23403
|
if (requested === void 0) return fallback;
|
|
23378
23404
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
23379
23405
|
}
|
|
23406
|
+
function pageOffset(requested) {
|
|
23407
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
23408
|
+
}
|
|
23380
23409
|
function encodeReuseCursor(payload) {
|
|
23381
23410
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
23382
23411
|
}
|
|
@@ -23724,7 +23753,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23724
23753
|
*/
|
|
23725
23754
|
listInventory(query = {}, now = Date.now()) {
|
|
23726
23755
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
23727
|
-
const
|
|
23756
|
+
const offset = pageOffset(query.offset);
|
|
23757
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
23728
23758
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
23729
23759
|
const rows = allRows(
|
|
23730
23760
|
this.db.prepare(
|
|
@@ -23738,11 +23768,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
23738
23768
|
FROM secret_vault v
|
|
23739
23769
|
${where}
|
|
23740
23770
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
23741
|
-
LIMIT :limit`
|
|
23771
|
+
LIMIT :limit OFFSET :offset`
|
|
23742
23772
|
),
|
|
23743
23773
|
bindParams({
|
|
23744
23774
|
now,
|
|
23745
23775
|
limit: limit + 1,
|
|
23776
|
+
offset,
|
|
23746
23777
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
23747
23778
|
})
|
|
23748
23779
|
);
|
|
@@ -23766,7 +23797,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23766
23797
|
*/
|
|
23767
23798
|
listReuse(query = {}, now = Date.now()) {
|
|
23768
23799
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
23769
|
-
const
|
|
23800
|
+
const offset = pageOffset(query.offset);
|
|
23801
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
23770
23802
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
23771
23803
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
23772
23804
|
const rows = allRows(
|
|
@@ -23781,11 +23813,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
23781
23813
|
FROM secret_vault v
|
|
23782
23814
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
23783
23815
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
23784
|
-
LIMIT :limit`
|
|
23816
|
+
LIMIT :limit OFFSET :offset`
|
|
23785
23817
|
),
|
|
23786
23818
|
bindParams({
|
|
23787
23819
|
now,
|
|
23788
23820
|
limit: limit + 1,
|
|
23821
|
+
offset,
|
|
23789
23822
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
23790
23823
|
})
|
|
23791
23824
|
);
|
|
@@ -23810,7 +23843,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23810
23843
|
*/
|
|
23811
23844
|
listDerefs(query = {}) {
|
|
23812
23845
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
23813
|
-
const
|
|
23846
|
+
const offset = pageOffset(query.offset);
|
|
23847
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
23814
23848
|
const conditions = [];
|
|
23815
23849
|
if (query.includeBatched !== true) {
|
|
23816
23850
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -23823,21 +23857,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
23823
23857
|
this.db.prepare(
|
|
23824
23858
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
23825
23859
|
FROM secret_vault_deref ${where}
|
|
23826
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
23860
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
23827
23861
|
),
|
|
23828
23862
|
bindParams({
|
|
23829
23863
|
limit: limit + 1,
|
|
23864
|
+
offset,
|
|
23830
23865
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
23831
23866
|
})
|
|
23832
23867
|
);
|
|
23833
23868
|
const hasMore = rows.length > limit;
|
|
23834
23869
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
23835
23870
|
const last = page[page.length - 1];
|
|
23836
|
-
const
|
|
23837
|
-
this.db
|
|
23838
|
-
|
|
23839
|
-
|
|
23871
|
+
const counts = getRow(
|
|
23872
|
+
this.db.prepare(
|
|
23873
|
+
`SELECT count(*) AS total,
|
|
23874
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
23875
|
+
FROM secret_vault_deref`
|
|
23876
|
+
)
|
|
23877
|
+
) ?? { total: 0, hidden: 0 };
|
|
23878
|
+
const includeBatched = query.includeBatched === true;
|
|
23879
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
23840
23880
|
return {
|
|
23881
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
23841
23882
|
items: page.map((r) => ({
|
|
23842
23883
|
id: r.id,
|
|
23843
23884
|
pointerId: r.pointer_id,
|
|
@@ -30387,7 +30428,7 @@ function shippedRegexMatchers() {
|
|
|
30387
30428
|
}
|
|
30388
30429
|
|
|
30389
30430
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30390
|
-
import { existsSync as existsSync9,
|
|
30431
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30391
30432
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30392
30433
|
function remoteWithoutCredentials(remote) {
|
|
30393
30434
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -30421,6 +30462,7 @@ function unparsedWithoutCredentials(remote) {
|
|
|
30421
30462
|
return `${scheme}${tail.split(/[?#]/, 1)[0] ?? ""}`;
|
|
30422
30463
|
}
|
|
30423
30464
|
var NO_ATTRIBUTION = Object.freeze({});
|
|
30465
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30424
30466
|
|
|
30425
30467
|
// ../../packages/plugin-sdk/src/data-gateway.ts
|
|
30426
30468
|
function offersCaptureStatusReader(gateway) {
|
|
@@ -32010,7 +32052,7 @@ function sessionToolIsKeyed(tool) {
|
|
|
32010
32052
|
|
|
32011
32053
|
// ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
|
|
32012
32054
|
import { createHash as createHash11 } from "crypto";
|
|
32013
|
-
import { readFileSync as
|
|
32055
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
32014
32056
|
import { join as join28 } from "path";
|
|
32015
32057
|
|
|
32016
32058
|
// ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
|
|
@@ -32110,7 +32152,7 @@ async function publishByRename(tmp, file, move = rename2) {
|
|
|
32110
32152
|
|
|
32111
32153
|
// ../../packages/plugin-runtime/src/attached/capture-settings.ts
|
|
32112
32154
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
32113
|
-
import { readFileSync as
|
|
32155
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
32114
32156
|
import { rm, writeFile as writeFile2 } from "fs/promises";
|
|
32115
32157
|
import { join as join26 } from "path";
|
|
32116
32158
|
var HookCaptureSettingsSchema = CaptureSettings.pick({
|
|
@@ -32498,7 +32540,7 @@ function reportKey(request) {
|
|
|
32498
32540
|
function readStagedEntries(dataDir2) {
|
|
32499
32541
|
let parsed2;
|
|
32500
32542
|
try {
|
|
32501
|
-
parsed2 = JSON.parse(
|
|
32543
|
+
parsed2 = JSON.parse(readFileSync17(stagedConfigInventoryPath(dataDir2), "utf8"));
|
|
32502
32544
|
} catch {
|
|
32503
32545
|
return [];
|
|
32504
32546
|
}
|
|
@@ -32522,7 +32564,7 @@ function isTimestamp(value) {
|
|
|
32522
32564
|
}
|
|
32523
32565
|
|
|
32524
32566
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
32525
|
-
import { readFileSync as
|
|
32567
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
32526
32568
|
import { join as join29 } from "path";
|
|
32527
32569
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
32528
32570
|
function forwardDropsPath(dataDir2) {
|
|
@@ -32544,7 +32586,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
|
|
|
32544
32586
|
}
|
|
32545
32587
|
function readForwardDrops(dataDir2) {
|
|
32546
32588
|
try {
|
|
32547
|
-
const parsed2 = JSON.parse(
|
|
32589
|
+
const parsed2 = JSON.parse(readFileSync18(forwardDropsPath(dataDir2), "utf8"));
|
|
32548
32590
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
32549
32591
|
const record2 = parsed2;
|
|
32550
32592
|
if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
|
|
@@ -33648,7 +33690,7 @@ function toWireInspection(insp, nameKey) {
|
|
|
33648
33690
|
}
|
|
33649
33691
|
|
|
33650
33692
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
33651
|
-
import { readFileSync as
|
|
33693
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
33652
33694
|
|
|
33653
33695
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
33654
33696
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
@@ -33721,7 +33763,7 @@ async function readInstalledVersionBounded(installRoot) {
|
|
|
33721
33763
|
}
|
|
33722
33764
|
|
|
33723
33765
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
33724
|
-
import { readFileSync as
|
|
33766
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
33725
33767
|
import { join as join31 } from "path";
|
|
33726
33768
|
var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
|
|
33727
33769
|
var OUTCOME_KEYS = {
|
|
@@ -33997,11 +34039,11 @@ function createPostureStore(dir = settingsDir(), legacyDir) {
|
|
|
33997
34039
|
}
|
|
33998
34040
|
|
|
33999
34041
|
// ../../packages/plugin-runtime/src/attached/label-drops.ts
|
|
34000
|
-
import { readFileSync as
|
|
34042
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
34001
34043
|
import { join as join33 } from "path";
|
|
34002
34044
|
|
|
34003
34045
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
34004
|
-
import { readFileSync as
|
|
34046
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
34005
34047
|
import { join as join34 } from "path";
|
|
34006
34048
|
|
|
34007
34049
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
@@ -34323,7 +34365,7 @@ var RANK = Object.fromEntries(
|
|
|
34323
34365
|
);
|
|
34324
34366
|
|
|
34325
34367
|
// ../../packages/setup-wizard/src/triage/plan-file.ts
|
|
34326
|
-
import { mkdtempSync, readFileSync as
|
|
34368
|
+
import { mkdtempSync, readFileSync as readFileSync23, rmdirSync, rmSync as rmSync11, writeFileSync as writeFileSync6 } from "fs";
|
|
34327
34369
|
import { tmpdir } from "os";
|
|
34328
34370
|
import { basename as basename5, dirname as dirname10, join as join37 } from "path";
|
|
34329
34371
|
var SuppressionEntrySchema = object({
|
|
@@ -34367,7 +34409,7 @@ var PersistedPlanSchema = object({
|
|
|
34367
34409
|
});
|
|
34368
34410
|
|
|
34369
34411
|
// src/skills-registry.ts
|
|
34370
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
34412
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync24 } from "fs";
|
|
34371
34413
|
import { join as join38 } from "path";
|
|
34372
34414
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
34373
34415
|
var SKILLS_DIR = fileURLToPath5(new URL("../skills", import.meta.url));
|
package/scripts/reconcile.js
CHANGED
|
@@ -8783,7 +8783,11 @@ var ListFindingTypesQuery = object({
|
|
|
8783
8783
|
// and so is not bounded by what any page happens to hold.
|
|
8784
8784
|
includeId: string2().optional(),
|
|
8785
8785
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8786
|
-
cursor: string2().optional()
|
|
8786
|
+
cursor: string2().optional(),
|
|
8787
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8788
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8789
|
+
// from wherever it lands.
|
|
8790
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8787
8791
|
});
|
|
8788
8792
|
var ListFindingTypesResponse = object({
|
|
8789
8793
|
totals: object({
|
|
@@ -8864,7 +8868,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8864
8868
|
sessionId: string2().optional(),
|
|
8865
8869
|
from: iso_exports.datetime().optional(),
|
|
8866
8870
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8867
|
-
cursor: string2().optional()
|
|
8871
|
+
cursor: string2().optional(),
|
|
8872
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8873
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8874
|
+
// from wherever it lands.
|
|
8875
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8868
8876
|
});
|
|
8869
8877
|
var ListFindingInstancesResponse = object({
|
|
8870
8878
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8936,7 +8944,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8936
8944
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8937
8945
|
includeId: string2().optional(),
|
|
8938
8946
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8939
|
-
cursor: string2().optional()
|
|
8947
|
+
cursor: string2().optional(),
|
|
8948
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8949
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8950
|
+
// from wherever it lands.
|
|
8951
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8940
8952
|
});
|
|
8941
8953
|
var ListFindingLocationsResponse = object({
|
|
8942
8954
|
totals: object({
|
|
@@ -11568,7 +11580,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11568
11580
|
var ListVaultInventoryQuery = object({
|
|
11569
11581
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11570
11582
|
// Opaque; names the last row of the page just served.
|
|
11571
|
-
cursor: string2().optional()
|
|
11583
|
+
cursor: string2().optional(),
|
|
11584
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11585
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11586
|
+
// from wherever it lands.
|
|
11587
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11572
11588
|
});
|
|
11573
11589
|
var ListVaultInventoryResponse = object({
|
|
11574
11590
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11580,7 +11596,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11580
11596
|
});
|
|
11581
11597
|
var ListVaultReuseQuery = object({
|
|
11582
11598
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11583
|
-
cursor: string2().optional()
|
|
11599
|
+
cursor: string2().optional(),
|
|
11600
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11601
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11602
|
+
// from wherever it lands.
|
|
11603
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11584
11604
|
});
|
|
11585
11605
|
var ListVaultReuseResponse = object({
|
|
11586
11606
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11596,9 +11616,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11596
11616
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11597
11617
|
includeBatched: boolean2().optional(),
|
|
11598
11618
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11599
|
-
cursor: string2().optional()
|
|
11619
|
+
cursor: string2().optional(),
|
|
11620
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11621
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11622
|
+
// from wherever it lands.
|
|
11623
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11600
11624
|
});
|
|
11601
11625
|
var ListVaultDerefsResponse = object({
|
|
11626
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11627
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11602
11628
|
items: array(VaultDeref),
|
|
11603
11629
|
nextCursor: string2().nullable(),
|
|
11604
11630
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -25107,7 +25133,7 @@ var SqliteFindingsRepository = class {
|
|
|
25107
25133
|
};
|
|
25108
25134
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
25109
25135
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
25110
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
25136
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
25111
25137
|
const page = sorted.slice(start, start + limit);
|
|
25112
25138
|
const lastOnPage = page.at(-1);
|
|
25113
25139
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -25201,7 +25227,7 @@ var SqliteFindingsRepository = class {
|
|
|
25201
25227
|
accumulator.add(row);
|
|
25202
25228
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
25203
25229
|
total += 1;
|
|
25204
|
-
if (!isPastCursor(row)) continue;
|
|
25230
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
25205
25231
|
if (items.length < limit) {
|
|
25206
25232
|
items.push(toInstanceDetail(row));
|
|
25207
25233
|
last = row;
|
|
@@ -25290,7 +25316,7 @@ var SqliteFindingsRepository = class {
|
|
|
25290
25316
|
}
|
|
25291
25317
|
}
|
|
25292
25318
|
sorted.sort(compareLocationOrder);
|
|
25293
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
25319
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
25294
25320
|
const page = sorted.slice(start, start + limit);
|
|
25295
25321
|
const lastOnPage = page.at(-1);
|
|
25296
25322
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -27918,6 +27944,9 @@ function pageLimit(requested, fallback) {
|
|
|
27918
27944
|
if (requested === void 0) return fallback;
|
|
27919
27945
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
27920
27946
|
}
|
|
27947
|
+
function pageOffset(requested) {
|
|
27948
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
27949
|
+
}
|
|
27921
27950
|
function encodeReuseCursor(payload) {
|
|
27922
27951
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27923
27952
|
}
|
|
@@ -28265,7 +28294,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28265
28294
|
*/
|
|
28266
28295
|
listInventory(query = {}, now = Date.now()) {
|
|
28267
28296
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28268
|
-
const
|
|
28297
|
+
const offset = pageOffset(query.offset);
|
|
28298
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28269
28299
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
28270
28300
|
const rows = allRows(
|
|
28271
28301
|
this.db.prepare(
|
|
@@ -28279,11 +28309,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28279
28309
|
FROM secret_vault v
|
|
28280
28310
|
${where}
|
|
28281
28311
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
28282
|
-
LIMIT :limit`
|
|
28312
|
+
LIMIT :limit OFFSET :offset`
|
|
28283
28313
|
),
|
|
28284
28314
|
bindParams({
|
|
28285
28315
|
now,
|
|
28286
28316
|
limit: limit + 1,
|
|
28317
|
+
offset,
|
|
28287
28318
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
28288
28319
|
})
|
|
28289
28320
|
);
|
|
@@ -28307,7 +28338,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28307
28338
|
*/
|
|
28308
28339
|
listReuse(query = {}, now = Date.now()) {
|
|
28309
28340
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28310
|
-
const
|
|
28341
|
+
const offset = pageOffset(query.offset);
|
|
28342
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
28311
28343
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
28312
28344
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
28313
28345
|
const rows = allRows(
|
|
@@ -28322,11 +28354,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28322
28354
|
FROM secret_vault v
|
|
28323
28355
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
28324
28356
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
28325
|
-
LIMIT :limit`
|
|
28357
|
+
LIMIT :limit OFFSET :offset`
|
|
28326
28358
|
),
|
|
28327
28359
|
bindParams({
|
|
28328
28360
|
now,
|
|
28329
28361
|
limit: limit + 1,
|
|
28362
|
+
offset,
|
|
28330
28363
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
28331
28364
|
})
|
|
28332
28365
|
);
|
|
@@ -28351,7 +28384,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28351
28384
|
*/
|
|
28352
28385
|
listDerefs(query = {}) {
|
|
28353
28386
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
28354
|
-
const
|
|
28387
|
+
const offset = pageOffset(query.offset);
|
|
28388
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28355
28389
|
const conditions = [];
|
|
28356
28390
|
if (query.includeBatched !== true) {
|
|
28357
28391
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -28364,21 +28398,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
28364
28398
|
this.db.prepare(
|
|
28365
28399
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
28366
28400
|
FROM secret_vault_deref ${where}
|
|
28367
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
28401
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
28368
28402
|
),
|
|
28369
28403
|
bindParams({
|
|
28370
28404
|
limit: limit + 1,
|
|
28405
|
+
offset,
|
|
28371
28406
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
28372
28407
|
})
|
|
28373
28408
|
);
|
|
28374
28409
|
const hasMore = rows.length > limit;
|
|
28375
28410
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
28376
28411
|
const last = page[page.length - 1];
|
|
28377
|
-
const
|
|
28378
|
-
this.db
|
|
28379
|
-
|
|
28380
|
-
|
|
28412
|
+
const counts = getRow(
|
|
28413
|
+
this.db.prepare(
|
|
28414
|
+
`SELECT count(*) AS total,
|
|
28415
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
28416
|
+
FROM secret_vault_deref`
|
|
28417
|
+
)
|
|
28418
|
+
) ?? { total: 0, hidden: 0 };
|
|
28419
|
+
const includeBatched = query.includeBatched === true;
|
|
28420
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
28381
28421
|
return {
|
|
28422
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
28382
28423
|
items: page.map((r) => ({
|
|
28383
28424
|
id: r.id,
|
|
28384
28425
|
pointerId: r.pointer_id,
|
|
@@ -30741,8 +30782,25 @@ function scanText2(text2, ruleVersions, options = {}) {
|
|
|
30741
30782
|
}
|
|
30742
30783
|
}
|
|
30743
30784
|
|
|
30785
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
30786
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
30787
|
+
function notRegularFile(path) {
|
|
30788
|
+
return `not a regular file: ${path}`;
|
|
30789
|
+
}
|
|
30790
|
+
function readRegularFile(path, maxBytes) {
|
|
30791
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
30792
|
+
try {
|
|
30793
|
+
const stat2 = fstatSync(fd);
|
|
30794
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
30795
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
30796
|
+
return readFileSync16(fd, "utf8");
|
|
30797
|
+
} finally {
|
|
30798
|
+
closeSync2(fd);
|
|
30799
|
+
}
|
|
30800
|
+
}
|
|
30801
|
+
|
|
30744
30802
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30745
|
-
import { existsSync as existsSync9,
|
|
30803
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30746
30804
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30747
30805
|
function remoteWithoutCredentials(remote) {
|
|
30748
30806
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -30846,9 +30904,10 @@ function resolveGitContext(root) {
|
|
|
30846
30904
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
30847
30905
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
30848
30906
|
}
|
|
30907
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30849
30908
|
function safeRead(path) {
|
|
30850
30909
|
try {
|
|
30851
|
-
return
|
|
30910
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
30852
30911
|
} catch {
|
|
30853
30912
|
return void 0;
|
|
30854
30913
|
}
|
|
@@ -34637,21 +34696,21 @@ function chatgptKey(accountId) {
|
|
|
34637
34696
|
|
|
34638
34697
|
// ../../packages/plugin-sdk/src/account/observation-log.ts
|
|
34639
34698
|
import { createHash as createHash12 } from "crypto";
|
|
34640
|
-
import { closeSync as
|
|
34699
|
+
import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, mkdirSync as mkdirSync2, openSync as openSync3, readSync, writeSync } from "fs";
|
|
34641
34700
|
import { join as join34 } from "path";
|
|
34642
34701
|
var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
|
|
34643
34702
|
var SESSION_LOG_TAIL_BYTES = 64 * 1024;
|
|
34644
34703
|
var NEWLINE = 10;
|
|
34645
34704
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
34646
34705
|
function sessionLogOpenFlags(noFollow) {
|
|
34647
|
-
return
|
|
34706
|
+
return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
|
|
34648
34707
|
}
|
|
34649
34708
|
var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
|
|
34650
|
-
|
|
34709
|
+
constants2.O_NOFOLLOW
|
|
34651
34710
|
);
|
|
34652
34711
|
function closeQuietly2(fd) {
|
|
34653
34712
|
try {
|
|
34654
|
-
|
|
34713
|
+
closeSync3(fd);
|
|
34655
34714
|
} catch {
|
|
34656
34715
|
}
|
|
34657
34716
|
}
|
|
@@ -34687,12 +34746,12 @@ function parseLines(buffer, base) {
|
|
|
34687
34746
|
function readRange(path, from, capBytes) {
|
|
34688
34747
|
let fd;
|
|
34689
34748
|
try {
|
|
34690
|
-
fd =
|
|
34749
|
+
fd = openSync3(path, "r");
|
|
34691
34750
|
} catch {
|
|
34692
34751
|
return void 0;
|
|
34693
34752
|
}
|
|
34694
34753
|
try {
|
|
34695
|
-
const size =
|
|
34754
|
+
const size = fstatSync2(fd).size;
|
|
34696
34755
|
const length = Math.max(0, Math.min(size, capBytes) - from);
|
|
34697
34756
|
const buffer = Buffer.alloc(length);
|
|
34698
34757
|
let filled = 0;
|
|
@@ -34739,7 +34798,7 @@ function classifyObservation(observation) {
|
|
|
34739
34798
|
}
|
|
34740
34799
|
|
|
34741
34800
|
// ../../packages/plugin-sdk/src/account/codex-head.ts
|
|
34742
|
-
import { closeSync as
|
|
34801
|
+
import { closeSync as closeSync4, openSync as openSync4, readSync as readSync2 } from "fs";
|
|
34743
34802
|
var CODEX_HEAD_READ_BYTES = 64 * 1024;
|
|
34744
34803
|
var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
|
|
34745
34804
|
var NEWLINE2 = 10;
|
|
@@ -34772,7 +34831,7 @@ function parseHead(line) {
|
|
|
34772
34831
|
function readCodexHead(rolloutPath) {
|
|
34773
34832
|
let fd;
|
|
34774
34833
|
try {
|
|
34775
|
-
fd =
|
|
34834
|
+
fd = openSync4(rolloutPath, "r");
|
|
34776
34835
|
} catch (error2) {
|
|
34777
34836
|
return isNotFound(error2) ? "pending" : void 0;
|
|
34778
34837
|
}
|
|
@@ -34797,7 +34856,7 @@ function readCodexHead(rolloutPath) {
|
|
|
34797
34856
|
return void 0;
|
|
34798
34857
|
} finally {
|
|
34799
34858
|
try {
|
|
34800
|
-
|
|
34859
|
+
closeSync4(fd);
|
|
34801
34860
|
} catch {
|
|
34802
34861
|
}
|
|
34803
34862
|
}
|
|
@@ -35070,10 +35129,10 @@ function codexLeafStamper(gateway, dataDir2, sessionId, transcriptPath) {
|
|
|
35070
35129
|
// src/history/tail.ts
|
|
35071
35130
|
import { createHash as createHash13 } from "crypto";
|
|
35072
35131
|
import {
|
|
35073
|
-
closeSync as
|
|
35074
|
-
fstatSync as
|
|
35132
|
+
closeSync as closeSync5,
|
|
35133
|
+
fstatSync as fstatSync3,
|
|
35075
35134
|
mkdirSync as mkdirSync3,
|
|
35076
|
-
openSync as
|
|
35135
|
+
openSync as openSync5,
|
|
35077
35136
|
readFileSync as readFileSync24,
|
|
35078
35137
|
readSync as readSync3,
|
|
35079
35138
|
writeFileSync as writeFileSync5
|
|
@@ -35119,12 +35178,12 @@ function writeOffset(dataDir2, sessionId, value) {
|
|
|
35119
35178
|
function readTail(transcriptPath, startOffset) {
|
|
35120
35179
|
let fd;
|
|
35121
35180
|
try {
|
|
35122
|
-
fd =
|
|
35181
|
+
fd = openSync5(transcriptPath, "r");
|
|
35123
35182
|
} catch {
|
|
35124
35183
|
return { chunk: "", nextOffset: startOffset };
|
|
35125
35184
|
}
|
|
35126
35185
|
try {
|
|
35127
|
-
const size =
|
|
35186
|
+
const size = fstatSync3(fd).size;
|
|
35128
35187
|
const from = size < startOffset ? 0 : startOffset;
|
|
35129
35188
|
if (from >= size) return { chunk: "", nextOffset: from };
|
|
35130
35189
|
const length = size - from;
|
|
@@ -35145,7 +35204,7 @@ function readTail(transcriptPath, startOffset) {
|
|
|
35145
35204
|
return { chunk: "", nextOffset: startOffset };
|
|
35146
35205
|
} finally {
|
|
35147
35206
|
try {
|
|
35148
|
-
|
|
35207
|
+
closeSync5(fd);
|
|
35149
35208
|
} catch {
|
|
35150
35209
|
}
|
|
35151
35210
|
}
|